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
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
|
// Copyright (c) 2011 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 "views/widget/native_widget_view.h"
#include "ui/gfx/canvas.h"
namespace views {
namespace internal {
////////////////////////////////////////////////////////////////////////////////
// NativeWidgetView, public:
// static
const char NativeWidgetView::kViewClassName[] = "views/NativeWidgetView";
NativeWidgetView::NativeWidgetView(NativeWidgetViews* native_widget)
: native_widget_(native_widget) {
}
NativeWidgetView::~NativeWidgetView() {
}
Widget* NativeWidgetView::GetAssociatedWidget() {
return native_widget_->delegate()->AsWidget();
}
////////////////////////////////////////////////////////////////////////////////
// NativeWidgetView, View overrides:
void NativeWidgetView::SchedulePaintInternal(const gfx::Rect& r) {
View::SchedulePaintInternal(r);
}
void NativeWidgetView::ViewHierarchyChanged(bool is_add, View* parent,
View* child) {
if (is_add && child == this)
delegate()->OnNativeWidgetCreated();
}
void NativeWidgetView::OnBoundsChanged(const gfx::Rect& previous_bounds) {
delegate()->OnNativeWidgetSizeChanged(size());
}
void NativeWidgetView::OnPaint(gfx::Canvas* canvas) {
canvas->FillRectInt(SK_ColorRED, 0, 0, width(), height());
delegate()->OnNativeWidgetPaint(canvas);
}
bool NativeWidgetView::OnMousePressed(const MouseEvent& event) {
MouseEvent e(event, this);
return delegate()->OnMouseEvent(event);
}
bool NativeWidgetView::OnMouseDragged(const MouseEvent& event) {
MouseEvent e(event, this);
return delegate()->OnMouseEvent(event);
}
void NativeWidgetView::OnMouseReleased(const MouseEvent& event) {
MouseEvent e(event, this);
delegate()->OnMouseEvent(event);
}
void NativeWidgetView::OnMouseCaptureLost() {
delegate()->OnMouseCaptureLost();
}
void NativeWidgetView::OnMouseMoved(const MouseEvent& event) {
MouseEvent e(event, this);
delegate()->OnMouseEvent(event);
}
void NativeWidgetView::OnMouseEntered(const MouseEvent& event) {
MouseEvent e(event, this);
delegate()->OnMouseEvent(event);
}
void NativeWidgetView::OnMouseExited(const MouseEvent& event) {
MouseEvent e(event, this);
delegate()->OnMouseEvent(event);
}
#if defined(TOUCH_UI)
ui::TouchStatus NativeWidgetView::OnTouchEvent(const TouchEvent& event) {
return delegate()->OnTouchEvent(event);
}
#endif
bool NativeWidgetView::OnKeyPressed(const KeyEvent& event) {
return delegate()->OnKeyEvent(event);
}
bool NativeWidgetView::OnKeyReleased(const KeyEvent& event) {
return delegate()->OnKeyEvent(event);
}
bool NativeWidgetView::OnMouseWheel(const MouseWheelEvent& event) {
MouseWheelEvent e(event, this);
return delegate()->OnMouseEvent(event);
}
void NativeWidgetView::OnFocus() {
// TODO(beng): check if we have to do this.
//delegate()->OnNativeFocus(NULL);
}
void NativeWidgetView::OnBlur() {
// TODO(beng): check if we have to do this.
//delegate()->OnNativeBlur(NULL);
}
std::string NativeWidgetView::GetClassName() const {
return kViewClassName;
}
} // namespace internal
} // namespace views
|