1 /////////////////////////////////////////////////////////////////////////////
3 // Purpose: interface of wxControl
4 // Author: wxWidgets team
6 // Licence: wxWindows license
7 /////////////////////////////////////////////////////////////////////////////
10 Flags used by wxControl::Ellipsize function.
14 /// With this flag when calculating the size of the passed string, mnemonics
15 /// characters (see wxControl::SetLabel) will be automatically reduced to a
17 /// This leads to correct calculations only if the string passed to Ellipsize()
18 /// will be used with wxControl::SetLabel. If you don't want ampersand to
19 /// be interpreted as mnemonics (e.g. because you use wxControl::SetLabelText)
20 /// then don't use this flag.
21 wxELLIPSIZE_PROCESS_MNEMONICS
= 1,
23 /// This flag tells wxControl::Ellipsize to calculate the width of tab
24 /// characters @c '\\t' as 6 spaces.
25 wxELLIPSIZE_EXPAND_TAB
= 2,
27 /// The default flags for wxControl::Ellipsize.
28 wxELLIPSIZE_DEFAULT_FLAGS
= wxELLIPSIZE_PROCESS_MNEMONICS
|wxELLIPSIZE_EXPAND_TAB
33 The different ellipsization modes supported by the
34 wxControl::Ellipsize function.
38 /// Put the ellipsis at the start of the string, if the string needs ellipsization.
41 /// Put the ellipsis in the middle of the string, if the string needs ellipsization.
44 /// Put the ellipsis at the end of the string, if the string needs ellipsization.
51 This is the base class for a control or "widget".
53 A control is generally a small window which processes user input and/or
54 displays one or more item of data.
61 class wxControl
: public wxWindow
65 Simulates the effect of the user issuing a command to the item.
69 virtual void Command(wxCommandEvent
& event
);
72 Replaces parts of the @a label string with ellipsis, if needed, so
73 that it doesn't exceed @a maxWidth.
76 The string to ellipsize
78 The DC used to retrieve the character widths through the
79 wxDC::GetPartialTextExtents() function.
81 The ellipsization modes. See ::wxEllipsizeMode.
83 The maximum width of the returned string in pixels.
85 One or more of the ::wxEllipsize
87 static wxString
Ellipsize(const wxString
& label
, const wxDC
& dc
,
88 wxEllipsizeMode mode
, int maxWidth
,
89 int flags
= wxELLIPSIZE_DEFAULT_FLAGS
);
92 Returns the control's text.
94 @note The returned string contains mnemonics ("&" characters) if it has
95 any, use GetLabelText() if they are undesired.
97 wxString
GetLabel() const;
100 Returns the control's label without mnemonics.
102 wxString
GetLabelText() const;
105 Returns the given @a label string without mnemonics ("&" characters).
107 static wxString
GetLabelText(const wxString
& label
);
110 Removes the mnemonics ("&" characters) from the given string.
112 static wxString
RemoveMnemonics(const wxString
& str
);
115 Escape the special mnemonics characters ("&") in the given string.
117 This function can be helpful if you need to set the controls label to a
118 user-provided string. If the string contains ampersands, they wouldn't
119 appear on the display but be used instead to indicate that the
120 character following the first of them can be used as a control mnemonic.
121 While this can sometimes be desirable (e.g. to allow the user to
122 configure mnemonics of the controls), more often you will want to use
123 this function before passing a user-defined string to SetLabel().
124 Alternatively, if the label is entirely user-defined, you can just call
125 SetLabelText() directly -- but this function must be used if the label
126 is a combination of a part defined by program containing the control
127 mnemonics and a user-defined part.
130 The string such as it should appear on the display.
132 The same string with the ampersands in it doubled.
134 static wxString
EscapeMnemonics(const wxString
& text
);
137 Sets the item's text.
139 Any "&" characters in the @a label are special and indicate that the
140 following character is a @e mnemonic for this control and can be used to
141 activate it from the keyboard (typically by using @e Alt key in
142 combination with it). To insert a literal ampersand character, you need
143 to double it, i.e. use use "&&". If this behaviour is undesirable, use
144 SetLabelText() instead.
146 void SetLabel(const wxString
& label
);
149 Sets the item's text to exactly the given string.
151 Unlike SetLabel(), this function shows exactly the @a text passed to it
152 in the control, without interpreting ampersands in it in any way.
153 Notice that it means that the control can't have any mnemonic defined
154 for it using this function.
156 @see EscapeMnemonics()
158 void SetLabelText(const wxString
& text
);