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 #ifndef UI_VIEWS_CONTROLS_COMBOBOX_COMBOBOX_H_ | 5 #ifndef UI_VIEWS_CONTROLS_COMBOBOX_COMBOBOX_H_ |
6 #define UI_VIEWS_CONTROLS_COMBOBOX_COMBOBOX_H_ | 6 #define UI_VIEWS_CONTROLS_COMBOBOX_COMBOBOX_H_ |
7 | 7 |
8 #include <string> | 8 #include <string> |
9 | 9 |
10 #include "base/time/time.h" | 10 #include "base/time/time.h" |
(...skipping 61 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
72 int selected_index() const { return selected_index_; } | 72 int selected_index() const { return selected_index_; } |
73 void SetSelectedIndex(int index); | 73 void SetSelectedIndex(int index); |
74 | 74 |
75 // Looks for the first occurrence of |value| in |model()|. If found, selects | 75 // Looks for the first occurrence of |value| in |model()|. If found, selects |
76 // the found index and returns true. Otherwise simply noops and returns false. | 76 // the found index and returns true. Otherwise simply noops and returns false. |
77 bool SelectValue(const base::string16& value); | 77 bool SelectValue(const base::string16& value); |
78 | 78 |
79 ui::ComboboxModel* model() const { return model_; } | 79 ui::ComboboxModel* model() const { return model_; } |
80 | 80 |
81 // Set the accessible name of the combobox. | 81 // Set the accessible name of the combobox. |
82 void SetAccessibleName(const string16& name); | 82 void SetAccessibleName(const base::string16& name); |
83 | 83 |
84 // Visually marks the combobox as having an invalid value selected. | 84 // Visually marks the combobox as having an invalid value selected. |
85 // When invalid, it paints with white text on a red background. | 85 // When invalid, it paints with white text on a red background. |
86 // Callers are responsible for restoring validity with selection changes. | 86 // Callers are responsible for restoring validity with selection changes. |
87 void SetInvalid(bool invalid); | 87 void SetInvalid(bool invalid); |
88 bool invalid() const { return invalid_; } | 88 bool invalid() const { return invalid_; } |
89 | 89 |
90 // Overridden from View: | 90 // Overridden from View: |
91 virtual gfx::Size GetPreferredSize() OVERRIDE; | 91 virtual gfx::Size GetPreferredSize() OVERRIDE; |
92 virtual const char* GetClassName() const OVERRIDE; | 92 virtual const char* GetClassName() const OVERRIDE; |
(...skipping 10 matching lines...) Expand all Loading... |
103 // Overridden from MenuDelegate: | 103 // Overridden from MenuDelegate: |
104 virtual bool IsItemChecked(int id) const OVERRIDE; | 104 virtual bool IsItemChecked(int id) const OVERRIDE; |
105 virtual bool IsCommandEnabled(int id) const OVERRIDE; | 105 virtual bool IsCommandEnabled(int id) const OVERRIDE; |
106 virtual void ExecuteCommand(int id) OVERRIDE; | 106 virtual void ExecuteCommand(int id) OVERRIDE; |
107 virtual bool GetAccelerator(int id, ui::Accelerator* accelerator) OVERRIDE; | 107 virtual bool GetAccelerator(int id, ui::Accelerator* accelerator) OVERRIDE; |
108 | 108 |
109 // Overridden from PrefixDelegate: | 109 // Overridden from PrefixDelegate: |
110 virtual int GetRowCount() OVERRIDE; | 110 virtual int GetRowCount() OVERRIDE; |
111 virtual int GetSelectedRow() OVERRIDE; | 111 virtual int GetSelectedRow() OVERRIDE; |
112 virtual void SetSelectedRow(int row) OVERRIDE; | 112 virtual void SetSelectedRow(int row) OVERRIDE; |
113 virtual string16 GetTextForRow(int row) OVERRIDE; | 113 virtual base::string16 GetTextForRow(int row) OVERRIDE; |
114 | 114 |
115 // Overriden from ComboboxModelObserver: | 115 // Overriden from ComboboxModelObserver: |
116 virtual void OnModelChanged() OVERRIDE; | 116 virtual void OnModelChanged() OVERRIDE; |
117 | 117 |
118 // Overriden from ButtonListener: | 118 // Overriden from ButtonListener: |
119 virtual void ButtonPressed(Button* sender, const ui::Event& event) OVERRIDE; | 119 virtual void ButtonPressed(Button* sender, const ui::Event& event) OVERRIDE; |
120 | 120 |
121 private: | 121 private: |
122 FRIEND_TEST_ALL_PREFIXES(ComboboxTest, Click); | 122 FRIEND_TEST_ALL_PREFIXES(ComboboxTest, Click); |
123 FRIEND_TEST_ALL_PREFIXES(ComboboxTest, NotifyOnClickWithMouse); | 123 FRIEND_TEST_ALL_PREFIXES(ComboboxTest, NotifyOnClickWithMouse); |
(...skipping 37 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
161 // Our listener. Not owned. Notified when the selected index change. | 161 // Our listener. Not owned. Notified when the selected index change. |
162 ComboboxListener* listener_; | 162 ComboboxListener* listener_; |
163 | 163 |
164 // The current selected index; -1 and means no selection. | 164 // The current selected index; -1 and means no selection. |
165 int selected_index_; | 165 int selected_index_; |
166 | 166 |
167 // True when the selection is visually denoted as invalid. | 167 // True when the selection is visually denoted as invalid. |
168 bool invalid_; | 168 bool invalid_; |
169 | 169 |
170 // The accessible name of this combobox. | 170 // The accessible name of this combobox. |
171 string16 accessible_name_; | 171 base::string16 accessible_name_; |
172 | 172 |
173 // A helper used to select entries by keyboard input. | 173 // A helper used to select entries by keyboard input. |
174 scoped_ptr<PrefixSelector> selector_; | 174 scoped_ptr<PrefixSelector> selector_; |
175 | 175 |
176 // The disclosure arrow next to the currently selected item from the list. | 176 // The disclosure arrow next to the currently selected item from the list. |
177 const gfx::ImageSkia* disclosure_arrow_; | 177 const gfx::ImageSkia* disclosure_arrow_; |
178 | 178 |
179 // Responsible for showing the context menu. | 179 // Responsible for showing the context menu. |
180 scoped_ptr<MenuRunner> dropdown_list_menu_runner_; | 180 scoped_ptr<MenuRunner> dropdown_list_menu_runner_; |
181 | 181 |
(...skipping 26 matching lines...) Expand all Loading... |
208 // The base View takes the ownerships of these as child views. | 208 // The base View takes the ownerships of these as child views. |
209 CustomButton* text_button_; | 209 CustomButton* text_button_; |
210 CustomButton* arrow_button_; | 210 CustomButton* arrow_button_; |
211 | 211 |
212 DISALLOW_COPY_AND_ASSIGN(Combobox); | 212 DISALLOW_COPY_AND_ASSIGN(Combobox); |
213 }; | 213 }; |
214 | 214 |
215 } // namespace views | 215 } // namespace views |
216 | 216 |
217 #endif // UI_VIEWS_CONTROLS_COMBOBOX_COMBOBOX_H_ | 217 #endif // UI_VIEWS_CONTROLS_COMBOBOX_COMBOBOX_H_ |
OLD | NEW |