spinbutt.h 5.4 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188
  1. /////////////////////////////////////////////////////////////////////////////
  2. // Name: spinbutt.h
  3. // Purpose: interface of wxSpinEvent, wxSpinButton
  4. // Author: wxWidgets team
  5. // Licence: wxWindows licence
  6. /////////////////////////////////////////////////////////////////////////////
  7. /**
  8. @class wxSpinEvent
  9. This event class is used for the events generated by wxSpinButton and wxSpinCtrl.
  10. @beginEventTable{wxSpinEvent}
  11. @event{EVT_SPIN(id, func)}
  12. Generated whenever an arrow is pressed.
  13. @event{EVT_SPIN_UP(id, func)}
  14. Generated when left/up arrow is pressed.
  15. @event{EVT_SPIN_DOWN(id, func)}
  16. Generated when right/down arrow is pressed.
  17. @endEventTable
  18. Note that if you handle both SPIN and UP or DOWN events, you will be notified
  19. about each of them twice: first the UP/DOWN event will be received and then,
  20. if it wasn't vetoed, the SPIN event will be sent.
  21. @library{wxcore}
  22. @category{events}
  23. @see wxSpinButton and wxSpinCtrl
  24. */
  25. class wxSpinEvent : public wxNotifyEvent
  26. {
  27. public:
  28. /**
  29. The constructor is not normally used by the user code.
  30. */
  31. wxSpinEvent(wxEventType commandType = wxEVT_NULL, int id = 0);
  32. /**
  33. Retrieve the current spin button or control value.
  34. */
  35. int GetPosition() const;
  36. /**
  37. Set the value associated with the event.
  38. */
  39. void SetPosition(int pos);
  40. };
  41. /**
  42. @class wxSpinButton
  43. A wxSpinButton has two small up and down (or left and right) arrow buttons.
  44. It is often used next to a text control for increment and decrementing a value.
  45. Portable programs should try to use wxSpinCtrl instead as wxSpinButton is not
  46. implemented for all platforms but wxSpinCtrl is as it degenerates to a simple
  47. wxTextCtrl on such platforms.
  48. @note the range supported by this control (and wxSpinCtrl) depends on the
  49. platform but is at least @c -0x8000 to @c 0x7fff. Under GTK and
  50. Win32 with sufficiently new version of @c comctrl32.dll (at least 4.71
  51. is required, 5.80 is recommended) the full 32 bit range is supported.
  52. @beginStyleTable
  53. @style{wxSP_HORIZONTAL}
  54. Specifies a horizontal spin button (note that this style is not
  55. supported in wxGTK).
  56. @style{wxSP_VERTICAL}
  57. Specifies a vertical spin button.
  58. @style{wxSP_ARROW_KEYS}
  59. The user can use arrow keys to change the value.
  60. @style{wxSP_WRAP}
  61. The value wraps at the minimum and maximum.
  62. @endStyleTable
  63. @beginEventEmissionTable{wxSpinEvent}
  64. @event{EVT_SPIN(id, func)}
  65. Generated whenever an arrow is pressed.
  66. @event{EVT_SPIN_UP(id, func)}
  67. Generated when left/up arrow is pressed.
  68. @event{EVT_SPIN_DOWN(id, func)}
  69. Generated when right/down arrow is pressed.
  70. @endEventTable
  71. Note that if you handle both SPIN and UP or DOWN events, you will be notified
  72. about each of them twice: first the UP/DOWN event will be received and then,
  73. if it wasn't vetoed, the SPIN event will be sent.
  74. @library{wxcore}
  75. @category{ctrl}
  76. @appearance{spinbutton}
  77. @see wxSpinCtrl
  78. */
  79. class wxSpinButton : public wxControl
  80. {
  81. public:
  82. /**
  83. Default constructor.
  84. */
  85. wxSpinButton();
  86. /**
  87. Constructor, creating and showing a spin button.
  88. @param parent
  89. Parent window. Must not be @NULL.
  90. @param id
  91. Window identifier. The value wxID_ANY indicates a default value.
  92. @param pos
  93. Window position.
  94. If ::wxDefaultPosition is specified then a default position is chosen.
  95. @param size
  96. Window size.
  97. If ::wxDefaultSize is specified then a default size is chosen.
  98. @param style
  99. Window style. See wxSpinButton class description.
  100. @param name
  101. Window name.
  102. @see Create()
  103. */
  104. wxSpinButton(wxWindow* parent, wxWindowID id = -1,
  105. const wxPoint& pos = wxDefaultPosition,
  106. const wxSize& size = wxDefaultSize,
  107. long style = wxSP_VERTICAL,
  108. const wxString& name = "spinButton");
  109. /**
  110. Destructor, destroys the spin button control.
  111. */
  112. virtual ~wxSpinButton();
  113. /**
  114. Scrollbar creation function called by the spin button constructor.
  115. See wxSpinButton() for details.
  116. */
  117. bool Create(wxWindow* parent, wxWindowID id = -1,
  118. const wxPoint& pos = wxDefaultPosition,
  119. const wxSize& size = wxDefaultSize,
  120. long style = wxSP_VERTICAL,
  121. const wxString& name = "wxSpinButton");
  122. /**
  123. Returns the maximum permissible value.
  124. @see SetRange()
  125. */
  126. virtual int GetMax() const;
  127. /**
  128. Returns the minimum permissible value.
  129. @see SetRange()
  130. */
  131. virtual int GetMin() const;
  132. /**
  133. Returns the current spin button value.
  134. @see SetValue()
  135. */
  136. virtual int GetValue() const;
  137. /**
  138. Sets the range of the spin button.
  139. @param min
  140. The minimum value for the spin button.
  141. @param max
  142. The maximum value for the spin button.
  143. @see GetMin(), GetMax()
  144. */
  145. virtual void SetRange(int min, int max);
  146. /**
  147. Sets the value of the spin button.
  148. @param value
  149. The value for the spin button.
  150. */
  151. virtual void SetValue(int value);
  152. };