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

Unified Diff: chrome/views/checkbox.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 side-by-side diff with in-line comments
Download patch
Index: chrome/views/checkbox.cc
===================================================================
--- chrome/views/checkbox.cc (revision 3391)
+++ chrome/views/checkbox.cc (working copy)
@@ -71,14 +71,13 @@
}
void CheckBox::ComputeTextRect(gfx::Rect* out) {
- CSize s;
- label_->GetPreferredSize(&s);
+ gfx::Size s = label_->GetPreferredSize();
out->set_x(GetTextIndent());
out->set_y(kFocusPaddingVertical);
int new_width = std::min(width() - (kCheckBoxWidth + kCheckBoxToLabel),
- static_cast<int>(s.cx));
+ s.width());
out->set_width(std::max(0, new_width));
- out->set_height(s.cy);
+ out->set_height(s.height());
}
void CheckBox::Paint(ChromeCanvas* canvas) {
@@ -119,11 +118,12 @@
label_->SetText(GetLabel());
}
-void CheckBox::GetPreferredSize(CSize *out) {
- label_->GetPreferredSize(out);
- out->cy = std::max(static_cast<int>(out->cy + kFocusPaddingVertical * 2),
- kCheckBoxHeight);
- out->cx += GetTextIndent() * 2;
+gfx::Size CheckBox::GetPreferredSize() {
+ gfx::Size prefsize = label_->GetPreferredSize();
+ prefsize.set_height(std::max(prefsize.height() + kFocusPaddingVertical * 2,
+ kCheckBoxHeight));
+ prefsize.Enlarge(GetTextIndent() * 2, 0);
+ return prefsize;
}
LRESULT CheckBox::OnCommand(UINT code, int id, HWND source) {

Powered by Google App Engine
This is Rietveld 408576698