]> git.saurik.com Git - wxWidgets.git/blobdiff - src/mac/carbon/window.cpp
added wxWS_EX_VALIDATE_RECURSIVELY
[wxWidgets.git] / src / mac / carbon / window.cpp
index 32633ad95db0915b6b892f21301d70b7c2504da4..07696993a6d6f52c9adecc6f6664eb122f7315de 100644 (file)
@@ -659,7 +659,9 @@ void wxAssociateControlWithMacControl(ControlRef inControl, wxWindow *control)
 
 void wxRemoveMacControlAssociation(wxWindow *control)
 {
-    wxWinMacControlList.DeleteObject(control);
+    // remove all associations pointing to us
+    while ( wxWinMacControlList.DeleteObject(control) )
+        {}
 }
 #else
 
@@ -686,13 +688,22 @@ void wxAssociateControlWithMacControl(ControlRef inControl, wxWindow *control)
 void wxRemoveMacControlAssociation(wxWindow *control)
 {
    // iterate over all the elements in the class
-    MacControlMap::iterator it;
-    for ( it = wxWinMacControlList.begin(); it != wxWinMacControlList.end(); ++it )
+    // is the iterator stable ? as we might have two associations pointing to the same wxWindow
+    // we should go on...
+
+    bool found = true ;
+    while( found )
     {
-        if ( it->second == control )
+        found = false ;
+        MacControlMap::iterator it;
+        for ( it = wxWinMacControlList.begin(); it != wxWinMacControlList.end(); ++it )
         {
-            wxWinMacControlList.erase(it);
-            break;
+            if ( it->second == control )
+            {
+                wxWinMacControlList.erase(it);
+                found = true ;
+                break;
+            }
         }
     }
 }
