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{Window styles
}
17 There are no special styles for wxButton.
19 See also
\helpref{window styles overview
}{windowstyles
}.
21 \wxheading{Event handling
}
24 \begin{twocollist
}\itemsep=
0pt
25 \twocolitem{{\bf EVT
\_BUTTON(id, func)
}}{Process a wxEVT
\_COMMAND\_BUTTON\_CLICKED event,
26 when the button is clicked.
}
31 \helpref{wxBitmapButton
}{wxbitmapbutton
}
33 \latexignore{\rtfignore{\wxheading{Members
}}}
35 \membersection{wxButton::wxButton
}\label{wxbuttonconstr
}
37 \func{}{wxButton
}{\void}
41 \func{}{wxButton
}{\param{wxWindow*
}{parent
},
\param{wxWindowID
}{ id
},
\param{const wxString\&
}{label
},
\rtfsp
42 \param{const wxPoint\&
}{pos
},
\param{const wxSize\&
}{size = wxDefaultSize
},
\rtfsp
43 \param{long
}{ style =
0},
\param{const wxValidator\&
}{validator
},
\param{const wxString\&
}{name = ``button"
}}
45 Constructor, creating and showing a button.
47 \wxheading{Parameters
}
49 \docparam{parent
}{Parent window. Must not be NULL.
}
51 \docparam{id
}{Button identifier. A value of -
1 indicates a default value.
}
53 \docparam{label
}{Text to be displayed on the button.
}
55 \docparam{pos
}{Button position.
}
57 \docparam{size
}{Button size. If the default size (-
1, -
1) is specified then the button is sized
58 appropriately for the text.
}
60 \docparam{style
}{Window style. See
\helpref{wxButton
}{wxbutton
}.
}
62 \docparam{validator
}{Window validator.
}
64 \docparam{name
}{Window name.
}
68 \helpref{wxButton::Create
}{wxbuttoncreate
},
\helpref{wxValidator
}{wxvalidator
}
70 \membersection{wxButton::
\destruct{wxButton
}}
72 \func{}{\destruct{wxButton
}}{\void}
74 Destructor, destroying the button.
76 \membersection{wxButton::Create
}\label{wxbuttoncreate
}
78 \func{bool
}{Create
}{\param{wxWindow*
}{parent
},
\param{wxWindowID
}{ id
},
\param{const wxString\&
}{label
},
\rtfsp
79 \param{const wxPoint\&
}{pos
},
\param{const wxSize\&
}{size = wxDefaultSize
},
\rtfsp
80 \param{long
}{ style =
0},
\param{const wxValidator\&
}{validator
},
\param{const wxString\&
}{name = ``button"
}}
82 Button creation function for two-step creation. For more details, see
\helpref{wxButton::wxButton
}{wxbuttonconstr
}.
84 \membersection{wxButton::GetLabel
}\label{wxbuttongetlabel
}
86 \constfunc{wxString
}{GetLabel
}{\void}
88 Returns the string label for the button.
90 \wxheading{Return value
}
96 \helpref{wxButton::SetLabel
}{wxbuttonsetlabel
}
98 \membersection{wxButton::SetDefault
}\label{wxbuttonsetdefault
}
100 \func{void
}{SetDefault
}{\void}
102 This sets the button to be the default item for the panel or dialog
107 Under Windows, only dialog box buttons respond to this function. As
108 normal under Windows and Motif, pressing return causes the default button to
109 be depressed when the return key is pressed. See also
\helpref{wxWindow::SetFocus
}{wxwindowsetfocus
}\rtfsp
110 which sets the keyboard focus for windows and text panel items,
\rtfsp
111 and
\helpref{wxWindow::GetDefaultItem
}{wxwindowgetdefaultitem
}.
113 Note that under Motif, calling this function immediately after
114 creation of a button and before the creation of other buttons
115 will cause misalignment of the row of buttons, since default
116 buttons are larger. To get around this, call
{\it SetDefault
}\rtfsp
117 after you have created a row of buttons: wxWindows will
118 then set the size of all buttons currently on the panel to
121 \membersection{wxButton::SetLabel
}\label{wxbuttonsetlabel
}
123 \func{void
}{SetLabel
}{\param{const wxString\&
}{label
}}
125 Sets the string label for the button.
127 \wxheading{Parameters
}
129 \docparam{label
}{The label to set.
}
133 \helpref{wxButton::GetLabel
}{wxbuttongetlabel
}