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
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
165
166
167
168
169
170
171
172
173
174
175
176
177
178
179
180
181
182
183
184
185
186
187
188
189
190
191
192
193
194
195
196
197
198
199
200
201
202
203
204
205
206
207
208
209
210
211
212
213
214
215
216
217
218
219
220
221
222
223
224
225
226
227
228
229
230
231
232
233
234
235
236
237
238
239
240
241
242
243
244
245
246
247
248
249
250
251
252
253
254
255
256
257
258
259
260
261
262
263
264
265
266
267
268
269
270
271
272
273
274
275
276
277
278
279
280
281
282
283
284
285
286
287
288
289
290
291
292
293
294
295
296
297
298
299
300
301
302
303
304
305
306
307
308
309
310
311
312
313
314
315
316
317
318
319
320
321
322
323
324
325
326
327
328
329
330
331
|
// 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_views.h"
#include "views/view.h"
#include "views/widget/native_widget_view.h"
namespace views {
////////////////////////////////////////////////////////////////////////////////
// NativeWidgetViews, public:
NativeWidgetViews::NativeWidgetViews(View* host,
internal::NativeWidgetDelegate* delegate)
: delegate_(delegate),
view_(NULL),
host_view_(host),
active_(false),
ALLOW_THIS_IN_INITIALIZER_LIST(close_widget_factory_(this)) {
}
NativeWidgetViews::~NativeWidgetViews() {
}
View* NativeWidgetViews::GetView() {
return view_;
}
const View* NativeWidgetViews::GetView() const {
return view_;
}
void NativeWidgetViews::OnActivate(bool active) {
active_ = active;
view_->SchedulePaint();
}
////////////////////////////////////////////////////////////////////////////////
// NativeWidgetViews, NativeWidget implementation:
void NativeWidgetViews::InitNativeWidget(const Widget::InitParams& params) {
view_ = new internal::NativeWidgetView(this);
host_view_->AddChildView(view_);
// TODO(beng): handle parenting.
// TODO(beng): SetInitParams().
}
NonClientFrameView* NativeWidgetViews::CreateNonClientFrameView() {
return NULL;
}
void NativeWidgetViews::UpdateFrameAfterFrameChange() {
}
bool NativeWidgetViews::ShouldUseNativeFrame() const {
NOTIMPLEMENTED();
return false;
}
void NativeWidgetViews::FrameTypeChanged() {
}
Widget* NativeWidgetViews::GetWidget() {
return delegate_->AsWidget();
}
const Widget* NativeWidgetViews::GetWidget() const {
return delegate_->AsWidget();
}
gfx::NativeView NativeWidgetViews::GetNativeView() const {
return GetParentNativeWidget()->GetNativeView();
}
gfx::NativeWindow NativeWidgetViews::GetNativeWindow() const {
return GetParentNativeWidget()->GetNativeWindow();
}
void NativeWidgetViews::ViewRemoved(View* view) {
return GetParentNativeWidget()->ViewRemoved(view);
}
void NativeWidgetViews::SetNativeWindowProperty(const char* name, void* value) {
NOTIMPLEMENTED();
}
void* NativeWidgetViews::GetNativeWindowProperty(const char* name) const {
NOTIMPLEMENTED();
return NULL;
}
TooltipManager* NativeWidgetViews::GetTooltipManager() const {
return GetParentNativeWidget()->GetTooltipManager();
}
bool NativeWidgetViews::IsScreenReaderActive() const {
return GetParentNativeWidget()->IsScreenReaderActive();
}
void NativeWidgetViews::SendNativeAccessibilityEvent(
View* view,
ui::AccessibilityTypes::Event event_type) {
return GetParentNativeWidget()->SendNativeAccessibilityEvent(view,
event_type);
}
void NativeWidgetViews::SetMouseCapture() {
GetParentNativeWidget()->SetMouseCapture();
}
void NativeWidgetViews::ReleaseMouseCapture() {
GetParentNativeWidget()->ReleaseMouseCapture();
}
bool NativeWidgetViews::HasMouseCapture() const {
return GetParentNativeWidget()->HasMouseCapture();
}
bool NativeWidgetViews::IsMouseButtonDown() const {
return GetParentNativeWidget()->IsMouseButtonDown();
}
InputMethod* NativeWidgetViews::GetInputMethodNative() {
return GetParentNativeWidget()->GetInputMethodNative();
}
void NativeWidgetViews::ReplaceInputMethod(InputMethod* input_method) {
GetParentNativeWidget()->ReplaceInputMethod(input_method);
}
void NativeWidgetViews::CenterWindow(const gfx::Size& size) {
// TODO(beng): actually center.
GetView()->SetBounds(0, 0, size.width(), size.height());
}
void NativeWidgetViews::GetWindowBoundsAndMaximizedState(
gfx::Rect* bounds,
bool* maximized) const {
*bounds = GetView()->bounds();
*maximized = false;
}
void NativeWidgetViews::SetWindowTitle(const std::wstring& title) {
}
void NativeWidgetViews::SetWindowIcons(const SkBitmap& window_icon,
const SkBitmap& app_icon) {
}
void NativeWidgetViews::SetAccessibleName(const std::wstring& name) {
}
void NativeWidgetViews::SetAccessibleRole(ui::AccessibilityTypes::Role role) {
}
void NativeWidgetViews::SetAccessibleState(
ui::AccessibilityTypes::State state) {
}
void NativeWidgetViews::BecomeModal() {
NOTIMPLEMENTED();
}
gfx::AcceleratedWidget NativeWidgetViews::GetAcceleratedWidget() {
// TODO(sky):
return gfx::kNullAcceleratedWidget;
}
gfx::Rect NativeWidgetViews::GetWindowScreenBounds() const {
gfx::Point origin = view_->bounds().origin();
View::ConvertPointToScreen(view_->parent(), &origin);
return gfx::Rect(origin.x(), origin.y(), view_->width(), view_->height());
}
gfx::Rect NativeWidgetViews::GetClientAreaScreenBounds() const {
return GetWindowScreenBounds();
}
gfx::Rect NativeWidgetViews::GetRestoredBounds() const {
return GetWindowScreenBounds();
}
void NativeWidgetViews::SetBounds(const gfx::Rect& bounds) {
// |bounds| are supplied in the coordinates of the parent.
view_->SetBoundsRect(bounds);
}
void NativeWidgetViews::SetSize(const gfx::Size& size) {
view_->SetSize(size);
}
void NativeWidgetViews::SetBoundsConstrained(const gfx::Rect& bounds,
Widget* other_widget) {
// TODO(beng): honor other_widget.
SetBounds(bounds);
}
void NativeWidgetViews::MoveAbove(gfx::NativeView native_view) {
NOTIMPLEMENTED();
}
void NativeWidgetViews::SetShape(gfx::NativeRegion region) {
NOTIMPLEMENTED();
}
void NativeWidgetViews::Close() {
Hide();
if (close_widget_factory_.empty()) {
MessageLoop::current()->PostTask(FROM_HERE,
close_widget_factory_.NewRunnableMethod(&NativeWidgetViews::CloseNow));
}
}
void NativeWidgetViews::CloseNow() {
view_->parent()->RemoveChildView(view_);
delete view_;
}
void NativeWidgetViews::EnableClose(bool enable) {
}
void NativeWidgetViews::Show() {
view_->SetVisible(true);
}
void NativeWidgetViews::Hide() {
view_->SetVisible(false);
}
void NativeWidgetViews::ShowNativeWidget(ShowState state) {
}
bool NativeWidgetViews::IsVisible() const {
return view_->IsVisible();
}
void NativeWidgetViews::Activate() {
NOTIMPLEMENTED();
}
void NativeWidgetViews::Deactivate() {
NOTIMPLEMENTED();
}
bool NativeWidgetViews::IsActive() const {
return active_;
}
void NativeWidgetViews::SetAlwaysOnTop(bool on_top) {
NOTIMPLEMENTED();
}
void NativeWidgetViews::Maximize() {
NOTIMPLEMENTED();
}
void NativeWidgetViews::Minimize() {
NOTIMPLEMENTED();
}
bool NativeWidgetViews::IsMaximized() const {
NOTIMPLEMENTED();
return false;
}
bool NativeWidgetViews::IsMinimized() const {
NOTIMPLEMENTED();
return false;
}
void NativeWidgetViews::Restore() {
NOTIMPLEMENTED();
}
void NativeWidgetViews::SetFullscreen(bool fullscreen) {
NOTIMPLEMENTED();
}
bool NativeWidgetViews::IsFullscreen() const {
NOTIMPLEMENTED();
return false;
}
void NativeWidgetViews::SetOpacity(unsigned char opacity) {
NOTIMPLEMENTED();
}
void NativeWidgetViews::SetUseDragFrame(bool use_drag_frame) {
NOTIMPLEMENTED();
}
bool NativeWidgetViews::IsAccessibleWidget() const {
NOTIMPLEMENTED();
return false;
}
bool NativeWidgetViews::ContainsNativeView(gfx::NativeView native_view) const {
NOTIMPLEMENTED();
return GetParentNativeWidget()->ContainsNativeView(native_view);
}
void NativeWidgetViews::RunShellDrag(View* view,
const ui::OSExchangeData& data,
int operation) {
GetParentNativeWidget()->RunShellDrag(view, data, operation);
}
void NativeWidgetViews::SchedulePaintInRect(const gfx::Rect& rect) {
view_->SchedulePaintInRect(rect);
}
void NativeWidgetViews::SetCursor(gfx::NativeCursor cursor) {
GetParentNativeWidget()->SetCursor(cursor);
}
////////////////////////////////////////////////////////////////////////////////
// NativeWidgetViews, private:
NativeWidget* NativeWidgetViews::GetParentNativeWidget() {
return view_->GetWidget()->native_widget();
}
const NativeWidget* NativeWidgetViews::GetParentNativeWidget() const {
return view_->GetWidget()->native_widget();
}
} // namespace views
|