| 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 87 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 98 | 98 |
| 99 // Overridden from PrefixDelegate: | 99 // Overridden from PrefixDelegate: |
| 100 int GetRowCount() override; | 100 int GetRowCount() override; |
| 101 int GetSelectedRow() override; | 101 int GetSelectedRow() override; |
| 102 void SetSelectedRow(int row) override; | 102 void SetSelectedRow(int row) override; |
| 103 base::string16 GetTextForRow(int row) override; | 103 base::string16 GetTextForRow(int row) override; |
| 104 | 104 |
| 105 // Overriden from ButtonListener: | 105 // Overriden from ButtonListener: |
| 106 void ButtonPressed(Button* sender, const ui::Event& event) override; | 106 void ButtonPressed(Button* sender, const ui::Event& event) override; |
| 107 | 107 |
| 108 protected: |
| 109 void set_size_to_largest_label(bool size_to_largest_label) { |
| 110 size_to_largest_label_ = size_to_largest_label; |
| 111 } |
| 112 |
| 108 private: | 113 private: |
| 109 friend class test::ComboboxTestApi; | 114 friend class test::ComboboxTestApi; |
| 110 | 115 |
| 111 class ComboboxMenuModelAdapter; | 116 class ComboboxMenuModelAdapter; |
| 112 | 117 |
| 113 // Updates the border according to the current state. | 118 // Updates the border according to the current state. |
| 114 void UpdateBorder(); | 119 void UpdateBorder(); |
| 115 | 120 |
| 116 // Given bounds within our View, this helper mirrors the bounds if necessary. | 121 // Given bounds within our View, this helper mirrors the bounds if necessary. |
| 117 void AdjustBoundsForRTLUI(gfx::Rect* rect) const; | 122 void AdjustBoundsForRTLUI(gfx::Rect* rect) const; |
| (...skipping 79 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 197 CustomButton* text_button_; | 202 CustomButton* text_button_; |
| 198 CustomButton* arrow_button_; | 203 CustomButton* arrow_button_; |
| 199 | 204 |
| 200 // Set while the dropdown is showing. Ensures the menu is closed if |this| is | 205 // Set while the dropdown is showing. Ensures the menu is closed if |this| is |
| 201 // destroyed. | 206 // destroyed. |
| 202 std::unique_ptr<views::MenuRunner> menu_runner_; | 207 std::unique_ptr<views::MenuRunner> menu_runner_; |
| 203 | 208 |
| 204 // The image to be drawn for this combobox's arrow. | 209 // The image to be drawn for this combobox's arrow. |
| 205 gfx::ImageSkia arrow_image_; | 210 gfx::ImageSkia arrow_image_; |
| 206 | 211 |
| 212 // When true, the size of contents is defined by the selected label. |
| 213 // Otherwise, it's defined by the widest label in the menu. If this is set to |
| 214 // true, the parent view must relayout in ChildPreferredSizeChanged(). |
| 215 bool size_to_largest_label_; |
| 216 |
| 207 // Used for making calbacks. | 217 // Used for making calbacks. |
| 208 base::WeakPtrFactory<Combobox> weak_ptr_factory_; | 218 base::WeakPtrFactory<Combobox> weak_ptr_factory_; |
| 209 | 219 |
| 210 DISALLOW_COPY_AND_ASSIGN(Combobox); | 220 DISALLOW_COPY_AND_ASSIGN(Combobox); |
| 211 }; | 221 }; |
| 212 | 222 |
| 213 } // namespace views | 223 } // namespace views |
| 214 | 224 |
| 215 #endif // UI_VIEWS_CONTROLS_COMBOBOX_COMBOBOX_H_ | 225 #endif // UI_VIEWS_CONTROLS_COMBOBOX_COMBOBOX_H_ |
| OLD | NEW |