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