Chromium Code Reviews
chromiumcodereview-hr@appspot.gserviceaccount.com (chromiumcodereview-hr) | Please choose your nickname with Settings | Help | Chromium Project | Gerrit Changes | Sign out
(36)

Side by Side Diff: views/widget/native_widget_views.cc

Issue 6990048: Add NativeWidgetViews. This is a stub implementation that mostly just defers to its parent Native... (Closed) Base URL: svn://svn.chromium.org/chrome/trunk/src/
Patch Set: '' Created 9 years, 7 months ago
Use n/p to move between diff chunks; N/P to move between comments. Draft comments are only viewable by you.
Jump to:
View unified diff | Download patch | Annotate | Revision Log
« no previous file with comments | « views/widget/native_widget_views.h ('k') | no next file » | no next file with comments »
Toggle Intra-line Diffs ('i') | Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
Property Changes:
Added: svn:eol-style
+ LF
OLDNEW
(Empty)
1 // Copyright (c) 2011 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 "views/widget/native_widget_views.h"
6
7 #include "ui/gfx/canvas.h"
8 #include "views/view.h"
9
10 namespace views {
11
12 ////////////////////////////////////////////////////////////////////////////////
13 // NativeWidgetViews::NativeWidgetView:
14
15 class NativeWidgetViews::NativeWidgetView : public View {
16 public:
17 NativeWidgetView() {}
18 virtual ~NativeWidgetView() {}
19
20 // Overridden from View:
21 virtual void OnPaint(gfx::Canvas* canvas) {
22 canvas->FillRectInt(SK_ColorRED, 0, 0, width(), height());
23 }
24
25 private:
26 DISALLOW_COPY_AND_ASSIGN(NativeWidgetView);
27 };
28
29 ////////////////////////////////////////////////////////////////////////////////
30 // NativeWidgetViews, public:
31
32 NativeWidgetViews::NativeWidgetViews(internal::NativeWidgetDelegate* delegate)
33 : delegate_(delegate),
34 view_(NULL),
35 ALLOW_THIS_IN_INITIALIZER_LIST(close_widget_factory_(this)) {
36 }
37
38 NativeWidgetViews::~NativeWidgetViews() {
39 }
40
41 View* NativeWidgetViews::GetView() {
42 return view_;
43 }
44
45 ////////////////////////////////////////////////////////////////////////////////
46 // NativeWidgetViews, NativeWidget implementation:
47
48 void NativeWidgetViews::InitNativeWidget(const Widget::InitParams& params) {
49 view_ = new NativeWidgetView;
50
51 // TODO(beng): handle parenting.
52 // TODO(beng): SetInitParams().
53 }
54
55 Widget* NativeWidgetViews::GetWidget() {
56 return delegate_->AsWidget();
57 }
58
59 const Widget* NativeWidgetViews::GetWidget() const {
60 return delegate_->AsWidget();
61 }
62
63 gfx::NativeView NativeWidgetViews::GetNativeView() const {
64 return GetParentNativeWidget()->GetNativeView();
65 }
66
67 gfx::NativeWindow NativeWidgetViews::GetNativeWindow() const {
68 return GetParentNativeWidget()->GetNativeWindow();
69 }
70
71 Window* NativeWidgetViews::GetContainingWindow() {
72 return view_->GetWindow();
73 }
74
75 const Window* NativeWidgetViews::GetContainingWindow() const {
76 return view_->GetWindow();
77 }
78
79 void NativeWidgetViews::ViewRemoved(View* view) {
80 return GetParentNativeWidget()->ViewRemoved(view);
81 }
82
83 void NativeWidgetViews::SetNativeWindowProperty(const char* name, void* value) {
84 NOTIMPLEMENTED();
85 }
86
87 void* NativeWidgetViews::GetNativeWindowProperty(const char* name) {
88 NOTIMPLEMENTED();
89 return NULL;
90 }
91
92 TooltipManager* NativeWidgetViews::GetTooltipManager() const {
93 return GetParentNativeWidget()->GetTooltipManager();
94 }
95
96 bool NativeWidgetViews::IsScreenReaderActive() const {
97 return GetParentNativeWidget()->IsScreenReaderActive();
98 }
99
100 void NativeWidgetViews::SendNativeAccessibilityEvent(
101 View* view,
102 ui::AccessibilityTypes::Event event_type) {
103 return GetParentNativeWidget()->SendNativeAccessibilityEvent(view,
104 event_type);
105 }
106
107 void NativeWidgetViews::SetMouseCapture() {
108 GetParentNativeWidget()->SetMouseCapture();
109 }
110
111 void NativeWidgetViews::ReleaseMouseCapture() {
112 GetParentNativeWidget()->ReleaseMouseCapture();
113 }
114
115 bool NativeWidgetViews::HasMouseCapture() const {
116 return GetParentNativeWidget()->HasMouseCapture();
117 }
118
119 bool NativeWidgetViews::IsMouseButtonDown() const {
120 return GetParentNativeWidget()->IsMouseButtonDown();
121 }
122
123 InputMethod* NativeWidgetViews::GetInputMethodNative() {
124 return GetParentNativeWidget()->GetInputMethodNative();
125 }
126
127 void NativeWidgetViews::ReplaceInputMethod(InputMethod* input_method) {
128 GetParentNativeWidget()->ReplaceInputMethod(input_method);
129 }
130
131 gfx::AcceleratedWidget NativeWidgetViews::GetAcceleratedWidget() {
132 // TODO(sky):
133 return gfx::kNullAcceleratedWidget;
134 }
135
136 gfx::Rect NativeWidgetViews::GetWindowScreenBounds() const {
137 gfx::Point origin = view_->bounds().origin();
138 View::ConvertPointToScreen(view_->parent(), &origin);
139 return gfx::Rect(origin.x(), origin.y(), view_->width(), view_->height());
140 }
141
142 gfx::Rect NativeWidgetViews::GetClientAreaScreenBounds() const {
143 return GetWindowScreenBounds();
144 }
145
146 void NativeWidgetViews::SetBounds(const gfx::Rect& bounds) {
147 // |bounds| are supplied in the coordinates of the parent.
148 view_->SetBoundsRect(bounds);
149 }
150
151 void NativeWidgetViews::SetSize(const gfx::Size& size) {
152 view_->SetSize(size);
153 }
154
155 void NativeWidgetViews::MoveAbove(gfx::NativeView native_view) {
156 NOTIMPLEMENTED();
157 }
158
159 void NativeWidgetViews::SetShape(gfx::NativeRegion region) {
160 NOTIMPLEMENTED();
161 }
162
163 void NativeWidgetViews::Close() {
164 Hide();
165 if (close_widget_factory_.empty()) {
166 MessageLoop::current()->PostTask(FROM_HERE,
167 close_widget_factory_.NewRunnableMethod(&NativeWidgetViews::CloseNow));
168 }
169 }
170
171 void NativeWidgetViews::CloseNow() {
172 view_->parent()->RemoveChildView(view_);
173 delete view_;
174 }
175
176 void NativeWidgetViews::Show() {
177 view_->SetVisible(true);
178 }
179
180 void NativeWidgetViews::Hide() {
181 view_->SetVisible(false);
182 }
183
184 void NativeWidgetViews::SetOpacity(unsigned char opacity) {
185 NOTIMPLEMENTED();
186 }
187
188 void NativeWidgetViews::SetAlwaysOnTop(bool on_top) {
189 NOTIMPLEMENTED();
190 }
191
192 bool NativeWidgetViews::IsVisible() const {
193 return view_->IsVisible();
194 }
195
196 bool NativeWidgetViews::IsActive() const {
197 return view_->HasFocus();
198 }
199
200 bool NativeWidgetViews::IsAccessibleWidget() const {
201 NOTIMPLEMENTED();
202 return false;
203 }
204
205 bool NativeWidgetViews::ContainsNativeView(gfx::NativeView native_view) const {
206 NOTIMPLEMENTED();
207 return GetParentNativeWidget()->ContainsNativeView(native_view);
208 }
209
210 void NativeWidgetViews::RunShellDrag(View* view,
211 const ui::OSExchangeData& data,
212 int operation) {
213 GetParentNativeWidget()->RunShellDrag(view, data, operation);
214 }
215
216 void NativeWidgetViews::SchedulePaintInRect(const gfx::Rect& rect) {
217 view_->SchedulePaintInRect(rect);
218 }
219
220 void NativeWidgetViews::SetCursor(gfx::NativeCursor cursor) {
221 GetParentNativeWidget()->SetCursor(cursor);
222 }
223
224 ////////////////////////////////////////////////////////////////////////////////
225 // NativeWidgetViews, private:
226
227 NativeWidget* NativeWidgetViews::GetParentNativeWidget() {
228 return view_->GetWidget()->native_widget();
229 }
230
231 const NativeWidget* NativeWidgetViews::GetParentNativeWidget() const {
232 return view_->GetWidget()->native_widget();
233 }
234
235 } // namespace views
236
OLDNEW
« no previous file with comments | « views/widget/native_widget_views.h ('k') | no next file » | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698