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

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

Issue 2432423002: Merge the CFWL_*Imp classes into the IFWL_* classes. (Closed)
Patch Set: Review feedback Created 4 years, 2 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/fwl_noteimp.h ('k') | xfa/fwl/core/fwl_timerimp.cpp » ('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 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/fwl_noteimp.h" 7 #include "xfa/fwl/core/fwl_noteimp.h"
8 8
9 #include "core/fxcrt/fx_ext.h" 9 #include "core/fxcrt/fx_ext.h"
10 #include "third_party/base/stl_util.h" 10 #include "third_party/base/stl_util.h"
11 #include "xfa/fwl/basewidget/fwl_tooltipctrlimp.h"
12 #include "xfa/fwl/basewidget/ifwl_tooltip.h"
13 #include "xfa/fwl/core/cfwl_message.h" 11 #include "xfa/fwl/core/cfwl_message.h"
14 #include "xfa/fwl/core/cfwl_widgetmgr.h" 12 #include "xfa/fwl/core/cfwl_widgetmgr.h"
15 #include "xfa/fwl/core/fwl_formimp.h"
16 #include "xfa/fwl/core/fwl_widgetimp.h"
17 #include "xfa/fwl/core/ifwl_app.h" 13 #include "xfa/fwl/core/ifwl_app.h"
14 #include "xfa/fwl/core/ifwl_tooltip.h"
18 15
19 CFWL_NoteLoop::CFWL_NoteLoop(CFWL_WidgetImp* pForm) 16 CFWL_NoteLoop::CFWL_NoteLoop(IFWL_Widget* pForm)
20 : m_pForm(pForm), m_bContinueModal(TRUE) {} 17 : m_pForm(pForm), m_bContinueModal(TRUE) {}
21 18
22 FWL_Error CFWL_NoteLoop::Idle(int32_t count) { 19 FWL_Error CFWL_NoteLoop::Idle(int32_t count) {
23 #if (_FX_OS_ == _FX_WIN32_DESKTOP_) 20 #if (_FX_OS_ == _FX_WIN32_DESKTOP_)
24 if (count <= 0) { 21 if (count <= 0) {
25 #endif 22 #endif
26 CFWL_EvtIdle ev; 23 CFWL_EvtIdle ev;
27 IFWL_App* pApp = FWL_GetApp(); 24 IFWL_App* pApp = FWL_GetApp();
28 if (!pApp) 25 if (!pApp)
29 return FWL_Error::Indefinite; 26 return FWL_Error::Indefinite;
30 CFWL_NoteDriver* pDriver = pApp->GetNoteDriver(); 27 CFWL_NoteDriver* pDriver = pApp->GetNoteDriver();
31 if (!pDriver) 28 if (!pDriver)
32 return FWL_Error::Indefinite; 29 return FWL_Error::Indefinite;
33 pDriver->SendEvent(&ev); 30 pDriver->SendEvent(&ev);
34 #if (_FX_OS_ == _FX_WIN32_DESKTOP_) 31 #if (_FX_OS_ == _FX_WIN32_DESKTOP_)
35 } 32 }
36 #endif 33 #endif
37 return FWL_Error::Indefinite; 34 return FWL_Error::Indefinite;
38 } 35 }
39 CFWL_WidgetImp* CFWL_NoteLoop::GetForm() { 36 IFWL_Widget* CFWL_NoteLoop::GetForm() {
40 return m_pForm; 37 return m_pForm;
41 } 38 }
42 FX_BOOL CFWL_NoteLoop::ContinueModal() { 39 FX_BOOL CFWL_NoteLoop::ContinueModal() {
43 return m_bContinueModal; 40 return m_bContinueModal;
44 } 41 }
45 FWL_Error CFWL_NoteLoop::EndModalLoop() { 42 FWL_Error CFWL_NoteLoop::EndModalLoop() {
46 m_bContinueModal = FALSE; 43 m_bContinueModal = FALSE;
47 return FWL_Error::Succeeded; 44 return FWL_Error::Succeeded;
48 } 45 }
49 46
50 FWL_Error CFWL_NoteLoop::SetMainForm(CFWL_WidgetImp* pForm) { 47 FWL_Error CFWL_NoteLoop::SetMainForm(IFWL_Widget* pForm) {
51 m_pForm = pForm; 48 m_pForm = pForm;
52 return FWL_Error::Succeeded; 49 return FWL_Error::Succeeded;
53 } 50 }
54 void CFWL_NoteLoop::GenerateCommondEvent(uint32_t dwCommand) { 51 void CFWL_NoteLoop::GenerateCommondEvent(uint32_t dwCommand) {
55 CFWL_EvtMenuCommand ev; 52 CFWL_EvtMenuCommand ev;
56 ev.m_iCommand = dwCommand; 53 ev.m_iCommand = dwCommand;
57 IFWL_App* pApp = m_pForm->GetOwnerApp(); 54 IFWL_App* pApp = m_pForm->GetOwnerApp();
58 if (!pApp) 55 if (!pApp)
59 return; 56 return;
60 57
(...skipping 87 matching lines...) Expand 10 before | Expand all | Expand 10 after
148 ms.m_dwExtend = 1; 145 ms.m_dwExtend = 1;
149 } 146 }
150 IFWL_WidgetDelegate* pDelegate = pPrev->SetDelegate(nullptr); 147 IFWL_WidgetDelegate* pDelegate = pPrev->SetDelegate(nullptr);
151 if (pDelegate) { 148 if (pDelegate) {
152 pDelegate->OnProcessMessage(&ms); 149 pDelegate->OnProcessMessage(&ms);
153 } 150 }
154 } 151 }
155 if (pFocus) { 152 if (pFocus) {
156 IFWL_Widget* pWidget = 153 IFWL_Widget* pWidget =
157 CFWL_WidgetMgr::GetInstance()->GetSystemFormWidget(pFocus); 154 CFWL_WidgetMgr::GetInstance()->GetSystemFormWidget(pFocus);
158 CFWL_FormImp* pForm = 155 IFWL_Form* pForm = static_cast<IFWL_Form*>(pWidget);
159 pWidget ? static_cast<CFWL_FormImp*>(pWidget->GetImpl()) : nullptr; 156 if (pForm)
160 if (pForm) { 157 pForm->SetSubFocus(pFocus);
161 CFWL_WidgetImp* pNewFocus = 158
162 static_cast<CFWL_WidgetImp*>(pFocus->GetImpl());
163 pForm->SetSubFocus(pNewFocus);
164 }
165 CFWL_MsgSetFocus ms; 159 CFWL_MsgSetFocus ms;
166 ms.m_pDstTarget = pFocus; 160 ms.m_pDstTarget = pFocus;
167 if (bNotify) { 161 if (bNotify) {
168 ms.m_dwExtend = 1; 162 ms.m_dwExtend = 1;
169 } 163 }
170 IFWL_WidgetDelegate* pDelegate = pFocus->SetDelegate(nullptr); 164 IFWL_WidgetDelegate* pDelegate = pFocus->SetDelegate(nullptr);
171 if (pDelegate) { 165 if (pDelegate) {
172 pDelegate->OnProcessMessage(&ms); 166 pDelegate->OnProcessMessage(&ms);
173 } 167 }
174 } 168 }
(...skipping 48 matching lines...) Expand 10 before | Expand all | Expand 10 after
223 } 217 }
224 if (m_pHover == pNoteTarget) { 218 if (m_pHover == pNoteTarget) {
225 m_pHover = nullptr; 219 m_pHover = nullptr;
226 } 220 }
227 if (m_pGrab == pNoteTarget) { 221 if (m_pGrab == pNoteTarget) {
228 m_pGrab = nullptr; 222 m_pGrab = nullptr;
229 } 223 }
230 UnregisterEventTarget(pNoteTarget); 224 UnregisterEventTarget(pNoteTarget);
231 int32_t count = m_forms.GetSize(); 225 int32_t count = m_forms.GetSize();
232 for (int32_t nIndex = 0; nIndex < count; nIndex++) { 226 for (int32_t nIndex = 0; nIndex < count; nIndex++) {
233 CFWL_FormImp* pForm = static_cast<CFWL_FormImp*>(m_forms[nIndex]); 227 IFWL_Form* pForm = static_cast<IFWL_Form*>(m_forms[nIndex]);
234 if (!pForm) { 228 if (!pForm) {
235 continue; 229 continue;
236 } 230 }
237 CFWL_WidgetImp* pSubFocus = pForm->GetSubFocus(); 231 IFWL_Widget* pSubFocus = pForm->GetSubFocus();
238 if (!pSubFocus) 232 if (!pSubFocus)
239 return; 233 return;
240 if (pSubFocus && pSubFocus->GetInterface() == pNoteTarget) { 234 if (pSubFocus == pNoteTarget) {
241 pForm->SetSubFocus(nullptr); 235 pForm->SetSubFocus(nullptr);
242 } 236 }
243 } 237 }
244 } 238 }
245 239
246 FWL_Error CFWL_NoteDriver::RegisterForm(CFWL_WidgetImp* pForm) { 240 FWL_Error CFWL_NoteDriver::RegisterForm(IFWL_Widget* pForm) {
247 if (!pForm) 241 if (!pForm)
248 return FWL_Error::Indefinite; 242 return FWL_Error::Indefinite;
249 if (m_forms.Find(pForm) >= 0) { 243 if (m_forms.Find(pForm) >= 0) {
250 return FWL_Error::Indefinite; 244 return FWL_Error::Indefinite;
251 } 245 }
252 m_forms.Add(pForm); 246 m_forms.Add(pForm);
253 if (m_forms.GetSize() == 1) { 247 if (m_forms.GetSize() == 1) {
254 CFWL_NoteLoop* pLoop = 248 CFWL_NoteLoop* pLoop =
255 static_cast<CFWL_NoteLoop*>(m_noteLoopQueue.GetAt(0)); 249 static_cast<CFWL_NoteLoop*>(m_noteLoopQueue.GetAt(0));
256 if (!pLoop) 250 if (!pLoop)
257 return FWL_Error::Indefinite; 251 return FWL_Error::Indefinite;
258 pLoop->SetMainForm(pForm); 252 pLoop->SetMainForm(pForm);
259 } 253 }
260 return FWL_Error::Succeeded; 254 return FWL_Error::Succeeded;
261 } 255 }
262 FWL_Error CFWL_NoteDriver::UnRegisterForm(CFWL_WidgetImp* pForm) { 256 FWL_Error CFWL_NoteDriver::UnRegisterForm(IFWL_Widget* pForm) {
263 if (!pForm) 257 if (!pForm)
264 return FWL_Error::Indefinite; 258 return FWL_Error::Indefinite;
265 int32_t nIndex = m_forms.Find(pForm); 259 int32_t nIndex = m_forms.Find(pForm);
266 if (nIndex < 0) { 260 if (nIndex < 0) {
267 return FWL_Error::Indefinite; 261 return FWL_Error::Indefinite;
268 } 262 }
269 m_forms.RemoveAt(nIndex); 263 m_forms.RemoveAt(nIndex);
270 return FWL_Error::Succeeded; 264 return FWL_Error::Succeeded;
271 } 265 }
272 FX_BOOL CFWL_NoteDriver::QueueMessage(CFWL_Message* pMessage) { 266 FX_BOOL CFWL_NoteDriver::QueueMessage(CFWL_Message* pMessage) {
(...skipping 144 matching lines...) Expand 10 before | Expand all | Expand 10 after
417 !pMessageForm->IsInstance(FX_WSTRC(L"FWL_FORMPROXY")); 411 !pMessageForm->IsInstance(FX_WSTRC(L"FWL_FORMPROXY"));
418 } 412 }
419 FX_BOOL CFWL_NoteDriver::DoSetFocus(CFWL_MsgSetFocus* pMsg, 413 FX_BOOL CFWL_NoteDriver::DoSetFocus(CFWL_MsgSetFocus* pMsg,
420 IFWL_Widget* pMessageForm) { 414 IFWL_Widget* pMessageForm) {
421 CFWL_WidgetMgr* pWidgetMgr = CFWL_WidgetMgr::GetInstance(); 415 CFWL_WidgetMgr* pWidgetMgr = CFWL_WidgetMgr::GetInstance();
422 if (pWidgetMgr->IsFormDisabled()) { 416 if (pWidgetMgr->IsFormDisabled()) {
423 m_pFocus = pMsg->m_pDstTarget; 417 m_pFocus = pMsg->m_pDstTarget;
424 return TRUE; 418 return TRUE;
425 } 419 }
426 IFWL_Widget* pWidget = pMsg->m_pDstTarget; 420 IFWL_Widget* pWidget = pMsg->m_pDstTarget;
427 CFWL_FormImp* pForm = 421 if (pWidget) {
428 pWidget ? static_cast<CFWL_FormImp*>(pWidget->GetImpl()) : nullptr; 422 IFWL_Form* pForm = static_cast<IFWL_Form*>(pWidget);
429 if (pForm) { 423 IFWL_Widget* pSubFocus = pForm->GetSubFocus();
430 CFWL_WidgetImp* pSubFocus = pForm->GetSubFocus();
431 if (pSubFocus && ((pSubFocus->GetStates() & FWL_WGTSTATE_Focused) == 0)) { 424 if (pSubFocus && ((pSubFocus->GetStates() & FWL_WGTSTATE_Focused) == 0)) {
432 pMsg->m_pDstTarget = pSubFocus->GetInterface(); 425 pMsg->m_pDstTarget = pSubFocus;
433 if (m_pFocus != pMsg->m_pDstTarget) { 426 if (m_pFocus != pMsg->m_pDstTarget) {
434 m_pFocus = pMsg->m_pDstTarget; 427 m_pFocus = pMsg->m_pDstTarget;
435 return TRUE; 428 return TRUE;
436 } 429 }
437 } 430 }
438 } 431 }
439 return FALSE; 432 return FALSE;
440 } 433 }
441 FX_BOOL CFWL_NoteDriver::DoKillFocus(CFWL_MsgKillFocus* pMsg, 434 FX_BOOL CFWL_NoteDriver::DoKillFocus(CFWL_MsgKillFocus* pMsg,
442 IFWL_Widget* pMessageForm) { 435 IFWL_Widget* pMessageForm) {
443 CFWL_WidgetMgr* pWidgetMgr = CFWL_WidgetMgr::GetInstance(); 436 CFWL_WidgetMgr* pWidgetMgr = CFWL_WidgetMgr::GetInstance();
444 if (pWidgetMgr->IsFormDisabled()) { 437 if (pWidgetMgr->IsFormDisabled()) {
445 if (m_pFocus == pMsg->m_pDstTarget) { 438 if (m_pFocus == pMsg->m_pDstTarget) {
446 m_pFocus = nullptr; 439 m_pFocus = nullptr;
447 } 440 }
448 return TRUE; 441 return TRUE;
449 } 442 }
450 IFWL_Widget* pWidget = pMsg->m_pDstTarget; 443 IFWL_Form* pForm = static_cast<IFWL_Form*>(pMsg->m_pDstTarget);
451 CFWL_FormImp* pForm =
452 pWidget ? static_cast<CFWL_FormImp*>(pWidget->GetImpl()) : nullptr;
453 if (pForm) { 444 if (pForm) {
454 CFWL_WidgetImp* pSubFocus = pForm->GetSubFocus(); 445 IFWL_Widget* pSubFocus = pForm->GetSubFocus();
455 if (pSubFocus && (pSubFocus->GetStates() & FWL_WGTSTATE_Focused)) { 446 if (pSubFocus && (pSubFocus->GetStates() & FWL_WGTSTATE_Focused)) {
456 pMsg->m_pDstTarget = pSubFocus->GetInterface(); 447 pMsg->m_pDstTarget = pSubFocus;
457 if (m_pFocus == pMsg->m_pDstTarget) { 448 if (m_pFocus == pMsg->m_pDstTarget) {
458 m_pFocus = nullptr; 449 m_pFocus = nullptr;
459 return TRUE; 450 return TRUE;
460 } 451 }
461 } 452 }
462 } 453 }
463 return FALSE; 454 return FALSE;
464 } 455 }
465 FX_BOOL CFWL_NoteDriver::DoKey(CFWL_MsgKey* pMsg, IFWL_Widget* pMessageForm) { 456 FX_BOOL CFWL_NoteDriver::DoKey(CFWL_MsgKey* pMsg, IFWL_Widget* pMessageForm) {
466 #if (_FX_OS_ != _FX_MACOSX_) 457 #if (_FX_OS_ != _FX_MACOSX_)
(...skipping 132 matching lines...) Expand 10 before | Expand all | Expand 10 after
599 msHover.m_dwCmd = FWL_MouseCommand::Hover; 590 msHover.m_dwCmd = FWL_MouseCommand::Hover;
600 DispatchMessage(&msHover, nullptr); 591 DispatchMessage(&msHover, nullptr);
601 } 592 }
602 FX_BOOL CFWL_NoteDriver::IsValidMessage(CFWL_Message* pMessage) { 593 FX_BOOL CFWL_NoteDriver::IsValidMessage(CFWL_Message* pMessage) {
603 if (pMessage->GetClassID() == CFWL_MessageType::Post) 594 if (pMessage->GetClassID() == CFWL_MessageType::Post)
604 return TRUE; 595 return TRUE;
605 596
606 int32_t iCount = m_noteLoopQueue.GetSize(); 597 int32_t iCount = m_noteLoopQueue.GetSize();
607 for (int32_t i = 0; i < iCount; i++) { 598 for (int32_t i = 0; i < iCount; i++) {
608 CFWL_NoteLoop* pNoteLoop = static_cast<CFWL_NoteLoop*>(m_noteLoopQueue[i]); 599 CFWL_NoteLoop* pNoteLoop = static_cast<CFWL_NoteLoop*>(m_noteLoopQueue[i]);
609 CFWL_WidgetImp* pForm = pNoteLoop->GetForm(); 600 IFWL_Widget* pForm = pNoteLoop->GetForm();
610 if (pForm && (pForm->GetInterface() == pMessage->m_pDstTarget)) 601 if (pForm && (pForm == pMessage->m_pDstTarget))
611 return TRUE; 602 return TRUE;
612 } 603 }
613 iCount = m_forms.GetSize(); 604 iCount = m_forms.GetSize();
614 for (int32_t j = 0; j < iCount; j++) { 605 for (int32_t j = 0; j < iCount; j++) {
615 CFWL_FormImp* pForm = static_cast<CFWL_FormImp*>(m_forms[j]); 606 IFWL_Form* pForm = static_cast<IFWL_Form*>(m_forms[j]);
616 if (pForm->GetInterface() == pMessage->m_pDstTarget) 607 if (pForm == pMessage->m_pDstTarget)
617 return TRUE; 608 return TRUE;
618 } 609 }
619 return FALSE; 610 return FALSE;
620 } 611 }
621 612
622 IFWL_Widget* CFWL_NoteDriver::GetMessageForm(IFWL_Widget* pDstTarget) { 613 IFWL_Widget* CFWL_NoteDriver::GetMessageForm(IFWL_Widget* pDstTarget) {
623 int32_t iTrackLoop = m_noteLoopQueue.GetSize(); 614 int32_t iTrackLoop = m_noteLoopQueue.GetSize();
624 if (iTrackLoop <= 0) 615 if (iTrackLoop <= 0)
625 return nullptr; 616 return nullptr;
626 IFWL_Widget* pMessageForm = nullptr; 617 IFWL_Widget* pMessageForm = nullptr;
627 if (iTrackLoop > 1) { 618 if (iTrackLoop > 1) {
628 CFWL_NoteLoop* pNootLoop = 619 CFWL_NoteLoop* pNootLoop =
629 static_cast<CFWL_NoteLoop*>(m_noteLoopQueue[iTrackLoop - 1]); 620 static_cast<CFWL_NoteLoop*>(m_noteLoopQueue[iTrackLoop - 1]);
630 pMessageForm = pNootLoop->GetForm()->GetInterface(); 621 pMessageForm = pNootLoop->GetForm();
631 } else if (m_forms.Find(pDstTarget->GetImpl()) < 0) { 622 } else if (m_forms.Find(pDstTarget) < 0) {
632 pMessageForm = pDstTarget; 623 pMessageForm = pDstTarget;
633 } 624 }
634 if (!pMessageForm && pDstTarget) { 625 if (!pMessageForm && pDstTarget) {
635 CFWL_WidgetMgr* pWidgetMgr = CFWL_WidgetMgr::GetInstance(); 626 CFWL_WidgetMgr* pWidgetMgr = CFWL_WidgetMgr::GetInstance();
636 if (!pWidgetMgr) 627 if (!pWidgetMgr)
637 return nullptr; 628 return nullptr;
638 pMessageForm = pWidgetMgr->GetSystemFormWidget(pDstTarget); 629 pMessageForm = pWidgetMgr->GetSystemFormWidget(pDstTarget);
639 } 630 }
640 return pMessageForm; 631 return pMessageForm;
641 } 632 }
(...skipping 128 matching lines...) Expand 10 before | Expand all | Expand 10 after
770 } 761 }
771 } 762 }
772 763
773 CFWL_ToolTipContainer* CFWL_ToolTipContainer::s_pInstance = nullptr; 764 CFWL_ToolTipContainer* CFWL_ToolTipContainer::s_pInstance = nullptr;
774 765
775 CFWL_ToolTipContainer::CFWL_ToolTipContainer() 766 CFWL_ToolTipContainer::CFWL_ToolTipContainer()
776 : m_pToolTipImp(nullptr), m_pToolTipDp(new CFWL_CoreToolTipDP(0, 2000)) {} 767 : m_pToolTipImp(nullptr), m_pToolTipDp(new CFWL_CoreToolTipDP(0, 2000)) {}
777 768
778 CFWL_ToolTipContainer::~CFWL_ToolTipContainer() { 769 CFWL_ToolTipContainer::~CFWL_ToolTipContainer() {
779 if (m_pToolTipImp) { 770 if (m_pToolTipImp) {
780 IFWL_ToolTip* pToolTip = 771 IFWL_ToolTip* pToolTip = static_cast<IFWL_ToolTip*>(m_pToolTipImp);
781 static_cast<IFWL_ToolTip*>(m_pToolTipImp->GetInterface());
782 pToolTip->Finalize(); 772 pToolTip->Finalize();
783 delete pToolTip; 773 delete pToolTip;
784 } 774 }
785 } 775 }
786 776
787 // static 777 // static
788 CFWL_ToolTipContainer* CFWL_ToolTipContainer::getInstance() { 778 CFWL_ToolTipContainer* CFWL_ToolTipContainer::getInstance() {
789 if (!s_pInstance) 779 if (!s_pInstance)
790 s_pInstance = new CFWL_ToolTipContainer; 780 s_pInstance = new CFWL_ToolTipContainer;
791 return s_pInstance; 781 return s_pInstance;
792 } 782 }
793 783
794 // static 784 // static
795 void CFWL_ToolTipContainer::DeleteInstance() { 785 void CFWL_ToolTipContainer::DeleteInstance() {
796 delete s_pInstance; 786 delete s_pInstance;
797 s_pInstance = nullptr; 787 s_pInstance = nullptr;
798 } 788 }
OLDNEW
« no previous file with comments | « xfa/fwl/core/fwl_noteimp.h ('k') | xfa/fwl/core/fwl_timerimp.cpp » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698