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 XFA_FWL_CFWL_NOTEDRIVER_H_
8 #define XFA_FWL_CFWL_NOTEDRIVER_H_
9 
10 #include <map>
11 #include <memory>
12 #include <vector>
13 
14 #include "core/fxcrt/unowned_ptr.h"
15 #include "xfa/fwl/cfwl_event.h"
16 #include "xfa/fwl/cfwl_widget.h"
17 #include "xfa/fxgraphics/cxfa_graphics.h"
18 
19 class CFWL_EventTarget;
20 class CFWL_TargetImp;
21 class CFWL_Widget;
22 
23 class CFWL_NoteDriver {
24  public:
25   CFWL_NoteDriver();
26   ~CFWL_NoteDriver();
27 
28   void SendEvent(CFWL_Event* pNote);
29 
30   void RegisterEventTarget(CFWL_Widget* pListener, CFWL_Widget* pEventSource);
31   void UnregisterEventTarget(CFWL_Widget* pListener);
32   void ClearEventTargets();
33 
GetFocus()34   CFWL_Widget* GetFocus() const { return m_pFocus.Get(); }
35   bool SetFocus(CFWL_Widget* pFocus);
SetGrab(CFWL_Widget * pGrab,bool bSet)36   void SetGrab(CFWL_Widget* pGrab, bool bSet) {
37     m_pGrab = bSet ? pGrab : nullptr;
38   }
39 
40   void NotifyTargetHide(CFWL_Widget* pNoteTarget);
41   void NotifyTargetDestroy(CFWL_Widget* pNoteTarget);
42   void ProcessMessage(std::unique_ptr<CFWL_Message> pMessage);
43 
44  private:
45   bool DispatchMessage(CFWL_Message* pMessage, CFWL_Widget* pMessageForm);
46   bool DoSetFocus(CFWL_Message* pMsg, CFWL_Widget* pMessageForm);
47   bool DoKillFocus(CFWL_Message* pMsg, CFWL_Widget* pMessageForm);
48   bool DoKey(CFWL_Message* pMsg, CFWL_Widget* pMessageForm);
49   bool DoMouse(CFWL_Message* pMsg, CFWL_Widget* pMessageForm);
50   bool DoWheel(CFWL_Message* pMsg, CFWL_Widget* pMessageForm);
51   bool DoMouseEx(CFWL_Message* pMsg, CFWL_Widget* pMessageForm);
52   void MouseSecondary(CFWL_Message* pMsg);
53   CFWL_Widget* GetMessageForm(CFWL_Widget* pDstTarget);
54 
55   std::map<uint32_t, std::unique_ptr<CFWL_EventTarget>> m_eventTargets;
56   UnownedPtr<CFWL_Widget> m_pHover;
57   UnownedPtr<CFWL_Widget> m_pFocus;
58   UnownedPtr<CFWL_Widget> m_pGrab;
59 };
60 
61 #endif  // XFA_FWL_CFWL_NOTEDRIVER_H_
62