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 579 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
607 } | 609 } |
608 | 610 |
609 void CFFL_FormFiller::InvalidateRect(double left, | 611 void CFFL_FormFiller::InvalidateRect(double left, |
610 double top, | 612 double top, |
611 double right, | 613 double right, |
612 double bottom) { | 614 double bottom) { |
613 UnderlyingPageType* pPage = m_pWidget->GetUnderlyingPage(); | 615 UnderlyingPageType* pPage = m_pWidget->GetUnderlyingPage(); |
614 m_pApp->FFI_Invalidate(pPage, left, top, right, bottom); | 616 m_pApp->FFI_Invalidate(pPage, left, top, right, bottom); |
615 } | 617 } |
616 | 618 |
617 /* ------------------------- CFFL_Button ------------------------- */ | |
618 | |
619 CFFL_Button::CFFL_Button(CPDFDoc_Environment* pApp, CPDFSDK_Annot* pWidget) | 619 CFFL_Button::CFFL_Button(CPDFDoc_Environment* pApp, CPDFSDK_Annot* pWidget) |
620 : CFFL_FormFiller(pApp, pWidget), m_bMouseIn(FALSE), m_bMouseDown(FALSE) {} | 620 : CFFL_FormFiller(pApp, pWidget), m_bMouseIn(FALSE), m_bMouseDown(FALSE) {} |
621 | 621 |
622 CFFL_Button::~CFFL_Button() {} | 622 CFFL_Button::~CFFL_Button() {} |
623 | 623 |
624 void CFFL_Button::OnMouseEnter(CPDFSDK_PageView* pPageView, | 624 void CFFL_Button::OnMouseEnter(CPDFSDK_PageView* pPageView, |
625 CPDFSDK_Annot* pAnnot) { | 625 CPDFSDK_Annot* pAnnot) { |
626 m_bMouseIn = TRUE; | 626 m_bMouseIn = TRUE; |
627 FX_RECT rect = GetViewBBox(pPageView, pAnnot); | 627 FX_RECT rect = GetViewBBox(pPageView, pAnnot); |
628 InvalidateRect(rect.left, rect.top, rect.right, rect.bottom); | 628 InvalidateRect(rect.left, rect.top, rect.right, rect.bottom); |
(...skipping 52 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
681 void CFFL_Button::OnDraw(CPDFSDK_PageView* pPageView, | 681 void CFFL_Button::OnDraw(CPDFSDK_PageView* pPageView, |
682 CPDFSDK_Annot* pAnnot, | 682 CPDFSDK_Annot* pAnnot, |
683 CFX_RenderDevice* pDevice, | 683 CFX_RenderDevice* pDevice, |
684 CFX_Matrix* pUser2Device, | 684 CFX_Matrix* pUser2Device, |
685 FX_DWORD dwFlags) { | 685 FX_DWORD dwFlags) { |
686 ASSERT(pPageView); | 686 ASSERT(pPageView); |
687 CPDFSDK_Widget* pWidget = (CPDFSDK_Widget*)pAnnot; | 687 CPDFSDK_Widget* pWidget = (CPDFSDK_Widget*)pAnnot; |
688 CPDF_FormControl* pCtrl = pWidget->GetFormControl(); | 688 CPDF_FormControl* pCtrl = pWidget->GetFormControl(); |
689 CPDF_FormControl::HighlightingMode eHM = pCtrl->GetHighlightingMode(); | 689 CPDF_FormControl::HighlightingMode eHM = pCtrl->GetHighlightingMode(); |
690 | 690 |
691 if (eHM == CPDF_FormControl::Push) { | 691 if (eHM != CPDF_FormControl::Push) { |
692 if (m_bMouseDown) { | 692 pWidget->DrawAppearance(pDevice, pUser2Device, CPDF_Annot::Normal, NULL); |
693 if (pWidget->IsWidgetAppearanceValid(CPDF_Annot::Down)) | 693 return; |
694 pWidget->DrawAppearance(pDevice, pUser2Device, CPDF_Annot::Down, NULL); | 694 } |
695 else | 695 |
696 pWidget->DrawAppearance(pDevice, pUser2Device, CPDF_Annot::Normal, | 696 if (m_bMouseDown) { |
697 NULL); | 697 if (pWidget->IsWidgetAppearanceValid(CPDF_Annot::Down)) |
698 } else if (m_bMouseIn) { | 698 pWidget->DrawAppearance(pDevice, pUser2Device, CPDF_Annot::Down, NULL); |
699 if (pWidget->IsWidgetAppearanceValid(CPDF_Annot::Rollover)) | 699 else |
700 pWidget->DrawAppearance(pDevice, pUser2Device, CPDF_Annot::Rollover, | |
701 NULL); | |
702 else | |
703 pWidget->DrawAppearance(pDevice, pUser2Device, CPDF_Annot::Normal, | |
704 NULL); | |
705 } else { | |
706 pWidget->DrawAppearance(pDevice, pUser2Device, CPDF_Annot::Normal, NULL); | 700 pWidget->DrawAppearance(pDevice, pUser2Device, CPDF_Annot::Normal, NULL); |
707 } | 701 } else if (m_bMouseIn) { |
708 } else | 702 if (pWidget->IsWidgetAppearanceValid(CPDF_Annot::Rollover)) |
| 703 pWidget->DrawAppearance(pDevice, pUser2Device, CPDF_Annot::Rollover, |
| 704 NULL); |
| 705 else |
| 706 pWidget->DrawAppearance(pDevice, pUser2Device, CPDF_Annot::Normal, NULL); |
| 707 } else { |
709 pWidget->DrawAppearance(pDevice, pUser2Device, CPDF_Annot::Normal, NULL); | 708 pWidget->DrawAppearance(pDevice, pUser2Device, CPDF_Annot::Normal, NULL); |
| 709 } |
710 } | 710 } |
711 | 711 |
712 void CFFL_Button::OnDrawDeactive(CPDFSDK_PageView* pPageView, | 712 void CFFL_Button::OnDrawDeactive(CPDFSDK_PageView* pPageView, |
713 CPDFSDK_Annot* pAnnot, | 713 CPDFSDK_Annot* pAnnot, |
714 CFX_RenderDevice* pDevice, | 714 CFX_RenderDevice* pDevice, |
715 CFX_Matrix* pUser2Device, | 715 CFX_Matrix* pUser2Device, |
716 FX_DWORD dwFlags) { | 716 FX_DWORD dwFlags) { |
717 OnDraw(pPageView, pAnnot, pDevice, pUser2Device, dwFlags); | 717 OnDraw(pPageView, pAnnot, pDevice, pUser2Device, dwFlags); |
718 } | 718 } |
OLD | NEW |