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