annotate src/glyphs-widget.c @ 408:501cfd01ee6d r21-2-34

Import from CVS: tag r21-2-34
author cvs
date Mon, 13 Aug 2007 11:18:11 +0200
parents b8cc9ab3f761
children de805c49cfc1
Ignore whitespace changes - Everywhere: Within whitespace: At end of lines:
rev   line source
384
bbff43aa5eb7 Import from CVS: tag r21-2-7
cvs
parents:
diff changeset
1 /* Widget-specific glyph objects.
398
74fd4e045ea6 Import from CVS: tag r21-2-29
cvs
parents: 388
diff changeset
2 Copyright (C) 1998, 1999, 2000 Andy Piper.
384
bbff43aa5eb7 Import from CVS: tag r21-2-7
cvs
parents:
diff changeset
3
bbff43aa5eb7 Import from CVS: tag r21-2-7
cvs
parents:
diff changeset
4 This file is part of XEmacs.
bbff43aa5eb7 Import from CVS: tag r21-2-7
cvs
parents:
diff changeset
5
bbff43aa5eb7 Import from CVS: tag r21-2-7
cvs
parents:
diff changeset
6 XEmacs is free software; you can redistribute it and/or modify it
bbff43aa5eb7 Import from CVS: tag r21-2-7
cvs
parents:
diff changeset
7 under the terms of the GNU General Public License as published by the
bbff43aa5eb7 Import from CVS: tag r21-2-7
cvs
parents:
diff changeset
8 Free Software Foundation; either version 2, or (at your option) any
bbff43aa5eb7 Import from CVS: tag r21-2-7
cvs
parents:
diff changeset
9 later version.
bbff43aa5eb7 Import from CVS: tag r21-2-7
cvs
parents:
diff changeset
10
bbff43aa5eb7 Import from CVS: tag r21-2-7
cvs
parents:
diff changeset
11 XEmacs is distributed in the hope that it will be useful, but WITHOUT
bbff43aa5eb7 Import from CVS: tag r21-2-7
cvs
parents:
diff changeset
12 ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or
bbff43aa5eb7 Import from CVS: tag r21-2-7
cvs
parents:
diff changeset
13 FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License
bbff43aa5eb7 Import from CVS: tag r21-2-7
cvs
parents:
diff changeset
14 for more details.
bbff43aa5eb7 Import from CVS: tag r21-2-7
cvs
parents:
diff changeset
15
bbff43aa5eb7 Import from CVS: tag r21-2-7
cvs
parents:
diff changeset
16 You should have received a copy of the GNU General Public License
bbff43aa5eb7 Import from CVS: tag r21-2-7
cvs
parents:
diff changeset
17 along with XEmacs; see the file COPYING. If not, write to
bbff43aa5eb7 Import from CVS: tag r21-2-7
cvs
parents:
diff changeset
18 the Free Software Foundation, Inc., 59 Temple Place - Suite 330,
bbff43aa5eb7 Import from CVS: tag r21-2-7
cvs
parents:
diff changeset
19 Boston, MA 02111-1307, USA. */
bbff43aa5eb7 Import from CVS: tag r21-2-7
cvs
parents:
diff changeset
20
bbff43aa5eb7 Import from CVS: tag r21-2-7
cvs
parents:
diff changeset
21 /* Synched up with: Not in FSF. */
bbff43aa5eb7 Import from CVS: tag r21-2-7
cvs
parents:
diff changeset
22
388
aabb7f5b1c81 Import from CVS: tag r21-2-9
cvs
parents: 384
diff changeset
23 /* written by Andy Piper <andy@xemacs.org> */
aabb7f5b1c81 Import from CVS: tag r21-2-9
cvs
parents: 384
diff changeset
24
384
bbff43aa5eb7 Import from CVS: tag r21-2-7
cvs
parents:
diff changeset
25 #include <config.h>
bbff43aa5eb7 Import from CVS: tag r21-2-7
cvs
parents:
diff changeset
26 #include "lisp.h"
bbff43aa5eb7 Import from CVS: tag r21-2-7
cvs
parents:
diff changeset
27 #include "lstream.h"
bbff43aa5eb7 Import from CVS: tag r21-2-7
cvs
parents:
diff changeset
28 #include "console.h"
bbff43aa5eb7 Import from CVS: tag r21-2-7
cvs
parents:
diff changeset
29 #include "device.h"
bbff43aa5eb7 Import from CVS: tag r21-2-7
cvs
parents:
diff changeset
30 #include "faces.h"
bbff43aa5eb7 Import from CVS: tag r21-2-7
cvs
parents:
diff changeset
31 #include "glyphs.h"
bbff43aa5eb7 Import from CVS: tag r21-2-7
cvs
parents:
diff changeset
32 #include "objects.h"
388
aabb7f5b1c81 Import from CVS: tag r21-2-9
cvs
parents: 384
diff changeset
33 #include "bytecode.h"
384
bbff43aa5eb7 Import from CVS: tag r21-2-7
cvs
parents:
diff changeset
34 #include "window.h"
bbff43aa5eb7 Import from CVS: tag r21-2-7
cvs
parents:
diff changeset
35 #include "buffer.h"
bbff43aa5eb7 Import from CVS: tag r21-2-7
cvs
parents:
diff changeset
36 #include "frame.h"
bbff43aa5eb7 Import from CVS: tag r21-2-7
cvs
parents:
diff changeset
37 #include "insdel.h"
bbff43aa5eb7 Import from CVS: tag r21-2-7
cvs
parents:
diff changeset
38 #include "opaque.h"
bbff43aa5eb7 Import from CVS: tag r21-2-7
cvs
parents:
diff changeset
39
bbff43aa5eb7 Import from CVS: tag r21-2-7
cvs
parents:
diff changeset
40 DEFINE_IMAGE_INSTANTIATOR_FORMAT (button);
398
74fd4e045ea6 Import from CVS: tag r21-2-29
cvs
parents: 388
diff changeset
41 DEFINE_IMAGE_INSTANTIATOR_FORMAT (combo_box);
74fd4e045ea6 Import from CVS: tag r21-2-29
cvs
parents: 388
diff changeset
42 Lisp_Object Qcombo_box;
74fd4e045ea6 Import from CVS: tag r21-2-29
cvs
parents: 388
diff changeset
43 DEFINE_IMAGE_INSTANTIATOR_FORMAT (edit_field);
74fd4e045ea6 Import from CVS: tag r21-2-29
cvs
parents: 388
diff changeset
44 Lisp_Object Qedit_field;
384
bbff43aa5eb7 Import from CVS: tag r21-2-7
cvs
parents:
diff changeset
45 DEFINE_IMAGE_INSTANTIATOR_FORMAT (scrollbar);
bbff43aa5eb7 Import from CVS: tag r21-2-7
cvs
parents:
diff changeset
46 Lisp_Object Qscrollbar;
bbff43aa5eb7 Import from CVS: tag r21-2-7
cvs
parents:
diff changeset
47 DEFINE_IMAGE_INSTANTIATOR_FORMAT (widget);
bbff43aa5eb7 Import from CVS: tag r21-2-7
cvs
parents:
diff changeset
48 DEFINE_IMAGE_INSTANTIATOR_FORMAT (label);
bbff43aa5eb7 Import from CVS: tag r21-2-7
cvs
parents:
diff changeset
49 Lisp_Object Qlabel;
398
74fd4e045ea6 Import from CVS: tag r21-2-29
cvs
parents: 388
diff changeset
50 DEFINE_IMAGE_INSTANTIATOR_FORMAT (progress_gauge);
74fd4e045ea6 Import from CVS: tag r21-2-29
cvs
parents: 388
diff changeset
51 Lisp_Object Qprogress_gauge;
74fd4e045ea6 Import from CVS: tag r21-2-29
cvs
parents: 388
diff changeset
52 DEFINE_IMAGE_INSTANTIATOR_FORMAT (tree_view);
74fd4e045ea6 Import from CVS: tag r21-2-29
cvs
parents: 388
diff changeset
53 Lisp_Object Qtree_view;
74fd4e045ea6 Import from CVS: tag r21-2-29
cvs
parents: 388
diff changeset
54 DEFINE_IMAGE_INSTANTIATOR_FORMAT (tab_control);
74fd4e045ea6 Import from CVS: tag r21-2-29
cvs
parents: 388
diff changeset
55 Lisp_Object Qtab_control;
74fd4e045ea6 Import from CVS: tag r21-2-29
cvs
parents: 388
diff changeset
56 DEFINE_IMAGE_INSTANTIATOR_FORMAT (layout);
74fd4e045ea6 Import from CVS: tag r21-2-29
cvs
parents: 388
diff changeset
57 Lisp_Object Qlayout;
408
501cfd01ee6d Import from CVS: tag r21-2-34
cvs
parents: 406
diff changeset
58 DEFINE_IMAGE_INSTANTIATOR_FORMAT (native_layout);
501cfd01ee6d Import from CVS: tag r21-2-34
cvs
parents: 406
diff changeset
59 Lisp_Object Qnative_layout;
384
bbff43aa5eb7 Import from CVS: tag r21-2-7
cvs
parents:
diff changeset
60
bbff43aa5eb7 Import from CVS: tag r21-2-7
cvs
parents:
diff changeset
61 Lisp_Object Q_descriptor, Q_height, Q_width, Q_properties, Q_items;
406
b8cc9ab3f761 Import from CVS: tag r21-2-33
cvs
parents: 404
diff changeset
62 Lisp_Object Q_image, Q_text, Q_orientation, Q_justify, Q_border;
408
501cfd01ee6d Import from CVS: tag r21-2-34
cvs
parents: 406
diff changeset
63 Lisp_Object Q_margin_width;
398
74fd4e045ea6 Import from CVS: tag r21-2-29
cvs
parents: 388
diff changeset
64 Lisp_Object Qetched_in, Qetched_out, Qbevel_in, Qbevel_out;
384
bbff43aa5eb7 Import from CVS: tag r21-2-7
cvs
parents:
diff changeset
65
398
74fd4e045ea6 Import from CVS: tag r21-2-29
cvs
parents: 388
diff changeset
66 #ifdef DEBUG_WIDGETS
74fd4e045ea6 Import from CVS: tag r21-2-29
cvs
parents: 388
diff changeset
67 int debug_widget_instances;
74fd4e045ea6 Import from CVS: tag r21-2-29
cvs
parents: 388
diff changeset
68 #endif
384
bbff43aa5eb7 Import from CVS: tag r21-2-7
cvs
parents:
diff changeset
69
bbff43aa5eb7 Import from CVS: tag r21-2-7
cvs
parents:
diff changeset
70 /* TODO:
398
74fd4e045ea6 Import from CVS: tag r21-2-29
cvs
parents: 388
diff changeset
71 - tooltips for controls, especially buttons.
74fd4e045ea6 Import from CVS: tag r21-2-29
cvs
parents: 388
diff changeset
72 - keyboard traversal.
74fd4e045ea6 Import from CVS: tag r21-2-29
cvs
parents: 388
diff changeset
73 - lisp configurable layout.
384
bbff43aa5eb7 Import from CVS: tag r21-2-7
cvs
parents:
diff changeset
74 */
bbff43aa5eb7 Import from CVS: tag r21-2-7
cvs
parents:
diff changeset
75
398
74fd4e045ea6 Import from CVS: tag r21-2-29
cvs
parents: 388
diff changeset
76 /* In MS-Windows normal windows work in pixels, dialog boxes work in
384
bbff43aa5eb7 Import from CVS: tag r21-2-7
cvs
parents:
diff changeset
77 dialog box units. Why? sigh. We could reuse the metrics for dialogs
bbff43aa5eb7 Import from CVS: tag r21-2-7
cvs
parents:
diff changeset
78 if this were not the case. As it is we have to position things
bbff43aa5eb7 Import from CVS: tag r21-2-7
cvs
parents:
diff changeset
79 pixel wise. I'm not even sure that X has this problem at least for
bbff43aa5eb7 Import from CVS: tag r21-2-7
cvs
parents:
diff changeset
80 buttons in groups. */
bbff43aa5eb7 Import from CVS: tag r21-2-7
cvs
parents:
diff changeset
81 static int
bbff43aa5eb7 Import from CVS: tag r21-2-7
cvs
parents:
diff changeset
82 widget_possible_dest_types (void)
bbff43aa5eb7 Import from CVS: tag r21-2-7
cvs
parents:
diff changeset
83 {
bbff43aa5eb7 Import from CVS: tag r21-2-7
cvs
parents:
diff changeset
84 return IMAGE_WIDGET_MASK;
bbff43aa5eb7 Import from CVS: tag r21-2-7
cvs
parents:
diff changeset
85 }
bbff43aa5eb7 Import from CVS: tag r21-2-7
cvs
parents:
diff changeset
86
bbff43aa5eb7 Import from CVS: tag r21-2-7
cvs
parents:
diff changeset
87 static void
398
74fd4e045ea6 Import from CVS: tag r21-2-29
cvs
parents: 388
diff changeset
88 check_valid_glyph_or_instantiator (Lisp_Object data)
384
bbff43aa5eb7 Import from CVS: tag r21-2-7
cvs
parents:
diff changeset
89 {
388
aabb7f5b1c81 Import from CVS: tag r21-2-9
cvs
parents: 384
diff changeset
90 Lisp_Object glyph = data;
384
bbff43aa5eb7 Import from CVS: tag r21-2-7
cvs
parents:
diff changeset
91 if (SYMBOLP (data))
388
aabb7f5b1c81 Import from CVS: tag r21-2-9
cvs
parents: 384
diff changeset
92 glyph = XSYMBOL (data)->value;
aabb7f5b1c81 Import from CVS: tag r21-2-9
cvs
parents: 384
diff changeset
93
aabb7f5b1c81 Import from CVS: tag r21-2-9
cvs
parents: 384
diff changeset
94 if (IMAGE_INSTANCEP (glyph))
aabb7f5b1c81 Import from CVS: tag r21-2-9
cvs
parents: 384
diff changeset
95 CHECK_IMAGE_INSTANCE (glyph);
398
74fd4e045ea6 Import from CVS: tag r21-2-29
cvs
parents: 388
diff changeset
96 else if (!CONSP (glyph) && !VECTORP (glyph))
388
aabb7f5b1c81 Import from CVS: tag r21-2-9
cvs
parents: 384
diff changeset
97 CHECK_BUFFER_GLYPH (glyph);
aabb7f5b1c81 Import from CVS: tag r21-2-9
cvs
parents: 384
diff changeset
98 }
aabb7f5b1c81 Import from CVS: tag r21-2-9
cvs
parents: 384
diff changeset
99
aabb7f5b1c81 Import from CVS: tag r21-2-9
cvs
parents: 384
diff changeset
100 static void
398
74fd4e045ea6 Import from CVS: tag r21-2-29
cvs
parents: 388
diff changeset
101 check_valid_orientation (Lisp_Object data)
74fd4e045ea6 Import from CVS: tag r21-2-29
cvs
parents: 388
diff changeset
102 {
74fd4e045ea6 Import from CVS: tag r21-2-29
cvs
parents: 388
diff changeset
103 if (!EQ (data, Qhorizontal)
74fd4e045ea6 Import from CVS: tag r21-2-29
cvs
parents: 388
diff changeset
104 &&
74fd4e045ea6 Import from CVS: tag r21-2-29
cvs
parents: 388
diff changeset
105 !EQ (data, Qvertical))
74fd4e045ea6 Import from CVS: tag r21-2-29
cvs
parents: 388
diff changeset
106 signal_simple_error ("unknown orientation for layout", data);
74fd4e045ea6 Import from CVS: tag r21-2-29
cvs
parents: 388
diff changeset
107 }
74fd4e045ea6 Import from CVS: tag r21-2-29
cvs
parents: 388
diff changeset
108
74fd4e045ea6 Import from CVS: tag r21-2-29
cvs
parents: 388
diff changeset
109 static void
74fd4e045ea6 Import from CVS: tag r21-2-29
cvs
parents: 388
diff changeset
110 check_valid_tab_orientation (Lisp_Object data)
74fd4e045ea6 Import from CVS: tag r21-2-29
cvs
parents: 388
diff changeset
111 {
74fd4e045ea6 Import from CVS: tag r21-2-29
cvs
parents: 388
diff changeset
112 if (!EQ (data, Qtop)
74fd4e045ea6 Import from CVS: tag r21-2-29
cvs
parents: 388
diff changeset
113 &&
74fd4e045ea6 Import from CVS: tag r21-2-29
cvs
parents: 388
diff changeset
114 !EQ (data, Qbottom)
74fd4e045ea6 Import from CVS: tag r21-2-29
cvs
parents: 388
diff changeset
115 &&
74fd4e045ea6 Import from CVS: tag r21-2-29
cvs
parents: 388
diff changeset
116 !EQ (data, Qleft)
74fd4e045ea6 Import from CVS: tag r21-2-29
cvs
parents: 388
diff changeset
117 &&
74fd4e045ea6 Import from CVS: tag r21-2-29
cvs
parents: 388
diff changeset
118 !EQ (data, Qright))
74fd4e045ea6 Import from CVS: tag r21-2-29
cvs
parents: 388
diff changeset
119 signal_simple_error ("unknown orientation for tab control", data);
74fd4e045ea6 Import from CVS: tag r21-2-29
cvs
parents: 388
diff changeset
120 }
74fd4e045ea6 Import from CVS: tag r21-2-29
cvs
parents: 388
diff changeset
121
74fd4e045ea6 Import from CVS: tag r21-2-29
cvs
parents: 388
diff changeset
122 static void
74fd4e045ea6 Import from CVS: tag r21-2-29
cvs
parents: 388
diff changeset
123 check_valid_justification (Lisp_Object data)
74fd4e045ea6 Import from CVS: tag r21-2-29
cvs
parents: 388
diff changeset
124 {
74fd4e045ea6 Import from CVS: tag r21-2-29
cvs
parents: 388
diff changeset
125 if (!EQ (data, Qleft) && !EQ (data, Qright) && !EQ (data, Qcenter))
74fd4e045ea6 Import from CVS: tag r21-2-29
cvs
parents: 388
diff changeset
126 signal_simple_error ("unknown justification for layout", data);
74fd4e045ea6 Import from CVS: tag r21-2-29
cvs
parents: 388
diff changeset
127 }
74fd4e045ea6 Import from CVS: tag r21-2-29
cvs
parents: 388
diff changeset
128
74fd4e045ea6 Import from CVS: tag r21-2-29
cvs
parents: 388
diff changeset
129 static void
74fd4e045ea6 Import from CVS: tag r21-2-29
cvs
parents: 388
diff changeset
130 check_valid_border (Lisp_Object data)
74fd4e045ea6 Import from CVS: tag r21-2-29
cvs
parents: 388
diff changeset
131 {
74fd4e045ea6 Import from CVS: tag r21-2-29
cvs
parents: 388
diff changeset
132 if (!EQ (data, Qt) && !EQ (data, Qetched_in) && !EQ (data, Qetched_out)
74fd4e045ea6 Import from CVS: tag r21-2-29
cvs
parents: 388
diff changeset
133 && !EQ (data, Qbevel_in) && !EQ (data, Qbevel_out)
74fd4e045ea6 Import from CVS: tag r21-2-29
cvs
parents: 388
diff changeset
134 && !GLYPHP (data) && !VECTORP (data))
74fd4e045ea6 Import from CVS: tag r21-2-29
cvs
parents: 388
diff changeset
135 signal_simple_error ("unknown border style for layout", data);
74fd4e045ea6 Import from CVS: tag r21-2-29
cvs
parents: 388
diff changeset
136 }
74fd4e045ea6 Import from CVS: tag r21-2-29
cvs
parents: 388
diff changeset
137
74fd4e045ea6 Import from CVS: tag r21-2-29
cvs
parents: 388
diff changeset
138 static void
388
aabb7f5b1c81 Import from CVS: tag r21-2-9
cvs
parents: 384
diff changeset
139 check_valid_anything (Lisp_Object data)
aabb7f5b1c81 Import from CVS: tag r21-2-9
cvs
parents: 384
diff changeset
140 {
384
bbff43aa5eb7 Import from CVS: tag r21-2-7
cvs
parents:
diff changeset
141 }
388
aabb7f5b1c81 Import from CVS: tag r21-2-9
cvs
parents: 384
diff changeset
142
aabb7f5b1c81 Import from CVS: tag r21-2-9
cvs
parents: 384
diff changeset
143 static void
aabb7f5b1c81 Import from CVS: tag r21-2-9
cvs
parents: 384
diff changeset
144 check_valid_callback (Lisp_Object data)
aabb7f5b1c81 Import from CVS: tag r21-2-9
cvs
parents: 384
diff changeset
145 {
aabb7f5b1c81 Import from CVS: tag r21-2-9
cvs
parents: 384
diff changeset
146 if (!SYMBOLP (data)
aabb7f5b1c81 Import from CVS: tag r21-2-9
cvs
parents: 384
diff changeset
147 && !COMPILED_FUNCTIONP (data)
aabb7f5b1c81 Import from CVS: tag r21-2-9
cvs
parents: 384
diff changeset
148 && !CONSP (data))
aabb7f5b1c81 Import from CVS: tag r21-2-9
cvs
parents: 384
diff changeset
149 {
aabb7f5b1c81 Import from CVS: tag r21-2-9
cvs
parents: 384
diff changeset
150 signal_simple_error (":callback must be a function or expression", data);
aabb7f5b1c81 Import from CVS: tag r21-2-9
cvs
parents: 384
diff changeset
151 }
aabb7f5b1c81 Import from CVS: tag r21-2-9
cvs
parents: 384
diff changeset
152 }
aabb7f5b1c81 Import from CVS: tag r21-2-9
cvs
parents: 384
diff changeset
153
aabb7f5b1c81 Import from CVS: tag r21-2-9
cvs
parents: 384
diff changeset
154 static void
404
2f8bb876ab1d Import from CVS: tag r21-2-32
cvs
parents: 400
diff changeset
155 check_valid_int_or_function (Lisp_Object data)
2f8bb876ab1d Import from CVS: tag r21-2-32
cvs
parents: 400
diff changeset
156 {
2f8bb876ab1d Import from CVS: tag r21-2-32
cvs
parents: 400
diff changeset
157 if (!INTP (data) && !CONSP (data))
2f8bb876ab1d Import from CVS: tag r21-2-32
cvs
parents: 400
diff changeset
158 signal_simple_error ("must be an integer or expresssion", data);
2f8bb876ab1d Import from CVS: tag r21-2-32
cvs
parents: 400
diff changeset
159 }
2f8bb876ab1d Import from CVS: tag r21-2-32
cvs
parents: 400
diff changeset
160
2f8bb876ab1d Import from CVS: tag r21-2-32
cvs
parents: 400
diff changeset
161 static void
388
aabb7f5b1c81 Import from CVS: tag r21-2-9
cvs
parents: 384
diff changeset
162 check_valid_symbol (Lisp_Object data)
aabb7f5b1c81 Import from CVS: tag r21-2-9
cvs
parents: 384
diff changeset
163 {
aabb7f5b1c81 Import from CVS: tag r21-2-9
cvs
parents: 384
diff changeset
164 CHECK_SYMBOL (data);
aabb7f5b1c81 Import from CVS: tag r21-2-9
cvs
parents: 384
diff changeset
165 }
aabb7f5b1c81 Import from CVS: tag r21-2-9
cvs
parents: 384
diff changeset
166
aabb7f5b1c81 Import from CVS: tag r21-2-9
cvs
parents: 384
diff changeset
167 static void
aabb7f5b1c81 Import from CVS: tag r21-2-9
cvs
parents: 384
diff changeset
168 check_valid_string_or_vector (Lisp_Object data)
aabb7f5b1c81 Import from CVS: tag r21-2-9
cvs
parents: 384
diff changeset
169 {
aabb7f5b1c81 Import from CVS: tag r21-2-9
cvs
parents: 384
diff changeset
170 if (!STRINGP (data) && !VECTORP (data))
aabb7f5b1c81 Import from CVS: tag r21-2-9
cvs
parents: 384
diff changeset
171 signal_simple_error (":descriptor must be a string or a vector", data);
aabb7f5b1c81 Import from CVS: tag r21-2-9
cvs
parents: 384
diff changeset
172 }
384
bbff43aa5eb7 Import from CVS: tag r21-2-7
cvs
parents:
diff changeset
173
398
74fd4e045ea6 Import from CVS: tag r21-2-29
cvs
parents: 388
diff changeset
174 void
74fd4e045ea6 Import from CVS: tag r21-2-29
cvs
parents: 388
diff changeset
175 check_valid_item_list_1 (Lisp_Object items)
384
bbff43aa5eb7 Import from CVS: tag r21-2-7
cvs
parents:
diff changeset
176 {
bbff43aa5eb7 Import from CVS: tag r21-2-7
cvs
parents:
diff changeset
177 Lisp_Object rest;
bbff43aa5eb7 Import from CVS: tag r21-2-7
cvs
parents:
diff changeset
178
bbff43aa5eb7 Import from CVS: tag r21-2-7
cvs
parents:
diff changeset
179 CHECK_LIST (items);
bbff43aa5eb7 Import from CVS: tag r21-2-7
cvs
parents:
diff changeset
180 EXTERNAL_LIST_LOOP (rest, items)
bbff43aa5eb7 Import from CVS: tag r21-2-7
cvs
parents:
diff changeset
181 {
398
74fd4e045ea6 Import from CVS: tag r21-2-29
cvs
parents: 388
diff changeset
182 if (STRINGP (XCAR (rest)))
74fd4e045ea6 Import from CVS: tag r21-2-29
cvs
parents: 388
diff changeset
183 CHECK_STRING (XCAR (rest));
74fd4e045ea6 Import from CVS: tag r21-2-29
cvs
parents: 388
diff changeset
184 else if (VECTORP (XCAR (rest)))
74fd4e045ea6 Import from CVS: tag r21-2-29
cvs
parents: 388
diff changeset
185 gui_parse_item_keywords (XCAR (rest));
74fd4e045ea6 Import from CVS: tag r21-2-29
cvs
parents: 388
diff changeset
186 else if (LISTP (XCAR (rest)))
74fd4e045ea6 Import from CVS: tag r21-2-29
cvs
parents: 388
diff changeset
187 check_valid_item_list_1 (XCAR (rest));
74fd4e045ea6 Import from CVS: tag r21-2-29
cvs
parents: 388
diff changeset
188 else
74fd4e045ea6 Import from CVS: tag r21-2-29
cvs
parents: 388
diff changeset
189 signal_simple_error ("Items must be vectors, lists or strings", items);
74fd4e045ea6 Import from CVS: tag r21-2-29
cvs
parents: 388
diff changeset
190 }
74fd4e045ea6 Import from CVS: tag r21-2-29
cvs
parents: 388
diff changeset
191 }
74fd4e045ea6 Import from CVS: tag r21-2-29
cvs
parents: 388
diff changeset
192
74fd4e045ea6 Import from CVS: tag r21-2-29
cvs
parents: 388
diff changeset
193 static void
74fd4e045ea6 Import from CVS: tag r21-2-29
cvs
parents: 388
diff changeset
194 check_valid_item_list (Lisp_Object data)
74fd4e045ea6 Import from CVS: tag r21-2-29
cvs
parents: 388
diff changeset
195 {
74fd4e045ea6 Import from CVS: tag r21-2-29
cvs
parents: 388
diff changeset
196 Lisp_Object items;
74fd4e045ea6 Import from CVS: tag r21-2-29
cvs
parents: 388
diff changeset
197
74fd4e045ea6 Import from CVS: tag r21-2-29
cvs
parents: 388
diff changeset
198 Fcheck_valid_plist (data);
74fd4e045ea6 Import from CVS: tag r21-2-29
cvs
parents: 388
diff changeset
199 items = Fplist_get (data, Q_items, Qnil);
74fd4e045ea6 Import from CVS: tag r21-2-29
cvs
parents: 388
diff changeset
200
74fd4e045ea6 Import from CVS: tag r21-2-29
cvs
parents: 388
diff changeset
201 check_valid_item_list_1 (items);
74fd4e045ea6 Import from CVS: tag r21-2-29
cvs
parents: 388
diff changeset
202 }
74fd4e045ea6 Import from CVS: tag r21-2-29
cvs
parents: 388
diff changeset
203
74fd4e045ea6 Import from CVS: tag r21-2-29
cvs
parents: 388
diff changeset
204 static void
74fd4e045ea6 Import from CVS: tag r21-2-29
cvs
parents: 388
diff changeset
205 check_valid_glyph_or_instantiator_list (Lisp_Object data)
74fd4e045ea6 Import from CVS: tag r21-2-29
cvs
parents: 388
diff changeset
206 {
74fd4e045ea6 Import from CVS: tag r21-2-29
cvs
parents: 388
diff changeset
207 Lisp_Object rest;
74fd4e045ea6 Import from CVS: tag r21-2-29
cvs
parents: 388
diff changeset
208
74fd4e045ea6 Import from CVS: tag r21-2-29
cvs
parents: 388
diff changeset
209 CHECK_LIST (data);
74fd4e045ea6 Import from CVS: tag r21-2-29
cvs
parents: 388
diff changeset
210 EXTERNAL_LIST_LOOP (rest, data)
74fd4e045ea6 Import from CVS: tag r21-2-29
cvs
parents: 388
diff changeset
211 {
74fd4e045ea6 Import from CVS: tag r21-2-29
cvs
parents: 388
diff changeset
212 check_valid_glyph_or_instantiator (XCAR (rest));
384
bbff43aa5eb7 Import from CVS: tag r21-2-7
cvs
parents:
diff changeset
213 }
bbff43aa5eb7 Import from CVS: tag r21-2-7
cvs
parents:
diff changeset
214 }
bbff43aa5eb7 Import from CVS: tag r21-2-7
cvs
parents:
diff changeset
215
398
74fd4e045ea6 Import from CVS: tag r21-2-29
cvs
parents: 388
diff changeset
216 static Lisp_Object
74fd4e045ea6 Import from CVS: tag r21-2-29
cvs
parents: 388
diff changeset
217 glyph_instantiator_to_glyph (Lisp_Object sym)
74fd4e045ea6 Import from CVS: tag r21-2-29
cvs
parents: 388
diff changeset
218 {
74fd4e045ea6 Import from CVS: tag r21-2-29
cvs
parents: 388
diff changeset
219 /* This function calls lisp. */
74fd4e045ea6 Import from CVS: tag r21-2-29
cvs
parents: 388
diff changeset
220 Lisp_Object glyph = sym;
74fd4e045ea6 Import from CVS: tag r21-2-29
cvs
parents: 388
diff changeset
221 struct gcpro gcpro1;
74fd4e045ea6 Import from CVS: tag r21-2-29
cvs
parents: 388
diff changeset
222
74fd4e045ea6 Import from CVS: tag r21-2-29
cvs
parents: 388
diff changeset
223 GCPRO1 (glyph);
74fd4e045ea6 Import from CVS: tag r21-2-29
cvs
parents: 388
diff changeset
224 /* if we have a symbol get at the actual data */
74fd4e045ea6 Import from CVS: tag r21-2-29
cvs
parents: 388
diff changeset
225 if (SYMBOLP (glyph))
74fd4e045ea6 Import from CVS: tag r21-2-29
cvs
parents: 388
diff changeset
226 glyph = XSYMBOL (glyph)->value;
74fd4e045ea6 Import from CVS: tag r21-2-29
cvs
parents: 388
diff changeset
227
74fd4e045ea6 Import from CVS: tag r21-2-29
cvs
parents: 388
diff changeset
228 if (CONSP (glyph))
74fd4e045ea6 Import from CVS: tag r21-2-29
cvs
parents: 388
diff changeset
229 glyph = Feval (glyph);
74fd4e045ea6 Import from CVS: tag r21-2-29
cvs
parents: 388
diff changeset
230
74fd4e045ea6 Import from CVS: tag r21-2-29
cvs
parents: 388
diff changeset
231 /* Be really helpful to the user. */
74fd4e045ea6 Import from CVS: tag r21-2-29
cvs
parents: 388
diff changeset
232 if (VECTORP (glyph))
74fd4e045ea6 Import from CVS: tag r21-2-29
cvs
parents: 388
diff changeset
233 {
74fd4e045ea6 Import from CVS: tag r21-2-29
cvs
parents: 388
diff changeset
234 glyph = call1 (intern ("make-glyph"), glyph);
74fd4e045ea6 Import from CVS: tag r21-2-29
cvs
parents: 388
diff changeset
235 }
74fd4e045ea6 Import from CVS: tag r21-2-29
cvs
parents: 388
diff changeset
236
74fd4e045ea6 Import from CVS: tag r21-2-29
cvs
parents: 388
diff changeset
237 /* substitute the new glyph */
74fd4e045ea6 Import from CVS: tag r21-2-29
cvs
parents: 388
diff changeset
238 RETURN_UNGCPRO (glyph);
74fd4e045ea6 Import from CVS: tag r21-2-29
cvs
parents: 388
diff changeset
239 }
74fd4e045ea6 Import from CVS: tag r21-2-29
cvs
parents: 388
diff changeset
240
74fd4e045ea6 Import from CVS: tag r21-2-29
cvs
parents: 388
diff changeset
241 static void
74fd4e045ea6 Import from CVS: tag r21-2-29
cvs
parents: 388
diff changeset
242 substitute_keyword_value (Lisp_Object inst, Lisp_Object key, Lisp_Object val)
74fd4e045ea6 Import from CVS: tag r21-2-29
cvs
parents: 388
diff changeset
243 {
74fd4e045ea6 Import from CVS: tag r21-2-29
cvs
parents: 388
diff changeset
244 int i;
74fd4e045ea6 Import from CVS: tag r21-2-29
cvs
parents: 388
diff changeset
245 /* substitute the new glyph */
74fd4e045ea6 Import from CVS: tag r21-2-29
cvs
parents: 388
diff changeset
246 for (i = 0; i < XVECTOR_LENGTH (inst); i++)
74fd4e045ea6 Import from CVS: tag r21-2-29
cvs
parents: 388
diff changeset
247 {
74fd4e045ea6 Import from CVS: tag r21-2-29
cvs
parents: 388
diff changeset
248 if (EQ (key, XVECTOR_DATA (inst)[i]))
74fd4e045ea6 Import from CVS: tag r21-2-29
cvs
parents: 388
diff changeset
249 {
74fd4e045ea6 Import from CVS: tag r21-2-29
cvs
parents: 388
diff changeset
250 XVECTOR_DATA (inst)[i+1] = val;
74fd4e045ea6 Import from CVS: tag r21-2-29
cvs
parents: 388
diff changeset
251 break;
74fd4e045ea6 Import from CVS: tag r21-2-29
cvs
parents: 388
diff changeset
252 }
74fd4e045ea6 Import from CVS: tag r21-2-29
cvs
parents: 388
diff changeset
253 }
74fd4e045ea6 Import from CVS: tag r21-2-29
cvs
parents: 388
diff changeset
254 }
74fd4e045ea6 Import from CVS: tag r21-2-29
cvs
parents: 388
diff changeset
255
74fd4e045ea6 Import from CVS: tag r21-2-29
cvs
parents: 388
diff changeset
256 /* Wire widget property invocations to specific widgets. The problem
74fd4e045ea6 Import from CVS: tag r21-2-29
cvs
parents: 388
diff changeset
257 we are solving here is that when instantiators get converted to
74fd4e045ea6 Import from CVS: tag r21-2-29
cvs
parents: 388
diff changeset
258 instances they lose some type information (they just become
74fd4e045ea6 Import from CVS: tag r21-2-29
cvs
parents: 388
diff changeset
259 subwindows or widgets for example). For widgets we need to preserve
74fd4e045ea6 Import from CVS: tag r21-2-29
cvs
parents: 388
diff changeset
260 this type information so that we can do widget specific operations
74fd4e045ea6 Import from CVS: tag r21-2-29
cvs
parents: 388
diff changeset
261 on the instances. This is encoded in the widget type
74fd4e045ea6 Import from CVS: tag r21-2-29
cvs
parents: 388
diff changeset
262 field. widget_property gets invoked by decoding the primary type
74fd4e045ea6 Import from CVS: tag r21-2-29
cvs
parents: 388
diff changeset
263 (Qwidget), <widget>_property then invokes based on the secondary
74fd4e045ea6 Import from CVS: tag r21-2-29
cvs
parents: 388
diff changeset
264 type (Qedit_field for example). It is debatable whether we should
74fd4e045ea6 Import from CVS: tag r21-2-29
cvs
parents: 388
diff changeset
265 wire things in this generalised way rather than treating widgets
74fd4e045ea6 Import from CVS: tag r21-2-29
cvs
parents: 388
diff changeset
266 specially in image_instance_property. */
384
bbff43aa5eb7 Import from CVS: tag r21-2-7
cvs
parents:
diff changeset
267 static Lisp_Object
bbff43aa5eb7 Import from CVS: tag r21-2-7
cvs
parents:
diff changeset
268 widget_property (Lisp_Object image_instance, Lisp_Object prop)
bbff43aa5eb7 Import from CVS: tag r21-2-7
cvs
parents:
diff changeset
269 {
398
74fd4e045ea6 Import from CVS: tag r21-2-29
cvs
parents: 388
diff changeset
270 Lisp_Image_Instance* ii = XIMAGE_INSTANCE (image_instance);
384
bbff43aa5eb7 Import from CVS: tag r21-2-7
cvs
parents:
diff changeset
271 struct image_instantiator_methods* meths;
bbff43aa5eb7 Import from CVS: tag r21-2-7
cvs
parents:
diff changeset
272
bbff43aa5eb7 Import from CVS: tag r21-2-7
cvs
parents:
diff changeset
273 /* first see if its a general property ... */
bbff43aa5eb7 Import from CVS: tag r21-2-7
cvs
parents:
diff changeset
274 if (!NILP (Fplist_member (IMAGE_INSTANCE_WIDGET_PROPS (ii), prop)))
bbff43aa5eb7 Import from CVS: tag r21-2-7
cvs
parents:
diff changeset
275 return Fplist_get (IMAGE_INSTANCE_WIDGET_PROPS (ii), prop, Qnil);
bbff43aa5eb7 Import from CVS: tag r21-2-7
cvs
parents:
diff changeset
276
bbff43aa5eb7 Import from CVS: tag r21-2-7
cvs
parents:
diff changeset
277 /* .. then try device specific methods ... */
408
501cfd01ee6d Import from CVS: tag r21-2-34
cvs
parents: 406
diff changeset
278 meths = decode_device_ii_format (image_instance_device (image_instance),
384
bbff43aa5eb7 Import from CVS: tag r21-2-7
cvs
parents:
diff changeset
279 IMAGE_INSTANCE_WIDGET_TYPE (ii),
bbff43aa5eb7 Import from CVS: tag r21-2-7
cvs
parents:
diff changeset
280 ERROR_ME_NOT);
bbff43aa5eb7 Import from CVS: tag r21-2-7
cvs
parents:
diff changeset
281 if (meths && HAS_IIFORMAT_METH_P (meths, property))
bbff43aa5eb7 Import from CVS: tag r21-2-7
cvs
parents:
diff changeset
282 return IIFORMAT_METH (meths, property, (image_instance, prop));
bbff43aa5eb7 Import from CVS: tag r21-2-7
cvs
parents:
diff changeset
283 /* ... then format specific methods ... */
bbff43aa5eb7 Import from CVS: tag r21-2-7
cvs
parents:
diff changeset
284 meths = decode_device_ii_format (Qnil, IMAGE_INSTANCE_WIDGET_TYPE (ii),
bbff43aa5eb7 Import from CVS: tag r21-2-7
cvs
parents:
diff changeset
285 ERROR_ME_NOT);
bbff43aa5eb7 Import from CVS: tag r21-2-7
cvs
parents:
diff changeset
286 if (meths && HAS_IIFORMAT_METH_P (meths, property))
bbff43aa5eb7 Import from CVS: tag r21-2-7
cvs
parents:
diff changeset
287 return IIFORMAT_METH (meths, property, (image_instance, prop));
bbff43aa5eb7 Import from CVS: tag r21-2-7
cvs
parents:
diff changeset
288 /* ... then fail */
bbff43aa5eb7 Import from CVS: tag r21-2-7
cvs
parents:
diff changeset
289 return Qunbound;
bbff43aa5eb7 Import from CVS: tag r21-2-7
cvs
parents:
diff changeset
290 }
bbff43aa5eb7 Import from CVS: tag r21-2-7
cvs
parents:
diff changeset
291
bbff43aa5eb7 Import from CVS: tag r21-2-7
cvs
parents:
diff changeset
292 static Lisp_Object
bbff43aa5eb7 Import from CVS: tag r21-2-7
cvs
parents:
diff changeset
293 widget_set_property (Lisp_Object image_instance, Lisp_Object prop, Lisp_Object val)
bbff43aa5eb7 Import from CVS: tag r21-2-7
cvs
parents:
diff changeset
294 {
398
74fd4e045ea6 Import from CVS: tag r21-2-29
cvs
parents: 388
diff changeset
295 Lisp_Image_Instance* ii = XIMAGE_INSTANCE (image_instance);
384
bbff43aa5eb7 Import from CVS: tag r21-2-7
cvs
parents:
diff changeset
296 struct image_instantiator_methods* meths;
bbff43aa5eb7 Import from CVS: tag r21-2-7
cvs
parents:
diff changeset
297 Lisp_Object ret;
bbff43aa5eb7 Import from CVS: tag r21-2-7
cvs
parents:
diff changeset
298
398
74fd4e045ea6 Import from CVS: tag r21-2-29
cvs
parents: 388
diff changeset
299 /* PIck up any generic properties that we might need to keep hold
74fd4e045ea6 Import from CVS: tag r21-2-29
cvs
parents: 388
diff changeset
300 of. */
74fd4e045ea6 Import from CVS: tag r21-2-29
cvs
parents: 388
diff changeset
301 if (EQ (prop, Q_text))
74fd4e045ea6 Import from CVS: tag r21-2-29
cvs
parents: 388
diff changeset
302 {
74fd4e045ea6 Import from CVS: tag r21-2-29
cvs
parents: 388
diff changeset
303 IMAGE_INSTANCE_WIDGET_TEXT (ii) = val;
74fd4e045ea6 Import from CVS: tag r21-2-29
cvs
parents: 388
diff changeset
304 IMAGE_INSTANCE_TEXT_CHANGED (ii) = 1;
74fd4e045ea6 Import from CVS: tag r21-2-29
cvs
parents: 388
diff changeset
305 }
74fd4e045ea6 Import from CVS: tag r21-2-29
cvs
parents: 388
diff changeset
306
74fd4e045ea6 Import from CVS: tag r21-2-29
cvs
parents: 388
diff changeset
307 /* Now try device specific methods first ... */
408
501cfd01ee6d Import from CVS: tag r21-2-34
cvs
parents: 406
diff changeset
308 meths = decode_device_ii_format (image_instance_device (image_instance),
384
bbff43aa5eb7 Import from CVS: tag r21-2-7
cvs
parents:
diff changeset
309 IMAGE_INSTANCE_WIDGET_TYPE (ii),
bbff43aa5eb7 Import from CVS: tag r21-2-7
cvs
parents:
diff changeset
310 ERROR_ME_NOT);
bbff43aa5eb7 Import from CVS: tag r21-2-7
cvs
parents:
diff changeset
311 if (meths && HAS_IIFORMAT_METH_P (meths, set_property)
bbff43aa5eb7 Import from CVS: tag r21-2-7
cvs
parents:
diff changeset
312 &&
bbff43aa5eb7 Import from CVS: tag r21-2-7
cvs
parents:
diff changeset
313 !UNBOUNDP (ret =
bbff43aa5eb7 Import from CVS: tag r21-2-7
cvs
parents:
diff changeset
314 IIFORMAT_METH (meths, set_property, (image_instance, prop, val))))
bbff43aa5eb7 Import from CVS: tag r21-2-7
cvs
parents:
diff changeset
315 {
bbff43aa5eb7 Import from CVS: tag r21-2-7
cvs
parents:
diff changeset
316 return ret;
bbff43aa5eb7 Import from CVS: tag r21-2-7
cvs
parents:
diff changeset
317 }
bbff43aa5eb7 Import from CVS: tag r21-2-7
cvs
parents:
diff changeset
318 /* ... then format specific methods ... */
bbff43aa5eb7 Import from CVS: tag r21-2-7
cvs
parents:
diff changeset
319 meths = decode_device_ii_format (Qnil, IMAGE_INSTANCE_WIDGET_TYPE (ii),
bbff43aa5eb7 Import from CVS: tag r21-2-7
cvs
parents:
diff changeset
320 ERROR_ME_NOT);
bbff43aa5eb7 Import from CVS: tag r21-2-7
cvs
parents:
diff changeset
321 if (meths && HAS_IIFORMAT_METH_P (meths, set_property)
bbff43aa5eb7 Import from CVS: tag r21-2-7
cvs
parents:
diff changeset
322 &&
bbff43aa5eb7 Import from CVS: tag r21-2-7
cvs
parents:
diff changeset
323 !UNBOUNDP (ret =
bbff43aa5eb7 Import from CVS: tag r21-2-7
cvs
parents:
diff changeset
324 IIFORMAT_METH (meths, set_property, (image_instance, prop, val))))
bbff43aa5eb7 Import from CVS: tag r21-2-7
cvs
parents:
diff changeset
325 {
bbff43aa5eb7 Import from CVS: tag r21-2-7
cvs
parents:
diff changeset
326 return ret;
bbff43aa5eb7 Import from CVS: tag r21-2-7
cvs
parents:
diff changeset
327 }
bbff43aa5eb7 Import from CVS: tag r21-2-7
cvs
parents:
diff changeset
328 /* we didn't do any device specific properties, so shove the property in our plist */
bbff43aa5eb7 Import from CVS: tag r21-2-7
cvs
parents:
diff changeset
329 IMAGE_INSTANCE_WIDGET_PROPS (ii)
bbff43aa5eb7 Import from CVS: tag r21-2-7
cvs
parents:
diff changeset
330 = Fplist_put (IMAGE_INSTANCE_WIDGET_PROPS (ii), prop, val);
bbff43aa5eb7 Import from CVS: tag r21-2-7
cvs
parents:
diff changeset
331 return val;
bbff43aa5eb7 Import from CVS: tag r21-2-7
cvs
parents:
diff changeset
332 }
bbff43aa5eb7 Import from CVS: tag r21-2-7
cvs
parents:
diff changeset
333
398
74fd4e045ea6 Import from CVS: tag r21-2-29
cvs
parents: 388
diff changeset
334 /* Like the rest of redisplay, we want widget updates to occur
408
501cfd01ee6d Import from CVS: tag r21-2-34
cvs
parents: 406
diff changeset
335 asynchronously. Thus toolkit specific methods for setting
501cfd01ee6d Import from CVS: tag r21-2-34
cvs
parents: 406
diff changeset
336 properties must be called by redisplay instead of by
501cfd01ee6d Import from CVS: tag r21-2-34
cvs
parents: 406
diff changeset
337 *_set_property. Thus *_set_property records the change and this
501cfd01ee6d Import from CVS: tag r21-2-34
cvs
parents: 406
diff changeset
338 function actually implements it. We want to be slightly clever
501cfd01ee6d Import from CVS: tag r21-2-34
cvs
parents: 406
diff changeset
339 about this however by supplying format specific functions for the
501cfd01ee6d Import from CVS: tag r21-2-34
cvs
parents: 406
diff changeset
340 updates instead of lumping them all into this function. Note that
501cfd01ee6d Import from CVS: tag r21-2-34
cvs
parents: 406
diff changeset
341 there is no need for format generic functions. */
398
74fd4e045ea6 Import from CVS: tag r21-2-29
cvs
parents: 388
diff changeset
342 void
74fd4e045ea6 Import from CVS: tag r21-2-29
cvs
parents: 388
diff changeset
343 update_widget (Lisp_Object widget)
74fd4e045ea6 Import from CVS: tag r21-2-29
cvs
parents: 388
diff changeset
344 {
74fd4e045ea6 Import from CVS: tag r21-2-29
cvs
parents: 388
diff changeset
345 Lisp_Image_Instance* ii = XIMAGE_INSTANCE (widget);
74fd4e045ea6 Import from CVS: tag r21-2-29
cvs
parents: 388
diff changeset
346 struct image_instantiator_methods* meths;
74fd4e045ea6 Import from CVS: tag r21-2-29
cvs
parents: 388
diff changeset
347
408
501cfd01ee6d Import from CVS: tag r21-2-34
cvs
parents: 406
diff changeset
348 if (!WIDGET_IMAGE_INSTANCEP (widget)
501cfd01ee6d Import from CVS: tag r21-2-34
cvs
parents: 406
diff changeset
349 || EQ (IMAGE_INSTANCE_WIDGET_TYPE (ii), Qlayout)
501cfd01ee6d Import from CVS: tag r21-2-34
cvs
parents: 406
diff changeset
350 || EQ (IMAGE_INSTANCE_WIDGET_TYPE (ii), Qnative_layout))
398
74fd4e045ea6 Import from CVS: tag r21-2-29
cvs
parents: 388
diff changeset
351 return;
74fd4e045ea6 Import from CVS: tag r21-2-29
cvs
parents: 388
diff changeset
352
74fd4e045ea6 Import from CVS: tag r21-2-29
cvs
parents: 388
diff changeset
353 /* Device generic methods. We must update the widget's size as it
74fd4e045ea6 Import from CVS: tag r21-2-29
cvs
parents: 388
diff changeset
354 may have been changed by the the layout routines. We also do this
74fd4e045ea6 Import from CVS: tag r21-2-29
cvs
parents: 388
diff changeset
355 here so that explicit resizing from lisp does not result in
74fd4e045ea6 Import from CVS: tag r21-2-29
cvs
parents: 388
diff changeset
356 synchronous updates. */
408
501cfd01ee6d Import from CVS: tag r21-2-34
cvs
parents: 406
diff changeset
357 MAYBE_DEVMETH (DOMAIN_XDEVICE (ii->domain), update_widget, (ii));
398
74fd4e045ea6 Import from CVS: tag r21-2-29
cvs
parents: 388
diff changeset
358
74fd4e045ea6 Import from CVS: tag r21-2-29
cvs
parents: 388
diff changeset
359 /* Device-format specific methods */
408
501cfd01ee6d Import from CVS: tag r21-2-34
cvs
parents: 406
diff changeset
360 meths = decode_device_ii_format (image_instance_device (widget),
398
74fd4e045ea6 Import from CVS: tag r21-2-29
cvs
parents: 388
diff changeset
361 IMAGE_INSTANCE_WIDGET_TYPE (ii),
74fd4e045ea6 Import from CVS: tag r21-2-29
cvs
parents: 388
diff changeset
362 ERROR_ME_NOT);
74fd4e045ea6 Import from CVS: tag r21-2-29
cvs
parents: 388
diff changeset
363 MAYBE_IIFORMAT_METH (meths, update, (widget));
406
b8cc9ab3f761 Import from CVS: tag r21-2-33
cvs
parents: 404
diff changeset
364
b8cc9ab3f761 Import from CVS: tag r21-2-33
cvs
parents: 404
diff changeset
365 /* Pick up the items we recorded earlier. */
b8cc9ab3f761 Import from CVS: tag r21-2-33
cvs
parents: 404
diff changeset
366 if (IMAGE_INSTANCE_WIDGET_ITEMS_CHANGED (ii))
b8cc9ab3f761 Import from CVS: tag r21-2-33
cvs
parents: 404
diff changeset
367 {
b8cc9ab3f761 Import from CVS: tag r21-2-33
cvs
parents: 404
diff changeset
368 IMAGE_INSTANCE_WIDGET_ITEMS (ii) =
b8cc9ab3f761 Import from CVS: tag r21-2-33
cvs
parents: 404
diff changeset
369 IMAGE_INSTANCE_WIDGET_PENDING_ITEMS (ii);
b8cc9ab3f761 Import from CVS: tag r21-2-33
cvs
parents: 404
diff changeset
370 IMAGE_INSTANCE_WIDGET_PENDING_ITEMS (ii) = Qnil;
b8cc9ab3f761 Import from CVS: tag r21-2-33
cvs
parents: 404
diff changeset
371 }
398
74fd4e045ea6 Import from CVS: tag r21-2-29
cvs
parents: 388
diff changeset
372 }
74fd4e045ea6 Import from CVS: tag r21-2-29
cvs
parents: 388
diff changeset
373
74fd4e045ea6 Import from CVS: tag r21-2-29
cvs
parents: 388
diff changeset
374 /* Query for a widgets desired geometry. If no type specific method is
74fd4e045ea6 Import from CVS: tag r21-2-29
cvs
parents: 388
diff changeset
375 provided then use the widget text to calculate sizes. */
74fd4e045ea6 Import from CVS: tag r21-2-29
cvs
parents: 388
diff changeset
376 static void
74fd4e045ea6 Import from CVS: tag r21-2-29
cvs
parents: 388
diff changeset
377 widget_query_geometry (Lisp_Object image_instance,
74fd4e045ea6 Import from CVS: tag r21-2-29
cvs
parents: 388
diff changeset
378 unsigned int* width, unsigned int* height,
74fd4e045ea6 Import from CVS: tag r21-2-29
cvs
parents: 388
diff changeset
379 enum image_instance_geometry disp, Lisp_Object domain)
74fd4e045ea6 Import from CVS: tag r21-2-29
cvs
parents: 388
diff changeset
380 {
74fd4e045ea6 Import from CVS: tag r21-2-29
cvs
parents: 388
diff changeset
381 Lisp_Image_Instance* ii = XIMAGE_INSTANCE (image_instance);
74fd4e045ea6 Import from CVS: tag r21-2-29
cvs
parents: 388
diff changeset
382 struct image_instantiator_methods* meths;
404
2f8bb876ab1d Import from CVS: tag r21-2-32
cvs
parents: 400
diff changeset
383 Lisp_Object dynamic_width = Qnil;
2f8bb876ab1d Import from CVS: tag r21-2-32
cvs
parents: 400
diff changeset
384 Lisp_Object dynamic_height = Qnil;
398
74fd4e045ea6 Import from CVS: tag r21-2-29
cvs
parents: 388
diff changeset
385
74fd4e045ea6 Import from CVS: tag r21-2-29
cvs
parents: 388
diff changeset
386 /* First just set up what we already have. */
74fd4e045ea6 Import from CVS: tag r21-2-29
cvs
parents: 388
diff changeset
387 if (width) *width = IMAGE_INSTANCE_WIDTH (ii);
74fd4e045ea6 Import from CVS: tag r21-2-29
cvs
parents: 388
diff changeset
388 if (height) *height = IMAGE_INSTANCE_HEIGHT (ii);
74fd4e045ea6 Import from CVS: tag r21-2-29
cvs
parents: 388
diff changeset
389
74fd4e045ea6 Import from CVS: tag r21-2-29
cvs
parents: 388
diff changeset
390 if (IMAGE_INSTANCE_SUBWINDOW_V_RESIZEP (ii)
74fd4e045ea6 Import from CVS: tag r21-2-29
cvs
parents: 388
diff changeset
391 ||
74fd4e045ea6 Import from CVS: tag r21-2-29
cvs
parents: 388
diff changeset
392 IMAGE_INSTANCE_SUBWINDOW_H_RESIZEP (ii))
74fd4e045ea6 Import from CVS: tag r21-2-29
cvs
parents: 388
diff changeset
393 {
74fd4e045ea6 Import from CVS: tag r21-2-29
cvs
parents: 388
diff changeset
394 /* .. then try device specific methods ... */
408
501cfd01ee6d Import from CVS: tag r21-2-34
cvs
parents: 406
diff changeset
395 meths = decode_device_ii_format (image_instance_device (image_instance),
398
74fd4e045ea6 Import from CVS: tag r21-2-29
cvs
parents: 388
diff changeset
396 IMAGE_INSTANCE_WIDGET_TYPE (ii),
74fd4e045ea6 Import from CVS: tag r21-2-29
cvs
parents: 388
diff changeset
397 ERROR_ME_NOT);
74fd4e045ea6 Import from CVS: tag r21-2-29
cvs
parents: 388
diff changeset
398 if (meths && HAS_IIFORMAT_METH_P (meths, query_geometry))
74fd4e045ea6 Import from CVS: tag r21-2-29
cvs
parents: 388
diff changeset
399 IIFORMAT_METH (meths, query_geometry, (image_instance,
74fd4e045ea6 Import from CVS: tag r21-2-29
cvs
parents: 388
diff changeset
400 width, height, disp,
74fd4e045ea6 Import from CVS: tag r21-2-29
cvs
parents: 388
diff changeset
401 domain));
74fd4e045ea6 Import from CVS: tag r21-2-29
cvs
parents: 388
diff changeset
402 else
74fd4e045ea6 Import from CVS: tag r21-2-29
cvs
parents: 388
diff changeset
403 {
74fd4e045ea6 Import from CVS: tag r21-2-29
cvs
parents: 388
diff changeset
404 /* ... then format specific methods ... */
74fd4e045ea6 Import from CVS: tag r21-2-29
cvs
parents: 388
diff changeset
405 meths = decode_device_ii_format (Qnil, IMAGE_INSTANCE_WIDGET_TYPE (ii),
74fd4e045ea6 Import from CVS: tag r21-2-29
cvs
parents: 388
diff changeset
406 ERROR_ME_NOT);
74fd4e045ea6 Import from CVS: tag r21-2-29
cvs
parents: 388
diff changeset
407 if (meths && HAS_IIFORMAT_METH_P (meths, query_geometry))
74fd4e045ea6 Import from CVS: tag r21-2-29
cvs
parents: 388
diff changeset
408 IIFORMAT_METH (meths, query_geometry, (image_instance,
74fd4e045ea6 Import from CVS: tag r21-2-29
cvs
parents: 388
diff changeset
409 width, height, disp,
74fd4e045ea6 Import from CVS: tag r21-2-29
cvs
parents: 388
diff changeset
410 domain));
74fd4e045ea6 Import from CVS: tag r21-2-29
cvs
parents: 388
diff changeset
411 else
74fd4e045ea6 Import from CVS: tag r21-2-29
cvs
parents: 388
diff changeset
412 {
74fd4e045ea6 Import from CVS: tag r21-2-29
cvs
parents: 388
diff changeset
413 unsigned int w, h;
74fd4e045ea6 Import from CVS: tag r21-2-29
cvs
parents: 388
diff changeset
414
74fd4e045ea6 Import from CVS: tag r21-2-29
cvs
parents: 388
diff changeset
415 /* Then if we are allowed to resize the widget, make the
74fd4e045ea6 Import from CVS: tag r21-2-29
cvs
parents: 388
diff changeset
416 size the same as the text dimensions. */
74fd4e045ea6 Import from CVS: tag r21-2-29
cvs
parents: 388
diff changeset
417 query_string_geometry (IMAGE_INSTANCE_WIDGET_TEXT (ii),
74fd4e045ea6 Import from CVS: tag r21-2-29
cvs
parents: 388
diff changeset
418 IMAGE_INSTANCE_WIDGET_FACE (ii),
74fd4e045ea6 Import from CVS: tag r21-2-29
cvs
parents: 388
diff changeset
419 &w, &h, 0, domain);
74fd4e045ea6 Import from CVS: tag r21-2-29
cvs
parents: 388
diff changeset
420 /* Adjust the size for borders. */
74fd4e045ea6 Import from CVS: tag r21-2-29
cvs
parents: 388
diff changeset
421 if (IMAGE_INSTANCE_SUBWINDOW_H_RESIZEP (ii))
74fd4e045ea6 Import from CVS: tag r21-2-29
cvs
parents: 388
diff changeset
422 *width = w + 2 * WIDGET_BORDER_WIDTH;
74fd4e045ea6 Import from CVS: tag r21-2-29
cvs
parents: 388
diff changeset
423 if (IMAGE_INSTANCE_SUBWINDOW_V_RESIZEP (ii))
74fd4e045ea6 Import from CVS: tag r21-2-29
cvs
parents: 388
diff changeset
424 *height = h + 2 * WIDGET_BORDER_HEIGHT;
74fd4e045ea6 Import from CVS: tag r21-2-29
cvs
parents: 388
diff changeset
425 }
74fd4e045ea6 Import from CVS: tag r21-2-29
cvs
parents: 388
diff changeset
426 }
404
2f8bb876ab1d Import from CVS: tag r21-2-32
cvs
parents: 400
diff changeset
427 /* Finish off with dynamic sizing. */
2f8bb876ab1d Import from CVS: tag r21-2-32
cvs
parents: 400
diff changeset
428 if (!NILP (IMAGE_INSTANCE_WIDGET_WIDTH_SUBR (ii)))
2f8bb876ab1d Import from CVS: tag r21-2-32
cvs
parents: 400
diff changeset
429 {
2f8bb876ab1d Import from CVS: tag r21-2-32
cvs
parents: 400
diff changeset
430 dynamic_width = Feval (IMAGE_INSTANCE_WIDGET_WIDTH_SUBR (ii));
2f8bb876ab1d Import from CVS: tag r21-2-32
cvs
parents: 400
diff changeset
431 if (INTP (dynamic_width))
2f8bb876ab1d Import from CVS: tag r21-2-32
cvs
parents: 400
diff changeset
432 *width = XINT (dynamic_width);
2f8bb876ab1d Import from CVS: tag r21-2-32
cvs
parents: 400
diff changeset
433 }
2f8bb876ab1d Import from CVS: tag r21-2-32
cvs
parents: 400
diff changeset
434 if (!NILP (IMAGE_INSTANCE_WIDGET_HEIGHT_SUBR (ii)))
2f8bb876ab1d Import from CVS: tag r21-2-32
cvs
parents: 400
diff changeset
435 {
2f8bb876ab1d Import from CVS: tag r21-2-32
cvs
parents: 400
diff changeset
436 dynamic_height = Feval (IMAGE_INSTANCE_WIDGET_HEIGHT_SUBR (ii));
2f8bb876ab1d Import from CVS: tag r21-2-32
cvs
parents: 400
diff changeset
437 if (INTP (dynamic_height))
2f8bb876ab1d Import from CVS: tag r21-2-32
cvs
parents: 400
diff changeset
438 *height = XINT (dynamic_height);
2f8bb876ab1d Import from CVS: tag r21-2-32
cvs
parents: 400
diff changeset
439 }
398
74fd4e045ea6 Import from CVS: tag r21-2-29
cvs
parents: 388
diff changeset
440 }
74fd4e045ea6 Import from CVS: tag r21-2-29
cvs
parents: 388
diff changeset
441 }
74fd4e045ea6 Import from CVS: tag r21-2-29
cvs
parents: 388
diff changeset
442
408
501cfd01ee6d Import from CVS: tag r21-2-34
cvs
parents: 406
diff changeset
443 static int
398
74fd4e045ea6 Import from CVS: tag r21-2-29
cvs
parents: 388
diff changeset
444 widget_layout (Lisp_Object image_instance,
74fd4e045ea6 Import from CVS: tag r21-2-29
cvs
parents: 388
diff changeset
445 unsigned int width, unsigned int height, Lisp_Object domain)
74fd4e045ea6 Import from CVS: tag r21-2-29
cvs
parents: 388
diff changeset
446 {
74fd4e045ea6 Import from CVS: tag r21-2-29
cvs
parents: 388
diff changeset
447 Lisp_Image_Instance* ii = XIMAGE_INSTANCE (image_instance);
74fd4e045ea6 Import from CVS: tag r21-2-29
cvs
parents: 388
diff changeset
448 struct image_instantiator_methods* meths;
74fd4e045ea6 Import from CVS: tag r21-2-29
cvs
parents: 388
diff changeset
449
74fd4e045ea6 Import from CVS: tag r21-2-29
cvs
parents: 388
diff changeset
450 /* .. then try device specific methods ... */
408
501cfd01ee6d Import from CVS: tag r21-2-34
cvs
parents: 406
diff changeset
451 meths = decode_device_ii_format (image_instance_device (image_instance),
398
74fd4e045ea6 Import from CVS: tag r21-2-29
cvs
parents: 388
diff changeset
452 IMAGE_INSTANCE_WIDGET_TYPE (ii),
74fd4e045ea6 Import from CVS: tag r21-2-29
cvs
parents: 388
diff changeset
453 ERROR_ME_NOT);
74fd4e045ea6 Import from CVS: tag r21-2-29
cvs
parents: 388
diff changeset
454 if (meths && HAS_IIFORMAT_METH_P (meths, layout))
408
501cfd01ee6d Import from CVS: tag r21-2-34
cvs
parents: 406
diff changeset
455 return IIFORMAT_METH (meths, layout, (image_instance,
501cfd01ee6d Import from CVS: tag r21-2-34
cvs
parents: 406
diff changeset
456 width, height, domain));
398
74fd4e045ea6 Import from CVS: tag r21-2-29
cvs
parents: 388
diff changeset
457 else
74fd4e045ea6 Import from CVS: tag r21-2-29
cvs
parents: 388
diff changeset
458 {
74fd4e045ea6 Import from CVS: tag r21-2-29
cvs
parents: 388
diff changeset
459 /* ... then format specific methods ... */
74fd4e045ea6 Import from CVS: tag r21-2-29
cvs
parents: 388
diff changeset
460 meths = decode_device_ii_format (Qnil, IMAGE_INSTANCE_WIDGET_TYPE (ii),
74fd4e045ea6 Import from CVS: tag r21-2-29
cvs
parents: 388
diff changeset
461 ERROR_ME_NOT);
74fd4e045ea6 Import from CVS: tag r21-2-29
cvs
parents: 388
diff changeset
462 if (meths && HAS_IIFORMAT_METH_P (meths, layout))
408
501cfd01ee6d Import from CVS: tag r21-2-34
cvs
parents: 406
diff changeset
463 return IIFORMAT_METH (meths, layout, (image_instance,
501cfd01ee6d Import from CVS: tag r21-2-34
cvs
parents: 406
diff changeset
464 width, height, domain));
398
74fd4e045ea6 Import from CVS: tag r21-2-29
cvs
parents: 388
diff changeset
465 }
408
501cfd01ee6d Import from CVS: tag r21-2-34
cvs
parents: 406
diff changeset
466 return 1;
398
74fd4e045ea6 Import from CVS: tag r21-2-29
cvs
parents: 388
diff changeset
467 }
74fd4e045ea6 Import from CVS: tag r21-2-29
cvs
parents: 388
diff changeset
468
384
bbff43aa5eb7 Import from CVS: tag r21-2-7
cvs
parents:
diff changeset
469 static void
bbff43aa5eb7 Import from CVS: tag r21-2-7
cvs
parents:
diff changeset
470 widget_validate (Lisp_Object instantiator)
bbff43aa5eb7 Import from CVS: tag r21-2-7
cvs
parents:
diff changeset
471 {
bbff43aa5eb7 Import from CVS: tag r21-2-7
cvs
parents:
diff changeset
472 Lisp_Object desc = find_keyword_in_vector (instantiator, Q_descriptor);
398
74fd4e045ea6 Import from CVS: tag r21-2-29
cvs
parents: 388
diff changeset
473
384
bbff43aa5eb7 Import from CVS: tag r21-2-7
cvs
parents:
diff changeset
474 if (NILP (desc))
bbff43aa5eb7 Import from CVS: tag r21-2-7
cvs
parents:
diff changeset
475 signal_simple_error ("Must supply :descriptor", instantiator);
bbff43aa5eb7 Import from CVS: tag r21-2-7
cvs
parents:
diff changeset
476
388
aabb7f5b1c81 Import from CVS: tag r21-2-9
cvs
parents: 384
diff changeset
477 if (VECTORP (desc))
398
74fd4e045ea6 Import from CVS: tag r21-2-29
cvs
parents: 388
diff changeset
478 gui_parse_item_keywords (desc);
384
bbff43aa5eb7 Import from CVS: tag r21-2-7
cvs
parents:
diff changeset
479
bbff43aa5eb7 Import from CVS: tag r21-2-7
cvs
parents:
diff changeset
480 if (!NILP (find_keyword_in_vector (instantiator, Q_width))
398
74fd4e045ea6 Import from CVS: tag r21-2-29
cvs
parents: 388
diff changeset
481 && !NILP (find_keyword_in_vector (instantiator, Q_pixel_width)))
384
bbff43aa5eb7 Import from CVS: tag r21-2-7
cvs
parents:
diff changeset
482 signal_simple_error ("Must supply only one of :width and :pixel-width", instantiator);
bbff43aa5eb7 Import from CVS: tag r21-2-7
cvs
parents:
diff changeset
483
bbff43aa5eb7 Import from CVS: tag r21-2-7
cvs
parents:
diff changeset
484 if (!NILP (find_keyword_in_vector (instantiator, Q_height))
bbff43aa5eb7 Import from CVS: tag r21-2-7
cvs
parents:
diff changeset
485 && !NILP (find_keyword_in_vector (instantiator, Q_pixel_height)))
bbff43aa5eb7 Import from CVS: tag r21-2-7
cvs
parents:
diff changeset
486 signal_simple_error ("Must supply only one of :height and :pixel-height", instantiator);
bbff43aa5eb7 Import from CVS: tag r21-2-7
cvs
parents:
diff changeset
487 }
bbff43aa5eb7 Import from CVS: tag r21-2-7
cvs
parents:
diff changeset
488
bbff43aa5eb7 Import from CVS: tag r21-2-7
cvs
parents:
diff changeset
489 static void
398
74fd4e045ea6 Import from CVS: tag r21-2-29
cvs
parents: 388
diff changeset
490 combo_box_validate (Lisp_Object instantiator)
384
bbff43aa5eb7 Import from CVS: tag r21-2-7
cvs
parents:
diff changeset
491 {
bbff43aa5eb7 Import from CVS: tag r21-2-7
cvs
parents:
diff changeset
492 widget_validate (instantiator);
bbff43aa5eb7 Import from CVS: tag r21-2-7
cvs
parents:
diff changeset
493 if (NILP (find_keyword_in_vector (instantiator, Q_properties)))
bbff43aa5eb7 Import from CVS: tag r21-2-7
cvs
parents:
diff changeset
494 signal_simple_error ("Must supply item list", instantiator);
bbff43aa5eb7 Import from CVS: tag r21-2-7
cvs
parents:
diff changeset
495 }
bbff43aa5eb7 Import from CVS: tag r21-2-7
cvs
parents:
diff changeset
496
388
aabb7f5b1c81 Import from CVS: tag r21-2-9
cvs
parents: 384
diff changeset
497 /* we need to convert things like glyphs to images, eval expressions
aabb7f5b1c81 Import from CVS: tag r21-2-9
cvs
parents: 384
diff changeset
498 etc.*/
aabb7f5b1c81 Import from CVS: tag r21-2-9
cvs
parents: 384
diff changeset
499 static Lisp_Object
aabb7f5b1c81 Import from CVS: tag r21-2-9
cvs
parents: 384
diff changeset
500 widget_normalize (Lisp_Object inst, Lisp_Object console_type)
aabb7f5b1c81 Import from CVS: tag r21-2-9
cvs
parents: 384
diff changeset
501 {
aabb7f5b1c81 Import from CVS: tag r21-2-9
cvs
parents: 384
diff changeset
502 /* This function can call lisp */
aabb7f5b1c81 Import from CVS: tag r21-2-9
cvs
parents: 384
diff changeset
503 Lisp_Object glyph = find_keyword_in_vector (inst, Q_image);
aabb7f5b1c81 Import from CVS: tag r21-2-9
cvs
parents: 384
diff changeset
504
aabb7f5b1c81 Import from CVS: tag r21-2-9
cvs
parents: 384
diff changeset
505 /* we need to eval glyph if its an expression, we do this for the
aabb7f5b1c81 Import from CVS: tag r21-2-9
cvs
parents: 384
diff changeset
506 same reasons we normalize file to data. */
aabb7f5b1c81 Import from CVS: tag r21-2-9
cvs
parents: 384
diff changeset
507 if (!NILP (glyph))
aabb7f5b1c81 Import from CVS: tag r21-2-9
cvs
parents: 384
diff changeset
508 {
398
74fd4e045ea6 Import from CVS: tag r21-2-29
cvs
parents: 388
diff changeset
509 substitute_keyword_value (inst, Q_image, glyph_instantiator_to_glyph (glyph));
74fd4e045ea6 Import from CVS: tag r21-2-29
cvs
parents: 388
diff changeset
510 }
388
aabb7f5b1c81 Import from CVS: tag r21-2-9
cvs
parents: 384
diff changeset
511
aabb7f5b1c81 Import from CVS: tag r21-2-9
cvs
parents: 384
diff changeset
512 return inst;
aabb7f5b1c81 Import from CVS: tag r21-2-9
cvs
parents: 384
diff changeset
513 }
aabb7f5b1c81 Import from CVS: tag r21-2-9
cvs
parents: 384
diff changeset
514
384
bbff43aa5eb7 Import from CVS: tag r21-2-7
cvs
parents:
diff changeset
515 static void
398
74fd4e045ea6 Import from CVS: tag r21-2-29
cvs
parents: 388
diff changeset
516 initialize_widget_image_instance (Lisp_Image_Instance *ii, Lisp_Object type)
384
bbff43aa5eb7 Import from CVS: tag r21-2-7
cvs
parents:
diff changeset
517 {
bbff43aa5eb7 Import from CVS: tag r21-2-7
cvs
parents:
diff changeset
518 /* initialize_subwindow_image_instance (ii);*/
bbff43aa5eb7 Import from CVS: tag r21-2-7
cvs
parents:
diff changeset
519 IMAGE_INSTANCE_WIDGET_TYPE (ii) = type;
bbff43aa5eb7 Import from CVS: tag r21-2-7
cvs
parents:
diff changeset
520 IMAGE_INSTANCE_WIDGET_PROPS (ii) = Qnil;
398
74fd4e045ea6 Import from CVS: tag r21-2-29
cvs
parents: 388
diff changeset
521 SET_IMAGE_INSTANCE_WIDGET_FACE (ii, Qnil);
74fd4e045ea6 Import from CVS: tag r21-2-29
cvs
parents: 388
diff changeset
522 IMAGE_INSTANCE_WIDGET_ITEMS (ii) = allocate_gui_item ();
408
501cfd01ee6d Import from CVS: tag r21-2-34
cvs
parents: 406
diff changeset
523 IMAGE_INSTANCE_LAYOUT_CHILDREN (ii) = Qnil;
404
2f8bb876ab1d Import from CVS: tag r21-2-32
cvs
parents: 400
diff changeset
524 IMAGE_INSTANCE_WIDGET_PENDING_ITEMS (ii) = Qnil;
2f8bb876ab1d Import from CVS: tag r21-2-32
cvs
parents: 400
diff changeset
525 IMAGE_INSTANCE_WIDGET_WIDTH_SUBR (ii) = Qnil;
2f8bb876ab1d Import from CVS: tag r21-2-32
cvs
parents: 400
diff changeset
526 IMAGE_INSTANCE_WIDGET_HEIGHT_SUBR (ii) = Qnil;
398
74fd4e045ea6 Import from CVS: tag r21-2-29
cvs
parents: 388
diff changeset
527 IMAGE_INSTANCE_SUBWINDOW_H_RESIZEP (ii) = 1;
74fd4e045ea6 Import from CVS: tag r21-2-29
cvs
parents: 388
diff changeset
528 IMAGE_INSTANCE_SUBWINDOW_V_RESIZEP (ii) = 1;
406
b8cc9ab3f761 Import from CVS: tag r21-2-33
cvs
parents: 404
diff changeset
529 IMAGE_INSTANCE_SUBWINDOW_ORIENT (ii) = LAYOUT_HORIZONTAL;
398
74fd4e045ea6 Import from CVS: tag r21-2-29
cvs
parents: 388
diff changeset
530 IMAGE_INSTANCE_SUBWINDOW_JUSTIFY (ii) = 0;
384
bbff43aa5eb7 Import from CVS: tag r21-2-7
cvs
parents:
diff changeset
531 }
bbff43aa5eb7 Import from CVS: tag r21-2-7
cvs
parents:
diff changeset
532
bbff43aa5eb7 Import from CVS: tag r21-2-7
cvs
parents:
diff changeset
533 /* Instantiate a button widget. Unfortunately instantiated widgets are
bbff43aa5eb7 Import from CVS: tag r21-2-7
cvs
parents:
diff changeset
534 particular to a frame since they need to have a parent. It's not
bbff43aa5eb7 Import from CVS: tag r21-2-7
cvs
parents:
diff changeset
535 like images where you just select the image into the context you
398
74fd4e045ea6 Import from CVS: tag r21-2-29
cvs
parents: 388
diff changeset
536 want to display it in and BitBlt it. So image instances can have a
384
bbff43aa5eb7 Import from CVS: tag r21-2-7
cvs
parents:
diff changeset
537 many-to-one relationship with things you see, whereas widgets can
bbff43aa5eb7 Import from CVS: tag r21-2-7
cvs
parents:
diff changeset
538 only be one-to-one (i.e. per frame) */
398
74fd4e045ea6 Import from CVS: tag r21-2-29
cvs
parents: 388
diff changeset
539 void
74fd4e045ea6 Import from CVS: tag r21-2-29
cvs
parents: 388
diff changeset
540 widget_instantiate (Lisp_Object image_instance, Lisp_Object instantiator,
74fd4e045ea6 Import from CVS: tag r21-2-29
cvs
parents: 388
diff changeset
541 Lisp_Object pointer_fg, Lisp_Object pointer_bg,
74fd4e045ea6 Import from CVS: tag r21-2-29
cvs
parents: 388
diff changeset
542 int dest_mask, Lisp_Object domain)
384
bbff43aa5eb7 Import from CVS: tag r21-2-7
cvs
parents:
diff changeset
543 {
398
74fd4e045ea6 Import from CVS: tag r21-2-29
cvs
parents: 388
diff changeset
544 Lisp_Image_Instance *ii = XIMAGE_INSTANCE (image_instance);
384
bbff43aa5eb7 Import from CVS: tag r21-2-7
cvs
parents:
diff changeset
545 Lisp_Object face = find_keyword_in_vector (instantiator, Q_face);
bbff43aa5eb7 Import from CVS: tag r21-2-7
cvs
parents:
diff changeset
546 Lisp_Object height = find_keyword_in_vector (instantiator, Q_height);
bbff43aa5eb7 Import from CVS: tag r21-2-7
cvs
parents:
diff changeset
547 Lisp_Object width = find_keyword_in_vector (instantiator, Q_width);
bbff43aa5eb7 Import from CVS: tag r21-2-7
cvs
parents:
diff changeset
548 Lisp_Object pixwidth = find_keyword_in_vector (instantiator, Q_pixel_width);
bbff43aa5eb7 Import from CVS: tag r21-2-7
cvs
parents:
diff changeset
549 Lisp_Object pixheight = find_keyword_in_vector (instantiator, Q_pixel_height);
bbff43aa5eb7 Import from CVS: tag r21-2-7
cvs
parents:
diff changeset
550 Lisp_Object desc = find_keyword_in_vector (instantiator, Q_descriptor);
388
aabb7f5b1c81 Import from CVS: tag r21-2-9
cvs
parents: 384
diff changeset
551 Lisp_Object glyph = find_keyword_in_vector (instantiator, Q_image);
398
74fd4e045ea6 Import from CVS: tag r21-2-29
cvs
parents: 388
diff changeset
552 Lisp_Object props = find_keyword_in_vector (instantiator, Q_properties);
74fd4e045ea6 Import from CVS: tag r21-2-29
cvs
parents: 388
diff changeset
553 Lisp_Object items = find_keyword_in_vector (instantiator, Q_items);
74fd4e045ea6 Import from CVS: tag r21-2-29
cvs
parents: 388
diff changeset
554 Lisp_Object orient = find_keyword_in_vector (instantiator, Q_orientation);
408
501cfd01ee6d Import from CVS: tag r21-2-34
cvs
parents: 406
diff changeset
555 Lisp_Object mwidth = find_keyword_in_vector (instantiator, Q_margin_width);
384
bbff43aa5eb7 Import from CVS: tag r21-2-7
cvs
parents:
diff changeset
556 int pw=0, ph=0, tw=0, th=0;
bbff43aa5eb7 Import from CVS: tag r21-2-7
cvs
parents:
diff changeset
557
bbff43aa5eb7 Import from CVS: tag r21-2-7
cvs
parents:
diff changeset
558 /* this just does pixel type sizing */
bbff43aa5eb7 Import from CVS: tag r21-2-7
cvs
parents:
diff changeset
559 subwindow_instantiate (image_instance, instantiator, pointer_fg, pointer_bg,
bbff43aa5eb7 Import from CVS: tag r21-2-7
cvs
parents:
diff changeset
560 dest_mask, domain);
408
501cfd01ee6d Import from CVS: tag r21-2-34
cvs
parents: 406
diff changeset
561
501cfd01ee6d Import from CVS: tag r21-2-34
cvs
parents: 406
diff changeset
562 if (!(dest_mask & IMAGE_WIDGET_MASK))
501cfd01ee6d Import from CVS: tag r21-2-34
cvs
parents: 406
diff changeset
563 incompatible_image_types (instantiator, dest_mask, IMAGE_WIDGET_MASK);
384
bbff43aa5eb7 Import from CVS: tag r21-2-7
cvs
parents:
diff changeset
564
bbff43aa5eb7 Import from CVS: tag r21-2-7
cvs
parents:
diff changeset
565 initialize_widget_image_instance (ii, XVECTOR_DATA (instantiator)[0]);
bbff43aa5eb7 Import from CVS: tag r21-2-7
cvs
parents:
diff changeset
566
398
74fd4e045ea6 Import from CVS: tag r21-2-29
cvs
parents: 388
diff changeset
567 IMAGE_INSTANCE_TYPE (ii) = IMAGE_WIDGET;
74fd4e045ea6 Import from CVS: tag r21-2-29
cvs
parents: 388
diff changeset
568 IMAGE_INSTANCE_WIDGET_PROPS (ii) = props;
74fd4e045ea6 Import from CVS: tag r21-2-29
cvs
parents: 388
diff changeset
569
384
bbff43aa5eb7 Import from CVS: tag r21-2-7
cvs
parents:
diff changeset
570 /* retrieve the fg and bg colors */
bbff43aa5eb7 Import from CVS: tag r21-2-7
cvs
parents:
diff changeset
571 if (!NILP (face))
398
74fd4e045ea6 Import from CVS: tag r21-2-29
cvs
parents: 388
diff changeset
572 SET_IMAGE_INSTANCE_WIDGET_FACE (ii, Fget_face (face));
384
bbff43aa5eb7 Import from CVS: tag r21-2-7
cvs
parents:
diff changeset
573
388
aabb7f5b1c81 Import from CVS: tag r21-2-9
cvs
parents: 384
diff changeset
574 /* retrieve the gui item information. This is easy if we have been
aabb7f5b1c81 Import from CVS: tag r21-2-9
cvs
parents: 384
diff changeset
575 provided with a vector, more difficult if we have just been given
aabb7f5b1c81 Import from CVS: tag r21-2-9
cvs
parents: 384
diff changeset
576 keywords */
408
501cfd01ee6d Import from CVS: tag r21-2-34
cvs
parents: 406
diff changeset
577 if (STRINGP (desc) || NILP (desc))
388
aabb7f5b1c81 Import from CVS: tag r21-2-9
cvs
parents: 384
diff changeset
578 {
aabb7f5b1c81 Import from CVS: tag r21-2-9
cvs
parents: 384
diff changeset
579 /* big cheat - we rely on the fact that a gui item looks like an instantiator */
398
74fd4e045ea6 Import from CVS: tag r21-2-29
cvs
parents: 388
diff changeset
580 IMAGE_INSTANCE_WIDGET_ITEMS (ii) =
74fd4e045ea6 Import from CVS: tag r21-2-29
cvs
parents: 388
diff changeset
581 gui_parse_item_keywords_no_errors (instantiator);
388
aabb7f5b1c81 Import from CVS: tag r21-2-9
cvs
parents: 384
diff changeset
582 IMAGE_INSTANCE_WIDGET_TEXT (ii) = desc;
aabb7f5b1c81 Import from CVS: tag r21-2-9
cvs
parents: 384
diff changeset
583 }
384
bbff43aa5eb7 Import from CVS: tag r21-2-7
cvs
parents:
diff changeset
584 else
398
74fd4e045ea6 Import from CVS: tag r21-2-29
cvs
parents: 388
diff changeset
585 IMAGE_INSTANCE_WIDGET_ITEMS (ii) =
74fd4e045ea6 Import from CVS: tag r21-2-29
cvs
parents: 388
diff changeset
586 gui_parse_item_keywords_no_errors (desc);
408
501cfd01ee6d Import from CVS: tag r21-2-34
cvs
parents: 406
diff changeset
587
398
74fd4e045ea6 Import from CVS: tag r21-2-29
cvs
parents: 388
diff changeset
588 /* Pick up the orientation before we do our first layout. */
74fd4e045ea6 Import from CVS: tag r21-2-29
cvs
parents: 388
diff changeset
589 if (EQ (orient, Qleft) || EQ (orient, Qright) || EQ (orient, Qvertical))
406
b8cc9ab3f761 Import from CVS: tag r21-2-33
cvs
parents: 404
diff changeset
590 IMAGE_INSTANCE_SUBWINDOW_ORIENT (ii) = LAYOUT_VERTICAL;
398
74fd4e045ea6 Import from CVS: tag r21-2-29
cvs
parents: 388
diff changeset
591
74fd4e045ea6 Import from CVS: tag r21-2-29
cvs
parents: 388
diff changeset
592 /* parse more gui items out of the properties */
74fd4e045ea6 Import from CVS: tag r21-2-29
cvs
parents: 388
diff changeset
593 if (!NILP (props)
408
501cfd01ee6d Import from CVS: tag r21-2-34
cvs
parents: 406
diff changeset
594 &&
501cfd01ee6d Import from CVS: tag r21-2-34
cvs
parents: 406
diff changeset
595 !EQ (IMAGE_INSTANCE_WIDGET_TYPE (ii), Qlayout)
501cfd01ee6d Import from CVS: tag r21-2-34
cvs
parents: 406
diff changeset
596 && !EQ (IMAGE_INSTANCE_WIDGET_TYPE (ii), Qnative_layout))
398
74fd4e045ea6 Import from CVS: tag r21-2-29
cvs
parents: 388
diff changeset
597 {
74fd4e045ea6 Import from CVS: tag r21-2-29
cvs
parents: 388
diff changeset
598 if (NILP (items))
74fd4e045ea6 Import from CVS: tag r21-2-29
cvs
parents: 388
diff changeset
599 {
74fd4e045ea6 Import from CVS: tag r21-2-29
cvs
parents: 388
diff changeset
600 items = Fplist_get (props, Q_items, Qnil);
74fd4e045ea6 Import from CVS: tag r21-2-29
cvs
parents: 388
diff changeset
601 }
74fd4e045ea6 Import from CVS: tag r21-2-29
cvs
parents: 388
diff changeset
602 if (!NILP (items))
74fd4e045ea6 Import from CVS: tag r21-2-29
cvs
parents: 388
diff changeset
603 {
74fd4e045ea6 Import from CVS: tag r21-2-29
cvs
parents: 388
diff changeset
604 IMAGE_INSTANCE_WIDGET_ITEMS (ii) =
74fd4e045ea6 Import from CVS: tag r21-2-29
cvs
parents: 388
diff changeset
605 Fcons (IMAGE_INSTANCE_WIDGET_ITEMS (ii),
74fd4e045ea6 Import from CVS: tag r21-2-29
cvs
parents: 388
diff changeset
606 parse_gui_item_tree_children (items));
74fd4e045ea6 Import from CVS: tag r21-2-29
cvs
parents: 388
diff changeset
607 }
74fd4e045ea6 Import from CVS: tag r21-2-29
cvs
parents: 388
diff changeset
608 }
384
bbff43aa5eb7 Import from CVS: tag r21-2-7
cvs
parents:
diff changeset
609
398
74fd4e045ea6 Import from CVS: tag r21-2-29
cvs
parents: 388
diff changeset
610 /* Normalize size information. We now only assign sizes if the user
74fd4e045ea6 Import from CVS: tag r21-2-29
cvs
parents: 388
diff changeset
611 gives us some explicitly, or there are some constraints that we
74fd4e045ea6 Import from CVS: tag r21-2-29
cvs
parents: 388
diff changeset
612 can't change later on. Otherwise we postpone sizing until query
74fd4e045ea6 Import from CVS: tag r21-2-29
cvs
parents: 388
diff changeset
613 geometry gets called. */
74fd4e045ea6 Import from CVS: tag r21-2-29
cvs
parents: 388
diff changeset
614 if (!NILP (pixwidth)) /* pixwidth takes precendent */
74fd4e045ea6 Import from CVS: tag r21-2-29
cvs
parents: 388
diff changeset
615 {
404
2f8bb876ab1d Import from CVS: tag r21-2-32
cvs
parents: 400
diff changeset
616 if (!INTP (pixwidth))
2f8bb876ab1d Import from CVS: tag r21-2-32
cvs
parents: 400
diff changeset
617 IMAGE_INSTANCE_WIDGET_WIDTH_SUBR (ii) = pixwidth;
2f8bb876ab1d Import from CVS: tag r21-2-32
cvs
parents: 400
diff changeset
618 else
2f8bb876ab1d Import from CVS: tag r21-2-32
cvs
parents: 400
diff changeset
619 {
2f8bb876ab1d Import from CVS: tag r21-2-32
cvs
parents: 400
diff changeset
620 pw = XINT (pixwidth);
2f8bb876ab1d Import from CVS: tag r21-2-32
cvs
parents: 400
diff changeset
621 IMAGE_INSTANCE_SUBWINDOW_H_RESIZEP (ii) = 0;
2f8bb876ab1d Import from CVS: tag r21-2-32
cvs
parents: 400
diff changeset
622 }
398
74fd4e045ea6 Import from CVS: tag r21-2-29
cvs
parents: 388
diff changeset
623 }
74fd4e045ea6 Import from CVS: tag r21-2-29
cvs
parents: 388
diff changeset
624 else if (!NILP (width))
74fd4e045ea6 Import from CVS: tag r21-2-29
cvs
parents: 388
diff changeset
625 {
74fd4e045ea6 Import from CVS: tag r21-2-29
cvs
parents: 388
diff changeset
626 tw = XINT (width);
74fd4e045ea6 Import from CVS: tag r21-2-29
cvs
parents: 388
diff changeset
627 IMAGE_INSTANCE_SUBWINDOW_H_RESIZEP (ii) = 0;
74fd4e045ea6 Import from CVS: tag r21-2-29
cvs
parents: 388
diff changeset
628 }
74fd4e045ea6 Import from CVS: tag r21-2-29
cvs
parents: 388
diff changeset
629
384
bbff43aa5eb7 Import from CVS: tag r21-2-7
cvs
parents:
diff changeset
630 if (!NILP (pixheight))
398
74fd4e045ea6 Import from CVS: tag r21-2-29
cvs
parents: 388
diff changeset
631 {
406
b8cc9ab3f761 Import from CVS: tag r21-2-33
cvs
parents: 404
diff changeset
632 if (!INTP (pixheight))
404
2f8bb876ab1d Import from CVS: tag r21-2-32
cvs
parents: 400
diff changeset
633 IMAGE_INSTANCE_WIDGET_HEIGHT_SUBR (ii) = pixheight;
2f8bb876ab1d Import from CVS: tag r21-2-32
cvs
parents: 400
diff changeset
634 else
2f8bb876ab1d Import from CVS: tag r21-2-32
cvs
parents: 400
diff changeset
635 {
2f8bb876ab1d Import from CVS: tag r21-2-32
cvs
parents: 400
diff changeset
636 ph = XINT (pixheight);
2f8bb876ab1d Import from CVS: tag r21-2-32
cvs
parents: 400
diff changeset
637 IMAGE_INSTANCE_SUBWINDOW_V_RESIZEP (ii) = 0;
2f8bb876ab1d Import from CVS: tag r21-2-32
cvs
parents: 400
diff changeset
638 }
398
74fd4e045ea6 Import from CVS: tag r21-2-29
cvs
parents: 388
diff changeset
639 }
74fd4e045ea6 Import from CVS: tag r21-2-29
cvs
parents: 388
diff changeset
640 else if (!NILP (height) && XINT (height) > 1)
74fd4e045ea6 Import from CVS: tag r21-2-29
cvs
parents: 388
diff changeset
641 {
74fd4e045ea6 Import from CVS: tag r21-2-29
cvs
parents: 388
diff changeset
642 th = XINT (height);
74fd4e045ea6 Import from CVS: tag r21-2-29
cvs
parents: 388
diff changeset
643 IMAGE_INSTANCE_SUBWINDOW_V_RESIZEP (ii) = 0;
74fd4e045ea6 Import from CVS: tag r21-2-29
cvs
parents: 388
diff changeset
644 }
74fd4e045ea6 Import from CVS: tag r21-2-29
cvs
parents: 388
diff changeset
645
74fd4e045ea6 Import from CVS: tag r21-2-29
cvs
parents: 388
diff changeset
646 /* Taking the default face information when the user has specified
74fd4e045ea6 Import from CVS: tag r21-2-29
cvs
parents: 388
diff changeset
647 size in characters is probably as good as any since the widget
74fd4e045ea6 Import from CVS: tag r21-2-29
cvs
parents: 388
diff changeset
648 face is more likely to be proportional and thus give inadequate
74fd4e045ea6 Import from CVS: tag r21-2-29
cvs
parents: 388
diff changeset
649 results. Using character sizes can only ever be approximate
74fd4e045ea6 Import from CVS: tag r21-2-29
cvs
parents: 388
diff changeset
650 anyway. */
74fd4e045ea6 Import from CVS: tag r21-2-29
cvs
parents: 388
diff changeset
651 if (tw || th)
74fd4e045ea6 Import from CVS: tag r21-2-29
cvs
parents: 388
diff changeset
652 {
74fd4e045ea6 Import from CVS: tag r21-2-29
cvs
parents: 388
diff changeset
653 int charwidth, charheight;
74fd4e045ea6 Import from CVS: tag r21-2-29
cvs
parents: 388
diff changeset
654 default_face_font_info (domain, 0, 0, &charheight, &charwidth, 0);
74fd4e045ea6 Import from CVS: tag r21-2-29
cvs
parents: 388
diff changeset
655 if (tw)
74fd4e045ea6 Import from CVS: tag r21-2-29
cvs
parents: 388
diff changeset
656 pw = charwidth * tw;
74fd4e045ea6 Import from CVS: tag r21-2-29
cvs
parents: 388
diff changeset
657 if (th)
74fd4e045ea6 Import from CVS: tag r21-2-29
cvs
parents: 388
diff changeset
658 ph = charheight * th;
74fd4e045ea6 Import from CVS: tag r21-2-29
cvs
parents: 388
diff changeset
659 }
384
bbff43aa5eb7 Import from CVS: tag r21-2-7
cvs
parents:
diff changeset
660
388
aabb7f5b1c81 Import from CVS: tag r21-2-9
cvs
parents: 384
diff changeset
661 /* for a widget with an image pick up the dimensions from that */
aabb7f5b1c81 Import from CVS: tag r21-2-9
cvs
parents: 384
diff changeset
662 if (!NILP (glyph))
aabb7f5b1c81 Import from CVS: tag r21-2-9
cvs
parents: 384
diff changeset
663 {
398
74fd4e045ea6 Import from CVS: tag r21-2-29
cvs
parents: 388
diff changeset
664 if (!pw)
74fd4e045ea6 Import from CVS: tag r21-2-29
cvs
parents: 388
diff changeset
665 pw = glyph_width (glyph, domain) + 2 * WIDGET_BORDER_WIDTH;
74fd4e045ea6 Import from CVS: tag r21-2-29
cvs
parents: 388
diff changeset
666 if (!ph)
74fd4e045ea6 Import from CVS: tag r21-2-29
cvs
parents: 388
diff changeset
667 ph = glyph_height (glyph, domain) + 2 * WIDGET_BORDER_HEIGHT;
74fd4e045ea6 Import from CVS: tag r21-2-29
cvs
parents: 388
diff changeset
668 IMAGE_INSTANCE_SUBWINDOW_V_RESIZEP (ii) = 0;
74fd4e045ea6 Import from CVS: tag r21-2-29
cvs
parents: 388
diff changeset
669 IMAGE_INSTANCE_SUBWINDOW_H_RESIZEP (ii) = 0;
74fd4e045ea6 Import from CVS: tag r21-2-29
cvs
parents: 388
diff changeset
670 }
74fd4e045ea6 Import from CVS: tag r21-2-29
cvs
parents: 388
diff changeset
671
408
501cfd01ee6d Import from CVS: tag r21-2-34
cvs
parents: 406
diff changeset
672 /* Pick up the margin width. */
501cfd01ee6d Import from CVS: tag r21-2-34
cvs
parents: 406
diff changeset
673 if (!NILP (mwidth))
501cfd01ee6d Import from CVS: tag r21-2-34
cvs
parents: 406
diff changeset
674 IMAGE_INSTANCE_MARGIN_WIDTH (ii) = XINT (mwidth);
398
74fd4e045ea6 Import from CVS: tag r21-2-29
cvs
parents: 388
diff changeset
675
408
501cfd01ee6d Import from CVS: tag r21-2-34
cvs
parents: 406
diff changeset
676 /* Layout for the layout widget is premature at this point since the
501cfd01ee6d Import from CVS: tag r21-2-34
cvs
parents: 406
diff changeset
677 children will not have been instantiated. We can't instantiate
501cfd01ee6d Import from CVS: tag r21-2-34
cvs
parents: 406
diff changeset
678 them until the device instantiation method for the layout has
501cfd01ee6d Import from CVS: tag r21-2-34
cvs
parents: 406
diff changeset
679 been executed. We do however want to record any specified
501cfd01ee6d Import from CVS: tag r21-2-34
cvs
parents: 406
diff changeset
680 dimensions. */
501cfd01ee6d Import from CVS: tag r21-2-34
cvs
parents: 406
diff changeset
681 if (pw) IMAGE_INSTANCE_WIDTH (ii) = pw;
501cfd01ee6d Import from CVS: tag r21-2-34
cvs
parents: 406
diff changeset
682 if (ph) IMAGE_INSTANCE_HEIGHT (ii) = ph;
501cfd01ee6d Import from CVS: tag r21-2-34
cvs
parents: 406
diff changeset
683 }
501cfd01ee6d Import from CVS: tag r21-2-34
cvs
parents: 406
diff changeset
684
501cfd01ee6d Import from CVS: tag r21-2-34
cvs
parents: 406
diff changeset
685 static void
501cfd01ee6d Import from CVS: tag r21-2-34
cvs
parents: 406
diff changeset
686 widget_post_instantiate (Lisp_Object image_instance, Lisp_Object instantiator,
501cfd01ee6d Import from CVS: tag r21-2-34
cvs
parents: 406
diff changeset
687 Lisp_Object domain)
501cfd01ee6d Import from CVS: tag r21-2-34
cvs
parents: 406
diff changeset
688 {
398
74fd4e045ea6 Import from CVS: tag r21-2-29
cvs
parents: 388
diff changeset
689 #ifdef DEBUG_WIDGETS
74fd4e045ea6 Import from CVS: tag r21-2-29
cvs
parents: 388
diff changeset
690 debug_widget_instances++;
74fd4e045ea6 Import from CVS: tag r21-2-29
cvs
parents: 388
diff changeset
691 stderr_out ("instantiated ");
74fd4e045ea6 Import from CVS: tag r21-2-29
cvs
parents: 388
diff changeset
692 debug_print (instantiator);
74fd4e045ea6 Import from CVS: tag r21-2-29
cvs
parents: 388
diff changeset
693 stderr_out ("%d widgets instantiated\n", debug_widget_instances);
74fd4e045ea6 Import from CVS: tag r21-2-29
cvs
parents: 388
diff changeset
694 #endif
74fd4e045ea6 Import from CVS: tag r21-2-29
cvs
parents: 388
diff changeset
695 }
74fd4e045ea6 Import from CVS: tag r21-2-29
cvs
parents: 388
diff changeset
696
406
b8cc9ab3f761 Import from CVS: tag r21-2-33
cvs
parents: 404
diff changeset
697 /* Get the geometry of a button control. We need to adjust the size
b8cc9ab3f761 Import from CVS: tag r21-2-33
cvs
parents: 404
diff changeset
698 depending on the type of button. */
b8cc9ab3f761 Import from CVS: tag r21-2-33
cvs
parents: 404
diff changeset
699 static void
b8cc9ab3f761 Import from CVS: tag r21-2-33
cvs
parents: 404
diff changeset
700 button_query_geometry (Lisp_Object image_instance,
b8cc9ab3f761 Import from CVS: tag r21-2-33
cvs
parents: 404
diff changeset
701 unsigned int* width, unsigned int* height,
b8cc9ab3f761 Import from CVS: tag r21-2-33
cvs
parents: 404
diff changeset
702 enum image_instance_geometry disp, Lisp_Object domain)
b8cc9ab3f761 Import from CVS: tag r21-2-33
cvs
parents: 404
diff changeset
703 {
b8cc9ab3f761 Import from CVS: tag r21-2-33
cvs
parents: 404
diff changeset
704 Lisp_Image_Instance *ii = XIMAGE_INSTANCE (image_instance);
b8cc9ab3f761 Import from CVS: tag r21-2-33
cvs
parents: 404
diff changeset
705 unsigned int w, h;
b8cc9ab3f761 Import from CVS: tag r21-2-33
cvs
parents: 404
diff changeset
706 query_string_geometry (IMAGE_INSTANCE_WIDGET_TEXT (ii),
b8cc9ab3f761 Import from CVS: tag r21-2-33
cvs
parents: 404
diff changeset
707 IMAGE_INSTANCE_WIDGET_FACE (ii),
b8cc9ab3f761 Import from CVS: tag r21-2-33
cvs
parents: 404
diff changeset
708 &w, &h, 0, domain);
b8cc9ab3f761 Import from CVS: tag r21-2-33
cvs
parents: 404
diff changeset
709 /* Adjust the size for borders. */
b8cc9ab3f761 Import from CVS: tag r21-2-33
cvs
parents: 404
diff changeset
710 if (IMAGE_INSTANCE_SUBWINDOW_H_RESIZEP (ii))
b8cc9ab3f761 Import from CVS: tag r21-2-33
cvs
parents: 404
diff changeset
711 {
b8cc9ab3f761 Import from CVS: tag r21-2-33
cvs
parents: 404
diff changeset
712 *width = w + 2 * WIDGET_BORDER_WIDTH;
b8cc9ab3f761 Import from CVS: tag r21-2-33
cvs
parents: 404
diff changeset
713
b8cc9ab3f761 Import from CVS: tag r21-2-33
cvs
parents: 404
diff changeset
714 if (EQ (XGUI_ITEM (IMAGE_INSTANCE_WIDGET_ITEM (ii))->style, Qradio)
b8cc9ab3f761 Import from CVS: tag r21-2-33
cvs
parents: 404
diff changeset
715 ||
b8cc9ab3f761 Import from CVS: tag r21-2-33
cvs
parents: 404
diff changeset
716 EQ (XGUI_ITEM (IMAGE_INSTANCE_WIDGET_ITEM (ii))->style, Qtoggle))
b8cc9ab3f761 Import from CVS: tag r21-2-33
cvs
parents: 404
diff changeset
717 /* This is an approximation to the size of the actual button bit. */
b8cc9ab3f761 Import from CVS: tag r21-2-33
cvs
parents: 404
diff changeset
718 *width += 12;
b8cc9ab3f761 Import from CVS: tag r21-2-33
cvs
parents: 404
diff changeset
719 }
b8cc9ab3f761 Import from CVS: tag r21-2-33
cvs
parents: 404
diff changeset
720 if (IMAGE_INSTANCE_SUBWINDOW_V_RESIZEP (ii))
b8cc9ab3f761 Import from CVS: tag r21-2-33
cvs
parents: 404
diff changeset
721 *height = h + 2 * WIDGET_BORDER_HEIGHT;
b8cc9ab3f761 Import from CVS: tag r21-2-33
cvs
parents: 404
diff changeset
722 }
b8cc9ab3f761 Import from CVS: tag r21-2-33
cvs
parents: 404
diff changeset
723
398
74fd4e045ea6 Import from CVS: tag r21-2-29
cvs
parents: 388
diff changeset
724 /* tree-view geometry - get the height right */
74fd4e045ea6 Import from CVS: tag r21-2-29
cvs
parents: 388
diff changeset
725 static void
74fd4e045ea6 Import from CVS: tag r21-2-29
cvs
parents: 388
diff changeset
726 tree_view_query_geometry (Lisp_Object image_instance,
74fd4e045ea6 Import from CVS: tag r21-2-29
cvs
parents: 388
diff changeset
727 unsigned int* width, unsigned int* height,
74fd4e045ea6 Import from CVS: tag r21-2-29
cvs
parents: 388
diff changeset
728 enum image_instance_geometry disp, Lisp_Object domain)
74fd4e045ea6 Import from CVS: tag r21-2-29
cvs
parents: 388
diff changeset
729 {
74fd4e045ea6 Import from CVS: tag r21-2-29
cvs
parents: 388
diff changeset
730 Lisp_Image_Instance *ii = XIMAGE_INSTANCE (image_instance);
74fd4e045ea6 Import from CVS: tag r21-2-29
cvs
parents: 388
diff changeset
731 Lisp_Object items = IMAGE_INSTANCE_WIDGET_ITEMS (ii);
74fd4e045ea6 Import from CVS: tag r21-2-29
cvs
parents: 388
diff changeset
732
74fd4e045ea6 Import from CVS: tag r21-2-29
cvs
parents: 388
diff changeset
733
74fd4e045ea6 Import from CVS: tag r21-2-29
cvs
parents: 388
diff changeset
734 if (*width)
74fd4e045ea6 Import from CVS: tag r21-2-29
cvs
parents: 388
diff changeset
735 {
74fd4e045ea6 Import from CVS: tag r21-2-29
cvs
parents: 388
diff changeset
736 /* #### what should this be. reconsider when X has tree views. */
74fd4e045ea6 Import from CVS: tag r21-2-29
cvs
parents: 388
diff changeset
737 query_string_geometry (IMAGE_INSTANCE_WIDGET_TEXT (ii),
74fd4e045ea6 Import from CVS: tag r21-2-29
cvs
parents: 388
diff changeset
738 IMAGE_INSTANCE_WIDGET_FACE (ii),
74fd4e045ea6 Import from CVS: tag r21-2-29
cvs
parents: 388
diff changeset
739 width, 0, 0, domain);
74fd4e045ea6 Import from CVS: tag r21-2-29
cvs
parents: 388
diff changeset
740 }
74fd4e045ea6 Import from CVS: tag r21-2-29
cvs
parents: 388
diff changeset
741 if (*height)
74fd4e045ea6 Import from CVS: tag r21-2-29
cvs
parents: 388
diff changeset
742 {
74fd4e045ea6 Import from CVS: tag r21-2-29
cvs
parents: 388
diff changeset
743 int len, h;
74fd4e045ea6 Import from CVS: tag r21-2-29
cvs
parents: 388
diff changeset
744 default_face_font_info (domain, 0, 0, &h, 0, 0);
74fd4e045ea6 Import from CVS: tag r21-2-29
cvs
parents: 388
diff changeset
745 GET_LIST_LENGTH (items, len);
74fd4e045ea6 Import from CVS: tag r21-2-29
cvs
parents: 388
diff changeset
746 *height = len * h;
74fd4e045ea6 Import from CVS: tag r21-2-29
cvs
parents: 388
diff changeset
747 }
74fd4e045ea6 Import from CVS: tag r21-2-29
cvs
parents: 388
diff changeset
748 }
74fd4e045ea6 Import from CVS: tag r21-2-29
cvs
parents: 388
diff changeset
749
74fd4e045ea6 Import from CVS: tag r21-2-29
cvs
parents: 388
diff changeset
750 /* Get the geometry of a tab control. This is based on the number of
74fd4e045ea6 Import from CVS: tag r21-2-29
cvs
parents: 388
diff changeset
751 items and text therin in the tab control. */
74fd4e045ea6 Import from CVS: tag r21-2-29
cvs
parents: 388
diff changeset
752 static void
74fd4e045ea6 Import from CVS: tag r21-2-29
cvs
parents: 388
diff changeset
753 tab_control_query_geometry (Lisp_Object image_instance,
74fd4e045ea6 Import from CVS: tag r21-2-29
cvs
parents: 388
diff changeset
754 unsigned int* width, unsigned int* height,
74fd4e045ea6 Import from CVS: tag r21-2-29
cvs
parents: 388
diff changeset
755 enum image_instance_geometry disp, Lisp_Object domain)
74fd4e045ea6 Import from CVS: tag r21-2-29
cvs
parents: 388
diff changeset
756 {
74fd4e045ea6 Import from CVS: tag r21-2-29
cvs
parents: 388
diff changeset
757 Lisp_Image_Instance *ii = XIMAGE_INSTANCE (image_instance);
400
a86b2b5e0111 Import from CVS: tag r21-2-30
cvs
parents: 398
diff changeset
758 Lisp_Object items = XCDR (IMAGE_INSTANCE_WIDGET_ITEMS (ii));
398
74fd4e045ea6 Import from CVS: tag r21-2-29
cvs
parents: 388
diff changeset
759 Lisp_Object rest;
74fd4e045ea6 Import from CVS: tag r21-2-29
cvs
parents: 388
diff changeset
760 unsigned int tw = 0, th = 0;
74fd4e045ea6 Import from CVS: tag r21-2-29
cvs
parents: 388
diff changeset
761
74fd4e045ea6 Import from CVS: tag r21-2-29
cvs
parents: 388
diff changeset
762 LIST_LOOP (rest, items)
74fd4e045ea6 Import from CVS: tag r21-2-29
cvs
parents: 388
diff changeset
763 {
74fd4e045ea6 Import from CVS: tag r21-2-29
cvs
parents: 388
diff changeset
764 unsigned int h, w;
74fd4e045ea6 Import from CVS: tag r21-2-29
cvs
parents: 388
diff changeset
765
74fd4e045ea6 Import from CVS: tag r21-2-29
cvs
parents: 388
diff changeset
766 query_string_geometry (XGUI_ITEM (XCAR (rest))->name,
74fd4e045ea6 Import from CVS: tag r21-2-29
cvs
parents: 388
diff changeset
767 IMAGE_INSTANCE_WIDGET_FACE (ii),
74fd4e045ea6 Import from CVS: tag r21-2-29
cvs
parents: 388
diff changeset
768 &w, &h, 0, domain);
400
a86b2b5e0111 Import from CVS: tag r21-2-30
cvs
parents: 398
diff changeset
769 tw += 5 * WIDGET_BORDER_WIDTH; /* some bias */
398
74fd4e045ea6 Import from CVS: tag r21-2-29
cvs
parents: 388
diff changeset
770 tw += w;
74fd4e045ea6 Import from CVS: tag r21-2-29
cvs
parents: 388
diff changeset
771 th = max (th, h + 2 * WIDGET_BORDER_HEIGHT);
388
aabb7f5b1c81 Import from CVS: tag r21-2-9
cvs
parents: 384
diff changeset
772 }
aabb7f5b1c81 Import from CVS: tag r21-2-9
cvs
parents: 384
diff changeset
773
398
74fd4e045ea6 Import from CVS: tag r21-2-29
cvs
parents: 388
diff changeset
774 /* Fixup returned values depending on orientation. */
74fd4e045ea6 Import from CVS: tag r21-2-29
cvs
parents: 388
diff changeset
775 if (IMAGE_INSTANCE_SUBWINDOW_ORIENT (ii))
74fd4e045ea6 Import from CVS: tag r21-2-29
cvs
parents: 388
diff changeset
776 {
74fd4e045ea6 Import from CVS: tag r21-2-29
cvs
parents: 388
diff changeset
777 if (height) *height = tw;
74fd4e045ea6 Import from CVS: tag r21-2-29
cvs
parents: 388
diff changeset
778 if (width) *width = th;
74fd4e045ea6 Import from CVS: tag r21-2-29
cvs
parents: 388
diff changeset
779 }
74fd4e045ea6 Import from CVS: tag r21-2-29
cvs
parents: 388
diff changeset
780 else
74fd4e045ea6 Import from CVS: tag r21-2-29
cvs
parents: 388
diff changeset
781 {
74fd4e045ea6 Import from CVS: tag r21-2-29
cvs
parents: 388
diff changeset
782 if (height) *height = th;
74fd4e045ea6 Import from CVS: tag r21-2-29
cvs
parents: 388
diff changeset
783 if (width) *width = tw;
74fd4e045ea6 Import from CVS: tag r21-2-29
cvs
parents: 388
diff changeset
784 }
74fd4e045ea6 Import from CVS: tag r21-2-29
cvs
parents: 388
diff changeset
785 }
74fd4e045ea6 Import from CVS: tag r21-2-29
cvs
parents: 388
diff changeset
786
74fd4e045ea6 Import from CVS: tag r21-2-29
cvs
parents: 388
diff changeset
787 /* Get the geometry of a tab control. This is based on the number of
74fd4e045ea6 Import from CVS: tag r21-2-29
cvs
parents: 388
diff changeset
788 items and text therin in the tab control. */
74fd4e045ea6 Import from CVS: tag r21-2-29
cvs
parents: 388
diff changeset
789 static Lisp_Object
74fd4e045ea6 Import from CVS: tag r21-2-29
cvs
parents: 388
diff changeset
790 tab_control_set_property (Lisp_Object image_instance,
74fd4e045ea6 Import from CVS: tag r21-2-29
cvs
parents: 388
diff changeset
791 Lisp_Object prop,
74fd4e045ea6 Import from CVS: tag r21-2-29
cvs
parents: 388
diff changeset
792 Lisp_Object val)
74fd4e045ea6 Import from CVS: tag r21-2-29
cvs
parents: 388
diff changeset
793 {
74fd4e045ea6 Import from CVS: tag r21-2-29
cvs
parents: 388
diff changeset
794 /* Record new items for update. *_tab_control_update will do the
74fd4e045ea6 Import from CVS: tag r21-2-29
cvs
parents: 388
diff changeset
795 rest. */
74fd4e045ea6 Import from CVS: tag r21-2-29
cvs
parents: 388
diff changeset
796 if (EQ (prop, Q_items))
384
bbff43aa5eb7 Import from CVS: tag r21-2-7
cvs
parents:
diff changeset
797 {
398
74fd4e045ea6 Import from CVS: tag r21-2-29
cvs
parents: 388
diff changeset
798 Lisp_Image_Instance* ii = XIMAGE_INSTANCE (image_instance);
404
2f8bb876ab1d Import from CVS: tag r21-2-32
cvs
parents: 400
diff changeset
799
398
74fd4e045ea6 Import from CVS: tag r21-2-29
cvs
parents: 388
diff changeset
800 check_valid_item_list_1 (val);
404
2f8bb876ab1d Import from CVS: tag r21-2-32
cvs
parents: 400
diff changeset
801
2f8bb876ab1d Import from CVS: tag r21-2-32
cvs
parents: 400
diff changeset
802 /* Don't set the actual items since we might decide not to use
2f8bb876ab1d Import from CVS: tag r21-2-32
cvs
parents: 400
diff changeset
803 the new ones (because nothing has really changed). If we did
2f8bb876ab1d Import from CVS: tag r21-2-32
cvs
parents: 400
diff changeset
804 set them and didn't use them then we would get into whole
2f8bb876ab1d Import from CVS: tag r21-2-32
cvs
parents: 400
diff changeset
805 heaps of trouble when the old items get GC'd. */
2f8bb876ab1d Import from CVS: tag r21-2-32
cvs
parents: 400
diff changeset
806 IMAGE_INSTANCE_WIDGET_PENDING_ITEMS (ii) =
2f8bb876ab1d Import from CVS: tag r21-2-32
cvs
parents: 400
diff changeset
807 Fcons (XCAR (IMAGE_INSTANCE_WIDGET_ITEMS (ii)),
398
74fd4e045ea6 Import from CVS: tag r21-2-29
cvs
parents: 388
diff changeset
808 parse_gui_item_tree_children (val));
74fd4e045ea6 Import from CVS: tag r21-2-29
cvs
parents: 388
diff changeset
809 IMAGE_INSTANCE_WIDGET_ITEMS_CHANGED (ii) = 1;
74fd4e045ea6 Import from CVS: tag r21-2-29
cvs
parents: 388
diff changeset
810
74fd4e045ea6 Import from CVS: tag r21-2-29
cvs
parents: 388
diff changeset
811 return Qt;
74fd4e045ea6 Import from CVS: tag r21-2-29
cvs
parents: 388
diff changeset
812 }
74fd4e045ea6 Import from CVS: tag r21-2-29
cvs
parents: 388
diff changeset
813 return Qunbound;
74fd4e045ea6 Import from CVS: tag r21-2-29
cvs
parents: 388
diff changeset
814 }
74fd4e045ea6 Import from CVS: tag r21-2-29
cvs
parents: 388
diff changeset
815
74fd4e045ea6 Import from CVS: tag r21-2-29
cvs
parents: 388
diff changeset
816 /* set the properties of a progres guage */
74fd4e045ea6 Import from CVS: tag r21-2-29
cvs
parents: 388
diff changeset
817 static Lisp_Object
74fd4e045ea6 Import from CVS: tag r21-2-29
cvs
parents: 388
diff changeset
818 progress_gauge_set_property (Lisp_Object image_instance,
74fd4e045ea6 Import from CVS: tag r21-2-29
cvs
parents: 388
diff changeset
819 Lisp_Object prop,
74fd4e045ea6 Import from CVS: tag r21-2-29
cvs
parents: 388
diff changeset
820 Lisp_Object val)
74fd4e045ea6 Import from CVS: tag r21-2-29
cvs
parents: 388
diff changeset
821 {
74fd4e045ea6 Import from CVS: tag r21-2-29
cvs
parents: 388
diff changeset
822 Lisp_Image_Instance *ii = XIMAGE_INSTANCE (image_instance);
74fd4e045ea6 Import from CVS: tag r21-2-29
cvs
parents: 388
diff changeset
823
406
b8cc9ab3f761 Import from CVS: tag r21-2-33
cvs
parents: 404
diff changeset
824 if (EQ (prop, Q_value))
398
74fd4e045ea6 Import from CVS: tag r21-2-29
cvs
parents: 388
diff changeset
825 {
74fd4e045ea6 Import from CVS: tag r21-2-29
cvs
parents: 388
diff changeset
826 CHECK_INT (val);
406
b8cc9ab3f761 Import from CVS: tag r21-2-33
cvs
parents: 404
diff changeset
827 #ifdef DEBUG_WIDGET_OUTPUT
b8cc9ab3f761 Import from CVS: tag r21-2-33
cvs
parents: 404
diff changeset
828 printf ("progress gauge value set to %ld\n", XINT (val));
b8cc9ab3f761 Import from CVS: tag r21-2-33
cvs
parents: 404
diff changeset
829 #endif
b8cc9ab3f761 Import from CVS: tag r21-2-33
cvs
parents: 404
diff changeset
830 IMAGE_INSTANCE_WIDGET_PENDING_ITEMS (ii) =
b8cc9ab3f761 Import from CVS: tag r21-2-33
cvs
parents: 404
diff changeset
831 copy_gui_item_tree (IMAGE_INSTANCE_WIDGET_ITEMS (ii));
b8cc9ab3f761 Import from CVS: tag r21-2-33
cvs
parents: 404
diff changeset
832 #ifdef ERROR_CHECK_GLYPHS
b8cc9ab3f761 Import from CVS: tag r21-2-33
cvs
parents: 404
diff changeset
833 assert (GUI_ITEMP (IMAGE_INSTANCE_WIDGET_PENDING_ITEMS (ii)));
b8cc9ab3f761 Import from CVS: tag r21-2-33
cvs
parents: 404
diff changeset
834 #endif
b8cc9ab3f761 Import from CVS: tag r21-2-33
cvs
parents: 404
diff changeset
835 if (GUI_ITEMP (IMAGE_INSTANCE_WIDGET_PENDING_ITEMS (ii)))
b8cc9ab3f761 Import from CVS: tag r21-2-33
cvs
parents: 404
diff changeset
836 XGUI_ITEM (IMAGE_INSTANCE_WIDGET_PENDING_ITEMS (ii))->value = val;
b8cc9ab3f761 Import from CVS: tag r21-2-33
cvs
parents: 404
diff changeset
837
b8cc9ab3f761 Import from CVS: tag r21-2-33
cvs
parents: 404
diff changeset
838 IMAGE_INSTANCE_WIDGET_ITEMS_CHANGED (ii) = 1;
398
74fd4e045ea6 Import from CVS: tag r21-2-29
cvs
parents: 388
diff changeset
839
74fd4e045ea6 Import from CVS: tag r21-2-29
cvs
parents: 388
diff changeset
840 return Qt;
384
bbff43aa5eb7 Import from CVS: tag r21-2-7
cvs
parents:
diff changeset
841 }
398
74fd4e045ea6 Import from CVS: tag r21-2-29
cvs
parents: 388
diff changeset
842 return Qunbound;
74fd4e045ea6 Import from CVS: tag r21-2-29
cvs
parents: 388
diff changeset
843 }
74fd4e045ea6 Import from CVS: tag r21-2-29
cvs
parents: 388
diff changeset
844
74fd4e045ea6 Import from CVS: tag r21-2-29
cvs
parents: 388
diff changeset
845
74fd4e045ea6 Import from CVS: tag r21-2-29
cvs
parents: 388
diff changeset
846 /*****************************************************************************
74fd4e045ea6 Import from CVS: tag r21-2-29
cvs
parents: 388
diff changeset
847 * widget layout *
74fd4e045ea6 Import from CVS: tag r21-2-29
cvs
parents: 388
diff changeset
848 *****************************************************************************/
74fd4e045ea6 Import from CVS: tag r21-2-29
cvs
parents: 388
diff changeset
849 /* we need to convert things like glyphs to images, eval expressions
74fd4e045ea6 Import from CVS: tag r21-2-29
cvs
parents: 388
diff changeset
850 etc.*/
74fd4e045ea6 Import from CVS: tag r21-2-29
cvs
parents: 388
diff changeset
851 static Lisp_Object
74fd4e045ea6 Import from CVS: tag r21-2-29
cvs
parents: 388
diff changeset
852 layout_normalize (Lisp_Object inst, Lisp_Object console_type)
74fd4e045ea6 Import from CVS: tag r21-2-29
cvs
parents: 388
diff changeset
853 {
74fd4e045ea6 Import from CVS: tag r21-2-29
cvs
parents: 388
diff changeset
854 /* This function can call lisp */
74fd4e045ea6 Import from CVS: tag r21-2-29
cvs
parents: 388
diff changeset
855 Lisp_Object items = find_keyword_in_vector (inst, Q_items);
74fd4e045ea6 Import from CVS: tag r21-2-29
cvs
parents: 388
diff changeset
856 Lisp_Object border = find_keyword_in_vector (inst, Q_border);
74fd4e045ea6 Import from CVS: tag r21-2-29
cvs
parents: 388
diff changeset
857 /* we need to eval glyph if its an expression, we do this for the
74fd4e045ea6 Import from CVS: tag r21-2-29
cvs
parents: 388
diff changeset
858 same reasons we normalize file to data. */
74fd4e045ea6 Import from CVS: tag r21-2-29
cvs
parents: 388
diff changeset
859 if (!NILP (items))
74fd4e045ea6 Import from CVS: tag r21-2-29
cvs
parents: 388
diff changeset
860 {
74fd4e045ea6 Import from CVS: tag r21-2-29
cvs
parents: 388
diff changeset
861 Lisp_Object rest;
74fd4e045ea6 Import from CVS: tag r21-2-29
cvs
parents: 388
diff changeset
862 LIST_LOOP (rest, items)
74fd4e045ea6 Import from CVS: tag r21-2-29
cvs
parents: 388
diff changeset
863 {
74fd4e045ea6 Import from CVS: tag r21-2-29
cvs
parents: 388
diff changeset
864 /* substitute the new glyph */
74fd4e045ea6 Import from CVS: tag r21-2-29
cvs
parents: 388
diff changeset
865 Fsetcar (rest, glyph_instantiator_to_glyph (XCAR (rest)));
74fd4e045ea6 Import from CVS: tag r21-2-29
cvs
parents: 388
diff changeset
866 }
74fd4e045ea6 Import from CVS: tag r21-2-29
cvs
parents: 388
diff changeset
867 }
74fd4e045ea6 Import from CVS: tag r21-2-29
cvs
parents: 388
diff changeset
868 /* normalize the border spec. */
74fd4e045ea6 Import from CVS: tag r21-2-29
cvs
parents: 388
diff changeset
869 if (VECTORP (border) || CONSP (border))
74fd4e045ea6 Import from CVS: tag r21-2-29
cvs
parents: 388
diff changeset
870 {
74fd4e045ea6 Import from CVS: tag r21-2-29
cvs
parents: 388
diff changeset
871 substitute_keyword_value (inst, Q_border, glyph_instantiator_to_glyph (border));
74fd4e045ea6 Import from CVS: tag r21-2-29
cvs
parents: 388
diff changeset
872 }
74fd4e045ea6 Import from CVS: tag r21-2-29
cvs
parents: 388
diff changeset
873 return inst;
384
bbff43aa5eb7 Import from CVS: tag r21-2-7
cvs
parents:
diff changeset
874 }
bbff43aa5eb7 Import from CVS: tag r21-2-7
cvs
parents:
diff changeset
875
408
501cfd01ee6d Import from CVS: tag r21-2-34
cvs
parents: 406
diff changeset
876 static void
501cfd01ee6d Import from CVS: tag r21-2-34
cvs
parents: 406
diff changeset
877 layout_instantiate (Lisp_Object image_instance, Lisp_Object instantiator,
501cfd01ee6d Import from CVS: tag r21-2-34
cvs
parents: 406
diff changeset
878 Lisp_Object pointer_fg, Lisp_Object pointer_bg,
501cfd01ee6d Import from CVS: tag r21-2-34
cvs
parents: 406
diff changeset
879 int dest_mask, Lisp_Object domain)
501cfd01ee6d Import from CVS: tag r21-2-34
cvs
parents: 406
diff changeset
880 {
501cfd01ee6d Import from CVS: tag r21-2-34
cvs
parents: 406
diff changeset
881 Lisp_Image_Instance *ii = XIMAGE_INSTANCE (image_instance);
501cfd01ee6d Import from CVS: tag r21-2-34
cvs
parents: 406
diff changeset
882 Lisp_Object orient = find_keyword_in_vector (instantiator, Q_orientation);
501cfd01ee6d Import from CVS: tag r21-2-34
cvs
parents: 406
diff changeset
883 Lisp_Object border = find_keyword_in_vector (instantiator, Q_border);
501cfd01ee6d Import from CVS: tag r21-2-34
cvs
parents: 406
diff changeset
884
501cfd01ee6d Import from CVS: tag r21-2-34
cvs
parents: 406
diff changeset
885 /* Do widget type instantiation first. */
501cfd01ee6d Import from CVS: tag r21-2-34
cvs
parents: 406
diff changeset
886 widget_instantiate (image_instance, instantiator, pointer_fg, pointer_bg,
501cfd01ee6d Import from CVS: tag r21-2-34
cvs
parents: 406
diff changeset
887 dest_mask, domain);
501cfd01ee6d Import from CVS: tag r21-2-34
cvs
parents: 406
diff changeset
888
501cfd01ee6d Import from CVS: tag r21-2-34
cvs
parents: 406
diff changeset
889 if (NILP (orient))
501cfd01ee6d Import from CVS: tag r21-2-34
cvs
parents: 406
diff changeset
890 {
501cfd01ee6d Import from CVS: tag r21-2-34
cvs
parents: 406
diff changeset
891 IMAGE_INSTANCE_SUBWINDOW_ORIENT (ii) = LAYOUT_VERTICAL;
501cfd01ee6d Import from CVS: tag r21-2-34
cvs
parents: 406
diff changeset
892 }
501cfd01ee6d Import from CVS: tag r21-2-34
cvs
parents: 406
diff changeset
893
501cfd01ee6d Import from CVS: tag r21-2-34
cvs
parents: 406
diff changeset
894 if (EQ (border, Qt))
501cfd01ee6d Import from CVS: tag r21-2-34
cvs
parents: 406
diff changeset
895 {
501cfd01ee6d Import from CVS: tag r21-2-34
cvs
parents: 406
diff changeset
896 IMAGE_INSTANCE_LAYOUT_BORDER (ii) = Qetched_in;
501cfd01ee6d Import from CVS: tag r21-2-34
cvs
parents: 406
diff changeset
897 }
501cfd01ee6d Import from CVS: tag r21-2-34
cvs
parents: 406
diff changeset
898 else
501cfd01ee6d Import from CVS: tag r21-2-34
cvs
parents: 406
diff changeset
899 {
501cfd01ee6d Import from CVS: tag r21-2-34
cvs
parents: 406
diff changeset
900 IMAGE_INSTANCE_LAYOUT_BORDER (ii) = border;
501cfd01ee6d Import from CVS: tag r21-2-34
cvs
parents: 406
diff changeset
901 }
501cfd01ee6d Import from CVS: tag r21-2-34
cvs
parents: 406
diff changeset
902 /* We don't do the children yet as we might not have a containing
501cfd01ee6d Import from CVS: tag r21-2-34
cvs
parents: 406
diff changeset
903 window. */
501cfd01ee6d Import from CVS: tag r21-2-34
cvs
parents: 406
diff changeset
904 }
501cfd01ee6d Import from CVS: tag r21-2-34
cvs
parents: 406
diff changeset
905
501cfd01ee6d Import from CVS: tag r21-2-34
cvs
parents: 406
diff changeset
906 static void
501cfd01ee6d Import from CVS: tag r21-2-34
cvs
parents: 406
diff changeset
907 layout_post_instantiate (Lisp_Object image_instance, Lisp_Object instantiator,
501cfd01ee6d Import from CVS: tag r21-2-34
cvs
parents: 406
diff changeset
908 Lisp_Object domain)
501cfd01ee6d Import from CVS: tag r21-2-34
cvs
parents: 406
diff changeset
909 {
501cfd01ee6d Import from CVS: tag r21-2-34
cvs
parents: 406
diff changeset
910 Lisp_Image_Instance *ii = XIMAGE_INSTANCE (image_instance);
501cfd01ee6d Import from CVS: tag r21-2-34
cvs
parents: 406
diff changeset
911 Lisp_Object items = find_keyword_in_vector (instantiator, Q_items);
501cfd01ee6d Import from CVS: tag r21-2-34
cvs
parents: 406
diff changeset
912 Lisp_Object rest, children = Qnil;
501cfd01ee6d Import from CVS: tag r21-2-34
cvs
parents: 406
diff changeset
913
501cfd01ee6d Import from CVS: tag r21-2-34
cvs
parents: 406
diff changeset
914 if (GLYPHP (IMAGE_INSTANCE_LAYOUT_BORDER (ii)))
501cfd01ee6d Import from CVS: tag r21-2-34
cvs
parents: 406
diff changeset
915 {
501cfd01ee6d Import from CVS: tag r21-2-34
cvs
parents: 406
diff changeset
916 /* We are going to be sneaky here and add the border text as
501cfd01ee6d Import from CVS: tag r21-2-34
cvs
parents: 406
diff changeset
917 just another child, the layout and output routines don't know
501cfd01ee6d Import from CVS: tag r21-2-34
cvs
parents: 406
diff changeset
918 this and will just display at the offsets we prescribe. */
501cfd01ee6d Import from CVS: tag r21-2-34
cvs
parents: 406
diff changeset
919 Lisp_Object gii = glyph_image_instance
501cfd01ee6d Import from CVS: tag r21-2-34
cvs
parents: 406
diff changeset
920 (IMAGE_INSTANCE_LAYOUT_BORDER (ii),
501cfd01ee6d Import from CVS: tag r21-2-34
cvs
parents: 406
diff changeset
921 image_instance, ERROR_ME, 1);
501cfd01ee6d Import from CVS: tag r21-2-34
cvs
parents: 406
diff changeset
922
501cfd01ee6d Import from CVS: tag r21-2-34
cvs
parents: 406
diff changeset
923 if (!IMAGE_INSTANCEP (gii))
501cfd01ee6d Import from CVS: tag r21-2-34
cvs
parents: 406
diff changeset
924 return;
501cfd01ee6d Import from CVS: tag r21-2-34
cvs
parents: 406
diff changeset
925 /* make sure we are designated as the parent. */
501cfd01ee6d Import from CVS: tag r21-2-34
cvs
parents: 406
diff changeset
926 XIMAGE_INSTANCE_PARENT (gii) = image_instance;
501cfd01ee6d Import from CVS: tag r21-2-34
cvs
parents: 406
diff changeset
927 children = Fcons (gii, children);
501cfd01ee6d Import from CVS: tag r21-2-34
cvs
parents: 406
diff changeset
928 IMAGE_INSTANCE_LAYOUT_BORDER (ii) = make_int (0);
501cfd01ee6d Import from CVS: tag r21-2-34
cvs
parents: 406
diff changeset
929 }
501cfd01ee6d Import from CVS: tag r21-2-34
cvs
parents: 406
diff changeset
930
501cfd01ee6d Import from CVS: tag r21-2-34
cvs
parents: 406
diff changeset
931 /* Pick up the sub-widgets. */
501cfd01ee6d Import from CVS: tag r21-2-34
cvs
parents: 406
diff changeset
932 LIST_LOOP (rest, items)
501cfd01ee6d Import from CVS: tag r21-2-34
cvs
parents: 406
diff changeset
933 {
501cfd01ee6d Import from CVS: tag r21-2-34
cvs
parents: 406
diff changeset
934 /* make sure the image is instantiated */
501cfd01ee6d Import from CVS: tag r21-2-34
cvs
parents: 406
diff changeset
935 Lisp_Object gii = glyph_image_instance (XCAR (rest),
501cfd01ee6d Import from CVS: tag r21-2-34
cvs
parents: 406
diff changeset
936 image_instance, ERROR_ME, 1);
501cfd01ee6d Import from CVS: tag r21-2-34
cvs
parents: 406
diff changeset
937 if (!IMAGE_INSTANCEP (gii))
501cfd01ee6d Import from CVS: tag r21-2-34
cvs
parents: 406
diff changeset
938 return;
501cfd01ee6d Import from CVS: tag r21-2-34
cvs
parents: 406
diff changeset
939 /* make sure we are designated as the parent. */
501cfd01ee6d Import from CVS: tag r21-2-34
cvs
parents: 406
diff changeset
940 XIMAGE_INSTANCE_PARENT (gii) = image_instance;
501cfd01ee6d Import from CVS: tag r21-2-34
cvs
parents: 406
diff changeset
941 children = Fcons (gii, children);
501cfd01ee6d Import from CVS: tag r21-2-34
cvs
parents: 406
diff changeset
942 }
501cfd01ee6d Import from CVS: tag r21-2-34
cvs
parents: 406
diff changeset
943 /* Make sure elements in the layout are in the order the
501cfd01ee6d Import from CVS: tag r21-2-34
cvs
parents: 406
diff changeset
944 user expected. */
501cfd01ee6d Import from CVS: tag r21-2-34
cvs
parents: 406
diff changeset
945 children = Fnreverse (children);
501cfd01ee6d Import from CVS: tag r21-2-34
cvs
parents: 406
diff changeset
946 IMAGE_INSTANCE_LAYOUT_CHILDREN (ii) = children;
501cfd01ee6d Import from CVS: tag r21-2-34
cvs
parents: 406
diff changeset
947 }
501cfd01ee6d Import from CVS: tag r21-2-34
cvs
parents: 406
diff changeset
948
398
74fd4e045ea6 Import from CVS: tag r21-2-29
cvs
parents: 388
diff changeset
949 /* Layout widget. Sizing commentary: we have a number of problems that
74fd4e045ea6 Import from CVS: tag r21-2-29
cvs
parents: 388
diff changeset
950 we would like to address. Some consider some of these more
74fd4e045ea6 Import from CVS: tag r21-2-29
cvs
parents: 388
diff changeset
951 important than others. It used to be that size information was
74fd4e045ea6 Import from CVS: tag r21-2-29
cvs
parents: 388
diff changeset
952 determined at instantiation time and was then fixed forever
74fd4e045ea6 Import from CVS: tag r21-2-29
cvs
parents: 388
diff changeset
953 after. Generally this is not what we want. Users want size to be
74fd4e045ea6 Import from CVS: tag r21-2-29
cvs
parents: 388
diff changeset
954 "big enough" to accommodate whatever they are trying to show and
74fd4e045ea6 Import from CVS: tag r21-2-29
cvs
parents: 388
diff changeset
955 this is dependent on text length, lines, font metrics etc. Of
74fd4e045ea6 Import from CVS: tag r21-2-29
cvs
parents: 388
diff changeset
956 course these attributes can change dynamically and so the size
74fd4e045ea6 Import from CVS: tag r21-2-29
cvs
parents: 388
diff changeset
957 should changed dynamically also. Only in a few limited cases should
74fd4e045ea6 Import from CVS: tag r21-2-29
cvs
parents: 388
diff changeset
958 the size be fixed and remain fixed. Of course this actually means
74fd4e045ea6 Import from CVS: tag r21-2-29
cvs
parents: 388
diff changeset
959 that we don't really want to specifiy the size *at all* for most
74fd4e045ea6 Import from CVS: tag r21-2-29
cvs
parents: 388
diff changeset
960 widgets - we want it to be discovered dynamically. Thus we can
74fd4e045ea6 Import from CVS: tag r21-2-29
cvs
parents: 388
diff changeset
961 envisage the following scenarios:
74fd4e045ea6 Import from CVS: tag r21-2-29
cvs
parents: 388
diff changeset
962
74fd4e045ea6 Import from CVS: tag r21-2-29
cvs
parents: 388
diff changeset
963 1. A button is sized to accommodate its text, the text changes and the
74fd4e045ea6 Import from CVS: tag r21-2-29
cvs
parents: 388
diff changeset
964 button should change size also.
74fd4e045ea6 Import from CVS: tag r21-2-29
cvs
parents: 388
diff changeset
965
74fd4e045ea6 Import from CVS: tag r21-2-29
cvs
parents: 388
diff changeset
966 2. A button is given an explicit size. Its size should never change.
74fd4e045ea6 Import from CVS: tag r21-2-29
cvs
parents: 388
diff changeset
967
74fd4e045ea6 Import from CVS: tag r21-2-29
cvs
parents: 388
diff changeset
968 3. Layout is put inside an area. The size of the area changes, the
74fd4e045ea6 Import from CVS: tag r21-2-29
cvs
parents: 388
diff changeset
969 layout should change with it.
74fd4e045ea6 Import from CVS: tag r21-2-29
cvs
parents: 388
diff changeset
970
74fd4e045ea6 Import from CVS: tag r21-2-29
cvs
parents: 388
diff changeset
971 4. A button grows to accommodate additional text. The whitespace
74fd4e045ea6 Import from CVS: tag r21-2-29
cvs
parents: 388
diff changeset
972 around it should be modified to cope with the new layout
74fd4e045ea6 Import from CVS: tag r21-2-29
cvs
parents: 388
diff changeset
973 requirements.
74fd4e045ea6 Import from CVS: tag r21-2-29
cvs
parents: 388
diff changeset
974
74fd4e045ea6 Import from CVS: tag r21-2-29
cvs
parents: 388
diff changeset
975 5. A button grows. The area surrounding it should grow also if
74fd4e045ea6 Import from CVS: tag r21-2-29
cvs
parents: 388
diff changeset
976 possible.
74fd4e045ea6 Import from CVS: tag r21-2-29
cvs
parents: 388
diff changeset
977
74fd4e045ea6 Import from CVS: tag r21-2-29
cvs
parents: 388
diff changeset
978 What metrics are important?
74fd4e045ea6 Import from CVS: tag r21-2-29
cvs
parents: 388
diff changeset
979 1. Actual width and height.
74fd4e045ea6 Import from CVS: tag r21-2-29
cvs
parents: 388
diff changeset
980
74fd4e045ea6 Import from CVS: tag r21-2-29
cvs
parents: 388
diff changeset
981 2. Whether the width and height are what the widget actually wants, or
74fd4e045ea6 Import from CVS: tag r21-2-29
cvs
parents: 388
diff changeset
982 whether it can grow or shrink.
74fd4e045ea6 Import from CVS: tag r21-2-29
cvs
parents: 388
diff changeset
983
74fd4e045ea6 Import from CVS: tag r21-2-29
cvs
parents: 388
diff changeset
984 Text glyphs are particularly troublesome since their metrics depend
74fd4e045ea6 Import from CVS: tag r21-2-29
cvs
parents: 388
diff changeset
985 on the context in which they are being viewed. For instance they
74fd4e045ea6 Import from CVS: tag r21-2-29
cvs
parents: 388
diff changeset
986 can appear differently depending on the window face, frame face or
74fd4e045ea6 Import from CVS: tag r21-2-29
cvs
parents: 388
diff changeset
987 glyph face. In order to simplify this text glyphs can now only have
74fd4e045ea6 Import from CVS: tag r21-2-29
cvs
parents: 388
diff changeset
988 a glyph-face or image-instance face. All other glyphs are
74fd4e045ea6 Import from CVS: tag r21-2-29
cvs
parents: 388
diff changeset
989 essentially fixed in appearance. Perhaps the problem is that text
74fd4e045ea6 Import from CVS: tag r21-2-29
cvs
parents: 388
diff changeset
990 glyphs are cached on a device basis like most other glyphs. Instead
74fd4e045ea6 Import from CVS: tag r21-2-29
cvs
parents: 388
diff changeset
991 they should be cached per-window and then the instance would be
74fd4e045ea6 Import from CVS: tag r21-2-29
cvs
parents: 388
diff changeset
992 fixed and we wouldn't have to mess around with font metrics and the
74fd4e045ea6 Import from CVS: tag r21-2-29
cvs
parents: 388
diff changeset
993 rest. */
74fd4e045ea6 Import from CVS: tag r21-2-29
cvs
parents: 388
diff changeset
994
74fd4e045ea6 Import from CVS: tag r21-2-29
cvs
parents: 388
diff changeset
995 /* Query the geometry of a layout widget. We assume that we can only
74fd4e045ea6 Import from CVS: tag r21-2-29
cvs
parents: 388
diff changeset
996 get here if the size is not already fixed. */
384
bbff43aa5eb7 Import from CVS: tag r21-2-7
cvs
parents:
diff changeset
997 static void
398
74fd4e045ea6 Import from CVS: tag r21-2-29
cvs
parents: 388
diff changeset
998 layout_query_geometry (Lisp_Object image_instance, unsigned int* width,
74fd4e045ea6 Import from CVS: tag r21-2-29
cvs
parents: 388
diff changeset
999 unsigned int* height, enum image_instance_geometry disp,
74fd4e045ea6 Import from CVS: tag r21-2-29
cvs
parents: 388
diff changeset
1000 Lisp_Object domain)
384
bbff43aa5eb7 Import from CVS: tag r21-2-7
cvs
parents:
diff changeset
1001 {
398
74fd4e045ea6 Import from CVS: tag r21-2-29
cvs
parents: 388
diff changeset
1002 Lisp_Image_Instance *ii = XIMAGE_INSTANCE (image_instance);
74fd4e045ea6 Import from CVS: tag r21-2-29
cvs
parents: 388
diff changeset
1003 Lisp_Object items = IMAGE_INSTANCE_LAYOUT_CHILDREN (ii), rest;
74fd4e045ea6 Import from CVS: tag r21-2-29
cvs
parents: 388
diff changeset
1004 int maxph = 0, maxpw = 0, nitems = 0, ph_adjust = 0;
406
b8cc9ab3f761 Import from CVS: tag r21-2-33
cvs
parents: 404
diff changeset
1005 unsigned int gheight, gwidth;
398
74fd4e045ea6 Import from CVS: tag r21-2-29
cvs
parents: 388
diff changeset
1006
408
501cfd01ee6d Import from CVS: tag r21-2-34
cvs
parents: 406
diff changeset
1007 /* If we are not initialized then we won't have any children. */
501cfd01ee6d Import from CVS: tag r21-2-34
cvs
parents: 406
diff changeset
1008 if (!IMAGE_INSTANCE_INITIALIZED (ii))
501cfd01ee6d Import from CVS: tag r21-2-34
cvs
parents: 406
diff changeset
1009 return;
501cfd01ee6d Import from CVS: tag r21-2-34
cvs
parents: 406
diff changeset
1010
406
b8cc9ab3f761 Import from CVS: tag r21-2-33
cvs
parents: 404
diff changeset
1011 /* First just set up what we already have. */
b8cc9ab3f761 Import from CVS: tag r21-2-33
cvs
parents: 404
diff changeset
1012 if (width) *width = IMAGE_INSTANCE_WIDTH (ii);
b8cc9ab3f761 Import from CVS: tag r21-2-33
cvs
parents: 404
diff changeset
1013 if (height) *height = IMAGE_INSTANCE_HEIGHT (ii);
b8cc9ab3f761 Import from CVS: tag r21-2-33
cvs
parents: 404
diff changeset
1014
b8cc9ab3f761 Import from CVS: tag r21-2-33
cvs
parents: 404
diff changeset
1015 /* If we are not allowed to dynamically size then return. */
b8cc9ab3f761 Import from CVS: tag r21-2-33
cvs
parents: 404
diff changeset
1016 if (!IMAGE_INSTANCE_SUBWINDOW_V_RESIZEP (ii)
b8cc9ab3f761 Import from CVS: tag r21-2-33
cvs
parents: 404
diff changeset
1017 &&
b8cc9ab3f761 Import from CVS: tag r21-2-33
cvs
parents: 404
diff changeset
1018 !IMAGE_INSTANCE_SUBWINDOW_H_RESIZEP (ii))
b8cc9ab3f761 Import from CVS: tag r21-2-33
cvs
parents: 404
diff changeset
1019 return;
b8cc9ab3f761 Import from CVS: tag r21-2-33
cvs
parents: 404
diff changeset
1020
b8cc9ab3f761 Import from CVS: tag r21-2-33
cvs
parents: 404
diff changeset
1021 /* Pick up the border text if we have one. */
b8cc9ab3f761 Import from CVS: tag r21-2-33
cvs
parents: 404
diff changeset
1022 if (INTP (IMAGE_INSTANCE_LAYOUT_BORDER (ii)))
b8cc9ab3f761 Import from CVS: tag r21-2-33
cvs
parents: 404
diff changeset
1023 {
b8cc9ab3f761 Import from CVS: tag r21-2-33
cvs
parents: 404
diff changeset
1024 image_instance_query_geometry (XCAR (items), &gwidth, &gheight, disp, domain);
b8cc9ab3f761 Import from CVS: tag r21-2-33
cvs
parents: 404
diff changeset
1025 ph_adjust = gheight / 2;
b8cc9ab3f761 Import from CVS: tag r21-2-33
cvs
parents: 404
diff changeset
1026 items = XCDR (items);
b8cc9ab3f761 Import from CVS: tag r21-2-33
cvs
parents: 404
diff changeset
1027 }
b8cc9ab3f761 Import from CVS: tag r21-2-33
cvs
parents: 404
diff changeset
1028
398
74fd4e045ea6 Import from CVS: tag r21-2-29
cvs
parents: 388
diff changeset
1029 /* Flip through the items to work out how much stuff we have to display */
74fd4e045ea6 Import from CVS: tag r21-2-29
cvs
parents: 388
diff changeset
1030 LIST_LOOP (rest, items)
74fd4e045ea6 Import from CVS: tag r21-2-29
cvs
parents: 388
diff changeset
1031 {
74fd4e045ea6 Import from CVS: tag r21-2-29
cvs
parents: 388
diff changeset
1032 Lisp_Object glyph = XCAR (rest);
74fd4e045ea6 Import from CVS: tag r21-2-29
cvs
parents: 388
diff changeset
1033 image_instance_query_geometry (glyph, &gwidth, &gheight, disp, domain);
74fd4e045ea6 Import from CVS: tag r21-2-29
cvs
parents: 388
diff changeset
1034
406
b8cc9ab3f761 Import from CVS: tag r21-2-33
cvs
parents: 404
diff changeset
1035 nitems ++;
b8cc9ab3f761 Import from CVS: tag r21-2-33
cvs
parents: 404
diff changeset
1036 if (IMAGE_INSTANCE_SUBWINDOW_ORIENT (ii)
b8cc9ab3f761 Import from CVS: tag r21-2-33
cvs
parents: 404
diff changeset
1037 == LAYOUT_HORIZONTAL)
398
74fd4e045ea6 Import from CVS: tag r21-2-29
cvs
parents: 388
diff changeset
1038 {
406
b8cc9ab3f761 Import from CVS: tag r21-2-33
cvs
parents: 404
diff changeset
1039 maxph = max (maxph, gheight);
b8cc9ab3f761 Import from CVS: tag r21-2-33
cvs
parents: 404
diff changeset
1040 maxpw += gwidth;
398
74fd4e045ea6 Import from CVS: tag r21-2-29
cvs
parents: 388
diff changeset
1041 }
74fd4e045ea6 Import from CVS: tag r21-2-29
cvs
parents: 388
diff changeset
1042 else
74fd4e045ea6 Import from CVS: tag r21-2-29
cvs
parents: 388
diff changeset
1043 {
406
b8cc9ab3f761 Import from CVS: tag r21-2-33
cvs
parents: 404
diff changeset
1044 maxpw = max (maxpw, gwidth);
b8cc9ab3f761 Import from CVS: tag r21-2-33
cvs
parents: 404
diff changeset
1045 maxph += gheight;
398
74fd4e045ea6 Import from CVS: tag r21-2-29
cvs
parents: 388
diff changeset
1046 }
74fd4e045ea6 Import from CVS: tag r21-2-29
cvs
parents: 388
diff changeset
1047 }
74fd4e045ea6 Import from CVS: tag r21-2-29
cvs
parents: 388
diff changeset
1048
406
b8cc9ab3f761 Import from CVS: tag r21-2-33
cvs
parents: 404
diff changeset
1049 /* Work out minimum space we need to fit all the items. This could
b8cc9ab3f761 Import from CVS: tag r21-2-33
cvs
parents: 404
diff changeset
1050 have been fixed by the user. */
b8cc9ab3f761 Import from CVS: tag r21-2-33
cvs
parents: 404
diff changeset
1051 if (!NILP (IMAGE_INSTANCE_WIDGET_WIDTH_SUBR (ii)))
b8cc9ab3f761 Import from CVS: tag r21-2-33
cvs
parents: 404
diff changeset
1052 {
b8cc9ab3f761 Import from CVS: tag r21-2-33
cvs
parents: 404
diff changeset
1053 Lisp_Object dynamic_width =
b8cc9ab3f761 Import from CVS: tag r21-2-33
cvs
parents: 404
diff changeset
1054 Feval (IMAGE_INSTANCE_WIDGET_WIDTH_SUBR (ii));
b8cc9ab3f761 Import from CVS: tag r21-2-33
cvs
parents: 404
diff changeset
1055 if (INTP (dynamic_width))
b8cc9ab3f761 Import from CVS: tag r21-2-33
cvs
parents: 404
diff changeset
1056 *width = XINT (dynamic_width);
b8cc9ab3f761 Import from CVS: tag r21-2-33
cvs
parents: 404
diff changeset
1057 }
b8cc9ab3f761 Import from CVS: tag r21-2-33
cvs
parents: 404
diff changeset
1058 else if (IMAGE_INSTANCE_SUBWINDOW_ORIENT (ii)
b8cc9ab3f761 Import from CVS: tag r21-2-33
cvs
parents: 404
diff changeset
1059 == LAYOUT_HORIZONTAL)
408
501cfd01ee6d Import from CVS: tag r21-2-34
cvs
parents: 406
diff changeset
1060 *width = maxpw + ((nitems + 1) * WIDGET_BORDER_WIDTH +
501cfd01ee6d Import from CVS: tag r21-2-34
cvs
parents: 406
diff changeset
1061 IMAGE_INSTANCE_MARGIN_WIDTH (ii)) * 2;
398
74fd4e045ea6 Import from CVS: tag r21-2-29
cvs
parents: 388
diff changeset
1062 else
408
501cfd01ee6d Import from CVS: tag r21-2-34
cvs
parents: 406
diff changeset
1063 *width = maxpw + 2 * (WIDGET_BORDER_WIDTH * 2 +
501cfd01ee6d Import from CVS: tag r21-2-34
cvs
parents: 406
diff changeset
1064 IMAGE_INSTANCE_MARGIN_WIDTH (ii));
398
74fd4e045ea6 Import from CVS: tag r21-2-29
cvs
parents: 388
diff changeset
1065
74fd4e045ea6 Import from CVS: tag r21-2-29
cvs
parents: 388
diff changeset
1066 /* Work out vertical spacings. */
406
b8cc9ab3f761 Import from CVS: tag r21-2-33
cvs
parents: 404
diff changeset
1067 if (!NILP (IMAGE_INSTANCE_WIDGET_HEIGHT_SUBR (ii)))
b8cc9ab3f761 Import from CVS: tag r21-2-33
cvs
parents: 404
diff changeset
1068 {
b8cc9ab3f761 Import from CVS: tag r21-2-33
cvs
parents: 404
diff changeset
1069 Lisp_Object dynamic_height =
b8cc9ab3f761 Import from CVS: tag r21-2-33
cvs
parents: 404
diff changeset
1070 Feval (IMAGE_INSTANCE_WIDGET_HEIGHT_SUBR (ii));
b8cc9ab3f761 Import from CVS: tag r21-2-33
cvs
parents: 404
diff changeset
1071 if (INTP (dynamic_height))
b8cc9ab3f761 Import from CVS: tag r21-2-33
cvs
parents: 404
diff changeset
1072 *height = XINT (dynamic_height);
b8cc9ab3f761 Import from CVS: tag r21-2-33
cvs
parents: 404
diff changeset
1073 }
b8cc9ab3f761 Import from CVS: tag r21-2-33
cvs
parents: 404
diff changeset
1074 else if (IMAGE_INSTANCE_SUBWINDOW_ORIENT (ii)
b8cc9ab3f761 Import from CVS: tag r21-2-33
cvs
parents: 404
diff changeset
1075 == LAYOUT_VERTICAL)
408
501cfd01ee6d Import from CVS: tag r21-2-34
cvs
parents: 406
diff changeset
1076 *height = maxph + ((nitems + 1) * WIDGET_BORDER_HEIGHT +
501cfd01ee6d Import from CVS: tag r21-2-34
cvs
parents: 406
diff changeset
1077 IMAGE_INSTANCE_MARGIN_WIDTH (ii)) * 2 + ph_adjust;
406
b8cc9ab3f761 Import from CVS: tag r21-2-33
cvs
parents: 404
diff changeset
1078 else
408
501cfd01ee6d Import from CVS: tag r21-2-34
cvs
parents: 406
diff changeset
1079 *height = maxph + (2 * WIDGET_BORDER_HEIGHT +
501cfd01ee6d Import from CVS: tag r21-2-34
cvs
parents: 406
diff changeset
1080 IMAGE_INSTANCE_MARGIN_WIDTH (ii)) * 2 + ph_adjust;
384
bbff43aa5eb7 Import from CVS: tag r21-2-7
cvs
parents:
diff changeset
1081 }
bbff43aa5eb7 Import from CVS: tag r21-2-7
cvs
parents:
diff changeset
1082
408
501cfd01ee6d Import from CVS: tag r21-2-34
cvs
parents: 406
diff changeset
1083 int
398
74fd4e045ea6 Import from CVS: tag r21-2-29
cvs
parents: 388
diff changeset
1084 layout_layout (Lisp_Object image_instance,
74fd4e045ea6 Import from CVS: tag r21-2-29
cvs
parents: 388
diff changeset
1085 unsigned int width, unsigned int height, Lisp_Object domain)
384
bbff43aa5eb7 Import from CVS: tag r21-2-7
cvs
parents:
diff changeset
1086 {
398
74fd4e045ea6 Import from CVS: tag r21-2-29
cvs
parents: 388
diff changeset
1087 Lisp_Image_Instance *ii = XIMAGE_INSTANCE (image_instance);
74fd4e045ea6 Import from CVS: tag r21-2-29
cvs
parents: 388
diff changeset
1088 Lisp_Object rest;
74fd4e045ea6 Import from CVS: tag r21-2-29
cvs
parents: 388
diff changeset
1089 Lisp_Object items = IMAGE_INSTANCE_LAYOUT_CHILDREN (ii);
74fd4e045ea6 Import from CVS: tag r21-2-29
cvs
parents: 388
diff changeset
1090 int x, y, maxph = 0, maxpw = 0, nitems = 0,
74fd4e045ea6 Import from CVS: tag r21-2-29
cvs
parents: 388
diff changeset
1091 horiz_spacing, vert_spacing, ph_adjust = 0;
74fd4e045ea6 Import from CVS: tag r21-2-29
cvs
parents: 388
diff changeset
1092 unsigned int gheight, gwidth;
408
501cfd01ee6d Import from CVS: tag r21-2-34
cvs
parents: 406
diff changeset
1093
501cfd01ee6d Import from CVS: tag r21-2-34
cvs
parents: 406
diff changeset
1094 /* If we are not initialized then we won't have any children. */
501cfd01ee6d Import from CVS: tag r21-2-34
cvs
parents: 406
diff changeset
1095 if (!IMAGE_INSTANCE_INITIALIZED (ii))
501cfd01ee6d Import from CVS: tag r21-2-34
cvs
parents: 406
diff changeset
1096 return 0;
501cfd01ee6d Import from CVS: tag r21-2-34
cvs
parents: 406
diff changeset
1097
406
b8cc9ab3f761 Import from CVS: tag r21-2-33
cvs
parents: 404
diff changeset
1098 /* Pick up the border text if we have one. */
b8cc9ab3f761 Import from CVS: tag r21-2-33
cvs
parents: 404
diff changeset
1099 if (INTP (IMAGE_INSTANCE_LAYOUT_BORDER (ii)))
b8cc9ab3f761 Import from CVS: tag r21-2-33
cvs
parents: 404
diff changeset
1100 {
b8cc9ab3f761 Import from CVS: tag r21-2-33
cvs
parents: 404
diff changeset
1101 Lisp_Object border = XCAR (items);
b8cc9ab3f761 Import from CVS: tag r21-2-33
cvs
parents: 404
diff changeset
1102 items = XCDR (items);
b8cc9ab3f761 Import from CVS: tag r21-2-33
cvs
parents: 404
diff changeset
1103 image_instance_query_geometry (border, &gwidth, &gheight,
b8cc9ab3f761 Import from CVS: tag r21-2-33
cvs
parents: 404
diff changeset
1104 IMAGE_DESIRED_GEOMETRY, domain);
b8cc9ab3f761 Import from CVS: tag r21-2-33
cvs
parents: 404
diff changeset
1105 /* #### Really, what should this be? */
b8cc9ab3f761 Import from CVS: tag r21-2-33
cvs
parents: 404
diff changeset
1106 XIMAGE_INSTANCE_XOFFSET (border) = 10;
b8cc9ab3f761 Import from CVS: tag r21-2-33
cvs
parents: 404
diff changeset
1107 XIMAGE_INSTANCE_YOFFSET (border) = 0;
b8cc9ab3f761 Import from CVS: tag r21-2-33
cvs
parents: 404
diff changeset
1108 ph_adjust = gheight / 2;
b8cc9ab3f761 Import from CVS: tag r21-2-33
cvs
parents: 404
diff changeset
1109 IMAGE_INSTANCE_LAYOUT_BORDER (ii) = make_int (ph_adjust);
398
74fd4e045ea6 Import from CVS: tag r21-2-29
cvs
parents: 388
diff changeset
1110
406
b8cc9ab3f761 Import from CVS: tag r21-2-33
cvs
parents: 404
diff changeset
1111 image_instance_layout (border, gwidth, gheight, domain);
b8cc9ab3f761 Import from CVS: tag r21-2-33
cvs
parents: 404
diff changeset
1112 }
b8cc9ab3f761 Import from CVS: tag r21-2-33
cvs
parents: 404
diff changeset
1113
b8cc9ab3f761 Import from CVS: tag r21-2-33
cvs
parents: 404
diff changeset
1114 /* Flip through the items to work out how much stuff we have to display. */
398
74fd4e045ea6 Import from CVS: tag r21-2-29
cvs
parents: 388
diff changeset
1115 LIST_LOOP (rest, items)
74fd4e045ea6 Import from CVS: tag r21-2-29
cvs
parents: 388
diff changeset
1116 {
74fd4e045ea6 Import from CVS: tag r21-2-29
cvs
parents: 388
diff changeset
1117 Lisp_Object glyph = XCAR (rest);
74fd4e045ea6 Import from CVS: tag r21-2-29
cvs
parents: 388
diff changeset
1118
74fd4e045ea6 Import from CVS: tag r21-2-29
cvs
parents: 388
diff changeset
1119 image_instance_query_geometry (glyph, &gwidth, &gheight,
74fd4e045ea6 Import from CVS: tag r21-2-29
cvs
parents: 388
diff changeset
1120 IMAGE_DESIRED_GEOMETRY, domain);
406
b8cc9ab3f761 Import from CVS: tag r21-2-33
cvs
parents: 404
diff changeset
1121 nitems ++;
b8cc9ab3f761 Import from CVS: tag r21-2-33
cvs
parents: 404
diff changeset
1122 if (IMAGE_INSTANCE_SUBWINDOW_ORIENT (ii)
b8cc9ab3f761 Import from CVS: tag r21-2-33
cvs
parents: 404
diff changeset
1123 == LAYOUT_HORIZONTAL)
398
74fd4e045ea6 Import from CVS: tag r21-2-29
cvs
parents: 388
diff changeset
1124 {
406
b8cc9ab3f761 Import from CVS: tag r21-2-33
cvs
parents: 404
diff changeset
1125 maxph = max (maxph, gheight);
b8cc9ab3f761 Import from CVS: tag r21-2-33
cvs
parents: 404
diff changeset
1126 maxpw += gwidth;
398
74fd4e045ea6 Import from CVS: tag r21-2-29
cvs
parents: 388
diff changeset
1127 }
74fd4e045ea6 Import from CVS: tag r21-2-29
cvs
parents: 388
diff changeset
1128 else
74fd4e045ea6 Import from CVS: tag r21-2-29
cvs
parents: 388
diff changeset
1129 {
406
b8cc9ab3f761 Import from CVS: tag r21-2-33
cvs
parents: 404
diff changeset
1130 maxpw = max (maxpw, gwidth);
b8cc9ab3f761 Import from CVS: tag r21-2-33
cvs
parents: 404
diff changeset
1131 maxph += gheight;
398
74fd4e045ea6 Import from CVS: tag r21-2-29
cvs
parents: 388
diff changeset
1132 }
74fd4e045ea6 Import from CVS: tag r21-2-29
cvs
parents: 388
diff changeset
1133 }
74fd4e045ea6 Import from CVS: tag r21-2-29
cvs
parents: 388
diff changeset
1134
74fd4e045ea6 Import from CVS: tag r21-2-29
cvs
parents: 388
diff changeset
1135 /* work out spacing between items and bounds of the layout */
74fd4e045ea6 Import from CVS: tag r21-2-29
cvs
parents: 388
diff changeset
1136 if (width < maxpw)
74fd4e045ea6 Import from CVS: tag r21-2-29
cvs
parents: 388
diff changeset
1137 /* The user wants a smaller space than the largest item, so we
74fd4e045ea6 Import from CVS: tag r21-2-29
cvs
parents: 388
diff changeset
1138 just provide default spacing and will let the output routines
74fd4e045ea6 Import from CVS: tag r21-2-29
cvs
parents: 388
diff changeset
1139 clip.. */
74fd4e045ea6 Import from CVS: tag r21-2-29
cvs
parents: 388
diff changeset
1140 horiz_spacing = WIDGET_BORDER_WIDTH * 2;
74fd4e045ea6 Import from CVS: tag r21-2-29
cvs
parents: 388
diff changeset
1141 else if (IMAGE_INSTANCE_SUBWINDOW_ORIENT (ii)
74fd4e045ea6 Import from CVS: tag r21-2-29
cvs
parents: 388
diff changeset
1142 == LAYOUT_HORIZONTAL)
74fd4e045ea6 Import from CVS: tag r21-2-29
cvs
parents: 388
diff changeset
1143 /* We have a larger area to display in so distribute the space
74fd4e045ea6 Import from CVS: tag r21-2-29
cvs
parents: 388
diff changeset
1144 evenly. */
408
501cfd01ee6d Import from CVS: tag r21-2-34
cvs
parents: 406
diff changeset
1145 horiz_spacing = (width - (maxpw +
501cfd01ee6d Import from CVS: tag r21-2-34
cvs
parents: 406
diff changeset
1146 IMAGE_INSTANCE_MARGIN_WIDTH (ii) * 2))
501cfd01ee6d Import from CVS: tag r21-2-34
cvs
parents: 406
diff changeset
1147 / (nitems + 1);
398
74fd4e045ea6 Import from CVS: tag r21-2-29
cvs
parents: 388
diff changeset
1148 else
408
501cfd01ee6d Import from CVS: tag r21-2-34
cvs
parents: 406
diff changeset
1149 horiz_spacing = (width - maxpw) / 2
501cfd01ee6d Import from CVS: tag r21-2-34
cvs
parents: 406
diff changeset
1150 - IMAGE_INSTANCE_MARGIN_WIDTH (ii);
384
bbff43aa5eb7 Import from CVS: tag r21-2-7
cvs
parents:
diff changeset
1151
398
74fd4e045ea6 Import from CVS: tag r21-2-29
cvs
parents: 388
diff changeset
1152 if (height < maxph)
74fd4e045ea6 Import from CVS: tag r21-2-29
cvs
parents: 388
diff changeset
1153 vert_spacing = WIDGET_BORDER_HEIGHT * 2;
74fd4e045ea6 Import from CVS: tag r21-2-29
cvs
parents: 388
diff changeset
1154 else if (IMAGE_INSTANCE_SUBWINDOW_ORIENT (ii)
74fd4e045ea6 Import from CVS: tag r21-2-29
cvs
parents: 388
diff changeset
1155 == LAYOUT_VERTICAL)
408
501cfd01ee6d Import from CVS: tag r21-2-34
cvs
parents: 406
diff changeset
1156 vert_spacing = (height - (maxph + ph_adjust +
501cfd01ee6d Import from CVS: tag r21-2-34
cvs
parents: 406
diff changeset
1157 IMAGE_INSTANCE_MARGIN_WIDTH (ii) * 2))
501cfd01ee6d Import from CVS: tag r21-2-34
cvs
parents: 406
diff changeset
1158 / (nitems + 1);
398
74fd4e045ea6 Import from CVS: tag r21-2-29
cvs
parents: 388
diff changeset
1159 else
408
501cfd01ee6d Import from CVS: tag r21-2-34
cvs
parents: 406
diff changeset
1160 vert_spacing = (height - (maxph + ph_adjust)) / 2
501cfd01ee6d Import from CVS: tag r21-2-34
cvs
parents: 406
diff changeset
1161 - IMAGE_INSTANCE_MARGIN_WIDTH (ii);
398
74fd4e045ea6 Import from CVS: tag r21-2-29
cvs
parents: 388
diff changeset
1162
408
501cfd01ee6d Import from CVS: tag r21-2-34
cvs
parents: 406
diff changeset
1163 y = vert_spacing + ph_adjust + IMAGE_INSTANCE_MARGIN_WIDTH (ii);
501cfd01ee6d Import from CVS: tag r21-2-34
cvs
parents: 406
diff changeset
1164 x = horiz_spacing + IMAGE_INSTANCE_MARGIN_WIDTH (ii);
398
74fd4e045ea6 Import from CVS: tag r21-2-29
cvs
parents: 388
diff changeset
1165
74fd4e045ea6 Import from CVS: tag r21-2-29
cvs
parents: 388
diff changeset
1166 /* Now flip through putting items where we want them, paying
74fd4e045ea6 Import from CVS: tag r21-2-29
cvs
parents: 388
diff changeset
1167 attention to justification. Make sure we don't mess with the
74fd4e045ea6 Import from CVS: tag r21-2-29
cvs
parents: 388
diff changeset
1168 border glyph. */
74fd4e045ea6 Import from CVS: tag r21-2-29
cvs
parents: 388
diff changeset
1169 LIST_LOOP (rest, items)
74fd4e045ea6 Import from CVS: tag r21-2-29
cvs
parents: 388
diff changeset
1170 {
74fd4e045ea6 Import from CVS: tag r21-2-29
cvs
parents: 388
diff changeset
1171 Lisp_Object glyph = XCAR (rest);
74fd4e045ea6 Import from CVS: tag r21-2-29
cvs
parents: 388
diff changeset
1172
74fd4e045ea6 Import from CVS: tag r21-2-29
cvs
parents: 388
diff changeset
1173 image_instance_query_geometry (glyph, &gwidth, &gheight,
74fd4e045ea6 Import from CVS: tag r21-2-29
cvs
parents: 388
diff changeset
1174 IMAGE_DESIRED_GEOMETRY, domain);
74fd4e045ea6 Import from CVS: tag r21-2-29
cvs
parents: 388
diff changeset
1175
406
b8cc9ab3f761 Import from CVS: tag r21-2-33
cvs
parents: 404
diff changeset
1176 if (IMAGE_INSTANCE_SUBWINDOW_ORIENT (ii)
b8cc9ab3f761 Import from CVS: tag r21-2-33
cvs
parents: 404
diff changeset
1177 == LAYOUT_HORIZONTAL)
b8cc9ab3f761 Import from CVS: tag r21-2-33
cvs
parents: 404
diff changeset
1178 {
b8cc9ab3f761 Import from CVS: tag r21-2-33
cvs
parents: 404
diff changeset
1179 if (IMAGE_INSTANCE_SUBWINDOW_JUSTIFY (ii)
b8cc9ab3f761 Import from CVS: tag r21-2-33
cvs
parents: 404
diff changeset
1180 == LAYOUT_JUSTIFY_RIGHT)
b8cc9ab3f761 Import from CVS: tag r21-2-33
cvs
parents: 404
diff changeset
1181 y = height - (gheight + vert_spacing);
b8cc9ab3f761 Import from CVS: tag r21-2-33
cvs
parents: 404
diff changeset
1182 if (IMAGE_INSTANCE_SUBWINDOW_JUSTIFY (ii)
b8cc9ab3f761 Import from CVS: tag r21-2-33
cvs
parents: 404
diff changeset
1183 == LAYOUT_JUSTIFY_CENTER)
b8cc9ab3f761 Import from CVS: tag r21-2-33
cvs
parents: 404
diff changeset
1184 y = (height - gheight) / 2;
b8cc9ab3f761 Import from CVS: tag r21-2-33
cvs
parents: 404
diff changeset
1185 }
b8cc9ab3f761 Import from CVS: tag r21-2-33
cvs
parents: 404
diff changeset
1186 else
b8cc9ab3f761 Import from CVS: tag r21-2-33
cvs
parents: 404
diff changeset
1187 {
b8cc9ab3f761 Import from CVS: tag r21-2-33
cvs
parents: 404
diff changeset
1188 if (IMAGE_INSTANCE_SUBWINDOW_JUSTIFY (ii)
b8cc9ab3f761 Import from CVS: tag r21-2-33
cvs
parents: 404
diff changeset
1189 == LAYOUT_JUSTIFY_RIGHT)
b8cc9ab3f761 Import from CVS: tag r21-2-33
cvs
parents: 404
diff changeset
1190 x = width - (gwidth + horiz_spacing);
b8cc9ab3f761 Import from CVS: tag r21-2-33
cvs
parents: 404
diff changeset
1191 if (IMAGE_INSTANCE_SUBWINDOW_JUSTIFY (ii)
b8cc9ab3f761 Import from CVS: tag r21-2-33
cvs
parents: 404
diff changeset
1192 == LAYOUT_JUSTIFY_CENTER)
b8cc9ab3f761 Import from CVS: tag r21-2-33
cvs
parents: 404
diff changeset
1193 x = (width - gwidth) / 2;
b8cc9ab3f761 Import from CVS: tag r21-2-33
cvs
parents: 404
diff changeset
1194 }
398
74fd4e045ea6 Import from CVS: tag r21-2-29
cvs
parents: 388
diff changeset
1195
406
b8cc9ab3f761 Import from CVS: tag r21-2-33
cvs
parents: 404
diff changeset
1196 XIMAGE_INSTANCE_XOFFSET (glyph) = x;
b8cc9ab3f761 Import from CVS: tag r21-2-33
cvs
parents: 404
diff changeset
1197 XIMAGE_INSTANCE_YOFFSET (glyph) = y;
398
74fd4e045ea6 Import from CVS: tag r21-2-29
cvs
parents: 388
diff changeset
1198
406
b8cc9ab3f761 Import from CVS: tag r21-2-33
cvs
parents: 404
diff changeset
1199 if (IMAGE_INSTANCE_SUBWINDOW_ORIENT (ii)
b8cc9ab3f761 Import from CVS: tag r21-2-33
cvs
parents: 404
diff changeset
1200 == LAYOUT_HORIZONTAL)
b8cc9ab3f761 Import from CVS: tag r21-2-33
cvs
parents: 404
diff changeset
1201 {
b8cc9ab3f761 Import from CVS: tag r21-2-33
cvs
parents: 404
diff changeset
1202 x += (gwidth + horiz_spacing);
b8cc9ab3f761 Import from CVS: tag r21-2-33
cvs
parents: 404
diff changeset
1203 }
b8cc9ab3f761 Import from CVS: tag r21-2-33
cvs
parents: 404
diff changeset
1204 else
b8cc9ab3f761 Import from CVS: tag r21-2-33
cvs
parents: 404
diff changeset
1205 {
b8cc9ab3f761 Import from CVS: tag r21-2-33
cvs
parents: 404
diff changeset
1206 y += (gheight + vert_spacing);
b8cc9ab3f761 Import from CVS: tag r21-2-33
cvs
parents: 404
diff changeset
1207 }
398
74fd4e045ea6 Import from CVS: tag r21-2-29
cvs
parents: 388
diff changeset
1208
74fd4e045ea6 Import from CVS: tag r21-2-29
cvs
parents: 388
diff changeset
1209 /* Now layout subwidgets if they require it. */
74fd4e045ea6 Import from CVS: tag r21-2-29
cvs
parents: 388
diff changeset
1210 image_instance_layout (glyph, gwidth, gheight, domain);
74fd4e045ea6 Import from CVS: tag r21-2-29
cvs
parents: 388
diff changeset
1211 }
408
501cfd01ee6d Import from CVS: tag r21-2-34
cvs
parents: 406
diff changeset
1212 return 1;
501cfd01ee6d Import from CVS: tag r21-2-34
cvs
parents: 406
diff changeset
1213 }
501cfd01ee6d Import from CVS: tag r21-2-34
cvs
parents: 406
diff changeset
1214
501cfd01ee6d Import from CVS: tag r21-2-34
cvs
parents: 406
diff changeset
1215 /* Layout subwindows if they are real subwindows. */
501cfd01ee6d Import from CVS: tag r21-2-34
cvs
parents: 406
diff changeset
1216 static int
501cfd01ee6d Import from CVS: tag r21-2-34
cvs
parents: 406
diff changeset
1217 native_layout_layout (Lisp_Object image_instance,
501cfd01ee6d Import from CVS: tag r21-2-34
cvs
parents: 406
diff changeset
1218 unsigned int width, unsigned int height,
501cfd01ee6d Import from CVS: tag r21-2-34
cvs
parents: 406
diff changeset
1219 Lisp_Object domain)
501cfd01ee6d Import from CVS: tag r21-2-34
cvs
parents: 406
diff changeset
1220 {
501cfd01ee6d Import from CVS: tag r21-2-34
cvs
parents: 406
diff changeset
1221 Lisp_Image_Instance* ii = XIMAGE_INSTANCE (image_instance);
501cfd01ee6d Import from CVS: tag r21-2-34
cvs
parents: 406
diff changeset
1222 Lisp_Object rest;
501cfd01ee6d Import from CVS: tag r21-2-34
cvs
parents: 406
diff changeset
1223
501cfd01ee6d Import from CVS: tag r21-2-34
cvs
parents: 406
diff changeset
1224 /* The first time this gets called, the layout will be only
501cfd01ee6d Import from CVS: tag r21-2-34
cvs
parents: 406
diff changeset
1225 partially instantiated. The children get done in
501cfd01ee6d Import from CVS: tag r21-2-34
cvs
parents: 406
diff changeset
1226 post_instantiate. */
501cfd01ee6d Import from CVS: tag r21-2-34
cvs
parents: 406
diff changeset
1227 if (!IMAGE_INSTANCE_INITIALIZED (ii))
501cfd01ee6d Import from CVS: tag r21-2-34
cvs
parents: 406
diff changeset
1228 return 0;
501cfd01ee6d Import from CVS: tag r21-2-34
cvs
parents: 406
diff changeset
1229
501cfd01ee6d Import from CVS: tag r21-2-34
cvs
parents: 406
diff changeset
1230 /* Defining this overrides the default layout_layout so we first have to call that to get
501cfd01ee6d Import from CVS: tag r21-2-34
cvs
parents: 406
diff changeset
1231 suitable instances and values set up. */
501cfd01ee6d Import from CVS: tag r21-2-34
cvs
parents: 406
diff changeset
1232 layout_layout (image_instance, width, height, domain);
501cfd01ee6d Import from CVS: tag r21-2-34
cvs
parents: 406
diff changeset
1233
501cfd01ee6d Import from CVS: tag r21-2-34
cvs
parents: 406
diff changeset
1234 LIST_LOOP (rest, IMAGE_INSTANCE_LAYOUT_CHILDREN (ii))
501cfd01ee6d Import from CVS: tag r21-2-34
cvs
parents: 406
diff changeset
1235 {
501cfd01ee6d Import from CVS: tag r21-2-34
cvs
parents: 406
diff changeset
1236 struct display_glyph_area dga;
501cfd01ee6d Import from CVS: tag r21-2-34
cvs
parents: 406
diff changeset
1237 dga.xoffset = 0;
501cfd01ee6d Import from CVS: tag r21-2-34
cvs
parents: 406
diff changeset
1238 dga.yoffset = 0;
501cfd01ee6d Import from CVS: tag r21-2-34
cvs
parents: 406
diff changeset
1239 dga.width = IMAGE_INSTANCE_WIDTH (ii);
501cfd01ee6d Import from CVS: tag r21-2-34
cvs
parents: 406
diff changeset
1240 dga.height = IMAGE_INSTANCE_HEIGHT (ii);
501cfd01ee6d Import from CVS: tag r21-2-34
cvs
parents: 406
diff changeset
1241
501cfd01ee6d Import from CVS: tag r21-2-34
cvs
parents: 406
diff changeset
1242 map_subwindow (XCAR (rest),
501cfd01ee6d Import from CVS: tag r21-2-34
cvs
parents: 406
diff changeset
1243 IMAGE_INSTANCE_XOFFSET (ii),
501cfd01ee6d Import from CVS: tag r21-2-34
cvs
parents: 406
diff changeset
1244 IMAGE_INSTANCE_YOFFSET (ii), &dga);
501cfd01ee6d Import from CVS: tag r21-2-34
cvs
parents: 406
diff changeset
1245 }
501cfd01ee6d Import from CVS: tag r21-2-34
cvs
parents: 406
diff changeset
1246 return 1;
384
bbff43aa5eb7 Import from CVS: tag r21-2-7
cvs
parents:
diff changeset
1247 }
bbff43aa5eb7 Import from CVS: tag r21-2-7
cvs
parents:
diff changeset
1248
bbff43aa5eb7 Import from CVS: tag r21-2-7
cvs
parents:
diff changeset
1249
bbff43aa5eb7 Import from CVS: tag r21-2-7
cvs
parents:
diff changeset
1250 /************************************************************************/
bbff43aa5eb7 Import from CVS: tag r21-2-7
cvs
parents:
diff changeset
1251 /* initialization */
bbff43aa5eb7 Import from CVS: tag r21-2-7
cvs
parents:
diff changeset
1252 /************************************************************************/
bbff43aa5eb7 Import from CVS: tag r21-2-7
cvs
parents:
diff changeset
1253
bbff43aa5eb7 Import from CVS: tag r21-2-7
cvs
parents:
diff changeset
1254 void
bbff43aa5eb7 Import from CVS: tag r21-2-7
cvs
parents:
diff changeset
1255 syms_of_glyphs_widget (void)
bbff43aa5eb7 Import from CVS: tag r21-2-7
cvs
parents:
diff changeset
1256 {
bbff43aa5eb7 Import from CVS: tag r21-2-7
cvs
parents:
diff changeset
1257 defkeyword (&Q_descriptor, ":descriptor");
bbff43aa5eb7 Import from CVS: tag r21-2-7
cvs
parents:
diff changeset
1258 defkeyword (&Q_height, ":height");
bbff43aa5eb7 Import from CVS: tag r21-2-7
cvs
parents:
diff changeset
1259 defkeyword (&Q_width, ":width");
bbff43aa5eb7 Import from CVS: tag r21-2-7
cvs
parents:
diff changeset
1260 defkeyword (&Q_properties, ":properties");
bbff43aa5eb7 Import from CVS: tag r21-2-7
cvs
parents:
diff changeset
1261 defkeyword (&Q_items, ":items");
388
aabb7f5b1c81 Import from CVS: tag r21-2-9
cvs
parents: 384
diff changeset
1262 defkeyword (&Q_image, ":image");
398
74fd4e045ea6 Import from CVS: tag r21-2-29
cvs
parents: 388
diff changeset
1263 defkeyword (&Q_text, ":text");
74fd4e045ea6 Import from CVS: tag r21-2-29
cvs
parents: 388
diff changeset
1264 defkeyword (&Q_orientation, ":orientation");
74fd4e045ea6 Import from CVS: tag r21-2-29
cvs
parents: 388
diff changeset
1265 defkeyword (&Q_justify, ":justify");
74fd4e045ea6 Import from CVS: tag r21-2-29
cvs
parents: 388
diff changeset
1266 defkeyword (&Q_border, ":border");
408
501cfd01ee6d Import from CVS: tag r21-2-34
cvs
parents: 406
diff changeset
1267 defkeyword (&Q_margin_width, ":margin-width");
398
74fd4e045ea6 Import from CVS: tag r21-2-29
cvs
parents: 388
diff changeset
1268
74fd4e045ea6 Import from CVS: tag r21-2-29
cvs
parents: 388
diff changeset
1269 defsymbol (&Qetched_in, "etched-in");
74fd4e045ea6 Import from CVS: tag r21-2-29
cvs
parents: 388
diff changeset
1270 defsymbol (&Qetched_out, "etched-out");
74fd4e045ea6 Import from CVS: tag r21-2-29
cvs
parents: 388
diff changeset
1271 defsymbol (&Qbevel_in, "bevel-in");
74fd4e045ea6 Import from CVS: tag r21-2-29
cvs
parents: 388
diff changeset
1272 defsymbol (&Qbevel_out, "bevel-out");
384
bbff43aa5eb7 Import from CVS: tag r21-2-7
cvs
parents:
diff changeset
1273 }
bbff43aa5eb7 Import from CVS: tag r21-2-7
cvs
parents:
diff changeset
1274
398
74fd4e045ea6 Import from CVS: tag r21-2-29
cvs
parents: 388
diff changeset
1275 #define VALID_GUI_KEYWORDS(type) do { \
74fd4e045ea6 Import from CVS: tag r21-2-29
cvs
parents: 388
diff changeset
1276 IIFORMAT_VALID_NONCOPY_KEYWORD (type, Q_active, check_valid_anything); \
74fd4e045ea6 Import from CVS: tag r21-2-29
cvs
parents: 388
diff changeset
1277 IIFORMAT_VALID_KEYWORD (type, Q_suffix, check_valid_anything); \
74fd4e045ea6 Import from CVS: tag r21-2-29
cvs
parents: 388
diff changeset
1278 IIFORMAT_VALID_KEYWORD (type, Q_keys, check_valid_string); \
74fd4e045ea6 Import from CVS: tag r21-2-29
cvs
parents: 388
diff changeset
1279 IIFORMAT_VALID_KEYWORD (type, Q_style, check_valid_symbol); \
74fd4e045ea6 Import from CVS: tag r21-2-29
cvs
parents: 388
diff changeset
1280 IIFORMAT_VALID_NONCOPY_KEYWORD (type, Q_selected, check_valid_anything); \
74fd4e045ea6 Import from CVS: tag r21-2-29
cvs
parents: 388
diff changeset
1281 IIFORMAT_VALID_KEYWORD (type, Q_filter, check_valid_anything); \
74fd4e045ea6 Import from CVS: tag r21-2-29
cvs
parents: 388
diff changeset
1282 IIFORMAT_VALID_KEYWORD (type, Q_config, check_valid_symbol); \
74fd4e045ea6 Import from CVS: tag r21-2-29
cvs
parents: 388
diff changeset
1283 IIFORMAT_VALID_KEYWORD (type, Q_included, check_valid_anything); \
74fd4e045ea6 Import from CVS: tag r21-2-29
cvs
parents: 388
diff changeset
1284 IIFORMAT_VALID_KEYWORD (type, Q_key_sequence, check_valid_string); \
74fd4e045ea6 Import from CVS: tag r21-2-29
cvs
parents: 388
diff changeset
1285 IIFORMAT_VALID_KEYWORD (type, Q_accelerator, check_valid_string); \
74fd4e045ea6 Import from CVS: tag r21-2-29
cvs
parents: 388
diff changeset
1286 IIFORMAT_VALID_KEYWORD (type, Q_label, check_valid_anything); \
74fd4e045ea6 Import from CVS: tag r21-2-29
cvs
parents: 388
diff changeset
1287 IIFORMAT_VALID_NONCOPY_KEYWORD (type, Q_callback, check_valid_callback); \
406
b8cc9ab3f761 Import from CVS: tag r21-2-33
cvs
parents: 404
diff changeset
1288 IIFORMAT_VALID_NONCOPY_KEYWORD (type, Q_callback_ex, check_valid_callback); \
398
74fd4e045ea6 Import from CVS: tag r21-2-29
cvs
parents: 388
diff changeset
1289 IIFORMAT_VALID_NONCOPY_KEYWORD (type, Q_descriptor, check_valid_string_or_vector); \
74fd4e045ea6 Import from CVS: tag r21-2-29
cvs
parents: 388
diff changeset
1290 } while (0)
388
aabb7f5b1c81 Import from CVS: tag r21-2-9
cvs
parents: 384
diff changeset
1291
398
74fd4e045ea6 Import from CVS: tag r21-2-29
cvs
parents: 388
diff changeset
1292 #define VALID_WIDGET_KEYWORDS(type) do { \
388
aabb7f5b1c81 Import from CVS: tag r21-2-9
cvs
parents: 384
diff changeset
1293 IIFORMAT_VALID_KEYWORD (type, Q_width, check_valid_int); \
aabb7f5b1c81 Import from CVS: tag r21-2-9
cvs
parents: 384
diff changeset
1294 IIFORMAT_VALID_KEYWORD (type, Q_height, check_valid_int); \
404
2f8bb876ab1d Import from CVS: tag r21-2-32
cvs
parents: 400
diff changeset
1295 IIFORMAT_VALID_KEYWORD (type, Q_pixel_width, check_valid_int_or_function);\
2f8bb876ab1d Import from CVS: tag r21-2-32
cvs
parents: 400
diff changeset
1296 IIFORMAT_VALID_KEYWORD (type, Q_pixel_height, check_valid_int_or_function);\
398
74fd4e045ea6 Import from CVS: tag r21-2-29
cvs
parents: 388
diff changeset
1297 IIFORMAT_VALID_KEYWORD (type, Q_face, check_valid_face); \
74fd4e045ea6 Import from CVS: tag r21-2-29
cvs
parents: 388
diff changeset
1298 } while (0)
388
aabb7f5b1c81 Import from CVS: tag r21-2-9
cvs
parents: 384
diff changeset
1299
398
74fd4e045ea6 Import from CVS: tag r21-2-29
cvs
parents: 388
diff changeset
1300
74fd4e045ea6 Import from CVS: tag r21-2-29
cvs
parents: 388
diff changeset
1301 static void image_instantiator_widget (void)
74fd4e045ea6 Import from CVS: tag r21-2-29
cvs
parents: 388
diff changeset
1302 { /* we only do this for properties */
384
bbff43aa5eb7 Import from CVS: tag r21-2-7
cvs
parents:
diff changeset
1303 INITIALIZE_IMAGE_INSTANTIATOR_FORMAT_NO_SYM (widget, "widget");
bbff43aa5eb7 Import from CVS: tag r21-2-7
cvs
parents:
diff changeset
1304 IIFORMAT_HAS_METHOD (widget, property);
bbff43aa5eb7 Import from CVS: tag r21-2-7
cvs
parents:
diff changeset
1305 IIFORMAT_HAS_METHOD (widget, set_property);
398
74fd4e045ea6 Import from CVS: tag r21-2-29
cvs
parents: 388
diff changeset
1306 IIFORMAT_HAS_METHOD (widget, query_geometry);
74fd4e045ea6 Import from CVS: tag r21-2-29
cvs
parents: 388
diff changeset
1307 IIFORMAT_HAS_METHOD (widget, layout);
74fd4e045ea6 Import from CVS: tag r21-2-29
cvs
parents: 388
diff changeset
1308 }
384
bbff43aa5eb7 Import from CVS: tag r21-2-7
cvs
parents:
diff changeset
1309
398
74fd4e045ea6 Import from CVS: tag r21-2-29
cvs
parents: 388
diff changeset
1310 static void image_instantiator_buttons (void)
74fd4e045ea6 Import from CVS: tag r21-2-29
cvs
parents: 388
diff changeset
1311 {
384
bbff43aa5eb7 Import from CVS: tag r21-2-7
cvs
parents:
diff changeset
1312 INITIALIZE_IMAGE_INSTANTIATOR_FORMAT (button, "button");
bbff43aa5eb7 Import from CVS: tag r21-2-7
cvs
parents:
diff changeset
1313 IIFORMAT_HAS_SHARED_METHOD (button, validate, widget);
bbff43aa5eb7 Import from CVS: tag r21-2-7
cvs
parents:
diff changeset
1314 IIFORMAT_HAS_SHARED_METHOD (button, possible_dest_types, widget);
bbff43aa5eb7 Import from CVS: tag r21-2-7
cvs
parents:
diff changeset
1315 IIFORMAT_HAS_SHARED_METHOD (button, instantiate, widget);
408
501cfd01ee6d Import from CVS: tag r21-2-34
cvs
parents: 406
diff changeset
1316 IIFORMAT_HAS_SHARED_METHOD (button, post_instantiate, widget);
388
aabb7f5b1c81 Import from CVS: tag r21-2-9
cvs
parents: 384
diff changeset
1317 IIFORMAT_HAS_SHARED_METHOD (button, normalize, widget);
408
501cfd01ee6d Import from CVS: tag r21-2-34
cvs
parents: 406
diff changeset
1318 IIFORMAT_HAS_SHARED_METHOD (button, governing_domain, subwindow);
406
b8cc9ab3f761 Import from CVS: tag r21-2-33
cvs
parents: 404
diff changeset
1319 IIFORMAT_HAS_METHOD (button, query_geometry);
398
74fd4e045ea6 Import from CVS: tag r21-2-29
cvs
parents: 388
diff changeset
1320 IIFORMAT_VALID_KEYWORD (button,
74fd4e045ea6 Import from CVS: tag r21-2-29
cvs
parents: 388
diff changeset
1321 Q_image, check_valid_glyph_or_instantiator);
388
aabb7f5b1c81 Import from CVS: tag r21-2-9
cvs
parents: 384
diff changeset
1322 VALID_WIDGET_KEYWORDS (button);
aabb7f5b1c81 Import from CVS: tag r21-2-9
cvs
parents: 384
diff changeset
1323 VALID_GUI_KEYWORDS (button);
398
74fd4e045ea6 Import from CVS: tag r21-2-29
cvs
parents: 388
diff changeset
1324 }
384
bbff43aa5eb7 Import from CVS: tag r21-2-7
cvs
parents:
diff changeset
1325
398
74fd4e045ea6 Import from CVS: tag r21-2-29
cvs
parents: 388
diff changeset
1326 static void image_instantiator_edit_fields (void)
74fd4e045ea6 Import from CVS: tag r21-2-29
cvs
parents: 388
diff changeset
1327 {
74fd4e045ea6 Import from CVS: tag r21-2-29
cvs
parents: 388
diff changeset
1328 INITIALIZE_IMAGE_INSTANTIATOR_FORMAT (edit_field, "edit-field");
74fd4e045ea6 Import from CVS: tag r21-2-29
cvs
parents: 388
diff changeset
1329 IIFORMAT_HAS_SHARED_METHOD (edit_field, validate, widget);
74fd4e045ea6 Import from CVS: tag r21-2-29
cvs
parents: 388
diff changeset
1330 IIFORMAT_HAS_SHARED_METHOD (edit_field, possible_dest_types, widget);
74fd4e045ea6 Import from CVS: tag r21-2-29
cvs
parents: 388
diff changeset
1331 IIFORMAT_HAS_SHARED_METHOD (edit_field, instantiate, widget);
408
501cfd01ee6d Import from CVS: tag r21-2-34
cvs
parents: 406
diff changeset
1332 IIFORMAT_HAS_SHARED_METHOD (edit_field, post_instantiate, widget);
501cfd01ee6d Import from CVS: tag r21-2-34
cvs
parents: 406
diff changeset
1333 IIFORMAT_HAS_SHARED_METHOD (edit_field, governing_domain, subwindow);
398
74fd4e045ea6 Import from CVS: tag r21-2-29
cvs
parents: 388
diff changeset
1334 VALID_WIDGET_KEYWORDS (edit_field);
74fd4e045ea6 Import from CVS: tag r21-2-29
cvs
parents: 388
diff changeset
1335 VALID_GUI_KEYWORDS (edit_field);
74fd4e045ea6 Import from CVS: tag r21-2-29
cvs
parents: 388
diff changeset
1336 }
384
bbff43aa5eb7 Import from CVS: tag r21-2-7
cvs
parents:
diff changeset
1337
398
74fd4e045ea6 Import from CVS: tag r21-2-29
cvs
parents: 388
diff changeset
1338 static void image_instantiator_combo_box (void)
74fd4e045ea6 Import from CVS: tag r21-2-29
cvs
parents: 388
diff changeset
1339 {
74fd4e045ea6 Import from CVS: tag r21-2-29
cvs
parents: 388
diff changeset
1340 INITIALIZE_IMAGE_INSTANTIATOR_FORMAT (combo_box, "combo-box");
74fd4e045ea6 Import from CVS: tag r21-2-29
cvs
parents: 388
diff changeset
1341 IIFORMAT_HAS_METHOD (combo_box, validate);
74fd4e045ea6 Import from CVS: tag r21-2-29
cvs
parents: 388
diff changeset
1342 IIFORMAT_HAS_SHARED_METHOD (combo_box, possible_dest_types, widget);
408
501cfd01ee6d Import from CVS: tag r21-2-34
cvs
parents: 406
diff changeset
1343 IIFORMAT_HAS_SHARED_METHOD (combo_box, governing_domain, subwindow);
501cfd01ee6d Import from CVS: tag r21-2-34
cvs
parents: 406
diff changeset
1344
398
74fd4e045ea6 Import from CVS: tag r21-2-29
cvs
parents: 388
diff changeset
1345 VALID_GUI_KEYWORDS (combo_box);
384
bbff43aa5eb7 Import from CVS: tag r21-2-7
cvs
parents:
diff changeset
1346
398
74fd4e045ea6 Import from CVS: tag r21-2-29
cvs
parents: 388
diff changeset
1347 IIFORMAT_VALID_KEYWORD (combo_box, Q_width, check_valid_int);
74fd4e045ea6 Import from CVS: tag r21-2-29
cvs
parents: 388
diff changeset
1348 IIFORMAT_VALID_KEYWORD (combo_box, Q_height, check_valid_int);
404
2f8bb876ab1d Import from CVS: tag r21-2-32
cvs
parents: 400
diff changeset
1349 IIFORMAT_VALID_KEYWORD (combo_box, Q_pixel_width, check_valid_int_or_function);
398
74fd4e045ea6 Import from CVS: tag r21-2-29
cvs
parents: 388
diff changeset
1350 IIFORMAT_VALID_KEYWORD (combo_box, Q_face, check_valid_face);
74fd4e045ea6 Import from CVS: tag r21-2-29
cvs
parents: 388
diff changeset
1351 IIFORMAT_VALID_KEYWORD (combo_box, Q_properties, check_valid_item_list);
74fd4e045ea6 Import from CVS: tag r21-2-29
cvs
parents: 388
diff changeset
1352 }
388
aabb7f5b1c81 Import from CVS: tag r21-2-9
cvs
parents: 384
diff changeset
1353
398
74fd4e045ea6 Import from CVS: tag r21-2-29
cvs
parents: 388
diff changeset
1354 static void image_instantiator_scrollbar (void)
74fd4e045ea6 Import from CVS: tag r21-2-29
cvs
parents: 388
diff changeset
1355 {
384
bbff43aa5eb7 Import from CVS: tag r21-2-7
cvs
parents:
diff changeset
1356 INITIALIZE_IMAGE_INSTANTIATOR_FORMAT (scrollbar, "scrollbar");
bbff43aa5eb7 Import from CVS: tag r21-2-7
cvs
parents:
diff changeset
1357 IIFORMAT_HAS_SHARED_METHOD (scrollbar, validate, widget);
bbff43aa5eb7 Import from CVS: tag r21-2-7
cvs
parents:
diff changeset
1358 IIFORMAT_HAS_SHARED_METHOD (scrollbar, possible_dest_types, widget);
bbff43aa5eb7 Import from CVS: tag r21-2-7
cvs
parents:
diff changeset
1359 IIFORMAT_HAS_SHARED_METHOD (scrollbar, instantiate, widget);
408
501cfd01ee6d Import from CVS: tag r21-2-34
cvs
parents: 406
diff changeset
1360 IIFORMAT_HAS_SHARED_METHOD (scrollbar, post_instantiate, widget);
501cfd01ee6d Import from CVS: tag r21-2-34
cvs
parents: 406
diff changeset
1361 IIFORMAT_HAS_SHARED_METHOD (scrollbar, governing_domain, subwindow);
388
aabb7f5b1c81 Import from CVS: tag r21-2-9
cvs
parents: 384
diff changeset
1362 VALID_GUI_KEYWORDS (scrollbar);
384
bbff43aa5eb7 Import from CVS: tag r21-2-7
cvs
parents:
diff changeset
1363
404
2f8bb876ab1d Import from CVS: tag r21-2-32
cvs
parents: 400
diff changeset
1364 IIFORMAT_VALID_KEYWORD (scrollbar, Q_pixel_width, check_valid_int_or_function);
2f8bb876ab1d Import from CVS: tag r21-2-32
cvs
parents: 400
diff changeset
1365 IIFORMAT_VALID_KEYWORD (scrollbar, Q_pixel_height, check_valid_int_or_function);
384
bbff43aa5eb7 Import from CVS: tag r21-2-7
cvs
parents:
diff changeset
1366 IIFORMAT_VALID_KEYWORD (scrollbar, Q_face, check_valid_face);
398
74fd4e045ea6 Import from CVS: tag r21-2-29
cvs
parents: 388
diff changeset
1367 }
388
aabb7f5b1c81 Import from CVS: tag r21-2-9
cvs
parents: 384
diff changeset
1368
398
74fd4e045ea6 Import from CVS: tag r21-2-29
cvs
parents: 388
diff changeset
1369 static void image_instantiator_progress_guage (void)
74fd4e045ea6 Import from CVS: tag r21-2-29
cvs
parents: 388
diff changeset
1370 {
74fd4e045ea6 Import from CVS: tag r21-2-29
cvs
parents: 388
diff changeset
1371 INITIALIZE_IMAGE_INSTANTIATOR_FORMAT (progress_gauge, "progress-gauge");
74fd4e045ea6 Import from CVS: tag r21-2-29
cvs
parents: 388
diff changeset
1372 IIFORMAT_HAS_SHARED_METHOD (progress_gauge, validate, widget);
74fd4e045ea6 Import from CVS: tag r21-2-29
cvs
parents: 388
diff changeset
1373 IIFORMAT_HAS_SHARED_METHOD (progress_gauge, possible_dest_types, widget);
74fd4e045ea6 Import from CVS: tag r21-2-29
cvs
parents: 388
diff changeset
1374 IIFORMAT_HAS_SHARED_METHOD (progress_gauge, instantiate, widget);
408
501cfd01ee6d Import from CVS: tag r21-2-34
cvs
parents: 406
diff changeset
1375 IIFORMAT_HAS_SHARED_METHOD (progress_gauge, post_instantiate, widget);
501cfd01ee6d Import from CVS: tag r21-2-34
cvs
parents: 406
diff changeset
1376 IIFORMAT_HAS_SHARED_METHOD (progress_gauge, governing_domain, subwindow);
398
74fd4e045ea6 Import from CVS: tag r21-2-29
cvs
parents: 388
diff changeset
1377 IIFORMAT_HAS_METHOD (progress_gauge, set_property);
74fd4e045ea6 Import from CVS: tag r21-2-29
cvs
parents: 388
diff changeset
1378 VALID_WIDGET_KEYWORDS (progress_gauge);
74fd4e045ea6 Import from CVS: tag r21-2-29
cvs
parents: 388
diff changeset
1379 VALID_GUI_KEYWORDS (progress_gauge);
74fd4e045ea6 Import from CVS: tag r21-2-29
cvs
parents: 388
diff changeset
1380 }
388
aabb7f5b1c81 Import from CVS: tag r21-2-9
cvs
parents: 384
diff changeset
1381
398
74fd4e045ea6 Import from CVS: tag r21-2-29
cvs
parents: 388
diff changeset
1382 static void image_instantiator_tree_view (void)
74fd4e045ea6 Import from CVS: tag r21-2-29
cvs
parents: 388
diff changeset
1383 {
74fd4e045ea6 Import from CVS: tag r21-2-29
cvs
parents: 388
diff changeset
1384 INITIALIZE_IMAGE_INSTANTIATOR_FORMAT (tree_view, "tree-view");
74fd4e045ea6 Import from CVS: tag r21-2-29
cvs
parents: 388
diff changeset
1385 IIFORMAT_HAS_SHARED_METHOD (tree_view, validate, combo_box);
74fd4e045ea6 Import from CVS: tag r21-2-29
cvs
parents: 388
diff changeset
1386 IIFORMAT_HAS_SHARED_METHOD (tree_view, possible_dest_types, widget);
74fd4e045ea6 Import from CVS: tag r21-2-29
cvs
parents: 388
diff changeset
1387 IIFORMAT_HAS_SHARED_METHOD (tree_view, instantiate, widget);
408
501cfd01ee6d Import from CVS: tag r21-2-34
cvs
parents: 406
diff changeset
1388 IIFORMAT_HAS_SHARED_METHOD (tree_view, post_instantiate, widget);
501cfd01ee6d Import from CVS: tag r21-2-34
cvs
parents: 406
diff changeset
1389 IIFORMAT_HAS_SHARED_METHOD (tree_view, governing_domain, subwindow);
398
74fd4e045ea6 Import from CVS: tag r21-2-29
cvs
parents: 388
diff changeset
1390 IIFORMAT_HAS_METHOD (tree_view, query_geometry);
74fd4e045ea6 Import from CVS: tag r21-2-29
cvs
parents: 388
diff changeset
1391 VALID_WIDGET_KEYWORDS (tree_view);
74fd4e045ea6 Import from CVS: tag r21-2-29
cvs
parents: 388
diff changeset
1392 VALID_GUI_KEYWORDS (tree_view);
74fd4e045ea6 Import from CVS: tag r21-2-29
cvs
parents: 388
diff changeset
1393 IIFORMAT_VALID_KEYWORD (tree_view, Q_properties, check_valid_item_list);
74fd4e045ea6 Import from CVS: tag r21-2-29
cvs
parents: 388
diff changeset
1394 }
74fd4e045ea6 Import from CVS: tag r21-2-29
cvs
parents: 388
diff changeset
1395
74fd4e045ea6 Import from CVS: tag r21-2-29
cvs
parents: 388
diff changeset
1396 static void image_instantiator_tab_control (void)
74fd4e045ea6 Import from CVS: tag r21-2-29
cvs
parents: 388
diff changeset
1397 {
74fd4e045ea6 Import from CVS: tag r21-2-29
cvs
parents: 388
diff changeset
1398 INITIALIZE_IMAGE_INSTANTIATOR_FORMAT (tab_control, "tab-control");
74fd4e045ea6 Import from CVS: tag r21-2-29
cvs
parents: 388
diff changeset
1399 IIFORMAT_HAS_SHARED_METHOD (tab_control, validate, combo_box);
74fd4e045ea6 Import from CVS: tag r21-2-29
cvs
parents: 388
diff changeset
1400 IIFORMAT_HAS_SHARED_METHOD (tab_control, possible_dest_types, widget);
74fd4e045ea6 Import from CVS: tag r21-2-29
cvs
parents: 388
diff changeset
1401 IIFORMAT_HAS_SHARED_METHOD (tab_control, instantiate, widget);
408
501cfd01ee6d Import from CVS: tag r21-2-34
cvs
parents: 406
diff changeset
1402 IIFORMAT_HAS_SHARED_METHOD (tab_control, post_instantiate, widget);
501cfd01ee6d Import from CVS: tag r21-2-34
cvs
parents: 406
diff changeset
1403 IIFORMAT_HAS_SHARED_METHOD (tab_control, governing_domain, subwindow);
398
74fd4e045ea6 Import from CVS: tag r21-2-29
cvs
parents: 388
diff changeset
1404 IIFORMAT_HAS_METHOD (tab_control, query_geometry);
74fd4e045ea6 Import from CVS: tag r21-2-29
cvs
parents: 388
diff changeset
1405 IIFORMAT_HAS_METHOD (tab_control, set_property);
74fd4e045ea6 Import from CVS: tag r21-2-29
cvs
parents: 388
diff changeset
1406 VALID_WIDGET_KEYWORDS (tab_control);
74fd4e045ea6 Import from CVS: tag r21-2-29
cvs
parents: 388
diff changeset
1407 VALID_GUI_KEYWORDS (tab_control);
74fd4e045ea6 Import from CVS: tag r21-2-29
cvs
parents: 388
diff changeset
1408 IIFORMAT_VALID_KEYWORD (tab_control, Q_orientation, check_valid_tab_orientation);
74fd4e045ea6 Import from CVS: tag r21-2-29
cvs
parents: 388
diff changeset
1409 IIFORMAT_VALID_KEYWORD (tab_control, Q_properties, check_valid_item_list);
74fd4e045ea6 Import from CVS: tag r21-2-29
cvs
parents: 388
diff changeset
1410 }
74fd4e045ea6 Import from CVS: tag r21-2-29
cvs
parents: 388
diff changeset
1411
74fd4e045ea6 Import from CVS: tag r21-2-29
cvs
parents: 388
diff changeset
1412 static void image_instantiator_labels (void)
74fd4e045ea6 Import from CVS: tag r21-2-29
cvs
parents: 388
diff changeset
1413 {
384
bbff43aa5eb7 Import from CVS: tag r21-2-7
cvs
parents:
diff changeset
1414 INITIALIZE_IMAGE_INSTANTIATOR_FORMAT (label, "label");
bbff43aa5eb7 Import from CVS: tag r21-2-7
cvs
parents:
diff changeset
1415 IIFORMAT_HAS_SHARED_METHOD (label, possible_dest_types, widget);
398
74fd4e045ea6 Import from CVS: tag r21-2-29
cvs
parents: 388
diff changeset
1416 IIFORMAT_HAS_SHARED_METHOD (label, instantiate, widget);
408
501cfd01ee6d Import from CVS: tag r21-2-34
cvs
parents: 406
diff changeset
1417 IIFORMAT_HAS_SHARED_METHOD (label, post_instantiate, widget);
501cfd01ee6d Import from CVS: tag r21-2-34
cvs
parents: 406
diff changeset
1418 IIFORMAT_HAS_SHARED_METHOD (label, governing_domain, subwindow);
388
aabb7f5b1c81 Import from CVS: tag r21-2-9
cvs
parents: 384
diff changeset
1419 VALID_WIDGET_KEYWORDS (label);
aabb7f5b1c81 Import from CVS: tag r21-2-9
cvs
parents: 384
diff changeset
1420 IIFORMAT_VALID_KEYWORD (label, Q_descriptor, check_valid_string);
398
74fd4e045ea6 Import from CVS: tag r21-2-29
cvs
parents: 388
diff changeset
1421 }
384
bbff43aa5eb7 Import from CVS: tag r21-2-7
cvs
parents:
diff changeset
1422
408
501cfd01ee6d Import from CVS: tag r21-2-34
cvs
parents: 406
diff changeset
1423 #define VALID_LAYOUT_KEYWORDS(layout) \
501cfd01ee6d Import from CVS: tag r21-2-34
cvs
parents: 406
diff changeset
1424 VALID_WIDGET_KEYWORDS (layout); \
501cfd01ee6d Import from CVS: tag r21-2-34
cvs
parents: 406
diff changeset
1425 IIFORMAT_VALID_KEYWORD (layout, Q_orientation, check_valid_orientation); \
501cfd01ee6d Import from CVS: tag r21-2-34
cvs
parents: 406
diff changeset
1426 IIFORMAT_VALID_KEYWORD (layout, Q_justify, check_valid_justification); \
501cfd01ee6d Import from CVS: tag r21-2-34
cvs
parents: 406
diff changeset
1427 IIFORMAT_VALID_KEYWORD (layout, Q_border, check_valid_border); \
501cfd01ee6d Import from CVS: tag r21-2-34
cvs
parents: 406
diff changeset
1428 IIFORMAT_VALID_KEYWORD (layout, Q_margin_width, check_valid_int); \
501cfd01ee6d Import from CVS: tag r21-2-34
cvs
parents: 406
diff changeset
1429 IIFORMAT_VALID_KEYWORD (layout, Q_items, \
501cfd01ee6d Import from CVS: tag r21-2-34
cvs
parents: 406
diff changeset
1430 check_valid_glyph_or_instantiator_list)
501cfd01ee6d Import from CVS: tag r21-2-34
cvs
parents: 406
diff changeset
1431
398
74fd4e045ea6 Import from CVS: tag r21-2-29
cvs
parents: 388
diff changeset
1432 static void image_instantiator_layout (void)
74fd4e045ea6 Import from CVS: tag r21-2-29
cvs
parents: 388
diff changeset
1433 {
74fd4e045ea6 Import from CVS: tag r21-2-29
cvs
parents: 388
diff changeset
1434 INITIALIZE_IMAGE_INSTANTIATOR_FORMAT (layout, "layout");
408
501cfd01ee6d Import from CVS: tag r21-2-34
cvs
parents: 406
diff changeset
1435 IIFORMAT_HAS_SHARED_METHOD (layout, possible_dest_types, widget);
501cfd01ee6d Import from CVS: tag r21-2-34
cvs
parents: 406
diff changeset
1436 IIFORMAT_HAS_METHOD (layout, instantiate);
501cfd01ee6d Import from CVS: tag r21-2-34
cvs
parents: 406
diff changeset
1437 IIFORMAT_HAS_METHOD (layout, post_instantiate);
501cfd01ee6d Import from CVS: tag r21-2-34
cvs
parents: 406
diff changeset
1438 IIFORMAT_HAS_SHARED_METHOD (layout, governing_domain, subwindow);
398
74fd4e045ea6 Import from CVS: tag r21-2-29
cvs
parents: 388
diff changeset
1439 IIFORMAT_HAS_METHOD (layout, normalize);
74fd4e045ea6 Import from CVS: tag r21-2-29
cvs
parents: 388
diff changeset
1440 IIFORMAT_HAS_METHOD (layout, query_geometry);
74fd4e045ea6 Import from CVS: tag r21-2-29
cvs
parents: 388
diff changeset
1441 IIFORMAT_HAS_METHOD (layout, layout);
408
501cfd01ee6d Import from CVS: tag r21-2-34
cvs
parents: 406
diff changeset
1442
501cfd01ee6d Import from CVS: tag r21-2-34
cvs
parents: 406
diff changeset
1443 VALID_GUI_KEYWORDS (layout);
501cfd01ee6d Import from CVS: tag r21-2-34
cvs
parents: 406
diff changeset
1444 VALID_LAYOUT_KEYWORDS (layout);
501cfd01ee6d Import from CVS: tag r21-2-34
cvs
parents: 406
diff changeset
1445 }
501cfd01ee6d Import from CVS: tag r21-2-34
cvs
parents: 406
diff changeset
1446
501cfd01ee6d Import from CVS: tag r21-2-34
cvs
parents: 406
diff changeset
1447 static void image_instantiator_native_layout (void)
501cfd01ee6d Import from CVS: tag r21-2-34
cvs
parents: 406
diff changeset
1448 {
501cfd01ee6d Import from CVS: tag r21-2-34
cvs
parents: 406
diff changeset
1449 INITIALIZE_IMAGE_INSTANTIATOR_FORMAT (native_layout, "native-layout");
501cfd01ee6d Import from CVS: tag r21-2-34
cvs
parents: 406
diff changeset
1450 IIFORMAT_HAS_SHARED_METHOD (native_layout, possible_dest_types, widget);
501cfd01ee6d Import from CVS: tag r21-2-34
cvs
parents: 406
diff changeset
1451 IIFORMAT_HAS_SHARED_METHOD (native_layout, instantiate, layout);
501cfd01ee6d Import from CVS: tag r21-2-34
cvs
parents: 406
diff changeset
1452 IIFORMAT_HAS_SHARED_METHOD (native_layout, post_instantiate, layout);
501cfd01ee6d Import from CVS: tag r21-2-34
cvs
parents: 406
diff changeset
1453 IIFORMAT_HAS_METHOD (native_layout, layout);
501cfd01ee6d Import from CVS: tag r21-2-34
cvs
parents: 406
diff changeset
1454 IIFORMAT_HAS_SHARED_METHOD (native_layout, governing_domain, subwindow);
501cfd01ee6d Import from CVS: tag r21-2-34
cvs
parents: 406
diff changeset
1455 IIFORMAT_HAS_SHARED_METHOD (native_layout, normalize, layout);
501cfd01ee6d Import from CVS: tag r21-2-34
cvs
parents: 406
diff changeset
1456 IIFORMAT_HAS_SHARED_METHOD (native_layout, query_geometry, layout);
501cfd01ee6d Import from CVS: tag r21-2-34
cvs
parents: 406
diff changeset
1457 IIFORMAT_HAS_SHARED_METHOD (native_layout, layout, layout);
501cfd01ee6d Import from CVS: tag r21-2-34
cvs
parents: 406
diff changeset
1458
501cfd01ee6d Import from CVS: tag r21-2-34
cvs
parents: 406
diff changeset
1459 VALID_GUI_KEYWORDS (native_layout);
501cfd01ee6d Import from CVS: tag r21-2-34
cvs
parents: 406
diff changeset
1460 VALID_LAYOUT_KEYWORDS (native_layout);
398
74fd4e045ea6 Import from CVS: tag r21-2-29
cvs
parents: 388
diff changeset
1461 }
384
bbff43aa5eb7 Import from CVS: tag r21-2-7
cvs
parents:
diff changeset
1462
398
74fd4e045ea6 Import from CVS: tag r21-2-29
cvs
parents: 388
diff changeset
1463 void
74fd4e045ea6 Import from CVS: tag r21-2-29
cvs
parents: 388
diff changeset
1464 image_instantiator_format_create_glyphs_widget (void)
74fd4e045ea6 Import from CVS: tag r21-2-29
cvs
parents: 388
diff changeset
1465 {
74fd4e045ea6 Import from CVS: tag r21-2-29
cvs
parents: 388
diff changeset
1466 image_instantiator_widget();
74fd4e045ea6 Import from CVS: tag r21-2-29
cvs
parents: 388
diff changeset
1467 image_instantiator_buttons();
74fd4e045ea6 Import from CVS: tag r21-2-29
cvs
parents: 388
diff changeset
1468 image_instantiator_edit_fields();
74fd4e045ea6 Import from CVS: tag r21-2-29
cvs
parents: 388
diff changeset
1469 image_instantiator_combo_box();
74fd4e045ea6 Import from CVS: tag r21-2-29
cvs
parents: 388
diff changeset
1470 image_instantiator_scrollbar();
74fd4e045ea6 Import from CVS: tag r21-2-29
cvs
parents: 388
diff changeset
1471 image_instantiator_progress_guage();
74fd4e045ea6 Import from CVS: tag r21-2-29
cvs
parents: 388
diff changeset
1472 image_instantiator_tree_view();
74fd4e045ea6 Import from CVS: tag r21-2-29
cvs
parents: 388
diff changeset
1473 image_instantiator_tab_control();
74fd4e045ea6 Import from CVS: tag r21-2-29
cvs
parents: 388
diff changeset
1474 image_instantiator_labels();
74fd4e045ea6 Import from CVS: tag r21-2-29
cvs
parents: 388
diff changeset
1475 image_instantiator_layout();
408
501cfd01ee6d Import from CVS: tag r21-2-34
cvs
parents: 406
diff changeset
1476 image_instantiator_native_layout();
398
74fd4e045ea6 Import from CVS: tag r21-2-29
cvs
parents: 388
diff changeset
1477 }
74fd4e045ea6 Import from CVS: tag r21-2-29
cvs
parents: 388
diff changeset
1478
74fd4e045ea6 Import from CVS: tag r21-2-29
cvs
parents: 388
diff changeset
1479 void
74fd4e045ea6 Import from CVS: tag r21-2-29
cvs
parents: 388
diff changeset
1480 reinit_vars_of_glyphs_widget (void)
74fd4e045ea6 Import from CVS: tag r21-2-29
cvs
parents: 388
diff changeset
1481 {
74fd4e045ea6 Import from CVS: tag r21-2-29
cvs
parents: 388
diff changeset
1482 #ifdef DEBUG_WIDGETS
74fd4e045ea6 Import from CVS: tag r21-2-29
cvs
parents: 388
diff changeset
1483 debug_widget_instances = 0;
384
bbff43aa5eb7 Import from CVS: tag r21-2-7
cvs
parents:
diff changeset
1484 #endif
bbff43aa5eb7 Import from CVS: tag r21-2-7
cvs
parents:
diff changeset
1485 }
bbff43aa5eb7 Import from CVS: tag r21-2-7
cvs
parents:
diff changeset
1486
bbff43aa5eb7 Import from CVS: tag r21-2-7
cvs
parents:
diff changeset
1487 void
bbff43aa5eb7 Import from CVS: tag r21-2-7
cvs
parents:
diff changeset
1488 vars_of_glyphs_widget (void)
bbff43aa5eb7 Import from CVS: tag r21-2-7
cvs
parents:
diff changeset
1489 {
398
74fd4e045ea6 Import from CVS: tag r21-2-29
cvs
parents: 388
diff changeset
1490 reinit_vars_of_glyphs_widget ();
384
bbff43aa5eb7 Import from CVS: tag r21-2-7
cvs
parents:
diff changeset
1491 }