home *** CD-ROM | disk | FTP | other *** search
/ Tools / WinSN5.0Ver.iso / NETSCAP.50 / WIN1998.ZIP / ns / cmd / xfe / XfeWidgets / Xfe / Pane.c < prev    next >
Encoding:
C/C++ Source or Header  |  1998-04-08  |  69.6 KB  |  2,675 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/Pane.c>                                            */
  21. /* Description:    XfePane widget source.                                    */
  22. /* Author:        Ramiro Estrugo <ramiro@netscape.com>                    */
  23. /*                                                                        */
  24. /*----------------------------------------------------------------------*/
  25.  
  26.  
  27. #include <Xfe/PaneP.h>
  28.  
  29. #include <stdio.h>
  30.  
  31. #define MESSAGE1 "Widget is not an XfePane."
  32. #define MESSAGE2 "XmNpaneChildType can only be set at creationg time."
  33. #define MESSAGE3 "Only one child attachment can be XmNalwaysVisible."
  34. #define MESSAGE4 "The descendant for XfePaneAddDragDescendant() is invalid."
  35. #define MESSAGE5 "Cannot find a valid ancestor attachment for '%s'."
  36.  
  37. #define DEFAULT_SASH_POSITION 300
  38.  
  39. #define TWO_TIMES_SST(sp) ((sp)->sash_shadow_thickness << 1)
  40.  
  41. #define ALWAYS_VISIBLE(w) \
  42. ( _XfeChildIsShown(w) && (_XfePaneConstraintPart(w) -> always_visible) )
  43.  
  44. #define CONSTRAINT_ALLOW_EXPAND(w) \
  45. (_XfeIsAlive(w) && (_XfePaneConstraintPart(w) -> allow_expand))
  46.  
  47. #define CONSTRAINT_ALLOW_RESIZE(w) \
  48. (_XfeIsAlive(w) && (_XfePaneConstraintPart(w) -> allow_resize))
  49.  
  50. #define SASH_SPACING(cp) \
  51. (sp->sash_thickness ? sp->sash_spacing : 0)
  52.  
  53. #define CHOOSE_X_OR_Y(o,x,y) \
  54. (((o) == XmVERTICAL) ? (y) : (x))
  55.  
  56. /*----------------------------------------------------------------------*/
  57. /*                                                                        */
  58. /* Core class methods                                                    */
  59. /*                                                                        */
  60. /*----------------------------------------------------------------------*/
  61. static void     Initialize            (Widget,Widget,ArgList,Cardinal *);
  62. static void     Destroy                (Widget);
  63. static Boolean    SetValues            (Widget,Widget,Widget,ArgList,Cardinal *);
  64.  
  65. /*----------------------------------------------------------------------*/
  66. /*                                                                        */
  67. /* Constraint class methods                                                */
  68. /*                                                                        */
  69. /*----------------------------------------------------------------------*/
  70. static void        ConstraintInitialize(Widget,Widget,ArgList,Cardinal *);
  71. static Boolean    ConstraintSetValues    (Widget,Widget,Widget,ArgList,Cardinal *);
  72.  
  73. /*----------------------------------------------------------------------*/
  74. /*                                                                        */
  75. /* XfeManager class methods                                                */
  76. /*                                                                        */
  77. /*----------------------------------------------------------------------*/
  78. static void        PreferredGeometry    (Widget,Dimension *,Dimension *);
  79. static void        MinimumGeometry    (Widget,Dimension *,Dimension *);
  80. static Boolean    AcceptChild            (Widget);
  81. static Boolean    InsertChild            (Widget);
  82. static Boolean    DeleteChild            (Widget);
  83. static void        PrepareComponents    (Widget,int);
  84. static void        LayoutComponents    (Widget);
  85. static void        LayoutChildren        (Widget);
  86. static void        DrawComponents        (Widget,XEvent *,Region,XRectangle *);
  87.  
  88. /*----------------------------------------------------------------------*/
  89. /*                                                                        */
  90. /* XfeOriented class methods                                            */
  91. /*                                                                        */
  92. /*----------------------------------------------------------------------*/
  93. static void     EnterProc                (Widget,Widget,int,int);
  94. static void     MotionProc                (Widget,Widget,int,int);
  95. static void     DragStart                (Widget,Widget,int,int);
  96. static void     DragEnd                    (Widget,Widget,int,int);
  97. static void     DragMotion                (Widget,Widget,int,int);
  98. static void     DescendantDragStart        (Widget,Widget,int,int);
  99. static void     DescendantDragEnd        (Widget,Widget,int,int);
  100. static void     DescendantDragMotion    (Widget,Widget,int,int);
  101.  
  102. /*----------------------------------------------------------------------*/
  103. /*                                                                        */
  104. /* Child functions                                                        */
  105. /*                                                                        */
  106. /*----------------------------------------------------------------------*/
  107. static Boolean        ChildShouldExpand            (Widget,Widget);
  108. static void            ChildLayout                    (Widget,Widget,Widget,Widget,
  109.                                                  Widget,XfeGeometry);
  110. static void            ChildOneLayoutVertical        (Widget);
  111. static void            ChildOneLayoutHorizontal    (Widget);
  112. static void            ChildTwoLayoutVertical        (Widget);
  113. static void            ChildTwoLayoutHorizontal    (Widget);
  114.  
  115. static Boolean        ChildOneAttachmentsAreFull    (Widget);
  116. static Boolean        ChildTwoAttachmentsAreFull    (Widget);
  117.  
  118. static Dimension    ChildMaxSize                (Widget,Widget);
  119. static Dimension    ChildMinSize                (Widget,Widget);
  120.  
  121. static Boolean        ChildIsAttachment            (Widget,Widget);
  122.  
  123. /*----------------------------------------------------------------------*/
  124. /*                                                                        */
  125. /* Descendant functions                                                    */
  126. /*                                                                        */
  127. /*----------------------------------------------------------------------*/
  128. static Widget        DescendantFindAttachment    (Widget,Widget);
  129.  
  130. /*----------------------------------------------------------------------*/
  131. /*                                                                        */
  132. /* Attachment functions                                                    */
  133. /*                                                                        */
  134. /*----------------------------------------------------------------------*/
  135. static void        AttachmentLayout            (Widget,Widget,XfeGeometry);
  136. static void        AttachmentSetMappedAll        (Widget,Widget,Boolean);
  137. static void        AttachmentSetMappedChild    (Widget,Widget,Widget);
  138. static Widget    AttachmentGetVisibleChild    (Widget,Widget);
  139. static void        AttachmentLoadAll            (Widget,Widget,Widget *);
  140. static Boolean    AttachmentContainsXY        (Widget,int,int);
  141.  
  142. /*----------------------------------------------------------------------*/
  143. /*                                                                        */
  144. /* Sash functions                                                        */
  145. /*                                                                        */
  146. /*----------------------------------------------------------------------*/
  147. static void        SashLayout                    (Widget,Position,XRectangle *);
  148. static Boolean    SashContainsXY                (Widget,int,int);
  149. static void        SashDrawDragging            (Widget,XRectangle *);
  150. static void        SashDrawShadow                (Widget,XRectangle *,Boolean);
  151. static void        SashDragStart                (Widget,int,int,Widget);
  152. static void        SashDragEnd                    (Widget,int,int,Widget);
  153. static void        SashDragMotion                (Widget,int,int,Widget);
  154. static Position    SashMinPosition                (Widget);
  155. static Position    SashMaxPosition                (Widget);
  156. static void        SashVerifyPosition            (Widget,Dimension,Dimension);
  157.  
  158. static Position    SashMinPositionVertical        (Widget);
  159. static Position    SashMaxPositionHorizontal    (Widget);
  160.  
  161. /*----------------------------------------------------------------------*/
  162. /*                                                                        */
  163. /* Misc XfePane functions                                                */
  164. /*                                                                        */
  165. /*----------------------------------------------------------------------*/
  166. static Boolean        HasChildOneAttachment        (Widget);
  167. static Boolean        HasChildTwoAttachment        (Widget);
  168.  
  169. /*----------------------------------------------------------------------*/
  170. /*                                                                        */
  171. /* IsAttachment test function.                                            */
  172. /*                                                                        */
  173. /*----------------------------------------------------------------------*/
  174. static Boolean    FindTestIsAttachment    (Widget,XtPointer);
  175.  
  176. /*----------------------------------------------------------------------*/
  177. /*                                                                        */
  178. /* Constraint resource callprocs                                        */
  179. /*                                                                        */
  180. /*----------------------------------------------------------------------*/
  181. static void        DefaultPaneChildType            (Widget,int,XrmValue *);
  182. static void        DefaultPaneChildAttachment        (Widget,int,XrmValue *);
  183.  
  184. /*----------------------------------------------------------------------*/
  185. /*                                                                        */
  186. /* XfePane resources                                                    */
  187. /*                                                                        */
  188. /*----------------------------------------------------------------------*/
  189. static XtResource resources[] =     
  190. {                    
  191.     /* Sash resources */
  192.     {
  193.         XmNsashAlwaysVisible,
  194.         XmCSashAlwaysVisible,
  195.         XmRBoolean,
  196.         sizeof(Boolean),
  197.         XtOffsetOf(XfePaneRec , xfe_pane . sash_always_visible),
  198.         XmRImmediate, 
  199.         (XtPointer) True
  200.     },
  201.     {
  202.         XmNsashColor,
  203.         XmCSashColor,
  204.         XmRPixel,
  205.         sizeof(Pixel),
  206.         XtOffsetOf(XfePaneRec , xfe_pane . sash_color),
  207.         XmRCallProc, 
  208.         (XtPointer) _XfeCallProcCopyForeground
  209.     },
  210.     {
  211.         XmNsashOffset,
  212.         XmCOffset,
  213.         XmRHorizontalDimension,
  214.         sizeof(Dimension),
  215.         XtOffsetOf(XfePaneRec , xfe_pane . sash_offset),
  216.         XmRImmediate, 
  217.         (XtPointer) 0
  218.     },
  219.     { 
  220.         XmNsashPosition,
  221.         XmCPosition,
  222.         XmRPosition,
  223.         sizeof(Position),
  224.         XtOffsetOf(XfePaneRec , xfe_pane . sash_position),
  225.         XmRImmediate, 
  226.         (XtPointer) DEFAULT_SASH_POSITION
  227.     },
  228.     {
  229.         XmNsashShadowThickness,
  230.         XmCShadowThickness,
  231.         XmRHorizontalDimension,
  232.         sizeof(Dimension),
  233.         XtOffsetOf(XfePaneRec , xfe_pane . sash_shadow_thickness),
  234.         XmRCallProc, 
  235.         (XtPointer) _XfeCallProcCopyShadowThickness
  236.     },
  237.     {
  238.         XmNsashShadowType,
  239.         XmCShadowType,
  240.         XmRShadowType,
  241.         sizeof(unsigned char),
  242.         XtOffsetOf(XfePaneRec , xfe_pane . sash_shadow_type),
  243.         XmRImmediate, 
  244.         (XtPointer) XmSHADOW_OUT
  245.     },
  246.     {
  247.         XmNsashSpacing,
  248.         XmCSashSpacing,
  249.         XmRHorizontalDimension,
  250.         sizeof(Dimension),
  251.         XtOffsetOf(XfePaneRec , xfe_pane . sash_spacing),
  252.         XmRImmediate, 
  253.         (XtPointer) 2
  254.     },
  255.     {
  256.         XmNsashThickness,
  257.         XmCSashThickness,
  258.         XmRHorizontalDimension,
  259.         sizeof(Dimension),
  260.         XtOffsetOf(XfePaneRec , xfe_pane . sash_thickness),
  261.         XmRImmediate, 
  262.         (XtPointer) 10
  263.     },
  264.  
  265.  
  266.     /* Drag resources */
  267.     {
  268.         XmNpaneSashType,
  269.         XmCPaneSashType,
  270.         XmRPaneSashType,
  271.         sizeof(unsigned char),
  272.         XtOffsetOf(XfePaneRec , xfe_pane . pane_sash_type),
  273.         XmRImmediate, 
  274.         (XtPointer) XmPANE_SASH_DOUBLE_LINE
  275.     },
  276.     {
  277.         XmNpaneDragMode,
  278.         XmCPaneDragMode,
  279.         XmRPaneDragMode,
  280.         sizeof(unsigned char),
  281.         XtOffsetOf(XfePaneRec , xfe_pane . pane_drag_mode),
  282.         XmRImmediate, 
  283.         (XtPointer) XmPANE_DRAG_PRESERVE_ONE
  284.     },
  285.     { 
  286.         XmNdragThreshold,
  287.         XmCDragThreshold,
  288.         XmRVerticalDimension,
  289.         sizeof(Dimension),
  290.         XtOffsetOf(XfePaneRec , xfe_pane . drag_threshold),
  291.         XmRImmediate, 
  292.         (XtPointer) 1
  293.     },
  294.  
  295.     /* Child one resources */
  296.     { 
  297.         XmNchildOne,
  298.         XmCChildOne,
  299.         XmRWidget,
  300.         sizeof(Widget),
  301.         XtOffsetOf(XfePaneRec , xfe_pane . child_one),
  302.         XmRImmediate, 
  303.         (XtPointer) NULL
  304.     },
  305.     { 
  306.         XmNattachmentOneBottom,
  307.         XmCAttachmentOneBottom,
  308.         XmRWidget,
  309.         sizeof(Widget),
  310.         XtOffsetOf(XfePaneRec , xfe_pane . attachment_one_bottom),
  311.         XmRImmediate, 
  312.         (XtPointer) NULL
  313.     },
  314.     { 
  315.         XmNattachmentOneLeft,
  316.         XmCAttachmentOneLeft,
  317.         XmRWidget,
  318.         sizeof(Widget),
  319.         XtOffsetOf(XfePaneRec , xfe_pane . attachment_one_left),
  320.         XmRImmediate, 
  321.         (XtPointer) NULL
  322.     },
  323.     { 
  324.         XmNattachmentOneRight,
  325.         XmCAttachmentOneRight,
  326.         XmRWidget,
  327.         sizeof(Widget),
  328.         XtOffsetOf(XfePaneRec , xfe_pane . attachment_one_right),
  329.         XmRImmediate, 
  330.         (XtPointer) NULL
  331.     },
  332.     { 
  333.         XmNattachmentOneTop,
  334.         XmCAttachmentOneTop,
  335.         XmRWidget,
  336.         sizeof(Widget),
  337.         XtOffsetOf(XfePaneRec , xfe_pane . attachment_one_top),
  338.         XmRImmediate, 
  339.         (XtPointer) NULL
  340.     },
  341.  
  342.     /* Child two resources */
  343.     { 
  344.         XmNchildTwo,
  345.         XmCChildTwo,
  346.         XmRWidget,
  347.         sizeof(Widget),
  348.         XtOffsetOf(XfePaneRec , xfe_pane . child_two),
  349.         XmRImmediate, 
  350.         (XtPointer) NULL
  351.     },
  352.     { 
  353.         XmNattachmentTwoBottom,
  354.         XmCAttachmentTwoBottom,
  355.         XmRWidget,
  356.         sizeof(Widget),
  357.         XtOffsetOf(XfePaneRec , xfe_pane . attachment_two_bottom),
  358.         XmRImmediate, 
  359.         (XtPointer) NULL
  360.     },
  361.     { 
  362.         XmNattachmentTwoLeft,
  363.         XmCAttachmentTwoLeft,
  364.         XmRWidget,
  365.         sizeof(Widget),
  366.         XtOffsetOf(XfePaneRec , xfe_pane . attachment_two_left),
  367.         XmRImmediate, 
  368.         (XtPointer) NULL
  369.     },
  370.     { 
  371.         XmNattachmentTwoRight,
  372.         XmCAttachmentTwoRight,
  373.         XmRWidget,
  374.         sizeof(Widget),
  375.         XtOffsetOf(XfePaneRec , xfe_pane . attachment_two_right),
  376.         XmRImmediate, 
  377.         (XtPointer) NULL
  378.     },
  379.     { 
  380.         XmNattachmentTwoTop,
  381.         XmCAttachmentTwoTop,
  382.         XmRWidget,
  383.         sizeof(Widget),
  384.         XtOffsetOf(XfePaneRec , xfe_pane . attachment_two_top),
  385.         XmRImmediate, 
  386.         (XtPointer) NULL
  387.     },
  388.  
  389.     /* Force XmNallowDrag to True */
  390.     { 
  391.         XmNallowDrag,
  392.         XmCBoolean,
  393.         XmRBoolean,
  394.         sizeof(Boolean),
  395.         XtOffsetOf(XfePaneRec , xfe_oriented . allow_drag),
  396.         XmRImmediate, 
  397.         (XtPointer) True
  398.     },
  399.  
  400.     /* Force XmNusePreferredHeight and XmNusePreferredWidth to False */
  401.     {
  402.         XmNusePreferredHeight,
  403.         XmCUsePreferredHeight,
  404.         XmRBoolean,
  405.         sizeof(Boolean),
  406.         XtOffsetOf(XfePaneRec , xfe_manager . use_preferred_height),
  407.         XmRImmediate, 
  408.         (XtPointer) False
  409.     },
  410.     {
  411.         XmNusePreferredWidth,
  412.         XmCUsePreferredWidth,
  413.         XmRBoolean,
  414.         sizeof(Boolean),
  415.         XtOffsetOf(XfePaneRec , xfe_manager . use_preferred_width),
  416.         XmRImmediate, 
  417.         (XtPointer) False
  418.     },
  419. };   
  420.  
  421. /*----------------------------------------------------------------------*/
  422. /*                                                                        */
  423. /* XfePane synthetic resources                                            */
  424. /*                                                                        */
  425. /*----------------------------------------------------------------------*/
  426. static XmSyntheticResource synthetic_resources[] =
  427. {
  428.     { 
  429.         XmNsashOffset,
  430.         sizeof(Dimension),
  431.         XtOffsetOf(XfePaneRec , xfe_pane . sash_offset),
  432.         _XmFromHorizontalPixels,
  433.         _XmToHorizontalPixels 
  434.     },
  435.     { 
  436.         XmNsashShadowThickness,
  437.         sizeof(Dimension),
  438.         XtOffsetOf(XfePaneRec , xfe_pane . sash_shadow_thickness),
  439.         _XmFromHorizontalPixels,
  440.         _XmToHorizontalPixels 
  441.     },
  442.     { 
  443.         XmNsashThickness,
  444.         sizeof(Dimension),
  445.         XtOffsetOf(XfePaneRec , xfe_pane . sash_thickness),
  446.         _XmFromHorizontalPixels,
  447.         _XmToHorizontalPixels 
  448.     },
  449.     { 
  450.         XmNsashSpacing,
  451.         sizeof(Dimension),
  452.         XtOffsetOf(XfePaneRec , xfe_pane . sash_spacing),
  453.         _XmFromHorizontalPixels,
  454.         _XmToHorizontalPixels 
  455.     },
  456. };
  457.  
  458. /*----------------------------------------------------------------------*/
  459. /*                                                                        */
  460. /* XfePane constraint resources                                            */
  461. /*                                                                        */
  462. /*----------------------------------------------------------------------*/
  463. static XtResource constraint_resources[] = 
  464. {
  465.     { 
  466.         XmNpaneMaximum,
  467.         XmCPaneMaximum,
  468.         XmRDimension,
  469.         sizeof(Dimension),
  470.         XtOffsetOf(XfePaneConstraintRec , xfe_pane . pane_maximum),
  471.         XmRImmediate,
  472.         (XtPointer) 65535
  473.     },
  474.     { 
  475.         XmNpaneMinimum,
  476.         XmCPaneMinimum,
  477.         XmRDimension,
  478.         sizeof(Dimension),
  479.         XtOffsetOf(XfePaneConstraintRec , xfe_pane . pane_minimum),
  480.         XmRImmediate,
  481.         (XtPointer) 40
  482.     },
  483.     { 
  484.         XmNpaneChildType,
  485.         XmCPaneChildType,
  486.         XmRPaneChildType,
  487.         sizeof(unsigned char),
  488.         XtOffsetOf(XfePaneConstraintRec , xfe_pane . pane_child_type),
  489.         XmRCallProc,
  490.         (XtPointer) DefaultPaneChildType
  491.     },
  492.     { 
  493.         XmNpaneChildAttachment,
  494.         XmCPaneChildAttachment,
  495.         XmRPaneChildAttachment,
  496.         sizeof(unsigned char),
  497.         XtOffsetOf(XfePaneConstraintRec , xfe_pane . pane_child_attachment),
  498.         XmRCallProc,
  499.         (XtPointer) DefaultPaneChildAttachment
  500.     },
  501.     { 
  502.         XmNalwaysVisible,
  503.         XmCAlwaysVisible,
  504.         XmRBoolean,
  505.         sizeof(Boolean),
  506.         XtOffsetOf(XfePaneConstraintRec , xfe_pane . always_visible),
  507.         XmRImmediate,
  508.         (XtPointer) False
  509.     },
  510.     { 
  511.         XmNallowExpand,
  512.         XmCBoolean,
  513.         XmRBoolean,
  514.         sizeof(Boolean),
  515.         XtOffsetOf(XfePaneConstraintRec , xfe_pane . allow_expand),
  516.         XmRImmediate,
  517.         (XtPointer) True
  518.     },
  519.     { 
  520.         XmNallowResize,
  521.         XmCBoolean,
  522.         XmRBoolean,
  523.         sizeof(Boolean),
  524.         XtOffsetOf(XfePaneConstraintRec , xfe_pane . allow_resize),
  525.         XmRImmediate,
  526.         (XtPointer) True
  527.     },
  528. };   
  529.  
  530. /*----------------------------------------------------------------------*/
  531. /*                                                                        */
  532. /* XfePane constraint synthetic resources                                */
  533. /*                                                                        */
  534. /*----------------------------------------------------------------------*/
  535. static XmSyntheticResource constraint_synthetic_resources[] =
  536. {
  537.     { 
  538.         XmNpaneMaximum,
  539.         sizeof(Dimension),
  540.         XtOffsetOf(XfePaneConstraintRec , xfe_pane . pane_maximum),
  541.         _XmFromHorizontalPixels,
  542.         _XmToHorizontalPixels 
  543.     },
  544.     { 
  545.         XmNpaneMinimum,
  546.         sizeof(Dimension),
  547.         XtOffsetOf(XfePaneConstraintRec , xfe_pane . pane_minimum),
  548.         _XmFromHorizontalPixels,
  549.         _XmToHorizontalPixels 
  550.     },
  551. };
  552.  
  553. /*----------------------------------------------------------------------*/
  554. /*                                                                        */
  555. /* Widget Class Record Initialization                                   */
  556. /*                                                                        */
  557. /*----------------------------------------------------------------------*/
  558. _XFE_WIDGET_CLASS_RECORD(pane,Pane) =
  559. {
  560.     {
  561.         (WidgetClass) &xfeOrientedClassRec,        /* superclass            */
  562.         "XfePane",                                /* class_name            */
  563.         sizeof(XfePaneRec),                        /* widget_size            */
  564.         NULL,                                    /* class_initialize        */
  565.         NULL,                                    /* class_part_initialize*/
  566.         FALSE,                                    /* class_inited            */
  567.         Initialize,                                /* initialize            */
  568.         NULL,                                    /* initialize_hook        */
  569.         XtInheritRealize,                        /* realize                */
  570.         NULL,                                    /* actions                */
  571.         0,                                        /* num_actions            */
  572.         resources,                              /* resources            */
  573.         XtNumber(resources),                    /* num_resources        */
  574.         NULLQUARK,                              /* xrm_class            */
  575.         TRUE,                                   /* compress_motion        */
  576.         XtExposeCompressMaximal,                /* compress_exposure    */
  577.         TRUE,                                   /* compress_enterleave    */
  578.         FALSE,                                  /* visible_interest        */
  579.         Destroy,                                /* destroy                */
  580.         XtInheritResize,                        /* resize                */
  581.         XtInheritExpose,                        /* expose                */
  582.         SetValues,                              /* set_values            */
  583.         NULL,                                   /* set_values_hook        */
  584.         XtInheritSetValuesAlmost,                /* set_values_almost    */
  585.         NULL,                                    /* get_values_hook        */
  586.         NULL,                                   /* access_focus            */
  587.         XtVersion,                              /* version                */
  588.         NULL,                                   /* callback_private        */
  589.         XtInheritTranslations,                    /* tm_table                */
  590.         XtInheritQueryGeometry,                    /* query_geometry        */
  591.         XtInheritDisplayAccelerator,            /* display accelerator    */
  592.         NULL,                                   /* extension            */
  593.     },
  594.     
  595.     /* Composite Part */
  596.     {
  597.         XtInheritGeometryManager,                /* geometry_manager        */
  598.         XtInheritChangeManaged,                    /* change_managed        */
  599.         XtInheritInsertChild,                    /* insert_child            */
  600.         XtInheritDeleteChild,                    /* delete_child            */
  601.         NULL                                    /* extension            */
  602.     },
  603.  
  604.     /* Constraint Part */
  605.     {
  606.         constraint_resources,                    /* constraint res        */
  607.         XtNumber(constraint_resources),            /* num constraint res    */
  608.         sizeof(XfePaneConstraintRec),            /* constraint size        */
  609.         ConstraintInitialize,                    /* init proc            */
  610.         NULL,                                    /* destroy proc            */
  611.         ConstraintSetValues,                    /* set values proc        */
  612.         NULL,                                   /* extension            */
  613.     },
  614.  
  615.     /* XmManager Part */
  616.     {
  617.         XtInheritTranslations,                    /* tm_table                */
  618.         synthetic_resources,                    /* syn resources        */
  619.         XtNumber(synthetic_resources),            /* num syn_resources    */
  620.         constraint_synthetic_resources,            /* syn_cont_resources      */
  621.         XtNumber(constraint_synthetic_resources),/* num_syn_cont_resource*/
  622.         XmInheritParentProcess,                 /* parent_process        */
  623.         NULL,                                   /* extension            */
  624.     },
  625.     
  626.     /* XfeManager Part     */
  627.     {
  628.         XfeInheritBitGravity,                    /* bit_gravity            */
  629.         PreferredGeometry,                        /* preferred_geometry    */
  630.         MinimumGeometry,                        /* minimum_geometry        */
  631.         XfeInheritUpdateRect,                    /* update_rect            */
  632.         AcceptChild,                            /* accept_child            */
  633.         InsertChild,                            /* insert_child            */
  634.         DeleteChild,                            /* delete_child            */
  635.         NULL,                                    /* change_managed        */
  636.         PrepareComponents,                        /* prepare_components    */
  637.         LayoutComponents,                        /* layout_components    */
  638.         LayoutChildren,                            /* layout_children        */
  639.         NULL,                                    /* draw_background        */
  640.         XfeInheritDrawShadow,                    /* draw_shadow            */
  641.         DrawComponents,                            /* draw_components        */
  642.         NULL,                                    /* extension            */
  643.     },
  644.  
  645.     /* XfeOriented Part */
  646.     {
  647.         EnterProc,                                /* enter                */
  648.         XfeInheritLeave,                        /* leave                */
  649.         MotionProc,                                /* motion                */
  650.         DragStart,                                /* drag_start            */
  651.         DragEnd,                                /* drag_end                */
  652.         DragMotion,                                /* drag_motion            */
  653.         XfeInheritDescendantEnter,                /* des_enter            */
  654.         XfeInheritDescendantLeave,                /* des_leave            */
  655.         XfeInheritDescendantMotion,                /* des_motion            */
  656.         DescendantDragStart,                    /* des_drag_start        */
  657.         DescendantDragEnd,                        /* des_drag_end            */
  658.         DescendantDragMotion,                    /* des_drag_motion        */
  659.         NULL,                                    /* extension              */
  660.     },
  661.     
  662.     /* XfePane Part */
  663.     {
  664.         NULL,                                    /* extension            */
  665.     },
  666. };
  667.  
  668. /*----------------------------------------------------------------------*/
  669. /*                                                                        */
  670. /* xfePaneWidgetClass declaration.                                        */
  671. /*                                                                        */
  672. /*----------------------------------------------------------------------*/
  673. _XFE_WIDGET_CLASS(pane,Pane);
  674.  
  675. /*----------------------------------------------------------------------*/
  676. /*                                                                        */
  677. /* Constraint resource callprocs                                        */
  678. /*                                                                        */
  679. /*----------------------------------------------------------------------*/
  680. static void
  681. DefaultPaneChildType(Widget child,int offset,XrmValue * value)
  682. {
  683.     Widget                    w = _XfeParent(child);
  684.     XfePanePart *            sp = _XfePanePart(w);
  685.     static unsigned char    pane_child_type;
  686.  
  687.     /* Initialize the child type to none */
  688.     pane_child_type = XmPANE_CHILD_NONE;
  689.  
  690.     /* Child one is alive */
  691.     if (_XfeIsAlive(sp->child_one))
  692.     {
  693.         /* Look for child two if not alive */
  694.         if (!_XfeIsAlive(sp->child_two))
  695.         {
  696.             pane_child_type = XmPANE_CHILD_WORK_AREA_TWO;
  697.         }
  698.         /* Look for child one attachment if not full */
  699.         else if (!ChildOneAttachmentsAreFull(w))
  700.         {
  701.             pane_child_type = XmPANE_CHILD_ATTACHMENT_ONE;
  702.         }
  703.         else if (!ChildTwoAttachmentsAreFull(w))
  704.         {
  705.             pane_child_type = XmPANE_CHILD_ATTACHMENT_TWO;
  706.         }
  707.     }
  708.     /* Child two is alive */
  709.     else if (_XfeIsAlive(sp->child_two))
  710.     {
  711.         /* Child one must not be alive at this point */
  712.         pane_child_type = XmPANE_CHILD_WORK_AREA_ONE;
  713.     }
  714.     /* Neither child one or two are alive */
  715.     else
  716.     {
  717.         pane_child_type = XmPANE_CHILD_WORK_AREA_ONE;
  718.     }
  719.  
  720.     value->addr = (XPointer) &pane_child_type;
  721.     value->size = sizeof(pane_child_type);
  722. }
  723. /*----------------------------------------------------------------------*/
  724. static void
  725. DefaultPaneChildAttachment(Widget child,int offset,XrmValue * value)
  726. {
  727.     Widget                    w = _XfeParent(child);
  728.     XfePanePart *            sp = _XfePanePart(w);
  729.     XfePaneConstraintPart *    cp = _XfePaneConstraintPart(child);
  730.     static unsigned char    pane_child_attachment;
  731.  
  732.     /* Initialize the child attachment to none */
  733.     pane_child_attachment = XmPANE_CHILD_ATTACH_NONE;
  734.  
  735.     if (cp->pane_child_type == XmPANE_CHILD_ATTACHMENT_ONE)
  736.     {
  737.         if (!_XfeIsAlive(sp->attachment_one_top))
  738.         {
  739.             pane_child_attachment = XmPANE_CHILD_ATTACH_TOP;
  740.         }
  741.         else if (!_XfeIsAlive(sp->attachment_one_bottom))
  742.         {
  743.             pane_child_attachment = XmPANE_CHILD_ATTACH_BOTTOM;
  744.         }
  745.         else if (!_XfeIsAlive(sp->attachment_one_left))
  746.         {
  747.             pane_child_attachment = XmPANE_CHILD_ATTACH_LEFT;
  748.         }
  749.         else if (!_XfeIsAlive(sp->attachment_one_right))
  750.         {
  751.             pane_child_attachment = XmPANE_CHILD_ATTACH_RIGHT;
  752.         }
  753.     }
  754.     else if (cp->pane_child_type == XmPANE_CHILD_ATTACHMENT_TWO)
  755.     {
  756.         if (!_XfeIsAlive(sp->attachment_two_top))
  757.         {
  758.             pane_child_attachment = XmPANE_CHILD_ATTACH_TOP;
  759.         }
  760.         else if (!_XfeIsAlive(sp->attachment_two_bottom))
  761.         {
  762.             pane_child_attachment = XmPANE_CHILD_ATTACH_BOTTOM;
  763.         }
  764.         else if (!_XfeIsAlive(sp->attachment_two_left))
  765.         {
  766.             pane_child_attachment = XmPANE_CHILD_ATTACH_LEFT;
  767.         }
  768.         else if (!_XfeIsAlive(sp->attachment_two_right))
  769.         {
  770.             pane_child_attachment = XmPANE_CHILD_ATTACH_RIGHT;
  771.         }
  772.     }
  773.  
  774.     value->addr = (XPointer) &pane_child_attachment;
  775.     value->size = sizeof(pane_child_attachment);
  776. }
  777. /*----------------------------------------------------------------------*/
  778.  
  779.  
  780. /*----------------------------------------------------------------------*/
  781. /*                                                                        */
  782. /* Core Class methods                                                    */
  783. /*                                                                        */
  784. /*----------------------------------------------------------------------*/
  785. static void
  786. Initialize(Widget rw,Widget nw,ArgList av,Cardinal * ac)
  787. {
  788.     XfePanePart *        sp = _XfePanePart(nw);
  789.  
  790.     /* Make sure rep types are ok */
  791.      XfeRepTypeCheck(nw,XmRShadowType,&sp->sash_shadow_type,XmSHADOW_OUT);
  792.  
  793.      XfeRepTypeCheck(nw,XmRPaneSashType,&sp->pane_sash_type,
  794.                     XmPANE_SASH_DOUBLE_LINE);
  795.  
  796.      XfeRepTypeCheck(nw,XmRPaneDragMode,&sp->pane_drag_mode,
  797.                     XmPANE_DRAG_PRESERVE_ONE);
  798.  
  799.     /* Allocate sash gc */
  800.     sp->sash_GC = XfeAllocateSelectionGc(nw,1,sp->sash_color,
  801.                                          _XfeBackgroundPixel(nw));
  802.  
  803.     /* Initialize private members */
  804.     sp->old_width            = _XfeWidth(nw);
  805.     sp->old_height            = _XfeHeight(nw);
  806.     sp->old_sash_position    = sp->sash_position;
  807.     
  808.     /* Finish of initialization */
  809.     _XfeManagerChainInitialize(rw,nw,xfePaneWidgetClass);
  810. }
  811. /*----------------------------------------------------------------------*/
  812. static void
  813. Destroy(Widget w)
  814. {
  815.     XfePanePart *        sp = _XfePanePart(w);
  816.  
  817.     XtReleaseGC(w,sp->sash_GC);
  818. }
  819. /*----------------------------------------------------------------------*/
  820. static Boolean
  821. SetValues(Widget ow,Widget rw,Widget nw,ArgList av,Cardinal * ac)
  822. {
  823.     XfePanePart *        np = _XfePanePart(nw);
  824.     XfePanePart *        op = _XfePanePart(ow);
  825.     Boolean                update_pane_gc = False;
  826.  
  827.     /* sash_shadow_type */
  828.     if (np->sash_shadow_type != op->sash_shadow_type)
  829.     {
  830.         _XfemConfigFlags(nw) |= XfeConfigExpose;
  831.  
  832.         /* Make sure the new sash_shadow_type is ok */
  833.         XfeRepTypeCheck(nw,XmRShadowType,&np->sash_shadow_type,XmSHADOW_OUT);
  834.     }
  835.  
  836.     /* pane_sash_type */
  837.     if (np->pane_sash_type != op->pane_sash_type)
  838.     {
  839.         _XfemConfigFlags(nw) |= XfeConfigExpose;
  840.  
  841.         /* Make sure the new pane_sash_type is ok */
  842.         XfeRepTypeCheck(nw,XmRPaneSashType,&np->pane_sash_type,
  843.                         XmPANE_SASH_DOUBLE_LINE);
  844.     }
  845.  
  846.     /* pane_drag_mode */
  847.     if (np->pane_drag_mode != op->pane_drag_mode)
  848.     {
  849.         _XfemConfigFlags(nw) |= XfeConfigExpose;
  850.  
  851.         /* Make sure the new pane_drag_mode is ok */
  852.         XfeRepTypeCheck(nw,XmRPaneDragMode,&np->pane_drag_mode,
  853.                         XmPANE_DRAG_PRESERVE_ONE);
  854.     }
  855.  
  856.     /* sash_shadow_thickness */
  857.     if (np->sash_shadow_thickness != op->sash_shadow_thickness)
  858.     {
  859.         _XfemConfigFlags(nw) |= XfeConfigLED;
  860.     }
  861.  
  862.     /* sash_offset, sash_spacing, sash_thickness, sash_position */
  863.     if ( (np->sash_offset != op->sash_offset) ||
  864.          (np->sash_spacing != op->sash_spacing) ||
  865.          (np->sash_thickness != op->sash_thickness) )
  866.     {
  867.         _XfemConfigFlags(nw) |= XfeConfigLED;
  868.     }
  869.  
  870.     /* sash_position */
  871.     if (np->sash_position != op->sash_position)
  872.     {
  873.         np->old_sash_position = op->sash_position;
  874.  
  875.         _XfemConfigFlags(nw) |= XfeConfigLED;
  876.     }
  877.     
  878.     /* sash_color */
  879.     if (np->sash_color != op->sash_color)
  880.     {
  881.         _XfemConfigFlags(nw) |= XfeConfigLE;
  882.  
  883.         update_pane_gc = True;
  884.     }
  885.  
  886.     /* Update the pane gc if needed */
  887.     if (update_pane_gc)
  888.     {
  889.         XtReleaseGC(nw,np->sash_GC);
  890.  
  891.         np->sash_GC = XfeAllocateSelectionGc(nw,1,np->sash_color,
  892.                                              _XfeBackgroundPixel(nw));
  893.     }
  894.  
  895.     return _XfeManagerChainSetValues(ow,rw,nw,xfePaneWidgetClass);
  896. }
  897. /*----------------------------------------------------------------------*/
  898.  
  899. /*----------------------------------------------------------------------*/
  900. /*                                                                        */
  901. /* Constraint class methods                                                */
  902. /*                                                                        */
  903. /*----------------------------------------------------------------------*/
  904. static void
  905. ConstraintInitialize(Widget rc,Widget nc,ArgList av,Cardinal * ac)
  906. {
  907. /*      Widget                    w = _XfeParent(nc); */
  908. /*     XfePanePart *            sp = _XfePanePart(w); */
  909.     XfePaneConstraintPart *    cp = _XfePaneConstraintPart(nc);
  910.  
  911.     /* Make sure the pane child type is ok */
  912.     XfeRepTypeCheck(nc,XmRPaneChildType,&cp->pane_child_type,
  913.                     XmPANE_CHILD_WORK_AREA_ONE);
  914.  
  915.     /* Finish constraint initialization */
  916.     _XfeConstraintChainInitialize(rc,nc,xfePaneWidgetClass);
  917. }
  918. /*----------------------------------------------------------------------*/
  919. static Boolean
  920. ConstraintSetValues(Widget oc,Widget rc,Widget nc,ArgList av,Cardinal * ac)
  921. {
  922.     Widget                    w = XtParent(nc);
  923. /*     XfePanePart *            sp = _XfePanePart(w); */
  924.      XfePaneConstraintPart *    ncp = _XfePaneConstraintPart(nc);
  925.      XfePaneConstraintPart *    ocp = _XfePaneConstraintPart(oc);
  926.  
  927.     /* pane_child_type */
  928.     if (ncp->pane_child_type != ocp->pane_child_type)
  929.     {
  930.         ncp->pane_child_type = ocp->pane_child_type;
  931.  
  932.         _XfeWarning(nc,MESSAGE2);
  933.     }
  934.  
  935.     /* pane_minimum */
  936.     if (ncp->pane_minimum != ocp->pane_minimum)
  937.     {
  938.         _XfemConfigFlags(w) |= XfeConfigLayout;
  939.     }
  940.  
  941.     /* pane_maximum */
  942.     if (ncp->pane_maximum != ocp->pane_maximum)
  943.     {
  944.         _XfemConfigFlags(w) |= XfeConfigLayout;
  945.     }
  946.  
  947.     /* Finish constraint set values */
  948.     return _XfeConstraintChainSetValues(oc,rc,nc,xfePaneWidgetClass);
  949. }
  950. /*----------------------------------------------------------------------*/
  951.  
  952. /*----------------------------------------------------------------------*/
  953. /*                                                                        */
  954. /* XfeManager class methods                                                */
  955. /*                                                                        */
  956. /*----------------------------------------------------------------------*/
  957. static void
  958. PreferredGeometry(Widget w,Dimension * width,Dimension * height)
  959. {
  960.     XfePanePart *        sp = _XfePanePart(w);
  961.  
  962.      Dimension            one_total_width = 0;
  963.      Dimension            one_total_height = 0;
  964.  
  965.      Dimension            two_total_width = 0;
  966.      Dimension            two_total_height = 0;
  967.  
  968.     *width  = _XfemOffsetLeft(w) + _XfemOffsetRight(w);
  969.     *height = _XfemOffsetTop(w) + _XfemOffsetBottom(w);
  970.  
  971.     if (_XfeChildIsShown(sp->child_one))
  972.     {
  973.         one_total_width =+ _XfeWidth(sp->child_one);
  974.         one_total_height =+ _XfeHeight(sp->child_one);
  975.     }
  976.  
  977.     if (_XfeChildIsShown(sp->child_two))
  978.     {
  979.         two_total_width =+ _XfeWidth(sp->child_two);
  980.         two_total_height =+ _XfeHeight(sp->child_two);
  981.     }
  982.  
  983.     /* Vertical */
  984.     if (_XfeOrientedOrientation(w) == XmVERTICAL)
  985.     {
  986.          *height += (one_total_height + sp->sash_thickness + two_total_height);
  987.          *width += XfeMax(one_total_width,two_total_width);
  988.     }
  989.     /* Horizontal */
  990.     else
  991.     {
  992.          *width += (one_total_width + sp->sash_thickness + two_total_width);
  993.          *height += XfeMax(one_total_height,two_total_height);
  994.     }
  995. }
  996. /*----------------------------------------------------------------------*/
  997. static void
  998. MinimumGeometry(Widget w,Dimension * width,Dimension * height)
  999. {
  1000.     /* XfePanePart *        sp = _XfePanePart(w); */
  1001.  
  1002.     *width  = _XfemOffsetLeft(w) + _XfemOffsetRight(w);
  1003.     *height = _XfemOffsetTop(w) + _XfemOffsetBottom(w);
  1004. }
  1005. /*----------------------------------------------------------------------*/
  1006. static Boolean
  1007. AcceptChild(Widget child)
  1008. {
  1009.     Widget                    w = _XfeParent(child);
  1010.     XfePanePart *            sp = _XfePanePart(w);
  1011.     XfePaneConstraintPart *    cp = _XfePaneConstraintPart(child);
  1012.  
  1013. #if 0
  1014.     printf("AcceptChild(%-10s , %-25s , %s)\n",
  1015.            XtName(child),
  1016.            XfeDebugRepTypeValueName(XmRPaneChildType,cp->pane_child_type),
  1017.            XfeDebugRepTypeValueName(XmRPaneChildAttachment,cp->pane_child_attachment));
  1018. #endif
  1019.  
  1020.     /* Child one */
  1021.     if ((cp->pane_child_type == XmPANE_CHILD_WORK_AREA_ONE) && 
  1022.         !_XfeIsAlive(sp->child_one))
  1023.     {
  1024.         return True;
  1025.     }
  1026.  
  1027.     /* Child two */
  1028.     if ((cp->pane_child_type == XmPANE_CHILD_WORK_AREA_TWO) && 
  1029.         !_XfeIsAlive(sp->child_two))
  1030.     {
  1031.         return True;
  1032.     }
  1033.  
  1034.     /* Attachment one */
  1035.     if ((cp->pane_child_type == XmPANE_CHILD_ATTACHMENT_ONE) && 
  1036.         !ChildOneAttachmentsAreFull(w))
  1037.     {
  1038.         return True;
  1039.     }
  1040.  
  1041.     /* Attachment two */
  1042.     if ((cp->pane_child_type == XmPANE_CHILD_ATTACHMENT_TWO) && 
  1043.         !ChildTwoAttachmentsAreFull(w))
  1044.     {
  1045.         return True;
  1046.     }
  1047.  
  1048.     return False;
  1049. }
  1050. /*----------------------------------------------------------------------*/
  1051. static Boolean
  1052. InsertChild(Widget child)
  1053. {
  1054.     Widget                    w = _XfeParent(child);
  1055.     XfePanePart *            sp = _XfePanePart(w);
  1056.     XfePaneConstraintPart *    cp = _XfePaneConstraintPart(child);
  1057.  
  1058. #if 0
  1059.     printf("InsertChild(%-10s , %-25s , %s)\n",
  1060.            XtName(child),
  1061.            XfeDebugRepTypeValueName(XmRPaneChildType,cp->pane_child_type),
  1062.            XfeDebugRepTypeValueName(XmRPaneChildAttachment,cp->pane_child_attachment));
  1063. #endif
  1064.  
  1065.     /* Child one */
  1066.     if (cp->pane_child_type == XmPANE_CHILD_WORK_AREA_ONE)
  1067.     {
  1068.         sp->child_one = child;
  1069.     }
  1070.     /* Child two */
  1071.     else if (cp->pane_child_type == XmPANE_CHILD_WORK_AREA_TWO)
  1072.     {
  1073.         sp->child_two = child;
  1074.  
  1075.         if (sp->pane_drag_mode == XmPANE_DRAG_PRESERVE_TWO)
  1076.         {
  1077.             /* Vertical */
  1078.             if (_XfeOrientedOrientation(w) == XmVERTICAL)
  1079.             {
  1080.                 
  1081.             }
  1082.             /* Horizontal */
  1083.             else
  1084.             {
  1085.             }
  1086.         }
  1087.     }
  1088.     /* Child one attachment */
  1089.     else if (cp->pane_child_type == XmPANE_CHILD_ATTACHMENT_ONE)
  1090.     {
  1091.         if (cp->pane_child_attachment == XmPANE_CHILD_ATTACH_BOTTOM)
  1092.         {
  1093.             sp->attachment_one_bottom = child;
  1094.         }
  1095.         else if (cp->pane_child_attachment == XmPANE_CHILD_ATTACH_TOP)
  1096.         {
  1097.             sp->attachment_one_top = child;
  1098.         }
  1099.         else if (cp->pane_child_attachment == XmPANE_CHILD_ATTACH_LEFT)
  1100.         {
  1101.             sp->attachment_one_left = child;
  1102.         }
  1103.         else if (cp->pane_child_attachment == XmPANE_CHILD_ATTACH_RIGHT)
  1104.         {
  1105.             sp->attachment_one_right = child;
  1106.         }
  1107.         else
  1108.         {
  1109.             assert( 0 );
  1110.         }
  1111.     }
  1112.     /* Child two attachment */
  1113.     else if (cp->pane_child_type == XmPANE_CHILD_ATTACHMENT_TWO)
  1114.     {
  1115.         if (cp->pane_child_attachment == XmPANE_CHILD_ATTACH_BOTTOM)
  1116.         {
  1117.             sp->attachment_two_bottom = child;
  1118.         }
  1119.         else if (cp->pane_child_attachment == XmPANE_CHILD_ATTACH_TOP)
  1120.         {
  1121.             sp->attachment_two_top = child;
  1122.         }
  1123.         else if (cp->pane_child_attachment == XmPANE_CHILD_ATTACH_LEFT)
  1124.         {
  1125.             sp->attachment_two_left = child;
  1126.         }
  1127.         else if (cp->pane_child_attachment == XmPANE_CHILD_ATTACH_RIGHT)
  1128.         {
  1129.             sp->attachment_two_right = child;
  1130.         }
  1131.         else
  1132.         {
  1133.             assert( 0 );
  1134.         }
  1135.     }
  1136.  
  1137.     return True;
  1138. }
  1139. /*----------------------------------------------------------------------*/
  1140. static Boolean
  1141. DeleteChild(Widget child)
  1142. {
  1143.     Widget                w = XtParent(child);
  1144.     XfePanePart *        sp = _XfePanePart(w);
  1145.  
  1146.     /* Child one */
  1147.     if (sp->child_one == child)
  1148.     {
  1149.         sp->child_one = NULL;
  1150.     }
  1151.     /* Child two */
  1152.     else if (sp->child_two == child)
  1153.     {
  1154.         sp->child_two = NULL;
  1155.     }
  1156.     /* Child one bottom attachment */
  1157.     else if (sp->attachment_one_bottom == child)
  1158.     {
  1159.         sp->attachment_one_bottom = NULL;
  1160.     }
  1161.     /* Child one top attachment */
  1162.     else if (sp->attachment_two_top == child)
  1163.     {
  1164.         sp->attachment_one_top = NULL;
  1165.     }
  1166.     /* Child one left attachment */
  1167.     else if (sp->attachment_one_left == child)
  1168.     {
  1169.         sp->attachment_one_left = NULL;
  1170.     }
  1171.     /* Child one right attachment */
  1172.     else if (sp->attachment_one_right == child)
  1173.     {
  1174.         sp->attachment_one_right = NULL;
  1175.     }
  1176.     /* Child two bottom attachment */
  1177.     else if (sp->attachment_two_bottom == child)
  1178.     {
  1179.         sp->attachment_two_bottom = NULL;
  1180.     }
  1181.     /* Child two top attachment */
  1182.     else if (sp->attachment_two_top == child)
  1183.     {
  1184.         sp->attachment_two_top = NULL;
  1185.     }
  1186.     /* Child two left attachment */
  1187.     else if (sp->attachment_two_left == child)
  1188.     {
  1189.         sp->attachment_two_left = NULL;
  1190.     }
  1191.     /* Child two right attachment */
  1192.     else if (sp->attachment_two_right == child)
  1193.     {
  1194.         sp->attachment_two_right = NULL;
  1195.     }
  1196.  
  1197.     return True;
  1198. }
  1199. /*----------------------------------------------------------------------*/
  1200. static void
  1201. PrepareComponents(Widget w,int flags)
  1202. {
  1203.     if (flags & _XFE_PREPARE_LABEL_STRING)
  1204.     {
  1205.     }
  1206. }
  1207. /*----------------------------------------------------------------------*/
  1208. static void
  1209. LayoutComponents(Widget w)
  1210. {
  1211.     XfePanePart *    sp = _XfePanePart(w);
  1212.     Position        sash_position = sp->sash_position;
  1213.  
  1214.     /* This is a hack and will be fixed later using MinimumGeometry() */
  1215.     int min_width = 4;
  1216.     int min_height = 4;
  1217.  
  1218.     /* Vertical */
  1219.     if (_XfeOrientedOrientation(w) == XmVERTICAL)
  1220.     {
  1221.         /* Determine if we need to tweak the sash position */
  1222.         if ( (_XfemOldHeight(w) != _XfeHeight(w)) &&
  1223.              (_XfemOldHeight(w) > min_height) &&
  1224.              (_XfeHeight(w) > min_height) &&
  1225.              (sp->old_sash_position == sp->sash_position) )
  1226.         {
  1227.             
  1228.             if (sp->pane_drag_mode == XmPANE_DRAG_PRESERVE_ONE)
  1229.             {
  1230.             }
  1231.             else if (sp->pane_drag_mode == XmPANE_DRAG_PRESERVE_TWO)
  1232.             {
  1233.                 int diff = _XfemOldHeight(w) - _XfeHeight(w);
  1234.                 int two_height;
  1235.  
  1236. #if 0
  1237.                 printf("LayoutComponents(%s) old = %d , new = %d, diff = %d\n",
  1238.                        XtName(w),
  1239.                        _XfemOldHeight(w),
  1240.                        _XfeHeight(w),
  1241.                        diff);
  1242. #endif                
  1243.  
  1244. /*                 printf("LayoutComponents(%s) diff = %d\n", */
  1245. /*                        XtName(w),diff); */
  1246.  
  1247.                 sash_position -= diff;
  1248.  
  1249. #if 0
  1250.                 two_height = 
  1251.                     _XfemOldHeight(w) -
  1252.                     _XfemOffsetBottom(w) -
  1253.                     (sp->sash_position + sp->sash_thickness);
  1254.  
  1255.                 sash_position = 
  1256.                     _XfeHeight(w) - 
  1257.                     _XfemOffsetBottom(w) -
  1258.                     two_height;
  1259. #endif
  1260.  
  1261. #if 0                
  1262.                 printf("adjusting sash position from %d to %d\n",
  1263.                        sp->sash_position,sash_position);
  1264. #endif
  1265.  
  1266. #if 0
  1267.                 int x;
  1268.                 int new_pos;
  1269.                 int two_height;
  1270.  
  1271.                 printf("num children = %d\n",_XfemNumChildren(w));
  1272.  
  1273.                 two_height = 
  1274.                     sp->old_height -
  1275.                     _XfemOffsetBottom(w) -
  1276.                     (sp->old_sash_position + sp->sash_thickness);
  1277.  
  1278.                 sash_position = 
  1279.                     _XfeHeight(w) - 
  1280.                     _XfemOffsetBottom(w) -
  1281.                     _XfeHeight(sp->child_two);
  1282.  
  1283.                 printf("changing sash position to %d from %d\n",
  1284.                        sash_position,sp->sash_position);
  1285. #endif                       
  1286.             }
  1287.             else if (sp->pane_drag_mode == XmPANE_DRAG_PRESERVE_RATIO)
  1288.             {
  1289.             }
  1290.         }
  1291.     }
  1292.     /* Horizontal */
  1293.     else
  1294.     {
  1295.         /* Determine if we need to tweak the sash position */
  1296.         if ((sp->old_width != _XfeWidth(w)) && 
  1297.             (sp->old_width >= 2) && 
  1298.             (_XfeWidth(w) >= 2) &&
  1299.             (sp->old_sash_position == sp->sash_position))
  1300.         {
  1301.             if (sp->pane_drag_mode == XmPANE_DRAG_PRESERVE_ONE)
  1302.             {
  1303.             }
  1304.             else if (sp->pane_drag_mode == XmPANE_DRAG_PRESERVE_TWO)
  1305.             {
  1306.             }
  1307.             else if (sp->pane_drag_mode == XmPANE_DRAG_PRESERVE_RATIO)
  1308.             {
  1309.             }
  1310.         }
  1311.     }
  1312.  
  1313.     /* Layout the sash */
  1314.     SashLayout(w,sash_position,&sp->sash_rect);
  1315.  
  1316.     sp->old_sash_position = sp->sash_position;
  1317.     sp->sash_position = sash_position;
  1318. }
  1319. /*----------------------------------------------------------------------*/
  1320. static void
  1321. LayoutChildren(Widget w)
  1322. {
  1323.     XfePanePart *        sp = _XfePanePart(w);
  1324.     Boolean                one_on = False;
  1325.     Boolean                two_on = False;
  1326.  
  1327.     /* Vertical */
  1328.     if (_XfeOrientedOrientation(w) == XmVERTICAL)
  1329.     {
  1330.         /* Child one */
  1331.         if (_XfeChildIsShown(sp->child_one))
  1332.         {
  1333.             ChildOneLayoutVertical(w);
  1334.  
  1335.             one_on = True;
  1336.         }
  1337.  
  1338.         /* Child two */
  1339.         if (_XfeChildIsShown(sp->child_two))
  1340.         {
  1341.             ChildTwoLayoutVertical(w);
  1342.  
  1343.             two_on = True;
  1344.         }
  1345.     }
  1346.     /* Horizontal */
  1347.     else
  1348.     {
  1349.         /* Child one */
  1350.         if (_XfeChildIsShown(sp->child_one))
  1351.         {
  1352.             ChildOneLayoutHorizontal(w);
  1353.  
  1354.             one_on = True;
  1355.         }
  1356.         
  1357.         /* Child two */
  1358.         if (_XfeChildIsShown(sp->child_two))
  1359.         {
  1360.             ChildTwoLayoutHorizontal(w);
  1361.  
  1362.             two_on = True;
  1363.         }
  1364.     }
  1365.  
  1366.     /* Both childs on - turn on all 8 attachments if needed */
  1367.     if (one_on && two_on)
  1368.     {
  1369.         AttachmentSetMappedAll(w,sp->child_one,True);
  1370.         AttachmentSetMappedAll(w,sp->child_two,True);
  1371.     }
  1372.     /* Both childs off - turn off all 8 attachments if needed */
  1373.     else if (!one_on && !two_on)
  1374.     {
  1375.         AttachmentSetMappedAll(w,sp->child_one,False);
  1376.         AttachmentSetMappedAll(w,sp->child_two,False);
  1377.     }
  1378.     /* Only one child on */
  1379.     else
  1380.     {
  1381.         Widget        aw;
  1382.         Boolean        should_expand;
  1383.         Widget        target;
  1384.         Widget        opposite;
  1385.  
  1386.         /* Child one on */
  1387.         if (one_on)
  1388.         {
  1389.             target        = sp->child_one;
  1390.             opposite    = sp->child_two;
  1391.         }
  1392.         /* Child two on */
  1393.         else
  1394.         {
  1395.             target        = sp->child_two;
  1396.             opposite    = sp->child_one;
  1397.         }
  1398.  
  1399.         aw                = AttachmentGetVisibleChild(w,opposite);
  1400.         should_expand    = ChildShouldExpand(w,target);
  1401.  
  1402.         /* Turn on all the attachments for the target child that is on */
  1403.         AttachmentSetMappedAll(w,target,True);
  1404.         
  1405.         if (should_expand && _XfeIsAlive(aw))
  1406.         {
  1407.             /* Turn on only the visible when off attachment.  All others off */
  1408.             AttachmentSetMappedChild(w,opposite,aw);
  1409.         }
  1410.         else
  1411.         {
  1412.             /* Turn off all attachments for the opposite child */
  1413.             AttachmentSetMappedAll(w,opposite,False);
  1414.         }
  1415.         
  1416.     }
  1417.  
  1418.     /* Update old dimensions */
  1419.     sp->old_width            = _XfeWidth(w);
  1420.     sp->old_height            = _XfeHeight(w);
  1421.     sp->old_sash_position    = sp->sash_position;
  1422. }
  1423. /*----------------------------------------------------------------------*/
  1424. static void
  1425. DrawComponents(Widget w,XEvent * event,Region region,XRectangle * clip_rect)
  1426. {
  1427.     XfePanePart *    sp = _XfePanePart(w);
  1428.  
  1429.     /* Draw the sash */
  1430.     SashDrawShadow(w,&sp->sash_rect,False);
  1431. }
  1432. /*----------------------------------------------------------------------*/
  1433.  
  1434. /*----------------------------------------------------------------------*/
  1435. /*                                                                        */
  1436. /* XfeOriented class methods                                            */
  1437. /*                                                                        */
  1438. /*----------------------------------------------------------------------*/
  1439. static void
  1440. EnterProc(Widget w,Widget descendant,int x,int y)
  1441. {
  1442.     /* Turn cursor on if needed */
  1443.     if (SashContainsXY(w,x,y))
  1444.     {
  1445.         _XfeOrientedSetCursorState(w,True);
  1446.     }
  1447.     /* Otherwise turn it off */
  1448.     else
  1449.     {
  1450.         _XfeOrientedSetCursorState(w,False);
  1451.     }
  1452. }
  1453. /*----------------------------------------------------------------------*/
  1454. static void
  1455. MotionProc(Widget w,Widget descendant,int x,int y)
  1456. {
  1457.     EnterProc(w,descendant,x,y);
  1458. }
  1459. /*----------------------------------------------------------------------*/
  1460. static void
  1461. DragStart(Widget w,Widget descendant,int x,int y)
  1462. {
  1463.     /* Make sure the coords are inside the sash */
  1464.     if (!SashContainsXY(w,x,y))
  1465.     {
  1466.         return;
  1467.     }
  1468.  
  1469.     SashDragStart(w,x,y,NULL);
  1470. }
  1471. /*----------------------------------------------------------------------*/
  1472. static void
  1473. DragEnd(Widget w,Widget descendant,int x,int y)
  1474. {
  1475.     SashDragEnd(w,x,y,NULL);
  1476. }
  1477. /*----------------------------------------------------------------------*/
  1478. static void
  1479. DragMotion(Widget w,Widget descendant,int x,int y)
  1480. {
  1481.     SashDragMotion(w,x,y,NULL);
  1482. }
  1483. /*----------------------------------------------------------------------*/
  1484. static void
  1485. DescendantDragStart(Widget w,Widget descendant,int x,int y)
  1486. {
  1487.     SashDragStart(w,x,y,DescendantFindAttachment(w,descendant));
  1488. }
  1489. /*----------------------------------------------------------------------*/
  1490. static void
  1491. DescendantDragEnd(Widget w,Widget descendant,int x,int y)
  1492. {
  1493.     SashDragEnd(w,x,y,DescendantFindAttachment(w,descendant));
  1494. }
  1495. /*----------------------------------------------------------------------*/
  1496. static void
  1497. DescendantDragMotion(Widget w,Widget descendant,int x,int y)
  1498. {
  1499.     SashDragMotion(w,x,y,DescendantFindAttachment(w,descendant));
  1500. }
  1501. /*----------------------------------------------------------------------*/
  1502.  
  1503. /*----------------------------------------------------------------------*/
  1504. /*                                                                        */
  1505. /* Child functions                                                        */
  1506. /*                                                                        */
  1507. /*----------------------------------------------------------------------*/
  1508. static Boolean
  1509. ChildShouldExpand(Widget w,Widget child)
  1510. {
  1511.     XfePanePart *            sp = _XfePanePart(w);
  1512.     Boolean                    should_expand = False;
  1513.  
  1514.     if (_XfeChildIsShown(child))
  1515.     {
  1516.         if (child == sp->child_one)
  1517.         {
  1518.             should_expand = (!_XfeChildIsShown(sp->child_two) && 
  1519.                              CONSTRAINT_ALLOW_EXPAND(sp->child_one));
  1520.         }
  1521.         else
  1522.         {
  1523.             should_expand = (!_XfeChildIsShown(sp->child_one) && 
  1524.                              CONSTRAINT_ALLOW_EXPAND(sp->child_two));
  1525.         }
  1526.     }
  1527.  
  1528.     return should_expand;
  1529. }
  1530. /*----------------------------------------------------------------------*/
  1531. static void
  1532. ChildLayout(Widget                child,
  1533.             Widget                top,
  1534.             Widget                bottom,
  1535.             Widget                left,
  1536.             Widget                right,
  1537.             XfeGeometry            pg)
  1538. {
  1539.     XfePanePart *            sp = _XfePanePart(XtParent(child));
  1540.     int    x;
  1541.     int    y;
  1542.     int    width;
  1543.     int    height;
  1544.  
  1545.     assert( _XfeChildIsShown(child) );
  1546.     assert( pg != NULL );
  1547.  
  1548.     x = pg->x;
  1549.     y = pg->y;
  1550.     width = pg->width;
  1551.     height = pg->height;
  1552.     
  1553.     /* Top attachment */
  1554.     if (_XfeChildIsShown(top))
  1555.     {
  1556.         _XfeConfigureOrHideWidget(top,
  1557.                                   pg->x,
  1558.                                   pg->y,
  1559.                                   pg->width,
  1560.                                   _XfeHeight(top));
  1561.  
  1562.         y += _XfeHeight(top);
  1563.         height -= _XfeHeight(top);
  1564.     }
  1565.  
  1566.     /* Bottom attachment */
  1567.     if (_XfeChildIsShown(bottom))
  1568.     {
  1569.         _XfeConfigureOrHideWidget(bottom,
  1570.                                   pg->x,
  1571.                                   pg->y + pg->height - _XfeHeight(bottom),
  1572.                                   pg->width,
  1573.                                   _XfeHeight(bottom));
  1574.  
  1575.         height -= _XfeHeight(bottom);
  1576.     }
  1577.  
  1578.     /* Left attachment */
  1579.     if (_XfeChildIsShown(left))
  1580.     {
  1581.         _XfeConfigureOrHideWidget(left,
  1582.                                   pg->x,
  1583.                                   y,
  1584.                                   _XfeWidth(left),
  1585.                                   height);
  1586.         
  1587.         x += _XfeWidth(left);
  1588.         width -= _XfeWidth(left);
  1589.     }
  1590.  
  1591.     /* Right attachment */
  1592.     if (_XfeChildIsShown(right))
  1593.     {
  1594.         _XfeConfigureOrHideWidget(right,
  1595.                                   
  1596.                                   pg->x + 
  1597.                                   pg->width - 
  1598.                                   _XfeWidth(right),
  1599.                                   
  1600.                                   y,
  1601.                                   _XfeWidth(right),
  1602.                                   height);
  1603.         
  1604.         width -= _XfeWidth(right);
  1605.     }
  1606.  
  1607. #ifdef DEBUG_ramiro
  1608.     /* Child */
  1609.     if (child == sp->child_two)
  1610.         printf("child_two(new y pos = %d\n",y);
  1611. #endif
  1612.  
  1613.     _XfeConfigureOrHideWidget(child,x,y,width,height);
  1614. }
  1615. /*----------------------------------------------------------------------*/
  1616. static void
  1617. ChildOneLayoutVertical(Widget w)
  1618. {
  1619.     XfePanePart *        sp = _XfePanePart(w);
  1620.     XfeGeometryRec        geom;
  1621.  
  1622.     geom.x        = _XfemRectX(w);
  1623.     geom.y        = _XfemRectY(w);
  1624.     geom.width    = _XfemRectWidth(w);
  1625.  
  1626.     /* Check whether the child can resize */
  1627.     if (CONSTRAINT_ALLOW_RESIZE(sp->child_one))
  1628.     {
  1629.         /* Check whether the child should expand */
  1630.         if (ChildShouldExpand(w,sp->child_one))
  1631.         {
  1632.             /* Look for a visible attachment */
  1633.             Widget aw = AttachmentGetVisibleChild(w,sp->child_two);
  1634.             
  1635.             /* Start by asuming that we can use the full extent of the pane */
  1636.             geom.height = _XfemRectHeight(w);
  1637.             
  1638.             /* Layout a visible attachment if needed */
  1639.             if (_XfeIsAlive(aw))
  1640.             {
  1641.                 geom.height -= _XfeHeight(aw);
  1642.                 
  1643.                 AttachmentLayout(w,aw,&geom);
  1644.             }
  1645.         }
  1646.         else
  1647.         {
  1648.             geom.height = sp->sash_rect.y - _XfemRectY(w) - SASH_SPACING(sp);
  1649.         }    
  1650.     }
  1651.     else
  1652.     {
  1653.         geom.height = _XfeHeight(sp->child_one);
  1654.     }
  1655.  
  1656.     ChildLayout(sp->child_one,
  1657.                 sp->attachment_one_top,
  1658.                 sp->attachment_one_bottom,
  1659.                 sp->attachment_one_left,
  1660.                 sp->attachment_one_right,
  1661.                 &geom);
  1662. }
  1663. /*----------------------------------------------------------------------*/
  1664. static void
  1665. ChildTwoLayoutVertical(Widget w)
  1666. {
  1667.     XfePanePart *        sp = _XfePanePart(w);
  1668.     XfeGeometryRec        geom;
  1669.  
  1670.     geom.x        = _XfemRectX(w);
  1671.     geom.width    = _XfemRectWidth(w);
  1672.  
  1673.     /* Check whether the child can resize */
  1674.     if (CONSTRAINT_ALLOW_RESIZE(sp->child_two))
  1675.     {
  1676.         if (ChildShouldExpand(w,sp->child_two))
  1677.         {
  1678.             Widget aw = AttachmentGetVisibleChild(w,sp->child_one);
  1679.             
  1680.             /* Start by asuming that we can use the full extent of the pane */
  1681.             geom.y        = _XfemRectY(w);
  1682.             geom.height = _XfemRectHeight(w);
  1683.             
  1684.             /* Look for a visible attachment */
  1685.             if (_XfeIsAlive(aw))
  1686.             {
  1687.                 geom.height -= _XfeHeight(aw);
  1688.                 
  1689.                 geom.y        += _XfeHeight(aw);
  1690.                 
  1691.                 AttachmentLayout(w,aw,&geom);
  1692.             }
  1693.         }
  1694.         else
  1695.         {
  1696.             geom.y        = 
  1697.                 sp->sash_rect.y + 
  1698.                 sp->sash_rect.height + 
  1699.                 SASH_SPACING(sp);
  1700.             
  1701.             geom.height    = 
  1702.                 _XfemRectY(w) + 
  1703.                 _XfemRectHeight(w) - 
  1704.                 geom.y -
  1705.                 SASH_SPACING(sp);
  1706.         }    
  1707.     }
  1708.     else
  1709.     {
  1710.         geom.height = _XfeHeight(sp->child_two);
  1711.         geom.y        = _XfeHeight(w) - _XfemOffsetBottom(w) - geom.height;
  1712.     }
  1713.  
  1714.     ChildLayout(sp->child_two,
  1715.                 sp->attachment_two_top,
  1716.                 sp->attachment_two_bottom,
  1717.                 sp->attachment_two_left,
  1718.                 sp->attachment_two_right,
  1719.                 &geom);
  1720. }
  1721. /*----------------------------------------------------------------------*/
  1722. static void
  1723. ChildOneLayoutHorizontal(Widget w)
  1724. {
  1725.     XfePanePart *        sp = _XfePanePart(w);
  1726.     XfeGeometryRec        geom;
  1727.  
  1728.     geom.x        = _XfemRectX(w);
  1729.     geom.y        = _XfemRectY(w);
  1730.     geom.height = _XfemRectHeight(w);
  1731.  
  1732.     if (ChildShouldExpand(w,sp->child_one))
  1733.     {
  1734.         Widget aw = AttachmentGetVisibleChild(w,sp->child_two);
  1735.  
  1736.         /* Start by asuming that we can use the full extent of the pane */
  1737.         geom.width = _XfemRectWidth(w);
  1738.  
  1739.         /* Look for a visible attachment */
  1740.         if (_XfeIsAlive(aw))
  1741.         {
  1742.             geom.width -= _XfeWidth(aw);
  1743.  
  1744.             AttachmentLayout(w,aw,&geom);
  1745.         }
  1746.     }
  1747.     else
  1748.     {
  1749.         geom.width = sp->sash_rect.x - _XfemRectX(w) - SASH_SPACING(sp);
  1750.     }    
  1751.  
  1752.     ChildLayout(sp->child_one,
  1753.                 sp->attachment_one_top,
  1754.                 sp->attachment_one_bottom,
  1755.                 sp->attachment_one_left,
  1756.                 sp->attachment_one_right,
  1757.                 &geom);
  1758. }
  1759. /*----------------------------------------------------------------------*/
  1760. static void
  1761. ChildTwoLayoutHorizontal(Widget w)
  1762. {
  1763.     XfePanePart *        sp = _XfePanePart(w);
  1764.     XfeGeometryRec        geom;
  1765.  
  1766.     geom.y        = _XfemRectY(w);
  1767.     geom.height = _XfemRectHeight(w);
  1768.  
  1769.     if (ChildShouldExpand(w,sp->child_two))
  1770.     {
  1771.         Widget aw = AttachmentGetVisibleChild(w,sp->child_one);
  1772.  
  1773.         /* Start by asuming that we can use the full extent of the pane */
  1774.         geom.x        = _XfemRectX(w);
  1775.         geom.width    = _XfemRectWidth(w);
  1776.  
  1777.         /* Look for a visible attachment */
  1778.         if (_XfeIsAlive(aw))
  1779.         {
  1780.             geom.width -= _XfeWidth(aw);
  1781.  
  1782.             geom.x        += _XfeWidth(aw);
  1783.  
  1784.             AttachmentLayout(w,aw,&geom);
  1785.         }
  1786.     }
  1787.     else
  1788.     {
  1789.         geom.x        = 
  1790.             sp->sash_rect.x + 
  1791.             sp->sash_rect.width +
  1792.             SASH_SPACING(sp);
  1793.  
  1794.         geom.width    = 
  1795.             _XfemRectX(w) + 
  1796.             _XfemRectWidth(w) - 
  1797.             geom.x -
  1798.             SASH_SPACING(sp);
  1799.     }    
  1800.  
  1801.     ChildLayout(sp->child_two,
  1802.                 sp->attachment_two_top,
  1803.                 sp->attachment_two_bottom,
  1804.                 sp->attachment_two_left,
  1805.                 sp->attachment_two_right,
  1806.                 &geom);
  1807. }
  1808. /*----------------------------------------------------------------------*/
  1809. static Dimension
  1810. ChildMaxSize(Widget w,Widget child)
  1811. {
  1812.     Dimension pane_maximum = 0;
  1813.  
  1814.     if (_XfeIsAlive(child))
  1815.     {
  1816.         XfePaneConstraintPart * cp = _XfePaneConstraintPart(child);
  1817.  
  1818.         pane_maximum = cp->pane_maximum;
  1819.     }
  1820.  
  1821.     return pane_maximum;
  1822. }
  1823. /*----------------------------------------------------------------------*/
  1824. static Dimension
  1825. ChildMinSize(Widget w,Widget child)
  1826. {
  1827.     Dimension pane_minimum = 0;
  1828.  
  1829.     if (_XfeIsAlive(child))
  1830.     {
  1831.         XfePaneConstraintPart * cp = _XfePaneConstraintPart(child);
  1832.  
  1833.         pane_minimum = cp->pane_minimum;
  1834.     }
  1835.  
  1836.     return pane_minimum;
  1837. }
  1838. /*----------------------------------------------------------------------*/
  1839. static Boolean
  1840. ChildOneAttachmentsAreFull(Widget w)
  1841. {
  1842.     XfePanePart * sp = _XfePanePart(w);
  1843.     
  1844.     return (_XfeIsAlive(sp->attachment_one_bottom) &&
  1845.             _XfeIsAlive(sp->attachment_one_left) &&
  1846.             _XfeIsAlive(sp->attachment_one_right) &&
  1847.             _XfeIsAlive(sp->attachment_one_top));
  1848. }
  1849. /*----------------------------------------------------------------------*/
  1850. static Boolean
  1851. ChildTwoAttachmentsAreFull(Widget w)
  1852. {
  1853.     XfePanePart * sp = _XfePanePart(w);
  1854.     
  1855.     return (_XfeIsAlive(sp->attachment_two_bottom) &&
  1856.             _XfeIsAlive(sp->attachment_two_left) &&
  1857.             _XfeIsAlive(sp->attachment_two_right) &&
  1858.             _XfeIsAlive(sp->attachment_two_top));
  1859. }
  1860. /*----------------------------------------------------------------------*/
  1861. static Boolean
  1862. ChildIsAttachment(Widget w,Widget child)
  1863. {
  1864.     XfePanePart * sp = _XfePanePart(w);
  1865.     
  1866.     return (child == sp->attachment_one_bottom ||
  1867.             child == sp->attachment_one_top ||
  1868.             child == sp->attachment_one_left ||
  1869.             child == sp->attachment_one_right ||
  1870.             child == sp->attachment_two_bottom ||
  1871.             child == sp->attachment_two_top ||
  1872.             child == sp->attachment_two_left ||
  1873.             child == sp->attachment_two_right);
  1874. }
  1875. /*----------------------------------------------------------------------*/
  1876.  
  1877. /*----------------------------------------------------------------------*/
  1878. /*                                                                        */
  1879. /* Descendant functions                                                    */
  1880. /*                                                                        */
  1881. /*----------------------------------------------------------------------*/
  1882. static Widget
  1883. DescendantFindAttachment(Widget w,Widget descendant)
  1884. {
  1885.     Widget attachment = NULL;
  1886.  
  1887.     if (_XfeIsAlive(w) && _XfeIsAlive(descendant))
  1888.     {
  1889.         /* Try to find an attachment ancestor */
  1890.         attachment = XfeAncestorFindByFunction(descendant,
  1891.                                                FindTestIsAttachment,
  1892.                                                XfeFIND_ANY,
  1893.                                                (XtPointer) w);
  1894.     }
  1895.  
  1896.     return attachment;
  1897. }
  1898. /*----------------------------------------------------------------------*/
  1899.  
  1900. /*----------------------------------------------------------------------*/
  1901. /*                                                                        */
  1902. /* Attachment functions                                                    */
  1903. /*                                                                        */
  1904. /*----------------------------------------------------------------------*/
  1905. static void
  1906. AttachmentLayout(Widget w,Widget aw,XfeGeometry pg)
  1907. {
  1908.     XfePanePart *        sp = _XfePanePart(w);
  1909.     int                    x;
  1910.     int                    y;
  1911.     int                    width;
  1912.     int                    height;
  1913.     
  1914.     /* Vertical */
  1915.     if (_XfeOrientedOrientation(w) == XmVERTICAL)
  1916.     {
  1917.         if ((aw == sp->attachment_one_top) || 
  1918.             (aw == sp->attachment_one_bottom))
  1919.         {
  1920.             x        = pg->x;
  1921.             y        = _XfemRectY(w);
  1922.             width    = pg->width;
  1923.             height    = _XfeHeight(aw);
  1924.         }
  1925.         else if ((aw == sp->attachment_two_top) || 
  1926.                  (aw == sp->attachment_two_bottom))
  1927.         {
  1928.             x        = pg->x;
  1929.             y        = _XfemRectY(w) + _XfemRectHeight(w) - _XfeHeight(aw);
  1930.             width    = pg->width;
  1931.             height    = _XfeHeight(aw);
  1932.         }
  1933.     }
  1934.     /* Horizontal */
  1935.     else
  1936.     {
  1937.         if ((aw == sp->attachment_one_left) || 
  1938.             (aw == sp->attachment_one_right))
  1939.         {
  1940.             x        = _XfemRectY(w);
  1941.             y        = pg->y;
  1942.             width    = _XfeWidth(aw);
  1943.             height    = pg->height;
  1944.         }
  1945.         else if ((aw == sp->attachment_two_left) || 
  1946.                  (aw == sp->attachment_two_right))
  1947.         {
  1948.             x        = _XfemRectX(w) + _XfemRectWidth(w) - _XfeWidth(aw);
  1949.             y        = pg->y;
  1950.             width    = _XfeWidth(aw);
  1951.             height    = pg->height;
  1952.         }
  1953.     }
  1954.  
  1955.     /* Attachment */
  1956.     _XfeConfigureWidget(aw,x,y,width,height);
  1957. }
  1958. /*----------------------------------------------------------------------*/
  1959. static void
  1960. AttachmentSetMappedChild(Widget w,Widget child,Widget aw)
  1961. {
  1962.     Widget            al[4];
  1963.     Cardinal        i;
  1964.  
  1965.     AttachmentLoadAll(w,child,al);
  1966.  
  1967.     for(i = 0; i < 4; i++)
  1968.     {
  1969.         _XfeSetMappedWhenManaged(al[i],al[i] == aw);
  1970.     }
  1971. }
  1972. /*----------------------------------------------------------------------*/
  1973. static void
  1974. AttachmentSetMappedAll(Widget w,Widget child,Boolean state)
  1975. {
  1976.     Widget            al[4];
  1977.     Cardinal        i;
  1978.  
  1979.     AttachmentLoadAll(w,child,al);
  1980.     
  1981.     for(i = 0; i < 4; i++)
  1982.     {
  1983.         _XfeSetMappedWhenManaged(al[i],state);
  1984.     }
  1985. }
  1986. /*----------------------------------------------------------------------*/
  1987. static void
  1988. AttachmentLoadAll(Widget w,Widget child,Widget * al)
  1989. {
  1990.     XfePanePart *        sp = _XfePanePart(w);
  1991.  
  1992.     assert( child == sp->child_one || child == sp->child_two );
  1993.     assert( al != NULL );
  1994.             
  1995.     /* Child one */
  1996.     if (child == sp->child_one)
  1997.     {
  1998.         /* Vertical */
  1999.         if (_XfeOrientedOrientation(w) == XmVERTICAL)
  2000.         {
  2001.             al[0] = sp->attachment_one_top;
  2002.             al[1] = sp->attachment_one_bottom;
  2003.             al[2] = sp->attachment_one_left;
  2004.             al[3] = sp->attachment_one_right;
  2005.         }
  2006.         /* Horizontal */
  2007.         else
  2008.         {
  2009.             al[0] = sp->attachment_one_left;
  2010.             al[1] = sp->attachment_one_right;
  2011.             al[2] = sp->attachment_one_top;
  2012.             al[3] = sp->attachment_one_bottom;
  2013.         }
  2014.     }
  2015.     /* Child two */
  2016.     else if (child == sp->child_two)
  2017.     {
  2018.         /* Vertical */
  2019.         if (_XfeOrientedOrientation(w) == XmVERTICAL)
  2020.         {
  2021.             al[0] = sp->attachment_two_top;
  2022.             al[1] = sp->attachment_two_bottom;
  2023.             al[2] = sp->attachment_two_left;
  2024.             al[3] = sp->attachment_two_right;
  2025.         }
  2026.         /* Horizontal */
  2027.         else
  2028.         {
  2029.             al[0] = sp->attachment_two_left;
  2030.             al[1] = sp->attachment_two_right;
  2031.             al[2] = sp->attachment_two_top;
  2032.             al[3] = sp->attachment_two_bottom;
  2033.         }
  2034.     }
  2035. }
  2036. /*----------------------------------------------------------------------*/
  2037. static Widget
  2038. AttachmentGetVisibleChild(Widget w,Widget child)
  2039. {
  2040.     Widget            al[4];
  2041.     Cardinal        i;
  2042.  
  2043.     AttachmentLoadAll(w,child,al);
  2044.  
  2045.     /*
  2046.      * Look only in the first two - so that only top/bottom are caught for
  2047.      * vertical and left/right for horizontal 
  2048.      */
  2049.     for(i = 0; i < 4; i++)
  2050.     {
  2051.         if (ALWAYS_VISIBLE(al[i]))
  2052.         {
  2053.             return al[i];
  2054.         }
  2055.     }
  2056.             
  2057.     return NULL;
  2058. }
  2059. /*----------------------------------------------------------------------*/
  2060. static Boolean
  2061. AttachmentContainsXY(Widget aw,int x,int y)
  2062. {
  2063.     if (!_XfeChildIsShown(aw))
  2064.     {
  2065.         return False;
  2066.     }
  2067.  
  2068.     return ( (x >= _XfeX(aw)) &&
  2069.              (x <= (_XfeX(aw) + _XfeWidth(aw))) &&
  2070.              (y >= _XfeY(aw)) &&
  2071.              (y <= (_XfeY(aw) + _XfeHeight(aw))) );
  2072. }
  2073. /*----------------------------------------------------------------------*/
  2074.  
  2075. /*----------------------------------------------------------------------*/
  2076. /*                                                                        */
  2077. /* Sash functions                                                        */
  2078. /*                                                                        */
  2079. /*----------------------------------------------------------------------*/
  2080. static void
  2081. SashLayout(Widget w,Position sash_position,XRectangle * sash_rect)
  2082. {
  2083.     XfePanePart *        sp = _XfePanePart(w);
  2084.  
  2085.     /* Vertical */
  2086.     if (_XfeOrientedOrientation(w) == XmVERTICAL)
  2087.     {
  2088.         sash_rect->x = _XfemRectX(w) + sp->sash_offset;
  2089.         sash_rect->y = _XfemRectY(w) + sash_position;  
  2090.         
  2091.         sash_rect->width = _XfemRectWidth(w) - 2 * sp->sash_offset;
  2092.         sash_rect->height = sp->sash_thickness;
  2093.     }
  2094.     /* Horizontal */
  2095.     else
  2096.     {
  2097.         sash_rect->x = _XfemRectX(w) + sash_position; 
  2098.         sash_rect->y = _XfemRectY(w) + sp->sash_offset; 
  2099.  
  2100.         sash_rect->width = sp->sash_thickness;
  2101.         sash_rect->height = _XfemRectHeight(w) - 2 * sp->sash_offset;
  2102.     }
  2103. }
  2104. /*----------------------------------------------------------------------*/
  2105. static void
  2106. SashDrawDragging(Widget w,XRectangle * sash_rect)
  2107. {
  2108.     XfePanePart *        sp = _XfePanePart(w);
  2109.  
  2110.     /* The line thickness needs to be at least one */
  2111.     Dimension line_thickness = XfeMax(sp->sash_shadow_thickness,1);
  2112.     
  2113.     switch(sp->pane_sash_type)
  2114.     {
  2115.     case XmPANE_SASH_DOUBLE_LINE:
  2116.         
  2117.         /* Vertical */
  2118.         if (_XfeOrientedOrientation(w) == XmVERTICAL)
  2119.         {
  2120.             XfeDrawHorizontalLine(XtDisplay(w),
  2121.                                   _XfeWindow(w),
  2122.                                   sp->sash_GC,
  2123.                                   
  2124.                                   sash_rect->x,
  2125.                                   
  2126.                                   sash_rect->y,
  2127.                                   
  2128.                                   sash_rect->width,
  2129.                                   
  2130.                                   line_thickness);
  2131.  
  2132.             XfeDrawHorizontalLine(XtDisplay(w),
  2133.                                   _XfeWindow(w),
  2134.                                   sp->sash_GC,
  2135.  
  2136.                                   sash_rect->x,
  2137.  
  2138.                                   sash_rect->y +
  2139.                                   sash_rect->height -
  2140.                                   line_thickness,
  2141.                                   
  2142.                                   sash_rect->width,
  2143.                                   
  2144.                                   line_thickness);
  2145.             
  2146.         }
  2147.         /* Horizontal */
  2148.         else
  2149.         {
  2150.             XfeDrawVerticalLine(XtDisplay(w),
  2151.                                 _XfeWindow(w),
  2152.                                 sp->sash_GC,
  2153.                                     
  2154.                                 sash_rect->x,
  2155.                                 
  2156.                                 sash_rect->y,
  2157.                                 
  2158.                                 sash_rect->height,
  2159.  
  2160.                                 line_thickness);
  2161.             
  2162.             XfeDrawVerticalLine(XtDisplay(w),
  2163.                                 _XfeWindow(w),
  2164.                                 sp->sash_GC,
  2165.                                 
  2166.                                 sash_rect->x +
  2167.                                 sash_rect->width -
  2168.                                 line_thickness,
  2169.                                 
  2170.                                 sash_rect->y,
  2171.                                 
  2172.                                 sash_rect->height,
  2173.  
  2174.                                 line_thickness);
  2175.         }
  2176.         
  2177.         break;    
  2178.         
  2179.     case XmPANE_SASH_RECTANGLE:
  2180.         
  2181.         XfeDrawRectangle(XtDisplay(w),
  2182.                          _XfeWindow(w),
  2183.                          sp->sash_GC,
  2184.                          sash_rect->x,
  2185.                          sash_rect->y,
  2186.                          sash_rect->width,
  2187.                          sash_rect->height,
  2188.                          sp->sash_shadow_thickness);
  2189.         
  2190.         break;
  2191.         
  2192.     case XmPANE_SASH_FILLED_RECTANGLE:
  2193.         
  2194.         XFillRectangle(XtDisplay(w),
  2195.                        _XfeWindow(w),
  2196.                        sp->sash_GC,
  2197.                        sash_rect->x,
  2198.                        sash_rect->y,
  2199.                        sash_rect->width,
  2200.                        sash_rect->height);
  2201.         
  2202.         break;
  2203.         
  2204.     case XmPANE_SASH_SINGLE_LINE:
  2205.         
  2206.         /* Vertical */
  2207.         if (_XfeOrientedOrientation(w) == XmVERTICAL)
  2208.         {
  2209.             XfeDrawHorizontalLine(XtDisplay(w),
  2210.                                   _XfeWindow(w),
  2211.                                   sp->sash_GC,
  2212.                                   
  2213.                                   sash_rect->x,
  2214.                                   
  2215.                                   sash_rect->y +
  2216.                                   (sash_rect->height / 2) -
  2217.                                   (line_thickness / 2),
  2218.                                   
  2219.                                   sash_rect->width,
  2220.                                   
  2221.                                   line_thickness);
  2222.         }
  2223.         /* Horizontal */
  2224.         else
  2225.         {
  2226.             XfeDrawVerticalLine(XtDisplay(w),
  2227.                                 _XfeWindow(w),
  2228.                                 sp->sash_GC,
  2229.                                 
  2230.                                 sash_rect->x +
  2231.                                 (sash_rect->width / 2) -
  2232.                                 (line_thickness / 2),
  2233.                                 
  2234.                                 sash_rect->y,
  2235.                                 
  2236.                                 sash_rect->height,
  2237.                                 
  2238.                                 line_thickness);
  2239.         }
  2240.         
  2241.         break;
  2242.         
  2243.         /* Nothing is needed for this one */
  2244.     case XmPANE_SASH_LIVE:
  2245.         break;
  2246.     }
  2247. }
  2248. /*----------------------------------------------------------------------*/
  2249. static void
  2250. SashDrawShadow(Widget w,XRectangle * sash_rect,Boolean clear_body)
  2251. {
  2252.     XfePanePart *    sp = _XfePanePart(w);
  2253.  
  2254.     /* Make sure the sash has dimensions > 0 */
  2255.     if (sash_rect->width && sash_rect->height)
  2256.      {
  2257.         _XmDrawShadows(XtDisplay(w),
  2258.                        _XfeWindow(w),
  2259.                        _XfemTopShadowGC(w),
  2260.                        _XfemBottomShadowGC(w),
  2261.                        sash_rect->x,
  2262.                        sash_rect->y,
  2263.                        sash_rect->width,
  2264.                        sash_rect->height,
  2265.                        sp->sash_shadow_thickness,
  2266.                        sp->sash_shadow_type);
  2267.  
  2268.         
  2269.         /* Clear the sash body if needed */
  2270.          if (clear_body &&
  2271.              (sash_rect->width > (sp->sash_shadow_thickness * 2)) &&
  2272.              (sash_rect->height > (sp->sash_shadow_thickness * 2)))
  2273.          {
  2274.             XClearArea(XtDisplay(w),
  2275.                        _XfeWindow(w),
  2276.                        sash_rect->x + sp->sash_shadow_thickness,
  2277.                        sash_rect->y + sp->sash_shadow_thickness,
  2278.                        sash_rect->width - 2 * sp->sash_shadow_thickness,
  2279.                        sash_rect->height - 2 * sp->sash_shadow_thickness,
  2280.                        False);
  2281.         }
  2282.     }
  2283. }
  2284. /*----------------------------------------------------------------------*/
  2285. static void
  2286. SashDragStart(Widget w,int x,int y,Widget aw)
  2287. {
  2288.     XfePanePart *        sp = _XfePanePart(w);
  2289.  
  2290.     /* Save the original sash position */
  2291.     sp->sash_original_position = sp->sash_position;
  2292.  
  2293.     /* If the attachment is valid, use it as the dragging rect */
  2294.     if (_XfeIsAlive(aw))
  2295.     {
  2296.         XfeRectSet(&sp->sash_dragging_rect,
  2297.                    _XfeX(aw),
  2298.                    _XfeY(aw),
  2299.                    _XfeWidth(aw),
  2300.                    _XfeHeight(aw));
  2301.     }
  2302.     /* Otherwise use the sash's rect */
  2303.     else
  2304.     {
  2305.         XfeRectCopy(&sp->sash_dragging_rect,&sp->sash_rect);
  2306.     }
  2307.  
  2308.     /* Assign the last dragging coordinate for the first time */
  2309.     sp->sash_dragging_last = CHOOSE_X_OR_Y(_XfeOrientedOrientation(w),x,y);
  2310.  
  2311.     /* Draw the first dragging sash if needed */
  2312.     if (sp->pane_sash_type != XmPANE_SASH_LIVE)
  2313.     {
  2314.         SashDrawDragging(w,&sp->sash_dragging_rect);
  2315.     }
  2316. }
  2317. /*----------------------------------------------------------------------*/
  2318. static void
  2319. SashDragEnd(Widget w,int x,int y,Widget aw)
  2320. {
  2321.     XfePanePart *        sp = _XfePanePart(w);
  2322.     Position            new_pos;
  2323.  
  2324.     /* Compute the new position */
  2325.     new_pos = CHOOSE_X_OR_Y(_XfeOrientedOrientation(w),
  2326.  
  2327.                             sp->sash_original_position + 
  2328.                             (x - sp->sash_dragging_last),
  2329.  
  2330.                             sp->sash_original_position + 
  2331.                             (y - sp->sash_dragging_last));
  2332.  
  2333.     /* Erase the previous sash if needed */
  2334.     if (sp->pane_sash_type != XmPANE_SASH_LIVE)
  2335.     {
  2336.         SashDrawDragging(w,&sp->sash_dragging_rect);
  2337.     }
  2338.  
  2339.  
  2340.             
  2341.     /* Update the sash position */
  2342.     sp->sash_position = new_pos;
  2343.     
  2344.     /* Layout the components */
  2345.     _XfeManagerLayoutComponents(w);
  2346.     
  2347.     /* Layout the children */
  2348.     _XfeManagerLayoutChildren(w);
  2349.     
  2350.     /* Draw components */
  2351.     SashDrawShadow(w,&sp->sash_rect,True);
  2352. }
  2353. /*----------------------------------------------------------------------*/
  2354. static void
  2355. SashDragMotion(Widget w,int x,int y,Widget aw)
  2356. {
  2357.     XfePanePart *        sp = _XfePanePart(w);
  2358.      Position            new_pos;
  2359.      Position            max_pos;
  2360.      Position            min_pos;
  2361.  
  2362.     /* Compute the new position */
  2363.     new_pos = CHOOSE_X_OR_Y(_XfeOrientedOrientation(w),
  2364.  
  2365.                             sp->sash_original_position + 
  2366.                             (x - sp->sash_dragging_last),
  2367.  
  2368.                             sp->sash_original_position + 
  2369.                             (y - sp->sash_dragging_last));
  2370.  
  2371.  
  2372.     /* Make sure the diff in positions is greater than the drag threshold */
  2373.     if (XfeAbs(new_pos - sp->sash_position) < sp->drag_threshold)
  2374.     {
  2375.         return;
  2376.     }
  2377.  
  2378. #if 1
  2379.     max_pos = SashMaxPosition(w);
  2380.     min_pos = SashMinPosition(w);
  2381.  
  2382.     if (new_pos < min_pos)
  2383.     {
  2384.         new_pos = min_pos;
  2385.     }
  2386.     else if (new_pos > max_pos)
  2387.     {
  2388.         new_pos = max_pos;
  2389.     }
  2390. #endif
  2391.  
  2392.     /* Erase the previous sash if needed */
  2393.     if (sp->pane_sash_type != XmPANE_SASH_LIVE)
  2394.     {
  2395.         SashDrawDragging(w,&sp->sash_dragging_rect);
  2396.     }
  2397.  
  2398.     /* If the attachment is valid, use it as the new dragging rect */
  2399.     if (_XfeIsAlive(aw))
  2400.     {
  2401.         Position rect_x = _XfeX(aw);
  2402.         Position rect_y = _XfeY(aw);
  2403.  
  2404.         /* Vertical */
  2405.         if (_XfeOrientedOrientation(w) == XmVERTICAL)
  2406.         {
  2407.             rect_y += (new_pos - sp->sash_original_position);
  2408.         }
  2409.         /* Horizontal */
  2410.         else
  2411.         {
  2412.             rect_x += (new_pos - sp->sash_original_position);
  2413.         }
  2414.  
  2415.         XfeRectSet(&sp->sash_dragging_rect,
  2416.                    rect_x,
  2417.                    rect_y,
  2418.                    _XfeWidth(aw),
  2419.                    _XfeHeight(aw));
  2420.     }
  2421.     /* Otherwise use the new sash's rect */
  2422.     else
  2423.     {
  2424.         SashLayout(w,new_pos,&sp->sash_dragging_rect);
  2425.     }
  2426.  
  2427.     /* Draw the new sash if needed */
  2428.     if (sp->pane_sash_type != XmPANE_SASH_LIVE)
  2429.     {
  2430.         SashDrawDragging(w,&sp->sash_dragging_rect);
  2431.     }
  2432.  
  2433.     if (sp->pane_sash_type == XmPANE_SASH_LIVE)
  2434.     {
  2435.         /* Update the sash position */
  2436.         sp->sash_position = new_pos;
  2437.         
  2438.         /* Layout the components */
  2439.         _XfeManagerLayoutComponents(w);
  2440.         
  2441.         /* Layout the children */
  2442.         _XfeManagerLayoutChildren(w);
  2443.         
  2444.         /* Draw components */
  2445.         SashDrawShadow(w,&sp->sash_rect,True);
  2446.     }
  2447.  
  2448. /*       printf("DragMotion(%s,%d,%d)\n",XtName(w),form_x,form_y); */
  2449. }
  2450. /*----------------------------------------------------------------------*/
  2451. static Position
  2452. SashMinPosition(Widget w)
  2453. {
  2454.     XfePanePart *        sp = _XfePanePart(w);
  2455.     Position            min_pos;
  2456.     Dimension            pane_minimum_one = ChildMinSize(w,sp->child_one);
  2457.  
  2458.     /* Vertical */
  2459.     if (_XfeOrientedOrientation(w) == XmVERTICAL)
  2460.     {
  2461. /*         printf("min height for 1 is %d\n",pane_minimum_one); */
  2462.  
  2463.         min_pos = _XfemOffsetTop(w);
  2464.     }
  2465.     /* Horizontal */
  2466.     else
  2467.     {
  2468. /*          printf("min width for 1 is %d\n",pane_minimum_one);  */
  2469.  
  2470.         if (pane_minimum_one == 0)
  2471.         {
  2472.             min_pos = _XfemOffsetLeft(w);
  2473.         }
  2474.         else
  2475.         {
  2476.             min_pos = 
  2477.                 _XfemOffsetLeft(w) + 
  2478.                 pane_minimum_one;/*  + */
  2479. /*                 _XfemOffsetRight(w); */
  2480.         }
  2481.     }
  2482.  
  2483.     return min_pos;
  2484. }
  2485. /*----------------------------------------------------------------------*/
  2486. static Position
  2487. SashMaxPosition(Widget w)
  2488. {
  2489.     XfePanePart *        sp = _XfePanePart(w);
  2490.     Position            max_pos;
  2491.  
  2492.     /* Vertical */
  2493.     if (_XfeOrientedOrientation(w) == XmVERTICAL)
  2494.     {
  2495.         max_pos = 
  2496.             _XfeHeight(w) - 
  2497.             _XfemOffsetBottom(w) - 
  2498.             sp->sash_rect.height;
  2499.     }
  2500.     /* Horizontal */
  2501.     else
  2502.     {
  2503.         Dimension pane_minimum_two = ChildMinSize(w,sp->child_two);
  2504.  
  2505.         max_pos = 
  2506.             _XfemRectWidth(w) - 
  2507.             pane_minimum_two -
  2508.             sp->sash_rect.width;
  2509.     }
  2510.  
  2511.     return max_pos;
  2512. }
  2513. /*----------------------------------------------------------------------*/
  2514. static Position
  2515. SashMinPositionVertical(Widget w)
  2516. {
  2517.     XfePanePart *        sp = _XfePanePart(w);
  2518.     Position            min_pos;
  2519.     Dimension            pane_minimum_one = ChildMinSize(w,sp->child_one);
  2520.     
  2521.     min_pos = _XfemOffsetTop(w);
  2522.  
  2523.     return min_pos;
  2524. }
  2525. /*----------------------------------------------------------------------*/
  2526. static Position
  2527. SashMaxPositionX(Widget w)
  2528. {
  2529.     XfePanePart *        sp = _XfePanePart(w);
  2530.     Position            max_pos;
  2531.  
  2532.     /* Vertical */
  2533.     if (_XfeOrientedOrientation(w) == XmVERTICAL)
  2534.     {
  2535.         max_pos = 
  2536.             _XfeHeight(w) - 
  2537.             _XfemOffsetBottom(w) - 
  2538.             sp->sash_rect.height;
  2539.     }
  2540.     /* Horizontal */
  2541.     else
  2542.     {
  2543.         Dimension pane_minimum_two = ChildMinSize(w,sp->child_two);
  2544.  
  2545.         max_pos = 
  2546.             _XfemRectWidth(w) - 
  2547.             pane_minimum_two -
  2548.             sp->sash_rect.width;
  2549.     }
  2550.  
  2551.     return max_pos;
  2552. }
  2553. /*----------------------------------------------------------------------*/
  2554. static void
  2555. SashVerifyPosition(Widget        w,
  2556.                    Dimension    form_pref_width,
  2557.                    Dimension    form_pref_height)
  2558. {
  2559.      XfePanePart *        sp = _XfePanePart(w);
  2560.  
  2561.     /* Setup the sash position if it still is the default */
  2562.     if (sp->sash_position == DEFAULT_SASH_POSITION)
  2563.     {
  2564.         Dimension    sash_thickness;
  2565.         Dimension    pane_thickness;
  2566.  
  2567.         /* Vertical */
  2568.         if (_XfeOrientedOrientation(w) == XmVERTICAL)
  2569.         {
  2570.             if (_XfeHeight(w) == XfeMANAGER_DEFAULT_HEIGHT)
  2571.             {
  2572.                 pane_thickness = 0;
  2573.             }
  2574.             else
  2575.             {
  2576.                 pane_thickness = _XfeHeight(w);
  2577.             }
  2578.  
  2579.             sash_thickness = form_pref_height + TWO_TIMES_SST(sp);
  2580.         }
  2581.         /* Horizontal */
  2582.         else
  2583.         {
  2584.             if (_XfeWidth(w) == XfeMANAGER_DEFAULT_WIDTH)
  2585.             {
  2586.                 pane_thickness = 0;
  2587.             }
  2588.             else
  2589.             {
  2590.                 pane_thickness = _XfeWidth(w);
  2591.             }
  2592.  
  2593.             sash_thickness = form_pref_width + TWO_TIMES_SST(sp);
  2594.         }
  2595.  
  2596. /*         printf("%s: pane_thickness = %d\n",XtName(w),pane_thickness); */
  2597.  
  2598.         if (pane_thickness != 0)
  2599.         {
  2600.             sp->sash_position = (pane_thickness - sash_thickness) / 2;
  2601.         }
  2602.     }
  2603. }
  2604. /*----------------------------------------------------------------------*/
  2605. static Boolean
  2606. SashContainsXY(Widget w,int x,int y)
  2607. {
  2608.      XfePanePart *        sp = _XfePanePart(w);
  2609.  
  2610.     return ( (x >= sp->sash_rect.x) &&
  2611.              (x <= (sp->sash_rect.x + sp->sash_rect.width)) &&
  2612.              (y >= sp->sash_rect.y) &&
  2613.              (y <= (sp->sash_rect.y + sp->sash_rect.height)) );
  2614. }
  2615. /*----------------------------------------------------------------------*/
  2616.  
  2617. /*----------------------------------------------------------------------*/
  2618. /*                                                                        */
  2619. /* Misc XfePane functions                                                */
  2620. /*                                                                        */
  2621. /*----------------------------------------------------------------------*/
  2622. static Boolean
  2623. HasChildOneAttachment(Widget w)
  2624. {
  2625.     XfePanePart * sp = _XfePanePart(w);
  2626.     
  2627.     return (_XfeIsAlive(sp->attachment_one_bottom) ||
  2628.             _XfeIsAlive(sp->attachment_one_left) ||
  2629.             _XfeIsAlive(sp->attachment_one_right) ||
  2630.             _XfeIsAlive(sp->attachment_one_top));
  2631. }
  2632. /*----------------------------------------------------------------------*/
  2633. static Boolean
  2634. HasChildTwoAttachment(Widget w)
  2635. {
  2636.     XfePanePart * sp = _XfePanePart(w);
  2637.     
  2638.     return (_XfeIsAlive(sp->attachment_two_bottom) ||
  2639.             _XfeIsAlive(sp->attachment_two_left) ||
  2640.             _XfeIsAlive(sp->attachment_two_right) ||
  2641.             _XfeIsAlive(sp->attachment_two_top));
  2642. }
  2643. /*----------------------------------------------------------------------*/
  2644.  
  2645. /*----------------------------------------------------------------------*/
  2646. /*                                                                        */
  2647. /* IsAttachment test function.                                            */
  2648. /*                                                                        */
  2649. /*----------------------------------------------------------------------*/
  2650. static Boolean
  2651. FindTestIsAttachment(Widget child,XtPointer data)
  2652. {
  2653.     Widget pane = (Widget) data;
  2654.  
  2655.     if (_XfeIsAlive(pane))
  2656.     {
  2657.         return ChildIsAttachment(pane,child);
  2658.     }
  2659.  
  2660.     return False;
  2661. }
  2662. /*----------------------------------------------------------------------*/
  2663.  
  2664. /*----------------------------------------------------------------------*/
  2665. /*                                                                        */
  2666. /* XfePane Public Methods                                                */
  2667. /*                                                                        */
  2668. /*----------------------------------------------------------------------*/
  2669. /* extern */ Widget
  2670. XfeCreatePane(Widget pw,char * name,Arg * av,Cardinal ac)
  2671. {
  2672.     return XtCreateWidget(name,xfePaneWidgetClass,pw,av,ac);
  2673. }
  2674. /*----------------------------------------------------------------------*/
  2675.