]> git.saurik.com Git - wxWidgets.git/blobdiff - src/mac/carbon/window.cpp
warning fix
[wxWidgets.git] / src / mac / carbon / window.cpp
index ec1e62b0d177810a6341d9a47dcd6c9149644596..95e1077a9b48bc445a105060c375ea6bfdfad10e 100644 (file)
@@ -152,6 +152,20 @@ void wxWindow::Init()
 // Destructor
 wxWindow::~wxWindow()
 {
 // Destructor
 wxWindow::~wxWindow()
 {
+    // deleting a window while it is shown invalidates the region
+    if ( IsShown() ) {
+        wxWindow* iter = this ;
+        while( iter ) {
+            if ( iter->m_macWindowData )
+            {
+                Refresh() ;
+                break ;
+            }
+            iter = iter->GetParent() ;
+            
+        }
+    }
+    
     m_isBeingDeleted = TRUE;
 
        if ( s_lastMouseWindow == this )
     m_isBeingDeleted = TRUE;
 
        if ( s_lastMouseWindow == this )
@@ -629,7 +643,7 @@ void wxWindow::DoSetSize(int x, int y, int width, int height, int sizeFlags)
                        if ( focus.Ok() )
                        {
                                Rect clientrect = { 0 , 0 , m_height , m_width } ;
                        if ( focus.Ok() )
                        {
                                Rect clientrect = { 0 , 0 , m_height , m_width } ;
-                               ClipRect( &clientrect ) ;
+                               // ClipRect( &clientrect ) ;
                        InvalWindowRect( GetMacRootWindow() , &clientrect ) ;
                        }
                }
                        InvalWindowRect( GetMacRootWindow() , &clientrect ) ;
                        }
                }
@@ -664,7 +678,7 @@ void wxWindow::DoSetSize(int x, int y, int width, int height, int sizeFlags)
                                if ( focus.Ok() )
                                {
                                        Rect clientrect = { 0 , 0 , m_height , m_width } ;
                                if ( focus.Ok() )
                                {
                                        Rect clientrect = { 0 , 0 , m_height , m_width } ;
-                                       ClipRect( &clientrect ) ;
+                                       // ClipRect( &clientrect ) ;
                                InvalWindowRect( GetMacRootWindow() , &clientrect ) ;
                                }
                        }
                                InvalWindowRect( GetMacRootWindow() , &clientrect ) ;
                                }
                        }
@@ -754,8 +768,6 @@ bool wxWindow::Show(bool show)
        }
        MacSuperShown( show ) ;
        Refresh() ;
        }
        MacSuperShown( show ) ;
        Refresh() ;
-       if(m_macWindowData)
-               MacUpdateImmediately() ;
 
     return TRUE;
 }
 
     return TRUE;
 }
@@ -897,11 +909,14 @@ void wxWindow::MacEraseBackground( Rect *rect )
 
 void wxWindow::Refresh(bool eraseBack, const wxRect *rect)
 {
 
 void wxWindow::Refresh(bool eraseBack, const wxRect *rect)
 {
+//    if ( !IsShown() )
+//        return ;
+        
        wxMacDrawingHelper focus( this ) ;
        if ( focus.Ok() )
        {
                Rect clientrect = { 0 , 0 , m_height , m_width } ;
        wxMacDrawingHelper focus( this ) ;
        if ( focus.Ok() )
        {
                Rect clientrect = { 0 , 0 , m_height , m_width } ;
-               ClipRect( &clientrect ) ;
+               // ClipRect( &clientrect ) ;
 
        if ( rect )
        {
 
        if ( rect )
        {
@@ -1141,6 +1156,7 @@ void  wxWindow::MacCreateRealWindow( const wxString& title,
        UMACreateRootControl( m_macWindowData->m_macWindow , &m_macWindowData->m_macRootControl ) ;
 
        m_macWindowData->m_macFocus = NULL ;
        UMACreateRootControl( m_macWindowData->m_macWindow , &m_macWindowData->m_macRootControl ) ;
 
        m_macWindowData->m_macFocus = NULL ;
+       m_macWindowData->m_macHasReceivedFirstActivate = true ;
 }
 
 void wxWindow::MacPaint( wxPaintEvent &event ) 
 }
 
 void wxWindow::MacPaint( wxPaintEvent &event ) 
@@ -1692,8 +1708,12 @@ void wxWindow::MacFireMouseEvent( EventRecord *ev )
                                else
                                        event.SetEventType(wxEVT_LEFT_DCLICK ) ;
                        }
                                else
                                        event.SetEventType(wxEVT_LEFT_DCLICK ) ;
                        }
+                   lastWhen = 0 ;
+               }
+               else
+               {
+                   lastWhen = ev->when ;
                }
                }
-               lastWhen = ev->when ;
                lastWhere = localwhere ;
        }
 
                lastWhere = localwhere ;
        }
 
