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; |
26 class IFWL_WidgetMgrDelegate; | |
npm
2016/11/15 18:20:19
Is this forward declare needed?
dsinclair
2016/11/15 19:05:16
Done.
| |
27 | 27 |
28 class CFWL_WidgetMgrItem { | 28 class CFWL_WidgetMgrItem { |
29 public: | 29 public: |
30 CFWL_WidgetMgrItem(); | 30 CFWL_WidgetMgrItem(); |
31 explicit CFWL_WidgetMgrItem(IFWL_Widget* widget); | 31 explicit CFWL_WidgetMgrItem(IFWL_Widget* widget); |
32 ~CFWL_WidgetMgrItem(); | 32 ~CFWL_WidgetMgrItem(); |
33 | 33 |
34 CFWL_WidgetMgrItem* pParent; | 34 CFWL_WidgetMgrItem* pParent; |
35 CFWL_WidgetMgrItem* pOwner; | 35 CFWL_WidgetMgrItem* pOwner; |
36 CFWL_WidgetMgrItem* pChild; | 36 CFWL_WidgetMgrItem* pChild; |
37 CFWL_WidgetMgrItem* pPrevious; | 37 CFWL_WidgetMgrItem* pPrevious; |
38 CFWL_WidgetMgrItem* pNext; | 38 CFWL_WidgetMgrItem* pNext; |
39 IFWL_Widget* const pWidget; | 39 IFWL_Widget* const pWidget; |
40 std::unique_ptr<CFX_Graphics> pOffscreen; | 40 std::unique_ptr<CFX_Graphics> pOffscreen; |
41 int32_t iRedrawCounter; | 41 int32_t iRedrawCounter; |
42 #if (_FX_OS_ == _FX_WIN32_DESKTOP_) || (_FX_OS_ == _FX_WIN64_) | 42 #if (_FX_OS_ == _FX_WIN32_DESKTOP_) || (_FX_OS_ == _FX_WIN64_) |
43 bool bOutsideChanged; | 43 bool bOutsideChanged; |
44 #endif | 44 #endif |
45 }; | 45 }; |
46 | 46 |
47 class CFWL_WidgetMgr { | 47 class IFWL_WidgetMgrDelegate { |
npm
2016/11/15 18:20:19
If this class is only being implemented by CFWL_Wi
dsinclair
2016/11/15 18:40:36
The interface is passed into other classes. I coul
| |
48 public: | |
49 virtual void OnSetCapability( | |
50 uint32_t dwCapability = FWL_WGTMGR_DisableThread) = 0; | |
npm
2016/11/15 18:20:19
Do we need to have the parameter default?
dsinclair
2016/11/15 18:40:36
No, but I'm not cleaning up default params yet, he
| |
51 virtual void OnProcessMessageToForm(CFWL_Message* pMessage) = 0; | |
52 virtual void OnDrawWidget(IFWL_Widget* pWidget, | |
53 CFX_Graphics* pGraphics, | |
54 const CFX_Matrix* pMatrix) = 0; | |
55 }; | |
56 | |
57 class CFWL_WidgetMgr : public IFWL_WidgetMgrDelegate { | |
48 public: | 58 public: |
49 explicit CFWL_WidgetMgr(CXFA_FFApp* pAdapterNative); | 59 explicit CFWL_WidgetMgr(CXFA_FFApp* pAdapterNative); |
50 ~CFWL_WidgetMgr(); | 60 ~CFWL_WidgetMgr(); |
51 | 61 |
62 // IFWL_WidgetMgrDelegate | |
63 void OnSetCapability( | |
64 uint32_t dwCapability = FWL_WGTMGR_DisableThread) override; | |
65 void OnProcessMessageToForm(CFWL_Message* pMessage) override; | |
66 void OnDrawWidget(IFWL_Widget* pWidget, | |
67 CFX_Graphics* pGraphics, | |
68 const CFX_Matrix* pMatrix) override; | |
69 | |
52 IFWL_Widget* GetParentWidget(IFWL_Widget* pWidget) const; | 70 IFWL_Widget* GetParentWidget(IFWL_Widget* pWidget) const; |
53 IFWL_Widget* GetOwnerWidget(IFWL_Widget* pWidget) const; | 71 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; | 72 IFWL_Widget* GetNextSiblingWidget(IFWL_Widget* pWidget) const; |
57 IFWL_Widget* GetLastSiblingWidget(IFWL_Widget* pWidget) const; | |
58 IFWL_Widget* GetFirstChildWidget(IFWL_Widget* pWidget) const; | 73 IFWL_Widget* GetFirstChildWidget(IFWL_Widget* pWidget) const; |
59 IFWL_Widget* GetLastChildWidget(IFWL_Widget* pWidget) const; | |
60 IFWL_Widget* GetSystemFormWidget(IFWL_Widget* pWidget) const; | 74 IFWL_Widget* GetSystemFormWidget(IFWL_Widget* pWidget) const; |
61 | 75 |
62 bool SetWidgetIndex(IFWL_Widget* pWidget, int32_t nIndex); | 76 void RepaintWidget(IFWL_Widget* pWidget, const CFX_RectF* pRect = nullptr); |
63 FWL_Error RepaintWidget(IFWL_Widget* pWidget, | |
64 const CFX_RectF* pRect = nullptr); | |
65 | 77 |
66 void AddWidget(IFWL_Widget* pWidget); | |
67 void InsertWidget(IFWL_Widget* pParent, | 78 void InsertWidget(IFWL_Widget* pParent, |
68 IFWL_Widget* pChild, | 79 IFWL_Widget* pChild, |
69 int32_t nIndex = -1); | 80 int32_t nIndex = -1); |
70 void RemoveWidget(IFWL_Widget* pWidget); | 81 void RemoveWidget(IFWL_Widget* pWidget); |
71 void SetOwner(IFWL_Widget* pOwner, IFWL_Widget* pOwned); | 82 void SetOwner(IFWL_Widget* pOwner, IFWL_Widget* pOwned); |
72 void SetParent(IFWL_Widget* pParent, IFWL_Widget* pChild); | 83 void SetParent(IFWL_Widget* pParent, IFWL_Widget* pChild); |
73 bool IsChild(IFWL_Widget* pChild, IFWL_Widget* pParent); | 84 |
74 FWL_Error SetWidgetRect_Native(IFWL_Widget* pWidget, const CFX_RectF& rect); | 85 void SetWidgetRect_Native(IFWL_Widget* pWidget, const CFX_RectF& rect); |
86 | |
75 IFWL_Widget* GetWidgetAtPoint(IFWL_Widget* pParent, FX_FLOAT fx, FX_FLOAT fy); | 87 IFWL_Widget* GetWidgetAtPoint(IFWL_Widget* pParent, FX_FLOAT fx, FX_FLOAT fy); |
88 | |
76 void NotifySizeChanged(IFWL_Widget* pForm, FX_FLOAT fx, FX_FLOAT fy); | 89 void NotifySizeChanged(IFWL_Widget* pForm, FX_FLOAT fx, FX_FLOAT fy); |
77 IFWL_Widget* nextTab(IFWL_Widget* parent, IFWL_Widget* focus, bool& bFind); | 90 |
78 int32_t CountRadioButtonGroup(IFWL_Widget* pFirst); | 91 IFWL_Widget* NextTab(IFWL_Widget* parent, IFWL_Widget* focus, bool& bFind); |
79 IFWL_Widget* GetSiblingRadioButton(IFWL_Widget* pWidget, bool bNext); | 92 |
80 IFWL_Widget* GetRadioButtonGroupHeader(IFWL_Widget* pRadioButton); | |
81 void GetSameGroupRadioButton(IFWL_Widget* pRadioButton, | 93 void GetSameGroupRadioButton(IFWL_Widget* pRadioButton, |
82 CFX_ArrayTemplate<IFWL_Widget*>& group); | 94 CFX_ArrayTemplate<IFWL_Widget*>& group) const; |
83 IFWL_Widget* GetDefaultButton(IFWL_Widget* pParent); | 95 IFWL_Widget* GetDefaultButton(IFWL_Widget* pParent) const; |
84 void AddRedrawCounts(IFWL_Widget* pWidget); | 96 void AddRedrawCounts(IFWL_Widget* pWidget); |
85 void ResetRedrawCounts(IFWL_Widget* pWidget); | 97 |
86 CXFA_FWLAdapterWidgetMgr* GetAdapterWidgetMgr() const { return m_pAdapter; } | 98 bool IsFormDisabled() const { |
87 CFWL_WidgetMgrDelegate* GetDelegate() const { return m_pDelegate.get(); } | 99 return !!(m_dwCapability & FWL_WGTMGR_DisableForm); |
88 CFWL_WidgetMgrItem* GetWidgetMgrItem(IFWL_Widget* pWidget) const; | 100 } |
89 bool IsThreadEnabled(); | 101 |
90 bool IsFormDisabled(); | 102 void GetAdapterPopupPos(IFWL_Widget* pWidget, |
91 bool GetAdapterPopupPos(IFWL_Widget* pWidget, | |
92 FX_FLOAT fMinHeight, | 103 FX_FLOAT fMinHeight, |
93 FX_FLOAT fMaxHeight, | 104 FX_FLOAT fMaxHeight, |
94 const CFX_RectF& rtAnchor, | 105 const CFX_RectF& rtAnchor, |
95 CFX_RectF& rtPopup); | 106 CFX_RectF& rtPopup) const; |
96 | 107 |
97 protected: | 108 private: |
98 friend class CFWL_WidgetMgrDelegate; | 109 IFWL_Widget* GetFirstSiblingWidget(IFWL_Widget* pWidget) const; |
110 IFWL_Widget* GetPriorSiblingWidget(IFWL_Widget* pWidget) const; | |
111 IFWL_Widget* GetLastChildWidget(IFWL_Widget* pWidget) const; | |
112 CFWL_WidgetMgrItem* GetWidgetMgrItem(IFWL_Widget* pWidget) const; | |
99 | 113 |
100 int32_t TravelWidgetMgr(CFWL_WidgetMgrItem* pParent, | 114 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 | 115 |
106 uint32_t m_dwCapability; | 116 int32_t CountRadioButtonGroup(IFWL_Widget* pFirst) const; |
107 std::unique_ptr<CFWL_WidgetMgrDelegate> m_pDelegate; | 117 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 | 118 |
115 class CFWL_WidgetMgrDelegate { | 119 void ResetRedrawCounts(IFWL_Widget* pWidget); |
116 public: | |
117 explicit CFWL_WidgetMgrDelegate(CFWL_WidgetMgr* pWidgetMgr); | |
118 ~CFWL_WidgetMgrDelegate() {} | |
119 | 120 |
120 FWL_Error OnSetCapability(uint32_t dwCapability = FWL_WGTMGR_DisableThread); | 121 bool IsThreadEnabled() const { |
121 void OnProcessMessageToForm(CFWL_Message* pMessage); | 122 return !(m_dwCapability & FWL_WGTMGR_DisableThread); |
122 void OnDrawWidget(IFWL_Widget* pWidget, | 123 } |
123 CFX_Graphics* pGraphics, | |
124 const CFX_Matrix* pMatrix); | |
125 | 124 |
126 protected: | |
127 void DrawChild(IFWL_Widget* pParent, | 125 void DrawChild(IFWL_Widget* pParent, |
128 const CFX_RectF& rtClip, | 126 const CFX_RectF& rtClip, |
129 CFX_Graphics* pGraphics, | 127 CFX_Graphics* pGraphics, |
130 const CFX_Matrix* pMatrix); | 128 const CFX_Matrix* pMatrix); |
131 CFX_Graphics* DrawWidgetBefore(IFWL_Widget* pWidget, | 129 CFX_Graphics* DrawWidgetBefore(IFWL_Widget* pWidget, |
132 CFX_Graphics* pGraphics, | 130 CFX_Graphics* pGraphics, |
133 const CFX_Matrix* pMatrix); | 131 const CFX_Matrix* pMatrix); |
134 void DrawWidgetAfter(IFWL_Widget* pWidget, | 132 void DrawWidgetAfter(IFWL_Widget* pWidget, |
135 CFX_Graphics* pGraphics, | 133 CFX_Graphics* pGraphics, |
136 CFX_RectF& rtClip, | 134 CFX_RectF& rtClip, |
137 const CFX_Matrix* pMatrix); | 135 const CFX_Matrix* pMatrix); |
138 bool IsNeedRepaint(IFWL_Widget* pWidget, | 136 bool IsNeedRepaint(IFWL_Widget* pWidget, |
139 CFX_Matrix* pMatrix, | 137 CFX_Matrix* pMatrix, |
140 const CFX_RectF& rtDirty); | 138 const CFX_RectF& rtDirty); |
141 bool bUseOffscreenDirect(IFWL_Widget* pWidget); | 139 bool UseOffscreenDirect(IFWL_Widget* pWidget) const; |
142 | 140 |
143 CFWL_WidgetMgr* m_pWidgetMgr; | 141 bool IsAbleNative(IFWL_Widget* pWidget) const; |
142 | |
143 uint32_t m_dwCapability; | |
144 std::map<IFWL_Widget*, std::unique_ptr<CFWL_WidgetMgrItem>> m_mapWidgetItem; | |
145 CXFA_FWLAdapterWidgetMgr* const m_pAdapter; | |
146 #if (_FX_OS_ == _FX_WIN32_DESKTOP_) || (_FX_OS_ == _FX_WIN64_) | |
147 CFX_RectF m_rtScreen; | |
148 #endif | |
144 }; | 149 }; |
145 | 150 |
146 #endif // XFA_FWL_CORE_CFWL_WIDGETMGR_H_ | 151 #endif // XFA_FWL_CORE_CFWL_WIDGETMGR_H_ |
OLD | NEW |