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

Unified Diff: views/controls/native/native_view_host.h

Issue 114059: Refactors HWNDView, NativeViewHostGtk and NativeViewHost so that they match t... (Closed) Base URL: svn://chrome-svn/chrome/trunk/src/
Patch Set: '' Created 11 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 side-by-side diff with in-line comments
Download patch
« no previous file with comments | « views/controls/hwnd_view.cc ('k') | views/controls/native/native_view_host.cc » ('j') | no next file with comments »
Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
Index: views/controls/native/native_view_host.h
===================================================================
--- views/controls/native/native_view_host.h (revision 0)
+++ views/controls/native/native_view_host.h (working copy)
@@ -13,21 +13,34 @@
namespace views {
-// Base class for embedding native widgets in a view.
+class NativeViewHostWrapper;
+
+// A View type that hosts a gfx::NativeView. The bounds of the native view are
+// kept in sync with the bounds of this view as it is moved and sized.
+// Under the hood, a platform-specific NativeViewHostWrapper implementation does
+// the platform-specific work of manipulating the underlying OS widget type.
class NativeViewHost : public View {
public:
+ // The NativeViewHost's class name.
+ static const char kViewClassName[];
+
NativeViewHost();
virtual ~NativeViewHost();
- void SetPreferredSize(const gfx::Size& size);
- virtual gfx::Size GetPreferredSize();
+ // Attach a gfx::NativeView to this View. Its bounds will be kept in sync
+ // with the bounds of this View until Detach is called.
+ //
+ // Because native views are positioned in the coordinates of their parent
+ // native view, this function should only be called after this View has been
+ // added to a View hierarchy hosted within a valid Widget.
+ void Attach(gfx::NativeView native_view);
- // Overriden to invoke Layout.
- virtual void VisibilityChanged(View* starting_from, bool is_visible);
+ // Detach the attached window handle. Its bounds and visibility will no longer
+ // be manipulated by this View.
+ void Detach();
- // Invokes any of InstallClip, UninstallClip, ShowWidget or HideWidget
- // depending upon what portion of the widget is view in the parent.
- virtual void Layout();
+ // Sets a preferred size for the native view attached to this View.
+ void SetPreferredSize(const gfx::Size& size);
// A NativeViewHost has an associated focus View so that the focus of the
// native control and of the View are kept in sync. In simple cases where the
@@ -36,58 +49,48 @@
// view (such as TextField), the actual View is not the NativeViewHost and
// this method must be called to set that.
// This method must be called before Attach().
- void SetAssociatedFocusView(View* view) { focus_view_ = view; }
- View* associated_focus_view() { return focus_view_; }
+ void set_focus_view(View* view) { focus_view_ = view; }
+ View* focus_view() { return focus_view_; }
+ // Fast resizing will move the native view and clip its visible region, this
+ // will result in white areas and will not resize the content (so scrollbars
+ // will be all wrong and content will flow offscreen). Only use this
+ // when you're doing extremely quick, high-framerate vertical resizes
+ // and don't care about accuracy. Make sure you do a real resize at the
+ // end. USE WITH CAUTION.
void set_fast_resize(bool fast_resize) { fast_resize_ = fast_resize; }
bool fast_resize() const { return fast_resize_; }
- // The embedded native view.
+ // Accessor for |native_view_|.
gfx::NativeView native_view() const { return native_view_; }
+ void NativeViewDestroyed();
+
+ // Overridden from View:
+ virtual gfx::Size GetPreferredSize();
+ virtual void Layout();
+ virtual void Paint(gfx::Canvas* canvas);
+ virtual void VisibilityChanged(View* starting_from, bool is_visible);
+
protected:
- // Notification that our visible bounds relative to the root has changed.
- // Invokes Layout to make sure the widget is positioned correctly.
virtual void VisibleBoundsInRootChanged();
+ virtual void ViewHierarchyChanged(bool is_add, View* parent, View* child);
+ virtual std::string GetClassName() const;
+ virtual void Focus();
- // Sets the native view. Subclasses will typically invoke Layout after setting
- // the widget.
- void set_native_view(gfx::NativeView widget) { native_view_ = widget; }
-
- // Installs a clip on the native widget.
- virtual void InstallClip(int x, int y, int w, int h) = 0;
-
- // Removes the clip installed on the native widget by way of InstallClip.
- virtual void UninstallClip() = 0;
-
- // Shows the widget at the specified position (relative to the parent widget).
- virtual void ShowWidget(int x, int y, int w, int h) = 0;
-
- // Hides the widget. NOTE: this may be invoked when the widget is already
- // hidden.
- virtual void HideWidget() = 0;
-
- void set_installed_clip(bool installed_clip) {
- installed_clip_ = installed_clip;
- }
- bool installed_clip() const { return installed_clip_; }
-
private:
+ // The attached native view.
gfx::NativeView native_view_;
+ // A platform-specific wrapper that does the OS-level manipulation of the
+ // attached gfx::NativeView.
+ NativeViewHostWrapper* native_wrapper_;
+
// The preferred size of this View
gfx::Size preferred_size_;
- // Have we installed a region on the HWND used to clip to only the visible
- // portion of the HWND?
- bool installed_clip_;
-
- // Fast resizing will move the hwnd and clip its window region, this will
- // result in white areas and will not resize the content (so scrollbars
- // will be all wrong and content will flow offscreen). Only use this
- // when you're doing extremely quick, high-framerate vertical resizes
- // and don't care about accuracy. Make sure you do a real resize at the
- // end. USE WITH CAUTION.
+ // True if the native view is being resized using the fast method described
+ // in the setter/accessor above.
bool fast_resize_;
// The view that should be given focus when this NativeViewHost is focused.
« no previous file with comments | « views/controls/hwnd_view.cc ('k') | views/controls/native/native_view_host.cc » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698