diff options
author | Dan Sinclair <dsinclair@chromium.org> | 2017-07-10 11:35:18 -0400 |
---|---|---|
committer | Chromium commit bot <commit-bot@chromium.org> | 2017-07-10 15:51:02 +0000 |
commit | b9eed2f50403e59c7aa414e272ae732d9bca0a7b (patch) | |
tree | 35c7e377169229b0b4688ad3d3f6488805eae542 /fpdfsdk/formfiller/cffl_button.cpp | |
parent | 217644c0d65abfc9729c083074d505b22cd7ccf6 (diff) | |
download | pdfium-b9eed2f50403e59c7aa414e272ae732d9bca0a7b.tar.xz |
Fix nits in CFFL_FormFiller
Cleanup nits in CFFL_FormFiller. Split CFFL_Button into own files.
Change-Id: I41fa7118a46aa1f495c15f90a4c4b77b309a10d3
Reviewed-on: https://pdfium-review.googlesource.com/7339
Reviewed-by: Nicolás Peña <npm@chromium.org>
Commit-Queue: dsinclair <dsinclair@chromium.org>
Diffstat (limited to 'fpdfsdk/formfiller/cffl_button.cpp')
-rw-r--r-- | fpdfsdk/formfiller/cffl_button.cpp | 101 |
1 files changed, 101 insertions, 0 deletions
diff --git a/fpdfsdk/formfiller/cffl_button.cpp b/fpdfsdk/formfiller/cffl_button.cpp new file mode 100644 index 0000000000..2a290ed213 --- /dev/null +++ b/fpdfsdk/formfiller/cffl_button.cpp @@ -0,0 +1,101 @@ +// Copyright 2017 PDFium Authors. All rights reserved. +// Use of this source code is governed by a BSD-style license that can be +// found in the LICENSE file. + +// Original code copyright 2014 Foxit Software Inc. http://www.foxitsoftware.com + +#include "fpdfsdk/formfiller/cffl_button.h" + +CFFL_Button::CFFL_Button(CPDFSDK_FormFillEnvironment* pApp, + CPDFSDK_Widget* pWidget) + : CFFL_FormFiller(pApp, pWidget), m_bMouseIn(false), m_bMouseDown(false) {} + +CFFL_Button::~CFFL_Button() {} + +void CFFL_Button::OnMouseEnter(CPDFSDK_PageView* pPageView, + CPDFSDK_Annot* pAnnot) { + m_bMouseIn = true; + InvalidateRect(GetViewBBox(pPageView, pAnnot)); +} + +void CFFL_Button::OnMouseExit(CPDFSDK_PageView* pPageView, + CPDFSDK_Annot* pAnnot) { + m_bMouseIn = false; + InvalidateRect(GetViewBBox(pPageView, pAnnot)); + EndTimer(); + ASSERT(m_pWidget); +} + +bool CFFL_Button::OnLButtonDown(CPDFSDK_PageView* pPageView, + CPDFSDK_Annot* pAnnot, + uint32_t nFlags, + const CFX_PointF& point) { + if (!pAnnot->GetRect().Contains(point)) + return false; + + m_bMouseDown = true; + m_bValid = true; + InvalidateRect(GetViewBBox(pPageView, pAnnot)); + return true; +} + +bool CFFL_Button::OnLButtonUp(CPDFSDK_PageView* pPageView, + CPDFSDK_Annot* pAnnot, + uint32_t nFlags, + const CFX_PointF& point) { + if (!pAnnot->GetRect().Contains(point)) + return false; + + m_bMouseDown = false; + m_pWidget->GetPDFPage(); + InvalidateRect(GetViewBBox(pPageView, pAnnot)); + return true; +} + +bool CFFL_Button::OnMouseMove(CPDFSDK_PageView* pPageView, + CPDFSDK_Annot* pAnnot, + uint32_t nFlags, + const CFX_PointF& point) { + return true; +} + +void CFFL_Button::OnDraw(CPDFSDK_PageView* pPageView, + CPDFSDK_Annot* pAnnot, + CFX_RenderDevice* pDevice, + CFX_Matrix* pUser2Device) { + ASSERT(pPageView); + CPDFSDK_Widget* pWidget = static_cast<CPDFSDK_Widget*>(pAnnot); + CPDF_FormControl* pCtrl = pWidget->GetFormControl(); + if (pCtrl->GetHighlightingMode() != CPDF_FormControl::Push) { + pWidget->DrawAppearance(pDevice, pUser2Device, CPDF_Annot::Normal, nullptr); + return; + } + if (m_bMouseDown) { + if (pWidget->IsWidgetAppearanceValid(CPDF_Annot::Down)) { + pWidget->DrawAppearance(pDevice, pUser2Device, CPDF_Annot::Down, nullptr); + } else { + pWidget->DrawAppearance(pDevice, pUser2Device, CPDF_Annot::Normal, + nullptr); + } + return; + } + if (m_bMouseIn) { + if (pWidget->IsWidgetAppearanceValid(CPDF_Annot::Rollover)) { + pWidget->DrawAppearance(pDevice, pUser2Device, CPDF_Annot::Rollover, + nullptr); + } else { + pWidget->DrawAppearance(pDevice, pUser2Device, CPDF_Annot::Normal, + nullptr); + } + return; + } + + pWidget->DrawAppearance(pDevice, pUser2Device, CPDF_Annot::Normal, nullptr); +} + +void CFFL_Button::OnDrawDeactive(CPDFSDK_PageView* pPageView, + CPDFSDK_Annot* pAnnot, + CFX_RenderDevice* pDevice, + CFX_Matrix* pUser2Device) { + OnDraw(pPageView, pAnnot, pDevice, pUser2Device); +} |