home *** CD-ROM | disk | FTP | other *** search
/ Tools / WinSN5.0Ver.iso / NETSCAP.50 / WIN1998.ZIP / ns / cmd / xfe / XfeWidgets / Xfe / Manager.c < prev    next >
Encoding:
C/C++ Source or Header  |  1998-04-08  |  55.1 KB  |  2,127 lines

  1. /* -*- Mode: C; tab-width: 4; indent-tabs-mode: nil; c-basic-offset: 2 -*-
  2.  *
  3.  * The contents of this file are subject to the Netscape Public License
  4.  * Version 1.0 (the "NPL"); you may not use this file except in
  5.  * compliance with the NPL.  You may obtain a copy of the NPL at
  6.  * http://www.mozilla.org/NPL/
  7.  *
  8.  * Software distributed under the NPL is distributed on an "AS IS" basis,
  9.  * WITHOUT WARRANTY OF ANY KIND, either express or implied. See the NPL
  10.  * for the specific language governing rights and limitations under the
  11.  * NPL.
  12.  *
  13.  * The Initial Developer of this code under the NPL is Netscape
  14.  * Communications Corporation.  Portions created by Netscape are
  15.  * Copyright (C) 1998 Netscape Communications Corporation.  All Rights
  16.  * Reserved.
  17.  */
  18. /*-----------------------------------------*/
  19. /*                                                                        */
  20. /* Name:        <Xfe/Manager.c>                                            */
  21. /* Description:    XfeManager widget source.                                */
  22. /* Author:        Ramiro Estrugo <ramiro@netscape.com>                    */
  23. /*                                                                        */
  24. /*----------------------------------------------------------------------*/
  25.  
  26.  
  27. #include <stdio.h>
  28. #include <assert.h>
  29.  
  30. #include <Xfe/ManagerP.h>
  31. #include <Xfe/PrimitiveP.h>
  32.  
  33. #define MESSAGE0 "XfeManager is an abstract class and cannot be instanciated."
  34. #define MESSAGE1 "No XmNorderFunction installed."
  35. #define MESSAGE2 "XmNselectedChildren is a Read-Only resource."
  36. #define MESSAGE3 "XmNnumSelected is a Read-Only resource."
  37. #define MESSAGE4 "XmNindex is a read-only reasource."
  38. #define MESSAGE5 "Widget is not an XfeManager"
  39. #define MESSAGE6 "XmNpreferredHeight is a read-only resource."
  40. #define MESSAGE7 "XmNpreferredWidth is a read-only resource."
  41. #define MESSAGE8 "XmNnumPopupChildren is a read-only resource."
  42. #define MESSAGE9 "XmNpopupChildren is a read-only resource."
  43. #define MESSAGE11 "The XmNx position of a child cannot be set explicitly."
  44. #define MESSAGE12 "The XmNy position of a child cannot be set explicitly."
  45. #define MESSAGE13 "The XmNborderWidth of a child cannot be set explicitly."
  46. #define MESSAGE14 "Cannot accept new child '%s'."
  47.  
  48. #define MIN_LAYOUT_WIDTH    10
  49. #define MIN_LAYOUT_HEIGHT    10
  50.  
  51. /*----------------------------------------------------------------------*/
  52. /*                                                                        */
  53. /* Core Class Methods                                                    */
  54. /*                                                                        */
  55. /*----------------------------------------------------------------------*/
  56. static void                Initialize        (Widget,Widget,ArgList,Cardinal *);
  57. static void                ClassInitialize    ();
  58. static void                ClassPartInit    (WidgetClass);
  59. static void                Destroy            (Widget);
  60. static void                Resize            (Widget);
  61. static void                Realize            (Widget,XtValueMask *,
  62.                                          XSetWindowAttributes *);
  63. static void                Redisplay        (Widget,XEvent *,Region);
  64. static Boolean            SetValues        (Widget,Widget,Widget,ArgList,
  65.                                          Cardinal *);
  66. static XtGeometryResult QueryGeometry    (Widget,XtWidgetGeometry *,
  67.                                          XtWidgetGeometry *);
  68.  
  69. /*----------------------------------------------------------------------*/
  70. /*                                                                        */
  71. /* Composite Class Methods                                                */
  72. /*                                                                        */
  73. /*----------------------------------------------------------------------*/
  74. static void                InsertChild        (Widget);
  75. static void                DeleteChild        (Widget);
  76. static void                ChangeManaged    (Widget);
  77. static XtGeometryResult GeometryManager    (Widget,XtWidgetGeometry *,
  78.                                          XtWidgetGeometry *);
  79.  
  80. /*----------------------------------------------------------------------*/
  81. /*                                                                        */
  82. /* Constraint Class Methods                                                */
  83. /*                                                                        */
  84. /*----------------------------------------------------------------------*/
  85. static void            ConstraintInitialize    (Widget,Widget,ArgList,Cardinal *);
  86. static Boolean        ConstraintSetValues        (Widget,Widget,Widget,ArgList,
  87.                                              Cardinal *);
  88.  
  89. /*----------------------------------------------------------------------*/
  90. /*                                                                        */
  91. /* XfeManager Class Methods                                                */
  92. /*                                                                        */
  93. /*----------------------------------------------------------------------*/
  94. static void        InitializePostHook            (Widget,Widget);
  95. static Boolean    SetValuesPostHook            (Widget,Widget,Widget);
  96. static void        ConstraintInitializePostHook(Widget,Widget);
  97. static Boolean    ConstraintSetValuesPostHook    (Widget,Widget,Widget);
  98. static void        PreferredGeometry            (Widget,Dimension *,Dimension *);
  99. static void        MinimumGeometry            (Widget,Dimension *,Dimension *);
  100. static void        UpdateRect                    (Widget);
  101. static void        DrawShadow                    (Widget,XEvent *,Region,
  102.                                              XRectangle *);
  103.  
  104. /*----------------------------------------------------------------------*/
  105. /*                                                                        */
  106. /* XfeManager Resources                                                    */
  107. /*                                                                        */
  108. /*----------------------------------------------------------------------*/
  109. static XtResource resources[] = 
  110. {
  111.     /* Callback resources */
  112.     { 
  113.         XmNlayoutCallback,
  114.         XmCCallback,
  115.         XmRCallback,
  116.         sizeof(XtCallbackList),
  117.         XtOffsetOf(XfeManagerRec , xfe_manager . layout_callback),
  118.         XmRImmediate, 
  119.         (XtPointer) NULL,
  120.     },
  121.     { 
  122.         XmNresizeCallback,
  123.         XmCCallback,
  124.         XmRCallback,
  125.         sizeof(XtCallbackList),
  126.         XtOffsetOf(XfeManagerRec , xfe_manager . resize_callback),
  127.         XmRImmediate, 
  128.         (XtPointer) NULL,
  129.     },
  130.     { 
  131.         XmNchangeManagedCallback,
  132.         XmCCallback,
  133.         XmRCallback,
  134.         sizeof(XtCallbackList),
  135.         XtOffsetOf(XfeManagerRec , xfe_manager . change_managed_callback),
  136.         XmRImmediate, 
  137.         (XtPointer) NULL,
  138.     },
  139.  
  140.     /* Busy resources */
  141.     { 
  142.         XmNbusy,
  143.         XmCBusy,
  144.         XmRBoolean,
  145.         sizeof(Boolean),
  146.         XtOffsetOf(XfeManagerRec , xfe_manager . busy),
  147.         XmRImmediate, 
  148.         (XtPointer) False
  149.     },
  150.     { 
  151.         XmNbusyCursor,
  152.         XmCBusyCursor,
  153.         XmRCursor,
  154.         sizeof(Cursor),
  155.         XtOffsetOf(XfeManagerRec , xfe_manager . busy_cursor),
  156.         XmRString,
  157.         "watch"
  158.     },
  159.     { 
  160.         XmNbusyCursorOn,
  161.         XmCBusyCursorOn,
  162.         XmRBoolean,
  163.         sizeof(Boolean),
  164.         XtOffsetOf(XfeManagerRec , xfe_manager . busy_cursor_on),
  165.         XmRImmediate, 
  166.         (XtPointer) False
  167.     },
  168.  
  169.  
  170.     /* Misc resources */
  171.     { 
  172.         XmNignoreConfigure,
  173.         XmCIgnoreConfigure,
  174.         XmRBoolean,
  175.         sizeof(Boolean),
  176.         XtOffsetOf(XfeManagerRec , xfe_manager . ignore_configure),
  177.         XmRImmediate, 
  178.         (XtPointer) False
  179.     },
  180.     { 
  181.         XmNshadowType,
  182.         XmCShadowType,
  183.         XmRShadowType,
  184.         sizeof(unsigned char),
  185.         XtOffsetOf(XfeManagerRec , xfe_manager . shadow_type),
  186.         XmRImmediate, 
  187.         (XtPointer) XfeDEFAULT_SHADOW_TYPE
  188.     },
  189.  
  190.  
  191.     /* Geometry resources */
  192.     {
  193.         XmNusePreferredHeight,
  194.         XmCUsePreferredHeight,
  195.         XmRBoolean,
  196.         sizeof(Boolean),
  197.         XtOffsetOf(XfeManagerRec , xfe_manager . use_preferred_height),
  198.         XmRImmediate, 
  199.         (XtPointer) True
  200.     },
  201.     {
  202.         XmNusePreferredWidth,
  203.         XmCUsePreferredWidth,
  204.         XmRBoolean,
  205.         sizeof(Boolean),
  206.         XtOffsetOf(XfeManagerRec , xfe_manager . use_preferred_width),
  207.         XmRImmediate, 
  208.         (XtPointer) True
  209.     },
  210.     { 
  211.         XmNmarginBottom,
  212.         XmCMarginBottom,
  213.         XmRVerticalDimension,
  214.         sizeof(Dimension),
  215.         XtOffsetOf(XfeManagerRec , xfe_manager . margin_bottom),
  216.         XmRImmediate, 
  217.         (XtPointer) XfeDEFAULT_MARGIN_BOTTOM
  218.     },
  219.     { 
  220.         XmNmarginLeft,
  221.         XmCMarginLeft,
  222.         XmRHorizontalDimension,
  223.         sizeof(Dimension),
  224.         XtOffsetOf(XfeManagerRec , xfe_manager . margin_left),
  225.         XmRImmediate, 
  226.         (XtPointer) XfeDEFAULT_MARGIN_LEFT
  227.     },
  228.     { 
  229.         XmNmarginRight,
  230.         XmCMarginRight,
  231.         XmRHorizontalDimension,
  232.         sizeof(Dimension),
  233.         XtOffsetOf(XfeManagerRec , xfe_manager . margin_right),
  234.         XmRImmediate, 
  235.         (XtPointer) XfeDEFAULT_MARGIN_RIGHT
  236.     },
  237.     { 
  238.         XmNmarginTop,
  239.         XmCMarginTop,
  240.         XmRVerticalDimension,
  241.         sizeof(Dimension),
  242.         XtOffsetOf(XfeManagerRec , xfe_manager . margin_top),
  243.         XmRImmediate, 
  244.         (XtPointer) XfeDEFAULT_MARGIN_TOP
  245.     },
  246.     { 
  247.         XmNminWidth,
  248.         XmCMinWidth,
  249.         XmRHorizontalDimension,
  250.         sizeof(Dimension),
  251.         XtOffsetOf(XfeManagerRec , xfe_manager . min_width),
  252.         XmRImmediate, 
  253.         (XtPointer) 2
  254.     },
  255.     { 
  256.         XmNminHeight,
  257.         XmCMinHeight,
  258.         XmRVerticalDimension,
  259.         sizeof(Dimension),
  260.         XtOffsetOf(XfeManagerRec , xfe_manager . min_height),
  261.         XmRImmediate, 
  262.         (XtPointer) 2
  263.     },
  264.  
  265.     /* For c++ usage */
  266.     { 
  267.         XmNinstancePointer,
  268.         XmCInstancePointer,
  269.         XmRPointer,
  270.         sizeof(XtPointer),
  271.         XtOffsetOf(XfeManagerRec , xfe_manager . instance_pointer),
  272.         XmRImmediate, 
  273.         (XtPointer) NULL
  274.     },
  275.  
  276.  
  277.     /* Read-only resources */
  278.     { 
  279.         XmNpreferredHeight,
  280.         XmCReadOnly,
  281.         XmRVerticalDimension,
  282.         sizeof(Dimension),
  283.         XtOffsetOf(XfeManagerRec , xfe_manager . preferred_height),
  284.         XmRImmediate, 
  285.         (XtPointer) True
  286.     },
  287.     { 
  288.         XmNpreferredWidth,
  289.         XmCReadOnly,
  290.         XmRHorizontalDimension,
  291.         sizeof(Dimension),
  292.         XtOffsetOf(XfeManagerRec , xfe_manager . preferred_width),
  293.         XmRImmediate, 
  294.         (XtPointer) True
  295.     },
  296.  
  297.     /* Popup children resources */
  298.     { 
  299.         XmNnumPopupChildren,
  300.         XmCReadOnly,
  301.         XmRCardinal,
  302.         sizeof(Cardinal),
  303.         XtOffsetOf(CoreRec,core . num_popups),
  304.         XmRImmediate,
  305.         (XtPointer) 0,
  306.     },
  307.     { 
  308.         XmNpopupChildren,
  309.         XmCReadOnly,
  310.         XmRWidgetList,
  311.         sizeof(WidgetList),
  312.         XtOffsetOf(CoreRec,core . popup_list),
  313.         XmRImmediate,
  314.         (XtPointer) NULL,
  315.     },
  316.  
  317.     /* Force the shadow_thickness to 0 */
  318.     { 
  319.         XmNshadowThickness,
  320.         XmCShadowThickness,
  321.         XmRHorizontalDimension,
  322.         sizeof(Dimension),
  323.         XtOffsetOf(XfeManagerRec , manager . shadow_thickness),
  324.         XmRImmediate, 
  325.         (XtPointer) 0
  326.     },
  327.  
  328.     /* Force the width and height to the preffered values */
  329.     { 
  330.         XmNwidth,
  331.         XmCWidth,
  332.         XmRHorizontalDimension,
  333.         sizeof(Dimension),
  334.         XtOffsetOf(XfeManagerRec , core . width),
  335.         XmRImmediate, 
  336.         (XtPointer) XfeDEFAULT_PREFERRED_WIDTH
  337.     },
  338.     { 
  339.         XmNheight,
  340.         XmCHeight,
  341.         XmRVerticalDimension,
  342.         sizeof(Dimension),
  343.         XtOffsetOf(XfeManagerRec , core . height),
  344.         XmRImmediate, 
  345.         (XtPointer) XfeDEFAULT_PREFERRED_HEIGHT
  346.     },
  347. };
  348.  
  349. /*----------------------------------------------------------------------*/
  350. /*                                                                        */
  351. /* XfeManager Synthetic Resources                                        */
  352. /*                                                                        */
  353. /*----------------------------------------------------------------------*/
  354. static XmSyntheticResource syn_resources[] =
  355. {
  356.     { 
  357.         XmNmarginBottom,
  358.         sizeof(Dimension),
  359.         XtOffsetOf(XfeManagerRec , xfe_manager . margin_bottom),
  360.         _XmFromVerticalPixels,
  361.         _XmToVerticalPixels 
  362.     },
  363.     {
  364.         XmNmarginLeft,
  365.         sizeof(Dimension),
  366.         XtOffsetOf(XfeManagerRec , xfe_manager . margin_left),
  367.         _XmFromHorizontalPixels,
  368.         _XmToHorizontalPixels 
  369.     },
  370.     { 
  371.         XmNmarginRight,
  372.         sizeof(Dimension),
  373.         XtOffsetOf(XfeManagerRec , xfe_manager . margin_right),
  374.         _XmFromHorizontalPixels,
  375.         _XmToHorizontalPixels 
  376.     },
  377.     { 
  378.         XmNmarginTop,
  379.         sizeof(Dimension),
  380.         XtOffsetOf(XfeManagerRec , xfe_manager . margin_top),
  381.         _XmFromVerticalPixels,
  382.         _XmToVerticalPixels 
  383.     },
  384.     { 
  385.         XmNminWidth,
  386.         sizeof(Dimension),
  387.         XtOffsetOf(XfeManagerRec , xfe_manager . min_width),
  388.         _XmFromHorizontalPixels,
  389.         _XmToHorizontalPixels 
  390.     },
  391.     { 
  392.         XmNminHeight,
  393.         sizeof(Dimension),
  394.         XtOffsetOf(XfeManagerRec , xfe_manager . min_height),
  395.         _XmFromVerticalPixels,
  396.         _XmToVerticalPixels 
  397.     },
  398. };
  399.  
  400. /*----------------------------------------------------------------------*/
  401. /*                                                                        */
  402. /* XfeManager Constraint Resources                                        */
  403. /*                                                                        */
  404. /*----------------------------------------------------------------------*/
  405. static XtResource constraint_resources[] = 
  406. {
  407.     { 
  408.         XmNpositionIndex,
  409.         XmCPositionIndex,
  410.         XmRInt,
  411.         sizeof(int),
  412.         XtOffsetOf(XfeManagerConstraintRec , xfe_manager . position_index),
  413.         XmRImmediate,
  414.         (XtPointer) -1
  415.     },
  416.     { 
  417.         XmNprivateComponent,
  418.         XmCPrivateComponent,
  419.         XmRBoolean,
  420.         sizeof(Boolean),
  421.         XtOffsetOf(XfeManagerConstraintRec , xfe_manager . private_component),
  422.         XmRImmediate,
  423.         (XtPointer) False
  424.     },
  425. };   
  426.  
  427. /* Widget class record initialization. */
  428. _XFE_WIDGET_CLASS_RECORD(manager,Manager) =
  429. {
  430.     {
  431.         (WidgetClass) &xmManagerClassRec,        /* superclass            */
  432.         "XfeManager",                            /* class_name            */
  433.         sizeof(XfeManagerRec),                    /* widget_size            */
  434.         ClassInitialize,                        /* class_initialize        */
  435.         ClassPartInit,                            /* class_part_initialize*/
  436.         FALSE,                                    /* class_inited            */
  437.         Initialize,                                /* initialize            */
  438.         NULL,                                    /* initialize_hook        */
  439.         Realize,                                /* realize                */
  440.         NULL,                                    /* actions                */
  441.         0,                                        /* num_actions            */
  442.         resources,                                /* resources            */
  443.         XtNumber(resources),                    /* num_resources        */
  444.         NULLQUARK,                                /* xrm_class            */
  445.         TRUE,                                    /* compress_motion        */
  446.         XtExposeCompressMaximal,                /* compress_exposure    */
  447.         TRUE,                                    /* compress_enterleave    */
  448.         FALSE,                                    /* visible_interest        */
  449.         Destroy,                                /* destroy                */
  450.         Resize,                                    /* resize                */
  451.         Redisplay,                                /* expose                */
  452.         SetValues,                                /* set_values            */
  453.         NULL,                                    /* set_values_hook        */
  454.         XtInheritSetValuesAlmost,                /* set_values_almost    */
  455.         NULL,                                    /* get_values_hook        */
  456.         NULL,                                    /* accept_focus            */
  457.         XtVersion,                                /* version                */
  458.         NULL,                                    /* callback_private        */
  459.         XtInheritTranslations,                    /* tm_table                */
  460.         QueryGeometry,                            /* query_geometry        */
  461.         XtInheritDisplayAccelerator,            /* display accel        */
  462.         NULL,                                    /* extension            */
  463.     },
  464.  
  465.     /* Composite Part */
  466.     {
  467.         GeometryManager,                        /* geometry_manager        */
  468.         ChangeManaged,                            /* change_managed        */
  469.         InsertChild,                            /* insert_child            */
  470.         DeleteChild,                            /* delete_child            */
  471.         NULL                                    /* extension            */
  472.     },
  473.     
  474.     /* Constraint Part */
  475.     {
  476.         constraint_resources,                    /* resource list        */
  477.         XtNumber(constraint_resources),            /* num resources        */
  478.         sizeof(XfeManagerConstraintRec),        /* constraint size        */
  479.         ConstraintInitialize,                    /* init proc            */
  480.         NULL,                                    /* destroy proc            */
  481.         ConstraintSetValues,                    /* set values proc        */
  482.         NULL,                                    /* extension            */
  483.     },
  484.  
  485.     /* XmManager Part */
  486.     {
  487.         XtInheritTranslations,                    /* tm_table                */
  488.         syn_resources,                            /* syn resources        */
  489.         XtNumber(syn_resources),                /* num syn_resources    */
  490.         NULL,                                    /* syn_cont_resources    */
  491.         0,                                        /* num_syn_cont_res        */
  492.         XmInheritParentProcess,                    /* parent_process        */
  493.         NULL,                                    /* extension            */
  494.     },
  495.  
  496.     /* XfeManager Part */
  497.     {
  498.         ForgetGravity,                            /* bit_gravity            */
  499.         PreferredGeometry,                        /* preferred_geometry    */
  500.         MinimumGeometry,                        /* minimum_geometry    */
  501.         UpdateRect,                                /* update_rect            */
  502.         NULL,                                    /* accept_child            */
  503.         NULL,                                    /* insert_child            */
  504.         NULL,                                    /* delete_child            */
  505.         NULL,                                    /* change_managed        */
  506.         NULL,                                    /* prepare_components    */
  507.         NULL,                                    /* layout_components    */
  508.         NULL,                                    /* layout_children        */
  509.         NULL,                                    /* draw_background        */
  510.         DrawShadow,                                /* draw_shadow            */
  511.         NULL,                                    /* draw_components        */
  512.         NULL                                    /* extension            */
  513.     },
  514. };
  515.  
  516. /*----------------------------------------------------------------------*/
  517. /*                                                                        */
  518. /* xfeManagerWidgetClass declaration.                                    */
  519. /*                                                                        */
  520. /*----------------------------------------------------------------------*/
  521. _XFE_WIDGET_CLASS(manager,Manager);
  522.  
  523. /*----------------------------------------------------------------------*/
  524. /*                                                                        */
  525. /* Core Class Methods                                                    */
  526. /*                                                                        */
  527. /*----------------------------------------------------------------------*/
  528. static void
  529. ClassInitialize()
  530. {
  531.     /* Register Xfe Converters */
  532.     XfeRegisterConverters();
  533.  
  534.     /* Register Representation Types */
  535.     XfeRegisterRepresentationTypes();
  536. }
  537. /*----------------------------------------------------------------------*/
  538. static void
  539. ClassPartInit(WidgetClass wc)
  540. {
  541.     XfeManagerWidgetClass cc = (XfeManagerWidgetClass) wc;
  542.     XfeManagerWidgetClass sc = (XfeManagerWidgetClass) wc->core_class.superclass;
  543.  
  544.     _XfeResolve(cc,sc,xfe_manager_class,bit_gravity,
  545.                 XfeInheritBitGravity);
  546.    
  547.     _XfeResolve(cc,sc,xfe_manager_class,preferred_geometry,
  548.                 XfeInheritPreferredGeometry);
  549.  
  550.     _XfeResolve(cc,sc,xfe_manager_class,minimum_geometry,
  551.                 XfeInheritMinimumGeometry);
  552.  
  553.     _XfeResolve(cc,sc,xfe_manager_class,update_rect,
  554.                 XfeInheritUpdateRect);
  555.  
  556.     _XfeResolve(cc,sc,xfe_manager_class,accept_child,
  557.                 XfeInheritAcceptChild);
  558.  
  559.     _XfeResolve(cc,sc,xfe_manager_class,insert_child,
  560.                 XfeInheritInsertChild);
  561.  
  562.     _XfeResolve(cc,sc,xfe_manager_class,delete_child,
  563.                 XfeInheritDeleteChild);
  564.  
  565.     _XfeResolve(cc,sc,xfe_manager_class,change_managed,
  566.                 XfeInheritChangeManaged);
  567.  
  568.     _XfeResolve(cc,sc,xfe_manager_class,layout_components,
  569.                 XfeInheritLayoutComponents);
  570.  
  571.     _XfeResolve(cc,sc,xfe_manager_class,layout_children,
  572.                 XfeInheritLayoutChildren);
  573.    
  574.     _XfeResolve(cc,sc,xfe_manager_class,draw_background,
  575.                 XfeInheritDrawBackground);
  576.    
  577.     _XfeResolve(cc,sc,xfe_manager_class,draw_shadow,
  578.                 XfeInheritDrawShadow);
  579.    
  580.     _XfeResolve(cc,sc,xfe_manager_class,draw_components,
  581.                 XfeInheritDrawComponents);
  582. }
  583. /*----------------------------------------------------------------------*/
  584. static void
  585. Initialize(Widget rw,Widget nw,ArgList args,Cardinal *nargs)
  586. {
  587.     /* Initialize private members */
  588.     _XfemComponentFlag(nw)            = True;
  589.   
  590.     /* Make sure the shadow is ok */
  591.     XfeRepTypeCheck(nw,XmRShadowType,&_XfemShadowType(nw),
  592.                     XfeDEFAULT_SHADOW_TYPE);
  593.  
  594.     /* Finish of initialization */
  595.     _XfeManagerChainInitialize(rw,nw,xfeManagerWidgetClass);
  596. }
  597. /*----------------------------------------------------------------------*/
  598. static void
  599. Realize(Widget w,XtValueMask *mask,XSetWindowAttributes* wa)
  600. {
  601.     XSetWindowAttributes attr;
  602.     
  603.     /* Make sure only subclasses of XfeManager get instanciated */
  604.     if ((XtClass(w) == xfeManagerWidgetClass))
  605.     {
  606.         _XfeWarning(w,MESSAGE0);
  607.  
  608.         return;
  609.     }
  610.  
  611.     /* Let Manager Create Window */
  612.     (*xmManagerWidgetClass->core_class.realize)(w,mask,wa);
  613.     
  614.     /* Set the Bit Gravity to Forget Gravity */
  615.     attr.bit_gravity = _XfeManagerAccessBitGravity(w);
  616.     
  617.     XChangeWindowAttributes(XtDisplay(w), _XfeWindow(w), CWBitGravity, &attr);
  618. }
  619. /*----------------------------------------------------------------------*/
  620. static void
  621. Destroy(Widget w)
  622. {
  623.     /* Remove all CallBacks */
  624.     /* XtRemoveAllCallbacks(w,XmNlayoutCallback); */
  625.     /* XtRemoveAllCallbacks(w,XmNresizeCallback); */
  626.     /* XtRemoveAllCallbacks(w,XmNexposeCallback); */
  627. }
  628. /*----------------------------------------------------------------------*/
  629. static void
  630. Resize(Widget w)
  631. {
  632.     /*printf("%s: Resize to (%d,%d)\n",XtName(w),_XfeWidth(w),_XfeHeight(w));*/
  633.  
  634.     /* Obtain the Prefered Geometry */
  635.     _XfeManagerPreferredGeometry(w,
  636.                                  &_XfemPreferredWidth(w),
  637.                                  &_XfemPreferredHeight(w));
  638.  
  639.     /* Force the preferred dimensions if required */
  640.     if (_XfemUsePreferredWidth(w))
  641.     {
  642.         _XfeWidth(w) = _XfemPreferredWidth(w);
  643.     }
  644.     
  645.     if (_XfemUsePreferredHeight(w))
  646.     {
  647.         _XfeHeight(w) = _XfemPreferredHeight(w);
  648.     }
  649.     
  650.     /* Update the widget rect */
  651.     _XfeManagerUpdateRect(w);
  652.     
  653.     /* Layout the components */
  654.     _XfeManagerLayoutComponents(w);
  655.     
  656.     /* Layout the children */
  657.     _XfeManagerLayoutChildren(w);
  658.  
  659.     /* Invoke Resize Callbacks */
  660.     _XfeInvokeCallbacks(w,_XfemResizeCallback(w),XmCR_RESIZE,NULL,False);
  661. }
  662. /*----------------------------------------------------------------------*/
  663. static void
  664. Redisplay(Widget w,XEvent *event,Region region)
  665. {
  666.     /* Make sure the widget is realized before drawing ! */
  667.     if (!XtIsRealized(w)) return;
  668.    
  669.     /* Draw Background */ 
  670.     _XfeManagerDrawBackground(w,event,region,&_XfemWidgetRect(w));
  671.  
  672.     /* Draw Shadow */ 
  673.     _XfeManagerDrawShadow(w,event,region,&_XfemWidgetRect(w));
  674.  
  675.     /* Draw Components */ 
  676.     _XfeManagerDrawComponents(w,event,region,&_XfemWidgetRect(w));
  677.  
  678.     /* Redisplay Gadgets */
  679.     _XmRedisplayGadgets(w,event,region);
  680. }
  681. /*----------------------------------------------------------------------*/
  682. static Boolean
  683. SetValues(Widget ow,Widget rw,Widget nw,ArgList args,Cardinal *nargs)
  684. {
  685.    /* Reset the Configuration Flags */
  686.     _XfemConfigFlags(nw) = XfeConfigNone;
  687.  
  688.     /* Reset the preparation Flags */
  689.     _XfemPrepareFlags(nw) = XfePrepareNone;
  690.  
  691.     /* preferred_height */
  692.     if (_XfemPreferredHeight(nw) != _XfemPreferredHeight(ow))
  693.     {
  694.         _XfemPreferredHeight(nw) = _XfemPreferredHeight(ow);
  695.       
  696.         _XfeWarning(nw,MESSAGE6);
  697.     }
  698.  
  699.     /* preferred_width */
  700.     if (_XfemPreferredWidth(nw) != _XfemPreferredWidth(ow))
  701.     {
  702.         _XfemPreferredWidth(nw) = _XfemPreferredWidth(ow);
  703.       
  704.         _XfeWarning(nw,MESSAGE7);
  705.     }
  706.  
  707.     /* num_popups */
  708.     if (_XfeNumPopups(nw) != _XfeNumPopups(ow))
  709.     {
  710.         _XfeNumPopups(nw) = _XfeNumPopups(ow);
  711.       
  712.         _XfeWarning(nw,MESSAGE8);
  713.     }
  714.  
  715.     /* popup_list */
  716.     if (_XfePopupList(nw) != _XfePopupList(ow))
  717.     {
  718.         _XfePopupList(nw) = _XfePopupList(ow);
  719.       
  720.         _XfeWarning(nw,MESSAGE9);
  721.     }
  722.  
  723.     /* height */
  724.     if (_XfeHeight(nw) != _XfeHeight(ow))
  725.     {
  726.         /* if resize_heigh is True, we dont allow width changes */
  727.         if (_XfemUsePreferredHeight(nw)) 
  728.         {
  729.             _XfeHeight(nw) = _XfeHeight(ow);
  730.         }
  731.         else
  732.         {
  733.             _XfemConfigFlags(nw) |= XfeConfigGLE;
  734.         }
  735.     }
  736.    
  737.     /* width */
  738.     if (_XfeWidth(nw) != _XfeWidth(ow))
  739.     {
  740.         /* if resize_width is True, we dont allow width changes */
  741.         if (_XfemUsePreferredWidth(nw)) 
  742.         {
  743.             _XfeWidth(nw) = _XfeWidth(ow);
  744.         }
  745.         else
  746.         {
  747.             _XfemConfigFlags(nw) |= XfeConfigGLE;
  748.         }
  749.     }
  750.  
  751.     /* Changes in sensitivity */
  752.     if (_XfeSensitive(nw) != _XfeSensitive(ow))
  753.     {
  754.         Widget *    pw;
  755.         int            i;
  756.  
  757.         /* Make sure all the children have the same sensitivity */
  758.         for (i = 0, pw = _XfemChildren(nw); i < _XfemNumChildren(nw); i++,pw++)
  759.         {
  760.             if (_XfeIsAlive(*pw))
  761.             {
  762.                 if (XtIsSensitive(*pw) != XtIsSensitive(nw))
  763.                 {
  764.                     XtSetSensitive(*pw,_XfeSensitive(nw));
  765.                 }
  766.             }
  767.         }
  768.     }
  769.  
  770.     /* busy */
  771.     if (_XfemBusy(nw) != _XfemBusy(ow))
  772.     {
  773.         if (_XfemBusy(nw))
  774.         {
  775.             if (_XfemBusyCursor(nw))
  776.             {
  777.                 XfeCursorDefine(nw,_XfemBusyCursor(nw));
  778.             }
  779.         }
  780.         else
  781.         {
  782.             XfeCursorUndefine(nw);
  783.         }
  784.     }
  785.    
  786.     /* busy_cursor */
  787.     if (_XfemBusyCursor(nw) != _XfemBusyCursor(ow))
  788.     {
  789.         if (_XfemBusyCursorOn(nw) && _XfemBusyCursor(nw) && XtIsRealized(nw))
  790.         {
  791.             XfeCursorDefine(nw,_XfemBusyCursor(nw));
  792.         }
  793.     }
  794.  
  795.     /* busy_cursor_on */
  796.     if (_XfemBusyCursorOn(nw) != _XfemBusyCursorOn(ow))
  797.     {
  798.         /* Undefine the old cursor if needed */
  799.         if (_XfemBusyCursorOn(ow) && _XfemBusyCursor(ow) && XtIsRealized(ow))
  800.         {
  801.             XfeCursorUndefine(ow);
  802.         }
  803.         else if (_XfemBusyCursorOn(nw) && 
  804.                  _XfemBusyCursor(nw) && 
  805.                  XtIsRealized(nw))
  806.         {
  807.             XfeCursorDefine(nw,_XfemBusyCursor(nw));
  808.         }
  809.     }
  810.  
  811.     /* Changes that affect the layout and geometry */
  812.     if ((_XfemMarginTop(nw)            != _XfemMarginTop(ow)) ||
  813.         (_XfemMarginBottom(nw)        != _XfemMarginBottom(ow)) ||
  814.         (_XfemMarginLeft(nw)        != _XfemMarginLeft(ow)) ||
  815.         (_XfemMarginRight(nw)        != _XfemMarginRight(ow)) ||       
  816.         (_XfemShadowThickness(nw)    != _XfemShadowThickness(ow)) ||
  817.         (_XfemUnitType(nw)            != _XfemUnitType(ow)))
  818.     {
  819.         _XfemConfigFlags(nw) |= XfeConfigGLE;
  820.     }
  821.  
  822.     /* shadow_type */
  823.     if (_XfemShadowType(nw) != _XfemShadowType(ow))
  824.     {
  825.         /* Make sure the new shadow type is ok */
  826.         XfeRepTypeCheck(nw,XmRShadowType,&_XfemShadowType(nw),XfeDEFAULT_SHADOW_TYPE);
  827.  
  828.         _XfemConfigFlags(nw) |= XfeConfigExpose;
  829.     }
  830.  
  831.     return _XfeManagerChainSetValues(ow,rw,nw,xfeManagerWidgetClass);
  832. }
  833. /*----------------------------------------------------------------------*/
  834. static XtGeometryResult
  835. QueryGeometry(Widget w,XtWidgetGeometry    *req,XtWidgetGeometry *reply)
  836. {
  837.     reply->request_mode        = CWWidth | CWHeight;
  838.     reply->width            = _XfemPreferredWidth(w);
  839.     reply->height            = _XfemPreferredHeight(w);
  840.  
  841.     /* XtGeometryYes: Request matches Prefered Geometry. */
  842.     if (((req->request_mode & CWWidth) && (req->width == reply->width)) &&
  843.         ((req->request_mode & CWHeight) && (req->height == reply->height)))
  844.     {
  845.         return XtGeometryYes;
  846.     }
  847.     
  848.     /* XtGeometryNo: Reply matches current Geometry. */
  849.     if ((reply->width == _XfeWidth(w)) && (reply->height == _XfeHeight(w)))
  850.     {
  851.         return XtGeometryNo; 
  852.     }
  853.     
  854.     /* XtGeometryAlmost: One of reply fields doesn't match cur/req Geometry. */
  855.     return XtGeometryAlmost; 
  856. }
  857. /*----------------------------------------------------------------------*/
  858.  
  859. /*----------------------------------------------------------------------*/
  860. /*                                                                        */
  861. /* Composite Class Methods                                                */
  862. /*                                                                        */
  863. /*----------------------------------------------------------------------*/
  864. static void
  865. InsertChild(Widget child)
  866. {
  867.     Widget                  w = XtParent(child);
  868.     XmManagerWidgetClass    mwc = (XmManagerWidgetClass) xmManagerWidgetClass;
  869.  
  870.     /* Leave private components alone */
  871.     if (_XfemComponentFlag(w) || _XfeManagerPrivateComponent(child))
  872.     {
  873.         /* Mark the child as a private component */
  874.         _XfeManagerPrivateComponent(child) = True;
  875.  
  876.         /* Call XmManager's InsertChild */
  877.         (*mwc->composite_class.insert_child)(child);
  878.  
  879.     }
  880.     /* Accept or reject other children */
  881.     else if (_XfeManagerAcceptChild(child))
  882.     {
  883.         /* Call XmManager's InsertChild */
  884.         (*mwc->composite_class.insert_child)(child);
  885.         
  886.         /* Insert the child and relayout if necessary */
  887.         if (_XfeManagerInsertChild(child))
  888.         {
  889.             XfeManagerLayout(w);
  890.         }
  891.     }
  892.     else
  893.      {
  894.         _XfeArgWarning(w,MESSAGE14,XtName(child));
  895.     }
  896. }
  897. /*----------------------------------------------------------------------*/
  898. static void
  899. DeleteChild(Widget child)
  900. {
  901.     Widget                  w = XtParent(child);
  902.     XmManagerWidgetClass    mwc = (XmManagerWidgetClass) xmManagerWidgetClass;
  903.     Boolean                 layout = XtIsManaged(child);
  904.  
  905.     /* Leave private components alone */
  906.     if (!_XfeManagerPrivateComponent(child))
  907.     {
  908.         /* Delete the child and relayout if necessary */
  909.         layout = _XfeManagerDeleteChild(child);
  910.     }
  911.     
  912.     /* call manager DeleteChild to update child info */
  913.     (*mwc->composite_class.delete_child)(child);
  914.  
  915.     if (layout)
  916.     {
  917.         XfeManagerLayout(w);
  918.     }
  919. }
  920. /*----------------------------------------------------------------------*/
  921. static void
  922. ChangeManaged(Widget w)
  923. {
  924.     /* Update widget geometry only if ignore_configure is False */
  925.     if (!_XfemIgnoreConfigure(w))
  926.     {
  927.         Boolean        change_width = False;
  928.         Boolean        change_height = False;
  929.  
  930. #if 0
  931.         /* Prepare the Widget */
  932.         _XfeManagerPrepareComponents(w,_XfemPrepareFlags(w));
  933. #endif
  934.  
  935.         /* Invoke the change_managed method */
  936.         _XfeManagerChangeManaged(w);
  937.  
  938.         /* Obtain our new preferred geometry */
  939.         _XfeManagerPreferredGeometry(w,
  940.                                      &_XfemPreferredWidth(w),
  941.                                      &_XfemPreferredHeight(w));
  942.         
  943.         /* Check for changes in preferred width if needed */
  944.         if (_XfemUsePreferredWidth(w) && (_XfeWidth(w) != _XfemPreferredWidth(w)))
  945.         {
  946.             change_width = True;
  947.         }
  948.  
  949.         /* Check for changes in preferred height if needed */
  950.         if (_XfemUsePreferredHeight(w) && (_XfeHeight(w) != _XfemPreferredHeight(w)))
  951.         {
  952.             change_height = True;
  953.         }
  954.         
  955.         /* Check for geometry changes */
  956.         if (change_width || change_height)
  957.         {
  958.             XtGeometryResult    result;
  959.             XtWidgetGeometry    request;
  960.  
  961.             request.request_mode = 0;
  962.  
  963.             /* Request a width change */
  964.             if (change_width)
  965.             {
  966.                 request.width = _XfemPreferredWidth(w);
  967.                 request.request_mode |= CWWidth;
  968.             }
  969.  
  970.             /* Request a width height */
  971.             if (change_height)
  972.             {
  973.                 request.height = _XfemPreferredHeight(w);
  974.                 request.request_mode |= CWHeight;
  975.             }
  976.  
  977.             /* Make the request */
  978.             result = _XmMakeGeometryRequest(w,&request);
  979.  
  980.             /* Adjust geometry accordingly */
  981.             if (result == XtGeometryYes)
  982.             {
  983.                 /* Goody */
  984.             }
  985.             else if(result == XtGeometryNo)
  986.             {
  987.                 /* Too bad */
  988.             }
  989. #if 0            
  990.             /* Make a geometry request to accomodate new geometry */
  991.             _XfeWidth(w) = _XfemPreferredWidth(w);
  992.             _XfeHeight(w) = _XfemPreferredHeight(w);
  993. #endif
  994.         }
  995.  
  996.         /* Update the widget rect */
  997.         _XfeManagerUpdateRect(w);
  998.         
  999.         /* Layout the components */
  1000.         _XfeManagerLayoutComponents(w);
  1001.         
  1002.         /* Layout the children */
  1003.         _XfeManagerLayoutChildren(w);
  1004.     }
  1005.     else
  1006.     {
  1007. /*        printf("Change managed for %s - ignored \n",XtName(w));*/
  1008.     }
  1009.  
  1010.     /* Invoke change managed callbacks */
  1011.     _XfeInvokeCallbacks(w,_XfemChangeManagedCallback(w),
  1012.                         XmCR_CHANGE_MANAGED,NULL,False);
  1013.     
  1014.     /* Update keyboard traversal */
  1015.     _XmNavigChangeManaged(w);
  1016. }
  1017. /*----------------------------------------------------------------------*/
  1018. static XtGeometryResult
  1019. GeometryManager(Widget child,XtWidgetGeometry *request,XtWidgetGeometry *reply)
  1020. {
  1021. #if 1
  1022.     Widget                w = XtParent(child);
  1023.     XtGeometryMask        mask = request->request_mode;
  1024.     XtGeometryResult    our_result = XtGeometryNo;
  1025.  
  1026. /*     printf("GeometryManager(%s) - child = %s\n",XtName(w),XtName(child)); */
  1027.     
  1028.     /* Ignore x changes */
  1029.     if (mask & CWX)
  1030.     {
  1031.         mask |= ~CWX;
  1032.  
  1033.         /*_XfeWarning(w,MESSAGE11);*/
  1034.     }
  1035.  
  1036.     /* Ignore y changes */
  1037.     if (mask & CWY)
  1038.     {
  1039.         mask |= ~CWY;
  1040.         
  1041.         /*_XfeWarning(w,MESSAGE12);*/
  1042.     }
  1043.  
  1044.     /* Ignore border_width changes */
  1045.     if (mask & CWBorderWidth)
  1046.     {
  1047.         mask |= ~CWBorderWidth;
  1048.  
  1049.         /*_XfeWarning(w,MESSAGE13);*/
  1050.     }
  1051.  
  1052.     /* Check for something else being requested */
  1053.     if ((mask & CWWidth) || (mask & CWHeight))
  1054.     {
  1055.         Boolean                change_width = False;
  1056.         Boolean                change_height = False;
  1057.         Dimension            old_width;
  1058.         Dimension            old_height;
  1059.         Dimension            pref_width;
  1060.         Dimension            pref_height;
  1061.  
  1062.         /* Remember the child's old dimensions */
  1063.         old_width = _XfeWidth(child);
  1064.         old_height = _XfeHeight(child);
  1065.  
  1066.         /* Adjust the child's dimensions _TEMPORARLY_ */
  1067.         if (mask & CWWidth)
  1068.         {
  1069.             _XfeWidth(child) = request->width;
  1070.         }
  1071.  
  1072.         if (mask & CWHeight)
  1073.         {
  1074.             _XfeHeight(child) = request->height;
  1075.         }
  1076.  
  1077.         /* Obtain the preferred geometry to support the new child */
  1078.         _XfeManagerPreferredGeometry(w,&pref_width,&pref_height);
  1079.  
  1080.         /* Restore the child's dimensions */
  1081.         _XfeWidth(child) = old_width;
  1082.         _XfeHeight(child) = old_height;
  1083.             
  1084.         /* Check for changes in preferred width if needed */
  1085.         if (_XfemUsePreferredWidth(w) && (_XfeWidth(w) != pref_width))
  1086.         {
  1087.             change_width = True;
  1088.         }
  1089.  
  1090.         /* Check for changes in preferred height if needed */
  1091.         if (_XfemUsePreferredHeight(w) && (_XfeHeight(w) != pref_height))
  1092.         {
  1093.             change_height = True;
  1094.         }
  1095.  
  1096.         /* Check for geometry changes to ourselves */
  1097.         if (change_width || change_height)
  1098.         {
  1099.             XtGeometryResult    parent_result;
  1100.             XtWidgetGeometry    parent_request;
  1101.                 
  1102.             parent_request.request_mode = 0;
  1103.                 
  1104.             /* Request a width change */
  1105.             if (change_width)
  1106.             {
  1107.                 parent_request.width = pref_width;
  1108.                 parent_request.request_mode |= CWWidth;
  1109.             }
  1110.                 
  1111.             /* Request a width height */
  1112.             if (change_height)
  1113.             {
  1114.                 parent_request.height = pref_height;
  1115.                 parent_request.request_mode |= CWHeight;
  1116.             }
  1117.  
  1118.             /* Make the request */
  1119.             parent_result = _XmMakeGeometryRequest(w,&parent_request);
  1120.  
  1121.             /* Adjust geometry accordingly */
  1122.             if (parent_result == XtGeometryYes)
  1123.             {
  1124.                 /* Goody */
  1125.                 if (mask & CWWidth)
  1126.                 {
  1127.                     _XfeWidth(child) = request->width;
  1128.  
  1129.                     _XfemPreferredWidth(w) = pref_width;
  1130.                 }
  1131.  
  1132.                 if (mask & CWHeight)
  1133.                 {
  1134.                     _XfeHeight(child) = request->height;
  1135.  
  1136.                     _XfemPreferredHeight(w) = pref_height;
  1137.                 }
  1138.  
  1139.                 XfeResize(w);
  1140.  
  1141.                 our_result = XtGeometryYes;
  1142.  
  1143.             }
  1144.             else if(parent_result == XtGeometryNo)
  1145.             {
  1146.                 /* Too bad */
  1147.             }
  1148.         }
  1149.     }
  1150.  
  1151.     return our_result;
  1152.  
  1153. #else
  1154.  
  1155.     Widget                w = XtParent(child);
  1156.     XtGeometryMask        mask = request->request_mode;
  1157.     Boolean                set_almost = False;
  1158.     XtGeometryResult     result = XtGeometryYes;
  1159.     XtWidgetGeometry     geo_request;
  1160.     XtWidgetGeometry     geo_reply;
  1161.     Boolean                dim_flag = False;
  1162.     Boolean                x_flag = False;
  1163.     Boolean                y_flag = False;
  1164.     Position            x;
  1165.     Position            y;
  1166.  
  1167.     /*
  1168.     *We do not allow children to change position, since that is the
  1169.     * whole point of this widget!  
  1170.     */
  1171.     if (!(mask & (CWWidth | CWHeight)))
  1172.     {
  1173.         return XtGeometryNo;
  1174.     }
  1175.     
  1176.     /*
  1177.      *The child can also request a combination of width/height
  1178.      * and/or border changes.  In this situation, we will have to
  1179.      * return XtGeometryAlmost
  1180.      */ 
  1181.     
  1182.     if ((mask & CWX) && (request->x != w->core.x))
  1183.     {
  1184.         reply->x = w->core.x;
  1185.         reply->request_mode |= CWX;
  1186.         set_almost = True;
  1187.     }
  1188.     
  1189.     if ((mask & CWY) && (request->y != w->core.y))
  1190.     {
  1191.         reply->y = w->core.y;
  1192.         reply->request_mode |= CWY;
  1193.         set_almost = True;
  1194.     }
  1195.     
  1196.     if ((mask & CWBorderWidth) && 
  1197.        (request->border_width != w->core.border_width))
  1198.     {
  1199.         reply->y = w->core.border_width;
  1200.         reply->request_mode |= CWBorderWidth;
  1201.         set_almost = True;
  1202.     }
  1203.     
  1204.     /* Check for queryonly or requests other than width and height.
  1205.      * If the request more than just width and height, we must
  1206.      * return GeometryAlmost. This means the request to our parent must be
  1207.      * a queryonly request to prevent our parent from reconfiguring our
  1208.      * geometry.
  1209.      */
  1210.     if ((mask & XtCWQueryOnly) || set_almost)
  1211.     {
  1212.         geo_request.request_mode = XtCWQueryOnly;
  1213.     }
  1214.     else
  1215.     {
  1216.         geo_request.request_mode = 0 ;
  1217.     }
  1218.    
  1219.     if (mask & CWWidth)
  1220.     {
  1221.         /* If the request width causes the column to grow or
  1222.          * the request width may cause the column to shrink
  1223.          * see if the change will affect the grid's geometry.
  1224.          * Otherwise expexp the request and change the childs width.
  1225.          */
  1226.         w->core.width = request->width;
  1227.         reply->width = w->core.width;
  1228.         
  1229.         dim_flag = True;
  1230.     }
  1231.     
  1232.     
  1233.     if (mask & CWHeight)
  1234.     {
  1235.         /* If the request width causes the column to grow or
  1236.          * the request width may cause the column to shrink
  1237.          * see if the change will affect the grid's geometry.
  1238.          * Otherwise expexp the request and change the childs width.
  1239.          */
  1240.         w->core.height = request->height;
  1241.         reply->height = w->core.height;
  1242.         
  1243.         dim_flag = True;
  1244.     }
  1245.     
  1246.     if (set_almost) 
  1247.     {
  1248.         return XtGeometryAlmost;
  1249.     }
  1250.     
  1251.     if (dim_flag)
  1252.     {
  1253.         if (!_XfemIgnoreConfigure(XtParent(w)))
  1254.         {
  1255.             XfeResize(XtParent(w));
  1256.         }
  1257.     }
  1258.     
  1259.     return XtGeometryYes;
  1260. #endif
  1261. }
  1262. /*----------------------------------------------------------------------*/
  1263.  
  1264.  
  1265. /*----------------------------------------------------------------------*/
  1266. /*                                                                        */
  1267. /* Constraint Class Methods                                                */
  1268. /*                                                                        */
  1269. /*----------------------------------------------------------------------*/
  1270. static void
  1271. ConstraintInitialize(Widget rw,Widget nw,ArgList args,Cardinal *nargs)
  1272. {
  1273. /*     Widget                        w = XtParent(nw); */
  1274. /*    XfeManagerConstraintPart *    cp = _XfeManagerConstraintPart(nw);*/
  1275.  
  1276.     /* Finish constraint initialization */
  1277.     _XfeConstraintChainInitialize(rw,nw,xfeManagerWidgetClass);
  1278. }
  1279. /*----------------------------------------------------------------------*/
  1280. static Boolean
  1281. ConstraintSetValues(Widget ow,Widget rw,Widget nw,ArgList args,Cardinal *nargs)
  1282. {
  1283.     Widget                        w = XtParent(nw);
  1284. /*     XfeManagerConstraintPart *    np = _XfeManagerConstraintPart(nw); */
  1285. /*     XfeManagerConstraintPart *    op = _XfeManagerConstraintPart(ow); */
  1286.  
  1287.     /* Reset the Configuration Flags */
  1288.     _XfemConfigFlags(w) = XfeConfigNone;
  1289.  
  1290.     /* Reset the preparation Flags */
  1291.     _XfemPrepareFlags(w) = XfePrepareNone;
  1292.  
  1293.  
  1294.     /* Finish constraint set values */
  1295.     return _XfeConstraintChainSetValues(ow,rw,nw,xfeManagerWidgetClass);
  1296. }
  1297. /*----------------------------------------------------------------------*/
  1298.  
  1299.  
  1300. /*----------------------------------------------------------------------*/
  1301. /*                                                                        */
  1302. /* XfeManager Class Methods                                                */
  1303. /*                                                                        */
  1304. /*----------------------------------------------------------------------*/
  1305. static void
  1306. InitializePostHook(Widget rw,Widget nw)
  1307. {
  1308.     assert( nw != NULL );
  1309.     assert( _XfeIsAlive(nw) );
  1310.     assert( XfeIsManager(nw) );
  1311.  
  1312.     _XfemPrepareFlags(nw) = XfePrepareAll;
  1313.     
  1314.     /* Prepare the Widget */
  1315.     _XfeManagerPrepareComponents(nw,_XfemPrepareFlags(nw));
  1316.     
  1317.     /* Obtain the preferred dimensions for the first time. */
  1318.     _XfeManagerPreferredGeometry(nw,
  1319.                                  &_XfemPreferredWidth(nw),
  1320.                                  &_XfemPreferredHeight(nw));
  1321.     
  1322.     /* Force the preferred width if needed */
  1323.     if (_XfemUsePreferredWidth(nw) || 
  1324.         (_XfeWidth(nw) == XfeDEFAULT_PREFERRED_WIDTH))
  1325.     {
  1326.         _XfeWidth(nw) = _XfemPreferredWidth(nw);
  1327.     }
  1328.  
  1329.     /* Force the preferred height if needed */
  1330.     if (_XfemUsePreferredHeight(nw) || 
  1331.         (_XfeHeight(nw) == XfeDEFAULT_PREFERRED_HEIGHT))
  1332.     {
  1333.         _XfeHeight(nw) = _XfemPreferredHeight(nw);
  1334.     }
  1335.     
  1336.     /* Update the widget rect */
  1337.     _XfeManagerUpdateRect(nw);
  1338.     
  1339.     /* Layout the components */
  1340.     _XfeManagerLayoutComponents(nw);
  1341.     
  1342.     /* Layout the children */
  1343.     _XfeManagerLayoutChildren(nw);
  1344.     
  1345.     _XfemComponentFlag(nw) = False;
  1346.     _XfemPrepareFlags(nw) = XfePrepareNone;
  1347.  
  1348.     _XfemOldWidth(nw) = XfeGEOMETRY_INVALID_DIMENSION;
  1349.     _XfemOldHeight(nw) = XfeGEOMETRY_INVALID_DIMENSION;
  1350. }
  1351. /*----------------------------------------------------------------------*/
  1352. static Boolean
  1353. SetValuesPostHook(Widget ow,Widget rw,Widget nw)
  1354. {
  1355.     assert( nw != NULL );
  1356.     assert( _XfeIsAlive(nw) );
  1357.     assert( XfeIsManager(nw) );
  1358.  
  1359.     /* Prepare the Widget if needed */
  1360.     if (_XfemPrepareFlags(nw))
  1361.     {
  1362.         _XfeManagerPrepareComponents(nw,_XfemPrepareFlags(nw));
  1363.     }
  1364.     
  1365.     /* Obtain the preferred dimensions if needed */
  1366.     if (_XfemConfigFlags(nw) & XfeConfigGeometry)
  1367.     {
  1368.         _XfeManagerPreferredGeometry(nw,
  1369.                                      &_XfemPreferredWidth(nw),
  1370.                                      &_XfemPreferredHeight(nw));
  1371.         
  1372.         /* Set the preferred dimensions if resize flags are True */
  1373.         if (_XfemUsePreferredWidth(nw))
  1374.         {
  1375.             _XfeWidth(nw) = _XfemPreferredWidth(nw);
  1376.         }
  1377.         
  1378.         if (_XfemUsePreferredHeight(nw))
  1379.         {
  1380.             _XfeHeight(nw) = _XfemPreferredHeight(nw);
  1381.         }
  1382.     }
  1383.     
  1384.     /* Update the widget rect */
  1385.     _XfeManagerUpdateRect(nw);
  1386.  
  1387.     /* Clear the window if it is dirty and realized */
  1388.     if (XtIsRealized(nw) && (_XfemConfigFlags(nw) & XfeConfigDirty))
  1389.     {
  1390.         XClearWindow(XtDisplay(nw),_XfeWindow(nw));
  1391.     }
  1392.     
  1393.     if (_XfemConfigFlags(nw) & XfeConfigLayout)
  1394.     {
  1395.         /* Layout the components */
  1396.         _XfeManagerLayoutComponents(nw);
  1397.         
  1398.         /* Layout the children */
  1399.         _XfeManagerLayoutChildren(nw);
  1400.     }
  1401.     
  1402.     return (_XfemConfigFlags(nw) & XfeConfigExpose);
  1403. }
  1404. /*----------------------------------------------------------------------*/
  1405. static void
  1406. ConstraintInitializePostHook(Widget rw,Widget nw)
  1407. {
  1408.     Widget                        w = XtParent(nw);
  1409. /*     XfeManagerConstraintPart *    cp = _XfeManagerConstraintPart(nw); */
  1410.  
  1411.     assert( w != NULL );
  1412.     assert( _XfeIsAlive(w) );
  1413.     assert( XfeIsManager(w) );
  1414.  
  1415.     /* Nothing.  I wonder if some geometry magic is needed here ? */
  1416. }
  1417. /*----------------------------------------------------------------------*/
  1418. static Boolean
  1419. ConstraintSetValuesPostHook(Widget oc,Widget rc,Widget nc)
  1420. {
  1421.     Widget                 w = XtParent(nc);
  1422.  
  1423.     assert( w != NULL );
  1424.     assert( _XfeIsAlive(w) );
  1425.     assert( XfeIsManager(w) );
  1426.  
  1427.     /* The following is the same as SetValuesPostHook() - combine ... */
  1428.  
  1429.     /* Prepare the Widget if needed */
  1430.     if (_XfemPrepareFlags(w))
  1431.     {
  1432.         _XfeManagerPrepareComponents(w,_XfemPrepareFlags(w));
  1433.     }
  1434.     
  1435.     /* Obtain the preferred dimensions if needed */
  1436.     if (_XfemConfigFlags(w) & XfeConfigGeometry)
  1437.     {
  1438.         _XfeManagerPreferredGeometry(w,
  1439.                                      &_XfemPreferredWidth(w),
  1440.                                      &_XfemPreferredHeight(w));
  1441.         
  1442.         /* Set the preferred dimensions if resize flags are True */
  1443.         if (_XfemUsePreferredWidth(w))
  1444.         {
  1445.             _XfeWidth(w) = _XfemPreferredWidth(w);
  1446.         }
  1447.         
  1448.         if (_XfemUsePreferredHeight(w))
  1449.         {
  1450.             _XfeHeight(w) = _XfemPreferredHeight(w);
  1451.         }
  1452.     }
  1453.     
  1454.     /* Update the widget rect */
  1455.     _XfeManagerUpdateRect(w);
  1456.  
  1457.     /* Clear the window if it is dirty and realized */
  1458.     if (XtIsRealized(w) && (_XfemConfigFlags(w) & XfeConfigDirty))
  1459.     {
  1460.         XClearWindow(XtDisplay(w),_XfeWindow(w));
  1461.     }
  1462.     
  1463.     if (_XfemConfigFlags(w) & XfeConfigLayout)
  1464.     {
  1465.         /* Layout the components */
  1466.         _XfeManagerLayoutComponents(w);
  1467.         
  1468.         /* Layout the children */
  1469.         _XfeManagerLayoutChildren(w);
  1470.     }
  1471.     
  1472.     return (_XfemConfigFlags(w) & XfeConfigExpose);
  1473. }
  1474. /*----------------------------------------------------------------------*/
  1475. static void
  1476. PreferredGeometry(Widget w,Dimension *width,Dimension *height)
  1477. {
  1478.     *width  = _XfemOffsetLeft(w) + _XfemOffsetRight(w);
  1479.     *height = _XfemOffsetTop(w) + _XfemOffsetBottom(w);
  1480. }
  1481. /*----------------------------------------------------------------------*/
  1482. static void
  1483. MinimumGeometry(Widget w,Dimension *width,Dimension *height)
  1484. {
  1485.     *width  = _XfemOffsetLeft(w) + _XfemOffsetRight(w);
  1486.     *height = _XfemOffsetTop(w) + _XfemOffsetBottom(w);
  1487. }
  1488. /*----------------------------------------------------------------------*/
  1489. static void
  1490. UpdateRect(Widget w)
  1491. {
  1492.     XfeRectSet(&_XfemWidgetRect(w),
  1493.                
  1494.                _XfemOffsetLeft(w),
  1495.                
  1496.                _XfemOffsetTop(w),
  1497.                
  1498.                _XfeWidth(w) - _XfemOffsetLeft(w) - _XfemOffsetRight(w),
  1499.                
  1500.                _XfeHeight(w) - _XfemOffsetTop(w) - _XfemOffsetBottom(w));
  1501. }
  1502. /*----------------------------------------------------------------------*/
  1503. static void
  1504. DrawShadow(Widget w,XEvent * event,Region region,XRectangle * clip_rect)
  1505. {
  1506.     if (!_XfemShadowThickness(w))
  1507.      {
  1508.          return;
  1509.      }
  1510.  
  1511.     /* Draw the shadow */
  1512.     _XmDrawShadows(XtDisplay(w),
  1513.                    _XfeWindow(w),
  1514.                    _XfemTopShadowGC(w),_XfemBottomShadowGC(w),
  1515.                    0,0,
  1516.                    _XfeWidth(w),_XfeHeight(w),
  1517.                    _XfemShadowThickness(w),
  1518.                    _XfemShadowType(w));
  1519. }
  1520. /*----------------------------------------------------------------------*/
  1521.  
  1522. /*----------------------------------------------------------------------*/
  1523. /*                                                                        */
  1524. /* XfeManager Method invocation functions                                */
  1525. /*                                                                        */
  1526. /*----------------------------------------------------------------------*/
  1527. void
  1528. _XfeManagerPreferredGeometry(Widget w,Dimension *width,Dimension *height)
  1529. {
  1530.     XfeManagerWidgetClass    mc = (XfeManagerWidgetClass) XtClass(w);
  1531.  
  1532.     Dimension                min_width = 
  1533.         XfeMax(_XfemMinWidth(w),XfeMANAGER_DEFAULT_WIDTH);
  1534.  
  1535.     Dimension                min_height = 
  1536.         XfeMax(_XfemMinHeight(w),XfeMANAGER_DEFAULT_HEIGHT);
  1537.     
  1538.     if (mc->xfe_manager_class.preferred_geometry)
  1539.     {
  1540.         (*mc->xfe_manager_class.preferred_geometry)(w,width,height);
  1541.     }
  1542.  
  1543.     /* Make sure preferred width is greater than the min possible width */
  1544.     if (*width <= min_width)
  1545.     {
  1546.         *width = min_width;
  1547.     }
  1548.  
  1549.     /* Make sure preferred height is greater than the min possible height */
  1550.     if (*height <= min_height)
  1551.     {
  1552.         *height = min_height;
  1553.     }
  1554. }
  1555. /*----------------------------------------------------------------------*/
  1556. void
  1557. _XfeManagerMinimumGeometry(Widget w,Dimension *width,Dimension *height)
  1558. {
  1559.     XfeManagerWidgetClass    mc = (XfeManagerWidgetClass) XtClass(w);
  1560.  
  1561.     if (mc->xfe_manager_class.minimum_geometry)
  1562.     {
  1563.         (*mc->xfe_manager_class.minimum_geometry)(w,width,height);
  1564.     }
  1565. }
  1566. /*----------------------------------------------------------------------*/
  1567. void
  1568. _XfeManagerUpdateRect(Widget w)
  1569. {
  1570.     XfeManagerWidgetClass mc = (XfeManagerWidgetClass) XtClass(w);
  1571.     
  1572.     if (mc->xfe_manager_class.update_rect)
  1573.     {
  1574.         (*mc->xfe_manager_class.update_rect)(w);
  1575.     }
  1576. }
  1577. /*----------------------------------------------------------------------*/
  1578. /* extern */ Boolean
  1579. _XfeManagerAcceptChild(Widget child)
  1580. {
  1581.     Boolean                    result = True;
  1582.     Widget                    w = XtParent(child);
  1583.     XfeManagerWidgetClass    mc = (XfeManagerWidgetClass) XtClass(w);
  1584.     
  1585.     if (mc->xfe_manager_class.accept_child)
  1586.     {
  1587.         result = (*mc->xfe_manager_class.accept_child)(child);
  1588.     }
  1589.  
  1590.     return result;
  1591. }
  1592. /*----------------------------------------------------------------------*/
  1593. /* extern */ Boolean
  1594. _XfeManagerInsertChild(Widget child)
  1595. {
  1596.     Boolean                    result = XtIsManaged(child);
  1597.     Widget                    w = XtParent(child);
  1598.     XfeManagerWidgetClass    mc = (XfeManagerWidgetClass) XtClass(w);
  1599.     
  1600.     if (mc->xfe_manager_class.insert_child)
  1601.     {
  1602.         result = (*mc->xfe_manager_class.insert_child)(child);
  1603.     }
  1604.  
  1605.     return result;
  1606. }
  1607. /*----------------------------------------------------------------------*/
  1608. /* extern */ Boolean
  1609. _XfeManagerDeleteChild(Widget child)
  1610. {
  1611.     Boolean                    result = XtIsManaged(child);
  1612.     Widget                    w = XtParent(child);
  1613.     XfeManagerWidgetClass    mc = (XfeManagerWidgetClass) XtClass(w);
  1614.     
  1615.     if (mc->xfe_manager_class.delete_child)
  1616.     {
  1617.         result = (*mc->xfe_manager_class.delete_child)(child);
  1618.     }
  1619.  
  1620.     return result;
  1621. }
  1622. /*----------------------------------------------------------------------*/
  1623. /* extern */ void
  1624. _XfeManagerChangeManaged(Widget w)
  1625. {
  1626.     XfeManagerWidgetClass    mc = (XfeManagerWidgetClass) XtClass(w);
  1627.     
  1628.     if (mc->xfe_manager_class.change_managed)
  1629.     {
  1630.         (*mc->xfe_manager_class.change_managed)(w);
  1631.     }
  1632. }
  1633. /*----------------------------------------------------------------------*/
  1634. void
  1635. _XfeManagerPrepareComponents(Widget w,int flags)
  1636. {
  1637.     WidgetClass                cc;
  1638.     XfeManagerWidgetClass    mc;
  1639.     Cardinal                i = 0;
  1640.     Cardinal                count = 0;
  1641.  
  1642.     /* Someone has to be nuts to have more than 32 subclasses... */
  1643.     static XfePrepareProc        proc_table[32];
  1644.  
  1645.     /* Traverse all classes until we find XmManager */
  1646.     for (cc = XtClass(w); 
  1647.          cc != xmManagerWidgetClass; 
  1648.          cc = cc->core_class.superclass)
  1649.     {
  1650.         mc = (XfeManagerWidgetClass) cc;
  1651.  
  1652.         /* Add the method to the table */
  1653.         if (mc->xfe_manager_class.prepare_components)
  1654.         {
  1655.             proc_table[count++] = mc->xfe_manager_class.prepare_components;
  1656.         }
  1657.     }
  1658.  
  1659.     /* Invoke the methods in reverse order */
  1660.     for (i = count; i; i--)
  1661.     {
  1662.         XfePrepareProc proc = proc_table[i - 1];
  1663.  
  1664.         /* Invoke the prepare_components */
  1665.         (*proc)(w,flags);
  1666.     }
  1667. }
  1668. /*----------------------------------------------------------------------*/
  1669. void
  1670. _XfeManagerLayoutComponents(Widget w)
  1671. {
  1672.     XfeManagerWidgetClass mc = (XfeManagerWidgetClass) XtClass(w);
  1673.  
  1674.      if ((_XfeWidth(w) <= MIN_LAYOUT_WIDTH) || (_XfeHeight(w) <= MIN_LAYOUT_HEIGHT))
  1675.     {
  1676.         return;
  1677.     }
  1678.     
  1679.     if (mc->xfe_manager_class.layout_components)
  1680.     {
  1681.         (*mc->xfe_manager_class.layout_components)(w);
  1682.     }
  1683. }
  1684. /*----------------------------------------------------------------------*/
  1685. void
  1686. _XfeManagerLayoutChildren(Widget w)
  1687. {
  1688.     XfeManagerWidgetClass mc = (XfeManagerWidgetClass) XtClass(w);
  1689.  
  1690.      if ((_XfeWidth(w) <= MIN_LAYOUT_WIDTH) || (_XfeHeight(w) <= MIN_LAYOUT_HEIGHT))
  1691.     {
  1692.         return;
  1693.     }
  1694.     
  1695.     if (mc->xfe_manager_class.layout_children)
  1696.     {
  1697.         (*mc->xfe_manager_class.layout_children)(w);
  1698.     }
  1699. }
  1700. /*----------------------------------------------------------------------*/
  1701. void
  1702. _XfeManagerDrawBackground(Widget        w,
  1703.                           XEvent *        event,
  1704.                           Region        region,
  1705.                           XRectangle *    rect)
  1706. {
  1707.     XfeManagerWidgetClass mc = (XfeManagerWidgetClass) XtClass(w);
  1708.     
  1709.     if (mc->xfe_manager_class.draw_background)
  1710.     {
  1711.         (*mc->xfe_manager_class.draw_background)(w,event,region,rect);
  1712.     }
  1713. }
  1714. /*----------------------------------------------------------------------*/
  1715. void
  1716. _XfeManagerDrawComponents(Widget        w,
  1717.                           XEvent *        event,
  1718.                           Region        region,
  1719.                           XRectangle *    rect)
  1720. {
  1721.     XfeManagerWidgetClass mc = (XfeManagerWidgetClass) XtClass(w);
  1722.     
  1723.     if (mc->xfe_manager_class.draw_components)
  1724.     {
  1725.         (*mc->xfe_manager_class.draw_components)(w,event,region,rect);
  1726.     }
  1727. }
  1728. /*----------------------------------------------------------------------*/
  1729. void
  1730. _XfeManagerDrawShadow(Widget        w,
  1731.                       XEvent *        event,
  1732.                       Region        region,
  1733.                       XRectangle *    rect)
  1734. {
  1735.     XfeManagerWidgetClass mc = (XfeManagerWidgetClass) XtClass(w);
  1736.     
  1737.     if (mc->xfe_manager_class.draw_shadow)
  1738.     {
  1739.         (*mc->xfe_manager_class.draw_shadow)(w,event,region,rect);
  1740.     }
  1741. }
  1742. /*----------------------------------------------------------------------*/
  1743.  
  1744. /* Public Functions */
  1745. /*----------------------------------------------------------------------*/
  1746. void
  1747. XfeManagerLayout(Widget w)
  1748. {
  1749.     assert( _XfeIsAlive(w) );
  1750.     assert( XfeIsManager(w) );
  1751.  
  1752.     XfeResize(w);
  1753.  
  1754. #if 0    
  1755.    /* Setup the max children dimensions */
  1756.     _XfeManagerChildrenInfo(w,
  1757.                             &_XfemMaxChildWidth(w),
  1758.                             &_XfemMaxChildHeight(w),
  1759.                             &_XfemTotalChildrenWidth(w),
  1760.                             &_XfemTotalChildrenHeight(w),
  1761.                             &_XfemNumManaged(w),
  1762.                             &_XfemNumComponents(w));
  1763.     
  1764.  
  1765.     /* Make sure some components exist */
  1766.     if (!_XfemNumComponents(w))
  1767.     {
  1768.         return;
  1769.     }
  1770.     
  1771.     /* Layout the components */
  1772.     _XfeManagerLayoutComponents(w);
  1773.     
  1774.     /* Layout the children */
  1775.     _XfeManagerLayoutChildren(w);
  1776. #endif
  1777. }
  1778. /*----------------------------------------------------------------------*/
  1779. void
  1780. XfeManagerSetChildrenValues(Widget        w,
  1781.                             ArgList        args,
  1782.                             Cardinal    count,
  1783.                             Boolean        only_managed)
  1784. {
  1785.     Cardinal i;
  1786.    
  1787.     assert(w != NULL);
  1788.    
  1789.     /* Make sure its a Manager */
  1790.     if (!XfeIsManager(w))
  1791.     {
  1792.         _XfeWarning(w,MESSAGE5);
  1793.         return;
  1794.     }
  1795.  
  1796.     _XfemIgnoreConfigure(w) = True;
  1797.  
  1798.     /* Iterate through all the items */
  1799.     for (i = 0; i < _XfemNumChildren(w); i++)
  1800.     {
  1801.         Widget obj = _XfemChildren(w)[i];
  1802.  
  1803.         if (_XfeIsAlive(obj))
  1804.         {
  1805.             if (only_managed && XtIsManaged(obj))
  1806.             {
  1807.                 XtSetValues(obj,args,count);
  1808.             }
  1809.             else
  1810.             {
  1811.                 XtSetValues(obj,args,count);
  1812.             }
  1813.         }
  1814.     }
  1815.    
  1816.     _XfemIgnoreConfigure(w) = False;
  1817.  
  1818. /*    XfeConfigure(w); */
  1819. }
  1820. /*----------------------------------------------------------------------*/
  1821. void
  1822. XfeManagerApply(Widget                w,
  1823.                 XfeManagerApplyProc    proc,
  1824.                 XtPointer            data,
  1825.                 Boolean                only_managed)
  1826. {
  1827.    Cardinal i;
  1828.  
  1829.    assert(w != NULL);
  1830.  
  1831.    /* Make sure its a Manager */
  1832.    if (!XfeIsManager(w))
  1833.    {
  1834.       _XfeWarning(w,MESSAGE5);
  1835.  
  1836.       return;
  1837.    }
  1838.  
  1839.     /* Show the action button as needed */
  1840.     _XfemIgnoreConfigure(w) = True;
  1841.  
  1842.    /* Iterate through all the items */
  1843.    for (i = 0; i < _XfemNumChildren(w); i++)
  1844.    {
  1845.        Widget child = _XfemChildren(w)[i];
  1846.        
  1847.        if (child && 
  1848.            _XfeIsAlive(child) && 
  1849.            !_XfeManagerPrivateComponent(child))
  1850.        {
  1851.            if (only_managed)
  1852.            {
  1853.                if (XtIsManaged(child))
  1854.                {
  1855.                    proc(w,child,data);
  1856.                }
  1857.            }
  1858.            else
  1859.            {
  1860.                proc(w,child,data);
  1861.            }
  1862.        }
  1863.    }
  1864.  
  1865.     _XfemIgnoreConfigure(w) = False;
  1866.  
  1867.     XfeManagerLayout(w);
  1868. }
  1869.  
  1870.  
  1871. /*----------------------------------------------------------------------*/
  1872. /*                                                                        */
  1873. /* XfeManager private functions                                            */
  1874. /*                                                                        */
  1875. /*----------------------------------------------------------------------*/
  1876. /* extern */ void
  1877. _XfeManagerChainInitialize(Widget rw,Widget nw,WidgetClass wc)
  1878. {
  1879.     assert( nw != NULL );
  1880.  
  1881.     if (XtClass(nw) == wc)
  1882.     {
  1883.         InitializePostHook(rw,nw);
  1884.     }
  1885. }
  1886. /*----------------------------------------------------------------------*/
  1887. /* extern */ Boolean
  1888. _XfeManagerChainSetValues(Widget ow,Widget rw,Widget nw,WidgetClass wc)
  1889. {
  1890.     assert( nw != NULL );
  1891.  
  1892.     if (XtClass(nw) == wc)
  1893.     {
  1894.         return SetValuesPostHook(ow,rw,nw);
  1895.     }
  1896.     
  1897.     return False;
  1898. }
  1899. /*----------------------------------------------------------------------*/
  1900. /* extern */ void
  1901. _XfeConstraintChainInitialize(Widget rw,Widget nw,WidgetClass wc)
  1902. {
  1903.     assert( nw != NULL );
  1904.     assert( XtParent(nw) != NULL );
  1905.  
  1906.     if (XtClass(XtParent(nw)) == wc)
  1907.     {
  1908.         ConstraintInitializePostHook(rw,nw);
  1909.     }
  1910. }
  1911. /*----------------------------------------------------------------------*/
  1912. /* extern */ Boolean
  1913. _XfeConstraintChainSetValues(Widget ow,Widget rw,Widget nw,WidgetClass wc)
  1914. {
  1915.     assert( nw != NULL );
  1916.     assert( XtParent(nw) != NULL );
  1917.  
  1918.     if (XtClass(XtParent(nw)) == wc)
  1919.     {
  1920.         return ConstraintSetValuesPostHook(ow,rw,nw);
  1921.     }
  1922.     
  1923.     return False;
  1924. }
  1925. /*----------------------------------------------------------------------*/
  1926. /*                                                                        */
  1927. /* Name:        _XfeManagerChildrenInfo()                                */
  1928. /*                                                                        */
  1929. /* Purpose:        Obtain information about the manager's children            */
  1930. /*                                                                        */
  1931. /* Ret Val:        void                                                    */
  1932. /*                                                                        */
  1933. /* Args in:        w                    The manager widget.                    */
  1934. /*                                                                        */
  1935. /* Args out:    max_width_out        Max managed child width                */
  1936. /*                max_height_out        Max managed child height            */
  1937. /*                num_managed_out        Num managed children                */
  1938. /*                num_components_out    Num component children                */
  1939. /*                                                                        */
  1940. /* Comments:    Output args can be NULL - for which no value is            */
  1941. /*                assigned or returned.                                    */
  1942. /*                                                                        */
  1943. /*----------------------------------------------------------------------*/
  1944. /* extern */ void
  1945. _XfeManagerChildrenInfo(Widget            w,
  1946.                         Dimension *        max_width_out,
  1947.                         Dimension *        max_height_out,
  1948.                         Dimension *        total_width_out,
  1949.                         Dimension *        total_height_out,
  1950.                         Cardinal *        num_managed_out,
  1951.                         Cardinal *        num_components_out)
  1952. {
  1953.     Dimension            max_width = 0;
  1954.     Dimension            max_height = 0;
  1955.     Dimension            total_width = 0;
  1956.     Dimension            total_height = 0;
  1957.     Cardinal            num_managed = 0;
  1958.     Cardinal            num_components = 0;
  1959.     Widget                child;
  1960.     Cardinal            i;
  1961.  
  1962.     if (!XfeIsManager(w))
  1963.     {
  1964.         _XfeWarning(w,MESSAGE5);
  1965.  
  1966.         return;
  1967.     }
  1968.  
  1969.     /* Iterate through all the items */
  1970.     for (i = 0; i < _XfemNumChildren(w); i++)
  1971.     {
  1972.         child = _XfemChildren(w)[i];
  1973.  
  1974.         /* Check for private components */
  1975.         if (_XfeManagerPrivateComponent(child))
  1976.         {
  1977.                 num_components++;
  1978.         }
  1979.         else
  1980.         {
  1981.             /* Make sure widget is shown */
  1982.             if (_XfeChildIsShown(child))
  1983.             {
  1984.                 Dimension width;
  1985.                 Dimension height;
  1986.  
  1987.                 if (XfeIsPrimitive(child))
  1988.                 {
  1989.                     width = _XfePreferredWidth(child);
  1990.                 }
  1991.                 else
  1992.                 {
  1993.                     width = _XfeWidth(child);
  1994.                 }
  1995.  
  1996.                 if (XfeIsPrimitive(child))
  1997.                 {
  1998.                     height = _XfePreferredHeight(child);
  1999.                 }
  2000.                 else
  2001.                 {
  2002.                     height = _XfeHeight(child);
  2003.                 }
  2004.  
  2005.                 /* Keep track of largest width */
  2006.                 if (width > max_width)
  2007.                 {
  2008.                     max_width = width;
  2009.                 }
  2010.  
  2011.  
  2012.                 /* Keep track of largest height */
  2013.                 if (height > max_height)
  2014.                 {
  2015.                     max_height = height;
  2016.                 }
  2017.  
  2018.                 total_width  += width;
  2019.                 total_height += height;
  2020.                 
  2021.                 num_managed++;
  2022.             }
  2023.         }
  2024.     }
  2025.  
  2026.     /* Assign only required arguments */
  2027.     if (max_width_out) 
  2028.     {
  2029.         *max_width_out = max_width;
  2030.     }
  2031.  
  2032.     if (max_height_out) 
  2033.     {
  2034.         *max_height_out = max_height;
  2035.     }
  2036.  
  2037.     if (total_width_out) 
  2038.     {
  2039.         *total_width_out = total_width;
  2040.     }
  2041.  
  2042.     if (total_height_out) 
  2043.     {
  2044.         *total_height_out = total_height;
  2045.     }
  2046.  
  2047.     if (num_managed_out) 
  2048.     {
  2049.         *num_managed_out = num_managed;
  2050.     }
  2051.  
  2052.     if (num_components_out) 
  2053.     {
  2054.         *num_components_out = num_components;
  2055.     }
  2056. }
  2057. /*----------------------------------------------------------------------*/
  2058. /*                                                                        */
  2059. /* Name:        _XfeManagerComponentInfo()                                */
  2060. /*                                                                        */
  2061. /* Purpose:        Obtain information about the manager's components        */
  2062. /*                                                                        */
  2063. /* Ret Val:        void                                                    */
  2064. /*                                                                        */
  2065. /* Args in:        w                    The manager widget.                    */
  2066. /*                                                                        */
  2067. /* Args out:    max_width_out        Max managed child width                */
  2068. /*                max_height_out        Max managed child height            */
  2069. /*                                                                        */
  2070. /* Comments:    Output args can be NULL - for which no value is            */
  2071. /*                assigned or returned.                                    */
  2072. /*                                                                        */
  2073. /*----------------------------------------------------------------------*/
  2074. /* extern */ void
  2075. _XfeManagerComponentInfo(Widget                w,
  2076.                          Dimension *        max_width_out,
  2077.                          Dimension *        max_height_out)
  2078. {
  2079.     Dimension            max_width = 0;
  2080.     Dimension            max_height = 0;
  2081.     Widget                child;
  2082.     Cardinal            i;
  2083.  
  2084.     if (!XfeIsManager(w))
  2085.     {
  2086.         _XfeWarning(w,MESSAGE5);
  2087.  
  2088.         return;
  2089.     }
  2090.  
  2091.     /* Iterate through all the items */
  2092.     for (i = 0; i < _XfemNumChildren(w); i++)
  2093.     {
  2094.         child = _XfemChildren(w)[i];
  2095.  
  2096.         /* Check for private components */
  2097.         if (_XfeManagerPrivateComponent(child) &&
  2098.             XtIsManaged(child) && 
  2099.             _XfeIsAlive(child))
  2100.         {
  2101.             /* Keep track of largest width */
  2102.             if (_XfeWidth(child) > max_width)
  2103.             {
  2104.                 max_width = _XfeWidth(child);
  2105.             }
  2106.  
  2107.             /* Keep track of largest height */
  2108.             if (_XfeHeight(child) > max_height)
  2109.             {
  2110.                 max_height = _XfeHeight(child);
  2111.             }
  2112.         }
  2113.     }
  2114.  
  2115.     /* Assign only required arguments */
  2116.     if (max_width_out) 
  2117.     {
  2118.         *max_width_out = max_width;
  2119.     }
  2120.  
  2121.     if (max_height_out) 
  2122.     {
  2123.         *max_height_out = max_height;
  2124.     }
  2125. }
  2126. /*----------------------------------------------------------------------*/
  2127.