aboutsummaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorEttore Perazzoli <ettore@src.gnome.org>2002-05-23 06:15:33 +0800
committerEttore Perazzoli <ettore@src.gnome.org>2002-05-23 06:15:33 +0800
commit5b6053851275131b8b9b15d19e7b8f202fa11f4b (patch)
tree1ef3149eeef79d3a9c7966cb473fca07f97aceeb
parent2b9f864daf03aa8e130385f082a9b9072fdd4349 (diff)
downloadgsoc2013-evolution-5b6053851275131b8b9b15d19e7b8f202fa11f4b.tar
gsoc2013-evolution-5b6053851275131b8b9b15d19e7b8f202fa11f4b.tar.gz
gsoc2013-evolution-5b6053851275131b8b9b15d19e7b8f202fa11f4b.tar.bz2
gsoc2013-evolution-5b6053851275131b8b9b15d19e7b8f202fa11f4b.tar.lz
gsoc2013-evolution-5b6053851275131b8b9b15d19e7b8f202fa11f4b.tar.xz
gsoc2013-evolution-5b6053851275131b8b9b15d19e7b8f202fa11f4b.tar.zst
gsoc2013-evolution-5b6053851275131b8b9b15d19e7b8f202fa11f4b.zip
New, overrides GtkWidget::draw. (impl_expose_event): New, overrides
* e-combo-button.c (impl_draw): New, overrides GtkWidget::draw. (impl_expose_event): New, overrides GtkWidget::expose_event. svn path=/trunk/; revision=16978
-rw-r--r--widgets/misc/ChangeLog5
-rw-r--r--widgets/misc/e-combo-button.c105
2 files changed, 108 insertions, 2 deletions
diff --git a/widgets/misc/ChangeLog b/widgets/misc/ChangeLog
index f005836c2b..612338d596 100644
--- a/widgets/misc/ChangeLog
+++ b/widgets/misc/ChangeLog
@@ -1,3 +1,8 @@
+2002-05-22 Ettore Perazzoli <ettore@ximian.com>
+
+ * e-combo-button.c (impl_draw): New, overrides GtkWidget::draw.
+ (impl_expose_event): New, overrides GtkWidget::expose_event.
+
2002-05-20 Ettore Perazzoli <ettore@ximian.com>
* e-filter-bar.c (build_items): Prepend the advanced menu with a
diff --git a/widgets/misc/e-combo-button.c b/widgets/misc/e-combo-button.c
index 5277180f7d..9203bece01 100644
--- a/widgets/misc/e-combo-button.c
+++ b/widgets/misc/e-combo-button.c
@@ -154,6 +154,61 @@ set_icon (EComboButton *combo_button,
}
+/* Paint the borders. */
+
+static void
+paint (EComboButton *combo_button,
+ GdkRectangle *area)
+{
+ EComboButtonPrivate *priv = combo_button->priv;
+ GtkShadowType shadow_type;
+ int separator_x;
+
+ gdk_window_set_back_pixmap (GTK_WIDGET (combo_button)->window, NULL, TRUE);
+ gdk_window_clear_area (GTK_WIDGET (combo_button)->window,
+ area->x, area->y,
+ area->width, area->height);
+
+ /* Only paint the outline if we are in prelight state. */
+ if (GTK_WIDGET_STATE (combo_button) != GTK_STATE_PRELIGHT
+ && GTK_WIDGET_STATE (combo_button) != GTK_STATE_ACTIVE)
+ return;
+
+ separator_x = (priv->label->allocation.width
+ + priv->label->allocation.x
+ + priv->arrow_pixmap->allocation.x) / 2;
+
+ if (GTK_WIDGET_STATE (combo_button) == GTK_STATE_ACTIVE)
+ shadow_type = GTK_SHADOW_IN;
+ else
+ shadow_type = GTK_SHADOW_OUT;
+
+ gtk_paint_box (GTK_WIDGET (combo_button)->style,
+ GTK_WIDGET (combo_button)->window,
+ GTK_STATE_PRELIGHT,
+ shadow_type,
+ area,
+ GTK_WIDGET (combo_button),
+ "button",
+ 0,
+ 0,
+ separator_x,
+ GTK_WIDGET (combo_button)->allocation.height);
+
+ gtk_paint_box (GTK_WIDGET (combo_button)->style,
+ GTK_WIDGET (combo_button)->window,
+ GTK_STATE_PRELIGHT,
+ shadow_type,
+ area,
+ GTK_WIDGET (combo_button),
+ "button",
+ separator_x,
+ 0,
+ GTK_WIDGET (combo_button)->allocation.width - separator_x,
+ GTK_WIDGET (combo_button)->allocation.height);
+}
+
+
/* Callbacks for the associated menu. */
static void
@@ -288,6 +343,48 @@ impl_leave_notify_event (GtkWidget *widget,
return FALSE;
}
+static void
+impl_draw (GtkWidget *widget,
+ GdkRectangle *area)
+{
+ GdkRectangle child_area;
+ GdkRectangle tmp_area;
+
+ if (! GTK_WIDGET_DRAWABLE (widget))
+ return;
+
+ tmp_area = *area;
+ tmp_area.x -= GTK_CONTAINER (widget)->border_width;
+ tmp_area.y -= GTK_CONTAINER (widget)->border_width;
+
+ paint (E_COMBO_BUTTON (widget), &tmp_area);
+
+ if (GTK_BIN (widget)->child && gtk_widget_intersect (GTK_BIN (widget)->child, &tmp_area, &child_area))
+ gtk_widget_draw (GTK_BIN (widget)->child, &child_area);
+}
+
+static int
+impl_expose_event (GtkWidget *widget,
+ GdkEventExpose *event)
+{
+ GtkBin *bin;
+ GdkEventExpose child_event;
+
+ if (! GTK_WIDGET_DRAWABLE (widget))
+ return FALSE;
+
+ bin = GTK_BIN (widget);
+
+ paint (E_COMBO_BUTTON (widget), &event->area);
+
+ child_event = *event;
+ if (bin->child && GTK_WIDGET_NO_WINDOW (bin->child) &&
+ gtk_widget_intersect (bin->child, &event->area, &child_event.area))
+ gtk_widget_event (bin->child, (GdkEvent*) &child_event);
+
+ return FALSE;
+}
+
/* GtkButton methods. */
@@ -342,6 +439,8 @@ class_init (GtkObjectClass *object_class)
widget_class = GTK_WIDGET_CLASS (object_class);
widget_class->button_press_event = impl_button_press_event;
widget_class->leave_notify_event = impl_leave_notify_event;
+ widget_class->draw = impl_draw;
+ widget_class->expose_event = impl_expose_event;
button_class = GTK_BUTTON_CLASS (object_class);
button_class->released = impl_released;
@@ -373,11 +472,13 @@ init (EComboButton *combo_button)
gtk_widget_show (priv->icon_pixmap);
priv->label = gtk_label_new ("");
- gtk_box_pack_start (GTK_BOX (priv->hbox), priv->label, TRUE, TRUE, 0);
+ gtk_box_pack_start (GTK_BOX (priv->hbox), priv->label, TRUE, TRUE,
+ 2 * GTK_WIDGET (combo_button)->style->klass->xthickness);
gtk_widget_show (priv->label);
priv->arrow_pixmap = create_arrow_pixmap_widget ();
- gtk_box_pack_start (GTK_BOX (priv->hbox), priv->arrow_pixmap, TRUE, TRUE, 0);
+ gtk_box_pack_start (GTK_BOX (priv->hbox), priv->arrow_pixmap, TRUE, TRUE,
+ GTK_WIDGET (combo_button)->style->klass->xthickness);
gtk_widget_show (priv->arrow_pixmap);
priv->icon = NULL;