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
cfwl_caret.cpp
Go to the documentation of this file.
1// Copyright 2014 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 "xfa/fwl/cfwl_caret.h"
8
9#include <utility>
10
11#include "xfa/fwl/cfwl_app.h"
12#include "xfa/fwl/cfwl_notedriver.h"
13#include "xfa/fwl/cfwl_themebackground.h"
14#include "xfa/fwl/ifwl_themeprovider.h"
15
16namespace {
17
18const uint32_t kBlinkPeriodMs = 600;
19
20constexpr int kStateHighlight = (1 << 0);
21
22} // namespace
23
24CFWL_Caret::CFWL_Caret(CFWL_App* app,
25 const Properties& properties,
26 CFWL_Widget* pOuter)
27 : CFWL_Widget(app, properties, pOuter) {
28 SetStates(kStateHighlight);
29}
30
31CFWL_Caret::~CFWL_Caret() = default;
32
33FWL_Type CFWL_Caret::GetClassID() const {
34 return FWL_Type::Caret;
35}
36
37void CFWL_Caret::Update() {}
38
39void CFWL_Caret::DrawWidget(CFGAS_GEGraphics* pGraphics,
40 const CFX_Matrix& matrix) {
41 if (!pGraphics)
42 return;
43
44 DrawCaretBK(pGraphics, matrix);
45}
46
47void CFWL_Caret::ShowCaret() {
48 m_pTimer = std::make_unique<CFX_Timer>(GetFWLApp()->GetTimerHandler(), this,
49 kBlinkPeriodMs);
51 SetStates(kStateHighlight);
52}
53
54void CFWL_Caret::HideCaret() {
55 m_pTimer.reset();
57}
58
59void CFWL_Caret::DrawCaretBK(CFGAS_GEGraphics* pGraphics,
60 const CFX_Matrix& mtMatrix) {
61 if (!(m_Properties.m_dwStates & kStateHighlight))
62 return;
63
64 CFWL_ThemeBackground param(CFWL_ThemePart::Part::kBackground, this,
65 pGraphics);
66 param.m_PartRect = CFX_RectF(0, 0, GetWidgetRect().Size());
67 param.m_dwStates = CFWL_PartState::kHightLight;
68 param.m_matrix = mtMatrix;
69 GetThemeProvider()->DrawBackground(param);
70}
71
72void CFWL_Caret::OnProcessMessage(CFWL_Message* pMessage) {}
73
74void CFWL_Caret::OnDrawWidget(CFGAS_GEGraphics* pGraphics,
75 const CFX_Matrix& matrix) {
76 DrawWidget(pGraphics, matrix);
77}
78
79void CFWL_Caret::OnTimerFired() {
80 if (!(GetStates() & kStateHighlight))
81 SetStates(kStateHighlight);
82 else
83 RemoveStates(kStateHighlight);
84
87}
CFWL_PartState
#define FWL_STATE_WGT_Invisible
Definition cfwl_widget.h:43
FWL_Type
Definition cfwl_widget.h:46
FWL_Type GetClassID() const override
void ShowCaret()
void DrawWidget(CFGAS_GEGraphics *pGraphics, const CFX_Matrix &matrix) override
void OnDrawWidget(CFGAS_GEGraphics *pGraphics, const CFX_Matrix &matrix) override
void HideCaret()
void OnProcessMessage(CFWL_Message *pMessage) override
void Update() override
void OnTimerFired() override
~CFWL_Caret() override
CFX_RectF m_PartRect
CFX_Matrix m_matrix
CFWL_Widget(CFWL_App *app, const Properties &properties, CFWL_Widget *pOuter)
virtual void SetStates(uint32_t dwStates)
Properties m_Properties
uint32_t GetStates() const
void RepaintRect(const CFX_RectF &pRect)
virtual CFX_RectF GetWidgetRect()
IFWL_ThemeProvider * GetThemeProvider() const
virtual void RemoveStates(uint32_t dwStates)
CFX_Matrix & operator=(const CFX_Matrix &other)=default
CFX_RectF & operator=(const CFX_RectF &other)=default
constexpr CFX_RectF(float dst_left, float dst_top, float dst_width, float dst_height)