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

Side by Side Diff: chrome/browser/views/old_frames/simple_xp_frame.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/old_frames/simple_xp_frame.h" 5 #include "chrome/browser/views/old_frames/simple_xp_frame.h"
6 6
7 #include "chrome/app/theme/theme_resources.h" 7 #include "chrome/app/theme/theme_resources.h"
8 #include "base/string_util.h" 8 #include "base/string_util.h"
9 #include "chrome/browser/browser.h" 9 #include "chrome/browser/browser.h"
10 #include "chrome/browser/profile.h" 10 #include "chrome/browser/profile.h"
(...skipping 61 matching lines...) Expand 10 before | Expand all | Expand 10 after
72 drop_arrow_ = rb.GetBitmapNamed(IDR_APP_DROPARROW); 72 drop_arrow_ = rb.GetBitmapNamed(IDR_APP_DROPARROW);
73 } 73 }
74 74
75 TitleBarMenuButton::~TitleBarMenuButton() { 75 TitleBarMenuButton::~TitleBarMenuButton() {
76 } 76 }
77 77
78 void TitleBarMenuButton::SetContents(ChromeViews::View* contents) { 78 void TitleBarMenuButton::SetContents(ChromeViews::View* contents) {
79 contents_ = contents; 79 contents_ = contents;
80 } 80 }
81 81
82 void TitleBarMenuButton::GetPreferredSize(CSize *out) { 82 gfx::Size TitleBarMenuButton::GetPreferredSize() {
83 gfx::Size prefsize;
83 if (contents_) 84 if (contents_)
84 contents_->GetPreferredSize(out); 85 prefsize = contents_->GetPreferredSize();
85 else
86 out->cx = out->cy = 0;
87 86
88 out->cx += drop_arrow_->width() + kHorizMargin + (2 * kHorizBorderSize); 87 prefsize.set_height(std::max(drop_arrow_->height(), prefsize.height()));
89 out->cy = std::max(drop_arrow_->height(), static_cast<int>(out->cy)); 88 prefsize.Enlarge(
90 out->cy += (2 * kVertBorderSize); 89 drop_arrow_->width() + kHorizMargin + (2 * kHorizBorderSize),
90 2 * kVertBorderSize);
91 return prefsize;
91 } 92 }
92 93
93 void TitleBarMenuButton::Paint(ChromeCanvas* canvas) { 94 void TitleBarMenuButton::Paint(ChromeCanvas* canvas) {
94 if (GetState() == TextButton::BS_HOT || 95 if (GetState() == TextButton::BS_HOT ||
95 GetState() == TextButton::BS_PUSHED || menu_visible_) { 96 GetState() == TextButton::BS_PUSHED || menu_visible_) {
96 canvas->FillRectInt(kHotColor, 0, 0, width(), height()); 97 canvas->FillRectInt(kHotColor, 0, 0, width(), height());
97 } 98 }
98 99
99 if (contents_) { 100 if (contents_) {
100 CSize s; 101 gfx::Size s = contents_->GetPreferredSize();
101 contents_->GetPreferredSize(&s);
102 // Note: we use a floating view in this case because we never want the 102 // Note: we use a floating view in this case because we never want the
103 // contents to process any event. 103 // contents to process any event.
104 PaintFloatingView(canvas, 104 PaintFloatingView(canvas,
105 contents_, 105 contents_,
106 kVertBorderSize, 106 kVertBorderSize,
107 (height() - s.cy) / 2, 107 (height() - s.height()) / 2,
108 width() - kHorizMargin - drop_arrow_->width() - 108 width() - kHorizMargin - drop_arrow_->width() -
109 (2 * kHorizBorderSize), 109 (2 * kHorizBorderSize),
110 s.cy); 110 s.height());
111 } 111 }
112 112
113 // We can not use the mirroring infrastructure in ChromeViews in order to 113 // We can not use the mirroring infrastructure in ChromeViews in order to
114 // mirror the drop down arrow because is is drawn directly on the canvas 114 // mirror the drop down arrow because is is drawn directly on the canvas
115 // (instead of using a child View). Thus, we should mirror its position 115 // (instead of using a child View). Thus, we should mirror its position
116 // manually. 116 // manually.
117 gfx::Rect arrow_bounds(width() - drop_arrow_->width() - kHorizBorderSize, 117 gfx::Rect arrow_bounds(width() - drop_arrow_->width() - kHorizBorderSize,
118 (height() - drop_arrow_->height()) / 2, 118 (height() - drop_arrow_->height()) / 2,
119 drop_arrow_->width(), 119 drop_arrow_->width(),
120 drop_arrow_->height()); 120 drop_arrow_->height());
(...skipping 77 matching lines...) Expand 10 before | Expand all | Expand 10 after
198 gfx::Point p(menu_button_->GetX(APPLY_MIRRORING_TRANSFORMATION), 198 gfx::Point p(menu_button_->GetX(APPLY_MIRRORING_TRANSFORMATION),
199 menu_button_->y() + menu_button_->height()); 199 menu_button_->y() + menu_button_->height());
200 200
201 if (UILayoutIsRightToLeft()) 201 if (UILayoutIsRightToLeft())
202 p.set_x(p.x() + menu_button_->width()); 202 p.set_x(p.x() + menu_button_->width());
203 View::ConvertPointToScreen(this, &p); 203 View::ConvertPointToScreen(this, &p);
204 parent_->RunMenu(p.ToPOINT(), hwnd); 204 parent_->RunMenu(p.ToPOINT(), hwnd);
205 } 205 }
206 206
207 void SimpleXPFrameTitleBar::Layout() { 207 void SimpleXPFrameTitleBar::Layout() {
208 CSize s; 208 gfx::Size s = menu_button_->GetPreferredSize();
209 menu_button_->GetPreferredSize(&s); 209 menu_button_->SetBounds(kFavIconMargin, (height() - s.height()) / 2,
210 menu_button_->SetBounds(kFavIconMargin, (height() - s.cy) / 2, 210 s.width(), s.height());
211 s.cx, s.cy);
212 menu_button_->Layout(); 211 menu_button_->Layout();
213 label_->SetBounds(menu_button_->x() + menu_button_->width() + 212 label_->SetBounds(menu_button_->x() + menu_button_->width() +
214 kFavIconPadding, kLabelVerticalOffset, 213 kFavIconPadding, kLabelVerticalOffset,
215 width() - (menu_button_->x() + 214 width() - (menu_button_->x() +
216 menu_button_->width() + kFavIconPadding), 215 menu_button_->width() + kFavIconPadding),
217 height()); 216 height());
218 } 217 }
219 218
220 bool SimpleXPFrameTitleBar::WillHandleMouseEvent(int x, int y) { 219 bool SimpleXPFrameTitleBar::WillHandleMouseEvent(int x, int y) {
221 // If the locale is RTL, we must query for the bounds of the menu button in 220 // If the locale is RTL, we must query for the bounds of the menu button in
(...skipping 93 matching lines...) Expand 10 before | Expand all | Expand 10 after
315 TabContentsContainerView* tccv = GetTabContentsContainer(); 314 TabContentsContainerView* tccv = GetTabContentsContainer();
316 DCHECK(tccv); 315 DCHECK(tccv);
317 title_bar_->SetBounds(tccv->x(), 0, 316 title_bar_->SetBounds(tccv->x(), 0,
318 GetButtonXOrigin() - tccv->x(), 317 GetButtonXOrigin() - tccv->x(),
319 GetContentsYOrigin()); 318 GetContentsYOrigin());
320 title_bar_->Layout(); 319 title_bar_->Layout();
321 } 320 }
322 321
323 if (browser_->ShouldDisplayURLField()) { 322 if (browser_->ShouldDisplayURLField()) {
324 TabContentsContainerView* container = GetTabContentsContainer(); 323 TabContentsContainerView* container = GetTabContentsContainer();
325 CSize s; 324 gfx::Size s = location_bar_->GetPreferredSize();
326 location_bar_->GetPreferredSize(&s);
327 location_bar_->SetBounds(container->x() - kLocationBarOffset, 325 location_bar_->SetBounds(container->x() - kLocationBarOffset,
328 container->y(), 326 container->y(),
329 container->width() + kLocationBarOffset * 2, 327 container->width() + kLocationBarOffset * 2,
330 s.cy); 328 s.height());
331 container->SetBounds(container->x(), 329 container->SetBounds(container->x(),
332 location_bar_->y() + location_bar_->height() + 330 location_bar_->y() + location_bar_->height() +
333 kLocationBarSpacing, container->width(), 331 kLocationBarSpacing, container->width(),
334 container->height() - location_bar_->height() - 332 container->height() - location_bar_->height() -
335 1); 333 1);
336 location_bar_->SetVisible(true); 334 location_bar_->SetVisible(true);
337 location_bar_->Layout(); 335 location_bar_->Layout();
338 } else { 336 } else {
339 location_bar_->SetVisible(false); 337 location_bar_->SetVisible(false);
340 } 338 }
(...skipping 53 matching lines...) Expand 10 before | Expand all | Expand 10 after
394 location_bar_->Update(NULL); 392 location_bar_->Update(NULL);
395 } 393 }
396 394
397 TabContents* SimpleXPFrame::GetTabContents() { 395 TabContents* SimpleXPFrame::GetTabContents() {
398 return GetCurrentContents(); 396 return GetCurrentContents();
399 } 397 }
400 398
401 void SimpleXPFrame::OnInputInProgress(bool in_progress) { 399 void SimpleXPFrame::OnInputInProgress(bool in_progress) {
402 } 400 }
403 401
OLDNEW

Powered by Google App Engine
This is Rietveld 408576698