]>
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 /////////////////////////////////////////////////////////////////////////////
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 IMPLEMENT_DYNAMIC_CLASS(wxWindowDC
, wxDC
)
35 IMPLEMENT_DYNAMIC_CLASS(wxClientDC
, wxWindowDC
)
36 IMPLEMENT_DYNAMIC_CLASS(wxPaintDC
, wxWindowDC
)
42 #include "wx/mac/uma.h"
44 wxWindowDC::wxWindowDC()
49 wxWindowDC::wxWindowDC(wxWindow
*window
)
52 wxTopLevelWindowMac
* rootwindow
= window
->MacGetTopLevelWindow() ;
53 WindowRef windowref
= (WindowRef
) rootwindow
->MacGetWindowRef() ;
57 window
->MacWindowToRootWindow( &x
, &y
) ;
58 m_macLocalOrigin
.x
= x
;
59 m_macLocalOrigin
.y
= y
;
60 CopyRgn( (RgnHandle
) window
->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 SetBackground(window
->MacGetBackgroundBrush());
68 wxWindowDC::~wxWindowDC()
72 void wxWindowDC::DoGetSize( int* width
, int* height
) const
74 wxCHECK_RET( m_window
, _T("GetSize() doesn't work without window") );
76 m_window
->GetSize(width
, height
);
83 wxClientDC::wxClientDC()
88 wxClientDC::wxClientDC(wxWindow
*window
)
91 wxTopLevelWindowMac
* rootwindow
= window
->MacGetTopLevelWindow() ;
94 WindowRef windowref
= (WindowRef
) rootwindow
->MacGetWindowRef() ;
95 wxPoint origin
= window
->GetClientAreaOrigin() ;
96 wxSize size
= window
->GetClientSize() ;
100 window
->MacWindowToRootWindow( &x
, &y
) ;
101 m_macLocalOrigin
.x
= x
;
102 m_macLocalOrigin
.y
= y
;
103 SetRectRgn( (RgnHandle
) m_macBoundaryClipRgn
, origin
.x
, origin
.y
, origin
.x
+ size
.x
, origin
.y
+ size
.y
) ;
104 SectRgn( (RgnHandle
) m_macBoundaryClipRgn
, (RgnHandle
) window
->MacGetVisibleRegion().GetWXHRGN() , (RgnHandle
) m_macBoundaryClipRgn
) ;
105 OffsetRgn( (RgnHandle
) m_macBoundaryClipRgn
, -origin
.x
, -origin
.y
) ;
106 OffsetRgn( (RgnHandle
) m_macBoundaryClipRgn
, m_macLocalOrigin
.x
, m_macLocalOrigin
.y
) ;
107 CopyRgn( (RgnHandle
) m_macBoundaryClipRgn
,(RgnHandle
) m_macCurrentClipRgn
) ;
108 m_macPort
= UMAGetWindowPort( windowref
) ;
111 SetBackground(window
->MacGetBackgroundBrush());
112 SetFont( window
->GetFont() ) ;
115 wxClientDC::~wxClientDC()
119 void wxClientDC::DoGetSize(int *width
, int *height
) const
121 wxCHECK_RET( m_window
, _T("GetSize() doesn't work without window") );
123 m_window
->GetClientSize( width
, height
);
131 wxPaintDC::wxPaintDC()
136 wxPaintDC::wxPaintDC(wxWindow
*window
)
139 wxTopLevelWindowMac
* rootwindow
= window
->MacGetTopLevelWindow() ;
140 WindowRef windowref
= (WindowRef
) rootwindow
->MacGetWindowRef() ;
141 wxPoint origin
= window
->GetClientAreaOrigin() ;
142 wxSize size
= window
->GetClientSize() ;
146 window
->MacWindowToRootWindow( &x
, &y
) ;
147 m_macLocalOrigin
.x
= x
;
148 m_macLocalOrigin
.y
= y
;
149 SetRectRgn( (RgnHandle
) m_macBoundaryClipRgn
, origin
.x
, origin
.y
, origin
.x
+ size
.x
, origin
.y
+ size
.y
) ;
150 SectRgn( (RgnHandle
) m_macBoundaryClipRgn
, (RgnHandle
) window
->MacGetVisibleRegion().GetWXHRGN() , (RgnHandle
) m_macBoundaryClipRgn
) ;
151 OffsetRgn( (RgnHandle
) m_macBoundaryClipRgn
, -origin
.x
, -origin
.y
) ;
152 SectRgn( (RgnHandle
) m_macBoundaryClipRgn
, (RgnHandle
) window
->GetUpdateRegion().GetWXHRGN() , (RgnHandle
) m_macBoundaryClipRgn
) ;
153 OffsetRgn( (RgnHandle
) m_macBoundaryClipRgn
, m_macLocalOrigin
.x
, m_macLocalOrigin
.y
) ;
154 CopyRgn( (RgnHandle
) m_macBoundaryClipRgn
, (RgnHandle
) m_macCurrentClipRgn
) ;
155 m_macPort
= UMAGetWindowPort( windowref
) ;
158 SetBackground(window
->MacGetBackgroundBrush());
159 SetFont( window
->GetFont() ) ;
162 wxPaintDC::~wxPaintDC()
166 void wxPaintDC::DoGetSize(int *width
, int *height
) const
168 wxCHECK_RET( m_window
, _T("GetSize() doesn't work without window") );
170 m_window
->GetClientSize( width
, height
);