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

Unified Diff: views/examples/radio_button_example.cc

Issue 6955002: Change chrome to use the new native themed radio button. (Closed) Base URL: svn://svn.chromium.org/chrome/trunk/src/
Patch Set: Addressed some more comments from review Created 9 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
« no previous file with comments | « views/examples/radio_button_example.h ('k') | views/focus/focus_manager_unittest.cc » ('j') | no next file with comments »
Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
Index: views/examples/radio_button_example.cc
===================================================================
--- views/examples/radio_button_example.cc (revision 86135)
+++ views/examples/radio_button_example.cc (working copy)
@@ -5,13 +5,14 @@
#include "views/examples/radio_button_example.h"
#include "base/stringprintf.h"
+#include "views/controls/button/text_button.h"
#include "views/layout/grid_layout.h"
#include "views/view.h"
namespace examples {
RadioButtonExample::RadioButtonExample(ExamplesMain* main)
- : ExampleBase(main) {
+ : ExampleBase(main), count_(0) {
}
RadioButtonExample::~RadioButtonExample() {
@@ -26,16 +27,17 @@
status_ = new views::TextButton(this, L"Show Status");
int group = 1;
- for (size_t i = 0; i < arraysize(radio_buttons_); ++i) {
- radio_buttons_[i] = new views::RadioButton(
+ for (size_t i = 0; i < arraysize(native_radio_buttons_); ++i) {
+ native_radio_buttons_[i] = new views::NativeRadioButton(
base::StringPrintf( L"Radio %d in group %d", i + 1, group), group);
+ native_radio_buttons_[i]->set_listener(this);
}
++group;
- for (size_t i = 0; i < arraysize(radio_buttons_nt_); ++i) {
- radio_buttons_nt_[i] = new views::RadioButtonNt(
+ for (size_t i = 0; i < arraysize(radio_buttons_); ++i) {
+ radio_buttons_[i] = new views::RadioButton(
base::StringPrintf( L"Radio %d in group %d", i + 1, group), group);
- radio_buttons_nt_[i]->SetFocusable(true);
+ radio_buttons_[i]->set_listener(this);
}
views::GridLayout* layout = new views::GridLayout(container);
@@ -44,13 +46,13 @@
views::ColumnSet* column_set = layout->AddColumnSet(0);
column_set->AddColumn(views::GridLayout::FILL, views::GridLayout::FILL,
1.0f, views::GridLayout::USE_PREF, 0, 0);
- for (size_t i = 0; i < arraysize(radio_buttons_); i++) {
+ for (size_t i = 0; i < arraysize(native_radio_buttons_); ++i) {
layout->StartRow(0, 0);
- layout->AddView(radio_buttons_[i]);
+ layout->AddView(native_radio_buttons_[i]);
}
- for (size_t i = 0; i < arraysize(radio_buttons_nt_); i++) {
+ for (size_t i = 0; i < arraysize(radio_buttons_); ++i) {
layout->StartRow(0, 0);
- layout->AddView(radio_buttons_nt_[i]);
+ layout->AddView(radio_buttons_[i]);
}
layout->StartRow(0, 0);
layout->AddView(select_);
@@ -61,17 +63,19 @@
void RadioButtonExample::ButtonPressed(views::Button* sender,
const views::Event& event) {
if (sender == select_) {
- radio_buttons_[0]->SetChecked(true);
- radio_buttons_nt_[2]->SetChecked(true);
+ native_radio_buttons_[0]->SetChecked(true);
+ radio_buttons_[2]->SetChecked(true);
} else if (sender == status_) {
// Show the state of radio buttons.
PrintStatus(L"Group1: 1:%ls, 2:%ls, 3:%ls Group2: 1:%ls, 2:%ls, 3:%ls",
+ IntToOnOff(native_radio_buttons_[0]->checked()),
+ IntToOnOff(native_radio_buttons_[1]->checked()),
+ IntToOnOff(native_radio_buttons_[2]->checked()),
IntToOnOff(radio_buttons_[0]->checked()),
IntToOnOff(radio_buttons_[1]->checked()),
- IntToOnOff(radio_buttons_[2]->checked()),
- IntToOnOff(radio_buttons_nt_[0]->checked()),
- IntToOnOff(radio_buttons_nt_[1]->checked()),
- IntToOnOff(radio_buttons_nt_[2]->checked()));
+ IntToOnOff(radio_buttons_[2]->checked()));
+ } else {
+ PrintStatus(L"Pressed! count:%d", ++count_);
}
}
« no previous file with comments | « views/examples/radio_button_example.h ('k') | views/focus/focus_manager_unittest.cc » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698