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

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

Issue 2031873003: Get rid of NULLs in xfa/ (Closed) Base URL: https://pdfium.googlesource.com/pdfium@nullptr_fpdfsdk
Patch Set: 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/fwl_formimp.cpp ('k') | xfa/fwl/core/fwl_widgetimp.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 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/include/fx_ext.h" 9 #include "core/fxcrt/include/fx_ext.h"
10 #include "third_party/base/stl_util.h" 10 #include "third_party/base/stl_util.h"
(...skipping 145 matching lines...) Expand 10 before | Expand all | Expand 10 after
156 } 156 }
157 IFWL_Widget* pPrev = m_pFocus; 157 IFWL_Widget* pPrev = m_pFocus;
158 m_pFocus = pFocus; 158 m_pFocus = pFocus;
159 if (pPrev) { 159 if (pPrev) {
160 CFWL_MsgKillFocus ms; 160 CFWL_MsgKillFocus ms;
161 ms.m_pDstTarget = pPrev; 161 ms.m_pDstTarget = pPrev;
162 ms.m_pSrcTarget = pPrev; 162 ms.m_pSrcTarget = pPrev;
163 if (bNotify) { 163 if (bNotify) {
164 ms.m_dwExtend = 1; 164 ms.m_dwExtend = 1;
165 } 165 }
166 IFWL_WidgetDelegate* pDelegate = pPrev->SetDelegate(NULL); 166 IFWL_WidgetDelegate* pDelegate = pPrev->SetDelegate(nullptr);
167 if (pDelegate) { 167 if (pDelegate) {
168 pDelegate->OnProcessMessage(&ms); 168 pDelegate->OnProcessMessage(&ms);
169 } 169 }
170 } 170 }
171 if (pFocus) { 171 if (pFocus) {
172 IFWL_Widget* pWidget = 172 IFWL_Widget* pWidget =
173 CFWL_WidgetMgr::GetInstance()->GetSystemFormWidget(pFocus); 173 CFWL_WidgetMgr::GetInstance()->GetSystemFormWidget(pFocus);
174 CFWL_FormImp* pForm = 174 CFWL_FormImp* pForm =
175 pWidget ? static_cast<CFWL_FormImp*>(pWidget->GetImpl()) : nullptr; 175 pWidget ? static_cast<CFWL_FormImp*>(pWidget->GetImpl()) : nullptr;
176 if (pForm) { 176 if (pForm) {
177 CFWL_WidgetImp* pNewFocus = 177 CFWL_WidgetImp* pNewFocus =
178 static_cast<CFWL_WidgetImp*>(pFocus->GetImpl()); 178 static_cast<CFWL_WidgetImp*>(pFocus->GetImpl());
179 pForm->SetSubFocus(pNewFocus); 179 pForm->SetSubFocus(pNewFocus);
180 } 180 }
181 CFWL_MsgSetFocus ms; 181 CFWL_MsgSetFocus ms;
182 ms.m_pDstTarget = pFocus; 182 ms.m_pDstTarget = pFocus;
183 if (bNotify) { 183 if (bNotify) {
184 ms.m_dwExtend = 1; 184 ms.m_dwExtend = 1;
185 } 185 }
186 IFWL_WidgetDelegate* pDelegate = pFocus->SetDelegate(NULL); 186 IFWL_WidgetDelegate* pDelegate = pFocus->SetDelegate(nullptr);
187 if (pDelegate) { 187 if (pDelegate) {
188 pDelegate->OnProcessMessage(&ms); 188 pDelegate->OnProcessMessage(&ms);
189 } 189 }
190 } 190 }
191 return TRUE; 191 return TRUE;
192 } 192 }
193 FWL_Error CFWL_NoteDriver::Run() { 193 FWL_Error CFWL_NoteDriver::Run() {
194 CFWL_WidgetMgr* pWidgetMgr = CFWL_WidgetMgr::GetInstance(); 194 CFWL_WidgetMgr* pWidgetMgr = CFWL_WidgetMgr::GetInstance();
195 if (!pWidgetMgr) 195 if (!pWidgetMgr)
196 return FWL_Error::Indefinite; 196 return FWL_Error::Indefinite;
197 197
198 #if (_FX_OS_ == _FX_LINUX_DESKTOP_ || _FX_OS_ == _FX_WIN32_DESKTOP_ || \ 198 #if (_FX_OS_ == _FX_LINUX_DESKTOP_ || _FX_OS_ == _FX_WIN32_DESKTOP_ || \
199 _FX_OS_ == _FX_WIN64_) 199 _FX_OS_ == _FX_WIN64_)
200 CFWL_NoteLoop* pTopLoop = NULL; 200 CFWL_NoteLoop* pTopLoop = nullptr;
201 for (;;) { 201 for (;;) {
202 pTopLoop = GetTopLoop(); 202 pTopLoop = GetTopLoop();
203 if (!pTopLoop || !pTopLoop->ContinueModal()) 203 if (!pTopLoop || !pTopLoop->ContinueModal())
204 break; 204 break;
205 if (UnqueueMessage(pTopLoop)) 205 if (UnqueueMessage(pTopLoop))
206 continue; 206 continue;
207 } 207 }
208 #endif 208 #endif
209 209
210 return FWL_Error::Succeeded; 210 return FWL_Error::Succeeded;
211 } 211 }
212 212
213 IFWL_Widget* CFWL_NoteDriver::GetFocus() { 213 IFWL_Widget* CFWL_NoteDriver::GetFocus() {
214 return m_pFocus; 214 return m_pFocus;
215 } 215 }
216 IFWL_Widget* CFWL_NoteDriver::GetHover() { 216 IFWL_Widget* CFWL_NoteDriver::GetHover() {
217 return m_pHover; 217 return m_pHover;
218 } 218 }
219 void CFWL_NoteDriver::SetHover(IFWL_Widget* pHover) { 219 void CFWL_NoteDriver::SetHover(IFWL_Widget* pHover) {
220 m_pHover = pHover; 220 m_pHover = pHover;
221 } 221 }
222 void CFWL_NoteDriver::SetGrab(IFWL_Widget* pGrab, FX_BOOL bSet) { 222 void CFWL_NoteDriver::SetGrab(IFWL_Widget* pGrab, FX_BOOL bSet) {
223 m_pGrab = bSet ? pGrab : NULL; 223 m_pGrab = bSet ? pGrab : nullptr;
224 } 224 }
225 void CFWL_NoteDriver::NotifyTargetHide(IFWL_Widget* pNoteTarget) { 225 void CFWL_NoteDriver::NotifyTargetHide(IFWL_Widget* pNoteTarget) {
226 if (m_pFocus == pNoteTarget) { 226 if (m_pFocus == pNoteTarget) {
227 m_pFocus = NULL; 227 m_pFocus = nullptr;
228 } 228 }
229 if (m_pHover == pNoteTarget) { 229 if (m_pHover == pNoteTarget) {
230 m_pHover = NULL; 230 m_pHover = nullptr;
231 } 231 }
232 if (m_pGrab == pNoteTarget) { 232 if (m_pGrab == pNoteTarget) {
233 m_pGrab = NULL; 233 m_pGrab = nullptr;
234 } 234 }
235 } 235 }
236 void CFWL_NoteDriver::NotifyTargetDestroy(IFWL_Widget* pNoteTarget) { 236 void CFWL_NoteDriver::NotifyTargetDestroy(IFWL_Widget* pNoteTarget) {
237 if (m_pFocus == pNoteTarget) { 237 if (m_pFocus == pNoteTarget) {
238 m_pFocus = NULL; 238 m_pFocus = nullptr;
239 } 239 }
240 if (m_pHover == pNoteTarget) { 240 if (m_pHover == pNoteTarget) {
241 m_pHover = NULL; 241 m_pHover = nullptr;
242 } 242 }
243 if (m_pGrab == pNoteTarget) { 243 if (m_pGrab == pNoteTarget) {
244 m_pGrab = NULL; 244 m_pGrab = nullptr;
245 } 245 }
246 UnregisterEventTarget(pNoteTarget); 246 UnregisterEventTarget(pNoteTarget);
247 int32_t count = m_forms.GetSize(); 247 int32_t count = m_forms.GetSize();
248 for (int32_t nIndex = 0; nIndex < count; nIndex++) { 248 for (int32_t nIndex = 0; nIndex < count; nIndex++) {
249 CFWL_FormImp* pForm = static_cast<CFWL_FormImp*>(m_forms[nIndex]); 249 CFWL_FormImp* pForm = static_cast<CFWL_FormImp*>(m_forms[nIndex]);
250 if (!pForm) { 250 if (!pForm) {
251 continue; 251 continue;
252 } 252 }
253 CFWL_WidgetImp* pSubFocus = pForm->GetSubFocus(); 253 CFWL_WidgetImp* pSubFocus = pForm->GetSubFocus();
254 if (!pSubFocus) 254 if (!pSubFocus)
255 return; 255 return;
256 if (pSubFocus && pSubFocus->GetInterface() == pNoteTarget) { 256 if (pSubFocus && pSubFocus->GetInterface() == pNoteTarget) {
257 pForm->SetSubFocus(NULL); 257 pForm->SetSubFocus(nullptr);
258 } 258 }
259 } 259 }
260 } 260 }
261 261
262 FWL_Error CFWL_NoteDriver::RegisterForm(CFWL_WidgetImp* pForm) { 262 FWL_Error CFWL_NoteDriver::RegisterForm(CFWL_WidgetImp* pForm) {
263 if (!pForm) 263 if (!pForm)
264 return FWL_Error::Indefinite; 264 return FWL_Error::Indefinite;
265 if (m_forms.Find(pForm) >= 0) { 265 if (m_forms.Find(pForm) >= 0) {
266 return FWL_Error::Indefinite; 266 return FWL_Error::Indefinite;
267 } 267 }
(...skipping 113 matching lines...) Expand 10 before | Expand all | Expand 10 after
381 bRet = 381 bRet =
382 DoDragFiles(static_cast<CFWL_MsgDropFiles*>(pMessage), pMessageForm); 382 DoDragFiles(static_cast<CFWL_MsgDropFiles*>(pMessage), pMessageForm);
383 break; 383 break;
384 } 384 }
385 default: { 385 default: {
386 bRet = TRUE; 386 bRet = TRUE;
387 break; 387 break;
388 } 388 }
389 } 389 }
390 if (bRet) { 390 if (bRet) {
391 IFWL_WidgetDelegate* pDelegate = pMessage->m_pDstTarget->SetDelegate(NULL); 391 IFWL_WidgetDelegate* pDelegate =
392 pMessage->m_pDstTarget->SetDelegate(nullptr);
392 if (pDelegate) 393 if (pDelegate)
393 pDelegate->OnProcessMessage(pMessage); 394 pDelegate->OnProcessMessage(pMessage);
394 } 395 }
395 return bRet; 396 return bRet;
396 } 397 }
397 398
398 FX_BOOL CFWL_NoteDriver::DoActivate(CFWL_MsgActivate* pMsg, 399 FX_BOOL CFWL_NoteDriver::DoActivate(CFWL_MsgActivate* pMsg,
399 IFWL_Widget* pMessageForm) { 400 IFWL_Widget* pMessageForm) {
400 pMsg->m_pDstTarget = pMessageForm; 401 pMsg->m_pDstTarget = pMessageForm;
401 return (pMsg->m_pDstTarget)->GetStates() & FWL_WGTSTATE_Deactivated; 402 return (pMsg->m_pDstTarget)->GetStates() & FWL_WGTSTATE_Deactivated;
(...skipping 49 matching lines...) Expand 10 before | Expand all | Expand 10 after
451 } 452 }
452 } 453 }
453 } 454 }
454 return FALSE; 455 return FALSE;
455 } 456 }
456 FX_BOOL CFWL_NoteDriver::DoKillFocus(CFWL_MsgKillFocus* pMsg, 457 FX_BOOL CFWL_NoteDriver::DoKillFocus(CFWL_MsgKillFocus* pMsg,
457 IFWL_Widget* pMessageForm) { 458 IFWL_Widget* pMessageForm) {
458 CFWL_WidgetMgr* pWidgetMgr = CFWL_WidgetMgr::GetInstance(); 459 CFWL_WidgetMgr* pWidgetMgr = CFWL_WidgetMgr::GetInstance();
459 if (pWidgetMgr->IsFormDisabled()) { 460 if (pWidgetMgr->IsFormDisabled()) {
460 if (m_pFocus == pMsg->m_pDstTarget) { 461 if (m_pFocus == pMsg->m_pDstTarget) {
461 m_pFocus = NULL; 462 m_pFocus = nullptr;
462 } 463 }
463 return TRUE; 464 return TRUE;
464 } 465 }
465 IFWL_Widget* pWidget = pMsg->m_pDstTarget; 466 IFWL_Widget* pWidget = pMsg->m_pDstTarget;
466 CFWL_FormImp* pForm = 467 CFWL_FormImp* pForm =
467 pWidget ? static_cast<CFWL_FormImp*>(pWidget->GetImpl()) : nullptr; 468 pWidget ? static_cast<CFWL_FormImp*>(pWidget->GetImpl()) : nullptr;
468 if (pForm) { 469 if (pForm) {
469 CFWL_WidgetImp* pSubFocus = pForm->GetSubFocus(); 470 CFWL_WidgetImp* pSubFocus = pForm->GetSubFocus();
470 if (pSubFocus && (pSubFocus->GetStates() & FWL_WGTSTATE_Focused)) { 471 if (pSubFocus && (pSubFocus->GetStates() & FWL_WGTSTATE_Focused)) {
471 pMsg->m_pDstTarget = pSubFocus->GetInterface(); 472 pMsg->m_pDstTarget = pSubFocus->GetInterface();
472 if (m_pFocus == pMsg->m_pDstTarget) { 473 if (m_pFocus == pMsg->m_pDstTarget) {
473 m_pFocus = NULL; 474 m_pFocus = nullptr;
474 return TRUE; 475 return TRUE;
475 } 476 }
476 } 477 }
477 } 478 }
478 return FALSE; 479 return FALSE;
479 } 480 }
480 FX_BOOL CFWL_NoteDriver::DoKey(CFWL_MsgKey* pMsg, IFWL_Widget* pMessageForm) { 481 FX_BOOL CFWL_NoteDriver::DoKey(CFWL_MsgKey* pMsg, IFWL_Widget* pMessageForm) {
481 #if (_FX_OS_ != _FX_MACOSX_) 482 #if (_FX_OS_ != _FX_MACOSX_)
482 if (pMsg->m_dwCmd == FWL_KeyCommand::KeyDown && 483 if (pMsg->m_dwCmd == FWL_KeyCommand::KeyDown &&
483 pMsg->m_dwKeyCode == FWL_VKEY_Tab) { 484 pMsg->m_dwKeyCode == FWL_VKEY_Tab) {
(...skipping 32 matching lines...) Expand 10 before | Expand all | Expand 10 after
516 return FALSE; 517 return FALSE;
517 } 518 }
518 pMsg->m_pDstTarget = m_pFocus; 519 pMsg->m_pDstTarget = m_pFocus;
519 return TRUE; 520 return TRUE;
520 } 521 }
521 FX_BOOL CFWL_NoteDriver::DoMouse(CFWL_MsgMouse* pMsg, 522 FX_BOOL CFWL_NoteDriver::DoMouse(CFWL_MsgMouse* pMsg,
522 IFWL_Widget* pMessageForm) { 523 IFWL_Widget* pMessageForm) {
523 if (pMsg->m_dwCmd == FWL_MouseCommand::Leave || 524 if (pMsg->m_dwCmd == FWL_MouseCommand::Leave ||
524 pMsg->m_dwCmd == FWL_MouseCommand::Hover || 525 pMsg->m_dwCmd == FWL_MouseCommand::Hover ||
525 pMsg->m_dwCmd == FWL_MouseCommand::Enter) { 526 pMsg->m_dwCmd == FWL_MouseCommand::Enter) {
526 return pMsg->m_pDstTarget != NULL; 527 return !!pMsg->m_pDstTarget;
527 } 528 }
528 if (pMsg->m_pDstTarget != pMessageForm) { 529 if (pMsg->m_pDstTarget != pMessageForm) {
529 pMsg->m_pDstTarget->TransformTo(pMessageForm, pMsg->m_fx, pMsg->m_fy); 530 pMsg->m_pDstTarget->TransformTo(pMessageForm, pMsg->m_fx, pMsg->m_fy);
530 } 531 }
531 if (!DoMouseEx(pMsg, pMessageForm)) { 532 if (!DoMouseEx(pMsg, pMessageForm)) {
532 pMsg->m_pDstTarget = pMessageForm; 533 pMsg->m_pDstTarget = pMessageForm;
533 } 534 }
534 return TRUE; 535 return TRUE;
535 } 536 }
536 FX_BOOL CFWL_NoteDriver::DoWheel(CFWL_MsgMouseWheel* pMsg, 537 FX_BOOL CFWL_NoteDriver::DoWheel(CFWL_MsgMouseWheel* pMsg,
(...skipping 25 matching lines...) Expand all
562 } 563 }
563 FX_BOOL CFWL_NoteDriver::DoDragFiles(CFWL_MsgDropFiles* pMsg, 564 FX_BOOL CFWL_NoteDriver::DoDragFiles(CFWL_MsgDropFiles* pMsg,
564 IFWL_Widget* pMessageForm) { 565 IFWL_Widget* pMessageForm) {
565 return pMsg->m_pDstTarget == pMessageForm; 566 return pMsg->m_pDstTarget == pMessageForm;
566 } 567 }
567 FX_BOOL CFWL_NoteDriver::DoMouseEx(CFWL_MsgMouse* pMsg, 568 FX_BOOL CFWL_NoteDriver::DoMouseEx(CFWL_MsgMouse* pMsg,
568 IFWL_Widget* pMessageForm) { 569 IFWL_Widget* pMessageForm) {
569 CFWL_WidgetMgr* pWidgetMgr = CFWL_WidgetMgr::GetInstance(); 570 CFWL_WidgetMgr* pWidgetMgr = CFWL_WidgetMgr::GetInstance();
570 if (!pWidgetMgr) 571 if (!pWidgetMgr)
571 return FALSE; 572 return FALSE;
572 IFWL_Widget* pTarget = NULL; 573 IFWL_Widget* pTarget = nullptr;
573 if (m_pGrab) 574 if (m_pGrab)
574 pTarget = m_pGrab; 575 pTarget = m_pGrab;
575 if (!pTarget) { 576 if (!pTarget) {
576 pTarget = 577 pTarget =
577 pWidgetMgr->GetWidgetAtPoint(pMessageForm, pMsg->m_fx, pMsg->m_fy); 578 pWidgetMgr->GetWidgetAtPoint(pMessageForm, pMsg->m_fx, pMsg->m_fy);
578 } 579 }
579 if (pTarget) { 580 if (pTarget) {
580 if (pMessageForm != pTarget) { 581 if (pMessageForm != pTarget) {
581 pMessageForm->TransformTo(pTarget, pMsg->m_fx, pMsg->m_fy); 582 pMessageForm->TransformTo(pTarget, pMsg->m_fx, pMsg->m_fy);
582 } 583 }
(...skipping 108 matching lines...) Expand 10 before | Expand all | Expand 10 after
691 wsCaption = m_wsCaption; 692 wsCaption = m_wsCaption;
692 return FWL_Error::Succeeded; 693 return FWL_Error::Succeeded;
693 } 694 }
694 int32_t CFWL_CoreToolTipDP::GetInitialDelay(IFWL_Widget* pWidget) { 695 int32_t CFWL_CoreToolTipDP::GetInitialDelay(IFWL_Widget* pWidget) {
695 return m_nInitDelayTime; 696 return m_nInitDelayTime;
696 } 697 }
697 int32_t CFWL_CoreToolTipDP::GetAutoPopDelay(IFWL_Widget* pWidget) { 698 int32_t CFWL_CoreToolTipDP::GetAutoPopDelay(IFWL_Widget* pWidget) {
698 return m_nAutoPopDelayTime; 699 return m_nAutoPopDelayTime;
699 } 700 }
700 CFX_DIBitmap* CFWL_CoreToolTipDP::GetToolTipIcon(IFWL_Widget* pWidget) { 701 CFX_DIBitmap* CFWL_CoreToolTipDP::GetToolTipIcon(IFWL_Widget* pWidget) {
701 return NULL; 702 return nullptr;
702 } 703 }
703 CFX_SizeF CFWL_CoreToolTipDP::GetToolTipIconSize(IFWL_Widget* pWidget) { 704 CFX_SizeF CFWL_CoreToolTipDP::GetToolTipIconSize(IFWL_Widget* pWidget) {
704 return CFX_SizeF(); 705 return CFX_SizeF();
705 } 706 }
706 CFX_RectF CFWL_CoreToolTipDP::GetAnchor() { 707 CFX_RectF CFWL_CoreToolTipDP::GetAnchor() {
707 return m_fAnchor; 708 return m_fAnchor;
708 } 709 }
709 CFWL_EventTarget::~CFWL_EventTarget() { 710 CFWL_EventTarget::~CFWL_EventTarget() {
710 m_eventSources.RemoveAll(); 711 m_eventSources.RemoveAll();
711 } 712 }
712 int32_t CFWL_EventTarget::SetEventSource(IFWL_Widget* pSource, 713 int32_t CFWL_EventTarget::SetEventSource(IFWL_Widget* pSource,
713 uint32_t dwFilter) { 714 uint32_t dwFilter) {
714 if (pSource) { 715 if (pSource) {
715 m_eventSources.SetAt(pSource, dwFilter); 716 m_eventSources.SetAt(pSource, dwFilter);
716 return m_eventSources.GetCount(); 717 return m_eventSources.GetCount();
717 } 718 }
718 return 1; 719 return 1;
719 } 720 }
720 721
721 FX_BOOL CFWL_EventTarget::ProcessEvent(CFWL_Event* pEvent) { 722 FX_BOOL CFWL_EventTarget::ProcessEvent(CFWL_Event* pEvent) {
722 IFWL_WidgetDelegate* pDelegate = m_pListener->SetDelegate(NULL); 723 IFWL_WidgetDelegate* pDelegate = m_pListener->SetDelegate(nullptr);
723 if (!pDelegate) 724 if (!pDelegate)
724 return FALSE; 725 return FALSE;
725 if (m_eventSources.GetCount() == 0) { 726 if (m_eventSources.GetCount() == 0) {
726 pDelegate->OnProcessEvent(pEvent); 727 pDelegate->OnProcessEvent(pEvent);
727 return TRUE; 728 return TRUE;
728 } 729 }
729 FX_POSITION pos = m_eventSources.GetStartPosition(); 730 FX_POSITION pos = m_eventSources.GetStartPosition();
730 while (pos) { 731 while (pos) {
731 IFWL_Widget* pSource = NULL; 732 IFWL_Widget* pSource = nullptr;
732 uint32_t dwFilter = 0; 733 uint32_t dwFilter = 0;
733 m_eventSources.GetNextAssoc(pos, (void*&)pSource, dwFilter); 734 m_eventSources.GetNextAssoc(pos, (void*&)pSource, dwFilter);
734 if (pSource == pEvent->m_pSrcTarget || 735 if (pSource == pEvent->m_pSrcTarget ||
735 pEvent->GetClassID() == CFWL_EventType::Idle) { 736 pEvent->GetClassID() == CFWL_EventType::Idle) {
736 if (IsFilterEvent(pEvent, dwFilter)) { 737 if (IsFilterEvent(pEvent, dwFilter)) {
737 pDelegate->OnProcessEvent(pEvent); 738 pDelegate->OnProcessEvent(pEvent);
738 return TRUE; 739 return TRUE;
739 } 740 }
740 } 741 }
741 } 742 }
(...skipping 20 matching lines...) Expand all
762 return !!(dwFilter & FWL_EVENT_CLOSE_MASK); 763 return !!(dwFilter & FWL_EVENT_CLOSE_MASK);
763 case CFWL_EventType::SizeChanged: 764 case CFWL_EventType::SizeChanged:
764 return !!(dwFilter & FWL_EVENT_SIZECHANGED_MASK); 765 return !!(dwFilter & FWL_EVENT_SIZECHANGED_MASK);
765 case CFWL_EventType::Idle: 766 case CFWL_EventType::Idle:
766 return !!(dwFilter & FWL_EVENT_IDLE_MASK); 767 return !!(dwFilter & FWL_EVENT_IDLE_MASK);
767 default: 768 default:
768 return !!(dwFilter & FWL_EVENT_CONTROL_MASK); 769 return !!(dwFilter & FWL_EVENT_CONTROL_MASK);
769 } 770 }
770 } 771 }
771 772
772 CFWL_ToolTipContainer* CFWL_ToolTipContainer::s_pInstance = NULL; 773 CFWL_ToolTipContainer* CFWL_ToolTipContainer::s_pInstance = nullptr;
773 774
774 CFWL_ToolTipContainer::CFWL_ToolTipContainer() 775 CFWL_ToolTipContainer::CFWL_ToolTipContainer()
775 : pCurTarget(NULL), m_pToolTipImp(NULL) { 776 : pCurTarget(nullptr), m_pToolTipImp(nullptr) {
776 m_ToolTipDp = new CFWL_CoreToolTipDP; 777 m_ToolTipDp = new CFWL_CoreToolTipDP;
777 m_ToolTipDp->m_nInitDelayTime = 0; 778 m_ToolTipDp->m_nInitDelayTime = 0;
778 m_ToolTipDp->m_nAutoPopDelayTime = 2000; 779 m_ToolTipDp->m_nAutoPopDelayTime = 2000;
779 } 780 }
780 CFWL_ToolTipContainer::~CFWL_ToolTipContainer() { 781 CFWL_ToolTipContainer::~CFWL_ToolTipContainer() {
781 if (m_pToolTipImp) { 782 if (m_pToolTipImp) {
782 IFWL_ToolTip* pToolTip = 783 IFWL_ToolTip* pToolTip =
783 static_cast<IFWL_ToolTip*>(m_pToolTipImp->GetInterface()); 784 static_cast<IFWL_ToolTip*>(m_pToolTipImp->GetInterface());
784 pToolTip->Finalize(); 785 pToolTip->Finalize();
785 delete pToolTip; 786 delete pToolTip;
786 } 787 }
787 delete m_ToolTipDp; 788 delete m_ToolTipDp;
788 } 789 }
789 790
790 // static 791 // static
791 CFWL_ToolTipContainer* CFWL_ToolTipContainer::getInstance() { 792 CFWL_ToolTipContainer* CFWL_ToolTipContainer::getInstance() {
792 if (!s_pInstance) 793 if (!s_pInstance)
793 s_pInstance = new CFWL_ToolTipContainer; 794 s_pInstance = new CFWL_ToolTipContainer;
794 return s_pInstance; 795 return s_pInstance;
795 } 796 }
796 797
797 // static 798 // static
798 void CFWL_ToolTipContainer::DeleteInstance() { 799 void CFWL_ToolTipContainer::DeleteInstance() {
799 delete s_pInstance; 800 delete s_pInstance;
800 s_pInstance = NULL; 801 s_pInstance = nullptr;
801 } 802 }
802 803
803 FWL_Error CFWL_ToolTipContainer::AddToolTipTarget(IFWL_ToolTipTarget* pTarget) { 804 FWL_Error CFWL_ToolTipContainer::AddToolTipTarget(IFWL_ToolTipTarget* pTarget) {
804 if (m_arrWidget.Find(pTarget) < 0) { 805 if (m_arrWidget.Find(pTarget) < 0) {
805 m_arrWidget.Add(pTarget); 806 m_arrWidget.Add(pTarget);
806 return FWL_Error::Succeeded; 807 return FWL_Error::Succeeded;
807 } 808 }
808 return FWL_Error::Indefinite; 809 return FWL_Error::Indefinite;
809 } 810 }
810 FWL_Error CFWL_ToolTipContainer::RemoveToolTipTarget( 811 FWL_Error CFWL_ToolTipContainer::RemoveToolTipTarget(
(...skipping 12 matching lines...) Expand all
823 if (p->GetWidget() == pWedget) { 824 if (p->GetWidget() == pWedget) {
824 pCurTarget = p; 825 pCurTarget = p;
825 return TRUE; 826 return TRUE;
826 } 827 }
827 } 828 }
828 return FALSE; 829 return FALSE;
829 } 830 }
830 FX_BOOL CFWL_ToolTipContainer::ProcessEnter(CFWL_EvtMouse* pEvt, 831 FX_BOOL CFWL_ToolTipContainer::ProcessEnter(CFWL_EvtMouse* pEvt,
831 IFWL_Widget* pOwner) { 832 IFWL_Widget* pOwner) {
832 if (HasToolTip(pEvt->m_pDstTarget)) { 833 if (HasToolTip(pEvt->m_pDstTarget)) {
833 if (NULL == m_pToolTipImp) { 834 if (!m_pToolTipImp) {
834 CFWL_WidgetImpProperties prop; 835 CFWL_WidgetImpProperties prop;
835 prop.m_pDataProvider = m_ToolTipDp; 836 prop.m_pDataProvider = m_ToolTipDp;
836 prop.m_pOwner = pOwner; 837 prop.m_pOwner = pOwner;
837 CFX_RectF rtTooltip; 838 CFX_RectF rtTooltip;
838 rtTooltip.Set(150, 150, 100, 50); 839 rtTooltip.Set(150, 150, 100, 50);
839 prop.m_rtWidget = rtTooltip; 840 prop.m_rtWidget = rtTooltip;
840 IFWL_ToolTip* pToolTip = IFWL_ToolTip::Create(prop, nullptr); 841 IFWL_ToolTip* pToolTip = IFWL_ToolTip::Create(prop, nullptr);
841 pToolTip->Initialize(); 842 pToolTip->Initialize();
842 m_pToolTipImp = static_cast<CFWL_ToolTipImp*>(pToolTip->GetImpl()); 843 m_pToolTipImp = static_cast<CFWL_ToolTipImp*>(pToolTip->GetImpl());
843 m_pToolTipImp->ModifyStylesEx(FWL_STYLEEXT_TTP_Multiline, 0); 844 m_pToolTipImp->ModifyStylesEx(FWL_STYLEEXT_TTP_Multiline, 0);
(...skipping 18 matching lines...) Expand all
862 rt.height = r.height; 863 rt.height = r.height;
863 } 864 }
864 CFX_PointF pt(pEvt->m_fx, pEvt->m_fy); 865 CFX_PointF pt(pEvt->m_fx, pEvt->m_fy);
865 if (pCurTarget->GetToolTipPos(pt) == FWL_Error::Succeeded) { 866 if (pCurTarget->GetToolTipPos(pt) == FWL_Error::Succeeded) {
866 rt.left = pt.x; 867 rt.left = pt.x;
867 rt.top = pt.y; 868 rt.top = pt.y;
868 m_pToolTipImp->ModifyStylesEx(FWL_STYLEEXT_TTP_NoAnchor, 0); 869 m_pToolTipImp->ModifyStylesEx(FWL_STYLEEXT_TTP_NoAnchor, 0);
869 } else { 870 } else {
870 CFX_RectF rtAnchor; 871 CFX_RectF rtAnchor;
871 pCurTarget->GetWidget()->GetClientRect(rtAnchor); 872 pCurTarget->GetWidget()->GetClientRect(rtAnchor);
872 pCurTarget->GetWidget()->TransformTo(NULL, rtAnchor.left, rtAnchor.top); 873 pCurTarget->GetWidget()->TransformTo(nullptr, rtAnchor.left,
874 rtAnchor.top);
873 m_pToolTipImp->SetAnchor(rtAnchor); 875 m_pToolTipImp->SetAnchor(rtAnchor);
874 m_pToolTipImp->ModifyStylesEx(0, FWL_STYLEEXT_TTP_NoAnchor); 876 m_pToolTipImp->ModifyStylesEx(0, FWL_STYLEEXT_TTP_NoAnchor);
875 } 877 }
876 m_pToolTipImp->SetWidgetRect(rt); 878 m_pToolTipImp->SetWidgetRect(rt);
877 m_pToolTipImp->Update(); 879 m_pToolTipImp->Update();
878 m_pToolTipImp->Show(); 880 m_pToolTipImp->Show();
879 } 881 }
880 return TRUE; 882 return TRUE;
881 } 883 }
882 return FALSE; 884 return FALSE;
883 } 885 }
884 FX_BOOL CFWL_ToolTipContainer::ProcessLeave(CFWL_EvtMouse* pEvt) { 886 FX_BOOL CFWL_ToolTipContainer::ProcessLeave(CFWL_EvtMouse* pEvt) {
885 if (HasToolTip(pEvt->m_pDstTarget) && NULL != m_pToolTipImp) { 887 if (HasToolTip(pEvt->m_pDstTarget) && m_pToolTipImp) {
886 m_pToolTipImp->Hide(); 888 m_pToolTipImp->Hide();
887 pCurTarget = NULL; 889 pCurTarget = nullptr;
888 return TRUE; 890 return TRUE;
889 } 891 }
890 return FALSE; 892 return FALSE;
891 } 893 }
892 IFWL_ToolTipTarget* CFWL_ToolTipContainer::GetCurrentToolTipTarget() { 894 IFWL_ToolTipTarget* CFWL_ToolTipContainer::GetCurrentToolTipTarget() {
893 return pCurTarget; 895 return pCurTarget;
894 } 896 }
OLDNEW
« no previous file with comments | « xfa/fwl/core/fwl_formimp.cpp ('k') | xfa/fwl/core/fwl_widgetimp.h » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698