OLD | NEW |
1 // Copyright 2014 PDFium Authors. All rights reserved. | 1 // Copyright 2014 PDFium Authors. All rights reserved. |
2 // Use of this source code is governed by a BSD-style license that can be | 2 // Use of this source code is governed by a BSD-style license that can be |
3 // found in the LICENSE file. | 3 // found in the LICENSE file. |
4 | 4 |
5 // Original code copyright 2014 Foxit Software Inc. http://www.foxitsoftware.com | 5 // Original code copyright 2014 Foxit Software Inc. http://www.foxitsoftware.com |
6 | 6 |
7 #ifndef XFA_FWL_CORE_FWL_NOTEIMP_H_ | 7 #ifndef XFA_FWL_CORE_FWL_NOTEIMP_H_ |
8 #define XFA_FWL_CORE_FWL_NOTEIMP_H_ | 8 #define XFA_FWL_CORE_FWL_NOTEIMP_H_ |
9 | 9 |
10 #include <memory> | 10 #include <memory> |
11 #include <unordered_map> | 11 #include <unordered_map> |
12 | 12 |
13 #include "xfa/fwl/core/cfwl_event.h" | 13 #include "xfa/fwl/core/cfwl_event.h" |
14 #include "xfa/fwl/core/cfwl_message.h" | 14 #include "xfa/fwl/core/cfwl_message.h" |
15 #include "xfa/fwl/core/fwl_error.h" | |
16 #include "xfa/fwl/core/ifwl_tooltip.h" | 15 #include "xfa/fwl/core/ifwl_tooltip.h" |
17 #include "xfa/fwl/core/ifwl_widget.h" | 16 #include "xfa/fwl/core/ifwl_widget.h" |
18 #include "xfa/fxgraphics/cfx_graphics.h" | 17 #include "xfa/fxgraphics/cfx_graphics.h" |
19 | 18 |
20 class CFWL_EventTarget; | 19 class CFWL_EventTarget; |
21 class CFWL_MsgActivate; | 20 class CFWL_MsgActivate; |
22 class CFWL_MsgDeactivate; | 21 class CFWL_MsgDeactivate; |
23 class CFWL_MsgDropFiles; | 22 class CFWL_MsgDropFiles; |
24 class CFWL_MsgKey; | 23 class CFWL_MsgKey; |
25 class CFWL_MsgKillFocus; | 24 class CFWL_MsgKillFocus; |
26 class CFWL_MsgMouse; | 25 class CFWL_MsgMouse; |
27 class CFWL_MsgMouseWheel; | 26 class CFWL_MsgMouseWheel; |
28 class CFWL_MsgSetFocus; | 27 class CFWL_MsgSetFocus; |
29 class CFWL_MsgSize; | 28 class CFWL_MsgSize; |
30 class CFWL_MsgWindowMove; | 29 class CFWL_MsgWindowMove; |
31 class CFWL_TargetImp; | 30 class CFWL_TargetImp; |
32 class IFWL_ToolTip; | 31 class IFWL_ToolTip; |
33 class IFWL_Widget; | 32 class IFWL_Widget; |
34 | 33 |
35 class CFWL_NoteLoop { | 34 class CFWL_NoteLoop { |
36 public: | 35 public: |
37 CFWL_NoteLoop(IFWL_Widget* pForm = nullptr); | 36 CFWL_NoteLoop(); |
38 ~CFWL_NoteLoop() {} | 37 ~CFWL_NoteLoop() {} |
39 | 38 |
40 FWL_Error Idle(int32_t count); | 39 IFWL_Widget* GetForm() const { return m_pForm; } |
41 IFWL_Widget* GetForm(); | 40 bool ContinueModal() const { return m_bContinueModal; } |
42 bool ContinueModal(); | 41 void EndModalLoop() { m_bContinueModal = false; } |
43 FWL_Error EndModalLoop(); | 42 void SetMainForm(IFWL_Widget* pForm) { m_pForm = pForm; } |
44 FWL_Error SetMainForm(IFWL_Widget* pForm); | |
45 | 43 |
46 protected: | 44 private: |
47 void GenerateCommondEvent(uint32_t dwCommand); | |
48 | |
49 IFWL_Widget* m_pForm; | 45 IFWL_Widget* m_pForm; |
50 bool m_bContinueModal; | 46 bool m_bContinueModal; |
51 }; | 47 }; |
52 | 48 |
53 class CFWL_NoteDriver { | 49 class CFWL_NoteDriver { |
54 public: | 50 public: |
55 CFWL_NoteDriver(); | 51 CFWL_NoteDriver(); |
56 ~CFWL_NoteDriver(); | 52 ~CFWL_NoteDriver(); |
57 | 53 |
58 void SendEvent(CFWL_Event* pNote); | 54 void SendEvent(CFWL_Event* pNote); |
59 FWL_Error RegisterEventTarget(IFWL_Widget* pListener, | 55 |
60 IFWL_Widget* pEventSource = nullptr, | 56 void RegisterEventTarget(IFWL_Widget* pListener, |
61 uint32_t dwFilter = FWL_EVENT_ALL_MASK); | 57 IFWL_Widget* pEventSource = nullptr, |
62 FWL_Error UnregisterEventTarget(IFWL_Widget* pListener); | 58 uint32_t dwFilter = FWL_EVENT_ALL_MASK); |
| 59 void UnregisterEventTarget(IFWL_Widget* pListener); |
63 void ClearEventTargets(bool bRemoveAll); | 60 void ClearEventTargets(bool bRemoveAll); |
64 FWL_Error PushNoteLoop(CFWL_NoteLoop* pNoteLoop); | 61 |
| 62 CFWL_NoteLoop* GetTopLoop() const; |
| 63 void PushNoteLoop(CFWL_NoteLoop* pNoteLoop); |
65 CFWL_NoteLoop* PopNoteLoop(); | 64 CFWL_NoteLoop* PopNoteLoop(); |
66 IFWL_Widget* GetFocus(); | 65 |
| 66 IFWL_Widget* GetFocus() const { return m_pFocus; } |
67 bool SetFocus(IFWL_Widget* pFocus, bool bNotify = false); | 67 bool SetFocus(IFWL_Widget* pFocus, bool bNotify = false); |
68 void SetGrab(IFWL_Widget* pGrab, bool bSet); | 68 void SetGrab(IFWL_Widget* pGrab, bool bSet) { |
69 FWL_Error Run(); | 69 m_pGrab = bSet ? pGrab : nullptr; |
| 70 } |
70 | 71 |
71 IFWL_Widget* GetHover(); | 72 void Run(); |
72 void SetHover(IFWL_Widget* pHover); | 73 |
73 void NotifyTargetHide(IFWL_Widget* pNoteTarget); | 74 void NotifyTargetHide(IFWL_Widget* pNoteTarget); |
74 void NotifyTargetDestroy(IFWL_Widget* pNoteTarget); | 75 void NotifyTargetDestroy(IFWL_Widget* pNoteTarget); |
75 FWL_Error RegisterForm(IFWL_Widget* pForm); | 76 |
76 FWL_Error UnRegisterForm(IFWL_Widget* pForm); | 77 void RegisterForm(IFWL_Widget* pForm); |
| 78 void UnRegisterForm(IFWL_Widget* pForm); |
| 79 |
77 bool QueueMessage(CFWL_Message* pMessage); | 80 bool QueueMessage(CFWL_Message* pMessage); |
78 bool UnqueueMessage(CFWL_NoteLoop* pNoteLoop); | 81 bool UnqueueMessage(CFWL_NoteLoop* pNoteLoop); |
79 CFWL_NoteLoop* GetTopLoop(); | |
80 int32_t CountLoop(); | |
81 bool ProcessMessage(CFWL_Message* pMessage); | 82 bool ProcessMessage(CFWL_Message* pMessage); |
82 | 83 |
83 protected: | 84 private: |
84 bool DispatchMessage(CFWL_Message* pMessage, IFWL_Widget* pMessageForm); | 85 bool DispatchMessage(CFWL_Message* pMessage, IFWL_Widget* pMessageForm); |
85 bool DoActivate(CFWL_MsgActivate* pMsg, IFWL_Widget* pMessageForm); | 86 bool DoActivate(CFWL_MsgActivate* pMsg, IFWL_Widget* pMessageForm); |
86 bool DoDeactivate(CFWL_MsgDeactivate* pMsg, IFWL_Widget* pMessageForm); | 87 bool DoDeactivate(CFWL_MsgDeactivate* pMsg, IFWL_Widget* pMessageForm); |
87 bool DoSetFocus(CFWL_MsgSetFocus* pMsg, IFWL_Widget* pMessageForm); | 88 bool DoSetFocus(CFWL_MsgSetFocus* pMsg, IFWL_Widget* pMessageForm); |
88 bool DoKillFocus(CFWL_MsgKillFocus* pMsg, IFWL_Widget* pMessageForm); | 89 bool DoKillFocus(CFWL_MsgKillFocus* pMsg, IFWL_Widget* pMessageForm); |
89 bool DoKey(CFWL_MsgKey* pMsg, IFWL_Widget* pMessageForm); | 90 bool DoKey(CFWL_MsgKey* pMsg, IFWL_Widget* pMessageForm); |
90 bool DoMouse(CFWL_MsgMouse* pMsg, IFWL_Widget* pMessageForm); | 91 bool DoMouse(CFWL_MsgMouse* pMsg, IFWL_Widget* pMessageForm); |
91 bool DoWheel(CFWL_MsgMouseWheel* pMsg, IFWL_Widget* pMessageForm); | 92 bool DoWheel(CFWL_MsgMouseWheel* pMsg, IFWL_Widget* pMessageForm); |
92 bool DoSize(CFWL_MsgSize* pMsg); | 93 bool DoSize(CFWL_MsgSize* pMsg); |
93 bool DoWindowMove(CFWL_MsgWindowMove* pMsg, IFWL_Widget* pMessageForm); | 94 bool DoWindowMove(CFWL_MsgWindowMove* pMsg, IFWL_Widget* pMessageForm); |
94 bool DoDragFiles(CFWL_MsgDropFiles* pMsg, IFWL_Widget* pMessageForm); | 95 bool DoDragFiles(CFWL_MsgDropFiles* pMsg, IFWL_Widget* pMessageForm); |
95 bool DoMouseEx(CFWL_MsgMouse* pMsg, IFWL_Widget* pMessageForm); | 96 bool DoMouseEx(CFWL_MsgMouse* pMsg, IFWL_Widget* pMessageForm); |
96 void MouseSecondary(CFWL_MsgMouse* pMsg); | 97 void MouseSecondary(CFWL_MsgMouse* pMsg); |
97 bool IsValidMessage(CFWL_Message* pMessage); | 98 bool IsValidMessage(CFWL_Message* pMessage); |
98 IFWL_Widget* GetMessageForm(IFWL_Widget* pDstTarget); | 99 IFWL_Widget* GetMessageForm(IFWL_Widget* pDstTarget); |
99 void ClearInvalidEventTargets(bool bRemoveAll); | |
100 | 100 |
101 CFX_ArrayTemplate<IFWL_Widget*> m_forms; | 101 CFX_ArrayTemplate<IFWL_Widget*> m_forms; |
102 CFX_ArrayTemplate<CFWL_Message*> m_noteQueue; | 102 CFX_ArrayTemplate<CFWL_Message*> m_noteQueue; |
103 CFX_ArrayTemplate<CFWL_NoteLoop*> m_noteLoopQueue; | 103 CFX_ArrayTemplate<CFWL_NoteLoop*> m_noteLoopQueue; |
104 std::unordered_map<uint32_t, CFWL_EventTarget*> m_eventTargets; | 104 std::unordered_map<uint32_t, CFWL_EventTarget*> m_eventTargets; |
105 IFWL_Widget* m_pHover; | 105 IFWL_Widget* m_pHover; |
106 IFWL_Widget* m_pFocus; | 106 IFWL_Widget* m_pFocus; |
107 IFWL_Widget* m_pGrab; | 107 IFWL_Widget* m_pGrab; |
108 std::unique_ptr<CFWL_NoteLoop> m_pNoteLoop; | 108 std::unique_ptr<CFWL_NoteLoop> m_pNoteLoop; |
109 }; | 109 }; |
110 | 110 |
111 class CFWL_EventTarget { | 111 class CFWL_EventTarget { |
112 public: | 112 public: |
113 CFWL_EventTarget(CFWL_NoteDriver* pNoteDriver, IFWL_Widget* pListener); | 113 CFWL_EventTarget(IFWL_Widget* pListener); |
114 ~CFWL_EventTarget(); | 114 ~CFWL_EventTarget(); |
115 | 115 |
116 int32_t SetEventSource(IFWL_Widget* pSource, | 116 int32_t SetEventSource(IFWL_Widget* pSource, |
117 uint32_t dwFilter = FWL_EVENT_ALL_MASK); | 117 uint32_t dwFilter = FWL_EVENT_ALL_MASK); |
118 bool ProcessEvent(CFWL_Event* pEvent); | 118 bool ProcessEvent(CFWL_Event* pEvent); |
119 bool IsFilterEvent(CFWL_Event* pEvent, uint32_t dwFilter); | 119 |
120 bool IsInvalid() { return m_bInvalid; } | 120 bool IsInvalid() const { return m_bInvalid; } |
121 void FlagInvalid() { m_bInvalid = true; } | 121 void FlagInvalid() { m_bInvalid = true; } |
122 | 122 |
123 protected: | 123 private: |
| 124 bool IsFilterEvent(CFWL_Event* pEvent, uint32_t dwFilter) const; |
| 125 |
124 CFX_MapPtrTemplate<void*, uint32_t> m_eventSources; | 126 CFX_MapPtrTemplate<void*, uint32_t> m_eventSources; |
125 IFWL_Widget* m_pListener; | 127 IFWL_Widget* m_pListener; |
126 CFWL_NoteDriver* m_pNoteDriver; | |
127 bool m_bInvalid; | 128 bool m_bInvalid; |
128 }; | 129 }; |
129 | 130 |
130 class CFWL_ToolTipContainer final : public IFWL_ToolTipDP { | |
131 public: | |
132 static CFWL_ToolTipContainer* getInstance(); | |
133 static void DeleteInstance(); | |
134 | |
135 // IFWL_ToolTipDP | |
136 void GetCaption(IFWL_Widget* pWidget, CFX_WideString& wsCaption) override; | |
137 int32_t GetInitialDelay(IFWL_Widget* pWidget) override; | |
138 int32_t GetAutoPopDelay(IFWL_Widget* pWidget) override; | |
139 CFX_DIBitmap* GetToolTipIcon(IFWL_Widget* pWidget) override; | |
140 CFX_SizeF GetToolTipIconSize(IFWL_Widget* pWidget) override; | |
141 | |
142 protected: | |
143 CFWL_ToolTipContainer(); | |
144 ~CFWL_ToolTipContainer() override; | |
145 | |
146 CFX_RectF GetAnchor(); | |
147 | |
148 private: | |
149 static CFWL_ToolTipContainer* s_pInstance; | |
150 CFX_WideString m_wsCaption; | |
151 int32_t m_nInitDelayTime; | |
152 int32_t m_nAutoPopDelayTime; | |
153 CFX_RectF m_fAnchor; | |
154 }; | |
155 | |
156 #endif // XFA_FWL_CORE_FWL_NOTEIMP_H_ | 131 #endif // XFA_FWL_CORE_FWL_NOTEIMP_H_ |
OLD | NEW |