X-Git-Url: https://git.saurik.com/wxWidgets.git/blobdiff_plain/1e181c7a2c32193fc8138cc32ed07984eadd4a21..952555f7b1af7b263fd18ec4ad6e87e14970d9b8:/src/osx/carbon/window.cpp diff --git a/src/osx/carbon/window.cpp b/src/osx/carbon/window.cpp index 00d919ffca..392c061792 100644 --- a/src/osx/carbon/window.cpp +++ b/src/osx/carbon/window.cpp @@ -79,50 +79,6 @@ #define wxMAC_DEBUG_REDRAW 0 #endif - -WX_DECLARE_HASH_MAP(WXWidget, wxWindow*, wxPointerHash, wxPointerEqual, MacControlMap); - -static MacControlMap wxWinMacControlList; - -wxWindowMac *wxFindWindowFromWXWidget(WXWidget inControl ) -{ - MacControlMap::iterator node = wxWinMacControlList.find(inControl); - - return (node == wxWinMacControlList.end()) ? NULL : node->second; -} - -void wxAssociateWindowWithWXWidget(WXWidget inControl, wxWindow *control) -{ - // adding NULL ControlRef is (first) surely a result of an error and - // (secondly) breaks native event processing - wxCHECK_RET( inControl != (WXWidget) NULL, wxT("attempt to add a NULL WindowRef to window list") ); - - wxWinMacControlList[inControl] = control; -} - -void wxRemoveWXWidgetAssociation(wxWindow *control) -{ - // iterate over all the elements in the class - // is the iterator stable ? as we might have two associations pointing to the same wxWindow - // we should go on... - - bool found = true ; - while ( found ) - { - found = false ; - MacControlMap::iterator it; - for ( it = wxWinMacControlList.begin(); it != wxWinMacControlList.end(); ++it ) - { - if ( it->second == control ) - { - wxWinMacControlList.erase(it); - found = true ; - break; - } - } - } -} - // --------------------------------------------------------------------------- // Carbon Events // --------------------------------------------------------------------------- @@ -331,8 +287,8 @@ static pascal OSStatus wxMacWindowControlEventHandler( EventHandlerCallRef handl thisWindow->GetCaret()->OnKillFocus(); #endif - wxLogTrace(_T("Focus"), _T("focus lost(%p)"), wx_static_cast(void*, thisWindow)); - + wxLogTrace(_T("Focus"), _T("focus lost(%p)"), static_cast(thisWindow)); + // remove this as soon as posting the synthesized event works properly static bool inKillFocusEvent = false ; @@ -351,7 +307,7 @@ static pascal OSStatus wxMacWindowControlEventHandler( EventHandlerCallRef handl { // set focus // panel wants to track the window which was the last to have focus in it - wxLogTrace(_T("Focus"), _T("focus set(%p)"), wx_static_cast(void*, thisWindow)); + wxLogTrace(_T("Focus"), _T("focus set(%p)"), static_cast(thisWindow)); wxChildFocusEvent eventFocus((wxWindow*)thisWindow); thisWindow->HandleWindowEvent(eventFocus); @@ -379,12 +335,12 @@ static pascal OSStatus wxMacWindowControlEventHandler( EventHandlerCallRef handl if ( controlPart != kControlFocusNoPart ) { targetFocusWindow = thisWindow; - wxLogTrace(_T("Focus"), _T("focus to be set(%p)"), wx_static_cast(void*, thisWindow)); + wxLogTrace(_T("Focus"), _T("focus to be set(%p)"), static_cast(thisWindow)); } else { formerFocusWindow = thisWindow; - wxLogTrace(_T("Focus"), _T("focus to be lost(%p)"), wx_static_cast(void*, thisWindow)); + wxLogTrace(_T("Focus"), _T("focus to be lost(%p)"), static_cast(thisWindow)); } ControlPartCode previousControlPart = 0; @@ -437,7 +393,7 @@ static pascal OSStatus wxMacWindowControlEventHandler( EventHandlerCallRef handl thisWindow->GetCaret()->OnKillFocus(); #endif - wxLogTrace(_T("Focus"), _T("focus lost(%p)"), wx_static_cast(void*, thisWindow)); + wxLogTrace(_T("Focus"), _T("focus lost(%p)"), static_cast(thisWindow)); static bool inKillFocusEvent = false ; @@ -453,7 +409,7 @@ static pascal OSStatus wxMacWindowControlEventHandler( EventHandlerCallRef handl else { // panel wants to track the window which was the last to have focus in it - wxLogTrace(_T("Focus"), _T("focus set(%p)"), wx_static_cast(void*, thisWindow)); + wxLogTrace(_T("Focus"), _T("focus set(%p)"), static_cast(thisWindow)); wxChildFocusEvent eventFocus((wxWindow*)thisWindow); thisWindow->HandleWindowEvent(eventFocus); @@ -842,11 +798,11 @@ wxWidgetImplType* wxWidgetImpl::CreateUserPane( wxWindowMac* wxpeer, wxWindowMac } -void wxMacControl::MacInstallEventHandler( ControlRef control, wxWindowMac* wxPeer ) +void wxMacControl::InstallEventHandler( WXWidget control ) { - wxAssociateWindowWithWXWidget( (WXWidget) control , wxPeer ) ; - ::InstallControlEventHandler( control , GetwxMacWindowEventHandlerUPP(), - GetEventTypeCount(eventList), eventList, wxPeer, NULL); + wxWidgetImpl::Associate( control ? control : (WXWidget) m_controlRef , this ) ; + ::InstallControlEventHandler( control ? (ControlRef) control : m_controlRef , GetwxMacWindowEventHandlerUPP(), + GetEventTypeCount(eventList), eventList, GetWXPeer(), NULL); } IMPLEMENT_DYNAMIC_CLASS( wxMacControl , wxWidgetImpl ) @@ -869,7 +825,7 @@ wxMacControl::~wxMacControl() wxASSERT_MSG( m_controlRef != NULL , wxT("Control Handle already NULL, Dispose called twice ?") ); wxASSERT_MSG( IsValidControlHandle(m_controlRef) , wxT("Invalid Control Handle (maybe already released) in Dispose") ); - wxRemoveWXWidgetAssociation( m_wxPeer) ; + wxWidgetImpl::RemoveAssociations( this ) ; // we cannot check the ref count here anymore, as autorelease objects might delete their refs later // we can have situations when being embedded, where the control gets deleted behind our back, so only // CFRelease if we are safe @@ -885,22 +841,15 @@ void wxMacControl::Init() m_macControlEventHandler = NULL; } -void wxMacControl::SetReference( URefCon data ) -{ - SetControlReference( m_controlRef , data ); -} - void wxMacControl::RemoveFromParent() { // nothing to do here for carbon + HIViewRemoveFromSuperview(m_controlRef); } void wxMacControl::Embed( wxWidgetImpl *parent ) { - // copied from MacPostControlCreate - ControlRef container = (ControlRef) parent->GetWXWidget() ; - wxASSERT_MSG( container != NULL , wxT("No valid mac container control") ) ; - ::EmbedControl( m_controlRef , container ) ; + HIViewAddSubview((ControlRef)parent->GetWXWidget(), m_controlRef); } void wxMacControl::SetNeedsDisplay( const wxRect* rect ) @@ -1089,6 +1038,47 @@ bool wxMacControl::HasFocus() const return control == m_controlRef; } +void wxMacControl::SetCursor(const wxCursor& cursor) +{ + wxWindowMac *mouseWin = 0 ; + WindowRef window = GetControlOwner( m_controlRef ) ; + + wxNonOwnedWindow* tlwwx = wxNonOwnedWindow::GetFromWXWindow( (WXWindow) window ) ; + if ( tlwwx != NULL ) + { + ControlPartCode part ; + ControlRef control ; + Point pt ; +#if MAC_OS_X_VERSION_MIN_REQUIRED >= MAC_OS_X_VERSION_10_5 + HIPoint hiPoint ; + HIGetMousePosition(kHICoordSpaceWindow, window, &hiPoint); + pt.h = hiPoint.x; + pt.v = hiPoint.y; +#else + GetGlobalMouse( &pt ); + int x = pt.h; + int y = pt.v; + tlwwx->ScreenToClient(&x, &y); + pt.h = x; + pt.v = y; +#endif + control = FindControlUnderMouse( pt , window , &part ) ; + if ( control ) + mouseWin = wxFindWindowFromWXWidget( (WXWidget) control ) ; + } + + if ( mouseWin == tlwwx && !wxIsBusy() ) + cursor.MacInstall() ; +} + +void wxMacControl::CaptureMouse() +{ +} + +void wxMacControl::ReleaseMouse() +{ +} + // // subclass specifics //