diff options
Diffstat (limited to 'xfa/fwl/core')
-rw-r--r-- | xfa/fwl/core/cfwl_widgetmgr.cpp | 268 | ||||
-rw-r--r-- | xfa/fwl/core/cfwl_widgetmgr.h | 110 | ||||
-rw-r--r-- | xfa/fwl/core/fwl_noteimp.cpp | 4 | ||||
-rw-r--r-- | xfa/fwl/core/ifwl_widget.cpp | 17 | ||||
-rw-r--r-- | xfa/fwl/core/ifwl_widget.h | 2 |
5 files changed, 151 insertions, 250 deletions
diff --git a/xfa/fwl/core/cfwl_widgetmgr.cpp b/xfa/fwl/core/cfwl_widgetmgr.cpp index 90dcd6e121..310577c1f5 100644 --- a/xfa/fwl/core/cfwl_widgetmgr.cpp +++ b/xfa/fwl/core/cfwl_widgetmgr.cpp @@ -35,9 +35,7 @@ bool FWL_UseOffscreen(IFWL_Widget* pWidget) { } CFWL_WidgetMgr::CFWL_WidgetMgr(CXFA_FFApp* pAdapterNative) - : m_dwCapability(0), - m_pDelegate(new CFWL_WidgetMgrDelegate(this)), - m_pAdapter(pAdapterNative->GetWidgetMgr(m_pDelegate.get())) { + : m_dwCapability(0), m_pAdapter(pAdapterNative->GetWidgetMgr(this)) { ASSERT(m_pAdapter); m_mapWidgetItem[nullptr].reset(new CFWL_WidgetMgrItem); #if (_FX_OS_ == _FX_WIN32_DESKTOP_) || (_FX_OS_ == _FX_WIN64_) @@ -76,15 +74,6 @@ IFWL_Widget* CFWL_WidgetMgr::GetNextSiblingWidget(IFWL_Widget* pWidget) const { return pItem && pItem->pNext ? pItem->pNext->pWidget : nullptr; } -IFWL_Widget* CFWL_WidgetMgr::GetLastSiblingWidget(IFWL_Widget* pWidget) const { - CFWL_WidgetMgrItem* pItem = GetWidgetMgrItem(pWidget); - pItem = pItem ? pItem->pNext : nullptr; // Not self. - while (pItem && pItem->pNext) - pItem = pItem->pNext; - - return pItem ? pItem->pWidget : nullptr; -} - IFWL_Widget* CFWL_WidgetMgr::GetFirstChildWidget(IFWL_Widget* pWidget) const { CFWL_WidgetMgrItem* pItem = GetWidgetMgrItem(pWidget); return pItem && pItem->pChild ? pItem->pChild->pWidget : nullptr; @@ -109,19 +98,18 @@ IFWL_Widget* CFWL_WidgetMgr::GetSystemFormWidget(IFWL_Widget* pWidget) const { return nullptr; } -bool CFWL_WidgetMgr::SetWidgetIndex(IFWL_Widget* pWidget, int32_t nIndex) { +void CFWL_WidgetMgr::SetWidgetIndex(IFWL_Widget* pWidget, int32_t nIndex) { CFWL_WidgetMgrItem* pItem = GetWidgetMgrItem(pWidget); if (!pItem) - return false; + return; if (!pItem->pParent) - return false; + return; CFWL_WidgetMgrItem* pChild = pItem->pParent->pChild; int32_t i = 0; while (pChild) { if (pChild == pItem) { - if (i == nIndex) { - return true; - } + if (i == nIndex) + return; if (pChild->pPrevious) { pChild->pPrevious->pNext = pChild->pNext; } @@ -150,7 +138,7 @@ bool CFWL_WidgetMgr::SetWidgetIndex(IFWL_Widget* pWidget, int32_t nIndex) { pChild->pNext = pItem; pItem->pPrevious = pChild; pItem->pNext = nullptr; - return true; + return; } i = 0; while (i < nIndex && pChild->pNext) { @@ -161,7 +149,7 @@ bool CFWL_WidgetMgr::SetWidgetIndex(IFWL_Widget* pWidget, int32_t nIndex) { pChild->pNext = pItem; pItem->pPrevious = pChild; pItem->pNext = nullptr; - return true; + return; } if (pChild->pPrevious) { pItem->pPrevious = pChild->pPrevious; @@ -177,12 +165,13 @@ bool CFWL_WidgetMgr::SetWidgetIndex(IFWL_Widget* pWidget, int32_t nIndex) { pItem->pPrevious = nullptr; pItem->pNext = nullptr; } - return true; } -FWL_Error CFWL_WidgetMgr::RepaintWidget(IFWL_Widget* pWidget, - const CFX_RectF* pRect) { + +void CFWL_WidgetMgr::RepaintWidget(IFWL_Widget* pWidget, + const CFX_RectF* pRect) { if (!m_pAdapter) - return FWL_Error::Indefinite; + return; + IFWL_Widget* pNative = pWidget; CFX_RectF rect(*pRect); if (IsFormDisabled()) { @@ -198,33 +187,14 @@ FWL_Error CFWL_WidgetMgr::RepaintWidget(IFWL_Widget* pWidget, } else if (!IsAbleNative(pWidget)) { pNative = GetSystemFormWidget(pWidget); if (!pNative) - return FWL_Error::Indefinite; + return; + pWidget->TransformTo(pNative, rect.left, rect.top); } AddRedrawCounts(pNative); - return m_pAdapter->RepaintWidget(pNative, &rect); -} -void CFWL_WidgetMgr::AddWidget(IFWL_Widget* pWidget) { - CFWL_WidgetMgrItem* pParentItem = GetWidgetMgrItem(nullptr); - CFWL_WidgetMgrItem* pItem = GetWidgetMgrItem(pWidget); - if (!pItem) { - pItem = new CFWL_WidgetMgrItem(pWidget); - m_mapWidgetItem[pWidget].reset(pItem); - } - if (pItem->pParent && pItem->pParent != pParentItem) { - if (pItem->pPrevious) { - pItem->pPrevious->pNext = pItem->pNext; - } - if (pItem->pNext) { - pItem->pNext->pPrevious = pItem->pPrevious; - } - if (pItem->pParent->pChild == pItem) { - pItem->pParent->pChild = pItem->pNext; - } - } - pItem->pParent = pParentItem; - SetWidgetIndex(pWidget, -1); + m_pAdapter->RepaintWidget(pNative, &rect); } + void CFWL_WidgetMgr::InsertWidget(IFWL_Widget* pParent, IFWL_Widget* pChild, int32_t nIndex) { @@ -313,18 +283,8 @@ void CFWL_WidgetMgr::SetParent(IFWL_Widget* pParent, IFWL_Widget* pChild) { SetWidgetIndex(pChild, -1); } -bool CFWL_WidgetMgr::IsChild(IFWL_Widget* pChild, IFWL_Widget* pParent) { - IFWL_Widget* pTemp = pChild; - do { - if (pTemp == pParent) - return true; - pTemp = GetParentWidget(pTemp); - } while (pTemp); - return false; -} - -FWL_Error CFWL_WidgetMgr::SetWidgetRect_Native(IFWL_Widget* pWidget, - const CFX_RectF& rect) { +void CFWL_WidgetMgr::SetWidgetRect_Native(IFWL_Widget* pWidget, + const CFX_RectF& rect) { if (FWL_UseOffscreen(pWidget)) { CFWL_WidgetMgrItem* pItem = GetWidgetMgrItem(pWidget); pItem->iRedrawCounter++; @@ -342,7 +302,6 @@ FWL_Error CFWL_WidgetMgr::SetWidgetRect_Native(IFWL_Widget* pWidget, pItem->bOutsideChanged = !m_rtScreen.Contains(rect); #endif } - return FWL_Error::Succeeded; } IFWL_Widget* CFWL_WidgetMgr::GetWidgetAtPoint(IFWL_Widget* parent, @@ -383,7 +342,7 @@ void CFWL_WidgetMgr::NotifySizeChanged(IFWL_Widget* pForm, GetWidgetMgrItem(pForm)->pOffscreen.reset(); } -IFWL_Widget* CFWL_WidgetMgr::nextTab(IFWL_Widget* parent, +IFWL_Widget* CFWL_WidgetMgr::NextTab(IFWL_Widget* parent, IFWL_Widget* focus, bool& bFind) { CFWL_WidgetMgr* pMgr = parent->GetOwnerApp()->GetWidgetMgr(); @@ -396,7 +355,7 @@ IFWL_Widget* CFWL_WidgetMgr::nextTab(IFWL_Widget* parent, (!focus || (focus != child && bFind))) { return child; } - IFWL_Widget* bRet = nextTab(child, focus, bFind); + IFWL_Widget* bRet = NextTab(child, focus, bFind); if (bRet) return bRet; @@ -405,7 +364,7 @@ IFWL_Widget* CFWL_WidgetMgr::nextTab(IFWL_Widget* parent, return nullptr; } -int32_t CFWL_WidgetMgr::CountRadioButtonGroup(IFWL_Widget* pFirst) { +int32_t CFWL_WidgetMgr::CountRadioButtonGroup(IFWL_Widget* pFirst) const { int32_t iRet = 0; IFWL_Widget* pChild = pFirst; while (pChild) { @@ -414,51 +373,29 @@ int32_t CFWL_WidgetMgr::CountRadioButtonGroup(IFWL_Widget* pFirst) { } return iRet; } -IFWL_Widget* CFWL_WidgetMgr::GetSiblingRadioButton(IFWL_Widget* pWidget, - bool bNext) { - return nullptr; -} + IFWL_Widget* CFWL_WidgetMgr::GetRadioButtonGroupHeader( - IFWL_Widget* pRadioButton) { + IFWL_Widget* pRadioButton) const { IFWL_Widget* pNext = pRadioButton; - while (pNext) { - if (pNext->GetStyles() & FWL_WGTSTYLE_Group) - return pNext; - pNext = GetSiblingRadioButton(pNext, false); - } - pNext = GetLastSiblingWidget(pRadioButton); - while ((pNext = GetSiblingRadioButton(pNext, false)) != nullptr && - pNext != pRadioButton) { - if (pNext->GetStyles() & FWL_WGTSTYLE_Group) - return pNext; - } - pNext = GetFirstSiblingWidget(pRadioButton); - return GetSiblingRadioButton(pNext, true); + if (pNext && (pNext->GetStyles() & FWL_WGTSTYLE_Group)) + return pNext; + return nullptr; } + void CFWL_WidgetMgr::GetSameGroupRadioButton( IFWL_Widget* pRadioButton, - CFX_ArrayTemplate<IFWL_Widget*>& group) { + CFX_ArrayTemplate<IFWL_Widget*>& group) const { IFWL_Widget* pFirst = GetFirstSiblingWidget(pRadioButton); if (!pFirst) { pFirst = pRadioButton; } int32_t iGroup = CountRadioButtonGroup(pFirst); - if (iGroup < 2) { - IFWL_Widget* pNext = pFirst; - while ((pNext = GetSiblingRadioButton(pNext, true)) != nullptr) { - group.Add(pNext); - } + if (iGroup < 2) return; - } - IFWL_Widget* pNext = GetRadioButtonGroupHeader(pRadioButton); - do { - group.Add(pNext); - pNext = GetSiblingRadioButton(pNext, true); - if (!pNext) - pNext = GetSiblingRadioButton(pFirst, true); - } while (pNext && ((pNext->GetStyles() & FWL_WGTSTYLE_Group) == 0)); + group.Add(GetRadioButtonGroupHeader(pRadioButton)); } -IFWL_Widget* CFWL_WidgetMgr::GetDefaultButton(IFWL_Widget* pParent) { + +IFWL_Widget* CFWL_WidgetMgr::GetDefaultButton(IFWL_Widget* pParent) const { if ((pParent->GetClassID() == FWL_Type::PushButton) && (pParent->GetStates() & (1 << (FWL_WGTSTATE_MAX + 2)))) { return pParent; @@ -478,14 +415,15 @@ IFWL_Widget* CFWL_WidgetMgr::GetDefaultButton(IFWL_Widget* pParent) { } return nullptr; } + void CFWL_WidgetMgr::AddRedrawCounts(IFWL_Widget* pWidget) { - CFWL_WidgetMgrItem* pItem = GetWidgetMgrItem(pWidget); - (pItem->iRedrawCounter)++; + GetWidgetMgrItem(pWidget)->iRedrawCounter++; } + void CFWL_WidgetMgr::ResetRedrawCounts(IFWL_Widget* pWidget) { - CFWL_WidgetMgrItem* pItem = GetWidgetMgrItem(pWidget); - pItem->iRedrawCounter = 0; + GetWidgetMgrItem(pWidget)->iRedrawCounter = 0; } + CFWL_WidgetMgrItem* CFWL_WidgetMgr::GetWidgetMgrItem( IFWL_Widget* pWidget) const { auto it = m_mapWidgetItem.find(pWidget); @@ -493,36 +431,6 @@ CFWL_WidgetMgrItem* CFWL_WidgetMgr::GetWidgetMgrItem( ? static_cast<CFWL_WidgetMgrItem*>(it->second.get()) : nullptr; } -int32_t CFWL_WidgetMgr::TravelWidgetMgr(CFWL_WidgetMgrItem* pParent, - int32_t* pIndex, - CFWL_WidgetMgrItem* pItem, - IFWL_Widget** pWidget) { - if (!pParent) { - return 0; - } - int32_t iCount = 0; - CFWL_WidgetMgrItem* pChild = pParent->pChild; - while (pChild) { - iCount++; - if (pIndex) { - if (*pIndex == 0) { - *pWidget = pChild->pWidget; - return iCount; - } - pIndex--; - } - if (pItem && pItem == pChild) { - return iCount - 1; - } - pChild = pChild->pNext; - } - if (pIndex) { - return 0; - } else if (pItem) { - return -1; - } - return iCount - 1; -} bool CFWL_WidgetMgr::IsAbleNative(IFWL_Widget* pWidget) const { if (!pWidget) @@ -536,31 +444,19 @@ bool CFWL_WidgetMgr::IsAbleNative(IFWL_Widget* pWidget) const { (dwStyles & FWL_WGTSTYLE_Popup); } -bool CFWL_WidgetMgr::IsThreadEnabled() { - return !(m_dwCapability & FWL_WGTMGR_DisableThread); -} - -bool CFWL_WidgetMgr::IsFormDisabled() { - return !!(m_dwCapability & FWL_WGTMGR_DisableForm); -} - -bool CFWL_WidgetMgr::GetAdapterPopupPos(IFWL_Widget* pWidget, +void CFWL_WidgetMgr::GetAdapterPopupPos(IFWL_Widget* pWidget, FX_FLOAT fMinHeight, FX_FLOAT fMaxHeight, const CFX_RectF& rtAnchor, - CFX_RectF& rtPopup) { - CXFA_FWLAdapterWidgetMgr* pSDApapter = GetAdapterWidgetMgr(); - return pSDApapter->GetPopupPos(pWidget, fMinHeight, fMaxHeight, rtAnchor, - rtPopup); + CFX_RectF& rtPopup) const { + m_pAdapter->GetPopupPos(pWidget, fMinHeight, fMaxHeight, rtAnchor, rtPopup); } -CFWL_WidgetMgrDelegate::CFWL_WidgetMgrDelegate(CFWL_WidgetMgr* pWidgetMgr) - : m_pWidgetMgr(pWidgetMgr) {} -FWL_Error CFWL_WidgetMgrDelegate::OnSetCapability(uint32_t dwCapability) { - m_pWidgetMgr->m_dwCapability = dwCapability; - return FWL_Error::Succeeded; + +void CFWL_WidgetMgr::OnSetCapability(uint32_t dwCapability) { + m_dwCapability = dwCapability; } -void CFWL_WidgetMgrDelegate::OnProcessMessageToForm(CFWL_Message* pMessage) { +void CFWL_WidgetMgr::OnProcessMessageToForm(CFWL_Message* pMessage) { if (!pMessage) return; if (!pMessage->m_pDstTarget) @@ -576,9 +472,9 @@ void CFWL_WidgetMgrDelegate::OnProcessMessageToForm(CFWL_Message* pMessage) { if (!pNoteDriver) return; - if (m_pWidgetMgr->IsThreadEnabled()) + if (IsThreadEnabled()) pMessage = static_cast<CFWL_Message*>(pMessage->Clone()); - if (m_pWidgetMgr->IsFormDisabled()) + if (IsFormDisabled()) pNoteDriver->ProcessMessage(pMessage); else pNoteDriver->QueueMessage(pMessage); @@ -589,15 +485,15 @@ void CFWL_WidgetMgrDelegate::OnProcessMessageToForm(CFWL_Message* pMessage) { pNoteDriver->UnqueueMessage(pTopLoop); #endif - if (m_pWidgetMgr->IsThreadEnabled()) + if (IsThreadEnabled()) pMessage->Release(); return; } -void CFWL_WidgetMgrDelegate::OnDrawWidget(IFWL_Widget* pWidget, - CFX_Graphics* pGraphics, - const CFX_Matrix* pMatrix) { +void CFWL_WidgetMgr::OnDrawWidget(IFWL_Widget* pWidget, + CFX_Graphics* pGraphics, + const CFX_Matrix* pMatrix) { if (!pWidget || !pGraphics) return; @@ -605,7 +501,7 @@ void CFWL_WidgetMgrDelegate::OnDrawWidget(IFWL_Widget* pWidget, CFX_RectF clipCopy; pWidget->GetWidgetRect(clipCopy); clipCopy.left = clipCopy.top = 0; - if (bUseOffscreenDirect(pWidget)) { + if (UseOffscreenDirect(pWidget)) { DrawWidgetAfter(pWidget, pGraphics, clipCopy, pMatrix); return; } @@ -617,7 +513,7 @@ void CFWL_WidgetMgrDelegate::OnDrawWidget(IFWL_Widget* pWidget, pGraphics->GetClipRect(clipBounds); clipCopy = clipBounds; #elif _FX_OS_ == _FX_MACOSX_ - if (m_pWidgetMgr->IsFormDisabled()) { + if (IsFormDisabled()) { pWidget->GetDelegate()->OnDrawWidget(pTemp, pMatrix); pGraphics->GetClipRect(clipBounds); clipCopy = clipBounds; @@ -628,7 +524,7 @@ void CFWL_WidgetMgrDelegate::OnDrawWidget(IFWL_Widget* pWidget, } #endif // _FX_OS_ == _FX_MACOSX_ - if (!m_pWidgetMgr->IsFormDisabled()) { + if (!IsFormDisabled()) { CFX_RectF rtClient; pWidget->GetClientRect(rtClient); clipBounds.Intersect(rtClient); @@ -637,21 +533,21 @@ void CFWL_WidgetMgrDelegate::OnDrawWidget(IFWL_Widget* pWidget, DrawChild(pWidget, clipBounds, pTemp, pMatrix); DrawWidgetAfter(pWidget, pGraphics, clipCopy, pMatrix); - m_pWidgetMgr->ResetRedrawCounts(pWidget); + ResetRedrawCounts(pWidget); } -void CFWL_WidgetMgrDelegate::DrawChild(IFWL_Widget* parent, - const CFX_RectF& rtClip, - CFX_Graphics* pGraphics, - const CFX_Matrix* pMatrix) { +void CFWL_WidgetMgr::DrawChild(IFWL_Widget* parent, + const CFX_RectF& rtClip, + CFX_Graphics* pGraphics, + const CFX_Matrix* pMatrix) { if (!parent) return; - bool bFormDisable = m_pWidgetMgr->IsFormDisabled(); - IFWL_Widget* pNextChild = m_pWidgetMgr->GetFirstChildWidget(parent); + bool bFormDisable = IsFormDisabled(); + IFWL_Widget* pNextChild = GetFirstChildWidget(parent); while (pNextChild) { IFWL_Widget* child = pNextChild; - pNextChild = m_pWidgetMgr->GetNextSiblingWidget(child); + pNextChild = GetNextSiblingWidget(child); if (child->GetStates() & FWL_WGTSTATE_Invisible) continue; @@ -679,8 +575,7 @@ void CFWL_WidgetMgrDelegate::DrawChild(IFWL_Widget* parent, widgetMatrix.Translate(rtWidget.left, rtWidget.top, true); if (IFWL_WidgetDelegate* pDelegate = child->GetDelegate()) { - if (m_pWidgetMgr->IsFormDisabled() || - IsNeedRepaint(child, &widgetMatrix, rtClip)) { + if (IsFormDisabled() || IsNeedRepaint(child, &widgetMatrix, rtClip)) { pDelegate->OnDrawWidget(pGraphics, &widgetMatrix); } } @@ -689,18 +584,17 @@ void CFWL_WidgetMgrDelegate::DrawChild(IFWL_Widget* parent, DrawChild(child, clipBounds, pGraphics, bFormDisable ? &widgetMatrix : pMatrix); - child = m_pWidgetMgr->GetNextSiblingWidget(child); + child = GetNextSiblingWidget(child); } } -CFX_Graphics* CFWL_WidgetMgrDelegate::DrawWidgetBefore( - IFWL_Widget* pWidget, - CFX_Graphics* pGraphics, - const CFX_Matrix* pMatrix) { +CFX_Graphics* CFWL_WidgetMgr::DrawWidgetBefore(IFWL_Widget* pWidget, + CFX_Graphics* pGraphics, + const CFX_Matrix* pMatrix) { if (!FWL_UseOffscreen(pWidget)) return pGraphics; - CFWL_WidgetMgrItem* pItem = m_pWidgetMgr->GetWidgetMgrItem(pWidget); + CFWL_WidgetMgrItem* pItem = GetWidgetMgrItem(pWidget); if (!pItem->pOffscreen) { pItem->pOffscreen.reset(new CFX_Graphics); CFX_RectF rect; @@ -714,26 +608,26 @@ CFX_Graphics* CFWL_WidgetMgrDelegate::DrawWidgetBefore( return pItem->pOffscreen.get(); } -void CFWL_WidgetMgrDelegate::DrawWidgetAfter(IFWL_Widget* pWidget, - CFX_Graphics* pGraphics, - CFX_RectF& rtClip, - const CFX_Matrix* pMatrix) { +void CFWL_WidgetMgr::DrawWidgetAfter(IFWL_Widget* pWidget, + CFX_Graphics* pGraphics, + CFX_RectF& rtClip, + const CFX_Matrix* pMatrix) { if (FWL_UseOffscreen(pWidget)) { - CFWL_WidgetMgrItem* pItem = m_pWidgetMgr->GetWidgetMgrItem(pWidget); + CFWL_WidgetMgrItem* pItem = GetWidgetMgrItem(pWidget); pGraphics->Transfer(pItem->pOffscreen.get(), rtClip.left, rtClip.top, rtClip, pMatrix); #ifdef _WIN32 pItem->pOffscreen->ClearClip(); #endif } - CFWL_WidgetMgrItem* pItem = m_pWidgetMgr->GetWidgetMgrItem(pWidget); + CFWL_WidgetMgrItem* pItem = GetWidgetMgrItem(pWidget); pItem->iRedrawCounter = 0; } -bool CFWL_WidgetMgrDelegate::IsNeedRepaint(IFWL_Widget* pWidget, - CFX_Matrix* pMatrix, - const CFX_RectF& rtDirty) { - CFWL_WidgetMgrItem* pItem = m_pWidgetMgr->GetWidgetMgrItem(pWidget); +bool CFWL_WidgetMgr::IsNeedRepaint(IFWL_Widget* pWidget, + CFX_Matrix* pMatrix, + const CFX_RectF& rtDirty) { + CFWL_WidgetMgrItem* pItem = GetWidgetMgrItem(pWidget); if (pItem && pItem->iRedrawCounter > 0) { pItem->iRedrawCounter = 0; return true; @@ -829,8 +723,8 @@ bool CFWL_WidgetMgrDelegate::IsNeedRepaint(IFWL_Widget* pWidget, return true; } -bool CFWL_WidgetMgrDelegate::bUseOffscreenDirect(IFWL_Widget* pWidget) { - CFWL_WidgetMgrItem* pItem = m_pWidgetMgr->GetWidgetMgrItem(pWidget); +bool CFWL_WidgetMgr::UseOffscreenDirect(IFWL_Widget* pWidget) const { + CFWL_WidgetMgrItem* pItem = GetWidgetMgrItem(pWidget); if (!FWL_UseOffscreen(pWidget) || !(pItem->pOffscreen)) return false; @@ -838,7 +732,7 @@ bool CFWL_WidgetMgrDelegate::bUseOffscreenDirect(IFWL_Widget* pWidget) { if (pItem->bOutsideChanged) { CFX_RectF r; pWidget->GetWidgetRect(r); - CFX_RectF temp(m_pWidgetMgr->m_rtScreen); + CFX_RectF temp(m_rtScreen); temp.Deflate(50, 50); if (!temp.Contains(r)) return false; diff --git a/xfa/fwl/core/cfwl_widgetmgr.h b/xfa/fwl/core/cfwl_widgetmgr.h index 25c5735a98..10176c2598 100644 --- a/xfa/fwl/core/cfwl_widgetmgr.h +++ b/xfa/fwl/core/cfwl_widgetmgr.h @@ -18,7 +18,6 @@ #define FWL_WGTMGR_DisableForm 0x00000002 class CFWL_Message; -class CFWL_WidgetMgrDelegate; class CXFA_FFApp; class CXFA_FWLAdapterWidgetMgr; class CFX_Graphics; @@ -44,86 +43,84 @@ class CFWL_WidgetMgrItem { #endif }; -class CFWL_WidgetMgr { +class IFWL_WidgetMgrDelegate { + public: + virtual void OnSetCapability( + uint32_t dwCapability = FWL_WGTMGR_DisableThread) = 0; + virtual void OnProcessMessageToForm(CFWL_Message* pMessage) = 0; + virtual void OnDrawWidget(IFWL_Widget* pWidget, + CFX_Graphics* pGraphics, + const CFX_Matrix* pMatrix) = 0; +}; + +class CFWL_WidgetMgr : public IFWL_WidgetMgrDelegate { public: explicit CFWL_WidgetMgr(CXFA_FFApp* pAdapterNative); ~CFWL_WidgetMgr(); + // IFWL_WidgetMgrDelegate + void OnSetCapability( + uint32_t dwCapability = FWL_WGTMGR_DisableThread) override; + void OnProcessMessageToForm(CFWL_Message* pMessage) override; + void OnDrawWidget(IFWL_Widget* pWidget, + CFX_Graphics* pGraphics, + const CFX_Matrix* pMatrix) override; + IFWL_Widget* GetParentWidget(IFWL_Widget* pWidget) const; IFWL_Widget* GetOwnerWidget(IFWL_Widget* pWidget) const; - IFWL_Widget* GetFirstSiblingWidget(IFWL_Widget* pWidget) const; - IFWL_Widget* GetPriorSiblingWidget(IFWL_Widget* pWidget) const; IFWL_Widget* GetNextSiblingWidget(IFWL_Widget* pWidget) const; - IFWL_Widget* GetLastSiblingWidget(IFWL_Widget* pWidget) const; IFWL_Widget* GetFirstChildWidget(IFWL_Widget* pWidget) const; - IFWL_Widget* GetLastChildWidget(IFWL_Widget* pWidget) const; IFWL_Widget* GetSystemFormWidget(IFWL_Widget* pWidget) const; - bool SetWidgetIndex(IFWL_Widget* pWidget, int32_t nIndex); - FWL_Error RepaintWidget(IFWL_Widget* pWidget, - const CFX_RectF* pRect = nullptr); + void RepaintWidget(IFWL_Widget* pWidget, const CFX_RectF* pRect = nullptr); - void AddWidget(IFWL_Widget* pWidget); void InsertWidget(IFWL_Widget* pParent, IFWL_Widget* pChild, int32_t nIndex = -1); void RemoveWidget(IFWL_Widget* pWidget); void SetOwner(IFWL_Widget* pOwner, IFWL_Widget* pOwned); void SetParent(IFWL_Widget* pParent, IFWL_Widget* pChild); - bool IsChild(IFWL_Widget* pChild, IFWL_Widget* pParent); - FWL_Error SetWidgetRect_Native(IFWL_Widget* pWidget, const CFX_RectF& rect); + + void SetWidgetRect_Native(IFWL_Widget* pWidget, const CFX_RectF& rect); + IFWL_Widget* GetWidgetAtPoint(IFWL_Widget* pParent, FX_FLOAT fx, FX_FLOAT fy); + void NotifySizeChanged(IFWL_Widget* pForm, FX_FLOAT fx, FX_FLOAT fy); - IFWL_Widget* nextTab(IFWL_Widget* parent, IFWL_Widget* focus, bool& bFind); - int32_t CountRadioButtonGroup(IFWL_Widget* pFirst); - IFWL_Widget* GetSiblingRadioButton(IFWL_Widget* pWidget, bool bNext); - IFWL_Widget* GetRadioButtonGroupHeader(IFWL_Widget* pRadioButton); + + IFWL_Widget* NextTab(IFWL_Widget* parent, IFWL_Widget* focus, bool& bFind); + void GetSameGroupRadioButton(IFWL_Widget* pRadioButton, - CFX_ArrayTemplate<IFWL_Widget*>& group); - IFWL_Widget* GetDefaultButton(IFWL_Widget* pParent); + CFX_ArrayTemplate<IFWL_Widget*>& group) const; + IFWL_Widget* GetDefaultButton(IFWL_Widget* pParent) const; void AddRedrawCounts(IFWL_Widget* pWidget); - void ResetRedrawCounts(IFWL_Widget* pWidget); - CXFA_FWLAdapterWidgetMgr* GetAdapterWidgetMgr() const { return m_pAdapter; } - CFWL_WidgetMgrDelegate* GetDelegate() const { return m_pDelegate.get(); } - CFWL_WidgetMgrItem* GetWidgetMgrItem(IFWL_Widget* pWidget) const; - bool IsThreadEnabled(); - bool IsFormDisabled(); - bool GetAdapterPopupPos(IFWL_Widget* pWidget, + + bool IsFormDisabled() const { + return !!(m_dwCapability & FWL_WGTMGR_DisableForm); + } + + void GetAdapterPopupPos(IFWL_Widget* pWidget, FX_FLOAT fMinHeight, FX_FLOAT fMaxHeight, const CFX_RectF& rtAnchor, - CFX_RectF& rtPopup); + CFX_RectF& rtPopup) const; - protected: - friend class CFWL_WidgetMgrDelegate; + private: + IFWL_Widget* GetFirstSiblingWidget(IFWL_Widget* pWidget) const; + IFWL_Widget* GetPriorSiblingWidget(IFWL_Widget* pWidget) const; + IFWL_Widget* GetLastChildWidget(IFWL_Widget* pWidget) const; + CFWL_WidgetMgrItem* GetWidgetMgrItem(IFWL_Widget* pWidget) const; - int32_t TravelWidgetMgr(CFWL_WidgetMgrItem* pParent, - int32_t* pIndex, - CFWL_WidgetMgrItem* pItem, - IFWL_Widget** pWidget = nullptr); - bool IsAbleNative(IFWL_Widget* pWidget) const; + void SetWidgetIndex(IFWL_Widget* pWidget, int32_t nIndex); - uint32_t m_dwCapability; - std::unique_ptr<CFWL_WidgetMgrDelegate> m_pDelegate; - std::map<IFWL_Widget*, std::unique_ptr<CFWL_WidgetMgrItem>> m_mapWidgetItem; - CXFA_FWLAdapterWidgetMgr* const m_pAdapter; -#if (_FX_OS_ == _FX_WIN32_DESKTOP_) || (_FX_OS_ == _FX_WIN64_) - CFX_RectF m_rtScreen; -#endif -}; + int32_t CountRadioButtonGroup(IFWL_Widget* pFirst) const; + IFWL_Widget* GetRadioButtonGroupHeader(IFWL_Widget* pRadioButton) const; -class CFWL_WidgetMgrDelegate { - public: - explicit CFWL_WidgetMgrDelegate(CFWL_WidgetMgr* pWidgetMgr); - ~CFWL_WidgetMgrDelegate() {} + void ResetRedrawCounts(IFWL_Widget* pWidget); - FWL_Error OnSetCapability(uint32_t dwCapability = FWL_WGTMGR_DisableThread); - void OnProcessMessageToForm(CFWL_Message* pMessage); - void OnDrawWidget(IFWL_Widget* pWidget, - CFX_Graphics* pGraphics, - const CFX_Matrix* pMatrix); + bool IsThreadEnabled() const { + return !(m_dwCapability & FWL_WGTMGR_DisableThread); + } - protected: void DrawChild(IFWL_Widget* pParent, const CFX_RectF& rtClip, CFX_Graphics* pGraphics, @@ -138,9 +135,16 @@ class CFWL_WidgetMgrDelegate { bool IsNeedRepaint(IFWL_Widget* pWidget, CFX_Matrix* pMatrix, const CFX_RectF& rtDirty); - bool bUseOffscreenDirect(IFWL_Widget* pWidget); + bool UseOffscreenDirect(IFWL_Widget* pWidget) const; - CFWL_WidgetMgr* m_pWidgetMgr; + bool IsAbleNative(IFWL_Widget* pWidget) const; + + uint32_t m_dwCapability; + std::map<IFWL_Widget*, std::unique_ptr<CFWL_WidgetMgrItem>> m_mapWidgetItem; + CXFA_FWLAdapterWidgetMgr* const m_pAdapter; +#if (_FX_OS_ == _FX_WIN32_DESKTOP_) || (_FX_OS_ == _FX_WIN64_) + CFX_RectF m_rtScreen; +#endif }; #endif // XFA_FWL_CORE_CFWL_WIDGETMGR_H_ diff --git a/xfa/fwl/core/fwl_noteimp.cpp b/xfa/fwl/core/fwl_noteimp.cpp index c17105a3f7..f04d38d81b 100644 --- a/xfa/fwl/core/fwl_noteimp.cpp +++ b/xfa/fwl/core/fwl_noteimp.cpp @@ -386,10 +386,10 @@ bool CFWL_NoteDriver::DoKey(CFWL_MsgKey* pMsg, IFWL_Widget* pMessageForm) { pFocus = nullptr; } bool bFind = false; - IFWL_Widget* pNextTabStop = pWidgetMgr->nextTab(pForm, pFocus, bFind); + IFWL_Widget* pNextTabStop = pWidgetMgr->NextTab(pForm, pFocus, bFind); if (!pNextTabStop) { bFind = false; - pNextTabStop = pWidgetMgr->nextTab(pForm, nullptr, bFind); + pNextTabStop = pWidgetMgr->NextTab(pForm, nullptr, bFind); } if (pNextTabStop == pFocus) { return true; diff --git a/xfa/fwl/core/ifwl_widget.cpp b/xfa/fwl/core/ifwl_widget.cpp index 0768f38915..c9decffe24 100644 --- a/xfa/fwl/core/ifwl_widget.cpp +++ b/xfa/fwl/core/ifwl_widget.cpp @@ -416,23 +416,26 @@ void IFWL_Widget::SetGrab(bool bSet) { pDriver->SetGrab(this, bSet); } -bool IFWL_Widget::GetPopupPos(FX_FLOAT fMinHeight, +void IFWL_Widget::GetPopupPos(FX_FLOAT fMinHeight, FX_FLOAT fMaxHeight, const CFX_RectF& rtAnchor, CFX_RectF& rtPopup) { if (GetClassID() == FWL_Type::ComboBox) { if (m_pWidgetMgr->IsFormDisabled()) { - return m_pWidgetMgr->GetAdapterPopupPos(this, fMinHeight, fMaxHeight, - rtAnchor, rtPopup); + m_pWidgetMgr->GetAdapterPopupPos(this, fMinHeight, fMaxHeight, rtAnchor, + rtPopup); + return; } - return GetPopupPosComboBox(fMinHeight, fMaxHeight, rtAnchor, rtPopup); + GetPopupPosComboBox(fMinHeight, fMaxHeight, rtAnchor, rtPopup); + return; } if (GetClassID() == FWL_Type::DateTimePicker && m_pWidgetMgr->IsFormDisabled()) { - return m_pWidgetMgr->GetAdapterPopupPos(this, fMinHeight, fMaxHeight, - rtAnchor, rtPopup); + m_pWidgetMgr->GetAdapterPopupPos(this, fMinHeight, fMaxHeight, rtAnchor, + rtPopup); + return; } - return GetPopupPosGeneral(fMinHeight, fMaxHeight, rtAnchor, rtPopup); + GetPopupPosGeneral(fMinHeight, fMaxHeight, rtAnchor, rtPopup); } bool IFWL_Widget::GetPopupPosMenu(FX_FLOAT fMinHeight, diff --git a/xfa/fwl/core/ifwl_widget.h b/xfa/fwl/core/ifwl_widget.h index 36c587b3ea..221c29d51a 100644 --- a/xfa/fwl/core/ifwl_widget.h +++ b/xfa/fwl/core/ifwl_widget.h @@ -171,7 +171,7 @@ class IFWL_Widget : public IFWL_WidgetDelegate { int32_t iTTOAlign, CFX_RectF& rect); void SetGrab(bool bSet); - bool GetPopupPos(FX_FLOAT fMinHeight, + void GetPopupPos(FX_FLOAT fMinHeight, FX_FLOAT fMaxHeight, const CFX_RectF& rtAnchor, CFX_RectF& rtPopup); |