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" |
(...skipping 40 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
51 enum class FWL_KeyCommand { KeyDown, KeyUp, Char }; | 51 enum class FWL_KeyCommand { KeyDown, KeyUp, Char }; |
52 | 52 |
53 class IFWL_Widget; | 53 class IFWL_Widget; |
54 | 54 |
55 class CFWL_Message { | 55 class CFWL_Message { |
56 public: | 56 public: |
57 CFWL_Message(); | 57 CFWL_Message(); |
58 virtual ~CFWL_Message(); | 58 virtual ~CFWL_Message(); |
59 | 59 |
60 virtual CFWL_Message* Clone(); | 60 virtual CFWL_Message* Clone(); |
61 virtual FWL_Error GetClassName(CFX_WideString& wsClass) const; | |
62 virtual CFWL_MessageType GetClassID() const; | 61 virtual CFWL_MessageType GetClassID() const; |
63 | 62 |
64 uint32_t Release(); | 63 uint32_t Release(); |
65 CFWL_Message* Retain(); | 64 CFWL_Message* Retain(); |
66 | 65 |
67 IFWL_Widget* m_pSrcTarget; | 66 IFWL_Widget* m_pSrcTarget; |
68 IFWL_Widget* m_pDstTarget; | 67 IFWL_Widget* m_pDstTarget; |
69 uint32_t m_dwExtend; | 68 uint32_t m_dwExtend; |
70 | 69 |
71 private: | 70 private: |
72 uint32_t m_dwRefCount; | 71 uint32_t m_dwRefCount; |
73 }; | 72 }; |
74 | 73 |
75 inline CFWL_Message::CFWL_Message() | 74 inline CFWL_Message::CFWL_Message() |
76 : m_pSrcTarget(nullptr), | 75 : m_pSrcTarget(nullptr), |
77 m_pDstTarget(nullptr), | 76 m_pDstTarget(nullptr), |
78 m_dwExtend(0), | 77 m_dwExtend(0), |
79 m_dwRefCount(1) {} | 78 m_dwRefCount(1) {} |
80 | 79 |
81 inline CFWL_Message::~CFWL_Message() {} | 80 inline CFWL_Message::~CFWL_Message() {} |
82 | 81 |
83 inline CFWL_Message* CFWL_Message::Clone() { | 82 inline CFWL_Message* CFWL_Message::Clone() { |
84 return nullptr; | 83 return nullptr; |
85 } | 84 } |
86 | 85 |
87 inline FWL_Error CFWL_Message::GetClassName(CFX_WideString& wsClass) const { | |
88 return FWL_Error::Succeeded; | |
89 } | |
90 | |
91 inline CFWL_MessageType CFWL_Message::GetClassID() const { | 86 inline CFWL_MessageType CFWL_Message::GetClassID() const { |
92 return CFWL_MessageType::None; | 87 return CFWL_MessageType::None; |
93 } | 88 } |
94 | 89 |
95 inline uint32_t CFWL_Message::Release() { | 90 inline uint32_t CFWL_Message::Release() { |
96 m_dwRefCount--; | 91 m_dwRefCount--; |
97 uint32_t dwRefCount = m_dwRefCount; | 92 uint32_t dwRefCount = m_dwRefCount; |
98 if (!m_dwRefCount) | 93 if (!m_dwRefCount) |
99 delete this; | 94 delete this; |
100 return dwRefCount; | 95 return dwRefCount; |
101 } | 96 } |
102 | 97 |
103 inline CFWL_Message* CFWL_Message::Retain() { | 98 inline CFWL_Message* CFWL_Message::Retain() { |
104 m_dwRefCount++; | 99 m_dwRefCount++; |
105 return this; | 100 return this; |
106 } | 101 } |
107 | 102 |
108 #define FWL_MESSAGE_CLASS_DEF(classname, msgType, ...) \ | 103 #define FWL_MESSAGE_CLASS_DEF(classname, msgType, ...) \ |
109 class classname : public CFWL_Message { \ | 104 class classname : public CFWL_Message { \ |
110 public: \ | 105 public: \ |
111 classname(); \ | 106 classname(); \ |
112 ~classname() override; \ | 107 ~classname() override; \ |
113 CFWL_Message* Clone() override; \ | 108 CFWL_Message* Clone() override; \ |
114 FWL_Error GetClassName(CFX_WideString& wsClass) const override; \ | |
115 CFWL_MessageType GetClassID() const override; \ | 109 CFWL_MessageType GetClassID() const override; \ |
116 __VA_ARGS__ \ | 110 __VA_ARGS__ \ |
117 }; | 111 }; |
118 | 112 |
119 #define FWL_MESSAGE_FUNCTION_DEF(classname, msgType, ...) \ | 113 #define FWL_MESSAGE_FUNCTION_DEF(classname, msgType, ...) \ |
120 inline classname::classname() {} \ | 114 inline classname::classname() {} \ |
121 inline classname::~classname() {} \ | 115 inline classname::~classname() {} \ |
122 inline CFWL_Message* classname::Clone() { return new classname(*this); } \ | 116 inline CFWL_Message* classname::Clone() { return new classname(*this); } \ |
123 inline FWL_Error classname::GetClassName(CFX_WideString& wsClass) const { \ | |
124 wsClass = L## #classname; \ | |
125 return FWL_Error::Succeeded; \ | |
126 } \ | |
127 inline CFWL_MessageType classname::GetClassID() const { return msgType; } \ | 117 inline CFWL_MessageType classname::GetClassID() const { return msgType; } \ |
128 __VA_ARGS__ | 118 __VA_ARGS__ |
129 | 119 |
130 #define FWL_MESSAGE_DEF(classname, msgType, ...) \ | 120 #define FWL_MESSAGE_DEF(classname, msgType, ...) \ |
131 FWL_MESSAGE_CLASS_DEF(classname, msgType, __VA_ARGS__) \ | 121 FWL_MESSAGE_CLASS_DEF(classname, msgType, __VA_ARGS__) \ |
132 FWL_MESSAGE_FUNCTION_DEF(classname, msgType) | 122 FWL_MESSAGE_FUNCTION_DEF(classname, msgType) |
133 | 123 |
134 FWL_MESSAGE_DEF(CFWL_MsgActivate, CFWL_MessageType::Activate) | 124 FWL_MESSAGE_DEF(CFWL_MsgActivate, CFWL_MessageType::Activate) |
135 | 125 |
136 FWL_MESSAGE_DEF(CFWL_MsgDeactivate, CFWL_MessageType::Deactivate) | 126 FWL_MESSAGE_DEF(CFWL_MsgDeactivate, CFWL_MessageType::Deactivate) |
(...skipping 49 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
186 FWL_MESSAGE_DEF(CFWL_MsgTaskClicked, | 176 FWL_MESSAGE_DEF(CFWL_MsgTaskClicked, |
187 CFWL_MessageType::TaskClicked, | 177 CFWL_MessageType::TaskClicked, |
188 FX_FLOAT m_fx; | 178 FX_FLOAT m_fx; |
189 FX_FLOAT m_fy;) | 179 FX_FLOAT m_fy;) |
190 | 180 |
191 FWL_MESSAGE_DEF(CFWL_MsgClose, CFWL_MessageType::Close) | 181 FWL_MESSAGE_DEF(CFWL_MsgClose, CFWL_MessageType::Close) |
192 | 182 |
193 FWL_MESSAGE_DEF(CFWL_MsgWindowWillMove, CFWL_MessageType::WindowWillMove) | 183 FWL_MESSAGE_DEF(CFWL_MsgWindowWillMove, CFWL_MessageType::WindowWillMove) |
194 | 184 |
195 #endif // XFA_FWL_CORE_CFWL_MESSAGE_H_ | 185 #endif // XFA_FWL_CORE_CFWL_MESSAGE_H_ |
OLD | NEW |