]> git.saurik.com Git - wxWidgets.git/blob - docs/latex/wx/button.tex
added stock buttons support
[wxWidgets.git] / docs / latex / wx / button.tex
1 \section{\class{wxButton}}\label{wxbutton}
2
3 A button is a control that contains a text string,
4 and is one of the commonest elements of a GUI. It may be placed on a
5 \rtfsp\helpref{dialog box}{wxdialog} or \helpref{panel}{wxpanel}, or indeed
6 almost any other window.
7
8 \wxheading{Derived from}
9
10 \helpref{wxControl}{wxcontrol}\\
11 \helpref{wxWindow}{wxwindow}\\
12 \helpref{wxEvtHandler}{wxevthandler}\\
13 \helpref{wxObject}{wxobject}
14
15 \wxheading{Include files}
16
17 <wx/button.h>
18
19 \wxheading{Window styles}
20
21 \twocolwidtha{5cm}%
22 \begin{twocollist}\itemsep=0pt
23 \twocolitem{\windowstyle{wxBU\_LEFT}}{Left-justifies the label. Windows and GTK+ only.}
24 \twocolitem{\windowstyle{wxBU\_TOP}}{Aligns the label to the top of the button. Windows and GTK+ only.}
25 \twocolitem{\windowstyle{wxBU\_RIGHT}}{Right-justifies the bitmap label. Windows and GTK+ only.}
26 \twocolitem{\windowstyle{wxBU\_BOTTOM}}{Aligns the label to the bottom of the button. Windows and GTK+ only.}
27 \twocolitem{\windowstyle{wxBU\_EXACTFIT}}{Creates the button as small as possible instead of making it of the standard size (which is the default behaviour ).}
28 \twocolitem{\windowstyle{wxNO\_BORDER}}{Creates a flat button. Windows and GTK+ only.}
29 \end{twocollist}
30
31 See also \helpref{window styles overview}{windowstyles}.
32
33 \wxheading{Event handling}
34
35 \twocolwidtha{7cm}%
36 \begin{twocollist}\itemsep=0pt
37 \twocolitem{{\bf EVT\_BUTTON(id, func)}}{Process a wxEVT\_COMMAND\_BUTTON\_CLICKED event,
38 when the button is clicked.}
39 \end{twocollist}
40
41 \wxheading{See also}
42
43 \helpref{wxBitmapButton}{wxbitmapbutton}
44
45 \latexignore{\rtfignore{\wxheading{Members}}}
46
47 \membersection{wxButton::wxButton}\label{wxbuttonconstr}
48
49 \func{}{wxButton}{\void}
50
51 Default constructor.
52
53 \func{}{wxButton}{\param{wxWindow* }{parent}, \param{wxWindowID}{ id}, \param{const wxString\& }{label},\rtfsp
54 \param{const wxPoint\& }{pos}, \param{const wxSize\& }{size = wxDefaultSize},\rtfsp
55 \param{long}{ style = 0}, \param{const wxValidator\& }{validator}, \param{const wxString\& }{name = ``button"}}
56
57 \func{}{wxButton}{\param{wxWindow* }{parent}, \param{wxWindowID}{ id},
58 \param{wxStockItemID}{ stock},\rtfsp
59 \param{const wxString\& }{descriptiveLabel = wxEmptyString},\rtfsp
60 \param{const wxPoint\& }{pos},\rtfsp
61 \param{long}{ style = 0}, \param{const wxValidator\& }{validator}, \param{const wxString\& }{name = ``button"}}
62
63 Constructor, creating and showing a button.
64
65 The second form is used to create {\em stock} button. Stock buttons are
66 commonly used buttons such as OK or Cancel. They have standard label and
67 dimensions and may have different appearance on some platforms (e.g. GTK+ 2
68 decorates them with icons). Using this from is preferred way of creating
69 standard buttons.
70
71 \wxheading{Parameters}
72
73 \docparam{parent}{Parent window. Must not be NULL.}
74
75 \docparam{id}{Button identifier. A value of -1 indicates a default value.}
76
77 \docparam{label}{Text to be displayed on the button.}
78
79 \docparam{pos}{Button position.}
80
81 \docparam{size}{Button size. If the default size (-1, -1) is specified then the button is sized
82 appropriately for the text.}
83
84 \docparam{style}{Window style. See \helpref{wxButton}{wxbutton}.}
85
86 \docparam{validator}{Window validator.}
87
88 \docparam{name}{Window name.}
89
90 \docparam{stock}{Stock ID of the stock button to create. See the
91 \helpref{list of possible values}{stockitems}.}
92
93 \docparam{descriptiveLabel}{Optional label to be used on platforms where
94 standard buttons have descriptive rather than generic labels. Mac is one such
95 platforms, well-behaved Mac apps should use descriptive labels (e.g. "Save"
96 and "Don't Save" instead of "OK" and "Cancel").}
97
98 \wxheading{See also}
99
100 \helpref{wxButton::Create}{wxbuttoncreate}, \helpref{wxValidator}{wxvalidator}
101
102 \membersection{wxButton::\destruct{wxButton}}
103
104 \func{}{\destruct{wxButton}}{\void}
105
106 Destructor, destroying the button.
107
108 \membersection{wxButton::Create}\label{wxbuttoncreate}
109
110 \func{bool}{Create}{\param{wxWindow* }{parent}, \param{wxWindowID}{ id}, \param{const wxString\& }{label},\rtfsp
111 \param{const wxPoint\& }{pos}, \param{const wxSize\& }{size = wxDefaultSize},\rtfsp
112 \param{long}{ style = 0}, \param{const wxValidator\& }{validator}, \param{const wxString\& }{name = ``button"}}
113
114 \func{bool}{Create}{\param{wxWindow* }{parent}, \param{wxWindowID}{ id},
115 \param{wxStockItemID}{ stock},\rtfsp
116 \param{const wxString\& }{descriptiveLabel = wxEmptyString},\rtfsp
117 \param{const wxPoint\& }{pos},\rtfsp
118 \param{long}{ style = 0}, \param{const wxValidator\& }{validator}, \param{const wxString\& }{name = ``button"}}
119
120 Button creation function for two-step creation. For more details, see
121 \helpref{wxButton::wxButton}{wxbuttonconstr}.
122
123 \membersection{wxButton::GetLabel}\label{wxbuttongetlabel}
124
125 \constfunc{wxString}{GetLabel}{\void}
126
127 Returns the string label for the button.
128
129 \wxheading{Return value}
130
131 The button's label.
132
133 \wxheading{See also}
134
135 \helpref{wxButton::SetLabel}{wxbuttonsetlabel}
136
137 \membersection{wxButton::GetDefaultSize}\label{wxbuttongetdefaultsize}
138
139 \func{wxSize}{GetDefaultSize}{\void}
140
141 Returns the default size for the buttons. It is advised to make all the dialog
142 buttons of the same size and this function allows to retrieve the (platform and
143 current font dependent size) which should be the best suited for this.
144
145 \membersection{wxButton::SetDefault}\label{wxbuttonsetdefault}
146
147 \func{void}{SetDefault}{\void}
148
149 This sets the button to be the default item for the panel or dialog
150 box.
151
152 \wxheading{Remarks}
153
154 Under Windows, only dialog box buttons respond to this function. As
155 normal under Windows and Motif, pressing return causes the default button to
156 be depressed when the return key is pressed. See also \helpref{wxWindow::SetFocus}{wxwindowsetfocus}\rtfsp
157 which sets the keyboard focus for windows and text panel items,\rtfsp
158 and \helpref{wxPanel::SetDefaultItem}{wxpanelsetdefaultitem}.
159
160 Note that under Motif, calling this function immediately after
161 creation of a button and before the creation of other buttons
162 will cause misalignment of the row of buttons, since default
163 buttons are larger. To get around this, call {\it SetDefault}\rtfsp
164 after you have created a row of buttons: wxWidgets will
165 then set the size of all buttons currently on the panel to
166 the same size.
167
168 \membersection{wxButton::SetLabel}\label{wxbuttonsetlabel}
169
170 \func{void}{SetLabel}{\param{const wxString\& }{label}}
171
172 Sets the string label for the button.
173
174 \wxheading{Parameters}
175
176 \docparam{label}{The label to set.}
177
178 \wxheading{See also}
179
180 \helpref{wxButton::GetLabel}{wxbuttongetlabel}
181