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 {
|
853
|
509 dynamic_width =
|
|
510 eval_within_redisplay (IMAGE_INSTANCE_WIDGET_WIDTH_SUBR (ii));
|
442
|
511 if (INTP (dynamic_width))
|
|
512 *width = XINT (dynamic_width);
|
|
513 }
|
|
514 if (!NILP (IMAGE_INSTANCE_WIDGET_HEIGHT_SUBR (ii)))
|
|
515 {
|
853
|
516 dynamic_height =
|
|
517 eval_within_redisplay (IMAGE_INSTANCE_WIDGET_HEIGHT_SUBR (ii));
|
442
|
518 if (INTP (dynamic_height))
|
|
519 *height = XINT (dynamic_height);
|
|
520 }
|
438
|
521 }
|
|
522 }
|
|
523
|
442
|
524 static int
|
|
525 widget_layout (Lisp_Object image_instance,
|
|
526 int width, int height, int xoffset, int yoffset,
|
|
527 Lisp_Object domain)
|
438
|
528 {
|
440
|
529 Lisp_Image_Instance* ii = XIMAGE_INSTANCE (image_instance);
|
438
|
530 struct image_instantiator_methods* meths;
|
|
531
|
|
532 /* .. then try device specific methods ... */
|
442
|
533 meths = decode_device_ii_format (image_instance_device (image_instance),
|
|
534 IMAGE_INSTANCE_WIDGET_TYPE (ii),
|
438
|
535 ERROR_ME_NOT);
|
|
536 if (meths && HAS_IIFORMAT_METH_P (meths, layout))
|
442
|
537 return IIFORMAT_METH (meths, layout, (image_instance,
|
|
538 width, height, xoffset, yoffset,
|
|
539 domain));
|
438
|
540 else
|
|
541 {
|
|
542 /* ... then format specific methods ... */
|
442
|
543 meths = decode_device_ii_format (Qnil, IMAGE_INSTANCE_WIDGET_TYPE (ii),
|
438
|
544 ERROR_ME_NOT);
|
|
545 if (meths && HAS_IIFORMAT_METH_P (meths, layout))
|
442
|
546 return IIFORMAT_METH (meths, layout, (image_instance,
|
|
547 width, height, xoffset, yoffset,
|
|
548 domain));
|
438
|
549 }
|
442
|
550 return 1;
|
438
|
551 }
|
|
552
|
428
|
553 static void
|
|
554 widget_validate (Lisp_Object instantiator)
|
|
555 {
|
|
556 Lisp_Object desc = find_keyword_in_vector (instantiator, Q_descriptor);
|
|
557
|
|
558 if (NILP (desc))
|
563
|
559 invalid_argument ("Must supply :descriptor", instantiator);
|
428
|
560
|
|
561 if (VECTORP (desc))
|
|
562 gui_parse_item_keywords (desc);
|
|
563
|
|
564 if (!NILP (find_keyword_in_vector (instantiator, Q_width))
|
|
565 && !NILP (find_keyword_in_vector (instantiator, Q_pixel_width)))
|
563
|
566 invalid_argument ("Must supply only one of :width and :pixel-width", instantiator);
|
428
|
567
|
|
568 if (!NILP (find_keyword_in_vector (instantiator, Q_height))
|
|
569 && !NILP (find_keyword_in_vector (instantiator, Q_pixel_height)))
|
563
|
570 invalid_argument ("Must supply only one of :height and :pixel-height", instantiator);
|
428
|
571 }
|
|
572
|
|
573 static void
|
|
574 combo_box_validate (Lisp_Object instantiator)
|
|
575 {
|
|
576 widget_validate (instantiator);
|
442
|
577 if (NILP (find_keyword_in_vector (instantiator, Q_items)))
|
563
|
578 invalid_argument ("Must supply item list", instantiator);
|
428
|
579 }
|
|
580
|
|
581 /* we need to convert things like glyphs to images, eval expressions
|
|
582 etc.*/
|
|
583 static Lisp_Object
|
442
|
584 widget_normalize (Lisp_Object inst, Lisp_Object console_type,
|
|
585 Lisp_Object dest_mask)
|
428
|
586 {
|
|
587 /* This function can call lisp */
|
|
588 Lisp_Object glyph = find_keyword_in_vector (inst, Q_image);
|
|
589
|
|
590 /* we need to eval glyph if its an expression, we do this for the
|
442
|
591 same reasons we normalize file to data.
|
|
592
|
|
593 #### should just normalize the data. */
|
428
|
594 if (!NILP (glyph))
|
|
595 {
|
|
596 substitute_keyword_value (inst, Q_image, glyph_instantiator_to_glyph (glyph));
|
|
597 }
|
|
598
|
|
599 return inst;
|
|
600 }
|
|
601
|
|
602 static void
|
440
|
603 initialize_widget_image_instance (Lisp_Image_Instance *ii, Lisp_Object type)
|
428
|
604 {
|
|
605 /* initialize_subwindow_image_instance (ii);*/
|
|
606 IMAGE_INSTANCE_WIDGET_TYPE (ii) = type;
|
|
607 IMAGE_INSTANCE_WIDGET_PROPS (ii) = Qnil;
|
438
|
608 SET_IMAGE_INSTANCE_WIDGET_FACE (ii, Qnil);
|
428
|
609 IMAGE_INSTANCE_WIDGET_ITEMS (ii) = allocate_gui_item ();
|
442
|
610 IMAGE_INSTANCE_LAYOUT_CHILDREN (ii) = Qnil;
|
|
611 IMAGE_INSTANCE_WIDGET_PENDING_ITEMS (ii) = Qnil;
|
|
612 IMAGE_INSTANCE_WIDGET_WIDTH_SUBR (ii) = Qnil;
|
|
613 IMAGE_INSTANCE_WIDGET_HEIGHT_SUBR (ii) = Qnil;
|
438
|
614 IMAGE_INSTANCE_SUBWINDOW_H_RESIZEP (ii) = 1;
|
|
615 IMAGE_INSTANCE_SUBWINDOW_V_RESIZEP (ii) = 1;
|
442
|
616 IMAGE_INSTANCE_SUBWINDOW_ORIENT (ii) = LAYOUT_HORIZONTAL;
|
438
|
617 IMAGE_INSTANCE_SUBWINDOW_JUSTIFY (ii) = 0;
|
428
|
618 }
|
|
619
|
|
620 /* Instantiate a button widget. Unfortunately instantiated widgets are
|
|
621 particular to a frame since they need to have a parent. It's not
|
|
622 like images where you just select the image into the context you
|
|
623 want to display it in and BitBlt it. So image instances can have a
|
|
624 many-to-one relationship with things you see, whereas widgets can
|
|
625 only be one-to-one (i.e. per frame) */
|
|
626 void
|
438
|
627 widget_instantiate (Lisp_Object image_instance, Lisp_Object instantiator,
|
|
628 Lisp_Object pointer_fg, Lisp_Object pointer_bg,
|
|
629 int dest_mask, Lisp_Object domain)
|
428
|
630 {
|
442
|
631 /* #### practically all of this should be moved to widget_update()
|
|
632 so that users can dynamically change all possible widget
|
|
633 properties. */
|
440
|
634 Lisp_Image_Instance *ii = XIMAGE_INSTANCE (image_instance);
|
428
|
635 Lisp_Object face = find_keyword_in_vector (instantiator, Q_face);
|
|
636 Lisp_Object height = find_keyword_in_vector (instantiator, Q_height);
|
|
637 Lisp_Object width = find_keyword_in_vector (instantiator, Q_width);
|
|
638 Lisp_Object pixwidth = find_keyword_in_vector (instantiator, Q_pixel_width);
|
|
639 Lisp_Object pixheight = find_keyword_in_vector (instantiator, Q_pixel_height);
|
|
640 Lisp_Object desc = find_keyword_in_vector (instantiator, Q_descriptor);
|
|
641 Lisp_Object glyph = find_keyword_in_vector (instantiator, Q_image);
|
440
|
642 Lisp_Object items = find_keyword_in_vector (instantiator, Q_items);
|
438
|
643 Lisp_Object orient = find_keyword_in_vector (instantiator, Q_orientation);
|
442
|
644 Lisp_Object mwidth = find_keyword_in_vector (instantiator, Q_margin_width);
|
|
645 Lisp_Object ifocus = find_keyword_in_vector (instantiator, Q_initial_focus);
|
428
|
646 int pw=0, ph=0, tw=0, th=0;
|
442
|
647
|
428
|
648 /* this just does pixel type sizing */
|
|
649 subwindow_instantiate (image_instance, instantiator, pointer_fg, pointer_bg,
|
|
650 dest_mask, domain);
|
|
651
|
442
|
652 if (!(dest_mask & IMAGE_WIDGET_MASK))
|
|
653 incompatible_image_types (instantiator, dest_mask, IMAGE_WIDGET_MASK);
|
428
|
654
|
|
655 initialize_widget_image_instance (ii, XVECTOR_DATA (instantiator)[0]);
|
|
656
|
440
|
657 IMAGE_INSTANCE_TYPE (ii) = IMAGE_WIDGET;
|
|
658
|
428
|
659 /* retrieve the fg and bg colors */
|
|
660 if (!NILP (face))
|
438
|
661 SET_IMAGE_INSTANCE_WIDGET_FACE (ii, Fget_face (face));
|
428
|
662
|
454
|
663 /* Retrieve the gui item information. This is easy if we have been
|
428
|
664 provided with a vector, more difficult if we have just been given
|
454
|
665 keywords. Note that standard gui descriptor shortcuts will not work
|
|
666 because of keyword parsing.
|
|
667
|
|
668 #### This is bogus in that descriptor and items share the same slot,
|
|
669 we should rationalize. */
|
|
670 if (VECTORP (desc))
|
|
671 {
|
|
672 IMAGE_INSTANCE_WIDGET_ITEMS (ii) =
|
|
673 gui_parse_item_keywords_no_errors (desc);
|
|
674 }
|
|
675 else
|
428
|
676 {
|
|
677 /* big cheat - we rely on the fact that a gui item looks like an instantiator */
|
442
|
678 IMAGE_INSTANCE_WIDGET_ITEMS (ii) =
|
454
|
679 widget_gui_parse_item_keywords (instantiator);
|
428
|
680 }
|
|
681
|
440
|
682 /* Pick up the orientation before we do our first layout. */
|
|
683 if (EQ (orient, Qleft) || EQ (orient, Qright) || EQ (orient, Qvertical))
|
442
|
684 IMAGE_INSTANCE_SUBWINDOW_ORIENT (ii) = LAYOUT_VERTICAL;
|
440
|
685
|
428
|
686 /* parse more gui items out of the properties */
|
442
|
687 if (!NILP (items) && !EQ (IMAGE_INSTANCE_WIDGET_TYPE (ii), Qlayout)
|
|
688 && !EQ (IMAGE_INSTANCE_WIDGET_TYPE (ii), Qnative_layout))
|
428
|
689 {
|
442
|
690 IMAGE_INSTANCE_WIDGET_ITEMS (ii) =
|
|
691 Fcons (IMAGE_INSTANCE_WIDGET_ITEMS (ii),
|
|
692 parse_gui_item_tree_children (items));
|
428
|
693 }
|
|
694
|
438
|
695 /* Normalize size information. We now only assign sizes if the user
|
|
696 gives us some explicitly, or there are some constraints that we
|
|
697 can't change later on. Otherwise we postpone sizing until query
|
|
698 geometry gets called. */
|
|
699 if (!NILP (pixwidth)) /* pixwidth takes precendent */
|
|
700 {
|
442
|
701 if (!INTP (pixwidth))
|
|
702 IMAGE_INSTANCE_WIDGET_WIDTH_SUBR (ii) = pixwidth;
|
|
703 else
|
|
704 {
|
|
705 pw = XINT (pixwidth);
|
|
706 IMAGE_INSTANCE_SUBWINDOW_H_RESIZEP (ii) = 0;
|
|
707 }
|
438
|
708 }
|
|
709 else if (!NILP (width))
|
|
710 {
|
|
711 tw = XINT (width);
|
|
712 IMAGE_INSTANCE_SUBWINDOW_H_RESIZEP (ii) = 0;
|
|
713 }
|
|
714
|
428
|
715 if (!NILP (pixheight))
|
438
|
716 {
|
442
|
717 if (!INTP (pixheight))
|
|
718 IMAGE_INSTANCE_WIDGET_HEIGHT_SUBR (ii) = pixheight;
|
|
719 else
|
|
720 {
|
|
721 ph = XINT (pixheight);
|
|
722 IMAGE_INSTANCE_SUBWINDOW_V_RESIZEP (ii) = 0;
|
|
723 }
|
438
|
724 }
|
|
725 else if (!NILP (height) && XINT (height) > 1)
|
|
726 {
|
|
727 th = XINT (height);
|
|
728 IMAGE_INSTANCE_SUBWINDOW_V_RESIZEP (ii) = 0;
|
|
729 }
|
|
730
|
|
731 /* Taking the default face information when the user has specified
|
|
732 size in characters is probably as good as any since the widget
|
|
733 face is more likely to be proportional and thus give inadequate
|
|
734 results. Using character sizes can only ever be approximate
|
|
735 anyway. */
|
|
736 if (tw || th)
|
|
737 {
|
|
738 int charwidth, charheight;
|
|
739 default_face_font_info (domain, 0, 0, &charheight, &charwidth, 0);
|
|
740 if (tw)
|
|
741 pw = charwidth * tw;
|
|
742 if (th)
|
|
743 ph = charheight * th;
|
|
744 }
|
428
|
745
|
|
746 /* for a widget with an image pick up the dimensions from that */
|
|
747 if (!NILP (glyph))
|
|
748 {
|
438
|
749 if (!pw)
|
442
|
750 pw = glyph_width (glyph, image_instance) + 2 * WIDGET_BORDER_WIDTH;
|
438
|
751 if (!ph)
|
442
|
752 ph = glyph_height (glyph, image_instance) + 2 * WIDGET_BORDER_HEIGHT;
|
438
|
753 IMAGE_INSTANCE_SUBWINDOW_V_RESIZEP (ii) = 0;
|
|
754 IMAGE_INSTANCE_SUBWINDOW_H_RESIZEP (ii) = 0;
|
428
|
755 }
|
|
756
|
442
|
757 /* Pick up the margin width. */
|
|
758 if (!NILP (mwidth))
|
|
759 IMAGE_INSTANCE_MARGIN_WIDTH (ii) = XINT (mwidth);
|
|
760
|
|
761 IMAGE_INSTANCE_WANTS_INITIAL_FOCUS (ii) = !NILP (ifocus);
|
438
|
762
|
442
|
763 /* Layout for the layout widget is premature at this point since the
|
|
764 children will not have been instantiated. We can't instantiate
|
|
765 them until the device instantiation method for the layout has
|
|
766 been executed. We do however want to record any specified
|
|
767 dimensions. */
|
|
768 if (pw) IMAGE_INSTANCE_WIDTH (ii) = pw;
|
|
769 if (ph) IMAGE_INSTANCE_HEIGHT (ii) = ph;
|
|
770 }
|
|
771
|
|
772 static void
|
|
773 widget_post_instantiate (Lisp_Object image_instance, Lisp_Object instantiator,
|
|
774 Lisp_Object domain)
|
|
775 {
|
428
|
776 #ifdef DEBUG_WIDGETS
|
|
777 debug_widget_instances++;
|
|
778 stderr_out ("instantiated ");
|
|
779 debug_print (instantiator);
|
|
780 stderr_out ("%d widgets instantiated\n", debug_widget_instances);
|
|
781 #endif
|
|
782 }
|
|
783
|
442
|
784 /* Get the geometry of a button control. We need to adjust the size
|
|
785 depending on the type of button. */
|
|
786 static void
|
|
787 button_query_geometry (Lisp_Object image_instance,
|
|
788 int* width, int* height,
|
|
789 enum image_instance_geometry disp, Lisp_Object domain)
|
|
790 {
|
|
791 Lisp_Image_Instance *ii = XIMAGE_INSTANCE (image_instance);
|
|
792 int w, h;
|
771
|
793 widget_query_string_geometry (IMAGE_INSTANCE_WIDGET_TEXT (ii),
|
|
794 IMAGE_INSTANCE_WIDGET_FACE (ii),
|
|
795 &w, &h, domain);
|
442
|
796 /* Adjust the size for borders. */
|
|
797 if (IMAGE_INSTANCE_SUBWINDOW_H_RESIZEP (ii))
|
|
798 {
|
|
799 *width = w + 2 * WIDGET_BORDER_WIDTH;
|
|
800
|
|
801 if (EQ (XGUI_ITEM (IMAGE_INSTANCE_WIDGET_ITEM (ii))->style, Qradio)
|
|
802 ||
|
|
803 EQ (XGUI_ITEM (IMAGE_INSTANCE_WIDGET_ITEM (ii))->style, Qtoggle))
|
|
804 /* This is an approximation to the size of the actual button bit. */
|
|
805 *width += 12;
|
|
806 }
|
|
807 if (IMAGE_INSTANCE_SUBWINDOW_V_RESIZEP (ii))
|
|
808 *height = h + 2 * WIDGET_BORDER_HEIGHT;
|
|
809 }
|
|
810
|
438
|
811 /* tree-view geometry - get the height right */
|
428
|
812 static void
|
442
|
813 tree_view_query_geometry (Lisp_Object image_instance,
|
|
814 int* width, int* height,
|
438
|
815 enum image_instance_geometry disp, Lisp_Object domain)
|
428
|
816 {
|
440
|
817 Lisp_Image_Instance *ii = XIMAGE_INSTANCE (image_instance);
|
438
|
818 Lisp_Object items = IMAGE_INSTANCE_WIDGET_ITEMS (ii);
|
|
819
|
442
|
820
|
438
|
821 if (*width)
|
|
822 {
|
|
823 /* #### what should this be. reconsider when X has tree views. */
|
771
|
824 widget_query_string_geometry (IMAGE_INSTANCE_WIDGET_TEXT (ii),
|
|
825 IMAGE_INSTANCE_WIDGET_FACE (ii),
|
|
826 width, 0, domain);
|
438
|
827 }
|
|
828 if (*height)
|
|
829 {
|
|
830 int len, h;
|
|
831 default_face_font_info (domain, 0, 0, &h, 0, 0);
|
|
832 GET_LIST_LENGTH (items, len);
|
|
833 *height = len * h;
|
|
834 }
|
428
|
835 }
|
|
836
|
438
|
837 /* Get the geometry of a tab control. This is based on the number of
|
|
838 items and text therin in the tab control. */
|
428
|
839 static void
|
442
|
840 tab_control_query_geometry (Lisp_Object image_instance,
|
|
841 int* width, int* height,
|
438
|
842 enum image_instance_geometry disp, Lisp_Object domain)
|
428
|
843 {
|
440
|
844 Lisp_Image_Instance *ii = XIMAGE_INSTANCE (image_instance);
|
442
|
845 Lisp_Object items = XCDR (IMAGE_INSTANCE_WIDGET_ITEMS (ii));
|
428
|
846 Lisp_Object rest;
|
442
|
847 int tw = 0, th = 0;
|
428
|
848
|
438
|
849 LIST_LOOP (rest, items)
|
428
|
850 {
|
442
|
851 int h, w;
|
438
|
852
|
771
|
853 widget_query_string_geometry (XGUI_ITEM (XCAR (rest))->name,
|
|
854 IMAGE_INSTANCE_WIDGET_FACE (ii),
|
|
855 &w, &h, domain);
|
442
|
856 tw += 5 * WIDGET_BORDER_WIDTH; /* some bias */
|
438
|
857 tw += w;
|
|
858 th = max (th, h + 2 * WIDGET_BORDER_HEIGHT);
|
428
|
859 }
|
|
860
|
438
|
861 /* Fixup returned values depending on orientation. */
|
|
862 if (IMAGE_INSTANCE_SUBWINDOW_ORIENT (ii))
|
|
863 {
|
|
864 if (height) *height = tw;
|
|
865 if (width) *width = th;
|
|
866 }
|
|
867 else
|
|
868 {
|
|
869 if (height) *height = th;
|
|
870 if (width) *width = tw;
|
|
871 }
|
428
|
872 }
|
|
873
|
442
|
874 /* Determine whether only the order has changed for a tab. */
|
|
875 int tab_control_order_only_changed (Lisp_Object image_instance)
|
|
876 {
|
|
877 Lisp_Image_Instance *ii = XIMAGE_INSTANCE (image_instance);
|
|
878 int found = 0, len, pending_len;
|
|
879 Lisp_Object rest;
|
|
880
|
|
881 /* Degenerate case. */
|
|
882 if (NILP (IMAGE_INSTANCE_WIDGET_PENDING_ITEMS (ii)))
|
|
883 return 1;
|
|
884
|
|
885 /* See whether we just need a change in order. */
|
|
886 GET_LIST_LENGTH (IMAGE_INSTANCE_WIDGET_ITEMS (ii), len);
|
|
887 GET_LIST_LENGTH (IMAGE_INSTANCE_WIDGET_PENDING_ITEMS (ii),
|
|
888 pending_len);
|
|
889 if (len == pending_len)
|
|
890 {
|
|
891 LIST_LOOP (rest, XCDR (IMAGE_INSTANCE_WIDGET_ITEMS (ii)))
|
|
892 {
|
|
893 Lisp_Object pending_rest;
|
|
894 found = 0;
|
|
895 LIST_LOOP (pending_rest,
|
|
896 XCDR (IMAGE_INSTANCE_WIDGET_PENDING_ITEMS (ii)))
|
|
897 {
|
|
898 if (gui_item_equal_sans_selected (XCAR (rest),
|
|
899 XCAR (pending_rest), 0))
|
|
900 {
|
|
901 found = 1;
|
|
902 break;
|
|
903 }
|
|
904 }
|
|
905 if (!found)
|
|
906 break;
|
|
907 }
|
|
908 }
|
|
909 return found;
|
|
910 }
|
|
911
|
428
|
912
|
|
913 /*****************************************************************************
|
|
914 * widget layout *
|
|
915 *****************************************************************************/
|
442
|
916 /* We need to cascade normalization.*/
|
428
|
917 static Lisp_Object
|
442
|
918 layout_normalize (Lisp_Object inst, Lisp_Object console_type,
|
|
919 Lisp_Object dest_mask)
|
428
|
920 {
|
|
921 /* This function can call lisp */
|
442
|
922 struct gcpro gcpro1, gcpro2;
|
|
923 Lisp_Object alist = Qnil, new_items = Qnil, border;
|
|
924 /* This function can call lisp */
|
|
925 Lisp_Object items;
|
|
926
|
|
927 GCPRO2 (alist, new_items);
|
|
928 alist = tagged_vector_to_alist (inst);
|
|
929 items = assq_no_quit (Q_items, alist);
|
|
930
|
|
931 /* We need to normalize sub-objects. */
|
428
|
932 if (!NILP (items))
|
|
933 {
|
|
934 Lisp_Object rest;
|
442
|
935 LIST_LOOP (rest, XCDR (items))
|
428
|
936 {
|
442
|
937 /* Substitute the new instantiator */
|
|
938 new_items = Fcons (normalize_image_instantiator (XCAR (rest),
|
|
939 console_type, dest_mask),
|
|
940 new_items);
|
|
941 }
|
|
942 new_items = Fnreverse (new_items);
|
|
943 Fsetcdr (items, new_items);
|
|
944 }
|
|
945 /* Normalize the border spec. */
|
|
946 border = assq_no_quit (Q_border, alist);
|
|
947 if (!NILP (border) && VECTORP (XCDR (border)))
|
|
948 {
|
|
949 Fsetcdr (border, normalize_image_instantiator (XCDR (border),
|
|
950 console_type, dest_mask));
|
|
951 }
|
|
952
|
|
953 {
|
|
954 Lisp_Object result = alist_to_tagged_vector (XVECTOR_DATA (inst)[0],
|
|
955 alist);
|
|
956 free_alist (alist);
|
|
957 RETURN_UNGCPRO (result);
|
|
958 }
|
|
959 }
|
|
960
|
|
961 /* Update the instances in the layout. */
|
|
962 static void
|
|
963 layout_update (Lisp_Object image_instance, Lisp_Object instantiator)
|
|
964 {
|
|
965 Lisp_Image_Instance *ii = XIMAGE_INSTANCE (image_instance);
|
|
966 Lisp_Object items = find_keyword_in_vector (instantiator, Q_items);
|
|
967 Lisp_Object border_inst = find_keyword_in_vector (instantiator, Q_border);
|
|
968 Lisp_Object border = Qnil;
|
|
969 Lisp_Object children = IMAGE_INSTANCE_LAYOUT_CHILDREN (ii);
|
|
970 int structure_changed = 0;
|
|
971 struct gcpro gcpro1;
|
|
972
|
|
973 /* We want to avoid consing if we can. This is quite awkward because
|
|
974 we have to deal with the border as well as the items. */
|
|
975
|
|
976 GCPRO1 (border);
|
|
977
|
|
978 if (INTP (IMAGE_INSTANCE_LAYOUT_BORDER (ii)))
|
|
979 {
|
|
980 border = XCAR (children);
|
|
981 children = XCDR (children);
|
|
982 }
|
|
983
|
|
984 #ifdef DEBUG_WIDGET_OUTPUT
|
|
985 stderr_out ("layout updated\n");
|
|
986 #endif
|
|
987 /* Update the border. */
|
|
988 if (!NILP (border_inst))
|
|
989 {
|
|
990 if (VECTORP (border_inst))
|
|
991 {
|
|
992 /* We are going to be sneaky here and add the border text as
|
|
993 just another child, the layout and output routines don't know
|
|
994 this and will just display at the offsets we prescribe. */
|
|
995 if (!NILP (border))
|
|
996 call3 (Qset_glyph_image, border, border_inst,
|
|
997 IMAGE_INSTANCE_DOMAIN (ii));
|
|
998 else
|
|
999 {
|
|
1000 border = Fcons (call1 (Qmake_glyph, border_inst), Qnil);
|
|
1001 structure_changed = 1;
|
|
1002 }
|
|
1003 IMAGE_INSTANCE_LAYOUT_BORDER (ii) = make_int (0);
|
|
1004 }
|
|
1005 else
|
|
1006 {
|
|
1007 if (!NILP (border))
|
|
1008 {
|
|
1009 border = Qnil;
|
|
1010 structure_changed = 1;
|
|
1011 }
|
|
1012 if (EQ (border_inst, Qt))
|
|
1013 IMAGE_INSTANCE_LAYOUT_BORDER (ii) = Qetched_in;
|
|
1014 else
|
|
1015 IMAGE_INSTANCE_LAYOUT_BORDER (ii) = border_inst;
|
428
|
1016 }
|
|
1017 }
|
442
|
1018
|
|
1019 /* Pick up the sub-widgets. */
|
|
1020 if (!NILP (items))
|
428
|
1021 {
|
442
|
1022 int len1, len2;
|
|
1023 GET_LIST_LENGTH (items, len1);
|
|
1024 GET_LIST_LENGTH (children, len2);
|
|
1025 /* The structure hasn't changed so just update the images. */
|
|
1026 if (!structure_changed && len1 == len2)
|
|
1027 {
|
|
1028 /* Pick up the sub-widgets. */
|
|
1029 for (; !NILP (children); children = XCDR (children), items = XCDR (items))
|
|
1030 {
|
|
1031 call3 (Qset_glyph_image, XCAR (children), XCAR (items),
|
|
1032 IMAGE_INSTANCE_DOMAIN (ii));
|
|
1033 }
|
|
1034 }
|
|
1035 /* The structure has changed so start over. */
|
|
1036 else
|
|
1037 {
|
|
1038 /* Instantiate any new glyphs. */
|
|
1039 for (; !NILP (items); items = XCDR (items))
|
|
1040 {
|
458
|
1041 /* #### We really want to use call_with_suspended_errors
|
|
1042 here, but it won't allow us to call lisp. */
|
442
|
1043 border = Fcons (call1 (Qmake_glyph, XCAR (items)), border);
|
|
1044 }
|
|
1045 IMAGE_INSTANCE_LAYOUT_CHILDREN (ii) = Fnreverse (border);
|
|
1046 }
|
428
|
1047 }
|
442
|
1048 UNGCPRO;
|
|
1049 }
|
|
1050
|
|
1051 static void
|
|
1052 layout_instantiate (Lisp_Object image_instance, Lisp_Object instantiator,
|
|
1053 Lisp_Object pointer_fg, Lisp_Object pointer_bg,
|
|
1054 int dest_mask, Lisp_Object domain)
|
|
1055 {
|
|
1056 Lisp_Image_Instance *ii = XIMAGE_INSTANCE (image_instance);
|
|
1057 Lisp_Object orient = find_keyword_in_vector (instantiator, Q_orientation);
|
|
1058
|
|
1059 #ifdef DEBUG_WIDGET_OUTPUT
|
|
1060 stderr_out ("layout instantiated\n");
|
|
1061 #endif
|
|
1062 /* Do widget type instantiation first. */
|
|
1063 widget_instantiate (image_instance, instantiator, pointer_fg, pointer_bg,
|
|
1064 dest_mask, domain);
|
|
1065
|
|
1066 if (NILP (orient))
|
|
1067 {
|
|
1068 IMAGE_INSTANCE_SUBWINDOW_ORIENT (ii) = LAYOUT_VERTICAL;
|
|
1069 }
|
|
1070
|
|
1071 /* Get child glyphs and finish instantiation. We can't do image
|
|
1072 instance children yet as we might not have a containing
|
|
1073 window. */
|
|
1074 layout_update (image_instance, instantiator);
|
|
1075 }
|
|
1076
|
|
1077 static void
|
|
1078 layout_post_instantiate (Lisp_Object image_instance, Lisp_Object instantiator,
|
|
1079 Lisp_Object domain)
|
|
1080 {
|
428
|
1081 }
|
|
1082
|
440
|
1083 /* Layout widget. Sizing commentary: we have a number of problems that
|
|
1084 we would like to address. Some consider some of these more
|
|
1085 important than others. It used to be that size information was
|
|
1086 determined at instantiation time and was then fixed forever
|
434
|
1087 after. Generally this is not what we want. Users want size to be
|
|
1088 "big enough" to accommodate whatever they are trying to show and
|
|
1089 this is dependent on text length, lines, font metrics etc. Of
|
|
1090 course these attributes can change dynamically and so the size
|
|
1091 should changed dynamically also. Only in a few limited cases should
|
|
1092 the size be fixed and remain fixed. Of course this actually means
|
442
|
1093 that we don't really want to specify the size *at all* for most
|
434
|
1094 widgets - we want it to be discovered dynamically. Thus we can
|
|
1095 envisage the following scenarios:
|
442
|
1096
|
434
|
1097 1. A button is sized to accommodate its text, the text changes and the
|
442
|
1098 button should change size also.
|
434
|
1099
|
|
1100 2. A button is given an explicit size. Its size should never change.
|
|
1101
|
|
1102 3. Layout is put inside an area. The size of the area changes, the
|
442
|
1103 layout should change with it.
|
434
|
1104
|
|
1105 4. A button grows to accommodate additional text. The whitespace
|
|
1106 around it should be modified to cope with the new layout
|
442
|
1107 requirements.
|
434
|
1108
|
|
1109 5. A button grows. The area surrounding it should grow also if
|
442
|
1110 possible.
|
434
|
1111
|
|
1112 What metrics are important?
|
|
1113 1. Actual width and height.
|
442
|
1114
|
434
|
1115 2. Whether the width and height are what the widget actually wants, or
|
442
|
1116 whether it can grow or shrink.
|
434
|
1117
|
|
1118 Text glyphs are particularly troublesome since their metrics depend
|
|
1119 on the context in which they are being viewed. For instance they
|
|
1120 can appear differently depending on the window face, frame face or
|
440
|
1121 glyph face. In order to simplify this text glyphs can now only have
|
|
1122 a glyph-face or image-instance face. All other glyphs are
|
|
1123 essentially fixed in appearance. Perhaps the problem is that text
|
|
1124 glyphs are cached on a device basis like most other glyphs. Instead
|
|
1125 they should be cached per-window and then the instance would be
|
|
1126 fixed and we wouldn't have to mess around with font metrics and the
|
|
1127 rest. */
|
|
1128
|
|
1129 /* Query the geometry of a layout widget. We assume that we can only
|
|
1130 get here if the size is not already fixed. */
|
428
|
1131 static void
|
442
|
1132 layout_query_geometry (Lisp_Object image_instance, int* width,
|
|
1133 int* height, enum image_instance_geometry disp,
|
440
|
1134 Lisp_Object domain)
|
428
|
1135 {
|
440
|
1136 Lisp_Image_Instance *ii = XIMAGE_INSTANCE (image_instance);
|
|
1137 Lisp_Object items = IMAGE_INSTANCE_LAYOUT_CHILDREN (ii), rest;
|
|
1138 int maxph = 0, maxpw = 0, nitems = 0, ph_adjust = 0;
|
442
|
1139 int gheight, gwidth;
|
|
1140
|
|
1141 /* If we are not initialized then we won't have any children. */
|
|
1142 if (!IMAGE_INSTANCE_INITIALIZED (ii))
|
|
1143 return;
|
|
1144
|
|
1145 /* First just set up what we already have. */
|
|
1146 if (width) *width = IMAGE_INSTANCE_WIDTH (ii);
|
|
1147 if (height) *height = IMAGE_INSTANCE_HEIGHT (ii);
|
|
1148
|
|
1149 /* If we are not allowed to dynamically size then return. */
|
|
1150 if (!IMAGE_INSTANCE_SUBWINDOW_V_RESIZEP (ii)
|
|
1151 &&
|
|
1152 !IMAGE_INSTANCE_SUBWINDOW_H_RESIZEP (ii))
|
|
1153 return;
|
|
1154
|
|
1155 /* Pick up the border text if we have one. */
|
|
1156 if (INTP (IMAGE_INSTANCE_LAYOUT_BORDER (ii)))
|
|
1157 {
|
|
1158 glyph_query_geometry (XCAR (items), &gwidth, &gheight, disp,
|
|
1159 image_instance);
|
|
1160 ph_adjust = gheight / 2;
|
|
1161 items = XCDR (items);
|
|
1162 }
|
440
|
1163
|
|
1164 /* Flip through the items to work out how much stuff we have to display */
|
|
1165 LIST_LOOP (rest, items)
|
|
1166 {
|
|
1167 Lisp_Object glyph = XCAR (rest);
|
442
|
1168 glyph_query_geometry (glyph, &gwidth, &gheight, disp, image_instance);
|
440
|
1169
|
442
|
1170 nitems ++;
|
|
1171 if (IMAGE_INSTANCE_SUBWINDOW_ORIENT (ii)
|
|
1172 == LAYOUT_HORIZONTAL)
|
440
|
1173 {
|
442
|
1174 maxph = max (maxph, gheight);
|
|
1175 maxpw += gwidth;
|
440
|
1176 }
|
|
1177 else
|
|
1178 {
|
442
|
1179 maxpw = max (maxpw, gwidth);
|
|
1180 maxph += gheight;
|
440
|
1181 }
|
|
1182 }
|
428
|
1183
|
442
|
1184 /* Work out minimum space we need to fit all the items. This could
|
|
1185 have been fixed by the user. */
|
|
1186 if (!NILP (IMAGE_INSTANCE_WIDGET_WIDTH_SUBR (ii)))
|
|
1187 {
|
|
1188 Lisp_Object dynamic_width =
|
853
|
1189 eval_within_redisplay (IMAGE_INSTANCE_WIDGET_WIDTH_SUBR (ii));
|
442
|
1190 if (INTP (dynamic_width))
|
|
1191 *width = XINT (dynamic_width);
|
|
1192 }
|
|
1193 else if (IMAGE_INSTANCE_SUBWINDOW_ORIENT (ii)
|
|
1194 == LAYOUT_HORIZONTAL)
|
|
1195 *width = maxpw + ((nitems + 1) * WIDGET_BORDER_WIDTH +
|
|
1196 IMAGE_INSTANCE_MARGIN_WIDTH (ii)) * 2;
|
|
1197 else
|
|
1198 *width = maxpw + 2 * (WIDGET_BORDER_WIDTH * 2 +
|
|
1199 IMAGE_INSTANCE_MARGIN_WIDTH (ii));
|
428
|
1200
|
440
|
1201 /* Work out vertical spacings. */
|
442
|
1202 if (!NILP (IMAGE_INSTANCE_WIDGET_HEIGHT_SUBR (ii)))
|
|
1203 {
|
|
1204 Lisp_Object dynamic_height =
|
853
|
1205 eval_within_redisplay (IMAGE_INSTANCE_WIDGET_HEIGHT_SUBR (ii));
|
442
|
1206 if (INTP (dynamic_height))
|
|
1207 *height = XINT (dynamic_height);
|
|
1208 }
|
|
1209 else if (IMAGE_INSTANCE_SUBWINDOW_ORIENT (ii)
|
|
1210 == LAYOUT_VERTICAL)
|
|
1211 *height = maxph + ((nitems + 1) * WIDGET_BORDER_HEIGHT +
|
|
1212 IMAGE_INSTANCE_MARGIN_WIDTH (ii)) * 2 + ph_adjust;
|
|
1213 else
|
|
1214 *height = maxph + (2 * WIDGET_BORDER_HEIGHT +
|
|
1215 IMAGE_INSTANCE_MARGIN_WIDTH (ii)) * 2 + ph_adjust;
|
440
|
1216 }
|
|
1217
|
442
|
1218 int
|
|
1219 layout_layout (Lisp_Object image_instance,
|
|
1220 int width, int height, int xoffset, int yoffset,
|
|
1221 Lisp_Object domain)
|
440
|
1222 {
|
|
1223 Lisp_Image_Instance *ii = XIMAGE_INSTANCE (image_instance);
|
|
1224 Lisp_Object rest;
|
|
1225 Lisp_Object items = IMAGE_INSTANCE_LAYOUT_CHILDREN (ii);
|
|
1226 int x, y, maxph = 0, maxpw = 0, nitems = 0,
|
|
1227 horiz_spacing, vert_spacing, ph_adjust = 0;
|
442
|
1228 int gheight, gwidth;
|
|
1229
|
|
1230 /* If we are not initialized then we won't have any children. */
|
|
1231 if (!IMAGE_INSTANCE_INITIALIZED (ii))
|
|
1232 return 0;
|
428
|
1233
|
442
|
1234 /* Pick up the border text if we have one. */
|
|
1235 if (INTP (IMAGE_INSTANCE_LAYOUT_BORDER (ii)))
|
|
1236 {
|
|
1237 Lisp_Object border = XCAR (items);
|
|
1238 items = XCDR (items);
|
|
1239 glyph_query_geometry (border, &gwidth, &gheight,
|
|
1240 IMAGE_DESIRED_GEOMETRY, image_instance);
|
|
1241 ph_adjust = gheight / 2;
|
|
1242 IMAGE_INSTANCE_LAYOUT_BORDER (ii) = make_int (ph_adjust);
|
|
1243
|
|
1244 /* #### Really, what should this be? */
|
|
1245 glyph_do_layout (border, gwidth, gheight, 10, 0,
|
|
1246 image_instance);
|
|
1247 }
|
|
1248
|
|
1249 /* Flip through the items to work out how much stuff we have to display. */
|
428
|
1250 LIST_LOOP (rest, items)
|
|
1251 {
|
|
1252 Lisp_Object glyph = XCAR (rest);
|
440
|
1253
|
442
|
1254 glyph_query_geometry (glyph, &gwidth, &gheight,
|
|
1255 IMAGE_DESIRED_GEOMETRY, image_instance);
|
|
1256 nitems ++;
|
|
1257 if (IMAGE_INSTANCE_SUBWINDOW_ORIENT (ii)
|
|
1258 == LAYOUT_HORIZONTAL)
|
428
|
1259 {
|
442
|
1260 maxph = max (maxph, gheight);
|
|
1261 maxpw += gwidth;
|
428
|
1262 }
|
440
|
1263 else
|
428
|
1264 {
|
442
|
1265 maxpw = max (maxpw, gwidth);
|
|
1266 maxph += gheight;
|
428
|
1267 }
|
|
1268 }
|
|
1269
|
|
1270 /* work out spacing between items and bounds of the layout */
|
440
|
1271 if (width < maxpw)
|
428
|
1272 /* The user wants a smaller space than the largest item, so we
|
|
1273 just provide default spacing and will let the output routines
|
|
1274 clip.. */
|
|
1275 horiz_spacing = WIDGET_BORDER_WIDTH * 2;
|
442
|
1276 else if (IMAGE_INSTANCE_SUBWINDOW_ORIENT (ii)
|
440
|
1277 == LAYOUT_HORIZONTAL)
|
428
|
1278 /* We have a larger area to display in so distribute the space
|
|
1279 evenly. */
|
442
|
1280 horiz_spacing = (width - (maxpw +
|
|
1281 IMAGE_INSTANCE_MARGIN_WIDTH (ii) * 2))
|
|
1282 / (nitems + 1);
|
428
|
1283 else
|
442
|
1284 horiz_spacing = (width - maxpw) / 2
|
|
1285 - IMAGE_INSTANCE_MARGIN_WIDTH (ii);
|
428
|
1286
|
440
|
1287 if (height < maxph)
|
428
|
1288 vert_spacing = WIDGET_BORDER_HEIGHT * 2;
|
442
|
1289 else if (IMAGE_INSTANCE_SUBWINDOW_ORIENT (ii)
|
440
|
1290 == LAYOUT_VERTICAL)
|
442
|
1291 vert_spacing = (height - (maxph + ph_adjust +
|
|
1292 IMAGE_INSTANCE_MARGIN_WIDTH (ii) * 2))
|
|
1293 / (nitems + 1);
|
428
|
1294 else
|
442
|
1295 vert_spacing = (height - (maxph + ph_adjust)) / 2
|
|
1296 - IMAGE_INSTANCE_MARGIN_WIDTH (ii);
|
428
|
1297
|
442
|
1298 y = vert_spacing + ph_adjust + IMAGE_INSTANCE_MARGIN_WIDTH (ii);
|
|
1299 x = horiz_spacing + IMAGE_INSTANCE_MARGIN_WIDTH (ii);
|
428
|
1300
|
|
1301 /* Now flip through putting items where we want them, paying
|
440
|
1302 attention to justification. Make sure we don't mess with the
|
|
1303 border glyph. */
|
428
|
1304 LIST_LOOP (rest, items)
|
|
1305 {
|
|
1306 Lisp_Object glyph = XCAR (rest);
|
|
1307
|
442
|
1308 glyph_query_geometry (glyph, &gwidth, &gheight,
|
|
1309 IMAGE_DESIRED_GEOMETRY, image_instance);
|
|
1310
|
|
1311 if (IMAGE_INSTANCE_SUBWINDOW_ORIENT (ii)
|
|
1312 == LAYOUT_HORIZONTAL)
|
|
1313 {
|
|
1314 if (IMAGE_INSTANCE_SUBWINDOW_JUSTIFY (ii)
|
|
1315 == LAYOUT_JUSTIFY_RIGHT)
|
|
1316 y = height - (gheight + vert_spacing);
|
|
1317 if (IMAGE_INSTANCE_SUBWINDOW_JUSTIFY (ii)
|
|
1318 == LAYOUT_JUSTIFY_CENTER)
|
|
1319 y = (height - gheight) / 2;
|
|
1320 }
|
|
1321 else
|
|
1322 {
|
|
1323 if (IMAGE_INSTANCE_SUBWINDOW_JUSTIFY (ii)
|
|
1324 == LAYOUT_JUSTIFY_RIGHT)
|
|
1325 x = width - (gwidth + horiz_spacing);
|
|
1326 if (IMAGE_INSTANCE_SUBWINDOW_JUSTIFY (ii)
|
|
1327 == LAYOUT_JUSTIFY_CENTER)
|
|
1328 x = (width - gwidth) / 2;
|
|
1329 }
|
|
1330
|
|
1331 /* Now layout subwidgets if they require it. */
|
|
1332 glyph_do_layout (glyph, gwidth, gheight, x, y, image_instance);
|
|
1333
|
|
1334 if (IMAGE_INSTANCE_SUBWINDOW_ORIENT (ii)
|
|
1335 == LAYOUT_HORIZONTAL)
|
|
1336 {
|
|
1337 x += (gwidth + horiz_spacing);
|
|
1338 }
|
|
1339 else
|
|
1340 {
|
|
1341 y += (gheight + vert_spacing);
|
|
1342 }
|
|
1343
|
|
1344 }
|
|
1345 return 1;
|
|
1346 }
|
|
1347
|
|
1348 /* Get the glyphs that comprise a layout. These are created internally
|
|
1349 and so are otherwise inaccessible to lisp. We need some way of getting
|
|
1350 properties from the widgets that comprise a layout and this is the
|
|
1351 simplest way of doing it.
|
428
|
1352
|
442
|
1353 #### Eventually we should allow some more intelligent access to
|
|
1354 sub-widgets. */
|
|
1355 static Lisp_Object
|
|
1356 layout_property (Lisp_Object image_instance, Lisp_Object prop)
|
|
1357 {
|
|
1358 /* This function can GC. */
|
|
1359 Lisp_Image_Instance *ii = XIMAGE_INSTANCE (image_instance);
|
|
1360 if (EQ (prop, Q_items))
|
|
1361 {
|
|
1362 if (INTP (IMAGE_INSTANCE_LAYOUT_BORDER (ii)) &&
|
|
1363 CONSP (IMAGE_INSTANCE_LAYOUT_CHILDREN (ii)))
|
|
1364 return Fcopy_sequence (XCDR
|
|
1365 (IMAGE_INSTANCE_LAYOUT_CHILDREN (ii)));
|
|
1366 else
|
|
1367 return Fcopy_sequence (IMAGE_INSTANCE_LAYOUT_CHILDREN (ii));
|
428
|
1368 }
|
442
|
1369 return Qunbound;
|
|
1370 }
|
428
|
1371
|
442
|
1372 /* Layout subwindows if they are real subwindows. */
|
|
1373 static int
|
|
1374 native_layout_layout (Lisp_Object image_instance,
|
|
1375 int width, int height, int xoffset, int yoffset,
|
|
1376 Lisp_Object domain)
|
|
1377 {
|
|
1378 Lisp_Image_Instance* ii = XIMAGE_INSTANCE (image_instance);
|
|
1379 Lisp_Object rest;
|
|
1380
|
|
1381 /* The first time this gets called, the layout will be only
|
|
1382 partially instantiated. The children get done in
|
|
1383 post_instantiate. */
|
|
1384 if (!IMAGE_INSTANCE_INITIALIZED (ii))
|
|
1385 return 0;
|
|
1386
|
|
1387 /* Defining this overrides the default layout_layout so we first have to call that to get
|
|
1388 suitable instances and values set up. */
|
|
1389 layout_layout (image_instance, width, height, xoffset, yoffset, domain);
|
|
1390
|
|
1391 LIST_LOOP (rest, IMAGE_INSTANCE_LAYOUT_CHILDREN (ii))
|
|
1392 {
|
|
1393 struct display_glyph_area dga;
|
|
1394 dga.xoffset = 0;
|
|
1395 dga.yoffset = 0;
|
|
1396 dga.width = IMAGE_INSTANCE_WIDTH (ii);
|
|
1397 dga.height = IMAGE_INSTANCE_HEIGHT (ii);
|
|
1398
|
|
1399 map_subwindow (XCAR (rest),
|
|
1400 IMAGE_INSTANCE_XOFFSET (ii),
|
|
1401 IMAGE_INSTANCE_YOFFSET (ii), &dga);
|
|
1402 }
|
|
1403 return 1;
|
428
|
1404 }
|
|
1405
|
|
1406
|
|
1407 /************************************************************************/
|
|
1408 /* initialization */
|
|
1409 /************************************************************************/
|
|
1410
|
|
1411 void
|
|
1412 syms_of_glyphs_widget (void)
|
|
1413 {
|
442
|
1414 DEFSYMBOL (Qetched_in);
|
|
1415 DEFSYMBOL (Qetched_out);
|
|
1416 DEFSYMBOL (Qbevel_in);
|
|
1417 DEFSYMBOL (Qbevel_out);
|
|
1418 DEFSYMBOL (Qmake_glyph);
|
428
|
1419 }
|
|
1420
|
442
|
1421 #define VALID_GUI_KEYWORDS(type) do { \
|
|
1422 IIFORMAT_VALID_NONCOPY_KEYWORD (type, Q_active, check_valid_anything); \
|
|
1423 IIFORMAT_VALID_KEYWORD (type, Q_suffix, check_valid_anything); \
|
|
1424 IIFORMAT_VALID_KEYWORD (type, Q_keys, check_valid_string); \
|
|
1425 IIFORMAT_VALID_KEYWORD (type, Q_style, check_valid_symbol); \
|
|
1426 IIFORMAT_VALID_NONCOPY_KEYWORD (type, Q_selected, check_valid_anything); \
|
|
1427 IIFORMAT_VALID_KEYWORD (type, Q_filter, check_valid_anything); \
|
|
1428 IIFORMAT_VALID_KEYWORD (type, Q_config, check_valid_symbol); \
|
|
1429 IIFORMAT_VALID_KEYWORD (type, Q_included, check_valid_anything); \
|
|
1430 IIFORMAT_VALID_KEYWORD (type, Q_initial_focus, check_valid_anything); \
|
|
1431 IIFORMAT_VALID_KEYWORD (type, Q_key_sequence, check_valid_string); \
|
|
1432 IIFORMAT_VALID_KEYWORD (type, Q_accelerator, check_valid_string); \
|
|
1433 IIFORMAT_VALID_KEYWORD (type, Q_label, check_valid_anything); \
|
|
1434 IIFORMAT_VALID_NONCOPY_KEYWORD (type, Q_callback, check_valid_callback); \
|
|
1435 IIFORMAT_VALID_NONCOPY_KEYWORD (type, Q_callback_ex, check_valid_callback); \
|
|
1436 IIFORMAT_VALID_NONCOPY_KEYWORD (type, Q_descriptor, \
|
|
1437 check_valid_string_or_vector); \
|
440
|
1438 } while (0)
|
428
|
1439
|
442
|
1440 #define VALID_WIDGET_KEYWORDS(type) do { \
|
|
1441 IIFORMAT_VALID_KEYWORD (type, Q_width, check_valid_int); \
|
|
1442 IIFORMAT_VALID_KEYWORD (type, Q_height, check_valid_int); \
|
|
1443 IIFORMAT_VALID_KEYWORD (type, Q_pixel_width, check_valid_int_or_function); \
|
|
1444 IIFORMAT_VALID_KEYWORD (type, Q_pixel_height, check_valid_int_or_function); \
|
|
1445 IIFORMAT_VALID_KEYWORD (type, Q_face, check_valid_face); \
|
440
|
1446 } while (0)
|
428
|
1447
|
440
|
1448
|
|
1449 static void image_instantiator_widget (void)
|
|
1450 { /* we only do this for properties */
|
428
|
1451 INITIALIZE_IMAGE_INSTANTIATOR_FORMAT_NO_SYM (widget, "widget");
|
|
1452 IIFORMAT_HAS_METHOD (widget, property);
|
442
|
1453 IIFORMAT_HAS_METHOD (widget, update);
|
438
|
1454 IIFORMAT_HAS_METHOD (widget, query_geometry);
|
|
1455 IIFORMAT_HAS_METHOD (widget, layout);
|
440
|
1456 }
|
428
|
1457
|
440
|
1458 static void image_instantiator_buttons (void)
|
|
1459 {
|
428
|
1460 INITIALIZE_IMAGE_INSTANTIATOR_FORMAT (button, "button");
|
|
1461 IIFORMAT_HAS_SHARED_METHOD (button, validate, widget);
|
|
1462 IIFORMAT_HAS_SHARED_METHOD (button, possible_dest_types, widget);
|
|
1463 IIFORMAT_HAS_SHARED_METHOD (button, instantiate, widget);
|
442
|
1464 IIFORMAT_HAS_SHARED_METHOD (button, post_instantiate, widget);
|
428
|
1465 IIFORMAT_HAS_SHARED_METHOD (button, normalize, widget);
|
442
|
1466 IIFORMAT_HAS_SHARED_METHOD (button, governing_domain, subwindow);
|
|
1467 IIFORMAT_HAS_METHOD (button, query_geometry);
|
440
|
1468 IIFORMAT_VALID_KEYWORD (button,
|
442
|
1469 Q_image, check_valid_instantiator);
|
428
|
1470 VALID_WIDGET_KEYWORDS (button);
|
|
1471 VALID_GUI_KEYWORDS (button);
|
440
|
1472 }
|
428
|
1473
|
440
|
1474 static void image_instantiator_edit_fields (void)
|
|
1475 {
|
428
|
1476 INITIALIZE_IMAGE_INSTANTIATOR_FORMAT (edit_field, "edit-field");
|
|
1477 IIFORMAT_HAS_SHARED_METHOD (edit_field, validate, widget);
|
|
1478 IIFORMAT_HAS_SHARED_METHOD (edit_field, possible_dest_types, widget);
|
|
1479 IIFORMAT_HAS_SHARED_METHOD (edit_field, instantiate, widget);
|
442
|
1480 IIFORMAT_HAS_SHARED_METHOD (edit_field, post_instantiate, widget);
|
|
1481 IIFORMAT_HAS_SHARED_METHOD (edit_field, governing_domain, subwindow);
|
428
|
1482 VALID_WIDGET_KEYWORDS (edit_field);
|
|
1483 VALID_GUI_KEYWORDS (edit_field);
|
440
|
1484 }
|
428
|
1485
|
440
|
1486 static void image_instantiator_combo_box (void)
|
|
1487 {
|
428
|
1488 INITIALIZE_IMAGE_INSTANTIATOR_FORMAT (combo_box, "combo-box");
|
|
1489 IIFORMAT_HAS_METHOD (combo_box, validate);
|
|
1490 IIFORMAT_HAS_SHARED_METHOD (combo_box, possible_dest_types, widget);
|
442
|
1491 IIFORMAT_HAS_SHARED_METHOD (combo_box, governing_domain, subwindow);
|
|
1492
|
428
|
1493 VALID_GUI_KEYWORDS (combo_box);
|
|
1494
|
|
1495 IIFORMAT_VALID_KEYWORD (combo_box, Q_width, check_valid_int);
|
|
1496 IIFORMAT_VALID_KEYWORD (combo_box, Q_height, check_valid_int);
|
442
|
1497 IIFORMAT_VALID_KEYWORD (combo_box, Q_pixel_width,
|
|
1498 check_valid_int_or_function);
|
428
|
1499 IIFORMAT_VALID_KEYWORD (combo_box, Q_face, check_valid_face);
|
442
|
1500 IIFORMAT_VALID_KEYWORD (combo_box, Q_items, check_valid_item_list);
|
440
|
1501 }
|
428
|
1502
|
440
|
1503 static void image_instantiator_scrollbar (void)
|
|
1504 {
|
428
|
1505 INITIALIZE_IMAGE_INSTANTIATOR_FORMAT (scrollbar, "scrollbar");
|
|
1506 IIFORMAT_HAS_SHARED_METHOD (scrollbar, validate, widget);
|
|
1507 IIFORMAT_HAS_SHARED_METHOD (scrollbar, possible_dest_types, widget);
|
|
1508 IIFORMAT_HAS_SHARED_METHOD (scrollbar, instantiate, widget);
|
442
|
1509 IIFORMAT_HAS_SHARED_METHOD (scrollbar, post_instantiate, widget);
|
|
1510 IIFORMAT_HAS_SHARED_METHOD (scrollbar, governing_domain, subwindow);
|
428
|
1511 VALID_GUI_KEYWORDS (scrollbar);
|
|
1512
|
442
|
1513 IIFORMAT_VALID_KEYWORD (scrollbar, Q_pixel_width,
|
|
1514 check_valid_int_or_function);
|
|
1515 IIFORMAT_VALID_KEYWORD (scrollbar, Q_pixel_height,
|
|
1516 check_valid_int_or_function);
|
428
|
1517 IIFORMAT_VALID_KEYWORD (scrollbar, Q_face, check_valid_face);
|
440
|
1518 }
|
428
|
1519
|
440
|
1520 static void image_instantiator_progress_guage (void)
|
|
1521 {
|
428
|
1522 INITIALIZE_IMAGE_INSTANTIATOR_FORMAT (progress_gauge, "progress-gauge");
|
|
1523 IIFORMAT_HAS_SHARED_METHOD (progress_gauge, validate, widget);
|
|
1524 IIFORMAT_HAS_SHARED_METHOD (progress_gauge, possible_dest_types, widget);
|
|
1525 IIFORMAT_HAS_SHARED_METHOD (progress_gauge, instantiate, widget);
|
442
|
1526 IIFORMAT_HAS_SHARED_METHOD (progress_gauge, post_instantiate, widget);
|
|
1527 IIFORMAT_HAS_SHARED_METHOD (progress_gauge, governing_domain, subwindow);
|
428
|
1528 VALID_WIDGET_KEYWORDS (progress_gauge);
|
|
1529 VALID_GUI_KEYWORDS (progress_gauge);
|
442
|
1530
|
|
1531 IIFORMAT_VALID_KEYWORD (progress_gauge, Q_value, check_valid_int);
|
440
|
1532 }
|
428
|
1533
|
440
|
1534 static void image_instantiator_tree_view (void)
|
|
1535 {
|
428
|
1536 INITIALIZE_IMAGE_INSTANTIATOR_FORMAT (tree_view, "tree-view");
|
|
1537 IIFORMAT_HAS_SHARED_METHOD (tree_view, validate, combo_box);
|
|
1538 IIFORMAT_HAS_SHARED_METHOD (tree_view, possible_dest_types, widget);
|
438
|
1539 IIFORMAT_HAS_SHARED_METHOD (tree_view, instantiate, widget);
|
442
|
1540 IIFORMAT_HAS_SHARED_METHOD (tree_view, post_instantiate, widget);
|
|
1541 IIFORMAT_HAS_SHARED_METHOD (tree_view, governing_domain, subwindow);
|
438
|
1542 IIFORMAT_HAS_METHOD (tree_view, query_geometry);
|
428
|
1543 VALID_WIDGET_KEYWORDS (tree_view);
|
|
1544 VALID_GUI_KEYWORDS (tree_view);
|
442
|
1545 IIFORMAT_VALID_KEYWORD (tree_view, Q_items, check_valid_item_list);
|
440
|
1546 }
|
428
|
1547
|
440
|
1548 static void image_instantiator_tab_control (void)
|
|
1549 {
|
428
|
1550 INITIALIZE_IMAGE_INSTANTIATOR_FORMAT (tab_control, "tab-control");
|
|
1551 IIFORMAT_HAS_SHARED_METHOD (tab_control, validate, combo_box);
|
|
1552 IIFORMAT_HAS_SHARED_METHOD (tab_control, possible_dest_types, widget);
|
438
|
1553 IIFORMAT_HAS_SHARED_METHOD (tab_control, instantiate, widget);
|
442
|
1554 IIFORMAT_HAS_SHARED_METHOD (tab_control, post_instantiate, widget);
|
|
1555 IIFORMAT_HAS_SHARED_METHOD (tab_control, governing_domain, subwindow);
|
438
|
1556 IIFORMAT_HAS_METHOD (tab_control, query_geometry);
|
428
|
1557 VALID_WIDGET_KEYWORDS (tab_control);
|
|
1558 VALID_GUI_KEYWORDS (tab_control);
|
442
|
1559 IIFORMAT_VALID_KEYWORD (tab_control, Q_orientation,
|
|
1560 check_valid_tab_orientation);
|
|
1561 IIFORMAT_VALID_KEYWORD (tab_control, Q_items, check_valid_item_list);
|
440
|
1562 }
|
428
|
1563
|
440
|
1564 static void image_instantiator_labels (void)
|
|
1565 {
|
428
|
1566 INITIALIZE_IMAGE_INSTANTIATOR_FORMAT (label, "label");
|
|
1567 IIFORMAT_HAS_SHARED_METHOD (label, possible_dest_types, widget);
|
438
|
1568 IIFORMAT_HAS_SHARED_METHOD (label, instantiate, widget);
|
442
|
1569 IIFORMAT_HAS_SHARED_METHOD (label, post_instantiate, widget);
|
|
1570 IIFORMAT_HAS_SHARED_METHOD (label, governing_domain, subwindow);
|
428
|
1571 VALID_WIDGET_KEYWORDS (label);
|
|
1572 IIFORMAT_VALID_KEYWORD (label, Q_descriptor, check_valid_string);
|
440
|
1573 }
|
428
|
1574
|
442
|
1575 #define VALID_LAYOUT_KEYWORDS(layout) \
|
|
1576 VALID_WIDGET_KEYWORDS (layout); \
|
|
1577 IIFORMAT_VALID_KEYWORD (layout, Q_orientation, check_valid_orientation); \
|
|
1578 IIFORMAT_VALID_KEYWORD (layout, Q_justify, check_valid_justification); \
|
|
1579 IIFORMAT_VALID_KEYWORD (layout, Q_border, check_valid_border); \
|
|
1580 IIFORMAT_VALID_KEYWORD (layout, Q_margin_width, check_valid_int); \
|
|
1581 IIFORMAT_VALID_KEYWORD (layout, Q_items, \
|
|
1582 check_valid_instantiator_list)
|
|
1583
|
440
|
1584 static void image_instantiator_layout (void)
|
|
1585 {
|
428
|
1586 INITIALIZE_IMAGE_INSTANTIATOR_FORMAT (layout, "layout");
|
442
|
1587 IIFORMAT_HAS_SHARED_METHOD (layout, possible_dest_types, widget);
|
|
1588 IIFORMAT_HAS_METHOD (layout, instantiate);
|
|
1589 IIFORMAT_HAS_METHOD (layout, post_instantiate);
|
|
1590 IIFORMAT_HAS_SHARED_METHOD (layout, governing_domain, subwindow);
|
428
|
1591 IIFORMAT_HAS_METHOD (layout, normalize);
|
440
|
1592 IIFORMAT_HAS_METHOD (layout, query_geometry);
|
|
1593 IIFORMAT_HAS_METHOD (layout, layout);
|
442
|
1594 IIFORMAT_HAS_METHOD (layout, update);
|
|
1595 IIFORMAT_HAS_METHOD (layout, property);
|
|
1596
|
|
1597 VALID_GUI_KEYWORDS (layout);
|
|
1598 VALID_LAYOUT_KEYWORDS (layout);
|
|
1599 }
|
|
1600
|
|
1601 static void image_instantiator_native_layout (void)
|
|
1602 {
|
|
1603 INITIALIZE_IMAGE_INSTANTIATOR_FORMAT (native_layout, "native-layout");
|
|
1604 IIFORMAT_HAS_SHARED_METHOD (native_layout, possible_dest_types, widget);
|
|
1605 IIFORMAT_HAS_SHARED_METHOD (native_layout, instantiate, layout);
|
|
1606 IIFORMAT_HAS_SHARED_METHOD (native_layout, post_instantiate, layout);
|
|
1607 IIFORMAT_HAS_METHOD (native_layout, layout);
|
|
1608 IIFORMAT_HAS_SHARED_METHOD (native_layout, governing_domain, subwindow);
|
|
1609 IIFORMAT_HAS_SHARED_METHOD (native_layout, normalize, layout);
|
|
1610 IIFORMAT_HAS_SHARED_METHOD (native_layout, query_geometry, layout);
|
|
1611 IIFORMAT_HAS_SHARED_METHOD (native_layout, layout, layout);
|
|
1612 IIFORMAT_HAS_SHARED_METHOD (native_layout, property, layout);
|
|
1613
|
|
1614 VALID_GUI_KEYWORDS (native_layout);
|
|
1615 VALID_LAYOUT_KEYWORDS (native_layout);
|
428
|
1616 }
|
|
1617
|
|
1618 void
|
440
|
1619 image_instantiator_format_create_glyphs_widget (void)
|
|
1620 {
|
|
1621 image_instantiator_widget();
|
|
1622 image_instantiator_buttons();
|
|
1623 image_instantiator_edit_fields();
|
|
1624 image_instantiator_combo_box();
|
|
1625 image_instantiator_scrollbar();
|
|
1626 image_instantiator_progress_guage();
|
|
1627 image_instantiator_tree_view();
|
|
1628 image_instantiator_tab_control();
|
|
1629 image_instantiator_labels();
|
|
1630 image_instantiator_layout();
|
442
|
1631 image_instantiator_native_layout();
|
440
|
1632 }
|
|
1633
|
|
1634 void
|
428
|
1635 reinit_vars_of_glyphs_widget (void)
|
|
1636 {
|
|
1637 #ifdef DEBUG_WIDGETS
|
|
1638 debug_widget_instances = 0;
|
|
1639 #endif
|
|
1640 }
|
|
1641
|
|
1642 void
|
|
1643 vars_of_glyphs_widget (void)
|
|
1644 {
|
|
1645 reinit_vars_of_glyphs_widget ();
|
|
1646 }
|