]> git.saurik.com Git - wxWidgets.git/commitdiff
Carbon Event Mouse Moved handler changes
authorStefan Csomor <csomor@advancedconcepts.ch>
Sun, 31 Aug 2003 15:35:32 +0000 (15:35 +0000)
committerStefan Csomor <csomor@advancedconcepts.ch>
Sun, 31 Aug 2003 15:35:32 +0000 (15:35 +0000)
git-svn-id: https://svn.wxwidgets.org/svn/wx/wxWidgets/trunk@23321 c3d73ce0-8a6f-49c7-b76d-6d57e0e08775

src/mac/app.cpp
src/mac/carbon/app.cpp
src/mac/carbon/toplevel.cpp
src/mac/toplevel.cpp

index aa4e3b578bfada9ec36fa70752c40dd803c080a6..381dc7fb4281c8599448e5549be93fbcc3d54ae3 100644 (file)
@@ -298,6 +298,7 @@ void wxApp::MacNewFile()
         { kEventClassAppleEvent , kEventAppleEvent } ,
 
         { kEventClassMouse , kEventMouseDown } ,
+        { kEventClassMouse , kEventMouseMoved } ,
         { 'WXMC' , 'WXMC' }
     } ;
 
@@ -340,15 +341,30 @@ static pascal OSStatus MouseEventHandler( EventHandlerCallRef handler , EventRef
 {
     OSStatus result = eventNotHandledErr ;
 
+    Point point ;
+    UInt32 modifiers = 0;
+    EventMouseButton button = 0 ;
+    UInt32 click = 0 ;
+
+    GetEventParameter( event, kEventParamMouseLocation, typeQDPoint, NULL,
+        sizeof( Point ), NULL, &point );
+    GetEventParameter( event, kEventParamKeyModifiers, typeUInt32, NULL,
+        sizeof( UInt32 ), NULL, &modifiers );
+    GetEventParameter( event, kEventParamMouseButton, typeMouseButton, NULL,
+        sizeof( EventMouseButton ), NULL, &button );
+    GetEventParameter( event, kEventParamClickCount, typeUInt32, NULL,
+        sizeof( UInt32 ), NULL, &click );
+
+    if ( button == 0 || GetEventKind( event ) == kEventMouseUp )
+        modifiers += btnState ;
+
+
     switch( GetEventKind(event) )
     {
         case kEventMouseDown :
         {
-            Point point ;
             WindowRef window ;
 
-            GetEventParameter( event, kEventParamMouseLocation, typeQDPoint, NULL,
-                sizeof( Point ), NULL, &point );
             short windowPart = ::FindWindow(point, &window);
 
             if ( windowPart == inMenuBar )
@@ -358,6 +374,13 @@ static pascal OSStatus MouseEventHandler( EventHandlerCallRef handler , EventRef
             }
         }
         break ;
+        case kEventMouseMoved :
+        {
+            wxTheApp->MacHandleMouseMovedEvent( point.h , point.v , modifiers , EventTimeToTicks( GetEventTime( event ) ) ) ;
+            result = noErr ;
+            break ;
+        }
+        break ;
     }
 
     return result ;
@@ -2099,6 +2122,111 @@ void wxApp::MacHandleOSEvent( WXEVENTREF evr )
 
     }
 }
