]> git.saurik.com Git - wxWidgets.git/blame - docs/latex/wx/button.tex
Added wxDataViewTreeCtrl
[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,
3980000c 4and is one of the most common elements of a GUI. It may be placed on a
a660d684
KB
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
a7af285d
VZ
19\wxheading{Library}
20
21\helpref{wxCore}{librarieslist}
22
a660d684
KB
23\wxheading{Window styles}
24
f6bcfd97
BP
25\twocolwidtha{5cm}%
26\begin{twocollist}\itemsep=0pt
401e3b6e
VS
27\twocolitem{\windowstyle{wxBU\_LEFT}}{Left-justifies the label. Windows and GTK+ only.}
28\twocolitem{\windowstyle{wxBU\_TOP}}{Aligns the label to the top of the button. Windows and GTK+ only.}
29\twocolitem{\windowstyle{wxBU\_RIGHT}}{Right-justifies the bitmap label. Windows and GTK+ only.}
30\twocolitem{\windowstyle{wxBU\_BOTTOM}}{Aligns the label to the bottom of the button. Windows and GTK+ only.}
7ef8bfc4 31\twocolitem{\windowstyle{wxBU\_EXACTFIT}}{Creates the button as small as possible instead of making it of the standard size (which is the default behaviour ).}
0a42e3b6 32\twocolitem{\windowstyle{wxBORDER\_NONE}}{Creates a flat button. Windows and GTK+ only.}
f6bcfd97 33\end{twocollist}
a660d684
KB
34
35See also \helpref{window styles overview}{windowstyles}.
36
5de76427
JS
37\wxheading{Event handling}
38
39\twocolwidtha{7cm}%
40\begin{twocollist}\itemsep=0pt
41\twocolitem{{\bf EVT\_BUTTON(id, func)}}{Process a wxEVT\_COMMAND\_BUTTON\_CLICKED event,
42when the button is clicked.}
43\end{twocollist}
44
a660d684
KB
45\wxheading{See also}
46
47\helpref{wxBitmapButton}{wxbitmapbutton}
48
49\latexignore{\rtfignore{\wxheading{Members}}}
50
f510b7b2 51\membersection{wxButton::wxButton}\label{wxbuttonctor}
a660d684
KB
52
53\func{}{wxButton}{\void}
54
55Default constructor.
56
5f7bcb48 57\func{}{wxButton}{\param{wxWindow* }{parent}, \param{wxWindowID}{ id}, \param{const wxString\& }{label = wxEmptyString},\rtfsp
f38d3607 58\param{const wxPoint\& }{pos = wxDefaultPosition}, \param{const wxSize\& }{size = wxDefaultSize},\rtfsp
01a01d10 59\param{long}{ style = 0}, \param{const wxValidator\& }{validator = wxDefaultValidator}, \param{const wxString\& }{name = ``button"}}
a660d684
KB
60
61Constructor, creating and showing a button.
62
5f7bcb48
VS
63The preferred way to create standard buttons is to use default value of
64\arg{label}. If no label is supplied and \arg{id} is one of standard IDs from
dbd94b75 65\helpref{this list}{stockitems}, standard label will be used. In addition to
5f7bcb48 66that, the button will be decorated with stock icons under GTK+ 2.
401e3b6e 67
a660d684
KB
68\wxheading{Parameters}
69
70\docparam{parent}{Parent window. Must not be NULL.}
71
f38d3607 72\docparam{id}{Button identifier. A value of \texttt{wxID\_ANY} indicates a default value.}
a660d684
KB
73
74\docparam{label}{Text to be displayed on the button.}
75
76\docparam{pos}{Button position.}
77
f38d3607 78\docparam{size}{Button size. If the default size is specified then the button is sized
a660d684
KB
79appropriately for the text.}
80
81\docparam{style}{Window style. See \helpref{wxButton}{wxbutton}.}
82
83\docparam{validator}{Window validator.}
84
85\docparam{name}{Window name.}
86
87\wxheading{See also}
88
89\helpref{wxButton::Create}{wxbuttoncreate}, \helpref{wxValidator}{wxvalidator}
90
f510b7b2 91\membersection{wxButton::\destruct{wxButton}}\label{wxbuttondtor}
a660d684
KB
92
93\func{}{\destruct{wxButton}}{\void}
94
95Destructor, destroying the button.
96
97\membersection{wxButton::Create}\label{wxbuttoncreate}
98
5f7bcb48 99\func{bool}{Create}{\param{wxWindow* }{parent}, \param{wxWindowID}{ id}, \param{const wxString\& }{label = wxEmptyString},\rtfsp
f38d3607 100\param{const wxPoint\& }{pos = wxDefaultPosition}, \param{const wxSize\& }{size = wxDefaultSize},\rtfsp
eaaa6a06 101\param{long}{ style = 0}, \param{const wxValidator\& }{validator}, \param{const wxString\& }{name = ``button"}}
401e3b6e
VS
102
103Button creation function for two-step creation. For more details, see
f510b7b2 104\helpref{wxButton::wxButton}{wxbuttonctor}.
a660d684
KB
105
106\membersection{wxButton::GetLabel}\label{wxbuttongetlabel}
107
108\constfunc{wxString}{GetLabel}{\void}
109
110Returns the string label for the button.
111
112\wxheading{Return value}
113
114The button's label.
115
116\wxheading{See also}
117
118\helpref{wxButton::SetLabel}{wxbuttonsetlabel}
119
e1f36ff8
VZ
120\membersection{wxButton::GetDefaultSize}\label{wxbuttongetdefaultsize}
121
122\func{wxSize}{GetDefaultSize}{\void}
123
124Returns the default size for the buttons. It is advised to make all the dialog
125buttons of the same size and this function allows to retrieve the (platform and
126current font dependent size) which should be the best suited for this.
127
a660d684
KB
128\membersection{wxButton::SetDefault}\label{wxbuttonsetdefault}
129
130\func{void}{SetDefault}{\void}
131
132This sets the button to be the default item for the panel or dialog
133box.
134
135\wxheading{Remarks}
136
137Under Windows, only dialog box buttons respond to this function. As
138normal under Windows and Motif, pressing return causes the default button to
139be depressed when the return key is pressed. See also \helpref{wxWindow::SetFocus}{wxwindowsetfocus}\rtfsp
f7bd2698 140which sets the keyboard focus for windows and text panel items,\rtfsp
4334c3d5 141and \helpref{wxTopLevelWindow::SetDefaultItem}{wxtoplevelwindowsetdefaultitem}.
a660d684
KB
142
143Note that under Motif, calling this function immediately after
144creation of a button and before the creation of other buttons
145will cause misalignment of the row of buttons, since default
146buttons are larger. To get around this, call {\it SetDefault}\rtfsp
fc2171bd 147after you have created a row of buttons: wxWidgets will
a660d684
KB
148then set the size of all buttons currently on the panel to
149the same size.
150
151\membersection{wxButton::SetLabel}\label{wxbuttonsetlabel}
152
153\func{void}{SetLabel}{\param{const wxString\& }{label}}
154
155Sets the string label for the button.
156
157\wxheading{Parameters}
158
159\docparam{label}{The label to set.}
160
161\wxheading{See also}
162
163\helpref{wxButton::GetLabel}{wxbuttongetlabel}
164