diff options
author | Dan Sinclair <dsinclair@chromium.org> | 2017-02-21 14:27:59 -0500 |
---|---|---|
committer | Chromium commit bot <commit-bot@chromium.org> | 2017-02-21 20:44:29 +0000 |
commit | b45ea1fce52d93615470bab8b671cba5907fb01e (patch) | |
tree | 15153c437a253f73b3f5bb154a294ace77fe2c6d | |
parent | 37a35df8c878d6e21a62ce0dfd2d480997d9e86c (diff) | |
download | pdfium-b45ea1fce52d93615470bab8b671cba5907fb01e.tar.xz |
Convert CFWL messages to use CFX_PointF
This Cl updates the various CFWL_Message classes to take CFX_PointF instead of
x,y values.
Change-Id: I5d9d01d68be64fc9e69c04574994c01286ad24e1
Reviewed-on: https://pdfium-review.googlesource.com/2811
Commit-Queue: dsinclair <dsinclair@chromium.org>
Reviewed-by: Tom Sepez <tsepez@chromium.org>
69 files changed, 514 insertions, 633 deletions
diff --git a/core/fpdfdoc/cpdf_interform.cpp b/core/fpdfdoc/cpdf_interform.cpp index 127e542227..d9f0db9747 100644 --- a/core/fpdfdoc/cpdf_interform.cpp +++ b/core/fpdfdoc/cpdf_interform.cpp @@ -900,8 +900,8 @@ CPDF_FormField* CPDF_InterForm::GetFieldByDict( } CPDF_FormControl* CPDF_InterForm::GetControlAtPoint(CPDF_Page* pPage, - FX_FLOAT pdf_x, - FX_FLOAT pdf_y, + const CFX_PointF& point, + int* z_order) const { CPDF_Array* pAnnotList = pPage->m_pFormDict->GetArrayFor("Annots"); if (!pAnnotList) @@ -918,8 +918,7 @@ CPDF_FormControl* CPDF_InterForm::GetControlAtPoint(CPDF_Page* pPage, continue; CPDF_FormControl* pControl = it->second.get(); - CFX_FloatRect rect = pControl->GetRect(); - if (!rect.Contains(pdf_x, pdf_y)) + if (!pControl->GetRect().Contains(point)) continue; if (z_order) diff --git a/core/fpdfdoc/cpdf_interform.h b/core/fpdfdoc/cpdf_interform.h index a42c4cef84..cbaaa7bc2d 100644 --- a/core/fpdfdoc/cpdf_interform.h +++ b/core/fpdfdoc/cpdf_interform.h @@ -55,8 +55,7 @@ class CPDF_InterForm { CPDF_FormField* GetFieldByDict(CPDF_Dictionary* pFieldDict) const; CPDF_FormControl* GetControlAtPoint(CPDF_Page* pPage, - FX_FLOAT pdf_x, - FX_FLOAT pdf_y, + const CFX_PointF& point, int* z_order) const; CPDF_FormControl* GetControlByDict(const CPDF_Dictionary* pWidgetDict) const; diff --git a/core/fpdfdoc/cpdf_linklist.cpp b/core/fpdfdoc/cpdf_linklist.cpp index 2d8f7e2339..0620dbf32b 100644 --- a/core/fpdfdoc/cpdf_linklist.cpp +++ b/core/fpdfdoc/cpdf_linklist.cpp @@ -30,8 +30,7 @@ const std::vector<CPDF_Dictionary*>* CPDF_LinkList::GetPageLinks( } CPDF_Link CPDF_LinkList::GetLinkAtPoint(CPDF_Page* pPage, - FX_FLOAT pdf_x, - FX_FLOAT pdf_y, + const CFX_PointF& point, int* z_order) { const std::vector<CPDF_Dictionary*>* pPageLinkList = GetPageLinks(pPage); if (!pPageLinkList) @@ -44,8 +43,7 @@ CPDF_Link CPDF_LinkList::GetLinkAtPoint(CPDF_Page* pPage, continue; CPDF_Link link(pAnnot); - CFX_FloatRect rect = link.GetRect(); - if (!rect.Contains(pdf_x, pdf_y)) + if (!link.GetRect().Contains(point)) continue; if (z_order) diff --git a/core/fpdfdoc/cpdf_linklist.h b/core/fpdfdoc/cpdf_linklist.h index 21d69fdd1d..129790f846 100644 --- a/core/fpdfdoc/cpdf_linklist.h +++ b/core/fpdfdoc/cpdf_linklist.h @@ -22,8 +22,7 @@ class CPDF_LinkList { ~CPDF_LinkList(); CPDF_Link GetLinkAtPoint(CPDF_Page* pPage, - FX_FLOAT pdf_x, - FX_FLOAT pdf_y, + const CFX_PointF& point, int* z_order); private: diff --git a/core/fxcrt/fx_basic_coords.cpp b/core/fxcrt/fx_basic_coords.cpp index c9f3195f36..3e306339f2 100644 --- a/core/fxcrt/fx_basic_coords.cpp +++ b/core/fxcrt/fx_basic_coords.cpp @@ -190,7 +190,10 @@ FX_RECT CFX_FloatRect::GetClosestRect() const { } bool CFX_FloatRect::Contains(const CFX_PointF& point) const { - return Contains(point.x, point.y); + CFX_FloatRect n1(*this); + n1.Normalize(); + return point.x <= n1.right && point.x >= n1.left && point.y <= n1.top && + point.y >= n1.bottom; } bool CFX_FloatRect::Contains(const CFX_FloatRect& other_rect) const { @@ -202,12 +205,6 @@ bool CFX_FloatRect::Contains(const CFX_FloatRect& other_rect) const { n2.top <= n1.top; } -bool CFX_FloatRect::Contains(FX_FLOAT x, FX_FLOAT y) const { - CFX_FloatRect n1(*this); - n1.Normalize(); - return x <= n1.right && x >= n1.left && y <= n1.top && y >= n1.bottom; -} - void CFX_FloatRect::UpdateRect(FX_FLOAT x, FX_FLOAT y) { left = std::min(left, x); right = std::max(right, x); diff --git a/core/fxcrt/fx_coordinates.h b/core/fxcrt/fx_coordinates.h index c773d374f1..d1fa8115b7 100644 --- a/core/fxcrt/fx_coordinates.h +++ b/core/fxcrt/fx_coordinates.h @@ -361,10 +361,10 @@ class CFX_RTemplate { return width <= fEpsilon || height <= fEpsilon; } void Empty() { width = height = 0; } - bool Contains(BaseType x, BaseType y) const { - return x >= left && x < left + width && y >= top && y < top + height; + bool Contains(const PointType& p) const { + return p.x >= left && p.x < left + width && p.y >= top && + p.y < top + height; } - bool Contains(const PointType& p) const { return Contains(p.x, p.y); } bool Contains(const RectType& rt) const { return rt.left >= left && rt.right() <= right() && rt.top >= top && rt.bottom() <= bottom(); @@ -474,7 +474,6 @@ class CFX_FloatRect { bool Contains(const CFX_PointF& point) const; bool Contains(const CFX_FloatRect& other_rect) const; - bool Contains(FX_FLOAT x, FX_FLOAT y) const; void Intersect(const CFX_FloatRect& other_rect); void Union(const CFX_FloatRect& other_rect); diff --git a/fpdfsdk/cpdfsdk_baannothandler.cpp b/fpdfsdk/cpdfsdk_baannothandler.cpp index 475ee4bf0e..fa83932a81 100644 --- a/fpdfsdk/cpdfsdk_baannothandler.cpp +++ b/fpdfsdk/cpdfsdk_baannothandler.cpp @@ -198,7 +198,5 @@ bool CPDFSDK_BAAnnotHandler::HitTest(CPDFSDK_PageView* pPageView, const CFX_PointF& point) { ASSERT(pPageView); ASSERT(pAnnot); - - CFX_FloatRect rect = GetViewBBox(pPageView, pAnnot); - return rect.Contains(point.x, point.y); + return GetViewBBox(pPageView, pAnnot).Contains(point); } diff --git a/fpdfsdk/cpdfsdk_pageview.cpp b/fpdfsdk/cpdfsdk_pageview.cpp index 0136077df5..1f041dfb25 100644 --- a/fpdfsdk/cpdfsdk_pageview.cpp +++ b/fpdfsdk/cpdfsdk_pageview.cpp @@ -130,22 +130,20 @@ void CPDFSDK_PageView::PageView_OnDraw(CFX_RenderDevice* pDevice, } } -CPDFSDK_Annot* CPDFSDK_PageView::GetFXAnnotAtPoint(FX_FLOAT pageX, - FX_FLOAT pageY) { +CPDFSDK_Annot* CPDFSDK_PageView::GetFXAnnotAtPoint(const CFX_PointF& point) { CPDFSDK_AnnotHandlerMgr* pAnnotMgr = m_pFormFillEnv->GetAnnotHandlerMgr(); CPDFSDK_AnnotIteration annotIteration(this, false); for (const auto& pSDKAnnot : annotIteration) { CFX_FloatRect rc = pAnnotMgr->Annot_OnGetViewBBox(this, pSDKAnnot.Get()); if (pSDKAnnot->GetAnnotSubtype() == CPDF_Annot::Subtype::POPUP) continue; - if (rc.Contains(pageX, pageY)) + if (rc.Contains(point)) return pSDKAnnot.Get(); } return nullptr; } -CPDFSDK_Annot* CPDFSDK_PageView::GetFXWidgetAtPoint(FX_FLOAT pageX, - FX_FLOAT pageY) { +CPDFSDK_Annot* CPDFSDK_PageView::GetFXWidgetAtPoint(const CFX_PointF& point) { CPDFSDK_AnnotHandlerMgr* pAnnotMgr = m_pFormFillEnv->GetAnnotHandlerMgr(); CPDFSDK_AnnotIteration annotIteration(this, false); for (const auto& pSDKAnnot : annotIteration) { @@ -156,8 +154,7 @@ CPDFSDK_Annot* CPDFSDK_PageView::GetFXWidgetAtPoint(FX_FLOAT pageX, #endif // PDF_ENABLE_XFA if (bHitTest) { pAnnotMgr->Annot_OnGetViewBBox(this, pSDKAnnot.Get()); - if (pAnnotMgr->Annot_OnHitTest(this, pSDKAnnot.Get(), - CFX_PointF(pageX, pageY))) + if (pAnnotMgr->Annot_OnHitTest(this, pSDKAnnot.Get(), point)) return pSDKAnnot.Get(); } } @@ -247,7 +244,7 @@ CPDFSDK_Annot* CPDFSDK_PageView::GetAnnotByXFAWidget(CXFA_FFWidget* hWidget) { #endif // PDF_ENABLE_XFA bool CPDFSDK_PageView::OnLButtonDown(const CFX_PointF& point, uint32_t nFlag) { - CPDFSDK_Annot::ObservedPtr pAnnot(GetFXWidgetAtPoint(point.x, point.y)); + CPDFSDK_Annot::ObservedPtr pAnnot(GetFXWidgetAtPoint(point)); if (!pAnnot) { m_pFormFillEnv->KillFocusAnnot(nFlag); return false; @@ -267,7 +264,7 @@ bool CPDFSDK_PageView::OnLButtonDown(const CFX_PointF& point, uint32_t nFlag) { #ifdef PDF_ENABLE_XFA bool CPDFSDK_PageView::OnRButtonDown(const CFX_PointF& point, uint32_t nFlag) { - CPDFSDK_Annot::ObservedPtr pAnnot(GetFXWidgetAtPoint(point.x, point.y)); + CPDFSDK_Annot::ObservedPtr pAnnot(GetFXWidgetAtPoint(point)); if (!pAnnot) return false; @@ -286,7 +283,7 @@ bool CPDFSDK_PageView::OnRButtonDown(const CFX_PointF& point, uint32_t nFlag) { bool CPDFSDK_PageView::OnRButtonUp(const CFX_PointF& point, uint32_t nFlag) { CPDFSDK_AnnotHandlerMgr* pAnnotHandlerMgr = m_pFormFillEnv->GetAnnotHandlerMgr(); - CPDFSDK_Annot::ObservedPtr pFXAnnot(GetFXWidgetAtPoint(point.x, point.y)); + CPDFSDK_Annot::ObservedPtr pFXAnnot(GetFXWidgetAtPoint(point)); if (!pFXAnnot) return false; @@ -300,7 +297,7 @@ bool CPDFSDK_PageView::OnRButtonUp(const CFX_PointF& point, uint32_t nFlag) { bool CPDFSDK_PageView::OnLButtonUp(const CFX_PointF& point, uint32_t nFlag) { CPDFSDK_AnnotHandlerMgr* pAnnotHandlerMgr = m_pFormFillEnv->GetAnnotHandlerMgr(); - CPDFSDK_Annot::ObservedPtr pFXAnnot(GetFXWidgetAtPoint(point.x, point.y)); + CPDFSDK_Annot::ObservedPtr pFXAnnot(GetFXWidgetAtPoint(point)); CPDFSDK_Annot::ObservedPtr pFocusAnnot(GetFocusAnnot()); if (pFocusAnnot && pFocusAnnot != pFXAnnot) { // Last focus Annot gets a chance to handle the event. @@ -314,7 +311,7 @@ bool CPDFSDK_PageView::OnLButtonUp(const CFX_PointF& point, uint32_t nFlag) { bool CPDFSDK_PageView::OnMouseMove(const CFX_PointF& point, int nFlag) { CPDFSDK_AnnotHandlerMgr* pAnnotHandlerMgr = m_pFormFillEnv->GetAnnotHandlerMgr(); - CPDFSDK_Annot::ObservedPtr pFXAnnot(GetFXAnnotAtPoint(point.x, point.y)); + CPDFSDK_Annot::ObservedPtr pFXAnnot(GetFXAnnotAtPoint(point)); if (pFXAnnot) { if (m_pCaptureWidget && m_pCaptureWidget != pFXAnnot) { m_bExitWidget = true; @@ -347,7 +344,7 @@ bool CPDFSDK_PageView::OnMouseWheel(double deltaX, double deltaY, const CFX_PointF& point, int nFlag) { - CPDFSDK_Annot::ObservedPtr pAnnot(GetFXWidgetAtPoint(point.x, point.y)); + CPDFSDK_Annot::ObservedPtr pAnnot(GetFXWidgetAtPoint(point)); if (!pAnnot) return false; diff --git a/fpdfsdk/cpdfsdk_pageview.h b/fpdfsdk/cpdfsdk_pageview.h index 495f1685d6..bcd5177c1a 100644 --- a/fpdfsdk/cpdfsdk_pageview.h +++ b/fpdfsdk/cpdfsdk_pageview.h @@ -35,9 +35,6 @@ class CPDFSDK_PageView final : public CPDF_Page::View { CPDF_RenderOptions* pOptions); #endif // PDF_ENABLE_XFA - CPDFSDK_Annot* GetFXAnnotAtPoint(FX_FLOAT pageX, FX_FLOAT pageY); - CPDFSDK_Annot* GetFXWidgetAtPoint(FX_FLOAT pageX, FX_FLOAT pageY); - void LoadFXAnnots(); CPDFSDK_Annot* GetFocusAnnot(); bool IsValidAnnot(const CPDF_Annot* p) const; @@ -96,6 +93,9 @@ class CPDFSDK_PageView final : public CPDF_Page::View { #endif // PDF_ENABLE_XFA private: + CPDFSDK_Annot* GetFXAnnotAtPoint(const CFX_PointF& point); + CPDFSDK_Annot* GetFXWidgetAtPoint(const CFX_PointF& point); + int GetPageIndexForStaticPDF() const; CFX_Matrix m_curMatrix; diff --git a/fpdfsdk/cpdfsdk_widget.cpp b/fpdfsdk/cpdfsdk_widget.cpp index 7821e1f528..8925c9a302 100644 --- a/fpdfsdk/cpdfsdk_widget.cpp +++ b/fpdfsdk/cpdfsdk_widget.cpp @@ -1907,18 +1907,3 @@ int32_t CPDFSDK_Widget::GetAppearanceAge() const { int32_t CPDFSDK_Widget::GetValueAge() const { return m_nValueAge; } - -bool CPDFSDK_Widget::HitTest(FX_FLOAT pageX, FX_FLOAT pageY) { - CPDF_Annot* pAnnot = GetPDFAnnot(); - CFX_FloatRect annotRect = pAnnot->GetRect(); - if (!annotRect.Contains(pageX, pageY)) - return false; - - if (!IsVisible()) - return false; - - if ((GetFieldFlags() & FIELDFLAG_READONLY) == FIELDFLAG_READONLY) - return false; - - return true; -} diff --git a/fpdfsdk/cpdfsdk_widget.h b/fpdfsdk/cpdfsdk_widget.h index 69114d1295..21e5169706 100644 --- a/fpdfsdk/cpdfsdk_widget.h +++ b/fpdfsdk/cpdfsdk_widget.h @@ -138,8 +138,6 @@ class CPDFSDK_Widget : public CPDFSDK_BAAnnot { CPDF_Annot::AppearanceMode mode, const CPDF_RenderOptions* pOptions) override; - bool HitTest(FX_FLOAT pageX, FX_FLOAT pageY); - private: void ResetAppearance_PushButton(); void ResetAppearance_CheckBox(); diff --git a/fpdfsdk/cpdfsdk_widgethandler.cpp b/fpdfsdk/cpdfsdk_widgethandler.cpp index bc085464ca..e85d24c4e0 100644 --- a/fpdfsdk/cpdfsdk_widgethandler.cpp +++ b/fpdfsdk/cpdfsdk_widgethandler.cpp @@ -282,7 +282,5 @@ bool CPDFSDK_WidgetHandler::HitTest(CPDFSDK_PageView* pPageView, const CFX_PointF& point) { ASSERT(pPageView); ASSERT(pAnnot); - - CFX_FloatRect rect = GetViewBBox(pPageView, pAnnot); - return rect.Contains(point.x, point.y); + return GetViewBBox(pPageView, pAnnot).Contains(point); } diff --git a/fpdfsdk/cpdfsdk_xfawidgethandler.cpp b/fpdfsdk/cpdfsdk_xfawidgethandler.cpp index d7bef32acd..41c21e0bd8 100644 --- a/fpdfsdk/cpdfsdk_xfawidgethandler.cpp +++ b/fpdfsdk/cpdfsdk_xfawidgethandler.cpp @@ -121,7 +121,7 @@ bool CPDFSDK_XFAWidgetHandler::HitTest(CPDFSDK_PageView* pPageView, return false; FWL_WidgetHit dwHitTest = - pWidgetHandler->OnHitTest(pAnnot->GetXFAWidget(), point.x, point.y); + pWidgetHandler->OnHitTest(pAnnot->GetXFAWidget(), point); return dwHitTest != FWL_WidgetHit::Unknown; } @@ -153,7 +153,7 @@ bool CPDFSDK_XFAWidgetHandler::OnLButtonDown(CPDFSDK_PageView* pPageView, CXFA_FFWidgetHandler* pWidgetHandler = GetXFAWidgetHandler(pAnnot->Get()); return pWidgetHandler->OnLButtonDown((*pAnnot)->GetXFAWidget(), - GetFWLFlags(nFlags), point.x, point.y); + GetFWLFlags(nFlags), point); } bool CPDFSDK_XFAWidgetHandler::OnLButtonUp(CPDFSDK_PageView* pPageView, @@ -165,7 +165,7 @@ bool CPDFSDK_XFAWidgetHandler::OnLButtonUp(CPDFSDK_PageView* pPageView, CXFA_FFWidgetHandler* pWidgetHandler = GetXFAWidgetHandler(pAnnot->Get()); return pWidgetHandler->OnLButtonUp((*pAnnot)->GetXFAWidget(), - GetFWLFlags(nFlags), point.x, point.y); + GetFWLFlags(nFlags), point); } bool CPDFSDK_XFAWidgetHandler::OnLButtonDblClk( @@ -178,7 +178,7 @@ bool CPDFSDK_XFAWidgetHandler::OnLButtonDblClk( CXFA_FFWidgetHandler* pWidgetHandler = GetXFAWidgetHandler(pAnnot->Get()); return pWidgetHandler->OnLButtonDblClk((*pAnnot)->GetXFAWidget(), - GetFWLFlags(nFlags), point.x, point.y); + GetFWLFlags(nFlags), point); } bool CPDFSDK_XFAWidgetHandler::OnMouseMove(CPDFSDK_PageView* pPageView, @@ -190,7 +190,7 @@ bool CPDFSDK_XFAWidgetHandler::OnMouseMove(CPDFSDK_PageView* pPageView, CXFA_FFWidgetHandler* pWidgetHandler = GetXFAWidgetHandler(pAnnot->Get()); return pWidgetHandler->OnMouseMove((*pAnnot)->GetXFAWidget(), - GetFWLFlags(nFlags), point.x, point.y); + GetFWLFlags(nFlags), point); } bool CPDFSDK_XFAWidgetHandler::OnMouseWheel(CPDFSDK_PageView* pPageView, @@ -202,8 +202,8 @@ bool CPDFSDK_XFAWidgetHandler::OnMouseWheel(CPDFSDK_PageView* pPageView, return false; CXFA_FFWidgetHandler* pWidgetHandler = GetXFAWidgetHandler(pAnnot->Get()); - return pWidgetHandler->OnMouseWheel( - (*pAnnot)->GetXFAWidget(), GetFWLFlags(nFlags), zDelta, point.x, point.y); + return pWidgetHandler->OnMouseWheel((*pAnnot)->GetXFAWidget(), + GetFWLFlags(nFlags), zDelta, point); } bool CPDFSDK_XFAWidgetHandler::OnRButtonDown(CPDFSDK_PageView* pPageView, @@ -215,7 +215,7 @@ bool CPDFSDK_XFAWidgetHandler::OnRButtonDown(CPDFSDK_PageView* pPageView, CXFA_FFWidgetHandler* pWidgetHandler = GetXFAWidgetHandler(pAnnot->Get()); return pWidgetHandler->OnRButtonDown((*pAnnot)->GetXFAWidget(), - GetFWLFlags(nFlags), point.x, point.y); + GetFWLFlags(nFlags), point); } bool CPDFSDK_XFAWidgetHandler::OnRButtonUp(CPDFSDK_PageView* pPageView, @@ -227,7 +227,7 @@ bool CPDFSDK_XFAWidgetHandler::OnRButtonUp(CPDFSDK_PageView* pPageView, CXFA_FFWidgetHandler* pWidgetHandler = GetXFAWidgetHandler(pAnnot->Get()); return pWidgetHandler->OnRButtonUp((*pAnnot)->GetXFAWidget(), - GetFWLFlags(nFlags), point.x, point.y); + GetFWLFlags(nFlags), point); } bool CPDFSDK_XFAWidgetHandler::OnRButtonDblClk( @@ -240,7 +240,7 @@ bool CPDFSDK_XFAWidgetHandler::OnRButtonDblClk( CXFA_FFWidgetHandler* pWidgetHandler = GetXFAWidgetHandler(pAnnot->Get()); return pWidgetHandler->OnRButtonDblClk((*pAnnot)->GetXFAWidget(), - GetFWLFlags(nFlags), point.x, point.y); + GetFWLFlags(nFlags), point); } bool CPDFSDK_XFAWidgetHandler::OnChar(CPDFSDK_Annot* pAnnot, diff --git a/fpdfsdk/formfiller/cffl_formfiller.cpp b/fpdfsdk/formfiller/cffl_formfiller.cpp index 3b06c30a28..36aaae0f29 100644 --- a/fpdfsdk/formfiller/cffl_formfiller.cpp +++ b/fpdfsdk/formfiller/cffl_formfiller.cpp @@ -634,8 +634,7 @@ bool CFFL_Button::OnLButtonDown(CPDFSDK_PageView* pPageView, CPDFSDK_Annot* pAnnot, uint32_t nFlags, const CFX_PointF& point) { - CFX_FloatRect rcAnnot = pAnnot->GetRect(); - if (!rcAnnot.Contains(point)) + if (!pAnnot->GetRect().Contains(point)) return false; m_bMouseDown = true; @@ -649,8 +648,7 @@ bool CFFL_Button::OnLButtonUp(CPDFSDK_PageView* pPageView, CPDFSDK_Annot* pAnnot, uint32_t nFlags, const CFX_PointF& point) { - CFX_FloatRect rcAnnot = pAnnot->GetRect(); - if (!rcAnnot.Contains(point.x, point.y)) + if (!pAnnot->GetRect().Contains(point)) return false; m_bMouseDown = false; diff --git a/fpdfsdk/formfiller/cffl_interactiveformfiller.cpp b/fpdfsdk/formfiller/cffl_interactiveformfiller.cpp index 7778408531..01d12c1687 100644 --- a/fpdfsdk/formfiller/cffl_interactiveformfiller.cpp +++ b/fpdfsdk/formfiller/cffl_interactiveformfiller.cpp @@ -35,8 +35,7 @@ CFFL_InteractiveFormFiller::~CFFL_InteractiveFormFiller() {} bool CFFL_InteractiveFormFiller::Annot_HitTest(CPDFSDK_PageView* pPageView, CPDFSDK_Annot* pAnnot, const CFX_PointF& point) { - CFX_FloatRect rc = pAnnot->GetRect(); - return rc.Contains(point.x, point.y); + return pAnnot->GetRect().Contains(point); } FX_RECT CFFL_InteractiveFormFiller::GetViewBBox(CPDFSDK_PageView* pPageView, diff --git a/fpdfsdk/fpdfdoc.cpp b/fpdfsdk/fpdfdoc.cpp index 82b898aa85..f7d94c2f97 100644 --- a/fpdfsdk/fpdfdoc.cpp +++ b/fpdfsdk/fpdfdoc.cpp @@ -257,7 +257,10 @@ DLLEXPORT FPDF_LINK STDCALL FPDFLink_GetLinkAtPoint(FPDF_PAGE page, if (!pLinkList) return nullptr; - return pLinkList->GetLinkAtPoint(pPage, (FX_FLOAT)x, (FX_FLOAT)y, nullptr) + return pLinkList + ->GetLinkAtPoint( + pPage, CFX_PointF(static_cast<FX_FLOAT>(x), static_cast<FX_FLOAT>(y)), + nullptr) .GetDict(); } @@ -273,7 +276,9 @@ DLLEXPORT int STDCALL FPDFLink_GetLinkZOrderAtPoint(FPDF_PAGE page, return -1; int z_order = -1; - pLinkList->GetLinkAtPoint(pPage, (FX_FLOAT)x, (FX_FLOAT)y, &z_order); + pLinkList->GetLinkAtPoint( + pPage, CFX_PointF(static_cast<FX_FLOAT>(x), static_cast<FX_FLOAT>(y)), + &z_order); return z_order; } diff --git a/fpdfsdk/fpdfformfill.cpp b/fpdfsdk/fpdfformfill.cpp index a891db9019..57ff6b669c 100644 --- a/fpdfsdk/fpdfformfill.cpp +++ b/fpdfsdk/fpdfformfill.cpp @@ -155,9 +155,10 @@ DLLEXPORT int STDCALL FPDFPage_HasFormFieldAtPoint(FPDF_FORMHANDLE hHandle, CPDF_Page* pPage = CPDFPageFromFPDFPage(page); if (pPage) { CPDF_InterForm interform(pPage->m_pDocument); - CPDF_FormControl* pFormCtrl = - interform.GetControlAtPoint(pPage, static_cast<FX_FLOAT>(page_x), - static_cast<FX_FLOAT>(page_y), nullptr); + CPDF_FormControl* pFormCtrl = interform.GetControlAtPoint( + pPage, CFX_PointF(static_cast<FX_FLOAT>(page_x), + static_cast<FX_FLOAT>(page_y)), + nullptr); if (!pFormCtrl) return -1; CPDF_FormField* pFormField = pFormCtrl->GetField(); @@ -197,8 +198,8 @@ DLLEXPORT int STDCALL FPDFPage_HasFormFieldAtPoint(FPDF_FORMHANDLE hHandle, rcWidget.bottom -= 1.0f; rcWidget.top += 1.0f; - if (rcWidget.Contains(static_cast<FX_FLOAT>(page_x), - static_cast<FX_FLOAT>(page_y))) { + if (rcWidget.Contains(CFX_PointF(static_cast<FX_FLOAT>(page_x), + static_cast<FX_FLOAT>(page_y)))) { return FPDF_FORMFIELD_XFA; } pXFAAnnot = pWidgetIterator->MoveToNext(); @@ -225,8 +226,10 @@ DLLEXPORT int STDCALL FPDFPage_FormFieldZOrderAtPoint(FPDF_FORMHANDLE hHandle, return -1; CPDF_InterForm interform(pPage->m_pDocument); int z_order = -1; - (void)interform.GetControlAtPoint(pPage, (FX_FLOAT)page_x, (FX_FLOAT)page_y, - &z_order); + (void)interform.GetControlAtPoint( + pPage, + CFX_PointF(static_cast<FX_FLOAT>(page_x), static_cast<FX_FLOAT>(page_y)), + &z_order); return z_order; } diff --git a/fpdfsdk/pdfwindow/PWL_ScrollBar.cpp b/fpdfsdk/pdfwindow/PWL_ScrollBar.cpp index a202513b92..652c8e1f45 100644 --- a/fpdfsdk/pdfwindow/PWL_ScrollBar.cpp +++ b/fpdfsdk/pdfwindow/PWL_ScrollBar.cpp @@ -723,13 +723,13 @@ bool CPWL_ScrollBar::OnLButtonDown(const CFX_PointF& point, uint32_t nFlag) { rcMinArea.Normalize(); rcMaxArea.Normalize(); - if (rcMinArea.Contains(point.x, point.y)) { + if (rcMinArea.Contains(point)) { m_sData.SubBig(); MovePosButton(true); NotifyScrollWindow(); } - if (rcMaxArea.Contains(point.x, point.y)) { + if (rcMaxArea.Contains(point)) { m_sData.AddBig(); MovePosButton(true); NotifyScrollWindow(); diff --git a/fpdfsdk/pdfwindow/PWL_Wnd.cpp b/fpdfsdk/pdfwindow/PWL_Wnd.cpp index 341ae7448f..f5d97adc19 100644 --- a/fpdfsdk/pdfwindow/PWL_Wnd.cpp +++ b/fpdfsdk/pdfwindow/PWL_Wnd.cpp @@ -673,11 +673,11 @@ void CPWL_Wnd::OnSetFocus() {} void CPWL_Wnd::OnKillFocus() {} bool CPWL_Wnd::WndHitTest(const CFX_PointF& point) const { - return IsValid() && IsVisible() && GetWindowRect().Contains(point.x, point.y); + return IsValid() && IsVisible() && GetWindowRect().Contains(point); } bool CPWL_Wnd::ClientHitTest(const CFX_PointF& point) const { - return IsValid() && IsVisible() && GetClientRect().Contains(point.x, point.y); + return IsValid() && IsVisible() && GetClientRect().Contains(point); } const CPWL_Wnd* CPWL_Wnd::GetRootWnd() const { diff --git a/xfa/fde/cfde_txtedtpage.cpp b/xfa/fde/cfde_txtedtpage.cpp index cfb7f83b2c..56e1a04a55 100644 --- a/xfa/fde/cfde_txtedtpage.cpp +++ b/xfa/fde/cfde_txtedtpage.cpp @@ -478,17 +478,15 @@ int32_t CFDE_TxtEdtPage::GetWidth(const FDE_TEXTEDITPIECE* pIdentity, void CFDE_TxtEdtPage::NormalizePt2Rect(CFX_PointF& ptF, const CFX_RectF& rtF, FX_FLOAT fTolerance) const { - if (rtF.Contains(ptF.x, ptF.y)) { + if (rtF.Contains(ptF)) return; - } - if (ptF.x < rtF.left) { + if (ptF.x < rtF.left) ptF.x = rtF.left; - } else if (ptF.x >= rtF.right()) { + else if (ptF.x >= rtF.right()) ptF.x = rtF.right() - fTolerance; - } - if (ptF.y < rtF.top) { + + if (ptF.y < rtF.top) ptF.y = rtF.top; - } else if (ptF.y >= rtF.bottom()) { + else if (ptF.y >= rtF.bottom()) ptF.y = rtF.bottom() - fTolerance; - } } diff --git a/xfa/fwl/cfwl_checkbox.cpp b/xfa/fwl/cfwl_checkbox.cpp index 2dc0808831..0102bc7cc4 100644 --- a/xfa/fwl/cfwl_checkbox.cpp +++ b/xfa/fwl/cfwl_checkbox.cpp @@ -297,7 +297,7 @@ void CFWL_CheckBox::OnLButtonUp(CFWL_MessageMouse* pMsg) { return; m_bBtnDown = false; - if (!m_rtClient.Contains(pMsg->m_fx, pMsg->m_fy)) + if (!m_rtClient.Contains(pMsg->m_pos)) return; m_pProperties->m_dwStates |= FWL_STATE_CKB_Hovered; @@ -311,7 +311,7 @@ void CFWL_CheckBox::OnMouseMove(CFWL_MessageMouse* pMsg) { bool bRepaint = false; if (m_bBtnDown) { - if (m_rtClient.Contains(pMsg->m_fx, pMsg->m_fy)) { + if (m_rtClient.Contains(pMsg->m_pos)) { if ((m_pProperties->m_dwStates & FWL_STATE_CKB_Pressed) == 0) { bRepaint = true; m_pProperties->m_dwStates |= FWL_STATE_CKB_Pressed; @@ -331,7 +331,7 @@ void CFWL_CheckBox::OnMouseMove(CFWL_MessageMouse* pMsg) { } } } else { - if (m_rtClient.Contains(pMsg->m_fx, pMsg->m_fy)) { + if (m_rtClient.Contains(pMsg->m_pos)) { if ((m_pProperties->m_dwStates & FWL_STATE_CKB_Hovered) == 0) { bRepaint = true; m_pProperties->m_dwStates |= FWL_STATE_CKB_Hovered; diff --git a/xfa/fwl/cfwl_combobox.cpp b/xfa/fwl/cfwl_combobox.cpp index a0a4cc0a79..6083943f94 100644 --- a/xfa/fwl/cfwl_combobox.cpp +++ b/xfa/fwl/cfwl_combobox.cpp @@ -118,10 +118,10 @@ void CFWL_ComboBox::Update() { Layout(); } -FWL_WidgetHit CFWL_ComboBox::HitTest(FX_FLOAT fx, FX_FLOAT fy) { +FWL_WidgetHit CFWL_ComboBox::HitTest(const CFX_PointF& point) { if (m_pWidgetMgr->IsFormDisabled()) - return DisForm_HitTest(fx, fy); - return CFWL_Widget::HitTest(fx, fy); + return DisForm_HitTest(point); + return CFWL_Widget::HitTest(point); } void CFWL_ComboBox::DrawWidget(CFX_Graphics* pGraphics, @@ -599,16 +599,16 @@ void CFWL_ComboBox::DisForm_Update() { Layout(); } -FWL_WidgetHit CFWL_ComboBox::DisForm_HitTest(FX_FLOAT fx, FX_FLOAT fy) { +FWL_WidgetHit CFWL_ComboBox::DisForm_HitTest(const CFX_PointF& point) { CFX_RectF rect(0, 0, m_pProperties->m_rtWidget.width - m_rtBtn.width, m_pProperties->m_rtWidget.height); - if (rect.Contains(fx, fy)) + if (rect.Contains(point)) return FWL_WidgetHit::Edit; - if (m_rtBtn.Contains(fx, fy)) + if (m_rtBtn.Contains(point)) return FWL_WidgetHit::Client; if (DisForm_IsDropListVisible()) { rect = m_pListBox->GetWidgetRect(); - if (rect.Contains(fx, fy)) + if (rect.Contains(point)) return FWL_WidgetHit::Client; } return FWL_WidgetHit::Unknown; @@ -791,7 +791,7 @@ void CFWL_ComboBox::OnLButtonDown(CFWL_MessageMouse* pMsg) { return; CFX_RectF& rtBtn = IsDropDownStyle() ? m_rtBtn : m_rtClient; - if (!rtBtn.Contains(pMsg->m_fx, pMsg->m_fy)) + if (!rtBtn.Contains(pMsg->m_pos)) return; if (IsDropDownStyle() && m_pEdit) @@ -808,7 +808,7 @@ void CFWL_ComboBox::OnLButtonDown(CFWL_MessageMouse* pMsg) { void CFWL_ComboBox::OnLButtonUp(CFWL_MessageMouse* pMsg) { m_bLButtonDown = false; - if (m_rtBtn.Contains(pMsg->m_fx, pMsg->m_fy)) + if (m_rtBtn.Contains(pMsg->m_pos)) m_iBtnState = CFWL_PartState_Hovered; else m_iBtnState = CFWL_PartState_Normal; @@ -818,7 +818,7 @@ void CFWL_ComboBox::OnLButtonUp(CFWL_MessageMouse* pMsg) { void CFWL_ComboBox::OnMouseMove(CFWL_MessageMouse* pMsg) { int32_t iOldState = m_iBtnState; - if (m_rtBtn.Contains(pMsg->m_fx, pMsg->m_fy)) { + if (m_rtBtn.Contains(pMsg->m_pos)) { m_iBtnState = m_bLButtonDown ? CFWL_PartState_Pressed : CFWL_PartState_Hovered; } else { @@ -950,7 +950,7 @@ void CFWL_ComboBox::DisForm_OnProcessMessage(CFWL_Message* pMessage) { void CFWL_ComboBox::DisForm_OnLButtonDown(CFWL_MessageMouse* pMsg) { bool bDropDown = DisForm_IsDropListVisible(); CFX_RectF& rtBtn = bDropDown ? m_rtBtn : m_rtClient; - if (!rtBtn.Contains(pMsg->m_fx, pMsg->m_fy)) + if (!rtBtn.Contains(pMsg->m_pos)) return; if (DisForm_IsDropListVisible()) { diff --git a/xfa/fwl/cfwl_combobox.h b/xfa/fwl/cfwl_combobox.h index d8db10dd2c..168e203162 100644 --- a/xfa/fwl/cfwl_combobox.h +++ b/xfa/fwl/cfwl_combobox.h @@ -51,7 +51,7 @@ class CFWL_ComboBox : public CFWL_Widget { void SetStates(uint32_t dwStates) override; void RemoveStates(uint32_t dwStates) override; void Update() override; - FWL_WidgetHit HitTest(FX_FLOAT fx, FX_FLOAT fy) override; + FWL_WidgetHit HitTest(const CFX_PointF& point) override; void DrawWidget(CFX_Graphics* pGraphics, const CFX_Matrix* pMatrix) override; void SetThemeProvider(IFWL_ThemeProvider* pThemeProvider) override; void OnProcessMessage(CFWL_Message* pMessage) override; @@ -135,7 +135,7 @@ class CFWL_ComboBox : public CFWL_Widget { void DisForm_ModifyStylesEx(uint32_t dwStylesExAdded, uint32_t dwStylesExRemoved); void DisForm_Update(); - FWL_WidgetHit DisForm_HitTest(FX_FLOAT fx, FX_FLOAT fy); + FWL_WidgetHit DisForm_HitTest(const CFX_PointF& point); void DisForm_DrawWidget(CFX_Graphics* pGraphics, const CFX_Matrix* pMatrix); CFX_RectF DisForm_GetBBox() const; void DisForm_Layout(); diff --git a/xfa/fwl/cfwl_comboboxproxy.cpp b/xfa/fwl/cfwl_comboboxproxy.cpp index 35ff3ef6e0..0e2779b5c9 100644 --- a/xfa/fwl/cfwl_comboboxproxy.cpp +++ b/xfa/fwl/cfwl_comboboxproxy.cpp @@ -71,8 +71,7 @@ void CFWL_ComboBoxProxy::OnLButtonDown(CFWL_Message* pMessage) { CFWL_NoteDriver* pDriver = static_cast<CFWL_NoteDriver*>(pApp->GetNoteDriver()); CFWL_MessageMouse* pMsg = static_cast<CFWL_MessageMouse*>(pMessage); - if (CFX_RectF(0, 0, GetWidgetRect().Size()) - .Contains(pMsg->m_fx, pMsg->m_fy)) { + if (CFX_RectF(0, 0, GetWidgetRect().Size()).Contains(pMsg->m_pos)) { m_bLButtonDown = true; pDriver->SetGrab(this, true); } else { @@ -97,8 +96,7 @@ void CFWL_ComboBoxProxy::OnLButtonUp(CFWL_Message* pMessage) { } CFWL_MessageMouse* pMsg = static_cast<CFWL_MessageMouse*>(pMessage); - if (!CFX_RectF(0, 0, GetWidgetRect().Size()) - .Contains(pMsg->m_fx, pMsg->m_fy) && + if (!CFX_RectF(0, 0, GetWidgetRect().Size()).Contains(pMsg->m_pos) && m_pComboBox->IsDropListVisible()) { m_pComboBox->ShowDropList(false); } diff --git a/xfa/fwl/cfwl_combolist.cpp b/xfa/fwl/cfwl_combolist.cpp index 171b54121c..5b700a90de 100644 --- a/xfa/fwl/cfwl_combolist.cpp +++ b/xfa/fwl/cfwl_combolist.cpp @@ -84,9 +84,8 @@ void CFWL_ComboList::OnProcessMessage(CFWL_Message* pMessage) { CFWL_ScrollBar* vertSB = GetVertScrollBar(); if (IsShowScrollBar(true) && vertSB) { CFX_RectF rect = vertSB->GetWidgetRect(); - if (rect.Contains(pMsg->m_fx, pMsg->m_fy)) { - pMsg->m_fx -= rect.left; - pMsg->m_fy -= rect.top; + if (rect.Contains(pMsg->m_pos)) { + pMsg->m_pos -= rect.TopLeft(); vertSB->GetDelegate()->OnProcessMessage(pMsg); return; } @@ -130,26 +129,24 @@ void CFWL_ComboList::OnDropListFocusChanged(CFWL_Message* pMsg, bool bSet) { } void CFWL_ComboList::OnDropListMouseMove(CFWL_MessageMouse* pMsg) { - if (GetRTClient().Contains(pMsg->m_fx, pMsg->m_fy)) { + if (GetRTClient().Contains(pMsg->m_pos)) { if (m_bNotifyOwner) m_bNotifyOwner = false; CFWL_ScrollBar* vertSB = GetVertScrollBar(); if (IsShowScrollBar(true) && vertSB) { CFX_RectF rect = vertSB->GetWidgetRect(); - if (rect.Contains(pMsg->m_fx, pMsg->m_fy)) + if (rect.Contains(pMsg->m_pos)) return; } - CFWL_ListItem* hItem = GetItemAtPoint(pMsg->m_fx, pMsg->m_fy); + CFWL_ListItem* hItem = GetItemAtPoint(pMsg->m_pos); if (!hItem) return; ChangeSelected(GetItemIndex(this, hItem)); } else if (m_bNotifyOwner) { - CFX_PointF point = ClientToOuter(CFX_PointF(pMsg->m_fx, pMsg->m_fy)); - pMsg->m_fx = point.x; - pMsg->m_fy = point.y; + pMsg->m_pos = ClientToOuter(pMsg->m_pos); CFWL_ComboBox* pOuter = static_cast<CFWL_ComboBox*>(m_pOuter); pOuter->GetDelegate()->OnProcessMessage(pMsg); @@ -157,7 +154,7 @@ void CFWL_ComboList::OnDropListMouseMove(CFWL_MessageMouse* pMsg) { } void CFWL_ComboList::OnDropListLButtonDown(CFWL_MessageMouse* pMsg) { - if (GetRTClient().Contains(pMsg->m_fx, pMsg->m_fy)) + if (GetRTClient().Contains(pMsg->m_pos)) return; CFWL_ComboBox* pOuter = static_cast<CFWL_ComboBox*>(m_pOuter); @@ -167,9 +164,7 @@ 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) { - CFX_PointF point = ClientToOuter(CFX_PointF(pMsg->m_fx, pMsg->m_fy)); - pMsg->m_fx = point.x; - pMsg->m_fy = point.y; + pMsg->m_pos = ClientToOuter(pMsg->m_pos); pOuter->GetDelegate()->OnProcessMessage(pMsg); return; } @@ -177,12 +172,12 @@ void CFWL_ComboList::OnDropListLButtonUp(CFWL_MessageMouse* pMsg) { CFWL_ScrollBar* vertSB = GetVertScrollBar(); if (IsShowScrollBar(true) && vertSB) { CFX_RectF rect = vertSB->GetWidgetRect(); - if (rect.Contains(pMsg->m_fx, pMsg->m_fy)) + if (rect.Contains(pMsg->m_pos)) return; } pOuter->ShowDropList(false); - CFWL_ListItem* hItem = GetItemAtPoint(pMsg->m_fx, pMsg->m_fy); + CFWL_ListItem* hItem = GetItemAtPoint(pMsg->m_pos); if (hItem) pOuter->ProcessSelChanged(true); } diff --git a/xfa/fwl/cfwl_datetimepicker.cpp b/xfa/fwl/cfwl_datetimepicker.cpp index 1a76727dac..a6ba65a3b2 100644 --- a/xfa/fwl/cfwl_datetimepicker.cpp +++ b/xfa/fwl/cfwl_datetimepicker.cpp @@ -101,14 +101,14 @@ void CFWL_DateTimePicker::Update() { return; } -FWL_WidgetHit CFWL_DateTimePicker::HitTest(FX_FLOAT fx, FX_FLOAT fy) { +FWL_WidgetHit CFWL_DateTimePicker::HitTest(const CFX_PointF& point) { if (m_pWidgetMgr->IsFormDisabled()) - return DisForm_HitTest(fx, fy); - if (m_rtClient.Contains(fx, fy)) + return DisForm_HitTest(point); + if (m_rtClient.Contains(point)) return FWL_WidgetHit::Client; if (IsMonthCalendarVisible()) { CFX_RectF rect = m_pMonthCal->GetWidgetRect(); - if (rect.Contains(fx, fy)) + if (rect.Contains(point)) return FWL_WidgetHit::Client; } return FWL_WidgetHit::Unknown; @@ -380,18 +380,18 @@ void CFWL_DateTimePicker::DisForm_ShowMonthCalendar(bool bActivate) { RepaintRect(rtInvalidate); } -FWL_WidgetHit CFWL_DateTimePicker::DisForm_HitTest(FX_FLOAT fx, - FX_FLOAT fy) const { +FWL_WidgetHit CFWL_DateTimePicker::DisForm_HitTest( + const CFX_PointF& point) const { CFX_RectF rect(0, 0, m_pProperties->m_rtWidget.width, m_pProperties->m_rtWidget.height); - if (rect.Contains(fx, fy)) + if (rect.Contains(point)) return FWL_WidgetHit::Edit; if (DisForm_IsNeedShowButton()) rect.width += m_fBtn; - if (rect.Contains(fx, fy)) + if (rect.Contains(point)) return FWL_WidgetHit::Client; if (IsMonthCalendarVisible()) { - if (m_pMonthCal->GetWidgetRect().Contains(fx, fy)) + if (m_pMonthCal->GetWidgetRect().Contains(point)) return FWL_WidgetHit::Client; } return FWL_WidgetHit::Unknown; @@ -539,7 +539,7 @@ void CFWL_DateTimePicker::OnLButtonDown(CFWL_MessageMouse* pMsg) { return; if ((m_pProperties->m_dwStates & FWL_WGTSTATE_Focused) == 0) SetFocus(true); - if (!m_rtBtn.Contains(pMsg->m_fx, pMsg->m_fy)) + if (!m_rtBtn.Contains(pMsg->m_pos)) return; if (IsMonthCalendarVisible()) { @@ -557,7 +557,7 @@ void CFWL_DateTimePicker::OnLButtonUp(CFWL_MessageMouse* pMsg) { return; m_bLBtnDown = false; - if (m_rtBtn.Contains(pMsg->m_fx, pMsg->m_fy)) + if (m_rtBtn.Contains(pMsg->m_pos)) m_iBtnState = CFWL_PartState_Hovered; else m_iBtnState = CFWL_PartState_Normal; @@ -565,7 +565,7 @@ void CFWL_DateTimePicker::OnLButtonUp(CFWL_MessageMouse* pMsg) { } void CFWL_DateTimePicker::OnMouseMove(CFWL_MessageMouse* pMsg) { - if (!m_rtBtn.Contains(pMsg->m_fx, pMsg->m_fy)) + if (!m_rtBtn.Contains(pMsg->m_pos)) m_iBtnState = CFWL_PartState_Normal; RepaintRect(m_rtBtn); } diff --git a/xfa/fwl/cfwl_datetimepicker.h b/xfa/fwl/cfwl_datetimepicker.h index 47d1c70fc3..2935ee8b1c 100644 --- a/xfa/fwl/cfwl_datetimepicker.h +++ b/xfa/fwl/cfwl_datetimepicker.h @@ -38,7 +38,7 @@ class CFWL_DateTimePicker : public CFWL_Widget { // CFWL_Widget FWL_Type GetClassID() const override; void Update() override; - FWL_WidgetHit HitTest(FX_FLOAT fx, FX_FLOAT fy) override; + FWL_WidgetHit HitTest(const CFX_PointF& point) override; void DrawWidget(CFX_Graphics* pGraphics, const CFX_Matrix* pMatrix) override; void SetThemeProvider(IFWL_ThemeProvider* pTP) override; void OnProcessMessage(CFWL_Message* pMessage) override; @@ -84,7 +84,7 @@ class CFWL_DateTimePicker : public CFWL_Widget { bool DisForm_IsMonthCalendarVisible() const; void DisForm_ShowMonthCalendar(bool bActivate); - FWL_WidgetHit DisForm_HitTest(FX_FLOAT fx, FX_FLOAT fy) const; + FWL_WidgetHit DisForm_HitTest(const CFX_PointF& point) const; bool DisForm_IsNeedShowButton() const; void DisForm_Update(); CFX_RectF DisForm_GetBBox() const; diff --git a/xfa/fwl/cfwl_edit.cpp b/xfa/fwl/cfwl_edit.cpp index a227176ed0..35a83f9da5 100644 --- a/xfa/fwl/cfwl_edit.cpp +++ b/xfa/fwl/cfwl_edit.cpp @@ -142,18 +142,18 @@ void CFWL_Edit::Update() { InitCaret(); } -FWL_WidgetHit CFWL_Edit::HitTest(FX_FLOAT fx, FX_FLOAT fy) { +FWL_WidgetHit CFWL_Edit::HitTest(const CFX_PointF& point) { if (m_pProperties->m_dwStyleExes & FWL_STYLEEXT_EDT_OuterScrollbar) { if (IsShowScrollBar(true)) { - if (m_pVertScrollBar->GetWidgetRect().Contains(fx, fy)) + if (m_pVertScrollBar->GetWidgetRect().Contains(point)) return FWL_WidgetHit::VScrollBar; } if (IsShowScrollBar(false)) { - if (m_pHorzScrollBar->GetWidgetRect().Contains(fx, fy)) + if (m_pHorzScrollBar->GetWidgetRect().Contains(point)) return FWL_WidgetHit::HScrollBar; } } - if (m_rtClient.Contains(fx, fy)) + if (m_rtClient.Contains(point)) return FWL_WidgetHit::Edit; return FWL_WidgetHit::Unknown; } @@ -1057,9 +1057,9 @@ void CFWL_Edit::LayoutScrollBar() { UpdateScroll(); } -void CFWL_Edit::DeviceToEngine(CFX_PointF& pt) { - pt.x += m_fScrollOffsetX - m_rtEngine.left; - pt.y += m_fScrollOffsetY - m_rtEngine.top - m_fVAlignOffset; +CFX_PointF CFWL_Edit::DeviceToEngine(const CFX_PointF& pt) { + return pt + CFX_PointF(m_fScrollOffsetX - m_rtEngine.left, + m_fScrollOffsetY - m_rtEngine.top - m_fVAlignOffset); } void CFWL_Edit::InitVerticalScrollBar() { @@ -1268,10 +1268,8 @@ void CFWL_Edit::DoButtonDown(CFWL_MessageMouse* pMsg) { if (!pPage) return; - CFX_PointF pt(pMsg->m_fx, pMsg->m_fy); - DeviceToEngine(pt); bool bBefore = true; - int32_t nIndex = pPage->GetCharIndex(pt, bBefore); + int32_t nIndex = pPage->GetCharIndex(DeviceToEngine(pMsg->m_pos), bBefore); if (nIndex < 0) nIndex = 0; @@ -1346,10 +1344,8 @@ void CFWL_Edit::OnButtonDblClk(CFWL_MessageMouse* pMsg) { if (!pPage) return; - CFX_PointF pt(pMsg->m_fx, pMsg->m_fy); - DeviceToEngine(pt); int32_t nCount = 0; - int32_t nIndex = pPage->SelectWord(pt, nCount); + int32_t nIndex = pPage->SelectWord(DeviceToEngine(pMsg->m_pos), nCount); if (nIndex < 0) return; @@ -1366,10 +1362,8 @@ void CFWL_Edit::OnMouseMove(CFWL_MessageMouse* pMsg) { if (!pPage) return; - CFX_PointF pt(pMsg->m_fx, pMsg->m_fy); - DeviceToEngine(pt); bool bBefore = true; - int32_t nIndex = pPage->GetCharIndex(pt, bBefore); + int32_t nIndex = pPage->GetCharIndex(DeviceToEngine(pMsg->m_pos), bBefore); m_EdtEngine.SetCaretPos(nIndex, bBefore); nIndex = m_EdtEngine.GetCaretPos(); m_EdtEngine.ClearSelection(); diff --git a/xfa/fwl/cfwl_edit.h b/xfa/fwl/cfwl_edit.h index 4193e735f9..154e286331 100644 --- a/xfa/fwl/cfwl_edit.h +++ b/xfa/fwl/cfwl_edit.h @@ -59,7 +59,7 @@ class CFWL_Edit : public CFWL_Widget { CFX_RectF GetAutosizedWidgetRect() override; CFX_RectF GetWidgetRect() override; void Update() override; - FWL_WidgetHit HitTest(FX_FLOAT fx, FX_FLOAT fy) override; + FWL_WidgetHit HitTest(const CFX_PointF& point) override; void SetStates(uint32_t dwStates) override; void DrawWidget(CFX_Graphics* pGraphics, const CFX_Matrix* pMatrix) override; void SetThemeProvider(IFWL_ThemeProvider* pThemeProvider) override; @@ -127,7 +127,7 @@ class CFWL_Edit : public CFWL_Widget { CFWL_ScrollBar* UpdateScroll(); void Layout(); void LayoutScrollBar(); - void DeviceToEngine(CFX_PointF& pt); + CFX_PointF DeviceToEngine(const CFX_PointF& pt); void InitVerticalScrollBar(); void InitHorizontalScrollBar(); void InitEngine(); diff --git a/xfa/fwl/cfwl_form.cpp b/xfa/fwl/cfwl_form.cpp index 54a77dc65f..5e956ade2d 100644 --- a/xfa/fwl/cfwl_form.cpp +++ b/xfa/fwl/cfwl_form.cpp @@ -67,12 +67,12 @@ void CFWL_Form::Update() { Layout(); } -FWL_WidgetHit CFWL_Form::HitTest(FX_FLOAT fx, FX_FLOAT fy) { +FWL_WidgetHit CFWL_Form::HitTest(const CFX_PointF& point) { GetAvailableTheme(); CFX_RectF rtCap(m_fCYBorder, m_fCXBorder, -2 * m_fCYBorder, 0 - m_fCXBorder); - return rtCap.Contains(fx, fy) ? FWL_WidgetHit::Titlebar - : FWL_WidgetHit::Client; + return rtCap.Contains(point) ? FWL_WidgetHit::Titlebar + : FWL_WidgetHit::Client; } void CFWL_Form::DrawWidget(CFX_Graphics* pGraphics, const CFX_Matrix* pMatrix) { diff --git a/xfa/fwl/cfwl_form.h b/xfa/fwl/cfwl_form.h index 4297fde86e..7202cb279b 100644 --- a/xfa/fwl/cfwl_form.h +++ b/xfa/fwl/cfwl_form.h @@ -37,7 +37,7 @@ class CFWL_Form : public CFWL_Widget { bool IsInstance(const CFX_WideStringC& wsClass) const override; CFX_RectF GetClientRect() override; void Update() override; - FWL_WidgetHit HitTest(FX_FLOAT fx, FX_FLOAT fy) override; + FWL_WidgetHit HitTest(const CFX_PointF& point) override; void DrawWidget(CFX_Graphics* pGraphics, const CFX_Matrix* pMatrix) override; void OnProcessMessage(CFWL_Message* pMessage) override; void OnDrawWidget(CFX_Graphics* pGraphics, diff --git a/xfa/fwl/cfwl_listbox.cpp b/xfa/fwl/cfwl_listbox.cpp index aed2a9a733..0b82709972 100644 --- a/xfa/fwl/cfwl_listbox.cpp +++ b/xfa/fwl/cfwl_listbox.cpp @@ -75,18 +75,18 @@ void CFWL_ListBox::Update() { CalcSize(false); } -FWL_WidgetHit CFWL_ListBox::HitTest(FX_FLOAT fx, FX_FLOAT fy) { +FWL_WidgetHit CFWL_ListBox::HitTest(const CFX_PointF& point) { if (IsShowScrollBar(false)) { CFX_RectF rect = m_pHorzScrollBar->GetWidgetRect(); - if (rect.Contains(fx, fy)) + if (rect.Contains(point)) return FWL_WidgetHit::HScrollBar; } if (IsShowScrollBar(true)) { CFX_RectF rect = m_pVertScrollBar->GetWidgetRect(); - if (rect.Contains(fx, fy)) + if (rect.Contains(point)) return FWL_WidgetHit::VScrollBar; } - if (m_rtClient.Contains(fx, fy)) + if (m_rtClient.Contains(point)) return FWL_WidgetHit::Client; return FWL_WidgetHit::Unknown; } @@ -304,8 +304,8 @@ void CFWL_ListBox::SetFocusItem(CFWL_ListItem* pItem) { } } -CFWL_ListItem* CFWL_ListBox::GetItemAtPoint(FX_FLOAT fx, FX_FLOAT fy) { - fx -= m_rtConent.left, fy -= m_rtConent.top; +CFWL_ListItem* CFWL_ListBox::GetItemAtPoint(const CFX_PointF& point) { + CFX_PointF pos = point - m_rtConent.TopLeft(); FX_FLOAT fPosX = 0.0f; if (m_pHorzScrollBar) fPosX = m_pHorzScrollBar->GetPos(); @@ -322,7 +322,7 @@ CFWL_ListItem* CFWL_ListBox::GetItemAtPoint(FX_FLOAT fx, FX_FLOAT fy) { CFX_RectF rtItem = pItem->GetRect(); rtItem.Offset(-fPosX, -fPosY); - if (rtItem.Contains(fx, fy)) + if (rtItem.Contains(pos)) return pItem; } return nullptr; @@ -748,7 +748,7 @@ void CFWL_ListBox::OnLButtonDown(CFWL_MessageMouse* pMsg) { if ((m_pProperties->m_dwStates & FWL_WGTSTATE_Focused) == 0) SetFocus(true); - CFWL_ListItem* pItem = GetItemAtPoint(pMsg->m_fx, pMsg->m_fy); + CFWL_ListItem* pItem = GetItemAtPoint(pMsg->m_pos); if (!pItem) return; diff --git a/xfa/fwl/cfwl_listbox.h b/xfa/fwl/cfwl_listbox.h index 95d8ad9900..caa4f509f8 100644 --- a/xfa/fwl/cfwl_listbox.h +++ b/xfa/fwl/cfwl_listbox.h @@ -41,7 +41,7 @@ class CFWL_ListBox : public CFWL_Widget { // CFWL_Widget FWL_Type GetClassID() const override; void Update() override; - FWL_WidgetHit HitTest(FX_FLOAT fx, FX_FLOAT fy) override; + FWL_WidgetHit HitTest(const CFX_PointF& point) override; void DrawWidget(CFX_Graphics* pGraphics, const CFX_Matrix* pMatrix) override; void SetThemeProvider(IFWL_ThemeProvider* pThemeProvider) override; void OnProcessMessage(CFWL_Message* pMessage) override; @@ -69,7 +69,7 @@ class CFWL_ListBox : public CFWL_Widget { protected: CFWL_ListItem* GetListItem(CFWL_ListItem* hItem, uint32_t dwKeyCode); void SetSelection(CFWL_ListItem* hStart, CFWL_ListItem* hEnd, bool bSelected); - CFWL_ListItem* GetItemAtPoint(FX_FLOAT fx, FX_FLOAT fy); + CFWL_ListItem* GetItemAtPoint(const CFX_PointF& point); bool ScrollToVisible(CFWL_ListItem* hItem); void InitVerticalScrollBar(); void InitHorizontalScrollBar(); diff --git a/xfa/fwl/cfwl_messagemouse.cpp b/xfa/fwl/cfwl_messagemouse.cpp index 110292a1de..1d56b0f17b 100644 --- a/xfa/fwl/cfwl_messagemouse.cpp +++ b/xfa/fwl/cfwl_messagemouse.cpp @@ -14,6 +14,8 @@ CFWL_MessageMouse::CFWL_MessageMouse(CFWL_Widget* pSrcTarget, CFWL_Widget* pDstTarget) : CFWL_Message(CFWL_Message::Type::Mouse, pSrcTarget, pDstTarget) {} +CFWL_MessageMouse::CFWL_MessageMouse(const CFWL_MessageMouse& other) = default; + CFWL_MessageMouse::~CFWL_MessageMouse() {} std::unique_ptr<CFWL_Message> CFWL_MessageMouse::Clone() { diff --git a/xfa/fwl/cfwl_messagemouse.h b/xfa/fwl/cfwl_messagemouse.h index ac45745df1..a2b0d39ae0 100644 --- a/xfa/fwl/cfwl_messagemouse.h +++ b/xfa/fwl/cfwl_messagemouse.h @@ -9,6 +9,7 @@ #include <memory> +#include "core/fxcrt/fx_coordinates.h" #include "xfa/fwl/cfwl_message.h" enum class FWL_MouseCommand { @@ -27,13 +28,13 @@ enum class FWL_MouseCommand { class CFWL_MessageMouse : public CFWL_Message { public: CFWL_MessageMouse(CFWL_Widget* pSrcTarget, CFWL_Widget* pDstTarget); + CFWL_MessageMouse(const CFWL_MessageMouse& other); ~CFWL_MessageMouse() override; // CFWL_Message std::unique_ptr<CFWL_Message> Clone() override; - FX_FLOAT m_fx; - FX_FLOAT m_fy; + CFX_PointF m_pos; uint32_t m_dwFlags; FWL_MouseCommand m_dwCmd; }; diff --git a/xfa/fwl/cfwl_messagemousewheel.cpp b/xfa/fwl/cfwl_messagemousewheel.cpp index 3646b6c30d..8996f650bf 100644 --- a/xfa/fwl/cfwl_messagemousewheel.cpp +++ b/xfa/fwl/cfwl_messagemousewheel.cpp @@ -14,6 +14,9 @@ CFWL_MessageMouseWheel::CFWL_MessageMouseWheel(CFWL_Widget* pSrcTarget, CFWL_Widget* pDstTarget) : CFWL_Message(CFWL_Message::Type::MouseWheel, pSrcTarget, pDstTarget) {} +CFWL_MessageMouseWheel::CFWL_MessageMouseWheel(const CFWL_MessageMouseWheel&) = + default; + CFWL_MessageMouseWheel::~CFWL_MessageMouseWheel() {} std::unique_ptr<CFWL_Message> CFWL_MessageMouseWheel::Clone() { diff --git a/xfa/fwl/cfwl_messagemousewheel.h b/xfa/fwl/cfwl_messagemousewheel.h index 4d568c8e45..f969b9a8f3 100644 --- a/xfa/fwl/cfwl_messagemousewheel.h +++ b/xfa/fwl/cfwl_messagemousewheel.h @@ -9,20 +9,20 @@ #include <memory> +#include "core/fxcrt/fx_coordinates.h" #include "xfa/fwl/cfwl_message.h" class CFWL_MessageMouseWheel : public CFWL_Message { public: CFWL_MessageMouseWheel(CFWL_Widget* pSrcTarget, CFWL_Widget* pDstTarget); + CFWL_MessageMouseWheel(const CFWL_MessageMouseWheel&); ~CFWL_MessageMouseWheel() override; // CFWL_Message std::unique_ptr<CFWL_Message> Clone() override; - FX_FLOAT m_fx; - FX_FLOAT m_fy; - FX_FLOAT m_fDeltaX; - FX_FLOAT m_fDeltaY; + CFX_PointF m_pos; + CFX_PointF m_delta; uint32_t m_dwFlags; }; diff --git a/xfa/fwl/cfwl_monthcalendar.cpp b/xfa/fwl/cfwl_monthcalendar.cpp index 32336913bf..6882d709bf 100644 --- a/xfa/fwl/cfwl_monthcalendar.cpp +++ b/xfa/fwl/cfwl_monthcalendar.cpp @@ -691,10 +691,10 @@ CFX_WideString CFWL_MonthCalendar::GetTodayText(int32_t iYear, return wsToday; } -int32_t CFWL_MonthCalendar::GetDayAtPoint(FX_FLOAT x, FX_FLOAT y) { +int32_t CFWL_MonthCalendar::GetDayAtPoint(const CFX_PointF& point) const { int i = 1; // one-based day values. for (const auto& pDateInfo : m_arrDates) { - if (pDateInfo->rect.Contains(x, y)) + if (pDateInfo->rect.Contains(point)) return i; ++i; } @@ -752,15 +752,15 @@ void CFWL_MonthCalendar::OnDrawWidget(CFX_Graphics* pGraphics, } void CFWL_MonthCalendar::OnLButtonDown(CFWL_MessageMouse* pMsg) { - if (m_rtLBtn.Contains(pMsg->m_fx, pMsg->m_fy)) { + if (m_rtLBtn.Contains(pMsg->m_pos)) { m_iLBtnPartStates = CFWL_PartState_Pressed; PrevMonth(); RepaintRect(m_rtClient); - } else if (m_rtRBtn.Contains(pMsg->m_fx, pMsg->m_fy)) { + } else if (m_rtRBtn.Contains(pMsg->m_pos)) { m_iRBtnPartStates |= CFWL_PartState_Pressed; NextMonth(); RepaintRect(m_rtClient); - } else if (m_rtToday.Contains(pMsg->m_fx, pMsg->m_fy)) { + } else if (m_rtToday.Contains(pMsg->m_pos)) { JumpToToday(); RepaintRect(m_rtClient); } else { @@ -774,24 +774,24 @@ void CFWL_MonthCalendar::OnLButtonUp(CFWL_MessageMouse* pMsg) { if (m_pWidgetMgr->IsFormDisabled()) return DisForm_OnLButtonUp(pMsg); - if (m_rtLBtn.Contains(pMsg->m_fx, pMsg->m_fy)) { + if (m_rtLBtn.Contains(pMsg->m_pos)) { m_iLBtnPartStates = 0; RepaintRect(m_rtLBtn); return; } - if (m_rtRBtn.Contains(pMsg->m_fx, pMsg->m_fy)) { + if (m_rtRBtn.Contains(pMsg->m_pos)) { m_iRBtnPartStates = 0; RepaintRect(m_rtRBtn); return; } - if (m_rtToday.Contains(pMsg->m_fx, pMsg->m_fy)) + if (m_rtToday.Contains(pMsg->m_pos)) return; int32_t iOldSel = 0; if (!m_arrSelDays.empty()) iOldSel = m_arrSelDays[0]; - int32_t iCurSel = GetDayAtPoint(pMsg->m_fx, pMsg->m_fy); + int32_t iCurSel = GetDayAtPoint(pMsg->m_pos); CFWL_DateTimePicker* pIPicker = static_cast<CFWL_DateTimePicker*>(m_pOuter); if (iCurSel > 0) { DATEINFO* lpDatesInfo = m_arrDates[iCurSel - 1].get(); @@ -808,31 +808,31 @@ void CFWL_MonthCalendar::OnLButtonUp(CFWL_MessageMouse* pMsg) { pIPicker->ShowMonthCalendar(false); } else if (m_bFlag && (!CFX_RectF(0, 0, pIPicker->GetFormProxy()->GetWidgetRect().Size()) - .Contains(pMsg->m_fx, pMsg->m_fy))) { + .Contains(pMsg->m_pos))) { pIPicker->ShowMonthCalendar(false); } m_bFlag = false; } void CFWL_MonthCalendar::DisForm_OnLButtonUp(CFWL_MessageMouse* pMsg) { - if (m_rtLBtn.Contains(pMsg->m_fx, pMsg->m_fy)) { + if (m_rtLBtn.Contains(pMsg->m_pos)) { m_iLBtnPartStates = 0; RepaintRect(m_rtLBtn); return; } - if (m_rtRBtn.Contains(pMsg->m_fx, pMsg->m_fy)) { + if (m_rtRBtn.Contains(pMsg->m_pos)) { m_iRBtnPartStates = 0; RepaintRect(m_rtRBtn); return; } - if (m_rtToday.Contains(pMsg->m_fx, pMsg->m_fy)) + if (m_rtToday.Contains(pMsg->m_pos)) return; int32_t iOldSel = 0; if (!m_arrSelDays.empty()) iOldSel = m_arrSelDays[0]; - int32_t iCurSel = GetDayAtPoint(pMsg->m_fx, pMsg->m_fy); + int32_t iCurSel = GetDayAtPoint(pMsg->m_pos); if (iCurSel > 0) { DATEINFO* lpDatesInfo = m_arrDates[iCurSel - 1].get(); CFX_RectF rtInvalidate(lpDatesInfo->rect); @@ -851,8 +851,8 @@ void CFWL_MonthCalendar::DisForm_OnLButtonUp(CFWL_MessageMouse* pMsg) { void CFWL_MonthCalendar::OnMouseMove(CFWL_MessageMouse* pMsg) { bool bRepaint = false; CFX_RectF rtInvalidate; - if (m_rtDates.Contains(pMsg->m_fx, pMsg->m_fy)) { - int32_t iHover = GetDayAtPoint(pMsg->m_fx, pMsg->m_fy); + if (m_rtDates.Contains(pMsg->m_pos)) { + int32_t iHover = GetDayAtPoint(pMsg->m_pos); bRepaint = m_iHovered != iHover; if (bRepaint) { if (m_iHovered > 0) diff --git a/xfa/fwl/cfwl_monthcalendar.h b/xfa/fwl/cfwl_monthcalendar.h index 245663cf5e..a110ee8297 100644 --- a/xfa/fwl/cfwl_monthcalendar.h +++ b/xfa/fwl/cfwl_monthcalendar.h @@ -143,7 +143,7 @@ class CFWL_MonthCalendar : public CFWL_Widget { void JumpToToday(); CFX_WideString GetHeadText(int32_t iYear, int32_t iMonth); CFX_WideString GetTodayText(int32_t iYear, int32_t iMonth, int32_t iDay); - int32_t GetDayAtPoint(FX_FLOAT x, FX_FLOAT y); + int32_t GetDayAtPoint(const CFX_PointF& point) const; CFX_RectF GetDayRect(int32_t iDay); void OnLButtonDown(CFWL_MessageMouse* pMsg); void OnLButtonUp(CFWL_MessageMouse* pMsg); diff --git a/xfa/fwl/cfwl_notedriver.cpp b/xfa/fwl/cfwl_notedriver.cpp index 6904759e59..8feb0fb4e5 100644 --- a/xfa/fwl/cfwl_notedriver.cpp +++ b/xfa/fwl/cfwl_notedriver.cpp @@ -341,12 +341,8 @@ bool CFWL_NoteDriver::DoMouse(CFWL_Message* pMessage, pMsg->m_dwCmd == FWL_MouseCommand::Enter) { return !!pMsg->m_pDstTarget; } - 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 (pMsg->m_pDstTarget != pMessageForm) + pMsg->m_pos = pMsg->m_pDstTarget->TransformTo(pMessageForm, pMsg->m_pos); if (!DoMouseEx(pMsg, pMessageForm)) pMsg->m_pDstTarget = pMessageForm; return true; @@ -359,15 +355,11 @@ bool CFWL_NoteDriver::DoWheel(CFWL_Message* pMessage, return false; CFWL_MessageMouseWheel* pMsg = static_cast<CFWL_MessageMouseWheel*>(pMessage); - CFWL_Widget* pDst = - pWidgetMgr->GetWidgetAtPoint(pMessageForm, pMsg->m_fx, pMsg->m_fy); + CFWL_Widget* pDst = pWidgetMgr->GetWidgetAtPoint(pMessageForm, pMsg->m_pos); if (!pDst) return false; - 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_pos = pMessageForm->TransformTo(pDst, pMsg->m_pos); pMsg->m_pDstTarget = pDst; return true; } @@ -382,20 +374,12 @@ bool CFWL_NoteDriver::DoMouseEx(CFWL_Message* pMessage, pTarget = m_pGrab; CFWL_MessageMouse* pMsg = static_cast<CFWL_MessageMouse*>(pMessage); - if (!pTarget) { - pTarget = - pWidgetMgr->GetWidgetAtPoint(pMessageForm, pMsg->m_fx, pMsg->m_fy); - } - if (pTarget) { - 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) + pTarget = pWidgetMgr->GetWidgetAtPoint(pMessageForm, pMsg->m_pos); if (!pTarget) return false; + if (pTarget && pMessageForm != pTarget) + pMsg->m_pos = pMessageForm->TransformTo(pTarget, pMsg->m_pos); pMsg->m_pDstTarget = pTarget; return true; @@ -409,10 +393,7 @@ void CFWL_NoteDriver::MouseSecondary(CFWL_Message* pMessage) { CFWL_MessageMouse* pMsg = static_cast<CFWL_MessageMouse*>(pMessage); if (m_pHover) { CFWL_MessageMouse msLeave(nullptr, m_pHover); - 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_pos = pTarget->TransformTo(m_pHover, pMsg->m_pos); msLeave.m_dwFlags = 0; msLeave.m_dwCmd = FWL_MouseCommand::Leave; DispatchMessage(&msLeave, nullptr); @@ -424,8 +405,7 @@ void CFWL_NoteDriver::MouseSecondary(CFWL_Message* pMessage) { m_pHover = pTarget; CFWL_MessageMouse msHover(nullptr, pTarget); - msHover.m_fx = pMsg->m_fx; - msHover.m_fy = pMsg->m_fy; + msHover.m_pos = pMsg->m_pos; msHover.m_dwFlags = 0; msHover.m_dwCmd = FWL_MouseCommand::Hover; DispatchMessage(&msHover, nullptr); diff --git a/xfa/fwl/cfwl_pushbutton.cpp b/xfa/fwl/cfwl_pushbutton.cpp index d36d1d8ca7..fe4c3f621a 100644 --- a/xfa/fwl/cfwl_pushbutton.cpp +++ b/xfa/fwl/cfwl_pushbutton.cpp @@ -170,14 +170,14 @@ void CFWL_PushButton::OnLButtonDown(CFWL_MessageMouse* pMsg) { void CFWL_PushButton::OnLButtonUp(CFWL_MessageMouse* pMsg) { m_bBtnDown = false; - if (m_rtClient.Contains(pMsg->m_fx, pMsg->m_fy)) { + if (m_rtClient.Contains(pMsg->m_pos)) { m_pProperties->m_dwStates &= ~FWL_STATE_PSB_Pressed; m_pProperties->m_dwStates |= FWL_STATE_PSB_Hovered; } else { m_pProperties->m_dwStates &= ~FWL_STATE_PSB_Hovered; m_pProperties->m_dwStates &= ~FWL_STATE_PSB_Pressed; } - if (m_rtClient.Contains(pMsg->m_fx, pMsg->m_fy)) { + if (m_rtClient.Contains(pMsg->m_pos)) { CFWL_Event wmClick(CFWL_Event::Type::Click, this); DispatchEvent(&wmClick); } @@ -187,7 +187,7 @@ void CFWL_PushButton::OnLButtonUp(CFWL_MessageMouse* pMsg) { void CFWL_PushButton::OnMouseMove(CFWL_MessageMouse* pMsg) { bool bRepaint = false; if (m_bBtnDown) { - if (m_rtClient.Contains(pMsg->m_fx, pMsg->m_fy)) { + if (m_rtClient.Contains(pMsg->m_pos)) { if ((m_pProperties->m_dwStates & FWL_STATE_PSB_Pressed) == 0) { m_pProperties->m_dwStates |= FWL_STATE_PSB_Pressed; bRepaint = true; @@ -207,7 +207,7 @@ void CFWL_PushButton::OnMouseMove(CFWL_MessageMouse* pMsg) { } } } else { - if (!m_rtClient.Contains(pMsg->m_fx, pMsg->m_fy)) + if (!m_rtClient.Contains(pMsg->m_pos)) return; if ((m_pProperties->m_dwStates & FWL_STATE_PSB_Hovered) == 0) { m_pProperties->m_dwStates |= FWL_STATE_PSB_Hovered; diff --git a/xfa/fwl/cfwl_scrollbar.cpp b/xfa/fwl/cfwl_scrollbar.cpp index b928d4c5b3..1da2674550 100644 --- a/xfa/fwl/cfwl_scrollbar.cpp +++ b/xfa/fwl/cfwl_scrollbar.cpp @@ -45,8 +45,6 @@ CFWL_ScrollBar::CFWL_ScrollBar( m_iMinTrackState(CFWL_PartState_Normal), m_iMaxTrackState(CFWL_PartState_Normal), m_fLastTrackPos(0), - m_cpTrackPointX(0), - m_cpTrackPointY(0), m_iMouseWheel(0), m_bMouseDown(false), m_fButtonLen(0), @@ -276,17 +274,16 @@ CFX_RectF CFWL_ScrollBar::CalcMaxTrackRect(const CFX_RectF& rtMaxRect) { m_rtClient.height); } -FX_FLOAT CFWL_ScrollBar::GetTrackPointPos(FX_FLOAT fx, FX_FLOAT fy) { - FX_FLOAT fDiffX = fx - m_cpTrackPointX; - FX_FLOAT fDiffY = fy - m_cpTrackPointY; +FX_FLOAT CFWL_ScrollBar::GetTrackPointPos(const CFX_PointF& point) { + CFX_PointF diff = point - m_cpTrackPoint; FX_FLOAT fRange = m_fRangeMax - m_fRangeMin; FX_FLOAT fPos; if (IsVertical()) { - fPos = fRange * fDiffY / + fPos = fRange * diff.y / (m_rtMaxBtn.top - m_rtMinBtn.bottom() - m_rtThumb.height); } else { - fPos = fRange * fDiffX / + fPos = fRange * diff.x / (m_rtMaxBtn.left - m_rtMinBtn.right() - m_rtThumb.width); } @@ -305,11 +302,11 @@ bool CFWL_ScrollBar::SendEvent() { } if (m_iMinTrackState == CFWL_PartState_Pressed) { DoScroll(CFWL_EventScroll::Code::PageBackward, m_fTrackPos); - return m_rtThumb.Contains(m_cpTrackPointX, m_cpTrackPointY); + return m_rtThumb.Contains(m_cpTrackPoint); } if (m_iMaxTrackState == CFWL_PartState_Pressed) { DoScroll(CFWL_EventScroll::Code::PageForward, m_fTrackPos); - return m_rtThumb.Contains(m_cpTrackPointX, m_cpTrackPointY); + return m_rtThumb.Contains(m_cpTrackPoint); } if (m_iMouseWheel) { CFWL_EventScroll::Code dwCode = m_iMouseWheel < 0 @@ -337,13 +334,13 @@ void CFWL_ScrollBar::OnProcessMessage(CFWL_Message* pMessage) { CFWL_MessageMouse* pMsg = static_cast<CFWL_MessageMouse*>(pMessage); switch (pMsg->m_dwCmd) { case FWL_MouseCommand::LeftButtonDown: - OnLButtonDown(pMsg->m_dwFlags, pMsg->m_fx, pMsg->m_fy); + OnLButtonDown(pMsg->m_pos); break; case FWL_MouseCommand::LeftButtonUp: - OnLButtonUp(pMsg->m_dwFlags, pMsg->m_fx, pMsg->m_fy); + OnLButtonUp(pMsg->m_pos); break; case FWL_MouseCommand::Move: - OnMouseMove(pMsg->m_dwFlags, pMsg->m_fx, pMsg->m_fy); + OnMouseMove(pMsg->m_pos); break; case FWL_MouseCommand::Leave: OnMouseLeave(); @@ -354,8 +351,7 @@ void CFWL_ScrollBar::OnProcessMessage(CFWL_Message* pMessage) { } else if (type == CFWL_Message::Type::MouseWheel) { CFWL_MessageMouseWheel* pMsg = static_cast<CFWL_MessageMouseWheel*>(pMessage); - OnMouseWheel(pMsg->m_fx, pMsg->m_fy, pMsg->m_dwFlags, pMsg->m_fDeltaX, - pMsg->m_fDeltaY); + OnMouseWheel(pMsg->m_delta); } } @@ -364,47 +360,47 @@ void CFWL_ScrollBar::OnDrawWidget(CFX_Graphics* pGraphics, DrawWidget(pGraphics, pMatrix); } -void CFWL_ScrollBar::OnLButtonDown(uint32_t dwFlags, FX_FLOAT fx, FX_FLOAT fy) { +void CFWL_ScrollBar::OnLButtonDown(const CFX_PointF& point) { if (!IsEnabled()) return; m_bMouseDown = true; SetGrab(true); - m_cpTrackPointX = fx; - m_cpTrackPointY = fy; + + m_cpTrackPoint = point; m_fLastTrackPos = m_fTrackPos; - if (m_rtMinBtn.Contains(fx, fy)) - DoMouseDown(0, m_rtMinBtn, m_iMinButtonState, fx, fy); - else if (m_rtThumb.Contains(fx, fy)) - DoMouseDown(1, m_rtThumb, m_iThumbButtonState, fx, fy); - else if (m_rtMaxBtn.Contains(fx, fy)) - DoMouseDown(2, m_rtMaxBtn, m_iMaxButtonState, fx, fy); - else if (m_rtMinTrack.Contains(fx, fy)) - DoMouseDown(3, m_rtMinTrack, m_iMinTrackState, fx, fy); + if (m_rtMinBtn.Contains(point)) + DoMouseDown(0, m_rtMinBtn, m_iMinButtonState, point); + else if (m_rtThumb.Contains(point)) + DoMouseDown(1, m_rtThumb, m_iThumbButtonState, point); + else if (m_rtMaxBtn.Contains(point)) + DoMouseDown(2, m_rtMaxBtn, m_iMaxButtonState, point); + else if (m_rtMinTrack.Contains(point)) + DoMouseDown(3, m_rtMinTrack, m_iMinTrackState, point); else - DoMouseDown(4, m_rtMaxTrack, m_iMaxTrackState, fx, fy); + DoMouseDown(4, m_rtMaxTrack, m_iMaxTrackState, point); if (!SendEvent()) m_pTimerInfo = m_Timer.StartTimer(FWL_SCROLLBAR_Elapse, true); } -void CFWL_ScrollBar::OnLButtonUp(uint32_t dwFlags, FX_FLOAT fx, FX_FLOAT fy) { +void CFWL_ScrollBar::OnLButtonUp(const CFX_PointF& point) { m_pTimerInfo->StopTimer(); m_bMouseDown = false; - DoMouseUp(0, m_rtMinBtn, m_iMinButtonState, fx, fy); - DoMouseUp(1, m_rtThumb, m_iThumbButtonState, fx, fy); - DoMouseUp(2, m_rtMaxBtn, m_iMaxButtonState, fx, fy); - DoMouseUp(3, m_rtMinTrack, m_iMinTrackState, fx, fy); - DoMouseUp(4, m_rtMaxTrack, m_iMaxTrackState, fx, fy); + DoMouseUp(0, m_rtMinBtn, m_iMinButtonState, point); + DoMouseUp(1, m_rtThumb, m_iThumbButtonState, point); + DoMouseUp(2, m_rtMaxBtn, m_iMaxButtonState, point); + DoMouseUp(3, m_rtMinTrack, m_iMinTrackState, point); + DoMouseUp(4, m_rtMaxTrack, m_iMaxTrackState, point); SetGrab(false); } -void CFWL_ScrollBar::OnMouseMove(uint32_t dwFlags, FX_FLOAT fx, FX_FLOAT fy) { - DoMouseMove(0, m_rtMinBtn, m_iMinButtonState, fx, fy); - DoMouseMove(1, m_rtThumb, m_iThumbButtonState, fx, fy); - DoMouseMove(2, m_rtMaxBtn, m_iMaxButtonState, fx, fy); - DoMouseMove(3, m_rtMinTrack, m_iMinTrackState, fx, fy); - DoMouseMove(4, m_rtMaxTrack, m_iMaxTrackState, fx, fy); +void CFWL_ScrollBar::OnMouseMove(const CFX_PointF& point) { + DoMouseMove(0, m_rtMinBtn, m_iMinButtonState, point); + DoMouseMove(1, m_rtThumb, m_iThumbButtonState, point); + DoMouseMove(2, m_rtMaxBtn, m_iMaxButtonState, point); + DoMouseMove(3, m_rtMinTrack, m_iMinTrackState, point); + DoMouseMove(4, m_rtMaxTrack, m_iMaxTrackState, point); } void CFWL_ScrollBar::OnMouseLeave() { @@ -415,12 +411,8 @@ void CFWL_ScrollBar::OnMouseLeave() { DoMouseLeave(4, m_rtMaxTrack, m_iMaxTrackState); } -void CFWL_ScrollBar::OnMouseWheel(FX_FLOAT fx, - FX_FLOAT fy, - uint32_t dwFlags, - FX_FLOAT fDeltaX, - FX_FLOAT fDeltaY) { - m_iMouseWheel = (int32_t)fDeltaX; +void CFWL_ScrollBar::OnMouseWheel(const CFX_PointF& delta) { + m_iMouseWheel = static_cast<int32_t>(delta.x); SendEvent(); m_iMouseWheel = 0; } @@ -428,9 +420,8 @@ void CFWL_ScrollBar::OnMouseWheel(FX_FLOAT fx, void CFWL_ScrollBar::DoMouseDown(int32_t iItem, const CFX_RectF& rtItem, int32_t& iState, - FX_FLOAT fx, - FX_FLOAT fy) { - if (!rtItem.Contains(fx, fy)) + const CFX_PointF& point) { + if (!rtItem.Contains(point)) return; if (iState == CFWL_PartState_Pressed) return; @@ -442,10 +433,9 @@ void CFWL_ScrollBar::DoMouseDown(int32_t iItem, void CFWL_ScrollBar::DoMouseUp(int32_t iItem, const CFX_RectF& rtItem, int32_t& iState, - FX_FLOAT fx, - FX_FLOAT fy) { + const CFX_PointF& point) { int32_t iNewState = - rtItem.Contains(fx, fy) ? CFWL_PartState_Hovered : CFWL_PartState_Normal; + rtItem.Contains(point) ? CFWL_PartState_Hovered : CFWL_PartState_Normal; if (iState == iNewState) return; @@ -457,20 +447,18 @@ void CFWL_ScrollBar::DoMouseUp(int32_t iItem, void CFWL_ScrollBar::DoMouseMove(int32_t iItem, const CFX_RectF& rtItem, int32_t& iState, - FX_FLOAT fx, - FX_FLOAT fy) { + const CFX_PointF& point) { if (!m_bMouseDown) { - int32_t iNewState = rtItem.Contains(fx, fy) ? CFWL_PartState_Hovered - : CFWL_PartState_Normal; + int32_t iNewState = + rtItem.Contains(point) ? CFWL_PartState_Hovered : CFWL_PartState_Normal; if (iState == iNewState) return; iState = iNewState; RepaintRect(rtItem); } else if ((2 == iItem) && (m_iThumbButtonState == CFWL_PartState_Pressed)) { - FX_FLOAT fPos = GetTrackPointPos(fx, fy); - m_fTrackPos = fPos; - OnScroll(CFWL_EventScroll::Code::TrackPos, fPos); + m_fTrackPos = GetTrackPointPos(point); + OnScroll(CFWL_EventScroll::Code::TrackPos, m_fTrackPos); } } diff --git a/xfa/fwl/cfwl_scrollbar.h b/xfa/fwl/cfwl_scrollbar.h index 62ce523646..6a67fa8687 100644 --- a/xfa/fwl/cfwl_scrollbar.h +++ b/xfa/fwl/cfwl_scrollbar.h @@ -84,35 +84,28 @@ class CFWL_ScrollBar : public CFWL_Widget { CFX_RectF CalcThumbButtonRect(const CFX_RectF& rtThumbRect); CFX_RectF CalcMinTrackRect(const CFX_RectF& rtMinRect); CFX_RectF CalcMaxTrackRect(const CFX_RectF& rtMaxRect); - FX_FLOAT GetTrackPointPos(FX_FLOAT fx, FX_FLOAT fy); + FX_FLOAT GetTrackPointPos(const CFX_PointF& point); bool SendEvent(); bool OnScroll(CFWL_EventScroll::Code dwCode, FX_FLOAT fPos); - void OnLButtonDown(uint32_t dwFlags, FX_FLOAT fx, FX_FLOAT fy); - void OnLButtonUp(uint32_t dwFlags, FX_FLOAT fx, FX_FLOAT fy); - void OnMouseMove(uint32_t dwFlags, FX_FLOAT fx, FX_FLOAT fy); + void OnLButtonDown(const CFX_PointF& point); + void OnLButtonUp(const CFX_PointF& point); + void OnMouseMove(const CFX_PointF& point); void OnMouseLeave(); - void OnMouseWheel(FX_FLOAT fx, - FX_FLOAT fy, - uint32_t dwFlags, - FX_FLOAT fDeltaX, - FX_FLOAT fDeltaY); + void OnMouseWheel(const CFX_PointF& delta); bool DoScroll(CFWL_EventScroll::Code dwCode, FX_FLOAT fPos); void DoMouseDown(int32_t iItem, const CFX_RectF& rtItem, int32_t& iState, - FX_FLOAT fx, - FX_FLOAT fy); + const CFX_PointF& point); void DoMouseUp(int32_t iItem, const CFX_RectF& rtItem, int32_t& iState, - FX_FLOAT fx, - FX_FLOAT fy); + const CFX_PointF& point); void DoMouseMove(int32_t iItem, const CFX_RectF& rtItem, int32_t& iState, - FX_FLOAT fx, - FX_FLOAT fy); + const CFX_PointF& point); void DoMouseLeave(int32_t iItem, const CFX_RectF& rtItem, int32_t& iState); void DoMouseHover(int32_t iItem, const CFX_RectF& rtItem, int32_t& iState); @@ -129,8 +122,7 @@ class CFWL_ScrollBar : public CFWL_Widget { int32_t m_iMinTrackState; int32_t m_iMaxTrackState; FX_FLOAT m_fLastTrackPos; - FX_FLOAT m_cpTrackPointX; - FX_FLOAT m_cpTrackPointY; + CFX_PointF m_cpTrackPoint; int32_t m_iMouseWheel; bool m_bMouseDown; FX_FLOAT m_fButtonLen; diff --git a/xfa/fwl/cfwl_spinbutton.cpp b/xfa/fwl/cfwl_spinbutton.cpp index 140cdd50be..6e58b69baf 100644 --- a/xfa/fwl/cfwl_spinbutton.cpp +++ b/xfa/fwl/cfwl_spinbutton.cpp @@ -66,14 +66,14 @@ void CFWL_SpinButton::Update() { } } -FWL_WidgetHit CFWL_SpinButton::HitTest(FX_FLOAT fx, FX_FLOAT fy) { - if (m_rtClient.Contains(fx, fy)) +FWL_WidgetHit CFWL_SpinButton::HitTest(const CFX_PointF& point) { + if (m_rtClient.Contains(point)) return FWL_WidgetHit::Client; - if (HasBorder() && (m_rtClient.Contains(fx, fy))) + if (HasBorder() && (m_rtClient.Contains(point))) return FWL_WidgetHit::Border; - if (m_rtUpButton.Contains(fx, fy)) + if (m_rtUpButton.Contains(point)) return FWL_WidgetHit::UpButton; - if (m_rtDnButton.Contains(fx, fy)) + if (m_rtDnButton.Contains(point)) return FWL_WidgetHit::DownButton; return FWL_WidgetHit::Unknown; } @@ -201,10 +201,8 @@ void CFWL_SpinButton::OnLButtonDown(CFWL_MessageMouse* pMsg) { SetGrab(true); SetFocus(true); - bool bUpPress = - (m_rtUpButton.Contains(pMsg->m_fx, pMsg->m_fy) && IsUpButtonEnabled()); - bool bDnPress = - (m_rtDnButton.Contains(pMsg->m_fx, pMsg->m_fy) && IsDownButtonEnabled()); + bool bUpPress = m_rtUpButton.Contains(pMsg->m_pos) && IsUpButtonEnabled(); + bool bDnPress = m_rtDnButton.Contains(pMsg->m_pos) && IsDownButtonEnabled(); if (!bUpPress && !bDnPress) return; if (bUpPress) { @@ -255,7 +253,7 @@ void CFWL_SpinButton::OnMouseMove(CFWL_MessageMouse* pMsg) { bool bRepaint = false; CFX_RectF rtInvlidate; - if (m_rtUpButton.Contains(pMsg->m_fx, pMsg->m_fy)) { + if (m_rtUpButton.Contains(pMsg->m_pos)) { if (IsUpButtonEnabled()) { if (m_dwUpState == CFWL_PartState_Hovered) { m_dwUpState = CFWL_PartState_Hovered; @@ -275,7 +273,7 @@ void CFWL_SpinButton::OnMouseMove(CFWL_MessageMouse* pMsg) { if (!IsDownButtonEnabled()) DisableButton(); - } else if (m_rtDnButton.Contains(pMsg->m_fx, pMsg->m_fy)) { + } else if (m_rtDnButton.Contains(pMsg->m_pos)) { if (IsDownButtonEnabled()) { if (m_dwDnState != CFWL_PartState_Hovered) { m_dwDnState = CFWL_PartState_Hovered; diff --git a/xfa/fwl/cfwl_spinbutton.h b/xfa/fwl/cfwl_spinbutton.h index 4794461fb2..3cda761f91 100644 --- a/xfa/fwl/cfwl_spinbutton.h +++ b/xfa/fwl/cfwl_spinbutton.h @@ -27,7 +27,7 @@ class CFWL_SpinButton : public CFWL_Widget { // CFWL_Widget FWL_Type GetClassID() const override; void Update() override; - FWL_WidgetHit HitTest(FX_FLOAT fx, FX_FLOAT fy) override; + FWL_WidgetHit HitTest(const CFX_PointF& point) override; void DrawWidget(CFX_Graphics* pGraphics, const CFX_Matrix* pMatrix) override; void OnProcessMessage(CFWL_Message* pMessage) override; void OnDrawWidget(CFX_Graphics* pGraphics, diff --git a/xfa/fwl/cfwl_widget.cpp b/xfa/fwl/cfwl_widget.cpp index 3462ea792a..b5b8bf4c7d 100644 --- a/xfa/fwl/cfwl_widget.cpp +++ b/xfa/fwl/cfwl_widget.cpp @@ -151,10 +151,10 @@ void CFWL_Widget::RemoveStates(uint32_t dwStates) { m_pProperties->m_dwStates &= ~dwStates; } -FWL_WidgetHit CFWL_Widget::HitTest(FX_FLOAT fx, FX_FLOAT fy) { - if (GetClientRect().Contains(fx, fy)) +FWL_WidgetHit CFWL_Widget::HitTest(const CFX_PointF& point) { + if (GetClientRect().Contains(point)) return FWL_WidgetHit::Client; - if (HasBorder() && GetRelativeRect().Contains(fx, fy)) + if (HasBorder() && GetRelativeRect().Contains(point)) return FWL_WidgetHit::Border; return FWL_WidgetHit::Unknown; } diff --git a/xfa/fwl/cfwl_widget.h b/xfa/fwl/cfwl_widget.h index a375005970..2387b753e5 100644 --- a/xfa/fwl/cfwl_widget.h +++ b/xfa/fwl/cfwl_widget.h @@ -60,7 +60,7 @@ class CFWL_Widget : public IFWL_WidgetDelegate { virtual void SetStates(uint32_t dwStates); virtual void RemoveStates(uint32_t dwStates); virtual void Update() = 0; - virtual FWL_WidgetHit HitTest(FX_FLOAT fx, FX_FLOAT fy); + virtual FWL_WidgetHit HitTest(const CFX_PointF& point); virtual void DrawWidget(CFX_Graphics* pGraphics, const CFX_Matrix* pMatrix) = 0; virtual void SetThemeProvider(IFWL_ThemeProvider* pThemeProvider); @@ -173,7 +173,6 @@ class CFWL_Widget : public IFWL_WidgetDelegate { FX_FLOAT fMaxHeight, const CFX_RectF& rtAnchor, CFX_RectF& rtPopup); - bool GetScreenSize(FX_FLOAT& fx, FX_FLOAT& fy); void DrawBackground(CFX_Graphics* pGraphics, CFWL_Part iPartBk, IFWL_ThemeProvider* pTheme, diff --git a/xfa/fwl/cfwl_widgetmgr.cpp b/xfa/fwl/cfwl_widgetmgr.cpp index ea4cbde230..7c0fddd419 100644 --- a/xfa/fwl/cfwl_widgetmgr.cpp +++ b/xfa/fwl/cfwl_widgetmgr.cpp @@ -258,8 +258,7 @@ void CFWL_WidgetMgr::SetParent(CFWL_Widget* pParent, CFWL_Widget* pChild) { } CFWL_Widget* CFWL_WidgetMgr::GetWidgetAtPoint(CFWL_Widget* parent, - FX_FLOAT x, - FX_FLOAT y) { + const CFX_PointF& point) const { if (!parent) return nullptr; @@ -272,12 +271,12 @@ CFWL_Widget* CFWL_WidgetMgr::GetWidgetAtPoint(CFWL_Widget* parent, CFX_Matrix matrixOnParent; m.SetReverse(matrixOnParent); - pos = m.Transform(CFX_PointF(x, y)); + pos = m.Transform(point); CFX_RectF bounds = child->GetWidgetRect(); - if (bounds.Contains(pos.x, pos.y)) { + if (bounds.Contains(pos)) { pos -= bounds.TopLeft(); - return GetWidgetAtPoint(child, pos.x, pos.y); + return GetWidgetAtPoint(child, pos); } } child = GetPriorSiblingWidget(child); @@ -531,8 +530,7 @@ bool CFWL_WidgetMgr::IsNeedRepaint(CFWL_Widget* pWidget, CFX_RectF rtChilds; bool bChildIntersectWithDirty = false; bool bOrginPtIntersectWidthChild = false; - bool bOrginPtIntersectWidthDirty = - rtDirty.Contains(rtWidget.left, rtWidget.top); + bool bOrginPtIntersectWidthDirty = rtDirty.Contains(rtWidget.TopLeft()); static FWL_NEEDREPAINTHITDATA hitPoint[kNeedRepaintHitPoints]; FXSYS_memset(hitPoint, 0, sizeof(hitPoint)); FX_FLOAT fxPiece = rtWidget.width / kNeedRepaintHitPiece; @@ -562,7 +560,7 @@ bool CFWL_WidgetMgr::IsNeedRepaint(CFWL_Widget* pWidget, if (!bChildIntersectWithDirty && r.IntersectWith(rtDirty)) bChildIntersectWithDirty = true; if (bOrginPtIntersectWidthDirty && !bOrginPtIntersectWidthChild) - bOrginPtIntersectWidthChild = rect.Contains(0, 0); + bOrginPtIntersectWidthChild = rect.Contains(CFX_PointF(0, 0)); if (rtChilds.IsEmpty()) rtChilds = rect; diff --git a/xfa/fwl/cfwl_widgetmgr.h b/xfa/fwl/cfwl_widgetmgr.h index baa2d1a628..02dbf46473 100644 --- a/xfa/fwl/cfwl_widgetmgr.h +++ b/xfa/fwl/cfwl_widgetmgr.h @@ -50,7 +50,8 @@ class CFWL_WidgetMgr : public CFWL_WidgetMgrDelegate { void SetOwner(CFWL_Widget* pOwner, CFWL_Widget* pOwned); void SetParent(CFWL_Widget* pParent, CFWL_Widget* pChild); - CFWL_Widget* GetWidgetAtPoint(CFWL_Widget* pParent, FX_FLOAT fx, FX_FLOAT fy); + CFWL_Widget* GetWidgetAtPoint(CFWL_Widget* pParent, + const CFX_PointF& point) const; CFWL_Widget* NextTab(CFWL_Widget* parent, CFWL_Widget* focus, bool& bFind); std::vector<CFWL_Widget*> GetSameGroupRadioButton( diff --git a/xfa/fxfa/app/xfa_ffbarcode.cpp b/xfa/fxfa/app/xfa_ffbarcode.cpp index 0207318e95..b136b8da5a 100644 --- a/xfa/fxfa/app/xfa_ffbarcode.cpp +++ b/xfa/fxfa/app/xfa_ffbarcode.cpp @@ -221,20 +221,18 @@ void CXFA_FFBarcode::UpdateWidgetProperty() { } } -bool CXFA_FFBarcode::OnLButtonDown(uint32_t dwFlags, FX_FLOAT fx, FX_FLOAT fy) { +bool CXFA_FFBarcode::OnLButtonDown(uint32_t dwFlags, const CFX_PointF& point) { CFWL_Barcode* pBarCodeWidget = (CFWL_Barcode*)m_pNormalWidget; - if (!pBarCodeWidget || pBarCodeWidget->IsProtectedType()) { + if (!pBarCodeWidget || pBarCodeWidget->IsProtectedType()) return false; - } - if (m_pDataAcc->GetAccess() != XFA_ATTRIBUTEENUM_Open) { + if (m_pDataAcc->GetAccess() != XFA_ATTRIBUTEENUM_Open) return false; - } - return CXFA_FFTextEdit::OnLButtonDown(dwFlags, fx, fy); + return CXFA_FFTextEdit::OnLButtonDown(dwFlags, point); } -bool CXFA_FFBarcode::OnRButtonDown(uint32_t dwFlags, FX_FLOAT fx, FX_FLOAT fy) { + +bool CXFA_FFBarcode::OnRButtonDown(uint32_t dwFlags, const CFX_PointF& point) { CFWL_Barcode* pBarCodeWidget = (CFWL_Barcode*)m_pNormalWidget; - if (!pBarCodeWidget || pBarCodeWidget->IsProtectedType()) { + if (!pBarCodeWidget || pBarCodeWidget->IsProtectedType()) return false; - } - return CXFA_FFTextEdit::OnRButtonDown(dwFlags, fx, fy); + return CXFA_FFTextEdit::OnRButtonDown(dwFlags, point); } diff --git a/xfa/fxfa/app/xfa_ffbarcode.h b/xfa/fxfa/app/xfa_ffbarcode.h index 28d7486bcd..c20feb5167 100644 --- a/xfa/fxfa/app/xfa_ffbarcode.h +++ b/xfa/fxfa/app/xfa_ffbarcode.h @@ -22,8 +22,8 @@ class CXFA_FFBarcode : public CXFA_FFTextEdit { CFX_Matrix* pMatrix, uint32_t dwStatus) override; void UpdateWidgetProperty() override; - bool OnLButtonDown(uint32_t dwFlags, FX_FLOAT fx, FX_FLOAT fy) override; - bool OnRButtonDown(uint32_t dwFlags, FX_FLOAT fx, FX_FLOAT fy) override; + bool OnLButtonDown(uint32_t dwFlags, const CFX_PointF& point) override; + bool OnRButtonDown(uint32_t dwFlags, const CFX_PointF& point) override; }; enum XFA_BARCODETYPEENUM { diff --git a/xfa/fxfa/app/xfa_ffcheckbutton.cpp b/xfa/fxfa/app/xfa_ffcheckbutton.cpp index 8a20c1a879..f088b5d4dd 100644 --- a/xfa/fxfa/app/xfa_ffcheckbutton.cpp +++ b/xfa/fxfa/app/xfa_ffcheckbutton.cpp @@ -232,8 +232,7 @@ void CXFA_FFCheckButton::RenderWidget(CFX_Graphics* pGS, GetApp()->GetWidgetMgrDelegate()->OnDrawWidget(m_pNormalWidget, pGS, &mt); } bool CXFA_FFCheckButton::OnLButtonUp(uint32_t dwFlags, - FX_FLOAT fx, - FX_FLOAT fy) { + const CFX_PointF& point) { if (!m_pNormalWidget || !IsButtonDown()) return false; @@ -241,9 +240,7 @@ bool CXFA_FFCheckButton::OnLButtonUp(uint32_t dwFlags, CFWL_MessageMouse ms(nullptr, m_pNormalWidget); ms.m_dwCmd = FWL_MouseCommand::LeftButtonUp; ms.m_dwFlags = dwFlags; - ms.m_fx = fx; - ms.m_fy = fy; - FWLToClient(ms.m_fx, ms.m_fy); + ms.m_pos = FWLToClient(point); TranslateFWLMessage(&ms); return true; } diff --git a/xfa/fxfa/app/xfa_ffcheckbutton.h b/xfa/fxfa/app/xfa_ffcheckbutton.h index 4cb7d2113c..2c0acd6e3e 100644 --- a/xfa/fxfa/app/xfa_ffcheckbutton.h +++ b/xfa/fxfa/app/xfa_ffcheckbutton.h @@ -24,7 +24,7 @@ class CXFA_FFCheckButton : public CXFA_FFField { bool PerformLayout() override; bool UpdateFWLData() override; void UpdateWidgetProperty() override; - bool OnLButtonUp(uint32_t dwFlags, FX_FLOAT fx, FX_FLOAT fy) override; + bool OnLButtonUp(uint32_t dwFlags, const CFX_PointF& point) override; void OnProcessMessage(CFWL_Message* pMessage) override; void OnProcessEvent(CFWL_Event* pEvent) override; void OnDrawWidget(CFX_Graphics* pGraphics, diff --git a/xfa/fxfa/app/xfa_ffchoicelist.cpp b/xfa/fxfa/app/xfa_ffchoicelist.cpp index efe8b0c8c2..3aabde870a 100644 --- a/xfa/fxfa/app/xfa_ffchoicelist.cpp +++ b/xfa/fxfa/app/xfa_ffchoicelist.cpp @@ -226,12 +226,9 @@ CFX_RectF CXFA_FFComboBox::GetBBox(uint32_t dwStatus, bool bDrawFocus) { return CXFA_FFWidget::GetBBox(dwStatus); } -bool CXFA_FFComboBox::PtInActiveRect(FX_FLOAT fx, FX_FLOAT fy) { - if (!m_pNormalWidget) - return false; - return static_cast<CFWL_ComboBox*>(m_pNormalWidget) - ->GetBBox() - .Contains(fx, fy); +bool CXFA_FFComboBox::PtInActiveRect(const CFX_PointF& point) { + auto pComboBox = static_cast<CFWL_ComboBox*>(m_pNormalWidget); + return pComboBox && pComboBox->GetBBox().Contains(point); } bool CXFA_FFComboBox::LoadWidget() { @@ -292,13 +289,15 @@ void CXFA_FFComboBox::UpdateWidgetProperty() { } pComboBox->EditModifyStylesEx(dwEditStyles, 0xFFFFFFFF); } -bool CXFA_FFComboBox::OnRButtonUp(uint32_t dwFlags, FX_FLOAT fx, FX_FLOAT fy) { - if (!CXFA_FFField::OnRButtonUp(dwFlags, fx, fy)) + +bool CXFA_FFComboBox::OnRButtonUp(uint32_t dwFlags, const CFX_PointF& point) { + if (!CXFA_FFField::OnRButtonUp(dwFlags, point)) return false; - GetDoc()->GetDocEnvironment()->PopupMenu(this, CFX_PointF(fx, fy)); + GetDoc()->GetDocEnvironment()->PopupMenu(this, point); return true; } + bool CXFA_FFComboBox::OnKillFocus(CXFA_FFWidget* pNewWidget) { bool flag = ProcessCommittedData(); if (!flag) { diff --git a/xfa/fxfa/app/xfa_ffchoicelist.h b/xfa/fxfa/app/xfa_ffchoicelist.h index 9eb42e593b..e89366ad13 100644 --- a/xfa/fxfa/app/xfa_ffchoicelist.h +++ b/xfa/fxfa/app/xfa_ffchoicelist.h @@ -48,7 +48,7 @@ class CXFA_FFComboBox : public CXFA_FFField { CFX_RectF GetBBox(uint32_t dwStatus, bool bDrawFocus = false) override; bool LoadWidget() override; void UpdateWidgetProperty() override; - bool OnRButtonUp(uint32_t dwFlags, FX_FLOAT fx, FX_FLOAT fy) override; + bool OnRButtonUp(uint32_t dwFlags, const CFX_PointF& point) override; bool OnKillFocus(CXFA_FFWidget* pNewWidget) override; bool CanUndo() override; bool CanRedo() override; @@ -84,7 +84,7 @@ class CXFA_FFComboBox : public CXFA_FFField { protected: // CXFA_FFField - bool PtInActiveRect(FX_FLOAT fx, FX_FLOAT fy) override; + bool PtInActiveRect(const CFX_PointF& point) override; bool CommitData() override; bool UpdateFWLData() override; bool IsDataChanged() override; diff --git a/xfa/fxfa/app/xfa_fffield.cpp b/xfa/fxfa/app/xfa_fffield.cpp index 932754c09c..0c8d8c1b5f 100644 --- a/xfa/fxfa/app/xfa_fffield.cpp +++ b/xfa/fxfa/app/xfa_fffield.cpp @@ -98,6 +98,7 @@ void CXFA_FFField::DrawFocus(CFX_Graphics* pGS, CFX_Matrix* pMatrix) { FX_FLOAT DashPattern[2] = {1, 1}; pGS->SetLineDash(0.0f, DashPattern, 2); pGS->SetLineWidth(0, false); + CFX_Path path; path.Create(); path.AddRectangle(m_rtUI.left, m_rtUI.top, m_rtUI.width, m_rtUI.height); @@ -350,145 +351,126 @@ bool CXFA_FFField::OnMouseExit() { return true; } -void CXFA_FFField::FWLToClient(FX_FLOAT& fx, FX_FLOAT& fy) { - if (!m_pNormalWidget) - return; - - CFX_RectF rtWidget = m_pNormalWidget->GetWidgetRect(); - fx -= rtWidget.left; - fy -= rtWidget.top; +CFX_PointF CXFA_FFField::FWLToClient(const CFX_PointF& point) { + return m_pNormalWidget ? point - m_pNormalWidget->GetWidgetRect().TopLeft() + : point; } -bool CXFA_FFField::OnLButtonDown(uint32_t dwFlags, FX_FLOAT fx, FX_FLOAT fy) { - if (!m_pNormalWidget) { +bool CXFA_FFField::OnLButtonDown(uint32_t dwFlags, const CFX_PointF& point) { + if (!m_pNormalWidget) return false; - } if (m_pDataAcc->GetAccess() != XFA_ATTRIBUTEENUM_Open || !m_pDataAcc->GetDoc()->GetXFADoc()->IsInteractive()) { return false; } - if (!PtInActiveRect(fx, fy)) { + if (!PtInActiveRect(point)) return false; - } + SetButtonDown(true); CFWL_MessageMouse ms(nullptr, m_pNormalWidget); ms.m_dwCmd = FWL_MouseCommand::LeftButtonDown; ms.m_dwFlags = dwFlags; - ms.m_fx = fx; - ms.m_fy = fy; - FWLToClient(ms.m_fx, ms.m_fy); + ms.m_pos = FWLToClient(point); TranslateFWLMessage(&ms); return true; } -bool CXFA_FFField::OnLButtonUp(uint32_t dwFlags, FX_FLOAT fx, FX_FLOAT fy) { - if (!m_pNormalWidget) { + +bool CXFA_FFField::OnLButtonUp(uint32_t dwFlags, const CFX_PointF& point) { + if (!m_pNormalWidget) return false; - } - if (!IsButtonDown()) { + if (!IsButtonDown()) return false; - } + SetButtonDown(false); CFWL_MessageMouse ms(nullptr, m_pNormalWidget); ms.m_dwCmd = FWL_MouseCommand::LeftButtonUp; ms.m_dwFlags = dwFlags; - ms.m_fx = fx; - ms.m_fy = fy; - FWLToClient(ms.m_fx, ms.m_fy); + ms.m_pos = FWLToClient(point); TranslateFWLMessage(&ms); return true; } -bool CXFA_FFField::OnLButtonDblClk(uint32_t dwFlags, FX_FLOAT fx, FX_FLOAT fy) { - if (!m_pNormalWidget) { + +bool CXFA_FFField::OnLButtonDblClk(uint32_t dwFlags, const CFX_PointF& point) { + if (!m_pNormalWidget) return false; - } + CFWL_MessageMouse ms(nullptr, m_pNormalWidget); ms.m_dwCmd = FWL_MouseCommand::LeftButtonDblClk; ms.m_dwFlags = dwFlags; - ms.m_fx = fx; - ms.m_fy = fy; - FWLToClient(ms.m_fx, ms.m_fy); + ms.m_pos = FWLToClient(point); TranslateFWLMessage(&ms); return true; } -bool CXFA_FFField::OnMouseMove(uint32_t dwFlags, FX_FLOAT fx, FX_FLOAT fy) { - if (!m_pNormalWidget) { + +bool CXFA_FFField::OnMouseMove(uint32_t dwFlags, const CFX_PointF& point) { + if (!m_pNormalWidget) return false; - } + CFWL_MessageMouse ms(nullptr, m_pNormalWidget); ms.m_dwCmd = FWL_MouseCommand::Move; ms.m_dwFlags = dwFlags; - ms.m_fx = fx; - ms.m_fy = fy; - FWLToClient(ms.m_fx, ms.m_fy); + ms.m_pos = FWLToClient(point); TranslateFWLMessage(&ms); return true; } + bool CXFA_FFField::OnMouseWheel(uint32_t dwFlags, int16_t zDelta, - FX_FLOAT fx, - FX_FLOAT fy) { - if (!m_pNormalWidget) { + const CFX_PointF& point) { + if (!m_pNormalWidget) return false; - } + CFWL_MessageMouseWheel ms(nullptr, m_pNormalWidget); ms.m_dwFlags = dwFlags; - ms.m_fx = fx; - ms.m_fy = fy; - FWLToClient(ms.m_fx, ms.m_fy); - ms.m_fDeltaX = zDelta; - ms.m_fDeltaY = 0; + ms.m_pos = FWLToClient(point); + ms.m_delta = CFX_PointF(zDelta, 0); TranslateFWLMessage(&ms); return true; } -bool CXFA_FFField::OnRButtonDown(uint32_t dwFlags, FX_FLOAT fx, FX_FLOAT fy) { - if (!m_pNormalWidget) { + +bool CXFA_FFField::OnRButtonDown(uint32_t dwFlags, const CFX_PointF& point) { + if (!m_pNormalWidget) return false; - } if (m_pDataAcc->GetAccess() != XFA_ATTRIBUTEENUM_Open || !m_pDataAcc->GetDoc()->GetXFADoc()->IsInteractive()) { return false; } - if (!PtInActiveRect(fx, fy)) { + if (!PtInActiveRect(point)) return false; - } + SetButtonDown(true); CFWL_MessageMouse ms(nullptr, m_pNormalWidget); ms.m_dwCmd = FWL_MouseCommand::RightButtonDown; ms.m_dwFlags = dwFlags; - ms.m_fx = fx; - ms.m_fy = fy; - FWLToClient(ms.m_fx, ms.m_fy); + ms.m_pos = FWLToClient(point); TranslateFWLMessage(&ms); return true; } -bool CXFA_FFField::OnRButtonUp(uint32_t dwFlags, FX_FLOAT fx, FX_FLOAT fy) { - if (!m_pNormalWidget) { + +bool CXFA_FFField::OnRButtonUp(uint32_t dwFlags, const CFX_PointF& point) { + if (!m_pNormalWidget) return false; - } - if (!IsButtonDown()) { + if (!IsButtonDown()) return false; - } + SetButtonDown(false); CFWL_MessageMouse ms(nullptr, m_pNormalWidget); ms.m_dwCmd = FWL_MouseCommand::RightButtonUp; ms.m_dwFlags = dwFlags; - ms.m_fx = fx; - ms.m_fy = fy; - FWLToClient(ms.m_fx, ms.m_fy); + ms.m_pos = FWLToClient(point); TranslateFWLMessage(&ms); return true; } -bool CXFA_FFField::OnRButtonDblClk(uint32_t dwFlags, FX_FLOAT fx, FX_FLOAT fy) { - if (!m_pNormalWidget) { + +bool CXFA_FFField::OnRButtonDblClk(uint32_t dwFlags, const CFX_PointF& point) { + if (!m_pNormalWidget) return false; - } + CFWL_MessageMouse ms(nullptr, m_pNormalWidget); ms.m_dwCmd = FWL_MouseCommand::RightButtonDblClk; ms.m_dwFlags = dwFlags; - ms.m_fx = fx; - ms.m_fy = fy; - FWLToClient(ms.m_fx, ms.m_fy); + ms.m_pos = FWLToClient(point); TranslateFWLMessage(&ms); return true; } @@ -557,27 +539,25 @@ bool CXFA_FFField::OnChar(uint32_t dwChar, uint32_t dwFlags) { TranslateFWLMessage(&ms); return true; } -FWL_WidgetHit CXFA_FFField::OnHitTest(FX_FLOAT fx, FX_FLOAT fy) { - if (m_pNormalWidget) { - FX_FLOAT ffx = fx, ffy = fy; - FWLToClient(ffx, ffy); - if (m_pNormalWidget->HitTest(ffx, ffy) != FWL_WidgetHit::Unknown) - return FWL_WidgetHit::Client; +FWL_WidgetHit CXFA_FFField::OnHitTest(const CFX_PointF& point) { + if (m_pNormalWidget && + m_pNormalWidget->HitTest(FWLToClient(point)) != FWL_WidgetHit::Unknown) { + return FWL_WidgetHit::Client; } - if (!GetRectWithoutRotate().Contains(fx, fy)) + if (!GetRectWithoutRotate().Contains(point)) return FWL_WidgetHit::Unknown; - if (m_rtCaption.Contains(fx, fy)) + if (m_rtCaption.Contains(point)) return FWL_WidgetHit::Titlebar; return FWL_WidgetHit::Border; } -bool CXFA_FFField::OnSetCursor(FX_FLOAT fx, FX_FLOAT fy) { +bool CXFA_FFField::OnSetCursor(const CFX_PointF& point) { return true; } -bool CXFA_FFField::PtInActiveRect(FX_FLOAT fx, FX_FLOAT fy) { - return m_pNormalWidget && m_pNormalWidget->GetWidgetRect().Contains(fx, fy); +bool CXFA_FFField::PtInActiveRect(const CFX_PointF& point) { + return m_pNormalWidget && m_pNormalWidget->GetWidgetRect().Contains(point); } void CXFA_FFField::LayoutCaption() { diff --git a/xfa/fxfa/app/xfa_fffield.h b/xfa/fxfa/app/xfa_fffield.h index 1ccd57f30e..f10ce61738 100644 --- a/xfa/fxfa/app/xfa_fffield.h +++ b/xfa/fxfa/app/xfa_fffield.h @@ -31,25 +31,24 @@ class CXFA_FFField : public CXFA_FFWidget, public IFWL_WidgetDelegate { bool PerformLayout() override; bool OnMouseEnter() override; bool OnMouseExit() override; - bool OnLButtonDown(uint32_t dwFlags, FX_FLOAT fx, FX_FLOAT fy) override; - bool OnLButtonUp(uint32_t dwFlags, FX_FLOAT fx, FX_FLOAT fy) override; - bool OnLButtonDblClk(uint32_t dwFlags, FX_FLOAT fx, FX_FLOAT fy) override; - bool OnMouseMove(uint32_t dwFlags, FX_FLOAT fx, FX_FLOAT fy) override; + bool OnLButtonDown(uint32_t dwFlags, const CFX_PointF& point) override; + bool OnLButtonUp(uint32_t dwFlags, const CFX_PointF& point) override; + bool OnLButtonDblClk(uint32_t dwFlags, const CFX_PointF& point) override; + bool OnMouseMove(uint32_t dwFlags, const CFX_PointF& point) override; bool OnMouseWheel(uint32_t dwFlags, int16_t zDelta, - FX_FLOAT fx, - FX_FLOAT fy) override; - bool OnRButtonDown(uint32_t dwFlags, FX_FLOAT fx, FX_FLOAT fy) override; - bool OnRButtonUp(uint32_t dwFlags, FX_FLOAT fx, FX_FLOAT fy) override; - bool OnRButtonDblClk(uint32_t dwFlags, FX_FLOAT fx, FX_FLOAT fy) override; + const CFX_PointF& point) override; + bool OnRButtonDown(uint32_t dwFlags, const CFX_PointF& point) override; + bool OnRButtonUp(uint32_t dwFlags, const CFX_PointF& point) override; + bool OnRButtonDblClk(uint32_t dwFlags, const CFX_PointF& point) override; bool OnSetFocus(CXFA_FFWidget* pOldWidget) override; bool OnKillFocus(CXFA_FFWidget* pNewWidget) override; bool OnKeyDown(uint32_t dwKeyCode, uint32_t dwFlags) override; bool OnKeyUp(uint32_t dwKeyCode, uint32_t dwFlags) override; bool OnChar(uint32_t dwChar, uint32_t dwFlags) override; - FWL_WidgetHit OnHitTest(FX_FLOAT fx, FX_FLOAT fy) override; - bool OnSetCursor(FX_FLOAT fx, FX_FLOAT fy) override; + FWL_WidgetHit OnHitTest(const CFX_PointF& point) override; + bool OnSetCursor(const CFX_PointF& point) override; // IFWL_WidgetDelegate void OnProcessMessage(CFWL_Message* pMessage) override; @@ -61,12 +60,12 @@ class CXFA_FFField : public CXFA_FFWidget, public IFWL_WidgetDelegate { uint32_t UpdateUIProperty(); protected: - bool PtInActiveRect(FX_FLOAT fx, FX_FLOAT fy) override; + bool PtInActiveRect(const CFX_PointF& point) override; virtual void SetFWLRect(); void SetFWLThemeProvider(); CFWL_Widget* GetNormalWidget() { return m_pNormalWidget; } - void FWLToClient(FX_FLOAT& fx, FX_FLOAT& fy); + CFX_PointF FWLToClient(const CFX_PointF& point); void LayoutCaption(); void RenderCaption(CFX_Graphics* pGS, CFX_Matrix* pMatrix = nullptr); diff --git a/xfa/fxfa/app/xfa_ffimageedit.cpp b/xfa/fxfa/app/xfa_ffimageedit.cpp index 93e9481ddf..01d29eed41 100644 --- a/xfa/fxfa/app/xfa_ffimageedit.cpp +++ b/xfa/fxfa/app/xfa_ffimageedit.cpp @@ -86,12 +86,10 @@ void CXFA_FFImageEdit::RenderWidget(CFX_Graphics* pGS, } bool CXFA_FFImageEdit::OnLButtonDown(uint32_t dwFlags, - FX_FLOAT fx, - FX_FLOAT fy) { + const CFX_PointF& point) { if (m_pDataAcc->GetAccess() != XFA_ATTRIBUTEENUM_Open) return false; - - if (!PtInActiveRect(fx, fy)) + if (!PtInActiveRect(point)) return false; SetButtonDown(true); @@ -99,9 +97,7 @@ bool CXFA_FFImageEdit::OnLButtonDown(uint32_t dwFlags, CFWL_MessageMouse ms(nullptr, m_pNormalWidget); ms.m_dwCmd = FWL_MouseCommand::LeftButtonDown; ms.m_dwFlags = dwFlags; - ms.m_fx = fx; - ms.m_fy = fy; - FWLToClient(ms.m_fx, ms.m_fy); + ms.m_pos = FWLToClient(point); TranslateFWLMessage(&ms); return true; } diff --git a/xfa/fxfa/app/xfa_ffimageedit.h b/xfa/fxfa/app/xfa_ffimageedit.h index 9a2d19b8a8..73032b9815 100644 --- a/xfa/fxfa/app/xfa_ffimageedit.h +++ b/xfa/fxfa/app/xfa_ffimageedit.h @@ -20,7 +20,7 @@ class CXFA_FFImageEdit : public CXFA_FFField { uint32_t dwStatus) override; bool LoadWidget() override; void UnloadWidget() override; - bool OnLButtonDown(uint32_t dwFlags, FX_FLOAT fx, FX_FLOAT fy) override; + bool OnLButtonDown(uint32_t dwFlags, const CFX_PointF& point) override; void OnProcessMessage(CFWL_Message* pMessage) override; void OnProcessEvent(CFWL_Event* pEvent) override; void OnDrawWidget(CFX_Graphics* pGraphics, diff --git a/xfa/fxfa/app/xfa_ffsignature.cpp b/xfa/fxfa/app/xfa_ffsignature.cpp index 53f693d1ba..bf2bba3adf 100644 --- a/xfa/fxfa/app/xfa_ffsignature.cpp +++ b/xfa/fxfa/app/xfa_ffsignature.cpp @@ -41,69 +41,74 @@ void CXFA_FFSignature::RenderWidget(CFX_Graphics* pGS, bool CXFA_FFSignature::OnMouseEnter() { return false; } + bool CXFA_FFSignature::OnMouseExit() { return false; } + bool CXFA_FFSignature::OnLButtonDown(uint32_t dwFlags, - FX_FLOAT fx, - FX_FLOAT fy) { + const CFX_PointF& point) { return false; } -bool CXFA_FFSignature::OnLButtonUp(uint32_t dwFlags, FX_FLOAT fx, FX_FLOAT fy) { + +bool CXFA_FFSignature::OnLButtonUp(uint32_t dwFlags, const CFX_PointF& point) { return false; } + bool CXFA_FFSignature::OnLButtonDblClk(uint32_t dwFlags, - FX_FLOAT fx, - FX_FLOAT fy) { + const CFX_PointF& point) { return false; } -bool CXFA_FFSignature::OnMouseMove(uint32_t dwFlags, FX_FLOAT fx, FX_FLOAT fy) { + +bool CXFA_FFSignature::OnMouseMove(uint32_t dwFlags, const CFX_PointF& point) { return false; } + bool CXFA_FFSignature::OnMouseWheel(uint32_t dwFlags, int16_t zDelta, - FX_FLOAT fx, - FX_FLOAT fy) { + const CFX_PointF& point) { return false; } + bool CXFA_FFSignature::OnRButtonDown(uint32_t dwFlags, - FX_FLOAT fx, - FX_FLOAT fy) { + const CFX_PointF& point) { return false; } -bool CXFA_FFSignature::OnRButtonUp(uint32_t dwFlags, FX_FLOAT fx, FX_FLOAT fy) { + +bool CXFA_FFSignature::OnRButtonUp(uint32_t dwFlags, const CFX_PointF& point) { return false; } + bool CXFA_FFSignature::OnRButtonDblClk(uint32_t dwFlags, - FX_FLOAT fx, - FX_FLOAT fy) { + const CFX_PointF& point) { return false; } + bool CXFA_FFSignature::OnKeyDown(uint32_t dwKeyCode, uint32_t dwFlags) { return false; } + bool CXFA_FFSignature::OnKeyUp(uint32_t dwKeyCode, uint32_t dwFlags) { return false; } + bool CXFA_FFSignature::OnChar(uint32_t dwChar, uint32_t dwFlags) { return false; } -FWL_WidgetHit CXFA_FFSignature::OnHitTest(FX_FLOAT fx, FX_FLOAT fy) { - if (m_pNormalWidget) { - FX_FLOAT ffx = fx, ffy = fy; - FWLToClient(ffx, ffy); - if (m_pNormalWidget->HitTest(ffx, ffy) != FWL_WidgetHit::Unknown) - return FWL_WidgetHit::Client; +FWL_WidgetHit CXFA_FFSignature::OnHitTest(const CFX_PointF& point) { + if (m_pNormalWidget && + m_pNormalWidget->HitTest(FWLToClient(point)) != FWL_WidgetHit::Unknown) { + return FWL_WidgetHit::Client; } - if (!GetRectWithoutRotate().Contains(fx, fy)) + if (!GetRectWithoutRotate().Contains(point)) return FWL_WidgetHit::Unknown; - if (m_rtCaption.Contains(fx, fy)) + if (m_rtCaption.Contains(point)) return FWL_WidgetHit::Titlebar; return FWL_WidgetHit::Client; } -bool CXFA_FFSignature::OnSetCursor(FX_FLOAT fx, FX_FLOAT fy) { +bool CXFA_FFSignature::OnSetCursor(const CFX_PointF& point) { return false; } diff --git a/xfa/fxfa/app/xfa_ffsignature.h b/xfa/fxfa/app/xfa_ffsignature.h index 29c27360a9..934323f436 100644 --- a/xfa/fxfa/app/xfa_ffsignature.h +++ b/xfa/fxfa/app/xfa_ffsignature.h @@ -21,23 +21,22 @@ class CXFA_FFSignature final : public CXFA_FFField { bool LoadWidget() override; bool OnMouseEnter() override; bool OnMouseExit() override; - bool OnLButtonDown(uint32_t dwFlags, FX_FLOAT fx, FX_FLOAT fy) override; - bool OnLButtonUp(uint32_t dwFlags, FX_FLOAT fx, FX_FLOAT fy) override; - bool OnLButtonDblClk(uint32_t dwFlags, FX_FLOAT fx, FX_FLOAT fy) override; - bool OnMouseMove(uint32_t dwFlags, FX_FLOAT fx, FX_FLOAT fy) override; + bool OnLButtonDown(uint32_t dwFlags, const CFX_PointF& point) override; + bool OnLButtonUp(uint32_t dwFlags, const CFX_PointF& point) override; + bool OnLButtonDblClk(uint32_t dwFlags, const CFX_PointF& point) override; + bool OnMouseMove(uint32_t dwFlags, const CFX_PointF& point) override; bool OnMouseWheel(uint32_t dwFlags, int16_t zDelta, - FX_FLOAT fx, - FX_FLOAT fy) override; - bool OnRButtonDown(uint32_t dwFlags, FX_FLOAT fx, FX_FLOAT fy) override; - bool OnRButtonUp(uint32_t dwFlags, FX_FLOAT fx, FX_FLOAT fy) override; - bool OnRButtonDblClk(uint32_t dwFlags, FX_FLOAT fx, FX_FLOAT fy) override; + const CFX_PointF& pointy) override; + bool OnRButtonDown(uint32_t dwFlags, const CFX_PointF& point) override; + bool OnRButtonUp(uint32_t dwFlags, const CFX_PointF& point) override; + bool OnRButtonDblClk(uint32_t dwFlags, const CFX_PointF& point) override; bool OnKeyDown(uint32_t dwKeyCode, uint32_t dwFlags) override; bool OnKeyUp(uint32_t dwKeyCode, uint32_t dwFlags) override; bool OnChar(uint32_t dwChar, uint32_t dwFlags) override; - FWL_WidgetHit OnHitTest(FX_FLOAT fx, FX_FLOAT fy) override; - bool OnSetCursor(FX_FLOAT fx, FX_FLOAT fy) override; + FWL_WidgetHit OnHitTest(const CFX_PointF& point) override; + bool OnSetCursor(const CFX_PointF& point) override; }; #endif // XFA_FXFA_APP_XFA_FFSIGNATURE_H_ diff --git a/xfa/fxfa/app/xfa_fftext.cpp b/xfa/fxfa/app/xfa_fftext.cpp index d8231bfda8..e8d7aa32d0 100644 --- a/xfa/fxfa/app/xfa_fftext.cpp +++ b/xfa/fxfa/app/xfa_fftext.cpp @@ -107,11 +107,11 @@ bool CXFA_FFText::PerformLayout() { return true; } -bool CXFA_FFText::OnLButtonDown(uint32_t dwFlags, FX_FLOAT fx, FX_FLOAT fy) { - if (!GetRectWithoutRotate().Contains(fx, fy)) +bool CXFA_FFText::OnLButtonDown(uint32_t dwFlags, const CFX_PointF& point) { + if (!GetRectWithoutRotate().Contains(point)) return false; - const FX_WCHAR* wsURLContent = GetLinkURLAtPoint(fx, fy); + const FX_WCHAR* wsURLContent = GetLinkURLAtPoint(point); if (!wsURLContent) return false; @@ -119,33 +119,33 @@ bool CXFA_FFText::OnLButtonDown(uint32_t dwFlags, FX_FLOAT fx, FX_FLOAT fy) { return true; } -bool CXFA_FFText::OnMouseMove(uint32_t dwFlags, FX_FLOAT fx, FX_FLOAT fy) { - return GetRectWithoutRotate().Contains(fx, fy) && !!GetLinkURLAtPoint(fx, fy); +bool CXFA_FFText::OnMouseMove(uint32_t dwFlags, const CFX_PointF& point) { + return GetRectWithoutRotate().Contains(point) && !!GetLinkURLAtPoint(point); } -bool CXFA_FFText::OnLButtonUp(uint32_t dwFlags, FX_FLOAT fx, FX_FLOAT fy) { - if (!IsButtonDown()) { +bool CXFA_FFText::OnLButtonUp(uint32_t dwFlags, const CFX_PointF& point) { + if (!IsButtonDown()) return false; - } + SetButtonDown(false); - const FX_WCHAR* wsURLContent = GetLinkURLAtPoint(fx, fy); - if (!wsURLContent) { + const FX_WCHAR* wsURLContent = GetLinkURLAtPoint(point); + if (!wsURLContent) return false; - } + CXFA_FFDoc* pDoc = GetDoc(); pDoc->GetDocEnvironment()->GotoURL(pDoc, wsURLContent); return true; } -FWL_WidgetHit CXFA_FFText::OnHitTest(FX_FLOAT fx, FX_FLOAT fy) { - if (!GetRectWithoutRotate().Contains(fx, fy)) +FWL_WidgetHit CXFA_FFText::OnHitTest(const CFX_PointF& point) { + if (!GetRectWithoutRotate().Contains(point)) return FWL_WidgetHit::Unknown; - if (!GetLinkURLAtPoint(fx, fy)) + if (!GetLinkURLAtPoint(point)) return FWL_WidgetHit::Unknown; return FWL_WidgetHit::HyperLink; } -const FX_WCHAR* CXFA_FFText::GetLinkURLAtPoint(FX_FLOAT fx, FX_FLOAT fy) { +const FX_WCHAR* CXFA_FFText::GetLinkURLAtPoint(const CFX_PointF& point) { CXFA_TextLayout* pTextLayout = m_pDataAcc->GetTextLayout(); if (!pTextLayout) return nullptr; @@ -154,7 +154,7 @@ const FX_WCHAR* CXFA_FFText::GetLinkURLAtPoint(FX_FLOAT fx, FX_FLOAT fy) { for (const auto& pPieceLine : *pTextLayout->GetPieceLines()) { for (const auto& pPiece : pPieceLine->m_textPieces) { if (pPiece->pLinkData && - pPiece->rtPiece.Contains(fx - rect.left, fy - rect.top)) { + pPiece->rtPiece.Contains(point - rect.TopLeft())) { return pPiece->pLinkData->GetLinkURL(); } } diff --git a/xfa/fxfa/app/xfa_fftext.h b/xfa/fxfa/app/xfa_fftext.h index 2c01a6f349..c553821791 100644 --- a/xfa/fxfa/app/xfa_fftext.h +++ b/xfa/fxfa/app/xfa_fftext.h @@ -15,10 +15,10 @@ class CXFA_FFText : public CXFA_FFDraw { ~CXFA_FFText() override; // CXFA_FFWidget - bool OnLButtonDown(uint32_t dwFlags, FX_FLOAT fx, FX_FLOAT fy) override; - bool OnLButtonUp(uint32_t dwFlags, FX_FLOAT fx, FX_FLOAT fy) override; - bool OnMouseMove(uint32_t dwFlags, FX_FLOAT fx, FX_FLOAT fy) override; - FWL_WidgetHit OnHitTest(FX_FLOAT fx, FX_FLOAT fy) override; + bool OnLButtonDown(uint32_t dwFlags, const CFX_PointF& point) override; + bool OnLButtonUp(uint32_t dwFlags, const CFX_PointF& point) override; + bool OnMouseMove(uint32_t dwFlags, const CFX_PointF& point) override; + FWL_WidgetHit OnHitTest(const CFX_PointF& point) override; void RenderWidget(CFX_Graphics* pGS, CFX_Matrix* pMatrix, uint32_t dwStatus) override; @@ -26,7 +26,7 @@ class CXFA_FFText : public CXFA_FFDraw { bool PerformLayout() override; private: - const FX_WCHAR* GetLinkURLAtPoint(FX_FLOAT fx, FX_FLOAT fy); + const FX_WCHAR* GetLinkURLAtPoint(const CFX_PointF& point); }; #endif // XFA_FXFA_APP_XFA_FFTEXT_H_ diff --git a/xfa/fxfa/app/xfa_fftextedit.cpp b/xfa/fxfa/app/xfa_fftextedit.cpp index ad5ab434c6..094839f486 100644 --- a/xfa/fxfa/app/xfa_fftextedit.cpp +++ b/xfa/fxfa/app/xfa_fftextedit.cpp @@ -103,58 +103,53 @@ void CXFA_FFTextEdit::UpdateWidgetProperty() { m_pNormalWidget->ModifyStyles(dwStyle, 0xFFFFFFFF); m_pNormalWidget->ModifyStylesEx(dwExtendedStyle, 0xFFFFFFFF); } -bool CXFA_FFTextEdit::OnLButtonDown(uint32_t dwFlags, - FX_FLOAT fx, - FX_FLOAT fy) { - if (!PtInActiveRect(fx, fy)) { + +bool CXFA_FFTextEdit::OnLButtonDown(uint32_t dwFlags, const CFX_PointF& point) { + if (!PtInActiveRect(point)) return false; - } if (!IsFocused()) { m_dwStatus |= XFA_WidgetStatus_Focused; UpdateFWLData(); AddInvalidateRect(); } + SetButtonDown(true); CFWL_MessageMouse ms(nullptr, m_pNormalWidget); ms.m_dwCmd = FWL_MouseCommand::LeftButtonDown; ms.m_dwFlags = dwFlags; - ms.m_fx = fx; - ms.m_fy = fy; - FWLToClient(ms.m_fx, ms.m_fy); + ms.m_pos = FWLToClient(point); TranslateFWLMessage(&ms); return true; } -bool CXFA_FFTextEdit::OnRButtonDown(uint32_t dwFlags, - FX_FLOAT fx, - FX_FLOAT fy) { - if (m_pDataAcc->GetAccess() != XFA_ATTRIBUTEENUM_Open) { + +bool CXFA_FFTextEdit::OnRButtonDown(uint32_t dwFlags, const CFX_PointF& point) { + if (m_pDataAcc->GetAccess() != XFA_ATTRIBUTEENUM_Open) return false; - } - if (!PtInActiveRect(fx, fy)) { + if (!PtInActiveRect(point)) return false; - } if (!IsFocused()) { m_dwStatus |= XFA_WidgetStatus_Focused; UpdateFWLData(); AddInvalidateRect(); } + SetButtonDown(true); CFWL_MessageMouse ms(nullptr, nullptr); ms.m_dwCmd = FWL_MouseCommand::RightButtonDown; ms.m_dwFlags = dwFlags; - ms.m_fx = fx; - ms.m_fy = fy; - FWLToClient(ms.m_fx, ms.m_fy); + ms.m_pos = FWLToClient(point); TranslateFWLMessage(&ms); return true; } -bool CXFA_FFTextEdit::OnRButtonUp(uint32_t dwFlags, FX_FLOAT fx, FX_FLOAT fy) { - if (!CXFA_FFField::OnRButtonUp(dwFlags, fx, fy)) + +bool CXFA_FFTextEdit::OnRButtonUp(uint32_t dwFlags, const CFX_PointF& point) { + if (!CXFA_FFField::OnRButtonUp(dwFlags, point)) return false; - GetDoc()->GetDocEnvironment()->PopupMenu(this, CFX_PointF(fx, fy)); + GetDoc()->GetDocEnvironment()->PopupMenu(this, point); return true; } + bool CXFA_FFTextEdit::OnSetFocus(CXFA_FFWidget* pOldWidget) { m_dwStatus &= ~XFA_WidgetStatus_TextEditValueChanged; if (!IsFocused()) { @@ -499,11 +494,11 @@ CFX_RectF CXFA_FFDateTimeEdit::GetBBox(uint32_t dwStatus, bool bDrawFocus) { return CXFA_FFWidget::GetBBox(dwStatus); } -bool CXFA_FFDateTimeEdit::PtInActiveRect(FX_FLOAT fx, FX_FLOAT fy) { +bool CXFA_FFDateTimeEdit::PtInActiveRect(const CFX_PointF& point) { return m_pNormalWidget && static_cast<CFWL_DateTimePicker*>(m_pNormalWidget) ->GetBBox() - .Contains(fx, fy); + .Contains(point); } bool CXFA_FFDateTimeEdit::LoadWidget() { diff --git a/xfa/fxfa/app/xfa_fftextedit.h b/xfa/fxfa/app/xfa_fftextedit.h index 91c30ba8c9..1e0562a75b 100644 --- a/xfa/fxfa/app/xfa_fftextedit.h +++ b/xfa/fxfa/app/xfa_fftextedit.h @@ -19,9 +19,9 @@ class CXFA_FFTextEdit : public CXFA_FFField { // CXFA_FFField bool LoadWidget() override; void UpdateWidgetProperty() override; - bool OnLButtonDown(uint32_t dwFlags, FX_FLOAT fx, FX_FLOAT fy) override; - bool OnRButtonDown(uint32_t dwFlags, FX_FLOAT fx, FX_FLOAT fy) override; - bool OnRButtonUp(uint32_t dwFlags, FX_FLOAT fx, FX_FLOAT fy) override; + bool OnLButtonDown(uint32_t dwFlags, const CFX_PointF& point) override; + bool OnRButtonDown(uint32_t dwFlags, const CFX_PointF& point) override; + bool OnRButtonUp(uint32_t dwFlags, const CFX_PointF& point) override; bool OnSetFocus(CXFA_FFWidget* pOldWidget) override; bool OnKillFocus(CXFA_FFWidget* pNewWidget) override; void OnProcessMessage(CFWL_Message* pMessage) override; @@ -95,7 +95,7 @@ class CXFA_FFDateTimeEdit : public CXFA_FFTextEdit { int32_t iDay); protected: - bool PtInActiveRect(FX_FLOAT fx, FX_FLOAT fy) override; + bool PtInActiveRect(const CFX_PointF& point) override; bool CommitData() override; bool UpdateFWLData() override; bool IsDataChanged() override; diff --git a/xfa/fxfa/app/xfa_ffwidget.cpp b/xfa/fxfa/app/xfa_ffwidget.cpp index 7a8cc646dd..c917697948 100644 --- a/xfa/fxfa/app/xfa_ffwidget.cpp +++ b/xfa/fxfa/app/xfa_ffwidget.cpp @@ -189,38 +189,42 @@ bool CXFA_FFWidget::IsFocused() { bool CXFA_FFWidget::OnMouseEnter() { return false; } + bool CXFA_FFWidget::OnMouseExit() { return false; } -bool CXFA_FFWidget::OnLButtonDown(uint32_t dwFlags, FX_FLOAT fx, FX_FLOAT fy) { + +bool CXFA_FFWidget::OnLButtonDown(uint32_t dwFlags, const CFX_PointF& point) { return false; } -bool CXFA_FFWidget::OnLButtonUp(uint32_t dwFlags, FX_FLOAT fx, FX_FLOAT fy) { + +bool CXFA_FFWidget::OnLButtonUp(uint32_t dwFlags, const CFX_PointF& point) { return false; } -bool CXFA_FFWidget::OnLButtonDblClk(uint32_t dwFlags, - FX_FLOAT fx, - FX_FLOAT fy) { + +bool CXFA_FFWidget::OnLButtonDblClk(uint32_t dwFlags, const CFX_PointF& point) { return false; } -bool CXFA_FFWidget::OnMouseMove(uint32_t dwFlags, FX_FLOAT fx, FX_FLOAT fy) { + +bool CXFA_FFWidget::OnMouseMove(uint32_t dwFlags, const CFX_PointF& point) { return false; } + bool CXFA_FFWidget::OnMouseWheel(uint32_t dwFlags, int16_t zDelta, - FX_FLOAT fx, - FX_FLOAT fy) { + const CFX_PointF& point) { return false; } -bool CXFA_FFWidget::OnRButtonDown(uint32_t dwFlags, FX_FLOAT fx, FX_FLOAT fy) { + +bool CXFA_FFWidget::OnRButtonDown(uint32_t dwFlags, const CFX_PointF& point) { return false; } -bool CXFA_FFWidget::OnRButtonUp(uint32_t dwFlags, FX_FLOAT fx, FX_FLOAT fy) { + +bool CXFA_FFWidget::OnRButtonUp(uint32_t dwFlags, const CFX_PointF& point) { return false; } -bool CXFA_FFWidget::OnRButtonDblClk(uint32_t dwFlags, - FX_FLOAT fx, - FX_FLOAT fy) { + +bool CXFA_FFWidget::OnRButtonDblClk(uint32_t dwFlags, const CFX_PointF& point) { return false; } @@ -236,6 +240,7 @@ bool CXFA_FFWidget::OnSetFocus(CXFA_FFWidget* pOldWidget) { m_pDataAcc->ProcessEvent(XFA_ATTRIBUTEENUM_Enter, &eParam); return true; } + bool CXFA_FFWidget::OnKillFocus(CXFA_FFWidget* pNewWidget) { m_dwStatus &= ~XFA_WidgetStatus_Focused; EventKillFocus(); @@ -247,57 +252,75 @@ bool CXFA_FFWidget::OnKillFocus(CXFA_FFWidget* pNewWidget) { } return true; } + bool CXFA_FFWidget::OnKeyDown(uint32_t dwKeyCode, uint32_t dwFlags) { return false; } + bool CXFA_FFWidget::OnKeyUp(uint32_t dwKeyCode, uint32_t dwFlags) { return false; } + bool CXFA_FFWidget::OnChar(uint32_t dwChar, uint32_t dwFlags) { return false; } -FWL_WidgetHit CXFA_FFWidget::OnHitTest(FX_FLOAT fx, FX_FLOAT fy) { + +FWL_WidgetHit CXFA_FFWidget::OnHitTest(const CFX_PointF& point) { return FWL_WidgetHit::Unknown; } -bool CXFA_FFWidget::OnSetCursor(FX_FLOAT fx, FX_FLOAT fy) { + +bool CXFA_FFWidget::OnSetCursor(const CFX_PointF& point) { return false; } + bool CXFA_FFWidget::CanUndo() { return false; } + bool CXFA_FFWidget::CanRedo() { return false; } + bool CXFA_FFWidget::Undo() { return false; } + bool CXFA_FFWidget::Redo() { return false; } + bool CXFA_FFWidget::CanCopy() { return false; } + bool CXFA_FFWidget::CanCut() { return false; } + bool CXFA_FFWidget::CanPaste() { return false; } + bool CXFA_FFWidget::CanSelectAll() { return false; } + bool CXFA_FFWidget::CanDelete() { return CanCut(); } + bool CXFA_FFWidget::CanDeSelect() { return CanCopy(); } + bool CXFA_FFWidget::Copy(CFX_WideString& wsCopy) { return false; } + bool CXFA_FFWidget::Cut(CFX_WideString& wsCut) { return false; } + bool CXFA_FFWidget::Paste(const CFX_WideString& wsPaste) { return false; } @@ -429,8 +452,8 @@ bool CXFA_FFWidget::IsAncestorOf(CXFA_FFWidget* pWidget) { return false; } -bool CXFA_FFWidget::PtInActiveRect(FX_FLOAT fx, FX_FLOAT fy) { - return GetWidgetRect().Contains(fx, fy); +bool CXFA_FFWidget::PtInActiveRect(const CFX_PointF& point) { + return GetWidgetRect().Contains(point); } CXFA_FFDocView* CXFA_FFWidget::GetDocView() { diff --git a/xfa/fxfa/app/xfa_ffwidgethandler.cpp b/xfa/fxfa/app/xfa_ffwidgethandler.cpp index bbca0409d3..2fddfb6156 100644 --- a/xfa/fxfa/app/xfa_ffwidgethandler.cpp +++ b/xfa/fxfa/app/xfa_ffwidgethandler.cpp @@ -40,11 +40,9 @@ bool CXFA_FFWidgetHandler::OnMouseExit(CXFA_FFWidget* hWidget) { bool CXFA_FFWidgetHandler::OnLButtonDown(CXFA_FFWidget* hWidget, uint32_t dwFlags, - FX_FLOAT fx, - FX_FLOAT fy) { + const CFX_PointF& point) { m_pDocView->LockUpdate(); - CFX_PointF pos = hWidget->Rotate2Normal(CFX_PointF(fx, fy)); - bool bRet = hWidget->OnLButtonDown(dwFlags, pos.x, pos.y); + bool bRet = hWidget->OnLButtonDown(dwFlags, hWidget->Rotate2Normal(point)); if (bRet && m_pDocView->SetFocus(hWidget)) { m_pDocView->GetDoc()->GetDocEnvironment()->SetFocusWidget( m_pDocView->GetDoc(), hWidget); @@ -56,12 +54,10 @@ bool CXFA_FFWidgetHandler::OnLButtonDown(CXFA_FFWidget* hWidget, bool CXFA_FFWidgetHandler::OnLButtonUp(CXFA_FFWidget* hWidget, uint32_t dwFlags, - FX_FLOAT fx, - FX_FLOAT fy) { + const CFX_PointF& point) { m_pDocView->LockUpdate(); - CFX_PointF pos = hWidget->Rotate2Normal(CFX_PointF(fx, fy)); m_pDocView->m_bLayoutEvent = true; - bool bRet = hWidget->OnLButtonUp(dwFlags, pos.x, pos.y); + bool bRet = hWidget->OnLButtonUp(dwFlags, hWidget->Rotate2Normal(point)); m_pDocView->UnlockUpdate(); m_pDocView->UpdateDocView(); return bRet; @@ -69,20 +65,16 @@ bool CXFA_FFWidgetHandler::OnLButtonUp(CXFA_FFWidget* hWidget, bool CXFA_FFWidgetHandler::OnLButtonDblClk(CXFA_FFWidget* hWidget, uint32_t dwFlags, - FX_FLOAT fx, - FX_FLOAT fy) { - CFX_PointF pos = hWidget->Rotate2Normal(CFX_PointF(fx, fy)); - bool bRet = hWidget->OnLButtonDblClk(dwFlags, pos.x, pos.y); + const CFX_PointF& point) { + bool bRet = hWidget->OnLButtonDblClk(dwFlags, hWidget->Rotate2Normal(point)); m_pDocView->RunInvalidate(); return bRet; } bool CXFA_FFWidgetHandler::OnMouseMove(CXFA_FFWidget* hWidget, uint32_t dwFlags, - FX_FLOAT fx, - FX_FLOAT fy) { - CFX_PointF pos = hWidget->Rotate2Normal(CFX_PointF(fx, fy)); - bool bRet = hWidget->OnMouseMove(dwFlags, pos.x, pos.y); + const CFX_PointF& point) { + bool bRet = hWidget->OnMouseMove(dwFlags, hWidget->Rotate2Normal(point)); m_pDocView->RunInvalidate(); return bRet; } @@ -90,20 +82,17 @@ bool CXFA_FFWidgetHandler::OnMouseMove(CXFA_FFWidget* hWidget, bool CXFA_FFWidgetHandler::OnMouseWheel(CXFA_FFWidget* hWidget, uint32_t dwFlags, int16_t zDelta, - FX_FLOAT fx, - FX_FLOAT fy) { - CFX_PointF pos = hWidget->Rotate2Normal(CFX_PointF(fx, fy)); - bool bRet = hWidget->OnMouseWheel(dwFlags, zDelta, pos.x, pos.y); + const CFX_PointF& point) { + bool bRet = + hWidget->OnMouseWheel(dwFlags, zDelta, hWidget->Rotate2Normal(point)); m_pDocView->RunInvalidate(); return bRet; } bool CXFA_FFWidgetHandler::OnRButtonDown(CXFA_FFWidget* hWidget, uint32_t dwFlags, - FX_FLOAT fx, - FX_FLOAT fy) { - CFX_PointF pos = hWidget->Rotate2Normal(CFX_PointF(fx, fy)); - bool bRet = hWidget->OnRButtonDown(dwFlags, pos.x, pos.y); + const CFX_PointF& point) { + bool bRet = hWidget->OnRButtonDown(dwFlags, hWidget->Rotate2Normal(point)); if (bRet && m_pDocView->SetFocus(hWidget)) { m_pDocView->GetDoc()->GetDocEnvironment()->SetFocusWidget( m_pDocView->GetDoc(), hWidget); @@ -114,20 +103,16 @@ bool CXFA_FFWidgetHandler::OnRButtonDown(CXFA_FFWidget* hWidget, bool CXFA_FFWidgetHandler::OnRButtonUp(CXFA_FFWidget* hWidget, uint32_t dwFlags, - FX_FLOAT fx, - FX_FLOAT fy) { - CFX_PointF pos = hWidget->Rotate2Normal(CFX_PointF(fx, fy)); - bool bRet = hWidget->OnRButtonUp(dwFlags, pos.x, pos.y); + const CFX_PointF& point) { + bool bRet = hWidget->OnRButtonUp(dwFlags, hWidget->Rotate2Normal(point)); m_pDocView->RunInvalidate(); return bRet; } bool CXFA_FFWidgetHandler::OnRButtonDblClk(CXFA_FFWidget* hWidget, uint32_t dwFlags, - FX_FLOAT fx, - FX_FLOAT fy) { - CFX_PointF pos = hWidget->Rotate2Normal(CFX_PointF(fx, fy)); - bool bRet = hWidget->OnRButtonDblClk(dwFlags, pos.x, pos.y); + const CFX_PointF& point) { + bool bRet = hWidget->OnRButtonDblClk(dwFlags, hWidget->Rotate2Normal(point)); m_pDocView->RunInvalidate(); return bRet; } @@ -158,20 +143,15 @@ bool CXFA_FFWidgetHandler::OnChar(CXFA_FFWidget* hWidget, } FWL_WidgetHit CXFA_FFWidgetHandler::OnHitTest(CXFA_FFWidget* hWidget, - FX_FLOAT fx, - FX_FLOAT fy) { + const CFX_PointF& point) { if (!(hWidget->GetStatus() & XFA_WidgetStatus_Visible)) return FWL_WidgetHit::Unknown; - - CFX_PointF pos = hWidget->Rotate2Normal(CFX_PointF(fx, fy)); - return hWidget->OnHitTest(pos.x, pos.y); + return hWidget->OnHitTest(hWidget->Rotate2Normal(point)); } bool CXFA_FFWidgetHandler::OnSetCursor(CXFA_FFWidget* hWidget, - FX_FLOAT fx, - FX_FLOAT fy) { - CFX_PointF pos = hWidget->Rotate2Normal(CFX_PointF(fx, fy)); - return hWidget->OnSetCursor(pos.x, pos.y); + const CFX_PointF& point) { + return hWidget->OnSetCursor(hWidget->Rotate2Normal(point)); } void CXFA_FFWidgetHandler::RenderWidget(CXFA_FFWidget* hWidget, diff --git a/xfa/fxfa/xfa_ffwidget.h b/xfa/fxfa/xfa_ffwidget.h index 57dfc639da..5972b8ad70 100644 --- a/xfa/fxfa/xfa_ffwidget.h +++ b/xfa/fxfa/xfa_ffwidget.h @@ -60,25 +60,24 @@ class CXFA_FFWidget : public CXFA_ContentLayoutItem { virtual void UpdateWidgetProperty(); virtual bool OnMouseEnter(); virtual bool OnMouseExit(); - virtual bool OnLButtonDown(uint32_t dwFlags, FX_FLOAT fx, FX_FLOAT fy); - virtual bool OnLButtonUp(uint32_t dwFlags, FX_FLOAT fx, FX_FLOAT fy); - virtual bool OnLButtonDblClk(uint32_t dwFlags, FX_FLOAT fx, FX_FLOAT fy); - virtual bool OnMouseMove(uint32_t dwFlags, FX_FLOAT fx, FX_FLOAT fy); + virtual bool OnLButtonDown(uint32_t dwFlags, const CFX_PointF& point); + virtual bool OnLButtonUp(uint32_t dwFlags, const CFX_PointF& point); + virtual bool OnLButtonDblClk(uint32_t dwFlags, const CFX_PointF& point); + virtual bool OnMouseMove(uint32_t dwFlags, const CFX_PointF& point); virtual bool OnMouseWheel(uint32_t dwFlags, int16_t zDelta, - FX_FLOAT fx, - FX_FLOAT fy); - virtual bool OnRButtonDown(uint32_t dwFlags, FX_FLOAT fx, FX_FLOAT fy); - virtual bool OnRButtonUp(uint32_t dwFlags, FX_FLOAT fx, FX_FLOAT fy); - virtual bool OnRButtonDblClk(uint32_t dwFlags, FX_FLOAT fx, FX_FLOAT fy); + const CFX_PointF& point); + virtual bool OnRButtonDown(uint32_t dwFlags, const CFX_PointF& point); + virtual bool OnRButtonUp(uint32_t dwFlags, const CFX_PointF& point); + virtual bool OnRButtonDblClk(uint32_t dwFlags, const CFX_PointF& point); virtual bool OnSetFocus(CXFA_FFWidget* pOldWidget); virtual bool OnKillFocus(CXFA_FFWidget* pNewWidget); virtual bool OnKeyDown(uint32_t dwKeyCode, uint32_t dwFlags); virtual bool OnKeyUp(uint32_t dwKeyCode, uint32_t dwFlags); virtual bool OnChar(uint32_t dwChar, uint32_t dwFlags); - virtual FWL_WidgetHit OnHitTest(FX_FLOAT fx, FX_FLOAT fy); - virtual bool OnSetCursor(FX_FLOAT fx, FX_FLOAT fy); + virtual FWL_WidgetHit OnHitTest(const CFX_PointF& point); + virtual bool OnSetCursor(const CFX_PointF& point); virtual bool CanUndo(); virtual bool CanRedo(); virtual bool Undo(); @@ -127,7 +126,7 @@ class CXFA_FFWidget : public CXFA_ContentLayoutItem { const CFWL_App* GetFWLApp(); protected: - virtual bool PtInActiveRect(FX_FLOAT fx, FX_FLOAT fy); + virtual bool PtInActiveRect(const CFX_PointF& point); void DrawBorder(CFX_Graphics* pGS, CXFA_Box box, diff --git a/xfa/fxfa/xfa_ffwidgethandler.h b/xfa/fxfa/xfa_ffwidgethandler.h index 7335f9d1b6..66bda3e02a 100644 --- a/xfa/fxfa/xfa_ffwidgethandler.h +++ b/xfa/fxfa/xfa_ffwidgethandler.h @@ -29,43 +29,35 @@ class CXFA_FFWidgetHandler { bool OnMouseExit(CXFA_FFWidget* hWidget); bool OnLButtonDown(CXFA_FFWidget* hWidget, uint32_t dwFlags, - FX_FLOAT fx, - FX_FLOAT fy); + const CFX_PointF& point); bool OnLButtonUp(CXFA_FFWidget* hWidget, uint32_t dwFlags, - FX_FLOAT fx, - FX_FLOAT fy); + const CFX_PointF& point); bool OnLButtonDblClk(CXFA_FFWidget* hWidget, uint32_t dwFlags, - FX_FLOAT fx, - FX_FLOAT fy); + const CFX_PointF& point); bool OnMouseMove(CXFA_FFWidget* hWidget, uint32_t dwFlags, - FX_FLOAT fx, - FX_FLOAT fy); + const CFX_PointF& point); bool OnMouseWheel(CXFA_FFWidget* hWidget, uint32_t dwFlags, int16_t zDelta, - FX_FLOAT fx, - FX_FLOAT fy); + const CFX_PointF& point); bool OnRButtonDown(CXFA_FFWidget* hWidget, uint32_t dwFlags, - FX_FLOAT fx, - FX_FLOAT fy); + const CFX_PointF& point); bool OnRButtonUp(CXFA_FFWidget* hWidget, uint32_t dwFlags, - FX_FLOAT fx, - FX_FLOAT fy); + const CFX_PointF& point); bool OnRButtonDblClk(CXFA_FFWidget* hWidget, uint32_t dwFlags, - FX_FLOAT fx, - FX_FLOAT fy); + const CFX_PointF& point); bool OnKeyDown(CXFA_FFWidget* hWidget, uint32_t dwKeyCode, uint32_t dwFlags); bool OnKeyUp(CXFA_FFWidget* hWidget, uint32_t dwKeyCode, uint32_t dwFlags); bool OnChar(CXFA_FFWidget* hWidget, uint32_t dwChar, uint32_t dwFlags); - FWL_WidgetHit OnHitTest(CXFA_FFWidget* hWidget, FX_FLOAT fx, FX_FLOAT fy); - bool OnSetCursor(CXFA_FFWidget* hWidget, FX_FLOAT fx, FX_FLOAT fy); + FWL_WidgetHit OnHitTest(CXFA_FFWidget* hWidget, const CFX_PointF& point); + bool OnSetCursor(CXFA_FFWidget* hWidget, const CFX_PointF& point); void RenderWidget(CXFA_FFWidget* hWidget, CFX_Graphics* pGS, CFX_Matrix* pMatrix, |