+#else
+
+void wxApp::MacHandleMouseMovedEvent(wxInt32 x , wxInt32 y ,wxUint32 modifiers , long timestamp)
+{
+    WindowRef window;
+
+    wxWindow* currentMouseWindow = NULL ;
+
+    if (s_captureWindow )
+    {
+        currentMouseWindow = s_captureWindow ;
+    }
+    else
+    {
+        wxWindow::MacGetWindowFromPoint( wxPoint( x, y ) , &currentMouseWindow ) ;
+    }
+
+    if ( currentMouseWindow != wxWindow::s_lastMouseWindow )
+    {
+        wxMouseEvent event ;
+
+        bool isDown = !(modifiers & btnState) ; // 1 is for up
+        bool controlDown = modifiers & controlKey ; // for simulating right mouse
+
+        event.m_leftDown = isDown && !controlDown;
+
+        event.m_middleDown = FALSE;
+        event.m_rightDown = isDown && controlDown;
+
+        event.m_shiftDown = modifiers & shiftKey;
+        event.m_controlDown = modifiers & controlKey;
+        event.m_altDown = modifiers & optionKey;
+        event.m_metaDown = modifiers & cmdKey;
+        event.m_x = x;
+        event.m_y = y;
+        event.m_timeStamp = timestamp;
+
+        if ( wxWindow::s_lastMouseWindow )
+        {
+            wxMouseEvent eventleave(event);
+            eventleave.SetEventType( wxEVT_LEAVE_WINDOW );
+            wxWindow::s_lastMouseWindow->ScreenToClient( &eventleave.m_x, &eventleave.m_y );
+            eventleave.SetEventObject( wxWindow::s_lastMouseWindow ) ;
+
+#if wxUSE_TOOLTIPS
+            wxToolTip::RelayEvent( wxWindow::s_lastMouseWindow , eventleave);
+#endif // wxUSE_TOOLTIPS
+            wxWindow::s_lastMouseWindow->GetEventHandler()->ProcessEvent(eventleave);
+        }
+        if ( currentMouseWindow )
+        {
+            wxMouseEvent evententer(event);
+            evententer.SetEventType( wxEVT_ENTER_WINDOW );
+            currentMouseWindow->ScreenToClient( &evententer.m_x, &evententer.m_y );
+            evententer.SetEventObject( currentMouseWindow ) ;
+#if wxUSE_TOOLTIPS
+            wxToolTip::RelayEvent( currentMouseWindow , evententer);
+#endif // wxUSE_TOOLTIPS
+            currentMouseWindow->GetEventHandler()->ProcessEvent(evententer);
+        }
+        wxWindow::s_lastMouseWindow = currentMouseWindow ;
+    }
+
+    short windowPart = inNoWindow ;
+
+    if ( s_captureWindow )
+    {
+        window = (WindowRef) s_captureWindow->MacGetRootWindow() ;
+        windowPart = inContent ;
+    }
+    else
+    {
+        Point pt= { y , x } ;
+        windowPart = ::FindWindow(pt , &window);
+    }
+
+    switch (windowPart)
+    {
+        case inContent :
+            {
+                wxTopLevelWindowMac* win = wxFindWinFromMacWindow( window ) ;
+                if ( win )
+                    win->MacFireMouseEvent( nullEvent , x , y , modifiers , timestamp ) ;
+                else
+                {
+                    if ( wxIsBusy() )
+                    {
+                    }
+                    else
+                        UMAShowArrowCursor();
+                 }
+            }
+            break;
+        default :
+            {
+                if ( wxIsBusy() )
+                {
+                }
+                else
+                    UMAShowArrowCursor();
+            }
+            break ;
+    }
+}
 #endif
 
 void wxApp::MacHandleMenuCommand( wxUint32 id )
index aa4e3b578bfada9ec36fa70752c40dd803c080a6..381dc7fb4281c8599448e5549be93fbcc3d54ae3 100644 (file)
@@ -298,6 +298,7 @@ void wxApp::MacNewFile()
         { kEventClassAppleEvent , kEventAppleEvent } ,
 
         { kEventClassMouse , kEventMouseDown } ,
+        { kEventClassMouse , kEventMouseMoved } ,
         { 'WXMC' , 'WXMC' }
     } ;
 
@@ -340,15 +341,30 @@ static pascal OSStatus MouseEventHandler( EventHandlerCallRef handler , EventRef
 {
     OSStatus result = eventNotHandledErr ;
 
+    Point point ;
+    UInt32 modifiers = 0;
+    EventMouseButton button = 0 ;
+    UInt32 click = 0 ;
+
+    GetEventParameter( event, kEventParamMouseLocation, typeQDPoint, NULL,
+        sizeof( Point ), NULL, &point );
+    GetEventParameter( event, kEventParamKeyModifiers, typeUInt32, NULL,
+        sizeof( UInt32 ), NULL, &modifiers );
+    GetEventParameter( event, kEventParamMouseButton, typeMouseButton, NULL,
+        sizeof( EventMouseButton ), NULL, &button );
+    GetEventParameter( event, kEventParamClickCount, typeUInt32, NULL,
+        sizeof( UInt32 ), NULL, &click );
+
+    if ( button == 0 || GetEventKind( event ) == kEventMouseUp )
+        modifiers += btnState ;
+
+
     switch( GetEventKind(event) )
     {
         case kEventMouseDown :
         {
-            Point point ;
             WindowRef window ;
 
-            GetEventParameter( event, kEventParamMouseLocation, typeQDPoint, NULL,
-                sizeof( Point ), NULL, &point );
             short windowPart = ::FindWindow(point, &window);
 
             if ( windowPart == inMenuBar )
@@ -358,6 +374,13 @@ static pascal OSStatus MouseEventHandler( EventHandlerCallRef handler , EventRef
             }
         }
         break ;
+        case kEventMouseMoved :
+        {
+            wxTheApp->MacHandleMouseMovedEvent( point.h , point.v , modifiers , EventTimeToTicks( GetEventTime( event ) ) ) ;
+            result = noErr ;
+            break ;
+        }
+        break ;
     }
 
     return result ;
@@ -2099,6 +2122,111 @@ void wxApp::MacHandleOSEvent( WXEVENTREF evr )
 
     }
 }
