1 /////////////////////////////////////////////////////////////////////////////
3 // Purpose: interface of wxControl
4 // Author: wxWidgets team
6 // Licence: wxWindows licence
7 /////////////////////////////////////////////////////////////////////////////
10 Flags used by wxControl::Ellipsize function.
15 wxELLIPSIZE_FLAGS_NONE
= 0,
18 Take mnemonics into account when calculating the text width.
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
28 wxELLIPSIZE_FLAGS_PROCESS_MNEMONICS
= 1,
31 Expand tabs in spaces when calculating the text width.
33 This flag tells wxControl::Ellipsize() to calculate the width of tab
34 characters @c '\\t' as 6 spaces.
36 wxELLIPSIZE_FLAGS_EXPAND_TABS
= 2,
38 /// The default flags for wxControl::Ellipsize.
39 wxELLIPSIZE_FLAGS_DEFAULT
= wxELLIPSIZE_FLAGS_PROCESS_MNEMONICS
|
40 wxELLIPSIZE_FLAGS_EXPAND_TABS
45 The different ellipsization modes supported by the
46 wxControl::Ellipsize function.
50 /// Don't ellipsize the text at all. @since 2.9.1
53 /// Put the ellipsis at the start of the string, if the string needs ellipsization.
56 /// Put the ellipsis in the middle of the string, if the string needs ellipsization.
59 /// Put the ellipsis at the end of the string, if the string needs ellipsization.
66 This is the base class for a control or "widget".
68 A control is generally a small window which processes user input and/or
69 displays one or more item of data.
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
77 @event{EVT_TEXT_PASTE(id, func)}
78 Clipboard content was pasted into the control.
86 class wxControl
: public wxWindow
90 Simulates the effect of the user issuing a command to the item.
94 virtual void Command(wxCommandEvent
& event
);
97 Returns the control's label, as it was passed to SetLabel().
99 Note that the returned string may contains mnemonics ("&" characters) if they were
100 passed to the SetLabel() function; use GetLabelText() if they are undesired.
102 Also note that the returned string is always the string which was passed to
103 SetLabel() but may be different from the string passed to SetLabelText()
104 (since this last one escapes mnemonic characters).
106 wxString
GetLabel() const;
109 Returns the control's label without mnemonics.
111 Note that because of the stripping of the mnemonics the returned string may differ
112 from the string which was passed to SetLabel() but should always be the same which
113 was passed to SetLabelText().
115 wxString
GetLabelText() const;
118 Sets the control's label.
120 All "&" characters in the @a label are special and indicate that the
121 following character is a @e mnemonic for this control and can be used to
122 activate it from the keyboard (typically by using @e Alt key in
123 combination with it). To insert a literal ampersand character, you need
124 to double it, i.e. use use "&&". If this behaviour is undesirable, use
125 SetLabelText() instead.
127 void SetLabel(const wxString
& label
);
130 Sets the control's label to exactly the given string.
132 Unlike SetLabel(), this function shows exactly the @a text passed to it
133 in the control, without interpreting ampersands in it in any way.
134 Notice that it means that the control can't have any mnemonic defined
135 for it using this function.
137 @see EscapeMnemonics()
139 void SetLabelText(const wxString
& text
);
142 public: // static functions
145 Returns the given @a label string without mnemonics ("&" characters).
147 static wxString
GetLabelText(const wxString
& label
);
150 Returns the given @a str string without mnemonics ("&" characters).
152 @note This function is identic to GetLabelText() and is provided both for symmetry
153 with the wxStaticText::RemoveMarkup() function and to allow to write more
154 readable code (since this function has a more descriptive name respect GetLabelText()).
156 static wxString
RemoveMnemonics(const wxString
& str
);
159 Escapes the special mnemonics characters ("&") in the given string.
161 This function can be helpful if you need to set the controls label to a
162 user-provided string. If the string contains ampersands, they wouldn't
163 appear on the display but be used instead to indicate that the
164 character following the first of them can be used as a control mnemonic.
165 While this can sometimes be desirable (e.g. to allow the user to
166 configure mnemonics of the controls), more often you will want to use
167 this function before passing a user-defined string to SetLabel().
168 Alternatively, if the label is entirely user-defined, you can just call
169 SetLabelText() directly -- but this function must be used if the label
170 is a combination of a part defined by program containing the control
171 mnemonics and a user-defined part.
174 The string such as it should appear on the display.
176 The same string with the ampersands in it doubled.
178 static wxString
EscapeMnemonics(const wxString
& text
);
181 Replaces parts of the @a label string with ellipsis, if needed, so
182 that it doesn't exceed @a maxWidth.
184 Note that this functions is guaranteed to always returns a string
185 whose rendering on the given DC takes less than @a maxWidth pixels
189 The string to ellipsize
191 The DC used to retrieve the character widths through the
192 wxDC::GetPartialTextExtents() function.
194 The ellipsization mode. This is the setting which determines
195 which part of the string should be replaced by the ellipsis.
196 See ::wxEllipsizeMode enumeration values for more info.
198 The maximum width of the returned string in pixels.
199 This argument determines how much characters of the string need to
200 be removed (and replaced by ellipsis).
202 One or more of the ::wxEllipsizeFlags enumeration values combined.
204 static wxString
Ellipsize(const wxString
& label
, const wxDC
& dc
,
205 wxEllipsizeMode mode
, int maxWidth
,
206 int flags
= wxELLIPSIZE_FLAGS_DEFAULT
);