radiobut.h 3.9 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117
  1. /////////////////////////////////////////////////////////////////////////////
  2. // Name: radiobut.h
  3. // Purpose: interface of wxRadioButton
  4. // Author: wxWidgets team
  5. // Licence: wxWindows licence
  6. /////////////////////////////////////////////////////////////////////////////
  7. /**
  8. @class wxRadioButton
  9. A radio button item is a button which usually denotes one of several
  10. mutually exclusive options. It has a text label next to a (usually) round
  11. button.
  12. You can create a group of mutually-exclusive radio buttons by specifying
  13. @c wxRB_GROUP for the first in the group. The group ends when another
  14. radio button group is created, or there are no more radio buttons.
  15. @beginStyleTable
  16. @style{wxRB_GROUP}
  17. Marks the beginning of a new group of radio buttons.
  18. @style{wxRB_SINGLE}
  19. In some circumstances, radio buttons that are not consecutive
  20. siblings trigger a hang bug in Windows (only). If this happens, add
  21. this style to mark the button as not belonging to a group, and
  22. implement the mutually-exclusive group behaviour yourself.
  23. @endStyleTable
  24. @beginEventEmissionTable{wxCommandEvent}
  25. @event{EVT_RADIOBUTTON(id, func)}
  26. Process a @c wxEVT_RADIOBUTTON event, when the
  27. radiobutton is clicked.
  28. @endEventTable
  29. @library{wxcore}
  30. @category{ctrl}
  31. @appearance{radiobutton}
  32. @see @ref overview_events, wxRadioBox, wxCheckBox
  33. */
  34. class wxRadioButton : public wxControl
  35. {
  36. public:
  37. /**
  38. Default constructor.
  39. @see Create(), wxValidator
  40. */
  41. wxRadioButton();
  42. /**
  43. Constructor, creating and showing a radio button.
  44. @param parent
  45. Parent window. Must not be @NULL.
  46. @param id
  47. Window identifier. The value @c wxID_ANY indicates a default value.
  48. @param label
  49. Label for the radio button.
  50. @param pos
  51. Window position. If ::wxDefaultPosition is specified then a default
  52. position is chosen.
  53. @param size
  54. Window size. If ::wxDefaultSize is specified then a default size
  55. is chosen.
  56. @param style
  57. Window style. See wxRadioButton.
  58. @param validator
  59. Window validator.
  60. @param name
  61. Window name.
  62. @see Create(), wxValidator
  63. */
  64. wxRadioButton(wxWindow* parent, wxWindowID id,
  65. const wxString& label,
  66. const wxPoint& pos = wxDefaultPosition,
  67. const wxSize& size = wxDefaultSize,
  68. long style = 0,
  69. const wxValidator& validator = wxDefaultValidator,
  70. const wxString& name = wxRadioButtonNameStr);
  71. /**
  72. Destructor, destroying the radio button item.
  73. */
  74. virtual ~wxRadioButton();
  75. /**
  76. Creates the choice for two-step construction. See wxRadioButton() for
  77. further details.
  78. */
  79. bool Create(wxWindow* parent, wxWindowID id, const wxString& label,
  80. const wxPoint& pos = wxDefaultPosition,
  81. const wxSize& size = wxDefaultSize, long style = 0,
  82. const wxValidator& validator = wxDefaultValidator,
  83. const wxString& name = wxRadioButtonNameStr);
  84. /**
  85. Returns @true if the radio button is checked, @false otherwise.
  86. */
  87. virtual bool GetValue() const;
  88. /**
  89. Sets the radio button to checked or unchecked status. This does not cause a
  90. @c wxEVT_RADIOBUTTON event to get emitted.
  91. If the radio button belongs to a radio group exactly one button in the
  92. group may be checked and so this method can be only called with @a
  93. value set to @true. To uncheck a radio button in a group you must check
  94. another button in the same group.
  95. @param value
  96. @true to check, @false to uncheck.
  97. */
  98. virtual void SetValue(bool value);
  99. };