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

Side by Side Diff: chrome/browser/chromeos/login/message_bubble.cc

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 #include "chrome/browser/chromeos/login/message_bubble.h" 5 #include "chrome/browser/chromeos/login/message_bubble.h"
6 6
7 #include "base/logging.h" 7 #include "base/logging.h"
8 #include "chrome/browser/chromeos/login/helper.h" 8 #include "chrome/browser/chromeos/login/helper.h"
9 #include "grit/generated_resources.h" 9 #include "grit/generated_resources.h"
10 #include "grit/theme_resources.h" 10 #include "grit/theme_resources.h"
11 #include "ui/base/resource/resource_bundle.h" 11 #include "ui/base/resource/resource_bundle.h"
12 #include "views/controls/button/image_button.h" 12 #include "views/controls/button/image_button.h"
13 #include "views/controls/image_view.h" 13 #include "views/controls/image_view.h"
14 #include "views/controls/label.h" 14 #include "views/controls/label.h"
15 #include "views/layout/grid_layout.h" 15 #include "views/layout/grid_layout.h"
16 #include "views/widget/widget.h" 16 #include "views/widget/widget.h"
17 17
18 namespace chromeos { 18 namespace chromeos {
19 19
20 static const int kBorderSize = 4; 20 static const int kBorderSize = 4;
21 static const int kMaxLabelWidth = 250; 21 static const int kMaxLabelWidth = 250;
22 22
23 MessageBubble::MessageBubble(views::WidgetGtk::Type type, 23 MessageBubble::MessageBubble(views::Widget* parent,
24 views::Widget* parent,
25 SkBitmap* image, 24 SkBitmap* image,
26 const std::wstring& text, 25 const std::wstring& text,
27 const std::wstring& help, 26 const std::wstring& help,
28 bool grab_enabled, 27 bool grab_enabled,
29 MessageBubbleDelegate* delegate) 28 MessageBubbleDelegate* delegate)
30 : Bubble(type, false), // don't show while screen is locked 29 : Bubble(false), // don't show while screen is locked
31 parent_(parent), 30 parent_(parent),
32 help_link_(NULL), 31 help_link_(NULL),
33 message_delegate_(delegate), 32 message_delegate_(delegate),
34 grab_enabled_(grab_enabled) { 33 grab_enabled_(grab_enabled) {
35 using views::GridLayout; 34 using views::GridLayout;
36 35
37 views::View* control_view = new views::View(); 36 views::View* control_view = new views::View();
38 GridLayout* layout = new GridLayout(control_view); 37 GridLayout* layout = new GridLayout(control_view);
39 control_view->SetLayoutManager(layout); 38 control_view->SetLayoutManager(layout);
40 views::ColumnSet* column_set = layout->AddColumnSet(0); 39 views::ColumnSet* column_set = layout->AddColumnSet(0);
(...skipping 64 matching lines...) Expand 10 before | Expand all | Expand 10 after
105 104
106 // static 105 // static
107 MessageBubble* MessageBubble::Show(views::Widget* parent, 106 MessageBubble* MessageBubble::Show(views::Widget* parent,
108 const gfx::Rect& position_relative_to, 107 const gfx::Rect& position_relative_to,
109 BubbleBorder::ArrowLocation arrow_location, 108 BubbleBorder::ArrowLocation arrow_location,
110 SkBitmap* image, 109 SkBitmap* image,
111 const std::wstring& text, 110 const std::wstring& text,
112 const std::wstring& help, 111 const std::wstring& help,
113 MessageBubbleDelegate* delegate) { 112 MessageBubbleDelegate* delegate) {
114 // The bubble will be destroyed when it is closed. 113 // The bubble will be destroyed when it is closed.
115 MessageBubble* bubble = new MessageBubble( 114 MessageBubble* bubble = new MessageBubble(parent, image, text, help, true,
116 views::WidgetGtk::TYPE_WINDOW, parent, image, text, help, true, delegate); 115 delegate);
117 bubble->InitBubble(parent, position_relative_to, arrow_location, 116 bubble->InitBubble(parent, position_relative_to, arrow_location,
118 bubble->text_->parent(), delegate); 117 bubble->text_->parent(), delegate);
119 return bubble; 118 return bubble;
120 } 119 }
121 120
122 // static 121 // static
123 MessageBubble* MessageBubble::ShowNoGrab( 122 MessageBubble* MessageBubble::ShowNoGrab(
124 views::Widget* parent, 123 views::Widget* parent,
125 const gfx::Rect& position_relative_to, 124 const gfx::Rect& position_relative_to,
126 BubbleBorder::ArrowLocation arrow_location, 125 BubbleBorder::ArrowLocation arrow_location,
127 SkBitmap* image, 126 SkBitmap* image,
128 const std::wstring& text, 127 const std::wstring& text,
129 const std::wstring& help, 128 const std::wstring& help,
130 MessageBubbleDelegate* delegate) { 129 MessageBubbleDelegate* delegate) {
131 // The bubble will be destroyed when it is closed. 130 // The bubble will be destroyed when it is closed.
132 MessageBubble* bubble = new MessageBubble( 131 MessageBubble* bubble = new MessageBubble(parent, image, text, help, false,
133 views::WidgetGtk::TYPE_CHILD, parent, image, text, help, false, delegate); 132 delegate);
134 bubble->InitBubble(parent, position_relative_to, arrow_location, 133 bubble->InitBubble(parent, position_relative_to, arrow_location,
135 bubble->text_->parent(), delegate); 134 bubble->text_->parent(), delegate);
136 return bubble; 135 return bubble;
137 } 136 }
138 137
139 void MessageBubble::IsActiveChanged() { 138 void MessageBubble::IsActiveChanged() {
140 // Active parent instead. 139 // Active parent instead.
141 if (parent_ && IsActive()) { 140 if (parent_ && IsActive()) {
142 gtk_window_present_with_time( 141 gtk_window_present_with_time(
143 GTK_WINDOW(static_cast<WidgetGtk*>(parent_)->GetNativeView()), 142 GTK_WINDOW(static_cast<WidgetGtk*>(parent_)->GetNativeView()),
144 gtk_get_current_event_time()); 143 gtk_get_current_event_time());
145 } 144 }
146 } 145 }
147 146
148 void MessageBubble::SetMouseCapture() { 147 void MessageBubble::SetMouseCapture() {
149 if (grab_enabled_) 148 if (grab_enabled_)
150 WidgetGtk::SetMouseCapture(); 149 WidgetGtk::SetMouseCapture();
151 } 150 }
152 151
153 void MessageBubble::Close() { 152 void MessageBubble::Close() {
154 parent_ = NULL; 153 parent_ = NULL;
155 Bubble::Close(); 154 Bubble::Close();
156 } 155 }
157 156
158 } // namespace chromeos 157 } // namespace chromeos
OLDNEW

Powered by Google App Engine
This is Rietveld 408576698