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