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