// Copyright (c) 2010 The Chromium Authors. All rights reserved. // Use of this source code is governed by a BSD-style license that can be // found in the LICENSE file. #include #include "ppapi/cpp/dev/scrollbar_dev.h" #include "ppapi/cpp/instance_handle.h" #include "ppapi/cpp/module.h" #include "ppapi/cpp/module_impl.h" #include "ppapi/cpp/rect.h" namespace pp { namespace { template <> const char* interface_name() { return PPB_SCROLLBAR_DEV_INTERFACE; } } // namespace Scrollbar_Dev::Scrollbar_Dev(PP_Resource resource) : Widget_Dev(resource) { } Scrollbar_Dev::Scrollbar_Dev(const InstanceHandle& instance, bool vertical) { if (!has_interface()) return; PassRefFromConstructor(get_interface()->Create( instance.pp_instance(), PP_FromBool(vertical))); } Scrollbar_Dev::Scrollbar_Dev(const Scrollbar_Dev& other) : Widget_Dev(other) { } uint32_t Scrollbar_Dev::GetThickness() { if (!has_interface()) return 0; return get_interface()->GetThickness(pp_resource()); } bool Scrollbar_Dev::IsOverlay() { if (!has_interface()) return false; return PP_ToBool(get_interface()->IsOverlay(pp_resource())); } uint32_t Scrollbar_Dev::GetValue() { if (!has_interface()) return 0; return get_interface()->GetValue(pp_resource()); } void Scrollbar_Dev::SetValue(uint32_t value) { if (has_interface()) get_interface()->SetValue(pp_resource(), value); } void Scrollbar_Dev::SetDocumentSize(uint32_t size) { if (has_interface()) get_interface()->SetDocumentSize(pp_resource(), size); } void Scrollbar_Dev::SetTickMarks(const Rect* tick_marks, uint32_t count) { if (!has_interface()) return; std::vector temp; temp.resize(count); for (uint32_t i = 0; i < count; ++i) temp[i] = tick_marks[i]; get_interface()->SetTickMarks( pp_resource(), count ? &temp[0] : NULL, count); } void Scrollbar_Dev::ScrollBy(PP_ScrollBy_Dev unit, int32_t multiplier) { if (has_interface()) get_interface()->ScrollBy(pp_resource(), unit, multiplier); } } // namespace pp