OLD | NEW |
---|---|
1 // Copyright 2016 PDFium Authors. All rights reserved. | 1 // Copyright 2016 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_CFWL_MESSAGE_H_ | 7 #ifndef XFA_FWL_CORE_CFWL_MESSAGE_H_ |
8 #define XFA_FWL_CORE_CFWL_MESSAGE_H_ | 8 #define XFA_FWL_CORE_CFWL_MESSAGE_H_ |
9 | 9 |
10 #include "core/fxcrt/fx_basic.h" | 10 #include "core/fxcrt/fx_basic.h" |
11 #include "core/fxcrt/fx_string.h" | 11 #include "core/fxcrt/fx_string.h" |
12 #include "core/fxcrt/fx_system.h" | 12 #include "core/fxcrt/fx_system.h" |
13 #include "xfa/fwl/core/fwl_error.h" | 13 #include "xfa/fwl/core/fwl_error.h" |
14 | 14 |
15 enum class CFWL_MessageType { | 15 enum class CFWL_MessageType { |
16 None = 0, | 16 None = 0, |
17 | |
18 Activate, | |
19 Close, | |
20 Cursor, | |
21 Deactivate, | |
22 DropFiles, | |
23 Key, | 17 Key, |
24 KillFocus, | 18 KillFocus, |
25 Mouse, | 19 Mouse, |
26 MouseWheel, | 20 MouseWheel, |
27 Post, | 21 SetFocus |
28 SetFocus, | |
29 Size, | |
30 TaskClicked, | |
31 WindowMove, | |
32 WindowWillMove | |
33 }; | 22 }; |
34 | 23 |
35 enum class FWL_MouseCommand { | 24 enum class FWL_MouseCommand { |
36 LeftButtonDown, | 25 LeftButtonDown, |
37 LeftButtonUp, | 26 LeftButtonUp, |
38 LeftButtonDblClk, | 27 LeftButtonDblClk, |
39 RightButtonDown, | 28 RightButtonDown, |
40 RightButtonUp, | 29 RightButtonUp, |
41 RightButtonDblClk, | 30 RightButtonDblClk, |
42 MiddleButtonDown, | |
43 MiddleButtonUp, | |
44 MiddleButtonDblClk, | |
45 Move, | 31 Move, |
46 Enter, | 32 Enter, |
47 Leave, | 33 Leave, |
48 Hover | 34 Hover |
49 }; | 35 }; |
50 | 36 |
51 enum class FWL_KeyCommand { KeyDown, KeyUp, Char }; | 37 enum class FWL_KeyCommand { KeyDown, KeyUp, Char }; |
52 | 38 |
53 class IFWL_Widget; | 39 class IFWL_Widget; |
54 | 40 |
(...skipping 38 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
93 if (!m_dwRefCount) | 79 if (!m_dwRefCount) |
94 delete this; | 80 delete this; |
95 return dwRefCount; | 81 return dwRefCount; |
96 } | 82 } |
97 | 83 |
98 inline CFWL_Message* CFWL_Message::Retain() { | 84 inline CFWL_Message* CFWL_Message::Retain() { |
99 m_dwRefCount++; | 85 m_dwRefCount++; |
100 return this; | 86 return this; |
101 } | 87 } |
102 | 88 |
103 #define FWL_MESSAGE_CLASS_DEF(classname, msgType, ...) \ | 89 #define FWL_MESSAGE_DEF(classname, msgType, ...) \ |
npm
2016/11/15 21:38:30
Is this really the best way to do this?
dsinclair
2016/11/15 21:44:06
Probably not, but it's the way it's currently done
Tom Sepez
2016/11/15 22:41:47
I'd suggest just writing it out "longhand" in the
| |
104 class classname : public CFWL_Message { \ | 90 class classname : public CFWL_Message { \ |
105 public: \ | 91 public: \ |
106 classname(); \ | 92 classname(); \ |
107 ~classname() override; \ | 93 ~classname() override; \ |
108 CFWL_Message* Clone() override; \ | 94 CFWL_Message* Clone() override; \ |
109 CFWL_MessageType GetClassID() const override; \ | 95 CFWL_MessageType GetClassID() const override; \ |
110 __VA_ARGS__ \ | 96 __VA_ARGS__ \ |
111 }; | 97 }; \ |
112 | 98 inline classname::classname() {} \ |
113 #define FWL_MESSAGE_FUNCTION_DEF(classname, msgType, ...) \ | 99 inline classname::~classname() {} \ |
114 inline classname::classname() {} \ | 100 inline CFWL_Message* classname::Clone() { return new classname(*this); } \ |
115 inline classname::~classname() {} \ | 101 inline CFWL_MessageType classname::GetClassID() const { return msgType; } |
116 inline CFWL_Message* classname::Clone() { return new classname(*this); } \ | |
117 inline CFWL_MessageType classname::GetClassID() const { return msgType; } \ | |
118 __VA_ARGS__ | |
119 | |
120 #define FWL_MESSAGE_DEF(classname, msgType, ...) \ | |
121 FWL_MESSAGE_CLASS_DEF(classname, msgType, __VA_ARGS__) \ | |
122 FWL_MESSAGE_FUNCTION_DEF(classname, msgType) | |
123 | |
124 FWL_MESSAGE_DEF(CFWL_MsgActivate, CFWL_MessageType::Activate) | |
125 | |
126 FWL_MESSAGE_DEF(CFWL_MsgDeactivate, CFWL_MessageType::Deactivate) | |
127 | 102 |
128 FWL_MESSAGE_DEF(CFWL_MsgMouse, CFWL_MessageType::Mouse, FX_FLOAT m_fx; | 103 FWL_MESSAGE_DEF(CFWL_MsgMouse, CFWL_MessageType::Mouse, FX_FLOAT m_fx; |
129 FX_FLOAT m_fy; | 104 FX_FLOAT m_fy; |
130 uint32_t m_dwFlags; | 105 uint32_t m_dwFlags; |
131 FWL_MouseCommand m_dwCmd;) | 106 FWL_MouseCommand m_dwCmd;) |
132 | 107 |
133 FWL_MESSAGE_DEF(CFWL_MsgMouseWheel, CFWL_MessageType::MouseWheel, FX_FLOAT m_fx; | 108 FWL_MESSAGE_DEF(CFWL_MsgMouseWheel, CFWL_MessageType::MouseWheel, FX_FLOAT m_fx; |
134 FX_FLOAT m_fy; | 109 FX_FLOAT m_fy; |
135 FX_FLOAT m_fDeltaX; | 110 FX_FLOAT m_fDeltaX; |
136 FX_FLOAT m_fDeltaY; | 111 FX_FLOAT m_fDeltaY; |
137 uint32_t m_dwFlags;) | 112 uint32_t m_dwFlags;) |
138 | 113 |
139 FWL_MESSAGE_DEF(CFWL_MsgSetFocus, | 114 FWL_MESSAGE_DEF(CFWL_MsgSetFocus, |
140 CFWL_MessageType::SetFocus, | 115 CFWL_MessageType::SetFocus, |
141 IFWL_Widget* m_pKillFocus;) | 116 IFWL_Widget* m_pKillFocus;) |
142 | 117 |
143 FWL_MESSAGE_DEF(CFWL_MsgKillFocus, | 118 FWL_MESSAGE_DEF(CFWL_MsgKillFocus, |
144 CFWL_MessageType::KillFocus, | 119 CFWL_MessageType::KillFocus, |
145 IFWL_Widget* m_pSetFocus;) | 120 IFWL_Widget* m_pSetFocus;) |
146 | 121 |
147 FWL_MESSAGE_DEF(CFWL_MsgKey, CFWL_MessageType::Key, uint32_t m_dwKeyCode; | 122 FWL_MESSAGE_DEF(CFWL_MsgKey, CFWL_MessageType::Key, uint32_t m_dwKeyCode; |
148 uint32_t m_dwFlags; | 123 uint32_t m_dwFlags; |
149 FWL_KeyCommand m_dwCmd;) | 124 FWL_KeyCommand m_dwCmd;) |
150 | 125 |
151 FWL_MESSAGE_DEF(CFWL_MsgCursor, CFWL_MessageType::Cursor) | |
152 | |
153 FWL_MESSAGE_DEF(CFWL_MsgSize, CFWL_MessageType::Size, int32_t m_iWidth; | |
154 int32_t m_iHeight;) | |
155 | |
156 FWL_MESSAGE_DEF(CFWL_MsgWindowMove, CFWL_MessageType::WindowMove, FX_FLOAT m_fx; | |
157 FX_FLOAT m_fy;) | |
158 | |
159 FWL_MESSAGE_CLASS_DEF(CFWL_MsgDropFiles, | |
160 CFWL_MessageType::DropFiles, | |
161 CFWL_MsgDropFiles(const CFWL_MsgDropFiles& copy); | |
162 FX_FLOAT m_fx; | |
163 FX_FLOAT m_fy; | |
164 CFX_WideStringArray m_files;) | |
165 FWL_MESSAGE_FUNCTION_DEF( | |
166 CFWL_MsgDropFiles, | |
167 CFWL_MessageType::DropFiles, | |
168 inline CFWL_MsgDropFiles::CFWL_MsgDropFiles(const CFWL_MsgDropFiles& copy) { | |
169 m_pDstTarget = copy.m_pDstTarget; | |
170 m_pSrcTarget = copy.m_pSrcTarget; | |
171 m_fx = copy.m_fx; | |
172 m_fy = copy.m_fy; | |
173 m_files.Append(copy.m_files); | |
174 }) | |
175 | |
176 FWL_MESSAGE_DEF(CFWL_MsgTaskClicked, | |
177 CFWL_MessageType::TaskClicked, | |
178 FX_FLOAT m_fx; | |
179 FX_FLOAT m_fy;) | |
180 | |
181 FWL_MESSAGE_DEF(CFWL_MsgClose, CFWL_MessageType::Close) | |
182 | |
183 FWL_MESSAGE_DEF(CFWL_MsgWindowWillMove, CFWL_MessageType::WindowWillMove) | |
184 | |
185 #endif // XFA_FWL_CORE_CFWL_MESSAGE_H_ | 126 #endif // XFA_FWL_CORE_CFWL_MESSAGE_H_ |
OLD | NEW |