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