Chromium Code Reviews
chromiumcodereview-hr@appspot.gserviceaccount.com (chromiumcodereview-hr) | Please choose your nickname with Settings | Help | Chromium Project | Gerrit Changes | Sign out
(334)

Side by Side Diff: ui/views/widget/widget.h

Issue 10834079: views: Extract Widget observer into its own header file. (Closed) Base URL: svn://svn.chromium.org/chrome/trunk/src
Patch Set: Created 8 years, 4 months ago
Use n/p to move between diff chunks; N/P to move between comments. Draft comments are only viewable by you.
Jump to:
View unified diff | Download patch | Annotate | Revision Log
« no previous file with comments | « ui/views/views.gyp ('k') | ui/views/widget/widget.cc » ('j') | no next file with comments »
Toggle Intra-line Diffs ('i') | Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
OLDNEW
1 // Copyright (c) 2012 The Chromium Authors. All rights reserved. 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 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 UI_VIEWS_WIDGET_WIDGET_H_ 5 #ifndef UI_VIEWS_WIDGET_WIDGET_H_
6 #define UI_VIEWS_WIDGET_WIDGET_H_ 6 #define UI_VIEWS_WIDGET_WIDGET_H_
7 7
8 #include <set> 8 #include <set>
9 #include <stack> 9 #include <stack>
10 #include <vector> 10 #include <vector>
(...skipping 31 matching lines...) Expand 10 before | Expand all | Expand 10 after
42 } 42 }
43 43
44 namespace ui { 44 namespace ui {
45 class Accelerator; 45 class Accelerator;
46 class Compositor; 46 class Compositor;
47 class Layer; 47 class Layer;
48 class OSExchangeData; 48 class OSExchangeData;
49 class ThemeProvider; 49 class ThemeProvider;
50 enum TouchStatus; 50 enum TouchStatus;
51 } 51 }
52 using ui::ThemeProvider;
53 52
54 namespace views { 53 namespace views {
55 54
56 class DefaultThemeProvider; 55 class DefaultThemeProvider;
57 class InputMethod; 56 class InputMethod;
58 class NativeWidget; 57 class NativeWidget;
59 class NonClientFrameView; 58 class NonClientFrameView;
60 class ScopedEvent; 59 class ScopedEvent;
61 class View; 60 class View;
62 class WidgetDelegate; 61 class WidgetDelegate;
62 class WidgetObserver;
63
63 namespace internal { 64 namespace internal {
64 class NativeWidgetPrivate; 65 class NativeWidgetPrivate;
65 class RootView; 66 class RootView;
66 } 67 }
67 68
68 //////////////////////////////////////////////////////////////////////////////// 69 ////////////////////////////////////////////////////////////////////////////////
69 // Widget class 70 // Widget class
70 // 71 //
71 // Encapsulates the platform-specific rendering, event receiving and widget 72 // Encapsulates the platform-specific rendering, event receiving and widget
72 // management aspects of the UI framework. 73 // management aspects of the UI framework.
(...skipping 13 matching lines...) Expand all
86 // the Widget from its destructor. 87 // the Widget from its destructor.
87 // ownership = WIDGET_OWNS_NATIVE_WIDGET (non-default) 88 // ownership = WIDGET_OWNS_NATIVE_WIDGET (non-default)
88 // The Widget instance owns its NativeWidget. This state implies someone 89 // The Widget instance owns its NativeWidget. This state implies someone
89 // else wants to control the lifetime of this object. When they destroy 90 // else wants to control the lifetime of this object. When they destroy
90 // the Widget it is responsible for destroying the NativeWidget (from its 91 // the Widget it is responsible for destroying the NativeWidget (from its
91 // destructor). 92 // destructor).
92 // 93 //
93 class VIEWS_EXPORT Widget : public internal::NativeWidgetDelegate, 94 class VIEWS_EXPORT Widget : public internal::NativeWidgetDelegate,
94 public FocusTraversable { 95 public FocusTraversable {
95 public: 96 public:
96 // Observers can listen to various events on the Widgets.
97 class VIEWS_EXPORT Observer {
98 public:
99 virtual void OnWidgetClosing(Widget* widget) {}
100 virtual void OnWidgetVisibilityChanged(Widget* widget, bool visible) {}
101 virtual void OnWidgetActivationChanged(Widget* widget, bool active) {}
102 virtual void OnWidgetMoved(Widget* widget) {}
103 protected:
104 virtual ~Observer() {}
105 };
106
107 typedef std::set<Widget*> Widgets; 97 typedef std::set<Widget*> Widgets;
108 98
109 enum FrameType { 99 enum FrameType {
110 FRAME_TYPE_DEFAULT, // Use whatever the default would be. 100 FRAME_TYPE_DEFAULT, // Use whatever the default would be.
111 FRAME_TYPE_FORCE_CUSTOM, // Force the custom frame. 101 FRAME_TYPE_FORCE_CUSTOM, // Force the custom frame.
112 FRAME_TYPE_FORCE_NATIVE // Force the native frame. 102 FRAME_TYPE_FORCE_NATIVE // Force the native frame.
113 }; 103 };
114 104
115 // Result from RunMoveLoop(). 105 // Result from RunMoveLoop().
116 enum MoveLoopResult { 106 enum MoveLoopResult {
(...skipping 147 matching lines...) Expand 10 before | Expand all | Expand 10 after
264 254
265 // Returns the gfx::NativeView associated with this Widget. 255 // Returns the gfx::NativeView associated with this Widget.
266 gfx::NativeView GetNativeView() const; 256 gfx::NativeView GetNativeView() const;
267 257
268 // Returns the gfx::NativeWindow associated with this Widget. This may return 258 // Returns the gfx::NativeWindow associated with this Widget. This may return
269 // NULL on some platforms if the widget was created with a type other than 259 // NULL on some platforms if the widget was created with a type other than
270 // TYPE_WINDOW or TYPE_PANEL. 260 // TYPE_WINDOW or TYPE_PANEL.
271 gfx::NativeWindow GetNativeWindow() const; 261 gfx::NativeWindow GetNativeWindow() const;
272 262
273 // Add/remove observer. 263 // Add/remove observer.
274 void AddObserver(Observer* observer); 264 void AddObserver(WidgetObserver* observer);
275 void RemoveObserver(Observer* observer); 265 void RemoveObserver(WidgetObserver* observer);
276 bool HasObserver(Observer* observer); 266 bool HasObserver(WidgetObserver* observer);
277 267
278 // Returns the accelerator given a command id. Returns false if there is 268 // Returns the accelerator given a command id. Returns false if there is
279 // no accelerator associated with a given id, which is a common condition. 269 // no accelerator associated with a given id, which is a common condition.
280 virtual bool GetAccelerator(int cmd_id, ui::Accelerator* accelerator); 270 virtual bool GetAccelerator(int cmd_id, ui::Accelerator* accelerator);
281 271
282 // Forwarded from the RootView so that the widget can do any cleanup. 272 // Forwarded from the RootView so that the widget can do any cleanup.
283 void ViewHierarchyChanged(bool is_add, View* parent, View* child); 273 void ViewHierarchyChanged(bool is_add, View* parent, View* child);
284 274
285 // Performs any necessary cleanup and forwards to RootView. 275 // Performs any necessary cleanup and forwards to RootView.
286 void NotifyNativeViewHierarchyChanged(bool attached, 276 void NotifyNativeViewHierarchyChanged(bool attached,
(...skipping 135 matching lines...) Expand 10 before | Expand all | Expand 10 after
422 } 412 }
423 bool is_secondary_widget() const { return is_secondary_widget_; } 413 bool is_secondary_widget() const { return is_secondary_widget_; }
424 414
425 // Returns whether the Widget is visible to the user. 415 // Returns whether the Widget is visible to the user.
426 virtual bool IsVisible() const; 416 virtual bool IsVisible() const;
427 417
428 // Returns whether the Widget is customized for accessibility. 418 // Returns whether the Widget is customized for accessibility.
429 bool IsAccessibleWidget() const; 419 bool IsAccessibleWidget() const;
430 420
431 // Returns the ThemeProvider that provides theme resources for this Widget. 421 // Returns the ThemeProvider that provides theme resources for this Widget.
432 virtual ThemeProvider* GetThemeProvider() const; 422 virtual ui::ThemeProvider* GetThemeProvider() const;
433 423
434 // Returns the FocusManager for this widget. 424 // Returns the FocusManager for this widget.
435 // Note that all widgets in a widget hierarchy share the same focus manager. 425 // Note that all widgets in a widget hierarchy share the same focus manager.
436 FocusManager* GetFocusManager(); 426 FocusManager* GetFocusManager();
437 const FocusManager* GetFocusManager() const; 427 const FocusManager* GetFocusManager() const;
438 428
439 // Returns the InputMethod for this widget. 429 // Returns the InputMethod for this widget.
440 // Note that all widgets in a widget hierarchy share the same input method. 430 // Note that all widgets in a widget hierarchy share the same input method.
441 InputMethod* GetInputMethod(); 431 InputMethod* GetInputMethod();
442 432
(...skipping 127 matching lines...) Expand 10 before | Expand all | Expand 10 after
570 560
571 internal::NativeWidgetPrivate* native_widget_private() { 561 internal::NativeWidgetPrivate* native_widget_private() {
572 return native_widget_; 562 return native_widget_;
573 } 563 }
574 const internal::NativeWidgetPrivate* native_widget_private() const { 564 const internal::NativeWidgetPrivate* native_widget_private() const {
575 return native_widget_; 565 return native_widget_;
576 } 566 }
577 567
578 // Sets capture to the specified view. This makes it so that all mouse, touch 568 // Sets capture to the specified view. This makes it so that all mouse, touch
579 // and gesture events go to |view|. 569 // and gesture events go to |view|.
580 void SetCapture(views::View* view); 570 void SetCapture(View* view);
581 571
582 // Releases capture. 572 // Releases capture.
583 void ReleaseCapture(); 573 void ReleaseCapture();
584 574
585 // Returns true if the widget has capture. 575 // Returns true if the widget has capture.
586 bool HasCapture(); 576 bool HasCapture();
587 577
588 // Returns the current event being processed. If there are multiple events 578 // Returns the current event being processed. If there are multiple events
589 // being processed at the same time (e.g. one event triggers another event), 579 // being processed at the same time (e.g. one event triggers another event),
590 // then the most recent event is returned. Returns NULL if no event is being 580 // then the most recent event is returned. Returns NULL if no event is being
(...skipping 113 matching lines...) Expand 10 before | Expand all | Expand 10 after
704 bool GetSavedWindowPlacement(gfx::Rect* bounds, 694 bool GetSavedWindowPlacement(gfx::Rect* bounds,
705 ui::WindowShowState* show_state); 695 ui::WindowShowState* show_state);
706 696
707 // Sets a different InputMethod instance to this widget. The instance 697 // Sets a different InputMethod instance to this widget. The instance
708 // must not be initialized, the ownership will be assumed by the widget. 698 // must not be initialized, the ownership will be assumed by the widget.
709 // It's only for testing purpose. 699 // It's only for testing purpose.
710 void ReplaceInputMethod(InputMethod* input_method); 700 void ReplaceInputMethod(InputMethod* input_method);
711 701
712 internal::NativeWidgetPrivate* native_widget_; 702 internal::NativeWidgetPrivate* native_widget_;
713 703
714 ObserverList<Observer> observers_; 704 ObserverList<WidgetObserver> observers_;
715 705
716 // Non-owned pointer to the Widget's delegate. May be NULL if no delegate is 706 // Non-owned pointer to the Widget's delegate. May be NULL if no delegate is
717 // being used. 707 // being used.
718 WidgetDelegate* widget_delegate_; 708 WidgetDelegate* widget_delegate_;
719 709
720 // The root of the View hierarchy attached to this window. 710 // The root of the View hierarchy attached to this window.
721 // WARNING: see warning in tooltip_manager_ for ordering dependencies with 711 // WARNING: see warning in tooltip_manager_ for ordering dependencies with
722 // this and tooltip_manager_. 712 // this and tooltip_manager_.
723 scoped_ptr<internal::RootView> root_view_; 713 scoped_ptr<internal::RootView> root_view_;
724 714
(...skipping 79 matching lines...) Expand 10 before | Expand all | Expand 10 after
804 794
805 // Is |root_layers_| out of date? 795 // Is |root_layers_| out of date?
806 bool root_layers_dirty_; 796 bool root_layers_dirty_;
807 797
808 DISALLOW_COPY_AND_ASSIGN(Widget); 798 DISALLOW_COPY_AND_ASSIGN(Widget);
809 }; 799 };
810 800
811 } // namespace views 801 } // namespace views
812 802
813 #endif // UI_VIEWS_WIDGET_WIDGET_H_ 803 #endif // UI_VIEWS_WIDGET_WIDGET_H_
OLDNEW
« no previous file with comments | « ui/views/views.gyp ('k') | ui/views/widget/widget.cc » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698