]> git.saurik.com Git - wxWidgets.git/blame_incremental - docs/latex/wx/text.tex
deprecated static wxWizard::Create()
[wxWidgets.git] / docs / latex / wx / text.tex
... / ...
CommitLineData
1%%%%%%%%%%%%%%%%%%%%%%%%%%%% wxTextAttr %%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
2
3\section{\class{wxTextAttr}}\label{wxtextattr}
4
5wxTextAttr represents the attributes, or style, for a range of text in a\rtfsp
6\helpref{wxTextCtrl}{wxtextctrl}.
7
8\wxheading{Derived from}
9
10No base class
11
12\wxheading{Include files}
13
14<wx/textctrl.h>
15
16\latexignore{\rtfignore{\wxheading{Members}}}
17
18\membersection{wxTextAttr::wxTextAttr}\label{wxtextattrctor}
19
20\func{}{wxTextAttr}{\void}
21
22\func{}{wxTextAttr}{\param{const wxColour\& }{colText}, \param{const wxColour\& }{colBack = wxNullColour}, \param{const wxFont\& }{font = wxNullFont}}
23
24The constructors initialize one or more of the text foreground and background
25colours and font. The values not initialized in the constructor can be set
26later, otherwise \helpref{wxTextCtrl::SetStyle}{wxtextctrlsetstyle} will use
27the default values for them.
28
29\membersection{wxTextAttr::GetBackgroundColour}
30
31\constfunc{const wxColour\&}{GetBackgroundColour}{\void}
32
33Return the background colour specified by this attribute.
34
35\membersection{wxTextAttr::GetFont}
36
37\constfunc{const wxFont\&}{GetFont}{\void}
38
39Return the text font specified by this attribute.
40
41\membersection{wxTextAttr::GetTextColour}
42
43\constfunc{const wxColour\&}{GetTextColour}{\void}
44
45Return the text colour specified by this attribute.
46
47\membersection{wxTextAttr::HasBackgroundColour}
48
49\constfunc{bool}{HasBackgroundColour}{\void}
50
51Returns {\tt TRUE} if this style specifies the background colour to use.
52
53\membersection{wxTextAttr::HasFont}
54
55\constfunc{bool}{HasFont}{\void}
56
57Returns {\tt TRUE} if this style specifies the font to use.
58
59\membersection{wxTextAttr::HasTextColour}
60
61\constfunc{bool}{HasTextColour}{\void}
62
63Returns {\tt TRUE} if this style specifies the foreground colour to use.
64
65\membersection{wxTextAttr::IsDefault}
66
67\constfunc{bool}{IsDefault}{\void}
68
69Returns {\tt TRUE} if this style specifies any non-default attributes.
70
71%%%%%%%%%%%%%%%%%%%%%%%%%%%% wxTextCtrl %%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
72
73\section{\class{wxTextCtrl}}\label{wxtextctrl}
74
75A text control allows text to be displayed and edited. It may be
76single line or multi-line.
77
78\wxheading{Derived from}
79
80streambuf\\
81\helpref{wxControl}{wxcontrol}\\
82\helpref{wxWindow}{wxwindow}\\
83\helpref{wxEvtHandler}{wxevthandler}\\
84\helpref{wxObject}{wxobject}
85
86\wxheading{Include files}
87
88<wx/textctrl.h>
89
90\wxheading{Window styles}
91
92\twocolwidtha{5cm}
93\begin{twocollist}\itemsep=0pt
94\twocolitem{\windowstyle{wxTE\_PROCESS\_ENTER}}{The control will generate
95the message wxEVENT\_TYPE\_TEXT\_ENTER\_COMMAND (otherwise pressing <Enter> is
96either processed internally by the control or used for navigation between
97dialog controls).}
98\twocolitem{\windowstyle{wxTE\_PROCESS\_TAB}}{The control will receive
99EVT\_CHAR messages for TAB pressed - normally, TAB is used for passing to the
100next control in a dialog instead. For the control created with this style,
101you can still use Ctrl-Enter to pass to the next control from the keyboard.}
102\twocolitem{\windowstyle{wxTE\_MULTILINE}}{The text control allows multiple lines.}
103\twocolitem{\windowstyle{wxTE\_PASSWORD}}{The text will be echoed as asterisks.}
104\twocolitem{\windowstyle{wxTE\_READONLY}}{The text will not be user-editable.}
105\twocolitem{\windowstyle{wxTE\_RICH}}{Use rich text control under Win32, this
106allows to have more than 64Kb of text in the control even under Win9x. This
107style is ignored under other platforms.}
108\twocolitem{\windowstyle{wxTE\_RICH2}}{Use rich text control version 2.0 or 3.0
109under Win32, this style is ignored under other platforms}
110\twocolitem{\windowstyle{wxTE\_AUTO\_URL}}{Highlight the URLs and generate the
111wxTextUrlEvents when mouse events occur over them. This style is supported
112under Win32 only and requires wxTE\_RICH.}
113\twocolitem{\windowstyle{wxTE\_NOHIDESEL}}{By default, the Windows text control
114doesn't show the selection when it doesn't have focus - use this style to force
115it to always show it. It doesn't do anything under other platforms.}
116\twocolitem{\windowstyle{wxHSCROLL}}{A horizontal scrollbar will be created. No effect under GTK+.}
117\twocolitem{\windowstyle{wxTE\_DONTWRAP}}{Same as {\tt wxHSCROLL} style.}
118\twocolitem{\windowstyle{wxTE\_LINEWRAP}}{Wrap the lines too long to be shown entirely at any position (wxUniv only currently)}
119\twocolitem{\windowstyle{wxTE\_WORDWRAP}}{Wrap the lines too long to be shown entirely at word boundaries only (wxUniv only currently)}
120\end{twocollist}
121
122See also \helpref{window styles overview}{windowstyles} and
123\helpref{wxTextCtrl::wxTextCtrl}{wxtextctrlconstr}.
124
125\wxheading{wxTextCtrl styles}
126
127Multi-line text controls support the styles, i.e. provide a possibility to set
128colours and font for individual characters in it (note that under Windows {\tt
129wxTE\_RICH} style is required for style support). To use the styles you can
130either call \helpref{SetDefaultStyle}{wxtextctrlsetdefaultstyle} before
131inserting the text or call \helpref{SetStyle}{wxtextctrlsetstyle} later to
132change the style of the text already in the control (the first solution is
133much more efficient).
134
135In either case, if the style doesn't specify some of the attributes (for
136example you only want to set the text colour but without changing the font nor
137the text background), the values of the default style will be used for them.
138If there is no default style, the attributes of the text control itself are
139used.
140
141So the following code correctly describes what it does: the second call
142to \helpref{SetDefaultStyle}{wxtextctrlsetdefaultstyle} doesn't change the
143text foreground colour (which stays red) while the last one doesn't change the
144background colour (which stays grey):
145
146{\small%
147\begin{verbatim}
148 text->SetDefaultStyle(wxTextAttr(*wxRED));
149 text->AppendText("Red text\n");
150 text->SetDefaultStyle(wxTextAttr(wxNullColour, *wxLIGHT_GREY));
151 text->AppendText("Red on grey text\n");
152 text->SetDefaultStyle(wxTextAttr(*wxBLUE);
153 text->AppendText("Blue on grey text\n");
154\end{verbatim}
155}%
156
157\wxheading{wxTextCtrl and C++ streams}
158
159This class multiply-inherits from {\bf streambuf} where compilers allow,
160allowing code such as the following:
161
162{\small%
163\begin{verbatim}
164 wxTextCtrl *control = new wxTextCtrl(...);
165
166 ostream stream(control)
167
168 stream << 123.456 << " some text\n";
169 stream.flush();
170\end{verbatim}
171}%
172
173If your compiler does not support derivation from {\bf streambuf} and gives a
174compile error, define the symbol {\bf NO\_TEXT\_WINDOW\_STREAM} in the
175wxTextCtrl header file.
176
177Note that independently of this setting you can always use wxTextCtrl itself
178in a stream-like manner:
179
180{\small%
181\begin{verbatim}
182 wxTextCtrl *control = new wxTextCtrl(...);
183
184 *control << 123.456 << " some text\n";
185\end{verbatim}
186}%
187
188always works. However the possibility to create an ostream associated with
189wxTextCtrl may be useful if you need to redirect the output of a function
190taking an ostream as parameter to a text control.
191
192Another commonly requested need is to redirect {\bf std::cout} to the text
193control. This could be done in the following way:
194
195{\small%
196\begin{verbatim}
197 #include <iostream>
198
199 wxTextCtrl *control = new wxTextCtrl(...);
200
201 std::streambuf *sbOld = std::cout.rdbuf();
202 std::cout.rdbuf(*control);
203
204 // use cout as usual, the output appears in the text control
205 ...
206
207 std::cout.rdbuf(sbOld);
208\end{verbatim}
209}%
210
211But wxWindows provides a convenient class to make it even simpler so instead
212you may just do
213
214{\small%
215\begin{verbatim}
216 #include <iostream>
217
218 wxTextCtrl *control = new wxTextCtrl(...);
219
220 wxStreamToTextRedirector redirect(control);
221
222 // all output to cout goes into the text control until the exit from current
223 // scope
224\end{verbatim}
225}%
226
227See \helpref{wxStreamToTextRedirector}{wxstreamtotextredirector} for more
228details.
229
230\wxheading{Event handling}
231
232The following commands are processed by default event handlers in wxTextCtrl: wxID\_CUT, wxID\_COPY,
233wxID\_PASTE, wxID\_UNDO, wxID\_REDO. The associated UI update events are also processed
234automatically, when the control has the focus.
235
236To process input from a text control, use these event handler macros to direct input to member
237functions that take a \helpref{wxCommandEvent}{wxcommandevent} argument.
238
239\twocolwidtha{7cm}%
240\begin{twocollist}\itemsep=0pt
241\twocolitem{{\bf EVT\_TEXT(id, func)}}{Respond to a wxEVT\_COMMAND\_TEXT\_UPDATED event,
242generated when the text changes. Notice that this event will always be sent
243when the text controls contents changes - whether this is due to user input or
244comes from the program itself (for example, if SetValue() is called)}
245\twocolitem{{\bf EVT\_TEXT\_ENTER(id, func)}}{Respond to a wxEVT\_COMMAND\_TEXT\_ENTER event,
246generated when enter is pressed in a single-line text control.}
247\twocolitem{{\bf EVT\_TEXT\_URL(id, func)}}{A mouse event occured over an URL
248in the text control (Win32 only)}
249\twocolitem{{\bf EVT\_TEXT\_MAXLEN(id, func)}}{User tried to enter more text
250into the control than the limit set by
251\helpref{SetMaxLength}{wxtextctrlsetmaxlength}.}
252\end{twocollist}%
253
254\latexignore{\rtfignore{\wxheading{Members}}}
255
256\membersection{wxTextCtrl::wxTextCtrl}\label{wxtextctrlconstr}
257
258\func{}{wxTextCtrl}{\void}
259
260Default constructor.
261
262\func{}{wxTextCtrl}{\param{wxWindow* }{parent}, \param{wxWindowID}{ id},\rtfsp
263\param{const wxString\& }{value = ``"}, \param{const wxPoint\& }{pos = wxDefaultPosition}, \param{const wxSize\& }{size = wxDefaultSize},\rtfsp
264\param{long}{ style = 0}, \param{const wxValidator\& }{validator = wxDefaultValidator}, \param{const wxString\& }{name = wxTextCtrlNameStr}}
265
266Constructor, creating and showing a text control.
267
268\wxheading{Parameters}
269
270\docparam{parent}{Parent window. Should not be NULL.}
271
272\docparam{id}{Control identifier. A value of -1 denotes a default value.}
273
274\docparam{value}{Default text value.}
275
276\docparam{pos}{Text control position.}
277
278\docparam{size}{Text control size.}
279
280\docparam{style}{Window style. See \helpref{wxTextCtrl}{wxtextctrl}.}
281
282\docparam{validator}{Window validator.}
283
284\docparam{name}{Window name.}
285
286\wxheading{Remarks}
287
288The horizontal scrollbar ({\bf wxHSCROLL} style flag) will only be created
289for multi-line text controls.
290Without a horizontal scrollbar, text lines that don't fit in the control's
291size will be wrapped (but no newline character is inserted). Single line
292controls don't have a horizontal scrollbar, the text is automatically scrolled
293so that the \helpref{insertion point}{wxtextctrlgetinsertionpoint} is always
294visible.
295
296% VZ: this is no longer true
297%Under Windows, if the {\bf wxTE\_MULTILINE} style is used, the window is implemented
298%as a Windows rich text control with unlimited capacity. Otherwise, normal edit control limits
299%apply.
300
301\wxheading{See also}
302
303\helpref{wxTextCtrl::Create}{wxtextctrlcreate}, \helpref{wxValidator}{wxvalidator}
304
305\membersection{wxTextCtrl::\destruct{wxTextCtrl}}
306
307\func{}{\destruct{wxTextCtrl}}{\void}
308
309Destructor, destroying the text control.
310
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
330\membersection{wxTextCtrl::CanCopy}\label{wxtextctrlcancopy}
331
332\func{virtual bool}{CanCopy}{\void}
333
334Returns {\tt TRUE} if the selection can be copied to the clipboard.
335
336\membersection{wxTextCtrl::CanCut}\label{wxtextctrlcancut}
337
338\func{virtual bool}{CanCut}{\void}
339
340Returns {\tt TRUE} if the selection can be cut to the clipboard.
341
342\membersection{wxTextCtrl::CanPaste}\label{wxtextctrlcanpaste}
343
344\func{virtual bool}{CanPaste}{\void}
345
346Returns {\tt TRUE} if the contents of the clipboard can be pasted into the
347text control. On some platforms (Motif, GTK) this is an approximation
348and returns {\tt TRUE} if the control is editable, {\tt FALSE} otherwise.
349
350\membersection{wxTextCtrl::CanRedo}\label{wxtextctrlcanredo}
351
352\func{virtual bool}{CanRedo}{\void}
353
354Returns {\tt TRUE} if there is a redo facility available and the last operation
355can be redone.
356
357\membersection{wxTextCtrl::CanUndo}\label{wxtextctrlcanundo}
358
359\func{virtual bool}{CanUndo}{\void}
360
361Returns {\tt TRUE} if there is an undo facility available and the last operation
362can be undone.
363
364\membersection{wxTextCtrl::Clear}\label{wxtextctrlclear}
365
366\func{virtual void}{Clear}{\void}
367
368Clears the text in the control.
369
370Note that this function will generate a {\tt wxEVT\_COMMAND\_TEXT\_UPDATED}
371event.
372
373\membersection{wxTextCtrl::Copy}\label{wxtextctrlcopy}
374
375\func{virtual void}{Copy}{\void}
376
377Copies the selected text to the clipboard under Motif and MS Windows.
378
379\membersection{wxTextCtrl::Create}\label{wxtextctrlcreate}
380
381\func{bool}{Create}{\param{wxWindow* }{parent}, \param{wxWindowID}{ id},\rtfsp
382\param{const wxString\& }{value = ``"}, \param{const wxPoint\& }{pos = wxDefaultPosition}, \param{const wxSize\& }{size = wxDefaultSize},\rtfsp
383\param{long}{ style = 0}, \param{const wxValidator\& }{validator = wxDefaultValidator}, \param{const wxString\& }{name = wxTextCtrlNameStr}}
384
385Creates the text control for two-step construction. Derived classes
386should call or replace this function. See \helpref{wxTextCtrl::wxTextCtrl}{wxtextctrlconstr}\rtfsp
387for further details.
388
389\membersection{wxTextCtrl::Cut}\label{wxtextctrlcut}
390
391\func{virtual void}{Cut}{\void}
392
393Copies the selected text to the clipboard and removes the selection.
394
395\membersection{wxTextCtrl::DiscardEdits}
396
397\func{void}{DiscardEdits}{\void}
398
399Resets the internal `modified' flag as if the current edits had been saved.
400
401\membersection{wxTextCtrl::EmulateKeyPress}
402
403\func{bool}{EmulateKeyPress}{\param{const wxKeyEvent\& }{event}}
404
405This functions inserts into the control the character which would have been
406inserted if the given key event had occured in the text control. The
407{\it event} object should be the same as the one passed to {\tt EVT\_KEY\_DOWN}
408handler previously by wxWindows.
409
410\wxheading{Return value}
411
412{\tt TRUE} if the event resulted in a change to the control, {\tt FALSE}
413otherwise.
414
415\membersection{wxTextCtrl::GetDefaultStyle}\label{wxtextctrlgetdefaultstyle}
416
417\constfunc{const wxTextAttr\& }{GetDefaultStyle}{\void}
418
419Returns the style currently used for the new text.
420
421\wxheading{See also}
422
423\helpref{SetDefaultStyle}{wxtextctrlsetdefaultstyle}
424
425\membersection{wxTextCtrl::GetInsertionPoint}\label{wxtextctrlgetinsertionpoint}
426
427\constfunc{virtual long}{GetInsertionPoint}{\void}
428
429Returns the insertion point. This is defined as the zero based index of the
430character position to the right of the insertion point. For example, if
431the insertion point is at the end of the text control, it is equal to
432both \helpref{GetValue()}{wxtextctrlgetvalue}.Length() and
433\helpref{GetLastPosition()}{wxtextctrlgetlastposition}.
434
435The following code snippet safely returns the character at the insertion
436point or the zero character if the point is at the end of the control.
437
438{\small%
439\begin{verbatim}
440 char GetCurrentChar(wxTextCtrl *tc) {
441 if (tc->GetInsertionPoint() == tc->GetLastPosition())
442 return '\0';
443 return tc->GetValue[tc->GetInsertionPoint()];
444 }
445\end{verbatim}
446}%
447
448\membersection{wxTextCtrl::GetLastPosition}\label{wxtextctrlgetlastposition}
449
450\constfunc{virtual long}{GetLastPosition}{\void}
451
452Returns the zero based index of the last position in the text control,
453which is equal to the number of characters in the control.
454
455\membersection{wxTextCtrl::GetLineLength}\label{wxtextctrlgetlinelength}
456
457\constfunc{int}{GetLineLength}{\param{long}{ lineNo}}
458
459Gets the length of the specified line, not including any trailing newline
460character(s).
461
462\wxheading{Parameters}
463
464\docparam{lineNo}{Line number (starting from zero).}
465
466\wxheading{Return value}
467
468The length of the line, or -1 if {\it lineNo} was invalid.
469
470\membersection{wxTextCtrl::GetLineText}\label{wxtextctrlgetlinetext}
471
472\constfunc{wxString}{GetLineText}{\param{long}{ lineNo}}
473
474Returns the contents of a given line in the text control, not including
475any trailing newline character(s).
476
477\wxheading{Parameters}
478
479\docparam{lineNo}{The line number, starting from zero.}
480
481\wxheading{Return value}
482
483The contents of the line.
484
485\membersection{wxTextCtrl::GetNumberOfLines}\label{wxtextctrlgetnumberoflines}
486
487\constfunc{int}{GetNumberOfLines}{\void}
488
489Returns the number of lines in the text control buffer.
490
491\wxheading{Remarks}
492
493Note that even empty text controls have one line (where the insertion point
494is), so GetNumberOfLines() never returns 0.
495
496For gtk\_text (multi-line) controls, the number of lines is
497calculated by actually counting newline characters in the buffer. You
498may wish to avoid using functions that work with line numbers if you are
499working with controls that contain large amounts of text.
500
501\membersection{wxTextCtrl::GetRange}\label{wxtextctrlgetrange}
502
503\constfunc{virtual wxString}{GetRange}{\param{long}{ from}, \param{long}{ to}}
504
505Returns the string containing the text staring in the positions {\it from} and
506up to {\it to} in the control. The positions must have been returned by another
507wxTextCtrl method.
508
509Please note that the positions in a multiline wxTextCtrl do {\bf not}
510correspond to the indices in the string returned by
511\helpref{GetValue}{wxtextctrlgetvalue} because of the different new line
512representations ({\tt CR} or {\tt CR LF}) and so this method should be used to
513obtain the correct results instead of extracting parts of the entire value. It
514may also be more efficient, especially if the control contains a lot of data.
515
516\membersection{wxTextCtrl::GetSelection}\label{wxtextctrlgetselection}
517
518\constfunc{virtual void}{GetSelection}{\param{long*}{ from}, \param{long*}{ to}}
519
520Gets the current selection span. If the returned values are equal, there was
521no selection.
522
523Please note that the indices returned may be used with the other wxTextctrl
524methods but don't necessarily represent the correct indices into the string
525returned by \helpref{GetValue()}{wxtextctrlgetvalue} for multiline controls
526under Windows (at least,) you should use
527\helpref{GetStringSelection()}{wxtextctrlgetstringselection} to get the selected
528text.
529
530\wxheading{Parameters}
531
532\docparam{from}{The returned first position.}
533
534\docparam{to}{The returned last position.}
535
536\pythonnote{The wxPython version of this method returns a tuple
537consisting of the from and to values.}
538
539\perlnote{In wxPerl this method takes no parameter and returns a
5402-element list {\tt ( from, to )}.}
541
542\membersection{wxTextCtrl::GetStringSelection}\label{wxtextctrlgetstringselection}
543
544\func{virtual wxString}{GetStringSelection}{\void}
545
546Gets the text currently selected in the control. If there is no selection, the
547returned string is empty.
548
549\membersection{wxTextCtrl::GetValue}\label{wxtextctrlgetvalue}
550
551\constfunc{wxString}{GetValue}{\void}
552
553Gets the contents of the control. Notice that for a multiline text control,
554the lines will be separated by (Unix-style) $\backslash$n characters, even under
555Windows where they are separated by a $\backslash$r$\backslash$n sequence in the native control.
556
557\membersection{wxTextCtrl::IsEditable}\label{wxtextctrliseditable}
558
559\constfunc{bool}{IsEditable}{\void}
560
561Returns {\tt TRUE} if the controls contents may be edited by user (note that it
562always can be changed by the program), i.e. if the control hasn't been put in
563read-only mode by a previous call to
564\helpref{SetEditable}{wxtextctrlseteditable}.
565
566\membersection{wxTextCtrl::IsModified}\label{wxtextctrlismodified}
567
568\constfunc{bool}{IsModified}{\void}
569
570Returns {\tt TRUE} if the text has been modified by user. Note that calling
571\helpref{SetValue}{wxtextctrlsetvalue} doesn't make the control modified.
572
573\membersection{wxTextCtrl::IsMultiLine}\label{wxtextctrlismultiline}
574
575\constfunc{bool}{IsMultiLine}{\void}
576
577Returns {\tt TRUE} if this is a multi line edit control and {\tt FALSE}
578otherwise.
579
580\wxheading{See also}
581
582\helpref{IsSingleLine}{wxtextctrlissingleline}
583
584\membersection{wxTextCtrl::IsSingleLine}\label{wxtextctrlissingleline}
585
586\constfunc{bool}{IsSingleLine}{\void}
587
588Returns {\tt TRUE} if this is a single line edit control and {\tt FALSE}
589otherwise.
590
591\wxheading{See also}
592
593\helpref{IsMultiLine}{wxtextctrlissingleline}
594
595\membersection{wxTextCtrl::LoadFile}\label{wxtextctrlloadfile}
596
597\func{bool}{LoadFile}{\param{const wxString\& }{ filename}}
598
599Loads and displays the named file, if it exists.
600
601\wxheading{Parameters}
602
603\docparam{filename}{The filename of the file to load.}
604
605\wxheading{Return value}
606
607{\tt TRUE} if successful, {\tt FALSE} otherwise.
608
609% VZ: commenting this out as: (a) the docs are wrong (you can't replace
610% anything), (b) wxTextCtrl doesn't have any OnChar() anyhow
611%% \membersection{wxTextCtrl::OnChar}\label{wxtextctrlonchar}
612%%
613%% \func{void}{OnChar}{\param{wxKeyEvent\& }{event}}
614%%
615%% Default handler for character input.
616%%
617%% \wxheading{Remarks}
618%%
619%% It is possible to intercept character
620%% input by overriding this member. Call this function
621%% to let the default behaviour take place; not calling
622%% it results in the character being ignored. You can
623%% replace the {\it keyCode} member of {\it event} to
624%% translate keystrokes.
625%%
626%% Note that Windows and Motif have different ways
627%% of implementing the default behaviour. In Windows,
628%% calling wxTextCtrl::OnChar immediately
629%% processes the character. In Motif,
630%% calling this function simply sets a flag
631%% to let default processing happen. This might affect
632%% the way in which you write your OnChar function
633%% on different platforms.
634%%
635%% \wxheading{See also}
636%%
637%% \helpref{wxKeyEvent}{wxkeyevent}
638
639\membersection{wxTextCtrl::OnDropFiles}\label{wxtextctrlondropfiles}
640
641\func{void}{OnDropFiles}{\param{wxDropFilesEvent\& }{event}}
642
643This event handler function implements default drag and drop behaviour, which
644is to load the first dropped file into the control.
645
646\wxheading{Parameters}
647
648\docparam{event}{The drop files event.}
649
650\wxheading{Remarks}
651
652This is not implemented on non-Windows platforms.
653
654\wxheading{See also}
655
656\helpref{wxDropFilesEvent}{wxdropfilesevent}
657
658\membersection{wxTextCtrl::Paste}\label{wxtextctrlpaste}
659
660\func{virtual void}{Paste}{\void}
661
662Pastes text from the clipboard to the text item.
663
664\membersection{wxTextCtrl::PositionToXY}\label{wxtextctrlpositiontoxy}
665
666\constfunc{bool}{PositionToXY}{\param{long }{pos}, \param{long *}{x}, \param{long *}{y}}
667
668Converts given position to a zero-based column, line number pair.
669
670\wxheading{Parameters}
671
672\docparam{pos}{Position.}
673
674\docparam{x}{Receives zero based column number.}
675
676\docparam{y}{Receives zero based line number.}
677
678\wxheading{Return value}
679
680{\tt TRUE} on success, {\tt FALSE} on failure (most likely due to a too large position
681parameter).
682
683\wxheading{See also}
684
685\helpref{wxTextCtrl::XYToPosition}{wxtextctrlxytoposition}
686
687\pythonnote{In Python, PositionToXY() returns a tuple containing the x and
688y values, so (x,y) = PositionToXY() is equivalent to the call described
689above.}
690
691\perlnote{In wxPerl this method only takes the {\tt pos} parameter, and
692returns a 2-element list {\tt ( x, y )}.}
693
694\membersection{wxTextCtrl::Redo}\label{wxtextctrlredo}
695
696\func{virtual void}{Redo}{\void}
697
698If there is a redo facility and the last operation can be redone, redoes the last operation. Does nothing
699if there is no redo facility.
700
701\membersection{wxTextCtrl::Remove}\label{wxtextctrlremove}
702
703\func{virtual void}{Remove}{\param{long}{ from}, \param{long}{ to}}
704
705Removes the text starting at the first given position up to (but not including)
706the character at the last position.
707
708\wxheading{Parameters}
709
710\docparam{from}{The first position.}
711
712\docparam{to}{The last position.}
713
714\membersection{wxTextCtrl::Replace}\label{wxtextctrlreplace}
715
716\func{virtual void}{Replace}{\param{long}{ from}, \param{long}{ to}, \param{const wxString\& }{value}}
717
718Replaces the text starting at the first position up to (but not including)
719the character at the last position with the given text.
720
721\wxheading{Parameters}
722
723\docparam{from}{The first position.}
724
725\docparam{to}{The last position.}
726
727\docparam{value}{The value to replace the existing text with.}
728
729\membersection{wxTextCtrl::SaveFile}\label{wxtextctrlsavefile}
730
731\func{bool}{SaveFile}{\param{const wxString\& }{ filename}}
732
733Saves the contents of the control in a text file.
734
735\wxheading{Parameters}
736
737\docparam{filename}{The name of the file in which to save the text.}
738
739\wxheading{Return value}
740
741{\tt TRUE} if the operation was successful, {\tt FALSE} otherwise.
742
743\membersection{wxTextCtrl::SetDefaultStyle}\label{wxtextctrlsetdefaultstyle}
744
745\func{bool}{SetDefaultStyle}{\param{const wxTextAttr\& }{style}}
746
747Changes the default style to use for the new text which is going to be added
748to the control using \helpref{WriteText}{wxtextctrlwritetext} or\rtfsp
749\helpref{AppendText}{wxtextctrlappendtext}.
750
751If either of the font, foreground, or background colour is not set in\rtfsp
752{\it style}, the values of the previous default style are used for them. If
753the previous default style didn't set them neither, the global font or colours
754of the text control itself are used as fall back.
755
756However if the {\it style} parameter is the default wxTextAttr, then the
757default style is just reset (instead of being combined with the new style which
758wouldn't change it at all).
759
760\wxheading{Parameters}
761
762\docparam{style}{The style for the new text.}
763
764\wxheading{Return value}
765
766{\tt TRUE} on success, {\tt FALSE} if an error occured - may also mean that
767the styles are not supported under this platform.
768
769\wxheading{See also}
770
771\helpref{GetDefaultStyle}{wxtextctrlgetdefaultstyle}
772
773\membersection{wxTextCtrl::SetEditable}\label{wxtextctrlseteditable}
774
775\func{virtual void}{SetEditable}{\param{const bool}{ editable}}
776
777Makes the text item editable or read-only, overriding the {\bf wxTE\_READONLY} flag.
778
779\wxheading{Parameters}
780
781\docparam{editable}{If {\tt TRUE}, the control is editable. If {\tt FALSE}, the control is read-only.}
782
783\wxheading{See also}
784
785\helpref{IsEditable}{wxtextctrliseditable}
786
787\membersection{wxTextCtrl::SetInsertionPoint}\label{wxtextctrlsetinsertionpoint}
788
789\func{virtual void}{SetInsertionPoint}{\param{long}{ pos}}
790
791Sets the insertion point at the given position.
792
793\wxheading{Parameters}
794
795\docparam{pos}{Position to set.}
796
797\membersection{wxTextCtrl::SetInsertionPointEnd}\label{wxtextctrlsetinsertionpointend}
798
799\func{virtual void}{SetInsertionPointEnd}{\void}
800
801Sets the insertion point at the end of the text control. This is equivalent
802to \helpref{SetInsertionPoint}{wxtextctrlsetinsertionpoint}(\helpref{GetLastPosition}{wxtextctrlgetlastposition}()).
803
804\membersection{wxTextCtrl::SetMaxLength}\label{wxtextctrlsetmaxlength}
805
806\func{virtual void}{SetMaxLength}{\param{unsigned long }{len}}
807
808This function sets the maximum number of characters the user can enter into the
809control. In other words, it allows to limit the text value length to {\it len}
810not counting the terminating {\tt NUL} character.
811
812If {\it len} is $0$, the previously set max length limit, if any, is discarded
813and the user may enter as much text as the underlying native text control
814widget supports (typically at least 32Kb).
815
816If the user tries to enter more characters into the text control when it
817already is filled up to the maximal length, a
818{\tt wxEVT\_COMMAND\_TEXT\_MAXLEN} event is sent to notify the program about it
819(giving it the possibility to show an explanatory message, for example) and the
820extra input is discarded.
821
822Note that this function may only be used with single line text controls.
823
824\wxheading{Compatibility}
825
826Only implemented in wxMSW/wxGTK starting with wxWindows 2.3.2.
827
828\membersection{wxTextCtrl::SetSelection}\label{wxtextctrlsetselection}
829
830\func{virtual void}{SetSelection}{\param{long}{ from}, \param{long}{ to}}
831
832Selects the text starting at the first position up to (but not including) the character at the last position.
833
834\wxheading{Parameters}
835
836\docparam{from}{The first position.}
837
838\docparam{to}{The last position.}
839
840\membersection{wxTextCtrl::SetStyle}\label{wxtextctrlsetstyle}
841
842\func{bool}{SetStyle}{\param{long }{start}, \param{long }{end}, \param{const wxTextAttr\& }{style}}
843
844Changes the style of the selection. If either of the font, foreground, or
845background colour is not set in {\it style}, the values of\rtfsp
846\helpref{GetDefaultStyle()}{wxtextctrlgetdefaultstyle} are used.
847
848\wxheading{Parameters}
849
850\docparam{start}{The start of selection to change.}
851
852\docparam{end}{The end of selection to change.}
853
854\docparam{style}{The new style for the selection.}
855
856\wxheading{Return value}
857
858{\tt TRUE} on success, {\tt FALSE} if an error occured - may also mean that
859the styles are not supported under this platform.
860
861\membersection{wxTextCtrl::SetValue}\label{wxtextctrlsetvalue}
862
863\func{virtual void}{SetValue}{\param{const wxString\& }{ value}}
864
865Sets the text value and marks the control as not-modified (which means that
866\helpref{IsModified}{wxtextctrlismodified} would return {\tt FALSE} immediately
867after the call to SetValue).
868
869Note that this function will generate a {\tt wxEVT\_COMMAND\_TEXT\_UPDATED}
870event.
871
872\wxheading{Parameters}
873
874\docparam{value}{The new value to set. It may contain newline characters if the text control is multi-line.}
875
876\membersection{wxTextCtrl::ShowPosition}\label{wxtextctrlshowposition}
877
878\func{void}{ShowPosition}{\param{long}{ pos}}
879
880Makes the line containing the given position visible.
881
882\wxheading{Parameters}
883
884\docparam{pos}{The position that should be visible.}
885
886\membersection{wxTextCtrl::Undo}\label{wxtextctrlundo}
887
888\func{virtual void}{Undo}{\void}
889
890If there is an undo facility and the last operation can be undone, undoes the last operation. Does nothing
891if there is no undo facility.
892
893\membersection{wxTextCtrl::WriteText}\label{wxtextctrlwritetext}
894
895\func{void}{WriteText}{\param{const wxString\& }{ text}}
896
897Writes the text into the text control at the current insertion position.
898
899\wxheading{Parameters}
900
901\docparam{text}{Text to write to the text control.}
902
903\wxheading{Remarks}
904
905Newlines in the text string
906are the only control characters allowed, and they will cause appropriate
907line breaks. See \helpref{wxTextCtrl::\cinsert}{wxtextctrlinsert} and \helpref{wxTextCtrl::AppendText}{wxtextctrlappendtext} for more convenient ways of writing to the window.
908
909After 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.
910
911\membersection{wxTextCtrl::XYToPosition}\label{wxtextctrlxytoposition}
912
913\func{long}{XYToPosition}{\param{long}{ x}, \param{long}{ y}}
914
915Converts the given zero based column and line number to a position.
916
917\wxheading{Parameters}
918
919\docparam{x}{The column number.}
920
921\docparam{y}{The line number.}
922
923\wxheading{Return value}
924
925The position value.
926
927\membersection{wxTextCtrl::operator \cinsert}\label{wxtextctrlinsert}
928
929\func{wxTextCtrl\&}{operator \cinsert}{\param{const wxString\& }{s}}
930
931\func{wxTextCtrl\&}{operator \cinsert}{\param{int}{ i}}
932
933\func{wxTextCtrl\&}{operator \cinsert}{\param{long}{ i}}
934
935\func{wxTextCtrl\&}{operator \cinsert}{\param{float}{ f}}
936
937\func{wxTextCtrl\&}{operator \cinsert}{\param{double}{ d}}
938
939\func{wxTextCtrl\&}{operator \cinsert}{\param{char}{ c}}
940
941Operator definitions for appending to a text control, for example:
942
943\begin{verbatim}
944 wxTextCtrl *wnd = new wxTextCtrl(my_frame);
945
946 (*wnd) << "Welcome to text control number " << 1 << ".\n";
947\end{verbatim}
948