| 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 "fpdfsdk/include/formfiller/FFL_FormFiller.h" |
| 8 |
| 7 #include "fpdfsdk/include/formfiller/FFL_CBA_Fontmap.h" | 9 #include "fpdfsdk/include/formfiller/FFL_CBA_Fontmap.h" |
| 8 #include "fpdfsdk/include/formfiller/FFL_FormFiller.h" | 10 #include "fpdfsdk/include/fsdk_common.h" |
| 11 #include "fpdfsdk/include/fsdk_mgr.h" |
| 12 #include "fpdfsdk/include/pdfwindow/PWL_Utils.h" |
| 9 | 13 |
| 10 #define GetRed(rgb) ((uint8_t)(rgb)) | 14 #define GetRed(rgb) ((uint8_t)(rgb)) |
| 11 #define GetGreen(rgb) ((uint8_t)(((FX_WORD)(rgb)) >> 8)) | 15 #define GetGreen(rgb) ((uint8_t)(((FX_WORD)(rgb)) >> 8)) |
| 12 #define GetBlue(rgb) ((uint8_t)((rgb) >> 16)) | 16 #define GetBlue(rgb) ((uint8_t)((rgb) >> 16)) |
| 13 | 17 |
| 14 #define FFL_HINT_ELAPSE 800 | 18 #define FFL_HINT_ELAPSE 800 |
| 15 | 19 |
| 16 /* ------------------------- CFFL_FormFiller ------------------------- */ | |
| 17 | |
| 18 CFFL_FormFiller::CFFL_FormFiller(CPDFDoc_Environment* pApp, | 20 CFFL_FormFiller::CFFL_FormFiller(CPDFDoc_Environment* pApp, |
| 19 CPDFSDK_Annot* pAnnot) | 21 CPDFSDK_Annot* pAnnot) |
| 20 : m_pApp(pApp), m_pAnnot(pAnnot), m_bValid(FALSE), m_ptOldPos(0, 0) { | 22 : m_pApp(pApp), m_pAnnot(pAnnot), m_bValid(FALSE), m_ptOldPos(0, 0) { |
| 21 m_pWidget = (CPDFSDK_Widget*)pAnnot; | 23 m_pWidget = (CPDFSDK_Widget*)pAnnot; |
| 22 } | 24 } |
| 23 | 25 |
| 24 CFFL_FormFiller::~CFFL_FormFiller() { | 26 CFFL_FormFiller::~CFFL_FormFiller() { |
| 25 for (auto& it : m_Maps) { | 27 for (auto& it : m_Maps) { |
| 26 CPWL_Wnd* pWnd = it.second; | 28 CPWL_Wnd* pWnd = it.second; |
| 27 CFFL_PrivateData* pData = (CFFL_PrivateData*)pWnd->GetAttachedData(); | 29 CFFL_PrivateData* pData = (CFFL_PrivateData*)pWnd->GetAttachedData(); |
| (...skipping 581 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 609 } | 611 } |
| 610 | 612 |
| 611 void CFFL_FormFiller::InvalidateRect(double left, | 613 void CFFL_FormFiller::InvalidateRect(double left, |
| 612 double top, | 614 double top, |
| 613 double right, | 615 double right, |
| 614 double bottom) { | 616 double bottom) { |
| 615 UnderlyingPageType* pPage = m_pWidget->GetUnderlyingPage(); | 617 UnderlyingPageType* pPage = m_pWidget->GetUnderlyingPage(); |
| 616 m_pApp->FFI_Invalidate(pPage, left, top, right, bottom); | 618 m_pApp->FFI_Invalidate(pPage, left, top, right, bottom); |
| 617 } | 619 } |
| 618 | 620 |
| 619 /* ------------------------- CFFL_Button ------------------------- */ | |
| 620 | |
| 621 CFFL_Button::CFFL_Button(CPDFDoc_Environment* pApp, CPDFSDK_Annot* pWidget) | 621 CFFL_Button::CFFL_Button(CPDFDoc_Environment* pApp, CPDFSDK_Annot* pWidget) |
| 622 : CFFL_FormFiller(pApp, pWidget), m_bMouseIn(FALSE), m_bMouseDown(FALSE) {} | 622 : CFFL_FormFiller(pApp, pWidget), m_bMouseIn(FALSE), m_bMouseDown(FALSE) {} |
| 623 | 623 |
| 624 CFFL_Button::~CFFL_Button() {} | 624 CFFL_Button::~CFFL_Button() {} |
| 625 | 625 |
| 626 void CFFL_Button::OnMouseEnter(CPDFSDK_PageView* pPageView, | 626 void CFFL_Button::OnMouseEnter(CPDFSDK_PageView* pPageView, |
| 627 CPDFSDK_Annot* pAnnot) { | 627 CPDFSDK_Annot* pAnnot) { |
| 628 m_bMouseIn = TRUE; | 628 m_bMouseIn = TRUE; |
| 629 FX_RECT rect = GetViewBBox(pPageView, pAnnot); | 629 FX_RECT rect = GetViewBBox(pPageView, pAnnot); |
| 630 InvalidateRect(rect.left, rect.top, rect.right, rect.bottom); | 630 InvalidateRect(rect.left, rect.top, rect.right, rect.bottom); |
| (...skipping 52 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 683 void CFFL_Button::OnDraw(CPDFSDK_PageView* pPageView, | 683 void CFFL_Button::OnDraw(CPDFSDK_PageView* pPageView, |
| 684 CPDFSDK_Annot* pAnnot, | 684 CPDFSDK_Annot* pAnnot, |
| 685 CFX_RenderDevice* pDevice, | 685 CFX_RenderDevice* pDevice, |
| 686 CFX_Matrix* pUser2Device, | 686 CFX_Matrix* pUser2Device, |
| 687 FX_DWORD dwFlags) { | 687 FX_DWORD dwFlags) { |
| 688 ASSERT(pPageView); | 688 ASSERT(pPageView); |
| 689 CPDFSDK_Widget* pWidget = (CPDFSDK_Widget*)pAnnot; | 689 CPDFSDK_Widget* pWidget = (CPDFSDK_Widget*)pAnnot; |
| 690 CPDF_FormControl* pCtrl = pWidget->GetFormControl(); | 690 CPDF_FormControl* pCtrl = pWidget->GetFormControl(); |
| 691 CPDF_FormControl::HighlightingMode eHM = pCtrl->GetHighlightingMode(); | 691 CPDF_FormControl::HighlightingMode eHM = pCtrl->GetHighlightingMode(); |
| 692 | 692 |
| 693 if (eHM == CPDF_FormControl::Push) { | 693 if (eHM != CPDF_FormControl::Push) { |
| 694 if (m_bMouseDown) { | 694 pWidget->DrawAppearance(pDevice, pUser2Device, CPDF_Annot::Normal, NULL); |
| 695 if (pWidget->IsWidgetAppearanceValid(CPDF_Annot::Down)) | 695 return; |
| 696 pWidget->DrawAppearance(pDevice, pUser2Device, CPDF_Annot::Down, NULL); | 696 } |
| 697 else | 697 |
| 698 pWidget->DrawAppearance(pDevice, pUser2Device, CPDF_Annot::Normal, | 698 if (m_bMouseDown) { |
| 699 NULL); | 699 if (pWidget->IsWidgetAppearanceValid(CPDF_Annot::Down)) |
| 700 } else if (m_bMouseIn) { | 700 pWidget->DrawAppearance(pDevice, pUser2Device, CPDF_Annot::Down, NULL); |
| 701 if (pWidget->IsWidgetAppearanceValid(CPDF_Annot::Rollover)) | 701 else |
| 702 pWidget->DrawAppearance(pDevice, pUser2Device, CPDF_Annot::Rollover, | |
| 703 NULL); | |
| 704 else | |
| 705 pWidget->DrawAppearance(pDevice, pUser2Device, CPDF_Annot::Normal, | |
| 706 NULL); | |
| 707 } else { | |
| 708 pWidget->DrawAppearance(pDevice, pUser2Device, CPDF_Annot::Normal, NULL); | 702 pWidget->DrawAppearance(pDevice, pUser2Device, CPDF_Annot::Normal, NULL); |
| 709 } | 703 } else if (m_bMouseIn) { |
| 710 } else | 704 if (pWidget->IsWidgetAppearanceValid(CPDF_Annot::Rollover)) |
| 705 pWidget->DrawAppearance(pDevice, pUser2Device, CPDF_Annot::Rollover, |
| 706 NULL); |
| 707 else |
| 708 pWidget->DrawAppearance(pDevice, pUser2Device, CPDF_Annot::Normal, NULL); |
| 709 } else { |
| 711 pWidget->DrawAppearance(pDevice, pUser2Device, CPDF_Annot::Normal, NULL); | 710 pWidget->DrawAppearance(pDevice, pUser2Device, CPDF_Annot::Normal, NULL); |
| 711 } |
| 712 } | 712 } |
| 713 | 713 |
| 714 void CFFL_Button::OnDrawDeactive(CPDFSDK_PageView* pPageView, | 714 void CFFL_Button::OnDrawDeactive(CPDFSDK_PageView* pPageView, |
| 715 CPDFSDK_Annot* pAnnot, | 715 CPDFSDK_Annot* pAnnot, |
| 716 CFX_RenderDevice* pDevice, | 716 CFX_RenderDevice* pDevice, |
| 717 CFX_Matrix* pUser2Device, | 717 CFX_Matrix* pUser2Device, |
| 718 FX_DWORD dwFlags) { | 718 FX_DWORD dwFlags) { |
| 719 OnDraw(pPageView, pAnnot, pDevice, pUser2Device, dwFlags); | 719 OnDraw(pPageView, pAnnot, pDevice, pUser2Device, dwFlags); |
| 720 } | 720 } |
| OLD | NEW |