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

Side by Side Diff: chrome/browser/views/first_run_view.cc

Issue 7344: Convert GetPreferredSize from:... (Closed) Base URL: svn://chrome-svn/chrome/trunk/src/
Patch Set: Created 12 years, 2 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) 2006-2008 The Chromium Authors. All rights reserved. 1 // Copyright (c) 2006-2008 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/views/first_run_view.h" 5 #include "chrome/browser/views/first_run_view.h"
6 6
7 #include "chrome/app/locales/locale_settings.h" 7 #include "chrome/app/locales/locale_settings.h"
8 #include "chrome/app/theme/theme_resources.h" 8 #include "chrome/app/theme/theme_resources.h"
9 #include "chrome/browser/importer/importer.h" 9 #include "chrome/browser/importer/importer.h"
10 #include "chrome/browser/first_run.h" 10 #include "chrome/browser/first_run.h"
(...skipping 76 matching lines...) Expand 10 before | Expand all | Expand 10 after
87 actions_shorcuts_ = new Label(AddBullet(label2)); 87 actions_shorcuts_ = new Label(AddBullet(label2));
88 actions_shorcuts_->SetHorizontalAlignment(Label::ALIGN_LEFT); 88 actions_shorcuts_->SetHorizontalAlignment(Label::ALIGN_LEFT);
89 actions_shorcuts_->SetMultiLine(true); 89 actions_shorcuts_->SetMultiLine(true);
90 AddChildView(actions_shorcuts_); 90 AddChildView(actions_shorcuts_);
91 91
92 customize_link_ = new Link(l10n_util::GetString(IDS_FIRSTRUN_DLG_OVERRIDE)); 92 customize_link_ = new Link(l10n_util::GetString(IDS_FIRSTRUN_DLG_OVERRIDE));
93 customize_link_->SetController(this); 93 customize_link_->SetController(this);
94 AddChildView(customize_link_); 94 AddChildView(customize_link_);
95 } 95 }
96 96
97 void FirstRunView::GetPreferredSize(CSize *out) { 97 gfx::Size FirstRunView::GetPreferredSize() {
98 DCHECK(out); 98 return gfx::Size(ChromeViews::Window::GetLocalizedContentsSize(
99 *out = ChromeViews::Window::GetLocalizedContentsSize(
100 IDS_FIRSTRUN_DIALOG_WIDTH_CHARS, 99 IDS_FIRSTRUN_DIALOG_WIDTH_CHARS,
101 IDS_FIRSTRUN_DIALOG_HEIGHT_LINES).ToSIZE(); 100 IDS_FIRSTRUN_DIALOG_HEIGHT_LINES));
102 } 101 }
103 102
104 void FirstRunView::Layout() { 103 void FirstRunView::Layout() {
105 FirstRunViewBase::Layout(); 104 FirstRunViewBase::Layout();
106 105
107 const int kVertSpacing = 8; 106 const int kVertSpacing = 8;
108 ResourceBundle& rb = ResourceBundle::GetSharedInstance(); 107 ResourceBundle& rb = ResourceBundle::GetSharedInstance();
109 108
110 CSize pref_size; 109 gfx::Size pref_size = welcome_label_->GetPreferredSize();
111 welcome_label_->GetPreferredSize(&pref_size);
112 // Wrap the label text before we overlap the product icon. 110 // Wrap the label text before we overlap the product icon.
113 int label_width = background_image()->width() - 111 int label_width = background_image()->width() -
114 rb.GetBitmapNamed(IDR_WIZARD_ICON)->width() - kPanelHorizMargin; 112 rb.GetBitmapNamed(IDR_WIZARD_ICON)->width() - kPanelHorizMargin;
115 welcome_label_->SetBounds(kPanelHorizMargin, kPanelVertMargin, 113 welcome_label_->SetBounds(kPanelHorizMargin, kPanelVertMargin,
116 label_width, pref_size.cy); 114 label_width, pref_size.height());
117 AdjustDialogWidth(welcome_label_); 115 AdjustDialogWidth(welcome_label_);
118 116
119 int next_v_space = background_image()->y() + 117 int next_v_space = background_image()->y() +
120 background_image()->height() + kPanelVertMargin; 118 background_image()->height() + kPanelVertMargin;
121 119
122 actions_label_->GetPreferredSize(&pref_size); 120 pref_size = actions_label_->GetPreferredSize();
123 actions_label_->SetBounds(kPanelHorizMargin, next_v_space, 121 actions_label_->SetBounds(kPanelHorizMargin, next_v_space,
124 pref_size.cx, pref_size.cy); 122 pref_size.width(), pref_size.height());
125 AdjustDialogWidth(actions_label_); 123 AdjustDialogWidth(actions_label_);
126 124
127 next_v_space = actions_label_->y() + 125 next_v_space = actions_label_->y() +
128 actions_label_->height() + kVertSpacing; 126 actions_label_->height() + kVertSpacing;
129 127
130 label_width = width() - (2 * kPanelHorizMargin); 128 label_width = width() - (2 * kPanelHorizMargin);
131 int label_height = actions_import_->GetHeightForWidth(label_width); 129 int label_height = actions_import_->GetHeightForWidth(label_width);
132 actions_import_->SetBounds(kPanelHorizMargin, next_v_space, label_width, 130 actions_import_->SetBounds(kPanelHorizMargin, next_v_space, label_width,
133 label_height); 131 label_height);
134 132
135 next_v_space = actions_import_->y() + 133 next_v_space = actions_import_->y() +
136 actions_import_->height() + kVertSpacing; 134 actions_import_->height() + kVertSpacing;
137 AdjustDialogWidth(actions_import_); 135 AdjustDialogWidth(actions_import_);
138 136
139 label_height = actions_shorcuts_->GetHeightForWidth(label_width); 137 label_height = actions_shorcuts_->GetHeightForWidth(label_width);
140 actions_shorcuts_->SetBounds(kPanelHorizMargin, next_v_space, label_width, 138 actions_shorcuts_->SetBounds(kPanelHorizMargin, next_v_space, label_width,
141 label_height); 139 label_height);
142 AdjustDialogWidth(actions_shorcuts_); 140 AdjustDialogWidth(actions_shorcuts_);
143 141
144 next_v_space = actions_shorcuts_->y() + 142 next_v_space = actions_shorcuts_->y() +
145 actions_shorcuts_->height() + 143 actions_shorcuts_->height() +
146 kUnrelatedControlVerticalSpacing; 144 kUnrelatedControlVerticalSpacing;
147 145
148 customize_link_->GetPreferredSize(&pref_size); 146 pref_size = customize_link_->GetPreferredSize();
149 customize_link_->SetBounds(kPanelHorizMargin, next_v_space, 147 customize_link_->SetBounds(kPanelHorizMargin, next_v_space,
150 pref_size.cx, pref_size.cy); 148 pref_size.width(), pref_size.height());
151 } 149 }
152 150
153 void FirstRunView::OpenCustomizeDialog() { 151 void FirstRunView::OpenCustomizeDialog() {
154 // The customize dialog now owns the importer host object. 152 // The customize dialog now owns the importer host object.
155 ChromeViews::Window::CreateChromeWindow( 153 ChromeViews::Window::CreateChromeWindow(
156 window()->GetHWND(), 154 window()->GetHWND(),
157 gfx::Rect(), 155 gfx::Rect(),
158 new FirstRunCustomizeView(profile_, 156 new FirstRunCustomizeView(profile_,
159 importer_host_, 157 importer_host_,
160 this, 158 this,
(...skipping 39 matching lines...) Expand 10 before | Expand all | Expand 10 after
200 // the work is done there we got nothing else to do. 198 // the work is done there we got nothing else to do.
201 void FirstRunView::CustomizeAccepted() { 199 void FirstRunView::CustomizeAccepted() {
202 window()->Close(); 200 window()->Close();
203 } 201 }
204 202
205 // Notification from the customize dialog that the user cancelled. 203 // Notification from the customize dialog that the user cancelled.
206 void FirstRunView::CustomizeCanceled() { 204 void FirstRunView::CustomizeCanceled() {
207 UserMetrics::RecordAction(L"FirstRunCustom_Cancel", profile_); 205 UserMetrics::RecordAction(L"FirstRunCustom_Cancel", profile_);
208 } 206 }
209 207
OLDNEW

Powered by Google App Engine
This is Rietveld 408576698