Revert of Roll src/third_party/WebKit e0eac24:489c548 (svn 193311:193320) (patchset...
[chromium-blink-merge.git] / ui / aura / window_delegate.h
blobc344ac23bf3759ce0507c30fe27eeae87c379146
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_AURA_WINDOW_DELEGATE_H_
6 #define UI_AURA_WINDOW_DELEGATE_H_
8 #include "base/compiler_specific.h"
9 #include "base/memory/ref_counted.h"
10 #include "ui/aura/aura_export.h"
11 #include "ui/events/event_constants.h"
12 #include "ui/events/event_handler.h"
13 #include "ui/gfx/native_widget_types.h"
15 namespace gfx {
16 class Canvas;
17 class Path;
18 class Point;
19 class Rect;
20 class Size;
23 namespace ui {
24 class GestureEvent;
25 class KeyEvent;
26 class Layer;
27 class MouseEvent;
28 class PaintContext;
29 class TextInputClient;
30 class Texture;
31 class TouchEvent;
34 namespace aura {
36 // Delegate interface for aura::Window.
37 class AURA_EXPORT WindowDelegate : public ui::EventHandler {
38 public:
39 // Returns the window's minimum size, or size 0,0 if there is no limit.
40 virtual gfx::Size GetMinimumSize() const = 0;
42 // Returns the window's maximum size, or size 0,0 if there is no limit.
43 virtual gfx::Size GetMaximumSize() const = 0;
45 // Called when the Window's position and/or size changes.
46 virtual void OnBoundsChanged(const gfx::Rect& old_bounds,
47 const gfx::Rect& new_bounds) = 0;
49 // Returns the focused text input client within this window.
50 // This function does not look at child windows.
51 virtual ui::TextInputClient* GetFocusedTextInputClient() = 0;
53 // Returns the native cursor for the specified point, in window coordinates,
54 // or NULL for the default cursor.
55 virtual gfx::NativeCursor GetCursor(const gfx::Point& point) = 0;
57 // Returns the non-client component (see hit_test.h) containing |point|, in
58 // window coordinates.
59 virtual int GetNonClientComponent(const gfx::Point& point) const = 0;
61 // Returns true if event handling should descend into |child|. |location| is
62 // in terms of the Window.
63 virtual bool ShouldDescendIntoChildForEventHandling(
64 Window* child,
65 const gfx::Point& location) = 0;
67 // Returns true of the window can be focused.
68 virtual bool CanFocus() = 0;
70 // Invoked when mouse capture is lost on the window.
71 virtual void OnCaptureLost() = 0;
73 // Asks the delegate to paint window contents into the supplied context.
74 virtual void OnPaint(const ui::PaintContext& context) = 0;
76 // Called when the window's device scale factor has changed.
77 virtual void OnDeviceScaleFactorChanged(float device_scale_factor) = 0;
79 // Called from Window's destructor before OnWindowDestroyed and before the
80 // children have been destroyed and the window has been removed from its
81 // parent.
82 // This method takes the window because the delegate implementation may no
83 // longer have a route back to the window by the time this method is called.
84 virtual void OnWindowDestroying(Window* window) = 0;
86 // Called when the Window has been destroyed (i.e. from its destructor). This
87 // is called after OnWindowDestroying and after the children have been
88 // deleted and the window has been removed from its parent.
89 // The delegate can use this as an opportunity to delete itself if necessary.
90 // This method takes the window because the delegate implementation may no
91 // longer have a route back to the window by the time this method is called.
92 virtual void OnWindowDestroyed(Window* window) = 0;
94 // Called when the TargetVisibility() of a Window changes. |visible|
95 // corresponds to the target visibility of the window. See
96 // Window::TargetVisibility() for details.
97 virtual void OnWindowTargetVisibilityChanged(bool visible) = 0;
99 // Called from Window::HitTest to check if the window has a custom hit test
100 // mask. It works similar to the views counterparts. That is, if the function
101 // returns true, GetHitTestMask below will be called to get the mask.
102 // Otherwise, Window will hit-test against its bounds.
103 virtual bool HasHitTestMask() const = 0;
105 // Called from Window::HitTest to retrieve hit test mask when HasHitTestMask
106 // above returns true.
107 virtual void GetHitTestMask(gfx::Path* mask) const = 0;
109 protected:
110 ~WindowDelegate() override {}
113 } // namespace aura
115 #endif // UI_AURA_WINDOW_DELEGATE_H_