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

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

Issue 2467993003: Merge delegates into IFWL_* classes. (Closed)
Patch Set: Add const version 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
« 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>
(...skipping 44 matching lines...) Expand 10 before | Expand all | Expand 10 after
55 class CFWL_MsgKey; 55 class CFWL_MsgKey;
56 class CFWL_Widget; 56 class CFWL_Widget;
57 class CFWL_WidgetImpProperties; 57 class CFWL_WidgetImpProperties;
58 class CFWL_WidgetMgr; 58 class CFWL_WidgetMgr;
59 class IFWL_App; 59 class IFWL_App;
60 class IFWL_DataProvider; 60 class IFWL_DataProvider;
61 class IFWL_ThemeProvider; 61 class IFWL_ThemeProvider;
62 class IFWL_Widget; 62 class IFWL_Widget;
63 enum class FWL_Type; 63 enum class FWL_Type;
64 64
65 class IFWL_Widget { 65 class IFWL_Widget : public IFWL_WidgetDelegate {
66 public: 66 public:
67 virtual ~IFWL_Widget(); 67 ~IFWL_Widget() override;
68 68
69 virtual FWL_Type GetClassID() const = 0; 69 virtual FWL_Type GetClassID() const = 0;
70 virtual FX_BOOL IsInstance(const CFX_WideStringC& wsClass) const; 70 virtual FX_BOOL IsInstance(const CFX_WideStringC& wsClass) const;
71 71
72 virtual FWL_Error GetWidgetRect(CFX_RectF& rect, FX_BOOL bAutoSize = FALSE); 72 virtual FWL_Error GetWidgetRect(CFX_RectF& rect, FX_BOOL bAutoSize = FALSE);
73 virtual FWL_Error GetGlobalRect(CFX_RectF& rect); 73 virtual FWL_Error GetGlobalRect(CFX_RectF& rect);
74 virtual FWL_Error SetWidgetRect(const CFX_RectF& rect); 74 virtual FWL_Error SetWidgetRect(const CFX_RectF& rect);
75 virtual FWL_Error GetClientRect(CFX_RectF& rect); 75 virtual FWL_Error GetClientRect(CFX_RectF& rect);
76 76
77 virtual IFWL_Widget* GetParent(); 77 virtual IFWL_Widget* GetParent();
(...skipping 27 matching lines...) Expand all
105 105
106 virtual FWL_Error GetMatrix(CFX_Matrix& matrix, FX_BOOL bGlobal = FALSE); 106 virtual FWL_Error GetMatrix(CFX_Matrix& matrix, FX_BOOL bGlobal = FALSE);
107 virtual FWL_Error SetMatrix(const CFX_Matrix& matrix); 107 virtual FWL_Error SetMatrix(const CFX_Matrix& matrix);
108 108
109 virtual FWL_Error DrawWidget(CFX_Graphics* pGraphics, 109 virtual FWL_Error DrawWidget(CFX_Graphics* pGraphics,
110 const CFX_Matrix* pMatrix = nullptr); 110 const CFX_Matrix* pMatrix = nullptr);
111 111
112 virtual IFWL_ThemeProvider* GetThemeProvider(); 112 virtual IFWL_ThemeProvider* GetThemeProvider();
113 virtual FWL_Error SetThemeProvider(IFWL_ThemeProvider* pThemeProvider); 113 virtual FWL_Error SetThemeProvider(IFWL_ThemeProvider* pThemeProvider);
114 114
115 IFWL_WidgetDelegate* GetCurrentDelegate(); 115 void SetDelegate(IFWL_WidgetDelegate* delegate) { m_pDelegate = delegate; }
116 void SetCurrentDelegate(IFWL_WidgetDelegate* pDelegate); 116 IFWL_WidgetDelegate* GetDelegate() {
117 return m_pDelegate ? m_pDelegate : this;
118 }
119 const IFWL_WidgetDelegate* GetDelegate() const {
120 return m_pDelegate ? m_pDelegate : this;
121 }
122
123 // IFWL_WidgetDelegate.
124 void OnProcessMessage(CFWL_Message* pMessage) override;
125 void OnProcessEvent(CFWL_Event* pEvent) override;
126 void OnDrawWidget(CFX_Graphics* pGraphics,
127 const CFX_Matrix* pMatrix = nullptr) override;
117 128
118 const IFWL_App* GetOwnerApp() const; 129 const IFWL_App* GetOwnerApp() const;
119 130
120 CFX_SizeF GetOffsetFromParent(IFWL_Widget* pParent); 131 CFX_SizeF GetOffsetFromParent(IFWL_Widget* pParent);
121 132
122 uint32_t GetEventKey() const; 133 uint32_t GetEventKey() const;
123 void SetEventKey(uint32_t key); 134 void SetEventKey(uint32_t key);
124 135
125 void* GetLayoutItem() const; 136 void* GetLayoutItem() const;
126 void SetLayoutItem(void* pItem); 137 void SetLayoutItem(void* pItem);
127 138
128 void SetAssociateWidget(CFWL_Widget* pAssociate); 139 void SetAssociateWidget(CFWL_Widget* pAssociate);
129 140
141 void SetFocus(FX_BOOL bFocus);
142 void Repaint(const CFX_RectF* pRect = nullptr);
143
130 protected: 144 protected:
131 friend class CFWL_WidgetImpDelegate; 145 friend class CFWL_WidgetImpDelegate;
132 146
133 IFWL_Widget(const IFWL_App* app, 147 IFWL_Widget(const IFWL_App* app,
134 const CFWL_WidgetImpProperties& properties, 148 const CFWL_WidgetImpProperties& properties,
135 IFWL_Widget* pOuter); 149 IFWL_Widget* pOuter);
136 150
137 FX_BOOL IsEnabled() const; 151 FX_BOOL IsEnabled() const;
138 FX_BOOL IsVisible() const; 152 FX_BOOL IsVisible() const;
139 FX_BOOL IsActive() const; 153 FX_BOOL IsActive() const;
(...skipping 13 matching lines...) Expand all
153 IFWL_Widget* GetRootOuter(); 167 IFWL_Widget* GetRootOuter();
154 CFX_SizeF CalcTextSize(const CFX_WideString& wsText, 168 CFX_SizeF CalcTextSize(const CFX_WideString& wsText,
155 IFWL_ThemeProvider* pTheme, 169 IFWL_ThemeProvider* pTheme,
156 FX_BOOL bMultiLine = FALSE, 170 FX_BOOL bMultiLine = FALSE,
157 int32_t iLineWidth = -1); 171 int32_t iLineWidth = -1);
158 void CalcTextRect(const CFX_WideString& wsText, 172 void CalcTextRect(const CFX_WideString& wsText,
159 IFWL_ThemeProvider* pTheme, 173 IFWL_ThemeProvider* pTheme,
160 uint32_t dwTTOStyles, 174 uint32_t dwTTOStyles,
161 int32_t iTTOAlign, 175 int32_t iTTOAlign,
162 CFX_RectF& rect); 176 CFX_RectF& rect);
163 void SetFocus(FX_BOOL bFocus);
164 void SetGrab(FX_BOOL bSet); 177 void SetGrab(FX_BOOL bSet);
165 FX_BOOL GetPopupPos(FX_FLOAT fMinHeight, 178 FX_BOOL GetPopupPos(FX_FLOAT fMinHeight,
166 FX_FLOAT fMaxHeight, 179 FX_FLOAT fMaxHeight,
167 const CFX_RectF& rtAnchor, 180 const CFX_RectF& rtAnchor,
168 CFX_RectF& rtPopup); 181 CFX_RectF& rtPopup);
169 FX_BOOL GetPopupPosMenu(FX_FLOAT fMinHeight, 182 FX_BOOL GetPopupPosMenu(FX_FLOAT fMinHeight,
170 FX_FLOAT fMaxHeight, 183 FX_FLOAT fMaxHeight,
171 const CFX_RectF& rtAnchor, 184 const CFX_RectF& rtAnchor,
172 CFX_RectF& rtPopup); 185 CFX_RectF& rtPopup);
173 FX_BOOL GetPopupPosComboBox(FX_FLOAT fMinHeight, 186 FX_BOOL GetPopupPosComboBox(FX_FLOAT fMinHeight,
174 FX_FLOAT fMaxHeight, 187 FX_FLOAT fMaxHeight,
175 const CFX_RectF& rtAnchor, 188 const CFX_RectF& rtAnchor,
176 CFX_RectF& rtPopup); 189 CFX_RectF& rtPopup);
177 FX_BOOL GetPopupPosGeneral(FX_FLOAT fMinHeight, 190 FX_BOOL GetPopupPosGeneral(FX_FLOAT fMinHeight,
178 FX_FLOAT fMaxHeight, 191 FX_FLOAT fMaxHeight,
179 const CFX_RectF& rtAnchor, 192 const CFX_RectF& rtAnchor,
180 CFX_RectF& rtPopup); 193 CFX_RectF& rtPopup);
181 FX_BOOL GetScreenSize(FX_FLOAT& fx, FX_FLOAT& fy); 194 FX_BOOL GetScreenSize(FX_FLOAT& fx, FX_FLOAT& fy);
182 void RegisterEventTarget(IFWL_Widget* pEventSource = nullptr, 195 void RegisterEventTarget(IFWL_Widget* pEventSource = nullptr,
183 uint32_t dwFilter = FWL_EVENT_ALL_MASK); 196 uint32_t dwFilter = FWL_EVENT_ALL_MASK);
184 void UnregisterEventTarget(); 197 void UnregisterEventTarget();
185 void DispatchKeyEvent(CFWL_MsgKey* pNote); 198 void DispatchKeyEvent(CFWL_MsgKey* pNote);
186 void DispatchEvent(CFWL_Event* pEvent); 199 void DispatchEvent(CFWL_Event* pEvent);
187 void Repaint(const CFX_RectF* pRect = nullptr);
188 void DrawBackground(CFX_Graphics* pGraphics, 200 void DrawBackground(CFX_Graphics* pGraphics,
189 CFWL_Part iPartBk, 201 CFWL_Part iPartBk,
190 IFWL_ThemeProvider* pTheme, 202 IFWL_ThemeProvider* pTheme,
191 const CFX_Matrix* pMatrix = nullptr); 203 const CFX_Matrix* pMatrix = nullptr);
192 void DrawBorder(CFX_Graphics* pGraphics, 204 void DrawBorder(CFX_Graphics* pGraphics,
193 CFWL_Part iPartBorder, 205 CFWL_Part iPartBorder,
194 IFWL_ThemeProvider* pTheme, 206 IFWL_ThemeProvider* pTheme,
195 const CFX_Matrix* pMatrix = nullptr); 207 const CFX_Matrix* pMatrix = nullptr);
196 void DrawEdge(CFX_Graphics* pGraphics, 208 void DrawEdge(CFX_Graphics* pGraphics,
197 CFWL_Part iPartEdge, 209 CFWL_Part iPartEdge,
198 IFWL_ThemeProvider* pTheme, 210 IFWL_ThemeProvider* pTheme,
199 const CFX_Matrix* pMatrix = nullptr); 211 const CFX_Matrix* pMatrix = nullptr);
200 void NotifyDriver(); 212 void NotifyDriver();
201 213
202 FX_BOOL IsParent(IFWL_Widget* pParent); 214 FX_BOOL IsParent(IFWL_Widget* pParent);
203 215
204 void SetDelegate(std::unique_ptr<IFWL_WidgetDelegate> delegate) {
205 m_pDelegate = std::move(delegate);
206 }
207 IFWL_WidgetDelegate* GetDelegate() const { return m_pDelegate.get(); }
208
209 const IFWL_App* const m_pOwnerApp; 216 const IFWL_App* const m_pOwnerApp;
210 CFWL_WidgetMgr* const m_pWidgetMgr; 217 CFWL_WidgetMgr* const m_pWidgetMgr;
211 std::unique_ptr<CFWL_WidgetImpProperties> m_pProperties; 218 std::unique_ptr<CFWL_WidgetImpProperties> m_pProperties;
212 IFWL_WidgetDelegate* m_pCurDelegate; // Not owned.
213 IFWL_Widget* m_pOuter; 219 IFWL_Widget* m_pOuter;
214 void* m_pLayoutItem; 220 void* m_pLayoutItem;
215 CFWL_Widget* m_pAssociate; 221 CFWL_Widget* m_pAssociate;
216 int32_t m_iLock; 222 int32_t m_iLock;
217 uint32_t m_nEventKey; 223 uint32_t m_nEventKey;
218 224
219 private: 225 private:
220 std::unique_ptr<IFWL_WidgetDelegate> m_pDelegate; 226 IFWL_WidgetDelegate* m_pDelegate; // Not owned.
221 };
222
223 class CFWL_WidgetImpDelegate : public IFWL_WidgetDelegate {
224 public:
225 CFWL_WidgetImpDelegate();
226 ~CFWL_WidgetImpDelegate() override {}
227 void OnProcessMessage(CFWL_Message* pMessage) override;
228 void OnProcessEvent(CFWL_Event* pEvent) override;
229 void OnDrawWidget(CFX_Graphics* pGraphics,
230 const CFX_Matrix* pMatrix = nullptr) override;
231 }; 227 };
232 228
233 #endif // XFA_FWL_CORE_IFWL_WIDGET_H_ 229 #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