From: Stefan Csomor Date: Mon, 29 Mar 2004 11:28:08 +0000 (+0000) Subject: added port state save class X-Git-Url: https://git.saurik.com/wxWidgets.git/commitdiff_plain/01299d5694fdccdbec96588ea2fb81a7d597da07 added port state save class git-svn-id: https://svn.wxwidgets.org/svn/wx/wxWidgets/trunk@26451 c3d73ce0-8a6f-49c7-b76d-6d57e0e08775 --- diff --git a/include/wx/mac/carbon/private.h b/include/wx/mac/carbon/private.h index c64fcbb0b3..fcb7cb0aa2 100644 --- a/include/wx/mac/carbon/private.h +++ b/include/wx/mac/carbon/private.h @@ -105,10 +105,23 @@ public: wxMacWindowClipper( const wxWindow* win ) ; ~wxMacWindowClipper() ; private: + GrafPtr m_newPort ; RgnHandle m_formerClip ; RgnHandle m_newClip ; } ; +class WXDLLEXPORT wxMacWindowStateSaver : public wxMacWindowClipper +{ + DECLARE_NO_COPY_CLASS(wxMacWindowStateSaver) + +public: + wxMacWindowStateSaver( const wxWindow* win ) ; + ~wxMacWindowStateSaver() ; +private: + GrafPtr m_newPort ; + ThemeDrawingState m_themeDrawingState ; +} ; + /* class wxMacDrawingHelper { diff --git a/src/mac/carbon/dc.cpp b/src/mac/carbon/dc.cpp index 53ab8a3f7f..49de162c0a 100644 --- a/src/mac/carbon/dc.cpp +++ b/src/mac/carbon/dc.cpp @@ -107,6 +107,7 @@ typedef wxMacPortSetter wxMacFastPortSetter ; wxMacWindowClipper::wxMacWindowClipper( const wxWindow* win ) : wxMacPortSaver( (GrafPtr) GetWindowPort((WindowRef) win->MacGetTopLevelWindowRef()) ) { + m_newPort =(GrafPtr) GetWindowPort((WindowRef) win->MacGetTopLevelWindowRef()) ; m_formerClip = NewRgn() ; m_newClip = NewRgn() ; GetClip( m_formerClip ) ; @@ -126,11 +127,26 @@ wxMacWindowClipper::wxMacWindowClipper( const wxWindow* win ) : wxMacWindowClipper::~wxMacWindowClipper() { + SetPort( m_newPort ) ; SetClip( m_formerClip ) ; DisposeRgn( m_newClip ) ; DisposeRgn( m_formerClip ) ; } +wxMacWindowStateSaver::wxMacWindowStateSaver( const wxWindow* win ) : + wxMacWindowClipper( win ) +{ + // the port is already set at this point + m_newPort =(GrafPtr) GetWindowPort((WindowRef) win->MacGetTopLevelWindowRef()) ; + GetThemeDrawingState( &m_themeDrawingState ) ; +} + +wxMacWindowStateSaver::~wxMacWindowStateSaver() +{ + SetPort( m_newPort ) ; + SetThemeDrawingState( m_themeDrawingState , true ) ; +} + //----------------------------------------------------------------------------- // Local functions //-----------------------------------------------------------------------------