home *** CD-ROM | disk | FTP | other *** search
/ Tools / WinSN5.0Ver.iso / NETSCAP.50 / WIN1998.ZIP / ns / cmd / xfe / XfeWidgets / Xfe / ToolScroll.c < prev    next >
Encoding:
C/C++ Source or Header  |  1998-04-08  |  26.0 KB  |  872 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/ToolScroll.c>                                        */
  21. /* Description:    XfeToolScroll widget source.                            */
  22. /* Author:        Ramiro Estrugo <ramiro@netscape.com>                    */
  23. /*                                                                        */
  24. /*----------------------------------------------------------------------*/
  25.  
  26.  
  27. #include <Xfe/ToolScrollP.h>
  28. #include <Xfe/ToolBarP.h>
  29.  
  30. #include <Xm/DrawingA.h>
  31. #include <Xfe/Arrow.h>
  32. #include <Xfe/ToolBar.h>
  33.  
  34. #define MESSAGE1 "Widget is not an XfeToolScroll."
  35. #define MESSAGE2 "XmNbackwardArrow is a read-only resource."
  36. #define MESSAGE3 "XmNforwardArrow is a read-only resource."
  37. #define MESSAGE4 "XmNtoolBar is a read-only resource."
  38. #define MESSAGE5 "XmNclipArea is a read-only resource."
  39.  
  40. #define BACKWARD_ARROW_NAME        "BackwardArrow"
  41. #define FORWARD_ARROW_NAME        "ForwardArrow"
  42. #define TOOL_BAR_NAME            "ToolBar"
  43. #define CLIP_AREA_NAME            "ClipArea"
  44.  
  45. /*----------------------------------------------------------------------*/
  46. /*                                                                        */
  47. /* Core class methods                                                    */
  48. /*                                                                        */
  49. /*----------------------------------------------------------------------*/
  50. static void     Initialize        (Widget,Widget,ArgList,Cardinal *);
  51. static void     Destroy            (Widget);
  52. static Boolean    SetValues        (Widget,Widget,Widget,ArgList,Cardinal *);
  53.  
  54. /*----------------------------------------------------------------------*/
  55. /*                                                                        */
  56. /* XfeManager class methods                                                */
  57. /*                                                                        */
  58. /*----------------------------------------------------------------------*/
  59. static void        PreferredGeometry    (Widget,Dimension *,Dimension *);
  60. static void        DrawComponents        (Widget,XEvent *,Region,XRectangle *);
  61. static void        LayoutComponents    (Widget);
  62. static Boolean    AcceptChild            (Widget);
  63. static Boolean    DeleteChild            (Widget);
  64. static Boolean    InsertChild            (Widget);
  65.  
  66. /*----------------------------------------------------------------------*/
  67. /*                                                                        */
  68. /* XfeOriented class methods                                            */
  69. /*                                                                        */
  70. /*----------------------------------------------------------------------*/
  71. static void     EnterProc                (Widget,Widget,int,int);
  72. static void     LeaveProc                (Widget,Widget,int,int);
  73. static void     MotionProc                (Widget,Widget,int,int);
  74. static void     DragStart                (Widget,Widget,int,int);
  75. static void     DragEnd                    (Widget,Widget,int,int);
  76. static void     DragMotion                (Widget,Widget,int,int);
  77.  
  78. static void     DescendantMotion        (Widget,Widget,int,int);
  79. static void     DescendantDragStart        (Widget,Widget,int,int);
  80. static void     DescendantDragEnd        (Widget,Widget,int,int);
  81. static void     DescendantDragMotion    (Widget,Widget,int,int);
  82.  
  83. /*----------------------------------------------------------------------*/
  84. /*                                                                        */
  85. /* Misc functions                                                        */
  86. /*                                                                        */
  87. /*----------------------------------------------------------------------*/
  88. static void        LayoutVertical        (Widget);
  89. static void        LayoutHorizontal    (Widget);
  90. static void        LayoutToolBar        (Widget);
  91.  
  92. /*----------------------------------------------------------------------*/
  93. /*                                                                        */
  94. /* XfeToolScroll Resources                                                */
  95. /*                                                                        */
  96. /*----------------------------------------------------------------------*/
  97. static XtResource resources[] =     
  98. {                    
  99.     /* Arrow resources */
  100.     { 
  101.         XmNbackwardArrow,
  102.         XmCReadOnly,
  103.         XmRWidget,
  104.         sizeof(Widget),
  105.         XtOffsetOf(XfeToolScrollRec , xfe_tool_scroll . backward_arrow),
  106.         XmRImmediate, 
  107.         (XtPointer) NULL
  108.     },
  109.     { 
  110.         XmNforwardArrow,
  111.         XmCReadOnly,
  112.         XmRWidget,
  113.         sizeof(Widget),
  114.         XtOffsetOf(XfeToolScrollRec , xfe_tool_scroll . forward_arrow),
  115.         XmRImmediate, 
  116.         (XtPointer) NULL
  117.     },
  118.     { 
  119.         XmNarrowDisplayPolicy,
  120.         XmCArrowDisplayPolicy,
  121.         XmRArrowDisplayPolicy,
  122.         sizeof(unsigned char),
  123.         XtOffsetOf(XfeToolScrollRec , xfe_tool_scroll . arrow_display_policy),
  124.         XmRImmediate, 
  125.         (XtPointer) XmAS_NEEDED
  126.     },
  127.     { 
  128.         XmNarrowPlacement,
  129.         XmCArrowPlacement,
  130.         XmRToolScrollArrowPlacement,
  131.         sizeof(unsigned char),
  132.         XtOffsetOf(XfeToolScrollRec , xfe_tool_scroll . arrow_placement),
  133.         XmRImmediate, 
  134.         (XtPointer) XmTOOL_SCROLL_ARROW_PLACEMENT_START
  135.     },
  136.  
  137.     /* ClipArea resources */
  138.     { 
  139.         XmNclipArea,
  140.         XmCReadOnly,
  141.         XmRWidget,
  142.         sizeof(Widget),
  143.         XtOffsetOf(XfeToolScrollRec , xfe_tool_scroll . clip_area),
  144.         XmRImmediate, 
  145.         (XtPointer) NULL
  146.     },
  147.     { 
  148.         XmNclipShadowThickness,
  149.         XmCShadowThickness,
  150.         XmRHorizontalDimension,
  151.         sizeof(Dimension),
  152.         XtOffsetOf(XfeToolScrollRec , xfe_tool_scroll . clip_shadow_thickness),
  153.         XmRCallProc, 
  154.         (XtPointer) _XfeCallProcCopyShadowThickness
  155.     },
  156.     { 
  157.         XmNclipShadowType,
  158.         XmCShadowType,
  159.         XmRShadowType,
  160.         sizeof(unsigned char),
  161.         XtOffsetOf(XfeToolScrollRec , xfe_tool_scroll . clip_shadow_type),
  162.         XmRImmediate, 
  163.         (XtPointer) XmSHADOW_IN
  164.     },
  165.  
  166.     /* Tool bar resources */
  167.     { 
  168.         XmNtoolBar,
  169.         XmCReadOnly,
  170.         XmRWidget,
  171.         sizeof(Widget),
  172.         XtOffsetOf(XfeToolScrollRec , xfe_tool_scroll . tool_bar),
  173.         XmRImmediate, 
  174.         (XtPointer) NULL
  175.     },
  176.     { 
  177.         XmNtoolBarPosition,
  178.         XmCToolBarPosition,
  179.         XmRPosition,
  180.         sizeof(Position),
  181.         XtOffsetOf(XfeToolScrollRec , xfe_tool_scroll . tool_bar_position),
  182.         XmRImmediate, 
  183.         (XtPointer) 0
  184.     },
  185.  
  186.     /* Force XmNallowDrag to True */
  187.     { 
  188.         XmNallowDrag,
  189.         XmCBoolean,
  190.         XmRBoolean,
  191.         sizeof(Boolean),
  192.         XtOffsetOf(XfeToolScrollRec , xfe_oriented . allow_drag),
  193.         XmRImmediate, 
  194.         (XtPointer) True
  195.     },
  196.  
  197.     /* Force XmNspacing to 4 */
  198.     { 
  199.         XmNspacing,
  200.         XmCSpacing,
  201.         XmRHorizontalDimension,
  202.         sizeof(Dimension),
  203.         XtOffsetOf(XfeToolScrollRec , xfe_oriented . spacing),
  204.         XmRImmediate, 
  205.         (XtPointer) 4
  206.     },
  207. };   
  208.  
  209. /*----------------------------------------------------------------------*/
  210. /*                                                                        */
  211. /* XfeToolScroll Synthetic Resources                                    */
  212. /*                                                                        */
  213. /*----------------------------------------------------------------------*/
  214. static XmSyntheticResource syn_resources[] =
  215. {
  216.    { 
  217.        XmNclipShadowThickness,
  218.        sizeof(Dimension),
  219.        XtOffsetOf(XfeToolScrollRec , xfe_tool_scroll . clip_shadow_thickness),
  220.        _XmFromHorizontalPixels,
  221.        _XmToHorizontalPixels 
  222.    },
  223. };
  224.  
  225. /*----------------------------------------------------------------------*/
  226. /*                                                                        */
  227. /* Widget Class Record Initialization                                   */
  228. /*                                                                        */
  229. /*----------------------------------------------------------------------*/
  230. _XFE_WIDGET_CLASS_RECORD(toolscroll,ToolScroll) =
  231. {
  232.     {
  233.         (WidgetClass) &xfeOrientedClassRec,        /* superclass           */
  234.         "XfeToolScroll",                        /* class_name           */
  235.         sizeof(XfeToolScrollRec),                /* widget_size          */
  236.         NULL,                                    /* class_initialize     */
  237.         NULL,                                    /* class_part_initialize*/
  238.         FALSE,                                  /* class_inited         */
  239.         Initialize,                             /* initialize           */
  240.         NULL,                                   /* initialize_hook      */
  241.         XtInheritRealize,                        /* realize              */
  242.         NULL,                                    /* actions              */
  243.         0,                                        /* num_actions            */
  244.         resources,                              /* resources            */
  245.         XtNumber(resources),                    /* num_resources        */
  246.         NULLQUARK,                              /* xrm_class            */
  247.         TRUE,                                   /* compress_motion      */
  248.         XtExposeCompressMaximal,                /* compress_exposure    */
  249.         TRUE,                                   /* compress_enterleave    */
  250.         FALSE,                                  /* visible_interest     */
  251.         Destroy,                                /* destroy              */
  252.         XtInheritResize,                        /* resize               */
  253.         XtInheritExpose,                        /* expose               */
  254.         SetValues,                              /* set_values           */
  255.         NULL,                                   /* set_values_hook      */
  256.         XtInheritSetValuesAlmost,                /* set_values_almost    */
  257.         NULL,                                    /* get_values_hook      */
  258.         NULL,                                   /* accexfe_focus         */
  259.         XtVersion,                              /* version              */
  260.         NULL,                                   /* callback_private     */
  261.         XtInheritTranslations,                    /* tm_table                */
  262.         XtInheritQueryGeometry,                    /* query_geometry       */
  263.         XtInheritDisplayAccelerator,            /* display accel        */
  264.         NULL,                                   /* extension            */
  265.     },
  266.  
  267.     /* Composite Part */
  268.     {
  269.         XtInheritGeometryManager,                /* geometry_manager        */
  270.         XtInheritChangeManaged,                    /* change_managed        */
  271.         XtInheritInsertChild,                    /* insert_child            */
  272.         XtInheritDeleteChild,                    /* delete_child            */
  273.         NULL                                    /* extension            */
  274.     },
  275.  
  276.     /* Constraint Part */
  277.     {
  278.         NULL,                                    /* resource list           */
  279.         0,                                        /* num resources           */
  280.         sizeof(XfeOrientedConstraintRec),        /* constraint size         */
  281.         NULL,                                    /* init proc               */
  282.         NULL,                                   /* destroy proc            */
  283.         NULL,                                    /* set values proc         */
  284.         NULL,                                   /* extension               */
  285.     },
  286.  
  287.     /* XmManager Part */
  288.     {
  289.         XtInheritTranslations,                    /* tm_table                */
  290.         syn_resources,                            /* syn resources           */
  291.         XtNumber(syn_resources),                /* num syn_resources       */
  292.         NULL,                                   /* syn_cont_resources      */
  293.         0,                                      /* num_syn_cont_resource*/
  294.         XmInheritParentProcess,                 /* parent_process          */
  295.         NULL,                                   /* extension               */
  296.     },
  297.  
  298.     /* XfeManager Part     */
  299.     {
  300.         XfeInheritBitGravity,                    /* bit_gravity            */
  301.         PreferredGeometry,                        /* preferred_geometry    */
  302.         XfeInheritMinimumGeometry,                /* minimum_geometry        */
  303.         XfeInheritUpdateRect,                    /* update_rect            */
  304.         AcceptChild,                            /* accept_child            */
  305.         InsertChild,                            /* insert_child            */
  306.         DeleteChild,                            /* delete_child            */
  307.         NULL,                                    /* change_managed        */
  308.         NULL,                                    /* prepare_components    */
  309.         LayoutComponents,                        /* layout_components    */
  310.         NULL,                                    /* layout_children        */
  311.         NULL,                                    /* draw_background        */
  312.         XfeInheritDrawShadow,                    /* draw_shadow            */
  313.         DrawComponents,                            /* draw_components        */
  314.         NULL,                                    /* extension              */
  315.     },
  316.  
  317.     /* XfeOriented Part */
  318.     {
  319.         EnterProc,                                /* enter                */
  320.         LeaveProc,                                /* leave                */
  321.         MotionProc,                                /* motion                */
  322.         DragStart,                                /* drag_start            */
  323.         DragEnd,                                /* drag_end                */
  324.         DragMotion,                                /* drag_motion            */
  325.         XfeInheritDescendantEnter,                /* des_enter            */
  326.         XfeInheritDescendantLeave,                /* des_leave            */
  327.         DescendantMotion,                        /* des_motion            */
  328.         DescendantDragStart,                    /* des_drag_start        */
  329.         DescendantDragEnd,                        /* des_drag_end            */
  330.         DescendantDragMotion,                    /* des_drag_motion        */
  331.         NULL,                                    /* extension              */
  332.     },
  333.  
  334.     /* XfeToolScroll Part */
  335.     {
  336.         NULL,                                    /* extension              */
  337.     },
  338. };
  339.  
  340. /*----------------------------------------------------------------------*/
  341. /*                                                                        */
  342. /* xfeToolScrollWidgetClassdeclaration.                                    */
  343. /*                                                                        */
  344. /*----------------------------------------------------------------------*/
  345. _XFE_WIDGET_CLASS(toolscroll,ToolScroll);
  346.  
  347. /*----------------------------------------------------------------------*/
  348. /*                                                                        */
  349. /* Core class methods                                                    */
  350. /*                                                                        */
  351. /*----------------------------------------------------------------------*/
  352. static void
  353. Initialize(Widget rw,Widget nw,ArgList args,Cardinal *nargs)
  354. {
  355.     XfeToolScrollPart *        tp = _XfeToolScrollPart(nw);
  356.  
  357.     /* Make sure rep types are ok */
  358.     XfeRepTypeCheck(nw,XmRArrowDisplayPolicy,&tp->arrow_display_policy,
  359.                     XmAS_NEEDED);
  360.  
  361.     XfeRepTypeCheck(nw,XmRToolScrollArrowPlacement,&tp->arrow_placement,
  362.                     XmTOOL_SCROLL_ARROW_PLACEMENT_START);
  363.  
  364.     tp->backward_arrow = 
  365.         XtVaCreateManagedWidget(BACKWARD_ARROW_NAME,
  366.                                 xfeArrowWidgetClass,
  367.                                 nw,
  368.                                 XmNbackground,        _XfeBackgroundPixel(nw),
  369.                                 XmNforeground,        _XfemForeground(nw),
  370.                                 XmNbackgroundPixmap,_XfeBackgroundPixmap(nw),
  371.                                 NULL);
  372.  
  373.     tp->forward_arrow = 
  374.         XtVaCreateManagedWidget(FORWARD_ARROW_NAME,
  375.                                 xfeArrowWidgetClass,
  376.                                 nw,
  377.                                 XmNbackground,        _XfeBackgroundPixel(nw),
  378.                                 XmNforeground,        _XfemForeground(nw),
  379.                                 XmNbackgroundPixmap,_XfeBackgroundPixmap(nw),
  380.                                 NULL);
  381.  
  382.     tp->clip_area = 
  383.         XtVaCreateManagedWidget(CLIP_AREA_NAME,
  384.                                 xmDrawingAreaWidgetClass,
  385.                                 nw,
  386.                                  XmNbackground,        _XfeBackgroundPixel(nw),
  387.                                 XmNforeground,        _XfemForeground(nw),
  388.                                  XmNbackgroundPixmap,_XfeBackgroundPixmap(nw),
  389.                                 XmNmarginWidth,        0,
  390.                                 XmNmarginHeight,    0,
  391.                                  XmNshadowThickness,    0,
  392.                                  XmNallowDrag,        True,
  393.                                 NULL);
  394.  
  395.     tp->tool_bar = 
  396.         XtVaCreateManagedWidget(TOOL_BAR_NAME,
  397.                                 xfeToolBarWidgetClass,
  398.                                 tp->clip_area,
  399.                                 XmNbackground,        _XfeBackgroundPixel(nw),
  400.                                 XmNforeground,        _XfemForeground(nw),
  401.                                 XmNbackgroundPixmap,_XfeBackgroundPixmap(nw),
  402.                                 XmNorientation,       _XfeOrientedOrientation(nw),
  403.                                  XmNallowDrag,        True,
  404.                                 NULL);
  405.  
  406.     /* Finish of initialization */
  407.     _XfeManagerChainInitialize(rw,nw,xfeToolScrollWidgetClass);
  408. }
  409. /*----------------------------------------------------------------------*/
  410. static void
  411. Destroy(Widget w)
  412. {
  413. }
  414. /*----------------------------------------------------------------------*/
  415. static Boolean
  416. SetValues(Widget ow,Widget rw,Widget nw,ArgList args,Cardinal *nargs)
  417. {
  418.     XfeToolScrollPart *        np = _XfeToolScrollPart(nw);
  419.     XfeToolScrollPart *        op = _XfeToolScrollPart(ow);
  420.  
  421.     /* backward_arrow */
  422.     if (np->backward_arrow != op->backward_arrow)
  423.     {
  424.         _XfeWarning(nw,MESSAGE2);
  425.  
  426.         np->backward_arrow = op->backward_arrow;
  427.     }
  428.  
  429.     /* forward_arrow */
  430.     if (np->forward_arrow != op->forward_arrow)
  431.     {
  432.         _XfeWarning(nw,MESSAGE3);
  433.  
  434.         np->forward_arrow = op->forward_arrow;
  435.     }
  436.  
  437.     /* tool_bar */
  438.     if (np->tool_bar != op->tool_bar)
  439.     {
  440.         _XfeWarning(nw,MESSAGE4);
  441.  
  442.         np->tool_bar = op->tool_bar;
  443.     }
  444.  
  445.     /* clip_area */
  446.     if (np->clip_area != op->clip_area)
  447.     {
  448.         _XfeWarning(nw,MESSAGE5);
  449.  
  450.         np->clip_area = op->clip_area;
  451.     }
  452.  
  453.     /* orientation */
  454.     if (_XfeOrientedOrientation(nw) != _XfeOrientedOrientation(ow))
  455.     {
  456.         if (_XfeIsAlive(np->tool_bar))
  457.         {
  458.             XtVaSetValues(np->tool_bar,
  459.                           XmNorientation,    _XfeOrientedOrientation(nw),
  460.                           NULL);
  461.         }
  462.     }
  463.  
  464.     /* arrow_display_policy */
  465.     if (np->arrow_display_policy != op->arrow_display_policy)
  466.     {
  467.         /* Make sure the new arrow display policy is ok */
  468.         XfeRepTypeCheck(nw,XmRArrowDisplayPolicy,&np->arrow_display_policy,
  469.                         XmAS_NEEDED);
  470.  
  471.         _XfemConfigFlags(nw) |= XfeConfigGLE;
  472.     }
  473.  
  474.     /* arrow_placement */
  475.     if (np->arrow_placement != op->arrow_placement)
  476.     {
  477.         /* Make sure the new arrow display policy is ok */
  478.         XfeRepTypeCheck(nw,XmRToolScrollArrowPlacement,&np->arrow_placement,
  479.                         XmTOOL_SCROLL_ARROW_PLACEMENT_START);
  480.  
  481.         _XfemConfigFlags(nw) |= XfeConfigGLE;
  482.     }
  483.  
  484.     return _XfeManagerChainSetValues(ow,rw,nw,xfeToolScrollWidgetClass);
  485. }
  486. /*----------------------------------------------------------------------*/
  487.  
  488. /*----------------------------------------------------------------------*/
  489. /*                                                                        */
  490. /* XfeManager class methods                                                */
  491. /*                                                                        */
  492. /*----------------------------------------------------------------------*/
  493. static void
  494. PreferredGeometry(Widget w,Dimension * width,Dimension * height)
  495. {
  496.     XfeToolScrollPart *    tp = _XfeToolScrollPart(w);
  497.  
  498.     *width  =
  499.         _XfemOffsetLeft(w) + 
  500.         _XfemOffsetRight(w) + 
  501.         2 * tp->clip_shadow_thickness +
  502.         2 * _XfeOrientedSpacing(w);
  503.  
  504.     *height = 
  505.         _XfemOffsetTop(w) + 
  506.         _XfemOffsetBottom(w) +
  507.         2 * tp->clip_shadow_thickness + 
  508.         2 * _XfeOrientedSpacing(w);
  509.  
  510.     if (_XfeOrientedOrientation(w) == XmVERTICAL)
  511.     {
  512.         *width += _XfemPreferredWidth(tp->tool_bar);
  513.  
  514.         *height += 
  515.             (_XfemPreferredHeight(tp->tool_bar) +
  516.              _XfeHeight(tp->backward_arrow));
  517.     }
  518.     else
  519.     {
  520.         *height += _XfemPreferredHeight(tp->tool_bar);
  521.  
  522.         *width += 
  523.             (_XfemPreferredWidth(tp->tool_bar) +
  524.              _XfeWidth(tp->backward_arrow));
  525.     }
  526. }
  527. /*----------------------------------------------------------------------*/
  528. static void
  529. DrawComponents(Widget w,XEvent * event,Region region,XRectangle * clip_rect)
  530. {
  531.     XfeToolScrollPart *    tp = _XfeToolScrollPart(w);
  532.  
  533.     if (tp->clip_shadow_thickness > 0)
  534.     {
  535.         XfeDrawShadowsAroundWidget(w,
  536.                                    tp->clip_area,
  537.                                    _XfemTopShadowGC(w),
  538.                                    _XfemBottomShadowGC(w),
  539.                                    _XfeOrientedSpacing(w),
  540.                                    tp->clip_shadow_thickness,
  541.                                    tp->clip_shadow_type);
  542.     }
  543. }
  544. /*----------------------------------------------------------------------*/
  545. static void
  546. LayoutComponents(Widget w)
  547. {
  548.     /* Vertical */
  549.     if (_XfeOrientedOrientation(w) == XmVERTICAL)
  550.     {
  551.         LayoutVertical(w);
  552.     }
  553.     /* Horizontal */
  554.     else
  555.     {
  556.         LayoutHorizontal(w);
  557.     }
  558.  
  559.     /* Layout the toolbar */
  560.     LayoutToolBar(w);
  561. }
  562. /*----------------------------------------------------------------------*/
  563. static Boolean
  564. AcceptChild(Widget child)
  565. {
  566.     return False;
  567. }
  568. /*----------------------------------------------------------------------*/
  569. static Boolean
  570. InsertChild(Widget child)
  571. {
  572.     Widget                    w = XtParent(child);
  573. /*     XfeToolScrollPart *        tp = _XfeToolScrollPart(w); */
  574.  
  575.     return True;
  576. }
  577. /*----------------------------------------------------------------------*/
  578. static Boolean
  579. DeleteChild(Widget child)
  580. {
  581.     Widget                    w = XtParent(child);
  582. /*     XfeToolScrollPart *        tp = _XfeToolScrollPart(w); */
  583.  
  584.     return True;
  585. }
  586. /*----------------------------------------------------------------------*/
  587.  
  588. /*----------------------------------------------------------------------*/
  589. /*                                                                        */
  590. /* XfeOriented class methods                                            */
  591. /*                                                                        */
  592. /*----------------------------------------------------------------------*/
  593. static void
  594. EnterProc(Widget w,Widget descendant,int x,int y)
  595. {
  596.     _XfeOrientedSetCursorState(w,True);
  597. }
  598. /*----------------------------------------------------------------------*/
  599. static void
  600. LeaveProc(Widget w,Widget descendant,int x,int y)
  601. {
  602.     _XfeOrientedSetCursorState(w,False);
  603. }
  604. /*----------------------------------------------------------------------*/
  605. static void
  606. MotionProc(Widget w,Widget descendant,int x,int y)
  607. {
  608. }
  609. /*----------------------------------------------------------------------*/
  610. static void
  611. DragStart(Widget w,Widget descendant,int x,int y)
  612. {
  613.     printf("DragStart(%s,%s,%d,%d)\n",
  614.            XtName(w),descendant ? XtName(descendant) : "NULL",x,y);
  615.  
  616. #if 0
  617.     /* Make sure the coords are inside the sash */
  618.     if (!SashContainsXY(w,x,y))
  619.     {
  620.         return;
  621.     }
  622.  
  623.     SashDragStart(w,x,y,NULL);
  624. #endif
  625. }
  626. /*----------------------------------------------------------------------*/
  627. static void
  628. DragEnd(Widget w,Widget descendant,int x,int y)
  629. {
  630.     printf("DragEnd(%s,%s,%d,%d) start = (%d,%d)\n",
  631.            XtName(w),
  632.            descendant ? XtName(descendant) : "NULL",
  633.            x,y,
  634.            _XfeOrientedDragStartX(w),
  635.            _XfeOrientedDragStartY(w));
  636.  
  637. #if 0
  638.     SashDragEnd(w,x,y,NULL);
  639. #endif
  640. }
  641. /*----------------------------------------------------------------------*/
  642. static void
  643. DragMotion(Widget w,Widget descendant,int x,int y)
  644. {
  645.     printf("DragMotion(%s,%s,%d,%d)\n",
  646.            XtName(w),descendant ? XtName(descendant) : "NULL",x,y);
  647.  
  648. #if 0
  649.     SashDragMotion(w,x,y,NULL);
  650. #endif
  651. }
  652. /*----------------------------------------------------------------------*/
  653. static void
  654. DescendantMotion(Widget w,Widget descendant,int x,int y)
  655. {
  656.     printf("DescendantMotion(%s,%s,%d,%d)\n",
  657.            XtName(w),descendant ? XtName(descendant) : "NULL",x,y);
  658. }
  659. /*----------------------------------------------------------------------*/
  660. static void
  661. DescendantDragStart(Widget w,Widget descendant,int x,int y)
  662. {
  663. #if 0
  664.     printf("DescendantDragStart(%s,%s,%d,%d)\n",
  665.            XtName(w),descendant ? XtName(descendant) : "NULL",x,y);
  666. #endif
  667.  
  668.     printf("diff = %d\n",_XfeOrientedDragStartY(w) - y);
  669.  
  670. #if 0
  671.     SashDragStart(w,x,y,DescendantFindAttachment(w,descendant));
  672. #endif
  673. }
  674. /*----------------------------------------------------------------------*/
  675. static void
  676. DescendantDragEnd(Widget w,Widget descendant,int x,int y)
  677. {
  678.     printf("DescendantDragEnd(%s,%s,%d,%d) start = (%d,%d)\n",
  679.            XtName(w),
  680.            descendant ? XtName(descendant) : "NULL",
  681.            x,y,
  682.            _XfeOrientedDragStartX(w),
  683.            _XfeOrientedDragStartY(w));
  684.  
  685. #if 0
  686.     SashDragEnd(w,x,y,DescendantFindAttachment(w,descendant));
  687. #endif
  688. }
  689. /*----------------------------------------------------------------------*/
  690. static void
  691. DescendantDragMotion(Widget w,Widget descendant,int x,int y)
  692. {
  693.     XfeToolScrollPart *    tp = _XfeToolScrollPart(w);
  694.     Position            new_pos;
  695.  
  696. #if 0
  697.     printf("DescendantDragMotion(%s,%s,%d,%d)\n",
  698.            XtName(w),descendant ? XtName(descendant) : "NULL",x,y);
  699. #endif
  700.  
  701.     new_pos = tp->tool_bar_position + (y - _XfeOrientedDragStartY(w)) * 1;
  702.  
  703.     _XfeMoveWidget(tp->tool_bar,0,new_pos);
  704.  
  705. #if 0
  706.     SashDragMotion(w,x,y,DescendantFindAttachment(w,descendant));
  707. #endif
  708. }
  709. /*----------------------------------------------------------------------*/
  710.  
  711. /*----------------------------------------------------------------------*/
  712. /*                                                                        */
  713. /* Misc functions                                                        */
  714. /*                                                                        */
  715. /*----------------------------------------------------------------------*/
  716. static void
  717. LayoutVertical(Widget w)
  718. {
  719.     XfeToolScrollPart *    tp = _XfeToolScrollPart(w);
  720.     int                    backward_width = _XfemRectWidth(w) / 2;
  721.     int                    forward_width = _XfemRectWidth(w) - backward_width;
  722.  
  723.  
  724.     /* The backward arrow */
  725.     if (backward_width > 0)
  726.     {
  727.         XtVaSetValues(tp->backward_arrow,XmNarrowDirection,XmARROW_DOWN,NULL);
  728.         
  729.         _XfeConfigureWidget(tp->backward_arrow,
  730.                             _XfemRectX(w),
  731.                             _XfemRectY(w),
  732.                             backward_width,
  733.                             _XfeHeight(tp->backward_arrow));
  734.     }
  735.     
  736.     /* The forward arrow */
  737.     if (forward_width > 0)
  738.     {
  739.         XtVaSetValues(tp->backward_arrow,XmNarrowDirection,XmARROW_UP,NULL);
  740.         
  741.         _XfeConfigureWidget(tp->forward_arrow,
  742.                             
  743.                             _XfeX(tp->backward_arrow) + 
  744.                             _XfeWidth(tp->backward_arrow),
  745.                             
  746.                             _XfemRectY(w),
  747.                             
  748.                             forward_width,
  749.                             
  750.                             _XfeHeight(tp->forward_arrow));
  751.     }
  752.     
  753.     if (backward_width || forward_width)
  754.     {
  755.         _XfeConfigureWidget(tp->clip_area,
  756.                             
  757.                             _XfemRectX(w) + 
  758.                             tp->clip_shadow_thickness +
  759.                             _XfeOrientedSpacing(w),
  760.                             
  761.                             _XfeY(tp->backward_arrow) + 
  762.                             _XfeHeight(tp->backward_arrow) +
  763.                             tp->clip_shadow_thickness +
  764.                             _XfeOrientedSpacing(w),
  765.                             
  766.                             _XfemRectWidth(w) - 
  767.                             2 * tp->clip_shadow_thickness -
  768.                             2 * _XfeOrientedSpacing(w),
  769.                                 
  770.                             _XfemRectHeight(w) - 
  771.                             _XfeHeight(tp->backward_arrow) -
  772.                             2 * tp->clip_shadow_thickness -
  773.                             2 * _XfeOrientedSpacing(w));
  774.         
  775.     }
  776. }
  777. /*----------------------------------------------------------------------*/
  778. static void
  779. LayoutHorizontal(Widget w)
  780. {
  781.     XfeToolScrollPart *    tp = _XfeToolScrollPart(w);
  782.     int                    backward_height = _XfemRectHeight(w) / 2;
  783.     int                    forward_height = _XfemRectHeight(w) - backward_height;
  784.     
  785.     /* The backward arrow */
  786.     if (backward_height > 1)
  787.     {
  788.         XtVaSetValues(tp->backward_arrow,XmNarrowDirection,XmARROW_LEFT,NULL);
  789.         
  790.         _XfeConfigureWidget(tp->backward_arrow,
  791.                             _XfemRectX(w),
  792.                             _XfemRectY(w),
  793.                             _XfeWidth(tp->backward_arrow),
  794.                             backward_height);
  795.     }
  796.     
  797.     /* The forward arrow */
  798.     if (forward_height > 1)
  799.     {
  800.         XtVaSetValues(tp->forward_arrow,XmNarrowDirection,XmARROW_RIGHT,NULL);
  801.         
  802.         _XfeConfigureWidget(tp->forward_arrow,
  803.                             
  804.                             _XfemRectX(w),
  805.                             
  806.                             _XfeY(tp->backward_arrow) + 
  807.                             _XfeHeight(tp->backward_arrow),
  808.                             
  809.                             _XfeWidth(tp->forward_arrow),
  810.                             
  811.                             forward_height);
  812.     }
  813.     
  814.     if (backward_height || forward_height)
  815.     {
  816.         _XfeConfigureWidget(tp->clip_area,
  817.                             
  818.                             _XfeX(tp->backward_arrow) + 
  819.                             _XfeWidth(tp->backward_arrow) +
  820.                             tp->clip_shadow_thickness +
  821.                             _XfeOrientedSpacing(w),
  822.                             
  823.                             _XfemRectY(w) + 
  824.                             tp->clip_shadow_thickness +
  825.                             _XfeOrientedSpacing(w),
  826.                             
  827.                             _XfemRectWidth(w) - 
  828.                             _XfeWidth(tp->backward_arrow) -
  829.                             2 * tp->clip_shadow_thickness -
  830.                             2 * _XfeOrientedSpacing(w),
  831.                             
  832.                             _XfemRectHeight(w) -
  833.                             2 * tp->clip_shadow_thickness -
  834.                             2 * _XfeOrientedSpacing(w));
  835.     }
  836. }
  837. /*----------------------------------------------------------------------*/
  838. static void
  839. LayoutToolBar(Widget w)
  840. {
  841.     XfeToolScrollPart *    tp = _XfeToolScrollPart(w);
  842.  
  843.     if (!_XfeIsAlive(tp->tool_bar))
  844.     {
  845.         return;
  846.     }
  847.  
  848. /*     tp->tool_bar_position = 20; */
  849.  
  850.     if (_XfeOrientedOrientation(w) == XmVERTICAL)
  851.     {
  852.         _XfeMoveWidget(tp->tool_bar,0,tp->tool_bar_position);
  853.     }
  854.     else
  855.     {
  856.         _XfeMoveWidget(tp->tool_bar,tp->tool_bar_position,0);
  857.     }
  858. }
  859. /*----------------------------------------------------------------------*/
  860.  
  861. /*----------------------------------------------------------------------*/
  862. /*                                                                        */
  863. /* XfeToolScroll Public Methods                                            */
  864. /*                                                                        */
  865. /*----------------------------------------------------------------------*/
  866. /* extern*/ Widget
  867. XfeCreateToolScroll(Widget pw,char * name,Arg * av,Cardinal ac)
  868. {
  869.    return XtCreateWidget(name,xfeToolScrollWidgetClass,pw,av,ac);
  870. }
  871. /*----------------------------------------------------------------------*/
  872.