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 160 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
171 | 171 |
172 int Combobox::GetSelectedRow() { | 172 int Combobox::GetSelectedRow() { |
173 return selected_index_; | 173 return selected_index_; |
174 } | 174 } |
175 | 175 |
176 void Combobox::SetSelectedRow(int row) { | 176 void Combobox::SetSelectedRow(int row) { |
177 SetSelectedIndex(row); | 177 SetSelectedIndex(row); |
178 } | 178 } |
179 | 179 |
180 string16 Combobox::GetTextForRow(int row) { | 180 string16 Combobox::GetTextForRow(int row) { |
181 return model()->GetItemAt(row); | 181 return model()->IsItemSeparatorAt(row) ? string16() : model()->GetItemAt(row); |
182 } | 182 } |
183 | 183 |
184 //////////////////////////////////////////////////////////////////////////////// | 184 //////////////////////////////////////////////////////////////////////////////// |
185 // Combobox, View overrides: | 185 // Combobox, View overrides: |
186 | 186 |
187 gfx::Size Combobox::GetPreferredSize() { | 187 gfx::Size Combobox::GetPreferredSize() { |
188 if (content_size_.IsEmpty()) | 188 if (content_size_.IsEmpty()) |
189 UpdateFromModel(); | 189 UpdateFromModel(); |
190 | 190 |
191 // The preferred size will drive the local bounds which in turn is used to set | 191 // The preferred size will drive the local bounds which in turn is used to set |
(...skipping 267 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
459 | 459 |
460 int Combobox::MenuCommandToIndex(int menu_command_id) const { | 460 int Combobox::MenuCommandToIndex(int menu_command_id) const { |
461 // (note that the id received is offset by kFirstMenuItemId) | 461 // (note that the id received is offset by kFirstMenuItemId) |
462 // Revert menu ID offset to map back to combobox model. | 462 // Revert menu ID offset to map back to combobox model. |
463 int index = menu_command_id - kFirstMenuItemId; | 463 int index = menu_command_id - kFirstMenuItemId; |
464 DCHECK_LT(index, model()->GetItemCount()); | 464 DCHECK_LT(index, model()->GetItemCount()); |
465 return index; | 465 return index; |
466 } | 466 } |
467 | 467 |
468 } // namespace views | 468 } // namespace views |
OLD | NEW |