radiobox.h 10 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273274275276277278279280281282283284285286287288289290291292293294295296297298299300301302303304305306307308309310311312313314315316317318319320321322
  1. /////////////////////////////////////////////////////////////////////////////
  2. // Name: radiobox.h
  3. // Purpose: interface of wxRadioBox
  4. // Author: wxWidgets team
  5. // Licence: wxWindows licence
  6. /////////////////////////////////////////////////////////////////////////////
  7. /**
  8. @class wxRadioBox
  9. A radio box item is used to select one of number of mutually exclusive
  10. choices. It is displayed as a vertical column or horizontal row of
  11. labelled buttons.
  12. @beginStyleTable
  13. @style{wxRA_SPECIFY_ROWS}
  14. The major dimension parameter refers to the maximum number of rows.
  15. @style{wxRA_SPECIFY_COLS}
  16. The major dimension parameter refers to the maximum number of
  17. columns.
  18. @endStyleTable
  19. @beginEventEmissionTable{wxCommandEvent}
  20. @event{EVT_RADIOBOX(id, func)}
  21. Process a @c wxEVT_RADIOBOX event, when a radiobutton
  22. is clicked.
  23. @endEventTable
  24. @library{wxcore}
  25. @category{ctrl}
  26. @appearance{radiobox}
  27. @see @ref overview_events, wxRadioButton, wxCheckBox
  28. */
  29. class wxRadioBox : public wxControl, wxItemContainerImmutable
  30. {
  31. public:
  32. /**
  33. Default constructor.
  34. @see Create(), wxValidator
  35. */
  36. wxRadioBox();
  37. /**
  38. Constructor, creating and showing a radiobox.
  39. @param parent
  40. Parent window. Must not be @NULL.
  41. @param id
  42. Window identifier. The value @c wxID_ANY indicates a default value.
  43. @param label
  44. Label for the static box surrounding the radio buttons.
  45. @param pos
  46. Window position. If ::wxDefaultPosition is specified then a
  47. default position is chosen.
  48. @param size
  49. Window size. If ::wxDefaultSize is specified then a default size
  50. is chosen.
  51. @param n
  52. Number of choices with which to initialize the radiobox.
  53. @param choices
  54. An array of choices with which to initialize the radiobox.
  55. @param majorDimension
  56. Specifies the maximum number of rows (if style contains
  57. @c wxRA_SPECIFY_ROWS) or columns (if style contains
  58. @c wxRA_SPECIFY_COLS) for a two-dimensional radiobox. The default
  59. value of 0 means to use the number of items, i.e. @a n.
  60. @param style
  61. Window style. See wxRadioBox.
  62. @param validator
  63. Window validator.
  64. @param name
  65. Window name.
  66. @beginWxPerlOnly
  67. Not supported by wxPerl.
  68. @endWxPerlOnly
  69. @see Create(), wxValidator
  70. */
  71. wxRadioBox(wxWindow* parent, wxWindowID id,
  72. const wxString& label,
  73. const wxPoint& pos = wxDefaultPosition,
  74. const wxSize& size = wxDefaultSize,
  75. int n = 0,
  76. const wxString choices[] = NULL,
  77. int majorDimension = 0,
  78. long style = wxRA_SPECIFY_COLS,
  79. const wxValidator& validator = wxDefaultValidator,
  80. const wxString& name = wxRadioBoxNameStr);
  81. /**
  82. Constructor, creating and showing a radiobox.
  83. @param parent
  84. Parent window. Must not be @NULL.
  85. @param id
  86. Window identifier. The value @c wxID_ANY indicates a default value.
  87. @param label
  88. Label for the static box surrounding the radio buttons.
  89. @param pos
  90. Window position. If ::wxDefaultPosition is specified then a
  91. default position is chosen.
  92. @param size
  93. Window size. If ::wxDefaultSize is specified then a default size
  94. is chosen.
  95. @param choices
  96. An array of choices with which to initialize the radiobox.
  97. @param majorDimension
  98. Specifies the maximum number of rows (if style contains
  99. @c wxRA_SPECIFY_ROWS) or columns (if style contains
  100. @c wxRA_SPECIFY_COLS) for a two-dimensional radiobox. The default
  101. value of 0 means to use the number of items, i.e. number of
  102. elements in @a choices.
  103. @param style
  104. Window style. See wxRadioBox.
  105. @param validator
  106. Window validator.
  107. @param name
  108. Window name.
  109. @beginWxPerlOnly
  110. Use an array reference for the @a choices parameter.
  111. @endWxPerlOnly
  112. @see Create(), wxValidator
  113. */
  114. wxRadioBox(wxWindow* parent, wxWindowID id,
  115. const wxString& label,
  116. const wxPoint& pos,
  117. const wxSize& size,
  118. const wxArrayString& choices,
  119. int majorDimension = 0,
  120. long style = wxRA_SPECIFY_COLS,
  121. const wxValidator& validator = wxDefaultValidator,
  122. const wxString& name = wxRadioBoxNameStr);
  123. /**
  124. Destructor, destroying the radiobox item.
  125. */
  126. virtual ~wxRadioBox();
  127. /**
  128. Creates the radiobox for two-step construction. See wxRadioBox()
  129. for further details.
  130. */
  131. bool Create(wxWindow* parent, wxWindowID id,
  132. const wxString& label,
  133. const wxPoint& pos = wxDefaultPosition,
  134. const wxSize& size = wxDefaultSize,
  135. int n = 0,
  136. const wxString choices[] = NULL,
  137. int majorDimension = 0,
  138. long style = wxRA_SPECIFY_COLS,
  139. const wxValidator& validator = wxDefaultValidator,
  140. const wxString& name = wxRadioBoxNameStr);
  141. /**
  142. Creates the radiobox for two-step construction. See wxRadioBox()
  143. for further details.
  144. */
  145. bool Create(wxWindow* parent, wxWindowID id,
  146. const wxString& label,
  147. const wxPoint& pos,
  148. const wxSize& size,
  149. const wxArrayString& choices,
  150. int majorDimension = 0,
  151. long style = wxRA_SPECIFY_COLS,
  152. const wxValidator& validator = wxDefaultValidator,
  153. const wxString& name = wxRadioBoxNameStr);
  154. /**
  155. Enables or disables an individual button in the radiobox.
  156. @param enable
  157. @true to enable, @false to disable.
  158. @param n
  159. The zero-based button to enable or disable.
  160. @see wxWindow::Enable()
  161. */
  162. virtual bool Enable(unsigned int n, bool enable = true);
  163. /**
  164. Finds a button matching the given string, returning the position if found,
  165. or @c wxNOT_FOUND if not found.
  166. @param string
  167. The string to find.
  168. @param bCase
  169. Should the search be case-sensitive?
  170. */
  171. virtual int FindString(const wxString& string, bool bCase = false) const;
  172. /**
  173. Returns the number of columns in the radiobox.
  174. */
  175. unsigned int GetColumnCount() const;
  176. /**
  177. Returns a radio box item under the point, a zero-based item index, or @c
  178. wxNOT_FOUND if no item is under the point.
  179. @param pt
  180. Point in client coordinates.
  181. */
  182. virtual int GetItemFromPoint(const wxPoint& pt) const;
  183. /**
  184. Returns the helptext associated with the specified @a item if any or @c
  185. wxEmptyString.
  186. @param item
  187. The zero-based item index.
  188. @see SetItemHelpText()
  189. */
  190. wxString GetItemHelpText(unsigned int item) const;
  191. /**
  192. Returns the tooltip associated with the specified @a item if any or @NULL.
  193. @see SetItemToolTip(), wxWindow::GetToolTip()
  194. */
  195. wxToolTip* GetItemToolTip(unsigned int item) const;
  196. /**
  197. Returns the number of rows in the radiobox.
  198. */
  199. unsigned int GetRowCount() const;
  200. /**
  201. Returns @true if the item is enabled or @false if it was disabled using
  202. @ref Enable(unsigned int,bool) "Enable(n, false)".
  203. This function is currently only implemented in wxMSW, wxGTK and
  204. wxUniversal and always returns @true in the other ports.
  205. @param n
  206. The zero-based button position.
  207. */
  208. virtual bool IsItemEnabled(unsigned int n) const;
  209. /**
  210. Returns @true if the item is currently shown or @false if it was hidden
  211. using @ref Show(unsigned int,bool) "Show(n, false)".
  212. Note that this function returns @true for an item which hadn't been hidden
  213. even if the entire radiobox is not currently shown.
  214. This function is currently only implemented in wxMSW, wxGTK and
  215. wxUniversal and always returns @true in the other ports.
  216. @param n
  217. The zero-based button position.
  218. */
  219. virtual bool IsItemShown(unsigned int n) const;
  220. /**
  221. Sets the helptext for an item. Empty string erases any existing helptext.
  222. @param item
  223. The zero-based item index.
  224. @param helptext
  225. The help text to set for the item.
  226. @see GetItemHelpText()
  227. */
  228. void SetItemHelpText(unsigned int item, const wxString& helptext);
  229. /**
  230. Sets the tooltip text for the specified item in the radio group.
  231. This function is currently only implemented in wxMSW and wxGTK2 and
  232. does nothing in the other ports.
  233. @param item
  234. Index of the item the tooltip will be shown for.
  235. @param text
  236. Tooltip text for the item, the tooltip is removed if empty.
  237. @see GetItemToolTip(), wxWindow::SetToolTip()
  238. */
  239. void SetItemToolTip(unsigned int item, const wxString& text);
  240. /**
  241. Sets the selection to the given item.
  242. Notice that a radio box always has selection, so @a n must be valid
  243. here and passing @c wxNOT_FOUND is not allowed.
  244. */
  245. virtual void SetSelection(int n);
  246. /**
  247. Shows or hides individual buttons.
  248. @param show
  249. @true to show, @false to hide.
  250. @param item
  251. The zero-based position of the button to show or hide.
  252. @return
  253. @true if the item has been shown or hidden or @false if nothing
  254. was done because it already was in the requested state.
  255. @see
  256. wxWindow::Show()
  257. */
  258. virtual bool Show(unsigned int item, bool show = true);
  259. // pure virtuals that have implementations here
  260. virtual unsigned int GetCount() const;
  261. virtual wxString GetString(unsigned int n) const;
  262. virtual void SetString(unsigned int n, const wxString& string);
  263. virtual int GetSelection() const;
  264. };