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