comparison lwlib/xlwmenu.c @ 45152:0e9984418269

(make_drawing_gcs): The scaling factor passed to `x_alloc_lighter_color_for_widget' is a float, not an int, and it's a multiplicative factor, so the name `delta' is inaccurate. Always base disabled foreground on the normal foreground. Don't use the temporary variable `temp'.
author Pavel Janík <Pavel@Janik.cz>
date Tue, 07 May 2002 05:22:29 +0000
parents e10cf8f440ae
children a24391626ba1
comparison
equal deleted inserted replaced
45151:e5a353edec82 45152:0e9984418269
1453 static void 1453 static void
1454 make_drawing_gcs (mw) 1454 make_drawing_gcs (mw)
1455 XlwMenuWidget mw; 1455 XlwMenuWidget mw;
1456 { 1456 {
1457 XGCValues xgcv; 1457 XGCValues xgcv;
1458 XColor temp; 1458 float scale;
1459 int delta;
1460 1459
1461 xgcv.font = mw->menu.font->fid; 1460 xgcv.font = mw->menu.font->fid;
1462 xgcv.foreground = mw->menu.foreground; 1461 xgcv.foreground = mw->menu.foreground;
1463 xgcv.background = mw->core.background_pixel; 1462 xgcv.background = mw->core.background_pixel;
1464 mw->menu.foreground_gc = XtGetGC ((Widget)mw, 1463 mw->menu.foreground_gc = XtGetGC ((Widget)mw,
1476 xgcv.background = mw->core.background_pixel; 1475 xgcv.background = mw->core.background_pixel;
1477 1476
1478 #define BRIGHTNESS(color) (((color) & 0xff) + (((color) >> 8) & 0xff) + (((color) >> 16) & 0xff)) 1477 #define BRIGHTNESS(color) (((color) & 0xff) + (((color) >> 8) & 0xff) + (((color) >> 16) & 0xff))
1479 1478
1480 /* Allocate color for disabled menu-items. */ 1479 /* Allocate color for disabled menu-items. */
1480 mw->menu.disabled_foreground = mw->menu.foreground;
1481 if (BRIGHTNESS(mw->menu.foreground) < BRIGHTNESS(mw->core.background_pixel)) 1481 if (BRIGHTNESS(mw->menu.foreground) < BRIGHTNESS(mw->core.background_pixel))
1482 { 1482 scale = 2.3;
1483 delta = 2.3;
1484 temp.pixel = mw->menu.foreground;
1485 }
1486 else 1483 else
1487 { 1484 scale = 0.55;
1488 delta = 1.2;
1489 temp.pixel = mw->core.background_pixel;
1490 }
1491 1485
1492 x_alloc_lighter_color_for_widget ((Widget) mw, XtDisplay ((Widget) mw), 1486 x_alloc_lighter_color_for_widget ((Widget) mw, XtDisplay ((Widget) mw),
1493 mw->core.colormap, 1487 mw->core.colormap,
1494 &temp.pixel, 1488 &mw->menu.disabled_foreground,
1495 delta, 1489 scale,
1496 0x8000); 1490 0x8000);
1497 mw->menu.disabled_foreground = temp.pixel;
1498 1491
1499 if (mw->menu.foreground == mw->menu.disabled_foreground 1492 if (mw->menu.foreground == mw->menu.disabled_foreground
1500 || mw->core.background_pixel == mw->menu.disabled_foreground) 1493 || mw->core.background_pixel == mw->menu.disabled_foreground)
1501 { 1494 {
1502 /* Too few colors, use stipple. */ 1495 /* Too few colors, use stipple. */