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