diff options
author | Owen Taylor <otaylor@src.gnome.org> | 1998-11-06 22:05:02 +0000 |
---|---|---|
committer | Owen Taylor <otaylor@src.gnome.org> | 1998-11-06 22:05:02 +0000 |
commit | e2a521922085c8010028e227f61bba59ea6b8242 (patch) | |
tree | 2500d6aa6f63aab4b58c17546532ecce8fdcca37 /gtk/gtkcheckbutton.c | |
parent | 3c0df19a588bd96f328bda975db8eb9fa7f79e81 (diff) | |
download | gtk+-e2a521922085c8010028e227f61bba59ea6b8242.tar.gz |
Merge from themes-2. See the ChangeLog for a somewhat detailed
history of the evolution of the changes involved. Most of this
is actually minor painting tweaks.
Diffstat (limited to 'gtk/gtkcheckbutton.c')
-rw-r--r-- | gtk/gtkcheckbutton.c | 118 |
1 files changed, 60 insertions, 58 deletions
diff --git a/gtk/gtkcheckbutton.c b/gtk/gtkcheckbutton.c index 8b863a8b80..3560b422d5 100644 --- a/gtk/gtkcheckbutton.c +++ b/gtk/gtkcheckbutton.c @@ -42,7 +42,6 @@ static void gtk_check_button_draw_indicator (GtkCheckButton *check_but static void gtk_real_check_button_draw_indicator (GtkCheckButton *check_button, GdkRectangle *area); - static GtkToggleButtonClass *parent_class = NULL; @@ -84,7 +83,7 @@ gtk_check_button_class_init (GtkCheckButtonClass *class) widget_class->size_request = gtk_check_button_size_request; widget_class->size_allocate = gtk_check_button_size_allocate; widget_class->expose_event = gtk_check_button_expose; - + class->indicator_size = INDICATOR_SIZE; class->indicator_spacing = INDICATOR_SPACING; class->draw_indicator = gtk_real_check_button_draw_indicator; @@ -93,6 +92,7 @@ gtk_check_button_class_init (GtkCheckButtonClass *class) static void gtk_check_button_init (GtkCheckButton *check_button) { + GTK_WIDGET_SET_FLAGS (check_button, GTK_NO_WINDOW); check_button->toggle_button.draw_indicator = TRUE; } @@ -137,15 +137,23 @@ gtk_check_button_draw (GtkWidget *widget, if (check_button->toggle_button.draw_indicator) { - button = GTK_BUTTON (widget); + gint border_width; + button = GTK_BUTTON (widget); gtk_check_button_draw_indicator (check_button, area); - + + border_width = GTK_CONTAINER (widget)->border_width; + if (GTK_WIDGET_HAS_FOCUS (widget)) + gtk_paint_focus (widget->style, widget->window, + NULL, widget, "checkbutton", + border_width + widget->allocation.x, + border_width + widget->allocation.y, + widget->allocation.width - 2 * border_width - 1, + widget->allocation.height - 2 * border_width - 1); + if (GTK_BIN (button)->child && GTK_WIDGET_NO_WINDOW (GTK_BIN (button)->child) && gtk_widget_intersect (GTK_BIN (button)->child, area, &child_area)) gtk_widget_draw (GTK_BIN (button)->child, &child_area); - - gtk_widget_draw_focus (widget); } else { @@ -158,38 +166,17 @@ gtk_check_button_draw (GtkWidget *widget, static void gtk_check_button_draw_focus (GtkWidget *widget) { - GtkCheckButton *check_button; + gint border_width; g_return_if_fail (widget != NULL); g_return_if_fail (GTK_IS_CHECK_BUTTON (widget)); - - if (GTK_WIDGET_DRAWABLE (widget)) - { - check_button = GTK_CHECK_BUTTON (widget); - if (check_button->toggle_button.draw_indicator) - { - gint border_width; - - border_width = GTK_CONTAINER (widget)->border_width; - if (GTK_WIDGET_HAS_FOCUS (widget)) - gdk_draw_rectangle (widget->window, - widget->style->black_gc, FALSE, - border_width, border_width, - widget->allocation.width - 2 * border_width - 1, - widget->allocation.height - 2 * border_width - 1); - else - gdk_draw_rectangle (widget->window, - widget->style->bg_gc[GTK_STATE_NORMAL], FALSE, - border_width, border_width, - widget->allocation.width - 2 * border_width - 1, - widget->allocation.height - 2 * border_width - 1); - } - else - { - if (GTK_WIDGET_CLASS (parent_class)->draw_focus) - (* GTK_WIDGET_CLASS (parent_class)->draw_focus) (widget); - } - } + + border_width = GTK_CONTAINER (widget)->border_width; + gtk_widget_queue_clear_area(widget->parent, + border_width + widget->allocation.x, + border_width + widget->allocation.y, + widget->allocation.width - 2 * border_width, + widget->allocation.height - 2 * border_width); } static void @@ -227,19 +214,21 @@ gtk_check_button_size_allocate (GtkWidget *widget, GtkAllocation *allocation) { GtkCheckButton *check_button; + GtkToggleButton *toggle_button; GtkButton *button; GtkAllocation child_allocation; - + g_return_if_fail (widget != NULL); g_return_if_fail (GTK_IS_CHECK_BUTTON (widget)); g_return_if_fail (allocation != NULL); check_button = GTK_CHECK_BUTTON (widget); + toggle_button = GTK_TOGGLE_BUTTON (widget); if (check_button->toggle_button.draw_indicator) { widget->allocation = *allocation; if (GTK_WIDGET_REALIZED (widget)) - gdk_window_move_resize (widget->window, + gdk_window_move_resize (toggle_button->event_window, allocation->x, allocation->y, allocation->width, allocation->height); @@ -249,11 +238,16 @@ gtk_check_button_size_allocate (GtkWidget *widget, { child_allocation.x = (GTK_CONTAINER (widget)->border_width + CHECK_BUTTON_CLASS (widget)->indicator_size + - CHECK_BUTTON_CLASS (widget)->indicator_spacing * 3 + 1); - child_allocation.y = GTK_CONTAINER (widget)->border_width + 1; - child_allocation.width = MAX (1, allocation->width - child_allocation.x - + CHECK_BUTTON_CLASS (widget)->indicator_spacing * 3 + 1 + + widget->allocation.x); + child_allocation.y = GTK_CONTAINER (widget)->border_width + 1 + + widget->allocation.y; + child_allocation.width = MAX (1, allocation->width - + (GTK_CONTAINER (widget)->border_width + + CHECK_BUTTON_CLASS (widget)->indicator_size + + CHECK_BUTTON_CLASS (widget)->indicator_spacing * 3 + 1) - GTK_CONTAINER (widget)->border_width - 1); - child_allocation.height = MAX (1, allocation->height - child_allocation.y * 2); + child_allocation.height = MAX (1, allocation->height - (GTK_CONTAINER (widget)->border_width + 1) * 2); gtk_widget_size_allocate (GTK_BIN (button)->child, &child_allocation); } @@ -333,34 +327,43 @@ gtk_real_check_button_draw_indicator (GtkCheckButton *check_button, GdkRectangle new_area; gint width, height; gint x, y; - + GdkWindow *window; + g_return_if_fail (check_button != NULL); g_return_if_fail (GTK_IS_CHECK_BUTTON (check_button)); + if (GTK_WIDGET_DRAWABLE (check_button)) { widget = GTK_WIDGET (check_button); toggle_button = GTK_TOGGLE_BUTTON (check_button); - state_type = GTK_WIDGET_STATE (widget); + window = widget->window; + if (!window) + return; + + state_type = GTK_WIDGET_STATE (widget); if ((state_type != GTK_STATE_NORMAL) && (state_type != GTK_STATE_PRELIGHT)) state_type = GTK_STATE_NORMAL; - restrict_area.x = GTK_CONTAINER (widget)->border_width; - restrict_area.y = restrict_area.x; - restrict_area.width = widget->allocation.width - restrict_area.x * 2; - restrict_area.height = widget->allocation.height - restrict_area.x * 2; + restrict_area.x = widget->allocation.x + GTK_CONTAINER (widget)->border_width; + restrict_area.y = widget->allocation.y + GTK_CONTAINER (widget)->border_width; + restrict_area.width = widget->allocation.width - ( 2 * GTK_CONTAINER (widget)->border_width); + restrict_area.height = widget->allocation.height - ( 2 * GTK_CONTAINER (widget)->border_width); if (gdk_rectangle_intersect (area, &restrict_area, &new_area)) { - gtk_style_set_background (widget->style, widget->window, state_type); - gdk_window_clear_area (widget->window, new_area.x, new_area.y, - new_area.width, new_area.height); + if (state_type != GTK_STATE_NORMAL) + gtk_paint_flat_box(widget->style, window, state_type, + GTK_SHADOW_ETCHED_OUT, + area, widget, "checkbutton", + new_area.x, new_area.y, + new_area.width, new_area.height); } - x = CHECK_BUTTON_CLASS (widget)->indicator_spacing + GTK_CONTAINER (widget)->border_width; - y = (widget->allocation.height - CHECK_BUTTON_CLASS (widget)->indicator_size) / 2; + x = widget->allocation.x + CHECK_BUTTON_CLASS (widget)->indicator_spacing + GTK_CONTAINER (widget)->border_width; + y = widget->allocation.y + (widget->allocation.height - CHECK_BUTTON_CLASS (widget)->indicator_size) / 2; width = CHECK_BUTTON_CLASS (widget)->indicator_size; height = CHECK_BUTTON_CLASS (widget)->indicator_size; @@ -369,11 +372,10 @@ gtk_real_check_button_draw_indicator (GtkCheckButton *check_button, else shadow_type = GTK_SHADOW_OUT; - gdk_draw_rectangle (widget->window, - widget->style->bg_gc[GTK_WIDGET_STATE (widget)], - TRUE, x + 1, y + 1, width, height); - gtk_draw_shadow (widget->style, widget->window, - GTK_WIDGET_STATE (widget), shadow_type, - x + 1, y + 1, width, height); + gtk_paint_check (widget->style, window, + GTK_WIDGET_STATE (widget), shadow_type, + area, widget, "checkbutton", + x + 1, y + 1, width, height); } } + |