]> git.saurik.com Git - wxWidgets.git/blobdiff - src/common/toplvcmn.cpp
fixed compilation problem in pror commit
[wxWidgets.git] / src / common / toplvcmn.cpp
index 0146f40ab4553fe2d3f93eb6b4cff17f4bda493d..f69ac1e02154c459284b2264b37cac58746dd24a 100644 (file)
 // headers
 // ----------------------------------------------------------------------------
 
-#if defined(__GNUG__) && !defined(NO_GCC_PRAGMA)
-    #pragma implementation "toplevelbase.h"
-#endif
-
 // For compilers that support precompilation, includes "wx.h".
 #include "wx/wxprec.h"
 
@@ -33,6 +29,8 @@
     #include "wx/app.h"
 #endif // WX_PRECOMP
 
+#include "wx/display.h"
+
 // ----------------------------------------------------------------------------
 // event table
 // ----------------------------------------------------------------------------
@@ -46,7 +44,7 @@ END_EVENT_TABLE()
 // implementation
 // ============================================================================
 
-IMPLEMENT_DYNAMIC_CLASS(wxTopLevelWindow, wxWindow)
+IMPLEMENT_ABSTRACT_CLASS(wxTopLevelWindow, wxWindow)
 
 // ----------------------------------------------------------------------------
 // construction/destruction
@@ -155,6 +153,35 @@ wxSize wxTopLevelWindowBase::GetDefaultSize()
     return size;
 }
 
+void wxTopLevelWindowBase::DoCentre(int dir)
+{
+    wxRect rectCentre;
+    if ( !(dir & wxCENTRE_ON_SCREEN) && GetParent() )
+    {
+        // centre on parent window
+        rectCentre = GetParent()->GetRect();
+    }
+    else
+    {
+        // we were explicitely asked to centre this window on the entire screen
+        // or if we have no parent anyhow and so can't centre on it
+#if wxUSE_DISPLAY
+        const int nDisplay = wxDisplay::GetFromWindow(this);
+        if ( nDisplay != wxNOT_FOUND )
+        {
+            rectCentre = wxDisplay(nDisplay).GetGeometry();
+        }
+        else
+#endif // wxUSE_DISPLAY
+        {
+            wxDisplaySize(&rectCentre.width, &rectCentre.height);
+        }
+    }
+
+    // window may be at -1 if it's centered on a secondary display, for example
+    SetSize(GetRect().CentreIn(rectCentre, dir), wxSIZE_ALLOW_MINUS_ONE);
+}
+
 // ----------------------------------------------------------------------------
 // wxTopLevelWindow size management: we exclude the areas taken by
 // menu/status/toolbars from the client area, so the client area is what's