X-Git-Url: https://git.saurik.com/wxWidgets.git/blobdiff_plain/7372fd0a3c5b84f7cbaaf37592f7d413a3e0372b..a811affe70feeb727bf7fbd2748a48ded6ec3b9b:/src/mac/carbon/window.cpp diff --git a/src/mac/carbon/window.cpp b/src/mac/carbon/window.cpp index 44cd7f0919..bc83a282a2 100644 --- a/src/mac/carbon/window.cpp +++ b/src/mac/carbon/window.cpp @@ -37,6 +37,7 @@ #include "wx/menuitem.h" #include "wx/spinctrl.h" #include "wx/log.h" +#include "wx/geometry.h" #if wxUSE_CARET #include "wx/caret.h" @@ -168,6 +169,13 @@ wxWindowMac::~wxWindowMac() { s_lastMouseWindow = NULL ; } + + wxFrame* frame = wxDynamicCast( wxGetTopLevelParent( this ) , wxFrame ) ; + if ( frame ) + { + if ( frame->GetLastFocus() == this ) + frame->SetLastFocus( NULL ) ; + } if ( gFocusWindow == this ) { @@ -1434,6 +1442,48 @@ bool wxWindowMac::MacGetWindowFromPoint( const wxPoint &screenpoint , wxWindowMa extern int wxBusyCursorCount ; static wxWindow *gs_lastWhich = NULL; +bool wxWindowMac::MacSetupCursor( const wxPoint& pt) +{ + // first trigger a set cursor event + + wxPoint clientorigin = GetClientAreaOrigin() ; + wxSize clientsize = GetClientSize() ; + wxCursor cursor ; + if ( wxRect2DInt( clientorigin.x , clientorigin.y , clientsize.x , clientsize.y ).Contains( wxPoint2DInt( pt ) ) ) + { + wxSetCursorEvent event( pt.x , pt.y ); + + bool processedEvtSetCursor = GetEventHandler()->ProcessEvent(event); + if ( processedEvtSetCursor && event.HasCursor() ) + { + cursor = event.GetCursor() ; + } + else + { + + // the test for processedEvtSetCursor is here to prevent using m_cursor + // if the user code caught EVT_SET_CURSOR() and returned nothing from + // it - this is a way to say that our cursor shouldn't be used for this + // point + if ( !processedEvtSetCursor && m_cursor.Ok() ) + { + cursor = m_cursor ; + } + if ( wxIsBusy() ) + { + } + else + { + if ( !GetParent() ) + cursor = *wxSTANDARD_CURSOR ; + } + } + if ( cursor.Ok() ) + cursor.MacInstall() ; + } + return cursor.Ok() ; +} + bool wxWindowMac::MacDispatchMouseEvent(wxMouseEvent& event) { if ((event.m_x < m_x) || (event.m_y < m_y) || @@ -1462,14 +1512,18 @@ bool wxWindowMac::MacDispatchMouseEvent(wxMouseEvent& event) } } - event.m_x = x ; - event.m_y = y ; - event.SetEventObject( this ) ; + wxWindow* cursorTarget = this ; + wxPoint cursorPoint( x , y ) ; - if ( wxBusyCursorCount == 0 ) + while( cursorTarget && !cursorTarget->MacSetupCursor( cursorPoint ) ) { - m_cursor.MacInstall() ; + cursorTarget = cursorTarget->GetParent() ; + if ( cursorTarget ) + cursorPoint += cursorTarget->GetPosition() ; } + event.m_x = x ; + event.m_y = y ; + event.SetEventObject( this ) ; if ( event.GetEventType() == wxEVT_LEFT_DOWN ) { @@ -1569,7 +1623,12 @@ const wxRegion& wxWindowMac::MacGetVisibleRegion( bool respectChildrenAndSibling x = y = 0 ; parent->MacWindowToRootWindow( &x, &y ) ; MacRootWindowToWindow( &x , &y ) ; - SetRectRgn( tempRgn , x , y , x + size.x , y + size.y ) ; + + SetRectRgn( tempRgn , + x + parent->MacGetLeftBorderSize() , y + parent->MacGetTopBorderSize() , + x + size.x - parent->MacGetLeftBorderSize() - parent->MacGetRightBorderSize(), + y + size.y - parent->MacGetTopBorderSize() - parent->MacGetBottomBorderSize()) ; + SectRgn( visRgn , tempRgn , visRgn ) ; if ( parent->IsTopLevel() ) break ;