]>
git.saurik.com Git - wxWidgets.git/blob - src/mac/classic/dcclient.cpp
1 /////////////////////////////////////////////////////////////////////////////
3 // Purpose: wxClientDC class
4 // Author: Stefan Csomor
8 // Copyright: (c) Stefan Csomor
9 // Licence: wxWindows licence
10 /////////////////////////////////////////////////////////////////////////////
12 #include "wx/dcclient.h"
13 #include "wx/dcmemory.h"
14 #include "wx/region.h"
15 #include "wx/window.h"
16 #include "wx/toplevel.h"
18 #include "wx/mac/private.h"
20 //-----------------------------------------------------------------------------
22 //-----------------------------------------------------------------------------
24 #define RAD2DEG 57.2957795131
26 //-----------------------------------------------------------------------------
28 //-----------------------------------------------------------------------------
30 IMPLEMENT_DYNAMIC_CLASS(wxWindowDC
, wxDC
)
31 IMPLEMENT_DYNAMIC_CLASS(wxClientDC
, wxWindowDC
)
32 IMPLEMENT_DYNAMIC_CLASS(wxPaintDC
, wxWindowDC
)
38 #include "wx/mac/uma.h"
40 wxWindowDC::wxWindowDC()
45 wxWindowDC::wxWindowDC(wxWindow
*window
)
48 wxTopLevelWindowMac
* rootwindow
= window
->MacGetTopLevelWindow() ;
49 WindowRef windowref
= (WindowRef
) rootwindow
->MacGetWindowRef() ;
53 window
->MacWindowToRootWindow( &x
, &y
) ;
54 m_macLocalOrigin
.x
= x
;
55 m_macLocalOrigin
.y
= y
;
56 CopyRgn( (RgnHandle
) window
->MacGetVisibleRegion().GetWXHRGN() , (RgnHandle
) m_macBoundaryClipRgn
) ;
57 OffsetRgn( (RgnHandle
) m_macBoundaryClipRgn
, m_macLocalOrigin
.x
, m_macLocalOrigin
.y
) ;
58 CopyRgn( (RgnHandle
) m_macBoundaryClipRgn
, (RgnHandle
) m_macCurrentClipRgn
) ;
59 m_macPort
= UMAGetWindowPort( windowref
) ;
61 SetBackground(window
->MacGetBackgroundBrush());
64 wxWindowDC::~wxWindowDC()
68 void wxWindowDC::DoGetSize( int* width
, int* height
) const
70 wxCHECK_RET( m_window
, _T("GetSize() doesn't work without window") );
72 m_window
->GetSize(width
, height
);
79 wxClientDC::wxClientDC()
84 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
) ;
107 SetBackground(window
->MacGetBackgroundBrush());
108 SetFont( window
->GetFont() ) ;
111 wxClientDC::~wxClientDC()
115 void wxClientDC::DoGetSize(int *width
, int *height
) const
117 wxCHECK_RET( m_window
, _T("GetSize() doesn't work without window") );
119 m_window
->GetClientSize( width
, height
);
127 wxPaintDC::wxPaintDC()
132 wxPaintDC::wxPaintDC(wxWindow
*window
)
135 wxTopLevelWindowMac
* rootwindow
= window
->MacGetTopLevelWindow() ;
136 WindowRef windowref
= (WindowRef
) rootwindow
->MacGetWindowRef() ;
137 wxPoint origin
= window
->GetClientAreaOrigin() ;
138 wxSize size
= window
->GetClientSize() ;
142 window
->MacWindowToRootWindow( &x
, &y
) ;
143 m_macLocalOrigin
.x
= x
;
144 m_macLocalOrigin
.y
= y
;
145 SetRectRgn( (RgnHandle
) m_macBoundaryClipRgn
, origin
.x
, origin
.y
, origin
.x
+ size
.x
, origin
.y
+ size
.y
) ;
146 SectRgn( (RgnHandle
) m_macBoundaryClipRgn
, (RgnHandle
) window
->MacGetVisibleRegion().GetWXHRGN() , (RgnHandle
) m_macBoundaryClipRgn
) ;
147 OffsetRgn( (RgnHandle
) m_macBoundaryClipRgn
, -origin
.x
, -origin
.y
) ;
148 SectRgn( (RgnHandle
) m_macBoundaryClipRgn
, (RgnHandle
) window
->GetUpdateRegion().GetWXHRGN() , (RgnHandle
) m_macBoundaryClipRgn
) ;
149 OffsetRgn( (RgnHandle
) m_macBoundaryClipRgn
, m_macLocalOrigin
.x
, m_macLocalOrigin
.y
) ;
150 CopyRgn( (RgnHandle
) m_macBoundaryClipRgn
, (RgnHandle
) m_macCurrentClipRgn
) ;
151 m_macPort
= UMAGetWindowPort( windowref
) ;
154 SetBackground(window
->MacGetBackgroundBrush());
155 SetFont( window
->GetFont() ) ;
158 wxPaintDC::~wxPaintDC()
162 void wxPaintDC::DoGetSize(int *width
, int *height
) const
164 wxCHECK_RET( m_window
, _T("GetSize() doesn't work without window") );
166 m_window
->GetClientSize( width
, height
);