OLD | NEW |
1 // Copyright (c) 2011 The Chromium Authors. All rights reserved. | 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 | 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 #pragma once | 7 #pragma once |
8 | 8 |
9 #include <set> | 9 #include <set> |
10 #include <stack> | 10 #include <stack> |
(...skipping 93 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
104 enum FrameType { | 104 enum FrameType { |
105 FRAME_TYPE_DEFAULT, // Use whatever the default would be. | 105 FRAME_TYPE_DEFAULT, // Use whatever the default would be. |
106 FRAME_TYPE_FORCE_CUSTOM, // Force the custom frame. | 106 FRAME_TYPE_FORCE_CUSTOM, // Force the custom frame. |
107 FRAME_TYPE_FORCE_NATIVE // Force the native frame. | 107 FRAME_TYPE_FORCE_NATIVE // Force the native frame. |
108 }; | 108 }; |
109 | 109 |
110 struct VIEWS_EXPORT InitParams { | 110 struct VIEWS_EXPORT InitParams { |
111 enum Type { | 111 enum Type { |
112 TYPE_WINDOW, // A decorated Window, like a frame window. | 112 TYPE_WINDOW, // A decorated Window, like a frame window. |
113 // Widgets of TYPE_WINDOW will have a NonClientView. | 113 // Widgets of TYPE_WINDOW will have a NonClientView. |
| 114 TYPE_PANEL, // Always on top window managed by PanelManager. |
| 115 // Widgets of TYPE_PANEL will have a NonClientView. |
114 TYPE_WINDOW_FRAMELESS, | 116 TYPE_WINDOW_FRAMELESS, |
115 // An undecorated Window. | 117 // An undecorated Window. |
116 TYPE_CONTROL, // A control, like a button. | 118 TYPE_CONTROL, // A control, like a button. |
117 TYPE_POPUP, // An undecorated Window, with transient properties. | 119 TYPE_POPUP, // An undecorated Window, with transient properties. |
118 TYPE_MENU, // An undecorated Window, with transient properties | 120 TYPE_MENU, // An undecorated Window, with transient properties |
119 // specialized to menus. | 121 // specialized to menus. |
120 TYPE_TOOLTIP, | 122 TYPE_TOOLTIP, |
121 TYPE_BUBBLE, | 123 TYPE_BUBBLE, |
122 }; | 124 }; |
123 enum Ownership { | 125 enum Ownership { |
(...skipping 80 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
204 static void SetPureViews(bool pure); | 206 static void SetPureViews(bool pure); |
205 static bool IsPureViews(); | 207 static bool IsPureViews(); |
206 | 208 |
207 // Retrieves the Widget implementation associated with the given | 209 // Retrieves the Widget implementation associated with the given |
208 // NativeView or Window, or NULL if the supplied handle has no associated | 210 // NativeView or Window, or NULL if the supplied handle has no associated |
209 // Widget. | 211 // Widget. |
210 static Widget* GetWidgetForNativeView(gfx::NativeView native_view); | 212 static Widget* GetWidgetForNativeView(gfx::NativeView native_view); |
211 static Widget* GetWidgetForNativeWindow(gfx::NativeWindow native_window); | 213 static Widget* GetWidgetForNativeWindow(gfx::NativeWindow native_window); |
212 | 214 |
213 // Retrieves the top level widget in a native view hierarchy | 215 // Retrieves the top level widget in a native view hierarchy |
214 // starting at |native_view|. Top level widget is a widget with | 216 // starting at |native_view|. Top level widget is a widget with TYPE_WINDOW, |
215 // TYPE_WINDOW, TYPE_WINDOW_FRAMELESS, POPUP or MENU and has its own | 217 // TYPE_PANEL, TYPE_WINDOW_FRAMELESS, POPUP or MENU and has its own |
216 // focus manager. This may be itself if the |native_view| is top level, | 218 // focus manager. This may be itself if the |native_view| is top level, |
217 // or NULL if there is no toplevel in a native view hierarchy. | 219 // or NULL if there is no toplevel in a native view hierarchy. |
218 static Widget* GetTopLevelWidgetForNativeView(gfx::NativeView native_view); | 220 static Widget* GetTopLevelWidgetForNativeView(gfx::NativeView native_view); |
219 | 221 |
220 // Returns all Widgets in |native_view|'s hierarchy, including itself if | 222 // Returns all Widgets in |native_view|'s hierarchy, including itself if |
221 // it is one. | 223 // it is one. |
222 static void GetAllChildWidgets(gfx::NativeView native_view, | 224 static void GetAllChildWidgets(gfx::NativeView native_view, |
223 Widgets* children); | 225 Widgets* children); |
224 | 226 |
225 // Re-parent a NativeView and notify all Widgets in |native_view|'s hierarchy | 227 // Re-parent a NativeView and notify all Widgets in |native_view|'s hierarchy |
(...skipping 18 matching lines...) Expand all Loading... |
244 // Returns true if the specified type requires a NonClientView. | 246 // Returns true if the specified type requires a NonClientView. |
245 static bool RequiresNonClientView(InitParams::Type type); | 247 static bool RequiresNonClientView(InitParams::Type type); |
246 | 248 |
247 void Init(const InitParams& params); | 249 void Init(const InitParams& params); |
248 | 250 |
249 // Returns the gfx::NativeView associated with this Widget. | 251 // Returns the gfx::NativeView associated with this Widget. |
250 gfx::NativeView GetNativeView() const; | 252 gfx::NativeView GetNativeView() const; |
251 | 253 |
252 // Returns the gfx::NativeWindow associated with this Widget. This may return | 254 // Returns the gfx::NativeWindow associated with this Widget. This may return |
253 // NULL on some platforms if the widget was created with a type other than | 255 // NULL on some platforms if the widget was created with a type other than |
254 // TYPE_WINDOW. | 256 // TYPE_WINDOW or TYPE_PANEL. |
255 gfx::NativeWindow GetNativeWindow() const; | 257 gfx::NativeWindow GetNativeWindow() const; |
256 | 258 |
257 // Add/remove observer. | 259 // Add/remove observer. |
258 void AddObserver(Observer* observer); | 260 void AddObserver(Observer* observer); |
259 void RemoveObserver(Observer* observer); | 261 void RemoveObserver(Observer* observer); |
260 bool HasObserver(Observer* observer); | 262 bool HasObserver(Observer* observer); |
261 | 263 |
262 // Returns the accelerator given a command id. Returns false if there is | 264 // Returns the accelerator given a command id. Returns false if there is |
263 // no accelerator associated with a given id, which is a common condition. | 265 // no accelerator associated with a given id, which is a common condition. |
264 virtual bool GetAccelerator(int cmd_id, ui::Accelerator* accelerator); | 266 virtual bool GetAccelerator(int cmd_id, ui::Accelerator* accelerator); |
(...skipping 284 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
549 void set_focus_on_creation(bool focus_on_creation) { | 551 void set_focus_on_creation(bool focus_on_creation) { |
550 focus_on_creation_ = focus_on_creation; | 552 focus_on_creation_ = focus_on_creation; |
551 } | 553 } |
552 | 554 |
553 // Returns a View* that any child Widgets backed by NativeWidgetViews | 555 // Returns a View* that any child Widgets backed by NativeWidgetViews |
554 // are added to. The default implementation returns the contents view | 556 // are added to. The default implementation returns the contents view |
555 // if it exists and the root view otherwise. | 557 // if it exists and the root view otherwise. |
556 virtual View* GetChildViewParent(); | 558 virtual View* GetChildViewParent(); |
557 | 559 |
558 // True if the widget is considered top level widget. Top level widget | 560 // True if the widget is considered top level widget. Top level widget |
559 // is a widget of TYPE_WINDOW, TYPE_WINDOW_FRAMELESS, BUBBLE, POPUP or MENU, | 561 // is a widget of TYPE_WINDOW, TYPE_PANEL, TYPE_WINDOW_FRAMELESS, BUBBLE, |
560 // and has a focus manager and input method object associated with it. | 562 // POPUP or MENU, and has a focus manager and input method object associated |
561 // TYPE_CONTROL and TYPE_TOOLTIP is not considered top level. | 563 // with it. TYPE_CONTROL and TYPE_TOOLTIP is not considered top level. |
562 bool is_top_level() const { return is_top_level_; } | 564 bool is_top_level() const { return is_top_level_; } |
563 | 565 |
564 // Returns the bounds of work area in the screen that Widget belongs to. | 566 // Returns the bounds of work area in the screen that Widget belongs to. |
565 gfx::Rect GetWorkAreaBoundsInScreen() const; | 567 gfx::Rect GetWorkAreaBoundsInScreen() const; |
566 | 568 |
567 // Overridden from NativeWidgetDelegate: | 569 // Overridden from NativeWidgetDelegate: |
568 virtual bool IsModal() const OVERRIDE; | 570 virtual bool IsModal() const OVERRIDE; |
569 virtual bool IsDialogBox() const OVERRIDE; | 571 virtual bool IsDialogBox() const OVERRIDE; |
570 virtual bool CanActivate() const OVERRIDE; | 572 virtual bool CanActivate() const OVERRIDE; |
571 virtual bool IsInactiveRenderingDisabled() const OVERRIDE; | 573 virtual bool IsInactiveRenderingDisabled() const OVERRIDE; |
(...skipping 154 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
726 // duplicate move events even though the mouse hasn't moved. | 728 // duplicate move events even though the mouse hasn't moved. |
727 bool last_mouse_event_was_move_; | 729 bool last_mouse_event_was_move_; |
728 gfx::Point last_mouse_event_position_; | 730 gfx::Point last_mouse_event_position_; |
729 | 731 |
730 DISALLOW_COPY_AND_ASSIGN(Widget); | 732 DISALLOW_COPY_AND_ASSIGN(Widget); |
731 }; | 733 }; |
732 | 734 |
733 } // namespace views | 735 } // namespace views |
734 | 736 |
735 #endif // UI_VIEWS_WIDGET_WIDGET_H_ | 737 #endif // UI_VIEWS_WIDGET_WIDGET_H_ |
OLD | NEW |