summaryrefslogtreecommitdiffstats
path: root/ppapi/cpp/dev/widget_dev.cc
blob: 46f36b5aae3f256648d1471d47d37dc45b4d16bf (plain)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
// 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 "ppapi/cpp/dev/widget_dev.h"

#include "ppapi/c/dev/ppb_widget_dev.h"
#include "ppapi/cpp/common.h"
#include "ppapi/cpp/image_data.h"
#include "ppapi/cpp/instance.h"
#include "ppapi/cpp/module.h"
#include "ppapi/cpp/rect.h"
#include "ppapi/cpp/module_impl.h"

namespace {

DeviceFuncs<PPB_Widget_Dev> widget_f(PPB_WIDGET_DEV_INTERFACE);

}  // namespace

namespace pp {

Widget_Dev::Widget_Dev(PP_Resource resource) : Resource(resource) {
}

Widget_Dev::Widget_Dev(const Widget_Dev& other) : Resource(other) {
}

Widget_Dev& Widget_Dev::operator=(const Widget_Dev& other) {
  Resource::operator=(other);
  return *this;
}

bool Widget_Dev::Paint(const Rect& rect, ImageData* image) {
  if (!widget_f)
    return false;
  return PPBoolToBool(widget_f->Paint(pp_resource(),
                                      &rect.pp_rect(),
                                      image->pp_resource()));
}

bool Widget_Dev::HandleEvent(const PP_InputEvent& event) {
  if (!widget_f)
    return false;
  return PPBoolToBool(widget_f->HandleEvent(pp_resource(), &event));
}

bool Widget_Dev::GetLocation(Rect* location) {
  if (!widget_f)
    return false;
  return PPBoolToBool(widget_f->GetLocation(pp_resource(),
                                            &location->pp_rect()));
}

void Widget_Dev::SetLocation(const Rect& location) {
  if (widget_f)
    widget_f->SetLocation(pp_resource(), &location.pp_rect());
}

}  // namespace pp