#include <wx/stattext.h>
A static text control displays one or more lines of read-only text.
wxStaticText supports the three classic text alignments, label ellipsization and formatting markup.
This class supports the following styles:
![]() | ![]() | ![]() |
wxMSW appearance | wxGTK appearance | wxMac appearance |
Public Member Functions | |
wxStaticText () | |
Default constructor. | |
wxStaticText (wxWindow *parent, wxWindowID id, const wxString &label, const wxPoint &pos=wxDefaultPosition, const wxSize &size=wxDefaultSize, long style=0, const wxString &name=wxStaticTextNameStr) | |
Constructor, creating and showing a text control. | |
bool | Create (wxWindow *parent, wxWindowID id, const wxString &label, const wxPoint &pos=wxDefaultPosition, const wxSize &size=wxDefaultSize, long style=0, const wxString &name=wxStaticTextNameStr) |
Creation function, for two-step construction. | |
wxString | GetLabel () const |
Returns the contents of the control. | |
wxString | GetLabelText () const |
This method returns the control's label without the mnemonics characters (if any) and without the markup (if the control has wxST_MARKUP style). | |
bool | IsEllipsized () const |
Returns true if the window styles for this control contains one of the wxST_ELLIPSIZE_START , wxST_ELLIPSIZE_MIDDLE or wxST_ELLIPSIZE_END styles. | |
virtual void | SetLabel (const wxString &label) |
Sets the static text label and updates the controls size to exactly fit the label unless the control has wxST_NO_AUTORESIZE flag. | |
void | Wrap (int width) |
This functions wraps the controls label so that each of its lines becomes at most width pixels wide if possible (the lines are broken at words boundaries so it might not be the case if words are too long). | |
Static Public Member Functions | |
static wxString | EscapeMarkup (const wxString &str) |
Escapes all the symbols of str that have a special meaning (<>"'& ) for wxStaticText objects with the wxST_MARKUP style. | |
static wxString | GetLabelText (const wxString &label) |
This overload returns the given label string without the mnemonics characters (if any) and without the markup. | |
static wxString | RemoveMarkup (const wxString &str) |
Removes the markup accepted by wxStaticText when the wxST_MARKUP style is used, and then returns the cleaned string. |
wxStaticText::wxStaticText | ( | ) |
Default constructor.
wxStaticText::wxStaticText | ( | wxWindow * | parent, | |
wxWindowID | id, | |||
const wxString & | label, | |||
const wxPoint & | pos = wxDefaultPosition , |
|||
const wxSize & | size = wxDefaultSize , |
|||
long | style = 0 , |
|||
const wxString & | name = wxStaticTextNameStr | |||
) |
Constructor, creating and showing a text control.
parent | Parent window. Should not be NULL. | |
id | Control identifier. A value of -1 denotes a default value. | |
label | Text label. | |
pos | Window position. | |
size | Window size. | |
style | Window style. See wxStaticText. | |
name | Window name. |
bool wxStaticText::Create | ( | wxWindow * | parent, | |
wxWindowID | id, | |||
const wxString & | label, | |||
const wxPoint & | pos = wxDefaultPosition , |
|||
const wxSize & | size = wxDefaultSize , |
|||
long | style = 0 , |
|||
const wxString & | name = wxStaticTextNameStr | |||
) |
Creation function, for two-step construction.
For details see wxStaticText().
Escapes all the symbols of str that have a special meaning (<>"'&
) for wxStaticText objects with the wxST_MARKUP
style.
Those symbols are replaced the corresponding entities (< > " ' &).
wxString wxStaticText::GetLabel | ( | ) | const [virtual] |
Returns the contents of the control.
Note that the returned string contains both the mnemonics (& characters), if any, and markup tags, if any. Use GetLabelText() if only the label text is needed.
Reimplemented from wxControl.
This overload returns the given label string without the mnemonics characters (if any) and without the markup.
Reimplemented from wxControl.
wxString wxStaticText::GetLabelText | ( | ) | const |
This method returns the control's label without the mnemonics characters (if any) and without the markup (if the control has wxST_MARKUP
style).
Reimplemented from wxControl.
bool wxStaticText::IsEllipsized | ( | ) | const |
Returns true if the window styles for this control contains one of the wxST_ELLIPSIZE_START
, wxST_ELLIPSIZE_MIDDLE
or wxST_ELLIPSIZE_END
styles.
Removes the markup accepted by wxStaticText when the wxST_MARKUP
style is used, and then returns the cleaned string.
See SetLabel() for more info about the markup.
virtual void wxStaticText::SetLabel | ( | const wxString & | label | ) | [virtual] |
Sets the static text label and updates the controls size to exactly fit the label unless the control has wxST_NO_AUTORESIZE flag.
This function allows to set decorated static label text on platforms which support it (currently only GTK+ 2). For the other platforms, the markup is ignored.
The supported tags are:
<b> | bold text |
<big> | bigger text |
<i> | italic text |
<s> | strike-through text |
<sub> | subscript text |
<sup> | superscript text |
<small> | smaller text |
<tt> | monospaced text |
<u> | underlined text |
<span> | generic formatter tag; see Pango Markup (http://library.gnome.org/devel/pango/unstable/PangoMarkupFormat.html) for more information. |
Note that the string must be well-formed (e.g. all tags must be correctly closed) otherwise it can be not shown correctly or at all. Also note that you need to escape the following special characters:
Special character | Escape as |
|
|
|
|
|
|
|
|
|
|
The non-escaped ampersand &
characters are interpreted as mnemonics; see wxControl::SetLabel.
Example:
label | The new label to set. It may contain newline characters and the markup tags described above. |
Reimplemented from wxControl.
void wxStaticText::Wrap | ( | int | width | ) |
This functions wraps the controls label so that each of its lines becomes at most width pixels wide if possible (the lines are broken at words boundaries so it might not be the case if words are too long).
If width is negative, no wrapping is done. Note that this width is not necessarily the total width of the control, since a few pixels for the border (depending on the controls border style) may be added.
![]() |
[ top ] |