tglbtn.h 4.4 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136
  1. /////////////////////////////////////////////////////////////////////////////
  2. // Name: wx/gtk1/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. // classes
  16. //-----------------------------------------------------------------------------
  17. class WXDLLIMPEXP_FWD_CORE wxToggleButton;
  18. class WXDLLIMPEXP_FWD_CORE wxToggleBitmapButton;
  19. //-----------------------------------------------------------------------------
  20. // wxToggleBitmapButton
  21. //-----------------------------------------------------------------------------
  22. class WXDLLIMPEXP_CORE wxToggleBitmapButton: public wxToggleButtonBase
  23. {
  24. public:
  25. // construction/destruction
  26. wxToggleBitmapButton() {}
  27. wxToggleBitmapButton(wxWindow *parent,
  28. wxWindowID id,
  29. const wxBitmap& label,
  30. const wxPoint& pos = wxDefaultPosition,
  31. const wxSize& size = wxDefaultSize,
  32. long style = 0,
  33. const wxValidator& validator = wxDefaultValidator,
  34. const wxString& name = wxCheckBoxNameStr)
  35. {
  36. Create(parent, id, label, pos, size, style, validator, name);
  37. }
  38. // Create the control
  39. bool Create(wxWindow *parent,
  40. wxWindowID id,
  41. const wxBitmap& label,
  42. const wxPoint& pos = wxDefaultPosition,
  43. const wxSize& size = wxDefaultSize, long style = 0,
  44. const wxValidator& validator = wxDefaultValidator,
  45. const wxString& name = wxCheckBoxNameStr);
  46. // Get/set the value
  47. void SetValue(bool state);
  48. bool GetValue() const;
  49. // Set the label
  50. virtual void SetLabel(const wxString& label) { wxControl::SetLabel(label); }
  51. virtual void SetLabel(const wxBitmap& label);
  52. bool Enable(bool enable = TRUE);
  53. static wxVisualAttributes
  54. GetClassDefaultAttributes(wxWindowVariant variant = wxWINDOW_VARIANT_NORMAL);
  55. // implementation
  56. bool m_blockEvent;
  57. wxBitmap m_bitmap;
  58. void OnSetBitmap();
  59. void DoApplyWidgetStyle(GtkRcStyle *style);
  60. bool IsOwnGtkWindow(GdkWindow *window);
  61. virtual void OnInternalIdle();
  62. virtual wxSize DoGetBestSize() const;
  63. private:
  64. DECLARE_DYNAMIC_CLASS(wxToggleBitmapButton)
  65. };
  66. //-----------------------------------------------------------------------------
  67. // wxToggleButton
  68. //-----------------------------------------------------------------------------
  69. class WXDLLIMPEXP_CORE wxToggleButton: public wxControl
  70. {
  71. public:
  72. // construction/destruction
  73. wxToggleButton() {}
  74. wxToggleButton(wxWindow *parent,
  75. wxWindowID id,
  76. const wxString& label,
  77. const wxPoint& pos = wxDefaultPosition,
  78. const wxSize& size = wxDefaultSize,
  79. long style = 0,
  80. const wxValidator& validator = wxDefaultValidator,
  81. const wxString& name = wxCheckBoxNameStr)
  82. {
  83. Create(parent, id, label, pos, size, style, validator, name);
  84. }
  85. // Create the control
  86. bool Create(wxWindow *parent,
  87. wxWindowID id,
  88. const wxString& label,
  89. const wxPoint& pos = wxDefaultPosition,
  90. const wxSize& size = wxDefaultSize, long style = 0,
  91. const wxValidator& validator = wxDefaultValidator,
  92. const wxString& name = wxCheckBoxNameStr);
  93. // Get/set the value
  94. void SetValue(bool state);
  95. bool GetValue() const;
  96. // Set the label
  97. void SetLabel(const wxString& label);
  98. bool Enable(bool enable = TRUE);
  99. static wxVisualAttributes
  100. GetClassDefaultAttributes(wxWindowVariant variant = wxWINDOW_VARIANT_NORMAL);
  101. // implementation
  102. bool m_blockEvent;
  103. void DoApplyWidgetStyle(GtkRcStyle *style);
  104. bool IsOwnGtkWindow(GdkWindow *window);
  105. virtual void OnInternalIdle();
  106. virtual wxSize DoGetBestSize() const;
  107. private:
  108. DECLARE_DYNAMIC_CLASS(wxToggleButton)
  109. };
  110. #endif // _WX_GTK_TOGGLEBUTTON_H_