1 /*
2 * Motif Tools Library, Version 3.1
3 * $Id: LayoutGadget.c,v 1.2 2001/09/19 02:57:18 grmcdorman Exp $
4 *
5 * Written by David Flanagan.
6 * Copyright (c) 1992-2001 by David Flanagan.
7 * All Rights Reserved. See the file COPYRIGHT for details.
8 * This is open source software. See the file LICENSE for details.
9 * There is no warranty for this software. See NO_WARRANTY for details.
10 *
11 * $Log: LayoutGadget.c,v $
12 * Revision 1.2 2001/09/19 02:57:18 grmcdorman
13 * This change makes the following modifications:
14 * A new program, printConfig, is provided. This is built by a
15 * simple rule in the Makefile and not installed. It prints
16 * significant defines from Xmt.tmpl.
17 *
18 * XmtP.h is now generated from XmtP.h.in using printConfig. As
19 * a result, code compiled outside of the Xmt Imakefiles will
20 * have all of the Xmt.tmpl defines.
21 *
22 * Source files are modified to use XmtP.h instead of Xmt.h.
23 *
24 * WorkingBox.c is modified to use the new Progress widget.
25 * It can be compiled in the old style if WORKINGBOX_USE_SCALE is
26 * defined at compile time.
27 *
28 * Because XmtP.h is generated dynamically, it is removed from CVS
29 * with this check-in.
30 *
31 * Revision 1.1.1.1 2001/02/10 13:46:15 motiftools
32 * Initial import of Xmt310 to CVS
33 *
34 *
35 */
36
37 #include <Xmt/XmtP.h>
38 #include <Xmt/LayoutGP.h>
39
40 /* $XConsortium: RectObj.c,v 1.14 91/06/11 20:11:45 converse Exp $ */
41
42 #if NeedFunctionPrototypes
43 static void CopyAncestorSensitive(Widget widget, int offset, XrmValue *value);
44 #else
45 static void CopyAncestorSensitive();
46 #endif
47
48 static XtResource resources[] = {
49 {XtNancestorSensitive, XtCSensitive, XtRBoolean, sizeof(Boolean),
50 XtOffsetOf(XmtLayoutGadgetRec,rectangle.ancestor_sensitive),XtRCallProc,
51 (XtPointer)CopyAncestorSensitive},
52 {XtNx, XtCPosition, XtRPosition, sizeof(Position),
53 XtOffsetOf(XmtLayoutGadgetRec,rectangle.x),
54 XtRImmediate, (XtPointer)0},
55 {XtNy, XtCPosition, XtRPosition, sizeof(Position),
56 XtOffsetOf(XmtLayoutGadgetRec,rectangle.y),
57 XtRImmediate, (XtPointer)0},
58 {XtNwidth, XtCWidth, XtRDimension, sizeof(Dimension),
59 XtOffsetOf(XmtLayoutGadgetRec,rectangle.width),
60 XtRImmediate, (XtPointer)0},
61 {XtNheight, XtCHeight, XtRDimension, sizeof(Dimension),
62 XtOffsetOf(XmtLayoutGadgetRec,rectangle.height),
63 XtRImmediate, (XtPointer)0},
64 {XtNborderWidth, XtCBorderWidth, XtRDimension, sizeof(Dimension),
65 XtOffsetOf(XmtLayoutGadgetRec,rectangle.border_width),
66 XtRImmediate, (XtPointer)1},
67 {XtNsensitive, XtCSensitive, XtRBoolean, sizeof(Boolean),
68 XtOffsetOf(XmtLayoutGadgetRec,rectangle.sensitive),
69 XtRImmediate, (XtPointer)True}
70 };
71
72 #if XmVersion >= 1002
73 #if NeedFunctionPrototypes
74 static void ClassInitialize(void);
75 #else
76 static void ClassInitialize();
77 #endif
78 #endif
79 #if NeedFunctionPrototypes
80 static void Initialize(Widget requested_widget, register Widget new_widget,
81 ArgList args, Cardinal *num_args);
82 static void ClassPartInitialize(register WidgetClass wc);
83 static void SetValuesAlmost(Widget old, Widget new,
84 XtWidgetGeometry *request,XtWidgetGeometry *reply);
85 #else
86 static void Initialize();
87 static void ClassPartInitialize();
88 static void SetValuesAlmost();
89 #endif
90
91 #if XmVersion >= 1002
92 XmBaseClassExtRec baseClassExt = {
93 NULL,
94 NULLQUARK,
95 XmBaseClassExtVersion,
96 sizeof(XmBaseClassExtRec),
97 NULL, /* InitializePrehook */
98 NULL, /* SetValuesPrehook */
99 NULL, /* InitializePosthook */
100 NULL, /* SetValuesPosthook */
101 NULL, /* secondaryObjectClass */
102 NULL, /* secondaryCreate */
103 NULL, /* getSecRes data */
104 { 0 }, /* fastSubclass flags */
105 NULL, /* get_values_prehook */
106 NULL, /* get_values_posthook */
107 NULL, /* classPartInitPrehook */
108 NULL, /* classPartInitPosthook*/
109 NULL, /* ext_resources */
110 NULL, /* compiled_ext_resources*/
111 0, /* num_ext_resources */
112 FALSE, /* use_sub_resources */
113 NULL, /* widgetNavigable */
114 NULL, /* focusChange */
115 };
116 #endif
117
118 externaldef(xmtlayoutgadgetclassrec)
119 XmtLayoutGadgetClassRec xmtLayoutGadgetClassRec = {
120 {
121 /* superclass */ (WidgetClass)&objectClassRec,
122 /* class_name */ "XmtLayoutGadget",
123 /* widget_size */ sizeof(XmtLayoutGadgetRec),
124 #if XmVersion <= 1001
125 /* class_initialize */ NULL,
126 #else
127 /* class_initialize */ ClassInitialize,
128 #endif
129 /* class_part_initialize*/ ClassPartInitialize,
130 /* class_inited */ FALSE,
131 /* initialize */ Initialize,
132 /* initialize_hook */ NULL,
133 /* realize */ NULL,
134 /* actions */ NULL,
135 /* num_actions */ 0,
136 /* resources */ resources,
137 /* num_resources */ XtNumber(resources),
138 /* xrm_class */ NULLQUARK,
139 /* compress_motion */ FALSE,
140 /* compress_exposure */ TRUE,
141 /* compress_enterleave*/ FALSE,
142 /* visible_interest */ FALSE,
143 /* destroy */ NULL,
144 /* resize */ NULL,
145 /* expose */ NULL,
146 /* set_values */ NULL,
147 /* set_values_hook */ NULL,
148 /* set_values_almost */ SetValuesAlmost,
149 /* get_values_hook */ NULL,
150 /* accept_focus */ NULL,
151 /* version */ XtVersion,
152 /* callback_offsets */ NULL,
153 /* tm_table */ NULL,
154 /* query_geometry */ NULL,
155 /* display_accelerator */ NULL,
156 #if XmVersion <= 1001
157 /* extension */ NULL,
158 #else
159 /* extension */ (XtPointer)&baseClassExt,
160 #endif
161 }
162 };
163
164 externaldef(xmtlayoutgadgetclass)
165 WidgetClass xmtLayoutGadgetClass = (WidgetClass)&xmtLayoutGadgetClassRec;
166
167 /*ARGSUSED*/
168 #if NeedFunctionPrototypes
CopyAncestorSensitive(Widget widget,int offset,XrmValue * value)169 static void CopyAncestorSensitive(Widget widget, int offset, XrmValue *value)
170 #else
171 static void CopyAncestorSensitive(widget, offset, value)
172 Widget widget;
173 int offset;
174 XrmValue *value;
175 #endif
176 {
177 static Boolean sensitive;
178 Widget parent = widget->core.parent;
179
180 sensitive = (parent->core.ancestor_sensitive & parent->core.sensitive);
181 value->addr = (XPointer)(&sensitive);
182 }
183
184 #if XmVersion >= 1002
185 #if NeedFunctionPrototypes
ClassInitialize(void)186 static void ClassInitialize(void)
187 #else
188 static void ClassInitialize()
189 #endif
190 {
191 baseClassExt.record_type = XmQmotif;
192 }
193 #endif
194
195 #if NeedFunctionPrototypes
ClassPartInitialize(register WidgetClass wc)196 static void ClassPartInitialize(register WidgetClass wc)
197 #else
198 static void ClassPartInitialize(wc)
199 register WidgetClass wc;
200 #endif
201 {
202 register XmtLayoutGadgetClass roc = (XmtLayoutGadgetClass)wc;
203 register XmtLayoutGadgetClass super =
204 ((XmtLayoutGadgetClass)roc->rect_class.superclass);
205
206 if (roc->rect_class.resize == XtInheritResize) {
207 roc->rect_class.resize = super->rect_class.resize;
208 }
209
210 if (roc->rect_class.expose == XtInheritExpose) {
211 roc->rect_class.expose = super->rect_class.expose;
212 }
213
214 if (roc->rect_class.set_values_almost == XtInheritSetValuesAlmost) {
215 roc->rect_class.set_values_almost = super->rect_class.set_values_almost;
216 }
217
218 if (roc->rect_class.query_geometry == XtInheritQueryGeometry) {
219 roc->rect_class.query_geometry = super->rect_class.query_geometry;
220 }
221
222 #if XmVersion >= 1002
223 /* always inherit the base class extension.
224 * We assume that there aren't any other extension records.
225 */
226 roc->rect_class.extension = (XtPointer)&baseClassExt;
227 #endif
228 }
229
230 /* ARGSUSED */
231 #if NeedFunctionPrototypes
Initialize(Widget requested_widget,register Widget new_widget,ArgList args,Cardinal * num_args)232 static void Initialize(Widget requested_widget, register Widget new_widget,
233 ArgList args, Cardinal *num_args)
234 #else
235 static void Initialize(requested_widget, new_widget, args, num_args)
236 Widget requested_widget;
237 register Widget new_widget;
238 ArgList args;
239 Cardinal *num_args;
240 #endif
241 {
242 ((XmtLayoutGadget)new_widget)->rectangle.managed = FALSE;
243 }
244
245 /*ARGSUSED*/
246 #if NeedFunctionPrototypes
SetValuesAlmost(Widget old,Widget new,XtWidgetGeometry * request,XtWidgetGeometry * reply)247 static void SetValuesAlmost(Widget old, Widget new,
248 XtWidgetGeometry *request, XtWidgetGeometry *reply)
249 #else
250 static void SetValuesAlmost(old, new, request, reply)
251 Widget old;
252 Widget new;
253 XtWidgetGeometry *request;
254 XtWidgetGeometry *reply;
255 #endif
256 {
257 *request = *reply;
258 }
259