Merge XFA to PDFium master at 4dc95e7 on 10/28/2014
[pdfium.git] / xfa / src / fwl / src / lightwidget / scrollbar.cpp
1 // Copyright 2014 PDFium Authors. All rights reserved.\r
2 // Use of this source code is governed by a BSD-style license that can be\r
3 // found in the LICENSE file.\r
4 \r
5 // Original code copyright 2014 Foxit Software Inc. http://www.foxitsoftware.com\r
6 \r
7 #include "../../../foxitlib.h"\r
8 CFWL_ScrollBar* CFWL_ScrollBar::Create()\r
9 {\r
10     return FX_NEW CFWL_ScrollBar;\r
11 }\r
12 FWL_ERR CFWL_ScrollBar::Initialize(const CFWL_WidgetProperties *pProperties )\r
13 {\r
14     _FWL_RETURN_VALUE_IF_FAIL(!m_pImp, FWL_ERR_Indefinite);\r
15     if (pProperties) {\r
16         *m_pProperties = *pProperties;\r
17     }\r
18     CFWL_WidgetImpProperties prop;\r
19     prop.m_dwStyles = m_pProperties->m_dwStyles;\r
20     prop.m_dwStyleExes = m_pProperties->m_dwStyleExes;\r
21     prop.m_dwStates = m_pProperties->m_dwStates;\r
22     prop.m_ctmOnParent = m_pProperties->m_ctmOnParent;\r
23     if (m_pProperties->m_pParent) {\r
24         prop.m_pParent = m_pProperties->m_pParent->GetWidget();\r
25     }\r
26     if (m_pProperties->m_pOwner) {\r
27         prop.m_pOwner = m_pProperties->m_pOwner->GetWidget();\r
28     }\r
29     prop.m_rtWidget = m_pProperties->m_rtWidget;\r
30     m_pImp = IFWL_ScrollBar::Create();\r
31     FWL_ERR ret = ((IFWL_ScrollBar*)m_pImp)->Initialize(prop);\r
32     if (ret == FWL_ERR_Succeeded) {\r
33         CFWL_Widget::Initialize();\r
34     }\r
35     return ret;\r
36 }\r
37 FX_BOOL CFWL_ScrollBar::IsVertical()\r
38 {\r
39     _FWL_RETURN_VALUE_IF_FAIL(m_pImp, FALSE);\r
40     return ((IFWL_ScrollBar*)m_pImp)->IsVertical();\r
41 }\r
42 FWL_ERR CFWL_ScrollBar::GetRange(FX_FLOAT &fMin, FX_FLOAT &fMax)\r
43 {\r
44     _FWL_RETURN_VALUE_IF_FAIL(m_pImp, FWL_ERR_Indefinite);\r
45     return ((IFWL_ScrollBar*)m_pImp)->GetRange(fMin, fMax);\r
46 }\r
47 FWL_ERR CFWL_ScrollBar::SetRange(FX_FLOAT fMin, FX_FLOAT fMax)\r
48 {\r
49     _FWL_RETURN_VALUE_IF_FAIL(m_pImp, FWL_ERR_Indefinite);\r
50     return ((IFWL_ScrollBar*)m_pImp)->SetRange(fMin, fMax);\r
51 }\r
52 FX_FLOAT CFWL_ScrollBar::GetPageSize()\r
53 {\r
54     _FWL_RETURN_VALUE_IF_FAIL(m_pImp, 0);\r
55     return ((IFWL_ScrollBar*)m_pImp)->GetPageSize();\r
56 }\r
57 FWL_ERR CFWL_ScrollBar::SetPageSize(FX_FLOAT fPageSize)\r
58 {\r
59     _FWL_RETURN_VALUE_IF_FAIL(m_pImp, FWL_ERR_Indefinite);\r
60     return ((IFWL_ScrollBar*)m_pImp)->SetPageSize(fPageSize);\r
61 }\r
62 FX_FLOAT CFWL_ScrollBar::GetStepSize()\r
63 {\r
64     _FWL_RETURN_VALUE_IF_FAIL(m_pImp, 0);\r
65     return ((IFWL_ScrollBar*)m_pImp)->GetStepSize();\r
66 }\r
67 FWL_ERR CFWL_ScrollBar::SetStepSize(FX_FLOAT fStepSize)\r
68 {\r
69     _FWL_RETURN_VALUE_IF_FAIL(m_pImp, FWL_ERR_Indefinite);\r
70     return ((IFWL_ScrollBar*)m_pImp)->SetStepSize(fStepSize);\r
71 }\r
72 FX_FLOAT CFWL_ScrollBar::GetPos()\r
73 {\r
74     _FWL_RETURN_VALUE_IF_FAIL(m_pImp, -1);\r
75     return ((IFWL_ScrollBar*)m_pImp)->GetPos();\r
76 }\r
77 FWL_ERR CFWL_ScrollBar::SetPos(FX_FLOAT fPos)\r
78 {\r
79     _FWL_RETURN_VALUE_IF_FAIL(m_pImp, FWL_ERR_Indefinite);\r
80     return ((IFWL_ScrollBar*)m_pImp)->SetPos(fPos);\r
81 }\r
82 FX_FLOAT CFWL_ScrollBar::GetTrackPos()\r
83 {\r
84     _FWL_RETURN_VALUE_IF_FAIL(m_pImp, -1);\r
85     return ((IFWL_ScrollBar*)m_pImp)->GetTrackPos();\r
86 }\r
87 FWL_ERR CFWL_ScrollBar::SetTrackPos(FX_FLOAT fTrackPos)\r
88 {\r
89     _FWL_RETURN_VALUE_IF_FAIL(m_pImp, FWL_ERR_Indefinite);\r
90     return ((IFWL_ScrollBar*)m_pImp)->SetTrackPos(fTrackPos);\r
91 }\r
92 FX_BOOL CFWL_ScrollBar::DoScroll(FX_DWORD dwCode, FX_FLOAT fPos)\r
93 {\r
94     _FWL_RETURN_VALUE_IF_FAIL(m_pImp, FALSE);\r
95     return ((IFWL_ScrollBar*)m_pImp)->DoScroll(dwCode, fPos);\r
96 }\r
97 CFWL_ScrollBar::CFWL_ScrollBar()\r
98 {\r
99 }\r
100 CFWL_ScrollBar::~CFWL_ScrollBar()\r
101 {\r
102 }\r