Updating trunk VERSION from 2139.0 to 2140.0
[chromium-blink-merge.git] / ui / views / widget / native_widget_delegate.h
blob5ab2a6def4d37d471c2b4557479504ebeac9d723
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_DELEGATE_H_
6 #define UI_VIEWS_WIDGET_NATIVE_WIDGET_DELEGATE_H_
8 #include <vector>
10 #include "ui/events/event_constants.h"
11 #include "ui/views/views_export.h"
13 namespace gfx {
14 class Canvas;
15 class Path;
16 class Point;
17 class Size;
20 namespace ui {
21 class GestureEvent;
22 class KeyEvent;
23 class Layer;
24 class MouseEvent;
25 class TouchEvent;
26 class ScrollEvent;
29 namespace views {
30 class InputMethod;
31 class Widget;
33 namespace internal {
35 ////////////////////////////////////////////////////////////////////////////////
36 // NativeWidgetDelegate
38 // An interface implemented by the object that handles events sent by a
39 // NativeWidget implementation.
41 class VIEWS_EXPORT NativeWidgetDelegate {
42 public:
43 virtual ~NativeWidgetDelegate() {}
45 // Returns true if the window is modal.
46 virtual bool IsModal() const = 0;
48 // Returns true if the window is a dialog box.
49 virtual bool IsDialogBox() const = 0;
51 // Returns true if the window can be activated.
52 virtual bool CanActivate() const = 0;
54 virtual bool IsInactiveRenderingDisabled() const = 0;
55 virtual void EnableInactiveRendering() = 0;
57 // Called when the activation state of a window has changed.
58 virtual void OnNativeWidgetActivationChanged(bool active) = 0;
60 // Called when native focus moves from one native view to another.
61 virtual void OnNativeFocus(gfx::NativeView focused_view) = 0;
62 virtual void OnNativeBlur(gfx::NativeView focused_view) = 0;
64 // Called when the window is about to be shown/hidden.
65 virtual void OnNativeWidgetVisibilityChanging(bool visible) = 0;
67 // Called when the window is shown/hidden.
68 virtual void OnNativeWidgetVisibilityChanged(bool visible) = 0;
70 // Called when the native widget is created.
71 // The |desktop_widget| bool is true for widgets created in the desktop and
72 // false for widgets created in the shell.
73 virtual void OnNativeWidgetCreated(bool desktop_widget) = 0;
75 // Called just before the native widget is destroyed. This is the delegate's
76 // last chance to do anything with the native widget handle.
77 virtual void OnNativeWidgetDestroying() = 0;
79 // Called just after the native widget is destroyed.
80 virtual void OnNativeWidgetDestroyed() = 0;
82 // Returns the smallest size the window can be resized to by the user.
83 virtual gfx::Size GetMinimumSize() const = 0;
85 // Returns the largest size the window can be resized to by the user.
86 virtual gfx::Size GetMaximumSize() const = 0;
88 // Called when the NativeWidget changed position.
89 virtual void OnNativeWidgetMove() = 0;
91 // Called when the NativeWidget changed size to |new_size|.
92 // This may happen at the same time as OnNativeWidgetWindowShowStateChanged,
93 // e.g. maximize.
94 virtual void OnNativeWidgetSizeChanged(const gfx::Size& new_size) = 0;
96 // Called when the NativeWidget changes its window state.
97 // This may happen at the same time as OnNativeWidgetSizeChanged, e.g.
98 // maximize.
99 virtual void OnNativeWidgetWindowShowStateChanged() = 0;
101 // Called when the user begins/ends to change the bounds of the window.
102 virtual void OnNativeWidgetBeginUserBoundsChange() = 0;
103 virtual void OnNativeWidgetEndUserBoundsChange() = 0;
105 // Returns true if the delegate has a FocusManager.
106 virtual bool HasFocusManager() const = 0;
108 // Paints the widget using acceleration. If the widget is not using
109 // accelerated painting this returns false and does nothing.
110 virtual bool OnNativeWidgetPaintAccelerated(
111 const gfx::Rect& dirty_region) = 0;
113 // Paints the rootview in the canvas. This will also refresh the compositor
114 // tree if necessary when accelerated painting is enabled.
115 virtual void OnNativeWidgetPaint(gfx::Canvas* canvas) = 0;
117 // Returns the non-client component (see ui/base/hit_test.h) containing
118 // |point|, in client coordinates.
119 virtual int GetNonClientComponent(const gfx::Point& point) = 0;
121 // Mouse and key event handlers.
122 virtual void OnKeyEvent(ui::KeyEvent* event) = 0;
123 virtual void OnMouseEvent(ui::MouseEvent* event) = 0;
124 virtual void OnMouseCaptureLost() = 0;
126 virtual void OnScrollEvent(ui::ScrollEvent* event) = 0;
127 virtual void OnGestureEvent(ui::GestureEvent* event) = 0;
129 // Runs the specified native command. Returns true if the command is handled.
130 virtual bool ExecuteCommand(int command_id) = 0;
132 // Returns the input method of the widget this delegate is associated with.
133 // Note that this does not use the top level widget, so may return NULL
134 // if the widget doesn't have input method.
135 virtual InputMethod* GetInputMethodDirect() = 0;
137 // Returns the child Layers of the Widgets layer that were created by Views.
138 virtual const std::vector<ui::Layer*>& GetRootLayers() = 0;
140 // Returns true if window has a hit-test mask.
141 virtual bool HasHitTestMask() const = 0;
143 // Provides the hit-test mask if HasHitTestMask above returns true.
144 virtual void GetHitTestMask(gfx::Path* mask) const = 0;
147 virtual Widget* AsWidget() = 0;
148 virtual const Widget* AsWidget() const = 0;
150 // Sets-up the focus manager with the view that should have focus when the
151 // window is shown the first time. It takes the intended |show_state| of the
152 // window in order to decide whether the window should be focused now or
153 // later. Returns true if the initial focus has been set or the window should
154 // not set the initial focus, or false if the caller should set the initial
155 // focus (if any).
156 virtual bool SetInitialFocus(ui::WindowShowState show_state) = 0;
159 } // namespace internal
160 } // namespace views
162 #endif // UI_VIEWS_WIDGET_NATIVE_WIDGET_DELEGATE_H_