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