| 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/fwl_widgetmgrimp.h" | 7 #include "xfa/fwl/core/fwl_widgetmgrimp.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_appimp.h" | 10 #include "xfa/fwl/core/fwl_appimp.h" |
| (...skipping 201 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 212 if (pItem->pParent->pChild == pChild) { | 212 if (pItem->pParent->pChild == pChild) { |
| 213 pItem->pParent->pChild = pItem; | 213 pItem->pParent->pChild = pItem; |
| 214 } | 214 } |
| 215 } else { | 215 } else { |
| 216 pItem->pParent->pChild = pItem; | 216 pItem->pParent->pChild = pItem; |
| 217 pItem->pPrevious = NULL; | 217 pItem->pPrevious = NULL; |
| 218 pItem->pNext = NULL; | 218 pItem->pNext = NULL; |
| 219 } | 219 } |
| 220 return TRUE; | 220 return TRUE; |
| 221 } | 221 } |
| 222 FWL_ERR CFWL_WidgetMgr::RepaintWidget(IFWL_Widget* pWidget, | 222 FWL_Error CFWL_WidgetMgr::RepaintWidget(IFWL_Widget* pWidget, |
| 223 const CFX_RectF* pRect) { | 223 const CFX_RectF* pRect) { |
| 224 if (!m_pAdapter) | 224 if (!m_pAdapter) |
| 225 return FWL_ERR_Indefinite; | 225 return FWL_Error::Indefinite; |
| 226 IFWL_Widget* pNative = pWidget; | 226 IFWL_Widget* pNative = pWidget; |
| 227 CFX_RectF rect(*pRect); | 227 CFX_RectF rect(*pRect); |
| 228 if (IsFormDisabled()) { | 228 if (IsFormDisabled()) { |
| 229 IFWL_Widget* pOuter = pWidget->GetOuter(); | 229 IFWL_Widget* pOuter = pWidget->GetOuter(); |
| 230 while (pOuter) { | 230 while (pOuter) { |
| 231 CFX_RectF rtTemp; | 231 CFX_RectF rtTemp; |
| 232 pNative->GetWidgetRect(rtTemp); | 232 pNative->GetWidgetRect(rtTemp); |
| 233 rect.left += rtTemp.left; | 233 rect.left += rtTemp.left; |
| 234 rect.top += rtTemp.top; | 234 rect.top += rtTemp.top; |
| 235 pNative = pOuter; | 235 pNative = pOuter; |
| 236 pOuter = pOuter->GetOuter(); | 236 pOuter = pOuter->GetOuter(); |
| 237 } | 237 } |
| 238 } else if (!IsAbleNative(pWidget)) { | 238 } else if (!IsAbleNative(pWidget)) { |
| 239 pNative = GetWidget(pWidget, FWL_WGTRELATION_SystemForm); | 239 pNative = GetWidget(pWidget, FWL_WGTRELATION_SystemForm); |
| 240 if (!pNative) | 240 if (!pNative) |
| 241 return FWL_ERR_Indefinite; | 241 return FWL_Error::Indefinite; |
| 242 pWidget->TransformTo(pNative, rect.left, rect.top); | 242 pWidget->TransformTo(pNative, rect.left, rect.top); |
| 243 } | 243 } |
| 244 AddRedrawCounts(pNative); | 244 AddRedrawCounts(pNative); |
| 245 return m_pAdapter->RepaintWidget(pNative, &rect); | 245 return m_pAdapter->RepaintWidget(pNative, &rect); |
| 246 } | 246 } |
| 247 void CFWL_WidgetMgr::AddWidget(IFWL_Widget* pWidget) { | 247 void CFWL_WidgetMgr::AddWidget(IFWL_Widget* pWidget) { |
| 248 CFWL_WidgetMgrItem* pParentItem = GetWidgetMgrItem(NULL); | 248 CFWL_WidgetMgrItem* pParentItem = GetWidgetMgrItem(NULL); |
| 249 CFWL_WidgetMgrItem* pItem = GetWidgetMgrItem(pWidget); | 249 CFWL_WidgetMgrItem* pItem = GetWidgetMgrItem(pWidget); |
| 250 if (!pItem) { | 250 if (!pItem) { |
| 251 pItem = new CFWL_WidgetMgrItem; | 251 pItem = new CFWL_WidgetMgrItem; |
| (...skipping 112 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 364 FX_BOOL CFWL_WidgetMgr::IsChild(IFWL_Widget* pChild, IFWL_Widget* pParent) { | 364 FX_BOOL CFWL_WidgetMgr::IsChild(IFWL_Widget* pChild, IFWL_Widget* pParent) { |
| 365 IFWL_Widget* pTemp = pChild; | 365 IFWL_Widget* pTemp = pChild; |
| 366 do { | 366 do { |
| 367 if (pTemp == pParent) { | 367 if (pTemp == pParent) { |
| 368 return TRUE; | 368 return TRUE; |
| 369 } | 369 } |
| 370 pTemp = GetWidget(pTemp, FWL_WGTRELATION_Parent); | 370 pTemp = GetWidget(pTemp, FWL_WGTRELATION_Parent); |
| 371 } while (pTemp); | 371 } while (pTemp); |
| 372 return FALSE; | 372 return FALSE; |
| 373 } | 373 } |
| 374 FWL_ERR CFWL_WidgetMgr::SetWidgetRect_Native(IFWL_Widget* pWidget, | 374 |
| 375 const CFX_RectF& rect) { | 375 FWL_Error CFWL_WidgetMgr::SetWidgetRect_Native(IFWL_Widget* pWidget, |
| 376 const CFX_RectF& rect) { |
| 376 if (FWL_UseOffscreen(pWidget)) { | 377 if (FWL_UseOffscreen(pWidget)) { |
| 377 CFWL_WidgetMgrItem* pItem = GetWidgetMgrItem(pWidget); | 378 CFWL_WidgetMgrItem* pItem = GetWidgetMgrItem(pWidget); |
| 378 pItem->iRedrawCounter++; | 379 pItem->iRedrawCounter++; |
| 379 if (pItem->pOffscreen) { | 380 if (pItem->pOffscreen) { |
| 380 CFX_RenderDevice* pDevice = pItem->pOffscreen->GetRenderDevice(); | 381 CFX_RenderDevice* pDevice = pItem->pOffscreen->GetRenderDevice(); |
| 381 if (pDevice && pDevice->GetBitmap()) { | 382 if (pDevice && pDevice->GetBitmap()) { |
| 382 CFX_DIBitmap* pBitmap = pDevice->GetBitmap(); | 383 CFX_DIBitmap* pBitmap = pDevice->GetBitmap(); |
| 383 if (pBitmap->GetWidth() - rect.width > 1 || | 384 if (pBitmap->GetWidth() - rect.width > 1 || |
| 384 pBitmap->GetHeight() - rect.height > 1) { | 385 pBitmap->GetHeight() - rect.height > 1) { |
| 385 delete pItem->pOffscreen; | 386 delete pItem->pOffscreen; |
| 386 pItem->pOffscreen = NULL; | 387 pItem->pOffscreen = NULL; |
| 387 } | 388 } |
| 388 } | 389 } |
| 389 } | 390 } |
| 390 #if (_FX_OS_ == _FX_WIN32_DESKTOP_) || (_FX_OS_ == _FX_WIN64_) | 391 #if (_FX_OS_ == _FX_WIN32_DESKTOP_) || (_FX_OS_ == _FX_WIN64_) |
| 391 pItem->bOutsideChanged = !m_rtScreen.Contains(rect); | 392 pItem->bOutsideChanged = !m_rtScreen.Contains(rect); |
| 392 #endif | 393 #endif |
| 393 } | 394 } |
| 394 return FWL_ERR_Succeeded; | 395 return FWL_Error::Succeeded; |
| 395 } | 396 } |
| 397 |
| 396 IFWL_Widget* CFWL_WidgetMgr::GetWidgetAtPoint(IFWL_Widget* parent, | 398 IFWL_Widget* CFWL_WidgetMgr::GetWidgetAtPoint(IFWL_Widget* parent, |
| 397 FX_FLOAT x, | 399 FX_FLOAT x, |
| 398 FX_FLOAT y) { | 400 FX_FLOAT y) { |
| 399 if (!parent) | 401 if (!parent) |
| 400 return NULL; | 402 return NULL; |
| 401 FX_FLOAT x1; | 403 FX_FLOAT x1; |
| 402 FX_FLOAT y1; | 404 FX_FLOAT y1; |
| 403 IFWL_Widget* child = GetWidget(parent, FWL_WGTRELATION_LastChild); | 405 IFWL_Widget* child = GetWidget(parent, FWL_WGTRELATION_LastChild); |
| 404 while (child) { | 406 while (child) { |
| 405 if ((child->GetStates() & FWL_WGTSTATE_Invisible) == 0) { | 407 if ((child->GetStates() & FWL_WGTSTATE_Invisible) == 0) { |
| (...skipping 218 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 624 FX_FLOAT fMinHeight, | 626 FX_FLOAT fMinHeight, |
| 625 FX_FLOAT fMaxHeight, | 627 FX_FLOAT fMaxHeight, |
| 626 const CFX_RectF& rtAnchor, | 628 const CFX_RectF& rtAnchor, |
| 627 CFX_RectF& rtPopup) { | 629 CFX_RectF& rtPopup) { |
| 628 CXFA_FWLAdapterWidgetMgr* pSDApapter = GetAdapterWidgetMgr(); | 630 CXFA_FWLAdapterWidgetMgr* pSDApapter = GetAdapterWidgetMgr(); |
| 629 return pSDApapter->GetPopupPos(pWidget, fMinHeight, fMaxHeight, rtAnchor, | 631 return pSDApapter->GetPopupPos(pWidget, fMinHeight, fMaxHeight, rtAnchor, |
| 630 rtPopup); | 632 rtPopup); |
| 631 } | 633 } |
| 632 CFWL_WidgetMgrDelegate::CFWL_WidgetMgrDelegate(CFWL_WidgetMgr* pWidgetMgr) | 634 CFWL_WidgetMgrDelegate::CFWL_WidgetMgrDelegate(CFWL_WidgetMgr* pWidgetMgr) |
| 633 : m_pWidgetMgr(pWidgetMgr) {} | 635 : m_pWidgetMgr(pWidgetMgr) {} |
| 634 FWL_ERR CFWL_WidgetMgrDelegate::OnSetCapability(uint32_t dwCapability) { | 636 FWL_Error CFWL_WidgetMgrDelegate::OnSetCapability(uint32_t dwCapability) { |
| 635 m_pWidgetMgr->m_dwCapability = dwCapability; | 637 m_pWidgetMgr->m_dwCapability = dwCapability; |
| 636 return FWL_ERR_Succeeded; | 638 return FWL_Error::Succeeded; |
| 637 } | 639 } |
| 638 int32_t CFWL_WidgetMgrDelegate::OnProcessMessageToForm(CFWL_Message* pMessage) { | 640 |
| 641 void CFWL_WidgetMgrDelegate::OnProcessMessageToForm(CFWL_Message* pMessage) { |
| 639 if (!pMessage) | 642 if (!pMessage) |
| 640 return 0; | 643 return; |
| 641 if (!pMessage->m_pDstTarget) | 644 if (!pMessage->m_pDstTarget) |
| 642 return 0; | 645 return; |
| 643 | 646 |
| 644 IFWL_Widget* pDstWidget = pMessage->m_pDstTarget; | 647 IFWL_Widget* pDstWidget = pMessage->m_pDstTarget; |
| 645 IFWL_App* pApp = pDstWidget->GetOwnerApp(); | 648 IFWL_App* pApp = pDstWidget->GetOwnerApp(); |
| 646 if (!pApp) | 649 if (!pApp) |
| 647 return 0; | 650 return; |
| 648 | 651 |
| 649 CFWL_NoteDriver* pNoteDriver = | 652 CFWL_NoteDriver* pNoteDriver = |
| 650 static_cast<CFWL_NoteDriver*>(pApp->GetNoteDriver()); | 653 static_cast<CFWL_NoteDriver*>(pApp->GetNoteDriver()); |
| 651 if (!pNoteDriver) | 654 if (!pNoteDriver) |
| 652 return 0; | 655 return; |
| 653 | 656 |
| 654 if (m_pWidgetMgr->IsThreadEnabled()) | 657 if (m_pWidgetMgr->IsThreadEnabled()) |
| 655 pMessage = static_cast<CFWL_Message*>(pMessage->Clone()); | 658 pMessage = static_cast<CFWL_Message*>(pMessage->Clone()); |
| 656 if (m_pWidgetMgr->IsFormDisabled()) | 659 if (m_pWidgetMgr->IsFormDisabled()) |
| 657 pNoteDriver->ProcessMessage(pMessage); | 660 pNoteDriver->ProcessMessage(pMessage); |
| 658 else | 661 else |
| 659 pNoteDriver->QueueMessage(pMessage); | 662 pNoteDriver->QueueMessage(pMessage); |
| 660 | 663 |
| 661 #if (_FX_OS_ == _FX_MACOSX_) | 664 #if (_FX_OS_ == _FX_MACOSX_) |
| 662 CFWL_NoteLoop* pTopLoop = pNoteDriver->GetTopLoop(); | 665 CFWL_NoteLoop* pTopLoop = pNoteDriver->GetTopLoop(); |
| 663 if (pTopLoop) { | 666 if (pTopLoop) |
| 664 pNoteDriver->UnqueueMessage(pTopLoop); | 667 pNoteDriver->UnqueueMessage(pTopLoop); |
| 665 } | |
| 666 #endif | 668 #endif |
| 667 if (m_pWidgetMgr->IsThreadEnabled()) { | 669 |
| 670 if (m_pWidgetMgr->IsThreadEnabled()) |
| 668 pMessage->Release(); | 671 pMessage->Release(); |
| 669 } | 672 |
| 670 return FWL_ERR_Succeeded; | 673 return; |
| 671 } | 674 } |
| 672 | 675 |
| 673 FWL_ERR CFWL_WidgetMgrDelegate::OnDrawWidget(IFWL_Widget* pWidget, | 676 void CFWL_WidgetMgrDelegate::OnDrawWidget(IFWL_Widget* pWidget, |
| 674 CFX_Graphics* pGraphics, | 677 CFX_Graphics* pGraphics, |
| 675 const CFX_Matrix* pMatrix) { | 678 const CFX_Matrix* pMatrix) { |
| 676 if (!pWidget) | 679 if (!pWidget || !pGraphics) |
| 677 return FWL_ERR_Indefinite; | 680 return; |
| 678 if (!pGraphics) | |
| 679 return FWL_ERR_Indefinite; | |
| 680 | 681 |
| 681 CFX_Graphics* pTemp = DrawWidgetBefore(pWidget, pGraphics, pMatrix); | 682 CFX_Graphics* pTemp = DrawWidgetBefore(pWidget, pGraphics, pMatrix); |
| 682 CFX_RectF clipCopy; | 683 CFX_RectF clipCopy; |
| 683 pWidget->GetWidgetRect(clipCopy); | 684 pWidget->GetWidgetRect(clipCopy); |
| 684 clipCopy.left = clipCopy.top = 0; | 685 clipCopy.left = clipCopy.top = 0; |
| 685 if (bUseOffscreenDirect(pWidget)) { | 686 if (bUseOffscreenDirect(pWidget)) { |
| 686 DrawWidgetAfter(pWidget, pGraphics, clipCopy, pMatrix); | 687 DrawWidgetAfter(pWidget, pGraphics, clipCopy, pMatrix); |
| 687 return FWL_ERR_Succeeded; | 688 return; |
| 688 } | 689 } |
| 689 CFX_RectF clipBounds; | 690 CFX_RectF clipBounds; |
| 690 | 691 |
| 691 #if (_FX_OS_ == _FX_WIN32_DESKTOP_) || (_FX_OS_ == _FX_WIN64_) || \ | 692 #if (_FX_OS_ == _FX_WIN32_DESKTOP_) || (_FX_OS_ == _FX_WIN64_) || \ |
| 692 (_FX_OS_ == _FX_LINUX_DESKTOP_) || (_FX_OS_ == _FX_ANDROID_) | 693 (_FX_OS_ == _FX_LINUX_DESKTOP_) || (_FX_OS_ == _FX_ANDROID_) |
| 693 IFWL_WidgetDelegate* pDelegate = pWidget->SetDelegate(NULL); | 694 IFWL_WidgetDelegate* pDelegate = pWidget->SetDelegate(NULL); |
| 694 pDelegate->OnDrawWidget(pTemp, pMatrix); | 695 pDelegate->OnDrawWidget(pTemp, pMatrix); |
| 695 pGraphics->GetClipRect(clipBounds); | 696 pGraphics->GetClipRect(clipBounds); |
| 696 clipCopy = clipBounds; | 697 clipCopy = clipBounds; |
| 697 #elif(_FX_OS_ == _FX_MACOSX_) | 698 #elif(_FX_OS_ == _FX_MACOSX_) |
| (...skipping 13 matching lines...) Expand all Loading... |
| 711 if (!m_pWidgetMgr->IsFormDisabled()) { | 712 if (!m_pWidgetMgr->IsFormDisabled()) { |
| 712 CFX_RectF rtClient; | 713 CFX_RectF rtClient; |
| 713 pWidget->GetClientRect(rtClient); | 714 pWidget->GetClientRect(rtClient); |
| 714 clipBounds.Intersect(rtClient); | 715 clipBounds.Intersect(rtClient); |
| 715 } | 716 } |
| 716 if (!clipBounds.IsEmpty()) | 717 if (!clipBounds.IsEmpty()) |
| 717 DrawChild(pWidget, clipBounds, pTemp, pMatrix); | 718 DrawChild(pWidget, clipBounds, pTemp, pMatrix); |
| 718 | 719 |
| 719 DrawWidgetAfter(pWidget, pGraphics, clipCopy, pMatrix); | 720 DrawWidgetAfter(pWidget, pGraphics, clipCopy, pMatrix); |
| 720 m_pWidgetMgr->ResetRedrawCounts(pWidget); | 721 m_pWidgetMgr->ResetRedrawCounts(pWidget); |
| 721 return FWL_ERR_Succeeded; | |
| 722 } | 722 } |
| 723 | 723 |
| 724 void CFWL_WidgetMgrDelegate::DrawChild(IFWL_Widget* parent, | 724 void CFWL_WidgetMgrDelegate::DrawChild(IFWL_Widget* parent, |
| 725 const CFX_RectF& rtClip, | 725 const CFX_RectF& rtClip, |
| 726 CFX_Graphics* pGraphics, | 726 CFX_Graphics* pGraphics, |
| 727 const CFX_Matrix* pMatrix) { | 727 const CFX_Matrix* pMatrix) { |
| 728 if (!parent) | 728 if (!parent) |
| 729 return; | 729 return; |
| 730 | 730 |
| 731 FX_BOOL bFormDisable = m_pWidgetMgr->IsFormDisabled(); | 731 FX_BOOL bFormDisable = m_pWidgetMgr->IsFormDisabled(); |
| (...skipping 201 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 933 temp.Deflate(50, 50); | 933 temp.Deflate(50, 50); |
| 934 if (!temp.Contains(r)) | 934 if (!temp.Contains(r)) |
| 935 return FALSE; | 935 return FALSE; |
| 936 | 936 |
| 937 pItem->bOutsideChanged = FALSE; | 937 pItem->bOutsideChanged = FALSE; |
| 938 } | 938 } |
| 939 #endif | 939 #endif |
| 940 | 940 |
| 941 return pItem->iRedrawCounter == 0; | 941 return pItem->iRedrawCounter == 0; |
| 942 } | 942 } |
| OLD | NEW |