Modernize to C89, for better static checking.
[bpt/emacs.git] / oldXMenu / Create.c
CommitLineData
e745ede7
DL
1/* Copyright Massachusetts Institute of Technology 1985 */
2
3#include "copyright.h"
4
f10de189 5/*
73b0cd50 6Copyright (C) 1993-1994, 2001-2011 Free Software Foundation, Inc.
f10de189 7
4eaa4034 8This program is free software: you can redistribute it and/or modify
f10de189 9it under the terms of the GNU General Public License as published by
4eaa4034
GM
10the Free Software Foundation, either version 3 of the License, or
11(at your option) any later version.
f10de189
GM
12
13This program is distributed in the hope that it will be useful,
14but WITHOUT ANY WARRANTY; without even the implied warranty of
15MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
16GNU General Public License for more details.
17
18You should have received a copy of the GNU General Public License
4eaa4034 19along with this program. If not, see <http://www.gnu.org/licenses/>. */
f10de189
GM
20
21
e745ede7
DL
22/*
23 * XMenu: MIT Project Athena, X Window system menu package
24 *
25 * XMenuCreate - Creates an X window system menu object.
26 *
27 * Author: Tony Della Fera, DEC
28 * January 23, 1986
29 *
30 */
31
32#include <config.h>
33#include "XMenuInt.h"
55660072 34#include <stdlib.h>
e745ede7
DL
35
36#ifdef EMACS_BITMAP_FILES
37#include "../src/bitmaps/dimple1.xbm"
38#include "../src/bitmaps/dimple3.xbm"
39#include "../src/bitmaps/gray1.xbm"
40#include "../src/bitmaps/gray3.xbm"
41#include "../src/bitmaps/crosswv.xbm"
42
43#include "../src/bitmaps/leftptr.xbm"
44#include "../src/bitmaps/leftpmsk.xbm"
45#include "../src/bitmaps/rtptr.xbm"
46#include "../src/bitmaps/rtpmsk.xbm"
47#include "../src/bitmaps/cntrptr.xbm"
48#include "../src/bitmaps/cntrpmsk.xbm"
49#include "../src/bitmaps/stipple.xbm"
50
51#else
e745ede7
DL
52
53#include <X11/bitmaps/dimple1>
54#include <X11/bitmaps/dimple3>
55#include <X11/bitmaps/gray1>
56#include <X11/bitmaps/gray3>
57#include <X11/bitmaps/cross_weave>
58
59#include <X11/bitmaps/left_ptr>
60#include <X11/bitmaps/left_ptrmsk>
61#include <X11/bitmaps/right_ptr>
62#include <X11/bitmaps/right_ptrmsk>
63#include <X11/bitmaps/cntr_ptr>
64#include <X11/bitmaps/cntr_ptrmsk>
65#include <X11/bitmaps/stipple>
66
e745ede7
DL
67#endif /* not EMACS_BITMAP_FILES */
68
69#define DEF_FREEZE 0
70#define DEF_REVERSE 0
71#define DEF_MENU_STYLE LEFT
72#define DEF_MENU_MODE BOX
73#define DEF_INACT_PNUM 3
e745ede7
DL
74
75#define DEF_P_STYLE CENTER
76
77#define DEF_P_EVENTS (EnterWindowMask | ExposureMask)
78#define DEF_P_FNT_NAME "fixed"
79#define DEF_P_SPREAD 0.5
80#define DEF_P_BDR_WIDTH 2
81
82#define DEF_S_STYLE LEFT
83#define DEF_S_EVENTS (EnterWindowMask | LeaveWindowMask)
84#define DEF_S_FNT_NAME "fixed"
85#define DEF_S_SPREAD 0.10
86#define DEF_S_BDR_WIDTH 1
87
88#define XASSOC_TABLE_SIZE 64
89
55660072 90char *x_get_resource_string (char const *, char const *);
e745ede7
DL
91
92
93
177c0ea7 94static Status
55660072
PE
95XAllocDisplayColor(Display *display, Colormap map, char const *colorName,
96 XColor *color, XColor *junk)
e745ede7
DL
97{
98 return (colorName!=0 &&
99 XParseColor(display, map, colorName, color) &&
100 XAllocColor(display, map, color));
101}
102
103
104XMenu *
55660072 105XMenuCreate(Display *display, Window parent, register char const *def_env)
b782e2d7
DN
106 /* ID of previously opened display */
107 /* Window ID of the menu's parent window. */
108 /* X Defaults program environment name. */
e745ede7 109{
e745ede7
DL
110 register char *def_val; /* X Default value temp variable. */
111
112 register XMenu *menu; /* Pointer to the new menu. */
113 XMStyle menu_style; /* Menu display style. */
114 XMMode menu_mode; /* Menu display mode. */
115 XMPane *pane; /* Pane list header. */
116 XAssocTable *assoc_tab; /* XAssocTable pointer. */
117
118 int freeze; /* Freeze server mode. */
119 int reverse; /* Reverse video mode. */
120
121 XMStyle p_style; /* Pane display style. */
55660072 122 char const *p_fnt_name; /* Flag font name. */
e745ede7
DL
123 XFontStruct *p_fnt_info; /* Flag font structure */
124 int p_fnt_pad; /* Flag font padding in pixels. */
125 double p_spread; /* Pane spread in flag height fractions. */
126 int p_fnt_height; /* Pane character height. */
127 int p_bdr_width; /* Pane border width. */
128 int flag_height; /* Flag window height. */
129 int p_height; /* Pane window height. */
130 int p_x_off; /* Pane X offset. */
131 int p_y_off; /* Pane Y offset. */
132 GC pane_GC; /* Pane graphics context. */
133
134 XMStyle s_style; /* Selection display style. */
55660072 135 char const *s_fnt_name; /* Selection font name. */
e745ede7
DL
136 XFontStruct *s_fnt_info; /* Selection font structure. */
137 int s_fnt_pad; /* Selection font padding in pixels. */
138 int s_fnt_height; /* Selection font character height */
139 double s_spread; /* Select spread in line height fractions. */
140 int s_bdr_width; /* Highlight border width. */
141 int s_height; /* Selection window height. */
142 int s_x_off; /* Selection window X offset. */
143 int s_y_off; /* Selection window Y offset. */
144 GC normal_select_GC; /* GC used for normal video selection. */
145 GC inverse_select_GC; /* GC used for inverse video selection. */
146 GC inact_GC; /* GC for inactive pane header and */
147 /* selections. */
e745ede7
DL
148
149 XColor color_def; /* Temp color definition holder. */
e745ede7
DL
150 XColor p_bdr_color; /* Color of border. */
151 XColor s_bdr_color; /* Color of highlight. */
152 XColor p_frg_color; /* Color of pane foreground color. */
153 XColor s_frg_color; /* Color of selection foreground. */
154 XColor bkgnd_color; /* Color of background.. */
155 XColor mouse_color; /* Color of mouse cursor. */
156 Cursor mouse_cursor; /* Mouse cursor. */
157 Pixmap inact_bitmap; /* Menu inactive pixmap. */
158
159 int inact_pnum; /* Inactive background pattern number. */
160
e745ede7
DL
161 Pixmap cursor; /* Cursor pixmap holder. */
162 Pixmap cursor_mask; /* Cursor mask pixmap holder. */
163 Pixmap stipple_pixmap; /* Stipple mask for half-tone text. */
164 unsigned long valuemask;
165 XGCValues *values;
177c0ea7 166
e745ede7
DL
167 Window root = RootWindow (display, DefaultScreen (display));
168
169 /*
170 * Calloc the XMenu structure and the initial pane.
171 */
172 menu = (XMenu *)calloc(1, sizeof(XMenu));
173 if (menu == NULL) {
174 _XMErrorCode = XME_CALLOC;
175 return(NULL);
176 }
177 pane = (XMPane *)calloc(1, sizeof(XMPane));
178 if (pane == NULL) {
179 _XMErrorCode = XME_CALLOC;
180 return(NULL);
181 }
177c0ea7
JB
182
183 /*
e745ede7
DL
184 * Create the XAssocTable
185 */
186 assoc_tab = (XAssocTable *)XCreateAssocTable(XASSOC_TABLE_SIZE);
187 if(assoc_tab == NULL) {
188 _XMErrorCode= XME_CREATE_ASSOC;
189 return(NULL);
190 }
191
192 /*
193 * Set up the default environment name.
194 */
195 if (def_env == NULL || *def_env == '\0') def_env = "XMenu";
196
197 /*
198 * Set up internal fail-safe defaults.
199 */
200 freeze = DEF_FREEZE;
201 reverse = DEF_REVERSE;
202 menu_style = DEF_MENU_STYLE;
203 menu_mode = DEF_MENU_MODE;
204 inact_pnum = DEF_INACT_PNUM;
205
206 p_style = DEF_P_STYLE;
207 p_spread = DEF_P_SPREAD;
208 p_fnt_name = DEF_P_FNT_NAME;
209 p_bdr_width = DEF_P_BDR_WIDTH;
210
211 s_style = DEF_S_STYLE;
212 s_spread = DEF_S_SPREAD;
213 s_fnt_name = DEF_S_FNT_NAME;
214 s_bdr_width = DEF_S_BDR_WIDTH;
215
216 /*
217 * Get default values from X.
218 */
219 def_val = x_get_resource_string ("menuFreeze", "MenuFreeze");
220 if (def_val != NULL) {
221 if (strcmp(def_val, "on") == 0) freeze = 1;
222 else if (strcmp(def_val, "off") == 0) freeze = 0;
223 }
224
225 def_val = x_get_resource_string ("menuReverseVideo", "MenuReverseVideo");
226 if (def_val != NULL) {
227 if (strcmp(def_val, "on") == 0) reverse = 1;
228 else if (strcmp(def_val, "off") == 0) reverse = 0;
229 }
230
231 def_val = x_get_resource_string ("menuStyle", "MenuStyle");
232 if (def_val != NULL) {
233 if (strcmp(def_val, "right_hand") == 0) menu_style = RIGHT;
234 else if (strcmp(def_val, "left_hand") == 0) menu_style = LEFT;
235 else if (strcmp(def_val, "center") == 0) menu_style = CENTER;
236 }
237
238 def_val = x_get_resource_string ("menuMode", "MenuMode");
239 if (def_val != NULL) {
240 if (strcmp(def_val, "box") == 0) menu_mode = BOX;
241 else if (strcmp(def_val, "invert") == 0) menu_mode = INVERT;
242 }
177c0ea7 243
e745ede7
DL
244 def_val = x_get_resource_string ("menuMouse", "MenuMouse");
245 if (
246 def_val != NULL &&
247 DisplayCells(display, DefaultScreen(display)) > 2 &&
177c0ea7
JB
248 XAllocDisplayColor(display,
249 DefaultColormap(display, DefaultScreen(display)),
250 def_val,
e745ede7
DL
251 &mouse_color, &color_def)
252 );
253 else if (reverse &&
254 XAllocDisplayColor(display,
255 DefaultColormap(display, DefaultScreen(display)),
256 "white",
257 &mouse_color, &color_def)
258 );
177c0ea7 259
e745ede7
DL
260 else if (XAllocDisplayColor(display,
261 DefaultColormap(display, DefaultScreen(display)),
177c0ea7 262 "black",
e745ede7
DL
263 &mouse_color, &color_def)
264 );
177c0ea7 265
55660072 266 else {}
e745ede7
DL
267
268 def_val = x_get_resource_string ("menuBackground", "MenuBackground");
269 if (
270 def_val != NULL &&
271 DisplayCells(display, DefaultScreen(display)) > 2 &&
272 XAllocDisplayColor(display,
273 DefaultColormap(display, DefaultScreen(display)),
274 def_val,
275 &bkgnd_color, &color_def)
276 );
277 else if (reverse &&
278 XAllocDisplayColor(display,
279 DefaultColormap(display, DefaultScreen(display)),
280 "black",
281 &bkgnd_color, &color_def)
282 );
283 else if (XAllocDisplayColor(display,
284 DefaultColormap(display, DefaultScreen(display)),
285 "white",
286 &bkgnd_color, &color_def)
287 );
55660072 288 else {}
e745ede7
DL
289
290 def_val = x_get_resource_string ("menuInactivePattern", "MenuInactivePattern");
291 if (def_val != NULL) {
292 if (strcmp(def_val, "dimple1") == 0) inact_pnum = 0;
293 else if (strcmp(def_val, "dimple3") == 0) inact_pnum = 1;
294 else if (strcmp(def_val, "gray1") == 0) inact_pnum = 2;
295 else if (strcmp(def_val, "gray3") == 0) inact_pnum = 3;
296 else if (strcmp(def_val, "cross_weave") == 0) inact_pnum = 4;
297 }
298
299 def_val = x_get_resource_string ("paneStyle", "PaneStyle");
300 if (def_val != NULL) {
301 if (strcmp(def_val, "flush_left") == 0) p_style = LEFT;
302 else if (strcmp(def_val, "flush_right") == 0) p_style = RIGHT;
303 else if (strcmp(def_val, "center") == 0) p_style = CENTER;
304 }
305
306 def_val = x_get_resource_string ("paneFont", "PaneFont");
307 if (def_val != NULL) p_fnt_name = def_val;
308
309 def_val = x_get_resource_string ("paneForeground", "PaneForeground");
310 if (
311 def_val != NULL &&
177c0ea7 312 DisplayCells(display, DefaultScreen(display)) > 2
e745ede7
DL
313 )
314 XAllocDisplayColor(display, DefaultColormap(display,
315 DefaultScreen(display)),
316 def_val,
317 &p_frg_color, &color_def);
177c0ea7 318
e745ede7 319 else if (reverse) XAllocDisplayColor(display,
177c0ea7 320 DefaultColormap(display,
e745ede7
DL
321 DefaultScreen(display)),
322 "white",
323 &p_frg_color, &color_def);
324 else XAllocDisplayColor(display,
325 DefaultColormap(display, DefaultScreen(display)),
326 "black",
327 &p_frg_color, &color_def);
328
329 def_val = x_get_resource_string ("paneBorder", "PaneBorder");
330 if (
331 def_val != NULL &&
332 DisplayCells(display, DefaultScreen(display)) > 2 &&
333 XAllocDisplayColor(display,
334 DefaultColormap(display, DefaultScreen(display)),
335 def_val,
336 &p_bdr_color, &color_def)
337 );
338 else if (reverse &&
177c0ea7 339 XAllocDisplayColor(display,
e745ede7
DL
340 DefaultColormap(display, DefaultScreen(display)),
341 "white",
342 &p_bdr_color, &color_def)
343 );
177c0ea7 344 else XAllocDisplayColor(display,
e745ede7
DL
345 DefaultColormap(display, DefaultScreen(display)),
346 "black",
347 &p_bdr_color, &color_def);
177c0ea7 348
e745ede7
DL
349 def_val = x_get_resource_string ("paneBorderWidth", "PaneBorderWidth");
350 if (def_val != NULL) p_bdr_width = atoi(def_val);
177c0ea7 351
e745ede7
DL
352 def_val = x_get_resource_string ("paneSpread", "PaneSpread");
353 if (def_val != NULL) p_spread = atof(def_val);
354
355 def_val = x_get_resource_string ("selectionStyle", "SelectionStyle");
356 if (def_val != NULL) {
357 if (strcmp(def_val, "flush_left") == 0) s_style = LEFT;
358 else if (strcmp(def_val, "flush_right") == 0) s_style = RIGHT;
359 else if (strcmp(def_val, "center") == 0) s_style = CENTER;
360 }
361
362 def_val = x_get_resource_string ("selectionFont", "SelectionFont");
363 if (def_val != NULL) s_fnt_name = def_val;
364
365 def_val = x_get_resource_string ("selectionForeground", "SelectionForeground");
366 if (
367 def_val != NULL &&
368 DisplayCells(display, DefaultScreen(display)) > 2 &&
369 XAllocDisplayColor(display,
370 DefaultColormap(display, DefaultScreen(display)),
371 def_val,
372 &s_frg_color, &color_def)
177c0ea7 373 );
e745ede7
DL
374 else if (reverse &&
375 XAllocDisplayColor(display,
376 DefaultColormap(display, DefaultScreen(display)),
377 "white",
378 &s_frg_color, &color_def)
379 ) ;
380 else if (XAllocDisplayColor(display,
381 DefaultColormap(display, DefaultScreen(display)),
382 "black",
383 &s_frg_color, &color_def)
384 ) ;
55660072 385 else {}
177c0ea7 386
e745ede7
DL
387
388 def_val = x_get_resource_string ("selectionBorder", "SelectionBorder");
389 if (
390 def_val != NULL &&
391 DisplayCells(display, DefaultScreen(display)) > 2 &&
392 XAllocDisplayColor(display,
393 DefaultColormap(display, DefaultScreen(display)),
394 def_val,
395 &s_bdr_color, &color_def)
396 ) ;
397 else if (reverse &&
177c0ea7 398 XAllocDisplayColor(display,
e745ede7
DL
399 DefaultColormap(display, DefaultScreen(display)),
400 "white",
401 &s_bdr_color, &color_def)
402 ) ;
403 else if (XAllocDisplayColor(display,
404 DefaultColormap(display, DefaultScreen(display)),
405 "black",
406 &s_bdr_color, &color_def)
407 ) ;
55660072 408 else {}
e745ede7
DL
409
410 def_val = x_get_resource_string ("selectionBorderWidth", "SelectionBorderWidth");
411 if (def_val != NULL) s_bdr_width = atoi(def_val);
177c0ea7 412
e745ede7
DL
413 def_val = x_get_resource_string ("selectionSpread", "SelectionSpread");
414 if (def_val != NULL) s_spread = atof(def_val);
415
416 /*
417 * Create and store the inactive pattern pixmap.
418 */
419 {
420 char *data = NULL;
421 int width, height;
422
177c0ea7 423 switch (inact_pnum)
e745ede7
DL
424 {
425 case 0:
426 data = (char *)dimple1_bits;
427 width = dimple1_width;
428 height = dimple1_height;
429 break;
430
431 case 1:
432 data = (char *)dimple3_bits;
433 width = dimple3_width;
434 height = dimple3_height;
435 break;
436
437 case 2:
438 data = (char *)gray1_bits;
439 width = gray1_width;
440 height = gray1_height;
441 break;
442
443 case 3:
444 data = (char *)gray3_bits;
445 width = gray3_width;
446 height = gray3_height;
447 break;
448
449 case 4:
450 data = (char *)cross_weave_bits;
451 width = cross_weave_width;
452 height = cross_weave_height;
453 break;
454 }
455
456 if (! data)
457 {
458 _XMErrorCode = XME_STORE_BITMAP;
459 return(NULL);
460 }
461
462 inact_bitmap =
463 XCreatePixmapFromBitmapData
464 (display, root, data, width, height,
465 p_frg_color.pixel, bkgnd_color.pixel,
466 DisplayPlanes (display, DefaultScreen (display)));
467 }
468
469 /*
470 * Load the mouse cursor.
471 */
177c0ea7 472
e745ede7
DL
473 switch (menu_style) {
474 case LEFT:
475 cursor = XCreateBitmapFromData(display,
476 root,
477 left_ptr_bits,
478 left_ptr_width,
479 left_ptr_height);
480 cursor_mask = XCreateBitmapFromData(display,
481 root,
482 left_ptrmsk_bits,
483 left_ptrmsk_width,
484 left_ptrmsk_height);
485 mouse_cursor = XCreatePixmapCursor(
486 display,
177c0ea7 487 cursor, cursor_mask,
e745ede7
DL
488 &mouse_color, &bkgnd_color,
489 left_ptr_x_hot,
490 left_ptr_y_hot
491 );
492 XFreePixmap(display, cursor);
177c0ea7 493 XFreePixmap(display, cursor_mask);
e745ede7
DL
494 break;
495 case RIGHT:
496 cursor = XCreateBitmapFromData(display,
497 root,
498 right_ptr_bits,
499 right_ptr_width,
500 right_ptr_height);
501 cursor_mask = XCreateBitmapFromData(display,
502 root,
503 right_ptrmsk_bits,
504 right_ptrmsk_width,
505 right_ptrmsk_height);
506 mouse_cursor = XCreatePixmapCursor(
507 display,
508 cursor, cursor_mask,
509 &mouse_color, &bkgnd_color,
510 right_ptr_x_hot,
511 right_ptr_y_hot
512 );
513 XFreePixmap(display, cursor);
177c0ea7 514 XFreePixmap(display, cursor_mask);
e745ede7
DL
515 break;
516 case CENTER:
517 cursor = XCreateBitmapFromData(display,
518 root,
519 cntr_ptr_bits,
520 cntr_ptr_width,
521 cntr_ptr_height);
522 cursor_mask = XCreateBitmapFromData(display,
523 root,
524 cntr_ptrmsk_bits,
525 cntr_ptrmsk_width,
526 cntr_ptrmsk_height);
527 mouse_cursor = XCreatePixmapCursor(
528 display,
529 cursor, cursor_mask,
530 &mouse_color, &bkgnd_color,
531 cntr_ptr_x_hot,
532 cntr_ptr_y_hot
533 );
534 XFreePixmap(display, cursor);
177c0ea7 535 XFreePixmap(display, cursor_mask);
e745ede7
DL
536 break;
537 default:
538 /* Error! Invalid style parameter. */
539 _XMErrorCode = XME_STYLE_PARAM;
540 return(NULL);
541 }
542 if (mouse_cursor == _X_FAILURE) {
543 _XMErrorCode = XME_CREATE_CURSOR;
544 return(NULL);
545 }
546
547 /*
548 * Open the pane and selection fonts.
549 */
177c0ea7 550
e745ede7
DL
551 p_fnt_info = XLoadQueryFont(display, p_fnt_name);
552 if (p_fnt_info == NULL) {
553 _XMErrorCode = XME_OPEN_FONT;
554 return(NULL);
177c0ea7 555
e745ede7
DL
556 }
557
558 s_fnt_info = XLoadQueryFont(display, s_fnt_name);
559 if (s_fnt_info == NULL) {
560 _XMErrorCode = XME_OPEN_FONT;
561 return(NULL);
562 }
563 /*
564 * Calculate the fixed padding value in pixels for each font.
565 */
566 p_fnt_height = p_fnt_info->max_bounds.ascent + p_fnt_info->max_bounds.descent;
567 s_fnt_height = s_fnt_info->max_bounds.ascent + s_fnt_info->max_bounds.descent;
568 p_fnt_pad = s_spread * p_fnt_height;
569 s_fnt_pad = s_spread * s_fnt_height;
570
571 /*
572 * Calculate fixed height and offset requirements.
573 */
574 flag_height = p_fnt_height + (p_fnt_pad << 1);
575
576 p_height = 0;
577 p_y_off = flag_height + p_bdr_width;
578 p_x_off = p_y_off * p_spread;
579
580 s_height = s_fnt_height + (s_fnt_pad << 1) + (s_bdr_width << 1);
581 s_y_off = s_height;
582 s_x_off = p_x_off;
583
584 /*
585 * Set up the pane list header.
586 */
587 pane->next = pane;
588 pane->prev = pane;
589 pane->type = PL_HEADER;
590 pane->serial = -1;
591
592 /*
593 * Initialize the internal pane and selection creation queues.
594 */
595 _XMWinQueInit();
177c0ea7 596
e745ede7
DL
597 /*
598 * Create pane, active, and inactive GC's.
599 */
600 values = (XGCValues *)malloc(sizeof(XGCValues));
601 valuemask = (GCForeground | GCBackground | GCFont | GCLineWidth);
602
603 /*
604 * First, pane.
605 */
606
607 values->foreground = p_frg_color.pixel;
608 values->background = bkgnd_color.pixel;
609 values->font = p_fnt_info->fid;
610 values->line_width = p_bdr_width;
177c0ea7 611
e745ede7 612 pane_GC = XCreateGC(
177c0ea7 613 display,
e745ede7
DL
614 root,
615 valuemask,
616 values);
617 /*
618 * Then normal video selection.
619 */
620
621 values->foreground = s_frg_color.pixel;
622 values->background = bkgnd_color.pixel;
623 values->font = s_fnt_info->fid;
624 values->line_width = s_bdr_width;
177c0ea7 625 normal_select_GC = XCreateGC(display,
e745ede7
DL
626 root,
627 valuemask,
628 values);
629 /*
630 * Inverse video selection.
631 */
632
177c0ea7 633 values->foreground = bkgnd_color.pixel;
e745ede7
DL
634 values->background = s_frg_color.pixel;
635 values->font = s_fnt_info->fid;
636 values->line_width = s_bdr_width;
177c0ea7 637 inverse_select_GC = XCreateGC(display,
e745ede7
DL
638 root,
639 valuemask,
640 values);
641 stipple_pixmap = XCreateBitmapFromData(display,
642 root,
177c0ea7
JB
643 stipple_bits,
644 stipple_width,
645 stipple_height);
646
e745ede7
DL
647 /*
648 * Finally, inactive pane header and selections
649 */
650 valuemask |= (GCFillStyle | GCStipple);
651 values->foreground = s_frg_color.pixel;
652 values->background = bkgnd_color.pixel;
653 values->font = s_fnt_info->fid;
654 values->line_width = s_bdr_width;
655 values->fill_style = FillStippled;
656 values->stipple = stipple_pixmap;
177c0ea7
JB
657
658 inact_GC = XCreateGC(display,
e745ede7
DL
659 root,
660 valuemask,
661 values);
662
663 valuemask |= (GCGraphicsExposures);
664 values->graphics_exposures = False;
e745ede7
DL
665
666
667 /*
668 * Construct the XMenu object.
669 */
670 /* -------------------- Menu data -------------------- */
671 menu->menu_style = menu_style;
672 menu->menu_mode = menu_mode;
673 menu->freeze = freeze;
674 menu->aeq = 0;
675 menu->recompute = 1;
676 menu->parent = parent;
677 menu->height = 0;
678 menu->width = 0;
679 menu->mouse_cursor = mouse_cursor;
680 menu->assoc_tab = assoc_tab;
681 menu->p_list = pane;
682 /* -------------------- Pane window data -------------------- */
683 menu->p_style = p_style;
684 menu->p_events = DEF_P_EVENTS;
685 menu->p_fnt_info = p_fnt_info;
686 menu->p_fnt_pad = p_fnt_pad;
687 menu->p_spread = p_spread;
688 menu->p_bdr_width = p_bdr_width;
689 menu->flag_height = flag_height;
690 menu->p_width = 0;
691 menu->p_height = p_height;
692 menu->p_x_off = p_x_off;
693 menu->p_y_off = p_y_off;
694 menu->p_count = 0;
695 menu->pane_GC = pane_GC;
696 menu->x_pos = 0;
697 menu->y_pos = 0;
698 /* -------------------- Selection window data -------------------- */
699 menu->s_style = s_style;
700 menu->s_events = DEF_S_EVENTS;
701 menu->s_fnt_info = s_fnt_info;
702 menu->s_fnt_pad = s_fnt_pad;
703 menu->s_spread = s_spread;
704 menu->s_bdr_width = s_bdr_width; /* unnecessary */
705 menu->s_width = 0;
706 menu->s_height = s_height;
707 menu->s_x_off = s_x_off;
708 menu->s_y_off = s_y_off;
709 menu->s_count = 0;
710 menu->normal_select_GC = normal_select_GC;
711 menu->inverse_select_GC = inverse_select_GC;
712 menu->inact_GC = inact_GC;
713 /* -------------------- Color data -------------------- */
714 menu->p_bdr_color = p_bdr_color.pixel;
715 menu->s_bdr_color = s_bdr_color.pixel;
716 menu->p_frg_color = p_frg_color.pixel;
717 menu->s_frg_color = s_frg_color.pixel;
718 menu->bkgnd_color = bkgnd_color.pixel;
719 /* -------------------- Pixmap data -------------------- */
720 menu->p_bdr_pixmap = None;
721 menu->s_bdr_pixmap = None;
722 menu->p_frg_pixmap = None;
723 menu->s_frg_pixmap = None;
724 menu->bkgnd_pixmap = None;
725 menu->inact_pixmap = inact_bitmap;
726
727 /*
728 * Return the completed XMenu.
729 */
730 _XMErrorCode = XME_NO_ERROR;
731 return(menu);
732}