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

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

Issue 2070583003: Make code compile with clang_use_chrome_plugin (part VI) (Closed) Base URL: https://pdfium.googlesource.com/pdfium.git@master
Patch Set: better macros Created 4 years, 6 months 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
« no previous file with comments | « xfa/fwl/core/cfwl_event.h ('k') | xfa/fwl/core/cfwl_themepart.h » ('j') | no next file with comments »
Toggle Intra-line Diffs ('i') | Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
OLDNEW
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"
(...skipping 35 matching lines...) Expand 10 before | Expand all | Expand 10 after
46 Leave, 46 Leave,
47 Hover 47 Hover
48 }; 48 };
49 49
50 enum class FWL_KeyCommand { KeyDown, KeyUp, Char }; 50 enum class FWL_KeyCommand { KeyDown, KeyUp, Char };
51 51
52 class IFWL_Widget; 52 class IFWL_Widget;
53 53
54 class CFWL_Message { 54 class CFWL_Message {
55 public: 55 public:
56 CFWL_Message() 56 CFWL_Message();
57 : m_pSrcTarget(nullptr), 57 virtual ~CFWL_Message();
58 m_pDstTarget(nullptr),
59 m_dwExtend(0),
60 m_dwRefCount(1) {}
61 virtual ~CFWL_Message() {}
62 58
63 virtual CFWL_Message* Clone() { return nullptr; } 59 virtual CFWL_Message* Clone();
64 virtual FWL_Error GetClassName(CFX_WideString& wsClass) const { 60 virtual FWL_Error GetClassName(CFX_WideString& wsClass) const;
65 return FWL_Error::Succeeded; 61 virtual CFWL_MessageType GetClassID() const;
66 }
67 virtual CFWL_MessageType GetClassID() const { return CFWL_MessageType::None; }
68 62
69 uint32_t Release() { 63 uint32_t Release();
70 m_dwRefCount--; 64 CFWL_Message* Retain();
71 uint32_t dwRefCount = m_dwRefCount;
72 if (!m_dwRefCount)
73 delete this;
74 return dwRefCount;
75 }
76
77 CFWL_Message* Retain() {
78 m_dwRefCount++;
79 return this;
80 }
81 65
82 IFWL_Widget* m_pSrcTarget; 66 IFWL_Widget* m_pSrcTarget;
83 IFWL_Widget* m_pDstTarget; 67 IFWL_Widget* m_pDstTarget;
84 uint32_t m_dwExtend; 68 uint32_t m_dwExtend;
85 69
86 private: 70 private:
87 uint32_t m_dwRefCount; 71 uint32_t m_dwRefCount;
88 }; 72 };
89 73
90 #define BEGIN_FWL_MESSAGE_DEF(classname, msgType) \ 74 inline CFWL_Message::CFWL_Message()
91 class classname : public CFWL_Message { \ 75 : m_pSrcTarget(nullptr),
92 public: \ 76 m_pDstTarget(nullptr),
93 classname() : CFWL_Message() {} \ 77 m_dwExtend(0),
94 CFWL_Message* Clone() override { return new classname(*this); } \ 78 m_dwRefCount(1) {}
95 FWL_Error GetClassName(CFX_WideString& wsClass) const override { \
96 wsClass = L## #classname; \
97 return FWL_Error::Succeeded; \
98 } \
99 CFWL_MessageType GetClassID() const override { return msgType; }
100 79
101 #define END_FWL_MESSAGE_DEF \ 80 inline CFWL_Message::~CFWL_Message() {}
102 } \
103 ; // NOLINT
104 81
105 BEGIN_FWL_MESSAGE_DEF(CFWL_MsgActivate, CFWL_MessageType::Activate) 82 inline CFWL_Message* CFWL_Message::Clone() {
106 END_FWL_MESSAGE_DEF 83 return nullptr;
84 }
107 85
108 BEGIN_FWL_MESSAGE_DEF(CFWL_MsgDeactivate, CFWL_MessageType::Deactivate) 86 inline FWL_Error CFWL_Message::GetClassName(CFX_WideString& wsClass) const {
109 END_FWL_MESSAGE_DEF 87 return FWL_Error::Succeeded;
88 }
110 89
111 BEGIN_FWL_MESSAGE_DEF(CFWL_MsgMouse, CFWL_MessageType::Mouse) 90 inline CFWL_MessageType CFWL_Message::GetClassID() const {
112 FX_FLOAT m_fx; 91 return CFWL_MessageType::None;
113 FX_FLOAT m_fy; 92 }
114 uint32_t m_dwFlags;
115 FWL_MouseCommand m_dwCmd;
116 END_FWL_MESSAGE_DEF
117 93
118 BEGIN_FWL_MESSAGE_DEF(CFWL_MsgMouseWheel, CFWL_MessageType::MouseWheel) 94 inline uint32_t CFWL_Message::Release() {
119 FX_FLOAT m_fx; 95 m_dwRefCount--;
120 FX_FLOAT m_fy; 96 uint32_t dwRefCount = m_dwRefCount;
121 FX_FLOAT m_fDeltaX; 97 if (!m_dwRefCount)
122 FX_FLOAT m_fDeltaY; 98 delete this;
123 uint32_t m_dwFlags; 99 return dwRefCount;
124 END_FWL_MESSAGE_DEF 100 }
125 101
126 BEGIN_FWL_MESSAGE_DEF(CFWL_MsgSetFocus, CFWL_MessageType::SetFocus) 102 inline CFWL_Message* CFWL_Message::Retain() {
127 IFWL_Widget* m_pKillFocus; 103 m_dwRefCount++;
128 END_FWL_MESSAGE_DEF 104 return this;
105 }
129 106
130 BEGIN_FWL_MESSAGE_DEF(CFWL_MsgKillFocus, CFWL_MessageType::KillFocus) 107 #define FWL_MESSAGE_CLASS_DEF(classname, msgType, ...) \
131 IFWL_Widget* m_pSetFocus; 108 class classname : public CFWL_Message { \
132 END_FWL_MESSAGE_DEF 109 public: \
110 classname(); \
111 ~classname() override; \
112 CFWL_Message* Clone() override; \
113 FWL_Error GetClassName(CFX_WideString& wsClass) const override; \
114 CFWL_MessageType GetClassID() const override; \
115 __VA_ARGS__ \
116 };
133 117
134 BEGIN_FWL_MESSAGE_DEF(CFWL_MsgKey, CFWL_MessageType::Key) 118 #define FWL_MESSAGE_FUNCTION_DEF(classname, msgType, ...) \
135 uint32_t m_dwKeyCode; 119 inline classname::classname() {} \
136 uint32_t m_dwFlags; 120 inline classname::~classname() {} \
137 FWL_KeyCommand m_dwCmd; 121 inline CFWL_Message* classname::Clone() { return new classname(*this); } \
138 END_FWL_MESSAGE_DEF 122 inline FWL_Error classname::GetClassName(CFX_WideString& wsClass) const { \
123 wsClass = L## #classname; \
124 return FWL_Error::Succeeded; \
125 } \
126 inline CFWL_MessageType classname::GetClassID() const { return msgType; } \
127 __VA_ARGS__
139 128
140 BEGIN_FWL_MESSAGE_DEF(CFWL_MsgCursor, CFWL_MessageType::Cursor) 129 #define FWL_MESSAGE_DEF(classname, msgType, ...) \
141 END_FWL_MESSAGE_DEF 130 FWL_MESSAGE_CLASS_DEF(classname, msgType, __VA_ARGS__) \
131 FWL_MESSAGE_FUNCTION_DEF(classname, msgType)
142 132
143 BEGIN_FWL_MESSAGE_DEF(CFWL_MsgSize, CFWL_MessageType::Size) 133 FWL_MESSAGE_DEF(CFWL_MsgActivate, CFWL_MessageType::Activate)
144 int32_t m_iWidth;
145 int32_t m_iHeight;
146 END_FWL_MESSAGE_DEF
147 134
148 BEGIN_FWL_MESSAGE_DEF(CFWL_MsgWindowMove, CFWL_MessageType::WindowMove) 135 FWL_MESSAGE_DEF(CFWL_MsgDeactivate, CFWL_MessageType::Deactivate)
149 FX_FLOAT m_fx;
150 FX_FLOAT m_fy;
151 END_FWL_MESSAGE_DEF
152 136
153 BEGIN_FWL_MESSAGE_DEF(CFWL_MsgDropFiles, CFWL_MessageType::DropFiles) 137 FWL_MESSAGE_DEF(CFWL_MsgMouse, CFWL_MessageType::Mouse, FX_FLOAT m_fx;
154 CFWL_MsgDropFiles(const CFWL_MsgDropFiles& copy) { 138 FX_FLOAT m_fy;
155 m_pDstTarget = copy.m_pDstTarget; 139 uint32_t m_dwFlags;
156 m_pSrcTarget = copy.m_pSrcTarget; 140 FWL_MouseCommand m_dwCmd;)
157 m_fx = copy.m_fx;
158 m_fy = copy.m_fy;
159 m_files.Append(copy.m_files);
160 }
161 FX_FLOAT m_fx;
162 FX_FLOAT m_fy;
163 CFX_WideStringArray m_files;
164 END_FWL_MESSAGE_DEF
165 141
166 BEGIN_FWL_MESSAGE_DEF(CFWL_MsgTaskClicked, CFWL_MessageType::TaskClicked) 142 FWL_MESSAGE_DEF(CFWL_MsgMouseWheel, CFWL_MessageType::MouseWheel, FX_FLOAT m_fx;
167 FX_FLOAT m_fx; 143 FX_FLOAT m_fy;
168 FX_FLOAT m_fy; 144 FX_FLOAT m_fDeltaX;
169 END_FWL_MESSAGE_DEF 145 FX_FLOAT m_fDeltaY;
146 uint32_t m_dwFlags;)
170 147
171 BEGIN_FWL_MESSAGE_DEF(CFWL_MsgClose, CFWL_MessageType::Close) 148 FWL_MESSAGE_DEF(CFWL_MsgSetFocus,
172 END_FWL_MESSAGE_DEF 149 CFWL_MessageType::SetFocus,
150 IFWL_Widget* m_pKillFocus;)
173 151
174 BEGIN_FWL_MESSAGE_DEF(CFWL_MsgWindowWillMove, CFWL_MessageType::WindowWillMove) 152 FWL_MESSAGE_DEF(CFWL_MsgKillFocus,
175 END_FWL_MESSAGE_DEF 153 CFWL_MessageType::KillFocus,
154 IFWL_Widget* m_pSetFocus;)
155
156 FWL_MESSAGE_DEF(CFWL_MsgKey, CFWL_MessageType::Key, uint32_t m_dwKeyCode;
157 uint32_t m_dwFlags;
158 FWL_KeyCommand m_dwCmd;)
159
160 FWL_MESSAGE_DEF(CFWL_MsgCursor, CFWL_MessageType::Cursor)
161
162 FWL_MESSAGE_DEF(CFWL_MsgSize, CFWL_MessageType::Size, int32_t m_iWidth;
163 int32_t m_iHeight;)
164
165 FWL_MESSAGE_DEF(CFWL_MsgWindowMove, CFWL_MessageType::WindowMove, FX_FLOAT m_fx;
166 FX_FLOAT m_fy;)
167
168 FWL_MESSAGE_CLASS_DEF(CFWL_MsgDropFiles,
169 CFWL_MessageType::DropFiles,
170 CFWL_MsgDropFiles(const CFWL_MsgDropFiles& copy);
171 FX_FLOAT m_fx;
172 FX_FLOAT m_fy;
173 CFX_WideStringArray m_files;)
174 FWL_MESSAGE_FUNCTION_DEF(
175 CFWL_MsgDropFiles,
176 CFWL_MessageType::DropFiles,
177 inline CFWL_MsgDropFiles::CFWL_MsgDropFiles(const CFWL_MsgDropFiles& copy) {
178 m_pDstTarget = copy.m_pDstTarget;
179 m_pSrcTarget = copy.m_pSrcTarget;
180 m_fx = copy.m_fx;
181 m_fy = copy.m_fy;
182 m_files.Append(copy.m_files);
183 })
184
185 FWL_MESSAGE_DEF(CFWL_MsgTaskClicked,
186 CFWL_MessageType::TaskClicked,
187 FX_FLOAT m_fx;
188 FX_FLOAT m_fy;)
189
190 FWL_MESSAGE_DEF(CFWL_MsgClose, CFWL_MessageType::Close)
191
192 FWL_MESSAGE_DEF(CFWL_MsgWindowWillMove, CFWL_MessageType::WindowWillMove)
176 193
177 #endif // XFA_FWL_CORE_CFWL_MESSAGE_H_ 194 #endif // XFA_FWL_CORE_CFWL_MESSAGE_H_
OLDNEW
« no previous file with comments | « xfa/fwl/core/cfwl_event.h ('k') | xfa/fwl/core/cfwl_themepart.h » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698