home *** CD-ROM | disk | FTP | other *** search
/ Liren Large Software Subsidy 7 / 07.iso / c / c083 / 13.ddi / NOTEBOOK.PAK / VSCROLL.H < prev   
Encoding:
C/C++ Source or Header  |  1993-12-02  |  5.3 KB  |  115 lines

  1. //----------------------------------------------------------------------------
  2. //    vscroll.h
  3. //----------------------------------------------------------------------------
  4. //    copyright (c) 1993 Borland International
  5. //----------------------------------------------------------------------------
  6. #ifndef VSCROLLINC
  7.  
  8. #define VSCROLLINC
  9. #include <owl\window.h>
  10. //----------------------------------------------------------------------------
  11. #define max(a,b)            (((a) > (b)) ? (a) : (b))
  12. #define min(a,b)            (((a) < (b)) ? (a) : (b))
  13. //----------------------------------------------------------------------------
  14. #define NW_VSCROLL    WM_USER+0x2802    // custom message used to talk to parent
  15.             // (params are same as for WM_VSCROLL msg)
  16.  
  17. //---- all 3 defines below use currently selected brush ----
  18. #define FASTRECT(dc,l,t,w,h)  dc.PatBlt(l, t, w, h, PATCOPY)
  19. #define FASTVLINE(dc,l,t,h)  dc.PatBlt(l, t, 1, h, PATCOPY)
  20. #define FASTHLINE(dc,l,t,w)  dc.PatBlt(l, t, w, 1, PATCOPY)
  21.  
  22. #define VSB_NOTDOWN    1    // mouse not currently down
  23. #define VSB_TOPARROW    2    // mouse went down at tab scroll top button
  24. #define VSB_BOTTOMARROW    3    // mouse went down at tab scroll bottom button
  25. #define VSB_TOPTHUMB    4    // mouse went down at tab to top of thumb
  26. #define VSB_BOTTOMTHUMB    5    // mouse went down at tab to bottom of thumb
  27.  
  28. #define VSB_FORCEALL    6    // force entire scrollbar redraw
  29. #define VSB_THUMB    7    // mouse went down at tab scroll thumb button
  30. #define VSB_THUMBFOCUS    8    // draw solid at origval and focus rect at new
  31.  
  32. // repaint param values to SetValue()
  33. #define SV_NOREPAINT   0    // don't update thumb display
  34. #define SV_REPAINT     1    // repaint thumb position
  35. #define SV_THUMBTRACK  2    // paint thumb position in thumb tracking style
  36. //----------------------------------------------------------------------------
  37. class TVScroll             
  38. {
  39.   public:
  40.     TVScroll(TWindow *Parent, int x, int y, int width, int height, 
  41.      int idnum = 0, int Lowval = 0, int Highval = 100, int initval = 0, 
  42.     BOOL frame3d = FALSE, BOOL Arrowline = TRUE, BOOL Thumbmove = FALSE, 
  43.     int Repeatdelay = 250);
  44.     ~TVScroll();
  45.  
  46.     int GetScrollPos();
  47.     void GetScrollRange(int &low, int &high);
  48.     int SetScrollPos(int newval, BOOL redraw);
  49.     void SetScrollRange(int lowval, int highval, BOOL redraw);
  50.     void ShowScrollBar(BOOL show);
  51.  
  52.     void ForcePaint();
  53.     void ChangeRect(TRect &newrect, BOOL repaint = TRUE);
  54.     void SysColorChange();
  55.     //----- use below 3 funcs to pass along mouse events --------
  56.     BOOL MyLButtonDown(UINT hitTest, TPoint& winpt);
  57.     BOOL MyMouseMove(UINT hitTest, TPoint& winpt);
  58.     BOOL MyLButtonUp(UINT hitTest, TPoint& winpt);
  59.   protected:
  60.     //----- various measurements (window-relative coordinates) ------
  61.     TRect framerect;        // rect for 3d frame
  62.     TRect sbrect;        // rect for actual scrollbar 
  63.     int sbheight;        // height of actual scrollbar
  64.     int sbwidth;        // width of actual scrollbar
  65.     int sqsize;            // size of arrow & thumb squares
  66.     int barsize;        // thickness of arrow inner bars (1-2 pixels)
  67.     int trackheight;        // height of thumb track (overlap 2 black lines)
  68.     int trackyoff;        // yoffset where thumb track starts
  69.     int thumbyoff;        // where thumb is currently sitting
  70.     int thumbgrabyoff;        // offset from start of thumb to mouse pt
  71.     int lastfocusyoff;        // last yoff of thumb focus rect
  72.     //---- non measurement items --------
  73.     TWindow *parent;        // parent window of this sb
  74.     int trange;            // cnt-1 of # of thumb positions in mouse track
  75.     int vrange;            // cnt-1 of # of values in low...high range
  76.     int mousedown;        // part of sb that mouse went down on
  77.     int newloc;            // new value for mousedown
  78.     int displaystate;        // state of scrollbar as currently displayed
  79.     int lowval;            // lowest value for scrollbar
  80.     int highval;        // highest value for scrollbar
  81.     int curval;            // current value (position) of scrollbar
  82.     int origval;        // value before mouse capture
  83.     int scrollmsg;        // WM_HSCROLL or NW_HSCROLL
  84.     int repeatdelay;        // # of milliseconds to delay mouse repeat
  85.     long mylongid;        // my idnum as HIWORD() of a long value
  86.     BOOL frame3d;        // TRUE if 3d frame around sb requested
  87.     BOOL arrowline;        // TRUE if line of arrow needed on scroll button
  88.     BOOL thumbmove;        // TRUE if tracking thumb moved (vs. focus rect)
  89.     BOOL showit;        // TRUE if should show & be enabled
  90.     //------------------------------------------
  91.     TBrush *framebrush;
  92.     TBrush *trackbrush;
  93.     TBrush *hilitebrush;
  94.     TBrush *shadowbrush;
  95.     TBrush *facebrush;
  96.     //------------------------------------------
  97.     void BuildBrushes();
  98.     void DeleteBrushes();
  99.     int GetMouseLoc(TPoint &winpt);
  100.     void AutoScrollMouse();
  101.     void AutoScrollAction();
  102.     void MyPaint(int newstate);
  103.     void DrawFrames(TDC &mydc);
  104.     void DrawTopArrow(TDC &mydc, BOOL isdown);
  105.     void DrawBottomArrow(TDC &mydc, BOOL isdown);
  106.     void DrawTopTrack(TDC &mydc, BOOL isdown);
  107.     void DrawBottomTrack(TDC &mydc, BOOL isdown);
  108.     void DrawThumb(TDC &mydc, BOOL drawfocus, BOOL erasefocus);
  109.     void DrawArrowButton(TDC &mydc, TRect brect, BOOL isdown, BOOL top);
  110.     void DrawShadeFrame(TDC &mydc, TRect &myrect, BOOL forthumb);
  111.     void DrawDownFrame(TDC &mydc, TRect &myrect);
  112. };
  113. //----------------------------------------------------------------------------
  114. #endif
  115.