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

Unified Diff: ui/views/controls/button/radio_button.cc

Issue 15061006: views: Switch Checkbox over to LabelButton. (Closed) Base URL: svn://svn.chromium.org/chrome/trunk/src
Patch Set: SetCustomImage() Created 7 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 side-by-side diff with in-line comments
Download patch
Index: ui/views/controls/button/radio_button.cc
diff --git a/ui/views/controls/button/radio_button.cc b/ui/views/controls/button/radio_button.cc
index 7f7aa1e1e66922c75641bbffda1b6bf6ed8b55cb..de61263f673c8b284f3faa0ba6434844794e2800 100644
--- a/ui/views/controls/button/radio_button.cc
+++ b/ui/views/controls/button/radio_button.cc
@@ -5,7 +5,9 @@
#include "ui/views/controls/button/radio_button.h"
#include "base/logging.h"
+#include "grit/ui_resources.h"
#include "ui/base/accessibility/accessible_view_state.h"
+#include "ui/base/resource/resource_bundle.h"
#include "ui/views/widget/widget.h"
namespace views {
@@ -15,8 +17,46 @@ const char RadioButton::kViewClassName[] = "views/RadioButton";
RadioButton::RadioButton(const string16& label, int group_id)
: Checkbox(label) {
+ SetStyle(STYLE_RADIO);
SetGroup(group_id);
set_focusable(true);
+
+ ui::ResourceBundle& rb = ui::ResourceBundle::GetSharedInstance();
+ SetImage(STATE_NORMAL, *rb.GetImageSkiaNamed(IDR_RADIO));
+ SetCustomImage(
msw 2013/05/21 00:35:17 nit: ditto for 3 state args on SetCustomImage line
tfarina 2013/05/21 01:56:52 Done.
+ true, false, STATE_NORMAL, *rb.GetImageSkiaNamed(IDR_RADIO_CHECKED));
+ SetCustomImage(true,
+ false,
+ STATE_HOVERED,
+ *rb.GetImageSkiaNamed(IDR_RADIO_CHECKED_HOVER));
+ SetCustomImage(true,
+ false,
+ STATE_PRESSED,
+ *rb.GetImageSkiaNamed(IDR_RADIO_CHECKED_PRESSED));
+ SetCustomImage(
+ false, true, STATE_NORMAL, *rb.GetImageSkiaNamed(IDR_RADIO_FOCUSED));
+ SetCustomImage(true,
+ true,
+ STATE_NORMAL,
+ *rb.GetImageSkiaNamed(IDR_RADIO_FOCUSED_CHECKED));
+ SetCustomImage(true,
+ true,
+ STATE_HOVERED,
+ *rb.GetImageSkiaNamed(IDR_RADIO_FOCUSED_CHECKED_HOVER));
+ SetCustomImage(true,
+ true,
+ STATE_PRESSED,
+ *rb.GetImageSkiaNamed(IDR_RADIO_FOCUSED_CHECKED_PRESSED));
+ SetCustomImage(false,
+ true,
+ STATE_HOVERED,
+ *rb.GetImageSkiaNamed(IDR_RADIO_FOCUSED_HOVER));
+ SetCustomImage(false,
+ true,
+ STATE_PRESSED,
+ *rb.GetImageSkiaNamed(IDR_RADIO_FOCUSED_PRESSED));
+ SetImage(STATE_HOVERED, *rb.GetImageSkiaNamed(IDR_RADIO_HOVER));
msw 2013/05/21 00:35:17 ditto for using SetCustomImage for everything.
tfarina 2013/05/21 01:56:52 Done.
+ SetImage(STATE_PRESSED, *rb.GetImageSkiaNamed(IDR_RADIO_PRESSED));
}
RadioButton::~RadioButton() {
@@ -85,7 +125,7 @@ void RadioButton::OnFocus() {
Checkbox::OnFocus();
SetChecked(true);
ui::MouseEvent event(ui::ET_MOUSE_PRESSED, gfx::Point(), gfx::Point(), 0);
- TextButtonBase::NotifyClick(event);
+ LabelButton::NotifyClick(event);
}
void RadioButton::NotifyClick(const ui::Event& event) {
@@ -94,7 +134,7 @@ void RadioButton::NotifyClick(const ui::Event& event) {
if (!checked())
SetChecked(true);
RequestFocus();
- TextButtonBase::NotifyClick(event);
+ LabelButton::NotifyClick(event);
}
ui::NativeTheme::Part RadioButton::GetThemePart() const {
« ui/views/controls/button/checkbox.cc ('K') | « ui/views/controls/button/label_button_border.cc ('k') | no next file » | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698