Fix centering of top-level children of wxMDIParentFrame on Mac

git-svn-id: https://svn.wxwidgets.org/svn/wx/wxWidgets/trunk@30706 c3d73ce0-8a6f-49c7-b76d-6d57e0e08775
This commit is contained in:
David Elliott
2004-11-22 20:10:53 +00:00
parent 58b9c9badd
commit 0bba37f51d
5 changed files with 32 additions and 5 deletions

View File

@@ -68,6 +68,8 @@ public:
// Get the client window // Get the client window
inline wxMDIClientWindow *GetClientWindow() const { return m_clientWindow; }; 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, // Create the client window class (don't Create the window,
// just return a new class) // just return a new class)

View File

@@ -196,6 +196,9 @@ public:
void OnCloseWindow(wxCloseEvent& event); void OnCloseWindow(wxCloseEvent& event);
void OnSize(wxSizeEvent& WXUNUSED(event)) { DoLayout(); } 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, // this should go away, but for now it's called from docview.cpp,
// so should be there for all platforms // so should be there for all platforms
void OnActivate(wxActivateEvent &WXUNUSED(event)) { } void OnActivate(wxActivateEvent &WXUNUSED(event)) { }

View File

@@ -109,6 +109,12 @@ bool wxTopLevelWindowBase::IsLastBeforeExit() const
// wxTopLevelWindow geometry // wxTopLevelWindow geometry
// ---------------------------------------------------------------------------- // ----------------------------------------------------------------------------
void wxTopLevelWindowBase::GetRectForTopLevelChildren(int *x, int *y, int *w, int *h)
{
GetPosition(x,y);
GetSize(w,h);
}
wxSize wxTopLevelWindowBase::GetMaxSize() const wxSize wxTopLevelWindowBase::GetMaxSize() const
{ {
wxSize size( GetMaxWidth(), GetMaxHeight() ); wxSize size( GetMaxWidth(), GetMaxHeight() );

View File

@@ -388,6 +388,7 @@ void wxWindowBase::Centre(int direction)
int widthParent, heightParent; int widthParent, heightParent;
wxWindow *parent = NULL; wxWindow *parent = NULL;
wxTopLevelWindow *winTop = NULL;
if ( !(direction & wxCENTRE_ON_SCREEN) ) if ( !(direction & wxCENTRE_ON_SCREEN) )
{ {
@@ -409,9 +410,10 @@ void wxWindowBase::Centre(int direction)
// Windows, for example, this places it completely off the screen // Windows, for example, this places it completely off the screen
if ( parent ) if ( parent )
{ {
wxTopLevelWindow *winTop = wxDynamicCast(parent, wxTopLevelWindow); winTop = wxDynamicCast(parent, wxTopLevelWindow);
if ( winTop && winTop->IsIconized() ) if ( winTop && winTop->IsIconized() )
{ {
winTop = NULL;
parent = NULL; parent = NULL;
} }
} }
@@ -433,6 +435,10 @@ void wxWindowBase::Centre(int direction)
else else
{ {
if ( IsTopLevel() ) if ( IsTopLevel() )
{
if(winTop)
winTop->GetRectForTopLevelChildren(&posParent.x, &posParent.y, &widthParent, &heightParent);
else
{ {
// centre on the parent // centre on the parent
parent->GetSize(&widthParent, &heightParent); parent->GetSize(&widthParent, &heightParent);
@@ -440,6 +446,7 @@ void wxWindowBase::Centre(int direction)
// adjust to the parents position // adjust to the parents position
posParent = parent->GetPosition(); posParent = parent->GetPosition();
} }
}
else else
{ {
// centre inside the parents client rectangle // centre inside the parents client rectangle

View File

@@ -117,6 +117,15 @@ void wxMDIParentFrame::SetMenuBar(wxMenuBar *menu_bar)
wxFrame::SetMenuBar( 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) void wxMDIParentFrame::MacActivate(long timestamp, bool activating)
{ {
wxLogDebug(wxT("MDI PARENT=%p MacActivate(0x%08lx,%s)"),this,timestamp,activating?wxT("ACTIV"):wxT("deact")); wxLogDebug(wxT("MDI PARENT=%p MacActivate(0x%08lx,%s)"),this,timestamp,activating?wxT("ACTIV"):wxT("deact"));