]> git.saurik.com Git - wxWidgets.git/blame - src/mac/toplevel.cpp
corrected background
[wxWidgets.git] / src / mac / toplevel.cpp
CommitLineData
a15eb0a5
SC
1///////////////////////////////////////////////////////////////////////////////
2// Name: mac/toplevel.cpp
3// Purpose: implements wxTopLevelWindow for MSW
4// Author: Vadim Zeitlin
5// Modified by:
6// Created: 24.09.01
7// RCS-ID: $Id$
8// Copyright: (c) 2001 SciTech Software, Inc. (www.scitechsoft.com)
9// License: wxWindows license
10///////////////////////////////////////////////////////////////////////////////
11
12// ============================================================================
13// declarations
14// ============================================================================
15
16// ----------------------------------------------------------------------------
17// headers
18// ----------------------------------------------------------------------------
19
20#ifdef __GNUG__
21 #pragma implementation "toplevel.h"
22#endif
23
24// For compilers that support precompilation, includes "wx.h".
25#include "wx/wxprec.h"
26
27#ifdef __BORLANDC__
28 #pragma hdrstop
29#endif
30
31#ifndef WX_PRECOMP
32 #include "wx/app.h"
33 #include "wx/toplevel.h"
422644a3 34 #include "wx/frame.h"
a15eb0a5
SC
35 #include "wx/string.h"
36 #include "wx/log.h"
37 #include "wx/intl.h"
38#endif //WX_PRECOMP
39
5f0b2f22 40#include "wx/mac/uma.h"
422644a3 41#include "wx/mac/aga.h"
5f0b2f22 42#include "wx/tooltip.h"
a07c1212 43#include "wx/dnd.h"
5f0b2f22 44
34dc8f91
SC
45#define wxMAC_DEBUG_REDRAW 0
46#ifndef wxMAC_DEBUG_REDRAW
47#define wxMAC_DEBUG_REDRAW 0
48#endif
49
a15eb0a5
SC
50// ----------------------------------------------------------------------------
51// globals
52// ----------------------------------------------------------------------------
53
54// list of all frames and modeless dialogs
32b5be3d
RR
55wxWindowList wxModelessWindows;
56
57// double click testing
58static Point gs_lastWhere;
59static long gs_lastWhen = 0;
60
61// cursor stuff
62extern int wxBusyCursorCount;
63
a15eb0a5
SC
64
65// ============================================================================
66// wxTopLevelWindowMac implementation
67// ============================================================================
68
5f0b2f22
SC
69// ---------------------------------------------------------------------------
70// wxWindowMac utility functions
71// ---------------------------------------------------------------------------
72
73// Find an item given the Macintosh Window Reference
74
75wxList *wxWinMacWindowList = NULL;
76a5e5d2 76wxTopLevelWindowMac *wxFindWinFromMacWindow(WXWindow inWindowRef)
5f0b2f22
SC
77{
78 wxNode *node = wxWinMacWindowList->Find((long)inWindowRef);
79 if (!node)
80 return NULL;
81 return (wxTopLevelWindowMac *)node->Data();
82}
83
76a5e5d2 84void wxAssociateWinWithMacWindow(WXWindow inWindowRef, wxTopLevelWindowMac *win)
5f0b2f22
SC
85{
86 // adding NULL WindowRef is (first) surely a result of an error and
87 // (secondly) breaks menu command processing
88 wxCHECK_RET( inWindowRef != (WindowRef) NULL, "attempt to add a NULL WindowRef to window list" );
89
90 if ( !wxWinMacWindowList->Find((long)inWindowRef) )
91 wxWinMacWindowList->Append((long)inWindowRef, win);
92}
93
94void wxRemoveMacWindowAssociation(wxTopLevelWindowMac *win)
95{
96 wxWinMacWindowList->DeleteObject(win);
97}
98
99
a15eb0a5
SC
100// ----------------------------------------------------------------------------
101// wxTopLevelWindowMac creation
102// ----------------------------------------------------------------------------
103
76a5e5d2 104WXHWND wxTopLevelWindowMac::s_macWindowInUpdate = NULL;
5f0b2f22 105
a15eb0a5
SC
106void wxTopLevelWindowMac::Init()
107{
108 m_iconized =
109 m_maximizeOnShow = FALSE;
5f0b2f22
SC
110 m_macNoEraseUpdateRgn = NewRgn() ;
111 m_macNeedsErasing = false ;
6a17ca35 112 m_macWindow = NULL ;
a15eb0a5
SC
113}
114
118f012e
SC
115class wxMacDeferredWindowDeleter : public wxObject
116{
117public :
118 wxMacDeferredWindowDeleter( WindowRef windowRef )
119 {
120 m_macWindow = windowRef ;
121 }
122 virtual ~wxMacDeferredWindowDeleter()
123 {
124 UMADisposeWindow( (WindowRef) m_macWindow ) ;
125 }
126 protected :
127 WindowRef m_macWindow ;
128} ;
129
a15eb0a5
SC
130bool wxTopLevelWindowMac::Create(wxWindow *parent,
131 wxWindowID id,
132 const wxString& title,
133 const wxPoint& pos,
134 const wxSize& size,
135 long style,
136 const wxString& name)
137{
138 // init our fields
139 Init();
140
141 m_windowStyle = style;
142
143 SetName(name);
144
145 m_windowId = id == -1 ? NewControlId() : id;
146
147 wxTopLevelWindows.Append(this);
148
149 if ( parent )
150 parent->AddChild(this);
151
152 return TRUE;
153}
154
155wxTopLevelWindowMac::~wxTopLevelWindowMac()
156{
6a17ca35
SC
157 if ( m_macWindow )
158 {
159 wxToolTip::NotifyWindowDelete(m_macWindow) ;
118f012e 160 wxPendingDelete.Append( new wxMacDeferredWindowDeleter( (WindowRef) m_macWindow ) ) ;
6a17ca35
SC
161 }
162
5f0b2f22
SC
163 wxRemoveMacWindowAssociation( this ) ;
164
a15eb0a5
SC
165 wxTopLevelWindows.DeleteObject(this);
166
167 if ( wxModelessWindows.Find(this) )
168 wxModelessWindows.DeleteObject(this);
169
170 // If this is the last top-level window, exit.
171 if ( wxTheApp && (wxTopLevelWindows.Number() == 0) )
172 {
173 wxTheApp->SetTopWindow(NULL);
174
175 if ( wxTheApp->GetExitOnFrameDelete() )
176 {
177 wxTheApp->ExitMainLoop() ;
178 }
179 }
76a5e5d2 180 DisposeRgn( (RgnHandle) m_macNoEraseUpdateRgn ) ;
a15eb0a5
SC
181}
182
183
184// ----------------------------------------------------------------------------
185// wxTopLevelWindowMac maximize/minimize
186// ----------------------------------------------------------------------------
187
188void wxTopLevelWindowMac::Maximize(bool maximize)
189{
190 // not available on mac
191}
192
193bool wxTopLevelWindowMac::IsMaximized() const
194{
195 return false ;
196}
197
198void wxTopLevelWindowMac::Iconize(bool iconize)
199{
200 // not available on mac
201}
202
203bool wxTopLevelWindowMac::IsIconized() const
204{
ed60b502 205 // mac dialogs cannot be iconized
a15eb0a5
SC
206 return FALSE;
207}
208
209void wxTopLevelWindowMac::Restore()
210{
211 // not available on mac
212}
213
214// ----------------------------------------------------------------------------
215// wxTopLevelWindowMac misc
216// ----------------------------------------------------------------------------
217
218void wxTopLevelWindowMac::SetIcon(const wxIcon& icon)
219{
220 // this sets m_icon
221 wxTopLevelWindowBase::SetIcon(icon);
222}
5f0b2f22
SC
223
224void wxTopLevelWindowMac::MacCreateRealWindow( const wxString& title,
225 const wxPoint& pos,
226 const wxSize& size,
227 long style,
228 const wxString& name )
229{
230 SetName(name);
231 m_windowStyle = style;
232 m_isShown = FALSE;
233
234 // create frame.
235
236 Rect theBoundsRect;
237
238 m_x = (int)pos.x;
239 m_y = (int)pos.y;
240 if ( m_y < 50 )
241 m_y = 50 ;
242 if ( m_x < 20 )
243 m_x = 20 ;
244
245 m_width = size.x;
246 if (m_width == -1)
247 m_width = 20;
248 m_height = size.y;
249 if (m_height == -1)
250 m_height = 20;
251
252 ::SetRect(&theBoundsRect, m_x, m_y , m_x + m_width, m_y + m_height);
253
254 // translate the window attributes in the appropriate window class and attributes
255
256 WindowClass wclass = 0;
257 WindowAttributes attr = kWindowNoAttributes ;
258
14862aeb 259 if ( HasFlag( wxFRAME_TOOL_WINDOW) /*|| HasFlag(wxTINY_CAPTION_HORIZ) || HasFlag(wxTINY_CAPTION_VERT)*/ )
5f0b2f22
SC
260 {
261 wclass = kFloatingWindowClass ;
262 if ( HasFlag(wxTINY_CAPTION_VERT) )
263 {
264 attr |= kWindowSideTitlebarAttribute ;
265 }
266 }
267 else if ( HasFlag( wxCAPTION ) )
268 {
269 if ( HasFlag( wxDIALOG_MODAL ) )
270 {
60fcb584 271 wclass = kDocumentWindowClass ; // kMovableModalWindowClass ;
5f0b2f22
SC
272 }
273 else
274 {
275 wclass = kDocumentWindowClass ;
276 }
277 }
278 else
279 {
14862aeb 280 wclass = kDocumentWindowClass ;
5f0b2f22
SC
281 }
282
283 if ( HasFlag( wxMINIMIZE_BOX ) || HasFlag( wxMAXIMIZE_BOX ) )
284 {
285 attr |= kWindowFullZoomAttribute ;
286 attr |= kWindowCollapseBoxAttribute ;
287 }
288 if ( HasFlag( wxRESIZE_BORDER ) )
289 {
290 attr |= kWindowResizableAttribute ;
291 }
292 if ( HasFlag( wxSYSTEM_MENU ) )
293 {
294 attr |= kWindowCloseBoxAttribute ;
295 }
296
76a5e5d2 297 ::CreateNewWindow( wclass , attr , &theBoundsRect , (WindowRef*)&m_macWindow ) ;
5f0b2f22
SC
298 wxAssociateWinWithMacWindow( m_macWindow , this ) ;
299 wxString label ;
300 if( wxApp::s_macDefaultEncodingIsPC )
301 label = wxMacMakeMacStringFromPC( title ) ;
302 else
303 label = title ;
76a5e5d2
SC
304 UMASetWTitleC( (WindowRef)m_macWindow , label ) ;
305 ::CreateRootControl( (WindowRef)m_macWindow , (ControlHandle*)&m_macRootControl ) ;
5f0b2f22
SC
306
307 m_macFocus = NULL ;
308}
309
76a5e5d2 310void wxTopLevelWindowMac::MacGetPortParams(WXPOINTPTR localOrigin, WXRECTPTR clipRect, WXHWND *window , wxWindowMac** rootwin)
5f0b2f22 311{
76a5e5d2
SC
312 ((Point*)localOrigin)->h = 0;
313 ((Point*)localOrigin)->v = 0;
314 ((Rect*)clipRect)->left = 0;
315 ((Rect*)clipRect)->top = 0;
316 ((Rect*)clipRect)->right = m_width;
317 ((Rect*)clipRect)->bottom = m_height;
5f0b2f22
SC
318 *window = m_macWindow ;
319 *rootwin = this ;
320}
321
322void wxTopLevelWindowMac::Clear()
323{
7d9d1fd7 324 wxWindow::Clear() ;
5f0b2f22
SC
325}
326
76a5e5d2 327WXWidget wxTopLevelWindowMac::MacGetContainerForEmbedding()
5f0b2f22
SC
328{
329 return m_macRootControl ;
330}
331
332
333void wxTopLevelWindowMac::MacUpdate( long timestamp)
334{
76a5e5d2 335
66a09d47 336 wxMacPortStateHelper help( (GrafPtr) GetWindowPort( (WindowRef) m_macWindow) ) ;
76a5e5d2
SC
337
338 BeginUpdate( (WindowRef)m_macWindow ) ;
5f0b2f22
SC
339
340 RgnHandle updateRgn = NewRgn();
341 RgnHandle diffRgn = NewRgn() ;
342 if ( updateRgn && diffRgn )
343 {
76a5e5d2
SC
344 GetPortVisibleRegion( GetWindowPort( (WindowRef)m_macWindow ), updateRgn );
345 DiffRgn( updateRgn , (RgnHandle) m_macNoEraseUpdateRgn , diffRgn ) ;
5f0b2f22
SC
346 if ( !EmptyRgn( updateRgn ) )
347 {
348 MacRedraw( updateRgn , timestamp , m_macNeedsErasing || !EmptyRgn( diffRgn ) ) ;
349 }
350 }
351 if ( updateRgn )
352 DisposeRgn( updateRgn );
353 if ( diffRgn )
354 DisposeRgn( diffRgn );
76a5e5d2
SC
355 EndUpdate( (WindowRef)m_macWindow ) ;
356 SetEmptyRgn( (RgnHandle) m_macNoEraseUpdateRgn ) ;
5f0b2f22
SC
357 m_macNeedsErasing = false ;
358}
359
360
361// Raise the window to the top of the Z order
362void wxTopLevelWindowMac::Raise()
363{
76a5e5d2 364 ::BringToFront( (WindowRef)m_macWindow ) ;
5f0b2f22
SC
365}
366
367// Lower the window to the bottom of the Z order
368void wxTopLevelWindowMac::Lower()
369{
76a5e5d2 370 ::SendBehind( (WindowRef)m_macWindow , NULL ) ;
5f0b2f22
SC
371}
372
76a5e5d2 373void wxTopLevelWindowMac::MacFireMouseEvent( WXEVENTREF evr )
5f0b2f22 374{
76a5e5d2 375 EventRecord *ev = (EventRecord*) evr ;
5f0b2f22
SC
376 wxMouseEvent event(wxEVT_LEFT_DOWN);
377 bool isDown = !(ev->modifiers & btnState) ; // 1 is for up
378 bool controlDown = ev->modifiers & controlKey ; // for simulating right mouse
379
380 event.m_leftDown = isDown && !controlDown;
381
382 event.m_middleDown = FALSE;
383 event.m_rightDown = isDown && controlDown;
384
385 if ( ev->what == mouseDown )
386 {
387 if ( controlDown )
388 event.SetEventType(wxEVT_RIGHT_DOWN ) ;
389 else
390 event.SetEventType(wxEVT_LEFT_DOWN ) ;
391 }
392 else if ( ev->what == mouseUp )
393 {
394 if ( controlDown )
395 event.SetEventType(wxEVT_RIGHT_UP ) ;
396 else
397 event.SetEventType(wxEVT_LEFT_UP ) ;
398 }
399 else
400 {
401 event.SetEventType(wxEVT_MOTION ) ;
402 }
403
404 event.m_shiftDown = ev->modifiers & shiftKey;
405 event.m_controlDown = ev->modifiers & controlKey;
406 event.m_altDown = ev->modifiers & optionKey;
407 event.m_metaDown = ev->modifiers & cmdKey;
408
409 Point localwhere = ev->where ;
410
411 GrafPtr port ;
412 ::GetPort( &port ) ;
76a5e5d2 413 ::SetPort( UMAGetWindowPort( (WindowRef)m_macWindow ) ) ;
5f0b2f22
SC
414 ::GlobalToLocal( &localwhere ) ;
415 ::SetPort( port ) ;
416
417 if ( ev->what == mouseDown )
418 {
32b5be3d 419 if ( ev->when - gs_lastWhen <= GetDblTime() )
5f0b2f22 420 {
32b5be3d 421 if ( abs( localwhere.h - gs_lastWhere.h ) < 3 && abs( localwhere.v - gs_lastWhere.v ) < 3 )
5f0b2f22 422 {
32b5be3d
RR
423 // This is not right if the second mouse down
424 // event occured in a differen window. We
425 // correct this in MacDispatchMouseEvent.
5f0b2f22
SC
426 if ( controlDown )
427 event.SetEventType(wxEVT_RIGHT_DCLICK ) ;
428 else
429 event.SetEventType(wxEVT_LEFT_DCLICK ) ;
430 }
32b5be3d 431 gs_lastWhen = 0 ;
5f0b2f22
SC
432 }
433 else
434 {
32b5be3d 435 gs_lastWhen = ev->when ;
5f0b2f22 436 }
32b5be3d 437 gs_lastWhere = localwhere ;
5f0b2f22
SC
438 }
439
440 event.m_x = localwhere.h;
441 event.m_y = localwhere.v;
442 event.m_x += m_x;
443 event.m_y += m_y;
444
5f0b2f22
SC
445 event.m_timeStamp = ev->when;
446 event.SetEventObject(this);
447 if ( wxTheApp->s_captureWindow )
448 {
449 int x = event.m_x ;
450 int y = event.m_y ;
451 wxTheApp->s_captureWindow->ScreenToClient( &x , &y ) ;
452 event.m_x = x ;
453 event.m_y = y ;
2e6857fa 454 event.SetEventObject( wxTheApp->s_captureWindow ) ;
5f0b2f22 455 wxTheApp->s_captureWindow->GetEventHandler()->ProcessEvent( event ) ;
ed60b502 456
5f0b2f22
SC
457 if ( ev->what == mouseUp )
458 {
459 wxTheApp->s_captureWindow = NULL ;
460 if ( wxBusyCursorCount == 0 )
461 {
462 m_cursor.MacInstall() ;
463 }
464 }
465 }
466 else
467 {
468 MacDispatchMouseEvent( event ) ;
469 }
470}
471
76a5e5d2 472void wxTopLevelWindowMac::MacMouseDown( WXEVENTREF ev , short part)
5f0b2f22
SC
473{
474 MacFireMouseEvent( ev ) ;
475}
476
76a5e5d2 477void wxTopLevelWindowMac::MacMouseUp( WXEVENTREF ev , short part)
5f0b2f22
SC
478{
479 switch (part)
480 {
481 case inContent:
482 {
483 MacFireMouseEvent( ev ) ;
484 }
485 break ;
486 }
487}
488
76a5e5d2 489void wxTopLevelWindowMac::MacMouseMoved( WXEVENTREF ev , short part)
5f0b2f22
SC
490{
491 switch (part)
492 {
493 case inContent:
494 {
495 MacFireMouseEvent( ev ) ;
496 }
497 break ;
498 }
499}
76a5e5d2 500void wxTopLevelWindowMac::MacActivate( WXEVENTREF ev , bool inIsActivating )
5f0b2f22
SC
501{
502 wxActivateEvent event(wxEVT_ACTIVATE, inIsActivating , m_windowId);
76a5e5d2 503 event.m_timeStamp = ((EventRecord*)ev)->when ;
5f0b2f22
SC
504 event.SetEventObject(this);
505
506 GetEventHandler()->ProcessEvent(event);
507
76a5e5d2 508 UMAHighlightAndActivateWindow( (WindowRef)m_macWindow , inIsActivating ) ;
5f0b2f22 509
1c469f7f 510 MacSuperEnabled( inIsActivating ) ;
5f0b2f22
SC
511}
512
76a5e5d2 513void wxTopLevelWindowMac::MacKeyDown( WXEVENTREF ev )
5f0b2f22
SC
514{
515}
516
517void wxTopLevelWindowMac::SetTitle(const wxString& title)
518{
519 wxWindow::SetTitle( title ) ;
520
521 wxString label ;
522
523 if( wxApp::s_macDefaultEncodingIsPC )
524 label = wxMacMakeMacStringFromPC( m_label ) ;
525 else
526 label = m_label ;
527
76a5e5d2 528 UMASetWTitleC( (WindowRef)m_macWindow , label ) ;
5f0b2f22
SC
529}
530
531bool wxTopLevelWindowMac::Show(bool show)
532{
533 if ( !wxWindow::Show(show) )
534 return FALSE;
535
536 if (show)
537 {
76a5e5d2
SC
538 ::ShowWindow( (WindowRef)m_macWindow ) ;
539 ::SelectWindow( (WindowRef)m_macWindow ) ;
5f0b2f22
SC
540 // no need to generate events here, they will get them triggered by macos
541 // actually they should be , but apparently they are not
542 wxSize size(m_width, m_height);
543 wxSizeEvent event(size, m_windowId);
544 event.SetEventObject(this);
545 GetEventHandler()->ProcessEvent(event);
546 }
547 else
548 {
76a5e5d2 549 ::HideWindow( (WindowRef)m_macWindow ) ;
5f0b2f22
SC
550 }
551
552 if ( !show )
553 {
554 }
555 else
556 {
557 Refresh() ;
558 }
559
560 return TRUE;
561}
562
563void wxTopLevelWindowMac::DoMoveWindow(int x, int y, int width, int height)
564{
565 int former_x = m_x ;
566 int former_y = m_y ;
567 int former_w = m_width ;
568 int former_h = m_height ;
569
570 int actualWidth = width;
571 int actualHeight = height;
572 int actualX = x;
573 int actualY = y;
574
575 if ((m_minWidth != -1) && (actualWidth < m_minWidth))
576 actualWidth = m_minWidth;
577 if ((m_minHeight != -1) && (actualHeight < m_minHeight))
578 actualHeight = m_minHeight;
579 if ((m_maxWidth != -1) && (actualWidth > m_maxWidth))
580 actualWidth = m_maxWidth;
581 if ((m_maxHeight != -1) && (actualHeight > m_maxHeight))
582 actualHeight = m_maxHeight;
583
584 bool doMove = false ;
585 bool doResize = false ;
586
587 if ( actualX != former_x || actualY != former_y )
588 {
589 doMove = true ;
590 }
591 if ( actualWidth != former_w || actualHeight != former_h )
592 {
593 doResize = true ;
594 }
595
596 if ( doMove || doResize )
597 {
598 m_x = actualX ;
599 m_y = actualY ;
600 m_width = actualWidth ;
601 m_height = actualHeight ;
602
603 if ( doMove )
76a5e5d2 604 ::MoveWindow((WindowRef)m_macWindow, m_x, m_y , false); // don't make frontmost
5f0b2f22
SC
605
606 if ( doResize )
76a5e5d2 607 ::SizeWindow((WindowRef)m_macWindow, m_width, m_height , true);
5f0b2f22
SC
608
609 // the OS takes care of invalidating and erasing the new area
610 // we have erased the old one
611
612 if ( IsKindOf( CLASSINFO( wxFrame ) ) )
613 {
614 wxFrame* frame = (wxFrame*) this ;
615 frame->PositionStatusBar();
616 frame->PositionToolBar();
617 }
618 if ( doMove )
619 wxWindowMac::MacTopLevelWindowChangedPosition() ; // like this only children will be notified
620
621 MacRepositionScrollBars() ;
622 if ( doMove )
623 {
624 wxPoint point(m_x, m_y);
625 wxMoveEvent event(point, m_windowId);
626 event.SetEventObject(this);
627 GetEventHandler()->ProcessEvent(event) ;
628 }
629 if ( doResize )
630 {
631 MacRepositionScrollBars() ;
632 wxSize size(m_width, m_height);
633 wxSizeEvent event(size, m_windowId);
634 event.SetEventObject(this);
635 GetEventHandler()->ProcessEvent(event);
636 }
637 }
638
639}
640
641/*
642 * Invalidation Mechanism
643 *
644 * The update mechanism reflects exactely the windows mechanism
645 * the rect gets added to the window invalidate region, if the eraseBackground flag
646 * has been true for any part of the update rgn the background is erased in the entire region
647 * not just in the specified rect.
648 *
649 * In order to achive this, we also have an internal m_macNoEraseUpdateRgn, all rects that have
650 * the eraseBackground flag set to false are also added to this rgn. upon receiving an update event
651 * the update rgn is compared to the m_macNoEraseUpdateRgn and in case they differ, every window
652 * will get the eraseBackground event first
653 */
654
76a5e5d2 655void wxTopLevelWindowMac::MacInvalidate( const WXRECTPTR rect, bool eraseBackground )
5f0b2f22
SC
656{
657 GrafPtr formerPort ;
658 GetPort( &formerPort ) ;
76a5e5d2 659 SetPortWindowPort( (WindowRef)m_macWindow ) ;
5f0b2f22
SC
660
661 m_macNeedsErasing |= eraseBackground ;
662
663 // if we already know that we will have to erase, there's no need to track the rest
664 if ( !m_macNeedsErasing)
665 {
666 // we end only here if eraseBackground is false
667 // if we already have a difference between m_macNoEraseUpdateRgn and UpdateRgn
668 // we will have to erase anyway
669
670 RgnHandle updateRgn = NewRgn();
671 RgnHandle diffRgn = NewRgn() ;
672 if ( updateRgn && diffRgn )
673 {
76a5e5d2 674 GetWindowUpdateRgn( (WindowRef)m_macWindow , updateRgn );
5f0b2f22
SC
675 Point pt = {0,0} ;
676 LocalToGlobal( &pt ) ;
677 OffsetRgn( updateRgn , -pt.h , -pt.v ) ;
76a5e5d2 678 DiffRgn( updateRgn , (RgnHandle) m_macNoEraseUpdateRgn , diffRgn ) ;
5f0b2f22
SC
679 if ( !EmptyRgn( diffRgn ) )
680 {
681 m_macNeedsErasing = true ;
682 }
683 }
684 if ( updateRgn )
685 DisposeRgn( updateRgn );
686 if ( diffRgn )
687 DisposeRgn( diffRgn );
688
689 if ( !m_macNeedsErasing )
690 {
691 RgnHandle rectRgn = NewRgn() ;
76a5e5d2
SC
692 SetRectRgn( rectRgn , ((Rect*)rect)->left , ((Rect*)rect)->top , ((Rect*)rect)->right , ((Rect*)rect)->bottom ) ;
693 UnionRgn( (RgnHandle) m_macNoEraseUpdateRgn , rectRgn , (RgnHandle) m_macNoEraseUpdateRgn ) ;
5f0b2f22
SC
694 DisposeRgn( rectRgn ) ;
695 }
696 }
76a5e5d2 697 InvalWindowRect( (WindowRef)m_macWindow , (Rect*)rect ) ;
5f0b2f22 698 // turn this on to debug the refreshing cycle
34dc8f91 699#if wxMAC_DEBUG_REDRAW
5f0b2f22
SC
700 PaintRect( rect ) ;
701#endif
702 SetPort( formerPort ) ;
703}
a07c1212 704