]> git.saurik.com Git - wxWidgets.git/blob - include/wx/stattext.h
no real change: rename wxPendingEvents to wxHandlersWithPendingEvents since its curre...
[wxWidgets.git] / include / wx / stattext.h
1 /////////////////////////////////////////////////////////////////////////////
2 // Name: stattext.h
3 // Purpose: wxStaticText base header
4 // Author: Julian Smart
5 // Modified by:
6 // Created:
7 // Copyright: (c) Julian Smart
8 // RCS-ID: $Id$
9 // Licence: wxWindows licence
10 /////////////////////////////////////////////////////////////////////////////
11
12 #ifndef _WX_STATTEXT_H_BASE_
13 #define _WX_STATTEXT_H_BASE_
14
15 #include "wx/defs.h"
16
17 #if wxUSE_STATTEXT
18
19 #include "wx/control.h"
20
21 /*
22 * wxStaticText flags
23 */
24 #define wxST_NO_AUTORESIZE 0x0001
25 #define wxST_MARKUP 0x0002
26
27 // NOTE: the members of this enum are used both as window styles for wxStaticText
28 // and both as enumeration values for wxStaticText::Ellipsize static function
29 enum wxEllipsizeMode
30 {
31 wxST_ELLIPSIZE_START = 0x0004,
32 wxST_ELLIPSIZE_MIDDLE = 0x0008,
33 wxST_ELLIPSIZE_END = 0x0010
34 };
35
36 extern WXDLLIMPEXP_DATA_CORE(const char) wxStaticTextNameStr[];
37
38 class WXDLLIMPEXP_CORE wxStaticTextBase : public wxControl
39 {
40 public:
41 wxStaticTextBase() { }
42
43 // wrap the text of the control so that no line is longer than the given
44 // width (if possible: this function won't break words)
45 // This function will modify the value returned by GetLabel()!
46 void Wrap(int width);
47
48 // overriden base virtuals
49 virtual bool AcceptsFocus() const { return false; }
50 virtual bool HasTransparentBackground() { return true; }
51
52 bool IsEllipsized() const
53 {
54 return HasFlag(wxST_ELLIPSIZE_START) ||
55 HasFlag(wxST_ELLIPSIZE_MIDDLE) ||
56 HasFlag(wxST_ELLIPSIZE_END);
57 }
58
59 // get the string without mnemonic characters ('&') and without markup
60 // (if wxST_MARKUP is being used)
61 virtual wxString GetLabelText() const;
62
63 // public utilities (symmetric to those in wxControl about mnemonics):
64
65 // get the string without mnemonic characters ('&') and without markup
66 static wxString GetLabelText(const wxString& label);
67
68 // removes the markup accepted by wxStaticText when wxST_MARKUP is used,
69 // and then returns the cleaned string
70 static wxString RemoveMarkup(const wxString& str);
71
72 // escapes all special symbols (<>"'&) present in the given string
73 // using the corresponding entities (&lt; &gt; &quot; &apos; &amp;)
74 static wxString EscapeMarkup(const wxString& str);
75
76 // replaces parts of the string with ellipsis if needed
77 static wxString Ellipsize(const wxString& label, const wxDC& dc,
78 wxEllipsizeMode mode, int maxWidth);
79
80 protected: // functions required for wxST_ELLIPSIZE_* support
81
82 // choose the default border for this window
83 virtual wxBorder GetDefaultBorder() const { return wxBORDER_NONE; }
84
85 // just calls RemoveMarkup & Ellipsize on the original label.
86 virtual wxString GetEllipsizedLabelWithoutMarkup() const;
87
88 // replaces parts of the string with ellipsis if needed
89 wxString Ellipsize(const wxString& label) const;
90
91 // to be called when updating the size of the static text:
92 // updates the label redoing ellipsization calculations
93 void UpdateLabel();
94
95 // These functions are platform-specific and must be overridden in ports
96 // which do not natively support ellipsization and they must be implemented
97 // in a way so that the m_label member of wxControl is not touched:
98
99 // returns the real label currently displayed inside the control.
100 virtual wxString DoGetLabel() const { return wxEmptyString; }
101
102 // sets the real label currently displayed inside the control,
103 // _without_ invalidating the size. The text passed is always markup-free.
104 virtual void DoSetLabel(const wxString& WXUNUSED(str)) { }
105
106 private:
107 DECLARE_NO_COPY_CLASS(wxStaticTextBase)
108 };
109
110 // see wx/generic/stattextg.h for the explanation
111 #ifndef wxNO_PORT_STATTEXT_INCLUDE
112
113 #if defined(__WXUNIVERSAL__)
114 #include "wx/univ/stattext.h"
115 #elif defined(__WXMSW__)
116 #include "wx/msw/stattext.h"
117 #elif defined(__WXMOTIF__)
118 #include "wx/motif/stattext.h"
119 #elif defined(__WXGTK20__)
120 #include "wx/gtk/stattext.h"
121 #elif defined(__WXGTK__)
122 #include "wx/gtk1/stattext.h"
123 #elif defined(__WXMAC__)
124 #include "wx/osx/stattext.h"
125 #elif defined(__WXCOCOA__)
126 #include "wx/cocoa/stattext.h"
127 #elif defined(__WXPM__)
128 #include "wx/os2/stattext.h"
129 #elif defined(__WXPALMOS__)
130 #include "wx/palmos/stattext.h"
131 #endif
132
133 #endif // !wxNO_PORT_STATTEXT_INCLUDE
134
135 #endif // wxUSE_STATTEXT
136
137 #endif // _WX_STATTEXT_H_BASE_