]> git.saurik.com Git - wxWidgets.git/blob - wxPython/src/_button.i
Alpha is supported on GTK2 now!
[wxWidgets.git] / wxPython / src / _button.i
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
19 MAKE_CONST_WXSTRING(ButtonNameStr);
20
21 enum {
22 wxBU_LEFT,
23 wxBU_TOP,
24 wxBU_RIGHT,
25 wxBU_BOTTOM,
26
27 wxBU_EXACTFIT,
28 wxBU_AUTODRAW,
29 };
30
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
86 //---------------------------------------------------------------------------
87
88 DocStr(wxButton,
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
91 indeed almost any other window.", "
92
93 Window Styles
94 -------------
95 ============== ==========================================
96 wx.BU_LEFT Left-justifies the label. Windows and GTK+ only.
97 wx.BU_TOP Aligns the label to the top of the button.
98 Windows and GTK+ only.
99 wx.BU_RIGHT Right-justifies the bitmap label. Windows and GTK+ only.
100 wx.BU_BOTTOM Aligns the label to the bottom of the button.
101 Windows and GTK+ only.
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`
114 ");
115 //, `wx.StockButton`
116
117
118 MustHaveApp(wxButton);
119
120 class wxButton : public wxControl
121 {
122 public:
123 %pythonAppend wxButton "self._setOORInfo(self)"
124 %pythonAppend wxButton() ""
125 %typemap(out) wxButton*; // turn off this typemap
126
127
128 DocCtorStr(
129 wxButton(wxWindow* parent, wxWindowID id=-1,
130 const wxString& label=wxPyEmptyString,
131 const wxPoint& pos = wxDefaultPosition,
132 const wxSize& size = wxDefaultSize,
133 long style = 0,
134 const wxValidator& validator = wxDefaultValidator,
135 const wxString& name = wxPyButtonNameStr),
136 "Create and show a button.", "");
137
138 DocCtorStrName(
139 wxButton(),
140 "Precreate a Button for 2-phase creation.", "",
141 PreButton);
142
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
222 // Turn it back on again
223 %typemap(out) wxButton* { $result = wxPyMake_wxObject($1, $owner); }
224
225
226 DocDeclStr(
227 bool , Create(wxWindow* parent, wxWindowID id=-1,
228 const wxString& label=wxPyEmptyString,
229 const wxPoint& pos = wxDefaultPosition,
230 const wxSize& size = wxDefaultSize,
231 long style = 0,
232 const wxValidator& validator = wxDefaultValidator,
233 const wxString& name = wxPyButtonNameStr),
234 "Acutally create the GUI Button for 2-phase creation.", "");
235
236
237
238 DocDeclStr(
239 void , SetDefault(),
240 "This sets the button to be the default item for the panel or dialog box.", "");
241
242
243 DocDeclStr(
244 static wxSize , GetDefaultSize(),
245 "Returns the default button size for this platform.", "");
246
247 static wxVisualAttributes
248 GetClassDefaultAttributes(wxWindowVariant variant = wxWINDOW_VARIANT_NORMAL);
249 };
250
251
252
253 //---------------------------------------------------------------------------
254
255
256 DocStr(wxBitmapButton,
257 "A Button that contains a bitmap. A bitmap button can be supplied with a
258 single bitmap, and wxWidgets will draw all button states using this bitmap. If
259 the application needs more control, additional bitmaps for the selected state,
260 unpressed focused state, and greyed-out state may be supplied.", "
261
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
270 bitmaps. WIN32 only.
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`
289 ");
290
291 MustHaveApp(wxBitmapButton);
292
293 class wxBitmapButton : public wxButton
294 {
295 public:
296 %pythonAppend wxBitmapButton "self._setOORInfo(self)"
297 %pythonAppend wxBitmapButton() ""
298 %typemap(out) wxBitmapButton*; // turn off this typemap
299
300 DocCtorStr(
301 wxBitmapButton(wxWindow* parent, wxWindowID id=-1,
302 const wxBitmap& bitmap = wxNullBitmap,
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),
308 "Create and show a button with a bitmap for the label.", "");
309
310 DocCtorStrName(
311 wxBitmapButton(),
312 "Precreate a BitmapButton for 2-phase creation.", "",
313 PreBitmapButton);
314
315 // Turn it back on again
316 %typemap(out) wxBitmapButton* { $result = wxPyMake_wxObject($1, $owner); }
317
318
319 DocDeclStr(
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,
326 const wxString& name = wxPyButtonNameStr),
327 "Acutally create the GUI BitmapButton for 2-phase creation.", "");
328
329
330 DocDeclStr(
331 wxBitmap , GetBitmapLabel(),
332 "Returns the label bitmap (the one passed to the constructor).", "");
333
334 DocDeclStr(
335 wxBitmap , GetBitmapDisabled(),
336 "Returns the bitmap for the disabled state.", "");
337
338 DocDeclStr(
339 wxBitmap , GetBitmapFocus(),
340 "Returns the bitmap for the focused state.", "");
341
342
343 DocDeclStr(
344 wxBitmap , GetBitmapSelected(),
345 "Returns the bitmap for the selected state.", "");
346
347
348 DocDeclStr(
349 void , SetBitmapDisabled(const wxBitmap& bitmap),
350 "Sets the bitmap for the disabled button appearance.", "");
351
352
353 DocDeclStr(
354 void , SetBitmapFocus(const wxBitmap& bitmap),
355 "Sets the bitmap for the button appearance when it has the keyboard focus.", "");
356
357
358 DocDeclStr(
359 void , SetBitmapSelected(const wxBitmap& bitmap),
360 "Sets the bitmap for the selected (depressed) button appearance.", "");
361
362
363 DocDeclStr(
364 void , SetBitmapLabel(const wxBitmap& bitmap),
365 "Sets the bitmap label for the button. This is the bitmap used for the
366 unselected state, and for all other states if no other bitmaps are provided.", "");
367
368
369 void SetMargins(int x, int y);
370 int GetMarginX() const;
371 int GetMarginY() const;
372 };
373
374
375 //---------------------------------------------------------------------------