summaryrefslogtreecommitdiff
path: root/xfa/fwl
diff options
context:
space:
mode:
Diffstat (limited to 'xfa/fwl')
-rw-r--r--xfa/fwl/cfwl_combolist.cpp18
-rw-r--r--xfa/fwl/cfwl_combolist.h2
-rw-r--r--xfa/fwl/cfwl_notedriver.cpp29
-rw-r--r--xfa/fwl/cfwl_widget.cpp106
-rw-r--r--xfa/fwl/cfwl_widget.h2
-rw-r--r--xfa/fwl/cfwl_widgetmgr.cpp24
6 files changed, 88 insertions, 93 deletions
diff --git a/xfa/fwl/cfwl_combolist.cpp b/xfa/fwl/cfwl_combolist.cpp
index d411f03ca3..171b54121c 100644
--- a/xfa/fwl/cfwl_combolist.cpp
+++ b/xfa/fwl/cfwl_combolist.cpp
@@ -63,12 +63,11 @@ void CFWL_ComboList::ChangeSelected(int32_t iSel) {
RepaintRect(rtInvalidate);
}
-void CFWL_ComboList::ClientToOuter(FX_FLOAT& fx, FX_FLOAT& fy) {
- fx += m_pProperties->m_rtWidget.left, fy += m_pProperties->m_rtWidget.top;
+CFX_PointF CFWL_ComboList::ClientToOuter(const CFX_PointF& point) {
+ CFX_PointF ret = point + CFX_PointF(m_pProperties->m_rtWidget.left,
+ m_pProperties->m_rtWidget.top);
CFWL_Widget* pOwner = GetOwner();
- if (!pOwner)
- return;
- pOwner->TransformTo(m_pOuter, fx, fy);
+ return pOwner ? pOwner->TransformTo(m_pOuter, ret) : ret;
}
void CFWL_ComboList::OnProcessMessage(CFWL_Message* pMessage) {
@@ -148,7 +147,10 @@ void CFWL_ComboList::OnDropListMouseMove(CFWL_MessageMouse* pMsg) {
ChangeSelected(GetItemIndex(this, hItem));
} else if (m_bNotifyOwner) {
- ClientToOuter(pMsg->m_fx, pMsg->m_fy);
+ CFX_PointF point = ClientToOuter(CFX_PointF(pMsg->m_fx, pMsg->m_fy));
+ pMsg->m_fx = point.x;
+ pMsg->m_fy = point.y;
+
CFWL_ComboBox* pOuter = static_cast<CFWL_ComboBox*>(m_pOuter);
pOuter->GetDelegate()->OnProcessMessage(pMsg);
}
@@ -165,7 +167,9 @@ void CFWL_ComboList::OnDropListLButtonDown(CFWL_MessageMouse* pMsg) {
void CFWL_ComboList::OnDropListLButtonUp(CFWL_MessageMouse* pMsg) {
CFWL_ComboBox* pOuter = static_cast<CFWL_ComboBox*>(m_pOuter);
if (m_bNotifyOwner) {
- ClientToOuter(pMsg->m_fx, pMsg->m_fy);
+ CFX_PointF point = ClientToOuter(CFX_PointF(pMsg->m_fx, pMsg->m_fy));
+ pMsg->m_fx = point.x;
+ pMsg->m_fy = point.y;
pOuter->GetDelegate()->OnProcessMessage(pMsg);
return;
}
diff --git a/xfa/fwl/cfwl_combolist.h b/xfa/fwl/cfwl_combolist.h
index e1d5fd9b24..b7ba6b5780 100644
--- a/xfa/fwl/cfwl_combolist.h
+++ b/xfa/fwl/cfwl_combolist.h
@@ -29,7 +29,7 @@ class CFWL_ComboList : public CFWL_ListBox {
void SetNotifyOwner(bool notify) { m_bNotifyOwner = notify; }
private:
- void ClientToOuter(FX_FLOAT& fx, FX_FLOAT& fy);
+ CFX_PointF ClientToOuter(const CFX_PointF& point);
void OnDropListFocusChanged(CFWL_Message* pMsg, bool bSet);
void OnDropListMouseMove(CFWL_MessageMouse* pMsg);
void OnDropListLButtonDown(CFWL_MessageMouse* pMsg);
diff --git a/xfa/fwl/cfwl_notedriver.cpp b/xfa/fwl/cfwl_notedriver.cpp
index f4db9b14ab..6904759e59 100644
--- a/xfa/fwl/cfwl_notedriver.cpp
+++ b/xfa/fwl/cfwl_notedriver.cpp
@@ -341,8 +341,12 @@ bool CFWL_NoteDriver::DoMouse(CFWL_Message* pMessage,
pMsg->m_dwCmd == FWL_MouseCommand::Enter) {
return !!pMsg->m_pDstTarget;
}
- if (pMsg->m_pDstTarget != pMessageForm)
- pMsg->m_pDstTarget->TransformTo(pMessageForm, pMsg->m_fx, pMsg->m_fy);
+ if (pMsg->m_pDstTarget != pMessageForm) {
+ CFX_PointF point = pMsg->m_pDstTarget->TransformTo(
+ pMessageForm, CFX_PointF(pMsg->m_fx, pMsg->m_fy));
+ pMsg->m_fx = point.x;
+ pMsg->m_fy = point.y;
+ }
if (!DoMouseEx(pMsg, pMessageForm))
pMsg->m_pDstTarget = pMessageForm;
return true;
@@ -360,7 +364,10 @@ bool CFWL_NoteDriver::DoWheel(CFWL_Message* pMessage,
if (!pDst)
return false;
- pMessageForm->TransformTo(pDst, pMsg->m_fx, pMsg->m_fy);
+ CFX_PointF point =
+ pMessageForm->TransformTo(pDst, CFX_PointF(pMsg->m_fx, pMsg->m_fy));
+ pMsg->m_fx = point.x;
+ pMsg->m_fy = point.y;
pMsg->m_pDstTarget = pDst;
return true;
}
@@ -380,8 +387,12 @@ bool CFWL_NoteDriver::DoMouseEx(CFWL_Message* pMessage,
pWidgetMgr->GetWidgetAtPoint(pMessageForm, pMsg->m_fx, pMsg->m_fy);
}
if (pTarget) {
- if (pMessageForm != pTarget)
- pMessageForm->TransformTo(pTarget, pMsg->m_fx, pMsg->m_fy);
+ if (pMessageForm != pTarget) {
+ CFX_PointF point = pMessageForm->TransformTo(
+ pTarget, CFX_PointF(pMsg->m_fx, pMsg->m_fy));
+ pMsg->m_fx = point.x;
+ pMsg->m_fy = point.y;
+ }
}
if (!pTarget)
return false;
@@ -398,10 +409,10 @@ void CFWL_NoteDriver::MouseSecondary(CFWL_Message* pMessage) {
CFWL_MessageMouse* pMsg = static_cast<CFWL_MessageMouse*>(pMessage);
if (m_pHover) {
CFWL_MessageMouse msLeave(nullptr, m_pHover);
- msLeave.m_fx = pMsg->m_fx;
- msLeave.m_fy = pMsg->m_fy;
- pTarget->TransformTo(m_pHover, msLeave.m_fx, msLeave.m_fy);
-
+ CFX_PointF point =
+ pTarget->TransformTo(m_pHover, CFX_PointF(pMsg->m_fx, pMsg->m_fy));
+ msLeave.m_fx = point.x;
+ msLeave.m_fy = point.y;
msLeave.m_dwFlags = 0;
msLeave.m_dwCmd = FWL_MouseCommand::Leave;
DispatchMessage(&msLeave, nullptr);
diff --git a/xfa/fwl/cfwl_widget.cpp b/xfa/fwl/cfwl_widget.cpp
index e9c6ddc7d8..3462ea792a 100644
--- a/xfa/fwl/cfwl_widget.cpp
+++ b/xfa/fwl/cfwl_widget.cpp
@@ -159,9 +159,8 @@ FWL_WidgetHit CFWL_Widget::HitTest(FX_FLOAT fx, FX_FLOAT fy) {
return FWL_WidgetHit::Unknown;
}
-void CFWL_Widget::TransformTo(CFWL_Widget* pWidget,
- FX_FLOAT& fx,
- FX_FLOAT& fy) {
+CFX_PointF CFWL_Widget::TransformTo(CFWL_Widget* pWidget,
+ const CFX_PointF& point) {
if (m_pWidgetMgr->IsFormDisabled()) {
CFX_SizeF szOffset;
if (IsParent(pWidget)) {
@@ -171,50 +170,36 @@ void CFWL_Widget::TransformTo(CFWL_Widget* pWidget,
szOffset.width = -szOffset.width;
szOffset.height = -szOffset.height;
}
- fx += szOffset.width;
- fy += szOffset.height;
- return;
+ return point + CFX_PointF(szOffset.width, szOffset.height);
}
- CFX_RectF r;
- CFX_Matrix m;
+
+ CFX_PointF ret = point;
CFWL_Widget* parent = GetParent();
- if (parent) {
- r = GetWidgetRect();
- fx += r.left;
- fy += r.top;
- m = GetMatrix();
- m.TransformPoint(fx, fy);
- }
+ if (parent)
+ ret = GetMatrix().Transform(ret + GetWidgetRect().TopLeft());
+
CFWL_Widget* form1 = m_pWidgetMgr->GetSystemFormWidget(this);
if (!form1)
- return;
+ return ret;
+
+ if (!pWidget)
+ return ret + form1->GetWidgetRect().TopLeft();
- if (!pWidget) {
- r = form1->GetWidgetRect();
- fx += r.left;
- fy += r.top;
- return;
- }
CFWL_Widget* form2 = m_pWidgetMgr->GetSystemFormWidget(pWidget);
if (!form2)
- return;
+ return ret;
if (form1 != form2) {
- r = form1->GetWidgetRect();
- fx += r.left;
- fy += r.top;
- r = form2->GetWidgetRect();
- fx -= r.left;
- fy -= r.top;
+ ret += form1->GetWidgetRect().TopLeft();
+ ret -= form2->GetWidgetRect().TopLeft();
}
+
parent = pWidget->GetParent();
- if (parent) {
- CFX_Matrix m1;
- m1.SetReverse(pWidget->GetMatrix());
- m1.TransformPoint(fx, fy);
- r = pWidget->GetWidgetRect();
- fx -= r.left;
- fy -= r.top;
- }
+ if (!parent)
+ return ret;
+
+ CFX_Matrix m;
+ m.SetReverse(pWidget->GetMatrix());
+ return m.Transform(ret) - pWidget->GetWidgetRect().TopLeft();
}
CFX_Matrix CFWL_Widget::GetMatrix() {
@@ -419,32 +404,31 @@ bool CFWL_Widget::GetPopupPosMenu(FX_FLOAT fMinHeight,
FX_FLOAT fMaxHeight,
const CFX_RectF& rtAnchor,
CFX_RectF& rtPopup) {
- FX_FLOAT fx = 0;
- FX_FLOAT fy = 0;
-
if (GetStylesEx() & FWL_STYLEEXT_MNU_Vert) {
bool bLeft = m_pProperties->m_rtWidget.left < 0;
FX_FLOAT fRight = rtAnchor.right() + rtPopup.width;
- TransformTo(nullptr, fx, fy);
- if (fRight + fx > 0.0f || bLeft) {
+ 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;
+ }
+
+ FX_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 {
- FX_FLOAT fBottom = rtAnchor.bottom() + rtPopup.height;
- TransformTo(nullptr, fx, fy);
- if (fBottom + fy > 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 = CFX_RectF(rtAnchor.left, rtAnchor.bottom(), rtPopup.width,
+ rtPopup.height);
}
- rtPopup.Offset(fx, fy);
+ rtPopup.Offset(point.x, point.y);
return true;
}
@@ -452,9 +436,6 @@ bool CFWL_Widget::GetPopupPosComboBox(FX_FLOAT fMinHeight,
FX_FLOAT fMaxHeight,
const CFX_RectF& rtAnchor,
CFX_RectF& rtPopup) {
- FX_FLOAT fx = 0;
- FX_FLOAT fy = 0;
-
FX_FLOAT fPopHeight = rtPopup.height;
if (rtPopup.height > fMaxHeight)
fPopHeight = fMaxHeight;
@@ -463,15 +444,15 @@ bool CFWL_Widget::GetPopupPosComboBox(FX_FLOAT fMinHeight,
FX_FLOAT fWidth = std::max(rtAnchor.width, rtPopup.width);
FX_FLOAT fBottom = rtAnchor.bottom() + fPopHeight;
- TransformTo(nullptr, fx, fy);
- if (fBottom + fy > 0.0f) {
+ 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(fx, fy);
+ rtPopup.Offset(point.x, point.y);
return true;
}
@@ -479,18 +460,15 @@ bool CFWL_Widget::GetPopupPosGeneral(FX_FLOAT fMinHeight,
FX_FLOAT fMaxHeight,
const CFX_RectF& rtAnchor,
CFX_RectF& rtPopup) {
- FX_FLOAT fx = 0;
- FX_FLOAT fy = 0;
-
- TransformTo(nullptr, fx, fy);
- if (rtAnchor.bottom() + fy > 0.0f) {
+ 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(fx, fy);
+ rtPopup.Offset(point.x, point.y);
return true;
}
diff --git a/xfa/fwl/cfwl_widget.h b/xfa/fwl/cfwl_widget.h
index 74fa314bfd..a375005970 100644
--- a/xfa/fwl/cfwl_widget.h
+++ b/xfa/fwl/cfwl_widget.h
@@ -90,7 +90,7 @@ class CFWL_Widget : public IFWL_WidgetDelegate {
m_iLock--;
}
- void TransformTo(CFWL_Widget* pWidget, FX_FLOAT& fx, FX_FLOAT& fy);
+ CFX_PointF TransformTo(CFWL_Widget* pWidget, const CFX_PointF& point);
CFX_Matrix GetMatrix();
IFWL_ThemeProvider* GetThemeProvider() const;
diff --git a/xfa/fwl/cfwl_widgetmgr.cpp b/xfa/fwl/cfwl_widgetmgr.cpp
index 0af93dc38b..ea4cbde230 100644
--- a/xfa/fwl/cfwl_widgetmgr.cpp
+++ b/xfa/fwl/cfwl_widgetmgr.cpp
@@ -160,7 +160,10 @@ void CFWL_WidgetMgr::RepaintWidget(CFWL_Widget* pWidget,
if (!pNative)
return;
- pWidget->TransformTo(pNative, transformedRect.left, transformedRect.top);
+ CFX_PointF pos = pWidget->TransformTo(
+ pNative, CFX_PointF(transformedRect.left, transformedRect.top));
+ transformedRect.left = pos.x;
+ transformedRect.top = pos.y;
}
AddRedrawCounts(pNative);
m_pAdapter->RepaintWidget(pNative);
@@ -260,24 +263,21 @@ CFWL_Widget* CFWL_WidgetMgr::GetWidgetAtPoint(CFWL_Widget* parent,
if (!parent)
return nullptr;
- FX_FLOAT x1;
- FX_FLOAT y1;
+ CFX_PointF pos;
CFWL_Widget* child = GetLastChildWidget(parent);
while (child) {
if ((child->GetStates() & FWL_WGTSTATE_Invisible) == 0) {
- x1 = x;
- y1 = y;
CFX_Matrix m;
m.SetIdentity();
CFX_Matrix matrixOnParent;
m.SetReverse(matrixOnParent);
- m.TransformPoint(x1, y1);
+ pos = m.Transform(CFX_PointF(x, y));
+
CFX_RectF bounds = child->GetWidgetRect();
- if (bounds.Contains(x1, y1)) {
- x1 -= bounds.left;
- y1 -= bounds.top;
- return GetWidgetAtPoint(child, x1, y1);
+ if (bounds.Contains(pos.x, pos.y)) {
+ pos -= bounds.TopLeft();
+ return GetWidgetAtPoint(child, pos.x, pos.y);
}
}
child = GetPriorSiblingWidget(child);
@@ -484,7 +484,9 @@ void CFWL_WidgetMgr::DrawChild(CFWL_Widget* parent,
widgetMatrix.Concat(*pMatrix);
if (!bFormDisable) {
- widgetMatrix.TransformPoint(clipBounds.left, clipBounds.top);
+ CFX_PointF pos = widgetMatrix.Transform(clipBounds.TopLeft());
+ clipBounds.left = pos.x;
+ clipBounds.top = pos.y;
clipBounds.Intersect(rtClip);
if (clipBounds.IsEmpty())
continue;