+#else
+
+void wxApp::MacHandleMouseMovedEvent(wxInt32 x , wxInt32 y ,wxUint32 modifiers , long timestamp)
+{
+    WindowRef window;
+
+    wxWindow* currentMouseWindow = NULL ;
+
+    if (s_captureWindow )
+    {
+        currentMouseWindow = s_captureWindow ;
+    }
+    else
+    {
+        wxWindow::MacGetWindowFromPoint( wxPoint( x, y ) , &currentMouseWindow ) ;
+    }
+
+    if ( currentMouseWindow != wxWindow::s_lastMouseWindow )
+    {
+        wxMouseEvent event ;
+
+        bool isDown = !(modifiers & btnState) ; // 1 is for up
+        bool controlDown = modifiers & controlKey ; // for simulating right mouse
+
+        event.m_leftDown = isDown && !controlDown;
+
+        event.m_middleDown = FALSE;
+        event.m_rightDown = isDown && controlDown;
+
+        event.m_shiftDown = modifiers & shiftKey;
+        event.m_controlDown = modifiers & controlKey;
+        event.m_altDown = modifiers & optionKey;
+        event.m_metaDown = modifiers & cmdKey;
+        event.m_x = x;
+        event.m_y = y;
+        event.m_timeStamp = timestamp;
+
+        if ( wxWindow::s_lastMouseWindow )
+        {
+            wxMouseEvent eventleave(event);
+            eventleave.SetEventType( wxEVT_LEAVE_WINDOW );
+            wxWindow::s_lastMouseWindow->ScreenToClient( &eventleave.m_x, &eventleave.m_y );
+            eventleave.SetEventObject( wxWindow::s_lastMouseWindow ) ;
+
+#if wxUSE_TOOLTIPS
+            wxToolTip::RelayEvent( wxWindow::s_lastMouseWindow , eventleave);
+#endif // wxUSE_TOOLTIPS
+            wxWindow::s_lastMouseWindow->GetEventHandler()->ProcessEvent(eventleave);
+        }
+        if ( currentMouseWindow )
+        {
+            wxMouseEvent evententer(event);
+            evententer.SetEventType( wxEVT_ENTER_WINDOW );
+            currentMouseWindow->ScreenToClient( &evententer.m_x, &evententer.m_y );
+            evententer.SetEventObject( currentMouseWindow ) ;
+#if wxUSE_TOOLTIPS
+            wxToolTip::RelayEvent( currentMouseWindow , evententer);
+#endif // wxUSE_TOOLTIPS
+            currentMouseWindow->GetEventHandler()->ProcessEvent(evententer);
+        }
+        wxWindow::s_lastMouseWindow = currentMouseWindow ;
+    }
+
+    short windowPart = inNoWindow ;
+
+    if ( s_captureWindow )
+    {
+        window = (WindowRef) s_captureWindow->MacGetRootWindow() ;
+        windowPart = inContent ;
+    }
+    else
+    {
+        Point pt= { y , x } ;
+        windowPart = ::FindWindow(pt , &window);
+    }
+
+    switch (windowPart)
+    {
+        case inContent :
+            {
+                wxTopLevelWindowMac* win = wxFindWinFromMacWindow( window ) ;
+                if ( win )
+                    win->MacFireMouseEvent( nullEvent , x , y , modifiers , timestamp ) ;
+                else
+                {
+                    if ( wxIsBusy() )
+                    {
+                    }
+                    else
+                        UMAShowArrowCursor();
+                 }
+            }
+            break;
+        default :
+            {
+                if ( wxIsBusy() )
+                {
+                }
+                else
+                    UMAShowArrowCursor();
+            }
+            break ;
+    }
+}
 #endif
 
 void wxApp::MacHandleMenuCommand( wxUint32 id )
index a6a9882aea62cb2af5920324d19995571c8c0e55..fce9d1fbf5274537fbd3781f90de9dead3b0c17a 100644 (file)
@@ -280,7 +280,7 @@ static pascal OSStatus MouseEventHandler( EventHandlerCallRef handler , EventRef
                 result = noErr ;
                 break ;
             case kEventMouseMoved :
-                toplevelWindow->MacFireMouseEvent( nullEvent , point.h , point.v , modifiers , EventTimeToTicks( GetEventTime( event ) ) ) ;
+                wxTheApp->MacHandleMouseMovedEvent( point.h , point.v , modifiers , EventTimeToTicks( GetEventTime( event ) ) ) ;
                 result = noErr ;
                 break ;
             case kEventMouseDragged :
index a6a9882aea62cb2af5920324d19995571c8c0e55..fce9d1fbf5274537fbd3781f90de9dead3b0c17a 100644 (file)
@@ -280,7 +280,7 @@ static pascal OSStatus MouseEventHandler( EventHandlerCallRef handler , EventRef
                 result = noErr ;
                 break ;
             case kEventMouseMoved :
-                toplevelWindow->MacFireMouseEvent( nullEvent , point.h , point.v , modifiers , EventTimeToTicks( GetEventTime( event ) ) ) ;
+                wxTheApp->MacHandleMouseMovedEvent( point.h , point.v , modifiers , EventTimeToTicks( GetEventTime( event ) ) ) ;
                 result = noErr ;
                 break ;
             case kEventMouseDragged :