]>
git.saurik.com Git - wxWidgets.git/blob - interface/wx/stattext.h
1 /////////////////////////////////////////////////////////////////////////////
3 // Purpose: interface of wxStaticText
4 // Author: wxWidgets team
6 // Licence: wxWindows license
7 /////////////////////////////////////////////////////////////////////////////
12 A static text control displays one or more lines of read-only text.
16 Align the text to the left
18 Align the text to the right
19 @style{wxALIGN_CENTRE}
20 Center the text (horizontally)
21 @style{wxST_NO_AUTORESIZE}
22 By default, the control will adjust its size to exactly fit to the
23 size of the text when SetLabel is called. If this style flag is
24 given, the control will not change its size (this style is
25 especially useful with controls which also have wxALIGN_RIGHT or
26 CENTER style because otherwise they won't make sense any longer
27 after a call to SetLabel)
28 @style{wxST_ELLIPSIZE_START}
29 If the text width exceeds the control width, replace the beginning
30 of the text with an ellipsis
31 @style{wxST_ELLIPSIZE_MIDDLE}
32 Same as above, but replace the text in the middle of the control
34 @style{wxST_ELLIPSIZE_END}
35 Same as above, but replace the end of the text with an ellipsis
37 Support markup in the label; see SetLabel for more information
42 <!-- @appearance{statictext.png} -->
44 @see wxStaticBitmap, wxStaticBox
46 class wxStaticText
: public wxControl
55 Constructor, creating and showing a text control.
58 Parent window. Should not be @NULL.
60 Control identifier. A value of -1 denotes a default value.
68 Window style. See wxStaticText.
74 wxStaticText(wxWindow
* parent
, wxWindowID id
,
75 const wxString
& label
,
76 const wxPoint
& pos
= wxDefaultPosition
,
77 const wxSize
& size
= wxDefaultSize
,
79 const wxString
& name
= "staticText");
82 Creation function, for two-step construction. For details see wxStaticText().
84 bool Create(wxWindow
* parent
, wxWindowID id
,
85 const wxString
& label
,
86 const wxPoint
& pos
= wxDefaultPosition
,
87 const wxSize
& size
= wxDefaultSize
,
89 const wxString
& name
= "staticText");
92 Returns the contents of the control.
93 Note that the returned string contains both the mnemonics (@c characters),
94 if any, and markup tags, if any.
95 Use GetLabelText() if only the
98 wxString
GetLabel() const;
102 The first form returns the control's label without the mnemonics characters (if
104 and without the markup (if the control has @c wxST_MARKUP style).
105 The second (static) version returns the given @a label string without the
107 characters (if any) and without the markup.
109 wxString
GetLabelText();
110 const static wxString
GetLabelText(const wxString
& label
);
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.
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
119 The supported tags are:
135 <TD>strike-through text</TD>
139 <TD>subscript text</TD>
143 <TD>superscript text</TD>
146 <TD><small></TD>
147 <TD>smaller text</TD>
151 <TD>monospaced text</TD>
155 <TD>underlined text</TD>
158 <TD><span></TD>
159 <TD>generic formatter tag; see Pango Markup for more information.</TD>
163 Note that the string must be well-formed (e.g. all tags must be correctly
165 otherwise it can be not shown correctly or at all.
166 Also note that you need to escape the following special characters:
169 <TD>@b Special character</TD>
170 <TD>@b Escape as</TD>
174 <TD>@c &amp; or as &&</TD>
178 <TD>@c &apos;</TD>
182 <TD>@c &quot;</TD>
194 The non-escaped ampersand @c & characters are interpreted as
195 mnemonics; see wxControl::SetLabel.
200 The new label to set. It may contain newline characters and the markup tags
203 virtual void SetLabel(const wxString
& label
);
206 This functions wraps the controls label so that each of its lines becomes at
207 most @a width pixels wide if possible (the lines are broken at words
208 boundaries so it might not be the case if words are too long). If @e width
209 is negative, no wrapping is done. Note that this width is not
210 necessarily the total width of the control, since a few pixels for the
211 border (depending on the controls border style) may be added.
215 void Wrap(int width
);