]> git.saurik.com Git - wxWidgets.git/blame - src/mac/carbon/dccg.cpp
guard code for mac / quickdraw
[wxWidgets.git] / src / mac / carbon / dccg.cpp
CommitLineData
613a24f7 1/////////////////////////////////////////////////////////////////////////////
e4db172a 2// Name: src/mac/carbon/dccg.cpp
613a24f7
SC
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
e4db172a 9// Licence: wxWindows licence
613a24f7
SC
10/////////////////////////////////////////////////////////////////////////////
11
20b69855
SC
12#include "wx/wxprec.h"
13
613a24f7 14#include "wx/dc.h"
20b69855 15
e4db172a
WS
16#ifndef WX_PRECOMP
17 #include "wx/log.h"
f38924e8 18 #include "wx/dcmemory.h"
b3a44e05 19 #include "wx/region.h"
e4db172a
WS
20#endif
21
613a24f7 22#include "wx/mac/uma.h"
613a24f7 23
138861bc
VZ
24#ifdef __MSL__
25 #if __MSL__ >= 0x6000
26 #include "math.h"
d281db8b 27 // in case our functions were defined outside std, we make it known all the same
0f4c3aa2 28 namespace std { }
138861bc
VZ
29 using namespace std ;
30 #endif
613a24f7
SC
31#endif
32
33#include "wx/mac/private.h"
613a24f7 34
4f74e0d1 35#ifndef __LP64__
613a24f7 36
eb1a7cf9 37// TODO: update
b21d67a0
DS
38// The textctrl implementation still needs that (needs what?) for the non-HIView implementation
39//
613a24f7 40wxMacWindowClipper::wxMacWindowClipper( const wxWindow* win ) :
0f4c3aa2 41 wxMacPortSaver( (GrafPtr) GetWindowPort( (WindowRef) win->MacGetTopLevelWindowRef() ) )
613a24f7 42{
0f4c3aa2 43 m_newPort = (GrafPtr) GetWindowPort( (WindowRef) win->MacGetTopLevelWindowRef() ) ;
613a24f7
SC
44 m_formerClip = NewRgn() ;
45 m_newClip = NewRgn() ;
46 GetClip( m_formerClip ) ;
97071cdb 47
613a24f7
SC
48 if ( win )
49 {
bcbbfab8 50 // guard against half constructed objects, this just leads to a empty clip
97071cdb 51 if ( win->GetPeer() )
bcbbfab8
SC
52 {
53 int x = 0 , y = 0;
eb1a7cf9 54 win->MacWindowToRootWindow( &x, &y ) ;
0f4c3aa2 55
bcbbfab8
SC
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 }
613a24f7
SC
61
62 SetClip( m_newClip ) ;
63 }
64}
65
0f4c3aa2 66wxMacWindowClipper::~wxMacWindowClipper()
613a24f7
SC
67{
68 SetPort( m_newPort ) ;
69 SetClip( m_formerClip ) ;
70 DisposeRgn( m_newClip ) ;
71 DisposeRgn( m_formerClip ) ;
72}
73
74wxMacWindowStateSaver::wxMacWindowStateSaver( const wxWindow* win ) :
75 wxMacWindowClipper( win )
76{
77 // the port is already set at this point
0f4c3aa2 78 m_newPort = (GrafPtr) GetWindowPort( (WindowRef) win->MacGetTopLevelWindowRef() ) ;
613a24f7
SC
79 GetThemeDrawingState( &m_themeDrawingState ) ;
80}
81
0f4c3aa2 82wxMacWindowStateSaver::~wxMacWindowStateSaver()
613a24f7
SC
83{
84 SetPort( m_newPort ) ;
85 SetThemeDrawingState( m_themeDrawingState , true ) ;
86}
87
20b69855 88#endif