1 %%%%%%%%%%%%%%%%%%%%%%%%%%%% wxTextCtrl %%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
3 \section{\class{wxTextCtrl
}}\label{wxtextctrl
}
5 A text control allows text to be displayed and edited. It may be
6 single line or multi-line.
8 \wxheading{Derived from
}
11 \helpref{wxControl
}{wxcontrol
}\\
12 \helpref{wxWindow
}{wxwindow
}\\
13 \helpref{wxEvtHandler
}{wxevthandler
}\\
14 \helpref{wxObject
}{wxobject
}
16 \wxheading{Include files
}
20 \wxheading{Window styles
}
23 \begin{twocollist
}\itemsep=
0pt
24 \twocolitem{\windowstyle{wxTE
\_PROCESS\_ENTER}}{The control will generate
25 the event wxEVT
\_COMMAND\_TEXT\_ENTER (otherwise pressing Enter key
26 is either processed internally by the control or used for navigation between
28 \twocolitem{\windowstyle{wxTE
\_PROCESS\_TAB}}{The control will receive
29 wxEVT
\_CHAR events for TAB pressed - normally, TAB is used for passing to the
30 next control in a dialog instead. For the control created with this style,
31 you can still use Ctrl-Enter to pass to the next control from the keyboard.
}
32 \twocolitem{\windowstyle{wxTE
\_MULTILINE}}{The text control allows multiple lines.
}
33 \twocolitem{\windowstyle{wxTE
\_PASSWORD}}{The text will be echoed as asterisks.
}
34 \twocolitem{\windowstyle{wxTE
\_READONLY}}{The text will not be user-editable.
}
35 \twocolitem{\windowstyle{wxTE
\_RICH}}{Use rich text control under Win32, this
36 allows to have more than
64KB of text in the control even under Win9x. This
37 style is ignored under other platforms.
}
38 \twocolitem{\windowstyle{wxTE
\_RICH2}}{Use rich text control version
2.0 or
3.0
39 under Win32, this style is ignored under other platforms
}
40 \twocolitem{\windowstyle{wxTE
\_AUTO\_URL}}{Highlight the URLs and generate the
41 wxTextUrlEvents when mouse events occur over them. This style is only supported
42 for wxTE
\_RICH Win32 and multi-line wxGTK2 text controls.
}
43 \twocolitem{\windowstyle{wxTE
\_NOHIDESEL}}{By default, the Windows text control
44 doesn't show the selection when it doesn't have focus - use this style to force
45 it to always show it. It doesn't do anything under other platforms.
}
46 \twocolitem{\windowstyle{wxHSCROLL
}}{A horizontal scrollbar will be created and
47 used, so that text won't be wrapped. No effect under wxGTK1.
}
48 \twocolitem{\windowstyle{wxTE
\_LEFT}}{The text in the control will be left-justified (default).
}
49 \twocolitem{\windowstyle{wxTE
\_CENTRE}}{The text in the control will be centered (currently wxMSW and wxGTK2 only).
}
50 \twocolitem{\windowstyle{wxTE
\_RIGHT}}{The text in the control will be right-justified (currently wxMSW and wxGTK2 only).
}
51 \twocolitem{\windowstyle{wxTE
\_DONTWRAP}}{Same as
{\tt wxHSCROLL
} style: don't wrap at all, show horizontal scrollbar instead.
}
52 \twocolitem{\windowstyle{wxTE
\_CHARWRAP}}{Wrap the lines too long to be shown entirely at any position (wxUniv and wxGTK2 only).
}
53 \twocolitem{\windowstyle{wxTE
\_WORDWRAP}}{Wrap the lines too long to be shown entirely at word boundaries (wxUniv and wxGTK2 only).
}
54 \twocolitem{\windowstyle{wxTE
\_BESTWRAP}}{Wrap the lines at word boundaries or at any other character if there are words longer than the window width (this is the default).
}
55 \twocolitem{\windowstyle{wxTE
\_CAPITALIZE}}{On PocketPC and Smartphone, causes the first letter to be capitalized.
}
58 See also
\helpref{window styles overview
}{windowstyles
} and
\helpref{wxTextCtrl::wxTextCtrl
}{wxtextctrlctor
}.
60 \wxheading{wxTextCtrl text format
}
62 The multiline text controls always store the text as a sequence of lines
63 separated by
{\tt $
\backslash$n
} characters, i.e. in the Unix text format even
64 on non-Unix platforms. This allows the user code to ignore the differences
65 between the platforms but at a price: the indices in the control such as those
66 returned by
\helpref{GetInsertionPoint
}{wxtextctrlgetinsertionpoint
} or
67 \helpref{GetSelection
}{wxtextctrlgetselection
} can
{\bf not
} be used as
68 indices into the string returned by
\helpref{GetValue
}{wxtextctrlgetvalue
} as
69 they're going to be slightly off for platforms using
70 {\tt $
\backslash$r$
\backslash$n
} as separator (as Windows does), for example.
72 Instead, if you need to obtain a substring between the $
2$ indices obtained
73 from the control with the help of the functions mentioned above, you should
74 use
\helpref{GetRange
}{wxtextctrlgetrange
}. And the indices themselves can
75 only be passed to other methods, for example
76 \helpref{SetInsertionPoint
}{wxtextctrlsetinsertionpoint
} or
77 \helpref{SetSelection
}{wxtextctrlsetselection
}.
79 To summarize: never use the indices returned by (multiline) wxTextCtrl as
80 indices into the string it contains, but only as arguments to be passed back
81 to the other wxTextCtrl methods.
83 \wxheading{wxTextCtrl styles
}
85 Multi-line text controls support the styles, i.e. provide a possibility to set
86 colours and font for individual characters in it (note that under Windows
{\tt
87 wxTE
\_RICH} style is required for style support). To use the styles you can
88 either call
\helpref{SetDefaultStyle
}{wxtextctrlsetdefaultstyle
} before
89 inserting the text or call
\helpref{SetStyle
}{wxtextctrlsetstyle
} later to
90 change the style of the text already in the control (the first solution is
93 In either case, if the style doesn't specify some of the attributes (for
94 example you only want to set the text colour but without changing the font nor
95 the text background), the values of the default style will be used for them.
96 If there is no default style, the attributes of the text control itself are
99 So the following code correctly describes what it does: the second call
100 to
\helpref{SetDefaultStyle
}{wxtextctrlsetdefaultstyle
} doesn't change the
101 text foreground colour (which stays red) while the last one doesn't change the
102 background colour (which stays grey):
106 text->SetDefaultStyle(wxTextAttr
(*wxRED));
107 text->AppendText("Red text\n");
108 text->SetDefaultStyle(wxTextAttr(wxNullColour, *wxLIGHT_GREY));
109 text->AppendText("Red on grey text\n");
110 text->SetDefaultStyle(wxTextAttr(*wxBLUE);
111 text->AppendText("Blue on grey text\n");
115 \wxheading{wxTextCtrl and C++ streams}
117 This class multiply-inherits from {\bf streambuf} where compilers allow,
118 allowing code such as the following:
122 wxTextCtrl *control = new wxTextCtrl(...);
124 ostream stream(control)
126 stream << 123.456 << " some text\n";
131 If your compiler does not support derivation from {\bf streambuf} and gives a
132 compile error, define the symbol {\bf NO\_TEXT\_WINDOW\_STREAM} in the
133 wxTextCtrl header file.
135 Note that independently of this setting you can always use wxTextCtrl itself
136 in a stream-like manner:
140 wxTextCtrl *control = new wxTextCtrl(...);
142 *control << 123.456 << " some text\n";
146 always works. However the possibility to create an ostream associated with
147 wxTextCtrl may be useful if you need to redirect the output of a function
148 taking an ostream as parameter to a text control.
150 Another commonly requested need is to redirect {\bf std::cout} to the text
151 control. This could be done in the following way:
157 wxTextCtrl *control = new wxTextCtrl(...);
159 std::streambuf *sbOld = std::cout.rdbuf();
160 std::cout.rdbuf(*control);
162 // use cout as usual, the output appears in the text control
165 std::cout.rdbuf(sbOld);
169 But wxWidgets provides a convenient class to make it even simpler so instead
176 wxTextCtrl *control = new wxTextCtrl(...);
178 wxStreamToTextRedirector redirect(control);
180 // all output to cout goes into the text control until the exit from current
185 See \helpref{wxStreamToTextRedirector}{wxstreamtotextredirector} for more
188 \wxheading{Constants}
190 The values below are the possible return codes of the
191 \helpref{HitTest}{wxtextctrlhittest} method:
195 // the point asked is ...
196 enum wxTextCtrlHitTestResult
198 wxTE_HT_UNKNOWN = -2, // this means HitTest() is simply not implemented
199 wxTE_HT_BEFORE, // either to the left or upper
200 wxTE_HT_ON_TEXT, // directly on
201 wxTE_HT_BELOW, // below [the last line]
202 wxTE_HT_BEYOND // after [the end of line]
204 // ... the character returned
209 \wxheading{Event handling}
211 The following commands are processed by default event handlers in wxTextCtrl: wxID\_CUT, wxID\_COPY,
212 wxID\_PASTE, wxID\_UNDO, wxID\_REDO. The associated UI update events are also processed
213 automatically, when the control has the focus.
215 To process input from a text control, use these event handler macros to direct input to member
216 functions that take a \helpref{wxCommandEvent}{wxcommandevent} argument.
219 \begin{twocollist}\itemsep=0pt
220 \twocolitem{{\bf EVT\_TEXT(id, func)}}{Respond to a wxEVT\_COMMAND\_TEXT\_UPDATED event,
221 generated when the text changes. Notice that this event will be sent
222 when the text controls contents changes - whether this is due to user input or
223 comes from the program itself (for example, if SetValue() is called); see ChangeValue() for
224 a function which does not send this event.}
225 \twocolitem{{\bf EVT\_TEXT\_ENTER(id, func)}}{Respond to a wxEVT\_COMMAND\_TEXT\_ENTER event,
226 generated when enter is pressed in a text control (which must have
227 wxTE\_PROCESS\_ENTER style for this event to be generated).}
228 \twocolitem{{\bf EVT\_TEXT\_URL(id, func)}}{A mouse event occurred over an URL
229 in the text control (wxMSW and wxGTK2 only)}
230 \twocolitem{{\bf EVT\_TEXT\_MAXLEN(id, func)}}{User tried to enter more text
231 into the control than the limit set by
232 \helpref{SetMaxLength}{wxtextctrlsetmaxlength}.}
235 \latexignore{\rtfignore{\wxheading{Members}}}
238 \membersection{wxTextCtrl::wxTextCtrl}\label{wxtextctrlctor}
240 \func{}{wxTextCtrl}{\void}
244 \func{}{wxTextCtrl}{\param{wxWindow* }{parent}, \param{wxWindowID}{ id},\rtfsp
245 \param{const wxString\& }{value = ``"}, \param{const wxPoint\& }{pos = wxDefaultPosition}, \param{const wxSize\& }{size = wxDefaultSize},\rtfsp
246 \param{long}{ style = 0}, \param{const wxValidator\& }{validator = wxDefaultValidator}, \param{const wxString\& }{name = wxTextCtrlNameStr}}
248 Constructor, creating and showing a text control.
250 \wxheading{Parameters}
252 \docparam{parent}{Parent window. Should not be NULL.}
254 \docparam{id}{Control identifier. A value of -1 denotes a default value.}
256 \docparam{value}{Default text value.}
258 \docparam{pos}{Text control position.}
260 \docparam{size}{Text control size.}
262 \docparam{style}{Window style. See \helpref{wxTextCtrl}{wxtextctrl}.}
264 \docparam{validator}{Window validator.}
266 \docparam{name}{Window name.}
270 The horizontal scrollbar ({\bf wxHSCROLL} style flag) will only be created
271 for multi-line text controls.
272 Without a horizontal scrollbar, text lines that don't fit in the control's
273 size will be wrapped (but no newline character is inserted). Single line
274 controls don't have a horizontal scrollbar, the text is automatically scrolled
275 so that the \helpref{insertion point}{wxtextctrlgetinsertionpoint} is always
278 % VZ: this is no longer true
279 %Under Windows, if the {\bf wxTE\_MULTILINE} style is used, the window is implemented
280 %as a Windows rich text control with unlimited capacity. Otherwise, normal edit control limits
285 \helpref{wxTextCtrl::Create}{wxtextctrlcreate}, \helpref{wxValidator}{wxvalidator}
288 \membersection{wxTextCtrl::\destruct{wxTextCtrl}}\label{wxtextctrldtor}
290 \func{}{\destruct{wxTextCtrl}}{\void}
292 Destructor, destroying the text control.
295 \membersection{wxTextCtrl::AppendText}\label{wxtextctrlappendtext}
297 \func{void}{AppendText}{\param{const wxString\& }{ text}}
299 Appends the text to the end of the text control.
301 \wxheading{Parameters}
303 \docparam{text}{Text to write to the text control.}
307 After the text is appended, the insertion point will be at the end of the text control. If this behaviour is not desired,
308 the programmer should use \helpref{GetInsertionPoint}{wxtextctrlgetinsertionpoint} and \helpref{SetInsertionPoint}{wxtextctrlsetinsertionpoint}.
312 \helpref{wxTextCtrl::WriteText}{wxtextctrlwritetext}
315 \membersection{wxTextCtrl::CanCopy}\label{wxtextctrlcancopy}
317 \func{virtual bool}{CanCopy}{\void}
319 Returns {\tt true} if the selection can be copied to the clipboard.
322 \membersection{wxTextCtrl::CanCut}\label{wxtextctrlcancut}
324 \func{virtual bool}{CanCut}{\void}
326 Returns {\tt true} if the selection can be cut to the clipboard.
329 \membersection{wxTextCtrl::CanPaste}\label{wxtextctrlcanpaste}
331 \func{virtual bool}{CanPaste}{\void}
333 Returns {\tt true} if the contents of the clipboard can be pasted into the
334 text control. On some platforms (Motif, GTK) this is an approximation
335 and returns {\tt true} if the control is editable, {\tt false} otherwise.
338 \membersection{wxTextCtrl::CanRedo}\label{wxtextctrlcanredo}
340 \func{virtual bool}{CanRedo}{\void}
342 Returns {\tt true} if there is a redo facility available and the last operation
346 \membersection{wxTextCtrl::CanUndo}\label{wxtextctrlcanundo}
348 \func{virtual bool}{CanUndo}{\void}
350 Returns {\tt true} if there is an undo facility available and the last operation
354 \membersection{wxTextCtrl::Clear}\label{wxtextctrlclear}
356 \func{virtual void}{Clear}{\void}
358 Clears the text in the control.
360 Note that this function will generate a {\tt wxEVT\_COMMAND\_TEXT\_UPDATED}
364 \membersection{wxTextCtrl::Copy}\label{wxtextctrlcopy}
366 \func{virtual void}{Copy}{\void}
368 Copies the selected text to the clipboard under Motif and MS Windows.
371 \membersection{wxTextCtrl::Create}\label{wxtextctrlcreate}
373 \func{bool}{Create}{\param{wxWindow* }{parent}, \param{wxWindowID}{ id},\rtfsp
374 \param{const wxString\& }{value = ``"}, \param{const wxPoint\& }{pos = wxDefaultPosition}, \param{const wxSize\& }{size = wxDefaultSize},\rtfsp
375 \param{long}{ style = 0}, \param{const wxValidator\& }{validator = wxDefaultValidator}, \param{const wxString\& }{name = wxTextCtrlNameStr}}
377 Creates the text control for two-step construction. Derived classes
378 should call or replace this function. See \helpref{wxTextCtrl::wxTextCtrl}{wxtextctrlctor}\rtfsp
382 \membersection{wxTextCtrl::Cut}\label{wxtextctrlcut}
384 \func{virtual void}{Cut}{\void}
386 Copies the selected text to the clipboard and removes the selection.
389 \membersection{wxTextCtrl::DiscardEdits}\label{wxtextctrldiscardedits}
391 \func{void}{DiscardEdits}{\void}
393 Resets the internal `modified' flag as if the current edits had been saved.
396 \membersection{wxTextCtrl::EmulateKeyPress}\label{wxtextctrlemulatekeypress}
398 \func{bool}{EmulateKeyPress}{\param{const wxKeyEvent\& }{event}}
400 This functions inserts into the control the character which would have been
401 inserted if the given key event had occurred in the text control. The
402 {\it event} object should be the same as the one passed to {\tt EVT\_KEY\_DOWN}
403 handler previously by wxWidgets.
405 Please note that this function doesn't currently work correctly for all keys
406 under any platform but MSW.
408 \wxheading{Return value}
410 {\tt true} if the event resulted in a change to the control, {\tt false}
414 \membersection{wxTextCtrl::GetDefaultStyle}\label{wxtextctrlgetdefaultstyle}
416 \constfunc{const wxTextAttr\& }{GetDefaultStyle}{\void}
418 Returns the style currently used for the new text.
422 \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()];
449 \membersection{wxTextCtrl::GetLastPosition}\label{wxtextctrlgetlastposition}
451 \constfunc{virtual wxTextPos}{GetLastPosition}{\void}
453 Returns the zero based index of the last position in the text control,
454 which is equal to the number of characters in the control.
457 \membersection{wxTextCtrl::GetLineLength}\label{wxtextctrlgetlinelength}
459 \constfunc{int}{GetLineLength}{\param{long}{ lineNo}}
461 Gets the length of the specified line, not including any trailing newline
464 \wxheading{Parameters}
466 \docparam{lineNo}{Line number (starting from zero).}
468 \wxheading{Return value}
470 The length of the line, or -1 if {\it lineNo} was invalid.
473 \membersection{wxTextCtrl::GetLineText}\label{wxtextctrlgetlinetext}
475 \constfunc{wxString}{GetLineText}{\param{long}{ lineNo}}
477 Returns the contents of a given line in the text control, not including
478 any trailing newline character(s).
480 \wxheading{Parameters}
482 \docparam{lineNo}{The line number, starting from zero.}
484 \wxheading{Return value}
486 The contents of the line.
489 \membersection{wxTextCtrl::GetNumberOfLines}\label{wxtextctrlgetnumberoflines}
491 \constfunc{int}{GetNumberOfLines}{\void}
493 Returns the number of lines in the text control buffer.
497 Note that even empty text controls have one line (where the insertion point
498 is), so GetNumberOfLines() never returns $0$.
500 For wxGTK using GTK+ 1.2.x and earlier, the number of lines in a multi-line
501 text control is calculated by actually counting newline characters in the
502 buffer, i.e. this function returns the number of logical lines and doesn't
503 depend on whether any of them are wrapped. For all the other platforms, the
504 number of physical lines in the control is returned.
506 Also note that you may wish to avoid using functions that work with line
507 numbers if you are working with controls that contain large amounts of text as
508 this function has $O(N)$ complexity for $N$ being the number of lines.
511 \membersection{wxTextCtrl::GetRange}\label{wxtextctrlgetrange}
513 \constfunc{virtual wxString}{GetRange}{\param{long}{ from}, \param{long}{ to}}
515 Returns the string containing the text starting in the positions {\it from} and
516 up to {\it to} in the control. The positions must have been returned by another
519 Please note that the positions in a multiline wxTextCtrl do {\bf not}
520 correspond to the indices in the string returned by
521 \helpref{GetValue}{wxtextctrlgetvalue} because of the different new line
522 representations ({\tt CR} or {\tt CR LF}) and so this method should be used to
523 obtain the correct results instead of extracting parts of the entire value. It
524 may also be more efficient, especially if the control contains a lot of data.
527 \membersection{wxTextCtrl::GetSelection}\label{wxtextctrlgetselection}
529 \constfunc{virtual void}{GetSelection}{\param{long*}{ from}, \param{long*}{ to}}
531 Gets the current selection span. If the returned values are equal, there was
534 Please note that the indices returned may be used with the other wxTextctrl
535 methods but don't necessarily represent the correct indices into the string
536 returned by \helpref{GetValue()}{wxtextctrlgetvalue} for multiline controls
537 under Windows (at least,) you should use
538 \helpref{GetStringSelection()}{wxtextctrlgetstringselection} to get the selected
541 \wxheading{Parameters}
543 \docparam{from}{The returned first position.}
545 \docparam{to}{The returned last position.}
547 \pythonnote{The wxPython version of this method returns a tuple
548 consisting of the from and to values.}
550 \perlnote{In wxPerl this method takes no parameter and returns a
551 2-element list {\tt ( from, to )}.}
554 \membersection{wxTextCtrl::GetStringSelection}\label{wxtextctrlgetstringselection}
556 \func{virtual wxString}{GetStringSelection}{\void}
558 Gets the text currently selected in the control. If there is no selection, the
559 returned string is empty.
562 \membersection{wxTextCtrl::GetStyle}\label{wxtextctrlgetstyle}
564 \func{bool}{GetStyle}{\param{long }{position}, \param{wxTextAttr\& }{style}}
566 Returns the style at this position in the text control. Not all platforms
567 support this function.
569 \wxheading{Return value}
571 {\tt true} on success, {\tt false} if an error occurred - it may also mean that
572 the styles are not supported under this platform.
576 \helpref{wxTextCtrl::SetStyle}{wxtextctrlsetstyle}, \helpref{wxTextAttr}{wxtextattr}
579 \membersection{wxTextCtrl::GetValue}\label{wxtextctrlgetvalue}
581 \constfunc{wxString}{GetValue}{\void}
583 Gets the contents of the control. Notice that for a multiline text control,
584 the lines will be separated by (Unix-style) $\backslash$n characters, even
585 under Windows where they are separated by a $\backslash$r$\backslash$n
586 sequence in the native control.
589 \membersection{wxTextCtrl::HitTest}\label{wxtextctrlhittest}
591 \constfunc{wxTextCtrlHitTestResult}{HitTest}{\param{const wxPoint\& }{pt}, \param{wxTextCoord }{*col}, \param{wxTextCoord }{*row}}
593 This function finds the character at the specified position expressed in
594 pixels. If the return code is not \texttt{wxTE\_HT\_UNKNOWN} the row and column
595 of the character closest to this position are returned in the \arg{col} and
596 \arg{row} parameters (unless the pointers are {\tt NULL} which is allowed).
598 Please note that this function is currently only implemented in wxUniv,
599 wxMSW and wxGTK2 ports.
603 \helpref{PositionToXY}{wxtextctrlpositiontoxy}, \helpref{XYToPosition}{wxtextctrlxytoposition}
605 \perlnote{In wxPerl this function takes only the position argument and
606 returns a 3-element list \texttt{(result, col, row)}}.
609 \membersection{wxTextCtrl::IsEditable}\label{wxtextctrliseditable}
611 \constfunc{bool}{IsEditable}{\void}
613 Returns {\tt true} if the controls contents may be edited by user (note that it
614 always can be changed by the program), i.e. if the control hasn't been put in
615 read-only mode by a previous call to
616 \helpref{SetEditable}{wxtextctrlseteditable}.
619 \membersection{wxTextCtrl::IsEmpty}\label{wxtextctrlisempty}
621 \constfunc{bool}{IsEmpty}{\void}
623 Returns \true if the control is currently empty. This is the same as
624 \texttt{GetValue().empty()} but can be much more efficient for the multiline
625 controls containing big amounts of text.
630 \membersection{wxTextCtrl::IsModified}\label{wxtextctrlismodified}
632 \constfunc{bool}{IsModified}{\void}
634 Returns {\tt true} if the text has been modified by user. Note that calling
635 \helpref{SetValue}{wxtextctrlsetvalue} doesn't make the control modified.
639 \helpref{MarkDirty}{wxtextctrlmarkdirty}
642 \membersection{wxTextCtrl::IsMultiLine}\label{wxtextctrlismultiline}
644 \constfunc{bool}{IsMultiLine}{\void}
646 Returns {\tt true} if this is a multi line edit control and {\tt false}
651 \helpref{IsSingleLine}{wxtextctrlissingleline}
654 \membersection{wxTextCtrl::IsSingleLine}\label{wxtextctrlissingleline}
656 \constfunc{bool}{IsSingleLine}{\void}
658 Returns {\tt true} if this is a single line edit control and {\tt false}
663 \helpref{IsMultiLine}{wxtextctrlissingleline}
666 \membersection{wxTextCtrl::LoadFile}\label{wxtextctrlloadfile}
668 \func{bool}{LoadFile}{\param{const wxString\& }{ filename}, \param{int }{fileType = wxTEXT\_TYPE\_ANY}}
670 Loads and displays the named file, if it exists.
672 \wxheading{Parameters}
674 \docparam{filename}{The filename of the file to load.}
676 \docparam{fileType}{The type of file to load. This is currently ignored in wxTextCtrl.}
678 \wxheading{Return value}
680 {\tt true} if successful, {\tt false} otherwise.
682 % VZ: commenting this out as: (a) the docs are wrong (you can't replace
683 % anything), (b) wxTextCtrl doesn't have any OnChar() anyhow
684 %% \membersection{wxTextCtrl::OnChar}\label{wxtextctrlonchar}
686 %% \func{void}{OnChar}{\param{wxKeyEvent\& }{event}}
688 %% Default handler for character input.
690 %% \wxheading{Remarks}
692 %% It is possible to intercept character
693 %% input by overriding this member. Call this function
694 %% to let the default behaviour take place; not calling
695 %% it results in the character being ignored. You can
696 %% replace the {\it keyCode} member of {\it event} to
697 %% translate keystrokes.
699 %% Note that Windows and Motif have different ways
700 %% of implementing the default behaviour. In Windows,
701 %% calling wxTextCtrl::OnChar immediately
702 %% processes the character. In Motif,
703 %% calling this function simply sets a flag
704 %% to let default processing happen. This might affect
705 %% the way in which you write your OnChar function
706 %% on different platforms.
708 %% \wxheading{See also}
710 %% \helpref{wxKeyEvent}{wxkeyevent}
713 \membersection{wxTextCtrl::MarkDirty}\label{wxtextctrlmarkdirty}
715 \func{void}{MarkDirty}{\void}
717 Mark text as modified (dirty).
721 \helpref{IsModified}{wxtextctrlismodified}
724 \membersection{wxTextCtrl::OnDropFiles}\label{wxtextctrlondropfiles}
726 \func{void}{OnDropFiles}{\param{wxDropFilesEvent\& }{event}}
728 This event handler function implements default drag and drop behaviour, which
729 is to load the first dropped file into the control.
731 \wxheading{Parameters}
733 \docparam{event}{The drop files event.}
737 This is not implemented on non-Windows platforms.
741 \helpref{wxDropFilesEvent}{wxdropfilesevent}
744 \membersection{wxTextCtrl::Paste}\label{wxtextctrlpaste}
746 \func{virtual void}{Paste}{\void}
748 Pastes text from the clipboard to the text item.
751 \membersection{wxTextCtrl::PositionToXY}\label{wxtextctrlpositiontoxy}
753 \constfunc{bool}{PositionToXY}{\param{long }{pos}, \param{long *}{x}, \param{long *}{y}}
755 Converts given position to a zero-based column, line number pair.
757 \wxheading{Parameters}
759 \docparam{pos}{Position.}
761 \docparam{x}{Receives zero based column number.}
763 \docparam{y}{Receives zero based line number.}
765 \wxheading{Return value}
767 {\tt true} on success, {\tt false} on failure (most likely due to a too large position
772 \helpref{wxTextCtrl::XYToPosition}{wxtextctrlxytoposition}
774 \pythonnote{In Python, PositionToXY() returns a tuple containing the x and
775 y values, so (x,y) = PositionToXY() is equivalent to the call described
778 \perlnote{In wxPerl this method only takes the {\tt pos} parameter, and
779 returns a 2-element list {\tt ( x, y )}.}
782 \membersection{wxTextCtrl::Redo}\label{wxtextctrlredo}
784 \func{virtual void}{Redo}{\void}
786 If there is a redo facility and the last operation can be redone, redoes the last operation. Does nothing
787 if there is no redo facility.
790 \membersection{wxTextCtrl::Remove}\label{wxtextctrlremove}
792 \func{virtual void}{Remove}{\param{long}{ from}, \param{long}{ to}}
794 Removes the text starting at the first given position up to (but not including)
795 the character at the last position.
797 \wxheading{Parameters}
799 \docparam{from}{The first position.}
801 \docparam{to}{The last position.}
804 \membersection{wxTextCtrl::Replace}\label{wxtextctrlreplace}
806 \func{virtual void}{Replace}{\param{long}{ from}, \param{long}{ to}, \param{const wxString\& }{value}}
808 Replaces the text starting at the first position up to (but not including)
809 the character at the last position with the given text.
811 \wxheading{Parameters}
813 \docparam{from}{The first position.}
815 \docparam{to}{The last position.}
817 \docparam{value}{The value to replace the existing text with.}
820 \membersection{wxTextCtrl::SaveFile}\label{wxtextctrlsavefile}
822 \func{bool}{SaveFile}{\param{const wxString\& }{ filename}, \param{int }{fileType = wxTEXT\_TYPE\_ANY}}
824 Saves the contents of the control in a text file.
826 \wxheading{Parameters}
828 \docparam{filename}{The name of the file in which to save the text.}
830 \docparam{fileType}{The type of file to save. This is currently ignored in wxTextCtrl.}
832 \wxheading{Return value}
834 {\tt true} if the operation was successful, {\tt false} otherwise.
837 \membersection{wxTextCtrl::SetDefaultStyle}\label{wxtextctrlsetdefaultstyle}
839 \func{bool}{SetDefaultStyle}{\param{const wxTextAttr\& }{style}}
841 Changes the default style to use for the new text which is going to be added
842 to the control using \helpref{WriteText}{wxtextctrlwritetext} or\rtfsp
843 \helpref{AppendText}{wxtextctrlappendtext}.
845 If either of the font, foreground, or background colour is not set in\rtfsp
846 {\it style}, the values of the previous default style are used for them. If
847 the previous default style didn't set them neither, the global font or colours
848 of the text control itself are used as fall back.
850 However if the {\it style} parameter is the default wxTextAttr, then the
851 default style is just reset (instead of being combined with the new style which
852 wouldn't change it at all).
854 \wxheading{Parameters}
856 \docparam{style}{The style for the new text.}
858 \wxheading{Return value}
860 {\tt true} on success, {\tt false} if an error occurred - may also mean that
861 the styles are not supported under this platform.
865 \helpref{GetDefaultStyle}{wxtextctrlgetdefaultstyle}
868 \membersection{wxTextCtrl::SetEditable}\label{wxtextctrlseteditable}
870 \func{virtual void}{SetEditable}{\param{const bool}{ editable}}
872 Makes the text item editable or read-only, overriding the {\bf wxTE\_READONLY} flag.
874 \wxheading{Parameters}
876 \docparam{editable}{If {\tt true}, the control is editable. If {\tt false}, the control is read-only.}
880 \helpref{IsEditable}{wxtextctrliseditable}
883 \membersection{wxTextCtrl::SetInsertionPoint}\label{wxtextctrlsetinsertionpoint}
885 \func{virtual void}{SetInsertionPoint}{\param{long}{ pos}}
887 Sets the insertion point at the given position.
889 \wxheading{Parameters}
891 \docparam{pos}{Position to set.}
894 \membersection{wxTextCtrl::SetInsertionPointEnd}\label{wxtextctrlsetinsertionpointend}
896 \func{virtual void}{SetInsertionPointEnd}{\void}
898 Sets the insertion point at the end of the text control. This is equivalent
899 to \helpref{SetInsertionPoint}{wxtextctrlsetinsertionpoint}(\helpref{GetLastPosition}{wxtextctrlgetlastposition}()).
902 \membersection{wxTextCtrl::SetMaxLength}\label{wxtextctrlsetmaxlength}
904 \func{virtual void}{SetMaxLength}{\param{unsigned long }{len}}
906 This function sets the maximum number of characters the user can enter into the
907 control. In other words, it allows to limit the text value length to {\it len}
908 not counting the terminating {\tt NUL} character.
910 If {\it len} is $0$, the previously set max length limit, if any, is discarded
911 and the user may enter as much text as the underlying native text control
912 widget supports (typically at least 32Kb).
914 If the user tries to enter more characters into the text control when it
915 already is filled up to the maximal length, a
916 {\tt wxEVT\_COMMAND\_TEXT\_MAXLEN} event is sent to notify the program about it
917 (giving it the possibility to show an explanatory message, for example) and the
918 extra input is discarded.
920 Note that under GTK+, this function may only be used with single line text controls.
922 \wxheading{Compatibility}
924 Only implemented in wxMSW/wxGTK starting with wxWidgets 2.3.2.
927 \membersection{wxTextCtrl::SetModified}\label{wxtextctrlsetmodified}
929 \func{void}{SetModified}{\param{bool }{modified}}
931 Marks the control as being modified by the user or not.
935 \helpref{MarkDirty}{wxtextctrlmarkdirty}, \helpref{DiscardEdits}{wxtextctrldiscardedits}
938 \membersection{wxTextCtrl::SetSelection}\label{wxtextctrlsetselection}
940 \func{virtual void}{SetSelection}{\param{long}{ from}, \param{long}{ to}}
942 Selects the text starting at the first position up to (but not including) the
943 character at the last position. If both parameters are equal to $-1$ all text
944 in the control is selected.
946 \wxheading{Parameters}
948 \docparam{from}{The first position.}
950 \docparam{to}{The last position.}
953 \membersection{wxTextCtrl::SetStyle}\label{wxtextctrlsetstyle}
955 \func{bool}{SetStyle}{\param{long }{start}, \param{long }{end}, \param{const wxTextAttr\& }{style}}
957 Changes the style of the given range. If any attribute within {\it style} is
958 not set, the corresponding attribute from \helpref{GetDefaultStyle()}{wxtextctrlgetdefaultstyle} is used.
960 \wxheading{Parameters}
962 \docparam{start}{The start of the range to change.}
964 \docparam{end}{The end of the range to change.}
966 \docparam{style}{The new style for the range.}
968 \wxheading{Return value}
970 {\tt true} on success, {\tt false} if an error occurred - it may also mean that
971 the styles are not supported under this platform.
975 \helpref{wxTextCtrl::GetStyle}{wxtextctrlgetstyle}, \helpref{wxTextAttr}{wxtextattr}
978 \membersection{wxTextCtrl::SetValue}\label{wxtextctrlsetvalue}
980 \func{virtual void}{SetValue}{\param{const wxString\& }{ value}}
982 Sets the text value and marks the control as not-modified (which means that
983 \helpref{IsModified}{wxtextctrlismodified} would return {\tt false} immediately
984 after the call to SetValue).
986 Note that this function will generate a {\tt wxEVT\_COMMAND\_TEXT\_UPDATED}
989 This function is deprecated and should not be used in new code. Please use the
990 \helpref{ChangeValue}{wxtextctrlchangevalue} function instead.
992 \wxheading{Parameters}
994 \docparam{value}{The new value to set. It may contain newline characters if the text control is multi-line.}
997 \membersection{wxTextCtrl::ChangeValue}\label{wxtextctrlchangevalue}
999 \func{virtual void}{ChangeValue}{\param{const wxString\& }{ value}}
1001 Sets the text value and marks the control as not-modified (which means that
1002 \helpref{IsModified}{wxtextctrlismodified} would return {\tt false} immediately
1003 after the call to SetValue).
1005 Note that this function will \emph{not} generate the {\tt wxEVT\_COMMAND\_TEXT\_UPDATED}
1007 This is the only difference with \helpref{SetValue}{wxtextctrlsetvalue}.
1008 See \helpref{this topic}{progevent} for more information.
1012 \wxheading{Parameters}
1014 \docparam{value}{The new value to set. It may contain newline characters if the text control is multi-line.}
1017 \membersection{wxTextCtrl::ShowPosition}\label{wxtextctrlshowposition}
1019 \func{void}{ShowPosition}{\param{long}{ pos}}
1021 Makes the line containing the given position visible.
1023 \wxheading{Parameters}
1025 \docparam{pos}{The position that should be visible.}
1028 \membersection{wxTextCtrl::Undo}\label{wxtextctrlundo}
1030 \func{virtual void}{Undo}{\void}
1032 If there is an undo facility and the last operation can be undone, undoes the last operation. Does nothing
1033 if there is no undo facility.
1036 \membersection{wxTextCtrl::WriteText}\label{wxtextctrlwritetext}
1038 \func{void}{WriteText}{\param{const wxString\& }{ text}}
1040 Writes the text into the text control at the current insertion position.
1042 \wxheading{Parameters}
1044 \docparam{text}{Text to write to the text control.}
1048 Newlines in the text string
1049 are the only control characters allowed, and they will cause appropriate
1050 line breaks. See \helpref{wxTextCtrl::\cinsert}{wxtextctrlinsert} and \helpref{wxTextCtrl::AppendText}{wxtextctrlappendtext} for more convenient ways of writing to the window.
1052 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.
1055 \membersection{wxTextCtrl::XYToPosition}\label{wxtextctrlxytoposition}
1057 \func{long}{XYToPosition}{\param{long}{ x}, \param{long}{ y}}
1059 Converts the given zero based column and line number to a position.
1061 \wxheading{Parameters}
1063 \docparam{x}{The column number.}
1065 \docparam{y}{The line number.}
1067 \wxheading{Return value}
1069 The position value, or -1 if {\tt x} or {\tt y} was invalid.
1072 \membersection{wxTextCtrl::operator \cinsert}\label{wxtextctrlinsert}
1074 \func{wxTextCtrl\&}{operator \cinsert}{\param{const wxString\& }{s}}
1076 \func{wxTextCtrl\&}{operator \cinsert}{\param{int}{ i}}
1078 \func{wxTextCtrl\&}{operator \cinsert}{\param{long}{ i}}
1080 \func{wxTextCtrl\&}{operator \cinsert}{\param{float}{ f}}
1082 \func{wxTextCtrl\&}{operator \cinsert}{\param{double}{ d}}
1084 \func{wxTextCtrl\&}{operator \cinsert}{\param{char}{ c}}
1086 Operator definitions for appending to a text control, for example:
1089 wxTextCtrl *wnd = new wxTextCtrl(my_frame);
1091 (*wnd) << "Welcome to text control number " << 1 << ".\n";