1 /////////////////////////////////////////////////////////////////////////////
2 // Name: src/osx/carbon/textctrl.cpp
4 // Author: Stefan Csomor
5 // Modified by: Ryan Norton (MLTE GetLineLength and GetLineText)
8 // Copyright: (c) Stefan Csomor
9 // Licence: wxWindows licence
10 /////////////////////////////////////////////////////////////////////////////
12 #include "wx/wxprec.h"
16 #include "wx/textctrl.h"
23 #include "wx/button.h"
25 #include "wx/settings.h"
26 #include "wx/msgdlg.h"
27 #include "wx/toplevel.h"
31 #include <sys/types.h>
37 #if wxUSE_STD_IOSTREAM
45 #include "wx/filefn.h"
46 #include "wx/sysopt.h"
47 #include "wx/thread.h"
49 #include "wx/osx/private.h"
50 #include "wx/osx/carbon/private/mactext.h"
56 virtual ~wxMacFunctor() {}
58 virtual void* operator()() = 0 ;
60 static void* CallBackProc( void *param
)
62 wxMacFunctor
* f
= (wxMacFunctor
*) param
;
63 void *result
= (*f
)() ;
68 template<typename classtype
, typename param1type
>
70 class wxMacObjectFunctor1
: public wxMacFunctor
72 typedef void (classtype::*function
)( param1type p1
) ;
73 typedef void (classtype::*ref_function
)( const param1type
& p1
) ;
75 wxMacObjectFunctor1( classtype
*obj
, function f
, param1type p1
) :
83 wxMacObjectFunctor1( classtype
*obj
, ref_function f
, param1type p1
) :
91 virtual ~wxMacObjectFunctor1() {}
93 virtual void* operator()()
95 (m_object
->*m_function
)( m_param1
) ;
100 classtype
* m_object
;
101 param1type m_param1
;
104 function m_function
;
105 ref_function m_refFunction
;
109 template<typename classtype
, typename param1type
>
110 void* wxMacMPRemoteCall( classtype
*object
, void (classtype::*function
)( param1type p1
) , param1type p1
)
112 wxMacObjectFunctor1
<classtype
, param1type
> params(object
, function
, p1
) ;
114 MPRemoteCall( wxMacFunctor::CallBackProc
, ¶ms
, kMPOwningProcessRemoteContext
) ;
118 template<typename classtype
, typename param1type
>
119 void* wxMacMPRemoteCall( classtype
*object
, void (classtype::*function
)( const param1type
& p1
) , param1type p1
)
121 wxMacObjectFunctor1
<classtype
,param1type
> params(object
, function
, p1
) ;
123 MPRemoteCall( wxMacFunctor::CallBackProc
, ¶ms
, kMPOwningProcessRemoteContext
) ;
127 template<typename classtype
, typename param1type
>
128 void* wxMacMPRemoteGUICall( classtype
*object
, void (classtype::*function
)( param1type p1
) , param1type p1
)
131 void *result
= wxMacMPRemoteCall( object
, function
, p1
) ;
136 template<typename classtype
, typename param1type
>
137 void* wxMacMPRemoteGUICall( classtype
*object
, void (classtype::*function
)( const param1type
& p1
) , param1type p1
)
140 void *result
= wxMacMPRemoteCall( object
, function
, p1
) ;
145 class WXDLLEXPORT wxMacPortSaver
147 DECLARE_NO_COPY_CLASS(wxMacPortSaver
)
150 wxMacPortSaver( GrafPtr port
);
158 Clips to the visible region of a control within the current port
161 class WXDLLEXPORT wxMacWindowClipper
: public wxMacPortSaver
163 DECLARE_NO_COPY_CLASS(wxMacWindowClipper
)
166 wxMacWindowClipper( const wxWindow
* win
);
167 ~wxMacWindowClipper();
170 RgnHandle m_formerClip
;
174 wxMacPortSaver::wxMacPortSaver( GrafPtr port
)
176 ::GetPort( &m_port
);
180 wxMacPortSaver::~wxMacPortSaver()
185 wxMacWindowClipper::wxMacWindowClipper( const wxWindow
* win
) :
186 wxMacPortSaver( (GrafPtr
) GetWindowPort( (WindowRef
) win
->MacGetTopLevelWindowRef() ) )
188 m_newPort
= (GrafPtr
) GetWindowPort( (WindowRef
) win
->MacGetTopLevelWindowRef() ) ;
189 m_formerClip
= NewRgn() ;
190 m_newClip
= NewRgn() ;
191 GetClip( m_formerClip
) ;
195 // guard against half constructed objects, this just leads to a empty clip
196 if ( win
->GetPeer() )
199 win
->MacWindowToRootWindow( &x
, &y
) ;
201 // get area including focus rect
202 HIShapeGetAsQDRgn( ((wxWindow
*)win
)->MacGetVisibleRegion(true).GetWXHRGN() , m_newClip
);
203 if ( !EmptyRgn( m_newClip
) )
204 OffsetRgn( m_newClip
, x
, y
) ;
207 SetClip( m_newClip
) ;
211 wxMacWindowClipper::~wxMacWindowClipper()
213 SetPort( m_newPort
) ;
214 SetClip( m_formerClip
) ;
215 DisposeRgn( m_newClip
) ;
216 DisposeRgn( m_formerClip
) ;
219 // common parts for implementations based on MLTE
221 class wxMacMLTEControl
: public wxMacControl
, public wxTextWidgetImpl
224 wxMacMLTEControl( wxTextCtrl
*peer
) ;
225 ~wxMacMLTEControl() {}
227 virtual bool CanFocus() const
230 virtual wxString
GetStringValue() const ;
231 virtual void SetStringValue( const wxString
&str
) ;
233 static TXNFrameOptions
FrameOptionsFromWXStyle( long wxStyle
) ;
235 void AdjustCreationAttributes( const wxColour
& background
, bool visible
) ;
237 virtual void SetFont( const wxFont
& font
, const wxColour
& foreground
, long windowStyle
) ;
238 virtual void SetBackgroundColour(const wxColour
& col
);
239 virtual void SetStyle( long start
, long end
, const wxTextAttr
& style
) ;
240 virtual void Copy() ;
242 virtual void Paste() ;
243 virtual bool CanPaste() const ;
244 virtual void SetEditable( bool editable
) ;
245 virtual long GetLastPosition() const ;
246 virtual void Replace( long from
, long to
, const wxString
&str
) ;
247 virtual void Remove( long from
, long to
) ;
248 virtual void GetSelection( long* from
, long* to
) const ;
249 virtual void SetSelection( long from
, long to
) ;
251 virtual void WriteText( const wxString
& str
) ;
253 virtual bool HasOwnContextMenu() const
255 TXNCommandEventSupportOptions options
;
256 TXNGetCommandEventSupport( m_txn
, & options
) ;
257 return options
& kTXNSupportEditCommandProcessing
;
260 virtual void CheckSpelling(bool check
)
262 TXNSetSpellCheckAsYouType( m_txn
, (Boolean
) check
);
264 virtual void Clear() ;
266 virtual bool CanUndo() const ;
267 virtual void Undo() ;
268 virtual bool CanRedo() const;
269 virtual void Redo() ;
270 virtual int GetNumberOfLines() const ;
271 virtual long XYToPosition(long x
, long y
) const ;
272 virtual bool PositionToXY(long pos
, long *x
, long *y
) const ;
273 virtual void ShowPosition( long pos
) ;
274 virtual int GetLineLength(long lineNo
) const ;
275 virtual wxString
GetLineText(long lineNo
) const ;
277 void SetTXNData( const wxString
& st
, TXNOffset start
, TXNOffset end
) ;
278 TXNObject
GetTXNObject() { return m_txn
; }
281 void TXNSetAttribute( const wxTextAttr
& style
, long from
, long to
) ;
286 // implementation available under OSX
288 class wxMacMLTEHIViewControl
: public wxMacMLTEControl
291 wxMacMLTEHIViewControl( wxTextCtrl
*wxPeer
,
294 const wxSize
& size
, long style
) ;
295 virtual ~wxMacMLTEHIViewControl() ;
297 virtual bool SetFocus() ;
298 virtual bool HasFocus() const ;
299 virtual void SetBackgroundColour(const wxColour
& col
) ;
302 HIViewRef m_scrollView
;
303 HIViewRef m_textView
;
306 // 'classic' MLTE implementation
308 class wxMacMLTEClassicControl
: public wxMacMLTEControl
311 wxMacMLTEClassicControl( wxTextCtrl
*wxPeer
,
314 const wxSize
& size
, long style
) ;
315 virtual ~wxMacMLTEClassicControl() ;
317 virtual void VisibilityChanged(bool shown
) ;
318 virtual void SuperChangedPosition() ;
320 virtual void MacControlUserPaneDrawProc(wxInt16 part
) ;
321 virtual wxInt16
MacControlUserPaneHitTestProc(wxInt16 x
, wxInt16 y
) ;
322 virtual wxInt16
MacControlUserPaneTrackingProc(wxInt16 x
, wxInt16 y
, void* actionProc
) ;
323 virtual void MacControlUserPaneIdleProc() ;
324 virtual wxInt16
MacControlUserPaneKeyDownProc(wxInt16 keyCode
, wxInt16 charCode
, wxInt16 modifiers
) ;
325 virtual void MacControlUserPaneActivateProc(bool activating
) ;
326 virtual wxInt16
MacControlUserPaneFocusProc(wxInt16 action
) ;
327 virtual void MacControlUserPaneBackgroundProc(void* info
) ;
329 virtual bool SetupCursor( const wxPoint
& WXUNUSED(pt
) )
331 MacControlUserPaneIdleProc();
335 virtual void Move(int x
, int y
, int width
, int height
);
340 void MacUpdatePosition() ;
341 void MacActivatePaneText(bool setActive
) ;
342 void MacFocusPaneText(bool setFocus
) ;
343 void MacSetObjectVisibility(bool vis
) ;
346 TXNFrameID m_txnFrameID
;
348 WindowRef m_txnWindow
;
349 // bounds of the control as we last did set the txn frames
350 Rect m_txnControlBounds
;
351 Rect m_txnVisBounds
;
353 static pascal void TXNScrollActionProc( ControlRef controlRef
, ControlPartCode partCode
) ;
354 static pascal void TXNScrollInfoProc(
355 SInt32 iValue
, SInt32 iMaximumValue
,
356 TXNScrollBarOrientation iScrollBarOrientation
, SInt32 iRefCon
) ;
358 ControlRef m_sbHorizontal
;
359 SInt32 m_lastHorizontalValue
;
360 ControlRef m_sbVertical
;
361 SInt32 m_lastVerticalValue
;
364 wxWidgetImplType
* wxWidgetImpl::CreateTextControl( wxTextCtrl
* wxpeer
,
373 bool forceMLTE
= false ;
375 #if wxUSE_SYSTEM_OPTIONS
376 if (wxSystemOptions::HasOption( wxMAC_TEXTCONTROL_USE_MLTE
) && (wxSystemOptions::GetOptionInt( wxMAC_TEXTCONTROL_USE_MLTE
) == 1))
382 if ( UMAGetSystemVersion() >= 0x1050 )
385 wxMacControl
* peer
= NULL
;
389 if ( style
& wxTE_MULTILINE
|| ( UMAGetSystemVersion() >= 0x1050 ) )
390 peer
= new wxMacMLTEHIViewControl( wxpeer
, str
, pos
, size
, style
) ;
395 if ( !(style
& wxTE_MULTILINE
) && !forceMLTE
)
397 peer
= new wxMacUnicodeTextControl( wxpeer
, str
, pos
, size
, style
) ;
401 // the horizontal single line scrolling bug that made us keep the classic implementation
403 #if MAC_OS_X_VERSION_MIN_REQUIRED < MAC_OS_X_VERSION_10_5
405 peer
= new wxMacMLTEClassicControl( wxpeer
, str
, pos
, size
, style
) ;
410 // ----------------------------------------------------------------------------
411 // standard unicode control implementation
412 // ----------------------------------------------------------------------------
414 // the current unicode textcontrol implementation has a bug : only if the control
415 // is currently having the focus, the selection can be retrieved by the corresponding
416 // data tag. So we have a mirroring using a member variable
417 // TODO : build event table using virtual member functions for wxMacControl
419 static const EventTypeSpec unicodeTextControlEventList
[] =
421 { kEventClassControl
, kEventControlSetFocusPart
} ,
424 static pascal OSStatus
wxMacUnicodeTextControlControlEventHandler( EventHandlerCallRef handler
, EventRef event
, void *data
)
426 OSStatus result
= eventNotHandledErr
;
427 wxMacUnicodeTextControl
* focus
= (wxMacUnicodeTextControl
*) data
;
428 wxMacCarbonEvent
cEvent( event
) ;
430 switch ( GetEventKind( event
) )
432 case kEventControlSetFocusPart
:
434 ControlPartCode controlPart
= cEvent
.GetParameter
<ControlPartCode
>(kEventParamControlPart
, typeControlPartCode
);
435 if ( controlPart
== kControlFocusNoPart
)
437 // about to loose focus -> store selection to field
438 focus
->GetData
<ControlEditTextSelectionRec
>( 0, kControlEditTextSelectionTag
, &focus
->m_selection
);
440 result
= CallNextEventHandler(handler
,event
) ;
441 if ( controlPart
!= kControlFocusNoPart
)
443 // about to gain focus -> set selection from field
444 focus
->SetData
<ControlEditTextSelectionRec
>( 0, kControlEditTextSelectionTag
, &focus
->m_selection
);
455 static pascal OSStatus
wxMacUnicodeTextControlEventHandler( EventHandlerCallRef handler
, EventRef event
, void *data
)
457 OSStatus result
= eventNotHandledErr
;
459 switch ( GetEventClass( event
) )
461 case kEventClassControl
:
462 result
= wxMacUnicodeTextControlControlEventHandler( handler
, event
, data
) ;
471 DEFINE_ONE_SHOT_HANDLER_GETTER( wxMacUnicodeTextControlEventHandler
)
473 wxMacUnicodeTextControl::wxMacUnicodeTextControl( wxTextCtrl
*wxPeer
) : wxMacControl( wxPeer
)
477 wxMacUnicodeTextControl::wxMacUnicodeTextControl( wxTextCtrl
*wxPeer
,
480 const wxSize
& size
, long style
)
481 : wxMacControl( wxPeer
)
483 m_font
= wxPeer
->GetFont() ;
484 m_windowStyle
= style
;
485 m_selection
.selStart
= m_selection
.selEnd
= 0;
486 Rect bounds
= wxMacGetBoundsForControl( wxPeer
, pos
, size
) ;
488 wxMacConvertNewlines10To13( &st
) ;
489 wxCFStringRef
cf(st
, m_font
.GetEncoding()) ;
491 m_valueTag
= kControlEditTextCFStringTag
;
492 Boolean isPassword
= ( m_windowStyle
& wxTE_PASSWORD
) != 0 ;
495 m_valueTag
= kControlEditTextPasswordCFStringTag
;
497 OSStatus err
= CreateEditUnicodeTextControl(
498 MAC_WXHWND(wxPeer
->MacGetTopLevelWindowRef()), &bounds
, cf
,
499 isPassword
, NULL
, &m_controlRef
) ;
502 if ( !(m_windowStyle
& wxTE_MULTILINE
) )
503 SetData
<Boolean
>( kControlEditTextPart
, kControlEditTextSingleLineTag
, true ) ;
505 InstallEventHandlers();
508 void wxMacUnicodeTextControl::InstallEventHandlers()
510 ::InstallControlEventHandler( m_controlRef
, GetwxMacUnicodeTextControlEventHandlerUPP(),
511 GetEventTypeCount(unicodeTextControlEventList
), unicodeTextControlEventList
, this,
515 wxMacUnicodeTextControl::~wxMacUnicodeTextControl()
519 void wxMacUnicodeTextControl::VisibilityChanged(bool shown
)
521 if ( !(m_windowStyle
& wxTE_MULTILINE
) && shown
)
523 // work around a refresh issue insofar as not always the entire content is shown,
524 // even if this would be possible
525 ControlEditTextSelectionRec sel
;
526 CFStringRef value
= NULL
;
528 verify_noerr( GetData
<ControlEditTextSelectionRec
>( 0, kControlEditTextSelectionTag
, &sel
) );
529 verify_noerr( GetData
<CFStringRef
>( 0, m_valueTag
, &value
) );
530 verify_noerr( SetData
<CFStringRef
>( 0, m_valueTag
, &value
) );
531 verify_noerr( SetData
<ControlEditTextSelectionRec
>( 0, kControlEditTextSelectionTag
, &sel
) );
537 wxString
wxMacUnicodeTextControl::GetStringValue() const
540 CFStringRef value
= GetData
<CFStringRef
>(0, m_valueTag
) ;
543 wxCFStringRef
cf(value
) ;
544 result
= cf
.AsString() ;
548 wxMacConvertNewlines13To10( &result
) ;
550 wxMacConvertNewlines10To13( &result
) ;
556 void wxMacUnicodeTextControl::SetStringValue( const wxString
&str
)
559 wxMacConvertNewlines10To13( &st
) ;
560 wxCFStringRef
cf( st
, m_font
.GetEncoding() ) ;
561 verify_noerr( SetData
<CFStringRef
>( 0, m_valueTag
, cf
) ) ;
564 void wxMacUnicodeTextControl::Copy()
566 SendHICommand( kHICommandCopy
) ;
569 void wxMacUnicodeTextControl::Cut()
571 SendHICommand( kHICommandCut
) ;
574 void wxMacUnicodeTextControl::Paste()
576 SendHICommand( kHICommandPaste
) ;
579 bool wxMacUnicodeTextControl::CanPaste() const
584 void wxMacUnicodeTextControl::SetEditable(bool WXUNUSED(editable
))
586 #if 0 // leads to problem because text cannot be selected anymore
587 SetData
<Boolean
>( kControlEditTextPart
, kControlEditTextLockedTag
, (Boolean
) !editable
) ;
591 void wxMacUnicodeTextControl::GetSelection( long* from
, long* to
) const
593 ControlEditTextSelectionRec sel
;
595 verify_noerr( GetData
<ControlEditTextSelectionRec
>( 0, kControlEditTextSelectionTag
, &sel
) ) ;
600 *from
= sel
.selStart
;
605 void wxMacUnicodeTextControl::SetSelection( long from
, long to
)
607 ControlEditTextSelectionRec sel
;
610 CFStringRef value
= GetData
<CFStringRef
>(0, m_valueTag
) ;
613 wxCFStringRef
cf(value
) ;
614 textLength
= cf
.AsString().length() ;
617 if ((from
== -1) && (to
== -1))
624 from
= wxMin(textLength
,wxMax(from
,0)) ;
628 to
= wxMax(0,wxMin(textLength
,to
)) ;
631 sel
.selStart
= from
;
634 SetData
<ControlEditTextSelectionRec
>( 0, kControlEditTextSelectionTag
, &sel
) ;
639 void wxMacUnicodeTextControl::WriteText( const wxString
& str
)
641 // TODO: this MPRemoting will be moved into a remoting peer proxy for any command
642 if ( !wxIsMainThread() )
645 // unfortunately CW 8 is not able to correctly deduce the template types,
646 // so we have to instantiate explicitly
647 wxMacMPRemoteGUICall
<wxTextCtrl
,wxString
>( (wxTextCtrl
*) GetWXPeer() , &wxTextCtrl::WriteText
, str
) ;
653 wxMacConvertNewlines10To13( &st
) ;
657 wxCFStringRef
cf(st
, m_font
.GetEncoding() ) ;
658 CFStringRef value
= cf
;
659 SetData
<CFStringRef
>( 0, kControlEditTextInsertCFStringRefTag
, &value
);
663 wxString val
= GetStringValue() ;
665 GetSelection( &start
, &end
) ;
666 val
.Remove( start
, end
- start
) ;
667 val
.insert( start
, str
) ;
668 SetStringValue( val
) ;
669 SetSelection( start
+ str
.length() , start
+ str
.length() ) ;
673 // ----------------------------------------------------------------------------
674 // MLTE control implementation (common part)
675 // ----------------------------------------------------------------------------
677 // if MTLE is read only, no changes at all are allowed, not even from
678 // procedural API, in order to allow changes via API all the same we must undo
679 // the readonly status while we are executing, this class helps to do so
681 class wxMacEditHelper
684 wxMacEditHelper( TXNObject txn
)
686 TXNControlTag tag
[] = { kTXNIOPrivilegesTag
} ;
688 TXNGetTXNObjectControls( m_txn
, 1 , tag
, m_data
) ;
689 if ( m_data
[0].uValue
== kTXNReadOnly
)
691 TXNControlData data
[] = { { kTXNReadWrite
} } ;
692 TXNSetTXNObjectControls( m_txn
, false , 1 , tag
, data
) ;
698 TXNControlTag tag
[] = { kTXNIOPrivilegesTag
} ;
699 if ( m_data
[0].uValue
== kTXNReadOnly
)
700 TXNSetTXNObjectControls( m_txn
, false , 1 , tag
, m_data
) ;
705 TXNControlData m_data
[1] ;
708 wxMacMLTEControl::wxMacMLTEControl( wxTextCtrl
*peer
)
709 : wxMacControl( peer
)
711 SetNeedsFocusRect( true ) ;
714 wxString
wxMacMLTEControl::GetStringValue() const
723 err
= TXNGetDataEncoded( m_txn
, kTXNStartOffset
, kTXNEndOffset
, &theText
, kTXNUnicodeTextData
);
732 actualSize
= GetHandleSize( theText
) / sizeof(UniChar
) ;
733 if ( actualSize
> 0 )
737 #if SIZEOF_WCHAR_T == 2
738 ptr
= new wxChar
[actualSize
+ 1] ;
739 wxStrncpy( ptr
, (wxChar
*)(*theText
) , actualSize
) ;
741 SetHandleSize( theText
, (actualSize
+ 1) * sizeof(UniChar
) ) ;
743 (((UniChar
*)*theText
)[actualSize
]) = 0 ;
744 wxMBConvUTF16 converter
;
745 size_t noChars
= converter
.MB2WC( NULL
, (const char*)*theText
, 0 ) ;
746 wxASSERT_MSG( noChars
!= wxCONV_FAILED
, _T("Unable to count the number of characters in this string!") );
747 ptr
= new wxChar
[noChars
+ 1] ;
749 noChars
= converter
.MB2WC( ptr
, (const char*)*theText
, noChars
+ 1 ) ;
750 wxASSERT_MSG( noChars
!= wxCONV_FAILED
, _T("Conversion of string failed!") );
755 ptr
[actualSize
] = 0 ;
756 result
= wxString( ptr
) ;
760 DisposeHandle( theText
) ;
764 err
= TXNGetDataEncoded( m_txn
, kTXNStartOffset
, kTXNEndOffset
, &theText
, kTXNTextData
);
773 actualSize
= GetHandleSize( theText
) ;
774 if ( actualSize
> 0 )
777 result
= wxString( *theText
, wxConvLocal
, actualSize
) ;
781 DisposeHandle( theText
) ;
787 wxMacConvertNewlines13To10( &result
) ;
789 wxMacConvertNewlines10To13( &result
) ;
795 void wxMacMLTEControl::SetStringValue( const wxString
&str
)
798 wxMacConvertNewlines10To13( &st
);
802 wxMacWindowClipper
c( GetWXPeer() ) ;
806 wxMacEditHelper
help( m_txn
);
807 SetTXNData( st
, kTXNStartOffset
, kTXNEndOffset
);
810 TXNSetSelection( m_txn
, 0, 0 );
811 TXNShowSelection( m_txn
, kTXNShowStart
);
815 TXNFrameOptions
wxMacMLTEControl::FrameOptionsFromWXStyle( long wxStyle
)
817 TXNFrameOptions frameOptions
= kTXNDontDrawCaretWhenInactiveMask
;
819 frameOptions
|= kTXNDoFontSubstitutionMask
;
821 if ( ! (wxStyle
& wxTE_NOHIDESEL
) )
822 frameOptions
|= kTXNDontDrawSelectionWhenInactiveMask
;
824 if ( wxStyle
& (wxHSCROLL
| wxTE_DONTWRAP
) )
825 frameOptions
|= kTXNWantHScrollBarMask
;
827 if ( wxStyle
& wxTE_MULTILINE
)
829 if ( ! (wxStyle
& wxTE_DONTWRAP
) )
830 frameOptions
|= kTXNAlwaysWrapAtViewEdgeMask
;
832 if ( !(wxStyle
& wxTE_NO_VSCROLL
) )
834 frameOptions
|= kTXNWantVScrollBarMask
;
836 // The following code causes drawing problems on 10.4. Perhaps it can be restored for
837 // older versions of the OS, but I'm not sure it's appropriate to put a grow icon here
838 // anyways, as AFAIK users can't actually use it to resize the text ctrl.
839 // if ( frameOptions & kTXNWantHScrollBarMask )
840 // frameOptions |= kTXNDrawGrowIconMask ;
845 frameOptions
|= kTXNSingleLineOnlyMask
;
848 return frameOptions
;
851 void wxMacMLTEControl::AdjustCreationAttributes(const wxColour
&background
,
852 bool WXUNUSED(visible
))
854 TXNControlTag iControlTags
[] =
856 kTXNDoFontSubstitution
,
857 kTXNWordWrapStateTag
,
859 TXNControlData iControlData
[] =
865 int toptag
= WXSIZEOF( iControlTags
) ;
867 if ( m_windowStyle
& wxTE_MULTILINE
)
869 iControlData
[1].uValue
=
870 (m_windowStyle
& wxTE_DONTWRAP
)
875 OSStatus err
= TXNSetTXNObjectControls( m_txn
, false, toptag
, iControlTags
, iControlData
) ;
878 // setting the default font:
879 // under 10.2 this causes a visible caret, therefore we avoid it
885 GetThemeFont( kThemeSystemFont
, GetApplicationScript() , fontName
, &fontSize
, &fontStyle
) ;
887 TXNTypeAttributes typeAttr
[] =
889 { kTXNQDFontNameAttribute
, kTXNQDFontNameAttributeSize
, { (void*) fontName
} } ,
890 { kTXNQDFontSizeAttribute
, kTXNFontSizeAttributeSize
, { (void*) (fontSize
<< 16) } } ,
891 { kTXNQDFontStyleAttribute
, kTXNQDFontStyleAttributeSize
, { (void*) normal
} } ,
894 err
= TXNSetTypeAttributes(
895 m_txn
, sizeof(typeAttr
) / sizeof(TXNTypeAttributes
),
896 typeAttr
, kTXNStartOffset
, kTXNEndOffset
);
899 if ( m_windowStyle
& wxTE_PASSWORD
)
902 err
= TXNEchoMode( m_txn
, c
, 0 , true );
907 tback
.bgType
= kTXNBackgroundTypeRGB
;
908 background
.GetRGBColor( &tback
.bg
.color
);
909 TXNSetBackground( m_txn
, &tback
);
912 TXNCommandEventSupportOptions options
;
913 if ( TXNGetCommandEventSupport( m_txn
, &options
) == noErr
)
916 kTXNSupportEditCommandProcessing
917 | kTXNSupportEditCommandUpdating
918 | kTXNSupportFontCommandProcessing
919 | kTXNSupportFontCommandUpdating
;
921 // only spell check when not read-only
922 // use system options for the default
923 bool checkSpelling
= false ;
924 if ( !(m_windowStyle
& wxTE_READONLY
) )
926 #if wxUSE_SYSTEM_OPTIONS
927 if ( wxSystemOptions::HasOption( wxMAC_TEXTCONTROL_USE_SPELL_CHECKER
) && (wxSystemOptions::GetOptionInt( wxMAC_TEXTCONTROL_USE_SPELL_CHECKER
) == 1) )
929 checkSpelling
= true ;
936 kTXNSupportSpellCheckCommandProcessing
937 | kTXNSupportSpellCheckCommandUpdating
;
939 TXNSetCommandEventSupport( m_txn
, options
) ;
943 void wxMacMLTEControl::SetBackgroundColour(const wxColour
& col
)
946 tback
.bgType
= kTXNBackgroundTypeRGB
;
947 col
.GetRGBColor(&tback
.bg
.color
);
948 TXNSetBackground( m_txn
, &tback
);
951 static inline int wxConvertToTXN(int x
)
953 return wx_static_cast(int, x
/ 254.0 * 72 + 0.5);
956 void wxMacMLTEControl::TXNSetAttribute( const wxTextAttr
& style
, long from
, long to
)
958 TXNTypeAttributes typeAttr
[4] ;
960 size_t typeAttrCount
= 0 ;
963 TXNControlTag controlTags
[4];
964 TXNControlData controlData
[4];
965 size_t controlAttrCount
= 0;
969 bool relayout
= false;
972 if ( style
.HasFont() )
974 wxASSERT( typeAttrCount
< WXSIZEOF(typeAttr
) );
975 font
= style
.GetFont() ;
976 typeAttr
[typeAttrCount
].tag
= kTXNATSUIStyle
;
977 typeAttr
[typeAttrCount
].size
= kTXNATSUIStyleSize
;
978 typeAttr
[typeAttrCount
].data
.dataPtr
= font
.MacGetATSUStyle() ;
982 if ( style
.HasTextColour() )
984 wxASSERT( typeAttrCount
< WXSIZEOF(typeAttr
) );
985 style
.GetTextColour().GetRGBColor( &color
);
986 typeAttr
[typeAttrCount
].tag
= kTXNQDFontColorAttribute
;
987 typeAttr
[typeAttrCount
].size
= kTXNQDFontColorAttributeSize
;
988 typeAttr
[typeAttrCount
].data
.dataPtr
= (void*) &color
;
992 if ( style
.HasAlignment() )
994 wxASSERT( controlAttrCount
< WXSIZEOF(controlTags
) );
997 switch ( style
.GetAlignment() )
999 case wxTEXT_ALIGNMENT_LEFT
:
1000 align
= kTXNFlushLeft
;
1002 case wxTEXT_ALIGNMENT_CENTRE
:
1005 case wxTEXT_ALIGNMENT_RIGHT
:
1006 align
= kTXNFlushRight
;
1008 case wxTEXT_ALIGNMENT_JUSTIFIED
:
1009 align
= kTXNFullJust
;
1012 case wxTEXT_ALIGNMENT_DEFAULT
:
1013 align
= kTXNFlushDefault
;
1017 controlTags
[controlAttrCount
] = kTXNJustificationTag
;
1018 controlData
[controlAttrCount
].sValue
= align
;
1019 controlAttrCount
++ ;
1022 if ( style
.HasLeftIndent() || style
.HasRightIndent() )
1024 wxASSERT( controlAttrCount
< WXSIZEOF(controlTags
) );
1025 controlTags
[controlAttrCount
] = kTXNMarginsTag
;
1026 controlData
[controlAttrCount
].marginsPtr
= &margins
;
1027 verify_noerr( TXNGetTXNObjectControls (m_txn
, 1 ,
1028 &controlTags
[controlAttrCount
], &controlData
[controlAttrCount
]) );
1029 if ( style
.HasLeftIndent() )
1031 margins
.leftMargin
= wxConvertToTXN(style
.GetLeftIndent());
1033 if ( style
.HasRightIndent() )
1035 margins
.rightMargin
= wxConvertToTXN(style
.GetRightIndent());
1037 controlAttrCount
++ ;
1040 if ( style
.HasTabs() )
1042 const wxArrayInt
& tabarray
= style
.GetTabs();
1043 // unfortunately Mac only applies a tab distance, not individually different tabs
1044 controlTags
[controlAttrCount
] = kTXNTabSettingsTag
;
1045 if ( tabarray
.size() > 0 )
1046 controlData
[controlAttrCount
].tabValue
.value
= wxConvertToTXN(tabarray
[0]);
1048 controlData
[controlAttrCount
].tabValue
.value
= 72 ;
1050 controlData
[controlAttrCount
].tabValue
.tabType
= kTXNLeftTab
;
1051 controlAttrCount
++ ;
1054 // unfortunately the relayout is not automatic
1055 if ( controlAttrCount
> 0 )
1057 verify_noerr( TXNSetTXNObjectControls (m_txn
, false /* don't clear all */, controlAttrCount
,
1058 controlTags
, controlData
) );
1062 if ( typeAttrCount
> 0 )
1064 verify_noerr( TXNSetTypeAttributes( m_txn
, typeAttrCount
, typeAttr
, from
, to
) );
1076 TXNRecalcTextLayout( m_txn
);
1080 void wxMacMLTEControl::SetFont(const wxFont
& font
,
1081 const wxColour
& foreground
,
1082 long WXUNUSED(windowStyle
))
1084 wxMacEditHelper
help( m_txn
) ;
1085 TXNSetAttribute( wxTextAttr( foreground
, wxNullColour
, font
), kTXNStartOffset
, kTXNEndOffset
) ;
1088 void wxMacMLTEControl::SetStyle( long start
, long end
, const wxTextAttr
& style
)
1090 wxMacEditHelper
help( m_txn
) ;
1091 TXNSetAttribute( style
, start
, end
) ;
1094 void wxMacMLTEControl::Copy()
1099 void wxMacMLTEControl::Cut()
1104 void wxMacMLTEControl::Paste()
1109 bool wxMacMLTEControl::CanPaste() const
1111 return TXNIsScrapPastable() ;
1114 void wxMacMLTEControl::SetEditable(bool editable
)
1116 TXNControlTag tag
[] = { kTXNIOPrivilegesTag
} ;
1117 TXNControlData data
[] = { { editable
? kTXNReadWrite
: kTXNReadOnly
} } ;
1118 TXNSetTXNObjectControls( m_txn
, false, WXSIZEOF(tag
), tag
, data
) ;
1121 long wxMacMLTEControl::GetLastPosition() const
1123 wxTextPos actualsize
= 0 ;
1126 OSErr err
= TXNGetDataEncoded( m_txn
, kTXNStartOffset
, kTXNEndOffset
, &theText
, kTXNTextData
);
1131 actualsize
= GetHandleSize( theText
) ;
1132 DisposeHandle( theText
) ;
1142 void wxMacMLTEControl::Replace( long from
, long to
, const wxString
&str
)
1144 wxString value
= str
;
1145 wxMacConvertNewlines10To13( &value
) ;
1147 wxMacEditHelper
help( m_txn
) ;
1149 wxMacWindowClipper
c( GetWXPeer() ) ;
1152 TXNSetSelection( m_txn
, from
, to
== -1 ? kTXNEndOffset
: to
) ;
1154 SetTXNData( value
, kTXNUseCurrentSelection
, kTXNUseCurrentSelection
) ;
1157 void wxMacMLTEControl::Remove( long from
, long to
)
1160 wxMacWindowClipper
c( GetWXPeer() ) ;
1162 wxMacEditHelper
help( m_txn
) ;
1163 TXNSetSelection( m_txn
, from
, to
) ;
1167 void wxMacMLTEControl::GetSelection( long* from
, long* to
) const
1170 TXNGetSelection( m_txn
, &f
, &t
) ;
1175 void wxMacMLTEControl::SetSelection( long from
, long to
)
1178 wxMacWindowClipper
c( GetWXPeer() ) ;
1181 // change the selection
1182 if ((from
== -1) && (to
== -1))
1183 TXNSelectAll( m_txn
);
1185 TXNSetSelection( m_txn
, from
, to
== -1 ? kTXNEndOffset
: to
);
1187 TXNShowSelection( m_txn
, kTXNShowStart
);
1190 void wxMacMLTEControl::WriteText( const wxString
& str
)
1192 // TODO: this MPRemoting will be moved into a remoting peer proxy for any command
1193 if ( !wxIsMainThread() )
1195 #if wxOSX_USE_CARBON
1196 // unfortunately CW 8 is not able to correctly deduce the template types,
1197 // so we have to instantiate explicitly
1198 wxMacMPRemoteGUICall
<wxTextCtrl
,wxString
>( (wxTextCtrl
*) GetWXPeer() , &wxTextCtrl::WriteText
, str
) ;
1204 wxMacConvertNewlines10To13( &st
) ;
1206 long start
, end
, dummy
;
1208 GetSelection( &start
, &dummy
) ;
1210 wxMacWindowClipper
c( GetWXPeer() ) ;
1214 wxMacEditHelper
helper( m_txn
) ;
1215 SetTXNData( st
, kTXNUseCurrentSelection
, kTXNUseCurrentSelection
) ;
1218 GetSelection( &dummy
, &end
) ;
1220 // TODO: SetStyle( start , end , GetDefaultStyle() ) ;
1223 void wxMacMLTEControl::Clear()
1226 wxMacWindowClipper
c( GetWXPeer() ) ;
1228 wxMacEditHelper
st( m_txn
) ;
1229 TXNSetSelection( m_txn
, kTXNStartOffset
, kTXNEndOffset
) ;
1233 bool wxMacMLTEControl::CanUndo() const
1235 return TXNCanUndo( m_txn
, NULL
) ;
1238 void wxMacMLTEControl::Undo()
1243 bool wxMacMLTEControl::CanRedo() const
1245 return TXNCanRedo( m_txn
, NULL
) ;
1248 void wxMacMLTEControl::Redo()
1253 int wxMacMLTEControl::GetNumberOfLines() const
1255 ItemCount lines
= 0 ;
1256 TXNGetLineCount( m_txn
, &lines
) ;
1261 long wxMacMLTEControl::XYToPosition(long x
, long y
) const
1266 // TODO: find a better implementation : while we can get the
1267 // line metrics of a certain line, we don't get its starting
1268 // position, so it would probably be rather a binary search
1269 // for the start position
1270 long xpos
= 0, ypos
= 0 ;
1271 int lastHeight
= 0 ;
1274 lastpos
= GetLastPosition() ;
1275 for ( n
= 0 ; n
<= (ItemCount
) lastpos
; ++n
)
1277 if ( y
== ypos
&& x
== xpos
)
1280 TXNOffsetToPoint( m_txn
, n
, &curpt
) ;
1282 if ( curpt
.v
> lastHeight
)
1288 lastHeight
= curpt
.v
;
1297 bool wxMacMLTEControl::PositionToXY( long pos
, long *x
, long *y
) const
1307 lastpos
= GetLastPosition() ;
1308 if ( pos
<= lastpos
)
1310 // TODO: find a better implementation - while we can get the
1311 // line metrics of a certain line, we don't get its starting
1312 // position, so it would probably be rather a binary search
1313 // for the start position
1314 long xpos
= 0, ypos
= 0 ;
1315 int lastHeight
= 0 ;
1318 for ( n
= 0 ; n
<= (ItemCount
) pos
; ++n
)
1320 TXNOffsetToPoint( m_txn
, n
, &curpt
) ;
1322 if ( curpt
.v
> lastHeight
)
1328 lastHeight
= curpt
.v
;
1343 void wxMacMLTEControl::ShowPosition( long pos
)
1345 Point current
, desired
;
1346 TXNOffset selstart
, selend
;
1348 TXNGetSelection( m_txn
, &selstart
, &selend
);
1349 TXNOffsetToPoint( m_txn
, selstart
, ¤t
);
1350 TXNOffsetToPoint( m_txn
, pos
, &desired
);
1352 // TODO: use HIPoints for 10.3 and above
1354 OSErr theErr
= noErr
;
1355 long dv
= desired
.v
- current
.v
;
1356 long dh
= desired
.h
- current
.h
;
1357 TXNShowSelection( m_txn
, kTXNShowStart
) ; // NB: should this be kTXNShowStart or kTXNShowEnd ??
1358 theErr
= TXNScroll( m_txn
, kTXNScrollUnitsInPixels
, kTXNScrollUnitsInPixels
, &dv
, &dh
);
1360 // there will be an error returned for classic MLTE implementation when the control is
1361 // invisible, but HITextView works correctly, so we don't assert that one
1362 // wxASSERT_MSG( theErr == noErr, _T("TXNScroll returned an error!") );
1365 void wxMacMLTEControl::SetTXNData( const wxString
& st
, TXNOffset start
, TXNOffset end
)
1368 #if SIZEOF_WCHAR_T == 2
1369 size_t len
= st
.length() ;
1370 TXNSetData( m_txn
, kTXNUnicodeTextData
, (void*)st
.wc_str(), len
* 2, start
, end
);
1372 wxMBConvUTF16 converter
;
1373 ByteCount byteBufferLen
= converter
.WC2MB( NULL
, st
.wc_str(), 0 ) ;
1374 UniChar
*unibuf
= (UniChar
*)malloc( byteBufferLen
) ;
1375 converter
.WC2MB( (char*)unibuf
, st
.wc_str(), byteBufferLen
) ;
1376 TXNSetData( m_txn
, kTXNUnicodeTextData
, (void*)unibuf
, byteBufferLen
, start
, end
) ;
1380 wxCharBuffer text
= st
.mb_str( wxConvLocal
) ;
1381 TXNSetData( m_txn
, kTXNTextData
, (void*)text
.data(), strlen( text
), start
, end
) ;
1385 wxString
wxMacMLTEControl::GetLineText(long lineNo
) const
1389 if ( lineNo
< GetNumberOfLines() )
1392 Fixed lineWidth
, lineHeight
, currentHeight
;
1395 // get the first possible position in the control
1396 TXNOffsetToPoint(m_txn
, 0, &firstPoint
);
1398 // Iterate through the lines until we reach the one we want,
1399 // adding to our current y pixel point position
1402 while (ypos
< lineNo
)
1404 TXNGetLineMetrics(m_txn
, ypos
++, &lineWidth
, &lineHeight
);
1405 currentHeight
+= lineHeight
;
1408 Point thePoint
= { firstPoint
.v
+ (currentHeight
>> 16), firstPoint
.h
+ (0) };
1409 TXNOffset theOffset
;
1410 TXNPointToOffset(m_txn
, thePoint
, &theOffset
);
1412 wxString content
= GetStringValue() ;
1413 Point currentPoint
= thePoint
;
1414 while (thePoint
.v
== currentPoint
.v
&& theOffset
< content
.length())
1416 line
+= content
[theOffset
];
1417 TXNOffsetToPoint(m_txn
, ++theOffset
, ¤tPoint
);
1424 int wxMacMLTEControl::GetLineLength(long lineNo
) const
1428 if ( lineNo
< GetNumberOfLines() )
1431 Fixed lineWidth
, lineHeight
, currentHeight
;
1434 // get the first possible position in the control
1435 TXNOffsetToPoint(m_txn
, 0, &firstPoint
);
1437 // Iterate through the lines until we reach the one we want,
1438 // adding to our current y pixel point position
1441 while (ypos
< lineNo
)
1443 TXNGetLineMetrics(m_txn
, ypos
++, &lineWidth
, &lineHeight
);
1444 currentHeight
+= lineHeight
;
1447 Point thePoint
= { firstPoint
.v
+ (currentHeight
>> 16), firstPoint
.h
+ (0) };
1448 TXNOffset theOffset
;
1449 TXNPointToOffset(m_txn
, thePoint
, &theOffset
);
1451 wxString content
= GetStringValue() ;
1452 Point currentPoint
= thePoint
;
1453 while (thePoint
.v
== currentPoint
.v
&& theOffset
< content
.length())
1456 TXNOffsetToPoint(m_txn
, ++theOffset
, ¤tPoint
);
1463 #if MAC_OS_X_VERSION_MIN_REQUIRED < MAC_OS_X_VERSION_10_5
1465 // ----------------------------------------------------------------------------
1466 // MLTE control implementation (classic part)
1467 // ----------------------------------------------------------------------------
1469 // OS X Notes : We still don't have a full replacement for MLTE, so this implementation
1470 // has to live on. We have different problems coming from outdated implementations on the
1471 // various OS X versions. Most deal with the scrollbars: they are not correctly embedded
1472 // while this can be solved on 10.3 by reassigning them the correct place, on 10.2 there is
1473 // no way out, therefore we are using our own implementation and our own scrollbars ....
1475 TXNScrollInfoUPP gTXNScrollInfoProc
= NULL
;
1476 ControlActionUPP gTXNScrollActionProc
= NULL
;
1478 pascal void wxMacMLTEClassicControl::TXNScrollInfoProc(
1479 SInt32 iValue
, SInt32 iMaximumValue
,
1480 TXNScrollBarOrientation iScrollBarOrientation
, SInt32 iRefCon
)
1482 wxMacMLTEClassicControl
* mlte
= (wxMacMLTEClassicControl
*) iRefCon
;
1483 SInt32 value
= wxMax( iValue
, 0 ) ;
1484 SInt32 maximum
= wxMax( iMaximumValue
, 0 ) ;
1486 if ( iScrollBarOrientation
== kTXNHorizontal
)
1488 if ( mlte
->m_sbHorizontal
)
1490 SetControl32BitValue( mlte
->m_sbHorizontal
, value
) ;
1491 SetControl32BitMaximum( mlte
->m_sbHorizontal
, maximum
) ;
1492 mlte
->m_lastHorizontalValue
= value
;
1495 else if ( iScrollBarOrientation
== kTXNVertical
)
1497 if ( mlte
->m_sbVertical
)
1499 SetControl32BitValue( mlte
->m_sbVertical
, value
) ;
1500 SetControl32BitMaximum( mlte
->m_sbVertical
, maximum
) ;
1501 mlte
->m_lastVerticalValue
= value
;
1506 pascal void wxMacMLTEClassicControl::TXNScrollActionProc( ControlRef controlRef
, ControlPartCode partCode
)
1508 wxMacMLTEClassicControl
* mlte
= (wxMacMLTEClassicControl
*) GetControlReference( controlRef
) ;
1512 if ( controlRef
!= mlte
->m_sbVertical
&& controlRef
!= mlte
->m_sbHorizontal
)
1516 bool isHorizontal
= ( controlRef
== mlte
->m_sbHorizontal
) ;
1518 SInt32 minimum
= 0 ;
1519 SInt32 maximum
= GetControl32BitMaximum( controlRef
) ;
1520 SInt32 value
= GetControl32BitValue( controlRef
) ;
1525 case kControlDownButtonPart
:
1529 case kControlUpButtonPart
:
1533 case kControlPageDownPart
:
1534 delta
= GetControlViewSize( controlRef
) ;
1537 case kControlPageUpPart
:
1538 delta
= -GetControlViewSize( controlRef
) ;
1541 case kControlIndicatorPart
:
1542 delta
= value
- (isHorizontal
? mlte
->m_lastHorizontalValue
: mlte
->m_lastVerticalValue
) ;
1551 SInt32 newValue
= value
;
1553 if ( partCode
!= kControlIndicatorPart
)
1555 if ( value
+ delta
< minimum
)
1556 delta
= minimum
- value
;
1557 if ( value
+ delta
> maximum
)
1558 delta
= maximum
- value
;
1560 SetControl32BitValue( controlRef
, value
+ delta
) ;
1561 newValue
= value
+ delta
;
1564 SInt32 verticalDelta
= isHorizontal
? 0 : delta
;
1565 SInt32 horizontalDelta
= isHorizontal
? delta
: 0 ;
1568 mlte
->m_txn
, kTXNScrollUnitsInPixels
, kTXNScrollUnitsInPixels
,
1569 &verticalDelta
, &horizontalDelta
);
1570 verify_noerr( err
);
1573 mlte
->m_lastHorizontalValue
= newValue
;
1575 mlte
->m_lastVerticalValue
= newValue
;
1579 // make correct activations
1580 void wxMacMLTEClassicControl::MacActivatePaneText(bool setActive
)
1582 wxTextCtrl
* textctrl
= (wxTextCtrl
*) GetControlReference(m_controlRef
);
1584 wxMacWindowClipper
clipper( textctrl
) ;
1585 TXNActivate( m_txn
, m_txnFrameID
, setActive
);
1587 ControlRef controlFocus
= 0 ;
1588 GetKeyboardFocus( m_txnWindow
, &controlFocus
) ;
1589 if ( controlFocus
== m_controlRef
)
1590 TXNFocus( m_txn
, setActive
);
1593 void wxMacMLTEClassicControl::MacFocusPaneText(bool setFocus
)
1595 TXNFocus( m_txn
, setFocus
);
1598 // guards against inappropriate redraw (hidden objects drawing onto window)
1600 void wxMacMLTEClassicControl::MacSetObjectVisibility(bool vis
)
1602 ControlRef controlFocus
= 0 ;
1603 GetKeyboardFocus( m_txnWindow
, &controlFocus
) ;
1605 if ( !vis
&& (controlFocus
== m_controlRef
) )
1606 SetKeyboardFocus( m_txnWindow
, m_controlRef
, kControlFocusNoPart
) ;
1608 TXNControlTag iControlTags
[1] = { kTXNVisibilityTag
};
1609 TXNControlData iControlData
[1] = { { (UInt32
)false } };
1611 verify_noerr( TXNGetTXNObjectControls( m_txn
, 1, iControlTags
, iControlData
) ) ;
1613 if ( iControlData
[0].uValue
!= vis
)
1615 iControlData
[0].uValue
= vis
;
1616 verify_noerr( TXNSetTXNObjectControls( m_txn
, false , 1, iControlTags
, iControlData
) ) ;
1619 // currently, we always clip as partial visibility (overlapped) visibility is also a problem,
1620 // if we run into further problems we might set the FrameBounds to an empty rect here
1623 // make sure that the TXNObject is at the right position
1625 void wxMacMLTEClassicControl::MacUpdatePosition()
1627 wxTextCtrl
* textctrl
= (wxTextCtrl
*)GetControlReference( m_controlRef
);
1628 if ( textctrl
== NULL
)
1632 GetRectInWindowCoords( &bounds
);
1634 wxRect visRect
= textctrl
->MacGetClippedClientRect() ;
1635 Rect visBounds
= { visRect
.y
, visRect
.x
, visRect
.y
+ visRect
.height
, visRect
.x
+ visRect
.width
} ;
1638 textctrl
->MacWindowToRootWindow( &x
, &y
) ;
1639 OffsetRect( &visBounds
, x
, y
) ;
1641 if ( !EqualRect( &bounds
, &m_txnControlBounds
) || !EqualRect( &visBounds
, &m_txnVisBounds
) )
1643 m_txnControlBounds
= bounds
;
1644 m_txnVisBounds
= visBounds
;
1645 wxMacWindowClipper
cl( textctrl
) ;
1647 if ( m_sbHorizontal
|| m_sbVertical
)
1649 int w
= bounds
.right
- bounds
.left
;
1650 int h
= bounds
.bottom
- bounds
.top
;
1652 if ( m_sbHorizontal
)
1656 sbBounds
.left
= -1 ;
1657 sbBounds
.top
= h
- 14 ;
1658 sbBounds
.right
= w
+ 1 ;
1659 sbBounds
.bottom
= h
+ 1 ;
1661 SetControlBounds( m_sbHorizontal
, &sbBounds
) ;
1662 SetControlViewSize( m_sbHorizontal
, w
) ;
1669 sbBounds
.left
= w
- 14 ;
1671 sbBounds
.right
= w
+ 1 ;
1672 sbBounds
.bottom
= m_sbHorizontal
? h
- 14 : h
+ 1 ;
1674 SetControlBounds( m_sbVertical
, &sbBounds
) ;
1675 SetControlViewSize( m_sbVertical
, h
) ;
1680 TXNLongRect olddestRect
;
1681 TXNGetRectBounds( m_txn
, &oldviewRect
, &olddestRect
, NULL
) ;
1683 Rect viewRect
= { m_txnControlBounds
.top
, m_txnControlBounds
.left
,
1684 m_txnControlBounds
.bottom
- ( m_sbHorizontal
? 14 : 0 ) ,
1685 m_txnControlBounds
.right
- ( m_sbVertical
? 14 : 0 ) } ;
1686 TXNLongRect destRect
= { m_txnControlBounds
.top
, m_txnControlBounds
.left
,
1687 m_txnControlBounds
.bottom
- ( m_sbHorizontal
? 14 : 0 ) ,
1688 m_txnControlBounds
.right
- ( m_sbVertical
? 14 : 0 ) } ;
1690 if ( olddestRect
.right
>= 10000 )
1691 destRect
.right
= destRect
.left
+ 32000 ;
1693 if ( olddestRect
.bottom
>= 0x20000000 )
1694 destRect
.bottom
= destRect
.top
+ 0x40000000 ;
1696 SectRect( &viewRect
, &visBounds
, &viewRect
) ;
1697 TXNSetRectBounds( m_txn
, &viewRect
, &destRect
, true ) ;
1702 m_txnControlBounds
.top
,
1703 m_txnControlBounds
.left
,
1704 m_txnControlBounds
.bottom
- (m_sbHorizontal
? 14 : 0),
1705 m_txnControlBounds
.right
- (m_sbVertical
? 14 : 0),
1709 // the SetFrameBounds method under Classic sometimes does not correctly scroll a selection into sight after a
1710 // movement, therefore we have to force it
1712 // this problem has been reported in OSX as well, so we use this here once again
1714 TXNLongRect textRect
;
1715 TXNGetRectBounds( m_txn
, NULL
, NULL
, &textRect
) ;
1716 if ( textRect
.left
< m_txnControlBounds
.left
)
1717 TXNShowSelection( m_txn
, kTXNShowStart
) ;
1721 void wxMacMLTEClassicControl::Move(int x
, int y
, int width
, int height
)
1723 wxMacControl::Move(x
,y
,width
,height
) ;
1724 MacUpdatePosition() ;
1727 void wxMacMLTEClassicControl::MacControlUserPaneDrawProc(wxInt16
WXUNUSED(thePart
))
1729 wxTextCtrl
* textctrl
= (wxTextCtrl
*)GetControlReference( m_controlRef
);
1730 if ( textctrl
== NULL
)
1733 if ( textctrl
->IsShownOnScreen() )
1735 wxMacWindowClipper
clipper( textctrl
) ;
1736 TXNDraw( m_txn
, NULL
) ;
1740 wxInt16
wxMacMLTEClassicControl::MacControlUserPaneHitTestProc(wxInt16 x
, wxInt16 y
)
1742 Point where
= { y
, x
} ;
1743 ControlPartCode result
= kControlNoPart
;
1745 wxTextCtrl
* textctrl
= (wxTextCtrl
*) GetControlReference( m_controlRef
);
1746 if ( (textctrl
!= NULL
) && textctrl
->IsShownOnScreen() )
1748 if (PtInRect( where
, &m_txnControlBounds
))
1750 result
= kControlEditTextPart
;
1754 // sometimes we get the coords also in control local coordinates, therefore test again
1756 textctrl
->MacClientToRootWindow( &x
, &y
) ;
1760 if (PtInRect( where
, &m_txnControlBounds
))
1761 result
= kControlEditTextPart
;
1768 wxInt16
wxMacMLTEClassicControl::MacControlUserPaneTrackingProc( wxInt16 x
, wxInt16 y
, void* WXUNUSED(actionProc
) )
1770 ControlPartCode result
= kControlNoPart
;
1772 wxTextCtrl
* textctrl
= (wxTextCtrl
*) GetControlReference( m_controlRef
);
1773 if ( (textctrl
!= NULL
) && textctrl
->IsShownOnScreen() )
1775 Point startPt
= { y
, x
} ;
1777 // for compositing, we must convert these into toplevel window coordinates, because hittesting expects them
1779 textctrl
->MacClientToRootWindow( &x
, &y
) ;
1783 switch (MacControlUserPaneHitTestProc( startPt
.h
, startPt
.v
))
1785 case kControlEditTextPart
:
1787 wxMacWindowClipper
clipper( textctrl
) ;
1790 ConvertEventRefToEventRecord( (EventRef
) wxTheApp
->MacGetCurrentEvent() , &rec
) ;
1791 TXNClick( m_txn
, &rec
);
1803 void wxMacMLTEClassicControl::MacControlUserPaneIdleProc()
1805 wxTextCtrl
* textctrl
= (wxTextCtrl
*)GetControlReference( m_controlRef
);
1806 if ( textctrl
== NULL
)
1809 if (textctrl
->IsShownOnScreen())
1811 if (IsControlActive(m_controlRef
))
1815 wxMacWindowClipper
clipper( textctrl
) ;
1820 if (PtInRect(mousep
, &m_txnControlBounds
))
1822 RgnHandle theRgn
= NewRgn();
1823 RectRgn(theRgn
, &m_txnControlBounds
);
1824 TXNAdjustCursor(m_txn
, theRgn
);
1831 wxInt16
wxMacMLTEClassicControl::MacControlUserPaneKeyDownProc (wxInt16 keyCode
, wxInt16 charCode
, wxInt16 modifiers
)
1833 wxTextCtrl
* textctrl
= (wxTextCtrl
*)GetControlReference( m_controlRef
);
1834 if ( textctrl
== NULL
)
1835 return kControlNoPart
;
1837 wxMacWindowClipper
clipper( textctrl
) ;
1840 memset( &ev
, 0 , sizeof( ev
) ) ;
1842 ev
.modifiers
= modifiers
;
1843 ev
.message
= ((keyCode
<< 8) & keyCodeMask
) | (charCode
& charCodeMask
);
1844 TXNKeyDown( m_txn
, &ev
);
1846 return kControlEntireControl
;
1849 void wxMacMLTEClassicControl::MacControlUserPaneActivateProc(bool activating
)
1851 MacActivatePaneText( activating
);
1854 wxInt16
wxMacMLTEClassicControl::MacControlUserPaneFocusProc(wxInt16 action
)
1856 ControlPartCode focusResult
= kControlFocusNoPart
;
1858 wxTextCtrl
* textctrl
= (wxTextCtrl
*)GetControlReference( m_controlRef
);
1859 if ( textctrl
== NULL
)
1862 wxMacWindowClipper
clipper( textctrl
) ;
1864 ControlRef controlFocus
= NULL
;
1865 GetKeyboardFocus( m_txnWindow
, &controlFocus
) ;
1866 bool wasFocused
= ( controlFocus
== m_controlRef
) ;
1870 case kControlFocusPrevPart
:
1871 case kControlFocusNextPart
:
1872 MacFocusPaneText( !wasFocused
);
1873 focusResult
= (!wasFocused
? (ControlPartCode
) kControlEditTextPart
: (ControlPartCode
) kControlFocusNoPart
);
1876 case kControlFocusNoPart
:
1878 MacFocusPaneText( false );
1879 focusResult
= kControlFocusNoPart
;
1886 void wxMacMLTEClassicControl::MacControlUserPaneBackgroundProc( void *WXUNUSED(info
) )
1890 wxMacMLTEClassicControl::wxMacMLTEClassicControl( wxTextCtrl
*wxPeer
,
1891 const wxString
& str
,
1893 const wxSize
& size
, long style
)
1894 : wxMacMLTEControl( wxPeer
)
1896 m_font
= wxPeer
->GetFont() ;
1897 m_windowStyle
= style
;
1898 Rect bounds
= wxMacGetBoundsForControl( wxPeer
, pos
, size
) ;
1901 kControlSupportsEmbedding
| kControlSupportsFocus
| kControlWantsIdle
1902 | kControlWantsActivate
| kControlHandlesTracking
1903 // | kControlHasSpecialBackground
1904 | kControlGetsFocusOnClick
| kControlSupportsLiveFeedback
;
1906 OSStatus err
= ::CreateUserPaneControl(
1907 MAC_WXHWND(wxPeer
->GetParent()->MacGetTopLevelWindowRef()),
1908 &bounds
, featureSet
, &m_controlRef
);
1909 verify_noerr( err
);
1910 SetControlReference( m_controlRef
, (URefCon
) wxPeer
);
1914 AdjustCreationAttributes( *wxWHITE
, true ) ;
1916 MacSetObjectVisibility( wxPeer
->IsShownOnScreen() ) ;
1920 wxMacConvertNewlines10To13( &st
) ;
1921 wxMacWindowClipper
clipper( GetWXPeer() ) ;
1922 SetTXNData( st
, kTXNStartOffset
, kTXNEndOffset
) ;
1923 TXNSetSelection( m_txn
, 0, 0 ) ;
1927 wxMacMLTEClassicControl::~wxMacMLTEClassicControl()
1929 TXNDeleteObject( m_txn
);
1933 void wxMacMLTEClassicControl::VisibilityChanged(bool shown
)
1935 MacSetObjectVisibility( shown
) ;
1936 wxMacControl::VisibilityChanged( shown
) ;
1939 void wxMacMLTEClassicControl::SuperChangedPosition()
1941 MacUpdatePosition() ;
1942 wxMacControl::SuperChangedPosition() ;
1945 ControlUserPaneDrawUPP gTPDrawProc
= NULL
;
1946 ControlUserPaneHitTestUPP gTPHitProc
= NULL
;
1947 ControlUserPaneTrackingUPP gTPTrackProc
= NULL
;
1948 ControlUserPaneIdleUPP gTPIdleProc
= NULL
;
1949 ControlUserPaneKeyDownUPP gTPKeyProc
= NULL
;
1950 ControlUserPaneActivateUPP gTPActivateProc
= NULL
;
1951 ControlUserPaneFocusUPP gTPFocusProc
= NULL
;
1953 static pascal void wxMacControlUserPaneDrawProc(ControlRef control
, SInt16 part
)
1955 wxTextCtrl
*textCtrl
= wxDynamicCast( wxFindWindowFromWXWidget( (WXWidget
) control
) , wxTextCtrl
) ;
1956 wxMacMLTEClassicControl
* win
= textCtrl
? (wxMacMLTEClassicControl
*)(textCtrl
->GetPeer()) : NULL
;
1958 win
->MacControlUserPaneDrawProc( part
) ;
1961 static pascal ControlPartCode
wxMacControlUserPaneHitTestProc(ControlRef control
, Point where
)
1963 wxTextCtrl
*textCtrl
= wxDynamicCast( wxFindWindowFromWXWidget( (WXWidget
) control
) , wxTextCtrl
) ;
1964 wxMacMLTEClassicControl
* win
= textCtrl
? (wxMacMLTEClassicControl
*)(textCtrl
->GetPeer()) : NULL
;
1966 return win
->MacControlUserPaneHitTestProc( where
.h
, where
.v
) ;
1968 return kControlNoPart
;
1971 static pascal ControlPartCode
wxMacControlUserPaneTrackingProc(ControlRef control
, Point startPt
, ControlActionUPP actionProc
)
1973 wxTextCtrl
*textCtrl
= wxDynamicCast( wxFindWindowFromWXWidget( (WXWidget
) control
) , wxTextCtrl
) ;
1974 wxMacMLTEClassicControl
* win
= textCtrl
? (wxMacMLTEClassicControl
*)(textCtrl
->GetPeer()) : NULL
;
1976 return win
->MacControlUserPaneTrackingProc( startPt
.h
, startPt
.v
, (void*) actionProc
) ;
1978 return kControlNoPart
;
1981 static pascal void wxMacControlUserPaneIdleProc(ControlRef control
)
1983 wxTextCtrl
*textCtrl
= wxDynamicCast( wxFindWindowFromWXWidget((WXWidget
) control
) , wxTextCtrl
) ;
1984 wxMacMLTEClassicControl
* win
= textCtrl
? (wxMacMLTEClassicControl
*)(textCtrl
->GetPeer()) : NULL
;
1986 win
->MacControlUserPaneIdleProc() ;
1989 static pascal ControlPartCode
wxMacControlUserPaneKeyDownProc(ControlRef control
, SInt16 keyCode
, SInt16 charCode
, SInt16 modifiers
)
1991 wxTextCtrl
*textCtrl
= wxDynamicCast( wxFindWindowFromWXWidget((WXWidget
) control
) , wxTextCtrl
) ;
1992 wxMacMLTEClassicControl
* win
= textCtrl
? (wxMacMLTEClassicControl
*)(textCtrl
->GetPeer()) : NULL
;
1994 return win
->MacControlUserPaneKeyDownProc( keyCode
, charCode
, modifiers
) ;
1996 return kControlNoPart
;
1999 static pascal void wxMacControlUserPaneActivateProc(ControlRef control
, Boolean activating
)
2001 wxTextCtrl
*textCtrl
= wxDynamicCast( wxFindWindowFromWXWidget( (WXWidget
)control
) , wxTextCtrl
) ;
2002 wxMacMLTEClassicControl
* win
= textCtrl
? (wxMacMLTEClassicControl
*)(textCtrl
->GetPeer()) : NULL
;
2004 win
->MacControlUserPaneActivateProc( activating
) ;
2007 static pascal ControlPartCode
wxMacControlUserPaneFocusProc(ControlRef control
, ControlFocusPart action
)
2009 wxTextCtrl
*textCtrl
= wxDynamicCast( wxFindWindowFromWXWidget((WXWidget
) control
) , wxTextCtrl
) ;
2010 wxMacMLTEClassicControl
* win
= textCtrl
? (wxMacMLTEClassicControl
*)(textCtrl
->GetPeer()) : NULL
;
2012 return win
->MacControlUserPaneFocusProc( action
) ;
2014 return kControlNoPart
;
2018 static pascal void wxMacControlUserPaneBackgroundProc(ControlRef control
, ControlBackgroundPtr info
)
2020 wxTextCtrl
*textCtrl
= wxDynamicCast( wxFindWindowFromWXWidget(control
) , wxTextCtrl
) ;
2021 wxMacMLTEClassicControl
* win
= textCtrl
? (wxMacMLTEClassicControl
*)(textCtrl
->GetPeer()) : NULL
;
2023 win
->MacControlUserPaneBackgroundProc(info
) ;
2027 // TXNRegisterScrollInfoProc
2029 OSStatus
wxMacMLTEClassicControl::DoCreate()
2032 OSStatus err
= noErr
;
2034 // set up our globals
2035 if (gTPDrawProc
== NULL
) gTPDrawProc
= NewControlUserPaneDrawUPP(wxMacControlUserPaneDrawProc
);
2036 if (gTPHitProc
== NULL
) gTPHitProc
= NewControlUserPaneHitTestUPP(wxMacControlUserPaneHitTestProc
);
2037 if (gTPTrackProc
== NULL
) gTPTrackProc
= NewControlUserPaneTrackingUPP(wxMacControlUserPaneTrackingProc
);
2038 if (gTPIdleProc
== NULL
) gTPIdleProc
= NewControlUserPaneIdleUPP(wxMacControlUserPaneIdleProc
);
2039 if (gTPKeyProc
== NULL
) gTPKeyProc
= NewControlUserPaneKeyDownUPP(wxMacControlUserPaneKeyDownProc
);
2040 if (gTPActivateProc
== NULL
) gTPActivateProc
= NewControlUserPaneActivateUPP(wxMacControlUserPaneActivateProc
);
2041 if (gTPFocusProc
== NULL
) gTPFocusProc
= NewControlUserPaneFocusUPP(wxMacControlUserPaneFocusProc
);
2043 if (gTXNScrollInfoProc
== NULL
) gTXNScrollInfoProc
= NewTXNScrollInfoUPP(TXNScrollInfoProc
) ;
2044 if (gTXNScrollActionProc
== NULL
) gTXNScrollActionProc
= NewControlActionUPP(TXNScrollActionProc
) ;
2046 // set the initial settings for our private data
2048 m_txnWindow
= GetControlOwner(m_controlRef
);
2049 m_txnPort
= (GrafPtr
) GetWindowPort(m_txnWindow
);
2051 // set up the user pane procedures
2052 SetControlData(m_controlRef
, kControlEntireControl
, kControlUserPaneDrawProcTag
, sizeof(gTPDrawProc
), &gTPDrawProc
);
2053 SetControlData(m_controlRef
, kControlEntireControl
, kControlUserPaneHitTestProcTag
, sizeof(gTPHitProc
), &gTPHitProc
);
2054 SetControlData(m_controlRef
, kControlEntireControl
, kControlUserPaneTrackingProcTag
, sizeof(gTPTrackProc
), &gTPTrackProc
);
2055 SetControlData(m_controlRef
, kControlEntireControl
, kControlUserPaneIdleProcTag
, sizeof(gTPIdleProc
), &gTPIdleProc
);
2056 SetControlData(m_controlRef
, kControlEntireControl
, kControlUserPaneKeyDownProcTag
, sizeof(gTPKeyProc
), &gTPKeyProc
);
2057 SetControlData(m_controlRef
, kControlEntireControl
, kControlUserPaneActivateProcTag
, sizeof(gTPActivateProc
), &gTPActivateProc
);
2058 SetControlData(m_controlRef
, kControlEntireControl
, kControlUserPaneFocusProcTag
, sizeof(gTPFocusProc
), &gTPFocusProc
);
2060 // calculate the rectangles used by the control
2061 GetRectInWindowCoords( &bounds
);
2063 m_txnControlBounds
= bounds
;
2064 m_txnVisBounds
= bounds
;
2069 GetGWorld( &origPort
, &origDev
) ;
2070 SetPort( m_txnPort
);
2072 // create the new edit field
2073 TXNFrameOptions frameOptions
= FrameOptionsFromWXStyle( m_windowStyle
);
2075 // the scrollbars are not correctly embedded but are inserted at the root:
2076 // this gives us problems as we have erratic redraws even over the structure area
2078 m_sbHorizontal
= 0 ;
2080 m_lastHorizontalValue
= 0 ;
2081 m_lastVerticalValue
= 0 ;
2083 Rect sb
= { 0 , 0 , 0 , 0 } ;
2084 if ( frameOptions
& kTXNWantVScrollBarMask
)
2086 CreateScrollBarControl( m_txnWindow
, &sb
, 0, 0, 100, 1, true, gTXNScrollActionProc
, &m_sbVertical
);
2087 SetControlReference( m_sbVertical
, (SInt32
)this );
2088 SetControlAction( m_sbVertical
, gTXNScrollActionProc
);
2089 ShowControl( m_sbVertical
);
2090 EmbedControl( m_sbVertical
, m_controlRef
);
2091 frameOptions
&= ~kTXNWantVScrollBarMask
;
2094 if ( frameOptions
& kTXNWantHScrollBarMask
)
2096 CreateScrollBarControl( m_txnWindow
, &sb
, 0, 0, 100, 1, true, gTXNScrollActionProc
, &m_sbHorizontal
);
2097 SetControlReference( m_sbHorizontal
, (SInt32
)this );
2098 SetControlAction( m_sbHorizontal
, gTXNScrollActionProc
);
2099 ShowControl( m_sbHorizontal
);
2100 EmbedControl( m_sbHorizontal
, m_controlRef
);
2101 frameOptions
&= ~(kTXNWantHScrollBarMask
| kTXNDrawGrowIconMask
);
2105 NULL
, m_txnWindow
, &bounds
, frameOptions
,
2106 kTXNTextEditStyleFrameType
, kTXNTextensionFile
, kTXNSystemDefaultEncoding
,
2107 &m_txn
, &m_txnFrameID
, NULL
);
2108 verify_noerr( err
);
2111 TXNControlTag iControlTags
[] = { kTXNUseCarbonEvents
};
2112 TXNControlData iControlData
[] = { { (UInt32
)&cInfo
} };
2113 int toptag
= WXSIZEOF( iControlTags
) ;
2114 TXNCarbonEventInfo cInfo
;
2115 cInfo
.useCarbonEvents
= false ;
2118 cInfo
.fDictionary
= NULL
;
2120 verify_noerr( TXNSetTXNObjectControls( m_txn
, false, toptag
, iControlTags
, iControlData
) );
2123 TXNRegisterScrollInfoProc( m_txn
, gTXNScrollInfoProc
, (SInt32
)this );
2125 SetGWorld( origPort
, origDev
) ;
2131 // ----------------------------------------------------------------------------
2132 // MLTE control implementation (OSX part)
2133 // ----------------------------------------------------------------------------
2135 // tiger multi-line textcontrols with no CR in the entire content
2136 // don't scroll automatically, so we need a hack.
2137 // This attempt only works 'before' the key (ie before CallNextEventHandler)
2138 // is processed, thus the scrolling always occurs one character too late, but
2139 // better than nothing ...
2141 static const EventTypeSpec eventList
[] =
2143 { kEventClassTextInput
, kEventTextInputUnicodeForKeyEvent
} ,
2146 static pascal OSStatus
wxMacUnicodeTextEventHandler( EventHandlerCallRef handler
, EventRef event
, void *data
)
2148 OSStatus result
= eventNotHandledErr
;
2149 wxMacMLTEHIViewControl
* focus
= (wxMacMLTEHIViewControl
*) data
;
2151 switch ( GetEventKind( event
) )
2153 case kEventTextInputUnicodeForKeyEvent
:
2155 TXNOffset from
, to
;
2156 TXNGetSelection( focus
->GetTXNObject() , &from
, &to
) ;
2158 TXNShowSelection( focus
->GetTXNObject() , kTXNShowStart
);
2159 result
= CallNextEventHandler(handler
,event
);
2169 static pascal OSStatus
wxMacTextControlEventHandler( EventHandlerCallRef handler
, EventRef event
, void *data
)
2171 OSStatus result
= eventNotHandledErr
;
2173 switch ( GetEventClass( event
) )
2175 case kEventClassTextInput
:
2176 result
= wxMacUnicodeTextEventHandler( handler
, event
, data
) ;
2185 DEFINE_ONE_SHOT_HANDLER_GETTER( wxMacTextControlEventHandler
)
2187 wxMacMLTEHIViewControl::wxMacMLTEHIViewControl( wxTextCtrl
*wxPeer
,
2188 const wxString
& str
,
2190 const wxSize
& size
, long style
) : wxMacMLTEControl( wxPeer
)
2192 m_font
= wxPeer
->GetFont() ;
2193 m_windowStyle
= style
;
2194 Rect bounds
= wxMacGetBoundsForControl( wxPeer
, pos
, size
) ;
2196 wxMacConvertNewlines10To13( &st
) ;
2199 { bounds
.left
, bounds
.top
},
2200 { bounds
.right
- bounds
.left
, bounds
.bottom
- bounds
.top
} } ;
2202 m_scrollView
= NULL
;
2203 TXNFrameOptions frameOptions
= FrameOptionsFromWXStyle( style
) ;
2204 if (( frameOptions
& (kTXNWantVScrollBarMask
| kTXNWantHScrollBarMask
)) || (frameOptions
&kTXNSingleLineOnlyMask
))
2206 if ( frameOptions
& (kTXNWantVScrollBarMask
| kTXNWantHScrollBarMask
) )
2209 (frameOptions
& kTXNWantHScrollBarMask
? kHIScrollViewOptionsHorizScroll
: 0)
2210 | (frameOptions
& kTXNWantVScrollBarMask
? kHIScrollViewOptionsVertScroll
: 0) ,
2215 HIScrollViewCreate(kHIScrollViewOptionsVertScroll
,&m_scrollView
);
2216 HIScrollViewSetScrollBarAutoHide(m_scrollView
,true);
2219 HIViewSetFrame( m_scrollView
, &hr
);
2220 HIViewSetVisible( m_scrollView
, true );
2224 HITextViewCreate( NULL
, 0, frameOptions
, &m_textView
) ;
2225 m_txn
= HITextViewGetTXNObject( m_textView
) ;
2226 HIViewSetVisible( m_textView
, true ) ;
2229 HIViewAddSubview( m_scrollView
, m_textView
) ;
2230 m_controlRef
= m_scrollView
;
2231 InstallEventHandler( (WXWidget
) m_textView
) ;
2235 HIViewSetFrame( m_textView
, &hr
);
2236 m_controlRef
= m_textView
;
2239 AdjustCreationAttributes( *wxWHITE
, true ) ;
2241 wxMacWindowClipper
c( GetWXPeer() ) ;
2243 SetTXNData( st
, kTXNStartOffset
, kTXNEndOffset
) ;
2245 TXNSetSelection( m_txn
, 0, 0 );
2246 TXNShowSelection( m_txn
, kTXNShowStart
);
2248 ::InstallControlEventHandler( m_textView
, GetwxMacTextControlEventHandlerUPP(),
2249 GetEventTypeCount(eventList
), eventList
, this,
2253 wxMacMLTEHIViewControl::~wxMacMLTEHIViewControl()
2257 bool wxMacMLTEHIViewControl::SetFocus()
2259 return SetKeyboardFocus( GetControlOwner( m_textView
), m_textView
, kControlFocusNextPart
) == noErr
;
2262 bool wxMacMLTEHIViewControl::HasFocus() const
2264 ControlRef control
;
2265 if ( GetUserFocusWindow() == NULL
)
2268 GetKeyboardFocus( GetUserFocusWindow() , &control
) ;
2269 return control
== m_textView
;
2272 void wxMacMLTEHIViewControl::SetBackgroundColour(const wxColour
& col
)
2274 HITextViewSetBackgroundColor( m_textView
, col
.GetPixel() );
2277 #endif // wxUSE_TEXTCTRL