]>
git.saurik.com Git - wxWidgets.git/blob - src/mac/carbon/dcclient.cpp
1 /////////////////////////////////////////////////////////////////////////////
3 // Purpose: wxClientDC class
8 // Copyright: (c) AUTHOR
9 // Licence: wxWindows licence
10 /////////////////////////////////////////////////////////////////////////////
13 #pragma implementation "dcclient.h"
16 #include "wx/dcclient.h"
17 #include "wx/dcmemory.h"
18 #include "wx/region.h"
19 #include "wx/window.h"
20 #include "wx/toplevel.h"
22 #include "wx/mac/private.h"
24 //-----------------------------------------------------------------------------
26 //-----------------------------------------------------------------------------
28 #define RAD2DEG 57.2957795131
30 //-----------------------------------------------------------------------------
32 //-----------------------------------------------------------------------------
34 #if !USE_SHARED_LIBRARY
35 IMPLEMENT_DYNAMIC_CLASS(wxWindowDC
, wxDC
)
36 IMPLEMENT_DYNAMIC_CLASS(wxClientDC
, wxWindowDC
)
37 IMPLEMENT_DYNAMIC_CLASS(wxPaintDC
, wxWindowDC
)
44 #include "wx/mac/uma.h"
46 wxWindowDC::wxWindowDC()
50 wxWindowDC::wxWindowDC(wxWindow
*the_canvas
)
52 wxTopLevelWindowMac
* rootwindow
= the_canvas
->MacGetTopLevelWindow() ;
53 WindowRef windowref
= (WindowRef
) rootwindow
->MacGetWindowRef() ;
57 the_canvas
->MacWindowToRootWindow( &x
, &y
) ;
58 m_macLocalOrigin
.x
= x
;
59 m_macLocalOrigin
.y
= y
;
60 CopyRgn( (RgnHandle
) the_canvas
->MacGetVisibleRegion().GetWXHRGN() , (RgnHandle
) m_macBoundaryClipRgn
) ;
61 OffsetRgn( (RgnHandle
) m_macBoundaryClipRgn
, m_macLocalOrigin
.x
, m_macLocalOrigin
.y
) ;
62 CopyRgn( (RgnHandle
) m_macBoundaryClipRgn
, (RgnHandle
) m_macCurrentClipRgn
) ;
63 m_macPort
= UMAGetWindowPort( windowref
) ;
65 wxSize size
= the_canvas
->GetSize() ;
70 SetBackground(the_canvas
->MacGetBackgroundBrush());
73 wxWindowDC::~wxWindowDC()
81 wxClientDC::wxClientDC()
85 wxClientDC::wxClientDC(wxWindow
*window
)
87 wxTopLevelWindowMac
* rootwindow
= window
->MacGetTopLevelWindow() ;
90 WindowRef windowref
= (WindowRef
) rootwindow
->MacGetWindowRef() ;
91 wxPoint origin
= window
->GetClientAreaOrigin() ;
92 wxSize size
= window
->GetClientSize() ;
96 window
->MacWindowToRootWindow( &x
, &y
) ;
97 m_macLocalOrigin
.x
= x
;
98 m_macLocalOrigin
.y
= y
;
99 SetRectRgn( (RgnHandle
) m_macBoundaryClipRgn
, origin
.x
, origin
.y
, origin
.x
+ size
.x
, origin
.y
+ size
.y
) ;
100 SectRgn( (RgnHandle
) m_macBoundaryClipRgn
, (RgnHandle
) window
->MacGetVisibleRegion().GetWXHRGN() , (RgnHandle
) m_macBoundaryClipRgn
) ;
101 OffsetRgn( (RgnHandle
) m_macBoundaryClipRgn
, -origin
.x
, -origin
.y
) ;
102 OffsetRgn( (RgnHandle
) m_macBoundaryClipRgn
, m_macLocalOrigin
.x
, m_macLocalOrigin
.y
) ;
103 CopyRgn( (RgnHandle
) m_macBoundaryClipRgn
,(RgnHandle
) m_macCurrentClipRgn
) ;
104 m_macPort
= UMAGetWindowPort( windowref
) ;
109 SetBackground(window
->MacGetBackgroundBrush());
110 SetFont( window
->GetFont() ) ;
113 wxClientDC::~wxClientDC()
121 wxPaintDC::wxPaintDC()
125 wxPaintDC::wxPaintDC(wxWindow
*window
)
127 wxTopLevelWindowMac
* rootwindow
= window
->MacGetTopLevelWindow() ;
128 WindowRef windowref
= (WindowRef
) rootwindow
->MacGetWindowRef() ;
129 wxPoint origin
= window
->GetClientAreaOrigin() ;
130 wxSize size
= window
->GetClientSize() ;
134 window
->MacWindowToRootWindow( &x
, &y
) ;
135 m_macLocalOrigin
.x
= x
;
136 m_macLocalOrigin
.y
= y
;
137 SetRectRgn( (RgnHandle
) m_macBoundaryClipRgn
, origin
.x
, origin
.y
, origin
.x
+ size
.x
, origin
.y
+ size
.y
) ;
138 SectRgn( (RgnHandle
) m_macBoundaryClipRgn
, (RgnHandle
) window
->MacGetVisibleRegion().GetWXHRGN() , (RgnHandle
) m_macBoundaryClipRgn
) ;
139 OffsetRgn( (RgnHandle
) m_macBoundaryClipRgn
, -origin
.x
, -origin
.y
) ;
140 SectRgn( (RgnHandle
) m_macBoundaryClipRgn
, (RgnHandle
) window
->GetUpdateRegion().GetWXHRGN() , (RgnHandle
) m_macBoundaryClipRgn
) ;
141 OffsetRgn( (RgnHandle
) m_macBoundaryClipRgn
, m_macLocalOrigin
.x
, m_macLocalOrigin
.y
) ;
142 CopyRgn( (RgnHandle
) m_macBoundaryClipRgn
, (RgnHandle
) m_macCurrentClipRgn
) ;
143 m_macPort
= UMAGetWindowPort( windowref
) ;
148 SetBackground(window
->MacGetBackgroundBrush());
149 SetFont( window
->GetFont() ) ;
152 wxPaintDC::~wxPaintDC()