diff options
author | Matthias Clasen <maclas@gmx.de> | 2004-03-11 21:10:49 +0000 |
---|---|---|
committer | Matthias Clasen <matthiasc@src.gnome.org> | 2004-03-11 21:10:49 +0000 |
commit | c20280810ab86d65b7ef5089002c24be90e49d43 (patch) | |
tree | 8b3a5072ea323e6f7640300d88b7aa63248543dd /gtk/gtkspinbutton.c | |
parent | 3e696271463f84d4ea0c46823466cba20ab7c40e (diff) | |
download | gtk+-c20280810ab86d65b7ef5089002c24be90e49d43.tar.gz |
Use the same logic as GtkEntry when calculating border width. (#116368,
Thu Mar 11 22:12:14 2004 Matthias Clasen <maclas@gmx.de>
* gtk/gtkspinbutton.c (gtk_spin_button_size_request): Use the same
logic as GtkEntry when calculating border width. (#116368, reported
by Morten Welinder)
Diffstat (limited to 'gtk/gtkspinbutton.c')
-rw-r--r-- | gtk/gtkspinbutton.c | 43 |
1 files changed, 40 insertions, 3 deletions
diff --git a/gtk/gtkspinbutton.c b/gtk/gtkspinbutton.c index 7a65b5b028..1c4c30924b 100644 --- a/gtk/gtkspinbutton.c +++ b/gtk/gtkspinbutton.c @@ -616,6 +616,40 @@ compute_double_length (double val, int digits) return a + digits + extra; } +/* Keep in sync with gtkentry.c ! + */ +static void +get_borders (GtkEntry *entry, + gint *xborder, + gint *yborder) +{ + GtkWidget *widget = GTK_WIDGET (entry); + gint focus_width; + gboolean interior_focus; + + gtk_widget_style_get (widget, + "interior-focus", &interior_focus, + "focus-line-width", &focus_width, + NULL); + + if (entry->has_frame) + { + *xborder = widget->style->xthickness; + *yborder = widget->style->ythickness; + } + else + { + *xborder = 0; + *yborder = 0; + } + + if (!interior_focus) + { + *xborder += focus_width; + *yborder += focus_width; + } +} + static void gtk_spin_button_size_request (GtkWidget *widget, GtkRequisition *requisition) @@ -641,6 +675,7 @@ gtk_spin_button_size_request (GtkWidget *widget, gint digit_width; gboolean interior_focus; gint focus_width; + gint xborder, yborder; gtk_widget_style_get (widget, "interior-focus", &interior_focus, @@ -673,9 +708,11 @@ gtk_spin_button_size_request (GtkWidget *widget, w = PANGO_PIXELS (MIN (string_len, max_string_len) * digit_width); width = MAX (width, w); - requisition->width = width + /* INNER_BORDER */ 2 * 2; - if (!interior_focus) - requisition->width += 2 * focus_width; + get_borders (entry, &xborder, &yborder); + + xborder += 2; /* INNER_BORDER */ + + requisition->width = width + xborder * 2; } requisition->width += arrow_size + 2 * widget->style->xthickness; |