annotate oldXMenu/Internal.c @ 26271:b47b74998eef

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