diff options
Diffstat (limited to 'xfa/fwl')
-rw-r--r-- | xfa/fwl/cfwl_combobox.cpp | 34 | ||||
-rw-r--r-- | xfa/fwl/cfwl_combobox.h | 2 | ||||
-rw-r--r-- | xfa/fwl/cfwl_datetimepicker.cpp | 22 | ||||
-rw-r--r-- | xfa/fwl/cfwl_datetimepicker.h | 2 | ||||
-rw-r--r-- | xfa/fwl/cfwl_widgetmgr.cpp | 5 | ||||
-rw-r--r-- | xfa/fwl/cfwl_widgetmgr.h | 2 |
6 files changed, 30 insertions, 37 deletions
diff --git a/xfa/fwl/cfwl_combobox.cpp b/xfa/fwl/cfwl_combobox.cpp index 0a5ccd0e7c..20134a830b 100644 --- a/xfa/fwl/cfwl_combobox.cpp +++ b/xfa/fwl/cfwl_combobox.cpp @@ -332,7 +332,7 @@ void CFWL_ComboBox::ShowDropList(bool bActivate) { m_rtList.width = std::max(m_rtList.width, m_rtClient.width); m_rtProxy = m_rtList; - GetPopupPos(0, m_rtProxy.height, rtAnchor, m_rtProxy); + GetPopupPos(0, m_rtProxy.height, rtAnchor, &m_rtProxy); m_pComboBoxProxy->SetWidgetRect(m_rtProxy); m_pComboBoxProxy->Update(); @@ -551,7 +551,7 @@ void CFWL_ComboBox::DisForm_ShowDropList(bool bActivate) { float fPopupMax = fItemHeight * iItems + fBorder * 2; CFX_RectF rtList(m_rtClient.left, 0, m_pProperties->m_rtWidget.width, 0); - GetPopupPos(fPopupMin, fPopupMax, m_pProperties->m_rtWidget, rtList); + GetPopupPos(fPopupMin, fPopupMax, m_pProperties->m_rtWidget, &rtList); m_pListBox->SetWidgetRect(rtList); m_pListBox->Update(); @@ -1018,28 +1018,22 @@ void CFWL_ComboBox::DisForm_OnKey(CFWL_MessageKey* pMsg) { void CFWL_ComboBox::GetPopupPos(float fMinHeight, float fMaxHeight, const CFX_RectF& rtAnchor, - CFX_RectF& rtPopup) { + CFX_RectF* pPopupRect) { if (m_pWidgetMgr->IsFormDisabled()) { m_pWidgetMgr->GetAdapterPopupPos(this, fMinHeight, fMaxHeight, rtAnchor, - rtPopup); + pPopupRect); 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); + float fPopupHeight = + pdfium::clamp(pPopupRect->height, fMinHeight, fMaxHeight); + float fPopupWidth = std::max(rtAnchor.width, pPopupRect->width); + float fPopupBottom = rtAnchor.bottom() + fPopupHeight; + float fPopupTop = (fPopupBottom + point.y > 0.0f) + ? rtAnchor.top - fPopupHeight + : rtAnchor.bottom(); + + *pPopupRect = CFX_RectF(rtAnchor.left, fPopupTop, fPopupWidth, fPopupHeight); + pPopupRect->Offset(point.x, point.y); } diff --git a/xfa/fwl/cfwl_combobox.h b/xfa/fwl/cfwl_combobox.h index 6dbd05df78..bd8cd056eb 100644 --- a/xfa/fwl/cfwl_combobox.h +++ b/xfa/fwl/cfwl_combobox.h @@ -119,7 +119,7 @@ class CFWL_ComboBox : public CFWL_Widget { void GetPopupPos(float fMinHeight, float fMaxHeight, const CFX_RectF& rtAnchor, - CFX_RectF& rtPopup); + CFX_RectF* pPopupRect); void OnFocusChanged(CFWL_Message* pMsg, bool bSet); void OnLButtonDown(CFWL_MessageMouse* pMsg); diff --git a/xfa/fwl/cfwl_datetimepicker.cpp b/xfa/fwl/cfwl_datetimepicker.cpp index 101540ffc0..66e55dea9c 100644 --- a/xfa/fwl/cfwl_datetimepicker.cpp +++ b/xfa/fwl/cfwl_datetimepicker.cpp @@ -241,7 +241,7 @@ void CFWL_DateTimePicker::ShowMonthCalendar(bool bActivate) { CFX_RectF rtAnchor(0, 0, m_pProperties->m_rtWidget.width, m_pProperties->m_rtWidget.height); - GetPopupPos(0, rtMonth.height, rtAnchor, rtMonth); + GetPopupPos(0, rtMonth.height, rtAnchor, &rtMonth); m_pForm->SetWidgetRect(rtMonth); rtMonth.left = rtMonth.top = 0; @@ -356,7 +356,7 @@ void CFWL_DateTimePicker::DisForm_ShowMonthCalendar(bool bActivate) { rtAnchor.width = rtMonthCal.width; rtMonthCal.left = m_rtClient.left; rtMonthCal.top = rtAnchor.Height(); - GetPopupPos(fPopupMin, fPopupMax, rtAnchor, rtMonthCal); + GetPopupPos(fPopupMin, fPopupMax, rtAnchor, &rtMonthCal); m_pMonthCal->SetWidgetRect(rtMonthCal); if (m_iYear > 0 && m_iMonth > 0 && m_iDay > 0) m_pMonthCal->SetSelect(m_iYear, m_iMonth, m_iDay); @@ -608,20 +608,18 @@ void CFWL_DateTimePicker::DisForm_OnFocusChanged(CFWL_Message* pMsg, void CFWL_DateTimePicker::GetPopupPos(float fMinHeight, float fMaxHeight, const CFX_RectF& rtAnchor, - CFX_RectF& rtPopup) { + CFX_RectF* pPopupRect) { if (m_pWidgetMgr->IsFormDisabled()) { m_pWidgetMgr->GetAdapterPopupPos(this, fMinHeight, fMaxHeight, rtAnchor, - rtPopup); + pPopupRect); return; } CFX_PointF point = TransformTo(nullptr, CFX_PointF()); - if (rtAnchor.bottom() + point.y > 0.0f) { - rtPopup = CFX_RectF(rtAnchor.left, rtAnchor.top - rtPopup.height, - rtPopup.width, rtPopup.height); - } else { - rtPopup = CFX_RectF(rtAnchor.left, rtAnchor.bottom(), rtPopup.width, - rtPopup.height); - } - rtPopup.Offset(point.x, point.y); + float fPopupTop = (rtAnchor.bottom() + point.y > 0.0f) + ? rtAnchor.top - pPopupRect->height + : rtAnchor.bottom(); + *pPopupRect = CFX_RectF(rtAnchor.left, fPopupTop, pPopupRect->width, + pPopupRect->height); + pPopupRect->Offset(point.x, point.y); } diff --git a/xfa/fwl/cfwl_datetimepicker.h b/xfa/fwl/cfwl_datetimepicker.h index d20df084be..4bfd3d022a 100644 --- a/xfa/fwl/cfwl_datetimepicker.h +++ b/xfa/fwl/cfwl_datetimepicker.h @@ -78,7 +78,7 @@ class CFWL_DateTimePicker : public CFWL_Widget { void GetPopupPos(float fMinHeight, float fMaxHeight, const CFX_RectF& rtAnchor, - CFX_RectF& rtPopup); + CFX_RectF* pPopupRect); void OnFocusChanged(CFWL_Message* pMsg, bool bSet); void OnLButtonDown(CFWL_MessageMouse* pMsg); void OnLButtonUp(CFWL_MessageMouse* pMsg); diff --git a/xfa/fwl/cfwl_widgetmgr.cpp b/xfa/fwl/cfwl_widgetmgr.cpp index 0860556665..32b275cd2e 100644 --- a/xfa/fwl/cfwl_widgetmgr.cpp +++ b/xfa/fwl/cfwl_widgetmgr.cpp @@ -382,8 +382,9 @@ void CFWL_WidgetMgr::GetAdapterPopupPos(CFWL_Widget* pWidget, float fMinHeight, float fMaxHeight, const CFX_RectF& rtAnchor, - CFX_RectF& rtPopup) const { - m_pAdapter->GetPopupPos(pWidget, fMinHeight, fMaxHeight, rtAnchor, rtPopup); + CFX_RectF* pPopupRect) const { + m_pAdapter->GetPopupPos(pWidget, fMinHeight, fMaxHeight, rtAnchor, + pPopupRect); } void CFWL_WidgetMgr::OnProcessMessageToForm(CFWL_Message* pMessage) { diff --git a/xfa/fwl/cfwl_widgetmgr.h b/xfa/fwl/cfwl_widgetmgr.h index 153d0a903e..8a6e974447 100644 --- a/xfa/fwl/cfwl_widgetmgr.h +++ b/xfa/fwl/cfwl_widgetmgr.h @@ -64,7 +64,7 @@ class CFWL_WidgetMgr { float fMinHeight, float fMaxHeight, const CFX_RectF& rtAnchor, - CFX_RectF& rtPopup) const; + CFX_RectF* pPopupRect) const; private: class Item { |