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 #define FWL_WGTMGR_DisableForm 0x00000002 18 19 class CFWL_Message; 20 class CXFA_FFApp; 21 class CXFA_FWLAdapterWidgetMgr; 22 class CXFA_Graphics; 23 class CFX_Matrix; 24 class CFWL_Widget; 25 26 class CFWL_WidgetMgr { 27 public: 28 explicit CFWL_WidgetMgr(CXFA_FFApp* pAdapterNative); 29 ~CFWL_WidgetMgr(); 30 31 void OnProcessMessageToForm(CFWL_Message* pMessage); 32 void OnDrawWidget(CFWL_Widget* pWidget, 33 CXFA_Graphics* pGraphics, 34 const CFX_Matrix& matrix); 35 36 CFWL_Widget* GetParentWidget(CFWL_Widget* pWidget) const; 37 CFWL_Widget* GetOwnerWidget(CFWL_Widget* pWidget) const; 38 CFWL_Widget* GetNextSiblingWidget(CFWL_Widget* pWidget) const; 39 CFWL_Widget* GetFirstChildWidget(CFWL_Widget* pWidget) const; 40 CFWL_Widget* GetSystemFormWidget(CFWL_Widget* pWidget) const; 41 42 void RepaintWidget(CFWL_Widget* pWidget, const CFX_RectF& pRect); 43 44 void InsertWidget(CFWL_Widget* pParent, CFWL_Widget* pChild); 45 void RemoveWidget(CFWL_Widget* pWidget); 46 void SetOwner(CFWL_Widget* pOwner, CFWL_Widget* pOwned); 47 void SetParent(CFWL_Widget* pParent, CFWL_Widget* pChild); 48 49 CFWL_Widget* GetWidgetAtPoint(CFWL_Widget* pParent, 50 const CFX_PointF& point) const; 51 CFWL_Widget* NextTab(CFWL_Widget* parent, CFWL_Widget* focus, bool& bFind); 52 53 std::vector<CFWL_Widget*> GetSameGroupRadioButton( 54 CFWL_Widget* pRadioButton) const; 55 56 CFWL_Widget* GetDefaultButton(CFWL_Widget* pParent) const; 57 void AddRedrawCounts(CFWL_Widget* pWidget); 58 IsFormDisabled()59 bool IsFormDisabled() const { 60 return !!(m_dwCapability & FWL_WGTMGR_DisableForm); 61 } 62 63 void GetAdapterPopupPos(CFWL_Widget* pWidget, 64 float fMinHeight, 65 float fMaxHeight, 66 const CFX_RectF& rtAnchor, 67 CFX_RectF& rtPopup) const; 68 69 private: 70 class Item { 71 public: 72 Item(); 73 explicit Item(CFWL_Widget* widget); 74 ~Item(); 75 76 Item* pParent; 77 Item* pOwner; 78 Item* pChild; 79 Item* pPrevious; 80 Item* pNext; 81 CFWL_Widget* const pWidget; 82 std::unique_ptr<CXFA_Graphics> pOffscreen; 83 int32_t iRedrawCounter; 84 #if _FX_PLATFORM_ == _FX_PLATFORM_WINDOWS_ 85 bool bOutsideChanged; 86 #endif // _FX_PLATFORM_ == _FX_PLATFORM_WINDOWS_ 87 }; 88 89 CFWL_Widget* GetFirstSiblingWidget(CFWL_Widget* pWidget) const; 90 CFWL_Widget* GetPriorSiblingWidget(CFWL_Widget* pWidget) const; 91 CFWL_Widget* GetLastChildWidget(CFWL_Widget* pWidget) const; 92 Item* GetWidgetMgrItem(CFWL_Widget* pWidget) const; 93 94 void AppendWidget(CFWL_Widget* pWidget); 95 96 int32_t CountRadioButtonGroup(CFWL_Widget* pFirst) const; 97 CFWL_Widget* GetRadioButtonGroupHeader(CFWL_Widget* pRadioButton) const; 98 99 void ResetRedrawCounts(CFWL_Widget* pWidget); 100 101 void DrawChild(CFWL_Widget* pParent, 102 const CFX_RectF& rtClip, 103 CXFA_Graphics* pGraphics, 104 const CFX_Matrix* pMatrix); 105 CXFA_Graphics* DrawWidgetBefore(CFWL_Widget* pWidget, 106 CXFA_Graphics* pGraphics, 107 const CFX_Matrix* pMatrix); 108 bool IsNeedRepaint(CFWL_Widget* pWidget, 109 CFX_Matrix* pMatrix, 110 const CFX_RectF& rtDirty); 111 112 bool IsAbleNative(CFWL_Widget* pWidget) const; 113 114 uint32_t m_dwCapability; 115 std::map<CFWL_Widget*, std::unique_ptr<Item>> m_mapWidgetItem; 116 UnownedPtr<CXFA_FWLAdapterWidgetMgr> const m_pAdapter; 117 #if _FX_PLATFORM_ == _FX_PLATFORM_WINDOWS_ 118 CFX_RectF m_rtScreen; 119 #endif // _FX_PLATFORM_ == _FX_PLATFORM_WINDOWS_ 120 }; 121 122 #endif // XFA_FWL_CFWL_WIDGETMGR_H_ 123