]> git.saurik.com Git - wxWidgets.git/blame_incremental - src/mac/carbon/dcclient.cpp
stubs for wxUSE_DBGHELP == 0
[wxWidgets.git] / src / mac / carbon / dcclient.cpp
... / ...
CommitLineData
1/////////////////////////////////////////////////////////////////////////////
2// Name: 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#if defined(__GNUG__) && !defined(NO_GCC_PRAGMA)
13#pragma implementation "dcclient.h"
14#endif
15
16#include "wx/wxprec.h"
17
18#include "wx/dcclient.h"
19#include "wx/dcmemory.h"
20#include "wx/region.h"
21#include "wx/window.h"
22#include "wx/toplevel.h"
23#include "wx/settings.h"
24#include "wx/math.h"
25#include "wx/mac/private.h"
26
27//-----------------------------------------------------------------------------
28// constants
29//-----------------------------------------------------------------------------
30
31#define RAD2DEG 57.2957795131
32
33//-----------------------------------------------------------------------------
34// wxPaintDC
35//-----------------------------------------------------------------------------
36
37#if !USE_SHARED_LIBRARY
38IMPLEMENT_DYNAMIC_CLASS(wxWindowDC, wxDC)
39IMPLEMENT_DYNAMIC_CLASS(wxClientDC, wxWindowDC)
40IMPLEMENT_DYNAMIC_CLASS(wxPaintDC, wxWindowDC)
41#endif
42
43/*
44 * wxWindowDC
45 */
46
47#include "wx/mac/uma.h"
48#include "wx/notebook.h"
49#include "wx/tabctrl.h"
50
51
52static wxBrush MacGetBackgroundBrush( wxWindow* window )
53{
54 wxBrush bkdBrush = window->MacGetBackgroundBrush() ;
55#if !TARGET_API_MAC_OSX
56 // transparency cannot be handled by the OS when not using composited windows
57 wxWindow* parent = window->GetParent() ;
58 // if we have some 'pseudo' transparency
59 if ( ! bkdBrush.Ok() || bkdBrush.GetStyle() == wxTRANSPARENT || window->GetBackgroundColour() == wxSystemSettings::GetColour(wxSYS_COLOUR_3DFACE ) )
60 {
61 // walk up until we find something
62 while( parent != NULL )
63 {
64 if ( parent->GetBackgroundColour() != wxSystemSettings::GetColour(wxSYS_COLOUR_3DFACE ) )
65 {
66 // if we have any other colours in the hierarchy
67 bkdBrush.SetColour( parent->GetBackgroundColour() ) ;
68 break ;
69 }
70 if ( parent->IsKindOf( CLASSINFO(wxTopLevelWindow) ) )
71 {
72 bkdBrush = parent->MacGetBackgroundBrush() ;
73 break ;
74 }
75 if ( parent->IsKindOf( CLASSINFO( wxNotebook ) ) || parent->IsKindOf( CLASSINFO( wxTabCtrl ) ) )
76 {
77 Rect extent = { 0 , 0 , 0 , 0 } ;
78 int x , y ;
79 x = y = 0 ;
80 wxSize size = parent->GetSize() ;
81 parent->MacClientToRootWindow( &x , &y ) ;
82 extent.left = x ;
83 extent.top = y ;
84 extent.top-- ;
85 extent.right = x + size.x ;
86 extent.bottom = y + size.y ;
87 bkdBrush.MacSetThemeBackground( kThemeBackgroundTabPane , (WXRECTPTR) &extent ) ;
88 break ;
89 }
90
91 parent = parent->GetParent() ;
92 }
93 }
94 if ( !bkdBrush.Ok() || bkdBrush.GetStyle() == wxTRANSPARENT )
95 {
96 // if we did not find something, use a default
97 bkdBrush.MacSetTheme( kThemeBrushDialogBackgroundActive ) ;
98 }
99#endif
100 return bkdBrush ;
101}
102
103
104wxWindowDC::wxWindowDC()
105{
106 m_window = NULL ;
107}
108
109wxWindowDC::wxWindowDC(wxWindow *window)
110{
111 m_window = window ;
112 wxTopLevelWindowMac* rootwindow = window->MacGetTopLevelWindow() ;
113 WindowRef windowref = (WindowRef) rootwindow->MacGetWindowRef() ;
114
115 int x , y ;
116 x = y = 0 ;
117 window->MacWindowToRootWindow( &x , &y ) ;
118 m_macLocalOrigin.x = x ;
119 m_macLocalOrigin.y = y ;
120 CopyRgn( (RgnHandle) window->MacGetVisibleRegion(true).GetWXHRGN() , (RgnHandle) m_macBoundaryClipRgn ) ;
121 OffsetRgn( (RgnHandle) m_macBoundaryClipRgn , m_macLocalOrigin.x , m_macLocalOrigin.y ) ;
122 CopyRgn( (RgnHandle) m_macBoundaryClipRgn , (RgnHandle) m_macCurrentClipRgn ) ;
123 m_macPort = UMAGetWindowPort( windowref ) ;
124 m_ok = TRUE ;
125 MacSetupGraphicContext() ;
126 SetBackground(MacGetBackgroundBrush(window));
127}
128
129wxWindowDC::~wxWindowDC()
130{
131}
132
133void wxWindowDC::DoGetSize( int* width, int* height ) const
134{
135 wxCHECK_RET( m_window, _T("GetSize() doesn't work without window") );
136
137 m_window->GetSize(width, height);
138}
139
140/*
141 * wxClientDC
142 */
143
144wxClientDC::wxClientDC()
145{
146 m_window = NULL ;
147}
148
149wxClientDC::wxClientDC(wxWindow *window)
150{
151 m_window = window ;
152 wxTopLevelWindowMac* rootwindow = window->MacGetTopLevelWindow() ;
153 if (!rootwindow)
154 return;
155 WindowRef windowref = (WindowRef) rootwindow->MacGetWindowRef() ;
156 wxPoint origin = window->GetClientAreaOrigin() ;
157 wxSize size = window->GetClientSize() ;
158 int x , y ;
159 x = origin.x ;
160 y = origin.y ;
161 window->MacWindowToRootWindow( &x , &y ) ;
162 m_macLocalOrigin.x = x ;
163 m_macLocalOrigin.y = y ;
164 SetRectRgn( (RgnHandle) m_macBoundaryClipRgn , origin.x , origin.y , origin.x + size.x , origin.y + size.y ) ;
165 SectRgn( (RgnHandle) m_macBoundaryClipRgn , (RgnHandle) window->MacGetVisibleRegion().GetWXHRGN() , (RgnHandle) m_macBoundaryClipRgn ) ;
166 OffsetRgn( (RgnHandle) m_macBoundaryClipRgn , -origin.x , -origin.y ) ;
167 OffsetRgn( (RgnHandle) m_macBoundaryClipRgn , m_macLocalOrigin.x , m_macLocalOrigin.y ) ;
168 CopyRgn( (RgnHandle) m_macBoundaryClipRgn ,(RgnHandle) m_macCurrentClipRgn ) ;
169 m_macPort = UMAGetWindowPort( windowref ) ;
170
171 m_ok = TRUE ;
172 MacSetupGraphicContext() ;
173 SetBackground(MacGetBackgroundBrush(window));
174 SetFont( window->GetFont() ) ;
175}
176
177wxClientDC::~wxClientDC()
178{
179}
180
181void wxClientDC::DoGetSize(int *width, int *height) const
182{
183 wxCHECK_RET( m_window, _T("GetSize() doesn't work without window") );
184
185 m_window->GetClientSize( width, height );
186}
187
188
189/*
190 * wxPaintDC
191 */
192
193wxPaintDC::wxPaintDC()
194{
195 m_window = NULL ;
196}
197
198wxPaintDC::wxPaintDC(wxWindow *window)
199{
200 m_window = window ;
201 wxTopLevelWindowMac* rootwindow = window->MacGetTopLevelWindow() ;
202 WindowRef windowref = (WindowRef) rootwindow->MacGetWindowRef() ;
203 wxPoint origin = window->GetClientAreaOrigin() ;
204 wxSize size = window->GetClientSize() ;
205 int x , y ;
206 x = origin.x ;
207 y = origin.y ;
208 window->MacWindowToRootWindow( &x , &y ) ;
209 m_macLocalOrigin.x = x ;
210 m_macLocalOrigin.y = y ;
211 SetRectRgn( (RgnHandle) m_macBoundaryClipRgn , origin.x , origin.y , origin.x + size.x , origin.y + size.y ) ;
212 SectRgn( (RgnHandle) m_macBoundaryClipRgn , (RgnHandle) window->MacGetVisibleRegion().GetWXHRGN() , (RgnHandle) m_macBoundaryClipRgn ) ;
213 OffsetRgn( (RgnHandle) m_macBoundaryClipRgn , -origin.x , -origin.y ) ;
214 SectRgn( (RgnHandle) m_macBoundaryClipRgn , (RgnHandle) window->GetUpdateRegion().GetWXHRGN() , (RgnHandle) m_macBoundaryClipRgn ) ;
215 OffsetRgn( (RgnHandle) m_macBoundaryClipRgn , m_macLocalOrigin.x , m_macLocalOrigin.y ) ;
216 CopyRgn( (RgnHandle) m_macBoundaryClipRgn , (RgnHandle) m_macCurrentClipRgn ) ;
217 m_macPort = UMAGetWindowPort( windowref ) ;
218
219 m_ok = TRUE ;
220 MacSetupGraphicContext() ;
221 SetBackground(MacGetBackgroundBrush(window));
222 SetFont( window->GetFont() ) ;
223}
224
225wxPaintDC::~wxPaintDC()
226{
227}
228
229void wxPaintDC::DoGetSize(int *width, int *height) const
230{
231 wxCHECK_RET( m_window, _T("GetSize() doesn't work without window") );
232
233 m_window->GetClientSize( width, height );
234}
235
236