From: Stefan Csomor Date: Sun, 27 Feb 2005 08:54:16 +0000 (+0000) Subject: reintroducing non-composited functionality due to DataBrowser Bugs under 10.2 X-Git-Url: https://git.saurik.com/wxWidgets.git/commitdiff_plain/9b89f11ad8f5456b6823598f7f2c3c1070a6f10c reintroducing non-composited functionality due to DataBrowser Bugs under 10.2 git-svn-id: https://svn.wxwidgets.org/svn/wx/wxWidgets/trunk@32395 c3d73ce0-8a6f-49c7-b76d-6d57e0e08775 --- diff --git a/include/wx/mac/carbon/private.h b/include/wx/mac/carbon/private.h index 1ae59814b9..a3f4094719 100644 --- a/include/wx/mac/carbon/private.h +++ b/include/wx/mac/carbon/private.h @@ -411,26 +411,12 @@ Rect wxMacGetBoundsForControl( wxWindow* window , const wxPoint& pos , const wxS class wxMacControl { public : - wxMacControl(wxWindow* peer) - { - m_peer = peer ; - m_controlRef = NULL ; - } + wxMacControl( wxWindow* peer) ; + wxMacControl( wxWindow* peer , ControlRef control ) ; + wxMacControl( wxWindow* peer , WXWidget control ) ; + virtual ~wxMacControl() ; - wxMacControl( wxWindow* peer , ControlRef control ) - { - m_peer = peer ; - m_controlRef = control ; - } - wxMacControl( wxWindow* peer , WXWidget control ) - { - m_peer = peer ; - m_controlRef = (ControlRef) control ; - } - - virtual ~wxMacControl() - { - } + void Init() ; virtual void Dispose() ; @@ -469,6 +455,7 @@ public : virtual OSStatus SetFocus( ControlFocusPart focusPart ) ; virtual bool HasFocus() const ; virtual bool NeedsFocusRect() const ; + virtual void SetNeedsFocusRect( bool needs ) ; // templated helpers @@ -570,11 +557,14 @@ public : // to be moved into a tab control class virtual OSStatus SetTabEnabled( SInt16 tabNo , bool enable ) ; + bool IsCompositing() { return m_isCompositing ; } protected : ControlRef m_controlRef ; wxFont m_font ; long m_windowStyle ; wxWindow* m_peer ; + bool m_needsFocusRect ; + bool m_isCompositing ; } ; #if wxMAC_USE_CORE_GRAPHICS @@ -750,7 +740,7 @@ wxString wxMacMakeStringFromPascal( ConstStringPtr from ) ; // toplevel.cpp -ControlRef wxMacFindControlUnderMouse( Point location , WindowRef window , ControlPartCode *outPart ) ; +ControlRef wxMacFindControlUnderMouse( wxTopLevelWindowMac* toplevelWindow, Point location , WindowRef window , ControlPartCode *outPart ) ; // filefn.cpp diff --git a/src/mac/carbon/utils.cpp b/src/mac/carbon/utils.cpp index 6ccff5444c..4a209c9517 100644 --- a/src/mac/carbon/utils.cpp +++ b/src/mac/carbon/utils.cpp @@ -784,6 +784,41 @@ OSStatus wxMacCarbonEvent::SetParameter(EventParamName inName, EventParamType in // Control Access Support // ---------------------------------------------------------------------------- +wxMacControl::wxMacControl(wxWindow* peer) +{ + Init() ; + m_peer = peer ; + m_isCompositing = peer->MacGetTopLevelWindow()->MacUsesCompositing() ; +} + +wxMacControl::wxMacControl( wxWindow* peer , ControlRef control ) +{ + Init() ; + m_peer = peer ; + m_isCompositing = peer->MacGetTopLevelWindow()->MacUsesCompositing() ; + m_controlRef = control ; +} + +wxMacControl::wxMacControl( wxWindow* peer , WXWidget control ) +{ + Init() ; + m_peer = peer ; + m_isCompositing = peer->MacGetTopLevelWindow()->MacUsesCompositing() ; + m_controlRef = (ControlRef) control ; +} + +wxMacControl::~wxMacControl() +{ +} + +void wxMacControl::Init() +{ + m_peer = NULL ; + m_controlRef = NULL ; + m_needsFocusRect = false ; + m_isCompositing = false ; +} + void wxMacControl::Dispose() { ::DisposeControl( m_controlRef ) ; @@ -894,9 +929,14 @@ bool wxMacControl::HasFocus() const return control == m_controlRef ; } +void wxMacControl::SetNeedsFocusRect( bool needs ) +{ + m_needsFocusRect = needs ; +} + bool wxMacControl::NeedsFocusRect() const { - return false ; + return m_needsFocusRect ; } void wxMacControl::VisibilityChanged(bool shown) @@ -1052,46 +1092,64 @@ void wxMacControl::SetNeedsDisplay( bool needsDisplay , RgnHandle where ) void wxMacControl::Convert( wxPoint *pt , wxMacControl *from , wxMacControl *to ) { #if TARGET_API_MAC_OSX - HIPoint hiPoint ; - hiPoint.x = pt->x ; - hiPoint.y = pt->y ; - HIViewConvertPoint( &hiPoint , from->m_controlRef , to->m_controlRef ) ; - pt->x = (int)hiPoint.x ; - pt->y = (int)hiPoint.y ; -#else - Rect fromRect ; - Rect toRect ; - from->GetRect( &fromRect ) ; - to->GetRect( &toRect ) ; - - // correct the case of the root control - if ( fromRect.left == -32768 && fromRect.top == -32768 && fromRect.bottom == 32767 && fromRect.right == 32767) - fromRect.left = fromRect.top = 0 ; - - if ( toRect.left == -32768 && toRect.top == -32768 && toRect.bottom == 32767 && toRect.right == 32767 ) - toRect.left = toRect.top = 0 ; - - pt->x = pt->x + fromRect.left - toRect.left ; - pt->y = pt->y + fromRect.top - toRect.top ; + if ( from->m_peer->MacGetTopLevelWindow()->MacUsesCompositing() ) + { + HIPoint hiPoint ; + hiPoint.x = pt->x ; + hiPoint.y = pt->y ; + HIViewConvertPoint( &hiPoint , from->m_controlRef , to->m_controlRef ) ; + pt->x = (int)hiPoint.x ; + pt->y = (int)hiPoint.y ; + } + else #endif + { + Rect fromRect ; + Rect toRect ; + from->GetRect( &fromRect ) ; + to->GetRect( &toRect ) ; + + pt->x = pt->x + fromRect.left - toRect.left ; + pt->y = pt->y + fromRect.top - toRect.top ; + } } void wxMacControl::SetRect( Rect *r ) { #if TARGET_API_MAC_OSX - //A HIRect is actually a CGRect on OSX - which consists of two structures - - //CGPoint and CGSize, which have two floats each - HIRect hir = { { r->left , r->top }, { r->right - r->left , r->bottom - r->top } } ; - HIViewSetFrame ( m_controlRef , &hir ) ; -#else - SetControlBounds( m_controlRef , r ) ; + if ( m_isCompositing ) + { + //A HIRect is actually a CGRect on OSX - which consists of two structures - + //CGPoint and CGSize, which have two floats each + HIRect hir = { { r->left , r->top }, { r->right - r->left , r->bottom - r->top } } ; + HIViewSetFrame ( m_controlRef , &hir ) ; + // eventuall we might have to do a SetVisibility( false , true ) ; + // before and a SetVisibility( true , true ) ; after + } + else #endif - + { + Rect former ; + GetControlBounds( m_controlRef , &former ) ; + InvalWindowRect( GetControlOwner( m_controlRef ) , &former ) ; + SetControlBounds( m_controlRef , r ) ; + InvalWindowRect( GetControlOwner( m_controlRef ) , r ) ; + } } void wxMacControl::GetRect( Rect *r ) { GetControlBounds( m_controlRef , r ) ; + // correct the case of the root control + if ( r->left == -32768 && r->top == -32768 && r->bottom == 32767 && r->right == 32767) + { + WindowRef wr = GetControlOwner( m_controlRef ) ; + GetWindowBounds( wr , kWindowContentRgn , r ) ; + r->right -= r->left ; + r->bottom -= r->top ; + r->left = 0 ; + r->top = 0 ; + } } void wxMacControl::GetRectInWindowCoords( Rect *r )