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