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

Side by Side Diff: xfa/fwl/core/cfwl_notedriver.cpp

Issue 2524173002: Merge IFWL and CFWL classes. (Closed)
Patch Set: make chrome build happy Created 4 years 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 #include "xfa/fwl/core/cfwl_notedriver.h" 7 #include "xfa/fwl/core/cfwl_notedriver.h"
8 8
9 #include <utility> 9 #include <utility>
10 10
(...skipping 27 matching lines...) Expand all
38 if (m_eventTargets.empty()) 38 if (m_eventTargets.empty())
39 return; 39 return;
40 40
41 for (const auto& pair : m_eventTargets) { 41 for (const auto& pair : m_eventTargets) {
42 CFWL_EventTarget* pEventTarget = pair.second; 42 CFWL_EventTarget* pEventTarget = pair.second;
43 if (pEventTarget && !pEventTarget->IsInvalid()) 43 if (pEventTarget && !pEventTarget->IsInvalid())
44 pEventTarget->ProcessEvent(pNote); 44 pEventTarget->ProcessEvent(pNote);
45 } 45 }
46 } 46 }
47 47
48 void CFWL_NoteDriver::RegisterEventTarget(IFWL_Widget* pListener, 48 void CFWL_NoteDriver::RegisterEventTarget(CFWL_Widget* pListener,
49 IFWL_Widget* pEventSource) { 49 CFWL_Widget* pEventSource) {
50 uint32_t key = pListener->GetEventKey(); 50 uint32_t key = pListener->GetEventKey();
51 if (key == 0) { 51 if (key == 0) {
52 do { 52 do {
53 key = rand(); 53 key = rand();
54 } while (key == 0 || pdfium::ContainsKey(m_eventTargets, key)); 54 } while (key == 0 || pdfium::ContainsKey(m_eventTargets, key));
55 pListener->SetEventKey(key); 55 pListener->SetEventKey(key);
56 } 56 }
57 if (!m_eventTargets[key]) 57 if (!m_eventTargets[key])
58 m_eventTargets[key] = new CFWL_EventTarget(pListener); 58 m_eventTargets[key] = new CFWL_EventTarget(pListener);
59 59
60 m_eventTargets[key]->SetEventSource(pEventSource); 60 m_eventTargets[key]->SetEventSource(pEventSource);
61 } 61 }
62 62
63 void CFWL_NoteDriver::UnregisterEventTarget(IFWL_Widget* pListener) { 63 void CFWL_NoteDriver::UnregisterEventTarget(CFWL_Widget* pListener) {
64 uint32_t key = pListener->GetEventKey(); 64 uint32_t key = pListener->GetEventKey();
65 if (key == 0) 65 if (key == 0)
66 return; 66 return;
67 67
68 auto it = m_eventTargets.find(key); 68 auto it = m_eventTargets.find(key);
69 if (it != m_eventTargets.end()) 69 if (it != m_eventTargets.end())
70 it->second->FlagInvalid(); 70 it->second->FlagInvalid();
71 } 71 }
72 72
73 void CFWL_NoteDriver::PushNoteLoop(CFWL_NoteLoop* pNoteLoop) { 73 void CFWL_NoteDriver::PushNoteLoop(CFWL_NoteLoop* pNoteLoop) {
74 m_noteLoopQueue.Add(pNoteLoop); 74 m_noteLoopQueue.Add(pNoteLoop);
75 } 75 }
76 76
77 CFWL_NoteLoop* CFWL_NoteDriver::PopNoteLoop() { 77 CFWL_NoteLoop* CFWL_NoteDriver::PopNoteLoop() {
78 int32_t pos = m_noteLoopQueue.GetSize(); 78 int32_t pos = m_noteLoopQueue.GetSize();
79 if (pos <= 0) 79 if (pos <= 0)
80 return nullptr; 80 return nullptr;
81 81
82 CFWL_NoteLoop* p = m_noteLoopQueue.GetAt(pos - 1); 82 CFWL_NoteLoop* p = m_noteLoopQueue.GetAt(pos - 1);
83 m_noteLoopQueue.RemoveAt(pos - 1); 83 m_noteLoopQueue.RemoveAt(pos - 1);
84 return p; 84 return p;
85 } 85 }
86 86
87 bool CFWL_NoteDriver::SetFocus(IFWL_Widget* pFocus, bool bNotify) { 87 bool CFWL_NoteDriver::SetFocus(CFWL_Widget* pFocus, bool bNotify) {
88 if (m_pFocus == pFocus) 88 if (m_pFocus == pFocus)
89 return true; 89 return true;
90 90
91 IFWL_Widget* pPrev = m_pFocus; 91 CFWL_Widget* pPrev = m_pFocus;
92 m_pFocus = pFocus; 92 m_pFocus = pFocus;
93 if (pPrev) { 93 if (pPrev) {
94 CFWL_MsgKillFocus ms; 94 CFWL_MsgKillFocus ms;
95 ms.m_pDstTarget = pPrev; 95 ms.m_pDstTarget = pPrev;
96 ms.m_pSrcTarget = pPrev; 96 ms.m_pSrcTarget = pPrev;
97 if (bNotify) 97 if (bNotify)
98 ms.m_dwExtend = 1; 98 ms.m_dwExtend = 1;
99 99
100 if (IFWL_WidgetDelegate* pDelegate = pPrev->GetDelegate()) 100 if (IFWL_WidgetDelegate* pDelegate = pPrev->GetDelegate())
101 pDelegate->OnProcessMessage(&ms); 101 pDelegate->OnProcessMessage(&ms);
102 } 102 }
103 if (pFocus) { 103 if (pFocus) {
104 IFWL_Widget* pWidget = 104 CFWL_Widget* pWidget =
105 pFocus->GetOwnerApp()->GetWidgetMgr()->GetSystemFormWidget(pFocus); 105 pFocus->GetOwnerApp()->GetWidgetMgr()->GetSystemFormWidget(pFocus);
106 CFWL_Form* pForm = static_cast<CFWL_Form*>(pWidget); 106 CFWL_Form* pForm = static_cast<CFWL_Form*>(pWidget);
107 if (pForm) 107 if (pForm)
108 pForm->SetSubFocus(pFocus); 108 pForm->SetSubFocus(pFocus);
109 109
110 CFWL_MsgSetFocus ms; 110 CFWL_MsgSetFocus ms;
111 ms.m_pDstTarget = pFocus; 111 ms.m_pDstTarget = pFocus;
112 if (bNotify) 112 if (bNotify)
113 ms.m_dwExtend = 1; 113 ms.m_dwExtend = 1;
114 if (IFWL_WidgetDelegate* pDelegate = pFocus->GetDelegate()) 114 if (IFWL_WidgetDelegate* pDelegate = pFocus->GetDelegate())
115 pDelegate->OnProcessMessage(&ms); 115 pDelegate->OnProcessMessage(&ms);
116 } 116 }
117 return true; 117 return true;
118 } 118 }
119 119
120 void CFWL_NoteDriver::Run() { 120 void CFWL_NoteDriver::Run() {
121 #if (_FX_OS_ == _FX_LINUX_DESKTOP_ || _FX_OS_ == _FX_WIN32_DESKTOP_ || \ 121 #if (_FX_OS_ == _FX_LINUX_DESKTOP_ || _FX_OS_ == _FX_WIN32_DESKTOP_ || \
122 _FX_OS_ == _FX_WIN64_) 122 _FX_OS_ == _FX_WIN64_)
123 for (;;) { 123 for (;;) {
124 CFWL_NoteLoop* pTopLoop = GetTopLoop(); 124 CFWL_NoteLoop* pTopLoop = GetTopLoop();
125 if (!pTopLoop || !pTopLoop->ContinueModal()) 125 if (!pTopLoop || !pTopLoop->ContinueModal())
126 break; 126 break;
127 UnqueueMessage(pTopLoop); 127 UnqueueMessage(pTopLoop);
128 } 128 }
129 #endif 129 #endif
130 } 130 }
131 131
132 void CFWL_NoteDriver::NotifyTargetHide(IFWL_Widget* pNoteTarget) { 132 void CFWL_NoteDriver::NotifyTargetHide(CFWL_Widget* pNoteTarget) {
133 if (m_pFocus == pNoteTarget) 133 if (m_pFocus == pNoteTarget)
134 m_pFocus = nullptr; 134 m_pFocus = nullptr;
135 if (m_pHover == pNoteTarget) 135 if (m_pHover == pNoteTarget)
136 m_pHover = nullptr; 136 m_pHover = nullptr;
137 if (m_pGrab == pNoteTarget) 137 if (m_pGrab == pNoteTarget)
138 m_pGrab = nullptr; 138 m_pGrab = nullptr;
139 } 139 }
140 140
141 void CFWL_NoteDriver::NotifyTargetDestroy(IFWL_Widget* pNoteTarget) { 141 void CFWL_NoteDriver::NotifyTargetDestroy(CFWL_Widget* pNoteTarget) {
142 if (m_pFocus == pNoteTarget) 142 if (m_pFocus == pNoteTarget)
143 m_pFocus = nullptr; 143 m_pFocus = nullptr;
144 if (m_pHover == pNoteTarget) 144 if (m_pHover == pNoteTarget)
145 m_pHover = nullptr; 145 m_pHover = nullptr;
146 if (m_pGrab == pNoteTarget) 146 if (m_pGrab == pNoteTarget)
147 m_pGrab = nullptr; 147 m_pGrab = nullptr;
148 148
149 UnregisterEventTarget(pNoteTarget); 149 UnregisterEventTarget(pNoteTarget);
150 150
151 for (int32_t nIndex = 0; nIndex < m_forms.GetSize(); nIndex++) { 151 for (int32_t nIndex = 0; nIndex < m_forms.GetSize(); nIndex++) {
152 CFWL_Form* pForm = static_cast<CFWL_Form*>(m_forms[nIndex]); 152 CFWL_Form* pForm = static_cast<CFWL_Form*>(m_forms[nIndex]);
153 if (!pForm) 153 if (!pForm)
154 continue; 154 continue;
155 155
156 IFWL_Widget* pSubFocus = pForm->GetSubFocus(); 156 CFWL_Widget* pSubFocus = pForm->GetSubFocus();
157 if (!pSubFocus) 157 if (!pSubFocus)
158 return; 158 return;
159 if (pSubFocus == pNoteTarget) 159 if (pSubFocus == pNoteTarget)
160 pForm->SetSubFocus(nullptr); 160 pForm->SetSubFocus(nullptr);
161 } 161 }
162 } 162 }
163 163
164 void CFWL_NoteDriver::RegisterForm(IFWL_Widget* pForm) { 164 void CFWL_NoteDriver::RegisterForm(CFWL_Widget* pForm) {
165 if (!pForm || m_forms.Find(pForm) >= 0) 165 if (!pForm || m_forms.Find(pForm) >= 0)
166 return; 166 return;
167 167
168 m_forms.Add(pForm); 168 m_forms.Add(pForm);
169 if (m_forms.GetSize() != 1) 169 if (m_forms.GetSize() != 1)
170 return; 170 return;
171 171
172 CFWL_NoteLoop* pLoop = m_noteLoopQueue.GetAt(0); 172 CFWL_NoteLoop* pLoop = m_noteLoopQueue.GetAt(0);
173 if (!pLoop) 173 if (!pLoop)
174 return; 174 return;
175 175
176 pLoop->SetMainForm(pForm); 176 pLoop->SetMainForm(pForm);
177 } 177 }
178 178
179 void CFWL_NoteDriver::UnRegisterForm(IFWL_Widget* pForm) { 179 void CFWL_NoteDriver::UnRegisterForm(CFWL_Widget* pForm) {
180 if (!pForm) 180 if (!pForm)
181 return; 181 return;
182 182
183 int32_t nIndex = m_forms.Find(pForm); 183 int32_t nIndex = m_forms.Find(pForm);
184 if (nIndex < 0) 184 if (nIndex < 0)
185 return; 185 return;
186 186
187 m_forms.RemoveAt(nIndex); 187 m_forms.RemoveAt(nIndex);
188 } 188 }
189 189
(...skipping 17 matching lines...) Expand all
207 CFWL_NoteLoop* CFWL_NoteDriver::GetTopLoop() const { 207 CFWL_NoteLoop* CFWL_NoteDriver::GetTopLoop() const {
208 int32_t size = m_noteLoopQueue.GetSize(); 208 int32_t size = m_noteLoopQueue.GetSize();
209 if (size <= 0) 209 if (size <= 0)
210 return nullptr; 210 return nullptr;
211 return m_noteLoopQueue[size - 1]; 211 return m_noteLoopQueue[size - 1];
212 } 212 }
213 213
214 void CFWL_NoteDriver::ProcessMessage(CFWL_Message* pMessage) { 214 void CFWL_NoteDriver::ProcessMessage(CFWL_Message* pMessage) {
215 CFWL_WidgetMgr* pWidgetMgr = 215 CFWL_WidgetMgr* pWidgetMgr =
216 pMessage->m_pDstTarget->GetOwnerApp()->GetWidgetMgr(); 216 pMessage->m_pDstTarget->GetOwnerApp()->GetWidgetMgr();
217 IFWL_Widget* pMessageForm = pWidgetMgr->IsFormDisabled() 217 CFWL_Widget* pMessageForm = pWidgetMgr->IsFormDisabled()
218 ? pMessage->m_pDstTarget 218 ? pMessage->m_pDstTarget
219 : GetMessageForm(pMessage->m_pDstTarget); 219 : GetMessageForm(pMessage->m_pDstTarget);
220 if (!pMessageForm) 220 if (!pMessageForm)
221 return; 221 return;
222 if (!DispatchMessage(pMessage, pMessageForm)) 222 if (!DispatchMessage(pMessage, pMessageForm))
223 return; 223 return;
224 224
225 if (pMessage->GetClassID() == CFWL_MessageType::Mouse) 225 if (pMessage->GetClassID() == CFWL_MessageType::Mouse)
226 MouseSecondary(pMessage); 226 MouseSecondary(pMessage);
227 } 227 }
228 228
229 bool CFWL_NoteDriver::DispatchMessage(CFWL_Message* pMessage, 229 bool CFWL_NoteDriver::DispatchMessage(CFWL_Message* pMessage,
230 IFWL_Widget* pMessageForm) { 230 CFWL_Widget* pMessageForm) {
231 switch (pMessage->GetClassID()) { 231 switch (pMessage->GetClassID()) {
232 case CFWL_MessageType::SetFocus: { 232 case CFWL_MessageType::SetFocus: {
233 if (!DoSetFocus(pMessage, pMessageForm)) 233 if (!DoSetFocus(pMessage, pMessageForm))
234 return false; 234 return false;
235 break; 235 break;
236 } 236 }
237 case CFWL_MessageType::KillFocus: { 237 case CFWL_MessageType::KillFocus: {
238 if (!DoKillFocus(pMessage, pMessageForm)) 238 if (!DoKillFocus(pMessage, pMessageForm))
239 return false; 239 return false;
240 break; 240 break;
(...skipping 16 matching lines...) Expand all
257 default: 257 default:
258 break; 258 break;
259 } 259 }
260 if (IFWL_WidgetDelegate* pDelegate = pMessage->m_pDstTarget->GetDelegate()) 260 if (IFWL_WidgetDelegate* pDelegate = pMessage->m_pDstTarget->GetDelegate())
261 pDelegate->OnProcessMessage(pMessage); 261 pDelegate->OnProcessMessage(pMessage);
262 262
263 return true; 263 return true;
264 } 264 }
265 265
266 bool CFWL_NoteDriver::DoSetFocus(CFWL_Message* pMessage, 266 bool CFWL_NoteDriver::DoSetFocus(CFWL_Message* pMessage,
267 IFWL_Widget* pMessageForm) { 267 CFWL_Widget* pMessageForm) {
268 CFWL_WidgetMgr* pWidgetMgr = pMessageForm->GetOwnerApp()->GetWidgetMgr(); 268 CFWL_WidgetMgr* pWidgetMgr = pMessageForm->GetOwnerApp()->GetWidgetMgr();
269 if (pWidgetMgr->IsFormDisabled()) { 269 if (pWidgetMgr->IsFormDisabled()) {
270 m_pFocus = pMessage->m_pDstTarget; 270 m_pFocus = pMessage->m_pDstTarget;
271 return true; 271 return true;
272 } 272 }
273 273
274 IFWL_Widget* pWidget = pMessage->m_pDstTarget; 274 CFWL_Widget* pWidget = pMessage->m_pDstTarget;
275 if (!pWidget) 275 if (!pWidget)
276 return false; 276 return false;
277 277
278 CFWL_Form* pForm = static_cast<CFWL_Form*>(pWidget); 278 CFWL_Form* pForm = static_cast<CFWL_Form*>(pWidget);
279 IFWL_Widget* pSubFocus = pForm->GetSubFocus(); 279 CFWL_Widget* pSubFocus = pForm->GetSubFocus();
280 if (pSubFocus && ((pSubFocus->GetStates() & FWL_WGTSTATE_Focused) == 0)) { 280 if (pSubFocus && ((pSubFocus->GetStates() & FWL_WGTSTATE_Focused) == 0)) {
281 pMessage->m_pDstTarget = pSubFocus; 281 pMessage->m_pDstTarget = pSubFocus;
282 if (m_pFocus != pMessage->m_pDstTarget) { 282 if (m_pFocus != pMessage->m_pDstTarget) {
283 m_pFocus = pMessage->m_pDstTarget; 283 m_pFocus = pMessage->m_pDstTarget;
284 return true; 284 return true;
285 } 285 }
286 } 286 }
287 return false; 287 return false;
288 } 288 }
289 289
290 bool CFWL_NoteDriver::DoKillFocus(CFWL_Message* pMessage, 290 bool CFWL_NoteDriver::DoKillFocus(CFWL_Message* pMessage,
291 IFWL_Widget* pMessageForm) { 291 CFWL_Widget* pMessageForm) {
292 CFWL_WidgetMgr* pWidgetMgr = pMessageForm->GetOwnerApp()->GetWidgetMgr(); 292 CFWL_WidgetMgr* pWidgetMgr = pMessageForm->GetOwnerApp()->GetWidgetMgr();
293 if (pWidgetMgr->IsFormDisabled()) { 293 if (pWidgetMgr->IsFormDisabled()) {
294 if (m_pFocus == pMessage->m_pDstTarget) 294 if (m_pFocus == pMessage->m_pDstTarget)
295 m_pFocus = nullptr; 295 m_pFocus = nullptr;
296 return true; 296 return true;
297 } 297 }
298 298
299 CFWL_Form* pForm = static_cast<CFWL_Form*>(pMessage->m_pDstTarget); 299 CFWL_Form* pForm = static_cast<CFWL_Form*>(pMessage->m_pDstTarget);
300 if (!pForm) 300 if (!pForm)
301 return false; 301 return false;
302 302
303 IFWL_Widget* pSubFocus = pForm->GetSubFocus(); 303 CFWL_Widget* pSubFocus = pForm->GetSubFocus();
304 if (pSubFocus && (pSubFocus->GetStates() & FWL_WGTSTATE_Focused)) { 304 if (pSubFocus && (pSubFocus->GetStates() & FWL_WGTSTATE_Focused)) {
305 pMessage->m_pDstTarget = pSubFocus; 305 pMessage->m_pDstTarget = pSubFocus;
306 if (m_pFocus == pMessage->m_pDstTarget) { 306 if (m_pFocus == pMessage->m_pDstTarget) {
307 m_pFocus = nullptr; 307 m_pFocus = nullptr;
308 return true; 308 return true;
309 } 309 }
310 } 310 }
311 return false; 311 return false;
312 } 312 }
313 313
314 bool CFWL_NoteDriver::DoKey(CFWL_Message* pMessage, IFWL_Widget* pMessageForm) { 314 bool CFWL_NoteDriver::DoKey(CFWL_Message* pMessage, CFWL_Widget* pMessageForm) {
315 CFWL_MsgKey* pMsg = static_cast<CFWL_MsgKey*>(pMessage); 315 CFWL_MsgKey* pMsg = static_cast<CFWL_MsgKey*>(pMessage);
316 #if (_FX_OS_ != _FX_MACOSX_) 316 #if (_FX_OS_ != _FX_MACOSX_)
317 if (pMsg->m_dwCmd == FWL_KeyCommand::KeyDown && 317 if (pMsg->m_dwCmd == FWL_KeyCommand::KeyDown &&
318 pMsg->m_dwKeyCode == FWL_VKEY_Tab) { 318 pMsg->m_dwKeyCode == FWL_VKEY_Tab) {
319 CFWL_WidgetMgr* pWidgetMgr = pMessageForm->GetOwnerApp()->GetWidgetMgr(); 319 CFWL_WidgetMgr* pWidgetMgr = pMessageForm->GetOwnerApp()->GetWidgetMgr();
320 IFWL_Widget* pForm = GetMessageForm(pMsg->m_pDstTarget); 320 CFWL_Widget* pForm = GetMessageForm(pMsg->m_pDstTarget);
321 IFWL_Widget* pFocus = m_pFocus; 321 CFWL_Widget* pFocus = m_pFocus;
322 if (m_pFocus && pWidgetMgr->GetSystemFormWidget(m_pFocus) != pForm) 322 if (m_pFocus && pWidgetMgr->GetSystemFormWidget(m_pFocus) != pForm)
323 pFocus = nullptr; 323 pFocus = nullptr;
324 324
325 bool bFind = false; 325 bool bFind = false;
326 IFWL_Widget* pNextTabStop = pWidgetMgr->NextTab(pForm, pFocus, bFind); 326 CFWL_Widget* pNextTabStop = pWidgetMgr->NextTab(pForm, pFocus, bFind);
327 if (!pNextTabStop) { 327 if (!pNextTabStop) {
328 bFind = false; 328 bFind = false;
329 pNextTabStop = pWidgetMgr->NextTab(pForm, nullptr, bFind); 329 pNextTabStop = pWidgetMgr->NextTab(pForm, nullptr, bFind);
330 } 330 }
331 if (pNextTabStop == pFocus) 331 if (pNextTabStop == pFocus)
332 return true; 332 return true;
333 if (pNextTabStop) 333 if (pNextTabStop)
334 SetFocus(pNextTabStop); 334 SetFocus(pNextTabStop);
335 return true; 335 return true;
336 } 336 }
337 #endif 337 #endif
338 338
339 if (!m_pFocus) { 339 if (!m_pFocus) {
340 if (pMsg->m_dwCmd == FWL_KeyCommand::KeyDown && 340 if (pMsg->m_dwCmd == FWL_KeyCommand::KeyDown &&
341 pMsg->m_dwKeyCode == FWL_VKEY_Return) { 341 pMsg->m_dwKeyCode == FWL_VKEY_Return) {
342 CFWL_WidgetMgr* pWidgetMgr = pMessageForm->GetOwnerApp()->GetWidgetMgr(); 342 CFWL_WidgetMgr* pWidgetMgr = pMessageForm->GetOwnerApp()->GetWidgetMgr();
343 IFWL_Widget* defButton = pWidgetMgr->GetDefaultButton(pMessageForm); 343 CFWL_Widget* defButton = pWidgetMgr->GetDefaultButton(pMessageForm);
344 if (defButton) { 344 if (defButton) {
345 pMsg->m_pDstTarget = defButton; 345 pMsg->m_pDstTarget = defButton;
346 return true; 346 return true;
347 } 347 }
348 } 348 }
349 return false; 349 return false;
350 } 350 }
351 pMsg->m_pDstTarget = m_pFocus; 351 pMsg->m_pDstTarget = m_pFocus;
352 return true; 352 return true;
353 } 353 }
354 354
355 bool CFWL_NoteDriver::DoMouse(CFWL_Message* pMessage, 355 bool CFWL_NoteDriver::DoMouse(CFWL_Message* pMessage,
356 IFWL_Widget* pMessageForm) { 356 CFWL_Widget* pMessageForm) {
357 CFWL_MsgMouse* pMsg = static_cast<CFWL_MsgMouse*>(pMessage); 357 CFWL_MsgMouse* pMsg = static_cast<CFWL_MsgMouse*>(pMessage);
358 if (pMsg->m_dwCmd == FWL_MouseCommand::Leave || 358 if (pMsg->m_dwCmd == FWL_MouseCommand::Leave ||
359 pMsg->m_dwCmd == FWL_MouseCommand::Hover || 359 pMsg->m_dwCmd == FWL_MouseCommand::Hover ||
360 pMsg->m_dwCmd == FWL_MouseCommand::Enter) { 360 pMsg->m_dwCmd == FWL_MouseCommand::Enter) {
361 return !!pMsg->m_pDstTarget; 361 return !!pMsg->m_pDstTarget;
362 } 362 }
363 if (pMsg->m_pDstTarget != pMessageForm) 363 if (pMsg->m_pDstTarget != pMessageForm)
364 pMsg->m_pDstTarget->TransformTo(pMessageForm, pMsg->m_fx, pMsg->m_fy); 364 pMsg->m_pDstTarget->TransformTo(pMessageForm, pMsg->m_fx, pMsg->m_fy);
365 if (!DoMouseEx(pMsg, pMessageForm)) 365 if (!DoMouseEx(pMsg, pMessageForm))
366 pMsg->m_pDstTarget = pMessageForm; 366 pMsg->m_pDstTarget = pMessageForm;
367 return true; 367 return true;
368 } 368 }
369 369
370 bool CFWL_NoteDriver::DoWheel(CFWL_Message* pMessage, 370 bool CFWL_NoteDriver::DoWheel(CFWL_Message* pMessage,
371 IFWL_Widget* pMessageForm) { 371 CFWL_Widget* pMessageForm) {
372 CFWL_WidgetMgr* pWidgetMgr = pMessageForm->GetOwnerApp()->GetWidgetMgr(); 372 CFWL_WidgetMgr* pWidgetMgr = pMessageForm->GetOwnerApp()->GetWidgetMgr();
373 if (!pWidgetMgr) 373 if (!pWidgetMgr)
374 return false; 374 return false;
375 375
376 CFWL_MsgMouseWheel* pMsg = static_cast<CFWL_MsgMouseWheel*>(pMessage); 376 CFWL_MsgMouseWheel* pMsg = static_cast<CFWL_MsgMouseWheel*>(pMessage);
377 IFWL_Widget* pDst = 377 CFWL_Widget* pDst =
378 pWidgetMgr->GetWidgetAtPoint(pMessageForm, pMsg->m_fx, pMsg->m_fy); 378 pWidgetMgr->GetWidgetAtPoint(pMessageForm, pMsg->m_fx, pMsg->m_fy);
379 if (!pDst) 379 if (!pDst)
380 return false; 380 return false;
381 381
382 pMessageForm->TransformTo(pDst, pMsg->m_fx, pMsg->m_fy); 382 pMessageForm->TransformTo(pDst, pMsg->m_fx, pMsg->m_fy);
383 pMsg->m_pDstTarget = pDst; 383 pMsg->m_pDstTarget = pDst;
384 return true; 384 return true;
385 } 385 }
386 386
387 bool CFWL_NoteDriver::DoMouseEx(CFWL_Message* pMessage, 387 bool CFWL_NoteDriver::DoMouseEx(CFWL_Message* pMessage,
388 IFWL_Widget* pMessageForm) { 388 CFWL_Widget* pMessageForm) {
389 CFWL_WidgetMgr* pWidgetMgr = pMessageForm->GetOwnerApp()->GetWidgetMgr(); 389 CFWL_WidgetMgr* pWidgetMgr = pMessageForm->GetOwnerApp()->GetWidgetMgr();
390 if (!pWidgetMgr) 390 if (!pWidgetMgr)
391 return false; 391 return false;
392 IFWL_Widget* pTarget = nullptr; 392 CFWL_Widget* pTarget = nullptr;
393 if (m_pGrab) 393 if (m_pGrab)
394 pTarget = m_pGrab; 394 pTarget = m_pGrab;
395 395
396 CFWL_MsgMouse* pMsg = static_cast<CFWL_MsgMouse*>(pMessage); 396 CFWL_MsgMouse* pMsg = static_cast<CFWL_MsgMouse*>(pMessage);
397 if (!pTarget) { 397 if (!pTarget) {
398 pTarget = 398 pTarget =
399 pWidgetMgr->GetWidgetAtPoint(pMessageForm, pMsg->m_fx, pMsg->m_fy); 399 pWidgetMgr->GetWidgetAtPoint(pMessageForm, pMsg->m_fx, pMsg->m_fy);
400 } 400 }
401 if (pTarget) { 401 if (pTarget) {
402 if (pMessageForm != pTarget) 402 if (pMessageForm != pTarget)
403 pMessageForm->TransformTo(pTarget, pMsg->m_fx, pMsg->m_fy); 403 pMessageForm->TransformTo(pTarget, pMsg->m_fx, pMsg->m_fy);
404 } 404 }
405 if (!pTarget) 405 if (!pTarget)
406 return false; 406 return false;
407 407
408 pMsg->m_pDstTarget = pTarget; 408 pMsg->m_pDstTarget = pTarget;
409 return true; 409 return true;
410 } 410 }
411 411
412 void CFWL_NoteDriver::MouseSecondary(CFWL_Message* pMessage) { 412 void CFWL_NoteDriver::MouseSecondary(CFWL_Message* pMessage) {
413 IFWL_Widget* pTarget = pMessage->m_pDstTarget; 413 CFWL_Widget* pTarget = pMessage->m_pDstTarget;
414 if (pTarget == m_pHover) 414 if (pTarget == m_pHover)
415 return; 415 return;
416 416
417 CFWL_MsgMouse* pMsg = static_cast<CFWL_MsgMouse*>(pMessage); 417 CFWL_MsgMouse* pMsg = static_cast<CFWL_MsgMouse*>(pMessage);
418 if (m_pHover) { 418 if (m_pHover) {
419 CFWL_MsgMouse msLeave; 419 CFWL_MsgMouse msLeave;
420 msLeave.m_pDstTarget = m_pHover; 420 msLeave.m_pDstTarget = m_pHover;
421 msLeave.m_fx = pMsg->m_fx; 421 msLeave.m_fx = pMsg->m_fx;
422 msLeave.m_fy = pMsg->m_fy; 422 msLeave.m_fy = pMsg->m_fy;
423 pTarget->TransformTo(m_pHover, msLeave.m_fx, msLeave.m_fy); 423 pTarget->TransformTo(m_pHover, msLeave.m_fx, msLeave.m_fy);
(...skipping 13 matching lines...) Expand all
437 msHover.m_fx = pMsg->m_fx; 437 msHover.m_fx = pMsg->m_fx;
438 msHover.m_fy = pMsg->m_fy; 438 msHover.m_fy = pMsg->m_fy;
439 msHover.m_dwFlags = 0; 439 msHover.m_dwFlags = 0;
440 msHover.m_dwCmd = FWL_MouseCommand::Hover; 440 msHover.m_dwCmd = FWL_MouseCommand::Hover;
441 DispatchMessage(&msHover, nullptr); 441 DispatchMessage(&msHover, nullptr);
442 } 442 }
443 443
444 bool CFWL_NoteDriver::IsValidMessage(CFWL_Message* pMessage) { 444 bool CFWL_NoteDriver::IsValidMessage(CFWL_Message* pMessage) {
445 for (int32_t i = 0; i < m_noteLoopQueue.GetSize(); i++) { 445 for (int32_t i = 0; i < m_noteLoopQueue.GetSize(); i++) {
446 CFWL_NoteLoop* pNoteLoop = m_noteLoopQueue[i]; 446 CFWL_NoteLoop* pNoteLoop = m_noteLoopQueue[i];
447 IFWL_Widget* pForm = pNoteLoop->GetForm(); 447 CFWL_Widget* pForm = pNoteLoop->GetForm();
448 if (pForm && (pForm == pMessage->m_pDstTarget)) 448 if (pForm && (pForm == pMessage->m_pDstTarget))
449 return true; 449 return true;
450 } 450 }
451 451
452 for (int32_t j = 0; j < m_forms.GetSize(); j++) { 452 for (int32_t j = 0; j < m_forms.GetSize(); j++) {
453 CFWL_Form* pForm = static_cast<CFWL_Form*>(m_forms[j]); 453 CFWL_Form* pForm = static_cast<CFWL_Form*>(m_forms[j]);
454 if (pForm == pMessage->m_pDstTarget) 454 if (pForm == pMessage->m_pDstTarget)
455 return true; 455 return true;
456 } 456 }
457 return false; 457 return false;
458 } 458 }
459 459
460 IFWL_Widget* CFWL_NoteDriver::GetMessageForm(IFWL_Widget* pDstTarget) { 460 CFWL_Widget* CFWL_NoteDriver::GetMessageForm(CFWL_Widget* pDstTarget) {
461 int32_t iTrackLoop = m_noteLoopQueue.GetSize(); 461 int32_t iTrackLoop = m_noteLoopQueue.GetSize();
462 if (iTrackLoop <= 0) 462 if (iTrackLoop <= 0)
463 return nullptr; 463 return nullptr;
464 464
465 IFWL_Widget* pMessageForm = nullptr; 465 CFWL_Widget* pMessageForm = nullptr;
466 if (iTrackLoop > 1) 466 if (iTrackLoop > 1)
467 pMessageForm = m_noteLoopQueue[iTrackLoop - 1]->GetForm(); 467 pMessageForm = m_noteLoopQueue[iTrackLoop - 1]->GetForm();
468 else if (m_forms.Find(pDstTarget) < 0) 468 else if (m_forms.Find(pDstTarget) < 0)
469 pMessageForm = pDstTarget; 469 pMessageForm = pDstTarget;
470 if (!pMessageForm && pDstTarget) { 470 if (!pMessageForm && pDstTarget) {
471 CFWL_WidgetMgr* pWidgetMgr = pDstTarget->GetOwnerApp()->GetWidgetMgr(); 471 CFWL_WidgetMgr* pWidgetMgr = pDstTarget->GetOwnerApp()->GetWidgetMgr();
472 if (!pWidgetMgr) 472 if (!pWidgetMgr)
473 return nullptr; 473 return nullptr;
474 pMessageForm = pWidgetMgr->GetSystemFormWidget(pDstTarget); 474 pMessageForm = pWidgetMgr->GetSystemFormWidget(pDstTarget);
475 } 475 }
476 return pMessageForm; 476 return pMessageForm;
477 } 477 }
478 478
479 void CFWL_NoteDriver::ClearEventTargets(bool bRemoveAll) { 479 void CFWL_NoteDriver::ClearEventTargets(bool bRemoveAll) {
480 auto it = m_eventTargets.begin(); 480 auto it = m_eventTargets.begin();
481 while (it != m_eventTargets.end()) { 481 while (it != m_eventTargets.end()) {
482 auto old = it++; 482 auto old = it++;
483 if (old->second && (bRemoveAll || old->second->IsInvalid())) { 483 if (old->second && (bRemoveAll || old->second->IsInvalid())) {
484 delete old->second; 484 delete old->second;
485 m_eventTargets.erase(old); 485 m_eventTargets.erase(old);
486 } 486 }
487 } 487 }
488 } 488 }
OLDNEW

Powered by Google App Engine
This is Rietveld 408576698