]>
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 | |
26 | ||
27 | #define wxST_ELLIPSIZE_START 0x0004 | |
28 | #define wxST_ELLIPSIZE_MIDDLE 0x0008 | |
29 | #define wxST_ELLIPSIZE_END 0x0010 | |
30 | ||
31 | ||
53a2db12 | 32 | extern WXDLLIMPEXP_DATA_CORE(const char) wxStaticTextNameStr[]; |
1e6feb95 | 33 | |
53a2db12 | 34 | class WXDLLIMPEXP_CORE wxStaticTextBase : public wxControl |
1e6feb95 VZ |
35 | { |
36 | public: | |
fc7a2a60 VZ |
37 | wxStaticTextBase() { } |
38 | ||
5d1b4919 VZ |
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) | |
39bc0347 | 41 | // This function will modify the value returned by GetLabel()! |
5d1b4919 VZ |
42 | void Wrap(int width); |
43 | ||
bd507486 RD |
44 | // overriden base virtuals |
45 | virtual bool AcceptsFocus() const { return false; } | |
7c7a653b | 46 | virtual bool HasTransparentBackground() { return true; } |
fc7a2a60 | 47 | |
39bc0347 VZ |
48 | bool IsEllipsized() const |
49 | { | |
50 | return HasFlag(wxST_ELLIPSIZE_START) || | |
51 | HasFlag(wxST_ELLIPSIZE_MIDDLE) || | |
52 | HasFlag(wxST_ELLIPSIZE_END); | |
53 | } | |
54 | ||
55 | // get the string without mnemonic characters ('&') and without markup | |
56 | // (if wxST_MARKUP is being used) | |
57 | virtual wxString GetLabelText() const; | |
58 | ||
59 | // public utilities (symmetric to those in wxControl about mnemonics): | |
60 | ||
19cf1ef3 FM |
61 | // get the string without mnemonic characters ('&') and without markup |
62 | static wxString GetLabelText(const wxString& label); | |
63 | ||
39bc0347 VZ |
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); | |
67 | ||
68 | // escapes the alls special symbols (<>"'&) present inside the given string | |
69 | // using the corresponding entities (< > " ' &) | |
70 | static wxString EscapeMarkup(const wxString& str); | |
71 | ||
72 | ||
73 | protected: // functions required for wxST_ELLIPSIZE_* support | |
74 | ||
dc797d8e JS |
75 | // choose the default border for this window |
76 | virtual wxBorder GetDefaultBorder() const { return wxBORDER_NONE; } | |
77 | ||
39bc0347 VZ |
78 | // just calls RemoveMarkup & Ellipsize on the original label. |
79 | virtual wxString GetEllipsizedLabelWithoutMarkup() const; | |
80 | ||
81 | // replaces parts of the string with ellipsis if needed | |
82 | wxString Ellipsize(const wxString& label) const; | |
83 | ||
84 | // to be called when updating the size of the static text: | |
85 | // updates the label redoing ellipsization calculations | |
86 | void UpdateLabel(); | |
87 | ||
88 | // These functions are platform-specific and must be overridden in ports | |
89 | // which do not natively support ellipsization and they must be implemented | |
90 | // in a way so that the m_label member of wxControl is not touched: | |
91 | ||
92 | // returns the real label currently displayed inside the control. | |
93 | virtual wxString DoGetLabel() const { return wxEmptyString; } | |
94 | ||
95 | // sets the real label currently displayed inside the control, | |
96 | // _without_ invalidating the size. The text passed is always markup-free. | |
97 | virtual void DoSetLabel(const wxString& WXUNUSED(str)) { } | |
98 | ||
fc7a2a60 VZ |
99 | private: |
100 | DECLARE_NO_COPY_CLASS(wxStaticTextBase) | |
1e6feb95 VZ |
101 | }; |
102 | ||
103 | #if defined(__WXUNIVERSAL__) | |
104 | #include "wx/univ/stattext.h" | |
105 | #elif defined(__WXMSW__) | |
106 | #include "wx/msw/stattext.h" | |
2049ba38 | 107 | #elif defined(__WXMOTIF__) |
1e6feb95 | 108 | #include "wx/motif/stattext.h" |
1be7a35c | 109 | #elif defined(__WXGTK20__) |
1e6feb95 | 110 | #include "wx/gtk/stattext.h" |
1be7a35c MR |
111 | #elif defined(__WXGTK__) |
112 | #include "wx/gtk1/stattext.h" | |
34138703 | 113 | #elif defined(__WXMAC__) |
ef0e9220 | 114 | #include "wx/osx/stattext.h" |
e64df9bc DE |
115 | #elif defined(__WXCOCOA__) |
116 | #include "wx/cocoa/stattext.h" | |
1777b9bb | 117 | #elif defined(__WXPM__) |
1e6feb95 | 118 | #include "wx/os2/stattext.h" |
a152561c WS |
119 | #elif defined(__WXPALMOS__) |
120 | #include "wx/palmos/stattext.h" | |
c801d85f KB |
121 | #endif |
122 | ||
1e6feb95 VZ |
123 | #endif // wxUSE_STATTEXT |
124 | ||
c801d85f | 125 | #endif |
34138703 | 126 | // _WX_STATTEXT_H_BASE_ |