1 // Copyright 2014 PDFium Authors. All rights reserved. 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 #ifndef FPDFSDK_PWL_CPWL_CARET_H_ 8 #define FPDFSDK_PWL_CPWL_CARET_H_ 9 10 #include <memory> 11 12 #include "core/fxcrt/cfx_timer.h" 13 #include "fpdfsdk/pwl/cpwl_wnd.h" 14 15 class CPWL_Caret final : public CPWL_Wnd, public CFX_Timer::CallbackIface { 16 public: 17 CPWL_Caret(const CreateParams& cp, 18 std::unique_ptr<IPWL_SystemHandler::PerWindowData> pAttachedData); 19 ~CPWL_Caret() override; 20 21 // CPWL_Wnd: 22 void DrawThisAppearance(CFX_RenderDevice* pDevice, 23 const CFX_Matrix& mtUser2Device) override; 24 bool InvalidateRect(CFX_FloatRect* pRect) override; 25 bool SetVisible(bool bVisible) override; 26 27 // CFX_Timer::CallbackIface: 28 void OnTimerFired() override; 29 30 void SetCaret(bool bVisible, 31 const CFX_PointF& ptHead, 32 const CFX_PointF& ptFoot); SetInvalidRect(const CFX_FloatRect & rc)33 void SetInvalidRect(const CFX_FloatRect& rc) { m_rcInvalid = rc; } 34 35 private: 36 CFX_FloatRect GetCaretRect() const; 37 38 bool m_bFlash = false; 39 CFX_PointF m_ptHead; 40 CFX_PointF m_ptFoot; 41 float m_fWidth = 0.4f; 42 CFX_FloatRect m_rcInvalid; 43 std::unique_ptr<CFX_Timer> m_pTimer; 44 }; 45 46 #endif // FPDFSDK_PWL_CPWL_CARET_H_ 47