wxWindow* g_MacLastWindow = NULL ;
+static EventMouseButton lastButton = 0 ;
+
static void SetupMouseEvent( wxMouseEvent &wxevent , wxMacCarbonEvent &cEvent )
{
UInt32 modifiers = cEvent.GetParameter<UInt32>(kEventParamKeyModifiers, typeUInt32) ;
{
button = kEventMouseButtonSecondary ;
}
+
+ // we must make sure that our synthetic 'right' button corresponds in
+ // mouse down, moved and mouse up, and does not deliver a right down and left up
+
+ if ( cEvent.GetKind() == kEventMouseDown )
+ lastButton = button ;
+
+ if ( button == 0 )
+ lastButton = 0 ;
+ else if ( lastButton )
+ button = lastButton ;
// determinate the correct down state, wx does not want a 'down' for a mouseUp event, while mac delivers
// this button
break ;
}
}
- // determinate the correct click button
- if ( button == kEventMouseButtonSecondary )
- {
- if (cEvent.GetKind() == kEventMouseDown )
- wxevent.SetEventType( clickCount > 1 ? wxEVT_RIGHT_DCLICK : wxEVT_RIGHT_DOWN ) ;
- else if ( cEvent.GetKind() == kEventMouseUp )
- wxevent.SetEventType(wxEVT_RIGHT_UP ) ;
- }
- else if ( button == kEventMouseButtonTertiary )
+ // translate into wx types
+ switch ( cEvent.GetKind() )
{
- if (cEvent.GetKind() == kEventMouseDown )
- wxevent.SetEventType(clickCount > 1 ? wxEVT_MIDDLE_DCLICK : wxEVT_MIDDLE_DOWN ) ;
- else if ( cEvent.GetKind() == kEventMouseUp )
- wxevent.SetEventType(wxEVT_MIDDLE_UP ) ;
- }
- else
- {
- if (cEvent.GetKind() == kEventMouseDown )
- wxevent.SetEventType(clickCount > 1 ? wxEVT_LEFT_DCLICK : wxEVT_LEFT_DOWN ) ;
- else if ( cEvent.GetKind() == kEventMouseUp )
- wxevent.SetEventType(wxEVT_LEFT_UP ) ;
- else if ( cEvent.GetKind() == kEventMouseWheelMoved )
- {
+ case kEventMouseDown :
+ switch( button )
+ {
+ case kEventMouseButtonPrimary :
+ wxevent.SetEventType(clickCount > 1 ? wxEVT_LEFT_DCLICK : wxEVT_LEFT_DOWN ) ;
+ break ;
+ case kEventMouseButtonSecondary :
+ wxevent.SetEventType( clickCount > 1 ? wxEVT_RIGHT_DCLICK : wxEVT_RIGHT_DOWN ) ;
+ break ;
+ case kEventMouseButtonTertiary :
+ wxevent.SetEventType(clickCount > 1 ? wxEVT_MIDDLE_DCLICK : wxEVT_MIDDLE_DOWN ) ;
+ break ;
+ }
+ break ;
+ case kEventMouseUp :
+ switch( button )
+ {
+ case kEventMouseButtonPrimary :
+ wxevent.SetEventType( wxEVT_LEFT_UP ) ;
+ break ;
+ case kEventMouseButtonSecondary :
+ wxevent.SetEventType( wxEVT_RIGHT_UP ) ;
+ break ;
+ case kEventMouseButtonTertiary :
+ wxevent.SetEventType( wxEVT_MIDDLE_UP ) ;
+ break ;
+ }
+ break ;
+ case kEventMouseWheelMoved :
+ {
wxevent.SetEventType(wxEVT_MOUSEWHEEL ) ;
// EventMouseWheelAxis axis = cEvent.GetParameter<EventMouseWheelAxis>(kEventParamMouseWheelAxis, typeMouseWheelAxis) ;
wxevent.m_wheelRotation = delta;
wxevent.m_wheelDelta = 1;
wxevent.m_linesPerAction = 1;
- }
- else
+ break ;
+ }
+ default :
wxevent.SetEventType(wxEVT_MOTION ) ;
- }
+ break ;
+ }
}
ControlRef wxMacFindSubControl( Point location , ControlRef superControl , ControlPartCode *outPart )
short windowPart = ::FindWindow(screenMouseLocation, &window);
wxWindow* currentMouseWindow = NULL ;
-
+ ControlRef control = NULL ;
+
if ( window )
{
QDGlobalToLocalPoint( UMAGetWindowPort(window ) , &windowMouseLocation ) ;
else if ( (IsWindowActive(window) && windowPart == inContent) )
{
ControlPartCode part ;
- ControlRef control = wxMacFindControlUnderMouse( windowMouseLocation , window , &part ) ;
+ control = wxMacFindControlUnderMouse( windowMouseLocation , window , &part ) ;
+ // if there is no control below the mouse position, send the event to the toplevel window itself
if ( control == 0 )
currentMouseWindow = (wxWindow*) data ;
else
+ {
currentMouseWindow = wxFindControlFromMacControl( control ) ;
+ if ( currentMouseWindow == NULL && cEvent.GetKind() == kEventMouseMoved )
+ {
+ // for wxToolBar to function we have to send certaint events to it
+ // instead of its children (wxToolBarTools)
+ ControlRef parent ;
+ GetSuperControl(control, &parent );
+ wxWindow *wxParent = wxFindControlFromMacControl( parent ) ;
+ if ( wxParent && wxParent->IsKindOf( CLASSINFO( wxToolBar ) ) )
+ currentMouseWindow = wxParent ;
+ }
+ }
}
}
-
+
wxMouseEvent wxevent(wxEVT_LEFT_DOWN);
SetupMouseEvent( wxevent , cEvent ) ;
(FindControlUnderMouse(windowMouseLocation , window , &dummyPart) !=
wxMacFindControlUnderMouse( windowMouseLocation , window , &dummyPart ) ) )
{
- EventModifiers modifiers = cEvent.GetParameter<EventModifiers>(kEventParamKeyModifiers, typeUInt32) ;
- Point clickLocation = windowMouseLocation ;
-#if TARGET_API_MAC_OSX
- currentMouseWindow->MacRootWindowToWindow( &clickLocation.h , &clickLocation.v ) ;
-#endif
- HandleControlClick( (ControlRef) currentMouseWindow->GetHandle() , clickLocation ,
- modifiers , (ControlActionUPP ) -1 ) ;
+ if ( currentMouseWindow->MacIsReallyEnabled() )
+ {
+ EventModifiers modifiers = cEvent.GetParameter<EventModifiers>(kEventParamKeyModifiers, typeUInt32) ;
+ Point clickLocation = windowMouseLocation ;
+ #if TARGET_API_MAC_OSX
+ currentMouseWindow->MacRootWindowToWindow( &clickLocation.h , &clickLocation.v ) ;
+ #endif
+ HandleControlClick( (ControlRef) currentMouseWindow->GetHandle() , clickLocation ,
+ modifiers , (ControlActionUPP ) -1 ) ;
+ }
result = noErr ;
}
}
// update cursor ?
}
} // else if ( currentMouseWindow )
+ else
+ {
+ // don't mess with controls we don't know about
+ // for some reason returning eventNotHandledErr does not lead to the correct behaviour
+ // so we try sending them the correct control directly
+ wxTopLevelWindowMac* toplevelWindow = (wxTopLevelWindowMac*) data ;
+ if ( cEvent.GetKind() == kEventMouseDown && toplevelWindow && control )
+ {
+ EventModifiers modifiers = cEvent.GetParameter<EventModifiers>(kEventParamKeyModifiers, typeUInt32) ;
+ Point clickLocation = windowMouseLocation ;
+#if TARGET_API_MAC_OSX
+ HIPoint hiPoint ;
+ hiPoint.x = clickLocation.h ;
+ hiPoint.y = clickLocation.v ;
+ HIViewConvertPoint( &hiPoint , (ControlRef) toplevelWindow->GetHandle() , control ) ;
+ clickLocation.h = (int)hiPoint.x ;
+ clickLocation.v = (int)hiPoint.y ;
+#endif
+ HandleControlClick( control , clickLocation ,
+ modifiers , (ControlActionUPP ) -1 ) ;
+ result = noErr ;
+ }
+ }
return result ;
}
adjustR.SetWidth( toplevelWindow->GetMinWidth() ) ;
if ( toplevelWindow->GetMinHeight() != -1 && adjustR.GetHeight() < toplevelWindow->GetMinHeight() )
adjustR.SetHeight( toplevelWindow->GetMinHeight() ) ;
- Rect adjustedRect = { adjustR.y + top , adjustR.x + left , adjustR.y + adjustR.height - bottom , adjustR.x + adjustR.width - right } ;
+ const Rect adjustedRect = { adjustR.y + top , adjustR.x + left , adjustR.y + adjustR.height - bottom , adjustR.x + adjustR.width - right } ;
if ( !EqualRect( &newRect , &adjustedRect ) )
- cEvent.SetParameter( kEventParamCurrentBounds , &adjustedRect ) ;
+ cEvent.SetParameter<Rect>( kEventParamCurrentBounds , &adjustedRect ) ;
}
result = noErr ;
wxTopLevelWindowMac *wxTopLevelWindowMac::s_macDeactivateWindow = NULL;
+typedef struct
+{
+ wxPoint m_position ;
+ wxSize m_size ;
+} FullScreenData ;
+
void wxTopLevelWindowMac::Init()
{
m_iconized =
m_macUsesCompositing = FALSE;
#endif
m_macEventHandler = NULL ;
+ m_macFullScreenData = NULL ;
}
class wxMacDeferredWindowDeleter : public wxObject
SetName(name);
m_windowId = id == -1 ? NewControlId() : id;
+ wxWindow::SetTitle( title ) ;
MacCreateRealWindow( title, pos , size , MacRemoveBordersFromStyle(style) , name ) ;
if ( wxModelessWindows.Find(this) )
wxModelessWindows.DeleteObject(this);
+
+ FullScreenData *data = (FullScreenData *) m_macFullScreenData ;
+ delete data ;
+ m_macFullScreenData = NULL ;
}
wxAssociateWinWithMacWindow( (WindowRef) m_macWindow , this ) ;
UMASetWTitle( (WindowRef) m_macWindow , title , m_font.GetEncoding() ) ;
+ m_peer = new wxMacControl() ;
#if TARGET_API_MAC_OSX
// There is a bug in 10.2.X for ::GetRootControl returning the window view instead of
// the content view, so we have to retrieve it explicitely
HIViewFindByID( HIViewGetRoot( (WindowRef) m_macWindow ) , kHIViewWindowContentID ,
- (ControlRef*)&m_macControl ) ;
+ m_peer->GetControlRefAddr() ) ;
+ if ( !m_peer->Ok() )
+ {
+ // compatibility mode fallback
+ GetRootControl( (WindowRef) m_macWindow , m_peer->GetControlRefAddr() ) ;
+ }
#else
- ::CreateRootControl( (WindowRef)m_macWindow , (ControlRef*)&m_macControl ) ;
+ ::CreateRootControl( (WindowRef)m_macWindow , m_peer->GetControlRefAddr() ) ;
#endif
// the root control level handleer
- MacInstallEventHandler() ;
+ MacInstallEventHandler( (WXWidget) m_peer->GetControlRef() ) ;
// the frame window event handler
InstallStandardEventHandler( GetWindowEventTarget(MAC_WXHWND(m_macWindow)) ) ;
return TRUE ;
}
+bool wxTopLevelWindowMac::ShowFullScreen(bool show, long style)
+{
+ if ( show )
+ {
+ FullScreenData *data = (FullScreenData *)m_macFullScreenData ;
+ delete data ;
+ data = new FullScreenData() ;
+
+ m_macFullScreenData = data ;
+ data->m_position = GetPosition() ;
+ data->m_size = GetSize() ;
+
+ if ( style & wxFULLSCREEN_NOMENUBAR )
+ {
+ HideMenuBar() ;
+ }
+ int left , top , right , bottom ;
+ wxRect client = wxGetClientDisplayRect() ;
+
+ int x, y, w, h ;
+
+ x = client.x ;
+ y = client.y ;
+ w = client.width ;
+ h = client.height ;
+
+ MacGetContentAreaInset( left , top , right , bottom ) ;
+
+ if ( style & wxFULLSCREEN_NOCAPTION )
+ {
+ y -= top ;
+ h += top ;
+ }
+ if ( style & wxFULLSCREEN_NOBORDER )
+ {
+ x -= left ;
+ w += left + right ;
+ h += bottom ;
+ }
+ if ( style & wxFULLSCREEN_NOTOOLBAR )
+ {
+ // TODO
+ }
+ if ( style & wxFULLSCREEN_NOSTATUSBAR )
+ {
+ // TODO
+ }
+ SetSize( x , y , w, h ) ;
+ }
+ else
+ {
+ ShowMenuBar() ;
+ FullScreenData *data = (FullScreenData *) m_macFullScreenData ;
+ SetPosition( data->m_position ) ;
+ SetSize( data->m_size ) ;
+ delete data ;
+ m_macFullScreenData = NULL ;
+ }
+ return FALSE;
+}
+
+bool wxTopLevelWindowMac::IsFullScreen() const
+{
+ return m_macFullScreenData != NULL ;
+}
+
// we are still using coordinates of the content view, todo switch to structure bounds
void wxTopLevelWindowMac::MacGetContentAreaInset( int &left , int &top , int &right , int &bottom )
kWindowCanDrawInCurrentPort|
//kWindowCanMeasureTitle|
kWindowWantsDisposeAtProcessDeath|
- kWindowSupportsSetGrowImageRegion|
+ kWindowSupportsGetGrowImageRegion|
kWindowDefSupportsColorGrafPort;
return 1;
}