]> git.saurik.com Git - wxWidgets.git/blame - interface/stattext.h
remove wxTextAttr::CreateFont(); return wxNullFont from GetFont() if we have no font...
[wxWidgets.git] / interface / stattext.h
CommitLineData
23324ae1
FM
1/////////////////////////////////////////////////////////////////////////////
2// Name: stattext.h
3// Purpose: documentation for wxStaticText class
4// Author: wxWidgets team
5// RCS-ID: $Id$
6// Licence: wxWindows license
7/////////////////////////////////////////////////////////////////////////////
8
9/**
10 @class wxStaticText
11 @wxheader{stattext.h}
7c913512 12
23324ae1 13 A static text control displays one or more lines of read-only text.
7c913512 14
23324ae1
FM
15 @beginStyleTable
16 @style{wxALIGN_LEFT}:
17 Align the text to the left
18 @style{wxALIGN_RIGHT}:
19 Align the text to the right
20 @style{wxALIGN_CENTRE}:
21 Center the text (horizontally)
22 @style{wxST_NO_AUTORESIZE}:
23 By default, the control will adjust its size to exactly fit to the
24 size of the text when SetLabel is called. If this style flag is
25 given, the control will not change its size (this style is
26 especially useful with controls which also have wxALIGN_RIGHT or
27 CENTER style because otherwise they won't make sense any longer
28 after a call to SetLabel)
29 @style{wxST_ELLIPSIZE_START}:
30 If the text width exceeds the control width, replace the beginning
31 of the text with an ellipsis
32 @style{wxST_ELLIPSIZE_MIDDLE}:
33 Same as above, but replace the text in the middle of the control
34 with an ellipsis
35 @style{wxST_ELLIPSIZE_END}:
36 Same as above, but replace the end of the text with an ellipsis
37 @style{wxST_MARKUP}:
38 Support markup in the label; see SetLabel for more information
39 @endStyleTable
7c913512 40
23324ae1
FM
41 @library{wxcore}
42 @category{ctrl}
43 @appearance{statictext.png}
7c913512 44
23324ae1
FM
45 @seealso
46 wxStaticBitmap, wxStaticBox
47*/
48class wxStaticText : public wxControl
49{
50public:
51 //@{
52 /**
53 Constructor, creating and showing a text control.
54
7c913512 55 @param parent
4cc4bfaf 56 Parent window. Should not be @NULL.
7c913512 57 @param id
4cc4bfaf 58 Control identifier. A value of -1 denotes a default value.
7c913512 59 @param label
4cc4bfaf 60 Text label.
7c913512 61 @param pos
4cc4bfaf 62 Window position.
7c913512 63 @param size
4cc4bfaf 64 Window size.
7c913512 65 @param style
4cc4bfaf 66 Window style. See wxStaticText.
7c913512 67 @param name
4cc4bfaf 68 Window name.
23324ae1 69
4cc4bfaf 70 @see Create()
23324ae1
FM
71 */
72 wxStaticText();
7c913512
FM
73 wxStaticText(wxWindow* parent, wxWindowID id,
74 const wxString& label,
75 const wxPoint& pos = wxDefaultPosition,
76 const wxSize& size = wxDefaultSize,
77 long style = 0,
78 const wxString& name = "staticText");
23324ae1
FM
79 //@}
80
81 /**
82 Creation function, for two-step construction. For details see wxStaticText().
83 */
84 bool Create(wxWindow* parent, wxWindowID id,
85 const wxString& label,
86 const wxPoint& pos = wxDefaultPosition,
87 const wxSize& size = wxDefaultSize,
88 long style = 0,
89 const wxString& name = "staticText");
90
91 /**
92 Returns the contents of the control.
23324ae1
FM
93 Note that the returned string contains both the mnemonics (@c characters),
94 if any, and markup tags, if any.
23324ae1
FM
95 Use GetLabelText() if only the
96 label text is needed.
97 */
98 wxString GetLabel();
99
100 //@{
101 /**
102 The first form returns the control's label without the mnemonics characters (if
7c913512 103 any)
23324ae1 104 and without the markup (if the control has @c wxST_MARKUP style).
4cc4bfaf 105 The second (static) version returns the given @a label string without the
7c913512 106 mnemonics
23324ae1
FM
107 characters (if any) and without the markup.
108 */
109 wxString GetLabelText();
7c913512 110 static wxString GetLabelText(const wxString& label);
23324ae1
FM
111 //@}
112
113 /**
114 Sets the static text label and updates the controls size to exactly fit the
115 label unless the control has wxST_NO_AUTORESIZE flag.
23324ae1
FM
116 This function allows to set decorated static label text on platforms which
117 support it (currently only GTK+ 2). For the other platforms, the markup is
118 ignored.
23324ae1
FM
119 The supported tags are:
120
23324ae1
FM
121 b
122
23324ae1
FM
123 bold text
124
125 big
126
23324ae1
FM
127 bigger text
128
129 i
130
23324ae1
FM
131 italic text
132
133 s
134
23324ae1
FM
135 strike-through text
136
137 sub
138
23324ae1
FM
139 subscript text
140
141 sup
142
23324ae1
FM
143 superscript text
144
145 small
146
23324ae1
FM
147 smaller text
148
149 tt
150
23324ae1
FM
151 monospaced text
152
153 u
154
23324ae1
FM
155 underlined text
156
157 span
158
23324ae1
FM
159 generic formatter tag; see Pango Markup for more information.
160
161 Note that the string must be well-formed (e.g. all tags must be correctly
162 closed)
163 otherwise it can be not shown correctly or at all.
23324ae1
FM
164 Also note that you need to escape the following special characters:
165
23324ae1
FM
166 @b Special character
167
23324ae1
FM
168 @b Escape as
169
7c913512 170 @c
23324ae1 171
7c913512 172 @c amp; or as @c
23324ae1
FM
173
174 @c '
175
23324ae1
FM
176 @c apos;
177
178 @c "
179
23324ae1
FM
180 @c quot;
181
7c913512 182 @c
23324ae1 183
23324ae1
FM
184 @c lt;
185
7c913512 186 @c
23324ae1 187
23324ae1
FM
188 @c gt;
189
190 The non-escaped ampersand @c characters are interpreted as
191 mnemonics; see wxControl::SetLabel.
4cc4bfaf 192
23324ae1
FM
193 Example:
194
7c913512 195 @param label
4cc4bfaf 196 The new label to set. It may contain newline characters and the markup tags
23324ae1
FM
197 described above.
198 */
199 virtual void SetLabel(const wxString& label);
200
201 /**
202 This functions wraps the controls label so that each of its lines becomes at
4cc4bfaf 203 most @a width pixels wide if possible (the lines are broken at words
23324ae1
FM
204 boundaries so it might not be the case if words are too long). If @e width
205 is negative, no wrapping is done.
23324ae1
FM
206 This function is new since wxWidgets version 2.6.2
207 */
208 void Wrap(int width);
209};