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