always display the correct active state.

Thu Mar 26 21:37:57 1998  Tim Janik  <timj@gtk.org>

        * gtk/gtkradiobutton.c (gtk_radio_button_draw_indicator): always
                display the correct active state.

                        * gtk/gtkcheckbutton.c (gtk_real_check_button_draw_indicator): always
                                display the correct active state.

                                        * gtk/gtkwidget.c (gtk_widget_set_arg): CAN_FOCUS and CAN_DEFAULT flag
                                                changes need to queue a resize.

                                                        * gtk/gtkbutton.c (gtk_button_paint): take border_width into
                                                                consideration for restrict area.

                                                                        * gtk/gtktogglebutton.c (gtk_toggle_button_class_init): enable the
                                                                                draw_default member of GtkButton, otherwise the diplay is messed up
                                                                                        for CAN_DEFAULT toggles.
                                                                                                (gtk_toggle_button_draw_focus): always display whether the toggle button
                                                                                                        is active or not.

                                                                                                                * gtk/gtkwidget.c (gtk_widget_set_state):
                                                                                                                        (gtk_widget_set_sensitive):
                                                                                                                                (gtk_widget_set_parent):
                                                                                                                                        (gtk_widget_propagate_state): take into consideration, whether we really
                                                                                                                                                want to change childrens states, or just restauration of old states.
This commit is contained in:
Tim Janik 1998-03-26 21:57:45 +00:00 committed by Tim Janik
parent a74e338517
commit c2906f2bea
13 changed files with 248 additions and 46 deletions

View File

@ -1,3 +1,29 @@
Thu Mar 26 21:37:57 1998 Tim Janik <timj@gtk.org>
* gtk/gtkradiobutton.c (gtk_radio_button_draw_indicator): always
display the correct active state.
* gtk/gtkcheckbutton.c (gtk_real_check_button_draw_indicator): always
display the correct active state.
* gtk/gtkwidget.c (gtk_widget_set_arg): CAN_FOCUS and CAN_DEFAULT flag
changes need to queue a resize.
* gtk/gtkbutton.c (gtk_button_paint): take border_width into
consideration for restrict area.
* gtk/gtktogglebutton.c (gtk_toggle_button_class_init): enable the
draw_default member of GtkButton, otherwise the diplay is messed up
for CAN_DEFAULT toggles.
(gtk_toggle_button_draw_focus): always display whether the toggle button
is active or not.
* gtk/gtkwidget.c (gtk_widget_set_state):
(gtk_widget_set_sensitive):
(gtk_widget_set_parent):
(gtk_widget_propagate_state): take into consideration, whether we really
want to change childrens states, or just restauration of old states.
Thu Mar 26 15:33:50 1998 Owen Taylor <owt1@cornell.edu>
* gtk/gtkwidget.c: When gtk_widget_draw() is called on a

View File

@ -1,3 +1,29 @@
Thu Mar 26 21:37:57 1998 Tim Janik <timj@gtk.org>
* gtk/gtkradiobutton.c (gtk_radio_button_draw_indicator): always
display the correct active state.
* gtk/gtkcheckbutton.c (gtk_real_check_button_draw_indicator): always
display the correct active state.
* gtk/gtkwidget.c (gtk_widget_set_arg): CAN_FOCUS and CAN_DEFAULT flag
changes need to queue a resize.
* gtk/gtkbutton.c (gtk_button_paint): take border_width into
consideration for restrict area.
* gtk/gtktogglebutton.c (gtk_toggle_button_class_init): enable the
draw_default member of GtkButton, otherwise the diplay is messed up
for CAN_DEFAULT toggles.
(gtk_toggle_button_draw_focus): always display whether the toggle button
is active or not.
* gtk/gtkwidget.c (gtk_widget_set_state):
(gtk_widget_set_sensitive):
(gtk_widget_set_parent):
(gtk_widget_propagate_state): take into consideration, whether we really
want to change childrens states, or just restauration of old states.
Thu Mar 26 15:33:50 1998 Owen Taylor <owt1@cornell.edu>
* gtk/gtkwidget.c: When gtk_widget_draw() is called on a

