From 7f6bec9b4c0cb2f53724ea83715d4fe22eed1d28 Mon Sep 17 00:00:00 2001 From: Dan Sinclair Date: Wed, 5 Jul 2017 14:13:16 -0400 Subject: Remove PNM_ mouse methods and OnNotify MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit This CL removes the remaining PNM_* messages and converts them to individual methods. Change-Id: I44791a35bc720f29f8f5d4d7c26a8c899b54132d Reviewed-on: https://pdfium-review.googlesource.com/7255 Reviewed-by: Nicolás Peña Reviewed-by: Tom Sepez Commit-Queue: dsinclair --- fpdfsdk/pdfwindow/cpwl_combo_box.cpp | 44 +++++++------------- fpdfsdk/pdfwindow/cpwl_combo_box.h | 6 +-- fpdfsdk/pdfwindow/cpwl_scroll_bar.cpp | 77 ++++++++++++----------------------- fpdfsdk/pdfwindow/cpwl_scroll_bar.h | 7 ++-- fpdfsdk/pdfwindow/cpwl_utils.h | 3 -- fpdfsdk/pdfwindow/cpwl_wnd.cpp | 11 ++--- fpdfsdk/pdfwindow/cpwl_wnd.h | 12 ++---- 7 files changed, 56 insertions(+), 104 deletions(-) diff --git a/fpdfsdk/pdfwindow/cpwl_combo_box.cpp b/fpdfsdk/pdfwindow/cpwl_combo_box.cpp index 3223db1b5f..11a674b41b 100644 --- a/fpdfsdk/pdfwindow/cpwl_combo_box.cpp +++ b/fpdfsdk/pdfwindow/cpwl_combo_box.cpp @@ -33,7 +33,7 @@ bool CPWL_CBListBox::OnLButtonUp(const CFX_PointF& point, uint32_t nFlag) { if (!ClientHitTest(point)) return true; if (CPWL_Wnd* pParent = GetParentWindow()) - pParent->OnNotify(this, PNM_LBUTTONUP, 0, PWL_MAKEDWORD(point.x, point.y)); + pParent->NotifyLButtonUp(this, point); bool bExit = false; OnNotifySelChanged(false, bExit, nFlag); @@ -165,10 +165,8 @@ bool CPWL_CBButton::OnLButtonDown(const CFX_PointF& point, uint32_t nFlag) { SetCapture(); - if (CPWL_Wnd* pParent = GetParentWindow()) { - pParent->OnNotify(this, PNM_LBUTTONDOWN, 0, - PWL_MAKEDWORD(point.x, point.y)); - } + if (CPWL_Wnd* pParent = GetParentWindow()) + pParent->NotifyLButtonDown(this, point); return true; } @@ -548,31 +546,19 @@ bool CPWL_ComboBox::OnChar(uint16_t nChar, uint32_t nFlag) { return m_pList->OnCharWithExit(nChar, bExit, nFlag) ? bExit : false; } -void CPWL_ComboBox::OnNotify(CPWL_Wnd* pWnd, - uint32_t msg, - intptr_t wParam, - intptr_t lParam) { - switch (msg) { - case PNM_LBUTTONDOWN: - if (pWnd == m_pButton) { - SetPopup(!m_bPopup); - return; - } - break; - case PNM_LBUTTONUP: - if (m_pEdit && m_pList) { - if (pWnd == m_pList) { - SetSelectText(); - SelectAll(); - m_pEdit->SetFocus(); - SetPopup(false); - return; - } - } - break; - } +void CPWL_ComboBox::NotifyLButtonDown(CPWL_Wnd* child, const CFX_PointF& pos) { + if (child == m_pButton) + SetPopup(!m_bPopup); +} - CPWL_Wnd::OnNotify(pWnd, msg, wParam, lParam); +void CPWL_ComboBox::NotifyLButtonUp(CPWL_Wnd* child, const CFX_PointF& pos) { + if (!m_pEdit || !m_pList || child != m_pList) + return; + + SetSelectText(); + SelectAll(); + m_pEdit->SetFocus(); + SetPopup(false); } bool CPWL_ComboBox::IsPopup() const { diff --git a/fpdfsdk/pdfwindow/cpwl_combo_box.h b/fpdfsdk/pdfwindow/cpwl_combo_box.h index f8da84ad2e..15915e64b4 100644 --- a/fpdfsdk/pdfwindow/cpwl_combo_box.h +++ b/fpdfsdk/pdfwindow/cpwl_combo_box.h @@ -60,10 +60,8 @@ class CPWL_ComboBox : public CPWL_Wnd { void OnDestroy() override; bool OnKeyDown(uint16_t nChar, uint32_t nFlag) override; bool OnChar(uint16_t nChar, uint32_t nFlag) override; - void OnNotify(CPWL_Wnd* pWnd, - uint32_t msg, - intptr_t wParam = 0, - intptr_t lParam = 0) override; + void NotifyLButtonDown(CPWL_Wnd* child, const CFX_PointF& pos) override; + void NotifyLButtonUp(CPWL_Wnd* child, const CFX_PointF& pos) override; void CreateChildWnd(const PWL_CREATEPARAM& cp) override; void RePosChildWnd() override; CFX_FloatRect GetFocusRect() const override; diff --git a/fpdfsdk/pdfwindow/cpwl_scroll_bar.cpp b/fpdfsdk/pdfwindow/cpwl_scroll_bar.cpp index 94ac2e6178..fdbe8fcb02 100644 --- a/fpdfsdk/pdfwindow/cpwl_scroll_bar.cpp +++ b/fpdfsdk/pdfwindow/cpwl_scroll_bar.cpp @@ -518,7 +518,7 @@ bool CPWL_SBButton::OnLButtonDown(const CFX_PointF& point, uint32_t nFlag) { CPWL_Wnd::OnLButtonDown(point, nFlag); if (CPWL_Wnd* pParent = GetParentWindow()) - pParent->OnNotify(this, PNM_LBUTTONDOWN, 0, (intptr_t)&point); + pParent->NotifyLButtonDown(this, point); m_bMouseDown = true; SetCapture(); @@ -530,7 +530,7 @@ bool CPWL_SBButton::OnLButtonUp(const CFX_PointF& point, uint32_t nFlag) { CPWL_Wnd::OnLButtonUp(point, nFlag); if (CPWL_Wnd* pParent = GetParentWindow()) - pParent->OnNotify(this, PNM_LBUTTONUP, 0, (intptr_t)&point); + pParent->NotifyLButtonUp(this, point); m_bMouseDown = false; ReleaseCapture(); @@ -541,9 +541,8 @@ bool CPWL_SBButton::OnLButtonUp(const CFX_PointF& point, uint32_t nFlag) { bool CPWL_SBButton::OnMouseMove(const CFX_PointF& point, uint32_t nFlag) { CPWL_Wnd::OnMouseMove(point, nFlag); - if (CPWL_Wnd* pParent = GetParentWindow()) { - pParent->OnNotify(this, PNM_MOUSEMOVE, 0, (intptr_t)&point); - } + if (CPWL_Wnd* pParent = GetParentWindow()) + pParent->NotifyMouseMove(this, point); return true; } @@ -774,53 +773,31 @@ void CPWL_ScrollBar::SetScrollPosition(float pos) { SetScrollPos(pos); } -void CPWL_ScrollBar::OnNotify(CPWL_Wnd* pWnd, - uint32_t msg, - intptr_t wParam, - intptr_t lParam) { - CPWL_Wnd::OnNotify(pWnd, msg, wParam, lParam); - - switch (msg) { - case PNM_LBUTTONDOWN: - if (pWnd == m_pMinButton) { - OnMinButtonLBDown(*(CFX_PointF*)lParam); - } - - if (pWnd == m_pMaxButton) { - OnMaxButtonLBDown(*(CFX_PointF*)lParam); - } - - if (pWnd == m_pPosButton) { - OnPosButtonLBDown(*(CFX_PointF*)lParam); - } - break; - case PNM_LBUTTONUP: - if (pWnd == m_pMinButton) { - OnMinButtonLBUp(*(CFX_PointF*)lParam); - } - - if (pWnd == m_pMaxButton) { - OnMaxButtonLBUp(*(CFX_PointF*)lParam); - } - - if (pWnd == m_pPosButton) { - OnPosButtonLBUp(*(CFX_PointF*)lParam); - } - break; - case PNM_MOUSEMOVE: - if (pWnd == m_pMinButton) { - OnMinButtonMouseMove(*(CFX_PointF*)lParam); - } +void CPWL_ScrollBar::NotifyLButtonDown(CPWL_Wnd* child, const CFX_PointF& pos) { + if (child == m_pMinButton) + OnMinButtonLBDown(pos); + else if (child == m_pMaxButton) + OnMaxButtonLBDown(pos); + else if (child == m_pPosButton) + OnPosButtonLBDown(pos); +} - if (pWnd == m_pMaxButton) { - OnMaxButtonMouseMove(*(CFX_PointF*)lParam); - } +void CPWL_ScrollBar::NotifyLButtonUp(CPWL_Wnd* child, const CFX_PointF& pos) { + if (child == m_pMinButton) + OnMinButtonLBUp(pos); + else if (child == m_pMaxButton) + OnMaxButtonLBUp(pos); + else if (child == m_pPosButton) + OnPosButtonLBUp(pos); +} - if (pWnd == m_pPosButton) { - OnPosButtonMouseMove(*(CFX_PointF*)lParam); - } - break; - } +void CPWL_ScrollBar::NotifyMouseMove(CPWL_Wnd* child, const CFX_PointF& pos) { + if (child == m_pMinButton) + OnMinButtonMouseMove(pos); + else if (child == m_pMaxButton) + OnMaxButtonMouseMove(pos); + else if (child == m_pPosButton) + OnPosButtonMouseMove(pos); } void CPWL_ScrollBar::CreateButtons(const PWL_CREATEPARAM& cp) { diff --git a/fpdfsdk/pdfwindow/cpwl_scroll_bar.h b/fpdfsdk/pdfwindow/cpwl_scroll_bar.h index 4aebda6609..d9bf835669 100644 --- a/fpdfsdk/pdfwindow/cpwl_scroll_bar.h +++ b/fpdfsdk/pdfwindow/cpwl_scroll_bar.h @@ -131,12 +131,11 @@ class CPWL_ScrollBar : public CPWL_Wnd { CFX_Matrix* pUser2Device) override; bool OnLButtonDown(const CFX_PointF& point, uint32_t nFlag) override; bool OnLButtonUp(const CFX_PointF& point, uint32_t nFlag) override; - void OnNotify(CPWL_Wnd* pWnd, - uint32_t msg, - intptr_t wParam = 0, - intptr_t lParam = 0) override; void SetScrollInfo(const PWL_SCROLL_INFO& info) override; void SetScrollPosition(float pos) override; + void NotifyLButtonDown(CPWL_Wnd* child, const CFX_PointF& pos) override; + void NotifyLButtonUp(CPWL_Wnd* child, const CFX_PointF& pos) override; + void NotifyMouseMove(CPWL_Wnd* child, const CFX_PointF& pos) override; void CreateChildWnd(const PWL_CREATEPARAM& cp) override; void TimerProc() override; diff --git a/fpdfsdk/pdfwindow/cpwl_utils.h b/fpdfsdk/pdfwindow/cpwl_utils.h index 297eb89b6e..5f039ad77c 100644 --- a/fpdfsdk/pdfwindow/cpwl_utils.h +++ b/fpdfsdk/pdfwindow/cpwl_utils.h @@ -13,9 +13,6 @@ class CFX_Edit; struct CPWL_Color; -#define PWL_MAKEDWORD(low, high) \ - ((uint32_t)((uint16_t)(low) | (uint32_t)(((uint16_t)(high)) << 16))) - // checkbox & radiobutton style #define PCS_CHECK 0 #define PCS_CIRCLE 1 diff --git a/fpdfsdk/pdfwindow/cpwl_wnd.cpp b/fpdfsdk/pdfwindow/cpwl_wnd.cpp index 51c30a5f8c..564c98c9e2 100644 --- a/fpdfsdk/pdfwindow/cpwl_wnd.cpp +++ b/fpdfsdk/pdfwindow/cpwl_wnd.cpp @@ -422,17 +422,18 @@ void CPWL_Wnd::RemoveChild(CPWL_Wnd* pWnd) { } } -void CPWL_Wnd::OnNotify(CPWL_Wnd* pWnd, - uint32_t msg, - intptr_t wParam, - intptr_t lParam) {} - void CPWL_Wnd::SetScrollInfo(const PWL_SCROLL_INFO& info) {} void CPWL_Wnd::SetScrollPosition(float pos) {} void CPWL_Wnd::ScrollWindowVertically(float pos) {} +void CPWL_Wnd::NotifyLButtonDown(CPWL_Wnd* child, const CFX_PointF& pos) {} + +void CPWL_Wnd::NotifyLButtonUp(CPWL_Wnd* child, const CFX_PointF& pos) {} + +void CPWL_Wnd::NotifyMouseMove(CPWL_Wnd* child, const CFX_PointF& pos) {} + bool CPWL_Wnd::IsValid() const { return m_bCreated; } diff --git a/fpdfsdk/pdfwindow/cpwl_wnd.h b/fpdfsdk/pdfwindow/cpwl_wnd.h index 4f378a419b..97c47527a2 100644 --- a/fpdfsdk/pdfwindow/cpwl_wnd.h +++ b/fpdfsdk/pdfwindow/cpwl_wnd.h @@ -73,11 +73,6 @@ struct PWL_SCROLL_INFO; #define PRES_MULTIPAGES 0x0200L #define PRES_TEXTOVERFLOW 0x0400L -// notification messages -#define PNM_LBUTTONDOWN 5 -#define PNM_LBUTTONUP 6 -#define PNM_MOUSEMOVE 7 - #define PWL_CLASSNAME_EDIT "CPWL_Edit" struct CPWL_Dash { @@ -213,13 +208,12 @@ class CPWL_Wnd : public CPWL_TimerHandler { virtual bool OnMouseWheel(short zDelta, const CFX_PointF& point, uint32_t nFlag); - virtual void OnNotify(CPWL_Wnd* pWnd, - uint32_t msg, - intptr_t wParam = 0, - intptr_t lParam = 0); virtual void SetScrollInfo(const PWL_SCROLL_INFO& info); virtual void SetScrollPosition(float pos); virtual void ScrollWindowVertically(float pos); + virtual void NotifyLButtonDown(CPWL_Wnd* child, const CFX_PointF& pos); + virtual void NotifyLButtonUp(CPWL_Wnd* child, const CFX_PointF& pos); + virtual void NotifyMouseMove(CPWL_Wnd* child, const CFX_PointF& pos); virtual void SetFocus(); virtual void KillFocus(); virtual void SetCursor(); -- cgit v1.2.3