tglbtn.h 5.3 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176
  1. /////////////////////////////////////////////////////////////////////////////
  2. // Name: tglbtn.h
  3. // Purpose: interface of wxBitmapToggleButton, wxToggleButton
  4. // Author: wxWidgets team
  5. // Licence: wxWindows licence
  6. /////////////////////////////////////////////////////////////////////////////
  7. wxEventType wxEVT_TOGGLEBUTTON;
  8. /**
  9. @class wxToggleButton
  10. wxToggleButton is a button that stays pressed when clicked by the user.
  11. In other words, it is similar to wxCheckBox in functionality but looks like a wxButton.
  12. Since wxWidgets version 2.9.0 this control emits an update UI event.
  13. You can see wxToggleButton in action in @ref page_samples_controls.
  14. @beginEventEmissionTable{wxCommandEvent}
  15. @event{EVT_TOGGLEBUTTON(id, func)}
  16. Handles a wxEVT_TOGGLEBUTTON event.
  17. @endEventTable
  18. @library{wxcore}
  19. @category{ctrl}
  20. @appearance{togglebutton}
  21. @see wxCheckBox, wxButton, wxBitmapToggleButton
  22. */
  23. class wxToggleButton : public wxAnyButton
  24. {
  25. public:
  26. /**
  27. Default constructor.
  28. */
  29. wxToggleButton();
  30. /**
  31. Constructor, creating and showing a toggle button.
  32. @param parent
  33. Parent window. Must not be @NULL.
  34. @param id
  35. Toggle button identifier. The value wxID_ANY indicates a default value.
  36. @param label
  37. Text to be displayed next to the toggle button.
  38. @param pos
  39. Toggle button position.
  40. If ::wxDefaultPosition is specified then a default position is chosen.
  41. @param size
  42. Toggle button size.
  43. If ::wxDefaultSize is specified then a default size is chosen.
  44. @param style
  45. Window style. See wxToggleButton.
  46. @param val
  47. Window validator.
  48. @param name
  49. Window name.
  50. @see Create(), wxValidator
  51. */
  52. wxToggleButton(wxWindow* parent, wxWindowID id,
  53. const wxString& label,
  54. const wxPoint& pos = wxDefaultPosition,
  55. const wxSize& size = wxDefaultSize,
  56. long style = 0,
  57. const wxValidator& val = wxDefaultValidator,
  58. const wxString& name = wxCheckBoxNameStr);
  59. /**
  60. Destructor, destroying the toggle button.
  61. */
  62. virtual ~wxToggleButton();
  63. /**
  64. Creates the toggle button for two-step construction.
  65. See wxToggleButton() for details.
  66. */
  67. bool Create(wxWindow* parent, wxWindowID id,
  68. const wxString& label,
  69. const wxPoint& pos = wxDefaultPosition,
  70. const wxSize& size = wxDefaultSize,
  71. long style = 0,
  72. const wxValidator& val = wxDefaultValidator,
  73. const wxString& name = wxCheckBoxNameStr);
  74. /**
  75. Gets the state of the toggle button.
  76. @return Returns @true if it is pressed, @false otherwise.
  77. */
  78. virtual bool GetValue() const;
  79. /**
  80. Sets the toggle button to the given state.
  81. This does not cause a @c EVT_TOGGLEBUTTON event to be emitted.
  82. @param state
  83. If @true, the button is pressed.
  84. */
  85. virtual void SetValue(bool state);
  86. };
  87. /**
  88. @class wxBitmapToggleButton
  89. wxBitmapToggleButton is a wxToggleButton that contains a bitmap instead of
  90. text.
  91. This class is not available in all ports currently (although it is
  92. available in the major ones), test for @c wxHAS_BITMAPTOGGLEBUTTON to
  93. determine whether it can be used (in addition for possibly testing for
  94. @c wxUSE_TOGGLEBTN which can be set to 0 to explicitly disable support for
  95. this class and wxToggleButton).
  96. This control emits an update UI event.
  97. @beginEventEmissionTable{wxCommandEvent}
  98. @event{EVT_TOGGLEBUTTON(id, func)}
  99. Handles a wxEVT_TOGGLEBUTTON event.
  100. @endEventTable
  101. @library{wxcore}
  102. @category{ctrl}
  103. */
  104. class wxBitmapToggleButton : public wxToggleButton
  105. {
  106. public:
  107. /**
  108. Default constructor.
  109. */
  110. wxBitmapToggleButton();
  111. /**
  112. Constructor, creating and showing a toggle button with the bitmap @e label.
  113. Internally calls Create().
  114. */
  115. wxBitmapToggleButton(wxWindow* parent, wxWindowID id,
  116. const wxBitmap& label,
  117. const wxPoint& pos = wxDefaultPosition,
  118. const wxSize& size = wxDefaultSize,
  119. long style = 0,
  120. const wxValidator& val = wxDefaultValidator,
  121. const wxString& name = wxCheckBoxNameStr);
  122. /**
  123. Create method for two-step construction.
  124. */
  125. bool Create(wxWindow* parent, wxWindowID id,
  126. const wxBitmap& label,
  127. const wxPoint& pos = wxDefaultPosition,
  128. const wxSize& size = wxDefaultSize,
  129. long style = 0,
  130. const wxValidator& val = wxDefaultValidator,
  131. const wxString& name = wxCheckBoxNameStr);
  132. /**
  133. Gets the state of the toggle button.
  134. @return Returns @true if it is pressed, @false otherwise.
  135. */
  136. virtual bool GetValue() const;
  137. /**
  138. Sets the toggle button to the given state.
  139. This does not cause a @c EVT_TOGGLEBUTTON event to be emitted.
  140. @param state
  141. If @true, the button is pressed.
  142. */
  143. virtual void SetValue(bool state);
  144. };