View File

@ -1,3 +1,29 @@
Thu Mar 26 21:37:57 1998 Tim Janik <timj@gtk.org>
* gtk/gtkradiobutton.c (gtk_radio_button_draw_indicator): always
display the correct active state.
* gtk/gtkcheckbutton.c (gtk_real_check_button_draw_indicator): always
display the correct active state.
* gtk/gtkwidget.c (gtk_widget_set_arg): CAN_FOCUS and CAN_DEFAULT flag
changes need to queue a resize.
* gtk/gtkbutton.c (gtk_button_paint): take border_width into
consideration for restrict area.
* gtk/gtktogglebutton.c (gtk_toggle_button_class_init): enable the
draw_default member of GtkButton, otherwise the diplay is messed up
for CAN_DEFAULT toggles.
(gtk_toggle_button_draw_focus): always display whether the toggle button
is active or not.
* gtk/gtkwidget.c (gtk_widget_set_state):
(gtk_widget_set_sensitive):
(gtk_widget_set_parent):
(gtk_widget_propagate_state): take into consideration, whether we really
want to change childrens states, or just restauration of old states.
Thu Mar 26 15:33:50 1998 Owen Taylor <owt1@cornell.edu>
* gtk/gtkwidget.c: When gtk_widget_draw() is called on a

View File

@ -1,3 +1,29 @@
Thu Mar 26 21:37:57 1998 Tim Janik <timj@gtk.org>
* gtk/gtkradiobutton.c (gtk_radio_button_draw_indicator): always
display the correct active state.
* gtk/gtkcheckbutton.c (gtk_real_check_button_draw_indicator): always
display the correct active state.
* gtk/gtkwidget.c (gtk_widget_set_arg): CAN_FOCUS and CAN_DEFAULT flag
changes need to queue a resize.
* gtk/gtkbutton.c (gtk_button_paint): take border_width into
consideration for restrict area.
* gtk/gtktogglebutton.c (gtk_toggle_button_class_init): enable the
draw_default member of GtkButton, otherwise the diplay is messed up
for CAN_DEFAULT toggles.
(gtk_toggle_button_draw_focus): always display whether the toggle button
is active or not.
* gtk/gtkwidget.c (gtk_widget_set_state):
(gtk_widget_set_sensitive):
(gtk_widget_set_parent):
(gtk_widget_propagate_state): take into consideration, whether we really
want to change childrens states, or just restauration of old states.
Thu Mar 26 15:33:50 1998 Owen Taylor <owt1@cornell.edu>
* gtk/gtkwidget.c: When gtk_widget_draw() is called on a

View File

@ -1,3 +1,29 @@
Thu Mar 26 21:37:57 1998 Tim Janik <timj@gtk.org>
* gtk/gtkradiobutton.c (gtk_radio_button_draw_indicator): always
display the correct active state.
* gtk/gtkcheckbutton.c (gtk_real_check_button_draw_indicator): always
display the correct active state.
* gtk/gtkwidget.c (gtk_widget_set_arg): CAN_FOCUS and CAN_DEFAULT flag
changes need to queue a resize.
* gtk/gtkbutton.c (gtk_button_paint): take border_width into
consideration for restrict area.
* gtk/gtktogglebutton.c (gtk_toggle_button_class_init): enable the
draw_default member of GtkButton, otherwise the diplay is messed up
for CAN_DEFAULT toggles.
(gtk_toggle_button_draw_focus): always display whether the toggle button
is active or not.
* gtk/gtkwidget.c (gtk_widget_set_state):
(gtk_widget_set_sensitive):
(gtk_widget_set_parent):
(gtk_widget_propagate_state): take into consideration, whether we really
want to change childrens states, or just restauration of old states.
Thu Mar 26 15:33:50 1998 Owen Taylor <owt1@cornell.edu>
* gtk/gtkwidget.c: When gtk_widget_draw() is called on a

