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