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 UI_VIEWS_WIDGET_NATIVE_WIDGET_DELEGATE_H_ | |
6 #define UI_VIEWS_WIDGET_NATIVE_WIDGET_DELEGATE_H_ | |
7 #pragma once | |
8 | |
9 #include "ui/base/events.h" | |
10 #include "ui/gfx/native_widget_types.h" | |
11 #include "views/views_export.h" | |
12 | |
13 #if defined(TOUCH_UI) | |
14 #include "ui/base/events.h" | |
15 #endif | |
16 | |
17 namespace gfx { | |
18 class Canvas; | |
19 class Point; | |
20 class Rect; | |
21 class Size; | |
22 } | |
23 | |
24 namespace views { | |
25 class InputMethod; | |
26 class KeyEvent; | |
27 class MouseEvent; | |
28 class TouchEvent; | |
29 | |
30 namespace internal { | |
31 | |
32 //////////////////////////////////////////////////////////////////////////////// | |
33 // NativeWidgetDelegate | |
34 // | |
35 // An interface implemented by the object that handles events sent by a | |
36 // NativeWidget implementation. | |
37 // | |
38 class VIEWS_EXPORT NativeWidgetDelegate { | |
39 public: | |
40 virtual ~NativeWidgetDelegate() {} | |
41 | |
42 // Returns true if the window is modal. | |
43 virtual bool IsModal() const = 0; | |
44 | |
45 // Returns true if the window is a dialog box. | |
46 virtual bool IsDialogBox() const = 0; | |
47 | |
48 // Returns true if the window can be activated. | |
49 virtual bool CanActivate() const = 0; | |
50 | |
51 virtual bool IsInactiveRenderingDisabled() const = 0; | |
52 virtual void EnableInactiveRendering() = 0; | |
53 | |
54 // Called when the activation state of a window has changed. | |
55 virtual void OnNativeWidgetActivationChanged(bool active) = 0; | |
56 | |
57 // Called when native focus moves from one native view to another. | |
58 virtual void OnNativeFocus(gfx::NativeView focused_view) = 0; | |
59 virtual void OnNativeBlur(gfx::NativeView focused_view) = 0; | |
60 | |
61 // Called when the window is shown/hidden. | |
62 virtual void OnNativeWidgetVisibilityChanged(bool visible) = 0; | |
63 | |
64 // Called when the native widget is created. | |
65 virtual void OnNativeWidgetCreated() = 0; | |
66 | |
67 // Called just before the native widget is destroyed. This is the delegate's | |
68 // last chance to do anything with the native widget handle. | |
69 virtual void OnNativeWidgetDestroying() = 0; | |
70 | |
71 // Called just after the native widget is destroyed. | |
72 virtual void OnNativeWidgetDestroyed() = 0; | |
73 | |
74 // Returns the smallest size the window can be resized to by the user. | |
75 virtual gfx::Size GetMinimumSize() = 0; | |
76 | |
77 // Called when the NativeWidget changed size to |new_size|. | |
78 virtual void OnNativeWidgetSizeChanged(const gfx::Size& new_size) = 0; | |
79 | |
80 // Called when the user begins/ends to change the bounds of the window. | |
81 virtual void OnNativeWidgetBeginUserBoundsChange() = 0; | |
82 virtual void OnNativeWidgetEndUserBoundsChange() = 0; | |
83 | |
84 // Returns true if the delegate has a FocusManager. | |
85 virtual bool HasFocusManager() const = 0; | |
86 | |
87 // Paints the widget using acceleration. If the widget is not using | |
88 // accelerated painting this returns false and does nothing. | |
89 virtual bool OnNativeWidgetPaintAccelerated( | |
90 const gfx::Rect& dirty_region) = 0; | |
91 | |
92 // Paints the rootview in the canvas. This will also refresh the compositor | |
93 // tree if necessary when accelerated painting is enabled. | |
94 virtual void OnNativeWidgetPaint(gfx::Canvas* canvas) = 0; | |
95 | |
96 // Returns the non-client component (see ui/base/hit_test.h) containing | |
97 // |point|, in client coordinates. | |
98 virtual int GetNonClientComponent(const gfx::Point& point) = 0; | |
99 | |
100 // Mouse and key event handlers. | |
101 virtual bool OnKeyEvent(const KeyEvent& event) = 0; | |
102 virtual bool OnMouseEvent(const MouseEvent& event) = 0; | |
103 virtual void OnMouseCaptureLost() = 0; | |
104 virtual ui::TouchStatus OnTouchEvent(const TouchEvent& event) = 0; | |
105 | |
106 // Runs the specified native command. Returns true if the command is handled. | |
107 virtual bool ExecuteCommand(int command_id) = 0; | |
108 | |
109 // Returns the input method of the widget this delegate is associated with. | |
110 // Note that this does not use the top level widget, so may return NULL | |
111 // if the widget doesn't have input method. | |
112 virtual InputMethod* GetInputMethodDirect() = 0; | |
113 | |
114 virtual Widget* AsWidget() = 0; | |
115 virtual const Widget* AsWidget() const = 0; | |
116 }; | |
117 | |
118 } // namespace internal | |
119 } // namespace views | |
120 | |
121 #endif // UI_VIEWS_WIDGET_NATIVE_WIDGET_DELEGATE_H_ | |
OLD | NEW |