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
26 #define wxST_ELLIPSIZE_START 0x0004
27 #define wxST_ELLIPSIZE_MIDDLE 0x0008
28 #define wxST_ELLIPSIZE_END 0x0010
30 extern WXDLLIMPEXP_DATA_CORE(const char) wxStaticTextNameStr
[];
32 class WXDLLIMPEXP_CORE wxStaticTextBase
: public wxControl
35 wxStaticTextBase() { }
37 // wrap the text of the control so that no line is longer than the given
38 // width (if possible: this function won't break words)
39 // This function will modify the value returned by GetLabel()!
42 // overriden base virtuals
43 virtual bool AcceptsFocus() const { return false; }
44 virtual bool HasTransparentBackground() { return true; }
46 bool IsEllipsized() const
48 return HasFlag(wxST_ELLIPSIZE_START
) ||
49 HasFlag(wxST_ELLIPSIZE_MIDDLE
) ||
50 HasFlag(wxST_ELLIPSIZE_END
);
53 // get the string without mnemonic characters ('&') and without markup
54 // (if wxST_MARKUP is being used)
55 virtual wxString
GetLabelText() const;
57 // public utilities (symmetric to those in wxControl about mnemonics):
59 // get the string without mnemonic characters ('&') and without markup
60 static wxString
GetLabelText(const wxString
& label
);
62 // removes the markup accepted by wxStaticText when wxST_MARKUP is used,
63 // and then returns the cleaned string
64 static wxString
RemoveMarkup(const wxString
& str
);
66 // escapes all special symbols (<>"'&) present in the given string
67 // using the corresponding entities (< > " ' &)
68 static wxString
EscapeMarkup(const wxString
& str
);
70 protected: // functions required for wxST_ELLIPSIZE_* support
72 // choose the default border for this window
73 virtual wxBorder
GetDefaultBorder() const { return wxBORDER_NONE
; }
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 wxDECLARE_NO_COPY_CLASS(wxStaticTextBase
);
100 // see wx/generic/stattextg.h for the explanation
101 #ifndef wxNO_PORT_STATTEXT_INCLUDE
103 #if defined(__WXUNIVERSAL__)
104 #include "wx/univ/stattext.h"
105 #elif defined(__WXMSW__)
106 #include "wx/msw/stattext.h"
107 #elif defined(__WXMOTIF__)
108 #include "wx/motif/stattext.h"
109 #elif defined(__WXGTK20__)
110 #include "wx/gtk/stattext.h"
111 #elif defined(__WXGTK__)
112 #include "wx/gtk1/stattext.h"
113 #elif defined(__WXMAC__)
114 #include "wx/osx/stattext.h"
115 #elif defined(__WXCOCOA__)
116 #include "wx/cocoa/stattext.h"
117 #elif defined(__WXPM__)
118 #include "wx/os2/stattext.h"
119 #elif defined(__WXPALMOS__)
120 #include "wx/palmos/stattext.h"
123 #endif // !wxNO_PORT_STATTEXT_INCLUDE
125 #endif // wxUSE_STATTEXT
127 #endif // _WX_STATTEXT_H_BASE_