]>
Commit | Line | Data |
---|---|---|
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::SetDefault}\label{wxbuttonsetdefault} | |
103 | ||
104 | \func{void}{SetDefault}{\void} | |
105 | ||
106 | This sets the button to be the default item for the panel or dialog | |
107 | box. | |
108 | ||
109 | \wxheading{Remarks} | |
110 | ||
111 | Under Windows, only dialog box buttons respond to this function. As | |
112 | normal under Windows and Motif, pressing return causes the default button to | |
113 | be depressed when the return key is pressed. See also \helpref{wxWindow::SetFocus}{wxwindowsetfocus}\rtfsp | |
114 | which sets the keyboard focus for windows and text panel items,\rtfsp | |
115 | and \helpref{wxWindow::GetDefaultItem}{wxwindowgetdefaultitem}. | |
116 | ||
117 | Note that under Motif, calling this function immediately after | |
118 | creation of a button and before the creation of other buttons | |
119 | will cause misalignment of the row of buttons, since default | |
120 | buttons are larger. To get around this, call {\it SetDefault}\rtfsp | |
121 | after you have created a row of buttons: wxWindows will | |
122 | then set the size of all buttons currently on the panel to | |
123 | the same size. | |
124 | ||
125 | \membersection{wxButton::SetLabel}\label{wxbuttonsetlabel} | |
126 | ||
127 | \func{void}{SetLabel}{\param{const wxString\& }{label}} | |
128 | ||
129 | Sets the string label for the button. | |
130 | ||
131 | \wxheading{Parameters} | |
132 | ||
133 | \docparam{label}{The label to set.} | |
134 | ||
135 | \wxheading{See also} | |
136 | ||
137 | \helpref{wxButton::GetLabel}{wxbuttongetlabel} | |
138 |