| 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/basewidget/fwl_caretimp.h" | 7 #include "xfa/fwl/basewidget/fwl_caretimp.h" |
| 8 | 8 |
| 9 #include "xfa/fwl/basewidget/ifwl_caret.h" | 9 #include "xfa/fwl/basewidget/ifwl_caret.h" |
| 10 #include "xfa/fwl/core/cfwl_themebackground.h" | 10 #include "xfa/fwl/core/cfwl_themebackground.h" |
| (...skipping 20 matching lines...) Expand all Loading... |
| 31 FWL_Error IFWL_Caret::SetFrequency(uint32_t elapse) { | 31 FWL_Error IFWL_Caret::SetFrequency(uint32_t elapse) { |
| 32 return static_cast<CFWL_CaretImp*>(GetImpl())->SetFrequency(elapse); | 32 return static_cast<CFWL_CaretImp*>(GetImpl())->SetFrequency(elapse); |
| 33 } | 33 } |
| 34 FWL_Error IFWL_Caret::SetColor(CFX_Color crFill) { | 34 FWL_Error IFWL_Caret::SetColor(CFX_Color crFill) { |
| 35 return static_cast<CFWL_CaretImp*>(GetImpl())->SetColor(crFill); | 35 return static_cast<CFWL_CaretImp*>(GetImpl())->SetColor(crFill); |
| 36 } | 36 } |
| 37 | 37 |
| 38 CFWL_CaretImp::CFWL_CaretImp(const CFWL_WidgetImpProperties& properties, | 38 CFWL_CaretImp::CFWL_CaretImp(const CFWL_WidgetImpProperties& properties, |
| 39 IFWL_Widget* pOuter) | 39 IFWL_Widget* pOuter) |
| 40 : CFWL_WidgetImp(properties, pOuter), | 40 : CFWL_WidgetImp(properties, pOuter), |
| 41 m_hTimer(nullptr), | 41 m_pTimerInfo(nullptr), |
| 42 m_dwElapse(400), | 42 m_dwElapse(400), |
| 43 m_bSetColor(FALSE) { | 43 m_bSetColor(FALSE) { |
| 44 m_pTimer = new CFWL_CaretTimer(this); | 44 m_pTimer = new CFWL_CaretTimer(this); |
| 45 SetStates(FWL_STATE_CAT_HightLight); | 45 SetStates(FWL_STATE_CAT_HightLight); |
| 46 } | 46 } |
| 47 | 47 |
| 48 CFWL_CaretImp::~CFWL_CaretImp() { | 48 CFWL_CaretImp::~CFWL_CaretImp() { |
| 49 delete m_pTimer; | 49 delete m_pTimer; |
| 50 } | 50 } |
| 51 | 51 |
| 52 FWL_Error CFWL_CaretImp::GetClassName(CFX_WideString& wsClass) const { | 52 FWL_Error CFWL_CaretImp::GetClassName(CFX_WideString& wsClass) const { |
| 53 wsClass = FWL_CLASS_Caret; | 53 wsClass = FWL_CLASS_Caret; |
| 54 return FWL_Error::Succeeded; | 54 return FWL_Error::Succeeded; |
| 55 } | 55 } |
| 56 | 56 |
| 57 FWL_Type CFWL_CaretImp::GetClassID() const { | 57 FWL_Type CFWL_CaretImp::GetClassID() const { |
| 58 return FWL_Type::Caret; | 58 return FWL_Type::Caret; |
| 59 } | 59 } |
| 60 | 60 |
| 61 FWL_Error CFWL_CaretImp::Initialize() { | 61 FWL_Error CFWL_CaretImp::Initialize() { |
| 62 if (CFWL_WidgetImp::Initialize() != FWL_Error::Succeeded) | 62 if (CFWL_WidgetImp::Initialize() != FWL_Error::Succeeded) |
| 63 return FWL_Error::Indefinite; | 63 return FWL_Error::Indefinite; |
| 64 | 64 |
| 65 m_pDelegate = new CFWL_CaretImpDelegate(this); | 65 m_pDelegate = new CFWL_CaretImpDelegate(this); |
| 66 return FWL_Error::Succeeded; | 66 return FWL_Error::Succeeded; |
| 67 } | 67 } |
| 68 | 68 |
| 69 FWL_Error CFWL_CaretImp::Finalize() { | 69 FWL_Error CFWL_CaretImp::Finalize() { |
| 70 if (m_hTimer) { | 70 if (m_pTimerInfo) { |
| 71 FWL_StopTimer(m_hTimer); | 71 m_pTimerInfo->StopTimer(); |
| 72 m_hTimer = NULL; | 72 m_pTimerInfo = nullptr; |
| 73 } | 73 } |
| 74 delete m_pDelegate; | 74 delete m_pDelegate; |
| 75 m_pDelegate = nullptr; | 75 m_pDelegate = nullptr; |
| 76 return CFWL_WidgetImp::Finalize(); | 76 return CFWL_WidgetImp::Finalize(); |
| 77 } | 77 } |
| 78 FWL_Error CFWL_CaretImp::DrawWidget(CFX_Graphics* pGraphics, | 78 FWL_Error CFWL_CaretImp::DrawWidget(CFX_Graphics* pGraphics, |
| 79 const CFX_Matrix* pMatrix) { | 79 const CFX_Matrix* pMatrix) { |
| 80 if (!pGraphics) | 80 if (!pGraphics) |
| 81 return FWL_Error::Indefinite; | 81 return FWL_Error::Indefinite; |
| 82 if (!m_pProperties->m_pThemeProvider) | 82 if (!m_pProperties->m_pThemeProvider) |
| 83 m_pProperties->m_pThemeProvider = GetAvailableTheme(); | 83 m_pProperties->m_pThemeProvider = GetAvailableTheme(); |
| 84 if (!m_pProperties->m_pThemeProvider) | 84 if (!m_pProperties->m_pThemeProvider) |
| 85 return FWL_Error::Indefinite; | 85 return FWL_Error::Indefinite; |
| 86 | 86 |
| 87 DrawCaretBK(pGraphics, m_pProperties->m_pThemeProvider, pMatrix); | 87 DrawCaretBK(pGraphics, m_pProperties->m_pThemeProvider, pMatrix); |
| 88 return FWL_Error::Succeeded; | 88 return FWL_Error::Succeeded; |
| 89 } | 89 } |
| 90 | 90 |
| 91 void CFWL_CaretImp::ShowCaret(FX_BOOL bFlag) { | 91 void CFWL_CaretImp::ShowCaret(FX_BOOL bFlag) { |
| 92 if (m_hTimer) { | 92 if (m_pTimerInfo) { |
| 93 FWL_StopTimer(m_hTimer); | 93 m_pTimerInfo->StopTimer(); |
| 94 m_hTimer = nullptr; | 94 m_pTimerInfo = nullptr; |
| 95 } | 95 } |
| 96 if (bFlag) | 96 if (bFlag) |
| 97 m_hTimer = FWL_StartTimer(m_pTimer, m_dwElapse); | 97 m_pTimerInfo = m_pTimer->StartTimer(m_dwElapse, true); |
| 98 | 98 |
| 99 SetStates(FWL_WGTSTATE_Invisible, !bFlag); | 99 SetStates(FWL_WGTSTATE_Invisible, !bFlag); |
| 100 } | 100 } |
| 101 FWL_Error CFWL_CaretImp::GetFrequency(uint32_t& elapse) { | 101 FWL_Error CFWL_CaretImp::GetFrequency(uint32_t& elapse) { |
| 102 elapse = m_dwElapse; | 102 elapse = m_dwElapse; |
| 103 return FWL_Error::Succeeded; | 103 return FWL_Error::Succeeded; |
| 104 } | 104 } |
| 105 FWL_Error CFWL_CaretImp::SetFrequency(uint32_t elapse) { | 105 FWL_Error CFWL_CaretImp::SetFrequency(uint32_t elapse) { |
| 106 m_dwElapse = elapse; | 106 m_dwElapse = elapse; |
| 107 return FWL_Error::Succeeded; | 107 return FWL_Error::Succeeded; |
| (...skipping 23 matching lines...) Expand all Loading... |
| 131 param.m_dwStates = CFWL_PartState_HightLight; | 131 param.m_dwStates = CFWL_PartState_HightLight; |
| 132 if (pMatrix) | 132 if (pMatrix) |
| 133 param.m_matrix.Concat(*pMatrix); | 133 param.m_matrix.Concat(*pMatrix); |
| 134 | 134 |
| 135 pTheme->DrawBackground(¶m); | 135 pTheme->DrawBackground(¶m); |
| 136 } | 136 } |
| 137 | 137 |
| 138 CFWL_CaretImp::CFWL_CaretTimer::CFWL_CaretTimer(CFWL_CaretImp* pCaret) | 138 CFWL_CaretImp::CFWL_CaretTimer::CFWL_CaretTimer(CFWL_CaretImp* pCaret) |
| 139 : m_pCaret(pCaret) {} | 139 : m_pCaret(pCaret) {} |
| 140 | 140 |
| 141 int32_t CFWL_CaretImp::CFWL_CaretTimer::Run(FWL_HTIMER hTimer) { | 141 void CFWL_CaretImp::CFWL_CaretTimer::Run(IFWL_TimerInfo* pTimerInfo) { |
| 142 if (m_pCaret->GetStates() & FWL_STATE_CAT_HightLight) { | 142 bool toggle = !(m_pCaret->GetStates() & FWL_STATE_CAT_HightLight); |
| 143 m_pCaret->SetStates(FWL_STATE_CAT_HightLight, FALSE); | 143 m_pCaret->SetStates(FWL_STATE_CAT_HightLight, toggle); |
| 144 } else { | 144 |
| 145 m_pCaret->SetStates(FWL_STATE_CAT_HightLight); | |
| 146 } | |
| 147 CFX_RectF rt; | 145 CFX_RectF rt; |
| 148 m_pCaret->GetWidgetRect(rt); | 146 m_pCaret->GetWidgetRect(rt); |
| 149 rt.Set(0, 0, rt.width + 1, rt.height); | 147 rt.Set(0, 0, rt.width + 1, rt.height); |
| 150 m_pCaret->Repaint(&rt); | 148 m_pCaret->Repaint(&rt); |
| 151 return 1; | |
| 152 } | 149 } |
| 153 | 150 |
| 154 CFWL_CaretImpDelegate::CFWL_CaretImpDelegate(CFWL_CaretImp* pOwner) | 151 CFWL_CaretImpDelegate::CFWL_CaretImpDelegate(CFWL_CaretImp* pOwner) |
| 155 : m_pOwner(pOwner) {} | 152 : m_pOwner(pOwner) {} |
| 156 | 153 |
| 157 void CFWL_CaretImpDelegate::OnProcessMessage(CFWL_Message* pMessage) {} | 154 void CFWL_CaretImpDelegate::OnProcessMessage(CFWL_Message* pMessage) {} |
| 158 | 155 |
| 159 void CFWL_CaretImpDelegate::OnDrawWidget(CFX_Graphics* pGraphics, | 156 void CFWL_CaretImpDelegate::OnDrawWidget(CFX_Graphics* pGraphics, |
| 160 const CFX_Matrix* pMatrix) { | 157 const CFX_Matrix* pMatrix) { |
| 161 m_pOwner->DrawWidget(pGraphics, pMatrix); | 158 m_pOwner->DrawWidget(pGraphics, pMatrix); |
| 162 } | 159 } |
| OLD | NEW |