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