7#include "xfa/fwl/cfwl_widgetmgr.h"
9#include "build/build_config.h"
10#include "fxjs/gc/container_trace.h"
11#include "third_party/base/check.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"
17CFWL_WidgetMgr::CFWL_WidgetMgr(
AdapterIface* pAdapter, CFWL_App* pApp)
18 : m_pAdapter(pAdapter), m_pApp(pApp) {
20 m_mapWidgetItem[
nullptr] = cppgc::MakeGarbageCollected<Item>(
21 pApp->GetHeap()->GetAllocationHandle(),
nullptr);
26void CFWL_WidgetMgr::Trace(cppgc::Visitor* visitor)
const {
27 visitor->Trace(m_pApp);
28 visitor->Trace(m_pAdapter);
29 ContainerTrace(visitor, m_mapWidgetItem);
33 Item* pItem = GetWidgetMgrItem(pWidget);
37 Item* pParent = pItem->GetParent();
38 return pParent ? pParent->pWidget :
nullptr;
42 Item* pItem = GetWidgetMgrItem(pWidget);
46 Item* pSibling = pItem->GetPrevSibling();
47 return pSibling ? pSibling->pWidget :
nullptr;
51 Item* pItem = GetWidgetMgrItem(pWidget);
55 Item* pSibling = pItem->GetNextSibling();
56 return pSibling ? pSibling->pWidget :
nullptr;
60 Item* pItem = GetWidgetMgrItem(pWidget);
64 Item* pChild = pItem->GetFirstChild();
65 return pChild ? pChild->pWidget :
nullptr;
69 Item* pItem = GetWidgetMgrItem(pWidget);
73 Item* pChild = pItem->GetLastChild();
74 return pChild ? pChild->pWidget :
nullptr;
89 m_pAdapter->RepaintWidget(pNative);
93 Item* pParentItem = GetWidgetMgrItem(pParent);
95 pParentItem = CreateWidgetMgrItem(pParent);
96 GetWidgetMgrRootItem()->AppendLastChild(pParentItem);
98 Item* pChildItem = GetWidgetMgrItem(pChild);
100 pChildItem = CreateWidgetMgrItem(pChild);
101 pParentItem->AppendLastChild(pChildItem);
106 Item* pItem = GetWidgetMgrItem(pWidget);
110 while (pItem->GetFirstChild())
113 pItem->RemoveSelfIfParented();
114 m_mapWidgetItem.erase(pWidget);
118 const CFX_PointF& point)
const {
125 CFX_PointF pos = parent->GetMatrix().GetInverse().Transform(point);
127 if (bounds.Contains(pos)) {
128 pos -= bounds.TopLeft();
132 child = GetPriorSiblingWidget(child);
157CFWL_WidgetMgr::Item* CFWL_WidgetMgr::GetWidgetMgrRootItem()
const {
158 return GetWidgetMgrItem(
nullptr);
161CFWL_WidgetMgr::Item* CFWL_WidgetMgr::GetWidgetMgrItem(
163 auto it = m_mapWidgetItem.find(pWidget);
164 return it != m_mapWidgetItem.end() ? it->second :
nullptr;
167CFWL_WidgetMgr::Item* CFWL_WidgetMgr::CreateWidgetMgrItem(
169 auto* pItem = cppgc::MakeGarbageCollected<Item>(
170 m_pApp->GetHeap()->GetAllocationHandle(), pWidget);
171 m_mapWidgetItem[pWidget] = pItem;
180 m_pAdapter->GetPopupPos(pWidget, fMinHeight, fMaxHeight, rtAnchor,
196 if (!pWidget || !pGraphics)
203 DrawChildren(pWidget, clipBounds, pGraphics, matrix);
206void CFWL_WidgetMgr::DrawChildren(
CFWL_Widget* parent,
232 DrawChildren(child, clipBounds, pGraphics, widgetMatrix);
236CFWL_WidgetMgr::Item::Item(
CFWL_Widget* widget) : pWidget(widget) {}
238CFWL_WidgetMgr::Item::~Item() =
default;
240void CFWL_WidgetMgr::Item::Trace(cppgc::Visitor* visitor)
const {
241 GCedTreeNode<Item>::Trace(visitor);
242 visitor->Trace(pWidget);
CFX_RectF GetClipRect() const
CFWL_NoteDriver * GetNoteDriver() const
CFWL_Widget * GetDstTarget() const
void ProcessMessage(CFWL_Message *pMessage)
void TranslatePrepend(float x, float y)
void Concat(const CFX_Matrix &right)
CFX_RectF(const CFX_RectF &other)=default