summaryrefslogtreecommitdiff
path: root/gtk/gtktogglebutton.c
diff options
context:
space:
mode:
authorOwen Taylor <otaylor@redhat.com>2001-11-15 21:04:51 +0000
committerOwen Taylor <otaylor@src.gnome.org>2001-11-15 21:04:51 +0000
commitb27345fe2cf7277bb3483d06651c8bb6820003ec (patch)
tree5d692b7598d24fb038d1c02b9304cb9b68e4a236 /gtk/gtktogglebutton.c
parent41f14d359739ba21d0725d7025885da880100f33 (diff)
downloadgtk+-b27345fe2cf7277bb3483d06651c8bb6820003ec.tar.gz
Cal gdk_window_invalidate_maybe_recurse() for recursion. (Soeren Sandmann)
Thu Nov 15 14:19:34 2001 Owen Taylor <otaylor@redhat.com> * gdk/gdkwindow.c (gdk_window_invalidate_maybe_recurse): Cal gdk_window_invalidate_maybe_recurse() for recursion. (Soeren Sandmann) * gtk/gtkviewport.c: Make !redraw_on_allocate. (Soeren Sandmann) * gtk/gtkcontainer.c (gtk_container_expose): Call gtk_container_forall() not _foreach() to propagate, since we need to propagate exposes to internal children as well. * gtk/gtkwidget.c (gtk_widget_set_events, gtk_widget_add_events): Remove the restriction of only being able to call these on window widgets, since we have lots of NO_WINDOW widgets with windows now; for add events, recurse over the children of widget->window to find one owned by the widget. * gtk/gtkbutton.[ch]: Make a NO_WINDOW widget, using an input-only window to catch events. * gtk/gtktogglebutton.[ch]: Remove the code for switching between NO_WINDOW and WINDOW widgets based on the mode. * gtk/gtkcheckbutton.c gtk/gtkoptionmenu.c gtk/gtkclist.c gtk/gtktreeview.c: Adopt to NO_WINDOW change for GtkButton. * gtk/gtkrange.[ch]: Make into a NO_WINDOW widget. * gtk/gtkhscale.c, gtk/gtkvscale.c: Adopt to NO_WINDOW change for range. * gtk/gtknotebook.[ch]: Make into a NO_WINDOW widget. * docs/Changes-2.0.txt: Add a note about the NO_WINDOW changes.
Diffstat (limited to 'gtk/gtktogglebutton.c')
-rw-r--r--gtk/gtktogglebutton.c163
1 files changed, 8 insertions, 155 deletions
diff --git a/gtk/gtktogglebutton.c b/gtk/gtktogglebutton.c
index 5d32d97306..dc3d8c90da 100644
--- a/gtk/gtktogglebutton.c
+++ b/gtk/gtktogglebutton.c
@@ -51,8 +51,6 @@ static void gtk_toggle_button_class_init (GtkToggleButtonClass *klass);
static void gtk_toggle_button_init (GtkToggleButton *toggle_button);
static void gtk_toggle_button_paint (GtkWidget *widget,
GdkRectangle *area);
-static void gtk_toggle_button_size_allocate (GtkWidget *widget,
- GtkAllocation *allocation);
static gint gtk_toggle_button_expose (GtkWidget *widget,
GdkEventExpose *event);
static void gtk_toggle_button_pressed (GtkButton *button);
@@ -66,10 +64,6 @@ static void gtk_toggle_button_get_property (GObject *object,
guint prop_id,
GValue *value,
GParamSpec *pspec);
-static void gtk_toggle_button_realize (GtkWidget *widget);
-static void gtk_toggle_button_unrealize (GtkWidget *widget);
-static void gtk_toggle_button_map (GtkWidget *widget);
-static void gtk_toggle_button_unmap (GtkWidget *widget);
static void gtk_toggle_button_update_state (GtkButton *button);
static guint toggle_button_signals[LAST_SIGNAL] = { 0 };
@@ -121,12 +115,7 @@ gtk_toggle_button_class_init (GtkToggleButtonClass *class)
gobject_class->set_property = gtk_toggle_button_set_property;
gobject_class->get_property = gtk_toggle_button_get_property;
- widget_class->size_allocate = gtk_toggle_button_size_allocate;
widget_class->expose_event = gtk_toggle_button_expose;
- widget_class->realize = gtk_toggle_button_realize;
- widget_class->unrealize = gtk_toggle_button_unrealize;
- widget_class->map = gtk_toggle_button_map;
- widget_class->unmap = gtk_toggle_button_unmap;
button_class->pressed = gtk_toggle_button_pressed;
button_class->released = gtk_toggle_button_released;
@@ -174,7 +163,6 @@ gtk_toggle_button_init (GtkToggleButton *toggle_button)
{
toggle_button->active = FALSE;
toggle_button->draw_indicator = FALSE;
- GTK_WIDGET_UNSET_FLAGS (toggle_button, GTK_NO_WINDOW);
}
@@ -273,35 +261,7 @@ gtk_toggle_button_set_mode (GtkToggleButton *toggle_button,
if (toggle_button->draw_indicator != draw_indicator)
{
- if (GTK_WIDGET_REALIZED (toggle_button))
- {
- gboolean visible = GTK_WIDGET_VISIBLE (toggle_button);
-
- if (visible)
- gtk_widget_hide (widget);
-
- gtk_widget_unrealize (widget);
- toggle_button->draw_indicator = draw_indicator;
-
- if (toggle_button->draw_indicator)
- GTK_WIDGET_SET_FLAGS (toggle_button, GTK_NO_WINDOW);
- else
- GTK_WIDGET_UNSET_FLAGS (toggle_button, GTK_NO_WINDOW);
-
- gtk_widget_realize (widget);
-
- if (visible)
- gtk_widget_show (widget);
- }
- else
- {
- toggle_button->draw_indicator = draw_indicator;
-
- if (toggle_button->draw_indicator)
- GTK_WIDGET_SET_FLAGS (toggle_button, GTK_NO_WINDOW);
- else
- GTK_WIDGET_UNSET_FLAGS (toggle_button, GTK_NO_WINDOW);
- }
+ toggle_button->draw_indicator = draw_indicator;
if (GTK_WIDGET_VISIBLE (toggle_button))
gtk_widget_queue_resize (GTK_WIDGET (toggle_button));
@@ -418,6 +378,7 @@ gtk_toggle_button_paint (GtkWidget *widget,
GtkStateType state_type;
gint width, height;
gboolean interior_focus;
+ gint border_width;
gint x, y;
button = GTK_BUTTON (widget);
@@ -425,15 +386,14 @@ gtk_toggle_button_paint (GtkWidget *widget,
if (GTK_WIDGET_DRAWABLE (widget))
{
+ border_width = GTK_CONTAINER (widget)->border_width;
+
gtk_widget_style_get (widget, "interior_focus", &interior_focus, NULL);
- x = 0;
- y = 0;
- width = widget->allocation.width - GTK_CONTAINER (widget)->border_width * 2;
- height = widget->allocation.height - GTK_CONTAINER (widget)->border_width * 2;
-
- gdk_window_set_back_pixmap (widget->window, NULL, TRUE);
- gdk_window_clear_area (widget->window, area->x, area->y, area->width, area->height);
+ x = widget->allocation.x + border_width;
+ y = widget->allocation.y + border_width;
+ width = widget->allocation.width - border_width * 2;
+ height = widget->allocation.height - border_width * 2;
if (GTK_WIDGET_HAS_DEFAULT (widget) &&
GTK_BUTTON (widget)->relief == GTK_RELIEF_NORMAL)
@@ -505,15 +465,6 @@ gtk_toggle_button_paint (GtkWidget *widget,
}
}
-static void
-gtk_toggle_button_size_allocate (GtkWidget *widget,
- GtkAllocation *allocation)
-{
- if (!GTK_WIDGET_NO_WINDOW (widget) &&
- GTK_WIDGET_CLASS (parent_class)->size_allocate)
- GTK_WIDGET_CLASS (parent_class)->size_allocate (widget, allocation);
-}
-
static gint
gtk_toggle_button_expose (GtkWidget *widget,
GdkEventExpose *event)
@@ -567,104 +518,6 @@ gtk_toggle_button_clicked (GtkButton *button)
}
static void
-gtk_toggle_button_realize (GtkWidget *widget)
-{
- GtkToggleButton *toggle_button;
- GdkWindowAttr attributes;
- gint attributes_mask;
- gint border_width;
-
- g_return_if_fail (GTK_IS_TOGGLE_BUTTON (widget));
-
- toggle_button = GTK_TOGGLE_BUTTON (widget);
- GTK_WIDGET_SET_FLAGS (widget, GTK_REALIZED);
-
- border_width = GTK_CONTAINER (widget)->border_width;
-
- attributes.window_type = GDK_WINDOW_CHILD;
- attributes.x = widget->allocation.x + border_width;
- attributes.y = widget->allocation.y + border_width;
- attributes.width = widget->allocation.width - border_width * 2;
- attributes.height = widget->allocation.height - border_width * 2;
- attributes.event_mask = gtk_widget_get_events (widget);
- attributes.event_mask |= (GDK_EXPOSURE_MASK |
- GDK_BUTTON_PRESS_MASK |
- GDK_BUTTON_RELEASE_MASK |
- GDK_ENTER_NOTIFY_MASK |
- GDK_LEAVE_NOTIFY_MASK);
-
- if (GTK_WIDGET_NO_WINDOW (widget))
- {
- attributes.wclass = GDK_INPUT_ONLY;
- attributes_mask = GDK_WA_X | GDK_WA_Y;
-
- widget->window = gtk_widget_get_parent_window (widget);
- gdk_window_ref (widget->window);
-
- toggle_button->event_window = gdk_window_new (gtk_widget_get_parent_window (widget),
- &attributes, attributes_mask);
- gdk_window_set_user_data (toggle_button->event_window, toggle_button);
- }
- else
- {
- attributes.wclass = GDK_INPUT_OUTPUT;
- attributes_mask = GDK_WA_X | GDK_WA_Y | GDK_WA_VISUAL | GDK_WA_COLORMAP;
- attributes.visual = gtk_widget_get_visual (widget);
- attributes.colormap = gtk_widget_get_colormap (widget);
- widget->window = gdk_window_new (gtk_widget_get_parent_window (widget),
- &attributes, attributes_mask);
- gdk_window_set_user_data (widget->window, toggle_button);
- }
-
- widget->style = gtk_style_attach (widget->style, widget->window);
-
- if (!GTK_WIDGET_NO_WINDOW (widget))
- gtk_style_set_background (widget->style, widget->window, GTK_STATE_NORMAL);
-}
-
-static void
-gtk_toggle_button_unrealize (GtkWidget *widget)
-{
- GtkToggleButton *toggle_button;
-
- g_return_if_fail (GTK_IS_TOGGLE_BUTTON (widget));
-
- toggle_button = GTK_TOGGLE_BUTTON (widget);
-
- if (GTK_WIDGET_NO_WINDOW (widget))
- {
- gdk_window_set_user_data (toggle_button->event_window, NULL);
- gdk_window_destroy (toggle_button->event_window);
- toggle_button->event_window = NULL;
- }
-
- if (GTK_WIDGET_CLASS (parent_class)->unrealize)
- (* GTK_WIDGET_CLASS (parent_class)->unrealize) (widget);
-}
-
-static void
-gtk_toggle_button_map (GtkWidget *widget)
-{
- g_return_if_fail (GTK_IS_TOGGLE_BUTTON (widget));
-
- if (GTK_WIDGET_NO_WINDOW (widget))
- gdk_window_show (GTK_TOGGLE_BUTTON (widget)->event_window);
-
- GTK_WIDGET_CLASS (parent_class)->map (widget);
-}
-
-static void
-gtk_toggle_button_unmap (GtkWidget *widget)
-{
- g_return_if_fail (GTK_IS_TOGGLE_BUTTON (widget));
-
- if (GTK_WIDGET_NO_WINDOW (widget))
- gdk_window_hide (GTK_TOGGLE_BUTTON (widget)->event_window);
-
- GTK_WIDGET_CLASS (parent_class)->unmap (widget);
-}
-
-static void
gtk_toggle_button_update_state (GtkButton *button)
{
GtkToggleButton *toggle_button = GTK_TOGGLE_BUTTON (button);