1 // Copyright 2014 PDFium Authors. All rights reserved. 2 // Use of this source code is governed by a BSD-style license that can be 3 // found in the LICENSE file. 4 5 // Original code copyright 2014 Foxit Software Inc. http://www.foxitsoftware.com 6 7 #ifndef XFA_FWL_CFWL_WIDGETMGR_H_ 8 #define XFA_FWL_CFWL_WIDGETMGR_H_ 9 10 #include <map> 11 #include <memory> 12 #include <vector> 13 14 #include "core/fxcrt/fx_system.h" 15 #include "xfa/fxgraphics/cxfa_graphics.h" 16 17 class CFWL_Message; 18 class CXFA_Graphics; 19 class CFX_Matrix; 20 class CFWL_Widget; 21 22 class CFWL_WidgetMgr { 23 public: 24 class AdapterIface { 25 public: ~AdapterIface()26 virtual ~AdapterIface() {} 27 virtual void RepaintWidget(CFWL_Widget* pWidget) = 0; 28 virtual bool GetPopupPos(CFWL_Widget* pWidget, 29 float fMinHeight, 30 float fMaxHeight, 31 const CFX_RectF& rtAnchor, 32 CFX_RectF* pPopupRect) = 0; 33 }; 34 35 explicit CFWL_WidgetMgr(AdapterIface* pAdapterNative); 36 ~CFWL_WidgetMgr(); 37 38 static CFWL_Widget* NextTab(CFWL_Widget* parent, CFWL_Widget* focus); 39 40 void OnProcessMessageToForm(std::unique_ptr<CFWL_Message> pMessage); 41 void OnDrawWidget(CFWL_Widget* pWidget, 42 CXFA_Graphics* pGraphics, 43 const CFX_Matrix& matrix); 44 45 CFWL_Widget* GetParentWidget(const CFWL_Widget* pWidget) const; 46 CFWL_Widget* GetOwnerWidget(const CFWL_Widget* pWidget) const; 47 CFWL_Widget* GetNextSiblingWidget(CFWL_Widget* pWidget) const; 48 CFWL_Widget* GetFirstChildWidget(CFWL_Widget* pWidget) const; 49 CFWL_Widget* GetSystemFormWidget(CFWL_Widget* pWidget) const; 50 51 void RepaintWidget(CFWL_Widget* pWidget, const CFX_RectF& pRect); 52 53 void InsertWidget(CFWL_Widget* pParent, CFWL_Widget* pChild); 54 void RemoveWidget(CFWL_Widget* pWidget); 55 void SetOwner(CFWL_Widget* pOwner, CFWL_Widget* pOwned); 56 void SetParent(CFWL_Widget* pParent, CFWL_Widget* pChild); 57 58 CFWL_Widget* GetWidgetAtPoint(CFWL_Widget* pParent, 59 const CFX_PointF& point) const; 60 61 CFWL_Widget* GetDefaultButton(CFWL_Widget* pParent) const; 62 void AddRedrawCounts(CFWL_Widget* pWidget); 63 64 void GetAdapterPopupPos(CFWL_Widget* pWidget, 65 float fMinHeight, 66 float fMaxHeight, 67 const CFX_RectF& rtAnchor, 68 CFX_RectF* pPopupRect) const; 69 70 private: 71 class Item { 72 public: 73 Item(); 74 explicit Item(CFWL_Widget* widget); 75 ~Item(); 76 77 Item* pParent; 78 Item* pOwner; 79 Item* pChild; 80 Item* pPrevious; 81 Item* pNext; 82 CFWL_Widget* const pWidget; 83 std::unique_ptr<CXFA_Graphics> pOffscreen; 84 int32_t iRedrawCounter; 85 }; 86 87 CFWL_Widget* GetFirstSiblingWidget(CFWL_Widget* pWidget) const; 88 CFWL_Widget* GetPriorSiblingWidget(CFWL_Widget* pWidget) const; 89 CFWL_Widget* GetLastChildWidget(CFWL_Widget* pWidget) const; 90 Item* GetWidgetMgrItem(const CFWL_Widget* pWidget) const; 91 92 void AppendWidget(CFWL_Widget* pWidget); 93 void ResetRedrawCounts(CFWL_Widget* pWidget); 94 void DrawChild(CFWL_Widget* pParent, 95 const CFX_RectF& rtClip, 96 CXFA_Graphics* pGraphics, 97 const CFX_Matrix* pMatrix); 98 99 bool IsAbleNative(CFWL_Widget* pWidget) const; 100 101 std::map<const CFWL_Widget*, std::unique_ptr<Item>> m_mapWidgetItem; 102 UnownedPtr<AdapterIface> const m_pAdapter; 103 }; 104 105 #endif // XFA_FWL_CFWL_WIDGETMGR_H_ 106