Qt
Internal/Contributor docs for the Qt SDK. Note: These are NOT official API docs; those are found at https://doc.qt.io/
Loading...
Searching...
No Matches
cffl_button.cpp
Go to the documentation of this file.
1// Copyright 2017 The PDFium Authors
2// Use of this source code is governed by a BSD-style license that can be
3// found in the LICENSE file.
4
5// Original code copyright 2014 Foxit Software Inc. http://www.foxitsoftware.com
6
7#include "fpdfsdk/formfiller/cffl_button.h"
8
9#include "fpdfsdk/cpdfsdk_widget.h"
10#include "third_party/base/check.h"
11
12CFFL_Button::CFFL_Button(CFFL_InteractiveFormFiller* pFormFiller,
13 CPDFSDK_Widget* pWidget)
14 : CFFL_FormField(pFormFiller, pWidget) {}
15
16CFFL_Button::~CFFL_Button() = default;
17
18void CFFL_Button::OnMouseEnter(CPDFSDK_PageView* pPageView) {
19 m_bMouseIn = true;
21}
22
23void CFFL_Button::OnMouseExit(CPDFSDK_PageView* pPageView) {
24 m_bMouseIn = false;
26 m_pTimer.reset();
27 DCHECK(m_pWidget);
28}
29
30bool CFFL_Button::OnLButtonDown(CPDFSDK_PageView* pPageView,
31 CPDFSDK_Widget* pWidget,
32 Mask<FWL_EVENTFLAG> nFlags,
33 const CFX_PointF& point) {
34 if (!pWidget->GetRect().Contains(point))
35 return false;
36
37 m_bMouseDown = true;
38 m_bValid = true;
40 return true;
41}
42
43bool CFFL_Button::OnLButtonUp(CPDFSDK_PageView* pPageView,
44 CPDFSDK_Widget* pWidget,
45 Mask<FWL_EVENTFLAG> nFlags,
46 const CFX_PointF& point) {
47 if (!pWidget->GetRect().Contains(point))
48 return false;
49
50 m_bMouseDown = false;
52 return true;
53}
54
55bool CFFL_Button::OnMouseMove(CPDFSDK_PageView* pPageView,
56 Mask<FWL_EVENTFLAG> nFlags,
57 const CFX_PointF& point) {
58 return true;
59}
60
61void CFFL_Button::OnDraw(CPDFSDK_PageView* pPageView,
62 CPDFSDK_Widget* pWidget,
63 CFX_RenderDevice* pDevice,
64 const CFX_Matrix& mtUser2Device) {
65 DCHECK(pPageView);
66 if (!pWidget->IsPushHighlighted()) {
67 pWidget->DrawAppearance(pDevice, mtUser2Device,
69 return;
70 }
71 if (m_bMouseDown) {
73 pWidget->DrawAppearance(pDevice, mtUser2Device,
75 } else {
76 pWidget->DrawAppearance(pDevice, mtUser2Device,
78 }
79 return;
80 }
81 if (m_bMouseIn) {
84 pWidget->DrawAppearance(pDevice, mtUser2Device,
86 } else {
87 pWidget->DrawAppearance(pDevice, mtUser2Device,
89 }
90 return;
91 }
92
93 pWidget->DrawAppearance(pDevice, mtUser2Device,
95}
96
97void CFFL_Button::OnDrawDeactive(CPDFSDK_PageView* pPageView,
98 CPDFSDK_Widget* pWidget,
99 CFX_RenderDevice* pDevice,
100 const CFX_Matrix& mtUser2Device) {
101 OnDraw(pPageView, pWidget, pDevice, mtUser2Device);
102}
void OnMouseEnter(CPDFSDK_PageView *pPageView) override
bool OnLButtonDown(CPDFSDK_PageView *pPageView, CPDFSDK_Widget *pWidget, Mask< FWL_EVENTFLAG > nFlags, const CFX_PointF &point) override
bool OnMouseMove(CPDFSDK_PageView *pPageView, Mask< FWL_EVENTFLAG > nFlags, const CFX_PointF &point) override
CFFL_Button(CFFL_InteractiveFormFiller *pFormFiller, CPDFSDK_Widget *pWidget)
~CFFL_Button() override
void OnDrawDeactive(CPDFSDK_PageView *pPageView, CPDFSDK_Widget *pWidget, CFX_RenderDevice *pDevice, const CFX_Matrix &mtUser2Device) override
void OnMouseExit(CPDFSDK_PageView *pPageView) override
bool OnLButtonUp(CPDFSDK_PageView *pPageView, CPDFSDK_Widget *pWidget, Mask< FWL_EVENTFLAG > nFlags, const CFX_PointF &point) override
void OnDraw(CPDFSDK_PageView *pPageView, CPDFSDK_Widget *pWidget, CFX_RenderDevice *pDevice, const CFX_Matrix &mtUser2Device) override
void InvalidateRect(const FX_RECT &rect)
CFFL_FormField(CFFL_InteractiveFormFiller *pFormFiller, CPDFSDK_Widget *pWidget)
FX_RECT GetViewBBox(const CPDFSDK_PageView *pPageView)
CFX_FloatRect GetRect() const override
bool IsWidgetAppearanceValid(CPDF_Annot::AppearanceMode mode) const
void DrawAppearance(CFX_RenderDevice *pDevice, const CFX_Matrix &mtUser2Device, CPDF_Annot::AppearanceMode mode) override
bool IsPushHighlighted() const