| 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_spinbuttonimp.h" | 7 #include "xfa/fwl/basewidget/fwl_spinbuttonimp.h" |
| 8 | 8 |
| 9 #include "xfa/fwl/basewidget/ifwl_spinbutton.h" | 9 #include "xfa/fwl/basewidget/ifwl_spinbutton.h" |
| 10 #include "xfa/fwl/core/cfwl_message.h" | 10 #include "xfa/fwl/core/cfwl_message.h" |
| (...skipping 34 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 45 } | 45 } |
| 46 | 46 |
| 47 CFWL_SpinButtonImp::CFWL_SpinButtonImp( | 47 CFWL_SpinButtonImp::CFWL_SpinButtonImp( |
| 48 const CFWL_WidgetImpProperties& properties, | 48 const CFWL_WidgetImpProperties& properties, |
| 49 IFWL_Widget* pOuter) | 49 IFWL_Widget* pOuter) |
| 50 : CFWL_WidgetImp(properties, pOuter), | 50 : CFWL_WidgetImp(properties, pOuter), |
| 51 m_dwUpState(CFWL_PartState_Normal), | 51 m_dwUpState(CFWL_PartState_Normal), |
| 52 m_dwDnState(CFWL_PartState_Normal), | 52 m_dwDnState(CFWL_PartState_Normal), |
| 53 m_iButtonIndex(0), | 53 m_iButtonIndex(0), |
| 54 m_bLButtonDwn(FALSE), | 54 m_bLButtonDwn(FALSE), |
| 55 m_hTimer(NULL) { | 55 m_pTimerInfo(nullptr) { |
| 56 m_rtClient.Reset(); | 56 m_rtClient.Reset(); |
| 57 m_rtUpButton.Reset(); | 57 m_rtUpButton.Reset(); |
| 58 m_rtDnButton.Reset(); | 58 m_rtDnButton.Reset(); |
| 59 m_pProperties->m_dwStyleExes |= FWL_STYLEEXE_SPB_Vert; | 59 m_pProperties->m_dwStyleExes |= FWL_STYLEEXE_SPB_Vert; |
| 60 } | 60 } |
| 61 | 61 |
| 62 CFWL_SpinButtonImp::~CFWL_SpinButtonImp() {} | 62 CFWL_SpinButtonImp::~CFWL_SpinButtonImp() {} |
| 63 | 63 |
| 64 FWL_Error CFWL_SpinButtonImp::GetClassName(CFX_WideString& wsClass) const { | 64 FWL_Error CFWL_SpinButtonImp::GetClassName(CFX_WideString& wsClass) const { |
| 65 wsClass = FWL_CLASS_SpinButton; | 65 wsClass = FWL_CLASS_SpinButton; |
| (...skipping 60 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 126 return FWL_WidgetHit::UpButton; | 126 return FWL_WidgetHit::UpButton; |
| 127 if (m_rtDnButton.Contains(fx, fy)) | 127 if (m_rtDnButton.Contains(fx, fy)) |
| 128 return FWL_WidgetHit::DownButton; | 128 return FWL_WidgetHit::DownButton; |
| 129 return FWL_WidgetHit::Unknown; | 129 return FWL_WidgetHit::Unknown; |
| 130 } | 130 } |
| 131 FWL_Error CFWL_SpinButtonImp::DrawWidget(CFX_Graphics* pGraphics, | 131 FWL_Error CFWL_SpinButtonImp::DrawWidget(CFX_Graphics* pGraphics, |
| 132 const CFX_Matrix* pMatrix) { | 132 const CFX_Matrix* pMatrix) { |
| 133 if (!pGraphics) | 133 if (!pGraphics) |
| 134 return FWL_Error::Indefinite; | 134 return FWL_Error::Indefinite; |
| 135 CFX_RectF rtClip(m_rtClient); | 135 CFX_RectF rtClip(m_rtClient); |
| 136 if (pMatrix != NULL) { | 136 if (pMatrix) { |
| 137 pMatrix->TransformRect(rtClip); | 137 pMatrix->TransformRect(rtClip); |
| 138 } | 138 } |
| 139 IFWL_ThemeProvider* pTheme = GetAvailableTheme(); | 139 IFWL_ThemeProvider* pTheme = GetAvailableTheme(); |
| 140 if (HasBorder()) { | 140 if (HasBorder()) { |
| 141 DrawBorder(pGraphics, CFWL_Part::Border, pTheme, pMatrix); | 141 DrawBorder(pGraphics, CFWL_Part::Border, pTheme, pMatrix); |
| 142 } | 142 } |
| 143 if (HasEdge()) { | 143 if (HasEdge()) { |
| 144 DrawEdge(pGraphics, CFWL_Part::Edge, pTheme, pMatrix); | 144 DrawEdge(pGraphics, CFWL_Part::Edge, pTheme, pMatrix); |
| 145 } | 145 } |
| 146 DrawUpButton(pGraphics, pTheme, pMatrix); | 146 DrawUpButton(pGraphics, pTheme, pMatrix); |
| 147 DrawDownButton(pGraphics, pTheme, pMatrix); | 147 DrawDownButton(pGraphics, pTheme, pMatrix); |
| 148 return FWL_Error::Succeeded; | 148 return FWL_Error::Succeeded; |
| 149 } | 149 } |
| 150 int32_t CFWL_SpinButtonImp::Run(FWL_HTIMER hTimer) { | 150 |
| 151 if (m_hTimer) { | 151 void CFWL_SpinButtonImp::Run(IFWL_TimerInfo* pTimerInfo) { |
| 152 CFWL_EvtSpbClick wmPosChanged; | 152 if (!m_pTimerInfo) |
| 153 wmPosChanged.m_pSrcTarget = m_pInterface; | 153 return; |
| 154 wmPosChanged.m_bUp = m_iButtonIndex == 0; | 154 |
| 155 DispatchEvent(&wmPosChanged); | 155 CFWL_EvtSpbClick wmPosChanged; |
| 156 } | 156 wmPosChanged.m_pSrcTarget = m_pInterface; |
| 157 return 1; | 157 wmPosChanged.m_bUp = m_iButtonIndex == 0; |
| 158 DispatchEvent(&wmPosChanged); |
| 158 } | 159 } |
| 160 |
| 159 FWL_Error CFWL_SpinButtonImp::EnableButton(FX_BOOL bEnable, FX_BOOL bUp) { | 161 FWL_Error CFWL_SpinButtonImp::EnableButton(FX_BOOL bEnable, FX_BOOL bUp) { |
| 160 if (bUp) { | 162 if (bUp) { |
| 161 if (bEnable) { | 163 if (bEnable) { |
| 162 m_dwUpState = CFWL_PartState_Normal; | 164 m_dwUpState = CFWL_PartState_Normal; |
| 163 } else { | 165 } else { |
| 164 m_dwUpState = CFWL_PartState_Disabled; | 166 m_dwUpState = CFWL_PartState_Disabled; |
| 165 } | 167 } |
| 166 } else { | 168 } else { |
| 167 if (bEnable) { | 169 if (bEnable) { |
| 168 m_dwDnState = CFWL_PartState_Normal; | 170 m_dwDnState = CFWL_PartState_Normal; |
| (...skipping 129 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 298 if (bDnPress) { | 300 if (bDnPress) { |
| 299 m_pOwner->m_iButtonIndex = 1; | 301 m_pOwner->m_iButtonIndex = 1; |
| 300 m_pOwner->m_dwDnState = CFWL_PartState_Pressed; | 302 m_pOwner->m_dwDnState = CFWL_PartState_Pressed; |
| 301 } | 303 } |
| 302 CFWL_EvtSpbClick wmPosChanged; | 304 CFWL_EvtSpbClick wmPosChanged; |
| 303 wmPosChanged.m_pSrcTarget = m_pOwner->m_pInterface; | 305 wmPosChanged.m_pSrcTarget = m_pOwner->m_pInterface; |
| 304 wmPosChanged.m_bUp = bUpPress; | 306 wmPosChanged.m_bUp = bUpPress; |
| 305 m_pOwner->DispatchEvent(&wmPosChanged); | 307 m_pOwner->DispatchEvent(&wmPosChanged); |
| 306 m_pOwner->Repaint(bUpPress ? &m_pOwner->m_rtUpButton | 308 m_pOwner->Repaint(bUpPress ? &m_pOwner->m_rtUpButton |
| 307 : &m_pOwner->m_rtDnButton); | 309 : &m_pOwner->m_rtDnButton); |
| 308 m_pOwner->m_hTimer = FWL_StartTimer(m_pOwner, kElapseTime); | 310 m_pOwner->m_pTimerInfo = m_pOwner->StartTimer(kElapseTime, true); |
| 309 } | 311 } |
| 312 |
| 310 void CFWL_SpinButtonImpDelegate::OnLButtonUp(CFWL_MsgMouse* pMsg) { | 313 void CFWL_SpinButtonImpDelegate::OnLButtonUp(CFWL_MsgMouse* pMsg) { |
| 311 if (m_pOwner->m_pProperties->m_dwStates & CFWL_PartState_Disabled) { | 314 if (m_pOwner->m_pProperties->m_dwStates & CFWL_PartState_Disabled) { |
| 312 return; | 315 return; |
| 313 } | 316 } |
| 314 m_pOwner->m_bLButtonDwn = FALSE; | 317 m_pOwner->m_bLButtonDwn = FALSE; |
| 315 m_pOwner->SetGrab(FALSE); | 318 m_pOwner->SetGrab(FALSE); |
| 316 m_pOwner->SetFocus(FALSE); | 319 m_pOwner->SetFocus(FALSE); |
| 317 if (m_pOwner->m_hTimer) { | 320 if (m_pOwner->m_pTimerInfo) { |
| 318 FWL_StopTimer(m_pOwner->m_hTimer); | 321 m_pOwner->m_pTimerInfo->StopTimer(); |
| 319 m_pOwner->m_hTimer = NULL; | 322 m_pOwner->m_pTimerInfo = nullptr; |
| 320 } | 323 } |
| 321 FX_BOOL bRepaint = FALSE; | 324 FX_BOOL bRepaint = FALSE; |
| 322 CFX_RectF rtInvalidate; | 325 CFX_RectF rtInvalidate; |
| 323 if (m_pOwner->m_dwUpState == CFWL_PartState_Pressed && | 326 if (m_pOwner->m_dwUpState == CFWL_PartState_Pressed && |
| 324 m_pOwner->IsButtonEnable(TRUE)) { | 327 m_pOwner->IsButtonEnable(TRUE)) { |
| 325 m_pOwner->m_dwUpState = CFWL_PartState_Normal; | 328 m_pOwner->m_dwUpState = CFWL_PartState_Normal; |
| 326 bRepaint = TRUE; | 329 bRepaint = TRUE; |
| 327 rtInvalidate = m_pOwner->m_rtUpButton; | 330 rtInvalidate = m_pOwner->m_rtUpButton; |
| 328 } else if (m_pOwner->m_dwDnState == CFWL_PartState_Pressed && | 331 } else if (m_pOwner->m_dwDnState == CFWL_PartState_Pressed && |
| 329 m_pOwner->IsButtonEnable(FALSE)) { | 332 m_pOwner->IsButtonEnable(FALSE)) { |
| (...skipping 102 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 432 if (!bUpEnable && !bDownEnable) { | 435 if (!bUpEnable && !bDownEnable) { |
| 433 return; | 436 return; |
| 434 } | 437 } |
| 435 CFWL_EvtSpbClick wmPosChanged; | 438 CFWL_EvtSpbClick wmPosChanged; |
| 436 wmPosChanged.m_pSrcTarget = m_pOwner->m_pInterface; | 439 wmPosChanged.m_pSrcTarget = m_pOwner->m_pInterface; |
| 437 wmPosChanged.m_bUp = bUpEnable; | 440 wmPosChanged.m_bUp = bUpEnable; |
| 438 m_pOwner->DispatchEvent(&wmPosChanged); | 441 m_pOwner->DispatchEvent(&wmPosChanged); |
| 439 m_pOwner->Repaint(bUpEnable ? &m_pOwner->m_rtUpButton | 442 m_pOwner->Repaint(bUpEnable ? &m_pOwner->m_rtUpButton |
| 440 : &m_pOwner->m_rtDnButton); | 443 : &m_pOwner->m_rtDnButton); |
| 441 } | 444 } |
| OLD | NEW |