| 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/combobox/combobox.h" | 5 #include "ui/views/controls/combobox/combobox.h" |
| 6 | 6 |
| 7 #include "base/logging.h" | 7 #include "base/logging.h" |
| 8 #include "base/strings/utf_string_conversions.h" | 8 #include "base/strings/utf_string_conversions.h" |
| 9 #include "grit/ui_resources.h" | 9 #include "grit/ui_resources.h" |
| 10 #include "ui/base/accessibility/accessible_view_state.h" | 10 #include "ui/base/accessibility/accessible_view_state.h" |
| (...skipping 122 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 133 } | 133 } |
| 134 } | 134 } |
| 135 return false; | 135 return false; |
| 136 } | 136 } |
| 137 | 137 |
| 138 void Combobox::SetAccessibleName(const string16& name) { | 138 void Combobox::SetAccessibleName(const string16& name) { |
| 139 accessible_name_ = name; | 139 accessible_name_ = name; |
| 140 } | 140 } |
| 141 | 141 |
| 142 void Combobox::SetInvalid(bool invalid) { | 142 void Combobox::SetInvalid(bool invalid) { |
| 143 if (invalid == invalid_) |
| 144 return; |
| 145 |
| 143 invalid_ = invalid; | 146 invalid_ = invalid; |
| 144 if (invalid) { | 147 if (invalid_) { |
| 145 text_border_->SetColor(kWarningColor); | 148 text_border_->SetColor(kWarningColor); |
| 146 set_background(new InvalidBackground()); | 149 set_background(new InvalidBackground()); |
| 147 } else { | 150 } else { |
| 148 text_border_->UseDefaultColor(); | 151 text_border_->UseDefaultColor(); |
| 149 set_background(NULL); | 152 set_background(NULL); |
| 150 } | 153 } |
| 154 SchedulePaint(); |
| 151 } | 155 } |
| 152 | 156 |
| 153 ui::TextInputClient* Combobox::GetTextInputClient() { | 157 ui::TextInputClient* Combobox::GetTextInputClient() { |
| 154 if (!selector_) | 158 if (!selector_) |
| 155 selector_.reset(new PrefixSelector(this)); | 159 selector_.reset(new PrefixSelector(this)); |
| 156 return selector_.get(); | 160 return selector_.get(); |
| 157 } | 161 } |
| 158 | 162 |
| 159 | 163 |
| 160 bool Combobox::IsItemChecked(int id) const { | 164 bool Combobox::IsItemChecked(int id) const { |
| (...skipping 307 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 468 | 472 |
| 469 int Combobox::MenuCommandToIndex(int menu_command_id) const { | 473 int Combobox::MenuCommandToIndex(int menu_command_id) const { |
| 470 // (note that the id received is offset by kFirstMenuItemId) | 474 // (note that the id received is offset by kFirstMenuItemId) |
| 471 // Revert menu ID offset to map back to combobox model. | 475 // Revert menu ID offset to map back to combobox model. |
| 472 int index = menu_command_id - kFirstMenuItemId; | 476 int index = menu_command_id - kFirstMenuItemId; |
| 473 DCHECK_LT(index, model()->GetItemCount()); | 477 DCHECK_LT(index, model()->GetItemCount()); |
| 474 return index; | 478 return index; |
| 475 } | 479 } |
| 476 | 480 |
| 477 } // namespace views | 481 } // namespace views |
| OLD | NEW |