OLD | NEW |
| (Empty) |
1 // Copyright 2014 PDFium Authors. All rights reserved. | |
2 // Use of this source code is governed by a BSD-style license that can be | |
3 // found in the LICENSE file. | |
4 | |
5 // Original code copyright 2014 Foxit Software Inc. http://www.foxitsoftware.com | |
6 | |
7 #include "xfa/fwl/lightwidget/cfwl_scrollbar.h" | |
8 | |
9 #include <memory> | |
10 | |
11 #include "xfa/fwl/basewidget/ifwl_scrollbar.h" | |
12 | |
13 CFWL_ScrollBar* CFWL_ScrollBar::Create() { | |
14 return new CFWL_ScrollBar; | |
15 } | |
16 | |
17 CFWL_ScrollBar::CFWL_ScrollBar() {} | |
18 | |
19 CFWL_ScrollBar::~CFWL_ScrollBar() {} | |
20 | |
21 FWL_Error CFWL_ScrollBar::Initialize(const CFWL_WidgetProperties* pProperties) { | |
22 if (m_pIface) | |
23 return FWL_Error::Indefinite; | |
24 if (pProperties) { | |
25 *m_pProperties = *pProperties; | |
26 } | |
27 std::unique_ptr<IFWL_ScrollBar> pScrollBar(IFWL_ScrollBar::Create( | |
28 m_pProperties->MakeWidgetImpProperties(nullptr), nullptr)); | |
29 FWL_Error ret = pScrollBar->Initialize(); | |
30 if (ret != FWL_Error::Succeeded) { | |
31 return ret; | |
32 } | |
33 m_pIface = pScrollBar.release(); | |
34 CFWL_Widget::Initialize(); | |
35 return FWL_Error::Succeeded; | |
36 } | |
37 | |
38 FX_BOOL CFWL_ScrollBar::IsVertical() { | |
39 if (!m_pIface) | |
40 return FALSE; | |
41 return static_cast<IFWL_ScrollBar*>(m_pIface)->IsVertical(); | |
42 } | |
43 | |
44 FWL_Error CFWL_ScrollBar::GetRange(FX_FLOAT& fMin, FX_FLOAT& fMax) { | |
45 if (!m_pIface) | |
46 return FWL_Error::Indefinite; | |
47 return static_cast<IFWL_ScrollBar*>(m_pIface)->GetRange(fMin, fMax); | |
48 } | |
49 | |
50 FWL_Error CFWL_ScrollBar::SetRange(FX_FLOAT fMin, FX_FLOAT fMax) { | |
51 if (!m_pIface) | |
52 return FWL_Error::Indefinite; | |
53 return static_cast<IFWL_ScrollBar*>(m_pIface)->SetRange(fMin, fMax); | |
54 } | |
55 | |
56 FX_FLOAT CFWL_ScrollBar::GetPageSize() { | |
57 if (!m_pIface) | |
58 return 0; | |
59 return static_cast<IFWL_ScrollBar*>(m_pIface)->GetPageSize(); | |
60 } | |
61 | |
62 FWL_Error CFWL_ScrollBar::SetPageSize(FX_FLOAT fPageSize) { | |
63 if (!m_pIface) | |
64 return FWL_Error::Indefinite; | |
65 return static_cast<IFWL_ScrollBar*>(m_pIface)->SetPageSize(fPageSize); | |
66 } | |
67 | |
68 FX_FLOAT CFWL_ScrollBar::GetStepSize() { | |
69 if (!m_pIface) | |
70 return 0; | |
71 return static_cast<IFWL_ScrollBar*>(m_pIface)->GetStepSize(); | |
72 } | |
73 | |
74 FWL_Error CFWL_ScrollBar::SetStepSize(FX_FLOAT fStepSize) { | |
75 if (!m_pIface) | |
76 return FWL_Error::Indefinite; | |
77 return static_cast<IFWL_ScrollBar*>(m_pIface)->SetStepSize(fStepSize); | |
78 } | |
79 | |
80 FX_FLOAT CFWL_ScrollBar::GetPos() { | |
81 if (!m_pIface) | |
82 return -1; | |
83 return static_cast<IFWL_ScrollBar*>(m_pIface)->GetPos(); | |
84 } | |
85 | |
86 FWL_Error CFWL_ScrollBar::SetPos(FX_FLOAT fPos) { | |
87 if (!m_pIface) | |
88 return FWL_Error::Indefinite; | |
89 return static_cast<IFWL_ScrollBar*>(m_pIface)->SetPos(fPos); | |
90 } | |
91 | |
92 FX_FLOAT CFWL_ScrollBar::GetTrackPos() { | |
93 if (!m_pIface) | |
94 return -1; | |
95 return static_cast<IFWL_ScrollBar*>(m_pIface)->GetTrackPos(); | |
96 } | |
97 | |
98 FWL_Error CFWL_ScrollBar::SetTrackPos(FX_FLOAT fTrackPos) { | |
99 if (!m_pIface) | |
100 return FWL_Error::Indefinite; | |
101 return static_cast<IFWL_ScrollBar*>(m_pIface)->SetTrackPos(fTrackPos); | |
102 } | |
103 | |
104 FX_BOOL CFWL_ScrollBar::DoScroll(uint32_t dwCode, FX_FLOAT fPos) { | |
105 if (!m_pIface) | |
106 return FALSE; | |
107 return static_cast<IFWL_ScrollBar*>(m_pIface)->DoScroll(dwCode, fPos); | |
108 } | |
OLD | NEW |