OLD | NEW |
1 // Copyright (c) 2012 The Chromium Authors. All rights reserved. | 1 // Copyright (c) 2012 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 "ui/accessibility/ax_view_state.h" | 7 #include "ui/accessibility/ax_view_state.h" |
8 #include "ui/base/resource/resource_bundle.h" | 8 #include "ui/base/resource/resource_bundle.h" |
9 #include "ui/resources/grit/ui_resources.h" | 9 #include "ui/resources/grit/ui_resources.h" |
10 #include "ui/views/controls/button/label_button_border.h" | 10 #include "ui/views/controls/button/label_button_border.h" |
11 #include "ui/views/painter.h" | 11 #include "ui/views/painter.h" |
12 #include "ui/views/resources/grit/views_resources.h" | 12 #include "ui/views/resources/grit/views_resources.h" |
13 | 13 |
14 namespace views { | 14 namespace views { |
15 | 15 |
16 // static | 16 // static |
17 const char Checkbox::kViewClassName[] = "Checkbox"; | 17 const char Checkbox::kViewClassName[] = "Checkbox"; |
18 | 18 |
19 Checkbox::Checkbox(const base::string16& label) | 19 Checkbox::Checkbox(const base::string16& label) |
20 : LabelButton(NULL, label), | 20 : LabelButton(nullptr), checked_(false) { |
21 checked_(false) { | |
22 SetHorizontalAlignment(gfx::ALIGN_LEFT); | 21 SetHorizontalAlignment(gfx::ALIGN_LEFT); |
23 scoped_ptr<LabelButtonBorder> button_border(new LabelButtonBorder(style())); | 22 scoped_ptr<LabelButtonBorder> button_border( |
| 23 new LabelButtonBorder(STYLE_TEXTBUTTON)); |
24 button_border->SetPainter(false, STATE_HOVERED, NULL); | 24 button_border->SetPainter(false, STATE_HOVERED, NULL); |
25 button_border->SetPainter(false, STATE_PRESSED, NULL); | 25 button_border->SetPainter(false, STATE_PRESSED, NULL); |
26 // Inset the trailing side by a couple pixels for the focus border. | 26 // Inset the trailing side by a couple pixels for the focus border. |
27 button_border->set_insets(gfx::Insets(0, 0, 0, 2)); | 27 button_border->set_insets(gfx::Insets(0, 0, 0, 2)); |
28 SetBorder(button_border.Pass()); | 28 SetBorder(button_border.Pass()); |
| 29 |
| 30 // TODO(tapted): Remove this. Checkbox has subclasses and Init() may call |
| 31 // virtual methods. |
| 32 InitAsTextbutton(label); |
| 33 |
29 SetFocusable(true); | 34 SetFocusable(true); |
30 | 35 |
31 ui::ResourceBundle& rb = ui::ResourceBundle::GetSharedInstance(); | 36 ui::ResourceBundle& rb = ui::ResourceBundle::GetSharedInstance(); |
32 | 37 |
33 // Unchecked/Unfocused images. | 38 // Unchecked/Unfocused images. |
34 SetCustomImage(false, false, STATE_NORMAL, | 39 SetCustomImage(false, false, STATE_NORMAL, |
35 *rb.GetImageSkiaNamed(IDR_CHECKBOX)); | 40 *rb.GetImageSkiaNamed(IDR_CHECKBOX)); |
36 SetCustomImage(false, false, STATE_HOVERED, | 41 SetCustomImage(false, false, STATE_HOVERED, |
37 *rb.GetImageSkiaNamed(IDR_CHECKBOX_HOVER)); | 42 *rb.GetImageSkiaNamed(IDR_CHECKBOX_HOVER)); |
38 SetCustomImage(false, false, STATE_PRESSED, | 43 SetCustomImage(false, false, STATE_PRESSED, |
(...skipping 100 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
139 ui::NativeTheme::Part Checkbox::GetThemePart() const { | 144 ui::NativeTheme::Part Checkbox::GetThemePart() const { |
140 return ui::NativeTheme::kCheckbox; | 145 return ui::NativeTheme::kCheckbox; |
141 } | 146 } |
142 | 147 |
143 void Checkbox::GetExtraParams(ui::NativeTheme::ExtraParams* params) const { | 148 void Checkbox::GetExtraParams(ui::NativeTheme::ExtraParams* params) const { |
144 LabelButton::GetExtraParams(params); | 149 LabelButton::GetExtraParams(params); |
145 params->button.checked = checked_; | 150 params->button.checked = checked_; |
146 } | 151 } |
147 | 152 |
148 } // namespace views | 153 } // namespace views |
OLD | NEW |