]> git.saurik.com Git - wxWidgets.git/blobdiff - src/mac/carbon/window.cpp
invalidate m_selection in DoRemovePage(), not in DeletePage() (replaces patch 998984)
[wxWidgets.git] / src / mac / carbon / window.cpp
index 9d20d9a04c43c1c1a4570f38984fe414570cb44b..04eeaf07b07c2cd4fe13dd66cd34834474e21580 100644 (file)
@@ -82,8 +82,6 @@ BEGIN_EVENT_TABLE(wxWindowMac, wxWindowBase)
     EVT_NC_PAINT(wxWindowMac::OnNcPaint)
     EVT_ERASE_BACKGROUND(wxWindowMac::OnEraseBackground)
 // TODO    EVT_PAINT(wxWindowMac::OnPaint)
     EVT_NC_PAINT(wxWindowMac::OnNcPaint)
     EVT_ERASE_BACKGROUND(wxWindowMac::OnEraseBackground)
 // TODO    EVT_PAINT(wxWindowMac::OnPaint)
-    EVT_SYS_COLOUR_CHANGED(wxWindowMac::OnSysColourChanged)
-    EVT_INIT_DIALOG(wxWindowMac::OnInitDialog)
     EVT_SET_FOCUS(wxWindowMac::OnSetFocus)
     EVT_KILL_FOCUS(wxWindowMac::OnSetFocus)
     EVT_MOUSE_EVENTS(wxWindowMac::OnMouseEvent)
     EVT_SET_FOCUS(wxWindowMac::OnSetFocus)
     EVT_KILL_FOCUS(wxWindowMac::OnSetFocus)
     EVT_MOUSE_EVENTS(wxWindowMac::OnMouseEvent)
@@ -151,13 +149,21 @@ static pascal OSStatus wxMacWindowControlEventHandler( EventHandlerCallRef handl
         case kEventControlDraw :
             {
                 RgnHandle updateRgn = NULL ;
         case kEventControlDraw :
             {
                 RgnHandle updateRgn = NULL ;
-
+                RgnHandle allocatedRgn = NULL ;
                 wxRegion visRegion = thisWindow->MacGetVisibleRegion() ;
                 if ( cEvent.GetParameter<RgnHandle>(kEventParamRgnHandle, &updateRgn) != noErr ) 
                 {
                     updateRgn = (RgnHandle) visRegion.GetWXHRGN() ;
                 }
                 wxRegion visRegion = thisWindow->MacGetVisibleRegion() ;
                 if ( cEvent.GetParameter<RgnHandle>(kEventParamRgnHandle, &updateRgn) != noErr ) 
                 {
                     updateRgn = (RgnHandle) visRegion.GetWXHRGN() ;
                 }
-                // GrafPtr myport = cEvent.GetParameter<GrafPtr>(kEventParamGrafPort,typeGrafPtr) ;
+                else
+                {
+                    if ( thisWindow->MacGetLeftBorderSize() != 0 || thisWindow->MacGetTopBorderSize() != 0 )
+                    {
+                        allocatedRgn = NewRgn() ;
+                        CopyRgn( updateRgn , allocatedRgn ) ;
+                        OffsetRgn( updateRgn , thisWindow->MacGetLeftBorderSize() , thisWindow->MacGetTopBorderSize() ) ;
+                    }
+                }
 
 #if 0 
               // in case we would need a coregraphics compliant background erase first
 
 #if 0 
               // in case we would need a coregraphics compliant background erase first
@@ -184,6 +190,8 @@ static pascal OSStatus wxMacWindowControlEventHandler( EventHandlerCallRef handl
 #endif
                 if ( thisWindow->MacDoRedraw( updateRgn , cEvent.GetTicks() ) )
                     result = noErr ;
 #endif
                 if ( thisWindow->MacDoRedraw( updateRgn , cEvent.GetTicks() ) )
                     result = noErr ;
+                if ( allocatedRgn )
+                    DisposeRgn( allocatedRgn ) ;
             }
             break ;
         case kEventControlVisibilityChanged :
             }
             break ;
         case kEventControlVisibilityChanged :
@@ -889,11 +897,14 @@ bool wxWindowMac::SetBackgroundColour(const wxColour& col )
     }
     MacSetBackgroundBrush( brush ) ;
         
     }
     MacSetBackgroundBrush( brush ) ;
         
-    MacUpdateControlFont() ;
-    
     return true ;
 }
 
     return true ;
 }
 
+void wxWindowMac::MacSetBackgroundBrush( const wxBrush &brush )
+{
+    m_macBackgroundBrush = brush ;
+    m_peer->SetBackground( brush ) ;
+}
 
 bool wxWindowMac::MacCanFocus() const
 {
 
 bool wxWindowMac::MacCanFocus() const
 {
@@ -991,6 +1002,9 @@ void wxWindowMac::DragAcceptFiles(bool accept)
     // TODO
 }
 
     // TODO
 }
 
+// Returns the size of the native control. In the case of the toplevel window
+// this is the content area root control
+
 void wxWindowMac::MacGetPositionAndSizeFromControl(int& x, int& y,
                                            int& w, int& h) const 
 {
 void wxWindowMac::MacGetPositionAndSizeFromControl(int& x, int& y,
                                            int& w, int& h) const 
 {
@@ -1013,6 +1027,8 @@ void wxWindowMac::MacGetPositionAndSizeFromControl(int& x, int& y,
     }
 }
 
     }
 }
 
