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_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 Loading... | |
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 Loading... | |
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() { |
dsinclair
2016/11/02 17:51:05
This isn't const because I return |this|. I can ma
Tom Sepez
2016/11/02 21:03:29
Actually, you may want to have an overload: e.g.
I
dsinclair
2016/11/02 21:11:14
Done.
| |
117 return m_pDelegate ? m_pDelegate : this; | |
118 } | |
119 | |
120 // IFWL_WidgetDelegate. | |
121 void OnProcessMessage(CFWL_Message* pMessage) override; | |
122 void OnProcessEvent(CFWL_Event* pEvent) override; | |
123 void OnDrawWidget(CFX_Graphics* pGraphics, | |
124 const CFX_Matrix* pMatrix = nullptr) override; | |
117 | 125 |
118 const IFWL_App* GetOwnerApp() const; | 126 const IFWL_App* GetOwnerApp() const; |
119 | 127 |
120 CFX_SizeF GetOffsetFromParent(IFWL_Widget* pParent); | 128 CFX_SizeF GetOffsetFromParent(IFWL_Widget* pParent); |
121 | 129 |
122 uint32_t GetEventKey() const; | 130 uint32_t GetEventKey() const; |
123 void SetEventKey(uint32_t key); | 131 void SetEventKey(uint32_t key); |
124 | 132 |
125 void* GetLayoutItem() const; | 133 void* GetLayoutItem() const; |
126 void SetLayoutItem(void* pItem); | 134 void SetLayoutItem(void* pItem); |
127 | 135 |
128 void SetAssociateWidget(CFWL_Widget* pAssociate); | 136 void SetAssociateWidget(CFWL_Widget* pAssociate); |
129 | 137 |
138 void SetFocus(FX_BOOL bFocus); | |
139 void Repaint(const CFX_RectF* pRect = nullptr); | |
140 | |
130 protected: | 141 protected: |
131 friend class CFWL_WidgetImpDelegate; | 142 friend class CFWL_WidgetImpDelegate; |
132 | 143 |
133 IFWL_Widget(const IFWL_App* app, | 144 IFWL_Widget(const IFWL_App* app, |
134 const CFWL_WidgetImpProperties& properties, | 145 const CFWL_WidgetImpProperties& properties, |
135 IFWL_Widget* pOuter); | 146 IFWL_Widget* pOuter); |
136 | 147 |
137 FX_BOOL IsEnabled() const; | 148 FX_BOOL IsEnabled() const; |
138 FX_BOOL IsVisible() const; | 149 FX_BOOL IsVisible() const; |
139 FX_BOOL IsActive() const; | 150 FX_BOOL IsActive() const; |
(...skipping 13 matching lines...) Expand all Loading... | |
153 IFWL_Widget* GetRootOuter(); | 164 IFWL_Widget* GetRootOuter(); |
154 CFX_SizeF CalcTextSize(const CFX_WideString& wsText, | 165 CFX_SizeF CalcTextSize(const CFX_WideString& wsText, |
155 IFWL_ThemeProvider* pTheme, | 166 IFWL_ThemeProvider* pTheme, |
156 FX_BOOL bMultiLine = FALSE, | 167 FX_BOOL bMultiLine = FALSE, |
157 int32_t iLineWidth = -1); | 168 int32_t iLineWidth = -1); |
158 void CalcTextRect(const CFX_WideString& wsText, | 169 void CalcTextRect(const CFX_WideString& wsText, |
159 IFWL_ThemeProvider* pTheme, | 170 IFWL_ThemeProvider* pTheme, |
160 uint32_t dwTTOStyles, | 171 uint32_t dwTTOStyles, |
161 int32_t iTTOAlign, | 172 int32_t iTTOAlign, |
162 CFX_RectF& rect); | 173 CFX_RectF& rect); |
163 void SetFocus(FX_BOOL bFocus); | |
164 void SetGrab(FX_BOOL bSet); | 174 void SetGrab(FX_BOOL bSet); |
165 FX_BOOL GetPopupPos(FX_FLOAT fMinHeight, | 175 FX_BOOL GetPopupPos(FX_FLOAT fMinHeight, |
166 FX_FLOAT fMaxHeight, | 176 FX_FLOAT fMaxHeight, |
167 const CFX_RectF& rtAnchor, | 177 const CFX_RectF& rtAnchor, |
168 CFX_RectF& rtPopup); | 178 CFX_RectF& rtPopup); |
169 FX_BOOL GetPopupPosMenu(FX_FLOAT fMinHeight, | 179 FX_BOOL GetPopupPosMenu(FX_FLOAT fMinHeight, |
170 FX_FLOAT fMaxHeight, | 180 FX_FLOAT fMaxHeight, |
171 const CFX_RectF& rtAnchor, | 181 const CFX_RectF& rtAnchor, |
172 CFX_RectF& rtPopup); | 182 CFX_RectF& rtPopup); |
173 FX_BOOL GetPopupPosComboBox(FX_FLOAT fMinHeight, | 183 FX_BOOL GetPopupPosComboBox(FX_FLOAT fMinHeight, |
174 FX_FLOAT fMaxHeight, | 184 FX_FLOAT fMaxHeight, |
175 const CFX_RectF& rtAnchor, | 185 const CFX_RectF& rtAnchor, |
176 CFX_RectF& rtPopup); | 186 CFX_RectF& rtPopup); |
177 FX_BOOL GetPopupPosGeneral(FX_FLOAT fMinHeight, | 187 FX_BOOL GetPopupPosGeneral(FX_FLOAT fMinHeight, |
178 FX_FLOAT fMaxHeight, | 188 FX_FLOAT fMaxHeight, |
179 const CFX_RectF& rtAnchor, | 189 const CFX_RectF& rtAnchor, |
180 CFX_RectF& rtPopup); | 190 CFX_RectF& rtPopup); |
181 FX_BOOL GetScreenSize(FX_FLOAT& fx, FX_FLOAT& fy); | 191 FX_BOOL GetScreenSize(FX_FLOAT& fx, FX_FLOAT& fy); |
182 void RegisterEventTarget(IFWL_Widget* pEventSource = nullptr, | 192 void RegisterEventTarget(IFWL_Widget* pEventSource = nullptr, |
183 uint32_t dwFilter = FWL_EVENT_ALL_MASK); | 193 uint32_t dwFilter = FWL_EVENT_ALL_MASK); |
184 void UnregisterEventTarget(); | 194 void UnregisterEventTarget(); |
185 void DispatchKeyEvent(CFWL_MsgKey* pNote); | 195 void DispatchKeyEvent(CFWL_MsgKey* pNote); |
186 void DispatchEvent(CFWL_Event* pEvent); | 196 void DispatchEvent(CFWL_Event* pEvent); |
187 void Repaint(const CFX_RectF* pRect = nullptr); | |
188 void DrawBackground(CFX_Graphics* pGraphics, | 197 void DrawBackground(CFX_Graphics* pGraphics, |
189 CFWL_Part iPartBk, | 198 CFWL_Part iPartBk, |
190 IFWL_ThemeProvider* pTheme, | 199 IFWL_ThemeProvider* pTheme, |
191 const CFX_Matrix* pMatrix = nullptr); | 200 const CFX_Matrix* pMatrix = nullptr); |
192 void DrawBorder(CFX_Graphics* pGraphics, | 201 void DrawBorder(CFX_Graphics* pGraphics, |
193 CFWL_Part iPartBorder, | 202 CFWL_Part iPartBorder, |
194 IFWL_ThemeProvider* pTheme, | 203 IFWL_ThemeProvider* pTheme, |
195 const CFX_Matrix* pMatrix = nullptr); | 204 const CFX_Matrix* pMatrix = nullptr); |
196 void DrawEdge(CFX_Graphics* pGraphics, | 205 void DrawEdge(CFX_Graphics* pGraphics, |
197 CFWL_Part iPartEdge, | 206 CFWL_Part iPartEdge, |
198 IFWL_ThemeProvider* pTheme, | 207 IFWL_ThemeProvider* pTheme, |
199 const CFX_Matrix* pMatrix = nullptr); | 208 const CFX_Matrix* pMatrix = nullptr); |
200 void NotifyDriver(); | 209 void NotifyDriver(); |
201 | 210 |
202 FX_BOOL IsParent(IFWL_Widget* pParent); | 211 FX_BOOL IsParent(IFWL_Widget* pParent); |
203 | 212 |
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; | 213 const IFWL_App* const m_pOwnerApp; |
210 CFWL_WidgetMgr* const m_pWidgetMgr; | 214 CFWL_WidgetMgr* const m_pWidgetMgr; |
211 std::unique_ptr<CFWL_WidgetImpProperties> m_pProperties; | 215 std::unique_ptr<CFWL_WidgetImpProperties> m_pProperties; |
212 IFWL_WidgetDelegate* m_pCurDelegate; // Not owned. | |
213 IFWL_Widget* m_pOuter; | 216 IFWL_Widget* m_pOuter; |
214 void* m_pLayoutItem; | 217 void* m_pLayoutItem; |
215 CFWL_Widget* m_pAssociate; | 218 CFWL_Widget* m_pAssociate; |
216 int32_t m_iLock; | 219 int32_t m_iLock; |
217 uint32_t m_nEventKey; | 220 uint32_t m_nEventKey; |
218 | 221 |
219 private: | 222 private: |
220 std::unique_ptr<IFWL_WidgetDelegate> m_pDelegate; | 223 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 }; | 224 }; |
232 | 225 |
233 #endif // XFA_FWL_CORE_IFWL_WIDGET_H_ | 226 #endif // XFA_FWL_CORE_IFWL_WIDGET_H_ |
OLD | NEW |