]> git.saurik.com Git - wxWidgets.git/blame - interface/wx/control.h
Correct wxFILTER_DIGITS handling broken by r63582.
[wxWidgets.git] / interface / wx / control.h
CommitLineData
23324ae1
FM
1/////////////////////////////////////////////////////////////////////////////
2// Name: control.h
e54c96f1 3// Purpose: interface of wxControl
23324ae1
FM
4// Author: wxWidgets team
5// RCS-ID: $Id$
6// Licence: wxWindows license
7/////////////////////////////////////////////////////////////////////////////
8
a78618b0
FM
9/**
10 Flags used by wxControl::Ellipsize function.
11*/
12enum wxEllipsizeFlags
13{
355ce7ad
VZ
14 /// No special flags.
15 wxELLIPSIZE_FLAGS_NONE = 0,
16
17 /**
18 Take mnemonics into account when calculating the text width.
19
20 With this flag when calculating the size of the passed string,
21 mnemonics characters (see wxControl::SetLabel) will be automatically
22 reduced to a single character. This leads to correct calculations only
23 if the string passed to Ellipsize() will be used with
24 wxControl::SetLabel. If you don't want ampersand to be interpreted as
25 mnemonics (e.g. because you use wxControl::SetLabelText) then don't use
26 this flag.
27 */
28 wxELLIPSIZE_FLAGS_PROCESS_MNEMONICS = 1,
29
30 /**
31 Expand tabs in spaces when calculating the text width.
32
33 This flag tells wxControl::Ellipsize() to calculate the width of tab
34 characters @c '\\t' as 6 spaces.
35 */
36 wxELLIPSIZE_FLAGS_EXPAND_TABS = 2,
a78618b0
FM
37
38 /// The default flags for wxControl::Ellipsize.
355ce7ad
VZ
39 wxELLIPSIZE_FLAGS_DEFAULT = wxELLIPSIZE_FLAGS_PROCESS_MNEMONICS|
40 wxELLIPSIZE_FLAGS_EXPAND_TABS
a78618b0
FM
41};
42
43
5c87527c
FM
44/**
45 The different ellipsization modes supported by the
46 wxControl::Ellipsize function.
47*/
48enum wxEllipsizeMode
49{
c937bcac
VZ
50 /// Don't ellipsize the text at all. @since 2.9.1
51 wxELLIPSIZE_NONE,
52
a78618b0 53 /// Put the ellipsis at the start of the string, if the string needs ellipsization.
5c87527c 54 wxELLIPSIZE_START,
a78618b0
FM
55
56 /// Put the ellipsis in the middle of the string, if the string needs ellipsization.
5c87527c 57 wxELLIPSIZE_MIDDLE,
a78618b0
FM
58
59 /// Put the ellipsis at the end of the string, if the string needs ellipsization.
5c87527c
FM
60 wxELLIPSIZE_END
61};
62
23324ae1
FM
63/**
64 @class wxControl
7c913512 65
cdbcf4c2 66 This is the base class for a control or "widget".
7c913512 67
23324ae1
FM
68 A control is generally a small window which processes user input and/or
69 displays one or more item of data.
7c913512 70
3051a44a
FM
71 @beginEventEmissionTable{wxClipboardTextEvent}
72 @event{EVT_TEXT_COPY(id, func)}
73 Some or all of the controls content was copied to the clipboard.
74 @event{EVT_TEXT_CUT(id, func)}
75 Some or all of the controls content was cut (i.e. copied and
76 deleted).
77 @event{EVT_TEXT_PASTE(id, func)}
78 Clipboard content was pasted into the control.
79 @endEventTable
80
23324ae1
FM
81 @library{wxcore}
82 @category{ctrl}
7c913512 83
e54c96f1 84 @see wxValidator
23324ae1
FM
85*/
86class wxControl : public wxWindow
87{
88public:
89 /**
bd0812fe
BP
90 Simulates the effect of the user issuing a command to the item.
91
92 @see wxCommandEvent
23324ae1 93 */
b7e94bd7 94 virtual void Command(wxCommandEvent& event);
23324ae1 95
5c87527c
FM
96 /**
97 Replaces parts of the @a label string with ellipsis, if needed, so
98 that it doesn't exceed @a maxWidth.
a37da0fa
FM
99
100 Note that this functions is guaranteed to always returns a string
101 whose rendering on the given DC takes less than @a maxWidth pixels
102 in horizontal.
5c87527c
FM
103
104 @param label
105 The string to ellipsize
106 @param dc
107 The DC used to retrieve the character widths through the
108 wxDC::GetPartialTextExtents() function.
109 @param mode
a37da0fa
FM
110 The ellipsization mode. This is the setting which determines
111 which part of the string should be replaced by the ellipsis.
112 See ::wxEllipsizeMode enumeration values for more info.
5c87527c
FM
113 @param maxWidth
114 The maximum width of the returned string in pixels.
a37da0fa
FM
115 This argument determines how much characters of the string need to
116 be removed (and replaced by ellipsis).
a78618b0 117 @param flags
a37da0fa 118 One or more of the ::wxEllipsizeFlags enumeration values combined.
5c87527c
FM
119 */
120 static wxString Ellipsize(const wxString& label, const wxDC& dc,
a78618b0 121 wxEllipsizeMode mode, int maxWidth,
355ce7ad 122 int flags = wxELLIPSIZE_FLAGS_DEFAULT);
5c87527c 123
23324ae1
FM
124 /**
125 Returns the control's text.
bd0812fe
BP
126
127 @note The returned string contains mnemonics ("&" characters) if it has
128 any, use GetLabelText() if they are undesired.
23324ae1 129 */
328f5751 130 wxString GetLabel() const;
23324ae1 131
23324ae1 132 /**
bd0812fe 133 Returns the control's label without mnemonics.
23324ae1 134 */
4707b84c 135 wxString GetLabelText() const;
bd0812fe
BP
136
137 /**
4520d583 138 Returns the given @a label string without mnemonics ("&" characters).
bd0812fe
BP
139 */
140 static wxString GetLabelText(const wxString& label);
23324ae1 141
4520d583
FM
142 /**
143 Removes the mnemonics ("&" characters) from the given string.
144 */
145 static wxString RemoveMnemonics(const wxString& str);
146
5b8b2c84
VZ
147 /**
148 Escape the special mnemonics characters ("&") in the given string.
149
150 This function can be helpful if you need to set the controls label to a
151 user-provided string. If the string contains ampersands, they wouldn't
152 appear on the display but be used instead to indicate that the
153 character following the first of them can be used as a control mnemonic.
154 While this can sometimes be desirable (e.g. to allow the user to
155 configure mnemonics of the controls), more often you will want to use
156 this function before passing a user-defined string to SetLabel().
157 Alternatively, if the label is entirely user-defined, you can just call
158 SetLabelText() directly -- but this function must be used if the label
159 is a combination of a part defined by program containing the control
160 mnemonics and a user-defined part.
161
162 @param text
163 The string such as it should appear on the display.
164 @return
165 The same string with the ampersands in it doubled.
166 */
167 static wxString EscapeMnemonics(const wxString& text);
168
23324ae1
FM
169 /**
170 Sets the item's text.
bd0812fe
BP
171
172 Any "&" characters in the @a label are special and indicate that the
4520d583 173 following character is a @e mnemonic for this control and can be used to
bd0812fe 174 activate it from the keyboard (typically by using @e Alt key in
5b8b2c84
VZ
175 combination with it). To insert a literal ampersand character, you need
176 to double it, i.e. use use "&&". If this behaviour is undesirable, use
177 SetLabelText() instead.
23324ae1
FM
178 */
179 void SetLabel(const wxString& label);
5b8b2c84
VZ
180
181 /**
182 Sets the item's text to exactly the given string.
183
184 Unlike SetLabel(), this function shows exactly the @a text passed to it
185 in the control, without interpreting ampersands in it in any way.
186 Notice that it means that the control can't have any mnemonic defined
187 for it using this function.
188
189 @see EscapeMnemonics()
190 */
191 void SetLabelText(const wxString& text);
23324ae1 192};
e54c96f1 193