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