View File

@ -1,3 +1,29 @@
Thu Mar 26 21:37:57 1998 Tim Janik <timj@gtk.org>
* gtk/gtkradiobutton.c (gtk_radio_button_draw_indicator): always
display the correct active state.
* gtk/gtkcheckbutton.c (gtk_real_check_button_draw_indicator): always
display the correct active state.
* gtk/gtkwidget.c (gtk_widget_set_arg): CAN_FOCUS and CAN_DEFAULT flag
changes need to queue a resize.
* gtk/gtkbutton.c (gtk_button_paint): take border_width into
consideration for restrict area.
* gtk/gtktogglebutton.c (gtk_toggle_button_class_init): enable the
draw_default member of GtkButton, otherwise the diplay is messed up
for CAN_DEFAULT toggles.
(gtk_toggle_button_draw_focus): always display whether the toggle button
is active or not.
* gtk/gtkwidget.c (gtk_widget_set_state):
(gtk_widget_set_sensitive):
(gtk_widget_set_parent):
(gtk_widget_propagate_state): take into consideration, whether we really
want to change childrens states, or just restauration of old states.
Thu Mar 26 15:33:50 1998 Owen Taylor <owt1@cornell.edu>
* gtk/gtkwidget.c: When gtk_widget_draw() is called on a

View File

@ -1,3 +1,29 @@
Thu Mar 26 21:37:57 1998 Tim Janik <timj@gtk.org>
* gtk/gtkradiobutton.c (gtk_radio_button_draw_indicator): always
display the correct active state.
* gtk/gtkcheckbutton.c (gtk_real_check_button_draw_indicator): always
display the correct active state.
* gtk/gtkwidget.c (gtk_widget_set_arg): CAN_FOCUS and CAN_DEFAULT flag
changes need to queue a resize.
* gtk/gtkbutton.c (gtk_button_paint): take border_width into
consideration for restrict area.
* gtk/gtktogglebutton.c (gtk_toggle_button_class_init): enable the
draw_default member of GtkButton, otherwise the diplay is messed up
for CAN_DEFAULT toggles.
(gtk_toggle_button_draw_focus): always display whether the toggle button
is active or not.
* gtk/gtkwidget.c (gtk_widget_set_state):
(gtk_widget_set_sensitive):
(gtk_widget_set_parent):
(gtk_widget_propagate_state): take into consideration, whether we really
want to change childrens states, or just restauration of old states.
Thu Mar 26 15:33:50 1998 Owen Taylor <owt1@cornell.edu>
* gtk/gtkwidget.c: When gtk_widget_draw() is called on a

7
TODO
View File

@ -73,6 +73,13 @@ TODO AFTER GTK 1.0
------------------
* Make all widget attributes configurable after the widget is created (timj).
* Widgets dervied from GtkButton need to be able to override
GtkButtonClass.paint. e.g. redrawing of GtkToggleButton with CAN_DEFAULT
is messed up otheriwse. This does in fact not only apply to (toggle)buttons,
we should introduce a common paint member for the GtkWidgetClass.
* Radio buttons need to display CAN/HAS_DEFAULT correctly.
* GtkCList improvements. (Jay Painter)

View File

