tglbtn.h 3.7 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110
  1. /////////////////////////////////////////////////////////////////////////////
  2. // Name: wx/msw/tglbtn.h
  3. // Purpose: Declaration of the wxToggleButton class, which implements a
  4. // toggle button under wxMSW.
  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_TOGGLEBUTTON_H_
  12. #define _WX_TOGGLEBUTTON_H_
  13. #include "wx/bitmap.h"
  14. // Checkbox item (single checkbox)
  15. class WXDLLIMPEXP_CORE wxToggleButton : public wxToggleButtonBase
  16. {
  17. public:
  18. wxToggleButton() { Init(); }
  19. wxToggleButton(wxWindow *parent,
  20. wxWindowID id,
  21. const wxString& label,
  22. const wxPoint& pos = wxDefaultPosition,
  23. const wxSize& size = wxDefaultSize,
  24. long style = 0,
  25. const wxValidator& validator = wxDefaultValidator,
  26. const wxString& name = wxCheckBoxNameStr)
  27. {
  28. Create(parent, id, label, pos, size, style, validator, name);
  29. }
  30. bool Create(wxWindow *parent,
  31. wxWindowID id,
  32. const wxString& label,
  33. const wxPoint& pos = wxDefaultPosition,
  34. const wxSize& size = wxDefaultSize,
  35. long style = 0,
  36. const wxValidator& validator = wxDefaultValidator,
  37. const wxString& name = wxCheckBoxNameStr);
  38. virtual void SetValue(bool value);
  39. virtual bool GetValue() const ;
  40. virtual bool MSWCommand(WXUINT param, WXWORD id);
  41. virtual void Command(wxCommandEvent& event);
  42. virtual State GetNormalState() const;
  43. // returns true if the platform should explicitly apply a theme border
  44. virtual bool CanApplyThemeBorder() const { return false; }
  45. protected:
  46. virtual wxBorder GetDefaultBorder() const { return wxBORDER_NONE; }
  47. virtual WXDWORD MSWGetStyle(long flags, WXDWORD *exstyle = NULL) const;
  48. void Init();
  49. // current state of the button (when owner-drawn)
  50. bool m_state;
  51. private:
  52. DECLARE_DYNAMIC_CLASS_NO_COPY(wxToggleButton)
  53. };
  54. //-----------------------------------------------------------------------------
  55. // wxBitmapToggleButton
  56. //-----------------------------------------------------------------------------
  57. class WXDLLIMPEXP_CORE wxBitmapToggleButton: public wxToggleButton
  58. {
  59. public:
  60. // construction/destruction
  61. wxBitmapToggleButton() {}
  62. wxBitmapToggleButton(wxWindow *parent,
  63. wxWindowID id,
  64. const wxBitmap& label,
  65. const wxPoint& pos = wxDefaultPosition,
  66. const wxSize& size = wxDefaultSize,
  67. long style = 0,
  68. const wxValidator& validator = wxDefaultValidator,
  69. const wxString& name = wxCheckBoxNameStr)
  70. {
  71. Create(parent, id, label, pos, size, style, validator, name);
  72. }
  73. // Create the control
  74. bool Create(wxWindow *parent,
  75. wxWindowID id,
  76. const wxBitmap& label,
  77. const wxPoint& pos = wxDefaultPosition,
  78. const wxSize& size = wxDefaultSize, long style = 0,
  79. const wxValidator& validator = wxDefaultValidator,
  80. const wxString& name = wxCheckBoxNameStr);
  81. // deprecated synonym for SetBitmapLabel()
  82. wxDEPRECATED_INLINE( void SetLabel(const wxBitmap& bitmap),
  83. SetBitmapLabel(bitmap); )
  84. // prevent virtual function hiding
  85. virtual void SetLabel(const wxString& label) { wxToggleButton::SetLabel(label); }
  86. private:
  87. DECLARE_DYNAMIC_CLASS(wxBitmapToggleButton)
  88. };
  89. #endif // _WX_TOGGLEBUTTON_H_