scrarrow.h 4.1 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111
  1. ///////////////////////////////////////////////////////////////////////////////
  2. // Name: wx/univ/scrarrow.h
  3. // Purpose: wxScrollArrows class
  4. // Author: Vadim Zeitlin
  5. // Modified by:
  6. // Created: 22.01.01
  7. // Copyright: (c) 2001 SciTech Software, Inc. (www.scitechsoft.com)
  8. // Licence: wxWindows licence
  9. ///////////////////////////////////////////////////////////////////////////////
  10. #ifndef _WX_UNIV_SCRARROW_H_
  11. #define _WX_UNIV_SCRARROW_H_
  12. // ----------------------------------------------------------------------------
  13. // wxScrollArrows is not a control but just a class containing the common
  14. // functionality of scroll arrows, whether part of scrollbars, spin ctrls or
  15. // anything else.
  16. //
  17. // To customize its behaviour, wxScrollArrows doesn't use any virtual methods
  18. // but instead a callback pointer to a wxControlWithArrows object which is used
  19. // for all control-dependent stuff. Thus, to use wxScrollArrows, you just need
  20. // to derive from the wxControlWithArrows interface and implement its methods.
  21. // ----------------------------------------------------------------------------
  22. class WXDLLIMPEXP_FWD_CORE wxControlWithArrows;
  23. class WXDLLIMPEXP_FWD_CORE wxDC;
  24. class WXDLLIMPEXP_FWD_CORE wxMouseEvent;
  25. class WXDLLIMPEXP_FWD_CORE wxRect;
  26. class WXDLLIMPEXP_FWD_CORE wxRenderer;
  27. // ----------------------------------------------------------------------------
  28. // wxScrollArrows: an abstraction of scrollbar arrow
  29. // ----------------------------------------------------------------------------
  30. class WXDLLIMPEXP_CORE wxScrollArrows
  31. {
  32. public:
  33. enum Arrow
  34. {
  35. Arrow_None = -1,
  36. Arrow_First, // left or top
  37. Arrow_Second, // right or bottom
  38. Arrow_Max
  39. };
  40. // ctor requires a back pointer to wxControlWithArrows
  41. wxScrollArrows(wxControlWithArrows *control);
  42. // draws the arrow on the given DC in the given rectangle, uses
  43. // wxControlWithArrows::GetArrowState() to get its current state
  44. void DrawArrow(Arrow arrow, wxDC& dc, const wxRect& rect,
  45. bool scrollbarLike = false) const;
  46. // process a mouse move, enter or leave event, possibly calling
  47. // wxControlWithArrows::SetArrowState() if
  48. // wxControlWithArrows::HitTestArrow() says that the mouse has left/entered
  49. // an arrow
  50. bool HandleMouseMove(const wxMouseEvent& event) const;
  51. // process a mouse click event
  52. bool HandleMouse(const wxMouseEvent& event) const;
  53. // dtor
  54. ~wxScrollArrows();
  55. private:
  56. // set or clear the wxCONTROL_CURRENT flag for the arrow
  57. void UpdateCurrentFlag(Arrow arrow, Arrow arrowCur) const;
  58. // the main control
  59. wxControlWithArrows *m_control;
  60. // the data for the mouse capture
  61. struct wxScrollArrowCaptureData *m_captureData;
  62. };
  63. // ----------------------------------------------------------------------------
  64. // wxControlWithArrows: interface implemented by controls using wxScrollArrows
  65. // ----------------------------------------------------------------------------
  66. class WXDLLIMPEXP_CORE wxControlWithArrows
  67. {
  68. public:
  69. virtual ~wxControlWithArrows() {}
  70. // get the renderer to use for drawing the arrows
  71. virtual wxRenderer *GetRenderer() const = 0;
  72. // get the controls window (used for mouse capturing)
  73. virtual wxWindow *GetWindow() = 0;
  74. // get the orientation of the arrows (vertical or horizontal)
  75. virtual bool IsVertical() const = 0;
  76. // get the state of this arrow as combination of wxCONTROL_XXX flags
  77. virtual int GetArrowState(wxScrollArrows::Arrow arrow) const = 0;
  78. // set or clear the specified flag in the arrow state: this function is
  79. // responsible for refreshing the control
  80. virtual void SetArrowFlag(wxScrollArrows::Arrow arrow,
  81. int flag, bool set = true) = 0;
  82. // hit testing: return on which arrow the point is (or Arrow_None)
  83. virtual wxScrollArrows::Arrow HitTestArrow(const wxPoint& pt) const = 0;
  84. // called when the arrow is pressed, return true to continue scrolling and
  85. // false to stop it
  86. virtual bool OnArrow(wxScrollArrows::Arrow arrow) = 0;
  87. };
  88. #endif // _WX_UNIV_SCRARROW_H_