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_DELEGATE_H_ | 5 #ifndef VIEWS_WIDGET_NATIVE_WIDGET_DELEGATE_H_ |
6 #define VIEWS_WIDGET_NATIVE_WIDGET_DELEGATE_H_ | 6 #define VIEWS_WIDGET_NATIVE_WIDGET_DELEGATE_H_ |
7 #pragma once | 7 #pragma once |
8 | 8 |
9 namespace gfx { | 9 namespace gfx { |
10 class Canvas; | 10 class Canvas; |
11 class Size; | 11 class Size; |
12 } | 12 } |
13 | 13 |
14 namespace views { | 14 namespace views { |
15 namespace internal { | 15 namespace internal { |
16 | 16 |
17 //////////////////////////////////////////////////////////////////////////////// | 17 //////////////////////////////////////////////////////////////////////////////// |
18 // NativeWidgetDelegate | 18 // NativeWidgetDelegate |
19 // | 19 // |
20 // An interface implemented by the object that handles events sent by a | 20 // An interface implemented by the object that handles events sent by a |
21 // NativeWidget implementation. | 21 // NativeWidget implementation. |
22 // | 22 // |
23 class NativeWidgetDelegate { | 23 class NativeWidgetDelegate { |
24 public: | 24 public: |
25 virtual ~NativeWidgetDelegate() {} | 25 virtual ~NativeWidgetDelegate() {} |
26 | 26 |
| 27 // Returns true if the window can be activated. |
| 28 virtual bool CanActivate() const = 0; |
| 29 |
| 30 virtual bool IsInactiveRenderingDisabled() const = 0; |
| 31 virtual void EnableInactiveRendering() = 0; |
| 32 |
| 33 // Called when the activation state of a window has changed. |
| 34 virtual void OnNativeWidgetActivationChanged(bool active) = 0; |
| 35 |
27 // Called when native focus moves from one native view to another. | 36 // Called when native focus moves from one native view to another. |
28 virtual void OnNativeFocus(gfx::NativeView focused_view) = 0; | 37 virtual void OnNativeFocus(gfx::NativeView focused_view) = 0; |
29 virtual void OnNativeBlur(gfx::NativeView focused_view) = 0; | 38 virtual void OnNativeBlur(gfx::NativeView focused_view) = 0; |
30 | 39 |
31 // Called when the native widget is created. | 40 // Called when the native widget is created. |
32 virtual void OnNativeWidgetCreated() = 0; | 41 virtual void OnNativeWidgetCreated() = 0; |
33 | 42 |
| 43 // Called just before the native widget is destroyed. This is the delegate's |
| 44 // last chance to do anything with the native widget handle. |
| 45 virtual void OnNativeWidgetDestroying() = 0; |
| 46 |
34 // Called just after the native widget is destroyed. | 47 // Called just after the native widget is destroyed. |
35 virtual void OnNativeWidgetDestroyed() = 0; | 48 virtual void OnNativeWidgetDestroyed() = 0; |
36 | 49 |
| 50 // Returns the smallest size the window can be resized to by the user. |
| 51 virtual gfx::Size GetMinimumSize() = 0; |
| 52 |
37 // Called when the NativeWidget changed size to |new_size|. | 53 // Called when the NativeWidget changed size to |new_size|. |
38 virtual void OnSizeChanged(const gfx::Size& new_size) = 0; | 54 virtual void OnNativeWidgetSizeChanged(const gfx::Size& new_size) = 0; |
| 55 |
| 56 // Called when the user begins/ends to change the bounds of the window. |
| 57 virtual void OnNativeWidgetBeginUserBoundsChange() = 0; |
| 58 virtual void OnNativeWidgetEndUserBoundsChange() = 0; |
39 | 59 |
40 // Returns true if the delegate has a FocusManager. | 60 // Returns true if the delegate has a FocusManager. |
41 virtual bool HasFocusManager() const = 0; | 61 virtual bool HasFocusManager() const = 0; |
42 | 62 |
43 // Paints the widget using acceleration. If the widget is not using | 63 // Paints the widget using acceleration. If the widget is not using |
44 // accelerated painting this returns false and does nothing. | 64 // accelerated painting this returns false and does nothing. |
45 virtual bool OnNativeWidgetPaintAccelerated( | 65 virtual bool OnNativeWidgetPaintAccelerated( |
46 const gfx::Rect& dirty_region) = 0; | 66 const gfx::Rect& dirty_region) = 0; |
47 | 67 |
48 // Paints the rootview in the canvas. This will also refresh the compositor | 68 // Paints the rootview in the canvas. This will also refresh the compositor |
49 // tree if necessary when accelerated painting is enabled. | 69 // tree if necessary when accelerated painting is enabled. |
50 virtual void OnNativeWidgetPaint(gfx::Canvas* canvas) = 0; | 70 virtual void OnNativeWidgetPaint(gfx::Canvas* canvas) = 0; |
51 | 71 |
| 72 // Returns the non-client component (see views/window/hit_test.h) containing |
| 73 // |point|, in client coordinates. |
| 74 virtual int GetNonClientComponent(const gfx::Point& point) = 0; |
| 75 |
52 // Mouse and key event handlers. | 76 // Mouse and key event handlers. |
53 virtual bool OnKeyEvent(const KeyEvent& event) = 0; | 77 virtual bool OnKeyEvent(const KeyEvent& event) = 0; |
54 virtual bool OnMouseEvent(const MouseEvent& event) = 0; | 78 virtual bool OnMouseEvent(const MouseEvent& event) = 0; |
55 virtual void OnMouseCaptureLost() = 0; | 79 virtual void OnMouseCaptureLost() = 0; |
56 | 80 |
| 81 // Runs the specified native command. Returns true if the command is handled. |
| 82 virtual bool ExecuteCommand(int command_id) = 0; |
| 83 |
57 // | 84 // |
58 virtual Widget* AsWidget() = 0; | 85 virtual Widget* AsWidget() = 0; |
59 virtual const Widget* AsWidget() const = 0; | 86 virtual const Widget* AsWidget() const = 0; |
60 }; | 87 }; |
61 | 88 |
62 } // namespace internal | 89 } // namespace internal |
63 } // namespace views | 90 } // namespace views |
64 | 91 |
65 #endif // VIEWS_WIDGET_NATIVE_WIDGET_DELEGATE_H_ | 92 #endif // VIEWS_WIDGET_NATIVE_WIDGET_DELEGATE_H_ |
OLD | NEW |