OLD | NEW |
| (Empty) |
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_CORE_FWL_WIDGETMGRIMP_H_ | |
8 #define XFA_FWL_CORE_FWL_WIDGETMGRIMP_H_ | |
9 | |
10 #include <map> | |
11 #include <memory> | |
12 | |
13 #include "core/fxcrt/include/fx_system.h" | |
14 #include "xfa/fwl/core/fwl_error.h" | |
15 #include "xfa/fxgraphics/include/cfx_graphics.h" | |
16 | |
17 #define FWL_WGTMGR_DisableThread 0x00000001 | |
18 #define FWL_WGTMGR_DisableForm 0x00000002 | |
19 | |
20 class CFWL_Message; | |
21 class CFWL_WidgetMgrDelegate; | |
22 class CXFA_FFApp; | |
23 class CXFA_FWLAdapterWidgetMgr; | |
24 class CFX_Graphics; | |
25 class CFX_Matrix; | |
26 class IFWL_Widget; | |
27 | |
28 class CFWL_WidgetMgrItem { | |
29 public: | |
30 CFWL_WidgetMgrItem() : CFWL_WidgetMgrItem(nullptr) {} | |
31 explicit CFWL_WidgetMgrItem(IFWL_Widget* widget) | |
32 : pParent(nullptr), | |
33 pOwner(nullptr), | |
34 pChild(nullptr), | |
35 pPrevious(nullptr), | |
36 pNext(nullptr), | |
37 pWidget(widget), | |
38 iRedrawCounter(0) | |
39 #if (_FX_OS_ == _FX_WIN32_DESKTOP_) || (_FX_OS_ == _FX_WIN64_) | |
40 , | |
41 bOutsideChanged(FALSE) | |
42 #endif | |
43 { | |
44 } | |
45 ~CFWL_WidgetMgrItem() {} | |
46 | |
47 CFWL_WidgetMgrItem* pParent; | |
48 CFWL_WidgetMgrItem* pOwner; | |
49 CFWL_WidgetMgrItem* pChild; | |
50 CFWL_WidgetMgrItem* pPrevious; | |
51 CFWL_WidgetMgrItem* pNext; | |
52 IFWL_Widget* const pWidget; | |
53 std::unique_ptr<CFX_Graphics> pOffscreen; | |
54 int32_t iRedrawCounter; | |
55 #if (_FX_OS_ == _FX_WIN32_DESKTOP_) || (_FX_OS_ == _FX_WIN64_) | |
56 FX_BOOL bOutsideChanged; | |
57 #endif | |
58 }; | |
59 | |
60 class CFWL_WidgetMgr { | |
61 public: | |
62 static CFWL_WidgetMgr* GetInstance(); | |
63 | |
64 explicit CFWL_WidgetMgr(CXFA_FFApp* pAdapterNative); | |
65 ~CFWL_WidgetMgr(); | |
66 | |
67 IFWL_Widget* GetParentWidget(IFWL_Widget* pWidget) const; | |
68 IFWL_Widget* GetOwnerWidget(IFWL_Widget* pWidget) const; | |
69 IFWL_Widget* GetFirstSiblingWidget(IFWL_Widget* pWidget) const; | |
70 IFWL_Widget* GetPriorSiblingWidget(IFWL_Widget* pWidget) const; | |
71 IFWL_Widget* GetNextSiblingWidget(IFWL_Widget* pWidget) const; | |
72 IFWL_Widget* GetLastSiblingWidget(IFWL_Widget* pWidget) const; | |
73 IFWL_Widget* GetFirstChildWidget(IFWL_Widget* pWidget) const; | |
74 IFWL_Widget* GetLastChildWidget(IFWL_Widget* pWidget) const; | |
75 IFWL_Widget* GetSystemFormWidget(IFWL_Widget* pWidget) const; | |
76 | |
77 FX_BOOL SetWidgetIndex(IFWL_Widget* pWidget, int32_t nIndex); | |
78 FWL_Error RepaintWidget(IFWL_Widget* pWidget, const CFX_RectF* pRect = NULL); | |
79 | |
80 void AddWidget(IFWL_Widget* pWidget); | |
81 void InsertWidget(IFWL_Widget* pParent, | |
82 IFWL_Widget* pChild, | |
83 int32_t nIndex = -1); | |
84 void RemoveWidget(IFWL_Widget* pWidget); | |
85 void SetOwner(IFWL_Widget* pOwner, IFWL_Widget* pOwned); | |
86 void SetParent(IFWL_Widget* pParent, IFWL_Widget* pChild); | |
87 FX_BOOL IsChild(IFWL_Widget* pChild, IFWL_Widget* pParent); | |
88 FWL_Error SetWidgetRect_Native(IFWL_Widget* pWidget, const CFX_RectF& rect); | |
89 IFWL_Widget* GetWidgetAtPoint(IFWL_Widget* pParent, FX_FLOAT fx, FX_FLOAT fy); | |
90 void NotifySizeChanged(IFWL_Widget* pForm, FX_FLOAT fx, FX_FLOAT fy); | |
91 IFWL_Widget* nextTab(IFWL_Widget* parent, IFWL_Widget* focus, FX_BOOL& bFind); | |
92 int32_t CountRadioButtonGroup(IFWL_Widget* pFirst); | |
93 IFWL_Widget* GetSiblingRadioButton(IFWL_Widget* pWidget, FX_BOOL bNext); | |
94 IFWL_Widget* GetRadioButtonGroupHeader(IFWL_Widget* pRadioButton); | |
95 void GetSameGroupRadioButton(IFWL_Widget* pRadioButton, | |
96 CFX_ArrayTemplate<IFWL_Widget*>& group); | |
97 IFWL_Widget* GetDefaultButton(IFWL_Widget* pParent); | |
98 void AddRedrawCounts(IFWL_Widget* pWidget); | |
99 void ResetRedrawCounts(IFWL_Widget* pWidget); | |
100 CXFA_FWLAdapterWidgetMgr* GetAdapterWidgetMgr() const { return m_pAdapter; } | |
101 CFWL_WidgetMgrDelegate* GetDelegate() const { return m_pDelegate.get(); } | |
102 CFWL_WidgetMgrItem* GetWidgetMgrItem(IFWL_Widget* pWidget) const; | |
103 bool IsThreadEnabled(); | |
104 bool IsFormDisabled(); | |
105 FX_BOOL GetAdapterPopupPos(IFWL_Widget* pWidget, | |
106 FX_FLOAT fMinHeight, | |
107 FX_FLOAT fMaxHeight, | |
108 const CFX_RectF& rtAnchor, | |
109 CFX_RectF& rtPopup); | |
110 | |
111 protected: | |
112 int32_t TravelWidgetMgr(CFWL_WidgetMgrItem* pParent, | |
113 int32_t* pIndex, | |
114 CFWL_WidgetMgrItem* pItem, | |
115 IFWL_Widget** pWidget = NULL); | |
116 FX_BOOL IsAbleNative(IFWL_Widget* pWidget) const; | |
117 | |
118 uint32_t m_dwCapability; | |
119 std::unique_ptr<CFWL_WidgetMgrDelegate> m_pDelegate; | |
120 std::map<IFWL_Widget*, std::unique_ptr<CFWL_WidgetMgrItem>> m_mapWidgetItem; | |
121 CXFA_FWLAdapterWidgetMgr* const m_pAdapter; | |
122 #if (_FX_OS_ == _FX_WIN32_DESKTOP_) || (_FX_OS_ == _FX_WIN64_) | |
123 CFX_RectF m_rtScreen; | |
124 #endif | |
125 friend class CFWL_WidgetMgrDelegate; | |
126 }; | |
127 | |
128 class CFWL_WidgetMgrDelegate { | |
129 public: | |
130 CFWL_WidgetMgrDelegate(CFWL_WidgetMgr* pWidgetMgr); | |
131 ~CFWL_WidgetMgrDelegate() {} | |
132 | |
133 FWL_Error OnSetCapability(uint32_t dwCapability = FWL_WGTMGR_DisableThread); | |
134 void OnProcessMessageToForm(CFWL_Message* pMessage); | |
135 void OnDrawWidget(IFWL_Widget* pWidget, | |
136 CFX_Graphics* pGraphics, | |
137 const CFX_Matrix* pMatrix); | |
138 | |
139 protected: | |
140 void DrawChild(IFWL_Widget* pParent, | |
141 const CFX_RectF& rtClip, | |
142 CFX_Graphics* pGraphics, | |
143 const CFX_Matrix* pMatrix); | |
144 CFX_Graphics* DrawWidgetBefore(IFWL_Widget* pWidget, | |
145 CFX_Graphics* pGraphics, | |
146 const CFX_Matrix* pMatrix); | |
147 void DrawWidgetAfter(IFWL_Widget* pWidget, | |
148 CFX_Graphics* pGraphics, | |
149 CFX_RectF& rtClip, | |
150 const CFX_Matrix* pMatrix); | |
151 FX_BOOL IsNeedRepaint(IFWL_Widget* pWidget, | |
152 CFX_Matrix* pMatrix, | |
153 const CFX_RectF& rtDirty); | |
154 FX_BOOL bUseOffscreenDirect(IFWL_Widget* pWidget); | |
155 | |
156 CFWL_WidgetMgr* m_pWidgetMgr; | |
157 }; | |
158 | |
159 #endif // XFA_FWL_CORE_FWL_WIDGETMGRIMP_H_ | |
OLD | NEW |