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