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

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

Issue 6881107: Rework the way Widget::Init works: (Closed) Base URL: svn://svn.chromium.org/chrome/trunk/src/
Patch Set: '' Created 9 years, 8 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
OLDNEW
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
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:
64 struct CreateParams { 65 struct CreateParams {
sky 2011/04/25 23:49:32 Consider renaming this to InitParams.
65 enum Type { 66 enum Type {
66 TYPE_WINDOW, // A Window, like a frame window. 67 TYPE_WINDOW, // A Window, like a frame window.
67 TYPE_CONTROL, // A control, like a button. 68 TYPE_CONTROL, // A control, like a button.
68 TYPE_POPUP, // An undecorated Window, with transient properties. 69 TYPE_POPUP, // An undecorated Window, with transient properties.
69 TYPE_MENU // An undecorated Window, with transient properties 70 TYPE_MENU // An undecorated Window, with transient properties
70 // specialized to menus. 71 // specialized to menus.
71 }; 72 };
72 73
73 CreateParams(); 74 CreateParams();
74 explicit CreateParams(Type type); 75 explicit CreateParams(Type type);
75 76
76 Type type; 77 Type type;
77
78 bool child; 78 bool child;
79 bool transparent; 79 bool transparent;
80 bool accept_events; 80 bool accept_events;
81 bool can_activate; 81 bool can_activate;
82 bool keep_on_top; 82 bool keep_on_top;
83 bool delete_on_destroy; 83 bool delete_on_destroy;
84 bool mirror_origin_in_rtl; 84 bool mirror_origin_in_rtl;
85 bool has_dropshadow; 85 bool has_dropshadow;
86 gfx::NativeView parent;
87 Widget* parent_widget;
88 gfx::Rect bounds;
86 NativeWidget* native_widget; 89 NativeWidget* native_widget;
87 }; 90 };
91 static CreateParams WindowCreateParams();
88 92
89 Widget(); 93 Widget();
90 virtual ~Widget(); 94 virtual ~Widget();
91 95
92 // Creates a Widget instance with the supplied params. 96 // Creates a Widget instance with the supplied params.
93 static Widget* CreateWidget(const CreateParams& params); 97 static Widget* CreateWidget();
94 98
95 // Enumerates all windows pertaining to us and notifies their 99 // Enumerates all windows pertaining to us and notifies their
96 // view hierarchies that the locale has changed. 100 // view hierarchies that the locale has changed.
97 static void NotifyLocaleChanged(); 101 static void NotifyLocaleChanged();
98 102
99 // Converts a rectangle from one Widget's coordinate system to another's. 103 // 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 104 // 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. 105 // 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. 106 // The value of |*rect| won't be changed when false is returned.
103 static bool ConvertRect(const Widget* source, 107 static bool ConvertRect(const Widget* source,
104 const Widget* target, 108 const Widget* target,
105 gfx::Rect* rect); 109 gfx::Rect* rect);
106 110
107 // Sets the creation params for the Widget. 111 void Init(const CreateParams& params);
108 void SetCreateParams(const CreateParams& params);
109 112
110 // Unconverted methods ------------------------------------------------------- 113 // Unconverted methods -------------------------------------------------------
111 114
112 // TODO(beng): 115 // TODO(beng):
113 // Widget subclasses are still implementing these methods by overriding from 116 // Widget subclasses are still implementing these methods by overriding from
114 // here rather than by implementing NativeWidget. 117 // here rather than by implementing NativeWidget.
115 118
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. 119 // Returns the gfx::NativeView associated with this Widget.
127 virtual gfx::NativeView GetNativeView() const; 120 virtual gfx::NativeView GetNativeView() const;
128 121
129 // Starts a drag operation for the specified view. |point| is a position in 122 // Starts a drag operation for the specified view. |point| is a position in
130 // |view| coordinates that the drag was initiated from. 123 // |view| coordinates that the drag was initiated from.
131 virtual void GenerateMousePressedForView(View* view, 124 virtual void GenerateMousePressedForView(View* view,
132 const gfx::Point& point); 125 const gfx::Point& point);
133 126
134 // Returns the accelerator given a command id. Returns false if there is 127 // 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. 128 // no accelerator associated with a given id, which is a common condition.
(...skipping 232 matching lines...) Expand 10 before | Expand all | Expand 10 after
368 361
369 // The compositor for accelerated drawing. 362 // The compositor for accelerated drawing.
370 scoped_refptr<ui::Compositor> compositor_; 363 scoped_refptr<ui::Compositor> compositor_;
371 364
372 DISALLOW_COPY_AND_ASSIGN(Widget); 365 DISALLOW_COPY_AND_ASSIGN(Widget);
373 }; 366 };
374 367
375 } // namespace views 368 } // namespace views
376 369
377 #endif // VIEWS_WIDGET_WIDGET_H_ 370 #endif // VIEWS_WIDGET_WIDGET_H_
OLDNEW

Powered by Google App Engine
This is Rietveld 408576698