]> git.saurik.com Git - wxWidgets.git/blame - docs/latex/wx/stattext.tex
added null pointer check and assert
[wxWidgets.git] / docs / latex / wx / stattext.tex
CommitLineData
a660d684
KB
1\section{\class{wxStaticText}}\label{wxstatictext}
2
3A static text control displays one or more lines of read-only text.
4
a660d684
KB
5\wxheading{Derived from}
6
7\helpref{wxControl}{wxcontrol}\\
8\helpref{wxWindow}{wxwindow}\\
9\helpref{wxEvtHandler}{wxevthandler}\\
10\helpref{wxObject}{wxobject}
11
954b8ae6
JS
12\wxheading{Include files}
13
14<wx/stattext.h>
15
a7af285d
VZ
16\wxheading{Library}
17
18\helpref{wxCore}{librarieslist}
19
a660d684
KB
20\wxheading{Window styles}
21
717a57c2
VZ
22\twocolwidtha{5cm}
23\begin{twocollist}\itemsep=0pt
24\twocolitem{\windowstyle{wxALIGN\_LEFT}}{Align the text to the left}
25\twocolitem{\windowstyle{wxALIGN\_RIGHT}}{Align the text to the right}
2edb0bde 26\twocolitem{\windowstyle{wxALIGN\_CENTRE}}{Center the text (horizontally)}
717a57c2
VZ
27\twocolitem{\windowstyle{wxST\_NO\_AUTORESIZE}}{By default, the control will
28adjust its size to exactly fit to the size of the text when
29\helpref{SetLabel}{wxstatictextsetlabel} is called. If this style flag is
30given, the control will not change its size (this style is especially useful
31with controls which also have wxALIGN\_RIGHT or CENTER style because otherwise
32they won't make sense any longer after a call to SetLabel)}
39bc0347
VZ
33\twocolitem{\windowstyle{wxST\_ELLIPSIZE\_START}}{If the text width exceeds the
34control width, replace the beginning of the text with an ellipsis}
35\twocolitem{\windowstyle{wxST\_ELLIPSIZE\_MIDDLE}}{Same as above, but replace
36the text in the middle of the control with an ellipsis}
37\twocolitem{\windowstyle{wxST\_ELLIPSIZE\_END}}{Same as above, but replace the
38end of the text with an ellipsis}
d6adfdf9 39\twocolitem{\windowstyle{wxST\_MARKUP}}{Support markup in the label; see
39bc0347 40\helpref{SetLabel}{wxstatictextsetlabel} for more information}
717a57c2 41\end{twocollist}
a660d684
KB
42
43See also \helpref{window styles overview}{windowstyles}.
44
45\wxheading{See also}
46
47\helpref{wxStaticBitmap}{wxstaticbitmap}, \helpref{wxStaticBox}{wxstaticbox}
48
49\latexignore{\rtfignore{\wxheading{Members}}}
50
5d1b4919 51
a660d684
KB
52\membersection{wxStaticText::wxStaticText}\label{wxstatictextconstr}
53
54\func{}{wxStaticText}{\void}
55
56Default constructor.
57
eaaa6a06 58\func{}{wxStaticText}{\param{wxWindow* }{parent}, \param{wxWindowID}{ id},\rtfsp
b3e65254 59\param{const wxString\& }{label}, \param{const wxPoint\& }{pos = wxDefaultPosition}, \param{const wxSize\& }{size = wxDefaultSize},\rtfsp
eaaa6a06 60\param{long}{ style = 0}, \param{const wxString\& }{name = ``staticText"}}
a660d684
KB
61
62Constructor, creating and showing a text control.
63
64\wxheading{Parameters}
65
66\docparam{parent}{Parent window. Should not be NULL.}
67
68\docparam{id}{Control identifier. A value of -1 denotes a default value.}
69
70\docparam{label}{Text label.}
71
72\docparam{pos}{Window position.}
73
74\docparam{size}{Window size.}
75
76\docparam{style}{Window style. See \helpref{wxStaticText}{wxstatictext}.}
77
78\docparam{name}{Window name.}
79
80\wxheading{See also}
81
82\helpref{wxStaticText::Create}{wxstatictextcreate}
83
5d1b4919 84
a660d684
KB
85\membersection{wxStaticText::Create}\label{wxstatictextcreate}
86
eaaa6a06 87\func{bool}{Create}{\param{wxWindow* }{parent}, \param{wxWindowID}{ id},\rtfsp
b3e65254 88\param{const wxString\& }{label}, \param{const wxPoint\& }{pos = wxDefaultPosition}, \param{const wxSize\& }{size = wxDefaultSize},\rtfsp
eaaa6a06 89\param{long}{ style = 0}, \param{const wxString\& }{name = ``staticText"}}
a660d684
KB
90
91Creation function, for two-step construction. For details see \helpref{wxStaticText::wxStaticText}{wxstatictextconstr}.
92
5d1b4919 93
a660d684
KB
94\membersection{wxStaticText::GetLabel}\label{wxstatictextgetlabel}
95
96\constfunc{wxString}{GetLabel}{\void}
97
98Returns the contents of the control.
99
39bc0347
VZ
100Note that the returned string contains both the mnemonics (\texttt{\&} characters),
101if any, and markup tags, if any.
102
103Use \helpref{wxStaticText::GetLabelText}{wxstatictextgetlabeltext} if only the
104label text is needed.
105
106
107\membersection{wxStaticText::GetLabelText}\label{wxstatictextgetlabeltext}
108
19cf1ef3 109\constfunc{wxString}{GetLabelText}{\void}
39bc0347 110
19cf1ef3 111\func{static wxString}{GetLabelText}{\param{const wxString\& }{label}}
39bc0347 112
19cf1ef3
FM
113The first form returns the control's label without the mnemonics characters (if any)
114and without the markup (if the control has \texttt{wxST\_MARKUP} style).
115
116The second (static) version returns the given \arg{label} string without the mnemonics
117characters (if any) and without the markup.
39bc0347 118
5d1b4919 119
a660d684
KB
120\membersection{wxStaticText::SetLabel}\label{wxstatictextsetlabel}
121
122\func{virtual void}{SetLabel}{\param{const wxString\& }{ label}}
123
717a57c2
VZ
124Sets the static text label and updates the controls size to exactly fit the
125label unless the control has wxST\_NO\_AUTORESIZE flag.
a660d684 126
39bc0347
VZ
127This function allows to set decorated static label text on platforms which
128support it (currently only GTK+ 2). For the other platforms, the markup is
129ignored.
130
131The supported tags are:
132
133\twocolwidtha{5cm}
134\begin{twocollist}\itemsep=0pt
135\twocolitem{<b>}{bold text}
136\twocolitem{<big>}{bigger text}
137\twocolitem{<i>}{italic text}
138\twocolitem{<s>}{strike-through text}
139\twocolitem{<sub>}{subscript text}
140\twocolitem{<sup>}{superscript text}
141\twocolitem{<small>}{smaller text}
142\twocolitem{<tt>}{monospaced text}
143\twocolitem{<u>}{underlined text}
144\twocolitem{<span>}{generic formatter tag; see \urlref{Pango Markup}{http://developer.gnome.org/doc/API/2.0/pango/PangoMarkupFormat.html} for more information.}
145\end{twocollist}
146
147Note that the string must be well-formed (e.g. all tags must be correctly closed)
148otherwise it can be not shown correctly or at all.
149
150Also note that you need to escape the following special characters:
151
152\twocolwidtha{5cm}
153\begin{twocollist}\itemsep=0pt
154\twocolitem{\textbf{Special character}}{\textbf{Escape as}}
155\twocolitem{\texttt{&}}{\texttt{&amp;} or as \texttt{&&}}
156\twocolitem{\texttt{'}}{\texttt{&apos;}}
157\twocolitem{\texttt{"}}{\texttt{&quot;}}
158\twocolitem{\texttt{<}}{\texttt{&lt;}}
159\twocolitem{\texttt{>}}{\texttt{&gt;}}
160\end{twocollist}
161
162The non-escaped ampersand \texttt{&} characters are interpreted as
163mnemonics; see \helpref{wxControl::SetLabel}{wxcontrolsetlabel}.
164
165
166Example:
167
168%% TEX NOTE: in the following block we need to write the (ugly) &&amp;amp;
169%% string in order to force Tex2rtf to show the &&amp; string
170\begin{verbatim}
171 // this will set the wxStaticText to show the "Hello world!" string
172 // with the "Hello" world in bold on platforms which support markup
173 pStaticText->SetLabelWithMarkup(wxT("<b>Hello</b> world!"));
174
175 // this will make wxStaticText show the string:
176 //
177 // Specials: & ' " < >"
178 //
179 // with "Specials" in smaller size font if markup is supported
180 pStaticText->SetLabelWithMarkup(
181 wxT("<small>Specials</small>: &amp;amp; &amp;apos; &amp;quot;; &amp;lt; &amp;gt;"));
182\end{verbatim}
183
a660d684
KB
184\wxheading{Parameters}
185
39bc0347
VZ
186\docparam{label}{The new label to set. It may contain newline characters and the markup tags described above.}
187
a660d684 188
5d1b4919 189
39bc0347 190\membersection{wxStaticText::Wrap}\label{wxstatictextwrap}
5d1b4919
VZ
191
192\func{void}{Wrap}{\param{int }{width}}
193
194This functions wraps the controls label so that each of its lines becomes at
195most \arg{width} pixels wide if possible (the lines are broken at words
196boundaries so it might not be the case if words are too long). If \arg{width}
197is negative, no wrapping is done.
98fe5d46
VZ
198
199\newsince{2.6.2}
1d20b7f2 200