1 \section{\class{wxButton
}}\label{wxbutton
}
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.
8 \wxheading{Derived from
}
10 \helpref{wxControl
}{wxcontrol
}\\
11 \helpref{wxWindow
}{wxwindow
}\\
12 \helpref{wxEvtHandler
}{wxevthandler
}\\
13 \helpref{wxObject
}{wxobject
}
15 \wxheading{Include files
}
21 \helpref{wxCore
}{librarieslist
}
23 \wxheading{Window styles
}
26 \begin{twocollist
}\itemsep=
0pt
27 \twocolitem{\windowstyle{wxBU
\_LEFT}}{Left-justifies the label. Windows and GTK+ only.
}
28 \twocolitem{\windowstyle{wxBU
\_TOP}}{Aligns the label to the top of the button. Windows and GTK+ only.
}
29 \twocolitem{\windowstyle{wxBU
\_RIGHT}}{Right-justifies the bitmap label. Windows and GTK+ only.
}
30 \twocolitem{\windowstyle{wxBU
\_BOTTOM}}{Aligns the label to the bottom of the button. Windows and GTK+ only.
}
31 \twocolitem{\windowstyle{wxBU
\_EXACTFIT}}{Creates the button as small as possible instead of making it of the standard size (which is the default behaviour ).
}
32 \twocolitem{\windowstyle{wxBORDER
\_NONE}}{Creates a flat button. Windows and GTK+ only.
}
35 See also
\helpref{window styles overview
}{windowstyles
}.
37 \wxheading{Event handling
}
40 \begin{twocollist
}\itemsep=
0pt
41 \twocolitem{{\bf EVT
\_BUTTON(id, func)
}}{Process a wxEVT
\_COMMAND\_BUTTON\_CLICKED event,
42 when the button is clicked.
}
47 \helpref{wxBitmapButton
}{wxbitmapbutton
}
49 \latexignore{\rtfignore{\wxheading{Members
}}}
51 \membersection{wxButton::wxButton
}\label{wxbuttonctor
}
53 \func{}{wxButton
}{\void}
57 \func{}{wxButton
}{\param{wxWindow*
}{parent
},
\param{wxWindowID
}{ id
},
\param{const wxString\&
}{label = wxEmptyString
},
\rtfsp
58 \param{const wxPoint\&
}{pos = wxDefaultPosition
},
\param{const wxSize\&
}{size = wxDefaultSize
},
\rtfsp
59 \param{long
}{ style =
0},
\param{const wxValidator\&
}{validator = wxDefaultValidator
},
\param{const wxString\&
}{name = ``button"
}}
61 Constructor, creating and showing a button.
63 The preferred way to create standard buttons is to use default value of
64 \arg{label
}. If no label is supplied and
\arg{id
} is one of standard IDs from
65 \helpref{this list
}{stockitems
}, standard label will be used. In addition to
66 that, the button will be decorated with stock icons under GTK+
2.
68 \wxheading{Parameters
}
70 \docparam{parent
}{Parent window. Must not be NULL.
}
72 \docparam{id
}{Button identifier. A value of
\texttt{wxID
\_ANY} indicates a default value.
}
74 \docparam{label
}{Text to be displayed on the button.
}
76 \docparam{pos
}{Button position.
}
78 \docparam{size
}{Button size. If the default size is specified then the button is sized
79 appropriately for the text.
}
81 \docparam{style
}{Window style. See
\helpref{wxButton
}{wxbutton
}.
}
83 \docparam{validator
}{Window validator.
}
85 \docparam{name
}{Window name.
}
89 \helpref{wxButton::Create
}{wxbuttoncreate
},
\helpref{wxValidator
}{wxvalidator
}
91 \membersection{wxButton::
\destruct{wxButton
}}\label{wxbuttondtor
}
93 \func{}{\destruct{wxButton
}}{\void}
95 Destructor, destroying the button.
97 \membersection{wxButton::Create
}\label{wxbuttoncreate
}
99 \func{bool
}{Create
}{\param{wxWindow*
}{parent
},
\param{wxWindowID
}{ id
},
\param{const wxString\&
}{label = wxEmptyString
},
\rtfsp
100 \param{const wxPoint\&
}{pos = wxDefaultPosition
},
\param{const wxSize\&
}{size = wxDefaultSize
},
\rtfsp
101 \param{long
}{ style =
0},
\param{const wxValidator\&
}{validator
},
\param{const wxString\&
}{name = ``button"
}}
103 Button creation function for two-step creation. For more details, see
104 \helpref{wxButton::wxButton
}{wxbuttonctor
}.
106 \membersection{wxButton::GetLabel
}\label{wxbuttongetlabel
}
108 \constfunc{wxString
}{GetLabel
}{\void}
110 Returns the string label for the button.
112 \wxheading{Return value
}
118 \helpref{wxButton::SetLabel
}{wxbuttonsetlabel
}
120 \membersection{wxButton::GetDefaultSize
}\label{wxbuttongetdefaultsize
}
122 \func{wxSize
}{GetDefaultSize
}{\void}
124 Returns the default size for the buttons. It is advised to make all the dialog
125 buttons of the same size and this function allows to retrieve the (platform and
126 current font dependent size) which should be the best suited for this.
128 \membersection{wxButton::SetDefault
}\label{wxbuttonsetdefault
}
130 \func{void
}{SetDefault
}{\void}
132 This sets the button to be the default item for the panel or dialog
137 Under Windows, only dialog box buttons respond to this function. As
138 normal under Windows and Motif, pressing return causes the default button to
139 be depressed when the return key is pressed. See also
\helpref{wxWindow::SetFocus
}{wxwindowsetfocus
}\rtfsp
140 which sets the keyboard focus for windows and text panel items,
\rtfsp
141 and
\helpref{wxTopLevelWindow::SetDefaultItem
}{wxtoplevelwindowsetdefaultitem
}.
143 Note that under Motif, calling this function immediately after
144 creation of a button and before the creation of other buttons
145 will cause misalignment of the row of buttons, since default
146 buttons are larger. To get around this, call
{\it SetDefault
}\rtfsp
147 after you have created a row of buttons: wxWidgets will
148 then set the size of all buttons currently on the panel to
151 \membersection{wxButton::SetLabel
}\label{wxbuttonsetlabel
}
153 \func{void
}{SetLabel
}{\param{const wxString\&
}{label
}}
155 Sets the string label for the button.
157 \wxheading{Parameters
}
159 \docparam{label
}{The label to set.
}
163 \helpref{wxButton::GetLabel
}{wxbuttongetlabel
}