fixed centering of top level windows on secondary displays (replaces patch 1267173)
git-svn-id: https://svn.wxwidgets.org/svn/wx/wxWidgets/trunk@37436 c3d73ce0-8a6f-49c7-b76d-6d57e0e08775
This commit is contained in:
@@ -29,6 +29,8 @@
|
||||
#include "wx/app.h"
|
||||
#endif // WX_PRECOMP
|
||||
|
||||
#include "wx/display.h"
|
||||
|
||||
// ----------------------------------------------------------------------------
|
||||
// event table
|
||||
// ----------------------------------------------------------------------------
|
||||
@@ -151,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
|
||||
|
||||
Reference in New Issue
Block a user