| Index: views/controls/button/radio_button.cc
|
| ===================================================================
|
| --- views/controls/button/radio_button.cc (revision 86135)
|
| +++ views/controls/button/radio_button.cc (working copy)
|
| @@ -11,27 +11,27 @@
|
| namespace views {
|
|
|
| // static
|
| -const char RadioButton::kViewClassName[] = "views/RadioButton";
|
| +const char NativeRadioButton::kViewClassName[] = "views/NativeRadioButton";
|
|
|
| // static
|
| -const char RadioButtonNt::kViewClassName[] = "views/RadioButtonNt";
|
| +const char RadioButton::kViewClassName[] = "views/RadioButton";
|
|
|
| ////////////////////////////////////////////////////////////////////////////////
|
| -// RadioButton, public:
|
| +// NativeRadioButton, public:
|
|
|
| -RadioButton::RadioButton(const std::wstring& label, int group_id)
|
| +NativeRadioButton::NativeRadioButton(const std::wstring& label, int group_id)
|
| : Checkbox(label) {
|
| SetGroup(group_id);
|
| }
|
|
|
| -RadioButton::~RadioButton() {
|
| +NativeRadioButton::~NativeRadioButton() {
|
| }
|
|
|
| ////////////////////////////////////////////////////////////////////////////////
|
| -// RadioButton, Checkbox overrides:
|
| +// NativeRadioButton, Checkbox overrides:
|
|
|
| -void RadioButton::SetChecked(bool checked) {
|
| - if (checked == RadioButton::checked())
|
| +void NativeRadioButton::SetChecked(bool checked) {
|
| + if (checked == NativeRadioButton::checked())
|
| return;
|
| if (native_wrapper_ &&
|
| !native_wrapper_->UsesNativeRadioButtonGroup() && checked) {
|
| @@ -52,7 +52,7 @@
|
| "radio-button views.";
|
| continue;
|
| }
|
| - RadioButton* peer = static_cast<RadioButton*>(*i);
|
| + NativeRadioButton* peer = static_cast<NativeRadioButton*>(*i);
|
| peer->SetChecked(false);
|
| }
|
| }
|
| @@ -62,14 +62,14 @@
|
| }
|
|
|
| ////////////////////////////////////////////////////////////////////////////////
|
| -// RadioButton, View overrides:
|
| +// NativeRadioButton, View overrides:
|
|
|
| -void RadioButton::GetAccessibleState(ui::AccessibleViewState* state) {
|
| +void NativeRadioButton::GetAccessibleState(ui::AccessibleViewState* state) {
|
| Checkbox::GetAccessibleState(state);
|
| state->role = ui::AccessibilityTypes::ROLE_RADIOBUTTON;
|
| }
|
|
|
| -View* RadioButton::GetSelectedViewForGroup(int group_id) {
|
| +View* NativeRadioButton::GetSelectedViewForGroup(int group_id) {
|
| std::vector<View*> views;
|
| GetWidget()->GetRootView()->GetViewsWithGroup(group_id, &views);
|
| if (views.empty())
|
| @@ -77,20 +77,20 @@
|
|
|
| for (std::vector<View*>::const_iterator iter = views.begin();
|
| iter != views.end(); ++iter) {
|
| - RadioButton* radio_button = static_cast<RadioButton*>(*iter);
|
| + NativeRadioButton* radio_button = static_cast<NativeRadioButton*>(*iter);
|
| if (radio_button->checked())
|
| return radio_button;
|
| }
|
| return NULL;
|
| }
|
|
|
| -bool RadioButton::IsGroupFocusTraversable() const {
|
| +bool NativeRadioButton::IsGroupFocusTraversable() const {
|
| // When focusing a radio button with tab/shift+tab, only the selected button
|
| // from the group should be focused.
|
| return false;
|
| }
|
|
|
| -void RadioButton::OnMouseReleased(const MouseEvent& event) {
|
| +void NativeRadioButton::OnMouseReleased(const MouseEvent& event) {
|
| // Set the checked state to true only if we are unchecked, since we can't
|
| // be toggled on and off like a checkbox.
|
| if (!checked() && HitTestLabel(event))
|
| @@ -99,38 +99,39 @@
|
| OnMouseCaptureLost();
|
| }
|
|
|
| -void RadioButton::OnMouseCaptureLost() {
|
| +void NativeRadioButton::OnMouseCaptureLost() {
|
| native_wrapper_->SetPushed(false);
|
| ButtonPressed();
|
| }
|
|
|
| -std::string RadioButton::GetClassName() const {
|
| +std::string NativeRadioButton::GetClassName() const {
|
| return kViewClassName;
|
| }
|
|
|
| ////////////////////////////////////////////////////////////////////////////////
|
| -// RadioButton, NativeButton overrides:
|
| +// NativeRadioButton, NativeButton overrides:
|
|
|
| -NativeButtonWrapper* RadioButton::CreateWrapper() {
|
| +NativeButtonWrapper* NativeRadioButton::CreateWrapper() {
|
| return NativeButtonWrapper::CreateRadioButtonWrapper(this);
|
| }
|
|
|
| ////////////////////////////////////////////////////////////////////////////////
|
| //
|
| -// RadioButtonNt
|
| +// RadioButton
|
| //
|
| ////////////////////////////////////////////////////////////////////////////////
|
|
|
| -RadioButtonNt::RadioButtonNt(const std::wstring& label, int group_id)
|
| +RadioButton::RadioButton(const std::wstring& label, int group_id)
|
| : CheckboxNt(label) {
|
| SetGroup(group_id);
|
| + focusable_ = true;
|
| }
|
|
|
| -RadioButtonNt::~RadioButtonNt() {
|
| +RadioButton::~RadioButton() {
|
| }
|
|
|
| -void RadioButtonNt::SetChecked(bool checked) {
|
| - if (checked == RadioButtonNt::checked())
|
| +void RadioButton::SetChecked(bool checked) {
|
| + if (checked == RadioButton::checked())
|
| return;
|
| if (checked) {
|
| // We can't just get the root view here because sometimes the radio
|
| @@ -150,7 +151,7 @@
|
| "radio-button-nt views.";
|
| continue;
|
| }
|
| - RadioButtonNt* peer = static_cast<RadioButtonNt*>(*i);
|
| + RadioButton* peer = static_cast<RadioButton*>(*i);
|
| peer->SetChecked(false);
|
| }
|
| }
|
| @@ -159,16 +160,16 @@
|
| CheckboxNt::SetChecked(checked);
|
| }
|
|
|
| -std::string RadioButtonNt::GetClassName() const {
|
| +std::string RadioButton::GetClassName() const {
|
| return kViewClassName;
|
| }
|
|
|
| -void RadioButtonNt::GetAccessibleState(ui::AccessibleViewState* state) {
|
| +void RadioButton::GetAccessibleState(ui::AccessibleViewState* state) {
|
| CheckboxNt::GetAccessibleState(state);
|
| state->role = ui::AccessibilityTypes::ROLE_RADIOBUTTON;
|
| }
|
|
|
| -View* RadioButtonNt::GetSelectedViewForGroup(int group_id) {
|
| +View* RadioButton::GetSelectedViewForGroup(int group_id) {
|
| std::vector<View*> views;
|
| GetWidget()->GetRootView()->GetViewsWithGroup(group_id, &views);
|
| if (views.empty())
|
| @@ -177,28 +178,36 @@
|
| for (std::vector<View*>::const_iterator iter = views.begin();
|
| iter != views.end(); ++iter) {
|
| // REVIEW: why don't we check the runtime type like is done above?
|
| - RadioButtonNt* radio_button = static_cast<RadioButtonNt*>(*iter);
|
| + RadioButton* radio_button = static_cast<RadioButton*>(*iter);
|
| if (radio_button->checked())
|
| return radio_button;
|
| }
|
| return NULL;
|
| }
|
|
|
| -bool RadioButtonNt::IsGroupFocusTraversable() const {
|
| +bool RadioButton::IsGroupFocusTraversable() const {
|
| // When focusing a radio button with tab/shift+tab, only the selected button
|
| // from the group should be focused.
|
| return false;
|
| }
|
|
|
| -void RadioButtonNt::NotifyClick(const views::Event& event) {
|
| +void RadioButton::OnFocus() {
|
| + CheckboxNt::OnFocus();
|
| + SetChecked(true);
|
| + views::MouseEvent event(ui::ET_MOUSE_PRESSED, 0, 0, 0);
|
| + TextButtonBase::NotifyClick(event);
|
| +}
|
| +
|
| +void RadioButton::NotifyClick(const views::Event& event) {
|
| // Set the checked state to true only if we are unchecked, since we can't
|
| // be toggled on and off like a checkbox.
|
| if (!checked())
|
| SetChecked(true);
|
| RequestFocus();
|
| + TextButtonBase::NotifyClick(event);
|
| }
|
|
|
| -gfx::NativeTheme::Part RadioButtonNt::GetThemePart() const {
|
| +gfx::NativeTheme::Part RadioButton::GetThemePart() const {
|
| return gfx::NativeTheme::kRadio;
|
| }
|
|
|
|
|