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