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/include/fx_string.h" | 10 #include "core/fxcrt/include/fx_string.h" |
11 #include "core/fxcrt/include/fx_system.h" | 11 #include "core/fxcrt/include/fx_system.h" |
12 #include "xfa/fwl/core/cfwl_note.h" | |
13 #include "xfa/fwl/core/fwl_error.h" | 12 #include "xfa/fwl/core/fwl_error.h" |
14 | 13 |
15 #define FWL_MSGHASH_Activate 2410369469 | 14 enum class CFWL_MessageType { |
16 #define FWL_MSGHASH_Deactivate 1184214790 | 15 None = 0, |
17 #define FWL_MSGHASH_SetFocus 4174512504 | 16 |
18 #define FWL_MSGHASH_KillFocus 1557903832 | 17 Activate, |
19 #define FWL_MSGHASH_Mouse 706128309 | 18 Close, |
20 #define FWL_MSGHASH_MouseWheel 893703466 | 19 Cursor, |
21 #define FWL_MSGHASH_Key 3751372405 | 20 Deactivate, |
22 #define FWL_MSGHASH_Cursor 3182626218 | 21 DropFiles, |
23 #define FWL_MSGHASH_Size 160077735 | 22 Key, |
24 #define FWL_MSGHASH_WindowMove 1032269377 | 23 KillFocus, |
25 #define FWL_MSGHASH_DropFiles 2004165236 | 24 Mouse, |
26 #define FWL_MSGHASH_TaskClicked 3128231086 | 25 MouseWheel, |
27 #define FWL_MSGHASH_Close 2977563906 | 26 Post, |
28 #define FWL_MSGHASH_Post 1969633074 | 27 SetFocus, |
29 #define FWL_MSGHASH_WindowWillMove 2229175763 | 28 Size, |
| 29 TaskClicked, |
| 30 WindowMove, |
| 31 WindowWillMove |
| 32 }; |
30 | 33 |
31 #define FWL_MSG_Activate L"FWL_MESSAGE_Activate" | 34 #define FWL_MSG_Activate L"FWL_MESSAGE_Activate" |
32 #define FWL_MSG_Deactivate L"FWL_MESSAGE_Deactivate" | 35 #define FWL_MSG_Deactivate L"FWL_MESSAGE_Deactivate" |
33 #define FWL_MSG_SetFocus L"FWL_MESSAGE_SetFocus" | 36 #define FWL_MSG_SetFocus L"FWL_MESSAGE_SetFocus" |
34 #define FWL_MSG_KillFocus L"FWL_MESSAGE_KillFocus" | 37 #define FWL_MSG_KillFocus L"FWL_MESSAGE_KillFocus" |
35 #define FWL_MSG_Mouse L"FWL_MESSAGE_Mouse" | 38 #define FWL_MSG_Mouse L"FWL_MESSAGE_Mouse" |
36 #define FWL_MSG_MouseWheel L"FWL_MESSAGE_MouseWheel" | 39 #define FWL_MSG_MouseWheel L"FWL_MESSAGE_MouseWheel" |
37 #define FWL_MSG_Key L"FWL_MESSAGE_Key" | 40 #define FWL_MSG_Key L"FWL_MESSAGE_Key" |
38 #define FWL_MSG_Cursor L"FWL_MESSAGE_Cursor" | 41 #define FWL_MSG_Cursor L"FWL_MESSAGE_Cursor" |
39 #define FWL_MSG_Size L"FWL_MESSAGE_Size" | 42 #define FWL_MSG_Size L"FWL_MESSAGE_Size" |
(...skipping 16 matching lines...) Expand all Loading... |
56 #define FWL_MSGMOUSECMD_MouseMove 10 | 59 #define FWL_MSGMOUSECMD_MouseMove 10 |
57 #define FWL_MSGMOUSECMD_MouseEnter 11 | 60 #define FWL_MSGMOUSECMD_MouseEnter 11 |
58 #define FWL_MSGMOUSECMD_MouseLeave 12 | 61 #define FWL_MSGMOUSECMD_MouseLeave 12 |
59 #define FWL_MSGMOUSECMD_MouseHover 13 | 62 #define FWL_MSGMOUSECMD_MouseHover 13 |
60 #define FWL_MSGKEYCMD_KeyDown 1 | 63 #define FWL_MSGKEYCMD_KeyDown 1 |
61 #define FWL_MSGKEYCMD_KeyUp 2 | 64 #define FWL_MSGKEYCMD_KeyUp 2 |
62 #define FWL_MSGKEYCMD_Char 3 | 65 #define FWL_MSGKEYCMD_Char 3 |
63 | 66 |
64 class IFWL_Widget; | 67 class IFWL_Widget; |
65 | 68 |
66 class CFWL_Message : public CFWL_Note { | 69 class CFWL_Message { |
67 public: | 70 public: |
68 CFWL_Message() : CFWL_Note(FALSE) {} | 71 CFWL_Message() |
| 72 : m_pSrcTarget(nullptr), |
| 73 m_pDstTarget(nullptr), |
| 74 m_dwExtend(0), |
| 75 m_dwRefCount(1) {} |
69 virtual ~CFWL_Message() {} | 76 virtual ~CFWL_Message() {} |
| 77 |
| 78 virtual CFWL_Message* Clone() { return nullptr; } |
| 79 virtual FWL_ERR GetClassName(CFX_WideString& wsClass) const { |
| 80 return FWL_ERR_Succeeded; |
| 81 } |
| 82 virtual CFWL_MessageType GetClassID() const { return CFWL_MessageType::None; } |
| 83 |
| 84 uint32_t Release() { |
| 85 m_dwRefCount--; |
| 86 uint32_t dwRefCount = m_dwRefCount; |
| 87 if (!m_dwRefCount) |
| 88 delete this; |
| 89 return dwRefCount; |
| 90 } |
| 91 |
| 92 CFWL_Message* Retain() { |
| 93 m_dwRefCount++; |
| 94 return this; |
| 95 } |
| 96 |
| 97 IFWL_Widget* m_pSrcTarget; |
| 98 IFWL_Widget* m_pDstTarget; |
| 99 uint32_t m_dwExtend; |
| 100 |
| 101 private: |
| 102 uint32_t m_dwRefCount; |
70 }; | 103 }; |
71 | 104 |
72 #define BEGIN_FWL_MESSAGE_DEF(classname, msghashcode) \ | 105 #define BEGIN_FWL_MESSAGE_DEF(classname, msgType) \ |
73 class classname : public CFWL_Message { \ | 106 class classname : public CFWL_Message { \ |
74 public: \ | 107 public: \ |
75 classname() : CFWL_Message() {} \ | 108 classname() : CFWL_Message() {} \ |
76 virtual CFWL_Note* Clone() { return new classname(*this); } \ | 109 CFWL_Message* Clone() override { return new classname(*this); } \ |
77 virtual FWL_ERR GetClassName(CFX_WideString& wsClass) const { \ | 110 FWL_ERR GetClassName(CFX_WideString& wsClass) const override { \ |
78 wsClass = L## #classname; \ | 111 wsClass = L## #classname; \ |
79 return FWL_ERR_Succeeded; \ | 112 return FWL_ERR_Succeeded; \ |
80 } \ | 113 } \ |
81 virtual uint32_t GetClassID() const { return msghashcode; } | 114 CFWL_MessageType GetClassID() const override { return msgType; } |
82 | 115 |
83 #define END_FWL_MESSAGE_DEF \ | 116 #define END_FWL_MESSAGE_DEF \ |
84 } \ | 117 } \ |
85 ; // NOLINT | 118 ; // NOLINT |
86 | 119 |
87 BEGIN_FWL_MESSAGE_DEF(CFWL_MsgActivate, FWL_MSGHASH_Activate) | 120 BEGIN_FWL_MESSAGE_DEF(CFWL_MsgActivate, CFWL_MessageType::Activate) |
88 END_FWL_MESSAGE_DEF | 121 END_FWL_MESSAGE_DEF |
89 | 122 |
90 BEGIN_FWL_MESSAGE_DEF(CFWL_MsgDeactivate, FWL_MSGHASH_Deactivate) | 123 BEGIN_FWL_MESSAGE_DEF(CFWL_MsgDeactivate, CFWL_MessageType::Deactivate) |
91 END_FWL_MESSAGE_DEF | 124 END_FWL_MESSAGE_DEF |
92 | 125 |
93 BEGIN_FWL_MESSAGE_DEF(CFWL_MsgMouse, FWL_MSGHASH_Mouse) | 126 BEGIN_FWL_MESSAGE_DEF(CFWL_MsgMouse, CFWL_MessageType::Mouse) |
94 FX_FLOAT m_fx; | 127 FX_FLOAT m_fx; |
95 FX_FLOAT m_fy; | 128 FX_FLOAT m_fy; |
96 uint32_t m_dwFlags; | 129 uint32_t m_dwFlags; |
97 uint32_t m_dwCmd; | 130 uint32_t m_dwCmd; |
98 END_FWL_MESSAGE_DEF | 131 END_FWL_MESSAGE_DEF |
99 | 132 |
100 BEGIN_FWL_MESSAGE_DEF(CFWL_MsgMouseWheel, FWL_MSGHASH_MouseWheel) | 133 BEGIN_FWL_MESSAGE_DEF(CFWL_MsgMouseWheel, CFWL_MessageType::MouseWheel) |
101 FX_FLOAT m_fx; | 134 FX_FLOAT m_fx; |
102 FX_FLOAT m_fy; | 135 FX_FLOAT m_fy; |
103 FX_FLOAT m_fDeltaX; | 136 FX_FLOAT m_fDeltaX; |
104 FX_FLOAT m_fDeltaY; | 137 FX_FLOAT m_fDeltaY; |
105 uint32_t m_dwFlags; | 138 uint32_t m_dwFlags; |
106 END_FWL_MESSAGE_DEF | 139 END_FWL_MESSAGE_DEF |
107 | 140 |
108 BEGIN_FWL_MESSAGE_DEF(CFWL_MsgSetFocus, FWL_MSGHASH_SetFocus) | 141 BEGIN_FWL_MESSAGE_DEF(CFWL_MsgSetFocus, CFWL_MessageType::SetFocus) |
109 IFWL_Widget* m_pKillFocus; | 142 IFWL_Widget* m_pKillFocus; |
110 END_FWL_MESSAGE_DEF | 143 END_FWL_MESSAGE_DEF |
111 | 144 |
112 BEGIN_FWL_MESSAGE_DEF(CFWL_MsgKillFocus, FWL_MSGHASH_KillFocus) | 145 BEGIN_FWL_MESSAGE_DEF(CFWL_MsgKillFocus, CFWL_MessageType::KillFocus) |
113 IFWL_Widget* m_pSetFocus; | 146 IFWL_Widget* m_pSetFocus; |
114 END_FWL_MESSAGE_DEF | 147 END_FWL_MESSAGE_DEF |
115 | 148 |
116 BEGIN_FWL_MESSAGE_DEF(CFWL_MsgKey, FWL_MSGHASH_Key) | 149 BEGIN_FWL_MESSAGE_DEF(CFWL_MsgKey, CFWL_MessageType::Key) |
117 uint32_t m_dwKeyCode; | 150 uint32_t m_dwKeyCode; |
118 uint32_t m_dwFlags; | 151 uint32_t m_dwFlags; |
119 uint32_t m_dwCmd; | 152 uint32_t m_dwCmd; |
120 END_FWL_MESSAGE_DEF | 153 END_FWL_MESSAGE_DEF |
121 | 154 |
122 BEGIN_FWL_MESSAGE_DEF(CFWL_MsgCursor, FWL_MSGHASH_Cursor) | 155 BEGIN_FWL_MESSAGE_DEF(CFWL_MsgCursor, CFWL_MessageType::Cursor) |
123 END_FWL_MESSAGE_DEF | 156 END_FWL_MESSAGE_DEF |
124 | 157 |
125 BEGIN_FWL_MESSAGE_DEF(CFWL_MsgSize, FWL_MSGHASH_Size) | 158 BEGIN_FWL_MESSAGE_DEF(CFWL_MsgSize, CFWL_MessageType::Size) |
126 int32_t m_iWidth; | 159 int32_t m_iWidth; |
127 int32_t m_iHeight; | 160 int32_t m_iHeight; |
128 END_FWL_MESSAGE_DEF | 161 END_FWL_MESSAGE_DEF |
129 | 162 |
130 BEGIN_FWL_MESSAGE_DEF(CFWL_MsgWindowMove, FWL_MSGHASH_WindowMove) | 163 BEGIN_FWL_MESSAGE_DEF(CFWL_MsgWindowMove, CFWL_MessageType::WindowMove) |
131 FX_FLOAT m_fx; | 164 FX_FLOAT m_fx; |
132 FX_FLOAT m_fy; | 165 FX_FLOAT m_fy; |
133 END_FWL_MESSAGE_DEF | 166 END_FWL_MESSAGE_DEF |
134 | 167 |
135 BEGIN_FWL_MESSAGE_DEF(CFWL_MsgDropFiles, FWL_MSGHASH_DropFiles) | 168 BEGIN_FWL_MESSAGE_DEF(CFWL_MsgDropFiles, CFWL_MessageType::DropFiles) |
136 CFWL_MsgDropFiles(const CFWL_MsgDropFiles& copy) { | 169 CFWL_MsgDropFiles(const CFWL_MsgDropFiles& copy) { |
137 m_pDstTarget = copy.m_pDstTarget; | 170 m_pDstTarget = copy.m_pDstTarget; |
138 m_pSrcTarget = copy.m_pSrcTarget; | 171 m_pSrcTarget = copy.m_pSrcTarget; |
139 m_fx = copy.m_fx; | 172 m_fx = copy.m_fx; |
140 m_fy = copy.m_fy; | 173 m_fy = copy.m_fy; |
141 m_files.Append(copy.m_files); | 174 m_files.Append(copy.m_files); |
142 } | 175 } |
143 FX_FLOAT m_fx; | 176 FX_FLOAT m_fx; |
144 FX_FLOAT m_fy; | 177 FX_FLOAT m_fy; |
145 CFX_WideStringArray m_files; | 178 CFX_WideStringArray m_files; |
146 END_FWL_MESSAGE_DEF | 179 END_FWL_MESSAGE_DEF |
147 | 180 |
148 BEGIN_FWL_MESSAGE_DEF(CFWL_MsgTaskClicked, FWL_MSGHASH_TaskClicked) | 181 BEGIN_FWL_MESSAGE_DEF(CFWL_MsgTaskClicked, CFWL_MessageType::TaskClicked) |
149 FX_FLOAT m_fx; | 182 FX_FLOAT m_fx; |
150 FX_FLOAT m_fy; | 183 FX_FLOAT m_fy; |
151 END_FWL_MESSAGE_DEF | 184 END_FWL_MESSAGE_DEF |
152 | 185 |
153 BEGIN_FWL_MESSAGE_DEF(CFWL_MsgClose, FWL_MSGHASH_Close) | 186 BEGIN_FWL_MESSAGE_DEF(CFWL_MsgClose, CFWL_MessageType::Close) |
154 END_FWL_MESSAGE_DEF | 187 END_FWL_MESSAGE_DEF |
155 | 188 |
156 BEGIN_FWL_MESSAGE_DEF(CFWL_MsgWindowWillMove, FWL_MSGHASH_WindowWillMove) | 189 BEGIN_FWL_MESSAGE_DEF(CFWL_MsgWindowWillMove, CFWL_MessageType::WindowWillMove) |
157 END_FWL_MESSAGE_DEF | 190 END_FWL_MESSAGE_DEF |
158 | 191 |
159 #endif // XFA_FWL_CORE_CFWL_MESSAGE_H_ | 192 #endif // XFA_FWL_CORE_CFWL_MESSAGE_H_ |
OLD | NEW |