Chromium Code Reviews
chromiumcodereview-hr@appspot.gserviceaccount.com (chromiumcodereview-hr) | Please choose your nickname with Settings | Help | Chromium Project | Gerrit Changes | Sign out
(88)

Side by Side Diff: ui/views/controls/combobox/combobox.h

Issue 2689363004: [Payments] Add combobox support to editors. (Closed)
Patch Set: fix test Created 3 years, 10 months ago
Use n/p to move between diff chunks; N/P to move between comments. Draft comments are only viewable by you.
Jump to:
View unified diff | Download patch
OLDNEW
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"
11 #include "base/time/time.h" 11 #include "base/time/time.h"
12 #include "ui/base/models/combobox_model.h"
12 #include "ui/views/controls/button/button.h" 13 #include "ui/views/controls/button/button.h"
13 #include "ui/views/controls/prefix_delegate.h" 14 #include "ui/views/controls/prefix_delegate.h"
14 15
15 namespace gfx { 16 namespace gfx {
16 class FontList; 17 class FontList;
17 } 18 }
18 19
19 namespace ui { 20 namespace ui {
20 class ComboboxModel;
21 class MenuModel; 21 class MenuModel;
22 } 22 }
23 23
24 namespace views { 24 namespace views {
25 namespace test { 25 namespace test {
26 class ComboboxTestApi; 26 class ComboboxTestApi;
27 } 27 }
28 28
29 class ComboboxListener; 29 class ComboboxListener;
30 class CustomButton; 30 class CustomButton;
(...skipping 18 matching lines...) Expand all
49 public: 49 public:
50 // The style of the combobox. 50 // The style of the combobox.
51 enum Style { 51 enum Style {
52 STYLE_NORMAL, 52 STYLE_NORMAL,
53 STYLE_ACTION, 53 STYLE_ACTION,
54 }; 54 };
55 55
56 // The combobox's class name. 56 // The combobox's class name.
57 static const char kViewClassName[]; 57 static const char kViewClassName[];
58 58
59 // |model| is not owned by the combobox. 59 // |model| is owned by the combobox when using this constructor.
60 explicit Combobox(std::unique_ptr<ui::ComboboxModel> model,
61 Style style = STYLE_NORMAL);
62 // |model| is not owned by the combobox when using this constructor.
60 explicit Combobox(ui::ComboboxModel* model, Style style = STYLE_NORMAL); 63 explicit Combobox(ui::ComboboxModel* model, Style style = STYLE_NORMAL);
61 ~Combobox() override; 64 ~Combobox() override;
62 65
63 static const gfx::FontList& GetFontList(); 66 static const gfx::FontList& GetFontList();
64 67
65 // Sets the listener which will be called when a selection has been made. 68 // Sets the listener which will be called when a selection has been made.
66 void set_listener(ComboboxListener* listener) { listener_ = listener; } 69 void set_listener(ComboboxListener* listener) { listener_ = listener; }
67 70
68 // Informs the combobox that its model changed. 71 // Informs the combobox that its model changed.
69 void ModelChanged(); 72 void ModelChanged();
(...skipping 82 matching lines...) Expand 10 before | Expand all | Expand 10 after
152 gfx::Size GetContentSize() const; 155 gfx::Size GetContentSize() const;
153 156
154 // Handles the clicking event. 157 // Handles the clicking event.
155 void HandleClickEvent(); 158 void HandleClickEvent();
156 159
157 PrefixSelector* GetPrefixSelector(); 160 PrefixSelector* GetPrefixSelector();
158 161
159 // Returns the width of the combobox's arrow container. 162 // Returns the width of the combobox's arrow container.
160 int GetArrowContainerWidth() const; 163 int GetArrowContainerWidth() const;
161 164
162 // Our model. Not owned. 165 // Optionally used to tie the lifetime of the model to this combobox. See
166 // constructor.
167 std::unique_ptr<ui::ComboboxModel> owned_model_;
168
169 // Reference to our model, which may be owned or not.
163 ui::ComboboxModel* model_; 170 ui::ComboboxModel* model_;
164 171
165 // The visual style of this combobox. 172 // The visual style of this combobox.
166 const Style style_; 173 const Style style_;
167 174
168 // Our listener. Not owned. Notified when the selected index change. 175 // Our listener. Not owned. Notified when the selected index change.
169 ComboboxListener* listener_; 176 ComboboxListener* listener_;
170 177
171 // The current selected index; -1 and means no selection. 178 // The current selected index; -1 and means no selection.
172 int selected_index_; 179 int selected_index_;
(...skipping 51 matching lines...) Expand 10 before | Expand all | Expand 10 after
224 231
225 // Used for making calbacks. 232 // Used for making calbacks.
226 base::WeakPtrFactory<Combobox> weak_ptr_factory_; 233 base::WeakPtrFactory<Combobox> weak_ptr_factory_;
227 234
228 DISALLOW_COPY_AND_ASSIGN(Combobox); 235 DISALLOW_COPY_AND_ASSIGN(Combobox);
229 }; 236 };
230 237
231 } // namespace views 238 } // namespace views
232 239
233 #endif // UI_VIEWS_CONTROLS_COMBOBOX_COMBOBOX_H_ 240 #endif // UI_VIEWS_CONTROLS_COMBOBOX_COMBOBOX_H_
OLDNEW

Powered by Google App Engine
This is Rietveld 408576698