diff options
author | tsepez <tsepez@chromium.org> | 2016-05-24 09:46:02 -0700 |
---|---|---|
committer | Commit bot <commit-bot@chromium.org> | 2016-05-24 09:46:02 -0700 |
commit | 1529756d0d62638ea0fc7965416bef717ff47413 (patch) | |
tree | 81f94e0c8cc9e093a97bf59d907d051bb6086039 /xfa/fwl | |
parent | ded3634145b214b11212a7c53faa8ba15a1789ca (diff) | |
download | pdfium-1529756d0d62638ea0fc7965416bef717ff47413.tar.xz |
Remove IWFL_WidgetMgr in favor of CFWL_WidgetMgr.
The pure virtual class isn't buying us anything, and is costing
us an otherwise unneeded vtable.
Fix pre-existing presubmit warning in fwl_noteimp.cpp:88:
If statement had no body and no else clause ...
Remove switch on enum() and make separate GetWidget() methods.
Review-Url: https://codereview.chromium.org/2004213002
Diffstat (limited to 'xfa/fwl')
-rw-r--r-- | xfa/fwl/basewidget/fwl_checkboximp.cpp | 3 | ||||
-rw-r--r-- | xfa/fwl/basewidget/fwl_editimp.cpp | 3 | ||||
-rw-r--r-- | xfa/fwl/core/fwl_appimp.cpp | 7 | ||||
-rw-r--r-- | xfa/fwl/core/fwl_appimp.h | 3 | ||||
-rw-r--r-- | xfa/fwl/core/fwl_formimp.cpp | 21 | ||||
-rw-r--r-- | xfa/fwl/core/fwl_noteimp.cpp | 65 | ||||
-rw-r--r-- | xfa/fwl/core/fwl_widgetimp.cpp | 49 | ||||
-rw-r--r-- | xfa/fwl/core/fwl_widgetmgrimp.cpp | 199 | ||||
-rw-r--r-- | xfa/fwl/core/fwl_widgetmgrimp.h | 35 | ||||
-rw-r--r-- | xfa/fwl/core/ifwl_app.h | 4 | ||||
-rw-r--r-- | xfa/fwl/core/ifwl_widgetmgr.h | 47 | ||||
-rw-r--r-- | xfa/fwl/lightwidget/cfwl_widget.cpp | 2 | ||||
-rw-r--r-- | xfa/fwl/theme/cfwl_widgettp.cpp | 9 |
13 files changed, 184 insertions, 263 deletions
diff --git a/xfa/fwl/basewidget/fwl_checkboximp.cpp b/xfa/fwl/basewidget/fwl_checkboximp.cpp index 574da160ee..ade6ebf155 100644 --- a/xfa/fwl/basewidget/fwl_checkboximp.cpp +++ b/xfa/fwl/basewidget/fwl_checkboximp.cpp @@ -368,8 +368,7 @@ void CFWL_CheckBoxImp::NextStates() { if (m_pProperties->m_dwStyleExes & FWL_STYLEEXT_CKB_RadioButton) { if ((m_pProperties->m_dwStates & FWL_STATE_CKB_CheckMask) == FWL_STATE_CKB_Unchecked) { - CFWL_WidgetMgr* pWidgetMgr = - static_cast<CFWL_WidgetMgr*>(FWL_GetWidgetMgr()); + CFWL_WidgetMgr* pWidgetMgr = CFWL_WidgetMgr::GetInstance(); if (!pWidgetMgr->IsFormDisabled()) { CFX_ArrayTemplate<IFWL_Widget*> radioarr; pWidgetMgr->GetSameGroupRadioButton(m_pInterface, radioarr); diff --git a/xfa/fwl/basewidget/fwl_editimp.cpp b/xfa/fwl/basewidget/fwl_editimp.cpp index 423d0b5c28..5975062902 100644 --- a/xfa/fwl/basewidget/fwl_editimp.cpp +++ b/xfa/fwl/basewidget/fwl_editimp.cpp @@ -1013,8 +1013,7 @@ void CFWL_EditImp::DrawContent(CFX_Graphics* pGraphics, (m_pProperties->m_dwStyleExes & FWL_STYLEEXT_EDT_NoHideSel) || (m_pProperties->m_dwStates & FWL_WGTSTATE_Focused); if (bShowSel) { - IFWL_Widget* pForm = - m_pWidgetMgr->GetWidget(m_pInterface, FWL_WGTRELATION_SystemForm); + IFWL_Widget* pForm = m_pWidgetMgr->GetSystemFormWidget(m_pInterface); if (pForm) { bShowSel = (pForm->GetStates() & FWL_WGTSTATE_Deactivated) != FWL_WGTSTATE_Deactivated; diff --git a/xfa/fwl/core/fwl_appimp.cpp b/xfa/fwl/core/fwl_appimp.cpp index d7fa8bc1c0..1b90d369b5 100644 --- a/xfa/fwl/core/fwl_appimp.cpp +++ b/xfa/fwl/core/fwl_appimp.cpp @@ -32,7 +32,7 @@ CXFA_FFApp* IFWL_App::GetAdapterNative() { return static_cast<CFWL_AppImp*>(GetImpl())->GetAdapterNative(); } -IFWL_WidgetMgr* IFWL_App::GetWidgetMgr() { +CFWL_WidgetMgr* IFWL_App::GetWidgetMgr() { return static_cast<CFWL_AppImp*>(GetImpl())->GetWidgetMgr(); } @@ -76,10 +76,9 @@ CXFA_FFApp* CFWL_AppImp::GetAdapterNative() const { return m_pAdapterNative; } CXFA_FWLAdapterWidgetMgr* FWL_GetAdapterWidgetMgr() { - return static_cast<CFWL_WidgetMgr*>(FWL_GetWidgetMgr()) - ->GetAdapterWidgetMgr(); + return CFWL_WidgetMgr::GetInstance()->GetAdapterWidgetMgr(); } -IFWL_WidgetMgr* CFWL_AppImp::GetWidgetMgr() const { +CFWL_WidgetMgr* CFWL_AppImp::GetWidgetMgr() const { return m_pWidgetMgr.get(); } diff --git a/xfa/fwl/core/fwl_appimp.h b/xfa/fwl/core/fwl_appimp.h index b138ccb5be..f3377048fc 100644 --- a/xfa/fwl/core/fwl_appimp.h +++ b/xfa/fwl/core/fwl_appimp.h @@ -16,7 +16,6 @@ class CXFA_FFApp; class IFWL_App; class IFWL_NoteThread; class IFWL_ThemeProvider; -class IFWL_WidgetMgr; class CFWL_AppImp { public: @@ -29,7 +28,7 @@ class CFWL_AppImp { FWL_Error Initialize(); FWL_Error Finalize(); CXFA_FFApp* GetAdapterNative() const; - IFWL_WidgetMgr* GetWidgetMgr() const; + CFWL_WidgetMgr* GetWidgetMgr() const; IFWL_ThemeProvider* GetThemeProvider() const; void SetThemeProvider(IFWL_ThemeProvider* pThemeProvider); void Exit(int32_t iExitCode); diff --git a/xfa/fwl/core/fwl_formimp.cpp b/xfa/fwl/core/fwl_formimp.cpp index bcaba2c153..9cfd70e4c7 100644 --- a/xfa/fwl/core/fwl_formimp.cpp +++ b/xfa/fwl/core/fwl_formimp.cpp @@ -151,7 +151,7 @@ FWL_Error CFWL_FormImp::GetClientRect(CFX_RectF& rect) { } #ifdef FWL_UseMacSystemBorder rect = m_rtRelative; - CFWL_WidgetMgr* pWidgetMgr = static_cast<CFWL_WidgetMgr*>(FWL_GetWidgetMgr()); + CFWL_WidgetMgr* pWidgetMgr = CFWL_WidgetMgr::GetInstance(); if (!pWidgetMgr) return FWL_Error::Indefinite; @@ -447,15 +447,15 @@ void CFWL_FormImp::ShowChildWidget(IFWL_Widget* pParent) { IFWL_App* pApp = FWL_GetApp(); if (!pApp) return; - CFWL_WidgetMgr* pWidgetMgr = - static_cast<CFWL_WidgetMgr*>(pApp->GetWidgetMgr()); + + CFWL_WidgetMgr* pWidgetMgr = pApp->GetWidgetMgr(); if (!pWidgetMgr) return; - IFWL_Widget* pChild = - pWidgetMgr->GetWidget(pParent, FWL_WGTRELATION_FirstChild); + + IFWL_Widget* pChild = pWidgetMgr->GetFirstChildWidget(pParent); while (pChild) { ShowChildWidget(pChild); - pChild = pWidgetMgr->GetWidget(pChild, FWL_WGTRELATION_NextSibling); + pChild = pWidgetMgr->GetNextSiblingWidget(pChild); } } @@ -616,7 +616,7 @@ void CFWL_FormImp::GetEdgeRect(CFX_RectF& rtEdge) { } void CFWL_FormImp::SetWorkAreaRect() { m_rtRestore = m_pProperties->m_rtWidget; - CFWL_WidgetMgr* pWidgetMgr = static_cast<CFWL_WidgetMgr*>(FWL_GetWidgetMgr()); + CFWL_WidgetMgr* pWidgetMgr = CFWL_WidgetMgr::GetInstance(); if (!pWidgetMgr) return; m_bSetMaximize = TRUE; @@ -765,7 +765,7 @@ FX_BOOL CFWL_FormImp::HasIcon() { return !!pData->GetIcon(m_pInterface, FALSE); } void CFWL_FormImp::UpdateIcon() { - CFWL_WidgetMgr* pWidgetMgr = static_cast<CFWL_WidgetMgr*>(FWL_GetWidgetMgr()); + CFWL_WidgetMgr* pWidgetMgr = CFWL_WidgetMgr::GetInstance(); if (!pWidgetMgr) return; IFWL_FormDP* pData = @@ -778,7 +778,7 @@ void CFWL_FormImp::UpdateIcon() { m_pSmallIcon = pSmallIcon; } void CFWL_FormImp::UpdateCaption() { - CFWL_WidgetMgr* pWidgetMgr = static_cast<CFWL_WidgetMgr*>(FWL_GetWidgetMgr()); + CFWL_WidgetMgr* pWidgetMgr = CFWL_WidgetMgr::GetInstance(); if (!pWidgetMgr) return; IFWL_FormDP* pData = @@ -935,8 +935,7 @@ void CFWL_FormImpDelegate::OnProcessMessage(CFWL_Message* pMessage) { break; } case CFWL_MessageType::Size: { - CFWL_WidgetMgr* pWidgetMgr = - static_cast<CFWL_WidgetMgr*>(FWL_GetWidgetMgr()); + CFWL_WidgetMgr* pWidgetMgr = CFWL_WidgetMgr::GetInstance(); if (!pWidgetMgr) return; diff --git a/xfa/fwl/core/fwl_noteimp.cpp b/xfa/fwl/core/fwl_noteimp.cpp index 4db2d6bb5f..7d123f7560 100644 --- a/xfa/fwl/core/fwl_noteimp.cpp +++ b/xfa/fwl/core/fwl_noteimp.cpp @@ -83,9 +83,9 @@ void CFWL_NoteDriver::SendEvent(CFWL_Event* pNote) { if (CFWL_EventType::Mouse == pNote->GetClassID()) { CFWL_EvtMouse* pMouse = static_cast<CFWL_EvtMouse*>(pNote); if (FWL_MouseCommand::Hover == pMouse->m_dwCmd) { - if (m_pNoteLoop->GetForm() && - CFWL_ToolTipContainer::getInstance()->ProcessEnter( - pMouse, m_pNoteLoop->GetForm()->GetInterface())) { + if (m_pNoteLoop->GetForm()) { + CFWL_ToolTipContainer::getInstance()->ProcessEnter( + pMouse, m_pNoteLoop->GetForm()->GetInterface()); } } else if (FWL_MouseCommand::Leave == pMouse->m_dwCmd) { CFWL_ToolTipContainer::getInstance()->ProcessLeave(pMouse); @@ -173,7 +173,7 @@ FX_BOOL CFWL_NoteDriver::SetFocus(IFWL_Widget* pFocus, FX_BOOL bNotify) { } if (pFocus) { IFWL_Widget* pWidget = - FWL_GetWidgetMgr()->GetWidget(pFocus, FWL_WGTRELATION_SystemForm); + CFWL_WidgetMgr::GetInstance()->GetSystemFormWidget(pFocus); CFWL_FormImp* pForm = pWidget ? static_cast<CFWL_FormImp*>(pWidget->GetImpl()) : nullptr; if (pForm) { @@ -194,7 +194,7 @@ FX_BOOL CFWL_NoteDriver::SetFocus(IFWL_Widget* pFocus, FX_BOOL bNotify) { return TRUE; } FWL_Error CFWL_NoteDriver::Run() { - CFWL_WidgetMgr* pWidgetMgr = static_cast<CFWL_WidgetMgr*>(FWL_GetWidgetMgr()); + CFWL_WidgetMgr* pWidgetMgr = CFWL_WidgetMgr::GetInstance(); if (!pWidgetMgr) return FWL_Error::Indefinite; @@ -319,7 +319,7 @@ int32_t CFWL_NoteDriver::CountLoop() { } FX_BOOL CFWL_NoteDriver::ProcessMessage(CFWL_Message* pMessage) { - CFWL_WidgetMgr* pWidgetMgr = static_cast<CFWL_WidgetMgr*>(FWL_GetWidgetMgr()); + CFWL_WidgetMgr* pWidgetMgr = CFWL_WidgetMgr::GetInstance(); IFWL_Widget* pMessageForm = pWidgetMgr->IsFormDisabled() ? pMessage->m_pDstTarget : GetMessageForm(pMessage->m_pDstTarget); @@ -436,22 +436,21 @@ FX_BOOL CFWL_NoteDriver::DoDeactivate(CFWL_MsgDeactivate* pMsg, } FX_BOOL CFWL_NoteDriver::DoSetFocus(CFWL_MsgSetFocus* pMsg, IFWL_Widget* pMessageForm) { - CFWL_WidgetMgr* pWidgetMgr = static_cast<CFWL_WidgetMgr*>(FWL_GetWidgetMgr()); + CFWL_WidgetMgr* pWidgetMgr = CFWL_WidgetMgr::GetInstance(); if (pWidgetMgr->IsFormDisabled()) { m_pFocus = pMsg->m_pDstTarget; return TRUE; - } else { - IFWL_Widget* pWidget = pMsg->m_pDstTarget; - CFWL_FormImp* pForm = - pWidget ? static_cast<CFWL_FormImp*>(pWidget->GetImpl()) : nullptr; - if (pForm) { - CFWL_WidgetImp* pSubFocus = pForm->GetSubFocus(); - if (pSubFocus && ((pSubFocus->GetStates() & FWL_WGTSTATE_Focused) == 0)) { - pMsg->m_pDstTarget = pSubFocus->GetInterface(); - if (m_pFocus != pMsg->m_pDstTarget) { - m_pFocus = pMsg->m_pDstTarget; - return TRUE; - } + } + IFWL_Widget* pWidget = pMsg->m_pDstTarget; + CFWL_FormImp* pForm = + pWidget ? static_cast<CFWL_FormImp*>(pWidget->GetImpl()) : nullptr; + if (pForm) { + CFWL_WidgetImp* pSubFocus = pForm->GetSubFocus(); + if (pSubFocus && ((pSubFocus->GetStates() & FWL_WGTSTATE_Focused) == 0)) { + pMsg->m_pDstTarget = pSubFocus->GetInterface(); + if (m_pFocus != pMsg->m_pDstTarget) { + m_pFocus = pMsg->m_pDstTarget; + return TRUE; } } } @@ -459,7 +458,7 @@ FX_BOOL CFWL_NoteDriver::DoSetFocus(CFWL_MsgSetFocus* pMsg, } FX_BOOL CFWL_NoteDriver::DoKillFocus(CFWL_MsgKillFocus* pMsg, IFWL_Widget* pMessageForm) { - CFWL_WidgetMgr* pWidgetMgr = static_cast<CFWL_WidgetMgr*>(FWL_GetWidgetMgr()); + CFWL_WidgetMgr* pWidgetMgr = CFWL_WidgetMgr::GetInstance(); if (pWidgetMgr->IsFormDisabled()) { if (m_pFocus == pMsg->m_pDstTarget) { m_pFocus = NULL; @@ -485,21 +484,18 @@ FX_BOOL CFWL_NoteDriver::DoKey(CFWL_MsgKey* pMsg, IFWL_Widget* pMessageForm) { #if (_FX_OS_ != _FX_MACOSX_) if (pMsg->m_dwCmd == FWL_KeyCommand::KeyDown && pMsg->m_dwKeyCode == FWL_VKEY_Tab) { - CFWL_WidgetMgr* pWidgetMgr = - static_cast<CFWL_WidgetMgr*>(FWL_GetWidgetMgr()); + CFWL_WidgetMgr* pWidgetMgr = CFWL_WidgetMgr::GetInstance(); IFWL_Widget* pForm = GetMessageForm(pMsg->m_pDstTarget); IFWL_Widget* pFocus = m_pFocus; if (m_pFocus) { - if (pWidgetMgr->GetWidget(m_pFocus, FWL_WGTRELATION_SystemForm) != - pForm) { - pFocus = NULL; - } + if (pWidgetMgr->GetSystemFormWidget(m_pFocus) != pForm) + pFocus = nullptr; } FX_BOOL bFind = FALSE; IFWL_Widget* pNextTabStop = pWidgetMgr->nextTab(pForm, pFocus, bFind); if (!pNextTabStop) { bFind = FALSE; - pNextTabStop = pWidgetMgr->nextTab(pForm, NULL, bFind); + pNextTabStop = pWidgetMgr->nextTab(pForm, nullptr, bFind); } if (pNextTabStop == pFocus) { return TRUE; @@ -513,8 +509,7 @@ FX_BOOL CFWL_NoteDriver::DoKey(CFWL_MsgKey* pMsg, IFWL_Widget* pMessageForm) { if (!m_pFocus) { if (pMsg->m_dwCmd == FWL_KeyCommand::KeyDown && pMsg->m_dwKeyCode == FWL_VKEY_Return) { - CFWL_WidgetMgr* pWidgetMgr = - static_cast<CFWL_WidgetMgr*>(FWL_GetWidgetMgr()); + CFWL_WidgetMgr* pWidgetMgr = CFWL_WidgetMgr::GetInstance(); IFWL_Widget* defButton = pWidgetMgr->GetDefaultButton(pMessageForm); if (defButton) { pMsg->m_pDstTarget = defButton; @@ -543,7 +538,7 @@ FX_BOOL CFWL_NoteDriver::DoMouse(CFWL_MsgMouse* pMsg, } FX_BOOL CFWL_NoteDriver::DoWheel(CFWL_MsgMouseWheel* pMsg, IFWL_Widget* pMessageForm) { - CFWL_WidgetMgr* pWidgetMgr = static_cast<CFWL_WidgetMgr*>(FWL_GetWidgetMgr()); + CFWL_WidgetMgr* pWidgetMgr = CFWL_WidgetMgr::GetInstance(); if (!pWidgetMgr) return FALSE; @@ -557,7 +552,7 @@ FX_BOOL CFWL_NoteDriver::DoWheel(CFWL_MsgMouseWheel* pMsg, return TRUE; } FX_BOOL CFWL_NoteDriver::DoSize(CFWL_MsgSize* pMsg) { - CFWL_WidgetMgr* pWidgetMgr = static_cast<CFWL_WidgetMgr*>(FWL_GetWidgetMgr()); + CFWL_WidgetMgr* pWidgetMgr = CFWL_WidgetMgr::GetInstance(); if (!pWidgetMgr) return FALSE; pWidgetMgr->NotifySizeChanged(pMsg->m_pDstTarget, (FX_FLOAT)pMsg->m_iWidth, @@ -574,7 +569,7 @@ FX_BOOL CFWL_NoteDriver::DoDragFiles(CFWL_MsgDropFiles* pMsg, } FX_BOOL CFWL_NoteDriver::DoMouseEx(CFWL_MsgMouse* pMsg, IFWL_Widget* pMessageForm) { - CFWL_WidgetMgr* pWidgetMgr = static_cast<CFWL_WidgetMgr*>(FWL_GetWidgetMgr()); + CFWL_WidgetMgr* pWidgetMgr = CFWL_WidgetMgr::GetInstance(); if (!pWidgetMgr) return FALSE; IFWL_Widget* pTarget = NULL; @@ -655,12 +650,10 @@ IFWL_Widget* CFWL_NoteDriver::GetMessageForm(IFWL_Widget* pDstTarget) { pMessageForm = pDstTarget; } if (!pMessageForm && pDstTarget) { - CFWL_WidgetMgr* pWidgetMgr = - static_cast<CFWL_WidgetMgr*>(FWL_GetWidgetMgr()); + CFWL_WidgetMgr* pWidgetMgr = CFWL_WidgetMgr::GetInstance(); if (!pWidgetMgr) return nullptr; - pMessageForm = - pWidgetMgr->GetWidget(pDstTarget, FWL_WGTRELATION_SystemForm); + pMessageForm = pWidgetMgr->GetSystemFormWidget(pDstTarget); } return pMessageForm; } diff --git a/xfa/fwl/core/fwl_widgetimp.cpp b/xfa/fwl/core/fwl_widgetimp.cpp index e72a7f385a..f6e130b563 100644 --- a/xfa/fwl/core/fwl_widgetimp.cpp +++ b/xfa/fwl/core/fwl_widgetimp.cpp @@ -209,18 +209,20 @@ FWL_Error CFWL_WidgetImp::GetWidgetRect(CFX_RectF& rect, FX_BOOL bAutoSize) { } return FWL_Error::Succeeded; } + FWL_Error CFWL_WidgetImp::GetGlobalRect(CFX_RectF& rect) { - IFWL_Widget* pForm = - m_pWidgetMgr->GetWidget(m_pInterface, FWL_WGTRELATION_SystemForm); + IFWL_Widget* pForm = m_pWidgetMgr->GetSystemFormWidget(m_pInterface); if (!pForm) return FWL_Error::Indefinite; + rect.Set(0, 0, m_pProperties->m_rtWidget.width, m_pProperties->m_rtWidget.height); - if (pForm == m_pInterface) { + if (pForm == m_pInterface) return FWL_Error::Succeeded; - } + return TransformTo(pForm, rect); } + FWL_Error CFWL_WidgetImp::SetWidgetRect(const CFX_RectF& rect) { CFX_RectF rtOld = m_pProperties->m_rtWidget; m_pProperties->m_rtWidget = rect; @@ -250,7 +252,7 @@ FWL_Error CFWL_WidgetImp::GetClientRect(CFX_RectF& rect) { return FWL_Error::Succeeded; } IFWL_Widget* CFWL_WidgetImp::GetParent() { - return m_pWidgetMgr->GetWidget(m_pInterface, FWL_WGTRELATION_Parent); + return m_pWidgetMgr->GetParentWidget(m_pInterface); } FWL_Error CFWL_WidgetImp::SetParent(IFWL_Widget* pParent) { m_pProperties->m_pParent = pParent; @@ -258,7 +260,7 @@ FWL_Error CFWL_WidgetImp::SetParent(IFWL_Widget* pParent) { return FWL_Error::Succeeded; } IFWL_Widget* CFWL_WidgetImp::GetOwner() { - return m_pWidgetMgr->GetWidget(m_pInterface, FWL_WGTRELATION_Owner); + return m_pWidgetMgr->GetOwnerWidget(m_pInterface); } FWL_Error CFWL_WidgetImp::SetOwner(IFWL_Widget* pOwner) { m_pProperties->m_pOwner = pOwner; @@ -289,14 +291,14 @@ FWL_Error CFWL_WidgetImp::ModifyStylesEx(uint32_t dwStylesExAdded, uint32_t CFWL_WidgetImp::GetStates() { return m_pProperties->m_dwStates; } -static void NotifyHideChildWidget(IFWL_WidgetMgr* widgetMgr, +static void NotifyHideChildWidget(CFWL_WidgetMgr* widgetMgr, IFWL_Widget* widget, CFWL_NoteDriver* noteDriver) { - IFWL_Widget* child = widgetMgr->GetWidget(widget, FWL_WGTRELATION_FirstChild); + IFWL_Widget* child = widgetMgr->GetFirstChildWidget(widget); while (child) { noteDriver->NotifyTargetHide(child); NotifyHideChildWidget(widgetMgr, child, noteDriver); - child = widgetMgr->GetWidget(child, FWL_WGTRELATION_NextSibling); + child = widgetMgr->GetNextSiblingWidget(child); } } @@ -308,14 +310,13 @@ void CFWL_WidgetImp::SetStates(uint32_t dwStates, FX_BOOL bSet) { CFWL_NoteDriver* noteDriver = static_cast<CFWL_NoteDriver*>(GetOwnerApp()->GetNoteDriver()); - IFWL_WidgetMgr* widgetMgr = FWL_GetWidgetMgr(); + CFWL_WidgetMgr* widgetMgr = CFWL_WidgetMgr::GetInstance(); noteDriver->NotifyTargetHide(m_pInterface); - IFWL_Widget* child = - widgetMgr->GetWidget(m_pInterface, FWL_WGTRELATION_FirstChild); + IFWL_Widget* child = widgetMgr->GetFirstChildWidget(m_pInterface); while (child) { noteDriver->NotifyTargetHide(child); NotifyHideChildWidget(widgetMgr, child, noteDriver); - child = widgetMgr->GetWidget(child, FWL_WGTRELATION_NextSibling); + child = widgetMgr->GetNextSiblingWidget(child); } return; } @@ -391,8 +392,7 @@ FWL_Error CFWL_WidgetImp::TransformTo(IFWL_Widget* pWidget, GetMatrix(m, TRUE); m.TransformPoint(fx, fy); } - IFWL_Widget* form1 = - m_pWidgetMgr->GetWidget(m_pInterface, FWL_WGTRELATION_SystemForm); + IFWL_Widget* form1 = m_pWidgetMgr->GetSystemFormWidget(m_pInterface); if (!form1) return FWL_Error::Indefinite; if (!pWidget) { @@ -401,8 +401,7 @@ FWL_Error CFWL_WidgetImp::TransformTo(IFWL_Widget* pWidget, fy += r.top; return FWL_Error::Succeeded; } - IFWL_Widget* form2 = - m_pWidgetMgr->GetWidget(pWidget, FWL_WGTRELATION_SystemForm); + IFWL_Widget* form2 = m_pWidgetMgr->GetSystemFormWidget(pWidget); if (!form2) return FWL_Error::Indefinite; if (form1 != form2) { @@ -517,7 +516,7 @@ CFWL_WidgetImp::CFWL_WidgetImp(const CFWL_WidgetImpProperties& properties, m_pInterface(NULL), m_iLock(0) { *m_pProperties = properties; - m_pWidgetMgr = static_cast<CFWL_WidgetMgr*>(FWL_GetWidgetMgr()); + m_pWidgetMgr = CFWL_WidgetMgr::GetInstance(); ASSERT(m_pWidgetMgr != NULL); } CFWL_WidgetImp::~CFWL_WidgetImp() { @@ -617,15 +616,13 @@ IFWL_ThemeProvider* CFWL_WidgetImp::GetAvailableTheme() { } IFWL_Widget* pUp = m_pInterface; do { - FWL_WGTRELATION relation = (pUp->GetStyles() & FWL_WGTSTYLE_Popup) - ? FWL_WGTRELATION_Owner - : FWL_WGTRELATION_Parent; - pUp = m_pWidgetMgr->GetWidget(pUp, relation); + pUp = (pUp->GetStyles() & FWL_WGTSTYLE_Popup) + ? m_pWidgetMgr->GetOwnerWidget(pUp) + : m_pWidgetMgr->GetParentWidget(pUp); if (pUp) { IFWL_ThemeProvider* pRet = pUp->GetThemeProvider(); - if (pRet && pRet->IsValidWidget(m_pInterface)) { + if (pRet && pRet->IsValidWidget(m_pInterface)) return pRet; - } } } while (pUp); return FWL_GetApp()->GetThemeProvider(); @@ -929,7 +926,7 @@ CFX_SizeF CFWL_WidgetImp::GetOffsetFromParent(IFWL_Widget* pParent) { if (pParent == GetInterface()) return CFX_SizeF(); - IFWL_WidgetMgr* pWidgetMgr = FWL_GetWidgetMgr(); + CFWL_WidgetMgr* pWidgetMgr = CFWL_WidgetMgr::GetInstance(); if (!pWidgetMgr) return CFX_SizeF(); @@ -941,7 +938,7 @@ CFX_SizeF CFWL_WidgetImp::GetOffsetFromParent(IFWL_Widget* pParent) { CFX_RectF rtDst; pDstWidget->GetWidgetRect(rtDst); szRet += CFX_SizeF(rtDst.left, rtDst.top); - pDstWidget = pWidgetMgr->GetWidget(pDstWidget, FWL_WGTRELATION_Parent); + pDstWidget = pWidgetMgr->GetParentWidget(pDstWidget); } return szRet; } diff --git a/xfa/fwl/core/fwl_widgetmgrimp.cpp b/xfa/fwl/core/fwl_widgetmgrimp.cpp index 93f39a98e5..98d135c96d 100644 --- a/xfa/fwl/core/fwl_widgetmgrimp.cpp +++ b/xfa/fwl/core/fwl_widgetmgrimp.cpp @@ -36,11 +36,10 @@ FX_BOOL FWL_UseOffscreen(IFWL_Widget* pWidget) { #endif } -IFWL_WidgetMgr* FWL_GetWidgetMgr() { +// static +CFWL_WidgetMgr* CFWL_WidgetMgr::GetInstance() { IFWL_App* pApp = FWL_GetApp(); - if (!pApp) - return NULL; - return pApp->GetWidgetMgr(); + return pApp ? pApp->GetWidgetMgr() : nullptr; } CFWL_WidgetMgr::CFWL_WidgetMgr(CXFA_FFApp* pAdapterNative) @@ -56,88 +55,68 @@ CFWL_WidgetMgr::CFWL_WidgetMgr(CXFA_FFApp* pAdapterNative) CFWL_WidgetMgr::~CFWL_WidgetMgr() {} -int32_t CFWL_WidgetMgr::CountWidgets(IFWL_Widget* pParent) { - CFWL_WidgetMgrItem* pParentItem = GetWidgetMgrItem(pParent); - return TravelWidgetMgr(pParentItem, NULL, NULL); +IFWL_Widget* CFWL_WidgetMgr::GetParentWidget(IFWL_Widget* pWidget) const { + CFWL_WidgetMgrItem* pItem = GetWidgetMgrItem(pWidget); + return pItem && pItem->pParent ? pItem->pParent->pWidget : nullptr; } -IFWL_Widget* CFWL_WidgetMgr::GetWidget(int32_t nIndex, IFWL_Widget* pParent) { - CFWL_WidgetMgrItem* pParentItem = GetWidgetMgrItem(pParent); - IFWL_Widget* pWidget = NULL; - TravelWidgetMgr(pParentItem, &nIndex, NULL, &pWidget); - return pWidget; + +IFWL_Widget* CFWL_WidgetMgr::GetOwnerWidget(IFWL_Widget* pWidget) const { + CFWL_WidgetMgrItem* pItem = GetWidgetMgrItem(pWidget); + return pItem && pItem->pOwner ? pItem->pOwner->pWidget : nullptr; } -IFWL_Widget* CFWL_WidgetMgr::GetWidget(IFWL_Widget* pWidget, - FWL_WGTRELATION eRelation) { + +IFWL_Widget* CFWL_WidgetMgr::GetFirstSiblingWidget(IFWL_Widget* pWidget) const { CFWL_WidgetMgrItem* pItem = GetWidgetMgrItem(pWidget); - if (!pItem) { - return NULL; - } - IFWL_Widget* pRet = NULL; - switch (eRelation) { - case FWL_WGTRELATION_Parent: { - pRet = pItem->pParent ? pItem->pParent->pWidget : NULL; - break; - } - case FWL_WGTRELATION_Owner: { - pRet = pItem->pOwner ? pItem->pOwner->pWidget : NULL; - break; - } - case FWL_WGTRELATION_FirstSibling: { - pItem = pItem->pPrevious; - while (pItem && pItem->pPrevious) { - pItem = pItem->pPrevious; - } - pRet = pItem ? pItem->pWidget : NULL; - break; - } - case FWL_WGTRELATION_PriorSibling: { - pRet = pItem->pPrevious ? pItem->pPrevious->pWidget : NULL; - break; - } - case FWL_WGTRELATION_NextSibling: { - pRet = pItem->pNext ? pItem->pNext->pWidget : NULL; - break; - } - case FWL_WGTRELATION_LastSibling: { - pItem = pItem->pNext; - while (pItem && pItem->pNext) { - pItem = pItem->pNext; - } - pRet = pItem ? pItem->pWidget : NULL; - break; - } - case FWL_WGTRELATION_FirstChild: { - pRet = pItem->pChild ? pItem->pChild->pWidget : NULL; - break; - } - case FWL_WGTRELATION_LastChild: { - pItem = pItem->pChild; - while (pItem && pItem->pNext) { - pItem = pItem->pNext; - } - pRet = pItem ? pItem->pWidget : NULL; - break; - } - case FWL_WGTRELATION_SystemForm: { - while (pItem) { - if (IsAbleNative(pItem->pWidget)) { - pRet = pItem->pWidget; - break; - } - pItem = pItem->pParent; - } - break; - } - default: {} - } - return pRet; + pItem = pItem ? pItem->pPrevious : nullptr; // Not self. + while (pItem && pItem->pPrevious) + pItem = pItem->pPrevious; + + return pItem ? pItem->pWidget : nullptr; } -int32_t CFWL_WidgetMgr::GetWidgetIndex(IFWL_Widget* pWidget) { + +IFWL_Widget* CFWL_WidgetMgr::GetPriorSiblingWidget(IFWL_Widget* pWidget) const { CFWL_WidgetMgrItem* pItem = GetWidgetMgrItem(pWidget); - if (!pItem) - return -1; - return TravelWidgetMgr(pItem->pParent, NULL, pItem); + return pItem && pItem->pPrevious ? pItem->pPrevious->pWidget : nullptr; +} + +IFWL_Widget* CFWL_WidgetMgr::GetNextSiblingWidget(IFWL_Widget* pWidget) const { + CFWL_WidgetMgrItem* pItem = GetWidgetMgrItem(pWidget); + 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; +} + +IFWL_Widget* CFWL_WidgetMgr::GetLastChildWidget(IFWL_Widget* pWidget) const { + CFWL_WidgetMgrItem* pItem = GetWidgetMgrItem(pWidget); + pItem = pItem ? pItem->pChild : nullptr; + while (pItem && pItem->pNext) + pItem = pItem->pNext; + + return pItem ? pItem->pWidget : nullptr; +} + +IFWL_Widget* CFWL_WidgetMgr::GetSystemFormWidget(IFWL_Widget* pWidget) const { + CFWL_WidgetMgrItem* pItem = GetWidgetMgrItem(pWidget); + while (pItem) { + if (IsAbleNative(pItem->pWidget)) + return pItem->pWidget; + pItem = pItem->pParent; + } + return nullptr; +} + FX_BOOL CFWL_WidgetMgr::SetWidgetIndex(IFWL_Widget* pWidget, int32_t nIndex) { CFWL_WidgetMgrItem* pItem = GetWidgetMgrItem(pWidget); if (!pItem) @@ -225,7 +204,7 @@ FWL_Error CFWL_WidgetMgr::RepaintWidget(IFWL_Widget* pWidget, pOuter = pOuter->GetOuter(); } } else if (!IsAbleNative(pWidget)) { - pNative = GetWidget(pWidget, FWL_WGTRELATION_SystemForm); + pNative = GetSystemFormWidget(pWidget); if (!pNative) return FWL_Error::Indefinite; pWidget->TransformTo(pNative, rect.left, rect.top); @@ -345,10 +324,9 @@ void CFWL_WidgetMgr::SetParent(IFWL_Widget* pParent, IFWL_Widget* pChild) { FX_BOOL CFWL_WidgetMgr::IsChild(IFWL_Widget* pChild, IFWL_Widget* pParent) { IFWL_Widget* pTemp = pChild; do { - if (pTemp == pParent) { + if (pTemp == pParent) return TRUE; - } - pTemp = GetWidget(pTemp, FWL_WGTRELATION_Parent); + pTemp = GetParentWidget(pTemp); } while (pTemp); return FALSE; } @@ -382,7 +360,7 @@ IFWL_Widget* CFWL_WidgetMgr::GetWidgetAtPoint(IFWL_Widget* parent, return NULL; FX_FLOAT x1; FX_FLOAT y1; - IFWL_Widget* child = GetWidget(parent, FWL_WGTRELATION_LastChild); + IFWL_Widget* child = GetLastChildWidget(parent); while (child) { if ((child->GetStates() & FWL_WGTSTATE_Invisible) == 0) { x1 = x; @@ -401,7 +379,7 @@ IFWL_Widget* CFWL_WidgetMgr::GetWidgetAtPoint(IFWL_Widget* parent, return GetWidgetAtPoint(child, x1, y1); } } - child = GetWidget(child, FWL_WGTRELATION_PriorSibling); + child = GetPriorSiblingWidget(child); } return parent; } @@ -416,29 +394,32 @@ void CFWL_WidgetMgr::NotifySizeChanged(IFWL_Widget* pForm, IFWL_Widget* CFWL_WidgetMgr::nextTab(IFWL_Widget* parent, IFWL_Widget* focus, FX_BOOL& bFind) { - IFWL_Widget* child = - FWL_GetWidgetMgr()->GetWidget(parent, FWL_WGTRELATION_FirstChild); + CFWL_WidgetMgr* pMgr = CFWL_WidgetMgr::GetInstance(); + IFWL_Widget* child = pMgr->GetFirstChildWidget(parent); while (child) { - if (focus == child) { + if (focus == child) bFind = TRUE; - } + if ((child->GetStyles() & FWL_WGTSTYLE_TabStop) && (!focus || (focus != child && bFind))) { return child; } IFWL_Widget* bRet = nextTab(child, focus, bFind); - if (bRet) { + if (bRet) return bRet; - } - child = FWL_GetWidgetMgr()->GetWidget(child, FWL_WGTRELATION_NextSibling); + + child = pMgr->GetNextSiblingWidget(child); } - return NULL; + return nullptr; } + int32_t CFWL_WidgetMgr::CountRadioButtonGroup(IFWL_Widget* pFirst) { int32_t iRet = 0; IFWL_Widget* pChild = pFirst; - while (pChild) - pChild = GetWidget(pChild, FWL_WGTRELATION_NextSibling); + while (pChild) { + pChild = GetNextSiblingWidget(pChild); + ++iRet; + } return iRet; } IFWL_Widget* CFWL_WidgetMgr::GetSiblingRadioButton(IFWL_Widget* pWidget, @@ -453,19 +434,19 @@ IFWL_Widget* CFWL_WidgetMgr::GetRadioButtonGroupHeader( return pNext; pNext = GetSiblingRadioButton(pNext, FALSE); } - pNext = GetWidget(pRadioButton, FWL_WGTRELATION_LastSibling); + pNext = GetLastSiblingWidget(pRadioButton); while ((pNext = GetSiblingRadioButton(pNext, FALSE)) != nullptr && pNext != pRadioButton) { if (pNext->GetStyles() & FWL_WGTSTYLE_Group) return pNext; } - pNext = GetWidget(pRadioButton, FWL_WGTRELATION_FirstSibling); + pNext = GetFirstSiblingWidget(pRadioButton); return GetSiblingRadioButton(pNext, TRUE); } void CFWL_WidgetMgr::GetSameGroupRadioButton( IFWL_Widget* pRadioButton, CFX_ArrayTemplate<IFWL_Widget*>& group) { - IFWL_Widget* pFirst = GetWidget(pRadioButton, FWL_WGTRELATION_FirstSibling); + IFWL_Widget* pFirst = GetFirstSiblingWidget(pRadioButton); if (!pFirst) { pFirst = pRadioButton; } @@ -491,7 +472,7 @@ IFWL_Widget* CFWL_WidgetMgr::GetDefaultButton(IFWL_Widget* pParent) { return pParent; } IFWL_Widget* child = - FWL_GetWidgetMgr()->GetWidget(pParent, FWL_WGTRELATION_FirstChild); + CFWL_WidgetMgr::GetInstance()->GetFirstChildWidget(pParent); while (child) { if ((child->GetClassID() == FWL_Type::PushButton) && (child->GetStates() & (1 << (FWL_WGTSTATE_MAX + 2)))) { @@ -501,7 +482,7 @@ IFWL_Widget* CFWL_WidgetMgr::GetDefaultButton(IFWL_Widget* pParent) { if (find) { return find; } - child = FWL_GetWidgetMgr()->GetWidget(child, FWL_WGTRELATION_NextSibling); + child = CFWL_WidgetMgr::GetInstance()->GetNextSiblingWidget(child); } return NULL; } @@ -550,7 +531,8 @@ int32_t CFWL_WidgetMgr::TravelWidgetMgr(CFWL_WidgetMgrItem* pParent, } return iCount - 1; } -FX_BOOL CFWL_WidgetMgr::IsAbleNative(IFWL_Widget* pWidget) { + +FX_BOOL CFWL_WidgetMgr::IsAbleNative(IFWL_Widget* pWidget) const { if (!pWidget) return FALSE; if (!pWidget->IsInstance(FX_WSTRC(FWL_CLASS_Form))) { @@ -677,11 +659,10 @@ void CFWL_WidgetMgrDelegate::DrawChild(IFWL_Widget* parent, return; FX_BOOL bFormDisable = m_pWidgetMgr->IsFormDisabled(); - IFWL_Widget* pNextChild = - m_pWidgetMgr->GetWidget(parent, FWL_WGTRELATION_FirstChild); + IFWL_Widget* pNextChild = m_pWidgetMgr->GetFirstChildWidget(parent); while (pNextChild) { IFWL_Widget* child = pNextChild; - pNextChild = m_pWidgetMgr->GetWidget(child, FWL_WGTRELATION_NextSibling); + pNextChild = m_pWidgetMgr->GetNextSiblingWidget(child); if (child->GetStates() & FWL_WGTSTATE_Invisible) continue; @@ -719,7 +700,7 @@ void CFWL_WidgetMgrDelegate::DrawChild(IFWL_Widget* parent, DrawChild(child, clipBounds, pGraphics, bFormDisable ? &widgetMatrix : pMatrix); - child = m_pWidgetMgr->GetWidget(child, FWL_WGTRELATION_NextSibling); + child = m_pWidgetMgr->GetNextSiblingWidget(child); } } @@ -776,7 +757,7 @@ FX_BOOL CFWL_WidgetMgrDelegate::IsNeedRepaint(IFWL_Widget* pWidget, return FALSE; IFWL_Widget* pChild = - FWL_GetWidgetMgr()->GetWidget(pWidget, FWL_WGTRELATION_FirstChild); + CFWL_WidgetMgr::GetInstance()->GetFirstChildWidget(pWidget); if (!pChild) return TRUE; @@ -835,8 +816,8 @@ FX_BOOL CFWL_WidgetMgrDelegate::IsNeedRepaint(IFWL_Widget* pWidget, if (r.Contains(hitPoint[i].hitPoint)) hitPoint[i].bNotNeedRepaint = true; } - } while ((pChild = FWL_GetWidgetMgr()->GetWidget( - pChild, FWL_WGTRELATION_NextSibling)) != NULL); + } while ( + (pChild = CFWL_WidgetMgr::GetInstance()->GetNextSiblingWidget(pChild))); if (!bChildIntersectWithDirty) return TRUE; diff --git a/xfa/fwl/core/fwl_widgetmgrimp.h b/xfa/fwl/core/fwl_widgetmgrimp.h index 6e4fffeca1..64fda0724e 100644 --- a/xfa/fwl/core/fwl_widgetmgrimp.h +++ b/xfa/fwl/core/fwl_widgetmgrimp.h @@ -12,7 +12,6 @@ #include "core/fxcrt/include/fx_system.h" #include "xfa/fwl/core/fwl_error.h" -#include "xfa/fwl/core/ifwl_widgetmgr.h" #include "xfa/fxgraphics/include/cfx_graphics.h" #define FWL_WGTMGR_DisableThread 0x00000001 @@ -58,21 +57,25 @@ class CFWL_WidgetMgrItem { #endif }; -class CFWL_WidgetMgr : public IFWL_WidgetMgr { +class CFWL_WidgetMgr { public: - CFWL_WidgetMgr(CXFA_FFApp* pAdapterNative); - ~CFWL_WidgetMgr() override; - - // IFWL_WidgetMgr: - int32_t CountWidgets(IFWL_Widget* pParent = NULL) override; - IFWL_Widget* GetWidget(int32_t nIndex, IFWL_Widget* pParent = NULL) override; - IFWL_Widget* GetWidget(IFWL_Widget* pWidget, - FWL_WGTRELATION eRelation) override; - int32_t GetWidgetIndex(IFWL_Widget* pWidget) override; - FX_BOOL SetWidgetIndex(IFWL_Widget* pWidget, int32_t nIndex) override; - FWL_Error RepaintWidget(IFWL_Widget* pWidget, - const CFX_RectF* pRect = NULL) override; - uint32_t GetCapability() override { return m_dwCapability; } + static CFWL_WidgetMgr* GetInstance(); + + explicit CFWL_WidgetMgr(CXFA_FFApp* pAdapterNative); + ~CFWL_WidgetMgr(); + + 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; + + FX_BOOL SetWidgetIndex(IFWL_Widget* pWidget, int32_t nIndex); + FWL_Error RepaintWidget(IFWL_Widget* pWidget, const CFX_RectF* pRect = NULL); void AddWidget(IFWL_Widget* pWidget); void InsertWidget(IFWL_Widget* pParent, @@ -110,7 +113,7 @@ class CFWL_WidgetMgr : public IFWL_WidgetMgr { int32_t* pIndex, CFWL_WidgetMgrItem* pItem, IFWL_Widget** pWidget = NULL); - FX_BOOL IsAbleNative(IFWL_Widget* pWidget); + FX_BOOL IsAbleNative(IFWL_Widget* pWidget) const; uint32_t m_dwCapability; std::unique_ptr<CFWL_WidgetMgrDelegate> m_pDelegate; diff --git a/xfa/fwl/core/ifwl_app.h b/xfa/fwl/core/ifwl_app.h index 41983ef8f5..5fbac6644f 100644 --- a/xfa/fwl/core/ifwl_app.h +++ b/xfa/fwl/core/ifwl_app.h @@ -22,11 +22,11 @@ #include "xfa/fwl/core/fwl_error.h" class CFWL_NoteDriver; +class CFWL_WidgetMgr; class CXFA_FFApp; class CXFA_FWLAdapterWidgetMgr; class IFWL_ThemeProvider; class IFWL_Widget; -class IFWL_WidgetMgr; class IFWL_App { public: @@ -37,7 +37,7 @@ class IFWL_App { FWL_Error Initialize(); FWL_Error Finalize(); CXFA_FFApp* GetAdapterNative(); - IFWL_WidgetMgr* GetWidgetMgr(); + CFWL_WidgetMgr* GetWidgetMgr(); IFWL_ThemeProvider* GetThemeProvider(); void SetThemeProvider(IFWL_ThemeProvider* pThemeProvider); void Exit(int32_t iExitCode); diff --git a/xfa/fwl/core/ifwl_widgetmgr.h b/xfa/fwl/core/ifwl_widgetmgr.h deleted file mode 100644 index 6e25b72290..0000000000 --- a/xfa/fwl/core/ifwl_widgetmgr.h +++ /dev/null @@ -1,47 +0,0 @@ -// Copyright 2014 PDFium Authors. All rights reserved. -// Use of this source code is governed by a BSD-style license that can be -// found in the LICENSE file. - -// Original code copyright 2014 Foxit Software Inc. http://www.foxitsoftware.com - -#ifndef XFA_FWL_CORE_IFWL_WIDGETMGR_H_ -#define XFA_FWL_CORE_IFWL_WIDGETMGR_H_ - -#include "core/fxcrt/include/fx_system.h" -#include "xfa/fwl/core/fwl_error.h" -#include "core/fxcrt/include/fx_coordinates.h" - -class CFX_WideString; -class CFX_Matrix; -class IFWL_Widget; - -enum FWL_WGTRELATION { - FWL_WGTRELATION_Parent = 0, - FWL_WGTRELATION_Owner, - FWL_WGTRELATION_FirstSibling, - FWL_WGTRELATION_PriorSibling, - FWL_WGTRELATION_NextSibling, - FWL_WGTRELATION_LastSibling, - FWL_WGTRELATION_FirstChild, - FWL_WGTRELATION_LastChild, - FWL_WGTRELATION_SystemForm -}; - -class IFWL_WidgetMgr { - public: - virtual ~IFWL_WidgetMgr() {} - virtual int32_t CountWidgets(IFWL_Widget* pParent = NULL) = 0; - virtual IFWL_Widget* GetWidget(int32_t nIndex, - IFWL_Widget* pParent = NULL) = 0; - virtual IFWL_Widget* GetWidget(IFWL_Widget* pWidget, - FWL_WGTRELATION eRelation) = 0; - virtual int32_t GetWidgetIndex(IFWL_Widget* pWidget) = 0; - virtual FX_BOOL SetWidgetIndex(IFWL_Widget* pWidget, int32_t nIndex) = 0; - virtual FWL_Error RepaintWidget(IFWL_Widget* pWidget, - const CFX_RectF* pRect = NULL) = 0; - virtual uint32_t GetCapability() = 0; -}; - -IFWL_WidgetMgr* FWL_GetWidgetMgr(); - -#endif // XFA_FWL_CORE_IFWL_WIDGETMGR_H_ diff --git a/xfa/fwl/lightwidget/cfwl_widget.cpp b/xfa/fwl/lightwidget/cfwl_widget.cpp index 8d3237605f..20c9a3b92f 100644 --- a/xfa/fwl/lightwidget/cfwl_widget.cpp +++ b/xfa/fwl/lightwidget/cfwl_widget.cpp @@ -217,7 +217,7 @@ IFWL_WidgetDelegate* CFWL_Widget::SetDelegate(IFWL_WidgetDelegate* pDelegate) { CFWL_Widget::CFWL_Widget() : m_pIface(nullptr), m_pDelegate(nullptr), m_pProperties(nullptr) { m_pProperties = new CFWL_WidgetProperties; - m_pWidgetMgr = static_cast<CFWL_WidgetMgr*>(FWL_GetWidgetMgr()); + m_pWidgetMgr = CFWL_WidgetMgr::GetInstance(); ASSERT(m_pWidgetMgr); } diff --git a/xfa/fwl/theme/cfwl_widgettp.cpp b/xfa/fwl/theme/cfwl_widgettp.cpp index 764c86e314..f4aea4aab6 100644 --- a/xfa/fwl/theme/cfwl_widgettp.cpp +++ b/xfa/fwl/theme/cfwl_widgettp.cpp @@ -13,9 +13,9 @@ #include "xfa/fwl/core/cfwl_themebackground.h" #include "xfa/fwl/core/cfwl_themepart.h" #include "xfa/fwl/core/cfwl_themetext.h" +#include "xfa/fwl/core/fwl_widgetmgrimp.h" #include "xfa/fwl/core/ifwl_themeprovider.h" #include "xfa/fwl/core/ifwl_widget.h" -#include "xfa/fwl/core/ifwl_widgetmgr.h" #include "xfa/fxgraphics/cfx_color.h" #include "xfa/fxgraphics/cfx_path.h" #include "xfa/fxgraphics/cfx_shading.h" @@ -35,16 +35,15 @@ const float kCYBorder = 1.0f; } // namespace static void FWL_SetChildThemeID(IFWL_Widget* pParent, uint32_t dwThemeID) { - IFWL_WidgetMgr* pWidgetMgr = FWL_GetWidgetMgr(); - IFWL_Widget* pChild = - pWidgetMgr->GetWidget(pParent, FWL_WGTRELATION_FirstChild); + CFWL_WidgetMgr* pWidgetMgr = CFWL_WidgetMgr::GetInstance(); + IFWL_Widget* pChild = pWidgetMgr->GetFirstChildWidget(pParent); while (pChild) { IFWL_ThemeProvider* pTheme = pChild->GetThemeProvider(); if (pTheme) { pTheme->SetThemeID(pChild, dwThemeID, FALSE); } FWL_SetChildThemeID(pChild, dwThemeID); - pChild = pWidgetMgr->GetWidget(pChild, FWL_WGTRELATION_NextSibling); + pChild = pWidgetMgr->GetNextSiblingWidget(pChild); } } |