Chromium Code Reviews
chromiumcodereview-hr@appspot.gserviceaccount.com (chromiumcodereview-hr) | Please choose your nickname with Settings | Help | Chromium Project | Gerrit Changes | Sign out
(301)

Side by Side Diff: xfa/fwl/core/fwl_noteimp.h

Issue 2503513002: Cleanup fwl_* classes and cfx_* classes in fwl. (Closed)
Patch Set: Created 4 years, 1 month ago
Use n/p to move between diff chunks; N/P to move between comments. Draft comments are only viewable by you.
Jump to:
View unified diff | Download patch
OLDNEW
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() { return m_pForm; }
41 IFWL_Widget* GetForm(); 40 bool ContinueModal() { 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 void PushNoteLoop(CFWL_NoteLoop* pNoteLoop);
65 CFWL_NoteLoop* PopNoteLoop(); 63 CFWL_NoteLoop* PopNoteLoop();
66 IFWL_Widget* GetFocus(); 64
65 IFWL_Widget* GetFocus() { return m_pFocus; }
67 bool SetFocus(IFWL_Widget* pFocus, bool bNotify = false); 66 bool SetFocus(IFWL_Widget* pFocus, bool bNotify = false);
68 void SetGrab(IFWL_Widget* pGrab, bool bSet); 67 void SetGrab(IFWL_Widget* pGrab, bool bSet) {
69 FWL_Error Run(); 68 m_pGrab = bSet ? pGrab : nullptr;
69 }
70 70
71 IFWL_Widget* GetHover(); 71 void Run();
72 void SetHover(IFWL_Widget* pHover); 72
73 void NotifyTargetHide(IFWL_Widget* pNoteTarget); 73 void NotifyTargetHide(IFWL_Widget* pNoteTarget);
74 void NotifyTargetDestroy(IFWL_Widget* pNoteTarget); 74 void NotifyTargetDestroy(IFWL_Widget* pNoteTarget);
75 FWL_Error RegisterForm(IFWL_Widget* pForm); 75
76 FWL_Error UnRegisterForm(IFWL_Widget* pForm); 76 void RegisterForm(IFWL_Widget* pForm);
77 void UnRegisterForm(IFWL_Widget* pForm);
78
77 bool QueueMessage(CFWL_Message* pMessage); 79 bool QueueMessage(CFWL_Message* pMessage);
80 bool ProcessMessage(CFWL_Message* pMessage);
81
82 private:
78 bool UnqueueMessage(CFWL_NoteLoop* pNoteLoop); 83 bool UnqueueMessage(CFWL_NoteLoop* pNoteLoop);
79 CFWL_NoteLoop* GetTopLoop(); 84 CFWL_NoteLoop* GetTopLoop();
80 int32_t CountLoop();
81 bool ProcessMessage(CFWL_Message* pMessage);
82 85
83 protected:
84 bool DispatchMessage(CFWL_Message* pMessage, IFWL_Widget* pMessageForm); 86 bool DispatchMessage(CFWL_Message* pMessage, IFWL_Widget* pMessageForm);
85 bool DoActivate(CFWL_MsgActivate* pMsg, IFWL_Widget* pMessageForm); 87 bool DoActivate(CFWL_MsgActivate* pMsg, IFWL_Widget* pMessageForm);
86 bool DoDeactivate(CFWL_MsgDeactivate* pMsg, IFWL_Widget* pMessageForm); 88 bool DoDeactivate(CFWL_MsgDeactivate* pMsg, IFWL_Widget* pMessageForm);
87 bool DoSetFocus(CFWL_MsgSetFocus* pMsg, IFWL_Widget* pMessageForm); 89 bool DoSetFocus(CFWL_MsgSetFocus* pMsg, IFWL_Widget* pMessageForm);
88 bool DoKillFocus(CFWL_MsgKillFocus* pMsg, IFWL_Widget* pMessageForm); 90 bool DoKillFocus(CFWL_MsgKillFocus* pMsg, IFWL_Widget* pMessageForm);
89 bool DoKey(CFWL_MsgKey* pMsg, IFWL_Widget* pMessageForm); 91 bool DoKey(CFWL_MsgKey* pMsg, IFWL_Widget* pMessageForm);
90 bool DoMouse(CFWL_MsgMouse* pMsg, IFWL_Widget* pMessageForm); 92 bool DoMouse(CFWL_MsgMouse* pMsg, IFWL_Widget* pMessageForm);
91 bool DoWheel(CFWL_MsgMouseWheel* pMsg, IFWL_Widget* pMessageForm); 93 bool DoWheel(CFWL_MsgMouseWheel* pMsg, IFWL_Widget* pMessageForm);
92 bool DoSize(CFWL_MsgSize* pMsg); 94 bool DoSize(CFWL_MsgSize* pMsg);
93 bool DoWindowMove(CFWL_MsgWindowMove* pMsg, IFWL_Widget* pMessageForm); 95 bool DoWindowMove(CFWL_MsgWindowMove* pMsg, IFWL_Widget* pMessageForm);
94 bool DoDragFiles(CFWL_MsgDropFiles* pMsg, IFWL_Widget* pMessageForm); 96 bool DoDragFiles(CFWL_MsgDropFiles* pMsg, IFWL_Widget* pMessageForm);
95 bool DoMouseEx(CFWL_MsgMouse* pMsg, IFWL_Widget* pMessageForm); 97 bool DoMouseEx(CFWL_MsgMouse* pMsg, IFWL_Widget* pMessageForm);
96 void MouseSecondary(CFWL_MsgMouse* pMsg); 98 void MouseSecondary(CFWL_MsgMouse* pMsg);
97 bool IsValidMessage(CFWL_Message* pMessage); 99 bool IsValidMessage(CFWL_Message* pMessage);
98 IFWL_Widget* GetMessageForm(IFWL_Widget* pDstTarget); 100 IFWL_Widget* GetMessageForm(IFWL_Widget* pDstTarget);
99 void ClearInvalidEventTargets(bool bRemoveAll);
100 101
101 CFX_ArrayTemplate<IFWL_Widget*> m_forms; 102 CFX_ArrayTemplate<IFWL_Widget*> m_forms;
102 CFX_ArrayTemplate<CFWL_Message*> m_noteQueue; 103 CFX_ArrayTemplate<CFWL_Message*> m_noteQueue;
103 CFX_ArrayTemplate<CFWL_NoteLoop*> m_noteLoopQueue; 104 CFX_ArrayTemplate<CFWL_NoteLoop*> m_noteLoopQueue;
104 std::unordered_map<uint32_t, CFWL_EventTarget*> m_eventTargets; 105 std::unordered_map<uint32_t, CFWL_EventTarget*> m_eventTargets;
105 IFWL_Widget* m_pHover; 106 IFWL_Widget* m_pHover;
106 IFWL_Widget* m_pFocus; 107 IFWL_Widget* m_pFocus;
107 IFWL_Widget* m_pGrab; 108 IFWL_Widget* m_pGrab;
108 std::unique_ptr<CFWL_NoteLoop> m_pNoteLoop; 109 std::unique_ptr<CFWL_NoteLoop> m_pNoteLoop;
109 }; 110 };
110 111
111 class CFWL_EventTarget { 112 class CFWL_EventTarget {
112 public: 113 public:
113 CFWL_EventTarget(CFWL_NoteDriver* pNoteDriver, IFWL_Widget* pListener); 114 CFWL_EventTarget(IFWL_Widget* pListener);
114 ~CFWL_EventTarget(); 115 ~CFWL_EventTarget();
115 116
116 int32_t SetEventSource(IFWL_Widget* pSource, 117 int32_t SetEventSource(IFWL_Widget* pSource,
117 uint32_t dwFilter = FWL_EVENT_ALL_MASK); 118 uint32_t dwFilter = FWL_EVENT_ALL_MASK);
118 bool ProcessEvent(CFWL_Event* pEvent); 119 bool ProcessEvent(CFWL_Event* pEvent);
119 bool IsFilterEvent(CFWL_Event* pEvent, uint32_t dwFilter); 120
120 bool IsInvalid() { return m_bInvalid; } 121 bool IsInvalid() { return m_bInvalid; }
121 void FlagInvalid() { m_bInvalid = true; } 122 void FlagInvalid() { m_bInvalid = true; }
122 123
123 protected: 124 private:
125 bool IsFilterEvent(CFWL_Event* pEvent, uint32_t dwFilter);
126
124 CFX_MapPtrTemplate<void*, uint32_t> m_eventSources; 127 CFX_MapPtrTemplate<void*, uint32_t> m_eventSources;
125 IFWL_Widget* m_pListener; 128 IFWL_Widget* m_pListener;
126 CFWL_NoteDriver* m_pNoteDriver;
127 bool m_bInvalid; 129 bool m_bInvalid;
128 }; 130 };
129 131
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_ 132 #endif // XFA_FWL_CORE_FWL_NOTEIMP_H_
OLDNEW

Powered by Google App Engine
This is Rietveld 408576698