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_WRAPPER_H_ | 5 #ifndef UI_VIEWS_CONTROLS_NATIVE_NATIVE_VIEW_HOST_WRAPPER_H_ |
6 #define UI_VIEWS_CONTROLS_NATIVE_NATIVE_VIEW_HOST_WRAPPER_H_ | 6 #define UI_VIEWS_CONTROLS_NATIVE_NATIVE_VIEW_HOST_WRAPPER_H_ |
7 | 7 |
8 #include "ui/gfx/native_widget_types.h" | 8 #include "ui/gfx/native_widget_types.h" |
9 #include "ui/views/views_export.h" | 9 #include "ui/views/views_export.h" |
10 | 10 |
11 namespace views { | 11 namespace views { |
12 | 12 |
13 class NativeViewHost; | 13 class NativeViewHost; |
14 | 14 |
15 // An interface that implemented by an object that wraps a gfx::NativeView on | 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 | 16 // a specific platform, used to perform platform specific operations on that |
17 // native view when attached, detached, moved and sized. | 17 // native view when attached, detached, moved and sized. |
18 class VIEWS_EXPORT NativeViewHostWrapper { | 18 class VIEWS_EXPORT NativeViewHostWrapper { |
19 public: | 19 public: |
20 virtual ~NativeViewHostWrapper() {} | 20 virtual ~NativeViewHostWrapper() {} |
21 | 21 |
22 // Called at the end of NativeViewHost::Attach, allowing the wrapper to | 22 // Called right before a gfx::NativeView is attached to the associated |
23 // perform platform-specific operations that need to occur to complete | 23 // NativeViewHost, allowing the wrapper to perform platform-specific |
24 // attaching the gfx::NativeView. | 24 // initialization. |
25 virtual void AttachNativeView() = 0; | 25 virtual void NativeViewWillAttach() = 0; |
26 | 26 |
27 // Called before the attached gfx::NativeView is detached from the | 27 // Called before the attached gfx::NativeView is detached from the |
28 // NativeViewHost, allowing the wrapper to perform platform-specific | 28 // NativeViewHost, allowing the wrapper to perform platform-specific |
29 // cleanup. |destroyed| is true if the native view is detached | 29 // cleanup. |destroyed| is true if the native view is detached |
30 // because it's being destroyed, or false otherwise. | 30 // because it's being destroyed, or false otherwise. |
31 virtual void NativeViewDetaching(bool destroyed) = 0; | 31 virtual void NativeViewDetaching(bool destroyed) = 0; |
32 | 32 |
33 // Called when our associated NativeViewHost is added to a View hierarchy | 33 // Called when our associated NativeViewHost is added to a View hierarchy |
34 // rooted at a valid Widget. | 34 // rooted at a valid Widget. |
35 virtual void AddedToWidget() = 0; | 35 virtual void AddedToWidget() = 0; |
36 | 36 |
37 // Called when our associated NativeViewHost is removed from a View hierarchy | 37 // Called when our associated NativeViewHost is removed from a View hierarchy |
38 // rooted at a valid Widget. | 38 // rooted at a valid Widget. |
39 virtual void RemovedFromWidget() = 0; | 39 virtual void RemovedFromWidget() = 0; |
40 | 40 |
41 // Installs a clip on the gfx::NativeView. These values are in the coordinate | 41 // Installs a clip on the gfx::NativeView. |
42 // space of the Widget, so if this method is called from ShowWidget | |
43 // then the values need to be translated. | |
44 virtual void InstallClip(int x, int y, int w, int h) = 0; | 42 virtual void InstallClip(int x, int y, int w, int h) = 0; |
45 | 43 |
46 // Whether or not a clip has been installed on the wrapped gfx::NativeView. | 44 // Whether or not a clip has been installed on the wrapped gfx::NativeView. |
47 virtual bool HasInstalledClip() = 0; | 45 virtual bool HasInstalledClip() = 0; |
48 | 46 |
49 // Removes the clip installed on the gfx::NativeView by way of InstallClip. A | 47 // Removes the clip installed on the gfx::NativeView by way of InstallClip. |
50 // following call to ShowWidget should occur after calling this method to | |
51 // position the gfx::NativeView correctly, since the clipping process may have | |
52 // adjusted its position. | |
53 virtual void UninstallClip() = 0; | 48 virtual void UninstallClip() = 0; |
54 | 49 |
55 // Shows the gfx::NativeView at the specified position (relative to the parent | 50 // Shows the gfx::NativeView at the specified position (relative to the parent |
56 // native view). | 51 // native view). |
57 virtual void ShowWidget(int x, int y, int w, int h) = 0; | 52 virtual void ShowWidget(int x, int y, int w, int h) = 0; |
58 | 53 |
59 // Hides the gfx::NativeView. NOTE: this may be invoked when the native view | 54 // Hides the gfx::NativeView. NOTE: this may be invoked when the native view |
60 // is already hidden. | 55 // is already hidden. |
61 virtual void HideWidget() = 0; | 56 virtual void HideWidget() = 0; |
62 | 57 |
63 // Sets focus to the gfx::NativeView. | 58 // Sets focus to the gfx::NativeView. |
64 virtual void SetFocus() = 0; | 59 virtual void SetFocus() = 0; |
65 | 60 |
66 // Return the native view accessible corresponding to the wrapped native | 61 // Return the native view accessible corresponding to the wrapped native |
67 // view. | 62 // view. |
68 virtual gfx::NativeViewAccessible GetNativeViewAccessible() = 0; | 63 virtual gfx::NativeViewAccessible GetNativeViewAccessible() = 0; |
69 | 64 |
70 // Returns the native cursor corresponding to the point (x, y) | 65 // Returns the native cursor corresponding to the point (x, y) |
71 // in the native view. | 66 // in the native view. |
72 virtual gfx::NativeCursor GetCursor(int x, int y) = 0; | 67 virtual gfx::NativeCursor GetCursor(int x, int y) = 0; |
73 | 68 |
74 // Creates a platform-specific instance of an object implementing this | 69 // Creates a platform-specific instance of an object implementing this |
75 // interface. | 70 // interface. |
76 static NativeViewHostWrapper* CreateWrapper(NativeViewHost* host); | 71 static NativeViewHostWrapper* CreateWrapper(NativeViewHost* host); |
77 }; | 72 }; |
78 | 73 |
79 } // namespace views | 74 } // namespace views |
80 | 75 |
81 #endif // UI_VIEWS_CONTROLS_NATIVE_NATIVE_VIEW_HOST_WRAPPER_H_ | 76 #endif // UI_VIEWS_CONTROLS_NATIVE_NATIVE_VIEW_HOST_WRAPPER_H_ |
OLD | NEW |