]>
Commit | Line | Data |
---|---|---|
2ecf902b WS |
1 | ///////////////////////////////////////////////////////////////////////////// |
2 | // Name: stattext.h | |
3 | // Purpose: wxStaticText base header | |
99d80019 | 4 | // Author: Julian Smart |
2ecf902b WS |
5 | // Modified by: |
6 | // Created: | |
99d80019 | 7 | // Copyright: (c) Julian Smart |
2ecf902b WS |
8 | // RCS-ID: $Id$ |
9 | // Licence: wxWindows licence | |
10 | ///////////////////////////////////////////////////////////////////////////// | |
11 | ||
34138703 JS |
12 | #ifndef _WX_STATTEXT_H_BASE_ |
13 | #define _WX_STATTEXT_H_BASE_ | |
c801d85f | 14 | |
2ecf902b WS |
15 | #include "wx/defs.h" |
16 | ||
1e6feb95 VZ |
17 | #if wxUSE_STATTEXT |
18 | ||
19 | #include "wx/control.h" | |
20 | ||
39bc0347 VZ |
21 | /* |
22 | * wxStaticText flags | |
23 | */ | |
24 | #define wxST_NO_AUTORESIZE 0x0001 | |
25 | #define wxST_MARKUP 0x0002 | |
5c87527c FM |
26 | #define wxST_ELLIPSIZE_START 0x0004 |
27 | #define wxST_ELLIPSIZE_MIDDLE 0x0008 | |
28 | #define wxST_ELLIPSIZE_END 0x0010 | |
39bc0347 | 29 | |
53a2db12 | 30 | extern WXDLLIMPEXP_DATA_CORE(const char) wxStaticTextNameStr[]; |
1e6feb95 | 31 | |
53a2db12 | 32 | class WXDLLIMPEXP_CORE wxStaticTextBase : public wxControl |
1e6feb95 VZ |
33 | { |
34 | public: | |
fc7a2a60 VZ |
35 | wxStaticTextBase() { } |
36 | ||
5d1b4919 VZ |
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) | |
39bc0347 | 39 | // This function will modify the value returned by GetLabel()! |
5d1b4919 VZ |
40 | void Wrap(int width); |
41 | ||
bd507486 RD |
42 | // overriden base virtuals |
43 | virtual bool AcceptsFocus() const { return false; } | |
7c7a653b | 44 | virtual bool HasTransparentBackground() { return true; } |
fc7a2a60 | 45 | |
39bc0347 VZ |
46 | bool IsEllipsized() const |
47 | { | |
48 | return HasFlag(wxST_ELLIPSIZE_START) || | |
49 | HasFlag(wxST_ELLIPSIZE_MIDDLE) || | |
50 | HasFlag(wxST_ELLIPSIZE_END); | |
51 | } | |
52 | ||
53 | // get the string without mnemonic characters ('&') and without markup | |
32ee98eb | 54 | // (if the wxST_MARKUP style is set) |
39bc0347 VZ |
55 | virtual wxString GetLabelText() const; |
56 | ||
32ee98eb FM |
57 | // set label text (mnemonics and markup, if the wxST_MARKUP style is set, |
58 | // will be escaped) | |
59 | virtual void SetLabelText(const wxString& text); | |
60 | ||
61 | ||
62 | // static utilities for markup handling | |
63 | // (symmetric to those in wxControl about mnemonics) | |
64 | // ------------------------------------------------- | |
39bc0347 | 65 | |
19cf1ef3 | 66 | // get the string without mnemonic characters ('&') and without markup |
32ee98eb FM |
67 | // (note that markup is always removed; this function is static and cannot |
68 | // check for wxST_MARKUP style presence/absence!) | |
19cf1ef3 FM |
69 | static wxString GetLabelText(const wxString& label); |
70 | ||
32ee98eb | 71 | // removes the markup recognized by wxStaticText and returns the cleaned string |
39bc0347 VZ |
72 | static wxString RemoveMarkup(const wxString& str); |
73 | ||
4520d583 | 74 | // escapes all special symbols (<>"'&) present in the given string |
39bc0347 VZ |
75 | // using the corresponding entities (< > " ' &) |
76 | static wxString EscapeMarkup(const wxString& str); | |
77 | ||
39bc0347 VZ |
78 | protected: // functions required for wxST_ELLIPSIZE_* support |
79 | ||
dc797d8e JS |
80 | // choose the default border for this window |
81 | virtual wxBorder GetDefaultBorder() const { return wxBORDER_NONE; } | |
82 | ||
ce00f59b | 83 | // calls only RemoveMarkup() on the original label |
32ee98eb FM |
84 | // if the wxST_MARKUP style is set |
85 | // (but unlike GetLabelText won't remove mnemonics) | |
86 | virtual wxString GetLabelWithoutMarkup() const; | |
87 | ||
ce00f59b | 88 | // just calls RemoveMarkup() & Ellipsize() on the original label |
32ee98eb FM |
89 | // if the wxST_MARKUP & wxST_ELLIPSIZE_* styles are set |
90 | // (but unlike GetLabelText won't remove mnemonics) | |
39bc0347 VZ |
91 | virtual wxString GetEllipsizedLabelWithoutMarkup() const; |
92 | ||
93 | // replaces parts of the string with ellipsis if needed | |
94 | wxString Ellipsize(const wxString& label) const; | |
95 | ||
96 | // to be called when updating the size of the static text: | |
97 | // updates the label redoing ellipsization calculations | |
98 | void UpdateLabel(); | |
99 | ||
100 | // These functions are platform-specific and must be overridden in ports | |
101 | // which do not natively support ellipsization and they must be implemented | |
7517dcb5 | 102 | // in a way so that the m_labelOrig member of wxControl is not touched: |
39bc0347 VZ |
103 | |
104 | // returns the real label currently displayed inside the control. | |
105 | virtual wxString DoGetLabel() const { return wxEmptyString; } | |
106 | ||
107 | // sets the real label currently displayed inside the control, | |
7517dcb5 FM |
108 | // _without_ invalidating the size. The text passed is always markup-free |
109 | // but may contain the mnemonic characters. | |
39bc0347 VZ |
110 | virtual void DoSetLabel(const wxString& WXUNUSED(str)) { } |
111 | ||
fc7a2a60 | 112 | private: |
c0c133e1 | 113 | wxDECLARE_NO_COPY_CLASS(wxStaticTextBase); |
1e6feb95 VZ |
114 | }; |
115 | ||
bce49490 VZ |
116 | // see wx/generic/stattextg.h for the explanation |
117 | #ifndef wxNO_PORT_STATTEXT_INCLUDE | |
118 | ||
1e6feb95 VZ |
119 | #if defined(__WXUNIVERSAL__) |
120 | #include "wx/univ/stattext.h" | |
121 | #elif defined(__WXMSW__) | |
122 | #include "wx/msw/stattext.h" | |
2049ba38 | 123 | #elif defined(__WXMOTIF__) |
1e6feb95 | 124 | #include "wx/motif/stattext.h" |
1be7a35c | 125 | #elif defined(__WXGTK20__) |
1e6feb95 | 126 | #include "wx/gtk/stattext.h" |
1be7a35c MR |
127 | #elif defined(__WXGTK__) |
128 | #include "wx/gtk1/stattext.h" | |
34138703 | 129 | #elif defined(__WXMAC__) |
ef0e9220 | 130 | #include "wx/osx/stattext.h" |
e64df9bc DE |
131 | #elif defined(__WXCOCOA__) |
132 | #include "wx/cocoa/stattext.h" | |
1777b9bb | 133 | #elif defined(__WXPM__) |
1e6feb95 | 134 | #include "wx/os2/stattext.h" |
a152561c WS |
135 | #elif defined(__WXPALMOS__) |
136 | #include "wx/palmos/stattext.h" | |
c801d85f KB |
137 | #endif |
138 | ||
bce49490 VZ |
139 | #endif // !wxNO_PORT_STATTEXT_INCLUDE |
140 | ||
1e6feb95 VZ |
141 | #endif // wxUSE_STATTEXT |
142 | ||
bce49490 | 143 | #endif // _WX_STATTEXT_H_BASE_ |