#include "wx/spinctrl.h"
#include "wx/log.h"
#include "wx/geometry.h"
+#include "wx/textctrl.h"
#include "wx/toolbar.h"
#include "wx/dc.h"
#ifndef __DARWIN__
#include <Windows.h>
#include <ToolUtils.h>
+#include <Scrap.h>
+#include <MacTextEditor.h>
#endif
#if TARGET_API_MAC_OSX
{ kEventClassControl , kEventControlEnabledStateChanged } ,
{ kEventClassControl , kEventControlHiliteChanged } ,
{ kEventClassControl , kEventControlSetFocusPart } ,
-// { kEventClassControl , kEventControlInvalidateForSizeChange } , // 10.3 only
+
+ { kEventClassService , kEventServiceGetTypes },
+ { kEventClassService , kEventServiceCopy },
+ { kEventClassService , kEventServicePaste },
+
+ // { kEventClassControl , kEventControlInvalidateForSizeChange } , // 10.3 only
// { kEventClassControl , kEventControlBoundsChanged } ,
#endif
} ;
wxFocusEvent event(wxEVT_KILL_FOCUS, thisWindow->GetId());
event.SetEventObject(thisWindow);
thisWindow->GetEventHandler()->ProcessEvent(event) ;
+ if (thisWindow->MacIsUserPane())
+ result = noErr;
}
else
{
wxFocusEvent event(wxEVT_SET_FOCUS, thisWindow->GetId());
event.SetEventObject(thisWindow);
thisWindow->GetEventHandler()->ProcessEvent(event) ;
+ if (thisWindow->MacIsUserPane())
+ result = noErr;
}
}
break ;
return result ;
}
+static pascal OSStatus wxMacWindowServiceEventHandler( EventHandlerCallRef handler , EventRef event , void *data )
+{
+ OSStatus result = eventNotHandledErr ;
+
+ wxMacCarbonEvent cEvent( event ) ;
+
+ ControlRef controlRef ;
+ wxWindowMac* thisWindow = (wxWindowMac*) data ;
+ wxTextCtrl* textCtrl = wxDynamicCast( thisWindow , wxTextCtrl ) ;
+ cEvent.GetParameter( kEventParamDirectObject , &controlRef ) ;
+
+ switch( GetEventKind( event ) )
+ {
+ case kEventServiceGetTypes :
+ if( textCtrl )
+ {
+ long from, to ;
+ textCtrl->GetSelection( &from , &to ) ;
+
+ CFMutableArrayRef copyTypes = 0 , pasteTypes = 0;
+ if( from != to )
+ copyTypes = cEvent.GetParameter< CFMutableArrayRef >( kEventParamServiceCopyTypes , typeCFMutableArrayRef ) ;
+ if ( textCtrl->IsEditable() )
+ pasteTypes = cEvent.GetParameter< CFMutableArrayRef >( kEventParamServicePasteTypes , typeCFMutableArrayRef ) ;
+
+ static const OSType textDataTypes[] = { kTXNTextData /* , 'utxt' , 'PICT', 'MooV', 'AIFF' */ };
+ for ( size_t i = 0 ; i < WXSIZEOF(textDataTypes) ; ++i )
+ {
+ CFStringRef typestring = CreateTypeStringWithOSType(textDataTypes[i]);
+ if ( typestring )
+ {
+ if ( copyTypes )
+ CFArrayAppendValue (copyTypes, typestring) ;
+ if ( pasteTypes )
+ CFArrayAppendValue (pasteTypes, typestring) ;
+ CFRelease( typestring ) ;
+ }
+ }
+ result = noErr ;
+ }
+ break ;
+ case kEventServiceCopy :
+ if ( textCtrl )
+ {
+ long from, to ;
+ textCtrl->GetSelection( &from , &to ) ;
+ wxString val = textCtrl->GetValue() ;
+ val = val.Mid( from , to - from ) ;
+ ScrapRef scrapRef = cEvent.GetParameter< ScrapRef > ( kEventParamScrapRef , typeScrapRef ) ;
+ verify_noerr( ClearScrap( &scrapRef ) ) ;
+ verify_noerr( PutScrapFlavor( scrapRef , kTXNTextData , 0 , val.Length() , val.c_str() ) ) ;
+ result = noErr ;
+ }
+ break ;
+ case kEventServicePaste :
+ if ( textCtrl )
+ {
+ ScrapRef scrapRef = cEvent.GetParameter< ScrapRef > ( kEventParamScrapRef , typeScrapRef ) ;
+ Size textSize, pastedSize ;
+ verify_noerr( GetScrapFlavorSize (scrapRef, kTXNTextData, &textSize) ) ;
+ textSize++ ;
+ char *content = new char[textSize] ;
+ GetScrapFlavorData (scrapRef, kTXNTextData, &pastedSize, content );
+ content[textSize-1] = 0 ;
+#if wxUSE_UNICODE
+ textCtrl->WriteText( wxString( content , wxConvLocal ) );
+#else
+ textCtrl->WriteText( wxString( content ) ) ;
+#endif
+ delete[] content ;
+ result = noErr ;
+ }
+ break ;
+ }
+
+ return result ;
+}
+
pascal OSStatus wxMacWindowEventHandler( EventHandlerCallRef handler , EventRef event , void *data )
{
OSStatus result = eventNotHandledErr ;
case kEventClassControl :
result = wxMacWindowControlEventHandler( handler, event, data ) ;
break ;
+ case kEventClassService :
+ result = wxMacWindowServiceEventHandler( handler, event , data ) ;
default :
break ;
}
wxSize new_size = size ;
if (!m_macIsUserPane)
- {
- wxSize best_size( DoGetBestSize() );
-
- if (size.x == -1) {
- new_size.x = best_size.x;
- }
- if (size.y == -1) {
- new_size.y = best_size.y;
- }
- SetSize( pos.x, pos.y , new_size.x, new_size.y,wxSIZE_USE_EXISTING );
+ {
+ SetInitialBestSize(size);
}
SetCursor( *wxSTANDARD_CURSOR ) ;
return FALSE;
bool former = MacIsReallyEnabled() ;
+#if TARGET_API_MAC_OSX
if ( enable )
EnableControl( (ControlRef) m_macControl ) ;
else
DisableControl( (ControlRef) m_macControl ) ;
+#else
+ if ( enable )
+ ActivateControl( (ControlRef) m_macControl ) ;
+ else
+ DeactivateControl( (ControlRef) m_macControl ) ;
+#endif
if ( former != MacIsReallyEnabled() )
MacPropagateEnabledStateChanged() ;
bool wxWindowMac::MacIsReallyEnabled()
{
+#if TARGET_API_MAC_OSX
return IsControlEnabled( (ControlRef) m_macControl ) ;
+#else
+ return IsControlActive( (ControlRef) m_macControl ) ;
+#endif
}
bool wxWindowMac::MacIsReallyHilited()