| 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_scrollbarimp.h" | 7 #include "xfa/fwl/basewidget/fwl_scrollbarimp.h" |
| 8 | 8 |
| 9 #include "xfa/fwl/basewidget/ifwl_scrollbar.h" | 9 #include "xfa/fwl/basewidget/ifwl_scrollbar.h" |
| 10 #include "xfa/fwl/core/cfwl_message.h" | 10 #include "xfa/fwl/core/cfwl_message.h" |
| (...skipping 49 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 60 } | 60 } |
| 61 FWL_Error IFWL_ScrollBar::SetTrackPos(FX_FLOAT fTrackPos) { | 61 FWL_Error IFWL_ScrollBar::SetTrackPos(FX_FLOAT fTrackPos) { |
| 62 return static_cast<CFWL_ScrollBarImp*>(GetImpl())->SetTrackPos(fTrackPos); | 62 return static_cast<CFWL_ScrollBarImp*>(GetImpl())->SetTrackPos(fTrackPos); |
| 63 } | 63 } |
| 64 FX_BOOL IFWL_ScrollBar::DoScroll(uint32_t dwCode, FX_FLOAT fPos) { | 64 FX_BOOL IFWL_ScrollBar::DoScroll(uint32_t dwCode, FX_FLOAT fPos) { |
| 65 return static_cast<CFWL_ScrollBarImp*>(GetImpl())->DoScroll(dwCode, fPos); | 65 return static_cast<CFWL_ScrollBarImp*>(GetImpl())->DoScroll(dwCode, fPos); |
| 66 } | 66 } |
| 67 CFWL_ScrollBarImp::CFWL_ScrollBarImp(const CFWL_WidgetImpProperties& properties, | 67 CFWL_ScrollBarImp::CFWL_ScrollBarImp(const CFWL_WidgetImpProperties& properties, |
| 68 IFWL_Widget* pOuter) | 68 IFWL_Widget* pOuter) |
| 69 : CFWL_WidgetImp(properties, pOuter), | 69 : CFWL_WidgetImp(properties, pOuter), |
| 70 m_hTimer(nullptr), | 70 m_pTimerInfo(nullptr), |
| 71 m_fRangeMin(0), | 71 m_fRangeMin(0), |
| 72 m_fRangeMax(-1), | 72 m_fRangeMax(-1), |
| 73 m_fPageSize(0), | 73 m_fPageSize(0), |
| 74 m_fStepSize(0), | 74 m_fStepSize(0), |
| 75 m_fPos(0), | 75 m_fPos(0), |
| 76 m_fTrackPos(0), | 76 m_fTrackPos(0), |
| 77 m_iMinButtonState(CFWL_PartState_Normal), | 77 m_iMinButtonState(CFWL_PartState_Normal), |
| 78 m_iMaxButtonState(CFWL_PartState_Normal), | 78 m_iMaxButtonState(CFWL_PartState_Normal), |
| 79 m_iThumbButtonState(CFWL_PartState_Normal), | 79 m_iThumbButtonState(CFWL_PartState_Normal), |
| 80 m_iMinTrackState(CFWL_PartState_Normal), | 80 m_iMinTrackState(CFWL_PartState_Normal), |
| (...skipping 145 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 226 case FWL_SCBCODE_StepForward: | 226 case FWL_SCBCODE_StepForward: |
| 227 break; | 227 break; |
| 228 case FWL_SCBCODE_Pos: | 228 case FWL_SCBCODE_Pos: |
| 229 case FWL_SCBCODE_TrackPos: | 229 case FWL_SCBCODE_TrackPos: |
| 230 case FWL_SCBCODE_EndScroll: | 230 case FWL_SCBCODE_EndScroll: |
| 231 break; | 231 break; |
| 232 default: { return FALSE; } | 232 default: { return FALSE; } |
| 233 } | 233 } |
| 234 return OnScroll(dwCode, fPos); | 234 return OnScroll(dwCode, fPos); |
| 235 } | 235 } |
| 236 int32_t CFWL_ScrollBarImp::Run(FWL_HTIMER hTimer) { | 236 |
| 237 if (m_hTimer) { | 237 void CFWL_ScrollBarImp::Run(IFWL_TimerInfo* pTimerInfo) { |
| 238 FWL_StopTimer(m_hTimer); | 238 if (m_pTimerInfo) |
| 239 } | 239 m_pTimerInfo->StopTimer(); |
| 240 if (!SendEvent()) { | 240 |
| 241 m_hTimer = FWL_StartTimer(this, 0); | 241 if (!SendEvent()) |
| 242 } | 242 m_pTimerInfo = StartTimer(0, true); |
| 243 return 1; | |
| 244 } | 243 } |
| 244 |
| 245 FWL_Error CFWL_ScrollBarImp::SetOuter(IFWL_Widget* pOuter) { | 245 FWL_Error CFWL_ScrollBarImp::SetOuter(IFWL_Widget* pOuter) { |
| 246 m_pOuter = pOuter; | 246 m_pOuter = pOuter; |
| 247 return FWL_Error::Succeeded; | 247 return FWL_Error::Succeeded; |
| 248 } | 248 } |
| 249 void CFWL_ScrollBarImp::DrawTrack(CFX_Graphics* pGraphics, | 249 void CFWL_ScrollBarImp::DrawTrack(CFX_Graphics* pGraphics, |
| 250 IFWL_ThemeProvider* pTheme, | 250 IFWL_ThemeProvider* pTheme, |
| 251 FX_BOOL bLower, | 251 FX_BOOL bLower, |
| 252 const CFX_Matrix* pMatrix) { | 252 const CFX_Matrix* pMatrix) { |
| 253 CFWL_ThemeBackground param; | 253 CFWL_ThemeBackground param; |
| 254 param.m_pWidget = m_pInterface; | 254 param.m_pWidget = m_pInterface; |
| (...skipping 19 matching lines...) Expand all Loading... |
| 274 param.m_pGraphics = pGraphics; | 274 param.m_pGraphics = pGraphics; |
| 275 param.m_matrix.Concat(*pMatrix); | 275 param.m_matrix.Concat(*pMatrix); |
| 276 param.m_rtPart = bMinBtn ? m_rtMinBtn : m_rtMaxBtn; | 276 param.m_rtPart = bMinBtn ? m_rtMinBtn : m_rtMaxBtn; |
| 277 if (param.m_rtPart.height > 0 && param.m_rtPart.width > 0) { | 277 if (param.m_rtPart.height > 0 && param.m_rtPart.width > 0) { |
| 278 pTheme->DrawBackground(¶m); | 278 pTheme->DrawBackground(¶m); |
| 279 } | 279 } |
| 280 } | 280 } |
| 281 void CFWL_ScrollBarImp::DrawThumb(CFX_Graphics* pGraphics, | 281 void CFWL_ScrollBarImp::DrawThumb(CFX_Graphics* pGraphics, |
| 282 IFWL_ThemeProvider* pTheme, | 282 IFWL_ThemeProvider* pTheme, |
| 283 const CFX_Matrix* pMatrix) { | 283 const CFX_Matrix* pMatrix) { |
| 284 if (!IsEnabled()) { | |
| 285 } | |
| 286 CFWL_ThemeBackground param; | 284 CFWL_ThemeBackground param; |
| 287 param.m_pWidget = m_pInterface; | 285 param.m_pWidget = m_pInterface; |
| 288 param.m_iPart = CFWL_Part::Thumb; | 286 param.m_iPart = CFWL_Part::Thumb; |
| 289 param.m_dwStates = (m_pProperties->m_dwStates & FWL_WGTSTATE_Disabled) | 287 param.m_dwStates = (m_pProperties->m_dwStates & FWL_WGTSTATE_Disabled) |
| 290 ? CFWL_PartState_Disabled | 288 ? CFWL_PartState_Disabled |
| 291 : m_iThumbButtonState; | 289 : m_iThumbButtonState; |
| 292 param.m_pGraphics = pGraphics; | 290 param.m_pGraphics = pGraphics; |
| 293 param.m_matrix.Concat(*pMatrix); | 291 param.m_matrix.Concat(*pMatrix); |
| 294 param.m_rtPart = m_rtThumb; | 292 param.m_rtPart = m_rtThumb; |
| 295 pTheme->DrawBackground(¶m); | 293 pTheme->DrawBackground(¶m); |
| (...skipping 403 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 699 if (m_pOwner->m_rtMinTrack.Contains(fx, fy)) { | 697 if (m_pOwner->m_rtMinTrack.Contains(fx, fy)) { |
| 700 DoMouseDown(3, m_pOwner->m_rtMinTrack, m_pOwner->m_iMinTrackState, fx, | 698 DoMouseDown(3, m_pOwner->m_rtMinTrack, m_pOwner->m_iMinTrackState, fx, |
| 701 fy); | 699 fy); |
| 702 } else { | 700 } else { |
| 703 DoMouseDown(4, m_pOwner->m_rtMaxTrack, m_pOwner->m_iMaxTrackState, fx, | 701 DoMouseDown(4, m_pOwner->m_rtMaxTrack, m_pOwner->m_iMaxTrackState, fx, |
| 704 fy); | 702 fy); |
| 705 } | 703 } |
| 706 } | 704 } |
| 707 } | 705 } |
| 708 } | 706 } |
| 709 if (!m_pOwner->SendEvent()) { | 707 if (!m_pOwner->SendEvent()) |
| 710 m_pOwner->m_hTimer = FWL_StartTimer(m_pOwner, FWL_SCROLLBAR_Elapse); | 708 m_pOwner->m_pTimerInfo = m_pOwner->StartTimer(FWL_SCROLLBAR_Elapse, true); |
| 711 } | |
| 712 } | 709 } |
| 710 |
| 713 void CFWL_ScrollBarImpDelegate::OnLButtonUp(uint32_t dwFlags, | 711 void CFWL_ScrollBarImpDelegate::OnLButtonUp(uint32_t dwFlags, |
| 714 FX_FLOAT fx, | 712 FX_FLOAT fx, |
| 715 FX_FLOAT fy) { | 713 FX_FLOAT fy) { |
| 716 FWL_StopTimer(m_pOwner->m_hTimer); | 714 m_pOwner->m_pTimerInfo->StopTimer(); |
| 717 m_pOwner->m_bMouseDown = FALSE; | 715 m_pOwner->m_bMouseDown = FALSE; |
| 718 DoMouseUp(0, m_pOwner->m_rtMinBtn, m_pOwner->m_iMinButtonState, fx, fy); | 716 DoMouseUp(0, m_pOwner->m_rtMinBtn, m_pOwner->m_iMinButtonState, fx, fy); |
| 719 DoMouseUp(1, m_pOwner->m_rtThumb, m_pOwner->m_iThumbButtonState, fx, fy); | 717 DoMouseUp(1, m_pOwner->m_rtThumb, m_pOwner->m_iThumbButtonState, fx, fy); |
| 720 DoMouseUp(2, m_pOwner->m_rtMaxBtn, m_pOwner->m_iMaxButtonState, fx, fy); | 718 DoMouseUp(2, m_pOwner->m_rtMaxBtn, m_pOwner->m_iMaxButtonState, fx, fy); |
| 721 DoMouseUp(3, m_pOwner->m_rtMinTrack, m_pOwner->m_iMinTrackState, fx, fy); | 719 DoMouseUp(3, m_pOwner->m_rtMinTrack, m_pOwner->m_iMinTrackState, fx, fy); |
| 722 DoMouseUp(4, m_pOwner->m_rtMaxTrack, m_pOwner->m_iMaxTrackState, fx, fy); | 720 DoMouseUp(4, m_pOwner->m_rtMaxTrack, m_pOwner->m_iMaxTrackState, fx, fy); |
| 723 m_pOwner->SetGrab(FALSE); | 721 m_pOwner->SetGrab(FALSE); |
| 724 } | 722 } |
| 725 void CFWL_ScrollBarImpDelegate::OnMouseMove(uint32_t dwFlags, | 723 void CFWL_ScrollBarImpDelegate::OnMouseMove(uint32_t dwFlags, |
| 726 FX_FLOAT fx, | 724 FX_FLOAT fx, |
| (...skipping 79 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 806 } | 804 } |
| 807 void CFWL_ScrollBarImpDelegate::DoMouseHover(int32_t iItem, | 805 void CFWL_ScrollBarImpDelegate::DoMouseHover(int32_t iItem, |
| 808 const CFX_RectF& rtItem, | 806 const CFX_RectF& rtItem, |
| 809 int32_t& iState) { | 807 int32_t& iState) { |
| 810 if (iState == CFWL_PartState_Hovered) { | 808 if (iState == CFWL_PartState_Hovered) { |
| 811 return; | 809 return; |
| 812 } | 810 } |
| 813 iState = CFWL_PartState_Hovered; | 811 iState = CFWL_PartState_Hovered; |
| 814 m_pOwner->Repaint(&rtItem); | 812 m_pOwner->Repaint(&rtItem); |
| 815 } | 813 } |
| OLD | NEW |