| 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/cfwl_spinbutton.h" | 7 #include "xfa/fwl/core/cfwl_spinbutton.h" |
| 8 | 8 |
| 9 #include <memory> | 9 #include <memory> |
| 10 #include <utility> | 10 #include <utility> |
| (...skipping 12 matching lines...) Expand all Loading... |
| 23 | 23 |
| 24 const int kMinWidth = 18; | 24 const int kMinWidth = 18; |
| 25 const int kMinHeight = 32; | 25 const int kMinHeight = 32; |
| 26 const int kElapseTime = 200; | 26 const int kElapseTime = 200; |
| 27 | 27 |
| 28 } // namespace | 28 } // namespace |
| 29 | 29 |
| 30 CFWL_SpinButton::CFWL_SpinButton( | 30 CFWL_SpinButton::CFWL_SpinButton( |
| 31 const CFWL_App* app, | 31 const CFWL_App* app, |
| 32 std::unique_ptr<CFWL_WidgetProperties> properties) | 32 std::unique_ptr<CFWL_WidgetProperties> properties) |
| 33 : IFWL_Widget(app, std::move(properties), nullptr), | 33 : CFWL_Widget(app, std::move(properties), nullptr), |
| 34 m_dwUpState(CFWL_PartState_Normal), | 34 m_dwUpState(CFWL_PartState_Normal), |
| 35 m_dwDnState(CFWL_PartState_Normal), | 35 m_dwDnState(CFWL_PartState_Normal), |
| 36 m_iButtonIndex(0), | 36 m_iButtonIndex(0), |
| 37 m_bLButtonDwn(false), | 37 m_bLButtonDwn(false), |
| 38 m_pTimerInfo(nullptr), | 38 m_pTimerInfo(nullptr), |
| 39 m_Timer(this) { | 39 m_Timer(this) { |
| 40 m_rtClient.Reset(); | 40 m_rtClient.Reset(); |
| 41 m_rtUpButton.Reset(); | 41 m_rtUpButton.Reset(); |
| 42 m_rtDnButton.Reset(); | 42 m_rtDnButton.Reset(); |
| 43 m_pProperties->m_dwStyleExes |= FWL_STYLEEXE_SPB_Vert; | 43 m_pProperties->m_dwStyleExes |= FWL_STYLEEXE_SPB_Vert; |
| 44 } | 44 } |
| 45 | 45 |
| 46 CFWL_SpinButton::~CFWL_SpinButton() {} | 46 CFWL_SpinButton::~CFWL_SpinButton() {} |
| 47 | 47 |
| 48 FWL_Type CFWL_SpinButton::GetClassID() const { | 48 FWL_Type CFWL_SpinButton::GetClassID() const { |
| 49 return FWL_Type::SpinButton; | 49 return FWL_Type::SpinButton; |
| 50 } | 50 } |
| 51 | 51 |
| 52 void CFWL_SpinButton::GetWidgetRect(CFX_RectF& rect, bool bAutoSize) { | 52 void CFWL_SpinButton::GetWidgetRect(CFX_RectF& rect, bool bAutoSize) { |
| 53 if (!bAutoSize) { | 53 if (!bAutoSize) { |
| 54 rect = m_pProperties->m_rtWidget; | 54 rect = m_pProperties->m_rtWidget; |
| 55 return; | 55 return; |
| 56 } | 56 } |
| 57 | 57 |
| 58 rect.Set(0, 0, kMinWidth, kMinHeight); | 58 rect.Set(0, 0, kMinWidth, kMinHeight); |
| 59 IFWL_Widget::GetWidgetRect(rect, true); | 59 CFWL_Widget::GetWidgetRect(rect, true); |
| 60 } | 60 } |
| 61 | 61 |
| 62 void CFWL_SpinButton::Update() { | 62 void CFWL_SpinButton::Update() { |
| 63 if (IsLocked()) | 63 if (IsLocked()) |
| 64 return; | 64 return; |
| 65 | 65 |
| 66 GetClientRect(m_rtClient); | 66 GetClientRect(m_rtClient); |
| 67 if (m_pProperties->m_dwStyleExes & FWL_STYLEEXE_SPB_Vert) { | 67 if (m_pProperties->m_dwStyleExes & FWL_STYLEEXE_SPB_Vert) { |
| 68 m_rtUpButton.Set(m_rtClient.top, m_rtClient.left, m_rtClient.width, | 68 m_rtUpButton.Set(m_rtClient.top, m_rtClient.left, m_rtClient.width, |
| 69 m_rtClient.height / 2); | 69 m_rtClient.height / 2); |
| (...skipping 123 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 193 } | 193 } |
| 194 case CFWL_MessageType::Key: { | 194 case CFWL_MessageType::Key: { |
| 195 CFWL_MsgKey* pKey = static_cast<CFWL_MsgKey*>(pMessage); | 195 CFWL_MsgKey* pKey = static_cast<CFWL_MsgKey*>(pMessage); |
| 196 if (pKey->m_dwCmd == FWL_KeyCommand::KeyDown) | 196 if (pKey->m_dwCmd == FWL_KeyCommand::KeyDown) |
| 197 OnKeyDown(pKey); | 197 OnKeyDown(pKey); |
| 198 break; | 198 break; |
| 199 } | 199 } |
| 200 default: | 200 default: |
| 201 break; | 201 break; |
| 202 } | 202 } |
| 203 IFWL_Widget::OnProcessMessage(pMessage); | 203 CFWL_Widget::OnProcessMessage(pMessage); |
| 204 } | 204 } |
| 205 | 205 |
| 206 void CFWL_SpinButton::OnDrawWidget(CFX_Graphics* pGraphics, | 206 void CFWL_SpinButton::OnDrawWidget(CFX_Graphics* pGraphics, |
| 207 const CFX_Matrix* pMatrix) { | 207 const CFX_Matrix* pMatrix) { |
| 208 DrawWidget(pGraphics, pMatrix); | 208 DrawWidget(pGraphics, pMatrix); |
| 209 } | 209 } |
| 210 | 210 |
| 211 void CFWL_SpinButton::OnFocusChanged(CFWL_Message* pMsg, bool bSet) { | 211 void CFWL_SpinButton::OnFocusChanged(CFWL_Message* pMsg, bool bSet) { |
| 212 if (bSet) | 212 if (bSet) |
| 213 m_pProperties->m_dwStates |= (FWL_WGTSTATE_Focused); | 213 m_pProperties->m_dwStates |= (FWL_WGTSTATE_Focused); |
| (...skipping 158 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 372 void CFWL_SpinButton::Timer::Run(CFWL_TimerInfo* pTimerInfo) { | 372 void CFWL_SpinButton::Timer::Run(CFWL_TimerInfo* pTimerInfo) { |
| 373 CFWL_SpinButton* pButton = static_cast<CFWL_SpinButton*>(m_pWidget); | 373 CFWL_SpinButton* pButton = static_cast<CFWL_SpinButton*>(m_pWidget); |
| 374 | 374 |
| 375 if (!pButton->m_pTimerInfo) | 375 if (!pButton->m_pTimerInfo) |
| 376 return; | 376 return; |
| 377 | 377 |
| 378 CFWL_EvtClick wmPosChanged; | 378 CFWL_EvtClick wmPosChanged; |
| 379 wmPosChanged.m_pSrcTarget = pButton; | 379 wmPosChanged.m_pSrcTarget = pButton; |
| 380 pButton->DispatchEvent(&wmPosChanged); | 380 pButton->DispatchEvent(&wmPosChanged); |
| 381 } | 381 } |
| OLD | NEW |