OLD | NEW |
1 // Copyright (c) 2010 The Chromium Authors. All rights reserved. | 1 // Copyright (c) 2010 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 "views/controls/combobox/combobox.h" | 5 #include "views/controls/combobox/combobox.h" |
6 | 6 |
7 #include "app/combobox_model.h" | 7 #include "app/combobox_model.h" |
8 #include "base/keyboard_codes.h" | 8 #include "base/keyboard_codes.h" |
9 #include "base/logging.h" | 9 #include "base/logging.h" |
| 10 #include "base/utf_string_conversions.h" |
10 #include "views/controls/combobox/native_combobox_wrapper.h" | 11 #include "views/controls/combobox/native_combobox_wrapper.h" |
11 #include "views/controls/native/native_view_host.h" | 12 #include "views/controls/native/native_view_host.h" |
12 | 13 |
13 namespace views { | 14 namespace views { |
14 | 15 |
15 // static | 16 // static |
16 const char Combobox::kViewClassName[] = "views/Combobox"; | 17 const char Combobox::kViewClassName[] = "views/Combobox"; |
17 | 18 |
18 //////////////////////////////////////////////////////////////////////////////// | 19 //////////////////////////////////////////////////////////////////////////////// |
19 // Combobox, public: | 20 // Combobox, public: |
(...skipping 69 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
89 bool Combobox::GetAccessibleRole(AccessibilityTypes::Role* role) { | 90 bool Combobox::GetAccessibleRole(AccessibilityTypes::Role* role) { |
90 DCHECK(role); | 91 DCHECK(role); |
91 | 92 |
92 *role = AccessibilityTypes::ROLE_COMBOBOX; | 93 *role = AccessibilityTypes::ROLE_COMBOBOX; |
93 return true; | 94 return true; |
94 } | 95 } |
95 | 96 |
96 bool Combobox::GetAccessibleValue(std::wstring* value) { | 97 bool Combobox::GetAccessibleValue(std::wstring* value) { |
97 DCHECK(value); | 98 DCHECK(value); |
98 | 99 |
99 *value = model_->GetItemAt(selected_item_); | 100 *value = UTF16ToWideHack(model_->GetItemAt(selected_item_)); |
100 return true; | 101 return true; |
101 } | 102 } |
102 | 103 |
103 void Combobox::Focus() { | 104 void Combobox::Focus() { |
104 // Forward the focus to the wrapper. | 105 // Forward the focus to the wrapper. |
105 if (native_wrapper_) | 106 if (native_wrapper_) |
106 native_wrapper_->SetFocus(); | 107 native_wrapper_->SetFocus(); |
107 else | 108 else |
108 View::Focus(); // Will focus the RootView window (so we still get | 109 View::Focus(); // Will focus the RootView window (so we still get |
109 // keyboard messages). | 110 // keyboard messages). |
110 } | 111 } |
111 | 112 |
112 void Combobox::ViewHierarchyChanged(bool is_add, View* parent, | 113 void Combobox::ViewHierarchyChanged(bool is_add, View* parent, |
113 View* child) { | 114 View* child) { |
114 if (is_add && !native_wrapper_ && GetWidget()) { | 115 if (is_add && !native_wrapper_ && GetWidget()) { |
115 native_wrapper_ = NativeComboboxWrapper::CreateWrapper(this); | 116 native_wrapper_ = NativeComboboxWrapper::CreateWrapper(this); |
116 AddChildView(native_wrapper_->GetView()); | 117 AddChildView(native_wrapper_->GetView()); |
117 } | 118 } |
118 } | 119 } |
119 | 120 |
120 std::string Combobox::GetClassName() const { | 121 std::string Combobox::GetClassName() const { |
121 return kViewClassName; | 122 return kViewClassName; |
122 } | 123 } |
123 | 124 |
124 } // namespace views | 125 } // namespace views |
OLD | NEW |