1 // Copyright 2014 PDFium Authors. All rights reserved. 2 // Use of this source code is governed by a BSD-style license that can be 3 // found in the LICENSE file. 4 5 // Original code copyright 2014 Foxit Software Inc. http://www.foxitsoftware.com 6 7 #ifndef _FWL_NOTE_IMP_H 8 #define _FWL_NOTE_IMP_H 9 10 #include "xfa/include/fwl/core/fwl_note.h" 11 12 class CFWL_TargetImp; 13 class CFWL_WidgetImp; 14 class CFWL_NoteThreadImp; 15 class CFWL_ToolTipImp; 16 class CFWL_CoreToopTipDP; 17 class CFWL_NoteDriver; 18 class CFWL_EventTarget; 19 class CFWL_ToolTipContainer; 20 21 class CFWL_NoteLoop : public IFWL_NoteLoop { 22 public: 23 CFWL_NoteLoop(CFWL_WidgetImp* pForm = NULL); 24 25 // IFWL_NoteLoop: 26 ~CFWL_NoteLoop() override {} 27 FX_BOOL PreProcessMessage(CFWL_Message* pMessage) override; 28 FWL_ERR Idle(int32_t count) override; 29 30 CFWL_WidgetImp* GetForm(); 31 FX_BOOL ContinueModal(); 32 FWL_ERR EndModalLoop(); 33 FX_BOOL TranslateAccelerator(CFWL_Message* pMessage); 34 FWL_ERR SetMainForm(CFWL_WidgetImp* pForm); 35 36 protected: 37 void GenerateCommondEvent(FX_DWORD dwCommand); 38 39 CFWL_WidgetImp* m_pForm; 40 FX_BOOL m_bContinueModal; 41 }; 42 class CFWL_NoteDriver : public IFWL_NoteDriver { 43 public: 44 CFWL_NoteDriver(); 45 ~CFWL_NoteDriver() override; 46 47 // IFWL_NoteDriver: 48 FX_BOOL SendNote(CFWL_Note* pNote) override; 49 FX_BOOL PostMessage(CFWL_Message* pMessage) override; 50 FWL_ERR RegisterEventTarget(IFWL_Widget* pListener, 51 IFWL_Widget* pEventSource = NULL, 52 FX_DWORD dwFilter = FWL_EVENT_ALL_MASK) override; 53 FWL_ERR UnregisterEventTarget(IFWL_Widget* pListener) override; 54 void ClearEventTargets(FX_BOOL bRemoveAll) override; 55 int32_t GetQueueMaxSize() const override; 56 FWL_ERR SetQueueMaxSize(const int32_t size) override; 57 IFWL_NoteThread* GetOwnerThread() const override; 58 FWL_ERR PushNoteLoop(IFWL_NoteLoop* pNoteLoop) override; 59 IFWL_NoteLoop* PopNoteLoop() override; 60 IFWL_Widget* GetFocus() override; 61 FX_BOOL SetFocus(IFWL_Widget* pFocus, FX_BOOL bNotify = FALSE) override; 62 void SetGrab(IFWL_Widget* pGrab, FX_BOOL bSet) override; 63 FWL_ERR Run() override; 64 65 IFWL_Widget* GetHover(); 66 void SetHover(IFWL_Widget* pHover); 67 void NotifyTargetHide(IFWL_Widget* pNoteTarget); 68 void NotifyTargetDestroy(IFWL_Widget* pNoteTarget); 69 void NotifyFullScreenMode(IFWL_Widget* pNoteTarget, FX_BOOL bFullScreen); 70 FWL_ERR RegisterForm(CFWL_WidgetImp* pForm); 71 FWL_ERR UnRegisterForm(CFWL_WidgetImp* pForm); 72 FX_BOOL QueueMessage(CFWL_Message* pMessage); 73 FX_BOOL UnqueueMessage(CFWL_NoteLoop* pNoteLoop); 74 CFWL_NoteLoop* GetTopLoop(); 75 int32_t CountLoop(); 76 void SetHook(FWLMessageHookCallback callback, void* info); 77 FX_BOOL ProcessMessage(CFWL_Message* pMessage); 78 79 protected: 80 FX_BOOL DispatchMessage(CFWL_Message* pMessage, IFWL_Widget* pMessageForm); 81 FX_BOOL DoActivate(CFWL_MsgActivate* pMsg, IFWL_Widget* pMessageForm); 82 FX_BOOL DoDeactivate(CFWL_MsgDeactivate* pMsg, IFWL_Widget* pMessageForm); 83 FX_BOOL DoSetFocus(CFWL_MsgSetFocus* pMsg, IFWL_Widget* pMessageForm); 84 FX_BOOL DoKillFocus(CFWL_MsgKillFocus* pMsg, IFWL_Widget* pMessageForm); 85 FX_BOOL DoKey(CFWL_MsgKey* pMsg, IFWL_Widget* pMessageForm); 86 FX_BOOL DoMouse(CFWL_MsgMouse* pMsg, IFWL_Widget* pMessageForm); 87 FX_BOOL DoWheel(CFWL_MsgMouseWheel* pMsg, IFWL_Widget* pMessageForm); 88 FX_BOOL DoSize(CFWL_MsgSize* pMsg); 89 FX_BOOL DoWindowMove(CFWL_MsgWindowMove* pMsg, IFWL_Widget* pMessageForm); 90 FX_BOOL DoDragFiles(CFWL_MsgDropFiles* pMsg, IFWL_Widget* pMessageForm); 91 FX_BOOL DoMouseEx(CFWL_MsgMouse* pMsg, IFWL_Widget* pMessageForm); 92 void MouseSecondary(CFWL_MsgMouse* pMsg); 93 FX_BOOL IsValidMessage(CFWL_Message* pMessage); 94 IFWL_Widget* GetMessageForm(IFWL_Widget* pDstTarget); 95 void ClearInvalidEventTargets(FX_BOOL bRemoveAll); 96 CFX_PtrArray m_forms; 97 CFX_PtrArray m_noteQueue; 98 CFX_PtrArray m_noteLoopQueue; 99 CFX_MapPtrToPtr m_eventTargets; 100 int32_t m_sendEventCalled; 101 int32_t m_maxSize; 102 FX_BOOL m_bFullScreen; 103 IFWL_Widget* m_pHover; 104 IFWL_Widget* m_pFocus; 105 IFWL_Widget* m_pGrab; 106 CFWL_NoteLoop* m_pNoteLoop; 107 FWLMessageHookCallback m_hook; 108 void* m_hookInfo; 109 }; 110 typedef CFX_MapPtrTemplate<void*, FX_DWORD> CFWL_EventSource; 111 class CFWL_EventTarget { 112 public: 113 CFWL_EventTarget(CFWL_NoteDriver* pNoteDriver, IFWL_Widget* pListener) 114 : m_pListener(pListener), m_pNoteDriver(pNoteDriver), m_bInvalid(FALSE) {} 115 ~CFWL_EventTarget(); 116 int32_t SetEventSource(IFWL_Widget* pSource, 117 FX_DWORD dwFilter = FWL_EVENT_ALL_MASK); 118 FX_BOOL ProcessEvent(CFWL_Event* pEvent); 119 FX_BOOL IsFilterEvent(CFWL_Event* pEvent, FX_DWORD dwFilter); 120 FX_BOOL IsInvalid() { return m_bInvalid; } 121 void FlagInvalid() { m_bInvalid = TRUE; } 122 123 protected: 124 CFWL_EventSource m_eventSources; 125 IFWL_Widget* m_pListener; 126 CFWL_NoteDriver* m_pNoteDriver; 127 FX_BOOL m_bInvalid; 128 }; 129 class CFWL_ToolTipContainer { 130 public: 131 static CFWL_ToolTipContainer* getInstance(); 132 static void DeleteInstance(); 133 134 FX_ERR AddToolTipTarget(IFWL_ToolTipTarget* pTarget); 135 FX_ERR RemoveToolTipTarget(IFWL_ToolTipTarget* pTarget); 136 IFWL_ToolTipTarget* GetCurrentToolTipTarget(); 137 138 FX_BOOL HasToolTip(IFWL_Widget* pWidget); 139 140 FX_BOOL ProcessEnter(CFWL_EvtMouse* pEvt, IFWL_Widget* pOwner); 141 FX_BOOL ProcessLeave(CFWL_EvtMouse* pEvt); 142 143 FX_ERR SetToolTipInitialDelay(int32_t iDelayTime); 144 FX_ERR SetToolTipAutoPopDelay(int32_t iDelayTime); 145 146 protected: 147 CFWL_ToolTipContainer(); 148 virtual ~CFWL_ToolTipContainer(); 149 150 IFWL_ToolTipTarget* pCurTarget; 151 CFWL_ToolTipImp* m_pToolTipImp; 152 CFWL_CoreToopTipDP* m_ToolTipDp; 153 CFX_PtrArray m_arrWidget; 154 155 private: 156 static CFWL_ToolTipContainer* s_pInstance; 157 }; 158 #endif 159