]>
Commit | Line | Data |
---|---|---|
d14a1e28 RD |
1 | ///////////////////////////////////////////////////////////////////////////// |
2 | // Name: _button.i | |
3 | // Purpose: SWIG interface defs for wxButton, wxBitmapButton | |
4 | // | |
5 | // Author: Robin Dunn | |
6 | // | |
7 | // Created: 10-June-1998 | |
8 | // RCS-ID: $Id$ | |
9 | // Copyright: (c) 2003 by Total Control Software | |
10 | // Licence: wxWindows license | |
11 | ///////////////////////////////////////////////////////////////////////////// | |
12 | ||
13 | // Not a %module | |
14 | ||
15 | ||
16 | //--------------------------------------------------------------------------- | |
17 | %newgroup; | |
18 | ||
b2dc1044 | 19 | MAKE_CONST_WXSTRING(ButtonNameStr); |
d14a1e28 RD |
20 | |
21 | enum { | |
22 | wxBU_LEFT, | |
23 | wxBU_TOP, | |
24 | wxBU_RIGHT, | |
25 | wxBU_BOTTOM, | |
26 | ||
27 | wxBU_EXACTFIT, | |
28 | wxBU_AUTODRAW, | |
29 | }; | |
30 | ||
ab9bb9c0 RD |
31 | // enum wxStockItemID |
32 | // { | |
33 | // wxSTOCK_NONE = 0, | |
34 | // wxSTOCK_ADD, | |
35 | // wxSTOCK_APPLY, | |
36 | // wxSTOCK_BOLD, | |
37 | // wxSTOCK_CANCEL, | |
38 | // wxSTOCK_CLEAR, | |
39 | // wxSTOCK_CLOSE, | |
40 | // wxSTOCK_COPY, | |
41 | // wxSTOCK_CUT, | |
42 | // wxSTOCK_DELETE, | |
43 | // wxSTOCK_FIND, | |
44 | // wxSTOCK_FIND_AND_REPLACE, | |
45 | // wxSTOCK_GO_BACK, | |
46 | // wxSTOCK_GO_DOWN, | |
47 | // wxSTOCK_GO_FORWARD, | |
48 | // wxSTOCK_GO_UP, | |
49 | // wxSTOCK_HELP, | |
50 | // wxSTOCK_HOME, | |
51 | // wxSTOCK_INDENT, | |
52 | // wxSTOCK_INDEX, | |
53 | // wxSTOCK_ITALIC, | |
54 | // wxSTOCK_JUSTIFY_CENTER, | |
55 | // wxSTOCK_JUSTIFY_FILL, | |
56 | // wxSTOCK_JUSTIFY_LEFT, | |
57 | // wxSTOCK_JUSTIFY_RIGHT, | |
58 | // wxSTOCK_NEW, | |
59 | // wxSTOCK_NO, | |
60 | // wxSTOCK_OK, | |
61 | // wxSTOCK_OPEN, | |
62 | // wxSTOCK_PASTE, | |
63 | // wxSTOCK_PREFERENCES, | |
64 | // wxSTOCK_PRINT, | |
65 | // wxSTOCK_PRINT_PREVIEW, | |
66 | // wxSTOCK_PROPERTIES, | |
67 | // wxSTOCK_QUIT, | |
68 | // wxSTOCK_REDO, | |
69 | // wxSTOCK_REFRESH, | |
70 | // wxSTOCK_REMOVE, | |
71 | // wxSTOCK_REVERT_TO_SAVED, | |
72 | // wxSTOCK_SAVE, | |
73 | // wxSTOCK_SAVE_AS, | |
74 | // wxSTOCK_STOP, | |
75 | // wxSTOCK_UNDELETE, | |
76 | // wxSTOCK_UNDERLINE, | |
77 | // wxSTOCK_UNDO, | |
78 | // wxSTOCK_UNINDENT, | |
79 | // wxSTOCK_YES, | |
80 | // wxSTOCK_ZOOM_100, | |
81 | // wxSTOCK_ZOOM_FIT, | |
82 | // wxSTOCK_ZOOM_IN, | |
83 | // wxSTOCK_ZOOM_OUT | |
84 | // }; | |
85 | ||
d14a1e28 RD |
86 | //--------------------------------------------------------------------------- |
87 | ||
1e0c8722 | 88 | DocStr(wxButton, |
dce2bd22 RD |
89 | "A button is a control that contains a text string, and is one of the most |
90 | common elements of a GUI. It may be placed on a dialog box or panel, or | |
d07d2bc9 | 91 | indeed almost any other window.", " |
dce2bd22 RD |
92 | |
93 | Window Styles | |
94 | ------------- | |
95 | ============== ========================================== | |
ab9bb9c0 | 96 | wx.BU_LEFT Left-justifies the label. Windows and GTK+ only. |
dce2bd22 | 97 | wx.BU_TOP Aligns the label to the top of the button. |
ab9bb9c0 RD |
98 | Windows and GTK+ only. |
99 | wx.BU_RIGHT Right-justifies the bitmap label. Windows and GTK+ only. | |
dce2bd22 | 100 | wx.BU_BOTTOM Aligns the label to the bottom of the button. |
ab9bb9c0 | 101 | Windows and GTK+ only. |
dce2bd22 RD |
102 | wx.BU_EXACTFIT Creates the button as small as possible |
103 | instead of making it of the standard size | |
104 | (which is the default behaviour.) | |
105 | ============== ========================================== | |
106 | ||
107 | Events | |
108 | ------ | |
109 | ============ ========================================== | |
110 | EVT_BUTTON Sent when the button is clicked. | |
111 | ============ ========================================== | |
112 | ||
113 | :see: `wx.BitmapButton` | |
1e0c8722 | 114 | "); |
ab9bb9c0 RD |
115 | //, `wx.StockButton` |
116 | ||
1e0c8722 | 117 | |
ab1f7d2a RD |
118 | MustHaveApp(wxButton); |
119 | ||
d14a1e28 RD |
120 | class wxButton : public wxControl |
121 | { | |
122 | public: | |
2b9048c5 RD |
123 | %pythonAppend wxButton "self._setOORInfo(self)" |
124 | %pythonAppend wxButton() "" | |
b39c3fa0 | 125 | %typemap(out) wxButton*; // turn off this typemap |
d14a1e28 RD |
126 | |
127 | ||
dce2bd22 | 128 | DocCtorStr( |
d5573410 RD |
129 | wxButton(wxWindow* parent, wxWindowID id=-1, |
130 | const wxString& label=wxPyEmptyString, | |
dce2bd22 RD |
131 | const wxPoint& pos = wxDefaultPosition, |
132 | const wxSize& size = wxDefaultSize, | |
133 | long style = 0, | |
134 | const wxValidator& validator = wxDefaultValidator, | |
135 | const wxString& name = wxPyButtonNameStr), | |
d07d2bc9 | 136 | "Create and show a button.", ""); |
dce2bd22 RD |
137 | |
138 | DocCtorStrName( | |
139 | wxButton(), | |
d07d2bc9 | 140 | "Precreate a Button for 2-phase creation.", "", |
dce2bd22 RD |
141 | PreButton); |
142 | ||
ab9bb9c0 RD |
143 | // DocCtorStrName( |
144 | // wxButton(wxWindow *parent, wxWindowID id, | |
145 | // wxStockItemID stock, | |
146 | // const wxString& descriptiveLabel = wxPyEmptyString, | |
147 | // const wxPoint& pos = wxDefaultPosition, | |
148 | // long style = 0, | |
149 | // const wxValidator& validator = wxDefaultValidator, | |
150 | // const wxString& name = wxButtonNameStr), | |
151 | // "Used to create a stock `wx.Button`. Stock buttons are commonly used | |
152 | // buttons such as OK or Cancel. They have standard label and dimensions | |
153 | // and may have different appearance on some platforms (e.g. GTK+ 2 | |
154 | // decorates them with icons). Using this from is the preferred way of | |
155 | // creating standard buttons.", " | |
156 | ||
157 | // :param stock: The stock ID of the button to create. One of the following: | |
158 | ||
159 | // ============================ | |
160 | // ``wx.STOCK_NONE`` | |
161 | // ``wx.STOCK_ADD`` | |
162 | // ``wx.STOCK_APPLY`` | |
163 | // ``wx.STOCK_BOLD`` | |
164 | // ``wx.STOCK_CANCEL`` | |
165 | // ``wx.STOCK_CLEAR`` | |
166 | // ``wx.STOCK_CLOSE`` | |
167 | // ``wx.STOCK_COPY`` | |
168 | // ``wx.STOCK_CUT`` | |
169 | // ``wx.STOCK_DELETE`` | |
170 | // ``wx.STOCK_FIND`` | |
171 | // ``wx.STOCK_FIND_AND_REPLACE`` | |
172 | // ``wx.STOCK_GO_BACK`` | |
173 | // ``wx.STOCK_GO_DOWN`` | |
174 | // ``wx.STOCK_GO_FORWARD`` | |
175 | // ``wx.STOCK_GO_UP`` | |
176 | // ``wx.STOCK_HELP`` | |
177 | // ``wx.STOCK_HOME`` | |
178 | // ``wx.STOCK_INDENT`` | |
179 | // ``wx.STOCK_INDEX`` | |
180 | // ``wx.STOCK_ITALIC`` | |
181 | // ``wx.STOCK_JUSTIFY_CENTER`` | |
182 | // ``wx.STOCK_JUSTIFY_FILL`` | |
183 | // ``wx.STOCK_JUSTIFY_LEFT`` | |
184 | // ``wx.STOCK_JUSTIFY_RIGHT`` | |
185 | // ``wx.STOCK_NEW`` | |
186 | // ``wx.STOCK_NO`` | |
187 | // ``wx.STOCK_OK`` | |
188 | // ``wx.STOCK_OPEN`` | |
189 | // ``wx.STOCK_PASTE`` | |
190 | // ``wx.STOCK_PREFERENCES`` | |
191 | // ``wx.STOCK_PRINT`` | |
192 | // ``wx.STOCK_PRINT_PREVIEW`` | |
193 | // ``wx.STOCK_PROPERTIES`` | |
194 | // ``wx.STOCK_QUIT`` | |
195 | // ``wx.STOCK_REDO`` | |
196 | // ``wx.STOCK_REFRESH`` | |
197 | // ``wx.STOCK_REMOVE`` | |
198 | // ``wx.STOCK_REVERT_TO_SAVED`` | |
199 | // ``wx.STOCK_SAVE`` | |
200 | // ``wx.STOCK_SAVE_AS`` | |
201 | // ``wx.STOCK_STOP`` | |
202 | // ``wx.STOCK_UNDELETE`` | |
203 | // ``wx.STOCK_UNDERLINE`` | |
204 | // ``wx.STOCK_UNDO`` | |
205 | // ``wx.STOCK_UNINDENT`` | |
206 | // ``wx.STOCK_YES`` | |
207 | // ``wx.STOCK_ZOOM_100`` | |
208 | // ``wx.STOCK_ZOOM_FIT`` | |
209 | // ``wx.STOCK_ZOOM_IN`` | |
210 | // ``wx.STOCK_ZOOM_OUT`` | |
211 | // ============================ | |
212 | ||
213 | ||
214 | // :param descriptiveLabel: Optional label to be used on platforms | |
215 | // where standard buttons have descriptive rather than generic | |
216 | // labels. Mac is one such platforms, well-behaved Mac apps should use | |
217 | // descriptive labels (e.g. \"Save\" and \"Don't Save\" instead of \"OK\" | |
218 | // and \"Cancel\"). This argument is ignored on other platforms.", | |
219 | // StockButton); | |
220 | ||
221 | ||
b39c3fa0 RD |
222 | // Turn it back on again |
223 | %typemap(out) wxButton* { $result = wxPyMake_wxObject($1, $owner); } | |
224 | ||
225 | ||
dce2bd22 | 226 | DocDeclStr( |
d5573410 RD |
227 | bool , Create(wxWindow* parent, wxWindowID id=-1, |
228 | const wxString& label=wxPyEmptyString, | |
dce2bd22 RD |
229 | const wxPoint& pos = wxDefaultPosition, |
230 | const wxSize& size = wxDefaultSize, | |
231 | long style = 0, | |
232 | const wxValidator& validator = wxDefaultValidator, | |
233 | const wxString& name = wxPyButtonNameStr), | |
d07d2bc9 | 234 | "Acutally create the GUI Button for 2-phase creation.", ""); |
dce2bd22 | 235 | |
d14a1e28 | 236 | |
d14a1e28 | 237 | |
dce2bd22 RD |
238 | DocDeclStr( |
239 | void , SetDefault(), | |
d07d2bc9 | 240 | "This sets the button to be the default item for the panel or dialog box.", ""); |
dce2bd22 | 241 | |
d14a1e28 | 242 | |
dce2bd22 RD |
243 | DocDeclStr( |
244 | static wxSize , GetDefaultSize(), | |
d07d2bc9 | 245 | "Returns the default button size for this platform.", ""); |
880715c9 RD |
246 | |
247 | static wxVisualAttributes | |
248 | GetClassDefaultAttributes(wxWindowVariant variant = wxWINDOW_VARIANT_NORMAL); | |
d14a1e28 RD |
249 | }; |
250 | ||
251 | ||
252 | ||
253 | //--------------------------------------------------------------------------- | |
254 | ||
1e0c8722 | 255 | |
856bf319 RD |
256 | DocStr(wxBitmapButton, |
257 | "A Button that contains a bitmap. A bitmap button can be supplied with a | |
dce2bd22 | 258 | single bitmap, and wxWidgets will draw all button states using this bitmap. If |
856bf319 | 259 | the application needs more control, additional bitmaps for the selected state, |
d07d2bc9 | 260 | unpressed focused state, and greyed-out state may be supplied.", " |
856bf319 | 261 | |
dce2bd22 RD |
262 | Window Styles |
263 | ------------- | |
264 | ============== ============================================= | |
265 | wx.BU_AUTODRAW If this is specified, the button will be drawn | |
266 | automatically using the label bitmap only, | |
267 | providing a 3D-look border. If this style is | |
268 | not specified, the button will be drawn | |
269 | without borders and using all provided | |
856bf319 | 270 | bitmaps. WIN32 only. |
dce2bd22 RD |
271 | wx.BU_LEFT Left-justifies the label. WIN32 only. |
272 | wx.BU_TOP Aligns the label to the top of the button. WIN32 | |
273 | only. | |
274 | wx.BU_RIGHT Right-justifies the bitmap label. WIN32 only. | |
275 | wx.BU_BOTTOM Aligns the label to the bottom of the | |
276 | button. WIN32 only. | |
277 | wx.BU_EXACTFIT Creates the button as small as possible | |
278 | instead of making it of the standard size | |
279 | (which is the default behaviour.) | |
280 | ============== ============================================= | |
281 | ||
282 | Events | |
283 | ------ | |
284 | =========== ================================== | |
285 | EVT_BUTTON Sent when the button is clicked. | |
286 | =========== ================================== | |
287 | ||
288 | :see: `wx.Button`, `wx.Bitmap` | |
856bf319 | 289 | "); |
1e0c8722 | 290 | |
ab1f7d2a RD |
291 | MustHaveApp(wxBitmapButton); |
292 | ||
d14a1e28 RD |
293 | class wxBitmapButton : public wxButton |
294 | { | |
295 | public: | |
2b9048c5 RD |
296 | %pythonAppend wxBitmapButton "self._setOORInfo(self)" |
297 | %pythonAppend wxBitmapButton() "" | |
b39c3fa0 | 298 | %typemap(out) wxBitmapButton*; // turn off this typemap |
d14a1e28 | 299 | |
dce2bd22 | 300 | DocCtorStr( |
d5573410 RD |
301 | wxBitmapButton(wxWindow* parent, wxWindowID id=-1, |
302 | const wxBitmap& bitmap = wxNullBitmap, | |
dce2bd22 RD |
303 | const wxPoint& pos = wxDefaultPosition, |
304 | const wxSize& size = wxDefaultSize, | |
305 | long style = wxBU_AUTODRAW, | |
306 | const wxValidator& validator = wxDefaultValidator, | |
307 | const wxString& name = wxPyButtonNameStr), | |
d07d2bc9 | 308 | "Create and show a button with a bitmap for the label.", ""); |
dce2bd22 RD |
309 | |
310 | DocCtorStrName( | |
311 | wxBitmapButton(), | |
d07d2bc9 | 312 | "Precreate a BitmapButton for 2-phase creation.", "", |
dce2bd22 RD |
313 | PreBitmapButton); |
314 | ||
b39c3fa0 RD |
315 | // Turn it back on again |
316 | %typemap(out) wxBitmapButton* { $result = wxPyMake_wxObject($1, $owner); } | |
317 | ||
318 | ||
dce2bd22 | 319 | DocDeclStr( |
d5573410 RD |
320 | bool , Create(wxWindow* parent, wxWindowID id=-1, |
321 | const wxBitmap& bitmap = wxNullBitmap, | |
322 | const wxPoint& pos = wxDefaultPosition, | |
323 | const wxSize& size = wxDefaultSize, | |
324 | long style = wxBU_AUTODRAW, | |
325 | const wxValidator& validator = wxDefaultValidator, | |
dce2bd22 | 326 | const wxString& name = wxPyButtonNameStr), |
d07d2bc9 | 327 | "Acutally create the GUI BitmapButton for 2-phase creation.", ""); |
dce2bd22 | 328 | |
1e0c8722 | 329 | |
dce2bd22 RD |
330 | DocDeclStr( |
331 | wxBitmap , GetBitmapLabel(), | |
d07d2bc9 | 332 | "Returns the label bitmap (the one passed to the constructor).", ""); |
dce2bd22 RD |
333 | |
334 | DocDeclStr( | |
335 | wxBitmap , GetBitmapDisabled(), | |
d07d2bc9 | 336 | "Returns the bitmap for the disabled state.", ""); |
dce2bd22 RD |
337 | |
338 | DocDeclStr( | |
339 | wxBitmap , GetBitmapFocus(), | |
d07d2bc9 | 340 | "Returns the bitmap for the focused state.", ""); |
dce2bd22 | 341 | |
1e0c8722 | 342 | |
dce2bd22 RD |
343 | DocDeclStr( |
344 | wxBitmap , GetBitmapSelected(), | |
d07d2bc9 | 345 | "Returns the bitmap for the selected state.", ""); |
dce2bd22 | 346 | |
1e0c8722 | 347 | |
dce2bd22 RD |
348 | DocDeclStr( |
349 | void , SetBitmapDisabled(const wxBitmap& bitmap), | |
d07d2bc9 | 350 | "Sets the bitmap for the disabled button appearance.", ""); |
dce2bd22 | 351 | |
1e0c8722 | 352 | |
dce2bd22 RD |
353 | DocDeclStr( |
354 | void , SetBitmapFocus(const wxBitmap& bitmap), | |
d07d2bc9 | 355 | "Sets the bitmap for the button appearance when it has the keyboard focus.", ""); |
dce2bd22 | 356 | |
1e0c8722 | 357 | |
dce2bd22 RD |
358 | DocDeclStr( |
359 | void , SetBitmapSelected(const wxBitmap& bitmap), | |
d07d2bc9 | 360 | "Sets the bitmap for the selected (depressed) button appearance.", ""); |
dce2bd22 | 361 | |
1e0c8722 | 362 | |
dce2bd22 RD |
363 | DocDeclStr( |
364 | void , SetBitmapLabel(const wxBitmap& bitmap), | |
365 | "Sets the bitmap label for the button. This is the bitmap used for the | |
d07d2bc9 | 366 | unselected state, and for all other states if no other bitmaps are provided.", ""); |
dce2bd22 | 367 | |
d14a1e28 RD |
368 | |
369 | void SetMargins(int x, int y); | |
370 | int GetMarginX() const; | |
371 | int GetMarginY() const; | |
372 | }; | |
373 | ||
374 | ||
375 | //--------------------------------------------------------------------------- |