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.
5 #ifndef UI_VIEWS_CONTROLS_NATIVE_NATIVE_VIEW_HOST_WRAPPER_H_
6 #define UI_VIEWS_CONTROLS_NATIVE_NATIVE_VIEW_HOST_WRAPPER_H_
8 #include "ui/gfx/native_widget_types.h"
9 #include "ui/views/views_export.h"
15 // An interface that implemented by an object that wraps a gfx::NativeView on
16 // a specific platform, used to perform platform specific operations on that
17 // native view when attached, detached, moved and sized.
18 class VIEWS_EXPORT NativeViewHostWrapper
{
20 virtual ~NativeViewHostWrapper() {}
22 // Called right before a gfx::NativeView is attached to the associated
23 // NativeViewHost, allowing the wrapper to perform platform-specific
25 virtual void NativeViewWillAttach() = 0;
27 // Called before the attached gfx::NativeView is detached from the
28 // NativeViewHost, allowing the wrapper to perform platform-specific
29 // cleanup. |destroyed| is true if the native view is detached
30 // because it's being destroyed, or false otherwise.
31 virtual void NativeViewDetaching(bool destroyed
) = 0;
33 // Called when our associated NativeViewHost is added to a View hierarchy
34 // rooted at a valid Widget.
35 virtual void AddedToWidget() = 0;
37 // Called when our associated NativeViewHost is removed from a View hierarchy
38 // rooted at a valid Widget.
39 virtual void RemovedFromWidget() = 0;
41 // Installs a clip on the gfx::NativeView.
42 virtual void InstallClip(int x
, int y
, int w
, int h
) = 0;
44 // Whether or not a clip has been installed on the wrapped gfx::NativeView.
45 virtual bool HasInstalledClip() = 0;
47 // Removes the clip installed on the gfx::NativeView by way of InstallClip.
48 virtual void UninstallClip() = 0;
50 // Shows the gfx::NativeView at the specified position (relative to the parent
52 virtual void ShowWidget(int x
, int y
, int w
, int h
) = 0;
54 // Hides the gfx::NativeView. NOTE: this may be invoked when the native view
56 virtual void HideWidget() = 0;
58 // Sets focus to the gfx::NativeView.
59 virtual void SetFocus() = 0;
61 // Return the native view accessible corresponding to the wrapped native
63 virtual gfx::NativeViewAccessible
GetNativeViewAccessible() = 0;
65 // Returns the native cursor corresponding to the point (x, y)
66 // in the native view.
67 virtual gfx::NativeCursor
GetCursor(int x
, int y
) = 0;
69 // Creates a platform-specific instance of an object implementing this
71 static NativeViewHostWrapper
* CreateWrapper(NativeViewHost
* host
);
76 #endif // UI_VIEWS_CONTROLS_NATIVE_NATIVE_VIEW_HOST_WRAPPER_H_