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 #define wxST_ELLIPSIZE_START 0x0004
28 #define wxST_ELLIPSIZE_MIDDLE 0x0008
29 #define wxST_ELLIPSIZE_END 0x0010
32 extern WXDLLEXPORT_DATA(const wxChar
) wxStaticTextNameStr
[];
34 class WXDLLEXPORT wxStaticTextBase
: public wxControl
37 wxStaticTextBase() { }
39 // wrap the text of the control so that no line is longer than the given
40 // width (if possible: this function won't break words)
41 // This function will modify the value returned by GetLabel()!
44 // overriden base virtuals
45 virtual bool AcceptsFocus() const { return false; }
46 virtual bool HasTransparentBackground() { return true; }
48 bool IsEllipsized() const
50 return HasFlag(wxST_ELLIPSIZE_START
) ||
51 HasFlag(wxST_ELLIPSIZE_MIDDLE
) ||
52 HasFlag(wxST_ELLIPSIZE_END
);
55 // get the string without mnemonic characters ('&') and without markup
56 // (if wxST_MARKUP is being used)
57 virtual wxString
GetLabelText() const;
59 // public utilities (symmetric to those in wxControl about mnemonics):
61 // get the string without mnemonic characters ('&') and without markup
62 static wxString
GetLabelText(const wxString
& label
);
64 // removes the markup accepted by wxStaticText when wxST_MARKUP is used,
65 // and then returns the cleaned string
66 static wxString
RemoveMarkup(const wxString
& str
);
68 // escapes the alls special symbols (<>"'&) present inside the given string
69 // using the corresponding entities (< > " ' &)
70 static wxString
EscapeMarkup(const wxString
& str
);
73 protected: // functions required for wxST_ELLIPSIZE_* support
75 // just calls RemoveMarkup & Ellipsize on the original label.
76 virtual wxString
GetEllipsizedLabelWithoutMarkup() const;
78 // replaces parts of the string with ellipsis if needed
79 wxString
Ellipsize(const wxString
& label
) const;
81 // to be called when updating the size of the static text:
82 // updates the label redoing ellipsization calculations
85 // These functions are platform-specific and must be overridden in ports
86 // which do not natively support ellipsization and they must be implemented
87 // in a way so that the m_label member of wxControl is not touched:
89 // returns the real label currently displayed inside the control.
90 virtual wxString
DoGetLabel() const { return wxEmptyString
; }
92 // sets the real label currently displayed inside the control,
93 // _without_ invalidating the size. The text passed is always markup-free.
94 virtual void DoSetLabel(const wxString
& WXUNUSED(str
)) { }
97 DECLARE_NO_COPY_CLASS(wxStaticTextBase
)
100 #if defined(__WXUNIVERSAL__)
101 #include "wx/univ/stattext.h"
102 #elif defined(__WXMSW__)
103 #include "wx/msw/stattext.h"
104 #elif defined(__WXMOTIF__)
105 #include "wx/motif/stattext.h"
106 #elif defined(__WXGTK20__)
107 #include "wx/gtk/stattext.h"
108 #elif defined(__WXGTK__)
109 #include "wx/gtk1/stattext.h"
110 #elif defined(__WXMAC__)
111 #include "wx/mac/stattext.h"
112 #elif defined(__WXCOCOA__)
113 #include "wx/cocoa/stattext.h"
114 #elif defined(__WXPM__)
115 #include "wx/os2/stattext.h"
116 #elif defined(__WXPALMOS__)
117 #include "wx/palmos/stattext.h"
120 #endif // wxUSE_STATTEXT
123 // _WX_STATTEXT_H_BASE_