Chromium Code Reviews
chromiumcodereview-hr@appspot.gserviceaccount.com (chromiumcodereview-hr) | Please choose your nickname with Settings | Help | Chromium Project | Gerrit Changes | Sign out
(3)

Side by Side Diff: xfa/fwl/core/ifwl_widget.h

Issue 2488953003: Cleanup IFWL_Widget visibility and virtual parameters (Closed)
Patch Set: Created 4 years, 1 month ago
Use n/p to move between diff chunks; N/P to move between comments. Draft comments are only viewable by you.
Jump to:
View unified diff | Download patch
OLDNEW
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_IFWL_WIDGET_H_ 7 #ifndef XFA_FWL_CORE_IFWL_WIDGET_H_
8 #define XFA_FWL_CORE_IFWL_WIDGET_H_ 8 #define XFA_FWL_CORE_IFWL_WIDGET_H_
9 9
10 #include <memory> 10 #include <memory>
11 11
12 #include "core/fxcrt/fx_coordinates.h" 12 #include "core/fxcrt/fx_coordinates.h"
13 #include "core/fxcrt/fx_system.h" 13 #include "core/fxcrt/fx_system.h"
14 #include "xfa/fwl/core/cfwl_event.h" 14 #include "xfa/fwl/core/cfwl_event.h"
15 #include "xfa/fwl/core/cfwl_themepart.h" 15 #include "xfa/fwl/core/cfwl_themepart.h"
16 #include "xfa/fwl/core/cfwl_widgetmgr.h"
17 #include "xfa/fwl/core/cfwl_widgetproperties.h"
16 #include "xfa/fwl/core/fwl_widgethit.h" 18 #include "xfa/fwl/core/fwl_widgethit.h"
17 #include "xfa/fwl/core/ifwl_widgetdelegate.h" 19 #include "xfa/fwl/core/ifwl_widgetdelegate.h"
18 #include "xfa/fwl/theme/cfwl_widgettp.h" 20 #include "xfa/fwl/theme/cfwl_widgettp.h"
19 21
20 // FWL contains two parallel inheritance hierarchies, which reference each 22 // FWL contains two parallel inheritance hierarchies, which reference each
21 // other via pointers as follows: 23 // other via pointers as follows:
22 // 24 //
23 // m_pAssociate 25 // m_pAssociate
24 // <---------- 26 // <----------
25 // CFWL_Widget ----------> IFWL_Widget 27 // CFWL_Widget ----------> IFWL_Widget
(...skipping 35 matching lines...) Expand 10 before | Expand all | Expand 10 after
61 class IFWL_ThemeProvider; 63 class IFWL_ThemeProvider;
62 class IFWL_Widget; 64 class IFWL_Widget;
63 enum class FWL_Type; 65 enum class FWL_Type;
64 66
65 class IFWL_Widget : public IFWL_WidgetDelegate { 67 class IFWL_Widget : public IFWL_WidgetDelegate {
66 public: 68 public:
67 ~IFWL_Widget() override; 69 ~IFWL_Widget() override;
68 70
69 virtual FWL_Type GetClassID() const = 0; 71 virtual FWL_Type GetClassID() const = 0;
70 virtual bool IsInstance(const CFX_WideStringC& wsClass) const; 72 virtual bool IsInstance(const CFX_WideStringC& wsClass) const;
73 virtual void GetWidgetRect(CFX_RectF& rect, bool bAutoSize = false);
74 virtual void GetClientRect(CFX_RectF& rect);
75 virtual void ModifyStylesEx(uint32_t dwStylesExAdded,
76 uint32_t dwStylesExRemoved);
77 virtual void SetStates(uint32_t dwStates, bool bSet = true);
78 virtual void Update();
79 virtual FWL_WidgetHit HitTest(FX_FLOAT fx, FX_FLOAT fy);
80 virtual void DrawWidget(CFX_Graphics* pGraphics,
81 const CFX_Matrix* pMatrix = nullptr);
82 virtual void SetThemeProvider(IFWL_ThemeProvider* pThemeProvider);
71 83
72 virtual FWL_Error GetWidgetRect(CFX_RectF& rect, bool bAutoSize = false); 84 // IFWL_WidgetDelegate.
73 virtual FWL_Error GetGlobalRect(CFX_RectF& rect); 85 void OnProcessMessage(CFWL_Message* pMessage) override;
74 virtual FWL_Error SetWidgetRect(const CFX_RectF& rect); 86 void OnProcessEvent(CFWL_Event* pEvent) override;
75 virtual FWL_Error GetClientRect(CFX_RectF& rect); 87 void OnDrawWidget(CFX_Graphics* pGraphics,
88 const CFX_Matrix* pMatrix = nullptr) override;
76 89
77 virtual IFWL_Widget* GetParent(); 90 void SetWidgetRect(const CFX_RectF& rect);
78 virtual FWL_Error SetParent(IFWL_Widget* pParent); 91 void GetGlobalRect(CFX_RectF& rect);
79 92
80 virtual IFWL_Widget* GetOwner(); 93 void SetParent(IFWL_Widget* pParent);
81 virtual FWL_Error SetOwner(IFWL_Widget* pOwner);
82 94
83 virtual IFWL_Widget* GetOuter(); 95 IFWL_Widget* GetOwner() { return m_pWidgetMgr->GetOwnerWidget(this); }
96 IFWL_Widget* GetOuter() const { return m_pOuter; }
84 97
85 virtual uint32_t GetStyles(); 98 uint32_t GetStyles() const { return m_pProperties->m_dwStyles; }
86 virtual FWL_Error ModifyStyles(uint32_t dwStylesAdded, 99 void ModifyStyles(uint32_t dwStylesAdded, uint32_t dwStylesRemoved);
87 uint32_t dwStylesRemoved); 100 uint32_t GetStylesEx() const { return m_pProperties->m_dwStyleExes; }
88 virtual uint32_t GetStylesEx(); 101 uint32_t GetStates() const { return m_pProperties->m_dwStates; }
89 virtual FWL_Error ModifyStylesEx(uint32_t dwStylesExAdded,
90 uint32_t dwStylesExRemoved);
91 102
92 virtual uint32_t GetStates(); 103 void LockUpdate() { m_iLock++; }
93 virtual void SetStates(uint32_t dwStates, bool bSet = true); 104 void UnlockUpdate() {
105 if (IsLocked())
106 m_iLock--;
107 }
94 108
95 virtual FWL_Error Update(); 109 void TransformTo(IFWL_Widget* pWidget, FX_FLOAT& fx, FX_FLOAT& fy);
96 virtual FWL_Error LockUpdate(); 110 void GetMatrix(CFX_Matrix& matrix, bool bGlobal = false);
97 virtual FWL_Error UnlockUpdate(); 111 IFWL_ThemeProvider* GetThemeProvider() const {
98 112 return m_pProperties->m_pThemeProvider;
99 virtual FWL_WidgetHit HitTest(FX_FLOAT fx, FX_FLOAT fy); 113 }
100
101 virtual FWL_Error TransformTo(IFWL_Widget* pWidget,
102 FX_FLOAT& fx,
103 FX_FLOAT& fy);
104 virtual FWL_Error TransformTo(IFWL_Widget* pWidget, CFX_RectF& rt);
105
106 virtual FWL_Error GetMatrix(CFX_Matrix& matrix, bool bGlobal = false);
107 virtual FWL_Error SetMatrix(const CFX_Matrix& matrix);
108
109 virtual FWL_Error DrawWidget(CFX_Graphics* pGraphics,
110 const CFX_Matrix* pMatrix = nullptr);
111
112 virtual IFWL_ThemeProvider* GetThemeProvider();
113 virtual FWL_Error SetThemeProvider(IFWL_ThemeProvider* pThemeProvider);
114 114
115 void SetDelegate(IFWL_WidgetDelegate* delegate) { m_pDelegate = delegate; } 115 void SetDelegate(IFWL_WidgetDelegate* delegate) { m_pDelegate = delegate; }
116 IFWL_WidgetDelegate* GetDelegate() { 116 IFWL_WidgetDelegate* GetDelegate() {
117 return m_pDelegate ? m_pDelegate : this; 117 return m_pDelegate ? m_pDelegate : this;
118 } 118 }
119 const IFWL_WidgetDelegate* GetDelegate() const { 119 const IFWL_WidgetDelegate* GetDelegate() const {
120 return m_pDelegate ? m_pDelegate : this; 120 return m_pDelegate ? m_pDelegate : this;
121 } 121 }
122 122
123 // IFWL_WidgetDelegate. 123 const IFWL_App* GetOwnerApp() const { return m_pOwnerApp; }
124 void OnProcessMessage(CFWL_Message* pMessage) override; 124 uint32_t GetEventKey() const { return m_nEventKey; }
125 void OnProcessEvent(CFWL_Event* pEvent) override; 125 void SetEventKey(uint32_t key) { m_nEventKey = key; }
126 void OnDrawWidget(CFX_Graphics* pGraphics,
127 const CFX_Matrix* pMatrix = nullptr) override;
128 126
129 const IFWL_App* GetOwnerApp() const; 127 void* GetLayoutItem() const { return m_pLayoutItem; }
128 void SetLayoutItem(void* pItem) { m_pLayoutItem = pItem; }
130 129
131 CFX_SizeF GetOffsetFromParent(IFWL_Widget* pParent); 130 void SetAssociateWidget(CFWL_Widget* pAssociate) {
132 131 m_pAssociate = pAssociate;
133 uint32_t GetEventKey() const; 132 }
134 void SetEventKey(uint32_t key);
135
136 void* GetLayoutItem() const;
137 void SetLayoutItem(void* pItem);
138
139 void SetAssociateWidget(CFWL_Widget* pAssociate);
140 133
141 void SetFocus(bool bFocus); 134 void SetFocus(bool bFocus);
142 void Repaint(const CFX_RectF* pRect = nullptr); 135 void Repaint(const CFX_RectF* pRect = nullptr);
143 136
144 protected: 137 protected:
145 friend class CFWL_WidgetImpDelegate;
146
147 IFWL_Widget(const IFWL_App* app, 138 IFWL_Widget(const IFWL_App* app,
148 std::unique_ptr<CFWL_WidgetProperties> properties, 139 std::unique_ptr<CFWL_WidgetProperties> properties,
149 IFWL_Widget* pOuter); 140 IFWL_Widget* pOuter);
150 141
151 bool IsEnabled() const; 142 bool IsEnabled() const {
152 bool IsVisible() const; 143 return (m_pProperties->m_dwStates & FWL_WGTSTATE_Disabled) == 0;
153 bool IsActive() const; 144 }
154 bool IsOverLapper() const; 145 bool IsActive() const {
155 bool IsPopup() const; 146 return (m_pProperties->m_dwStates & FWL_WGTSTATE_Deactivated) == 0;
156 bool IsChild() const; 147 }
157 bool IsLocked() const; 148 bool IsLocked() const { return m_iLock > 0; }
158 bool IsOffscreen() const; 149 bool HasBorder() const {
159 bool HasBorder() const; 150 return !!(m_pProperties->m_dwStyles & FWL_WGTSTYLE_Border);
160 bool HasEdge() const; 151 }
152 bool HasEdge() const {
153 return !!(m_pProperties->m_dwStyles & FWL_WGTSTYLE_EdgeMask);
154 }
161 void GetEdgeRect(CFX_RectF& rtEdge); 155 void GetEdgeRect(CFX_RectF& rtEdge);
162 FX_FLOAT GetBorderSize(bool bCX = true); 156 FX_FLOAT GetBorderSize(bool bCX = true);
163 FX_FLOAT GetEdgeWidth(); 157 FX_FLOAT GetEdgeWidth();
164 void GetRelativeRect(CFX_RectF& rect); 158 void GetRelativeRect(CFX_RectF& rect);
165 void* GetThemeCapacity(CFWL_WidgetCapacity dwCapacity); 159 void* GetThemeCapacity(CFWL_WidgetCapacity dwCapacity);
166 IFWL_ThemeProvider* GetAvailableTheme(); 160 IFWL_ThemeProvider* GetAvailableTheme();
167 IFWL_Widget* GetRootOuter();
168 CFX_SizeF CalcTextSize(const CFX_WideString& wsText, 161 CFX_SizeF CalcTextSize(const CFX_WideString& wsText,
169 IFWL_ThemeProvider* pTheme, 162 IFWL_ThemeProvider* pTheme,
170 bool bMultiLine = false, 163 bool bMultiLine = false,
171 int32_t iLineWidth = -1); 164 int32_t iLineWidth = -1);
172 void CalcTextRect(const CFX_WideString& wsText, 165 void CalcTextRect(const CFX_WideString& wsText,
173 IFWL_ThemeProvider* pTheme, 166 IFWL_ThemeProvider* pTheme,
174 uint32_t dwTTOStyles, 167 uint32_t dwTTOStyles,
175 int32_t iTTOAlign, 168 int32_t iTTOAlign,
176 CFX_RectF& rect); 169 CFX_RectF& rect);
177 void SetGrab(bool bSet); 170 void SetGrab(bool bSet);
178 bool GetPopupPos(FX_FLOAT fMinHeight, 171 bool GetPopupPos(FX_FLOAT fMinHeight,
179 FX_FLOAT fMaxHeight, 172 FX_FLOAT fMaxHeight,
180 const CFX_RectF& rtAnchor, 173 const CFX_RectF& rtAnchor,
181 CFX_RectF& rtPopup); 174 CFX_RectF& rtPopup);
175 void RegisterEventTarget(IFWL_Widget* pEventSource = nullptr,
176 uint32_t dwFilter = FWL_EVENT_ALL_MASK);
177 void UnregisterEventTarget();
178 void DispatchKeyEvent(CFWL_MsgKey* pNote);
179 void DispatchEvent(CFWL_Event* pEvent);
180 void DrawBorder(CFX_Graphics* pGraphics,
181 CFWL_Part iPartBorder,
182 IFWL_ThemeProvider* pTheme,
183 const CFX_Matrix* pMatrix = nullptr);
184 void DrawEdge(CFX_Graphics* pGraphics,
185 CFWL_Part iPartEdge,
186 IFWL_ThemeProvider* pTheme,
187 const CFX_Matrix* pMatrix = nullptr);
188
189 const IFWL_App* const m_pOwnerApp;
190 CFWL_WidgetMgr* const m_pWidgetMgr;
191 std::unique_ptr<CFWL_WidgetProperties> m_pProperties;
192 IFWL_Widget* m_pOuter;
193
194 int32_t m_iLock;
195
196 private:
197 IFWL_Widget* GetParent() { return m_pWidgetMgr->GetParentWidget(this); }
198 CFX_SizeF GetOffsetFromParent(IFWL_Widget* pParent);
199
200 bool IsVisible() const {
201 return (m_pProperties->m_dwStates & FWL_WGTSTATE_Invisible) == 0;
202 }
203 bool IsOverLapper() const {
204 return (m_pProperties->m_dwStyles & FWL_WGTSTYLE_WindowTypeMask) ==
205 FWL_WGTSTYLE_OverLapper;
206 }
207 bool IsPopup() const {
208 return !!(m_pProperties->m_dwStyles & FWL_WGTSTYLE_Popup);
209 }
210 bool IsChild() const {
211 return !!(m_pProperties->m_dwStyles & FWL_WGTSTYLE_Child);
212 }
213 bool IsOffscreen() const {
214 return !!(m_pProperties->m_dwStyles & FWL_WGTSTYLE_Offscreen);
215 }
216 IFWL_Widget* GetRootOuter();
182 bool GetPopupPosMenu(FX_FLOAT fMinHeight, 217 bool GetPopupPosMenu(FX_FLOAT fMinHeight,
183 FX_FLOAT fMaxHeight, 218 FX_FLOAT fMaxHeight,
184 const CFX_RectF& rtAnchor, 219 const CFX_RectF& rtAnchor,
185 CFX_RectF& rtPopup); 220 CFX_RectF& rtPopup);
186 bool GetPopupPosComboBox(FX_FLOAT fMinHeight, 221 bool GetPopupPosComboBox(FX_FLOAT fMinHeight,
187 FX_FLOAT fMaxHeight, 222 FX_FLOAT fMaxHeight,
188 const CFX_RectF& rtAnchor, 223 const CFX_RectF& rtAnchor,
189 CFX_RectF& rtPopup); 224 CFX_RectF& rtPopup);
190 bool GetPopupPosGeneral(FX_FLOAT fMinHeight, 225 bool GetPopupPosGeneral(FX_FLOAT fMinHeight,
191 FX_FLOAT fMaxHeight, 226 FX_FLOAT fMaxHeight,
192 const CFX_RectF& rtAnchor, 227 const CFX_RectF& rtAnchor,
193 CFX_RectF& rtPopup); 228 CFX_RectF& rtPopup);
194 bool GetScreenSize(FX_FLOAT& fx, FX_FLOAT& fy); 229 bool GetScreenSize(FX_FLOAT& fx, FX_FLOAT& fy);
195 void RegisterEventTarget(IFWL_Widget* pEventSource = nullptr,
196 uint32_t dwFilter = FWL_EVENT_ALL_MASK);
197 void UnregisterEventTarget();
198 void DispatchKeyEvent(CFWL_MsgKey* pNote);
199 void DispatchEvent(CFWL_Event* pEvent);
200 void DrawBackground(CFX_Graphics* pGraphics, 230 void DrawBackground(CFX_Graphics* pGraphics,
201 CFWL_Part iPartBk, 231 CFWL_Part iPartBk,
202 IFWL_ThemeProvider* pTheme, 232 IFWL_ThemeProvider* pTheme,
203 const CFX_Matrix* pMatrix = nullptr); 233 const CFX_Matrix* pMatrix = nullptr);
204 void DrawBorder(CFX_Graphics* pGraphics,
205 CFWL_Part iPartBorder,
206 IFWL_ThemeProvider* pTheme,
207 const CFX_Matrix* pMatrix = nullptr);
208 void DrawEdge(CFX_Graphics* pGraphics,
209 CFWL_Part iPartEdge,
210 IFWL_ThemeProvider* pTheme,
211 const CFX_Matrix* pMatrix = nullptr);
212 void NotifyDriver(); 234 void NotifyDriver();
213
214 bool IsParent(IFWL_Widget* pParent); 235 bool IsParent(IFWL_Widget* pParent);
215 236
216 const IFWL_App* const m_pOwnerApp;
217 CFWL_WidgetMgr* const m_pWidgetMgr;
218 std::unique_ptr<CFWL_WidgetProperties> m_pProperties;
219 IFWL_Widget* m_pOuter;
220 void* m_pLayoutItem; 237 void* m_pLayoutItem;
221 CFWL_Widget* m_pAssociate; 238 CFWL_Widget* m_pAssociate;
222 int32_t m_iLock;
223 uint32_t m_nEventKey; 239 uint32_t m_nEventKey;
224
225 private:
226 IFWL_WidgetDelegate* m_pDelegate; // Not owned. 240 IFWL_WidgetDelegate* m_pDelegate; // Not owned.
227 }; 241 };
228 242
229 #endif // XFA_FWL_CORE_IFWL_WIDGET_H_ 243 #endif // XFA_FWL_CORE_IFWL_WIDGET_H_
OLDNEW

Powered by Google App Engine
This is Rietveld 408576698