]>
Commit | Line | Data |
---|---|---|
1e6feb95 VZ |
1 | /////////////////////////////////////////////////////////////////////////////// |
2 | // Name: wx/univ/button.h | |
3 | // Purpose: wxButton for wxUniversal | |
4 | // Author: Vadim Zeitlin | |
5 | // Modified by: | |
6 | // Created: 15.08.00 | |
7 | // RCS-ID: $Id$ | |
442b35b5 | 8 | // Copyright: (c) 2000 SciTech Software, Inc. (www.scitechsoft.com) |
65571936 | 9 | // Licence: wxWindows licence |
1e6feb95 VZ |
10 | /////////////////////////////////////////////////////////////////////////////// |
11 | ||
12 | #ifndef _WX_UNIV_BUTTON_H_ | |
13 | #define _WX_UNIV_BUTTON_H_ | |
14 | ||
b5dbe15d | 15 | class WXDLLIMPEXP_FWD_CORE wxInputHandler; |
1e6feb95 VZ |
16 | |
17 | #include "wx/bitmap.h" | |
18 | ||
19 | // ---------------------------------------------------------------------------- | |
20 | // the actions supported by this control | |
21 | // ---------------------------------------------------------------------------- | |
22 | ||
23 | #define wxACTION_BUTTON_TOGGLE _T("toggle") // press/release the button | |
24 | #define wxACTION_BUTTON_PRESS _T("press") // press the button | |
25 | #define wxACTION_BUTTON_RELEASE _T("release") // release the button | |
26 | #define wxACTION_BUTTON_CLICK _T("click") // generate button click event | |
27 | ||
28 | // ---------------------------------------------------------------------------- | |
29 | // wxButton: a push button | |
30 | // ---------------------------------------------------------------------------- | |
31 | ||
53a2db12 | 32 | class WXDLLIMPEXP_CORE wxButton : public wxButtonBase |
1e6feb95 VZ |
33 | { |
34 | public: | |
6463b9f5 | 35 | wxButton() { Init(); } |
1e6feb95 VZ |
36 | wxButton(wxWindow *parent, |
37 | wxWindowID id, | |
38 | const wxBitmap& bitmap, | |
5f7bcb48 | 39 | const wxString& label = wxEmptyString, |
1e6feb95 VZ |
40 | const wxPoint& pos = wxDefaultPosition, |
41 | const wxSize& size = wxDefaultSize, | |
42 | long style = 0, | |
43 | const wxValidator& validator = wxDefaultValidator, | |
6463b9f5 JS |
44 | const wxString& name = wxButtonNameStr) |
45 | { | |
46 | Init(); | |
47 | ||
48 | Create(parent, id, bitmap, label, pos, size, style, validator, name); | |
49 | } | |
9467bdb7 | 50 | |
1e6feb95 VZ |
51 | wxButton(wxWindow *parent, |
52 | wxWindowID id, | |
5f7bcb48 | 53 | const wxString& label = wxEmptyString, |
1e6feb95 VZ |
54 | const wxPoint& pos = wxDefaultPosition, |
55 | const wxSize& size = wxDefaultSize, | |
56 | long style = 0, | |
57 | const wxValidator& validator = wxDefaultValidator, | |
6463b9f5 JS |
58 | const wxString& name = wxButtonNameStr) |
59 | { | |
60 | Init(); | |
61 | ||
62 | Create(parent, id, label, pos, size, style, validator, name); | |
63 | } | |
1e6feb95 VZ |
64 | |
65 | bool Create(wxWindow *parent, | |
66 | wxWindowID id, | |
5f7bcb48 | 67 | const wxString& label = wxEmptyString, |
1e6feb95 VZ |
68 | const wxPoint& pos = wxDefaultPosition, |
69 | const wxSize& size = wxDefaultSize, | |
70 | long style = 0, | |
71 | const wxValidator& validator = wxDefaultValidator, | |
72 | const wxString& name = wxButtonNameStr) | |
73 | { | |
74 | return Create(parent, id, wxNullBitmap, label, | |
75 | pos, size, style, validator, name); | |
76 | } | |
9467bdb7 | 77 | |
1e6feb95 VZ |
78 | bool Create(wxWindow *parent, |
79 | wxWindowID id, | |
80 | const wxBitmap& bitmap, | |
5f7bcb48 | 81 | const wxString& label = wxEmptyString, |
1e6feb95 VZ |
82 | const wxPoint& pos = wxDefaultPosition, |
83 | const wxSize& size = wxDefaultSize, | |
84 | long style = 0, | |
85 | const wxValidator& validator = wxDefaultValidator, | |
86 | const wxString& name = wxButtonNameStr); | |
87 | ||
88 | virtual ~wxButton(); | |
89 | ||
94aff5ff | 90 | virtual wxWindow *SetDefault(); |
1e6feb95 VZ |
91 | |
92 | virtual bool IsPressed() const { return m_isPressed; } | |
93 | virtual bool IsDefault() const { return m_isDefault; } | |
94 | ||
95 | // wxButton actions | |
bd88c1fa | 96 | virtual void Toggle(); |
1e6feb95 VZ |
97 | virtual void Press(); |
98 | virtual void Release(); | |
99 | virtual void Click(); | |
100 | ||
1e6feb95 VZ |
101 | virtual bool PerformAction(const wxControlAction& action, |
102 | long numArg = -1, | |
103 | const wxString& strArg = wxEmptyString); | |
6f02a879 VZ |
104 | |
105 | virtual bool CanBeHighlighted() const { return true; } | |
106 | ||
9467bdb7 VZ |
107 | static wxInputHandler *GetStdInputHandler(wxInputHandler *handlerDef); |
108 | virtual wxInputHandler *DoGetStdInputHandler(wxInputHandler *handlerDef) | |
109 | { | |
110 | return GetStdInputHandler(handlerDef); | |
111 | } | |
112 | ||
113 | ||
6f02a879 | 114 | protected: |
1e6feb95 | 115 | virtual wxSize DoGetBestClientSize() const; |
9467bdb7 | 116 | |
193e19cf | 117 | virtual bool DoDrawBackground(wxDC& dc); |
1e6feb95 VZ |
118 | virtual void DoDraw(wxControlRenderer *renderer); |
119 | ||
2352862a VZ |
120 | virtual void DoSetBitmap(const wxBitmap& bitmap, State which); |
121 | virtual void DoSetBitmapMargins(wxCoord x, wxCoord y); | |
122 | ||
1e6feb95 VZ |
123 | // common part of all ctors |
124 | void Init(); | |
125 | ||
126 | // current state | |
127 | bool m_isPressed, | |
128 | m_isDefault; | |
129 | ||
130 | // the (optional) image to show and the margins around it | |
131 | wxBitmap m_bitmap; | |
132 | wxCoord m_marginBmpX, | |
133 | m_marginBmpY; | |
134 | ||
135 | private: | |
136 | DECLARE_DYNAMIC_CLASS(wxButton) | |
137 | }; | |
138 | ||
1e6feb95 VZ |
139 | #endif // _WX_UNIV_BUTTON_H_ |
140 |