]> git.saurik.com Git - wxWidgets.git/blame - src/msw/textctrl.cpp
ScreenToClient() implemented correctly
[wxWidgets.git] / src / msw / textctrl.cpp
CommitLineData
2bda0e17
KB
1/////////////////////////////////////////////////////////////////////////////
2// Name: textctrl.cpp
3// Purpose: wxTextCtrl
4// Author: Julian Smart
5// Modified by:
6// Created: 04/01/98
7// RCS-ID: $Id$
8// Copyright: (c) Julian Smart and Markus Holzem
c085e333 9// Licence: wxWindows license
2bda0e17
KB
10/////////////////////////////////////////////////////////////////////////////
11
12#ifdef __GNUG__
13#pragma implementation "textctrl.h"
14#endif
15
16// For compilers that support precompilation, includes "wx.h".
17#include "wx/wxprec.h"
18
19#ifdef __BORLANDC__
20#pragma hdrstop
21#endif
22
23#ifndef WX_PRECOMP
24#include "wx/textctrl.h"
25#include "wx/settings.h"
2432b92d
JS
26#include "wx/brush.h"
27#include "wx/utils.h"
28#include "wx/log.h"
2bda0e17
KB
29#endif
30
47d67540 31#if wxUSE_CLIPBOARD
2bda0e17
KB
32#include "wx/app.h"
33#include "wx/clipbrd.h"
34#endif
35
36#include "wx/msw/private.h"
37
38#include <windows.h>
39#include <stdlib.h>
fbc535ff
JS
40
41#if wxUSE_IOSTREAMH
3f4a0c5b 42# include <fstream.h>
fbc535ff 43#else
3f4a0c5b 44# include <fstream>
fbc535ff 45#endif
2bda0e17
KB
46
47#include <sys/types.h>
17dff81c 48#ifndef __MWERKS__
2bda0e17 49#include <sys/stat.h>
17dff81c
SC
50#else
51#include <stat.h>
52#endif
2bda0e17
KB
53#if defined(__BORLANDC__) && !defined(__WIN32__)
54#include <alloc.h>
55#else
ce3ed50d 56#if !defined(__GNUWIN32__) && !defined(__SALFORDC__)
2bda0e17
KB
57#include <malloc.h>
58#endif
59#define farmalloc malloc
60#define farfree free
61#endif
62#include <windowsx.h>
63
64#include <string.h>
65
57c208c5 66#if wxUSE_RICHEDIT && !defined(__GNUWIN32__)
cd471848 67 #include <richedit.h>
2bda0e17
KB
68#endif
69
70#if !USE_SHARED_LIBRARY
e702ff0f 71
2bda0e17
KB
72IMPLEMENT_DYNAMIC_CLASS(wxTextCtrl, wxControl)
73
74BEGIN_EVENT_TABLE(wxTextCtrl, wxControl)
c085e333
VZ
75 EVT_CHAR(wxTextCtrl::OnChar)
76 EVT_DROP_FILES(wxTextCtrl::OnDropFiles)
e702ff0f
JS
77
78 EVT_MENU(wxID_CUT, wxTextCtrl::OnCut)
79 EVT_MENU(wxID_COPY, wxTextCtrl::OnCopy)
80 EVT_MENU(wxID_PASTE, wxTextCtrl::OnPaste)
81 EVT_MENU(wxID_UNDO, wxTextCtrl::OnUndo)
82 EVT_MENU(wxID_REDO, wxTextCtrl::OnRedo)
83
84 EVT_UPDATE_UI(wxID_CUT, wxTextCtrl::OnUpdateCut)
85 EVT_UPDATE_UI(wxID_COPY, wxTextCtrl::OnUpdateCopy)
86 EVT_UPDATE_UI(wxID_PASTE, wxTextCtrl::OnUpdatePaste)
87 EVT_UPDATE_UI(wxID_UNDO, wxTextCtrl::OnUpdateUndo)
88 EVT_UPDATE_UI(wxID_REDO, wxTextCtrl::OnUpdateRedo)
2bda0e17 89END_EVENT_TABLE()
e702ff0f 90
cd471848 91#endif // USE_SHARED_LIBRARY
2bda0e17
KB
92
93// Text item
cd471848 94wxTextCtrl::wxTextCtrl()
2bda0e17 95#ifndef NO_TEXT_WINDOW_STREAM
cd471848 96 : streambuf()
2bda0e17
KB
97#endif
98{
cd471848 99#if wxUSE_RICHEDIT
2bda0e17 100 m_isRich = FALSE;
cd471848 101#endif
2bda0e17
KB
102}
103
debe6624 104bool wxTextCtrl::Create(wxWindow *parent, wxWindowID id,
c085e333
VZ
105 const wxString& value,
106 const wxPoint& pos,
107 const wxSize& size, long style,
108 const wxValidator& validator,
109 const wxString& name)
2bda0e17 110{
2bda0e17
KB
111 SetName(name);
112 SetValidator(validator);
113 if (parent) parent->AddChild(this);
114
115 m_windowStyle = style;
116
117 // Should this be taken from the system colours?
118// SetBackgroundColour(wxColour(255, 255, 255));
119
120 SetBackgroundColour(wxSystemSettings::GetSystemColour(wxSYS_COLOUR_WINDOW));
121
fd71308f 122 SetForegroundColour(parent->GetForegroundColour()) ;
2bda0e17
KB
123
124 if ( id == -1 )
c085e333 125 m_windowId = (int)NewControlId();
2bda0e17 126 else
c085e333 127 m_windowId = id;
2bda0e17
KB
128
129 int x = pos.x;
130 int y = pos.y;
131 int width = size.x;
132 int height = size.y;
133
2bda0e17
KB
134 long msStyle = ES_LEFT | WS_VISIBLE | WS_CHILD | WS_TABSTOP;
135 if (m_windowStyle & wxTE_MULTILINE)
cd471848 136 {
5fb9fcfc
VZ
137 wxASSERT_MSG( !(m_windowStyle & wxTE_PROCESS_ENTER),
138 "wxTE_PROCESS_ENTER style is ignored for multiline controls" );
139
cd471848
VZ
140 msStyle |= ES_MULTILINE | ES_WANTRETURN | WS_VSCROLL ; // WS_BORDER
141 m_windowStyle |= wxTE_PROCESS_ENTER;
142 }
2bda0e17
KB
143 else
144 msStyle |= ES_AUTOHSCROLL ;
145
146 if (m_windowStyle & wxTE_READONLY)
147 msStyle |= ES_READONLY;
148
149 if (m_windowStyle & wxHSCROLL)
150 msStyle |= (WS_HSCROLL | ES_AUTOHSCROLL) ;
151 if (m_windowStyle & wxTE_PASSWORD) // hidden input
152 msStyle |= ES_PASSWORD;
153
cd471848
VZ
154 const char *windowClass = "EDIT";
155
57c208c5 156#if wxUSE_RICHEDIT
2bda0e17 157 if ( m_windowStyle & wxTE_MULTILINE )
2bda0e17 158 {
c085e333
VZ
159 msStyle |= ES_AUTOVSCROLL;
160 m_isRich = TRUE;
161 windowClass = "RichEdit" ;
2bda0e17
KB
162 }
163 else
c085e333 164 m_isRich = FALSE;
cd471848 165#endif
2bda0e17
KB
166
167 bool want3D;
168 WXDWORD exStyle = Determine3DEffects(WS_EX_CLIENTEDGE, &want3D) ;
169
170 // If we're in Win95, and we want a simple 2D border,
171 // then make it an EDIT control instead.
57c208c5 172#if wxUSE_RICHEDIT
2bda0e17
KB
173 if (m_windowStyle & wxSIMPLE_BORDER)
174 {
175 windowClass = "EDIT";
cd471848 176 m_isRich = FALSE;
2bda0e17
KB
177 }
178#endif
179
180 // Even with extended styles, need to combine with WS_BORDER
181 // for them to look right.
c085e333 182 if ( want3D || wxStyleHasBorder(m_windowStyle) )
2bda0e17
KB
183 msStyle |= WS_BORDER;
184
c085e333 185 m_hWnd = (WXHWND)::CreateWindowEx(exStyle, windowClass, NULL,
2bda0e17
KB
186 msStyle,
187 0, 0, 0, 0, (HWND) ((wxWindow*)parent)->GetHWND(), (HMENU)m_windowId,
cd471848 188 wxGetInstance(), NULL);
2bda0e17 189
c085e333
VZ
190 wxCHECK_MSG( m_hWnd, FALSE, "Failed to create text ctrl" );
191
1f112209 192#if wxUSE_CTL3D
2bda0e17
KB
193 if ( want3D )
194 {
c085e333
VZ
195 Ctl3dSubclassCtl((HWND)m_hWnd);
196 m_useCtl3D = TRUE;
2bda0e17
KB
197 }
198#endif
199
57c208c5 200#if wxUSE_RICHEDIT
2bda0e17
KB
201 if (m_isRich)
202 {
c085e333
VZ
203 // Have to enable events
204 ::SendMessage((HWND)m_hWnd, EM_SETEVENTMASK, 0,
205 ENM_CHANGE | ENM_DROPFILES | ENM_SELCHANGE | ENM_UPDATE);
2bda0e17
KB
206 }
207#endif
208
209 SubclassWin(GetHWND());
210
c0ed460c 211 if ( parent->GetFont().Ok() && parent->GetFont().Ok() )
2bda0e17 212 {
c0ed460c 213 SetFont(parent->GetFont());
2bda0e17
KB
214 }
215 else
216 {
c085e333 217 SetFont(wxSystemSettings::GetSystemFont(wxSYS_SYSTEM_FONT));
2bda0e17
KB
218 }
219
220 SetSize(x, y, width, height);
221
222 // Causes a crash for Symantec C++ and WIN32 for some reason
223#if !(defined(__SC__) && defined(__WIN32__))
c085e333
VZ
224 if ( !value.IsEmpty() )
225 {
226 SetValue(value);
227 }
2bda0e17
KB
228#endif
229
230 return TRUE;
231}
232
233// Make sure the window style (etc.) reflects the HWND style (roughly)
cd471848 234void wxTextCtrl::AdoptAttributesFromHWND()
2bda0e17 235{
c085e333 236 wxWindow::AdoptAttributesFromHWND();
2bda0e17 237
c085e333
VZ
238 HWND hWnd = (HWND) GetHWND();
239 long style = GetWindowLong((HWND) hWnd, GWL_STYLE);
2bda0e17 240
cd471848
VZ
241 // retrieve the style to see whether this is an edit or richedit ctrl
242#if wxUSE_RICHEDIT
243 char buf[256];
2bda0e17
KB
244
245#ifndef __WIN32__
c085e333 246 GetClassName((HWND) hWnd, buf, 256);
2bda0e17
KB
247#else
248#ifdef UNICODE
c085e333 249 GetClassNameW((HWND) hWnd, buf, 256);
57c208c5
JS
250#else
251#ifdef __TWIN32__
252 GetClassName((HWND) hWnd, buf, 256);
2bda0e17 253#else
c085e333 254 GetClassNameA((HWND) hWnd, buf, 256);
2bda0e17 255#endif
57c208c5 256#endif
2bda0e17
KB
257#endif
258
c085e333
VZ
259 wxString str(buf);
260 str.UpperCase();
261
262 if (str == "EDIT")
263 m_isRich = FALSE;
264 else
265 m_isRich = TRUE;
cd471848 266#endif
c085e333
VZ
267
268 if (style & ES_MULTILINE)
269 m_windowStyle |= wxTE_MULTILINE;
270 if (style & ES_PASSWORD)
271 m_windowStyle |= wxTE_PASSWORD;
272 if (style & ES_READONLY)
273 m_windowStyle |= wxTE_READONLY;
274 if (style & ES_WANTRETURN)
275 m_windowStyle |= wxTE_PROCESS_ENTER;
2bda0e17
KB
276}
277
cd471848 278void wxTextCtrl::SetupColours()
2bda0e17
KB
279{
280 SetBackgroundColour(wxSystemSettings::GetSystemColour(wxSYS_COLOUR_WINDOW));
fd71308f 281 SetForegroundColour(GetParent()->GetForegroundColour());
2bda0e17
KB
282}
283
cd471848 284wxString wxTextCtrl::GetValue() const
2bda0e17
KB
285{
286 int length = GetWindowTextLength((HWND) GetHWND());
287 char *s = new char[length+1];
288 GetWindowText((HWND) GetHWND(), s, length+1);
289 wxString str(s);
290 delete[] s;
c085e333 291 return str;
2bda0e17
KB
292}
293
294void wxTextCtrl::SetValue(const wxString& value)
295{
296 // If newlines are denoted by just 10, must stick 13 in front.
297 int singletons = 0;
298 int len = value.Length();
299 int i;
300 for (i = 0; i < len; i ++)
301 {
302 if ((i > 0) && (value[i] == 10) && (value[i-1] != 13))
303 singletons ++;
304 }
305 if (singletons > 0)
306 {
307 char *tmp = new char[len + singletons + 1];
308 int j = 0;
309 for (i = 0; i < len; i ++)
310 {
311 if ((i > 0) && (value[i] == 10) && (value[i-1] != 13))
312 {
313 tmp[j] = 13;
314 j ++;
315 }
316 tmp[j] = value[i];
317 j ++;
318 }
319 tmp[j] = 0;
320 SetWindowText((HWND) GetHWND(), tmp);
321 delete[] tmp;
322 }
323 else
324 SetWindowText((HWND) GetHWND(), (const char *)value);
325}
326
bfc6fde4 327void wxTextCtrl::DoSetSize(int x, int y, int width, int height, int sizeFlags)
2bda0e17
KB
328{
329 int currentX, currentY;
330 GetPosition(&currentX, &currentY);
331 int x1 = x;
332 int y1 = y;
333 int w1 = width;
334 int h1 = height;
335
336 if (x == -1 || (sizeFlags & wxSIZE_ALLOW_MINUS_ONE))
337 x1 = currentX;
338 if (y == -1 || (sizeFlags & wxSIZE_ALLOW_MINUS_ONE))
339 y1 = currentY;
340
81d66cf3
JS
341 AdjustForParentClientOrigin(x1, y1, sizeFlags);
342
2bda0e17
KB
343 int cx; // button font dimensions
344 int cy;
345
ce3ed50d 346 wxGetCharSize(GetHWND(), &cx, &cy, & this->GetFont());
2bda0e17 347
1c4a764c 348 int control_width, control_height, control_x, control_y;
2bda0e17
KB
349
350 // If we're prepared to use the existing size, then...
351 if (width == -1 && height == -1 && ((sizeFlags & wxSIZE_AUTO) != wxSIZE_AUTO))
352 {
353 GetSize(&w1, &h1);
354 }
355
356 // Deal with default size (using -1 values)
357 if (w1<=0)
358 w1 = DEFAULT_ITEM_WIDTH;
359
1c4a764c
VZ
360 control_x = x1;
361 control_y = y1;
362 control_width = w1;
363 control_height = h1;
2bda0e17
KB
364
365 // Calculations may have made text size too small
366 if (control_height <= 0)
1c4a764c 367 control_height = EDIT_HEIGHT_FROM_CHAR_HEIGHT(cy);
2bda0e17
KB
368
369 if (control_width <= 0)
1c4a764c 370 control_width = DEFAULT_ITEM_WIDTH;
2bda0e17
KB
371
372 MoveWindow((HWND) GetHWND(), (int)control_x, (int)control_y,
373 (int)control_width, (int)control_height, TRUE);
2bda0e17
KB
374}
375
376// Clipboard operations
cd471848 377void wxTextCtrl::Copy()
2bda0e17 378{
e702ff0f
JS
379 if (CanCopy())
380 {
381 HWND hWnd = (HWND) GetHWND();
382 SendMessage(hWnd, WM_COPY, 0, 0L);
383 }
2bda0e17
KB
384}
385
cd471848 386void wxTextCtrl::Cut()
2bda0e17 387{
e702ff0f
JS
388 if (CanCut())
389 {
390 HWND hWnd = (HWND) GetHWND();
391 SendMessage(hWnd, WM_CUT, 0, 0L);
392 }
2bda0e17
KB
393}
394
cd471848 395void wxTextCtrl::Paste()
2bda0e17 396{
e702ff0f
JS
397 if (CanPaste())
398 {
399 HWND hWnd = (HWND) GetHWND();
400 SendMessage(hWnd, WM_PASTE, 0, 0L);
401 }
2bda0e17
KB
402}
403
debe6624 404void wxTextCtrl::SetEditable(bool editable)
2bda0e17
KB
405{
406 HWND hWnd = (HWND) GetHWND();
407 SendMessage(hWnd, EM_SETREADONLY, (WPARAM)!editable, (LPARAM)0L);
408}
409
debe6624 410void wxTextCtrl::SetInsertionPoint(long pos)
2bda0e17
KB
411{
412 HWND hWnd = (HWND) GetHWND();
413#ifdef __WIN32__
57c208c5 414#if wxUSE_RICHEDIT
2bda0e17
KB
415 if ( m_isRich)
416 {
417 CHARRANGE range;
418 range.cpMin = pos;
419 range.cpMax = pos;
420 SendMessage(hWnd, EM_EXSETSEL, 0, (LPARAM) &range);
421 SendMessage(hWnd, EM_SCROLLCARET, (WPARAM)0, (LPARAM)0);
422 }
423 else
424#endif
425 {
426 SendMessage(hWnd, EM_SETSEL, pos, pos);
427 SendMessage(hWnd, EM_SCROLLCARET, (WPARAM)0, (LPARAM)0);
428 }
429#else
430 SendMessage(hWnd, EM_SETSEL, 0, MAKELPARAM(pos, pos));
431#endif
432 char *nothing = "";
433 SendMessage(hWnd, EM_REPLACESEL, 0, (LPARAM)nothing);
434}
435
cd471848 436void wxTextCtrl::SetInsertionPointEnd()
2bda0e17
KB
437{
438 long pos = GetLastPosition();
439 SetInsertionPoint(pos);
440}
441
cd471848 442long wxTextCtrl::GetInsertionPoint() const
2bda0e17 443{
57c208c5 444#if wxUSE_RICHEDIT
2bda0e17
KB
445 if (m_isRich)
446 {
447 CHARRANGE range;
448 range.cpMin = 0;
449 range.cpMax = 0;
450 SendMessage((HWND) GetHWND(), EM_EXGETSEL, 0, (LPARAM) &range);
451 return range.cpMin;
452 }
453#endif
454
455 DWORD Pos=(DWORD)SendMessage((HWND) GetHWND(), EM_GETSEL, 0, 0L);
456 return Pos&0xFFFF;
457}
458
cd471848 459long wxTextCtrl::GetLastPosition() const
2bda0e17
KB
460{
461 HWND hWnd = (HWND) GetHWND();
462
463 // Will always return a number > 0 (according to docs)
464 int noLines = (int)SendMessage(hWnd, EM_GETLINECOUNT, (WPARAM)0, (LPARAM)0L);
465
466 // This gets the char index for the _beginning_ of the last line
467 int charIndex = (int)SendMessage(hWnd, EM_LINEINDEX, (WPARAM)(noLines-1), (LPARAM)0L);
39136494 468
2bda0e17
KB
469 // Get number of characters in the last line. We'll add this to the character
470 // index for the last line, 1st position.
471 int lineLength = (int)SendMessage(hWnd, EM_LINELENGTH, (WPARAM)charIndex, (LPARAM)0L);
472
473 return (long)(charIndex + lineLength);
474}
475
debe6624 476void wxTextCtrl::Replace(long from, long to, const wxString& value)
2bda0e17 477{
acbd13a3 478#if wxUSE_CLIPBOARD
2bda0e17
KB
479 HWND hWnd = (HWND) GetHWND();
480 long fromChar = from;
481 long toChar = to;
39136494 482
2bda0e17
KB
483 // Set selection and remove it
484#ifdef __WIN32__
485 SendMessage(hWnd, EM_SETSEL, fromChar, toChar);
486#else
487 SendMessage(hWnd, EM_SETSEL, (WPARAM)0, (LPARAM)MAKELONG(fromChar, toChar));
488#endif
489 SendMessage(hWnd, WM_CUT, (WPARAM)0, (LPARAM)0);
490
491 // Now replace with 'value', by pasting.
b3324be2 492 wxSetClipboardData(wxDF_TEXT, (wxObject *) (const char *)value, 0, 0);
2bda0e17
KB
493
494 // Paste into edit control
495 SendMessage(hWnd, WM_PASTE, (WPARAM)0, (LPARAM)0L);
acbd13a3
JS
496#else
497 wxFAIL_MSG("wxTextCtrl::Replace not implemented if wxUSE_CLIPBOARD is 0.");
498#endif
2bda0e17
KB
499}
500
debe6624 501void wxTextCtrl::Remove(long from, long to)
2bda0e17
KB
502{
503 HWND hWnd = (HWND) GetHWND();
504 long fromChar = from;
505 long toChar = to;
39136494 506
2bda0e17
KB
507 // Cut all selected text
508#ifdef __WIN32__
509 SendMessage(hWnd, EM_SETSEL, fromChar, toChar);
510#else
511 SendMessage(hWnd, EM_SETSEL, (WPARAM)0, (LPARAM)MAKELONG(fromChar, toChar));
512#endif
513 SendMessage(hWnd, WM_CUT, (WPARAM)0, (LPARAM)0);
514}
515
debe6624 516void wxTextCtrl::SetSelection(long from, long to)
2bda0e17
KB
517{
518 HWND hWnd = (HWND) GetHWND();
519 long fromChar = from;
520 long toChar = to;
521 // if from and to are both -1, it means
522 // (in wxWindows) that all text should be selected.
523 // This translates into Windows convention
524 if ((from == -1) && (to == -1))
525 {
526 fromChar = 0;
527 toChar = -1;
528 }
39136494 529
2bda0e17
KB
530#ifdef __WIN32__
531 SendMessage(hWnd, EM_SETSEL, (WPARAM)fromChar, (LPARAM)toChar);
532 SendMessage(hWnd, EM_SCROLLCARET, (WPARAM)0, (LPARAM)0);
533#else
534 // WPARAM is 0: selection is scrolled into view
535 SendMessage(hWnd, EM_SETSEL, (WPARAM)0, (LPARAM)MAKELONG(fromChar, toChar));
536#endif
537}
538
539bool wxTextCtrl::LoadFile(const wxString& file)
540{
2432b92d 541 if (!wxFileExists(WXSTRINGCAST file))
2bda0e17
KB
542 return FALSE;
543
b823f5a1 544 m_fileName = file;
2bda0e17
KB
545
546 Clear();
547
fbc535ff
JS
548// ifstream input(WXSTRINGCAST file, ios::nocreate | ios::in);
549 ifstream input(WXSTRINGCAST file, ios::in);
2bda0e17
KB
550
551 if (!input.bad())
552 {
553 // Previously a SETSEL/REPLACESEL call-pair were done to insert
554 // line by line into the control. Apart from being very slow this
555 // was limited to 32K of text by the external interface presenting
556 // positions as signed shorts. Now load in one chunk...
557 // Note use of 'farmalloc' as in Borland 3.1 'size_t' is 16-bits...
558
ce3ed50d
JS
559#ifdef __SALFORDC__
560 struct _stat stat_buf;
561 if (stat((char*) (const char*) file, &stat_buf) < 0)
562 return FALSE;
563#else
2bda0e17
KB
564 struct stat stat_buf;
565 if (stat(file, &stat_buf) < 0)
566 return FALSE;
ce3ed50d
JS
567#endif
568
2bda0e17
KB
569// char *tmp_buffer = (char*)farmalloc(stat_buf.st_size+1);
570 // This may need to be a bigger buffer than the file size suggests,
571 // if it's a UNIX file. Give it an extra 1000 just in case.
572 char *tmp_buffer = (char*)farmalloc((size_t)(stat_buf.st_size+1+1000));
573 long no_lines = 0;
574 long pos = 0;
575 while (!input.eof() && input.peek() != EOF)
576 {
577 input.getline(wxBuffer, 500);
c085e333
VZ
578 int len = strlen(wxBuffer);
579 wxBuffer[len] = 13;
580 wxBuffer[len+1] = 10;
581 wxBuffer[len+2] = 0;
582 strcpy(tmp_buffer+pos, wxBuffer);
583 pos += strlen(wxBuffer);
584 no_lines++;
2bda0e17
KB
585 }
586
587// SendMessage((HWND) GetHWND(), WM_SETTEXT, 0, (LPARAM)tmp_buffer);
588 SetWindowText((HWND) GetHWND(), tmp_buffer);
589 SendMessage((HWND) GetHWND(), EM_SETMODIFY, FALSE, 0L);
590 farfree(tmp_buffer);
591
592 return TRUE;
593 }
594 return FALSE;
595}
596
597// If file is null, try saved file name first
598// Returns TRUE if succeeds.
599bool wxTextCtrl::SaveFile(const wxString& file)
600{
cd471848 601 wxString theFile(file);
2bda0e17 602
cd471848
VZ
603 if (theFile == "")
604 theFile = m_fileName;
605
606 if (theFile == "")
607 return FALSE;
608
609 m_fileName = theFile;
610
611 ofstream output((char*) (const char*) theFile);
612 if (output.bad())
613 return FALSE;
2bda0e17
KB
614
615 // This will only save 64K max
616 unsigned long nbytes = SendMessage((HWND) GetHWND(), WM_GETTEXTLENGTH, 0, 0);
617 char *tmp_buffer = (char*)farmalloc((size_t)(nbytes+1));
618 SendMessage((HWND) GetHWND(), WM_GETTEXT, (WPARAM)(nbytes+1), (LPARAM)tmp_buffer);
619 char *pstr = tmp_buffer;
620
cd471848
VZ
621 // Convert \r\n to just \n
622 while (*pstr)
623 {
624 if (*pstr != '\r')
625 output << *pstr;
626 pstr++;
627 }
2bda0e17
KB
628
629 farfree(tmp_buffer);
630 SendMessage((HWND) GetHWND(), EM_SETMODIFY, FALSE, 0L);
631
632 return TRUE;
633}
634
635void wxTextCtrl::WriteText(const wxString& text)
636{
637 // Covert \n to \r\n
638 int len = text.Length();
639 char *newtext = new char[(len*2)+1];
640 int i = 0;
641 int j = 0;
642 while (i < len)
643 {
644 if (text[i] == '\n')
645 {
646 newtext[j] = '\r';
647 j ++;
648 }
649 newtext[j] = text[i];
650 i ++;
651 j ++;
652 }
653 newtext[j] = 0;
654 SendMessage((HWND) GetHWND(), EM_REPLACESEL, 0, (LPARAM)newtext);
655 delete[] newtext;
656}
657
5fb9fcfc
VZ
658void wxTextCtrl::AppendText(const wxString& text)
659{
660 SetInsertionPointEnd();
661 WriteText(text);
662}
663
cd471848 664void wxTextCtrl::Clear()
2bda0e17 665{
2bda0e17
KB
666 SetWindowText((HWND) GetHWND(), "");
667}
668
cd471848 669bool wxTextCtrl::IsModified() const
2bda0e17
KB
670{
671 return (SendMessage((HWND) GetHWND(), EM_GETMODIFY, 0, 0) != 0);
672}
673
674// Makes 'unmodified'
cd471848 675void wxTextCtrl::DiscardEdits()
2bda0e17
KB
676{
677 SendMessage((HWND) GetHWND(), EM_SETMODIFY, FALSE, 0L);
678}
679
680/*
681 * Some of the following functions are yet to be implemented
682 *
683 */
39136494 684
cd471848 685int wxTextCtrl::GetNumberOfLines() const
2bda0e17
KB
686{
687 return (int)SendMessage((HWND) GetHWND(), EM_GETLINECOUNT, (WPARAM)0, (LPARAM)0);
688}
689
debe6624 690long wxTextCtrl::XYToPosition(long x, long y) const
2bda0e17
KB
691{
692 HWND hWnd = (HWND) GetHWND();
693
694 // This gets the char index for the _beginning_ of this line
695 int charIndex = (int)SendMessage(hWnd, EM_LINEINDEX, (WPARAM)y, (LPARAM)0);
696 return (long)(x + charIndex);
697}
698
debe6624 699void wxTextCtrl::PositionToXY(long pos, long *x, long *y) const
2bda0e17
KB
700{
701 HWND hWnd = (HWND) GetHWND();
702
703 // This gets the line number containing the character
704 int lineNo = (int)SendMessage(hWnd, EM_LINEFROMCHAR, (WPARAM)pos, (LPARAM)0);
705 // This gets the char index for the _beginning_ of this line
706 int charIndex = (int)SendMessage(hWnd, EM_LINEINDEX, (WPARAM)lineNo, (LPARAM)0);
707 // The X position must therefore be the different between pos and charIndex
708 *x = (long)(pos - charIndex);
709 *y = (long)lineNo;
710}
711
debe6624 712void wxTextCtrl::ShowPosition(long pos)
2bda0e17
KB
713{
714 HWND hWnd = (HWND) GetHWND();
715
716 // To scroll to a position, we pass the number of lines and characters
717 // to scroll *by*. This means that we need to:
718 // (1) Find the line position of the current line.
719 // (2) Find the line position of pos.
720 // (3) Scroll by (pos - current).
721 // For now, ignore the horizontal scrolling.
722
723 // Is this where scrolling is relative to - the line containing the caret?
724 // Or is the first visible line??? Try first visible line.
725// int currentLineLineNo1 = (int)SendMessage(hWnd, EM_LINEFROMCHAR, (WPARAM)-1, (LPARAM)0L);
726
727 int currentLineLineNo = (int)SendMessage(hWnd, EM_GETFIRSTVISIBLELINE, (WPARAM)0, (LPARAM)0L);
728
729 int specifiedLineLineNo = (int)SendMessage(hWnd, EM_LINEFROMCHAR, (WPARAM)pos, (LPARAM)0L);
39136494 730
2bda0e17
KB
731 int linesToScroll = specifiedLineLineNo - currentLineLineNo;
732
2bda0e17 733 if (linesToScroll != 0)
de4d7713 734 (void)SendMessage(hWnd, EM_LINESCROLL, (WPARAM)0, (LPARAM)linesToScroll);
2bda0e17
KB
735}
736
debe6624 737int wxTextCtrl::GetLineLength(long lineNo) const
2bda0e17
KB
738{
739 long charIndex = XYToPosition(0, lineNo);
740 HWND hWnd = (HWND) GetHWND();
741 int len = (int)SendMessage(hWnd, EM_LINELENGTH, (WPARAM)charIndex, (LPARAM)0);
742 return len;
743}
744
debe6624 745wxString wxTextCtrl::GetLineText(long lineNo) const
2bda0e17
KB
746{
747 HWND hWnd = (HWND) GetHWND();
748 *(WORD *)wxBuffer = 512;
749 int noChars = (int)SendMessage(hWnd, EM_GETLINE, (WPARAM)lineNo, (LPARAM)wxBuffer);
750 wxBuffer[noChars] = 0;
c085e333 751 return wxString(wxBuffer);
2bda0e17
KB
752}
753
ca8b28f2
JS
754bool wxTextCtrl::CanCopy() const
755{
756 // Can copy if there's a selection
757 long from, to;
758 GetSelection(& from, & to);
759 return (from != to) ;
760}
761
762bool wxTextCtrl::CanCut() const
763{
764 // Can cut if there's a selection
765 long from, to;
766 GetSelection(& from, & to);
767 return (from != to) ;
768}
769
770bool wxTextCtrl::CanPaste() const
771{
b80ec6db
JS
772#if wxUSE_RICHEDIT
773 if (m_isRich)
774 {
775 int dataFormat = 0; // 0 == any format
776 return (::SendMessage( (HWND) GetHWND(), EM_CANPASTE, (WPARAM) (UINT) dataFormat, 0) != 0);
777 }
778#endif
779 if (!IsEditable())
780 return FALSE;
781
782 // Standard edit control: check for straight text on clipboard
783 bool isTextAvailable = FALSE;
784 if (::OpenClipboard((HWND) wxTheApp->GetTopWindow()->GetHWND()))
785 {
786 isTextAvailable = (::IsClipboardFormatAvailable(CF_TEXT) != 0);
787 ::CloseClipboard();
788 }
789 return isTextAvailable;
ca8b28f2
JS
790}
791
792// Undo/redo
793void wxTextCtrl::Undo()
794{
795 if (CanUndo())
796 {
797 ::SendMessage((HWND) GetHWND(), EM_UNDO, 0, 0);
798 }
799}
800
801void wxTextCtrl::Redo()
802{
803 if (CanRedo())
804 {
805 // Same as Undo, since Undo undoes the undo, i.e. a redo.
806 ::SendMessage((HWND) GetHWND(), EM_UNDO, 0, 0);
807 }
808}
809
810bool wxTextCtrl::CanUndo() const
811{
812 return (::SendMessage((HWND) GetHWND(), EM_CANUNDO, 0, 0) != 0);
813}
814
815bool wxTextCtrl::CanRedo() const
816{
817 return (::SendMessage((HWND) GetHWND(), EM_CANUNDO, 0, 0) != 0);
818}
819
820// If the return values from and to are the same, there is no
821// selection.
822void wxTextCtrl::GetSelection(long* from, long* to) const
823{
824#if wxUSE_RICHEDIT
825 if (m_isRich)
826 {
827 CHARRANGE charRange;
828 ::SendMessage((HWND) GetHWND(), EM_EXGETSEL, 0, (LPARAM) (CHARRANGE*) & charRange);
829
830 *from = charRange.cpMin;
831 *to = charRange.cpMax;
832
833 return;
834 }
835#endif
836 DWORD dwStart, dwEnd;
b80ec6db
JS
837 WPARAM wParam = (WPARAM) (DWORD*) & dwStart; // receives starting position
838 LPARAM lParam = (LPARAM) (DWORD*) & dwEnd; // receives ending position
ca8b28f2
JS
839
840 ::SendMessage((HWND) GetHWND(), EM_GETSEL, wParam, lParam);
841
842 *from = dwStart;
843 *to = dwEnd;
844}
845
846bool wxTextCtrl::IsEditable() const
847{
848 long style = ::GetWindowLong((HWND) GetHWND(), GWL_STYLE);
849 return ((style & ES_READONLY) == 0);
850}
39136494 851
2bda0e17
KB
852void wxTextCtrl::Command(wxCommandEvent & event)
853{
854 SetValue (event.GetString());
855 ProcessCommand (event);
856}
857
858void wxTextCtrl::OnDropFiles(wxDropFilesEvent& event)
859{
860 // By default, load the first file into the text window.
861 if (event.GetNumberOfFiles() > 0)
862 {
863 LoadFile(event.GetFiles()[0]);
864 }
865}
866
867// The streambuf code was partly taken from chapter 3 by Jerry Schwarz of
868// AT&T's "C++ Lanuage System Release 3.0 Library Manual" - Stein Somers
869
870//=========================================================================
39136494 871// Called then the buffer is full (gcc 2.6.3)
2bda0e17
KB
872// or when "endl" is output (Borland 4.5)
873//=========================================================================
874// Class declaration using multiple inheritance doesn't work properly for
3f1af920 875// Borland. See note in textctrl.h.
2bda0e17
KB
876#ifndef NO_TEXT_WINDOW_STREAM
877int wxTextCtrl::overflow(int c)
878{
879 // Make sure there is a holding area
7cf98a65
UU
880 // this is not needed in <iostream> usage as it automagically allocates
881 // it, but does someone want to emulate it for safety's sake?
882#if wxUSE_IOSTREAMH
2bda0e17
KB
883 if ( allocate()==EOF )
884 {
2432b92d 885 wxLogError("Streambuf allocation failed");
2bda0e17
KB
886 return EOF;
887 }
7cf98a65 888#endif
39136494 889
2bda0e17
KB
890 // Verify that there are no characters in get area
891 if ( gptr() && gptr() < egptr() )
892 {
893 wxError("Who's trespassing my get area?","Internal error");
894 return EOF;
895 }
896
897 // Reset get area
898 setg(0,0,0);
899
900 // Make sure there is a put area
901 if ( ! pptr() )
902 {
903/* This doesn't seem to be fatal so comment out error message */
904// wxError("Put area not opened","Internal error");
7cf98a65
UU
905
906#if wxUSE_IOSTREAMH
907 setp( base(), base() );
908#else
909 setp( pbase(), pbase() );
910#endif
2bda0e17
KB
911 }
912
913 // Determine how many characters have been inserted but no consumed
914 int plen = pptr() - pbase();
915
916 // Now Jerry relies on the fact that the buffer is at least 2 chars
917 // long, but the holding area "may be as small as 1" ???
918 // And we need an additional \0, so let's keep this inefficient but
919 // safe copy.
920
921 // If c!=EOF, it is a character that must also be comsumed
922 int xtra = c==EOF? 0 : 1;
923
924 // Write temporary C-string to wxTextWindow
925 {
926 char *txt = new char[plen+xtra+1];
927 memcpy(txt, pbase(), plen);
928 txt[plen] = (char)c; // append c
929 txt[plen+xtra] = '\0'; // append '\0' or overwrite c
930 // If the put area already contained \0, output will be truncated there
5fb9fcfc 931 AppendText(txt);
2bda0e17
KB
932 delete[] txt;
933 }
934
935 // Reset put area
936 setp(pbase(), epptr());
937
938#if defined(__WATCOMC__)
939 return __NOT_EOF;
940#elif defined(zapeof) // HP-UX (all cfront based?)
941 return zapeof(c);
942#else
943 return c!=EOF ? c : 0; // this should make everybody happy
944#endif
945
946/* OLD CODE
947 int len = pptr() - pbase();
948 char *txt = new char[len+1];
949 strncpy(txt, pbase(), len);
950 txt[len] = '\0';
951 (*this) << txt;
952 setp(pbase(), epptr());
953 delete[] txt;
954 return EOF;
955*/
956}
957
958//=========================================================================
959// called then "endl" is output (gcc) or then explicit sync is done (Borland)
960//=========================================================================
cd471848 961int wxTextCtrl::sync()
2bda0e17
KB
962{
963 // Verify that there are no characters in get area
964 if ( gptr() && gptr() < egptr() )
965 {
966 wxError("Who's trespassing my get area?","Internal error");
967 return EOF;
968 }
969
970 if ( pptr() && pptr() > pbase() ) return overflow(EOF);
971
972 return 0;
973/* OLD CODE
974 int len = pptr() - pbase();
975 char *txt = new char[len+1];
976 strncpy(txt, pbase(), len);
977 txt[len] = '\0';
978 (*this) << txt;
979 setp(pbase(), epptr());
980 delete[] txt;
981 return 0;
982*/
983}
984
985//=========================================================================
986// Should not be called by a "ostream". Used by a "istream"
987//=========================================================================
cd471848 988int wxTextCtrl::underflow()
2bda0e17
KB
989{
990 return EOF;
991}
992#endif
993
994wxTextCtrl& wxTextCtrl::operator<<(const wxString& s)
995{
5fb9fcfc
VZ
996 AppendText(s);
997 return *this;
2bda0e17
KB
998}
999
debe6624 1000wxTextCtrl& wxTextCtrl::operator<<(float f)
2bda0e17 1001{
b823f5a1
JS
1002 wxString str;
1003 str.Printf("%.2f", f);
5fb9fcfc 1004 AppendText(str);
b823f5a1 1005 return *this;
2bda0e17
KB
1006}
1007
debe6624 1008wxTextCtrl& wxTextCtrl::operator<<(double d)
2bda0e17 1009{
b823f5a1
JS
1010 wxString str;
1011 str.Printf("%.2f", d);
5fb9fcfc 1012 AppendText(str);
b823f5a1 1013 return *this;
2bda0e17
KB
1014}
1015
debe6624 1016wxTextCtrl& wxTextCtrl::operator<<(int i)
2bda0e17 1017{
b823f5a1
JS
1018 wxString str;
1019 str.Printf("%d", i);
5fb9fcfc 1020 AppendText(str);
b823f5a1 1021 return *this;
2bda0e17
KB
1022}
1023
debe6624 1024wxTextCtrl& wxTextCtrl::operator<<(long i)
2bda0e17 1025{
b823f5a1
JS
1026 wxString str;
1027 str.Printf("%ld", i);
5fb9fcfc 1028 AppendText(str);
b823f5a1 1029 return *this;
2bda0e17
KB
1030}
1031
1032wxTextCtrl& wxTextCtrl::operator<<(const char c)
1033{
b823f5a1 1034 char buf[2];
2bda0e17 1035
b823f5a1
JS
1036 buf[0] = c;
1037 buf[1] = 0;
5fb9fcfc 1038 AppendText(buf);
b823f5a1 1039 return *this;
2bda0e17
KB
1040}
1041
debe6624 1042WXHBRUSH wxTextCtrl::OnCtlColor(WXHDC pDC, WXHWND pWnd, WXUINT nCtlColor,
c085e333 1043 WXUINT message, WXWPARAM wParam, WXLPARAM lParam)
2bda0e17 1044{
1f112209 1045#if wxUSE_CTL3D
2bda0e17
KB
1046 if ( m_useCtl3D )
1047 {
1048 HBRUSH hbrush = Ctl3dCtlColorEx(message, wParam, lParam);
1049 return (WXHBRUSH) hbrush;
1050 }
1051#endif
1052
1053 if (GetParent()->GetTransparentBackground())
1054 SetBkMode((HDC) pDC, TRANSPARENT);
1055 else
1056 SetBkMode((HDC) pDC, OPAQUE);
1057
1058 ::SetBkColor((HDC) pDC, RGB(GetBackgroundColour().Red(), GetBackgroundColour().Green(), GetBackgroundColour().Blue()));
1059 ::SetTextColor((HDC) pDC, RGB(GetForegroundColour().Red(), GetForegroundColour().Green(), GetForegroundColour().Blue()));
1060
1061 wxBrush *backgroundBrush = wxTheBrushList->FindOrCreateBrush(GetBackgroundColour(), wxSOLID);
1062
1063 // Note that this will be cleaned up in wxApp::OnIdle, if backgroundBrush
1064 // has a zero usage count.
1065 // NOT NOW - will be cleaned up at end of app.
1066// backgroundBrush->RealizeResource();
1067 return (WXHBRUSH) backgroundBrush->GetResourceHandle();
1068}
1069
1070void wxTextCtrl::OnChar(wxKeyEvent& event)
1071{
42e69d6b 1072 switch ( event.KeyCode() )
cd471848 1073 {
cd471848 1074 case WXK_RETURN:
39136494 1075 if ( !(m_windowStyle & wxTE_MULTILINE) )
cd471848
VZ
1076 {
1077 wxCommandEvent event(wxEVT_COMMAND_TEXT_ENTER, m_windowId);
1078 event.SetEventObject( this );
1079 if ( GetEventHandler()->ProcessEvent(event) )
1080 return;
1081 }
5fb9fcfc
VZ
1082 //else: multiline controls need Enter for themselves
1083
1084 break;
4d91c1d1 1085
cd471848 1086 case WXK_TAB:
5fb9fcfc
VZ
1087 // only produce navigation event if we don't process TAB ourself or
1088 // if it's a Shift-Tab keypress (we assume nobody will ever need
1089 // this key combo for himself)
1090 //
1091 // NB: Notice that Ctrl-Tab is handled elsewhere and Alt-Tab is
1092 // handled by Windows
1093 if ( event.ShiftDown() || !(m_windowStyle & wxTE_PROCESS_TAB) )
cd471848 1094 {
5fb9fcfc
VZ
1095 wxNavigationKeyEvent eventNav;
1096 eventNav.SetDirection(!event.ShiftDown());
1097 eventNav.SetWindowChange(FALSE);
1098 eventNav.SetEventObject(this);
39136494 1099
5fb9fcfc 1100 if ( GetEventHandler()->ProcessEvent(eventNav) )
cd471848
VZ
1101 return;
1102 }
341c92a8 1103 break;
4d91c1d1
VZ
1104
1105 default:
1106 event.Skip();
39136494 1107 return;
cd471848 1108 }
39136494 1109
cd471848
VZ
1110 // don't just call event.Skip() because this will cause TABs and ENTERs
1111 // be passed upwards and we don't always want this - instead process it
1112 // right here
42e69d6b
VZ
1113
1114 // FIXME
1115 event.Skip();
2bda0e17
KB
1116}
1117
ae29de83 1118long wxTextCtrl::MSWGetDlgCode()
2bda0e17 1119{
cd471848
VZ
1120 // we always want the characters and the arrows
1121 long lRc = DLGC_WANTCHARS | DLGC_WANTARROWS;
1122
1123 // we may have several different cases:
1124 // 1. normal case: both TAB and ENTER are used for dialog navigation
1125 // 2. ctrl which wants TAB for itself: ENTER is used to pass to the next
1126 // control in the dialog
1127 // 3. ctrl which wants ENTER for itself: TAB is used for dialog navigation
1128 // 4. ctrl which wants both TAB and ENTER: Ctrl-ENTER is used to pass to
1129 // the next control
1130 if ( m_windowStyle & wxTE_PROCESS_ENTER )
1131 lRc |= DLGC_WANTMESSAGE;
1132 if ( m_windowStyle & wxTE_PROCESS_TAB )
1133 lRc |= DLGC_WANTTAB;
39136494 1134
cd471848 1135 return lRc;
ae29de83
VZ
1136}
1137
debe6624 1138bool wxTextCtrl::MSWCommand(WXUINT param, WXWORD WXUNUSED(id))
2bda0e17
KB
1139{
1140/*
1141 // Debugging
1142 wxDebugMsg("Edit control %d: ", (int)id);
1143 switch (param)
1144 {
1145 case EN_SETFOCUS:
1146 wxDebugMsg("EN_SETFOCUS\n");
1147 break;
1148 case EN_KILLFOCUS:
1149 wxDebugMsg("EN_KILLFOCUS\n");
1150 break;
1151 case EN_CHANGE:
1152 wxDebugMsg("EN_CHANGE\n");
1153 break;
1154 case EN_UPDATE:
1155 wxDebugMsg("EN_UPDATE\n");
1156 break;
1157 case EN_ERRSPACE:
1158 wxDebugMsg("EN_ERRSPACE\n");
1159 break;
1160 case EN_MAXTEXT:
1161 wxDebugMsg("EN_MAXTEXT\n");
1162 break;
1163 case EN_HSCROLL:
1164 wxDebugMsg("EN_HSCROLL\n");
1165 break;
1166 case EN_VSCROLL:
1167 wxDebugMsg("EN_VSCROLL\n");
1168 break;
1169 default:
1170 wxDebugMsg("Unknown EDIT notification\n");
1171 break;
1172 }
1173*/
2bda0e17
KB
1174 switch (param)
1175 {
1176 case EN_SETFOCUS:
2bda0e17 1177 case EN_KILLFOCUS:
ae29de83
VZ
1178 {
1179 wxFocusEvent event(param == EN_KILLFOCUS ? wxEVT_KILL_FOCUS
1180 : wxEVT_SET_FOCUS,
1181 m_windowId);
1182 event.SetEventObject( this );
02800301 1183 GetEventHandler()->ProcessEvent(event);
ae29de83 1184 }
2bda0e17 1185 break;
ae29de83 1186
2bda0e17 1187 case EN_CHANGE:
ae29de83
VZ
1188 {
1189 wxCommandEvent event(wxEVT_COMMAND_TEXT_UPDATED, m_windowId);
1190 wxString val(GetValue());
1191 if ( !val.IsNull() )
1192 event.m_commandString = WXSTRINGCAST val;
1193 event.SetEventObject( this );
1194 ProcessCommand(event);
1195 }
2bda0e17 1196 break;
ae29de83
VZ
1197
1198 // the other notification messages are not processed
1199 case EN_UPDATE:
2bda0e17 1200 case EN_ERRSPACE:
2bda0e17 1201 case EN_MAXTEXT:
2bda0e17 1202 case EN_HSCROLL:
2bda0e17 1203 case EN_VSCROLL:
2bda0e17 1204 default:
ae29de83 1205 return FALSE;
2bda0e17 1206 }
2bda0e17 1207
ae29de83
VZ
1208 // processed
1209 return TRUE;
2bda0e17
KB
1210}
1211
1212
1213// For Rich Edit controls. Do we need it?
1214#if 0
57c208c5 1215#if wxUSE_RICHEDIT
a23fd0e1 1216bool wxTextCtrl::MSWOnNotify(WXWPARAM wParam, WXLPARAM lParam)
2bda0e17 1217{
c085e333
VZ
1218 wxCommandEvent event(0, m_windowId);
1219 int eventType = 0;
1220 NMHDR *hdr1 = (NMHDR *) lParam;
1221 switch ( hdr1->code )
1222 {
1223 // Insert case code here
1224 default :
a23fd0e1 1225 return wxControl::MSWOnNotify(wParam, lParam);
c085e333
VZ
1226 break;
1227 }
1228
1229 event.SetEventObject( this );
1230 event.SetEventType(eventType);
1231
02800301 1232 if ( !GetEventHandler()->ProcessEvent(event) )
c085e333
VZ
1233 return FALSE;
1234
1235 return TRUE;
2bda0e17
KB
1236}
1237#endif
1238#endif
1239
e702ff0f
JS
1240void wxTextCtrl::OnCut(wxCommandEvent& event)
1241{
1242 Cut();
1243}
1244
1245void wxTextCtrl::OnCopy(wxCommandEvent& event)
1246{
1247 Copy();
1248}
1249
1250void wxTextCtrl::OnPaste(wxCommandEvent& event)
1251{
1252 Paste();
1253}
1254
1255void wxTextCtrl::OnUndo(wxCommandEvent& event)
1256{
1257 Undo();
1258}
1259
1260void wxTextCtrl::OnRedo(wxCommandEvent& event)
1261{
1262 Redo();
1263}
1264
1265void wxTextCtrl::OnUpdateCut(wxUpdateUIEvent& event)
1266{
1267 event.Enable( CanCut() );
1268}
1269
1270void wxTextCtrl::OnUpdateCopy(wxUpdateUIEvent& event)
1271{
1272 event.Enable( CanCopy() );
1273}
1274
1275void wxTextCtrl::OnUpdatePaste(wxUpdateUIEvent& event)
1276{
1277 event.Enable( CanPaste() );
1278}
1279
1280void wxTextCtrl::OnUpdateUndo(wxUpdateUIEvent& event)
1281{
1282 event.Enable( CanUndo() );
1283}
1284
1285void wxTextCtrl::OnUpdateRedo(wxUpdateUIEvent& event)
1286{
1287 event.Enable( CanRedo() );
1288}
1289