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