1 /////////////////////////////////////////////////////////////////////////////
3 // Purpose: wxStaticText base header
4 // Author: Julian Smart
7 // Copyright: (c) Julian Smart
9 // Licence: wxWindows licence
10 /////////////////////////////////////////////////////////////////////////////
12 #ifndef _WX_STATTEXT_H_BASE_
13 #define _WX_STATTEXT_H_BASE_
19 #include "wx/control.h"
24 #define wxST_NO_AUTORESIZE 0x0001
25 #define wxST_MARKUP 0x0002
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
31 wxST_ELLIPSIZE_START
= 0x0004,
32 wxST_ELLIPSIZE_MIDDLE
= 0x0008,
33 wxST_ELLIPSIZE_END
= 0x0010
36 extern WXDLLIMPEXP_DATA_CORE(const char) wxStaticTextNameStr
[];
38 class WXDLLIMPEXP_CORE wxStaticTextBase
: public wxControl
41 wxStaticTextBase() { }
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()!
48 // overriden base virtuals
49 virtual bool AcceptsFocus() const { return false; }
50 virtual bool HasTransparentBackground() { return true; }
52 bool IsEllipsized() const
54 return HasFlag(wxST_ELLIPSIZE_START
) ||
55 HasFlag(wxST_ELLIPSIZE_MIDDLE
) ||
56 HasFlag(wxST_ELLIPSIZE_END
);
59 // get the string without mnemonic characters ('&') and without markup
60 // (if wxST_MARKUP is being used)
61 virtual wxString
GetLabelText() const;
63 // public utilities (symmetric to those in wxControl about mnemonics):
65 // get the string without mnemonic characters ('&') and without markup
66 static wxString
GetLabelText(const wxString
& label
);
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
);
72 // escapes all special symbols (<>"'&) present in the given string
73 // using the corresponding entities (< > " ' &)
74 static wxString
EscapeMarkup(const wxString
& str
);
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
);
80 protected: // functions required for wxST_ELLIPSIZE_* support
82 // choose the default border for this window
83 virtual wxBorder
GetDefaultBorder() const { return wxBORDER_NONE
; }
85 // just calls RemoveMarkup & Ellipsize on the original label.
86 virtual wxString
GetEllipsizedLabelWithoutMarkup() const;
88 // replaces parts of the string with ellipsis if needed
89 wxString
Ellipsize(const wxString
& label
) const;
91 // to be called when updating the size of the static text:
92 // updates the label redoing ellipsization calculations
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:
99 // returns the real label currently displayed inside the control.
100 virtual wxString
DoGetLabel() const { return wxEmptyString
; }
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
)) { }
107 DECLARE_NO_COPY_CLASS(wxStaticTextBase
)
110 // see wx/generic/stattextg.h for the explanation
111 #ifndef wxNO_PORT_STATTEXT_INCLUDE
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"
133 #endif // !wxNO_PORT_STATTEXT_INCLUDE
135 #endif // wxUSE_STATTEXT
137 #endif // _WX_STATTEXT_H_BASE_