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

Side by Side Diff: views/controls/native/native_view_host.h

Issue 5785001: A NativeViewHostViews class for embedding views inside NativeHostView instances. (Closed) Base URL: svn://svn.chromium.org/chrome/trunk/src
Patch Set: Fixed up the patchset to not include files that I pulled in by accident in #3 Created 10 years 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
OLDNEW
1 // Copyright (c) 2009 The Chromium Authors. All rights reserved. 1 // Copyright (c) 2009 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
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
41 // Detach the attached window handle. Its bounds and visibility will no longer 44 // Detach the attached window handle. Its bounds and visibility will no longer
42 // be manipulated by this View. 45 // be manipulated by this View.
43 void Detach(); 46 void Detach();
44 47
45 // Sets a preferred size for the native view attached to this View. 48 // Sets a preferred size for the native view attached to this View.
46 void SetPreferredSize(const gfx::Size& size); 49 void SetPreferredSize(const gfx::Size& size);
47 50
48 // A NativeViewHost has an associated focus View so that the focus of the 51 // A NativeViewHost has an associated focus View so that the focus of the
49 // native control and of the View are kept in sync. In simple cases where the 52 // native control and of the View are kept in sync. In simple cases where the
50 // NativeViewHost directly wraps a native window as is, the associated view 53 // NativeViewHost directly wraps a native window as is, the associated view
51 // is this View. In other cases where the NativeViewHost is part of another 54 // is this View. In other cases where the NativeViewHost is part of another
52 // view (such as TextField), the actual View is not the NativeViewHost and 55 // view (such as TextField), the actual View is not the NativeViewHost and
53 // this method must be called to set that. 56 // this method must be called to set that.
54 // This method must be called before Attach(). 57 // This method must be called before Attach().
55 void set_focus_view(View* view) { focus_view_ = view; } 58 void set_focus_view(View* view) { focus_view_ = view; }
56 View* focus_view() { return focus_view_; } 59 View* focus_view() { return focus_view_; }
57 60
58 // Fast resizing will move the native view and clip its visible region, this 61 // Fast resizing will move the native view and clip its visible region, this
59 // will result in white areas and will not resize the content (so scrollbars 62 // will result in white areas and will not resize the content (so scrollbars
60 // will be all wrong and content will flow offscreen). Only use this 63 // will be all wrong and content will flow offscreen). Only use this
61 // when you're doing extremely quick, high-framerate vertical resizes 64 // when you're doing extremely quick, high-framerate vertical resizes
62 // and don't care about accuracy. Make sure you do a real resize at the 65 // and don't care about accuracy. Make sure you do a real resize at the
63 // end. USE WITH CAUTION. 66 // end. USE WITH CAUTION.
64 void set_fast_resize(bool fast_resize) { fast_resize_ = fast_resize; } 67 void set_fast_resize(bool fast_resize) { fast_resize_ = fast_resize; }
65 bool fast_resize() const { return fast_resize_; } 68 bool fast_resize() const { return fast_resize_; }
66 69
67 // Accessor for |native_view_|. 70 // Accessor for |native_view_|.
68 gfx::NativeView native_view() const { return native_view_; } 71 gfx::NativeView native_view() const { return native_view_; }
69 72
73 // Accessor for |views_view_|.
74 View* views_view() const { return views_view_; }
75
70 void NativeViewDestroyed(); 76 void NativeViewDestroyed();
71 77
72 // Overridden from View: 78 // Overridden from View:
73 virtual gfx::Size GetPreferredSize(); 79 virtual gfx::Size GetPreferredSize();
74 virtual void Layout(); 80 virtual void Layout();
75 virtual void Paint(gfx::Canvas* canvas); 81 virtual void Paint(gfx::Canvas* canvas);
76 virtual void VisibilityChanged(View* starting_from, bool is_visible); 82 virtual void VisibilityChanged(View* starting_from, bool is_visible);
77 virtual void Focus(); 83 virtual void Focus();
78 virtual bool ContainsNativeView(gfx::NativeView native_view) const; 84 virtual bool ContainsNativeView(gfx::NativeView native_view) const;
79 85
80 protected: 86 protected:
81 virtual void VisibleBoundsInRootChanged(); 87 virtual void VisibleBoundsInRootChanged();
82 virtual void ViewHierarchyChanged(bool is_add, View* parent, View* child); 88 virtual void ViewHierarchyChanged(bool is_add, View* parent, View* child);
83 virtual std::string GetClassName() const; 89 virtual std::string GetClassName() const;
84 90
85 private: 91 private:
86 // Detach the native view. |destroyed| is true if the native view is 92 // Detach the native view. |destroyed| is true if the native view is
87 // detached because it's being destroyed, or false otherwise. 93 // detached because it's being destroyed, or false otherwise.
88 void Detach(bool destroyed); 94 void Detach(bool destroyed);
89 95
90 // The attached native view. 96 // The attached native view. There is exactly one native_view_ or views_view_
97 // attached.
91 gfx::NativeView native_view_; 98 gfx::NativeView native_view_;
92 99
100 // The attached view. There is exactly one native_view_ or views_view_
101 // attached.
102 View* views_view_;
103
93 // A platform-specific wrapper that does the OS-level manipulation of the 104 // A platform-specific wrapper that does the OS-level manipulation of the
94 // attached gfx::NativeView. 105 // attached gfx::NativeView.
95 scoped_ptr<NativeViewHostWrapper> native_wrapper_; 106 scoped_ptr<NativeViewHostWrapper> native_wrapper_;
96 107
97 // The preferred size of this View 108 // The preferred size of this View
98 gfx::Size preferred_size_; 109 gfx::Size preferred_size_;
99 110
100 // True if the native view is being resized using the fast method described 111 // True if the native view is being resized using the fast method described
101 // in the setter/accessor above. 112 // in the setter/accessor above.
102 bool fast_resize_; 113 bool fast_resize_;
103 114
104 // 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.
105 View* focus_view_; 116 View* focus_view_;
106 117
107 DISALLOW_COPY_AND_ASSIGN(NativeViewHost); 118 DISALLOW_COPY_AND_ASSIGN(NativeViewHost);
108 }; 119 };
109 120
110 } // namespace views 121 } // namespace views
111 122
112 #endif // VIEWS_CONTROLS_NATIVE_NATIVE_VIEW_HOST_H_ 123 #endif // VIEWS_CONTROLS_NATIVE_NATIVE_VIEW_HOST_H_
OLDNEW
« no previous file with comments | « chrome/browser/ui/views/tab_contents/tab_contents_view_views.cc ('k') | views/controls/native/native_view_host.cc » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698