diff options
| author | Pavel Janík | 2002-05-06 18:56:25 +0000 |
|---|---|---|
| committer | Pavel Janík | 2002-05-06 18:56:25 +0000 |
| commit | 8b71a9ca6f24fcd0e28769558fc23b4dff1adf18 (patch) | |
| tree | b22897f09f8aaed7106c7eb8a354421ff5f78a49 | |
| parent | 2ad99766659cb2866e0c84ad43b5362464f57267 (diff) | |
| download | emacs-8b71a9ca6f24fcd0e28769558fc23b4dff1adf18.tar.gz emacs-8b71a9ca6f24fcd0e28769558fc23b4dff1adf18.zip | |
(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.
| -rw-r--r-- | lwlib/ChangeLog | 16 | ||||
| -rw-r--r-- | lwlib/xlwmenu.c | 58 |
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 @@ | |||
| 1 | 2002-05-06 Pavel Jan,Bm(Bk <Pavel@Janik.cz> | ||
| 2 | |||
| 3 | * xlwmenu.c (xlwMenuResources): New resource. | ||
| 4 | (find_next_selectable): Return current item when the menu is not | ||
| 5 | poped up. | ||
| 6 | Rename `inactive_gc' to `disabled_gc'. | ||
| 7 | Use lighter/darker color for disabled menu items instead of using | ||
| 8 | stipple. Use stipple only when better color can not be | ||
| 9 | determined automatically. | ||
| 10 | |||
| 11 | * xlwmenu.h (XtNdisabledForeground, XtCDisabledForeground): | ||
| 12 | New resource names. | ||
| 13 | |||
| 14 | * xlwmenuP.h (_XlwMenu_part): Add new member `disabled_foreground'. | ||
| 15 | Rename `inactive_gc' to `disabled_gc'. | ||
| 16 | |||
| 1 | 2002-04-29 Pavel Jan,Bm(Bk <Pavel@Janik.cz> | 17 | 2002-04-29 Pavel Jan,Bm(Bk <Pavel@Janik.cz> |
| 2 | 18 | ||
| 3 | * xlwmenu.c <XtNmargin, XtNverticalSpacing, XmNshadowThickness>: | 19 | * 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[] = | |||
| 139 | offset(menu.font),XtRString, "XtDefaultFont"}, | 139 | offset(menu.font),XtRString, "XtDefaultFont"}, |
| 140 | {XtNforeground, XtCForeground, XtRPixel, sizeof(Pixel), | 140 | {XtNforeground, XtCForeground, XtRPixel, sizeof(Pixel), |
| 141 | offset(menu.foreground), XtRString, "XtDefaultForeground"}, | 141 | offset(menu.foreground), XtRString, "XtDefaultForeground"}, |
| 142 | {XtNdisabledForeground, XtCDisabledForeground, XtRPixel, sizeof(Pixel), | ||
| 143 | offset(menu.disabled_foreground), XtRString, (XtPointer)NULL}, | ||
| 142 | {XtNbuttonForeground, XtCButtonForeground, XtRPixel, sizeof(Pixel), | 144 | {XtNbuttonForeground, XtCButtonForeground, XtRPixel, sizeof(Pixel), |
| 143 | offset(menu.button_foreground), XtRString, "XtDefaultForeground"}, | 145 | offset(menu.button_foreground), XtRString, "XtDefaultForeground"}, |
| 144 | {XtNmargin, XtCMargin, XtRDimension, sizeof(Dimension), | 146 | {XtNmargin, XtCMargin, XtRDimension, sizeof(Dimension), |
| @@ -997,7 +999,7 @@ display_menu_item (mw, val, ws, where, highlighted_p, horizontal_p, | |||
| 997 | if (val->enabled) | 999 | if (val->enabled) |
| 998 | text_gc = mw->menu.foreground_gc; | 1000 | text_gc = mw->menu.foreground_gc; |
| 999 | else | 1001 | else |
| 1000 | text_gc = mw->menu.inactive_gc; | 1002 | text_gc = mw->menu.disabled_gc; |
| 1001 | deco_gc = mw->menu.foreground_gc; | 1003 | deco_gc = mw->menu.foreground_gc; |
| 1002 | 1004 | ||
| 1003 | if (separator_p) | 1005 | if (separator_p) |
| @@ -1453,6 +1455,8 @@ make_drawing_gcs (mw) | |||
| 1453 | XlwMenuWidget mw; | 1455 | XlwMenuWidget mw; |
| 1454 | { | 1456 | { |
| 1455 | XGCValues xgcv; | 1457 | XGCValues xgcv; |
| 1458 | XColor temp; | ||
| 1459 | int delta; | ||
| 1456 | 1460 | ||
| 1457 | xgcv.font = mw->menu.font->fid; | 1461 | xgcv.font = mw->menu.font->fid; |
| 1458 | xgcv.foreground = mw->menu.foreground; | 1462 | xgcv.foreground = mw->menu.foreground; |
| @@ -1469,13 +1473,47 @@ make_drawing_gcs (mw) | |||
| 1469 | &xgcv); | 1473 | &xgcv); |
| 1470 | 1474 | ||
| 1471 | xgcv.font = mw->menu.font->fid; | 1475 | xgcv.font = mw->menu.font->fid; |
| 1472 | xgcv.foreground = mw->menu.foreground; | ||
| 1473 | xgcv.background = mw->core.background_pixel; | 1476 | xgcv.background = mw->core.background_pixel; |
| 1474 | xgcv.fill_style = FillStippled; | 1477 | |
| 1475 | xgcv.stipple = mw->menu.gray_pixmap; | 1478 | #define BRIGHTNESS(color) (((color) & 0xff) + (((color) >> 8) & 0xff) + (((color) >> 16) & 0xff)) |
| 1476 | mw->menu.inactive_gc = XtGetGC ((Widget)mw, | 1479 | |
| 1477 | (GCFont | GCForeground | GCBackground | 1480 | /* Allocate color for disabled menu-items. */ |
| 1478 | | GCFillStyle | GCStipple), &xgcv); | 1481 | if (BRIGHTNESS(mw->menu.foreground) < BRIGHTNESS(mw->core.background_pixel)) |
| 1482 | { | ||
| 1483 | delta = 2.3; | ||
| 1484 | temp.pixel = mw->menu.foreground; | ||
| 1485 | } | ||
| 1486 | else | ||
| 1487 | { | ||
| 1488 | delta = 1.2; | ||
| 1489 | temp.pixel = mw->core.background_pixel; | ||
| 1490 | } | ||
| 1491 | |||
| 1492 | x_alloc_lighter_color_for_widget ((Widget) mw, XtDisplay ((Widget) mw), | ||
| 1493 | mw->core.colormap, | ||
| 1494 | &temp.pixel, | ||
| 1495 | delta, | ||
| 1496 | 0x8000); | ||
| 1497 | mw->menu.disabled_foreground = temp.pixel; | ||
| 1498 | |||
| 1499 | if (mw->menu.foreground == mw->menu.disabled_foreground | ||
| 1500 | || mw->core.background_pixel == mw->menu.disabled_foreground) | ||
| 1501 | { | ||
| 1502 | /* Too few colors, use stipple. */ | ||
| 1503 | xgcv.foreground = mw->menu.foreground; | ||
| 1504 | xgcv.fill_style = FillStippled; | ||
| 1505 | xgcv.stipple = mw->menu.gray_pixmap; | ||
| 1506 | mw->menu.disabled_gc = XtGetGC ((Widget)mw, | ||
| 1507 | (GCFont | GCForeground | GCBackground | ||
| 1508 | | GCFillStyle | GCStipple), &xgcv); | ||
| 1509 | } | ||
| 1510 | else | ||
| 1511 | { | ||
| 1512 | /* Many colors available, use disabled pixel. */ | ||
| 1513 | xgcv.foreground = mw->menu.disabled_foreground; | ||
| 1514 | mw->menu.disabled_gc = XtGetGC ((Widget)mw, | ||
| 1515 | (GCFont | GCForeground | GCBackground), &xgcv); | ||
| 1516 | } | ||
| 1479 | 1517 | ||
| 1480 | xgcv.font = mw->menu.font->fid; | 1518 | xgcv.font = mw->menu.font->fid; |
| 1481 | xgcv.foreground = mw->menu.button_foreground; | 1519 | xgcv.foreground = mw->menu.button_foreground; |
| @@ -1500,13 +1538,13 @@ release_drawing_gcs (mw) | |||
| 1500 | { | 1538 | { |
| 1501 | XtReleaseGC ((Widget) mw, mw->menu.foreground_gc); | 1539 | XtReleaseGC ((Widget) mw, mw->menu.foreground_gc); |
| 1502 | XtReleaseGC ((Widget) mw, mw->menu.button_gc); | 1540 | XtReleaseGC ((Widget) mw, mw->menu.button_gc); |
| 1503 | XtReleaseGC ((Widget) mw, mw->menu.inactive_gc); | 1541 | XtReleaseGC ((Widget) mw, mw->menu.disabled_gc); |
| 1504 | XtReleaseGC ((Widget) mw, mw->menu.inactive_button_gc); | 1542 | XtReleaseGC ((Widget) mw, mw->menu.inactive_button_gc); |
| 1505 | XtReleaseGC ((Widget) mw, mw->menu.background_gc); | 1543 | XtReleaseGC ((Widget) mw, mw->menu.background_gc); |
| 1506 | /* let's get some segvs if we try to use these... */ | 1544 | /* let's get some segvs if we try to use these... */ |
| 1507 | mw->menu.foreground_gc = (GC) -1; | 1545 | mw->menu.foreground_gc = (GC) -1; |
| 1508 | mw->menu.button_gc = (GC) -1; | 1546 | mw->menu.button_gc = (GC) -1; |
| 1509 | mw->menu.inactive_gc = (GC) -1; | 1547 | mw->menu.disabled_gc = (GC) -1; |
| 1510 | mw->menu.inactive_button_gc = (GC) -1; | 1548 | mw->menu.inactive_button_gc = (GC) -1; |
| 1511 | mw->menu.background_gc = (GC) -1; | 1549 | mw->menu.background_gc = (GC) -1; |
| 1512 | } | 1550 | } |
| @@ -2050,6 +2088,8 @@ find_next_selectable (mw, item) | |||
| 2050 | 2088 | ||
| 2051 | if (current == item) | 2089 | if (current == item) |
| 2052 | { | 2090 | { |
| 2091 | if (mw->menu.old_depth < 2) | ||
| 2092 | return current; | ||
| 2053 | current = mw->menu.old_stack [mw->menu.old_depth - 2]->contents; | 2093 | current = mw->menu.old_stack [mw->menu.old_depth - 2]->contents; |
| 2054 | 2094 | ||
| 2055 | while (lw_separator_p (current->name, &separator, 0) || !current->enabled) | 2095 | while (lw_separator_p (current->name, &separator, 0) || !current->enabled) |