diff options
author | Owen Taylor <otaylor@redhat.com> | 2001-12-04 03:27:30 +0000 |
---|---|---|
committer | Owen Taylor <otaylor@src.gnome.org> | 2001-12-04 03:27:30 +0000 |
commit | 7537825b34bee7094b6bf2e4f3f1e551114ed022 (patch) | |
tree | fb77377ab8aeb2e537f2177554e1d2ec9d390ee2 /gtk/gtktogglebutton.c | |
parent | cac3ad31314da1c2b0a5c35f54f7328da5ed51a3 (diff) | |
download | gtk+-7537825b34bee7094b6bf2e4f3f1e551114ed022.tar.gz |
Patch from Bill Haneman (with many modifications) to make the focus color
Mon Dec 3 16:39:17 2001 Owen Taylor <otaylor@redhat.com>
Patch from Bill Haneman (with many modifications) to make
the focus color work on dark themes and to make the
focus line width configurable. (#61079, #63074)
* gtk/gtkwidget.c: Add style properties,
::focus-widget, ::focus-line-width, and ::focus-padding.
* gtk/gtkstyle.[ch]: Make gtk_paint_focus() take a
state argument as well so we can use fg[STATE] to
draw instead of always drawing with black.
Cange paint_focus() to respect GtkWidget::focus-width
and GtkWidget::focus-line-pattern. Fix continuity
problem where the default 1-1 stipple had a blob
in one corner and a gap in the other. Change the
interpretation of x/y/width/height to be the bounding
box of the focus rect instead of the rectangle
passed to gdk_draw_rectangle.
* gtk/gtkcheckbutton.c gtk/gtklistitem.c gtk/gtknotebook.c
gtk/gtkoptionmenu.c gtk/gtkradiobutton.c gtk/gtkspinbutton.c
gtk/gtktextview.c gtk/gtktreeview.c: Handle ::focus-width
and ::focus-line-padding.
* gtk/gtkentry.c: Handle :;focus-width property; cleanup
and remove duplicated code; fix drawing of focus rectangle
when interior-focus = FALSE. (#63072, #63073)
* gtk/gtkrange.c gtk/gtktext.c gtk/gtktreeitem.c
gtk/gtktreeviewcolumn.c: Basic fixups to make compile;
Range and TreeViewColumn will need more extensive fixing.
* gtk/gtkcolorsel.c: Honor focus line attributes when
drawing the focus on the color swatches. (#63071)
* gtk/gtkhsv.c: Honor focus line attributes when
drawing the focus for the ring and triangle.
* docs/widget_geometry.txt: Start at documenting how
various widgets are drawn.
* gtk/gtkbutton.c (_gtk_button_paint): Export
_gtk_button_paint() librarywide, so we don't have
duplicate a bunch of code in gtktogglebutton.c.
* gtk/gtktogglebutton.c: Use _gtk_button_paint().
Diffstat (limited to 'gtk/gtktogglebutton.c')
-rw-r--r-- | gtk/gtktogglebutton.c | 104 |
1 files changed, 10 insertions, 94 deletions
diff --git a/gtk/gtktogglebutton.c b/gtk/gtktogglebutton.c index a275b55fbf..0b159e5a02 100644 --- a/gtk/gtktogglebutton.c +++ b/gtk/gtktogglebutton.c @@ -50,8 +50,6 @@ enum { 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 gint gtk_toggle_button_expose (GtkWidget *widget, GdkEventExpose *event); static void gtk_toggle_button_pressed (GtkButton *button); @@ -369,63 +367,20 @@ gtk_toggle_button_get_inconsistent (GtkToggleButton *toggle_button) return toggle_button->inconsistent; } -static void -gtk_toggle_button_paint (GtkWidget *widget, - GdkRectangle *area) +static gint +gtk_toggle_button_expose (GtkWidget *widget, + GdkEventExpose *event) { - GtkButton *button; - GtkToggleButton *toggle_button; - GtkShadowType shadow_type; - GtkStateType state_type; - gint width, height; - gboolean interior_focus; - gint border_width; - gint x, y; - - button = GTK_BUTTON (widget); - toggle_button = GTK_TOGGLE_BUTTON (widget); - if (GTK_WIDGET_DRAWABLE (widget)) { - border_width = GTK_CONTAINER (widget)->border_width; - - gtk_widget_style_get (widget, "interior_focus", &interior_focus, NULL); - - 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) - { - gtk_paint_box (widget->style, widget->window, - GTK_STATE_NORMAL, GTK_SHADOW_IN, - area, widget, "togglebuttondefault", - x, y, width, height); - } - - if (GTK_WIDGET_CAN_DEFAULT (widget)) - { - x += widget->style->xthickness; - y += widget->style->ythickness; - width -= 2 * x + DEFAULT_SPACING; - height -= 2 * y + DEFAULT_SPACING; - x += DEFAULT_LEFT_POS; - y += DEFAULT_TOP_POS; - } - - if (GTK_WIDGET_HAS_FOCUS (widget) && !interior_focus) - { - x += 1; - y += 1; - width -= 2; - height -= 2; - } + GtkWidget *child = GTK_BIN (widget)->child; + GtkButton *button = GTK_BUTTON (widget); + GtkStateType state_type; + GtkShadowType shadow_type; state_type = GTK_WIDGET_STATE (widget); - if (toggle_button->inconsistent) + if (GTK_TOGGLE_BUTTON (widget)->inconsistent) { if (state_type == GTK_STATE_ACTIVE) state_type = GTK_STATE_NORMAL; @@ -434,47 +389,8 @@ gtk_toggle_button_paint (GtkWidget *widget, else shadow_type = button->depressed ? GTK_SHADOW_IN : GTK_SHADOW_OUT; - if (button->relief != GTK_RELIEF_NONE || - (GTK_WIDGET_STATE(widget) != GTK_STATE_NORMAL && - GTK_WIDGET_STATE(widget) != GTK_STATE_INSENSITIVE)) - gtk_paint_box (widget->style, widget->window, - state_type, - shadow_type, area, widget, "togglebutton", - x, y, width, height); - - if (GTK_WIDGET_HAS_FOCUS (widget)) - { - if (interior_focus) - { - x += widget->style->xthickness + 1; - y += widget->style->xthickness + 1; - width -= 2 * (widget->style->xthickness + 1); - height -= 2 * (widget->style->ythickness + 1); - } - else - { - x -= 1; - y -= 1; - width += 2; - height += 2; - } - - gtk_paint_focus (widget->style, widget->window, - area, widget, "togglebutton", - x, y, width - 1, height - 1); - } - } -} - -static gint -gtk_toggle_button_expose (GtkWidget *widget, - GdkEventExpose *event) -{ - if (GTK_WIDGET_DRAWABLE (widget)) - { - GtkWidget *child = GTK_BIN (widget)->child; - - gtk_toggle_button_paint (widget, &event->area); + _gtk_button_paint (button, &event->area, state_type, shadow_type, + "togglebutton", "togglebuttondefault"); if (child) gtk_container_propagate_expose (GTK_CONTAINER (widget), child, event); |