X-Git-Url: https://git.saurik.com/wxWidgets.git/blobdiff_plain/a660d684eda27638bca0384b2058911a31c8e845..ab9717339232a7a728dea666c59b73fd6ac78dd3:/docs/latex/wx/stattext.tex diff --git a/docs/latex/wx/stattext.tex b/docs/latex/wx/stattext.tex index a8678e27e5..00be03aa2c 100644 --- a/docs/latex/wx/stattext.tex +++ b/docs/latex/wx/stattext.tex @@ -2,10 +2,6 @@ A static text control displays one or more lines of read-only text. -TODO: should a static text have a validator? E.g. if you wanted -to use it to initialise the control with some text taken from -the validator. - \wxheading{Derived from} \helpref{wxControl}{wxcontrol}\\ @@ -13,9 +9,36 @@ the validator. \helpref{wxEvtHandler}{wxevthandler}\\ \helpref{wxObject}{wxobject} +\wxheading{Include files} + + + +\wxheading{Library} + +\helpref{wxCore}{librarieslist} + \wxheading{Window styles} -There are no special styles for this control. +\twocolwidtha{5cm} +\begin{twocollist}\itemsep=0pt +\twocolitem{\windowstyle{wxALIGN\_LEFT}}{Align the text to the left} +\twocolitem{\windowstyle{wxALIGN\_RIGHT}}{Align the text to the right} +\twocolitem{\windowstyle{wxALIGN\_CENTRE}}{Center the text (horizontally)} +\twocolitem{\windowstyle{wxST\_NO\_AUTORESIZE}}{By default, the control will +adjust its size to exactly fit to the size of the text when +\helpref{SetLabel}{wxstatictextsetlabel} is called. If this style flag is +given, the control will not change its size (this style is especially useful +with controls which also have wxALIGN\_RIGHT or CENTER style because otherwise +they won't make sense any longer after a call to SetLabel)} +\twocolitem{\windowstyle{wxST\_ELLIPSIZE\_START}}{If the text width exceeds the +control width, replace the beginning of the text with an ellipsis} +\twocolitem{\windowstyle{wxST\_ELLIPSIZE\_MIDDLE}}{Same as above, but replace +the text in the middle of the control with an ellipsis} +\twocolitem{\windowstyle{wxST\_ELLIPSIZE\_END}}{Same as above, but replace the +end of the text with an ellipsis} +\twocolitem{\windowstyle{wxST\_MARKUP}}{Support markup in the label; see +\helpref{SetLabel}{wxstatictextsetlabel} for more information} +\end{twocollist} See also \helpref{window styles overview}{windowstyles}. @@ -25,15 +48,16 @@ See also \helpref{window styles overview}{windowstyles}. \latexignore{\rtfignore{\wxheading{Members}}} + \membersection{wxStaticText::wxStaticText}\label{wxstatictextconstr} \func{}{wxStaticText}{\void} Default constructor. -\func{}{wxStaticText}{\param{wxWindow* }{parent}, \param{const wxWindowID}{ id},\rtfsp -\param{const wxString\& }{label = ``"}, \param{const wxPosition\& }{pos}, \param{const wxSize\& }{size = wxDefaultSize},\rtfsp -\param{const long}{ style = 0}, \param{const wxString\& }{name = ``staticText"}} +\func{}{wxStaticText}{\param{wxWindow* }{parent}, \param{wxWindowID}{ id},\rtfsp +\param{const wxString\& }{label}, \param{const wxPoint\& }{pos = wxDefaultPosition}, \param{const wxSize\& }{size = wxDefaultSize},\rtfsp +\param{long}{ style = 0}, \param{const wxString\& }{name = ``staticText"}} Constructor, creating and showing a text control. @@ -57,28 +81,120 @@ Constructor, creating and showing a text control. \helpref{wxStaticText::Create}{wxstatictextcreate} + \membersection{wxStaticText::Create}\label{wxstatictextcreate} -\func{bool}{Create}{\param{wxWindow* }{parent}, \param{const wxWindowID}{ id},\rtfsp -\param{const wxString\& }{label = ``"}, \param{const wxPosition\& }{pos}, \param{const wxSize\& }{size = wxDefaultSize},\rtfsp -\param{const long}{ style = 0}, \param{const wxString\& }{name = ``staticText"}} +\func{bool}{Create}{\param{wxWindow* }{parent}, \param{wxWindowID}{ id},\rtfsp +\param{const wxString\& }{label}, \param{const wxPoint\& }{pos = wxDefaultPosition}, \param{const wxSize\& }{size = wxDefaultSize},\rtfsp +\param{long}{ style = 0}, \param{const wxString\& }{name = ``staticText"}} Creation function, for two-step construction. For details see \helpref{wxStaticText::wxStaticText}{wxstatictextconstr}. + \membersection{wxStaticText::GetLabel}\label{wxstatictextgetlabel} \constfunc{wxString}{GetLabel}{\void} Returns the contents of the control. +Note that the returned string contains both the mnemonics (\texttt{\&} characters), +if any, and markup tags, if any. + +Use \helpref{wxStaticText::GetLabelText}{wxstatictextgetlabeltext} if only the +label text is needed. + + +\membersection{wxStaticText::GetLabelText}\label{wxstatictextgetlabeltext} + +\constfunc{wxString}{GetLabelText}{\void} + +\func{static wxString}{GetLabelText}{\param{const wxString\& }{label}} + +The first form returns the control's label without the mnemonics characters (if any) +and without the markup (if the control has \texttt{wxST\_MARKUP} style). + +The second (static) version returns the given \arg{label} string without the mnemonics +characters (if any) and without the markup. + + \membersection{wxStaticText::SetLabel}\label{wxstatictextsetlabel} \func{virtual void}{SetLabel}{\param{const wxString\& }{ label}} -Sets the static text label. +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: + +\twocolwidtha{5cm} +\begin{twocollist}\itemsep=0pt +\twocolitem{}{bold text} +\twocolitem{}{bigger text} +\twocolitem{}{italic text} +\twocolitem{}{strike-through text} +\twocolitem{}{subscript text} +\twocolitem{}{superscript text} +\twocolitem{}{smaller text} +\twocolitem{}{monospaced text} +\twocolitem{}{underlined text} +\twocolitem{}{generic formatter tag; see \urlref{Pango Markup}{http://developer.gnome.org/doc/API/2.0/pango/PangoMarkupFormat.html} for more information.} +\end{twocollist} + +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: + +\twocolwidtha{5cm} +\begin{twocollist}\itemsep=0pt +\twocolitem{\textbf{Special character}}{\textbf{Escape as}} +\twocolitem{\texttt{&}}{\texttt{&} or as \texttt{&&}} +\twocolitem{\texttt{'}}{\texttt{'}} +\twocolitem{\texttt{"}}{\texttt{"}} +\twocolitem{\texttt{<}}{\texttt{<}} +\twocolitem{\texttt{>}}{\texttt{>}} +\end{twocollist} + +The non-escaped ampersand \texttt{&} characters are interpreted as +mnemonics; see \helpref{wxControl::SetLabel}{wxcontrolsetlabel}. + + +Example: + +%% TEX NOTE: in the following block we need to write the (ugly) &&amp; +%% string in order to force Tex2rtf to show the && string +\begin{verbatim} + // this will set the wxStaticText to show the "Hello world!" string + // with the "Hello" world in bold on platforms which support markup + pStaticText->SetLabelWithMarkup(wxT("Hello world!")); + + // this will make wxStaticText show the string: + // + // Specials: & ' " < >" + // + // with "Specials" in smaller size font if markup is supported + pStaticText->SetLabelWithMarkup( + wxT("Specials: &amp; &apos; &quot;; &lt; &gt;")); +\end{verbatim} \wxheading{Parameters} -\docparam{label}{The new label to set. It may contain newline characters.} +\docparam{label}{The new label to set. It may contain newline characters and the markup tags described above.} + + + +\membersection{wxStaticText::Wrap}\label{wxstatictextwrap} + +\func{void}{Wrap}{\param{int }{width}} + +This functions wraps the controls label so that each of its lines becomes at +most \arg{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 \arg{width} +is negative, no wrapping is done. +\newsince{2.6.2}