comparison lwlib/xlwmenu.c @ 207:e45d5e7c476e r20-4b2

Import from CVS: tag r20-4b2
author cvs
date Mon, 13 Aug 2007 10:03:52 +0200
parents 169c0442b401
children d44af0c54775
comparison
equal deleted inserted replaced
206:d3e9274cbc4e 207:e45d5e7c476e
98 #endif 98 #endif
99 {XtNforeground, XtCForeground, XtRPixel, sizeof(Pixel), 99 {XtNforeground, XtCForeground, XtRPixel, sizeof(Pixel),
100 offset(menu.foreground), XtRString, "XtDefaultForeground"}, 100 offset(menu.foreground), XtRString, "XtDefaultForeground"},
101 {XtNbuttonForeground, XtCButtonForeground, XtRPixel, sizeof(Pixel), 101 {XtNbuttonForeground, XtCButtonForeground, XtRPixel, sizeof(Pixel),
102 offset(menu.button_foreground), XtRString, "XtDefaultForeground"}, 102 offset(menu.button_foreground), XtRString, "XtDefaultForeground"},
103 {XtNhighlightForeground, XtCHighlightForeground, XtRPixel, sizeof(Pixel),
104 offset(menu.highlight_foreground), XtRString, "XtDefaultForeground"},
105 {XtNtitleForeground, XtCTitleForeground, XtRPixel, sizeof(Pixel),
106 offset(menu.title_foreground), XtRString, "XtDefaultForeground"},
103 {XtNmargin, XtCMargin, XtRDimension, sizeof(Dimension), 107 {XtNmargin, XtCMargin, XtRDimension, sizeof(Dimension),
104 offset(menu.margin), XtRImmediate, (XtPointer)2}, 108 offset(menu.margin), XtRImmediate, (XtPointer)2},
105 {XmNmarginWidth, XmCMarginWidth, XmRHorizontalDimension, sizeof(Dimension), 109 {XmNmarginWidth, XmCMarginWidth, XmRHorizontalDimension, sizeof(Dimension),
106 offset(menu.horizontal_margin), XtRImmediate, (XtPointer)2}, 110 offset(menu.horizontal_margin), XtRImmediate, (XtPointer)2},
107 {XmNmarginHeight, XmCMarginHeight, XmRVerticalDimension, sizeof(Dimension), 111 {XmNmarginHeight, XmCMarginHeight, XmRVerticalDimension, sizeof(Dimension),
108 offset(menu.vertical_margin), XtRImmediate, (XtPointer)1}, 112 offset(menu.vertical_margin), XtRImmediate, (XtPointer)1},
109 {XmNspacing, XmCSpacing, XmRHorizontalDimension, sizeof(Dimension), 113 {XmNspacing, XmCSpacing, XmRHorizontalDimension, sizeof(Dimension),
110 offset(menu.column_spacing), XtRImmediate, (XtPointer)4}, 114 offset(menu.column_spacing), XtRImmediate, (XtPointer)4},
111 {XmNindicatorSize, XmCIndicatorSize, XtRDimension, sizeof(Dimension), 115 {XmNindicatorSize, XmCIndicatorSize, XtRDimension, sizeof(Dimension),
112 offset(menu.indicator_size), XtRImmediate, (XtPointer)0}, 116 offset(menu.indicator_size), XtRImmediate, (XtPointer)0},
117 #if 0
113 {XmNshadowThickness, XmCShadowThickness, XmRHorizontalDimension, 118 {XmNshadowThickness, XmCShadowThickness, XmRHorizontalDimension,
114 sizeof (Dimension), offset (menu.shadow_thickness), 119 sizeof (Dimension), offset (menu.shadow_thickness),
115 XtRImmediate, (XtPointer) 2}, 120 XtRImmediate, (XtPointer) 2},
121 #else
122 {XmNshadowThickness, XmCShadowThickness, XtRDimension,
123 sizeof (Dimension), offset (menu.shadow_thickness),
124 XtRImmediate, (XtPointer) 2},
125 #endif
116 {XmNselectColor, XmCSelectColor, XtRPixel, sizeof (Pixel), 126 {XmNselectColor, XmCSelectColor, XtRPixel, sizeof (Pixel),
117 offset (menu.select_color), XtRImmediate, (XtPointer)-1}, 127 offset (menu.select_color), XtRImmediate, (XtPointer)-1},
118 {XmNtopShadowColor, XmCTopShadowColor, XtRPixel, sizeof (Pixel), 128 {XmNtopShadowColor, XmCTopShadowColor, XtRPixel, sizeof (Pixel),
119 offset (menu.top_shadow_color), XtRImmediate, (XtPointer)-1}, 129 offset (menu.top_shadow_color), XtRImmediate, (XtPointer)-1},
120 {XmNbottomShadowColor, XmCBottomShadowColor, XtRPixel, sizeof (Pixel), 130 {XmNbottomShadowColor, XmCBottomShadowColor, XtRPixel, sizeof (Pixel),
1547 unsigned height, 1557 unsigned height,
1548 unsigned label_offset, 1558 unsigned label_offset,
1549 unsigned binding_tab) 1559 unsigned binding_tab)
1550 { 1560 {
1551 int y_offset = mw->menu.shadow_thickness + mw->menu.vertical_margin; 1561 int y_offset = mw->menu.shadow_thickness + mw->menu.vertical_margin;
1562 GC gc;
1552 1563
1553 if (!label_offset) 1564 if (!label_offset)
1554 label_offset = mw->menu.shadow_thickness + mw->menu.horizontal_margin; 1565 label_offset = mw->menu.shadow_thickness + mw->menu.horizontal_margin;
1566
1567 if (highlighted && (in_menubar || val->contents))
1568 gc = mw->menu.highlight_gc;
1569 else if (in_menubar || val->contents)
1570 gc = mw->menu.foreground_gc;
1571 else
1572 gc = mw->menu.title_gc;
1555 1573
1556 /* 1574 /*
1557 * Draw the label string. 1575 * Draw the label string.
1558 */ 1576 */
1559 string_draw_u (mw, 1577 string_draw_u (mw,
1560 window, 1578 window,
1561 x + label_offset, y + y_offset, 1579 x + label_offset, y + y_offset,
1562 mw->menu.foreground_gc, 1580 gc,
1563 resource_widget_value (mw, val)); 1581 resource_widget_value (mw, val));
1564 } 1582 }
1565 1583
1566 static void 1584 static void
1567 push_button_size (XlwMenuWidget mw, 1585 push_button_size (XlwMenuWidget mw,
1613 * Draw the label string. 1631 * Draw the label string.
1614 */ 1632 */
1615 if (!label_offset) 1633 if (!label_offset)
1616 label_offset = mw->menu.shadow_thickness + mw->menu.horizontal_margin; 1634 label_offset = mw->menu.shadow_thickness + mw->menu.horizontal_margin;
1617 1635
1618 if (menu_pb) 1636 if (highlighted)
1637 {
1638 if (val->enabled)
1639 gc = mw->menu.highlight_gc;
1640 else
1641 gc = mw->menu.inactive_button_gc;
1642 }
1643 else if (menu_pb)
1619 { 1644 {
1620 if (val->enabled) 1645 if (val->enabled)
1621 gc = mw->menu.button_gc; 1646 gc = mw->menu.button_gc;
1622 else 1647 else
1623 gc = mw->menu.inactive_button_gc; 1648 gc = mw->menu.inactive_button_gc;
1776 else 1801 else
1777 rv = mw->menu.font_ascent; 1802 rv = mw->menu.font_ascent;
1778 1803
1779 if (rv > (mw->menu.font_ascent+mw->menu.font_descent)) 1804 if (rv > (mw->menu.font_ascent+mw->menu.font_descent))
1780 rv = mw->menu.font_ascent+mw->menu.font_descent; 1805 rv = mw->menu.font_ascent+mw->menu.font_descent;
1806
1807 /*
1808 * radio button can't be smaller than its border or a filling
1809 * error will occur.
1810 */
1811 if (rv < 2 * mw->menu.shadow_thickness)
1812 rv = 2 * mw->menu.shadow_thickness;
1781 1813
1782 return rv; 1814 return rv;
1783 } 1815 }
1784 1816
1785 static void 1817 static void
2648 xgcv.stipple = mw->menu.gray_pixmap; 2680 xgcv.stipple = mw->menu.gray_pixmap;
2649 mw->menu.inactive_gc = XtGetGC ((Widget)mw, 2681 mw->menu.inactive_gc = XtGetGC ((Widget)mw,
2650 (flags | GCFillStyle | GCStipple), 2682 (flags | GCFillStyle | GCStipple),
2651 &xgcv); 2683 &xgcv);
2652 2684
2685 xgcv.foreground = mw->menu.highlight_foreground;
2686 xgcv.background = mw->core.background_pixel;
2687 mw->menu.highlight_gc = XtGetGC ((Widget)mw, flags, &xgcv);
2688
2689 xgcv.foreground = mw->menu.title_foreground;
2690 xgcv.background = mw->core.background_pixel;
2691 mw->menu.title_gc = XtGetGC ((Widget)mw, flags, &xgcv);
2692
2653 xgcv.foreground = mw->menu.button_foreground; 2693 xgcv.foreground = mw->menu.button_foreground;
2654 xgcv.background = mw->core.background_pixel; 2694 xgcv.background = mw->core.background_pixel;
2655 mw->menu.button_gc = XtGetGC ((Widget)mw, flags, &xgcv); 2695 mw->menu.button_gc = XtGetGC ((Widget)mw, flags, &xgcv);
2656 2696
2657 xgcv.fill_style = FillStippled; 2697 xgcv.fill_style = FillStippled;
2664 static void 2704 static void
2665 release_drawing_gcs (XlwMenuWidget mw) 2705 release_drawing_gcs (XlwMenuWidget mw)
2666 { 2706 {
2667 XtReleaseGC ((Widget) mw, mw->menu.foreground_gc); 2707 XtReleaseGC ((Widget) mw, mw->menu.foreground_gc);
2668 XtReleaseGC ((Widget) mw, mw->menu.button_gc); 2708 XtReleaseGC ((Widget) mw, mw->menu.button_gc);
2709 XtReleaseGC ((Widget) mw, mw->menu.highlight_gc);
2710 XtReleaseGC ((Widget) mw, mw->menu.title_gc);
2669 XtReleaseGC ((Widget) mw, mw->menu.inactive_gc); 2711 XtReleaseGC ((Widget) mw, mw->menu.inactive_gc);
2670 XtReleaseGC ((Widget) mw, mw->menu.inactive_button_gc); 2712 XtReleaseGC ((Widget) mw, mw->menu.inactive_button_gc);
2671 XtReleaseGC ((Widget) mw, mw->menu.background_gc); 2713 XtReleaseGC ((Widget) mw, mw->menu.background_gc);
2672 XtReleaseGC ((Widget) mw, mw->menu.select_gc); 2714 XtReleaseGC ((Widget) mw, mw->menu.select_gc);
2673 /* let's get some segvs if we try to use these... */ 2715 /* let's get some segvs if we try to use these... */
2674 mw->menu.foreground_gc = (GC) -1; 2716 mw->menu.foreground_gc = (GC) -1;
2675 mw->menu.button_gc = (GC) -1; 2717 mw->menu.button_gc = (GC) -1;
2718 mw->menu.highlight_gc = (GC) -1;
2719 mw->menu.title_gc = (GC) -1;
2676 mw->menu.inactive_gc = (GC) -1; 2720 mw->menu.inactive_gc = (GC) -1;
2677 mw->menu.inactive_button_gc = (GC) -1; 2721 mw->menu.inactive_button_gc = (GC) -1;
2678 mw->menu.background_gc = (GC) -1; 2722 mw->menu.background_gc = (GC) -1;
2679 mw->menu.select_gc = (GC) -1; 2723 mw->menu.select_gc = (GC) -1;
2680 } 2724 }