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