]> git.saurik.com Git - wxWidgets.git/blame - src/mac/textctrl.cpp
added wxUSE_INTL around wxLocale::GetSystemEncoding
[wxWidgets.git] / src / mac / textctrl.cpp
CommitLineData
e9576ca5
SC
1/////////////////////////////////////////////////////////////////////////////
2// Name: textctrl.cpp
3// Purpose: wxTextCtrl
4// Author: AUTHOR
5// Modified by:
6// Created: ??/??/98
7// RCS-ID: $Id$
8// Copyright: (c) AUTHOR
9// Licence: wxWindows licence
10/////////////////////////////////////////////////////////////////////////////
11
12#ifdef __GNUG__
13#pragma implementation "textctrl.h"
14#endif
15
03e11df5
GD
16#ifdef __UNIX__
17 #include <sys/types.h>
18 #include <sys/stat.h>
e9576ca5 19#else
03e11df5 20 #include <stat.h>
e9576ca5
SC
21#endif
22#include <fstream.h>
23
03e11df5 24#include "wx/app.h"
5fde6fcc 25#include "wx/dc.h"
03e11df5
GD
26#include "wx/button.h"
27#include "wx/panel.h"
e9576ca5 28#include "wx/textctrl.h"
90b22aca
SC
29#include "wx/notebook.h"
30#include "wx/tabctrl.h"
e9576ca5
SC
31#include "wx/settings.h"
32#include "wx/filefn.h"
33#include "wx/utils.h"
34
35#if defined(__BORLANDC__) && !defined(__WIN32__)
03e11df5
GD
36 #include <alloc.h>
37#elif !defined(__MWERKS__) && !defined(__GNUWIN32) && !defined(__WXMAC_X__)
38 #include <malloc.h>
e9576ca5
SC
39#endif
40
519cb848
SC
41#include "wx/mac/uma.h"
42
2f1ae414 43#if !USE_SHARED_LIBRARY
e9576ca5
SC
44IMPLEMENT_DYNAMIC_CLASS(wxTextCtrl, wxControl)
45
46BEGIN_EVENT_TABLE(wxTextCtrl, wxControl)
47 EVT_DROP_FILES(wxTextCtrl::OnDropFiles)
519cb848 48 EVT_CHAR(wxTextCtrl::OnChar)
2f1ae414
SC
49 EVT_MENU(wxID_CUT, wxTextCtrl::OnCut)
50 EVT_MENU(wxID_COPY, wxTextCtrl::OnCopy)
51 EVT_MENU(wxID_PASTE, wxTextCtrl::OnPaste)
52 EVT_MENU(wxID_UNDO, wxTextCtrl::OnUndo)
53 EVT_MENU(wxID_REDO, wxTextCtrl::OnRedo)
54
55 EVT_UPDATE_UI(wxID_CUT, wxTextCtrl::OnUpdateCut)
56 EVT_UPDATE_UI(wxID_COPY, wxTextCtrl::OnUpdateCopy)
57 EVT_UPDATE_UI(wxID_PASTE, wxTextCtrl::OnUpdatePaste)
58 EVT_UPDATE_UI(wxID_UNDO, wxTextCtrl::OnUpdateUndo)
59 EVT_UPDATE_UI(wxID_REDO, wxTextCtrl::OnUpdateRedo)
e9576ca5 60END_EVENT_TABLE()
2f1ae414 61#endif
e9576ca5
SC
62
63// Text item
64wxTextCtrl::wxTextCtrl()
e9576ca5 65{
e9576ca5
SC
66}
67
2f1ae414
SC
68const short kVerticalMargin = 2 ;
69const short kHorizontalMargin = 2 ;
70
e9576ca5 71bool wxTextCtrl::Create(wxWindow *parent, wxWindowID id,
519cb848 72 const wxString& st,
e9576ca5
SC
73 const wxPoint& pos,
74 const wxSize& size, long style,
75 const wxValidator& validator,
76 const wxString& name)
77{
2f1ae414
SC
78 // base initialization
79 if ( !CreateBase(parent, id, pos, size, style, validator, name) )
80 return FALSE;
519cb848
SC
81
82 wxSize mySize = size ;
2f1ae414
SC
83 if ( UMAHasAppearance() )
84 {
85 m_macHorizontalBorder = 5 ; // additional pixels around the real control
86 m_macVerticalBorder = 5 ;
87 }
88 else
89 {
90 m_macHorizontalBorder = 0 ; // additional pixels around the real control
91 m_macVerticalBorder = 0 ;
92 }
93
519cb848
SC
94
95 Rect bounds ;
96 Str255 title ;
2f1ae414 97
519cb848
SC
98 if ( mySize.y == -1 )
99 {
100 if ( UMAHasAppearance() )
2f1ae414 101 mySize.y = 13 ;
519cb848
SC
102 else
103 mySize.y = 24 ;
2f1ae414
SC
104
105 mySize.y += 2 * m_macVerticalBorder ;
519cb848 106 }
2f1ae414 107
519cb848
SC
108 MacPreControlCreate( parent , id , "" , pos , mySize ,style, validator , name , &bounds , title ) ;
109
fdaf613a 110 m_macControl = UMANewControl( parent->GetMacRootWindow() , &bounds , "\p" , false , 0 , 0 , 1,
2f1ae414 111 ( style & wxTE_PASSWORD ) ? kControlEditTextPasswordProc : kControlEditTextProc , (long) this ) ;
519cb848
SC
112 MacPostControlCreate() ;
113
114 wxString value ;
115
5b781a67
SC
116 {
117 TEHandle teH ;
118 long size ;
119
120 UMAGetControlData( m_macControl , 0, kControlEditTextTEHandleTag , sizeof( TEHandle ) , (char*) &teH , &size ) ;
121 (*teH)->lineHeight = -1 ;
122 }
123
519cb848
SC
124 if( wxApp::s_macDefaultEncodingIsPC )
125 value = wxMacMakeMacStringFromPC( st ) ;
126 else
127 value = st ;
2f1ae414 128 UMASetControlData( m_macControl, 0, ( m_windowStyle & wxTE_PASSWORD ) ? kControlEditTextPasswordTag : kControlEditTextTextTag , value.Length() , (char*) ((const char*)value) ) ;
519cb848
SC
129
130 return TRUE;
e9576ca5
SC
131}
132
133wxString wxTextCtrl::GetValue() const
134{
519cb848 135 Size actualsize;
2f1ae414 136 UMAGetControlData( m_macControl, 0, ( m_windowStyle & wxTE_PASSWORD ) ? kControlEditTextPasswordTag : kControlEditTextTextTag , 32767 , wxBuffer , &actualsize) ;
519cb848
SC
137 wxBuffer[actualsize] = 0 ;
138 if( wxApp::s_macDefaultEncodingIsPC )
139 return wxMacMakePCStringFromMac( wxBuffer ) ;
140 else
141 return wxString(wxBuffer);
e9576ca5
SC
142}
143
2f1ae414
SC
144void wxTextCtrl::GetSelection(long* from, long* to) const
145{
146 ControlEditTextSelectionRec selection ;
147 TEHandle teH ;
148 long size ;
149
150 UMAGetControlData( m_macControl , 0, kControlEditTextTEHandleTag , sizeof( TEHandle ) , (char*) &teH , &size ) ;
151
152 *from = (**teH).selStart;
153 *to = (**teH).selEnd;
154}
155
519cb848
SC
156void wxTextCtrl::SetValue(const wxString& st)
157{
158 wxString value ;
159
160 if( wxApp::s_macDefaultEncodingIsPC )
161 value = wxMacMakeMacStringFromPC( st ) ;
162 else
163 value = st ;
2f1ae414 164 UMASetControlData( m_macControl, 0, ( m_windowStyle & wxTE_PASSWORD ) ? kControlEditTextPasswordTag : kControlEditTextTextTag , value.Length() , (char*) ((const char*)value) ) ;
90b22aca
SC
165 WindowRef window = GetMacRootWindow() ;
166 if ( window )
167 {
168 wxWindow* win = wxFindWinFromMacWindow( window ) ;
169 if ( win )
170 {
171 wxMacDrawingHelper help( win ) ;
172 // the mac control manager always assumes to have the origin at 0,0
173 SetOrigin( 0 , 0 ) ;
174
175 bool hasTabBehind = false ;
176 wxWindow* parent = GetParent() ;
177 while ( parent )
178 {
179 if( parent->MacGetWindowData() )
180 {
181 UMASetThemeWindowBackground( win->MacGetWindowData()->m_macWindow , kThemeBrushDialogBackgroundActive , false ) ;
182 break ;
183 }
184
185 if( parent->IsKindOf( CLASSINFO( wxNotebook ) ) || parent->IsKindOf( CLASSINFO( wxTabCtrl ) ))
186 {
187 if ( ((wxControl*)parent)->GetMacControl() )
188 SetUpControlBackground( ((wxControl*)parent)->GetMacControl() , -1 , true ) ;
189 break ;
190 }
191
192 parent = parent->GetParent() ;
193 }
194
195 UMADrawControl( m_macControl ) ;
196 UMASetThemeWindowBackground( win->MacGetWindowData()->m_macWindow , win->MacGetWindowData()->m_macWindowBackgroundTheme , false ) ;
90b22aca
SC
197 }
198 }
e9576ca5
SC
199}
200
e9576ca5
SC
201// Clipboard operations
202void wxTextCtrl::Copy()
203{
2f1ae414
SC
204 if (CanCopy())
205 {
206 TEHandle teH ;
207 long size ;
519cb848 208
2f1ae414
SC
209 UMAGetControlData( m_macControl , 0, kControlEditTextTEHandleTag , sizeof( TEHandle ) , (char*) &teH , &size ) ;
210 TECopy( teH ) ;
211#if TARGET_CARBON
212 OSStatus err ;
213 err = ClearCurrentScrap( );
214#else
215 OSErr err ;
216 err = ZeroScrap( );
217#endif
218 TEToScrap() ;
219 }
e9576ca5
SC
220}
221
222void wxTextCtrl::Cut()
223{
2f1ae414
SC
224 if (CanCut())
225 {
226 TEHandle teH ;
227 long size ;
519cb848 228
2f1ae414
SC
229 UMAGetControlData( m_macControl , 0, kControlEditTextTEHandleTag , sizeof( TEHandle ) , (char*) &teH , &size ) ;
230 TECut( teH ) ;
231#if TARGET_CARBON
232 OSStatus err ;
233 err = ClearCurrentScrap( );
234#else
235 OSErr err ;
236 err = ZeroScrap( );
237#endif
238 TEToScrap() ;
239 // MacInvalidateControl() ;
240 }
e9576ca5
SC
241}
242
243void wxTextCtrl::Paste()
244{
2f1ae414
SC
245 if (CanPaste())
246 {
247 TEHandle teH ;
248 long size ;
519cb848 249
2f1ae414
SC
250 UMAGetControlData( m_macControl , 0, kControlEditTextTEHandleTag , sizeof( TEHandle ) , (char*) &teH , &size ) ;
251 TEFromScrap() ;
252 TEPaste( teH ) ;
90b22aca
SC
253 WindowRef window = GetMacRootWindow() ;
254 if ( window )
255 {
256 wxWindow* win = wxFindWinFromMacWindow( window ) ;
257 if ( win )
258 {
259 wxMacDrawingHelper help( win ) ;
260 // the mac control manager always assumes to have the origin at 0,0
261 SetOrigin( 0 , 0 ) ;
262
263 bool hasTabBehind = false ;
264 wxWindow* parent = GetParent() ;
265 while ( parent )
266 {
267 if( parent->MacGetWindowData() )
268 {
269 UMASetThemeWindowBackground( win->MacGetWindowData()->m_macWindow , kThemeBrushDialogBackgroundActive , false ) ;
270 break ;
271 }
272
273 if( parent->IsKindOf( CLASSINFO( wxNotebook ) ) || parent->IsKindOf( CLASSINFO( wxTabCtrl ) ))
274 {
275 if ( ((wxControl*)parent)->GetMacControl() )
276 SetUpControlBackground( ((wxControl*)parent)->GetMacControl() , -1 , true ) ;
277 break ;
278 }
279
280 parent = parent->GetParent() ;
281 }
282
283 UMADrawControl( m_macControl ) ;
284 UMASetThemeWindowBackground( win->MacGetWindowData()->m_macWindow , win->MacGetWindowData()->m_macWindowBackgroundTheme , false ) ;
90b22aca
SC
285 }
286 }
2f1ae414
SC
287 }
288}
289
290bool wxTextCtrl::CanCopy() const
291{
292 // Can copy if there's a selection
293 long from, to;
294 GetSelection(& from, & to);
295 return (from != to);
296}
297
298bool wxTextCtrl::CanCut() const
299{
300 // Can cut if there's a selection
301 long from, to;
302 GetSelection(& from, & to);
303 return (from != to);
304}
305
306bool wxTextCtrl::CanPaste() const
307{
308 if (!IsEditable())
309 return FALSE;
310
311 long offset ;
312#if TARGET_CARBON
313 OSStatus err = noErr;
314 ScrapRef scrapRef;
315
316 err = GetCurrentScrap( &scrapRef );
317 if ( err != noTypeErr && err != memFullErr )
318 {
319 ScrapFlavorFlags flavorFlags;
320 Size byteCount;
321
322 if (( err = GetScrapFlavorFlags( scrapRef, 'TEXT', &flavorFlags )) == noErr)
323 {
324 if (( err = GetScrapFlavorSize( scrapRef, 'TEXT', &byteCount )) == noErr)
325 {
326 return TRUE ;
327 }
328 }
329 }
330 return FALSE;
331
332#else
333 if ( GetScrap( NULL , 'TEXT' , &offset ) > 0 )
334 {
335 return TRUE ;
336 }
337#endif
338 return FALSE ;
e9576ca5
SC
339}
340
341void wxTextCtrl::SetEditable(bool editable)
342{
519cb848
SC
343 if ( editable )
344 UMAActivateControl( m_macControl ) ;
345 else
346 UMADeactivateControl( m_macControl ) ;
e9576ca5
SC
347}
348
349void wxTextCtrl::SetInsertionPoint(long pos)
350{
519cb848 351 SetSelection( pos , pos ) ;
e9576ca5
SC
352}
353
354void wxTextCtrl::SetInsertionPointEnd()
355{
356 long pos = GetLastPosition();
357 SetInsertionPoint(pos);
358}
359
360long wxTextCtrl::GetInsertionPoint() const
361{
519cb848
SC
362 ControlEditTextSelectionRec selection ;
363 TEHandle teH ;
364 long size ;
365
366 UMAGetControlData( m_macControl , 0, kControlEditTextTEHandleTag , sizeof( TEHandle ) , (char*) &teH , &size ) ;
367// UMAGetControlData( m_macControl , 0, kControlEditTextSelectionTag , sizeof( selection ) , (char*) &selection , &size ) ;
368 return (**teH).selStart ;
e9576ca5
SC
369}
370
371long wxTextCtrl::GetLastPosition() const
372{
519cb848
SC
373 ControlEditTextSelectionRec selection ;
374 TEHandle teH ;
375 long size ;
376
377 UMAGetControlData( m_macControl , 0, kControlEditTextTEHandleTag , sizeof( TEHandle ) , (char*) &teH , &size ) ;
378
379// UMAGetControlData( m_macControl , 0, kControlEditTextSelectionTag , sizeof( selection ) , (char*) &selection , &size ) ;
380 return (**teH).teLength ;
e9576ca5
SC
381}
382
383void wxTextCtrl::Replace(long from, long to, const wxString& value)
384{
519cb848
SC
385 TEHandle teH ;
386 long size ;
387
388 ControlEditTextSelectionRec selection ;
389
390 selection.selStart = from ;
391 selection.selEnd = to ;
392 UMASetControlData( m_macControl , 0, kControlEditTextSelectionTag , sizeof( selection ) , (char*) &selection ) ;
393 UMAGetControlData( m_macControl , 0, kControlEditTextTEHandleTag , sizeof( TEHandle ) , (char*) &teH , &size ) ;
394 TESetSelect( from , to , teH ) ;
395 TEDelete( teH ) ;
396 TEInsert( value , value.Length() , teH ) ;
0a67a93b 397 Refresh() ;
e9576ca5
SC
398}
399
400void wxTextCtrl::Remove(long from, long to)
401{
519cb848
SC
402 TEHandle teH ;
403 long size ;
404
405 ControlEditTextSelectionRec selection ;
406
407 selection.selStart = from ;
408 selection.selEnd = to ;
409 UMASetControlData( m_macControl , 0, kControlEditTextSelectionTag , sizeof( selection ) , (char*) &selection ) ;
410 UMAGetControlData( m_macControl , 0, kControlEditTextTEHandleTag , sizeof( TEHandle ) , (char*) &teH , &size ) ;
411 TEDelete( teH ) ;
0a67a93b 412 Refresh() ;
e9576ca5
SC
413}
414
415void wxTextCtrl::SetSelection(long from, long to)
416{
519cb848
SC
417 ControlEditTextSelectionRec selection ;
418 TEHandle teH ;
419 long size ;
420
421 UMAGetControlData( m_macControl , 0, kControlEditTextTEHandleTag , sizeof( TEHandle ) , (char*) &teH , &size ) ;
422
423 selection.selStart = from ;
424 selection.selEnd = to ;
425
426 UMASetControlData( m_macControl , 0, kControlEditTextSelectionTag , sizeof( selection ) , (char*) &selection ) ;
427 TESetSelect( selection.selStart , selection.selEnd , teH ) ;
e9576ca5
SC
428}
429
430bool wxTextCtrl::LoadFile(const wxString& file)
431{
2f1ae414 432 if ( wxTextCtrlBase::LoadFile(file) )
e9576ca5 433 {
2f1ae414 434 return TRUE;
e9576ca5 435 }
e9576ca5
SC
436
437 return FALSE;
438}
439
440void wxTextCtrl::WriteText(const wxString& text)
441{
519cb848
SC
442 TEHandle teH ;
443 long size ;
444
445 memcpy( wxBuffer, text , text.Length() ) ;
446 wxBuffer[text.Length() ] = 0 ;
447// wxMacConvertNewlines( wxBuffer , wxBuffer ) ;
448
449 UMAGetControlData( m_macControl , 0, kControlEditTextTEHandleTag , sizeof( TEHandle ) , (char*) &teH , &size ) ;
450
451 TEInsert( wxBuffer , strlen( wxBuffer) , teH ) ;
452 Refresh() ;
e9576ca5
SC
453}
454
13c21be5
HH
455void wxTextCtrl::AppendText(const wxString& text)
456{
519cb848
SC
457 SetInsertionPointEnd();
458 WriteText(text);
13c21be5
HH
459}
460
e9576ca5
SC
461void wxTextCtrl::Clear()
462{
2f1ae414
SC
463 UMASetControlData( m_macControl, 0, ( m_windowStyle & wxTE_PASSWORD ) ? kControlEditTextPasswordTag : kControlEditTextTextTag , 0 , (char*) ((const char*)NULL) ) ;
464 Refresh() ;
e9576ca5
SC
465}
466
467bool wxTextCtrl::IsModified() const
468{
519cb848 469 return TRUE;
e9576ca5
SC
470}
471
2f1ae414
SC
472bool wxTextCtrl::IsEditable() const
473{
474 return IsEnabled();
475}
476
477bool wxTextCtrl::AcceptsFocus() const
478{
479 // we don't want focus if we can't be edited
480 return IsEditable() && wxControl::AcceptsFocus();
481}
482
483wxSize wxTextCtrl::DoGetBestSize() const
484{
485 int wText = 100 ;
486
487 int hText ;
488 if ( UMAHasAppearance() )
489 hText = 13 ;
490 else
491 hText = 24 ;
492 hText += 2 * m_macHorizontalBorder ;
493/*
494 int cx, cy;
495 wxGetCharSize(GetHWND(), &cx, &cy, &GetFont());
496
497 int wText = DEFAULT_ITEM_WIDTH;
498
499 int hText = EDIT_HEIGHT_FROM_CHAR_HEIGHT(cy);
500
501 return wxSize(wText, hText);
502*/
503 if ( m_windowStyle & wxTE_MULTILINE )
504 {
505 hText *= wxMin(GetNumberOfLines(), 5);
506 }
507 //else: for single line control everything is ok
508 return wxSize(wText, hText);
509}
510
511// ----------------------------------------------------------------------------
512// Undo/redo
513// ----------------------------------------------------------------------------
514
515void wxTextCtrl::Undo()
516{
517 if (CanUndo())
518 {
519 }
520}
521
522void wxTextCtrl::Redo()
523{
524 if (CanRedo())
525 {
526 }
527}
528
529bool wxTextCtrl::CanUndo() const
530{
531 return FALSE ;
532}
533
534bool wxTextCtrl::CanRedo() const
535{
536 return FALSE ;
537}
538
e9576ca5
SC
539// Makes 'unmodified'
540void wxTextCtrl::DiscardEdits()
541{
542 // TODO
543}
544
545int wxTextCtrl::GetNumberOfLines() const
546{
547 // TODO
548 return 0;
549}
550
551long wxTextCtrl::XYToPosition(long x, long y) const
552{
553 // TODO
554 return 0;
555}
556
2f1ae414 557bool wxTextCtrl::PositionToXY(long pos, long *x, long *y) const
e9576ca5 558{
2f1ae414 559 return FALSE ;
e9576ca5
SC
560}
561
562void wxTextCtrl::ShowPosition(long pos)
563{
564 // TODO
565}
566
567int wxTextCtrl::GetLineLength(long lineNo) const
568{
519cb848 569 return GetValue().Length();
e9576ca5
SC
570}
571
572wxString wxTextCtrl::GetLineText(long lineNo) const
573{
519cb848 574 return GetValue();
e9576ca5
SC
575}
576
577/*
578 * Text item
579 */
580
581void wxTextCtrl::Command(wxCommandEvent & event)
582{
583 SetValue (event.GetString());
584 ProcessCommand (event);
585}
586
587void wxTextCtrl::OnDropFiles(wxDropFilesEvent& event)
588{
589 // By default, load the first file into the text window.
590 if (event.GetNumberOfFiles() > 0)
591 {
592 LoadFile(event.GetFiles()[0]);
593 }
594}
595
519cb848
SC
596void wxTextCtrl::OnChar(wxKeyEvent& event)
597{
2f1ae414 598 switch ( event.KeyCode() )
519cb848
SC
599 {
600 case WXK_RETURN:
2f1ae414
SC
601 if (m_windowStyle & wxPROCESS_ENTER)
602 {
e7549107
SC
603 wxCommandEvent event(wxEVT_COMMAND_TEXT_ENTER, m_windowId);
604 event.SetEventObject( this );
605 if ( GetEventHandler()->ProcessEvent(event) )
606 return;
2f1ae414
SC
607 }
608 if ( !(m_windowStyle & wxTE_MULTILINE) )
609 {
610 wxWindow *parent = GetParent();
611 wxPanel *panel = wxDynamicCast(parent, wxPanel);
612 while ( parent != NULL && panel == NULL )
613 {
614 parent = parent->GetParent() ;
615 panel = wxDynamicCast(parent, wxPanel);
616 }
617 if ( panel && panel->GetDefaultItem() )
618 {
619 wxButton *def = panel->GetDefaultItem() ;
620 wxCommandEvent event(wxEVT_COMMAND_BUTTON_CLICKED, def->GetId() );
621 event.SetEventObject(def);
622 def->Command(event);
623 event.Skip() ;
624 return ;
625 }
519cb848 626 }
e7549107
SC
627 //else: multiline controls need Enter for themselves
628
519cb848 629 break;
2f1ae414 630
519cb848 631 case WXK_TAB:
e7549107
SC
632 // always produce navigation event - even if we process TAB
633 // ourselves the fact that we got here means that the user code
634 // decided to skip processing of this TAB - probably to let it
635 // do its default job.
519cb848
SC
636 {
637 wxNavigationKeyEvent eventNav;
638 eventNav.SetDirection(!event.ShiftDown());
2f1ae414 639 eventNav.SetWindowChange(event.ControlDown());
519cb848 640 eventNav.SetEventObject(this);
e7549107 641
2f1ae414 642 if ( GetParent()->GetEventHandler()->ProcessEvent(eventNav) )
519cb848 643 return;
2f1ae414
SC
644 event.Skip() ;
645 return ;
519cb848
SC
646 }
647 break;
648 }
e7549107 649
2f1ae414
SC
650 EventRecord *ev = wxTheApp->MacGetCurrentEvent() ;
651 short keycode ;
652 short keychar ;
653 keychar = short(ev->message & charCodeMask);
654 keycode = short(ev->message & keyCodeMask) >> 8 ;
655 UMAHandleControlKey( m_macControl , keycode , keychar , ev->modifiers ) ;
656 if ( keychar >= 0x20 || event.KeyCode() == WXK_RETURN)
657 {
658 wxCommandEvent event(wxEVT_COMMAND_TEXT_UPDATED, m_windowId);
659 event.SetString( GetValue() ) ;
660 event.SetEventObject( this );
661 GetEventHandler()->ProcessEvent(event);
662 }
663
e9576ca5
SC
664}
665
2f1ae414
SC
666// ----------------------------------------------------------------------------
667// standard handlers for standard edit menu events
668// ----------------------------------------------------------------------------
669
670void wxTextCtrl::OnCut(wxCommandEvent& event)
671{
672 Cut();
e9576ca5
SC
673}
674
2f1ae414 675void wxTextCtrl::OnCopy(wxCommandEvent& event)
e9576ca5 676{
2f1ae414 677 Copy();
e9576ca5 678}
e9576ca5 679
2f1ae414 680void wxTextCtrl::OnPaste(wxCommandEvent& event)
e9576ca5 681{
2f1ae414 682 Paste();
e9576ca5
SC
683}
684
2f1ae414 685void wxTextCtrl::OnUndo(wxCommandEvent& event)
e9576ca5 686{
2f1ae414 687 Undo();
e9576ca5
SC
688}
689
2f1ae414 690void wxTextCtrl::OnRedo(wxCommandEvent& event)
e9576ca5 691{
2f1ae414 692 Redo();
e9576ca5
SC
693}
694
2f1ae414 695void wxTextCtrl::OnUpdateCut(wxUpdateUIEvent& event)
e9576ca5 696{
2f1ae414 697 event.Enable( CanCut() );
e9576ca5
SC
698}
699
2f1ae414 700void wxTextCtrl::OnUpdateCopy(wxUpdateUIEvent& event)
e9576ca5 701{
2f1ae414 702 event.Enable( CanCopy() );
e9576ca5
SC
703}
704
2f1ae414 705void wxTextCtrl::OnUpdatePaste(wxUpdateUIEvent& event)
e9576ca5 706{
2f1ae414
SC
707 event.Enable( CanPaste() );
708}
e9576ca5 709
2f1ae414
SC
710void wxTextCtrl::OnUpdateUndo(wxUpdateUIEvent& event)
711{
712 event.Enable( CanUndo() );
713}
714
715void wxTextCtrl::OnUpdateRedo(wxUpdateUIEvent& event)
716{
717 event.Enable( CanRedo() );
e9576ca5
SC
718}
719