wxStaticText Class Reference
[Controls]

#include <wx/stattext.h>

Inheritance diagram for wxStaticText:

wxControl wxWindow wxEvtHandler wxObject

List of all members.


Detailed Description

A static text control displays one or more lines of read-only text.

Styles:

Library:  wxCore

Category:  Controls

Appearance:
wxMSW appearancewxGTK appearancewxMac appearance
wxMSW appearancewxGTK appearancewxMac appearance

See also:
wxStaticBitmap, wxStaticBox

Public Member Functions

 wxStaticText ()
 wxStaticText (wxWindow *parent, wxWindowID id, const wxString &label, const wxPoint &pos=wxDefaultPosition, const wxSize &size=wxDefaultSize, long style=0, const wxString &name=wxStaticTextNameStr)
bool Create (wxWindow *parent, wxWindowID id, const wxString &label, const wxPoint &pos=wxDefaultPosition, const wxSize &size=wxDefaultSize, long style=0, const wxString &name=wxStaticTextNameStr)
wxString GetLabel () const
wxString GetLabelText () const
virtual void SetLabel (const wxString &label)
void Wrap (int width)

Static Public Member Functions

static wxString GetLabelText (const wxString &label)

Constructor & Destructor Documentation

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.

Parameters:
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.
See also:
Create()


Member Function Documentation

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().

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.

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.

static wxString wxStaticText::GetLabelText ( const wxString label  )  [static]

This overload returns the given label string without the mnemonics characters (if any) and without the markup.

Reimplemented from wxControl.

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
& &amp; or as &&
' &apos;
" &quot;
< &lt;
> &gt;

The non-escaped ampersand & characters are interpreted as mnemonics; see wxControl::SetLabel.

Example:

Parameters:
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.

Since:
2.6.2



wxWidgets logo

[ top ]