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. 4 5 #ifndef UI_VIEWS_WIDGET_WIDGET_OBSERVER_H_ 6 #define UI_VIEWS_WIDGET_WIDGET_OBSERVER_H_ 7 8 #include "ui/views/views_export.h" 9 10 namespace gfx { 11 class Rect; 12 } 13 14 namespace views { 15 16 class Widget; 17 18 // Observers can listen to various events on the Widgets. 19 class VIEWS_EXPORT WidgetObserver { 20 public: 21 // The closing notification is sent immediately in response to (i.e. in the 22 // same call stack as) a request to close the Widget (via Close() or 23 // CloseNow()). 24 virtual void OnWidgetClosing(Widget* widget) {} 25 26 // Invoked after notification is received from the event loop that the native 27 // widget has been created. 28 virtual void OnWidgetCreated(Widget* widget) {} 29 30 // The destroying event occurs immediately before the widget is destroyed. 31 // This typically occurs asynchronously with respect the the close request, as 32 // a result of a later invocation from the event loop. 33 virtual void OnWidgetDestroying(Widget* widget) {} 34 35 // Invoked after notification is received from the event loop that the native 36 // widget has been destroyed. 37 virtual void OnWidgetDestroyed(Widget* widget) {} 38 39 virtual void OnWidgetVisibilityChanging(Widget* widget, bool visible) {} 40 41 virtual void OnWidgetVisibilityChanged(Widget* widget, bool visible) {} 42 43 virtual void OnWidgetActivationChanged(Widget* widget, bool active) {} 44 45 virtual void OnWidgetBoundsChanged(Widget* widget, 46 const gfx::Rect& new_bounds) {} 47 48 protected: 49 virtual ~WidgetObserver() {} 50 }; 51 52 } // namespace views 53 54 #endif // UI_VIEWS_WIDGET_WIDGET_OBSERVER_H_ 55