]> git.saurik.com Git - wxWidgets.git/blobdiff - src/common/wincmn.cpp
Fix FileTestCase to really test strings with embedded NULs.
[wxWidgets.git] / src / common / wincmn.cpp
index e67ee6a67b738af3204f44ec06a53863b7b5a662..63bc0450f645a5e6a6fd489aa298b916018e6f25 100644 (file)
@@ -364,8 +364,7 @@ wxWindowBase::~wxWindowBase()
         // This removes any dangling pointers to this window in other windows'
         // constraintsInvolvedIn lists.
         UnsetConstraints(m_constraints);
         // This removes any dangling pointers to this window in other windows'
         // constraintsInvolvedIn lists.
         UnsetConstraints(m_constraints);
-        delete m_constraints;
-        m_constraints = NULL;
+        wxDELETE(m_constraints);
     }
 #endif // wxUSE_CONSTRAINTS
 
     }
 #endif // wxUSE_CONSTRAINTS
 
@@ -737,17 +736,14 @@ wxSize wxWindowBase::GetEffectiveMinSize() const
 
 wxSize wxWindowBase::DoGetBorderSize() const
 {
 
 wxSize wxWindowBase::DoGetBorderSize() const
 {
-    // there is one case in which we can implement it for all ports easily:
-    // do it as some classes used by both wxUniv and native ports (e.g.
-    // wxGenericStaticText) do override DoGetBestClientSize() and so this
-    // method must work for them and that ensures that it does, at least in
-    // the default case)
+    // there is one case in which we can implement it for all ports easily
     if ( GetBorder() == wxBORDER_NONE )
         return wxSize(0, 0);
 
     if ( GetBorder() == wxBORDER_NONE )
         return wxSize(0, 0);
 
-    wxFAIL_MSG( "must be overridden if called" );
-
-    return wxDefaultSize;
+    // otherwise use the difference between the real size and the client size
+    // as a fallback: notice that this is incorrect in general as client size
+    // also doesn't take the scrollbars into account
+    return GetSize() - GetClientSize();
 }
 
 wxSize wxWindowBase::GetBestSize() const
 }
 
 wxSize wxWindowBase::GetBestSize() const
@@ -840,18 +836,15 @@ void wxWindowBase::DoSetWindowVariant( wxWindowVariant variant )
             break;
 
         case wxWINDOW_VARIANT_SMALL:
             break;
 
         case wxWINDOW_VARIANT_SMALL:
-            size *= 3;
-            size /= 4;
+            size = wxRound(size * 3.0 / 4.0);
             break;
 
         case wxWINDOW_VARIANT_MINI:
             break;
 
         case wxWINDOW_VARIANT_MINI:
-            size *= 2;
-            size /= 3;
+            size = wxRound(size * 2.0 / 3.0);
             break;
 
         case wxWINDOW_VARIANT_LARGE:
             break;
 
         case wxWINDOW_VARIANT_LARGE:
-            size *= 5;
-            size /= 4;
+            size = wxRound(size * 5.0 / 4.0);
             break;
 
         default:
             break;
 
         default:
@@ -1254,8 +1247,7 @@ wxEvtHandler *wxWindowBase::PopEventHandler(bool deleteHandler)
 
     if ( deleteHandler )
     {
 
     if ( deleteHandler )
     {
-        delete firstHandler;
-        firstHandler = NULL;
+        wxDELETE(firstHandler);
     }
 
     return firstHandler;
     }
 
     return firstHandler;
@@ -1275,7 +1267,7 @@ bool wxWindowBase::RemoveEventHandler(wxEvtHandler *handlerToRemove)
 
     // NOTE: the wxWindow event handler list is always terminated with "this" handler
     wxEvtHandler *handlerCur = GetEventHandler()->GetNextHandler();
 
     // NOTE: the wxWindow event handler list is always terminated with "this" handler
     wxEvtHandler *handlerCur = GetEventHandler()->GetNextHandler();
-    while ( handlerCur != this )
+    while ( handlerCur != this && handlerCur )
     {
         wxEvtHandler *handlerNext = handlerCur->GetNextHandler();
 
     {
         wxEvtHandler *handlerNext = handlerCur->GetNextHandler();
 
@@ -2076,8 +2068,7 @@ void wxWindowBase::DeleteRelatedConstraints()
             node = next;
         }
 
             node = next;
         }
 
-        delete m_constraintsInvolvedIn;
-        m_constraintsInvolvedIn = NULL;
+        wxDELETE(m_constraintsInvolvedIn);
     }
 }
 
     }
 }
 
@@ -2297,7 +2288,9 @@ void wxWindowBase::SetConstraintSizes(bool recurse)
         if ( (constr->width.GetRelationship() != wxAsIs ) ||
              (constr->height.GetRelationship() != wxAsIs) )
         {
         if ( (constr->width.GetRelationship() != wxAsIs ) ||
              (constr->height.GetRelationship() != wxAsIs) )
         {
-            SetSize(x, y, w, h);
+            // We really shouldn't set negative sizes for the windows so make
+            // them at least of 1*1 size
+            SetSize(x, y, w > 0 ? w : 1, h > 0 ? h : 1);
         }
         else
         {
         }
         else
         {
@@ -2567,6 +2560,9 @@ bool wxWindowBase::PopupMenu(wxMenu *menu, int x, int y)
 {
     wxCHECK_MSG( menu, false, "can't popup NULL menu" );
 
 {
     wxCHECK_MSG( menu, false, "can't popup NULL menu" );
 
+    wxMenuInvokingWindowSetter
+        setInvokingWin(*menu, static_cast<wxWindow *>(this));
+
     wxCurrentPopupMenu = menu;
     const bool rc = DoPopupMenu(menu, x, y);
     wxCurrentPopupMenu = NULL;
     wxCurrentPopupMenu = menu;
     const bool rc = DoPopupMenu(menu, x, y);
     wxCurrentPopupMenu = NULL;
@@ -2980,7 +2976,7 @@ bool wxWindowBase::TryBefore(wxEvent& event)
     if ( event.GetEventObject() == this )
     {
         wxValidator * const validator = GetValidator();
     if ( event.GetEventObject() == this )
     {
         wxValidator * const validator = GetValidator();
-        if ( validator && validator->ProcessEventHere(event) )
+        if ( validator && validator->ProcessEventLocally(event) )
         {
             return true;
         }
         {
             return true;
         }