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

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

Issue 10387121: Revert 136996 - ui: Move NativeTheme files into ui/base/native_theme/ directory. (Closed) Base URL: svn://svn.chromium.org/chrome/trunk/src/
Patch Set: Created 8 years, 7 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 | « ui/views/controls/button/checkbox.h ('k') | ui/views/controls/button/radio_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) 2012 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 "ui/views/controls/button/checkbox.h" 5 #include "ui/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 "ui/views/controls/label.h" 10 #include "ui/views/controls/label.h"
11 11
(...skipping 17 matching lines...) Expand all
29 Checkbox::~Checkbox() { 29 Checkbox::~Checkbox() {
30 } 30 }
31 31
32 void Checkbox::SetChecked(bool checked) { 32 void Checkbox::SetChecked(bool checked) {
33 checked_ = checked; 33 checked_ = checked;
34 SchedulePaint(); 34 SchedulePaint();
35 } 35 }
36 36
37 gfx::Size Checkbox::GetPreferredSize() { 37 gfx::Size Checkbox::GetPreferredSize() {
38 gfx::Size prefsize(TextButtonBase::GetPreferredSize()); 38 gfx::Size prefsize(TextButtonBase::GetPreferredSize());
39 ui::NativeTheme::ExtraParams extra; 39 gfx::NativeTheme::ExtraParams extra;
40 ui::NativeTheme::State state = GetThemeState(&extra); 40 gfx::NativeTheme::State state = GetThemeState(&extra);
41 gfx::Size size = ui::NativeTheme::instance()->GetPartSize(GetThemePart(), 41 gfx::Size size = gfx::NativeTheme::instance()->GetPartSize(GetThemePart(),
42 state, extra); 42 state,
43 extra);
43 prefsize.Enlarge(size.width(), 0); 44 prefsize.Enlarge(size.width(), 0);
44 prefsize.set_height(std::max(prefsize.height(), size.height())); 45 prefsize.set_height(std::max(prefsize.height(), size.height()));
45 46
46 if (max_width_ > 0) 47 if (max_width_ > 0)
47 prefsize.set_width(std::min(max_width_, prefsize.width())); 48 prefsize.set_width(std::min(max_width_, prefsize.width()));
48 49
49 return prefsize; 50 return prefsize;
50 } 51 }
51 52
52 std::string Checkbox::GetClassName() const { 53 std::string Checkbox::GetClassName() const {
(...skipping 15 matching lines...) Expand all
68 canvas->DrawFocusRect(bounds); 69 canvas->DrawFocusRect(bounds);
69 } 70 }
70 } 71 }
71 72
72 void Checkbox::NotifyClick(const views::Event& event) { 73 void Checkbox::NotifyClick(const views::Event& event) {
73 SetChecked(!checked()); 74 SetChecked(!checked());
74 RequestFocus(); 75 RequestFocus();
75 TextButtonBase::NotifyClick(event); 76 TextButtonBase::NotifyClick(event);
76 } 77 }
77 78
78 ui::NativeTheme::Part Checkbox::GetThemePart() const { 79 gfx::NativeTheme::Part Checkbox::GetThemePart() const {
79 return ui::NativeTheme::kCheckbox; 80 return gfx::NativeTheme::kCheckbox;
80 } 81 }
81 82
82 gfx::Rect Checkbox::GetThemePaintRect() const { 83 gfx::Rect Checkbox::GetThemePaintRect() const {
83 ui::NativeTheme::ExtraParams extra; 84 gfx::NativeTheme::ExtraParams extra;
84 ui::NativeTheme::State state = GetThemeState(&extra); 85 gfx::NativeTheme::State state = GetThemeState(&extra);
85 gfx::Size size(ui::NativeTheme::instance()->GetPartSize(GetThemePart(), state, 86 gfx::Size size(gfx::NativeTheme::instance()->GetPartSize(GetThemePart(),
86 extra)); 87 state,
88 extra));
87 gfx::Insets insets = GetInsets(); 89 gfx::Insets insets = GetInsets();
88 int y_offset = (height() - size.height()) / 2; 90 int y_offset = (height() - size.height()) / 2;
89 gfx::Rect rect(insets.left(), y_offset, size.width(), size.height()); 91 gfx::Rect rect(insets.left(), y_offset, size.width(), size.height());
90 rect.set_x(GetMirroredXForRect(rect)); 92 rect.set_x(GetMirroredXForRect(rect));
91 return rect; 93 return rect;
92 } 94 }
93 95
94 void Checkbox::GetExtraParams(ui::NativeTheme::ExtraParams* params) const { 96 void Checkbox::GetExtraParams(gfx::NativeTheme::ExtraParams* params) const {
95 TextButtonBase::GetExtraParams(params); 97 TextButtonBase::GetExtraParams(params);
96 params->button.checked = checked_; 98 params->button.checked = checked_;
97 } 99 }
98 100
99 gfx::Rect Checkbox::GetTextBounds() const { 101 gfx::Rect Checkbox::GetTextBounds() const {
100 gfx::Rect bounds(TextButtonBase::GetTextBounds()); 102 gfx::Rect bounds(TextButtonBase::GetTextBounds());
101 ui::NativeTheme::ExtraParams extra; 103 gfx::NativeTheme::ExtraParams extra;
102 ui::NativeTheme::State state = GetThemeState(&extra); 104 gfx::NativeTheme::State state = GetThemeState(&extra);
103 gfx::Size size(ui::NativeTheme::instance()->GetPartSize(GetThemePart(), state, 105 gfx::Size size(gfx::NativeTheme::instance()->GetPartSize(GetThemePart(),
104 extra)); 106 state,
107 extra));
105 bounds.Offset(size.width() + kCheckboxLabelSpacing, 0); 108 bounds.Offset(size.width() + kCheckboxLabelSpacing, 0);
106 return bounds; 109 return bounds;
107 } 110 }
108 111
109 } // namespace views 112 } // namespace views
OLDNEW
« no previous file with comments | « ui/views/controls/button/checkbox.h ('k') | ui/views/controls/button/radio_button.h » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698