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_WIDGET_NATIVE_WIDGET_H_ | 5 #ifndef VIEWS_WIDGET_NATIVE_WIDGET_H_ |
6 #define VIEWS_WIDGET_NATIVE_WIDGET_H_ | 6 #define VIEWS_WIDGET_NATIVE_WIDGET_H_ |
7 #pragma once | 7 #pragma once |
8 | 8 |
9 #include <set> | 9 #include <set> |
10 | 10 |
(...skipping 18 matching lines...) Expand all Loading... |
29 // | 29 // |
30 // An interface implemented by an object that encapsulates rendering, event | 30 // An interface implemented by an object that encapsulates rendering, event |
31 // handling and widget management provided by an underlying native toolkit. | 31 // handling and widget management provided by an underlying native toolkit. |
32 // | 32 // |
33 class NativeWidget { | 33 class NativeWidget { |
34 public: | 34 public: |
35 typedef std::set<NativeWidget*> NativeWidgets; | 35 typedef std::set<NativeWidget*> NativeWidgets; |
36 | 36 |
37 virtual ~NativeWidget() {} | 37 virtual ~NativeWidget() {} |
38 | 38 |
| 39 // Creates an appropriate default NativeWidget implementation for the current |
| 40 // OS/circumstance. |
| 41 static NativeWidget* CreateNativeWidget( |
| 42 internal::NativeWidgetDelegate* delegate); |
| 43 |
39 // Retrieves the NativeWidget implementation associated with the given | 44 // Retrieves the NativeWidget implementation associated with the given |
40 // NativeView or Window, or NULL if the supplied handle has no associated | 45 // NativeView or Window, or NULL if the supplied handle has no associated |
41 // NativeView. | 46 // NativeView. |
42 static NativeWidget* GetNativeWidgetForNativeView( | 47 static NativeWidget* GetNativeWidgetForNativeView( |
43 gfx::NativeView native_view); | 48 gfx::NativeView native_view); |
44 static NativeWidget* GetNativeWidgetForNativeWindow( | 49 static NativeWidget* GetNativeWidgetForNativeWindow( |
45 gfx::NativeWindow native_window); | 50 gfx::NativeWindow native_window); |
46 | 51 |
47 // Retrieves the top NativeWidget in the hierarchy containing the given | 52 // Retrieves the top NativeWidget in the hierarchy containing the given |
48 // NativeView, or NULL if there is no NativeWidget that contains it. | 53 // NativeView, or NULL if there is no NativeWidget that contains it. |
49 static NativeWidget* GetTopLevelNativeWidget(gfx::NativeView native_view); | 54 static NativeWidget* GetTopLevelNativeWidget(gfx::NativeView native_view); |
50 | 55 |
51 // Returns all NativeWidgets in |native_view|'s hierarchy, including itself if | 56 // Returns all NativeWidgets in |native_view|'s hierarchy, including itself if |
52 // it is one. | 57 // it is one. |
53 static void GetAllNativeWidgets(gfx::NativeView native_view, | 58 static void GetAllNativeWidgets(gfx::NativeView native_view, |
54 NativeWidgets* children); | 59 NativeWidgets* children); |
55 | 60 |
56 // Reparent a NativeView and notify all NativeWidgets in | 61 // Reparent a NativeView and notify all NativeWidgets in |
57 // |native_view|'s hierarchy of the change. | 62 // |native_view|'s hierarchy of the change. |
58 static void ReparentNativeView(gfx::NativeView native_view, | 63 static void ReparentNativeView(gfx::NativeView native_view, |
59 gfx::NativeView new_parent); | 64 gfx::NativeView new_parent); |
60 | 65 |
61 // Initializes the NativeWidget. | 66 // Initializes the NativeWidget. |
62 virtual void InitNativeWidget(const Widget::InitParams& params) = 0; | 67 virtual void InitNativeWidget(const Widget::InitParams& params) = 0; |
63 | 68 |
64 // Returns the Widget associated with this NativeWidget. This function is | 69 // Returns the Widget associated with this NativeWidget. This function is |
65 // guaranteed to return non-NULL for the lifetime of the NativeWidget. | 70 // guaranteed to return non-NULL for the lifetime of the NativeWidget. |
66 virtual Widget* GetWidget() = 0; | 71 virtual Widget* GetWidget() = 0; |
| 72 virtual const Widget* GetWidget() const = 0; |
| 73 |
| 74 // Returns the NativeView/Window associated with this NativeWidget. |
| 75 virtual gfx::NativeView GetNativeView() const = 0; |
| 76 virtual gfx::NativeWindow GetNativeWindow() const = 0; |
| 77 |
| 78 // Returns the enclosing Window, or NULL if there is no enclosing Window. |
| 79 virtual Window* GetContainingWindow() = 0; |
| 80 virtual const Window* GetContainingWindow() const = 0; |
| 81 |
| 82 // Notifies the NativeWidget that a view was removed from the Widget's view |
| 83 // hierarchy. |
| 84 virtual void ViewRemoved(View* view) = 0; |
67 | 85 |
68 // Sets/Gets a native window property on the underlying native window object. | 86 // Sets/Gets a native window property on the underlying native window object. |
69 // Returns NULL if the property does not exist. Setting the property value to | 87 // Returns NULL if the property does not exist. Setting the property value to |
70 // NULL removes the property. | 88 // NULL removes the property. |
71 virtual void SetNativeWindowProperty(const char* name, void* value) = 0; | 89 virtual void SetNativeWindowProperty(const char* name, void* value) = 0; |
72 virtual void* GetNativeWindowProperty(const char* name) = 0; | 90 virtual void* GetNativeWindowProperty(const char* name) = 0; |
73 | 91 |
74 // Returns the native widget's tooltip manager. Called from the View hierarchy | 92 // Returns the native widget's tooltip manager. Called from the View hierarchy |
75 // to update tooltips. | 93 // to update tooltips. |
76 virtual TooltipManager* GetTooltipManager() const = 0; | 94 virtual TooltipManager* GetTooltipManager() const = 0; |
77 | 95 |
78 // Returns true if a system screen reader is active for the NativeWidget. | 96 // Returns true if a system screen reader is active for the NativeWidget. |
79 virtual bool IsScreenReaderActive() const = 0; | 97 virtual bool IsScreenReaderActive() const = 0; |
80 | 98 |
| 99 // Notify native Accessibility clients of an event. |
| 100 virtual void SendNativeAccessibilityEvent( |
| 101 View* view, |
| 102 ui::AccessibilityTypes::Event event_type) = 0; |
| 103 |
81 // Sets or releases event capturing for this native widget. | 104 // Sets or releases event capturing for this native widget. |
82 virtual void SetMouseCapture() = 0; | 105 virtual void SetMouseCapture() = 0; |
83 virtual void ReleaseMouseCapture() = 0; | 106 virtual void ReleaseMouseCapture() = 0; |
84 | 107 |
85 // Returns true if this native widget is capturing all events. | 108 // Returns true if this native widget is capturing all events. |
86 virtual bool HasMouseCapture() const = 0; | 109 virtual bool HasMouseCapture() const = 0; |
87 | 110 |
| 111 // Returns true if any mouse button is currently pressed. |
| 112 virtual bool IsMouseButtonDown() const = 0; |
| 113 |
88 // Returns the InputMethod for this native widget. | 114 // Returns the InputMethod for this native widget. |
89 // Note that all widgets in a widget hierarchy share the same input method. | 115 // Note that all widgets in a widget hierarchy share the same input method. |
90 // TODO(suzhe): rename to GetInputMethod() when NativeWidget implementation | 116 // TODO(suzhe): rename to GetInputMethod() when NativeWidget implementation |
91 // class doesn't inherit Widget anymore. | 117 // class doesn't inherit Widget anymore. |
92 virtual InputMethod* GetInputMethodNative() = 0; | 118 virtual InputMethod* GetInputMethodNative() = 0; |
93 | 119 |
94 // Sets a different InputMethod instance to this native widget. The instance | 120 // Sets a different InputMethod instance to this native widget. The instance |
95 // must not be initialized, the ownership will be assumed by the native | 121 // must not be initialized, the ownership will be assumed by the native |
96 // widget. It's only for testing purpose. | 122 // widget. It's only for testing purpose. |
97 virtual void ReplaceInputMethod(InputMethod* input_method) = 0; | 123 virtual void ReplaceInputMethod(InputMethod* input_method) = 0; |
(...skipping 26 matching lines...) Expand all Loading... |
124 virtual void RunShellDrag(View* view, | 150 virtual void RunShellDrag(View* view, |
125 const ui::OSExchangeData& data, | 151 const ui::OSExchangeData& data, |
126 int operation) = 0; | 152 int operation) = 0; |
127 virtual void SchedulePaintInRect(const gfx::Rect& rect) = 0; | 153 virtual void SchedulePaintInRect(const gfx::Rect& rect) = 0; |
128 virtual void SetCursor(gfx::NativeCursor cursor) = 0; | 154 virtual void SetCursor(gfx::NativeCursor cursor) = 0; |
129 }; | 155 }; |
130 | 156 |
131 } // namespace views | 157 } // namespace views |
132 | 158 |
133 #endif // VIEWS_WIDGET_NATIVE_WIDGET_H_ | 159 #endif // VIEWS_WIDGET_NATIVE_WIDGET_H_ |
OLD | NEW |