]> git.saurik.com Git - wxWidgets.git/commitdiff
Fix centering of top-level children of wxMDIParentFrame on Mac
authorDavid Elliott <dfe@tgwbd.org>
Mon, 22 Nov 2004 20:10:53 +0000 (20:10 +0000)
committerDavid Elliott <dfe@tgwbd.org>
Mon, 22 Nov 2004 20:10:53 +0000 (20:10 +0000)
git-svn-id: https://svn.wxwidgets.org/svn/wx/wxWidgets/trunk@30706 c3d73ce0-8a6f-49c7-b76d-6d57e0e08775

include/wx/mac/carbon/mdi.h
include/wx/toplevel.h
src/common/toplvcmn.cpp
src/common/wincmn.cpp
src/mac/carbon/mdi.cpp

index bde585e0453eca9e01d3fc55ef245e2a585ceb9e..eb55fff2a182ba34848e07527d88362eb7bf7be1 100644 (file)
@@ -68,6 +68,8 @@ public:
 
   // Get the client window
   inline wxMDIClientWindow *GetClientWindow() const { return m_clientWindow; };
+  // Get rect to be used to center top-level children
+  virtual void GetRectForTopLevelChildren(int *x, int *y, int *w, int *h);
 
   // Create the client window class (don't Create the window,
   // just return a new class)
index e2201ae8fd7fbe302d58101ef5b8b5b8280915b1..b14af59160546da465093adb2543500330f79bba 100644 (file)
@@ -196,6 +196,9 @@ public:
     void OnCloseWindow(wxCloseEvent& event);
     void OnSize(wxSizeEvent& WXUNUSED(event)) { DoLayout(); }
 
+    // Get rect to be used to center top-level children
+    virtual void GetRectForTopLevelChildren(int *x, int *y, int *w, int *h);
+
     // this should go away, but for now it's called from docview.cpp,
     // so should be there for all platforms
     void OnActivate(wxActivateEvent &WXUNUSED(event)) { }
index e23349fb52d94f83718aa5ed821e5d81ba8e410c..0146f40ab4553fe2d3f93eb6b4cff17f4bda493d 100644 (file)
@@ -109,6 +109,12 @@ bool wxTopLevelWindowBase::IsLastBeforeExit() const
 // wxTopLevelWindow geometry
 // ----------------------------------------------------------------------------
 
+void wxTopLevelWindowBase::GetRectForTopLevelChildren(int *x, int *y, int *w, int *h)
+{
+    GetPosition(x,y);
+    GetSize(w,h);
+}
+
 wxSize wxTopLevelWindowBase::GetMaxSize() const
 {
     wxSize  size( GetMaxWidth(), GetMaxHeight() );
index f906802a0f49a1c0b45d3c5f8d974e7736c03cb2..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
         {
index a5672eebec9de040dd821042e6f51689d5d122ee..0c80890f18b3ca40d97a0b62f7eb293ecd2ae177 100644 (file)
@@ -117,6 +117,15 @@ void wxMDIParentFrame::SetMenuBar(wxMenuBar *menu_bar)
     wxFrame::SetMenuBar( menu_bar ) ;
 }
 
+void wxMDIParentFrame::GetRectForTopLevelChildren(int *x, int *y, int *w, int *h)
+{
+    if(x)
+        *x = 0;
+    if(y)
+        *y = 0;
+    wxDisplaySize(w,h);
+}
+
 void wxMDIParentFrame::MacActivate(long timestamp, bool activating)
 {
     wxLogDebug(wxT("MDI PARENT=%p MacActivate(0x%08lx,%s)"),this,timestamp,activating?wxT("ACTIV"):wxT("deact"));