]> git.saurik.com Git - wxWidgets.git/blame - wxPython/src/_button.i
Avoid crash in SelectAll if there are no nodes besides the root
[wxWidgets.git] / wxPython / src / _button.i
CommitLineData
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 19MAKE_CONST_WXSTRING(ButtonNameStr);
d14a1e28
RD
20
21enum {
22 wxBU_LEFT,
23 wxBU_TOP,
24 wxBU_RIGHT,
25 wxBU_BOTTOM,
26
e7e14318
RD
27 wxBU_ALIGN_MASK,
28
d14a1e28
RD
29 wxBU_EXACTFIT,
30 wxBU_AUTODRAW,
31};
32
33//---------------------------------------------------------------------------
34
1e0c8722 35DocStr(wxButton,
dce2bd22
RD
36"A button is a control that contains a text string, and is one of the most
37common elements of a GUI. It may be placed on a dialog box or panel, or
d07d2bc9 38indeed almost any other window.", "
dce2bd22
RD
39
40Window Styles
41-------------
42 ============== ==========================================
ab9bb9c0 43 wx.BU_LEFT Left-justifies the label. Windows and GTK+ only.
dce2bd22 44 wx.BU_TOP Aligns the label to the top of the button.
ab9bb9c0
RD
45 Windows and GTK+ only.
46 wx.BU_RIGHT Right-justifies the bitmap label. Windows and GTK+ only.
dce2bd22 47 wx.BU_BOTTOM Aligns the label to the bottom of the button.
ab9bb9c0 48 Windows and GTK+ only.
dce2bd22
RD
49 wx.BU_EXACTFIT Creates the button as small as possible
50 instead of making it of the standard size
51 (which is the default behaviour.)
52 ============== ==========================================
53
54Events
55------
56 ============ ==========================================
57 EVT_BUTTON Sent when the button is clicked.
58 ============ ==========================================
59
60:see: `wx.BitmapButton`
1e0c8722 61");
ab9bb9c0 62
1e0c8722 63
ab1f7d2a
RD
64MustHaveApp(wxButton);
65
d14a1e28
RD
66class wxButton : public wxControl
67{
68public:
2b9048c5
RD
69 %pythonAppend wxButton "self._setOORInfo(self)"
70 %pythonAppend wxButton() ""
b39c3fa0 71 %typemap(out) wxButton*; // turn off this typemap
d14a1e28
RD
72
73
dce2bd22 74 DocCtorStr(
d5573410
RD
75 wxButton(wxWindow* parent, wxWindowID id=-1,
76 const wxString& label=wxPyEmptyString,
dce2bd22
RD
77 const wxPoint& pos = wxDefaultPosition,
78 const wxSize& size = wxDefaultSize,
79 long style = 0,
80 const wxValidator& validator = wxDefaultValidator,
81 const wxString& name = wxPyButtonNameStr),
1a1ed526
RD
82 "Create and show a button. The preferred way to create standard
83buttons is to use a standard ID and an empty label. In this case
84wxWigets will automatically use a stock label that coresponds to the
85ID given. In additon, the button will be decorated with stock icons
86under GTK+ 2.", "
87
88The stock IDs and coresponding labels are
89
b7287719 90 ===================== ======================
1a1ed526
RD
91 wx.ID_ADD 'Add'
92 wx.ID_APPLY '\&Apply'
93 wx.ID_BOLD '\&Bold'
94 wx.ID_CANCEL '\&Cancel'
95 wx.ID_CLEAR '\&Clear'
96 wx.ID_CLOSE '\&Close'
97 wx.ID_COPY '\&Copy'
98 wx.ID_CUT 'Cu\&t'
99 wx.ID_DELETE '\&Delete'
100 wx.ID_FIND '\&Find'
101 wx.ID_REPLACE 'Find and rep\&lace'
102 wx.ID_BACKWARD '\&Back'
103 wx.ID_DOWN '\&Down'
104 wx.ID_FORWARD '\&Forward'
105 wx.ID_UP '\&Up'
106 wx.ID_HELP '\&Help'
107 wx.ID_HOME '\&Home'
108 wx.ID_INDENT 'Indent'
109 wx.ID_INDEX '\&Index'
110 wx.ID_ITALIC '\&Italic'
111 wx.ID_JUSTIFY_CENTER 'Centered'
112 wx.ID_JUSTIFY_FILL 'Justified'
113 wx.ID_JUSTIFY_LEFT 'Align Left'
114 wx.ID_JUSTIFY_RIGHT 'Align Right'
115 wx.ID_NEW '\&New'
116 wx.ID_NO '\&No'
117 wx.ID_OK '\&OK'
118 wx.ID_OPEN '\&Open'
119 wx.ID_PASTE '\&Paste'
120 wx.ID_PREFERENCES '\&Preferences'
121 wx.ID_PRINT '\&Print'
122 wx.ID_PREVIEW 'Print previe\&w'
123 wx.ID_PROPERTIES '\&Properties'
124 wx.ID_EXIT '\&Quit'
125 wx.ID_REDO '\&Redo'
126 wx.ID_REFRESH 'Refresh'
127 wx.ID_REMOVE 'Remove'
128 wx.ID_REVERT_TO_SAVED 'Revert to Saved'
129 wx.ID_SAVE '\&Save'
130 wx.ID_SAVEAS 'Save \&As...'
131 wx.ID_STOP '\&Stop'
132 wx.ID_UNDELETE 'Undelete'
133 wx.ID_UNDERLINE '\&Underline'
134 wx.ID_UNDO '\&Undo'
135 wx.ID_UNINDENT '\&Unindent'
136 wx.ID_YES '\&Yes'
137 wx.ID_ZOOM_100 '\&Actual Size'
138 wx.ID_ZOOM_FIT 'Zoom to \&Fit'
139 wx.ID_ZOOM_IN 'Zoom \&In'
140 wx.ID_ZOOM_OUT 'Zoom \&Out'
b7287719 141 ===================== ======================
1a1ed526 142");
dce2bd22
RD
143
144 DocCtorStrName(
145 wxButton(),
d07d2bc9 146 "Precreate a Button for 2-phase creation.", "",
dce2bd22
RD
147 PreButton);
148
b39c3fa0
RD
149 // Turn it back on again
150 %typemap(out) wxButton* { $result = wxPyMake_wxObject($1, $owner); }
151
152
dce2bd22 153 DocDeclStr(
d5573410
RD
154 bool , Create(wxWindow* parent, wxWindowID id=-1,
155 const wxString& label=wxPyEmptyString,
dce2bd22
RD
156 const wxPoint& pos = wxDefaultPosition,
157 const wxSize& size = wxDefaultSize,
158 long style = 0,
159 const wxValidator& validator = wxDefaultValidator,
160 const wxString& name = wxPyButtonNameStr),
d07d2bc9 161 "Acutally create the GUI Button for 2-phase creation.", "");
dce2bd22 162
d14a1e28 163
d14a1e28 164
dce2bd22
RD
165 DocDeclStr(
166 void , SetDefault(),
d07d2bc9 167 "This sets the button to be the default item for the panel or dialog box.", "");
dce2bd22 168
d14a1e28 169
dce2bd22
RD
170 DocDeclStr(
171 static wxSize , GetDefaultSize(),
d07d2bc9 172 "Returns the default button size for this platform.", "");
880715c9
RD
173
174 static wxVisualAttributes
175 GetClassDefaultAttributes(wxWindowVariant variant = wxWINDOW_VARIANT_NORMAL);
d14a1e28
RD
176};
177
178
179
180//---------------------------------------------------------------------------
181
1e0c8722 182
856bf319
RD
183DocStr(wxBitmapButton,
184"A Button that contains a bitmap. A bitmap button can be supplied with a
dce2bd22 185single bitmap, and wxWidgets will draw all button states using this bitmap. If
856bf319 186the application needs more control, additional bitmaps for the selected state,
d07d2bc9 187unpressed focused state, and greyed-out state may be supplied.", "
856bf319 188
dce2bd22
RD
189Window Styles
190-------------
191 ============== =============================================
192 wx.BU_AUTODRAW If this is specified, the button will be drawn
193 automatically using the label bitmap only,
194 providing a 3D-look border. If this style is
195 not specified, the button will be drawn
196 without borders and using all provided
856bf319 197 bitmaps. WIN32 only.
dce2bd22
RD
198 wx.BU_LEFT Left-justifies the label. WIN32 only.
199 wx.BU_TOP Aligns the label to the top of the button. WIN32
200 only.
201 wx.BU_RIGHT Right-justifies the bitmap label. WIN32 only.
202 wx.BU_BOTTOM Aligns the label to the bottom of the
203 button. WIN32 only.
204 wx.BU_EXACTFIT Creates the button as small as possible
205 instead of making it of the standard size
206 (which is the default behaviour.)
207 ============== =============================================
208
209Events
210------
211 =========== ==================================
212 EVT_BUTTON Sent when the button is clicked.
213 =========== ==================================
214
215:see: `wx.Button`, `wx.Bitmap`
856bf319 216");
1e0c8722 217
ab1f7d2a
RD
218MustHaveApp(wxBitmapButton);
219
d14a1e28
RD
220class wxBitmapButton : public wxButton
221{
222public:
2b9048c5
RD
223 %pythonAppend wxBitmapButton "self._setOORInfo(self)"
224 %pythonAppend wxBitmapButton() ""
b39c3fa0 225 %typemap(out) wxBitmapButton*; // turn off this typemap
d14a1e28 226
dce2bd22 227 DocCtorStr(
d5573410
RD
228 wxBitmapButton(wxWindow* parent, wxWindowID id=-1,
229 const wxBitmap& bitmap = wxNullBitmap,
dce2bd22
RD
230 const wxPoint& pos = wxDefaultPosition,
231 const wxSize& size = wxDefaultSize,
232 long style = wxBU_AUTODRAW,
233 const wxValidator& validator = wxDefaultValidator,
234 const wxString& name = wxPyButtonNameStr),
d07d2bc9 235 "Create and show a button with a bitmap for the label.", "");
dce2bd22
RD
236
237 DocCtorStrName(
238 wxBitmapButton(),
d07d2bc9 239 "Precreate a BitmapButton for 2-phase creation.", "",
dce2bd22
RD
240 PreBitmapButton);
241
b39c3fa0
RD
242 // Turn it back on again
243 %typemap(out) wxBitmapButton* { $result = wxPyMake_wxObject($1, $owner); }
244
245
dce2bd22 246 DocDeclStr(
d5573410
RD
247 bool , Create(wxWindow* parent, wxWindowID id=-1,
248 const wxBitmap& bitmap = wxNullBitmap,
249 const wxPoint& pos = wxDefaultPosition,
250 const wxSize& size = wxDefaultSize,
251 long style = wxBU_AUTODRAW,
252 const wxValidator& validator = wxDefaultValidator,
dce2bd22 253 const wxString& name = wxPyButtonNameStr),
d07d2bc9 254 "Acutally create the GUI BitmapButton for 2-phase creation.", "");
dce2bd22 255
1e0c8722 256
dce2bd22
RD
257 DocDeclStr(
258 wxBitmap , GetBitmapLabel(),
d07d2bc9 259 "Returns the label bitmap (the one passed to the constructor).", "");
dce2bd22
RD
260
261 DocDeclStr(
262 wxBitmap , GetBitmapDisabled(),
d07d2bc9 263 "Returns the bitmap for the disabled state.", "");
dce2bd22
RD
264
265 DocDeclStr(
266 wxBitmap , GetBitmapFocus(),
d07d2bc9 267 "Returns the bitmap for the focused state.", "");
dce2bd22 268
1e0c8722 269
dce2bd22
RD
270 DocDeclStr(
271 wxBitmap , GetBitmapSelected(),
d07d2bc9 272 "Returns the bitmap for the selected state.", "");
dce2bd22 273
f2e29d54
RD
274 DocDeclStr(
275 wxBitmap , GetBitmapHover(),
276 "Returns the bitmap used when the mouse is over the button, may be invalid.", "");
277
1e0c8722 278
dce2bd22
RD
279 DocDeclStr(
280 void , SetBitmapDisabled(const wxBitmap& bitmap),
d07d2bc9 281 "Sets the bitmap for the disabled button appearance.", "");
dce2bd22 282
1e0c8722 283
dce2bd22
RD
284 DocDeclStr(
285 void , SetBitmapFocus(const wxBitmap& bitmap),
d07d2bc9 286 "Sets the bitmap for the button appearance when it has the keyboard focus.", "");
dce2bd22 287
1e0c8722 288
dce2bd22
RD
289 DocDeclStr(
290 void , SetBitmapSelected(const wxBitmap& bitmap),
d07d2bc9 291 "Sets the bitmap for the selected (depressed) button appearance.", "");
dce2bd22 292
1e0c8722 293
dce2bd22
RD
294 DocDeclStr(
295 void , SetBitmapLabel(const wxBitmap& bitmap),
296 "Sets the bitmap label for the button. This is the bitmap used for the
d07d2bc9 297unselected state, and for all other states if no other bitmaps are provided.", "");
d14a1e28 298
f2e29d54
RD
299
300 DocDeclStr(
301 void , SetBitmapHover(const wxBitmap& hover),
302 "Sets the bitmap to be shown when the mouse is over the button. This function
303is new since wxWidgets version 2.7.0 and the hover bitmap is currently only
304supported in wxMSW.", "");
305
d14a1e28
RD
306 void SetMargins(int x, int y);
307 int GetMarginX() const;
308 int GetMarginY() const;
309};
310
311
312//---------------------------------------------------------------------------