]> git.saurik.com Git - wxWidgets.git/blobdiff - src/common/wincmn.cpp
Warning fix.
[wxWidgets.git] / src / common / wincmn.cpp
index c15d4f4da929cf678e51a1a6442db9973087b990..d109b28adf13a61b74d05b08cc87cbbb50970381 100644 (file)
@@ -85,7 +85,9 @@
 // static data
 // ----------------------------------------------------------------------------
 
-#if defined(__WXPM__)
+#if defined(__WXPALMOS__)
+int wxWindowBase::ms_lastControlId = 65535;
+#elif defined(__WXPM__)
 int wxWindowBase::ms_lastControlId = 2000;
 #else
 int wxWindowBase::ms_lastControlId = -200;
@@ -388,6 +390,7 @@ void wxWindowBase::Centre(int direction)
     int widthParent, heightParent;
 
     wxWindow *parent = NULL;
+    wxTopLevelWindow *winTop = NULL;
 
     if ( !(direction & wxCENTRE_ON_SCREEN) )
     {
@@ -409,9 +412,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 +438,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,7 +539,7 @@ static bool wxHasRealChildren(const wxWindowBase* win)
     return (realChildCount > 0);
 }
 #endif
-    
+
 void wxWindowBase::InvalidateBestSize()
 {
     m_bestSizeCache = wxDefaultSize;
@@ -976,8 +985,15 @@ void wxWindowBase::InheritAttributes()
         if ( parent->m_inheritFgCol && !m_hasFgCol )
             SetForegroundColour(parent->GetForegroundColour());
 
+        // inheriting (solid) background colour is wrong as it totally breaks
+        // any kind of themed backgrounds
+        //
+        // instead, the controls should use the same background as their parent
+        // (ideally by not drawing it at all)
+#if 0
         if ( parent->m_inheritBgCol && !m_hasBgCol )
             SetBackgroundColour(parent->GetBackgroundColour());
+#endif // 0
     }
 }
 
@@ -1041,6 +1057,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() );
@@ -1209,7 +1228,7 @@ void wxWindowBase::ClearBackground()
 // find child window by id or name
 // ----------------------------------------------------------------------------
 
-wxWindow *wxWindowBase::FindWindow( long id )
+wxWindow *wxWindowBase::FindWindow(long id) const
 {
     if ( id == m_windowId )
         return (wxWindow *)this;
@@ -1225,7 +1244,7 @@ wxWindow *wxWindowBase::FindWindow( long id )
     return (wxWindow *)res;
 }
 
-wxWindow *wxWindowBase::FindWindow( const wxString& name )
+wxWindow *wxWindowBase::FindWindow(const wxString& name) const
 {
     if ( name == m_windowName )
         return (wxWindow *)this;
@@ -2016,7 +2035,7 @@ void wxWindowBase::AdjustForParentClientOrigin(int& x, int& y, int sizeFlags) co
 void wxWindowBase::UpdateWindowUI(long flags)
 {
     wxUpdateUIEvent event(GetId());
-    event.m_eventObject = this;
+    event.SetEventObject(this);
 
     if ( GetEventHandler()->ProcessEvent(event) )
     {
@@ -2138,7 +2157,7 @@ void wxWindowBase::OnSysColourChanged(wxSysColourChangedEvent& event)
         if ( !win->IsTopLevel() )
         {
             wxSysColourChangedEvent event2;
-            event.m_eventObject = win;
+            event.SetEventObject(win);
             win->GetEventHandler()->ProcessEvent(event2);
         }
 
@@ -2199,7 +2218,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,
@@ -2209,6 +2228,11 @@ void wxWindowBase::OnMiddleClick( wxMouseEvent& event )
                                       L" (Unicode)",
 #else
                                       "",
+#endif
+#ifdef __WXDEBUG__
+                                      _T(" Debug build"),
+#else
+                                      _T(""),
 #endif
                                       __TDATE__,
                                       __TTIME__
@@ -2455,6 +2479,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);
@@ -2666,7 +2695,7 @@ wxAccStatus wxWindowAccessible::GetName(int childId, wxString* name)
 #endif
         title = GetWindow()->GetName();
 
-    if (!title.IsEmpty())
+    if (!title.empty())
     {
         *name = title;
         return wxACC_OK;
@@ -2772,7 +2801,7 @@ wxAccStatus wxWindowAccessible::GetDescription(int WXUNUSED(childId), wxString*
         return wxACC_FAIL;
 
     wxString ht(GetWindow()->GetHelpText());
-    if (!ht.IsEmpty())
+    if (!ht.empty())
     {
         *description = ht;
         return wxACC_OK;
@@ -2788,7 +2817,7 @@ wxAccStatus wxWindowAccessible::GetHelpText(int WXUNUSED(childId), wxString* hel
         return wxACC_FAIL;
 
     wxString ht(GetWindow()->GetHelpText());
-    if (!ht.IsEmpty())
+    if (!ht.empty())
     {
         *helpText = ht;
         return wxACC_OK;