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_scrollbar.h" | 7 #include "xfa/fwl/core/ifwl_scrollbar.h" |
8 | 8 |
| 9 #include "third_party/base/ptr_util.h" |
9 #include "xfa/fwl/core/cfwl_message.h" | 10 #include "xfa/fwl/core/cfwl_message.h" |
10 #include "xfa/fwl/core/cfwl_themebackground.h" | 11 #include "xfa/fwl/core/cfwl_themebackground.h" |
11 #include "xfa/fwl/core/cfwl_themepart.h" | 12 #include "xfa/fwl/core/cfwl_themepart.h" |
12 #include "xfa/fwl/core/fwl_noteimp.h" | 13 #include "xfa/fwl/core/fwl_noteimp.h" |
13 #include "xfa/fwl/core/ifwl_scrollbar.h" | 14 #include "xfa/fwl/core/ifwl_scrollbar.h" |
14 #include "xfa/fwl/core/ifwl_themeprovider.h" | 15 #include "xfa/fwl/core/ifwl_themeprovider.h" |
15 | 16 |
16 #define FWL_SCROLLBAR_Elapse 500 | 17 #define FWL_SCROLLBAR_Elapse 500 |
17 #define FWL_SCROLLBAR_MinThumb 5 | 18 #define FWL_SCROLLBAR_MinThumb 5 |
18 | 19 |
(...skipping 25 matching lines...) Expand all Loading... |
44 m_bMinSize(FALSE), | 45 m_bMinSize(FALSE), |
45 m_bCustomLayout(false), | 46 m_bCustomLayout(false), |
46 m_fMinThumb(FWL_SCROLLBAR_MinThumb), | 47 m_fMinThumb(FWL_SCROLLBAR_MinThumb), |
47 m_Timer(this) { | 48 m_Timer(this) { |
48 m_rtClient.Reset(); | 49 m_rtClient.Reset(); |
49 m_rtThumb.Reset(); | 50 m_rtThumb.Reset(); |
50 m_rtMinBtn.Reset(); | 51 m_rtMinBtn.Reset(); |
51 m_rtMaxBtn.Reset(); | 52 m_rtMaxBtn.Reset(); |
52 m_rtMinTrack.Reset(); | 53 m_rtMinTrack.Reset(); |
53 m_rtMaxTrack.Reset(); | 54 m_rtMaxTrack.Reset(); |
| 55 |
| 56 SetDelegate(pdfium::MakeUnique<CFWL_ScrollBarImpDelegate>(this)); |
54 } | 57 } |
55 | 58 |
56 IFWL_ScrollBar::~IFWL_ScrollBar() {} | 59 IFWL_ScrollBar::~IFWL_ScrollBar() {} |
57 | 60 |
58 void IFWL_ScrollBar::Initialize() { | |
59 IFWL_Widget::Initialize(); | |
60 m_pDelegate = new CFWL_ScrollBarImpDelegate(this); | |
61 } | |
62 | |
63 void IFWL_ScrollBar::Finalize() { | |
64 delete m_pDelegate; | |
65 m_pDelegate = nullptr; | |
66 IFWL_Widget::Finalize(); | |
67 } | |
68 | |
69 FWL_Type IFWL_ScrollBar::GetClassID() const { | 61 FWL_Type IFWL_ScrollBar::GetClassID() const { |
70 return FWL_Type::ScrollBar; | 62 return FWL_Type::ScrollBar; |
71 } | 63 } |
72 | 64 |
73 FWL_Error IFWL_ScrollBar::GetWidgetRect(CFX_RectF& rect, FX_BOOL bAutoSize) { | 65 FWL_Error IFWL_ScrollBar::GetWidgetRect(CFX_RectF& rect, FX_BOOL bAutoSize) { |
74 if (bAutoSize) { | 66 if (bAutoSize) { |
75 rect.Set(0, 0, 0, 0); | 67 rect.Set(0, 0, 0, 0); |
76 FX_FLOAT* pfMinWidth = static_cast<FX_FLOAT*>( | 68 FX_FLOAT* pfMinWidth = static_cast<FX_FLOAT*>( |
77 GetThemeCapacity(CFWL_WidgetCapacity::ScrollBarWidth)); | 69 GetThemeCapacity(CFWL_WidgetCapacity::ScrollBarWidth)); |
78 if (!pfMinWidth) | 70 if (!pfMinWidth) |
(...skipping 692 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
771 | 763 |
772 void IFWL_ScrollBar::Timer::Run(IFWL_TimerInfo* pTimerInfo) { | 764 void IFWL_ScrollBar::Timer::Run(IFWL_TimerInfo* pTimerInfo) { |
773 IFWL_ScrollBar* pButton = static_cast<IFWL_ScrollBar*>(m_pWidget); | 765 IFWL_ScrollBar* pButton = static_cast<IFWL_ScrollBar*>(m_pWidget); |
774 | 766 |
775 if (pButton->m_pTimerInfo) | 767 if (pButton->m_pTimerInfo) |
776 pButton->m_pTimerInfo->StopTimer(); | 768 pButton->m_pTimerInfo->StopTimer(); |
777 | 769 |
778 if (!pButton->SendEvent()) | 770 if (!pButton->SendEvent()) |
779 pButton->m_pTimerInfo = StartTimer(0, true); | 771 pButton->m_pTimerInfo = StartTimer(0, true); |
780 } | 772 } |
OLD | NEW |