From a724cb2df9f7b766174ac578cd4d435596898cc1 Mon Sep 17 00:00:00 2001 From: Henrique Nakashima Date: Thu, 8 Mar 2018 18:09:49 +0000 Subject: Move GetPopupPos from CFWL_Widget to subclasses that call it. Change-Id: I27118d2c8d0d7e4509b6a89cd32a7c9c906d19bc Reviewed-on: https://pdfium-review.googlesource.com/28270 Commit-Queue: dsinclair Reviewed-by: dsinclair --- xfa/fwl/cfwl_combobox.cpp | 29 +++++++++++++++++++++++++++++ 1 file changed, 29 insertions(+) (limited to 'xfa/fwl/cfwl_combobox.cpp') diff --git a/xfa/fwl/cfwl_combobox.cpp b/xfa/fwl/cfwl_combobox.cpp index 143d797fbd..0a5ccd0e7c 100644 --- a/xfa/fwl/cfwl_combobox.cpp +++ b/xfa/fwl/cfwl_combobox.cpp @@ -1014,3 +1014,32 @@ void CFWL_ComboBox::DisForm_OnKey(CFWL_MessageKey* pMsg) { if (m_pEdit) m_pEdit->GetDelegate()->OnProcessMessage(pMsg); } + +void CFWL_ComboBox::GetPopupPos(float fMinHeight, + float fMaxHeight, + const CFX_RectF& rtAnchor, + CFX_RectF& rtPopup) { + if (m_pWidgetMgr->IsFormDisabled()) { + m_pWidgetMgr->GetAdapterPopupPos(this, fMinHeight, fMaxHeight, rtAnchor, + rtPopup); + return; + } + + float fPopHeight = rtPopup.height; + if (rtPopup.height > fMaxHeight) + fPopHeight = fMaxHeight; + else if (rtPopup.height < fMinHeight) + fPopHeight = fMinHeight; + + float fWidth = std::max(rtAnchor.width, rtPopup.width); + float fBottom = rtAnchor.bottom() + fPopHeight; + CFX_PointF point = TransformTo(nullptr, CFX_PointF()); + if (fBottom + point.y > 0.0f) { + rtPopup = + CFX_RectF(rtAnchor.left, rtAnchor.top - fPopHeight, fWidth, fPopHeight); + } else { + rtPopup = CFX_RectF(rtAnchor.left, rtAnchor.bottom(), fWidth, fPopHeight); + } + + rtPopup.Offset(point.x, point.y); +} -- cgit v1.2.3