diff options
Diffstat (limited to 'xfa/fwl')
29 files changed, 187 insertions, 238 deletions
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( |