]> git.saurik.com Git - wxWidgets.git/blob - docs/latex/wx/button.tex
warning fix
[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. 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}
28
29 See also \helpref{window styles overview}{windowstyles}.
30
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,
36 when the button is clicked.}
37 \end{twocollist}
38
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
49 Default constructor.
50
51 \func{}{wxButton}{\param{wxWindow* }{parent}, \param{wxWindowID}{ id}, \param{const wxString\& }{label},\rtfsp
52 \param{const wxPoint\& }{pos}, \param{const wxSize\& }{size = wxDefaultSize},\rtfsp
53 \param{long}{ style = 0}, \param{const wxValidator\& }{validator}, \param{const wxString\& }{name = ``button"}}
54
55 Constructor, 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
68 appropriately 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
84 Destructor, destroying the button.
85
86 \membersection{wxButton::Create}\label{wxbuttoncreate}
87
88 \func{bool}{Create}{\param{wxWindow* }{parent}, \param{wxWindowID}{ id}, \param{const wxString\& }{label},\rtfsp
89 \param{const wxPoint\& }{pos}, \param{const wxSize\& }{size = wxDefaultSize},\rtfsp
90 \param{long}{ style = 0}, \param{const wxValidator\& }{validator}, \param{const wxString\& }{name = ``button"}}
91
92 Button 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
98 Returns the string label for the button.
99
100 \wxheading{Return value}
101
102 The button's label.
103
104 \wxheading{See also}
105
106 \helpref{wxButton::SetLabel}{wxbuttonsetlabel}
107
108 \membersection{wxButton::GetDefaultSize}\label{wxbuttongetdefaultsize}
109
110 \func{wxSize}{GetDefaultSize}{\void}
111
112 Returns the default size for the buttons. It is advised to make all the dialog
113 buttons of the same size and this function allows to retrieve the (platform and
114 current font dependent size) which should be the best suited for this.
115
116 \membersection{wxButton::SetDefault}\label{wxbuttonsetdefault}
117
118 \func{void}{SetDefault}{\void}
119
120 This sets the button to be the default item for the panel or dialog
121 box.
122
123 \wxheading{Remarks}
124
125 Under Windows, only dialog box buttons respond to this function. As
126 normal under Windows and Motif, pressing return causes the default button to
127 be depressed when the return key is pressed. See also \helpref{wxWindow::SetFocus}{wxwindowsetfocus}\rtfsp
128 which sets the keyboard focus for windows and text panel items,\rtfsp
129 and \helpref{wxPanel::SetDefaultItem}{wxpanelsetdefaultitem}.
130
131 Note that under Motif, calling this function immediately after
132 creation of a button and before the creation of other buttons
133 will cause misalignment of the row of buttons, since default
134 buttons are larger. To get around this, call {\it SetDefault}\rtfsp
135 after you have created a row of buttons: wxWindows will
136 then set the size of all buttons currently on the panel to
137 the same size.
138
139 \membersection{wxButton::SetLabel}\label{wxbuttonsetlabel}
140
141 \func{void}{SetLabel}{\param{const wxString\& }{label}}
142
143 Sets 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