home *** CD-ROM | disk | FTP | other *** search
/ OS/2 Shareware BBS: 10 Tools / 10-Tools.zip / yacl-012.zip / ui / scrolbar.h < prev    next >
C/C++ Source or Header  |  1995-04-08  |  5KB  |  204 lines

  1.  
  2.  
  3. #ifndef _scrolbar_h_
  4. #define _scrolbar_h_
  5.  
  6.  
  7.  
  8.  
  9.  
  10. /*
  11.  *
  12.  *          Copyright (C) 1994, M. A. Sridhar
  13.  *  
  14.  *
  15.  *     This software is Copyright M. A. Sridhar, 1994. You are free
  16.  *     to copy, modify or distribute this software  as you see fit,
  17.  *     and to use  it  for  any  purpose, provided   this copyright
  18.  *     notice and the following   disclaimer are included  with all
  19.  *     copies.
  20.  *
  21.  *                        DISCLAIMER
  22.  *
  23.  *     The author makes no warranties, either expressed or implied,
  24.  *     with respect  to  this  software, its  quality, performance,
  25.  *     merchantability, or fitness for any particular purpose. This
  26.  *     software is distributed  AS IS.  The  user of this  software
  27.  *     assumes all risks  as to its quality  and performance. In no
  28.  *     event shall the author be liable for any direct, indirect or
  29.  *     consequential damages, even if the  author has been  advised
  30.  *     as to the possibility of such damages.
  31.  *
  32.  */
  33.  
  34.  
  35.  
  36.  
  37.  
  38. // A scroll bar as a simple visual object.
  39. // The model for this object is a sub-interval of the interval that
  40. // represents the entire range of the scroll bar. The selection is undefined.
  41. // The ScrollBar object maintains a set of
  42. // clients that are notified of scrolling events (see {\small\tt event.h}
  43. // for the kinds of scrolling events supported).
  44.  
  45.  
  46.  
  47. #if defined(__GNUC__)
  48. #pragma interface
  49. #endif
  50.  
  51.  
  52. #include "base/clntset.h"
  53. #include "ui/simple.h"
  54. #include "ui/interval.h"
  55.  
  56. class CL_EXPORT UI_ScrollBar: public UI_SimpleVObject {
  57.  
  58. public:
  59.  
  60.     CL_Interval& Range ();
  61.     // Return the current extent (i.e., the total range) of the scroll
  62.     // bar. The return value may be modified.
  63.     
  64.     long& LineAmount ();
  65.     // Return the amount to scroll by when the line-down/line-up key or
  66.     // button is used. The return value is a reference and therefore may be
  67.     // modified by the caller.
  68.  
  69.     long& PageAmount ();
  70.     // Return the amount to scroll by when the "page-by" key or button
  71.     // is used. The return value is a reference and therefore may be
  72.     // modified by the caller.
  73.  
  74.     CL_ClientSet& ClientSet ();
  75.     // Return the set of clients for this scroll bar. The set may be
  76.     // modified, since  a reference is returned.
  77.  
  78.     bool& SmoothScroll ();
  79.     // Return the ``smooth scrolling'' parameter for this scroll bar. If this
  80.     // parameter is TRUE, the scroll bar notifies its clients on every
  81.     // scrolling (mouse) event; if it is FALSE, the notification occurs only
  82.     // when the mouse movement is completed.
  83.     
  84.     
  85.     //-------------Inherited SimpleVObject methods---------------
  86.  
  87.  
  88.     virtual UI_WindowClass WindowClass () const;
  89.     
  90.     const char* ClassName () const { return "UI_ScrollBar";};
  91.  
  92. protected:
  93.  
  94.     //
  95.     //------------------Construction-------------------
  96.     //
  97.  
  98.  
  99.     UI_ScrollBar (UI_VObjCollection* parent, const UI_Rectangle& shape,
  100.                   UI_ViewID id = -1, long style = -1);
  101.  
  102.     ~UI_ScrollBar ();
  103.  
  104.     bool MakeVisualElement ();
  105.     
  106.     void _PrivateInitialize ();
  107.  
  108.     bool HandleEvent (UI_Event* e);
  109.  
  110.     bool _ModelChanged (CL_Object&, long);
  111.  
  112.     virtual bool _RangeChanged (CL_Object&, long) = 0;
  113.     // Force this to be an abstract class
  114.  
  115.     CL_Interval   _range;
  116.     CL_ClientSet  _clientSet;
  117.     long          _lineAmount;
  118.     long          _pageAmount;
  119.     bool          _smoothScroll;
  120.     bool          _vertical;
  121.  
  122. private:
  123. #if defined(__X_MOTIF__)
  124.     static void ScrollBarCallback (struct _WidgetRec*, void *, void *);
  125.     // [X/Motif-specific.]
  126.     
  127. #endif
  128. };
  129.  
  130.  
  131.  
  132.  
  133.  
  134. class CL_EXPORT UI_VScrollBar: public UI_ScrollBar {
  135.  
  136. public:
  137.  
  138.  
  139.     // ------------------Construction-------------------
  140.     UI_VScrollBar (UI_VObjCollection* parent, const UI_Rectangle& shape,
  141.                    UI_ViewID id = -1, long style = -1);
  142.  
  143.     const char* ClassName () const {return "UI_VScrollBar";};
  144.  
  145. protected:
  146.  
  147.     ~UI_VScrollBar () {};
  148.  
  149.     virtual bool _RangeChanged (CL_Object& o, long l)
  150.         {return UI_ScrollBar::_RangeChanged (o, l);};
  151.     
  152. };
  153.  
  154.  
  155. class CL_EXPORT UI_HScrollBar: public UI_ScrollBar {
  156.  
  157. public:
  158.  
  159.     // ------------------Construction-------------------
  160.     
  161.     UI_HScrollBar (UI_VObjCollection* parent, const UI_Rectangle& shape,
  162.                    UI_ViewID id = -1, long style = -1);
  163.  
  164.     const char* ClassName () const {return "UI_HScrollBar";};
  165.  
  166. protected:
  167.  
  168.     ~UI_HScrollBar () {};
  169.  
  170.     virtual bool _RangeChanged (CL_Object& o, long l)
  171.         {return UI_ScrollBar::_RangeChanged (o, l);};
  172.     
  173. };
  174.  
  175.  
  176.  
  177.  
  178. inline long& UI_ScrollBar::LineAmount ()
  179. {
  180.     return _lineAmount;
  181. }
  182.  
  183.  
  184.  
  185. inline long& UI_ScrollBar::PageAmount ()
  186. {
  187.     return _pageAmount;
  188. }
  189.  
  190.  
  191. inline CL_ClientSet& UI_ScrollBar::ClientSet ()
  192. {
  193.     return _clientSet;
  194. }
  195.  
  196. inline bool& UI_ScrollBar::SmoothScroll ()
  197. {
  198.     return _smoothScroll;
  199. }
  200.  
  201.  
  202.  
  203. #endif
  204.