]> git.saurik.com Git - wxWidgets.git/blame - docs/latex/wx/text.tex
wxRichTextAttr does not exist anymore - document instead wxTextAttr
[wxWidgets.git] / docs / latex / wx / text.tex
CommitLineData
eda40bfc
VZ
1%%%%%%%%%%%%%%%%%%%%%%%%%%%% wxTextCtrl %%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
2
a660d684
KB
3\section{\class{wxTextCtrl}}\label{wxtextctrl}
4
5A text control allows text to be displayed and edited. It may be
71777e2c 6single line or multi-line.
a660d684
KB
7
8\wxheading{Derived from}
9
10streambuf\\
11\helpref{wxControl}{wxcontrol}\\
12\helpref{wxWindow}{wxwindow}\\
13\helpref{wxEvtHandler}{wxevthandler}\\
14\helpref{wxObject}{wxobject}
15
954b8ae6
JS
16\wxheading{Include files}
17
18<wx/textctrl.h>
19
a7af285d
VZ
20\wxheading{Library}
21
22\helpref{wxCore}{librarieslist}
23
a660d684
KB
24\wxheading{Window styles}
25
26\twocolwidtha{5cm}
27\begin{twocollist}\itemsep=0pt
c50f1fb9 28\twocolitem{\windowstyle{wxTE\_PROCESS\_ENTER}}{The control will generate
01a01d10 29the event wxEVT\_COMMAND\_TEXT\_ENTER (otherwise pressing Enter key
0f66923e 30is either processed internally by the control or used for navigation between
c50f1fb9 31dialog controls).}
2edb0bde 32\twocolitem{\windowstyle{wxTE\_PROCESS\_TAB}}{The control will receive
01a01d10 33wxEVT\_CHAR events for TAB pressed - normally, TAB is used for passing to the
c50f1fb9
VZ
34next control in a dialog instead. For the control created with this style,
35you can still use Ctrl-Enter to pass to the next control from the keyboard.}
a660d684
KB
36\twocolitem{\windowstyle{wxTE\_MULTILINE}}{The text control allows multiple lines.}
37\twocolitem{\windowstyle{wxTE\_PASSWORD}}{The text will be echoed as asterisks.}
38\twocolitem{\windowstyle{wxTE\_READONLY}}{The text will not be user-editable.}
c57e3339 39\twocolitem{\windowstyle{wxTE\_RICH}}{Use rich text control under Win32, this
e119d049 40allows to have more than 64KB of text in the control even under Win9x. This
c57e3339 41style is ignored under other platforms.}
a5aa8086
VZ
42\twocolitem{\windowstyle{wxTE\_RICH2}}{Use rich text control version 2.0 or 3.0
43under Win32, this style is ignored under other platforms}
c57e3339 44\twocolitem{\windowstyle{wxTE\_AUTO\_URL}}{Highlight the URLs and generate the
d69b094f
KH
45wxTextUrlEvents when mouse events occur over them. This style is only supported
46for wxTE\_RICH Win32 and multi-line wxGTK2 text controls.}
5a8f04e3
VZ
47\twocolitem{\windowstyle{wxTE\_NOHIDESEL}}{By default, the Windows text control
48doesn't show the selection when it doesn't have focus - use this style to force
49it to always show it. It doesn't do anything under other platforms.}
0376ed54 50\twocolitem{\windowstyle{wxHSCROLL}}{A horizontal scrollbar will be created and
0fec2f73 51used, so that text won't be wrapped. No effect under wxGTK1.}
09b86e69
VZ
52\twocolitem{\windowstyle{wxTE\_NO\_VSCROLL}}{For multiline controls only:
53vertical scrollbar will never be created. This limits the amount of text which
54can be entered into the control to what can be displayed in it under MSW but
55not under GTK2. Currently not implemented for the other platforms.}
3908fe9b 56\twocolitem{\windowstyle{wxTE\_LEFT}}{The text in the control will be left-justified (default).}
c663fbea
VS
57\twocolitem{\windowstyle{wxTE\_CENTRE}}{The text in the control will be centered (currently wxMSW and wxGTK2 only).}
58\twocolitem{\windowstyle{wxTE\_RIGHT}}{The text in the control will be right-justified (currently wxMSW and wxGTK2 only).}
fb4888a6
VZ
59\twocolitem{\windowstyle{wxTE\_DONTWRAP}}{Same as {\tt wxHSCROLL} style: don't wrap at all, show horizontal scrollbar instead.}
60\twocolitem{\windowstyle{wxTE\_CHARWRAP}}{Wrap the lines too long to be shown entirely at any position (wxUniv and wxGTK2 only).}
61\twocolitem{\windowstyle{wxTE\_WORDWRAP}}{Wrap the lines too long to be shown entirely at word boundaries (wxUniv and wxGTK2 only).}
62\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).}
b0dd9c00 63\twocolitem{\windowstyle{wxTE\_CAPITALIZE}}{On PocketPC and Smartphone, causes the first letter to be capitalized.}
a660d684
KB
64\end{twocollist}
65
b0dd9c00 66See also \helpref{window styles overview}{windowstyles} and \helpref{wxTextCtrl::wxTextCtrl}{wxtextctrlctor}.
a660d684 67
927637fd
VZ
68Note that alignment styles (\windowstyle{wxTE\_LEFT},
69\windowstyle{wxTE\_CENTRE} and \windowstyle{wxTE\_RIGHT}) can be changed
70dynamically after control creation on wxMSW and wxGTK.
71\windowstyle{wxTE\_READONLY}, \windowstyle{wxTE\_PASSWORD} and wrapping styles
72can be dynamically changed under wxGTK but not wxMSW. The other styles can be
73only set during control creation.
74
75
2b5f62a0
VZ
76\wxheading{wxTextCtrl text format}
77
78The multiline text controls always store the text as a sequence of lines
79separated by {\tt $\backslash$n} characters, i.e. in the Unix text format even
80on non-Unix platforms. This allows the user code to ignore the differences
81between the platforms but at a price: the indices in the control such as those
7d8268a1 82returned by \helpref{GetInsertionPoint}{wxtextctrlgetinsertionpoint} or
2b5f62a0
VZ
83\helpref{GetSelection}{wxtextctrlgetselection} can {\bf not} be used as
84indices into the string returned by \helpref{GetValue}{wxtextctrlgetvalue} as
7d8268a1 85they're going to be slightly off for platforms using
2b5f62a0
VZ
86{\tt $\backslash$r$\backslash$n} as separator (as Windows does), for example.
87
88Instead, if you need to obtain a substring between the $2$ indices obtained
89from the control with the help of the functions mentioned above, you should
90use \helpref{GetRange}{wxtextctrlgetrange}. And the indices themselves can
7d8268a1
WS
91only be passed to other methods, for example
92\helpref{SetInsertionPoint}{wxtextctrlsetinsertionpoint} or
2b5f62a0
VZ
93\helpref{SetSelection}{wxtextctrlsetselection}.
94
95To summarize: never use the indices returned by (multiline) wxTextCtrl as
96indices into the string it contains, but only as arguments to be passed back
97to the other wxTextCtrl methods.
98
eda40bfc
VZ
99\wxheading{wxTextCtrl styles}
100
101Multi-line text controls support the styles, i.e. provide a possibility to set
102colours and font for individual characters in it (note that under Windows {\tt
103wxTE\_RICH} style is required for style support). To use the styles you can
104either call \helpref{SetDefaultStyle}{wxtextctrlsetdefaultstyle} before
105inserting the text or call \helpref{SetStyle}{wxtextctrlsetstyle} later to
106change the style of the text already in the control (the first solution is
107much more efficient).
108
109In either case, if the style doesn't specify some of the attributes (for
110example you only want to set the text colour but without changing the font nor
111the text background), the values of the default style will be used for them.
112If there is no default style, the attributes of the text control itself are
113used.
114
115So the following code correctly describes what it does: the second call
116to \helpref{SetDefaultStyle}{wxtextctrlsetdefaultstyle} doesn't change the
117text foreground colour (which stays red) while the last one doesn't change the
118background colour (which stays grey):
119
120{\small%
121\begin{verbatim}
122 text->SetDefaultStyle(wxTextAttr(*wxRED));
123 text->AppendText("Red text\n");
124 text->SetDefaultStyle(wxTextAttr(wxNullColour, *wxLIGHT_GREY));
125 text->AppendText("Red on grey text\n");
126 text->SetDefaultStyle(wxTextAttr(*wxBLUE);
127 text->AppendText("Blue on grey text\n");
128\end{verbatim}
129}%
130
d73e6791 131\wxheading{wxTextCtrl and C++ streams}
a660d684 132
d73e6791
VZ
133This class multiply-inherits from {\bf streambuf} where compilers allow,
134allowing code such as the following:
a660d684
KB
135
136{\small%
137\begin{verbatim}
138 wxTextCtrl *control = new wxTextCtrl(...);
139
140 ostream stream(control)
141
142 stream << 123.456 << " some text\n";
143 stream.flush();
144\end{verbatim}
145}%
146
d73e6791
VZ
147If your compiler does not support derivation from {\bf streambuf} and gives a
148compile error, define the symbol {\bf NO\_TEXT\_WINDOW\_STREAM} in the
149wxTextCtrl header file.
9c884972 150
d73e6791
VZ
151Note that independently of this setting you can always use wxTextCtrl itself
152in a stream-like manner:
153
154{\small%
155\begin{verbatim}
156 wxTextCtrl *control = new wxTextCtrl(...);
157
158 *control << 123.456 << " some text\n";
159\end{verbatim}
160}%
161
162always works. However the possibility to create an ostream associated with
163wxTextCtrl may be useful if you need to redirect the output of a function
164taking an ostream as parameter to a text control.
165
166Another commonly requested need is to redirect {\bf std::cout} to the text
167control. This could be done in the following way:
168
169{\small%
170\begin{verbatim}
171 #include <iostream>
172
173 wxTextCtrl *control = new wxTextCtrl(...);
174
175 std::streambuf *sbOld = std::cout.rdbuf();
176 std::cout.rdbuf(*control);
177
178 // use cout as usual, the output appears in the text control
179 ...
180
181 std::cout.rdbuf(sbOld);
182\end{verbatim}
183}%
184
fc2171bd 185But wxWidgets provides a convenient class to make it even simpler so instead
d73e6791
VZ
186you may just do
187
188{\small%
189\begin{verbatim}
190 #include <iostream>
191
192 wxTextCtrl *control = new wxTextCtrl(...);
193
194 wxStreamToTextRedirector redirect(control);
195
196 // all output to cout goes into the text control until the exit from current
197 // scope
198\end{verbatim}
199}%
200
201See \helpref{wxStreamToTextRedirector}{wxstreamtotextredirector} for more
202details.
a660d684 203
562b0068
JS
204\wxheading{Constants}
205
206The values below are the possible return codes of the
207\helpref{HitTest}{wxtextctrlhittest} method:
208
209{\small
210\begin{verbatim}
211// the point asked is ...
212enum wxTextCtrlHitTestResult
213{
214 wxTE_HT_UNKNOWN = -2, // this means HitTest() is simply not implemented
215 wxTE_HT_BEFORE, // either to the left or upper
216 wxTE_HT_ON_TEXT, // directly on
217 wxTE_HT_BELOW, // below [the last line]
218 wxTE_HT_BEYOND // after [the end of line]
219};
220// ... the character returned
221\end{verbatim}
222}
223
224
5de76427
JS
225\wxheading{Event handling}
226
e702ff0f
JS
227The following commands are processed by default event handlers in wxTextCtrl: wxID\_CUT, wxID\_COPY,
228wxID\_PASTE, wxID\_UNDO, wxID\_REDO. The associated UI update events are also processed
229automatically, when the control has the focus.
230
5de76427
JS
231To process input from a text control, use these event handler macros to direct input to member
232functions that take a \helpref{wxCommandEvent}{wxcommandevent} argument.
233
234\twocolwidtha{7cm}%
235\begin{twocollist}\itemsep=0pt
236\twocolitem{{\bf EVT\_TEXT(id, func)}}{Respond to a wxEVT\_COMMAND\_TEXT\_UPDATED event,
f6519b40 237generated when the text changes. Notice that this event will be sent
a1665b22 238when the text controls contents changes - whether this is due to user input or
f6519b40
VZ
239comes from the program itself (for example, if SetValue() is called); see ChangeValue() for
240a function which does not send this event.}
5de76427 241\twocolitem{{\bf EVT\_TEXT\_ENTER(id, func)}}{Respond to a wxEVT\_COMMAND\_TEXT\_ENTER event,
0f66923e
VZ
242generated when enter is pressed in a text control (which must have
243wxTE\_PROCESS\_ENTER style for this event to be generated).}
43e8916f 244\twocolitem{{\bf EVT\_TEXT\_URL(id, func)}}{A mouse event occurred over an URL
d69b094f 245in the text control (wxMSW and wxGTK2 only)}
f2616db5 246\twocolitem{{\bf EVT\_TEXT\_MAXLEN(id, func)}}{User tried to enter more text
eef97940 247into the control than the limit set by
f2616db5 248\helpref{SetMaxLength}{wxtextctrlsetmaxlength}.}
5de76427
JS
249\end{twocollist}%
250
a660d684
KB
251\latexignore{\rtfignore{\wxheading{Members}}}
252
efe66bbc 253
15d83f72 254\membersection{wxTextCtrl::wxTextCtrl}\label{wxtextctrlctor}
a660d684
KB
255
256\func{}{wxTextCtrl}{\void}
257
258Default constructor.
259
eaaa6a06 260\func{}{wxTextCtrl}{\param{wxWindow* }{parent}, \param{wxWindowID}{ id},\rtfsp
aa8a815b
JS
261\param{const wxString\& }{value = ``"}, \param{const wxPoint\& }{pos = wxDefaultPosition}, \param{const wxSize\& }{size = wxDefaultSize},\rtfsp
262\param{long}{ style = 0}, \param{const wxValidator\& }{validator = wxDefaultValidator}, \param{const wxString\& }{name = wxTextCtrlNameStr}}
a660d684
KB
263
264Constructor, creating and showing a text control.
265
266\wxheading{Parameters}
267
268\docparam{parent}{Parent window. Should not be NULL.}
269
270\docparam{id}{Control identifier. A value of -1 denotes a default value.}
271
272\docparam{value}{Default text value.}
273
274\docparam{pos}{Text control position.}
275
276\docparam{size}{Text control size.}
277
278\docparam{style}{Window style. See \helpref{wxTextCtrl}{wxtextctrl}.}
279
280\docparam{validator}{Window validator.}
281
282\docparam{name}{Window name.}
283
284\wxheading{Remarks}
285
74ede4eb
VZ
286The horizontal scrollbar ({\bf wxHSCROLL} style flag) will only be created
287for multi-line text controls.
86975656 288Without a horizontal scrollbar, text lines that don't fit in the control's
71777e2c
HH
289size will be wrapped (but no newline character is inserted). Single line
290controls don't have a horizontal scrollbar, the text is automatically scrolled
86975656 291so that the \helpref{insertion point}{wxtextctrlgetinsertionpoint} is always
71777e2c
HH
292visible.
293
c57e3339
VZ
294% VZ: this is no longer true
295%Under Windows, if the {\bf wxTE\_MULTILINE} style is used, the window is implemented
296%as a Windows rich text control with unlimited capacity. Otherwise, normal edit control limits
297%apply.
a660d684
KB
298
299\wxheading{See also}
300
301\helpref{wxTextCtrl::Create}{wxtextctrlcreate}, \helpref{wxValidator}{wxvalidator}
302
efe66bbc 303
15d83f72 304\membersection{wxTextCtrl::\destruct{wxTextCtrl}}\label{wxtextctrldtor}
a660d684
KB
305
306\func{}{\destruct{wxTextCtrl}}{\void}
307
308Destructor, destroying the text control.
309
efe66bbc 310
ca8b28f2
JS
311\membersection{wxTextCtrl::AppendText}\label{wxtextctrlappendtext}
312
313\func{void}{AppendText}{\param{const wxString\& }{ text}}
314
315Appends the text to the end of the text control.
316
317\wxheading{Parameters}
318
319\docparam{text}{Text to write to the text control.}
320
321\wxheading{Remarks}
322
323After the text is appended, the insertion point will be at the end of the text control. If this behaviour is not desired,
324the programmer should use \helpref{GetInsertionPoint}{wxtextctrlgetinsertionpoint} and \helpref{SetInsertionPoint}{wxtextctrlsetinsertionpoint}.
325
326\wxheading{See also}
327
328\helpref{wxTextCtrl::WriteText}{wxtextctrlwritetext}
329
efe66bbc 330
ecaed0bc
VZ
331\membersection{wxTextCtrl::AutoComplete}\label{wxtextctrlautocomplete}
332
333\func{bool}{AutoComplete}{\param{const wxArrayString\& }{choices}}
334
335Call this function to enable auto-completion of the text typed in a single-line
336text control using the given \arg{choices}.
337
0847dca6
VZ
338Notice that currently this function is only implemented in wxGTK2 and wxMSW
339ports and does nothing under the other platforms.
ecaed0bc
VZ
340
341\newsince{2.9.0}
342
59396417
VZ
343\wxheading{Return value}
344
345\true if the auto-completion was enabled or \false if the operation failed,
346typically because auto-completion is not supported by the current platform.
347
348\wxheading{See also}
349
350\helpref{AutoCompleteFileNames}{wxtextctrlautocompletefilenames}
351
352
353\membersection{wxTextCtrl::AutoCompleteFileNames}\label{wxtextctrlautocompletefilenames}
354
355\func{bool}{AutoCompleteFileNames}{\void}
356
357Call this function to enable auto-completion of the text typed in a single-line
358text control using all valid file system paths.
359
360Notice that currently this function is only implemented in wxGTK2 port and does
361nothing under the other platforms.
362
363\newsince{2.9.0}
364
365\wxheading{Return value}
366
367\true if the auto-completion was enabled or \false if the operation failed,
368typically because auto-completion is not supported by the current platform.
369
370\wxheading{See also}
371
372\helpref{AutoComplete}{wxtextctrlautocomplete}
373
ecaed0bc 374
ca8b28f2
JS
375\membersection{wxTextCtrl::CanCopy}\label{wxtextctrlcancopy}
376
377\func{virtual bool}{CanCopy}{\void}
378
cc81d32f 379Returns {\tt true} if the selection can be copied to the clipboard.
ca8b28f2 380
efe66bbc 381
ca8b28f2
JS
382\membersection{wxTextCtrl::CanCut}\label{wxtextctrlcancut}
383
384\func{virtual bool}{CanCut}{\void}
385
cc81d32f 386Returns {\tt true} if the selection can be cut to the clipboard.
ca8b28f2 387
efe66bbc 388
ca8b28f2
JS
389\membersection{wxTextCtrl::CanPaste}\label{wxtextctrlcanpaste}
390
391\func{virtual bool}{CanPaste}{\void}
392
cc81d32f 393Returns {\tt true} if the contents of the clipboard can be pasted into the
ca8b28f2 394text control. On some platforms (Motif, GTK) this is an approximation
cc81d32f 395and returns {\tt true} if the control is editable, {\tt false} otherwise.
ca8b28f2 396
efe66bbc 397
ca8b28f2
JS
398\membersection{wxTextCtrl::CanRedo}\label{wxtextctrlcanredo}
399
400\func{virtual bool}{CanRedo}{\void}
401
cc81d32f 402Returns {\tt true} if there is a redo facility available and the last operation
ca8b28f2
JS
403can be redone.
404
efe66bbc 405
ca8b28f2
JS
406\membersection{wxTextCtrl::CanUndo}\label{wxtextctrlcanundo}
407
408\func{virtual bool}{CanUndo}{\void}
409
cc81d32f 410Returns {\tt true} if there is an undo facility available and the last operation
ca8b28f2
JS
411can be undone.
412
efe66bbc 413
a660d684
KB
414\membersection{wxTextCtrl::Clear}\label{wxtextctrlclear}
415
416\func{virtual void}{Clear}{\void}
417
418Clears the text in the control.
419
674c474f
VZ
420Note that this function will generate a {\tt wxEVT\_COMMAND\_TEXT\_UPDATED}
421event.
422
efe66bbc 423
a660d684
KB
424\membersection{wxTextCtrl::Copy}\label{wxtextctrlcopy}
425
426\func{virtual void}{Copy}{\void}
427
428Copies the selected text to the clipboard under Motif and MS Windows.
429
efe66bbc 430
a660d684
KB
431\membersection{wxTextCtrl::Create}\label{wxtextctrlcreate}
432
eaaa6a06 433\func{bool}{Create}{\param{wxWindow* }{parent}, \param{wxWindowID}{ id},\rtfsp
aa8a815b
JS
434\param{const wxString\& }{value = ``"}, \param{const wxPoint\& }{pos = wxDefaultPosition}, \param{const wxSize\& }{size = wxDefaultSize},\rtfsp
435\param{long}{ style = 0}, \param{const wxValidator\& }{validator = wxDefaultValidator}, \param{const wxString\& }{name = wxTextCtrlNameStr}}
a660d684
KB
436
437Creates the text control for two-step construction. Derived classes
15d83f72 438should call or replace this function. See \helpref{wxTextCtrl::wxTextCtrl}{wxtextctrlctor}\rtfsp
a660d684
KB
439for further details.
440
efe66bbc 441
a660d684
KB
442\membersection{wxTextCtrl::Cut}\label{wxtextctrlcut}
443
444\func{virtual void}{Cut}{\void}
445
446Copies the selected text to the clipboard and removes the selection.
447
efe66bbc 448
15d83f72 449\membersection{wxTextCtrl::DiscardEdits}\label{wxtextctrldiscardedits}
a660d684
KB
450
451\func{void}{DiscardEdits}{\void}
452
453Resets the internal `modified' flag as if the current edits had been saved.
454
efe66bbc 455
15d83f72 456\membersection{wxTextCtrl::EmulateKeyPress}\label{wxtextctrlemulatekeypress}
94af7d45
VZ
457
458\func{bool}{EmulateKeyPress}{\param{const wxKeyEvent\& }{event}}
459
460This functions inserts into the control the character which would have been
43e8916f 461inserted if the given key event had occurred in the text control. The
94af7d45 462{\it event} object should be the same as the one passed to {\tt EVT\_KEY\_DOWN}
fc2171bd 463handler previously by wxWidgets.
94af7d45 464
cd916794
VZ
465Please note that this function doesn't currently work correctly for all keys
466under any platform but MSW.
467
94af7d45
VZ
468\wxheading{Return value}
469
cc81d32f 470{\tt true} if the event resulted in a change to the control, {\tt false}
94af7d45
VZ
471otherwise.
472
efe66bbc 473
02a3b391 474\membersection{wxTextCtrl::GetDefaultStyle}\label{wxtextctrlgetdefaultstyle}
eda40bfc
VZ
475
476\constfunc{const wxTextAttr\& }{GetDefaultStyle}{\void}
477
478Returns the style currently used for the new text.
479
480\wxheading{See also}
481
482\helpref{SetDefaultStyle}{wxtextctrlsetdefaultstyle}
483
efe66bbc 484
a660d684
KB
485\membersection{wxTextCtrl::GetInsertionPoint}\label{wxtextctrlgetinsertionpoint}
486
487\constfunc{virtual long}{GetInsertionPoint}{\void}
488
71777e2c
HH
489Returns the insertion point. This is defined as the zero based index of the
490character position to the right of the insertion point. For example, if
491the insertion point is at the end of the text control, it is equal to
86975656
RD
492both \helpref{GetValue()}{wxtextctrlgetvalue}.Length() and
493\helpref{GetLastPosition()}{wxtextctrlgetlastposition}.
71777e2c
HH
494
495The following code snippet safely returns the character at the insertion
496point or the zero character if the point is at the end of the control.
497
498{\small%
499\begin{verbatim}
500 char GetCurrentChar(wxTextCtrl *tc) {
501 if (tc->GetInsertionPoint() == tc->GetLastPosition())
502 return '\0';
503 return tc->GetValue[tc->GetInsertionPoint()];
86975656 504 }
71777e2c
HH
505\end{verbatim}
506}%
a660d684 507
efe66bbc 508
a660d684
KB
509\membersection{wxTextCtrl::GetLastPosition}\label{wxtextctrlgetlastposition}
510
7d8268a1 511\constfunc{virtual wxTextPos}{GetLastPosition}{\void}
a660d684 512
86975656 513Returns the zero based index of the last position in the text control,
71777e2c 514which is equal to the number of characters in the control.
a660d684 515
efe66bbc 516
a660d684
KB
517\membersection{wxTextCtrl::GetLineLength}\label{wxtextctrlgetlinelength}
518
519\constfunc{int}{GetLineLength}{\param{long}{ lineNo}}
520
86975656 521Gets the length of the specified line, not including any trailing newline
71777e2c 522character(s).
a660d684
KB
523
524\wxheading{Parameters}
525
526\docparam{lineNo}{Line number (starting from zero).}
527
528\wxheading{Return value}
529
530The length of the line, or -1 if {\it lineNo} was invalid.
531
efe66bbc 532
a660d684
KB
533\membersection{wxTextCtrl::GetLineText}\label{wxtextctrlgetlinetext}
534
eaaa6a06 535\constfunc{wxString}{GetLineText}{\param{long}{ lineNo}}
a660d684 536
71777e2c
HH
537Returns the contents of a given line in the text control, not including
538any trailing newline character(s).
a660d684
KB
539
540\wxheading{Parameters}
541
542\docparam{lineNo}{The line number, starting from zero.}
543
544\wxheading{Return value}
545
546The contents of the line.
547
efe66bbc 548
a660d684
KB
549\membersection{wxTextCtrl::GetNumberOfLines}\label{wxtextctrlgetnumberoflines}
550
551\constfunc{int}{GetNumberOfLines}{\void}
552
553Returns the number of lines in the text control buffer.
554
71777e2c
HH
555\wxheading{Remarks}
556
557Note that even empty text controls have one line (where the insertion point
e894be20 558is), so GetNumberOfLines() never returns $0$.
71777e2c 559
e894be20
VZ
560For wxGTK using GTK+ 1.2.x and earlier, the number of lines in a multi-line
561text control is calculated by actually counting newline characters in the
562buffer, i.e. this function returns the number of logical lines and doesn't
563depend on whether any of them are wrapped. For all the other platforms, the
564number of physical lines in the control is returned.
565
566Also note that you may wish to avoid using functions that work with line
567numbers if you are working with controls that contain large amounts of text as
568this function has $O(N)$ complexity for $N$ being the number of lines.
71777e2c 569
efe66bbc 570
a5aa8086
VZ
571\membersection{wxTextCtrl::GetRange}\label{wxtextctrlgetrange}
572
573\constfunc{virtual wxString}{GetRange}{\param{long}{ from}, \param{long}{ to}}
574
43e8916f 575Returns the string containing the text starting in the positions {\it from} and
a5aa8086
VZ
576up to {\it to} in the control. The positions must have been returned by another
577wxTextCtrl method.
578
579Please note that the positions in a multiline wxTextCtrl do {\bf not}
7d8268a1 580correspond to the indices in the string returned by
a5aa8086
VZ
581\helpref{GetValue}{wxtextctrlgetvalue} because of the different new line
582representations ({\tt CR} or {\tt CR LF}) and so this method should be used to
583obtain the correct results instead of extracting parts of the entire value. It
584may also be more efficient, especially if the control contains a lot of data.
585
efe66bbc 586
ca8b28f2
JS
587\membersection{wxTextCtrl::GetSelection}\label{wxtextctrlgetselection}
588
a5aa8086 589\constfunc{virtual void}{GetSelection}{\param{long*}{ from}, \param{long*}{ to}}
ca8b28f2
JS
590
591Gets the current selection span. If the returned values are equal, there was
592no selection.
593
18414479
VZ
594Please note that the indices returned may be used with the other wxTextctrl
595methods but don't necessarily represent the correct indices into the string
596returned by \helpref{GetValue()}{wxtextctrlgetvalue} for multiline controls
eef97940
RD
597under Windows (at least,) you should use
598\helpref{GetStringSelection()}{wxtextctrlgetstringselection} to get the selected
18414479
VZ
599text.
600
ca8b28f2
JS
601\wxheading{Parameters}
602
603\docparam{from}{The returned first position.}
604
605\docparam{to}{The returned last position.}
606
86975656
RD
607\pythonnote{The wxPython version of this method returns a tuple
608consisting of the from and to values.}
609
5873607e
VZ
610\perlnote{In wxPerl this method takes no parameter and returns a
6112-element list {\tt ( from, to )}.}
612
efe66bbc 613
eef97940 614\membersection{wxTextCtrl::GetStringSelection}\label{wxtextctrlgetstringselection}
18414479 615
eef97940 616\func{virtual wxString}{GetStringSelection}{\void}
18414479
VZ
617
618Gets the text currently selected in the control. If there is no selection, the
619returned string is empty.
620
efe66bbc 621
e00a5d3c
JS
622\membersection{wxTextCtrl::GetStyle}\label{wxtextctrlgetstyle}
623
624\func{bool}{GetStyle}{\param{long }{position}, \param{wxTextAttr\& }{style}}
625
626Returns the style at this position in the text control. Not all platforms
627support this function.
628
629\wxheading{Return value}
630
43e8916f 631{\tt true} on success, {\tt false} if an error occurred - it may also mean that
e00a5d3c
JS
632the styles are not supported under this platform.
633
634\wxheading{See also}
635
636\helpref{wxTextCtrl::SetStyle}{wxtextctrlsetstyle}, \helpref{wxTextAttr}{wxtextattr}
637
efe66bbc 638
a660d684
KB
639\membersection{wxTextCtrl::GetValue}\label{wxtextctrlgetvalue}
640
641\constfunc{wxString}{GetValue}{\void}
642
9750fc42 643Gets the contents of the control. Notice that for a multiline text control,
2b5f62a0
VZ
644the lines will be separated by (Unix-style) $\backslash$n characters, even
645under Windows where they are separated by a $\backslash$r$\backslash$n
646sequence in the native control.
a660d684 647
efe66bbc
VZ
648
649\membersection{wxTextCtrl::HitTest}\label{wxtextctrlhittest}
650
651\constfunc{wxTextCtrlHitTestResult}{HitTest}{\param{const wxPoint\& }{pt}, \param{wxTextCoord }{*col}, \param{wxTextCoord }{*row}}
652
653This function finds the character at the specified position expressed in
654pixels. If the return code is not \texttt{wxTE\_HT\_UNKNOWN} the row and column
7d8268a1 655of the character closest to this position are returned in the \arg{col} and
b325f27f 656\arg{row} parameters (unless the pointers are {\tt NULL} which is allowed).
efe66bbc 657
692c9b86
VZ
658Please note that this function is currently only implemented in wxUniv,
659wxMSW and wxGTK2 ports.
efe66bbc
VZ
660
661\wxheading{See also}
662
e119d049 663\helpref{PositionToXY}{wxtextctrlpositiontoxy}, \helpref{XYToPosition}{wxtextctrlxytoposition}
efe66bbc 664
066f177c 665\perlnote{In wxPerl this function takes only the position argument and
e119d049 666returns a 3-element list \texttt{(result, col, row)}}.
efe66bbc 667
d4fbfbe5 668
9e3229b7
VZ
669\membersection{wxTextCtrl::IsEditable}\label{wxtextctrliseditable}
670
671\constfunc{bool}{IsEditable}{\void}
672
cc81d32f 673Returns {\tt true} if the controls contents may be edited by user (note that it
9e3229b7 674always can be changed by the program), i.e. if the control hasn't been put in
7d8268a1 675read-only mode by a previous call to
9e3229b7
VZ
676\helpref{SetEditable}{wxtextctrlseteditable}.
677
efe66bbc 678
d4fbfbe5
VZ
679\membersection{wxTextCtrl::IsEmpty}\label{wxtextctrlisempty}
680
681\constfunc{bool}{IsEmpty}{\void}
682
683Returns \true if the control is currently empty. This is the same as
684\texttt{GetValue().empty()} but can be much more efficient for the multiline
685controls containing big amounts of text.
686
687\newsince{2.7.1}
688
689
a660d684
KB
690\membersection{wxTextCtrl::IsModified}\label{wxtextctrlismodified}
691
692\constfunc{bool}{IsModified}{\void}
693
7d8268a1 694Returns {\tt true} if the text has been modified by user. Note that calling
29e1cfc2 695\helpref{SetValue}{wxtextctrlsetvalue} doesn't make the control modified.
a660d684 696
43e8916f
MW
697\wxheading{See also}
698
699\helpref{MarkDirty}{wxtextctrlmarkdirty}
700
efe66bbc 701
aa8e9a36
VZ
702\membersection{wxTextCtrl::IsMultiLine}\label{wxtextctrlismultiline}
703
704\constfunc{bool}{IsMultiLine}{\void}
705
cc81d32f 706Returns {\tt true} if this is a multi line edit control and {\tt false}
aa8e9a36
VZ
707otherwise.
708
709\wxheading{See also}
710
711\helpref{IsSingleLine}{wxtextctrlissingleline}
712
efe66bbc 713
aa8e9a36
VZ
714\membersection{wxTextCtrl::IsSingleLine}\label{wxtextctrlissingleline}
715
716\constfunc{bool}{IsSingleLine}{\void}
717
cc81d32f 718Returns {\tt true} if this is a single line edit control and {\tt false}
aa8e9a36
VZ
719otherwise.
720
721\wxheading{See also}
722
723\helpref{IsMultiLine}{wxtextctrlissingleline}
724
efe66bbc 725
a660d684
KB
726\membersection{wxTextCtrl::LoadFile}\label{wxtextctrlloadfile}
727
3306aec1 728\func{bool}{LoadFile}{\param{const wxString\& }{ filename}, \param{int }{fileType = wxTEXT\_TYPE\_ANY}}
a660d684
KB
729
730Loads and displays the named file, if it exists.
731
732\wxheading{Parameters}
733
734\docparam{filename}{The filename of the file to load.}
735
3306aec1
JS
736\docparam{fileType}{The type of file to load. This is currently ignored in wxTextCtrl.}
737
a660d684
KB
738\wxheading{Return value}
739
cc81d32f 740{\tt true} if successful, {\tt false} otherwise.
a660d684 741
d2d50a41
VZ
742% VZ: commenting this out as: (a) the docs are wrong (you can't replace
743% anything), (b) wxTextCtrl doesn't have any OnChar() anyhow
744%% \membersection{wxTextCtrl::OnChar}\label{wxtextctrlonchar}
7d8268a1 745%%
d2d50a41 746%% \func{void}{OnChar}{\param{wxKeyEvent\& }{event}}
7d8268a1 747%%
d2d50a41 748%% Default handler for character input.
7d8268a1 749%%
d2d50a41 750%% \wxheading{Remarks}
7d8268a1 751%%
d2d50a41
VZ
752%% It is possible to intercept character
753%% input by overriding this member. Call this function
754%% to let the default behaviour take place; not calling
755%% it results in the character being ignored. You can
756%% replace the {\it keyCode} member of {\it event} to
757%% translate keystrokes.
7d8268a1 758%%
d2d50a41
VZ
759%% Note that Windows and Motif have different ways
760%% of implementing the default behaviour. In Windows,
761%% calling wxTextCtrl::OnChar immediately
762%% processes the character. In Motif,
763%% calling this function simply sets a flag
764%% to let default processing happen. This might affect
765%% the way in which you write your OnChar function
766%% on different platforms.
7d8268a1 767%%
d2d50a41 768%% \wxheading{See also}
7d8268a1 769%%
d2d50a41 770%% \helpref{wxKeyEvent}{wxkeyevent}
a660d684 771
efe66bbc 772
43e8916f
MW
773\membersection{wxTextCtrl::MarkDirty}\label{wxtextctrlmarkdirty}
774
775\func{void}{MarkDirty}{\void}
776
777Mark text as modified (dirty).
778
779\wxheading{See also}
780
781\helpref{IsModified}{wxtextctrlismodified}
782
783
a660d684
KB
784\membersection{wxTextCtrl::OnDropFiles}\label{wxtextctrlondropfiles}
785
786\func{void}{OnDropFiles}{\param{wxDropFilesEvent\& }{event}}
787
788This event handler function implements default drag and drop behaviour, which
789is to load the first dropped file into the control.
790
791\wxheading{Parameters}
792
793\docparam{event}{The drop files event.}
794
71777e2c
HH
795\wxheading{Remarks}
796
b2cf617c 797This is not implemented on non-Windows platforms.
71777e2c 798
a660d684
KB
799\wxheading{See also}
800
801\helpref{wxDropFilesEvent}{wxdropfilesevent}
802
efe66bbc 803
a660d684
KB
804\membersection{wxTextCtrl::Paste}\label{wxtextctrlpaste}
805
806\func{virtual void}{Paste}{\void}
807
808Pastes text from the clipboard to the text item.
809
efe66bbc 810
a660d684
KB
811\membersection{wxTextCtrl::PositionToXY}\label{wxtextctrlpositiontoxy}
812
0efe5ba7 813\constfunc{bool}{PositionToXY}{\param{long }{pos}, \param{long *}{x}, \param{long *}{y}}
a660d684 814
71777e2c 815Converts given position to a zero-based column, line number pair.
a660d684
KB
816
817\wxheading{Parameters}
818
819\docparam{pos}{Position.}
820
71777e2c 821\docparam{x}{Receives zero based column number.}
a660d684 822
71777e2c
HH
823\docparam{y}{Receives zero based line number.}
824
825\wxheading{Return value}
826
cc81d32f 827{\tt true} on success, {\tt false} on failure (most likely due to a too large position
71777e2c 828parameter).
a660d684
KB
829
830\wxheading{See also}
831
832\helpref{wxTextCtrl::XYToPosition}{wxtextctrlxytoposition}
833
71777e2c
HH
834\pythonnote{In Python, PositionToXY() returns a tuple containing the x and
835y values, so (x,y) = PositionToXY() is equivalent to the call described
836above.}
837
5873607e
VZ
838\perlnote{In wxPerl this method only takes the {\tt pos} parameter, and
839returns a 2-element list {\tt ( x, y )}.}
840
efe66bbc 841
ca8b28f2
JS
842\membersection{wxTextCtrl::Redo}\label{wxtextctrlredo}
843
844\func{virtual void}{Redo}{\void}
845
846If there is a redo facility and the last operation can be redone, redoes the last operation. Does nothing
847if there is no redo facility.
848
efe66bbc 849
a660d684
KB
850\membersection{wxTextCtrl::Remove}\label{wxtextctrlremove}
851
eaaa6a06 852\func{virtual void}{Remove}{\param{long}{ from}, \param{long}{ to}}
a660d684 853
71777e2c
HH
854Removes the text starting at the first given position up to (but not including)
855the character at the last position.
a660d684
KB
856
857\wxheading{Parameters}
858
859\docparam{from}{The first position.}
860
861\docparam{to}{The last position.}
862
efe66bbc 863
a660d684
KB
864\membersection{wxTextCtrl::Replace}\label{wxtextctrlreplace}
865
eaaa6a06 866\func{virtual void}{Replace}{\param{long}{ from}, \param{long}{ to}, \param{const wxString\& }{value}}
a660d684 867
86975656 868Replaces the text starting at the first position up to (but not including)
71777e2c 869the character at the last position with the given text.
a660d684
KB
870
871\wxheading{Parameters}
872
873\docparam{from}{The first position.}
874
875\docparam{to}{The last position.}
876
877\docparam{value}{The value to replace the existing text with.}
878
efe66bbc 879
a660d684
KB
880\membersection{wxTextCtrl::SaveFile}\label{wxtextctrlsavefile}
881
3306aec1 882\func{bool}{SaveFile}{\param{const wxString\& }{ filename}, \param{int }{fileType = wxTEXT\_TYPE\_ANY}}
a660d684
KB
883
884Saves the contents of the control in a text file.
885
886\wxheading{Parameters}
887
71777e2c 888\docparam{filename}{The name of the file in which to save the text.}
a660d684 889
3306aec1
JS
890\docparam{fileType}{The type of file to save. This is currently ignored in wxTextCtrl.}
891
a660d684
KB
892\wxheading{Return value}
893
cc81d32f 894{\tt true} if the operation was successful, {\tt false} otherwise.
a660d684 895
efe66bbc 896
eda40bfc
VZ
897\membersection{wxTextCtrl::SetDefaultStyle}\label{wxtextctrlsetdefaultstyle}
898
899\func{bool}{SetDefaultStyle}{\param{const wxTextAttr\& }{style}}
900
901Changes the default style to use for the new text which is going to be added
902to the control using \helpref{WriteText}{wxtextctrlwritetext} or\rtfsp
903\helpref{AppendText}{wxtextctrlappendtext}.
904
905If either of the font, foreground, or background colour is not set in\rtfsp
906{\it style}, the values of the previous default style are used for them. If
907the previous default style didn't set them neither, the global font or colours
908of the text control itself are used as fall back.
909
c598f225
VZ
910However if the {\it style} parameter is the default wxTextAttr, then the
911default style is just reset (instead of being combined with the new style which
912wouldn't change it at all).
913
eda40bfc
VZ
914\wxheading{Parameters}
915
916\docparam{style}{The style for the new text.}
917
918\wxheading{Return value}
919
43e8916f 920{\tt true} on success, {\tt false} if an error occurred - may also mean that
eda40bfc
VZ
921the styles are not supported under this platform.
922
923\wxheading{See also}
924
925\helpref{GetDefaultStyle}{wxtextctrlgetdefaultstyle}
926
efe66bbc 927
a660d684
KB
928\membersection{wxTextCtrl::SetEditable}\label{wxtextctrlseteditable}
929
930\func{virtual void}{SetEditable}{\param{const bool}{ editable}}
931
b2cf617c 932Makes the text item editable or read-only, overriding the {\bf wxTE\_READONLY} flag.
a660d684
KB
933
934\wxheading{Parameters}
935
cc81d32f 936\docparam{editable}{If {\tt true}, the control is editable. If {\tt false}, the control is read-only.}
a660d684 937
9e3229b7
VZ
938\wxheading{See also}
939
940\helpref{IsEditable}{wxtextctrliseditable}
941
efe66bbc 942
a660d684
KB
943\membersection{wxTextCtrl::SetInsertionPoint}\label{wxtextctrlsetinsertionpoint}
944
eaaa6a06 945\func{virtual void}{SetInsertionPoint}{\param{long}{ pos}}
a660d684 946
71777e2c 947Sets the insertion point at the given position.
a660d684
KB
948
949\wxheading{Parameters}
950
951\docparam{pos}{Position to set.}
952
efe66bbc 953
a660d684
KB
954\membersection{wxTextCtrl::SetInsertionPointEnd}\label{wxtextctrlsetinsertionpointend}
955
956\func{virtual void}{SetInsertionPointEnd}{\void}
957
71777e2c
HH
958Sets the insertion point at the end of the text control. This is equivalent
959to \helpref{SetInsertionPoint}{wxtextctrlsetinsertionpoint}(\helpref{GetLastPosition}{wxtextctrlgetlastposition}()).
a660d684 960
efe66bbc 961
d7eee191
VZ
962\membersection{wxTextCtrl::SetMaxLength}\label{wxtextctrlsetmaxlength}
963
964\func{virtual void}{SetMaxLength}{\param{unsigned long }{len}}
965
966This function sets the maximum number of characters the user can enter into the
967control. In other words, it allows to limit the text value length to {\it len}
968not counting the terminating {\tt NUL} character.
969
2edb0bde 970If {\it len} is $0$, the previously set max length limit, if any, is discarded
5949fba6
VZ
971and the user may enter as much text as the underlying native text control
972widget supports (typically at least 32Kb).
973
d7eee191 974If the user tries to enter more characters into the text control when it
eef97940 975already is filled up to the maximal length, a
d7eee191
VZ
976{\tt wxEVT\_COMMAND\_TEXT\_MAXLEN} event is sent to notify the program about it
977(giving it the possibility to show an explanatory message, for example) and the
978extra input is discarded.
979
4a82116e 980Note that under GTK+, this function may only be used with single line text controls.
d7eee191
VZ
981
982\wxheading{Compatibility}
983
fc2171bd 984Only implemented in wxMSW/wxGTK starting with wxWidgets 2.3.2.
d7eee191 985
efe66bbc 986
be0ac181
VZ
987\membersection{wxTextCtrl::SetModified}\label{wxtextctrlsetmodified}
988
989\func{void}{SetModified}{\param{bool }{modified}}
990
991Marks the control as being modified by the user or not.
992
993\wxheading{See also}
994
995\helpref{MarkDirty}{wxtextctrlmarkdirty}, \helpref{DiscardEdits}{wxtextctrldiscardedits}
996
997
a660d684
KB
998\membersection{wxTextCtrl::SetSelection}\label{wxtextctrlsetselection}
999
eaaa6a06 1000\func{virtual void}{SetSelection}{\param{long}{ from}, \param{long}{ to}}
a660d684 1001
4d7b7fc2
VZ
1002Selects the text starting at the first position up to (but not including) the
1003character at the last position. If both parameters are equal to $-1$ all text
1004in the control is selected.
a660d684
KB
1005
1006\wxheading{Parameters}
1007
1008\docparam{from}{The first position.}
1009
1010\docparam{to}{The last position.}
1011
efe66bbc 1012
eda40bfc
VZ
1013\membersection{wxTextCtrl::SetStyle}\label{wxtextctrlsetstyle}
1014
1015\func{bool}{SetStyle}{\param{long }{start}, \param{long }{end}, \param{const wxTextAttr\& }{style}}
1016
e00a5d3c 1017Changes the style of the given range. If any attribute within {\it style} is
dbd94b75 1018not set, the corresponding attribute from \helpref{GetDefaultStyle()}{wxtextctrlgetdefaultstyle} is used.
eda40bfc
VZ
1019
1020\wxheading{Parameters}
1021
e00a5d3c 1022\docparam{start}{The start of the range to change.}
eda40bfc 1023
e00a5d3c 1024\docparam{end}{The end of the range to change.}
eda40bfc 1025
e00a5d3c 1026\docparam{style}{The new style for the range.}
eda40bfc
VZ
1027
1028\wxheading{Return value}
1029
43e8916f 1030{\tt true} on success, {\tt false} if an error occurred - it may also mean that
eda40bfc
VZ
1031the styles are not supported under this platform.
1032
e00a5d3c
JS
1033\wxheading{See also}
1034
1035\helpref{wxTextCtrl::GetStyle}{wxtextctrlgetstyle}, \helpref{wxTextAttr}{wxtextattr}
1036
efe66bbc 1037
a660d684
KB
1038\membersection{wxTextCtrl::SetValue}\label{wxtextctrlsetvalue}
1039
1040\func{virtual void}{SetValue}{\param{const wxString\& }{ value}}
1041
7d8268a1 1042Sets the text value and marks the control as not-modified (which means that
cc81d32f 1043\helpref{IsModified}{wxtextctrlismodified} would return {\tt false} immediately
29e1cfc2 1044after the call to SetValue).
a660d684 1045
674c474f
VZ
1046Note that this function will generate a {\tt wxEVT\_COMMAND\_TEXT\_UPDATED}
1047event.
1048
f6519b40
VZ
1049This function is deprecated and should not be used in new code. Please use the
1050\helpref{ChangeValue}{wxtextctrlchangevalue} function instead.
1051
1052\wxheading{Parameters}
1053
1054\docparam{value}{The new value to set. It may contain newline characters if the text control is multi-line.}
1055
1056
1057\membersection{wxTextCtrl::ChangeValue}\label{wxtextctrlchangevalue}
1058
1059\func{virtual void}{ChangeValue}{\param{const wxString\& }{ value}}
1060
1061Sets the text value and marks the control as not-modified (which means that
1062\helpref{IsModified}{wxtextctrlismodified} would return {\tt false} immediately
1063after the call to SetValue).
1064
1065Note that this function will \emph{not} generate the {\tt wxEVT\_COMMAND\_TEXT\_UPDATED}
1066event.
1067This is the only difference with \helpref{SetValue}{wxtextctrlsetvalue}.
b42a3531
VZ
1068See \helpref{this topic}{progevent} for more information.
1069
1070\newsince{2.7.1}
f6519b40 1071
a660d684
KB
1072\wxheading{Parameters}
1073
1074\docparam{value}{The new value to set. It may contain newline characters if the text control is multi-line.}
1075
efe66bbc 1076
a660d684
KB
1077\membersection{wxTextCtrl::ShowPosition}\label{wxtextctrlshowposition}
1078
eaaa6a06 1079\func{void}{ShowPosition}{\param{long}{ pos}}
a660d684
KB
1080
1081Makes the line containing the given position visible.
1082
1083\wxheading{Parameters}
1084
1085\docparam{pos}{The position that should be visible.}
1086
efe66bbc 1087
ca8b28f2
JS
1088\membersection{wxTextCtrl::Undo}\label{wxtextctrlundo}
1089
1090\func{virtual void}{Undo}{\void}
1091
1092If there is an undo facility and the last operation can be undone, undoes the last operation. Does nothing
1093if there is no undo facility.
1094
efe66bbc 1095
a660d684
KB
1096\membersection{wxTextCtrl::WriteText}\label{wxtextctrlwritetext}
1097
1098\func{void}{WriteText}{\param{const wxString\& }{ text}}
1099
86975656 1100Writes the text into the text control at the current insertion position.
a660d684
KB
1101
1102\wxheading{Parameters}
1103
1104\docparam{text}{Text to write to the text control.}
1105
1106\wxheading{Remarks}
1107
1108Newlines in the text string
1109are the only control characters allowed, and they will cause appropriate
abaa2936 1110line breaks. See \helpref{wxTextCtrl::\cinsert}{wxtextctrlinsert} and \helpref{wxTextCtrl::AppendText}{wxtextctrlappendtext} for more convenient ways of writing to the window.
71777e2c
HH
1111
1112After 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 1113
efe66bbc 1114
a660d684
KB
1115\membersection{wxTextCtrl::XYToPosition}\label{wxtextctrlxytoposition}
1116
eaaa6a06 1117\func{long}{XYToPosition}{\param{long}{ x}, \param{long}{ y}}
a660d684 1118
71777e2c 1119Converts the given zero based column and line number to a position.
a660d684
KB
1120
1121\wxheading{Parameters}
1122
71777e2c 1123\docparam{x}{The column number.}
a660d684 1124
71777e2c 1125\docparam{y}{The line number.}
a660d684
KB
1126
1127\wxheading{Return value}
1128
21d23b88 1129The position value, or -1 if {\tt x} or {\tt y} was invalid.
a660d684 1130
efe66bbc 1131
a660d684
KB
1132\membersection{wxTextCtrl::operator \cinsert}\label{wxtextctrlinsert}
1133
1134\func{wxTextCtrl\&}{operator \cinsert}{\param{const wxString\& }{s}}
1135
1136\func{wxTextCtrl\&}{operator \cinsert}{\param{int}{ i}}
1137
1138\func{wxTextCtrl\&}{operator \cinsert}{\param{long}{ i}}
1139
1140\func{wxTextCtrl\&}{operator \cinsert}{\param{float}{ f}}
1141
1142\func{wxTextCtrl\&}{operator \cinsert}{\param{double}{ d}}
1143
1144\func{wxTextCtrl\&}{operator \cinsert}{\param{char}{ c}}
1145
abaa2936 1146Operator definitions for appending to a text control, for example:
a660d684
KB
1147
1148\begin{verbatim}
1149 wxTextCtrl *wnd = new wxTextCtrl(my_frame);
1150
1151 (*wnd) << "Welcome to text control number " << 1 << ".\n";
1152\end{verbatim}
1153