7#include "xfa/fwl/cfwl_widgetmgr.h"
9#include "build/build_config.h"
10#include "core/fxcrt/check.h"
11#include "fxjs/gc/container_trace.h"
12#include "xfa/fwl/cfwl_app.h"
13#include "xfa/fwl/cfwl_message.h"
14#include "xfa/fwl/cfwl_notedriver.h"
15#include "xfa/fwl/cfwl_pushbutton.h"
19CFWL_WidgetMgr::CFWL_WidgetMgr(
AdapterIface* pAdapter, CFWL_App* pApp)
20 : m_pAdapter(pAdapter), m_pApp(pApp) {
22 m_mapWidgetItem[
nullptr] = cppgc::MakeGarbageCollected<Item>(
23 pApp->GetHeap()->GetAllocationHandle(),
nullptr);
28void CFWL_WidgetMgr::Trace(cppgc::Visitor* visitor)
const {
29 visitor->Trace(m_pApp);
30 visitor->Trace(m_pAdapter);
31 ContainerTrace(visitor, m_mapWidgetItem);
35 Item* pItem = GetWidgetMgrItem(pWidget);
39 Item* pParent = pItem->GetParent();
40 return pParent ? pParent->pWidget :
nullptr;
44 Item* pItem = GetWidgetMgrItem(pWidget);
48 Item* pSibling = pItem->GetPrevSibling();
49 return pSibling ? pSibling->pWidget :
nullptr;
53 Item* pItem = GetWidgetMgrItem(pWidget);
57 Item* pSibling = pItem->GetNextSibling();
58 return pSibling ? pSibling->pWidget :
nullptr;
62 Item* pItem = GetWidgetMgrItem(pWidget);
66 Item* pChild = pItem->GetFirstChild();
67 return pChild ? pChild->pWidget :
nullptr;
71 Item* pItem = GetWidgetMgrItem(pWidget);
75 Item* pChild = pItem->GetLastChild();
76 return pChild ? pChild->pWidget :
nullptr;
91 m_pAdapter->RepaintWidget(pNative);
95 Item* pParentItem = GetWidgetMgrItem(pParent);
97 pParentItem = CreateWidgetMgrItem(pParent);
98 GetWidgetMgrRootItem()->AppendLastChild(pParentItem);
100 Item* pChildItem = GetWidgetMgrItem(pChild);
102 pChildItem = CreateWidgetMgrItem(pChild);
103 pParentItem->AppendLastChild(pChildItem);
108 Item* pItem = GetWidgetMgrItem(pWidget);
112 while (pItem->GetFirstChild())
115 pItem->RemoveSelfIfParented();
116 m_mapWidgetItem.erase(pWidget);
127 CFX_PointF pos = parent->GetMatrix().GetInverse().Transform(point);
129 if (bounds.Contains(pos)) {
130 pos -= bounds.TopLeft();
134 child = GetPriorSiblingWidget(child);
159CFWL_WidgetMgr::Item* CFWL_WidgetMgr::GetWidgetMgrRootItem()
const {
160 return GetWidgetMgrItem(
nullptr);
163CFWL_WidgetMgr::Item* CFWL_WidgetMgr::GetWidgetMgrItem(
165 auto it = m_mapWidgetItem.find(pWidget);
166 return it != m_mapWidgetItem.end() ? it->second :
nullptr;
169CFWL_WidgetMgr::Item* CFWL_WidgetMgr::CreateWidgetMgrItem(
171 auto* pItem = cppgc::MakeGarbageCollected<Item>(
172 m_pApp->GetHeap()->GetAllocationHandle(), pWidget);
173 m_mapWidgetItem[pWidget] = pItem;
182 m_pAdapter->GetPopupPos(pWidget, fMinHeight, fMaxHeight, rtAnchor,
198 if (!pWidget || !pGraphics)
205 DrawChildren(pWidget, clipBounds, pGraphics, matrix);
208void CFWL_WidgetMgr::DrawChildren(
CFWL_Widget* parent,
234 DrawChildren(child, clipBounds, pGraphics, widgetMatrix);
238CFWL_WidgetMgr::Item::Item(
CFWL_Widget* widget) : pWidget(widget) {}
240CFWL_WidgetMgr::Item::~Item() =
default;
242void CFWL_WidgetMgr::Item::Trace(cppgc::Visitor* visitor)
const {
243 GCedTreeNode<Item>::Trace(visitor);
244 visitor->Trace(pWidget);
CFX_RectF GetClipRect() const
void TranslatePrepend(float x, float y)
void Concat(const CFX_Matrix &right)
CFX_RectF(const CFX_RectF &other)=default
CFWL_NoteDriver * GetNoteDriver() const
CFWL_Widget * GetDstTarget() const
void ProcessMessage(CFWL_Message *pMessage)
CFX_PTemplate< float > CFX_PointF