]> git.saurik.com Git - wxWidgets.git/blob - include/wx/private/stattext.h
added support for ellipsization and markup in wxStaticText (modified patch 1629946)
[wxWidgets.git] / include / wx / private / stattext.h
1 /////////////////////////////////////////////////////////////////////////////
2 // Name: include/wx/private/stattext.h
3 // Purpose: Internal declarations for dlgcmn.cpp and stattextcmn.cpp
4 // Author: Francesco Montorsi
5 // Created: 2007-01-07 (extracted from dlgcmn.cpp)
6 // RCS-ID: $Id$
7 // Copyright: (c) 1999 Vadim Zeitlin
8 // (c) 2007 wxWidgets team
9 // Licence: wxWindows licence
10 /////////////////////////////////////////////////////////////////////////////
11
12 #ifndef _WX_PRIVATE_STATTEXT_H_
13 #define _WX_PRIVATE_STATTEXT_H_
14
15 #if wxUSE_STATTEXT
16
17 // ----------------------------------------------------------------------------
18 // wxTextWrapper
19 // ----------------------------------------------------------------------------
20
21 // this class is used to wrap the text on word boundary: wrapping is done by
22 // calling OnStartLine() and OnOutputLine() functions
23 class wxTextWrapper
24 {
25 public:
26 wxTextWrapper() { m_eol = false; }
27
28 // win is used for getting the font, text is the text to wrap, width is the
29 // max line width or -1 to disable wrapping
30 void Wrap(wxWindow *win, const wxString& text, int widthMax);
31
32 // we don't need it, but just to avoid compiler warnings
33 virtual ~wxTextWrapper() { }
34
35 protected:
36 // line may be empty
37 virtual void OnOutputLine(const wxString& line) = 0;
38
39 // called at the start of every new line (except the very first one)
40 virtual void OnNewLine() { }
41
42 private:
43 // call OnOutputLine() and set m_eol to true
44 void DoOutputLine(const wxString& line)
45 {
46 OnOutputLine(line);
47
48 m_eol = true;
49 }
50
51 // this function is a destructive inspector: when it returns true it also
52 // resets the flag to false so calling it again woulnd't return true any
53 // more
54 bool IsStartOfNewLine()
55 {
56 if ( !m_eol )
57 return false;
58
59 m_eol = false;
60
61 return true;
62 }
63
64
65 bool m_eol;
66 };
67
68 enum
69 {
70 wxMARKUP_ENTITY_AMP,
71 wxMARKUP_ENTITY_LT,
72 wxMARKUP_ENTITY_GT,
73 wxMARKUP_ENTITY_APOS,
74 wxMARKUP_ENTITY_QUOT,
75 wxMARKUP_ENTITY_MAX
76 };
77
78 enum
79 {
80 wxMARKUP_ELEMENT_NAME,
81 wxMARKUP_ELEMENT_VALUE,
82 wxMARKUP_ELEMENT_MAX
83 };
84
85 // these are the only entities treated in a special way by wxStaticText::SetLabel()
86 // when the wxST_MARKUP style is used; use as:
87 //
88 // wxMarkupEntities[wxMARKUP_ELEMENT_NAME][wxMARKUP_ENTITY_GT] == ">"
89 // wxMarkupEntities[wxMARKUP_ELEMENT_VALUE][wxMARKUP_ENTITY_GT] == ">"
90 //
91 extern const wxChar *wxMarkupEntities[wxMARKUP_ELEMENT_MAX][wxMARKUP_ENTITY_MAX];
92
93 #endif // wxUSE_STATTEXT
94
95 #endif // _WX_PRIVATE_STATTEXT_H_