Commit f4fa22da authored by Havoc Pennington's avatar Havoc Pennington Committed by Havoc Pennington

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)
parent 6fb6363e
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)
2001-02-19 Hans Breuer <hans@breuer.org>
* gtk/gtk.def : updated exported symbols
......
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)
2001-02-19 Hans Breuer <hans@breuer.org>
* gtk/gtk.def : updated exported symbols
......
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)
2001-02-19 Hans Breuer <hans@breuer.org>
* gtk/gtk.def : updated exported symbols
......
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)
2001-02-19 Hans Breuer <hans@breuer.org>
* gtk/gtk.def : updated exported symbols
......
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)
2001-02-19 Hans Breuer <hans@breuer.org>
* gtk/gtk.def : updated exported symbols
......
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)
2001-02-19 Hans Breuer <hans@breuer.org>
* gtk/gtk.def : updated exported symbols
......
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)
2001-02-19 Hans Breuer <hans@breuer.org>
* gtk/gtk.def : updated exported symbols
......
......@@ -97,7 +97,7 @@ gboolean gdk_color_equal (const GdkColor *colora,
const GdkColor *colorb);
/* The following functions are deprecated */
#ifdef GDK_DISABLE_DEPRECATED
#ifndef GDK_DISABLE_DEPRECATED
void gdk_colors_store (GdkColormap *colormap,
GdkColor *colors,
gint ncolors);
......
......@@ -356,8 +356,13 @@ gtk_real_check_button_draw_indicator (GtkCheckButton *check_button,
y = widget->allocation.y + (widget->allocation.height - GTK_CHECK_BUTTON_GET_CLASS (widget)->indicator_size) / 2;
width = GTK_CHECK_BUTTON_GET_CLASS (widget)->indicator_size;
height = GTK_CHECK_BUTTON_GET_CLASS (widget)->indicator_size;
if (GTK_TOGGLE_BUTTON (widget)->active)
if (GTK_TOGGLE_BUTTON (widget)->inconsistent)
{
state_type = GTK_WIDGET_STATE (widget) == GTK_STATE_ACTIVE ? GTK_STATE_NORMAL : GTK_WIDGET_STATE (widget);
shadow_type = GTK_SHADOW_ETCHED_IN;
}
else if (GTK_TOGGLE_BUTTON (widget)->active)
{
state_type = GTK_STATE_ACTIVE;
shadow_type = GTK_SHADOW_IN;
......
......@@ -173,6 +173,52 @@ gtk_check_menu_item_toggled (GtkCheckMenuItem *check_menu_item)
gtk_signal_emit (GTK_OBJECT (check_menu_item), check_menu_item_signals[TOGGLED]);
}
/**
* gtk_check_menu_item_set_inconsistent:
* @check_menu_item: a #GtkCheckMenuItem
* @setting: %TRUE to display an "inconsistent" third state check
*
* If the user has selected a range of elements (such as some text or
* spreadsheet cells) that are affected by a boolean setting, and the
* current values in that range are inconsistent, you may want to
* display the check in an "in between" state. This function turns on
* "in between" display. Normally you would turn off the inconsistent
* state again if the user explicitly selects a setting. This has to be
* done manually, gtk_check_menu_item_set_inconsistent() only affects
* visual appearance, it doesn't affect the semantics of the widget.
*
**/
void
gtk_check_menu_item_set_inconsistent (GtkCheckMenuItem *check_menu_item,
gboolean setting)
{
g_return_if_fail (GTK_IS_CHECK_MENU_ITEM (check_menu_item));
setting = setting != FALSE;
if (setting != check_menu_item->inconsistent)
{
check_menu_item->inconsistent = setting;
gtk_widget_queue_draw (GTK_WIDGET (check_menu_item));
}
}
/**
* gtk_check_menu_item_get_inconsistent:
* @check_menu_item: a #GtkCheckMenuItem
*
* Retrieves the value set by gtk_check_menu_item_set_inconsistent().
*
* Return value: %TRUE if inconsistent
**/
gboolean
gtk_check_menu_item_get_inconsistent (GtkCheckMenuItem *check_menu_item)
{
g_return_val_if_fail (GTK_IS_CHECK_MENU_ITEM (check_menu_item), FALSE);
return check_menu_item->inconsistent;
}
static void
gtk_check_menu_item_init (GtkCheckMenuItem *check_menu_item)
{
......@@ -265,7 +311,14 @@ gtk_real_check_menu_item_draw_indicator (GtkCheckMenuItem *check_menu_item,
(state_type == GTK_STATE_PRELIGHT))
shadow_type = GTK_SHADOW_OUT;
}
if (check_menu_item->inconsistent)
{
shadow_type = GTK_SHADOW_ETCHED_IN;
if (state_type == GTK_STATE_ACTIVE)
state_type = GTK_STATE_NORMAL;
}
gtk_paint_check (widget->style, widget->window,
state_type, shadow_type,
area, widget, "check",
......
......@@ -54,6 +54,7 @@ struct _GtkCheckMenuItem
guint active : 1;
guint always_show_toggle : 1;
guint inconsistent : 1;
};
struct _GtkCheckMenuItemClass
......@@ -75,6 +76,10 @@ void gtk_check_menu_item_set_show_toggle (GtkCheckMenuItem *menu_item,
gboolean always);
void gtk_check_menu_item_toggled (GtkCheckMenuItem *check_menu_item);
void gtk_check_menu_item_set_inconsistent (GtkCheckMenuItem *check_menu_item,
gboolean setting);
gboolean gtk_check_menu_item_get_inconsistent (GtkCheckMenuItem *check_menu_item);
#ifdef __cplusplus
}
......
......@@ -416,6 +416,9 @@ gtk_radio_button_draw_indicator (GtkCheckButton *check_button,
shadow_type = GTK_SHADOW_IN;
else
shadow_type = GTK_SHADOW_OUT;
if (GTK_TOGGLE_BUTTON (widget)->inconsistent)
shadow_type = GTK_SHADOW_ETCHED_IN;
if (gtk_widget_get_direction (widget) == GTK_TEXT_DIR_RTL)
x = widget->allocation.x + widget->allocation.width - (width + x - widget->allocation.x);
......
......@@ -298,6 +298,9 @@ gtk_radio_menu_item_draw_indicator (GtkCheckMenuItem *check_menu_item,
else
shadow_type = GTK_SHADOW_OUT;
if (check_menu_item->inconsistent)
shadow_type = GTK_SHADOW_ETCHED_IN;
gtk_paint_option (widget->style, widget->window,
state_type, shadow_type,
area, widget, "option",
......
......@@ -2229,6 +2229,18 @@ gtk_default_draw_diamond (GtkStyle *style,
{
gint half_width;
gint half_height;
GdkGC *outer_nw = NULL;
GdkGC *outer_ne = NULL;
GdkGC *outer_sw = NULL;
GdkGC *outer_se = NULL;
GdkGC *middle_nw = NULL;
GdkGC *middle_ne = NULL;
GdkGC *middle_sw = NULL;
GdkGC *middle_se = NULL;
GdkGC *inner_nw = NULL;
GdkGC *inner_ne = NULL;
GdkGC *inner_sw = NULL;
GdkGC *inner_se = NULL;
g_return_if_fail (GTK_IS_STYLE (style));
g_return_if_fail (window != NULL);
......@@ -2250,89 +2262,91 @@ gtk_default_draw_diamond (GtkStyle *style,
gdk_gc_set_clip_rectangle (style->dark_gc[state_type], area);
gdk_gc_set_clip_rectangle (style->black_gc, area);
}
switch (shadow_type)
{
case GTK_SHADOW_IN:
gdk_draw_line (window, style->bg_gc[state_type],
x + 2, y + half_height,
x + half_width, y + height - 2);
gdk_draw_line (window, style->bg_gc[state_type],
x + half_width, y + height - 2,
x + width - 2, y + half_height);
gdk_draw_line (window, style->light_gc[state_type],
x + 1, y + half_height,
x + half_width, y + height - 1);
gdk_draw_line (window, style->light_gc[state_type],
x + half_width, y + height - 1,
x + width - 1, y + half_height);
gdk_draw_line (window, style->light_gc[state_type],
x, y + half_height,
x + half_width, y + height);
gdk_draw_line (window, style->light_gc[state_type],
x + half_width, y + height,
x + width, y + half_height);
gdk_draw_line (window, style->black_gc,
x + 2, y + half_height,
x + half_width, y + 2);
gdk_draw_line (window, style->black_gc,
x + half_width, y + 2,
x + width - 2, y + half_height);
gdk_draw_line (window, style->dark_gc[state_type],
x + 1, y + half_height,
x + half_width, y + 1);
gdk_draw_line (window, style->dark_gc[state_type],
x + half_width, y + 1,
x + width - 1, y + half_height);
gdk_draw_line (window, style->dark_gc[state_type],
x, y + half_height,
x + half_width, y);
gdk_draw_line (window, style->dark_gc[state_type],
x + half_width, y,
x + width, y + half_height);
inner_sw = inner_se = style->bg_gc[state_type];
middle_sw = middle_se = style->light_gc[state_type];
outer_sw = outer_se = style->light_gc[state_type];
inner_nw = inner_ne = style->black_gc;
middle_nw = middle_ne = style->dark_gc[state_type];
outer_nw = outer_ne = style->dark_gc[state_type];
break;
case GTK_SHADOW_OUT:
gdk_draw_line (window, style->dark_gc[state_type],
inner_sw = inner_se = style->dark_gc[state_type];
middle_sw = middle_se = style->dark_gc[state_type];
outer_sw = outer_se = style->black_gc;
inner_nw = inner_ne = style->bg_gc[state_type];
middle_nw = middle_ne = style->light_gc[state_type];
outer_nw = outer_ne = style->light_gc[state_type];
break;
case GTK_SHADOW_ETCHED_IN:
inner_sw = inner_se = style->bg_gc[state_type];
middle_sw = middle_se = style->dark_gc[state_type];
outer_sw = outer_se = style->light_gc[state_type];
inner_nw = inner_ne = style->bg_gc[state_type];
middle_nw = middle_ne = style->light_gc[state_type];
outer_nw = outer_ne = style->dark_gc[state_type];
break;
case GTK_SHADOW_ETCHED_OUT:
inner_sw = inner_se = style->bg_gc[state_type];
middle_sw = middle_se = style->light_gc[state_type];
outer_sw = outer_se = style->dark_gc[state_type];
inner_nw = inner_ne = style->bg_gc[state_type];
middle_nw = middle_ne = style->dark_gc[state_type];
outer_nw = outer_ne = style->light_gc[state_type];
break;
default:
break;
}
if (inner_sw)
{
gdk_draw_line (window, inner_sw,
x + 2, y + half_height,
x + half_width, y + height - 2);
gdk_draw_line (window, style->dark_gc[state_type],
gdk_draw_line (window, inner_se,
x + half_width, y + height - 2,
x + width - 2, y + half_height);
gdk_draw_line (window, style->dark_gc[state_type],
gdk_draw_line (window, middle_sw,
x + 1, y + half_height,
x + half_width, y + height - 1);
gdk_draw_line (window, style->dark_gc[state_type],
gdk_draw_line (window, middle_se,
x + half_width, y + height - 1,
x + width - 1, y + half_height);
gdk_draw_line (window, style->black_gc,
gdk_draw_line (window, outer_sw,
x, y + half_height,
x + half_width, y + height);
gdk_draw_line (window, style->black_gc,
gdk_draw_line (window, outer_se,
x + half_width, y + height,
x + width, y + half_height);
gdk_draw_line (window, style->bg_gc[state_type],
gdk_draw_line (window, inner_nw,
x + 2, y + half_height,
x + half_width, y + 2);
gdk_draw_line (window, style->bg_gc[state_type],
gdk_draw_line (window, inner_ne,
x + half_width, y + 2,
x + width - 2, y + half_height);
gdk_draw_line (window, style->light_gc[state_type],
gdk_draw_line (window, middle_nw,
x + 1, y + half_height,
x + half_width, y + 1);
gdk_draw_line (window, style->light_gc[state_type],
gdk_draw_line (window, middle_ne,
x + half_width, y + 1,
x + width - 1, y + half_height);
gdk_draw_line (window, style->light_gc[state_type],
gdk_draw_line (window, outer_nw,
x, y + half_height,
x + half_width, y);
gdk_draw_line (window, style->light_gc[state_type],
gdk_draw_line (window, outer_ne,
x + half_width, y,
x + width, y + half_height);
break;
default:
break;
}
if (area)
{
gdk_gc_set_clip_rectangle (style->light_gc[state_type], NULL);
......
......@@ -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;
}