]> git.saurik.com Git - wxWidgets.git/blob - src/mac/carbon/dccg.cpp
cleanup mac
[wxWidgets.git] / src / mac / carbon / dccg.cpp
1 /////////////////////////////////////////////////////////////////////////////
2 // Name: src/mac/carbon/dccg.cpp
3 // Purpose: wxDC class
4 // Author: Stefan Csomor
5 // Modified by:
6 // Created: 01/02/97
7 // RCS-ID: $Id$
8 // Copyright: (c) Stefan Csomor
9 // Licence: wxWindows licence
10 /////////////////////////////////////////////////////////////////////////////
11
12 #include "wx/wxprec.h"
13
14 #include "wx/dc.h"
15
16 #ifndef WX_PRECOMP
17 #include "wx/log.h"
18 #include "wx/dcmemory.h"
19 #include "wx/region.h"
20 #endif
21
22 #include "wx/mac/uma.h"
23
24 #ifdef __MSL__
25 #if __MSL__ >= 0x6000
26 #include "math.h"
27 // in case our functions were defined outside std, we make it known all the same
28 namespace std { }
29 using namespace std ;
30 #endif
31 #endif
32
33 #include "wx/mac/private.h"
34
35 #ifndef __LP64__
36
37 // TODO: update
38 // The textctrl implementation still needs that (needs what?) for the non-HIView implementation
39 //
40 wxMacWindowClipper::wxMacWindowClipper( const wxWindow* win ) :
41 wxMacPortSaver( (GrafPtr) GetWindowPort( (WindowRef) win->MacGetTopLevelWindowRef() ) )
42 {
43 m_newPort = (GrafPtr) GetWindowPort( (WindowRef) win->MacGetTopLevelWindowRef() ) ;
44 m_formerClip = NewRgn() ;
45 m_newClip = NewRgn() ;
46 GetClip( m_formerClip ) ;
47
48 if ( win )
49 {
50 // guard against half constructed objects, this just leads to a empty clip
51 if ( win->GetPeer() )
52 {
53 int x = 0 , y = 0;
54 win->MacWindowToRootWindow( &x, &y ) ;
55
56 // get area including focus rect
57 CopyRgn( (RgnHandle) ((wxWindow*)win)->MacGetVisibleRegion(true).GetWXHRGN() , m_newClip ) ;
58 if ( !EmptyRgn( m_newClip ) )
59 OffsetRgn( m_newClip , x , y ) ;
60 }
61
62 SetClip( m_newClip ) ;
63 }
64 }
65
66 wxMacWindowClipper::~wxMacWindowClipper()
67 {
68 SetPort( m_newPort ) ;
69 SetClip( m_formerClip ) ;
70 DisposeRgn( m_newClip ) ;
71 DisposeRgn( m_formerClip ) ;
72 }
73
74 wxMacWindowStateSaver::wxMacWindowStateSaver( const wxWindow* win ) :
75 wxMacWindowClipper( win )
76 {
77 // the port is already set at this point
78 m_newPort = (GrafPtr) GetWindowPort( (WindowRef) win->MacGetTopLevelWindowRef() ) ;
79 GetThemeDrawingState( &m_themeDrawingState ) ;
80 }
81
82 wxMacWindowStateSaver::~wxMacWindowStateSaver()
83 {
84 SetPort( m_newPort ) ;
85 SetThemeDrawingState( m_themeDrawingState , true ) ;
86 }
87
88 #endif