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 #include "xfa/fwl/core/fwl_widgetimp.h" | 7 #include "xfa/fwl/core/ifwl_widget.h" |
8 | 8 |
9 #include <algorithm> | 9 #include <algorithm> |
10 | 10 |
11 #include "xfa/fde/tto/fde_textout.h" | 11 #include "xfa/fde/tto/fde_textout.h" |
12 #include "xfa/fwl/basewidget/ifwl_combobox.h" | |
13 #include "xfa/fwl/core/cfwl_message.h" | 12 #include "xfa/fwl/core/cfwl_message.h" |
14 #include "xfa/fwl/core/cfwl_themebackground.h" | 13 #include "xfa/fwl/core/cfwl_themebackground.h" |
15 #include "xfa/fwl/core/cfwl_themepart.h" | 14 #include "xfa/fwl/core/cfwl_themepart.h" |
16 #include "xfa/fwl/core/cfwl_themetext.h" | 15 #include "xfa/fwl/core/cfwl_themetext.h" |
17 #include "xfa/fwl/core/cfwl_widgetmgr.h" | 16 #include "xfa/fwl/core/cfwl_widgetmgr.h" |
18 #include "xfa/fwl/core/fwl_noteimp.h" | 17 #include "xfa/fwl/core/fwl_noteimp.h" |
19 #include "xfa/fwl/core/ifwl_app.h" | 18 #include "xfa/fwl/core/ifwl_app.h" |
| 19 #include "xfa/fwl/core/ifwl_combobox.h" |
20 #include "xfa/fwl/core/ifwl_form.h" | 20 #include "xfa/fwl/core/ifwl_form.h" |
21 #include "xfa/fwl/core/ifwl_themeprovider.h" | 21 #include "xfa/fwl/core/ifwl_themeprovider.h" |
22 #include "xfa/fwl/core/ifwl_widget.h" | 22 #include "xfa/fwl/core/ifwl_widget.h" |
23 #include "xfa/fxfa/xfa_ffapp.h" | 23 #include "xfa/fxfa/xfa_ffapp.h" |
24 | 24 |
25 #define FWL_STYLEEXT_MNU_Vert (1L << 0) | 25 #define FWL_STYLEEXT_MNU_Vert (1L << 0) |
26 | 26 |
27 IFWL_Widget::IFWL_Widget() {} | |
28 | |
29 IFWL_Widget::~IFWL_Widget() {} | |
30 | |
31 FWL_Error IFWL_Widget::GetClassName(CFX_WideString& wsClass) const { | |
32 return m_pImpl->GetClassName(wsClass); | |
33 } | |
34 | |
35 FWL_Type IFWL_Widget::GetClassID() const { | |
36 return m_pImpl->GetClassID(); | |
37 } | |
38 | |
39 FX_BOOL IFWL_Widget::IsInstance(const CFX_WideStringC& wsClass) const { | |
40 return m_pImpl->IsInstance(wsClass); | |
41 } | |
42 | |
43 FWL_Error IFWL_Widget::Initialize() { | 27 FWL_Error IFWL_Widget::Initialize() { |
44 return m_pImpl->Initialize(); | |
45 } | |
46 | |
47 FWL_Error IFWL_Widget::Finalize() { | |
48 return m_pImpl->Finalize(); | |
49 } | |
50 | |
51 FWL_Error IFWL_Widget::GetWidgetRect(CFX_RectF& rect, FX_BOOL bAutoSize) { | |
52 return GetImpl()->GetWidgetRect(rect, bAutoSize); | |
53 } | |
54 FWL_Error IFWL_Widget::GetGlobalRect(CFX_RectF& rect) { | |
55 return GetImpl()->GetGlobalRect(rect); | |
56 } | |
57 FWL_Error IFWL_Widget::SetWidgetRect(const CFX_RectF& rect) { | |
58 return GetImpl()->SetWidgetRect(rect); | |
59 } | |
60 FWL_Error IFWL_Widget::GetClientRect(CFX_RectF& rect) { | |
61 return GetImpl()->GetClientRect(rect); | |
62 } | |
63 IFWL_Widget* IFWL_Widget::GetParent() { | |
64 return GetImpl()->GetParent(); | |
65 } | |
66 FWL_Error IFWL_Widget::SetParent(IFWL_Widget* pParent) { | |
67 return GetImpl()->SetParent(pParent); | |
68 } | |
69 IFWL_Widget* IFWL_Widget::GetOwner() { | |
70 return GetImpl()->GetOwner(); | |
71 } | |
72 FWL_Error IFWL_Widget::SetOwner(IFWL_Widget* pOwner) { | |
73 return GetImpl()->SetOwner(pOwner); | |
74 } | |
75 IFWL_Widget* IFWL_Widget::GetOuter() { | |
76 return GetImpl()->GetOuter(); | |
77 } | |
78 uint32_t IFWL_Widget::GetStyles() { | |
79 return GetImpl()->GetStyles(); | |
80 } | |
81 FWL_Error IFWL_Widget::ModifyStyles(uint32_t dwStylesAdded, | |
82 uint32_t dwStylesRemoved) { | |
83 return GetImpl()->ModifyStyles(dwStylesAdded, dwStylesRemoved); | |
84 } | |
85 uint32_t IFWL_Widget::GetStylesEx() { | |
86 return GetImpl()->GetStylesEx(); | |
87 } | |
88 FWL_Error IFWL_Widget::ModifyStylesEx(uint32_t dwStylesExAdded, | |
89 uint32_t dwStylesExRemoved) { | |
90 return GetImpl()->ModifyStylesEx(dwStylesExAdded, dwStylesExRemoved); | |
91 } | |
92 uint32_t IFWL_Widget::GetStates() { | |
93 return GetImpl()->GetStates(); | |
94 } | |
95 void IFWL_Widget::SetStates(uint32_t dwStates, FX_BOOL bSet) { | |
96 GetImpl()->SetStates(dwStates, bSet); | |
97 } | |
98 | |
99 uint32_t IFWL_Widget::GetEventKey() const { | |
100 return GetImpl()->GetEventKey(); | |
101 } | |
102 | |
103 void IFWL_Widget::SetEventKey(uint32_t key) { | |
104 GetImpl()->SetEventKey(key); | |
105 } | |
106 | |
107 void* IFWL_Widget::GetLayoutItem() const { | |
108 return GetImpl()->GetLayoutItem(); | |
109 } | |
110 | |
111 void IFWL_Widget::SetLayoutItem(void* pItem) { | |
112 GetImpl()->SetLayoutItem(pItem); | |
113 } | |
114 | |
115 void* IFWL_Widget::GetAssociateWidget() const { | |
116 return GetImpl()->GetAssociateWidget(); | |
117 } | |
118 | |
119 void IFWL_Widget::SetAssociateWidget(void* pAssociate) { | |
120 GetImpl()->SetAssociateWidget(pAssociate); | |
121 } | |
122 | |
123 FWL_Error IFWL_Widget::Update() { | |
124 return GetImpl()->Update(); | |
125 } | |
126 FWL_Error IFWL_Widget::LockUpdate() { | |
127 return GetImpl()->LockUpdate(); | |
128 } | |
129 FWL_Error IFWL_Widget::UnlockUpdate() { | |
130 return GetImpl()->UnlockUpdate(); | |
131 } | |
132 FWL_WidgetHit IFWL_Widget::HitTest(FX_FLOAT fx, FX_FLOAT fy) { | |
133 return GetImpl()->HitTest(fx, fy); | |
134 } | |
135 FWL_Error IFWL_Widget::TransformTo(IFWL_Widget* pWidget, | |
136 FX_FLOAT& fx, | |
137 FX_FLOAT& fy) { | |
138 return GetImpl()->TransformTo(pWidget, fx, fy); | |
139 } | |
140 FWL_Error IFWL_Widget::TransformTo(IFWL_Widget* pWidget, CFX_RectF& rt) { | |
141 return GetImpl()->TransformTo(pWidget, rt); | |
142 } | |
143 FWL_Error IFWL_Widget::GetMatrix(CFX_Matrix& matrix, FX_BOOL bGlobal) { | |
144 return GetImpl()->GetMatrix(matrix, bGlobal); | |
145 } | |
146 FWL_Error IFWL_Widget::SetMatrix(const CFX_Matrix& matrix) { | |
147 return GetImpl()->SetMatrix(matrix); | |
148 } | |
149 FWL_Error IFWL_Widget::DrawWidget(CFX_Graphics* pGraphics, | |
150 const CFX_Matrix* pMatrix) { | |
151 return GetImpl()->DrawWidget(pGraphics, pMatrix); | |
152 } | |
153 IFWL_ThemeProvider* IFWL_Widget::GetThemeProvider() { | |
154 return GetImpl()->GetThemeProvider(); | |
155 } | |
156 FWL_Error IFWL_Widget::SetThemeProvider(IFWL_ThemeProvider* pThemeProvider) { | |
157 return GetImpl()->SetThemeProvider(pThemeProvider); | |
158 } | |
159 IFWL_WidgetDelegate* IFWL_Widget::SetDelegate(IFWL_WidgetDelegate* pDelegate) { | |
160 return GetImpl()->SetDelegate(pDelegate); | |
161 } | |
162 IFWL_App* IFWL_Widget::GetOwnerApp() const { | |
163 return GetImpl()->GetOwnerApp(); | |
164 } | |
165 CFX_SizeF IFWL_Widget::GetOffsetFromParent(IFWL_Widget* pParent) { | |
166 return GetImpl()->GetOffsetFromParent(pParent); | |
167 } | |
168 | |
169 FWL_Error CFWL_WidgetImp::Initialize() { | |
170 IFWL_App* pApp = FWL_GetApp(); | 28 IFWL_App* pApp = FWL_GetApp(); |
171 if (!pApp) | 29 if (!pApp) |
172 return FWL_Error::Indefinite; | 30 return FWL_Error::Indefinite; |
173 | 31 |
174 CXFA_FFApp* pAdapter = pApp->GetAdapterNative(); | 32 CXFA_FFApp* pAdapter = pApp->GetAdapterNative(); |
175 if (!pAdapter) | 33 if (!pAdapter) |
176 return FWL_Error::Indefinite; | 34 return FWL_Error::Indefinite; |
177 | 35 |
178 SetOwnerApp(FWL_GetApp()); | 36 SetOwnerApp(FWL_GetApp()); |
179 | 37 |
180 IFWL_Widget* pParent = m_pProperties->m_pParent; | 38 IFWL_Widget* pParent = m_pProperties->m_pParent; |
181 m_pWidgetMgr->InsertWidget(pParent, m_pInterface); | 39 m_pWidgetMgr->InsertWidget(pParent, this); |
182 if (!IsChild()) { | 40 if (!IsChild()) { |
183 IFWL_Widget* pOwner = m_pProperties->m_pOwner; | 41 IFWL_Widget* pOwner = m_pProperties->m_pOwner; |
184 if (pOwner) | 42 if (pOwner) |
185 m_pWidgetMgr->SetOwner(pOwner, m_pInterface); | 43 m_pWidgetMgr->SetOwner(pOwner, this); |
186 } | 44 } |
187 return FWL_Error::Succeeded; | 45 return FWL_Error::Succeeded; |
188 } | 46 } |
189 | 47 |
190 FWL_Error CFWL_WidgetImp::Finalize() { | 48 FWL_Error IFWL_Widget::Finalize() { |
191 NotifyDriver(); | 49 NotifyDriver(); |
192 m_pWidgetMgr->RemoveWidget(m_pInterface); | 50 m_pWidgetMgr->RemoveWidget(this); |
193 return FWL_Error::Succeeded; | 51 return FWL_Error::Succeeded; |
194 } | 52 } |
195 | 53 |
196 FWL_Error CFWL_WidgetImp::GetClassName(CFX_WideString& wsClass) const { | 54 FWL_Error IFWL_Widget::GetClassName(CFX_WideString& wsClass) const { |
197 wsClass.clear(); | 55 wsClass.clear(); |
198 return FWL_Error::Succeeded; | 56 return FWL_Error::Succeeded; |
199 } | 57 } |
200 | 58 |
201 FX_BOOL CFWL_WidgetImp::IsInstance(const CFX_WideStringC& wsClass) const { | 59 FX_BOOL IFWL_Widget::IsInstance(const CFX_WideStringC& wsClass) const { |
202 return FALSE; | 60 return FALSE; |
203 } | 61 } |
204 | 62 |
205 FWL_Error CFWL_WidgetImp::GetWidgetRect(CFX_RectF& rect, FX_BOOL bAutoSize) { | 63 FWL_Error IFWL_Widget::GetWidgetRect(CFX_RectF& rect, FX_BOOL bAutoSize) { |
206 if (bAutoSize) { | 64 if (bAutoSize) { |
207 if (HasEdge()) { | 65 if (HasEdge()) { |
208 FX_FLOAT fEdge = GetEdgeWidth(); | 66 FX_FLOAT fEdge = GetEdgeWidth(); |
209 rect.Inflate(fEdge, fEdge); | 67 rect.Inflate(fEdge, fEdge); |
210 } | 68 } |
211 if (HasBorder()) { | 69 if (HasBorder()) { |
212 FX_FLOAT fBorder = GetBorderSize(); | 70 FX_FLOAT fBorder = GetBorderSize(); |
213 rect.Inflate(fBorder, fBorder); | 71 rect.Inflate(fBorder, fBorder); |
214 } | 72 } |
215 } else { | 73 } else { |
216 rect = m_pProperties->m_rtWidget; | 74 rect = m_pProperties->m_rtWidget; |
217 } | 75 } |
218 return FWL_Error::Succeeded; | 76 return FWL_Error::Succeeded; |
219 } | 77 } |
220 | 78 |
221 FWL_Error CFWL_WidgetImp::GetGlobalRect(CFX_RectF& rect) { | 79 FWL_Error IFWL_Widget::GetGlobalRect(CFX_RectF& rect) { |
222 IFWL_Widget* pForm = m_pWidgetMgr->GetSystemFormWidget(m_pInterface); | 80 IFWL_Widget* pForm = m_pWidgetMgr->GetSystemFormWidget(this); |
223 if (!pForm) | 81 if (!pForm) |
224 return FWL_Error::Indefinite; | 82 return FWL_Error::Indefinite; |
225 | 83 |
226 rect.Set(0, 0, m_pProperties->m_rtWidget.width, | 84 rect.Set(0, 0, m_pProperties->m_rtWidget.width, |
227 m_pProperties->m_rtWidget.height); | 85 m_pProperties->m_rtWidget.height); |
228 if (pForm == m_pInterface) | 86 if (pForm == this) |
229 return FWL_Error::Succeeded; | 87 return FWL_Error::Succeeded; |
230 | 88 |
231 return TransformTo(pForm, rect); | 89 return TransformTo(pForm, rect); |
232 } | 90 } |
233 | 91 |
234 FWL_Error CFWL_WidgetImp::SetWidgetRect(const CFX_RectF& rect) { | 92 FWL_Error IFWL_Widget::SetWidgetRect(const CFX_RectF& rect) { |
235 CFX_RectF rtOld = m_pProperties->m_rtWidget; | 93 CFX_RectF rtOld = m_pProperties->m_rtWidget; |
236 m_pProperties->m_rtWidget = rect; | 94 m_pProperties->m_rtWidget = rect; |
237 if (IsChild()) { | 95 if (IsChild()) { |
238 if (FXSYS_fabs(rtOld.width - rect.width) > 0.5f || | 96 if (FXSYS_fabs(rtOld.width - rect.width) > 0.5f || |
239 FXSYS_fabs(rtOld.height - rect.height) > 0.5f) { | 97 FXSYS_fabs(rtOld.height - rect.height) > 0.5f) { |
240 CFWL_EvtSizeChanged ev; | 98 CFWL_EvtSizeChanged ev; |
241 ev.m_pSrcTarget = m_pInterface; | 99 ev.m_pSrcTarget = this; |
242 ev.m_rtOld = rtOld; | 100 ev.m_rtOld = rtOld; |
243 ev.m_rtNew = rect; | 101 ev.m_rtNew = rect; |
244 IFWL_WidgetDelegate* pDelegate = SetDelegate(nullptr); | 102 IFWL_WidgetDelegate* pDelegate = SetDelegate(nullptr); |
245 if (pDelegate) { | 103 if (pDelegate) { |
246 pDelegate->OnProcessEvent(&ev); | 104 pDelegate->OnProcessEvent(&ev); |
247 } | 105 } |
248 } | 106 } |
249 return FWL_Error::Succeeded; | 107 return FWL_Error::Succeeded; |
250 } | 108 } |
251 m_pWidgetMgr->SetWidgetRect_Native(m_pInterface, rect); | 109 m_pWidgetMgr->SetWidgetRect_Native(this, rect); |
252 return FWL_Error::Succeeded; | 110 return FWL_Error::Succeeded; |
253 } | 111 } |
254 FWL_Error CFWL_WidgetImp::GetClientRect(CFX_RectF& rect) { | 112 |
| 113 FWL_Error IFWL_Widget::GetClientRect(CFX_RectF& rect) { |
255 GetEdgeRect(rect); | 114 GetEdgeRect(rect); |
256 if (HasEdge()) { | 115 if (HasEdge()) { |
257 FX_FLOAT fEdge = GetEdgeWidth(); | 116 FX_FLOAT fEdge = GetEdgeWidth(); |
258 rect.Deflate(fEdge, fEdge); | 117 rect.Deflate(fEdge, fEdge); |
259 } | 118 } |
260 return FWL_Error::Succeeded; | 119 return FWL_Error::Succeeded; |
261 } | 120 } |
262 IFWL_Widget* CFWL_WidgetImp::GetParent() { | 121 |
263 return m_pWidgetMgr->GetParentWidget(m_pInterface); | 122 IFWL_Widget* IFWL_Widget::GetParent() { |
| 123 return m_pWidgetMgr->GetParentWidget(this); |
264 } | 124 } |
265 FWL_Error CFWL_WidgetImp::SetParent(IFWL_Widget* pParent) { | 125 |
| 126 FWL_Error IFWL_Widget::SetParent(IFWL_Widget* pParent) { |
266 m_pProperties->m_pParent = pParent; | 127 m_pProperties->m_pParent = pParent; |
267 m_pWidgetMgr->SetParent(pParent, m_pInterface); | 128 m_pWidgetMgr->SetParent(pParent, this); |
268 return FWL_Error::Succeeded; | 129 return FWL_Error::Succeeded; |
269 } | 130 } |
270 IFWL_Widget* CFWL_WidgetImp::GetOwner() { | 131 |
271 return m_pWidgetMgr->GetOwnerWidget(m_pInterface); | 132 IFWL_Widget* IFWL_Widget::GetOwner() { |
| 133 return m_pWidgetMgr->GetOwnerWidget(this); |
272 } | 134 } |
273 FWL_Error CFWL_WidgetImp::SetOwner(IFWL_Widget* pOwner) { | 135 |
| 136 FWL_Error IFWL_Widget::SetOwner(IFWL_Widget* pOwner) { |
274 m_pProperties->m_pOwner = pOwner; | 137 m_pProperties->m_pOwner = pOwner; |
275 m_pWidgetMgr->SetOwner(pOwner, m_pInterface); | 138 m_pWidgetMgr->SetOwner(pOwner, this); |
276 return FWL_Error::Succeeded; | 139 return FWL_Error::Succeeded; |
277 } | 140 } |
278 IFWL_Widget* CFWL_WidgetImp::GetOuter() { | 141 |
| 142 IFWL_Widget* IFWL_Widget::GetOuter() { |
279 return m_pOuter; | 143 return m_pOuter; |
280 } | 144 } |
281 uint32_t CFWL_WidgetImp::GetStyles() { | 145 |
| 146 uint32_t IFWL_Widget::GetStyles() { |
282 return m_pProperties->m_dwStyles; | 147 return m_pProperties->m_dwStyles; |
283 } | 148 } |
284 FWL_Error CFWL_WidgetImp::ModifyStyles(uint32_t dwStylesAdded, | 149 |
285 uint32_t dwStylesRemoved) { | 150 FWL_Error IFWL_Widget::ModifyStyles(uint32_t dwStylesAdded, |
| 151 uint32_t dwStylesRemoved) { |
286 m_pProperties->m_dwStyles = | 152 m_pProperties->m_dwStyles = |
287 (m_pProperties->m_dwStyles & ~dwStylesRemoved) | dwStylesAdded; | 153 (m_pProperties->m_dwStyles & ~dwStylesRemoved) | dwStylesAdded; |
288 return FWL_Error::Succeeded; | 154 return FWL_Error::Succeeded; |
289 } | 155 } |
290 uint32_t CFWL_WidgetImp::GetStylesEx() { | 156 |
| 157 uint32_t IFWL_Widget::GetStylesEx() { |
291 return m_pProperties->m_dwStyleExes; | 158 return m_pProperties->m_dwStyleExes; |
292 } | 159 } |
293 FWL_Error CFWL_WidgetImp::ModifyStylesEx(uint32_t dwStylesExAdded, | 160 |
294 uint32_t dwStylesExRemoved) { | 161 FWL_Error IFWL_Widget::ModifyStylesEx(uint32_t dwStylesExAdded, |
| 162 uint32_t dwStylesExRemoved) { |
295 m_pProperties->m_dwStyleExes = | 163 m_pProperties->m_dwStyleExes = |
296 (m_pProperties->m_dwStyleExes & ~dwStylesExRemoved) | dwStylesExAdded; | 164 (m_pProperties->m_dwStyleExes & ~dwStylesExRemoved) | dwStylesExAdded; |
297 return FWL_Error::Succeeded; | 165 return FWL_Error::Succeeded; |
298 } | 166 } |
299 uint32_t CFWL_WidgetImp::GetStates() { | 167 |
| 168 uint32_t IFWL_Widget::GetStates() { |
300 return m_pProperties->m_dwStates; | 169 return m_pProperties->m_dwStates; |
301 } | 170 } |
| 171 |
302 static void NotifyHideChildWidget(CFWL_WidgetMgr* widgetMgr, | 172 static void NotifyHideChildWidget(CFWL_WidgetMgr* widgetMgr, |
303 IFWL_Widget* widget, | 173 IFWL_Widget* widget, |
304 CFWL_NoteDriver* noteDriver) { | 174 CFWL_NoteDriver* noteDriver) { |
305 IFWL_Widget* child = widgetMgr->GetFirstChildWidget(widget); | 175 IFWL_Widget* child = widgetMgr->GetFirstChildWidget(widget); |
306 while (child) { | 176 while (child) { |
307 noteDriver->NotifyTargetHide(child); | 177 noteDriver->NotifyTargetHide(child); |
308 NotifyHideChildWidget(widgetMgr, child, noteDriver); | 178 NotifyHideChildWidget(widgetMgr, child, noteDriver); |
309 child = widgetMgr->GetNextSiblingWidget(child); | 179 child = widgetMgr->GetNextSiblingWidget(child); |
310 } | 180 } |
311 } | 181 } |
312 | 182 |
313 void CFWL_WidgetImp::SetStates(uint32_t dwStates, FX_BOOL bSet) { | 183 void IFWL_Widget::SetStates(uint32_t dwStates, FX_BOOL bSet) { |
314 bSet ? (m_pProperties->m_dwStates |= dwStates) | 184 bSet ? (m_pProperties->m_dwStates |= dwStates) |
315 : (m_pProperties->m_dwStates &= ~dwStates); | 185 : (m_pProperties->m_dwStates &= ~dwStates); |
316 if (!(dwStates & FWL_WGTSTATE_Invisible) || !bSet) | 186 if (!(dwStates & FWL_WGTSTATE_Invisible) || !bSet) |
317 return; | 187 return; |
318 | 188 |
319 CFWL_NoteDriver* noteDriver = | 189 CFWL_NoteDriver* noteDriver = |
320 static_cast<CFWL_NoteDriver*>(GetOwnerApp()->GetNoteDriver()); | 190 static_cast<CFWL_NoteDriver*>(GetOwnerApp()->GetNoteDriver()); |
321 CFWL_WidgetMgr* widgetMgr = CFWL_WidgetMgr::GetInstance(); | 191 CFWL_WidgetMgr* widgetMgr = CFWL_WidgetMgr::GetInstance(); |
322 noteDriver->NotifyTargetHide(m_pInterface); | 192 noteDriver->NotifyTargetHide(this); |
323 IFWL_Widget* child = widgetMgr->GetFirstChildWidget(m_pInterface); | 193 IFWL_Widget* child = widgetMgr->GetFirstChildWidget(this); |
324 while (child) { | 194 while (child) { |
325 noteDriver->NotifyTargetHide(child); | 195 noteDriver->NotifyTargetHide(child); |
326 NotifyHideChildWidget(widgetMgr, child, noteDriver); | 196 NotifyHideChildWidget(widgetMgr, child, noteDriver); |
327 child = widgetMgr->GetNextSiblingWidget(child); | 197 child = widgetMgr->GetNextSiblingWidget(child); |
328 } | 198 } |
329 return; | 199 return; |
330 } | 200 } |
331 FWL_Error CFWL_WidgetImp::Update() { | 201 |
| 202 FWL_Error IFWL_Widget::Update() { |
332 return FWL_Error::Succeeded; | 203 return FWL_Error::Succeeded; |
333 } | 204 } |
334 FWL_Error CFWL_WidgetImp::LockUpdate() { | 205 |
| 206 FWL_Error IFWL_Widget::LockUpdate() { |
335 m_iLock++; | 207 m_iLock++; |
336 return FWL_Error::Succeeded; | 208 return FWL_Error::Succeeded; |
337 } | 209 } |
338 FWL_Error CFWL_WidgetImp::UnlockUpdate() { | 210 |
| 211 FWL_Error IFWL_Widget::UnlockUpdate() { |
339 if (IsLocked()) { | 212 if (IsLocked()) { |
340 m_iLock--; | 213 m_iLock--; |
341 } | 214 } |
342 return FWL_Error::Succeeded; | 215 return FWL_Error::Succeeded; |
343 } | 216 } |
344 FWL_WidgetHit CFWL_WidgetImp::HitTest(FX_FLOAT fx, FX_FLOAT fy) { | 217 |
| 218 FWL_WidgetHit IFWL_Widget::HitTest(FX_FLOAT fx, FX_FLOAT fy) { |
345 CFX_RectF rtClient; | 219 CFX_RectF rtClient; |
346 GetClientRect(rtClient); | 220 GetClientRect(rtClient); |
347 if (rtClient.Contains(fx, fy)) | 221 if (rtClient.Contains(fx, fy)) |
348 return FWL_WidgetHit::Client; | 222 return FWL_WidgetHit::Client; |
349 if (HasEdge()) { | 223 if (HasEdge()) { |
350 CFX_RectF rtEdge; | 224 CFX_RectF rtEdge; |
351 GetEdgeRect(rtEdge); | 225 GetEdgeRect(rtEdge); |
352 if (rtEdge.Contains(fx, fy)) | 226 if (rtEdge.Contains(fx, fy)) |
353 return FWL_WidgetHit::Edge; | 227 return FWL_WidgetHit::Edge; |
354 } | 228 } |
355 if (HasBorder()) { | 229 if (HasBorder()) { |
356 CFX_RectF rtRelative; | 230 CFX_RectF rtRelative; |
357 GetRelativeRect(rtRelative); | 231 GetRelativeRect(rtRelative); |
358 if (rtRelative.Contains(fx, fy)) | 232 if (rtRelative.Contains(fx, fy)) |
359 return FWL_WidgetHit::Border; | 233 return FWL_WidgetHit::Border; |
360 } | 234 } |
361 return FWL_WidgetHit::Unknown; | 235 return FWL_WidgetHit::Unknown; |
362 } | 236 } |
363 FWL_Error CFWL_WidgetImp::TransformTo(IFWL_Widget* pWidget, | 237 |
364 FX_FLOAT& fx, | 238 FWL_Error IFWL_Widget::TransformTo(IFWL_Widget* pWidget, |
365 FX_FLOAT& fy) { | 239 FX_FLOAT& fx, |
| 240 FX_FLOAT& fy) { |
366 if (m_pWidgetMgr->IsFormDisabled()) { | 241 if (m_pWidgetMgr->IsFormDisabled()) { |
367 CFX_SizeF szOffset; | 242 CFX_SizeF szOffset; |
368 if (IsParent(pWidget)) { | 243 if (IsParent(pWidget)) { |
369 szOffset = GetOffsetFromParent(pWidget); | 244 szOffset = GetOffsetFromParent(pWidget); |
370 } else { | 245 } else { |
371 szOffset = pWidget->GetOffsetFromParent(m_pInterface); | 246 szOffset = pWidget->GetOffsetFromParent(this); |
372 szOffset.x = -szOffset.x; | 247 szOffset.x = -szOffset.x; |
373 szOffset.y = -szOffset.y; | 248 szOffset.y = -szOffset.y; |
374 } | 249 } |
375 fx += szOffset.x; | 250 fx += szOffset.x; |
376 fy += szOffset.y; | 251 fy += szOffset.y; |
377 return FWL_Error::Succeeded; | 252 return FWL_Error::Succeeded; |
378 } | 253 } |
379 CFX_RectF r; | 254 CFX_RectF r; |
380 CFX_Matrix m; | 255 CFX_Matrix m; |
381 IFWL_Widget* parent = GetParent(); | 256 IFWL_Widget* parent = GetParent(); |
382 if (parent) { | 257 if (parent) { |
383 GetWidgetRect(r); | 258 GetWidgetRect(r); |
384 fx += r.left; | 259 fx += r.left; |
385 fy += r.top; | 260 fy += r.top; |
386 GetMatrix(m, TRUE); | 261 GetMatrix(m, TRUE); |
387 m.TransformPoint(fx, fy); | 262 m.TransformPoint(fx, fy); |
388 } | 263 } |
389 IFWL_Widget* form1 = m_pWidgetMgr->GetSystemFormWidget(m_pInterface); | 264 IFWL_Widget* form1 = m_pWidgetMgr->GetSystemFormWidget(this); |
390 if (!form1) | 265 if (!form1) |
391 return FWL_Error::Indefinite; | 266 return FWL_Error::Indefinite; |
392 if (!pWidget) { | 267 if (!pWidget) { |
393 form1->GetWidgetRect(r); | 268 form1->GetWidgetRect(r); |
394 fx += r.left; | 269 fx += r.left; |
395 fy += r.top; | 270 fy += r.top; |
396 return FWL_Error::Succeeded; | 271 return FWL_Error::Succeeded; |
397 } | 272 } |
398 IFWL_Widget* form2 = m_pWidgetMgr->GetSystemFormWidget(pWidget); | 273 IFWL_Widget* form2 = m_pWidgetMgr->GetSystemFormWidget(pWidget); |
399 if (!form2) | 274 if (!form2) |
(...skipping 12 matching lines...) Expand all Loading... |
412 CFX_Matrix m1; | 287 CFX_Matrix m1; |
413 m1.SetIdentity(); | 288 m1.SetIdentity(); |
414 m1.SetReverse(m); | 289 m1.SetReverse(m); |
415 m1.TransformPoint(fx, fy); | 290 m1.TransformPoint(fx, fy); |
416 pWidget->GetWidgetRect(r); | 291 pWidget->GetWidgetRect(r); |
417 fx -= r.left; | 292 fx -= r.left; |
418 fy -= r.top; | 293 fy -= r.top; |
419 } | 294 } |
420 return FWL_Error::Succeeded; | 295 return FWL_Error::Succeeded; |
421 } | 296 } |
422 FWL_Error CFWL_WidgetImp::TransformTo(IFWL_Widget* pWidget, CFX_RectF& rt) { | 297 |
| 298 FWL_Error IFWL_Widget::TransformTo(IFWL_Widget* pWidget, CFX_RectF& rt) { |
423 return TransformTo(pWidget, rt.left, rt.top); | 299 return TransformTo(pWidget, rt.left, rt.top); |
424 } | 300 } |
425 FWL_Error CFWL_WidgetImp::GetMatrix(CFX_Matrix& matrix, FX_BOOL bGlobal) { | 301 |
| 302 FWL_Error IFWL_Widget::GetMatrix(CFX_Matrix& matrix, FX_BOOL bGlobal) { |
426 if (!m_pProperties) | 303 if (!m_pProperties) |
427 return FWL_Error::Indefinite; | 304 return FWL_Error::Indefinite; |
428 if (bGlobal) { | 305 if (bGlobal) { |
429 IFWL_Widget* parent = GetParent(); | 306 IFWL_Widget* parent = GetParent(); |
430 CFX_ArrayTemplate<IFWL_Widget*> parents; | 307 CFX_ArrayTemplate<IFWL_Widget*> parents; |
431 while (parent) { | 308 while (parent) { |
432 parents.Add(parent); | 309 parents.Add(parent); |
433 parent = parent->GetParent(); | 310 parent = parent->GetParent(); |
434 } | 311 } |
435 matrix.SetIdentity(); | 312 matrix.SetIdentity(); |
436 CFX_Matrix ctmOnParent; | 313 CFX_Matrix ctmOnParent; |
437 CFX_RectF rect; | 314 CFX_RectF rect; |
438 int32_t count = parents.GetSize(); | 315 int32_t count = parents.GetSize(); |
439 for (int32_t i = count - 2; i >= 0; i--) { | 316 for (int32_t i = count - 2; i >= 0; i--) { |
440 parent = parents.GetAt(i); | 317 parent = parents.GetAt(i); |
441 parent->GetMatrix(ctmOnParent, FALSE); | 318 parent->GetMatrix(ctmOnParent, FALSE); |
442 parent->GetWidgetRect(rect); | 319 parent->GetWidgetRect(rect); |
443 matrix.Concat(ctmOnParent, TRUE); | 320 matrix.Concat(ctmOnParent, TRUE); |
444 matrix.Translate(rect.left, rect.top, TRUE); | 321 matrix.Translate(rect.left, rect.top, TRUE); |
445 } | 322 } |
446 matrix.Concat(m_pProperties->m_ctmOnParent, TRUE); | 323 matrix.Concat(m_pProperties->m_ctmOnParent, TRUE); |
447 parents.RemoveAll(); | 324 parents.RemoveAll(); |
448 } else { | 325 } else { |
449 matrix = m_pProperties->m_ctmOnParent; | 326 matrix = m_pProperties->m_ctmOnParent; |
450 } | 327 } |
451 return FWL_Error::Succeeded; | 328 return FWL_Error::Succeeded; |
452 } | 329 } |
453 FWL_Error CFWL_WidgetImp::SetMatrix(const CFX_Matrix& matrix) { | 330 |
| 331 FWL_Error IFWL_Widget::SetMatrix(const CFX_Matrix& matrix) { |
454 if (!m_pProperties) | 332 if (!m_pProperties) |
455 return FWL_Error::Indefinite; | 333 return FWL_Error::Indefinite; |
456 IFWL_Widget* parent = GetParent(); | 334 IFWL_Widget* parent = GetParent(); |
457 if (!parent) { | 335 if (!parent) { |
458 return FWL_Error::Indefinite; | 336 return FWL_Error::Indefinite; |
459 } | 337 } |
460 m_pProperties->m_ctmOnParent = matrix; | 338 m_pProperties->m_ctmOnParent = matrix; |
461 return FWL_Error::Succeeded; | 339 return FWL_Error::Succeeded; |
462 } | 340 } |
463 FWL_Error CFWL_WidgetImp::DrawWidget(CFX_Graphics* pGraphics, | 341 |
464 const CFX_Matrix* pMatrix) { | 342 FWL_Error IFWL_Widget::DrawWidget(CFX_Graphics* pGraphics, |
| 343 const CFX_Matrix* pMatrix) { |
465 return FWL_Error::Indefinite; | 344 return FWL_Error::Indefinite; |
466 } | 345 } |
467 IFWL_ThemeProvider* CFWL_WidgetImp::GetThemeProvider() { | 346 |
| 347 IFWL_ThemeProvider* IFWL_Widget::GetThemeProvider() { |
468 return m_pProperties->m_pThemeProvider; | 348 return m_pProperties->m_pThemeProvider; |
469 } | 349 } |
470 FWL_Error CFWL_WidgetImp::SetThemeProvider(IFWL_ThemeProvider* pThemeProvider) { | 350 FWL_Error IFWL_Widget::SetThemeProvider(IFWL_ThemeProvider* pThemeProvider) { |
471 m_pProperties->m_pThemeProvider = pThemeProvider; | 351 m_pProperties->m_pThemeProvider = pThemeProvider; |
472 return FWL_Error::Succeeded; | 352 return FWL_Error::Succeeded; |
473 } | 353 } |
474 IFWL_WidgetDelegate* CFWL_WidgetImp::SetDelegate( | 354 |
475 IFWL_WidgetDelegate* pDelegate) { | 355 IFWL_WidgetDelegate* IFWL_Widget::SetDelegate(IFWL_WidgetDelegate* pDelegate) { |
476 if (!m_pCurDelegate) { | 356 if (!m_pCurDelegate) { |
477 m_pCurDelegate = m_pDelegate; | 357 m_pCurDelegate = m_pDelegate; |
478 } | 358 } |
479 if (!pDelegate) { | 359 if (!pDelegate) { |
480 return m_pCurDelegate; | 360 return m_pCurDelegate; |
481 } | 361 } |
482 IFWL_WidgetDelegate* pOldDelegate = m_pCurDelegate; | 362 IFWL_WidgetDelegate* pOldDelegate = m_pCurDelegate; |
483 m_pCurDelegate = pDelegate; | 363 m_pCurDelegate = pDelegate; |
484 return pOldDelegate; | 364 return pOldDelegate; |
485 } | 365 } |
486 IFWL_App* CFWL_WidgetImp::GetOwnerApp() const { | 366 |
| 367 IFWL_App* IFWL_Widget::GetOwnerApp() const { |
487 return m_pOwnerApp; | 368 return m_pOwnerApp; |
488 } | 369 } |
489 FWL_Error CFWL_WidgetImp::SetOwnerApp(IFWL_App* pOwnerApp) { | 370 |
| 371 FWL_Error IFWL_Widget::SetOwnerApp(IFWL_App* pOwnerApp) { |
490 m_pOwnerApp = pOwnerApp; | 372 m_pOwnerApp = pOwnerApp; |
491 return FWL_Error::Succeeded; | 373 return FWL_Error::Succeeded; |
492 } | 374 } |
493 IFWL_Widget* CFWL_WidgetImp::GetInterface() const { | |
494 return m_pInterface; | |
495 } | |
496 void CFWL_WidgetImp::SetInterface(IFWL_Widget* pInterface) { | |
497 m_pInterface = pInterface; | |
498 } | |
499 | 375 |
500 uint32_t CFWL_WidgetImp::GetEventKey() const { | 376 uint32_t IFWL_Widget::GetEventKey() const { |
501 return m_nEventKey; | 377 return m_nEventKey; |
502 } | 378 } |
503 | 379 |
504 void CFWL_WidgetImp::SetEventKey(uint32_t key) { | 380 void IFWL_Widget::SetEventKey(uint32_t key) { |
505 m_nEventKey = key; | 381 m_nEventKey = key; |
506 } | 382 } |
507 | 383 |
508 void* CFWL_WidgetImp::GetLayoutItem() const { | 384 void* IFWL_Widget::GetLayoutItem() const { |
509 return m_pLayoutItem; | 385 return m_pLayoutItem; |
510 } | 386 } |
511 | 387 |
512 void CFWL_WidgetImp::SetLayoutItem(void* pItem) { | 388 void IFWL_Widget::SetLayoutItem(void* pItem) { |
513 m_pLayoutItem = pItem; | 389 m_pLayoutItem = pItem; |
514 } | 390 } |
515 | 391 |
516 void* CFWL_WidgetImp::GetAssociateWidget() const { | 392 CFWL_Widget* IFWL_Widget::GetAssociateWidget() const { |
517 return m_pAssociate; | 393 return m_pAssociate; |
518 } | 394 } |
519 | 395 |
520 void CFWL_WidgetImp::SetAssociateWidget(void* pAssociate) { | 396 void IFWL_Widget::SetAssociateWidget(CFWL_Widget* pAssociate) { |
521 m_pAssociate = pAssociate; | 397 m_pAssociate = pAssociate; |
522 } | 398 } |
523 | 399 |
524 CFWL_WidgetImp::CFWL_WidgetImp(const CFWL_WidgetImpProperties& properties, | 400 IFWL_Widget::IFWL_Widget(const CFWL_WidgetImpProperties& properties, |
525 IFWL_Widget* pOuter) | 401 IFWL_Widget* pOuter) |
526 : m_pWidgetMgr(CFWL_WidgetMgr::GetInstance()), | 402 : m_pWidgetMgr(CFWL_WidgetMgr::GetInstance()), |
527 m_pProperties(new CFWL_WidgetImpProperties(properties)), | 403 m_pProperties(new CFWL_WidgetImpProperties(properties)), |
528 m_pDelegate(nullptr), | 404 m_pDelegate(nullptr), |
529 m_pCurDelegate(nullptr), | 405 m_pCurDelegate(nullptr), |
530 m_pOuter(pOuter), | 406 m_pOuter(pOuter), |
531 m_pInterface(nullptr), | |
532 m_pLayoutItem(nullptr), | 407 m_pLayoutItem(nullptr), |
533 m_pAssociate(nullptr), | 408 m_pAssociate(nullptr), |
534 m_iLock(0), | 409 m_iLock(0), |
535 m_nEventKey(0) { | 410 m_nEventKey(0) { |
536 ASSERT(m_pWidgetMgr); | 411 ASSERT(m_pWidgetMgr); |
537 } | 412 } |
538 | 413 |
539 CFWL_WidgetImp::~CFWL_WidgetImp() {} | 414 IFWL_Widget::~IFWL_Widget() {} |
540 | 415 |
541 FX_BOOL CFWL_WidgetImp::IsEnabled() const { | 416 FX_BOOL IFWL_Widget::IsEnabled() const { |
542 return (m_pProperties->m_dwStates & FWL_WGTSTATE_Disabled) == 0; | 417 return (m_pProperties->m_dwStates & FWL_WGTSTATE_Disabled) == 0; |
543 } | 418 } |
544 FX_BOOL CFWL_WidgetImp::IsVisible() const { | 419 |
| 420 FX_BOOL IFWL_Widget::IsVisible() const { |
545 return (m_pProperties->m_dwStates & FWL_WGTSTATE_Invisible) == 0; | 421 return (m_pProperties->m_dwStates & FWL_WGTSTATE_Invisible) == 0; |
546 } | 422 } |
547 FX_BOOL CFWL_WidgetImp::IsActive() const { | 423 |
| 424 FX_BOOL IFWL_Widget::IsActive() const { |
548 return (m_pProperties->m_dwStates & FWL_WGTSTATE_Deactivated) == 0; | 425 return (m_pProperties->m_dwStates & FWL_WGTSTATE_Deactivated) == 0; |
549 } | 426 } |
550 FX_BOOL CFWL_WidgetImp::IsOverLapper() const { | 427 |
| 428 FX_BOOL IFWL_Widget::IsOverLapper() const { |
551 return (m_pProperties->m_dwStyles & FWL_WGTSTYLE_WindowTypeMask) == | 429 return (m_pProperties->m_dwStyles & FWL_WGTSTYLE_WindowTypeMask) == |
552 FWL_WGTSTYLE_OverLapper; | 430 FWL_WGTSTYLE_OverLapper; |
553 } | 431 } |
554 FX_BOOL CFWL_WidgetImp::IsPopup() const { | 432 |
| 433 FX_BOOL IFWL_Widget::IsPopup() const { |
555 return !!(m_pProperties->m_dwStyles & FWL_WGTSTYLE_Popup); | 434 return !!(m_pProperties->m_dwStyles & FWL_WGTSTYLE_Popup); |
556 } | 435 } |
557 FX_BOOL CFWL_WidgetImp::IsChild() const { | 436 |
| 437 FX_BOOL IFWL_Widget::IsChild() const { |
558 return !!(m_pProperties->m_dwStyles & FWL_WGTSTYLE_Child); | 438 return !!(m_pProperties->m_dwStyles & FWL_WGTSTYLE_Child); |
559 } | 439 } |
560 FX_BOOL CFWL_WidgetImp::IsLocked() const { | 440 |
| 441 FX_BOOL IFWL_Widget::IsLocked() const { |
561 return m_iLock > 0; | 442 return m_iLock > 0; |
562 } | 443 } |
563 FX_BOOL CFWL_WidgetImp::IsOffscreen() const { | 444 |
| 445 FX_BOOL IFWL_Widget::IsOffscreen() const { |
564 return !!(m_pProperties->m_dwStyles & FWL_WGTSTYLE_Offscreen); | 446 return !!(m_pProperties->m_dwStyles & FWL_WGTSTYLE_Offscreen); |
565 } | 447 } |
566 FX_BOOL CFWL_WidgetImp::HasBorder() const { | 448 |
| 449 FX_BOOL IFWL_Widget::HasBorder() const { |
567 return !!(m_pProperties->m_dwStyles & FWL_WGTSTYLE_Border); | 450 return !!(m_pProperties->m_dwStyles & FWL_WGTSTYLE_Border); |
568 } | 451 } |
569 FX_BOOL CFWL_WidgetImp::HasEdge() const { | 452 |
| 453 FX_BOOL IFWL_Widget::HasEdge() const { |
570 return !!(m_pProperties->m_dwStyles & FWL_WGTSTYLE_EdgeMask); | 454 return !!(m_pProperties->m_dwStyles & FWL_WGTSTYLE_EdgeMask); |
571 } | 455 } |
572 void CFWL_WidgetImp::GetEdgeRect(CFX_RectF& rtEdge) { | 456 |
| 457 void IFWL_Widget::GetEdgeRect(CFX_RectF& rtEdge) { |
573 rtEdge = m_pProperties->m_rtWidget; | 458 rtEdge = m_pProperties->m_rtWidget; |
574 rtEdge.left = rtEdge.top = 0; | 459 rtEdge.left = rtEdge.top = 0; |
575 if (HasBorder()) { | 460 if (HasBorder()) { |
576 FX_FLOAT fCX = GetBorderSize(); | 461 FX_FLOAT fCX = GetBorderSize(); |
577 FX_FLOAT fCY = GetBorderSize(FALSE); | 462 FX_FLOAT fCY = GetBorderSize(FALSE); |
578 rtEdge.Deflate(fCX, fCY); | 463 rtEdge.Deflate(fCX, fCY); |
579 } | 464 } |
580 } | 465 } |
581 FX_FLOAT CFWL_WidgetImp::GetBorderSize(FX_BOOL bCX) { | 466 |
| 467 FX_FLOAT IFWL_Widget::GetBorderSize(FX_BOOL bCX) { |
582 FX_FLOAT* pfBorder = static_cast<FX_FLOAT*>(GetThemeCapacity( | 468 FX_FLOAT* pfBorder = static_cast<FX_FLOAT*>(GetThemeCapacity( |
583 bCX ? CFWL_WidgetCapacity::CXBorder : CFWL_WidgetCapacity::CYBorder)); | 469 bCX ? CFWL_WidgetCapacity::CXBorder : CFWL_WidgetCapacity::CYBorder)); |
584 if (!pfBorder) | 470 if (!pfBorder) |
585 return 0; | 471 return 0; |
586 return *pfBorder; | 472 return *pfBorder; |
587 } | 473 } |
588 FX_FLOAT CFWL_WidgetImp::GetEdgeWidth() { | 474 |
| 475 FX_FLOAT IFWL_Widget::GetEdgeWidth() { |
589 CFWL_WidgetCapacity dwCapacity = CFWL_WidgetCapacity::None; | 476 CFWL_WidgetCapacity dwCapacity = CFWL_WidgetCapacity::None; |
590 switch (m_pProperties->m_dwStyles & FWL_WGTSTYLE_EdgeMask) { | 477 switch (m_pProperties->m_dwStyles & FWL_WGTSTYLE_EdgeMask) { |
591 case FWL_WGTSTYLE_EdgeFlat: { | 478 case FWL_WGTSTYLE_EdgeFlat: { |
592 dwCapacity = CFWL_WidgetCapacity::EdgeFlat; | 479 dwCapacity = CFWL_WidgetCapacity::EdgeFlat; |
593 break; | 480 break; |
594 } | 481 } |
595 case FWL_WGTSTYLE_EdgeRaised: { | 482 case FWL_WGTSTYLE_EdgeRaised: { |
596 dwCapacity = CFWL_WidgetCapacity::EdgeRaised; | 483 dwCapacity = CFWL_WidgetCapacity::EdgeRaised; |
597 break; | 484 break; |
598 } | 485 } |
599 case FWL_WGTSTYLE_EdgeSunken: { | 486 case FWL_WGTSTYLE_EdgeSunken: { |
600 dwCapacity = CFWL_WidgetCapacity::EdgeSunken; | 487 dwCapacity = CFWL_WidgetCapacity::EdgeSunken; |
601 break; | 488 break; |
602 } | 489 } |
603 } | 490 } |
604 if (dwCapacity != CFWL_WidgetCapacity::None) { | 491 if (dwCapacity != CFWL_WidgetCapacity::None) { |
605 FX_FLOAT* fRet = static_cast<FX_FLOAT*>(GetThemeCapacity(dwCapacity)); | 492 FX_FLOAT* fRet = static_cast<FX_FLOAT*>(GetThemeCapacity(dwCapacity)); |
606 return fRet ? *fRet : 0; | 493 return fRet ? *fRet : 0; |
607 } | 494 } |
608 return 0; | 495 return 0; |
609 } | 496 } |
610 void CFWL_WidgetImp::GetRelativeRect(CFX_RectF& rect) { | 497 |
| 498 void IFWL_Widget::GetRelativeRect(CFX_RectF& rect) { |
611 rect = m_pProperties->m_rtWidget; | 499 rect = m_pProperties->m_rtWidget; |
612 rect.left = rect.top = 0; | 500 rect.left = rect.top = 0; |
613 } | 501 } |
614 void* CFWL_WidgetImp::GetThemeCapacity(CFWL_WidgetCapacity dwCapacity) { | 502 |
| 503 void* IFWL_Widget::GetThemeCapacity(CFWL_WidgetCapacity dwCapacity) { |
615 IFWL_ThemeProvider* pTheme = GetAvailableTheme(); | 504 IFWL_ThemeProvider* pTheme = GetAvailableTheme(); |
616 if (!pTheme) | 505 if (!pTheme) |
617 return nullptr; | 506 return nullptr; |
618 CFWL_ThemePart part; | 507 CFWL_ThemePart part; |
619 part.m_pWidget = m_pInterface; | 508 part.m_pWidget = this; |
620 return pTheme->GetCapacity(&part, dwCapacity); | 509 return pTheme->GetCapacity(&part, dwCapacity); |
621 } | 510 } |
622 IFWL_ThemeProvider* CFWL_WidgetImp::GetAvailableTheme() { | 511 |
| 512 IFWL_ThemeProvider* IFWL_Widget::GetAvailableTheme() { |
623 if (m_pProperties->m_pThemeProvider) { | 513 if (m_pProperties->m_pThemeProvider) { |
624 return m_pProperties->m_pThemeProvider; | 514 return m_pProperties->m_pThemeProvider; |
625 } | 515 } |
626 IFWL_Widget* pUp = m_pInterface; | 516 IFWL_Widget* pUp = this; |
627 do { | 517 do { |
628 pUp = (pUp->GetStyles() & FWL_WGTSTYLE_Popup) | 518 pUp = (pUp->GetStyles() & FWL_WGTSTYLE_Popup) |
629 ? m_pWidgetMgr->GetOwnerWidget(pUp) | 519 ? m_pWidgetMgr->GetOwnerWidget(pUp) |
630 : m_pWidgetMgr->GetParentWidget(pUp); | 520 : m_pWidgetMgr->GetParentWidget(pUp); |
631 if (pUp) { | 521 if (pUp) { |
632 IFWL_ThemeProvider* pRet = pUp->GetThemeProvider(); | 522 IFWL_ThemeProvider* pRet = pUp->GetThemeProvider(); |
633 if (pRet) | 523 if (pRet) |
634 return pRet; | 524 return pRet; |
635 } | 525 } |
636 } while (pUp); | 526 } while (pUp); |
637 return nullptr; | 527 return nullptr; |
638 } | 528 } |
639 CFWL_WidgetImp* CFWL_WidgetImp::GetRootOuter() { | 529 |
| 530 IFWL_Widget* IFWL_Widget::GetRootOuter() { |
640 IFWL_Widget* pRet = m_pOuter; | 531 IFWL_Widget* pRet = m_pOuter; |
641 if (!pRet) | 532 if (!pRet) |
642 return nullptr; | 533 return nullptr; |
643 while (IFWL_Widget* pOuter = pRet->GetOuter()) { | 534 while (IFWL_Widget* pOuter = pRet->GetOuter()) { |
644 pRet = pOuter; | 535 pRet = pOuter; |
645 } | 536 } |
646 return static_cast<CFWL_WidgetImp*>(pRet->GetImpl()); | 537 return pRet; |
647 } | 538 } |
| 539 |
648 #define FWL_WGT_CalcHeight 2048 | 540 #define FWL_WGT_CalcHeight 2048 |
649 #define FWL_WGT_CalcWidth 2048 | 541 #define FWL_WGT_CalcWidth 2048 |
650 #define FWL_WGT_CalcMultiLineDefWidth 120.0f | 542 #define FWL_WGT_CalcMultiLineDefWidth 120.0f |
651 CFX_SizeF CFWL_WidgetImp::CalcTextSize(const CFX_WideString& wsText, | 543 |
652 IFWL_ThemeProvider* pTheme, | 544 CFX_SizeF IFWL_Widget::CalcTextSize(const CFX_WideString& wsText, |
653 FX_BOOL bMultiLine, | 545 IFWL_ThemeProvider* pTheme, |
654 int32_t iLineWidth) { | 546 FX_BOOL bMultiLine, |
| 547 int32_t iLineWidth) { |
655 if (!pTheme) | 548 if (!pTheme) |
656 return CFX_SizeF(); | 549 return CFX_SizeF(); |
657 | 550 |
658 CFWL_ThemeText calPart; | 551 CFWL_ThemeText calPart; |
659 calPart.m_pWidget = m_pInterface; | 552 calPart.m_pWidget = this; |
660 calPart.m_wsText = wsText; | 553 calPart.m_wsText = wsText; |
661 calPart.m_dwTTOStyles = | 554 calPart.m_dwTTOStyles = |
662 bMultiLine ? FDE_TTOSTYLE_LineWrap : FDE_TTOSTYLE_SingleLine; | 555 bMultiLine ? FDE_TTOSTYLE_LineWrap : FDE_TTOSTYLE_SingleLine; |
663 calPart.m_iTTOAlign = FDE_TTOALIGNMENT_TopLeft; | 556 calPart.m_iTTOAlign = FDE_TTOALIGNMENT_TopLeft; |
664 CFX_RectF rect; | 557 CFX_RectF rect; |
665 FX_FLOAT fWidth = bMultiLine | 558 FX_FLOAT fWidth = bMultiLine |
666 ? (iLineWidth > 0 ? (FX_FLOAT)iLineWidth | 559 ? (iLineWidth > 0 ? (FX_FLOAT)iLineWidth |
667 : FWL_WGT_CalcMultiLineDefWidth) | 560 : FWL_WGT_CalcMultiLineDefWidth) |
668 : FWL_WGT_CalcWidth; | 561 : FWL_WGT_CalcWidth; |
669 rect.Set(0, 0, fWidth, FWL_WGT_CalcHeight); | 562 rect.Set(0, 0, fWidth, FWL_WGT_CalcHeight); |
670 pTheme->CalcTextRect(&calPart, rect); | 563 pTheme->CalcTextRect(&calPart, rect); |
671 return CFX_SizeF(rect.width, rect.height); | 564 return CFX_SizeF(rect.width, rect.height); |
672 } | 565 } |
673 void CFWL_WidgetImp::CalcTextRect(const CFX_WideString& wsText, | 566 |
674 IFWL_ThemeProvider* pTheme, | 567 void IFWL_Widget::CalcTextRect(const CFX_WideString& wsText, |
675 uint32_t dwTTOStyles, | 568 IFWL_ThemeProvider* pTheme, |
676 int32_t iTTOAlign, | 569 uint32_t dwTTOStyles, |
677 CFX_RectF& rect) { | 570 int32_t iTTOAlign, |
| 571 CFX_RectF& rect) { |
678 CFWL_ThemeText calPart; | 572 CFWL_ThemeText calPart; |
679 calPart.m_pWidget = m_pInterface; | 573 calPart.m_pWidget = this; |
680 calPart.m_wsText = wsText; | 574 calPart.m_wsText = wsText; |
681 calPart.m_dwTTOStyles = dwTTOStyles; | 575 calPart.m_dwTTOStyles = dwTTOStyles; |
682 calPart.m_iTTOAlign = iTTOAlign; | 576 calPart.m_iTTOAlign = iTTOAlign; |
683 pTheme->CalcTextRect(&calPart, rect); | 577 pTheme->CalcTextRect(&calPart, rect); |
684 } | 578 } |
685 void CFWL_WidgetImp::SetFocus(FX_BOOL bFocus) { | 579 |
| 580 void IFWL_Widget::SetFocus(FX_BOOL bFocus) { |
686 if (m_pWidgetMgr->IsFormDisabled()) | 581 if (m_pWidgetMgr->IsFormDisabled()) |
687 return; | 582 return; |
688 | 583 |
689 IFWL_App* pApp = GetOwnerApp(); | 584 IFWL_App* pApp = GetOwnerApp(); |
690 if (!pApp) | 585 if (!pApp) |
691 return; | 586 return; |
692 | 587 |
693 CFWL_NoteDriver* pDriver = | 588 CFWL_NoteDriver* pDriver = |
694 static_cast<CFWL_NoteDriver*>(pApp->GetNoteDriver()); | 589 static_cast<CFWL_NoteDriver*>(pApp->GetNoteDriver()); |
695 if (!pDriver) | 590 if (!pDriver) |
696 return; | 591 return; |
697 | 592 |
698 IFWL_Widget* curFocus = pDriver->GetFocus(); | 593 IFWL_Widget* curFocus = pDriver->GetFocus(); |
699 if (bFocus && curFocus != m_pInterface) { | 594 if (bFocus && curFocus != this) { |
700 pDriver->SetFocus(m_pInterface); | 595 pDriver->SetFocus(this); |
701 } else if (!bFocus && curFocus == m_pInterface) { | 596 } else if (!bFocus && curFocus == this) { |
702 pDriver->SetFocus(nullptr); | 597 pDriver->SetFocus(nullptr); |
703 } | 598 } |
704 } | 599 } |
705 void CFWL_WidgetImp::SetGrab(FX_BOOL bSet) { | 600 |
| 601 void IFWL_Widget::SetGrab(FX_BOOL bSet) { |
706 IFWL_App* pApp = GetOwnerApp(); | 602 IFWL_App* pApp = GetOwnerApp(); |
707 if (!pApp) | 603 if (!pApp) |
708 return; | 604 return; |
709 CFWL_NoteDriver* pDriver = | 605 CFWL_NoteDriver* pDriver = |
710 static_cast<CFWL_NoteDriver*>(pApp->GetNoteDriver()); | 606 static_cast<CFWL_NoteDriver*>(pApp->GetNoteDriver()); |
711 pDriver->SetGrab(m_pInterface, bSet); | 607 pDriver->SetGrab(this, bSet); |
712 } | 608 } |
713 | 609 |
714 FX_BOOL CFWL_WidgetImp::GetPopupPos(FX_FLOAT fMinHeight, | 610 FX_BOOL IFWL_Widget::GetPopupPos(FX_FLOAT fMinHeight, |
715 FX_FLOAT fMaxHeight, | 611 FX_FLOAT fMaxHeight, |
716 const CFX_RectF& rtAnchor, | 612 const CFX_RectF& rtAnchor, |
717 CFX_RectF& rtPopup) { | 613 CFX_RectF& rtPopup) { |
718 if (GetClassID() == FWL_Type::ComboBox) { | 614 if (GetClassID() == FWL_Type::ComboBox) { |
719 if (m_pWidgetMgr->IsFormDisabled()) { | 615 if (m_pWidgetMgr->IsFormDisabled()) { |
720 return m_pWidgetMgr->GetAdapterPopupPos(m_pInterface, fMinHeight, | 616 return m_pWidgetMgr->GetAdapterPopupPos(this, fMinHeight, fMaxHeight, |
721 fMaxHeight, rtAnchor, rtPopup); | 617 rtAnchor, rtPopup); |
722 } | 618 } |
723 return GetPopupPosComboBox(fMinHeight, fMaxHeight, rtAnchor, rtPopup); | 619 return GetPopupPosComboBox(fMinHeight, fMaxHeight, rtAnchor, rtPopup); |
724 } | 620 } |
725 if (GetClassID() == FWL_Type::DateTimePicker && | 621 if (GetClassID() == FWL_Type::DateTimePicker && |
726 m_pWidgetMgr->IsFormDisabled()) { | 622 m_pWidgetMgr->IsFormDisabled()) { |
727 return m_pWidgetMgr->GetAdapterPopupPos(m_pInterface, fMinHeight, | 623 return m_pWidgetMgr->GetAdapterPopupPos(this, fMinHeight, fMaxHeight, |
728 fMaxHeight, rtAnchor, rtPopup); | 624 rtAnchor, rtPopup); |
729 } | 625 } |
730 return GetPopupPosGeneral(fMinHeight, fMaxHeight, rtAnchor, rtPopup); | 626 return GetPopupPosGeneral(fMinHeight, fMaxHeight, rtAnchor, rtPopup); |
731 } | 627 } |
732 | 628 |
733 FX_BOOL CFWL_WidgetImp::GetPopupPosMenu(FX_FLOAT fMinHeight, | 629 FX_BOOL IFWL_Widget::GetPopupPosMenu(FX_FLOAT fMinHeight, |
734 FX_FLOAT fMaxHeight, | 630 FX_FLOAT fMaxHeight, |
735 const CFX_RectF& rtAnchor, | 631 const CFX_RectF& rtAnchor, |
736 CFX_RectF& rtPopup) { | 632 CFX_RectF& rtPopup) { |
737 FX_FLOAT fx = 0; | 633 FX_FLOAT fx = 0; |
738 FX_FLOAT fy = 0; | 634 FX_FLOAT fy = 0; |
739 FX_FLOAT fScreenWidth = 0; | 635 FX_FLOAT fScreenWidth = 0; |
740 FX_FLOAT fScreenHeight = 0; | 636 FX_FLOAT fScreenHeight = 0; |
741 GetScreenSize(fScreenWidth, fScreenHeight); | 637 GetScreenSize(fScreenWidth, fScreenHeight); |
742 if (GetStylesEx() & FWL_STYLEEXT_MNU_Vert) { | 638 if (GetStylesEx() & FWL_STYLEEXT_MNU_Vert) { |
743 FX_BOOL bLeft = m_pProperties->m_rtWidget.left < 0; | 639 FX_BOOL bLeft = m_pProperties->m_rtWidget.left < 0; |
744 FX_FLOAT fRight = rtAnchor.right() + rtPopup.width; | 640 FX_FLOAT fRight = rtAnchor.right() + rtPopup.width; |
745 TransformTo(nullptr, fx, fy); | 641 TransformTo(nullptr, fx, fy); |
746 if (fRight + fx > fScreenWidth || bLeft) { | 642 if (fRight + fx > fScreenWidth || bLeft) { |
(...skipping 10 matching lines...) Expand all Loading... |
757 rtPopup.Set(rtAnchor.left, rtAnchor.top - rtPopup.height, rtPopup.width, | 653 rtPopup.Set(rtAnchor.left, rtAnchor.top - rtPopup.height, rtPopup.width, |
758 rtPopup.height); | 654 rtPopup.height); |
759 } else { | 655 } else { |
760 rtPopup.Set(rtAnchor.left, rtAnchor.bottom(), rtPopup.width, | 656 rtPopup.Set(rtAnchor.left, rtAnchor.bottom(), rtPopup.width, |
761 rtPopup.height); | 657 rtPopup.height); |
762 } | 658 } |
763 } | 659 } |
764 rtPopup.Offset(fx, fy); | 660 rtPopup.Offset(fx, fy); |
765 return TRUE; | 661 return TRUE; |
766 } | 662 } |
767 FX_BOOL CFWL_WidgetImp::GetPopupPosComboBox(FX_FLOAT fMinHeight, | 663 |
768 FX_FLOAT fMaxHeight, | 664 FX_BOOL IFWL_Widget::GetPopupPosComboBox(FX_FLOAT fMinHeight, |
769 const CFX_RectF& rtAnchor, | 665 FX_FLOAT fMaxHeight, |
770 CFX_RectF& rtPopup) { | 666 const CFX_RectF& rtAnchor, |
| 667 CFX_RectF& rtPopup) { |
771 FX_FLOAT fx = 0; | 668 FX_FLOAT fx = 0; |
772 FX_FLOAT fy = 0; | 669 FX_FLOAT fy = 0; |
773 FX_FLOAT fScreenWidth = 0; | 670 FX_FLOAT fScreenWidth = 0; |
774 FX_FLOAT fScreenHeight = 0; | 671 FX_FLOAT fScreenHeight = 0; |
775 GetScreenSize(fScreenWidth, fScreenHeight); | 672 GetScreenSize(fScreenWidth, fScreenHeight); |
776 FX_FLOAT fPopHeight = rtPopup.height; | 673 FX_FLOAT fPopHeight = rtPopup.height; |
777 if (rtPopup.height > fMaxHeight) { | 674 if (rtPopup.height > fMaxHeight) { |
778 fPopHeight = fMaxHeight; | 675 fPopHeight = fMaxHeight; |
779 } else if (rtPopup.height < fMinHeight) { | 676 } else if (rtPopup.height < fMinHeight) { |
780 fPopHeight = fMinHeight; | 677 fPopHeight = fMinHeight; |
781 } | 678 } |
782 FX_FLOAT fWidth = std::max(rtAnchor.width, rtPopup.width); | 679 FX_FLOAT fWidth = std::max(rtAnchor.width, rtPopup.width); |
783 FX_FLOAT fBottom = rtAnchor.bottom() + fPopHeight; | 680 FX_FLOAT fBottom = rtAnchor.bottom() + fPopHeight; |
784 TransformTo(nullptr, fx, fy); | 681 TransformTo(nullptr, fx, fy); |
785 if (fBottom + fy > fScreenHeight) { | 682 if (fBottom + fy > fScreenHeight) { |
786 rtPopup.Set(rtAnchor.left, rtAnchor.top - fPopHeight, fWidth, fPopHeight); | 683 rtPopup.Set(rtAnchor.left, rtAnchor.top - fPopHeight, fWidth, fPopHeight); |
787 } else { | 684 } else { |
788 rtPopup.Set(rtAnchor.left, rtAnchor.bottom(), fWidth, fPopHeight); | 685 rtPopup.Set(rtAnchor.left, rtAnchor.bottom(), fWidth, fPopHeight); |
789 } | 686 } |
790 rtPopup.Offset(fx, fy); | 687 rtPopup.Offset(fx, fy); |
791 return TRUE; | 688 return TRUE; |
792 } | 689 } |
793 FX_BOOL CFWL_WidgetImp::GetPopupPosGeneral(FX_FLOAT fMinHeight, | 690 |
794 FX_FLOAT fMaxHeight, | 691 FX_BOOL IFWL_Widget::GetPopupPosGeneral(FX_FLOAT fMinHeight, |
795 const CFX_RectF& rtAnchor, | 692 FX_FLOAT fMaxHeight, |
796 CFX_RectF& rtPopup) { | 693 const CFX_RectF& rtAnchor, |
| 694 CFX_RectF& rtPopup) { |
797 FX_FLOAT fx = 0; | 695 FX_FLOAT fx = 0; |
798 FX_FLOAT fy = 0; | 696 FX_FLOAT fy = 0; |
799 FX_FLOAT fScreenWidth = 0; | 697 FX_FLOAT fScreenWidth = 0; |
800 FX_FLOAT fScreenHeight = 0; | 698 FX_FLOAT fScreenHeight = 0; |
801 GetScreenSize(fScreenWidth, fScreenHeight); | 699 GetScreenSize(fScreenWidth, fScreenHeight); |
802 TransformTo(nullptr, fx, fy); | 700 TransformTo(nullptr, fx, fy); |
803 if (rtAnchor.bottom() + fy > fScreenHeight) { | 701 if (rtAnchor.bottom() + fy > fScreenHeight) { |
804 rtPopup.Set(rtAnchor.left, rtAnchor.top - rtPopup.height, rtPopup.width, | 702 rtPopup.Set(rtAnchor.left, rtAnchor.top - rtPopup.height, rtPopup.width, |
805 rtPopup.height); | 703 rtPopup.height); |
806 } else { | 704 } else { |
807 rtPopup.Set(rtAnchor.left, rtAnchor.bottom(), rtPopup.width, | 705 rtPopup.Set(rtAnchor.left, rtAnchor.bottom(), rtPopup.width, |
808 rtPopup.height); | 706 rtPopup.height); |
809 } | 707 } |
810 rtPopup.Offset(fx, fy); | 708 rtPopup.Offset(fx, fy); |
811 return TRUE; | 709 return TRUE; |
812 } | 710 } |
813 FX_BOOL CFWL_WidgetImp::GetScreenSize(FX_FLOAT& fx, FX_FLOAT& fy) { | 711 |
| 712 FX_BOOL IFWL_Widget::GetScreenSize(FX_FLOAT& fx, FX_FLOAT& fy) { |
814 return FALSE; | 713 return FALSE; |
815 } | 714 } |
816 void CFWL_WidgetImp::RegisterEventTarget(IFWL_Widget* pEventSource, | 715 |
817 uint32_t dwFilter) { | 716 void IFWL_Widget::RegisterEventTarget(IFWL_Widget* pEventSource, |
| 717 uint32_t dwFilter) { |
818 IFWL_App* pApp = GetOwnerApp(); | 718 IFWL_App* pApp = GetOwnerApp(); |
819 if (!pApp) | 719 if (!pApp) |
820 return; | 720 return; |
821 | 721 |
822 CFWL_NoteDriver* pNoteDriver = pApp->GetNoteDriver(); | 722 CFWL_NoteDriver* pNoteDriver = pApp->GetNoteDriver(); |
823 if (!pNoteDriver) | 723 if (!pNoteDriver) |
824 return; | 724 return; |
825 | 725 |
826 pNoteDriver->RegisterEventTarget(m_pInterface, pEventSource, dwFilter); | 726 pNoteDriver->RegisterEventTarget(this, pEventSource, dwFilter); |
827 } | 727 } |
828 void CFWL_WidgetImp::UnregisterEventTarget() { | 728 |
| 729 void IFWL_Widget::UnregisterEventTarget() { |
829 IFWL_App* pApp = GetOwnerApp(); | 730 IFWL_App* pApp = GetOwnerApp(); |
830 if (!pApp) | 731 if (!pApp) |
831 return; | 732 return; |
832 | 733 |
833 CFWL_NoteDriver* pNoteDriver = pApp->GetNoteDriver(); | 734 CFWL_NoteDriver* pNoteDriver = pApp->GetNoteDriver(); |
834 if (!pNoteDriver) | 735 if (!pNoteDriver) |
835 return; | 736 return; |
836 | 737 |
837 pNoteDriver->UnregisterEventTarget(m_pInterface); | 738 pNoteDriver->UnregisterEventTarget(this); |
838 } | 739 } |
839 void CFWL_WidgetImp::DispatchKeyEvent(CFWL_MsgKey* pNote) { | 740 |
| 741 void IFWL_Widget::DispatchKeyEvent(CFWL_MsgKey* pNote) { |
840 if (!pNote) | 742 if (!pNote) |
841 return; | 743 return; |
842 CFWL_EvtKey* pEvent = new CFWL_EvtKey; | 744 CFWL_EvtKey* pEvent = new CFWL_EvtKey; |
843 pEvent->m_pSrcTarget = m_pInterface; | 745 pEvent->m_pSrcTarget = this; |
844 pEvent->m_dwCmd = pNote->m_dwCmd; | 746 pEvent->m_dwCmd = pNote->m_dwCmd; |
845 pEvent->m_dwKeyCode = pNote->m_dwKeyCode; | 747 pEvent->m_dwKeyCode = pNote->m_dwKeyCode; |
846 pEvent->m_dwFlags = pNote->m_dwFlags; | 748 pEvent->m_dwFlags = pNote->m_dwFlags; |
847 DispatchEvent(pEvent); | 749 DispatchEvent(pEvent); |
848 pEvent->Release(); | 750 pEvent->Release(); |
849 } | 751 } |
850 void CFWL_WidgetImp::DispatchEvent(CFWL_Event* pEvent) { | 752 |
| 753 void IFWL_Widget::DispatchEvent(CFWL_Event* pEvent) { |
851 if (m_pOuter) { | 754 if (m_pOuter) { |
852 IFWL_WidgetDelegate* pDelegate = m_pOuter->SetDelegate(nullptr); | 755 IFWL_WidgetDelegate* pDelegate = m_pOuter->SetDelegate(nullptr); |
853 pDelegate->OnProcessEvent(pEvent); | 756 pDelegate->OnProcessEvent(pEvent); |
854 return; | 757 return; |
855 } | 758 } |
856 IFWL_App* pApp = GetOwnerApp(); | 759 IFWL_App* pApp = GetOwnerApp(); |
857 if (!pApp) | 760 if (!pApp) |
858 return; | 761 return; |
859 CFWL_NoteDriver* pNoteDriver = pApp->GetNoteDriver(); | 762 CFWL_NoteDriver* pNoteDriver = pApp->GetNoteDriver(); |
860 if (!pNoteDriver) | 763 if (!pNoteDriver) |
861 return; | 764 return; |
862 pNoteDriver->SendEvent(pEvent); | 765 pNoteDriver->SendEvent(pEvent); |
863 } | 766 } |
864 void CFWL_WidgetImp::Repaint(const CFX_RectF* pRect) { | 767 |
| 768 void IFWL_Widget::Repaint(const CFX_RectF* pRect) { |
865 if (pRect) { | 769 if (pRect) { |
866 m_pWidgetMgr->RepaintWidget(m_pInterface, pRect); | 770 m_pWidgetMgr->RepaintWidget(this, pRect); |
867 return; | 771 return; |
868 } | 772 } |
869 CFX_RectF rect; | 773 CFX_RectF rect; |
870 rect = m_pProperties->m_rtWidget; | 774 rect = m_pProperties->m_rtWidget; |
871 rect.left = rect.top = 0; | 775 rect.left = rect.top = 0; |
872 m_pWidgetMgr->RepaintWidget(m_pInterface, &rect); | 776 m_pWidgetMgr->RepaintWidget(this, &rect); |
873 } | 777 } |
874 void CFWL_WidgetImp::DrawBackground(CFX_Graphics* pGraphics, | 778 |
875 CFWL_Part iPartBk, | 779 void IFWL_Widget::DrawBackground(CFX_Graphics* pGraphics, |
876 IFWL_ThemeProvider* pTheme, | 780 CFWL_Part iPartBk, |
877 const CFX_Matrix* pMatrix) { | 781 IFWL_ThemeProvider* pTheme, |
| 782 const CFX_Matrix* pMatrix) { |
878 CFX_RectF rtRelative; | 783 CFX_RectF rtRelative; |
879 GetRelativeRect(rtRelative); | 784 GetRelativeRect(rtRelative); |
880 CFWL_ThemeBackground param; | 785 CFWL_ThemeBackground param; |
881 param.m_pWidget = m_pInterface; | 786 param.m_pWidget = this; |
882 param.m_iPart = iPartBk; | 787 param.m_iPart = iPartBk; |
883 param.m_pGraphics = pGraphics; | 788 param.m_pGraphics = pGraphics; |
884 if (pMatrix) { | 789 if (pMatrix) { |
885 param.m_matrix.Concat(*pMatrix, TRUE); | 790 param.m_matrix.Concat(*pMatrix, TRUE); |
886 } | 791 } |
887 param.m_rtPart = rtRelative; | 792 param.m_rtPart = rtRelative; |
888 pTheme->DrawBackground(¶m); | 793 pTheme->DrawBackground(¶m); |
889 } | 794 } |
890 void CFWL_WidgetImp::DrawBorder(CFX_Graphics* pGraphics, | 795 |
891 CFWL_Part iPartBorder, | 796 void IFWL_Widget::DrawBorder(CFX_Graphics* pGraphics, |
892 IFWL_ThemeProvider* pTheme, | 797 CFWL_Part iPartBorder, |
893 const CFX_Matrix* pMatrix) { | 798 IFWL_ThemeProvider* pTheme, |
| 799 const CFX_Matrix* pMatrix) { |
894 CFX_RectF rtRelative; | 800 CFX_RectF rtRelative; |
895 GetRelativeRect(rtRelative); | 801 GetRelativeRect(rtRelative); |
896 CFWL_ThemeBackground param; | 802 CFWL_ThemeBackground param; |
897 param.m_pWidget = m_pInterface; | 803 param.m_pWidget = this; |
898 param.m_iPart = iPartBorder; | 804 param.m_iPart = iPartBorder; |
899 param.m_pGraphics = pGraphics; | 805 param.m_pGraphics = pGraphics; |
900 if (pMatrix) { | 806 if (pMatrix) { |
901 param.m_matrix.Concat(*pMatrix, TRUE); | 807 param.m_matrix.Concat(*pMatrix, TRUE); |
902 } | 808 } |
903 param.m_rtPart = rtRelative; | 809 param.m_rtPart = rtRelative; |
904 pTheme->DrawBackground(¶m); | 810 pTheme->DrawBackground(¶m); |
905 } | 811 } |
906 void CFWL_WidgetImp::DrawEdge(CFX_Graphics* pGraphics, | 812 |
907 CFWL_Part iPartEdge, | 813 void IFWL_Widget::DrawEdge(CFX_Graphics* pGraphics, |
908 IFWL_ThemeProvider* pTheme, | 814 CFWL_Part iPartEdge, |
909 const CFX_Matrix* pMatrix) { | 815 IFWL_ThemeProvider* pTheme, |
| 816 const CFX_Matrix* pMatrix) { |
910 CFX_RectF rtEdge; | 817 CFX_RectF rtEdge; |
911 GetEdgeRect(rtEdge); | 818 GetEdgeRect(rtEdge); |
912 CFWL_ThemeBackground param; | 819 CFWL_ThemeBackground param; |
913 param.m_pWidget = m_pInterface; | 820 param.m_pWidget = this; |
914 param.m_iPart = iPartEdge; | 821 param.m_iPart = iPartEdge; |
915 param.m_pGraphics = pGraphics; | 822 param.m_pGraphics = pGraphics; |
916 if (pMatrix) { | 823 if (pMatrix) { |
917 param.m_matrix.Concat(*pMatrix, TRUE); | 824 param.m_matrix.Concat(*pMatrix, TRUE); |
918 } | 825 } |
919 param.m_rtPart = rtEdge; | 826 param.m_rtPart = rtEdge; |
920 pTheme->DrawBackground(¶m); | 827 pTheme->DrawBackground(¶m); |
921 } | 828 } |
922 void CFWL_WidgetImp::NotifyDriver() { | 829 |
| 830 void IFWL_Widget::NotifyDriver() { |
923 IFWL_App* pApp = GetOwnerApp(); | 831 IFWL_App* pApp = GetOwnerApp(); |
924 if (!pApp) | 832 if (!pApp) |
925 return; | 833 return; |
926 | 834 |
927 CFWL_NoteDriver* pDriver = | 835 CFWL_NoteDriver* pDriver = |
928 static_cast<CFWL_NoteDriver*>(pApp->GetNoteDriver()); | 836 static_cast<CFWL_NoteDriver*>(pApp->GetNoteDriver()); |
929 if (!pDriver) | 837 if (!pDriver) |
930 return; | 838 return; |
931 | 839 |
932 pDriver->NotifyTargetDestroy(m_pInterface); | 840 pDriver->NotifyTargetDestroy(this); |
933 } | 841 } |
934 CFX_SizeF CFWL_WidgetImp::GetOffsetFromParent(IFWL_Widget* pParent) { | 842 |
935 if (pParent == GetInterface()) | 843 CFX_SizeF IFWL_Widget::GetOffsetFromParent(IFWL_Widget* pParent) { |
| 844 if (pParent == this) |
936 return CFX_SizeF(); | 845 return CFX_SizeF(); |
937 | 846 |
938 CFWL_WidgetMgr* pWidgetMgr = CFWL_WidgetMgr::GetInstance(); | 847 CFWL_WidgetMgr* pWidgetMgr = CFWL_WidgetMgr::GetInstance(); |
939 if (!pWidgetMgr) | 848 if (!pWidgetMgr) |
940 return CFX_SizeF(); | 849 return CFX_SizeF(); |
941 | 850 |
942 CFX_SizeF szRet(m_pProperties->m_rtWidget.left, | 851 CFX_SizeF szRet(m_pProperties->m_rtWidget.left, |
943 m_pProperties->m_rtWidget.top); | 852 m_pProperties->m_rtWidget.top); |
944 | 853 |
945 IFWL_Widget* pDstWidget = GetParent(); | 854 IFWL_Widget* pDstWidget = GetParent(); |
946 while (pDstWidget && pDstWidget != pParent) { | 855 while (pDstWidget && pDstWidget != pParent) { |
947 CFX_RectF rtDst; | 856 CFX_RectF rtDst; |
948 pDstWidget->GetWidgetRect(rtDst); | 857 pDstWidget->GetWidgetRect(rtDst); |
949 szRet += CFX_SizeF(rtDst.left, rtDst.top); | 858 szRet += CFX_SizeF(rtDst.left, rtDst.top); |
950 pDstWidget = pWidgetMgr->GetParentWidget(pDstWidget); | 859 pDstWidget = pWidgetMgr->GetParentWidget(pDstWidget); |
951 } | 860 } |
952 return szRet; | 861 return szRet; |
953 } | 862 } |
954 FX_BOOL CFWL_WidgetImp::IsParent(IFWL_Widget* pParent) { | 863 |
| 864 FX_BOOL IFWL_Widget::IsParent(IFWL_Widget* pParent) { |
955 IFWL_Widget* pUpWidget = GetParent(); | 865 IFWL_Widget* pUpWidget = GetParent(); |
956 while (pUpWidget) { | 866 while (pUpWidget) { |
957 if (pUpWidget == pParent) | 867 if (pUpWidget == pParent) |
958 return TRUE; | 868 return TRUE; |
959 pUpWidget = pUpWidget->GetParent(); | 869 pUpWidget = pUpWidget->GetParent(); |
960 } | 870 } |
961 return FALSE; | 871 return FALSE; |
962 } | 872 } |
963 | 873 |
964 CFWL_WidgetImpDelegate::CFWL_WidgetImpDelegate() {} | 874 CFWL_WidgetImpDelegate::CFWL_WidgetImpDelegate() {} |
965 | 875 |
966 void CFWL_WidgetImpDelegate::OnProcessMessage(CFWL_Message* pMessage) { | 876 void CFWL_WidgetImpDelegate::OnProcessMessage(CFWL_Message* pMessage) { |
967 if (!pMessage->m_pDstTarget) | 877 if (!pMessage->m_pDstTarget) |
968 return; | 878 return; |
969 | 879 |
970 CFWL_WidgetImp* pWidget = | 880 IFWL_Widget* pWidget = pMessage->m_pDstTarget; |
971 static_cast<CFWL_WidgetImp*>(pMessage->m_pDstTarget->GetImpl()); | |
972 CFWL_MessageType dwMsgCode = pMessage->GetClassID(); | 881 CFWL_MessageType dwMsgCode = pMessage->GetClassID(); |
973 switch (dwMsgCode) { | 882 switch (dwMsgCode) { |
974 case CFWL_MessageType::Mouse: { | 883 case CFWL_MessageType::Mouse: { |
975 CFWL_MsgMouse* pMsgMouse = static_cast<CFWL_MsgMouse*>(pMessage); | 884 CFWL_MsgMouse* pMsgMouse = static_cast<CFWL_MsgMouse*>(pMessage); |
976 CFWL_EvtMouse evt; | 885 CFWL_EvtMouse evt; |
977 evt.m_pSrcTarget = pWidget->m_pInterface; | 886 evt.m_pSrcTarget = pWidget; |
978 evt.m_pDstTarget = pWidget->m_pInterface; | 887 evt.m_pDstTarget = pWidget; |
979 evt.m_dwCmd = pMsgMouse->m_dwCmd; | 888 evt.m_dwCmd = pMsgMouse->m_dwCmd; |
980 evt.m_dwFlags = pMsgMouse->m_dwFlags; | 889 evt.m_dwFlags = pMsgMouse->m_dwFlags; |
981 evt.m_fx = pMsgMouse->m_fx; | 890 evt.m_fx = pMsgMouse->m_fx; |
982 evt.m_fy = pMsgMouse->m_fy; | 891 evt.m_fy = pMsgMouse->m_fy; |
983 pWidget->DispatchEvent(&evt); | 892 pWidget->DispatchEvent(&evt); |
984 break; | 893 break; |
985 } | 894 } |
986 case CFWL_MessageType::MouseWheel: { | 895 case CFWL_MessageType::MouseWheel: { |
987 CFWL_MsgMouseWheel* pMsgMouseWheel = | 896 CFWL_MsgMouseWheel* pMsgMouseWheel = |
988 static_cast<CFWL_MsgMouseWheel*>(pMessage); | 897 static_cast<CFWL_MsgMouseWheel*>(pMessage); |
989 CFWL_EvtMouseWheel evt; | 898 CFWL_EvtMouseWheel evt; |
990 evt.m_pSrcTarget = pWidget->m_pInterface; | 899 evt.m_pSrcTarget = pWidget; |
991 evt.m_pDstTarget = pWidget->m_pInterface; | 900 evt.m_pDstTarget = pWidget; |
992 evt.m_dwFlags = pMsgMouseWheel->m_dwFlags; | 901 evt.m_dwFlags = pMsgMouseWheel->m_dwFlags; |
993 evt.m_fDeltaX = pMsgMouseWheel->m_fDeltaX; | 902 evt.m_fDeltaX = pMsgMouseWheel->m_fDeltaX; |
994 evt.m_fDeltaY = pMsgMouseWheel->m_fDeltaY; | 903 evt.m_fDeltaY = pMsgMouseWheel->m_fDeltaY; |
995 evt.m_fx = pMsgMouseWheel->m_fx; | 904 evt.m_fx = pMsgMouseWheel->m_fx; |
996 evt.m_fy = pMsgMouseWheel->m_fy; | 905 evt.m_fy = pMsgMouseWheel->m_fy; |
997 pWidget->DispatchEvent(&evt); | 906 pWidget->DispatchEvent(&evt); |
998 break; | 907 break; |
999 } | 908 } |
1000 case CFWL_MessageType::Key: { | 909 case CFWL_MessageType::Key: { |
1001 CFWL_MsgKey* pMsgKey = static_cast<CFWL_MsgKey*>(pMessage); | 910 CFWL_MsgKey* pMsgKey = static_cast<CFWL_MsgKey*>(pMessage); |
1002 CFWL_EvtKey evt; | 911 CFWL_EvtKey evt; |
1003 evt.m_pSrcTarget = pWidget->m_pInterface; | 912 evt.m_pSrcTarget = pWidget; |
1004 evt.m_pDstTarget = pWidget->m_pInterface; | 913 evt.m_pDstTarget = pWidget; |
1005 evt.m_dwKeyCode = pMsgKey->m_dwKeyCode; | 914 evt.m_dwKeyCode = pMsgKey->m_dwKeyCode; |
1006 evt.m_dwFlags = pMsgKey->m_dwFlags; | 915 evt.m_dwFlags = pMsgKey->m_dwFlags; |
1007 evt.m_dwCmd = pMsgKey->m_dwCmd; | 916 evt.m_dwCmd = pMsgKey->m_dwCmd; |
1008 pWidget->DispatchEvent(&evt); | 917 pWidget->DispatchEvent(&evt); |
1009 break; | 918 break; |
1010 } | 919 } |
1011 case CFWL_MessageType::SetFocus: { | 920 case CFWL_MessageType::SetFocus: { |
1012 CFWL_MsgSetFocus* pMsgSetFocus = static_cast<CFWL_MsgSetFocus*>(pMessage); | 921 CFWL_MsgSetFocus* pMsgSetFocus = static_cast<CFWL_MsgSetFocus*>(pMessage); |
1013 CFWL_EvtSetFocus evt; | 922 CFWL_EvtSetFocus evt; |
1014 evt.m_pSrcTarget = pMsgSetFocus->m_pDstTarget; | 923 evt.m_pSrcTarget = pMsgSetFocus->m_pDstTarget; |
1015 evt.m_pDstTarget = pMsgSetFocus->m_pDstTarget; | 924 evt.m_pDstTarget = pMsgSetFocus->m_pDstTarget; |
1016 evt.m_pSetFocus = pWidget->m_pInterface; | 925 evt.m_pSetFocus = pWidget; |
1017 pWidget->DispatchEvent(&evt); | 926 pWidget->DispatchEvent(&evt); |
1018 break; | 927 break; |
1019 } | 928 } |
1020 case CFWL_MessageType::KillFocus: { | 929 case CFWL_MessageType::KillFocus: { |
1021 CFWL_MsgKillFocus* pMsgKillFocus = | 930 CFWL_MsgKillFocus* pMsgKillFocus = |
1022 static_cast<CFWL_MsgKillFocus*>(pMessage); | 931 static_cast<CFWL_MsgKillFocus*>(pMessage); |
1023 CFWL_EvtKillFocus evt; | 932 CFWL_EvtKillFocus evt; |
1024 evt.m_pSrcTarget = pMsgKillFocus->m_pDstTarget; | 933 evt.m_pSrcTarget = pMsgKillFocus->m_pDstTarget; |
1025 evt.m_pDstTarget = pMsgKillFocus->m_pDstTarget; | 934 evt.m_pDstTarget = pMsgKillFocus->m_pDstTarget; |
1026 evt.m_pKillFocus = pWidget->m_pInterface; | 935 evt.m_pKillFocus = pWidget; |
1027 pWidget->DispatchEvent(&evt); | 936 pWidget->DispatchEvent(&evt); |
1028 break; | 937 break; |
1029 } | 938 } |
1030 default: | 939 default: |
1031 break; | 940 break; |
1032 } | 941 } |
1033 } | 942 } |
1034 | 943 |
1035 void CFWL_WidgetImpDelegate::OnProcessEvent(CFWL_Event* pEvent) {} | 944 void CFWL_WidgetImpDelegate::OnProcessEvent(CFWL_Event* pEvent) {} |
1036 | 945 |
1037 void CFWL_WidgetImpDelegate::OnDrawWidget(CFX_Graphics* pGraphics, | 946 void CFWL_WidgetImpDelegate::OnDrawWidget(CFX_Graphics* pGraphics, |
1038 const CFX_Matrix* pMatrix) { | 947 const CFX_Matrix* pMatrix) { |
1039 CFWL_EvtDraw evt; | 948 CFWL_EvtDraw evt; |
1040 evt.m_pGraphics = pGraphics; | 949 evt.m_pGraphics = pGraphics; |
1041 } | 950 } |
OLD | NEW |