annotate lwlib/xlwmenu.c @ 2:ac2d302a0011 r19-15b2

Import from CVS: tag r19-15b2
author cvs
date Mon, 13 Aug 2007 08:46:35 +0200
parents 376386a54a3c
children bcdc7deadc19
Ignore whitespace changes - Everywhere: Within whitespace: At end of lines:
rev   line source
0
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
1 /* Implements a lightweight menubar widget.
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
2 Copyright (C) 1992, 1993, 1994 Lucid, Inc.
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
3 Copyright (C) 1995 Tinker Systems and INS Engineering Corp.
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
4
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
5 This file is part of the Lucid Widget Library.
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
6
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
7 The Lucid Widget Library is free software; you can redistribute it and/or
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
8 modify it under the terms of the GNU General Public License as published by
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
9 the Free Software Foundation; either version 2, or (at your option)
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
10 any later version.
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
11
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
12 The Lucid Widget Library is distributed in the hope that it will be useful,
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
13 but WITHOUT ANY WARRANTY; without even the implied warranty of
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
14 MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
15 GNU General Public License for more details.
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
16
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
17 You should have received a copy of the GNU General Public License
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
18 along with GNU Emacs; see the file COPYING. If not, write to
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
19 the Free Software Foundation, 675 Mass Ave, Cambridge, MA 02139, USA. */
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
20
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
21 /* Created by devin@lucid.com */
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
22
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
23 #include <stdlib.h>
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
24 #include <unistd.h>
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
25 #include <string.h>
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
26 #include <ctype.h>
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
27 #include <stdio.h>
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
28
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
29 #include <sys/types.h>
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
30 #include <X11/Xos.h>
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
31 #include <X11/IntrinsicP.h>
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
32 #include <X11/StringDefs.h>
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
33 #include <X11/cursorfont.h>
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
34 #include <X11/bitmaps/gray>
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
35
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
36 #ifdef NEED_MOTIF
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
37 #include <Xm/Xm.h>
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
38 #endif
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
39 #include "xlwmenuP.h"
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
40
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
41 static char
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
42 xlwMenuTranslations [] =
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
43 "<BtnDown>: start()\n\
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
44 <BtnMotion>: drag()\n\
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
45 <BtnUp>: select()\n\
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
46 ";
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
47
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
48 #define offset(field) XtOffset(XlwMenuWidget, field)
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
49 static XtResource
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
50 xlwMenuResources[] =
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
51 {
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
52 #ifdef NEED_MOTIF
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
53 /* There are three font list resources, so that we can accept either of
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
54 the resources *fontList: or *font:, and so that we can tell the
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
55 difference between them being specified, and being defaulted to a
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
56 font from the XtRString specified here.
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
57 */
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
58 {XmNfontList, XmCFontList, XmRFontList, sizeof(XmFontList),
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
59 offset(menu.font_list), XtRImmediate, (XtPointer)0},
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
60 {XtNfont, XtCFont, XmRFontList, sizeof(XmFontList),
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
61 offset(menu.font_list_2),XtRImmediate, (XtPointer)0},
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
62 {XmNfontList, XmCFontList, XmRFontList, sizeof(XmFontList),
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
63 offset(menu.fallback_font_list),
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
64 /* We must use an iso8859-1 font here, or people without $LANG set lose.
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
65 It's fair to assume that those who do have $LANG set also have the
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
66 *fontList resource set, or at least know how to deal with this.
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
67 */
2
ac2d302a0011 Import from CVS: tag r19-15b2
cvs
parents: 0
diff changeset
68 XtRString, (String) "-*-helvetica-bold-r-*-*-*-120-*-*-*-*-iso8859-1"},
0
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
69 #else
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
70 {XtNfont, XtCFont, XtRFontStruct, sizeof(XFontStruct *),
2
ac2d302a0011 Import from CVS: tag r19-15b2
cvs
parents: 0
diff changeset
71 offset(menu.font), XtRString, "XtDefaultFont"},
0
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
72 #endif
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
73 {XtNforeground, XtCForeground, XtRPixel, sizeof(Pixel),
2
ac2d302a0011 Import from CVS: tag r19-15b2
cvs
parents: 0
diff changeset
74 offset(menu.foreground), XtRString, (String) "XtDefaultForeground"},
0
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
75 {XtNbuttonForeground, XtCButtonForeground, XtRPixel, sizeof(Pixel),
2
ac2d302a0011 Import from CVS: tag r19-15b2
cvs
parents: 0
diff changeset
76 offset(menu.button_foreground), XtRString, (String)"XtDefaultForeground"},
0
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
77 {XtNmargin, XtCMargin, XtRDimension, sizeof(Dimension),
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
78 offset(menu.margin), XtRImmediate, (XtPointer)2},
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
79 {XmNmarginWidth, XmCMarginWidth, XmRHorizontalDimension, sizeof(Dimension),
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
80 offset(menu.horizontal_margin), XtRImmediate, (XtPointer)2},
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
81 {XmNmarginHeight, XmCMarginHeight, XmRVerticalDimension, sizeof(Dimension),
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
82 offset(menu.vertical_margin), XtRImmediate, (XtPointer)1},
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
83 {XmNspacing, XmCSpacing, XmRHorizontalDimension, sizeof(Dimension),
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
84 offset(menu.column_spacing), XtRImmediate, (XtPointer)4},
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
85 {XmNindicatorSize, XmCIndicatorSize, XtRDimension, sizeof(Dimension),
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
86 offset(menu.indicator_size), XtRImmediate, (XtPointer)0},
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
87 {XmNshadowThickness, XmCShadowThickness, XmRHorizontalDimension,
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
88 sizeof (Dimension), offset (menu.shadow_thickness),
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
89 XtRImmediate, (XtPointer) 2},
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
90 {XmNselectColor, XmCSelectColor, XtRPixel, sizeof (Pixel),
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
91 offset (menu.select_color), XtRImmediate, (XtPointer)-1},
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
92 {XmNtopShadowColor, XmCTopShadowColor, XtRPixel, sizeof (Pixel),
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
93 offset (menu.top_shadow_color), XtRImmediate, (XtPointer)-1},
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
94 {XmNbottomShadowColor, XmCBottomShadowColor, XtRPixel, sizeof (Pixel),
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
95 offset (menu.bottom_shadow_color), XtRImmediate, (XtPointer)-1},
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
96 {XmNtopShadowPixmap, XmCTopShadowPixmap, XtRPixmap, sizeof (Pixmap),
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
97 offset (menu.top_shadow_pixmap), XtRImmediate, (XtPointer)None},
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
98 {XmNbottomShadowPixmap, XmCBottomShadowPixmap, XtRPixmap, sizeof (Pixmap),
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
99 offset (menu.bottom_shadow_pixmap), XtRImmediate, (XtPointer)None},
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
100
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
101 {XtNopen, XtCCallback, XtRCallback, sizeof(XtPointer),
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
102 offset(menu.open), XtRCallback, (XtPointer)NULL},
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
103 {XtNselect, XtCCallback, XtRCallback, sizeof(XtPointer),
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
104 offset(menu.select), XtRCallback, (XtPointer)NULL},
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
105 {XtNmenu, XtCMenu, XtRPointer, sizeof(XtPointer),
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
106 offset(menu.contents), XtRImmediate, (XtPointer)NULL},
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
107 {XtNcursor, XtCCursor, XtRCursor, sizeof(Cursor),
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
108 offset(menu.cursor_shape), XtRString, (XtPointer)"right_ptr"},
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
109 {XtNhorizontal, XtCHorizontal, XtRInt, sizeof(int),
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
110 offset(menu.horizontal), XtRImmediate, (XtPointer)True},
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
111 {XtNuseBackingStore, XtCUseBackingStore, XtRBoolean, sizeof (Boolean),
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
112 offset (menu.use_backing_store), XtRImmediate, (XtPointer)False},
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
113 {XtNbounceDown, XtCBounceDown, XtRBoolean, sizeof (Boolean),
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
114 offset (menu.bounce_down), XtRImmediate, (XtPointer)True},
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
115 {XtNresourceLabels, XtCResourceLabels, XtRBoolean, sizeof (Boolean),
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
116 offset (menu.lookup_labels), XtRImmediate, (XtPointer)False},
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
117 };
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
118 #undef offset
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
119
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
120 static Boolean XlwMenuSetValues (Widget current, Widget request, Widget new,
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
121 ArgList args, Cardinal *num_args);
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
122 static void XlwMenuRealize (Widget w, Mask *valueMask,
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
123 XSetWindowAttributes *attributes);
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
124 static void XlwMenuRedisplay (Widget w, XEvent *ev, Region region);
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
125 static void XlwMenuResize (Widget w);
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
126 static void XlwMenuInitialize (Widget request, Widget new, ArgList args,
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
127 Cardinal *num_args);
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
128 static void XlwMenuDestroy (Widget w);
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
129 static void XlwMenuClassInitialize (void);
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
130 static void Start (Widget w, XEvent *ev, String *params, Cardinal *num_params);
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
131 static void Drag (Widget w, XEvent *ev, String *params, Cardinal *num_params);
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
132 static void Select (Widget w, XEvent *ev, String *params,
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
133 Cardinal *num_params);
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
134
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
135 #ifdef NEED_MOTIF
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
136 static XFontStruct *default_font_of_font_list (XmFontList);
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
137 #endif
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
138
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
139 static XtActionsRec
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
140 xlwMenuActionsList [] =
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
141 {
2
ac2d302a0011 Import from CVS: tag r19-15b2
cvs
parents: 0
diff changeset
142 {(String) "start", Start},
ac2d302a0011 Import from CVS: tag r19-15b2
cvs
parents: 0
diff changeset
143 {(String) "drag", Drag},
ac2d302a0011 Import from CVS: tag r19-15b2
cvs
parents: 0
diff changeset
144 {(String) "select", Select},
0
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
145 };
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
146
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
147 #define SuperClass ((CoreWidgetClass)&coreClassRec)
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
148
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
149 XlwMenuClassRec xlwMenuClassRec =
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
150 {
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
151 { /* CoreClass fields initialization */
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
152 (WidgetClass) SuperClass, /* superclass */
2
ac2d302a0011 Import from CVS: tag r19-15b2
cvs
parents: 0
diff changeset
153 (String) "XlwMenu", /* class_name */
0
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
154 sizeof(XlwMenuRec), /* size */
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
155 XlwMenuClassInitialize, /* class_initialize */
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
156 NULL, /* class_part_initialize */
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
157 FALSE, /* class_inited */
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
158 XlwMenuInitialize, /* initialize */
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
159 NULL, /* initialize_hook */
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
160 XlwMenuRealize, /* realize */
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
161 xlwMenuActionsList, /* actions */
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
162 XtNumber(xlwMenuActionsList), /* num_actions */
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
163 xlwMenuResources, /* resources */
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
164 XtNumber(xlwMenuResources), /* resource_count */
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
165 NULLQUARK, /* xrm_class */
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
166 TRUE, /* compress_motion */
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
167 TRUE, /* compress_exposure */
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
168 TRUE, /* compress_enterleave */
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
169 FALSE, /* visible_interest */
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
170 XlwMenuDestroy, /* destroy */
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
171 XlwMenuResize, /* resize */
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
172 XlwMenuRedisplay, /* expose */
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
173 XlwMenuSetValues, /* set_values */
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
174 NULL, /* set_values_hook */
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
175 XtInheritSetValuesAlmost, /* set_values_almost */
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
176 NULL, /* get_values_hook */
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
177 NULL, /* #### - should this be set for grabs? accept_focus */
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
178 XtVersion, /* version */
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
179 NULL, /* callback_private */
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
180 xlwMenuTranslations, /* tm_table */
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
181 XtInheritQueryGeometry, /* query_geometry */
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
182 XtInheritDisplayAccelerator, /* display_accelerator */
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
183 NULL /* extension */
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
184 }, /* XlwMenuClass fields initialization */
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
185 {
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
186 0 /* dummy */
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
187 },
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
188 };
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
189
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
190 WidgetClass xlwMenuWidgetClass = (WidgetClass) &xlwMenuClassRec;
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
191
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
192 /* Utilities */
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
193 #if 0 /* Apparently not used anywhere */
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
194
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
195 static char *
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
196 safe_strdup (char *s)
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
197 {
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
198 char *result;
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
199 if (! s) return 0;
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
200 result = (char *) malloc (strlen (s) + 1);
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
201 if (! result)
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
202 return 0;
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
203 strcpy (result, s);
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
204 return result;
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
205 }
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
206
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
207 #endif /* 0 */
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
208
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
209 /* Replacement for XAllocColor() that tries to return the nearest
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
210 available color if the colormap is full. From FSF Emacs. */
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
211
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
212 static int
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
213 allocate_nearest_color (Display *display, Colormap screen_colormap,
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
214 XColor *color_def)
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
215 {
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
216 int status;
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
217
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
218 status = XAllocColor (display, screen_colormap, color_def);
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
219 if (!status)
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
220 {
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
221 /* If we got to this point, the colormap is full, so we're
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
222 going to try and get the next closest color.
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
223 The algorithm used is a least-squares matching, which is
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
224 what X uses for closest color matching with StaticColor visuals. */
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
225
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
226 XColor *cells;
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
227 int no_cells;
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
228 int nearest;
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
229 long nearest_delta, trial_delta;
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
230 int x;
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
231
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
232 no_cells = XDisplayCells (display, XDefaultScreen (display));
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
233 /* Don't use alloca here because lwlib doesn't have the
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
234 necessary configuration information that src does. */
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
235 cells = (XColor *) malloc (sizeof (XColor) * no_cells);
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
236
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
237 for (x = 0; x < no_cells; x++)
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
238 cells[x].pixel = x;
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
239
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
240 XQueryColors (display, screen_colormap, cells, no_cells);
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
241 nearest = 0;
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
242 /* I'm assuming CSE so I'm not going to condense this. */
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
243 nearest_delta = ((((color_def->red >> 8) - (cells[0].red >> 8))
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
244 * ((color_def->red >> 8) - (cells[0].red >> 8)))
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
245 +
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
246 (((color_def->green >> 8) - (cells[0].green >> 8))
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
247 * ((color_def->green >> 8) - (cells[0].green >> 8)))
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
248 +
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
249 (((color_def->blue >> 8) - (cells[0].blue >> 8))
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
250 * ((color_def->blue >> 8) - (cells[0].blue >> 8))));
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
251 for (x = 1; x < no_cells; x++)
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
252 {
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
253 trial_delta = ((((color_def->red >> 8) - (cells[x].red >> 8))
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
254 * ((color_def->red >> 8) - (cells[x].red >> 8)))
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
255 +
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
256 (((color_def->green >> 8) - (cells[x].green >> 8))
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
257 * ((color_def->green >> 8) - (cells[x].green >> 8)))
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
258 +
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
259 (((color_def->blue >> 8) - (cells[x].blue >> 8))
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
260 * ((color_def->blue >> 8) - (cells[x].blue >> 8))));
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
261 if (trial_delta < nearest_delta)
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
262 {
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
263 nearest = x;
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
264 nearest_delta = trial_delta;
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
265 }
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
266 }
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
267 color_def->red = cells[nearest].red;
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
268 color_def->green = cells[nearest].green;
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
269 color_def->blue = cells[nearest].blue;
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
270 status = XAllocColor (display, screen_colormap, color_def);
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
271
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
272 free (cells);
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
273 }
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
274
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
275 return status;
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
276 }
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
277
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
278 static void
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
279 push_new_stack (XlwMenuWidget mw, widget_value *val)
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
280 {
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
281 if (!mw->menu.new_stack)
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
282 {
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
283 mw->menu.new_stack_length = 10;
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
284 mw->menu.new_stack =
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
285 (widget_value**)XtCalloc (mw->menu.new_stack_length,
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
286 sizeof (widget_value*));
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
287 }
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
288 else if (mw->menu.new_depth == mw->menu.new_stack_length)
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
289 {
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
290 mw->menu.new_stack_length *= 2;
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
291 mw->menu.new_stack =
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
292 (widget_value**)XtRealloc ((char*)mw->menu.new_stack,
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
293 mw->menu.new_stack_length *
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
294 sizeof (widget_value*));
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
295 }
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
296 mw->menu.new_stack [mw->menu.new_depth++] = val;
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
297 }
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
298
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
299 static void
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
300 pop_new_stack_if_no_contents (XlwMenuWidget mw)
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
301 {
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
302 if (mw->menu.new_depth)
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
303 {
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
304 if (!mw->menu.new_stack [mw->menu.new_depth - 1]->contents)
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
305 {
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
306 mw->menu.new_depth -= 1;
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
307 }
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
308 }
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
309 }
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
310
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
311 static void
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
312 make_old_stack_space (XlwMenuWidget mw, int n)
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
313 {
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
314 if (!mw->menu.old_stack)
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
315 {
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
316 mw->menu.old_stack_length = 10;
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
317 mw->menu.old_stack =
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
318 (widget_value**)XtCalloc (mw->menu.old_stack_length,
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
319 sizeof (widget_value*));
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
320 }
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
321 else if (mw->menu.old_stack_length < n)
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
322 {
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
323 mw->menu.old_stack_length *= 2;
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
324 mw->menu.old_stack =
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
325 (widget_value**)XtRealloc ((char*)mw->menu.old_stack,
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
326 mw->menu.old_stack_length *
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
327 sizeof (widget_value*));
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
328 }
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
329 }
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
330
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
331 static Boolean
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
332 close_to_reference_time(Widget w, Time reference_time, XEvent *ev)
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
333 {
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
334 return (reference_time &&
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
335 (ev->xbutton.time - reference_time
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
336 < XtGetMultiClickTime (XtDisplay (w))));
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
337 }
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
338
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
339 /* Size code */
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
340 static int
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
341 string_width (XlwMenuWidget mw,
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
342 #ifdef NEED_MOTIF
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
343 XmString s
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
344 #else
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
345 char *s
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
346 #endif
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
347 )
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
348 {
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
349 #ifdef NEED_MOTIF
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
350 Dimension width, height;
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
351 XmStringExtent (mw->menu.font_list, s, &width, &height);
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
352 return width;
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
353 #else
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
354 XCharStruct xcs;
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
355 int drop;
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
356 XTextExtents (mw->menu.font, s, strlen (s), &drop, &drop, &drop, &xcs);
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
357 return xcs.width;
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
358 #endif
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
359 }
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
360
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
361 static void
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
362 massage_resource_name (CONST char *in, char *out)
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
363 {
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
364 /* Turn a random string into something suitable for using as a resource.
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
365 For example:
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
366
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
367 "Kill Buffer" -> "killBuffer"
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
368 "Find File..." -> "findFile"
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
369 "Search and Replace..." -> "searchAndReplace"
2
ac2d302a0011 Import from CVS: tag r19-15b2
cvs
parents: 0
diff changeset
370 "C++ Mode Commands" -> "cppModeCommands"
0
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
371 */
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
372
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
373 # define GOOD_CHAR(c) (((c) >= 'a' && (c) <= 'z') || \
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
374 ((c) >= 'A' && (c) <= 'Z') || \
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
375 ((c) >= '0' && (c) <= '9') || \
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
376 ((c) == '_') || \
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
377 ((c) > 0240))
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
378 int firstp = 1;
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
379 while (*in)
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
380 {
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
381 if (GOOD_CHAR ((unsigned char) *in))
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
382 {
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
383 if (firstp)
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
384 *out = tolower (*in);
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
385 else
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
386 *out = toupper (*in);
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
387 firstp = 0;
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
388 in++;
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
389 out++;
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
390 while (GOOD_CHAR ((unsigned char) *in))
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
391 {
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
392 *out = *in;
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
393 in++;
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
394 out++;
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
395 }
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
396 }
2
ac2d302a0011 Import from CVS: tag r19-15b2
cvs
parents: 0
diff changeset
397 else if ((unsigned char)*in == '+')
ac2d302a0011 Import from CVS: tag r19-15b2
cvs
parents: 0
diff changeset
398 {
ac2d302a0011 Import from CVS: tag r19-15b2
cvs
parents: 0
diff changeset
399 /* for char '+' convert to 'P', e.g for C++ to cPP */
ac2d302a0011 Import from CVS: tag r19-15b2
cvs
parents: 0
diff changeset
400 *out = 'P';
ac2d302a0011 Import from CVS: tag r19-15b2
cvs
parents: 0
diff changeset
401 in++;
ac2d302a0011 Import from CVS: tag r19-15b2
cvs
parents: 0
diff changeset
402 out++;
ac2d302a0011 Import from CVS: tag r19-15b2
cvs
parents: 0
diff changeset
403 }
0
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
404 else
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
405 {
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
406 /* A bogus char between words; skip it. */
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
407 in++;
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
408 }
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
409 }
2
ac2d302a0011 Import from CVS: tag r19-15b2
cvs
parents: 0
diff changeset
410
ac2d302a0011 Import from CVS: tag r19-15b2
cvs
parents: 0
diff changeset
411 /* Add the following define to --cflags to generate a translation
ac2d302a0011 Import from CVS: tag r19-15b2
cvs
parents: 0
diff changeset
412 file for menu localizations */
ac2d302a0011 Import from CVS: tag r19-15b2
cvs
parents: 0
diff changeset
413 #ifdef PRINT_XLWMENU_RESOURCE_CONVERSIONS
ac2d302a0011 Import from CVS: tag r19-15b2
cvs
parents: 0
diff changeset
414 printf("Emacs*XlwMenu.%s.labelString:\t%s\n", outpointer, inpointer);
ac2d302a0011 Import from CVS: tag r19-15b2
cvs
parents: 0
diff changeset
415 #endif
0
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
416 *out = 0;
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
417 #undef GOOD_CHAR
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
418 }
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
419
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
420 static XtResource
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
421 nameResource[] =
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
422 {
2
ac2d302a0011 Import from CVS: tag r19-15b2
cvs
parents: 0
diff changeset
423 { (String) "labelString", (String) "LabelString", XtRString, sizeof(String),
0
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
424 0, XtRImmediate, 0 }
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
425 };
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
426
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
427 /*
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
428 * This function looks through string searching for parameter
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
429 * inserts of the form:
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
430 * %[padding]1
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
431 * padding is space (' ') or dash ('-') characters meaning
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
432 * padding to the left or right of the inserted parameter.
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
433 * In essence all %1 strings are replaced by value in the return
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
434 * value (which the caller is expected to free).
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
435 * %% means insert one % (like printf).
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
436 * %1 means insert value.
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
437 * %-1 means insert value followed by one space. The latter is
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
438 * not inserted if value is a zero length string.
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
439 */
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
440 static char*
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
441 parameterize_string (CONST char *string, CONST char *value)
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
442 {
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
443 char *percent;
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
444 char *result;
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
445 unsigned done = 0;
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
446 unsigned ntimes;
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
447
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
448 if (!string)
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
449 {
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
450 result = XtMalloc(1);
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
451 result[0] = '\0';
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
452 return (result);
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
453 }
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
454
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
455 if (!value)
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
456 value = "";
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
457
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
458 for (ntimes = 1, result = (char *) string; (percent = strchr(result, '%'));
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
459 ntimes++)
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
460 result = &percent[1];
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
461
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
462 result = XtMalloc((ntimes * strlen(value)) + strlen(string) + 4);
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
463 result[0] = '\0';
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
464
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
465 while ((percent = strchr(string, '%')))
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
466 {
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
467 unsigned left_pad;
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
468 unsigned right_pad;
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
469 char *p;
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
470
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
471 if (percent[1] == '%')
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
472 { /* it's a real % */
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
473 strncat(result, string, 1 + percent - string); /* incl % */
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
474 string = &percent[2]; /* after the second '%' */
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
475 continue; /* with the while() loop */
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
476 }
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
477
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
478 left_pad = 0;
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
479 right_pad = 0;
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
480
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
481 for (p = &percent[1]; /* test *p inside the loop */ ; p++)
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
482 {
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
483 if (*p == ' ')
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
484 { /* left pad */
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
485 left_pad++;
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
486 }
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
487 else if (*p == '-')
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
488 { /* right pad */
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
489 right_pad++;
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
490 }
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
491 else if (*p == '1')
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
492 { /* param and terminator */
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
493 strncat(result, string, percent - string);
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
494 if (value[0] != '\0')
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
495 {
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
496 unsigned i;
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
497 for (i = 0; i < left_pad; i++)
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
498 strcat(result, " ");
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
499 strcat(result, value);
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
500 for (i = 0; i < right_pad; i++)
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
501 strcat(result, " ");
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
502 }
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
503 string = &p[1]; /* after the '1' */
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
504 done++; /* no need to do old way */
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
505 break; /* out of for() loop */
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
506 }
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
507 else
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
508 { /* bogus, copy the format as is */
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
509 /* out of for() loop */
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
510 strncat(result, string, 1 + p - string);
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
511 string= (*p ? &p[1] : p);
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
512 break;
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
513 }
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
514 }
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
515 }
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
516
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
517 /*
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
518 * Copy the tail of the string
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
519 */
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
520 strcat(result, string);
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
521
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
522 /*
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
523 * If we have not processed a % string, and we have a value, tail it.
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
524 */
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
525 if (!done && value[0] != '\0')
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
526 {
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
527 strcat(result, " ");
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
528 strcat(result, value);
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
529 }
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
530
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
531 return result;
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
532 }
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
533
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
534 #ifdef NEED_MOTIF
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
535
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
536 static XmString
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
537 resource_widget_value (XlwMenuWidget mw, widget_value *val)
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
538 {
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
539 if (!val->toolkit_data)
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
540 {
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
541 char *resourced_name = NULL;
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
542 char *converted_name, *str;
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
543 XmString complete_name;
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
544 char massaged_name [1024];
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
545
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
546 if (mw->menu.lookup_labels)
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
547 {
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
548 /* Convert value style name into resource style name.
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
549 eg: "Free Willy" becomes "freeWilly" */
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
550 massage_resource_name (val->name, massaged_name);
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
551
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
552 /* If we have a value (parameter) see if we can find a "Named"
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
553 resource. */
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
554 if (val->value)
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
555 {
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
556 char named_name[1024];
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
557 sprintf(named_name, "%sNamed", massaged_name);
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
558 XtGetSubresources ((Widget) mw,
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
559 (XtPointer) &resourced_name,
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
560 named_name, named_name,
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
561 nameResource, 1, NULL, 0);
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
562 }
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
563
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
564 /* If nothing yet, try to load from the massaged name. */
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
565 if (!resourced_name)
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
566 {
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
567 XtGetSubresources ((Widget) mw,
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
568 (XtPointer) &resourced_name,
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
569 massaged_name, massaged_name,
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
570 nameResource, 1, NULL, 0);
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
571 }
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
572 } /* if (mw->menu.lookup_labels) */
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
573
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
574 /* Still nothing yet, use the name as the value. */
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
575 if (!resourced_name)
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
576 resourced_name = val->name;
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
577
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
578 /* Parameterize the string. */
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
579 converted_name = parameterize_string(resourced_name, val->value);
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
580
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
581 /* nuke newline characters to prevent menubar screwups */
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
582 for ( str = converted_name ; *str ; str++ )
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
583 {
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
584 if (str[0] == '\n') str[0] = ' ';
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
585 }
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
586
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
587 /* Improve OSF's bottom line. */
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
588 #if (XmVersion >= 1002)
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
589 complete_name = XmStringCreateLocalized (converted_name);
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
590 #else
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
591 complete_name = XmStringCreateLtoR (converted_name,
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
592 XmSTRING_DEFAULT_CHARSET);
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
593 #endif
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
594 XtFree (converted_name);
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
595
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
596 val->toolkit_data = complete_name;
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
597 val->free_toolkit_data = True;
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
598 }
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
599 return ((XmString) val->toolkit_data);
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
600 }
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
601
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
602 /* Unused */
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
603 #if 0
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
604 /*
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
605 * These two routines should be a seperate file..djw
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
606 */
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
607 static char *
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
608 xlw_create_localized_string (Widget w,
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
609 char *name,
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
610 char **args,
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
611 unsigned nargs)
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
612 {
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
613 char *string = NULL;
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
614 char *arg = NULL;
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
615
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
616 if (nargs > 0)
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
617 arg = args[0];
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
618
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
619 XtGetSubresources (w,
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
620 (XtPointer)&string,
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
621 name,
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
622 name,
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
623 nameResource, 1,
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
624 NULL, 0
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
625 );
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
626
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
627 if (!string)
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
628 string = name;
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
629
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
630 return parameterize_string (string, arg);
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
631 }
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
632
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
633 static XmString
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
634 xlw_create_localized_xmstring (Widget w,
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
635 char *name,
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
636 char **args,
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
637 unsigned nargs)
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
638 {
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
639 char * string = xlw_create_localized_string (w, name, args, nargs);
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
640 XmString xm_string = XmStringCreateLtoR (string, XmSTRING_DEFAULT_CHARSET);
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
641 XtFree(string);
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
642 return xm_string;
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
643 }
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
644 #endif /* 0 */
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
645
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
646 #else /* !Motif */
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
647
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
648 static char*
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
649 resource_widget_value (XlwMenuWidget mw, widget_value *val)
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
650 {
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
651 if (!val->toolkit_data)
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
652 {
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
653 char *resourced_name = NULL;
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
654 char *complete_name;
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
655 char massaged_name [1024];
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
656
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
657 if (mw->menu.lookup_labels)
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
658 {
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
659 massage_resource_name (val->name, massaged_name);
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
660
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
661 XtGetSubresources ((Widget) mw,
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
662 (XtPointer) &resourced_name,
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
663 massaged_name, massaged_name,
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
664 nameResource, 1, NULL, 0);
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
665 }
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
666 if (!resourced_name)
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
667 resourced_name = val->name;
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
668
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
669 complete_name = parameterize_string(resourced_name, val->value);
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
670
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
671 val->toolkit_data = complete_name;
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
672 /* nuke newline characters to prevent menubar screwups */
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
673 for ( ; *complete_name ; complete_name++ )
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
674 {
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
675 if (complete_name[0] == '\n')
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
676 complete_name[0] = ' ';
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
677 }
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
678 val->free_toolkit_data = True;
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
679 }
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
680 return (char*)val->toolkit_data;
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
681 }
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
682
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
683 #endif /* !Motif */
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
684
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
685 /*
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
686 * Code for drawing strings.
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
687 */
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
688 static void
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
689 string_draw(
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
690 XlwMenuWidget mw,
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
691 Window window,
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
692 int x, int y,
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
693 GC gc,
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
694 #ifdef NEED_MOTIF
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
695 XmString string
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
696 #else
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
697 char *string
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
698 #endif
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
699 ) {
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
700 #ifdef NEED_MOTIF
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
701 XmStringDraw (XtDisplay (mw), window,
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
702 mw->menu.font_list,
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
703 string, gc,
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
704 x, y,
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
705 1000, /* ???? width */
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
706 XmALIGNMENT_BEGINNING,
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
707 0, /* ???? layout_direction */
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
708 0);
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
709 #else
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
710 XDrawString (XtDisplay (mw), window, gc,
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
711 x, y + mw->menu.font_ascent, string, strlen (string));
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
712
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
713 #endif
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
714 }
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
715
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
716 static void
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
717 binding_draw (XlwMenuWidget mw, Window w, int x, int y, GC gc, char *value)
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
718 {
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
719 #ifdef NEED_MOTIF
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
720 XmString xm_value = XmStringCreateLtoR(value, XmSTRING_DEFAULT_CHARSET);
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
721 string_draw (mw, w, x, y, gc, xm_value);
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
722 XmStringFree (xm_value);
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
723 #else
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
724 string_draw (mw, w, x, y, gc, value);
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
725 #endif
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
726 }
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
727
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
728 /*
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
729 * Low level code for drawing 3-D edges.
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
730 */
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
731 static void
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
732 shadow_rectangle_draw (
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
733 Display *dpy,
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
734 Window window,
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
735 GC top_gc,
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
736 GC bottom_gc,
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
737 int x, int y, unsigned width, unsigned height,
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
738 unsigned thickness
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
739 )
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
740 {
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
741 XPoint points [4];
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
742
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
743 if (!thickness)
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
744 return;
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
745
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
746 points [0].x = x;
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
747 points [0].y = y;
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
748 points [1].x = x + width;
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
749 points [1].y = y;
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
750 points [2].x = x + width - thickness;
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
751 points [2].y = y + thickness;
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
752 points [3].x = x;
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
753 points [3].y = y + thickness;
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
754 XFillPolygon (dpy, window, top_gc, points, 4, Convex, CoordModeOrigin);
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
755 points [0].x = x;
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
756 points [0].y = y + thickness;
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
757 points [1].x = x;
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
758 points [1].y = y + height;
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
759 points [2].x = x + thickness;
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
760 points [2].y = y + height - thickness;
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
761 points [3].x = x + thickness;
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
762 points [3].y = y + thickness;
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
763 XFillPolygon (dpy, window, top_gc, points, 4, Convex, CoordModeOrigin);
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
764 points [0].x = x + width;
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
765 points [0].y = y;
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
766 points [1].x = x + width - thickness;
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
767 points [1].y = y + thickness;
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
768 points [2].x = x + width - thickness;
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
769 points [2].y = y + height - thickness;
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
770 points [3].x = x + width;
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
771 points [3].y = y + height - thickness;
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
772 XFillPolygon (dpy, window, bottom_gc, points, 4, Convex, CoordModeOrigin);
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
773 points [0].x = x;
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
774 points [0].y = y + height;
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
775 points [1].x = x + width;
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
776 points [1].y = y + height;
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
777 points [2].x = x + width;
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
778 points [2].y = y + height - thickness;
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
779 points [3].x = x + thickness;
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
780 points [3].y = y + height - thickness;
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
781 XFillPolygon (dpy, window, bottom_gc, points, 4, Convex, CoordModeOrigin);
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
782 }
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
783
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
784 typedef enum e_shadow_type
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
785 {
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
786 /* these are Motif compliant */
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
787 SHADOW_BACKGROUND,
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
788 SHADOW_OUT,
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
789 SHADOW_IN,
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
790 SHADOW_ETCHED_OUT,
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
791 SHADOW_ETCHED_IN,
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
792 SHADOW_ETCHED_OUT_DASH,
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
793 SHADOW_ETCHED_IN_DASH,
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
794 SHADOW_SINGLE_LINE,
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
795 SHADOW_DOUBLE_LINE,
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
796 SHADOW_SINGLE_DASHED_LINE,
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
797 SHADOW_DOUBLE_DASHED_LINE,
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
798 SHADOW_NO_LINE,
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
799 /* these are all non-Motif */
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
800 SHADOW_DOUBLE_ETCHED_OUT,
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
801 SHADOW_DOUBLE_ETCHED_IN,
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
802 SHADOW_DOUBLE_ETCHED_OUT_DASH,
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
803 SHADOW_DOUBLE_ETCHED_IN_DASH
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
804 } shadow_type;
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
805
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
806 static void
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
807 shadow_draw (XlwMenuWidget mw,
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
808 Window window,
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
809 int x, int y, unsigned width, unsigned height,
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
810 shadow_type type
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
811 )
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
812 {
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
813 Display *dpy = XtDisplay (mw);
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
814 GC top_gc;
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
815 GC bottom_gc;
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
816 int thickness = mw->menu.shadow_thickness;
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
817 #if 0
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
818 XPoint points [4];
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
819 #endif /* 0 */
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
820 Boolean etched = False;
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
821
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
822 switch (type)
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
823 {
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
824 case SHADOW_BACKGROUND:
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
825 top_gc = bottom_gc = mw->menu.background_gc;
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
826 break;
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
827 case SHADOW_ETCHED_IN:
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
828 top_gc = mw->menu.shadow_bottom_gc;
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
829 bottom_gc = mw->menu.shadow_top_gc;
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
830 etched = True;
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
831 break;
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
832 case SHADOW_ETCHED_OUT:
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
833 top_gc = mw->menu.shadow_top_gc;
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
834 bottom_gc = mw->menu.shadow_bottom_gc;
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
835 etched = True;
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
836 break;
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
837 case SHADOW_IN:
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
838 top_gc = mw->menu.shadow_bottom_gc;
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
839 bottom_gc = mw->menu.shadow_top_gc;
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
840 break;
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
841 case SHADOW_OUT:
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
842 default:
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
843 top_gc = mw->menu.shadow_top_gc;
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
844 bottom_gc = mw->menu.shadow_bottom_gc;
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
845 break;
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
846 }
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
847
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
848 if (etched)
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
849 {
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
850 unsigned half = thickness/2;
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
851 shadow_rectangle_draw (
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
852 dpy,
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
853 window,
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
854 top_gc,
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
855 top_gc,
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
856 x, y,
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
857 width - half, height - half,
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
858 thickness - half
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
859 );
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
860 shadow_rectangle_draw (
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
861 dpy,
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
862 window,
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
863 bottom_gc,
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
864 bottom_gc,
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
865 x + half, y + half,
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
866 width - half , height - half,
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
867 half
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
868 );
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
869 }
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
870 else
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
871 {
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
872 shadow_rectangle_draw (
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
873 dpy,
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
874 window,
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
875 top_gc,
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
876 bottom_gc,
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
877 x, y,
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
878 width, height,
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
879 thickness
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
880 );
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
881 }
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
882 }
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
883
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
884 static void
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
885 arrow_decoration_draw (
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
886 XlwMenuWidget mw,
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
887 Window window,
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
888 int x, int y,
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
889 unsigned width,
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
890 Boolean raised
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
891 )
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
892 {
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
893 Display *dpy = XtDisplay (mw);
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
894 GC top_gc;
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
895 GC bottom_gc;
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
896 GC select_gc;
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
897 int thickness = mw->menu.shadow_thickness;
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
898 XPoint points [4];
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
899 int half_width;
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
900 int length = (int)((double)width * 0.87);
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
901 int thick_med = (int)((double)thickness * 1.73);
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
902
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
903 if (width & 0x1)
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
904 half_width = width/2 + 1;
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
905 else
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
906 half_width = width/2;
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
907
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
908 select_gc = mw->menu.background_gc;
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
909
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
910 if (raised)
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
911 {
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
912 top_gc = mw->menu.shadow_bottom_gc;
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
913 bottom_gc = mw->menu.shadow_top_gc;
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
914 }
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
915 else
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
916 {
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
917 top_gc = mw->menu.shadow_top_gc;
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
918 bottom_gc = mw->menu.shadow_bottom_gc;
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
919 }
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
920
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
921 /*
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
922 * Fill internal area, we do this first so that the borders
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
923 * have a nice sharp edge.
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
924 */
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
925 points [0].x = x + thickness;
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
926 points [0].y = y + thickness;
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
927 points [1].x = x + length - thickness;
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
928 points [1].y = y + half_width;
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
929 points [2].x = x + length - thickness;
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
930 points [2].y = y + half_width + thickness;
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
931 points [3].x = x + thickness;
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
932 points [3].y = y + width - thickness;
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
933
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
934 XFillPolygon (
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
935 dpy,
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
936 window,
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
937 select_gc,
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
938 points,
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
939 4,
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
940 Convex,
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
941 CoordModeOrigin
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
942 );
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
943
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
944 /* left border */
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
945 points [0].x = x;
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
946 points [0].y = y;
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
947 points [1].x = x + thickness;
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
948 points [1].y = y + thick_med;
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
949 points [2].x = x + thickness;
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
950 points [2].y = y + width - thick_med;
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
951 points [3].x = x;
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
952 points [3].y = y + width;
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
953
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
954 XFillPolygon (dpy, window, top_gc, points, 4, Convex, CoordModeOrigin);
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
955
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
956 /* top border */
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
957 points [0].x = x;
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
958 points [0].y = y + width;
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
959 points [1].x = x + length;
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
960 points [1].y = y + half_width;
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
961 points [2].x = x + length - (thickness + thickness);
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
962 points [2].y = y + half_width;
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
963 points [3].x = x + thickness;
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
964 points [3].y = y + width - thick_med;
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
965
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
966 XFillPolygon (dpy, window, bottom_gc, points, 4, Convex, CoordModeOrigin);
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
967
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
968 /* bottom shadow */
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
969 points [0].x = x;
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
970 points [0].y = y;
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
971 points [1].x = x + length;
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
972 points [1].y = y + half_width;
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
973 points [2].x = x + length - (thickness + thickness);
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
974 points [2].y = y + half_width;
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
975 points [3].x = x + thickness;
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
976 points [3].y = y + thick_med;
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
977
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
978 XFillPolygon (dpy, window, top_gc, points, 4, Convex, CoordModeOrigin);
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
979 }
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
980
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
981 static void
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
982 toggle_decoration_draw (
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
983 XlwMenuWidget mw,
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
984 Window window,
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
985 int x, int y,
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
986 unsigned width,
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
987 Boolean set
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
988 )
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
989 {
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
990 Display *dpy = XtDisplay (mw);
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
991 int thickness = mw->menu.shadow_thickness;
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
992 shadow_type type;
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
993 GC select_gc = mw->menu.select_gc;
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
994
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
995 if (set)
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
996 type = SHADOW_IN;
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
997 else
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
998 type = SHADOW_OUT;
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
999
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
1000 /*
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
1001 * Fill internal area.
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
1002 */
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
1003 if (set)
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
1004 XFillRectangle (
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
1005 dpy,
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
1006 window,
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
1007 select_gc,
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
1008 x + thickness,
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
1009 y + thickness,
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
1010 width - (2*thickness),
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
1011 width - (2*thickness)
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
1012 );
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
1013
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
1014 shadow_draw(mw, window, x, y, width, width, type);
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
1015 }
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
1016
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
1017 static void
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
1018 radio_decoration_draw (
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
1019 XlwMenuWidget mw,
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
1020 Window window,
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
1021 int x, int y,
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
1022 unsigned width,
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
1023 Boolean enabled
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
1024 )
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
1025 {
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
1026 Display *dpy = XtDisplay (mw);
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
1027 GC top_gc;
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
1028 GC bottom_gc;
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
1029 GC select_gc = mw->menu.select_gc;
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
1030 int thickness = mw->menu.shadow_thickness;
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
1031 XPoint points[6];
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
1032 int half_width;
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
1033 #if 0
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
1034 int npoints;
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
1035 #endif /* 0 */
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
1036
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
1037 if (width & 0x1)
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
1038 width++;
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
1039
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
1040 half_width = width/2;
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
1041
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
1042 if (enabled)
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
1043 {
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
1044 top_gc = mw->menu.shadow_bottom_gc;
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
1045 bottom_gc = mw->menu.shadow_top_gc;
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
1046 }
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
1047 else
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
1048 {
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
1049 top_gc = mw->menu.shadow_top_gc;
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
1050 bottom_gc = mw->menu.shadow_bottom_gc;
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
1051 }
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
1052
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
1053 #if 1
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
1054 /*
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
1055 * Draw the bottom first, just incase the regions overlap.
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
1056 * The top should cast the longer shadow.
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
1057 */
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
1058 points [0].x = x; /* left corner */
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
1059 points [0].y = y + half_width;
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
1060 points [1].x = x + half_width; /* bottom corner */
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
1061 points [1].y = y + width;
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
1062 points [2].x = x + half_width; /* bottom inside corner */
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
1063 points [2].y = y + width - thickness;
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
1064 points [3].x = x + thickness; /* left inside corner */
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
1065 points [3].y = y + half_width;
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
1066
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
1067 XFillPolygon (dpy, window, bottom_gc, points, 4, Convex, CoordModeOrigin);
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
1068
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
1069 points [0].x = x + half_width; /* bottom corner */
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
1070 points [0].y = y + width;
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
1071 points [1].x = x + width; /* right corner */
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
1072 points [1].y = y + half_width;
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
1073 points [2].x = x + width - thickness; /* right inside corner */
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
1074 points [2].y = y + half_width;
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
1075 points [3].x = x + half_width; /* bottom inside corner */
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
1076 points [3].y = y + width - thickness;
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
1077
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
1078 XFillPolygon (dpy, window, bottom_gc, points, 4, Convex, CoordModeOrigin);
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
1079
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
1080 points [0].x = x; /* left corner */
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
1081 points [0].y = y + half_width;
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
1082 points [1].x = x + half_width; /* top corner */
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
1083 points [1].y = y;
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
1084 points [2].x = x + half_width; /* top inside corner */
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
1085 points [2].y = y + thickness;
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
1086 points [3].x = x + thickness; /* left inside corner */
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
1087 points [3].y = y + half_width;
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
1088
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
1089 XFillPolygon (dpy, window, top_gc, points, 4, Convex, CoordModeOrigin);
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
1090
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
1091 points [0].x = x + half_width; /* top corner */
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
1092 points [0].y = y;
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
1093 points [1].x = x + width; /* right corner */
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
1094 points [1].y = y + half_width;
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
1095 points [2].x = x + width - thickness; /* right inside corner */
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
1096 points [2].y = y + half_width;
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
1097 points [3].x = x + half_width; /* top inside corner */
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
1098 points [3].y = y + thickness;
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
1099
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
1100 XFillPolygon (dpy, window, top_gc, points, 4, Convex, CoordModeOrigin);
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
1101 #else
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
1102 /*
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
1103 * Draw the bottom first, just incase the regions overlap.
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
1104 * The top should cast the longer shadow.
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
1105 */
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
1106 npoints = 0;
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
1107 points [npoints].x = x; /* left corner */
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
1108 points [npoints++].y = y + half_width;
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
1109 points [npoints].x = x + half_width; /* bottom corner */
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
1110 points [npoints++].y = y + width;
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
1111 points [npoints].x = x + width; /* right corner */
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
1112 points [npoints++].y = y + half_width;
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
1113 points [npoints].x = x + width - thickness; /* right inside corner */
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
1114 points [npoints++].y = y + half_width;
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
1115 points [npoints].x = x + half_width; /* bottom inside corner */
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
1116 points [npoints++].y = y + width - thickness;
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
1117 points [npoints].x = x + thickness; /* left inside corner */
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
1118 points [npoints++].y = y + half_width;
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
1119
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
1120 XFillPolygon (dpy, window, bottom_gc,
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
1121 points, npoints, Nonconvex, CoordModeOrigin);
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
1122
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
1123 npoints = 0;
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
1124
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
1125 points [npoints].x = x; /* left corner */
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
1126 points [npoints++].y = y + half_width;
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
1127 points [npoints].x = x + half_width; /* top corner */
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
1128 points [npoints++].y = y;
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
1129 points [npoints].x = x + width; /* right corner */
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
1130 points [npoints++].y = y + half_width;
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
1131 points [npoints].x = x + width - thickness; /* right inside corner */
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
1132 points [npoints++].y = y + half_width;
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
1133 points [npoints].x = x + half_width; /* top inside corner */
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
1134 points [npoints++].y = y + thickness;
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
1135 points [npoints].x = x + thickness; /* left inside corner */
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
1136 points [npoints++].y = y + half_width;
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
1137
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
1138 XFillPolygon (dpy, window, top_gc, points, npoints, Nonconvex,
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
1139 CoordModeOrigin);
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
1140 #endif
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
1141
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
1142
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
1143 /*
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
1144 * Fill internal area.
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
1145 */
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
1146 if (enabled)
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
1147 {
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
1148 points [0].x = x + thickness;
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
1149 points [0].y = y + half_width;
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
1150 points [1].x = x + half_width;
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
1151 points [1].y = y + thickness;
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
1152 points [2].x = x + width - thickness;
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
1153 points [2].y = y + half_width;
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
1154 points [3].x = x + half_width;
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
1155 points [3].y = y + width - thickness;
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
1156 XFillPolygon (dpy,
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
1157 window,
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
1158 select_gc,
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
1159 points,
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
1160 4,
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
1161 Convex,
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
1162 CoordModeOrigin
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
1163 );
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
1164 }
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
1165 }
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
1166
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
1167 static void
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
1168 separator_decoration_draw (
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
1169 XlwMenuWidget mw,
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
1170 Window window,
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
1171 int x, int y,
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
1172 unsigned width,
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
1173 Boolean vertical,
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
1174 shadow_type type
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
1175 )
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
1176 {
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
1177 Display *dpy = XtDisplay (mw);
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
1178 GC top_gc;
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
1179 GC bottom_gc;
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
1180 unsigned offset = 0;
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
1181 unsigned num_separators = 1;
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
1182 unsigned top_line_thickness = 0;
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
1183 unsigned bottom_line_thickness = 0;
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
1184 Boolean dashed = False;
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
1185 int i;
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
1186
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
1187 switch (type)
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
1188 {
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
1189 case SHADOW_NO_LINE: /* nothing to do */
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
1190 return;
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
1191 case SHADOW_DOUBLE_LINE:
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
1192 num_separators = 2;
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
1193 case SHADOW_SINGLE_LINE:
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
1194 top_gc = bottom_gc = mw->menu.foreground_gc;
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
1195 top_line_thickness = 1;
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
1196 break;
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
1197 case SHADOW_DOUBLE_DASHED_LINE:
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
1198 num_separators = 2;
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
1199 case SHADOW_SINGLE_DASHED_LINE:
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
1200 top_gc = bottom_gc = mw->menu.foreground_gc;
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
1201 top_line_thickness = 1;
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
1202 dashed = True;
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
1203 break;
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
1204 case SHADOW_DOUBLE_ETCHED_OUT_DASH:
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
1205 num_separators = 2;
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
1206 case SHADOW_ETCHED_OUT_DASH:
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
1207 top_gc = mw->menu.shadow_top_gc;
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
1208 bottom_gc = mw->menu.shadow_bottom_gc;
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
1209 top_line_thickness = mw->menu.shadow_thickness/2;
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
1210 bottom_line_thickness = mw->menu.shadow_thickness - top_line_thickness;
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
1211 dashed = True;
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
1212 break;
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
1213 case SHADOW_DOUBLE_ETCHED_IN_DASH:
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
1214 num_separators = 2;
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
1215 case SHADOW_ETCHED_IN_DASH:
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
1216 top_gc = mw->menu.shadow_bottom_gc;
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
1217 bottom_gc = mw->menu.shadow_top_gc;
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
1218 top_line_thickness = mw->menu.shadow_thickness/2;
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
1219 bottom_line_thickness = mw->menu.shadow_thickness - top_line_thickness;
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
1220 dashed = True;
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
1221 break;
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
1222 case SHADOW_DOUBLE_ETCHED_OUT:
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
1223 num_separators = 2;
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
1224 case SHADOW_ETCHED_OUT:
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
1225 top_gc = mw->menu.shadow_top_gc;
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
1226 bottom_gc = mw->menu.shadow_bottom_gc;
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
1227 top_line_thickness = mw->menu.shadow_thickness/2;
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
1228 bottom_line_thickness = mw->menu.shadow_thickness - top_line_thickness;
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
1229 break;
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
1230 case SHADOW_DOUBLE_ETCHED_IN:
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
1231 num_separators = 2;
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
1232 case SHADOW_ETCHED_IN:
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
1233 default:
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
1234 top_gc = mw->menu.shadow_bottom_gc;
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
1235 bottom_gc = mw->menu.shadow_top_gc;
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
1236 top_line_thickness = mw->menu.shadow_thickness/2;
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
1237 bottom_line_thickness = mw->menu.shadow_thickness - top_line_thickness;
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
1238 break;
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
1239 }
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
1240
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
1241 if (dashed)
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
1242 {
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
1243 XGCValues values;
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
1244 values.line_style = LineOnOffDash;
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
1245 if (top_line_thickness > 0)
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
1246 XChangeGC (dpy, top_gc, GCLineStyle, &values);
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
1247 if (bottom_line_thickness > 0 && bottom_gc != top_gc)
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
1248 XChangeGC (dpy, bottom_gc, GCLineStyle, &values);
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
1249 }
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
1250
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
1251 while (num_separators--)
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
1252 {
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
1253 for (i = 0; i < top_line_thickness; i++)
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
1254 XDrawLine (dpy, window, top_gc, x, y + i, x + width, y + i);
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
1255
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
1256 for (i = 0; i < bottom_line_thickness; i++)
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
1257 XDrawLine (
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
1258 dpy, window, bottom_gc,
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
1259 x, y + top_line_thickness + offset + i,
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
1260 x + width, y + top_line_thickness + offset + i
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
1261 );
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
1262 y += (top_line_thickness + offset + bottom_line_thickness + 1);
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
1263 }
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
1264
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
1265 if (dashed)
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
1266 {
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
1267 XGCValues values;
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
1268 values.line_style = LineSolid;
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
1269 if (top_line_thickness > 0)
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
1270 XChangeGC (dpy, top_gc, GCLineStyle, &values);
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
1271 if (bottom_line_thickness > 0 && bottom_gc != top_gc)
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
1272 XChangeGC (dpy, bottom_gc, GCLineStyle, &values);
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
1273 }
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
1274 }
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
1275
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
1276 #define SLOPPY_TYPES 0 /* 0=off, 1=error check, 2=easy to please */
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
1277 #if SLOPPY_TYPES
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
1278 #if SLOPPY_TYPES < 2
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
1279
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
1280 static char *wv_types[] =
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
1281 {
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
1282 "UNSPECIFIED",
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
1283 "BUTTON",
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
1284 "TOGGLE",
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
1285 "RADIO",
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
1286 "TEXT",
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
1287 "SEPARATOR",
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
1288 "CASCADE",
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
1289 "PUSHRIGHT",
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
1290 "INCREMENTAL"
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
1291 };
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
1292
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
1293 static void
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
1294 print_widget_value (widget_value *wv, int just_one, int depth)
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
1295 {
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
1296 char d [200];
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
1297 int i;
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
1298 for (i = 0; i < depth; i++) d[i] = ' ';
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
1299 d[depth]=0;
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
1300 if (!wv)
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
1301 {
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
1302 printf ("%s(null widget value pointer)\n", d);
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
1303 return;
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
1304 }
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
1305 printf ("%stype: %s\n", d, wv_types [wv->type]);
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
1306 #if 0
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
1307 printf ("%sname: %s\n", d, (wv->name ? wv->name : "(null)"));
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
1308 #else
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
1309 if (wv->name) printf ("%sname: %s\n", d, wv->name);
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
1310 #endif
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
1311 if (wv->value) printf ("%svalue: %s\n", d, wv->value);
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
1312 if (wv->key) printf ("%skey: %s\n", d, wv->key);
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
1313 printf ("%senabled: %d\n", d, wv->enabled);
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
1314 if (wv->contents)
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
1315 {
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
1316 printf ("\n%scontents: \n", d);
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
1317 print_widget_value (wv->contents, 0, depth + 5);
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
1318 }
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
1319 if (!just_one && wv->next)
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
1320 {
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
1321 printf ("\n");
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
1322 print_widget_value (wv->next, 0, depth);
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
1323 }
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
1324 }
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
1325 #endif
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
1326
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
1327 static Boolean
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
1328 all_dashes_p (char *s)
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
1329 {
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
1330 char *p;
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
1331 if (!s || s[0] == '\0')
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
1332 return False;
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
1333 for (p = s; *p == '-'; p++);
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
1334
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
1335 if (*p == '!' || *p == '\0')
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
1336 return True;
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
1337 return False;
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
1338 }
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
1339 #endif
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
1340
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
1341 static widget_value_type
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
1342 menu_item_type (widget_value *val)
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
1343 {
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
1344 if (val->type != UNSPECIFIED_TYPE)
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
1345 return val->type;
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
1346 else
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
1347 {
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
1348 #if SLOPPY_TYPES
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
1349 if (all_dashes_p(val->name))
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
1350 return SEPARATOR_TYPE;
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
1351 else if (val->name && val->name[0] == '\0') /* push right */
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
1352 return PUSHRIGHT_TYPE;
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
1353 else if (val->contents) /* cascade */
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
1354 return CASCADE_TYPE;
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
1355 else if (val->call_data) /* push button */
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
1356 return BUTTON_TYPE;
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
1357 else
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
1358 return TEXT_TYPE;
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
1359 #else
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
1360 abort();
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
1361 #endif
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
1362 }
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
1363 }
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
1364
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
1365 static void
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
1366 label_button_size (
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
1367 XlwMenuWidget mw,
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
1368 widget_value *val,
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
1369 Boolean in_menubar,
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
1370 unsigned *toggle_width,
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
1371 unsigned *label_width,
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
1372 unsigned *bindings_width,
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
1373 unsigned *height
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
1374 )
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
1375 {
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
1376 *height = (mw->menu.font_ascent + mw->menu.font_descent +
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
1377 2 * mw->menu.vertical_margin +
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
1378 2 * mw->menu.shadow_thickness);
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
1379 /* no left column decoration */
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
1380 *toggle_width = mw->menu.horizontal_margin + mw->menu.shadow_thickness;;
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
1381
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
1382 *label_width = string_width (mw, resource_widget_value (mw, val));
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
1383 *bindings_width = mw->menu.horizontal_margin + mw->menu.shadow_thickness;
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
1384 }
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
1385
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
1386 static void
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
1387 label_button_draw (
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
1388 XlwMenuWidget mw,
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
1389 widget_value *val,
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
1390 Boolean in_menubar,
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
1391 Boolean highlighted,
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
1392 Window window,
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
1393 int x, int y,
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
1394 unsigned width,
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
1395 unsigned height,
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
1396 unsigned label_offset,
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
1397 unsigned binding_tab
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
1398 )
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
1399 {
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
1400 int y_offset = mw->menu.shadow_thickness + mw->menu.vertical_margin;
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
1401
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
1402 if (!label_offset)
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
1403 label_offset = mw->menu.shadow_thickness + mw->menu.horizontal_margin;
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
1404
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
1405 /*
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
1406 * Draw the label string.
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
1407 */
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
1408 string_draw (
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
1409 mw,
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
1410 window,
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
1411 x + label_offset, y + y_offset,
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
1412 mw->menu.foreground_gc,
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
1413 resource_widget_value (mw, val)
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
1414 );
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
1415 }
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
1416
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
1417 static void
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
1418 push_button_size (
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
1419 XlwMenuWidget mw,
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
1420 widget_value *val,
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
1421 Boolean in_menubar,
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
1422 unsigned *toggle_width,
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
1423 unsigned *label_width,
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
1424 unsigned *bindings_width,
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
1425 unsigned *height
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
1426 )
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
1427 {
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
1428 /* inherit */
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
1429 label_button_size (
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
1430 mw, val, in_menubar,
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
1431 toggle_width, label_width, bindings_width,
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
1432 height
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
1433 );
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
1434
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
1435 /* key bindings to display? */
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
1436 if (!in_menubar && val->key)
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
1437 {
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
1438 int w;
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
1439 #ifdef NEED_MOTIF
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
1440 XmString key = XmStringCreateLtoR (val->key, XmSTRING_DEFAULT_CHARSET);
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
1441 w = string_width(mw, key);
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
1442 XmStringFree (key);
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
1443 #else
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
1444 char *key = val->key;
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
1445 w = string_width (mw, key);
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
1446 #endif
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
1447 *bindings_width += w + mw->menu.column_spacing;
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
1448 }
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
1449 }
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
1450
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
1451 static void
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
1452 push_button_draw (
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
1453 XlwMenuWidget mw,
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
1454 widget_value *val,
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
1455 Boolean in_menubar,
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
1456 Boolean highlighted,
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
1457 Window window,
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
1458 int x, int y,
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
1459 unsigned width, unsigned height,
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
1460 unsigned label_offset,
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
1461 unsigned binding_offset
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
1462 )
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
1463 {
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
1464 int y_offset = mw->menu.shadow_thickness + mw->menu.vertical_margin;
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
1465 GC gc;
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
1466 shadow_type type;
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
1467 Boolean menu_pb = in_menubar && (menu_item_type (val) == BUTTON_TYPE);
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
1468
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
1469 /*
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
1470 * Draw the label string.
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
1471 */
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
1472 if (!label_offset)
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
1473 label_offset = mw->menu.shadow_thickness + mw->menu.horizontal_margin;
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
1474
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
1475 if (menu_pb)
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
1476 {
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
1477 if (val->enabled)
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
1478 gc = mw->menu.button_gc;
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
1479 else
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
1480 gc = mw->menu.inactive_button_gc;
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
1481 }
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
1482 else
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
1483 {
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
1484 if (val->enabled)
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
1485 gc = mw->menu.foreground_gc;
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
1486 else
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
1487 gc = mw->menu.inactive_gc;
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
1488 }
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
1489
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
1490 string_draw (
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
1491 mw,
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
1492 window,
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
1493 x + label_offset, y + y_offset,
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
1494 gc,
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
1495 resource_widget_value(mw, val)
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
1496 );
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
1497
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
1498 /*
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
1499 * Draw the keybindings
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
1500 */
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
1501 if (val->key)
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
1502 {
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
1503 if (!binding_offset)
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
1504 {
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
1505 unsigned s_width = string_width (mw, resource_widget_value(mw, val));
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
1506 binding_offset = label_offset + s_width + mw->menu.shadow_thickness;
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
1507 }
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
1508 binding_draw (mw, window,
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
1509 x + binding_offset + mw->menu.column_spacing,
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
1510 y + y_offset, gc, val->key);
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
1511 }
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
1512
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
1513 /*
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
1514 * Draw the shadow
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
1515 */
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
1516 if (menu_pb)
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
1517 {
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
1518 if (highlighted)
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
1519 type = SHADOW_OUT;
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
1520 else
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
1521 type = (val->selected ? SHADOW_ETCHED_OUT : SHADOW_ETCHED_IN);
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
1522 }
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
1523 else
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
1524 {
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
1525 if (highlighted)
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
1526 type = SHADOW_OUT;
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
1527 else
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
1528 type = SHADOW_BACKGROUND;
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
1529 }
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
1530
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
1531 shadow_draw (mw, window, x, y, width, height, type);
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
1532 }
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
1533
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
1534 static unsigned int
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
1535 arrow_decoration_height (XlwMenuWidget mw)
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
1536 {
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
1537 unsigned int result =
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
1538 (mw->menu.font_ascent + mw->menu.font_descent) / (unsigned int)2;
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
1539
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
1540 result += 2 * mw->menu.shadow_thickness;
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
1541
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
1542 if (result > (mw->menu.font_ascent + mw->menu.font_descent))
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
1543 result = mw->menu.font_ascent + mw->menu.font_descent;
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
1544
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
1545 return result;
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
1546 }
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
1547
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
1548 static void
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
1549 cascade_button_size (
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
1550 XlwMenuWidget mw,
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
1551 widget_value *val,
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
1552 Boolean in_menubar,
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
1553 unsigned *toggle_width,
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
1554 unsigned *label_width,
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
1555 unsigned *arrow_width,
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
1556 unsigned *height
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
1557 )
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
1558 {
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
1559 /* inherit */
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
1560 label_button_size (
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
1561 mw, val, in_menubar,
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
1562 toggle_width, label_width, arrow_width,
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
1563 height
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
1564 );
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
1565 /* we have a pull aside arrow */
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
1566 if (!in_menubar)
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
1567 {
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
1568 *arrow_width += arrow_decoration_height(mw) + mw->menu.column_spacing;
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
1569 }
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
1570 }
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
1571
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
1572 static void
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
1573 cascade_button_draw (
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
1574 XlwMenuWidget mw,
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
1575 widget_value *val,
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
1576 Boolean in_menubar,
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
1577 Boolean highlighted,
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
1578 Window window,
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
1579 int x, int y,
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
1580 unsigned width, unsigned height,
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
1581 unsigned label_offset,
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
1582 unsigned binding_offset
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
1583 )
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
1584 {
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
1585 shadow_type type;
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
1586
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
1587 /*
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
1588 * Draw the label string.
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
1589 */
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
1590 label_button_draw (mw, val, in_menubar, highlighted,
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
1591 window, x, y, width, height, label_offset,
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
1592 binding_offset);
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
1593
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
1594 /*
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
1595 * Draw the pull aside arrow
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
1596 */
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
1597 if (!in_menubar && val->contents)
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
1598 {
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
1599 int y_offset;
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
1600 unsigned arrow_height = arrow_decoration_height (mw);
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
1601
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
1602 y_offset = mw->menu.shadow_thickness + mw->menu.vertical_margin +
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
1603 (mw->menu.font_ascent+mw->menu.font_descent - arrow_height)/2;
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
1604
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
1605 if (!binding_offset)
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
1606 {
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
1607 unsigned s_width = string_width(mw, resource_widget_value (mw, val));
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
1608
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
1609 if (!label_offset)
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
1610 label_offset = mw->menu.shadow_thickness +
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
1611 mw->menu.horizontal_margin;
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
1612
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
1613 binding_offset = label_offset + s_width + mw->menu.shadow_thickness;
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
1614 }
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
1615
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
1616 arrow_decoration_draw (
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
1617 mw,
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
1618 window,
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
1619 x + binding_offset + mw->menu.column_spacing,
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
1620 y + y_offset,
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
1621 arrow_height,
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
1622 highlighted
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
1623 );
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
1624 }
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
1625
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
1626 /*
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
1627 * Draw the shadow
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
1628 */
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
1629 if (highlighted)
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
1630 type = SHADOW_OUT;
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
1631 else
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
1632 type = SHADOW_BACKGROUND;
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
1633
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
1634 shadow_draw(mw, window, x, y, width, height, type);
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
1635 }
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
1636
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
1637 static unsigned
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
1638 toggle_decoration_height(XlwMenuWidget mw)
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
1639 {
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
1640 unsigned rv;
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
1641 if (mw->menu.indicator_size > 0)
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
1642 rv = mw->menu.indicator_size;
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
1643 else
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
1644 rv = mw->menu.font_ascent;
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
1645
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
1646 if (rv > (mw->menu.font_ascent+mw->menu.font_descent))
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
1647 rv = mw->menu.font_ascent+mw->menu.font_descent;
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
1648
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
1649 return rv;
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
1650 }
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
1651
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
1652 static void
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
1653 toggle_button_size (
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
1654 XlwMenuWidget mw,
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
1655 widget_value *val,
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
1656 Boolean in_menubar,
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
1657 unsigned *toggle_width,
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
1658 unsigned *label_width,
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
1659 unsigned *bindings_width,
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
1660 unsigned *height
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
1661 )
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
1662 {
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
1663 /* inherit */
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
1664 push_button_size (
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
1665 mw, val, in_menubar,
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
1666 toggle_width, label_width, bindings_width,
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
1667 height
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
1668 );
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
1669 /* we have a toggle */
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
1670 *toggle_width += toggle_decoration_height(mw) + mw->menu.column_spacing;
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
1671 }
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
1672
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
1673 static void
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
1674 toggle_button_draw (
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
1675 XlwMenuWidget mw,
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
1676 widget_value *val,
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
1677 Boolean in_menubar,
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
1678 Boolean highlighted,
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
1679 Window window,
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
1680 int x, int y,
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
1681 unsigned width, unsigned height,
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
1682 unsigned label_tab,
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
1683 unsigned binding_tab
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
1684 )
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
1685 {
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
1686 int x_offset;
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
1687 int y_offset;
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
1688 unsigned t_height = toggle_decoration_height(mw);
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
1689
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
1690 /*
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
1691 * Draw a toggle.
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
1692 */
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
1693 x_offset = mw->menu.shadow_thickness + mw->menu.horizontal_margin;
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
1694 y_offset = mw->menu.shadow_thickness + mw->menu.vertical_margin;
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
1695 y_offset += (mw->menu.font_ascent + mw->menu.font_descent - t_height)/2;
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
1696
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
1697 toggle_decoration_draw (mw, window, x + x_offset, y + y_offset,
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
1698 t_height, val->selected);
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
1699
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
1700 /*
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
1701 * Draw the pushbutton parts.
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
1702 */
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
1703 push_button_draw (mw, val, in_menubar, highlighted, window, x, y, width,
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
1704 height, label_tab, binding_tab);
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
1705 }
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
1706
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
1707 static unsigned
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
1708 radio_decoration_height(XlwMenuWidget mw)
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
1709 {
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
1710 return toggle_decoration_height(mw);
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
1711 }
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
1712
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
1713 static void
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
1714 radio_button_draw (
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
1715 XlwMenuWidget mw,
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
1716 widget_value *val,
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
1717 Boolean in_menubar,
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
1718 Boolean highlighted,
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
1719 Window window,
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
1720 int x, int y,
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
1721 unsigned width, unsigned height,
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
1722 unsigned label_tab,
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
1723 unsigned binding_tab
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
1724 )
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
1725 {
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
1726 int x_offset;
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
1727 int y_offset;
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
1728 unsigned r_height = radio_decoration_height(mw);
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
1729
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
1730 /*
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
1731 * Draw a toggle.
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
1732 */
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
1733 x_offset = mw->menu.shadow_thickness + mw->menu.horizontal_margin;
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
1734 y_offset = mw->menu.shadow_thickness + mw->menu.vertical_margin;
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
1735 y_offset += (mw->menu.font_ascent + mw->menu.font_descent - r_height)/2;
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
1736
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
1737 radio_decoration_draw (mw, window, x + x_offset, y + y_offset, r_height,
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
1738 val->selected);
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
1739
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
1740 /*
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
1741 * Draw the pushbutton parts.
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
1742 */
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
1743 push_button_draw (mw, val, in_menubar, highlighted, window, x, y, width,
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
1744 height, label_tab, binding_tab);
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
1745 }
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
1746
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
1747 static struct _shadow_names
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
1748 {
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
1749 CONST char * name;
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
1750 shadow_type type;
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
1751 } shadow_names[] =
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
1752 {
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
1753 /* Motif */
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
1754 { "singleLine", SHADOW_SINGLE_LINE },
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
1755 { "doubleLine", SHADOW_DOUBLE_LINE },
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
1756 { "singleDashedLine", SHADOW_SINGLE_DASHED_LINE },
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
1757 { "doubleDashedLine", SHADOW_DOUBLE_DASHED_LINE },
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
1758 { "noLine", SHADOW_NO_LINE },
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
1759 { "shadowEtchedIn", SHADOW_ETCHED_IN },
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
1760 { "shadowEtchedOut", SHADOW_ETCHED_OUT },
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
1761 { "shadowEtchedInDash", SHADOW_ETCHED_IN_DASH },
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
1762 { "shadowEtchedOutDash", SHADOW_ETCHED_OUT_DASH },
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
1763 /* non-Motif */
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
1764 { "shadowDoubleEtchedIn", SHADOW_DOUBLE_ETCHED_IN },
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
1765 { "shadowDoubleEtchedOut", SHADOW_DOUBLE_ETCHED_OUT },
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
1766 { "shadowDoubleEtchedInDash", SHADOW_DOUBLE_ETCHED_IN_DASH },
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
1767 { "shadowDoubleEtchedOutDash", SHADOW_DOUBLE_ETCHED_OUT_DASH }
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
1768 };
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
1769
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
1770 static shadow_type
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
1771 separator_type (char *name)
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
1772 {
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
1773 int i;
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
1774
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
1775 if (name)
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
1776 {
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
1777 for (i = 0; i < XtNumber(shadow_names); i++ )
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
1778 {
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
1779 if (strcmp (name, shadow_names[i].name) == 0)
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
1780 return shadow_names[i].type;
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
1781 }
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
1782 }
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
1783 return SHADOW_BACKGROUND;
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
1784 }
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
1785
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
1786 static unsigned
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
1787 separator_decoration_height (XlwMenuWidget mw, widget_value *val)
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
1788 {
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
1789
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
1790 switch (separator_type(val->value))
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
1791 {
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
1792 case SHADOW_NO_LINE:
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
1793 case SHADOW_SINGLE_LINE:
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
1794 case SHADOW_SINGLE_DASHED_LINE:
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
1795 return 1;
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
1796 case SHADOW_DOUBLE_LINE:
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
1797 case SHADOW_DOUBLE_DASHED_LINE:
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
1798 return 3;
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
1799 case SHADOW_DOUBLE_ETCHED_OUT:
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
1800 case SHADOW_DOUBLE_ETCHED_IN:
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
1801 case SHADOW_DOUBLE_ETCHED_OUT_DASH:
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
1802 case SHADOW_DOUBLE_ETCHED_IN_DASH:
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
1803 return (1 + 2 * mw->menu.shadow_thickness);
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
1804 case SHADOW_ETCHED_OUT:
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
1805 case SHADOW_ETCHED_IN:
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
1806 default:
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
1807 return mw->menu.shadow_thickness;
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
1808 }
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
1809 }
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
1810
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
1811 static void
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
1812 separator_size (XlwMenuWidget mw,
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
1813 widget_value *val,
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
1814 Boolean in_menubar,
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
1815 unsigned *toggle_width,
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
1816 unsigned *label_width,
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
1817 unsigned *rest_width,
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
1818 unsigned *height
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
1819 )
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
1820 {
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
1821 *height = separator_decoration_height (mw, val);
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
1822 *label_width = 1;
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
1823 *toggle_width = *rest_width = 0;
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
1824 }
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
1825
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
1826 static void
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
1827 separator_draw (XlwMenuWidget mw,
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
1828 widget_value *val,
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
1829 Boolean in_menubar,
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
1830 Boolean highlighted,
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
1831 Window window,
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
1832 int x, int y,
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
1833 unsigned width, unsigned height,
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
1834 unsigned label_tab,
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
1835 unsigned binding_tab
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
1836 )
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
1837 {
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
1838 unsigned sep_width;
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
1839
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
1840 if (in_menubar)
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
1841 sep_width = height;
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
1842 else
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
1843 sep_width = width;
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
1844
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
1845 separator_decoration_draw (mw,
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
1846 window,
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
1847 x,
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
1848 y,
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
1849 sep_width,
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
1850 in_menubar,
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
1851 separator_type(val->value)
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
1852 );
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
1853 }
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
1854
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
1855 static void
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
1856 pushright_size (XlwMenuWidget mw,
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
1857 widget_value *val,
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
1858 Boolean in_menubar,
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
1859 unsigned *toggle_width,
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
1860 unsigned *label_width,
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
1861 unsigned *rest_width,
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
1862 unsigned *height
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
1863 )
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
1864 {
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
1865 *height = *label_width = *toggle_width = *rest_width = 0;
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
1866 }
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
1867
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
1868 static void
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
1869 size_menu_item (XlwMenuWidget mw,
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
1870 widget_value *val,
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
1871 int horizontal,
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
1872 unsigned *toggle_width,
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
1873 unsigned *label_width,
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
1874 unsigned *rest_width,
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
1875 unsigned *height
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
1876 )
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
1877 {
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
1878
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
1879 void (*function_ptr) (
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
1880 XlwMenuWidget _mw,
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
1881 widget_value *_val,
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
1882 Boolean _in_menubar,
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
1883 unsigned *_toggle_width,
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
1884 unsigned *_label_width,
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
1885 unsigned *_rest_width,
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
1886 unsigned *_height
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
1887 );
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
1888 switch (menu_item_type (val))
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
1889 {
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
1890 case TOGGLE_TYPE:
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
1891 case RADIO_TYPE:
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
1892 function_ptr = toggle_button_size;
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
1893 break;
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
1894 case SEPARATOR_TYPE:
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
1895 function_ptr = separator_size;
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
1896 break;
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
1897 case INCREMENTAL_TYPE:
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
1898 case CASCADE_TYPE:
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
1899 function_ptr = cascade_button_size;
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
1900 break;
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
1901 case BUTTON_TYPE:
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
1902 function_ptr = push_button_size;
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
1903 break;
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
1904 case PUSHRIGHT_TYPE:
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
1905 function_ptr = pushright_size;
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
1906 break;
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
1907 case TEXT_TYPE:
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
1908 default:
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
1909 function_ptr = label_button_size;
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
1910 break;
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
1911 }
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
1912
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
1913 (*function_ptr) (
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
1914 mw,
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
1915 val,
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
1916 horizontal,
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
1917 toggle_width,
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
1918 label_width,
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
1919 rest_width,
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
1920 height
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
1921 );
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
1922 }
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
1923
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
1924 static void
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
1925 display_menu_item (
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
1926 XlwMenuWidget mw,
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
1927 widget_value *val,
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
1928 window_state *ws,
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
1929 XPoint *where,
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
1930 Boolean highlighted,
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
1931 Boolean horizontal,
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
1932 Boolean just_compute
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
1933 )
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
1934 {
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
1935
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
1936 int x = where->x /* + mw->menu.shadow_thickness */ ;
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
1937 int y = where->y /* + mw->menu.shadow_thickness */ ;
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
1938 unsigned toggle_width;
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
1939 unsigned label_width;
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
1940 unsigned binding_width;
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
1941 unsigned width;
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
1942 unsigned height;
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
1943 unsigned label_tab;
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
1944 unsigned binding_tab;
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
1945 void (*function_ptr) (
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
1946 XlwMenuWidget _mw,
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
1947 widget_value *_val,
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
1948 Boolean _in_menubar,
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
1949 Boolean _highlighted,
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
1950 Window _window,
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
1951 int _x, int _y,
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
1952 unsigned _width, unsigned _height,
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
1953 unsigned _label_tab,
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
1954 unsigned _binding_tab
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
1955 );
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
1956
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
1957 size_menu_item (
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
1958 mw, val, horizontal,
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
1959 &toggle_width, &label_width, &binding_width, &height
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
1960 );
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
1961
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
1962 if (horizontal)
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
1963 {
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
1964 width = toggle_width + label_width + binding_width;
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
1965 height = ws->height - 2 * mw->menu.shadow_thickness;
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
1966 }
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
1967 else
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
1968 {
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
1969 width = ws->width - 2 * mw->menu.shadow_thickness;
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
1970 toggle_width = ws->toggle_width;
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
1971 label_width = ws->label_width;
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
1972 }
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
1973
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
1974 where->x += width;
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
1975 where->y += height;
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
1976
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
1977 if (just_compute)
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
1978 return;
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
1979
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
1980 label_tab = toggle_width;
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
1981 binding_tab = toggle_width + label_width;
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
1982
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
1983 switch (menu_item_type (val))
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
1984 {
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
1985 case TOGGLE_TYPE:
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
1986 function_ptr = toggle_button_draw;
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
1987 break;
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
1988 case RADIO_TYPE:
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
1989 function_ptr = radio_button_draw;
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
1990 break;
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
1991 case SEPARATOR_TYPE:
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
1992 function_ptr = separator_draw;
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
1993 break;
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
1994 case INCREMENTAL_TYPE:
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
1995 case CASCADE_TYPE:
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
1996 function_ptr = cascade_button_draw;
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
1997 break;
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
1998 case BUTTON_TYPE:
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
1999 function_ptr = push_button_draw;
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
2000 break;
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
2001 case TEXT_TYPE:
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
2002 function_ptr = label_button_draw;
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
2003 break;
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
2004 default: /* do no drawing */
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
2005 return;
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
2006 }
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
2007
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
2008 (*function_ptr) (
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
2009 mw,
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
2010 val,
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
2011 horizontal,
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
2012 highlighted,
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
2013 ws->window,
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
2014 x, y,
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
2015 width, height,
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
2016 label_tab,
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
2017 binding_tab
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
2018 );
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
2019 }
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
2020
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
2021 static void
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
2022 size_menu (XlwMenuWidget mw, int level)
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
2023 {
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
2024 unsigned toggle_width;
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
2025 unsigned label_width;
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
2026 unsigned rest_width;
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
2027 unsigned height;
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
2028 unsigned max_toggle_width = 0;
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
2029 unsigned max_label_width = 0;
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
2030 unsigned max_rest_width = 0;
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
2031 unsigned max_height = 0;
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
2032 int horizontal_p = mw->menu.horizontal && (level == 0);
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
2033 widget_value* val;
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
2034 window_state* ws;
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
2035
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
2036 if (level >= mw->menu.old_depth)
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
2037 abort ();
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
2038
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
2039 ws = &mw->menu.windows [level];
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
2040
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
2041 for (val = mw->menu.old_stack [level]->contents; val; val = val->next)
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
2042 {
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
2043 size_menu_item (
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
2044 mw,
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
2045 val,
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
2046 horizontal_p,
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
2047 &toggle_width,
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
2048 &label_width,
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
2049 &rest_width,
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
2050 &height
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
2051 );
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
2052 if (horizontal_p)
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
2053 {
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
2054 max_label_width += toggle_width + label_width + rest_width;
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
2055 if (height > max_height)
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
2056 max_height = height;
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
2057 }
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
2058 else
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
2059 {
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
2060 if (toggle_width > max_toggle_width)
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
2061 max_toggle_width = toggle_width;
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
2062 if (label_width > max_label_width)
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
2063 max_label_width = label_width;
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
2064 if (rest_width > max_rest_width)
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
2065 max_rest_width = rest_width;
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
2066 max_height += height;
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
2067 }
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
2068 }
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
2069
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
2070 ws->height = max_height;
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
2071 ws->width = max_label_width + max_rest_width + max_toggle_width;
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
2072 ws->toggle_width = max_toggle_width;
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
2073 ws->label_width = max_label_width;
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
2074
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
2075 ws->width += 2 * mw->menu.shadow_thickness;
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
2076 ws->height += 2 * mw->menu.shadow_thickness;
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
2077 }
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
2078
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
2079 static void
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
2080 display_menu (XlwMenuWidget mw, int level, Boolean just_compute_p,
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
2081 XPoint *highlighted_pos, XPoint *hit, widget_value **hit_return,
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
2082 widget_value *this, widget_value *that)
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
2083 {
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
2084 widget_value *val;
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
2085 widget_value *following_item;
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
2086 window_state *ws;
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
2087 XPoint where;
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
2088 int horizontal_p = mw->menu.horizontal && (level == 0);
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
2089 int highlighted_p;
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
2090 int just_compute_this_one_p;
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
2091
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
2092 if (level >= mw->menu.old_depth)
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
2093 abort ();
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
2094
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
2095 if (level < mw->menu.old_depth - 1)
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
2096 following_item = mw->menu.old_stack [level + 1];
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
2097 else
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
2098 following_item = NULL;
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
2099
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
2100 #if SLOPPY_TYPES == 1
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
2101 puts("===================================================================");
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
2102 print_widget_value (following_item, 1, 0);
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
2103 #endif
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
2104 if (following_item
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
2105 && following_item->type == CASCADE_TYPE
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
2106 && following_item->contents
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
2107 && following_item->contents->type == INCREMENTAL_TYPE)
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
2108 {
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
2109 /* okay, we're now doing a lisp callback to incrementally generate
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
2110 more of the menu. */
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
2111 XtCallCallbackList ((Widget)mw,
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
2112 mw->menu.open,
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
2113 (XtPointer)following_item->contents);
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
2114 #if SLOPPY_TYPES == 1
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
2115 puts("==== NEW ==== NEW ==== NEW ==== NEW ==== NEW ==== NEW ==== NEW ====");
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
2116 print_widget_value(following_item, 1, 0);
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
2117 #endif
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
2118 }
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
2119
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
2120 if (hit)
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
2121 *hit_return = NULL;
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
2122
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
2123 where.x = mw->menu.shadow_thickness;
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
2124 where.y = mw->menu.shadow_thickness;
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
2125
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
2126 ws = &mw->menu.windows [level];
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
2127 for (val = mw->menu.old_stack [level]->contents; val; val = val->next)
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
2128 {
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
2129 XPoint start;
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
2130
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
2131 highlighted_p = (val == following_item);
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
2132 /* If this is the partition (the dummy item which says that menus
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
2133 after this should be flushright) then figure out how big the
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
2134 following items are. This means we walk down the tail of the
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
2135 list twice, but that's no big deal - it's short.
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
2136 */
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
2137 if (horizontal_p && (menu_item_type (val) == PUSHRIGHT_TYPE))
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
2138 {
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
2139 widget_value *rest;
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
2140 XPoint flushright_size;
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
2141 int new_x;
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
2142 flushright_size.x = 0;
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
2143 flushright_size.y = 0;
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
2144 for (rest = val; rest; rest = rest->next)
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
2145 display_menu_item (mw, rest, ws, &flushright_size,
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
2146 highlighted_p, horizontal_p, True);
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
2147 new_x = ws->width - (flushright_size.x + mw->menu.shadow_thickness);
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
2148 if (new_x > where.x)
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
2149 where.x = new_x;
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
2150 /* We know what we need; don't draw this item. */
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
2151 continue;
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
2152 }
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
2153
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
2154 if (highlighted_p && highlighted_pos)
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
2155 {
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
2156 if (horizontal_p)
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
2157 highlighted_pos->x = where.x;
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
2158 else
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
2159 highlighted_pos->y = where.y;
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
2160 }
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
2161
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
2162 just_compute_this_one_p =
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
2163 just_compute_p || ((this || that) && val != this && val != that);
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
2164
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
2165 start.x = where.x;
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
2166 start.y = where.y;
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
2167 display_menu_item (mw, val, ws, &where, highlighted_p, horizontal_p,
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
2168 just_compute_this_one_p);
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
2169
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
2170 if (highlighted_p && highlighted_pos)
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
2171 {
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
2172 if (horizontal_p)
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
2173 highlighted_pos->y = ws->height;
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
2174 else
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
2175 highlighted_pos->x = ws->width;
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
2176 }
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
2177
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
2178 if (hit && !*hit_return && (val->type != SEPARATOR_TYPE))
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
2179 {
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
2180 if (horizontal_p && hit->x > start.x && hit->x < where.x)
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
2181 *hit_return = val;
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
2182 else if (!horizontal_p && hit->y > start.y && hit->y < where.y)
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
2183 *hit_return = val;
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
2184 }
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
2185
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
2186 if (horizontal_p)
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
2187 where.y = mw->menu.shadow_thickness;
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
2188 else
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
2189 where.x = mw->menu.shadow_thickness;
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
2190 }
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
2191
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
2192 /* Draw slab edges around menu */
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
2193 if (!just_compute_p)
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
2194 shadow_draw(mw, ws->window, 0, 0, ws->width, ws->height, SHADOW_OUT);
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
2195 }
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
2196
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
2197 /* Motion code */
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
2198 static void
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
2199 set_new_state (XlwMenuWidget mw, widget_value *val, int level)
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
2200 {
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
2201 int i;
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
2202
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
2203 mw->menu.new_depth = 0;
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
2204 for (i = 0; i < level; i++)
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
2205 push_new_stack (mw, mw->menu.old_stack [i]);
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
2206 if (val)
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
2207 push_new_stack (mw, val);
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
2208 }
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
2209
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
2210 static void
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
2211 make_windows_if_needed (XlwMenuWidget mw, int n)
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
2212 {
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
2213 int i;
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
2214 int start_at;
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
2215 XSetWindowAttributes xswa;
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
2216 int mask;
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
2217 #define ROOT_PARENT
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
2218 #ifdef ROOT_PARENT
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
2219 Window root = RootWindowOfScreen (DefaultScreenOfDisplay (XtDisplay (mw)));
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
2220 #endif
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
2221 window_state *windows;
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
2222
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
2223 if (mw->menu.windows_length >= n)
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
2224 return;
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
2225
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
2226 xswa.save_under = True;
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
2227 xswa.override_redirect = True;
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
2228 xswa.background_pixel = mw->core.background_pixel;
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
2229 xswa.border_pixel = mw->core.border_pixel;
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
2230 xswa.event_mask = (ExposureMask | ButtonMotionMask
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
2231 | ButtonReleaseMask | ButtonPressMask);
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
2232 xswa.cursor = mw->menu.cursor_shape;
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
2233 mask = CWSaveUnder | CWOverrideRedirect | CWBackPixel | CWBorderPixel
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
2234 | CWEventMask | CWCursor;
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
2235
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
2236 if (mw->menu.use_backing_store)
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
2237 {
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
2238 xswa.backing_store = Always;
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
2239 mask |= CWBackingStore;
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
2240 }
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
2241
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
2242 if (!mw->menu.windows)
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
2243 {
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
2244 mw->menu.windows =
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
2245 (window_state *) XtMalloc (n * sizeof (window_state));
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
2246 start_at = 0;
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
2247 }
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
2248 else
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
2249 {
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
2250 mw->menu.windows =
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
2251 (window_state *) XtRealloc ((char*)mw->menu.windows,
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
2252 n * sizeof (window_state));
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
2253 start_at = mw->menu.windows_length;
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
2254 }
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
2255 mw->menu.windows_length = n;
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
2256
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
2257 windows = mw->menu.windows;
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
2258
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
2259 for (i = start_at; i < n; i++)
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
2260 {
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
2261 windows [i].x = 0;
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
2262 windows [i].y = 0;
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
2263 windows [i].width = 1;
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
2264 windows [i].height = 1;
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
2265 windows [i].window =
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
2266 XCreateWindow (XtDisplay (mw),
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
2267 #ifdef ROOT_PARENT
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
2268 root,
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
2269 #else
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
2270 ((i > 0)
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
2271 ? windows[0].window
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
2272 : XtWindow (XtParent (mw))),
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
2273 #endif
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
2274 0, 0, 1, 1,
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
2275 0, 0, CopyFromParent, CopyFromParent, mask, &xswa);
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
2276 }
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
2277 }
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
2278
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
2279 /* Make the window fit in the screen */
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
2280 static void
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
2281 fit_to_screen (XlwMenuWidget mw, window_state *ws, window_state *previous_ws,
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
2282 Boolean horizontal_p)
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
2283 {
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
2284 int screen_width = WidthOfScreen (XtScreen (mw));
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
2285 int screen_height = HeightOfScreen (XtScreen (mw));
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
2286
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
2287 if (ws->x < 0)
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
2288 ws->x = 0;
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
2289 else if ((int) (ws->x + ws->width) > screen_width)
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
2290 {
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
2291 if (!horizontal_p)
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
2292 ws->x = previous_ws->x - ws->width;
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
2293 else
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
2294 {
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
2295 ws->x = screen_width - ws->width;
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
2296
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
2297 /* This check is to make sure we cut off the right side
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
2298 instead of the left side if the menu is wider than the
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
2299 screen. */
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
2300 if (ws->x < 0)
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
2301 ws->x = 0;
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
2302 }
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
2303 }
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
2304 if (ws->y < 0)
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
2305 ws->y = 0;
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
2306 else if ((int) (ws->y + ws->height) > screen_height)
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
2307 {
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
2308 if (horizontal_p)
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
2309 {
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
2310 /* A pulldown must either be entirely above or below the menubar.
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
2311 If we're here, the pulldown doesn't fit below the menubar, so
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
2312 let's determine if it will fit above the menubar.
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
2313 Only put it above if there is more room above than below.
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
2314 Note shadow_thickness offset to allow for slab surround.
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
2315 */
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
2316 if (ws->y > (screen_height / 2))
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
2317 ws->y = previous_ws->y - ws->height + mw->menu.shadow_thickness;
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
2318 }
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
2319 else
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
2320 {
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
2321 ws->y = screen_height - ws->height;
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
2322 /* if it's taller than the screen, display the topmost part
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
2323 that will fit, beginning at the top of the screen. */
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
2324 if (ws->y < 0)
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
2325 ws->y = 0;
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
2326 }
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
2327 }
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
2328 }
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
2329
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
2330 /* Updates old_stack from new_stack and redisplays. */
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
2331 static void
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
2332 remap_menubar (XlwMenuWidget mw)
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
2333 {
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
2334 int i;
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
2335 int last_same;
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
2336 XPoint selection_position;
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
2337 int old_depth = mw->menu.old_depth;
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
2338 int new_depth = mw->menu.new_depth;
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
2339 widget_value **old_stack;
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
2340 widget_value **new_stack;
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
2341 window_state *windows;
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
2342 widget_value *old_selection;
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
2343 widget_value *new_selection;
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
2344
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
2345 /* Check that enough windows and old_stack are ready. */
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
2346 make_windows_if_needed (mw, new_depth);
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
2347 make_old_stack_space (mw, new_depth);
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
2348 windows = mw->menu.windows;
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
2349 old_stack = mw->menu.old_stack;
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
2350 new_stack = mw->menu.new_stack;
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
2351
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
2352 /* compute the last identical different entry */
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
2353 for (i = 1; i < old_depth && i < new_depth; i++)
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
2354 if (old_stack [i] != new_stack [i])
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
2355 break;
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
2356 last_same = i - 1;
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
2357
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
2358 /* Memorize the previously selected item to be able to refresh it */
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
2359 old_selection = last_same + 1 < old_depth ? old_stack [last_same + 1] : NULL;
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
2360 if (old_selection && !old_selection->enabled)
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
2361 old_selection = NULL;
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
2362 new_selection = last_same + 1 < new_depth ? new_stack [last_same + 1] : NULL;
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
2363 if (new_selection && !new_selection->enabled)
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
2364 new_selection = NULL;
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
2365
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
2366 /* updates old_state from new_state. It has to be done now because
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
2367 display_menu (called below) uses the old_stack to know what to display. */
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
2368 for (i = last_same + 1; i < new_depth; i++)
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
2369 old_stack [i] = new_stack [i];
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
2370 mw->menu.old_depth = new_depth;
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
2371
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
2372 /* refresh the last seletion */
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
2373 selection_position.x = 0;
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
2374 selection_position.y = 0;
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
2375 display_menu (mw, last_same, new_selection == old_selection,
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
2376 &selection_position, NULL, NULL, old_selection, new_selection);
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
2377
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
2378 /* Now popup the new menus */
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
2379 for (i = last_same + 1; i < new_depth && new_stack [i]->contents; i++)
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
2380 {
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
2381 window_state *previous_ws = &windows [i - 1];
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
2382 window_state *ws = &windows [i];
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
2383
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
2384 ws->x = previous_ws->x + selection_position.x;
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
2385 ws->y = previous_ws->y + selection_position.y;
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
2386
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
2387 /* take into account the slab around the new menu */
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
2388 ws->y -= mw->menu.shadow_thickness;
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
2389
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
2390 size_menu (mw, i);
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
2391
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
2392 fit_to_screen (mw, ws, previous_ws, mw->menu.horizontal && i == 1);
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
2393
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
2394 XClearWindow (XtDisplay (mw), ws->window);
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
2395 XMoveResizeWindow (XtDisplay (mw), ws->window, ws->x, ws->y,
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
2396 ws->width, ws->height);
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
2397 XMapRaised (XtDisplay (mw), ws->window);
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
2398 display_menu (mw, i, False, &selection_position, NULL, NULL, NULL, NULL);
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
2399 }
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
2400
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
2401 /* unmap the menus that popped down */
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
2402 for (i = new_depth - 1; i < old_depth; i++)
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
2403 if (i >= new_depth || !new_stack [i]->contents)
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
2404 XUnmapWindow (XtDisplay (mw), windows [i].window);
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
2405 }
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
2406
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
2407 static Boolean
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
2408 motion_event_is_in_menu (XlwMenuWidget mw, XMotionEvent *ev, int level,
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
2409 XPoint *relative_pos)
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
2410 {
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
2411 window_state *ws = &mw->menu.windows [level];
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
2412 int x = level == 0 ? ws->x : ws->x + mw->menu.shadow_thickness;
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
2413 int y = level == 0 ? ws->y : ws->y + mw->menu.shadow_thickness;
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
2414 relative_pos->x = ev->x_root - x;
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
2415 relative_pos->y = ev->y_root - y;
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
2416 return (x < ev->x_root && ev->x_root < (int) (x + ws->width)
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
2417 && y < ev->y_root && ev->y_root < (int) (y + ws->height));
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
2418 }
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
2419
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
2420 static Boolean
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
2421 map_event_to_widget_value (XlwMenuWidget mw, XMotionEvent *ev,
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
2422 widget_value **val_ptr, int *level,
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
2423 Boolean *inside_menu)
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
2424 {
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
2425 int i;
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
2426 XPoint relative_pos;
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
2427 window_state* ws;
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
2428
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
2429 *val_ptr = NULL;
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
2430 *inside_menu = False;
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
2431
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
2432 /* Find the window */
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
2433 for (i = mw->menu.old_depth - 1; i >= 0; i--)
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
2434 {
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
2435 ws = &mw->menu.windows [i];
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
2436 if (ws && motion_event_is_in_menu (mw, ev, i, &relative_pos))
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
2437 {
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
2438 *inside_menu = True; /* special logic for menubar below... */
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
2439 if ((ev->type == ButtonPress) ||
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
2440 (ev->state != 0))
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
2441 {
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
2442 display_menu (mw, i, True, NULL, &relative_pos,
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
2443 val_ptr, NULL, NULL);
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
2444 if (*val_ptr)
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
2445 {
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
2446 *level = i + 1;
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
2447 *inside_menu = True;
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
2448 return True;
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
2449 }
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
2450 else if (mw->menu.horizontal || i == 0)
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
2451 {
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
2452 /* if we're clicking on empty part of the menubar, then
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
2453 unpost the stay-up menu */
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
2454 *inside_menu = False;
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
2455 }
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
2456 }
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
2457 }
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
2458 }
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
2459 return False;
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
2460 }
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
2461
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
2462 /* Procedures */
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
2463 static void
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
2464 make_drawing_gcs (XlwMenuWidget mw)
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
2465 {
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
2466 XGCValues xgcv;
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
2467 unsigned long flags = (GCFont | GCForeground | GCBackground);
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
2468
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
2469 #ifdef NEED_MOTIF
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
2470 xgcv.font = default_font_of_font_list (mw->menu.font_list)->fid;
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
2471 #else
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
2472 xgcv.font = mw->menu.font->fid;
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
2473 #endif
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
2474
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
2475 xgcv.foreground = mw->core.background_pixel;
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
2476 xgcv.background = mw->menu.foreground;
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
2477 mw->menu.background_gc = XtGetGC ((Widget)mw, flags, &xgcv);
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
2478
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
2479 xgcv.foreground = mw->menu.foreground;
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
2480 xgcv.background = mw->core.background_pixel;
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
2481 mw->menu.foreground_gc = XtGetGC ((Widget)mw, flags, &xgcv);
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
2482
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
2483 if (mw->menu.select_color != (Pixel)-1)
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
2484 {
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
2485 xgcv.foreground = mw->menu.select_color;
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
2486 }
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
2487 else
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
2488 {
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
2489 Display *dpy = XtDisplay(mw);
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
2490 if (CellsOfScreen(DefaultScreenOfDisplay(dpy)) <= 2)
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
2491 { /* mono */
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
2492 xgcv.foreground = mw->menu.foreground;
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
2493 }
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
2494 else
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
2495 { /* color */
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
2496 XColor xcolor;
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
2497 Colormap cmap = DefaultColormapOfScreen (XtScreen ((Widget) mw));
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
2498 xcolor.pixel = mw->core.background_pixel;
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
2499 XQueryColor (dpy, cmap, &xcolor);
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
2500 xcolor.red *= 0.85;
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
2501 xcolor.green *= 0.85;
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
2502 xcolor.blue *= 0.85;
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
2503 if (allocate_nearest_color (dpy, cmap, &xcolor))
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
2504 xgcv.foreground = xcolor.pixel;
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
2505 }
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
2506 }
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
2507 xgcv.background = mw->core.background_pixel;
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
2508 mw->menu.select_gc = XtGetGC ((Widget)mw, flags, &xgcv);
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
2509
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
2510 xgcv.foreground = mw->menu.foreground;
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
2511 xgcv.background = mw->core.background_pixel;
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
2512 xgcv.fill_style = FillStippled;
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
2513 xgcv.stipple = mw->menu.gray_pixmap;
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
2514 mw->menu.inactive_gc = XtGetGC ((Widget)mw,
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
2515 (flags | GCFillStyle | GCStipple),
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
2516 &xgcv);
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
2517
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
2518 xgcv.foreground = mw->menu.button_foreground;
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
2519 xgcv.background = mw->core.background_pixel;
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
2520 mw->menu.button_gc = XtGetGC ((Widget)mw, flags, &xgcv);
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
2521
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
2522 xgcv.fill_style = FillStippled;
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
2523 xgcv.stipple = mw->menu.gray_pixmap;
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
2524 mw->menu.inactive_button_gc = XtGetGC ((Widget)mw,
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
2525 (flags | GCFillStyle | GCStipple),
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
2526 &xgcv);
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
2527 }
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
2528
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
2529 static void
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
2530 release_drawing_gcs (XlwMenuWidget mw)
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
2531 {
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
2532 XtReleaseGC ((Widget) mw, mw->menu.foreground_gc);
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
2533 XtReleaseGC ((Widget) mw, mw->menu.button_gc);
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
2534 XtReleaseGC ((Widget) mw, mw->menu.inactive_gc);
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
2535 XtReleaseGC ((Widget) mw, mw->menu.inactive_button_gc);
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
2536 XtReleaseGC ((Widget) mw, mw->menu.background_gc);
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
2537 XtReleaseGC ((Widget) mw, mw->menu.select_gc);
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
2538 /* let's get some segvs if we try to use these... */
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
2539 mw->menu.foreground_gc = (GC) -1;
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
2540 mw->menu.button_gc = (GC) -1;
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
2541 mw->menu.inactive_gc = (GC) -1;
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
2542 mw->menu.inactive_button_gc = (GC) -1;
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
2543 mw->menu.background_gc = (GC) -1;
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
2544 mw->menu.select_gc = (GC) -1;
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
2545 }
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
2546
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
2547 #define MINL(x,y) ((((unsigned long) (x)) < ((unsigned long) (y))) \
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
2548 ? ((unsigned long) (x)) : ((unsigned long) (y)))
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
2549
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
2550 static void
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
2551 make_shadow_gcs (XlwMenuWidget mw)
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
2552 {
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
2553 XGCValues xgcv;
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
2554 unsigned long pm = 0;
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
2555 Display *dpy = XtDisplay ((Widget) mw);
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
2556 Colormap cmap = DefaultColormapOfScreen (XtScreen ((Widget) mw));
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
2557 XColor topc, botc;
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
2558 int top_frobbed = 0, bottom_frobbed = 0;
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
2559
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
2560 if (mw->menu.top_shadow_color == -1)
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
2561 mw->menu.top_shadow_color = mw->core.background_pixel;
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
2562 if (mw->menu.bottom_shadow_color == -1)
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
2563 mw->menu.bottom_shadow_color = mw->menu.foreground;
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
2564
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
2565 if (mw->menu.top_shadow_color == mw->core.background_pixel ||
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
2566 mw->menu.top_shadow_color == mw->menu.foreground)
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
2567 {
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
2568 topc.pixel = mw->core.background_pixel;
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
2569 XQueryColor (dpy, cmap, &topc);
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
2570 /* don't overflow/wrap! */
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
2571 topc.red = MINL (65535, topc.red * 1.2);
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
2572 topc.green = MINL (65535, topc.green * 1.2);
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
2573 topc.blue = MINL (65535, topc.blue * 1.2);
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
2574 if (allocate_nearest_color (dpy, cmap, &topc))
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
2575 {
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
2576 if (topc.pixel == mw->core.background_pixel)
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
2577 {
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
2578 XFreeColors( dpy, cmap, &topc.pixel, 1, 0);
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
2579 topc.red = MINL (65535, topc.red + 0x8000);
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
2580 topc.green = MINL (65535, topc.green + 0x8000);
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
2581 topc.blue = MINL (65535, topc.blue + 0x8000);
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
2582 if (allocate_nearest_color (dpy, cmap, &topc))
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
2583 {
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
2584 mw->menu.top_shadow_color = topc.pixel;
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
2585 }
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
2586 }
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
2587 else
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
2588 {
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
2589 mw->menu.top_shadow_color = topc.pixel;
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
2590 }
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
2591
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
2592 top_frobbed = 1;
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
2593 }
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
2594 }
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
2595 if (mw->menu.bottom_shadow_color == mw->menu.foreground ||
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
2596 mw->menu.bottom_shadow_color == mw->core.background_pixel)
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
2597 {
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
2598 botc.pixel = mw->core.background_pixel;
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
2599 XQueryColor (dpy, cmap, &botc);
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
2600 botc.red *= 0.6;
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
2601 botc.green *= 0.6;
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
2602 botc.blue *= 0.6;
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
2603 if (allocate_nearest_color (dpy, cmap, &botc))
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
2604 {
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
2605 if (botc.pixel == mw->core.background_pixel)
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
2606 {
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
2607 XFreeColors (dpy, cmap, &botc.pixel, 1, 0);
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
2608 botc.red = MINL (65535, botc.red + 0x4000);
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
2609 botc.green = MINL (65535, botc.green + 0x4000);
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
2610 botc.blue = MINL (65535, botc.blue + 0x4000);
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
2611 if (allocate_nearest_color (dpy, cmap, &botc))
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
2612 {
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
2613 mw->menu.bottom_shadow_color = botc.pixel;
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
2614 }
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
2615 }
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
2616 else
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
2617 {
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
2618 mw->menu.bottom_shadow_color = botc.pixel;
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
2619 }
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
2620
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
2621 bottom_frobbed = 1;
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
2622 }
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
2623 }
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
2624
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
2625 if (top_frobbed && bottom_frobbed)
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
2626 {
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
2627 int top_avg = ((topc.red / 3) + (topc.green / 3) + (topc.blue / 3));
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
2628 int bot_avg = ((botc.red / 3) + (botc.green / 3) + (botc.blue / 3));
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
2629 if (bot_avg > top_avg)
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
2630 {
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
2631 Pixel tmp = mw->menu.top_shadow_color;
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
2632 mw->menu.top_shadow_color = mw->menu.bottom_shadow_color;
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
2633 mw->menu.bottom_shadow_color = tmp;
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
2634 }
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
2635 else if (topc.pixel == botc.pixel)
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
2636 {
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
2637 if (botc.pixel == mw->menu.foreground)
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
2638 mw->menu.top_shadow_color = mw->core.background_pixel;
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
2639 else
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
2640 mw->menu.bottom_shadow_color = mw->menu.foreground;
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
2641 }
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
2642 }
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
2643
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
2644 if (!mw->menu.top_shadow_pixmap &&
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
2645 mw->menu.top_shadow_color == mw->core.background_pixel)
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
2646 {
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
2647 mw->menu.top_shadow_pixmap = mw->menu.gray_pixmap;
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
2648 mw->menu.top_shadow_color = mw->menu.foreground;
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
2649 }
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
2650 if (!mw->menu.bottom_shadow_pixmap &&
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
2651 mw->menu.bottom_shadow_color == mw->core.background_pixel)
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
2652 {
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
2653 mw->menu.bottom_shadow_pixmap = mw->menu.gray_pixmap;
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
2654 mw->menu.bottom_shadow_color = mw->menu.foreground;
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
2655 }
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
2656
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
2657 xgcv.fill_style = FillOpaqueStippled;
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
2658 xgcv.foreground = mw->menu.top_shadow_color;
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
2659 xgcv.background = mw->core.background_pixel;
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
2660 xgcv.stipple = mw->menu.top_shadow_pixmap;
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
2661 pm = (xgcv.stipple ? GCStipple|GCFillStyle : 0);
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
2662 mw->menu.shadow_top_gc =
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
2663 XtGetGC((Widget)mw, GCForeground|GCBackground|pm, &xgcv);
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
2664
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
2665 xgcv.foreground = mw->menu.bottom_shadow_color;
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
2666 xgcv.stipple = mw->menu.bottom_shadow_pixmap;
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
2667 pm = (xgcv.stipple ? GCStipple|GCFillStyle : 0);
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
2668 mw->menu.shadow_bottom_gc =
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
2669 XtGetGC ((Widget)mw, GCForeground|GCBackground|pm, &xgcv);
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
2670 }
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
2671
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
2672
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
2673 static void
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
2674 release_shadow_gcs (XlwMenuWidget mw)
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
2675 {
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
2676 XtReleaseGC ((Widget) mw, mw->menu.shadow_top_gc);
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
2677 XtReleaseGC ((Widget) mw, mw->menu.shadow_bottom_gc);
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
2678 }
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
2679
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
2680
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
2681 static void
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
2682 extract_font_extents (XlwMenuWidget mw)
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
2683 {
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
2684 #ifdef NEED_MOTIF
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
2685 /* Find the maximal ascent/descent of the fonts in the font list
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
2686 so that all menu items can be the same height... */
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
2687 mw->menu.font_ascent = 0;
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
2688 mw->menu.font_descent = 0;
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
2689
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
2690 {
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
2691 XmFontContext context;
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
2692 #if (XmVersion >= 1002)
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
2693 XmFontListEntry fontentry;
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
2694 #else
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
2695 XmStringCharSet charset;
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
2696 #endif
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
2697 XFontStruct *font;
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
2698
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
2699 if (! XmFontListInitFontContext (&context, mw->menu.font_list))
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
2700 abort ();
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
2701 #if (XmVersion >= 1002)
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
2702 /* There is a BUG in the 1.2 version of XmFontListGetNextFont() (or more
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
2703 specifically, in _XmGetFirstFont()) that can cause a null pointer to be
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
2704 passed to XFontsOfFontSet. Use XmFontListNextEntry(), which is the
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
2705 newer equivalent, instead. Also, it supports font sets, and the
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
2706 older function doesn't. */
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
2707 while ((fontentry = XmFontListNextEntry (context)))
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
2708 {
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
2709 char *one_of_them;
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
2710 XmFontType rettype;
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
2711
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
2712 one_of_them = XmFontListEntryGetFont (fontentry, &rettype);
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
2713 if (rettype == XmFONT_IS_FONTSET)
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
2714 {
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
2715 XFontSet fontset = (XFontSet) one_of_them;
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
2716 XFontStruct **fontstruct_list;
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
2717 char **fontname_list;
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
2718 int fontcount = XFontsOfFontSet (fontset, &fontstruct_list,
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
2719 &fontname_list);
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
2720 while (--fontcount >= 0)
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
2721 {
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
2722 font = fontstruct_list[fontcount];
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
2723 if (font->ascent > (int) mw->menu.font_ascent)
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
2724 mw->menu.font_ascent = font->ascent;
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
2725 if (font->descent > (int) mw->menu.font_descent)
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
2726 mw->menu.font_descent = font->descent;
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
2727 }
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
2728 }
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
2729 else /* XmFONT_IS_FONT */
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
2730 {
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
2731 font = (XFontStruct *) one_of_them;
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
2732 if (font->ascent > (int) mw->menu.font_ascent)
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
2733 mw->menu.font_ascent = font->ascent;
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
2734 if (font->descent > (int) mw->menu.font_descent)
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
2735 mw->menu.font_descent = font->descent;
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
2736 }
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
2737 }
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
2738 #else /* motif 1.1 */
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
2739 while (XmFontListGetNextFont (context, &charset, &font))
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
2740 {
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
2741 if (font->ascent > (int) mw->menu.font_ascent)
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
2742 mw->menu.font_ascent = font->ascent;
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
2743 if (font->descent > (int) mw->menu.font_descent)
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
2744 mw->menu.font_descent = font->descent;
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
2745 XtFree (charset);
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
2746 }
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
2747 #endif /* Motif version */
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
2748 XmFontListFreeFontContext (context);
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
2749 }
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
2750 #else /* Not Motif */
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
2751 mw->menu.font_ascent = mw->menu.font->ascent;
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
2752 mw->menu.font_descent = mw->menu.font->descent;
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
2753 #endif /* NEED_MOTIF */
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
2754 }
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
2755
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
2756 #ifdef NEED_MOTIF
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
2757 static XFontStruct *
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
2758 default_font_of_font_list (XmFontList font_list)
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
2759 {
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
2760 XFontStruct *font = 0;
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
2761 # if 0
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
2762 /* Xm/Label.c does this: */
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
2763 _XmFontListGetDefaultFont (font_list, &font);
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
2764 # else /* !0 */
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
2765 {
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
2766 XmFontContext context;
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
2767 #if (XmVersion >= 1002)
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
2768 XmFontListEntry fontentry;
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
2769 XmFontType rettype;
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
2770 char *one_of_them;
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
2771 #else
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
2772 XmStringCharSet charset;
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
2773 #endif
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
2774
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
2775 if (! XmFontListInitFontContext (&context, font_list))
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
2776 abort ();
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
2777 #if (XmVersion >= 1002)
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
2778 /* There is a BUG in the 1.2 version of XmFontListGetNextFont() (or more
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
2779 specifically, in _XmGetFirstFont()) that can cause a null pointer to be
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
2780 passed to XFontsOfFontSet. Use XmFontListNextEntry(), which is the
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
2781 newer equivalent, instead. */
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
2782 fontentry = XmFontListNextEntry (context);
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
2783 one_of_them = XmFontListEntryGetFont (fontentry, &rettype);
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
2784 if (rettype == XmFONT_IS_FONTSET)
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
2785 {
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
2786 XFontSet fontset = (XFontSet) one_of_them;
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
2787 XFontStruct **fontstruct_list;
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
2788 char **fontname_list;
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
2789 (void) XFontsOfFontSet (fontset, &fontstruct_list, &fontname_list);
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
2790 font = fontstruct_list[0];
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
2791 }
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
2792 else /* XmFONT_IS_FONT */
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
2793 {
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
2794 font = (XFontStruct *) one_of_them;
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
2795 }
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
2796 #else
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
2797 if (! XmFontListGetNextFont (context, &charset, &font))
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
2798 abort ();
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
2799 XtFree (charset);
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
2800 #endif
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
2801 XmFontListFreeFontContext (context);
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
2802 }
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
2803 # endif /* !0 */
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
2804
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
2805 if (! font) abort ();
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
2806 return font;
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
2807 }
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
2808 #endif /* NEED_MOTIF */
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
2809
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
2810 static void
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
2811 XlwMenuInitialize (Widget request, Widget new, ArgList args,
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
2812 Cardinal *num_args)
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
2813 {
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
2814 /* Get the GCs and the widget size */
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
2815 XlwMenuWidget mw = (XlwMenuWidget)new;
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
2816
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
2817 XSetWindowAttributes xswa;
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
2818 int mask;
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
2819
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
2820 Window window = RootWindowOfScreen (DefaultScreenOfDisplay (XtDisplay (mw)));
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
2821 Display *display = XtDisplay (mw);
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
2822
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
2823 /* mw->menu.cursor = XCreateFontCursor (display, mw->menu.cursor_shape); */
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
2824 mw->menu.cursor = mw->menu.cursor_shape;
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
2825
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
2826 mw->menu.gray_pixmap = XCreatePixmapFromBitmapData (display, window,
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
2827 (char *) gray_bits,
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
2828 gray_width,
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
2829 gray_height, 1, 0, 1);
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
2830
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
2831 #ifdef NEED_MOTIF
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
2832 /* The menu.font_list slot came from the *fontList resource (Motif standard.)
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
2833 The menu.font_list_2 slot came from the *font resource, for backward
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
2834 compatibility with older versions of this code, and consistency with the
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
2835 rest of emacs. If both font and fontList are specified, we use font.
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
2836 If only one is specified, we use that. If neither are specified, we
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
2837 use the "fallback" value. What a kludge!!!
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
2838
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
2839 Note that this has the bug that a more general wildcard like "*fontList:"
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
2840 will override a more specific resource like "Emacs*menubar.font:". But
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
2841 I can't think of a way around that.
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
2842 */
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
2843 if (mw->menu.font_list) /* if *fontList is specified, use that */
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
2844 ;
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
2845 else if (mw->menu.font_list_2) /* else if *font is specified, use that */
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
2846 mw->menu.font_list = mw->menu.font_list_2;
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
2847 else /* otherwise use default */
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
2848 mw->menu.font_list = mw->menu.fallback_font_list;
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
2849 #endif
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
2850
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
2851 make_drawing_gcs (mw);
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
2852 make_shadow_gcs (mw);
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
2853 extract_font_extents (mw);
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
2854
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
2855 xswa.background_pixel = mw->core.background_pixel;
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
2856 xswa.border_pixel = mw->core.border_pixel;
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
2857 mask = CWBackPixel | CWBorderPixel;
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
2858
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
2859 mw->menu.popped_up = False;
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
2860 mw->menu.pointer_grabbed = False;
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
2861 mw->menu.next_release_must_exit = False;
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
2862
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
2863 mw->menu.old_depth = 1;
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
2864 mw->menu.old_stack = (widget_value**)XtMalloc (sizeof (widget_value*));
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
2865 mw->menu.old_stack_length = 1;
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
2866 mw->menu.old_stack [0] = mw->menu.contents;
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
2867
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
2868 mw->menu.new_depth = 0;
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
2869 mw->menu.new_stack = 0;
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
2870 mw->menu.new_stack_length = 0;
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
2871 push_new_stack (mw, mw->menu.contents);
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
2872
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
2873 mw->menu.windows = (window_state*)XtMalloc (sizeof (window_state));
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
2874 mw->menu.windows_length = 1;
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
2875 mw->menu.windows [0].x = 0;
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
2876 mw->menu.windows [0].y = 0;
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
2877 mw->menu.windows [0].width = 0;
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
2878 mw->menu.windows [0].height = 0;
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
2879 size_menu (mw, 0);
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
2880
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
2881 mw->core.width = mw->menu.windows [0].width;
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
2882 mw->core.height = mw->menu.windows [0].height;
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
2883 }
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
2884
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
2885 static void
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
2886 XlwMenuClassInitialize (void)
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
2887 {
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
2888 }
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
2889
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
2890 static void
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
2891 XlwMenuRealize (Widget w, Mask *valueMask, XSetWindowAttributes *attributes)
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
2892 {
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
2893 XlwMenuWidget mw = (XlwMenuWidget)w;
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
2894 XSetWindowAttributes xswa;
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
2895 int mask;
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
2896
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
2897 (*xlwMenuWidgetClass->core_class.superclass->core_class.realize)
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
2898 (w, valueMask, attributes);
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
2899
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
2900 xswa.save_under = True;
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
2901 xswa.cursor = mw->menu.cursor_shape;
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
2902 mask = CWSaveUnder | CWCursor;
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
2903 if (mw->menu.use_backing_store)
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
2904 {
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
2905 xswa.backing_store = Always;
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
2906 mask |= CWBackingStore;
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
2907 }
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
2908 XChangeWindowAttributes (XtDisplay (w), XtWindow (w), mask, &xswa);
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
2909
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
2910 mw->menu.windows [0].window = XtWindow (w);
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
2911 mw->menu.windows [0].x = w->core.x;
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
2912 mw->menu.windows [0].y = w->core.y;
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
2913 mw->menu.windows [0].width = w->core.width;
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
2914 mw->menu.windows [0].height = w->core.height;
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
2915 }
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
2916
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
2917 /* Only the toplevel menubar/popup is a widget so it's the only one that
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
2918 receives expose events through Xt. So we repaint all the other panes
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
2919 when receiving an Expose event. */
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
2920 static void
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
2921 XlwMenuRedisplay (Widget w, XEvent *ev, Region region)
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
2922 {
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
2923 XlwMenuWidget mw = (XlwMenuWidget)w;
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
2924 int i;
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
2925
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
2926 if (mw->core.being_destroyed) return;
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
2927
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
2928 for (i = 0; i < mw->menu.old_depth; i++)
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
2929 display_menu (mw, i, False, NULL, NULL, NULL, NULL, NULL);
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
2930 set_new_state (mw, NULL, mw->menu.old_depth); /* #### - ??? */
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
2931 remap_menubar (mw); /* #### - do these two lines do anything? */
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
2932 }
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
2933
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
2934 static void
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
2935 XlwMenuDestroy (Widget w)
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
2936 {
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
2937 int i;
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
2938 XlwMenuWidget mw = (XlwMenuWidget) w;
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
2939
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
2940 if (mw->menu.pointer_grabbed)
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
2941 {
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
2942 XtUngrabPointer (w, CurrentTime);
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
2943 mw->menu.pointer_grabbed = False;
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
2944 }
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
2945
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
2946 release_drawing_gcs (mw);
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
2947 release_shadow_gcs (mw);
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
2948
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
2949 /* this doesn't come from the resource db but is created explicitly
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
2950 so we must free it ourselves. */
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
2951 XFreePixmap (XtDisplay (mw), mw->menu.gray_pixmap);
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
2952 mw->menu.gray_pixmap = (Pixmap) -1;
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
2953
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
2954 /* Don't free mw->menu.contents because that comes from our creator.
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
2955 The `*_stack' elements are just pointers into `contents' so leave
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
2956 that alone too. But free the stacks themselves. */
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
2957 if (mw->menu.old_stack) XtFree ((char *) mw->menu.old_stack);
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
2958 if (mw->menu.new_stack) XtFree ((char *) mw->menu.new_stack);
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
2959
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
2960 /* Remember, you can't free anything that came from the resource
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
2961 database. This includes:
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
2962 mw->menu.cursor
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
2963 mw->menu.top_shadow_pixmap
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
2964 mw->menu.bottom_shadow_pixmap
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
2965 mw->menu.font
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
2966 mw->menu.font_set
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
2967 Also the color cells of top_shadow_color, bottom_shadow_color,
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
2968 foreground, and button_foreground will never be freed until this
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
2969 client exits. Nice, eh?
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
2970 */
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
2971
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
2972 /* start from 1 because the one in slot 0 is w->core.window */
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
2973 for (i = 1; i < mw->menu.windows_length; i++)
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
2974 XDestroyWindow (XtDisplay (mw), mw->menu.windows [i].window);
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
2975 if (mw->menu.windows)
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
2976 XtFree ((char *) mw->menu.windows);
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
2977 }
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
2978
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
2979 static Boolean
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
2980 XlwMenuSetValues (Widget current, Widget request, Widget new, ArgList args,
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
2981 Cardinal *num_args)
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
2982 {
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
2983 XlwMenuWidget oldmw = (XlwMenuWidget)current;
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
2984 XlwMenuWidget newmw = (XlwMenuWidget)new;
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
2985 Boolean redisplay = False;
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
2986 int i;
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
2987
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
2988 if (newmw->menu.contents
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
2989 && newmw->menu.contents->contents
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
2990 && newmw->menu.contents->contents->change >= VISIBLE_CHANGE)
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
2991 redisplay = True;
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
2992
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
2993 if (newmw->core.background_pixel != oldmw->core.background_pixel
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
2994 || newmw->menu.foreground != oldmw->menu.foreground
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
2995 /* For the XEditResource protocol, which may want to change the font. */
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
2996 #ifdef NEED_MOTIF
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
2997 || newmw->menu.font_list != oldmw->menu.font_list
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
2998 || newmw->menu.font_list_2 != oldmw->menu.font_list_2
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
2999 || newmw->menu.fallback_font_list != oldmw->menu.fallback_font_list
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
3000 #else
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
3001 || newmw->menu.font != oldmw->menu.font
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
3002 #endif
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
3003 )
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
3004 {
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
3005 release_drawing_gcs (newmw);
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
3006 make_drawing_gcs (newmw);
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
3007 redisplay = True;
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
3008
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
3009 for (i = 0; i < oldmw->menu.windows_length; i++)
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
3010 {
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
3011 XSetWindowBackground (XtDisplay (oldmw),
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
3012 oldmw->menu.windows [i].window,
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
3013 newmw->core.background_pixel);
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
3014 /* clear windows and generate expose events */
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
3015 XClearArea (XtDisplay (oldmw), oldmw->menu.windows[i].window,
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
3016 0, 0, 0, 0, True);
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
3017 }
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
3018 }
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
3019
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
3020 return redisplay;
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
3021 }
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
3022
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
3023 static void
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
3024 XlwMenuResize (Widget w)
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
3025 {
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
3026 XlwMenuWidget mw = (XlwMenuWidget)w;
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
3027
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
3028 mw->menu.windows [0].width = mw->core.width;
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
3029 mw->menu.windows [0].height = mw->core.height;
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
3030 }
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
3031
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
3032 /* Action procedures */
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
3033 static void
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
3034 handle_single_motion_event (XlwMenuWidget mw, XMotionEvent *ev,
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
3035 Boolean select_p)
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
3036 {
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
3037 widget_value *val;
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
3038 Boolean stay_up;
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
3039 int level;
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
3040
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
3041 if (!map_event_to_widget_value (mw, ev, &val, &level, &stay_up))
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
3042 {
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
3043 /* we wind up here when: (a) the event is in the menubar, (b) the
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
3044 event isn't in the menubar or any of the panes, (c) the event is on
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
3045 a disabled menu item */
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
3046 pop_new_stack_if_no_contents (mw);
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
3047 if (select_p && !stay_up) {
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
3048 /* pop down all menus and exit */
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
3049 mw->menu.next_release_must_exit = True;
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
3050 set_new_state(mw, (val = NULL), 1);
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
3051 }
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
3052 }
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
3053 else
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
3054 {
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
3055 /* we wind up here when: (a) the event pops up a pull_right menu,
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
3056 (b) a menu item that is not disabled is highlighted */
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
3057 if (select_p && mw->menu.bounce_down
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
3058 && close_to_reference_time((Widget)mw,
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
3059 mw->menu.menu_bounce_time,
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
3060 (XEvent *)ev))
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
3061 {
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
3062 /* motion can cause more than one event. Don't bounce right back
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
3063 up if we've just bounced down. */
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
3064 val = NULL;
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
3065 }
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
3066 else if (select_p && mw->menu.bounce_down &&
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
3067 mw->menu.last_selected_val &&
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
3068 (mw->menu.last_selected_val == val))
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
3069 {
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
3070 val = NULL; /* assigned to mw->last_selected_val below */
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
3071 mw->menu.menu_bounce_time = ev->time;
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
3072 /* popdown last menu if we're selecting the same menu item as we did
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
3073 last time and the XlwMenu.bounceDown resource is set, if the
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
3074 item is on the menubar itself, then exit. */
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
3075 if (level == (mw->menu.popped_up ? 0 : 1))
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
3076 mw->menu.next_release_must_exit = True;
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
3077 }
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
3078 else
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
3079 mw->menu.menu_bounce_time = 0;
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
3080 set_new_state (mw, val, level);
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
3081 }
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
3082 mw->menu.last_selected_val = val;
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
3083 remap_menubar (mw);
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
3084
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
3085 /* Sync with the display. Makes it feel better on X terms. */
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
3086 XFlush (XtDisplay (mw));
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
3087 }
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
3088
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
3089 static void
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
3090 handle_motion_event (XlwMenuWidget mw, XMotionEvent *ev,
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
3091 Boolean select_p)
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
3092 {
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
3093 int x = ev->x_root;
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
3094 int y = ev->y_root;
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
3095 int state = ev->state;
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
3096 XMotionEvent *event= ev, dummy;
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
3097
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
3098 /* allow motion events to be generated again */
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
3099 dummy.window = ev->window;
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
3100 if (ev->is_hint
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
3101 && XQueryPointer (XtDisplay (mw), dummy.window,
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
3102 &dummy.root, &dummy.subwindow,
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
3103 &dummy.x_root, &dummy.y_root,
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
3104 &dummy.x, &dummy.y,
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
3105 &dummy.state)
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
3106 && dummy.state == state
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
3107 && (dummy.x_root != x || dummy.y_root != y))
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
3108 {
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
3109 /* don't handle the event twice or that breaks bounce_down. --Stig */
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
3110 dummy.type = ev->type;
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
3111 event = &dummy;
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
3112 }
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
3113
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
3114 handle_single_motion_event (mw, event, select_p);
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
3115 }
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
3116
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
3117 static void
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
3118 Start (Widget w, XEvent *ev, String *params, Cardinal *num_params)
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
3119 {
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
3120 XlwMenuWidget mw = (XlwMenuWidget)w;
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
3121
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
3122 if (!mw->menu.pointer_grabbed)
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
3123 {
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
3124 mw->menu.menu_post_time = ev->xbutton.time;
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
3125 mw->menu.menu_bounce_time = 0;
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
3126 mw->menu.next_release_must_exit = True;
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
3127 mw->menu.last_selected_val = NULL;
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
3128
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
3129 XtCallCallbackList ((Widget)mw, mw->menu.open, NULL);
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
3130
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
3131 /* notes the absolute position of the menubar window */
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
3132 mw->menu.windows [0].x = ev->xmotion.x_root - ev->xmotion.x;
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
3133 mw->menu.windows [0].y = ev->xmotion.y_root - ev->xmotion.y;
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
3134
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
3135 XtGrabPointer ((Widget)mw, False,
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
3136 (ButtonMotionMask | ButtonReleaseMask | ButtonPressMask),
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
3137 GrabModeAsync, GrabModeAsync,
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
3138 None, mw->menu.cursor_shape,
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
3139 ((XButtonPressedEvent*)ev)->time);
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
3140 mw->menu.pointer_grabbed = True;
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
3141 }
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
3142
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
3143 /* handles the down like a move, slots are mostly compatible */
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
3144 handle_motion_event (mw, &ev->xmotion, True);
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
3145 }
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
3146
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
3147 static void
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
3148 Drag (Widget w, XEvent *ev, String *params, Cardinal *num_params)
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
3149 {
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
3150 XlwMenuWidget mw = (XlwMenuWidget)w;
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
3151 handle_motion_event (mw, &ev->xmotion, False);
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
3152 }
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
3153
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
3154 static void
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
3155 Select (Widget w, XEvent *ev, String *params, Cardinal *num_params)
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
3156 {
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
3157 XlwMenuWidget mw = (XlwMenuWidget)w;
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
3158 widget_value *selected_item = mw->menu.old_stack [mw->menu.old_depth - 1];
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
3159
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
3160 /* If user releases the button quickly, without selecting anything,
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
3161 after the initial down-click that brought the menu up,
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
3162 do nothing. */
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
3163 if ((selected_item == 0 || selected_item->call_data == 0)
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
3164 && (!mw->menu.next_release_must_exit
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
3165 || close_to_reference_time(w, mw->menu.menu_post_time, ev)))
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
3166 {
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
3167 mw->menu.next_release_must_exit = False;
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
3168 return;
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
3169 }
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
3170
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
3171 /* pop down everything */
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
3172 mw->menu.new_depth = 1;
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
3173 remap_menubar (mw);
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
3174
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
3175 /* Destroy() only gets called for popup menus. Menubar widgets aren't
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
3176 destroyed when their menu panes get nuked. */
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
3177 if (mw->menu.pointer_grabbed)
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
3178 {
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
3179 XtUngrabPointer ((Widget)w, ev->xmotion.time);
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
3180 mw->menu.pointer_grabbed = False;
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
3181 }
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
3182
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
3183 if (mw->menu.popped_up)
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
3184 {
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
3185 mw->menu.popped_up = False;
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
3186 XtPopdown (XtParent (mw));
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
3187 }
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
3188
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
3189 /* callback */
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
3190 XtCallCallbackList ((Widget)mw, mw->menu.select, (XtPointer)selected_item);
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
3191 }
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
3192
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
3193
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
3194 /* Special code to pop-up a menu */
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
3195 void
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
3196 xlw_pop_up_menu (XlwMenuWidget mw, XButtonPressedEvent *event)
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
3197 {
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
3198 int x = event->x_root;
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
3199 int y = event->y_root;
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
3200 int w;
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
3201 int h;
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
3202 int borderwidth = mw->menu.shadow_thickness;
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
3203 Screen* screen = XtScreen (mw);
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
3204
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
3205 mw->menu.menu_post_time = event->time;
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
3206 mw->menu.menu_bounce_time = 0;
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
3207 mw->menu.next_release_must_exit = True;
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
3208 mw->menu.last_selected_val = NULL;
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
3209
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
3210 XtCallCallbackList ((Widget)mw, mw->menu.open, NULL);
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
3211
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
3212 size_menu (mw, 0);
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
3213
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
3214 w = mw->menu.windows [0].width;
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
3215 h = mw->menu.windows [0].height;
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
3216
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
3217 x -= borderwidth;
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
3218 y -= borderwidth;
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
3219 if (x < borderwidth)
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
3220 x = borderwidth;
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
3221 if (x + w + 2 * borderwidth > WidthOfScreen (screen))
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
3222 x = WidthOfScreen (screen) - w - 2 * borderwidth;
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
3223 if (y < borderwidth)
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
3224 y = borderwidth;
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
3225 if (y + h + 2 * borderwidth> HeightOfScreen (screen))
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
3226 y = HeightOfScreen (screen) - h - 2 * borderwidth;
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
3227
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
3228 mw->menu.popped_up = True;
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
3229 XtConfigureWidget (XtParent (mw), x, y, w, h,
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
3230 XtParent (mw)->core.border_width);
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
3231 XtPopup (XtParent (mw), XtGrabExclusive);
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
3232 display_menu (mw, 0, False, NULL, NULL, NULL, NULL, NULL);
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
3233 if (!mw->menu.pointer_grabbed)
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
3234 {
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
3235 XtGrabPointer ((Widget)mw, False,
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
3236 (ButtonMotionMask | ButtonReleaseMask | ButtonPressMask),
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
3237 GrabModeAsync, GrabModeAsync,
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
3238 None, mw->menu.cursor_shape, event->time);
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
3239 mw->menu.pointer_grabbed = True;
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
3240 }
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
3241
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
3242 mw->menu.windows [0].x = x + borderwidth;
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
3243 mw->menu.windows [0].y = y + borderwidth;
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
3244
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
3245 handle_motion_event (mw, (XMotionEvent *) event, True);
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
3246 }
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
3247
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
3248 /* #### unused */
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
3249 #if 0
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
3250 /*
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
3251 * This is a horrible function which should not be needed.
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
3252 * use it to put the resize method back the way the XlwMenu
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
3253 * class initializer put it. Motif screws with this when
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
3254 * the XlwMenu class gets instantiated.
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
3255 */
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
3256 void
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
3257 xlw_unmunge_class_resize (Widget w)
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
3258 {
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
3259 if (w->core.widget_class->core_class.resize != XlwMenuResize)
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
3260 w->core.widget_class->core_class.resize = XlwMenuResize;
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
3261 }
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
3262 #endif /* 0 */
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
3263