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