1 %%%%%%%%%%%%%%%%%%%%%%%%%%%% wxTextAttr %%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
3 \section{\class{wxTextAttr
}}\label{wxtextattr
}
5 wxTextAttr represents the attributes, or style, for a range of text in a
\rtfsp
6 \helpref{wxTextCtrl
}{wxtextctrl
}.
8 \wxheading{Derived from
}
12 \wxheading{Include files
}
16 \latexignore{\rtfignore{\wxheading{Members
}}}
18 \membersection{wxTextAttr::wxTextAttr
}\label{wxtextattrctor
}
20 \func{}{wxTextAttr
}{\void}
22 \func{}{wxTextAttr
}{\param{const wxColour\&
}{colText
},
\param{const wxColour\&
}{colBack = wxNullColour
},
\param{const wxFont\&
}{font = wxNullFont
}}
24 The constructors initialize one or more of the text foreground and background
25 colours and font. The values not initialized in the constructor can be set
26 later, otherwise
\helpref{wxTextCtrl::SetStyle
}{wxtextctrlsetstyle
} will use
27 the default values for them.
29 \membersection{wxTextAttr::GetBackgroundColour
}
31 \constfunc{const wxColour\&
}{GetBackgroundColour
}{\void}
33 Return the background colour specified by this attribute.
35 \membersection{wxTextAttr::GetFont
}
37 \constfunc{const wxFont\&
}{GetFont
}{\void}
39 Return the text font specified by this attribute.
41 \membersection{wxTextAttr::GetTextColour
}
43 \constfunc{const wxColour\&
}{GetTextColour
}{\void}
45 Return the text colour specified by this attribute.
47 \membersection{wxTextAttr::HasBackgroundColour
}
49 \constfunc{bool
}{HasBackgroundColour
}{\void}
51 Returns
{\tt TRUE
} if this style specifies the background colour to use.
53 \membersection{wxTextAttr::HasFont
}
55 \constfunc{bool
}{HasFont
}{\void}
57 Returns
{\tt TRUE
} if this style specifies the font to use.
59 \membersection{wxTextAttr::HasTextColour
}
61 \constfunc{bool
}{HasTextColour
}{\void}
63 Returns
{\tt TRUE
} if this style specifies the foreground colour to use.
65 \membersection{wxTextAttr::IsDefault
}
67 \constfunc{bool
}{IsDefault
}{\void}
69 Returns
{\tt TRUE
} if this style specifies any non-default attributes.
71 %%%%%%%%%%%%%%%%%%%%%%%%%%%% wxTextCtrl %%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
73 \section{\class{wxTextCtrl
}}\label{wxtextctrl
}
75 A text control allows text to be displayed and edited. It may be
76 single line or multi-line.
78 \wxheading{Derived from
}
81 \helpref{wxControl
}{wxcontrol
}\\
82 \helpref{wxWindow
}{wxwindow
}\\
83 \helpref{wxEvtHandler
}{wxevthandler
}\\
84 \helpref{wxObject
}{wxobject
}
86 \wxheading{Include files
}
90 \wxheading{Window styles
}
93 \begin{twocollist
}\itemsep=
0pt
94 \twocolitem{\windowstyle{wxTE
\_PROCESS\_ENTER}}{The control will generate
95 the message wxEVENT
\_TYPE\_TEXT\_ENTER\_COMMAND (otherwise pressing <Enter> is
96 either processed internally by the control or used for navigation between
98 \twocolitem{\windowstyle{wxTE
\_PROCESS\_TAB}}{The control will receive
99 EVT
\_CHAR messages for TAB pressed - normally, TAB is used for passing to the
100 next control in a dialog instead. For the control created with this style,
101 you can still use Ctrl-Enter to pass to the next control from the keyboard.
}
102 \twocolitem{\windowstyle{wxTE
\_MULTILINE}}{The text control allows multiple lines.
}
103 \twocolitem{\windowstyle{wxTE
\_PASSWORD}}{The text will be echoed as asterisks.
}
104 \twocolitem{\windowstyle{wxTE
\_READONLY}}{The text will not be user-editable.
}
105 \twocolitem{\windowstyle{wxTE
\_RICH}}{Use rich text control under Win32, this
106 allows to have more than
64Kb of text in the control even under Win9x. This
107 style is ignored under other platforms.
}
108 \twocolitem{\windowstyle{wxTE
\_RICH2}}{Use rich text control version
2.0 or
3.0
109 under Win32, this style is ignored under other platforms
}
110 \twocolitem{\windowstyle{wxTE
\_AUTO\_URL}}{Highlight the URLs and generate the
111 wxTextUrlEvents when mouse events occur over them. This style is supported
112 under Win32 only and requires wxTE
\_RICH.
}
113 \twocolitem{\windowstyle{wxTE
\_NOHIDESEL}}{By default, the Windows text control
114 doesn't show the selection when it doesn't have focus - use this style to force
115 it to always show it. It doesn't do anything under other platforms.
}
116 \twocolitem{\windowstyle{wxHSCROLL
}}{A horizontal scrollbar will be created. No effect under GTK+.
}
117 \twocolitem{\windowstyle{wxTE
\_DONTWRAP}}{Same as
{\tt wxHSCROLL
} style.
}
118 \twocolitem{\windowstyle{wxTE
\_LINEWRAP}}{Wrap the lines too long to be shown entirely at any position (wxUniv only currently)
}
119 \twocolitem{\windowstyle{wxTE
\_WORDWRAP}}{Wrap the lines too long to be shown entirely at word boundaries only (wxUniv only currently)
}
122 See also
\helpref{window styles overview
}{windowstyles
} and
123 \helpref{wxTextCtrl::wxTextCtrl
}{wxtextctrlconstr
}.
125 \wxheading{wxTextCtrl styles
}
127 Multi-line text controls support the styles, i.e. provide a possibility to set
128 colours and font for individual characters in it (note that under Windows
{\tt
129 wxTE
\_RICH} style is required for style support). To use the styles you can
130 either call
\helpref{SetDefaultStyle
}{wxtextctrlsetdefaultstyle
} before
131 inserting the text or call
\helpref{SetStyle
}{wxtextctrlsetstyle
} later to
132 change the style of the text already in the control (the first solution is
133 much more efficient).
135 In either case, if the style doesn't specify some of the attributes (for
136 example you only want to set the text colour but without changing the font nor
137 the text background), the values of the default style will be used for them.
138 If there is no default style, the attributes of the text control itself are
141 So the following code correctly describes what it does: the second call
142 to
\helpref{SetDefaultStyle
}{wxtextctrlsetdefaultstyle
} doesn't change the
143 text foreground colour (which stays red) while the last one doesn't change the
144 background colour (which stays grey):
148 text->SetDefaultStyle(wxTextAttr
(*wxRED));
149 text->AppendText("Red text\n");
150 text->SetDefaultStyle(wxTextAttr(wxNullColour, *wxLIGHT_GREY));
151 text->AppendText("Red on grey text\n");
152 text->SetDefaultStyle(wxTextAttr(*wxBLUE);
153 text->AppendText("Blue on grey text\n");
157 \wxheading{wxTextCtrl and C++ streams}
159 This class multiply-inherits from {\bf streambuf} where compilers allow,
160 allowing code such as the following:
164 wxTextCtrl *control = new wxTextCtrl(...);
166 ostream stream(control)
168 stream << 123.456 << " some text\n";
173 If your compiler does not support derivation from {\bf streambuf} and gives a
174 compile error, define the symbol {\bf NO\_TEXT\_WINDOW\_STREAM} in the
175 wxTextCtrl header file.
177 Note that independently of this setting you can always use wxTextCtrl itself
178 in a stream-like manner:
182 wxTextCtrl *control = new wxTextCtrl(...);
184 *control << 123.456 << " some text\n";
188 always works. However the possibility to create an ostream associated with
189 wxTextCtrl may be useful if you need to redirect the output of a function
190 taking an ostream as parameter to a text control.
192 Another commonly requested need is to redirect {\bf std::cout} to the text
193 control. This could be done in the following way:
199 wxTextCtrl *control = new wxTextCtrl(...);
201 std::streambuf *sbOld = std::cout.rdbuf();
202 std::cout.rdbuf(*control);
204 // use cout as usual, the output appears in the text control
207 std::cout.rdbuf(sbOld);
211 But wxWindows provides a convenient class to make it even simpler so instead
218 wxTextCtrl *control = new wxTextCtrl(...);
220 wxStreamToTextRedirector redirect(control);
222 // all output to cout goes into the text control until the exit from current
227 See \helpref{wxStreamToTextRedirector}{wxstreamtotextredirector} for more
230 \wxheading{Event handling}
232 The following commands are processed by default event handlers in wxTextCtrl: wxID\_CUT, wxID\_COPY,
233 wxID\_PASTE, wxID\_UNDO, wxID\_REDO. The associated UI update events are also processed
234 automatically, when the control has the focus.
236 To process input from a text control, use these event handler macros to direct input to member
237 functions that take a \helpref{wxCommandEvent}{wxcommandevent} argument.
240 \begin{twocollist}\itemsep=0pt
241 \twocolitem{{\bf EVT\_TEXT(id, func)}}{Respond to a wxEVT\_COMMAND\_TEXT\_UPDATED event,
242 generated when the text changes. Notice that this event will always be sent
243 when the text controls contents changes - whether this is due to user input or
244 comes from the program itself (for example, if SetValue() is called)}
245 \twocolitem{{\bf EVT\_TEXT\_ENTER(id, func)}}{Respond to a wxEVT\_COMMAND\_TEXT\_ENTER event,
246 generated when enter is pressed in a single-line text control.}
247 \twocolitem{{\bf EVT\_TEXT\_URL(id, func)}}{A mouse event occured over an URL
248 in the text control (Win32 only)}
249 \twocolitem{{\bf EVT\_TEXT\_MAXLEN(id, func)}}{User tried to enter more text
250 into the control than the limit set by
251 \helpref{SetMaxLength}{wxtextctrlsetmaxlength}.}
254 \latexignore{\rtfignore{\wxheading{Members}}}
256 \membersection{wxTextCtrl::wxTextCtrl}\label{wxtextctrlconstr}
258 \func{}{wxTextCtrl}{\void}
262 \func{}{wxTextCtrl}{\param{wxWindow* }{parent}, \param{wxWindowID}{ id},\rtfsp
263 \param{const wxString\& }{value = ``"}, \param{const wxPoint\& }{pos = wxDefaultPosition}, \param{const wxSize\& }{size = wxDefaultSize},\rtfsp
264 \param{long}{ style = 0}, \param{const wxValidator\& }{validator = wxDefaultValidator}, \param{const wxString\& }{name = wxTextCtrlNameStr}}
266 Constructor, creating and showing a text control.
268 \wxheading{Parameters}
270 \docparam{parent}{Parent window. Should not be NULL.}
272 \docparam{id}{Control identifier. A value of -1 denotes a default value.}
274 \docparam{value}{Default text value.}
276 \docparam{pos}{Text control position.}
278 \docparam{size}{Text control size.}
280 \docparam{style}{Window style. See \helpref{wxTextCtrl}{wxtextctrl}.}
282 \docparam{validator}{Window validator.}
284 \docparam{name}{Window name.}
288 The horizontal scrollbar ({\bf wxHSCROLL} style flag) will only be created
289 for multi-line text controls.
290 Without a horizontal scrollbar, text lines that don't fit in the control's
291 size will be wrapped (but no newline character is inserted). Single line
292 controls don't have a horizontal scrollbar, the text is automatically scrolled
293 so that the \helpref{insertion point}{wxtextctrlgetinsertionpoint} is always
296 % VZ: this is no longer true
297 %Under Windows, if the {\bf wxTE\_MULTILINE} style is used, the window is implemented
298 %as a Windows rich text control with unlimited capacity. Otherwise, normal edit control limits
303 \helpref{wxTextCtrl::Create}{wxtextctrlcreate}, \helpref{wxValidator}{wxvalidator}
305 \membersection{wxTextCtrl::\destruct{wxTextCtrl}}
307 \func{}{\destruct{wxTextCtrl}}{\void}
309 Destructor, destroying the text control.
311 \membersection{wxTextCtrl::AppendText}\label{wxtextctrlappendtext}
313 \func{void}{AppendText}{\param{const wxString\& }{ text}}
315 Appends the text to the end of the text control.
317 \wxheading{Parameters}
319 \docparam{text}{Text to write to the text control.}
323 After the text is appended, the insertion point will be at the end of the text control. If this behaviour is not desired,
324 the programmer should use \helpref{GetInsertionPoint}{wxtextctrlgetinsertionpoint} and \helpref{SetInsertionPoint}{wxtextctrlsetinsertionpoint}.
328 \helpref{wxTextCtrl::WriteText}{wxtextctrlwritetext}
330 \membersection{wxTextCtrl::CanCopy}\label{wxtextctrlcancopy}
332 \func{virtual bool}{CanCopy}{\void}
334 Returns {\tt TRUE} if the selection can be copied to the clipboard.
336 \membersection{wxTextCtrl::CanCut}\label{wxtextctrlcancut}
338 \func{virtual bool}{CanCut}{\void}
340 Returns {\tt TRUE} if the selection can be cut to the clipboard.
342 \membersection{wxTextCtrl::CanPaste}\label{wxtextctrlcanpaste}
344 \func{virtual bool}{CanPaste}{\void}
346 Returns {\tt TRUE} if the contents of the clipboard can be pasted into the
347 text control. On some platforms (Motif, GTK) this is an approximation
348 and returns {\tt TRUE} if the control is editable, {\tt FALSE} otherwise.
350 \membersection{wxTextCtrl::CanRedo}\label{wxtextctrlcanredo}
352 \func{virtual bool}{CanRedo}{\void}
354 Returns {\tt TRUE} if there is a redo facility available and the last operation
357 \membersection{wxTextCtrl::CanUndo}\label{wxtextctrlcanundo}
359 \func{virtual bool}{CanUndo}{\void}
361 Returns {\tt TRUE} if there is an undo facility available and the last operation
364 \membersection{wxTextCtrl::Clear}\label{wxtextctrlclear}
366 \func{virtual void}{Clear}{\void}
368 Clears the text in the control.
370 Note that this function will generate a {\tt wxEVT\_COMMAND\_TEXT\_UPDATED}
373 \membersection{wxTextCtrl::Copy}\label{wxtextctrlcopy}
375 \func{virtual void}{Copy}{\void}
377 Copies the selected text to the clipboard under Motif and MS Windows.
379 \membersection{wxTextCtrl::Create}\label{wxtextctrlcreate}
381 \func{bool}{Create}{\param{wxWindow* }{parent}, \param{wxWindowID}{ id},\rtfsp
382 \param{const wxString\& }{value = ``"}, \param{const wxPoint\& }{pos = wxDefaultPosition}, \param{const wxSize\& }{size = wxDefaultSize},\rtfsp
383 \param{long}{ style = 0}, \param{const wxValidator\& }{validator = wxDefaultValidator}, \param{const wxString\& }{name = wxTextCtrlNameStr}}
385 Creates the text control for two-step construction. Derived classes
386 should call or replace this function. See \helpref{wxTextCtrl::wxTextCtrl}{wxtextctrlconstr}\rtfsp
389 \membersection{wxTextCtrl::Cut}\label{wxtextctrlcut}
391 \func{virtual void}{Cut}{\void}
393 Copies the selected text to the clipboard and removes the selection.
395 \membersection{wxTextCtrl::DiscardEdits}
397 \func{void}{DiscardEdits}{\void}
399 Resets the internal `modified' flag as if the current edits had been saved.
401 \membersection{wxTextCtrl::EmulateKeyPress}
403 \func{bool}{EmulateKeyPress}{\param{const wxKeyEvent\& }{event}}
405 This functions inserts into the control the character which would have been
406 inserted if the given key event had occured in the text control. The
407 {\it event} object should be the same as the one passed to {\tt EVT\_KEY\_DOWN}
408 handler previously by wxWindows.
410 \wxheading{Return value}
412 {\tt TRUE} if the event resulted in a change to the control, {\tt FALSE}
415 \membersection{wxTextCtrl::GetDefaultStyle}\label{wxtextctrlgetdefaultstyle}
417 \constfunc{const wxTextAttr\& }{GetDefaultStyle}{\void}
419 Returns the style currently used for the new text.
423 \helpref{SetDefaultStyle}{wxtextctrlsetdefaultstyle}
425 \membersection{wxTextCtrl::GetInsertionPoint}\label{wxtextctrlgetinsertionpoint}
427 \constfunc{virtual long}{GetInsertionPoint}{\void}
429 Returns the insertion point. This is defined as the zero based index of the
430 character position to the right of the insertion point. For example, if
431 the insertion point is at the end of the text control, it is equal to
432 both \helpref{GetValue()}{wxtextctrlgetvalue}.Length() and
433 \helpref{GetLastPosition()}{wxtextctrlgetlastposition}.
435 The following code snippet safely returns the character at the insertion
436 point or the zero character if the point is at the end of the control.
440 char GetCurrentChar(wxTextCtrl *tc) {
441 if (tc->GetInsertionPoint() == tc->GetLastPosition())
443 return tc->GetValue[tc->GetInsertionPoint()];
448 \membersection{wxTextCtrl::GetLastPosition}\label{wxtextctrlgetlastposition}
450 \constfunc{virtual long}{GetLastPosition}{\void}
452 Returns the zero based index of the last position in the text control,
453 which is equal to the number of characters in the control.
455 \membersection{wxTextCtrl::GetLineLength}\label{wxtextctrlgetlinelength}
457 \constfunc{int}{GetLineLength}{\param{long}{ lineNo}}
459 Gets the length of the specified line, not including any trailing newline
462 \wxheading{Parameters}
464 \docparam{lineNo}{Line number (starting from zero).}
466 \wxheading{Return value}
468 The length of the line, or -1 if {\it lineNo} was invalid.
470 \membersection{wxTextCtrl::GetLineText}\label{wxtextctrlgetlinetext}
472 \constfunc{wxString}{GetLineText}{\param{long}{ lineNo}}
474 Returns the contents of a given line in the text control, not including
475 any trailing newline character(s).
477 \wxheading{Parameters}
479 \docparam{lineNo}{The line number, starting from zero.}
481 \wxheading{Return value}
483 The contents of the line.
485 \membersection{wxTextCtrl::GetNumberOfLines}\label{wxtextctrlgetnumberoflines}
487 \constfunc{int}{GetNumberOfLines}{\void}
489 Returns the number of lines in the text control buffer.
493 Note that even empty text controls have one line (where the insertion point
494 is), so GetNumberOfLines() never returns 0.
496 For gtk\_text (multi-line) controls, the number of lines is
497 calculated by actually counting newline characters in the buffer. You
498 may wish to avoid using functions that work with line numbers if you are
499 working with controls that contain large amounts of text.
501 \membersection{wxTextCtrl::GetRange}\label{wxtextctrlgetrange}
503 \constfunc{virtual wxString}{GetRange}{\param{long}{ from}, \param{long}{ to}}
505 Returns the string containing the text staring in the positions {\it from} and
506 up to {\it to} in the control. The positions must have been returned by another
509 Please note that the positions in a multiline wxTextCtrl do {\bf not}
510 correspond to the indices in the string returned by
511 \helpref{GetValue}{wxtextctrlgetvalue} because of the different new line
512 representations ({\tt CR} or {\tt CR LF}) and so this method should be used to
513 obtain the correct results instead of extracting parts of the entire value. It
514 may also be more efficient, especially if the control contains a lot of data.
516 \membersection{wxTextCtrl::GetSelection}\label{wxtextctrlgetselection}
518 \constfunc{virtual void}{GetSelection}{\param{long*}{ from}, \param{long*}{ to}}
520 Gets the current selection span. If the returned values are equal, there was
523 Please note that the indices returned may be used with the other wxTextctrl
524 methods but don't necessarily represent the correct indices into the string
525 returned by \helpref{GetValue()}{wxtextctrlgetvalue} for multiline controls
526 under Windows (at least,) you should use
527 \helpref{GetStringSelection()}{wxtextctrlgetstringselection} to get the selected
530 \wxheading{Parameters}
532 \docparam{from}{The returned first position.}
534 \docparam{to}{The returned last position.}
536 \pythonnote{The wxPython version of this method returns a tuple
537 consisting of the from and to values.}
539 \perlnote{In wxPerl this method takes no parameter and returns a
540 2-element list {\tt ( from, to )}.}
542 \membersection{wxTextCtrl::GetStringSelection}\label{wxtextctrlgetstringselection}
544 \func{virtual wxString}{GetStringSelection}{\void}
546 Gets the text currently selected in the control. If there is no selection, the
547 returned string is empty.
549 \membersection{wxTextCtrl::GetValue}\label{wxtextctrlgetvalue}
551 \constfunc{wxString}{GetValue}{\void}
553 Gets the contents of the control. Notice that for a multiline text control,
554 the lines will be separated by (Unix-style) $\backslash$n characters, even under
555 Windows where they are separated by a $\backslash$r$\backslash$n sequence in the native control.
557 \membersection{wxTextCtrl::IsEditable}\label{wxtextctrliseditable}
559 \constfunc{bool}{IsEditable}{\void}
561 Returns {\tt TRUE} if the controls contents may be edited by user (note that it
562 always can be changed by the program), i.e. if the control hasn't been put in
563 read-only mode by a previous call to
564 \helpref{SetEditable}{wxtextctrlseteditable}.
566 \membersection{wxTextCtrl::IsModified}\label{wxtextctrlismodified}
568 \constfunc{bool}{IsModified}{\void}
570 Returns {\tt TRUE} if the text has been modified by user. Note that calling
571 \helpref{SetValue}{wxtextctrlsetvalue} doesn't make the control modified.
573 \membersection{wxTextCtrl::IsMultiLine}\label{wxtextctrlismultiline}
575 \constfunc{bool}{IsMultiLine}{\void}
577 Returns {\tt TRUE} if this is a multi line edit control and {\tt FALSE}
582 \helpref{IsSingleLine}{wxtextctrlissingleline}
584 \membersection{wxTextCtrl::IsSingleLine}\label{wxtextctrlissingleline}
586 \constfunc{bool}{IsSingleLine}{\void}
588 Returns {\tt TRUE} if this is a single line edit control and {\tt FALSE}
593 \helpref{IsMultiLine}{wxtextctrlissingleline}
595 \membersection{wxTextCtrl::LoadFile}\label{wxtextctrlloadfile}
597 \func{bool}{LoadFile}{\param{const wxString\& }{ filename}}
599 Loads and displays the named file, if it exists.
601 \wxheading{Parameters}
603 \docparam{filename}{The filename of the file to load.}
605 \wxheading{Return value}
607 {\tt TRUE} if successful, {\tt FALSE} otherwise.
609 % VZ: commenting this out as: (a) the docs are wrong (you can't replace
610 % anything), (b) wxTextCtrl doesn't have any OnChar() anyhow
611 %% \membersection{wxTextCtrl::OnChar}\label{wxtextctrlonchar}
613 %% \func{void}{OnChar}{\param{wxKeyEvent\& }{event}}
615 %% Default handler for character input.
617 %% \wxheading{Remarks}
619 %% It is possible to intercept character
620 %% input by overriding this member. Call this function
621 %% to let the default behaviour take place; not calling
622 %% it results in the character being ignored. You can
623 %% replace the {\it keyCode} member of {\it event} to
624 %% translate keystrokes.
626 %% Note that Windows and Motif have different ways
627 %% of implementing the default behaviour. In Windows,
628 %% calling wxTextCtrl::OnChar immediately
629 %% processes the character. In Motif,
630 %% calling this function simply sets a flag
631 %% to let default processing happen. This might affect
632 %% the way in which you write your OnChar function
633 %% on different platforms.
635 %% \wxheading{See also}
637 %% \helpref{wxKeyEvent}{wxkeyevent}
639 \membersection{wxTextCtrl::OnDropFiles}\label{wxtextctrlondropfiles}
641 \func{void}{OnDropFiles}{\param{wxDropFilesEvent\& }{event}}
643 This event handler function implements default drag and drop behaviour, which
644 is to load the first dropped file into the control.
646 \wxheading{Parameters}
648 \docparam{event}{The drop files event.}
652 This is not implemented on non-Windows platforms.
656 \helpref{wxDropFilesEvent}{wxdropfilesevent}
658 \membersection{wxTextCtrl::Paste}\label{wxtextctrlpaste}
660 \func{virtual void}{Paste}{\void}
662 Pastes text from the clipboard to the text item.
664 \membersection{wxTextCtrl::PositionToXY}\label{wxtextctrlpositiontoxy}
666 \constfunc{bool}{PositionToXY}{\param{long }{pos}, \param{long *}{x}, \param{long *}{y}}
668 Converts given position to a zero-based column, line number pair.
670 \wxheading{Parameters}
672 \docparam{pos}{Position.}
674 \docparam{x}{Receives zero based column number.}
676 \docparam{y}{Receives zero based line number.}
678 \wxheading{Return value}
680 {\tt TRUE} on success, {\tt FALSE} on failure (most likely due to a too large position
685 \helpref{wxTextCtrl::XYToPosition}{wxtextctrlxytoposition}
687 \pythonnote{In Python, PositionToXY() returns a tuple containing the x and
688 y values, so (x,y) = PositionToXY() is equivalent to the call described
691 \perlnote{In wxPerl this method only takes the {\tt pos} parameter, and
692 returns a 2-element list {\tt ( x, y )}.}
694 \membersection{wxTextCtrl::Redo}\label{wxtextctrlredo}
696 \func{virtual void}{Redo}{\void}
698 If there is a redo facility and the last operation can be redone, redoes the last operation. Does nothing
699 if there is no redo facility.
701 \membersection{wxTextCtrl::Remove}\label{wxtextctrlremove}
703 \func{virtual void}{Remove}{\param{long}{ from}, \param{long}{ to}}
705 Removes the text starting at the first given position up to (but not including)
706 the character at the last position.
708 \wxheading{Parameters}
710 \docparam{from}{The first position.}
712 \docparam{to}{The last position.}
714 \membersection{wxTextCtrl::Replace}\label{wxtextctrlreplace}
716 \func{virtual void}{Replace}{\param{long}{ from}, \param{long}{ to}, \param{const wxString\& }{value}}
718 Replaces the text starting at the first position up to (but not including)
719 the character at the last position with the given text.
721 \wxheading{Parameters}
723 \docparam{from}{The first position.}
725 \docparam{to}{The last position.}
727 \docparam{value}{The value to replace the existing text with.}
729 \membersection{wxTextCtrl::SaveFile}\label{wxtextctrlsavefile}
731 \func{bool}{SaveFile}{\param{const wxString\& }{ filename}}
733 Saves the contents of the control in a text file.
735 \wxheading{Parameters}
737 \docparam{filename}{The name of the file in which to save the text.}
739 \wxheading{Return value}
741 {\tt TRUE} if the operation was successful, {\tt FALSE} otherwise.
743 \membersection{wxTextCtrl::SetDefaultStyle}\label{wxtextctrlsetdefaultstyle}
745 \func{bool}{SetDefaultStyle}{\param{const wxTextAttr\& }{style}}
747 Changes the default style to use for the new text which is going to be added
748 to the control using \helpref{WriteText}{wxtextctrlwritetext} or\rtfsp
749 \helpref{AppendText}{wxtextctrlappendtext}.
751 If either of the font, foreground, or background colour is not set in\rtfsp
752 {\it style}, the values of the previous default style are used for them. If
753 the previous default style didn't set them neither, the global font or colours
754 of the text control itself are used as fall back.
756 However if the {\it style} parameter is the default wxTextAttr, then the
757 default style is just reset (instead of being combined with the new style which
758 wouldn't change it at all).
760 \wxheading{Parameters}
762 \docparam{style}{The style for the new text.}
764 \wxheading{Return value}
766 {\tt TRUE} on success, {\tt FALSE} if an error occured - may also mean that
767 the styles are not supported under this platform.
771 \helpref{GetDefaultStyle}{wxtextctrlgetdefaultstyle}
773 \membersection{wxTextCtrl::SetEditable}\label{wxtextctrlseteditable}
775 \func{virtual void}{SetEditable}{\param{const bool}{ editable}}
777 Makes the text item editable or read-only, overriding the {\bf wxTE\_READONLY} flag.
779 \wxheading{Parameters}
781 \docparam{editable}{If {\tt TRUE}, the control is editable. If {\tt FALSE}, the control is read-only.}
785 \helpref{IsEditable}{wxtextctrliseditable}
787 \membersection{wxTextCtrl::SetInsertionPoint}\label{wxtextctrlsetinsertionpoint}
789 \func{virtual void}{SetInsertionPoint}{\param{long}{ pos}}
791 Sets the insertion point at the given position.
793 \wxheading{Parameters}
795 \docparam{pos}{Position to set.}
797 \membersection{wxTextCtrl::SetInsertionPointEnd}\label{wxtextctrlsetinsertionpointend}
799 \func{virtual void}{SetInsertionPointEnd}{\void}
801 Sets the insertion point at the end of the text control. This is equivalent
802 to \helpref{SetInsertionPoint}{wxtextctrlsetinsertionpoint}(\helpref{GetLastPosition}{wxtextctrlgetlastposition}()).
804 \membersection{wxTextCtrl::SetMaxLength}\label{wxtextctrlsetmaxlength}
806 \func{virtual void}{SetMaxLength}{\param{unsigned long }{len}}
808 This function sets the maximum number of characters the user can enter into the
809 control. In other words, it allows to limit the text value length to {\it len}
810 not counting the terminating {\tt NUL} character.
812 If {\it len} is $0$, the previously set max length limit, if any, is discarded
813 and the user may enter as much text as the underlying native text control
814 widget supports (typically at least 32Kb).
816 If the user tries to enter more characters into the text control when it
817 already is filled up to the maximal length, a
818 {\tt wxEVT\_COMMAND\_TEXT\_MAXLEN} event is sent to notify the program about it
819 (giving it the possibility to show an explanatory message, for example) and the
820 extra input is discarded.
822 Note that this function may only be used with single line text controls.
824 \wxheading{Compatibility}
826 Only implemented in wxMSW/wxGTK starting with wxWindows 2.3.2.
828 \membersection{wxTextCtrl::SetSelection}\label{wxtextctrlsetselection}
830 \func{virtual void}{SetSelection}{\param{long}{ from}, \param{long}{ to}}
832 Selects the text starting at the first position up to (but not including) the character at the last position.
834 \wxheading{Parameters}
836 \docparam{from}{The first position.}
838 \docparam{to}{The last position.}
840 \membersection{wxTextCtrl::SetStyle}\label{wxtextctrlsetstyle}
842 \func{bool}{SetStyle}{\param{long }{start}, \param{long }{end}, \param{const wxTextAttr\& }{style}}
844 Changes the style of the selection. If either of the font, foreground, or
845 background colour is not set in {\it style}, the values of\rtfsp
846 \helpref{GetDefaultStyle()}{wxtextctrlgetdefaultstyle} are used.
848 \wxheading{Parameters}
850 \docparam{start}{The start of selection to change.}
852 \docparam{end}{The end of selection to change.}
854 \docparam{style}{The new style for the selection.}
856 \wxheading{Return value}
858 {\tt TRUE} on success, {\tt FALSE} if an error occured - may also mean that
859 the styles are not supported under this platform.
861 \membersection{wxTextCtrl::SetValue}\label{wxtextctrlsetvalue}
863 \func{virtual void}{SetValue}{\param{const wxString\& }{ value}}
865 Sets the text value and marks the control as not-modified (which means that
866 \helpref{IsModified}{wxtextctrlismodified} would return {\tt FALSE} immediately
867 after the call to SetValue).
869 Note that this function will generate a {\tt wxEVT\_COMMAND\_TEXT\_UPDATED}
872 \wxheading{Parameters}
874 \docparam{value}{The new value to set. It may contain newline characters if the text control is multi-line.}
876 \membersection{wxTextCtrl::ShowPosition}\label{wxtextctrlshowposition}
878 \func{void}{ShowPosition}{\param{long}{ pos}}
880 Makes the line containing the given position visible.
882 \wxheading{Parameters}
884 \docparam{pos}{The position that should be visible.}
886 \membersection{wxTextCtrl::Undo}\label{wxtextctrlundo}
888 \func{virtual void}{Undo}{\void}
890 If there is an undo facility and the last operation can be undone, undoes the last operation. Does nothing
891 if there is no undo facility.
893 \membersection{wxTextCtrl::WriteText}\label{wxtextctrlwritetext}
895 \func{void}{WriteText}{\param{const wxString\& }{ text}}
897 Writes the text into the text control at the current insertion position.
899 \wxheading{Parameters}
901 \docparam{text}{Text to write to the text control.}
905 Newlines in the text string
906 are the only control characters allowed, and they will cause appropriate
907 line breaks. See \helpref{wxTextCtrl::\cinsert}{wxtextctrlinsert} and \helpref{wxTextCtrl::AppendText}{wxtextctrlappendtext} for more convenient ways of writing to the window.
909 After the write operation, the insertion point will be at the end of the inserted text, so subsequent write operations will be appended. To append text after the user may have interacted with the control, call \helpref{wxTextCtrl::SetInsertionPointEnd}{wxtextctrlsetinsertionpointend} before writing.
911 \membersection{wxTextCtrl::XYToPosition}\label{wxtextctrlxytoposition}
913 \func{long}{XYToPosition}{\param{long}{ x}, \param{long}{ y}}
915 Converts the given zero based column and line number to a position.
917 \wxheading{Parameters}
919 \docparam{x}{The column number.}
921 \docparam{y}{The line number.}
923 \wxheading{Return value}
927 \membersection{wxTextCtrl::operator \cinsert}\label{wxtextctrlinsert}
929 \func{wxTextCtrl\&}{operator \cinsert}{\param{const wxString\& }{s}}
931 \func{wxTextCtrl\&}{operator \cinsert}{\param{int}{ i}}
933 \func{wxTextCtrl\&}{operator \cinsert}{\param{long}{ i}}
935 \func{wxTextCtrl\&}{operator \cinsert}{\param{float}{ f}}
937 \func{wxTextCtrl\&}{operator \cinsert}{\param{double}{ d}}
939 \func{wxTextCtrl\&}{operator \cinsert}{\param{char}{ c}}
941 Operator definitions for appending to a text control, for example:
944 wxTextCtrl *wnd = new wxTextCtrl(my_frame);
946 (*wnd) << "Welcome to text control number " << 1 << ".\n";