]> git.saurik.com Git - wxWidgets.git/blame - src/mac/carbon/textctrl.cpp
Fixup Blit so it can be used with a source that is a wxBufferedDC,
[wxWidgets.git] / src / mac / carbon / textctrl.cpp
CommitLineData
e9576ca5 1/////////////////////////////////////////////////////////////////////////////
faa94f3e 2// Name: src/mac/carbon/textctrl.cpp
e9576ca5 3// Purpose: wxTextCtrl
a31a5f85 4// Author: Stefan Csomor
6af16761 5// Modified by: Ryan Norton (MLTE GetLineLength and GetLineText)
a31a5f85 6// Created: 1998-01-01
e9576ca5 7// RCS-ID: $Id$
a31a5f85 8// Copyright: (c) Stefan Csomor
65571936 9// Licence: wxWindows licence
e9576ca5
SC
10/////////////////////////////////////////////////////////////////////////////
11
3d1a4878 12#include "wx/wxprec.h"
fedad417
GD
13
14#if wxUSE_TEXTCTRL
15
88a7a4e1
WS
16#include "wx/textctrl.h"
17
18#ifndef WX_PRECOMP
19 #include "wx/intl.h"
670f9935 20 #include "wx/app.h"
de6185e2 21 #include "wx/utils.h"
da80ae71 22 #include "wx/dc.h"
f1e01716 23 #include "wx/button.h"
3b3dc801 24 #include "wx/menu.h"
9eddec69 25 #include "wx/settings.h"
246c5004 26 #include "wx/msgdlg.h"
1832043f 27 #include "wx/toplevel.h"
88a7a4e1 28#endif
5ca0d812 29
f5c6eb5c 30#ifdef __DARWIN__
88a7a4e1
WS
31 #include <sys/types.h>
32 #include <sys/stat.h>
e9576ca5 33#else
88a7a4e1 34 #include <stat.h>
e9576ca5 35#endif
2b5f62a0
VZ
36
37#if wxUSE_STD_IOSTREAM
38 #if wxUSE_IOSTREAMH
39 #include <fstream.h>
40 #else
41 #include <fstream>
42 #endif
43#endif
e9576ca5 44
e9576ca5 45#include "wx/filefn.h"
823c4e96 46#include "wx/sysopt.h"
e9576ca5
SC
47
48#if defined(__BORLANDC__) && !defined(__WIN32__)
670f9935 49 #include <alloc.h>
f5c6eb5c 50#elif !defined(__MWERKS__) && !defined(__GNUWIN32) && !defined(__DARWIN__)
670f9935 51 #include <malloc.h>
e9576ca5
SC
52#endif
53
66a09d47
SC
54#ifndef __DARWIN__
55#include <Scrap.h>
1b2b1638 56#endif
3556e470 57
fef981b4
DS
58#ifndef __DARWIN__
59#include <MacTextEditor.h>
60#include <ATSUnicode.h>
61#include <TextCommon.h>
62#include <TextEncodingConverter.h>
63#endif
64
65#include "wx/mac/uma.h"
66
0f7817ab 67#ifndef __WXMAC_OSX__
3dee36ae 68enum
0f7817ab 69{
c88b7d28 70 kTXNVisibilityTag = 'visb' // set the visibility state of the object
0f7817ab
SC
71};
72#endif
73
72055702 74
5ca0d812 75class wxMacFunctor
587bc950 76{
7d8268a1 77public :
a8d2fb31 78 wxMacFunctor() {}
5ca0d812 79 virtual ~wxMacFunctor() {}
fef981b4 80
5ca0d812 81 virtual void* operator()() = 0 ;
fef981b4 82
c88b7d28 83 static void* CallBackProc( void *param )
587bc950 84 {
5ca0d812
SC
85 wxMacFunctor* f = (wxMacFunctor*) param ;
86 void *result = (*f)() ;
87 return result ;
587bc950 88 }
5ca0d812 89} ;
587bc950 90
fef981b4
DS
91template<typename classtype, typename param1type>
92
5ca0d812 93class wxMacObjectFunctor1 : public wxMacFunctor
587bc950 94{
5ca0d812
SC
95 typedef void (classtype::*function)( param1type p1 ) ;
96 typedef void (classtype::*ref_function)( const param1type& p1 ) ;
7d8268a1 97public :
5ca0d812 98 wxMacObjectFunctor1( classtype *obj , function f , param1type p1 ) :
fef981b4 99 wxMacFunctor()
587bc950 100 {
5ca0d812
SC
101 m_object = obj ;
102 m_function = f ;
103 m_param1 = p1 ;
587bc950 104 }
587bc950 105
5ca0d812 106 wxMacObjectFunctor1( classtype *obj , ref_function f , param1type p1 ) :
fef981b4 107 wxMacFunctor()
5ca0d812
SC
108 {
109 m_object = obj ;
110 m_refFunction = f ;
111 m_param1 = p1 ;
112 }
587bc950 113
d3c7fc99 114 virtual ~wxMacObjectFunctor1() {}
7d8268a1
WS
115
116 virtual void* operator()()
587bc950 117 {
c88b7d28 118 (m_object->*m_function)( m_param1 ) ;
5ca0d812
SC
119 return NULL ;
120 }
a8d2fb31 121
5ca0d812
SC
122private :
123 classtype* m_object ;
124 param1type m_param1 ;
125 union
126 {
fef981b4
DS
127 function m_function ;
128 ref_function m_refFunction ;
587bc950 129 } ;
5ca0d812 130} ;
587bc950 131
7d8268a1 132template<typename classtype, typename param1type>
5ca0d812
SC
133void* wxMacMPRemoteCall( classtype *object , void (classtype::*function)( param1type p1 ) , param1type p1 )
134{
fef981b4 135 wxMacObjectFunctor1<classtype, param1type> params(object, function, p1) ;
7d8268a1 136 void *result =
fef981b4 137 MPRemoteCall( wxMacFunctor::CallBackProc , &params , kMPOwningProcessRemoteContext ) ;
5ca0d812
SC
138 return result ;
139}
587bc950 140
7d8268a1 141template<typename classtype, typename param1type>
5ca0d812
SC
142void* wxMacMPRemoteCall( classtype *object , void (classtype::*function)( const param1type& p1 ) , param1type p1 )
143{
fef981b4 144 wxMacObjectFunctor1<classtype,param1type> params(object, function, p1) ;
7d8268a1 145 void *result =
fef981b4 146 MPRemoteCall( wxMacFunctor::CallBackProc , &params , kMPOwningProcessRemoteContext ) ;
5ca0d812 147 return result ;
587bc950
SC
148}
149
7d8268a1 150template<typename classtype, typename param1type>
5ca0d812
SC
151void* wxMacMPRemoteGUICall( classtype *object , void (classtype::*function)( param1type p1 ) , param1type p1 )
152{
153 wxMutexGuiLeave() ;
154 void *result = wxMacMPRemoteCall( object , function , p1 ) ;
155 wxMutexGuiEnter() ;
156 return result ;
157}
29b30405 158
7d8268a1 159template<typename classtype, typename param1type>
5ca0d812
SC
160void* wxMacMPRemoteGUICall( classtype *object , void (classtype::*function)( const param1type& p1 ) , param1type p1 )
161{
162 wxMutexGuiLeave() ;
163 void *result = wxMacMPRemoteCall( object , function , p1 ) ;
164 wxMutexGuiEnter() ;
165 return result ;
166}
a8d2fb31 167
5ca0d812
SC
168// common interface for all implementations
169class wxMacTextControl : public wxMacControl
170{
171public :
0f7817ab 172 wxMacTextControl( wxTextCtrl *peer ) ;
d3c7fc99 173 virtual ~wxMacTextControl() ;
7d8268a1 174
5ca0d812
SC
175 virtual wxString GetStringValue() const = 0 ;
176 virtual void SetStringValue( const wxString &val ) = 0 ;
c88b7d28
DS
177 virtual void SetSelection( long from, long to ) = 0 ;
178 virtual void GetSelection( long* from, long* to ) const = 0 ;
179 virtual void WriteText( const wxString& str ) = 0 ;
180
181 virtual void SetStyle( long start, long end, const wxTextAttr& style ) ;
5ca0d812
SC
182 virtual void Copy() ;
183 virtual void Cut() ;
184 virtual void Paste() ;
185 virtual bool CanPaste() const ;
c88b7d28 186 virtual void SetEditable( bool editable ) ;
7d8268a1 187 virtual wxTextPos GetLastPosition() const ;
c88b7d28
DS
188 virtual void Replace( long from, long to, const wxString &str ) ;
189 virtual void Remove( long from, long to ) ;
190
fef981b4
DS
191
192 virtual bool HasOwnContextMenu() const
193 { return false ; }
194
195 virtual bool SetupCursor( const wxPoint& pt )
196 { return false ; }
9eddec69 197
5ca0d812
SC
198 virtual void Clear() ;
199 virtual bool CanUndo() const;
7d8268a1 200 virtual void Undo() ;
5ca0d812
SC
201 virtual bool CanRedo() const;
202 virtual void Redo() ;
203 virtual int GetNumberOfLines() const ;
204 virtual long XYToPosition(long x, long y) const;
205 virtual bool PositionToXY(long pos, long *x, long *y) const ;
c88b7d28 206 virtual void ShowPosition(long WXUNUSED(pos)) ;
5ca0d812
SC
207 virtual int GetLineLength(long lineNo) const ;
208 virtual wxString GetLineText(long lineNo) const ;
24260aae
SC
209
210#ifndef __WXMAC_OSX__
211 virtual void MacControlUserPaneDrawProc(wxInt16 part) = 0 ;
212 virtual wxInt16 MacControlUserPaneHitTestProc(wxInt16 x, wxInt16 y) = 0 ;
213 virtual wxInt16 MacControlUserPaneTrackingProc(wxInt16 x, wxInt16 y, void* actionProc) = 0 ;
214 virtual void MacControlUserPaneIdleProc() = 0 ;
215 virtual wxInt16 MacControlUserPaneKeyDownProc(wxInt16 keyCode, wxInt16 charCode, wxInt16 modifiers) = 0 ;
216 virtual void MacControlUserPaneActivateProc(bool activating) = 0 ;
217 virtual wxInt16 MacControlUserPaneFocusProc(wxInt16 action) = 0 ;
218 virtual void MacControlUserPaneBackgroundProc(void* info) = 0 ;
219#endif
5ca0d812 220} ;
72055702 221
5ca0d812 222// common parts for implementations based on MLTE
72055702 223
5ca0d812
SC
224class wxMacMLTEControl : public wxMacTextControl
225{
226public :
789ae0cf 227 wxMacMLTEControl( wxTextCtrl *peer ) ;
c88b7d28 228
5ca0d812 229 virtual wxString GetStringValue() const ;
c88b7d28 230 virtual void SetStringValue( const wxString &str ) ;
7d8268a1 231
5ca0d812 232 static TXNFrameOptions FrameOptionsFromWXStyle( long wxStyle ) ;
fef981b4 233
c88b7d28 234 void AdjustCreationAttributes( const wxColour& background, bool visible ) ;
5ca0d812 235
c88b7d28
DS
236 virtual void SetFont( const wxFont & font, const wxColour& foreground, long windowStyle ) ;
237 virtual void SetBackground( const wxBrush &brush ) ;
238 virtual void SetStyle( long start, long end, const wxTextAttr& style ) ;
5ca0d812
SC
239 virtual void Copy() ;
240 virtual void Cut() ;
241 virtual void Paste() ;
242 virtual bool CanPaste() const ;
c88b7d28 243 virtual void SetEditable( bool editable ) ;
7d8268a1 244 virtual wxTextPos GetLastPosition() const ;
c88b7d28
DS
245 virtual void Replace( long from, long to, const wxString &str ) ;
246 virtual void Remove( long from, long to ) ;
247 virtual void GetSelection( long* from, long* to ) const ;
248 virtual void SetSelection( long from, long to ) ;
7d8268a1 249
c88b7d28 250 virtual void WriteText( const wxString& str ) ;
fef981b4 251
0207e969
DS
252 virtual bool HasOwnContextMenu() const
253 {
64bd657c
SC
254#if MAC_OS_X_VERSION_MAX_ALLOWED >= MAC_OS_X_VERSION_10_4
255 if ( UMAGetSystemVersion() >= 0x1040 )
256 {
257 TXNCommandEventSupportOptions options ;
258 TXNGetCommandEventSupport( m_txn , & options ) ;
259 return options & kTXNSupportEditCommandProcessing ;
260 }
261#endif
fef981b4 262
64bd657c
SC
263 return false ;
264 }
265
5ca0d812
SC
266 virtual void Clear() ;
267
268 virtual bool CanUndo() const ;
269 virtual void Undo() ;
270 virtual bool CanRedo() const;
271 virtual void Redo() ;
272 virtual int GetNumberOfLines() const ;
273 virtual long XYToPosition(long x, long y) const ;
274 virtual bool PositionToXY(long pos, long *x, long *y) const ;
275 virtual void ShowPosition( long pos ) ;
276 virtual int GetLineLength(long lineNo) const ;
277 virtual wxString GetLineText(long lineNo) const ;
278
279 void SetTXNData( const wxString& st , TXNOffset start , TXNOffset end ) ;
09660720 280 TXNObject GetTXNObject() { return m_txn ; }
5ca0d812
SC
281
282protected :
8623a883 283 void TXNSetAttribute( const wxTextAttr& style , long from , long to ) ;
fef981b4 284
5ca0d812
SC
285 TXNObject m_txn ;
286} ;
72055702 287
5ca0d812 288#if TARGET_API_MAC_OSX
72055702 289
5ca0d812
SC
290// implementation available under OSX
291
788e118f
SC
292#if MAC_OS_X_VERSION_MAX_ALLOWED > MAC_OS_X_VERSION_10_2
293
7d8268a1 294class wxMacMLTEHIViewControl : public wxMacMLTEControl
5ca0d812
SC
295{
296public :
0f7817ab 297 wxMacMLTEHIViewControl( wxTextCtrl *wxPeer,
5ca0d812
SC
298 const wxString& str,
299 const wxPoint& pos,
300 const wxSize& size, long style ) ;
d3c7fc99 301 virtual ~wxMacMLTEHIViewControl() ;
9eddec69 302
5ca0d812
SC
303 virtual OSStatus SetFocus( ControlFocusPart focusPart ) ;
304 virtual bool HasFocus() const ;
44aa865d 305 virtual void SetBackground( const wxBrush &brush) ;
a8d2fb31 306
5ca0d812
SC
307protected :
308 HIViewRef m_scrollView ;
309 HIViewRef m_textView ;
09660720 310 EventHandlerRef m_textEventHandlerRef ;
fef981b4 311};
ef4a634b 312
788e118f
SC
313#endif
314
5ca0d812
SC
315class wxMacUnicodeTextControl : public wxMacTextControl
316{
317public :
0f7817ab 318 wxMacUnicodeTextControl( wxTextCtrl *wxPeer,
5ca0d812
SC
319 const wxString& str,
320 const wxPoint& pos,
321 const wxSize& size, long style ) ;
d3c7fc99 322 virtual ~wxMacUnicodeTextControl();
fef981b4 323
5ca0d812
SC
324 virtual void VisibilityChanged(bool shown);
325 virtual wxString GetStringValue() const ;
326 virtual void SetStringValue( const wxString &str) ;
327 virtual void Copy();
328 virtual void Cut();
329 virtual void Paste();
330 virtual bool CanPaste() const;
331 virtual void SetEditable(bool editable) ;
5ca0d812
SC
332 virtual void GetSelection( long* from, long* to) const ;
333 virtual void SetSelection( long from , long to ) ;
334 virtual void WriteText(const wxString& str) ;
a8d2fb31 335
5ca0d812
SC
336protected :
337 // contains the tag for the content (is different for password and non-password controls)
338 OSType m_valueTag ;
ad604d0f
SC
339
340 // as the selection tag only works correctly when the control has the focus we have to mirror the
341 // intended value
342 EventHandlerRef m_focusHandlerRef ;
343public :
344 ControlEditTextSelectionRec m_selection ;
fef981b4 345};
72055702 346
3556e470 347#endif
72055702 348
24260aae 349// 'classic' MLTE implementation
72055702 350
5ca0d812
SC
351class wxMacMLTEClassicControl : public wxMacMLTEControl
352{
353public :
0f7817ab 354 wxMacMLTEClassicControl( wxTextCtrl *wxPeer,
5ca0d812
SC
355 const wxString& str,
356 const wxPoint& pos,
357 const wxSize& size, long style ) ;
d3c7fc99 358 virtual ~wxMacMLTEClassicControl() ;
ffafe6ca 359
5ca0d812 360 virtual void VisibilityChanged(bool shown) ;
4e477040 361 virtual void SuperChangedPosition() ;
24260aae
SC
362
363 virtual void MacControlUserPaneDrawProc(wxInt16 part) ;
364 virtual wxInt16 MacControlUserPaneHitTestProc(wxInt16 x, wxInt16 y) ;
365 virtual wxInt16 MacControlUserPaneTrackingProc(wxInt16 x, wxInt16 y, void* actionProc) ;
366 virtual void MacControlUserPaneIdleProc() ;
367 virtual wxInt16 MacControlUserPaneKeyDownProc(wxInt16 keyCode, wxInt16 charCode, wxInt16 modifiers) ;
368 virtual void MacControlUserPaneActivateProc(bool activating) ;
369 virtual wxInt16 MacControlUserPaneFocusProc(wxInt16 action) ;
370 virtual void MacControlUserPaneBackgroundProc(void* info) ;
371
ffafe6ca
DS
372 virtual bool SetupCursor( const wxPoint& WXUNUSED(pt) )
373 {
374 MacControlUserPaneIdleProc();
375 return true;
376 }
f2c3f2a8 377
0f7817ab
SC
378 virtual void SetRect( Rect *r ) ;
379
5ca0d812
SC
380protected :
381 OSStatus DoCreate();
3dee36ae 382
0f7817ab 383 void MacUpdatePosition() ;
fef981b4
DS
384 void MacActivatePaneText(bool setActive) ;
385 void MacFocusPaneText(bool setFocus) ;
386 void MacSetObjectVisibility(bool vis) ;
a8d2fb31 387
0f7817ab
SC
388private :
389 TXNFrameID m_txnFrameID ;
390 GrafPtr m_txnPort ;
5de694f0 391 WindowRef m_txnWindow ;
0f7817ab
SC
392 // bounds of the control as we last did set the txn frames
393 Rect m_txnControlBounds ;
ba75e603 394 Rect m_txnVisBounds ;
fef981b4 395
4e477040 396#ifdef __WXMAC_OSX__
fef981b4
DS
397 static pascal void TXNScrollActionProc( ControlRef controlRef , ControlPartCode partCode ) ;
398 static pascal void TXNScrollInfoProc(
399 SInt32 iValue, SInt32 iMaximumValue,
400 TXNScrollBarOrientation iScrollBarOrientation, SInt32 iRefCon ) ;
401
4e477040 402 ControlRef m_sbHorizontal ;
5de694f0 403 SInt32 m_lastHorizontalValue ;
4e477040 404 ControlRef m_sbVertical ;
5de694f0 405 SInt32 m_lastVerticalValue ;
4e477040 406#endif
fef981b4 407};
facd6764 408
fef981b4 409
9d112688 410IMPLEMENT_DYNAMIC_CLASS(wxTextCtrl, wxTextCtrlBase)
72055702 411
9d112688 412BEGIN_EVENT_TABLE(wxTextCtrl, wxTextCtrlBase)
7ea087b7 413 EVT_ERASE_BACKGROUND( wxTextCtrl::OnEraseBackground )
5ca0d812
SC
414 EVT_DROP_FILES(wxTextCtrl::OnDropFiles)
415 EVT_CHAR(wxTextCtrl::OnChar)
416 EVT_MENU(wxID_CUT, wxTextCtrl::OnCut)
417 EVT_MENU(wxID_COPY, wxTextCtrl::OnCopy)
418 EVT_MENU(wxID_PASTE, wxTextCtrl::OnPaste)
419 EVT_MENU(wxID_UNDO, wxTextCtrl::OnUndo)
420 EVT_MENU(wxID_REDO, wxTextCtrl::OnRedo)
24eef584
SC
421 EVT_MENU(wxID_CLEAR, wxTextCtrl::OnDelete)
422 EVT_MENU(wxID_SELECTALL, wxTextCtrl::OnSelectAll)
423
424 EVT_CONTEXT_MENU(wxTextCtrl::OnContextMenu)
5ca0d812
SC
425
426 EVT_UPDATE_UI(wxID_CUT, wxTextCtrl::OnUpdateCut)
427 EVT_UPDATE_UI(wxID_COPY, wxTextCtrl::OnUpdateCopy)
428 EVT_UPDATE_UI(wxID_PASTE, wxTextCtrl::OnUpdatePaste)
429 EVT_UPDATE_UI(wxID_UNDO, wxTextCtrl::OnUpdateUndo)
430 EVT_UPDATE_UI(wxID_REDO, wxTextCtrl::OnUpdateRedo)
24eef584
SC
431 EVT_UPDATE_UI(wxID_CLEAR, wxTextCtrl::OnUpdateDelete)
432 EVT_UPDATE_UI(wxID_SELECTALL, wxTextCtrl::OnUpdateSelectAll)
5ca0d812 433END_EVENT_TABLE()
5ca0d812 434
fef981b4 435
a8d2fb31 436void wxTextCtrl::Init()
facd6764 437{
24eef584
SC
438 m_editable = true ;
439 m_dirty = false;
5ca0d812 440
b9bae707 441 m_maxLength = 0;
c88b7d28 442 m_privateContextMenu = NULL;
51478cd6 443 m_triggerOnSetValue = true ;
facd6764
SC
444}
445
5ca0d812 446wxTextCtrl::~wxTextCtrl()
facd6764 447{
24eef584 448 delete m_privateContextMenu;
facd6764
SC
449}
450
ffafe6ca 451bool wxTextCtrl::Create( wxWindow *parent,
c88b7d28
DS
452 wxWindowID id,
453 const wxString& str,
454 const wxPoint& pos,
455 const wxSize& size,
456 long style,
457 const wxValidator& validator,
ffafe6ca 458 const wxString& name )
5ca0d812 459{
7d8268a1 460 m_macIsUserPane = false ;
5ca0d812
SC
461 m_editable = true ;
462
c88b7d28
DS
463 if ( ! (style & wxNO_BORDER) )
464 style = (style & ~wxBORDER_MASK) | wxSUNKEN_BORDER ;
7d8268a1 465
ffafe6ca 466 if ( !wxTextCtrlBase::Create( parent, id, pos, size, style & ~(wxHSCROLL | wxVSCROLL), validator, name ) )
7d8268a1 467 return false;
ef4a634b 468
5ca0d812 469 if ( m_windowStyle & wxTE_MULTILINE )
facd6764 470 {
9e15c718 471 // always turn on this style for multi-line controls
5ca0d812
SC
472 m_windowStyle |= wxTE_PROCESS_ENTER;
473 style |= wxTE_PROCESS_ENTER ;
ed8c2780 474 }
3556e470 475
4d7528a1 476 bool forceMLTE = false ;
fef981b4 477
823c4e96 478#if wxUSE_SYSTEM_OPTIONS
ffafe6ca 479 if (wxSystemOptions::HasOption( wxMAC_TEXTCONTROL_USE_MLTE ) && (wxSystemOptions::GetOptionInt( wxMAC_TEXTCONTROL_USE_MLTE ) == 1))
823c4e96 480 {
4d7528a1 481 forceMLTE = true ;
823c4e96
SC
482 }
483#endif
4d7528a1
SC
484
485#ifdef __WXMAC_OSX__
486#if MAC_OS_X_VERSION_MAX_ALLOWED > MAC_OS_X_VERSION_10_2
c88b7d28 487 if ( UMAGetSystemVersion() >= 0x1030 && !forceMLTE )
788e118f 488 {
4d7528a1
SC
489 if ( m_windowStyle & wxTE_MULTILINE )
490 m_peer = new wxMacMLTEHIViewControl( this , str , pos , size , style ) ;
788e118f 491 }
788e118f 492#endif
fef981b4 493
3556e470 494 if ( !m_peer )
7d8268a1 495 {
c88b7d28 496 if ( !(m_windowStyle & wxTE_MULTILINE) && !forceMLTE )
4d7528a1 497 m_peer = new wxMacUnicodeTextControl( this , str , pos , size , style ) ;
788e118f 498 }
3556e470 499#endif
fef981b4 500
3556e470 501 if ( !m_peer )
3556e470 502 m_peer = new wxMacMLTEClassicControl( this , str , pos , size , style ) ;
788e118f 503
c88b7d28 504 MacPostControlCreate(pos, size) ;
72055702 505
807c0706
SC
506 // only now the embedding is correct and we can do a positioning update
507
508 MacSuperChangedPosition() ;
509
5ca0d812 510 if ( m_windowStyle & wxTE_READONLY)
5ca0d812 511 SetEditable( false ) ;
3dee36ae 512
f2c3f2a8 513 SetCursor( wxCursor( wxCURSOR_IBEAM ) ) ;
72055702 514
7d8268a1 515 return true;
facd6764
SC
516}
517
3dee36ae 518void wxTextCtrl::MacSuperChangedPosition()
4e477040
SC
519{
520 wxWindow::MacSuperChangedPosition() ;
521 GetPeer()->SuperChangedPosition() ;
522}
523
7d8268a1 524void wxTextCtrl::MacVisibilityChanged()
5ca0d812
SC
525{
526 GetPeer()->VisibilityChanged( MacIsReallyShown() ) ;
527}
facd6764 528
7d8268a1 529void wxTextCtrl::MacEnabledStateChanged()
5ca0d812 530{
72055702
SC
531}
532
5ca0d812
SC
533wxString wxTextCtrl::GetValue() const
534{
535 return GetPeer()->GetStringValue() ;
536}
ef4a634b 537
5ca0d812 538void wxTextCtrl::GetSelection(long* from, long* to) const
7d8268a1 539{
5ca0d812
SC
540 GetPeer()->GetSelection( from , to ) ;
541}
542
ee2ec18e 543void wxTextCtrl::DoSetValue(const wxString& str, int flags)
5ca0d812
SC
544{
545 // optimize redraws
546 if ( GetValue() == str )
ee2ec18e 547 return;
facd6764 548
c88b7d28 549 GetPeer()->SetStringValue( str ) ;
e8b4fd4b 550
ee2ec18e 551 if ( (flags & SetValue_SendEvent) && m_triggerOnSetValue )
51478cd6 552 {
ee2ec18e 553 SendTextUpdatedEvent();
51478cd6 554 }
72055702
SC
555}
556
5ca0d812
SC
557void wxTextCtrl::SetMaxLength(unsigned long len)
558{
559 m_maxLength = len ;
560}
72055702 561
5ca0d812
SC
562bool wxTextCtrl::SetFont( const wxFont& font )
563{
564 if ( !wxTextCtrlBase::SetFont( font ) )
7d8268a1
WS
565 return false ;
566
5ca0d812 567 GetPeer()->SetFont( font , GetForegroundColour() , GetWindowStyle() ) ;
fef981b4 568
5ca0d812
SC
569 return true ;
570}
571
572bool wxTextCtrl::SetStyle(long start, long end, const wxTextAttr& style)
573{
574 GetPeer()->SetStyle( start , end , style ) ;
fef981b4 575
5ca0d812
SC
576 return true ;
577}
578
579bool wxTextCtrl::SetDefaultStyle(const wxTextAttr& style)
580{
581 wxTextCtrlBase::SetDefaultStyle( style ) ;
582 SetStyle( kTXNUseCurrentSelection , kTXNUseCurrentSelection , GetDefaultStyle() ) ;
fef981b4 583
7d8268a1 584 return true ;
5ca0d812
SC
585}
586
587// Clipboard operations
fef981b4 588
5ca0d812
SC
589void wxTextCtrl::Copy()
590{
591 if (CanCopy())
7d8268a1 592 GetPeer()->Copy() ;
72055702
SC
593}
594
5ca0d812
SC
595void wxTextCtrl::Cut()
596{
597 if (CanCut())
598 {
7d8268a1 599 GetPeer()->Cut() ;
72055702 600
c88b7d28 601 wxCommandEvent event( wxEVT_COMMAND_TEXT_UPDATED, m_windowId );
5ca0d812 602 event.SetEventObject( this );
c88b7d28 603 GetEventHandler()->ProcessEvent( event );
5ca0d812
SC
604 }
605}
72055702 606
5ca0d812
SC
607void wxTextCtrl::Paste()
608{
609 if (CanPaste())
610 {
7d8268a1 611 GetPeer()->Paste() ;
fef981b4
DS
612
613 // TODO: eventually we should add setting the default style again
72055702 614
c88b7d28 615 wxCommandEvent event( wxEVT_COMMAND_TEXT_UPDATED, m_windowId );
5ca0d812 616 event.SetEventObject( this );
c88b7d28 617 GetEventHandler()->ProcessEvent( event );
5ca0d812
SC
618 }
619}
72055702 620
5ca0d812
SC
621bool wxTextCtrl::CanCopy() const
622{
623 // Can copy if there's a selection
624 long from, to;
c88b7d28 625 GetSelection( &from, &to );
ffafe6ca 626
5ca0d812
SC
627 return (from != to);
628}
ef4a634b 629
5ca0d812
SC
630bool wxTextCtrl::CanCut() const
631{
632 if ( !IsEditable() )
c88b7d28 633 return false;
a8d2fb31 634
5ca0d812
SC
635 // Can cut if there's a selection
636 long from, to;
c88b7d28 637 GetSelection( &from, &to );
ffafe6ca 638
5ca0d812 639 return (from != to);
72055702
SC
640}
641
5ca0d812
SC
642bool wxTextCtrl::CanPaste() const
643{
644 if (!IsEditable())
7d8268a1 645 return false;
72055702 646
5ca0d812
SC
647 return GetPeer()->CanPaste() ;
648}
facd6764 649
5ca0d812
SC
650void wxTextCtrl::SetEditable(bool editable)
651{
652 if ( editable != m_editable )
653 {
654 m_editable = editable ;
655 GetPeer()->SetEditable( editable ) ;
ed8c2780 656 }
72055702
SC
657}
658
5ca0d812
SC
659void wxTextCtrl::SetInsertionPoint(long pos)
660{
661 SetSelection( pos , pos ) ;
662}
72055702 663
5ca0d812
SC
664void wxTextCtrl::SetInsertionPointEnd()
665{
7d8268a1 666 wxTextPos pos = GetLastPosition();
ffafe6ca 667 SetInsertionPoint( pos );
5ca0d812 668}
facd6764 669
5ca0d812
SC
670long wxTextCtrl::GetInsertionPoint() const
671{
ffafe6ca 672 long begin, end ;
5ca0d812 673 GetSelection( &begin , &end ) ;
ffafe6ca 674
5ca0d812
SC
675 return begin ;
676}
facd6764 677
7d8268a1 678wxTextPos wxTextCtrl::GetLastPosition() const
5ca0d812 679{
c88b7d28 680 return GetPeer()->GetLastPosition() ;
72055702
SC
681}
682
5ca0d812
SC
683void wxTextCtrl::Replace(long from, long to, const wxString& str)
684{
ffafe6ca 685 GetPeer()->Replace( from , to , str ) ;
5ca0d812 686}
72055702 687
5ca0d812
SC
688void wxTextCtrl::Remove(long from, long to)
689{
690 GetPeer()->Remove( from , to ) ;
691}
facd6764 692
5ca0d812
SC
693void wxTextCtrl::SetSelection(long from, long to)
694{
695 GetPeer()->SetSelection( from , to ) ;
696}
697
5ca0d812
SC
698void wxTextCtrl::WriteText(const wxString& str)
699{
fef981b4 700 // TODO: this MPRemoting will be moved into a remoting peer proxy for any command
5ca0d812
SC
701 if ( !wxIsMainThread() )
702 {
fef981b4
DS
703 // unfortunately CW 8 is not able to correctly deduce the template types,
704 // so we have to instantiate explicitly
5ca0d812 705 wxMacMPRemoteGUICall<wxTextCtrl,wxString>( this , &wxTextCtrl::WriteText , str ) ;
ffafe6ca 706
5ca0d812
SC
707 return ;
708 }
ffafe6ca
DS
709
710 GetPeer()->WriteText( str ) ;
5ca0d812 711}
72055702 712
5ca0d812
SC
713void wxTextCtrl::AppendText(const wxString& text)
714{
715 SetInsertionPointEnd();
ffafe6ca 716 WriteText( text );
5ca0d812 717}
facd6764 718
5ca0d812
SC
719void wxTextCtrl::Clear()
720{
721 GetPeer()->Clear() ;
722}
facd6764 723
5ca0d812
SC
724bool wxTextCtrl::IsModified() const
725{
726 return m_dirty;
727}
facd6764 728
5ca0d812
SC
729bool wxTextCtrl::IsEditable() const
730{
731 return IsEnabled() && m_editable ;
72055702
SC
732}
733
5ca0d812
SC
734bool wxTextCtrl::AcceptsFocus() const
735{
736 // we don't want focus if we can't be edited
737 return /*IsEditable() && */ wxControl::AcceptsFocus();
738}
72055702 739
5ca0d812 740wxSize wxTextCtrl::DoGetBestSize() const
1b2b1638 741{
c88b7d28 742 int wText, hText;
ef4a634b 743
a8d2fb31
DS
744 // these are the numbers from the HIG:
745 // we reduce them by the borders first
c88b7d28 746 wText = 100 ;
72463754 747
fef981b4 748 switch ( m_windowVariant )
5ca0d812
SC
749 {
750 case wxWINDOW_VARIANT_NORMAL :
72463754 751 hText = 22 - 6 ;
5ca0d812 752 break ;
a8d2fb31 753
5ca0d812 754 case wxWINDOW_VARIANT_SMALL :
72463754 755 hText = 19 - 6 ;
5ca0d812 756 break ;
a8d2fb31 757
5ca0d812 758 case wxWINDOW_VARIANT_MINI :
c88b7d28 759 hText = 15 - 6 ;
5ca0d812 760 break ;
a8d2fb31 761
5ca0d812 762 default :
72463754 763 hText = 22 - 6;
7d8268a1 764 break ;
5ca0d812 765 }
72055702 766
72463754
SC
767 // as the above numbers have some free space around the text
768 // we get 5 lines like this anyway
5ca0d812 769 if ( m_windowStyle & wxTE_MULTILINE )
5ca0d812 770 hText *= 5 ;
ef4a634b 771
72463754
SC
772 if ( !HasFlag(wxNO_BORDER) )
773 hText += 6 ;
774
5ca0d812
SC
775 return wxSize(wText, hText);
776}
ef4a634b 777
5ca0d812
SC
778// ----------------------------------------------------------------------------
779// Undo/redo
780// ----------------------------------------------------------------------------
facd6764 781
5ca0d812
SC
782void wxTextCtrl::Undo()
783{
784 if (CanUndo())
5ca0d812 785 GetPeer()->Undo() ;
72055702
SC
786}
787
5ca0d812 788void wxTextCtrl::Redo()
587bc950 789{
5ca0d812 790 if (CanRedo())
5ca0d812 791 GetPeer()->Redo() ;
5ca0d812 792}
1b2b1638 793
5ca0d812
SC
794bool wxTextCtrl::CanUndo() const
795{
7d8268a1 796 if ( !IsEditable() )
7d8268a1 797 return false ;
a8d2fb31 798
5ca0d812
SC
799 return GetPeer()->CanUndo() ;
800}
72055702 801
5ca0d812 802bool wxTextCtrl::CanRedo() const
6bdd4f5d 803{
7d8268a1 804 if ( !IsEditable() )
7d8268a1 805 return false ;
a8d2fb31 806
5ca0d812 807 return GetPeer()->CanRedo() ;
6bdd4f5d
SC
808}
809
5ca0d812
SC
810void wxTextCtrl::MarkDirty()
811{
812 m_dirty = true;
813}
587bc950 814
5ca0d812
SC
815void wxTextCtrl::DiscardEdits()
816{
817 m_dirty = false;
818}
587bc950 819
5ca0d812
SC
820int wxTextCtrl::GetNumberOfLines() const
821{
822 return GetPeer()->GetNumberOfLines() ;
823}
587bc950 824
5ca0d812
SC
825long wxTextCtrl::XYToPosition(long x, long y) const
826{
827 return GetPeer()->XYToPosition( x , y ) ;
828}
587bc950 829
5ca0d812 830bool wxTextCtrl::PositionToXY(long pos, long *x, long *y) const
72055702 831{
ffafe6ca 832 return GetPeer()->PositionToXY( pos , x , y ) ;
5ca0d812 833}
1fa29bdc 834
5ca0d812
SC
835void wxTextCtrl::ShowPosition(long pos)
836{
837 return GetPeer()->ShowPosition(pos) ;
838}
1fa29bdc 839
5ca0d812
SC
840int wxTextCtrl::GetLineLength(long lineNo) const
841{
842 return GetPeer()->GetLineLength(lineNo) ;
1b2b1638
SC
843}
844
5ca0d812 845wxString wxTextCtrl::GetLineText(long lineNo) const
1b2b1638 846{
5ca0d812 847 return GetPeer()->GetLineText(lineNo) ;
72055702
SC
848}
849
5ca0d812 850void wxTextCtrl::Command(wxCommandEvent & event)
72055702 851{
c88b7d28
DS
852 SetValue(event.GetString());
853 ProcessCommand(event);
5ca0d812 854}
72055702 855
5ca0d812
SC
856void wxTextCtrl::OnDropFiles(wxDropFilesEvent& event)
857{
858 // By default, load the first file into the text window.
859 if (event.GetNumberOfFiles() > 0)
ffafe6ca 860 LoadFile( event.GetFiles()[0] );
5ca0d812 861}
ef4a634b 862
7ea087b7
SC
863void wxTextCtrl::OnEraseBackground(wxEraseEvent& event)
864{
865 // all erasing should be done by the real mac control implementation
866 // while this is true for MLTE under classic, the HITextView is somehow
867 // transparent but background erase is not working correctly, so intercept
868 // things while we can...
395480fb 869 event.Skip() ;
7ea087b7
SC
870}
871
5ca0d812
SC
872void wxTextCtrl::OnChar(wxKeyEvent& event)
873{
874 int key = event.GetKeyCode() ;
875 bool eat_key = false ;
72055702 876
c4d9fc39
SC
877 if ( key == 'a' && event.MetaDown() )
878 {
88a7a4e1
WS
879 SelectAll() ;
880
c4d9fc39
SC
881 return ;
882 }
883
5ca0d812 884 if ( key == 'c' && event.MetaDown() )
72055702 885 {
5ca0d812
SC
886 if ( CanCopy() )
887 Copy() ;
fef981b4 888
5ca0d812 889 return ;
72055702
SC
890 }
891
5ca0d812 892 if ( !IsEditable() && key != WXK_LEFT && key != WXK_RIGHT && key != WXK_DOWN && key != WXK_UP && key != WXK_TAB &&
8e13c1ec 893 !( key == WXK_RETURN && ( (m_windowStyle & wxTE_PROCESS_ENTER) || (m_windowStyle & wxTE_MULTILINE) ) )
faa94f3e 894// && key != WXK_PAGEUP && key != WXK_PAGEDOWN && key != WXK_HOME && key != WXK_END
5ca0d812 895 )
29e4a190 896 {
5ca0d812
SC
897 // eat it
898 return ;
899 }
d3016f30 900
b9bae707
VZ
901 // Check if we have reached the max # of chars (if it is set), but still
902 // allow navigation and deletion
faa94f3e 903 if ( !IsMultiLine() && m_maxLength && GetValue().length() >= m_maxLength &&
bdf0c19c 904 key != WXK_LEFT && key != WXK_RIGHT && key != WXK_TAB &&
8e13c1ec 905 key != WXK_BACK && !( key == WXK_RETURN && (m_windowStyle & wxTE_PROCESS_ENTER) )
bdf0c19c
KH
906 )
907 {
908 // eat it, we don't want to add more than allowed # of characters
b9bae707
VZ
909
910 // TODO: generate EVT_TEXT_MAXLEN()
bdf0c19c
KH
911 return;
912 }
913
5ca0d812
SC
914 // assume that any key not processed yet is going to modify the control
915 m_dirty = true;
587bc950 916
5ca0d812
SC
917 if ( key == 'v' && event.MetaDown() )
918 {
919 if ( CanPaste() )
920 Paste() ;
0207e969 921
5ca0d812 922 return ;
29e4a190 923 }
fef981b4 924
5ca0d812 925 if ( key == 'x' && event.MetaDown() )
ed8c2780 926 {
5ca0d812
SC
927 if ( CanCut() )
928 Cut() ;
fef981b4 929
5ca0d812 930 return ;
1b2b1638 931 }
a8d2fb31 932
5ca0d812
SC
933 switch ( key )
934 {
935 case WXK_RETURN:
8e13c1ec 936 if (m_windowStyle & wxTE_PROCESS_ENTER)
5ca0d812
SC
937 {
938 wxCommandEvent event(wxEVT_COMMAND_TEXT_ENTER, m_windowId);
939 event.SetEventObject( this );
940 event.SetString( GetValue() );
941 if ( GetEventHandler()->ProcessEvent(event) )
942 return;
943 }
fef981b4 944
5ca0d812
SC
945 if ( !(m_windowStyle & wxTE_MULTILINE) )
946 {
6c20e8f8
VZ
947 wxTopLevelWindow *tlw = wxDynamicCast(wxGetTopLevelParent(this), wxTopLevelWindow);
948 if ( tlw && tlw->GetDefaultItem() )
fef981b4 949 {
6c20e8f8 950 wxButton *def = wxDynamicCast(tlw->GetDefaultItem(), wxButton);
5ca0d812
SC
951 if ( def && def->IsEnabled() )
952 {
953 wxCommandEvent event(wxEVT_COMMAND_BUTTON_CLICKED, def->GetId() );
954 event.SetEventObject(def);
955 def->Command(event);
fef981b4 956
5ca0d812 957 return ;
3dee36ae 958 }
5ca0d812
SC
959 }
960
961 // this will make wxWidgets eat the ENTER key so that
0207e969 962 // we actually prevent line wrapping in a single line text control
7d8268a1 963 eat_key = true;
5ca0d812 964 }
5ca0d812 965 break;
facd6764 966
5ca0d812
SC
967 case WXK_TAB:
968 if ( !(m_windowStyle & wxTE_PROCESS_TAB))
969 {
970 int flags = 0;
971 if (!event.ShiftDown())
972 flags |= wxNavigationKeyEvent::IsForward ;
973 if (event.ControlDown())
974 flags |= wxNavigationKeyEvent::WinChange ;
975 Navigate(flags);
fef981b4 976
5ca0d812
SC
977 return;
978 }
979 else
980 {
fef981b4
DS
981 // This is necessary (don't know why);
982 // otherwise the tab will not be inserted.
5ca0d812 983 WriteText(wxT("\t"));
4e6cc020 984 eat_key = true;
5ca0d812 985 }
a8d2fb31 986 break;
7d8268a1 987
a8d2fb31 988 default:
5ca0d812
SC
989 break;
990 }
facd6764 991
5ca0d812 992 if (!eat_key)
7f1de2b2 993 {
5ca0d812 994 // perform keystroke handling
665b537f 995 event.Skip(true) ;
7f1de2b2 996 }
a8d2fb31 997
5ca0d812 998 if ( ( key >= 0x20 && key < WXK_START ) ||
fce161de 999 ( key >= WXK_NUMPAD0 && key <= WXK_DIVIDE ) ||
5ca0d812
SC
1000 key == WXK_RETURN ||
1001 key == WXK_DELETE ||
1002 key == WXK_BACK)
7f1de2b2 1003 {
5ca0d812 1004 wxCommandEvent event1(wxEVT_COMMAND_TEXT_UPDATED, m_windowId);
5ca0d812 1005 event1.SetEventObject( this );
c88b7d28 1006 wxPostEvent( GetEventHandler(), event1 );
7f1de2b2 1007 }
5ca0d812 1008}
facd6764 1009
5ca0d812
SC
1010// ----------------------------------------------------------------------------
1011// standard handlers for standard edit menu events
1012// ----------------------------------------------------------------------------
1013
1014void wxTextCtrl::OnCut(wxCommandEvent& WXUNUSED(event))
1015{
1016 Cut();
72055702
SC
1017}
1018
5ca0d812 1019void wxTextCtrl::OnCopy(wxCommandEvent& WXUNUSED(event))
facd6764 1020{
5ca0d812
SC
1021 Copy();
1022}
7f1de2b2 1023
5ca0d812
SC
1024void wxTextCtrl::OnPaste(wxCommandEvent& WXUNUSED(event))
1025{
1026 Paste();
facd6764
SC
1027}
1028
5ca0d812 1029void wxTextCtrl::OnUndo(wxCommandEvent& WXUNUSED(event))
facd6764 1030{
5ca0d812 1031 Undo();
facd6764
SC
1032}
1033
5ca0d812
SC
1034void wxTextCtrl::OnRedo(wxCommandEvent& WXUNUSED(event))
1035{
1036 Redo();
1037}
facd6764 1038
24eef584
SC
1039void wxTextCtrl::OnDelete(wxCommandEvent& WXUNUSED(event))
1040{
1041 long from, to;
ffafe6ca 1042
c88b7d28 1043 GetSelection( &from, &to );
24eef584 1044 if (from != -1 && to != -1)
c88b7d28 1045 Remove( from, to );
24eef584
SC
1046}
1047
1048void wxTextCtrl::OnSelectAll(wxCommandEvent& WXUNUSED(event))
1049{
1050 SetSelection(-1, -1);
1051}
1052
5ca0d812 1053void wxTextCtrl::OnUpdateCut(wxUpdateUIEvent& event)
72055702 1054{
5ca0d812 1055 event.Enable( CanCut() );
72055702
SC
1056}
1057
5ca0d812
SC
1058void wxTextCtrl::OnUpdateCopy(wxUpdateUIEvent& event)
1059{
1060 event.Enable( CanCopy() );
72055702
SC
1061}
1062
5ca0d812 1063void wxTextCtrl::OnUpdatePaste(wxUpdateUIEvent& event)
72055702 1064{
5ca0d812 1065 event.Enable( CanPaste() );
72055702
SC
1066}
1067
5ca0d812 1068void wxTextCtrl::OnUpdateUndo(wxUpdateUIEvent& event)
29b30405 1069{
5ca0d812 1070 event.Enable( CanUndo() );
29b30405
SC
1071}
1072
5ca0d812 1073void wxTextCtrl::OnUpdateRedo(wxUpdateUIEvent& event)
facd6764 1074{
5ca0d812 1075 event.Enable( CanRedo() );
facd6764
SC
1076}
1077
24eef584
SC
1078void wxTextCtrl::OnUpdateDelete(wxUpdateUIEvent& event)
1079{
1080 long from, to;
ffafe6ca 1081
c88b7d28 1082 GetSelection( &from, &to );
0207e969 1083 event.Enable( from != -1 && to != -1 && from != to && IsEditable() ) ;
24eef584
SC
1084}
1085
1086void wxTextCtrl::OnUpdateSelectAll(wxUpdateUIEvent& event)
1087{
1088 event.Enable(GetLastPosition() > 0);
1089}
1090
a8d2fb31 1091// CS: Context Menus only work with MLTE implementations or non-multiline HIViews at the moment
24eef584
SC
1092
1093void wxTextCtrl::OnContextMenu(wxContextMenuEvent& event)
1094{
64bd657c
SC
1095 if ( GetPeer()->HasOwnContextMenu() )
1096 {
1097 event.Skip() ;
1098 return ;
1099 }
0207e969 1100
24eef584
SC
1101 if (m_privateContextMenu == NULL)
1102 {
1103 m_privateContextMenu = new wxMenu;
1104 m_privateContextMenu->Append(wxID_UNDO, _("&Undo"));
1105 m_privateContextMenu->Append(wxID_REDO, _("&Redo"));
1106 m_privateContextMenu->AppendSeparator();
1107 m_privateContextMenu->Append(wxID_CUT, _("Cu&t"));
1108 m_privateContextMenu->Append(wxID_COPY, _("&Copy"));
1109 m_privateContextMenu->Append(wxID_PASTE, _("&Paste"));
1110 m_privateContextMenu->Append(wxID_CLEAR, _("&Delete"));
1111 m_privateContextMenu->AppendSeparator();
1112 m_privateContextMenu->Append(wxID_SELECTALL, _("Select &All"));
1113 }
faa94f3e 1114
24eef584
SC
1115 if (m_privateContextMenu != NULL)
1116 PopupMenu(m_privateContextMenu);
1117}
1118
5ca0d812 1119bool wxTextCtrl::MacSetupCursor( const wxPoint& pt )
29b30405 1120{
0207e969 1121 if ( !GetPeer()->SetupCursor( pt ) )
f2c3f2a8
SC
1122 return wxWindow::MacSetupCursor( pt ) ;
1123 else
1124 return true ;
5ca0d812 1125}
a8d2fb31 1126
20b69855 1127#if !TARGET_API_MAC_OSX
24260aae 1128
5ca0d812 1129// user pane implementation
ef4a634b 1130
7d8268a1 1131void wxTextCtrl::MacControlUserPaneDrawProc(wxInt16 part)
5ca0d812 1132{
24260aae 1133 GetPeer()->MacControlUserPaneDrawProc( part ) ;
29b30405
SC
1134}
1135
7d8268a1 1136wxInt16 wxTextCtrl::MacControlUserPaneHitTestProc(wxInt16 x, wxInt16 y)
29b30405 1137{
24260aae 1138 return GetPeer()->MacControlUserPaneHitTestProc( x , y ) ;
29b30405
SC
1139}
1140
7d8268a1 1141wxInt16 wxTextCtrl::MacControlUserPaneTrackingProc(wxInt16 x, wxInt16 y, void* actionProc)
72055702 1142{
24260aae 1143 return GetPeer()->MacControlUserPaneTrackingProc( x , y , actionProc ) ;
72055702
SC
1144}
1145
7d8268a1 1146void wxTextCtrl::MacControlUserPaneIdleProc()
72055702 1147{
24260aae 1148 GetPeer()->MacControlUserPaneIdleProc( ) ;
72055702
SC
1149}
1150
7d8268a1 1151wxInt16 wxTextCtrl::MacControlUserPaneKeyDownProc(wxInt16 keyCode, wxInt16 charCode, wxInt16 modifiers)
72055702 1152{
24260aae 1153 return GetPeer()->MacControlUserPaneKeyDownProc( keyCode , charCode , modifiers ) ;
72055702
SC
1154}
1155
7d8268a1 1156void wxTextCtrl::MacControlUserPaneActivateProc(bool activating)
72055702 1157{
24260aae 1158 GetPeer()->MacControlUserPaneActivateProc( activating ) ;
72055702
SC
1159}
1160
7d8268a1 1161wxInt16 wxTextCtrl::MacControlUserPaneFocusProc(wxInt16 action)
72055702 1162{
24260aae 1163 return GetPeer()->MacControlUserPaneFocusProc( action ) ;
72055702
SC
1164}
1165
7d8268a1 1166void wxTextCtrl::MacControlUserPaneBackgroundProc(void* info)
72055702 1167{
24260aae 1168 GetPeer()->MacControlUserPaneBackgroundProc( info ) ;
5ca0d812 1169}
24260aae 1170
20b69855 1171#endif
a8d2fb31 1172
5ca0d812
SC
1173// ----------------------------------------------------------------------------
1174// implementation base class
1175// ----------------------------------------------------------------------------
1176
0f7817ab
SC
1177wxMacTextControl::wxMacTextControl(wxTextCtrl* peer) :
1178 wxMacControl( peer )
5ca0d812 1179{
72055702
SC
1180}
1181
7d8268a1 1182wxMacTextControl::~wxMacTextControl()
72055702 1183{
72055702
SC
1184}
1185
7d8268a1 1186void wxMacTextControl::SetStyle(long start, long end, const wxTextAttr& style)
72055702 1187{
72055702
SC
1188}
1189
7d8268a1 1190void wxMacTextControl::Copy()
72055702 1191{
72055702
SC
1192}
1193
7d8268a1 1194void wxMacTextControl::Cut()
72055702 1195{
72055702
SC
1196}
1197
7d8268a1 1198void wxMacTextControl::Paste()
72055702 1199{
72055702
SC
1200}
1201
7d8268a1
WS
1202bool wxMacTextControl::CanPaste() const
1203{
5ca0d812
SC
1204 return false ;
1205}
1206
7d8268a1 1207void wxMacTextControl::SetEditable(bool editable)
72055702 1208{
7d8268a1 1209}
facd6764 1210
7d8268a1 1211wxTextPos wxMacTextControl::GetLastPosition() const
5ca0d812 1212{
faa94f3e 1213 return GetStringValue().length() ;
5ca0d812 1214}
facd6764 1215
44aa865d
SC
1216void wxMacTextControl::Replace( long from , long to , const wxString &val )
1217{
1218 SetSelection( from , to ) ;
fef981b4 1219 WriteText( val ) ;
44aa865d
SC
1220}
1221
1222void wxMacTextControl::Remove( long from , long to )
5ca0d812 1223{
44aa865d
SC
1224 SetSelection( from , to ) ;
1225 WriteText( wxEmptyString) ;
72055702
SC
1226}
1227
7d8268a1 1228void wxMacTextControl::Clear()
72055702 1229{
5ca0d812 1230 SetStringValue( wxEmptyString ) ;
72055702
SC
1231}
1232
7d8268a1 1233bool wxMacTextControl::CanUndo() const
72055702 1234{
5ca0d812
SC
1235 return false ;
1236}
587bc950 1237
a8d2fb31
DS
1238void wxMacTextControl::Undo()
1239{
1240}
5ca0d812
SC
1241
1242bool wxMacTextControl::CanRedo() const
1243{
1244 return false ;
7d8268a1 1245}
5ca0d812 1246
7d8268a1 1247void wxMacTextControl::Redo()
5ca0d812 1248{
72055702
SC
1249}
1250
5ca0d812 1251long wxMacTextControl::XYToPosition(long x, long y) const
72055702 1252{
5ca0d812
SC
1253 return 0 ;
1254}
72055702 1255
7d8268a1 1256bool wxMacTextControl::PositionToXY(long pos, long *x, long *y) const
5ca0d812
SC
1257{
1258 return false ;
72055702
SC
1259}
1260
7d8268a1
WS
1261void wxMacTextControl::ShowPosition( long WXUNUSED(pos) )
1262{
1263}
5ca0d812 1264
7d8268a1 1265int wxMacTextControl::GetNumberOfLines() const
7548762c 1266{
5ca0d812
SC
1267 ItemCount lines = 0 ;
1268 wxString content = GetStringValue() ;
1269 lines = 1;
fef981b4 1270
faa94f3e 1271 for (size_t i = 0; i < content.length() ; i++)
7548762c 1272 {
fef981b4
DS
1273 if (content[i] == '\r')
1274 lines++;
7548762c 1275 }
a8d2fb31 1276
5ca0d812
SC
1277 return lines ;
1278}
7548762c 1279
5ca0d812 1280wxString wxMacTextControl::GetLineText(long lineNo) const
7548762c 1281{
fef981b4 1282 // TODO: change this if possible to reflect real lines
5ca0d812 1283 wxString content = GetStringValue() ;
7d8268a1 1284
5ca0d812
SC
1285 // Find line first
1286 int count = 0;
faa94f3e 1287 for (size_t i = 0; i < content.length() ; i++)
7548762c 1288 {
5ca0d812
SC
1289 if (count == lineNo)
1290 {
1291 // Add chars in line then
1292 wxString tmp;
7d8268a1 1293
faa94f3e 1294 for (size_t j = i; j < content.length(); j++)
5ca0d812
SC
1295 {
1296 if (content[j] == '\n')
1297 return tmp;
7d8268a1 1298
5ca0d812
SC
1299 tmp += content[j];
1300 }
7d8268a1 1301
5ca0d812
SC
1302 return tmp;
1303 }
a8d2fb31 1304
fef981b4
DS
1305 if (content[i] == '\n')
1306 count++;
7548762c 1307 }
a8d2fb31 1308
5ca0d812
SC
1309 return wxEmptyString ;
1310}
7548762c 1311
a8d2fb31 1312int wxMacTextControl::GetLineLength(long lineNo) const
5ca0d812 1313{
fef981b4 1314 // TODO: change this if possible to reflect real lines
5ca0d812 1315 wxString content = GetStringValue() ;
7d8268a1 1316
5ca0d812
SC
1317 // Find line first
1318 int count = 0;
faa94f3e 1319 for (size_t i = 0; i < content.length() ; i++)
7548762c 1320 {
5ca0d812
SC
1321 if (count == lineNo)
1322 {
1323 // Count chars in line then
1324 count = 0;
faa94f3e 1325 for (size_t j = i; j < content.length(); j++)
5ca0d812
SC
1326 {
1327 count++;
a8d2fb31
DS
1328 if (content[j] == '\n')
1329 return count;
5ca0d812 1330 }
7d8268a1 1331
5ca0d812
SC
1332 return count;
1333 }
a8d2fb31 1334
fef981b4
DS
1335 if (content[i] == '\n')
1336 count++;
7548762c 1337 }
a8d2fb31 1338
5ca0d812
SC
1339 return 0 ;
1340}
7548762c 1341
5ca0d812
SC
1342// ----------------------------------------------------------------------------
1343// standard unicode control implementation
1344// ----------------------------------------------------------------------------
1345
1346#if TARGET_API_MAC_OSX
1347
ad604d0f
SC
1348// the current unicode textcontrol implementation has a bug : only if the control
1349// is currently having the focus, the selection can be retrieved by the corresponding
1350// data tag. So we have a mirroring using a member variable
1351// TODO : build event table using virtual member functions for wxMacControl
1352
1353static const EventTypeSpec unicodeTextControlEventList[] =
1354{
1355 { kEventClassControl , kEventControlSetFocusPart } ,
1356} ;
1357
1358static pascal OSStatus wxMacUnicodeTextControlControlEventHandler( EventHandlerCallRef handler , EventRef event , void *data )
1359{
1360 OSStatus result = eventNotHandledErr ;
1361 wxMacUnicodeTextControl* focus = (wxMacUnicodeTextControl*) data ;
1362 wxMacCarbonEvent cEvent( event ) ;
9eddec69 1363
ad604d0f
SC
1364 switch ( GetEventKind( event ) )
1365 {
1366 case kEventControlSetFocusPart :
1367 {
1368 ControlPartCode controlPart = cEvent.GetParameter<ControlPartCode>(kEventParamControlPart , typeControlPartCode );
1369 if ( controlPart == kControlFocusNoPart )
1370 {
1371 // about to loose focus -> store selection to field
1372 focus->GetData<ControlEditTextSelectionRec>( 0, kControlEditTextSelectionTag, &focus->m_selection );
1373 }
1374 result = CallNextEventHandler(handler,event) ;
1375 if ( controlPart != kControlFocusNoPart )
1376 {
1377 // about to gain focus -> set selection from field
1378 focus->SetData<ControlEditTextSelectionRec>( 0, kControlEditTextSelectionTag, &focus->m_selection );
1379 }
1380 break;
1381 }
1382 default:
1383 break ;
1384 }
9eddec69 1385
ad604d0f
SC
1386 return result ;
1387}
1388
1389static pascal OSStatus wxMacUnicodeTextControlEventHandler( EventHandlerCallRef handler , EventRef event , void *data )
1390{
1391 OSStatus result = eventNotHandledErr ;
9eddec69 1392
ad604d0f
SC
1393 switch ( GetEventClass( event ) )
1394 {
1395 case kEventClassControl :
1396 result = wxMacUnicodeTextControlControlEventHandler( handler , event , data ) ;
1397 break ;
9eddec69 1398
ad604d0f
SC
1399 default :
1400 break ;
1401 }
1402 return result ;
1403}
1404
1405DEFINE_ONE_SHOT_HANDLER_GETTER( wxMacUnicodeTextControlEventHandler )
1406
0f7817ab 1407wxMacUnicodeTextControl::wxMacUnicodeTextControl( wxTextCtrl *wxPeer,
ffafe6ca
DS
1408 const wxString& str,
1409 const wxPoint& pos,
1410 const wxSize& size, long style )
1411 : wxMacTextControl( wxPeer )
5ca0d812
SC
1412{
1413 m_font = wxPeer->GetFont() ;
1414 m_windowStyle = style ;
7d8268a1 1415 Rect bounds = wxMacGetBoundsForControl( wxPeer , pos , size ) ;
5ca0d812 1416 wxString st = str ;
395480fb 1417 wxMacConvertNewlines10To13( &st ) ;
5ca0d812
SC
1418 wxMacCFStringHolder cf(st , m_font.GetEncoding()) ;
1419 CFStringRef cfr = cf ;
1420 Boolean isPassword = ( m_windowStyle & wxTE_PASSWORD ) != 0 ;
1421 m_valueTag = isPassword ? kControlEditTextPasswordCFStringTag : kControlEditTextCFStringTag ;
ffafe6ca
DS
1422
1423 OSStatus err = CreateEditUnicodeTextControl(
fef981b4
DS
1424 MAC_WXHWND(wxPeer->MacGetTopLevelWindowRef()), &bounds , cfr ,
1425 isPassword , NULL , &m_controlRef ) ;
ffafe6ca 1426 verify_noerr( err );
7d8268a1 1427
5ca0d812 1428 if ( !(m_windowStyle & wxTE_MULTILINE) )
5ca0d812 1429 SetData<Boolean>( kControlEditTextPart , kControlEditTextSingleLineTag , true ) ;
ad604d0f
SC
1430
1431 InstallControlEventHandler( m_controlRef , GetwxMacUnicodeTextControlEventHandlerUPP(),
1432 GetEventTypeCount(unicodeTextControlEventList), unicodeTextControlEventList, this,
1433 &m_focusHandlerRef);
5ca0d812 1434}
7548762c 1435
5ca0d812 1436wxMacUnicodeTextControl::~wxMacUnicodeTextControl()
7548762c 1437{
ad604d0f 1438 ::RemoveEventHandler( m_focusHandlerRef );
7548762c
SC
1439}
1440
7d8268a1 1441void wxMacUnicodeTextControl::VisibilityChanged(bool shown)
7548762c 1442{
5ca0d812
SC
1443 if ( !(m_windowStyle & wxTE_MULTILINE) && shown )
1444 {
fef981b4
DS
1445 // work around a refresh issue insofar as not always the entire content is shown,
1446 // even if this would be possible
5ca0d812
SC
1447 ControlEditTextSelectionRec sel ;
1448 CFStringRef value = NULL ;
7548762c 1449
5ca0d812 1450 verify_noerr( GetData<ControlEditTextSelectionRec>( 0, kControlEditTextSelectionTag, &sel ) );
c88b7d28 1451 verify_noerr( GetData<CFStringRef>( 0, m_valueTag, &value ) );
5ca0d812
SC
1452 verify_noerr( SetData<CFStringRef>( 0, m_valueTag, &value ) );
1453 verify_noerr( SetData<ControlEditTextSelectionRec>( 0, kControlEditTextSelectionTag, &sel ) );
7d8268a1 1454
5ca0d812
SC
1455 CFRelease( value ) ;
1456 }
1457}
a8d2fb31 1458
7d8268a1 1459wxString wxMacUnicodeTextControl::GetStringValue() const
7548762c 1460{
5ca0d812 1461 wxString result ;
c88b7d28 1462 CFStringRef value = GetData<CFStringRef>(0, m_valueTag) ;
5ca0d812
SC
1463 if ( value )
1464 {
1465 wxMacCFStringHolder cf(value) ;
1466 result = cf.AsString() ;
1467 }
a8d2fb31 1468
2e7573f7 1469#if '\n' == 10
395480fb
SC
1470 wxMacConvertNewlines13To10( &result ) ;
1471#else
5ca0d812 1472 wxMacConvertNewlines10To13( &result ) ;
395480fb 1473#endif
a8d2fb31 1474
7548762c
SC
1475 return result ;
1476}
a8d2fb31 1477
c88b7d28 1478void wxMacUnicodeTextControl::SetStringValue( const wxString &str )
5ca0d812
SC
1479{
1480 wxString st = str ;
395480fb 1481 wxMacConvertNewlines10To13( &st ) ;
ffafe6ca 1482 wxMacCFStringHolder cf( st , m_font.GetEncoding() ) ;
0207e969 1483 verify_noerr( SetData<CFStringRef>( 0, m_valueTag , cf ) ) ;
5ca0d812 1484}
a8d2fb31 1485
5ca0d812
SC
1486void wxMacUnicodeTextControl::Copy()
1487{
1488 SendHICommand( kHICommandCopy ) ;
1489}
a8d2fb31 1490
5ca0d812
SC
1491void wxMacUnicodeTextControl::Cut()
1492{
1493 SendHICommand( kHICommandCut ) ;
1494}
a8d2fb31 1495
5ca0d812
SC
1496void wxMacUnicodeTextControl::Paste()
1497{
1498 SendHICommand( kHICommandPaste ) ;
1499}
a8d2fb31 1500
5ca0d812
SC
1501bool wxMacUnicodeTextControl::CanPaste() const
1502{
1503 return true ;
1504}
a8d2fb31 1505
7d8268a1 1506void wxMacUnicodeTextControl::SetEditable(bool editable)
5ca0d812 1507{
35d9ac06
SC
1508#if 0 // leads to problem because text cannot be selected anymore
1509 SetData<Boolean>( kControlEditTextPart , kControlEditTextLockedTag , (Boolean) !editable ) ;
1510#endif
5ca0d812 1511}
7548762c 1512
0207e969 1513void wxMacUnicodeTextControl::GetSelection( long* from, long* to ) const
7548762c 1514{
5ca0d812 1515 ControlEditTextSelectionRec sel ;
ad604d0f
SC
1516 if (HasFocus())
1517 verify_noerr( GetData<ControlEditTextSelectionRec>( 0, kControlEditTextSelectionTag, &sel ) ) ;
1518 else
1519 sel = m_selection ;
9eddec69 1520
0207e969
DS
1521 if ( from )
1522 *from = sel.selStart ;
1523 if ( to )
1524 *to = sel.selEnd ;
7548762c
SC
1525}
1526
7d8268a1 1527void wxMacUnicodeTextControl::SetSelection( long from , long to )
ef4a634b 1528{
5ca0d812 1529 ControlEditTextSelectionRec sel ;
ad604d0f
SC
1530 wxString result ;
1531 int textLength = 0 ;
1532 CFStringRef value = GetData<CFStringRef>(0, m_valueTag) ;
1533 if ( value )
1534 {
1535 wxMacCFStringHolder cf(value) ;
1832043f 1536 textLength = cf.AsString().length() ;
ad604d0f
SC
1537 }
1538
1a535eb9
SC
1539 if ((from == -1) && (to == -1))
1540 {
1541 from = 0 ;
9eddec69 1542 to = textLength ;
ad604d0f
SC
1543 }
1544 else
1545 {
1546 from = wxMin(textLength,wxMax(from,0)) ;
1547 to = wxMax(0,wxMin(textLength,to)) ;
1a535eb9 1548 }
a8d2fb31 1549
5ca0d812
SC
1550 sel.selStart = from ;
1551 sel.selEnd = to ;
ad604d0f
SC
1552 if ( HasFocus() )
1553 SetData<ControlEditTextSelectionRec>( 0, kControlEditTextSelectionTag, &sel ) ;
1554 else
1555 m_selection = sel;
5ca0d812 1556}
facd6764 1557
c88b7d28 1558void wxMacUnicodeTextControl::WriteText( const wxString& str )
5ca0d812
SC
1559{
1560 wxString st = str ;
395480fb 1561 wxMacConvertNewlines10To13( &st ) ;
0207e969
DS
1562
1563#if MAC_OS_X_VERSION_MAX_ALLOWED > MAC_OS_X_VERSION_10_2
ad604d0f
SC
1564 if ( HasFocus() )
1565 {
7548762c
SC
1566 wxMacCFStringHolder cf(st , m_font.GetEncoding() ) ;
1567 CFStringRef value = cf ;
5ca0d812 1568 SetData<CFStringRef>( 0, kControlEditTextInsertCFStringRefTag, &value );
ad604d0f 1569 }
df39467f 1570 else
ad604d0f
SC
1571#endif
1572 {
5ca0d812 1573 wxString val = GetStringValue() ;
7548762c
SC
1574 long start , end ;
1575 GetSelection( &start , &end ) ;
1576 val.Remove( start , end - start ) ;
1577 val.insert( start , str ) ;
5ca0d812 1578 SetStringValue( val ) ;
faa94f3e 1579 SetSelection( start + str.length() , start + str.length() ) ;
ad604d0f 1580 }
72055702
SC
1581}
1582
5ca0d812 1583#endif
facd6764 1584
5ca0d812
SC
1585// ----------------------------------------------------------------------------
1586// MLTE control implementation (common part)
1587// ----------------------------------------------------------------------------
facd6764 1588
a8d2fb31 1589// if MTLE is read only, no changes at all are allowed, not even from
5ca0d812
SC
1590// procedural API, in order to allow changes via API all the same we must undo
1591// the readonly status while we are executing, this class helps to do so
72055702 1592
5de694f0 1593class wxMacEditHelper
72055702 1594{
5ca0d812 1595public :
5de694f0 1596 wxMacEditHelper( TXNObject txn )
5ca0d812
SC
1597 {
1598 TXNControlTag tag[] = { kTXNIOPrivilegesTag } ;
1599 m_txn = txn ;
1600 TXNGetTXNObjectControls( m_txn , 1 , tag , m_data ) ;
1601 if ( m_data[0].uValue == kTXNReadOnly )
1602 {
1603 TXNControlData data[] = { { kTXNReadWrite } } ;
1604 TXNSetTXNObjectControls( m_txn , false , 1 , tag , data ) ;
1605 }
1606 }
a8d2fb31 1607
5de694f0 1608 ~wxMacEditHelper()
5ca0d812
SC
1609 {
1610 TXNControlTag tag[] = { kTXNIOPrivilegesTag } ;
1611 if ( m_data[0].uValue == kTXNReadOnly )
5ca0d812 1612 TXNSetTXNObjectControls( m_txn , false , 1 , tag , m_data ) ;
5ca0d812 1613 }
a8d2fb31 1614
fef981b4
DS
1615protected :
1616 TXNObject m_txn ;
1617 TXNControlData m_data[1] ;
5ca0d812 1618} ;
72055702 1619
ffafe6ca
DS
1620wxMacMLTEControl::wxMacMLTEControl( wxTextCtrl *peer )
1621 : wxMacTextControl( peer )
789ae0cf 1622{
3dee36ae 1623 SetNeedsFocusRect( true ) ;
789ae0cf
SC
1624}
1625
7d8268a1 1626wxString wxMacMLTEControl::GetStringValue() const
72055702 1627{
5ca0d812
SC
1628 wxString result ;
1629 OSStatus err ;
1630 Size actualSize = 0;
c88b7d28 1631
5ca0d812
SC
1632 {
1633#if wxUSE_UNICODE
1634 Handle theText ;
c88b7d28 1635 err = TXNGetDataEncoded( m_txn, kTXNStartOffset, kTXNEndOffset, &theText, kTXNUnicodeTextData );
fef981b4 1636
5ca0d812 1637 // all done
fef981b4 1638 if ( err != noErr )
5ca0d812
SC
1639 {
1640 actualSize = 0 ;
1641 }
1642 else
1643 {
c88b7d28 1644 actualSize = GetHandleSize( theText ) / sizeof(UniChar) ;
5ca0d812
SC
1645 if ( actualSize > 0 )
1646 {
1647 wxChar *ptr = NULL ;
fef981b4 1648
7d8268a1 1649#if SIZEOF_WCHAR_T == 2
c88b7d28
DS
1650 ptr = new wxChar[actualSize + 1] ;
1651 wxStrncpy( ptr , (wxChar*)(*theText) , actualSize ) ;
5ca0d812 1652#else
c88b7d28 1653 SetHandleSize( theText, (actualSize + 1) * sizeof(UniChar) ) ;
5ca0d812
SC
1654 HLock( theText ) ;
1655 (((UniChar*)*theText)[actualSize]) = 0 ;
d9d488cf 1656 wxMBConvUTF16 converter ;
5ca0d812 1657 size_t noChars = converter.MB2WC( NULL , (const char*)*theText , 0 ) ;
88a7a4e1 1658 wxASSERT_MSG( noChars != wxCONV_FAILED, _T("Unable to count the number of characters in this string!") );
5ca0d812 1659 ptr = new wxChar[noChars + 1] ;
7d8268a1 1660
f3097709 1661 noChars = converter.MB2WC( ptr , (const char*)*theText , noChars + 1 ) ;
88a7a4e1 1662 wxASSERT_MSG( noChars != wxCONV_FAILED, _T("Conversion of string failed!") );
5ca0d812
SC
1663 ptr[noChars] = 0 ;
1664 HUnlock( theText ) ;
1665#endif
fef981b4 1666
5ca0d812
SC
1667 ptr[actualSize] = 0 ;
1668 result = wxString( ptr ) ;
c88b7d28 1669 delete [] ptr ;
5ca0d812 1670 }
a8d2fb31 1671
5ca0d812
SC
1672 DisposeHandle( theText ) ;
1673 }
1674#else
1675 Handle theText ;
c88b7d28 1676 err = TXNGetDataEncoded( m_txn , kTXNStartOffset, kTXNEndOffset, &theText, kTXNTextData );
0207e969 1677
5ca0d812 1678 // all done
0207e969 1679 if ( err != noErr )
5ca0d812
SC
1680 {
1681 actualSize = 0 ;
1682 }
1683 else
1684 {
1685 actualSize = GetHandleSize( theText ) ;
1686 if ( actualSize > 0 )
1687 {
1688 HLock( theText ) ;
1689 result = wxString( *theText , wxConvLocal , actualSize ) ;
1690 HUnlock( theText ) ;
1691 }
a8d2fb31 1692
5ca0d812
SC
1693 DisposeHandle( theText ) ;
1694 }
1695#endif
1696 }
a8d2fb31 1697
2e7573f7 1698#if '\n' == 10
395480fb
SC
1699 wxMacConvertNewlines13To10( &result ) ;
1700#else
5ca0d812 1701 wxMacConvertNewlines10To13( &result ) ;
395480fb 1702#endif
a8d2fb31 1703
5ca0d812 1704 return result ;
72055702
SC
1705}
1706
0207e969 1707void wxMacMLTEControl::SetStringValue( const wxString &str )
72055702 1708{
c88b7d28
DS
1709 wxString st = str;
1710 wxMacConvertNewlines10To13( &st );
395480fb 1711
5de694f0 1712 {
c88b7d28 1713 wxMacWindowClipper c( m_peer );
0207e969 1714
5de694f0 1715 {
c88b7d28
DS
1716 wxMacEditHelper help( m_txn );
1717 SetTXNData( st, kTXNStartOffset, kTXNEndOffset );
5de694f0 1718 }
0207e969 1719
fef981b4
DS
1720 TXNSetSelection( m_txn, 0, 0 );
1721 TXNShowSelection( m_txn, kTXNShowStart );
5de694f0 1722 }
5ca0d812 1723}
facd6764 1724
5ca0d812
SC
1725TXNFrameOptions wxMacMLTEControl::FrameOptionsFromWXStyle( long wxStyle )
1726{
c88b7d28
DS
1727 TXNFrameOptions frameOptions = kTXNDontDrawCaretWhenInactiveMask;
1728
b7e28620 1729#if MAC_OS_X_VERSION_MAX_ALLOWED >= MAC_OS_X_VERSION_10_3
c88b7d28 1730 frameOptions |= kTXNDoFontSubstitutionMask;
b7e28620 1731#endif
4d7528a1 1732
c88b7d28 1733 if ( ! (wxStyle & wxTE_NOHIDESEL) )
5ca0d812
SC
1734 frameOptions |= kTXNDontDrawSelectionWhenInactiveMask ;
1735
c88b7d28
DS
1736 if ( wxStyle & (wxHSCROLL | wxTE_DONTWRAP) )
1737 frameOptions |= kTXNWantHScrollBarMask ;
1738
5ca0d812 1739 if ( wxStyle & wxTE_MULTILINE )
29e4a190 1740 {
c88b7d28 1741 frameOptions |= kTXNAlwaysWrapAtViewEdgeMask ;
72055702 1742
c88b7d28 1743 if ( !(wxStyle & wxTE_NO_VSCROLL) )
5de694f0 1744 {
5ca0d812 1745 frameOptions |= kTXNWantVScrollBarMask ;
c88b7d28 1746
04c3457a
DS
1747 // The following code causes drawing problems on 10.4. Perhaps it can be restored for
1748 // older versions of the OS, but I'm not sure it's appropriate to put a grow icon here
1749 // anyways, as AFAIK users can't actually use it to resize the text ctrl.
1750// if ( frameOptions & kTXNWantHScrollBarMask )
1751// frameOptions |= kTXNDrawGrowIconMask ;
5de694f0 1752 }
5ca0d812
SC
1753 }
1754 else
c88b7d28 1755 {
5ca0d812 1756 frameOptions |= kTXNSingleLineOnlyMask ;
c88b7d28 1757 }
7d8268a1 1758
5ca0d812
SC
1759 return frameOptions ;
1760}
cfeff6f7 1761
5ca0d812
SC
1762void wxMacMLTEControl::AdjustCreationAttributes( const wxColour &background, bool visible )
1763{
3dee36ae
WS
1764 TXNControlTag iControlTags[] =
1765 {
1766 kTXNDoFontSubstitution,
5de694f0
SC
1767 kTXNWordWrapStateTag ,
1768 };
3dee36ae
WS
1769 TXNControlData iControlData[] =
1770 {
c88b7d28
DS
1771 { true },
1772 { kTXNNoAutoWrap },
5de694f0 1773 };
3dee36ae 1774
5de694f0 1775 int toptag = WXSIZEOF( iControlTags ) ;
7d8268a1 1776
72055702
SC
1777 if ( m_windowStyle & wxTE_MULTILINE )
1778 {
c88b7d28
DS
1779 iControlData[1].uValue =
1780 (m_windowStyle & wxTE_DONTWRAP)
1781 ? kTXNNoAutoWrap
1782 : kTXNAutoWrap;
72055702 1783 }
0207e969 1784
ffafe6ca
DS
1785 OSStatus err = TXNSetTXNObjectControls( m_txn, false, toptag, iControlTags, iControlData ) ;
1786 verify_noerr( err );
facd6764 1787
fef981b4 1788 // setting the default font:
8e15e610 1789 // under 10.2 this causes a visible caret, therefore we avoid it
72055702 1790
8e15e610 1791 if ( UMAGetSystemVersion() >= 0x1030 )
72055702 1792 {
8e15e610
SC
1793 Str255 fontName ;
1794 SInt16 fontSize ;
1795 Style fontStyle ;
5ca0d812 1796
ffafe6ca 1797 GetThemeFont( kThemeSystemFont , GetApplicationScript() , fontName , &fontSize , &fontStyle ) ;
5ca0d812 1798
8e15e610
SC
1799 TXNTypeAttributes typeAttr[] =
1800 {
c88b7d28
DS
1801 { kTXNQDFontNameAttribute , kTXNQDFontNameAttributeSize , { (void*) fontName } } ,
1802 { kTXNQDFontSizeAttribute , kTXNFontSizeAttributeSize , { (void*) (fontSize << 16) } } ,
1803 { kTXNQDFontStyleAttribute , kTXNQDFontStyleAttributeSize , { (void*) normal } } ,
8e15e610
SC
1804 } ;
1805
ffafe6ca
DS
1806 err = TXNSetTypeAttributes(
1807 m_txn, sizeof(typeAttr) / sizeof(TXNTypeAttributes),
1808 typeAttr, kTXNStartOffset, kTXNEndOffset );
1809 verify_noerr( err );
8e15e610 1810 }
3dee36ae 1811
5ca0d812
SC
1812 if ( m_windowStyle & wxTE_PASSWORD )
1813 {
ffafe6ca
DS
1814 UniChar c = 0x00A5 ;
1815 err = TXNEchoMode( m_txn , c , 0 , true );
1816 verify_noerr( err );
72055702 1817 }
5ca0d812
SC
1818
1819 TXNBackground tback;
1820 tback.bgType = kTXNBackgroundTypeRGB;
1821 tback.bg.color = MAC_WXCOLORREF( background.GetPixel() );
0207e969 1822 TXNSetBackground( m_txn , &tback );
a8d2fb31 1823
64bd657c
SC
1824#if MAC_OS_X_VERSION_MAX_ALLOWED >= MAC_OS_X_VERSION_10_4
1825 if ( UMAGetSystemVersion() >= 0x1040 )
1826 {
1827 TXNCommandEventSupportOptions options ;
fef981b4 1828 if ( TXNGetCommandEventSupport( m_txn, &options ) == noErr )
64bd657c 1829 {
fef981b4
DS
1830 options |=
1831 kTXNSupportEditCommandProcessing
1832 | kTXNSupportEditCommandUpdating
1833 | kTXNSupportSpellCheckCommandProcessing
1834 | kTXNSupportSpellCheckCommandUpdating
1835 | kTXNSupportFontCommandProcessing
1836 | kTXNSupportFontCommandUpdating;
9eddec69 1837
64bd657c
SC
1838 TXNSetCommandEventSupport( m_txn , options ) ;
1839 }
1840 }
1841#endif
72055702
SC
1842}
1843
7d8268a1 1844void wxMacMLTEControl::SetBackground( const wxBrush &brush )
7ea087b7
SC
1845{
1846 // currently only solid background are supported
1847 TXNBackground tback;
0207e969 1848
7ea087b7
SC
1849 tback.bgType = kTXNBackgroundTypeRGB;
1850 tback.bg.color = MAC_WXCOLORREF( brush.GetColour().GetPixel() );
0207e969 1851 TXNSetBackground( m_txn , &tback );
7ea087b7
SC
1852}
1853
0207e969 1854void wxMacMLTEControl::TXNSetAttribute( const wxTextAttr& style , long from , long to )
72055702 1855{
7d8268a1 1856 TXNTypeAttributes typeAttr[4] ;
5ca0d812 1857 RGBColor color ;
0207e969 1858 int attrCount = 0 ;
fef981b4 1859
5ca0d812 1860 if ( style.HasFont() )
72055702 1861 {
5ca0d812 1862 const wxFont &font = style.GetFont() ;
9eddec69 1863
acead93d 1864#if 0 // old version
09660720
SC
1865 Str255 fontName = "\pMonaco" ;
1866 SInt16 fontSize = 12 ;
1867 Style fontStyle = normal ;
5ca0d812
SC
1868 wxMacStringToPascal( font.GetFaceName() , fontName ) ;
1869 fontSize = font.GetPointSize() ;
1870 if ( font.GetUnderlined() )
1871 fontStyle |= underline ;
1872 if ( font.GetWeight() == wxBOLD )
1873 fontStyle |= bold ;
1874 if ( font.GetStyle() == wxITALIC )
1875 fontStyle |= italic ;
eda3f2b4 1876
0207e969
DS
1877 typeAttr[attrCount].tag = kTXNQDFontNameAttribute ;
1878 typeAttr[attrCount].size = kTXNQDFontNameAttributeSize ;
1879 typeAttr[attrCount].data.dataPtr = (void*)fontName ;
1880 attrCount++ ;
1881
1882 typeAttr[attrCount].tag = kTXNQDFontSizeAttribute ;
1883 typeAttr[attrCount].size = kTXNFontSizeAttributeSize ;
1884 typeAttr[attrCount].data.dataValue = (fontSize << 16) ;
1885 attrCount++ ;
1886
1887 typeAttr[attrCount].tag = kTXNQDFontStyleAttribute ;
1888 typeAttr[attrCount].size = kTXNQDFontStyleAttributeSize ;
1889 typeAttr[attrCount].data.dataValue = fontStyle ;
1890 attrCount++ ;
acead93d
SC
1891#else
1892 typeAttr[attrCount].tag = kTXNATSUIStyle ;
1893 typeAttr[attrCount].size = kTXNATSUIStyleSize ;
1894 typeAttr[attrCount].data.dataValue = (UInt32)font.MacGetATSUStyle() ;
1895 attrCount++ ;
1896#endif
5ca0d812 1897 }
fef981b4 1898
5ca0d812
SC
1899 if ( style.HasTextColour() )
1900 {
5ca0d812 1901 color = MAC_WXCOLORREF(style.GetTextColour().GetPixel()) ;
0207e969
DS
1902
1903 typeAttr[attrCount].tag = kTXNQDFontColorAttribute ;
1904 typeAttr[attrCount].size = kTXNQDFontColorAttributeSize ;
1905 typeAttr[attrCount].data.dataPtr = (void*) &color ;
1906 attrCount++ ;
72055702 1907 }
fef981b4 1908
0207e969 1909 if ( attrCount > 0 )
8623a883 1910 {
0207e969 1911 verify_noerr( TXNSetTypeAttributes( m_txn , attrCount , typeAttr, from , to ) );
09660720
SC
1912 // unfortunately the relayout is not automatic
1913 TXNRecalcTextLayout( m_txn );
8623a883 1914 }
72055702
SC
1915}
1916
7d8268a1 1917void wxMacMLTEControl::SetFont( const wxFont & font , const wxColour& foreground , long windowStyle )
72055702 1918{
0207e969
DS
1919 wxMacEditHelper help( m_txn ) ;
1920 TXNSetAttribute( wxTextAttr( foreground, wxNullColour, font ), kTXNStartOffset, kTXNEndOffset ) ;
72055702 1921}
a8d2fb31 1922
0207e969 1923void wxMacMLTEControl::SetStyle( long start, long end, const wxTextAttr& style )
7d8268a1 1924{
0207e969
DS
1925 wxMacEditHelper help( m_txn ) ;
1926 TXNSetAttribute( style, start, end ) ;
7d8268a1
WS
1927}
1928
1929void wxMacMLTEControl::Copy()
5ca0d812
SC
1930{
1931 ClearCurrentScrap();
0207e969 1932 TXNCopy( m_txn );
5ca0d812 1933 TXNConvertToPublicScrap();
72055702
SC
1934}
1935
7d8268a1 1936void wxMacMLTEControl::Cut()
3a9fa0d6 1937{
5ca0d812 1938 ClearCurrentScrap();
0207e969 1939 TXNCut( m_txn );
5ca0d812 1940 TXNConvertToPublicScrap();
3a9fa0d6
VZ
1941}
1942
7d8268a1 1943void wxMacMLTEControl::Paste()
72055702 1944{
5ca0d812 1945 TXNConvertFromPublicScrap();
0207e969 1946 TXNPaste( m_txn );
72055702
SC
1947}
1948
5ca0d812 1949bool wxMacMLTEControl::CanPaste() const
72055702 1950{
5ca0d812 1951 return TXNIsScrapPastable() ;
72055702
SC
1952}
1953
7d8268a1 1954void wxMacMLTEControl::SetEditable(bool editable)
72055702 1955{
5ca0d812
SC
1956 TXNControlTag tag[] = { kTXNIOPrivilegesTag } ;
1957 TXNControlData data[] = { { editable ? kTXNReadWrite : kTXNReadOnly } } ;
c88b7d28 1958 TXNSetTXNObjectControls( m_txn, false, WXSIZEOF(tag), tag, data ) ;
5ca0d812 1959}
bd3169a7 1960
7d8268a1 1961wxTextPos wxMacMLTEControl::GetLastPosition() const
5ca0d812 1962{
7d8268a1 1963 wxTextPos actualsize = 0 ;
5ca0d812
SC
1964
1965 Handle theText ;
0207e969 1966 OSErr err = TXNGetDataEncoded( m_txn, kTXNStartOffset, kTXNEndOffset, &theText, kTXNTextData );
fef981b4
DS
1967
1968 // all done
1969 if ( err == noErr )
5ca0d812 1970 {
fef981b4
DS
1971 actualsize = GetHandleSize( theText ) ;
1972 DisposeHandle( theText ) ;
5ca0d812
SC
1973 }
1974 else
1975 {
fef981b4 1976 actualsize = 0 ;
5ca0d812
SC
1977 }
1978
1979 return actualsize ;
1980}
1981
44aa865d 1982void wxMacMLTEControl::Replace( long from , long to , const wxString &str )
5ca0d812
SC
1983{
1984 wxString value = str ;
395480fb 1985 wxMacConvertNewlines10To13( &value ) ;
5ca0d812 1986
5de694f0 1987 wxMacEditHelper help( m_txn ) ;
0f7817ab 1988 wxMacWindowClipper c( m_peer ) ;
5ca0d812 1989
0207e969 1990 TXNSetSelection( m_txn, from, to ) ;
5ca0d812 1991 TXNClear( m_txn ) ;
0207e969 1992 SetTXNData( value, kTXNUseCurrentSelection, kTXNUseCurrentSelection ) ;
5ca0d812
SC
1993}
1994
1995void wxMacMLTEControl::Remove( long from , long to )
1996{
0f7817ab 1997 wxMacWindowClipper c( m_peer ) ;
5de694f0 1998 wxMacEditHelper help( m_txn ) ;
0207e969 1999 TXNSetSelection( m_txn , from , to ) ;
5ca0d812
SC
2000 TXNClear( m_txn ) ;
2001}
2002
2003void wxMacMLTEControl::GetSelection( long* from, long* to) const
2004{
2005 TXNGetSelection( m_txn , (TXNOffset*) from , (TXNOffset*) to ) ;
2006}
2007
7d8268a1 2008void wxMacMLTEControl::SetSelection( long from , long to )
5ca0d812 2009{
0f7817ab 2010 wxMacWindowClipper c( m_peer ) ;
fef981b4
DS
2011
2012 // change the selection
5ca0d812 2013 if ((from == -1) && (to == -1))
0207e969 2014 TXNSelectAll( m_txn );
5ca0d812 2015 else
fef981b4 2016 TXNSetSelection( m_txn, from, to );
0207e969 2017
fef981b4 2018 TXNShowSelection( m_txn, kTXNShowStart );
5ca0d812
SC
2019}
2020
c88b7d28 2021void wxMacMLTEControl::WriteText( const wxString& str )
5ca0d812 2022{
5ca0d812 2023 wxString st = str ;
395480fb 2024 wxMacConvertNewlines10To13( &st ) ;
5ca0d812
SC
2025
2026 long start , end , dummy ;
0207e969 2027
5ca0d812 2028 GetSelection( &start , &dummy ) ;
5de694f0 2029 wxMacWindowClipper c( m_peer ) ;
0207e969 2030
5de694f0
SC
2031 {
2032 wxMacEditHelper helper( m_txn ) ;
c88b7d28 2033 SetTXNData( st, kTXNUseCurrentSelection, kTXNUseCurrentSelection ) ;
5de694f0 2034 }
a8d2fb31 2035
c88b7d28 2036 GetSelection( &dummy, &end ) ;
fef981b4
DS
2037
2038 // TODO: SetStyle( start , end , GetDefaultStyle() ) ;
5ca0d812
SC
2039}
2040
7d8268a1 2041void wxMacMLTEControl::Clear()
5ca0d812 2042{
0f7817ab 2043 wxMacWindowClipper c( m_peer ) ;
0207e969 2044 wxMacEditHelper st( m_txn ) ;
5ca0d812 2045 TXNSetSelection( m_txn , kTXNStartOffset , kTXNEndOffset ) ;
c88b7d28 2046 TXNClear( m_txn ) ;
5ca0d812
SC
2047}
2048
7d8268a1 2049bool wxMacMLTEControl::CanUndo() const
5ca0d812
SC
2050{
2051 return TXNCanUndo( m_txn , NULL ) ;
2052}
2053
7d8268a1 2054void wxMacMLTEControl::Undo()
5ca0d812 2055{
7d8268a1
WS
2056 TXNUndo( m_txn ) ;
2057}
5ca0d812 2058
fef981b4 2059bool wxMacMLTEControl::CanRedo() const
5ca0d812
SC
2060{
2061 return TXNCanRedo( m_txn , NULL ) ;
7d8268a1 2062}
5ca0d812 2063
7d8268a1
WS
2064void wxMacMLTEControl::Redo()
2065{
5ca0d812
SC
2066 TXNRedo( m_txn ) ;
2067}
2068
7d8268a1 2069int wxMacMLTEControl::GetNumberOfLines() const
5ca0d812
SC
2070{
2071 ItemCount lines = 0 ;
fef981b4
DS
2072 TXNGetLineCount( m_txn, &lines ) ;
2073
5ca0d812
SC
2074 return lines ;
2075}
2076
2077long wxMacMLTEControl::XYToPosition(long x, long y) const
2078{
2079 Point curpt ;
fef981b4 2080 wxTextPos lastpos ;
7d8268a1 2081
fef981b4 2082 // TODO: find a better implementation : while we can get the
5ca0d812
SC
2083 // line metrics of a certain line, we don't get its starting
2084 // position, so it would probably be rather a binary search
2085 // for the start position
c88b7d28 2086 long xpos = 0, ypos = 0 ;
5ca0d812 2087 int lastHeight = 0 ;
5ca0d812 2088 ItemCount n ;
fef981b4
DS
2089
2090 lastpos = GetLastPosition() ;
ebe86b1e 2091 for ( n = 0 ; n <= (ItemCount) lastpos ; ++n )
bd3169a7
SC
2092 {
2093 if ( y == ypos && x == xpos )
2094 return n ;
7d8268a1 2095
ffafe6ca 2096 TXNOffsetToPoint( m_txn, n, &curpt ) ;
bd3169a7
SC
2097
2098 if ( curpt.v > lastHeight )
2099 {
2100 xpos = 0 ;
2101 if ( n > 0 )
2102 ++ypos ;
0207e969 2103
bd3169a7
SC
2104 lastHeight = curpt.v ;
2105 }
2106 else
2107 ++xpos ;
2108 }
a8d2fb31 2109
5ca0d812 2110 return 0 ;
72055702
SC
2111}
2112
c88b7d28 2113bool wxMacMLTEControl::PositionToXY( long pos, long *x, long *y ) const
72055702 2114{
bd3169a7 2115 Point curpt ;
fef981b4 2116 wxTextPos lastpos ;
7d8268a1 2117
fef981b4
DS
2118 if ( y )
2119 *y = 0 ;
2120 if ( x )
2121 *x = 0 ;
7d8268a1 2122
fef981b4 2123 lastpos = GetLastPosition() ;
bd3169a7
SC
2124 if ( pos <= lastpos )
2125 {
c88b7d28 2126 // TODO: find a better implementation - while we can get the
bd3169a7
SC
2127 // line metrics of a certain line, we don't get its starting
2128 // position, so it would probably be rather a binary search
2129 // for the start position
0207e969 2130 long xpos = 0, ypos = 0 ;
bd3169a7 2131 int lastHeight = 0 ;
bd3169a7 2132 ItemCount n ;
0207e969 2133
ebe86b1e 2134 for ( n = 0 ; n <= (ItemCount) pos ; ++n )
bd3169a7 2135 {
ffafe6ca 2136 TXNOffsetToPoint( m_txn, n, &curpt ) ;
bd3169a7
SC
2137
2138 if ( curpt.v > lastHeight )
2139 {
2140 xpos = 0 ;
2141 if ( n > 0 )
2142 ++ypos ;
0207e969 2143
bd3169a7
SC
2144 lastHeight = curpt.v ;
2145 }
2146 else
2147 ++xpos ;
2148 }
a8d2fb31 2149
fef981b4
DS
2150 if ( y )
2151 *y = ypos ;
2152 if ( x )
2153 *x = xpos ;
bd3169a7 2154 }
5ca0d812 2155
7d8268a1 2156 return false ;
72055702
SC
2157}
2158
7d8268a1 2159void wxMacMLTEControl::ShowPosition( long pos )
72055702 2160{
3a05d58d 2161#if TARGET_RT_MAC_MACHO && defined(AVAILABLE_MAC_OS_X_VERSION_10_2_AND_LATER)
3a05d58d 2162 {
fef981b4
DS
2163 Point current, desired ;
2164 TXNOffset selstart, selend;
2165
2166 TXNGetSelection( m_txn, &selstart, &selend );
2167 TXNOffsetToPoint( m_txn, selstart, &current );
2168 TXNOffsetToPoint( m_txn, pos, &desired );
2169
2170 // TODO: use HIPoints for 10.3 and above
2171 if ( (UInt32)TXNScroll != (UInt32)kUnresolvedCFragSymbolAddress )
f8e089e0
SC
2172 {
2173 OSErr theErr = noErr;
c88b7d28
DS
2174 SInt32 dv = desired.v - current.v;
2175 SInt32 dh = desired.h - current.h;
ffafe6ca 2176 TXNShowSelection( m_txn, kTXNShowStart ) ; // NB: should this be kTXNShowStart or kTXNShowEnd ??
c88b7d28 2177 theErr = TXNScroll( m_txn, kTXNScrollUnitsInPixels, kTXNScrollUnitsInPixels, &dv, &dh );
fef981b4
DS
2178
2179 // there will be an error returned for classic MLTE implementation when the control is
4d7528a1
SC
2180 // invisible, but HITextView works correctly, so we don't assert that one
2181 // wxASSERT_MSG( theErr == noErr, _T("TXNScroll returned an error!") );
f8e089e0 2182 }
3a05d58d
SC
2183 }
2184#endif
5ca0d812
SC
2185}
2186
fef981b4 2187void wxMacMLTEControl::SetTXNData( const wxString& st, TXNOffset start, TXNOffset end )
5ca0d812
SC
2188{
2189#if wxUSE_UNICODE
2190#if SIZEOF_WCHAR_T == 2
1832043f 2191 size_t len = st.length() ;
fef981b4 2192 TXNSetData( m_txn, kTXNUnicodeTextData, (void*)st.wc_str(), len * 2, start, end );
5ca0d812 2193#else
d9d488cf 2194 wxMBConvUTF16 converter ;
c88b7d28
DS
2195 ByteCount byteBufferLen = converter.WC2MB( NULL, st.wc_str(), 0 ) ;
2196 UniChar *unibuf = (UniChar*)malloc( byteBufferLen ) ;
fef981b4
DS
2197 converter.WC2MB( (char*)unibuf, st.wc_str(), byteBufferLen ) ;
2198 TXNSetData( m_txn, kTXNUnicodeTextData, (void*)unibuf, byteBufferLen, start, end ) ;
7d8268a1 2199 free( unibuf ) ;
587bc950 2200#endif
5ca0d812 2201#else
c88b7d28 2202 wxCharBuffer text = st.mb_str( wxConvLocal ) ;
fef981b4 2203 TXNSetData( m_txn, kTXNTextData, (void*)text.data(), strlen( text ), start, end ) ;
7d8268a1 2204#endif
72055702
SC
2205}
2206
5ca0d812 2207wxString wxMacMLTEControl::GetLineText(long lineNo) const
72055702 2208{
5ca0d812 2209 wxString line ;
5ca0d812 2210
bd3169a7 2211 if ( lineNo < GetNumberOfLines() )
32b5be3d 2212 {
fef981b4
DS
2213 Point firstPoint;
2214 Fixed lineWidth, lineHeight, currentHeight;
2215 long ypos ;
7d8268a1 2216
ae25e5cc 2217 // get the first possible position in the control
ae25e5cc 2218 TXNOffsetToPoint(m_txn, 0, &firstPoint);
7d8268a1 2219
ae25e5cc
RN
2220 // Iterate through the lines until we reach the one we want,
2221 // adding to our current y pixel point position
fef981b4
DS
2222 ypos = 0 ;
2223 currentHeight = 0;
ae25e5cc 2224 while (ypos < lineNo)
32b5be3d 2225 {
ae25e5cc
RN
2226 TXNGetLineMetrics(m_txn, ypos++, &lineWidth, &lineHeight);
2227 currentHeight += lineHeight;
2228 }
7d8268a1 2229
eab19a7c 2230 Point thePoint = { firstPoint.v + (currentHeight >> 16), firstPoint.h + (0) };
ae25e5cc
RN
2231 TXNOffset theOffset;
2232 TXNPointToOffset(m_txn, thePoint, &theOffset);
7d8268a1 2233
ae25e5cc
RN
2234 wxString content = GetStringValue() ;
2235 Point currentPoint = thePoint;
fef981b4 2236 while (thePoint.v == currentPoint.v && theOffset < content.length())
ae25e5cc
RN
2237 {
2238 line += content[theOffset];
2239 TXNOffsetToPoint(m_txn, ++theOffset, &currentPoint);
21fd5529 2240 }
21fd5529 2241 }
fef981b4 2242
5ca0d812 2243 return line ;
72055702
SC
2244}
2245
ffafe6ca 2246int wxMacMLTEControl::GetLineLength(long lineNo) const
72055702 2247{
ae25e5cc
RN
2248 int theLength = 0;
2249
bd3169a7 2250 if ( lineNo < GetNumberOfLines() )
32b5be3d 2251 {
fef981b4
DS
2252 Point firstPoint;
2253 Fixed lineWidth, lineHeight, currentHeight;
ffafe6ca 2254 long ypos;
7d8268a1 2255
ae25e5cc 2256 // get the first possible position in the control
ae25e5cc 2257 TXNOffsetToPoint(m_txn, 0, &firstPoint);
7d8268a1 2258
ae25e5cc
RN
2259 // Iterate through the lines until we reach the one we want,
2260 // adding to our current y pixel point position
fef981b4
DS
2261 ypos = 0;
2262 currentHeight = 0;
ae25e5cc 2263 while (ypos < lineNo)
32b5be3d 2264 {
ae25e5cc
RN
2265 TXNGetLineMetrics(m_txn, ypos++, &lineWidth, &lineHeight);
2266 currentHeight += lineHeight;
2267 }
7d8268a1 2268
eab19a7c 2269 Point thePoint = { firstPoint.v + (currentHeight >> 16), firstPoint.h + (0) };
ae25e5cc
RN
2270 TXNOffset theOffset;
2271 TXNPointToOffset(m_txn, thePoint, &theOffset);
7d8268a1 2272
ae25e5cc
RN
2273 wxString content = GetStringValue() ;
2274 Point currentPoint = thePoint;
fef981b4 2275 while (thePoint.v == currentPoint.v && theOffset < content.length())
ae25e5cc
RN
2276 {
2277 ++theLength;
2278 TXNOffsetToPoint(m_txn, ++theOffset, &currentPoint);
29e4a190 2279 }
29e4a190 2280 }
fef981b4 2281
ae25e5cc 2282 return theLength ;
5ca0d812 2283}
21fd5529 2284
5ca0d812
SC
2285// ----------------------------------------------------------------------------
2286// MLTE control implementation (classic part)
2287// ----------------------------------------------------------------------------
21fd5529 2288
5de694f0
SC
2289// OS X Notes : We still don't have a full replacement for MLTE, so this implementation
2290// has to live on. We have different problems coming from outdated implementations on the
2291// various OS X versions. Most deal with the scrollbars: they are not correctly embedded
2292// while this can be solved on 10.3 by reassigning them the correct place, on 10.2 there is
2293// no way out, therefore we are using our own implementation and our own scrollbars ....
5ca0d812 2294
5de694f0 2295#ifdef __WXMAC_OSX__
0f7817ab 2296
5de694f0
SC
2297TXNScrollInfoUPP gTXNScrollInfoProc = NULL ;
2298ControlActionUPP gTXNScrollActionProc = NULL ;
0f7817ab 2299
fef981b4
DS
2300pascal void wxMacMLTEClassicControl::TXNScrollInfoProc(
2301 SInt32 iValue, SInt32 iMaximumValue,
0207e969 2302 TXNScrollBarOrientation iScrollBarOrientation, SInt32 iRefCon )
0f7817ab 2303{
5de694f0
SC
2304 wxMacMLTEClassicControl* mlte = (wxMacMLTEClassicControl*) iRefCon ;
2305 SInt32 value = wxMax( iValue , 0 ) ;
2306 SInt32 maximum = wxMax( iMaximumValue , 0 ) ;
3dee36ae 2307
5de694f0
SC
2308 if ( iScrollBarOrientation == kTXNHorizontal )
2309 {
2310 if ( mlte->m_sbHorizontal )
2311 {
2312 SetControl32BitValue( mlte->m_sbHorizontal , value ) ;
2313 SetControl32BitMaximum( mlte->m_sbHorizontal , maximum ) ;
2314 mlte->m_lastHorizontalValue = value ;
2315 }
2316 }
2317 else if ( iScrollBarOrientation == kTXNVertical )
5ca0d812 2318 {
5de694f0
SC
2319 if ( mlte->m_sbVertical )
2320 {
2321 SetControl32BitValue( mlte->m_sbVertical , value ) ;
2322 SetControl32BitMaximum( mlte->m_sbVertical , maximum ) ;
2323 mlte->m_lastVerticalValue = value ;
2324 }
72055702
SC
2325 }
2326}
2327
5de694f0 2328pascal void wxMacMLTEClassicControl::TXNScrollActionProc( ControlRef controlRef , ControlPartCode partCode )
72055702 2329{
5de694f0
SC
2330 wxMacMLTEClassicControl* mlte = (wxMacMLTEClassicControl*) GetControlReference( controlRef ) ;
2331 if ( mlte == NULL )
2332 return ;
3dee36ae 2333
5de694f0 2334 if ( controlRef != mlte->m_sbVertical && controlRef != mlte->m_sbHorizontal )
3dee36ae
WS
2335 return ;
2336
fef981b4 2337 OSStatus err ;
3dee36ae
WS
2338 bool isHorizontal = ( controlRef == mlte->m_sbHorizontal ) ;
2339
5de694f0
SC
2340 SInt32 minimum = 0 ;
2341 SInt32 maximum = GetControl32BitMaximum( controlRef ) ;
2342 SInt32 value = GetControl32BitValue( controlRef ) ;
2343 SInt32 delta = 0;
fef981b4 2344
5de694f0
SC
2345 switch ( partCode )
2346 {
2347 case kControlDownButtonPart :
2348 delta = 10 ;
2349 break ;
fef981b4 2350
5de694f0
SC
2351 case kControlUpButtonPart :
2352 delta = -10 ;
2353 break ;
fef981b4 2354
5de694f0
SC
2355 case kControlPageDownPart :
2356 delta = GetControlViewSize( controlRef ) ;
2357 break ;
fef981b4 2358
5de694f0 2359 case kControlPageUpPart :
fef981b4 2360 delta = -GetControlViewSize( controlRef ) ;
5de694f0 2361 break ;
fef981b4 2362
5de694f0 2363 case kControlIndicatorPart :
c88b7d28 2364 delta = value - (isHorizontal ? mlte->m_lastHorizontalValue : mlte->m_lastVerticalValue) ;
5de694f0 2365 break ;
fef981b4 2366
5de694f0
SC
2367 default :
2368 break ;
2369 }
fef981b4 2370
5de694f0 2371 if ( delta != 0 )
e600c175 2372 {
5de694f0 2373 SInt32 newValue = value ;
3dee36ae 2374
5de694f0
SC
2375 if ( partCode != kControlIndicatorPart )
2376 {
fef981b4 2377 if ( value + delta < minimum )
5de694f0
SC
2378 delta = minimum - value ;
2379 if ( value + delta > maximum )
2380 delta = maximum - value ;
2381
2382 SetControl32BitValue( controlRef , value + delta ) ;
2383 newValue = value + delta ;
2384 }
3dee36ae 2385
5de694f0
SC
2386 SInt32 verticalDelta = isHorizontal ? 0 : delta ;
2387 SInt32 horizontalDelta = isHorizontal ? delta : 0 ;
3dee36ae 2388
0207e969
DS
2389 err = TXNScroll(
2390 mlte->m_txn, kTXNScrollUnitsInPixels, kTXNScrollUnitsInPixels,
2391 &verticalDelta, &horizontalDelta );
ffafe6ca 2392 verify_noerr( err );
3dee36ae 2393
5de694f0
SC
2394 if ( isHorizontal )
2395 mlte->m_lastHorizontalValue = newValue ;
2396 else
2397 mlte->m_lastVerticalValue = newValue ;
5ca0d812 2398 }
5ca0d812 2399}
5de694f0 2400#endif
7d8268a1 2401
0f7817ab 2402// make correct activations
fef981b4 2403void wxMacMLTEClassicControl::MacActivatePaneText(bool setActive)
0f7817ab
SC
2404{
2405 wxTextCtrl* textctrl = (wxTextCtrl*) GetControlReference(m_controlRef);
ef4a634b 2406
5de694f0 2407 wxMacWindowClipper clipper( textctrl ) ;
c88b7d28 2408 TXNActivate( m_txn, m_txnFrameID, setActive );
0f7817ab 2409
5de694f0
SC
2410 ControlRef controlFocus = 0 ;
2411 GetKeyboardFocus( m_txnWindow , &controlFocus ) ;
2412 if ( controlFocus == m_controlRef )
fef981b4 2413 TXNFocus( m_txn, setActive );
5de694f0
SC
2414}
2415
fef981b4 2416void wxMacMLTEClassicControl::MacFocusPaneText(bool setFocus)
5de694f0 2417{
0207e969 2418 TXNFocus( m_txn, setFocus );
5ca0d812 2419}
1fa29bdc 2420
3dee36ae 2421// guards against inappropriate redraw (hidden objects drawing onto window)
0f7817ab 2422
fef981b4 2423void wxMacMLTEClassicControl::MacSetObjectVisibility(bool vis)
0f7817ab 2424{
789ae0cf
SC
2425 ControlRef controlFocus = 0 ;
2426 GetKeyboardFocus( m_txnWindow , &controlFocus ) ;
3dee36ae 2427
fef981b4 2428 if ( !vis && (controlFocus == m_controlRef ) )
789ae0cf 2429 SetKeyboardFocus( m_txnWindow , m_controlRef , kControlFocusNoPart ) ;
3dee36ae 2430
4611a719 2431 TXNControlTag iControlTags[1] = { kTXNVisibilityTag };
c88b7d28 2432 TXNControlData iControlData[1] = { { (UInt32)false } };
bd2213c2 2433
fef981b4 2434 verify_noerr( TXNGetTXNObjectControls( m_txn , 1, iControlTags, iControlData ) ) ;
3dee36ae 2435
bd2213c2
SC
2436 if ( iControlData[0].uValue != vis )
2437 {
2438 iControlData[0].uValue = vis ;
0207e969 2439 verify_noerr( TXNSetTXNObjectControls( m_txn, false , 1, iControlTags, iControlData ) ) ;
bd2213c2 2440 }
fef981b4 2441
0207e969
DS
2442 // currently, we always clip as partial visibility (overlapped) visibility is also a problem,
2443 // if we run into further problems we might set the FrameBounds to an empty rect here
5ca0d812 2444}
1fa29bdc 2445
0f7817ab 2446// make sure that the TXNObject is at the right position
5de694f0 2447
3dee36ae 2448void wxMacMLTEClassicControl::MacUpdatePosition()
0f7817ab 2449{
c88b7d28 2450 wxTextCtrl* textctrl = (wxTextCtrl*)GetControlReference( m_controlRef );
0f7817ab
SC
2451 if ( textctrl == NULL )
2452 return ;
7d8268a1 2453
0f7817ab 2454 Rect bounds ;
c88b7d28 2455 UMAGetControlBoundsInWindowCoords( m_controlRef, &bounds );
3dee36ae 2456
ba75e603
SC
2457 wxRect visRect = textctrl->MacGetClippedClientRect() ;
2458 Rect visBounds = { visRect.y , visRect.x , visRect.y + visRect.height , visRect.x + visRect.width } ;
2459 int x , y ;
2460 x = y = 0 ;
2461 textctrl->MacWindowToRootWindow( &x , &y ) ;
2462 OffsetRect( &visBounds , x , y ) ;
3dee36ae 2463
c88b7d28 2464 if ( !EqualRect( &bounds, &m_txnControlBounds ) || !EqualRect( &visBounds, &m_txnVisBounds ) )
0f7817ab 2465 {
0f7817ab 2466 m_txnControlBounds = bounds ;
ba75e603 2467 m_txnVisBounds = visBounds ;
c88b7d28 2468 wxMacWindowClipper cl( textctrl ) ;
5de694f0 2469
4e477040
SC
2470#ifdef __WXMAC_OSX__
2471 if ( m_sbHorizontal || m_sbVertical )
2472 {
5de694f0
SC
2473 int w = bounds.right - bounds.left ;
2474 int h = bounds.bottom - bounds.top ;
4e477040
SC
2475
2476 if ( m_sbHorizontal )
2477 {
2478 Rect sbBounds ;
5de694f0 2479
4e477040 2480 sbBounds.left = -1 ;
5de694f0
SC
2481 sbBounds.top = h - 14 ;
2482 sbBounds.right = w + 1 ;
2483 sbBounds.bottom = h + 1 ;
3dee36ae 2484
4e477040 2485 SetControlBounds( m_sbHorizontal , &sbBounds ) ;
5de694f0 2486 SetControlViewSize( m_sbHorizontal , w ) ;
4e477040 2487 }
0207e969 2488
4e477040
SC
2489 if ( m_sbVertical )
2490 {
2491 Rect sbBounds ;
5de694f0
SC
2492
2493 sbBounds.left = w - 14 ;
4e477040 2494 sbBounds.top = -1 ;
5de694f0 2495 sbBounds.right = w + 1 ;
fef981b4 2496 sbBounds.bottom = m_sbHorizontal ? h - 14 : h + 1 ;
3dee36ae 2497
4e477040 2498 SetControlBounds( m_sbVertical , &sbBounds ) ;
5de694f0 2499 SetControlViewSize( m_sbVertical , h ) ;
4e477040
SC
2500 }
2501 }
3dee36ae 2502
c447d5a9
SC
2503 Rect oldviewRect ;
2504 TXNLongRect olddestRect ;
2505 TXNGetRectBounds( m_txn , &oldviewRect , &olddestRect , NULL ) ;
3dee36ae 2506
c447d5a9 2507 Rect viewRect = { m_txnControlBounds.top, m_txnControlBounds.left,
fef981b4
DS
2508 m_txnControlBounds.bottom - ( m_sbHorizontal ? 14 : 0 ) ,
2509 m_txnControlBounds.right - ( m_sbVertical ? 14 : 0 ) } ;
c447d5a9 2510 TXNLongRect destRect = { m_txnControlBounds.top, m_txnControlBounds.left,
fef981b4
DS
2511 m_txnControlBounds.bottom - ( m_sbHorizontal ? 14 : 0 ) ,
2512 m_txnControlBounds.right - ( m_sbVertical ? 14 : 0 ) } ;
3dee36ae 2513
c447d5a9
SC
2514 if ( olddestRect.right >= 10000 )
2515 destRect.right = destRect.left + 32000 ;
3dee36ae 2516
c447d5a9
SC
2517 if ( olddestRect.bottom >= 0x20000000 )
2518 destRect.bottom = destRect.top + 0x40000000 ;
3dee36ae
WS
2519
2520 SectRect( &viewRect , &visBounds , &viewRect ) ;
823c4e96 2521 TXNSetRectBounds( m_txn , &viewRect , &destRect , true ) ;
fef981b4
DS
2522
2523#if 0
2524 TXNSetFrameBounds(
2525 m_txn,
2526 m_txnControlBounds.top,
2527 m_txnControlBounds.left,
2528 m_txnControlBounds.bottom - (m_sbHorizontal ? 14 : 0),
2529 m_txnControlBounds.right - (m_sbVertical ? 14 : 0),
2530 m_txnFrameID );
2531#endif
5de694f0 2532#else
3dee36ae 2533
c88b7d28
DS
2534 TXNSetFrameBounds(
2535 m_txn, m_txnControlBounds.top, m_txnControlBounds.left,
2536 wxMax( m_txnControlBounds.bottom, m_txnControlBounds.top ),
2537 wxMax( m_txnControlBounds.right, m_txnControlBounds.left ), m_txnFrameID );
24eef584 2538#endif
c88b7d28
DS
2539
2540 // the SetFrameBounds method under Classic sometimes does not correctly scroll a selection into sight after a
5de694f0
SC
2541 // movement, therefore we have to force it
2542
fef981b4 2543 // this problem has been reported in OSX as well, so we use this here once again
0207e969 2544
5de694f0 2545 TXNLongRect textRect ;
3dee36ae 2546 TXNGetRectBounds( m_txn , NULL , NULL , &textRect ) ;
5de694f0 2547 if ( textRect.left < m_txnControlBounds.left )
fef981b4 2548 TXNShowSelection( m_txn , kTXNShowStart ) ;
e600c175 2549 }
5ca0d812
SC
2550}
2551
3dee36ae 2552void wxMacMLTEClassicControl::SetRect( Rect *r )
0f7817ab
SC
2553{
2554 wxMacControl::SetRect( r ) ;
2555 MacUpdatePosition() ;
2556}
2557
3dee36ae 2558void wxMacMLTEClassicControl::MacControlUserPaneDrawProc(wxInt16 thePart)
24260aae 2559{
c88b7d28 2560 wxTextCtrl* textctrl = (wxTextCtrl*)GetControlReference( m_controlRef );
5ca0d812 2561 if ( textctrl == NULL )
e600c175 2562 return ;
7d8268a1 2563
5ca0d812
SC
2564 if ( textctrl->MacIsReallyShown() )
2565 {
2566 wxMacWindowClipper clipper( textctrl ) ;
0f7817ab 2567 TXNDraw( m_txn , NULL ) ;
e600c175 2568 }
5ca0d812
SC
2569}
2570
3dee36ae 2571wxInt16 wxMacMLTEClassicControl::MacControlUserPaneHitTestProc(wxInt16 x, wxInt16 y)
24260aae
SC
2572{
2573 Point where = { y , x } ;
a8d2fb31 2574 ControlPartCode result = kControlNoPart;
5de694f0 2575
0207e969 2576 wxTextCtrl* textctrl = (wxTextCtrl*) GetControlReference( m_controlRef );
a8d2fb31 2577 if ( (textctrl != NULL) && textctrl->MacIsReallyShown() )
72055702 2578 {
fef981b4
DS
2579 if (PtInRect( where, &m_txnControlBounds ))
2580 {
5de694f0 2581 result = kControlEditTextPart ;
fef981b4 2582 }
7d8268a1 2583 else
3556e470
SC
2584 {
2585 // sometimes we get the coords also in control local coordinates, therefore test again
ab346e1c
VZ
2586 int x = 0 , y = 0 ;
2587 textctrl->MacClientToRootWindow( &x , &y ) ;
2588 where.h += x ;
2589 where.v += y ;
fef981b4 2590
0207e969 2591 if (PtInRect( where, &m_txnControlBounds ))
5de694f0 2592 result = kControlEditTextPart ;
3556e470 2593 }
5ca0d812 2594 }
a8d2fb31 2595
5ca0d812
SC
2596 return result;
2597}
2598
3dee36ae 2599wxInt16 wxMacMLTEClassicControl::MacControlUserPaneTrackingProc( wxInt16 x, wxInt16 y, void* actionProc )
24260aae 2600{
a8d2fb31 2601 ControlPartCode result = kControlNoPart;
5de694f0 2602
0207e969 2603 wxTextCtrl* textctrl = (wxTextCtrl*) GetControlReference( m_controlRef );
a8d2fb31 2604 if ( (textctrl != NULL) && textctrl->MacIsReallyShown() )
7d8268a1 2605 {
a8d2fb31 2606 Point startPt = { y , x } ;
ab346e1c 2607
5ca0d812 2608 // for compositing, we must convert these into toplevel window coordinates, because hittesting expects them
ab346e1c
VZ
2609 int x = 0 , y = 0 ;
2610 textctrl->MacClientToRootWindow( &x , &y ) ;
2611 startPt.h += x ;
2612 startPt.v += y ;
7d8268a1 2613
24260aae 2614 switch (MacControlUserPaneHitTestProc( startPt.h , startPt.v ))
5ca0d812 2615 {
5de694f0 2616 case kControlEditTextPart :
7d8268a1
WS
2617 {
2618 wxMacWindowClipper clipper( textctrl ) ;
7d8268a1 2619 EventRecord rec ;
c88b7d28 2620
7d8268a1 2621 ConvertEventRefToEventRecord( (EventRef) wxTheApp->MacGetCurrentEvent() , &rec ) ;
24260aae 2622 TXNClick( m_txn, &rec );
7d8268a1 2623 }
fef981b4 2624 break;
a8d2fb31 2625
fef981b4
DS
2626 default :
2627 break;
5ca0d812
SC
2628 }
2629 }
a8d2fb31
DS
2630
2631 return result;
5ca0d812
SC
2632}
2633
3dee36ae 2634void wxMacMLTEClassicControl::MacControlUserPaneIdleProc()
24260aae 2635{
c88b7d28 2636 wxTextCtrl* textctrl = (wxTextCtrl*)GetControlReference( m_controlRef );
5ca0d812
SC
2637 if ( textctrl == NULL )
2638 return ;
24260aae 2639
3dee36ae 2640 if (textctrl->MacIsReallyShown())
24260aae 2641 {
3dee36ae 2642 if (IsControlActive(m_controlRef))
24260aae 2643 {
5ca0d812 2644 Point mousep;
7d8268a1 2645
5ca0d812
SC
2646 wxMacWindowClipper clipper( textctrl ) ;
2647 GetMouse(&mousep);
5de694f0
SC
2648
2649 TXNIdle(m_txn);
2650
3dee36ae 2651 if (PtInRect(mousep, &m_txnControlBounds))
24260aae 2652 {
fef981b4
DS
2653 RgnHandle theRgn = NewRgn();
2654 RectRgn(theRgn, &m_txnControlBounds);
5de694f0
SC
2655 TXNAdjustCursor(m_txn, theRgn);
2656 DisposeRgn(theRgn);
72055702 2657 }
5ca0d812
SC
2658 }
2659 }
2660}
72055702 2661
3dee36ae 2662wxInt16 wxMacMLTEClassicControl::MacControlUserPaneKeyDownProc (wxInt16 keyCode, wxInt16 charCode, wxInt16 modifiers)
24260aae 2663{
c88b7d28 2664 wxTextCtrl* textctrl = (wxTextCtrl*)GetControlReference( m_controlRef );
5ca0d812 2665 if ( textctrl == NULL )
a8d2fb31 2666 return kControlNoPart;
7d8268a1 2667
5de694f0 2668 wxMacWindowClipper clipper( textctrl ) ;
ef4a634b 2669
5de694f0
SC
2670 EventRecord ev ;
2671 memset( &ev , 0 , sizeof( ev ) ) ;
2672 ev.what = keyDown ;
2673 ev.modifiers = modifiers ;
fef981b4
DS
2674 ev.message = ((keyCode << 8) & keyCodeMask) | (charCode & charCodeMask);
2675 TXNKeyDown( m_txn , &ev );
3dee36ae 2676
5de694f0
SC
2677 return kControlEntireControl;
2678}
24260aae 2679
c88b7d28 2680void wxMacMLTEClassicControl::MacControlUserPaneActivateProc(bool activating)
24260aae 2681{
5de694f0 2682 MacActivatePaneText( activating );
72055702
SC
2683}
2684
3dee36ae 2685wxInt16 wxMacMLTEClassicControl::MacControlUserPaneFocusProc(wxInt16 action)
24260aae 2686{
c88b7d28 2687 ControlPartCode focusResult = kControlFocusNoPart;
7d8268a1 2688
c88b7d28 2689 wxTextCtrl* textctrl = (wxTextCtrl*)GetControlReference( m_controlRef );
5ca0d812 2690 if ( textctrl == NULL )
c88b7d28 2691 return focusResult;
0f7817ab
SC
2692
2693 wxMacWindowClipper clipper( textctrl ) ;
3dee36ae 2694
a8d2fb31 2695 ControlRef controlFocus = NULL ;
5de694f0
SC
2696 GetKeyboardFocus( m_txnWindow , &controlFocus ) ;
2697 bool wasFocused = ( controlFocus == m_controlRef ) ;
2698
3dee36ae 2699 switch (action)
24260aae 2700 {
5de694f0
SC
2701 case kControlFocusPrevPart:
2702 case kControlFocusNextPart:
0207e969
DS
2703 MacFocusPaneText( !wasFocused );
2704 focusResult = (!wasFocused ? (ControlPartCode) kControlEditTextPart : (ControlPartCode) kControlFocusNoPart);
5de694f0 2705 break;
3dee36ae 2706
5ca0d812 2707 case kControlFocusNoPart:
5de694f0 2708 default:
a8d2fb31 2709 MacFocusPaneText( false );
5ca0d812
SC
2710 focusResult = kControlFocusNoPart;
2711 break;
5ca0d812 2712 }
0f7817ab 2713
5ca0d812 2714 return focusResult;
72055702
SC
2715}
2716
24260aae
SC
2717void wxMacMLTEClassicControl::MacControlUserPaneBackgroundProc( void *info )
2718{
2719}
2720
0f7817ab 2721wxMacMLTEClassicControl::wxMacMLTEClassicControl( wxTextCtrl *wxPeer,
ffafe6ca
DS
2722 const wxString& str,
2723 const wxPoint& pos,
2724 const wxSize& size, long style )
2725 : wxMacMLTEControl( wxPeer )
72055702 2726{
5ca0d812
SC
2727 m_font = wxPeer->GetFont() ;
2728 m_windowStyle = style ;
7d8268a1 2729 Rect bounds = wxMacGetBoundsForControl( wxPeer , pos , size ) ;
72055702 2730
c88b7d28 2731 short featureSet =
0207e969
DS
2732 kControlSupportsEmbedding | kControlSupportsFocus | kControlWantsIdle
2733 | kControlWantsActivate | kControlHandlesTracking
2734// | kControlHasSpecialBackground
2735 | kControlGetsFocusOnClick | kControlSupportsLiveFeedback;
72055702 2736
ffafe6ca
DS
2737 OSStatus err = ::CreateUserPaneControl(
2738 MAC_WXHWND(wxPeer->GetParent()->MacGetTopLevelWindowRef()),
2739 &bounds, featureSet, &m_controlRef );
2740 verify_noerr( err );
7d8268a1 2741
0f7817ab 2742 DoCreate();
7d8268a1 2743
a8d2fb31 2744 AdjustCreationAttributes( *wxWHITE , true ) ;
5ca0d812 2745
bd2213c2
SC
2746 MacSetObjectVisibility( wxPeer->MacIsReallyShown() ) ;
2747
24eef584
SC
2748 {
2749 wxString st = str ;
2750 wxMacConvertNewlines10To13( &st ) ;
2751 wxMacWindowClipper clipper( m_peer ) ;
2752 SetTXNData( st , kTXNStartOffset, kTXNEndOffset ) ;
0207e969 2753 TXNSetSelection( m_txn, 0, 0 ) ;
24eef584 2754 }
72055702
SC
2755}
2756
5ca0d812 2757wxMacMLTEClassicControl::~wxMacMLTEClassicControl()
72055702 2758{
0207e969 2759 TXNDeleteObject( m_txn );
5de694f0 2760 m_txn = NULL ;
72055702
SC
2761}
2762
7d8268a1 2763void wxMacMLTEClassicControl::VisibilityChanged(bool shown)
72055702 2764{
0f7817ab 2765 MacSetObjectVisibility( shown ) ;
4e477040
SC
2766 wxMacControl::VisibilityChanged( shown ) ;
2767}
2768
2769void wxMacMLTEClassicControl::SuperChangedPosition()
2770{
2771 MacUpdatePosition() ;
2772 wxMacControl::SuperChangedPosition() ;
72055702
SC
2773}
2774
24260aae
SC
2775#ifdef __WXMAC_OSX__
2776
5de694f0
SC
2777ControlUserPaneDrawUPP gTPDrawProc = NULL;
2778ControlUserPaneHitTestUPP gTPHitProc = NULL;
2779ControlUserPaneTrackingUPP gTPTrackProc = NULL;
2780ControlUserPaneIdleUPP gTPIdleProc = NULL;
2781ControlUserPaneKeyDownUPP gTPKeyProc = NULL;
2782ControlUserPaneActivateUPP gTPActivateProc = NULL;
2783ControlUserPaneFocusUPP gTPFocusProc = NULL;
2784
24260aae
SC
2785static pascal void wxMacControlUserPaneDrawProc(ControlRef control, SInt16 part)
2786{
2787 wxTextCtrl *textCtrl = wxDynamicCast( wxFindControlFromMacControl(control) , wxTextCtrl ) ;
bc8f7aee 2788 wxMacMLTEClassicControl * win = textCtrl ? (wxMacMLTEClassicControl*)(textCtrl->GetPeer()) : NULL ;
24260aae 2789 if ( win )
ffafe6ca 2790 win->MacControlUserPaneDrawProc( part ) ;
24260aae
SC
2791}
2792
c7fe80e2 2793static pascal ControlPartCode wxMacControlUserPaneHitTestProc(ControlRef control, Point where)
24260aae
SC
2794{
2795 wxTextCtrl *textCtrl = wxDynamicCast( wxFindControlFromMacControl(control) , wxTextCtrl ) ;
bc8f7aee 2796 wxMacMLTEClassicControl * win = textCtrl ? (wxMacMLTEClassicControl*)(textCtrl->GetPeer()) : NULL ;
24260aae 2797 if ( win )
ffafe6ca 2798 return win->MacControlUserPaneHitTestProc( where.h , where.v ) ;
24260aae
SC
2799 else
2800 return kControlNoPart ;
2801}
2802
c7fe80e2 2803static pascal ControlPartCode wxMacControlUserPaneTrackingProc(ControlRef control, Point startPt, ControlActionUPP actionProc)
24260aae
SC
2804{
2805 wxTextCtrl *textCtrl = wxDynamicCast( wxFindControlFromMacControl(control) , wxTextCtrl ) ;
bc8f7aee 2806 wxMacMLTEClassicControl * win = textCtrl ? (wxMacMLTEClassicControl*)(textCtrl->GetPeer()) : NULL ;
24260aae 2807 if ( win )
ffafe6ca 2808 return win->MacControlUserPaneTrackingProc( startPt.h , startPt.v , (void*) actionProc ) ;
24260aae
SC
2809 else
2810 return kControlNoPart ;
2811}
2812
2813static pascal void wxMacControlUserPaneIdleProc(ControlRef control)
2814{
2815 wxTextCtrl *textCtrl = wxDynamicCast( wxFindControlFromMacControl(control) , wxTextCtrl ) ;
bc8f7aee 2816 wxMacMLTEClassicControl * win = textCtrl ? (wxMacMLTEClassicControl*)(textCtrl->GetPeer()) : NULL ;
24260aae
SC
2817 if ( win )
2818 win->MacControlUserPaneIdleProc() ;
2819}
2820
2821static pascal ControlPartCode wxMacControlUserPaneKeyDownProc(ControlRef control, SInt16 keyCode, SInt16 charCode, SInt16 modifiers)
2822{
2823 wxTextCtrl *textCtrl = wxDynamicCast( wxFindControlFromMacControl(control) , wxTextCtrl ) ;
bc8f7aee 2824 wxMacMLTEClassicControl * win = textCtrl ? (wxMacMLTEClassicControl*)(textCtrl->GetPeer()) : NULL ;
24260aae 2825 if ( win )
ffafe6ca 2826 return win->MacControlUserPaneKeyDownProc( keyCode, charCode, modifiers ) ;
24260aae
SC
2827 else
2828 return kControlNoPart ;
2829}
2830
2831static pascal void wxMacControlUserPaneActivateProc(ControlRef control, Boolean activating)
2832{
2833 wxTextCtrl *textCtrl = wxDynamicCast( wxFindControlFromMacControl(control) , wxTextCtrl ) ;
bc8f7aee 2834 wxMacMLTEClassicControl * win = textCtrl ? (wxMacMLTEClassicControl*)(textCtrl->GetPeer()) : NULL ;
24260aae 2835 if ( win )
ffafe6ca 2836 win->MacControlUserPaneActivateProc( activating ) ;
24260aae
SC
2837}
2838
2839static pascal ControlPartCode wxMacControlUserPaneFocusProc(ControlRef control, ControlFocusPart action)
2840{
2841 wxTextCtrl *textCtrl = wxDynamicCast( wxFindControlFromMacControl(control) , wxTextCtrl ) ;
bc8f7aee 2842 wxMacMLTEClassicControl * win = textCtrl ? (wxMacMLTEClassicControl*)(textCtrl->GetPeer()) : NULL ;
24260aae 2843 if ( win )
ffafe6ca 2844 return win->MacControlUserPaneFocusProc( action ) ;
24260aae
SC
2845 else
2846 return kControlNoPart ;
2847}
2848
fef981b4 2849#if 0
24260aae
SC
2850static pascal void wxMacControlUserPaneBackgroundProc(ControlRef control, ControlBackgroundPtr info)
2851{
2852 wxTextCtrl *textCtrl = wxDynamicCast( wxFindControlFromMacControl(control) , wxTextCtrl ) ;
bc8f7aee 2853 wxMacMLTEClassicControl * win = textCtrl ? (wxMacMLTEClassicControl*)(textCtrl->GetPeer()) : NULL ;
24260aae
SC
2854 if ( win )
2855 win->MacControlUserPaneBackgroundProc(info) ;
2856}
2857#endif
2858
fef981b4
DS
2859#endif // __WXMAC_OSX__
2860
5de694f0
SC
2861// TXNRegisterScrollInfoProc
2862
5ca0d812 2863OSStatus wxMacMLTEClassicControl::DoCreate()
2b5f62a0 2864{
5ca0d812 2865 Rect bounds;
5ca0d812 2866 OSStatus err = noErr ;
7d8268a1 2867
fef981b4 2868 // set up our globals
24260aae
SC
2869#ifdef __WXMAC_OSX__
2870 if (gTPDrawProc == NULL) gTPDrawProc = NewControlUserPaneDrawUPP(wxMacControlUserPaneDrawProc);
2871 if (gTPHitProc == NULL) gTPHitProc = NewControlUserPaneHitTestUPP(wxMacControlUserPaneHitTestProc);
2872 if (gTPTrackProc == NULL) gTPTrackProc = NewControlUserPaneTrackingUPP(wxMacControlUserPaneTrackingProc);
2873 if (gTPIdleProc == NULL) gTPIdleProc = NewControlUserPaneIdleUPP(wxMacControlUserPaneIdleProc);
2874 if (gTPKeyProc == NULL) gTPKeyProc = NewControlUserPaneKeyDownUPP(wxMacControlUserPaneKeyDownProc);
2875 if (gTPActivateProc == NULL) gTPActivateProc = NewControlUserPaneActivateUPP(wxMacControlUserPaneActivateProc);
2876 if (gTPFocusProc == NULL) gTPFocusProc = NewControlUserPaneFocusUPP(wxMacControlUserPaneFocusProc);
5de694f0
SC
2877
2878 if (gTXNScrollInfoProc == NULL ) gTXNScrollInfoProc = NewTXNScrollInfoUPP(TXNScrollInfoProc) ;
2879 if (gTXNScrollActionProc == NULL ) gTXNScrollActionProc = NewControlActionUPP(TXNScrollActionProc) ;
24260aae 2880#endif
7d8268a1 2881
fef981b4 2882 // set the initial settings for our private data
7d8268a1 2883
a8d2fb31 2884 m_txnWindow = GetControlOwner(m_controlRef);
5de694f0 2885 m_txnPort = (GrafPtr) GetWindowPort(m_txnWindow);
7d8268a1 2886
24260aae 2887#ifdef __WXMAC_OSX__
fef981b4 2888 // set up the user pane procedures
5ca0d812
SC
2889 SetControlData(m_controlRef, kControlEntireControl, kControlUserPaneDrawProcTag, sizeof(gTPDrawProc), &gTPDrawProc);
2890 SetControlData(m_controlRef, kControlEntireControl, kControlUserPaneHitTestProcTag, sizeof(gTPHitProc), &gTPHitProc);
2891 SetControlData(m_controlRef, kControlEntireControl, kControlUserPaneTrackingProcTag, sizeof(gTPTrackProc), &gTPTrackProc);
2892 SetControlData(m_controlRef, kControlEntireControl, kControlUserPaneIdleProcTag, sizeof(gTPIdleProc), &gTPIdleProc);
2893 SetControlData(m_controlRef, kControlEntireControl, kControlUserPaneKeyDownProcTag, sizeof(gTPKeyProc), &gTPKeyProc);
2894 SetControlData(m_controlRef, kControlEntireControl, kControlUserPaneActivateProcTag, sizeof(gTPActivateProc), &gTPActivateProc);
2895 SetControlData(m_controlRef, kControlEntireControl, kControlUserPaneFocusProcTag, sizeof(gTPFocusProc), &gTPFocusProc);
24260aae 2896#endif
c88b7d28 2897
fef981b4 2898 // calculate the rectangles used by the control
c88b7d28 2899 UMAGetControlBoundsInWindowCoords( m_controlRef, &bounds );
3dee36ae 2900
0f7817ab 2901 m_txnControlBounds = bounds ;
ba75e603 2902 m_txnVisBounds = bounds ;
3dee36ae 2903
fef981b4
DS
2904 CGrafPtr origPort ;
2905 GDHandle origDev ;
7d8268a1 2906
c88b7d28 2907 GetGWorld( &origPort, &origDev ) ;
fef981b4 2908 SetPort( m_txnPort );
7d8268a1 2909
fef981b4 2910 // create the new edit field
c88b7d28 2911 TXNFrameOptions frameOptions = FrameOptionsFromWXStyle( m_windowStyle );
7d8268a1 2912
4e477040 2913#ifdef __WXMAC_OSX__
fef981b4
DS
2914 // the scrollbars are not correctly embedded but are inserted at the root:
2915 // this gives us problems as we have erratic redraws even over the structure area
4e477040 2916
5de694f0
SC
2917 m_sbHorizontal = 0 ;
2918 m_sbVertical = 0 ;
2919 m_lastHorizontalValue = 0 ;
2920 m_lastVerticalValue = 0 ;
3dee36ae 2921
5de694f0
SC
2922 Rect sb = { 0 , 0 , 0 , 0 } ;
2923 if ( frameOptions & kTXNWantVScrollBarMask )
2924 {
c88b7d28
DS
2925 CreateScrollBarControl( m_txnWindow, &sb, 0, 0, 100, 1, true, gTXNScrollActionProc, &m_sbVertical );
2926 SetControlReference( m_sbVertical, (SInt32)this );
5de694f0 2927 SetControlAction( m_sbVertical, gTXNScrollActionProc );
c88b7d28
DS
2928 ShowControl( m_sbVertical );
2929 EmbedControl( m_sbVertical , m_controlRef );
2930 frameOptions &= ~kTXNWantVScrollBarMask;
5de694f0 2931 }
fef981b4 2932
5de694f0
SC
2933 if ( frameOptions & kTXNWantHScrollBarMask )
2934 {
c88b7d28
DS
2935 CreateScrollBarControl( m_txnWindow, &sb, 0, 0, 100, 1, true, gTXNScrollActionProc, &m_sbHorizontal );
2936 SetControlReference( m_sbHorizontal, (SInt32)this );
5de694f0 2937 SetControlAction( m_sbHorizontal, gTXNScrollActionProc );
c88b7d28
DS
2938 ShowControl( m_sbHorizontal );
2939 EmbedControl( m_sbHorizontal, m_controlRef );
5de694f0
SC
2940 frameOptions &= ~(kTXNWantHScrollBarMask | kTXNDrawGrowIconMask);
2941 }
4e477040
SC
2942
2943#endif
2944
ffafe6ca
DS
2945 err = TXNNewObject(
2946 NULL, m_txnWindow, &bounds, frameOptions,
2947 kTXNTextEditStyleFrameType, kTXNTextensionFile, kTXNSystemDefaultEncoding,
2948 &m_txn, &m_txnFrameID, NULL );
2949 verify_noerr( err );
3dee36ae 2950
fef981b4
DS
2951#if 0
2952 TXNControlTag iControlTags[] = { kTXNUseCarbonEvents };
c88b7d28 2953 TXNControlData iControlData[] = { { (UInt32)&cInfo } };
fef981b4
DS
2954 int toptag = WXSIZEOF( iControlTags ) ;
2955 TXNCarbonEventInfo cInfo ;
55d0b180
SC
2956 cInfo.useCarbonEvents = false ;
2957 cInfo.filler = 0 ;
2958 cInfo.flags = 0 ;
2959 cInfo.fDictionary = NULL ;
2960
c88b7d28 2961 verify_noerr( TXNSetTXNObjectControls( m_txn, false, toptag, iControlTags, iControlData ) );
fef981b4 2962#endif
55d0b180 2963
4e477040 2964#ifdef __WXMAC_OSX__
c88b7d28 2965 TXNRegisterScrollInfoProc( m_txn, gTXNScrollInfoProc, (SInt32)this );
4e477040
SC
2966#endif
2967
0f7817ab 2968 SetGWorld( origPort , origDev ) ;
ffafe6ca 2969
5ca0d812 2970 return err;
facd6764
SC
2971}
2972
5ca0d812
SC
2973// ----------------------------------------------------------------------------
2974// MLTE control implementation (OSX part)
2975// ----------------------------------------------------------------------------
facd6764 2976
5ca0d812 2977#if TARGET_API_MAC_OSX
facd6764 2978
3b92f0e0
SC
2979#if MAC_OS_X_VERSION_MAX_ALLOWED > MAC_OS_X_VERSION_10_2
2980
09660720 2981// tiger multi-line textcontrols with no CR in the entire content
9eddec69 2982// don't scroll automatically, so we need a hack.
09660720
SC
2983// This attempt only works 'before' the key (ie before CallNextEventHandler)
2984// is processed, thus the scrolling always occurs one character too late, but
2985// better than nothing ...
2986
2987static const EventTypeSpec eventList[] =
2988{
2989 { kEventClassTextInput, kEventTextInputUnicodeForKeyEvent } ,
2990} ;
9eddec69 2991
09660720
SC
2992static pascal OSStatus wxMacUnicodeTextEventHandler( EventHandlerCallRef handler , EventRef event , void *data )
2993{
2994 OSStatus result = eventNotHandledErr ;
2995 wxMacMLTEHIViewControl* focus = (wxMacMLTEHIViewControl*) data ;
9eddec69 2996
09660720
SC
2997 switch ( GetEventKind( event ) )
2998 {
2999 case kEventTextInputUnicodeForKeyEvent :
3000 {
3001 if ( UMAGetSystemVersion() >= 0x1040 )
3002 {
3003 TXNOffset from , to ;
3004 TXNGetSelection( focus->GetTXNObject() , &from , &to ) ;
3005 if ( from == to )
3006 TXNShowSelection( focus->GetTXNObject() , kTXNShowStart );
3007 }
3008 result = CallNextEventHandler(handler,event);
3009 break;
3010 }
3011 default:
3012 break ;
3013 }
9eddec69 3014
09660720
SC
3015 return result ;
3016}
3017
3018static pascal OSStatus wxMacTextControlEventHandler( EventHandlerCallRef handler , EventRef event , void *data )
3019{
3020 OSStatus result = eventNotHandledErr ;
9eddec69 3021
09660720
SC
3022 switch ( GetEventClass( event ) )
3023 {
3024 case kEventClassTextInput :
3025 result = wxMacUnicodeTextEventHandler( handler , event , data ) ;
3026 break ;
9eddec69 3027
09660720
SC
3028 default :
3029 break ;
3030 }
3031 return result ;
3032}
3033
3034DEFINE_ONE_SHOT_HANDLER_GETTER( wxMacTextControlEventHandler )
3035
0f7817ab 3036wxMacMLTEHIViewControl::wxMacMLTEHIViewControl( wxTextCtrl *wxPeer,
ffafe6ca
DS
3037 const wxString& str,
3038 const wxPoint& pos,
3039 const wxSize& size, long style ) : wxMacMLTEControl( wxPeer )
facd6764 3040{
5ca0d812
SC
3041 m_font = wxPeer->GetFont() ;
3042 m_windowStyle = style ;
7d8268a1 3043 Rect bounds = wxMacGetBoundsForControl( wxPeer , pos , size ) ;
5ca0d812 3044 wxString st = str ;
395480fb 3045 wxMacConvertNewlines10To13( &st ) ;
7d8268a1 3046
ffafe6ca
DS
3047 HIRect hr = {
3048 { bounds.left , bounds.top },
3049 { bounds.right - bounds.left, bounds.bottom - bounds.top } } ;
facd6764 3050
5ca0d812
SC
3051 m_scrollView = NULL ;
3052 TXNFrameOptions frameOptions = FrameOptionsFromWXStyle( style ) ;
0207e969 3053 if ( frameOptions & (kTXNWantVScrollBarMask | kTXNWantHScrollBarMask) )
5ca0d812 3054 {
0207e969
DS
3055 HIScrollViewCreate(
3056 (frameOptions & kTXNWantHScrollBarMask ? kHIScrollViewOptionsHorizScroll : 0)
3057 | (frameOptions & kTXNWantVScrollBarMask ? kHIScrollViewOptionsVertScroll : 0) ,
3058 &m_scrollView ) ;
7d8268a1
WS
3059
3060 HIViewSetFrame( m_scrollView, &hr );
3061 HIViewSetVisible( m_scrollView, true );
5ca0d812 3062 }
7d8268a1 3063
5ca0d812
SC
3064 m_textView = NULL ;
3065 HITextViewCreate( NULL , 0, frameOptions , &m_textView ) ;
0207e969 3066 m_txn = HITextViewGetTXNObject( m_textView ) ;
5ca0d812
SC
3067 HIViewSetVisible( m_textView , true ) ;
3068 if ( m_scrollView )
3069 {
3070 HIViewAddSubview( m_scrollView , m_textView ) ;
3071 m_controlRef = m_scrollView ;
0207e969 3072 wxPeer->MacInstallEventHandler( (WXWidget) m_textView ) ;
5ca0d812
SC
3073 }
3074 else
3075 {
7d8268a1 3076 HIViewSetFrame( m_textView, &hr );
5ca0d812
SC
3077 m_controlRef = m_textView ;
3078 }
7d8268a1 3079
0f7817ab
SC
3080 AdjustCreationAttributes( *wxWHITE , true ) ;
3081
3082 wxMacWindowClipper c( m_peer ) ;
5ca0d812
SC
3083 SetTXNData( st , kTXNStartOffset, kTXNEndOffset ) ;
3084
fef981b4
DS
3085 TXNSetSelection( m_txn, 0, 0 );
3086 TXNShowSelection( m_txn, kTXNShowStart );
09660720
SC
3087
3088 InstallControlEventHandler( m_textView , GetwxMacTextControlEventHandlerUPP(),
3089 GetEventTypeCount(eventList), eventList, this,
3090 &m_textEventHandlerRef);
3091}
3092
3093wxMacMLTEHIViewControl::~wxMacMLTEHIViewControl()
3094{
3095 ::RemoveEventHandler( m_textEventHandlerRef ) ;
facd6764
SC
3096}
3097
7d8268a1 3098OSStatus wxMacMLTEHIViewControl::SetFocus( ControlFocusPart focusPart )
facd6764 3099{
fef981b4 3100 return SetKeyboardFocus( GetControlOwner( m_textView ), m_textView, focusPart ) ;
facd6764
SC
3101}
3102
7d8268a1 3103bool wxMacMLTEHIViewControl::HasFocus() const
facd6764 3104{
5ca0d812
SC
3105 ControlRef control ;
3106 GetKeyboardFocus( GetUserFocusWindow() , &control ) ;
3107 return control == m_textView ;
facd6764
SC
3108}
3109
44aa865d
SC
3110void wxMacMLTEHIViewControl::SetBackground( const wxBrush &brush )
3111{
3112 wxMacMLTEControl::SetBackground( brush ) ;
fef981b4
DS
3113
3114#if 0
44aa865d
SC
3115 CGColorSpaceRef rgbSpace = CGColorSpaceCreateDeviceRGB();
3116 RGBColor col = MAC_WXCOLORREF(brush.GetColour().GetPixel()) ;
3117
3118 float component[4] ;
3119 component[0] = col.red / 65536.0 ;
3120 component[1] = col.green / 65536.0 ;
3121 component[2] = col.blue / 65536.0 ;
3122 component[3] = 1.0 ; // alpha
0207e969 3123
ffafe6ca
DS
3124 CGColorRef color = CGColorCreate( rgbSpace , component );
3125 HITextViewSetBackgroundColor( m_textView , color );
44aa865d 3126 CGColorSpaceRelease( rgbSpace );
fef981b4 3127#endif
44aa865d
SC
3128}
3129
3b92f0e0
SC
3130#endif // MAC_OS_X_VERSION_MAX_ALLOWED > MAC_OS_X_VERSION_10_2
3131
3132
fedad417 3133#endif
5ca0d812
SC
3134
3135#endif // wxUSE_TEXTCTRL