| 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 #include "xfa/fwl/core/ifwl_caret.h" | 7 #include "xfa/fwl/core/ifwl_caret.h" |
| 8 | 8 |
| 9 #include "third_party/base/ptr_util.h" | 9 #include "third_party/base/ptr_util.h" |
| 10 #include "xfa/fwl/core/cfwl_themebackground.h" | 10 #include "xfa/fwl/core/cfwl_themebackground.h" |
| 11 #include "xfa/fwl/core/cfwl_widgetimpproperties.h" | 11 #include "xfa/fwl/core/cfwl_widgetimpproperties.h" |
| 12 #include "xfa/fwl/core/fwl_noteimp.h" | 12 #include "xfa/fwl/core/fwl_noteimp.h" |
| 13 #include "xfa/fwl/core/ifwl_caret.h" | 13 #include "xfa/fwl/core/ifwl_caret.h" |
| 14 #include "xfa/fwl/core/ifwl_themeprovider.h" | 14 #include "xfa/fwl/core/ifwl_themeprovider.h" |
| 15 | 15 |
| 16 IFWL_Caret::IFWL_Caret(const IFWL_App* app, | 16 IFWL_Caret::IFWL_Caret(const IFWL_App* app, |
| 17 const CFWL_WidgetImpProperties& properties, | 17 const CFWL_WidgetImpProperties& properties, |
| 18 IFWL_Widget* pOuter) | 18 IFWL_Widget* pOuter) |
| 19 : IFWL_Widget(app, properties, pOuter), | 19 : IFWL_Widget(app, properties, pOuter), |
| 20 m_pTimer(new IFWL_Caret::Timer(this)), | 20 m_pTimer(new IFWL_Caret::Timer(this)), |
| 21 m_pTimerInfo(nullptr), | 21 m_pTimerInfo(nullptr), |
| 22 m_dwElapse(400), | 22 m_dwElapse(400), |
| 23 m_bSetColor(FALSE) { | 23 m_bSetColor(FALSE) { |
| 24 SetStates(FWL_STATE_CAT_HightLight); | 24 SetStates(FWL_STATE_CAT_HightLight); |
| 25 SetDelegate(pdfium::MakeUnique<CFWL_CaretImpDelegate>(this)); | |
| 26 } | 25 } |
| 27 | 26 |
| 28 IFWL_Caret::~IFWL_Caret() { | 27 IFWL_Caret::~IFWL_Caret() { |
| 29 if (m_pTimerInfo) { | 28 if (m_pTimerInfo) { |
| 30 m_pTimerInfo->StopTimer(); | 29 m_pTimerInfo->StopTimer(); |
| 31 m_pTimerInfo = nullptr; | 30 m_pTimerInfo = nullptr; |
| 32 } | 31 } |
| 33 } | 32 } |
| 34 | 33 |
| 35 FWL_Type IFWL_Caret::GetClassID() const { | 34 FWL_Type IFWL_Caret::GetClassID() const { |
| (...skipping 56 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 92 return; | 91 return; |
| 93 | 92 |
| 94 param.m_iPart = CFWL_Part::Background; | 93 param.m_iPart = CFWL_Part::Background; |
| 95 param.m_dwStates = CFWL_PartState_HightLight; | 94 param.m_dwStates = CFWL_PartState_HightLight; |
| 96 if (pMatrix) | 95 if (pMatrix) |
| 97 param.m_matrix.Concat(*pMatrix); | 96 param.m_matrix.Concat(*pMatrix); |
| 98 | 97 |
| 99 pTheme->DrawBackground(¶m); | 98 pTheme->DrawBackground(¶m); |
| 100 } | 99 } |
| 101 | 100 |
| 101 void IFWL_Caret::OnProcessMessage(CFWL_Message* pMessage) {} |
| 102 |
| 103 void IFWL_Caret::OnDrawWidget(CFX_Graphics* pGraphics, |
| 104 const CFX_Matrix* pMatrix) { |
| 105 DrawWidget(pGraphics, pMatrix); |
| 106 } |
| 107 |
| 102 IFWL_Caret::Timer::Timer(IFWL_Caret* pCaret) : IFWL_Timer(pCaret) {} | 108 IFWL_Caret::Timer::Timer(IFWL_Caret* pCaret) : IFWL_Timer(pCaret) {} |
| 103 | 109 |
| 104 void IFWL_Caret::Timer::Run(IFWL_TimerInfo* pTimerInfo) { | 110 void IFWL_Caret::Timer::Run(IFWL_TimerInfo* pTimerInfo) { |
| 105 IFWL_Caret* pCaret = static_cast<IFWL_Caret*>(m_pWidget); | 111 IFWL_Caret* pCaret = static_cast<IFWL_Caret*>(m_pWidget); |
| 106 bool toggle = !(pCaret->GetStates() & FWL_STATE_CAT_HightLight); | 112 bool toggle = !(pCaret->GetStates() & FWL_STATE_CAT_HightLight); |
| 107 pCaret->SetStates(FWL_STATE_CAT_HightLight, toggle); | 113 pCaret->SetStates(FWL_STATE_CAT_HightLight, toggle); |
| 108 | 114 |
| 109 CFX_RectF rt; | 115 CFX_RectF rt; |
| 110 pCaret->GetWidgetRect(rt); | 116 pCaret->GetWidgetRect(rt); |
| 111 rt.Set(0, 0, rt.width + 1, rt.height); | 117 rt.Set(0, 0, rt.width + 1, rt.height); |
| 112 pCaret->Repaint(&rt); | 118 pCaret->Repaint(&rt); |
| 113 } | 119 } |
| 114 | |
| 115 CFWL_CaretImpDelegate::CFWL_CaretImpDelegate(IFWL_Caret* pOwner) | |
| 116 : m_pOwner(pOwner) {} | |
| 117 | |
| 118 void CFWL_CaretImpDelegate::OnProcessMessage(CFWL_Message* pMessage) {} | |
| 119 | |
| 120 void CFWL_CaretImpDelegate::OnDrawWidget(CFX_Graphics* pGraphics, | |
| 121 const CFX_Matrix* pMatrix) { | |
| 122 m_pOwner->DrawWidget(pGraphics, pMatrix); | |
| 123 } | |
| OLD | NEW |