@@ -1202,10 +1213,14 @@ void wxWindowMac::DoGetPosition(int *x, int *y) const
 {
     Rect bounds ;
     m_peer->GetRect( &bounds ) ;
-
+    
     int x1 = bounds.left ;
     int y1 = bounds.top ;
 
+    // get the wx window position from the native one
+    x1 -= MacGetLeftBorderSize() ;
+    y1 -= MacGetTopBorderSize() ;
+
     if ( !IsTopLevel() )
     {
         wxWindow *parent = GetParent();
@@ -2249,12 +2264,15 @@ void wxWindowMac::MacPaintBorders( int leftOrigin , int rightOrigin )
     bool hasBothScrollbars = ( m_hScrollBar && m_hScrollBar->IsShown()) && ( m_vScrollBar && m_vScrollBar->IsShown()) ;
 
     m_peer->GetRect( &rect ) ;
-    InsetRect( &rect, -MacGetLeftBorderSize() , -MacGetTopBorderSize() ) ;
+    // back to the surrounding frame rectangle
+    InsetRect( &rect, -1 , -1 ) ;
 
 #if wxMAC_USE_CORE_GRAPHICS && MAC_OS_X_VERSION_MAX_ALLOWED >= MAC_OS_X_VERSION_10_3
     if ( UMAGetSystemVersion() >= 0x1030  )
     {
-        Rect srect = rect ;
+        CGRect cgrect = CGRectMake( rect.left , rect.top , rect.right - rect.left ,
+            rect.bottom - rect.top ) ;
+
         HIThemeFrameDrawInfo info ;
         memset( &info, 0 , sizeof( info ) ) ;
         
@@ -2262,49 +2280,31 @@ void wxWindowMac::MacPaintBorders( int leftOrigin , int rightOrigin )
         info.kind = 0 ;
         info.state = IsEnabled() ? kThemeStateActive : kThemeStateInactive ;
         info.isFocused = hasFocus ;
-        bool draw = false ;
 
         CGContextRef cgContext = (CGContextRef) GetParent()->MacGetCGContextRef() ;
         wxASSERT( cgContext ) ;
          
         if (HasFlag(wxRAISED_BORDER) || HasFlag( wxSUNKEN_BORDER) || HasFlag(wxDOUBLE_BORDER) )
         {
-            SInt32 border = 0 ;
-            GetThemeMetric( kThemeMetricEditTextFrameOutset , &border ) ;
-            InsetRect( &srect , border , border );
             info.kind = kHIThemeFrameTextFieldSquare ;
-            draw = true ;
+            HIThemeDrawFrame( &cgrect , &info , cgContext , kHIThemeOrientationNormal ) ;
         }
         else if (HasFlag(wxSIMPLE_BORDER))
         {
-            SInt32 border = 0 ;
-            GetThemeMetric( kThemeMetricListBoxFrameOutset , &border ) ;
-            InsetRect( &srect , border , border );
             info.kind = kHIThemeFrameListBox ;
-            draw = true ;
-        }
-            
-        if ( draw )
-        {
-            CGRect cgrect = CGRectMake( srect.left , srect.top , srect.right - srect.left ,
-                srect.bottom - srect.top ) ;
             HIThemeDrawFrame( &cgrect , &info , cgContext , kHIThemeOrientationNormal ) ;
         }
         else if ( hasFocus )
         {
-            srect = rect ;
-            CGRect cgrect = CGRectMake( srect.left , srect.top , srect.right - srect.left ,
-                srect.bottom - srect.top ) ;
             HIThemeDrawFocusRect( &cgrect , true , cgContext , kHIThemeOrientationNormal ) ;
         }
         
         m_peer->GetRect( &rect ) ;
         if ( hasBothScrollbars )
         {
-            srect = rect ;
             int size = m_hScrollBar->GetWindowVariant() == wxWINDOW_VARIANT_NORMAL ? 16 : 12 ;
-            CGRect cgrect = CGRectMake( srect.right - size , srect.bottom - size , size , size ) ;
-            CGPoint cgpoint = CGPointMake( srect.right - size , srect.bottom - size ) ;
+            CGRect cgrect = CGRectMake( rect.right - size , rect.bottom - size , size , size ) ;
+            CGPoint cgpoint = CGPointMake( rect.right - size , rect.bottom - size ) ;
             HIThemeGrowBoxDrawInfo info ; 
             memset( &info, 0 , sizeof( info ) ) ;
             info.version = 0 ;
@@ -2328,26 +2328,18 @@ void wxWindowMac::MacPaintBorders( int leftOrigin , int rightOrigin )
 
         if (HasFlag(wxRAISED_BORDER) || HasFlag( wxSUNKEN_BORDER) || HasFlag(wxDOUBLE_BORDER) )
         {
-            Rect srect = rect ;
-            SInt32 border = 0 ;
-            GetThemeMetric( kThemeMetricEditTextFrameOutset , &border ) ;
-            InsetRect( &srect , border , border );
-            DrawThemeEditTextFrame(&srect,IsEnabled() ? kThemeStateActive : kThemeStateInactive) ;
+            DrawThemeEditTextFrame(&rect,IsEnabled() ? kThemeStateActive : kThemeStateInactive) ;
         }
         else if (HasFlag(wxSIMPLE_BORDER))
         {
-            Rect srect = rect ;
-            SInt32 border = 0 ;
-            GetThemeMetric( kThemeMetricListBoxFrameOutset , &border ) ;
-            InsetRect( &srect , border , border );
             DrawThemeListBoxFrame(&rect,IsEnabled() ? kThemeStateActive : kThemeStateInactive) ;
         }
         
         if ( hasFocus )
         {
-            Rect srect = rect ;
-            DrawThemeFocusRect( &srect , true ) ;
+            DrawThemeFocusRect( &rect , true ) ;
         }
+
         if ( hasBothScrollbars )
         {
             // GetThemeStandaloneGrowBoxBounds    
@@ -2577,7 +2569,8 @@ void wxWindowMac::OnSetFocus(wxFocusEvent& event)
         wxMacWindowStateSaver sv( this ) ;
         Rect rect ;
         m_peer->GetRect( &rect ) ;
-        InsetRect( &rect, -MacGetLeftBorderSize() , -MacGetTopBorderSize() ) ;
+        // auf den umgebenden Rahmen zur\9fck
+        InsetRect( &rect, -1 , -1 ) ;
 
         wxTopLevelWindowMac* top = MacGetTopLevelWindow();
         if (top )
@@ -2676,10 +2669,12 @@ bool wxWindowMac::MacSetupCursor( const wxPoint& pt)
 
 wxString wxWindowMac::MacGetToolTipString( wxPoint &pt )
 {
+#if wxUSE_TOOLTIPS
     if ( m_tooltip )
     {
         return m_tooltip->GetTip() ;
     }
+#endif
     return wxEmptyString ;
 }
 
@@ -3098,21 +3093,19 @@ long wxWindowMac::MacGetLeftBorderSize( ) const
     if( IsTopLevel() )
         return 0 ;
 
-    if (m_windowStyle & wxRAISED_BORDER || m_windowStyle & wxSUNKEN_BORDER )
-    {
-        SInt32 border = 3 ;
-          return border ;
-    }
-    else if (  m_windowStyle &wxDOUBLE_BORDER)
+    SInt32 border = 0 ;
+    
+    if (HasFlag(wxRAISED_BORDER) || HasFlag( wxSUNKEN_BORDER) || HasFlag(wxDOUBLE_BORDER) )
     {
-          SInt32 border = 3 ;
-          return border ;
+        GetThemeMetric( kThemeMetricEditTextFrameOutset , &border ) ;
+        border += 1 ; // the metric above is only the 'outset' outside the simple frame rect
     }
-    else if (m_windowStyle &wxSIMPLE_BORDER)
+    else if (HasFlag(wxSIMPLE_BORDER))
     {
-        return 1 ;
+        GetThemeMetric( kThemeMetricListBoxFrameOutset , &border ) ;
+        border += 1 ; // the metric above is only the 'outset' outside the simple frame rect
     }
-    return 0 ;
+    return border ;
 }
 
 long wxWindowMac::MacGetRightBorderSize( ) const