move Ellipsize() to wxControl so it can be easily used by other controls
[wxWidgets.git] / interface / wx / control.h
1 /////////////////////////////////////////////////////////////////////////////
2 // Name: control.h
3 // Purpose: interface of wxControl
4 // Author: wxWidgets team
5 // RCS-ID: $Id$
6 // Licence: wxWindows license
7 /////////////////////////////////////////////////////////////////////////////
8
9 /**
10 The different ellipsization modes supported by the
11 wxControl::Ellipsize function.
12 */
13 enum wxEllipsizeMode
14 {
15 wxELLIPSIZE_START,
16 wxELLIPSIZE_MIDDLE,
17 wxELLIPSIZE_END
18 };
19
20 /**
21 @class wxControl
22
23 This is the base class for a control or "widget".
24
25 A control is generally a small window which processes user input and/or
26 displays one or more item of data.
27
28 @library{wxcore}
29 @category{ctrl}
30
31 @see wxValidator
32 */
33 class wxControl : public wxWindow
34 {
35 public:
36 /**
37 Simulates the effect of the user issuing a command to the item.
38
39 @see wxCommandEvent
40 */
41 virtual void Command(wxCommandEvent& event);
42
43 /**
44 Replaces parts of the @a label string with ellipsis, if needed, so
45 that it doesn't exceed @a maxWidth.
46
47 @param label
48 The string to ellipsize
49 @param dc
50 The DC used to retrieve the character widths through the
51 wxDC::GetPartialTextExtents() function.
52 @param mode
53 The ellipsization modes. See ::wxEllipsizeMode.
54 @param maxWidth
55 The maximum width of the returned string in pixels.
56 */
57 static wxString Ellipsize(const wxString& label, const wxDC& dc,
58 wxEllipsizeMode mode, int maxWidth);
59
60 /**
61 Returns the control's text.
62
63 @note The returned string contains mnemonics ("&" characters) if it has
64 any, use GetLabelText() if they are undesired.
65 */
66 wxString GetLabel() const;
67
68 /**
69 Returns the control's label without mnemonics.
70 */
71 wxString GetLabelText() const;
72
73 /**
74 Returns the given @a label string without mnemonics ("&" characters).
75 */
76 static wxString GetLabelText(const wxString& label);
77
78 /**
79 Removes the mnemonics ("&" characters) from the given string.
80 */
81 static wxString RemoveMnemonics(const wxString& str);
82
83 /**
84 Sets the item's text.
85
86 Any "&" characters in the @a label are special and indicate that the
87 following character is a @e mnemonic for this control and can be used to
88 activate it from the keyboard (typically by using @e Alt key in
89 combination with it).
90 To insert a literal ampersand character, you need to double it, i.e. use "&&".
91 */
92 void SetLabel(const wxString& label);
93 };
94