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