X-Git-Url: https://git.saurik.com/wxWidgets.git/blobdiff_plain/524c47aa3adf2af11a3069fd5da035a604f08f66..357d2b88cb15fa0ad97b1676fdbc88c2abc85451:/src/osx/carbon/window.cpp diff --git a/src/osx/carbon/window.cpp b/src/osx/carbon/window.cpp index a24d1a6f55..21e9c4174a 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 // --------------------------------------------------------------------------- @@ -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 @@ -1184,7 +1140,7 @@ void wxMacControl::SuperChangedPosition() { } -void wxMacControl::SetFont( const wxFont & font , const wxColour& foreground , long windowStyle ) +void wxMacControl::SetFont( const wxFont & font , const wxColour& foreground , long windowStyle, bool ignoreBlack ) { m_font = font; #if wxOSX_USE_CORE_TEXT @@ -1199,7 +1155,7 @@ void wxMacControl::SetFont( const wxFont & font , const wxColour& foreground , l HIViewSetTextFont( m_controlRef , part , (CTFontRef) font.MacGetCTFont() ); HIViewSetTextHorizontalFlush( m_controlRef, part, flush ); - if ( foreground != *wxBLACK ) + if ( foreground != *wxBLACK || ignoreBlack == false ) { ControlFontStyleRec fontStyle; foreground.GetRGBColor( &fontStyle.foreColor ); @@ -1252,7 +1208,7 @@ void wxMacControl::SetFont( const wxFont & font , const wxColour& foreground , l // we only should do this in case of a non-standard color, as otherwise 'disabled' controls // won't get grayed out by the system anymore - if ( foreground != *wxBLACK ) + if ( foreground != *wxBLACK || ignoreBlack == false ) { foreground.GetRGBColor( &fontStyle.foreColor ); fontStyle.flags |= kControlUseForeColorMask;