slider.h 3.9 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107
  1. /////////////////////////////////////////////////////////////////////////////
  2. // Name: wx/cocoa/slider.h
  3. // Purpose: wxSlider class
  4. // Author: David Elliott
  5. // Mark Oxenham
  6. // Modified by:
  7. // Created: 2003/06/19
  8. // Copyright: (c) 2003 David Elliott
  9. // (c) 2007 Software 2000 Ltd.
  10. // Licence: wxWindows licence
  11. /////////////////////////////////////////////////////////////////////////////
  12. #ifndef __WX_COCOA_SLIDER_H__
  13. #define __WX_COCOA_SLIDER_H__
  14. #include "wx/cocoa/NSSlider.h"
  15. // ========================================================================
  16. // wxSlider
  17. // ========================================================================
  18. class WXDLLIMPEXP_CORE wxSlider: public wxSliderBase, protected wxCocoaNSSlider
  19. {
  20. DECLARE_DYNAMIC_CLASS(wxSlider)
  21. DECLARE_EVENT_TABLE()
  22. WX_DECLARE_COCOA_OWNER(NSSlider,NSControl,NSView)
  23. // ------------------------------------------------------------------------
  24. // initialization
  25. // ------------------------------------------------------------------------
  26. public:
  27. wxSlider() { }
  28. wxSlider(wxWindow *parent, wxWindowID winid,
  29. int value, int minValue, int maxValue,
  30. const wxPoint& pos = wxDefaultPosition,
  31. const wxSize& size = wxDefaultSize,
  32. long style = wxSL_HORIZONTAL,
  33. const wxValidator& validator = wxDefaultValidator,
  34. const wxString& name = wxSliderNameStr)
  35. {
  36. Create(parent, winid, value, minValue, maxValue,
  37. pos, size, style, validator, name);
  38. }
  39. bool Create(wxWindow *parent, wxWindowID winid,
  40. int value, int minValue, int maxValue,
  41. const wxPoint& pos = wxDefaultPosition,
  42. const wxSize& size = wxDefaultSize,
  43. long style = wxSL_HORIZONTAL,
  44. const wxValidator& validator = wxDefaultValidator,
  45. const wxString& name = wxSliderNameStr);
  46. virtual ~wxSlider();
  47. // ------------------------------------------------------------------------
  48. // Cocoa callbacks
  49. // ------------------------------------------------------------------------
  50. protected:
  51. // Override this so we can use wxCocoaNSControl's target
  52. void AssociateNSSlider(WX_NSSlider theSlider);
  53. // Helper method to do the real work
  54. virtual void ProcessEventType(wxEventType commandType);
  55. // from wxCocoaNSControl:
  56. virtual void CocoaTarget_action();
  57. // from wxCocoaNSSlider:
  58. virtual void CocoaNotification_startTracking(WX_NSNotification notification);
  59. virtual void CocoaNotification_continueTracking(WX_NSNotification notification);
  60. virtual void CocoaNotification_stopTracking(WX_NSNotification notification);
  61. // ------------------------------------------------------------------------
  62. // Implementation
  63. // ------------------------------------------------------------------------
  64. public:
  65. // Pure Virtuals
  66. virtual int GetValue() const;
  67. virtual void SetValue(int value);
  68. // retrieve/change the range
  69. virtual void SetRange(int minValue, int maxValue);
  70. virtual int GetMin() const;
  71. virtual int GetMax() const;
  72. // the line/page size is the increment by which the slider moves when
  73. // cursor arrow key/page up or down are pressed (clicking the mouse is like
  74. // pressing PageUp/Down) and are by default set to 1 and 1/10 of the range
  75. virtual void SetLineSize(int lineSize);
  76. virtual void SetPageSize(int pageSize);
  77. virtual int GetLineSize() const;
  78. virtual int GetPageSize() const;
  79. // these methods get/set the length of the slider pointer in pixels
  80. virtual void SetThumbLength(int lenPixels);
  81. virtual int GetThumbLength() const;
  82. // copied from (wxSliderCocoa.h)
  83. virtual int GetTickFreq() const;
  84. virtual void ClearTicks() { SetTickFreq(0); }
  85. virtual void SetTickPos(int pos);
  86. protected:
  87. // Platform-specific implementation of SetTickFreq
  88. virtual void DoSetTickFreq(int freq);
  89. };
  90. #endif
  91. // __WX_COCOA_SLIDER_H__