slider.h 5.3 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156
  1. ///////////////////////////////////////////////////////////////////////////////
  2. // Name: wx/slider.h
  3. // Purpose: wxSlider interface
  4. // Author: Vadim Zeitlin
  5. // Modified by:
  6. // Created: 09.02.01
  7. // Copyright: (c) 1996-2001 Vadim Zeitlin
  8. // Licence: wxWindows licence
  9. ///////////////////////////////////////////////////////////////////////////////
  10. #ifndef _WX_SLIDER_H_BASE_
  11. #define _WX_SLIDER_H_BASE_
  12. // ----------------------------------------------------------------------------
  13. // headers
  14. // ----------------------------------------------------------------------------
  15. #include "wx/defs.h"
  16. #if wxUSE_SLIDER
  17. #include "wx/control.h"
  18. // ----------------------------------------------------------------------------
  19. // wxSlider flags
  20. // ----------------------------------------------------------------------------
  21. #define wxSL_HORIZONTAL wxHORIZONTAL /* 0x0004 */
  22. #define wxSL_VERTICAL wxVERTICAL /* 0x0008 */
  23. #define wxSL_TICKS 0x0010
  24. #define wxSL_AUTOTICKS wxSL_TICKS // we don't support manual ticks
  25. #define wxSL_LEFT 0x0040
  26. #define wxSL_TOP 0x0080
  27. #define wxSL_RIGHT 0x0100
  28. #define wxSL_BOTTOM 0x0200
  29. #define wxSL_BOTH 0x0400
  30. #define wxSL_SELRANGE 0x0800
  31. #define wxSL_INVERSE 0x1000
  32. #define wxSL_MIN_MAX_LABELS 0x2000
  33. #define wxSL_VALUE_LABEL 0x4000
  34. #define wxSL_LABELS (wxSL_MIN_MAX_LABELS|wxSL_VALUE_LABEL)
  35. #if WXWIN_COMPATIBILITY_2_6
  36. // obsolete
  37. #define wxSL_NOTIFY_DRAG 0x0000
  38. #endif // WXWIN_COMPATIBILITY_2_6
  39. extern WXDLLIMPEXP_DATA_CORE(const char) wxSliderNameStr[];
  40. // ----------------------------------------------------------------------------
  41. // wxSliderBase: define wxSlider interface
  42. // ----------------------------------------------------------------------------
  43. class WXDLLIMPEXP_CORE wxSliderBase : public wxControl
  44. {
  45. public:
  46. /* the ctor of the derived class should have the following form:
  47. wxSlider(wxWindow *parent,
  48. wxWindowID id,
  49. int value, int minValue, int maxValue,
  50. const wxPoint& pos = wxDefaultPosition,
  51. const wxSize& size = wxDefaultSize,
  52. long style = wxSL_HORIZONTAL,
  53. const wxValidator& validator = wxDefaultValidator,
  54. const wxString& name = wxSliderNameStr);
  55. */
  56. wxSliderBase() { }
  57. // get/set the current slider value (should be in range)
  58. virtual int GetValue() const = 0;
  59. virtual void SetValue(int value) = 0;
  60. // retrieve/change the range
  61. virtual void SetRange(int minValue, int maxValue) = 0;
  62. virtual int GetMin() const = 0;
  63. virtual int GetMax() const = 0;
  64. void SetMin( int minValue ) { SetRange( minValue , GetMax() ) ; }
  65. void SetMax( int maxValue ) { SetRange( GetMin() , maxValue ) ; }
  66. // the line/page size is the increment by which the slider moves when
  67. // cursor arrow key/page up or down are pressed (clicking the mouse is like
  68. // pressing PageUp/Down) and are by default set to 1 and 1/10 of the range
  69. virtual void SetLineSize(int lineSize) = 0;
  70. virtual void SetPageSize(int pageSize) = 0;
  71. virtual int GetLineSize() const = 0;
  72. virtual int GetPageSize() const = 0;
  73. // these methods get/set the length of the slider pointer in pixels
  74. virtual void SetThumbLength(int lenPixels) = 0;
  75. virtual int GetThumbLength() const = 0;
  76. // warning: most of subsequent methods are currently only implemented in
  77. // wxMSW under Win95 and are silently ignored on other platforms
  78. void SetTickFreq(int freq) { DoSetTickFreq(freq); }
  79. virtual int GetTickFreq() const { return 0; }
  80. virtual void ClearTicks() { }
  81. virtual void SetTick(int WXUNUSED(tickPos)) { }
  82. virtual void ClearSel() { }
  83. virtual int GetSelEnd() const { return GetMin(); }
  84. virtual int GetSelStart() const { return GetMax(); }
  85. virtual void SetSelection(int WXUNUSED(min), int WXUNUSED(max)) { }
  86. #if WXWIN_COMPATIBILITY_2_8
  87. wxDEPRECATED_INLINE( void SetTickFreq(int freq, int), DoSetTickFreq(freq); )
  88. #endif
  89. protected:
  90. // Platform-specific implementation of SetTickFreq
  91. virtual void DoSetTickFreq(int WXUNUSED(freq)) { /* unsupported by default */ }
  92. // choose the default border for this window
  93. virtual wxBorder GetDefaultBorder() const { return wxBORDER_NONE; }
  94. // adjust value according to wxSL_INVERSE style
  95. virtual int ValueInvertOrNot(int value) const
  96. {
  97. if (HasFlag(wxSL_INVERSE))
  98. return (GetMax() + GetMin()) - value;
  99. else
  100. return value;
  101. }
  102. private:
  103. wxDECLARE_NO_COPY_CLASS(wxSliderBase);
  104. };
  105. // ----------------------------------------------------------------------------
  106. // include the real class declaration
  107. // ----------------------------------------------------------------------------
  108. #if defined(__WXUNIVERSAL__)
  109. #include "wx/univ/slider.h"
  110. #elif defined(__WXMSW__)
  111. #include "wx/msw/slider.h"
  112. #elif defined(__WXMOTIF__)
  113. #include "wx/motif/slider.h"
  114. #elif defined(__WXGTK20__)
  115. #include "wx/gtk/slider.h"
  116. #elif defined(__WXGTK__)
  117. #include "wx/gtk1/slider.h"
  118. #elif defined(__WXMAC__)
  119. #include "wx/osx/slider.h"
  120. #elif defined(__WXCOCOA__)
  121. #include "wx/cocoa/slider.h"
  122. #elif defined(__WXPM__)
  123. #include "wx/os2/slider.h"
  124. #endif
  125. #endif // wxUSE_SLIDER
  126. #endif
  127. // _WX_SLIDER_H_BASE_