summaryrefslogtreecommitdiff
path: root/lwlib
diff options
context:
space:
mode:
authorPavel Janík <Pavel@Janik.cz>2002-05-06 18:56:25 +0000
committerPavel Janík <Pavel@Janik.cz>2002-05-06 18:56:25 +0000
commit8b71a9ca6f24fcd0e28769558fc23b4dff1adf18 (patch)
treeb22897f09f8aaed7106c7eb8a354421ff5f78a49 /lwlib
parent2ad99766659cb2866e0c84ad43b5362464f57267 (diff)
downloademacs-8b71a9ca6f24fcd0e28769558fc23b4dff1adf18.tar.gz
(xlwMenuResources): New resource.
(find_next_selectable): Return current item when the menu is not poped up. Rename `inactive_gc' to `disabled_gc'. Use lighter/darker color for disabled menu items instead of using stipple. Use stipple only when better color can not be determined automatically.
Diffstat (limited to 'lwlib')
-rw-r--r--lwlib/ChangeLog16
-rw-r--r--lwlib/xlwmenu.c58
2 files changed, 65 insertions, 9 deletions
diff --git a/lwlib/ChangeLog b/lwlib/ChangeLog
index 754552fa5cd..b4c18ee2654 100644
--- a/lwlib/ChangeLog
+++ b/lwlib/ChangeLog
@@ -1,3 +1,19 @@
+2002-05-06 Pavel Jan,Bm(Bk <Pavel@Janik.cz>
+
+ * xlwmenu.c (xlwMenuResources): New resource.
+ (find_next_selectable): Return current item when the menu is not
+ poped up.
+ Rename `inactive_gc' to `disabled_gc'.
+ Use lighter/darker color for disabled menu items instead of using
+ stipple. Use stipple only when better color can not be
+ determined automatically.
+
+ * xlwmenu.h (XtNdisabledForeground, XtCDisabledForeground):
+ New resource names.
+
+ * xlwmenuP.h (_XlwMenu_part): Add new member `disabled_foreground'.
+ Rename `inactive_gc' to `disabled_gc'.
+
2002-04-29 Pavel Jan,Bm(Bk <Pavel@Janik.cz>
* xlwmenu.c <XtNmargin, XtNverticalSpacing, XmNshadowThickness>:
diff --git a/lwlib/xlwmenu.c b/lwlib/xlwmenu.c
index 691213ab3be..e712ed80717 100644
--- a/lwlib/xlwmenu.c
+++ b/lwlib/xlwmenu.c
@@ -139,6 +139,8 @@ xlwMenuResources[] =
offset(menu.font),XtRString, "XtDefaultFont"},
{XtNforeground, XtCForeground, XtRPixel, sizeof(Pixel),
offset(menu.foreground), XtRString, "XtDefaultForeground"},
+ {XtNdisabledForeground, XtCDisabledForeground, XtRPixel, sizeof(Pixel),
+ offset(menu.disabled_foreground), XtRString, (XtPointer)NULL},
{XtNbuttonForeground, XtCButtonForeground, XtRPixel, sizeof(Pixel),
offset(menu.button_foreground), XtRString, "XtDefaultForeground"},
{XtNmargin, XtCMargin, XtRDimension, sizeof(Dimension),
@@ -997,7 +999,7 @@ display_menu_item (mw, val, ws, where, highlighted_p, horizontal_p,
if (val->enabled)
text_gc = mw->menu.foreground_gc;
else
- text_gc = mw->menu.inactive_gc;
+ text_gc = mw->menu.disabled_gc;
deco_gc = mw->menu.foreground_gc;
if (separator_p)
@@ -1453,6 +1455,8 @@ make_drawing_gcs (mw)
XlwMenuWidget mw;
{
XGCValues xgcv;
+ XColor temp;
+ int delta;
xgcv.font = mw->menu.font->fid;
xgcv.foreground = mw->menu.foreground;
@@ -1469,13 +1473,47 @@ make_drawing_gcs (mw)
&xgcv);
xgcv.font = mw->menu.font->fid;
- xgcv.foreground = mw->menu.foreground;
xgcv.background = mw->core.background_pixel;
- xgcv.fill_style = FillStippled;
- xgcv.stipple = mw->menu.gray_pixmap;
- mw->menu.inactive_gc = XtGetGC ((Widget)mw,
- (GCFont | GCForeground | GCBackground
- | GCFillStyle | GCStipple), &xgcv);
+
+#define BRIGHTNESS(color) (((color) & 0xff) + (((color) >> 8) & 0xff) + (((color) >> 16) & 0xff))
+
+ /* Allocate color for disabled menu-items. */
+ if (BRIGHTNESS(mw->menu.foreground) < BRIGHTNESS(mw->core.background_pixel))
+ {
+ delta = 2.3;
+ temp.pixel = mw->menu.foreground;
+ }
+ else
+ {
+ delta = 1.2;
+ temp.pixel = mw->core.background_pixel;
+ }
+
+ x_alloc_lighter_color_for_widget ((Widget) mw, XtDisplay ((Widget) mw),
+ mw->core.colormap,
+ &temp.pixel,
+ delta,
+ 0x8000);
+ mw->menu.disabled_foreground = temp.pixel;
+
+ if (mw->menu.foreground == mw->menu.disabled_foreground
+ || mw->core.background_pixel == mw->menu.disabled_foreground)
+ {
+ /* Too few colors, use stipple. */
+ xgcv.foreground = mw->menu.foreground;
+ xgcv.fill_style = FillStippled;
+ xgcv.stipple = mw->menu.gray_pixmap;
+ mw->menu.disabled_gc = XtGetGC ((Widget)mw,
+ (GCFont | GCForeground | GCBackground
+ | GCFillStyle | GCStipple), &xgcv);
+ }
+ else
+ {
+ /* Many colors available, use disabled pixel. */
+ xgcv.foreground = mw->menu.disabled_foreground;
+ mw->menu.disabled_gc = XtGetGC ((Widget)mw,
+ (GCFont | GCForeground | GCBackground), &xgcv);
+ }
xgcv.font = mw->menu.font->fid;
xgcv.foreground = mw->menu.button_foreground;
@@ -1500,13 +1538,13 @@ release_drawing_gcs (mw)
{
XtReleaseGC ((Widget) mw, mw->menu.foreground_gc);
XtReleaseGC ((Widget) mw, mw->menu.button_gc);
- XtReleaseGC ((Widget) mw, mw->menu.inactive_gc);
+ XtReleaseGC ((Widget) mw, mw->menu.disabled_gc);
XtReleaseGC ((Widget) mw, mw->menu.inactive_button_gc);
XtReleaseGC ((Widget) mw, mw->menu.background_gc);
/* let's get some segvs if we try to use these... */
mw->menu.foreground_gc = (GC) -1;
mw->menu.button_gc = (GC) -1;
- mw->menu.inactive_gc = (GC) -1;
+ mw->menu.disabled_gc = (GC) -1;
mw->menu.inactive_button_gc = (GC) -1;
mw->menu.background_gc = (GC) -1;
}
@@ -2050,6 +2088,8 @@ find_next_selectable (mw, item)
if (current == item)
{
+ if (mw->menu.old_depth < 2)
+ return current;
current = mw->menu.old_stack [mw->menu.old_depth - 2]->contents;
while (lw_separator_p (current->name, &separator, 0) || !current->enabled)