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

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

Issue 2506253004: Split fwl/core class pt I. (Closed)
Patch Set: Rebase to master Created 4 years 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
« no previous file with comments | « xfa/fwl/core/ifwl_tooltip.cpp ('k') | xfa/fwl/core/ifwl_widget.cpp » ('j') | no next file with comments »
Toggle Intra-line Diffs ('i') | Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
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" 16 #include "xfa/fwl/core/cfwl_widgetmgr.h"
17 #include "xfa/fwl/core/cfwl_widgetproperties.h"
18 #include "xfa/fwl/core/fwl_widgethit.h" 17 #include "xfa/fwl/core/fwl_widgethit.h"
19 #include "xfa/fwl/core/ifwl_widgetdelegate.h" 18 #include "xfa/fwl/core/ifwl_widgetdelegate.h"
20 #include "xfa/fwl/theme/cfwl_widgettp.h" 19 #include "xfa/fwl/theme/cfwl_widgettp.h"
21 20
22 // FWL contains two parallel inheritance hierarchies, which reference each 21 // FWL contains two parallel inheritance hierarchies, which reference each
23 // other via pointers as follows: 22 // other via pointers as follows:
24 // 23 //
25 // m_pAssociate 24 // m_pAssociate
26 // <---------- 25 // <----------
27 // CFWL_Widget ----------> IFWL_Widget 26 // CFWL_Widget ----------> IFWL_Widget
(...skipping 24 matching lines...) Expand all
52 SpinButton, 51 SpinButton,
53 ToolTip 52 ToolTip
54 }; 53 };
55 54
56 class CFWL_AppImp; 55 class CFWL_AppImp;
57 class CFWL_MsgKey; 56 class CFWL_MsgKey;
58 class CFWL_Widget; 57 class CFWL_Widget;
59 class CFWL_WidgetProperties; 58 class CFWL_WidgetProperties;
60 class CFWL_WidgetMgr; 59 class CFWL_WidgetMgr;
61 class IFWL_App; 60 class IFWL_App;
62 class IFWL_DataProvider;
63 class IFWL_ThemeProvider; 61 class IFWL_ThemeProvider;
64 class IFWL_Widget; 62 class IFWL_Widget;
65 enum class FWL_Type; 63 enum class FWL_Type;
66 64
67 class IFWL_Widget : public IFWL_WidgetDelegate { 65 class IFWL_Widget : public IFWL_WidgetDelegate {
68 public: 66 public:
67 class DataProvider {
68 public:
69 virtual void GetCaption(IFWL_Widget* pWidget,
70 CFX_WideString& wsCaption) = 0;
71 };
72
69 ~IFWL_Widget() override; 73 ~IFWL_Widget() override;
70 74
71 virtual FWL_Type GetClassID() const = 0; 75 virtual FWL_Type GetClassID() const = 0;
72 virtual bool IsInstance(const CFX_WideStringC& wsClass) const; 76 virtual bool IsInstance(const CFX_WideStringC& wsClass) const;
73 virtual void GetWidgetRect(CFX_RectF& rect, bool bAutoSize = false); 77 virtual void GetWidgetRect(CFX_RectF& rect, bool bAutoSize = false);
74 virtual void GetClientRect(CFX_RectF& rect); 78 virtual void GetClientRect(CFX_RectF& rect);
75 virtual void ModifyStylesEx(uint32_t dwStylesExAdded, 79 virtual void ModifyStylesEx(uint32_t dwStylesExAdded,
76 uint32_t dwStylesExRemoved); 80 uint32_t dwStylesExRemoved);
77 virtual void SetStates(uint32_t dwStates, bool bSet = true); 81 virtual void SetStates(uint32_t dwStates, bool bSet = true);
78 virtual void Update(); 82 virtual void Update();
79 virtual FWL_WidgetHit HitTest(FX_FLOAT fx, FX_FLOAT fy); 83 virtual FWL_WidgetHit HitTest(FX_FLOAT fx, FX_FLOAT fy);
80 virtual void DrawWidget(CFX_Graphics* pGraphics, 84 virtual void DrawWidget(CFX_Graphics* pGraphics,
81 const CFX_Matrix* pMatrix = nullptr); 85 const CFX_Matrix* pMatrix = nullptr);
82 virtual void SetThemeProvider(IFWL_ThemeProvider* pThemeProvider); 86 virtual void SetThemeProvider(IFWL_ThemeProvider* pThemeProvider);
83 87
84 // IFWL_WidgetDelegate. 88 // IFWL_WidgetDelegate.
85 void OnProcessMessage(CFWL_Message* pMessage) override; 89 void OnProcessMessage(CFWL_Message* pMessage) override;
86 void OnProcessEvent(CFWL_Event* pEvent) override; 90 void OnProcessEvent(CFWL_Event* pEvent) override;
87 void OnDrawWidget(CFX_Graphics* pGraphics, 91 void OnDrawWidget(CFX_Graphics* pGraphics,
88 const CFX_Matrix* pMatrix = nullptr) override; 92 const CFX_Matrix* pMatrix = nullptr) override;
89 93
90 void SetWidgetRect(const CFX_RectF& rect); 94 void SetWidgetRect(const CFX_RectF& rect);
91 95
92 void SetParent(IFWL_Widget* pParent); 96 void SetParent(IFWL_Widget* pParent);
93 97
94 IFWL_Widget* GetOwner() { return m_pWidgetMgr->GetOwnerWidget(this); } 98 IFWL_Widget* GetOwner() { return m_pWidgetMgr->GetOwnerWidget(this); }
95 IFWL_Widget* GetOuter() const { return m_pOuter; } 99 IFWL_Widget* GetOuter() const { return m_pOuter; }
96 100
97 uint32_t GetStyles() const { return m_pProperties->m_dwStyles; } 101 uint32_t GetStyles() const;
98 void ModifyStyles(uint32_t dwStylesAdded, uint32_t dwStylesRemoved); 102 void ModifyStyles(uint32_t dwStylesAdded, uint32_t dwStylesRemoved);
99 uint32_t GetStylesEx() const { return m_pProperties->m_dwStyleExes; } 103 uint32_t GetStylesEx() const;
100 uint32_t GetStates() const { return m_pProperties->m_dwStates; } 104 uint32_t GetStates() const;
101 105
102 void LockUpdate() { m_iLock++; } 106 void LockUpdate() { m_iLock++; }
103 void UnlockUpdate() { 107 void UnlockUpdate() {
104 if (IsLocked()) 108 if (IsLocked())
105 m_iLock--; 109 m_iLock--;
106 } 110 }
107 111
108 void TransformTo(IFWL_Widget* pWidget, FX_FLOAT& fx, FX_FLOAT& fy); 112 void TransformTo(IFWL_Widget* pWidget, FX_FLOAT& fx, FX_FLOAT& fy);
109 void GetMatrix(CFX_Matrix& matrix, bool bGlobal = false); 113 void GetMatrix(CFX_Matrix& matrix, bool bGlobal = false);
110 IFWL_ThemeProvider* GetThemeProvider() const { 114 IFWL_ThemeProvider* GetThemeProvider() const;
111 return m_pProperties->m_pThemeProvider; 115 IFWL_Widget::DataProvider* GetDataProvider() const;
112 }
113
114 IFWL_DataProvider* GetDataProvider() const {
115 return m_pProperties->m_pDataProvider;
116 }
117 116
118 void SetDelegate(IFWL_WidgetDelegate* delegate) { m_pDelegate = delegate; } 117 void SetDelegate(IFWL_WidgetDelegate* delegate) { m_pDelegate = delegate; }
119 IFWL_WidgetDelegate* GetDelegate() { 118 IFWL_WidgetDelegate* GetDelegate() {
120 return m_pDelegate ? m_pDelegate : this; 119 return m_pDelegate ? m_pDelegate : this;
121 } 120 }
122 const IFWL_WidgetDelegate* GetDelegate() const { 121 const IFWL_WidgetDelegate* GetDelegate() const {
123 return m_pDelegate ? m_pDelegate : this; 122 return m_pDelegate ? m_pDelegate : this;
124 } 123 }
125 124
126 const IFWL_App* GetOwnerApp() const { return m_pOwnerApp; } 125 const IFWL_App* GetOwnerApp() const { return m_pOwnerApp; }
127 uint32_t GetEventKey() const { return m_nEventKey; } 126 uint32_t GetEventKey() const { return m_nEventKey; }
128 void SetEventKey(uint32_t key) { m_nEventKey = key; } 127 void SetEventKey(uint32_t key) { m_nEventKey = key; }
129 128
130 void* GetLayoutItem() const { return m_pLayoutItem; } 129 void* GetLayoutItem() const { return m_pLayoutItem; }
131 void SetLayoutItem(void* pItem) { m_pLayoutItem = pItem; } 130 void SetLayoutItem(void* pItem) { m_pLayoutItem = pItem; }
132 131
133 void SetAssociateWidget(CFWL_Widget* pAssociate) { 132 void SetAssociateWidget(CFWL_Widget* pAssociate) {
134 m_pAssociate = pAssociate; 133 m_pAssociate = pAssociate;
135 } 134 }
136 135
137 void SetFocus(bool bFocus); 136 void SetFocus(bool bFocus);
138 void Repaint(const CFX_RectF* pRect = nullptr); 137 void Repaint(const CFX_RectF* pRect = nullptr);
139 138
140 protected: 139 protected:
141 IFWL_Widget(const IFWL_App* app, 140 IFWL_Widget(const IFWL_App* app,
142 std::unique_ptr<CFWL_WidgetProperties> properties, 141 std::unique_ptr<CFWL_WidgetProperties> properties,
143 IFWL_Widget* pOuter); 142 IFWL_Widget* pOuter);
144 143
145 bool IsEnabled() const { 144 bool IsEnabled() const;
146 return (m_pProperties->m_dwStates & FWL_WGTSTATE_Disabled) == 0; 145 bool IsActive() const;
147 }
148 bool IsActive() const {
149 return (m_pProperties->m_dwStates & FWL_WGTSTATE_Deactivated) == 0;
150 }
151 bool IsLocked() const { return m_iLock > 0; } 146 bool IsLocked() const { return m_iLock > 0; }
152 bool HasBorder() const { 147 bool HasBorder() const;
153 return !!(m_pProperties->m_dwStyles & FWL_WGTSTYLE_Border); 148 bool HasEdge() const;
154 }
155 bool HasEdge() const {
156 return !!(m_pProperties->m_dwStyles & FWL_WGTSTYLE_EdgeMask);
157 }
158 void GetEdgeRect(CFX_RectF& rtEdge); 149 void GetEdgeRect(CFX_RectF& rtEdge);
159 FX_FLOAT GetBorderSize(bool bCX = true); 150 FX_FLOAT GetBorderSize(bool bCX = true);
160 FX_FLOAT GetEdgeWidth(); 151 FX_FLOAT GetEdgeWidth();
161 void GetRelativeRect(CFX_RectF& rect); 152 void GetRelativeRect(CFX_RectF& rect);
162 void* GetThemeCapacity(CFWL_WidgetCapacity dwCapacity); 153 void* GetThemeCapacity(CFWL_WidgetCapacity dwCapacity);
163 IFWL_ThemeProvider* GetAvailableTheme(); 154 IFWL_ThemeProvider* GetAvailableTheme();
164 CFX_SizeF CalcTextSize(const CFX_WideString& wsText, 155 CFX_SizeF CalcTextSize(const CFX_WideString& wsText,
165 IFWL_ThemeProvider* pTheme, 156 IFWL_ThemeProvider* pTheme,
166 bool bMultiLine = false, 157 bool bMultiLine = false,
167 int32_t iLineWidth = -1); 158 int32_t iLineWidth = -1);
(...skipping 24 matching lines...) Expand all
192 const IFWL_App* const m_pOwnerApp; 183 const IFWL_App* const m_pOwnerApp;
193 CFWL_WidgetMgr* const m_pWidgetMgr; 184 CFWL_WidgetMgr* const m_pWidgetMgr;
194 std::unique_ptr<CFWL_WidgetProperties> m_pProperties; 185 std::unique_ptr<CFWL_WidgetProperties> m_pProperties;
195 IFWL_Widget* m_pOuter; 186 IFWL_Widget* m_pOuter;
196 int32_t m_iLock; 187 int32_t m_iLock;
197 188
198 private: 189 private:
199 IFWL_Widget* GetParent() { return m_pWidgetMgr->GetParentWidget(this); } 190 IFWL_Widget* GetParent() { return m_pWidgetMgr->GetParentWidget(this); }
200 CFX_SizeF GetOffsetFromParent(IFWL_Widget* pParent); 191 CFX_SizeF GetOffsetFromParent(IFWL_Widget* pParent);
201 192
202 bool IsVisible() const { 193 bool IsVisible() const;
203 return (m_pProperties->m_dwStates & FWL_WGTSTATE_Invisible) == 0; 194 bool IsOverLapper() const;
204 } 195 bool IsPopup() const;
205 bool IsOverLapper() const { 196 bool IsChild() const;
206 return (m_pProperties->m_dwStyles & FWL_WGTSTYLE_WindowTypeMask) == 197 bool IsOffscreen() const;
207 FWL_WGTSTYLE_OverLapper;
208 }
209 bool IsPopup() const {
210 return !!(m_pProperties->m_dwStyles & FWL_WGTSTYLE_Popup);
211 }
212 bool IsChild() const {
213 return !!(m_pProperties->m_dwStyles & FWL_WGTSTYLE_Child);
214 }
215 bool IsOffscreen() const {
216 return !!(m_pProperties->m_dwStyles & FWL_WGTSTYLE_Offscreen);
217 }
218 IFWL_Widget* GetRootOuter(); 198 IFWL_Widget* GetRootOuter();
219 bool GetPopupPosMenu(FX_FLOAT fMinHeight, 199 bool GetPopupPosMenu(FX_FLOAT fMinHeight,
220 FX_FLOAT fMaxHeight, 200 FX_FLOAT fMaxHeight,
221 const CFX_RectF& rtAnchor, 201 const CFX_RectF& rtAnchor,
222 CFX_RectF& rtPopup); 202 CFX_RectF& rtPopup);
223 bool GetPopupPosComboBox(FX_FLOAT fMinHeight, 203 bool GetPopupPosComboBox(FX_FLOAT fMinHeight,
224 FX_FLOAT fMaxHeight, 204 FX_FLOAT fMaxHeight,
225 const CFX_RectF& rtAnchor, 205 const CFX_RectF& rtAnchor,
226 CFX_RectF& rtPopup); 206 CFX_RectF& rtPopup);
227 bool GetPopupPosGeneral(FX_FLOAT fMinHeight, 207 bool GetPopupPosGeneral(FX_FLOAT fMinHeight,
228 FX_FLOAT fMaxHeight, 208 FX_FLOAT fMaxHeight,
229 const CFX_RectF& rtAnchor, 209 const CFX_RectF& rtAnchor,
230 CFX_RectF& rtPopup); 210 CFX_RectF& rtPopup);
231 bool GetScreenSize(FX_FLOAT& fx, FX_FLOAT& fy); 211 bool GetScreenSize(FX_FLOAT& fx, FX_FLOAT& fy);
232 void DrawBackground(CFX_Graphics* pGraphics, 212 void DrawBackground(CFX_Graphics* pGraphics,
233 CFWL_Part iPartBk, 213 CFWL_Part iPartBk,
234 IFWL_ThemeProvider* pTheme, 214 IFWL_ThemeProvider* pTheme,
235 const CFX_Matrix* pMatrix = nullptr); 215 const CFX_Matrix* pMatrix = nullptr);
236 void NotifyDriver(); 216 void NotifyDriver();
237 bool IsParent(IFWL_Widget* pParent); 217 bool IsParent(IFWL_Widget* pParent);
238 218
239 void* m_pLayoutItem; 219 void* m_pLayoutItem;
240 CFWL_Widget* m_pAssociate; 220 CFWL_Widget* m_pAssociate;
241 uint32_t m_nEventKey; 221 uint32_t m_nEventKey;
242 IFWL_WidgetDelegate* m_pDelegate; // Not owned. 222 IFWL_WidgetDelegate* m_pDelegate; // Not owned.
243 }; 223 };
244 224
245 #endif // XFA_FWL_CORE_IFWL_WIDGET_H_ 225 #endif // XFA_FWL_CORE_IFWL_WIDGET_H_
OLDNEW
« no previous file with comments | « xfa/fwl/core/ifwl_tooltip.cpp ('k') | xfa/fwl/core/ifwl_widget.cpp » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698