diff options
author | rogerta@chromium.org <rogerta@chromium.org@0039d316-1c4b-4281-b951-d872f2087c98> | 2011-05-23 13:14:58 +0000 |
---|---|---|
committer | rogerta@chromium.org <rogerta@chromium.org@0039d316-1c4b-4281-b951-d872f2087c98> | 2011-05-23 13:14:58 +0000 |
commit | bf9940639b4a942b18837f532d71bf4e0855a39e (patch) | |
tree | 9ce2a7675ea516c4a3a0787824d19f7d61c3875c /views/examples | |
parent | f34fc289bcfff2304a854b2d8bf29a78979c75c3 (diff) | |
download | chromium_src-bf9940639b4a942b18837f532d71bf4e0855a39e.zip chromium_src-bf9940639b4a942b18837f532d71bf4e0855a39e.tar.gz chromium_src-bf9940639b4a942b18837f532d71bf4e0855a39e.tar.bz2 |
Change chrome to use the new native themed radio button.
While testing the chromeos password changed dialog, I noticed that the dialog
was clipped at the bottom, so that the text field to enter the old password
was not fully visible. This was with and without my change. To fix, I
increase the height of the dialog, hence the locale_settings.grd change.
BUG=None
TEST=Make sure all uses of radio buttons in chrome, on all platforms including
chromeos, work as expected. The look may be slightly different, but the
behaviour should be the same. To test the password changed dialog on chromeos,
login and then logout with a given account. Change the password of that
account (with another computer for example) and then log back in using the
new password. The text field at the bottom should not be clipped.
Review URL: http://codereview.chromium.org/6955002
git-svn-id: svn://svn.chromium.org/chrome/trunk/src@86283 0039d316-1c4b-4281-b951-d872f2087c98
Diffstat (limited to 'views/examples')
-rw-r--r-- | views/examples/radio_button_example.cc | 36 | ||||
-rw-r--r-- | views/examples/radio_button_example.h | 10 |
2 files changed, 28 insertions, 18 deletions
diff --git a/views/examples/radio_button_example.cc b/views/examples/radio_button_example.cc index c61eef5..252a25a 100644 --- a/views/examples/radio_button_example.cc +++ b/views/examples/radio_button_example.cc @@ -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 @@ void RadioButtonExample::CreateExampleView(views::View* container) { 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 @@ void RadioButtonExample::CreateExampleView(views::View* container) { 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::CreateExampleView(views::View* container) { 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_); } } diff --git a/views/examples/radio_button_example.h b/views/examples/radio_button_example.h index 72217e2..4af37af 100644 --- a/views/examples/radio_button_example.h +++ b/views/examples/radio_button_example.h @@ -11,9 +11,12 @@ #include "base/basictypes.h" #include "base/compiler_specific.h" #include "views/controls/button/radio_button.h" -#include "views/controls/button/text_button.h" #include "views/examples/example_base.h" +namespace events { +class TextButton; +} + namespace examples { class RadioButtonExample : public ExampleBase, @@ -32,13 +35,16 @@ class RadioButtonExample : public ExampleBase, const views::Event& event) OVERRIDE; // Two groups of 3 radio buttons. + views::NativeRadioButton* native_radio_buttons_[3]; views::RadioButton* radio_buttons_[3]; - views::RadioButtonNt* radio_buttons_nt_[3]; // Control button to select radio buttons, and show the status of buttons. views::TextButton* select_; views::TextButton* status_; + // The number of times the button is pressed. + int count_; + DISALLOW_COPY_AND_ASSIGN(RadioButtonExample); }; |