#include "wx/mac/private.h"
// ----------------------------------------------------------------------------
#include "wx/mac/private.h"
// ----------------------------------------------------------------------------
{ kEventClassWindow , kEventWindowBoundsChanged } ,
{ kEventClassWindow , kEventWindowClose } ,
{ kEventClassWindow , kEventWindowBoundsChanged } ,
{ kEventClassWindow , kEventWindowClose } ,
- // we have to catch these events on the toplevel window level, as controls don't get the
- // raw mouse events anymore
+ // we have to catch these events on the toplevel window level,
+ // as controls don't get the raw mouse events anymore
{ kEventClassMouse , kEventMouseDown } ,
{ kEventClassMouse , kEventMouseUp } ,
{ kEventClassMouse , kEventMouseDown } ,
{ kEventClassMouse , kEventMouseUp } ,
static pascal OSStatus TextInputEventHandler( EventHandlerCallRef handler , EventRef event , void *data )
{
OSStatus result = eventNotHandledErr ;
static pascal OSStatus TextInputEventHandler( EventHandlerCallRef handler , EventRef event , void *data )
{
OSStatus result = eventNotHandledErr ;
GetEventParameter( event, kEventParamTextInputSendKeyboardEvent, typeEventRef, NULL, sizeof(rawEvent), NULL, &rawEvent ) ;
GetEventParameter( event, kEventParamTextInputSendKeyboardEvent, typeEventRef, NULL, sizeof(rawEvent), NULL, &rawEvent ) ;
- GetEventParameter( rawEvent, kEventParamKeyMacCharCodes, typeChar, NULL,sizeof(char), NULL,&charCode );
+ GetEventParameter( rawEvent, kEventParamKeyMacCharCodes, typeChar, NULL, sizeof(char), NULL, &charCode );
GetEventParameter( rawEvent, kEventParamKeyCode, typeUInt32, NULL, sizeof(UInt32), NULL, &keyCode );
GetEventParameter( rawEvent, kEventParamKeyModifiers, typeUInt32, NULL, sizeof(UInt32), NULL, &modifiers );
GetEventParameter( rawEvent, kEventParamMouseLocation, typeQDPoint, NULL, sizeof(Point), NULL, &point );
GetEventParameter( rawEvent, kEventParamKeyCode, typeUInt32, NULL, sizeof(UInt32), NULL, &keyCode );
GetEventParameter( rawEvent, kEventParamKeyModifiers, typeUInt32, NULL, sizeof(UInt32), NULL, &modifiers );
GetEventParameter( rawEvent, kEventParamMouseLocation, typeQDPoint, NULL, sizeof(Point), NULL, &point );
- // this is only called when no default handler has jumped in, eg a wxControl on a floater window does not
- // get its own kEventTextInputUnicodeForKeyEvent, so we route back the
- wxControl* control = wxDynamicCast( focus , wxControl ) ;
- if ( control )
- ControlRef macControl = (ControlRef) control->GetHandle() ;
- if ( macControl )
+ // this is only called when no default handler has jumped in, e.g. a wxControl on a floater window does not
+ // get its own kEventTextInputUnicodeForKeyEvent, so we reroute the event back to the control
+ wxControl* control = wxDynamicCast( focus , wxControl ) ;
+ if ( control )
- ::HandleControlKey( macControl , keyCode , charCode , modifiers ) ;
- result = noErr ;
+ ControlRef macControl = (ControlRef) control->GetHandle() ;
+ if ( macControl )
+ {
+ ::HandleControlKey( macControl , keyCode , charCode , modifiers ) ;
+ result = noErr ;
+ }
- // this may lead to double events sent to a window in case all handlers have skipped the key down event
- UInt32 when = EventTimeToTicks( GetEventTime( event ) ) ;
- UInt32 message = (keyCode << 8) + charCode;
+ // this may lead to double events sent to a window in case all handlers have skipped the key down event
+ UInt32 when = EventTimeToTicks( GetEventTime( event ) ) ;
+ UInt32 message = (keyCode << 8) + charCode;
- if ( (focus != NULL) && wxTheApp->MacSendKeyDownEvent(
- focus , message , modifiers , when , point.h , point.v ) )
- {
- result = noErr ;
- }
+ if ( (focus != NULL) &&
+ wxTheApp->MacSendKeyDownEvent( focus , message , modifiers , when , point.h , point.v ) )
+ {
+ result = noErr ;
+ }
{
OSStatus result = eventNotHandledErr ;
// call DoFindFocus instead of FindFocus, because for Composite Windows(like WxGenericListCtrl)
{
OSStatus result = eventNotHandledErr ;
// call DoFindFocus instead of FindFocus, because for Composite Windows(like WxGenericListCtrl)
- if ( GetEventParameter( event, kEventParamKeyUnicodes, typeUnicodeText, NULL, 0 , &dataSize , NULL ) == noErr )
+ if ( GetEventParameter( event, kEventParamKeyUnicodes, typeUnicodeText, NULL, 0 , &dataSize, NULL ) == noErr )
if ( dataSize > 4 )
charBuf = new UniChar[ dataSize / sizeof( UniChar) ] ;
GetEventParameter( event, kEventParamKeyUnicodes, typeUnicodeText, NULL, dataSize , NULL , charBuf ) ;
if ( dataSize > 4 )
charBuf = new UniChar[ dataSize / sizeof( UniChar) ] ;
GetEventParameter( event, kEventParamKeyUnicodes, typeUnicodeText, NULL, dataSize , NULL , charBuf ) ;
#if SIZEOF_WCHAR_T == 2
uniChar = charBuf[0] ;
#else
wxMBConvUTF16 converter ;
converter.MB2WC( &uniChar , (const char*)charBuf , 1 ) ;
#endif
#if SIZEOF_WCHAR_T == 2
uniChar = charBuf[0] ;
#else
wxMBConvUTF16 converter ;
converter.MB2WC( &uniChar , (const char*)charBuf , 1 ) ;
#endif
- GetEventParameter( event, kEventParamKeyMacCharCodes, typeChar, NULL,sizeof(char), NULL,&charCode );
+ GetEventParameter( event, kEventParamKeyMacCharCodes, typeChar, NULL, sizeof(char), NULL, &charCode );
GetEventParameter( event, kEventParamKeyCode, typeUInt32, NULL, sizeof(UInt32), NULL, &keyCode );
GetEventParameter( event, kEventParamKeyModifiers, typeUInt32, NULL, sizeof(UInt32), NULL, &modifiers );
GetEventParameter( event, kEventParamMouseLocation, typeQDPoint, NULL, sizeof(Point), NULL, &point );
UInt32 message = (keyCode << 8) + charCode;
GetEventParameter( event, kEventParamKeyCode, typeUInt32, NULL, sizeof(UInt32), NULL, &keyCode );
GetEventParameter( event, kEventParamKeyModifiers, typeUInt32, NULL, sizeof(UInt32), NULL, &modifiers );
GetEventParameter( event, kEventParamMouseLocation, typeQDPoint, NULL, sizeof(Point), NULL, &point );
UInt32 message = (keyCode << 8) + charCode;
event.m_controlDown = modifiers & controlKey;
event.m_altDown = modifiers & optionKey;
event.m_metaDown = modifiers & cmdKey;
event.m_controlDown = modifiers & controlKey;
event.m_altDown = modifiers & optionKey;
event.m_metaDown = modifiers & cmdKey;
event.SetEventType( ( modifiers & cmdKey ) ? wxEVT_KEY_DOWN : wxEVT_KEY_UP ) ;
focus->GetEventHandler()->ProcessEvent( event ) ;
}
event.SetEventType( ( modifiers & cmdKey ) ? wxEVT_KEY_DOWN : wxEVT_KEY_UP ) ;
focus->GetEventHandler()->ProcessEvent( event ) ;
}
- cEvent.GetParameter<EventMouseButton>(kEventParamMouseButton, typeMouseButton , &button) ;
- cEvent.GetParameter<UInt32>(kEventParamClickCount, typeUInt32 , &clickCount ) ;
+ cEvent.GetParameter<EventMouseButton>( kEventParamMouseButton, typeMouseButton , &button ) ;
+ cEvent.GetParameter<UInt32>( kEventParamClickCount, typeUInt32 , &clickCount ) ;
- // determinate the correct down state, wx does not want a 'down' for a mouseUp event, while mac delivers
- // this button
+ // determine the correct down state, wx does not want a 'down' for a mouseUp event,
+ // while mac delivers this button
// EventMouseWheelAxis axis = cEvent.GetParameter<EventMouseWheelAxis>(kEventParamMouseWheelAxis, typeMouseWheelAxis) ;
SInt32 delta = cEvent.GetParameter<SInt32>(kEventParamMouseWheelDelta, typeLongInteger) ;
// EventMouseWheelAxis axis = cEvent.GetParameter<EventMouseWheelAxis>(kEventParamMouseWheelAxis, typeMouseWheelAxis) ;
SInt32 delta = cEvent.GetParameter<SInt32>(kEventParamMouseWheelDelta, typeLongInteger) ;
OSStatus err = CountSubControls( superControl , &childrenCount ) ;
if ( err == errControlIsNotEmbedder )
return NULL ;
OSStatus err = CountSubControls( superControl , &childrenCount ) ;
if ( err == errControlIsNotEmbedder )
return NULL ;
wxASSERT_MSG( err == noErr , wxT("Unexpected error when accessing subcontrols") ) ;
for ( UInt16 i = childrenCount ; i >=1 ; --i )
{
wxASSERT_MSG( err == noErr , wxT("Unexpected error when accessing subcontrols") ) ;
for ( UInt16 i = childrenCount ; i >=1 ; --i )
{
err = GetIndexedSubControl( superControl , i , & sibling ) ;
if ( err == errControlIsNotEmbedder )
return NULL ;
err = GetIndexedSubControl( superControl , i , & sibling ) ;
if ( err == errControlIsNotEmbedder )
return NULL ;
wxASSERT_MSG( err == noErr , wxT("Unexpected error when accessing subcontrols") ) ;
if ( IsControlVisible( sibling ) )
{
wxASSERT_MSG( err == noErr , wxT("Unexpected error when accessing subcontrols") ) ;
if ( IsControlVisible( sibling ) )
{
UMAGetControlBoundsInWindowCoords( sibling , &r ) ;
if ( MacPtInRect( location , &r ) )
{
ControlHandle child = wxMacFindSubControl( toplevelWindow , location , sibling , outPart ) ;
if ( child )
UMAGetControlBoundsInWindowCoords( sibling , &r ) ;
if ( MacPtInRect( location , &r ) )
{
ControlHandle child = wxMacFindSubControl( toplevelWindow , location , sibling , outPart ) ;
if ( child )
if ( UMAGetSystemVersion() >= 0x1030 && ( toplevelWindow == 0 || toplevelWindow->MacUsesCompositing() ) )
return FindControlUnderMouse( location , window , outPart ) ;
#endif
if ( UMAGetSystemVersion() >= 0x1030 && ( toplevelWindow == 0 || toplevelWindow->MacUsesCompositing() ) )
return FindControlUnderMouse( location , window , outPart ) ;
#endif
ControlRef rootControl = NULL ;
verify_noerr( GetRootControl( window , &rootControl ) ) ;
ControlRef rootControl = NULL ;
verify_noerr( GetRootControl( window , &rootControl ) ) ;
control = wxMacFindControlUnderMouse( toplevelWindow , windowMouseLocation , window , &part ) ;
// if there is no control below the mouse position, send the event to the toplevel window itself
if ( control == 0 )
control = wxMacFindControlUnderMouse( toplevelWindow , windowMouseLocation , window , &part ) ;
// if there is no control below the mouse position, send the event to the toplevel window itself
if ( control == 0 )
g_MacLastWindow->ScreenToClient( &eventleave.m_x, &eventleave.m_y );
eventleave.SetEventObject( g_MacLastWindow ) ;
wxevent.SetId( g_MacLastWindow->GetId() ) ;
g_MacLastWindow->ScreenToClient( &eventleave.m_x, &eventleave.m_y );
eventleave.SetEventObject( g_MacLastWindow ) ;
wxevent.SetId( g_MacLastWindow->GetId() ) ;
currentMouseWindow->ScreenToClient( &evententer.m_x, &evententer.m_y );
evententer.SetEventObject( currentMouseWindow ) ;
wxevent.SetId( currentMouseWindow->GetId() ) ;
currentMouseWindow->ScreenToClient( &evententer.m_x, &evententer.m_y );
evententer.SetEventObject( currentMouseWindow ) ;
wxevent.SetId( currentMouseWindow->GetId() ) ;
if ( wxevent.GetEventType() == wxEVT_MOTION
|| wxevent.GetEventType() == wxEVT_ENTER_WINDOW
|| wxevent.GetEventType() == wxEVT_LEAVE_WINDOW )
if ( wxevent.GetEventType() == wxEVT_MOTION
|| wxevent.GetEventType() == wxEVT_ENTER_WINDOW
|| wxevent.GetEventType() == wxEVT_LEAVE_WINDOW )
if ( currentMouseWindow->GetEventHandler()->ProcessEvent(wxevent) )
{
if ((currentMouseWindowParent != NULL) &&
if ( currentMouseWindow->GetEventHandler()->ProcessEvent(wxevent) )
{
if ((currentMouseWindowParent != NULL) &&
if ((currentMouseWindowParent != NULL) &&
(currentMouseWindowParent->GetChildren().Find(currentMouseWindow) == NULL))
if ((currentMouseWindowParent != NULL) &&
(currentMouseWindowParent->GetChildren().Find(currentMouseWindow) == NULL))
- wxMacPortStateHelper help( (GrafPtr) GetWindowPort( (WindowRef) m_macWindow) ) ;
- wxMacWindowClipper clip (this);
+ wxMacPortStateHelper help( (GrafPtr)GetWindowPort( (WindowRef)m_macWindow) ) ;
+ wxMacWindowClipper clip( this );
GetWindowBounds((WindowRef)m_macWindow, kWindowGlobalPortRgn, &rect);
SetWindowIdealUserState((WindowRef)m_macWindow, &rect);
SetWindowUserState((WindowRef)m_macWindow, &rect);
GetWindowBounds((WindowRef)m_macWindow, kWindowGlobalPortRgn, &rect);
SetWindowIdealUserState((WindowRef)m_macWindow, &rect);
SetWindowUserState((WindowRef)m_macWindow, &rect);
GetEventTypeCount(eventList), eventList, this, (EventHandlerRef *)&m_macEventHandler );
}
GetEventTypeCount(eventList), eventList, this, (EventHandlerRef *)&m_macEventHandler );
}
SetWindowBounds( (WindowRef) m_macWindow , kWindowStructureRgn , &theBoundsRect ) ;
wxAssociateWinWithMacWindow( (WindowRef) m_macWindow , this ) ;
UMASetWTitle( (WindowRef) m_macWindow , title , m_font.GetEncoding() ) ;
m_peer = new wxMacControl(this , true /*isRootControl*/) ;
SetWindowBounds( (WindowRef) m_macWindow , kWindowStructureRgn , &theBoundsRect ) ;
wxAssociateWinWithMacWindow( (WindowRef) m_macWindow , this ) ;
UMASetWTitle( (WindowRef) m_macWindow , title , m_font.GetEncoding() ) ;
m_peer = new wxMacControl(this , true /*isRootControl*/) ;
if ( m_macUsesCompositing )
{
// There is a bug in 10.2.X for ::GetRootControl returning the window view instead of
if ( m_macUsesCompositing )
{
// There is a bug in 10.2.X for ::GetRootControl returning the window view instead of
+ bool plainTransition = false;
+
+#if wxUSE_SYSTEM_OPTIONS
+ // code contributed by Ryan Wilcox December 18, 2003
+ plainTransition = UMAGetSystemVersion() >= 0x1000 ;
+ if ( wxSystemOptions::HasOption(wxMAC_WINDOW_PLAIN_TRANSITION) )
+ plainTransition = ( wxSystemOptions::GetOptionInt( wxMAC_WINDOW_PLAIN_TRANSITION ) == 1 ) ;
+#endif
+
-#if wxUSE_SYSTEM_OPTIONS // code contributed by Ryan Wilcox December 18, 2003
- bool plainTransition = UMAGetSystemVersion() >= 0x1000 ;
- if ( wxSystemOptions::HasOption(wxMAC_WINDOW_PLAIN_TRANSITION) )
- plainTransition = ( wxSystemOptions::GetOptionInt( wxMAC_WINDOW_PLAIN_TRANSITION ) == 1 ) ;
-
::TransitionWindow( (WindowRef)m_macWindow, kWindowZoomTransitionEffect, kWindowShowTransitionAction, NULL );
::TransitionWindow( (WindowRef)m_macWindow, kWindowZoomTransitionEffect, kWindowShowTransitionAction, NULL );
::SelectWindow( (WindowRef)m_macWindow ) ;
// because apps expect a size event to occur at this moment
::SelectWindow( (WindowRef)m_macWindow ) ;
// because apps expect a size event to occur at this moment
-#if wxUSE_SYSTEM_OPTIONS
- bool plainTransition = UMAGetSystemVersion() >= 0x1000 ;
- if ( wxSystemOptions::HasOption(wxMAC_WINDOW_PLAIN_TRANSITION) )
- plainTransition = ( wxSystemOptions::GetOptionInt( wxMAC_WINDOW_PLAIN_TRANSITION ) == 1 ) ;
-#endif
- {
- ::TransitionWindow((WindowRef)m_macWindow, kWindowZoomTransitionEffect, kWindowHideTransitionAction, NULL );
- }
+ ::TransitionWindow( (WindowRef)m_macWindow, kWindowZoomTransitionEffect, kWindowHideTransitionAction, NULL );
m_macFullScreenData = data ;
data->m_position = GetPosition() ;
data->m_size = GetSize() ;
m_macFullScreenData = data ;
data->m_position = GetPosition() ;
data->m_size = GetSize() ;
}
SetSize( x , y , w, h ) ;
}
SetSize( x , y , w, h ) ;
void wxTopLevelWindowMac::MacGetContentAreaInset( int &left , int &top , int &right , int &bottom )
{
void wxTopLevelWindowMac::MacGetContentAreaInset( int &left , int &top , int &right , int &bottom )
{
GetWindowBounds( (WindowRef) m_macWindow, kWindowStructureRgn , &structure ) ;
GetWindowBounds( (WindowRef) m_macWindow, kWindowContentRgn , &content ) ;
GetWindowBounds( (WindowRef) m_macWindow, kWindowStructureRgn , &structure ) ;
GetWindowBounds( (WindowRef) m_macWindow, kWindowContentRgn , &content ) ;
void wxTopLevelWindowMac::RequestUserAttention(int flags )
{
NMRecPtr notificationRequest = (NMRecPtr) NewPtr( sizeof( NMRec) ) ;
void wxTopLevelWindowMac::RequestUserAttention(int flags )
{
NMRecPtr notificationRequest = (NMRecPtr) NewPtr( sizeof( NMRec) ) ;
wxCHECK_MSG( HasFlag(wxFRAME_SHAPED), false,
_T("Shaped windows must be created with the wxFRAME_SHAPED style."));
wxCHECK_MSG( HasFlag(wxFRAME_SHAPED), false,
_T("Shaped windows must be created with the wxFRAME_SHAPED style."));
static void wxShapedMacWindowGetPos(WindowRef window, Rect* inRect)
{
GetWindowPortBounds(window, inRect);
static void wxShapedMacWindowGetPos(WindowRef window, Rect* inRect)
{
GetWindowPortBounds(window, inRect);
- Point pt = {inRect->left, inRect->top};
- QDLocalToGlobalPoint( GetWindowPort(window) , &pt ) ;
+ Point pt = { inRect->left, inRect->top };
+
+ QDLocalToGlobalPoint( GetWindowPort(window), &pt ) ;