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 "base/macros.h" | 8 #include "base/macros.h" |
9 #include "base/memory/weak_ptr.h" | 9 #include "base/memory/weak_ptr.h" |
10 #include "base/strings/string16.h" | 10 #include "base/strings/string16.h" |
(...skipping 149 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
160 // The current selected index; -1 and means no selection. | 160 // The current selected index; -1 and means no selection. |
161 int selected_index_; | 161 int selected_index_; |
162 | 162 |
163 // True when the selection is visually denoted as invalid. | 163 // True when the selection is visually denoted as invalid. |
164 bool invalid_; | 164 bool invalid_; |
165 | 165 |
166 // The accessible name of this combobox. | 166 // The accessible name of this combobox. |
167 base::string16 accessible_name_; | 167 base::string16 accessible_name_; |
168 | 168 |
169 // A helper used to select entries by keyboard input. | 169 // A helper used to select entries by keyboard input. |
170 scoped_ptr<PrefixSelector> selector_; | 170 std::unique_ptr<PrefixSelector> selector_; |
171 | 171 |
172 // Adapts a ComboboxModel for use by a views MenuRunner. | 172 // Adapts a ComboboxModel for use by a views MenuRunner. |
173 scoped_ptr<ui::MenuModel> menu_model_adapter_; | 173 std::unique_ptr<ui::MenuModel> menu_model_adapter_; |
174 | 174 |
175 // Like MenuButton, we use a time object in order to keep track of when the | 175 // Like MenuButton, we use a time object in order to keep track of when the |
176 // combobox was closed. The time is used for simulating menu behavior; that | 176 // combobox was closed. The time is used for simulating menu behavior; that |
177 // is, if the menu is shown and the button is pressed, we need to close the | 177 // is, if the menu is shown and the button is pressed, we need to close the |
178 // menu. There is no clean way to get the second click event because the | 178 // menu. There is no clean way to get the second click event because the |
179 // menu is displayed using a modal loop and, unlike regular menus in Windows, | 179 // menu is displayed using a modal loop and, unlike regular menus in Windows, |
180 // the button is not part of the displayed menu. | 180 // the button is not part of the displayed menu. |
181 base::Time closed_time_; | 181 base::Time closed_time_; |
182 | 182 |
183 // The maximum dimensions of the content in the dropdown. | 183 // The maximum dimensions of the content in the dropdown. |
184 gfx::Size content_size_; | 184 gfx::Size content_size_; |
185 | 185 |
186 // The painters or images that are used when |style_| is STYLE_BUTTONS. The | 186 // The painters or images that are used when |style_| is STYLE_BUTTONS. The |
187 // first index means the state of unfocused or focused. | 187 // first index means the state of unfocused or focused. |
188 // The images are owned by ResourceBundle. | 188 // The images are owned by ResourceBundle. |
189 scoped_ptr<Painter> body_button_painters_[2][Button::STATE_COUNT]; | 189 std::unique_ptr<Painter> body_button_painters_[2][Button::STATE_COUNT]; |
190 std::vector<const gfx::ImageSkia*> | 190 std::vector<const gfx::ImageSkia*> |
191 menu_button_images_[2][Button::STATE_COUNT]; | 191 menu_button_images_[2][Button::STATE_COUNT]; |
192 | 192 |
193 // The transparent buttons to handle events and render buttons. These are | 193 // The transparent buttons to handle events and render buttons. These are |
194 // placed on top of this combobox as child views, accept event and manage the | 194 // placed on top of this combobox as child views, accept event and manage the |
195 // button states. These are not rendered but when |style_| is | 195 // button states. These are not rendered but when |style_| is |
196 // STYLE_NOTIFY_ON_CLICK, a Combobox renders the button images according to | 196 // STYLE_NOTIFY_ON_CLICK, a Combobox renders the button images according to |
197 // these button states. | 197 // these button states. |
198 // The base View takes the ownerships of these as child views. | 198 // The base View takes the ownerships of these as child views. |
199 CustomButton* text_button_; | 199 CustomButton* text_button_; |
200 CustomButton* arrow_button_; | 200 CustomButton* arrow_button_; |
201 | 201 |
202 // Set while the dropdown is showing. Ensures the menu is closed if |this| is | 202 // Set while the dropdown is showing. Ensures the menu is closed if |this| is |
203 // destroyed. | 203 // destroyed. |
204 scoped_ptr<views::MenuRunner> menu_runner_; | 204 std::unique_ptr<views::MenuRunner> menu_runner_; |
205 | 205 |
206 // Used for making calbacks. | 206 // Used for making calbacks. |
207 base::WeakPtrFactory<Combobox> weak_ptr_factory_; | 207 base::WeakPtrFactory<Combobox> weak_ptr_factory_; |
208 | 208 |
209 DISALLOW_COPY_AND_ASSIGN(Combobox); | 209 DISALLOW_COPY_AND_ASSIGN(Combobox); |
210 }; | 210 }; |
211 | 211 |
212 } // namespace views | 212 } // namespace views |
213 | 213 |
214 #endif // UI_VIEWS_CONTROLS_COMBOBOX_COMBOBOX_H_ | 214 #endif // UI_VIEWS_CONTROLS_COMBOBOX_COMBOBOX_H_ |
OLD | NEW |