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 namespace { | 18 namespace { |
19 | 19 |
20 const int kNeedRepaintHitPoints = 12; | 20 const int kNeedRepaintHitPoints = 12; |
21 const int kNeedRepaintHitPiece = 3; | 21 const int kNeedRepaintHitPiece = 3; |
22 | 22 |
23 struct FWL_NEEDREPAINTHITDATA { | 23 struct FWL_NEEDREPAINTHITDATA { |
24 CFX_PointF hitPoint; | 24 CFX_PointF hitPoint; |
25 bool bNotNeedRepaint; | 25 bool bNotNeedRepaint; |
26 bool bNotContainByDirty; | 26 bool bNotContainByDirty; |
27 }; | 27 }; |
28 | 28 |
29 } // namespace | 29 } // namespace |
30 | 30 |
31 FX_BOOL FWL_UseOffscreen(IFWL_Widget* pWidget) { | 31 FX_BOOL FWL_UseOffscreen(IFWL_Widget* pWidget) { |
32 #if (_FX_OS_ == _FX_MACOSX_) | 32 #if (_FX_OS_ == _FX_MACOSX_) |
33 return FALSE; | 33 return FALSE; |
34 #else | 34 #else |
35 return pWidget->GetStyles() & FWL_WGTSTYLE_Offscreen; | 35 return pWidget->GetStyles() & FWL_WGTSTYLE_Offscreen; |
36 #endif | 36 #endif |
37 } | 37 } |
38 | 38 |
39 IFWL_WidgetMgr* FWL_GetWidgetMgr() { | 39 IFWL_WidgetMgr* FWL_GetWidgetMgr() { |
40 IFWL_App* pApp = FWL_GetApp(); | 40 IFWL_App* pApp = FWL_GetApp(); |
41 if (!pApp) | 41 if (!pApp) |
42 return NULL; | 42 return NULL; |
43 return pApp->GetWidgetMgr(); | 43 return pApp->GetWidgetMgr(); |
44 } | 44 } |
45 | 45 |
46 CFWL_WidgetMgr::CFWL_WidgetMgr(IFWL_AdapterNative* pAdapterNative) | 46 CFWL_WidgetMgr::CFWL_WidgetMgr(CXFA_FFApp* pAdapterNative) : m_dwCapability(0) { |
47 : m_dwCapability(0) { | |
48 m_pDelegate = new CFWL_WidgetMgrDelegate(this); | 47 m_pDelegate = new CFWL_WidgetMgrDelegate(this); |
49 m_pAdapter = pAdapterNative->GetWidgetMgr(m_pDelegate); | 48 m_pAdapter = pAdapterNative->GetWidgetMgr(m_pDelegate); |
50 ASSERT(m_pAdapter); | 49 ASSERT(m_pAdapter); |
51 CFWL_WidgetMgrItem* pRoot = new CFWL_WidgetMgrItem; | 50 CFWL_WidgetMgrItem* pRoot = new CFWL_WidgetMgrItem; |
52 m_mapWidgetItem.SetAt(NULL, pRoot); | 51 m_mapWidgetItem.SetAt(NULL, pRoot); |
53 | 52 |
54 #if (_FX_OS_ == _FX_WIN32_DESKTOP_) || (_FX_OS_ == _FX_WIN64_) | 53 #if (_FX_OS_ == _FX_WIN32_DESKTOP_) || (_FX_OS_ == _FX_WIN64_) |
55 m_rtScreen.Reset(); | 54 m_rtScreen.Reset(); |
56 #endif | 55 #endif |
57 } | 56 } |
(...skipping 295 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
353 pItem->pNext->pPrevious = pItem->pPrevious; | 352 pItem->pNext->pPrevious = pItem->pPrevious; |
354 } | 353 } |
355 if (pItem->pParent->pChild == pItem) { | 354 if (pItem->pParent->pChild == pItem) { |
356 pItem->pParent->pChild = pItem->pNext; | 355 pItem->pParent->pChild = pItem->pNext; |
357 } | 356 } |
358 pItem->pNext = NULL; | 357 pItem->pNext = NULL; |
359 pItem->pPrevious = NULL; | 358 pItem->pPrevious = NULL; |
360 } | 359 } |
361 pItem->pParent = pParentItem; | 360 pItem->pParent = pParentItem; |
362 SetWidgetIndex(pChild, -1); | 361 SetWidgetIndex(pChild, -1); |
363 if (!m_pAdapter) | |
364 return; | |
365 m_pAdapter->SetParentWidget(pChild, pParent); | |
366 } | 362 } |
| 363 |
367 FX_BOOL CFWL_WidgetMgr::IsChild(IFWL_Widget* pChild, IFWL_Widget* pParent) { | 364 FX_BOOL CFWL_WidgetMgr::IsChild(IFWL_Widget* pChild, IFWL_Widget* pParent) { |
368 IFWL_Widget* pTemp = pChild; | 365 IFWL_Widget* pTemp = pChild; |
369 do { | 366 do { |
370 if (pTemp == pParent) { | 367 if (pTemp == pParent) { |
371 return TRUE; | 368 return TRUE; |
372 } | 369 } |
373 pTemp = GetWidget(pTemp, FWL_WGTRELATION_Parent); | 370 pTemp = GetWidget(pTemp, FWL_WGTRELATION_Parent); |
374 } while (pTemp); | 371 } while (pTemp); |
375 return FALSE; | 372 return FALSE; |
376 } | 373 } |
377 FWL_ERR CFWL_WidgetMgr::CreateWidget_Native(IFWL_Widget* pWidget) { | |
378 if (!IsAbleNative(pWidget)) { | |
379 return FWL_ERR_Succeeded; | |
380 } | |
381 return m_pAdapter->CreateWidget(pWidget, pWidget->GetOwner()); | |
382 } | |
383 FWL_ERR CFWL_WidgetMgr::DestroyWidget_Native(IFWL_Widget* pWidget) { | |
384 if (!IsAbleNative(pWidget)) { | |
385 return FWL_ERR_Succeeded; | |
386 } | |
387 return m_pAdapter->DestroyWidget(pWidget); | |
388 } | |
389 FWL_ERR CFWL_WidgetMgr::GetWidgetRect_Native(IFWL_Widget* pWidget, | |
390 CFX_RectF& rect) { | |
391 if (!IsAbleNative(pWidget)) { | |
392 return FWL_ERR_Succeeded; | |
393 } | |
394 return m_pAdapter->GetWidgetRect(pWidget, rect); | |
395 } | |
396 FWL_ERR CFWL_WidgetMgr::SetWidgetRect_Native(IFWL_Widget* pWidget, | 374 FWL_ERR CFWL_WidgetMgr::SetWidgetRect_Native(IFWL_Widget* pWidget, |
397 const CFX_RectF& rect) { | 375 const CFX_RectF& rect) { |
398 if (FWL_UseOffscreen(pWidget)) { | 376 if (FWL_UseOffscreen(pWidget)) { |
399 CFWL_WidgetMgrItem* pItem = GetWidgetMgrItem(pWidget); | 377 CFWL_WidgetMgrItem* pItem = GetWidgetMgrItem(pWidget); |
400 pItem->iRedrawCounter++; | 378 pItem->iRedrawCounter++; |
401 if (pItem->pOffscreen) { | 379 if (pItem->pOffscreen) { |
402 CFX_RenderDevice* pDevice = pItem->pOffscreen->GetRenderDevice(); | 380 CFX_RenderDevice* pDevice = pItem->pOffscreen->GetRenderDevice(); |
403 if (pDevice && pDevice->GetBitmap()) { | 381 if (pDevice && pDevice->GetBitmap()) { |
404 CFX_DIBitmap* pBitmap = pDevice->GetBitmap(); | 382 CFX_DIBitmap* pBitmap = pDevice->GetBitmap(); |
405 if (pBitmap->GetWidth() - rect.width > 1 || | 383 if (pBitmap->GetWidth() - rect.width > 1 || |
406 pBitmap->GetHeight() - rect.height > 1) { | 384 pBitmap->GetHeight() - rect.height > 1) { |
407 delete pItem->pOffscreen; | 385 delete pItem->pOffscreen; |
408 pItem->pOffscreen = NULL; | 386 pItem->pOffscreen = NULL; |
409 } | 387 } |
410 } | 388 } |
411 } | 389 } |
412 #if (_FX_OS_ == _FX_WIN32_DESKTOP_) || (_FX_OS_ == _FX_WIN64_) | 390 #if (_FX_OS_ == _FX_WIN32_DESKTOP_) || (_FX_OS_ == _FX_WIN64_) |
413 pItem->bOutsideChanged = !m_rtScreen.Contains(rect); | 391 pItem->bOutsideChanged = !m_rtScreen.Contains(rect); |
414 #endif | 392 #endif |
415 } | 393 } |
416 return m_pAdapter->SetWidgetRect(pWidget, rect); | 394 return FWL_ERR_Succeeded; |
417 } | |
418 FWL_ERR CFWL_WidgetMgr::SetWidgetPosition_Native(IFWL_Widget* pWidget, | |
419 FX_FLOAT fx, | |
420 FX_FLOAT fy) { | |
421 return m_pAdapter->SetWidgetPosition(pWidget, fx, fy); | |
422 } | |
423 FWL_ERR CFWL_WidgetMgr::SetWidgetIcon_Native(IFWL_Widget* pWidget, | |
424 const CFX_DIBitmap* pIcon, | |
425 FX_BOOL bBig) { | |
426 return m_pAdapter->SetWidgetIcon(pWidget, pIcon, bBig); | |
427 } | |
428 FWL_ERR CFWL_WidgetMgr::SetWidgetCaption_Native( | |
429 IFWL_Widget* pWidget, | |
430 const CFX_WideStringC& wsCaption) { | |
431 return m_pAdapter->SetWidgetCaption(pWidget, wsCaption); | |
432 } | |
433 FWL_ERR CFWL_WidgetMgr::SetBorderRegion_Native(IFWL_Widget* pWidget, | |
434 CFX_Path* pPath) { | |
435 return m_pAdapter->SetBorderRegion(pWidget, pPath); | |
436 } | |
437 FWL_ERR CFWL_WidgetMgr::ShowWidget_Native(IFWL_Widget* pWidget) { | |
438 return m_pAdapter->ShowWidget(pWidget); | |
439 } | |
440 FWL_ERR CFWL_WidgetMgr::HideWidget_Native(IFWL_Widget* pWidget) { | |
441 return m_pAdapter->HideWidget(pWidget); | |
442 } | |
443 FWL_ERR CFWL_WidgetMgr::SetNormal_Native(IFWL_Widget* pWidget) { | |
444 return m_pAdapter->SetNormal(pWidget); | |
445 } | |
446 FWL_ERR CFWL_WidgetMgr::SetMaximize_Native(IFWL_Widget* pWidget) { | |
447 return m_pAdapter->SetMaximize(pWidget); | |
448 } | |
449 FWL_ERR CFWL_WidgetMgr::SetMinimize_Native(IFWL_Widget* pWidget) { | |
450 return m_pAdapter->SetMinimize(pWidget); | |
451 } | |
452 FX_BOOL CFWL_WidgetMgr::CheckMessage_Native() { | |
453 return m_pAdapter->CheckMessage(); | |
454 } | |
455 FWL_ERR CFWL_WidgetMgr::DispatchMessage_Native() { | |
456 return m_pAdapter->DispatchMessage(); | |
457 } | |
458 FX_BOOL CFWL_WidgetMgr::IsIdleMessage_Native() { | |
459 return m_pAdapter->IsIdleMessage(); | |
460 } | |
461 FWL_ERR CFWL_WidgetMgr::Exit_Native(int32_t iExitCode) { | |
462 return m_pAdapter->Exit(iExitCode); | |
463 } | |
464 FWL_ERR CFWL_WidgetMgr::CreateWidgetWithNativeId_Native(IFWL_Widget* pWidget, | |
465 void* vp) { | |
466 return m_pAdapter->CreateWidgetWithNativeId(pWidget, vp); | |
467 } | 395 } |
468 IFWL_Widget* CFWL_WidgetMgr::GetWidgetAtPoint(IFWL_Widget* parent, | 396 IFWL_Widget* CFWL_WidgetMgr::GetWidgetAtPoint(IFWL_Widget* parent, |
469 FX_FLOAT x, | 397 FX_FLOAT x, |
470 FX_FLOAT y) { | 398 FX_FLOAT y) { |
471 if (!parent) | 399 if (!parent) |
472 return NULL; | 400 return NULL; |
473 FX_FLOAT x1; | 401 FX_FLOAT x1; |
474 FX_FLOAT y1; | 402 FX_FLOAT y1; |
475 IFWL_Widget* child = GetWidget(parent, FWL_WGTRELATION_LastChild); | 403 IFWL_Widget* child = GetWidget(parent, FWL_WGTRELATION_LastChild); |
476 while (child) { | 404 while (child) { |
(...skipping 213 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
690 | 618 |
691 bool CFWL_WidgetMgr::IsFormDisabled() { | 619 bool CFWL_WidgetMgr::IsFormDisabled() { |
692 return !!(m_dwCapability & FWL_WGTMGR_DisableForm); | 620 return !!(m_dwCapability & FWL_WGTMGR_DisableForm); |
693 } | 621 } |
694 | 622 |
695 FX_BOOL CFWL_WidgetMgr::GetAdapterPopupPos(IFWL_Widget* pWidget, | 623 FX_BOOL CFWL_WidgetMgr::GetAdapterPopupPos(IFWL_Widget* pWidget, |
696 FX_FLOAT fMinHeight, | 624 FX_FLOAT fMinHeight, |
697 FX_FLOAT fMaxHeight, | 625 FX_FLOAT fMaxHeight, |
698 const CFX_RectF& rtAnchor, | 626 const CFX_RectF& rtAnchor, |
699 CFX_RectF& rtPopup) { | 627 CFX_RectF& rtPopup) { |
700 IFWL_AdapterWidgetMgr* pSDApapter = GetAdapterWidgetMgr(); | 628 CXFA_FWLAdapterWidgetMgr* pSDApapter = GetAdapterWidgetMgr(); |
701 return pSDApapter->GetPopupPos(pWidget, fMinHeight, fMaxHeight, rtAnchor, | 629 return pSDApapter->GetPopupPos(pWidget, fMinHeight, fMaxHeight, rtAnchor, |
702 rtPopup); | 630 rtPopup); |
703 } | 631 } |
704 CFWL_WidgetMgrDelegate::CFWL_WidgetMgrDelegate(CFWL_WidgetMgr* pWidgetMgr) | 632 CFWL_WidgetMgrDelegate::CFWL_WidgetMgrDelegate(CFWL_WidgetMgr* pWidgetMgr) |
705 : m_pWidgetMgr(pWidgetMgr) {} | 633 : m_pWidgetMgr(pWidgetMgr) {} |
706 FWL_ERR CFWL_WidgetMgrDelegate::OnSetCapability(uint32_t dwCapability) { | 634 FWL_ERR CFWL_WidgetMgrDelegate::OnSetCapability(uint32_t dwCapability) { |
707 m_pWidgetMgr->m_dwCapability = dwCapability; | 635 m_pWidgetMgr->m_dwCapability = dwCapability; |
708 return FWL_ERR_Succeeded; | 636 return FWL_ERR_Succeeded; |
709 } | 637 } |
710 int32_t CFWL_WidgetMgrDelegate::OnProcessMessageToForm(CFWL_Message* pMessage) { | 638 int32_t CFWL_WidgetMgrDelegate::OnProcessMessageToForm(CFWL_Message* pMessage) { |
(...skipping 294 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
1005 temp.Deflate(50, 50); | 933 temp.Deflate(50, 50); |
1006 if (!temp.Contains(r)) | 934 if (!temp.Contains(r)) |
1007 return FALSE; | 935 return FALSE; |
1008 | 936 |
1009 pItem->bOutsideChanged = FALSE; | 937 pItem->bOutsideChanged = FALSE; |
1010 } | 938 } |
1011 #endif | 939 #endif |
1012 | 940 |
1013 return pItem->iRedrawCounter == 0; | 941 return pItem->iRedrawCounter == 0; |
1014 } | 942 } |
OLD | NEW |