home *** CD-ROM | disk | FTP | other *** search
/ PC World Komputer 1998 May / Pcwk5b98.iso / Borland / Cplus45 / BC45 / OWLINC.PAK / SCROLLBA.H < prev    next >
C/C++ Source or Header  |  1995-08-29  |  3KB  |  115 lines

  1. //----------------------------------------------------------------------------
  2. // ObjectWindows
  3. // (C) Copyright 1991, 1994 by Borland International, All Rights Reserved
  4. //
  5. //   Defines class TScrollBar.  This defines the basic
  6. //   behavior of all scrollbar controls.
  7. //----------------------------------------------------------------------------
  8. #if !defined(OWL_SCROLLBAR_H)
  9. #define OWL_SCROLLBAR_H
  10.  
  11. #if !defined(OWL_CONTROL_H)
  12. # include <owl/control.h>
  13. #endif
  14.  
  15. //
  16. //  class TScrollBar
  17. //  ----- ----------
  18. //
  19. class _OWLCLASS TScrollBar : public TControl {
  20.   public:
  21.     TScrollBar(TWindow*        parent,
  22.                int             id,
  23.                int x, int y, int w, int h,
  24.                bool            isHScrollBar,
  25.                TModule*        module = 0);
  26.  
  27.     TScrollBar(TWindow* parent, int resourceId, TModule*   module = 0);
  28.  
  29.     //
  30.     // Virtual functions to interface to scrollbars & derived
  31.     //
  32.     virtual void  GetRange(int& min, int& max) const
  33.                     {::GetScrollRange(HWindow, SB_CTL, &min, &max);}
  34.     virtual int   GetPosition() const {return ::GetScrollPos(HWindow, SB_CTL);}
  35.     virtual void  SetRange(int min, int max)
  36.                     {::SetScrollRange(HWindow, SB_CTL, min, max, false);}
  37.     virtual void  SetPosition(int thumbPos);
  38.     virtual int   DeltaPos(int delta);
  39.  
  40.     //
  41.     // Override TWindow virtual member functions
  42.     //
  43.     uint          Transfer(void* buffer, TTransferDirection direction);
  44.  
  45.     //
  46.     // called by EvHScroll and EvVScroll response table handlers
  47.     //
  48.     // these routines all end up calling SetPosition()
  49.     //
  50.     virtual void  SBLineUp();
  51.     virtual void  SBLineDown();
  52.     virtual void  SBPageUp();
  53.     virtual void  SBPageDown();
  54.     virtual void  SBThumbPosition(int thumbPos);
  55.     virtual void  SBThumbTrack(int thumbPos);
  56.     virtual void  SBTop();
  57.     virtual void  SBBottom();
  58.     virtual void  SBEndScroll();
  59.  
  60.     //
  61.     // response table handlers that call above virtual functions in 
  62.     // response to messages sent by to us by TWindow::DispatchScroll()
  63.     //
  64.     void          EvHScroll(uint scrollCode, uint thumbPos, HWND hWndCtl);
  65.     void          EvVScroll(uint scrollCode, uint thumbPos, HWND hWndCtl);
  66.     
  67.   public:
  68.     int  LineMagnitude;
  69.     int  PageMagnitude;
  70.  
  71.   protected:
  72.     //
  73.     // Override TWindow virtual member functions
  74.     //
  75.     char far*     GetClassName();
  76.     void          SetupWindow();
  77.  
  78.   private:
  79.     //
  80.     // hidden to prevent accidental copying or assignment
  81.     //
  82.     TScrollBar(const TScrollBar&);
  83.     TScrollBar& operator=(const TScrollBar&);
  84.  
  85.   DECLARE_RESPONSE_TABLE(TScrollBar);
  86.   DECLARE_STREAMABLE(_OWLCLASS, TScrollBar, 1);
  87. };
  88.  
  89. //
  90. // scroll bar notification macros. methods are: void method()
  91. //
  92. // EV_SB_LINEDOWN(id, method)
  93. // EV_SB_LINEUP(id, method)
  94. // EV_SB_PAGEDOWN(id, method)
  95. // EV_SB_PAGEUP(id, method)
  96. // EV_SB_TOP(id, method)
  97. // EV_SB_BOTTOM(id, method)
  98. // EV_SB_THUMBPOSITION(id, method)
  99. // EV_SB_ENDSCROLL(id, method)
  100. // EV_SB_BEGINTRACK(id, method)
  101.  
  102. //
  103. //  struct TScrollBarData
  104. //  ------ --------------
  105. //
  106. //  TScrollBar transfer structure
  107. //
  108. struct TScrollBarData {
  109.   int  LowValue;
  110.   int  HighValue;
  111.   int  Position;
  112. };
  113.  
  114. #endif  // OWL_SCROLLBAR_H
  115.