slider.h 4.5 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141
  1. /////////////////////////////////////////////////////////////////////////////
  2. // Name: wx/msw/slider.h
  3. // Purpose: wxSlider class implementation using trackbar control
  4. // Author: Julian Smart
  5. // Modified by:
  6. // Created: 01/02/97
  7. // Copyright: (c) Julian Smart
  8. // Licence: wxWindows licence
  9. /////////////////////////////////////////////////////////////////////////////
  10. #ifndef _WX_SLIDER_H_
  11. #define _WX_SLIDER_H_
  12. class WXDLLIMPEXP_FWD_CORE wxSubwindows;
  13. // Slider
  14. class WXDLLIMPEXP_CORE wxSlider : public wxSliderBase
  15. {
  16. public:
  17. wxSlider() { Init(); }
  18. wxSlider(wxWindow *parent,
  19. wxWindowID id,
  20. int value,
  21. int minValue,
  22. int maxValue,
  23. const wxPoint& pos = wxDefaultPosition,
  24. const wxSize& size = wxDefaultSize,
  25. long style = wxSL_HORIZONTAL,
  26. const wxValidator& validator = wxDefaultValidator,
  27. const wxString& name = wxSliderNameStr)
  28. {
  29. Init();
  30. (void)Create(parent, id, value, minValue, maxValue,
  31. pos, size, style, validator, name);
  32. }
  33. bool Create(wxWindow *parent,
  34. wxWindowID id,
  35. int value,
  36. int minValue, int maxValue,
  37. const wxPoint& pos = wxDefaultPosition,
  38. const wxSize& size = wxDefaultSize,
  39. long style = wxSL_HORIZONTAL,
  40. const wxValidator& validator = wxDefaultValidator,
  41. const wxString& name = wxSliderNameStr);
  42. virtual ~wxSlider();
  43. // slider methods
  44. virtual int GetValue() const;
  45. virtual void SetValue(int);
  46. void SetRange(int minValue, int maxValue);
  47. int GetMin() const { return m_rangeMin; }
  48. int GetMax() const { return m_rangeMax; }
  49. // Win32-specific slider methods
  50. int GetTickFreq() const { return m_tickFreq; }
  51. void SetPageSize(int pageSize);
  52. int GetPageSize() const;
  53. void ClearSel();
  54. void ClearTicks();
  55. void SetLineSize(int lineSize);
  56. int GetLineSize() const;
  57. int GetSelEnd() const;
  58. int GetSelStart() const;
  59. void SetSelection(int minPos, int maxPos);
  60. void SetThumbLength(int len);
  61. int GetThumbLength() const;
  62. void SetTick(int tickPos);
  63. // implementation only from now on
  64. WXHWND GetStaticMin() const;
  65. WXHWND GetStaticMax() const;
  66. WXHWND GetEditValue() const;
  67. virtual bool ContainsHWND(WXHWND hWnd) const;
  68. // we should let background show through the slider (and its labels)
  69. virtual bool HasTransparentBackground() { return true; }
  70. // returns true if the platform should explicitly apply a theme border
  71. virtual bool CanApplyThemeBorder() const { return false; }
  72. void Command(wxCommandEvent& event);
  73. virtual bool MSWOnScroll(int orientation, WXWORD wParam,
  74. WXWORD pos, WXHWND control);
  75. virtual bool Show(bool show = true);
  76. virtual bool Enable(bool show = true);
  77. virtual bool SetFont(const wxFont& font);
  78. virtual WXDWORD MSWGetStyle(long flags, WXDWORD *exstyle = NULL) const;
  79. protected:
  80. // common part of all ctors
  81. void Init();
  82. // format an integer value as string
  83. static wxString Format(int n) { return wxString::Format(wxT("%d"), n); }
  84. // get the boundig box for the slider and possible labels
  85. wxRect GetBoundingBox() const;
  86. // Get the height and, if the pointers are non NULL, widths of both labels.
  87. //
  88. // Notice that the return value will be 0 if we don't have wxSL_LABELS
  89. // style but we do fill widthMin and widthMax even if we don't have
  90. // wxSL_MIN_MAX_LABELS style set so the caller should account for it.
  91. int GetLabelsSize(int *widthMin = NULL, int *widthMax = NULL) const;
  92. // overridden base class virtuals
  93. virtual void DoGetPosition(int *x, int *y) const;
  94. virtual void DoGetSize(int *width, int *height) const;
  95. virtual void DoMoveWindow(int x, int y, int width, int height);
  96. virtual wxSize DoGetBestSize() const;
  97. // the labels windows, if any
  98. wxSubwindows *m_labels;
  99. int m_rangeMin;
  100. int m_rangeMax;
  101. int m_pageSize;
  102. int m_lineSize;
  103. int m_tickFreq;
  104. // flag needed to detect whether we're getting THUMBRELEASE event because
  105. // of dragging the thumb or scrolling the mouse wheel
  106. bool m_isDragging;
  107. // Platform-specific implementation of SetTickFreq
  108. virtual void DoSetTickFreq(int freq);
  109. DECLARE_DYNAMIC_CLASS_NO_COPY(wxSlider)
  110. };
  111. #endif // _WX_SLIDER_H_