1 \section{\class{wxButton
}}\label{wxbutton
}
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.
8 \wxheading{Derived from
}
10 \helpref{wxControl
}{wxcontrol
}\\
11 \helpref{wxWindow
}{wxwindow
}\\
12 \helpref{wxEvtHandler
}{wxevthandler
}\\
13 \helpref{wxObject
}{wxobject
}
15 \wxheading{Include files
}
19 \wxheading{Window styles
}
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.
}
31 See also
\helpref{window styles overview
}{windowstyles
}.
33 \wxheading{Event handling
}
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.
}
43 \helpref{wxBitmapButton
}{wxbitmapbutton
}
45 \latexignore{\rtfignore{\wxheading{Members
}}}
47 \membersection{wxButton::wxButton
}\label{wxbuttonconstr
}
49 \func{}{wxButton
}{\void}
53 \func{}{wxButton
}{\param{wxWindow*
}{parent
},
\param{wxWindowID
}{ id
},
\param{const wxString\&
}{label
},
\rtfsp
54 \param{const wxPoint\&
}{pos
},
\param{const wxSize\&
}{size = wxDefaultSize
},
\rtfsp
55 \param{long
}{ style =
0},
\param{const wxValidator\&
}{validator
},
\param{const wxString\&
}{name = ``button"
}}
57 \func{}{wxButton
}{\param{wxWindow*
}{parent
},
\param{wxWindowID
}{ id
},
58 \param{wxStockItemID
}{ stock
},
\rtfsp
59 \param{const wxString\&
}{descriptiveLabel = wxEmptyString
},
\rtfsp
60 \param{const wxPoint\&
}{pos
},
\rtfsp
61 \param{long
}{ style =
0},
\param{const wxValidator\&
}{validator
},
\param{const wxString\&
}{name = ``button"
}}
63 Constructor, creating and showing a button.
65 The second form is used to create
{\em stock
} button. Stock buttons are
66 commonly used buttons such as OK or Cancel. They have standard label and
67 dimensions and may have different appearance on some platforms (e.g. GTK+
2
68 decorates them with icons). Using this from is preferred way of creating
71 \wxheading{Parameters
}
73 \docparam{parent
}{Parent window. Must not be NULL.
}
75 \docparam{id
}{Button identifier. A value of -
1 indicates a default value.
}
77 \docparam{label
}{Text to be displayed on the button.
}
79 \docparam{pos
}{Button position.
}
81 \docparam{size
}{Button size. If the default size (-
1, -
1) is specified then the button is sized
82 appropriately for the text.
}
84 \docparam{style
}{Window style. See
\helpref{wxButton
}{wxbutton
}.
}
86 \docparam{validator
}{Window validator.
}
88 \docparam{name
}{Window name.
}
90 \docparam{stock
}{Stock ID of the stock button to create. See the
91 \helpref{list of possible values
}{stockitems
}.
}
93 \docparam{descriptiveLabel
}{Optional label to be used on platforms where
94 standard buttons have descriptive rather than generic labels. Mac is one such
95 platforms, well-behaved Mac apps should use descriptive labels (e.g. "Save"
96 and "Don't Save" instead of "OK" and "Cancel"). This argument is ignored on
101 \helpref{wxButton::Create
}{wxbuttoncreate
},
\helpref{wxValidator
}{wxvalidator
}
103 \membersection{wxButton::
\destruct{wxButton
}}
105 \func{}{\destruct{wxButton
}}{\void}
107 Destructor, destroying the button.
109 \membersection{wxButton::Create
}\label{wxbuttoncreate
}
111 \func{bool
}{Create
}{\param{wxWindow*
}{parent
},
\param{wxWindowID
}{ id
},
\param{const wxString\&
}{label
},
\rtfsp
112 \param{const wxPoint\&
}{pos
},
\param{const wxSize\&
}{size = wxDefaultSize
},
\rtfsp
113 \param{long
}{ style =
0},
\param{const wxValidator\&
}{validator
},
\param{const wxString\&
}{name = ``button"
}}
115 \func{bool
}{Create
}{\param{wxWindow*
}{parent
},
\param{wxWindowID
}{ id
},
116 \param{wxStockItemID
}{ stock
},
\rtfsp
117 \param{const wxString\&
}{descriptiveLabel = wxEmptyString
},
\rtfsp
118 \param{const wxPoint\&
}{pos
},
\rtfsp
119 \param{long
}{ style =
0},
\param{const wxValidator\&
}{validator
},
\param{const wxString\&
}{name = ``button"
}}
121 Button creation function for two-step creation. For more details, see
122 \helpref{wxButton::wxButton
}{wxbuttonconstr
}.
124 \membersection{wxButton::GetLabel
}\label{wxbuttongetlabel
}
126 \constfunc{wxString
}{GetLabel
}{\void}
128 Returns the string label for the button.
130 \wxheading{Return value
}
136 \helpref{wxButton::SetLabel
}{wxbuttonsetlabel
}
138 \membersection{wxButton::GetDefaultSize
}\label{wxbuttongetdefaultsize
}
140 \func{wxSize
}{GetDefaultSize
}{\void}
142 Returns the default size for the buttons. It is advised to make all the dialog
143 buttons of the same size and this function allows to retrieve the (platform and
144 current font dependent size) which should be the best suited for this.
146 \membersection{wxButton::SetDefault
}\label{wxbuttonsetdefault
}
148 \func{void
}{SetDefault
}{\void}
150 This sets the button to be the default item for the panel or dialog
155 Under Windows, only dialog box buttons respond to this function. As
156 normal under Windows and Motif, pressing return causes the default button to
157 be depressed when the return key is pressed. See also
\helpref{wxWindow::SetFocus
}{wxwindowsetfocus
}\rtfsp
158 which sets the keyboard focus for windows and text panel items,
\rtfsp
159 and
\helpref{wxPanel::SetDefaultItem
}{wxpanelsetdefaultitem
}.
161 Note that under Motif, calling this function immediately after
162 creation of a button and before the creation of other buttons
163 will cause misalignment of the row of buttons, since default
164 buttons are larger. To get around this, call
{\it SetDefault
}\rtfsp
165 after you have created a row of buttons: wxWidgets will
166 then set the size of all buttons currently on the panel to
169 \membersection{wxButton::SetLabel
}\label{wxbuttonsetlabel
}
171 \func{void
}{SetLabel
}{\param{const wxString\&
}{label
}}
173 Sets the string label for the button.
175 \wxheading{Parameters
}
177 \docparam{label
}{The label to set.
}
181 \helpref{wxButton::GetLabel
}{wxbuttongetlabel
}