1 // Copyright (c) 2010 The Chromium 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.
7 #include "ppapi/cpp/dev/scrollbar_dev.h"
9 #include "ppapi/cpp/instance_handle.h"
10 #include "ppapi/cpp/module.h"
11 #include "ppapi/cpp/module_impl.h"
12 #include "ppapi/cpp/rect.h"
18 template <> const char* interface_name
<PPB_Scrollbar_Dev
>() {
19 return PPB_SCROLLBAR_DEV_INTERFACE
;
24 Scrollbar_Dev::Scrollbar_Dev(PP_Resource resource
) : Widget_Dev(resource
) {
27 Scrollbar_Dev::Scrollbar_Dev(const InstanceHandle
& instance
, bool vertical
) {
28 if (!has_interface
<PPB_Scrollbar_Dev
>())
30 PassRefFromConstructor(get_interface
<PPB_Scrollbar_Dev
>()->Create(
31 instance
.pp_instance(), PP_FromBool(vertical
)));
34 Scrollbar_Dev::Scrollbar_Dev(const Scrollbar_Dev
& other
)
38 uint32_t Scrollbar_Dev::GetThickness() {
39 if (!has_interface
<PPB_Scrollbar_Dev
>())
41 return get_interface
<PPB_Scrollbar_Dev
>()->GetThickness(pp_resource());
44 bool Scrollbar_Dev::IsOverlay() {
45 if (!has_interface
<PPB_Scrollbar_Dev
>())
48 PP_ToBool(get_interface
<PPB_Scrollbar_Dev
>()->IsOverlay(pp_resource()));
51 uint32_t Scrollbar_Dev::GetValue() {
52 if (!has_interface
<PPB_Scrollbar_Dev
>())
54 return get_interface
<PPB_Scrollbar_Dev
>()->GetValue(pp_resource());
57 void Scrollbar_Dev::SetValue(uint32_t value
) {
58 if (has_interface
<PPB_Scrollbar_Dev
>())
59 get_interface
<PPB_Scrollbar_Dev
>()->SetValue(pp_resource(), value
);
62 void Scrollbar_Dev::SetDocumentSize(uint32_t size
) {
63 if (has_interface
<PPB_Scrollbar_Dev
>())
64 get_interface
<PPB_Scrollbar_Dev
>()->SetDocumentSize(pp_resource(), size
);
67 void Scrollbar_Dev::SetTickMarks(const Rect
* tick_marks
, uint32_t count
) {
68 if (!has_interface
<PPB_Scrollbar_Dev
>())
71 std::vector
<PP_Rect
> temp
;
73 for (uint32_t i
= 0; i
< count
; ++i
)
74 temp
[i
] = tick_marks
[i
];
76 get_interface
<PPB_Scrollbar_Dev
>()->SetTickMarks(
77 pp_resource(), count
? &temp
[0] : NULL
, count
);
80 void Scrollbar_Dev::ScrollBy(PP_ScrollBy_Dev unit
, int32_t multiplier
) {
81 if (has_interface
<PPB_Scrollbar_Dev
>())
82 get_interface
<PPB_Scrollbar_Dev
>()->ScrollBy(pp_resource(),