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