annotate oldXMenu/Internal.c @ 64258:07d8968e1e9c

(command-line): Revert to previous handling of tooltip-mode. Explain in comment why the complexity is needed.
author Luc Teirlinck <teirllm@auburn.edu>
date Tue, 12 Jul 2005 20:15:57 +0000
parents e8824c4f5f7e
children 3861ff8f4bf1 8e5779acd195
Ignore whitespace changes - Everywhere: Within whitespace: At end of lines:
rev   line source
25858
Dave Love <fx@gnu.org>
parents:
diff changeset
1 #include "copyright.h"
Dave Love <fx@gnu.org>
parents:
diff changeset
2
Dave Love <fx@gnu.org>
parents:
diff changeset
3 /* Copyright Massachusetts Institute of Technology 1985 */
Dave Love <fx@gnu.org>
parents:
diff changeset
4
Dave Love <fx@gnu.org>
parents:
diff changeset
5 /*
Dave Love <fx@gnu.org>
parents:
diff changeset
6 * XMenu: MIT Project Athena, X Window system menu package
Dave Love <fx@gnu.org>
parents:
diff changeset
7 *
Dave Love <fx@gnu.org>
parents:
diff changeset
8 * XMenuInternal.c - XMenu internal (not user visible) routines.
Dave Love <fx@gnu.org>
parents:
diff changeset
9 *
Dave Love <fx@gnu.org>
parents:
diff changeset
10 * Author: Tony Della Fera, DEC
Dave Love <fx@gnu.org>
parents:
diff changeset
11 * November, 1985
Dave Love <fx@gnu.org>
parents:
diff changeset
12 *
Dave Love <fx@gnu.org>
parents:
diff changeset
13 */
Dave Love <fx@gnu.org>
parents:
diff changeset
14
Dave Love <fx@gnu.org>
parents:
diff changeset
15 #include <config.h>
Dave Love <fx@gnu.org>
parents:
diff changeset
16 #include "XMenuInt.h"
Dave Love <fx@gnu.org>
parents:
diff changeset
17
Dave Love <fx@gnu.org>
parents:
diff changeset
18 /*
Dave Love <fx@gnu.org>
parents:
diff changeset
19 * Toggle color macro.
Dave Love <fx@gnu.org>
parents:
diff changeset
20 */
Dave Love <fx@gnu.org>
parents:
diff changeset
21 #define toggle_color(x) \
Dave Love <fx@gnu.org>
parents:
diff changeset
22 ((x) == menu->bkgnd_color ? menu->s_frg_color : menu->bkgnd_color)
Dave Love <fx@gnu.org>
parents:
diff changeset
23
Dave Love <fx@gnu.org>
parents:
diff changeset
24 /*
Dave Love <fx@gnu.org>
parents:
diff changeset
25 * Internal Window creation queue sizes.
Dave Love <fx@gnu.org>
parents:
diff changeset
26 */
Dave Love <fx@gnu.org>
parents:
diff changeset
27 #define S_QUE_SIZE 300
Dave Love <fx@gnu.org>
parents:
diff changeset
28 #define P_QUE_SIZE 20
Dave Love <fx@gnu.org>
parents:
diff changeset
29 #define BUFFER_SIZE (S_QUE_SIZE >= P_QUE_SIZE ? S_QUE_SIZE : P_QUE_SIZE)
Dave Love <fx@gnu.org>
parents:
diff changeset
30
Dave Love <fx@gnu.org>
parents:
diff changeset
31
Dave Love <fx@gnu.org>
parents:
diff changeset
32 /*
Dave Love <fx@gnu.org>
parents:
diff changeset
33 * XMWinQue - Internal window creation queue datatype.
Dave Love <fx@gnu.org>
parents:
diff changeset
34 */
Dave Love <fx@gnu.org>
parents:
diff changeset
35 typedef struct _xmwinquedef {
Dave Love <fx@gnu.org>
parents:
diff changeset
36 int sq_size;
Dave Love <fx@gnu.org>
parents:
diff changeset
37 XMSelect *sq[S_QUE_SIZE];
Dave Love <fx@gnu.org>
parents:
diff changeset
38 XMSelect **sq_ptr;
Dave Love <fx@gnu.org>
parents:
diff changeset
39 int pq_size;
Dave Love <fx@gnu.org>
parents:
diff changeset
40 XMPane *pq[P_QUE_SIZE];
Dave Love <fx@gnu.org>
parents:
diff changeset
41 XMPane **pq_ptr;
Dave Love <fx@gnu.org>
parents:
diff changeset
42 } XMWinQue;
Dave Love <fx@gnu.org>
parents:
diff changeset
43
Dave Love <fx@gnu.org>
parents:
diff changeset
44 /*
Dave Love <fx@gnu.org>
parents:
diff changeset
45 * _XMWinQue - Internal static window creation queue.
Dave Love <fx@gnu.org>
parents:
diff changeset
46 */
Dave Love <fx@gnu.org>
parents:
diff changeset
47 static Bool _XMWinQueIsInit = False;
Dave Love <fx@gnu.org>
parents:
diff changeset
48 static XMWinQue _XMWinQue;
Dave Love <fx@gnu.org>
parents:
diff changeset
49
Dave Love <fx@gnu.org>
parents:
diff changeset
50 /*
Dave Love <fx@gnu.org>
parents:
diff changeset
51 * _XMErrorCode - Global XMenu error code.
Dave Love <fx@gnu.org>
parents:
diff changeset
52 */
49600
23a1cea22d13 Trailing whitespace deleted.
Juanma Barranquero <lekktu@gmail.com>
parents: 25858
diff changeset
53 int _XMErrorCode = XME_NO_ERROR;
25858
Dave Love <fx@gnu.org>
parents:
diff changeset
54 /*
Dave Love <fx@gnu.org>
parents:
diff changeset
55 * _XMErrorList - Global XMenu error code description strings.
Dave Love <fx@gnu.org>
parents:
diff changeset
56 */
Dave Love <fx@gnu.org>
parents:
diff changeset
57 char *
Dave Love <fx@gnu.org>
parents:
diff changeset
58 _XMErrorList[XME_CODE_COUNT] = {
Dave Love <fx@gnu.org>
parents:
diff changeset
59 "No error", /* XME_NO_ERROR */
Dave Love <fx@gnu.org>
parents:
diff changeset
60 "Menu not initialized", /* XME_NOT_INIT */
Dave Love <fx@gnu.org>
parents:
diff changeset
61 "Argument out of bounds", /* XME_ARG_BOUNDS */
Dave Love <fx@gnu.org>
parents:
diff changeset
62 "Pane not found", /* XME_P_NOT_FOUND */
Dave Love <fx@gnu.org>
parents:
diff changeset
63 "Selection not found", /* XME_S_NOT_FOUND */
Dave Love <fx@gnu.org>
parents:
diff changeset
64 "Invalid menu style parameter", /* XME_STYLE_PARAM */
Dave Love <fx@gnu.org>
parents:
diff changeset
65 "Unable to grab mouse", /* XME_GRAB_MOUSE */
Dave Love <fx@gnu.org>
parents:
diff changeset
66 "Unable to interpret locator", /* XME_INTERP_LOC */
Dave Love <fx@gnu.org>
parents:
diff changeset
67 "Unable to calloc memory", /* XME_CALLOC */
Dave Love <fx@gnu.org>
parents:
diff changeset
68 "Unable to create XAssocTable", /* XME_CREATE_ASSOC */
Dave Love <fx@gnu.org>
parents:
diff changeset
69 "Unable to store bitmap", /* XME_STORE_BITMAP */
Dave Love <fx@gnu.org>
parents:
diff changeset
70 "Unable to make tile pixmaps", /* XME_MAKE_TILES */
Dave Love <fx@gnu.org>
parents:
diff changeset
71 "Unable to make pixmap", /* XME_MAKE_PIXMAP */
Dave Love <fx@gnu.org>
parents:
diff changeset
72 "Unable to create cursor", /* XME_CREATE_CURSOR */
Dave Love <fx@gnu.org>
parents:
diff changeset
73 "Unable to open font", /* XME_OPEN_FONT */
Dave Love <fx@gnu.org>
parents:
diff changeset
74 "Unable to create windows", /* XME_CREATE_WINDOW */
Dave Love <fx@gnu.org>
parents:
diff changeset
75 "Unable to create transparencies", /* XME_CREATE_TRANSP */
Dave Love <fx@gnu.org>
parents:
diff changeset
76 };
Dave Love <fx@gnu.org>
parents:
diff changeset
77
Dave Love <fx@gnu.org>
parents:
diff changeset
78 /*
Dave Love <fx@gnu.org>
parents:
diff changeset
79 * _XMEventHandler - Internal event handler variable.
Dave Love <fx@gnu.org>
parents:
diff changeset
80 */
Dave Love <fx@gnu.org>
parents:
diff changeset
81 int (*_XMEventHandler)() = NULL;
Dave Love <fx@gnu.org>
parents:
diff changeset
82
Dave Love <fx@gnu.org>
parents:
diff changeset
83
Dave Love <fx@gnu.org>
parents:
diff changeset
84
Dave Love <fx@gnu.org>
parents:
diff changeset
85 /*
Dave Love <fx@gnu.org>
parents:
diff changeset
86 * _XMWinQueInit - Internal routine to initialize the window
Dave Love <fx@gnu.org>
parents:
diff changeset
87 * queue.
Dave Love <fx@gnu.org>
parents:
diff changeset
88 */
Dave Love <fx@gnu.org>
parents:
diff changeset
89 _XMWinQueInit()
Dave Love <fx@gnu.org>
parents:
diff changeset
90 {
Dave Love <fx@gnu.org>
parents:
diff changeset
91 /*
Dave Love <fx@gnu.org>
parents:
diff changeset
92 * If the queue is not initialized initialize it.
Dave Love <fx@gnu.org>
parents:
diff changeset
93 */
Dave Love <fx@gnu.org>
parents:
diff changeset
94 if (!_XMWinQueIsInit) {
Dave Love <fx@gnu.org>
parents:
diff changeset
95 /*
Dave Love <fx@gnu.org>
parents:
diff changeset
96 * Blank the queue structure.
Dave Love <fx@gnu.org>
parents:
diff changeset
97 */
Dave Love <fx@gnu.org>
parents:
diff changeset
98 register int i;
Dave Love <fx@gnu.org>
parents:
diff changeset
99
Dave Love <fx@gnu.org>
parents:
diff changeset
100 for (i = 0; i < S_QUE_SIZE; i++)
Dave Love <fx@gnu.org>
parents:
diff changeset
101 _XMWinQue.sq[i] = 0;
Dave Love <fx@gnu.org>
parents:
diff changeset
102
Dave Love <fx@gnu.org>
parents:
diff changeset
103 for (i = 0; i < P_QUE_SIZE; i++)
Dave Love <fx@gnu.org>
parents:
diff changeset
104 _XMWinQue.pq[i] = 0;
Dave Love <fx@gnu.org>
parents:
diff changeset
105
Dave Love <fx@gnu.org>
parents:
diff changeset
106 _XMWinQue.sq_size = _XMWinQue.pq_size = 0;
Dave Love <fx@gnu.org>
parents:
diff changeset
107
Dave Love <fx@gnu.org>
parents:
diff changeset
108 /*
Dave Love <fx@gnu.org>
parents:
diff changeset
109 * Initialize the next free location pointers.
Dave Love <fx@gnu.org>
parents:
diff changeset
110 */
Dave Love <fx@gnu.org>
parents:
diff changeset
111 _XMWinQue.sq_ptr = _XMWinQue.sq;
Dave Love <fx@gnu.org>
parents:
diff changeset
112 _XMWinQue.pq_ptr = _XMWinQue.pq;
Dave Love <fx@gnu.org>
parents:
diff changeset
113 }
Dave Love <fx@gnu.org>
parents:
diff changeset
114 }
Dave Love <fx@gnu.org>
parents:
diff changeset
115
Dave Love <fx@gnu.org>
parents:
diff changeset
116
Dave Love <fx@gnu.org>
parents:
diff changeset
117
Dave Love <fx@gnu.org>
parents:
diff changeset
118 /*
Dave Love <fx@gnu.org>
parents:
diff changeset
119 * _XMWinQueAddPane - Internal routine to add a pane to the pane
Dave Love <fx@gnu.org>
parents:
diff changeset
120 * window queue.
Dave Love <fx@gnu.org>
parents:
diff changeset
121 */
Dave Love <fx@gnu.org>
parents:
diff changeset
122 int
Dave Love <fx@gnu.org>
parents:
diff changeset
123 _XMWinQueAddPane(display, menu, p_ptr)
Dave Love <fx@gnu.org>
parents:
diff changeset
124 register Display *display;
Dave Love <fx@gnu.org>
parents:
diff changeset
125 register XMenu *menu; /* Menu being manipulated. */
Dave Love <fx@gnu.org>
parents:
diff changeset
126 register XMPane *p_ptr; /* XMPane being queued. */
Dave Love <fx@gnu.org>
parents:
diff changeset
127 {
Dave Love <fx@gnu.org>
parents:
diff changeset
128 /*
Dave Love <fx@gnu.org>
parents:
diff changeset
129 * If the queue is currently full then flush it.
Dave Love <fx@gnu.org>
parents:
diff changeset
130 */
Dave Love <fx@gnu.org>
parents:
diff changeset
131 if (_XMWinQue.pq_size == P_QUE_SIZE) {
Dave Love <fx@gnu.org>
parents:
diff changeset
132 if (_XMWinQueFlush(display, menu, 0, 0) == _FAILURE) return(_FAILURE);
Dave Love <fx@gnu.org>
parents:
diff changeset
133 }
Dave Love <fx@gnu.org>
parents:
diff changeset
134
Dave Love <fx@gnu.org>
parents:
diff changeset
135 /*
Dave Love <fx@gnu.org>
parents:
diff changeset
136 * Insert the new XMPane pointer and increment the queue pointer
Dave Love <fx@gnu.org>
parents:
diff changeset
137 * and the queue size.
Dave Love <fx@gnu.org>
parents:
diff changeset
138 */
Dave Love <fx@gnu.org>
parents:
diff changeset
139 *_XMWinQue.pq_ptr = p_ptr;
Dave Love <fx@gnu.org>
parents:
diff changeset
140 _XMWinQue.pq_ptr++;
Dave Love <fx@gnu.org>
parents:
diff changeset
141 _XMWinQue.pq_size++;
Dave Love <fx@gnu.org>
parents:
diff changeset
142
Dave Love <fx@gnu.org>
parents:
diff changeset
143 /*
Dave Love <fx@gnu.org>
parents:
diff changeset
144 * All went well, return successfully.
Dave Love <fx@gnu.org>
parents:
diff changeset
145 */
Dave Love <fx@gnu.org>
parents:
diff changeset
146 _XMErrorCode = XME_NO_ERROR;
Dave Love <fx@gnu.org>
parents:
diff changeset
147 return(_SUCCESS);
Dave Love <fx@gnu.org>
parents:
diff changeset
148 }
Dave Love <fx@gnu.org>
parents:
diff changeset
149
Dave Love <fx@gnu.org>
parents:
diff changeset
150
Dave Love <fx@gnu.org>
parents:
diff changeset
151
Dave Love <fx@gnu.org>
parents:
diff changeset
152 /*
Dave Love <fx@gnu.org>
parents:
diff changeset
153 * _XMWinQueAddSelection - Internal routine to add a selection to
Dave Love <fx@gnu.org>
parents:
diff changeset
154 * the selection window queue.
Dave Love <fx@gnu.org>
parents:
diff changeset
155 */
Dave Love <fx@gnu.org>
parents:
diff changeset
156 int
Dave Love <fx@gnu.org>
parents:
diff changeset
157 _XMWinQueAddSelection(display, menu, s_ptr)
Dave Love <fx@gnu.org>
parents:
diff changeset
158 register Display *display;
Dave Love <fx@gnu.org>
parents:
diff changeset
159 register XMenu *menu; /* Menu being manipulated. */
Dave Love <fx@gnu.org>
parents:
diff changeset
160 register XMSelect *s_ptr; /* XMSelection being queued. */
Dave Love <fx@gnu.org>
parents:
diff changeset
161 {
Dave Love <fx@gnu.org>
parents:
diff changeset
162 /*
Dave Love <fx@gnu.org>
parents:
diff changeset
163 * If this entry will overflow the queue then flush it.
Dave Love <fx@gnu.org>
parents:
diff changeset
164 */
Dave Love <fx@gnu.org>
parents:
diff changeset
165 if (_XMWinQue.sq_size == S_QUE_SIZE) {
Dave Love <fx@gnu.org>
parents:
diff changeset
166 if (_XMWinQueFlush(display, menu, 0, 0) == _FAILURE) return(_FAILURE);
Dave Love <fx@gnu.org>
parents:
diff changeset
167 }
Dave Love <fx@gnu.org>
parents:
diff changeset
168
Dave Love <fx@gnu.org>
parents:
diff changeset
169 /*
Dave Love <fx@gnu.org>
parents:
diff changeset
170 * Insert the new XMSelect pointer and increment the queue pointer
Dave Love <fx@gnu.org>
parents:
diff changeset
171 * and the queue size.
Dave Love <fx@gnu.org>
parents:
diff changeset
172 */
Dave Love <fx@gnu.org>
parents:
diff changeset
173 *_XMWinQue.sq_ptr = s_ptr;
Dave Love <fx@gnu.org>
parents:
diff changeset
174 _XMWinQue.sq_ptr++;
Dave Love <fx@gnu.org>
parents:
diff changeset
175 _XMWinQue.sq_size++;
Dave Love <fx@gnu.org>
parents:
diff changeset
176
Dave Love <fx@gnu.org>
parents:
diff changeset
177 /*
Dave Love <fx@gnu.org>
parents:
diff changeset
178 * All went well, return successfully.
Dave Love <fx@gnu.org>
parents:
diff changeset
179 */
Dave Love <fx@gnu.org>
parents:
diff changeset
180 _XMErrorCode = XME_NO_ERROR;
Dave Love <fx@gnu.org>
parents:
diff changeset
181 return(_SUCCESS);
Dave Love <fx@gnu.org>
parents:
diff changeset
182 }
Dave Love <fx@gnu.org>
parents:
diff changeset
183
Dave Love <fx@gnu.org>
parents:
diff changeset
184
Dave Love <fx@gnu.org>
parents:
diff changeset
185
Dave Love <fx@gnu.org>
parents:
diff changeset
186 /*
Dave Love <fx@gnu.org>
parents:
diff changeset
187 * _XMWinQueFlush - Internal routine to flush the pane and
Dave Love <fx@gnu.org>
parents:
diff changeset
188 * selection window queues.
Dave Love <fx@gnu.org>
parents:
diff changeset
189 */
Dave Love <fx@gnu.org>
parents:
diff changeset
190 int
Dave Love <fx@gnu.org>
parents:
diff changeset
191 _XMWinQueFlush(display, menu, pane, select)
Dave Love <fx@gnu.org>
parents:
diff changeset
192 register Display *display;
Dave Love <fx@gnu.org>
parents:
diff changeset
193 register XMenu *menu; /* Menu being manipulated. */
Dave Love <fx@gnu.org>
parents:
diff changeset
194 register XMPane *pane; /* Current pane. */
Dave Love <fx@gnu.org>
parents:
diff changeset
195 {
Dave Love <fx@gnu.org>
parents:
diff changeset
196 register int pq_index; /* Pane queue index. */
Dave Love <fx@gnu.org>
parents:
diff changeset
197 register int sq_index; /* Selection queue index. */
Dave Love <fx@gnu.org>
parents:
diff changeset
198 register XMPane *p_ptr; /* XMPane pointer. */
Dave Love <fx@gnu.org>
parents:
diff changeset
199 register XMSelect *s_ptr; /* XMSelect pointer. */
Dave Love <fx@gnu.org>
parents:
diff changeset
200 unsigned long valuemask; /* Which attributes to set. */
Dave Love <fx@gnu.org>
parents:
diff changeset
201 XSetWindowAttributes *attributes; /* Attributes to be set. */
Dave Love <fx@gnu.org>
parents:
diff changeset
202
Dave Love <fx@gnu.org>
parents:
diff changeset
203 /*
Dave Love <fx@gnu.org>
parents:
diff changeset
204 * If the pane window queue is not empty...
Dave Love <fx@gnu.org>
parents:
diff changeset
205 */
49600
23a1cea22d13 Trailing whitespace deleted.
Juanma Barranquero <lekktu@gmail.com>
parents: 25858
diff changeset
206
25858
Dave Love <fx@gnu.org>
parents:
diff changeset
207 if (_XMWinQue.pq_size > 0) {
Dave Love <fx@gnu.org>
parents:
diff changeset
208 /*
Dave Love <fx@gnu.org>
parents:
diff changeset
209 * set up attributes for pane window to be created.
Dave Love <fx@gnu.org>
parents:
diff changeset
210 */
Dave Love <fx@gnu.org>
parents:
diff changeset
211 valuemask = (CWBackPixmap | CWBorderPixel | CWOverrideRedirect);
Dave Love <fx@gnu.org>
parents:
diff changeset
212 attributes = (XSetWindowAttributes *)malloc(sizeof(XSetWindowAttributes));
Dave Love <fx@gnu.org>
parents:
diff changeset
213 attributes->border_pixel = menu->p_bdr_color;
Dave Love <fx@gnu.org>
parents:
diff changeset
214 attributes->background_pixmap = menu->inact_pixmap;
Dave Love <fx@gnu.org>
parents:
diff changeset
215 attributes->override_redirect = True;
49600
23a1cea22d13 Trailing whitespace deleted.
Juanma Barranquero <lekktu@gmail.com>
parents: 25858
diff changeset
216
25858
Dave Love <fx@gnu.org>
parents:
diff changeset
217 /*
Dave Love <fx@gnu.org>
parents:
diff changeset
218 * Create all the pending panes in order, so that the
Dave Love <fx@gnu.org>
parents:
diff changeset
219 * current pane will be on top, with the others
Dave Love <fx@gnu.org>
parents:
diff changeset
220 * stacked appropriately under it.
Dave Love <fx@gnu.org>
parents:
diff changeset
221 */
Dave Love <fx@gnu.org>
parents:
diff changeset
222 for (pq_index = _XMWinQue.pq_size - 1;
Dave Love <fx@gnu.org>
parents:
diff changeset
223 pq_index >= 0;
49600
23a1cea22d13 Trailing whitespace deleted.
Juanma Barranquero <lekktu@gmail.com>
parents: 25858
diff changeset
224 pq_index--)
25858
Dave Love <fx@gnu.org>
parents:
diff changeset
225 {
Dave Love <fx@gnu.org>
parents:
diff changeset
226 p_ptr = _XMWinQue.pq[pq_index]; /* Retrieve next pane. */
Dave Love <fx@gnu.org>
parents:
diff changeset
227 if (p_ptr == pane) break;
Dave Love <fx@gnu.org>
parents:
diff changeset
228 p_ptr->window = XCreateWindow(display,
Dave Love <fx@gnu.org>
parents:
diff changeset
229 menu->parent,
Dave Love <fx@gnu.org>
parents:
diff changeset
230 p_ptr->window_x,
Dave Love <fx@gnu.org>
parents:
diff changeset
231 p_ptr->window_y,
Dave Love <fx@gnu.org>
parents:
diff changeset
232 p_ptr->window_w,
Dave Love <fx@gnu.org>
parents:
diff changeset
233 p_ptr->window_h,
Dave Love <fx@gnu.org>
parents:
diff changeset
234 menu->p_bdr_width,
Dave Love <fx@gnu.org>
parents:
diff changeset
235 CopyFromParent,
Dave Love <fx@gnu.org>
parents:
diff changeset
236 InputOutput,
Dave Love <fx@gnu.org>
parents:
diff changeset
237 CopyFromParent,
Dave Love <fx@gnu.org>
parents:
diff changeset
238 valuemask,
Dave Love <fx@gnu.org>
parents:
diff changeset
239 attributes);
Dave Love <fx@gnu.org>
parents:
diff changeset
240 XMakeAssoc(display, menu->assoc_tab, p_ptr->window, p_ptr);
Dave Love <fx@gnu.org>
parents:
diff changeset
241 XSelectInput(display, p_ptr->window, menu->p_events);
Dave Love <fx@gnu.org>
parents:
diff changeset
242 }
Dave Love <fx@gnu.org>
parents:
diff changeset
243 for (pq_index = 0;
Dave Love <fx@gnu.org>
parents:
diff changeset
244 pq_index < _XMWinQue.pq_size;
49600
23a1cea22d13 Trailing whitespace deleted.
Juanma Barranquero <lekktu@gmail.com>
parents: 25858
diff changeset
245 pq_index++)
25858
Dave Love <fx@gnu.org>
parents:
diff changeset
246 {
Dave Love <fx@gnu.org>
parents:
diff changeset
247 p_ptr = _XMWinQue.pq[pq_index]; /* Retrieve next pane. */
Dave Love <fx@gnu.org>
parents:
diff changeset
248 p_ptr->window = XCreateWindow(display,
Dave Love <fx@gnu.org>
parents:
diff changeset
249 menu->parent,
Dave Love <fx@gnu.org>
parents:
diff changeset
250 p_ptr->window_x,
Dave Love <fx@gnu.org>
parents:
diff changeset
251 p_ptr->window_y,
Dave Love <fx@gnu.org>
parents:
diff changeset
252 p_ptr->window_w,
Dave Love <fx@gnu.org>
parents:
diff changeset
253 p_ptr->window_h,
Dave Love <fx@gnu.org>
parents:
diff changeset
254 menu->p_bdr_width,
Dave Love <fx@gnu.org>
parents:
diff changeset
255 CopyFromParent,
Dave Love <fx@gnu.org>
parents:
diff changeset
256 InputOutput,
Dave Love <fx@gnu.org>
parents:
diff changeset
257 CopyFromParent,
Dave Love <fx@gnu.org>
parents:
diff changeset
258 valuemask,
Dave Love <fx@gnu.org>
parents:
diff changeset
259 attributes);
Dave Love <fx@gnu.org>
parents:
diff changeset
260 XMakeAssoc(display, menu->assoc_tab, p_ptr->window, p_ptr);
Dave Love <fx@gnu.org>
parents:
diff changeset
261 XSelectInput(display, p_ptr->window, menu->p_events);
Dave Love <fx@gnu.org>
parents:
diff changeset
262 if (p_ptr == pane) break;
Dave Love <fx@gnu.org>
parents:
diff changeset
263 }
Dave Love <fx@gnu.org>
parents:
diff changeset
264
Dave Love <fx@gnu.org>
parents:
diff changeset
265 /*
Dave Love <fx@gnu.org>
parents:
diff changeset
266 * Reset the pane queue pointer and size.
Dave Love <fx@gnu.org>
parents:
diff changeset
267 */
Dave Love <fx@gnu.org>
parents:
diff changeset
268 _XMWinQue.pq_size = 0;
Dave Love <fx@gnu.org>
parents:
diff changeset
269 _XMWinQue.pq_ptr = _XMWinQue.pq;
Dave Love <fx@gnu.org>
parents:
diff changeset
270 }
Dave Love <fx@gnu.org>
parents:
diff changeset
271
Dave Love <fx@gnu.org>
parents:
diff changeset
272 /*
Dave Love <fx@gnu.org>
parents:
diff changeset
273 * If the selection window queue is not empty...
Dave Love <fx@gnu.org>
parents:
diff changeset
274 */
49600
23a1cea22d13 Trailing whitespace deleted.
Juanma Barranquero <lekktu@gmail.com>
parents: 25858
diff changeset
275
25858
Dave Love <fx@gnu.org>
parents:
diff changeset
276 if (_XMWinQue.sq_size > 0) {
Dave Love <fx@gnu.org>
parents:
diff changeset
277
Dave Love <fx@gnu.org>
parents:
diff changeset
278 for (sq_index = 0; sq_index < _XMWinQue.sq_size; sq_index++) {
Dave Love <fx@gnu.org>
parents:
diff changeset
279 /*
Dave Love <fx@gnu.org>
parents:
diff changeset
280 * Retrieve the XMSelect pointer.
Dave Love <fx@gnu.org>
parents:
diff changeset
281 */
Dave Love <fx@gnu.org>
parents:
diff changeset
282 s_ptr = _XMWinQue.sq[sq_index];
Dave Love <fx@gnu.org>
parents:
diff changeset
283 s_ptr->window = XCreateWindow(display,
Dave Love <fx@gnu.org>
parents:
diff changeset
284 s_ptr->parent_p->window,
Dave Love <fx@gnu.org>
parents:
diff changeset
285 s_ptr->window_x,
Dave Love <fx@gnu.org>
parents:
diff changeset
286 s_ptr->window_y,
Dave Love <fx@gnu.org>
parents:
diff changeset
287 s_ptr->window_w,
Dave Love <fx@gnu.org>
parents:
diff changeset
288 s_ptr->window_h,
Dave Love <fx@gnu.org>
parents:
diff changeset
289 0, /* border width*/
Dave Love <fx@gnu.org>
parents:
diff changeset
290 CopyFromParent,
Dave Love <fx@gnu.org>
parents:
diff changeset
291 InputOnly,
Dave Love <fx@gnu.org>
parents:
diff changeset
292 CopyFromParent,
Dave Love <fx@gnu.org>
parents:
diff changeset
293 0,
Dave Love <fx@gnu.org>
parents:
diff changeset
294 attributes);
49600
23a1cea22d13 Trailing whitespace deleted.
Juanma Barranquero <lekktu@gmail.com>
parents: 25858
diff changeset
295
25858
Dave Love <fx@gnu.org>
parents:
diff changeset
296 /*
Dave Love <fx@gnu.org>
parents:
diff changeset
297 * Insert the new window id and its
49600
23a1cea22d13 Trailing whitespace deleted.
Juanma Barranquero <lekktu@gmail.com>
parents: 25858
diff changeset
298 * associated XMSelect structure into the
25858
Dave Love <fx@gnu.org>
parents:
diff changeset
299 * association table.
Dave Love <fx@gnu.org>
parents:
diff changeset
300 */
Dave Love <fx@gnu.org>
parents:
diff changeset
301 XMakeAssoc(display, menu->assoc_tab, s_ptr->window, s_ptr);
Dave Love <fx@gnu.org>
parents:
diff changeset
302 XSelectInput(display, s_ptr->window, menu->s_events);
Dave Love <fx@gnu.org>
parents:
diff changeset
303 }
Dave Love <fx@gnu.org>
parents:
diff changeset
304
Dave Love <fx@gnu.org>
parents:
diff changeset
305 /*
Dave Love <fx@gnu.org>
parents:
diff changeset
306 * Reset the selection queue pointer and size.
Dave Love <fx@gnu.org>
parents:
diff changeset
307 */
Dave Love <fx@gnu.org>
parents:
diff changeset
308 _XMWinQue.sq_size = 0;
Dave Love <fx@gnu.org>
parents:
diff changeset
309 _XMWinQue.sq_ptr = _XMWinQue.sq;
Dave Love <fx@gnu.org>
parents:
diff changeset
310 }
Dave Love <fx@gnu.org>
parents:
diff changeset
311
Dave Love <fx@gnu.org>
parents:
diff changeset
312 /*
Dave Love <fx@gnu.org>
parents:
diff changeset
313 * Flush X's internal queues.
Dave Love <fx@gnu.org>
parents:
diff changeset
314 */
Dave Love <fx@gnu.org>
parents:
diff changeset
315 XFlush(display);
Dave Love <fx@gnu.org>
parents:
diff changeset
316
Dave Love <fx@gnu.org>
parents:
diff changeset
317 /*
Dave Love <fx@gnu.org>
parents:
diff changeset
318 * All went well, return successfully.
Dave Love <fx@gnu.org>
parents:
diff changeset
319 */
Dave Love <fx@gnu.org>
parents:
diff changeset
320 _XMErrorCode = XME_NO_ERROR;
Dave Love <fx@gnu.org>
parents:
diff changeset
321 return(_SUCCESS);
Dave Love <fx@gnu.org>
parents:
diff changeset
322 }
Dave Love <fx@gnu.org>
parents:
diff changeset
323
Dave Love <fx@gnu.org>
parents:
diff changeset
324
Dave Love <fx@gnu.org>
parents:
diff changeset
325
Dave Love <fx@gnu.org>
parents:
diff changeset
326 /*
Dave Love <fx@gnu.org>
parents:
diff changeset
327 * _XMGetPanePtr - Given a menu pointer and a pane index number, return
Dave Love <fx@gnu.org>
parents:
diff changeset
328 * a pane pointer that points to the indexed pane.
Dave Love <fx@gnu.org>
parents:
diff changeset
329 */
Dave Love <fx@gnu.org>
parents:
diff changeset
330 XMPane *
Dave Love <fx@gnu.org>
parents:
diff changeset
331 _XMGetPanePtr(menu, p_num)
Dave Love <fx@gnu.org>
parents:
diff changeset
332 register XMenu *menu; /* Menu to find the pane in. */
Dave Love <fx@gnu.org>
parents:
diff changeset
333 register int p_num; /* Index number of pane to find. */
Dave Love <fx@gnu.org>
parents:
diff changeset
334 {
Dave Love <fx@gnu.org>
parents:
diff changeset
335 register XMPane *p_ptr; /* Pane pointer to be returned. */
Dave Love <fx@gnu.org>
parents:
diff changeset
336 register int i; /* Loop counter. */
Dave Love <fx@gnu.org>
parents:
diff changeset
337
Dave Love <fx@gnu.org>
parents:
diff changeset
338 /*
Dave Love <fx@gnu.org>
parents:
diff changeset
339 * Is the pane number out of range?
Dave Love <fx@gnu.org>
parents:
diff changeset
340 */
Dave Love <fx@gnu.org>
parents:
diff changeset
341 if ((p_num < 0) || (p_num > (menu->p_count - 1))) {
Dave Love <fx@gnu.org>
parents:
diff changeset
342 _XMErrorCode = XME_P_NOT_FOUND;
Dave Love <fx@gnu.org>
parents:
diff changeset
343 return(NULL);
Dave Love <fx@gnu.org>
parents:
diff changeset
344 }
Dave Love <fx@gnu.org>
parents:
diff changeset
345
Dave Love <fx@gnu.org>
parents:
diff changeset
346 /*
Dave Love <fx@gnu.org>
parents:
diff changeset
347 * Find the right pane.
Dave Love <fx@gnu.org>
parents:
diff changeset
348 */
Dave Love <fx@gnu.org>
parents:
diff changeset
349 p_ptr = menu->p_list->next;
Dave Love <fx@gnu.org>
parents:
diff changeset
350 for (i = 0; i < p_num; i++) p_ptr = p_ptr->next;
Dave Love <fx@gnu.org>
parents:
diff changeset
351
Dave Love <fx@gnu.org>
parents:
diff changeset
352 /*
Dave Love <fx@gnu.org>
parents:
diff changeset
353 * Return successfully.
Dave Love <fx@gnu.org>
parents:
diff changeset
354 */
Dave Love <fx@gnu.org>
parents:
diff changeset
355 _XMErrorCode = XME_NO_ERROR;
Dave Love <fx@gnu.org>
parents:
diff changeset
356 return(p_ptr);
Dave Love <fx@gnu.org>
parents:
diff changeset
357 }
Dave Love <fx@gnu.org>
parents:
diff changeset
358
Dave Love <fx@gnu.org>
parents:
diff changeset
359
Dave Love <fx@gnu.org>
parents:
diff changeset
360
Dave Love <fx@gnu.org>
parents:
diff changeset
361 /*
Dave Love <fx@gnu.org>
parents:
diff changeset
362 * _XMGetSelectionPtr - Given pane pointer and a selection index number,
Dave Love <fx@gnu.org>
parents:
diff changeset
363 * return a selection pointer that points to the
Dave Love <fx@gnu.org>
parents:
diff changeset
364 * indexed selection.
Dave Love <fx@gnu.org>
parents:
diff changeset
365 */
Dave Love <fx@gnu.org>
parents:
diff changeset
366 XMSelect *
Dave Love <fx@gnu.org>
parents:
diff changeset
367 _XMGetSelectionPtr(p_ptr, s_num)
Dave Love <fx@gnu.org>
parents:
diff changeset
368 register XMPane *p_ptr; /* Pane to find the selection in. */
Dave Love <fx@gnu.org>
parents:
diff changeset
369 register int s_num; /* Index number of the selection to find. */
Dave Love <fx@gnu.org>
parents:
diff changeset
370 {
Dave Love <fx@gnu.org>
parents:
diff changeset
371 register XMSelect *s_ptr; /* Selection pointer to be returned. */
Dave Love <fx@gnu.org>
parents:
diff changeset
372 register int i; /* Loop counter. */
49600
23a1cea22d13 Trailing whitespace deleted.
Juanma Barranquero <lekktu@gmail.com>
parents: 25858
diff changeset
373
25858
Dave Love <fx@gnu.org>
parents:
diff changeset
374 /*
Dave Love <fx@gnu.org>
parents:
diff changeset
375 * Is the selection number out of range?
Dave Love <fx@gnu.org>
parents:
diff changeset
376 */
Dave Love <fx@gnu.org>
parents:
diff changeset
377 if ((s_num < 0) || (s_num > (p_ptr->s_count - 1))) {
Dave Love <fx@gnu.org>
parents:
diff changeset
378 _XMErrorCode = XME_S_NOT_FOUND;
Dave Love <fx@gnu.org>
parents:
diff changeset
379 return(NULL);
Dave Love <fx@gnu.org>
parents:
diff changeset
380 }
Dave Love <fx@gnu.org>
parents:
diff changeset
381
Dave Love <fx@gnu.org>
parents:
diff changeset
382 /*
Dave Love <fx@gnu.org>
parents:
diff changeset
383 * Find the right selection.
Dave Love <fx@gnu.org>
parents:
diff changeset
384 */
Dave Love <fx@gnu.org>
parents:
diff changeset
385 s_ptr = p_ptr->s_list->next;
Dave Love <fx@gnu.org>
parents:
diff changeset
386 for (i = 0; i < s_num; i++) s_ptr = s_ptr->next;
Dave Love <fx@gnu.org>
parents:
diff changeset
387
Dave Love <fx@gnu.org>
parents:
diff changeset
388 /*
Dave Love <fx@gnu.org>
parents:
diff changeset
389 * Return successfully.
Dave Love <fx@gnu.org>
parents:
diff changeset
390 */
Dave Love <fx@gnu.org>
parents:
diff changeset
391 _XMErrorCode = XME_NO_ERROR;
Dave Love <fx@gnu.org>
parents:
diff changeset
392 return(s_ptr);
Dave Love <fx@gnu.org>
parents:
diff changeset
393 }
Dave Love <fx@gnu.org>
parents:
diff changeset
394
Dave Love <fx@gnu.org>
parents:
diff changeset
395
Dave Love <fx@gnu.org>
parents:
diff changeset
396
Dave Love <fx@gnu.org>
parents:
diff changeset
397 /*
Dave Love <fx@gnu.org>
parents:
diff changeset
398 * _XMRecomputeGlobals - Internal subroutine to recompute menu wide
Dave Love <fx@gnu.org>
parents:
diff changeset
399 * global values.
Dave Love <fx@gnu.org>
parents:
diff changeset
400 */
Dave Love <fx@gnu.org>
parents:
diff changeset
401 _XMRecomputeGlobals(display, menu)
49600
23a1cea22d13 Trailing whitespace deleted.
Juanma Barranquero <lekktu@gmail.com>
parents: 25858
diff changeset
402 register Display *display; /*X11 display variable. */
25858
Dave Love <fx@gnu.org>
parents:
diff changeset
403 register XMenu *menu; /* Menu object to compute from. */
Dave Love <fx@gnu.org>
parents:
diff changeset
404 {
Dave Love <fx@gnu.org>
parents:
diff changeset
405 register XMPane *p_ptr; /* Pane pointer. */
Dave Love <fx@gnu.org>
parents:
diff changeset
406 register XMSelect *s_ptr; /* Selection pointer. */
Dave Love <fx@gnu.org>
parents:
diff changeset
407
Dave Love <fx@gnu.org>
parents:
diff changeset
408 register int max_p_label = 0; /* Maximum pane label width. */
Dave Love <fx@gnu.org>
parents:
diff changeset
409 register int max_s_label = 0; /* Maximum selection label width. */
Dave Love <fx@gnu.org>
parents:
diff changeset
410 register int s_count = 0; /* Maximum selection count. */
Dave Love <fx@gnu.org>
parents:
diff changeset
411
Dave Love <fx@gnu.org>
parents:
diff changeset
412 int p_s_pad; /* Pane <-> selection padding. */
Dave Love <fx@gnu.org>
parents:
diff changeset
413 int p_s_diff; /* Pane <-> selection separation. */
Dave Love <fx@gnu.org>
parents:
diff changeset
414
Dave Love <fx@gnu.org>
parents:
diff changeset
415 int p_height; /* Pane window height. */
Dave Love <fx@gnu.org>
parents:
diff changeset
416 int p_width; /* Pane window width. */
Dave Love <fx@gnu.org>
parents:
diff changeset
417 int s_width; /* Selection window width. */
Dave Love <fx@gnu.org>
parents:
diff changeset
418
Dave Love <fx@gnu.org>
parents:
diff changeset
419 int screen; /* DefaultScreen holder. */
49600
23a1cea22d13 Trailing whitespace deleted.
Juanma Barranquero <lekktu@gmail.com>
parents: 25858
diff changeset
420
25858
Dave Love <fx@gnu.org>
parents:
diff changeset
421 /*
Dave Love <fx@gnu.org>
parents:
diff changeset
422 * For each pane...
Dave Love <fx@gnu.org>
parents:
diff changeset
423 */
Dave Love <fx@gnu.org>
parents:
diff changeset
424 for (
Dave Love <fx@gnu.org>
parents:
diff changeset
425 p_ptr = menu->p_list->next;
Dave Love <fx@gnu.org>
parents:
diff changeset
426 p_ptr != menu->p_list;
Dave Love <fx@gnu.org>
parents:
diff changeset
427 p_ptr = p_ptr->next
Dave Love <fx@gnu.org>
parents:
diff changeset
428 ){
49600
23a1cea22d13 Trailing whitespace deleted.
Juanma Barranquero <lekktu@gmail.com>
parents: 25858
diff changeset
429
25858
Dave Love <fx@gnu.org>
parents:
diff changeset
430 /*
Dave Love <fx@gnu.org>
parents:
diff changeset
431 * Recompute maximum pane label width.
Dave Love <fx@gnu.org>
parents:
diff changeset
432 */
Dave Love <fx@gnu.org>
parents:
diff changeset
433 max_p_label = max(max_p_label, p_ptr->label_width);
Dave Love <fx@gnu.org>
parents:
diff changeset
434
Dave Love <fx@gnu.org>
parents:
diff changeset
435 /*
49600
23a1cea22d13 Trailing whitespace deleted.
Juanma Barranquero <lekktu@gmail.com>
parents: 25858
diff changeset
436 * Recompute maximum selection count.
25858
Dave Love <fx@gnu.org>
parents:
diff changeset
437 */
Dave Love <fx@gnu.org>
parents:
diff changeset
438 s_count = max(s_count, p_ptr->s_count);
Dave Love <fx@gnu.org>
parents:
diff changeset
439
Dave Love <fx@gnu.org>
parents:
diff changeset
440 /*
Dave Love <fx@gnu.org>
parents:
diff changeset
441 * For each selection in the current pane...
Dave Love <fx@gnu.org>
parents:
diff changeset
442 */
Dave Love <fx@gnu.org>
parents:
diff changeset
443 for (
Dave Love <fx@gnu.org>
parents:
diff changeset
444 s_ptr = p_ptr->s_list->next;
Dave Love <fx@gnu.org>
parents:
diff changeset
445 s_ptr != p_ptr->s_list;
Dave Love <fx@gnu.org>
parents:
diff changeset
446 s_ptr = s_ptr->next
Dave Love <fx@gnu.org>
parents:
diff changeset
447 ){
Dave Love <fx@gnu.org>
parents:
diff changeset
448
Dave Love <fx@gnu.org>
parents:
diff changeset
449 /*
Dave Love <fx@gnu.org>
parents:
diff changeset
450 * Recompute maximum selection label width.
Dave Love <fx@gnu.org>
parents:
diff changeset
451 */
Dave Love <fx@gnu.org>
parents:
diff changeset
452 max_s_label = max(max_s_label, s_ptr->label_width);
Dave Love <fx@gnu.org>
parents:
diff changeset
453 }
Dave Love <fx@gnu.org>
parents:
diff changeset
454 }
Dave Love <fx@gnu.org>
parents:
diff changeset
455
Dave Love <fx@gnu.org>
parents:
diff changeset
456 /*
Dave Love <fx@gnu.org>
parents:
diff changeset
457 * Recompute pane height.
Dave Love <fx@gnu.org>
parents:
diff changeset
458 */
Dave Love <fx@gnu.org>
parents:
diff changeset
459 p_height = (menu->flag_height << 1) + (menu->s_y_off * s_count);
Dave Love <fx@gnu.org>
parents:
diff changeset
460
Dave Love <fx@gnu.org>
parents:
diff changeset
461 /*
Dave Love <fx@gnu.org>
parents:
diff changeset
462 * Recompute horizontal padding between the pane window and the
Dave Love <fx@gnu.org>
parents:
diff changeset
463 * selection windows.
Dave Love <fx@gnu.org>
parents:
diff changeset
464 */
Dave Love <fx@gnu.org>
parents:
diff changeset
465 p_s_pad = menu->p_x_off << 1;
Dave Love <fx@gnu.org>
parents:
diff changeset
466
Dave Love <fx@gnu.org>
parents:
diff changeset
467 /*
Dave Love <fx@gnu.org>
parents:
diff changeset
468 * Recompute pane and selection window widths.
Dave Love <fx@gnu.org>
parents:
diff changeset
469 * This is done by first computing the window sizes from the maximum
Dave Love <fx@gnu.org>
parents:
diff changeset
470 * label widths. If the spacing between the selection window and the
Dave Love <fx@gnu.org>
parents:
diff changeset
471 * containing pane window is less than the pane selection padding value
Dave Love <fx@gnu.org>
parents:
diff changeset
472 * (twice the pane X offset) then change the size of the pane to be
Dave Love <fx@gnu.org>
parents:
diff changeset
473 * the size of the selection window plus the padding. If, however the
Dave Love <fx@gnu.org>
parents:
diff changeset
474 * spacing between the selection window and the containing pane window
Dave Love <fx@gnu.org>
parents:
diff changeset
475 * is more than the pane selection padding value increase the size of
Dave Love <fx@gnu.org>
parents:
diff changeset
476 * the selection to its maximum possible value (the pane width minus
Dave Love <fx@gnu.org>
parents:
diff changeset
477 * the pane selection padding value).
Dave Love <fx@gnu.org>
parents:
diff changeset
478 */
Dave Love <fx@gnu.org>
parents:
diff changeset
479 p_width = max_p_label + p_s_pad;
Dave Love <fx@gnu.org>
parents:
diff changeset
480 s_width = max_s_label + (menu->s_fnt_pad << 1) + (menu->s_bdr_width << 1);
Dave Love <fx@gnu.org>
parents:
diff changeset
481 p_s_diff = p_width - s_width;
Dave Love <fx@gnu.org>
parents:
diff changeset
482 if (p_s_diff < p_s_pad) {
Dave Love <fx@gnu.org>
parents:
diff changeset
483 p_width = s_width + p_s_pad;
Dave Love <fx@gnu.org>
parents:
diff changeset
484 }
Dave Love <fx@gnu.org>
parents:
diff changeset
485 else if (p_s_diff > p_s_pad) {
Dave Love <fx@gnu.org>
parents:
diff changeset
486 s_width = p_width - p_s_pad;
Dave Love <fx@gnu.org>
parents:
diff changeset
487 }
Dave Love <fx@gnu.org>
parents:
diff changeset
488
Dave Love <fx@gnu.org>
parents:
diff changeset
489 /*
Dave Love <fx@gnu.org>
parents:
diff changeset
490 * Reset menu wide global values.
Dave Love <fx@gnu.org>
parents:
diff changeset
491 */
Dave Love <fx@gnu.org>
parents:
diff changeset
492 menu->s_count = s_count;
Dave Love <fx@gnu.org>
parents:
diff changeset
493 menu->p_height = p_height;
Dave Love <fx@gnu.org>
parents:
diff changeset
494 menu->p_width = p_width;
Dave Love <fx@gnu.org>
parents:
diff changeset
495 menu->s_width = s_width;
Dave Love <fx@gnu.org>
parents:
diff changeset
496
49600
23a1cea22d13 Trailing whitespace deleted.
Juanma Barranquero <lekktu@gmail.com>
parents: 25858
diff changeset
497 /*
25858
Dave Love <fx@gnu.org>
parents:
diff changeset
498 * Ensure that the origin of the menu is placed so that
Dave Love <fx@gnu.org>
parents:
diff changeset
499 * None of the panes ore selections are off the screen.
Dave Love <fx@gnu.org>
parents:
diff changeset
500 */
Dave Love <fx@gnu.org>
parents:
diff changeset
501 screen = DefaultScreen(display);
Dave Love <fx@gnu.org>
parents:
diff changeset
502 if (menu->x_pos + menu->width > DisplayWidth(display, screen))
Dave Love <fx@gnu.org>
parents:
diff changeset
503 menu->x_pos = DisplayWidth(display, screen) - menu->width;
Dave Love <fx@gnu.org>
parents:
diff changeset
504 else if (menu->x_pos < 0) menu->x_pos = 0;
Dave Love <fx@gnu.org>
parents:
diff changeset
505 if(menu->y_pos + menu->height > DisplayHeight(display, screen))
Dave Love <fx@gnu.org>
parents:
diff changeset
506 menu->y_pos = DisplayHeight(display, screen) - menu->height;
Dave Love <fx@gnu.org>
parents:
diff changeset
507 else if (menu->y_pos < 0) menu->y_pos = 0;
Dave Love <fx@gnu.org>
parents:
diff changeset
508 }
Dave Love <fx@gnu.org>
parents:
diff changeset
509
Dave Love <fx@gnu.org>
parents:
diff changeset
510
Dave Love <fx@gnu.org>
parents:
diff changeset
511 /*
Dave Love <fx@gnu.org>
parents:
diff changeset
512 * _XMRecomputePane - Internal subroutine to recompute pane
Dave Love <fx@gnu.org>
parents:
diff changeset
513 * window dependencies.
Dave Love <fx@gnu.org>
parents:
diff changeset
514 */
Dave Love <fx@gnu.org>
parents:
diff changeset
515 int
Dave Love <fx@gnu.org>
parents:
diff changeset
516 _XMRecomputePane(display, menu, p_ptr, p_num)
Dave Love <fx@gnu.org>
parents:
diff changeset
517 register Display *display; /* Standard X display variable. */
Dave Love <fx@gnu.org>
parents:
diff changeset
518 register XMenu *menu; /* Menu object being recomputed. */
Dave Love <fx@gnu.org>
parents:
diff changeset
519 register XMPane *p_ptr; /* Pane pointer. */
Dave Love <fx@gnu.org>
parents:
diff changeset
520 register int p_num; /* Pane sequence number. */
Dave Love <fx@gnu.org>
parents:
diff changeset
521 {
Dave Love <fx@gnu.org>
parents:
diff changeset
522 register int window_x; /* Recomputed window X coordinate. */
Dave Love <fx@gnu.org>
parents:
diff changeset
523 register int window_y; /* Recomputed window Y coordinate. */
49600
23a1cea22d13 Trailing whitespace deleted.
Juanma Barranquero <lekktu@gmail.com>
parents: 25858
diff changeset
524
25858
Dave Love <fx@gnu.org>
parents:
diff changeset
525 unsigned long change_mask; /* Value mask to reconfigure window. */
Dave Love <fx@gnu.org>
parents:
diff changeset
526 XWindowChanges *changes; /* Values to use in configure window. */
49600
23a1cea22d13 Trailing whitespace deleted.
Juanma Barranquero <lekktu@gmail.com>
parents: 25858
diff changeset
527
25858
Dave Love <fx@gnu.org>
parents:
diff changeset
528 register Bool config_p = False; /* Reconfigure pane window? */
Dave Love <fx@gnu.org>
parents:
diff changeset
529
Dave Love <fx@gnu.org>
parents:
diff changeset
530 /*
Dave Love <fx@gnu.org>
parents:
diff changeset
531 * Update the pane serial number.
Dave Love <fx@gnu.org>
parents:
diff changeset
532 */
Dave Love <fx@gnu.org>
parents:
diff changeset
533 p_ptr->serial = p_num;
Dave Love <fx@gnu.org>
parents:
diff changeset
534
Dave Love <fx@gnu.org>
parents:
diff changeset
535 /*
Dave Love <fx@gnu.org>
parents:
diff changeset
536 * Recompute window X and Y coordinates.
Dave Love <fx@gnu.org>
parents:
diff changeset
537 */
Dave Love <fx@gnu.org>
parents:
diff changeset
538 switch (menu->menu_style) {
Dave Love <fx@gnu.org>
parents:
diff changeset
539 case LEFT:
Dave Love <fx@gnu.org>
parents:
diff changeset
540 window_x = menu->p_x_off * ((menu->p_count - 1) - p_num);
Dave Love <fx@gnu.org>
parents:
diff changeset
541 window_y = menu->p_y_off * ((menu->p_count - 1) - p_num);
Dave Love <fx@gnu.org>
parents:
diff changeset
542 break;
Dave Love <fx@gnu.org>
parents:
diff changeset
543 case RIGHT:
Dave Love <fx@gnu.org>
parents:
diff changeset
544 window_x = menu->p_x_off * p_num;
Dave Love <fx@gnu.org>
parents:
diff changeset
545 window_y = menu->p_y_off * ((menu->p_count - 1) - p_num);
Dave Love <fx@gnu.org>
parents:
diff changeset
546 break;
Dave Love <fx@gnu.org>
parents:
diff changeset
547 case CENTER:
Dave Love <fx@gnu.org>
parents:
diff changeset
548 window_x = 0;
Dave Love <fx@gnu.org>
parents:
diff changeset
549 window_y = menu->p_y_off * ((menu->p_count - 1) - p_num);
Dave Love <fx@gnu.org>
parents:
diff changeset
550 break;
Dave Love <fx@gnu.org>
parents:
diff changeset
551 default:
Dave Love <fx@gnu.org>
parents:
diff changeset
552 /* Error! Invalid style parameter. */
Dave Love <fx@gnu.org>
parents:
diff changeset
553 _XMErrorCode = XME_STYLE_PARAM;
Dave Love <fx@gnu.org>
parents:
diff changeset
554 return(_FAILURE);
Dave Love <fx@gnu.org>
parents:
diff changeset
555 }
Dave Love <fx@gnu.org>
parents:
diff changeset
556 window_x += menu->x_pos;
Dave Love <fx@gnu.org>
parents:
diff changeset
557 window_y += menu->y_pos;
Dave Love <fx@gnu.org>
parents:
diff changeset
558
Dave Love <fx@gnu.org>
parents:
diff changeset
559 /*
49600
23a1cea22d13 Trailing whitespace deleted.
Juanma Barranquero <lekktu@gmail.com>
parents: 25858
diff changeset
560 * If the newly compute pane coordinates differ from the
25858
Dave Love <fx@gnu.org>
parents:
diff changeset
561 * current coordinates, reset the current coordinates and
Dave Love <fx@gnu.org>
parents:
diff changeset
562 * reconfigure the pane.
Dave Love <fx@gnu.org>
parents:
diff changeset
563 */
Dave Love <fx@gnu.org>
parents:
diff changeset
564 if (
Dave Love <fx@gnu.org>
parents:
diff changeset
565 (window_x != p_ptr->window_x) ||
Dave Love <fx@gnu.org>
parents:
diff changeset
566 (window_y != p_ptr->window_y)
Dave Love <fx@gnu.org>
parents:
diff changeset
567 ){
Dave Love <fx@gnu.org>
parents:
diff changeset
568 /*
Dave Love <fx@gnu.org>
parents:
diff changeset
569 * Reset the coordinates and schedule
Dave Love <fx@gnu.org>
parents:
diff changeset
570 * the pane for reconfiguration.
Dave Love <fx@gnu.org>
parents:
diff changeset
571 */
Dave Love <fx@gnu.org>
parents:
diff changeset
572 p_ptr->window_x = window_x;
Dave Love <fx@gnu.org>
parents:
diff changeset
573 p_ptr->window_y = window_y;
Dave Love <fx@gnu.org>
parents:
diff changeset
574 config_p = True;
Dave Love <fx@gnu.org>
parents:
diff changeset
575 }
Dave Love <fx@gnu.org>
parents:
diff changeset
576
Dave Love <fx@gnu.org>
parents:
diff changeset
577 /*
Dave Love <fx@gnu.org>
parents:
diff changeset
578 * If the local pane width and height differs from the
Dave Love <fx@gnu.org>
parents:
diff changeset
579 * menu pane width and height, reset the local values.
Dave Love <fx@gnu.org>
parents:
diff changeset
580 */
Dave Love <fx@gnu.org>
parents:
diff changeset
581 if (
Dave Love <fx@gnu.org>
parents:
diff changeset
582 (p_ptr->window_w != menu->p_width) ||
Dave Love <fx@gnu.org>
parents:
diff changeset
583 (p_ptr->window_h != menu->p_height)
Dave Love <fx@gnu.org>
parents:
diff changeset
584 ){
Dave Love <fx@gnu.org>
parents:
diff changeset
585 /*
Dave Love <fx@gnu.org>
parents:
diff changeset
586 * Reset window width and height and schedule
Dave Love <fx@gnu.org>
parents:
diff changeset
587 * the pane for reconfiguration.
Dave Love <fx@gnu.org>
parents:
diff changeset
588 */
Dave Love <fx@gnu.org>
parents:
diff changeset
589 p_ptr->window_w = menu->p_width;
Dave Love <fx@gnu.org>
parents:
diff changeset
590 p_ptr->window_h = menu->p_height;
Dave Love <fx@gnu.org>
parents:
diff changeset
591 config_p = True;
Dave Love <fx@gnu.org>
parents:
diff changeset
592 }
Dave Love <fx@gnu.org>
parents:
diff changeset
593
Dave Love <fx@gnu.org>
parents:
diff changeset
594 /*
Dave Love <fx@gnu.org>
parents:
diff changeset
595 * If we need to reconfigure the pane window do it now.
Dave Love <fx@gnu.org>
parents:
diff changeset
596 */
Dave Love <fx@gnu.org>
parents:
diff changeset
597 if (config_p == True) {
Dave Love <fx@gnu.org>
parents:
diff changeset
598 /*
Dave Love <fx@gnu.org>
parents:
diff changeset
599 * If the pane window has already been created then
Dave Love <fx@gnu.org>
parents:
diff changeset
600 * reconfigure the existing window, otherwise queue
Dave Love <fx@gnu.org>
parents:
diff changeset
601 * it for creation with the new configuration.
Dave Love <fx@gnu.org>
parents:
diff changeset
602 */
Dave Love <fx@gnu.org>
parents:
diff changeset
603 if (p_ptr->window) {
Dave Love <fx@gnu.org>
parents:
diff changeset
604 change_mask = (CWX | CWY | CWWidth | CWHeight);
Dave Love <fx@gnu.org>
parents:
diff changeset
605 changes = (XWindowChanges *)malloc(sizeof(XWindowChanges));
Dave Love <fx@gnu.org>
parents:
diff changeset
606 changes->x = p_ptr->window_x;
Dave Love <fx@gnu.org>
parents:
diff changeset
607 changes->y = p_ptr->window_y;
Dave Love <fx@gnu.org>
parents:
diff changeset
608 changes->width = p_ptr->window_w;
Dave Love <fx@gnu.org>
parents:
diff changeset
609 changes->height = p_ptr->window_h;
49600
23a1cea22d13 Trailing whitespace deleted.
Juanma Barranquero <lekktu@gmail.com>
parents: 25858
diff changeset
610
25858
Dave Love <fx@gnu.org>
parents:
diff changeset
611 XConfigureWindow(
Dave Love <fx@gnu.org>
parents:
diff changeset
612 display,
Dave Love <fx@gnu.org>
parents:
diff changeset
613 p_ptr->window,
Dave Love <fx@gnu.org>
parents:
diff changeset
614 change_mask,
Dave Love <fx@gnu.org>
parents:
diff changeset
615 changes
Dave Love <fx@gnu.org>
parents:
diff changeset
616 );
Dave Love <fx@gnu.org>
parents:
diff changeset
617 free(changes);
49600
23a1cea22d13 Trailing whitespace deleted.
Juanma Barranquero <lekktu@gmail.com>
parents: 25858
diff changeset
618
25858
Dave Love <fx@gnu.org>
parents:
diff changeset
619 }
Dave Love <fx@gnu.org>
parents:
diff changeset
620 else {
Dave Love <fx@gnu.org>
parents:
diff changeset
621 if (_XMWinQueAddPane(display, menu, p_ptr) == _FAILURE) {
Dave Love <fx@gnu.org>
parents:
diff changeset
622 return(_FAILURE);
Dave Love <fx@gnu.org>
parents:
diff changeset
623 }
Dave Love <fx@gnu.org>
parents:
diff changeset
624 }
Dave Love <fx@gnu.org>
parents:
diff changeset
625 }
49600
23a1cea22d13 Trailing whitespace deleted.
Juanma Barranquero <lekktu@gmail.com>
parents: 25858
diff changeset
626
25858
Dave Love <fx@gnu.org>
parents:
diff changeset
627 /*
Dave Love <fx@gnu.org>
parents:
diff changeset
628 * Recompute label X position.
Dave Love <fx@gnu.org>
parents:
diff changeset
629 */
Dave Love <fx@gnu.org>
parents:
diff changeset
630 switch (menu->p_style) {
Dave Love <fx@gnu.org>
parents:
diff changeset
631 case LEFT:
Dave Love <fx@gnu.org>
parents:
diff changeset
632 p_ptr->label_x = menu->p_x_off + menu->p_fnt_pad;
Dave Love <fx@gnu.org>
parents:
diff changeset
633 break;
Dave Love <fx@gnu.org>
parents:
diff changeset
634 case RIGHT:
Dave Love <fx@gnu.org>
parents:
diff changeset
635 p_ptr->label_x = menu->p_width -
Dave Love <fx@gnu.org>
parents:
diff changeset
636 (p_ptr->label_width + menu->p_x_off + menu->p_fnt_pad);
Dave Love <fx@gnu.org>
parents:
diff changeset
637 break;
Dave Love <fx@gnu.org>
parents:
diff changeset
638 case CENTER:
Dave Love <fx@gnu.org>
parents:
diff changeset
639 p_ptr->label_x = (menu->p_width - p_ptr->label_width) >> 1;
Dave Love <fx@gnu.org>
parents:
diff changeset
640 break;
Dave Love <fx@gnu.org>
parents:
diff changeset
641 default:
Dave Love <fx@gnu.org>
parents:
diff changeset
642 /* Error! Invalid style parameter. */
Dave Love <fx@gnu.org>
parents:
diff changeset
643 _XMErrorCode = XME_STYLE_PARAM;
Dave Love <fx@gnu.org>
parents:
diff changeset
644 return(_FAILURE);
Dave Love <fx@gnu.org>
parents:
diff changeset
645 }
Dave Love <fx@gnu.org>
parents:
diff changeset
646 /*
Dave Love <fx@gnu.org>
parents:
diff changeset
647 * Recompute label Y positions.
Dave Love <fx@gnu.org>
parents:
diff changeset
648 */
Dave Love <fx@gnu.org>
parents:
diff changeset
649 p_ptr->label_uy = menu->p_fnt_pad + menu->p_fnt_info->max_bounds.ascent;
Dave Love <fx@gnu.org>
parents:
diff changeset
650 p_ptr->label_ly = (menu->p_height - menu->p_fnt_pad - menu->p_fnt_info->max_bounds.descent);
Dave Love <fx@gnu.org>
parents:
diff changeset
651
Dave Love <fx@gnu.org>
parents:
diff changeset
652 /*
Dave Love <fx@gnu.org>
parents:
diff changeset
653 * All went well, return successfully.
Dave Love <fx@gnu.org>
parents:
diff changeset
654 */
Dave Love <fx@gnu.org>
parents:
diff changeset
655 _XMErrorCode = XME_NO_ERROR;
Dave Love <fx@gnu.org>
parents:
diff changeset
656 return(_SUCCESS);
Dave Love <fx@gnu.org>
parents:
diff changeset
657 }
Dave Love <fx@gnu.org>
parents:
diff changeset
658
Dave Love <fx@gnu.org>
parents:
diff changeset
659
Dave Love <fx@gnu.org>
parents:
diff changeset
660
Dave Love <fx@gnu.org>
parents:
diff changeset
661 /*
Dave Love <fx@gnu.org>
parents:
diff changeset
662 * _XMRecomputeSelection - Internal subroutine to recompute
Dave Love <fx@gnu.org>
parents:
diff changeset
663 * selection window dependencies.
Dave Love <fx@gnu.org>
parents:
diff changeset
664 */
Dave Love <fx@gnu.org>
parents:
diff changeset
665 int
Dave Love <fx@gnu.org>
parents:
diff changeset
666 _XMRecomputeSelection(display, menu, s_ptr, s_num)
Dave Love <fx@gnu.org>
parents:
diff changeset
667 register Display *display;
Dave Love <fx@gnu.org>
parents:
diff changeset
668 register XMenu *menu; /* Menu object being recomputed. */
Dave Love <fx@gnu.org>
parents:
diff changeset
669 register XMSelect *s_ptr; /* Selection pointer. */
Dave Love <fx@gnu.org>
parents:
diff changeset
670 register int s_num; /* Selection sequence number. */
Dave Love <fx@gnu.org>
parents:
diff changeset
671 {
Dave Love <fx@gnu.org>
parents:
diff changeset
672 register Bool config_s = False; /* Reconfigure selection window? */
Dave Love <fx@gnu.org>
parents:
diff changeset
673 XWindowChanges *changes; /* Values to change in configure. */
Dave Love <fx@gnu.org>
parents:
diff changeset
674 unsigned long change_mask; /* Value mask for XConfigureWindow. */
49600
23a1cea22d13 Trailing whitespace deleted.
Juanma Barranquero <lekktu@gmail.com>
parents: 25858
diff changeset
675
25858
Dave Love <fx@gnu.org>
parents:
diff changeset
676 /*
Dave Love <fx@gnu.org>
parents:
diff changeset
677 * If the selection serial numbers are out of order, begin
Dave Love <fx@gnu.org>
parents:
diff changeset
678 * resequencing selections. Recompute selection window coordinates
Dave Love <fx@gnu.org>
parents:
diff changeset
679 * and serial number.
Dave Love <fx@gnu.org>
parents:
diff changeset
680 *
Dave Love <fx@gnu.org>
parents:
diff changeset
681 * When selections are created they are given a serial number of
Dave Love <fx@gnu.org>
parents:
diff changeset
682 * -1, this causes this routine to give a new selection
Dave Love <fx@gnu.org>
parents:
diff changeset
683 * its initial coordinates and serial number.
Dave Love <fx@gnu.org>
parents:
diff changeset
684 */
Dave Love <fx@gnu.org>
parents:
diff changeset
685 if (s_ptr->serial != s_num) {
Dave Love <fx@gnu.org>
parents:
diff changeset
686 /*
Dave Love <fx@gnu.org>
parents:
diff changeset
687 * Fix the sequence number.
Dave Love <fx@gnu.org>
parents:
diff changeset
688 */
Dave Love <fx@gnu.org>
parents:
diff changeset
689 s_ptr->serial = s_num;
Dave Love <fx@gnu.org>
parents:
diff changeset
690 /*
Dave Love <fx@gnu.org>
parents:
diff changeset
691 * Recompute window X and Y coordinates.
Dave Love <fx@gnu.org>
parents:
diff changeset
692 */
Dave Love <fx@gnu.org>
parents:
diff changeset
693 s_ptr->window_x = menu->s_x_off;
Dave Love <fx@gnu.org>
parents:
diff changeset
694 s_ptr->window_y = menu->flag_height + (menu->s_y_off * s_num);
Dave Love <fx@gnu.org>
parents:
diff changeset
695 /*
Dave Love <fx@gnu.org>
parents:
diff changeset
696 * We must reconfigure the window.
Dave Love <fx@gnu.org>
parents:
diff changeset
697 */
Dave Love <fx@gnu.org>
parents:
diff changeset
698 config_s = True;
Dave Love <fx@gnu.org>
parents:
diff changeset
699 }
Dave Love <fx@gnu.org>
parents:
diff changeset
700
Dave Love <fx@gnu.org>
parents:
diff changeset
701 /*
Dave Love <fx@gnu.org>
parents:
diff changeset
702 * If the local selection width and height differs from the
Dave Love <fx@gnu.org>
parents:
diff changeset
703 * menu selection width and height, reset the local values.
Dave Love <fx@gnu.org>
parents:
diff changeset
704 */
Dave Love <fx@gnu.org>
parents:
diff changeset
705 if (
Dave Love <fx@gnu.org>
parents:
diff changeset
706 (s_ptr->window_w != menu->s_width) ||
Dave Love <fx@gnu.org>
parents:
diff changeset
707 (s_ptr->window_h != menu->s_height)
Dave Love <fx@gnu.org>
parents:
diff changeset
708 ){
Dave Love <fx@gnu.org>
parents:
diff changeset
709 /*
Dave Love <fx@gnu.org>
parents:
diff changeset
710 * We must reconfigure the window.
Dave Love <fx@gnu.org>
parents:
diff changeset
711 */
Dave Love <fx@gnu.org>
parents:
diff changeset
712 config_s = True;
Dave Love <fx@gnu.org>
parents:
diff changeset
713 /*
Dave Love <fx@gnu.org>
parents:
diff changeset
714 * Reset window width and height.
Dave Love <fx@gnu.org>
parents:
diff changeset
715 */
Dave Love <fx@gnu.org>
parents:
diff changeset
716 s_ptr->window_w = menu->s_width;
Dave Love <fx@gnu.org>
parents:
diff changeset
717 s_ptr->window_h = menu->s_height;
Dave Love <fx@gnu.org>
parents:
diff changeset
718 }
Dave Love <fx@gnu.org>
parents:
diff changeset
719
Dave Love <fx@gnu.org>
parents:
diff changeset
720 /*
Dave Love <fx@gnu.org>
parents:
diff changeset
721 * If we need to reconfigure the selection window do it now.
Dave Love <fx@gnu.org>
parents:
diff changeset
722 */
Dave Love <fx@gnu.org>
parents:
diff changeset
723 if (config_s == True) {
Dave Love <fx@gnu.org>
parents:
diff changeset
724 /*
Dave Love <fx@gnu.org>
parents:
diff changeset
725 * If the selection window has already been created then
Dave Love <fx@gnu.org>
parents:
diff changeset
726 * reconfigure the existing window, otherwise queue it
Dave Love <fx@gnu.org>
parents:
diff changeset
727 * for creation with the new configuration.
Dave Love <fx@gnu.org>
parents:
diff changeset
728 */
Dave Love <fx@gnu.org>
parents:
diff changeset
729 if (s_ptr->window) {
Dave Love <fx@gnu.org>
parents:
diff changeset
730 changes = (XWindowChanges *)malloc(sizeof(XWindowChanges));
Dave Love <fx@gnu.org>
parents:
diff changeset
731 change_mask = (CWX | CWY | CWWidth | CWHeight);
Dave Love <fx@gnu.org>
parents:
diff changeset
732 changes = (XWindowChanges *)malloc(sizeof(XWindowChanges));
Dave Love <fx@gnu.org>
parents:
diff changeset
733 changes->x = s_ptr->window_x;
Dave Love <fx@gnu.org>
parents:
diff changeset
734 changes->y = s_ptr->window_y;
Dave Love <fx@gnu.org>
parents:
diff changeset
735 changes->width = s_ptr->window_w;
Dave Love <fx@gnu.org>
parents:
diff changeset
736 changes->height = s_ptr->window_h;
49600
23a1cea22d13 Trailing whitespace deleted.
Juanma Barranquero <lekktu@gmail.com>
parents: 25858
diff changeset
737
25858
Dave Love <fx@gnu.org>
parents:
diff changeset
738 XConfigureWindow(
Dave Love <fx@gnu.org>
parents:
diff changeset
739 display,
Dave Love <fx@gnu.org>
parents:
diff changeset
740 s_ptr->window,
Dave Love <fx@gnu.org>
parents:
diff changeset
741 change_mask,
Dave Love <fx@gnu.org>
parents:
diff changeset
742 changes
Dave Love <fx@gnu.org>
parents:
diff changeset
743 );
Dave Love <fx@gnu.org>
parents:
diff changeset
744 free(changes);
49600
23a1cea22d13 Trailing whitespace deleted.
Juanma Barranquero <lekktu@gmail.com>
parents: 25858
diff changeset
745
25858
Dave Love <fx@gnu.org>
parents:
diff changeset
746 }
Dave Love <fx@gnu.org>
parents:
diff changeset
747 else {
Dave Love <fx@gnu.org>
parents:
diff changeset
748 if (_XMWinQueAddSelection(display, menu, s_ptr) == _FAILURE) {
Dave Love <fx@gnu.org>
parents:
diff changeset
749 return(_FAILURE);
Dave Love <fx@gnu.org>
parents:
diff changeset
750 }
Dave Love <fx@gnu.org>
parents:
diff changeset
751 }
Dave Love <fx@gnu.org>
parents:
diff changeset
752 }
Dave Love <fx@gnu.org>
parents:
diff changeset
753
Dave Love <fx@gnu.org>
parents:
diff changeset
754 /*
Dave Love <fx@gnu.org>
parents:
diff changeset
755 * Recompute label X position.
Dave Love <fx@gnu.org>
parents:
diff changeset
756 */
Dave Love <fx@gnu.org>
parents:
diff changeset
757 switch (menu->s_style) {
Dave Love <fx@gnu.org>
parents:
diff changeset
758 case LEFT:
Dave Love <fx@gnu.org>
parents:
diff changeset
759 s_ptr->label_x = menu->s_bdr_width + menu->s_fnt_pad + s_ptr->window_x;
Dave Love <fx@gnu.org>
parents:
diff changeset
760 break;
Dave Love <fx@gnu.org>
parents:
diff changeset
761 case RIGHT:
Dave Love <fx@gnu.org>
parents:
diff changeset
762 s_ptr->label_x = s_ptr->window_x + menu->s_width -
Dave Love <fx@gnu.org>
parents:
diff changeset
763 (s_ptr->label_width + menu->s_bdr_width + menu->s_fnt_pad);
Dave Love <fx@gnu.org>
parents:
diff changeset
764 break;
Dave Love <fx@gnu.org>
parents:
diff changeset
765 case CENTER:
Dave Love <fx@gnu.org>
parents:
diff changeset
766 s_ptr->label_x = s_ptr->window_x + ((menu->s_width - s_ptr->label_width) >> 1);
Dave Love <fx@gnu.org>
parents:
diff changeset
767 break;
Dave Love <fx@gnu.org>
parents:
diff changeset
768 default:
Dave Love <fx@gnu.org>
parents:
diff changeset
769 /* Error! Invalid style parameter. */
Dave Love <fx@gnu.org>
parents:
diff changeset
770 _XMErrorCode = XME_STYLE_PARAM;
Dave Love <fx@gnu.org>
parents:
diff changeset
771 return(_FAILURE);
Dave Love <fx@gnu.org>
parents:
diff changeset
772 }
Dave Love <fx@gnu.org>
parents:
diff changeset
773 /*
Dave Love <fx@gnu.org>
parents:
diff changeset
774 * Recompute label Y position.
Dave Love <fx@gnu.org>
parents:
diff changeset
775 */
Dave Love <fx@gnu.org>
parents:
diff changeset
776 s_ptr->label_y = s_ptr->window_y + menu->s_fnt_info->max_bounds.ascent + menu->s_fnt_pad + menu->s_bdr_width;
49600
23a1cea22d13 Trailing whitespace deleted.
Juanma Barranquero <lekktu@gmail.com>
parents: 25858
diff changeset
777
25858
Dave Love <fx@gnu.org>
parents:
diff changeset
778 /*
Dave Love <fx@gnu.org>
parents:
diff changeset
779 * All went well, return successfully.
Dave Love <fx@gnu.org>
parents:
diff changeset
780 */
Dave Love <fx@gnu.org>
parents:
diff changeset
781 _XMErrorCode = XME_NO_ERROR;
Dave Love <fx@gnu.org>
parents:
diff changeset
782 return(_SUCCESS);
Dave Love <fx@gnu.org>
parents:
diff changeset
783 }
Dave Love <fx@gnu.org>
parents:
diff changeset
784
Dave Love <fx@gnu.org>
parents:
diff changeset
785
Dave Love <fx@gnu.org>
parents:
diff changeset
786
Dave Love <fx@gnu.org>
parents:
diff changeset
787 /*
Dave Love <fx@gnu.org>
parents:
diff changeset
788 * _XMTransToOrigin - Internal subroutine to translate the point at
49600
23a1cea22d13 Trailing whitespace deleted.
Juanma Barranquero <lekktu@gmail.com>
parents: 25858
diff changeset
789 * the center of the current pane and selection to the
25858
Dave Love <fx@gnu.org>
parents:
diff changeset
790 * the menu origin.
Dave Love <fx@gnu.org>
parents:
diff changeset
791 *
Dave Love <fx@gnu.org>
parents:
diff changeset
792 * WARNING! ****** Be certain that all menu dependencies have been
Dave Love <fx@gnu.org>
parents:
diff changeset
793 * recomputed before calling this routine or
Dave Love <fx@gnu.org>
parents:
diff changeset
794 * unpredictable results will follow.
Dave Love <fx@gnu.org>
parents:
diff changeset
795 */
Dave Love <fx@gnu.org>
parents:
diff changeset
796 _XMTransToOrigin(display, menu, p_ptr, s_ptr, x_pos, y_pos, orig_x, orig_y)
Dave Love <fx@gnu.org>
parents:
diff changeset
797 Display *display; /* Not used. Included for consistency. */
Dave Love <fx@gnu.org>
parents:
diff changeset
798 register XMenu *menu; /* Menu being computed against. */
Dave Love <fx@gnu.org>
parents:
diff changeset
799 register XMPane *p_ptr; /* Current pane pointer. */
Dave Love <fx@gnu.org>
parents:
diff changeset
800 register XMSelect *s_ptr; /* Current selection pointer. */
Dave Love <fx@gnu.org>
parents:
diff changeset
801 int x_pos; /* X coordinate of point to translate. */
Dave Love <fx@gnu.org>
parents:
diff changeset
802 int y_pos; /* Y coordinate of point to translate. */
Dave Love <fx@gnu.org>
parents:
diff changeset
803 int *orig_x; /* Return value X coord. of the menu origin. */
Dave Love <fx@gnu.org>
parents:
diff changeset
804 int *orig_y; /* Return value Y coord. of the menu origin. */
Dave Love <fx@gnu.org>
parents:
diff changeset
805 {
Dave Love <fx@gnu.org>
parents:
diff changeset
806 register int l_orig_x; /* Local X coordinate of the menu origin. */
Dave Love <fx@gnu.org>
parents:
diff changeset
807 register int l_orig_y; /* Local Y coordinate of the menu origin. */
49600
23a1cea22d13 Trailing whitespace deleted.
Juanma Barranquero <lekktu@gmail.com>
parents: 25858
diff changeset
808
25858
Dave Love <fx@gnu.org>
parents:
diff changeset
809 /*
Dave Love <fx@gnu.org>
parents:
diff changeset
810 * Translate the menu origin such that the cursor hot point will be in the
Dave Love <fx@gnu.org>
parents:
diff changeset
811 * center of the desired current selection and pane.
Dave Love <fx@gnu.org>
parents:
diff changeset
812 * If the current selection pointer is NULL then assume that the hot point
Dave Love <fx@gnu.org>
parents:
diff changeset
813 * will be in the center of the current pane flag.
Dave Love <fx@gnu.org>
parents:
diff changeset
814 */
Dave Love <fx@gnu.org>
parents:
diff changeset
815
Dave Love <fx@gnu.org>
parents:
diff changeset
816 if (s_ptr == NULL) {
Dave Love <fx@gnu.org>
parents:
diff changeset
817 /*
Dave Love <fx@gnu.org>
parents:
diff changeset
818 * Translate from the center of the pane flag to the upper left
Dave Love <fx@gnu.org>
parents:
diff changeset
819 * of the current pane window.
Dave Love <fx@gnu.org>
parents:
diff changeset
820 */
Dave Love <fx@gnu.org>
parents:
diff changeset
821 l_orig_x = x_pos - (menu->p_width >> 1) - menu->p_bdr_width;
Dave Love <fx@gnu.org>
parents:
diff changeset
822 l_orig_y = y_pos - (menu->flag_height >> 1) - menu->p_bdr_width;
Dave Love <fx@gnu.org>
parents:
diff changeset
823 }
Dave Love <fx@gnu.org>
parents:
diff changeset
824 else {
Dave Love <fx@gnu.org>
parents:
diff changeset
825 /*
Dave Love <fx@gnu.org>
parents:
diff changeset
826 * First translate from the center of the current selection
Dave Love <fx@gnu.org>
parents:
diff changeset
827 * to the upper left of the current selection window.
Dave Love <fx@gnu.org>
parents:
diff changeset
828 */
Dave Love <fx@gnu.org>
parents:
diff changeset
829 l_orig_x = x_pos - (menu->s_width >> 1);
Dave Love <fx@gnu.org>
parents:
diff changeset
830 l_orig_y = y_pos - (menu->s_height >> 1);
Dave Love <fx@gnu.org>
parents:
diff changeset
831
Dave Love <fx@gnu.org>
parents:
diff changeset
832 /*
Dave Love <fx@gnu.org>
parents:
diff changeset
833 * Then translate to the upper left of the current pane window.
Dave Love <fx@gnu.org>
parents:
diff changeset
834 */
Dave Love <fx@gnu.org>
parents:
diff changeset
835 l_orig_x -= (s_ptr->window_x + menu->p_bdr_width);
Dave Love <fx@gnu.org>
parents:
diff changeset
836 l_orig_y -= (s_ptr->window_y + menu->p_bdr_width);
Dave Love <fx@gnu.org>
parents:
diff changeset
837 }
Dave Love <fx@gnu.org>
parents:
diff changeset
838
Dave Love <fx@gnu.org>
parents:
diff changeset
839 /*
Dave Love <fx@gnu.org>
parents:
diff changeset
840 * Finally translate to the upper left of the menu.
Dave Love <fx@gnu.org>
parents:
diff changeset
841 */
Dave Love <fx@gnu.org>
parents:
diff changeset
842 l_orig_x -= (p_ptr->window_x - menu->x_pos);
Dave Love <fx@gnu.org>
parents:
diff changeset
843 l_orig_y -= (p_ptr->window_y - menu->y_pos);
Dave Love <fx@gnu.org>
parents:
diff changeset
844
Dave Love <fx@gnu.org>
parents:
diff changeset
845 /*
Dave Love <fx@gnu.org>
parents:
diff changeset
846 * Set the return values.
Dave Love <fx@gnu.org>
parents:
diff changeset
847 */
Dave Love <fx@gnu.org>
parents:
diff changeset
848 *orig_x = l_orig_x;
Dave Love <fx@gnu.org>
parents:
diff changeset
849 *orig_y = l_orig_y;
Dave Love <fx@gnu.org>
parents:
diff changeset
850 }
Dave Love <fx@gnu.org>
parents:
diff changeset
851
Dave Love <fx@gnu.org>
parents:
diff changeset
852 /*
Dave Love <fx@gnu.org>
parents:
diff changeset
853 * _XMRefreshPane - Internal subroutine to completely refresh
Dave Love <fx@gnu.org>
parents:
diff changeset
854 * the contents of a pane.
Dave Love <fx@gnu.org>
parents:
diff changeset
855 */
Dave Love <fx@gnu.org>
parents:
diff changeset
856 _XMRefreshPane(display, menu, pane)
Dave Love <fx@gnu.org>
parents:
diff changeset
857 register Display *display;
Dave Love <fx@gnu.org>
parents:
diff changeset
858 register XMenu *menu;
Dave Love <fx@gnu.org>
parents:
diff changeset
859 register XMPane *pane;
Dave Love <fx@gnu.org>
parents:
diff changeset
860 {
Dave Love <fx@gnu.org>
parents:
diff changeset
861 register XMSelect *s_list = pane->s_list;
Dave Love <fx@gnu.org>
parents:
diff changeset
862 register XMSelect *s_ptr;
Dave Love <fx@gnu.org>
parents:
diff changeset
863
Dave Love <fx@gnu.org>
parents:
diff changeset
864 /*
49600
23a1cea22d13 Trailing whitespace deleted.
Juanma Barranquero <lekktu@gmail.com>
parents: 25858
diff changeset
865 * First clear the pane.
25858
Dave Love <fx@gnu.org>
parents:
diff changeset
866 */
Dave Love <fx@gnu.org>
parents:
diff changeset
867 XClearWindow(display, pane->window);
Dave Love <fx@gnu.org>
parents:
diff changeset
868 if (!pane->activated) {
Dave Love <fx@gnu.org>
parents:
diff changeset
869 XFillRectangle(display,
Dave Love <fx@gnu.org>
parents:
diff changeset
870 pane->window,
Dave Love <fx@gnu.org>
parents:
diff changeset
871 menu->inverse_select_GC,
Dave Love <fx@gnu.org>
parents:
diff changeset
872 pane->label_x - menu->p_fnt_pad,
Dave Love <fx@gnu.org>
parents:
diff changeset
873 pane->label_uy - menu->p_fnt_info->max_bounds.ascent - menu->p_fnt_pad,
Dave Love <fx@gnu.org>
parents:
diff changeset
874 pane->label_width + (menu->p_fnt_pad << 1),
Dave Love <fx@gnu.org>
parents:
diff changeset
875 menu->flag_height);
Dave Love <fx@gnu.org>
parents:
diff changeset
876
Dave Love <fx@gnu.org>
parents:
diff changeset
877 XFillRectangle(display,
Dave Love <fx@gnu.org>
parents:
diff changeset
878 pane->window,
Dave Love <fx@gnu.org>
parents:
diff changeset
879 menu->inverse_select_GC,
Dave Love <fx@gnu.org>
parents:
diff changeset
880 pane->label_x - menu->p_fnt_pad,
Dave Love <fx@gnu.org>
parents:
diff changeset
881 pane->label_ly - menu->p_fnt_info->max_bounds.ascent - menu->p_fnt_pad,
Dave Love <fx@gnu.org>
parents:
diff changeset
882 pane->label_width + (menu->p_fnt_pad << 1),
Dave Love <fx@gnu.org>
parents:
diff changeset
883 menu->flag_height);
Dave Love <fx@gnu.org>
parents:
diff changeset
884 }
Dave Love <fx@gnu.org>
parents:
diff changeset
885 if (!pane->active) {
Dave Love <fx@gnu.org>
parents:
diff changeset
886 XDrawString(display,
Dave Love <fx@gnu.org>
parents:
diff changeset
887 pane->window,
Dave Love <fx@gnu.org>
parents:
diff changeset
888 menu->inact_GC,
Dave Love <fx@gnu.org>
parents:
diff changeset
889 pane->label_x, pane->label_uy,
Dave Love <fx@gnu.org>
parents:
diff changeset
890 pane->label, pane->label_length);
Dave Love <fx@gnu.org>
parents:
diff changeset
891 XDrawString(display,
Dave Love <fx@gnu.org>
parents:
diff changeset
892 pane->window,
Dave Love <fx@gnu.org>
parents:
diff changeset
893 menu->inact_GC,
Dave Love <fx@gnu.org>
parents:
diff changeset
894 pane->label_x, pane->label_ly,
Dave Love <fx@gnu.org>
parents:
diff changeset
895 pane->label, pane->label_length);
Dave Love <fx@gnu.org>
parents:
diff changeset
896 }
Dave Love <fx@gnu.org>
parents:
diff changeset
897 else {
Dave Love <fx@gnu.org>
parents:
diff changeset
898 XDrawString(display,
Dave Love <fx@gnu.org>
parents:
diff changeset
899 pane->window,
Dave Love <fx@gnu.org>
parents:
diff changeset
900 menu->pane_GC,
Dave Love <fx@gnu.org>
parents:
diff changeset
901 pane->label_x, pane->label_uy,
Dave Love <fx@gnu.org>
parents:
diff changeset
902 pane->label, pane->label_length);
Dave Love <fx@gnu.org>
parents:
diff changeset
903 XDrawString(display,
Dave Love <fx@gnu.org>
parents:
diff changeset
904 pane->window,
Dave Love <fx@gnu.org>
parents:
diff changeset
905 menu->pane_GC,
Dave Love <fx@gnu.org>
parents:
diff changeset
906 pane->label_x, pane->label_ly,
Dave Love <fx@gnu.org>
parents:
diff changeset
907 pane->label, pane->label_length);
Dave Love <fx@gnu.org>
parents:
diff changeset
908
Dave Love <fx@gnu.org>
parents:
diff changeset
909 /*
Dave Love <fx@gnu.org>
parents:
diff changeset
910 * Finally refresh each selection if the pane is activated.
Dave Love <fx@gnu.org>
parents:
diff changeset
911 */
Dave Love <fx@gnu.org>
parents:
diff changeset
912 if (pane->activated) {
Dave Love <fx@gnu.org>
parents:
diff changeset
913 for (s_ptr = s_list->next; s_ptr != s_list; s_ptr = s_ptr->next)
Dave Love <fx@gnu.org>
parents:
diff changeset
914 _XMRefreshSelection(display, menu, s_ptr);
Dave Love <fx@gnu.org>
parents:
diff changeset
915 }
Dave Love <fx@gnu.org>
parents:
diff changeset
916 }
Dave Love <fx@gnu.org>
parents:
diff changeset
917 }
49600
23a1cea22d13 Trailing whitespace deleted.
Juanma Barranquero <lekktu@gmail.com>
parents: 25858
diff changeset
918
23a1cea22d13 Trailing whitespace deleted.
Juanma Barranquero <lekktu@gmail.com>
parents: 25858
diff changeset
919
25858
Dave Love <fx@gnu.org>
parents:
diff changeset
920
Dave Love <fx@gnu.org>
parents:
diff changeset
921
Dave Love <fx@gnu.org>
parents:
diff changeset
922 /*
49600
23a1cea22d13 Trailing whitespace deleted.
Juanma Barranquero <lekktu@gmail.com>
parents: 25858
diff changeset
923 * _XMRefreshSelection - Internal subroutine that refreshes
25858
Dave Love <fx@gnu.org>
parents:
diff changeset
924 * a single selection window.
Dave Love <fx@gnu.org>
parents:
diff changeset
925 */
Dave Love <fx@gnu.org>
parents:
diff changeset
926 _XMRefreshSelection(display, menu, select)
Dave Love <fx@gnu.org>
parents:
diff changeset
927 register Display *display;
Dave Love <fx@gnu.org>
parents:
diff changeset
928 register XMenu *menu;
Dave Love <fx@gnu.org>
parents:
diff changeset
929 register XMSelect *select;
Dave Love <fx@gnu.org>
parents:
diff changeset
930 {
Dave Love <fx@gnu.org>
parents:
diff changeset
931 register int width = select->window_w;
Dave Love <fx@gnu.org>
parents:
diff changeset
932 register int height = select->window_h;
Dave Love <fx@gnu.org>
parents:
diff changeset
933 register int bdr_width = menu->s_bdr_width;
49600
23a1cea22d13 Trailing whitespace deleted.
Juanma Barranquero <lekktu@gmail.com>
parents: 25858
diff changeset
934
25858
Dave Love <fx@gnu.org>
parents:
diff changeset
935 if (select->type == SEPARATOR) {
Dave Love <fx@gnu.org>
parents:
diff changeset
936 XDrawLine(display,
Dave Love <fx@gnu.org>
parents:
diff changeset
937 select->parent_p->window,
Dave Love <fx@gnu.org>
parents:
diff changeset
938 menu->normal_select_GC,
Dave Love <fx@gnu.org>
parents:
diff changeset
939 select->window_x,
Dave Love <fx@gnu.org>
parents:
diff changeset
940 select->window_y + height / 2,
Dave Love <fx@gnu.org>
parents:
diff changeset
941 select->window_x + width,
Dave Love <fx@gnu.org>
parents:
diff changeset
942 select->window_y + height / 2);
Dave Love <fx@gnu.org>
parents:
diff changeset
943 }
Dave Love <fx@gnu.org>
parents:
diff changeset
944 else if (select->activated) {
Dave Love <fx@gnu.org>
parents:
diff changeset
945 if (menu->menu_mode == INVERT) {
49600
23a1cea22d13 Trailing whitespace deleted.
Juanma Barranquero <lekktu@gmail.com>
parents: 25858
diff changeset
946 XFillRectangle(display,
25858
Dave Love <fx@gnu.org>
parents:
diff changeset
947 select->parent_p->window,
Dave Love <fx@gnu.org>
parents:
diff changeset
948 menu->normal_select_GC,
Dave Love <fx@gnu.org>
parents:
diff changeset
949 select->window_x, select->window_y,
49600
23a1cea22d13 Trailing whitespace deleted.
Juanma Barranquero <lekktu@gmail.com>
parents: 25858
diff changeset
950 width, height);
25858
Dave Love <fx@gnu.org>
parents:
diff changeset
951 XDrawString(display,
Dave Love <fx@gnu.org>
parents:
diff changeset
952 select->parent_p->window,
Dave Love <fx@gnu.org>
parents:
diff changeset
953 menu->inverse_select_GC,
Dave Love <fx@gnu.org>
parents:
diff changeset
954 select->label_x,
Dave Love <fx@gnu.org>
parents:
diff changeset
955 select->label_y,
Dave Love <fx@gnu.org>
parents:
diff changeset
956 select->label, select->label_length);
Dave Love <fx@gnu.org>
parents:
diff changeset
957 }
Dave Love <fx@gnu.org>
parents:
diff changeset
958 else {
Dave Love <fx@gnu.org>
parents:
diff changeset
959 /*
Dave Love <fx@gnu.org>
parents:
diff changeset
960 * Using BOX mode.
Dave Love <fx@gnu.org>
parents:
diff changeset
961 * Since most drawing routines with arbitrary width lines
Dave Love <fx@gnu.org>
parents:
diff changeset
962 * are slow compared to raster-ops lets use a raster-op to
Dave Love <fx@gnu.org>
parents:
diff changeset
963 * draw the boxes.
Dave Love <fx@gnu.org>
parents:
diff changeset
964 */
49600
23a1cea22d13 Trailing whitespace deleted.
Juanma Barranquero <lekktu@gmail.com>
parents: 25858
diff changeset
965
25858
Dave Love <fx@gnu.org>
parents:
diff changeset
966 XDrawRectangle(display,
Dave Love <fx@gnu.org>
parents:
diff changeset
967 select->parent_p->window,
Dave Love <fx@gnu.org>
parents:
diff changeset
968 menu->normal_select_GC,
Dave Love <fx@gnu.org>
parents:
diff changeset
969 select->window_x + (bdr_width >> 1),
Dave Love <fx@gnu.org>
parents:
diff changeset
970 select->window_y + (bdr_width >> 1 ),
Dave Love <fx@gnu.org>
parents:
diff changeset
971 width - bdr_width,
Dave Love <fx@gnu.org>
parents:
diff changeset
972 height - bdr_width);
Dave Love <fx@gnu.org>
parents:
diff changeset
973 XDrawString(display,
Dave Love <fx@gnu.org>
parents:
diff changeset
974 select->parent_p->window,
Dave Love <fx@gnu.org>
parents:
diff changeset
975 menu->normal_select_GC,
Dave Love <fx@gnu.org>
parents:
diff changeset
976 select->label_x,
Dave Love <fx@gnu.org>
parents:
diff changeset
977 select->label_y,
Dave Love <fx@gnu.org>
parents:
diff changeset
978 select->label, select->label_length);
Dave Love <fx@gnu.org>
parents:
diff changeset
979 }
Dave Love <fx@gnu.org>
parents:
diff changeset
980 }
Dave Love <fx@gnu.org>
parents:
diff changeset
981 else {
49600
23a1cea22d13 Trailing whitespace deleted.
Juanma Barranquero <lekktu@gmail.com>
parents: 25858
diff changeset
982 XClearArea(display,
25858
Dave Love <fx@gnu.org>
parents:
diff changeset
983 select->parent_p->window,
Dave Love <fx@gnu.org>
parents:
diff changeset
984 select->window_x, select->window_y,
Dave Love <fx@gnu.org>
parents:
diff changeset
985 width, height,
Dave Love <fx@gnu.org>
parents:
diff changeset
986 False);
Dave Love <fx@gnu.org>
parents:
diff changeset
987 if (select->active) {
Dave Love <fx@gnu.org>
parents:
diff changeset
988 XDrawString(display,
Dave Love <fx@gnu.org>
parents:
diff changeset
989 select->parent_p->window,
Dave Love <fx@gnu.org>
parents:
diff changeset
990 menu->normal_select_GC,
Dave Love <fx@gnu.org>
parents:
diff changeset
991 select->label_x,
Dave Love <fx@gnu.org>
parents:
diff changeset
992 select->label_y,
Dave Love <fx@gnu.org>
parents:
diff changeset
993 select->label, select->label_length);
Dave Love <fx@gnu.org>
parents:
diff changeset
994 }
Dave Love <fx@gnu.org>
parents:
diff changeset
995 else {
Dave Love <fx@gnu.org>
parents:
diff changeset
996 XDrawString(display,
Dave Love <fx@gnu.org>
parents:
diff changeset
997 select->parent_p->window,
Dave Love <fx@gnu.org>
parents:
diff changeset
998 menu->inact_GC,
Dave Love <fx@gnu.org>
parents:
diff changeset
999 select->label_x,
Dave Love <fx@gnu.org>
parents:
diff changeset
1000 select->label_y,
Dave Love <fx@gnu.org>
parents:
diff changeset
1001 select->label, select->label_length);
Dave Love <fx@gnu.org>
parents:
diff changeset
1002 }
Dave Love <fx@gnu.org>
parents:
diff changeset
1003 }
Dave Love <fx@gnu.org>
parents:
diff changeset
1004 }
Dave Love <fx@gnu.org>
parents:
diff changeset
1005
52401
695cf19ef79e Add arch taglines
Miles Bader <miles@gnu.org>
parents: 49600
diff changeset
1006 /* arch-tag: 3ac61957-0852-4e72-8b88-7dfab1a5dee9
695cf19ef79e Add arch taglines
Miles Bader <miles@gnu.org>
parents: 49600
diff changeset
1007 (do not change this comment) */