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