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