@@ -1766,13 +1786,18 @@ void wxWindow::MacMouseMoved( EventRecord *ev , short part)
 }
 void wxWindow::MacActivate( EventRecord *ev , bool inIsActivating )
 {
 }
 void wxWindow::MacActivate( EventRecord *ev , bool inIsActivating )
 {
+    if ( !m_macWindowData->m_macHasReceivedFirstActivate )
+        m_macWindowData->m_macHasReceivedFirstActivate = true ;
+    
        wxActivateEvent event(wxEVT_ACTIVATE, inIsActivating , m_windowId);
        event.m_timeStamp = ev->when ;
        event.SetEventObject(this);
        
        GetEventHandler()->ProcessEvent(event);
        
        wxActivateEvent event(wxEVT_ACTIVATE, inIsActivating , m_windowId);
        event.m_timeStamp = ev->when ;
        event.SetEventObject(this);
        
        GetEventHandler()->ProcessEvent(event);
        
+    Refresh(false) ;
        UMAHighlightAndActivateWindow( m_macWindowData->m_macWindow , inIsActivating ) ;
        UMAHighlightAndActivateWindow( m_macWindowData->m_macWindow , inIsActivating ) ;
+//     MacUpdateImmediately() ;
 }
 
 void wxWindow::MacRedraw( RgnHandle updatergn , long time)
 }
 
 void wxWindow::MacRedraw( RgnHandle updatergn , long time)
@@ -1847,7 +1872,7 @@ void wxWindow::MacRedraw( RgnHandle updatergn , long time)
                                RGBBackColor( &m_backgroundColour.GetPixel()) ;
                        }
             // subtract all non transparent children from updatergn
                                RGBBackColor( &m_backgroundColour.GetPixel()) ;
                        }
             // subtract all non transparent children from updatergn
-
+            
            RgnHandle childarea = NewRgn() ;
                for (wxNode *node = GetChildren().First(); node; node = node->Next())
                {
            RgnHandle childarea = NewRgn() ;
                for (wxNode *node = GetChildren().First(); node; node = node->Next())
                {
@@ -1855,7 +1880,7 @@ void wxWindow::MacRedraw( RgnHandle updatergn , long time)
                        // eventually test for transparent windows
                        if ( child->GetMacRootWindow() == window && child->IsShown() )
                        {
                        // eventually test for transparent windows
                        if ( child->GetMacRootWindow() == window && child->IsShown() )
                        {
-                           if ( !child->IsKindOf( CLASSINFO( wxNotebook ) ) && !child->IsKindOf( CLASSINFO( wxTabCtrl ) ) )
+                           if ( child->GetBackgroundColour() != m_backgroundColour && !child->IsKindOf( CLASSINFO( wxControl ) ) && ((wxControl*)child)->GetMacControl() )
                            {
                                SetRectRgn( childarea , child->m_x , child->m_y , child->m_x + child->m_width ,  child->m_y + child->m_height ) ;
                                DiffRgn( ownUpdateRgn , childarea , ownUpdateRgn ) ;
                            {
                                SetRectRgn( childarea , child->m_x , child->m_y , child->m_x + child->m_width ,  child->m_y + child->m_height ) ;
                                DiffRgn( ownUpdateRgn , childarea , ownUpdateRgn ) ;
@@ -1938,7 +1963,7 @@ void wxWindow::MacUpdateImmediately()
                    GetPortVisibleRegion( GetWindowPort( window ), region );
 
                                // if windowshade gives incompatibility , take the follwing out
                    GetPortVisibleRegion( GetWindowPort( window ), region );
 
                                // if windowshade gives incompatibility , take the follwing out
-                   if ( !EmptyRgn( region ) )
+                   if ( !EmptyRgn( region ) && win->m_macWindowData->m_macHasReceivedFirstActivate )
                    {
                                        win->MacRedraw( region , wxTheApp->sm_lastMessageTime ) ;
                    }
                    {
                                        win->MacRedraw( region , wxTheApp->sm_lastMessageTime ) ;
                    }
@@ -1969,7 +1994,7 @@ void wxWindow::MacUpdate( EventRecord *ev )
             GetPortVisibleRegion( GetWindowPort( window ), region );
 
                        // if windowshade gives incompatibility , take the follwing out
             GetPortVisibleRegion( GetWindowPort( window ), region );
 
                        // if windowshade gives incompatibility , take the follwing out
-            if ( !EmptyRgn( region ) )
+            if ( !EmptyRgn( region ) && win->m_macWindowData->m_macHasReceivedFirstActivate )
             {
                                MacRedraw( region , ev->when ) ;
             }
             {
                                MacRedraw( region , ev->when ) ;
             }