1
0

scrollwnd.h 6.2 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220
  1. #ifndef _SCROLLWND_H
  2. #define _SCROLLWND_H
  3. /* minimum size of scrollbar before inserted buttons are
  4. hidden to make room when the window is sized too small */
  5. #define MIN_COOLSB_SIZE 24
  6. /* min size of scrollbar when resizing a button, before the
  7. resize is stopped because the scrollbar has gotten too small */
  8. #define MINSCROLLSIZE 50
  9. /* a normal scrollbar "snaps" its scroll-thumb back into position if
  10. you move the mouse too far away from the window, whilst you are
  11. dragging the thumb, that is. #undeffing this results in the thumb
  12. never snapping back into position, no matter how far away you move
  13. the mouse */
  14. #define SNAP_THUMB_BACK
  15. /* distance (in pixels) the mouse must move away from the thumb
  16. during tracking to cause the thumb bar to snap back to its
  17. starting place. Has no effect unless SNAP_THUMB_BACK is defined */
  18. #define THUMBTRACK_SNAPDIST 128
  19. #include <windows.h>
  20. // To complement the exisiting SB_HORZ, SB_VERT, SB_BOTH
  21. // scrollbar identifiers
  22. #define COOLSB_NONE (-1)
  23. #define SB_INSBUT (-2)
  24. //
  25. // Arrow size defines
  26. //
  27. #define SYSTEM_METRIC (-1)
  28. //
  29. // general scrollbar styles
  30. //
  31. // use the standard ESB_DISABLE_xxx flags to represent the
  32. // enabled / disabled states. (defined in winuser.h)
  33. //
  34. #define CSBS_THUMBALWAYS 4
  35. #define CSBS_VISIBLE 8
  36. //cool scrollbar styles for Flat scrollbars
  37. #define CSBS_NORMAL 0
  38. #define CSBS_FLAT 1
  39. #define CSBS_HOTTRACKED 2
  40. //
  41. // Button mask flags for indicating which members of SCROLLBUT
  42. // to use during a button insertion / modification
  43. //
  44. #define SBBF_TYPE 0x0001
  45. #define SBBF_ID 0x0002
  46. #define SBBF_PLACEMENT 0x0004
  47. #define SBBF_SIZE 0x0008
  48. #define SBBF_BITMAP 0x0010
  49. #define SBBF_ENHMETAFILE 0x0020
  50. //#define SBBF_OWNERDRAW 0x0040 //unused at present
  51. #define SBBF_CURSOR 0x0080
  52. #define SBBF_BUTMINMAX 0x0100
  53. #define SBBF_STATE 0x0200
  54. //button styles (states)
  55. #define SBBS_NORMAL 0
  56. #define SBBS_PUSHED 1
  57. #define SBBS_CHECKED SBBS_PUSHED
  58. //
  59. // scrollbar button types
  60. //
  61. #define SBBT_PUSHBUTTON 1 //standard push button
  62. #define SBBT_TOGGLEBUTTON 2 //toggle button
  63. #define SBBT_FIXED 3 //fixed button (non-clickable)
  64. #define SBBT_FLAT 4 //blank area (flat, with border)
  65. #define SBBT_BLANK 5 //blank area (flat, no border)
  66. #define SBBT_DARK 6 //dark blank area (flat)
  67. #define SBBT_OWNERDRAW 7 //user draws the button via a WM_NOTIFY
  68. #define SBBT_MASK 0x1f //mask off low 5 bits
  69. //button type modifiers
  70. #define SBBM_RECESSED 0x0020 //recessed when clicked (like Word 97)
  71. #define SBBM_LEFTARROW 0x0040
  72. #define SBBM_RIGHTARROW 0x0080
  73. #define SBBM_UPARROW 0x0100
  74. #define SBBM_DOWNARROW 0x0200
  75. #define SBBM_RESIZABLE 0x0400
  76. #define SBBM_TYPE2 0x0800
  77. #define SBBM_TYPE3 0x1000
  78. #define SBBM_TOOLTIPS 0x2000 //currently unused (define COOLSB_TOOLTIPS in userdefs.h)
  79. //button placement flags
  80. #define SBBP_LEFT 1
  81. #define SBBP_RIGHT 2
  82. #define SBBP_TOP 1 //3
  83. #define SBBP_BOTTOM 2 //4
  84. //
  85. // Button command notification codes
  86. // for sending with a WM_COMMAND message
  87. //
  88. #define CSBN_BASE 0
  89. #define CSBN_CLICKED (1 + CSBN_BASE)
  90. #define CSBN_HILIGHT (2 + CSBN_BASE)
  91. //
  92. // Minimum size in pixels of a scrollbar thumb
  93. //
  94. #define MINTHUMBSIZE_NT4 9
  95. #define MINTHUMBSIZE_2000 7
  96. //define some more hittest values for our cool-scrollbar
  97. #define HTSCROLL_LEFT (SB_LINELEFT)
  98. #define HTSCROLL_RIGHT (SB_LINERIGHT)
  99. #define HTSCROLL_UP (SB_LINEUP)
  100. #define HTSCROLL_DOWN (SB_LINEDOWN)
  101. #define HTSCROLL_THUMB (SB_THUMBTRACK)
  102. #define HTSCROLL_PAGEGUP (SB_PAGEUP)
  103. #define HTSCROLL_PAGEGDOWN (SB_PAGEDOWN)
  104. #define HTSCROLL_PAGELEFT (SB_PAGELEFT)
  105. #define HTSCROLL_PAGERIGHT (SB_PAGERIGHT)
  106. #define HTSCROLL_NONE (-1)
  107. #define HTSCROLL_NORMAL (-1)
  108. #define HTSCROLL_INSERTED (128)
  109. #define HTSCROLL_PRE (32 | HTSCROLL_INSERTED)
  110. #define HTSCROLL_POST (64 | HTSCROLL_INSERTED)
  111. //
  112. // SCROLLBAR datatype. There are two of these structures per window
  113. //
  114. #define SCROLLBAR_LISTVIEW 1 // scrollbar is for a listview
  115. typedef struct
  116. {
  117. UINT fScrollFlags; //flags
  118. BOOL fScrollVisible; //if this scrollbar visible?
  119. SCROLLINFO scrollInfo; //positional data (range, position, page size etc)
  120. int nArrowLength; //perpendicular size (height of a horizontal, width of a vertical)
  121. int nArrowWidth; //parallel size (width of horz, height of vert)
  122. //data for inserted buttons
  123. int nButSizeBefore; //size to the left / above the bar
  124. int nButSizeAfter; //size to the right / below the bar
  125. BOOL fButVisibleBefore; //if the buttons to the left are visible
  126. BOOL fButVisibleAfter; //if the buttons to the right are visible
  127. int nBarType; //SB_HORZ / SB_VERT
  128. UINT fFlatScrollbar; //do we display flat scrollbars?
  129. int nMinThumbSize;
  130. int flags;
  131. } SCROLLBAR;
  132. //
  133. // PRIVATE INTERNAL FUNCTIONS
  134. //
  135. #define COOLSB_TIMERID1 65533 //initial timer
  136. #define COOLSB_TIMERID2 65534 //scroll message timer
  137. #define COOLSB_TIMERID3 -14 //mouse hover timer
  138. #define COOLSB_TIMERINTERVAL1 300
  139. #define COOLSB_TIMERINTERVAL2 55
  140. #define COOLSB_TIMERINTERVAL3 20 //mouse hover time
  141. //
  142. // direction: 0 - same axis as scrollbar (i.e. width of a horizontal bar)
  143. // 1 - perpendicular dimesion (i.e. height of a horizontal bar)
  144. //
  145. #define SM_CXVERTSB 1
  146. #define SM_CYVERTSB 0
  147. #define SM_CXHORZSB 0
  148. #define SM_CYHORZSB 1
  149. #define SM_SCROLL_WIDTH 1
  150. #define SM_SCROLL_LENGTH 0
  151. class ScrollWnd {
  152. public:
  153. ScrollWnd(HWND hwnd, int flags=0);
  154. ~ScrollWnd();
  155. void update();
  156. HWND m_hwnd;
  157. UINT bars; //which of the scrollbars do we handle? SB_VERT / SB_HORZ / SB_BOTH
  158. WNDPROC oldproc; //old window procedure to call for every message
  159. BOOL fWndUnicode;
  160. SCROLLBAR sbarHorz; //one scrollbar structure each for
  161. SCROLLBAR sbarVert; //the horizontal and vertical scrollbars
  162. BOOL fThumbTracking; // are we currently thumb-tracking??
  163. BOOL fLeftScrollbar; // support the WS_EX_LEFTSCROLLBAR style
  164. //size of the window borders
  165. int cxLeftEdge, cxRightEdge;
  166. int cyTopEdge, cyBottomEdge;
  167. // To prevent calling original WindowProc in response
  168. // to our own temporary style change (fixes TreeView problem)
  169. BOOL bPreventStyleChange;
  170. void updatesb(int fnBar, BOOL *fRecalcFrame);
  171. void disableHorzScroll();
  172. //int setScrollInfo(int fnBar, LPSCROLLINFO lpsi, BOOL fRedraw);
  173. int m_disable_hscroll;
  174. int m_xp_theme_disabled;
  175. };
  176. #endif