summaryrefslogtreecommitdiff
path: root/xfa/fwl
diff options
context:
space:
mode:
authorHenrique Nakashima <hnakashima@chromium.org>2018-03-08 18:09:49 +0000
committerChromium commit bot <commit-bot@chromium.org>2018-03-08 18:09:49 +0000
commita724cb2df9f7b766174ac578cd4d435596898cc1 (patch)
tree31af95a1bad460b72e2ce8e1a5922709494e12e9 /xfa/fwl
parent403d1ad40b3bc8a96a28fc211fff2c106f590ed8 (diff)
downloadpdfium-a724cb2df9f7b766174ac578cd4d435596898cc1.tar.xz
Move GetPopupPos from CFWL_Widget to subclasses that call it.
Change-Id: I27118d2c8d0d7e4509b6a89cd32a7c9c906d19bc Reviewed-on: https://pdfium-review.googlesource.com/28270 Commit-Queue: dsinclair <dsinclair@chromium.org> Reviewed-by: dsinclair <dsinclair@chromium.org>
Diffstat (limited to 'xfa/fwl')
-rw-r--r--xfa/fwl/cfwl_combobox.cpp29
-rw-r--r--xfa/fwl/cfwl_combobox.h5
-rw-r--r--xfa/fwl/cfwl_datetimepicker.cpp21
-rw-r--r--xfa/fwl/cfwl_datetimepicker.h4
-rw-r--r--xfa/fwl/cfwl_widget.cpp94
-rw-r--r--xfa/fwl/cfwl_widget.h16
6 files changed, 59 insertions, 110 deletions
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);
+}
diff --git a/xfa/fwl/cfwl_combobox.h b/xfa/fwl/cfwl_combobox.h
index a9dc635373..6dbd05df78 100644
--- a/xfa/fwl/cfwl_combobox.h
+++ b/xfa/fwl/cfwl_combobox.h
@@ -116,6 +116,11 @@ class CFWL_ComboBox : public CFWL_Widget {
void ResetEditAlignment();
void ResetListItemAlignment();
void InitProxyForm();
+ void GetPopupPos(float fMinHeight,
+ float fMaxHeight,
+ const CFX_RectF& rtAnchor,
+ CFX_RectF& rtPopup);
+
void OnFocusChanged(CFWL_Message* pMsg, bool bSet);
void OnLButtonDown(CFWL_MessageMouse* pMsg);
void OnLButtonUp(CFWL_MessageMouse* pMsg);
diff --git a/xfa/fwl/cfwl_datetimepicker.cpp b/xfa/fwl/cfwl_datetimepicker.cpp
index f3da454354..101540ffc0 100644
--- a/xfa/fwl/cfwl_datetimepicker.cpp
+++ b/xfa/fwl/cfwl_datetimepicker.cpp
@@ -604,3 +604,24 @@ void CFWL_DateTimePicker::DisForm_OnFocusChanged(CFWL_Message* pMsg,
rtInvalidate.Inflate(2, 2);
RepaintRect(rtInvalidate);
}
+
+void CFWL_DateTimePicker::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;
+ }
+
+ 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);
+}
diff --git a/xfa/fwl/cfwl_datetimepicker.h b/xfa/fwl/cfwl_datetimepicker.h
index 6d536016dd..d20df084be 100644
--- a/xfa/fwl/cfwl_datetimepicker.h
+++ b/xfa/fwl/cfwl_datetimepicker.h
@@ -75,6 +75,10 @@ class CFWL_DateTimePicker : public CFWL_Widget {
WideString FormatDateString(int32_t iYear, int32_t iMonth, int32_t iDay);
void ResetEditAlignment();
void InitProxyForm();
+ void GetPopupPos(float fMinHeight,
+ float fMaxHeight,
+ const CFX_RectF& rtAnchor,
+ CFX_RectF& rtPopup);
void OnFocusChanged(CFWL_Message* pMsg, bool bSet);
void OnLButtonDown(CFWL_MessageMouse* pMsg);
void OnLButtonUp(CFWL_MessageMouse* pMsg);
diff --git a/xfa/fwl/cfwl_widget.cpp b/xfa/fwl/cfwl_widget.cpp
index b9b04cf1f4..c8d0db682a 100644
--- a/xfa/fwl/cfwl_widget.cpp
+++ b/xfa/fwl/cfwl_widget.cpp
@@ -379,100 +379,6 @@ void CFWL_Widget::SetGrab(bool bSet) {
pDriver->SetGrab(this, bSet);
}
-void CFWL_Widget::GetPopupPos(float fMinHeight,
- float fMaxHeight,
- const CFX_RectF& rtAnchor,
- CFX_RectF& rtPopup) {
- if (GetClassID() == FWL_Type::ComboBox) {
- if (m_pWidgetMgr->IsFormDisabled()) {
- m_pWidgetMgr->GetAdapterPopupPos(this, fMinHeight, fMaxHeight, rtAnchor,
- rtPopup);
- return;
- }
- GetPopupPosComboBox(fMinHeight, fMaxHeight, rtAnchor, rtPopup);
- return;
- }
- if (GetClassID() == FWL_Type::DateTimePicker &&
- m_pWidgetMgr->IsFormDisabled()) {
- m_pWidgetMgr->GetAdapterPopupPos(this, fMinHeight, fMaxHeight, rtAnchor,
- rtPopup);
- return;
- }
- GetPopupPosGeneral(fMinHeight, fMaxHeight, rtAnchor, rtPopup);
-}
-
-bool CFWL_Widget::GetPopupPosMenu(float fMinHeight,
- float fMaxHeight,
- const CFX_RectF& rtAnchor,
- CFX_RectF& rtPopup) {
- if (GetStylesEx() & FWL_STYLEEXT_MNU_Vert) {
- bool bLeft = m_pProperties->m_rtWidget.left < 0;
- float fRight = rtAnchor.right() + rtPopup.width;
- CFX_PointF point = TransformTo(nullptr, CFX_PointF());
- if (fRight + point.x > 0.0f || bLeft) {
- rtPopup = CFX_RectF(rtAnchor.left - rtPopup.width, rtAnchor.top,
- rtPopup.width, rtPopup.height);
- } else {
- rtPopup = CFX_RectF(rtAnchor.right(), rtAnchor.top, rtPopup.width,
- rtPopup.height);
- }
- rtPopup.Offset(point.x, point.y);
- return true;
- }
-
- float fBottom = rtAnchor.bottom() + rtPopup.height;
- CFX_PointF point = TransformTo(nullptr, point);
- if (fBottom + 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);
- return true;
-}
-
-bool CFWL_Widget::GetPopupPosComboBox(float fMinHeight,
- float fMaxHeight,
- const CFX_RectF& rtAnchor,
- CFX_RectF& rtPopup) {
- 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);
- return true;
-}
-
-bool CFWL_Widget::GetPopupPosGeneral(float fMinHeight,
- float fMaxHeight,
- const CFX_RectF& rtAnchor,
- CFX_RectF& rtPopup) {
- 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);
- return true;
-}
-
void CFWL_Widget::RegisterEventTarget(CFWL_Widget* pEventSource) {
const CFWL_App* pApp = GetOwnerApp();
if (!pApp)
diff --git a/xfa/fwl/cfwl_widget.h b/xfa/fwl/cfwl_widget.h
index 27cb458b9e..66ec0e170c 100644
--- a/xfa/fwl/cfwl_widget.h
+++ b/xfa/fwl/cfwl_widget.h
@@ -136,10 +136,6 @@ class CFWL_Widget : public IFWL_WidgetDelegate {
FDE_TextAlignment iTTOAlign,
CFX_RectF& rect);
void SetGrab(bool bSet);
- void GetPopupPos(float fMinHeight,
- float fMaxHeight,
- const CFX_RectF& rtAnchor,
- CFX_RectF& rtPopup);
void RegisterEventTarget(CFWL_Widget* pEventSource);
void UnregisterEventTarget();
void DispatchEvent(CFWL_Event* pEvent);
@@ -163,18 +159,6 @@ class CFWL_Widget : public IFWL_WidgetDelegate {
bool IsPopup() const;
bool IsChild() const;
CFWL_Widget* GetRootOuter();
- bool GetPopupPosMenu(float fMinHeight,
- float fMaxHeight,
- const CFX_RectF& rtAnchor,
- CFX_RectF& rtPopup);
- bool GetPopupPosComboBox(float fMinHeight,
- float fMaxHeight,
- const CFX_RectF& rtAnchor,
- CFX_RectF& rtPopup);
- bool GetPopupPosGeneral(float fMinHeight,
- float fMaxHeight,
- const CFX_RectF& rtAnchor,
- CFX_RectF& rtPopup);
void DrawBackground(CXFA_Graphics* pGraphics,
CFWL_Part iPartBk,
IFWL_ThemeProvider* pTheme,