]> git.saurik.com Git - wxWidgets.git/blobdiff - src/mac/window.cpp
tried to fix the accel string drawing in the owner drawn menu items
[wxWidgets.git] / src / mac / window.cpp
index 382b71024f1d48411f461dc841eba2c322d464b7..48ac3429cf94573b01e0f0a926d91823f706f337 100644 (file)
@@ -108,11 +108,15 @@ void wxRemoveMacWindowAssociation(wxWindow *win)
 // constructors and such
 // ----------------------------------------------------------------------------
 
+WindowRef wxWindow::s_macWindowInUpdate = NULL;
+
 void wxWindow::Init()
 {
     // generic
     InitBase();
 
+    m_macEraseOnRedraw = true ;
+
     // MSW specific
     m_doubleClickAllowed = 0;
     m_winCaptured = FALSE;
@@ -130,6 +134,7 @@ void wxWindow::Init()
     m_isShown = TRUE;
 
        m_macWindowData = NULL ;
+       m_macEraseOnRedraw = true ;
 
        m_x = 0;
        m_y = 0 ;       
@@ -408,11 +413,19 @@ void wxWindow::MacRootWindowToClient( int *x , int *y ) const
 
 bool wxWindow::SetCursor(const wxCursor& cursor)
 {
-   if ( !wxWindowBase::SetCursor(cursor) )
-   {
-       // no change
+    if (m_cursor == cursor)
        return FALSE;
-   }
+
+    if (wxNullCursor == cursor)
+    {
+       if ( ! wxWindowBase::SetCursor( *wxSTANDARD_CURSOR ) )
+        return FALSE ;
+    }
+    else
+    {
+       if ( ! wxWindowBase::SetCursor( cursor ) )
+        return FALSE ;
+    }
 
   wxASSERT_MSG( m_cursor.Ok(),
                   wxT("cursor must be valid after call to the base version"));
@@ -427,7 +440,7 @@ bool wxWindow::SetCursor(const wxCursor& cursor)
   {
        if ( mouseWin == this && !wxIsBusy() )
        {
-               cursor.MacInstall() ;
+               m_cursor.MacInstall() ;
        }
   }
 
@@ -811,6 +824,7 @@ void wxWindow::GetTextExtent(const wxString& string, int *x, int *y,
 
 void wxWindow::MacEraseBackground( Rect *rect )
 {
+/*
        WindowRef window = GetMacRootWindow() ;
        if ( m_backgroundColour == wxSystemSettings::GetSystemColour(wxSYS_COLOUR_APPWORKSPACE) )
        {
@@ -878,6 +892,7 @@ void wxWindow::MacEraseBackground( Rect *rect )
                        }
                }
        }
+*/
 }
 
 void wxWindow::Refresh(bool eraseBack, const wxRect *rect)
@@ -895,6 +910,10 @@ void wxWindow::Refresh(bool eraseBack, const wxRect *rect)
        }
        InvalWindowRect( GetMacRootWindow() , &clientrect ) ;
        }
+       if ( !eraseBack )
+               m_macEraseOnRedraw = false ;
+       else
+               m_macEraseOnRedraw = true ;
 }
 
 // Responds to colour changes: passes event on to children.
