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