tglbtn.h 4.0 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120
  1. /////////////////////////////////////////////////////////////////////////////
  2. // Name: wx/gtk/tglbtn.h
  3. // Purpose: Declaration of the wxToggleButton class, which implements a
  4. // toggle button under wxGTK.
  5. // Author: John Norris, minor changes by Axel Schlueter
  6. // Modified by:
  7. // Created: 08.02.01
  8. // Copyright: (c) 2000 Johnny C. Norris II
  9. // Licence: wxWindows licence
  10. /////////////////////////////////////////////////////////////////////////////
  11. #ifndef _WX_GTK_TOGGLEBUTTON_H_
  12. #define _WX_GTK_TOGGLEBUTTON_H_
  13. #include "wx/bitmap.h"
  14. //-----------------------------------------------------------------------------
  15. // wxToggleButton
  16. //-----------------------------------------------------------------------------
  17. class WXDLLIMPEXP_CORE wxToggleButton: public wxToggleButtonBase
  18. {
  19. public:
  20. // construction/destruction
  21. wxToggleButton() {}
  22. wxToggleButton(wxWindow *parent,
  23. wxWindowID id,
  24. const wxString& label,
  25. const wxPoint& pos = wxDefaultPosition,
  26. const wxSize& size = wxDefaultSize,
  27. long style = 0,
  28. const wxValidator& validator = wxDefaultValidator,
  29. const wxString& name = wxCheckBoxNameStr)
  30. {
  31. Create(parent, id, label, pos, size, style, validator, name);
  32. }
  33. // Create the control
  34. bool Create(wxWindow *parent,
  35. wxWindowID id,
  36. const wxString& label,
  37. const wxPoint& pos = wxDefaultPosition,
  38. const wxSize& size = wxDefaultSize, long style = 0,
  39. const wxValidator& validator = wxDefaultValidator,
  40. const wxString& name = wxCheckBoxNameStr);
  41. // Get/set the value
  42. void SetValue(bool state);
  43. bool GetValue() const;
  44. // Set the label
  45. void SetLabel(const wxString& label);
  46. static wxVisualAttributes
  47. GetClassDefaultAttributes(wxWindowVariant variant = wxWINDOW_VARIANT_NORMAL);
  48. protected:
  49. void GTKDisableEvents();
  50. void GTKEnableEvents();
  51. virtual wxSize DoGetBestSize() const;
  52. virtual void DoApplyWidgetStyle(GtkRcStyle *style);
  53. #if wxUSE_MARKUP
  54. virtual bool DoSetLabelMarkup(const wxString& markup);
  55. #endif // wxUSE_MARKUP
  56. private:
  57. typedef wxToggleButtonBase base_type;
  58. // Return the GtkLabel used by this toggle button.
  59. GtkLabel *GTKGetLabel() const;
  60. DECLARE_DYNAMIC_CLASS(wxToggleButton)
  61. };
  62. //-----------------------------------------------------------------------------
  63. // wxBitmapToggleButton
  64. //-----------------------------------------------------------------------------
  65. class WXDLLIMPEXP_CORE wxBitmapToggleButton: public wxToggleButton
  66. {
  67. public:
  68. // construction/destruction
  69. wxBitmapToggleButton() {}
  70. wxBitmapToggleButton(wxWindow *parent,
  71. wxWindowID id,
  72. const wxBitmap& label,
  73. const wxPoint& pos = wxDefaultPosition,
  74. const wxSize& size = wxDefaultSize,
  75. long style = 0,
  76. const wxValidator& validator = wxDefaultValidator,
  77. const wxString& name = wxCheckBoxNameStr)
  78. {
  79. Create(parent, id, label, pos, size, style, validator, name);
  80. }
  81. // Create the control
  82. bool Create(wxWindow *parent,
  83. wxWindowID id,
  84. const wxBitmap& label,
  85. const wxPoint& pos = wxDefaultPosition,
  86. const wxSize& size = wxDefaultSize, long style = 0,
  87. const wxValidator& validator = wxDefaultValidator,
  88. const wxString& name = wxCheckBoxNameStr);
  89. // deprecated synonym for SetBitmapLabel()
  90. wxDEPRECATED_INLINE( void SetLabel(const wxBitmap& bitmap),
  91. SetBitmapLabel(bitmap); )
  92. // prevent virtual function hiding
  93. virtual void SetLabel(const wxString& label) { wxToggleButton::SetLabel(label); }
  94. private:
  95. typedef wxToggleButtonBase base_type;
  96. DECLARE_DYNAMIC_CLASS(wxBitmapToggleButton)
  97. };
  98. #endif // _WX_GTK_TOGGLEBUTTON_H_