@@ -1760,6 +1779,9 @@ void wxWindow::MacRedraw( RgnHandle updatergn , long time)
 {
        // updatergn is always already clipped to our boundaries
        WindowRef window = GetMacRootWindow() ;
+       // ownUpdateRgn is the area that this window has to invalidate i.e. its own area without its children
+       RgnHandle ownUpdateRgn = NewRgn() ;
+       CopyRgn( updatergn , ownUpdateRgn ) ;
        wxWindow* win = wxFindWinFromMacWindow( window ) ;
        {
                wxMacDrawingHelper focus( this ) ; // was client
@@ -1824,23 +1846,45 @@ void wxWindow::MacRedraw( RgnHandle updatergn , long time)
                        {
                                RGBBackColor( &m_backgroundColour.GetPixel()) ;
                        }
+            // subtract all non transparent children from updatergn
+
+           RgnHandle childarea = NewRgn() ;
+               for (wxNode *node = GetChildren().First(); node; node = node->Next())
+               {
+                       wxWindow *child = (wxWindow*)node->Data();
+                       // eventually test for transparent windows
+                       if ( child->GetMacRootWindow() == window && child->IsShown() )
+                       {
+                           if ( !child->IsKindOf( CLASSINFO( wxNotebook ) ) && !child->IsKindOf( CLASSINFO( wxTabCtrl ) ) )
+                           {
+                               SetRectRgn( childarea , child->m_x , child->m_y , child->m_x + child->m_width ,  child->m_y + child->m_height ) ;
+                               DiffRgn( ownUpdateRgn , childarea , ownUpdateRgn ) ;
+                           }
+                       }
+               }               
+               DisposeRgn( childarea ) ;
+
                        if ( GetParent() && m_backgroundColour != GetParent()->GetBackgroundColour() )
                                eraseBackground = true ;
                        SetClip( updatergn ) ;
-                       if ( eraseBackground )
-                       {
-                               EraseRgn( updatergn ) ; 
-                       }
+                       if ( m_macEraseOnRedraw ) {
+                       if ( eraseBackground  )
+                       {
+                               EraseRgn( ownUpdateRgn ) ;      
+                       }
+               }
+               else {
+                   m_macEraseOnRedraw = true ;
+               }
                }
 
-               m_macUpdateRgn = updatergn ;
                {
                        RgnHandle newupdate = NewRgn() ;
                        wxSize point = GetClientSize() ;
                        wxPoint origin = GetClientAreaOrigin() ;
 
                        SetRectRgn( newupdate , origin.x , origin.y , origin.x + point.x , origin.y+point.y ) ;
-                       SectRgn( newupdate , m_macUpdateRgn , newupdate ) ;
+                       SectRgn( newupdate , ownUpdateRgn , newupdate ) ;
                        OffsetRgn( newupdate , -origin.x , -origin.y ) ;
                        m_updateRegion = newupdate ;
                        DisposeRgn( newupdate ) ;
@@ -1860,7 +1904,7 @@ void wxWindow::MacRedraw( RgnHandle updatergn , long time)
        {
                wxWindow *child = (wxWindow*)node->Data();
                SetRectRgn( childupdate , child->m_x , child->m_y , child->m_x + child->m_width ,  child->m_y + child->m_height ) ;
-               SectRgn( childupdate , m_macUpdateRgn , childupdate ) ;
+               SectRgn( childupdate , updatergn , childupdate ) ;
                OffsetRgn( childupdate , -child->m_x , -child->m_y ) ;
                if ( child->GetMacRootWindow() == window && child->IsShown() && !EmptyRgn( childupdate ) )
                {
@@ -2310,37 +2354,7 @@ long wxWindow::MacRemoveBordersFromStyle( long style )
 {
        return style & ~( wxDOUBLE_BORDER | wxSUNKEN_BORDER | wxRAISED_BORDER | wxBORDER | wxSTATIC_BORDER ) ;
 }
-/*
-wxMacFocusHelper::wxMacFocusHelper( wxWindow * theWindow ) 
-{
-       m_ok = false ;
-       Point localOrigin ;
-       Rect clipRect ;
-       WindowRef window ;
-       wxWindow *rootwin ;
-       m_currentPort = NULL ;
-       GetPort( &m_formerPort ) ;
-       if ( theWindow )
-       {
-       
-               theWindow->MacGetPortParams( &localOrigin , &clipRect , &window , &rootwin) ;
-               m_currentPort = UMAGetWindowPort( window ) ;
-               theWindow->MacSetPortFocusParams( localOrigin, clipRect, window , rootwin ) ; 
-               m_ok = true ;
-       }
-}
-       
-wxMacFocusHelper::~wxMacFocusHelper() 
-{
-       if ( m_ok )
-       {
-               SetPort( m_currentPort ) ;
-               SetOrigin( 0 , 0 ) ;
-       }
-       if ( m_formerPort != m_currentPort )
-               SetPort( m_formerPort ) ;
-}
-*/
+
 
 wxMacDrawingHelper::wxMacDrawingHelper( wxWindow * theWindow ) 
 {
@@ -2374,7 +2388,6 @@ wxMacDrawingHelper::~wxMacDrawingHelper()
                Rect portRect ;
                GetPortBounds( m_currentPort , &portRect ) ;
                ClipRect( &portRect ) ;
-               wxDC::MacInvalidateSetup() ;    
        }
                
        if ( m_formerPort != m_currentPort )