comparison lwlib/xlwmenu.c @ 70:131b0175ea99 r20-0b30

Import from CVS: tag r20-0b30
author cvs
date Mon, 13 Aug 2007 09:02:59 +0200
parents 56c54cf7c5b6
children c7528f8e288d
comparison
equal deleted inserted replaced
69:804d1389bcd6 70:131b0175ea99
13 but WITHOUT ANY WARRANTY; without even the implied warranty of 13 but WITHOUT ANY WARRANTY; without even the implied warranty of
14 MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the 14 MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
15 GNU General Public License for more details. 15 GNU General Public License for more details.
16 16
17 You should have received a copy of the GNU General Public License 17 You should have received a copy of the GNU General Public License
18 along with XEmacs; see the file COPYING. If not, write to 18 along with GNU Emacs; see the file COPYING. If not, write to
19 the Free Software Foundation, Inc., 59 Temple Place - Suite 330, 19 the Free Software Foundation, 675 Mass Ave, Cambridge, MA 02139, USA. */
20 Boston, MA 02111-1307, USA. */
21 20
22 /* Created by devin@lucid.com */ 21 /* Created by devin@lucid.com */
23 22
24 #include <stdlib.h> 23 #include <stdlib.h>
25 #include <unistd.h> 24 #include <unistd.h>
26 #include <string.h> 25 #include <string.h>
27 #include <ctype.h> 26 #include <ctype.h>
28 #include <stdio.h> 27 #include <stdio.h>
29 #include <limits.h>
30 28
31 #include <sys/types.h> 29 #include <sys/types.h>
32 #include <X11/Xos.h> 30 #include <X11/Xos.h>
33 #include <X11/IntrinsicP.h> 31 #include <X11/IntrinsicP.h>
34 #include <X11/StringDefs.h> 32 #include <X11/StringDefs.h>
53 { 51 {
54 #ifdef NEED_MOTIF 52 #ifdef NEED_MOTIF
55 /* There are three font list resources, so that we can accept either of 53 /* There are three font list resources, so that we can accept either of
56 the resources *fontList: or *font:, and so that we can tell the 54 the resources *fontList: or *font:, and so that we can tell the
57 difference between them being specified, and being defaulted to a 55 difference between them being specified, and being defaulted to a
58 font from the XtRString specified here. */ 56 font from the XtRString specified here.
57 */
59 {XmNfontList, XmCFontList, XmRFontList, sizeof(XmFontList), 58 {XmNfontList, XmCFontList, XmRFontList, sizeof(XmFontList),
60 offset(menu.font_list), XtRImmediate, (XtPointer)0}, 59 offset(menu.font_list), XtRImmediate, (XtPointer)0},
61 {XtNfont, XtCFont, XmRFontList, sizeof(XmFontList), 60 {XtNfont, XtCFont, XmRFontList, sizeof(XmFontList),
62 offset(menu.font_list_2),XtRImmediate, (XtPointer)0}, 61 offset(menu.font_list_2),XtRImmediate, (XtPointer)0},
63 {XmNfontList, XmCFontList, XmRFontList, sizeof(XmFontList), 62 {XmNfontList, XmCFontList, XmRFontList, sizeof(XmFontList),
64 offset(menu.fallback_font_list), 63 offset(menu.fallback_font_list),
65 /* We must use an iso8859-1 font here, or people without $LANG set lose. 64 /* We must use an iso8859-1 font here, or people without $LANG set lose.
66 It's fair to assume that those who do have $LANG set also have the 65 It's fair to assume that those who do have $LANG set also have the
67 *fontList resource set, or at least know how to deal with this. */ 66 *fontList resource set, or at least know how to deal with this.
68 XtRString, "-*-helvetica-bold-r-*-*-*-120-*-*-*-*-iso8859-1"}, 67 */
68 XtRString, (String) "-*-helvetica-bold-r-*-*-*-120-*-*-*-*-iso8859-1"},
69 #else 69 #else
70 {XtNfont, XtCFont, XtRFontStruct, sizeof(XFontStruct *), 70 {XtNfont, XtCFont, XtRFontStruct, sizeof(XFontStruct *),
71 offset(menu.font), XtRString, "XtDefaultFont"}, 71 offset(menu.font), XtRString, "XtDefaultFont"},
72 #endif 72 #endif
73 {XtNforeground, XtCForeground, XtRPixel, sizeof(Pixel), 73 {XtNforeground, XtCForeground, XtRPixel, sizeof(Pixel),
74 offset(menu.foreground), XtRString, "XtDefaultForeground"}, 74 offset(menu.foreground), XtRString, (String) "XtDefaultForeground"},
75 {XtNbuttonForeground, XtCButtonForeground, XtRPixel, sizeof(Pixel), 75 {XtNbuttonForeground, XtCButtonForeground, XtRPixel, sizeof(Pixel),
76 offset(menu.button_foreground), XtRString, "XtDefaultForeground"}, 76 offset(menu.button_foreground), XtRString, (String)"XtDefaultForeground"},
77 {XtNmargin, XtCMargin, XtRDimension, sizeof(Dimension), 77 {XtNmargin, XtCMargin, XtRDimension, sizeof(Dimension),
78 offset(menu.margin), XtRImmediate, (XtPointer)2}, 78 offset(menu.margin), XtRImmediate, (XtPointer)2},
79 {XmNmarginWidth, XmCMarginWidth, XtRDimension, sizeof(Dimension), 79 {XmNmarginWidth, XmCMarginWidth, XmRHorizontalDimension, sizeof(Dimension),
80 offset(menu.horizontal_margin), XtRImmediate, (XtPointer)2}, 80 offset(menu.horizontal_margin), XtRImmediate, (XtPointer)2},
81 {XmNmarginHeight, XmCMarginHeight, XtRDimension, sizeof(Dimension), 81 {XmNmarginHeight, XmCMarginHeight, XmRVerticalDimension, sizeof(Dimension),
82 offset(menu.vertical_margin), XtRImmediate, (XtPointer)1}, 82 offset(menu.vertical_margin), XtRImmediate, (XtPointer)1},
83 {XmNspacing, XmCSpacing, XtRDimension, sizeof(Dimension), 83 {XmNspacing, XmCSpacing, XmRHorizontalDimension, sizeof(Dimension),
84 offset(menu.column_spacing), XtRImmediate, (XtPointer)4}, 84 offset(menu.column_spacing), XtRImmediate, (XtPointer)4},
85 {XmNindicatorSize, XmCIndicatorSize, XtRDimension, sizeof(Dimension), 85 {XmNindicatorSize, XmCIndicatorSize, XtRDimension, sizeof(Dimension),
86 offset(menu.indicator_size), XtRImmediate, (XtPointer)0}, 86 offset(menu.indicator_size), XtRImmediate, (XtPointer)0},
87 {XmNshadowThickness, XmCShadowThickness, XtRDimension, 87 {XmNshadowThickness, XmCShadowThickness, XmRHorizontalDimension,
88 sizeof (Dimension), offset (menu.shadow_thickness), 88 sizeof (Dimension), offset (menu.shadow_thickness),
89 XtRImmediate, (XtPointer) 2}, 89 XtRImmediate, (XtPointer) 2},
90 {XmNselectColor, XmCSelectColor, XtRPixel, sizeof (Pixel), 90 {XmNselectColor, XmCSelectColor, XtRPixel, sizeof (Pixel),
91 offset (menu.select_color), XtRImmediate, (XtPointer)-1}, 91 offset (menu.select_color), XtRImmediate, (XtPointer)-1},
92 {XmNtopShadowColor, XmCTopShadowColor, XtRPixel, sizeof (Pixel), 92 {XmNtopShadowColor, XmCTopShadowColor, XtRPixel, sizeof (Pixel),
103 {XtNselect, XtCCallback, XtRCallback, sizeof(XtPointer), 103 {XtNselect, XtCCallback, XtRCallback, sizeof(XtPointer),
104 offset(menu.select), XtRCallback, (XtPointer)NULL}, 104 offset(menu.select), XtRCallback, (XtPointer)NULL},
105 {XtNmenu, XtCMenu, XtRPointer, sizeof(XtPointer), 105 {XtNmenu, XtCMenu, XtRPointer, sizeof(XtPointer),
106 offset(menu.contents), XtRImmediate, (XtPointer)NULL}, 106 offset(menu.contents), XtRImmediate, (XtPointer)NULL},
107 {XtNcursor, XtCCursor, XtRCursor, sizeof(Cursor), 107 {XtNcursor, XtCCursor, XtRCursor, sizeof(Cursor),
108 offset(menu.cursor_shape), XtRString, (XtPointer) "right_ptr"}, 108 offset(menu.cursor_shape), XtRString, (XtPointer)"right_ptr"},
109 {XtNhorizontal, XtCHorizontal, XtRInt, sizeof(int), 109 {XtNhorizontal, XtCHorizontal, XtRInt, sizeof(int),
110 offset(menu.horizontal), XtRImmediate, (XtPointer)True}, 110 offset(menu.horizontal), XtRImmediate, (XtPointer)True},
111 {XtNuseBackingStore, XtCUseBackingStore, XtRBoolean, sizeof (Boolean), 111 {XtNuseBackingStore, XtCUseBackingStore, XtRBoolean, sizeof (Boolean),
112 offset (menu.use_backing_store), XtRImmediate, (XtPointer)False}, 112 offset (menu.use_backing_store), XtRImmediate, (XtPointer)False},
113 {XtNbounceDown, XtCBounceDown, XtRBoolean, sizeof (Boolean), 113 {XtNbounceDown, XtCBounceDown, XtRBoolean, sizeof (Boolean),
126 static void XlwMenuInitialize (Widget request, Widget new, ArgList args, 126 static void XlwMenuInitialize (Widget request, Widget new, ArgList args,
127 Cardinal *num_args); 127 Cardinal *num_args);
128 static void XlwMenuDestroy (Widget w); 128 static void XlwMenuDestroy (Widget w);
129 static void XlwMenuClassInitialize (void); 129 static void XlwMenuClassInitialize (void);
130 static void Start (Widget w, XEvent *ev, String *params, Cardinal *num_params); 130 static void Start (Widget w, XEvent *ev, String *params, Cardinal *num_params);
131 static void Drag (Widget w, XEvent *ev, String *params, Cardinal *num_params); 131 static void Drag (Widget w, XEvent *ev, String *params, Cardinal *num_params);
132 static void Select(Widget w, XEvent *ev, String *params, Cardinal *num_params); 132 static void Select (Widget w, XEvent *ev, String *params,
133 Cardinal *num_params);
133 134
134 #ifdef NEED_MOTIF 135 #ifdef NEED_MOTIF
135 static XFontStruct *default_font_of_font_list (XmFontList); 136 static XFontStruct *default_font_of_font_list (XmFontList);
136 #endif 137 #endif
137 138
138 static XtActionsRec 139 static XtActionsRec
139 xlwMenuActionsList [] = 140 xlwMenuActionsList [] =
140 { 141 {
141 {"start", Start}, 142 {(String) "start", Start},
142 {"drag", Drag}, 143 {(String) "drag", Drag},
143 {"select", Select}, 144 {(String) "select", Select},
144 }; 145 };
145 146
146 #define SuperClass ((CoreWidgetClass)&coreClassRec) 147 #define SuperClass ((CoreWidgetClass)&coreClassRec)
147 148
148 XlwMenuClassRec xlwMenuClassRec = 149 XlwMenuClassRec xlwMenuClassRec =
149 { 150 {
150 { /* CoreClass fields initialization */ 151 { /* CoreClass fields initialization */
151 (WidgetClass) SuperClass, /* superclass */ 152 (WidgetClass) SuperClass, /* superclass */
152 "XlwMenu", /* class_name */ 153 (String) "XlwMenu", /* class_name */
153 sizeof(XlwMenuRec), /* size */ 154 sizeof(XlwMenuRec), /* size */
154 XlwMenuClassInitialize, /* class_initialize */ 155 XlwMenuClassInitialize, /* class_initialize */
155 NULL, /* class_part_initialize */ 156 NULL, /* class_part_initialize */
156 FALSE, /* class_inited */ 157 FALSE, /* class_inited */
157 XlwMenuInitialize, /* initialize */ 158 XlwMenuInitialize, /* initialize */
171 XlwMenuRedisplay, /* expose */ 172 XlwMenuRedisplay, /* expose */
172 XlwMenuSetValues, /* set_values */ 173 XlwMenuSetValues, /* set_values */
173 NULL, /* set_values_hook */ 174 NULL, /* set_values_hook */
174 XtInheritSetValuesAlmost, /* set_values_almost */ 175 XtInheritSetValuesAlmost, /* set_values_almost */
175 NULL, /* get_values_hook */ 176 NULL, /* get_values_hook */
176 NULL, /* #### - should this be set for */ 177 NULL, /* #### - should this be set for grabs? accept_focus */
177 /* grabs? accept_focus */
178 XtVersion, /* version */ 178 XtVersion, /* version */
179 NULL, /* callback_private */ 179 NULL, /* callback_private */
180 xlwMenuTranslations, /* tm_table */ 180 xlwMenuTranslations, /* tm_table */
181 XtInheritQueryGeometry, /* query_geometry */ 181 XtInheritQueryGeometry, /* query_geometry */
182 XtInheritDisplayAccelerator, /* display_accelerator */ 182 XtInheritDisplayAccelerator, /* display_accelerator */
211 211
212 static int 212 static int
213 allocate_nearest_color (Display *display, Colormap screen_colormap, 213 allocate_nearest_color (Display *display, Colormap screen_colormap,
214 XColor *color_def) 214 XColor *color_def)
215 { 215 {
216 int status = XAllocColor (display, screen_colormap, color_def); 216 int status;
217 if (status) 217
218 return status; 218 status = XAllocColor (display, screen_colormap, color_def);
219 219 if (!status)
220 { 220 {
221 /* If we got to this point, the colormap is full, so we're 221 /* If we got to this point, the colormap is full, so we're
222 going to try to get the next closest color. 222 going to try and get the next closest color.
223 The algorithm used is a least-squares matching, which is 223 The algorithm used is a least-squares matching, which is
224 what X uses for closest color matching with StaticColor visuals. */ 224 what X uses for closest color matching with StaticColor visuals. */
225 225
226 int nearest, x; 226 XColor *cells;
227 unsigned long nearest_delta = ULONG_MAX; 227 int no_cells;
228 228 int nearest;
229 int no_cells = XDisplayCells (display, XDefaultScreen (display)); 229 long nearest_delta, trial_delta;
230 int x;
231
232 no_cells = XDisplayCells (display, XDefaultScreen (display));
230 /* Don't use alloca here because lwlib doesn't have the 233 /* Don't use alloca here because lwlib doesn't have the
231 necessary configuration information that src does. */ 234 necessary configuration information that src does. */
232 XColor *cells = (XColor *) malloc (sizeof (XColor) * no_cells); 235 cells = (XColor *) malloc (sizeof (XColor) * no_cells);
233 236
234 for (x = 0; x < no_cells; x++) 237 for (x = 0; x < no_cells; x++)
235 cells[x].pixel = x; 238 cells[x].pixel = x;
236 239
237 XQueryColors (display, screen_colormap, cells, no_cells); 240 XQueryColors (display, screen_colormap, cells, no_cells);
238 241 nearest = 0;
239 for (nearest = 0, x = 0; x < no_cells; x++) 242 /* I'm assuming CSE so I'm not going to condense this. */
243 nearest_delta =
244 ((((color_def->red >> 8) - (cells[0].red >> 8))
245 * ((color_def->red >> 8) - (cells[0].red >> 8)))
246 +
247 (((color_def->green >> 8) - (cells[0].green >> 8))
248 * ((color_def->green >> 8) - (cells[0].green >> 8)))
249 +
250 (((color_def->blue >> 8) - (cells[0].blue >> 8))
251 * ((color_def->blue >> 8) - (cells[0].blue >> 8))));
252 for (x = 1; x < no_cells; x++)
240 { 253 {
241 long dred = (color_def->red >> 8) - (cells[x].red >> 8); 254 trial_delta =
242 long dgreen = (color_def->green >> 8) - (cells[x].green >> 8); 255 ((((color_def->red >> 8) - (cells[x].red >> 8))
243 long dblue = (color_def->blue >> 8) - (cells[x].blue >> 8); 256 * ((color_def->red >> 8) - (cells[x].red >> 8)))
244 unsigned long delta = dred * dred + dgreen * dgreen + dblue * dblue; 257 +
245 258 (((color_def->green >> 8) - (cells[x].green >> 8))
246 if (delta < nearest_delta) 259 * ((color_def->green >> 8) - (cells[x].green >> 8)))
260 +
261 (((color_def->blue >> 8) - (cells[x].blue >> 8))
262 * ((color_def->blue >> 8) - (cells[x].blue >> 8))));
263 if (trial_delta < nearest_delta)
247 { 264 {
248 nearest = x; 265 nearest = x;
249 nearest_delta = delta; 266 nearest_delta = trial_delta;
250 } 267 }
251 } 268 }
252 color_def->red = cells[nearest].red; 269 color_def->red = cells[nearest].red;
253 color_def->green = cells[nearest].green; 270 color_def->green = cells[nearest].green;
254 color_def->blue = cells[nearest].blue; 271 color_def->blue = cells[nearest].blue;
272 status = XAllocColor (display, screen_colormap, color_def);
273
255 free (cells); 274 free (cells);
256 return XAllocColor (display, screen_colormap, color_def); 275 }
257 } 276
277 return status;
258 } 278 }
259 279
260 static void 280 static void
261 push_new_stack (XlwMenuWidget mw, widget_value *val) 281 push_new_stack (XlwMenuWidget mw, widget_value *val)
262 { 282 {
269 } 289 }
270 else if (mw->menu.new_depth == mw->menu.new_stack_length) 290 else if (mw->menu.new_depth == mw->menu.new_stack_length)
271 { 291 {
272 mw->menu.new_stack_length *= 2; 292 mw->menu.new_stack_length *= 2;
273 mw->menu.new_stack = 293 mw->menu.new_stack =
274 (widget_value**)XtRealloc ((char *)mw->menu.new_stack, 294 (widget_value**)XtRealloc ((char*)mw->menu.new_stack,
275 mw->menu.new_stack_length * 295 mw->menu.new_stack_length *
276 sizeof (widget_value*)); 296 sizeof (widget_value*));
277 } 297 }
278 mw->menu.new_stack [mw->menu.new_depth++] = val; 298 mw->menu.new_stack [mw->menu.new_depth++] = val;
279 } 299 }
280 300
281 static void 301 static void
282 pop_new_stack_if_no_contents (XlwMenuWidget mw) 302 pop_new_stack_if_no_contents (XlwMenuWidget mw)
283 { 303 {
284 if (mw->menu.new_depth && 304 if (mw->menu.new_depth)
285 !mw->menu.new_stack [mw->menu.new_depth - 1]->contents) 305 {
286 mw->menu.new_depth -= 1; 306 if (!mw->menu.new_stack [mw->menu.new_depth - 1]->contents)
307 {
308 mw->menu.new_depth -= 1;
309 }
310 }
287 } 311 }
288 312
289 static void 313 static void
290 make_old_stack_space (XlwMenuWidget mw, int n) 314 make_old_stack_space (XlwMenuWidget mw, int n)
291 { 315 {
298 } 322 }
299 else if (mw->menu.old_stack_length < n) 323 else if (mw->menu.old_stack_length < n)
300 { 324 {
301 mw->menu.old_stack_length *= 2; 325 mw->menu.old_stack_length *= 2;
302 mw->menu.old_stack = 326 mw->menu.old_stack =
303 (widget_value**)XtRealloc ((char *)mw->menu.old_stack, 327 (widget_value**)XtRealloc ((char*)mw->menu.old_stack,
304 mw->menu.old_stack_length * 328 mw->menu.old_stack_length *
305 sizeof (widget_value*)); 329 sizeof (widget_value*));
306 } 330 }
307 } 331 }
308 332
309 static Boolean 333 static Boolean
310 close_to_reference_time(Widget w, Time reference_time, XEvent *ev) 334 close_to_reference_time(Widget w, Time reference_time, XEvent *ev)
311 { 335 {
312 return 336 return (reference_time &&
313 reference_time && 337 (ev->xbutton.time - reference_time
314 (ev->xbutton.time - reference_time < XtGetMultiClickTime (XtDisplay (w))); 338 < XtGetMultiClickTime (XtDisplay (w))));
315 } 339 }
316 340
317 /* Size code */ 341 /* Size code */
318 static int 342 static int
319 string_width (XlwMenuWidget mw, 343 string_width (XlwMenuWidget mw,
334 XTextExtents (mw->menu.font, s, strlen (s), &drop, &drop, &drop, &xcs); 358 XTextExtents (mw->menu.font, s, strlen (s), &drop, &drop, &drop, &xcs);
335 return xcs.width; 359 return xcs.width;
336 #endif 360 #endif
337 } 361 }
338 362
363 static char massaged_resource_char[256];
364
365 static void
366 Initialize_massaged_resource_char (void)
367 {
368 int j;
369 for (j = 0; j < sizeof (massaged_resource_char); j++)
370 {
371 if ((j >= 'a' && j <= 'z') ||
372 (j >= 'A' && j <= 'Z') ||
373 (j >= '0' && j <= '9') ||
374 (j == '_') ||
375 (j >= 0xa0))
376 massaged_resource_char[j] = (char) j;
377 }
378 massaged_resource_char ['_'] = '_';
379 massaged_resource_char ['+'] = 'P'; /* Convert C++ to cPP */
380 massaged_resource_char ['.'] = '_'; /* Convert Buffers... to buffers___ */
381 }
382
339 static void 383 static void
340 massage_resource_name (CONST char *in, char *out) 384 massage_resource_name (CONST char *in, char *out)
341 { 385 {
342 /* Turn a random string into something suitable for using as a resource. 386 /* Turn a random string into something suitable for using as a resource.
343 For example: 387 For example:
344 388
345 "Kill Buffer" -> "killBuffer" 389 "Kill Buffer" -> "killBuffer"
346 "Find File..." -> "findFile" 390 "Find File..." -> "findFile___"
347 "Search and Replace..." -> "searchAndReplace" 391 "Search and Replace..." -> "searchAndReplace___"
348 "C++ Mode Commands" -> "cppModeCommands" 392 "C++ Mode Commands" -> "cppModeCommands"
393
394 Valid characters in a resource NAME component are: a-zA-Z0-9_
349 */ 395 */
350 396
351 # define GOOD_CHAR(c) (((c) >= 'a' && (c) <= 'z') || \ 397 #ifdef PRINT_XLWMENU_RESOURCE_CONVERSIONS
352 ((c) >= 'A' && (c) <= 'Z') || \ 398 /* Compile with -DPRINT_XLWMENU_RESOURCE_CONVERSIONS to generate a
353 ((c) >= '0' && (c) <= '9') || \ 399 translation file for menu localizations. */
354 ((c) == '_') || \ 400 char *save_in = in, *save_out = out;
355 ((c) > 0240)) 401 #endif
356 int firstp = 1; 402
403 Boolean firstp = True;
357 while (*in) 404 while (*in)
358 { 405 {
359 if (GOOD_CHAR ((unsigned char) *in)) 406 char ch = massaged_resource_char[(unsigned char) *in++];
407 if (ch)
360 { 408 {
361 if (firstp) 409 *out++ = firstp ? tolower (ch) : toupper (ch);
362 *out = tolower (*in); 410 firstp = False;
363 else 411 while ((ch = massaged_resource_char[(unsigned char) *in++]) != NULL)
364 *out = toupper (*in); 412 *out++ = ch;
365 firstp = 0; 413 if (!*(in-1)) /* Overshot the NULL byte? */
366 in++; 414 break;
367 out++;
368 while (GOOD_CHAR ((unsigned char) *in))
369 {
370 *out = *in;
371 in++;
372 out++;
373 }
374 } 415 }
375 else if ((unsigned char)*in == '+') 416 }
376 { 417 *out = 0;
377 /* for char '+' convert to 'P', e.g for C++ to cPP */ 418
378 *out = 'P';
379 in++;
380 out++;
381 }
382 else
383 {
384 /* A bogus char between words; skip it. */
385 in++;
386 }
387 }
388
389 /* Add the following define to --cflags to generate a translation
390 file for menu localizations */
391 #ifdef PRINT_XLWMENU_RESOURCE_CONVERSIONS 419 #ifdef PRINT_XLWMENU_RESOURCE_CONVERSIONS
392 printf("Emacs*XlwMenu.%s.labelString:\t%s\n", outpointer, inpointer); 420 printf("! Emacs*XlwMenu.%s.labelString:\t%s\n", save_out, save_in);
421 printf( "Emacs*XlwMenu.%s.labelString:\n", save_out);
393 #endif 422 #endif
394 *out = 0;
395 #undef GOOD_CHAR
396 } 423 }
397 424
398 static XtResource 425 static XtResource
399 nameResource[] = 426 nameResource[] =
400 { 427 {
401 { "labelString", "LabelString", XtRString, sizeof(String), 428 { (String) "labelString", (String) "LabelString", XtRString, sizeof(String),
402 0, XtRImmediate, 0 } 429 0, XtRImmediate, 0 }
403 }; 430 };
404 431
405 /* 432 /*
406 * This function looks through string searching for parameter 433 * This function looks through string searching for parameter
435 462
436 for (ntimes = 1, result = (char *) string; (percent = strchr(result, '%')); 463 for (ntimes = 1, result = (char *) string; (percent = strchr(result, '%'));
437 ntimes++) 464 ntimes++)
438 result = &percent[1]; 465 result = &percent[1];
439 466
440 result = XtMalloc ((ntimes * strlen(value)) + strlen(string) + 4); 467 result = XtMalloc((ntimes * strlen(value)) + strlen(string) + 4);
441 result[0] = '\0'; 468 result[0] = '\0';
442 469
443 while ((percent = strchr(string, '%'))) 470 while ((percent = strchr(string, '%')))
444 { 471 {
445 unsigned left_pad; 472 unsigned left_pad;
572 XtFree (converted_name); 599 XtFree (converted_name);
573 600
574 val->toolkit_data = complete_name; 601 val->toolkit_data = complete_name;
575 val->free_toolkit_data = True; 602 val->free_toolkit_data = True;
576 } 603 }
577 return (XmString) val->toolkit_data; 604 return ((XmString) val->toolkit_data);
578 } 605 }
579 606
580 /* Unused */ 607 /* Unused */
581 #if 0 608 #if 0
582 /* 609 /*
597 XtGetSubresources (w, 624 XtGetSubresources (w,
598 (XtPointer)&string, 625 (XtPointer)&string,
599 name, 626 name,
600 name, 627 name,
601 nameResource, 1, 628 nameResource, 1,
602 NULL, 0); 629 NULL, 0
630 );
603 631
604 if (!string) 632 if (!string)
605 string = name; 633 string = name;
606 634
607 return parameterize_string (string, arg); 635 return parameterize_string (string, arg);
652 if (complete_name[0] == '\n') 680 if (complete_name[0] == '\n')
653 complete_name[0] = ' '; 681 complete_name[0] = ' ';
654 } 682 }
655 val->free_toolkit_data = True; 683 val->free_toolkit_data = True;
656 } 684 }
657 return (char *) val->toolkit_data; 685 return (char*)val->toolkit_data;
658 } 686 }
659 687
660 #endif /* !Motif */ 688 #endif /* !Motif */
661 689
662 /* 690 /*
663 * Code for drawing strings. 691 * Code for drawing strings.
664 */ 692 */
665 static void 693 static void
666 string_draw(XlwMenuWidget mw, 694 string_draw(
695 XlwMenuWidget mw,
667 Window window, 696 Window window,
668 int x, int y, 697 int x, int y,
669 GC gc, 698 GC gc,
670 #ifdef NEED_MOTIF 699 #ifdef NEED_MOTIF
671 XmString string 700 XmString string
672 #else 701 #else
673 char *string 702 char *string
674 #endif 703 #endif
675 ) 704 ) {
676 {
677 #ifdef NEED_MOTIF 705 #ifdef NEED_MOTIF
678 XmStringDraw (XtDisplay (mw), window, 706 XmStringDraw (XtDisplay (mw), window,
679 mw->menu.font_list, 707 mw->menu.font_list,
680 string, gc, 708 string, gc,
681 x, y, 709 x, y,
704 732
705 /* 733 /*
706 * Low level code for drawing 3-D edges. 734 * Low level code for drawing 3-D edges.
707 */ 735 */
708 static void 736 static void
709 shadow_rectangle_draw (Display *dpy, 737 shadow_rectangle_draw (
738 Display *dpy,
710 Window window, 739 Window window,
711 GC top_gc, 740 GC top_gc,
712 GC bottom_gc, 741 GC bottom_gc,
713 int x, int y, unsigned width, unsigned height, 742 int x, int y, unsigned width, unsigned height,
714 unsigned thickness) 743 unsigned thickness
744 )
715 { 745 {
716 XPoint points [4]; 746 XPoint points [4];
717 747
718 if (!thickness) 748 if (!thickness)
719 return; 749 return;
780 810
781 static void 811 static void
782 shadow_draw (XlwMenuWidget mw, 812 shadow_draw (XlwMenuWidget mw,
783 Window window, 813 Window window,
784 int x, int y, unsigned width, unsigned height, 814 int x, int y, unsigned width, unsigned height,
785 shadow_type type) 815 shadow_type type
816 )
786 { 817 {
787 Display *dpy = XtDisplay (mw); 818 Display *dpy = XtDisplay (mw);
788 GC top_gc; 819 GC top_gc;
789 GC bottom_gc; 820 GC bottom_gc;
790 int thickness = mw->menu.shadow_thickness; 821 int thickness = mw->menu.shadow_thickness;
820 } 851 }
821 852
822 if (etched) 853 if (etched)
823 { 854 {
824 unsigned half = thickness/2; 855 unsigned half = thickness/2;
825 shadow_rectangle_draw (dpy, 856 shadow_rectangle_draw (
857 dpy,
826 window, 858 window,
827 top_gc, 859 top_gc,
828 top_gc, 860 top_gc,
829 x, y, 861 x, y,
830 width - half, height - half, 862 width - half, height - half,
831 thickness - half); 863 thickness - half
832 shadow_rectangle_draw (dpy, 864 );
865 shadow_rectangle_draw (
866 dpy,
833 window, 867 window,
834 bottom_gc, 868 bottom_gc,
835 bottom_gc, 869 bottom_gc,
836 x + half, y + half, 870 x + half, y + half,
837 width - half , height - half, 871 width - half , height - half,
838 half); 872 half
873 );
839 } 874 }
840 else 875 else
841 { 876 {
842 shadow_rectangle_draw (dpy, 877 shadow_rectangle_draw (
878 dpy,
843 window, 879 window,
844 top_gc, 880 top_gc,
845 bottom_gc, 881 bottom_gc,
846 x, y, 882 x, y,
847 width, height, 883 width, height,
848 thickness); 884 thickness
885 );
849 } 886 }
850 } 887 }
851 888
852 static void 889 static void
853 arrow_decoration_draw (XlwMenuWidget mw, 890 arrow_decoration_draw (
891 XlwMenuWidget mw,
854 Window window, 892 Window window,
855 int x, int y, 893 int x, int y,
856 unsigned width, 894 unsigned width,
857 Boolean raised) 895 Boolean raised
896 )
858 { 897 {
859 Display *dpy = XtDisplay (mw); 898 Display *dpy = XtDisplay (mw);
860 GC top_gc; 899 GC top_gc;
861 GC bottom_gc; 900 GC bottom_gc;
862 GC select_gc; 901 GC select_gc;
873 912
874 select_gc = mw->menu.background_gc; 913 select_gc = mw->menu.background_gc;
875 914
876 if (raised) 915 if (raised)
877 { 916 {
878 top_gc = mw->menu.shadow_bottom_gc; 917 top_gc = mw->menu.shadow_bottom_gc;
879 bottom_gc = mw->menu.shadow_top_gc; 918 bottom_gc = mw->menu.shadow_top_gc;
880 } 919 }
881 else 920 else
882 { 921 {
883 top_gc = mw->menu.shadow_top_gc; 922 top_gc = mw->menu.shadow_top_gc;
884 bottom_gc = mw->menu.shadow_bottom_gc; 923 bottom_gc = mw->menu.shadow_bottom_gc;
885 } 924 }
886 925
887 /* 926 /*
888 * Fill internal area, we do this first so that the borders 927 * Fill internal area, we do this first so that the borders
895 points [2].x = x + length - thickness; 934 points [2].x = x + length - thickness;
896 points [2].y = y + half_width + thickness; 935 points [2].y = y + half_width + thickness;
897 points [3].x = x + thickness; 936 points [3].x = x + thickness;
898 points [3].y = y + width - thickness; 937 points [3].y = y + width - thickness;
899 938
900 XFillPolygon (dpy, 939 XFillPolygon (
940 dpy,
901 window, 941 window,
902 select_gc, 942 select_gc,
903 points, 943 points,
904 4, 944 4,
905 Convex, 945 Convex,
906 CoordModeOrigin); 946 CoordModeOrigin
947 );
907 948
908 /* left border */ 949 /* left border */
909 points [0].x = x; 950 points [0].x = x;
910 points [0].y = y; 951 points [0].y = y;
911 points [1].x = x + thickness; 952 points [1].x = x + thickness;
941 982
942 XFillPolygon (dpy, window, top_gc, points, 4, Convex, CoordModeOrigin); 983 XFillPolygon (dpy, window, top_gc, points, 4, Convex, CoordModeOrigin);
943 } 984 }
944 985
945 static void 986 static void
946 toggle_decoration_draw (XlwMenuWidget mw, 987 toggle_decoration_draw (
988 XlwMenuWidget mw,
947 Window window, 989 Window window,
948 int x, int y, 990 int x, int y,
949 unsigned width, 991 unsigned width,
950 Boolean set) 992 Boolean set
993 )
951 { 994 {
952 Display *dpy = XtDisplay (mw); 995 Display *dpy = XtDisplay (mw);
953 int thickness = mw->menu.shadow_thickness; 996 int thickness = mw->menu.shadow_thickness;
954 shadow_type type; 997 shadow_type type;
955 GC select_gc = mw->menu.select_gc; 998 GC select_gc = mw->menu.select_gc;
961 1004
962 /* 1005 /*
963 * Fill internal area. 1006 * Fill internal area.
964 */ 1007 */
965 if (set) 1008 if (set)
966 XFillRectangle (dpy, 1009 XFillRectangle (
1010 dpy,
967 window, 1011 window,
968 select_gc, 1012 select_gc,
969 x + thickness, 1013 x + thickness,
970 y + thickness, 1014 y + thickness,
971 width - (2*thickness), 1015 width - (2*thickness),
972 width - (2*thickness)); 1016 width - (2*thickness)
1017 );
973 1018
974 shadow_draw(mw, window, x, y, width, width, type); 1019 shadow_draw(mw, window, x, y, width, width, type);
975 } 1020 }
976 1021
977 static void 1022 static void
978 radio_decoration_draw (XlwMenuWidget mw, 1023 radio_decoration_draw (
1024 XlwMenuWidget mw,
979 Window window, 1025 Window window,
980 int x, int y, 1026 int x, int y,
981 unsigned width, 1027 unsigned width,
982 Boolean enabled) 1028 Boolean enabled
1029 )
983 { 1030 {
984 Display *dpy = XtDisplay (mw); 1031 Display *dpy = XtDisplay (mw);
985 GC top_gc; 1032 GC top_gc;
986 GC bottom_gc; 1033 GC bottom_gc;
987 GC select_gc = mw->menu.select_gc; 1034 GC select_gc = mw->menu.select_gc;
997 1044
998 half_width = width/2; 1045 half_width = width/2;
999 1046
1000 if (enabled) 1047 if (enabled)
1001 { 1048 {
1002 top_gc = mw->menu.shadow_bottom_gc; 1049 top_gc = mw->menu.shadow_bottom_gc;
1003 bottom_gc = mw->menu.shadow_top_gc; 1050 bottom_gc = mw->menu.shadow_top_gc;
1004 } 1051 }
1005 else 1052 else
1006 { 1053 {
1007 top_gc = mw->menu.shadow_top_gc; 1054 top_gc = mw->menu.shadow_top_gc;
1008 bottom_gc = mw->menu.shadow_bottom_gc; 1055 bottom_gc = mw->menu.shadow_bottom_gc;
1009 } 1056 }
1010 1057
1011 #if 1 1058 #if 1
1012 /* 1059 /*
1115 window, 1162 window,
1116 select_gc, 1163 select_gc,
1117 points, 1164 points,
1118 4, 1165 4,
1119 Convex, 1166 Convex,
1120 CoordModeOrigin); 1167 CoordModeOrigin
1121 } 1168 );
1122 } 1169 }
1123 1170 }
1124 static void 1171
1125 separator_decoration_draw (XlwMenuWidget mw, 1172 static void
1173 separator_decoration_draw (
1174 XlwMenuWidget mw,
1126 Window window, 1175 Window window,
1127 int x, int y, 1176 int x, int y,
1128 unsigned width, 1177 unsigned width,
1129 Boolean vertical, 1178 Boolean vertical,
1130 shadow_type type) 1179 shadow_type type
1180 )
1131 { 1181 {
1132 Display *dpy = XtDisplay (mw); 1182 Display *dpy = XtDisplay (mw);
1133 GC top_gc; 1183 GC top_gc;
1134 GC bottom_gc; 1184 GC bottom_gc;
1135 unsigned offset = 0; 1185 unsigned offset = 0;
1207 { 1257 {
1208 for (i = 0; i < top_line_thickness; i++) 1258 for (i = 0; i < top_line_thickness; i++)
1209 XDrawLine (dpy, window, top_gc, x, y + i, x + width, y + i); 1259 XDrawLine (dpy, window, top_gc, x, y + i, x + width, y + i);
1210 1260
1211 for (i = 0; i < bottom_line_thickness; i++) 1261 for (i = 0; i < bottom_line_thickness; i++)
1212 XDrawLine (dpy, window, bottom_gc, 1262 XDrawLine (
1263 dpy, window, bottom_gc,
1213 x, y + top_line_thickness + offset + i, 1264 x, y + top_line_thickness + offset + i,
1214 x + width, y + top_line_thickness + offset + i); 1265 x + width, y + top_line_thickness + offset + i
1266 );
1215 y += (top_line_thickness + offset + bottom_line_thickness + 1); 1267 y += (top_line_thickness + offset + bottom_line_thickness + 1);
1216 } 1268 }
1217 1269
1218 if (dashed) 1270 if (dashed)
1219 { 1271 {
1314 #endif 1366 #endif
1315 } 1367 }
1316 } 1368 }
1317 1369
1318 static void 1370 static void
1319 label_button_size (XlwMenuWidget mw, 1371 label_button_size (
1372 XlwMenuWidget mw,
1320 widget_value *val, 1373 widget_value *val,
1321 Boolean in_menubar, 1374 Boolean in_menubar,
1322 unsigned *toggle_width, 1375 unsigned *toggle_width,
1323 unsigned *label_width, 1376 unsigned *label_width,
1324 unsigned *bindings_width, 1377 unsigned *bindings_width,
1325 unsigned *height) 1378 unsigned *height
1379 )
1326 { 1380 {
1327 *height = (mw->menu.font_ascent + mw->menu.font_descent + 1381 *height = (mw->menu.font_ascent + mw->menu.font_descent +
1328 2 * mw->menu.vertical_margin + 1382 2 * mw->menu.vertical_margin +
1329 2 * mw->menu.shadow_thickness); 1383 2 * mw->menu.shadow_thickness);
1330 /* no left column decoration */ 1384 /* no left column decoration */
1333 *label_width = string_width (mw, resource_widget_value (mw, val)); 1387 *label_width = string_width (mw, resource_widget_value (mw, val));
1334 *bindings_width = mw->menu.horizontal_margin + mw->menu.shadow_thickness; 1388 *bindings_width = mw->menu.horizontal_margin + mw->menu.shadow_thickness;
1335 } 1389 }
1336 1390
1337 static void 1391 static void
1338 label_button_draw (XlwMenuWidget mw, 1392 label_button_draw (
1393 XlwMenuWidget mw,
1339 widget_value *val, 1394 widget_value *val,
1340 Boolean in_menubar, 1395 Boolean in_menubar,
1341 Boolean highlighted, 1396 Boolean highlighted,
1342 Window window, 1397 Window window,
1343 int x, int y, 1398 int x, int y,
1344 unsigned width, 1399 unsigned width,
1345 unsigned height, 1400 unsigned height,
1346 unsigned label_offset, 1401 unsigned label_offset,
1347 unsigned binding_tab) 1402 unsigned binding_tab
1403 )
1348 { 1404 {
1349 int y_offset = mw->menu.shadow_thickness + mw->menu.vertical_margin; 1405 int y_offset = mw->menu.shadow_thickness + mw->menu.vertical_margin;
1350 1406
1351 if (!label_offset) 1407 if (!label_offset)
1352 label_offset = mw->menu.shadow_thickness + mw->menu.horizontal_margin; 1408 label_offset = mw->menu.shadow_thickness + mw->menu.horizontal_margin;
1353 1409
1354 /* 1410 /*
1355 * Draw the label string. 1411 * Draw the label string.
1356 */ 1412 */
1357 string_draw (mw, 1413 string_draw (
1414 mw,
1358 window, 1415 window,
1359 x + label_offset, y + y_offset, 1416 x + label_offset, y + y_offset,
1360 mw->menu.foreground_gc, 1417 mw->menu.foreground_gc,
1361 resource_widget_value (mw, val)); 1418 resource_widget_value (mw, val)
1362 } 1419 );
1363 1420 }
1364 static void 1421
1365 push_button_size (XlwMenuWidget mw, 1422 static void
1423 push_button_size (
1424 XlwMenuWidget mw,
1366 widget_value *val, 1425 widget_value *val,
1367 Boolean in_menubar, 1426 Boolean in_menubar,
1368 unsigned *toggle_width, 1427 unsigned *toggle_width,
1369 unsigned *label_width, 1428 unsigned *label_width,
1370 unsigned *bindings_width, 1429 unsigned *bindings_width,
1371 unsigned *height) 1430 unsigned *height
1431 )
1372 { 1432 {
1373 /* inherit */ 1433 /* inherit */
1374 label_button_size (mw, val, in_menubar, 1434 label_button_size (
1435 mw, val, in_menubar,
1375 toggle_width, label_width, bindings_width, 1436 toggle_width, label_width, bindings_width,
1376 height); 1437 height
1438 );
1377 1439
1378 /* key bindings to display? */ 1440 /* key bindings to display? */
1379 if (!in_menubar && val->key) 1441 if (!in_menubar && val->key)
1380 { 1442 {
1381 int w; 1443 int w;
1390 *bindings_width += w + mw->menu.column_spacing; 1452 *bindings_width += w + mw->menu.column_spacing;
1391 } 1453 }
1392 } 1454 }
1393 1455
1394 static void 1456 static void
1395 push_button_draw (XlwMenuWidget mw, 1457 push_button_draw (
1458 XlwMenuWidget mw,
1396 widget_value *val, 1459 widget_value *val,
1397 Boolean in_menubar, 1460 Boolean in_menubar,
1398 Boolean highlighted, 1461 Boolean highlighted,
1399 Window window, 1462 Window window,
1400 int x, int y, 1463 int x, int y,
1401 unsigned width, unsigned height, 1464 unsigned width, unsigned height,
1402 unsigned label_offset, 1465 unsigned label_offset,
1403 unsigned binding_offset) 1466 unsigned binding_offset
1467 )
1404 { 1468 {
1405 int y_offset = mw->menu.shadow_thickness + mw->menu.vertical_margin; 1469 int y_offset = mw->menu.shadow_thickness + mw->menu.vertical_margin;
1406 GC gc; 1470 GC gc;
1407 shadow_type type; 1471 shadow_type type;
1408 Boolean menu_pb = in_menubar && (menu_item_type (val) == BUTTON_TYPE); 1472 Boolean menu_pb = in_menubar && (menu_item_type (val) == BUTTON_TYPE);
1426 gc = mw->menu.foreground_gc; 1490 gc = mw->menu.foreground_gc;
1427 else 1491 else
1428 gc = mw->menu.inactive_gc; 1492 gc = mw->menu.inactive_gc;
1429 } 1493 }
1430 1494
1431 string_draw (mw, 1495 string_draw (
1496 mw,
1432 window, 1497 window,
1433 x + label_offset, y + y_offset, 1498 x + label_offset, y + y_offset,
1434 gc, 1499 gc,
1435 resource_widget_value(mw, val)); 1500 resource_widget_value(mw, val)
1501 );
1436 1502
1437 /* 1503 /*
1438 * Draw the keybindings 1504 * Draw the keybindings
1439 */ 1505 */
1440 if (val->key) 1506 if (val->key)
1483 1549
1484 return result; 1550 return result;
1485 } 1551 }
1486 1552
1487 static void 1553 static void
1488 cascade_button_size (XlwMenuWidget mw, 1554 cascade_button_size (
1555 XlwMenuWidget mw,
1489 widget_value *val, 1556 widget_value *val,
1490 Boolean in_menubar, 1557 Boolean in_menubar,
1491 unsigned *toggle_width, 1558 unsigned *toggle_width,
1492 unsigned *label_width, 1559 unsigned *label_width,
1493 unsigned *arrow_width, 1560 unsigned *arrow_width,
1494 unsigned *height) 1561 unsigned *height
1562 )
1495 { 1563 {
1496 /* inherit */ 1564 /* inherit */
1497 label_button_size (mw, val, in_menubar, 1565 label_button_size (
1566 mw, val, in_menubar,
1498 toggle_width, label_width, arrow_width, 1567 toggle_width, label_width, arrow_width,
1499 height); 1568 height
1569 );
1500 /* we have a pull aside arrow */ 1570 /* we have a pull aside arrow */
1501 if (!in_menubar) 1571 if (!in_menubar)
1502 { 1572 {
1503 *arrow_width += arrow_decoration_height(mw) + mw->menu.column_spacing; 1573 *arrow_width += arrow_decoration_height(mw) + mw->menu.column_spacing;
1504 } 1574 }
1505 } 1575 }
1506 1576
1507 static void 1577 static void
1508 cascade_button_draw (XlwMenuWidget mw, 1578 cascade_button_draw (
1579 XlwMenuWidget mw,
1509 widget_value *val, 1580 widget_value *val,
1510 Boolean in_menubar, 1581 Boolean in_menubar,
1511 Boolean highlighted, 1582 Boolean highlighted,
1512 Window window, 1583 Window window,
1513 int x, int y, 1584 int x, int y,
1514 unsigned width, unsigned height, 1585 unsigned width, unsigned height,
1515 unsigned label_offset, 1586 unsigned label_offset,
1516 unsigned binding_offset) 1587 unsigned binding_offset
1588 )
1517 { 1589 {
1518 shadow_type type; 1590 shadow_type type;
1519 1591
1520 /* 1592 /*
1521 * Draw the label string. 1593 * Draw the label string.
1544 mw->menu.horizontal_margin; 1616 mw->menu.horizontal_margin;
1545 1617
1546 binding_offset = label_offset + s_width + mw->menu.shadow_thickness; 1618 binding_offset = label_offset + s_width + mw->menu.shadow_thickness;
1547 } 1619 }
1548 1620
1549 arrow_decoration_draw (mw, 1621 arrow_decoration_draw (
1622 mw,
1550 window, 1623 window,
1551 x + binding_offset + mw->menu.column_spacing, 1624 x + binding_offset + mw->menu.column_spacing,
1552 y + y_offset, 1625 y + y_offset,
1553 arrow_height, 1626 arrow_height,
1554 highlighted); 1627 highlighted
1628 );
1555 } 1629 }
1556 1630
1557 /* 1631 /*
1558 * Draw the shadow 1632 * Draw the shadow
1559 */ 1633 */
1579 1653
1580 return rv; 1654 return rv;
1581 } 1655 }
1582 1656
1583 static void 1657 static void
1584 toggle_button_size (XlwMenuWidget mw, 1658 toggle_button_size (
1659 XlwMenuWidget mw,
1585 widget_value *val, 1660 widget_value *val,
1586 Boolean in_menubar, 1661 Boolean in_menubar,
1587 unsigned *toggle_width, 1662 unsigned *toggle_width,
1588 unsigned *label_width, 1663 unsigned *label_width,
1589 unsigned *bindings_width, 1664 unsigned *bindings_width,
1590 unsigned *height) 1665 unsigned *height
1666 )
1591 { 1667 {
1592 /* inherit */ 1668 /* inherit */
1593 push_button_size (mw, val, in_menubar, 1669 push_button_size (
1670 mw, val, in_menubar,
1594 toggle_width, label_width, bindings_width, 1671 toggle_width, label_width, bindings_width,
1595 height); 1672 height
1673 );
1596 /* we have a toggle */ 1674 /* we have a toggle */
1597 *toggle_width += toggle_decoration_height(mw) + mw->menu.column_spacing; 1675 *toggle_width += toggle_decoration_height(mw) + mw->menu.column_spacing;
1598 } 1676 }
1599 1677
1600 static void 1678 static void
1601 toggle_button_draw (XlwMenuWidget mw, 1679 toggle_button_draw (
1680 XlwMenuWidget mw,
1602 widget_value *val, 1681 widget_value *val,
1603 Boolean in_menubar, 1682 Boolean in_menubar,
1604 Boolean highlighted, 1683 Boolean highlighted,
1605 Window window, 1684 Window window,
1606 int x, int y, 1685 int x, int y,
1607 unsigned width, unsigned height, 1686 unsigned width, unsigned height,
1608 unsigned label_tab, 1687 unsigned label_tab,
1609 unsigned binding_tab) 1688 unsigned binding_tab
1689 )
1610 { 1690 {
1611 int x_offset; 1691 int x_offset;
1612 int y_offset; 1692 int y_offset;
1613 unsigned t_height = toggle_decoration_height(mw); 1693 unsigned t_height = toggle_decoration_height(mw);
1614 1694
1634 { 1714 {
1635 return toggle_decoration_height(mw); 1715 return toggle_decoration_height(mw);
1636 } 1716 }
1637 1717
1638 static void 1718 static void
1639 radio_button_draw (XlwMenuWidget mw, 1719 radio_button_draw (
1720 XlwMenuWidget mw,
1640 widget_value *val, 1721 widget_value *val,
1641 Boolean in_menubar, 1722 Boolean in_menubar,
1642 Boolean highlighted, 1723 Boolean highlighted,
1643 Window window, 1724 Window window,
1644 int x, int y, 1725 int x, int y,
1645 unsigned width, unsigned height, 1726 unsigned width, unsigned height,
1646 unsigned label_tab, 1727 unsigned label_tab,
1647 unsigned binding_tab) 1728 unsigned binding_tab
1729 )
1648 { 1730 {
1649 int x_offset; 1731 int x_offset;
1650 int y_offset; 1732 int y_offset;
1651 unsigned r_height = radio_decoration_height(mw); 1733 unsigned r_height = radio_decoration_height(mw);
1652 1734
1736 widget_value *val, 1818 widget_value *val,
1737 Boolean in_menubar, 1819 Boolean in_menubar,
1738 unsigned *toggle_width, 1820 unsigned *toggle_width,
1739 unsigned *label_width, 1821 unsigned *label_width,
1740 unsigned *rest_width, 1822 unsigned *rest_width,
1741 unsigned *height) 1823 unsigned *height
1824 )
1742 { 1825 {
1743 *height = separator_decoration_height (mw, val); 1826 *height = separator_decoration_height (mw, val);
1744 *label_width = 1; 1827 *label_width = 1;
1745 *toggle_width = *rest_width = 0; 1828 *toggle_width = *rest_width = 0;
1746 } 1829 }
1752 Boolean highlighted, 1835 Boolean highlighted,
1753 Window window, 1836 Window window,
1754 int x, int y, 1837 int x, int y,
1755 unsigned width, unsigned height, 1838 unsigned width, unsigned height,
1756 unsigned label_tab, 1839 unsigned label_tab,
1757 unsigned binding_tab) 1840 unsigned binding_tab
1841 )
1758 { 1842 {
1759 unsigned sep_width; 1843 unsigned sep_width;
1760 1844
1761 if (in_menubar) 1845 if (in_menubar)
1762 sep_width = height; 1846 sep_width = height;
1767 window, 1851 window,
1768 x, 1852 x,
1769 y, 1853 y,
1770 sep_width, 1854 sep_width,
1771 in_menubar, 1855 in_menubar,
1772 separator_type(val->value)); 1856 separator_type(val->value)
1857 );
1773 } 1858 }
1774 1859
1775 static void 1860 static void
1776 pushright_size (XlwMenuWidget mw, 1861 pushright_size (XlwMenuWidget mw,
1777 widget_value *val, 1862 widget_value *val,
1793 unsigned *label_width, 1878 unsigned *label_width,
1794 unsigned *rest_width, 1879 unsigned *rest_width,
1795 unsigned *height 1880 unsigned *height
1796 ) 1881 )
1797 { 1882 {
1798 void (*function_ptr) (XlwMenuWidget _mw, 1883
1884 void (*function_ptr) (
1885 XlwMenuWidget _mw,
1799 widget_value *_val, 1886 widget_value *_val,
1800 Boolean _in_menubar, 1887 Boolean _in_menubar,
1801 unsigned *_toggle_width, 1888 unsigned *_toggle_width,
1802 unsigned *_label_width, 1889 unsigned *_label_width,
1803 unsigned *_rest_width, 1890 unsigned *_rest_width,
1804 unsigned *_height); 1891 unsigned *_height
1805 1892 );
1806 switch (menu_item_type (val)) 1893 switch (menu_item_type (val))
1807 { 1894 {
1808 case TOGGLE_TYPE: 1895 case TOGGLE_TYPE:
1809 case RADIO_TYPE: 1896 case RADIO_TYPE:
1810 function_ptr = toggle_button_size; 1897 function_ptr = toggle_button_size;
1826 default: 1913 default:
1827 function_ptr = label_button_size; 1914 function_ptr = label_button_size;
1828 break; 1915 break;
1829 } 1916 }
1830 1917
1831 (*function_ptr) (mw, 1918 (*function_ptr) (
1919 mw,
1832 val, 1920 val,
1833 horizontal, 1921 horizontal,
1834 toggle_width, 1922 toggle_width,
1835 label_width, 1923 label_width,
1836 rest_width, 1924 rest_width,
1837 height); 1925 height
1838 } 1926 );
1839 1927 }
1840 static void 1928
1841 display_menu_item (XlwMenuWidget mw, 1929 static void
1930 display_menu_item (
1931 XlwMenuWidget mw,
1842 widget_value *val, 1932 widget_value *val,
1843 window_state *ws, 1933 window_state *ws,
1844 XPoint *where, 1934 XPoint *where,
1845 Boolean highlighted, 1935 Boolean highlighted,
1846 Boolean horizontal, 1936 Boolean horizontal,
1847 Boolean just_compute) 1937 Boolean just_compute
1938 )
1848 { 1939 {
1849 1940
1850 int x = where->x /* + mw->menu.shadow_thickness */ ; 1941 int x = where->x /* + mw->menu.shadow_thickness */ ;
1851 int y = where->y /* + mw->menu.shadow_thickness */ ; 1942 int y = where->y /* + mw->menu.shadow_thickness */ ;
1852 unsigned toggle_width; 1943 unsigned toggle_width;
1854 unsigned binding_width; 1945 unsigned binding_width;
1855 unsigned width; 1946 unsigned width;
1856 unsigned height; 1947 unsigned height;
1857 unsigned label_tab; 1948 unsigned label_tab;
1858 unsigned binding_tab; 1949 unsigned binding_tab;
1859 void (*function_ptr) (XlwMenuWidget _mw, 1950 void (*function_ptr) (
1951 XlwMenuWidget _mw,
1860 widget_value *_val, 1952 widget_value *_val,
1861 Boolean _in_menubar, 1953 Boolean _in_menubar,
1862 Boolean _highlighted, 1954 Boolean _highlighted,
1863 Window _window, 1955 Window _window,
1864 int _x, int _y, 1956 int _x, int _y,
1865 unsigned _width, unsigned _height, 1957 unsigned _width, unsigned _height,
1866 unsigned _label_tab, 1958 unsigned _label_tab,
1867 unsigned _binding_tab); 1959 unsigned _binding_tab
1868 1960 );
1869 size_menu_item (mw, val, horizontal, 1961
1870 &toggle_width, &label_width, &binding_width, &height); 1962 size_menu_item (
1963 mw, val, horizontal,
1964 &toggle_width, &label_width, &binding_width, &height
1965 );
1871 1966
1872 if (horizontal) 1967 if (horizontal)
1873 { 1968 {
1874 width = toggle_width + label_width + binding_width; 1969 width = toggle_width + label_width + binding_width;
1875 height = ws->height - 2 * mw->menu.shadow_thickness; 1970 height = ws->height - 2 * mw->menu.shadow_thickness;
1913 break; 2008 break;
1914 default: /* do no drawing */ 2009 default: /* do no drawing */
1915 return; 2010 return;
1916 } 2011 }
1917 2012
1918 (*function_ptr) (mw, 2013 (*function_ptr) (
2014 mw,
1919 val, 2015 val,
1920 horizontal, 2016 horizontal,
1921 highlighted, 2017 highlighted,
1922 ws->window, 2018 ws->window,
1923 x, y, 2019 x, y,
1924 width, height, 2020 width, height,
1925 label_tab, 2021 label_tab,
1926 binding_tab); 2022 binding_tab
2023 );
1927 } 2024 }
1928 2025
1929 static void 2026 static void
1930 size_menu (XlwMenuWidget mw, int level) 2027 size_menu (XlwMenuWidget mw, int level)
1931 { 2028 {
1932 unsigned toggle_width; 2029 unsigned toggle_width;
1933 unsigned label_width; 2030 unsigned label_width;
1934 unsigned rest_width; 2031 unsigned rest_width;
1935 unsigned height; 2032 unsigned height;
1936 unsigned max_toggle_width = 0; 2033 unsigned max_toggle_width = 0;
1937 unsigned max_label_width = 0; 2034 unsigned max_label_width = 0;
1938 unsigned max_rest_width = 0; 2035 unsigned max_rest_width = 0;
1939 unsigned max_height = 0; 2036 unsigned max_height = 0;
1940 int horizontal_p = mw->menu.horizontal && (level == 0); 2037 int horizontal_p = mw->menu.horizontal && (level == 0);
1941 widget_value* val; 2038 widget_value* val;
1942 window_state* ws; 2039 window_state* ws;
1943 2040
1946 2043
1947 ws = &mw->menu.windows [level]; 2044 ws = &mw->menu.windows [level];
1948 2045
1949 for (val = mw->menu.old_stack [level]->contents; val; val = val->next) 2046 for (val = mw->menu.old_stack [level]->contents; val; val = val->next)
1950 { 2047 {
1951 size_menu_item (mw, 2048 size_menu_item (
2049 mw,
1952 val, 2050 val,
1953 horizontal_p, 2051 horizontal_p,
1954 &toggle_width, 2052 &toggle_width,
1955 &label_width, 2053 &label_width,
1956 &rest_width, 2054 &rest_width,
1957 &height); 2055 &height
2056 );
1958 if (horizontal_p) 2057 if (horizontal_p)
1959 { 2058 {
1960 max_label_width += toggle_width + label_width + rest_width; 2059 max_label_width += toggle_width + label_width + rest_width;
1961 if (height > max_height) 2060 if (height > max_height)
1962 max_height = height; 2061 max_height = height;
1963 } 2062 }
1964 else 2063 else
1965 { 2064 {
1966 if (max_toggle_width < toggle_width) 2065 if (toggle_width > max_toggle_width)
1967 max_toggle_width = toggle_width; 2066 max_toggle_width = toggle_width;
1968 if (max_label_width < label_width) 2067 if (label_width > max_label_width)
1969 max_label_width = label_width; 2068 max_label_width = label_width;
1970 if (max_rest_width < rest_width) 2069 if (rest_width > max_rest_width)
1971 max_rest_width = rest_width; 2070 max_rest_width = rest_width;
1972 max_height += height; 2071 max_height += height;
1973 } 2072 }
1974 } 2073 }
1975 2074
1976 ws->height = max_height; 2075 ws->height = max_height;
1977 ws->width = max_label_width + max_rest_width + max_toggle_width; 2076 ws->width = max_label_width + max_rest_width + max_toggle_width;
1978 ws->toggle_width = max_toggle_width; 2077 ws->toggle_width = max_toggle_width;
1979 ws->label_width = max_label_width; 2078 ws->label_width = max_label_width;
1980 2079
1981 ws->width += 2 * mw->menu.shadow_thickness; 2080 ws->width += 2 * mw->menu.shadow_thickness;
1982 ws->height += 2 * mw->menu.shadow_thickness; 2081 ws->height += 2 * mw->menu.shadow_thickness;
1983 } 2082 }
1984 2083
1985 static void 2084 static void
1986 display_menu (XlwMenuWidget mw, int level, Boolean just_compute_p, 2085 display_menu (XlwMenuWidget mw, int level, Boolean just_compute_p,
2152 start_at = 0; 2251 start_at = 0;
2153 } 2252 }
2154 else 2253 else
2155 { 2254 {
2156 mw->menu.windows = 2255 mw->menu.windows =
2157 (window_state *) XtRealloc ((char *) mw->menu.windows, 2256 (window_state *) XtRealloc ((char*)mw->menu.windows,
2158 n * sizeof (window_state)); 2257 n * sizeof (window_state));
2159 start_at = mw->menu.windows_length; 2258 start_at = mw->menu.windows_length;
2160 } 2259 }
2161 mw->menu.windows_length = n; 2260 mw->menu.windows_length = n;
2162 2261
2317 window_state *ws = &mw->menu.windows [level]; 2416 window_state *ws = &mw->menu.windows [level];
2318 int x = level == 0 ? ws->x : ws->x + mw->menu.shadow_thickness; 2417 int x = level == 0 ? ws->x : ws->x + mw->menu.shadow_thickness;
2319 int y = level == 0 ? ws->y : ws->y + mw->menu.shadow_thickness; 2418 int y = level == 0 ? ws->y : ws->y + mw->menu.shadow_thickness;
2320 relative_pos->x = ev->x_root - x; 2419 relative_pos->x = ev->x_root - x;
2321 relative_pos->y = ev->y_root - y; 2420 relative_pos->y = ev->y_root - y;
2322 return (x < ev->x_root && ev->x_root < (int) (x + ws->width) && 2421 return (x < ev->x_root && ev->x_root < (int) (x + ws->width)
2323 y < ev->y_root && ev->y_root < (int) (y + ws->height)); 2422 && y < ev->y_root && ev->y_root < (int) (y + ws->height));
2324 } 2423 }
2325 2424
2326 static Boolean 2425 static Boolean
2327 map_event_to_widget_value (XlwMenuWidget mw, XMotionEvent *ev, 2426 map_event_to_widget_value (XlwMenuWidget mw, XMotionEvent *ev,
2328 widget_value **val_ptr, int *level, 2427 widget_value **val_ptr, int *level,
2426 mw->menu.button_gc = XtGetGC ((Widget)mw, flags, &xgcv); 2525 mw->menu.button_gc = XtGetGC ((Widget)mw, flags, &xgcv);
2427 2526
2428 xgcv.fill_style = FillStippled; 2527 xgcv.fill_style = FillStippled;
2429 xgcv.stipple = mw->menu.gray_pixmap; 2528 xgcv.stipple = mw->menu.gray_pixmap;
2430 mw->menu.inactive_button_gc = XtGetGC ((Widget)mw, 2529 mw->menu.inactive_button_gc = XtGetGC ((Widget)mw,
2431 (flags | GCFillStyle | GCStipple), 2530 (flags | GCFillStyle | GCStipple),
2432 &xgcv); 2531 &xgcv);
2433 } 2532 }
2434 2533
2435 static void 2534 static void
2436 release_drawing_gcs (XlwMenuWidget mw) 2535 release_drawing_gcs (XlwMenuWidget mw)
2440 XtReleaseGC ((Widget) mw, mw->menu.inactive_gc); 2539 XtReleaseGC ((Widget) mw, mw->menu.inactive_gc);
2441 XtReleaseGC ((Widget) mw, mw->menu.inactive_button_gc); 2540 XtReleaseGC ((Widget) mw, mw->menu.inactive_button_gc);
2442 XtReleaseGC ((Widget) mw, mw->menu.background_gc); 2541 XtReleaseGC ((Widget) mw, mw->menu.background_gc);
2443 XtReleaseGC ((Widget) mw, mw->menu.select_gc); 2542 XtReleaseGC ((Widget) mw, mw->menu.select_gc);
2444 /* let's get some segvs if we try to use these... */ 2543 /* let's get some segvs if we try to use these... */
2445 mw->menu.foreground_gc = (GC) -1; 2544 mw->menu.foreground_gc = (GC) -1;
2446 mw->menu.button_gc = (GC) -1; 2545 mw->menu.button_gc = (GC) -1;
2447 mw->menu.inactive_gc = (GC) -1; 2546 mw->menu.inactive_gc = (GC) -1;
2448 mw->menu.inactive_button_gc = (GC) -1; 2547 mw->menu.inactive_button_gc = (GC) -1;
2449 mw->menu.background_gc = (GC) -1; 2548 mw->menu.background_gc = (GC) -1;
2450 mw->menu.select_gc = (GC) -1; 2549 mw->menu.select_gc = (GC) -1;
2451 } 2550 }
2452 2551
2453 #define MINL(x,y) ((((unsigned long) (x)) < ((unsigned long) (y))) \ 2552 #define MINL(x,y) ((((unsigned long) (x)) < ((unsigned long) (y))) \
2454 ? ((unsigned long) (x)) : ((unsigned long) (y))) 2553 ? ((unsigned long) (x)) : ((unsigned long) (y)))
2455 2554
2462 Colormap cmap = DefaultColormapOfScreen (XtScreen ((Widget) mw)); 2561 Colormap cmap = DefaultColormapOfScreen (XtScreen ((Widget) mw));
2463 XColor topc, botc; 2562 XColor topc, botc;
2464 int top_frobbed = 0, bottom_frobbed = 0; 2563 int top_frobbed = 0, bottom_frobbed = 0;
2465 2564
2466 if (mw->menu.top_shadow_color == -1) 2565 if (mw->menu.top_shadow_color == -1)
2467 mw->menu.top_shadow_color = mw->core.background_pixel; 2566 mw->menu.top_shadow_color = mw->core.background_pixel;
2468 if (mw->menu.bottom_shadow_color == -1) 2567 if (mw->menu.bottom_shadow_color == -1)
2469 mw->menu.bottom_shadow_color = mw->menu.foreground; 2568 mw->menu.bottom_shadow_color = mw->menu.foreground;
2470 2569
2471 if (mw->menu.top_shadow_color == mw->core.background_pixel || 2570 if (mw->menu.top_shadow_color == mw->core.background_pixel ||
2472 mw->menu.top_shadow_color == mw->menu.foreground) 2571 mw->menu.top_shadow_color == mw->menu.foreground)
2473 { 2572 {
2474 topc.pixel = mw->core.background_pixel; 2573 topc.pixel = mw->core.background_pixel;
2727 Display *display = XtDisplay (mw); 2826 Display *display = XtDisplay (mw);
2728 2827
2729 /* mw->menu.cursor = XCreateFontCursor (display, mw->menu.cursor_shape); */ 2828 /* mw->menu.cursor = XCreateFontCursor (display, mw->menu.cursor_shape); */
2730 mw->menu.cursor = mw->menu.cursor_shape; 2829 mw->menu.cursor = mw->menu.cursor_shape;
2731 2830
2732 mw->menu.gray_pixmap = 2831 mw->menu.gray_pixmap = XCreatePixmapFromBitmapData (display, window,
2733 XCreatePixmapFromBitmapData (display, window, (char *) gray_bits, 2832 (char *) gray_bits,
2734 gray_width, gray_height, 1, 0, 1); 2833 gray_width,
2834 gray_height, 1, 0, 1);
2735 2835
2736 #ifdef NEED_MOTIF 2836 #ifdef NEED_MOTIF
2737 /* The menu.font_list slot came from the *fontList resource (Motif standard.) 2837 /* The menu.font_list slot came from the *fontList resource (Motif standard.)
2738 The menu.font_list_2 slot came from the *font resource, for backward 2838 The menu.font_list_2 slot came from the *font resource, for backward
2739 compatibility with older versions of this code, and consistency with the 2839 compatibility with older versions of this code, and consistency with the
2788 } 2888 }
2789 2889
2790 static void 2890 static void
2791 XlwMenuClassInitialize (void) 2891 XlwMenuClassInitialize (void)
2792 { 2892 {
2893 Initialize_massaged_resource_char();
2793 } 2894 }
2794 2895
2795 static void 2896 static void
2796 XlwMenuRealize (Widget w, Mask *valueMask, XSetWindowAttributes *attributes) 2897 XlwMenuRealize (Widget w, Mask *valueMask, XSetWindowAttributes *attributes)
2797 { 2898 {
2847 XtUngrabPointer (w, CurrentTime); 2948 XtUngrabPointer (w, CurrentTime);
2848 mw->menu.pointer_grabbed = False; 2949 mw->menu.pointer_grabbed = False;
2849 } 2950 }
2850 2951
2851 release_drawing_gcs (mw); 2952 release_drawing_gcs (mw);
2852 release_shadow_gcs (mw); 2953 release_shadow_gcs (mw);
2853 2954
2854 /* this doesn't come from the resource db but is created explicitly 2955 /* this doesn't come from the resource db but is created explicitly
2855 so we must free it ourselves. */ 2956 so we must free it ourselves. */
2856 XFreePixmap (XtDisplay (mw), mw->menu.gray_pixmap); 2957 XFreePixmap (XtDisplay (mw), mw->menu.gray_pixmap);
2857 mw->menu.gray_pixmap = (Pixmap) -1; 2958 mw->menu.gray_pixmap = (Pixmap) -1;
2897 2998
2898 if (newmw->core.background_pixel != oldmw->core.background_pixel 2999 if (newmw->core.background_pixel != oldmw->core.background_pixel
2899 || newmw->menu.foreground != oldmw->menu.foreground 3000 || newmw->menu.foreground != oldmw->menu.foreground
2900 /* For the XEditResource protocol, which may want to change the font. */ 3001 /* For the XEditResource protocol, which may want to change the font. */
2901 #ifdef NEED_MOTIF 3002 #ifdef NEED_MOTIF
2902 || newmw->menu.font_list != oldmw->menu.font_list 3003 || newmw->menu.font_list != oldmw->menu.font_list
2903 || newmw->menu.font_list_2 != oldmw->menu.font_list_2 3004 || newmw->menu.font_list_2 != oldmw->menu.font_list_2
2904 || newmw->menu.fallback_font_list != oldmw->menu.fallback_font_list 3005 || newmw->menu.fallback_font_list != oldmw->menu.fallback_font_list
2905 #else 3006 #else
2906 || newmw->menu.font != oldmw->menu.font 3007 || newmw->menu.font != oldmw->menu.font
2907 #endif 3008 #endif
2908 ) 3009 )
2928 static void 3029 static void
2929 XlwMenuResize (Widget w) 3030 XlwMenuResize (Widget w)
2930 { 3031 {
2931 XlwMenuWidget mw = (XlwMenuWidget)w; 3032 XlwMenuWidget mw = (XlwMenuWidget)w;
2932 3033
2933 mw->menu.windows [0].width = mw->core.width; 3034 mw->menu.windows [0].width = mw->core.width;
2934 mw->menu.windows [0].height = mw->core.height; 3035 mw->menu.windows [0].height = mw->core.height;
2935 } 3036 }
2936 3037
2937 /* Action procedures */ 3038 /* Action procedures */
2938 static void 3039 static void
3090 mw->menu.popped_up = False; 3191 mw->menu.popped_up = False;
3091 XtPopdown (XtParent (mw)); 3192 XtPopdown (XtParent (mw));
3092 } 3193 }
3093 3194
3094 /* callback */ 3195 /* callback */
3095 XtCallCallbackList ((Widget) mw, mw->menu.select, (XtPointer) selected_item); 3196 XtCallCallbackList ((Widget)mw, mw->menu.select, (XtPointer)selected_item);
3096 } 3197 }
3097 3198
3098 3199
3099 /* Special code to pop-up a menu */ 3200 /* Special code to pop-up a menu */
3100 void 3201 void
3110 mw->menu.menu_post_time = event->time; 3211 mw->menu.menu_post_time = event->time;
3111 mw->menu.menu_bounce_time = 0; 3212 mw->menu.menu_bounce_time = 0;
3112 mw->menu.next_release_must_exit = True; 3213 mw->menu.next_release_must_exit = True;
3113 mw->menu.last_selected_val = NULL; 3214 mw->menu.last_selected_val = NULL;
3114 3215
3115 XtCallCallbackList ((Widget) mw, mw->menu.open, NULL); 3216 XtCallCallbackList ((Widget)mw, mw->menu.open, NULL);
3116 3217
3117 size_menu (mw, 0); 3218 size_menu (mw, 0);
3118 3219
3119 w = mw->menu.windows [0].width; 3220 w = mw->menu.windows [0].width;
3120 h = mw->menu.windows [0].height; 3221 h = mw->menu.windows [0].height;
3121 3222
3122 x -= borderwidth; 3223 x -= borderwidth;
3123 y -= borderwidth; 3224 y -= borderwidth;
3124
3125 if (x < borderwidth) 3225 if (x < borderwidth)
3126 x = borderwidth; 3226 x = borderwidth;
3127 3227 if (x + w + 2 * borderwidth > WidthOfScreen (screen))
3128 if (x > WidthOfScreen (screen) - w - 2 * borderwidth) 3228 x = WidthOfScreen (screen) - w - 2 * borderwidth;
3129 x = WidthOfScreen (screen) - w - 2 * borderwidth;
3130
3131 if (y < borderwidth) 3229 if (y < borderwidth)
3132 y = borderwidth; 3230 y = borderwidth;
3133 3231 if (y + h + 2 * borderwidth> HeightOfScreen (screen))
3134 if (y > HeightOfScreen (screen) - h - 2 * borderwidth) 3232 y = HeightOfScreen (screen) - h - 2 * borderwidth;
3135 y = HeightOfScreen (screen) - h - 2 * borderwidth;
3136 3233
3137 mw->menu.popped_up = True; 3234 mw->menu.popped_up = True;
3138 XtConfigureWidget (XtParent (mw), x, y, w, h, 3235 XtConfigureWidget (XtParent (mw), x, y, w, h,
3139 XtParent (mw)->core.border_width); 3236 XtParent (mw)->core.border_width);
3140 XtPopup (XtParent (mw), XtGrabExclusive); 3237 XtPopup (XtParent (mw), XtGrabExclusive);
3164 */ 3261 */
3165 void 3262 void
3166 xlw_unmunge_class_resize (Widget w) 3263 xlw_unmunge_class_resize (Widget w)
3167 { 3264 {
3168 if (w->core.widget_class->core_class.resize != XlwMenuResize) 3265 if (w->core.widget_class->core_class.resize != XlwMenuResize)
3169 w->core.widget_class->core_class.resize = XlwMenuResize; 3266 w->core.widget_class->core_class.resize = XlwMenuResize;
3170 } 3267 }
3171 #endif /* 0 */ 3268 #endif /* 0 */
3172 3269