diff options
author | Havoc Pennington <hp@redhat.com> | 2001-02-19 22:25:30 +0000 |
---|---|---|
committer | Havoc Pennington <hp@src.gnome.org> | 2001-02-19 22:25:30 +0000 |
commit | f4fa22da5524e90e70a14b9630d810b23d0b520e (patch) | |
tree | 2118721fb1b3fd3f74e5427315266c1d94dda7cf /gtk/gtktogglebutton.c | |
parent | 6fb6363e3013d67e19b9e2b1e5b9d1a3c8f67494 (diff) | |
download | gtk+-f4fa22da5524e90e70a14b9630d810b23d0b520e.tar.gz |
test was backward, so deprecated functions were excluded by default
2001-02-19 Havoc Pennington <hp@redhat.com>
* gdk/gdkcolor.h: test was backward, so deprecated functions were
excluded by default
* gtk/gtkstyle.c (gtk_default_draw_diamond): draw etched in/out,
clean up the old code a bit
* gtk/gtkradiobutton.c (gtk_radio_button_draw_indicator): draw
inconsistent state
* gtk/gtkradiomenuitem.c (gtk_radio_menu_item_draw_indicator):
draw inconsistent state
* gtk/testgtk.c (create_toggle_buttons): add test for inconsistent
(create_menu): add inconsistent test
* gtk/gtkcheckmenuitem.c (gtk_check_menu_item_set_inconsistent):
new function
(gtk_check_menu_item_get_inconsistent): new function
(gtk_real_check_menu_item_draw_indicator): draw the inconsistent
state (using etched in for now)
* gtk/gtkcheckbutton.c (gtk_real_check_button_draw_indicator):
draw inconsistent state
* gtk/gtktogglebutton.c (gtk_toggle_button_set_inconsistent): new
function, used when the user has selected a range of stuff in
different states
(gtk_toggle_button_get_inconsistent): accessor for that
(gtk_toggle_button_paint): draw inconsistent state (etched in?
don't know what else to do)
Diffstat (limited to 'gtk/gtktogglebutton.c')
-rw-r--r-- | gtk/gtktogglebutton.c | 60 |
1 files changed, 57 insertions, 3 deletions
diff --git a/gtk/gtktogglebutton.c b/gtk/gtktogglebutton.c index c1bb468562..e51ee8400f 100644 --- a/gtk/gtktogglebutton.c +++ b/gtk/gtktogglebutton.c @@ -305,6 +305,51 @@ gtk_toggle_button_toggled (GtkToggleButton *toggle_button) gtk_signal_emit (GTK_OBJECT (toggle_button), toggle_button_signals[TOGGLED]); } +/** + * gtk_toggle_button_set_inconsistent: + * @toggle_button: a #GtkToggleButton + * @setting: %TRUE if state is inconsistent + * + * If the user has selected a range of elements (such as some text or + * spreadsheet cells) that are affected by a toggle button, and the + * current values in that range are inconsistent, you may want to + * display the toggle in an "in between" state. This function turns on + * "in between" display. Normally you would turn off the inconsistent + * state again if the user toggles the toggle button. This has to be + * done manually, gtk_toggle_button_set_inconsistent() only affects + * visual appearance, it doesn't affect the semantics of the button. + * + **/ +void +gtk_toggle_button_set_inconsistent (GtkToggleButton *toggle_button, + gboolean setting) +{ + g_return_if_fail (GTK_IS_TOGGLE_BUTTON (toggle_button)); + + setting = setting != FALSE; + + if (setting != toggle_button->inconsistent) + { + toggle_button->inconsistent = setting; + gtk_widget_queue_draw (GTK_WIDGET (toggle_button)); + } +} + +/** + * gtk_toggle_button_get_inconsistent: + * @toggle_button: a #GtkToggleButton + * + * Gets the value set by gtk_toggle_button_set_inconsistent(). + * + * Return value: %TRUE if the button is displayed as inconsistent, %FALSE otherwise + **/ +gboolean +gtk_toggle_button_get_inconsistent (GtkToggleButton *toggle_button) +{ + g_return_val_if_fail (GTK_IS_TOGGLE_BUTTON (toggle_button), FALSE); + + return toggle_button->inconsistent; +} static void gtk_toggle_button_paint (GtkWidget *widget, @@ -313,6 +358,7 @@ gtk_toggle_button_paint (GtkWidget *widget, GtkButton *button; GtkToggleButton *toggle_button; GtkShadowType shadow_type; + GtkStateType state_type; gint width, height; gint x, y; @@ -356,9 +402,17 @@ gtk_toggle_button_paint (GtkWidget *widget, height -= 2; } - if ((GTK_WIDGET_STATE (widget) == GTK_STATE_ACTIVE) || + state_type = GTK_WIDGET_STATE (widget); + + if (toggle_button->inconsistent) + { + if (state_type == GTK_STATE_ACTIVE) + state_type = GTK_STATE_NORMAL; + shadow_type = GTK_SHADOW_ETCHED_IN; + } + else if ((GTK_WIDGET_STATE (widget) == GTK_STATE_ACTIVE) || toggle_button->active) - shadow_type = GTK_SHADOW_IN; + shadow_type = GTK_SHADOW_IN; else shadow_type = GTK_SHADOW_OUT; @@ -366,7 +420,7 @@ gtk_toggle_button_paint (GtkWidget *widget, (GTK_WIDGET_STATE(widget) != GTK_STATE_NORMAL && GTK_WIDGET_STATE(widget) != GTK_STATE_INSENSITIVE)) gtk_paint_box (widget->style, widget->window, - GTK_WIDGET_STATE (widget), + state_type, shadow_type, area, widget, "togglebutton", x, y, width, height); |