Leaked source code of windows server 2003
You can not select more than 25 topics Topics must start with a letter or number, can include dashes ('-') and can be up to 35 characters long.

125 lines
4.4 KiB

  1. /*
  2. * ScrollBar
  3. */
  4. #ifndef DUI_CONTROL_SCROLLBAR_H_INCLUDED
  5. #define DUI_CONTROL_SCROLLBAR_H_INCLUDED
  6. #pragma once
  7. namespace DirectUI
  8. {
  9. ////////////////////////////////////////////////////////
  10. // ScrollBar
  11. // Scroll bar layout order
  12. #define SBO_Normal 0x00043210
  13. #define SBO_ArrowsAtTop 0x00032140
  14. #define SBO_ArrowsAtBottom 0x00040321
  15. // Scroll event
  16. struct ScrollEvent : Event
  17. {
  18. int dPos;
  19. };
  20. // Class definition
  21. class ScrollBar : public Element
  22. {
  23. public:
  24. static HRESULT Create(OUT Element** ppElement) { return Create(true, ppElement); }
  25. static HRESULT Create(bool fBuildSubTree, OUT Element** ppElement);
  26. // Generic events
  27. virtual void OnEvent(Event* pEvent);
  28. // System events
  29. virtual bool OnPropertyChanging(PropertyInfo* ppi, int iIndex, Value* pvOld, Value* pvNew);
  30. virtual void OnPropertyChanged(PropertyInfo* ppi, int iIndex, Value* pvOld, Value* pvNew);
  31. // Self-layout methods
  32. void _SelfLayoutDoLayout(int dWidth, int dHeight);
  33. SIZE _SelfLayoutUpdateDesiredSize(int dConstW, int dConstH, Surface* psrf);
  34. // Event types
  35. static UID Scroll;
  36. // Property definitions
  37. static PropertyInfo* PositionProp;
  38. static PropertyInfo* MinimumProp;
  39. static PropertyInfo* MaximumProp;
  40. static PropertyInfo* PageProp;
  41. static PropertyInfo* LineProp;
  42. static PropertyInfo* VerticalProp;
  43. static PropertyInfo* ProportionalProp;
  44. static PropertyInfo* OrderProp;
  45. // Quick property accessors
  46. int GetPosition() DUIQuickGetter(int, GetInt(), Position, Specified)
  47. int GetMaximum() DUIQuickGetter(int, GetInt(), Maximum, Specified)
  48. int GetMinimum() DUIQuickGetter(int, GetInt(), Minimum, Specified)
  49. int GetPage() DUIQuickGetter(int, GetInt(), Page, Specified)
  50. int GetLine() DUIQuickGetter(int, GetInt(), Line, Specified)
  51. int GetOrder() DUIQuickGetter(int, GetInt(), Order, Specified)
  52. bool GetProportional() DUIQuickGetter(bool, GetBool(), Proportional, Specified)
  53. bool GetVertical() DUIQuickGetter(bool, GetBool(), Vertical, Specified)
  54. HRESULT SetPosition(int v) DUIQuickSetter(CreateInt(v), Position)
  55. HRESULT SetMaximum(int v) DUIQuickSetter(CreateInt(v), Maximum)
  56. HRESULT SetMinimum(int v) DUIQuickSetter(CreateInt(v), Minimum)
  57. HRESULT SetPage(int v) DUIQuickSetter(CreateInt(v), Page)
  58. HRESULT SetLine(int v) DUIQuickSetter(CreateInt(v), Line)
  59. HRESULT SetOrder(int v) DUIQuickSetter(CreateInt(v), Order)
  60. HRESULT SetProportional(bool v) DUIQuickSetter(CreateBool(v), Proportional)
  61. HRESULT SetVertical(bool v) DUIQuickSetter(CreateBool(v), Vertical)
  62. int LineUp(UINT nCount = 1) { SetPosition(GetPosition() - (nCount * GetLine())); return GetPosition(); }
  63. int LineDown(UINT nCount = 1) { SetPosition(GetPosition() + (nCount * GetLine())); return GetPosition(); }
  64. int PageUp(UINT nCount = 1) { SetPosition(GetPosition() - (nCount * GetPageInc())); return GetPosition(); }
  65. int PageDown(UINT nCount = 1) { SetPosition(GetPosition() + (nCount * GetPageInc())); return GetPosition(); }
  66. int Home() { SetPosition(GetMinimum()); return GetPosition(); }
  67. int End() { SetPosition(GetMaximum()); return GetPosition(); }
  68. bool IsScrollable();
  69. bool IsPinned() { return _fPinned; }
  70. // ClassInfo accessors (static and virtual instance-based)
  71. static IClassInfo* Class;
  72. virtual IClassInfo* GetClassInfo() { return Class; }
  73. static HRESULT Register();
  74. ScrollBar() { }
  75. HRESULT Initialize(bool fBuildSubTree);
  76. virtual ~ScrollBar() { }
  77. protected:
  78. #define SP_LineUp 0
  79. #define SP_PageUp 1
  80. #define SP_Thumb 2
  81. #define SP_PageDown 3
  82. #define SP_LineDown 4
  83. #define SP_Count 5
  84. Element* _peParts[SP_Count];
  85. #define _peLineUp _peParts[SP_LineUp]
  86. #define _peLineDown _peParts[SP_LineDown]
  87. #define _pePageUp _peParts[SP_PageUp]
  88. #define _pePageDown _peParts[SP_PageDown]
  89. #define _peThumb _peParts[SP_Thumb]
  90. private:
  91. int GetPageInc();
  92. int _posTop;
  93. int _cTrack;
  94. bool _fPinned;
  95. };
  96. } // namespace DirectUI
  97. #endif // DUI_CONTROL_SCROLLBAR_H_INCLUDED