+// From a wx position / size calculate the appropriate size of the native control
 bool wxWindowMac::MacGetBoundsForControl(const wxPoint& pos,
                                        const wxSize& size,
                                        int& x, int& y,
 bool wxWindowMac::MacGetBoundsForControl(const wxPoint& pos,
                                        const wxSize& size,
                                        int& x, int& y,
@@ -1194,8 +1210,8 @@ void wxWindowMac::MacWindowToRootWindow( int *x , int *y ) const
     {
         Rect bounds ;
         m_peer->GetRect( &bounds ) ;   
     {
         Rect bounds ;
         m_peer->GetRect( &bounds ) ;   
-        if(x)   *x += bounds.left ;
-        if(y)   *y += bounds.top ;
+        if(x)   *x += bounds.left - MacGetLeftBorderSize() ;
+        if(y)   *y += bounds.top - MacGetTopBorderSize() ;
     }
 #endif
 }
     }
 #endif
 }
@@ -1231,8 +1247,8 @@ void wxWindowMac::MacRootWindowToWindow( int *x , int *y ) const
     {
         Rect bounds ;
         m_peer->GetRect( &bounds ) ;   
     {
         Rect bounds ;
         m_peer->GetRect( &bounds ) ;   
-        if(x)   *x -= bounds.left ;
-        if(y)   *y -= bounds.top ;
+        if(x)   *x -= bounds.left + MacGetLeftBorderSize() ;
+        if(y)   *y -= bounds.top + MacGetTopBorderSize() ;
     }
 #endif
 }
     }
 #endif
 }
@@ -1327,10 +1343,10 @@ void wxWindowMac::DoGetClientSize(int *x, int *y) const
 #endif 
     ww = content.right - content.left ;
     hh = content.bottom - content.top ;
 #endif 
     ww = content.right - content.left ;
     hh = content.bottom - content.top ;
-    
+    /*
     ww -= MacGetLeftBorderSize(  )  + MacGetRightBorderSize(  ) ;
     hh -= MacGetTopBorderSize(  ) + MacGetBottomBorderSize( );
     ww -= MacGetLeftBorderSize(  )  + MacGetRightBorderSize(  ) ;
     hh -= MacGetTopBorderSize(  ) + MacGetBottomBorderSize( );
-
+    */
     if ( (m_vScrollBar && m_vScrollBar->IsShown()) || (m_hScrollBar  && m_hScrollBar->IsShown()) )
     {
         int x1 = 0 ;
     if ( (m_vScrollBar && m_vScrollBar->IsShown()) || (m_hScrollBar  && m_hScrollBar->IsShown()) )
     {
         int x1 = 0 ;
@@ -2387,8 +2403,6 @@ void wxWindowMac::OnSetFocus(wxFocusEvent& event)
     if ( MacGetTopLevelWindow() && m_peer->NeedsFocusRect() )
     {
         wxMacWindowStateSaver sv( this ) ;
     if ( MacGetTopLevelWindow() && m_peer->NeedsFocusRect() )
     {
         wxMacWindowStateSaver sv( this ) ;
-//        wxWindowDC dc(this) ;
-//        wxMacPortSetter helper(&dc) ;
 
         int w , h ;
         int x , y ;
 
         int w , h ;
         int x , y ;
@@ -2884,17 +2898,11 @@ long wxWindowMac::MacGetLeftBorderSize( ) const
     if (m_windowStyle & wxRAISED_BORDER || m_windowStyle & wxSUNKEN_BORDER )
     {
         SInt32 border = 3 ;
     if (m_windowStyle & wxRAISED_BORDER || m_windowStyle & wxSUNKEN_BORDER )
     {
         SInt32 border = 3 ;
-#if 0 // wxMAC_USE_THEME_BORDER
-          GetThemeMetric( kThemeMetricListBoxFrameOutset , &border ) ;
-#endif
           return border ;
     }
     else if (  m_windowStyle &wxDOUBLE_BORDER)
     {
           SInt32 border = 3 ;
           return border ;
     }
     else if (  m_windowStyle &wxDOUBLE_BORDER)
     {
           SInt32 border = 3 ;
-#if 0 // wxMAC_USE_THEME_BORDER
-          GetThemeMetric( kThemeMetricEditTextFrameOutset , &border ) ;
-#endif
           return border ;
     }
     else if (m_windowStyle &wxSIMPLE_BORDER)
           return border ;
     }
     else if (m_windowStyle &wxSIMPLE_BORDER)
@@ -2924,7 +2932,7 @@ long wxWindowMac::MacGetBottomBorderSize( ) const
 
 long wxWindowMac::MacRemoveBordersFromStyle( long style )
 {
 
 long wxWindowMac::MacRemoveBordersFromStyle( long style )
 {
-    return style & ~( wxDOUBLE_BORDER | wxSUNKEN_BORDER | wxRAISED_BORDER | wxBORDER | wxSTATIC_BORDER ) ;
+    return style & ~wxBORDER_MASK ;
 }
 
 // Find the wxWindowMac at the current mouse position, returning the mouse
 }
 
 // Find the wxWindowMac at the current mouse position, returning the mouse