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 53 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
90 return static_cast<CFWL_WidgetImp*>(GetImpl())->GetStylesEx(); | 88 return static_cast<CFWL_WidgetImp*>(GetImpl())->GetStylesEx(); |
91 } | 89 } |
92 FWL_ERR IFWL_Widget::ModifyStylesEx(uint32_t dwStylesExAdded, | 90 FWL_ERR IFWL_Widget::ModifyStylesEx(uint32_t dwStylesExAdded, |
93 uint32_t dwStylesExRemoved) { | 91 uint32_t dwStylesExRemoved) { |
94 return static_cast<CFWL_WidgetImp*>(GetImpl()) | 92 return static_cast<CFWL_WidgetImp*>(GetImpl()) |
95 ->ModifyStylesEx(dwStylesExAdded, dwStylesExRemoved); | 93 ->ModifyStylesEx(dwStylesExAdded, dwStylesExRemoved); |
96 } | 94 } |
97 uint32_t IFWL_Widget::GetStates() { | 95 uint32_t IFWL_Widget::GetStates() { |
98 return static_cast<CFWL_WidgetImp*>(GetImpl())->GetStates(); | 96 return static_cast<CFWL_WidgetImp*>(GetImpl())->GetStates(); |
99 } | 97 } |
100 FWL_ERR IFWL_Widget::SetStates(uint32_t dwStates, FX_BOOL bSet) { | 98 void IFWL_Widget::SetStates(uint32_t dwStates, FX_BOOL bSet) { |
101 return static_cast<CFWL_WidgetImp*>(GetImpl())->SetStates(dwStates, bSet); | 99 static_cast<CFWL_WidgetImp*>(GetImpl())->SetStates(dwStates, bSet); |
102 } | 100 } |
103 FWL_ERR IFWL_Widget::SetPrivateData(void* module_id, | 101 FWL_ERR IFWL_Widget::SetPrivateData(void* module_id, |
104 void* pData, | 102 void* pData, |
105 PD_CALLBACK_FREEDATA callback) { | 103 PD_CALLBACK_FREEDATA callback) { |
106 return static_cast<CFWL_WidgetImp*>(GetImpl()) | 104 return static_cast<CFWL_WidgetImp*>(GetImpl()) |
107 ->SetPrivateData(module_id, pData, callback); | 105 ->SetPrivateData(module_id, pData, callback); |
108 } | 106 } |
109 void* IFWL_Widget::GetPrivateData(void* module_id) { | 107 void* IFWL_Widget::GetPrivateData(void* module_id) { |
110 return static_cast<CFWL_WidgetImp*>(GetImpl())->GetPrivateData(module_id); | 108 return static_cast<CFWL_WidgetImp*>(GetImpl())->GetPrivateData(module_id); |
111 } | 109 } |
(...skipping 46 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 |
172 if (!pAdapterThread) | 170 SetOwnerApp(static_cast<CFWL_AppImp*>(FWL_GetApp()->GetImpl())); |
173 return FWL_ERR_Indefinite; | |
174 SetOwnerApp( | |
175 static_cast<CFWL_AppImp*>(pAdapterThread->GetCurrentThread()->GetImpl())); | |
176 IFWL_Widget* pParent = m_pProperties->m_pParent; | 171 IFWL_Widget* pParent = m_pProperties->m_pParent; |
177 m_pWidgetMgr->InsertWidget(pParent, m_pInterface); | 172 m_pWidgetMgr->InsertWidget(pParent, m_pInterface); |
178 if (!IsChild()) { | 173 if (!IsChild()) { |
179 { | 174 IFWL_Widget* pOwner = m_pProperties->m_pOwner; |
180 IFWL_Widget* pOwner = m_pProperties->m_pOwner; | 175 if (pOwner) |
181 if (pOwner) { | 176 m_pWidgetMgr->SetOwner(pOwner, m_pInterface); |
182 m_pWidgetMgr->SetOwner(pOwner, m_pInterface); | |
183 } | |
184 } | |
185 m_pWidgetMgr->CreateWidget_Native(m_pInterface); | |
186 } | 177 } |
187 return FWL_ERR_Succeeded; | 178 return FWL_ERR_Succeeded; |
188 } | 179 } |
189 | 180 |
190 FWL_ERR CFWL_WidgetImp::Finalize() { | 181 FWL_ERR CFWL_WidgetImp::Finalize() { |
191 NotifyDriver(); | 182 NotifyDriver(); |
192 if (!IsChild()) | |
193 m_pWidgetMgr->DestroyWidget_Native(m_pInterface); | |
194 | |
195 m_pWidgetMgr->RemoveWidget(m_pInterface); | 183 m_pWidgetMgr->RemoveWidget(m_pInterface); |
196 return FWL_ERR_Succeeded; | 184 return FWL_ERR_Succeeded; |
197 } | 185 } |
198 | 186 |
199 FWL_ERR CFWL_WidgetImp::GetClassName(CFX_WideString& wsClass) const { | 187 FWL_ERR CFWL_WidgetImp::GetClassName(CFX_WideString& wsClass) const { |
200 wsClass.clear(); | 188 wsClass.clear(); |
201 return FWL_ERR_Succeeded; | 189 return FWL_ERR_Succeeded; |
202 } | 190 } |
203 | 191 |
204 uint32_t CFWL_WidgetImp::GetClassID() const { | 192 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, | 295 static void NotifyHideChildWidget(IFWL_WidgetMgr* widgetMgr, |
308 IFWL_Widget* widget, | 296 IFWL_Widget* widget, |
309 CFWL_NoteDriver* noteDriver) { | 297 CFWL_NoteDriver* noteDriver) { |
310 IFWL_Widget* child = widgetMgr->GetWidget(widget, FWL_WGTRELATION_FirstChild); | 298 IFWL_Widget* child = widgetMgr->GetWidget(widget, FWL_WGTRELATION_FirstChild); |
311 while (child) { | 299 while (child) { |
312 noteDriver->NotifyTargetHide(child); | 300 noteDriver->NotifyTargetHide(child); |
313 NotifyHideChildWidget(widgetMgr, child, noteDriver); | 301 NotifyHideChildWidget(widgetMgr, child, noteDriver); |
314 child = widgetMgr->GetWidget(child, FWL_WGTRELATION_NextSibling); | 302 child = widgetMgr->GetWidget(child, FWL_WGTRELATION_NextSibling); |
315 } | 303 } |
316 } | 304 } |
317 FWL_ERR CFWL_WidgetImp::SetStates(uint32_t dwStates, FX_BOOL bSet) { | 305 void CFWL_WidgetImp::SetStates(uint32_t dwStates, FX_BOOL bSet) { |
318 bSet ? (m_pProperties->m_dwStates |= dwStates) | 306 bSet ? (m_pProperties->m_dwStates |= dwStates) |
319 : (m_pProperties->m_dwStates &= ~dwStates); | 307 : (m_pProperties->m_dwStates &= ~dwStates); |
320 FWL_ERR ret = FWL_ERR_Succeeded; | 308 if (!(dwStates & FWL_WGTSTATE_Invisible) || !bSet) |
321 if (dwStates & FWL_WGTSTATE_Invisible) { | 309 return; |
322 if (bSet) { | 310 |
323 ret = m_pWidgetMgr->HideWidget_Native(m_pInterface); | 311 CFWL_NoteDriver* noteDriver = |
324 CFWL_NoteDriver* noteDriver = | 312 static_cast<CFWL_NoteDriver*>(GetOwnerApp()->GetNoteDriver()); |
325 static_cast<CFWL_NoteDriver*>(GetOwnerApp()->GetNoteDriver()); | 313 IFWL_WidgetMgr* widgetMgr = FWL_GetWidgetMgr(); |
326 IFWL_WidgetMgr* widgetMgr = FWL_GetWidgetMgr(); | 314 noteDriver->NotifyTargetHide(m_pInterface); |
327 noteDriver->NotifyTargetHide(m_pInterface); | 315 IFWL_Widget* child = |
328 IFWL_Widget* child = | 316 widgetMgr->GetWidget(m_pInterface, FWL_WGTRELATION_FirstChild); |
329 widgetMgr->GetWidget(m_pInterface, FWL_WGTRELATION_FirstChild); | 317 while (child) { |
330 while (child) { | 318 noteDriver->NotifyTargetHide(child); |
331 noteDriver->NotifyTargetHide(child); | 319 NotifyHideChildWidget(widgetMgr, child, noteDriver); |
332 NotifyHideChildWidget(widgetMgr, child, noteDriver); | 320 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 } | 321 } |
339 return ret; | 322 return; |
340 } | 323 } |
341 FWL_ERR CFWL_WidgetImp::SetPrivateData(void* module_id, | 324 FWL_ERR CFWL_WidgetImp::SetPrivateData(void* module_id, |
342 void* pData, | 325 void* pData, |
343 PD_CALLBACK_FREEDATA callback) { | 326 PD_CALLBACK_FREEDATA callback) { |
344 if (!m_pPrivateData) { | 327 if (!m_pPrivateData) { |
345 m_pPrivateData = new CFX_PrivateData; | 328 m_pPrivateData = new CFX_PrivateData; |
346 } | 329 } |
347 m_pPrivateData->SetPrivateData(module_id, pData, callback); | 330 m_pPrivateData->SetPrivateData(module_id, pData, callback); |
348 return FWL_ERR_Succeeded; | 331 return FWL_ERR_Succeeded; |
349 } | 332 } |
(...skipping 61 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
411 m.TransformPoint(fx, fy); | 394 m.TransformPoint(fx, fy); |
412 } | 395 } |
413 IFWL_Widget* form1 = | 396 IFWL_Widget* form1 = |
414 m_pWidgetMgr->GetWidget(m_pInterface, FWL_WGTRELATION_SystemForm); | 397 m_pWidgetMgr->GetWidget(m_pInterface, FWL_WGTRELATION_SystemForm); |
415 if (!form1) | 398 if (!form1) |
416 return FWL_ERR_Indefinite; | 399 return FWL_ERR_Indefinite; |
417 if (!pWidget) { | 400 if (!pWidget) { |
418 form1->GetWidgetRect(r); | 401 form1->GetWidgetRect(r); |
419 fx += r.left; | 402 fx += r.left; |
420 fy += r.top; | 403 fy += r.top; |
421 #ifdef FWL_UseMacSystemBorder | |
422 if (form1->GetStyles() & FWL_WGTSTYLE_Caption) { | |
423 FX_FLOAT l, t, r, b; | |
424 l = t = r = b = 0; | |
425 FWL_GetAdapterWidgetMgr()->GetSystemBorder(l, t, r, b); | |
426 fy += t; | |
427 } | |
428 #endif | |
429 return FWL_ERR_Succeeded; | 404 return FWL_ERR_Succeeded; |
430 } | 405 } |
431 IFWL_Widget* form2 = | 406 IFWL_Widget* form2 = |
432 m_pWidgetMgr->GetWidget(pWidget, FWL_WGTRELATION_SystemForm); | 407 m_pWidgetMgr->GetWidget(pWidget, FWL_WGTRELATION_SystemForm); |
433 if (!form2) | 408 if (!form2) |
434 return FWL_ERR_Indefinite; | 409 return FWL_ERR_Indefinite; |
435 if (form1 != form2) { | 410 if (form1 != form2) { |
436 form1->GetWidgetRect(r); | 411 form1->GetWidgetRect(r); |
437 fx += r.left; | 412 fx += r.left; |
438 fy += r.top; | 413 fy += r.top; |
439 form2->GetWidgetRect(r); | 414 form2->GetWidgetRect(r); |
440 fx -= r.left; | 415 fx -= r.left; |
441 fy -= r.top; | 416 fy -= r.top; |
442 #ifdef FWL_UseMacSystemBorder | |
443 if ((form1->GetStyles() & FWL_WGTSTYLE_Caption) != | |
444 (form2->GetStyles() & FWL_WGTSTYLE_Caption)) { | |
445 FX_FLOAT l, t, r, b; | |
446 l = t = r = b = 0; | |
447 FWL_GetAdapterWidgetMgr()->GetSystemBorder(l, t, r, b); | |
448 (form1->GetStyles() & FWL_WGTSTYLE_Caption) ? (fy += t) : (fy -= t); | |
449 } | |
450 #endif | |
451 } | 417 } |
452 parent = pWidget->GetParent(); | 418 parent = pWidget->GetParent(); |
453 if (parent) { | 419 if (parent) { |
454 pWidget->GetMatrix(m, TRUE); | 420 pWidget->GetMatrix(m, TRUE); |
455 CFX_Matrix m1; | 421 CFX_Matrix m1; |
456 m1.SetIdentity(); | 422 m1.SetIdentity(); |
457 m1.SetReverse(m); | 423 m1.SetReverse(m); |
458 m1.TransformPoint(fx, fy); | 424 m1.TransformPoint(fx, fy); |
459 pWidget->GetWidgetRect(r); | 425 pWidget->GetWidgetRect(r); |
460 fx -= r.left; | 426 fx -= r.left; |
(...skipping 609 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
1070 FWL_ERR CFWL_WidgetImpDelegate::OnProcessEvent(CFWL_Event* pEvent) { | 1036 FWL_ERR CFWL_WidgetImpDelegate::OnProcessEvent(CFWL_Event* pEvent) { |
1071 return FWL_ERR_Succeeded; | 1037 return FWL_ERR_Succeeded; |
1072 } | 1038 } |
1073 | 1039 |
1074 FWL_ERR CFWL_WidgetImpDelegate::OnDrawWidget(CFX_Graphics* pGraphics, | 1040 FWL_ERR CFWL_WidgetImpDelegate::OnDrawWidget(CFX_Graphics* pGraphics, |
1075 const CFX_Matrix* pMatrix) { | 1041 const CFX_Matrix* pMatrix) { |
1076 CFWL_EvtDraw evt; | 1042 CFWL_EvtDraw evt; |
1077 evt.m_pGraphics = pGraphics; | 1043 evt.m_pGraphics = pGraphics; |
1078 return FWL_ERR_Succeeded; | 1044 return FWL_ERR_Succeeded; |
1079 } | 1045 } |
OLD | NEW |