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/gtkoptionmenu.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/gtkoptionmenu.c')
-rw-r--r-- | gtk/gtkoptionmenu.c | 73 |
1 files changed, 40 insertions, 33 deletions
diff --git a/gtk/gtkoptionmenu.c b/gtk/gtkoptionmenu.c index 458a8fe431..283a09a7ec 100644 --- a/gtk/gtkoptionmenu.c +++ b/gtk/gtkoptionmenu.c @@ -33,7 +33,7 @@ #include "gdk/gdkkeysyms.h" -#define CHILD_LEFT_SPACING 5 +#define CHILD_LEFT_SPACING 4 #define CHILD_RIGHT_SPACING 1 #define CHILD_TOP_SPACING 1 #define CHILD_BOTTOM_SPACING 1 @@ -45,12 +45,16 @@ struct _GtkOptionMenuProps gboolean interior_focus; GtkRequisition indicator_size; GtkBorder indicator_spacing; + gint focus_width; + gint focus_pad; }; static GtkOptionMenuProps default_props = { - FALSE, + TRUE, { 7, 13 }, - { 7, 5, 2, 2 } /* Left, right, top, bottom */ + { 7, 5, 2, 2 }, /* Left, right, top, bottom */ + 1, + 0 }; static void gtk_option_menu_class_init (GtkOptionMenuClass *klass); @@ -409,6 +413,8 @@ gtk_option_menu_get_props (GtkOptionMenu *option_menu, "indicator_size", &indicator_size, "indicator_spacing", &indicator_spacing, "interior_focus", &props->interior_focus, + "focus_line_width", &props->focus_width, + "focus_padding", &props->focus_pad, NULL); if (indicator_size) @@ -445,15 +451,15 @@ gtk_option_menu_size_request (GtkWidget *widget, } requisition->width = ((GTK_CONTAINER (widget)->border_width + - GTK_WIDGET (widget)->style->xthickness) * 2 + + GTK_WIDGET (widget)->style->xthickness + props.focus_pad) * 2 + MAX (child_requisition.width, option_menu->width) + props.indicator_size.width + props.indicator_spacing.left + props.indicator_spacing.right + - CHILD_LEFT_SPACING + CHILD_RIGHT_SPACING + 2); + CHILD_LEFT_SPACING + CHILD_RIGHT_SPACING + props.focus_width * 2); requisition->height = ((GTK_CONTAINER (widget)->border_width + - GTK_WIDGET (widget)->style->ythickness) * 2 + + GTK_WIDGET (widget)->style->ythickness + props.focus_pad) * 2 + MAX (child_requisition.height, option_menu->height) + - CHILD_TOP_SPACING + CHILD_BOTTOM_SPACING + 2); + CHILD_TOP_SPACING + CHILD_BOTTOM_SPACING + props.focus_width * 2); tmp = (requisition->height - option_menu->height + props.indicator_size.height + props.indicator_spacing.top + props.indicator_spacing.bottom); @@ -483,16 +489,15 @@ gtk_option_menu_size_allocate (GtkWidget *widget, if (child && GTK_WIDGET_VISIBLE (child)) { gint xthickness = GTK_WIDGET (widget)->style->xthickness; + gint ythickness = GTK_WIDGET (widget)->style->ythickness; - child_allocation.x = widget->allocation.x + border_width + xthickness + 1; - child_allocation.y = widget->allocation.y + 2 * border_width + 1; - child_allocation.width = MAX (1, (gint)allocation->width - (xthickness + 1) * 2 - border_width * 2 - + child_allocation.x = widget->allocation.x + border_width + xthickness + props.focus_width + props.focus_pad + CHILD_LEFT_SPACING; + child_allocation.y = widget->allocation.y + border_width + ythickness + props.focus_width + props.focus_pad + CHILD_TOP_SPACING; + child_allocation.width = MAX (1, allocation->width - (border_width + xthickness + props.focus_width + props.focus_pad) * 2 - props.indicator_size.width - props.indicator_spacing.left - props.indicator_spacing.right - - CHILD_LEFT_SPACING - CHILD_RIGHT_SPACING - 2); - child_allocation.height = MAX (1, (gint)allocation->height - (border_width + 1) * 2 - border_width * 2 - - CHILD_TOP_SPACING - CHILD_BOTTOM_SPACING - 2); - child_allocation.x += CHILD_LEFT_SPACING; - child_allocation.y += CHILD_TOP_SPACING; + CHILD_LEFT_SPACING - CHILD_RIGHT_SPACING); + child_allocation.height = MAX (1, allocation->height - (border_width + ythickness + props.focus_width + props.focus_pad) * 2 - + CHILD_TOP_SPACING - CHILD_BOTTOM_SPACING); gtk_widget_size_allocate (child, &child_allocation); } @@ -519,14 +524,14 @@ gtk_option_menu_paint (GtkWidget *widget, button_area.width = widget->allocation.width - 2 * border_width; button_area.height = widget->allocation.height - 2 * border_width; - if (!props.interior_focus) + if (!props.interior_focus && GTK_WIDGET_HAS_FOCUS (widget)) { - button_area.x += 1; - button_area.y += 1; - button_area.width -= 2; - button_area.height -= 2; + button_area.x += props.focus_width + props.focus_pad; + button_area.y += props.focus_width + props.focus_pad; + button_area.width -= 2 * (props.focus_width + props.focus_pad); + button_area.height -= 2 * (props.focus_width + props.focus_pad); } - + gtk_paint_box (widget->style, widget->window, GTK_WIDGET_STATE (widget), GTK_SHADOW_OUT, area, widget, "optionmenu", @@ -546,26 +551,28 @@ gtk_option_menu_paint (GtkWidget *widget, { if (props.interior_focus) { - button_area.x += widget->style->xthickness + 1; - button_area.y += widget->style->ythickness + 1; - button_area.width -= 2 * (widget->style->xthickness + 1) - + props.indicator_spacing.left + props.indicator_spacing.right + props.indicator_size.width; - button_area.height -= 2 * (widget->style->ythickness + 1); + button_area.x += widget->style->xthickness + props.focus_pad; + button_area.y += widget->style->ythickness + props.focus_pad; + button_area.width -= 2 * (widget->style->xthickness + props.focus_pad) + + props.indicator_spacing.left + + props.indicator_spacing.right + + props.indicator_size.width; + button_area.height -= 2 * (widget->style->ythickness + props.focus_pad); } else { - button_area.x -= 1; - button_area.y -= 1; - button_area.width += 2; - button_area.height += 2; + button_area.x -= props.focus_width + props.focus_pad; + button_area.y -= props.focus_width + props.focus_pad; + button_area.width += 2 * (props.focus_width + props.focus_pad); + button_area.height += 2 * (props.focus_width + props.focus_pad); } - gtk_paint_focus (widget->style, widget->window, + gtk_paint_focus (widget->style, widget->window, GTK_WIDGET_STATE (widget), area, widget, "button", button_area.x, button_area.y, - button_area.width - 1, - button_area.height - 1); + button_area.width, + button_area.height); } } } |