From 5d9da0c1255a75dd9b7b2005f8b7d6ae4948feaf Mon Sep 17 00:00:00 2001 From: dsinclair Date: Thu, 21 Apr 2016 13:12:06 -0700 Subject: Remove CFWL_Note. This CL removes the CFWL_Note class. The two subclasses, CFWL_Event and CFWL_Message are distinct types and should not be related by the subclass. The code has been updated to pass the correct types as needed. The various FWL_EVTHASH and FWL_MSGHASH defines have all been removed and turned into an FWL_EventType and FWL_MessageType enum classes. BUG=pdfium:474 Review URL: https://codereview.chromium.org/1901183002 --- xfa/fwl/core/cfwl_event.h | 103 +++++++++++++++++++++---------- xfa/fwl/core/cfwl_message.h | 117 ++++++++++++++++++++++------------- xfa/fwl/core/cfwl_note.h | 67 -------------------- xfa/fwl/core/fwl_formimp.cpp | 60 +++++++++--------- xfa/fwl/core/fwl_noteimp.cpp | 137 +++++++++++++++++++---------------------- xfa/fwl/core/fwl_noteimp.h | 4 +- xfa/fwl/core/fwl_widgetimp.cpp | 22 ++++--- xfa/fwl/core/ifwl_notedriver.h | 3 +- 8 files changed, 260 insertions(+), 253 deletions(-) delete mode 100644 xfa/fwl/core/cfwl_note.h (limited to 'xfa/fwl/core') diff --git a/xfa/fwl/core/cfwl_event.h b/xfa/fwl/core/cfwl_event.h index b2f88802f9..d53fcb36dc 100644 --- a/xfa/fwl/core/cfwl_event.h +++ b/xfa/fwl/core/cfwl_event.h @@ -10,23 +10,42 @@ #include "core/fxcrt/include/fx_coordinates.h" #include "core/fxcrt/include/fx_string.h" #include "core/fxcrt/include/fx_system.h" -#include "xfa/fwl/core/cfwl_note.h" #include "xfa/fwl/core/fwl_error.h" -// TODO(dsinclair): Event hash is hash of string, cleanup. pdfium:474 -#define FWL_EVTHASH_Mouse 1765258002 -#define FWL_EVTHASH_MouseWheel 3907114407 -#define FWL_EVTHASH_Key 2408354450 -#define FWL_EVTHASH_SetFocus 3909721269 -#define FWL_EVTHASH_KillFocus 1779363253 -#define FWL_EVTHASH_Draw 2430713303 -#define FWL_EVTHASH_Click 4026328783 -#define FWL_EVTHASH_Scroll 2965158968 -#define FWL_EVTHASH_Close 4036693599 -#define FWL_EVTHASH_ContextMenu 2717307715 -#define FWL_EVTHASH_MenuCommand 497763741 -#define FWL_EVTHASH_SizeChanged 3083958510 -#define FWL_EVTHASH_Idle 839546759 +enum class CFWL_EventType { + None = 0, + + CheckStateChanged, + CheckWord, + Click, + Close, + CloseUp, + ContextMenu, + DataSelected, + DateChanged, + Draw, + DrawItem, + DropDown, + EditChanged, + GetSuggestedWords, + HoverChanged, + Idle, + Key, + KillFocus, + MenuCommand, + Mouse, + MouseWheel, + PostDropDown, + PreDropDown, + PreSelfAdaption, + Scroll, + SelectChanged, + SetFocus, + SizeChanged, + TextChanged, + TextFull, + Validate +}; typedef enum { FWL_EVENT_MOUSE_MASK = 1 << 0, @@ -44,13 +63,33 @@ typedef enum { class CFX_Graphics; class IFWL_Widget; -class CFWL_Event : public CFWL_Note { +class CFWL_Event { public: - CFWL_Event() : CFWL_Note(TRUE) {} + CFWL_Event() + : m_pSrcTarget(nullptr), m_pDstTarget(nullptr), m_dwRefCount(1) {} virtual ~CFWL_Event() {} + + virtual FWL_ERR GetClassName(CFX_WideString& wsClass) const { + return FWL_ERR_Succeeded; + } + virtual CFWL_EventType GetClassID() const { return CFWL_EventType::None; } + + uint32_t Release() { + m_dwRefCount--; + uint32_t dwRefCount = m_dwRefCount; + if (!m_dwRefCount) + delete this; + return dwRefCount; + } + + IFWL_Widget* m_pSrcTarget; + IFWL_Widget* m_pDstTarget; + + private: + uint32_t m_dwRefCount; }; -#define BEGIN_FWL_EVENT_DEF(classname, eventhashcode) \ +#define BEGIN_FWL_EVENT_DEF(classname, eventType) \ class classname : public CFWL_Event { \ public: \ classname() : CFWL_Event() {} \ @@ -58,20 +97,20 @@ class CFWL_Event : public CFWL_Note { wsClass = L## #classname; \ return FWL_ERR_Succeeded; \ } \ - virtual uint32_t GetClassID() const { return eventhashcode; } + virtual CFWL_EventType GetClassID() const { return eventType; } #define END_FWL_EVENT_DEF \ } \ ; // NOLINT -BEGIN_FWL_EVENT_DEF(CFWL_EvtMouse, FWL_EVTHASH_Mouse) +BEGIN_FWL_EVENT_DEF(CFWL_EvtMouse, CFWL_EventType::Mouse) FX_FLOAT m_fx; FX_FLOAT m_fy; uint32_t m_dwFlags; uint32_t m_dwCmd; END_FWL_EVENT_DEF -BEGIN_FWL_EVENT_DEF(CFWL_EvtMouseWheel, FWL_EVTHASH_MouseWheel) +BEGIN_FWL_EVENT_DEF(CFWL_EvtMouseWheel, CFWL_EventType::MouseWheel) FX_FLOAT m_fx; FX_FLOAT m_fy; FX_FLOAT m_fDeltaX; @@ -79,55 +118,55 @@ FX_FLOAT m_fDeltaY; uint32_t m_dwFlags; END_FWL_EVENT_DEF -BEGIN_FWL_EVENT_DEF(CFWL_EvtKey, FWL_EVTHASH_Key) +BEGIN_FWL_EVENT_DEF(CFWL_EvtKey, CFWL_EventType::Key) uint32_t m_dwKeyCode; uint32_t m_dwFlags; uint32_t m_dwCmd; END_FWL_EVENT_DEF -BEGIN_FWL_EVENT_DEF(CFWL_EvtSetFocus, FWL_EVTHASH_SetFocus) +BEGIN_FWL_EVENT_DEF(CFWL_EvtSetFocus, CFWL_EventType::SetFocus) IFWL_Widget* m_pSetFocus; END_FWL_EVENT_DEF -BEGIN_FWL_EVENT_DEF(CFWL_EvtKillFocus, FWL_EVTHASH_KillFocus) +BEGIN_FWL_EVENT_DEF(CFWL_EvtKillFocus, CFWL_EventType::KillFocus) IFWL_Widget* m_pKillFocus; END_FWL_EVENT_DEF -BEGIN_FWL_EVENT_DEF(CFWL_EvtDraw, FWL_EVTHASH_Draw) +BEGIN_FWL_EVENT_DEF(CFWL_EvtDraw, CFWL_EventType::Draw) CFX_Graphics* m_pGraphics; IFWL_Widget* m_pWidget; END_FWL_EVENT_DEF -BEGIN_FWL_EVENT_DEF(CFWL_EvtClick, FWL_EVTHASH_Click) +BEGIN_FWL_EVENT_DEF(CFWL_EvtClick, CFWL_EventType::Click) END_FWL_EVENT_DEF -BEGIN_FWL_EVENT_DEF(CFWL_EvtScroll, FWL_EVTHASH_Scroll) +BEGIN_FWL_EVENT_DEF(CFWL_EvtScroll, CFWL_EventType::Scroll) uint32_t m_iScrollCode; FX_FLOAT m_fPos; FX_BOOL* m_pRet; END_FWL_EVENT_DEF -BEGIN_FWL_EVENT_DEF(CFWL_EvtClose, FWL_EVTHASH_Close) +BEGIN_FWL_EVENT_DEF(CFWL_EvtClose, CFWL_EventType::Close) END_FWL_EVENT_DEF -BEGIN_FWL_EVENT_DEF(CFWL_EvtContextMenu, FWL_EVTHASH_ContextMenu) +BEGIN_FWL_EVENT_DEF(CFWL_EvtContextMenu, CFWL_EventType::ContextMenu) FX_FLOAT m_fPosX; FX_FLOAT m_fPosY; IFWL_Widget* m_pOwner; END_FWL_EVENT_DEF -BEGIN_FWL_EVENT_DEF(CFWL_EvtMenuCommand, FWL_EVTHASH_MenuCommand) +BEGIN_FWL_EVENT_DEF(CFWL_EvtMenuCommand, CFWL_EventType::MenuCommand) int32_t m_iCommand; void* m_pData; END_FWL_EVENT_DEF -BEGIN_FWL_EVENT_DEF(CFWL_EvtSizeChanged, FWL_EVTHASH_SizeChanged) +BEGIN_FWL_EVENT_DEF(CFWL_EvtSizeChanged, CFWL_EventType::SizeChanged) IFWL_Widget* m_pWidget; CFX_RectF m_rtOld; CFX_RectF m_rtNew; END_FWL_EVENT_DEF -BEGIN_FWL_EVENT_DEF(CFWL_EvtIdle, FWL_EVTHASH_Idle) +BEGIN_FWL_EVENT_DEF(CFWL_EvtIdle, CFWL_EventType::Idle) END_FWL_EVENT_DEF #endif // XFA_FWL_CORE_CFWL_EVENT_H_ diff --git a/xfa/fwl/core/cfwl_message.h b/xfa/fwl/core/cfwl_message.h index 7bd6af1977..e751824bc9 100644 --- a/xfa/fwl/core/cfwl_message.h +++ b/xfa/fwl/core/cfwl_message.h @@ -9,24 +9,27 @@ #include "core/fxcrt/include/fx_string.h" #include "core/fxcrt/include/fx_system.h" -#include "xfa/fwl/core/cfwl_note.h" #include "xfa/fwl/core/fwl_error.h" -#define FWL_MSGHASH_Activate 2410369469 -#define FWL_MSGHASH_Deactivate 1184214790 -#define FWL_MSGHASH_SetFocus 4174512504 -#define FWL_MSGHASH_KillFocus 1557903832 -#define FWL_MSGHASH_Mouse 706128309 -#define FWL_MSGHASH_MouseWheel 893703466 -#define FWL_MSGHASH_Key 3751372405 -#define FWL_MSGHASH_Cursor 3182626218 -#define FWL_MSGHASH_Size 160077735 -#define FWL_MSGHASH_WindowMove 1032269377 -#define FWL_MSGHASH_DropFiles 2004165236 -#define FWL_MSGHASH_TaskClicked 3128231086 -#define FWL_MSGHASH_Close 2977563906 -#define FWL_MSGHASH_Post 1969633074 -#define FWL_MSGHASH_WindowWillMove 2229175763 +enum class CFWL_MessageType { + None = 0, + + Activate, + Close, + Cursor, + Deactivate, + DropFiles, + Key, + KillFocus, + Mouse, + MouseWheel, + Post, + SetFocus, + Size, + TaskClicked, + WindowMove, + WindowWillMove +}; #define FWL_MSG_Activate L"FWL_MESSAGE_Activate" #define FWL_MSG_Deactivate L"FWL_MESSAGE_Deactivate" @@ -63,41 +66,71 @@ class IFWL_Widget; -class CFWL_Message : public CFWL_Note { +class CFWL_Message { public: - CFWL_Message() : CFWL_Note(FALSE) {} + CFWL_Message() + : m_pSrcTarget(nullptr), + m_pDstTarget(nullptr), + m_dwExtend(0), + m_dwRefCount(1) {} virtual ~CFWL_Message() {} + + virtual CFWL_Message* Clone() { return nullptr; } + virtual FWL_ERR GetClassName(CFX_WideString& wsClass) const { + return FWL_ERR_Succeeded; + } + virtual CFWL_MessageType GetClassID() const { return CFWL_MessageType::None; } + + uint32_t Release() { + m_dwRefCount--; + uint32_t dwRefCount = m_dwRefCount; + if (!m_dwRefCount) + delete this; + return dwRefCount; + } + + CFWL_Message* Retain() { + m_dwRefCount++; + return this; + } + + IFWL_Widget* m_pSrcTarget; + IFWL_Widget* m_pDstTarget; + uint32_t m_dwExtend; + + private: + uint32_t m_dwRefCount; }; -#define BEGIN_FWL_MESSAGE_DEF(classname, msghashcode) \ - class classname : public CFWL_Message { \ - public: \ - classname() : CFWL_Message() {} \ - virtual CFWL_Note* Clone() { return new classname(*this); } \ - virtual FWL_ERR GetClassName(CFX_WideString& wsClass) const { \ - wsClass = L## #classname; \ - return FWL_ERR_Succeeded; \ - } \ - virtual uint32_t GetClassID() const { return msghashcode; } +#define BEGIN_FWL_MESSAGE_DEF(classname, msgType) \ + class classname : public CFWL_Message { \ + public: \ + classname() : CFWL_Message() {} \ + CFWL_Message* Clone() override { return new classname(*this); } \ + FWL_ERR GetClassName(CFX_WideString& wsClass) const override { \ + wsClass = L## #classname; \ + return FWL_ERR_Succeeded; \ + } \ + CFWL_MessageType GetClassID() const override { return msgType; } #define END_FWL_MESSAGE_DEF \ } \ ; // NOLINT -BEGIN_FWL_MESSAGE_DEF(CFWL_MsgActivate, FWL_MSGHASH_Activate) +BEGIN_FWL_MESSAGE_DEF(CFWL_MsgActivate, CFWL_MessageType::Activate) END_FWL_MESSAGE_DEF -BEGIN_FWL_MESSAGE_DEF(CFWL_MsgDeactivate, FWL_MSGHASH_Deactivate) +BEGIN_FWL_MESSAGE_DEF(CFWL_MsgDeactivate, CFWL_MessageType::Deactivate) END_FWL_MESSAGE_DEF -BEGIN_FWL_MESSAGE_DEF(CFWL_MsgMouse, FWL_MSGHASH_Mouse) +BEGIN_FWL_MESSAGE_DEF(CFWL_MsgMouse, CFWL_MessageType::Mouse) FX_FLOAT m_fx; FX_FLOAT m_fy; uint32_t m_dwFlags; uint32_t m_dwCmd; END_FWL_MESSAGE_DEF -BEGIN_FWL_MESSAGE_DEF(CFWL_MsgMouseWheel, FWL_MSGHASH_MouseWheel) +BEGIN_FWL_MESSAGE_DEF(CFWL_MsgMouseWheel, CFWL_MessageType::MouseWheel) FX_FLOAT m_fx; FX_FLOAT m_fy; FX_FLOAT m_fDeltaX; @@ -105,34 +138,34 @@ FX_FLOAT m_fDeltaY; uint32_t m_dwFlags; END_FWL_MESSAGE_DEF -BEGIN_FWL_MESSAGE_DEF(CFWL_MsgSetFocus, FWL_MSGHASH_SetFocus) +BEGIN_FWL_MESSAGE_DEF(CFWL_MsgSetFocus, CFWL_MessageType::SetFocus) IFWL_Widget* m_pKillFocus; END_FWL_MESSAGE_DEF -BEGIN_FWL_MESSAGE_DEF(CFWL_MsgKillFocus, FWL_MSGHASH_KillFocus) +BEGIN_FWL_MESSAGE_DEF(CFWL_MsgKillFocus, CFWL_MessageType::KillFocus) IFWL_Widget* m_pSetFocus; END_FWL_MESSAGE_DEF -BEGIN_FWL_MESSAGE_DEF(CFWL_MsgKey, FWL_MSGHASH_Key) +BEGIN_FWL_MESSAGE_DEF(CFWL_MsgKey, CFWL_MessageType::Key) uint32_t m_dwKeyCode; uint32_t m_dwFlags; uint32_t m_dwCmd; END_FWL_MESSAGE_DEF -BEGIN_FWL_MESSAGE_DEF(CFWL_MsgCursor, FWL_MSGHASH_Cursor) +BEGIN_FWL_MESSAGE_DEF(CFWL_MsgCursor, CFWL_MessageType::Cursor) END_FWL_MESSAGE_DEF -BEGIN_FWL_MESSAGE_DEF(CFWL_MsgSize, FWL_MSGHASH_Size) +BEGIN_FWL_MESSAGE_DEF(CFWL_MsgSize, CFWL_MessageType::Size) int32_t m_iWidth; int32_t m_iHeight; END_FWL_MESSAGE_DEF -BEGIN_FWL_MESSAGE_DEF(CFWL_MsgWindowMove, FWL_MSGHASH_WindowMove) +BEGIN_FWL_MESSAGE_DEF(CFWL_MsgWindowMove, CFWL_MessageType::WindowMove) FX_FLOAT m_fx; FX_FLOAT m_fy; END_FWL_MESSAGE_DEF -BEGIN_FWL_MESSAGE_DEF(CFWL_MsgDropFiles, FWL_MSGHASH_DropFiles) +BEGIN_FWL_MESSAGE_DEF(CFWL_MsgDropFiles, CFWL_MessageType::DropFiles) CFWL_MsgDropFiles(const CFWL_MsgDropFiles& copy) { m_pDstTarget = copy.m_pDstTarget; m_pSrcTarget = copy.m_pSrcTarget; @@ -145,15 +178,15 @@ FX_FLOAT m_fy; CFX_WideStringArray m_files; END_FWL_MESSAGE_DEF -BEGIN_FWL_MESSAGE_DEF(CFWL_MsgTaskClicked, FWL_MSGHASH_TaskClicked) +BEGIN_FWL_MESSAGE_DEF(CFWL_MsgTaskClicked, CFWL_MessageType::TaskClicked) FX_FLOAT m_fx; FX_FLOAT m_fy; END_FWL_MESSAGE_DEF -BEGIN_FWL_MESSAGE_DEF(CFWL_MsgClose, FWL_MSGHASH_Close) +BEGIN_FWL_MESSAGE_DEF(CFWL_MsgClose, CFWL_MessageType::Close) END_FWL_MESSAGE_DEF -BEGIN_FWL_MESSAGE_DEF(CFWL_MsgWindowWillMove, FWL_MSGHASH_WindowWillMove) +BEGIN_FWL_MESSAGE_DEF(CFWL_MsgWindowWillMove, CFWL_MessageType::WindowWillMove) END_FWL_MESSAGE_DEF #endif // XFA_FWL_CORE_CFWL_MESSAGE_H_ diff --git a/xfa/fwl/core/cfwl_note.h b/xfa/fwl/core/cfwl_note.h deleted file mode 100644 index d173dc6f76..0000000000 --- a/xfa/fwl/core/cfwl_note.h +++ /dev/null @@ -1,67 +0,0 @@ -// Copyright 2016 PDFium Authors. All rights reserved. -// Use of this source code is governed by a BSD-style license that can be -// found in the LICENSE file. - -// Original code copyright 2014 Foxit Software Inc. http://www.foxitsoftware.com - -#ifndef XFA_FWL_CORE_CFWL_NOTE_H_ -#define XFA_FWL_CORE_CFWL_NOTE_H_ - -#include "core/fxcrt/include/fx_string.h" -#include "core/fxcrt/include/fx_system.h" -#include "xfa/fwl/core/fwl_error.h" - -class IFWL_Widget; - -// Separate hierarchy not related to IFWL_* hierarchy. These should not -// get cast to IFWL_* types. -class CFWL_Note { - public: - virtual uint32_t Release() { - m_dwRefCount--; - uint32_t dwRefCount = m_dwRefCount; - if (!m_dwRefCount) - delete this; - return dwRefCount; - } - - virtual CFWL_Note* Retain() { - m_dwRefCount++; - return this; - } - - virtual FWL_ERR GetClassName(CFX_WideString& wsClass) const { - wsClass = L"CFWL_Note"; - return FWL_ERR_Succeeded; - } - - virtual uint32_t GetClassID() const { return 0; } - - virtual FX_BOOL IsInstance(const CFX_WideStringC& wsClass) const { - return TRUE; - } - - virtual CFWL_Note* Clone() { return NULL; } - FX_BOOL IsEvent() const { return m_bIsEvent; } - - IFWL_Widget* m_pSrcTarget; - IFWL_Widget* m_pDstTarget; - uint32_t m_dwExtend; - - protected: - CFWL_Note(FX_BOOL bIsEvent) - : m_pSrcTarget(NULL), - m_pDstTarget(NULL), - m_dwExtend(0), - m_dwRefCount(1), - m_bIsEvent(bIsEvent) {} - - virtual ~CFWL_Note() {} - virtual FX_BOOL Initialize() { return TRUE; } - virtual int32_t Finalize() { return 0; } - - uint32_t m_dwRefCount; - FX_BOOL m_bIsEvent; -}; - -#endif // XFA_FWL_CORE_CFWL_NOTE_H_ diff --git a/xfa/fwl/core/fwl_formimp.cpp b/xfa/fwl/core/fwl_formimp.cpp index 338c55fee1..ad3c173590 100644 --- a/xfa/fwl/core/fwl_formimp.cpp +++ b/xfa/fwl/core/fwl_formimp.cpp @@ -856,20 +856,25 @@ void CFWL_FormImp::DoHeightLimit(FX_FLOAT& fTop, } } } + CFWL_FormImpDelegate::CFWL_FormImpDelegate(CFWL_FormImp* pOwner) : m_pOwner(pOwner) {} + int32_t CFWL_FormImpDelegate::OnProcessMessage(CFWL_Message* pMessage) { -#ifdef FWL_UseMacSystemBorder if (!pMessage) return 0; - uint32_t dwMsgCode = pMessage->GetClassID(); + + CFWL_MessageType dwMsgCode = pMessage->GetClassID(); + +#ifdef FWL_UseMacSystemBorder + switch (dwMsgCode) { - case FWL_MSGHASH_Activate: { + case CFWL_MessageType::Activate: { m_pOwner->m_pProperties->m_dwStates &= ~FWL_WGTSTATE_Deactivated; m_pOwner->Repaint(&m_pOwner->m_rtRelative); break; } - case FWL_MSGHASH_Deactivate: { + case CFWL_MessageType::Deactivate: { m_pOwner->m_pProperties->m_dwStates |= FWL_WGTSTATE_Deactivated; m_pOwner->Repaint(&m_pOwner->m_rtRelative); break; @@ -877,48 +882,44 @@ int32_t CFWL_FormImpDelegate::OnProcessMessage(CFWL_Message* pMessage) { } return FWL_ERR_Succeeded; #else - if (!pMessage) - return 0; - uint32_t dwMsgCode = pMessage->GetClassID(); int32_t iRet = 1; switch (dwMsgCode) { - case FWL_MSGHASH_Activate: { + case CFWL_MessageType::Activate: { m_pOwner->m_pProperties->m_dwStates &= ~FWL_WGTSTATE_Deactivated; IFWL_Thread* pThread = m_pOwner->GetOwnerThread(); CFWL_NoteDriver* pDriver = static_cast(pThread->GetNoteDriver()); CFWL_WidgetImp* pSubFocusImp = m_pOwner->GetSubFocus(); IFWL_Widget* pSubFocus = - pSubFocusImp ? pSubFocusImp->GetInterface() : NULL; - if (pSubFocus && pSubFocus != pDriver->GetFocus()) { + pSubFocusImp ? pSubFocusImp->GetInterface() : nullptr; + if (pSubFocus && pSubFocus != pDriver->GetFocus()) pDriver->SetFocus(pSubFocus); - } + m_pOwner->Repaint(&m_pOwner->m_rtRelative); break; } - case FWL_MSGHASH_Deactivate: { + case CFWL_MessageType::Deactivate: { m_pOwner->m_pProperties->m_dwStates |= FWL_WGTSTATE_Deactivated; IFWL_Thread* pThread = m_pOwner->GetOwnerThread(); CFWL_NoteDriver* pDriver = static_cast(pThread->GetNoteDriver()); CFWL_WidgetImp* pSubFocusImp = m_pOwner->GetSubFocus(); IFWL_Widget* pSubFocus = - pSubFocusImp ? pSubFocusImp->GetInterface() : NULL; + pSubFocusImp ? pSubFocusImp->GetInterface() : nullptr; if (pSubFocus) { if (pSubFocus == pDriver->GetFocus()) { - pDriver->SetFocus(NULL); + pDriver->SetFocus(nullptr); } else if (pSubFocus->GetStates() & FWL_WGTSTATE_Focused) { CFWL_MsgKillFocus ms; - IFWL_WidgetDelegate* pDelegate = pSubFocus->SetDelegate(NULL); - if (pDelegate) { + IFWL_WidgetDelegate* pDelegate = pSubFocus->SetDelegate(nullptr); + if (pDelegate) pDelegate->OnProcessMessage(&ms); - } } } m_pOwner->Repaint(&m_pOwner->m_rtRelative); break; } - case FWL_MSGHASH_Mouse: { + case CFWL_MessageType::Mouse: { CFWL_MsgMouse* pMsg = static_cast(pMessage); switch (pMsg->m_dwCmd) { case FWL_MSGMOUSECMD_LButtonDown: { @@ -948,15 +949,16 @@ int32_t CFWL_FormImpDelegate::OnProcessMessage(CFWL_Message* pMessage) { } break; } - case FWL_MSGHASH_Size: { + case CFWL_MessageType::Size: { CFWL_WidgetMgr* pWidgetMgr = static_cast(FWL_GetWidgetMgr()); if (!pWidgetMgr) return 0; + pWidgetMgr->AddRedrawCounts(m_pOwner->m_pInterface); - if (!m_pOwner->m_bSetMaximize) { + if (!m_pOwner->m_bSetMaximize) break; - } + m_pOwner->m_bSetMaximize = FALSE; CFWL_MsgSize* pMsg = static_cast(pMessage); CFX_RectF rt; @@ -968,27 +970,29 @@ int32_t CFWL_FormImpDelegate::OnProcessMessage(CFWL_Message* pMessage) { m_pOwner->Update(); break; } - case FWL_MSGHASH_WindowMove: { + case CFWL_MessageType::WindowMove: { OnWindowMove(static_cast(pMessage)); break; } - case FWL_MSGHASH_Close: { + case CFWL_MessageType::Close: { OnClose(static_cast(pMessage)); break; } - default: { iRet = 0; } + default: { + iRet = 0; + break; + } } return iRet; -#endif +#endif // FWL_UseMacSystemBorder } + FWL_ERR CFWL_FormImpDelegate::OnProcessEvent(CFWL_Event* pEvent) { if (!pEvent) return FWL_ERR_Indefinite; - if (pEvent->GetClassID() == FWL_EVTHASH_Close && - pEvent->m_pSrcTarget == m_pOwner->m_pInterface) { - } return FWL_ERR_Succeeded; } + FWL_ERR CFWL_FormImpDelegate::OnDrawWidget(CFX_Graphics* pGraphics, const CFX_Matrix* pMatrix) { return m_pOwner->DrawWidget(pGraphics, pMatrix); diff --git a/xfa/fwl/core/fwl_noteimp.cpp b/xfa/fwl/core/fwl_noteimp.cpp index a01eea9138..b2e7440761 100644 --- a/xfa/fwl/core/fwl_noteimp.cpp +++ b/xfa/fwl/core/fwl_noteimp.cpp @@ -34,7 +34,7 @@ FWL_ERR CFWL_NoteLoop::Idle(int32_t count) { IFWL_NoteDriver* pDriver = pApp->GetNoteDriver(); if (!pDriver) return FWL_ERR_Indefinite; - pDriver->SendNote(&ev); + pDriver->SendEvent(&ev); #if (_FX_OS_ == _FX_WIN32_DESKTOP_) } #endif @@ -69,7 +69,7 @@ void CFWL_NoteLoop::GenerateCommondEvent(uint32_t dwCommand) { IFWL_NoteDriver* pDriver = pThread->GetNoteDriver(); if (!pDriver) return; - pDriver->SendNote(&ev); + pDriver->SendEvent(&ev); } CFWL_NoteDriver::CFWL_NoteDriver() : m_sendEventCalled(0), @@ -83,47 +83,37 @@ CFWL_NoteDriver::~CFWL_NoteDriver() { delete m_pNoteLoop; ClearInvalidEventTargets(TRUE); } -FX_BOOL CFWL_NoteDriver::SendNote(CFWL_Note* pNote) { - if (pNote->IsEvent()) { - int32_t iCount = m_eventTargets.GetCount(); - if (iCount < 1) { - return TRUE; - } - if (FWL_EVTHASH_Mouse == static_cast(pNote)->GetClassID()) { - CFWL_EvtMouse* pMouse = static_cast(pNote); - if (FWL_MSGMOUSECMD_MouseHover == pMouse->m_dwCmd) { - if (m_pNoteLoop->GetForm() && - CFWL_ToolTipContainer::getInstance()->ProcessEnter( - pMouse, m_pNoteLoop->GetForm()->GetInterface())) { - } - } else if (FWL_MSGMOUSECMD_MouseLeave == pMouse->m_dwCmd) { - if (CFWL_ToolTipContainer::getInstance()->ProcessLeave(pMouse)) { - } - } else if ((FWL_MSGMOUSECMD_LButtonDown <= pMouse->m_dwCmd) && - (FWL_MSGMOUSECMD_MButtonDblClk >= pMouse->m_dwCmd)) { - if (CFWL_ToolTipContainer::getInstance()->ProcessLeave(pMouse)) { - } - } - } - m_sendEventCalled++; - FX_POSITION pos = m_eventTargets.GetStartPosition(); - while (pos) { - void* key = NULL; - CFWL_EventTarget* pEventTarget; - m_eventTargets.GetNextAssoc(pos, key, (void*&)pEventTarget); - if (pEventTarget && !pEventTarget->IsInvalid()) { - pEventTarget->ProcessEvent(static_cast(pNote)); + +FX_BOOL CFWL_NoteDriver::SendEvent(CFWL_Event* pNote) { + int32_t iCount = m_eventTargets.GetCount(); + if (iCount < 1) + return TRUE; + if (CFWL_EventType::Mouse == pNote->GetClassID()) { + CFWL_EvtMouse* pMouse = static_cast(pNote); + if (FWL_MSGMOUSECMD_MouseHover == pMouse->m_dwCmd) { + if (m_pNoteLoop->GetForm() && + CFWL_ToolTipContainer::getInstance()->ProcessEnter( + pMouse, m_pNoteLoop->GetForm()->GetInterface())) { } - } - m_sendEventCalled--; - } else { - if (!pNote->m_pDstTarget) - return FALSE; - IFWL_WidgetDelegate* pDelegate = pNote->m_pDstTarget->SetDelegate(NULL); - if (pDelegate) { - pDelegate->OnProcessMessage(static_cast(pNote)); + } else if (FWL_MSGMOUSECMD_MouseLeave == pMouse->m_dwCmd) { + CFWL_ToolTipContainer::getInstance()->ProcessLeave(pMouse); + } else if ((FWL_MSGMOUSECMD_LButtonDown <= pMouse->m_dwCmd) && + (FWL_MSGMOUSECMD_MButtonDblClk >= pMouse->m_dwCmd)) { + CFWL_ToolTipContainer::getInstance()->ProcessLeave(pMouse); } } + m_sendEventCalled++; + FX_POSITION pos = m_eventTargets.GetStartPosition(); + while (pos) { + void* key = nullptr; + void* value = nullptr; + m_eventTargets.GetNextAssoc(pos, key, value); + + CFWL_EventTarget* pEventTarget = static_cast(value); + if (pEventTarget && !pEventTarget->IsInvalid()) + pEventTarget->ProcessEvent(pNote); + } + m_sendEventCalled--; return TRUE; } @@ -390,61 +380,61 @@ FX_BOOL CFWL_NoteDriver::ProcessMessage(CFWL_Message* pMessage) { if (!pMessageForm) return FALSE; if (DispatchMessage(pMessage, pMessageForm)) { - if (pMessage->GetClassID() == FWL_MSGHASH_Mouse) { + if (pMessage->GetClassID() == CFWL_MessageType::Mouse) MouseSecondary(static_cast(pMessage)); - } return TRUE; } return FALSE; } + FX_BOOL CFWL_NoteDriver::DispatchMessage(CFWL_Message* pMessage, IFWL_Widget* pMessageForm) { FX_BOOL bRet = FALSE; switch (pMessage->GetClassID()) { - case FWL_MSGHASH_Activate: { + case CFWL_MessageType::Activate: { bRet = DoActivate(static_cast(pMessage), pMessageForm); break; } - case FWL_MSGHASH_Deactivate: { + case CFWL_MessageType::Deactivate: { bRet = DoDeactivate(static_cast(pMessage), pMessageForm); break; } - case FWL_MSGHASH_SetFocus: { + case CFWL_MessageType::SetFocus: { bRet = DoSetFocus(static_cast(pMessage), pMessageForm); break; } - case FWL_MSGHASH_KillFocus: { + case CFWL_MessageType::KillFocus: { bRet = DoKillFocus(static_cast(pMessage), pMessageForm); break; } - case FWL_MSGHASH_Key: { + case CFWL_MessageType::Key: { bRet = DoKey(static_cast(pMessage), pMessageForm); break; } - case FWL_MSGHASH_Mouse: { + case CFWL_MessageType::Mouse: { bRet = DoMouse(static_cast(pMessage), pMessageForm); break; } - case FWL_MSGHASH_MouseWheel: { + case CFWL_MessageType::MouseWheel: { bRet = DoWheel(static_cast(pMessage), pMessageForm); break; } - case FWL_MSGHASH_Size: { + case CFWL_MessageType::Size: { bRet = DoSize(static_cast(pMessage)); break; } - case FWL_MSGHASH_Cursor: { + case CFWL_MessageType::Cursor: { bRet = TRUE; break; } - case FWL_MSGHASH_WindowMove: { + case CFWL_MessageType::WindowMove: { bRet = DoWindowMove(static_cast(pMessage), pMessageForm); break; } - case FWL_MSGHASH_DropFiles: { + case CFWL_MessageType::DropFiles: { bRet = DoDragFiles(static_cast(pMessage), pMessageForm); break; @@ -456,12 +446,12 @@ FX_BOOL CFWL_NoteDriver::DispatchMessage(CFWL_Message* pMessage, } if (bRet) { IFWL_WidgetDelegate* pDelegate = pMessage->m_pDstTarget->SetDelegate(NULL); - if (pDelegate) { + if (pDelegate) pDelegate->OnProcessMessage(pMessage); - } } return bRet; } + FX_BOOL CFWL_NoteDriver::DoActivate(CFWL_MsgActivate* pMsg, IFWL_Widget* pMessageForm) { pMsg->m_pDstTarget = pMessageForm; @@ -686,26 +676,25 @@ void CFWL_NoteDriver::MouseSecondary(CFWL_MsgMouse* pMsg) { DispatchMessage(&msHover, NULL); } FX_BOOL CFWL_NoteDriver::IsValidMessage(CFWL_Message* pMessage) { - if (pMessage->GetClassID() == FWL_MSGHASH_Post) { + if (pMessage->GetClassID() == CFWL_MessageType::Post) return TRUE; - } + int32_t iCount = m_noteLoopQueue.GetSize(); for (int32_t i = 0; i < iCount; i++) { CFWL_NoteLoop* pNoteLoop = static_cast(m_noteLoopQueue[i]); CFWL_WidgetImp* pForm = pNoteLoop->GetForm(); - if (pForm && (pForm->GetInterface() == pMessage->m_pDstTarget)) { + if (pForm && (pForm->GetInterface() == pMessage->m_pDstTarget)) return TRUE; - } } iCount = m_forms.GetSize(); for (int32_t j = 0; j < iCount; j++) { CFWL_FormImp* pForm = static_cast(m_forms[j]); - if (pForm->GetInterface() == pMessage->m_pDstTarget) { + if (pForm->GetInterface() == pMessage->m_pDstTarget) return TRUE; - } } return FALSE; } + IFWL_Widget* CFWL_NoteDriver::GetMessageForm(IFWL_Widget* pDstTarget) { int32_t iTrackLoop = m_noteLoopQueue.GetSize(); if (iTrackLoop <= 0) @@ -791,6 +780,7 @@ int32_t CFWL_EventTarget::SetEventSource(IFWL_Widget* pSource, } return 1; } + FX_BOOL CFWL_EventTarget::ProcessEvent(CFWL_Event* pEvent) { IFWL_WidgetDelegate* pDelegate = m_pListener->SetDelegate(NULL); if (!pDelegate) @@ -805,7 +795,7 @@ FX_BOOL CFWL_EventTarget::ProcessEvent(CFWL_Event* pEvent) { uint32_t dwFilter = 0; m_eventSources.GetNextAssoc(pos, (void*&)pSource, dwFilter); if (pSource == pEvent->m_pSrcTarget || - pEvent->GetClassID() == FWL_EVTHASH_Idle) { + pEvent->GetClassID() == CFWL_EventType::Idle) { if (IsFilterEvent(pEvent, dwFilter)) { pDelegate->OnProcessEvent(pEvent); return TRUE; @@ -814,42 +804,43 @@ FX_BOOL CFWL_EventTarget::ProcessEvent(CFWL_Event* pEvent) { } return FALSE; } + FX_BOOL CFWL_EventTarget::IsFilterEvent(CFWL_Event* pEvent, uint32_t dwFilter) { - if (dwFilter == FWL_EVENT_ALL_MASK) { + if (dwFilter == FWL_EVENT_ALL_MASK) return TRUE; - } + FX_BOOL bRet = FALSE; switch (pEvent->GetClassID()) { - case FWL_EVTHASH_Mouse: { + case CFWL_EventType::Mouse: { bRet = dwFilter & FWL_EVENT_MOUSE_MASK; break; } - case FWL_EVTHASH_MouseWheel: { + case CFWL_EventType::MouseWheel: { bRet = dwFilter & FWL_EVENT_MOUSEWHEEL_MASK; break; } - case FWL_EVTHASH_Key: { + case CFWL_EventType::Key: { bRet = dwFilter & FWL_EVENT_KEY_MASK; break; } - case FWL_EVTHASH_SetFocus: - case FWL_EVTHASH_KillFocus: { + case CFWL_EventType::SetFocus: + case CFWL_EventType::KillFocus: { bRet = dwFilter & FWL_EVENT_FOCUSCHANGED_MASK; break; } - case FWL_EVTHASH_Draw: { + case CFWL_EventType::Draw: { bRet = dwFilter & FWL_EVENT_DRAW_MASK; break; } - case FWL_EVTHASH_Close: { + case CFWL_EventType::Close: { bRet = dwFilter & FWL_EVENT_CLOSE_MASK; break; } - case FWL_EVTHASH_SizeChanged: { + case CFWL_EventType::SizeChanged: { bRet = dwFilter & FWL_EVENT_SIZECHANGED_MASK; break; } - case FWL_EVTHASH_Idle: { + case CFWL_EventType::Idle: { bRet = dwFilter & FWL_EVENT_IDLE_MASK; break; } diff --git a/xfa/fwl/core/fwl_noteimp.h b/xfa/fwl/core/fwl_noteimp.h index 0a0c8424e8..334c70535b 100644 --- a/xfa/fwl/core/fwl_noteimp.h +++ b/xfa/fwl/core/fwl_noteimp.h @@ -52,9 +52,9 @@ class CFWL_NoteDriver : public IFWL_NoteDriver { ~CFWL_NoteDriver() override; // IFWL_NoteDriver: - FX_BOOL SendNote(CFWL_Note* pNote) override; + FX_BOOL SendEvent(CFWL_Event* pNote) override; FWL_ERR RegisterEventTarget(IFWL_Widget* pListener, - IFWL_Widget* pEventSource = NULL, + IFWL_Widget* pEventSource = nullptr, uint32_t dwFilter = FWL_EVENT_ALL_MASK) override; FWL_ERR UnregisterEventTarget(IFWL_Widget* pListener) override; void ClearEventTargets(FX_BOOL bRemoveAll) override; diff --git a/xfa/fwl/core/fwl_widgetimp.cpp b/xfa/fwl/core/fwl_widgetimp.cpp index b11530eab5..f6be8cac5e 100644 --- a/xfa/fwl/core/fwl_widgetimp.cpp +++ b/xfa/fwl/core/fwl_widgetimp.cpp @@ -853,7 +853,7 @@ void CFWL_WidgetImp::DispatchEvent(CFWL_Event* pEvent) { IFWL_NoteDriver* pNoteDriver = pThread->GetNoteDriver(); if (!pNoteDriver) return; - pNoteDriver->SendNote(pEvent); + pNoteDriver->SendEvent(pEvent); } void CFWL_WidgetImp::Repaint(const CFX_RectF* pRect) { if (pRect) { @@ -952,15 +952,18 @@ FX_BOOL CFWL_WidgetImp::IsParent(IFWL_Widget* pParent) { } return FALSE; } + CFWL_WidgetImpDelegate::CFWL_WidgetImpDelegate() {} + int32_t CFWL_WidgetImpDelegate::OnProcessMessage(CFWL_Message* pMessage) { if (!pMessage->m_pDstTarget) return 0; + CFWL_WidgetImp* pWidget = static_cast(pMessage->m_pDstTarget->GetImpl()); - uint32_t dwMsgCode = pMessage->GetClassID(); + CFWL_MessageType dwMsgCode = pMessage->GetClassID(); switch (dwMsgCode) { - case FWL_MSGHASH_Mouse: { + case CFWL_MessageType::Mouse: { CFWL_MsgMouse* pMsgMouse = static_cast(pMessage); CFWL_EvtMouse evt; evt.m_pSrcTarget = pWidget->m_pInterface; @@ -972,7 +975,7 @@ int32_t CFWL_WidgetImpDelegate::OnProcessMessage(CFWL_Message* pMessage) { pWidget->DispatchEvent(&evt); break; } - case FWL_MSGHASH_MouseWheel: { + case CFWL_MessageType::MouseWheel: { CFWL_MsgMouseWheel* pMsgMouseWheel = static_cast(pMessage); CFWL_EvtMouseWheel evt; @@ -986,7 +989,7 @@ int32_t CFWL_WidgetImpDelegate::OnProcessMessage(CFWL_Message* pMessage) { pWidget->DispatchEvent(&evt); break; } - case FWL_MSGHASH_Key: { + case CFWL_MessageType::Key: { CFWL_MsgKey* pMsgKey = static_cast(pMessage); CFWL_EvtKey evt; evt.m_pSrcTarget = pWidget->m_pInterface; @@ -997,7 +1000,7 @@ int32_t CFWL_WidgetImpDelegate::OnProcessMessage(CFWL_Message* pMessage) { pWidget->DispatchEvent(&evt); break; } - case FWL_MSGHASH_SetFocus: { + case CFWL_MessageType::SetFocus: { CFWL_MsgSetFocus* pMsgSetFocus = static_cast(pMessage); CFWL_EvtSetFocus evt; evt.m_pSrcTarget = pMsgSetFocus->m_pDstTarget; @@ -1006,7 +1009,7 @@ int32_t CFWL_WidgetImpDelegate::OnProcessMessage(CFWL_Message* pMessage) { pWidget->DispatchEvent(&evt); break; } - case FWL_MSGHASH_KillFocus: { + case CFWL_MessageType::KillFocus: { CFWL_MsgKillFocus* pMsgKillFocus = static_cast(pMessage); CFWL_EvtKillFocus evt; @@ -1016,13 +1019,16 @@ int32_t CFWL_WidgetImpDelegate::OnProcessMessage(CFWL_Message* pMessage) { pWidget->DispatchEvent(&evt); break; } - default: {} + default: + break; } return 1; } + FWL_ERR CFWL_WidgetImpDelegate::OnProcessEvent(CFWL_Event* pEvent) { return FWL_ERR_Succeeded; } + FWL_ERR CFWL_WidgetImpDelegate::OnDrawWidget(CFX_Graphics* pGraphics, const CFX_Matrix* pMatrix) { CFWL_EvtDraw evt; diff --git a/xfa/fwl/core/ifwl_notedriver.h b/xfa/fwl/core/ifwl_notedriver.h index 783bebcd10..4bf265593c 100644 --- a/xfa/fwl/core/ifwl_notedriver.h +++ b/xfa/fwl/core/ifwl_notedriver.h @@ -29,7 +29,8 @@ class IFWL_NoteDriver { public: virtual ~IFWL_NoteDriver() {} - virtual FX_BOOL SendNote(CFWL_Note* pNote) = 0; + virtual FX_BOOL SendEvent(CFWL_Event* pNote) = 0; + virtual FWL_ERR RegisterEventTarget( IFWL_Widget* pListener, IFWL_Widget* pEventSource = NULL, -- cgit v1.2.3