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/fwl_widgetimp.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" | 12 #include "xfa/fwl/basewidget/ifwl_combobox.h" |
13 #include "xfa/fwl/basewidget/ifwl_datetimepicker.h" | 13 #include "xfa/fwl/basewidget/ifwl_datetimepicker.h" |
14 #include "xfa/fwl/core/cfwl_message.h" | 14 #include "xfa/fwl/core/cfwl_message.h" |
15 #include "xfa/fwl/core/cfwl_themebackground.h" | 15 #include "xfa/fwl/core/cfwl_themebackground.h" |
16 #include "xfa/fwl/core/cfwl_themepart.h" | 16 #include "xfa/fwl/core/cfwl_themepart.h" |
17 #include "xfa/fwl/core/cfwl_themetext.h" | 17 #include "xfa/fwl/core/cfwl_themetext.h" |
18 #include "xfa/fwl/core/fwl_appimp.h" | 18 #include "xfa/fwl/core/fwl_appimp.h" |
19 #include "xfa/fwl/core/fwl_noteimp.h" | 19 #include "xfa/fwl/core/fwl_noteimp.h" |
20 #include "xfa/fwl/core/fwl_widgetmgrimp.h" | 20 #include "xfa/fwl/core/fwl_widgetmgrimp.h" |
21 #include "xfa/fwl/core/ifwl_adapternative.h" | |
22 #include "xfa/fwl/core/ifwl_adapterthreadmgr.h" | |
23 #include "xfa/fwl/core/ifwl_adapterwidgetmgr.h" | |
24 #include "xfa/fwl/core/ifwl_app.h" | 21 #include "xfa/fwl/core/ifwl_app.h" |
25 #include "xfa/fwl/core/ifwl_form.h" | 22 #include "xfa/fwl/core/ifwl_form.h" |
26 #include "xfa/fwl/core/ifwl_themeprovider.h" | 23 #include "xfa/fwl/core/ifwl_themeprovider.h" |
24 #include "xfa/fxfa/include/xfa_ffapp.h" | |
27 | 25 |
28 #define FWL_CLASSHASH_Menu 3957949655 | 26 #define FWL_CLASSHASH_Menu 3957949655 |
29 #define FWL_STYLEEXT_MNU_Vert (1L << 0) | 27 #define FWL_STYLEEXT_MNU_Vert (1L << 0) |
30 | 28 |
31 IFWL_Widget::~IFWL_Widget() {} | 29 IFWL_Widget::~IFWL_Widget() {} |
32 | 30 |
33 FWL_ERR IFWL_Widget::GetClassName(CFX_WideString& wsClass) const { | 31 FWL_ERR IFWL_Widget::GetClassName(CFX_WideString& wsClass) const { |
34 return m_pImpl->GetClassName(wsClass); | 32 return m_pImpl->GetClassName(wsClass); |
35 } | 33 } |
36 | 34 |
(...skipping 121 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
158 return static_cast<CFWL_WidgetImp*>(GetImpl())->GetOwnerApp(); | 156 return static_cast<CFWL_WidgetImp*>(GetImpl())->GetOwnerApp(); |
159 } | 157 } |
160 CFX_SizeF IFWL_Widget::GetOffsetFromParent(IFWL_Widget* pParent) { | 158 CFX_SizeF IFWL_Widget::GetOffsetFromParent(IFWL_Widget* pParent) { |
161 return static_cast<CFWL_WidgetImp*>(GetImpl())->GetOffsetFromParent(pParent); | 159 return static_cast<CFWL_WidgetImp*>(GetImpl())->GetOffsetFromParent(pParent); |
162 } | 160 } |
163 | 161 |
164 FWL_ERR CFWL_WidgetImp::Initialize() { | 162 FWL_ERR CFWL_WidgetImp::Initialize() { |
165 IFWL_App* pApp = FWL_GetApp(); | 163 IFWL_App* pApp = FWL_GetApp(); |
166 if (!pApp) | 164 if (!pApp) |
167 return FWL_ERR_Indefinite; | 165 return FWL_ERR_Indefinite; |
168 IFWL_AdapterNative* pAdapter = pApp->GetAdapterNative(); | 166 CXFA_FFApp* pAdapter = pApp->GetAdapterNative(); |
169 if (!pAdapter) | 167 if (!pAdapter) |
170 return FWL_ERR_Indefinite; | 168 return FWL_ERR_Indefinite; |
171 IFWL_AdapterThreadMgr* pAdapterThread = pAdapter->GetThreadMgr(); | 169 SetOwnerApp(static_cast<CFWL_AppImp*>(FWL_GetApp()->GetImpl())); |
172 if (!pAdapterThread) | |
173 return FWL_ERR_Indefinite; | |
174 SetOwnerApp( | |
175 static_cast<CFWL_AppImp*>(pAdapterThread->GetCurrentThread()->GetImpl())); | |
176 IFWL_Widget* pParent = m_pProperties->m_pParent; | 170 IFWL_Widget* pParent = m_pProperties->m_pParent; |
177 m_pWidgetMgr->InsertWidget(pParent, m_pInterface); | 171 m_pWidgetMgr->InsertWidget(pParent, m_pInterface); |
178 if (!IsChild()) { | 172 if (!IsChild()) { |
179 { | 173 IFWL_Widget* pOwner = m_pProperties->m_pOwner; |
180 IFWL_Widget* pOwner = m_pProperties->m_pOwner; | 174 if (pOwner) |
181 if (pOwner) { | 175 m_pWidgetMgr->SetOwner(pOwner, m_pInterface); |
182 m_pWidgetMgr->SetOwner(pOwner, m_pInterface); | |
183 } | |
184 } | |
185 m_pWidgetMgr->CreateWidget_Native(m_pInterface); | |
186 } | 176 } |
187 return FWL_ERR_Succeeded; | 177 return FWL_ERR_Succeeded; |
188 } | 178 } |
189 | 179 |
190 FWL_ERR CFWL_WidgetImp::Finalize() { | 180 FWL_ERR CFWL_WidgetImp::Finalize() { |
191 NotifyDriver(); | 181 NotifyDriver(); |
192 if (!IsChild()) | |
193 m_pWidgetMgr->DestroyWidget_Native(m_pInterface); | |
194 | |
195 m_pWidgetMgr->RemoveWidget(m_pInterface); | 182 m_pWidgetMgr->RemoveWidget(m_pInterface); |
196 return FWL_ERR_Succeeded; | 183 return FWL_ERR_Succeeded; |
197 } | 184 } |
198 | 185 |
199 FWL_ERR CFWL_WidgetImp::GetClassName(CFX_WideString& wsClass) const { | 186 FWL_ERR CFWL_WidgetImp::GetClassName(CFX_WideString& wsClass) const { |
200 wsClass.clear(); | 187 wsClass.clear(); |
201 return FWL_ERR_Succeeded; | 188 return FWL_ERR_Succeeded; |
202 } | 189 } |
203 | 190 |
204 uint32_t CFWL_WidgetImp::GetClassID() const { | 191 uint32_t CFWL_WidgetImp::GetClassID() const { |
(...skipping 102 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
307 static void NotifyHideChildWidget(IFWL_WidgetMgr* widgetMgr, | 294 static void NotifyHideChildWidget(IFWL_WidgetMgr* widgetMgr, |
308 IFWL_Widget* widget, | 295 IFWL_Widget* widget, |
309 CFWL_NoteDriver* noteDriver) { | 296 CFWL_NoteDriver* noteDriver) { |
310 IFWL_Widget* child = widgetMgr->GetWidget(widget, FWL_WGTRELATION_FirstChild); | 297 IFWL_Widget* child = widgetMgr->GetWidget(widget, FWL_WGTRELATION_FirstChild); |
311 while (child) { | 298 while (child) { |
312 noteDriver->NotifyTargetHide(child); | 299 noteDriver->NotifyTargetHide(child); |
313 NotifyHideChildWidget(widgetMgr, child, noteDriver); | 300 NotifyHideChildWidget(widgetMgr, child, noteDriver); |
314 child = widgetMgr->GetWidget(child, FWL_WGTRELATION_NextSibling); | 301 child = widgetMgr->GetWidget(child, FWL_WGTRELATION_NextSibling); |
315 } | 302 } |
316 } | 303 } |
317 FWL_ERR CFWL_WidgetImp::SetStates(uint32_t dwStates, FX_BOOL bSet) { | 304 FWL_ERR CFWL_WidgetImp::SetStates(uint32_t dwStates, FX_BOOL bSet) { |
Tom Sepez
2016/04/28 16:42:12
nit: always success? can this be void?
dsinclair
2016/04/28 17:53:46
Done.
| |
318 bSet ? (m_pProperties->m_dwStates |= dwStates) | 305 bSet ? (m_pProperties->m_dwStates |= dwStates) |
319 : (m_pProperties->m_dwStates &= ~dwStates); | 306 : (m_pProperties->m_dwStates &= ~dwStates); |
320 FWL_ERR ret = FWL_ERR_Succeeded; | 307 if (!(dwStates & FWL_WGTSTATE_Invisible) || !bSet) |
321 if (dwStates & FWL_WGTSTATE_Invisible) { | 308 return FWL_ERR_Succeeded; |
322 if (bSet) { | 309 |
323 ret = m_pWidgetMgr->HideWidget_Native(m_pInterface); | 310 CFWL_NoteDriver* noteDriver = |
324 CFWL_NoteDriver* noteDriver = | 311 static_cast<CFWL_NoteDriver*>(GetOwnerApp()->GetNoteDriver()); |
325 static_cast<CFWL_NoteDriver*>(GetOwnerApp()->GetNoteDriver()); | 312 IFWL_WidgetMgr* widgetMgr = FWL_GetWidgetMgr(); |
326 IFWL_WidgetMgr* widgetMgr = FWL_GetWidgetMgr(); | 313 noteDriver->NotifyTargetHide(m_pInterface); |
327 noteDriver->NotifyTargetHide(m_pInterface); | 314 IFWL_Widget* child = |
328 IFWL_Widget* child = | 315 widgetMgr->GetWidget(m_pInterface, FWL_WGTRELATION_FirstChild); |
329 widgetMgr->GetWidget(m_pInterface, FWL_WGTRELATION_FirstChild); | 316 while (child) { |
330 while (child) { | 317 noteDriver->NotifyTargetHide(child); |
331 noteDriver->NotifyTargetHide(child); | 318 NotifyHideChildWidget(widgetMgr, child, noteDriver); |
332 NotifyHideChildWidget(widgetMgr, child, noteDriver); | 319 child = widgetMgr->GetWidget(child, FWL_WGTRELATION_NextSibling); |
333 child = widgetMgr->GetWidget(child, FWL_WGTRELATION_NextSibling); | |
334 } | |
335 } else { | |
336 ret = m_pWidgetMgr->ShowWidget_Native(m_pInterface); | |
337 } | |
338 } | 320 } |
339 return ret; | 321 return FWL_ERR_Succeeded; |
340 } | 322 } |
341 FWL_ERR CFWL_WidgetImp::SetPrivateData(void* module_id, | 323 FWL_ERR CFWL_WidgetImp::SetPrivateData(void* module_id, |
342 void* pData, | 324 void* pData, |
343 PD_CALLBACK_FREEDATA callback) { | 325 PD_CALLBACK_FREEDATA callback) { |
344 if (!m_pPrivateData) { | 326 if (!m_pPrivateData) { |
345 m_pPrivateData = new CFX_PrivateData; | 327 m_pPrivateData = new CFX_PrivateData; |
346 } | 328 } |
347 m_pPrivateData->SetPrivateData(module_id, pData, callback); | 329 m_pPrivateData->SetPrivateData(module_id, pData, callback); |
348 return FWL_ERR_Succeeded; | 330 return FWL_ERR_Succeeded; |
349 } | 331 } |
(...skipping 723 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
1073 FWL_ERR CFWL_WidgetImpDelegate::OnProcessEvent(CFWL_Event* pEvent) { | 1055 FWL_ERR CFWL_WidgetImpDelegate::OnProcessEvent(CFWL_Event* pEvent) { |
1074 return FWL_ERR_Succeeded; | 1056 return FWL_ERR_Succeeded; |
1075 } | 1057 } |
1076 | 1058 |
1077 FWL_ERR CFWL_WidgetImpDelegate::OnDrawWidget(CFX_Graphics* pGraphics, | 1059 FWL_ERR CFWL_WidgetImpDelegate::OnDrawWidget(CFX_Graphics* pGraphics, |
1078 const CFX_Matrix* pMatrix) { | 1060 const CFX_Matrix* pMatrix) { |
1079 CFWL_EvtDraw evt; | 1061 CFWL_EvtDraw evt; |
1080 evt.m_pGraphics = pGraphics; | 1062 evt.m_pGraphics = pGraphics; |
1081 return FWL_ERR_Succeeded; | 1063 return FWL_ERR_Succeeded; |
1082 } | 1064 } |
OLD | NEW |