| 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 VIEWS_WIDGET_WIDGET_H_ | 5 #ifndef VIEWS_WIDGET_WIDGET_H_ |
| 6 #define VIEWS_WIDGET_WIDGET_H_ | 6 #define VIEWS_WIDGET_WIDGET_H_ |
| 7 #pragma once | 7 #pragma once |
| 8 | 8 |
| 9 #include <vector> | 9 #include <vector> |
| 10 | 10 |
| 11 #include "base/memory/ref_counted.h" | 11 #include "base/memory/ref_counted.h" |
| 12 #include "base/memory/scoped_ptr.h" | 12 #include "base/memory/scoped_ptr.h" |
| 13 #include "ui/base/accessibility/accessibility_types.h" | 13 #include "ui/base/accessibility/accessibility_types.h" |
| 14 #include "ui/gfx/native_widget_types.h" | 14 #include "ui/gfx/native_widget_types.h" |
| 15 #include "ui/gfx/rect.h" |
| 15 #include "views/focus/focus_manager.h" | 16 #include "views/focus/focus_manager.h" |
| 16 #include "views/widget/native_widget_delegate.h" | 17 #include "views/widget/native_widget_delegate.h" |
| 17 | 18 |
| 18 namespace gfx { | 19 namespace gfx { |
| 19 class Canvas; | 20 class Canvas; |
| 20 class Path; | 21 class Path; |
| 21 class Point; | 22 class Point; |
| 22 class Rect; | 23 class Rect; |
| 23 } | 24 } |
| 24 | 25 |
| (...skipping 29 matching lines...) Expand all Loading... |
| 54 // TODO(beng): Note that this class being non-abstract means that we have a | 55 // TODO(beng): Note that this class being non-abstract means that we have a |
| 55 // violation of Google style in that we are using multiple | 56 // violation of Google style in that we are using multiple |
| 56 // inheritance. The intention is to split this into a separate | 57 // inheritance. The intention is to split this into a separate |
| 57 // object associated with but not equal to a NativeWidget | 58 // object associated with but not equal to a NativeWidget |
| 58 // implementation. Multiple inheritance is required for this | 59 // implementation. Multiple inheritance is required for this |
| 59 // transitional step. | 60 // transitional step. |
| 60 // | 61 // |
| 61 class Widget : public internal::NativeWidgetDelegate, | 62 class Widget : public internal::NativeWidgetDelegate, |
| 62 public FocusTraversable { | 63 public FocusTraversable { |
| 63 public: | 64 public: |
| 65 // TODO(beng): Rename to InitParams now this is required for Init(). |
| 64 struct CreateParams { | 66 struct CreateParams { |
| 65 enum Type { | 67 enum Type { |
| 66 TYPE_WINDOW, // A Window, like a frame window. | 68 TYPE_WINDOW, // A Window, like a frame window. |
| 67 TYPE_CONTROL, // A control, like a button. | 69 TYPE_CONTROL, // A control, like a button. |
| 68 TYPE_POPUP, // An undecorated Window, with transient properties. | 70 TYPE_POPUP, // An undecorated Window, with transient properties. |
| 69 TYPE_MENU // An undecorated Window, with transient properties | 71 TYPE_MENU // An undecorated Window, with transient properties |
| 70 // specialized to menus. | 72 // specialized to menus. |
| 71 }; | 73 }; |
| 72 | 74 |
| 73 CreateParams(); | 75 CreateParams(); |
| 74 explicit CreateParams(Type type); | 76 explicit CreateParams(Type type); |
| 75 | 77 |
| 76 Type type; | 78 Type type; |
| 77 | |
| 78 bool child; | 79 bool child; |
| 79 bool transparent; | 80 bool transparent; |
| 80 bool accept_events; | 81 bool accept_events; |
| 81 bool can_activate; | 82 bool can_activate; |
| 82 bool keep_on_top; | 83 bool keep_on_top; |
| 83 bool delete_on_destroy; | 84 bool delete_on_destroy; |
| 84 bool mirror_origin_in_rtl; | 85 bool mirror_origin_in_rtl; |
| 85 bool has_dropshadow; | 86 bool has_dropshadow; |
| 87 gfx::NativeView parent; |
| 88 Widget* parent_widget; |
| 89 gfx::Rect bounds; |
| 86 NativeWidget* native_widget; | 90 NativeWidget* native_widget; |
| 87 }; | 91 }; |
| 92 static CreateParams WindowCreateParams(); |
| 88 | 93 |
| 89 Widget(); | 94 Widget(); |
| 90 virtual ~Widget(); | 95 virtual ~Widget(); |
| 91 | 96 |
| 92 // Creates a Widget instance with the supplied params. | 97 // Creates a Widget instance with the supplied params. |
| 93 static Widget* CreateWidget(const CreateParams& params); | 98 static Widget* CreateWidget(); |
| 94 | 99 |
| 95 // Enumerates all windows pertaining to us and notifies their | 100 // Enumerates all windows pertaining to us and notifies their |
| 96 // view hierarchies that the locale has changed. | 101 // view hierarchies that the locale has changed. |
| 97 static void NotifyLocaleChanged(); | 102 static void NotifyLocaleChanged(); |
| 98 | 103 |
| 99 // Converts a rectangle from one Widget's coordinate system to another's. | 104 // Converts a rectangle from one Widget's coordinate system to another's. |
| 100 // Returns false if the conversion couldn't be made, because either these two | 105 // Returns false if the conversion couldn't be made, because either these two |
| 101 // Widgets do not have a common ancestor or they are not on the screen yet. | 106 // Widgets do not have a common ancestor or they are not on the screen yet. |
| 102 // The value of |*rect| won't be changed when false is returned. | 107 // The value of |*rect| won't be changed when false is returned. |
| 103 static bool ConvertRect(const Widget* source, | 108 static bool ConvertRect(const Widget* source, |
| 104 const Widget* target, | 109 const Widget* target, |
| 105 gfx::Rect* rect); | 110 gfx::Rect* rect); |
| 106 | 111 |
| 107 // Sets the creation params for the Widget. | 112 void Init(const CreateParams& params); |
| 108 void SetCreateParams(const CreateParams& params); | |
| 109 | 113 |
| 110 // Unconverted methods ------------------------------------------------------- | 114 // Unconverted methods ------------------------------------------------------- |
| 111 | 115 |
| 112 // TODO(beng): | 116 // TODO(beng): |
| 113 // Widget subclasses are still implementing these methods by overriding from | 117 // Widget subclasses are still implementing these methods by overriding from |
| 114 // here rather than by implementing NativeWidget. | 118 // here rather than by implementing NativeWidget. |
| 115 | 119 |
| 116 // Initialize the Widget with a parent and an initial desired size. | |
| 117 // |contents_view| is the view that will be the single child of RootView | |
| 118 // within this Widget. As contents_view is inserted into RootView's tree, | |
| 119 // RootView assumes ownership of this view and cleaning it up. If you remove | |
| 120 // this view, you are responsible for its destruction. If this value is NULL, | |
| 121 // the caller is responsible for populating the RootView, and sizing its | |
| 122 // contents as the window is sized. | |
| 123 virtual void Init(gfx::NativeView parent, const gfx::Rect& bounds); | |
| 124 virtual void InitWithWidget(Widget* parent, const gfx::Rect& bounds); | |
| 125 | |
| 126 // Returns the gfx::NativeView associated with this Widget. | 120 // Returns the gfx::NativeView associated with this Widget. |
| 127 virtual gfx::NativeView GetNativeView() const; | 121 virtual gfx::NativeView GetNativeView() const; |
| 128 | 122 |
| 129 // Starts a drag operation for the specified view. |point| is a position in | 123 // Starts a drag operation for the specified view. |point| is a position in |
| 130 // |view| coordinates that the drag was initiated from. | 124 // |view| coordinates that the drag was initiated from. |
| 131 virtual void GenerateMousePressedForView(View* view, | 125 virtual void GenerateMousePressedForView(View* view, |
| 132 const gfx::Point& point); | 126 const gfx::Point& point); |
| 133 | 127 |
| 134 // Returns the accelerator given a command id. Returns false if there is | 128 // Returns the accelerator given a command id. Returns false if there is |
| 135 // no accelerator associated with a given id, which is a common condition. | 129 // no accelerator associated with a given id, which is a common condition. |
| (...skipping 233 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 369 | 363 |
| 370 // The compositor for accelerated drawing. | 364 // The compositor for accelerated drawing. |
| 371 scoped_refptr<ui::Compositor> compositor_; | 365 scoped_refptr<ui::Compositor> compositor_; |
| 372 | 366 |
| 373 DISALLOW_COPY_AND_ASSIGN(Widget); | 367 DISALLOW_COPY_AND_ASSIGN(Widget); |
| 374 }; | 368 }; |
| 375 | 369 |
| 376 } // namespace views | 370 } // namespace views |
| 377 | 371 |
| 378 #endif // VIEWS_WIDGET_WIDGET_H_ | 372 #endif // VIEWS_WIDGET_WIDGET_H_ |
| OLD | NEW |