]> git.saurik.com Git - wxWidgets.git/blame - docs/latex/wx/button.tex
Documented new constructor and overloaded Create methods.
[wxWidgets.git] / docs / latex / wx / button.tex
CommitLineData
a660d684
KB
1\section{\class{wxButton}}\label{wxbutton}
2
3A button is a control that contains a text string,
4and 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
6almost 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
954b8ae6
JS
15\wxheading{Include files}
16
17<wx/button.h>
18
a660d684
KB
19\wxheading{Window styles}
20
f6bcfd97
BP
21\twocolwidtha{5cm}%
22\begin{twocollist}\itemsep=0pt
8a094d7b
JS
23\twocolitem{\windowstyle{wxBU\_LEFT}}{Left-justifies the label. Windows only.}
24\twocolitem{\windowstyle{wxBU\_TOP}}{Aligns the label to the top of the button. Windows only.}
25\twocolitem{\windowstyle{wxBU\_RIGHT}}{Right-justifies the bitmap label. Windows only.}
26\twocolitem{\windowstyle{wxBU\_BOTTOM}}{Aligns the label to the bottom of the button. Windows only.}
7ef8bfc4 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 ).}
8a094d7b 28\twocolitem{\windowstyle{wxNO\_BORDER}}{Creates a flat button. Windows and GTK+ only.}
f6bcfd97 29\end{twocollist}
a660d684
KB
30
31See also \helpref{window styles overview}{windowstyles}.
32
5de76427
JS
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,
38when the button is clicked.}
39\end{twocollist}
40
a660d684
KB
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
51Default constructor.
52
eaaa6a06 53\func{}{wxButton}{\param{wxWindow* }{parent}, \param{wxWindowID}{ id}, \param{const wxString\& }{label},\rtfsp
a660d684 54\param{const wxPoint\& }{pos}, \param{const wxSize\& }{size = wxDefaultSize},\rtfsp
eaaa6a06 55\param{long}{ style = 0}, \param{const wxValidator\& }{validator}, \param{const wxString\& }{name = ``button"}}
a660d684
KB
56
57Constructor, creating and showing a button.
58
59\wxheading{Parameters}
60
61\docparam{parent}{Parent window. Must not be NULL.}
62
63\docparam{id}{Button identifier. A value of -1 indicates a default value.}
64
65\docparam{label}{Text to be displayed on the button.}
66
67\docparam{pos}{Button position.}
68
69\docparam{size}{Button size. If the default size (-1, -1) is specified then the button is sized
70appropriately for the text.}
71
72\docparam{style}{Window style. See \helpref{wxButton}{wxbutton}.}
73
74\docparam{validator}{Window validator.}
75
76\docparam{name}{Window name.}
77
78\wxheading{See also}
79
80\helpref{wxButton::Create}{wxbuttoncreate}, \helpref{wxValidator}{wxvalidator}
81
82\membersection{wxButton::\destruct{wxButton}}
83
84\func{}{\destruct{wxButton}}{\void}
85
86Destructor, destroying the button.
87
88\membersection{wxButton::Create}\label{wxbuttoncreate}
89
eaaa6a06 90\func{bool}{Create}{\param{wxWindow* }{parent}, \param{wxWindowID}{ id}, \param{const wxString\& }{label},\rtfsp
a660d684 91\param{const wxPoint\& }{pos}, \param{const wxSize\& }{size = wxDefaultSize},\rtfsp
eaaa6a06 92\param{long}{ style = 0}, \param{const wxValidator\& }{validator}, \param{const wxString\& }{name = ``button"}}
a660d684
KB
93
94Button creation function for two-step creation. For more details, see \helpref{wxButton::wxButton}{wxbuttonconstr}.
95
96\membersection{wxButton::GetLabel}\label{wxbuttongetlabel}
97
98\constfunc{wxString}{GetLabel}{\void}
99
100Returns the string label for the button.
101
102\wxheading{Return value}
103
104The button's label.
105
106\wxheading{See also}
107
108\helpref{wxButton::SetLabel}{wxbuttonsetlabel}
109
e1f36ff8
VZ
110\membersection{wxButton::GetDefaultSize}\label{wxbuttongetdefaultsize}
111
112\func{wxSize}{GetDefaultSize}{\void}
113
114Returns the default size for the buttons. It is advised to make all the dialog
115buttons of the same size and this function allows to retrieve the (platform and
116current font dependent size) which should be the best suited for this.
117
a660d684
KB
118\membersection{wxButton::SetDefault}\label{wxbuttonsetdefault}
119
120\func{void}{SetDefault}{\void}
121
122This sets the button to be the default item for the panel or dialog
123box.
124
125\wxheading{Remarks}
126
127Under Windows, only dialog box buttons respond to this function. As
128normal under Windows and Motif, pressing return causes the default button to
129be depressed when the return key is pressed. See also \helpref{wxWindow::SetFocus}{wxwindowsetfocus}\rtfsp
f7bd2698 130which sets the keyboard focus for windows and text panel items,\rtfsp
d7da9756 131and \helpref{wxPanel::SetDefaultItem}{wxpanelsetdefaultitem}.
a660d684
KB
132
133Note that under Motif, calling this function immediately after
134creation of a button and before the creation of other buttons
135will cause misalignment of the row of buttons, since default
136buttons are larger. To get around this, call {\it SetDefault}\rtfsp
137after you have created a row of buttons: wxWindows will
138then set the size of all buttons currently on the panel to
139the same size.
140
141\membersection{wxButton::SetLabel}\label{wxbuttonsetlabel}
142
143\func{void}{SetLabel}{\param{const wxString\& }{label}}
144
145Sets the string label for the button.
146
147\wxheading{Parameters}
148
149\docparam{label}{The label to set.}
150
151\wxheading{See also}
152
153\helpref{wxButton::GetLabel}{wxbuttongetlabel}
154