Add ICU message format support
[chromium-blink-merge.git] / ui / views / widget / native_widget_private.h
blob2adf5894c4f6bc09b10b500ec335af996c387994
1 // Copyright (c) 2012 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_WIDGET_NATIVE_WIDGET_PRIVATE_H_
6 #define UI_VIEWS_WIDGET_NATIVE_WIDGET_PRIVATE_H_
8 #include "base/strings/string16.h"
9 #include "ui/base/ui_base_types.h"
10 #include "ui/gfx/native_widget_types.h"
11 #include "ui/views/widget/native_widget.h"
13 namespace gfx {
14 class FontList;
15 class ImageSkia;
16 class Rect;
19 namespace ui {
20 class InputMethod;
21 class NativeTheme;
22 class OSExchangeData;
25 namespace views {
26 class TooltipManager;
27 namespace internal {
29 ////////////////////////////////////////////////////////////////////////////////
30 // NativeWidgetPrivate interface
32 // A NativeWidget subclass internal to views that provides Widget a conduit for
33 // communication with a backend-specific native widget implementation.
35 // Many of the methods here are pass-thrus for Widget, and as such there is no
36 // documentation for them here. In that case, see methods of the same name in
37 // widget.h.
39 // IMPORTANT: This type is intended for use only by the views system and for
40 // NativeWidget implementations. This file should not be included
41 // in code that does not fall into one of these use cases.
43 class VIEWS_EXPORT NativeWidgetPrivate : public NativeWidget {
44 public:
45 ~NativeWidgetPrivate() override {}
47 // Creates an appropriate default NativeWidgetPrivate implementation for the
48 // current OS/circumstance.
49 static NativeWidgetPrivate* CreateNativeWidget(
50 internal::NativeWidgetDelegate* delegate);
52 static NativeWidgetPrivate* GetNativeWidgetForNativeView(
53 gfx::NativeView native_view);
54 static NativeWidgetPrivate* GetNativeWidgetForNativeWindow(
55 gfx::NativeWindow native_window);
57 // Retrieves the top NativeWidgetPrivate in the hierarchy containing the given
58 // NativeView, or NULL if there is no NativeWidgetPrivate that contains it.
59 static NativeWidgetPrivate* GetTopLevelNativeWidget(
60 gfx::NativeView native_view);
62 static void GetAllChildWidgets(gfx::NativeView native_view,
63 Widget::Widgets* children);
64 static void GetAllOwnedWidgets(gfx::NativeView native_view,
65 Widget::Widgets* owned);
66 static void ReparentNativeView(gfx::NativeView native_view,
67 gfx::NativeView new_parent);
69 // Returns true if any mouse button is currently down.
70 static bool IsMouseButtonDown();
72 static gfx::FontList GetWindowTitleFontList();
74 // Initializes the NativeWidget.
75 virtual void InitNativeWidget(const Widget::InitParams& params) = 0;
77 // Returns a NonClientFrameView for the widget's NonClientView, or NULL if
78 // the NativeWidget wants no special NonClientFrameView.
79 virtual NonClientFrameView* CreateNonClientFrameView() = 0;
81 virtual bool ShouldUseNativeFrame() const = 0;
82 virtual bool ShouldWindowContentsBeTransparent() const = 0;
83 virtual void FrameTypeChanged() = 0;
85 // Returns the Widget associated with this NativeWidget. This function is
86 // guaranteed to return non-NULL for the lifetime of the NativeWidget.
87 virtual Widget* GetWidget() = 0;
88 virtual const Widget* GetWidget() const = 0;
90 // Returns the NativeView/Window associated with this NativeWidget.
91 virtual gfx::NativeView GetNativeView() const = 0;
92 virtual gfx::NativeWindow GetNativeWindow() const = 0;
94 // Returns the topmost Widget in a hierarchy.
95 virtual Widget* GetTopLevelWidget() = 0;
97 // Returns the Compositor, or NULL if there isn't one associated with this
98 // NativeWidget.
99 virtual const ui::Compositor* GetCompositor() const = 0;
101 // Returns the NativeWidget's layer, if any.
102 virtual const ui::Layer* GetLayer() const = 0;
104 // Reorders the widget's child NativeViews which are associated to the view
105 // tree (eg via a NativeViewHost) to match the z-order of the views in the
106 // view tree. The z-order of views with layers relative to views with
107 // associated NativeViews is used to reorder the NativeView layers. This
108 // method assumes that the widget's child layers which are owned by a view are
109 // already in the correct z-order relative to each other and does no
110 // reordering if there are no views with an associated NativeView.
111 virtual void ReorderNativeViews() = 0;
113 // Notifies the NativeWidget that a view was removed from the Widget's view
114 // hierarchy.
115 virtual void ViewRemoved(View* view) = 0;
117 // Sets/Gets a native window property on the underlying native window object.
118 // Returns NULL if the property does not exist. Setting the property value to
119 // NULL removes the property.
120 virtual void SetNativeWindowProperty(const char* name, void* value) = 0;
121 virtual void* GetNativeWindowProperty(const char* name) const = 0;
123 // Returns the native widget's tooltip manager. Called from the View hierarchy
124 // to update tooltips.
125 virtual TooltipManager* GetTooltipManager() const = 0;
127 // Sets or releases event capturing for this native widget.
128 virtual void SetCapture() = 0;
129 virtual void ReleaseCapture() = 0;
131 // Returns true if this native widget is capturing events.
132 virtual bool HasCapture() const = 0;
134 // Returns the ui::InputMethod for this native widget.
135 virtual ui::InputMethod* GetInputMethod() = 0;
137 // Centers the window and sizes it to the specified size.
138 virtual void CenterWindow(const gfx::Size& size) = 0;
140 // Retrieves the window's current restored bounds and "show" state, for
141 // persisting.
142 virtual void GetWindowPlacement(
143 gfx::Rect* bounds,
144 ui::WindowShowState* show_state) const = 0;
146 // Sets the NativeWindow title. Returns true if the title changed.
147 virtual bool SetWindowTitle(const base::string16& title) = 0;
149 // Sets the Window icons. |window_icon| is a 16x16 icon suitable for use in
150 // a title bar. |app_icon| is a larger size for use in the host environment
151 // app switching UI.
152 virtual void SetWindowIcons(const gfx::ImageSkia& window_icon,
153 const gfx::ImageSkia& app_icon) = 0;
155 // Initializes the modal type of the window to |modal_type|. Called from
156 // NativeWidgetDelegate::OnNativeWidgetCreated() before the widget is
157 // initially parented.
158 virtual void InitModalType(ui::ModalType modal_type) = 0;
160 // See method documentation in Widget.
161 virtual gfx::Rect GetWindowBoundsInScreen() const = 0;
162 virtual gfx::Rect GetClientAreaBoundsInScreen() const = 0;
163 virtual gfx::Rect GetRestoredBounds() const = 0;
164 virtual void SetBounds(const gfx::Rect& bounds) = 0;
165 virtual void SetSize(const gfx::Size& size) = 0;
166 virtual void StackAbove(gfx::NativeView native_view) = 0;
167 virtual void StackAtTop() = 0;
168 virtual void StackBelow(gfx::NativeView native_view) = 0;
169 virtual void SetShape(SkRegion* shape) = 0;
170 virtual void Close() = 0;
171 virtual void CloseNow() = 0;
172 virtual void Show() = 0;
173 virtual void Hide() = 0;
174 // Invoked if the initial show should maximize the window. |restored_bounds|
175 // is the bounds of the window when not maximized.
176 virtual void ShowMaximizedWithBounds(const gfx::Rect& restored_bounds) = 0;
177 virtual void ShowWithWindowState(ui::WindowShowState show_state) = 0;
178 virtual bool IsVisible() const = 0;
179 virtual void Activate() = 0;
180 virtual void Deactivate() = 0;
181 virtual bool IsActive() const = 0;
182 virtual void SetAlwaysOnTop(bool always_on_top) = 0;
183 virtual bool IsAlwaysOnTop() const = 0;
184 virtual void SetVisibleOnAllWorkspaces(bool always_visible) = 0;
185 virtual void Maximize() = 0;
186 virtual void Minimize() = 0;
187 virtual bool IsMaximized() const = 0;
188 virtual bool IsMinimized() const = 0;
189 virtual void Restore() = 0;
190 virtual void SetFullscreen(bool fullscreen) = 0;
191 virtual bool IsFullscreen() const = 0;
192 virtual void SetOpacity(unsigned char opacity) = 0;
193 virtual void SetUseDragFrame(bool use_drag_frame) = 0;
194 virtual void FlashFrame(bool flash) = 0;
195 virtual void RunShellDrag(View* view,
196 const ui::OSExchangeData& data,
197 const gfx::Point& location,
198 int operation,
199 ui::DragDropTypes::DragEventSource source) = 0;
200 virtual void SchedulePaintInRect(const gfx::Rect& rect) = 0;
201 virtual void SetCursor(gfx::NativeCursor cursor) = 0;
202 virtual bool IsMouseEventsEnabled() const = 0;
203 virtual void ClearNativeFocus() = 0;
204 virtual gfx::Rect GetWorkAreaBoundsInScreen() const = 0;
205 virtual Widget::MoveLoopResult RunMoveLoop(
206 const gfx::Vector2d& drag_offset,
207 Widget::MoveLoopSource source,
208 Widget::MoveLoopEscapeBehavior escape_behavior) = 0;
209 virtual void EndMoveLoop() = 0;
210 virtual void SetVisibilityChangedAnimationsEnabled(bool value) = 0;
211 virtual void SetVisibilityAnimationDuration(
212 const base::TimeDelta& duration) = 0;
213 virtual void SetVisibilityAnimationTransition(
214 Widget::VisibilityTransition transition) = 0;
215 virtual ui::NativeTheme* GetNativeTheme() const = 0;
216 virtual void OnRootViewLayout() = 0;
217 virtual bool IsTranslucentWindowOpacitySupported() const = 0;
218 virtual void OnSizeConstraintsChanged() = 0;
220 // Repost an unhandled event to the native widget for default OS processing.
221 virtual void RepostNativeEvent(gfx::NativeEvent native_event) = 0;
223 // Overridden from NativeWidget:
224 internal::NativeWidgetPrivate* AsNativeWidgetPrivate() override;
227 } // namespace internal
228 } // namespace views
230 #endif // UI_VIEWS_WIDGET_NATIVE_WIDGET_PRIVATE_H_