OLD | NEW |
1 // Copyright 2014 PDFium Authors. All rights reserved. | 1 // Copyright 2014 PDFium Authors. All rights reserved. |
2 // Use of this source code is governed by a BSD-style license that can be | 2 // Use of this source code is governed by a BSD-style license that can be |
3 // found in the LICENSE file. | 3 // found in the LICENSE file. |
4 | 4 |
5 // Original code copyright 2014 Foxit Software Inc. http://www.foxitsoftware.com | 5 // Original code copyright 2014 Foxit Software Inc. http://www.foxitsoftware.com |
6 | 6 |
7 #ifndef XFA_FWL_BASEWIDGET_FWL_CARETIMP_H_ | 7 #ifndef XFA_FWL_CORE_IFWL_CARET_H_ |
8 #define XFA_FWL_BASEWIDGET_FWL_CARETIMP_H_ | 8 #define XFA_FWL_CORE_IFWL_CARET_H_ |
9 | 9 |
10 #include <memory> | 10 #include <memory> |
11 | 11 |
12 #include "xfa/fwl/core/fwl_widgetimp.h" | |
13 #include "xfa/fwl/core/ifwl_timer.h" | 12 #include "xfa/fwl/core/ifwl_timer.h" |
14 #include "xfa/fwl/core/ifwl_widget.h" | 13 #include "xfa/fwl/core/ifwl_widget.h" |
15 #include "xfa/fxgraphics/cfx_color.h" | 14 #include "xfa/fxgraphics/cfx_color.h" |
16 | 15 |
17 class CFWL_WidgetImpProperties; | 16 class CFWL_WidgetImpProperties; |
18 class IFWL_Widget; | 17 class IFWL_Widget; |
19 class CFWL_CaretImpDelegate; | 18 class CFWL_CaretImpDelegate; |
20 | 19 |
21 class CFWL_CaretImp : public CFWL_WidgetImp { | 20 #define FWL_CLASS_Caret L"FWL_CARET" |
| 21 #define FWL_STATE_CAT_HightLight 1 |
| 22 |
| 23 class IFWL_Caret : public IFWL_Widget { |
22 public: | 24 public: |
23 CFWL_CaretImp(const CFWL_WidgetImpProperties& properties, | 25 static IFWL_Caret* Create(const CFWL_WidgetImpProperties& properties, |
24 IFWL_Widget* pOuter); | 26 IFWL_Widget* pOuter); |
25 ~CFWL_CaretImp() override; | |
26 | 27 |
27 // CFWL_WidgetImp | 28 IFWL_Caret(const CFWL_WidgetImpProperties& properties, IFWL_Widget* pOuter); |
| 29 ~IFWL_Caret() override; |
| 30 |
| 31 // IFWL_Widget |
28 FWL_Error GetClassName(CFX_WideString& wsClass) const override; | 32 FWL_Error GetClassName(CFX_WideString& wsClass) const override; |
29 FWL_Type GetClassID() const override; | 33 FWL_Type GetClassID() const override; |
30 FWL_Error Initialize() override; | 34 FWL_Error Initialize() override; |
31 FWL_Error Finalize() override; | 35 FWL_Error Finalize() override; |
32 FWL_Error DrawWidget(CFX_Graphics* pGraphics, | 36 FWL_Error DrawWidget(CFX_Graphics* pGraphics, |
33 const CFX_Matrix* pMatrix = nullptr) override; | 37 const CFX_Matrix* pMatrix = nullptr) override; |
34 | 38 |
35 void ShowCaret(FX_BOOL bFlag = TRUE); | 39 void ShowCaret(FX_BOOL bFlag = TRUE); |
36 FWL_Error GetFrequency(uint32_t& elapse); | 40 FWL_Error GetFrequency(uint32_t& elapse); |
37 FWL_Error SetFrequency(uint32_t elapse); | 41 FWL_Error SetFrequency(uint32_t elapse); |
38 FWL_Error SetColor(CFX_Color crFill); | 42 FWL_Error SetColor(CFX_Color crFill); |
39 | 43 |
40 protected: | 44 protected: |
41 friend class CFWL_CaretImpDelegate; | 45 friend class CFWL_CaretImpDelegate; |
42 friend class CFWL_CaretTimer; | 46 friend class CFWL_CaretTimer; |
43 | 47 |
44 class CFWL_CaretTimer : public IFWL_Timer { | 48 class CFWL_CaretTimer : public IFWL_Timer { |
45 public: | 49 public: |
46 explicit CFWL_CaretTimer(CFWL_CaretImp* pCaret); | 50 explicit CFWL_CaretTimer(IFWL_Caret* pCaret); |
47 ~CFWL_CaretTimer() override {} | 51 ~CFWL_CaretTimer() override {} |
48 void Run(IFWL_TimerInfo* hTimer) override; | 52 void Run(IFWL_TimerInfo* hTimer) override; |
49 CFWL_CaretImp* const m_pCaret; | 53 IFWL_Caret* const m_pCaret; |
50 }; | 54 }; |
51 | 55 |
52 void DrawCaretBK(CFX_Graphics* pGraphics, | 56 void DrawCaretBK(CFX_Graphics* pGraphics, |
53 IFWL_ThemeProvider* pTheme, | 57 IFWL_ThemeProvider* pTheme, |
54 const CFX_Matrix* pMatrix); | 58 const CFX_Matrix* pMatrix); |
55 | 59 |
56 std::unique_ptr<CFWL_CaretTimer> m_pTimer; | 60 std::unique_ptr<CFWL_CaretTimer> m_pTimer; |
57 IFWL_TimerInfo* m_pTimerInfo; // not owned. | 61 IFWL_TimerInfo* m_pTimerInfo; // not owned. |
58 uint32_t m_dwElapse; | 62 uint32_t m_dwElapse; |
59 CFX_Color m_crFill; | 63 CFX_Color m_crFill; |
60 FX_BOOL m_bSetColor; | 64 FX_BOOL m_bSetColor; |
61 }; | 65 }; |
62 | 66 |
63 class CFWL_CaretImpDelegate : public CFWL_WidgetImpDelegate { | 67 class CFWL_CaretImpDelegate : public CFWL_WidgetImpDelegate { |
64 public: | 68 public: |
65 CFWL_CaretImpDelegate(CFWL_CaretImp* pOwner); | 69 CFWL_CaretImpDelegate(IFWL_Caret* pOwner); |
66 void OnProcessMessage(CFWL_Message* pMessage) override; | 70 void OnProcessMessage(CFWL_Message* pMessage) override; |
67 void OnDrawWidget(CFX_Graphics* pGraphics, | 71 void OnDrawWidget(CFX_Graphics* pGraphics, |
68 const CFX_Matrix* pMatrix = nullptr) override; | 72 const CFX_Matrix* pMatrix = nullptr) override; |
69 | 73 |
70 protected: | 74 protected: |
71 CFWL_CaretImp* m_pOwner; | 75 IFWL_Caret* m_pOwner; |
72 }; | 76 }; |
73 | 77 |
74 #endif // XFA_FWL_BASEWIDGET_FWL_CARETIMP_H_ | 78 #endif // XFA_FWL_CORE_IFWL_CARET_H_ |
OLD | NEW |