@ -454,12 +454,12 @@ gtk_button_paint (GtkWidget *widget,
if (GTK_WIDGET_DRAWABLE (widget))
{
restrict_area.x = GTK_WIDGET (widget)->style->klass->xthickness;
restrict_area.y = GTK_WIDGET (widget)->style->klass->ythickness;
restrict_area.width = (GTK_WIDGET (widget)->allocation.width - restrict_area.x * 2 -
GTK_CONTAINER (widget)->border_width * 2);
restrict_area.height = (GTK_WIDGET (widget)->allocation.height - restrict_area.y * 2 -
GTK_CONTAINER (widget)->border_width * 2);
restrict_area.x = (GTK_WIDGET (widget)->style->klass->xthickness +
GTK_CONTAINER (widget)->border_width);
restrict_area.y = (GTK_WIDGET (widget)->style->klass->ythickness +
GTK_CONTAINER (widget)->border_width);
restrict_area.width = GTK_WIDGET (widget)->allocation.width - restrict_area.x * 2;
restrict_area.height = GTK_WIDGET (widget)->allocation.height - restrict_area.y * 2;
if (GTK_WIDGET_CAN_DEFAULT (widget))
{

View File

@ -362,9 +362,7 @@ gtk_real_check_button_draw_indicator (GtkCheckButton *check_button,
width = CHECK_BUTTON_CLASS (widget)->indicator_size;
height = CHECK_BUTTON_CLASS (widget)->indicator_size;
if (GTK_WIDGET_STATE (widget) == GTK_STATE_ACTIVE)
shadow_type = GTK_SHADOW_IN;
else if ((GTK_WIDGET_STATE (widget) == GTK_STATE_PRELIGHT) && toggle_button->active)
if (GTK_TOGGLE_BUTTON (widget)->active)
shadow_type = GTK_SHADOW_IN;
else
shadow_type = GTK_SHADOW_OUT;

View File

@ -329,9 +329,7 @@ gtk_radio_button_draw_indicator (GtkCheckButton *check_button,
width = CHECK_BUTTON_CLASS (widget)->indicator_size;
height = CHECK_BUTTON_CLASS (widget)->indicator_size;
if (GTK_WIDGET_STATE (widget) == GTK_STATE_ACTIVE)
shadow_type = GTK_SHADOW_IN;
else if ((GTK_WIDGET_STATE (widget) == GTK_STATE_PRELIGHT) && toggle_button->active)
if (GTK_TOGGLE_BUTTON (widget)->active)
shadow_type = GTK_SHADOW_IN;
else
shadow_type = GTK_SHADOW_OUT;

View File

@ -92,7 +92,6 @@ gtk_toggle_button_class_init (GtkToggleButtonClass *class)
gtk_object_class_add_signals (object_class, toggle_button_signals, LAST_SIGNAL);
widget_class->draw_focus = gtk_toggle_button_draw_focus;
widget_class->draw_default = NULL;
button_class->pressed = gtk_toggle_button_pressed;
button_class->released = gtk_toggle_button_released;
@ -181,15 +180,15 @@ gtk_toggle_button_draw_focus (GtkWidget *widget)
g_return_if_fail (widget != NULL);
g_return_if_fail (GTK_IS_TOGGLE_BUTTON (widget));
if (GTK_WIDGET_DRAWABLE (widget))
if (GTK_WIDGET_DRAWABLE (widget))
{
button = GTK_BUTTON (widget);
toggle_button = GTK_TOGGLE_BUTTON (widget);
x = 0;
y = 0;
width = widget->allocation.width - GTK_CONTAINER (widget)->border_width * 2;
height = widget->allocation.height - GTK_CONTAINER (widget)->border_width * 2;
width = widget->allocation.width - GTK_CONTAINER (widget)->border_width * 2;
height = widget->allocation.height - GTK_CONTAINER (widget)->border_width * 2;
if (GTK_WIDGET_CAN_DEFAULT (widget))
{
@ -210,7 +209,7 @@ gtk_toggle_button_draw_focus (GtkWidget *widget)
}
else
{
if (GTK_WIDGET_STATE (widget) == GTK_STATE_ACTIVE)
if (GTK_WIDGET_STATE (toggle_button) == GTK_STATE_ACTIVE)
gdk_draw_rectangle (widget->window,
widget->style->bg_gc[GTK_WIDGET_STATE (widget)], FALSE,
x + 1, y + 1, width - 4, height - 4);
@ -220,9 +219,7 @@ gtk_toggle_button_draw_focus (GtkWidget *widget)
x + 2, y + 2, width - 5, height - 5);
}
if (GTK_WIDGET_STATE (widget) == GTK_STATE_ACTIVE)
shadow_type = GTK_SHADOW_IN;
else if ((GTK_WIDGET_STATE (widget) == GTK_STATE_PRELIGHT) && toggle_button->active)
if (toggle_button->active)
shadow_type = GTK_SHADOW_IN;
else
shadow_type = GTK_SHADOW_OUT;

View File

@ -133,7 +133,8 @@ typedef struct _GtkStateData GtkStateData;
struct _GtkStateData
{
GtkStateType state;
gint parent_sensitive;
guint state_restauration : 1;
guint parent_sensitive : 1;
};
@ -760,6 +761,8 @@ gtk_widget_set_arg (GtkWidget *widget,
GtkArg *arg,
guint arg_id)
{
guint32 saved_flags;
switch (arg_id)
{
case ARG_NAME:
@ -790,20 +793,26 @@ gtk_widget_set_arg (GtkWidget *widget,
gtk_widget_set_sensitive (widget, GTK_VALUE_BOOL (*arg));
break;
case ARG_CAN_FOCUS:
saved_flags = GTK_WIDGET_FLAGS (widget);
if (GTK_VALUE_BOOL (*arg))
GTK_WIDGET_SET_FLAGS (widget, GTK_CAN_FOCUS);
else
GTK_WIDGET_UNSET_FLAGS (widget, GTK_CAN_FOCUS);
if (saved_flags != GTK_WIDGET_FLAGS (widget))
gtk_widget_queue_resize (widget);
break;
case ARG_HAS_FOCUS:
if (GTK_VALUE_BOOL (*arg))
gtk_widget_grab_focus (widget);
break;
case ARG_CAN_DEFAULT:
saved_flags = GTK_WIDGET_FLAGS (widget);
if (GTK_VALUE_BOOL (*arg))
GTK_WIDGET_SET_FLAGS (widget, GTK_CAN_DEFAULT);
else
GTK_WIDGET_UNSET_FLAGS (widget, GTK_CAN_DEFAULT);
if (saved_flags != GTK_WIDGET_FLAGS (widget))
gtk_widget_queue_resize (widget);
break;
case ARG_HAS_DEFAULT:
if (GTK_VALUE_BOOL (*arg))
@ -2255,6 +2264,7 @@ gtk_widget_set_state (GtkWidget *widget,
GtkStateType state)
{
g_return_if_fail (widget != NULL);
g_return_if_fail (GTK_IS_WIDGET (widget));
if (state == GTK_WIDGET_STATE (widget))
return;
@ -2264,19 +2274,16 @@ gtk_widget_set_state (GtkWidget *widget,
else
{
GtkStateData data;
GtkStateType old_state;
data.state = state;
data.state_restauration = FALSE;
if (widget->parent)
data.parent_sensitive = GTK_WIDGET_IS_SENSITIVE (widget->parent);
data.parent_sensitive = (GTK_WIDGET_IS_SENSITIVE (widget->parent) != FALSE);
else
data.parent_sensitive = GTK_PARENT_SENSITIVE;
old_state = GTK_WIDGET_STATE (widget);
data.parent_sensitive = TRUE;
gtk_widget_propagate_state (widget, &data);
if (old_state != GTK_WIDGET_STATE (widget))
gtk_widget_queue_draw (widget);
gtk_widget_queue_draw (widget);
}
}
@ -2295,33 +2302,34 @@ gtk_widget_set_sensitive (GtkWidget *widget,
gint sensitive)
{
GtkStateData data;
GtkStateType old_state;
g_return_if_fail (widget != NULL);
g_return_if_fail (GTK_IS_WIDGET (widget));
sensitive = (sensitive != FALSE);
if (sensitive == (GTK_WIDGET_SENSITIVE (widget) != FALSE))
return;
if (sensitive)
{
GTK_WIDGET_SET_FLAGS (widget, GTK_SENSITIVE);
if (GTK_WIDGET_STATE (widget) == GTK_STATE_INSENSITIVE)
data.state = GTK_WIDGET_SAVED_STATE (widget);
else
data.state = GTK_WIDGET_STATE (widget);
data.state = GTK_WIDGET_SAVED_STATE (widget);
}
else
{
GTK_WIDGET_UNSET_FLAGS (widget, GTK_SENSITIVE);
data.state = GTK_WIDGET_STATE (widget);
}
data.state_restauration = TRUE;
if (widget->parent)
data.parent_sensitive = GTK_WIDGET_IS_SENSITIVE (widget->parent);
data.parent_sensitive = (GTK_WIDGET_IS_SENSITIVE (widget->parent) != FALSE);
else
data.parent_sensitive = GTK_PARENT_SENSITIVE;
data.parent_sensitive = TRUE;
old_state = GTK_WIDGET_STATE (widget);
gtk_widget_propagate_state (widget, &data);
if (old_state != GTK_WIDGET_STATE (widget))
gtk_widget_queue_draw (widget);
gtk_widget_queue_draw (widget);
}
/*****************************************
@ -2354,7 +2362,8 @@ gtk_widget_set_parent (GtkWidget *widget,
data.state = GTK_WIDGET_STATE (parent);
else
data.state = GTK_WIDGET_STATE (widget);
data.parent_sensitive = GTK_WIDGET_IS_SENSITIVE (parent);
data.state_restauration = FALSE;
data.parent_sensitive = (GTK_WIDGET_IS_SENSITIVE (parent) != FALSE);
gtk_widget_propagate_state (widget, &data);
@ -3752,8 +3761,8 @@ gtk_widget_propagate_state (GtkWidget *widget,
{
guint8 old_state;
/* don't call this function with state=GTK_STATE_INSENSITIVE,
* parent_sensitive=TRUE and a sensitive widget
/* don't call this function with state==GTK_STATE_INSENSITIVE,
* parent_sensitive==TRUE on a sensitive widget
*/
old_state = GTK_WIDGET_STATE (widget);
@ -3763,20 +3772,31 @@ gtk_widget_propagate_state (GtkWidget *widget,
GTK_WIDGET_SET_FLAGS (widget, GTK_PARENT_SENSITIVE);
if (GTK_WIDGET_IS_SENSITIVE (widget))
GTK_WIDGET_STATE (widget) = data->state;
{
if (data->state_restauration)
GTK_WIDGET_STATE (widget) = GTK_WIDGET_SAVED_STATE (widget);
else
GTK_WIDGET_STATE (widget) = data->state;
}
else
{
GTK_WIDGET_STATE (widget) = GTK_STATE_INSENSITIVE;
if (data->state != GTK_STATE_INSENSITIVE)
if (!data->state_restauration &&
data->state != GTK_STATE_INSENSITIVE)
GTK_WIDGET_SAVED_STATE (widget) = data->state;
}
}
else
{
GTK_WIDGET_UNSET_FLAGS (widget, GTK_PARENT_SENSITIVE);
if (!data->state_restauration)
{
if (data->state != GTK_STATE_INSENSITIVE)
GTK_WIDGET_SAVED_STATE (widget) = data->state;
}
else if (GTK_WIDGET_STATE (widget) != GTK_STATE_INSENSITIVE)
GTK_WIDGET_SAVED_STATE (widget) = GTK_WIDGET_STATE (widget);
GTK_WIDGET_STATE (widget) = GTK_STATE_INSENSITIVE;
if (data->state != GTK_STATE_INSENSITIVE)
GTK_WIDGET_SAVED_STATE (widget) = data->state;
}
if (GTK_WIDGET_HAS_FOCUS (widget) && !GTK_WIDGET_IS_SENSITIVE (widget))
@ -3795,7 +3815,7 @@ gtk_widget_propagate_state (GtkWidget *widget,
if (GTK_IS_CONTAINER (widget))
{
data->parent_sensitive = GTK_WIDGET_IS_SENSITIVE (widget);
data->parent_sensitive = (GTK_WIDGET_IS_SENSITIVE (widget) != FALSE);
data->state = GTK_WIDGET_STATE (widget);
gtk_container_foreach (GTK_CONTAINER (widget),
(GtkCallback) gtk_widget_propagate_state,