Use the new wxDisplay(wxWindow*) ctor to simplify the code
Make the code simpler and, in a couple of places where the fall back to the primary display in case wxDisplay::GetFromWindow() returned -1 was missing, also more correct.
This commit is contained in:
@@ -871,7 +871,7 @@ int wxStandardDialogLayoutAdapter::DoMustScroll(wxDialog* dialog, wxSize& window
|
||||
wxSize minWindowSize = dialog->GetSizer()->GetMinSize();
|
||||
windowSize = dialog->GetSize();
|
||||
windowSize = wxSize(wxMax(windowSize.x, minWindowSize.x), wxMax(windowSize.y, minWindowSize.y));
|
||||
displaySize = wxDisplay(wxDisplay::GetFromWindow(dialog)).GetClientArea().GetSize();
|
||||
displaySize = wxDisplay(dialog).GetClientArea().GetSize();
|
||||
|
||||
int flags = 0;
|
||||
|
||||
|
@@ -930,15 +930,9 @@ wxSize wxSizer::ComputeFittingClientSize(wxWindow *window)
|
||||
return tlw->GetClientSize();
|
||||
}
|
||||
|
||||
// limit the window to the size of the display it is on
|
||||
int disp = wxDisplay::GetFromWindow(window);
|
||||
if ( disp == wxNOT_FOUND )
|
||||
{
|
||||
// or, if we don't know which one it is, of the main one
|
||||
disp = 0;
|
||||
}
|
||||
|
||||
sizeMax = wxDisplay(disp).GetClientArea().GetSize();
|
||||
// limit the window to the size of the display it is on (or the main
|
||||
// one if the window display can't be determined)
|
||||
sizeMax = wxDisplay(window).GetClientArea().GetSize();
|
||||
|
||||
// If determining the display size failed, skip the max size checks as
|
||||
// we really don't want to create windows of (0, 0) size.
|
||||
|
@@ -249,8 +249,7 @@ void wxTopLevelWindowBase::DoCentre(int dir)
|
||||
// we need the display rect anyhow so store it first: notice that we should
|
||||
// be centered on the same display as our parent window, the display of
|
||||
// this window itself is not really defined yet
|
||||
int nDisplay = wxDisplay::GetFromWindow(GetParent() ? GetParent() : this);
|
||||
wxDisplay dpy(nDisplay == wxNOT_FOUND ? 0 : nDisplay);
|
||||
wxDisplay dpy(GetParent() ? GetParent() : this);
|
||||
const wxRect rectDisplay(dpy.GetClientArea());
|
||||
|
||||
// what should we centre this window on?
|
||||
|
@@ -318,11 +318,7 @@ private:
|
||||
|
||||
// Use GetFromWindow() and not GetFromPoint() here to try to get the
|
||||
// correct display even if the tip point itself is not visible.
|
||||
int dpy = wxDisplay::GetFromWindow(GetParent());
|
||||
if ( dpy == wxNOT_FOUND )
|
||||
dpy = 0; // What else can we do?
|
||||
|
||||
const wxRect rectDpy = wxDisplay(dpy).GetClientArea();
|
||||
const wxRect rectDpy = wxDisplay(GetParent()).GetClientArea();
|
||||
|
||||
#ifdef __WXMAC__
|
||||
return pos.y > rectDpy.height/2 ? wxTipKind_Bottom : wxTipKind_Top;
|
||||
|
@@ -162,10 +162,7 @@ wxMessageDialog::HookFunction(int code, WXWPARAM wParam, WXLPARAM lParam)
|
||||
void wxMessageDialog::ReplaceStaticWithEdit()
|
||||
{
|
||||
// check if the message box fits the display
|
||||
int nDisplay = wxDisplay::GetFromWindow(this);
|
||||
if ( nDisplay == wxNOT_FOUND )
|
||||
nDisplay = 0;
|
||||
const wxRect rectDisplay = wxDisplay(nDisplay).GetClientArea();
|
||||
const wxRect rectDisplay = wxDisplay(this).GetClientArea();
|
||||
|
||||
if ( rectDisplay.Contains(GetRect()) )
|
||||
{
|
||||
|
@@ -756,8 +756,7 @@ void wxTopLevelWindowMSW::DoGetPosition(int *x, int *y) const
|
||||
{
|
||||
// we must use the correct display for the translation as the
|
||||
// task bar might be shown on one display but not the other one
|
||||
int n = wxDisplay::GetFromWindow(this);
|
||||
wxDisplay dpy(n == wxNOT_FOUND ? 0 : n);
|
||||
wxDisplay dpy(this);
|
||||
const wxPoint ptOfs = dpy.GetClientArea().GetPosition() -
|
||||
dpy.GetGeometry().GetPosition();
|
||||
|
||||
@@ -916,11 +915,7 @@ bool wxTopLevelWindowMSW::ShowFullScreen(bool show, long style)
|
||||
|
||||
// resize to the size of the display containing us, falling back to the
|
||||
// primary one
|
||||
int dpy = wxDisplay::GetFromWindow(this);
|
||||
if ( dpy == wxNOT_FOUND )
|
||||
dpy = 0;
|
||||
|
||||
const wxRect rect = wxDisplay(dpy).GetGeometry();
|
||||
const wxRect rect = wxDisplay(this).GetGeometry();
|
||||
|
||||
SetSize(rect);
|
||||
|
||||
|
@@ -1861,8 +1861,7 @@ void Window::SetPositionRelative(PRectangle rc, Window relativeTo) {
|
||||
position.x = wxRound(position.x + rc.left);
|
||||
position.y = wxRound(position.y + rc.top);
|
||||
|
||||
const int currentDisplay = wxDisplay::GetFromWindow(relativeWin);
|
||||
const wxRect displayRect = wxDisplay(currentDisplay).GetClientArea();
|
||||
const wxRect displayRect = wxDisplay(relativeWin).GetClientArea();
|
||||
|
||||
if (position.x < displayRect.GetLeft())
|
||||
position.x = displayRect.GetLeft();
|
||||
|
Reference in New Issue
Block a user