From b45ea1fce52d93615470bab8b671cba5907fb01e Mon Sep 17 00:00:00 2001 From: Dan Sinclair Date: Tue, 21 Feb 2017 14:27:59 -0500 Subject: 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 Reviewed-by: Tom Sepez --- xfa/fwl/cfwl_edit.cpp | 26 ++++++++++---------------- 1 file changed, 10 insertions(+), 16 deletions(-) (limited to 'xfa/fwl/cfwl_edit.cpp') 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(); -- cgit v1.2.3