]> git.saurik.com Git - wxWidgets.git/blobdiff - src/common/wincmn.cpp
More DLL build fixes for wxMediaCtrl
[wxWidgets.git] / src / common / wincmn.cpp
index 8e8247259029d19a29346bbe4762f58416b877b6..546182a21269cbc4663260a1aeb5d6b62157eb0d 100644 (file)
@@ -388,6 +388,7 @@ void wxWindowBase::Centre(int direction)
     int widthParent, heightParent;
 
     wxWindow *parent = NULL;
+    wxTopLevelWindow *winTop = NULL;
 
     if ( !(direction & wxCENTRE_ON_SCREEN) )
     {
@@ -409,9 +410,10 @@ void wxWindowBase::Centre(int direction)
         // Windows, for example, this places it completely off the screen
         if ( parent )
         {
-            wxTopLevelWindow *winTop = wxDynamicCast(parent, wxTopLevelWindow);
+            winTop = wxDynamicCast(parent, wxTopLevelWindow);
             if ( winTop && winTop->IsIconized() )
             {
+                winTop = NULL;
                 parent = NULL;
             }
         }
@@ -434,11 +436,16 @@ void wxWindowBase::Centre(int direction)
     {
         if ( IsTopLevel() )
         {
-            // centre on the parent
-            parent->GetSize(&widthParent, &heightParent);
+            if(winTop)
+                winTop->GetRectForTopLevelChildren(&posParent.x, &posParent.y, &widthParent, &heightParent);
+            else
+            {
+                // centre on the parent
+                parent->GetSize(&widthParent, &heightParent);
 
-            // adjust to the parents position
-            posParent = parent->GetPosition();
+                // adjust to the parents position
+                posParent = parent->GetPosition();
+            }
         }
         else
         {
@@ -530,6 +537,16 @@ static bool wxHasRealChildren(const wxWindowBase* win)
     return (realChildCount > 0);
 }
 #endif
+    
+void wxWindowBase::InvalidateBestSize()
+{
+    m_bestSizeCache = wxDefaultSize;
+
+    // parent's best size calculation may depend on its children's
+    // best sizes, so let's invalidate it as well to be safe:
+    if (m_parent)
+        m_parent->InvalidateBestSize();
+}
 
 // return the size best suited for the current window
 wxSize wxWindowBase::DoGetBestSize() const
@@ -1031,6 +1048,9 @@ bool wxWindowBase::SetBackgroundColour( const wxColour &colour )
         return false;
 
     m_hasBgCol = colour.Ok();
+    if ( m_backgroundStyle != wxBG_STYLE_CUSTOM )
+        m_backgroundStyle = m_hasBgCol ? wxBG_STYLE_COLOUR : wxBG_STYLE_SYSTEM;
+
     m_inheritBgCol = m_hasBgCol;
     m_backgroundColour = colour;
     SetThemeEnabled( !m_hasBgCol && !m_foregroundColour.Ok() );
@@ -2043,12 +2063,16 @@ void wxWindowBase::DoUpdateWindowUI(wxUpdateUIEvent& event)
             if ( event.GetText() != control->GetLabel() )
                 control->SetLabel(event.GetText());
         }
+    }
+#endif // wxUSE_CONTROLS
+
+    if ( event.GetSetChecked() )
+    {
 #if wxUSE_CHECKBOX
         wxCheckBox *checkbox = wxDynamicCastThis(wxCheckBox);
         if ( checkbox )
         {
-            if ( event.GetSetChecked() )
-                checkbox->SetValue(event.GetChecked());
+            checkbox->SetValue(event.GetChecked());
         }
 #endif // wxUSE_CHECKBOX
 
@@ -2056,12 +2080,10 @@ void wxWindowBase::DoUpdateWindowUI(wxUpdateUIEvent& event)
         wxRadioButton *radiobtn = wxDynamicCastThis(wxRadioButton);
         if ( radiobtn )
         {
-            if ( event.GetSetChecked() )
-                radiobtn->SetValue(event.GetChecked());
+            radiobtn->SetValue(event.GetChecked());
         }
 #endif // wxUSE_RADIOBTN
     }
-#endif
 }
 
 #if 0
@@ -2187,7 +2209,7 @@ void wxWindowBase::OnMiddleClick( wxMouseEvent& event )
 
         wxMessageBox(wxString::Format(
                                       _T(
-                                        "       wxWidgets Library (%s port)\nVersion %u.%u.%u%s, compiled at %s %s\n   Copyright (c) 1995-2002 wxWidgets team"
+                                        "       wxWidgets Library (%s port)\nVersion %u.%u.%u%s%s, compiled at %s %s\n   Copyright (c) 1995-2004 wxWidgets team"
                                         ),
                                       port.c_str(),
                                       wxMAJOR_VERSION,
@@ -2197,6 +2219,11 @@ void wxWindowBase::OnMiddleClick( wxMouseEvent& event )
                                       L" (Unicode)",
 #else
                                       "",
+#endif
+#ifdef __WXDEBUG__
+                                      _T(" Debug build"),
+#else
+                                      _T(""),
 #endif
                                       __TDATE__,
                                       __TTIME__
@@ -2443,6 +2470,11 @@ void wxWindowBase::DoMoveInTabOrder(wxWindow *win, MoveKind move)
     wxCHECK_RET( GetParent(),
                     _T("MoveBefore/AfterInTabOrder() don't work for TLWs!") );
 
+    // detect the special case when we have nothing to do anyhow and when the
+    // code below wouldn't work
+    if ( win == this )
+        return;
+
     // find the target window in the siblings list
     wxWindowList& siblings = GetParent()->GetChildren();
     wxWindowList::compatibility_iterator i = siblings.Find(win);
@@ -2473,7 +2505,7 @@ void wxWindowBase::DoMoveInTabOrder(wxWindow *win, MoveKind move)
 
 /*static*/ wxWindow* wxWindowBase::FindFocus()
 {
-    wxWindow *win = DoFindFocus();
+    wxWindowBase *win = DoFindFocus();
     return win ? win->GetMainWindowOfCompositeControl() : NULL;
 }