Home | History | Annotate | Download | only in fwl
      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 <deque>
     11 #include <map>
     12 #include <memory>
     13 #include <vector>
     14 
     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_NoteLoop;
     21 class CFWL_TargetImp;
     22 class CFWL_Widget;
     23 
     24 class CFWL_NoteDriver {
     25  public:
     26   CFWL_NoteDriver();
     27   ~CFWL_NoteDriver();
     28 
     29   void SendEvent(CFWL_Event* pNote);
     30 
     31   void RegisterEventTarget(CFWL_Widget* pListener, CFWL_Widget* pEventSource);
     32   void UnregisterEventTarget(CFWL_Widget* pListener);
     33   void ClearEventTargets();
     34 
     35   CFWL_NoteLoop* GetTopLoop() const;
     36   void PushNoteLoop(CFWL_NoteLoop* pNoteLoop);
     37   CFWL_NoteLoop* PopNoteLoop();
     38 
     39   CFWL_Widget* GetFocus() const { return m_pFocus; }
     40   bool SetFocus(CFWL_Widget* pFocus);
     41   void SetGrab(CFWL_Widget* pGrab, bool bSet) {
     42     m_pGrab = bSet ? pGrab : nullptr;
     43   }
     44 
     45   void Run();
     46 
     47   void NotifyTargetHide(CFWL_Widget* pNoteTarget);
     48   void NotifyTargetDestroy(CFWL_Widget* pNoteTarget);
     49 
     50   void RegisterForm(CFWL_Widget* pForm);
     51   void UnRegisterForm(CFWL_Widget* pForm);
     52 
     53   void ProcessMessage(std::unique_ptr<CFWL_Message> pMessage);
     54   void QueueMessage(std::unique_ptr<CFWL_Message> pMessage);
     55   void UnqueueMessageAndProcess(CFWL_NoteLoop* pNoteLoop);
     56 
     57  private:
     58   bool DispatchMessage(CFWL_Message* pMessage, CFWL_Widget* pMessageForm);
     59   bool DoSetFocus(CFWL_Message* pMsg, CFWL_Widget* pMessageForm);
     60   bool DoKillFocus(CFWL_Message* pMsg, CFWL_Widget* pMessageForm);
     61   bool DoKey(CFWL_Message* pMsg, CFWL_Widget* pMessageForm);
     62   bool DoMouse(CFWL_Message* pMsg, CFWL_Widget* pMessageForm);
     63   bool DoWheel(CFWL_Message* pMsg, CFWL_Widget* pMessageForm);
     64   bool DoMouseEx(CFWL_Message* pMsg, CFWL_Widget* pMessageForm);
     65   void MouseSecondary(CFWL_Message* pMsg);
     66   bool IsValidMessage(CFWL_Message* pMessage);
     67   CFWL_Widget* GetMessageForm(CFWL_Widget* pDstTarget);
     68 
     69   std::vector<CFWL_Widget*> m_Forms;
     70   std::deque<std::unique_ptr<CFWL_Message>> m_NoteQueue;
     71   std::vector<CFWL_NoteLoop*> m_NoteLoopQueue;
     72   std::map<uint32_t, std::unique_ptr<CFWL_EventTarget>> m_eventTargets;
     73   CFWL_Widget* m_pHover;
     74   CFWL_Widget* m_pFocus;
     75   CFWL_Widget* m_pGrab;
     76   std::unique_ptr<CFWL_NoteLoop> m_pNoteLoop;
     77 };
     78 
     79 #endif  // XFA_FWL_CFWL_NOTEDRIVER_H_
     80