OLD | NEW |
(Empty) | |
| 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. |
| 4 |
| 5 #ifndef VIEWS_WIDGET_NATIVE_WIDGET_PRIVATE_H_ |
| 6 #define VIEWS_WIDGET_NATIVE_WIDGET_PRIVATE_H_ |
| 7 #pragma once |
| 8 |
| 9 #include "base/string16.h" |
| 10 #include "ui/gfx/native_widget_types.h" |
| 11 #include "ui/views/ime/input_method_delegate.h" |
| 12 #include "views/widget/native_widget.h" |
| 13 |
| 14 namespace gfx { |
| 15 class Rect; |
| 16 } |
| 17 |
| 18 namespace ui { |
| 19 class OSExchangeData; |
| 20 } |
| 21 |
| 22 namespace views { |
| 23 class InputMethod; |
| 24 class TooltipManager; |
| 25 namespace internal { |
| 26 |
| 27 //////////////////////////////////////////////////////////////////////////////// |
| 28 // NativeWidgetPrivate interface |
| 29 // |
| 30 // A NativeWidget subclass internal to views that provides Widget a conduit for |
| 31 // communication with a backend-specific native widget implementation. |
| 32 // |
| 33 // Many of the methods here are pass-thrus for Widget, and as such there is no |
| 34 // documentation for them here. In that case, see methods of the same name in |
| 35 // widget.h. |
| 36 // |
| 37 // IMPORTANT: This type is intended for use only by the views system and for |
| 38 // NativeWidget implementations. This file should not be included |
| 39 // in code that does not fall into one of these use cases. |
| 40 // |
| 41 class VIEWS_EXPORT NativeWidgetPrivate : public NativeWidget, |
| 42 public internal::InputMethodDelegate { |
| 43 public: |
| 44 virtual ~NativeWidgetPrivate() {} |
| 45 |
| 46 // Creates an appropriate default NativeWidgetPrivate implementation for the |
| 47 // current OS/circumstance. |
| 48 static NativeWidgetPrivate* CreateNativeWidget( |
| 49 internal::NativeWidgetDelegate* delegate); |
| 50 |
| 51 static NativeWidgetPrivate* GetNativeWidgetForNativeView( |
| 52 gfx::NativeView native_view); |
| 53 static NativeWidgetPrivate* GetNativeWidgetForNativeWindow( |
| 54 gfx::NativeWindow native_window); |
| 55 |
| 56 // Retrieves the top NativeWidgetPrivate in the hierarchy containing the given |
| 57 // NativeView, or NULL if there is no NativeWidgetPrivate that contains it. |
| 58 static NativeWidgetPrivate* GetTopLevelNativeWidget( |
| 59 gfx::NativeView native_view); |
| 60 |
| 61 static void GetAllChildWidgets(gfx::NativeView native_view, |
| 62 Widget::Widgets* children); |
| 63 static void ReparentNativeView(gfx::NativeView native_view, |
| 64 gfx::NativeView new_parent); |
| 65 |
| 66 // Returns true if any mouse button is currently down. |
| 67 static bool IsMouseButtonDown(); |
| 68 |
| 69 // Initializes the NativeWidget. |
| 70 virtual void InitNativeWidget(const Widget::InitParams& params) = 0; |
| 71 |
| 72 // Returns a NonClientFrameView for the widget's NonClientView, or NULL if |
| 73 // the NativeWidget wants no special NonClientFrameView. |
| 74 virtual NonClientFrameView* CreateNonClientFrameView() = 0; |
| 75 |
| 76 virtual void UpdateFrameAfterFrameChange() = 0; |
| 77 virtual bool ShouldUseNativeFrame() const = 0; |
| 78 virtual void FrameTypeChanged() = 0; |
| 79 |
| 80 // Returns the Widget associated with this NativeWidget. This function is |
| 81 // guaranteed to return non-NULL for the lifetime of the NativeWidget. |
| 82 virtual Widget* GetWidget() = 0; |
| 83 virtual const Widget* GetWidget() const = 0; |
| 84 |
| 85 // Returns the NativeView/Window associated with this NativeWidget. |
| 86 virtual gfx::NativeView GetNativeView() const = 0; |
| 87 virtual gfx::NativeWindow GetNativeWindow() const = 0; |
| 88 |
| 89 // Returns the topmost Widget in a hierarchy. |
| 90 virtual Widget* GetTopLevelWidget() = 0; |
| 91 |
| 92 // Returns the Compositor, or NULL if there isn't one associated with this |
| 93 // NativeWidget. |
| 94 virtual const ui::Compositor* GetCompositor() const = 0; |
| 95 virtual ui::Compositor* GetCompositor() = 0; |
| 96 |
| 97 // See description in View for details. |
| 98 virtual void CalculateOffsetToAncestorWithLayer(gfx::Point* offset, |
| 99 ui::Layer** layer_parent) = 0; |
| 100 virtual void ReorderLayers() = 0; |
| 101 |
| 102 // Notifies the NativeWidget that a view was removed from the Widget's view |
| 103 // hierarchy. |
| 104 virtual void ViewRemoved(View* view) = 0; |
| 105 |
| 106 // Sets/Gets a native window property on the underlying native window object. |
| 107 // Returns NULL if the property does not exist. Setting the property value to |
| 108 // NULL removes the property. |
| 109 virtual void SetNativeWindowProperty(const char* name, void* value) = 0; |
| 110 virtual void* GetNativeWindowProperty(const char* name) const = 0; |
| 111 |
| 112 // Returns the native widget's tooltip manager. Called from the View hierarchy |
| 113 // to update tooltips. |
| 114 virtual TooltipManager* GetTooltipManager() const = 0; |
| 115 |
| 116 // Returns true if a system screen reader is active for the NativeWidget. |
| 117 virtual bool IsScreenReaderActive() const = 0; |
| 118 |
| 119 // Notify native Accessibility clients of an event. |
| 120 virtual void SendNativeAccessibilityEvent( |
| 121 View* view, |
| 122 ui::AccessibilityTypes::Event event_type) = 0; |
| 123 |
| 124 // Sets or releases event capturing for this native widget. |
| 125 virtual void SetMouseCapture() = 0; |
| 126 virtual void ReleaseMouseCapture() = 0; |
| 127 |
| 128 // Returns true if this native widget is capturing mouse events. |
| 129 virtual bool HasMouseCapture() const = 0; |
| 130 |
| 131 // Returns the InputMethod for this native widget. |
| 132 // Note that all widgets in a widget hierarchy share the same input method. |
| 133 // TODO(suzhe): rename to GetInputMethod() when NativeWidget implementation |
| 134 // class doesn't inherit Widget anymore. |
| 135 virtual InputMethod* CreateInputMethod() = 0; |
| 136 |
| 137 |
| 138 // Centers the window and sizes it to the specified size. |
| 139 virtual void CenterWindow(const gfx::Size& size) = 0; |
| 140 |
| 141 // Retrieves the window's current restored bounds and "show" state, for |
| 142 // persisting. |
| 143 virtual void GetWindowPlacement( |
| 144 gfx::Rect* bounds, |
| 145 ui::WindowShowState* show_state) const = 0; |
| 146 |
| 147 // Sets the NativeWindow title. |
| 148 virtual void SetWindowTitle(const string16& title) = 0; |
| 149 |
| 150 // Sets the Window icons. |window_icon| is a 16x16 icon suitable for use in |
| 151 // a title bar. |app_icon| is a larger size for use in the host environment |
| 152 // app switching UI. |
| 153 virtual void SetWindowIcons(const SkBitmap& window_icon, |
| 154 const SkBitmap& app_icon) = 0; |
| 155 |
| 156 // Update native accessibility properties on the native window. |
| 157 virtual void SetAccessibleName(const string16& name) = 0; |
| 158 virtual void SetAccessibleRole(ui::AccessibilityTypes::Role role) = 0; |
| 159 virtual void SetAccessibleState(ui::AccessibilityTypes::State state) = 0; |
| 160 |
| 161 // Makes the NativeWindow modal. |
| 162 virtual void BecomeModal() = 0; |
| 163 |
| 164 // See method documentation in Widget. |
| 165 virtual gfx::Rect GetWindowScreenBounds() const = 0; |
| 166 virtual gfx::Rect GetClientAreaScreenBounds() const = 0; |
| 167 virtual gfx::Rect GetRestoredBounds() const = 0; |
| 168 virtual void SetBounds(const gfx::Rect& bounds) = 0; |
| 169 virtual void SetSize(const gfx::Size& size) = 0; |
| 170 virtual void MoveAbove(gfx::NativeView native_view) = 0; |
| 171 virtual void MoveToTop() = 0; |
| 172 virtual void SetShape(gfx::NativeRegion shape) = 0; |
| 173 virtual void Close() = 0; |
| 174 virtual void CloseNow() = 0; |
| 175 virtual void EnableClose(bool enable) = 0; |
| 176 virtual void Show() = 0; |
| 177 virtual void Hide() = 0; |
| 178 // Invoked if the initial show should maximize the window. |restored_bounds| |
| 179 // is the bounds of the window when not maximized. |
| 180 virtual void ShowMaximizedWithBounds(const gfx::Rect& restored_bounds) = 0; |
| 181 virtual void ShowWithWindowState(ui::WindowShowState show_state) = 0; |
| 182 virtual bool IsVisible() const = 0; |
| 183 virtual void Activate() = 0; |
| 184 virtual void Deactivate() = 0; |
| 185 virtual bool IsActive() const = 0; |
| 186 virtual void SetAlwaysOnTop(bool always_on_top) = 0; |
| 187 virtual void Maximize() = 0; |
| 188 virtual void Minimize() = 0; |
| 189 virtual bool IsMaximized() const = 0; |
| 190 virtual bool IsMinimized() const = 0; |
| 191 virtual void Restore() = 0; |
| 192 virtual void SetFullscreen(bool fullscreen) = 0; |
| 193 virtual bool IsFullscreen() const = 0; |
| 194 virtual void SetOpacity(unsigned char opacity) = 0; |
| 195 virtual void SetUseDragFrame(bool use_drag_frame) = 0; |
| 196 virtual bool IsAccessibleWidget() const = 0; |
| 197 virtual void RunShellDrag(View* view, |
| 198 const ui::OSExchangeData& data, |
| 199 int operation) = 0; |
| 200 virtual void SchedulePaintInRect(const gfx::Rect& rect) = 0; |
| 201 virtual void SetCursor(gfx::NativeCursor cursor) = 0; |
| 202 virtual void ClearNativeFocus() = 0; |
| 203 virtual void FocusNativeView(gfx::NativeView native_view) = 0; |
| 204 virtual bool ConvertPointFromAncestor( |
| 205 const Widget* ancestor, gfx::Point* point) const = 0; |
| 206 virtual gfx::Rect GetWorkAreaBoundsInScreen() const = 0; |
| 207 virtual void SetInactiveRenderingDisabled(bool value) = 0; |
| 208 |
| 209 // Overridden from NativeWidget: |
| 210 virtual internal::NativeWidgetPrivate* AsNativeWidgetPrivate() OVERRIDE; |
| 211 }; |
| 212 |
| 213 } // namespace internal |
| 214 } // namespace views |
| 215 |
| 216 #endif // VIEWS_WIDGET_NATIVE_WIDGET_PRIVATE_H_ |
OLD | NEW |