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