annotate src/glyphs-widget.c @ 440:8de8e3f6228a r21-2-28

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