1 /*****************************************************************************
2  * XedwForm is a modified version of the Athena Widget Form.
3  * Added capabilities :
4  *  1) Children may chose not to be resized in any particular plane.
5  *  2) Children may chose to extend their widths to the edge of the application.
6  *  3) Children may have linked widths and heights.
7  * The default is that these capabilities are turned off.
8  * See XedwForm.h for resource list.
9  *
10  * Edward Groenendaal, 20th Feb 1991.
11  *
12  * Changes to the original source :
13  *      1) Changed all references of Form to XedwForm and form to xedwForm.
14  *      2) Added resources
15  *      3) Rewrote Resize(), Layout() and LayoutChild().
16  *****************************************************************************/
17 
18 #include <X11/IntrinsicP.h>
19 #include <X11/StringDefs.h>
20 #include <X11/Xmu/Converters.h>
21 #include <X11/Xmu/CharSet.h>
22 #include <X11/Xaw/XawInit.h>
23 #include "XedwFormP.h"
24 
25 /* Private Definitions */
26 
27 static int default_value = -99999;
28 
29 #define Offset(field) XtOffset(XedwFormWidget, xedwForm.field)
30 static XtResource resources[] = {
31     {XtNdefaultDistance, XtCThickness, XtRInt, sizeof(int),
32         Offset(default_spacing), XtRImmediate, (caddr_t)4}
33 };
34 #undef Offset
35 
36 static XtEdgeType defEdge = XtRubber;
37 
38 #define Offset(field) XtOffset(XedwFormConstraints, xedwForm.field)
39 static XtResource xedwFormConstraintResources[] = {
40   {XtNtop, XtCEdge, XtREdgeType, sizeof(XtEdgeType),
41      Offset(top), XtREdgeType, (XtPointer)&defEdge},
42   {XtNbottom, XtCEdge, XtREdgeType, sizeof(XtEdgeType),
43      Offset(bottom), XtREdgeType, (XtPointer)&defEdge},
44   {XtNleft, XtCEdge, XtREdgeType, sizeof(XtEdgeType),
45      Offset(left), XtREdgeType, (XtPointer)&defEdge},
46   {XtNright, XtCEdge, XtREdgeType, sizeof(XtEdgeType),
47      Offset(right), XtREdgeType, (XtPointer)&defEdge},
48   {XtNhorizDistance, XtCThickness, XtRInt, sizeof(int),
49      Offset(dx), XtRInt, (XtPointer) &default_value},
50   {XtNfromHoriz, XtCWidget, XtRWidget, sizeof(Widget),
51      Offset(horiz_base), XtRWidget, (XtPointer)NULL},
52   {XtNvertDistance, XtCThickness, XtRInt, sizeof(int),
53      Offset(dy), XtRInt, (XtPointer) &default_value},
54   {XtNfromVert, XtCWidget, XtRWidget, sizeof(Widget),
55      Offset(vert_base), XtRWidget, (XtPointer)NULL},
56   {XtNrubberWidth, XtCBoolean, XtRBoolean, sizeof(Boolean),    /* new */
57      Offset(rubber_width), XtRImmediate, (XtPointer) True},
58   {XtNrubberHeight, XtCBoolean, XtRBoolean, sizeof(Boolean),   /* new */
59      Offset(rubber_height), XtRImmediate, (XtPointer) True},
60   {XtNfullWidth, XtCBoolean, XtRBoolean, sizeof(Boolean),      /* new */
61      Offset(full_width), XtRImmediate, (XtPointer) False},
62   {XtNfullHeight, XtCBoolean, XtRBoolean, sizeof(Boolean),     /* new */
63      Offset(full_height), XtRImmediate, (XtPointer) False},
64   {XtNwidthLinked, XtCWidget, XtRWidget, sizeof(Widget),
65      Offset(width_link), XtRWidget, (XtPointer)NULL},         /* new */
66   {XtNheightLinked, XtCWidget, XtRWidget, sizeof(Widget),
67      Offset(height_link), XtRWidget, (XtPointer)NULL},        /* new */
68   {XtNresizable, XtCBoolean, XtRBoolean, sizeof(Boolean),
69      Offset(allow_resize), XtRImmediate, (XtPointer) FALSE},
70 };
71 #undef Offset
72 
73 
74 #if NeedFunctionPrototypes
75 static void ClassInitialize(void);
76 static void ClassPartInitialize(WidgetClass);
77 static void Initialize(Widget, Widget, ArgList, Cardinal *);
78 static void Resize(Widget);
79 static void ConstraintInitialize(Widget, Widget, ArgList, Cardinal *);
80 static Boolean SetValues(Widget, Widget, Widget, ArgList, Cardinal *);
81 static Boolean ConstraintSetValues(Widget, Widget, Widget, ArgList, Cardinal *);
82 static XtGeometryResult GeometryManager(Widget, XtWidgetGeometry *, XtWidgetGeometry *);
83 static XtGeometryResult PreferredGeometry(Widget, XtWidgetGeometry *, XtWidgetGeometry *);
84 static void ChangeManaged(Widget);
85 static Boolean Layout(XedwFormWidget, Dimension, Dimension);
86 static void LayoutChild(Widget);
87 void XedwFormDoLayout(Widget, Boolean);
88 #else
89 static void ClassInitialize(), ClassPartInitialize(), Initialize(), Resize();
90 static void ConstraintInitialize();
91 static Boolean SetValues(), ConstraintSetValues();
92 static XtGeometryResult GeometryManager(), PreferredGeometry();
93 static void ChangeManaged();
94 static Boolean Layout();
95 static void LayoutChild();
96 void XedwFormDoLayout();
97 #endif
98 
99 XedwFormClassRec xedwFormClassRec = {
100   { /* core_class fields */
101     /* superclass         */    (WidgetClass) &constraintClassRec,
102     /* class_name         */    "XedwForm",
103     /* widget_size        */    sizeof(XedwFormRec),
104     /* class_initialize   */    ClassInitialize,
105     /* class_part_init    */    ClassPartInitialize,
106     /* class_inited       */    FALSE,
107     /* initialize         */    Initialize,
108     /* initialize_hook    */    NULL,
109     /* realize            */    XtInheritRealize,
110     /* actions            */    NULL,
111     /* num_actions        */    0,
112     /* resources          */    resources,
113     /* num_resources      */    XtNumber(resources),
114     /* xrm_class          */    NULLQUARK,
115     /* compress_motion    */    TRUE,
116     /* compress_exposure  */    TRUE,
117     /* compress_enterleave*/    TRUE,
118     /* visible_interest   */    FALSE,
119     /* destroy            */    NULL,
120     /* resize             */    Resize,                      /* new */
121     /* expose             */    XtInheritExpose,
122     /* set_values         */    SetValues,
123     /* set_values_hook    */    NULL,
124     /* set_values_almost  */    XtInheritSetValuesAlmost,
125     /* get_values_hook    */    NULL,
126     /* accept_focus       */    NULL,
127     /* version            */    XtVersion,
128     /* callback_private   */    NULL,
129     /* tm_table           */    NULL,
130     /* query_geometry     */    PreferredGeometry,
131     /* display_accelerator*/    XtInheritDisplayAccelerator,
132     /* extension          */    NULL
133   },
134   { /* composite_class fields */
135     /* geometry_manager   */   GeometryManager,
136     /* change_managed     */   ChangeManaged,
137     /* insert_child       */   XtInheritInsertChild,
138     /* delete_child       */   XtInheritDeleteChild,
139     /* extension          */   NULL
140   },
141   { /* constraint_class fields */
142     /* subresourses       */   xedwFormConstraintResources,
143     /* subresource_count  */   XtNumber(xedwFormConstraintResources),
144     /* constraint_size    */   sizeof(XedwFormConstraintsRec),
145     /* initialize         */   ConstraintInitialize,
146     /* destroy            */   NULL,
147     /* set_values         */   ConstraintSetValues,
148     /* extension          */   NULL
149   },
150   { /* xedwForm_class fields */
151     /* layout             */   Layout
152   }
153 };
154 
155 WidgetClass xedwFormWidgetClass = (WidgetClass)&xedwFormClassRec;
156 
157 /****************************************************************
158  *
159  * Private Procedures
160  *
161  ****************************************************************/
162 
163 
164 static XrmQuark XtQChainLeft, XtQChainRight, XtQChainTop,
165   XtQChainBottom, XtQRubber;
166 
167 #define done(address, type) \
168 { toVal->size = sizeof(type); \
169   toVal->addr = (caddr_t) address; \
170   return; \
171 }
172 
173 #if NeedFunctionPrototypes
_CvtStringToEdgeType(XrmValuePtr args,Cardinal * num_args,XrmValuePtr fromVal,XrmValuePtr toVal)174 static void _CvtStringToEdgeType(XrmValuePtr args, Cardinal *num_args, XrmValuePtr fromVal, XrmValuePtr toVal)
175 #else
176 static void _CvtStringToEdgeType(args, num_args, fromVal, toVal)
177 XrmValuePtr args;
178 Cardinal *num_args;
179 XrmValuePtr fromVal, toVal;
180 #endif
181 {
182   static XtEdgeType edgeType;
183   XrmQuark q;
184   char lowerName[1000];
185 
186   XmuCopyISOLatin1Lowered (lowerName, (char*)fromVal->addr);
187   q = XrmStringToQuark(lowerName);
188   if (q == XtQChainLeft) {
189     edgeType = XtChainLeft;
190     done(&edgeType, XtEdgeType);
191   }
192   if (q == XtQChainRight) {
193     edgeType = XtChainRight;
194     done(&edgeType, XtEdgeType);
195   }
196   if (q == XtQChainTop) {
197     edgeType = XtChainTop;
198     done(&edgeType, XtEdgeType);
199   }
200   if (q == XtQChainBottom) {
201     edgeType = XtChainBottom;
202     done(&edgeType, XtEdgeType);
203   }
204   if (q == XtQRubber) {
205     edgeType = XtRubber;
206     done(&edgeType, XtEdgeType);
207   }
208   XtStringConversionWarning(fromVal->addr, "edgeType");
209   toVal->addr = NULL;
210   toVal->size = 0;
211 }
212 
213 #if NeedFunctionPrototypes
ClassInitialize(void)214 static void ClassInitialize(void)
215 #else
216 static void ClassInitialize()
217 #endif
218 {
219   static XtConvertArgRec parentCvtArgs[] = {
220     {XtBaseOffset, (caddr_t)XtOffset(Widget, core.parent), sizeof(Widget)}
221   };
222   XawInitializeWidgetSet();
223   XtQChainLeft   = XrmStringToQuark("chainleft");
224   XtQChainRight  = XrmStringToQuark("chainright");
225   XtQChainTop    = XrmStringToQuark("chaintop");
226   XtQChainBottom = XrmStringToQuark("chainbottom");
227   XtQRubber      = XrmStringToQuark("rubber");
228 
229   XtAddConverter( XtRString, XtREdgeType, _CvtStringToEdgeType, NULL, 0 );
230   XtAddConverter( XtRString, XtRWidget, XmuCvtStringToWidget,
231 		 parentCvtArgs, XtNumber(parentCvtArgs) );
232 }
233 
234 #if NeedFunctionPrototypes
ClassPartInitialize(WidgetClass class)235 static void ClassPartInitialize(WidgetClass class)
236 #else
237 static void ClassPartInitialize(class)
238 WidgetClass class;
239 #endif
240 {
241   register XedwFormWidgetClass c = (XedwFormWidgetClass)class;
242 
243   if (((Boolean (*)())c->xedwForm_class.layout) ==  XtInheritLayout)
244     c->xedwForm_class.layout = Layout;
245 }
246 
247 
248 #if NeedFunctionPrototypes
Initialize(Widget request,Widget new,ArgList args,Cardinal * num_args)249 static void Initialize(Widget request, Widget new, ArgList args, Cardinal *num_args)
250 #else
251 static void Initialize(request, new)
252 Widget request, new;
253 ArgList args;
254 Cardinal *num_args;
255 #endif
256 {
257   XedwFormWidget fw = (XedwFormWidget)new;
258 
259   fw->xedwForm.old_width = fw->core.width;
260   fw->xedwForm.old_height = fw->core.height;
261   fw->xedwForm.no_refigure = False;
262   fw->xedwForm.needs_relayout = False;
263   fw->xedwForm.resize_in_layout = True;
264 }
265 
266 
267 #if NeedFunctionPrototypes
RefigureLocations(XedwFormWidget w)268 static void RefigureLocations(XedwFormWidget w)
269 #else
270 static void RefigureLocations(w)
271 XedwFormWidget w;
272 #endif
273 {
274   if (w->xedwForm.no_refigure) {
275     w->xedwForm.needs_relayout = True;
276   } else {
277     (*((XedwFormWidgetClass)w->core.widget_class)->xedwForm_class.layout)
278       ( w, w->core.width, w->core.height );
279     w->xedwForm.needs_relayout = False;
280   }
281 }
282 
283 #if NeedFunctionPrototypes
Layout(XedwFormWidget fw,Dimension width,Dimension height)284 static Boolean Layout(XedwFormWidget fw, Dimension width, Dimension height)
285 #else
286 static Boolean Layout(fw, width, height)
287 XedwFormWidget fw;
288 Dimension width, height;
289 #endif
290 {
291   int num_children = fw->composite.num_children;
292   WidgetList children = fw->composite.children;
293   Widget *childP;
294   Position maxx, maxy;
295   Boolean ret_val;
296 
297   for (childP = children; childP - children < num_children; childP++) {
298     XedwFormConstraints xedwForm =
299       (XedwFormConstraints)(*childP)->core.constraints;
300     xedwForm->xedwForm.layout_state = LayoutPending;
301   }
302 
303   maxx = maxy = 1;
304   for (childP = children; childP - children < num_children; childP++) {
305     if (XtIsManaged(*childP)) {
306       Position x, y;
307       LayoutChild(*childP);
308       x = (*childP)->core.x + (*childP)->core.width
309 	+ ((*childP)->core.border_width << 1);
310       y = (*childP)->core.y + (*childP)->core.height
311 	+ ((*childP)->core.border_width << 1);
312       if (maxx < x) maxx = x;  /* Track width  */
313       if (maxy < y) maxy = y;  /* Track Height */
314     }
315   }
316 
317   /* I want to be this big */
318   fw->xedwForm.preferred_width = (maxx += fw->xedwForm.default_spacing);
319   fw->xedwForm.preferred_height = (maxy += fw->xedwForm.default_spacing);
320 
321   /* Go back and check to see if any widgets want to be full height or
322    * full width, if so, do it, dont recalculate sizes, assume the programmer
323    * didn't make any silly mistakes like putting another widget to the right
324    * of a full width one. EG.
325    * Should really do this in one pass.
326    */
327 
328   for (childP = children; childP - children < num_children; childP++) {
329     XedwFormConstraints form = (XedwFormConstraints)(*childP)->core.constraints;
330     Position newwidth  = (Position)(*childP)->core.width;
331     Position newheight = (Position)(*childP)->core.height;
332     if (form->xedwForm.full_width == True)
333       form->xedwForm.virtual_width = newwidth =
334 	(maxx - ((form->xedwForm.dx) +
335 		 ((*childP)->core.border_width * 2) +
336 		 ((*childP)->core.x)));
337     if (form->xedwForm.full_height == True)
338       form->xedwForm.virtual_height = newheight =
339 	(maxy - ((form->xedwForm.dy) +
340 		 ((*childP)->core.border_width * 2) +
341 		 ((*childP)->core.y)));
342     /* Resize the widget if it has been changed. XtResizeWidget does the checking */
343     XtResizeWidget(*childP, newwidth, newheight, (*childP)->core.border_width);
344   }
345 
346   if (fw->xedwForm.resize_in_layout &&
347       (maxx != (Position)fw->core.width || maxy != (Position)fw->core.height))
348   {
349     XtGeometryResult result;
350     result = XtMakeResizeRequest((Widget)fw, (Dimension)maxx, (Dimension)maxy,
351 				 (Dimension*)&maxx, (Dimension*)&maxy );
352     if (result == XtGeometryAlmost)
353       result = XtMakeResizeRequest((Widget)fw, (Dimension)maxx, (Dimension)maxy,
354 				   NULL, NULL );
355     fw->xedwForm.old_width  = fw->core.width;
356     fw->xedwForm.old_height = fw->core.height;
357     ret_val = (result == XtGeometryYes);
358   } else ret_val = False;
359 
360   return ret_val;
361 }
362 
363 
364 #if NeedFunctionPrototypes
LayoutChild(Widget w)365 static void LayoutChild(Widget w)
366 #else
367 static void LayoutChild(w)
368 Widget w;
369 #endif
370 {
371   XedwFormConstraints xedwForm = (XedwFormConstraints)w->core.constraints;
372   Position x, y;
373   Dimension width, height;
374   Widget ref;
375 
376   switch (xedwForm->xedwForm.layout_state) {
377 
378   case LayoutPending:
379     xedwForm->xedwForm.layout_state = LayoutInProgress;
380     break;
381 
382   case LayoutDone:
383     return;
384 
385   case LayoutInProgress:
386     {
387       String subs[2];
388       Cardinal num_subs = 2;
389       subs[0] = w->core.name;
390       subs[1] = w->core.parent->core.name;
391       XtAppWarningMsg(XtWidgetToApplicationContext(w),
392 		      "constraintLoop","XedwFormLayout","XawToolkitError",
393 		      "constraint loop detected while laying out child '%s' in XedwFormWidget '%s'",
394 		      subs, &num_subs);
395       return;
396     }
397   }
398   x = xedwForm->xedwForm.dx;
399   y = xedwForm->xedwForm.dy;
400   if ((ref = xedwForm->xedwForm.width_link) != (Widget)NULL) {
401     LayoutChild(ref);
402     width = xedwForm->xedwForm.virtual_width = ref->core.width;
403     XtResizeWidget(w, width, w->core.height, w->core.border_width);
404   }
405   if ((ref = xedwForm->xedwForm.height_link) != (Widget)NULL) {
406     LayoutChild(ref);
407     height = xedwForm->xedwForm.virtual_height = ref->core.height;
408     XtResizeWidget(w, w->core.width, height, w->core.border_width);
409   }
410   if ((ref = xedwForm->xedwForm.horiz_base) != (Widget)NULL) {
411     LayoutChild(ref);
412     x += ref->core.x + ref->core.width + (ref->core.border_width << 1);
413   }
414   if ((ref = xedwForm->xedwForm.vert_base) != (Widget)NULL) {
415     LayoutChild(ref);
416     y += ref->core.y + ref->core.height + (ref->core.border_width << 1);
417   }
418   XtMoveWidget( w, x, y );
419   xedwForm->xedwForm.layout_state = LayoutDone;
420 }
421 
422 
423 #if NeedFunctionPrototypes
TransformCoord(Position loc,Dimension old,Dimension new,XawEdgeType type)424 static Position TransformCoord(Position loc, Dimension old, Dimension new, XawEdgeType type)
425 #else
426 static Position TransformCoord(loc, old, new, type)
427 Position loc;
428 Dimension old,new;
429 XtEdgeType type;
430 #endif
431 {
432   if (type == XtRubber) {
433     if ( ((int) old) > 0)
434       loc = (loc * new) / old;
435   }
436   else if (type == XtChainBottom || type == XtChainRight)
437     loc += (Position)new - (Position)old;
438 
439   /* I don't see any problem with returning values less than zero. */
440 
441   return (loc);
442 }
443 
444 
445 #if NeedFunctionPrototypes
Resize(Widget w)446 static void Resize(Widget w)
447 #else
448 static void Resize(w)
449 Widget w;
450 #endif
451 {
452   XedwFormWidget fw = (XedwFormWidget)w;
453   WidgetList children = fw->composite.children;
454   int num_children = fw->composite.num_children;
455   Widget *childP;
456   Position x, y;
457   Dimension width, height;
458 
459   for (childP = children; childP - children < num_children; childP++) {
460     XedwFormConstraints xedwForm = (XedwFormConstraints)(*childP)->core.constraints;
461     if (!XtIsManaged(*childP)) continue;
462     x = TransformCoord( (*childP)->core.x, fw->xedwForm.old_width,
463 		       fw->core.width, xedwForm->xedwForm.left );
464     y = TransformCoord( (*childP)->core.y, fw->xedwForm.old_height,
465 		       fw->core.height, xedwForm->xedwForm.top );
466 
467     if (xedwForm->xedwForm.rubber_width)
468       xedwForm->xedwForm.virtual_width =
469 	TransformCoord((Position)((*childP)->core.x
470 				  + xedwForm->xedwForm.virtual_width
471 				  + 2 * (*childP)->core.border_width),
472 		       fw->xedwForm.old_width, fw->core.width,
473 		       xedwForm->xedwForm.right )
474 	  - (x + 2 * (*childP)->core.border_width);
475 
476     if (xedwForm->xedwForm.rubber_height)
477       xedwForm->xedwForm.virtual_height =
478 	TransformCoord((Position)((*childP)->core.y
479 				  + xedwForm->xedwForm.virtual_height
480 				  + 2 * (*childP)->core.border_width),
481 		       fw->xedwForm.old_height, fw->core.height,
482 		       xedwForm->xedwForm.bottom )
483 	  - ( y + 2 * (*childP)->core.border_width);
484 
485     width = (Dimension)
486       (xedwForm->xedwForm.virtual_width < 1) ? 1 : xedwForm->xedwForm.virtual_width;
487     height = (Dimension)
488       (xedwForm->xedwForm.virtual_height < 1) ? 1 : xedwForm->xedwForm.virtual_height;
489 
490     XtConfigureWidget( *childP, x, y, (Dimension)width, (Dimension)height,
491 		      (*childP)->core.border_width );
492   }
493 
494   fw->xedwForm.old_width = fw->core.width;
495   fw->xedwForm.old_height = fw->core.height;
496 }
497 
498 
499 #if NeedFunctionPrototypes
GeometryManager(Widget w,XtWidgetGeometry * request,XtWidgetGeometry * reply)500 static XtGeometryResult GeometryManager(Widget w, XtWidgetGeometry *request, XtWidgetGeometry *reply)
501 #else
502 static XtGeometryResult GeometryManager(w, request, reply)
503 Widget w;
504 XtWidgetGeometry *request, *reply;
505 #endif
506 {
507   XedwFormConstraints xedwForm = (XedwFormConstraints)w->core.constraints;
508   XtWidgetGeometry allowed;
509 
510   if ((request->request_mode & ~(XtCWQueryOnly | CWWidth | CWHeight)) ||
511       !xedwForm->xedwForm.allow_resize)
512     return XtGeometryNo;
513 
514   if (request->request_mode & CWWidth)
515     allowed.width = request->width;
516   else
517     allowed.width = w->core.width;
518 
519   if (request->request_mode & CWHeight)
520     allowed.height = request->height;
521   else
522     allowed.height = w->core.height;
523 
524   if (allowed.width == w->core.width && allowed.height == w->core.height)
525     return XtGeometryNo;
526 
527   if (!(request->request_mode & XtCWQueryOnly)) {
528     /* reset virtual width and height. */
529     xedwForm->xedwForm.virtual_width = w->core.width = allowed.width;
530     xedwForm->xedwForm.virtual_height = w->core.height = allowed.height;
531     RefigureLocations( (XedwFormWidget)w->core.parent );
532   }
533   return XtGeometryYes;
534 }
535 
536 
537 
538 #if NeedFunctionPrototypes
SetValues(Widget current,Widget request,Widget new,ArgList args,Cardinal * num_args)539 static Boolean SetValues(Widget current, Widget request, Widget new, ArgList args, Cardinal *num_args)
540 #else
541 static Boolean SetValues(current, request, new)
542 Widget current, request, new;
543 ArgList args;
544 Cardinal *num_args;
545 #endif
546 {
547   return( FALSE );
548 }
549 
550 
551 #if NeedFunctionPrototypes
ConstraintInitialize(Widget request,Widget new,ArgList args,Cardinal * num_args)552 static void ConstraintInitialize(Widget request, Widget new, ArgList args, Cardinal *num_args)
553 #else
554 static void ConstraintInitialize(request, new)
555 Widget request, new;
556 ArgList args;
557 Cardinal *num_args;
558 #endif
559 {
560   XedwFormConstraints xedwForm = (XedwFormConstraints)new->core.constraints;
561   XedwFormWidget fw = (XedwFormWidget)new->core.parent;
562 
563   xedwForm->xedwForm.virtual_width = (int) new->core.width;
564   xedwForm->xedwForm.virtual_height = (int) new->core.height;
565 
566   if (xedwForm->xedwForm.dx == default_value)
567     xedwForm->xedwForm.dx = fw->xedwForm.default_spacing;
568 
569   if (xedwForm->xedwForm.dy == default_value)
570     xedwForm->xedwForm.dy = fw->xedwForm.default_spacing;
571 }
572 
573 #if NeedFunctionPrototypes
ConstraintSetValues(Widget current,Widget request,Widget new,ArgList args,Cardinal * num_args)574 static Boolean ConstraintSetValues(Widget current, Widget request, Widget new, ArgList args, Cardinal *num_args)
575 #else
576 static Boolean ConstraintSetValues(current, request, new)
577 Widget current, request, new;
578 ArgList args;
579 Cardinal *num_args;
580 #endif
581 {
582   return( FALSE );
583 }
584 
585 #if NeedFunctionPrototypes
ChangeManaged(Widget w)586 static void ChangeManaged(Widget w)
587 #else
588 static void ChangeManaged(w)
589 Widget w;
590 #endif
591 {
592   XedwFormWidget fw = (XedwFormWidget)w;
593   XedwFormConstraints xedwForm;
594   WidgetList children, childP;
595   int num_children = fw->composite.num_children;
596   Widget child;
597 
598   /*
599    * Reset virtual width and height for all children.
600    */
601 
602   for (children = childP = fw->composite.children ;
603        childP - children < num_children; childP++) {
604     child = *childP;
605     if (XtIsManaged(child)) {
606       xedwForm = (XedwFormConstraints)child->core.constraints;
607       if ( child->core.width != 1)
608         xedwForm->xedwForm.virtual_width = (int) child->core.width;
609       if ( child->core.height != 1)
610         xedwForm->xedwForm.virtual_height = (int) child->core.height;
611     }
612   }
613   RefigureLocations( (XedwFormWidget)w );
614 }
615 
616 
617 #if NeedFunctionPrototypes
PreferredGeometry(Widget widget,XtWidgetGeometry * request,XtWidgetGeometry * reply)618 static XtGeometryResult PreferredGeometry(Widget widget, XtWidgetGeometry *request, XtWidgetGeometry *reply)
619 #else
620 static XtGeometryResult PreferredGeometry(widget, request, reply)
621 Widget widget;
622 XtWidgetGeometry *request, *reply;
623 #endif
624 {
625   XedwFormWidget w = (XedwFormWidget)widget;
626 
627   reply->width = w->xedwForm.preferred_width;
628   reply->height = w->xedwForm.preferred_height;
629   reply->request_mode = CWWidth | CWHeight;
630   if (((request->request_mode & (CWWidth | CWHeight)) ==
631       (reply->request_mode & (CWWidth | CWHeight)))
632       && (request->width == reply->width)
633       && (request->height == reply->height))
634     return XtGeometryYes;
635   else if ((reply->width == w->core.width) && (reply->height == w->core.height))
636     return XtGeometryNo;
637   else
638     return XtGeometryAlmost;
639 }
640 
641 
642 /**********************************************************************
643  *
644  * Public routines
645  *
646  **********************************************************************/
647 
648 /*
649  * Set or reset figuring (ignored if not realized)
650  */
651 
652 #if NeedFunctionPrototypes
XedwFormDoLayout(Widget w,Boolean doit)653 void XedwFormDoLayout(Widget w, Boolean doit)
654 #else
655 void XedwFormDoLayout(w, doit)
656 Widget w;
657 Boolean doit;
658 #endif
659 {
660   register XedwFormWidget fw = (XedwFormWidget)w;
661 
662   fw->xedwForm.no_refigure = !doit;
663 
664   if ( XtIsRealized(w) && fw->xedwForm.needs_relayout )
665     RefigureLocations( fw );
666 }
667