1 \section{\class{wxStaticText
}}\label{wxstatictext
}
3 A static text control displays one or more lines of read-only text.
5 \wxheading{Derived from
}
7 \helpref{wxControl
}{wxcontrol
}\\
8 \helpref{wxWindow
}{wxwindow
}\\
9 \helpref{wxEvtHandler
}{wxevthandler
}\\
10 \helpref{wxObject
}{wxobject
}
12 \wxheading{Include files
}
16 \wxheading{Window styles
}
19 \begin{twocollist
}\itemsep=
0pt
20 \twocolitem{\windowstyle{wxALIGN
\_LEFT}}{Align the text to the left
}
21 \twocolitem{\windowstyle{wxALIGN
\_RIGHT}}{Align the text to the right
}
22 \twocolitem{\windowstyle{wxALIGN
\_CENTRE}}{Center the text (horizontally)
}
23 \twocolitem{\windowstyle{wxST
\_NO\_AUTORESIZE}}{By default, the control will
24 adjust its size to exactly fit to the size of the text when
25 \helpref{SetLabel
}{wxstatictextsetlabel
} is called. If this style flag is
26 given, the control will not change its size (this style is especially useful
27 with controls which also have wxALIGN
\_RIGHT or CENTER style because otherwise
28 they won't make sense any longer after a call to SetLabel)
}
29 \twocolitem{\windowstyle{wxST
\_ELLIPSIZE\_START}}{If the text width exceeds the
30 control width, replace the beginning of the text with an ellipsis
}
31 \twocolitem{\windowstyle{wxST
\_ELLIPSIZE\_MIDDLE}}{Same as above, but replace
32 the text in the middle of the control with an ellipsis
}
33 \twocolitem{\windowstyle{wxST
\_ELLIPSIZE\_END}}{Same as above, but replace the
34 end of the text with an ellipsis
}
35 \twocolitem{\windowstyle{wxST_MARKUP
}}{Support markup in the label; see
36 \helpref{SetLabel
}{wxstatictextsetlabel
} for more information
}
39 See also
\helpref{window styles overview
}{windowstyles
}.
43 \helpref{wxStaticBitmap
}{wxstaticbitmap
},
\helpref{wxStaticBox
}{wxstaticbox
}
45 \latexignore{\rtfignore{\wxheading{Members
}}}
48 \membersection{wxStaticText::wxStaticText
}\label{wxstatictextconstr
}
50 \func{}{wxStaticText
}{\void}
54 \func{}{wxStaticText
}{\param{wxWindow*
}{parent
},
\param{wxWindowID
}{ id
},
\rtfsp
55 \param{const wxString\&
}{label
},
\param{const wxPoint\&
}{pos = wxDefaultPosition
},
\param{const wxSize\&
}{size = wxDefaultSize
},
\rtfsp
56 \param{long
}{ style =
0},
\param{const wxString\&
}{name = ``staticText"
}}
58 Constructor, creating and showing a text control.
60 \wxheading{Parameters
}
62 \docparam{parent
}{Parent window. Should not be NULL.
}
64 \docparam{id
}{Control identifier. A value of -
1 denotes a default value.
}
66 \docparam{label
}{Text label.
}
68 \docparam{pos
}{Window position.
}
70 \docparam{size
}{Window size.
}
72 \docparam{style
}{Window style. See
\helpref{wxStaticText
}{wxstatictext
}.
}
74 \docparam{name
}{Window name.
}
78 \helpref{wxStaticText::Create
}{wxstatictextcreate
}
81 \membersection{wxStaticText::Create
}\label{wxstatictextcreate
}
83 \func{bool
}{Create
}{\param{wxWindow*
}{parent
},
\param{wxWindowID
}{ id
},
\rtfsp
84 \param{const wxString\&
}{label
},
\param{const wxPoint\&
}{pos = wxDefaultPosition
},
\param{const wxSize\&
}{size = wxDefaultSize
},
\rtfsp
85 \param{long
}{ style =
0},
\param{const wxString\&
}{name = ``staticText"
}}
87 Creation function, for two-step construction. For details see
\helpref{wxStaticText::wxStaticText
}{wxstatictextconstr
}.
90 \membersection{wxStaticText::GetLabel
}\label{wxstatictextgetlabel
}
92 \constfunc{wxString
}{GetLabel
}{\void}
94 Returns the contents of the control.
96 Note that the returned string contains both the mnemonics (
\texttt{\&
} characters),
97 if any, and markup tags, if any.
99 Use
\helpref{wxStaticText::GetLabelText
}{wxstatictextgetlabeltext
} if only the
100 label text is needed.
103 \membersection{wxStaticText::GetLabelText
}\label{wxstatictextgetlabeltext
}
105 \constfunc{const wxString\&
}{GetLabelText
}{\void}
107 Returns the control's label or the given
\arg{label
} string for the static
108 version without the mnemonics characters (if any) and without the markup
109 (if the control has
\texttt{wxST_MARKUP
} style).
113 \membersection{wxStaticText::SetLabel
}\label{wxstatictextsetlabel
}
115 \func{virtual void
}{SetLabel
}{\param{const wxString\&
}{ label
}}
117 Sets the static text label and updates the controls size to exactly fit the
118 label unless the control has wxST
\_NO\_AUTORESIZE flag.
120 This function allows to set decorated static label text on platforms which
121 support it (currently only GTK+
2). For the other platforms, the markup is
124 The supported tags are:
127 \begin{twocollist
}\itemsep=
0pt
128 \twocolitem{<b>
}{bold text
}
129 \twocolitem{<big>
}{bigger text
}
130 \twocolitem{<i>
}{italic text
}
131 \twocolitem{<s>
}{strike-through text
}
132 \twocolitem{<sub>
}{subscript text
}
133 \twocolitem{<sup>
}{superscript text
}
134 \twocolitem{<small>
}{smaller text
}
135 \twocolitem{<tt>
}{monospaced text
}
136 \twocolitem{<u>
}{underlined text
}
137 \twocolitem{<span>
}{generic formatter tag; see
\urlref{Pango Markup
}{http://developer.gnome.org/doc/API/
2.0/pango/PangoMarkupFormat.html
} for more information.
}
140 Note that the string must be well-formed (e.g. all tags must be correctly closed)
141 otherwise it can be not shown correctly or at all.
143 Also note that you need to escape the following special characters:
146 \begin{twocollist
}\itemsep=
0pt
147 \twocolitem{\textbf{Special character
}}{\textbf{Escape as
}}
148 \twocolitem{\texttt{&
}}{\texttt{&
} or as
\texttt{&&
}}
149 \twocolitem{\texttt{'
}}{\texttt{'
}}
150 \twocolitem{\texttt{"
}}{\texttt{"
}}
151 \twocolitem{\texttt{<
}}{\texttt{<
}}
152 \twocolitem{\texttt{>
}}{\texttt{>
}}
155 The non-escaped ampersand
\texttt{&
} characters are interpreted as
156 mnemonics; see
\helpref{wxControl::SetLabel
}{wxcontrolsetlabel
}.
161 %% TEX NOTE: in the following block we need to write the (ugly) &&amp;
162 %% string in order to force Tex2rtf to show the && string
164 // this will set the wxStaticText to show the "Hello world!" string
165 // with the "Hello" world in bold on platforms which support markup
166 pStaticText->SetLabelWithMarkup(wxT("<b>Hello</b> world!"));
168 // this will make wxStaticText show the string:
170 // Specials: & ' " < >"
172 // with "Specials" in smaller size font if markup is supported
173 pStaticText->SetLabelWithMarkup(
174 wxT("<small>Specials</small>: &amp; &apos; &quot;; &lt; &gt;"));
177 \wxheading{Parameters
}
179 \docparam{label
}{The new label to set. It may contain newline characters and the markup tags described above.
}
183 \membersection{wxStaticText::Wrap
}\label{wxstatictextwrap
}
185 \func{void
}{Wrap
}{\param{int
}{width
}}
187 This functions wraps the controls label so that each of its lines becomes at
188 most
\arg{width
} pixels wide if possible (the lines are broken at words
189 boundaries so it might not be the case if words are too long). If
\arg{width
}
190 is negative, no wrapping is done.