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

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

Issue 8607001: views: Factor out Listener from Combobox into its own header file. (Closed) Base URL: svn://svn.chromium.org/chrome/trunk/src
Patch Set: sky review Created 9 years, 1 month 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 | Annotate | Revision Log
« no previous file with comments | « ui/views/examples/text_example.cc ('k') | views/controls/combobox/combobox.cc » ('j') | no next file with comments »
Toggle Intra-line Diffs ('i') | Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
OLDNEW
1 // Copyright (c) 2011 The Chromium Authors. All rights reserved. 1 // Copyright (c) 2011 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 VIEWS_CONTROLS_COMBOBOX_COMBOBOX_H_ 5 #ifndef VIEWS_CONTROLS_COMBOBOX_COMBOBOX_H_
6 #define VIEWS_CONTROLS_COMBOBOX_COMBOBOX_H_ 6 #define VIEWS_CONTROLS_COMBOBOX_COMBOBOX_H_
7 #pragma once 7 #pragma once
8 8
9 #include <string> 9 #include <string>
10 10
11 #include "ui/gfx/native_widget_types.h" 11 #include "ui/gfx/native_widget_types.h"
12 #include "views/controls/combobox/native_combobox_wrapper.h" 12 #include "views/controls/combobox/native_combobox_wrapper.h"
13 #include "views/view.h" 13 #include "views/view.h"
14 14
15 namespace ui { 15 namespace ui {
16 class ComboboxModel; 16 class ComboboxModel;
17 } 17 }
18 18
19 namespace views { 19 namespace views {
20 20
21 class ComboboxListener;
22
21 // A non-editable combo-box (aka a drop-down list) 23 // A non-editable combo-box (aka a drop-down list)
22 class VIEWS_EXPORT Combobox : public View { 24 class VIEWS_EXPORT Combobox : public View {
23 public: 25 public:
24 // The combobox's class name. 26 // The combobox's class name.
25 static const char kViewClassName[]; 27 static const char kViewClassName[];
26 28
27 class Listener {
28 public:
29 // This is invoked once the selected item changed.
30 virtual void ItemChanged(Combobox* combo_box,
31 int prev_index,
32 int new_index) = 0;
33
34 protected:
35 virtual ~Listener() {}
36 };
37
38 // |model| is not owned by the combo box. 29 // |model| is not owned by the combo box.
39 explicit Combobox(ui::ComboboxModel* model); 30 explicit Combobox(ui::ComboboxModel* model);
40 virtual ~Combobox(); 31 virtual ~Combobox();
41 32
42 // Register |listener| for item change events. 33 // Register |listener| for item change events.
43 void set_listener(Listener* listener) { 34 void set_listener(ComboboxListener* listener) {
44 listener_ = listener; 35 listener_ = listener;
45 } 36 }
46 37
47 // Inform the combo box that its model changed. 38 // Inform the combo box that its model changed.
48 void ModelChanged(); 39 void ModelChanged();
49 40
50 // Gets/Sets the selected item. 41 // Gets/Sets the selected item.
51 int selected_item() const { return selected_item_; } 42 int selected_item() const { return selected_item_; }
52 void SetSelectedItem(int index); 43 void SetSelectedItem(int index);
53 44
(...skipping 33 matching lines...) Expand 10 before | Expand all | Expand 10 after
87 View* child) OVERRIDE; 78 View* child) OVERRIDE;
88 virtual std::string GetClassName() const OVERRIDE; 79 virtual std::string GetClassName() const OVERRIDE;
89 80
90 // The object that actually implements the native combobox. 81 // The object that actually implements the native combobox.
91 NativeComboboxWrapper* native_wrapper_; 82 NativeComboboxWrapper* native_wrapper_;
92 83
93 private: 84 private:
94 // Our model. 85 // Our model.
95 ui::ComboboxModel* model_; 86 ui::ComboboxModel* model_;
96 87
97 // Item change listener. 88 // The combobox's listener. Notified when the selected item change.
98 Listener* listener_; 89 ComboboxListener* listener_;
99 90
100 // The current selection. 91 // The current selection.
101 int selected_item_; 92 int selected_item_;
102 93
103 // The accessible name of the text field. 94 // The accessible name of the text field.
104 string16 accessible_name_; 95 string16 accessible_name_;
105 96
106 DISALLOW_COPY_AND_ASSIGN(Combobox); 97 DISALLOW_COPY_AND_ASSIGN(Combobox);
107 }; 98 };
108 99
109 } // namespace views 100 } // namespace views
110 101
111 #endif // VIEWS_CONTROLS_COMBOBOX_COMBOBOX_H_ 102 #endif // VIEWS_CONTROLS_COMBOBOX_COMBOBOX_H_
OLDNEW
« no previous file with comments | « ui/views/examples/text_example.cc ('k') | views/controls/combobox/combobox.cc » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698