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

Side by Side Diff: chrome/browser/views/page_info_window.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/page_info_window.h" 5 #include "chrome/browser/views/page_info_window.h"
6 6
7 #include <cryptuiapi.h> 7 #include <cryptuiapi.h>
8 #pragma comment(lib, "cryptui.lib") 8 #pragma comment(lib, "cryptui.lib")
9 9
10 #include "base/string_util.h" 10 #include "base/string_util.h"
(...skipping 152 matching lines...) Expand 10 before | Expand all | Expand 10 after
163 } 163 }
164 164
165 SecurityTabView::Section::~Section() { 165 SecurityTabView::Section::~Section() {
166 } 166 }
167 167
168 int SecurityTabView::Section::GetHeightForWidth(int width) { 168 int SecurityTabView::Section::GetHeightForWidth(int width) {
169 // The height of the section depends on the height of the description label 169 // The height of the section depends on the height of the description label
170 // (multi-line). We need to know the width of the description label to know 170 // (multi-line). We need to know the width of the description label to know
171 // its height. 171 // its height.
172 int height = 0; 172 int height = 0;
173 CSize size; 173 gfx::Size size = title_label_->GetPreferredSize();
174 title_label_->GetPreferredSize(&size); 174 height += size.height() + kVGapTitleToImage;
175 height += size.cy + kVGapTitleToImage;
176 175
177 CSize image_size; 176 gfx::Size image_size = status_image_->GetPreferredSize();
178 status_image_->GetPreferredSize(&image_size);
179 177
180 int text_height = 0; 178 int text_height = 0;
181 if (!head_line_label_->GetText().empty()) { 179 if (!head_line_label_->GetText().empty()) {
182 head_line_label_->GetPreferredSize(&size); 180 size = head_line_label_->GetPreferredSize();
183 text_height = size.cy + kVGapHeadLineToDescription; 181 text_height = size.height() + kVGapHeadLineToDescription;
184 } 182 }
185 183
186 int description_width = width - image_size.cx - kHGapImageToDescription - 184 int description_width =
187 kHGapToBorder; 185 width - image_size.width() - kHGapImageToDescription - kHGapToBorder;
188 text_height += description_label_->GetHeightForWidth(description_width); 186 text_height += description_label_->GetHeightForWidth(description_width);
189 187
190 height += std::max(static_cast<int>(image_size.cy), text_height); 188 height += std::max(image_size.height(), text_height);
191 189
192 return height; 190 return height;
193 } 191 }
194 192
195 void SecurityTabView::Section::Layout() { 193 void SecurityTabView::Section::Layout() {
196 // First, layout the title and separator. 194 // First, layout the title and separator.
197 int x = 0; 195 int x = 0;
198 int y = 0; 196 int y = 0;
199 CSize size; 197 gfx::Size size = title_label_->GetPreferredSize();
200 title_label_->GetPreferredSize(&size); 198 title_label_->SetBounds(x, y, size.width(), size.height());
201 title_label_->SetBounds(x, y, size.cx, size.cy); 199 x += size.width() + kHGapTitleToSeparator;
202 x += size.cx + kHGapTitleToSeparator;
203 separator_->SetBounds(x + kHExtraSeparatorPadding, y, 200 separator_->SetBounds(x + kHExtraSeparatorPadding, y,
204 width() - x - 2 * kHExtraSeparatorPadding, size.cy); 201 width() - x - 2 * kHExtraSeparatorPadding,
202 size.height());
205 203
206 // Then the image, head-line and description. 204 // Then the image, head-line and description.
207 x = kHGapToBorder; 205 x = kHGapToBorder;
208 y += title_label_->height() + kVGapTitleToImage; 206 y += title_label_->height() + kVGapTitleToImage;
209 status_image_->GetPreferredSize(&size); 207 size = status_image_->GetPreferredSize();
210 status_image_->SetBounds(x, y, size.cx, size.cy); 208 status_image_->SetBounds(x, y, size.width(), size.height());
211 x += size.cx + kHGapImageToDescription; 209 x += size.width() + kHGapImageToDescription;
212 int w = width() - x; 210 int w = width() - x;
213 if (!head_line_label_->GetText().empty()) { 211 if (!head_line_label_->GetText().empty()) {
214 head_line_label_->GetPreferredSize(&size); 212 size = head_line_label_->GetPreferredSize();
215 head_line_label_->SetBounds(x, y, w > 0 ? w : 0, size.cy); 213 head_line_label_->SetBounds(x, y, w > 0 ? w : 0, size.height());
216 y += size.cy + kVGapHeadLineToDescription; 214 y += size.height() + kVGapHeadLineToDescription;
217 } else { 215 } else {
218 head_line_label_->SetBounds(x, y, 0, 0); 216 head_line_label_->SetBounds(x, y, 0, 0);
219 } 217 }
220 if (w > 0) { 218 if (w > 0) {
221 description_label_->SetBounds(x, y, w, 219 description_label_->SetBounds(x, y, w,
222 description_label_->GetHeightForWidth(w)); 220 description_label_->GetHeightForWidth(w));
223 } else { 221 } else {
224 description_label_->SetBounds(x, y, 0, 0); 222 description_label_->SetBounds(x, y, 0, 0);
225 } 223 }
226 } 224 }
(...skipping 216 matching lines...) Expand 10 before | Expand all | Expand 10 after
443 // ChromeViews::View overrides: 441 // ChromeViews::View overrides:
444 virtual void GetPreferredSize(CSize *out) { 442 virtual void GetPreferredSize(CSize *out) {
445 DCHECK(out); 443 DCHECK(out);
446 *out = ChromeViews::Window::GetLocalizedContentsSize( 444 *out = ChromeViews::Window::GetLocalizedContentsSize(
447 IDS_PAGEINFO_DIALOG_WIDTH_CHARS, 445 IDS_PAGEINFO_DIALOG_WIDTH_CHARS,
448 IDS_PAGEINFO_DIALOG_HEIGHT_LINES).ToSIZE(); 446 IDS_PAGEINFO_DIALOG_HEIGHT_LINES).ToSIZE();
449 } 447 }
450 448
451 virtual void Layout() { 449 virtual void Layout() {
452 if (cert_viewer_button_) { 450 if (cert_viewer_button_) {
453 CSize ps; 451 gfx::Size ps = cert_viewer_button_->GetPreferredSize();
454 cert_viewer_button_->GetPreferredSize(&ps);
455 452
456 CRect parent_bounds; 453 CRect parent_bounds;
457 GetParent()->GetLocalBounds(&parent_bounds, false); 454 GetParent()->GetLocalBounds(&parent_bounds, false);
458 int y_buttons = parent_bounds.bottom - ps.cy - kButtonVEdgeMargin; 455 int y_buttons = parent_bounds.bottom - ps.height() - kButtonVEdgeMargin;
459 cert_viewer_button_->SetBounds(kPanelHorizMargin, y_buttons, ps.cx, 456 cert_viewer_button_->SetBounds(kPanelHorizMargin, y_buttons, ps.width(),
460 ps.cy); 457 ps.height());
461 } 458 }
462 View::Layout(); 459 View::Layout();
463 } 460 }
464 461
465 private: 462 private:
466 ChromeViews::NativeButton* cert_viewer_button_; 463 ChromeViews::NativeButton* cert_viewer_button_;
467 464
468 DISALLOW_EVIL_CONSTRUCTORS(PageInfoContentView); 465 DISALLOW_EVIL_CONSTRUCTORS(PageInfoContentView);
469 }; 466 };
470 467
(...skipping 222 matching lines...) Expand 10 before | Expand all | Expand 10 after
693 HCERTSTORE cert_store = view_info.pCertContext->hCertStore; 690 HCERTSTORE cert_store = view_info.pCertContext->hCertStore;
694 view_info.cStores = 1; 691 view_info.cStores = 1;
695 view_info.rghStores = &cert_store; 692 view_info.rghStores = &cert_store;
696 BOOL properties_changed; 693 BOOL properties_changed;
697 694
698 // This next call blocks but keeps processing windows messages, making it 695 // This next call blocks but keeps processing windows messages, making it
699 // modal to the browser window. 696 // modal to the browser window.
700 BOOL rv = ::CryptUIDlgViewCertificate(&view_info, &properties_changed); 697 BOOL rv = ::CryptUIDlgViewCertificate(&view_info, &properties_changed);
701 } 698 }
702 699
OLDNEW

Powered by Google App Engine
This is Rietveld 408576698