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 <memory> 8 9#include "xfa/src/foxitlib.h" 10 11CFWL_ScrollBar* CFWL_ScrollBar::Create() { 12 return new CFWL_ScrollBar; 13} 14FWL_ERR CFWL_ScrollBar::Initialize(const CFWL_WidgetProperties* pProperties) { 15 if (m_pIface) 16 return FWL_ERR_Indefinite; 17 if (pProperties) { 18 *m_pProperties = *pProperties; 19 } 20 std::unique_ptr<IFWL_ScrollBar> pScrollBar(IFWL_ScrollBar::Create( 21 m_pProperties->MakeWidgetImpProperties(nullptr), nullptr)); 22 FWL_ERR ret = pScrollBar->Initialize(); 23 if (ret != FWL_ERR_Succeeded) { 24 return ret; 25 } 26 m_pIface = pScrollBar.release(); 27 CFWL_Widget::Initialize(); 28 return FWL_ERR_Succeeded; 29} 30FX_BOOL CFWL_ScrollBar::IsVertical() { 31 if (!m_pIface) 32 return FALSE; 33 return static_cast<IFWL_ScrollBar*>(m_pIface)->IsVertical(); 34} 35FWL_ERR CFWL_ScrollBar::GetRange(FX_FLOAT& fMin, FX_FLOAT& fMax) { 36 if (!m_pIface) 37 return FWL_ERR_Indefinite; 38 return static_cast<IFWL_ScrollBar*>(m_pIface)->GetRange(fMin, fMax); 39} 40FWL_ERR CFWL_ScrollBar::SetRange(FX_FLOAT fMin, FX_FLOAT fMax) { 41 if (!m_pIface) 42 return FWL_ERR_Indefinite; 43 return static_cast<IFWL_ScrollBar*>(m_pIface)->SetRange(fMin, fMax); 44} 45FX_FLOAT CFWL_ScrollBar::GetPageSize() { 46 if (!m_pIface) 47 return 0; 48 return static_cast<IFWL_ScrollBar*>(m_pIface)->GetPageSize(); 49} 50FWL_ERR CFWL_ScrollBar::SetPageSize(FX_FLOAT fPageSize) { 51 if (!m_pIface) 52 return FWL_ERR_Indefinite; 53 return static_cast<IFWL_ScrollBar*>(m_pIface)->SetPageSize(fPageSize); 54} 55FX_FLOAT CFWL_ScrollBar::GetStepSize() { 56 if (!m_pIface) 57 return 0; 58 return static_cast<IFWL_ScrollBar*>(m_pIface)->GetStepSize(); 59} 60FWL_ERR CFWL_ScrollBar::SetStepSize(FX_FLOAT fStepSize) { 61 if (!m_pIface) 62 return FWL_ERR_Indefinite; 63 return static_cast<IFWL_ScrollBar*>(m_pIface)->SetStepSize(fStepSize); 64} 65FX_FLOAT CFWL_ScrollBar::GetPos() { 66 if (!m_pIface) 67 return -1; 68 return static_cast<IFWL_ScrollBar*>(m_pIface)->GetPos(); 69} 70FWL_ERR CFWL_ScrollBar::SetPos(FX_FLOAT fPos) { 71 if (!m_pIface) 72 return FWL_ERR_Indefinite; 73 return static_cast<IFWL_ScrollBar*>(m_pIface)->SetPos(fPos); 74} 75FX_FLOAT CFWL_ScrollBar::GetTrackPos() { 76 if (!m_pIface) 77 return -1; 78 return static_cast<IFWL_ScrollBar*>(m_pIface)->GetTrackPos(); 79} 80FWL_ERR CFWL_ScrollBar::SetTrackPos(FX_FLOAT fTrackPos) { 81 if (!m_pIface) 82 return FWL_ERR_Indefinite; 83 return static_cast<IFWL_ScrollBar*>(m_pIface)->SetTrackPos(fTrackPos); 84} 85FX_BOOL CFWL_ScrollBar::DoScroll(FX_DWORD dwCode, FX_FLOAT fPos) { 86 if (!m_pIface) 87 return FALSE; 88 return static_cast<IFWL_ScrollBar*>(m_pIface)->DoScroll(dwCode, fPos); 89} 90CFWL_ScrollBar::CFWL_ScrollBar() {} 91CFWL_ScrollBar::~CFWL_ScrollBar() {} 92