diff options
Diffstat (limited to 'executive-summary/widgets')
-rw-r--r-- | executive-summary/widgets/Makefile.am | 32 | ||||
-rw-r--r-- | executive-summary/widgets/e-summary-subwindow.c | 299 | ||||
-rw-r--r-- | executive-summary/widgets/e-summary-subwindow.h | 68 | ||||
-rw-r--r-- | executive-summary/widgets/e-summary-title-button.c | 403 | ||||
-rw-r--r-- | executive-summary/widgets/e-summary-title-button.h | 54 | ||||
-rw-r--r-- | executive-summary/widgets/e-summary-titlebar.c | 412 | ||||
-rw-r--r-- | executive-summary/widgets/e-summary-titlebar.h | 56 | ||||
-rw-r--r-- | executive-summary/widgets/edit.xpm | 19 | ||||
-rw-r--r-- | executive-summary/widgets/esummary-window-test.c | 43 | ||||
-rw-r--r-- | executive-summary/widgets/shade.xpm | 19 | ||||
-rw-r--r-- | executive-summary/widgets/x.xpm | 19 |
11 files changed, 1424 insertions, 0 deletions
diff --git a/executive-summary/widgets/Makefile.am b/executive-summary/widgets/Makefile.am new file mode 100644 index 0000000000..f83d956d63 --- /dev/null +++ b/executive-summary/widgets/Makefile.am @@ -0,0 +1,32 @@ +INCLUDES = \ + -I$(top_srcdir) \ + -I$(includedir) \ + $(GNOME_INCLUDEDIR) \ + -DG_LOG_DOMAIN=\"Executive-Summary-Widgets\" \ + -g \ + -Wall \ + -Wmissing-prototypes \ + -Wmissing-declarations + +noinst_LIBRARIES = libesummary-widgets.a + +libesummary_widgets_a_SOURCES = \ + e-summary-subwindow.c \ + e-summary-subwindow.h \ + e-summary-titlebar.c \ + e-summary-titlebar.h \ + e-summary-title-button.c \ + e-summary-title-button.h + +noinst_PROGRAMS = \ + esummary-window-test + +esummary_window_test_SOURCES = \ + esummary-window-test.c + +esummary_window_test_LDADD = \ + $(EXTRA_GNOME_LIBS) \ + libesummary-widgets.a \ + $(BONOBO_GNOME_LIBS) \ + $(top_builddir)/e-util/libeutil.la + diff --git a/executive-summary/widgets/e-summary-subwindow.c b/executive-summary/widgets/e-summary-subwindow.c new file mode 100644 index 0000000000..bf5bcb1eba --- /dev/null +++ b/executive-summary/widgets/e-summary-subwindow.c @@ -0,0 +1,299 @@ +/* -*- Mode: C; indent-tabs-mode: t; c-basic-offset: 8; tab-width: 8 -*- */ +/* e-summary.c + * + * Authors: Iain Holmes <iain@helixcode.com> + * + * Copyright (C) 2000 Helix Code, Inc. + * + * This program is free software; you can redistribute it and/or + * modify it under the terms of the GNU General Public License as + * published by the Free Software Foundation; either version 2 of the + * License, or (at your option) any later version. + * + * This program is distributed in the hope that it will be useful, + * but WITHOUT ANY WARRANTY; without even the implied warranty of + * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU + * General Public License for more details. + * + * You should have received a copy of the GNU General Public + * License along with this program; if not, write to the + * Free Software Foundation, Inc., 59 Temple Place - Suite 330, + * Boston, MA 02111-1307, USA. + */ + +#ifdef HAVE_CONFIG_H +#include <config.h> +#endif + +#include <gnome.h> +#include <gal/util/e-util.h> +#include <gal/widgets/e-font.h> + +#include <gal/e-text/e-text.h> + +#include "e-summary-subwindow.h" + +#define PARENT_TYPE (gnome_canvas_group_get_type ()) +#define TITLEBAR_BORDER_WIDTH 2 + +static void e_summary_subwindow_destroy (GtkObject *object); +static void e_summary_subwindow_class_init (GtkObjectClass *object_class); +static void e_summary_subwindow_init (GtkObject *object); + +static GnomeCanvasGroupClass *parent_class; + +struct _ESummarySubwindowPrivate { + GnomeCanvasItem *titlebar; + GnomeCanvasItem *contents; + + GtkWidget *container; + + char *title; +}; + +enum { + ARG_0, + ARG_X, + ARG_Y, + ARG_WIDTH, + ARG_HEIGHT, + ARG_STATE +}; + +enum { + CLOSE_CLICKED, + SHADE_CLICKED, + EDIT_CLICKED, + LAST_SIGNAL +}; + +static guint32 e_summary_subwindow_signals[LAST_SIGNAL] = { 0 }; + +static void +e_summary_subwindow_destroy (GtkObject *object) +{ + ESummarySubwindow *subwindow = E_SUMMARY_SUBWINDOW (object); + ESummarySubwindowPrivate *priv; + + priv = subwindow->private; + + if (priv == NULL) + return; + + if (priv->container) { + gtk_widget_destroy (priv->container); + priv->container = NULL; + } + + if (priv->title) { + g_free (priv->title); + priv->title = NULL; + } + + g_free (subwindow->private); + subwindow->private = NULL; + + if (GTK_OBJECT_CLASS (parent_class)->destroy) + (* GTK_OBJECT_CLASS (parent_class)->destroy) (object); +} + +static void +e_summary_subwindow_realize (GnomeCanvasItem *item) +{ + if (GNOME_CANVAS_ITEM_CLASS (parent_class)->realize) + (* GNOME_CANVAS_ITEM_CLASS (parent_class)->realize) (item); +} + +static void +e_summary_subwindow_unrealize (GnomeCanvasItem *item) +{ + if (GNOME_CANVAS_ITEM_CLASS (parent_class)->unrealize) + (* GNOME_CANVAS_ITEM_CLASS (parent_class)->unrealize) (item); +} + +static void +e_summary_subwindow_class_init (GtkObjectClass *object_class) +{ + GnomeCanvasItemClass *item_class; + + item_class = (GnomeCanvasItemClass *) object_class; + + object_class->destroy = e_summary_subwindow_destroy; + + item_class->realize = e_summary_subwindow_realize; + item_class->unrealize = e_summary_subwindow_unrealize; + + parent_class = gtk_type_class (PARENT_TYPE); +} + +static void +e_summary_subwindow_init (GtkObject *object) +{ + ESummarySubwindow *subwindow = E_SUMMARY_SUBWINDOW (object); + ESummarySubwindowPrivate *priv; + + subwindow->private = g_new0 (ESummarySubwindowPrivate, 1); + priv = subwindow->private; + + priv->title = NULL; +} + +E_MAKE_TYPE (e_summary_subwindow, "ESummarySubwindow", ESummarySubwindow, + e_summary_subwindow_class_init, e_summary_subwindow_init, + PARENT_TYPE); + +static void +container_size_allocate (GtkWidget *widget, + GtkAllocation *allocation, + ESummarySubwindow *subwindow) +{ + ESummarySubwindowPrivate *priv; + + g_return_if_fail (subwindow != NULL); + g_return_if_fail (IS_E_SUMMARY_SUBWINDOW (subwindow)); + + priv = subwindow->private; + + gnome_canvas_item_set (priv->titlebar, + "width", (double) allocation->width - 1, + NULL); + +} + +static void +edit_cb (GnomeCanvasItem *item, + ESummarySubwindow *subwindow) +{ + g_print ("EDIT!\n"); +} + +static void +shade_cb (GnomeCanvasItem *item, + ESummarySubwindow *subwindow) +{ + g_print ("SHADE!\n"); +} + +static void +close_cb (GnomeCanvasItem *item, + ESummarySubwindow *subwindow) +{ + g_print ("CLOSE!\n"); + gtk_object_destroy (GTK_OBJECT (subwindow)); +} + +void +e_summary_subwindow_construct (GnomeCanvasItem *item) +{ + GnomeCanvasGroup *group; + ESummarySubwindow *subwindow; + ESummarySubwindowPrivate *priv; + EFont *font; + int titlebar_height; + + g_return_if_fail (item != NULL); + g_return_if_fail (IS_E_SUMMARY_SUBWINDOW (item)); + + subwindow = E_SUMMARY_SUBWINDOW (item); + priv = subwindow->private; + + group = GNOME_CANVAS_GROUP (item); + + font = e_font_from_gdk_font ( ((GtkWidget *) item->canvas)->style->font); + + titlebar_height = 18 + 2 * TITLEBAR_BORDER_WIDTH; /* FIXME: Not hardcoded */ + + priv->titlebar = gnome_canvas_item_new (group, + e_summary_titlebar_get_type (), + "text", "Titlebar", + "width", 100.0, + NULL); + gtk_signal_connect (GTK_OBJECT (priv->titlebar), "edit", + GTK_SIGNAL_FUNC (edit_cb), subwindow); + gtk_signal_connect (GTK_OBJECT (priv->titlebar), "shade", + GTK_SIGNAL_FUNC (shade_cb), subwindow); + gtk_signal_connect (GTK_OBJECT (priv->titlebar), "close", + GTK_SIGNAL_FUNC (close_cb), subwindow); + + priv->container = gtk_frame_new (NULL); + gtk_frame_set_shadow_type (GTK_FRAME (priv->container), GTK_SHADOW_ETCHED_IN); + gtk_widget_show (priv->container); + + priv->contents = gnome_canvas_item_new (group, + gnome_canvas_widget_get_type (), + "x", (double) 0, + "y", (double) titlebar_height + 1, + "widget", priv->container, + NULL); + gtk_signal_connect (GTK_OBJECT (priv->container), "size_allocate", + GTK_SIGNAL_FUNC (container_size_allocate), subwindow); + +} + +GnomeCanvasItem * +e_summary_subwindow_new (GnomeCanvasGroup *parent, + double x, + double y) +{ + GnomeCanvasItem *item; + + item = gnome_canvas_item_new (parent, e_summary_subwindow_get_type (), + "x", x, + "y", y, + NULL); + e_summary_subwindow_construct (item); + + return item; +} + +/* These functions mimic the GtkContainer methods */ + +void +e_summary_subwindow_add (ESummarySubwindow *subwindow, + GtkWidget *widget) +{ + ESummarySubwindowPrivate *priv; + + g_return_if_fail (subwindow != NULL); + g_return_if_fail (IS_E_SUMMARY_SUBWINDOW (subwindow)); + g_return_if_fail (widget != NULL); + g_return_if_fail (GTK_IS_WIDGET (widget)); + + priv = subwindow->private; + + gtk_container_add (GTK_CONTAINER (priv->container), widget); + +} + +void +e_summary_subwindow_remove (ESummarySubwindow *subwindow, + GtkWidget *widget) +{ + ESummarySubwindowPrivate *priv; + + g_return_if_fail (subwindow != NULL); + g_return_if_fail (IS_E_SUMMARY_SUBWINDOW (subwindow)); + g_return_if_fail (widget != NULL); + g_return_if_fail (GTK_IS_WIDGET (widget)); + + priv = subwindow->private; + + gtk_container_remove (GTK_CONTAINER (priv->container), widget); +} + +void +e_summary_subwindow_set_title (ESummarySubwindow *subwindow, + const char *title) +{ + ESummarySubwindowPrivate *priv; + + g_return_if_fail (subwindow != NULL); + g_return_if_fail (IS_E_SUMMARY_SUBWINDOW (subwindow)); + g_return_if_fail (title != NULL); + + priv = subwindow->private; + if (priv->title) + g_free (priv->title); + + priv->title = g_strdup (title); +} diff --git a/executive-summary/widgets/e-summary-subwindow.h b/executive-summary/widgets/e-summary-subwindow.h new file mode 100644 index 0000000000..daad080a9c --- /dev/null +++ b/executive-summary/widgets/e-summary-subwindow.h @@ -0,0 +1,68 @@ +/* -*- Mode: C; indent-tabs-mode: t; c-basic-offset: 8; tab-width: 8 -*- */ +/* e-summary-subwindow.h + * + * Authors: Iain Holmes <iain@helixcode.com> + * + * Copyright (C) 2000 Helix Code, Inc. + * + * This program is free software; you can redistribute it and/or + * modify it under the terms of the GNU General Public License as + * published by the Free Software Foundation; either version 2 of the + * License, or (at your option) any later version. + * + * This program is distributed in the hope that it will be useful, + * but WITHOUT ANY WARRANTY; without even the implied warranty of + * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU + * General Public License for more details. + * + * You should have received a copy of the GNU General Public + * License along with this program; if not, write to the + * Free Software Foundation, Inc., 59 Temple Place - Suite 330, + * Boston, MA 02111-1307, USA. + */ + +#ifndef _E_SUMMARY_SUBWINDOW_H__ +#define _E_SUMMARY_SUBWINDIW_H__ + +#include <gtk/gtksignal.h> +#include <libgnomeui/gnome-canvas.h> + +#define E_SUMMARY_SUBWINDOW_TYPE (e_summary_subwindow_get_type ()) +#define E_SUMMARY_SUBWINDOW(obj) (GTK_CHECK_CAST ((obj), E_SUMMARY_SUBWINDOW_TYPE, ESummarySubwindow)) +#define E_SUMMARY_SUBWINDOW_CLASS(klass) (GTK_CHECK_CLASS_CAST ((klass), E_SUMMARY_SUBWINDOW_TYPE, ESummarySubwindowClass)) +#define IS_E_SUMMARY_SUBWINDOW(obj) (GTK_CHECK_TYPE ((obj), E_SUMMARY_SUBWINDOW_TYPE)) +#define IS_E_SUMMARY_SUBWINDOW_CLASS(klass) (GTK_CHECK_CLASS_TYPE ((obj), E_SUMMARY_SUBWINDOW_TYPE)) + +typedef struct _ESummarySubwindowPrivate ESummarySubwindowPrivate; +typedef struct _ESummarySubwindow ESummarySubwindow; +typedef struct _ESummarySubwindowClass ESummarySubwindowClass; + +struct _ESummarySubwindow { + GnomeCanvasGroup parent; + + ESummarySubwindowPrivate *private; +}; + +struct _ESummarySubwindowClass { + GnomeCanvasGroupClass parent_class; + + void (*close_clicked) (ESummarySubwindow *window); + void (*shade_clicked) (ESummarySubwindow *window); + void (*edit_clicked) (ESummarySubwindow *window); +}; + +GtkType e_summary_subwindow_get_type (void); + +void e_summary_subwindow_construct (GnomeCanvasItem *subwindow); +GnomeCanvasItem *e_summary_subwindow_new (GnomeCanvasGroup *parent, + double x, + double y); + +void e_summary_subwindow_add (ESummarySubwindow *subwindow, + GtkWidget *widget); +void e_summary_subwindow_remove (ESummarySubwindow *subwindow, + GtkWidget *widget); +void e_summary_subwindow_set_title (ESummarySubwindow *subwindow, + const char *title); + +#endif diff --git a/executive-summary/widgets/e-summary-title-button.c b/executive-summary/widgets/e-summary-title-button.c new file mode 100644 index 0000000000..81fa8e5923 --- /dev/null +++ b/executive-summary/widgets/e-summary-title-button.c @@ -0,0 +1,403 @@ +/* -*- Mode: C; indent-tabs-mode: t; c-basic-offset: 8; tab-width: 8 -*- */ +/* e-summary-title-buttons.c + * + * Authors: Iain Holmes <iain@helixcode.com> + * + * Copyright (C) 2000 Helix Code, Inc. + * + * This program is free software; you can redistribute it and/or + * modify it under the terms of the GNU General Public License as + * published by the Free Software Foundation; either version 2 of the + * License, or (at your option) any later version. + * + * This program is distributed in the hope that it will be useful, + * but WITHOUT ANY WARRANTY; without even the implied warranty of + * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU + * General Public License for more details. + * + * You should have received a copy of the GNU General Public + * License along with this program; if not, write to the + * Free Software Foundation, Inc., 59 Temple Place - Suite 330, + * Boston, MA 02111-1307, USA. + */ + +#ifdef HAVE_CONFIG_H +#include <config.h> +#endif + +#include <gnome.h> +#include <gal/util/e-util.h> + +#include <gdk-pixbuf/gdk-pixbuf.h> + +#include "e-summary-title-button.h" + +#define PARENT_TYPE (gnome_canvas_rect_get_type ()) + +enum { + ARG_0, + ARG_PIXBUF, + ARG_X, + ARG_Y +}; + +enum { + CLICKED, + LAST_SIGNAL +}; + +static void e_summary_title_button_destroy (GtkObject *object); +static void e_summary_title_button_set_arg (GtkObject *object, + GtkArg *arg, + guint arg_id); +static void e_summary_title_button_get_arg (GtkObject *object, + GtkArg *arg, + guint arg_id); +static void e_summary_title_button_class_init (ESummaryTitleButtonClass *estb_class); +static void e_summary_title_button_init (ESummaryTitleButton *estb); +static double e_summary_title_button_point (GnomeCanvasItem *item, + double x, + double y, + int cx, + int cy, + GnomeCanvasItem **actual_item); +static void e_summary_title_button_update (GnomeCanvasItem *item, + double affine[6], + ArtSVP *clip_path, + gint flags); +static void e_summary_title_button_draw (GnomeCanvasItem *item, + GdkDrawable *drawable, + int x, int y, + int width, int height); +static gint e_summary_title_button_event (GnomeCanvasItem *item, + GdkEvent *event); + +static GnomeCanvasRectClass *parent_class; +static guint estb_signals[LAST_SIGNAL] = { 0 }; + +struct _ESummaryTitleButtonPrivate { + GdkPixbuf *pixbuf; + double x, y; + int width, height; + + int in_button : 1; + int button_down : 1; +}; + +static void +e_summary_title_button_destroy (GtkObject *object) +{ + ESummaryTitleButton *estb; + ESummaryTitleButtonPrivate *priv; + + estb = E_SUMMARY_TITLE_BUTTON (object); + priv = estb->private; + + if (priv == NULL) + return; + + gdk_pixbuf_unref (priv->pixbuf); + + g_free (priv); + estb->private = NULL; + + if (GTK_OBJECT_CLASS (parent_class)->destroy) + (* GTK_OBJECT_CLASS (parent_class)->destroy) (object); +} + +static void +e_summary_title_button_set_arg (GtkObject *object, + GtkArg *arg, + guint arg_id) +{ + ESummaryTitleButton *estb; + ESummaryTitleButtonPrivate *priv; + gboolean update = FALSE; + + estb = E_SUMMARY_TITLE_BUTTON (object); + priv = estb->private; + + switch (arg_id) { + case ARG_PIXBUF: + if (priv->pixbuf) + gdk_pixbuf_unref (priv->pixbuf); + + priv->pixbuf = GTK_VALUE_POINTER (*arg); + gdk_pixbuf_ref (priv->pixbuf); + + priv->width = gdk_pixbuf_get_width (priv->pixbuf); + priv->height = gdk_pixbuf_get_height (priv->pixbuf); + + update = TRUE; + break; + + case ARG_X: + priv->x = GTK_VALUE_DOUBLE (*arg); + break; + + case ARG_Y: + priv->y = GTK_VALUE_DOUBLE (*arg); + break; + + default: + break; + + } + + if (update) + gnome_canvas_item_request_update (GNOME_CANVAS_ITEM (estb)); + +} + +static void +e_summary_title_button_get_arg (GtkObject *object, + GtkArg *arg, + guint arg_id) +{ + ESummaryTitleButton *estb; + ESummaryTitleButtonPrivate *priv; + + estb = E_SUMMARY_TITLE_BUTTON (object); + priv = estb->private; + + switch (arg_id) { + case ARG_PIXBUF: + GTK_VALUE_POINTER (*arg) = priv->pixbuf; + break; + + case ARG_X: + GTK_VALUE_DOUBLE (*arg) = priv->x; + break; + + case ARG_Y: + GTK_VALUE_DOUBLE (*arg) = priv->y; + break; + + default: + arg->type = GTK_TYPE_INVALID; + break; + + } +} + +static void +e_summary_title_button_init (ESummaryTitleButton *estb) +{ + estb->private = g_new0 (ESummaryTitleButtonPrivate, 1); +} + +static void +e_summary_title_button_class_init (ESummaryTitleButtonClass *estb_class) +{ + GtkObjectClass *object_class; + GnomeCanvasItemClass *item_class; + + object_class = (GtkObjectClass *) estb_class; + item_class = (GnomeCanvasItemClass *) estb_class; + + object_class->destroy = e_summary_title_button_destroy; + object_class->set_arg = e_summary_title_button_set_arg; + object_class->get_arg = e_summary_title_button_get_arg; + + item_class->draw = e_summary_title_button_draw; + item_class->point = e_summary_title_button_point; + item_class->update = e_summary_title_button_update; + item_class->event = e_summary_title_button_event; + + gtk_object_add_arg_type ("ESummaryTitleButton::pixbuf", + GTK_TYPE_POINTER, + GTK_ARG_READWRITE, + ARG_PIXBUF); + gtk_object_add_arg_type ("ESummaryTitleButton::x", + GTK_TYPE_DOUBLE, + GTK_ARG_READWRITE, + ARG_X); + gtk_object_add_arg_type ("ESummaryTitleButton::y", + GTK_TYPE_DOUBLE, + GTK_ARG_READWRITE, + ARG_Y); + estb_signals[CLICKED] = gtk_signal_new ("clicked", GTK_RUN_LAST, + object_class->type, + GTK_SIGNAL_OFFSET (ESummaryTitleButtonClass, + clicked), + gtk_marshal_NONE__NONE, + GTK_TYPE_NONE, 0); + gtk_object_class_add_signals (object_class, estb_signals, LAST_SIGNAL); + + parent_class = gtk_type_class (PARENT_TYPE); +} + +E_MAKE_TYPE (e_summary_title_button, "ESummaryTitleButton", + ESummaryTitleButton, e_summary_title_button_class_init, + e_summary_title_button_init, PARENT_TYPE); + +static double +e_summary_title_button_point (GnomeCanvasItem *item, + double x, + double y, + int cx, + int cy, + GnomeCanvasItem **actual_item) +{ + ESummaryTitleButton *estb; + ESummaryTitleButtonPrivate *priv; + double d = 1.0; + + estb = E_SUMMARY_TITLE_BUTTON (item); + priv = estb->private; + + if (x >= priv->x && x <= priv->x + gdk_pixbuf_get_width (priv->pixbuf) + && y >= priv->y && y <= priv->y + gdk_pixbuf_get_height (priv->pixbuf)) { + d = 0.0; + *actual_item = item; + } + + return d; +} + +static void +get_bounds (ESummaryTitleButton *estb, + double *px1, double *py1, + double *px2, double *py2) +{ + GnomeCanvasItem *item; + ESummaryTitleButtonPrivate *priv; + double x1, y1, x2, y2; + int cx1, cy1, cx2, cy2; + + item = GNOME_CANVAS_ITEM (estb); + priv = estb->private; + + x1 = priv->x; + y1 = priv->y; + x2 = x1 + priv->width; + y2 = y1 + priv->height; + + gnome_canvas_item_i2w (item, &x1, &y1); + gnome_canvas_item_i2w (item, &x2, &x2); + gnome_canvas_w2c (item->canvas, x1, y1, &cx1, &cy1); + gnome_canvas_w2c (item->canvas, x2, y2, &cx2, &cy2); + + *px1 = cx1; + *py1 = cy1; + *px2 = cx2; + *py2 = cy2; +} + +static void +e_summary_title_button_update (GnomeCanvasItem *item, + double affine[6], + ArtSVP *clip_path, + gint flags) +{ + ESummaryTitleButton *estb; + ESummaryTitleButtonPrivate *priv; + double x1, y1, x2, y2; + + estb = E_SUMMARY_TITLE_BUTTON (item); + priv = estb->private; + + get_bounds (estb, &x1, &y1, &x2, &y2); + gnome_canvas_update_bbox (item, (int) x1, (int) y1, (int) x2, (int) y2); +} + +static void +e_summary_title_button_draw (GnomeCanvasItem *item, + GdkDrawable *drawable, + int x, int y, + int width, int height) +{ + ESummaryTitleButton *estb; + ESummaryTitleButtonPrivate *priv; + double i2w[6], w2c[6], i2c[6]; + int x1, x2, y1, y2; + ArtPoint i1, i2; + ArtPoint c1, c2; + GdkGC *gc; + + estb = E_SUMMARY_TITLE_BUTTON (item); + priv = estb->private; + + if (GNOME_CANVAS_ITEM_CLASS (parent_class)->draw) + (* GNOME_CANVAS_ITEM_CLASS (parent_class)->draw) (item, drawable, x, y, width, height); + + gnome_canvas_item_i2w_affine (item, i2w); + gnome_canvas_w2c_affine (item->canvas, w2c); + art_affine_multiply (i2c, i2w, w2c); + + i1.x = priv->x; + i1.y = priv->y; + i2.x = i1.x + priv->width + 4; + i2.y = i1.y + priv->height + 4; + art_affine_point (&c1, &i1, i2c); + art_affine_point (&c2, &i2, i2c); + x1 = c1.x; + y1 = c1.y; + x2 = c2.x; + y2 = c2.y; + + gc = gdk_gc_new (item->canvas->layout.bin_window); + gdk_draw_rectangle (drawable, gc, + FALSE, x1 - x, + y1 - y, + x2 - x1, + y2 - y1); + gdk_gc_unref (gc); + + gdk_pixbuf_render_to_drawable_alpha (priv->pixbuf, + drawable, + 0, 0, + x1 + 2, y1 + 2, + priv->width, priv->height, + GDK_PIXBUF_ALPHA_BILEVEL, + 127, + GDK_RGB_DITHER_NORMAL, + 0, 0); +} + +static gint +e_summary_title_button_event (GnomeCanvasItem *item, + GdkEvent *event) +{ + ESummaryTitleButton *estb; + ESummaryTitleButtonPrivate *priv; + + estb = E_SUMMARY_TITLE_BUTTON (item); + priv = estb->private; + + switch (event->type) { + case GDK_ENTER_NOTIFY: + priv->in_button = TRUE; + break; + + case GDK_LEAVE_NOTIFY: + priv->in_button = FALSE; + break; + + case GDK_BUTTON_PRESS: + if (priv->in_button) { + priv->button_down = TRUE; + gnome_canvas_item_grab (item, + GDK_LEAVE_NOTIFY_MASK | + GDK_ENTER_NOTIFY_MASK | + GDK_POINTER_MOTION_MASK | + GDK_BUTTON_RELEASE_MASK, + NULL, event->button.time); + } + break; + + case GDK_BUTTON_RELEASE: + priv->button_down = FALSE; + gnome_canvas_item_ungrab (item, event->button.time); + + if (priv->in_button) { + gtk_signal_emit (GTK_OBJECT (estb), estb_signals[CLICKED]); + } + break; + + default: + return TRUE; + } + + return FALSE; +} diff --git a/executive-summary/widgets/e-summary-title-button.h b/executive-summary/widgets/e-summary-title-button.h new file mode 100644 index 0000000000..a99a96815a --- /dev/null +++ b/executive-summary/widgets/e-summary-title-button.h @@ -0,0 +1,54 @@ +/* -*- Mode: C; indent-tabs-mode: t; c-basic-offset: 8; tab-width: 8 -*- */ +/* e-summary-title-button.h + * + * Authors: Iain Holmes <iain@helixcode.com> + * + * Copyright (C) 2000 Helix Code, Inc. + * + * This program is free software; you can redistribute it and/or + * modify it under the terms of the GNU General Public License as + * published by the Free Software Foundation; either version 2 of the + * License, or (at your option) any later version. + * + * This program is distributed in the hope that it will be useful, + * but WITHOUT ANY WARRANTY; without even the implied warranty of + * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU + * General Public License for more details. + * + * You should have received a copy of the GNU General Public + * License along with this program; if not, write to the + * Free Software Foundation, Inc., 59 Temple Place - Suite 330, + * Boston, MA 02111-1307, USA. + */ + +#ifndef _E_SUMMARY_TITLE_BUTTON_H__ +#define _E_SUMMARY_TITLE_BUTTON_H__ + +#include <gtk/gtksignal.h> +#include <libgnomeui/gnome-canvas.h> + +#define E_SUMMARY_TITLE_BUTTON_TYPE (e_summary_title_button_get_type ()) +#define E_SUMMARY_TITLE_BUTTON(obj) (GTK_CHECK_CAST ((obj), E_SUMMARY_TITLE_BUTTON_TYPE, ESummaryTitleButton)) +#define E_SUMMARY_TITLE_BUTTON_CLASS(klass) (GTK_CHECK_CLASS_CAST ((klass), E_SUMMARY_TITLE_BUTTON_TYPE, ESummaryTitleButtonClass)) +#define IS_E_SUMMARY_TITLE_BUTTON(obj) (GTK_CHECK_TYPE ((obj), E_SUMMARY_TITLE_BUTTON_TYPE)) +#define IS_E_SUMMARY_TITLE_BUTTON_CLASS(klass) (GTK_CHECK_CLASS_TYPE ((obj), E_SUMMARY_TITLE_BUTTON_TYPE)) + +typedef struct _ESummaryTitleButtonPrivate ESummaryTitleButtonPrivate; +typedef struct _ESummaryTitleButton ESummaryTitleButton; +typedef struct _ESummaryTitleButtonClass ESummaryTitleButtonClass; + +struct _ESummaryTitleButton { + GnomeCanvasRect parent; + + ESummaryTitleButtonPrivate *private; +}; + +struct _ESummaryTitleButtonClass { + GnomeCanvasRectClass parent_class; + + void (*clicked) (ESummaryTitleButton *estb); +}; + +GtkType e_summary_title_button_get_type (void); + +#endif diff --git a/executive-summary/widgets/e-summary-titlebar.c b/executive-summary/widgets/e-summary-titlebar.c new file mode 100644 index 0000000000..3188b78bf8 --- /dev/null +++ b/executive-summary/widgets/e-summary-titlebar.c @@ -0,0 +1,412 @@ +/* -*- Mode: C; indent-tabs-mode: t; c-basic-offset: 8; tab-width: 8 -*- */ +/* e-summary-titlebar.c + * + * Authors: Iain Holmes <iain@helixcode.com> + * + * Copyright (C) 2000 Helix Code, Inc. + * + * This program is free software; you can redistribute it and/or + * modify it under the terms of the GNU General Public License as + * published by the Free Software Foundation; either version 2 of the + * License, or (at your option) any later version. + * + * This program is distributed in the hope that it will be useful, + * but WITHOUT ANY WARRANTY; without even the implied warranty of + * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU + * General Public License for more details. + * + * You should have received a copy of the GNU General Public + * License along with this program; if not, write to the + * Free Software Foundation, Inc., 59 Temple Place - Suite 330, + * Boston, MA 02111-1307, USA. + */ + +#ifdef HAVE_CONFIG_H +#include <config.h> +#endif + +#include <gnome.h> +#include <gal/util/e-util.h> +#include <gal/widgets/e-font.h> + +#include <gal/e-text/e-text.h> + +#include <gdk-pixbuf/gdk-pixbuf.h> + +#include "e-summary-titlebar.h" +#include "e-summary-title-button.h" + +/* XPMS */ +#include "edit.xpm" +#include "x.xpm" +#include "shade.xpm" + +#define PARENT_TYPE (gnome_canvas_group_get_type ()) +#define TITLEBAR_BORDER_WIDTH 2 + +enum { + ARG_0, + ARG_TEXT, + ARG_WIDTH, + ARG_HEIGHT +}; + +enum { + EDIT, + SHADE, + CLOSE, + LAST_SIGNAL +}; + +static void e_summary_titlebar_destroy (GtkObject *object); +static void e_summary_titlebar_class_init (GtkObjectClass *object_class); +static void e_summary_titlebar_init (GtkObject *object); + +static GnomeCanvasGroupClass *parent_class; +static guint titlebar_signals[LAST_SIGNAL] = { 0 }; + +struct _ESummaryTitlebarPrivate { + GnomeCanvasItem *rect; + GnomeCanvasItem *titletext; + + GnomeCanvasItem *edit; + GnomeCanvasItem *shade; + GnomeCanvasItem *close; + + char *text; + double width, height; +}; + +static void +e_summary_titlebar_destroy (GtkObject *object) +{ + ESummaryTitlebar *titlebar; + ESummaryTitlebarPrivate *priv; + + titlebar = E_SUMMARY_TITLEBAR (object); + priv = titlebar->private; + + if (priv == NULL) + return; + + g_free (priv); + titlebar->private = NULL; + + if (GTK_OBJECT_CLASS (parent_class)->destroy) + (* GTK_OBJECT_CLASS (parent_class)->destroy) (object); +} + +static void +edit_cb (GnomeCanvasItem *item, + ESummaryTitlebar *titlebar) +{ + gtk_signal_emit (GTK_OBJECT (titlebar), titlebar_signals[EDIT]); +} + +static void +shade_cb (GnomeCanvasItem *item, + ESummaryTitlebar *titlebar) +{ + gtk_signal_emit (GTK_OBJECT (titlebar), titlebar_signals[SHADE]); +} + +static void +close_cb (GnomeCanvasItem *item, + ESummaryTitlebar *titlebar) +{ + gtk_signal_emit (GTK_OBJECT (titlebar), titlebar_signals[CLOSE]); +} + +static void +e_summary_titlebar_realize (GnomeCanvasItem *item) +{ + GnomeCanvasGroup *group; + ESummaryTitlebar *titlebar; + ESummaryTitlebarPrivate *priv; + GdkPixbuf *pb; + EFont *font; + int font_height; + + group = GNOME_CANVAS_GROUP (item); + titlebar = E_SUMMARY_TITLEBAR (item); + priv = titlebar->private; + + font = e_font_from_gdk_font (GTK_WIDGET (item->canvas)->style->font); + font_height = e_font_height (font); + priv->height = 18 + 2 * TITLEBAR_BORDER_WIDTH; /* FIXME: Not hardcoded */ + + priv->rect = gnome_canvas_item_new (group, + gnome_canvas_rect_get_type (), + "x1", 0.0, + "y1", 0.0, + "y2", (double) priv->height, + "x2", priv->width, + "fill_color_rgba", 0x88AAFFFF, + NULL); + + pb = gdk_pixbuf_new_from_xpm_data ((const char**) x_xpm); + priv->close = gnome_canvas_item_new (group, + e_summary_title_button_get_type (), + "x", (double) priv->width - TITLEBAR_BORDER_WIDTH - 18, + "y", (double) TITLEBAR_BORDER_WIDTH, + "pixbuf", pb, + NULL); + gdk_pixbuf_unref (pb); + gtk_signal_connect (GTK_OBJECT (priv->close), "clicked", + GTK_SIGNAL_FUNC (close_cb), titlebar); + + pb = gdk_pixbuf_new_from_xpm_data ((const char**) shade_xpm); + priv->shade = gnome_canvas_item_new (group, + e_summary_title_button_get_type (), + "x", (double) priv->width - (TITLEBAR_BORDER_WIDTH * 2) - 36, + "y", (double) TITLEBAR_BORDER_WIDTH, + "pixbuf", pb, + NULL); + gdk_pixbuf_unref (pb); + gtk_signal_connect (GTK_OBJECT (priv->shade), "clicked", + GTK_SIGNAL_FUNC (shade_cb), titlebar); + + pb = gdk_pixbuf_new_from_xpm_data ((const char**) edit_xpm); + priv->edit = gnome_canvas_item_new (group, + e_summary_title_button_get_type (), + "x", (double) priv->width - (TITLEBAR_BORDER_WIDTH * 3) - 54, + "y", (double) TITLEBAR_BORDER_WIDTH, + "pixbuf", pb, + NULL); + gdk_pixbuf_unref (pb); + gtk_signal_connect (GTK_OBJECT (priv->edit), "clicked", + GTK_SIGNAL_FUNC (edit_cb), titlebar); + + priv->titletext = gnome_canvas_item_new (group, + e_text_get_type (), + "text", priv->text, + "font_gdk", GTK_WIDGET (item->canvas)->style->font, + "clip_width", (double) priv->width - + (TITLEBAR_BORDER_WIDTH*4)- 50, + "clip_height", (double) e_font_height (font), + + "clip", TRUE, + "use_ellipsis", TRUE, + "fill_color", "black", + "anchor", GTK_ANCHOR_NW, + NULL); + gnome_canvas_item_move (priv->titletext, TITLEBAR_BORDER_WIDTH, + (priv->height - font_height) / 2); + + if (GNOME_CANVAS_ITEM_CLASS (parent_class)->realize) + (* GNOME_CANVAS_ITEM_CLASS (parent_class)->realize) (item); +} + +static void +e_summary_titlebar_unrealize (GnomeCanvasItem *item) +{ + if (GNOME_CANVAS_ITEM_CLASS (parent_class)->unrealize) + (* GNOME_CANVAS_ITEM_CLASS (parent_class)->unrealize) (item); +} + +static void +e_summary_titlebar_set_arg (GtkObject *object, + GtkArg *arg, + guint arg_id) +{ + ESummaryTitlebar *titlebar; + ESummaryTitlebarPrivate *priv; + + titlebar = E_SUMMARY_TITLEBAR (object); + priv = titlebar->private; + + switch (arg_id) { + case ARG_TEXT: + if (priv->text) + g_free (priv->text); + + priv->text = g_strdup (GTK_VALUE_STRING (*arg)); + + if (priv->titletext) + gnome_canvas_item_set (priv->titletext, + "text", priv->text, + NULL); + break; + + case ARG_WIDTH: + priv->width = GTK_VALUE_DOUBLE (*arg); + + if (priv->rect) + gnome_canvas_item_set (priv->rect, + "x2", priv->width, + NULL); + if (priv->titletext) + gnome_canvas_item_set (priv->titletext, + "clip_width", priv->width - + (TITLEBAR_BORDER_WIDTH* 4) - 42, + NULL); + break; + + default: + break; + } +} + +static void +e_summary_titlebar_get_arg (GtkObject *object, + GtkArg *arg, + guint arg_id) +{ + ESummaryTitlebar *titlebar; + ESummaryTitlebarPrivate *priv; + + titlebar = E_SUMMARY_TITLEBAR (object); + priv = titlebar->private; + + switch (arg_id) { + case ARG_TEXT: + GTK_VALUE_STRING (*arg) = priv->text; + break; + + case ARG_WIDTH: + GTK_VALUE_DOUBLE (*arg) = priv->width; + break; + + case ARG_HEIGHT: + GTK_VALUE_DOUBLE (*arg) = priv->height; + break; + + default: + arg->type = GTK_TYPE_INVALID; + break; + } +} + +static gint +e_summary_titlebar_event (GnomeCanvasItem *item, + GdkEvent *event) +{ + if (event->type == GDK_2BUTTON_PRESS && + event->button.button == 1) { + gtk_signal_emit (GTK_OBJECT (item), titlebar_signals[SHADE]); + return FALSE; + } else { + return TRUE; + } +} + +static double +e_summary_titlebar_point (GnomeCanvasItem *item, + double x, + double y, + int cx, + int cy, + GnomeCanvasItem **actual_item) +{ + ESummaryTitlebar *est; + ESummaryTitlebarPrivate *priv; + GnomeCanvasItem *ret_item; + double d; + + est = E_SUMMARY_TITLEBAR (item); + priv = est->private; + + d = (* GNOME_CANVAS_ITEM_CLASS + (GTK_OBJECT (priv->edit)->klass)->point) (priv->edit, + x, y, + cx, cy, + &ret_item); + if (d == 0.0) { + *actual_item = ret_item; + return 0.0; + } + + d = (* GNOME_CANVAS_ITEM_CLASS + (GTK_OBJECT (priv->shade)->klass)->point) (priv->shade, + x, y, + cx, cy, + &ret_item); + if (d == 0.0) { + *actual_item = ret_item; + return 0.0; + } + + d = (* GNOME_CANVAS_ITEM_CLASS + (GTK_OBJECT (priv->close)->klass)->point) (priv->close, + x, y, + cx, cy, + &ret_item); + if (d == 0.0) { + *actual_item = ret_item; + return 0.0; + } + + *actual_item = item; + return 0.0; +} + +static void +e_summary_titlebar_class_init (GtkObjectClass *object_class) +{ + GnomeCanvasItemClass *item_class; + + item_class = (GnomeCanvasItemClass *) object_class; + + object_class->destroy = e_summary_titlebar_destroy; + object_class->set_arg = e_summary_titlebar_set_arg; + object_class->get_arg = e_summary_titlebar_get_arg; + + item_class->realize = e_summary_titlebar_realize; + item_class->unrealize = e_summary_titlebar_unrealize; + item_class->event = e_summary_titlebar_event; + item_class->point = e_summary_titlebar_point; + + gtk_object_add_arg_type ("ESummaryTitlebar::text", + GTK_TYPE_STRING, GTK_ARG_READWRITE, + ARG_TEXT); + gtk_object_add_arg_type ("ESummaryTitlebar::width", + GTK_TYPE_DOUBLE, GTK_ARG_READWRITE, + ARG_WIDTH); + gtk_object_add_arg_type ("ESummaryTitlebar::height", + GTK_TYPE_DOUBLE, GTK_ARG_READABLE, + ARG_HEIGHT); + + titlebar_signals[EDIT] = gtk_signal_new ("edit", GTK_RUN_LAST, + object_class->type, + GTK_SIGNAL_OFFSET (ESummaryTitlebarClass, + edit), + gtk_marshal_NONE__NONE, + GTK_TYPE_NONE, 0); + titlebar_signals[SHADE] = gtk_signal_new ("shade", GTK_RUN_LAST, + object_class->type, + GTK_SIGNAL_OFFSET (ESummaryTitlebarClass, + shade), + gtk_marshal_NONE__NONE, + GTK_TYPE_NONE, 0); + titlebar_signals[CLOSE] = gtk_signal_new ("close", GTK_RUN_LAST, + object_class->type, + GTK_SIGNAL_OFFSET (ESummaryTitlebarClass, + close), + gtk_marshal_NONE__NONE, + GTK_TYPE_NONE, 0); + gtk_object_class_add_signals (object_class, titlebar_signals, + LAST_SIGNAL); + + parent_class = gtk_type_class (PARENT_TYPE); +} + +static void +e_summary_titlebar_init (GtkObject *object) +{ + ESummaryTitlebar *titlebar; + ESummaryTitlebarPrivate *priv; + + titlebar = E_SUMMARY_TITLEBAR (object); + titlebar->private = g_new0 (ESummaryTitlebarPrivate, 1); + priv = titlebar->private; + + priv->width = 100.0; + priv->text = NULL; + + gdk_rgb_init (); +} + +E_MAKE_TYPE (e_summary_titlebar, "ESummaryTitlebar", ESummaryTitlebar, + e_summary_titlebar_class_init, e_summary_titlebar_init, + PARENT_TYPE); + diff --git a/executive-summary/widgets/e-summary-titlebar.h b/executive-summary/widgets/e-summary-titlebar.h new file mode 100644 index 0000000000..b748a4dc8b --- /dev/null +++ b/executive-summary/widgets/e-summary-titlebar.h @@ -0,0 +1,56 @@ +/* -*- Mode: C; indent-tabs-mode: t; c-basic-offset: 8; tab-width: 8 -*- */ +/* e-summary-titlebar.h + * + * Authors: Iain Holmes <iain@helixcode.com> + * + * Copyright (C) 2000 Helix Code, Inc. + * + * This program is free software; you can redistribute it and/or + * modify it under the terms of the GNU General Public License as + * published by the Free Software Foundation; either version 2 of the + * License, or (at your option) any later version. + * + * This program is distributed in the hope that it will be useful, + * but WITHOUT ANY WARRANTY; without even the implied warranty of + * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU + * General Public License for more details. + * + * You should have received a copy of the GNU General Public + * License along with this program; if not, write to the + * Free Software Foundation, Inc., 59 Temple Place - Suite 330, + * Boston, MA 02111-1307, USA. + */ + +#ifndef _E_SUMMARY_TITLEBAR_H__ +#define _E_SUMMARY_TITLEBAR_H__ + +#include <gtk/gtksignal.h> +#include <libgnomeui/gnome-canvas.h> + +#define E_SUMMARY_TITLEBAR_TYPE (e_summary_titlebar_get_type ()) +#define E_SUMMARY_TITLEBAR(obj) (GTK_CHECK_CAST ((obj), E_SUMMARY_TITLEBAR_TYPE, ESummaryTitlebar)) +#define E_SUMMARY_TITLEBAR_CLASS(klass) (GTK_CHECK_CLASS_CAST ((klass), E_SUMMARY_TITLEBAR_TYPE, ESummaryTitlebarClass)) +#define IS_E_SUMMARY_TITLEBAR(obj) (GTK_CHECK_TYPE ((obj), E_SUMMARY_TITLEBAR_TYPE)) +#define IS_E_SUMMARY_TITLEBAR_CLASS(klass) (GTK_CHECK_CLASS_TYPE ((obj), E_SUMMARY_TITLEBAR_TYPE)) + +typedef struct _ESummaryTitlebarPrivate ESummaryTitlebarPrivate; +typedef struct _ESummaryTitlebar ESummaryTitlebar; +typedef struct _ESummaryTitlebarClass ESummaryTitlebarClass; + +struct _ESummaryTitlebar { + GnomeCanvasGroup parent; + + ESummaryTitlebarPrivate *private; +}; + +struct _ESummaryTitlebarClass { + GnomeCanvasGroupClass parent_class; + + void (*close) (ESummaryTitlebar *window); + void (*shade) (ESummaryTitlebar *window); + void (*edit) (ESummaryTitlebar *window); +}; + +GtkType e_summary_titlebar_get_type (void); + +#endif diff --git a/executive-summary/widgets/edit.xpm b/executive-summary/widgets/edit.xpm new file mode 100644 index 0000000000..7f2deb1525 --- /dev/null +++ b/executive-summary/widgets/edit.xpm @@ -0,0 +1,19 @@ +/* XPM */ +static char * edit_xpm[] = { +"14 14 2 1", +" g None", +". g #000000", +" ", +" ", +" ... ", +" . . ", +" . . ", +" . ", +" . ", +" .. ", +" .. ", +" .. ", +" ", +" .. ", +" .. ", +" "}; diff --git a/executive-summary/widgets/esummary-window-test.c b/executive-summary/widgets/esummary-window-test.c new file mode 100644 index 0000000000..3a0ad0ab6b --- /dev/null +++ b/executive-summary/widgets/esummary-window-test.c @@ -0,0 +1,43 @@ +#include <gnome.h> +#include <gal/widgets/e-canvas.h> +#include "e-summary-subwindow.h" +#include "e-summary-titlebar.h" + +void +close_test (GtkWidget *widget, + gpointer data) +{ + gtk_main_quit (); +} + +int +main (int argc, + char **argv) +{ + GtkWidget *window, *canvas; + ESummarySubwindow *subwindow; + GtkWidget *control; + + gnome_init ("Executive Summary Subwindow Test", "1.0", argc, argv); + window = gtk_window_new (GTK_WINDOW_TOPLEVEL); + gtk_signal_connect (GTK_OBJECT (window), "destroy", + GTK_SIGNAL_FUNC (close_test), NULL); + + canvas = e_canvas_new (); + + subwindow = e_summary_subwindow_new (GNOME_CANVAS_GROUP (GNOME_CANVAS (canvas)->root), 100, 100); + + control = gtk_button_new_with_label ("A big button"); + gtk_widget_set_usize (control, 400, 200); + + e_summary_subwindow_add (subwindow, control); + gtk_widget_show (control); + + gnome_canvas_set_scroll_region (GNOME_CANVAS (canvas), 0.0, 0.0, 1000.0, 1300.0); + gtk_container_add (GTK_CONTAINER (window), canvas); + gtk_widget_show_all (window); + + gtk_main (); + + exit(0); +} diff --git a/executive-summary/widgets/shade.xpm b/executive-summary/widgets/shade.xpm new file mode 100644 index 0000000000..349212e906 --- /dev/null +++ b/executive-summary/widgets/shade.xpm @@ -0,0 +1,19 @@ +/* XPM */ +static char * shade_xpm[] = { +"14 14 2 1", +" g None", +". g #000000", +" ", +" ............ ", +" ............ ", +" ............ ", +" ............ ", +" . . ", +" . . ", +" . . ", +" . . ", +" . . ", +" . . ", +" . . ", +" ............ ", +" "}; diff --git a/executive-summary/widgets/x.xpm b/executive-summary/widgets/x.xpm new file mode 100644 index 0000000000..ce9e9f19dc --- /dev/null +++ b/executive-summary/widgets/x.xpm @@ -0,0 +1,19 @@ +/* XPM */ +static char * x_xpm[] = { +"14 14 2 1", +" g None", +". g #000000", +" ", +" .. .. ", +" ... ... ", +" ... ... ", +" ... ... ", +" ...... ", +" .... ", +" .... ", +" ...... ", +" ... ... ", +" ... ... ", +" ... ... ", +" .. .. ", +" "}; |