From ff709f69ce4de5184860a513b48ecfba1722e167 Mon Sep 17 00:00:00 2001 From: Kevin Reed Date: Mon, 13 May 2013 17:47:14 -0500 Subject: [PATCH] Modify the way we place an oversized or off screen message dialogue onto the screen. This simply moves it fully onto the screen rather than centering it. --- clientgui/DlgEventLog.cpp | 27 +++++++++++++++++++-------- 1 file changed, 19 insertions(+), 8 deletions(-) diff --git a/clientgui/DlgEventLog.cpp b/clientgui/DlgEventLog.cpp index 436c510804..e1bc02ca36 100644 --- a/clientgui/DlgEventLog.cpp +++ b/clientgui/DlgEventLog.cpp @@ -166,20 +166,31 @@ bool CDlgEventLog::Create( wxWindow* parent, wxWindowID id, const wxString& capt GetWindowDimensions( oTempPoint, oTempSize ); #ifdef __WXMSW__ - // Make sure that it fits within displayable area - wxDisplay *display = new wxDisplay(); + // Get the current display space for the current window + int iDisplay = wxDisplay::GetFromWindow(parent); + if ( iDisplay == wxNOT_FOUND ) iDisplay = 0; + wxDisplay *display = new wxDisplay(iDisplay); wxRect rDisplay = display->GetClientArea(); + + // Check that the saved height and width is not larger than the displayable space. + // If it is, then reduce the size. if ( oTempSize.GetWidth() > rDisplay.width ) oTempSize.SetWidth(rDisplay.width); if ( oTempSize.GetHeight() > rDisplay.height ) oTempSize.SetHeight(rDisplay.height); // Check if part of the display was going to be off the screen, if so, center the // display on that axis - if ( oTempPoint.x < 0 || oTempPoint.x + oTempSize.GetWidth() > rDisplay.width ) { - oTempPoint.x = (rDisplay.width - oTempSize.GetWidth())/2; - } - if ( oTempPoint.y < 0 || oTempPoint.y + oTempSize.GetHeight() > rDisplay.height ) { - oTempPoint.y = (rDisplay.height - oTempSize.GetHeight())/2; - } + if ( oTempPoint.x < 0 ) { + oTempPoint.x = 0; + } else if ( oTempPoint.x + oTempSize.GetWidth() > rDisplay.width ) { + oTempPoint.x = rDisplay.width - oTempSize.GetWidth(); + } + + if ( oTempPoint.y < 0 ) { + oTempPoint.y = 0; + } else if ( oTempPoint.y + oTempSize.GetHeight() > rDisplay.height ) { + oTempPoint.y = rDisplay.height - oTempSize.GetHeight(); + } + delete display; #endif