]>
Commit | Line | Data |
---|---|---|
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 | // RCS-ID: $Id$ | |
9 | // Copyright: (c) 2000 Johnny C. Norris II | |
10 | // Licence: wxWindows licence | |
11 | ///////////////////////////////////////////////////////////////////////////// | |
12 | ||
13 | #ifndef _WX_TOGGLEBUTTON_H_ | |
14 | #define _WX_TOGGLEBUTTON_H_ | |
15 | ||
16 | #include "wx/bitmap.h" | |
17 | ||
18 | //----------------------------------------------------------------------------- | |
19 | // wxBitmapToggleButton | |
20 | //----------------------------------------------------------------------------- | |
21 | ||
22 | ||
23 | class WXDLLIMPEXP_CORE wxBitmapToggleButton: public wxToggleButtonBase | |
24 | { | |
25 | public: | |
26 | // construction/destruction | |
27 | wxBitmapToggleButton() { Init(); } | |
28 | wxBitmapToggleButton(wxWindow *parent, | |
29 | wxWindowID id, | |
30 | const wxBitmap& label, | |
31 | const wxPoint& pos = wxDefaultPosition, | |
32 | const wxSize& size = wxDefaultSize, | |
33 | long style = 0, | |
34 | const wxValidator& validator = wxDefaultValidator, | |
35 | const wxString& name = wxCheckBoxNameStr) | |
36 | { | |
37 | Create(parent, id, label, pos, size, style, validator, name); | |
38 | } | |
39 | ||
40 | // Create the control | |
41 | bool Create(wxWindow *parent, | |
42 | wxWindowID id, | |
43 | const wxBitmap& label, | |
44 | const wxPoint& pos = wxDefaultPosition, | |
45 | const wxSize& size = wxDefaultSize, long style = 0, | |
46 | const wxValidator& validator = wxDefaultValidator, | |
47 | const wxString& name = wxCheckBoxNameStr); | |
48 | ||
49 | // Get/set the value | |
50 | void SetValue(bool state); | |
51 | bool GetValue() const; | |
52 | ||
53 | // Set the label | |
54 | virtual void SetLabel(const wxString& label) { wxControl::SetLabel(label); } | |
55 | virtual void SetLabel(const wxBitmap& label); | |
56 | bool Enable(bool enable = true); | |
57 | ||
58 | protected: | |
59 | void Init(); | |
60 | ||
61 | wxBitmap m_bitmap; | |
62 | wxBitmap m_disabledBitmap; | |
63 | bool m_capturing; | |
64 | bool m_depressed,m_oldValue; | |
65 | ||
66 | void OnPaint(wxPaintEvent &event); | |
67 | void OnMouse(wxMouseEvent &event); | |
68 | void OnChar(wxKeyEvent &event); | |
69 | void OnSize(wxSizeEvent &event); | |
70 | ||
71 | virtual wxSize DoGetBestSize() const; | |
72 | ||
73 | private: | |
74 | DECLARE_EVENT_TABLE() | |
75 | DECLARE_DYNAMIC_CLASS(wxBitmapToggleButton) | |
76 | }; | |
77 | ||
78 | // Checkbox item (single checkbox) | |
79 | class WXDLLIMPEXP_CORE wxToggleButton : public wxToggleButtonBase | |
80 | { | |
81 | public: | |
82 | wxToggleButton() {} | |
83 | wxToggleButton(wxWindow *parent, | |
84 | wxWindowID id, | |
85 | const wxString& label, | |
86 | const wxPoint& pos = wxDefaultPosition, | |
87 | const wxSize& size = wxDefaultSize, | |
88 | long style = 0, | |
89 | const wxValidator& validator = wxDefaultValidator, | |
90 | const wxString& name = wxCheckBoxNameStr) | |
91 | { | |
92 | Create(parent, id, label, pos, size, style, validator, name); | |
93 | } | |
94 | ||
95 | bool Create(wxWindow *parent, | |
96 | wxWindowID id, | |
97 | const wxString& label, | |
98 | const wxPoint& pos = wxDefaultPosition, | |
99 | const wxSize& size = wxDefaultSize, | |
100 | long style = 0, | |
101 | const wxValidator& validator = wxDefaultValidator, | |
102 | const wxString& name = wxCheckBoxNameStr); | |
103 | ||
104 | virtual void SetValue(bool value); | |
105 | virtual bool GetValue() const ; | |
106 | ||
107 | virtual void SetLabel(const wxString& label); | |
108 | ||
109 | virtual bool MSWCommand(WXUINT param, WXWORD id); | |
110 | virtual void Command(wxCommandEvent& event); | |
111 | ||
112 | // returns true if the platform should explicitly apply a theme border | |
113 | virtual bool CanApplyThemeBorder() const { return false; } | |
114 | ||
115 | protected: | |
116 | virtual wxBorder GetDefaultBorder() const { return wxBORDER_NONE; } | |
117 | virtual wxSize DoGetBestSize() const; | |
118 | ||
119 | virtual WXDWORD MSWGetStyle(long flags, WXDWORD *exstyle = NULL) const; | |
120 | ||
121 | private: | |
122 | DECLARE_DYNAMIC_CLASS_NO_COPY(wxToggleButton) | |
123 | }; | |
124 | ||
125 | #endif // _WX_TOGGLEBUTTON_H_ | |
126 |