1 /***********************************************************
3 Copyright 1987, 1988, 1994, 1998 The Open Group
5 Permission to use, copy, modify, distribute, and sell this software and its
6 documentation for any purpose is hereby granted without fee, provided that
7 the above copyright notice appear in all copies and that both that
8 copyright notice and this permission notice appear in supporting
11 The above copyright notice and this permission notice shall be included in
12 all copies or substantial portions of the Software.
14 THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
15 IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
16 FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
17 OPEN GROUP BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN
18 AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN
19 CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE.
21 Except as contained in this notice, the name of The Open Group shall not be
22 used in advertising or otherwise to promote the sale, use or other dealings
23 in this Software without prior written authorization from The Open Group.
26 Copyright 1987, 1988 by Digital Equipment Corporation, Maynard, Massachusetts.
30 Permission to use, copy, modify, and distribute this software and its
31 documentation for any purpose and without fee is hereby granted,
32 provided that the above copyright notice appear in all copies and that
33 both that copyright notice and this permission notice appear in
34 supporting documentation, and that the name of Digital not be
35 used in advertising or publicity pertaining to distribution of the
36 software without specific, written prior permission.
38 DIGITAL DISCLAIMS ALL WARRANTIES WITH REGARD TO THIS SOFTWARE, INCLUDING
39 ALL IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS, IN NO EVENT SHALL
40 DIGITAL BE LIABLE FOR ANY SPECIAL, INDIRECT OR CONSEQUENTIAL DAMAGES OR
41 ANY DAMAGES WHATSOEVER RESULTING FROM LOSS OF USE, DATA OR PROFITS,
42 WHETHER IN AN ACTION OF CONTRACT, NEGLIGENCE OR OTHER TORTIOUS ACTION,
43 ARISING OUT OF OR IN CONNECTION WITH THE USE OR PERFORMANCE OF THIS
46 ******************************************************************/
51 #include <X11/IntrinsicP.h>
52 #include <X11/StringDefs.h>
53 #include <X11/Xmu/CharSet.h>
54 #include <X11/Xmu/Converters.h>
55 #include <X11/Xaw/FormP.h>
56 #include <X11/Xaw/XawInit.h>
62 static void XawFormChangeManaged(Widget);
63 static void XawFormClassInitialize(void);
64 static void XawFormClassPartInitialize(WidgetClass);
65 static void XawFormConstraintInitialize(Widget, Widget, ArgList, Cardinal*);
66 static Boolean XawFormConstraintSetValues(Widget, Widget, Widget,
68 static XtGeometryResult XawFormGeometryManager(Widget, XtWidgetGeometry*,
70 static void XawFormInitialize(Widget, Widget, ArgList, Cardinal*);
72 static void XawFormRealize(Widget, Mask*, XSetWindowAttributes*);
73 static void XawFormRedisplay(Widget, XEvent*, Region);
75 static XtGeometryResult XawFormQueryGeometry(Widget, XtWidgetGeometry*,
77 static void XawFormResize(Widget);
78 static Boolean XawFormSetValues(Widget, Widget, Widget, ArgList, Cardinal*);
79 static Boolean Layout(FormWidget, unsigned int, unsigned int, Bool);
84 static void _CvtStringToEdgeType(XrmValuePtr, Cardinal*,
85 XrmValuePtr, XrmValuePtr);
86 static Bool ChangeFormGeometry(Widget, Bool, unsigned int, unsigned int,
87 Dimension*, Dimension*);
88 Boolean CvtEdgeTypeToString(Display*, XrmValuePtr, Cardinal*,
89 XrmValuePtr, XrmValuePtr, XtPointer*);
90 static void LayoutChild(Widget);
91 static int TransformCoord(int, unsigned int, unsigned int, XtEdgeType);
92 static void ResizeChildren(Widget);
98 static XtActionsRec actions[] = {
99 {"set-values", XawSetValuesAction},
100 {"get-values", XawGetValuesAction},
101 {"declare", XawDeclareAction},
102 {"call-proc", XawCallProcAction},
106 static XrmQuark QchainLeft, QchainRight, QchainTop, QchainBottom, Qrubber;
108 #define default_value -99999
109 #define Offset(field) XtOffsetOf(FormRec, form.field)
110 static XtResource resources[] = {
116 Offset(default_spacing),
125 sizeof(XawDisplayList*),
126 Offset(display_list),
134 #define defEdge XtRubber
136 #define Offset(field) XtOffsetOf(FormConstraintsRec, form.field)
137 static XtResource formConstraintResources[] = {
181 (XtPointer)default_value
199 (XtPointer)default_value
215 Offset(allow_resize),
222 FormClassRec formClassRec = {
225 (WidgetClass)&constraintClassRec, /* superclass */
226 "Form", /* class_name */
227 sizeof(FormRec), /* widget_size */
228 XawFormClassInitialize, /* class_initialize */
229 XawFormClassPartInitialize, /* class_part_init */
230 False, /* class_inited */
231 XawFormInitialize, /* initialize */
232 NULL, /* initialize_hook */
234 XawFormRealize, /* realize */
235 actions, /* actions */
236 XtNumber(actions), /* num_actions */
238 XtInheritRealize, /* realize */
242 resources, /* resources */
243 XtNumber(resources), /* num_resources */
244 NULLQUARK, /* xrm_class */
245 True, /* compress_motion */
246 True, /* compress_exposure */
247 True, /* compress_enterleave */
248 False, /* visible_interest */
250 XawFormResize, /* resize */
252 XawFormRedisplay, /* expose */
254 XtInheritExpose, /* expose */
256 XawFormSetValues, /* set_values */
257 NULL, /* set_values_hook */
258 XtInheritSetValuesAlmost, /* set_values_almost */
259 NULL, /* get_values_hook */
260 NULL, /* accept_focus */
261 XtVersion, /* version */
262 NULL, /* callback_private */
264 XawFormQueryGeometry, /* query_geometry */
265 XtInheritDisplayAccelerator, /* display_accelerator */
266 NULL, /* extension */
270 XawFormGeometryManager, /* geometry_manager */
271 XawFormChangeManaged, /* change_managed */
272 XtInheritInsertChild, /* insert_child */
273 XtInheritDeleteChild, /* delete_child */
274 NULL, /* extension */
278 formConstraintResources, /* subresourses */
279 XtNumber(formConstraintResources), /* subresource_count */
280 sizeof(FormConstraintsRec), /* constraint_size */
281 XawFormConstraintInitialize, /* initialize */
283 XawFormConstraintSetValues, /* set_values */
284 NULL, /* extension */
292 WidgetClass formWidgetClass = (WidgetClass)&formClassRec;
299 XawFormRealize(Widget w, Mask *mask, XSetWindowAttributes *attr)
303 (*formWidgetClass->core_class.superclass->core_class.realize)(w, mask, attr);
305 if (w->core.background_pixmap > XtUnspecifiedPixmap) {
306 pixmap = XawPixmapFromXPixmap(w->core.background_pixmap, XtScreen(w),
307 w->core.colormap, w->core.depth);
308 if (pixmap && pixmap->mask)
309 XawReshapeWidget(w, pixmap);
314 XawFormRedisplay(Widget w, XEvent *event, Region region)
316 FormWidget xaw = (FormWidget)w;
318 if (xaw->form.display_list)
319 XawRunDisplayList(w, xaw->form.display_list, event, region);
325 _CvtStringToEdgeType(XrmValuePtr args, Cardinal *num_args,
326 XrmValuePtr fromVal, XrmValuePtr toVal)
328 static XtEdgeType edgeType;
332 XmuNCopyISOLatin1Lowered(name, (char*)fromVal->addr, sizeof(name));
333 q = XrmStringToQuark(name);
336 edgeType = XtChainLeft;
337 else if (q == QchainRight)
338 edgeType = XtChainRight;
339 else if (q == QchainTop)
340 edgeType = XtChainTop;
341 else if (q == QchainBottom)
342 edgeType = XtChainBottom;
343 else if (q == Qrubber)
346 XtStringConversionWarning(fromVal->addr, XtREdgeType);
352 toVal->size = sizeof(XtEdgeType);
353 toVal->addr = (XPointer)&edgeType;
358 CvtEdgeTypeToString(Display *dpy, XrmValuePtr args, Cardinal *num_args,
359 XrmValuePtr fromVal, XrmValuePtr toVal, XtPointer *data)
361 static String buffer;
364 switch (*(XtEdgeType *)fromVal->addr) {
366 buffer = XtEchainLeft;
369 buffer = XtEchainRight;
372 buffer = XtEchainTop;
375 buffer = XtEchainBottom;
381 XawTypeToStringWarning(dpy, XtREdgeType);
387 size = strlen(buffer) + 1;
388 if (toVal->addr != NULL) {
389 if (toVal->size < size) {
393 strcpy((char *)toVal->addr, buffer);
396 toVal->addr = (XPointer)buffer;
397 toVal->size = sizeof(String);
403 XawFormClassInitialize(void)
405 static XtConvertArgRec parentCvtArgs[] = {
406 {XtBaseOffset, (XtPointer)XtOffsetOf(WidgetRec, core.parent),
412 XawInitializeWidgetSet();
413 XmuNCopyISOLatin1Lowered(name, XtEchainLeft, sizeof(name));
414 QchainLeft = XrmStringToQuark(name);
415 XmuNCopyISOLatin1Lowered(name, XtEchainRight, sizeof(name));
416 QchainRight = XrmStringToQuark(name);
417 XmuNCopyISOLatin1Lowered(name, XtEchainTop, sizeof(name));
418 QchainTop = XrmStringToQuark(name);
419 XmuNCopyISOLatin1Lowered(name, XtEchainBottom, sizeof(name));
420 QchainBottom = XrmStringToQuark(name);
421 XmuNCopyISOLatin1Lowered(name, XtErubber, sizeof(name));
422 Qrubber = XrmStringToQuark(name);
424 XtAddConverter(XtRString, XtREdgeType, _CvtStringToEdgeType, NULL, 0);
425 XtSetTypeConverter(XtREdgeType, XtRString, CvtEdgeTypeToString,
426 NULL, 0, XtCacheNone, NULL);
427 XtSetTypeConverter(XtRString, XtRWidget, XmuNewCvtStringToWidget,
428 parentCvtArgs, XtNumber(parentCvtArgs), XtCacheNone,
430 XtSetTypeConverter(XtRWidget, XtRString, XmuCvtWidgetToString,
431 NULL, 0, XtCacheNone, NULL);
435 XawFormClassPartInitialize(WidgetClass cclass)
437 FormWidgetClass c = (FormWidgetClass)cclass;
438 FormWidgetClass super = (FormWidgetClass)c->core_class.superclass;
440 if (c->form_class.layout == XtInheritLayout)
441 c->form_class.layout = super->form_class.layout;
446 XawFormInitialize(Widget request, Widget cnew,
447 ArgList args, Cardinal *num_args)
449 FormWidget fw = (FormWidget)cnew;
451 fw->form.old_width = fw->form.old_height = 0;
452 fw->form.no_refigure = False;
453 fw->form.needs_relayout = False;
454 fw->form.resize_in_layout = True;
455 fw->form.resize_is_no_op = False;
464 * query_only - is only a query?
465 * width - new width and height
467 * ret_width - actual size the form is allowed to resize to (return)
471 * Ask the parent to change the form widget's geometry.
474 * True of children may always be resized
477 ChangeFormGeometry(Widget w, Bool query_only,
478 unsigned int width, unsigned int height,
479 Dimension *ret_width, Dimension *ret_height)
481 FormWidget fw = (FormWidget)w;
482 Boolean always_resize_children;
483 XtGeometryResult result;
484 XtWidgetGeometry request, return_request;
487 * If we are already at the desired size then there is no need
488 * to ask our parent of we can change size
490 if (width == XtWidth(fw) && height == XtHeight(fw))
493 request.width = width;
494 request.height = height;
495 request.request_mode = CWWidth | CWHeight;
497 request.request_mode |= XtCWQueryOnly;
500 * Do no invoke the resize rules if our size changes here
502 fw->form.resize_is_no_op = True;
504 result = XtMakeGeometryRequest(w, &request, &return_request);
505 if (result == XtGeometryAlmost) {
506 request = return_request;
507 (void)XtMakeGeometryRequest(w, &request, &return_request);
508 always_resize_children = False;
511 always_resize_children = result == XtGeometryYes;
513 fw->form.resize_is_no_op = False;
515 if (ret_width != NULL)
516 *ret_width = request.width;
517 if (ret_height != NULL)
518 *ret_height = request.height;
520 return (always_resize_children);
531 * force_relayout - will force the children to be moved, even if some
532 * go past the edge of the form
535 * Moves all the children around.
538 * True if the children are allowed to move from their
539 * current locations to the new ones.
543 Layout(FormWidget fw, unsigned int width, unsigned int height,
546 int num_children = fw->composite.num_children;
547 WidgetList children = fw->composite.children;
549 Dimension maxx, maxy;
552 for (childP = children; childP - children < num_children; childP++) {
553 FormConstraints form = (FormConstraints)(*childP)->core.constraints;
554 form->form.layout_state = LayoutPending;
558 for (childP = children; childP - children < num_children; childP++) {
559 if (XtIsManaged(*childP)) {
560 FormConstraints form;
563 form = (FormConstraints)(*childP)->core.constraints;
565 LayoutChild(*childP);
567 x = form->form.new_x + XtWidth(*childP)
568 + (XtBorderWidth(*childP) << 1);
572 y = form->form.new_y + XtHeight(*childP)
573 + (XtBorderWidth(*childP) << 1);
579 fw->form.preferred_width = (maxx += fw->form.default_spacing);
580 fw->form.preferred_height = (maxy += fw->form.default_spacing);
582 if (fw->form.resize_in_layout) {
583 Boolean always_resize_children;
585 always_resize_children =
586 ChangeFormGeometry((Widget)fw, False, maxx, maxy, NULL, NULL);
589 fw->form.old_width = fw->core.width;
590 fw->form.old_height = fw->core.height;
596 ret_val = always_resize_children ||
597 (XtWidth(fw) >= maxx && XtHeight(fw) >= maxy);
600 ResizeChildren((Widget)fw);
605 fw->form.needs_relayout = False;
618 * Resizes all children to new_x and new_y.
621 ResizeChildren(Widget w)
623 FormWidget fw = (FormWidget)w;
624 int num_children = fw->composite.num_children;
625 WidgetList children = fw->composite.children;
628 for (childP = children; childP - children < num_children; childP++) {
629 FormConstraints form;
632 if (!XtIsManaged(*childP))
635 form = (FormConstraints)(*childP)->core.constraints;
637 if (fw->form.old_width && fw->form.old_height) {
638 x = TransformCoord(form->form.new_x, fw->form.old_width,
639 XtWidth(fw), form->form.left);
640 y = TransformCoord(form->form.new_y, fw->form.old_height,
641 XtHeight(fw), form->form.top);
644 x = form->form.new_x;
645 y = form->form.new_y;
648 if (fw->form.no_refigure) {
650 * I am changing the widget wrapper w/o modifing the window. This is
651 * risky, but I can get away with it since I am the parent of this
652 * widget, and he must ask me for any geometry changes
654 * The window will be updated when no_refigure is set back to False
660 XtMoveWidget(*childP, x, y);
665 LayoutChild(Widget w)
667 FormConstraints form = (FormConstraints)w->core.constraints;
670 switch (form->form.layout_state) {
672 form->form.layout_state = LayoutInProgress;
676 case LayoutInProgress: {
678 Cardinal num_subs = 2;
679 subs[0] = w->core.name;
680 subs[1] = w->core.parent->core.name;
682 XtAppWarningMsg(XtWidgetToApplicationContext(w),
683 "constraintLoop", "xawFormLayout", "XawToolkitError",
684 "constraint loop detected while laying out "
685 "child '%s' in FormWidget '%s'",
690 form->form.new_x = form->form.dx;
691 form->form.new_y = form->form.dy;
692 if ((ref = form->form.horiz_base) != NULL) {
693 FormConstraints ref_form = (FormConstraints)ref->core.constraints;
696 form->form.new_x += ref_form->form.new_x + XtWidth(ref) +
697 (XtBorderWidth(ref) << 1);
699 if ((ref = form->form.vert_base) != NULL) {
700 FormConstraints ref_form = (FormConstraints)ref->core.constraints;
703 form->form.new_y += ref_form->form.new_y + XtHeight(ref) +
704 (XtBorderWidth(ref) << 1);
707 form->form.layout_state = LayoutDone;
711 TransformCoord(int loc, unsigned int old, unsigned int cnew, XtEdgeType type)
713 if (type == XtRubber) {
715 loc = (int)(loc * ((double)cnew / (double)old));
717 else if (type == XtChainBottom || type == XtChainRight)
718 loc += (int)cnew - (int)old;
724 XawFormResize(Widget w)
726 FormWidget fw = (FormWidget)w;
727 WidgetList children = fw->composite.children;
728 int num_children = fw->composite.num_children;
732 Boolean unmap = XtIsRealized(w) && w->core.mapped_when_managed &&
738 if (!fw->form.resize_is_no_op)
739 for (childP = children; childP - children < num_children; childP++) {
740 FormConstraints form = (FormConstraints)(*childP)->core.constraints;
742 if (!XtIsManaged(*childP))
746 x = TransformCoord(form->form.virtual_x, fw->form.old_width,
747 XtWidth(fw), form->form.left);
748 y = TransformCoord(form->form.virtual_y, fw->form.old_height,
749 XtHeight(fw), form->form.top);
750 width = TransformCoord(form->form.virtual_x +
751 form->form.virtual_width +
752 (XtBorderWidth(*childP) << 1),
753 fw->form.old_width, XtWidth(fw),
755 (x + (XtBorderWidth(*childP) << 1));
756 height = TransformCoord(form->form.virtual_y +
757 form->form.virtual_height +
758 (XtBorderWidth(*childP) << 1),
759 fw->form.old_height, XtHeight(fw),
761 (y + (XtBorderWidth(*childP) << 1));
763 x = TransformCoord(XtX(*childP), fw->form.old_width,
764 XtWidth(fw), form->form.left);
765 y = TransformCoord(XtY(*childP), fw->form.old_height,
766 XtHeight(fw), form->form.top);
767 width = TransformCoord(XtX(*childP) + form->form.virtual_width +
768 (XtBorderWidth(*childP) << 1),
769 fw->form.old_width, XtWidth(fw),
771 (x + (XtBorderWidth(*childP) << 1));
772 height = TransformCoord(XtY(*childP) + form->form.virtual_height +
773 (XtBorderWidth(*childP) << 1),
774 fw->form.old_height, XtHeight(fw),
776 (y + (XtBorderWidth(*childP) << 1));
777 form->form.virtual_width = width;
778 form->form.virtual_height = height;
781 width = width < 1 ? 1 : width;
782 height = height < 1 ? 1 : height;
784 XtConfigureWidget(*childP, x, y, width, height,
785 XtBorderWidth(*childP));
792 fw->form.old_width = XtWidth(fw);
793 fw->form.old_height = XtHeight(fw);
798 static XtGeometryResult
799 XawFormGeometryManager(Widget w, XtWidgetGeometry *request,
800 XtWidgetGeometry *reply)
802 Dimension old_width, old_height;
803 FormWidget fw = (FormWidget)XtParent(w);
804 FormConstraints form = (FormConstraints)w->core.constraints;
805 XtWidgetGeometry allowed;
806 XtGeometryResult ret_val;
808 if ((request->request_mode & (unsigned)~(XtCWQueryOnly | CWWidth | CWHeight))
809 || !form->form.allow_resize) {
810 /* If GeometryManager is invoked during a SetValues call on a child
811 * then it is necessary to compute a new layout if ConstraintSetValues
812 * allowed any constraint changes
814 if (fw->form.needs_relayout)
815 (*((FormWidgetClass)fw->core.widget_class)->form_class.layout)
817 return (XtGeometryNo);
820 if (request->request_mode & CWWidth)
821 allowed.width = request->width;
823 allowed.width = XtWidth(w);
825 if (request->request_mode & CWHeight)
826 allowed.height = request->height;
828 allowed.height = XtHeight(w);
830 if (allowed.width == XtWidth(w) && allowed.height == XtHeight(w)) {
831 /* If GeometryManager is invoked during a SetValues call on a child
832 * then it is necessary to compute a new layout if ConstraintSetValues
833 * allowed any constraint changes
835 if (fw->form.needs_relayout)
836 (*((FormWidgetClass)fw->core.widget_class)->form_class.layout)
838 return (XtGeometryNo);
842 * Remember the old size, and then set the size to the requested size
844 old_width = XtWidth(w);
845 old_height = XtHeight(w);
846 XtWidth(w) = allowed.width;
847 XtHeight(w) = allowed.height;
849 if (request->request_mode & XtCWQueryOnly) {
850 Boolean always_resize_children;
851 Dimension ret_width, ret_height;
853 fw->form.resize_in_layout = False;
855 (*((FormWidgetClass)fw->core.widget_class)->form_class.layout)
856 (fw, XtWidth(w), XtHeight(w), False);
859 * Reset the size of this child back to what it used to be
861 XtWidth(w) = old_width;
862 XtHeight(w) = old_height;
864 fw->form.resize_in_layout = True;
866 always_resize_children = ChangeFormGeometry(w, True,
867 fw->form.preferred_width,
868 fw->form.preferred_height,
869 &ret_width, &ret_height);
871 if (always_resize_children
872 || (ret_width >= fw->form.preferred_width
873 && ret_height >= fw->form.preferred_height))
874 ret_val = XtGeometryYes;
876 ret_val = XtGeometryNo;
879 if ((*((FormWidgetClass)fw->core.widget_class)->form_class.layout)
880 (fw, XtWidth(w), XtHeight(w), False)) {
882 int num_children = fw->composite.num_children;
883 WidgetList children = fw->composite.children;
885 if (fw->form.no_refigure) {
887 * I am changing the widget wrapper w/o modifing the window.
888 * This is risky, but I can get away with it since I am the
889 * parent of this widget, and he must ask me for any geometry
892 * The window will be updated when no_refigure is set back
895 form->form.deferred_resize = True;
896 ret_val = XtGeometryDone;
899 ret_val = XtGeometryYes;
904 fw->form.old_width = XtWidth(fw);
905 fw->form.old_height = XtHeight(fw);
906 for (childP = children; childP - children < num_children; childP++) {
909 if (XtIsManaged(nw)) {
910 FormConstraints nform = (FormConstraints)nw->core.constraints;
913 nform->form.virtual_x = XtX(nw);
914 nform->form.virtual_y = XtY(nw);
916 nform->form.virtual_width = XtWidth(nw);
917 nform->form.virtual_height = XtHeight(nw);
922 XtWidth(w) = old_width;
923 XtHeight(w) = old_height;
924 ret_val = XtGeometryNo;
933 XawFormSetValues(Widget current, Widget request, Widget cnew,
934 ArgList args, Cardinal *num_args)
937 FormWidget f_old = (FormWidget)current;
938 FormWidget f_new = (FormWidget)cnew;
940 if (f_old->core.background_pixmap != f_new->core.background_pixmap) {
941 XawPixmap *opix, *npix;
943 opix = XawPixmapFromXPixmap(f_old->core.background_pixmap, XtScreen(f_old),
944 f_old->core.colormap, f_old->core.depth);
945 npix = XawPixmapFromXPixmap(f_new->core.background_pixmap, XtScreen(f_new),
946 f_new->core.colormap, f_new->core.depth);
947 if ((npix && npix->mask) || (opix && opix->mask))
948 XawReshapeWidget(cnew, npix);
957 XawFormConstraintInitialize(Widget request, Widget cnew,
958 ArgList args, Cardinal *num_args)
960 FormConstraints form = (FormConstraints)cnew->core.constraints;
961 FormWidget fw = (FormWidget)cnew->core.parent;
964 form->form.virtual_x = XtX(cnew);
965 form->form.virtual_y = XtY(cnew);
967 form->form.virtual_width = XtWidth(cnew);
968 form->form.virtual_height = XtHeight(cnew);
970 if (form->form.dx == default_value)
971 form->form.dx = fw->form.default_spacing;
973 if (form->form.dy == default_value)
974 form->form.dy = fw->form.default_spacing;
976 form->form.deferred_resize = False;
981 XawFormConstraintSetValues(Widget current, Widget request, Widget cnew,
982 ArgList args, Cardinal *num_args)
984 FormConstraints cfc = (FormConstraints)current->core.constraints;
985 FormConstraints nfc = (FormConstraints)cnew->core.constraints;
987 if (cfc->form.top != nfc->form.top || cfc->form.bottom != nfc->form.bottom
988 || cfc->form.left != nfc->form.left || cfc->form.right != nfc->form.right
989 || cfc->form.dx != nfc->form.dx || cfc->form.dy != nfc->form.dy
990 || cfc->form.horiz_base != nfc->form.horiz_base
991 || cfc->form.vert_base != nfc->form.vert_base) {
992 FormWidget fp = (FormWidget)XtParent(cnew);
994 /* If there are no subclass ConstraintSetValues procedures remaining
995 * to be invoked, and if there is no geometry request about to be
996 * made, then invoke the new layout now; else defer it
998 if (XtClass(XtParent(cnew)) == formWidgetClass
999 && XtX(current) == XtX(cnew)
1000 && XtY(current) == XtY(cnew)
1001 && XtWidth(current) == XtWidth(cnew)
1002 && XtHeight(current) == XtHeight(cnew)
1003 && XtBorderWidth(current) == XtBorderWidth(cnew))
1004 Layout(fp, 0, 0, True);
1006 fp->form.needs_relayout = True;
1013 XawFormChangeManaged(Widget w)
1015 FormWidget fw = (FormWidget)w;
1016 FormConstraints form;
1017 WidgetList children, childP;
1018 int num_children = fw->composite.num_children;
1021 (*((FormWidgetClass)w->core.widget_class)->form_class.layout)
1022 (fw, XtWidth(w), XtHeight(w), True);
1024 fw->form.old_width = XtWidth(w);
1025 fw->form.old_height = XtHeight(w);
1026 for (children = childP = fw->composite.children;
1027 childP - children < num_children;
1030 if (!XtIsManaged(child))
1032 form = (FormConstraints)child->core.constraints;
1034 form->form.virtual_x = XtX(child);
1035 form->form.virtual_y = XtY(child);
1037 form->form.virtual_width = XtWidth(child);
1038 form->form.virtual_height = XtHeight(child);
1042 static XtGeometryResult
1043 XawFormQueryGeometry(Widget widget, XtWidgetGeometry *request,
1044 XtWidgetGeometry *reply)
1046 FormWidget w = (FormWidget)widget;
1048 reply->width = w->form.preferred_width;
1049 reply->height = w->form.preferred_height;
1050 reply->request_mode = CWWidth | CWHeight;
1052 if ((request->request_mode & (CWWidth | CWHeight)) == (CWWidth | CWHeight)
1053 && request->width == reply->width
1054 && request->height == reply->height)
1055 return (XtGeometryYes);
1056 else if (reply->width == XtWidth(w) && reply->height == XtHeight(w))
1057 return (XtGeometryNo);
1059 return (XtGeometryAlmost);
1066 * Set or reset figuring (ignored if not realized)
1069 XawFormDoLayout(Widget w,
1070 #if NeedWidePrototypes
1078 FormWidget fw = (FormWidget)w;
1079 int num_children = fw->composite.num_children;
1080 WidgetList children = fw->composite.children;
1082 if ((fw->form.no_refigure = !force) == True || !XtIsRealized(w))
1085 for (childP = children; childP - children < num_children; childP++) {
1086 Widget nw = *childP;
1088 if (XtIsManaged(nw)) {
1089 FormConstraints form = (FormConstraints)nw->core.constraints;
1092 * Xt Configure widget is too smart, and optimizes out
1095 XMoveResizeWindow(XtDisplay(nw), XtWindow(nw),
1096 XtX(nw), XtY(nw), XtWidth(nw), XtHeight(nw));
1099 if (form->form.deferred_resize &&
1100 XtClass(nw)->core_class.resize != NULL) {
1101 (*(XtClass(nw)->core_class.resize))(nw);
1102 form->form.deferred_resize = False;