blob: 0f002a2b4aec36e22e0d4ae9b545a26d1a4c6a69 [file] [log] [blame]
John Abd-El-Malek3f3b45c2014-05-23 17:28:10 -07001// 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.
Lei Zhanga6d9f0e2015-06-13 00:48:38 -07004
John Abd-El-Malek3f3b45c2014-05-23 17:28:10 -07005// Original code copyright 2014 Foxit Software Inc. http://www.foxitsoftware.com
6
dan sinclair89e904b2016-03-23 19:29:15 -04007#ifndef FPDFSDK_PDFWINDOW_PWL_CARET_H_
8#define FPDFSDK_PDFWINDOW_PWL_CARET_H_
John Abd-El-Malek3f3b45c2014-05-23 17:28:10 -07009
dan sinclair89e904b2016-03-23 19:29:15 -040010#include "fpdfsdk/pdfwindow/PWL_Wnd.h"
Tom Sepez870292c2015-04-07 16:12:46 -070011
Nico Weber9d8ec5a2015-08-04 13:00:21 -070012struct PWL_CARET_INFO {
13 public:
14 PWL_CARET_INFO() : bVisible(FALSE), ptHead(0, 0), ptFoot(0, 0) {}
John Abd-El-Malek3f3b45c2014-05-23 17:28:10 -070015
Nico Weber9d8ec5a2015-08-04 13:00:21 -070016 FX_BOOL bVisible;
Tom Sepez281a9ea2016-02-26 14:24:28 -080017 CFX_FloatPoint ptHead;
18 CFX_FloatPoint ptFoot;
John Abd-El-Malek3f3b45c2014-05-23 17:28:10 -070019};
20
Nico Weber9d8ec5a2015-08-04 13:00:21 -070021class CPWL_Caret : public CPWL_Wnd {
22 public:
23 CPWL_Caret();
Lei Zhang2b1a2d52015-08-14 22:16:22 -070024 ~CPWL_Caret() override;
John Abd-El-Malek3f3b45c2014-05-23 17:28:10 -070025
Lei Zhang2b1a2d52015-08-14 22:16:22 -070026 // CPWL_Wnd
27 CFX_ByteString GetClassName() const override;
28 void GetThisAppearanceStream(CFX_ByteTextBuf& sAppStream) override;
29 void DrawThisAppearance(CFX_RenderDevice* pDevice,
Tom Sepez60d909e2015-12-10 15:34:55 -080030 CFX_Matrix* pUser2Device) override;
thestig1cd352e2016-06-07 17:53:06 -070031 void InvalidateRect(CFX_FloatRect* pRect = nullptr) override;
Lei Zhang2b1a2d52015-08-14 22:16:22 -070032 void SetVisible(FX_BOOL bVisible) override {}
33 void TimerProc() override;
34
Nico Weber9d8ec5a2015-08-04 13:00:21 -070035 void SetCaret(FX_BOOL bVisible,
Tom Sepez281a9ea2016-02-26 14:24:28 -080036 const CFX_FloatPoint& ptHead,
37 const CFX_FloatPoint& ptFoot);
38 CFX_ByteString GetCaretAppearanceStream(const CFX_FloatPoint& ptOffset);
39 void SetInvalidRect(CFX_FloatRect rc) { m_rcInvalid = rc; }
Tom Sepez870292c2015-04-07 16:12:46 -070040
Nico Weber9d8ec5a2015-08-04 13:00:21 -070041 private:
Tom Sepez281a9ea2016-02-26 14:24:28 -080042 void GetCaretApp(CFX_ByteTextBuf& sAppStream, const CFX_FloatPoint& ptOffset);
43 CFX_FloatRect GetCaretRect() const;
John Abd-El-Malek3f3b45c2014-05-23 17:28:10 -070044
Nico Weber9d8ec5a2015-08-04 13:00:21 -070045 FX_BOOL m_bFlash;
Tom Sepez281a9ea2016-02-26 14:24:28 -080046 CFX_FloatPoint m_ptHead;
47 CFX_FloatPoint m_ptFoot;
Nico Weber9d8ec5a2015-08-04 13:00:21 -070048 FX_FLOAT m_fWidth;
49 int32_t m_nDelay;
Tom Sepez281a9ea2016-02-26 14:24:28 -080050 CFX_FloatRect m_rcInvalid;
John Abd-El-Malek3f3b45c2014-05-23 17:28:10 -070051};
52
dan sinclair89e904b2016-03-23 19:29:15 -040053#endif // FPDFSDK_PDFWINDOW_PWL_CARET_H_