OLD | NEW |
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_widgetmgr.h" | 7 #include "xfa/fwl/core/cfwl_widgetmgr.h" |
8 | 8 |
9 #include "xfa/fwl/core/cfwl_message.h" | 9 #include "xfa/fwl/core/cfwl_message.h" |
10 #include "xfa/fwl/core/fwl_noteimp.h" | 10 #include "xfa/fwl/core/fwl_noteimp.h" |
(...skipping 16 matching lines...) Expand all Loading... |
27 } // namespace | 27 } // namespace |
28 | 28 |
29 FX_BOOL FWL_UseOffscreen(IFWL_Widget* pWidget) { | 29 FX_BOOL FWL_UseOffscreen(IFWL_Widget* pWidget) { |
30 #if (_FX_OS_ == _FX_MACOSX_) | 30 #if (_FX_OS_ == _FX_MACOSX_) |
31 return FALSE; | 31 return FALSE; |
32 #else | 32 #else |
33 return pWidget->GetStyles() & FWL_WGTSTYLE_Offscreen; | 33 return pWidget->GetStyles() & FWL_WGTSTYLE_Offscreen; |
34 #endif | 34 #endif |
35 } | 35 } |
36 | 36 |
37 // static | |
38 CFWL_WidgetMgr* CFWL_WidgetMgr::GetInstance() { | |
39 IFWL_App* pApp = FWL_GetApp(); | |
40 return pApp ? pApp->GetWidgetMgr() : nullptr; | |
41 } | |
42 | |
43 CFWL_WidgetMgr::CFWL_WidgetMgr(CXFA_FFApp* pAdapterNative) | 37 CFWL_WidgetMgr::CFWL_WidgetMgr(CXFA_FFApp* pAdapterNative) |
44 : m_dwCapability(0), | 38 : m_dwCapability(0), |
45 m_pDelegate(new CFWL_WidgetMgrDelegate(this)), | 39 m_pDelegate(new CFWL_WidgetMgrDelegate(this)), |
46 m_pAdapter(pAdapterNative->GetWidgetMgr(m_pDelegate.get())) { | 40 m_pAdapter(pAdapterNative->GetWidgetMgr(m_pDelegate.get())) { |
47 ASSERT(m_pAdapter); | 41 ASSERT(m_pAdapter); |
48 m_mapWidgetItem[nullptr].reset(new CFWL_WidgetMgrItem); | 42 m_mapWidgetItem[nullptr].reset(new CFWL_WidgetMgrItem); |
49 #if (_FX_OS_ == _FX_WIN32_DESKTOP_) || (_FX_OS_ == _FX_WIN64_) | 43 #if (_FX_OS_ == _FX_WIN32_DESKTOP_) || (_FX_OS_ == _FX_WIN64_) |
50 m_rtScreen.Reset(); | 44 m_rtScreen.Reset(); |
51 #endif | 45 #endif |
52 } | 46 } |
(...skipping 332 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
385 void CFWL_WidgetMgr::NotifySizeChanged(IFWL_Widget* pForm, | 379 void CFWL_WidgetMgr::NotifySizeChanged(IFWL_Widget* pForm, |
386 FX_FLOAT fx, | 380 FX_FLOAT fx, |
387 FX_FLOAT fy) { | 381 FX_FLOAT fy) { |
388 if (FWL_UseOffscreen(pForm)) | 382 if (FWL_UseOffscreen(pForm)) |
389 GetWidgetMgrItem(pForm)->pOffscreen.reset(); | 383 GetWidgetMgrItem(pForm)->pOffscreen.reset(); |
390 } | 384 } |
391 | 385 |
392 IFWL_Widget* CFWL_WidgetMgr::nextTab(IFWL_Widget* parent, | 386 IFWL_Widget* CFWL_WidgetMgr::nextTab(IFWL_Widget* parent, |
393 IFWL_Widget* focus, | 387 IFWL_Widget* focus, |
394 FX_BOOL& bFind) { | 388 FX_BOOL& bFind) { |
395 CFWL_WidgetMgr* pMgr = CFWL_WidgetMgr::GetInstance(); | 389 CFWL_WidgetMgr* pMgr = parent->GetOwnerApp()->GetWidgetMgr(); |
396 IFWL_Widget* child = pMgr->GetFirstChildWidget(parent); | 390 IFWL_Widget* child = pMgr->GetFirstChildWidget(parent); |
397 while (child) { | 391 while (child) { |
398 if (focus == child) | 392 if (focus == child) |
399 bFind = TRUE; | 393 bFind = TRUE; |
400 | 394 |
401 if ((child->GetStyles() & FWL_WGTSTYLE_TabStop) && | 395 if ((child->GetStyles() & FWL_WGTSTYLE_TabStop) && |
402 (!focus || (focus != child && bFind))) { | 396 (!focus || (focus != child && bFind))) { |
403 return child; | 397 return child; |
404 } | 398 } |
405 IFWL_Widget* bRet = nextTab(child, focus, bFind); | 399 IFWL_Widget* bRet = nextTab(child, focus, bFind); |
(...skipping 57 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
463 if (!pNext) | 457 if (!pNext) |
464 pNext = GetSiblingRadioButton(pFirst, TRUE); | 458 pNext = GetSiblingRadioButton(pFirst, TRUE); |
465 } while (pNext && ((pNext->GetStyles() & FWL_WGTSTYLE_Group) == 0)); | 459 } while (pNext && ((pNext->GetStyles() & FWL_WGTSTYLE_Group) == 0)); |
466 } | 460 } |
467 IFWL_Widget* CFWL_WidgetMgr::GetDefaultButton(IFWL_Widget* pParent) { | 461 IFWL_Widget* CFWL_WidgetMgr::GetDefaultButton(IFWL_Widget* pParent) { |
468 if ((pParent->GetClassID() == FWL_Type::PushButton) && | 462 if ((pParent->GetClassID() == FWL_Type::PushButton) && |
469 (pParent->GetStates() & (1 << (FWL_WGTSTATE_MAX + 2)))) { | 463 (pParent->GetStates() & (1 << (FWL_WGTSTATE_MAX + 2)))) { |
470 return pParent; | 464 return pParent; |
471 } | 465 } |
472 IFWL_Widget* child = | 466 IFWL_Widget* child = |
473 CFWL_WidgetMgr::GetInstance()->GetFirstChildWidget(pParent); | 467 pParent->GetOwnerApp()->GetWidgetMgr()->GetFirstChildWidget(pParent); |
474 while (child) { | 468 while (child) { |
475 if ((child->GetClassID() == FWL_Type::PushButton) && | 469 if ((child->GetClassID() == FWL_Type::PushButton) && |
476 (child->GetStates() & (1 << (FWL_WGTSTATE_MAX + 2)))) { | 470 (child->GetStates() & (1 << (FWL_WGTSTATE_MAX + 2)))) { |
477 return child; | 471 return child; |
478 } | 472 } |
479 IFWL_Widget* find = GetDefaultButton(child); | 473 IFWL_Widget* find = GetDefaultButton(child); |
480 if (find) { | 474 if (find) { |
481 return find; | 475 return find; |
482 } | 476 } |
483 child = CFWL_WidgetMgr::GetInstance()->GetNextSiblingWidget(child); | 477 child = child->GetOwnerApp()->GetWidgetMgr()->GetNextSiblingWidget(child); |
484 } | 478 } |
485 return nullptr; | 479 return nullptr; |
486 } | 480 } |
487 void CFWL_WidgetMgr::AddRedrawCounts(IFWL_Widget* pWidget) { | 481 void CFWL_WidgetMgr::AddRedrawCounts(IFWL_Widget* pWidget) { |
488 CFWL_WidgetMgrItem* pItem = GetWidgetMgrItem(pWidget); | 482 CFWL_WidgetMgrItem* pItem = GetWidgetMgrItem(pWidget); |
489 (pItem->iRedrawCounter)++; | 483 (pItem->iRedrawCounter)++; |
490 } | 484 } |
491 void CFWL_WidgetMgr::ResetRedrawCounts(IFWL_Widget* pWidget) { | 485 void CFWL_WidgetMgr::ResetRedrawCounts(IFWL_Widget* pWidget) { |
492 CFWL_WidgetMgrItem* pItem = GetWidgetMgrItem(pWidget); | 486 CFWL_WidgetMgrItem* pItem = GetWidgetMgrItem(pWidget); |
493 pItem->iRedrawCounter = 0; | 487 pItem->iRedrawCounter = 0; |
(...skipping 72 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
566 return FWL_Error::Succeeded; | 560 return FWL_Error::Succeeded; |
567 } | 561 } |
568 | 562 |
569 void CFWL_WidgetMgrDelegate::OnProcessMessageToForm(CFWL_Message* pMessage) { | 563 void CFWL_WidgetMgrDelegate::OnProcessMessageToForm(CFWL_Message* pMessage) { |
570 if (!pMessage) | 564 if (!pMessage) |
571 return; | 565 return; |
572 if (!pMessage->m_pDstTarget) | 566 if (!pMessage->m_pDstTarget) |
573 return; | 567 return; |
574 | 568 |
575 IFWL_Widget* pDstWidget = pMessage->m_pDstTarget; | 569 IFWL_Widget* pDstWidget = pMessage->m_pDstTarget; |
576 IFWL_App* pApp = pDstWidget->GetOwnerApp(); | 570 const IFWL_App* pApp = pDstWidget->GetOwnerApp(); |
577 if (!pApp) | 571 if (!pApp) |
578 return; | 572 return; |
579 | 573 |
580 CFWL_NoteDriver* pNoteDriver = | 574 CFWL_NoteDriver* pNoteDriver = |
581 static_cast<CFWL_NoteDriver*>(pApp->GetNoteDriver()); | 575 static_cast<CFWL_NoteDriver*>(pApp->GetNoteDriver()); |
582 if (!pNoteDriver) | 576 if (!pNoteDriver) |
583 return; | 577 return; |
584 | 578 |
585 if (m_pWidgetMgr->IsThreadEnabled()) | 579 if (m_pWidgetMgr->IsThreadEnabled()) |
586 pMessage = static_cast<CFWL_Message*>(pMessage->Clone()); | 580 pMessage = static_cast<CFWL_Message*>(pMessage->Clone()); |
(...skipping 161 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
748 return TRUE; | 742 return TRUE; |
749 } | 743 } |
750 CFX_RectF rtWidget; | 744 CFX_RectF rtWidget; |
751 pWidget->GetWidgetRect(rtWidget); | 745 pWidget->GetWidgetRect(rtWidget); |
752 rtWidget.left = rtWidget.top = 0; | 746 rtWidget.left = rtWidget.top = 0; |
753 pMatrix->TransformRect(rtWidget); | 747 pMatrix->TransformRect(rtWidget); |
754 if (!rtWidget.IntersectWith(rtDirty)) | 748 if (!rtWidget.IntersectWith(rtDirty)) |
755 return FALSE; | 749 return FALSE; |
756 | 750 |
757 IFWL_Widget* pChild = | 751 IFWL_Widget* pChild = |
758 CFWL_WidgetMgr::GetInstance()->GetFirstChildWidget(pWidget); | 752 pWidget->GetOwnerApp()->GetWidgetMgr()->GetFirstChildWidget(pWidget); |
759 if (!pChild) | 753 if (!pChild) |
760 return TRUE; | 754 return TRUE; |
761 | 755 |
762 CFX_RectF rtChilds; | 756 CFX_RectF rtChilds; |
763 rtChilds.Empty(); | 757 rtChilds.Empty(); |
764 FX_BOOL bChildIntersectWithDirty = FALSE; | 758 FX_BOOL bChildIntersectWithDirty = FALSE; |
765 FX_BOOL bOrginPtIntersectWidthChild = FALSE; | 759 FX_BOOL bOrginPtIntersectWidthChild = FALSE; |
766 FX_BOOL bOrginPtIntersectWidthDirty = | 760 FX_BOOL bOrginPtIntersectWidthDirty = |
767 rtDirty.Contains(rtWidget.left, rtWidget.top); | 761 rtDirty.Contains(rtWidget.left, rtWidget.top); |
768 static FWL_NEEDREPAINTHITDATA hitPoint[kNeedRepaintHitPoints]; | 762 static FWL_NEEDREPAINTHITDATA hitPoint[kNeedRepaintHitPoints]; |
(...skipping 37 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
806 for (int32_t i = 0; i < kNeedRepaintHitPoints; i++) { | 800 for (int32_t i = 0; i < kNeedRepaintHitPoints; i++) { |
807 if (hitPoint[i].bNotContainByDirty || hitPoint[i].bNotNeedRepaint) | 801 if (hitPoint[i].bNotContainByDirty || hitPoint[i].bNotNeedRepaint) |
808 continue; | 802 continue; |
809 if (!rtDirty.Contains(hitPoint[i].hitPoint)) { | 803 if (!rtDirty.Contains(hitPoint[i].hitPoint)) { |
810 hitPoint[i].bNotContainByDirty = true; | 804 hitPoint[i].bNotContainByDirty = true; |
811 continue; | 805 continue; |
812 } | 806 } |
813 if (r.Contains(hitPoint[i].hitPoint)) | 807 if (r.Contains(hitPoint[i].hitPoint)) |
814 hitPoint[i].bNotNeedRepaint = true; | 808 hitPoint[i].bNotNeedRepaint = true; |
815 } | 809 } |
816 pChild = CFWL_WidgetMgr::GetInstance()->GetNextSiblingWidget(pChild); | 810 pChild = |
| 811 pChild->GetOwnerApp()->GetWidgetMgr()->GetNextSiblingWidget(pChild); |
817 } while (pChild); | 812 } while (pChild); |
818 | 813 |
819 if (!bChildIntersectWithDirty) | 814 if (!bChildIntersectWithDirty) |
820 return TRUE; | 815 return TRUE; |
821 if (bOrginPtIntersectWidthDirty && !bOrginPtIntersectWidthChild) | 816 if (bOrginPtIntersectWidthDirty && !bOrginPtIntersectWidthChild) |
822 return TRUE; | 817 return TRUE; |
823 if (rtChilds.IsEmpty()) | 818 if (rtChilds.IsEmpty()) |
824 return TRUE; | 819 return TRUE; |
825 | 820 |
826 int32_t repaintPoint = kNeedRepaintHitPoints; | 821 int32_t repaintPoint = kNeedRepaintHitPoints; |
(...skipping 42 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
869 pWidget(widget), | 864 pWidget(widget), |
870 iRedrawCounter(0) | 865 iRedrawCounter(0) |
871 #if (_FX_OS_ == _FX_WIN32_DESKTOP_) || (_FX_OS_ == _FX_WIN64_) | 866 #if (_FX_OS_ == _FX_WIN32_DESKTOP_) || (_FX_OS_ == _FX_WIN64_) |
872 , | 867 , |
873 bOutsideChanged(FALSE) | 868 bOutsideChanged(FALSE) |
874 #endif | 869 #endif |
875 { | 870 { |
876 } | 871 } |
877 | 872 |
878 CFWL_WidgetMgrItem::~CFWL_WidgetMgrItem() {} | 873 CFWL_WidgetMgrItem::~CFWL_WidgetMgrItem() {} |
OLD | NEW |