428
|
1 /* Widget-specific glyph objects.
|
438
|
2 Copyright (C) 1998, 1999, 2000 Andy Piper.
|
428
|
3
|
|
4 This file is part of XEmacs.
|
|
5
|
|
6 XEmacs is free software; you can redistribute it and/or modify it
|
|
7 under the terms of the GNU General Public License as published by the
|
|
8 Free Software Foundation; either version 2, or (at your option) any
|
|
9 later version.
|
|
10
|
|
11 XEmacs is distributed in the hope that it will be useful, but WITHOUT
|
|
12 ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or
|
|
13 FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License
|
|
14 for more details.
|
|
15
|
|
16 You should have received a copy of the GNU General Public License
|
|
17 along with XEmacs; see the file COPYING. If not, write to
|
|
18 the Free Software Foundation, Inc., 59 Temple Place - Suite 330,
|
|
19 Boston, MA 02111-1307, USA. */
|
|
20
|
|
21 /* Synched up with: Not in FSF. */
|
|
22
|
|
23 /* written by Andy Piper <andy@xemacs.org> */
|
|
24
|
|
25 #include <config.h>
|
|
26 #include "lisp.h"
|
|
27 #include "lstream.h"
|
|
28 #include "console.h"
|
|
29 #include "device.h"
|
|
30 #include "faces.h"
|
|
31 #include "glyphs.h"
|
|
32 #include "objects.h"
|
|
33 #include "bytecode.h"
|
|
34 #include "window.h"
|
|
35 #include "buffer.h"
|
|
36 #include "frame.h"
|
|
37 #include "insdel.h"
|
|
38 #include "opaque.h"
|
|
39
|
|
40 DEFINE_IMAGE_INSTANTIATOR_FORMAT (button);
|
|
41 DEFINE_IMAGE_INSTANTIATOR_FORMAT (combo_box);
|
|
42 Lisp_Object Qcombo_box;
|
|
43 DEFINE_IMAGE_INSTANTIATOR_FORMAT (edit_field);
|
|
44 Lisp_Object Qedit_field;
|
|
45 DEFINE_IMAGE_INSTANTIATOR_FORMAT (scrollbar);
|
|
46 Lisp_Object Qscrollbar;
|
|
47 DEFINE_IMAGE_INSTANTIATOR_FORMAT (widget);
|
|
48 DEFINE_IMAGE_INSTANTIATOR_FORMAT (label);
|
|
49 Lisp_Object Qlabel;
|
|
50 DEFINE_IMAGE_INSTANTIATOR_FORMAT (progress_gauge);
|
|
51 Lisp_Object Qprogress_gauge;
|
|
52 DEFINE_IMAGE_INSTANTIATOR_FORMAT (tree_view);
|
|
53 Lisp_Object Qtree_view;
|
|
54 DEFINE_IMAGE_INSTANTIATOR_FORMAT (tab_control);
|
|
55 Lisp_Object Qtab_control;
|
|
56 DEFINE_IMAGE_INSTANTIATOR_FORMAT (layout);
|
|
57 Lisp_Object Qlayout;
|
442
|
58 DEFINE_IMAGE_INSTANTIATOR_FORMAT (native_layout);
|
|
59 Lisp_Object Qnative_layout;
|
428
|
60
|
|
61 Lisp_Object Qetched_in, Qetched_out, Qbevel_in, Qbevel_out;
|
442
|
62 Lisp_Object Qmake_glyph;
|
428
|
63
|
|
64 #ifdef DEBUG_WIDGETS
|
|
65 int debug_widget_instances;
|
|
66 #endif
|
|
67
|
|
68 /* TODO:
|
438
|
69 - tooltips for controls, especially buttons.
|
440
|
70 - keyboard traversal.
|
|
71 - lisp configurable layout.
|
428
|
72 */
|
|
73
|
438
|
74 /* In MS-Windows normal windows work in pixels, dialog boxes work in
|
428
|
75 dialog box units. Why? sigh. We could reuse the metrics for dialogs
|
|
76 if this were not the case. As it is we have to position things
|
|
77 pixel wise. I'm not even sure that X has this problem at least for
|
|
78 buttons in groups. */
|
|
79 static int
|
|
80 widget_possible_dest_types (void)
|
|
81 {
|
|
82 return IMAGE_WIDGET_MASK;
|
|
83 }
|
|
84
|
|
85 static void
|
442
|
86 check_valid_instantiator (Lisp_Object data)
|
428
|
87 {
|
|
88 Lisp_Object glyph = data;
|
|
89 if (SYMBOLP (data))
|
|
90 glyph = XSYMBOL (data)->value;
|
|
91
|
442
|
92 if (!CONSP (glyph) && !VECTORP (glyph))
|
|
93 invalid_argument ("instantiator item must be a vector", data);
|
428
|
94 }
|
|
95
|
|
96 static void
|
|
97 check_valid_orientation (Lisp_Object data)
|
|
98 {
|
|
99 if (!EQ (data, Qhorizontal)
|
|
100 &&
|
|
101 !EQ (data, Qvertical))
|
563
|
102 invalid_constant ("unknown orientation for layout", data);
|
428
|
103 }
|
|
104
|
|
105 static void
|
438
|
106 check_valid_tab_orientation (Lisp_Object data)
|
|
107 {
|
|
108 if (!EQ (data, Qtop)
|
|
109 &&
|
|
110 !EQ (data, Qbottom)
|
|
111 &&
|
|
112 !EQ (data, Qleft)
|
|
113 &&
|
|
114 !EQ (data, Qright))
|
563
|
115 invalid_constant ("unknown orientation for tab control", data);
|
438
|
116 }
|
|
117
|
|
118 static void
|
428
|
119 check_valid_justification (Lisp_Object data)
|
|
120 {
|
|
121 if (!EQ (data, Qleft) && !EQ (data, Qright) && !EQ (data, Qcenter))
|
563
|
122 invalid_constant ("unknown justification for layout", data);
|
428
|
123 }
|
|
124
|
|
125 static void
|
|
126 check_valid_border (Lisp_Object data)
|
|
127 {
|
|
128 if (!EQ (data, Qt) && !EQ (data, Qetched_in) && !EQ (data, Qetched_out)
|
|
129 && !EQ (data, Qbevel_in) && !EQ (data, Qbevel_out)
|
|
130 && !GLYPHP (data) && !VECTORP (data))
|
442
|
131 invalid_argument ("unknown border style for layout", data);
|
428
|
132 }
|
|
133
|
|
134 static void
|
|
135 check_valid_anything (Lisp_Object data)
|
|
136 {
|
|
137 }
|
|
138
|
|
139 static void
|
|
140 check_valid_callback (Lisp_Object data)
|
|
141 {
|
|
142 if (!SYMBOLP (data)
|
|
143 && !COMPILED_FUNCTIONP (data)
|
|
144 && !CONSP (data))
|
|
145 {
|
442
|
146 invalid_argument (":callback must be a function or expression", data);
|
428
|
147 }
|
|
148 }
|
|
149
|
|
150 static void
|
442
|
151 check_valid_int_or_function (Lisp_Object data)
|
|
152 {
|
458
|
153 if (!INTP (data) && !CONSP (data) && !SYMBOLP (data))
|
442
|
154 invalid_argument ("must be an integer or expresssion", data);
|
|
155 }
|
|
156
|
|
157 static void
|
428
|
158 check_valid_symbol (Lisp_Object data)
|
|
159 {
|
|
160 CHECK_SYMBOL (data);
|
|
161 }
|
|
162
|
|
163 static void
|
|
164 check_valid_string_or_vector (Lisp_Object data)
|
|
165 {
|
|
166 if (!STRINGP (data) && !VECTORP (data))
|
442
|
167 invalid_argument (":descriptor must be a string or a vector", data);
|
428
|
168 }
|
|
169
|
793
|
170 static void
|
442
|
171 check_valid_item_list (Lisp_Object items)
|
428
|
172 {
|
|
173 Lisp_Object rest;
|
|
174
|
|
175 CHECK_LIST (items);
|
|
176 EXTERNAL_LIST_LOOP (rest, items)
|
|
177 {
|
|
178 if (STRINGP (XCAR (rest)))
|
|
179 CHECK_STRING (XCAR (rest));
|
|
180 else if (VECTORP (XCAR (rest)))
|
|
181 gui_parse_item_keywords (XCAR (rest));
|
|
182 else if (LISTP (XCAR (rest)))
|
442
|
183 check_valid_item_list (XCAR (rest));
|
428
|
184 else
|
442
|
185 invalid_argument ("Items must be vectors, lists or strings", items);
|
428
|
186 }
|
|
187 }
|
|
188
|
|
189 static void
|
442
|
190 check_valid_instantiator_list (Lisp_Object data)
|
428
|
191 {
|
|
192 Lisp_Object rest;
|
|
193
|
|
194 CHECK_LIST (data);
|
|
195 EXTERNAL_LIST_LOOP (rest, data)
|
|
196 {
|
442
|
197 check_valid_instantiator (XCAR (rest));
|
428
|
198 }
|
|
199 }
|
|
200
|
|
201 static Lisp_Object
|
|
202 glyph_instantiator_to_glyph (Lisp_Object sym)
|
|
203 {
|
|
204 /* This function calls lisp. */
|
|
205 Lisp_Object glyph = sym;
|
|
206 struct gcpro gcpro1;
|
442
|
207
|
428
|
208 GCPRO1 (glyph);
|
|
209 /* if we have a symbol get at the actual data */
|
|
210 if (SYMBOLP (glyph))
|
|
211 glyph = XSYMBOL (glyph)->value;
|
442
|
212
|
428
|
213 if (CONSP (glyph))
|
|
214 glyph = Feval (glyph);
|
|
215
|
|
216 /* Be really helpful to the user. */
|
|
217 if (VECTORP (glyph))
|
|
218 {
|
442
|
219 glyph = call1 (Qmake_glyph, glyph);
|
428
|
220 }
|
|
221
|
|
222 /* substitute the new glyph */
|
|
223 RETURN_UNGCPRO (glyph);
|
|
224 }
|
|
225
|
442
|
226 static void
|
428
|
227 substitute_keyword_value (Lisp_Object inst, Lisp_Object key, Lisp_Object val)
|
|
228 {
|
|
229 int i;
|
|
230 /* substitute the new glyph */
|
|
231 for (i = 0; i < XVECTOR_LENGTH (inst); i++)
|
|
232 {
|
|
233 if (EQ (key, XVECTOR_DATA (inst)[i]))
|
|
234 {
|
|
235 XVECTOR_DATA (inst)[i+1] = val;
|
|
236 break;
|
|
237 }
|
|
238 }
|
|
239 }
|
|
240
|
438
|
241 /* Wire widget property invocations to specific widgets. The problem
|
|
242 we are solving here is that when instantiators get converted to
|
|
243 instances they lose some type information (they just become
|
|
244 subwindows or widgets for example). For widgets we need to preserve
|
|
245 this type information so that we can do widget specific operations
|
|
246 on the instances. This is encoded in the widget type
|
|
247 field. widget_property gets invoked by decoding the primary type
|
|
248 (Qwidget), <widget>_property then invokes based on the secondary
|
|
249 type (Qedit_field for example). It is debatable whether we should
|
|
250 wire things in this generalised way rather than treating widgets
|
|
251 specially in image_instance_property. */
|
442
|
252 static Lisp_Object
|
428
|
253 widget_property (Lisp_Object image_instance, Lisp_Object prop)
|
|
254 {
|
440
|
255 Lisp_Image_Instance* ii = XIMAGE_INSTANCE (image_instance);
|
428
|
256 struct image_instantiator_methods* meths;
|
442
|
257 #if 0 /* The usefulness of this is dubious. */
|
428
|
258 /* first see if its a general property ... */
|
|
259 if (!NILP (Fplist_member (IMAGE_INSTANCE_WIDGET_PROPS (ii), prop)))
|
|
260 return Fplist_get (IMAGE_INSTANCE_WIDGET_PROPS (ii), prop, Qnil);
|
442
|
261 #endif
|
428
|
262 /* .. then try device specific methods ... */
|
442
|
263 meths = decode_device_ii_format (image_instance_device (image_instance),
|
|
264 IMAGE_INSTANCE_WIDGET_TYPE (ii),
|
428
|
265 ERROR_ME_NOT);
|
|
266 if (meths && HAS_IIFORMAT_METH_P (meths, property))
|
|
267 return IIFORMAT_METH (meths, property, (image_instance, prop));
|
|
268 /* ... then format specific methods ... */
|
442
|
269 meths = decode_device_ii_format (Qnil, IMAGE_INSTANCE_WIDGET_TYPE (ii),
|
428
|
270 ERROR_ME_NOT);
|
|
271 if (meths && HAS_IIFORMAT_METH_P (meths, property))
|
|
272 return IIFORMAT_METH (meths, property, (image_instance, prop));
|
|
273 /* ... then fail */
|
|
274 return Qunbound;
|
|
275 }
|
|
276
|
442
|
277 /* Update the displayed properties of a widget.
|
|
278
|
|
279 #### This has been adapted from the original set_property functions
|
|
280 and thus reuses the state management of that. A better solution is
|
|
281 to simply re-parse the instantiator when items need updating. This
|
|
282 make comparing differences much simpler and obviates the need for a
|
|
283 lot of the state variables.
|
|
284
|
|
285 #### property is still a valid function since we have to be able to
|
|
286 extract information from the actual widget.
|
|
287
|
|
288 #### update_widget should probably be re-written to use the
|
|
289 instantiator. We probably want to keep a record of the differences
|
|
290 also to make this easy. We would also need a pending_instantiator
|
|
291 so that changes could be delayed. */
|
|
292 static void
|
|
293 widget_update (Lisp_Object image_instance, Lisp_Object instantiator)
|
428
|
294 {
|
440
|
295 Lisp_Image_Instance* ii = XIMAGE_INSTANCE (image_instance);
|
428
|
296 struct image_instantiator_methods* meths;
|
454
|
297 struct gcpro gcpro1;
|
428
|
298
|
442
|
299 Lisp_Object text = find_keyword_in_vector (instantiator, Q_text);
|
454
|
300 Lisp_Object desc = find_keyword_in_vector (instantiator, Q_descriptor);
|
|
301 Lisp_Object items = find_keyword_in_vector (instantiator, Q_items);
|
|
302 Lisp_Object descriptor_item = Qnil;
|
|
303
|
|
304 GCPRO1 (descriptor_item);
|
|
305
|
442
|
306 /* Pick up any generic properties that we might need to keep hold
|
454
|
307 of.
|
|
308 #### This is potentially bogus because it is changing the items
|
|
309 in place rather than in the pending items. */
|
442
|
310 if (!NILP (text))
|
438
|
311 {
|
442
|
312 IMAGE_INSTANCE_WIDGET_TEXT (ii) = text;
|
|
313 IMAGE_INSTANCE_TEXT_CHANGED (ii) = 1;
|
438
|
314 }
|
|
315
|
454
|
316 /* Retrieve the gui item information. This is easy if we have been
|
|
317 provided with a vector, more difficult if we have just been given
|
|
318 keywords.
|
|
319
|
|
320 #### This is inconsistent with instantiation in that you have to
|
|
321 have the :descriptor keyword for updates in order to recognise
|
|
322 changes. */
|
|
323 if (VECTORP (desc))
|
|
324 {
|
|
325 descriptor_item = gui_parse_item_keywords_no_errors (desc);
|
|
326 }
|
|
327 else
|
|
328 {
|
|
329 /* Since we are updating the instantiator could be incomplete
|
|
330 and hence the gui item descriptor not well formed. We
|
|
331 therefore try updating and discard the results if nothing
|
|
332 changed. */
|
|
333 descriptor_item = copy_gui_item (IMAGE_INSTANCE_WIDGET_ITEM (ii));
|
|
334 if (!update_gui_item_keywords (descriptor_item, instantiator))
|
|
335 descriptor_item = Qnil;
|
|
336 }
|
|
337
|
|
338 /* Record new items for update. *_redisplay will do the
|
|
339 rest. */
|
|
340 if (!EQ (IMAGE_INSTANCE_WIDGET_TYPE (ii), Qlayout)
|
|
341 &&
|
|
342 !EQ (IMAGE_INSTANCE_WIDGET_TYPE (ii), Qnative_layout))
|
|
343 {
|
|
344 if (!NILP (items))
|
|
345 {
|
|
346 if (NILP (descriptor_item))
|
|
347 descriptor_item = IMAGE_INSTANCE_WIDGET_ITEM (ii);
|
|
348
|
|
349 check_valid_item_list (items);
|
|
350 #ifdef DEBUG_WIDGET_OUTPUT
|
|
351 stderr_out ("items for widget %p updated\n",
|
|
352 IMAGE_INSTANCE_SUBWINDOW_ID (ii));
|
|
353 #endif
|
|
354 /* Don't set the actual items since we might decide not to use
|
|
355 the new ones (because nothing has really changed). If we did
|
|
356 set them and didn't use them then we would get into whole
|
|
357 heaps of trouble when the old items get GC'd. */
|
|
358 descriptor_item = Fcons (descriptor_item, parse_gui_item_tree_children (items));
|
|
359 }
|
|
360 /* If the descriptor was updated but not the items we need to fill
|
|
361 in the `new' items. */
|
|
362 else if (!NILP (descriptor_item)
|
|
363 &&
|
|
364 CONSP (IMAGE_INSTANCE_WIDGET_ITEMS (ii)))
|
|
365 {
|
|
366 descriptor_item = Fcons
|
|
367 (descriptor_item,
|
|
368 copy_gui_item_tree (XCDR (IMAGE_INSTANCE_WIDGET_ITEMS (ii))));
|
|
369 }
|
|
370 }
|
|
371
|
|
372 if (!NILP (descriptor_item))
|
|
373 {
|
|
374 IMAGE_INSTANCE_WIDGET_PENDING_ITEMS (ii) = descriptor_item;
|
|
375 IMAGE_INSTANCE_WIDGET_ITEMS_CHANGED (ii) = 1;
|
|
376 }
|
|
377
|
|
378 UNGCPRO;
|
|
379
|
438
|
380 /* Now try device specific methods first ... */
|
442
|
381 meths = decode_device_ii_format (image_instance_device (image_instance),
|
|
382 IMAGE_INSTANCE_WIDGET_TYPE (ii),
|
|
383 ERROR_ME_NOT);
|
|
384 MAYBE_IIFORMAT_METH (meths, update, (image_instance, instantiator));
|
|
385 /* ... then format specific methods ... */
|
|
386 meths = decode_device_ii_format (Qnil, IMAGE_INSTANCE_WIDGET_TYPE (ii),
|
|
387 ERROR_ME_NOT);
|
|
388 MAYBE_IIFORMAT_METH (meths, update, (image_instance, instantiator));
|
|
389 #if 0 /* The usefulness of this is dubious. */
|
|
390 /* we didn't do any device specific properties, so shove the property in our plist. */
|
|
391 IMAGE_INSTANCE_WIDGET_PROPS (ii)
|
|
392 = Fplist_put (IMAGE_INSTANCE_WIDGET_PROPS (ii), prop, val);
|
|
393 #endif
|
|
394 }
|
|
395
|
|
396 /* Like the rest of redisplay, we want widget updates to occur
|
|
397 asynchronously. Thus toolkit specific methods for setting
|
|
398 properties must be called by redisplay instead of by *_update. Thus
|
|
399 *_update records the change and this function actually implements
|
|
400 it. We want to be slightly clever about this however by supplying
|
|
401 format specific functions for the updates instead of lumping them
|
|
402 all into this function. Note that there is no need for format
|
|
403 generic functions. This is not the same as widget_update! */
|
|
404 void
|
|
405 redisplay_widget (Lisp_Object widget)
|
|
406 {
|
|
407 Lisp_Image_Instance* ii = XIMAGE_INSTANCE (widget);
|
|
408 struct image_instantiator_methods* meths;
|
|
409
|
|
410 if (!WIDGET_IMAGE_INSTANCEP (widget)
|
|
411 || EQ (IMAGE_INSTANCE_WIDGET_TYPE (ii), Qlayout)
|
|
412 || EQ (IMAGE_INSTANCE_WIDGET_TYPE (ii), Qnative_layout))
|
|
413 return;
|
|
414
|
|
415 /* Device-format specific methods - e.g. x_tab_control_redisplay () */
|
|
416 meths = decode_device_ii_format (image_instance_device (widget),
|
428
|
417 IMAGE_INSTANCE_WIDGET_TYPE (ii),
|
|
418 ERROR_ME_NOT);
|
442
|
419 MAYBE_IIFORMAT_METH (meths, redisplay, (widget));
|
|
420
|
|
421 /* Device generic methods - e.g. x_redisplay_widget (). We must
|
|
422 update the widget's size as it may have been changed by the the
|
|
423 layout routines. We also do this here so that explicit resizing
|
|
424 from lisp does not result in synchronous updates. Do this last so
|
|
425 that format-specific methods have an opportunity to prevent
|
|
426 wholesale changes - e.g. rebuilding tabs. */
|
|
427 MAYBE_DEVMETH (DOMAIN_XDEVICE (ii->domain), redisplay_widget, (ii));
|
|
428
|
|
429 /* Pick up the items we recorded earlier. */
|
|
430 if (IMAGE_INSTANCE_WIDGET_ITEMS_CHANGED (ii))
|
428
|
431 {
|
442
|
432 IMAGE_INSTANCE_WIDGET_ITEMS (ii) =
|
|
433 IMAGE_INSTANCE_WIDGET_PENDING_ITEMS (ii);
|
|
434 IMAGE_INSTANCE_WIDGET_PENDING_ITEMS (ii) = Qnil;
|
428
|
435 }
|
|
436 }
|
|
437
|
771
|
438 static void
|
|
439 widget_query_string_geometry (Lisp_Object string, Lisp_Object face,
|
|
440 int *width, int *height, Lisp_Object domain)
|
|
441 {
|
|
442 struct device *d = DOMAIN_XDEVICE (domain);
|
|
443
|
|
444 if (HAS_DEVMETH_P (d, widget_query_string_geometry))
|
|
445 DEVMETH (d, widget_query_string_geometry,
|
|
446 (string, face, width, height, domain));
|
|
447 else
|
|
448 query_string_geometry (string, face, width, height, 0, domain);
|
|
449
|
|
450 }
|
|
451
|
438
|
452 /* Query for a widgets desired geometry. If no type specific method is
|
|
453 provided then use the widget text to calculate sizes. */
|
442
|
454 static void
|
|
455 widget_query_geometry (Lisp_Object image_instance,
|
|
456 int* width, int* height,
|
438
|
457 enum image_instance_geometry disp, Lisp_Object domain)
|
|
458 {
|
440
|
459 Lisp_Image_Instance* ii = XIMAGE_INSTANCE (image_instance);
|
438
|
460 struct image_instantiator_methods* meths;
|
442
|
461 Lisp_Object dynamic_width = Qnil;
|
|
462 Lisp_Object dynamic_height = Qnil;
|
438
|
463
|
|
464 /* First just set up what we already have. */
|
|
465 if (width) *width = IMAGE_INSTANCE_WIDTH (ii);
|
|
466 if (height) *height = IMAGE_INSTANCE_HEIGHT (ii);
|
442
|
467
|
438
|
468 if (IMAGE_INSTANCE_SUBWINDOW_V_RESIZEP (ii)
|
|
469 ||
|
|
470 IMAGE_INSTANCE_SUBWINDOW_H_RESIZEP (ii))
|
|
471 {
|
|
472 /* .. then try device specific methods ... */
|
442
|
473 meths = decode_device_ii_format (image_instance_device (image_instance),
|
|
474 IMAGE_INSTANCE_WIDGET_TYPE (ii),
|
438
|
475 ERROR_ME_NOT);
|
|
476 if (meths && HAS_IIFORMAT_METH_P (meths, query_geometry))
|
442
|
477 IIFORMAT_METH (meths, query_geometry, (image_instance,
|
438
|
478 width, height, disp,
|
|
479 domain));
|
|
480 else
|
|
481 {
|
|
482 /* ... then format specific methods ... */
|
442
|
483 meths = decode_device_ii_format (Qnil, IMAGE_INSTANCE_WIDGET_TYPE (ii),
|
438
|
484 ERROR_ME_NOT);
|
|
485 if (meths && HAS_IIFORMAT_METH_P (meths, query_geometry))
|
442
|
486 IIFORMAT_METH (meths, query_geometry, (image_instance,
|
438
|
487 width, height, disp,
|
|
488 domain));
|
442
|
489 else
|
438
|
490 {
|
442
|
491 int w, h;
|
|
492
|
438
|
493 /* Then if we are allowed to resize the widget, make the
|
|
494 size the same as the text dimensions. */
|
771
|
495 widget_query_string_geometry (IMAGE_INSTANCE_WIDGET_TEXT (ii),
|
|
496 IMAGE_INSTANCE_WIDGET_FACE (ii),
|
|
497 &w, &h, domain);
|
438
|
498 /* Adjust the size for borders. */
|
|
499 if (IMAGE_INSTANCE_SUBWINDOW_H_RESIZEP (ii))
|
|
500 *width = w + 2 * WIDGET_BORDER_WIDTH;
|
|
501 if (IMAGE_INSTANCE_SUBWINDOW_V_RESIZEP (ii))
|
|
502 *height = h + 2 * WIDGET_BORDER_HEIGHT;
|
|
503 }
|
|
504 }
|
442
|
505 /* Finish off with dynamic sizing. */
|
|
506 if (!NILP (IMAGE_INSTANCE_WIDGET_WIDTH_SUBR (ii)))
|
|
507 {
|
|
508 dynamic_width = Feval (IMAGE_INSTANCE_WIDGET_WIDTH_SUBR (ii));
|
|
509 if (INTP (dynamic_width))
|
|
510 *width = XINT (dynamic_width);
|
|
511 }
|
|
512 if (!NILP (IMAGE_INSTANCE_WIDGET_HEIGHT_SUBR (ii)))
|
|
513 {
|
|
514 dynamic_height = Feval (IMAGE_INSTANCE_WIDGET_HEIGHT_SUBR (ii));
|
|
515 if (INTP (dynamic_height))
|
|
516 *height = XINT (dynamic_height);
|
|
517 }
|
438
|
518 }
|
|
519 }
|
|
520
|
442
|
521 static int
|
|
522 widget_layout (Lisp_Object image_instance,
|
|
523 int width, int height, int xoffset, int yoffset,
|
|
524 Lisp_Object domain)
|
438
|
525 {
|
440
|
526 Lisp_Image_Instance* ii = XIMAGE_INSTANCE (image_instance);
|
438
|
527 struct image_instantiator_methods* meths;
|
|
528
|
|
529 /* .. then try device specific methods ... */
|
442
|
530 meths = decode_device_ii_format (image_instance_device (image_instance),
|
|
531 IMAGE_INSTANCE_WIDGET_TYPE (ii),
|
438
|
532 ERROR_ME_NOT);
|
|
533 if (meths && HAS_IIFORMAT_METH_P (meths, layout))
|
442
|
534 return IIFORMAT_METH (meths, layout, (image_instance,
|
|
535 width, height, xoffset, yoffset,
|
|
536 domain));
|
438
|
537 else
|
|
538 {
|
|
539 /* ... then format specific methods ... */
|
442
|
540 meths = decode_device_ii_format (Qnil, IMAGE_INSTANCE_WIDGET_TYPE (ii),
|
438
|
541 ERROR_ME_NOT);
|
|
542 if (meths && HAS_IIFORMAT_METH_P (meths, layout))
|
442
|
543 return IIFORMAT_METH (meths, layout, (image_instance,
|
|
544 width, height, xoffset, yoffset,
|
|
545 domain));
|
438
|
546 }
|
442
|
547 return 1;
|
438
|
548 }
|
|
549
|
428
|
550 static void
|
|
551 widget_validate (Lisp_Object instantiator)
|
|
552 {
|
|
553 Lisp_Object desc = find_keyword_in_vector (instantiator, Q_descriptor);
|
|
554
|
|
555 if (NILP (desc))
|
563
|
556 invalid_argument ("Must supply :descriptor", instantiator);
|
428
|
557
|
|
558 if (VECTORP (desc))
|
|
559 gui_parse_item_keywords (desc);
|
|
560
|
|
561 if (!NILP (find_keyword_in_vector (instantiator, Q_width))
|
|
562 && !NILP (find_keyword_in_vector (instantiator, Q_pixel_width)))
|
563
|
563 invalid_argument ("Must supply only one of :width and :pixel-width", instantiator);
|
428
|
564
|
|
565 if (!NILP (find_keyword_in_vector (instantiator, Q_height))
|
|
566 && !NILP (find_keyword_in_vector (instantiator, Q_pixel_height)))
|
563
|
567 invalid_argument ("Must supply only one of :height and :pixel-height", instantiator);
|
428
|
568 }
|
|
569
|
|
570 static void
|
|
571 combo_box_validate (Lisp_Object instantiator)
|
|
572 {
|
|
573 widget_validate (instantiator);
|
442
|
574 if (NILP (find_keyword_in_vector (instantiator, Q_items)))
|
563
|
575 invalid_argument ("Must supply item list", instantiator);
|
428
|
576 }
|
|
577
|
|
578 /* we need to convert things like glyphs to images, eval expressions
|
|
579 etc.*/
|
|
580 static Lisp_Object
|
442
|
581 widget_normalize (Lisp_Object inst, Lisp_Object console_type,
|
|
582 Lisp_Object dest_mask)
|
428
|
583 {
|
|
584 /* This function can call lisp */
|
|
585 Lisp_Object glyph = find_keyword_in_vector (inst, Q_image);
|
|
586
|
|
587 /* we need to eval glyph if its an expression, we do this for the
|
442
|
588 same reasons we normalize file to data.
|
|
589
|
|
590 #### should just normalize the data. */
|
428
|
591 if (!NILP (glyph))
|
|
592 {
|
|
593 substitute_keyword_value (inst, Q_image, glyph_instantiator_to_glyph (glyph));
|
|
594 }
|
|
595
|
|
596 return inst;
|
|
597 }
|
|
598
|
|
599 static void
|
440
|
600 initialize_widget_image_instance (Lisp_Image_Instance *ii, Lisp_Object type)
|
428
|
601 {
|
|
602 /* initialize_subwindow_image_instance (ii);*/
|
|
603 IMAGE_INSTANCE_WIDGET_TYPE (ii) = type;
|
|
604 IMAGE_INSTANCE_WIDGET_PROPS (ii) = Qnil;
|
438
|
605 SET_IMAGE_INSTANCE_WIDGET_FACE (ii, Qnil);
|
428
|
606 IMAGE_INSTANCE_WIDGET_ITEMS (ii) = allocate_gui_item ();
|
442
|
607 IMAGE_INSTANCE_LAYOUT_CHILDREN (ii) = Qnil;
|
|
608 IMAGE_INSTANCE_WIDGET_PENDING_ITEMS (ii) = Qnil;
|
|
609 IMAGE_INSTANCE_WIDGET_WIDTH_SUBR (ii) = Qnil;
|
|
610 IMAGE_INSTANCE_WIDGET_HEIGHT_SUBR (ii) = Qnil;
|
438
|
611 IMAGE_INSTANCE_SUBWINDOW_H_RESIZEP (ii) = 1;
|
|
612 IMAGE_INSTANCE_SUBWINDOW_V_RESIZEP (ii) = 1;
|
442
|
613 IMAGE_INSTANCE_SUBWINDOW_ORIENT (ii) = LAYOUT_HORIZONTAL;
|
438
|
614 IMAGE_INSTANCE_SUBWINDOW_JUSTIFY (ii) = 0;
|
428
|
615 }
|
|
616
|
|
617 /* Instantiate a button widget. Unfortunately instantiated widgets are
|
|
618 particular to a frame since they need to have a parent. It's not
|
|
619 like images where you just select the image into the context you
|
|
620 want to display it in and BitBlt it. So image instances can have a
|
|
621 many-to-one relationship with things you see, whereas widgets can
|
|
622 only be one-to-one (i.e. per frame) */
|
|
623 void
|
438
|
624 widget_instantiate (Lisp_Object image_instance, Lisp_Object instantiator,
|
|
625 Lisp_Object pointer_fg, Lisp_Object pointer_bg,
|
|
626 int dest_mask, Lisp_Object domain)
|
428
|
627 {
|
442
|
628 /* #### practically all of this should be moved to widget_update()
|
|
629 so that users can dynamically change all possible widget
|
|
630 properties. */
|
440
|
631 Lisp_Image_Instance *ii = XIMAGE_INSTANCE (image_instance);
|
428
|
632 Lisp_Object face = find_keyword_in_vector (instantiator, Q_face);
|
|
633 Lisp_Object height = find_keyword_in_vector (instantiator, Q_height);
|
|
634 Lisp_Object width = find_keyword_in_vector (instantiator, Q_width);
|
|
635 Lisp_Object pixwidth = find_keyword_in_vector (instantiator, Q_pixel_width);
|
|
636 Lisp_Object pixheight = find_keyword_in_vector (instantiator, Q_pixel_height);
|
|
637 Lisp_Object desc = find_keyword_in_vector (instantiator, Q_descriptor);
|
|
638 Lisp_Object glyph = find_keyword_in_vector (instantiator, Q_image);
|
440
|
639 Lisp_Object items = find_keyword_in_vector (instantiator, Q_items);
|
438
|
640 Lisp_Object orient = find_keyword_in_vector (instantiator, Q_orientation);
|
442
|
641 Lisp_Object mwidth = find_keyword_in_vector (instantiator, Q_margin_width);
|
|
642 Lisp_Object ifocus = find_keyword_in_vector (instantiator, Q_initial_focus);
|
428
|
643 int pw=0, ph=0, tw=0, th=0;
|
442
|
644
|
428
|
645 /* this just does pixel type sizing */
|
|
646 subwindow_instantiate (image_instance, instantiator, pointer_fg, pointer_bg,
|
|
647 dest_mask, domain);
|
|
648
|
442
|
649 if (!(dest_mask & IMAGE_WIDGET_MASK))
|
|
650 incompatible_image_types (instantiator, dest_mask, IMAGE_WIDGET_MASK);
|
428
|
651
|
|
652 initialize_widget_image_instance (ii, XVECTOR_DATA (instantiator)[0]);
|
|
653
|
440
|
654 IMAGE_INSTANCE_TYPE (ii) = IMAGE_WIDGET;
|
|
655
|
428
|
656 /* retrieve the fg and bg colors */
|
|
657 if (!NILP (face))
|
438
|
658 SET_IMAGE_INSTANCE_WIDGET_FACE (ii, Fget_face (face));
|
428
|
659
|
454
|
660 /* Retrieve the gui item information. This is easy if we have been
|
428
|
661 provided with a vector, more difficult if we have just been given
|
454
|
662 keywords. Note that standard gui descriptor shortcuts will not work
|
|
663 because of keyword parsing.
|
|
664
|
|
665 #### This is bogus in that descriptor and items share the same slot,
|
|
666 we should rationalize. */
|
|
667 if (VECTORP (desc))
|
|
668 {
|
|
669 IMAGE_INSTANCE_WIDGET_ITEMS (ii) =
|
|
670 gui_parse_item_keywords_no_errors (desc);
|
|
671 }
|
|
672 else
|
428
|
673 {
|
|
674 /* big cheat - we rely on the fact that a gui item looks like an instantiator */
|
442
|
675 IMAGE_INSTANCE_WIDGET_ITEMS (ii) =
|
454
|
676 widget_gui_parse_item_keywords (instantiator);
|
428
|
677 }
|
|
678
|
440
|
679 /* Pick up the orientation before we do our first layout. */
|
|
680 if (EQ (orient, Qleft) || EQ (orient, Qright) || EQ (orient, Qvertical))
|
442
|
681 IMAGE_INSTANCE_SUBWINDOW_ORIENT (ii) = LAYOUT_VERTICAL;
|
440
|
682
|
428
|
683 /* parse more gui items out of the properties */
|
442
|
684 if (!NILP (items) && !EQ (IMAGE_INSTANCE_WIDGET_TYPE (ii), Qlayout)
|
|
685 && !EQ (IMAGE_INSTANCE_WIDGET_TYPE (ii), Qnative_layout))
|
428
|
686 {
|
442
|
687 IMAGE_INSTANCE_WIDGET_ITEMS (ii) =
|
|
688 Fcons (IMAGE_INSTANCE_WIDGET_ITEMS (ii),
|
|
689 parse_gui_item_tree_children (items));
|
428
|
690 }
|
|
691
|
438
|
692 /* Normalize size information. We now only assign sizes if the user
|
|
693 gives us some explicitly, or there are some constraints that we
|
|
694 can't change later on. Otherwise we postpone sizing until query
|
|
695 geometry gets called. */
|
|
696 if (!NILP (pixwidth)) /* pixwidth takes precendent */
|
|
697 {
|
442
|
698 if (!INTP (pixwidth))
|
|
699 IMAGE_INSTANCE_WIDGET_WIDTH_SUBR (ii) = pixwidth;
|
|
700 else
|
|
701 {
|
|
702 pw = XINT (pixwidth);
|
|
703 IMAGE_INSTANCE_SUBWINDOW_H_RESIZEP (ii) = 0;
|
|
704 }
|
438
|
705 }
|
|
706 else if (!NILP (width))
|
|
707 {
|
|
708 tw = XINT (width);
|
|
709 IMAGE_INSTANCE_SUBWINDOW_H_RESIZEP (ii) = 0;
|
|
710 }
|
|
711
|
428
|
712 if (!NILP (pixheight))
|
438
|
713 {
|
442
|
714 if (!INTP (pixheight))
|
|
715 IMAGE_INSTANCE_WIDGET_HEIGHT_SUBR (ii) = pixheight;
|
|
716 else
|
|
717 {
|
|
718 ph = XINT (pixheight);
|
|
719 IMAGE_INSTANCE_SUBWINDOW_V_RESIZEP (ii) = 0;
|
|
720 }
|
438
|
721 }
|
|
722 else if (!NILP (height) && XINT (height) > 1)
|
|
723 {
|
|
724 th = XINT (height);
|
|
725 IMAGE_INSTANCE_SUBWINDOW_V_RESIZEP (ii) = 0;
|
|
726 }
|
|
727
|
|
728 /* Taking the default face information when the user has specified
|
|
729 size in characters is probably as good as any since the widget
|
|
730 face is more likely to be proportional and thus give inadequate
|
|
731 results. Using character sizes can only ever be approximate
|
|
732 anyway. */
|
|
733 if (tw || th)
|
|
734 {
|
|
735 int charwidth, charheight;
|
|
736 default_face_font_info (domain, 0, 0, &charheight, &charwidth, 0);
|
|
737 if (tw)
|
|
738 pw = charwidth * tw;
|
|
739 if (th)
|
|
740 ph = charheight * th;
|
|
741 }
|
428
|
742
|
|
743 /* for a widget with an image pick up the dimensions from that */
|
|
744 if (!NILP (glyph))
|
|
745 {
|
438
|
746 if (!pw)
|
442
|
747 pw = glyph_width (glyph, image_instance) + 2 * WIDGET_BORDER_WIDTH;
|
438
|
748 if (!ph)
|
442
|
749 ph = glyph_height (glyph, image_instance) + 2 * WIDGET_BORDER_HEIGHT;
|
438
|
750 IMAGE_INSTANCE_SUBWINDOW_V_RESIZEP (ii) = 0;
|
|
751 IMAGE_INSTANCE_SUBWINDOW_H_RESIZEP (ii) = 0;
|
428
|
752 }
|
|
753
|
442
|
754 /* Pick up the margin width. */
|
|
755 if (!NILP (mwidth))
|
|
756 IMAGE_INSTANCE_MARGIN_WIDTH (ii) = XINT (mwidth);
|
|
757
|
|
758 IMAGE_INSTANCE_WANTS_INITIAL_FOCUS (ii) = !NILP (ifocus);
|
438
|
759
|
442
|
760 /* Layout for the layout widget is premature at this point since the
|
|
761 children will not have been instantiated. We can't instantiate
|
|
762 them until the device instantiation method for the layout has
|
|
763 been executed. We do however want to record any specified
|
|
764 dimensions. */
|
|
765 if (pw) IMAGE_INSTANCE_WIDTH (ii) = pw;
|
|
766 if (ph) IMAGE_INSTANCE_HEIGHT (ii) = ph;
|
|
767 }
|
|
768
|
|
769 static void
|
|
770 widget_post_instantiate (Lisp_Object image_instance, Lisp_Object instantiator,
|
|
771 Lisp_Object domain)
|
|
772 {
|
428
|
773 #ifdef DEBUG_WIDGETS
|
|
774 debug_widget_instances++;
|
|
775 stderr_out ("instantiated ");
|
|
776 debug_print (instantiator);
|
|
777 stderr_out ("%d widgets instantiated\n", debug_widget_instances);
|
|
778 #endif
|
|
779 }
|
|
780
|
442
|
781 /* Get the geometry of a button control. We need to adjust the size
|
|
782 depending on the type of button. */
|
|
783 static void
|
|
784 button_query_geometry (Lisp_Object image_instance,
|
|
785 int* width, int* height,
|
|
786 enum image_instance_geometry disp, Lisp_Object domain)
|
|
787 {
|
|
788 Lisp_Image_Instance *ii = XIMAGE_INSTANCE (image_instance);
|
|
789 int w, h;
|
771
|
790 widget_query_string_geometry (IMAGE_INSTANCE_WIDGET_TEXT (ii),
|
|
791 IMAGE_INSTANCE_WIDGET_FACE (ii),
|
|
792 &w, &h, domain);
|
442
|
793 /* Adjust the size for borders. */
|
|
794 if (IMAGE_INSTANCE_SUBWINDOW_H_RESIZEP (ii))
|
|
795 {
|
|
796 *width = w + 2 * WIDGET_BORDER_WIDTH;
|
|
797
|
|
798 if (EQ (XGUI_ITEM (IMAGE_INSTANCE_WIDGET_ITEM (ii))->style, Qradio)
|
|
799 ||
|
|
800 EQ (XGUI_ITEM (IMAGE_INSTANCE_WIDGET_ITEM (ii))->style, Qtoggle))
|
|
801 /* This is an approximation to the size of the actual button bit. */
|
|
802 *width += 12;
|
|
803 }
|
|
804 if (IMAGE_INSTANCE_SUBWINDOW_V_RESIZEP (ii))
|
|
805 *height = h + 2 * WIDGET_BORDER_HEIGHT;
|
|
806 }
|
|
807
|
438
|
808 /* tree-view geometry - get the height right */
|
428
|
809 static void
|
442
|
810 tree_view_query_geometry (Lisp_Object image_instance,
|
|
811 int* width, int* height,
|
438
|
812 enum image_instance_geometry disp, Lisp_Object domain)
|
428
|
813 {
|
440
|
814 Lisp_Image_Instance *ii = XIMAGE_INSTANCE (image_instance);
|
438
|
815 Lisp_Object items = IMAGE_INSTANCE_WIDGET_ITEMS (ii);
|
|
816
|
442
|
817
|
438
|
818 if (*width)
|
|
819 {
|
|
820 /* #### what should this be. reconsider when X has tree views. */
|
771
|
821 widget_query_string_geometry (IMAGE_INSTANCE_WIDGET_TEXT (ii),
|
|
822 IMAGE_INSTANCE_WIDGET_FACE (ii),
|
|
823 width, 0, domain);
|
438
|
824 }
|
|
825 if (*height)
|
|
826 {
|
|
827 int len, h;
|
|
828 default_face_font_info (domain, 0, 0, &h, 0, 0);
|
|
829 GET_LIST_LENGTH (items, len);
|
|
830 *height = len * h;
|
|
831 }
|
428
|
832 }
|
|
833
|
438
|
834 /* Get the geometry of a tab control. This is based on the number of
|
|
835 items and text therin in the tab control. */
|
428
|
836 static void
|
442
|
837 tab_control_query_geometry (Lisp_Object image_instance,
|
|
838 int* width, int* height,
|
438
|
839 enum image_instance_geometry disp, Lisp_Object domain)
|
428
|
840 {
|
440
|
841 Lisp_Image_Instance *ii = XIMAGE_INSTANCE (image_instance);
|
442
|
842 Lisp_Object items = XCDR (IMAGE_INSTANCE_WIDGET_ITEMS (ii));
|
428
|
843 Lisp_Object rest;
|
442
|
844 int tw = 0, th = 0;
|
428
|
845
|
438
|
846 LIST_LOOP (rest, items)
|
428
|
847 {
|
442
|
848 int h, w;
|
438
|
849
|
771
|
850 widget_query_string_geometry (XGUI_ITEM (XCAR (rest))->name,
|
|
851 IMAGE_INSTANCE_WIDGET_FACE (ii),
|
|
852 &w, &h, domain);
|
442
|
853 tw += 5 * WIDGET_BORDER_WIDTH; /* some bias */
|
438
|
854 tw += w;
|
|
855 th = max (th, h + 2 * WIDGET_BORDER_HEIGHT);
|
428
|
856 }
|
|
857
|
438
|
858 /* Fixup returned values depending on orientation. */
|
|
859 if (IMAGE_INSTANCE_SUBWINDOW_ORIENT (ii))
|
|
860 {
|
|
861 if (height) *height = tw;
|
|
862 if (width) *width = th;
|
|
863 }
|
|
864 else
|
|
865 {
|
|
866 if (height) *height = th;
|
|
867 if (width) *width = tw;
|
|
868 }
|
428
|
869 }
|
|
870
|
442
|
871 /* Determine whether only the order has changed for a tab. */
|
|
872 int tab_control_order_only_changed (Lisp_Object image_instance)
|
|
873 {
|
|
874 Lisp_Image_Instance *ii = XIMAGE_INSTANCE (image_instance);
|
|
875 int found = 0, len, pending_len;
|
|
876 Lisp_Object rest;
|
|
877
|
|
878 /* Degenerate case. */
|
|
879 if (NILP (IMAGE_INSTANCE_WIDGET_PENDING_ITEMS (ii)))
|
|
880 return 1;
|
|
881
|
|
882 /* See whether we just need a change in order. */
|
|
883 GET_LIST_LENGTH (IMAGE_INSTANCE_WIDGET_ITEMS (ii), len);
|
|
884 GET_LIST_LENGTH (IMAGE_INSTANCE_WIDGET_PENDING_ITEMS (ii),
|
|
885 pending_len);
|
|
886 if (len == pending_len)
|
|
887 {
|
|
888 LIST_LOOP (rest, XCDR (IMAGE_INSTANCE_WIDGET_ITEMS (ii)))
|
|
889 {
|
|
890 Lisp_Object pending_rest;
|
|
891 found = 0;
|
|
892 LIST_LOOP (pending_rest,
|
|
893 XCDR (IMAGE_INSTANCE_WIDGET_PENDING_ITEMS (ii)))
|
|
894 {
|
|
895 if (gui_item_equal_sans_selected (XCAR (rest),
|
|
896 XCAR (pending_rest), 0))
|
|
897 {
|
|
898 found = 1;
|
|
899 break;
|
|
900 }
|
|
901 }
|
|
902 if (!found)
|
|
903 break;
|
|
904 }
|
|
905 }
|
|
906 return found;
|
|
907 }
|
|
908
|
428
|
909
|
|
910 /*****************************************************************************
|
|
911 * widget layout *
|
|
912 *****************************************************************************/
|
442
|
913 /* We need to cascade normalization.*/
|
428
|
914 static Lisp_Object
|
442
|
915 layout_normalize (Lisp_Object inst, Lisp_Object console_type,
|
|
916 Lisp_Object dest_mask)
|
428
|
917 {
|
|
918 /* This function can call lisp */
|
442
|
919 struct gcpro gcpro1, gcpro2;
|
|
920 Lisp_Object alist = Qnil, new_items = Qnil, border;
|
|
921 /* This function can call lisp */
|
|
922 Lisp_Object items;
|
|
923
|
|
924 GCPRO2 (alist, new_items);
|
|
925 alist = tagged_vector_to_alist (inst);
|
|
926 items = assq_no_quit (Q_items, alist);
|
|
927
|
|
928 /* We need to normalize sub-objects. */
|
428
|
929 if (!NILP (items))
|
|
930 {
|
|
931 Lisp_Object rest;
|
442
|
932 LIST_LOOP (rest, XCDR (items))
|
428
|
933 {
|
442
|
934 /* Substitute the new instantiator */
|
|
935 new_items = Fcons (normalize_image_instantiator (XCAR (rest),
|
|
936 console_type, dest_mask),
|
|
937 new_items);
|
|
938 }
|
|
939 new_items = Fnreverse (new_items);
|
|
940 Fsetcdr (items, new_items);
|
|
941 }
|
|
942 /* Normalize the border spec. */
|
|
943 border = assq_no_quit (Q_border, alist);
|
|
944 if (!NILP (border) && VECTORP (XCDR (border)))
|
|
945 {
|
|
946 Fsetcdr (border, normalize_image_instantiator (XCDR (border),
|
|
947 console_type, dest_mask));
|
|
948 }
|
|
949
|
|
950 {
|
|
951 Lisp_Object result = alist_to_tagged_vector (XVECTOR_DATA (inst)[0],
|
|
952 alist);
|
|
953 free_alist (alist);
|
|
954 RETURN_UNGCPRO (result);
|
|
955 }
|
|
956 }
|
|
957
|
|
958 /* Update the instances in the layout. */
|
|
959 static void
|
|
960 layout_update (Lisp_Object image_instance, Lisp_Object instantiator)
|
|
961 {
|
|
962 Lisp_Image_Instance *ii = XIMAGE_INSTANCE (image_instance);
|
|
963 Lisp_Object items = find_keyword_in_vector (instantiator, Q_items);
|
|
964 Lisp_Object border_inst = find_keyword_in_vector (instantiator, Q_border);
|
|
965 Lisp_Object border = Qnil;
|
|
966 Lisp_Object children = IMAGE_INSTANCE_LAYOUT_CHILDREN (ii);
|
|
967 int structure_changed = 0;
|
|
968 struct gcpro gcpro1;
|
|
969
|
|
970 /* We want to avoid consing if we can. This is quite awkward because
|
|
971 we have to deal with the border as well as the items. */
|
|
972
|
|
973 GCPRO1 (border);
|
|
974
|
|
975 if (INTP (IMAGE_INSTANCE_LAYOUT_BORDER (ii)))
|
|
976 {
|
|
977 border = XCAR (children);
|
|
978 children = XCDR (children);
|
|
979 }
|
|
980
|
|
981 #ifdef DEBUG_WIDGET_OUTPUT
|
|
982 stderr_out ("layout updated\n");
|
|
983 #endif
|
|
984 /* Update the border. */
|
|
985 if (!NILP (border_inst))
|
|
986 {
|
|
987 if (VECTORP (border_inst))
|
|
988 {
|
|
989 /* We are going to be sneaky here and add the border text as
|
|
990 just another child, the layout and output routines don't know
|
|
991 this and will just display at the offsets we prescribe. */
|
|
992 if (!NILP (border))
|
|
993 call3 (Qset_glyph_image, border, border_inst,
|
|
994 IMAGE_INSTANCE_DOMAIN (ii));
|
|
995 else
|
|
996 {
|
|
997 border = Fcons (call1 (Qmake_glyph, border_inst), Qnil);
|
|
998 structure_changed = 1;
|
|
999 }
|
|
1000 IMAGE_INSTANCE_LAYOUT_BORDER (ii) = make_int (0);
|
|
1001 }
|
|
1002 else
|
|
1003 {
|
|
1004 if (!NILP (border))
|
|
1005 {
|
|
1006 border = Qnil;
|
|
1007 structure_changed = 1;
|
|
1008 }
|
|
1009 if (EQ (border_inst, Qt))
|
|
1010 IMAGE_INSTANCE_LAYOUT_BORDER (ii) = Qetched_in;
|
|
1011 else
|
|
1012 IMAGE_INSTANCE_LAYOUT_BORDER (ii) = border_inst;
|
428
|
1013 }
|
|
1014 }
|
442
|
1015
|
|
1016 /* Pick up the sub-widgets. */
|
|
1017 if (!NILP (items))
|
428
|
1018 {
|
442
|
1019 int len1, len2;
|
|
1020 GET_LIST_LENGTH (items, len1);
|
|
1021 GET_LIST_LENGTH (children, len2);
|
|
1022 /* The structure hasn't changed so just update the images. */
|
|
1023 if (!structure_changed && len1 == len2)
|
|
1024 {
|
|
1025 /* Pick up the sub-widgets. */
|
|
1026 for (; !NILP (children); children = XCDR (children), items = XCDR (items))
|
|
1027 {
|
|
1028 call3 (Qset_glyph_image, XCAR (children), XCAR (items),
|
|
1029 IMAGE_INSTANCE_DOMAIN (ii));
|
|
1030 }
|
|
1031 }
|
|
1032 /* The structure has changed so start over. */
|
|
1033 else
|
|
1034 {
|
|
1035 /* Instantiate any new glyphs. */
|
|
1036 for (; !NILP (items); items = XCDR (items))
|
|
1037 {
|
458
|
1038 /* #### We really want to use call_with_suspended_errors
|
|
1039 here, but it won't allow us to call lisp. */
|
442
|
1040 border = Fcons (call1 (Qmake_glyph, XCAR (items)), border);
|
|
1041 }
|
|
1042 IMAGE_INSTANCE_LAYOUT_CHILDREN (ii) = Fnreverse (border);
|
|
1043 }
|
428
|
1044 }
|
442
|
1045 UNGCPRO;
|
|
1046 }
|
|
1047
|
|
1048 static void
|
|
1049 layout_instantiate (Lisp_Object image_instance, Lisp_Object instantiator,
|
|
1050 Lisp_Object pointer_fg, Lisp_Object pointer_bg,
|
|
1051 int dest_mask, Lisp_Object domain)
|
|
1052 {
|
|
1053 Lisp_Image_Instance *ii = XIMAGE_INSTANCE (image_instance);
|
|
1054 Lisp_Object orient = find_keyword_in_vector (instantiator, Q_orientation);
|
|
1055
|
|
1056 #ifdef DEBUG_WIDGET_OUTPUT
|
|
1057 stderr_out ("layout instantiated\n");
|
|
1058 #endif
|
|
1059 /* Do widget type instantiation first. */
|
|
1060 widget_instantiate (image_instance, instantiator, pointer_fg, pointer_bg,
|
|
1061 dest_mask, domain);
|
|
1062
|
|
1063 if (NILP (orient))
|
|
1064 {
|
|
1065 IMAGE_INSTANCE_SUBWINDOW_ORIENT (ii) = LAYOUT_VERTICAL;
|
|
1066 }
|
|
1067
|
|
1068 /* Get child glyphs and finish instantiation. We can't do image
|
|
1069 instance children yet as we might not have a containing
|
|
1070 window. */
|
|
1071 layout_update (image_instance, instantiator);
|
|
1072 }
|
|
1073
|
|
1074 static void
|
|
1075 layout_post_instantiate (Lisp_Object image_instance, Lisp_Object instantiator,
|
|
1076 Lisp_Object domain)
|
|
1077 {
|
428
|
1078 }
|
|
1079
|
440
|
1080 /* Layout widget. Sizing commentary: we have a number of problems that
|
|
1081 we would like to address. Some consider some of these more
|
|
1082 important than others. It used to be that size information was
|
|
1083 determined at instantiation time and was then fixed forever
|
434
|
1084 after. Generally this is not what we want. Users want size to be
|
|
1085 "big enough" to accommodate whatever they are trying to show and
|
|
1086 this is dependent on text length, lines, font metrics etc. Of
|
|
1087 course these attributes can change dynamically and so the size
|
|
1088 should changed dynamically also. Only in a few limited cases should
|
|
1089 the size be fixed and remain fixed. Of course this actually means
|
442
|
1090 that we don't really want to specify the size *at all* for most
|
434
|
1091 widgets - we want it to be discovered dynamically. Thus we can
|
|
1092 envisage the following scenarios:
|
442
|
1093
|
434
|
1094 1. A button is sized to accommodate its text, the text changes and the
|
442
|
1095 button should change size also.
|
434
|
1096
|
|
1097 2. A button is given an explicit size. Its size should never change.
|
|
1098
|
|
1099 3. Layout is put inside an area. The size of the area changes, the
|
442
|
1100 layout should change with it.
|
434
|
1101
|
|
1102 4. A button grows to accommodate additional text. The whitespace
|
|
1103 around it should be modified to cope with the new layout
|
442
|
1104 requirements.
|
434
|
1105
|
|
1106 5. A button grows. The area surrounding it should grow also if
|
442
|
1107 possible.
|
434
|
1108
|
|
1109 What metrics are important?
|
|
1110 1. Actual width and height.
|
442
|
1111
|
434
|
1112 2. Whether the width and height are what the widget actually wants, or
|
442
|
1113 whether it can grow or shrink.
|
434
|
1114
|
|
1115 Text glyphs are particularly troublesome since their metrics depend
|
|
1116 on the context in which they are being viewed. For instance they
|
|
1117 can appear differently depending on the window face, frame face or
|
440
|
1118 glyph face. In order to simplify this text glyphs can now only have
|
|
1119 a glyph-face or image-instance face. All other glyphs are
|
|
1120 essentially fixed in appearance. Perhaps the problem is that text
|
|
1121 glyphs are cached on a device basis like most other glyphs. Instead
|
|
1122 they should be cached per-window and then the instance would be
|
|
1123 fixed and we wouldn't have to mess around with font metrics and the
|
|
1124 rest. */
|
|
1125
|
|
1126 /* Query the geometry of a layout widget. We assume that we can only
|
|
1127 get here if the size is not already fixed. */
|
428
|
1128 static void
|
442
|
1129 layout_query_geometry (Lisp_Object image_instance, int* width,
|
|
1130 int* height, enum image_instance_geometry disp,
|
440
|
1131 Lisp_Object domain)
|
428
|
1132 {
|
440
|
1133 Lisp_Image_Instance *ii = XIMAGE_INSTANCE (image_instance);
|
|
1134 Lisp_Object items = IMAGE_INSTANCE_LAYOUT_CHILDREN (ii), rest;
|
|
1135 int maxph = 0, maxpw = 0, nitems = 0, ph_adjust = 0;
|
442
|
1136 int gheight, gwidth;
|
|
1137
|
|
1138 /* If we are not initialized then we won't have any children. */
|
|
1139 if (!IMAGE_INSTANCE_INITIALIZED (ii))
|
|
1140 return;
|
|
1141
|
|
1142 /* First just set up what we already have. */
|
|
1143 if (width) *width = IMAGE_INSTANCE_WIDTH (ii);
|
|
1144 if (height) *height = IMAGE_INSTANCE_HEIGHT (ii);
|
|
1145
|
|
1146 /* If we are not allowed to dynamically size then return. */
|
|
1147 if (!IMAGE_INSTANCE_SUBWINDOW_V_RESIZEP (ii)
|
|
1148 &&
|
|
1149 !IMAGE_INSTANCE_SUBWINDOW_H_RESIZEP (ii))
|
|
1150 return;
|
|
1151
|
|
1152 /* Pick up the border text if we have one. */
|
|
1153 if (INTP (IMAGE_INSTANCE_LAYOUT_BORDER (ii)))
|
|
1154 {
|
|
1155 glyph_query_geometry (XCAR (items), &gwidth, &gheight, disp,
|
|
1156 image_instance);
|
|
1157 ph_adjust = gheight / 2;
|
|
1158 items = XCDR (items);
|
|
1159 }
|
440
|
1160
|
|
1161 /* Flip through the items to work out how much stuff we have to display */
|
|
1162 LIST_LOOP (rest, items)
|
|
1163 {
|
|
1164 Lisp_Object glyph = XCAR (rest);
|
442
|
1165 glyph_query_geometry (glyph, &gwidth, &gheight, disp, image_instance);
|
440
|
1166
|
442
|
1167 nitems ++;
|
|
1168 if (IMAGE_INSTANCE_SUBWINDOW_ORIENT (ii)
|
|
1169 == LAYOUT_HORIZONTAL)
|
440
|
1170 {
|
442
|
1171 maxph = max (maxph, gheight);
|
|
1172 maxpw += gwidth;
|
440
|
1173 }
|
|
1174 else
|
|
1175 {
|
442
|
1176 maxpw = max (maxpw, gwidth);
|
|
1177 maxph += gheight;
|
440
|
1178 }
|
|
1179 }
|
428
|
1180
|
442
|
1181 /* Work out minimum space we need to fit all the items. This could
|
|
1182 have been fixed by the user. */
|
|
1183 if (!NILP (IMAGE_INSTANCE_WIDGET_WIDTH_SUBR (ii)))
|
|
1184 {
|
|
1185 Lisp_Object dynamic_width =
|
|
1186 Feval (IMAGE_INSTANCE_WIDGET_WIDTH_SUBR (ii));
|
|
1187 if (INTP (dynamic_width))
|
|
1188 *width = XINT (dynamic_width);
|
|
1189 }
|
|
1190 else if (IMAGE_INSTANCE_SUBWINDOW_ORIENT (ii)
|
|
1191 == LAYOUT_HORIZONTAL)
|
|
1192 *width = maxpw + ((nitems + 1) * WIDGET_BORDER_WIDTH +
|
|
1193 IMAGE_INSTANCE_MARGIN_WIDTH (ii)) * 2;
|
|
1194 else
|
|
1195 *width = maxpw + 2 * (WIDGET_BORDER_WIDTH * 2 +
|
|
1196 IMAGE_INSTANCE_MARGIN_WIDTH (ii));
|
428
|
1197
|
440
|
1198 /* Work out vertical spacings. */
|
442
|
1199 if (!NILP (IMAGE_INSTANCE_WIDGET_HEIGHT_SUBR (ii)))
|
|
1200 {
|
|
1201 Lisp_Object dynamic_height =
|
|
1202 Feval (IMAGE_INSTANCE_WIDGET_HEIGHT_SUBR (ii));
|
|
1203 if (INTP (dynamic_height))
|
|
1204 *height = XINT (dynamic_height);
|
|
1205 }
|
|
1206 else if (IMAGE_INSTANCE_SUBWINDOW_ORIENT (ii)
|
|
1207 == LAYOUT_VERTICAL)
|
|
1208 *height = maxph + ((nitems + 1) * WIDGET_BORDER_HEIGHT +
|
|
1209 IMAGE_INSTANCE_MARGIN_WIDTH (ii)) * 2 + ph_adjust;
|
|
1210 else
|
|
1211 *height = maxph + (2 * WIDGET_BORDER_HEIGHT +
|
|
1212 IMAGE_INSTANCE_MARGIN_WIDTH (ii)) * 2 + ph_adjust;
|
440
|
1213 }
|
|
1214
|
442
|
1215 int
|
|
1216 layout_layout (Lisp_Object image_instance,
|
|
1217 int width, int height, int xoffset, int yoffset,
|
|
1218 Lisp_Object domain)
|
440
|
1219 {
|
|
1220 Lisp_Image_Instance *ii = XIMAGE_INSTANCE (image_instance);
|
|
1221 Lisp_Object rest;
|
|
1222 Lisp_Object items = IMAGE_INSTANCE_LAYOUT_CHILDREN (ii);
|
|
1223 int x, y, maxph = 0, maxpw = 0, nitems = 0,
|
|
1224 horiz_spacing, vert_spacing, ph_adjust = 0;
|
442
|
1225 int gheight, gwidth;
|
|
1226
|
|
1227 /* If we are not initialized then we won't have any children. */
|
|
1228 if (!IMAGE_INSTANCE_INITIALIZED (ii))
|
|
1229 return 0;
|
428
|
1230
|
442
|
1231 /* Pick up the border text if we have one. */
|
|
1232 if (INTP (IMAGE_INSTANCE_LAYOUT_BORDER (ii)))
|
|
1233 {
|
|
1234 Lisp_Object border = XCAR (items);
|
|
1235 items = XCDR (items);
|
|
1236 glyph_query_geometry (border, &gwidth, &gheight,
|
|
1237 IMAGE_DESIRED_GEOMETRY, image_instance);
|
|
1238 ph_adjust = gheight / 2;
|
|
1239 IMAGE_INSTANCE_LAYOUT_BORDER (ii) = make_int (ph_adjust);
|
|
1240
|
|
1241 /* #### Really, what should this be? */
|
|
1242 glyph_do_layout (border, gwidth, gheight, 10, 0,
|
|
1243 image_instance);
|
|
1244 }
|
|
1245
|
|
1246 /* Flip through the items to work out how much stuff we have to display. */
|
428
|
1247 LIST_LOOP (rest, items)
|
|
1248 {
|
|
1249 Lisp_Object glyph = XCAR (rest);
|
440
|
1250
|
442
|
1251 glyph_query_geometry (glyph, &gwidth, &gheight,
|
|
1252 IMAGE_DESIRED_GEOMETRY, image_instance);
|
|
1253 nitems ++;
|
|
1254 if (IMAGE_INSTANCE_SUBWINDOW_ORIENT (ii)
|
|
1255 == LAYOUT_HORIZONTAL)
|
428
|
1256 {
|
442
|
1257 maxph = max (maxph, gheight);
|
|
1258 maxpw += gwidth;
|
428
|
1259 }
|
440
|
1260 else
|
428
|
1261 {
|
442
|
1262 maxpw = max (maxpw, gwidth);
|
|
1263 maxph += gheight;
|
428
|
1264 }
|
|
1265 }
|
|
1266
|
|
1267 /* work out spacing between items and bounds of the layout */
|
440
|
1268 if (width < maxpw)
|
428
|
1269 /* The user wants a smaller space than the largest item, so we
|
|
1270 just provide default spacing and will let the output routines
|
|
1271 clip.. */
|
|
1272 horiz_spacing = WIDGET_BORDER_WIDTH * 2;
|
442
|
1273 else if (IMAGE_INSTANCE_SUBWINDOW_ORIENT (ii)
|
440
|
1274 == LAYOUT_HORIZONTAL)
|
428
|
1275 /* We have a larger area to display in so distribute the space
|
|
1276 evenly. */
|
442
|
1277 horiz_spacing = (width - (maxpw +
|
|
1278 IMAGE_INSTANCE_MARGIN_WIDTH (ii) * 2))
|
|
1279 / (nitems + 1);
|
428
|
1280 else
|
442
|
1281 horiz_spacing = (width - maxpw) / 2
|
|
1282 - IMAGE_INSTANCE_MARGIN_WIDTH (ii);
|
428
|
1283
|
440
|
1284 if (height < maxph)
|
428
|
1285 vert_spacing = WIDGET_BORDER_HEIGHT * 2;
|
442
|
1286 else if (IMAGE_INSTANCE_SUBWINDOW_ORIENT (ii)
|
440
|
1287 == LAYOUT_VERTICAL)
|
442
|
1288 vert_spacing = (height - (maxph + ph_adjust +
|
|
1289 IMAGE_INSTANCE_MARGIN_WIDTH (ii) * 2))
|
|
1290 / (nitems + 1);
|
428
|
1291 else
|
442
|
1292 vert_spacing = (height - (maxph + ph_adjust)) / 2
|
|
1293 - IMAGE_INSTANCE_MARGIN_WIDTH (ii);
|
428
|
1294
|
442
|
1295 y = vert_spacing + ph_adjust + IMAGE_INSTANCE_MARGIN_WIDTH (ii);
|
|
1296 x = horiz_spacing + IMAGE_INSTANCE_MARGIN_WIDTH (ii);
|
428
|
1297
|
|
1298 /* Now flip through putting items where we want them, paying
|
440
|
1299 attention to justification. Make sure we don't mess with the
|
|
1300 border glyph. */
|
428
|
1301 LIST_LOOP (rest, items)
|
|
1302 {
|
|
1303 Lisp_Object glyph = XCAR (rest);
|
|
1304
|
442
|
1305 glyph_query_geometry (glyph, &gwidth, &gheight,
|
|
1306 IMAGE_DESIRED_GEOMETRY, image_instance);
|
|
1307
|
|
1308 if (IMAGE_INSTANCE_SUBWINDOW_ORIENT (ii)
|
|
1309 == LAYOUT_HORIZONTAL)
|
|
1310 {
|
|
1311 if (IMAGE_INSTANCE_SUBWINDOW_JUSTIFY (ii)
|
|
1312 == LAYOUT_JUSTIFY_RIGHT)
|
|
1313 y = height - (gheight + vert_spacing);
|
|
1314 if (IMAGE_INSTANCE_SUBWINDOW_JUSTIFY (ii)
|
|
1315 == LAYOUT_JUSTIFY_CENTER)
|
|
1316 y = (height - gheight) / 2;
|
|
1317 }
|
|
1318 else
|
|
1319 {
|
|
1320 if (IMAGE_INSTANCE_SUBWINDOW_JUSTIFY (ii)
|
|
1321 == LAYOUT_JUSTIFY_RIGHT)
|
|
1322 x = width - (gwidth + horiz_spacing);
|
|
1323 if (IMAGE_INSTANCE_SUBWINDOW_JUSTIFY (ii)
|
|
1324 == LAYOUT_JUSTIFY_CENTER)
|
|
1325 x = (width - gwidth) / 2;
|
|
1326 }
|
|
1327
|
|
1328 /* Now layout subwidgets if they require it. */
|
|
1329 glyph_do_layout (glyph, gwidth, gheight, x, y, image_instance);
|
|
1330
|
|
1331 if (IMAGE_INSTANCE_SUBWINDOW_ORIENT (ii)
|
|
1332 == LAYOUT_HORIZONTAL)
|
|
1333 {
|
|
1334 x += (gwidth + horiz_spacing);
|
|
1335 }
|
|
1336 else
|
|
1337 {
|
|
1338 y += (gheight + vert_spacing);
|
|
1339 }
|
|
1340
|
|
1341 }
|
|
1342 return 1;
|
|
1343 }
|
|
1344
|
|
1345 /* Get the glyphs that comprise a layout. These are created internally
|
|
1346 and so are otherwise inaccessible to lisp. We need some way of getting
|
|
1347 properties from the widgets that comprise a layout and this is the
|
|
1348 simplest way of doing it.
|
428
|
1349
|
442
|
1350 #### Eventually we should allow some more intelligent access to
|
|
1351 sub-widgets. */
|
|
1352 static Lisp_Object
|
|
1353 layout_property (Lisp_Object image_instance, Lisp_Object prop)
|
|
1354 {
|
|
1355 /* This function can GC. */
|
|
1356 Lisp_Image_Instance *ii = XIMAGE_INSTANCE (image_instance);
|
|
1357 if (EQ (prop, Q_items))
|
|
1358 {
|
|
1359 if (INTP (IMAGE_INSTANCE_LAYOUT_BORDER (ii)) &&
|
|
1360 CONSP (IMAGE_INSTANCE_LAYOUT_CHILDREN (ii)))
|
|
1361 return Fcopy_sequence (XCDR
|
|
1362 (IMAGE_INSTANCE_LAYOUT_CHILDREN (ii)));
|
|
1363 else
|
|
1364 return Fcopy_sequence (IMAGE_INSTANCE_LAYOUT_CHILDREN (ii));
|
428
|
1365 }
|
442
|
1366 return Qunbound;
|
|
1367 }
|
428
|
1368
|
442
|
1369 /* Layout subwindows if they are real subwindows. */
|
|
1370 static int
|
|
1371 native_layout_layout (Lisp_Object image_instance,
|
|
1372 int width, int height, int xoffset, int yoffset,
|
|
1373 Lisp_Object domain)
|
|
1374 {
|
|
1375 Lisp_Image_Instance* ii = XIMAGE_INSTANCE (image_instance);
|
|
1376 Lisp_Object rest;
|
|
1377
|
|
1378 /* The first time this gets called, the layout will be only
|
|
1379 partially instantiated. The children get done in
|
|
1380 post_instantiate. */
|
|
1381 if (!IMAGE_INSTANCE_INITIALIZED (ii))
|
|
1382 return 0;
|
|
1383
|
|
1384 /* Defining this overrides the default layout_layout so we first have to call that to get
|
|
1385 suitable instances and values set up. */
|
|
1386 layout_layout (image_instance, width, height, xoffset, yoffset, domain);
|
|
1387
|
|
1388 LIST_LOOP (rest, IMAGE_INSTANCE_LAYOUT_CHILDREN (ii))
|
|
1389 {
|
|
1390 struct display_glyph_area dga;
|
|
1391 dga.xoffset = 0;
|
|
1392 dga.yoffset = 0;
|
|
1393 dga.width = IMAGE_INSTANCE_WIDTH (ii);
|
|
1394 dga.height = IMAGE_INSTANCE_HEIGHT (ii);
|
|
1395
|
|
1396 map_subwindow (XCAR (rest),
|
|
1397 IMAGE_INSTANCE_XOFFSET (ii),
|
|
1398 IMAGE_INSTANCE_YOFFSET (ii), &dga);
|
|
1399 }
|
|
1400 return 1;
|
428
|
1401 }
|
|
1402
|
|
1403
|
|
1404 /************************************************************************/
|
|
1405 /* initialization */
|
|
1406 /************************************************************************/
|
|
1407
|
|
1408 void
|
|
1409 syms_of_glyphs_widget (void)
|
|
1410 {
|
442
|
1411 DEFSYMBOL (Qetched_in);
|
|
1412 DEFSYMBOL (Qetched_out);
|
|
1413 DEFSYMBOL (Qbevel_in);
|
|
1414 DEFSYMBOL (Qbevel_out);
|
|
1415 DEFSYMBOL (Qmake_glyph);
|
428
|
1416 }
|
|
1417
|
442
|
1418 #define VALID_GUI_KEYWORDS(type) do { \
|
|
1419 IIFORMAT_VALID_NONCOPY_KEYWORD (type, Q_active, check_valid_anything); \
|
|
1420 IIFORMAT_VALID_KEYWORD (type, Q_suffix, check_valid_anything); \
|
|
1421 IIFORMAT_VALID_KEYWORD (type, Q_keys, check_valid_string); \
|
|
1422 IIFORMAT_VALID_KEYWORD (type, Q_style, check_valid_symbol); \
|
|
1423 IIFORMAT_VALID_NONCOPY_KEYWORD (type, Q_selected, check_valid_anything); \
|
|
1424 IIFORMAT_VALID_KEYWORD (type, Q_filter, check_valid_anything); \
|
|
1425 IIFORMAT_VALID_KEYWORD (type, Q_config, check_valid_symbol); \
|
|
1426 IIFORMAT_VALID_KEYWORD (type, Q_included, check_valid_anything); \
|
|
1427 IIFORMAT_VALID_KEYWORD (type, Q_initial_focus, check_valid_anything); \
|
|
1428 IIFORMAT_VALID_KEYWORD (type, Q_key_sequence, check_valid_string); \
|
|
1429 IIFORMAT_VALID_KEYWORD (type, Q_accelerator, check_valid_string); \
|
|
1430 IIFORMAT_VALID_KEYWORD (type, Q_label, check_valid_anything); \
|
|
1431 IIFORMAT_VALID_NONCOPY_KEYWORD (type, Q_callback, check_valid_callback); \
|
|
1432 IIFORMAT_VALID_NONCOPY_KEYWORD (type, Q_callback_ex, check_valid_callback); \
|
|
1433 IIFORMAT_VALID_NONCOPY_KEYWORD (type, Q_descriptor, \
|
|
1434 check_valid_string_or_vector); \
|
440
|
1435 } while (0)
|
428
|
1436
|
442
|
1437 #define VALID_WIDGET_KEYWORDS(type) do { \
|
|
1438 IIFORMAT_VALID_KEYWORD (type, Q_width, check_valid_int); \
|
|
1439 IIFORMAT_VALID_KEYWORD (type, Q_height, check_valid_int); \
|
|
1440 IIFORMAT_VALID_KEYWORD (type, Q_pixel_width, check_valid_int_or_function); \
|
|
1441 IIFORMAT_VALID_KEYWORD (type, Q_pixel_height, check_valid_int_or_function); \
|
|
1442 IIFORMAT_VALID_KEYWORD (type, Q_face, check_valid_face); \
|
440
|
1443 } while (0)
|
428
|
1444
|
440
|
1445
|
|
1446 static void image_instantiator_widget (void)
|
|
1447 { /* we only do this for properties */
|
428
|
1448 INITIALIZE_IMAGE_INSTANTIATOR_FORMAT_NO_SYM (widget, "widget");
|
|
1449 IIFORMAT_HAS_METHOD (widget, property);
|
442
|
1450 IIFORMAT_HAS_METHOD (widget, update);
|
438
|
1451 IIFORMAT_HAS_METHOD (widget, query_geometry);
|
|
1452 IIFORMAT_HAS_METHOD (widget, layout);
|
440
|
1453 }
|
428
|
1454
|
440
|
1455 static void image_instantiator_buttons (void)
|
|
1456 {
|
428
|
1457 INITIALIZE_IMAGE_INSTANTIATOR_FORMAT (button, "button");
|
|
1458 IIFORMAT_HAS_SHARED_METHOD (button, validate, widget);
|
|
1459 IIFORMAT_HAS_SHARED_METHOD (button, possible_dest_types, widget);
|
|
1460 IIFORMAT_HAS_SHARED_METHOD (button, instantiate, widget);
|
442
|
1461 IIFORMAT_HAS_SHARED_METHOD (button, post_instantiate, widget);
|
428
|
1462 IIFORMAT_HAS_SHARED_METHOD (button, normalize, widget);
|
442
|
1463 IIFORMAT_HAS_SHARED_METHOD (button, governing_domain, subwindow);
|
|
1464 IIFORMAT_HAS_METHOD (button, query_geometry);
|
440
|
1465 IIFORMAT_VALID_KEYWORD (button,
|
442
|
1466 Q_image, check_valid_instantiator);
|
428
|
1467 VALID_WIDGET_KEYWORDS (button);
|
|
1468 VALID_GUI_KEYWORDS (button);
|
440
|
1469 }
|
428
|
1470
|
440
|
1471 static void image_instantiator_edit_fields (void)
|
|
1472 {
|
428
|
1473 INITIALIZE_IMAGE_INSTANTIATOR_FORMAT (edit_field, "edit-field");
|
|
1474 IIFORMAT_HAS_SHARED_METHOD (edit_field, validate, widget);
|
|
1475 IIFORMAT_HAS_SHARED_METHOD (edit_field, possible_dest_types, widget);
|
|
1476 IIFORMAT_HAS_SHARED_METHOD (edit_field, instantiate, widget);
|
442
|
1477 IIFORMAT_HAS_SHARED_METHOD (edit_field, post_instantiate, widget);
|
|
1478 IIFORMAT_HAS_SHARED_METHOD (edit_field, governing_domain, subwindow);
|
428
|
1479 VALID_WIDGET_KEYWORDS (edit_field);
|
|
1480 VALID_GUI_KEYWORDS (edit_field);
|
440
|
1481 }
|
428
|
1482
|
440
|
1483 static void image_instantiator_combo_box (void)
|
|
1484 {
|
428
|
1485 INITIALIZE_IMAGE_INSTANTIATOR_FORMAT (combo_box, "combo-box");
|
|
1486 IIFORMAT_HAS_METHOD (combo_box, validate);
|
|
1487 IIFORMAT_HAS_SHARED_METHOD (combo_box, possible_dest_types, widget);
|
442
|
1488 IIFORMAT_HAS_SHARED_METHOD (combo_box, governing_domain, subwindow);
|
|
1489
|
428
|
1490 VALID_GUI_KEYWORDS (combo_box);
|
|
1491
|
|
1492 IIFORMAT_VALID_KEYWORD (combo_box, Q_width, check_valid_int);
|
|
1493 IIFORMAT_VALID_KEYWORD (combo_box, Q_height, check_valid_int);
|
442
|
1494 IIFORMAT_VALID_KEYWORD (combo_box, Q_pixel_width,
|
|
1495 check_valid_int_or_function);
|
428
|
1496 IIFORMAT_VALID_KEYWORD (combo_box, Q_face, check_valid_face);
|
442
|
1497 IIFORMAT_VALID_KEYWORD (combo_box, Q_items, check_valid_item_list);
|
440
|
1498 }
|
428
|
1499
|
440
|
1500 static void image_instantiator_scrollbar (void)
|
|
1501 {
|
428
|
1502 INITIALIZE_IMAGE_INSTANTIATOR_FORMAT (scrollbar, "scrollbar");
|
|
1503 IIFORMAT_HAS_SHARED_METHOD (scrollbar, validate, widget);
|
|
1504 IIFORMAT_HAS_SHARED_METHOD (scrollbar, possible_dest_types, widget);
|
|
1505 IIFORMAT_HAS_SHARED_METHOD (scrollbar, instantiate, widget);
|
442
|
1506 IIFORMAT_HAS_SHARED_METHOD (scrollbar, post_instantiate, widget);
|
|
1507 IIFORMAT_HAS_SHARED_METHOD (scrollbar, governing_domain, subwindow);
|
428
|
1508 VALID_GUI_KEYWORDS (scrollbar);
|
|
1509
|
442
|
1510 IIFORMAT_VALID_KEYWORD (scrollbar, Q_pixel_width,
|
|
1511 check_valid_int_or_function);
|
|
1512 IIFORMAT_VALID_KEYWORD (scrollbar, Q_pixel_height,
|
|
1513 check_valid_int_or_function);
|
428
|
1514 IIFORMAT_VALID_KEYWORD (scrollbar, Q_face, check_valid_face);
|
440
|
1515 }
|
428
|
1516
|
440
|
1517 static void image_instantiator_progress_guage (void)
|
|
1518 {
|
428
|
1519 INITIALIZE_IMAGE_INSTANTIATOR_FORMAT (progress_gauge, "progress-gauge");
|
|
1520 IIFORMAT_HAS_SHARED_METHOD (progress_gauge, validate, widget);
|
|
1521 IIFORMAT_HAS_SHARED_METHOD (progress_gauge, possible_dest_types, widget);
|
|
1522 IIFORMAT_HAS_SHARED_METHOD (progress_gauge, instantiate, widget);
|
442
|
1523 IIFORMAT_HAS_SHARED_METHOD (progress_gauge, post_instantiate, widget);
|
|
1524 IIFORMAT_HAS_SHARED_METHOD (progress_gauge, governing_domain, subwindow);
|
428
|
1525 VALID_WIDGET_KEYWORDS (progress_gauge);
|
|
1526 VALID_GUI_KEYWORDS (progress_gauge);
|
442
|
1527
|
|
1528 IIFORMAT_VALID_KEYWORD (progress_gauge, Q_value, check_valid_int);
|
440
|
1529 }
|
428
|
1530
|
440
|
1531 static void image_instantiator_tree_view (void)
|
|
1532 {
|
428
|
1533 INITIALIZE_IMAGE_INSTANTIATOR_FORMAT (tree_view, "tree-view");
|
|
1534 IIFORMAT_HAS_SHARED_METHOD (tree_view, validate, combo_box);
|
|
1535 IIFORMAT_HAS_SHARED_METHOD (tree_view, possible_dest_types, widget);
|
438
|
1536 IIFORMAT_HAS_SHARED_METHOD (tree_view, instantiate, widget);
|
442
|
1537 IIFORMAT_HAS_SHARED_METHOD (tree_view, post_instantiate, widget);
|
|
1538 IIFORMAT_HAS_SHARED_METHOD (tree_view, governing_domain, subwindow);
|
438
|
1539 IIFORMAT_HAS_METHOD (tree_view, query_geometry);
|
428
|
1540 VALID_WIDGET_KEYWORDS (tree_view);
|
|
1541 VALID_GUI_KEYWORDS (tree_view);
|
442
|
1542 IIFORMAT_VALID_KEYWORD (tree_view, Q_items, check_valid_item_list);
|
440
|
1543 }
|
428
|
1544
|
440
|
1545 static void image_instantiator_tab_control (void)
|
|
1546 {
|
428
|
1547 INITIALIZE_IMAGE_INSTANTIATOR_FORMAT (tab_control, "tab-control");
|
|
1548 IIFORMAT_HAS_SHARED_METHOD (tab_control, validate, combo_box);
|
|
1549 IIFORMAT_HAS_SHARED_METHOD (tab_control, possible_dest_types, widget);
|
438
|
1550 IIFORMAT_HAS_SHARED_METHOD (tab_control, instantiate, widget);
|
442
|
1551 IIFORMAT_HAS_SHARED_METHOD (tab_control, post_instantiate, widget);
|
|
1552 IIFORMAT_HAS_SHARED_METHOD (tab_control, governing_domain, subwindow);
|
438
|
1553 IIFORMAT_HAS_METHOD (tab_control, query_geometry);
|
428
|
1554 VALID_WIDGET_KEYWORDS (tab_control);
|
|
1555 VALID_GUI_KEYWORDS (tab_control);
|
442
|
1556 IIFORMAT_VALID_KEYWORD (tab_control, Q_orientation,
|
|
1557 check_valid_tab_orientation);
|
|
1558 IIFORMAT_VALID_KEYWORD (tab_control, Q_items, check_valid_item_list);
|
440
|
1559 }
|
428
|
1560
|
440
|
1561 static void image_instantiator_labels (void)
|
|
1562 {
|
428
|
1563 INITIALIZE_IMAGE_INSTANTIATOR_FORMAT (label, "label");
|
|
1564 IIFORMAT_HAS_SHARED_METHOD (label, possible_dest_types, widget);
|
438
|
1565 IIFORMAT_HAS_SHARED_METHOD (label, instantiate, widget);
|
442
|
1566 IIFORMAT_HAS_SHARED_METHOD (label, post_instantiate, widget);
|
|
1567 IIFORMAT_HAS_SHARED_METHOD (label, governing_domain, subwindow);
|
428
|
1568 VALID_WIDGET_KEYWORDS (label);
|
|
1569 IIFORMAT_VALID_KEYWORD (label, Q_descriptor, check_valid_string);
|
440
|
1570 }
|
428
|
1571
|
442
|
1572 #define VALID_LAYOUT_KEYWORDS(layout) \
|
|
1573 VALID_WIDGET_KEYWORDS (layout); \
|
|
1574 IIFORMAT_VALID_KEYWORD (layout, Q_orientation, check_valid_orientation); \
|
|
1575 IIFORMAT_VALID_KEYWORD (layout, Q_justify, check_valid_justification); \
|
|
1576 IIFORMAT_VALID_KEYWORD (layout, Q_border, check_valid_border); \
|
|
1577 IIFORMAT_VALID_KEYWORD (layout, Q_margin_width, check_valid_int); \
|
|
1578 IIFORMAT_VALID_KEYWORD (layout, Q_items, \
|
|
1579 check_valid_instantiator_list)
|
|
1580
|
440
|
1581 static void image_instantiator_layout (void)
|
|
1582 {
|
428
|
1583 INITIALIZE_IMAGE_INSTANTIATOR_FORMAT (layout, "layout");
|
442
|
1584 IIFORMAT_HAS_SHARED_METHOD (layout, possible_dest_types, widget);
|
|
1585 IIFORMAT_HAS_METHOD (layout, instantiate);
|
|
1586 IIFORMAT_HAS_METHOD (layout, post_instantiate);
|
|
1587 IIFORMAT_HAS_SHARED_METHOD (layout, governing_domain, subwindow);
|
428
|
1588 IIFORMAT_HAS_METHOD (layout, normalize);
|
440
|
1589 IIFORMAT_HAS_METHOD (layout, query_geometry);
|
|
1590 IIFORMAT_HAS_METHOD (layout, layout);
|
442
|
1591 IIFORMAT_HAS_METHOD (layout, update);
|
|
1592 IIFORMAT_HAS_METHOD (layout, property);
|
|
1593
|
|
1594 VALID_GUI_KEYWORDS (layout);
|
|
1595 VALID_LAYOUT_KEYWORDS (layout);
|
|
1596 }
|
|
1597
|
|
1598 static void image_instantiator_native_layout (void)
|
|
1599 {
|
|
1600 INITIALIZE_IMAGE_INSTANTIATOR_FORMAT (native_layout, "native-layout");
|
|
1601 IIFORMAT_HAS_SHARED_METHOD (native_layout, possible_dest_types, widget);
|
|
1602 IIFORMAT_HAS_SHARED_METHOD (native_layout, instantiate, layout);
|
|
1603 IIFORMAT_HAS_SHARED_METHOD (native_layout, post_instantiate, layout);
|
|
1604 IIFORMAT_HAS_METHOD (native_layout, layout);
|
|
1605 IIFORMAT_HAS_SHARED_METHOD (native_layout, governing_domain, subwindow);
|
|
1606 IIFORMAT_HAS_SHARED_METHOD (native_layout, normalize, layout);
|
|
1607 IIFORMAT_HAS_SHARED_METHOD (native_layout, query_geometry, layout);
|
|
1608 IIFORMAT_HAS_SHARED_METHOD (native_layout, layout, layout);
|
|
1609 IIFORMAT_HAS_SHARED_METHOD (native_layout, property, layout);
|
|
1610
|
|
1611 VALID_GUI_KEYWORDS (native_layout);
|
|
1612 VALID_LAYOUT_KEYWORDS (native_layout);
|
428
|
1613 }
|
|
1614
|
|
1615 void
|
440
|
1616 image_instantiator_format_create_glyphs_widget (void)
|
|
1617 {
|
|
1618 image_instantiator_widget();
|
|
1619 image_instantiator_buttons();
|
|
1620 image_instantiator_edit_fields();
|
|
1621 image_instantiator_combo_box();
|
|
1622 image_instantiator_scrollbar();
|
|
1623 image_instantiator_progress_guage();
|
|
1624 image_instantiator_tree_view();
|
|
1625 image_instantiator_tab_control();
|
|
1626 image_instantiator_labels();
|
|
1627 image_instantiator_layout();
|
442
|
1628 image_instantiator_native_layout();
|
440
|
1629 }
|
|
1630
|
|
1631 void
|
428
|
1632 reinit_vars_of_glyphs_widget (void)
|
|
1633 {
|
|
1634 #ifdef DEBUG_WIDGETS
|
|
1635 debug_widget_instances = 0;
|
|
1636 #endif
|
|
1637 }
|
|
1638
|
|
1639 void
|
|
1640 vars_of_glyphs_widget (void)
|
|
1641 {
|
|
1642 reinit_vars_of_glyphs_widget ();
|
|
1643 }
|