annotate src/glyphs-widget.c @ 404:2f8bb876ab1d r21-2-32

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