| 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 VIEWS_CONTROLS_NATIVE_NATIVE_VIEW_HOST_H_ | 5 #ifndef VIEWS_CONTROLS_NATIVE_NATIVE_VIEW_HOST_H_ |
| 6 #define VIEWS_CONTROLS_NATIVE_NATIVE_VIEW_HOST_H_ | 6 #define VIEWS_CONTROLS_NATIVE_NATIVE_VIEW_HOST_H_ |
| 7 #pragma once | 7 #pragma once |
| 8 | 8 |
| 9 #include <string> | 9 #include <string> |
| 10 | 10 |
| (...skipping 20 matching lines...) Expand all Loading... |
| 31 virtual ~NativeViewHost(); | 31 virtual ~NativeViewHost(); |
| 32 | 32 |
| 33 // Attach a gfx::NativeView to this View. Its bounds will be kept in sync | 33 // Attach a gfx::NativeView to this View. Its bounds will be kept in sync |
| 34 // with the bounds of this View until Detach is called. | 34 // with the bounds of this View until Detach is called. |
| 35 // | 35 // |
| 36 // Because native views are positioned in the coordinates of their parent | 36 // Because native views are positioned in the coordinates of their parent |
| 37 // native view, this function should only be called after this View has been | 37 // native view, this function should only be called after this View has been |
| 38 // added to a View hierarchy hosted within a valid Widget. | 38 // added to a View hierarchy hosted within a valid Widget. |
| 39 void Attach(gfx::NativeView native_view); | 39 void Attach(gfx::NativeView native_view); |
| 40 | 40 |
| 41 // Attach a views::View instead of a native view to this host. | |
| 42 void AttachToView(View* view); | |
| 43 | |
| 44 // Detach the attached native view. Its bounds and visibility will no | 41 // Detach the attached native view. Its bounds and visibility will no |
| 45 // longer be manipulated by this View. The native view may be destroyed and | 42 // longer be manipulated by this View. The native view may be destroyed and |
| 46 // detached before calling this function, and this has no effect in that case. | 43 // detached before calling this function, and this has no effect in that case. |
| 47 void Detach(); | 44 void Detach(); |
| 48 | 45 |
| 49 // Sets a preferred size for the native view attached to this View. | 46 // Sets a preferred size for the native view attached to this View. |
| 50 void SetPreferredSize(const gfx::Size& size); | 47 void SetPreferredSize(const gfx::Size& size); |
| 51 | 48 |
| 52 // A NativeViewHost has an associated focus View so that the focus of the | 49 // A NativeViewHost has an associated focus View so that the focus of the |
| 53 // native control and of the View are kept in sync. In simple cases where the | 50 // native control and of the View are kept in sync. In simple cases where the |
| (...skipping 15 matching lines...) Expand all Loading... |
| 69 bool fast_resize() const { return fast_resize_; } | 66 bool fast_resize() const { return fast_resize_; } |
| 70 | 67 |
| 71 // Value of fast_resize() the last time Layout() was invoked. | 68 // Value of fast_resize() the last time Layout() was invoked. |
| 72 bool fast_resize_at_last_layout() const { | 69 bool fast_resize_at_last_layout() const { |
| 73 return fast_resize_at_last_layout_; | 70 return fast_resize_at_last_layout_; |
| 74 } | 71 } |
| 75 | 72 |
| 76 // Accessor for |native_view_|. | 73 // Accessor for |native_view_|. |
| 77 gfx::NativeView native_view() const { return native_view_; } | 74 gfx::NativeView native_view() const { return native_view_; } |
| 78 | 75 |
| 79 // Accessor for |views_view_|. | |
| 80 View* views_view() const { return views_view_; } | |
| 81 | |
| 82 void NativeViewDestroyed(); | 76 void NativeViewDestroyed(); |
| 83 | 77 |
| 84 // Overridden from View: | 78 // Overridden from View: |
| 85 virtual gfx::Size GetPreferredSize(); | 79 virtual gfx::Size GetPreferredSize(); |
| 86 virtual void Layout(); | 80 virtual void Layout(); |
| 87 virtual void OnPaint(gfx::Canvas* canvas); | 81 virtual void OnPaint(gfx::Canvas* canvas); |
| 88 virtual void VisibilityChanged(View* starting_from, bool is_visible); | 82 virtual void VisibilityChanged(View* starting_from, bool is_visible); |
| 89 virtual void OnFocus(); | 83 virtual void OnFocus(); |
| 90 virtual gfx::NativeViewAccessible GetNativeViewAccessible(); | 84 virtual gfx::NativeViewAccessible GetNativeViewAccessible(); |
| 91 | 85 |
| 92 protected: | 86 protected: |
| 93 virtual bool NeedsNotificationWhenVisibleBoundsChange() const; | 87 virtual bool NeedsNotificationWhenVisibleBoundsChange() const; |
| 94 virtual void OnVisibleBoundsChanged(); | 88 virtual void OnVisibleBoundsChanged(); |
| 95 virtual void ViewHierarchyChanged(bool is_add, View* parent, View* child); | 89 virtual void ViewHierarchyChanged(bool is_add, View* parent, View* child); |
| 96 virtual std::string GetClassName() const; | 90 virtual std::string GetClassName() const; |
| 97 | 91 |
| 98 private: | 92 private: |
| 99 // Detach the native view. |destroyed| is true if the native view is | 93 // Detach the native view. |destroyed| is true if the native view is |
| 100 // detached because it's being destroyed, or false otherwise. | 94 // detached because it's being destroyed, or false otherwise. |
| 101 void Detach(bool destroyed); | 95 void Detach(bool destroyed); |
| 102 | 96 |
| 103 // The attached native view. There is exactly one native_view_ or views_view_ | 97 // The attached native view. There is exactly one native_view_ or views_view_ |
| 104 // attached. | 98 // attached. |
| 105 gfx::NativeView native_view_; | 99 gfx::NativeView native_view_; |
| 106 | 100 |
| 107 // The attached view. There is exactly one native_view_ or views_view_ | |
| 108 // attached. | |
| 109 // TODO(oshima): Delete views_view_ once TOUCH_UI migrates to aura. | |
| 110 View* views_view_; | |
| 111 | |
| 112 // A platform-specific wrapper that does the OS-level manipulation of the | 101 // A platform-specific wrapper that does the OS-level manipulation of the |
| 113 // attached gfx::NativeView. | 102 // attached gfx::NativeView. |
| 114 scoped_ptr<NativeViewHostWrapper> native_wrapper_; | 103 scoped_ptr<NativeViewHostWrapper> native_wrapper_; |
| 115 | 104 |
| 116 // The preferred size of this View | 105 // The preferred size of this View |
| 117 gfx::Size preferred_size_; | 106 gfx::Size preferred_size_; |
| 118 | 107 |
| 119 // True if the native view is being resized using the fast method described | 108 // True if the native view is being resized using the fast method described |
| 120 // in the setter/accessor above. | 109 // in the setter/accessor above. |
| 121 bool fast_resize_; | 110 bool fast_resize_; |
| 122 | 111 |
| 123 // Value of |fast_resize_| during the last call to Layout. | 112 // Value of |fast_resize_| during the last call to Layout. |
| 124 bool fast_resize_at_last_layout_; | 113 bool fast_resize_at_last_layout_; |
| 125 | 114 |
| 126 // The view that should be given focus when this NativeViewHost is focused. | 115 // The view that should be given focus when this NativeViewHost is focused. |
| 127 View* focus_view_; | 116 View* focus_view_; |
| 128 | 117 |
| 129 DISALLOW_COPY_AND_ASSIGN(NativeViewHost); | 118 DISALLOW_COPY_AND_ASSIGN(NativeViewHost); |
| 130 }; | 119 }; |
| 131 | 120 |
| 132 } // namespace views | 121 } // namespace views |
| 133 | 122 |
| 134 #endif // VIEWS_CONTROLS_NATIVE_NATIVE_VIEW_HOST_H_ | 123 #endif // VIEWS_CONTROLS_NATIVE_NATIVE_VIEW_HOST_H_ |
| OLD | NEW |