OLD | NEW |
(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_view.h" |
| 6 |
| 7 #include "ui/gfx/canvas.h" |
| 8 |
| 9 namespace views { |
| 10 namespace internal { |
| 11 |
| 12 //////////////////////////////////////////////////////////////////////////////// |
| 13 // NativeWidgetView, public: |
| 14 |
| 15 NativeWidgetView::NativeWidgetView(NativeWidgetViews* native_widget) |
| 16 : native_widget_(native_widget) { |
| 17 } |
| 18 |
| 19 NativeWidgetView::~NativeWidgetView() { |
| 20 } |
| 21 |
| 22 //////////////////////////////////////////////////////////////////////////////// |
| 23 // NativeWidgetView, View overrides: |
| 24 |
| 25 void NativeWidgetView::ViewHierarchyChanged(bool is_add, View* parent, |
| 26 View* child) { |
| 27 if (is_add && child == this) |
| 28 delegate()->OnNativeWidgetCreated(); |
| 29 } |
| 30 |
| 31 void NativeWidgetView::OnBoundsChanged(const gfx::Rect& previous_bounds) { |
| 32 delegate()->OnSizeChanged(size()); |
| 33 } |
| 34 |
| 35 void NativeWidgetView::OnPaint(gfx::Canvas* canvas) { |
| 36 canvas->FillRectInt(SK_ColorRED, 0, 0, width(), height()); |
| 37 delegate()->OnNativeWidgetPaint(canvas); |
| 38 } |
| 39 |
| 40 bool NativeWidgetView::OnMousePressed(const MouseEvent& event) { |
| 41 MouseEvent e(event, this); |
| 42 return delegate()->OnMouseEvent(event); |
| 43 } |
| 44 |
| 45 bool NativeWidgetView::OnMouseDragged(const MouseEvent& event) { |
| 46 MouseEvent e(event, this); |
| 47 return delegate()->OnMouseEvent(event); |
| 48 } |
| 49 |
| 50 void NativeWidgetView::OnMouseReleased(const MouseEvent& event) { |
| 51 MouseEvent e(event, this); |
| 52 delegate()->OnMouseEvent(event); |
| 53 } |
| 54 |
| 55 void NativeWidgetView::OnMouseCaptureLost() { |
| 56 delegate()->OnMouseCaptureLost(); |
| 57 } |
| 58 |
| 59 void NativeWidgetView::OnMouseMoved(const MouseEvent& event) { |
| 60 MouseEvent e(event, this); |
| 61 delegate()->OnMouseEvent(event); |
| 62 } |
| 63 |
| 64 void NativeWidgetView::OnMouseEntered(const MouseEvent& event) { |
| 65 MouseEvent e(event, this); |
| 66 delegate()->OnMouseEvent(event); |
| 67 } |
| 68 |
| 69 void NativeWidgetView::OnMouseExited(const MouseEvent& event) { |
| 70 MouseEvent e(event, this); |
| 71 delegate()->OnMouseEvent(event); |
| 72 } |
| 73 |
| 74 #if defined(TOUCH_UI) |
| 75 View::TouchStatus NativeWidgetView::OnTouchEvent(const TouchEvent& event) { |
| 76 NOTIMPLEMENTED(); |
| 77 // TODO(beng): TouchEvents don't go through the Widget right now... so we |
| 78 // can't just pass them to the delegate... |
| 79 return TOUCH_STATUS_UNKNOWN; |
| 80 } |
| 81 #endif |
| 82 |
| 83 bool NativeWidgetView::OnKeyPressed(const KeyEvent& event) { |
| 84 return delegate()->OnKeyEvent(event); |
| 85 } |
| 86 |
| 87 bool NativeWidgetView::OnKeyReleased(const KeyEvent& event) { |
| 88 return delegate()->OnKeyEvent(event); |
| 89 } |
| 90 |
| 91 bool NativeWidgetView::OnMouseWheel(const MouseWheelEvent& event) { |
| 92 MouseWheelEvent e(event, this); |
| 93 return delegate()->OnMouseEvent(event); |
| 94 } |
| 95 |
| 96 void NativeWidgetView::OnFocus() { |
| 97 // TODO(beng): check if we have to do this. |
| 98 //delegate()->OnNativeFocus(NULL); |
| 99 } |
| 100 |
| 101 void NativeWidgetView::OnBlur() { |
| 102 // TODO(beng): check if we have to do this. |
| 103 //delegate()->OnNativeBlur(NULL); |
| 104 } |
| 105 |
| 106 } // namespace internal |
| 107 } // namespace views |
| 108 |
OLD | NEW |