1 /* Generated by wbuild from "RowCol.w"
2 ** (generator version $Revision: 404 $ of $Date: 1999-09-28 09:56:30 -0600 (Tue, 28 Sep 1999) $)
3 */
4 #include <X11/IntrinsicP.h>
5 #include <X11/StringDefs.h>
6 #include "RowColP.h"
7 static void _resolve_inheritance(
8 #if NeedFunctionPrototypes
9 WidgetClass
10 #endif
11 );
12 #line 87 "RowCol.w"
13 static void change_managed(
14 #if NeedFunctionPrototypes
15 Widget
16 #endif
17 );
18 #line 105 "RowCol.w"
19 static void layout(
20 #if NeedFunctionPrototypes
21 Widget,int
22 #endif
23 );
24 #line 187 "RowCol.w"
25 static XtGeometryResult geometry_manager(
26 #if NeedFunctionPrototypes
27 Widget ,XtWidgetGeometry *,XtWidgetGeometry *
28 #endif
29 );
30 #line 212 "RowCol.w"
31 static void resize(
32 #if NeedFunctionPrototypes
33 Widget
34 #endif
35 );
36 #line 221 "RowCol.w"
37 static void initialize(
38 #if NeedFunctionPrototypes
39 Widget ,Widget,ArgList ,Cardinal *
40 #endif
41 );
42 #line 231 "RowCol.w"
43 static Boolean set_values(
44 #if NeedFunctionPrototypes
45 Widget ,Widget ,Widget,ArgList ,Cardinal *
46 #endif
47 );
48 #line 250 "RowCol.w"
49 static char rcsid[] = "$Header$";
50 #line 255 "RowCol.w"
51 static void align_child(
52 #if NeedFunctionPrototypes
53 Widget,int ,int ,int ,int ,Alignment
54 #endif
55 );
56 #line 255 "RowCol.w"
57 /*ARGSUSED*/
58 #if NeedFunctionPrototypes
59 #line 255 "RowCol.w"
align_child(Widget self,int cx,int cy,int width,int height,Alignment alignment)60 static void align_child(Widget self,int cx,int cy,int width,int height,Alignment alignment)
61 #else
62 #line 255 "RowCol.w"
63 static void align_child(self,cx,cy,width,height,alignment)Widget self;int cx;int cy;int width;int height;Alignment alignment;
64 #endif
65 #line 256 "RowCol.w"
66 {
67 Position x, y;
68
69 if (alignment & XfwfLeft) x = cx;
70 else if (alignment & XfwfRight) x = cx + width - ((XfwfRowColWidget)self)->core.width;
71 else x = cx + (width - ((XfwfRowColWidget)self)->core.width) / 2;
72 if (alignment & XfwfTop) y = cy;
73 else if (alignment & XfwfBottom) y = cy + height - ((XfwfRowColWidget)self)->core.height;
74 else y = cy + (height - ((XfwfRowColWidget)self)->core.height) / 2;
75 XtMoveWidget(self, x, y);
76 }
77
78 static XtResource resources[] = {
79 #line 31 "RowCol.w"
80 {XtNstoreByRow,XtCStoreByRow,XtRBoolean,sizeof(((XfwfRowColRec*)NULL)->xfwfRowCol.storeByRow),XtOffsetOf(XfwfRowColRec,xfwfRowCol.storeByRow),XtRImmediate,(XtPointer)True },
81 #line 41 "RowCol.w"
82 {XtNrows,XtCRows,XtRInt,sizeof(((XfwfRowColRec*)NULL)->xfwfRowCol.rows),XtOffsetOf(XfwfRowColRec,xfwfRowCol.rows),XtRImmediate,(XtPointer)0 },
83 #line 42 "RowCol.w"
84 {XtNcolumns,XtCColumns,XtRInt,sizeof(((XfwfRowColRec*)NULL)->xfwfRowCol.columns),XtOffsetOf(XfwfRowColRec,xfwfRowCol.columns),XtRImmediate,(XtPointer)0 },
85 #line 51 "RowCol.w"
86 {XtNalignment,XtCAlignment,XtRAlignment,sizeof(((XfwfRowColRec*)NULL)->xfwfRowCol.alignment),XtOffsetOf(XfwfRowColRec,xfwfRowCol.alignment),XtRImmediate,(XtPointer)XfwfTopLeft },
87 #line 63 "RowCol.w"
88 {XtNshrinkToFit,XtCShrinkToFit,XtRBoolean,sizeof(((XfwfRowColRec*)NULL)->xfwfRowCol.shrinkToFit),XtOffsetOf(XfwfRowColRec,xfwfRowCol.shrinkToFit),XtRImmediate,(XtPointer)False },
89 #line 69 "RowCol.w"
90 {XtNframeType,XtCFrameType,XtRFrameType,sizeof(((XfwfRowColRec*)NULL)->xfwfFrame.frameType),XtOffsetOf(XfwfRowColRec,xfwfFrame.frameType),XtRImmediate,(XtPointer)XfwfSunken },
91 #line 70 "RowCol.w"
92 {XtNframeWidth,XtCFrameWidth,XtRDimension,sizeof(((XfwfRowColRec*)NULL)->xfwfFrame.frameWidth),XtOffsetOf(XfwfRowColRec,xfwfFrame.frameWidth),XtRImmediate,(XtPointer)2 },
93 };
94
95 XfwfRowColClassRec xfwfRowColClassRec = {
96 { /* core_class part */
97 /* superclass */ (WidgetClass) &xfwfBoardClassRec,
98 /* class_name */ "XfwfRowCol",
99 /* widget_size */ sizeof(XfwfRowColRec),
100 /* class_initialize */ NULL,
101 /* class_part_initialize*/ _resolve_inheritance,
102 /* class_inited */ FALSE,
103 /* initialize */ initialize,
104 /* initialize_hook */ NULL,
105 /* realize */ XtInheritRealize,
106 /* actions */ NULL,
107 /* num_actions */ 0,
108 /* resources */ resources,
109 /* num_resources */ 7,
110 /* xrm_class */ NULLQUARK,
111 /* compres_motion */ True ,
112 /* compress_exposure */ XtExposeCompressMultiple ,
113 /* compress_enterleave */ True ,
114 /* visible_interest */ TRUE ,
115 /* destroy */ NULL,
116 /* resize */ resize,
117 /* expose */ XtInheritExpose,
118 /* set_values */ set_values,
119 /* set_values_hook */ NULL,
120 /* set_values_almost */ XtInheritSetValuesAlmost,
121 /* get_values+hook */ NULL,
122 /* accept_focus */ XtInheritAcceptFocus,
123 /* version */ XtVersion,
124 /* callback_private */ NULL,
125 /* tm_table */ NULL,
126 /* query_geometry */ XtInheritQueryGeometry,
127 /* display_acceleator */ XtInheritDisplayAccelerator,
128 /* extension */ NULL
129 },
130 { /* composite_class part */
131 geometry_manager,
132 change_managed,
133 XtInheritInsertChild,
134 XtInheritDeleteChild,
135 NULL
136 },
137 { /* XfwfCommon_class part */
138 XtInherit_compute_inside,
139 XtInherit_total_frame_width,
140 XtInherit_highlight_border,
141 XtInherit_unhighlight_border,
142 XtInherit_would_accept_focus,
143 XtInherit_traverse,
144 XtInherit_lighter_color,
145 XtInherit_darker_color,
146 /* traversal_trans */ NULL ,
147 },
148 { /* XfwfFrame_class part */
149 /* dummy */ 0
150 },
151 { /* XfwfBoard_class part */
152 XtInherit_set_abs_location,
153 },
154 { /* XfwfRowCol_class part */
155 layout,
156 },
157 };
158 WidgetClass xfwfRowColWidgetClass = (WidgetClass) &xfwfRowColClassRec;
_resolve_inheritance(class)159 static void _resolve_inheritance(class)
160 WidgetClass class;
161 {
162 XfwfRowColWidgetClass c = (XfwfRowColWidgetClass) class;
163 XfwfRowColWidgetClass super;
164 static CompositeClassExtensionRec extension_rec = {
165 NULL, NULLQUARK, XtCompositeExtensionVersion,
166 sizeof(CompositeClassExtensionRec), True};
167 CompositeClassExtensionRec *ext;
168 ext = (XtPointer)XtMalloc(sizeof(*ext));
169 *ext = extension_rec;
170 ext->next_extension = c->composite_class.extension;
171 c->composite_class.extension = ext;
172 if (class == xfwfRowColWidgetClass) return;
173 super = (XfwfRowColWidgetClass)class->core_class.superclass;
174 if (c->xfwfRowCol_class.layout == XtInherit_layout)
175 c->xfwfRowCol_class.layout = super->xfwfRowCol_class.layout;
176 }
177 #line 87 "RowCol.w"
178 /*ARGSUSED*/
179 #if NeedFunctionPrototypes
180 #line 87 "RowCol.w"
change_managed(Widget self)181 static void change_managed(Widget self)
182 #else
183 #line 87 "RowCol.w"
184 static void change_managed(self)Widget self;
185 #endif
186 #line 88 "RowCol.w"
187 {
188 ((XfwfRowColWidgetClass)self->core.widget_class)->xfwfRowCol_class.layout(self, ((XfwfRowColWidget)self)->xfwfRowCol.shrinkToFit);
189 }
190 #line 105 "RowCol.w"
191 /*ARGSUSED*/
192 #if NeedFunctionPrototypes
193 #line 105 "RowCol.w"
layout(Widget self,int shrink)194 static void layout(Widget self,int shrink)
195 #else
196 #line 105 "RowCol.w"
197 static void layout(self,shrink)Widget self;int shrink;
198 #endif
199 #line 106 "RowCol.w"
200 {
201 int nrows, ncols, i, nchild, n;
202 Position left, top, x, y;
203 Dimension width, height, w, h;
204 Widget child;
205
206 nchild = 0;
207 ((XfwfRowColWidget)self)->xfwfRowCol.max_width = 0;
208 ((XfwfRowColWidget)self)->xfwfRowCol.max_height = 0;
209 for (i = 0; i < ((XfwfRowColWidget)self)->composite.num_children; i++) {
210 child = ((XfwfRowColWidget)self)->composite.children[i];
211 if (! XtIsManaged(child)) continue;
212 nchild++;
213 ((XfwfRowColWidget)self)->xfwfRowCol.max_width = max(((XfwfRowColWidget)self)->xfwfRowCol.max_width, ((XfwfRowColWidget)child)->core.width + 2*((XfwfRowColWidget)child)->core.border_width);
214 ((XfwfRowColWidget)self)->xfwfRowCol.max_height = max(((XfwfRowColWidget)self)->xfwfRowCol.max_height, ((XfwfRowColWidget)child)->core.height + 2*((XfwfRowColWidget)child)->core.border_width);
215
216 }
217
218 ((XfwfRowColWidgetClass)self->core.widget_class)->xfwfCommon_class.compute_inside(self, &left, &top, &width, &height);
219
220 if (((XfwfRowColWidget)self)->xfwfRowCol.columns != 0) {
221 ncols = ((XfwfRowColWidget)self)->xfwfRowCol.columns;
222 nrows = (nchild + ncols - 1)/ncols;
223 } else if (((XfwfRowColWidget)self)->xfwfRowCol.rows != 0) {
224 nrows = ((XfwfRowColWidget)self)->xfwfRowCol.rows;
225 ncols = (nchild + nrows - 1)/nrows;
226 } else {
227 ncols = ((XfwfRowColWidget)self)->xfwfRowCol.max_width != 0 ? width/((XfwfRowColWidget)self)->xfwfRowCol.max_width : 1;
228 if (ncols == 0) ncols = 1;
229 nrows = (nchild + ncols - 1)/ncols;
230 }
231
232 x = left;
233 y = top;
234 n = 0;
235 if (((XfwfRowColWidget)self)->xfwfRowCol.storeByRow) {
236 for (i = 0; i < ((XfwfRowColWidget)self)->composite.num_children; i++) {
237 child = ((XfwfRowColWidget)self)->composite.children[i];
238 if (! XtIsManaged(child)) continue;
239 align_child(child, x, y, ((XfwfRowColWidget)self)->xfwfRowCol.max_width, ((XfwfRowColWidget)self)->xfwfRowCol.max_height, ((XfwfRowColWidget)self)->xfwfRowCol.alignment);
240 n++;
241 if (n == ncols) {
242 n = 0;
243 x = left;
244 y += ((XfwfRowColWidget)self)->xfwfRowCol.max_height;
245 } else
246 x += ((XfwfRowColWidget)self)->xfwfRowCol.max_width;
247 }
248 } else {
249 for (i = 0; i < ((XfwfRowColWidget)self)->composite.num_children; i++) {
250 child = ((XfwfRowColWidget)self)->composite.children[i];
251 if (! XtIsManaged(child)) continue;
252 align_child(child, x, y, ((XfwfRowColWidget)self)->xfwfRowCol.max_width, ((XfwfRowColWidget)self)->xfwfRowCol.max_height, ((XfwfRowColWidget)self)->xfwfRowCol.alignment);
253 n++;
254 if (n == nrows) {
255 n = 0;
256 y = top;
257 x += ((XfwfRowColWidget)self)->xfwfRowCol.max_width;
258 } else
259 y += ((XfwfRowColWidget)self)->xfwfRowCol.max_height;
260 }
261 }
262
263 if (shrink) {
264 w = 2*left + ncols * ((XfwfRowColWidget)self)->xfwfRowCol.max_width;
265 h = 2*top + nrows * ((XfwfRowColWidget)self)->xfwfRowCol.max_height;
266 if (((XfwfRowColWidget)self)->xfwfRowCol.columns != 0)
267 XtVaSetValues(self, XtNwidth, w, XtNheight, h, NULL);
268 else
269 XtVaSetValues(self, XtNheight, h, NULL);
270 }
271 }
272 #line 187 "RowCol.w"
273 /*ARGSUSED*/
274 #if NeedFunctionPrototypes
275 #line 167 "RowCol.w"
geometry_manager(Widget child,XtWidgetGeometry * request,XtWidgetGeometry * reply)276 static XtGeometryResult geometry_manager(Widget child,XtWidgetGeometry * request,XtWidgetGeometry * reply)
277 #else
278 #line 167 "RowCol.w"
279 static XtGeometryResult geometry_manager(child,request,reply)Widget child;XtWidgetGeometry * request;XtWidgetGeometry * reply;
280 #endif
281 { Widget self = XtParent(child); {
282 Dimension newwd, newht, newbd;
283
284 if (request->request_mode & (CWX | CWY)) return XtGeometryNo;
285 if (request->request_mode & XtCWQueryOnly) return XtGeometryYes;
286
287 newwd = request->request_mode & CWWidth ? request->width : ((XfwfRowColWidget)child)->core.width;
288 newht = request->request_mode & CWHeight ? request->height : ((XfwfRowColWidget)child)->core.height;
289 newbd = request->request_mode & CWBorderWidth
290 ? request->border_width : ((XfwfRowColWidget)child)->core.border_width;
291
292 if (newwd == ((XfwfRowColWidget)child)->core.width && newht == ((XfwfRowColWidget)child)->core.height
293 && newbd == ((XfwfRowColWidget)child)->core.border_width) return XtGeometryNo;
294
295 XtResizeWidget(child, newwd, newht, newbd);
296 ((XfwfRowColWidgetClass)self->core.widget_class)->xfwfRowCol_class.layout(self, ((XfwfRowColWidget)self)->xfwfRowCol.shrinkToFit);
297 return XtGeometryDone;
298 }
299 }
300 #line 212 "RowCol.w"
301 /*ARGSUSED*/
302 #if NeedFunctionPrototypes
303 #line 212 "RowCol.w"
resize(Widget self)304 static void resize(Widget self)
305 #else
306 #line 212 "RowCol.w"
307 static void resize(self)Widget self;
308 #endif
309 #line 213 "RowCol.w"
310 {
311 if (((XfwfRowColWidget)self)->xfwfRowCol.rows == 0 && ((XfwfRowColWidget)self)->xfwfRowCol.columns == 0) ((XfwfRowColWidgetClass)self->core.widget_class)->xfwfRowCol_class.layout(self, False);
312 }
313 #line 221 "RowCol.w"
314 /*ARGSUSED*/
315 #if NeedFunctionPrototypes
316 #line 221 "RowCol.w"
initialize(Widget request,Widget self,ArgList args,Cardinal * num_args)317 static void initialize(Widget request,Widget self,ArgList args,Cardinal * num_args)
318 #else
319 #line 221 "RowCol.w"
320 static void initialize(request,self,args,num_args)Widget request;Widget self;ArgList args;Cardinal * num_args;
321 #endif
322 #line 222 "RowCol.w"
323 {
324 ((XfwfRowColWidget)self)->xfwfRowCol.max_width = ((XfwfRowColWidget)self)->xfwfRowCol.max_height = 0;
325 }
326 #line 231 "RowCol.w"
327 /*ARGSUSED*/
328 #if NeedFunctionPrototypes
329 #line 231 "RowCol.w"
set_values(Widget old,Widget request,Widget self,ArgList args,Cardinal * num_args)330 static Boolean set_values(Widget old,Widget request,Widget self,ArgList args,Cardinal * num_args)
331 #else
332 #line 231 "RowCol.w"
333 static Boolean set_values(old,request,self,args,num_args)Widget old;Widget request;Widget self;ArgList args;Cardinal * num_args;
334 #endif
335 #line 232 "RowCol.w"
336 {
337 Boolean need_layout = False;
338 Boolean need_redisplay = False;
339
340 if (((XfwfRowColWidget)old)->xfwfRowCol.storeByRow != ((XfwfRowColWidget)self)->xfwfRowCol.storeByRow) need_layout = True;
341 if (((XfwfRowColWidget)old)->xfwfRowCol.rows != ((XfwfRowColWidget)self)->xfwfRowCol.rows) need_layout = True;
342 if (((XfwfRowColWidget)old)->xfwfRowCol.columns != ((XfwfRowColWidget)self)->xfwfRowCol.columns) need_layout = True;
343 if (((XfwfRowColWidget)old)->xfwfRowCol.alignment != ((XfwfRowColWidget)self)->xfwfRowCol.alignment) need_layout = True;
344 if (((XfwfRowColWidget)old)->xfwfRowCol.shrinkToFit != ((XfwfRowColWidget)self)->xfwfRowCol.shrinkToFit) need_layout = True;
345 if (need_layout) {
346 ((XfwfRowColWidgetClass)self->core.widget_class)->xfwfRowCol_class.layout(self, ((XfwfRowColWidget)self)->xfwfRowCol.shrinkToFit);
347 need_redisplay = True;
348 }
349 return need_redisplay;
350 }
351