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