From 793921582e924133aa0712d780d04b9a87ce2450 Mon Sep 17 00:00:00 2001 From: Stefan Csomor Date: Thu, 1 Apr 2004 08:34:18 +0000 Subject: [PATCH] added adjustOrigin parameter to bounds calculation, added Freeze and Thaw implementation git-svn-id: https://svn.wxwidgets.org/svn/wx/wxWidgets/trunk@26534 c3d73ce0-8a6f-49c7-b76d-6d57e0e08775 --- include/wx/mac/carbon/window.h | 8 ++++++-- src/mac/carbon/window.cpp | 36 +++++++++++++++++++++++++++++----- 2 files changed, 37 insertions(+), 7 deletions(-) diff --git a/include/wx/mac/carbon/window.h b/include/wx/mac/carbon/window.h index cb2349c71d..b97187fd46 100644 --- a/include/wx/mac/carbon/window.h +++ b/include/wx/mac/carbon/window.h @@ -79,6 +79,8 @@ public: virtual void Refresh( bool eraseBackground = TRUE, const wxRect *rect = (const wxRect *) NULL ); + virtual void Freeze() ; + virtual void Thaw() ; virtual bool SetCursor( const wxCursor &cursor ); virtual bool SetFont( const wxFont &font ) ; @@ -224,14 +226,16 @@ public: bool MacGetBoundsForControl(const wxPoint& pos, const wxSize& size, int& x, int& y, - int& w, int& h) const ; + int& w, int& h , bool adjustForOrigin ) const ; // calculates the real window position and size from the native control void MacGetPositionAndSizeFromControl(int& x, int& y, int& w, int& h) const ; protected: // For controls like radiobuttons which are really composite wxList m_subControls; - + // number of calls to Freeze() minus number of calls to Thaw() + unsigned int m_frozenness; + WXWidget m_macControl ; bool m_macIsUserPane ; wxBrush m_macBackgroundBrush ; diff --git a/src/mac/carbon/window.cpp b/src/mac/carbon/window.cpp index a611b10314..c30e7a0467 100644 --- a/src/mac/carbon/window.cpp +++ b/src/mac/carbon/window.cpp @@ -425,6 +425,7 @@ pascal void wxMacLiveScrollbarActionProc( ControlRef control , ControlPartCode p void wxWindowMac::Init() { + m_frozenness = 0 ; m_backgroundTransparent = FALSE; // as all windows are created with WS_VISIBLE style... @@ -920,7 +921,7 @@ void wxWindowMac::MacGetPositionAndSizeFromControl(int& x, int& y, bool wxWindowMac::MacGetBoundsForControl(const wxPoint& pos, const wxSize& size, int& x, int& y, - int& w, int& h) const + int& w, int& h , bool adjustOrigin ) const { x = (int)pos.x; y = (int)pos.y; @@ -930,7 +931,8 @@ bool wxWindowMac::MacGetBoundsForControl(const wxPoint& pos, #if !TARGET_API_MAC_OSX GetParent()->MacWindowToRootWindow( &x , &y ) ; #endif - + if ( adjustOrigin ) + AdjustForParentClientOrigin( x , y ) ; return true ; } @@ -1360,7 +1362,8 @@ void wxWindowMac::DoMoveWindow(int x, int y, int width, int height) if ( doMove || doResize ) { - Rect r = wxMacGetBoundsForControl(this , wxPoint( actualX,actualY), wxSize( actualWidth, actualHeight ) ) ; + // we don't adjust twice for the origin + Rect r = wxMacGetBoundsForControl(this , wxPoint( actualX,actualY), wxSize( actualWidth, actualHeight ) , false ) ; bool vis = IsControlVisible( (ControlRef) m_macControl ) ; #if TARGET_API_MAC_OSX // the HIViewSetFrame call itself should invalidate the areas, but when testing with the UnicodeTextCtrl it does not ! @@ -1811,6 +1814,29 @@ void wxWindowMac::Refresh(bool eraseBack, const wxRect *rect) #endif } +void wxWindowMac::Freeze() +{ +#if TARGET_API_MAC_OSX + if ( !m_frozenness++ ) + { + HIViewSetDrawingEnabled( (HIViewRef) m_macControl , false ) ; + } +#endif +} + +void wxWindowMac::Thaw() +{ +#if TARGET_API_MAC_OSX + wxASSERT_MSG( m_frozenness > 0, _T("Thaw() without matching Freeze()") ); + + if ( !--m_frozenness ) + { + HIViewSetDrawingEnabled( (HIViewRef) m_macControl , true ) ; + HIViewSetNeedsDisplay( (HIViewRef) m_macControl , true ) ; + } +#endif +} + void wxWindowMac::MacRedrawControl() { /* @@ -2755,11 +2781,11 @@ void wxWindowMac::MacHandleControlClick( WXWidget control , wxInt16 controlpart wxASSERT_MSG( (ControlRef) m_macControl != NULL , wxT("No valid mac control") ) ; } -Rect wxMacGetBoundsForControl( wxWindow* window , const wxPoint& pos , const wxSize &size ) +Rect wxMacGetBoundsForControl( wxWindow* window , const wxPoint& pos , const wxSize &size , bool adjustForOrigin ) { int x ,y , w ,h ; - window->MacGetBoundsForControl( pos , size , x , y, w, h ) ; + window->MacGetBoundsForControl( pos , size , x , y, w, h , adjustForOrigin) ; Rect bounds = { y , x , y+h , x+w }; return bounds ; } -- 2.45.2