]> git.saurik.com Git - wxWidgets.git/commitdiff
partially fix bug [ wxwindows-Bugs-1145813 ] Centre() Doesn't Work With Dual Monitors...
authorRyan Norton <wxprojects@comcast.net>
Mon, 28 Feb 2005 02:25:33 +0000 (02:25 +0000)
committerRyan Norton <wxprojects@comcast.net>
Mon, 28 Feb 2005 02:25:33 +0000 (02:25 +0000)
git-svn-id: https://svn.wxwidgets.org/svn/wx/wxWidgets/trunk@32447 c3d73ce0-8a6f-49c7-b76d-6d57e0e08775

src/common/wincmn.cpp

index d1e6488437a658ebd7452325d0794acfebf11d70..5115c3cce6e308a9e05d73b051003aef3c3aa650 100644 (file)
     #include "wx/caret.h"
 #endif // wxUSE_CARET
 
     #include "wx/caret.h"
 #endif // wxUSE_CARET
 
+#if wxUSE_DISPLAY
+    #include "wx/display.h"
+#endif
+
 #if wxUSE_SYSTEM_OPTIONS
     #include "wx/sysopt.h"
 #endif
 #if wxUSE_SYSTEM_OPTIONS
     #include "wx/sysopt.h"
 #endif
@@ -431,6 +435,20 @@ void wxWindowBase::Centre(int direction)
 
     if ( direction & wxCENTRE_ON_SCREEN )
     {
 
     if ( direction & wxCENTRE_ON_SCREEN )
     {
+        //RN:  If we are using wxDisplay we get
+        //the dimensions of the monitor the window is on,
+        //otherwise we get the dimensions of the primary monitor
+#if wxUSE_DISPLAY
+        int nDisplay = wxDisplay::GetFromWindow((wxWindow*)this);
+        if(nDisplay != wxNOT_FOUND)
+        {
+            wxDisplay windowDisplay(nDisplay);
+            wxRect displayRect = windowDisplay.GetGeometry();
+            widthParent = displayRect.width;
+            heightParent = displayRect.height;
+        }
+        else
+#endif
         // centre with respect to the whole screen
         wxDisplaySize(&widthParent, &heightParent);
     }
         // centre with respect to the whole screen
         wxDisplaySize(&widthParent, &heightParent);
     }
@@ -471,6 +489,9 @@ void wxWindowBase::Centre(int direction)
     xNew += posParent.x;
     yNew += posParent.y;
 
     xNew += posParent.x;
     yNew += posParent.y;
 
+    // FIXME:  This needs to get the client display rect of the display
+    // the window is (via wxDisplay::GetFromWindow). 
+    
     // Base size of the visible dimensions of the display
     // to take into account the taskbar. And the Mac menu bar at top.
     wxRect clientrect = wxGetClientDisplayRect();
     // Base size of the visible dimensions of the display
     // to take into account the taskbar. And the Mac menu bar at top.
     wxRect clientrect = wxGetClientDisplayRect();