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
}
18 \helpref{wxCore
}{librarieslist
}
20 \wxheading{Window styles
}
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
}
26 \twocolitem{\windowstyle{wxALIGN
\_CENTRE}}{Center the text (horizontally)
}
27 \twocolitem{\windowstyle{wxST
\_NO\_AUTORESIZE}}{By default, the control will
28 adjust its size to exactly fit to the size of the text when
29 \helpref{SetLabel
}{wxstatictextsetlabel
} is called. If this style flag is
30 given, the control will not change its size (this style is especially useful
31 with controls which also have wxALIGN
\_RIGHT or CENTER style because otherwise
32 they won't make sense any longer after a call to SetLabel)
}
33 \twocolitem{\windowstyle{wxST
\_ELLIPSIZE\_START}}{If the text width exceeds the
34 control width, replace the beginning of the text with an ellipsis
}
35 \twocolitem{\windowstyle{wxST
\_ELLIPSIZE\_MIDDLE}}{Same as above, but replace
36 the text in the middle of the control with an ellipsis
}
37 \twocolitem{\windowstyle{wxST
\_ELLIPSIZE\_END}}{Same as above, but replace the
38 end of the text with an ellipsis
}
39 \twocolitem{\windowstyle{wxST
\_MARKUP}}{Support markup in the label; see
40 \helpref{SetLabel
}{wxstatictextsetlabel
} for more information
}
43 See also
\helpref{window styles overview
}{windowstyles
}.
47 \helpref{wxStaticBitmap
}{wxstaticbitmap
},
\helpref{wxStaticBox
}{wxstaticbox
}
49 \latexignore{\rtfignore{\wxheading{Members
}}}
52 \membersection{wxStaticText::wxStaticText
}\label{wxstatictextconstr
}
54 \func{}{wxStaticText
}{\void}
58 \func{}{wxStaticText
}{\param{wxWindow*
}{parent
},
\param{wxWindowID
}{ id
},
\rtfsp
59 \param{const wxString\&
}{label
},
\param{const wxPoint\&
}{pos = wxDefaultPosition
},
\param{const wxSize\&
}{size = wxDefaultSize
},
\rtfsp
60 \param{long
}{ style =
0},
\param{const wxString\&
}{name = ``staticText"
}}
62 Constructor, creating and showing a text control.
64 \wxheading{Parameters
}
66 \docparam{parent
}{Parent window. Should not be NULL.
}
68 \docparam{id
}{Control identifier. A value of -
1 denotes a default value.
}
70 \docparam{label
}{Text label.
}
72 \docparam{pos
}{Window position.
}
74 \docparam{size
}{Window size.
}
76 \docparam{style
}{Window style. See
\helpref{wxStaticText
}{wxstatictext
}.
}
78 \docparam{name
}{Window name.
}
82 \helpref{wxStaticText::Create
}{wxstatictextcreate
}
85 \membersection{wxStaticText::Create
}\label{wxstatictextcreate
}
87 \func{bool
}{Create
}{\param{wxWindow*
}{parent
},
\param{wxWindowID
}{ id
},
\rtfsp
88 \param{const wxString\&
}{label
},
\param{const wxPoint\&
}{pos = wxDefaultPosition
},
\param{const wxSize\&
}{size = wxDefaultSize
},
\rtfsp
89 \param{long
}{ style =
0},
\param{const wxString\&
}{name = ``staticText"
}}
91 Creation function, for two-step construction. For details see
\helpref{wxStaticText::wxStaticText
}{wxstatictextconstr
}.
94 \membersection{wxStaticText::GetLabel
}\label{wxstatictextgetlabel
}
96 \constfunc{wxString
}{GetLabel
}{\void}
98 Returns the contents of the control.
100 Note that the returned string contains both the mnemonics (
\texttt{\&
} characters),
101 if any, and markup tags, if any.
103 Use
\helpref{wxStaticText::GetLabelText
}{wxstatictextgetlabeltext
} if only the
104 label text is needed.
107 \membersection{wxStaticText::GetLabelText
}\label{wxstatictextgetlabeltext
}
109 \constfunc{wxString
}{GetLabelText
}{\void}
111 \func{static wxString
}{GetLabelText
}{\param{const wxString\&
}{label
}}
113 The first form returns the control's label without the mnemonics characters (if any)
114 and without the markup (if the control has
\texttt{wxST
\_MARKUP} style).
116 The second (static) version returns the given
\arg{label
} string without the mnemonics
117 characters (if any) and without the markup.
120 \membersection{wxStaticText::SetLabel
}\label{wxstatictextsetlabel
}
122 \func{virtual void
}{SetLabel
}{\param{const wxString\&
}{ label
}}
124 Sets the static text label and updates the controls size to exactly fit the
125 label unless the control has wxST
\_NO\_AUTORESIZE flag.
127 This function allows to set decorated static label text on platforms which
128 support it (currently only GTK+
2). For the other platforms, the markup is
131 The supported tags are:
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.
}
147 Note that the string must be well-formed (e.g. all tags must be correctly closed)
148 otherwise it can be not shown correctly or at all.
150 Also note that you need to escape the following special characters:
153 \begin{twocollist
}\itemsep=
0pt
154 \twocolitem{\textbf{Special character
}}{\textbf{Escape as
}}
155 \twocolitem{\texttt{&
}}{\texttt{&
} or as
\texttt{&&
}}
156 \twocolitem{\texttt{'
}}{\texttt{'
}}
157 \twocolitem{\texttt{"
}}{\texttt{"
}}
158 \twocolitem{\texttt{<
}}{\texttt{<
}}
159 \twocolitem{\texttt{>
}}{\texttt{>
}}
162 The non-escaped ampersand
\texttt{&
} characters are interpreted as
163 mnemonics; see
\helpref{wxControl::SetLabel
}{wxcontrolsetlabel
}.
168 %% TEX NOTE: in the following block we need to write the (ugly) &&amp;
169 %% string in order to force Tex2rtf to show the && string
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!"));
175 // this will make wxStaticText show the string:
177 // Specials: & ' " < >"
179 // with "Specials" in smaller size font if markup is supported
180 pStaticText->SetLabelWithMarkup(
181 wxT("<small>Specials</small>: &amp; &apos; &quot;; &lt; &gt;"));
184 \wxheading{Parameters
}
186 \docparam{label
}{The new label to set. It may contain newline characters and the markup tags described above.
}
190 \membersection{wxStaticText::Wrap
}\label{wxstatictextwrap
}
192 \func{void
}{Wrap
}{\param{int
}{width
}}
194 This functions wraps the controls label so that each of its lines becomes at
195 most
\arg{width
} pixels wide if possible (the lines are broken at words
196 boundaries so it might not be the case if words are too long). If
\arg{width
}
197 is negative, no wrapping is done.