]> git.saurik.com Git - wxWidgets.git/blame_incremental - interface/wx/stattext.h
Document wxMessageQueueError.
[wxWidgets.git] / interface / wx / stattext.h
... / ...
CommitLineData
1/////////////////////////////////////////////////////////////////////////////
2// Name: stattext.h
3// Purpose: interface of wxStaticText
4// Author: wxWidgets team
5// RCS-ID: $Id$
6// Licence: wxWindows licence
7/////////////////////////////////////////////////////////////////////////////
8
9/**
10 @class wxStaticText
11
12 A static text control displays one or more lines of read-only text.
13 wxStaticText supports the three classic text alignments, label ellipsization
14 and formatting markup.
15
16 @beginStyleTable
17 @style{wxALIGN_LEFT}
18 Align the text to the left.
19 @style{wxALIGN_RIGHT}
20 Align the text to the right.
21 @style{wxALIGN_CENTRE}
22 Center the text (horizontally).
23 @style{wxST_NO_AUTORESIZE}
24 By default, the control will adjust its size to exactly fit to the
25 size of the text when SetLabel() is called. If this style flag is
26 given, the control will not change its size (this style is
27 especially useful with controls which also have the @c wxALIGN_RIGHT or
28 the @c wxALIGN_CENTRE style because otherwise they won't make sense any
29 longer after a call to SetLabel()).
30 @style{wxST_ELLIPSIZE_START}
31 If the labeltext width exceeds the control width, replace the beginning
32 of the label with an ellipsis; uses wxControl::Ellipsize.
33 @style{wxST_ELLIPSIZE_MIDDLE}
34 If the label text width exceeds the control width, replace the middle
35 of the label with an ellipsis; uses wxControl::Ellipsize.
36 @style{wxST_ELLIPSIZE_END}
37 If the label text width exceeds the control width, replace the end
38 of the label with an ellipsis; uses wxControl::Ellipsize.
39 @style{wxST_MARKUP}
40 Support markup in the label; see SetLabel() for more information.
41 @endStyleTable
42
43 @library{wxcore}
44 @category{ctrl}
45 @appearance{statictext.png}
46
47 @see wxStaticBitmap, wxStaticBox
48*/
49class wxStaticText : public wxControl
50{
51public:
52 /**
53 Default constructor.
54 */
55 wxStaticText();
56
57 /**
58 Constructor, creating and showing a text control.
59
60 @param parent
61 Parent window. Should not be @NULL.
62 @param id
63 Control identifier. A value of -1 denotes a default value.
64 @param label
65 Text label.
66 @param pos
67 Window position.
68 @param size
69 Window size.
70 @param style
71 Window style. See wxStaticText.
72 @param name
73 Window name.
74
75 @see Create()
76 */
77 wxStaticText(wxWindow* parent, wxWindowID id,
78 const wxString& label,
79 const wxPoint& pos = wxDefaultPosition,
80 const wxSize& size = wxDefaultSize,
81 long style = 0,
82 const wxString& name = wxStaticTextNameStr);
83
84 /**
85 Creation function, for two-step construction. For details see wxStaticText().
86 */
87 bool Create(wxWindow* parent, wxWindowID id, const wxString& label,
88 const wxPoint& pos = wxDefaultPosition,
89 const wxSize& size = wxDefaultSize, long style = 0,
90 const wxString& name = wxStaticTextNameStr);
91
92 /**
93 Returns the contents of the control.
94
95 Note that the returned string may contain both mnemonics (@& characters),
96 and markup tags, if they were passed to the SetLabel() function.
97
98 Use GetLabelText() if only the label text, without mnemonics and without
99 markup if the @c wxST_MARKUP style is set, is needed.
100
101 Also note that the returned string is always the string which was passed to
102 SetLabel() but may be different from the string passed to SetLabelText()
103 (since this last one escapes mnemonic characters and eventually markup).
104 */
105 wxString GetLabel() const;
106
107 /**
108 This method returns the control's label without the mnemonics characters
109 (if any) and without the markup (if the control has the @c wxST_MARKUP style).
110
111 Note that because of the stripping of the mnemonics and markup the returned
112 string may differ from the string which was passed to SetLabel() but should
113 always be the same which was passed to SetLabelText().
114 */
115 wxString GetLabelText() const;
116
117 /**
118 Returns @true if the window styles for this control contains one of the
119 @c wxST_ELLIPSIZE_START, @c wxST_ELLIPSIZE_MIDDLE or @c wxST_ELLIPSIZE_END styles.
120 */
121 bool IsEllipsized() const;
122
123 // NB: when writing docs for the following function remember that Doxygen
124 // will always expand HTML entities (e.g. ") and thus we need to
125 // write e.g. "<" to have in the output the "<" string.
126
127 /**
128 Sets the static text label and updates the controls size to exactly fit the
129 label unless the control has @c wxST_NO_AUTORESIZE flag.
130
131 This function allows to set decorated static label text, when the @c wxST_MARKUP
132 style is used, on those platforms which support it (currently only GTK+ 2).
133 For the other platforms or when @c wxST_MARKUP is not used, the markup is ignored.
134
135 The supported tags are:
136 <TABLE>
137 <TR>
138 <TD><b>Tag</b></TD>
139 <TD><b>Description</b></TD>
140 </TR>
141 <TR>
142 <TD>&lt;b&gt;</TD>
143 <TD>bold text</TD>
144 </TR>
145 <TR>
146 <TD>&lt;big&gt;</TD>
147 <TD>bigger text</TD>
148 </TR>
149 <TR>
150 <TD>&lt;i&gt;</TD>
151 <TD>italic text</TD>
152 </TR>
153 <TR>
154 <TD>&lt;s&gt;</TD>
155 <TD>strike-through text</TD>
156 </TR>
157 <TR>
158 <TD>&lt;sub&gt;</TD>
159 <TD>subscript text</TD>
160 </TR>
161 <TR>
162 <TD>&lt;sup&gt;</TD>
163 <TD>superscript text</TD>
164 </TR>
165 <TR>
166 <TD>&lt;small&gt;</TD>
167 <TD>smaller text</TD>
168 </TR>
169 <TR>
170 <TD>&lt;tt&gt;</TD>
171 <TD>monospaced text</TD>
172 </TR>
173 <TR>
174 <TD>&lt;u&gt;</TD>
175 <TD>underlined text</TD>
176 </TR>
177 <TR>
178 <TD>&lt;span&gt;</TD>
179 <TD>generic formatter tag; see Pango Markup
180 (http://library.gnome.org/devel/pango/unstable/PangoMarkupFormat.html)
181 for more information.</TD>
182 </TR>
183 </TABLE>
184
185 Note that the string must be well-formed (e.g. all tags must be correctly
186 closed) otherwise it can be not shown correctly or at all.
187 Also note that you need to escape the following special characters:
188
189 <TABLE>
190 <TR>
191 <TD><b>Special character</b></TD>
192 <TD><b>Escape as</b></TD>
193 </TR>
194 <TR>
195 <TD>@c &amp;</TD>
196 <TD>@c &amp;amp; or as @c &amp;&amp;</TD>
197 </TR>
198 <TR>
199 <TD>@c &apos;</TD>
200 <TD>@c &amp;apos;</TD>
201 </TR>
202 <TR>
203 <TD>@c &quot;</TD>
204 <TD>@c &amp;quot;</TD>
205 </TR>
206 <TR>
207 <TD>@c &lt;</TD>
208 <TD>@c &amp;lt;</TD>
209 </TR>
210 <TR>
211 <TD>@c &gt;</TD>
212 <TD>@c &amp;gt;</TD>
213 </TR>
214 </TABLE>
215
216 The non-escaped ampersand @c &amp; characters are interpreted as
217 mnemonics; see wxControl::SetLabel.
218
219 Example:
220
221 @param label
222 The new label to set.
223 It may contain newline characters and the markup tags described above.
224 */
225 virtual void SetLabel(const wxString& label);
226
227 /**
228 Sets the control's label to exactly the given string.
229
230 Unlike SetLabel(), this function shows exactly the @a text passed to it
231 in the control, without interpreting ampersands in it in any way and,
232 if @c wxST_MARKUP is used, without interpreting markup tags.
233 Notice that it means that the control can't have any mnemonic nor markup defined
234 for it using this function.
235
236 @see EscapeMarkup()
237 */
238 virtual void SetLabelText(const wxString& text);
239
240 /**
241 This functions wraps the controls label so that each of its lines becomes at
242 most @a width pixels wide if possible (the lines are broken at words
243 boundaries so it might not be the case if words are too long).
244
245 If @a width is negative, no wrapping is done. Note that this width is not
246 necessarily the total width of the control, since a few pixels for the
247 border (depending on the controls border style) may be added.
248
249 @since 2.6.2
250 */
251 void Wrap(int width);
252
253
254public: // static functions
255
256 /**
257 Returns the given @a label string without the mnemonics characters (if any)
258 and without the markup.
259
260 Note that since this function is static it will always remove markup
261 (since it cannot check @c wxST_MARKUP presence/absence!).
262 */
263 static wxString GetLabelText(const wxString& label);
264
265 /**
266 Escapes all the symbols of @a str that have a special meaning (<tt><>&quot;'&</tt>) for
267 wxStaticText objects with the @c wxST_MARKUP style.
268
269 Those symbols are replaced the corresponding entities
270 (&amp;lt; &amp;gt; &amp;quot; &amp;apos; &amp;amp;).
271 */
272 static wxString EscapeMarkup(const wxString& str);
273
274 /**
275 Removes the markup accepted by wxStaticText when the @c wxST_MARKUP style is used,
276 and then returns the cleaned string.
277
278 See SetLabel() for more info about the markup.
279 */
280 static wxString RemoveMarkup(const wxString& str);
281};
282