+ wxMacFunctor* f = (wxMacFunctor*) param ;
+ void *result = (*f)() ;
+ return result ;
+ }
+} ;
+
+template<typename classtype,typename param1type>
+class wxMacObjectFunctor1 : public wxMacFunctor
+{
+ typedef void (classtype::*function)( param1type p1 ) ;
+ typedef void (classtype::*ref_function)( const param1type& p1 ) ;
+public :
+ wxMacObjectFunctor1( classtype *obj , function f , param1type p1 ) :
+ wxMacFunctor( )
+ {
+ m_object = obj ;
+ m_function = f ;
+ m_param1 = p1 ;
+ }
+
+ wxMacObjectFunctor1( classtype *obj , ref_function f , param1type p1 ) :
+ wxMacFunctor( )
+ {
+ m_object = obj ;
+ m_refFunction = f ;
+ m_param1 = p1 ;
+ }
+
+ ~wxMacObjectFunctor1() {}
+
+ virtual void* operator()()
+ {
+ (m_object->*m_function)(m_param1) ;
+ return NULL ;
+ }
+private :
+ classtype* m_object ;
+ param1type m_param1 ;
+ union
+ {
+ function m_function ;
+ ref_function m_refFunction ;
+ } ;
+} ;
+
+template<typename classtype, typename param1type>
+void* wxMacMPRemoteCall( classtype *object , void (classtype::*function)( param1type p1 ) , param1type p1 )
+{
+ wxMacObjectFunctor1<classtype,param1type> params(object,function,p1) ;
+ void *result =
+ MPRemoteCall( wxMacFunctor::CallBackProc , ¶ms , kMPOwningProcessRemoteContext ) ;
+ return result ;
+}
+
+template<typename classtype, typename param1type>
+void* wxMacMPRemoteCall( classtype *object , void (classtype::*function)( const param1type& p1 ) , param1type p1 )
+{
+ wxMacObjectFunctor1<classtype,param1type> params(object,function,p1) ;
+ void *result =
+ MPRemoteCall( wxMacFunctor::CallBackProc , ¶ms , kMPOwningProcessRemoteContext ) ;
+ return result ;
+}
+
+template<typename classtype, typename param1type>
+void* wxMacMPRemoteGUICall( classtype *object , void (classtype::*function)( param1type p1 ) , param1type p1 )
+{
+ wxMutexGuiLeave() ;
+ void *result = wxMacMPRemoteCall( object , function , p1 ) ;
+ wxMutexGuiEnter() ;
+ return result ;
+}
+
+template<typename classtype, typename param1type>
+void* wxMacMPRemoteGUICall( classtype *object , void (classtype::*function)( const param1type& p1 ) , param1type p1 )
+{
+ wxMutexGuiLeave() ;
+ void *result = wxMacMPRemoteCall( object , function , p1 ) ;
+ wxMutexGuiEnter() ;
+ return result ;
+}
+
+void wxTextCtrl::WriteText(const wxString& str)
+{
+ if ( !wxIsMainThread() )
+ {
+ // unfortunately CW 8 is not able to correctly deduce the template types, so we have
+ // to instantiate explicitely
+ wxMacMPRemoteGUICall<wxTextCtrl,wxString>( this , &wxTextCtrl::WriteText , str ) ;
+ return ;
+ }
+ else
+ {
+ wxString st = str ;
+ wxMacConvertNewlines13To10( &st ) ;
+ #if wxMAC_USE_MLTE
+ bool formerEditable = m_editable ;
+ if ( !formerEditable )
+ SetEditable(true) ;
+ {
+ wxMacWindowStateSaver s( this ) ;
+ long start , end , dummy ;
+ GetSelection( &start , &dummy ) ;
+ SetTXNData( (STPTextPaneVars *)m_macTXNvars , (TXNObject) m_macTXN , st , kTXNUseCurrentSelection, kTXNUseCurrentSelection ) ;
+ GetSelection( &dummy , &end ) ;
+ SetStyle( start , end , GetDefaultStyle() ) ;
+ }
+ if ( !formerEditable )
+ SetEditable( formerEditable ) ;
+
+ MacRedrawControl() ;
+ #else
+ #if MAC_OS_X_VERSION_MAX_ALLOWED > MAC_OS_X_VERSION_10_2
+ wxMacCFStringHolder cf(st , m_font.GetEncoding() ) ;
+ CFStringRef value = cf ;
+ SetControlData( (ControlRef) m_macControl , 0, kControlEditTextInsertCFStringRefTag,
+ sizeof(CFStringRef), &value );
+ #else
+ wxString val = GetValue() ;
+ long start , end ;
+ GetSelection( &start , &end ) ;
+ val.Remove( start , end - start ) ;
+ val.insert( start , str ) ;
+ SetValue( val ) ;
+ SetInsertionPoint( start + str.Length() ) ;
+ #endif
+ #endif
+ }