OLD | NEW |
| (Empty) |
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. | |
4 | |
5 #include "ppapi/cpp/dev/widget_dev.h" | |
6 | |
7 #include "ppapi/c/dev/ppb_widget_dev.h" | |
8 #include "ppapi/cpp/image_data.h" | |
9 #include "ppapi/cpp/input_event.h" | |
10 #include "ppapi/cpp/instance.h" | |
11 #include "ppapi/cpp/module.h" | |
12 #include "ppapi/cpp/rect.h" | |
13 #include "ppapi/cpp/module_impl.h" | |
14 | |
15 namespace pp { | |
16 | |
17 namespace { | |
18 | |
19 template <> const char* interface_name<PPB_Widget_Dev_0_3>() { | |
20 return PPB_WIDGET_DEV_INTERFACE_0_3; | |
21 } | |
22 | |
23 template <> const char* interface_name<PPB_Widget_Dev_0_4>() { | |
24 return PPB_WIDGET_DEV_INTERFACE_0_4; | |
25 } | |
26 | |
27 } // namespace | |
28 | |
29 Widget_Dev::Widget_Dev(PP_Resource resource) : Resource(resource) { | |
30 } | |
31 | |
32 Widget_Dev::Widget_Dev(const Widget_Dev& other) : Resource(other) { | |
33 } | |
34 | |
35 bool Widget_Dev::Paint(const Rect& rect, ImageData* image) { | |
36 if (has_interface<PPB_Widget_Dev_0_4>()) { | |
37 return PP_ToBool(get_interface<PPB_Widget_Dev_0_4>()->Paint( | |
38 pp_resource(), &rect.pp_rect(), image->pp_resource())); | |
39 } else if (has_interface<PPB_Widget_Dev_0_3>()) { | |
40 return PP_ToBool(get_interface<PPB_Widget_Dev_0_3>()->Paint( | |
41 pp_resource(), &rect.pp_rect(), image->pp_resource())); | |
42 } | |
43 return false; | |
44 } | |
45 | |
46 bool Widget_Dev::HandleEvent(const InputEvent& event) { | |
47 if (has_interface<PPB_Widget_Dev_0_4>()) { | |
48 return PP_ToBool(get_interface<PPB_Widget_Dev_0_4>()->HandleEvent( | |
49 pp_resource(), event.pp_resource())); | |
50 } else if (has_interface<PPB_Widget_Dev_0_3>()) { | |
51 return PP_ToBool(get_interface<PPB_Widget_Dev_0_3>()->HandleEvent( | |
52 pp_resource(), event.pp_resource())); | |
53 } | |
54 return false; | |
55 } | |
56 | |
57 bool Widget_Dev::GetLocation(Rect* location) { | |
58 if (has_interface<PPB_Widget_Dev_0_4>()) { | |
59 return PP_ToBool(get_interface<PPB_Widget_Dev_0_4>()->GetLocation( | |
60 pp_resource(), &location->pp_rect())); | |
61 } else if (has_interface<PPB_Widget_Dev_0_3>()) { | |
62 return PP_ToBool(get_interface<PPB_Widget_Dev_0_3>()->GetLocation( | |
63 pp_resource(), &location->pp_rect())); | |
64 } | |
65 return false; | |
66 } | |
67 | |
68 void Widget_Dev::SetLocation(const Rect& location) { | |
69 if (has_interface<PPB_Widget_Dev_0_4>()) { | |
70 get_interface<PPB_Widget_Dev_0_4>()->SetLocation(pp_resource(), | |
71 &location.pp_rect()); | |
72 } else if (has_interface<PPB_Widget_Dev_0_3>()) { | |
73 get_interface<PPB_Widget_Dev_0_3>()->SetLocation(pp_resource(), | |
74 &location.pp_rect()); | |
75 } | |
76 } | |
77 | |
78 void Widget_Dev::SetScale(float scale) { | |
79 if (has_interface<PPB_Widget_Dev_0_4>()) | |
80 get_interface<PPB_Widget_Dev_0_4>()->SetScale(pp_resource(), scale); | |
81 } | |
82 | |
83 } // namespace pp | |
OLD | NEW |