From 6bd08ac815a7b6aa7bffb916ea290af3ed30172d Mon Sep 17 00:00:00 2001 From: Soeren Sandmann Date: Wed, 13 Nov 2002 12:58:43 +0000 Subject: [PATCH] - comment out check_inconsistent_aa_bits[]. Wed Nov 13 14:01:44 2002 Soeren Sandmann * gtk/gtkstyle.c: - comment out check_inconsistent_aa_bits[]. - use fg/bg with a generated aa color to draw check and option marks in menu items. - use text/base to draw check and option buttons, except when state is ACTIVE, in which case we use fg/bg with a generated aa color. * tests/testgtk.c (menu_items): Add three check items. --- ChangeLog | 15 +++++ ChangeLog.pre-2-10 | 15 +++++ ChangeLog.pre-2-2 | 15 +++++ ChangeLog.pre-2-4 | 15 +++++ ChangeLog.pre-2-6 | 15 +++++ ChangeLog.pre-2-8 | 15 +++++ gtk/gtkstyle.c | 142 +++++++++++++++++++++++++++++---------------- tests/testgtk.c | 18 ++++++ 8 files changed, 201 insertions(+), 49 deletions(-) diff --git a/ChangeLog b/ChangeLog index 4ea90f4706..e4a196088c 100644 --- a/ChangeLog +++ b/ChangeLog @@ -1,3 +1,18 @@ +Wed Nov 13 14:01:44 2002 Soeren Sandmann + + * gtk/gtkstyle.c: + + - comment out check_inconsistent_aa_bits[]. + + - use fg/bg with a generated aa color to draw check and option + marks in menu items. + + - use text/base to draw check and option buttons, except when + state is ACTIVE, in which case we use fg/bg with a generated + aa color. + + * tests/testgtk.c (menu_items): Add three check items. + 2002-11-12 Tor Lillqvist * gdk/win32/gdkprivate-win32.h diff --git a/ChangeLog.pre-2-10 b/ChangeLog.pre-2-10 index 4ea90f4706..e4a196088c 100644 --- a/ChangeLog.pre-2-10 +++ b/ChangeLog.pre-2-10 @@ -1,3 +1,18 @@ +Wed Nov 13 14:01:44 2002 Soeren Sandmann + + * gtk/gtkstyle.c: + + - comment out check_inconsistent_aa_bits[]. + + - use fg/bg with a generated aa color to draw check and option + marks in menu items. + + - use text/base to draw check and option buttons, except when + state is ACTIVE, in which case we use fg/bg with a generated + aa color. + + * tests/testgtk.c (menu_items): Add three check items. + 2002-11-12 Tor Lillqvist * gdk/win32/gdkprivate-win32.h diff --git a/ChangeLog.pre-2-2 b/ChangeLog.pre-2-2 index 4ea90f4706..e4a196088c 100644 --- a/ChangeLog.pre-2-2 +++ b/ChangeLog.pre-2-2 @@ -1,3 +1,18 @@ +Wed Nov 13 14:01:44 2002 Soeren Sandmann + + * gtk/gtkstyle.c: + + - comment out check_inconsistent_aa_bits[]. + + - use fg/bg with a generated aa color to draw check and option + marks in menu items. + + - use text/base to draw check and option buttons, except when + state is ACTIVE, in which case we use fg/bg with a generated + aa color. + + * tests/testgtk.c (menu_items): Add three check items. + 2002-11-12 Tor Lillqvist * gdk/win32/gdkprivate-win32.h diff --git a/ChangeLog.pre-2-4 b/ChangeLog.pre-2-4 index 4ea90f4706..e4a196088c 100644 --- a/ChangeLog.pre-2-4 +++ b/ChangeLog.pre-2-4 @@ -1,3 +1,18 @@ +Wed Nov 13 14:01:44 2002 Soeren Sandmann + + * gtk/gtkstyle.c: + + - comment out check_inconsistent_aa_bits[]. + + - use fg/bg with a generated aa color to draw check and option + marks in menu items. + + - use text/base to draw check and option buttons, except when + state is ACTIVE, in which case we use fg/bg with a generated + aa color. + + * tests/testgtk.c (menu_items): Add three check items. + 2002-11-12 Tor Lillqvist * gdk/win32/gdkprivate-win32.h diff --git a/ChangeLog.pre-2-6 b/ChangeLog.pre-2-6 index 4ea90f4706..e4a196088c 100644 --- a/ChangeLog.pre-2-6 +++ b/ChangeLog.pre-2-6 @@ -1,3 +1,18 @@ +Wed Nov 13 14:01:44 2002 Soeren Sandmann + + * gtk/gtkstyle.c: + + - comment out check_inconsistent_aa_bits[]. + + - use fg/bg with a generated aa color to draw check and option + marks in menu items. + + - use text/base to draw check and option buttons, except when + state is ACTIVE, in which case we use fg/bg with a generated + aa color. + + * tests/testgtk.c (menu_items): Add three check items. + 2002-11-12 Tor Lillqvist * gdk/win32/gdkprivate-win32.h diff --git a/ChangeLog.pre-2-8 b/ChangeLog.pre-2-8 index 4ea90f4706..e4a196088c 100644 --- a/ChangeLog.pre-2-8 +++ b/ChangeLog.pre-2-8 @@ -1,3 +1,18 @@ +Wed Nov 13 14:01:44 2002 Soeren Sandmann + + * gtk/gtkstyle.c: + + - comment out check_inconsistent_aa_bits[]. + + - use fg/bg with a generated aa color to draw check and option + marks in menu items. + + - use text/base to draw check and option buttons, except when + state is ACTIVE, in which case we use fg/bg with a generated + aa color. + + * tests/testgtk.c (menu_items): Add three check items. + 2002-11-12 Tor Lillqvist * gdk/win32/gdkprivate-win32.h diff --git a/gtk/gtkstyle.c b/gtk/gtkstyle.c index 9c07b121e6..aa3fb77594 100644 --- a/gtk/gtkstyle.c +++ b/gtk/gtkstyle.c @@ -330,7 +330,6 @@ typedef enum { CHECK_LIGHT, CHECK_MID, CHECK_TEXT, - CHECK_INCONSISTENT_AA, CHECK_INCONSISTENT_TEXT, RADIO_BASE, RADIO_BLACK, @@ -368,14 +367,19 @@ static guchar check_base_bits[] = { 0x07,0xfc,0x07,0xfc,0x07,0xfc,0x07,0x00,0x00,0x00,0x00,0x00,0x00}; /* - * Extracted from check-13-inconsistent-ssp.png, width=13, height=13 + * Extracted from check-13-inconsistent.png, width=13, height=13 */ static guchar check_inconsistent_text_bits[] = { 0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0xf8,0x03,0xf8, 0x03,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00}; +#if 0 +/* + * check_inconsistent_aa_bits is currently not used, since it is all zeros. + */ static guchar check_inconsistent_aa_bits[] = { 0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00, 0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00}; +#endif /* * Extracted from radio-13.png, width=13, height=13 @@ -428,7 +432,6 @@ static struct { { check_light_bits, NULL }, { check_mid_bits, NULL }, { check_text_bits, NULL }, - { check_inconsistent_aa_bits, NULL }, { check_inconsistent_text_bits, NULL }, { radio_base_bits, NULL }, { radio_black_bits, NULL }, @@ -3570,6 +3573,21 @@ gtk_default_draw_flat_box (GtkStyle *style, g_object_unref (freeme); } +static GdkGC * +create_aa_gc (GdkWindow *window, GtkStyle *style, GtkStateType state_type) +{ + GdkColor aa_color; + GdkGC *gc = gdk_gc_new (window); + + aa_color.red = (style->fg[state_type].red + style->bg[state_type].red) / 2; + aa_color.green = (style->fg[state_type].green + style->bg[state_type].green) / 2; + aa_color.blue = (style->fg[state_type].blue + style->bg[state_type].blue) / 2; + + gdk_gc_set_rgb_fg_color (gc, &aa_color); + + return gc; +} + static void gtk_default_draw_check (GtkStyle *style, GdkWindow *window, @@ -3606,48 +3624,56 @@ gtk_default_draw_check (GtkStyle *style, } else { + GdkGC *free_me = NULL; + + GdkGC *base_gc; + GdkGC *text_gc; + GdkGC *aa_gc; + x -= (1 + INDICATOR_PART_SIZE - width) / 2; y -= (1 + INDICATOR_PART_SIZE - height) / 2; - + if (strcmp (detail, "check") == 0) /* Menu item */ { - if (shadow_type == GTK_SHADOW_IN) - { - draw_part (window, style->black_gc, area, x, y, CHECK_TEXT); - draw_part (window, style->dark_gc[state_type], area, x, y, CHECK_AA); - } - else if (shadow_type == GTK_SHADOW_ETCHED_IN) /* inconsistent */ - { - draw_part (window, style->black_gc, area, x, y, CHECK_INCONSISTENT_TEXT); - draw_part (window, style->dark_gc[state_type], area, x, y, CHECK_INCONSISTENT_AA); - } + text_gc = style->fg_gc[state_type]; + base_gc = style->bg_gc[state_type]; + aa_gc = free_me = create_aa_gc (window, style, state_type); } else { - GdkGC *base_gc = style->base_gc[state_type]; - if (state_type == GTK_STATE_ACTIVE) - base_gc = style->bg_gc[GTK_STATE_ACTIVE]; - + { + text_gc = style->fg_gc[state_type]; + base_gc = style->bg_gc[state_type]; + aa_gc = free_me = create_aa_gc (window, style, state_type); + } + else + { + text_gc = style->text_gc[state_type]; + base_gc = style->base_gc[state_type]; + aa_gc = style->text_aa_gc[state_type]; + } + draw_part (window, base_gc, area, x, y, CHECK_BASE); draw_part (window, style->black_gc, area, x, y, CHECK_BLACK); draw_part (window, style->dark_gc[state_type], area, x, y, CHECK_DARK); draw_part (window, style->mid_gc[state_type], area, x, y, CHECK_MID); draw_part (window, style->light_gc[state_type], area, x, y, CHECK_LIGHT); - - if (shadow_type == GTK_SHADOW_IN) - { - draw_part (window, style->text_gc[state_type], area, x, y, CHECK_TEXT); - draw_part (window, style->text_aa_gc[state_type], area, x, y, CHECK_AA); - } - else if (shadow_type == GTK_SHADOW_ETCHED_IN) /* inconsistent */ - { - draw_part (window, style->text_gc[state_type], area, x, y, CHECK_INCONSISTENT_TEXT); - draw_part (window, style->text_aa_gc[state_type], area, x, y, CHECK_INCONSISTENT_AA); - } } - } + if (shadow_type == GTK_SHADOW_IN) + { + draw_part (window, text_gc, area, x, y, CHECK_TEXT); + draw_part (window, aa_gc, area, x, y, CHECK_AA); + } + else if (shadow_type == GTK_SHADOW_ETCHED_IN) /* inconsistent */ + { + draw_part (window, text_gc, area, x, y, CHECK_INCONSISTENT_TEXT); + } + + if (free_me) + g_object_unref (G_OBJECT (free_me)); + } } static void @@ -3687,44 +3713,62 @@ gtk_default_draw_option (GtkStyle *style, } else { + GdkGC *free_me = NULL; + + GdkGC *base_gc; + GdkGC *text_gc; + GdkGC *aa_gc; + x -= (1 + INDICATOR_PART_SIZE - width) / 2; y -= (1 + INDICATOR_PART_SIZE - height) / 2; - + if (strcmp (detail, "option") == 0) /* Menu item */ { - if (shadow_type == GTK_SHADOW_IN) - { - draw_part (window, style->fg_gc[state_type], area, x, y, RADIO_TEXT); - } - else if (shadow_type == GTK_SHADOW_ETCHED_IN) /* inconsistent */ - { - draw_part (window, style->black_gc, area, x, y, CHECK_INCONSISTENT_TEXT); - draw_part (window, style->dark_gc[state_type], area, x, y, CHECK_INCONSISTENT_AA); - } + text_gc = style->fg_gc[state_type]; + base_gc = style->bg_gc[state_type]; + aa_gc = free_me = create_aa_gc (window, style, state_type); } else { - GdkGC *base_gc = style->base_gc[state_type]; - if (state_type == GTK_STATE_ACTIVE) - base_gc = style->bg_gc[GTK_STATE_ACTIVE]; + { + text_gc = style->fg_gc[state_type]; + base_gc = style->bg_gc[state_type]; + aa_gc = free_me = create_aa_gc (window, style, state_type); + } + else + { + text_gc = style->text_gc[state_type]; + base_gc = style->base_gc[state_type]; + aa_gc = style->text_aa_gc[state_type]; + } draw_part (window, base_gc, area, x, y, RADIO_BASE); draw_part (window, style->black_gc, area, x, y, RADIO_BLACK); draw_part (window, style->dark_gc[state_type], area, x, y, RADIO_DARK); draw_part (window, style->mid_gc[state_type], area, x, y, RADIO_MID); draw_part (window, style->light_gc[state_type], area, x, y, RADIO_LIGHT); - - if (shadow_type == GTK_SHADOW_IN) + } + + if (shadow_type == GTK_SHADOW_IN) + { + draw_part (window, text_gc, area, x, y, RADIO_TEXT); + } + else if (shadow_type == GTK_SHADOW_ETCHED_IN) /* inconsistent */ + { + if (strcmp (detail, "option") == 0) /* Menu item */ { - draw_part (window, style->text_gc[state_type], area, x, y, RADIO_TEXT); + draw_part (window, text_gc, area, x, y, CHECK_INCONSISTENT_TEXT); } - else if (shadow_type == GTK_SHADOW_ETCHED_IN) /* inconsistent */ + else { - draw_part (window, style->text_aa_gc[state_type], area, x, y, RADIO_INCONSISTENT_AA); - draw_part (window, style->text_gc[state_type], area, x, y, RADIO_INCONSISTENT_TEXT); + draw_part (window, text_gc, area, x, y, RADIO_INCONSISTENT_TEXT); + draw_part (window, aa_gc, area, x, y, RADIO_INCONSISTENT_AA); } } + + if (free_me) + g_object_unref (G_OBJECT (free_me)); } } diff --git a/tests/testgtk.c b/tests/testgtk.c index fd406f50fd..437a2ee3c2 100644 --- a/tests/testgtk.c +++ b/tests/testgtk.c @@ -3758,6 +3758,9 @@ static GtkItemFactoryEntry menu_items[] = { "/_Preferences/Shape/_Rectangle", NULL, gtk_ifactory_cb, 0, "/Preferences/Shape/Square" }, { "/_Preferences/Shape/_Oval", NULL, gtk_ifactory_cb, 0, "/Preferences/Shape/Rectangle" }, { "/_Preferences/Shape/_Image", NULL, gtk_ifactory_cb, 0, "", apple }, + { "/_Preferences/Coffee", NULL, gtk_ifactory_cb, 0, "" }, + { "/_Preferences/Toast", NULL, gtk_ifactory_cb, 0, "" }, + { "/_Preferences/Marshmallow Froot Loops", NULL, gtk_ifactory_cb, 0, "" }, /* For testing deletion of menus */ { "/_Preferences/Should_NotAppear", NULL, 0, 0, "" }, @@ -3817,6 +3820,21 @@ create_item_factory (GtkWidget *widget) "/Preferences/Shape/Oval")), TRUE); + /* preselect /Preferences/Coffee + */ + gtk_check_menu_item_set_active (GTK_CHECK_MENU_ITEM (gtk_item_factory_get_item (item_factory, + "/Preferences/Coffee")), + TRUE); + + /* preselect /Preferences/Marshmallow Froot Loops and set it insensitive + */ + gtk_check_menu_item_set_active (GTK_CHECK_MENU_ITEM (gtk_item_factory_get_item (item_factory, + "/Preferences/Marshmallow Froot Loops")), + TRUE); + gtk_widget_set_sensitive (GTK_WIDGET (gtk_item_factory_get_item (item_factory, + "/Preferences/Marshmallow Froot Loops")), + FALSE); + /* Test how tooltips (ugh) work on menu items */ tooltips = gtk_tooltips_new ();