summaryrefslogtreecommitdiff
path: root/gtk
diff options
context:
space:
mode:
authorOwen Taylor <otaylor@redhat.com>2002-10-17 20:20:52 +0000
committerOwen Taylor <otaylor@src.gnome.org>2002-10-17 20:20:52 +0000
commitde89785a28b0b141ff4c9ea5a7798320ed8082d9 (patch)
tree438704caefd7588b204d68dcdffd3d459d24ff8f /gtk
parenta9d26e1478f33ca3d1aec25e7378feb7fc340022 (diff)
downloadgtk+-de89785a28b0b141ff4c9ea5a7798320ed8082d9.tar.gz
Make the widgets work reasonably when they don't have children -- draw the
Thu Oct 17 16:13:28 2002 Owen Taylor <otaylor@redhat.com> * gtk/gtkcheckbutton.c gtk/gtkradiobutton.c: Make the widgets work reasonably when they don't have children -- draw the focus around the indicator, and position the indicator symmetrically. (#74830, Dave Camp) * tests/testgtk.c: Add no-child portions to check and radio button tests.
Diffstat (limited to 'gtk')
-rw-r--r--gtk/gtkcheckbutton.c29
-rw-r--r--gtk/gtkradiobutton.c4
2 files changed, 17 insertions, 16 deletions
diff --git a/gtk/gtkcheckbutton.c b/gtk/gtkcheckbutton.c
index 1fa1c1f832..963cb6ea99 100644
--- a/gtk/gtkcheckbutton.c
+++ b/gtk/gtkcheckbutton.c
@@ -177,18 +177,15 @@ gtk_check_button_paint (GtkWidget *widget,
border_width = GTK_CONTAINER (widget)->border_width;
if (GTK_WIDGET_HAS_FOCUS (widget))
{
- if (interior_focus)
- {
- GtkWidget *child = GTK_BIN (widget)->child;
-
- if (child && GTK_WIDGET_VISIBLE (child))
- gtk_paint_focus (widget->style, widget->window, GTK_WIDGET_STATE (widget),
- NULL, widget, "checkbutton",
- child->allocation.x - focus_width - focus_pad,
- child->allocation.y - focus_width - focus_pad,
- child->allocation.width + 2 * (focus_width + focus_pad),
- child->allocation.height + 2 * (focus_width + focus_pad));
- }
+ GtkWidget *child = GTK_BIN (widget)->child;
+
+ if (interior_focus && child && GTK_WIDGET_VISIBLE (child))
+ gtk_paint_focus (widget->style, widget->window, GTK_WIDGET_STATE (widget),
+ NULL, widget, "checkbutton",
+ child->allocation.x - focus_width - focus_pad,
+ child->allocation.y - focus_width - focus_pad,
+ child->allocation.width + 2 * (focus_width + focus_pad),
+ child->allocation.height + 2 * (focus_width + focus_pad));
else
gtk_paint_focus (widget->style, widget->window, GTK_WIDGET_STATE (widget),
NULL, widget, "checkbutton",
@@ -245,14 +242,14 @@ gtk_check_button_size_request (GtkWidget *widget,
gtk_widget_size_request (child, &child_requisition);
- requisition->width += child_requisition.width;
+ requisition->width += child_requisition.width + indicator_spacing;
requisition->height += child_requisition.height;
}
_gtk_check_button_get_props (GTK_CHECK_BUTTON (widget),
&indicator_size, &indicator_spacing);
- requisition->width += (indicator_size + indicator_spacing * 3 + 2 * (focus_width + focus_pad));
+ requisition->width += (indicator_size + indicator_spacing * 2 + 2 * (focus_width + focus_pad));
temp = indicator_size + indicator_spacing * 2;
requisition->height = MAX (requisition->height, temp) + 2 * (focus_width + focus_pad);
@@ -376,6 +373,7 @@ gtk_real_check_button_draw_indicator (GtkCheckButton *check_button,
GdkRectangle *area)
{
GtkWidget *widget;
+ GtkWidget *child;
GtkButton *button;
GtkToggleButton *toggle_button;
GtkStateType state_type;
@@ -402,7 +400,8 @@ gtk_real_check_button_draw_indicator (GtkCheckButton *check_button,
x = widget->allocation.x + indicator_spacing + GTK_CONTAINER (widget)->border_width;
y = widget->allocation.y + (widget->allocation.height - indicator_size) / 2;
- if (!interior_focus)
+ child = GTK_BIN (check_button)->child;
+ if (!interior_focus || !(child && GTK_WIDGET_VISIBLE (child)))
x += focus_width + focus_pad;
if (toggle_button->inconsistent)
diff --git a/gtk/gtkradiobutton.c b/gtk/gtkradiobutton.c
index 57f1b178a0..f7feaf0e7c 100644
--- a/gtk/gtkradiobutton.c
+++ b/gtk/gtkradiobutton.c
@@ -599,6 +599,7 @@ gtk_radio_button_draw_indicator (GtkCheckButton *check_button,
GdkRectangle *area)
{
GtkWidget *widget;
+ GtkWidget *child;
GtkButton *button;
GtkToggleButton *toggle_button;
GtkStateType state_type;
@@ -626,7 +627,8 @@ gtk_radio_button_draw_indicator (GtkCheckButton *check_button,
x = widget->allocation.x + indicator_spacing + GTK_CONTAINER (widget)->border_width;
y = widget->allocation.y + (widget->allocation.height - indicator_size) / 2;
- if (!interior_focus)
+ child = GTK_BIN (check_button)->child;
+ if (!interior_focus || !(child && GTK_WIDGET_VISIBLE (child)))
x += focus_width + focus_pad;
if (toggle_button->inconsistent)