]> git.saurik.com Git - wxWidgets.git/blame - docs/latex/wx/text.tex
improved sizing of wxBusyInfo window and updated the docs a bit
[wxWidgets.git] / docs / latex / wx / text.tex
CommitLineData
a660d684
KB
1\section{\class{wxTextCtrl}}\label{wxtextctrl}
2
3A text control allows text to be displayed and edited. It may be
71777e2c 4single line or multi-line.
a660d684
KB
5
6\wxheading{Derived from}
7
8streambuf\\
9\helpref{wxControl}{wxcontrol}\\
10\helpref{wxWindow}{wxwindow}\\
11\helpref{wxEvtHandler}{wxevthandler}\\
12\helpref{wxObject}{wxobject}
13
954b8ae6
JS
14\wxheading{Include files}
15
16<wx/textctrl.h>
17
a660d684
KB
18\wxheading{Window styles}
19
20\twocolwidtha{5cm}
21\begin{twocollist}\itemsep=0pt
c50f1fb9
VZ
22\twocolitem{\windowstyle{wxTE\_PROCESS\_ENTER}}{The control will generate
23the message wxEVENT\_TYPE\_TEXT\_ENTER\_COMMAND (otherwise pressing <Enter> is
24either processed internally by the control or used for navigation between
25dialog controls).}
26\twocolitem{\windowstyle{wxTE\_PROCESS\_TAB}}{The control will receieve
27EVT\_CHAR messages for TAB pressed - normally, TAB is used for passing to the
28next control in a dialog instead. For the control created with this style,
29you can still use Ctrl-Enter to pass to the next control from the keyboard.}
a660d684
KB
30\twocolitem{\windowstyle{wxTE\_MULTILINE}}{The text control allows multiple lines.}
31\twocolitem{\windowstyle{wxTE\_PASSWORD}}{The text will be echoed as asterisks.}
32\twocolitem{\windowstyle{wxTE\_READONLY}}{The text will not be user-editable.}
c57e3339
VZ
33\twocolitem{\windowstyle{wxTE\_RICH}}{Use rich text control under Win32, this
34allows to have more than 64Kb of text in the control even under Win9x. This
35style is ignored under other platforms.}
36\twocolitem{\windowstyle{wxTE\_AUTO\_URL}}{Highlight the URLs and generate the
37wxTextUrlEvents when mouse events occur over them. This style is supported
38under Win32 only and requires wxTE\_RICH.}
5a8f04e3
VZ
39\twocolitem{\windowstyle{wxTE\_NOHIDESEL}}{By default, the Windows text control
40doesn't show the selection when it doesn't have focus - use this style to force
41it to always show it. It doesn't do anything under other platforms.}
9c884972 42\twocolitem{\windowstyle{wxHSCROLL}}{A horizontal scrollbar will be created. No effect under GTK+.}
a660d684
KB
43\end{twocollist}
44
b2cf617c 45See also \helpref{window styles overview}{windowstyles} and
f66205b6 46\helpref{wxTextCtrl::wxTextCtrl}{wxtextctrlconstr}.
a660d684 47
d73e6791 48\wxheading{wxTextCtrl and C++ streams}
a660d684 49
d73e6791
VZ
50This class multiply-inherits from {\bf streambuf} where compilers allow,
51allowing code such as the following:
a660d684
KB
52
53{\small%
54\begin{verbatim}
55 wxTextCtrl *control = new wxTextCtrl(...);
56
57 ostream stream(control)
58
59 stream << 123.456 << " some text\n";
60 stream.flush();
61\end{verbatim}
62}%
63
d73e6791
VZ
64If your compiler does not support derivation from {\bf streambuf} and gives a
65compile error, define the symbol {\bf NO\_TEXT\_WINDOW\_STREAM} in the
66wxTextCtrl header file.
9c884972 67
d73e6791
VZ
68Note that independently of this setting you can always use wxTextCtrl itself
69in a stream-like manner:
70
71{\small%
72\begin{verbatim}
73 wxTextCtrl *control = new wxTextCtrl(...);
74
75 *control << 123.456 << " some text\n";
76\end{verbatim}
77}%
78
79always works. However the possibility to create an ostream associated with
80wxTextCtrl may be useful if you need to redirect the output of a function
81taking an ostream as parameter to a text control.
82
83Another commonly requested need is to redirect {\bf std::cout} to the text
84control. This could be done in the following way:
85
86{\small%
87\begin{verbatim}
88 #include <iostream>
89
90 wxTextCtrl *control = new wxTextCtrl(...);
91
92 std::streambuf *sbOld = std::cout.rdbuf();
93 std::cout.rdbuf(*control);
94
95 // use cout as usual, the output appears in the text control
96 ...
97
98 std::cout.rdbuf(sbOld);
99\end{verbatim}
100}%
101
102But wxWindows provides a convenient class to make it even simpler so instead
103you may just do
104
105{\small%
106\begin{verbatim}
107 #include <iostream>
108
109 wxTextCtrl *control = new wxTextCtrl(...);
110
111 wxStreamToTextRedirector redirect(control);
112
113 // all output to cout goes into the text control until the exit from current
114 // scope
115\end{verbatim}
116}%
117
118See \helpref{wxStreamToTextRedirector}{wxstreamtotextredirector} for more
119details.
a660d684 120
5de76427
JS
121\wxheading{Event handling}
122
e702ff0f
JS
123The following commands are processed by default event handlers in wxTextCtrl: wxID\_CUT, wxID\_COPY,
124wxID\_PASTE, wxID\_UNDO, wxID\_REDO. The associated UI update events are also processed
125automatically, when the control has the focus.
126
5de76427
JS
127To process input from a text control, use these event handler macros to direct input to member
128functions that take a \helpref{wxCommandEvent}{wxcommandevent} argument.
129
130\twocolwidtha{7cm}%
131\begin{twocollist}\itemsep=0pt
132\twocolitem{{\bf EVT\_TEXT(id, func)}}{Respond to a wxEVT\_COMMAND\_TEXT\_UPDATED event,
a1665b22
VZ
133generated when the text changes. Notice that this event will always be sent
134when the text controls contents changes - whether this is due to user input or
135comes from the program itself (for example, if SetValue() is called)}
5de76427
JS
136\twocolitem{{\bf EVT\_TEXT\_ENTER(id, func)}}{Respond to a wxEVT\_COMMAND\_TEXT\_ENTER event,
137generated when enter is pressed in a single-line text control.}
f2616db5
VZ
138\twocolitem{{\bf EVT\_TEXT\_URL(id, func)}}{A mouse event occured over an URL
139in the text control (Win32 only)}
140\twocolitem{{\bf EVT\_TEXT\_MAXLEN(id, func)}}{User tried to enter more text
141into the control than the limit set by
142\helpref{SetMaxLength}{wxtextctrlsetmaxlength}.}
5de76427
JS
143\end{twocollist}%
144
a660d684
KB
145\latexignore{\rtfignore{\wxheading{Members}}}
146
147\membersection{wxTextCtrl::wxTextCtrl}\label{wxtextctrlconstr}
148
149\func{}{wxTextCtrl}{\void}
150
151Default constructor.
152
eaaa6a06 153\func{}{wxTextCtrl}{\param{wxWindow* }{parent}, \param{wxWindowID}{ id},\rtfsp
36b3b54a 154\param{const wxString\& }{value = ``"}, \param{const wxPoint\& }{pos}, \param{const wxSize\& }{size = wxDefaultSize},\rtfsp
eaaa6a06 155\param{long}{ style = 0}, \param{const wxValidator\& }{validator}, \param{const wxString\& }{name = ``text"}}
a660d684
KB
156
157Constructor, creating and showing a text control.
158
159\wxheading{Parameters}
160
161\docparam{parent}{Parent window. Should not be NULL.}
162
163\docparam{id}{Control identifier. A value of -1 denotes a default value.}
164
165\docparam{value}{Default text value.}
166
167\docparam{pos}{Text control position.}
168
169\docparam{size}{Text control size.}
170
171\docparam{style}{Window style. See \helpref{wxTextCtrl}{wxtextctrl}.}
172
173\docparam{validator}{Window validator.}
174
175\docparam{name}{Window name.}
176
177\wxheading{Remarks}
178
86975656
RD
179The horizontal scrollbar ({\bf wxTE\_HSCROLL} style flag) will only be created for multi-line text controls.
180Without a horizontal scrollbar, text lines that don't fit in the control's
71777e2c
HH
181size will be wrapped (but no newline character is inserted). Single line
182controls don't have a horizontal scrollbar, the text is automatically scrolled
86975656 183so that the \helpref{insertion point}{wxtextctrlgetinsertionpoint} is always
71777e2c
HH
184visible.
185
c57e3339
VZ
186% VZ: this is no longer true
187%Under Windows, if the {\bf wxTE\_MULTILINE} style is used, the window is implemented
188%as a Windows rich text control with unlimited capacity. Otherwise, normal edit control limits
189%apply.
a660d684
KB
190
191\wxheading{See also}
192
193\helpref{wxTextCtrl::Create}{wxtextctrlcreate}, \helpref{wxValidator}{wxvalidator}
194
195\membersection{wxTextCtrl::\destruct{wxTextCtrl}}
196
197\func{}{\destruct{wxTextCtrl}}{\void}
198
199Destructor, destroying the text control.
200
ca8b28f2
JS
201\membersection{wxTextCtrl::AppendText}\label{wxtextctrlappendtext}
202
203\func{void}{AppendText}{\param{const wxString\& }{ text}}
204
205Appends the text to the end of the text control.
206
207\wxheading{Parameters}
208
209\docparam{text}{Text to write to the text control.}
210
211\wxheading{Remarks}
212
213After the text is appended, the insertion point will be at the end of the text control. If this behaviour is not desired,
214the programmer should use \helpref{GetInsertionPoint}{wxtextctrlgetinsertionpoint} and \helpref{SetInsertionPoint}{wxtextctrlsetinsertionpoint}.
215
216\wxheading{See also}
217
218\helpref{wxTextCtrl::WriteText}{wxtextctrlwritetext}
219
220\membersection{wxTextCtrl::CanCopy}\label{wxtextctrlcancopy}
221
222\func{virtual bool}{CanCopy}{\void}
223
224Returns TRUE if the selection can be copied to the clipboard.
225
226\membersection{wxTextCtrl::CanCut}\label{wxtextctrlcancut}
227
228\func{virtual bool}{CanCut}{\void}
229
230Returns TRUE if the selection can be cut to the clipboard.
231
232\membersection{wxTextCtrl::CanPaste}\label{wxtextctrlcanpaste}
233
234\func{virtual bool}{CanPaste}{\void}
235
236Returns TRUE if the contents of the clipboard can be pasted into the
237text control. On some platforms (Motif, GTK) this is an approximation
238and returns TRUE if the control is editable, FALSE otherwise.
239
240\membersection{wxTextCtrl::CanRedo}\label{wxtextctrlcanredo}
241
242\func{virtual bool}{CanRedo}{\void}
243
244Returns TRUE if there is a redo facility available and the last operation
245can be redone.
246
247\membersection{wxTextCtrl::CanUndo}\label{wxtextctrlcanundo}
248
249\func{virtual bool}{CanUndo}{\void}
250
251Returns TRUE if there is an undo facility available and the last operation
252can be undone.
253
a660d684
KB
254\membersection{wxTextCtrl::Clear}\label{wxtextctrlclear}
255
256\func{virtual void}{Clear}{\void}
257
258Clears the text in the control.
259
260\membersection{wxTextCtrl::Copy}\label{wxtextctrlcopy}
261
262\func{virtual void}{Copy}{\void}
263
264Copies the selected text to the clipboard under Motif and MS Windows.
265
266\membersection{wxTextCtrl::Create}\label{wxtextctrlcreate}
267
eaaa6a06 268\func{bool}{Create}{\param{wxWindow* }{parent}, \param{wxWindowID}{ id},\rtfsp
36b3b54a 269\param{const wxString\& }{value = ``"}, \param{const wxPoint\& }{pos}, \param{const wxSize\& }{size = wxDefaultSize},\rtfsp
eaaa6a06 270\param{long}{ style = 0}, \param{const wxValidator\& }{validator}, \param{const wxString\& }{name = ``text"}}
a660d684
KB
271
272Creates the text control for two-step construction. Derived classes
273should call or replace this function. See \helpref{wxTextCtrl::wxTextCtrl}{wxtextctrlconstr}\rtfsp
274for further details.
275
276\membersection{wxTextCtrl::Cut}\label{wxtextctrlcut}
277
278\func{virtual void}{Cut}{\void}
279
280Copies the selected text to the clipboard and removes the selection.
281
282\membersection{wxTextCtrl::DiscardEdits}
283
284\func{void}{DiscardEdits}{\void}
285
286Resets the internal `modified' flag as if the current edits had been saved.
287
288\membersection{wxTextCtrl::GetInsertionPoint}\label{wxtextctrlgetinsertionpoint}
289
290\constfunc{virtual long}{GetInsertionPoint}{\void}
291
71777e2c
HH
292Returns the insertion point. This is defined as the zero based index of the
293character position to the right of the insertion point. For example, if
294the insertion point is at the end of the text control, it is equal to
86975656
RD
295both \helpref{GetValue()}{wxtextctrlgetvalue}.Length() and
296\helpref{GetLastPosition()}{wxtextctrlgetlastposition}.
71777e2c
HH
297
298The following code snippet safely returns the character at the insertion
299point or the zero character if the point is at the end of the control.
300
301{\small%
302\begin{verbatim}
303 char GetCurrentChar(wxTextCtrl *tc) {
304 if (tc->GetInsertionPoint() == tc->GetLastPosition())
305 return '\0';
306 return tc->GetValue[tc->GetInsertionPoint()];
86975656 307 }
71777e2c
HH
308\end{verbatim}
309}%
a660d684
KB
310
311\membersection{wxTextCtrl::GetLastPosition}\label{wxtextctrlgetlastposition}
312
313\constfunc{virtual long}{GetLastPosition}{\void}
314
86975656 315Returns the zero based index of the last position in the text control,
71777e2c 316which is equal to the number of characters in the control.
a660d684
KB
317
318\membersection{wxTextCtrl::GetLineLength}\label{wxtextctrlgetlinelength}
319
320\constfunc{int}{GetLineLength}{\param{long}{ lineNo}}
321
86975656 322Gets the length of the specified line, not including any trailing newline
71777e2c 323character(s).
a660d684
KB
324
325\wxheading{Parameters}
326
327\docparam{lineNo}{Line number (starting from zero).}
328
329\wxheading{Return value}
330
331The length of the line, or -1 if {\it lineNo} was invalid.
332
333\membersection{wxTextCtrl::GetLineText}\label{wxtextctrlgetlinetext}
334
eaaa6a06 335\constfunc{wxString}{GetLineText}{\param{long}{ lineNo}}
a660d684 336
71777e2c
HH
337Returns the contents of a given line in the text control, not including
338any trailing newline character(s).
a660d684
KB
339
340\wxheading{Parameters}
341
342\docparam{lineNo}{The line number, starting from zero.}
343
344\wxheading{Return value}
345
346The contents of the line.
347
348\membersection{wxTextCtrl::GetNumberOfLines}\label{wxtextctrlgetnumberoflines}
349
350\constfunc{int}{GetNumberOfLines}{\void}
351
352Returns the number of lines in the text control buffer.
353
71777e2c
HH
354\wxheading{Remarks}
355
356Note that even empty text controls have one line (where the insertion point
357is), so GetNumberOfLines() never returns 0.
358
359For gtk\_text (multi-line) controls, the number of lines is
360calculated by actually counting newline characters in the buffer. You
361may wish to avoid using functions that work with line numbers if you are
362working with controls that contain large amounts of text.
363
ca8b28f2
JS
364\membersection{wxTextCtrl::GetSelection}\label{wxtextctrlgetselection}
365
366\func{virtual void}{GetSelection}{\param{long*}{ from}, \param{long*}{ to}}
367
368Gets the current selection span. If the returned values are equal, there was
369no selection.
370
371\wxheading{Parameters}
372
373\docparam{from}{The returned first position.}
374
375\docparam{to}{The returned last position.}
376
86975656
RD
377\pythonnote{The wxPython version of this method returns a tuple
378consisting of the from and to values.}
379
5873607e
VZ
380\perlnote{In wxPerl this method takes no parameter and returns a
3812-element list {\tt ( from, to )}.}
382
a660d684
KB
383\membersection{wxTextCtrl::GetValue}\label{wxtextctrlgetvalue}
384
385\constfunc{wxString}{GetValue}{\void}
386
9750fc42 387Gets the contents of the control. Notice that for a multiline text control,
b2cf617c
JS
388the lines will be separated by (Unix-style) $\backslash$n characters, even under
389Windows where they are separated by a $\backslash$r$\backslash$n sequence in the native control.
a660d684
KB
390
391\membersection{wxTextCtrl::IsModified}\label{wxtextctrlismodified}
392
393\constfunc{bool}{IsModified}{\void}
394
395Returns TRUE if the text has been modified.
396
397\membersection{wxTextCtrl::LoadFile}\label{wxtextctrlloadfile}
398
399\func{bool}{LoadFile}{\param{const wxString\& }{ filename}}
400
401Loads and displays the named file, if it exists.
402
403\wxheading{Parameters}
404
405\docparam{filename}{The filename of the file to load.}
406
407\wxheading{Return value}
408
409TRUE if successful, FALSE otherwise.
410
411\membersection{wxTextCtrl::OnChar}\label{wxtextctrlonchar}
412
413\func{void}{OnChar}{\param{wxKeyEvent\& }{event}}
414
415Default handler for character input.
416
417\wxheading{Remarks}
418
419It is possible to intercept character
420input by overriding this member. Call this function
421to let the default behaviour take place; not calling
422it results in the character being ignored. You can
423replace the {\it keyCode} member of {\it event} to
424translate keystrokes.
425
426Note that Windows and Motif have different ways
427of implementing the default behaviour. In Windows,
428calling wxTextCtrl::OnChar immediately
429processes the character. In Motif,
430calling this function simply sets a flag
431to let default processing happen. This might affect
432the way in which you write your OnChar function
433on different platforms.
434
435\wxheading{See also}
436
437\helpref{wxKeyEvent}{wxkeyevent}
438
439\membersection{wxTextCtrl::OnDropFiles}\label{wxtextctrlondropfiles}
440
441\func{void}{OnDropFiles}{\param{wxDropFilesEvent\& }{event}}
442
443This event handler function implements default drag and drop behaviour, which
444is to load the first dropped file into the control.
445
446\wxheading{Parameters}
447
448\docparam{event}{The drop files event.}
449
71777e2c
HH
450\wxheading{Remarks}
451
b2cf617c 452This is not implemented on non-Windows platforms.
71777e2c 453
a660d684
KB
454\wxheading{See also}
455
456\helpref{wxDropFilesEvent}{wxdropfilesevent}
457
458\membersection{wxTextCtrl::Paste}\label{wxtextctrlpaste}
459
460\func{virtual void}{Paste}{\void}
461
462Pastes text from the clipboard to the text item.
463
464\membersection{wxTextCtrl::PositionToXY}\label{wxtextctrlpositiontoxy}
465
0efe5ba7 466\constfunc{bool}{PositionToXY}{\param{long }{pos}, \param{long *}{x}, \param{long *}{y}}
a660d684 467
71777e2c 468Converts given position to a zero-based column, line number pair.
a660d684
KB
469
470\wxheading{Parameters}
471
472\docparam{pos}{Position.}
473
71777e2c 474\docparam{x}{Receives zero based column number.}
a660d684 475
71777e2c
HH
476\docparam{y}{Receives zero based line number.}
477
478\wxheading{Return value}
479
0efe5ba7 480TRUE on success, FALSE on failure (most likely due to a too large position
71777e2c 481parameter).
a660d684
KB
482
483\wxheading{See also}
484
485\helpref{wxTextCtrl::XYToPosition}{wxtextctrlxytoposition}
486
71777e2c
HH
487\pythonnote{In Python, PositionToXY() returns a tuple containing the x and
488y values, so (x,y) = PositionToXY() is equivalent to the call described
489above.}
490
5873607e
VZ
491\perlnote{In wxPerl this method only takes the {\tt pos} parameter, and
492returns a 2-element list {\tt ( x, y )}.}
493
ca8b28f2
JS
494\membersection{wxTextCtrl::Redo}\label{wxtextctrlredo}
495
496\func{virtual void}{Redo}{\void}
497
498If there is a redo facility and the last operation can be redone, redoes the last operation. Does nothing
499if there is no redo facility.
500
a660d684
KB
501\membersection{wxTextCtrl::Remove}\label{wxtextctrlremove}
502
eaaa6a06 503\func{virtual void}{Remove}{\param{long}{ from}, \param{long}{ to}}
a660d684 504
71777e2c
HH
505Removes the text starting at the first given position up to (but not including)
506the character at the last position.
a660d684
KB
507
508\wxheading{Parameters}
509
510\docparam{from}{The first position.}
511
512\docparam{to}{The last position.}
513
514\membersection{wxTextCtrl::Replace}\label{wxtextctrlreplace}
515
eaaa6a06 516\func{virtual void}{Replace}{\param{long}{ from}, \param{long}{ to}, \param{const wxString\& }{value}}
a660d684 517
86975656 518Replaces the text starting at the first position up to (but not including)
71777e2c 519the character at the last position with the given text.
a660d684
KB
520
521\wxheading{Parameters}
522
523\docparam{from}{The first position.}
524
525\docparam{to}{The last position.}
526
527\docparam{value}{The value to replace the existing text with.}
528
529\membersection{wxTextCtrl::SaveFile}\label{wxtextctrlsavefile}
530
531\func{bool}{SaveFile}{\param{const wxString\& }{ filename}}
532
533Saves the contents of the control in a text file.
534
535\wxheading{Parameters}
536
71777e2c 537\docparam{filename}{The name of the file in which to save the text.}
a660d684
KB
538
539\wxheading{Return value}
540
541TRUE if the operation was successful, FALSE otherwise.
542
543\membersection{wxTextCtrl::SetEditable}\label{wxtextctrlseteditable}
544
545\func{virtual void}{SetEditable}{\param{const bool}{ editable}}
546
b2cf617c 547Makes the text item editable or read-only, overriding the {\bf wxTE\_READONLY} flag.
a660d684
KB
548
549\wxheading{Parameters}
550
551\docparam{editable}{If TRUE, the control is editable. If FALSE, the control is read-only.}
552
553\membersection{wxTextCtrl::SetInsertionPoint}\label{wxtextctrlsetinsertionpoint}
554
eaaa6a06 555\func{virtual void}{SetInsertionPoint}{\param{long}{ pos}}
a660d684 556
71777e2c 557Sets the insertion point at the given position.
a660d684
KB
558
559\wxheading{Parameters}
560
561\docparam{pos}{Position to set.}
562
563\membersection{wxTextCtrl::SetInsertionPointEnd}\label{wxtextctrlsetinsertionpointend}
564
565\func{virtual void}{SetInsertionPointEnd}{\void}
566
71777e2c
HH
567Sets the insertion point at the end of the text control. This is equivalent
568to \helpref{SetInsertionPoint}{wxtextctrlsetinsertionpoint}(\helpref{GetLastPosition}{wxtextctrlgetlastposition}()).
a660d684 569
d7eee191
VZ
570\membersection{wxTextCtrl::SetMaxLength}\label{wxtextctrlsetmaxlength}
571
572\func{virtual void}{SetMaxLength}{\param{unsigned long }{len}}
573
574This function sets the maximum number of characters the user can enter into the
575control. In other words, it allows to limit the text value length to {\it len}
576not counting the terminating {\tt NUL} character.
577
5949fba6
VZ
578If {\it len} is $0$, the previously set max length limi, if any, is discarded
579and the user may enter as much text as the underlying native text control
580widget supports (typically at least 32Kb).
581
d7eee191
VZ
582If the user tries to enter more characters into the text control when it
583already is filled up to the maximal length, a
584{\tt wxEVT\_COMMAND\_TEXT\_MAXLEN} event is sent to notify the program about it
585(giving it the possibility to show an explanatory message, for example) and the
586extra input is discarded.
587
588Note that this function may only be used with single line text controls.
589
590\wxheading{Compatibility}
591
592Only implemented in wxMSW/wxGTK starting with wxWindows 2.3.2.
593
a660d684
KB
594\membersection{wxTextCtrl::SetSelection}\label{wxtextctrlsetselection}
595
eaaa6a06 596\func{virtual void}{SetSelection}{\param{long}{ from}, \param{long}{ to}}
a660d684 597
71777e2c 598Selects the text starting at the first position up to (but not including) the character at the last position.
a660d684
KB
599
600\wxheading{Parameters}
601
602\docparam{from}{The first position.}
603
604\docparam{to}{The last position.}
605
606\membersection{wxTextCtrl::SetValue}\label{wxtextctrlsetvalue}
607
608\func{virtual void}{SetValue}{\param{const wxString\& }{ value}}
609
f6bcfd97 610Sets the text value and marks the control as not-modified.
a660d684
KB
611
612\wxheading{Parameters}
613
614\docparam{value}{The new value to set. It may contain newline characters if the text control is multi-line.}
615
616\membersection{wxTextCtrl::ShowPosition}\label{wxtextctrlshowposition}
617
eaaa6a06 618\func{void}{ShowPosition}{\param{long}{ pos}}
a660d684
KB
619
620Makes the line containing the given position visible.
621
622\wxheading{Parameters}
623
624\docparam{pos}{The position that should be visible.}
625
ca8b28f2
JS
626\membersection{wxTextCtrl::Undo}\label{wxtextctrlundo}
627
628\func{virtual void}{Undo}{\void}
629
630If there is an undo facility and the last operation can be undone, undoes the last operation. Does nothing
631if there is no undo facility.
632
a660d684
KB
633\membersection{wxTextCtrl::WriteText}\label{wxtextctrlwritetext}
634
635\func{void}{WriteText}{\param{const wxString\& }{ text}}
636
86975656 637Writes the text into the text control at the current insertion position.
a660d684
KB
638
639\wxheading{Parameters}
640
641\docparam{text}{Text to write to the text control.}
642
643\wxheading{Remarks}
644
645Newlines in the text string
646are the only control characters allowed, and they will cause appropriate
abaa2936 647line breaks. See \helpref{wxTextCtrl::\cinsert}{wxtextctrlinsert} and \helpref{wxTextCtrl::AppendText}{wxtextctrlappendtext} for more convenient ways of writing to the window.
71777e2c
HH
648
649After 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.
a660d684
KB
650
651\membersection{wxTextCtrl::XYToPosition}\label{wxtextctrlxytoposition}
652
eaaa6a06 653\func{long}{XYToPosition}{\param{long}{ x}, \param{long}{ y}}
a660d684 654
71777e2c 655Converts the given zero based column and line number to a position.
a660d684
KB
656
657\wxheading{Parameters}
658
71777e2c 659\docparam{x}{The column number.}
a660d684 660
71777e2c 661\docparam{y}{The line number.}
a660d684
KB
662
663\wxheading{Return value}
664
665The position value.
666
667\membersection{wxTextCtrl::operator \cinsert}\label{wxtextctrlinsert}
668
669\func{wxTextCtrl\&}{operator \cinsert}{\param{const wxString\& }{s}}
670
671\func{wxTextCtrl\&}{operator \cinsert}{\param{int}{ i}}
672
673\func{wxTextCtrl\&}{operator \cinsert}{\param{long}{ i}}
674
675\func{wxTextCtrl\&}{operator \cinsert}{\param{float}{ f}}
676
677\func{wxTextCtrl\&}{operator \cinsert}{\param{double}{ d}}
678
679\func{wxTextCtrl\&}{operator \cinsert}{\param{char}{ c}}
680
abaa2936 681Operator definitions for appending to a text control, for example:
a660d684
KB
682
683\begin{verbatim}
684 wxTextCtrl *wnd = new wxTextCtrl(my_frame);
685
686 (*wnd) << "Welcome to text control number " << 1 << ".\n";
687\end{verbatim}
688