]> git.saurik.com Git - wxWidgets.git/blame_incremental - src/mac/classic/dcclient.cpp
fix warnings (double to int conversions and unused variables); removed hard TABs...
[wxWidgets.git] / src / mac / classic / dcclient.cpp
... / ...
CommitLineData
1/////////////////////////////////////////////////////////////////////////////
2// Name: src/mac/classic/dcclient.cpp
3// Purpose: wxClientDC class
4// Author: Stefan Csomor
5// Modified by:
6// Created: 01/02/97
7// RCS-ID: $Id$
8// Copyright: (c) Stefan Csomor
9// Licence: wxWindows licence
10/////////////////////////////////////////////////////////////////////////////
11
12#include "wx/wxprec.h"
13
14#include "wx/dcclient.h"
15
16#ifndef WX_PRECOMP
17 #include "wx/window.h"
18 #include "wx/dcmemory.h"
19 #include "wx/toplevel.h"
20 #include "wx/math.h"
21 #include "wx/region.h"
22#endif
23
24#include "wx/mac/private.h"
25
26//-----------------------------------------------------------------------------
27// constants
28//-----------------------------------------------------------------------------
29
30#define RAD2DEG 57.2957795131
31
32//-----------------------------------------------------------------------------
33// wxPaintDC
34//-----------------------------------------------------------------------------
35
36IMPLEMENT_DYNAMIC_CLASS(wxWindowDC, wxDC)
37IMPLEMENT_DYNAMIC_CLASS(wxClientDC, wxWindowDC)
38IMPLEMENT_DYNAMIC_CLASS(wxPaintDC, wxWindowDC)
39
40/*
41 * wxWindowDC
42 */
43
44#include "wx/mac/uma.h"
45
46wxWindowDC::wxWindowDC()
47{
48 m_window = NULL ;
49}
50
51wxWindowDC::wxWindowDC(wxWindow *window)
52{
53 m_window = window ;
54 wxTopLevelWindowMac* rootwindow = window->MacGetTopLevelWindow() ;
55 WindowRef windowref = (WindowRef) rootwindow->MacGetWindowRef() ;
56
57 int x , y ;
58 x = y = 0 ;
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 ) ;
66 m_ok = true ;
67 SetBackground(window->MacGetBackgroundBrush());
68}
69
70wxWindowDC::~wxWindowDC()
71{
72}
73
74void wxWindowDC::DoGetSize( int* width, int* height ) const
75{
76 wxCHECK_RET( m_window, _T("GetSize() doesn't work without window") );
77
78 m_window->GetSize(width, height);
79}
80
81/*
82 * wxClientDC
83 */
84
85wxClientDC::wxClientDC()
86{
87 m_window = NULL ;
88}
89
90wxClientDC::wxClientDC(wxWindow *window)
91{
92 m_window = window ;
93 wxTopLevelWindowMac* rootwindow = window->MacGetTopLevelWindow() ;
94 if (!rootwindow)
95 return;
96 WindowRef windowref = (WindowRef) rootwindow->MacGetWindowRef() ;
97 wxPoint origin = window->GetClientAreaOrigin() ;
98 wxSize size = window->GetClientSize() ;
99 int x , y ;
100 x = origin.x ;
101 y = origin.y ;
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 ) ;
111
112 m_ok = true ;
113 SetBackground(window->MacGetBackgroundBrush());
114 SetFont( window->GetFont() ) ;
115}
116
117wxClientDC::~wxClientDC()
118{
119}
120
121void wxClientDC::DoGetSize(int *width, int *height) const
122{
123 wxCHECK_RET( m_window, _T("GetSize() doesn't work without window") );
124
125 m_window->GetClientSize( width, height );
126}
127
128
129/*
130 * wxPaintDC
131 */
132
133wxPaintDC::wxPaintDC()
134{
135 m_window = NULL ;
136}
137
138wxPaintDC::wxPaintDC(wxWindow *window)
139{
140 m_window = window ;
141 wxTopLevelWindowMac* rootwindow = window->MacGetTopLevelWindow() ;
142 WindowRef windowref = (WindowRef) rootwindow->MacGetWindowRef() ;
143 wxPoint origin = window->GetClientAreaOrigin() ;
144 wxSize size = window->GetClientSize() ;
145 int x , y ;
146 x = origin.x ;
147 y = origin.y ;
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 ) ;
158
159 m_ok = true ;
160 SetBackground(window->MacGetBackgroundBrush());
161 SetFont( window->GetFont() ) ;
162}
163
164wxPaintDC::~wxPaintDC()
165{
166}
167
168void wxPaintDC::DoGetSize(int *width, int *height) const
169{
170 wxCHECK_RET( m_window, _T("GetSize() doesn't work without window") );
171
172 m_window->GetClientSize( width, height );
173}