]>
git.saurik.com Git - wxWidgets.git/blob - src/mac/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 #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()
51 wxWindowDC::wxWindowDC(wxWindow
*window
)
54 wxTopLevelWindowMac
* rootwindow
= window
->MacGetTopLevelWindow() ;
55 WindowRef windowref
= (WindowRef
) rootwindow
->MacGetWindowRef() ;
59 window
->MacWindowToRootWindow( &x
, &y
) ;
60 m_macLocalOrigin
.x
= x
;
61 m_macLocalOrigin
.y
= y
;
62 CopyRgn( (RgnHandle
) window
->MacGetVisibleRegion().GetWXHRGN() , (RgnHandle
) m_macBoundaryClipRgn
) ;
63 OffsetRgn( (RgnHandle
) m_macBoundaryClipRgn
, m_macLocalOrigin
.x
, m_macLocalOrigin
.y
) ;
64 CopyRgn( (RgnHandle
) m_macBoundaryClipRgn
, (RgnHandle
) m_macCurrentClipRgn
) ;
65 m_macPort
= UMAGetWindowPort( windowref
) ;
67 SetBackground(window
->MacGetBackgroundBrush());
70 wxWindowDC::~wxWindowDC()
74 void wxWindowDC::DoGetSize( int* width
, int* height
) const
76 wxCHECK_RET( m_window
, _T("GetSize() doesn't work without window") );
78 m_window
->GetSize(width
, height
);
85 wxClientDC::wxClientDC()
90 wxClientDC::wxClientDC(wxWindow
*window
)
93 wxTopLevelWindowMac
* rootwindow
= window
->MacGetTopLevelWindow() ;
96 WindowRef windowref
= (WindowRef
) rootwindow
->MacGetWindowRef() ;
97 wxPoint origin
= window
->GetClientAreaOrigin() ;
98 wxSize size
= window
->GetClientSize() ;
102 window
->MacWindowToRootWindow( &x
, &y
) ;
103 m_macLocalOrigin
.x
= x
;
104 m_macLocalOrigin
.y
= y
;
105 SetRectRgn( (RgnHandle
) m_macBoundaryClipRgn
, origin
.x
, origin
.y
, origin
.x
+ size
.x
, origin
.y
+ size
.y
) ;
106 SectRgn( (RgnHandle
) m_macBoundaryClipRgn
, (RgnHandle
) window
->MacGetVisibleRegion().GetWXHRGN() , (RgnHandle
) m_macBoundaryClipRgn
) ;
107 OffsetRgn( (RgnHandle
) m_macBoundaryClipRgn
, -origin
.x
, -origin
.y
) ;
108 OffsetRgn( (RgnHandle
) m_macBoundaryClipRgn
, m_macLocalOrigin
.x
, m_macLocalOrigin
.y
) ;
109 CopyRgn( (RgnHandle
) m_macBoundaryClipRgn
,(RgnHandle
) m_macCurrentClipRgn
) ;
110 m_macPort
= UMAGetWindowPort( windowref
) ;
113 SetBackground(window
->MacGetBackgroundBrush());
114 SetFont( window
->GetFont() ) ;
117 wxClientDC::~wxClientDC()
121 void wxClientDC::DoGetSize(int *width
, int *height
) const
123 wxCHECK_RET( m_window
, _T("GetSize() doesn't work without window") );
125 m_window
->GetClientSize( width
, height
);
133 wxPaintDC::wxPaintDC()
138 wxPaintDC::wxPaintDC(wxWindow
*window
)
141 wxTopLevelWindowMac
* rootwindow
= window
->MacGetTopLevelWindow() ;
142 WindowRef windowref
= (WindowRef
) rootwindow
->MacGetWindowRef() ;
143 wxPoint origin
= window
->GetClientAreaOrigin() ;
144 wxSize size
= window
->GetClientSize() ;
148 window
->MacWindowToRootWindow( &x
, &y
) ;
149 m_macLocalOrigin
.x
= x
;
150 m_macLocalOrigin
.y
= y
;
151 SetRectRgn( (RgnHandle
) m_macBoundaryClipRgn
, origin
.x
, origin
.y
, origin
.x
+ size
.x
, origin
.y
+ size
.y
) ;
152 SectRgn( (RgnHandle
) m_macBoundaryClipRgn
, (RgnHandle
) window
->MacGetVisibleRegion().GetWXHRGN() , (RgnHandle
) m_macBoundaryClipRgn
) ;
153 OffsetRgn( (RgnHandle
) m_macBoundaryClipRgn
, -origin
.x
, -origin
.y
) ;
154 SectRgn( (RgnHandle
) m_macBoundaryClipRgn
, (RgnHandle
) window
->GetUpdateRegion().GetWXHRGN() , (RgnHandle
) m_macBoundaryClipRgn
) ;
155 OffsetRgn( (RgnHandle
) m_macBoundaryClipRgn
, m_macLocalOrigin
.x
, m_macLocalOrigin
.y
) ;
156 CopyRgn( (RgnHandle
) m_macBoundaryClipRgn
, (RgnHandle
) m_macCurrentClipRgn
) ;
157 m_macPort
= UMAGetWindowPort( windowref
) ;
160 SetBackground(window
->MacGetBackgroundBrush());
161 SetFont( window
->GetFont() ) ;
164 wxPaintDC::~wxPaintDC()
168 void wxPaintDC::DoGetSize(int *width
, int *height
) const
170 wxCHECK_RET( m_window
, _T("GetSize() doesn't work without window") );
172 m_window
->GetClientSize( width
, height
);