OLD | NEW |
1 // Copyright (c) 2011 The Chromium Authors. All rights reserved. | 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 | 2 // Use of this source code is governed by a BSD-style license that can be |
3 // found in the LICENSE file. | 3 // found in the LICENSE file. |
4 | 4 |
5 #ifndef UI_VIEWS_CONTROLS_NATIVE_NATIVE_VIEW_HOST_H_ | 5 #ifndef UI_VIEWS_CONTROLS_NATIVE_NATIVE_VIEW_HOST_H_ |
6 #define UI_VIEWS_CONTROLS_NATIVE_NATIVE_VIEW_HOST_H_ | 6 #define UI_VIEWS_CONTROLS_NATIVE_NATIVE_VIEW_HOST_H_ |
7 | 7 |
8 #include <string> | 8 #include <string> |
9 | 9 |
10 #include "ui/gfx/native_widget_types.h" | 10 #include "ui/gfx/native_widget_types.h" |
(...skipping 13 matching lines...) Expand all Loading... |
24 // A View type that hosts a gfx::NativeView. The bounds of the native view are | 24 // A View type that hosts a gfx::NativeView. The bounds of the native view are |
25 // kept in sync with the bounds of this view as it is moved and sized. | 25 // kept in sync with the bounds of this view as it is moved and sized. |
26 // Under the hood, a platform-specific NativeViewHostWrapper implementation does | 26 // Under the hood, a platform-specific NativeViewHostWrapper implementation does |
27 // the platform-specific work of manipulating the underlying OS widget type. | 27 // the platform-specific work of manipulating the underlying OS widget type. |
28 class VIEWS_EXPORT NativeViewHost : public View { | 28 class VIEWS_EXPORT NativeViewHost : public View { |
29 public: | 29 public: |
30 // The NativeViewHost's class name. | 30 // The NativeViewHost's class name. |
31 static const char kViewClassName[]; | 31 static const char kViewClassName[]; |
32 | 32 |
33 NativeViewHost(); | 33 NativeViewHost(); |
34 virtual ~NativeViewHost(); | 34 ~NativeViewHost() override; |
35 | 35 |
36 // Attach a gfx::NativeView to this View. Its bounds will be kept in sync | 36 // Attach a gfx::NativeView to this View. Its bounds will be kept in sync |
37 // with the bounds of this View until Detach is called. | 37 // with the bounds of this View until Detach is called. |
38 // | 38 // |
39 // Because native views are positioned in the coordinates of their parent | 39 // Because native views are positioned in the coordinates of their parent |
40 // native view, this function should only be called after this View has been | 40 // native view, this function should only be called after this View has been |
41 // added to a View hierarchy hosted within a valid Widget. | 41 // added to a View hierarchy hosted within a valid Widget. |
42 void Attach(gfx::NativeView native_view); | 42 void Attach(gfx::NativeView native_view); |
43 | 43 |
44 // Detach the attached native view. Its bounds and visibility will no | 44 // Detach the attached native view. Its bounds and visibility will no |
(...skipping 27 matching lines...) Expand all Loading... |
72 bool fast_resize_at_last_layout() const { | 72 bool fast_resize_at_last_layout() const { |
73 return fast_resize_at_last_layout_; | 73 return fast_resize_at_last_layout_; |
74 } | 74 } |
75 | 75 |
76 // Accessor for |native_view_|. | 76 // Accessor for |native_view_|. |
77 gfx::NativeView native_view() const { return native_view_; } | 77 gfx::NativeView native_view() const { return native_view_; } |
78 | 78 |
79 void NativeViewDestroyed(); | 79 void NativeViewDestroyed(); |
80 | 80 |
81 // Overridden from View: | 81 // Overridden from View: |
82 virtual gfx::Size GetPreferredSize() const override; | 82 gfx::Size GetPreferredSize() const override; |
83 virtual void Layout() override; | 83 void Layout() override; |
84 virtual void OnPaint(gfx::Canvas* canvas) override; | 84 void OnPaint(gfx::Canvas* canvas) override; |
85 virtual void VisibilityChanged(View* starting_from, bool is_visible) override; | 85 void VisibilityChanged(View* starting_from, bool is_visible) override; |
86 virtual void OnFocus() override; | 86 void OnFocus() override; |
87 virtual gfx::NativeViewAccessible GetNativeViewAccessible() override; | 87 gfx::NativeViewAccessible GetNativeViewAccessible() override; |
88 virtual gfx::NativeCursor GetCursor(const ui::MouseEvent& event) override; | 88 gfx::NativeCursor GetCursor(const ui::MouseEvent& event) override; |
89 | 89 |
90 protected: | 90 protected: |
91 virtual bool GetNeedsNotificationWhenVisibleBoundsChange() const override; | 91 bool GetNeedsNotificationWhenVisibleBoundsChange() const override; |
92 virtual void OnVisibleBoundsChanged() override; | 92 void OnVisibleBoundsChanged() override; |
93 virtual void ViewHierarchyChanged( | 93 void ViewHierarchyChanged( |
94 const ViewHierarchyChangedDetails& details) override; | 94 const ViewHierarchyChangedDetails& details) override; |
95 virtual const char* GetClassName() const override; | 95 const char* GetClassName() const override; |
96 | 96 |
97 private: | 97 private: |
98 friend class test::NativeViewHostTestBase; | 98 friend class test::NativeViewHostTestBase; |
99 | 99 |
100 // Detach the native view. |destroyed| is true if the native view is | 100 // Detach the native view. |destroyed| is true if the native view is |
101 // detached because it's being destroyed, or false otherwise. | 101 // detached because it's being destroyed, or false otherwise. |
102 void Detach(bool destroyed); | 102 void Detach(bool destroyed); |
103 | 103 |
104 // Invokes ViewRemoved() on the FocusManager for all the child Widgets of our | 104 // Invokes ViewRemoved() on the FocusManager for all the child Widgets of our |
105 // NativeView. This is used when detaching to ensure the FocusManager doesn't | 105 // NativeView. This is used when detaching to ensure the FocusManager doesn't |
(...skipping 19 matching lines...) Expand all Loading... |
125 | 125 |
126 // The view that should be given focus when this NativeViewHost is focused. | 126 // The view that should be given focus when this NativeViewHost is focused. |
127 View* focus_view_; | 127 View* focus_view_; |
128 | 128 |
129 DISALLOW_COPY_AND_ASSIGN(NativeViewHost); | 129 DISALLOW_COPY_AND_ASSIGN(NativeViewHost); |
130 }; | 130 }; |
131 | 131 |
132 } // namespace views | 132 } // namespace views |
133 | 133 |
134 #endif // UI_VIEWS_CONTROLS_NATIVE_NATIVE_VIEW_HOST_H_ | 134 #endif // UI_VIEWS_CONTROLS_NATIVE_NATIVE_VIEW_HOST_H_ |
OLD | NEW |