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

Side by Side Diff: views/controls/button/checkbox.cc

Issue 6976048: views: Add OnEnabledChanged() method to View class. (Closed) Base URL: svn://svn.chromium.org/chrome/trunk/src
Patch Set: fix DisableOnHover test? Created 9 years, 6 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
« no previous file with comments | « views/controls/button/checkbox.h ('k') | views/controls/button/custom_button.h » ('j') | no next file with comments »
Toggle Intra-line Diffs ('i') | Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
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 "views/controls/button/checkbox.h" 5 #include "views/controls/button/checkbox.h"
6 6
7 #include "base/logging.h" 7 #include "base/logging.h"
8 #include "ui/base/accessibility/accessible_view_state.h" 8 #include "ui/base/accessibility/accessible_view_state.h"
9 #include "ui/gfx/canvas.h" 9 #include "ui/gfx/canvas.h"
10 #include "views/controls/label.h" 10 #include "views/controls/label.h"
(...skipping 72 matching lines...) Expand 10 before | Expand all | Expand 10 after
83 83
84 gfx::Size prefsize = native_wrapper_->GetView()->GetPreferredSize(); 84 gfx::Size prefsize = native_wrapper_->GetView()->GetPreferredSize();
85 if (native_wrapper_->UsesNativeLabel()) 85 if (native_wrapper_->UsesNativeLabel())
86 return prefsize.height(); 86 return prefsize.height();
87 87
88 int width = prefsize.width() + kCheckboxLabelSpacing + 88 int width = prefsize.width() + kCheckboxLabelSpacing +
89 kLabelFocusPaddingHorizontal * 2; 89 kLabelFocusPaddingHorizontal * 2;
90 return label_->GetHeightForWidth(std::max(prefsize.height(), w - width)); 90 return label_->GetHeightForWidth(std::max(prefsize.height(), w - width));
91 } 91 }
92 92
93 void Checkbox::SetEnabled(bool enabled) { 93 void Checkbox::OnEnabledChanged() {
94 NativeButtonBase::SetEnabled(enabled); 94 NativeButtonBase::OnEnabledChanged();
95 if (label_) 95 if (label_)
96 label_->SetEnabled(enabled); 96 label_->SetEnabled(IsEnabled());
97 } 97 }
98 98
99 void Checkbox::Layout() { 99 void Checkbox::Layout() {
100 if (!native_wrapper_) 100 if (!native_wrapper_)
101 return; 101 return;
102 102
103 if (native_wrapper_->UsesNativeLabel()) { 103 if (native_wrapper_->UsesNativeLabel()) {
104 label_->SetBounds(0, 0, 0, 0); 104 label_->SetBounds(0, 0, 0, 0);
105 label_->SetVisible(false); 105 label_->SetVisible(false);
106 native_wrapper_->GetView()->SetBounds(0, 0, width(), height()); 106 native_wrapper_->GetView()->SetBounds(0, 0, width(), height());
(...skipping 201 matching lines...) Expand 10 before | Expand all | Expand 10 after
308 gfx::NativeTheme::ExtraParams extra; 308 gfx::NativeTheme::ExtraParams extra;
309 gfx::NativeTheme::State state = GetThemeState(&extra); 309 gfx::NativeTheme::State state = GetThemeState(&extra);
310 gfx::Size size(gfx::NativeTheme::instance()->GetPartSize(GetThemePart(), 310 gfx::Size size(gfx::NativeTheme::instance()->GetPartSize(GetThemePart(),
311 state, 311 state,
312 extra)); 312 extra));
313 bounds.Offset(size.width() + kCheckboxLabelSpacing, 0); 313 bounds.Offset(size.width() + kCheckboxLabelSpacing, 0);
314 return bounds; 314 return bounds;
315 } 315 }
316 316
317 } // namespace views 317 } // namespace views
OLDNEW
« no previous file with comments | « views/controls/button/checkbox.h ('k') | views/controls/button/custom_button.h » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698