]> git.saurik.com Git - wxWidgets.git/blob - interface/button.h
3db1b2dcc3b99c0a4cfc50ad77a983227cf710f7
[wxWidgets.git] / interface / button.h
1 /////////////////////////////////////////////////////////////////////////////
2 // Name: button.h
3 // Purpose: documentation for wxButton class
4 // Author: wxWidgets team
5 // RCS-ID: $Id$
6 // Licence: wxWindows license
7 /////////////////////////////////////////////////////////////////////////////
8
9 /**
10 @class wxButton
11 @wxheader{button.h}
12
13 A button is a control that contains a text string,
14 and is one of the most common elements of a GUI. It may be placed on a
15 @ref overview_wxdialog "dialog box" or panel, or indeed
16 almost any other window.
17
18 @beginStyleTable
19 @style{wxBU_LEFT}:
20 Left-justifies the label. Windows and GTK+ only.
21 @style{wxBU_TOP}:
22 Aligns the label to the top of the button. Windows and GTK+ only.
23 @style{wxBU_RIGHT}:
24 Right-justifies the bitmap label. Windows and GTK+ only.
25 @style{wxBU_BOTTOM}:
26 Aligns the label to the bottom of the button. Windows and GTK+ only.
27 @style{wxBU_EXACTFIT}:
28 Creates the button as small as possible instead of making it of the
29 standard size (which is the default behaviour ).
30 @style{wxBORDER_NONE}:
31 Creates a flat button. Windows and GTK+ only.
32 @endStyleTable
33
34 @beginEventTable
35 @event{EVT_BUTTON(id, func)}:
36 Process a wxEVT_COMMAND_BUTTON_CLICKED event, when the button is
37 clicked.
38 @endEventTable
39
40 @library{wxcore}
41 @category{ctrl}
42 @appearance{button.png}
43
44 @seealso
45 wxBitmapButton
46 */
47 class wxButton : public wxControl
48 {
49 public:
50 //@{
51 /**
52 Constructor, creating and showing a button.
53 The preferred way to create standard buttons is to use default value of
54 @e label. If no label is supplied and @a id is one of standard IDs from
55 @ref overview_stockitems "this list", standard label will be used. In addition
56 to
57 that, the button will be decorated with stock icons under GTK+ 2.
58
59 @param parent
60 Parent window. Must not be @NULL.
61 @param id
62 Button identifier. A value of wxID_ANY indicates a default value.
63 @param label
64 Text to be displayed on the button.
65 @param pos
66 Button position.
67 @param size
68 Button size. If the default size is specified then the button is sized
69 appropriately for the text.
70 @param style
71 Window style. See wxButton.
72 @param validator
73 Window validator.
74 @param name
75 Window name.
76
77 @see Create(), wxValidator
78 */
79 wxButton();
80 wxButton(wxWindow* parent, wxWindowID id,
81 const wxString& label = wxEmptyString,
82 const wxPoint& pos = wxDefaultPosition,
83 const wxSize& size = wxDefaultSize,
84 long style = 0,
85 const wxValidator& validator = wxDefaultValidator,
86 const wxString& name = "button");
87 //@}
88
89 /**
90 Destructor, destroying the button.
91 */
92 ~wxButton();
93
94 /**
95 Button creation function for two-step creation. For more details, see
96 wxButton().
97 */
98 bool Create(wxWindow* parent, wxWindowID id,
99 const wxString& label = wxEmptyString,
100 const wxPoint& pos = wxDefaultPosition,
101 const wxSize& size = wxDefaultSize,
102 long style = 0,
103 const wxValidator& validator,
104 const wxString& name = "button");
105
106 /**
107 Returns the default size for the buttons. It is advised to make all the dialog
108 buttons of the same size and this function allows to retrieve the (platform and
109 current font dependent size) which should be the best suited for this.
110 */
111 wxSize GetDefaultSize();
112
113 /**
114 Returns the string label for the button.
115
116 @returns The button's label.
117
118 @see SetLabel()
119 */
120 wxString GetLabel();
121
122 /**
123 This sets the button to be the default item for the panel or dialog
124 box.
125
126 @remarks Under Windows, only dialog box buttons respond to this function.
127 As normal under Windows and Motif, pressing return
128 causes the default button to be depressed when the
129 return key is pressed. See also wxWindow::SetFocus
130 which sets the keyboard focus for windows and text
131 panel items, and wxTopLevelWindow::SetDefaultItem.
132 */
133 void SetDefault();
134
135 /**
136 Sets the string label for the button.
137
138 @param label
139 The label to set.
140 */
141 void SetLabel(const wxString& label);
142 };