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_widgetmgrimp.h" | 7 #include "xfa/fwl/core/fwl_widgetmgrimp.h" |
8 | 8 |
9 #include "xfa/fwl/core/cfwl_message.h" | 9 #include "xfa/fwl/core/cfwl_message.h" |
10 #include "xfa/fwl/core/fwl_appimp.h" | 10 #include "xfa/fwl/core/fwl_appimp.h" |
11 #include "xfa/fwl/core/fwl_noteimp.h" | 11 #include "xfa/fwl/core/fwl_noteimp.h" |
12 #include "xfa/fwl/core/fwl_widgetimp.h" | 12 #include "xfa/fwl/core/fwl_widgetimp.h" |
13 #include "xfa/fwl/core/ifwl_adapternative.h" | |
14 #include "xfa/fwl/core/ifwl_adapterwidgetmgr.h" | |
15 #include "xfa/fwl/core/ifwl_app.h" | 13 #include "xfa/fwl/core/ifwl_app.h" |
16 #include "xfa/fwl/core/ifwl_form.h" | 14 #include "xfa/fwl/core/ifwl_form.h" |
15 #include "xfa/fxfa/app/xfa_fwladapter.h" | |
16 #include "xfa/fxfa/include/xfa_ffapp.h" | |
17 | 17 |
18 FX_BOOL FWL_UseOffscreen(IFWL_Widget* pWidget) { | 18 FX_BOOL FWL_UseOffscreen(IFWL_Widget* pWidget) { |
19 #if (_FX_OS_ == _FX_MACOSX_) | 19 #if (_FX_OS_ == _FX_MACOSX_) |
20 return FALSE; | 20 return FALSE; |
21 #else | 21 #else |
22 return pWidget->GetStyles() & FWL_WGTSTYLE_Offscreen; | 22 return pWidget->GetStyles() & FWL_WGTSTYLE_Offscreen; |
23 #endif | 23 #endif |
24 } | 24 } |
25 IFWL_WidgetMgr* FWL_GetWidgetMgr() { | 25 IFWL_WidgetMgr* FWL_GetWidgetMgr() { |
26 IFWL_App* pApp = FWL_GetApp(); | 26 IFWL_App* pApp = FWL_GetApp(); |
27 if (!pApp) | 27 if (!pApp) |
28 return NULL; | 28 return NULL; |
29 return pApp->GetWidgetMgr(); | 29 return pApp->GetWidgetMgr(); |
30 } | 30 } |
31 CFWL_WidgetMgr::CFWL_WidgetMgr(IFWL_AdapterNative* pAdapterNative) | 31 CFWL_WidgetMgr::CFWL_WidgetMgr(CXFA_FFApp* pAdapterNative) : m_dwCapability(0) { |
32 : m_dwCapability(0) { | |
33 m_pDelegate = new CFWL_WidgetMgrDelegate(this); | 32 m_pDelegate = new CFWL_WidgetMgrDelegate(this); |
34 m_pAdapter = pAdapterNative->GetWidgetMgr(m_pDelegate); | 33 m_pAdapter = pAdapterNative->GetWidgetMgr(m_pDelegate); |
35 ASSERT(m_pAdapter); | 34 ASSERT(m_pAdapter); |
36 CFWL_WidgetMgrItem* pRoot = new CFWL_WidgetMgrItem; | 35 CFWL_WidgetMgrItem* pRoot = new CFWL_WidgetMgrItem; |
37 m_mapWidgetItem.SetAt(NULL, pRoot); | 36 m_mapWidgetItem.SetAt(NULL, pRoot); |
38 #if (_FX_OS_ == _FX_WIN32_DESKTOP_) || (_FX_OS_ == _FX_WIN64_) | 37 #if (_FX_OS_ == _FX_WIN32_DESKTOP_) || (_FX_OS_ == _FX_WIN64_) |
Tom Sepez
2016/04/28 16:42:12
Curious. I didn't think _FX_WIN64_ was a legitimat
dsinclair
2016/04/28 17:53:46
I think it should be WIN64_DESKTOP, will do as a f
| |
39 m_rtScreen.Reset(); | 38 m_rtScreen.Reset(); |
40 #endif | 39 #endif |
41 } | 40 } |
42 CFWL_WidgetMgr::~CFWL_WidgetMgr() { | 41 CFWL_WidgetMgr::~CFWL_WidgetMgr() { |
43 FX_POSITION ps = m_mapWidgetItem.GetStartPosition(); | 42 FX_POSITION ps = m_mapWidgetItem.GetStartPosition(); |
44 while (ps) { | 43 while (ps) { |
45 void* pWidget; | 44 void* pWidget; |
46 CFWL_WidgetMgrItem* pItem; | 45 CFWL_WidgetMgrItem* pItem; |
47 m_mapWidgetItem.GetNextAssoc(ps, pWidget, (void*&)pItem); | 46 m_mapWidgetItem.GetNextAssoc(ps, pWidget, (void*&)pItem); |
48 delete pItem; | 47 delete pItem; |
(...skipping 289 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
338 pItem->pNext->pPrevious = pItem->pPrevious; | 337 pItem->pNext->pPrevious = pItem->pPrevious; |
339 } | 338 } |
340 if (pItem->pParent->pChild == pItem) { | 339 if (pItem->pParent->pChild == pItem) { |
341 pItem->pParent->pChild = pItem->pNext; | 340 pItem->pParent->pChild = pItem->pNext; |
342 } | 341 } |
343 pItem->pNext = NULL; | 342 pItem->pNext = NULL; |
344 pItem->pPrevious = NULL; | 343 pItem->pPrevious = NULL; |
345 } | 344 } |
346 pItem->pParent = pParentItem; | 345 pItem->pParent = pParentItem; |
347 SetWidgetIndex(pChild, -1); | 346 SetWidgetIndex(pChild, -1); |
348 if (!m_pAdapter) | |
349 return; | |
350 m_pAdapter->SetParentWidget(pChild, pParent); | |
351 } | 347 } |
348 | |
352 FX_BOOL CFWL_WidgetMgr::IsChild(IFWL_Widget* pChild, IFWL_Widget* pParent) { | 349 FX_BOOL CFWL_WidgetMgr::IsChild(IFWL_Widget* pChild, IFWL_Widget* pParent) { |
353 IFWL_Widget* pTemp = pChild; | 350 IFWL_Widget* pTemp = pChild; |
354 do { | 351 do { |
355 if (pTemp == pParent) { | 352 if (pTemp == pParent) { |
356 return TRUE; | 353 return TRUE; |
357 } | 354 } |
358 pTemp = GetWidget(pTemp, FWL_WGTRELATION_Parent); | 355 pTemp = GetWidget(pTemp, FWL_WGTRELATION_Parent); |
359 } while (pTemp); | 356 } while (pTemp); |
360 return FALSE; | 357 return FALSE; |
361 } | 358 } |
362 FWL_ERR CFWL_WidgetMgr::CreateWidget_Native(IFWL_Widget* pWidget) { | |
363 if (!IsAbleNative(pWidget)) { | |
364 return FWL_ERR_Succeeded; | |
365 } | |
366 return m_pAdapter->CreateWidget(pWidget, pWidget->GetOwner()); | |
367 } | |
368 FWL_ERR CFWL_WidgetMgr::DestroyWidget_Native(IFWL_Widget* pWidget) { | |
369 if (!IsAbleNative(pWidget)) { | |
370 return FWL_ERR_Succeeded; | |
371 } | |
372 return m_pAdapter->DestroyWidget(pWidget); | |
373 } | |
374 FWL_ERR CFWL_WidgetMgr::GetWidgetRect_Native(IFWL_Widget* pWidget, | |
375 CFX_RectF& rect) { | |
376 if (!IsAbleNative(pWidget)) { | |
377 return FWL_ERR_Succeeded; | |
378 } | |
379 return m_pAdapter->GetWidgetRect(pWidget, rect); | |
380 } | |
381 FWL_ERR CFWL_WidgetMgr::SetWidgetRect_Native(IFWL_Widget* pWidget, | 359 FWL_ERR CFWL_WidgetMgr::SetWidgetRect_Native(IFWL_Widget* pWidget, |
382 const CFX_RectF& rect) { | 360 const CFX_RectF& rect) { |
383 if (FWL_UseOffscreen(pWidget)) { | 361 if (FWL_UseOffscreen(pWidget)) { |
384 CFWL_WidgetMgrItem* pItem = GetWidgetMgrItem(pWidget); | 362 CFWL_WidgetMgrItem* pItem = GetWidgetMgrItem(pWidget); |
385 pItem->iRedrawCounter++; | 363 pItem->iRedrawCounter++; |
386 if (pItem->pOffscreen) { | 364 if (pItem->pOffscreen) { |
387 CFX_RenderDevice* pDevice = pItem->pOffscreen->GetRenderDevice(); | 365 CFX_RenderDevice* pDevice = pItem->pOffscreen->GetRenderDevice(); |
388 if (pDevice && pDevice->GetBitmap()) { | 366 if (pDevice && pDevice->GetBitmap()) { |
389 CFX_DIBitmap* pBitmap = pDevice->GetBitmap(); | 367 CFX_DIBitmap* pBitmap = pDevice->GetBitmap(); |
390 if (pBitmap->GetWidth() - rect.width > 1 || | 368 if (pBitmap->GetWidth() - rect.width > 1 || |
391 pBitmap->GetHeight() - rect.height > 1) { | 369 pBitmap->GetHeight() - rect.height > 1) { |
392 delete pItem->pOffscreen; | 370 delete pItem->pOffscreen; |
393 pItem->pOffscreen = NULL; | 371 pItem->pOffscreen = NULL; |
394 } | 372 } |
395 } | 373 } |
396 } | 374 } |
397 #if (_FX_OS_ == _FX_WIN32_DESKTOP_) || (_FX_OS_ == _FX_WIN64_) | 375 #if (_FX_OS_ == _FX_WIN32_DESKTOP_) || (_FX_OS_ == _FX_WIN64_) |
398 pItem->bOutsideChanged = !m_rtScreen.Contains(rect); | 376 pItem->bOutsideChanged = !m_rtScreen.Contains(rect); |
399 #endif | 377 #endif |
400 } | 378 } |
401 return m_pAdapter->SetWidgetRect(pWidget, rect); | 379 return FWL_ERR_Succeeded; |
402 } | |
403 FWL_ERR CFWL_WidgetMgr::SetWidgetPosition_Native(IFWL_Widget* pWidget, | |
404 FX_FLOAT fx, | |
405 FX_FLOAT fy) { | |
406 return m_pAdapter->SetWidgetPosition(pWidget, fx, fy); | |
407 } | |
408 FWL_ERR CFWL_WidgetMgr::SetWidgetIcon_Native(IFWL_Widget* pWidget, | |
409 const CFX_DIBitmap* pIcon, | |
410 FX_BOOL bBig) { | |
411 return m_pAdapter->SetWidgetIcon(pWidget, pIcon, bBig); | |
412 } | |
413 FWL_ERR CFWL_WidgetMgr::SetWidgetCaption_Native( | |
414 IFWL_Widget* pWidget, | |
415 const CFX_WideStringC& wsCaption) { | |
416 return m_pAdapter->SetWidgetCaption(pWidget, wsCaption); | |
417 } | |
418 FWL_ERR CFWL_WidgetMgr::SetBorderRegion_Native(IFWL_Widget* pWidget, | |
419 CFX_Path* pPath) { | |
420 return m_pAdapter->SetBorderRegion(pWidget, pPath); | |
421 } | |
422 FWL_ERR CFWL_WidgetMgr::ShowWidget_Native(IFWL_Widget* pWidget) { | |
423 return m_pAdapter->ShowWidget(pWidget); | |
424 } | |
425 FWL_ERR CFWL_WidgetMgr::HideWidget_Native(IFWL_Widget* pWidget) { | |
426 return m_pAdapter->HideWidget(pWidget); | |
427 } | |
428 FWL_ERR CFWL_WidgetMgr::SetNormal_Native(IFWL_Widget* pWidget) { | |
429 return m_pAdapter->SetNormal(pWidget); | |
430 } | |
431 FWL_ERR CFWL_WidgetMgr::SetMaximize_Native(IFWL_Widget* pWidget) { | |
432 return m_pAdapter->SetMaximize(pWidget); | |
433 } | |
434 FWL_ERR CFWL_WidgetMgr::SetMinimize_Native(IFWL_Widget* pWidget) { | |
435 return m_pAdapter->SetMinimize(pWidget); | |
436 } | |
437 FX_BOOL CFWL_WidgetMgr::CheckMessage_Native() { | |
438 return m_pAdapter->CheckMessage(); | |
439 } | |
440 FWL_ERR CFWL_WidgetMgr::DispatchMessage_Native() { | |
441 return m_pAdapter->DispatchMessage(); | |
442 } | |
443 FX_BOOL CFWL_WidgetMgr::IsIdleMessage_Native() { | |
444 return m_pAdapter->IsIdleMessage(); | |
445 } | |
446 FWL_ERR CFWL_WidgetMgr::Exit_Native(int32_t iExitCode) { | |
447 return m_pAdapter->Exit(iExitCode); | |
448 } | |
449 FWL_ERR CFWL_WidgetMgr::CreateWidgetWithNativeId_Native(IFWL_Widget* pWidget, | |
450 void* vp) { | |
451 return m_pAdapter->CreateWidgetWithNativeId(pWidget, vp); | |
452 } | 380 } |
453 IFWL_Widget* CFWL_WidgetMgr::GetWidgetAtPoint(IFWL_Widget* parent, | 381 IFWL_Widget* CFWL_WidgetMgr::GetWidgetAtPoint(IFWL_Widget* parent, |
454 FX_FLOAT x, | 382 FX_FLOAT x, |
455 FX_FLOAT y) { | 383 FX_FLOAT y) { |
456 if (!parent) | 384 if (!parent) |
457 return NULL; | 385 return NULL; |
458 FX_FLOAT x1; | 386 FX_FLOAT x1; |
459 FX_FLOAT y1; | 387 FX_FLOAT y1; |
460 IFWL_Widget* child = GetWidget(parent, FWL_WGTRELATION_LastChild); | 388 IFWL_Widget* child = GetWidget(parent, FWL_WGTRELATION_LastChild); |
461 while (child) { | 389 while (child) { |
(...skipping 209 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
671 return !(m_dwCapability & FWL_WGTMGR_DisableThread); | 599 return !(m_dwCapability & FWL_WGTMGR_DisableThread); |
672 } | 600 } |
673 FX_BOOL CFWL_WidgetMgr::IsFormDisabled() { | 601 FX_BOOL CFWL_WidgetMgr::IsFormDisabled() { |
674 return m_dwCapability & FWL_WGTMGR_DisableForm; | 602 return m_dwCapability & FWL_WGTMGR_DisableForm; |
675 } | 603 } |
676 FX_BOOL CFWL_WidgetMgr::GetAdapterPopupPos(IFWL_Widget* pWidget, | 604 FX_BOOL CFWL_WidgetMgr::GetAdapterPopupPos(IFWL_Widget* pWidget, |
677 FX_FLOAT fMinHeight, | 605 FX_FLOAT fMinHeight, |
678 FX_FLOAT fMaxHeight, | 606 FX_FLOAT fMaxHeight, |
679 const CFX_RectF& rtAnchor, | 607 const CFX_RectF& rtAnchor, |
680 CFX_RectF& rtPopup) { | 608 CFX_RectF& rtPopup) { |
681 IFWL_AdapterWidgetMgr* pSDApapter = GetAdapterWidgetMgr(); | 609 CXFA_FWLAdapterWidgetMgr* pSDApapter = GetAdapterWidgetMgr(); |
682 return pSDApapter->GetPopupPos(pWidget, fMinHeight, fMaxHeight, rtAnchor, | 610 return pSDApapter->GetPopupPos(pWidget, fMinHeight, fMaxHeight, rtAnchor, |
683 rtPopup); | 611 rtPopup); |
684 } | 612 } |
685 CFWL_WidgetMgrDelegate::CFWL_WidgetMgrDelegate(CFWL_WidgetMgr* pWidgetMgr) | 613 CFWL_WidgetMgrDelegate::CFWL_WidgetMgrDelegate(CFWL_WidgetMgr* pWidgetMgr) |
686 : m_pWidgetMgr(pWidgetMgr) {} | 614 : m_pWidgetMgr(pWidgetMgr) {} |
687 FWL_ERR CFWL_WidgetMgrDelegate::OnSetCapability(uint32_t dwCapability) { | 615 FWL_ERR CFWL_WidgetMgrDelegate::OnSetCapability(uint32_t dwCapability) { |
688 m_pWidgetMgr->m_dwCapability = dwCapability; | 616 m_pWidgetMgr->m_dwCapability = dwCapability; |
689 return FWL_ERR_Succeeded; | 617 return FWL_ERR_Succeeded; |
690 } | 618 } |
691 int32_t CFWL_WidgetMgrDelegate::OnProcessMessageToForm(CFWL_Message* pMessage) { | 619 int32_t CFWL_WidgetMgrDelegate::OnProcessMessageToForm(CFWL_Message* pMessage) { |
(...skipping 308 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
1000 CFX_RectF temp(m_pWidgetMgr->m_rtScreen); | 928 CFX_RectF temp(m_pWidgetMgr->m_rtScreen); |
1001 temp.Deflate(50, 50); | 929 temp.Deflate(50, 50); |
1002 if (!temp.Contains(r)) { | 930 if (!temp.Contains(r)) { |
1003 return FALSE; | 931 return FALSE; |
1004 } | 932 } |
1005 pItem->bOutsideChanged = FALSE; | 933 pItem->bOutsideChanged = FALSE; |
1006 } | 934 } |
1007 #endif | 935 #endif |
1008 return pItem->iRedrawCounter == 0; | 936 return pItem->iRedrawCounter == 0; |
1009 } | 937 } |
OLD | NEW |