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 587 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
615 } | 617 } |
616 | 618 |
617 void CFFL_FormFiller::InvalidateRect(double left, | 619 void CFFL_FormFiller::InvalidateRect(double left, |
618 double top, | 620 double top, |
619 double right, | 621 double right, |
620 double bottom) { | 622 double bottom) { |
621 UnderlyingPageType* pPage = m_pWidget->GetUnderlyingPage(); | 623 UnderlyingPageType* pPage = m_pWidget->GetUnderlyingPage(); |
622 m_pApp->FFI_Invalidate(pPage, left, top, right, bottom); | 624 m_pApp->FFI_Invalidate(pPage, left, top, right, bottom); |
623 } | 625 } |
624 | 626 |
625 /* ------------------------- CFFL_Button ------------------------- */ | |
626 | |
627 CFFL_Button::CFFL_Button(CPDFDoc_Environment* pApp, CPDFSDK_Annot* pWidget) | 627 CFFL_Button::CFFL_Button(CPDFDoc_Environment* pApp, CPDFSDK_Annot* pWidget) |
628 : CFFL_FormFiller(pApp, pWidget), m_bMouseIn(FALSE), m_bMouseDown(FALSE) {} | 628 : CFFL_FormFiller(pApp, pWidget), m_bMouseIn(FALSE), m_bMouseDown(FALSE) {} |
629 | 629 |
630 CFFL_Button::~CFFL_Button() {} | 630 CFFL_Button::~CFFL_Button() {} |
631 | 631 |
632 void CFFL_Button::OnMouseEnter(CPDFSDK_PageView* pPageView, | 632 void CFFL_Button::OnMouseEnter(CPDFSDK_PageView* pPageView, |
633 CPDFSDK_Annot* pAnnot) { | 633 CPDFSDK_Annot* pAnnot) { |
634 m_bMouseIn = TRUE; | 634 m_bMouseIn = TRUE; |
635 FX_RECT rect = GetViewBBox(pPageView, pAnnot); | 635 FX_RECT rect = GetViewBBox(pPageView, pAnnot); |
636 InvalidateRect(rect.left, rect.top, rect.right, rect.bottom); | 636 InvalidateRect(rect.left, rect.top, rect.right, rect.bottom); |
(...skipping 52 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
689 void CFFL_Button::OnDraw(CPDFSDK_PageView* pPageView, | 689 void CFFL_Button::OnDraw(CPDFSDK_PageView* pPageView, |
690 CPDFSDK_Annot* pAnnot, | 690 CPDFSDK_Annot* pAnnot, |
691 CFX_RenderDevice* pDevice, | 691 CFX_RenderDevice* pDevice, |
692 CFX_Matrix* pUser2Device, | 692 CFX_Matrix* pUser2Device, |
693 FX_DWORD dwFlags) { | 693 FX_DWORD dwFlags) { |
694 ASSERT(pPageView); | 694 ASSERT(pPageView); |
695 CPDFSDK_Widget* pWidget = (CPDFSDK_Widget*)pAnnot; | 695 CPDFSDK_Widget* pWidget = (CPDFSDK_Widget*)pAnnot; |
696 CPDF_FormControl* pCtrl = pWidget->GetFormControl(); | 696 CPDF_FormControl* pCtrl = pWidget->GetFormControl(); |
697 CPDF_FormControl::HighlightingMode eHM = pCtrl->GetHighlightingMode(); | 697 CPDF_FormControl::HighlightingMode eHM = pCtrl->GetHighlightingMode(); |
698 | 698 |
699 if (eHM == CPDF_FormControl::Push) { | 699 if (eHM != CPDF_FormControl::Push) { |
700 if (m_bMouseDown) { | 700 pWidget->DrawAppearance(pDevice, pUser2Device, CPDF_Annot::Normal, NULL); |
701 if (pWidget->IsWidgetAppearanceValid(CPDF_Annot::Down)) | 701 return; |
702 pWidget->DrawAppearance(pDevice, pUser2Device, CPDF_Annot::Down, NULL); | 702 } |
703 else | 703 |
704 pWidget->DrawAppearance(pDevice, pUser2Device, CPDF_Annot::Normal, | 704 if (m_bMouseDown) { |
705 NULL); | 705 if (pWidget->IsWidgetAppearanceValid(CPDF_Annot::Down)) |
706 } else if (m_bMouseIn) { | 706 pWidget->DrawAppearance(pDevice, pUser2Device, CPDF_Annot::Down, NULL); |
707 if (pWidget->IsWidgetAppearanceValid(CPDF_Annot::Rollover)) | 707 else |
708 pWidget->DrawAppearance(pDevice, pUser2Device, CPDF_Annot::Rollover, | |
709 NULL); | |
710 else | |
711 pWidget->DrawAppearance(pDevice, pUser2Device, CPDF_Annot::Normal, | |
712 NULL); | |
713 } else { | |
714 pWidget->DrawAppearance(pDevice, pUser2Device, CPDF_Annot::Normal, NULL); | 708 pWidget->DrawAppearance(pDevice, pUser2Device, CPDF_Annot::Normal, NULL); |
715 } | 709 } else if (m_bMouseIn) { |
716 } else | 710 if (pWidget->IsWidgetAppearanceValid(CPDF_Annot::Rollover)) |
| 711 pWidget->DrawAppearance(pDevice, pUser2Device, CPDF_Annot::Rollover, |
| 712 NULL); |
| 713 else |
| 714 pWidget->DrawAppearance(pDevice, pUser2Device, CPDF_Annot::Normal, NULL); |
| 715 } else { |
717 pWidget->DrawAppearance(pDevice, pUser2Device, CPDF_Annot::Normal, NULL); | 716 pWidget->DrawAppearance(pDevice, pUser2Device, CPDF_Annot::Normal, NULL); |
| 717 } |
718 } | 718 } |
719 | 719 |
720 void CFFL_Button::OnDrawDeactive(CPDFSDK_PageView* pPageView, | 720 void CFFL_Button::OnDrawDeactive(CPDFSDK_PageView* pPageView, |
721 CPDFSDK_Annot* pAnnot, | 721 CPDFSDK_Annot* pAnnot, |
722 CFX_RenderDevice* pDevice, | 722 CFX_RenderDevice* pDevice, |
723 CFX_Matrix* pUser2Device, | 723 CFX_Matrix* pUser2Device, |
724 FX_DWORD dwFlags) { | 724 FX_DWORD dwFlags) { |
725 OnDraw(pPageView, pAnnot, pDevice, pUser2Device, dwFlags); | 725 OnDraw(pPageView, pAnnot, pDevice, pUser2Device, dwFlags); |
726 } | 726 } |
OLD | NEW |