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

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

Issue 2524173002: Merge IFWL and CFWL classes. (Closed)
Patch Set: make chrome build happy 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
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_CFWL_WIDGET_H_ 7 #ifndef XFA_FWL_CORE_CFWL_WIDGET_H_
8 #define XFA_FWL_CORE_CFWL_WIDGET_H_ 8 #define XFA_FWL_CORE_CFWL_WIDGET_H_
9
10 #include <memory> 9 #include <memory>
11 10
11 #include "core/fxcrt/fx_coordinates.h"
12 #include "core/fxcrt/fx_system.h"
12 #include "xfa/fwl/core/cfwl_event.h" 13 #include "xfa/fwl/core/cfwl_event.h"
13 #include "xfa/fwl/core/ifwl_widget.h" 14 #include "xfa/fwl/core/cfwl_themepart.h"
15 #include "xfa/fwl/core/cfwl_widgetmgr.h"
16 #include "xfa/fwl/core/fwl_widgethit.h"
17 #include "xfa/fwl/core/ifwl_widgetdelegate.h"
18 #include "xfa/fwl/theme/cfwl_widgettp.h"
14 19
15 class CFWL_Event; 20 enum class FWL_Type {
16 class CFWL_Message; 21 Unknown = 0,
22
23 Barcode,
24 Caret,
25 CheckBox,
26 ComboBox,
27 DateTimePicker,
28 Edit,
29 Form,
30 FormProxy,
31 ListBox,
32 MonthCalendar,
33 PictureBox,
34 PushButton,
35 ScrollBar,
36 SpinButton,
37 ToolTip
38 };
39
40 class CFWL_App;
41 class CFWL_AppImp;
42 class CFWL_MsgKey;
17 class CFWL_Widget; 43 class CFWL_Widget;
18 class CFWL_WidgetDelegate;
19 class CFWL_WidgetMgr; 44 class CFWL_WidgetMgr;
45 class CFWL_WidgetProperties;
46 class IFWL_ThemeProvider;
20 47
21 class CFWL_Widget { 48 class CFWL_Widget : public IFWL_WidgetDelegate {
22 public: 49 public:
23 explicit CFWL_Widget(const CFWL_App*); 50 ~CFWL_Widget() override;
24 virtual ~CFWL_Widget();
25 51
26 IFWL_Widget* GetWidget() { return m_pIface.get(); } 52 virtual FWL_Type GetClassID() const = 0;
27 IFWL_Widget* GetWidget() const { return m_pIface.get(); } 53 virtual bool IsInstance(const CFX_WideStringC& wsClass) const;
54 virtual void GetWidgetRect(CFX_RectF& rect, bool bAutoSize = false);
55 virtual void GetClientRect(CFX_RectF& rect);
56 virtual void ModifyStylesEx(uint32_t dwStylesExAdded,
57 uint32_t dwStylesExRemoved);
58 virtual void SetStates(uint32_t dwStates, bool bSet = true);
59 virtual void Update() = 0;
60 virtual FWL_WidgetHit HitTest(FX_FLOAT fx, FX_FLOAT fy);
61 virtual void DrawWidget(CFX_Graphics* pGraphics,
62 const CFX_Matrix* pMatrix = nullptr) = 0;
63 virtual void SetThemeProvider(IFWL_ThemeProvider* pThemeProvider);
28 64
29 void GetWidgetRect(CFX_RectF& rect, bool bAutoSize = false); 65 // IFWL_WidgetDelegate.
66 void OnProcessMessage(CFWL_Message* pMessage) override;
67 void OnProcessEvent(CFWL_Event* pEvent) override;
68 void OnDrawWidget(CFX_Graphics* pGraphics,
69 const CFX_Matrix* pMatrix = nullptr) override;
70
30 void SetWidgetRect(const CFX_RectF& rect); 71 void SetWidgetRect(const CFX_RectF& rect);
31 72
73 void SetParent(CFWL_Widget* pParent);
74
75 CFWL_Widget* GetOwner() { return m_pWidgetMgr->GetOwnerWidget(this); }
76 CFWL_Widget* GetOuter() const { return m_pOuter; }
77
78 uint32_t GetStyles() const;
32 void ModifyStyles(uint32_t dwStylesAdded, uint32_t dwStylesRemoved); 79 void ModifyStyles(uint32_t dwStylesAdded, uint32_t dwStylesRemoved);
33 uint32_t GetStylesEx(); 80 uint32_t GetStylesEx() const;
34 void ModifyStylesEx(uint32_t dwStylesExAdded, uint32_t dwStylesExRemoved); 81 uint32_t GetStates() const;
35 82
36 uint32_t GetStates(); 83 void LockUpdate() { m_iLock++; }
37 void SetStates(uint32_t dwStates, bool bSet = true); 84 void UnlockUpdate() {
38 void SetLayoutItem(void* pItem); 85 if (IsLocked())
86 m_iLock--;
87 }
39 88
40 void Update(); 89 void TransformTo(CFWL_Widget* pWidget, FX_FLOAT& fx, FX_FLOAT& fy);
41 void LockUpdate(); 90 void GetMatrix(CFX_Matrix& matrix, bool bGlobal = false);
42 void UnlockUpdate(); 91 IFWL_ThemeProvider* GetThemeProvider() const;
43 92
44 FWL_WidgetHit HitTest(FX_FLOAT fx, FX_FLOAT fy); 93 void SetDelegate(IFWL_WidgetDelegate* delegate) { m_pDelegate = delegate; }
45 void DrawWidget(CFX_Graphics* pGraphics, const CFX_Matrix* pMatrix = nullptr); 94 IFWL_WidgetDelegate* GetDelegate() {
95 return m_pDelegate ? m_pDelegate : this;
96 }
97 const IFWL_WidgetDelegate* GetDelegate() const {
98 return m_pDelegate ? m_pDelegate : this;
99 }
46 100
47 IFWL_WidgetDelegate* GetDelegate() const; 101 const CFWL_App* GetOwnerApp() const { return m_pOwnerApp; }
48 void SetDelegate(IFWL_WidgetDelegate*); 102 uint32_t GetEventKey() const { return m_nEventKey; }
103 void SetEventKey(uint32_t key) { m_nEventKey = key; }
104
105 void* GetLayoutItem() const { return m_pLayoutItem; }
106 void SetLayoutItem(void* pItem) { m_pLayoutItem = pItem; }
107
108 void SetFocus(bool bFocus);
109 void Repaint(const CFX_RectF* pRect = nullptr);
49 110
50 protected: 111 protected:
51 void Initialize(); 112 CFWL_Widget(const CFWL_App* app,
113 std::unique_ptr<CFWL_WidgetProperties> properties,
114 CFWL_Widget* pOuter);
52 115
53 const CFWL_App* m_pApp; 116 bool IsEnabled() const;
54 std::unique_ptr<IFWL_Widget> m_pIface; 117 bool IsActive() const;
118 bool IsLocked() const { return m_iLock > 0; }
119 bool HasBorder() const;
120 bool HasEdge() const;
121 void GetEdgeRect(CFX_RectF& rtEdge);
122 FX_FLOAT GetBorderSize(bool bCX = true);
123 FX_FLOAT GetEdgeWidth();
124 void GetRelativeRect(CFX_RectF& rect);
125 void* GetThemeCapacity(CFWL_WidgetCapacity dwCapacity);
126 IFWL_ThemeProvider* GetAvailableTheme();
127 CFX_SizeF CalcTextSize(const CFX_WideString& wsText,
128 IFWL_ThemeProvider* pTheme,
129 bool bMultiLine = false,
130 int32_t iLineWidth = -1);
131 void CalcTextRect(const CFX_WideString& wsText,
132 IFWL_ThemeProvider* pTheme,
133 uint32_t dwTTOStyles,
134 int32_t iTTOAlign,
135 CFX_RectF& rect);
136 void SetGrab(bool bSet);
137 void GetPopupPos(FX_FLOAT fMinHeight,
138 FX_FLOAT fMaxHeight,
139 const CFX_RectF& rtAnchor,
140 CFX_RectF& rtPopup);
141 void RegisterEventTarget(CFWL_Widget* pEventSource);
142 void UnregisterEventTarget();
143 void DispatchKeyEvent(CFWL_MsgKey* pNote);
144 void DispatchEvent(CFWL_Event* pEvent);
145 void DrawBorder(CFX_Graphics* pGraphics,
146 CFWL_Part iPartBorder,
147 IFWL_ThemeProvider* pTheme,
148 const CFX_Matrix* pMatrix = nullptr);
149 void DrawEdge(CFX_Graphics* pGraphics,
150 CFWL_Part iPartEdge,
151 IFWL_ThemeProvider* pTheme,
152 const CFX_Matrix* pMatrix = nullptr);
153
154 const CFWL_App* const m_pOwnerApp;
155 CFWL_WidgetMgr* const m_pWidgetMgr;
156 std::unique_ptr<CFWL_WidgetProperties> m_pProperties;
157 CFWL_Widget* m_pOuter;
158 int32_t m_iLock;
159
160 private:
161 CFWL_Widget* GetParent() { return m_pWidgetMgr->GetParentWidget(this); }
162 CFX_SizeF GetOffsetFromParent(CFWL_Widget* pParent);
163
164 bool IsVisible() const;
165 bool IsOverLapper() const;
166 bool IsPopup() const;
167 bool IsChild() const;
168 bool IsOffscreen() const;
169 CFWL_Widget* GetRootOuter();
170 bool GetPopupPosMenu(FX_FLOAT fMinHeight,
171 FX_FLOAT fMaxHeight,
172 const CFX_RectF& rtAnchor,
173 CFX_RectF& rtPopup);
174 bool GetPopupPosComboBox(FX_FLOAT fMinHeight,
175 FX_FLOAT fMaxHeight,
176 const CFX_RectF& rtAnchor,
177 CFX_RectF& rtPopup);
178 bool GetPopupPosGeneral(FX_FLOAT fMinHeight,
179 FX_FLOAT fMaxHeight,
180 const CFX_RectF& rtAnchor,
181 CFX_RectF& rtPopup);
182 bool GetScreenSize(FX_FLOAT& fx, FX_FLOAT& fy);
183 void DrawBackground(CFX_Graphics* pGraphics,
184 CFWL_Part iPartBk,
185 IFWL_ThemeProvider* pTheme,
186 const CFX_Matrix* pMatrix = nullptr);
187 void NotifyDriver();
188 bool IsParent(CFWL_Widget* pParent);
189
190 void* m_pLayoutItem;
191 uint32_t m_nEventKey;
192 IFWL_WidgetDelegate* m_pDelegate; // Not owned.
55 }; 193 };
56 194
57 #endif // XFA_FWL_CORE_CFWL_WIDGET_H_ 195 #endif // XFA_FWL_CORE_CFWL_WIDGET_H_
OLDNEW

Powered by Google App Engine
This is Rietveld 408576698