Improve wxComboCtrl popup position with multiple displays
This commit is contained in:
@@ -2296,13 +2296,10 @@ void wxComboCtrlBase::ShowPopup()
|
|||||||
int maxHeightPopup;
|
int maxHeightPopup;
|
||||||
wxSize ctrlSz = GetSize();
|
wxSize ctrlSz = GetSize();
|
||||||
|
|
||||||
// wxSystemSettings::GetMetric( wxSYS_SCREEN_Y, this ) returns a geometry of the primary display
|
screenHeight = displayRect.GetHeight();
|
||||||
// And it causes wrong calculation of the popuping on secondary monitor.
|
scrPos = GetScreenPosition();
|
||||||
// So, let's make all calculation in respect to the display of the provided window.
|
|
||||||
screenHeight = displayRect.height;//wxSystemSettings::GetMetric( wxSYS_SCREEN_Y, this );
|
|
||||||
scrPos = GetScreenPosition() - displayRect.GetTopLeft();
|
|
||||||
|
|
||||||
spaceAbove = scrPos.y;
|
spaceAbove = scrPos.y - displayRect.GetY();
|
||||||
spaceBelow = screenHeight - spaceAbove - ctrlSz.y;
|
spaceBelow = screenHeight - spaceAbove - ctrlSz.y;
|
||||||
|
|
||||||
maxHeightPopup = spaceBelow;
|
maxHeightPopup = spaceBelow;
|
||||||
@@ -2364,20 +2361,20 @@ void wxComboCtrlBase::ShowPopup()
|
|||||||
wxSize szp = popup->GetSize();
|
wxSize szp = popup->GetSize();
|
||||||
|
|
||||||
int popupX;
|
int popupX;
|
||||||
int popupY = scrPos.y + ctrlSz.y + displayRect.GetTop();
|
int popupY = scrPos.y + ctrlSz.y;
|
||||||
|
|
||||||
// Default anchor is wxLEFT
|
// Default anchor is wxLEFT
|
||||||
int anchorSide = m_anchorSide;
|
int anchorSide = m_anchorSide;
|
||||||
if ( !anchorSide )
|
if ( !anchorSide )
|
||||||
anchorSide = wxLEFT;
|
anchorSide = wxLEFT;
|
||||||
|
|
||||||
int rightX = scrPos.x + ctrlSz.x + m_extRight - szp.x + displayRect.GetLeft();
|
int rightX = scrPos.x + ctrlSz.x + m_extRight - szp.x;
|
||||||
int leftX = scrPos.x - m_extLeft + displayRect.GetLeft();
|
int leftX = scrPos.x - m_extLeft;
|
||||||
|
|
||||||
if ( wxTheApp->GetLayoutDirection() == wxLayout_RightToLeft )
|
if ( wxTheApp->GetLayoutDirection() == wxLayout_RightToLeft )
|
||||||
leftX -= ctrlSz.x;
|
leftX -= ctrlSz.x;
|
||||||
|
|
||||||
int screenWidth = displayRect.width;// wxSystemSettings::GetMetric( wxSYS_SCREEN_X, this );
|
int screenWidth = displayRect.GetWidth();
|
||||||
|
|
||||||
// If there is not enough horizontal space, anchor on the other side.
|
// If there is not enough horizontal space, anchor on the other side.
|
||||||
// If there is no space even then, place the popup at x 0.
|
// If there is no space even then, place the popup at x 0.
|
||||||
@@ -2414,7 +2411,7 @@ void wxComboCtrlBase::ShowPopup()
|
|||||||
|
|
||||||
if ( spaceBelow < szp.y )
|
if ( spaceBelow < szp.y )
|
||||||
{
|
{
|
||||||
popupY = scrPos.y - szp.y + displayRect.GetTop();
|
popupY = scrPos.y - szp.y;
|
||||||
showFlags |= ShowAbove;
|
showFlags |= ShowAbove;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
Reference in New Issue
Block a user