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

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

Issue 113991: Make Combobox portable (Closed) Base URL: svn://svn.chromium.org/chrome/trunk/src/
Patch Set: '' Created 11 years, 6 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 | Annotate | Revision Log
« no previous file with comments | « views/controls/combo_box.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
(Empty)
1 // Copyright (c) 2006-2008 The Chromium Authors. All rights reserved.
2 // Use of this source code is governed by a BSD-style license that can be
3 // found in the LICENSE file.
4
5 #ifndef VIEWS_CONTROLS_COMBOBOX_COMBOBOX_H_
6 #define VIEWS_CONTROLS_COMBOBOX_COMBOBOX_H_
7
8 #include "views/view.h"
9
10 namespace views {
11
12 class NativeComboboxWrapper;
13
14 // A non-editable combo-box.
15 class Combobox : public View {
16 public:
17 // The combobox's class name.
18 static const char kViewClassName[];
19
20 class Model {
21 public:
22 // Return the number of items in the combo box.
23 virtual int GetItemCount(Combobox* source) = 0;
24
25 // Return the string that should be used to represent a given item.
26 virtual std::wstring GetItemAt(Combobox* source, int index) = 0;
27 };
28
29 class Listener {
30 public:
31 // This is invoked once the selected item changed.
32 virtual void ItemChanged(Combobox* combo_box,
33 int prev_index,
34 int new_index) = 0;
35 };
36
37 // |model| is not owned by the combo box.
38 explicit Combobox(Model* model);
39 virtual ~Combobox();
40
41 // Register |listener| for item change events.
42 void set_listener(Listener* listener) {
43 listener_ = listener;
44 }
45
46 // Inform the combo box that its model changed.
47 void ModelChanged();
48
49 // Gets/Sets the selected item.
50 int selected_item() const { return selected_item_; };
51 void SetSelectedItem(int index);
52
53 // Called when the combo box's selection is changed by the user.
54 void SelectionChanged();
55
56 // Accessor for |model_|.
57 Model* model() const { return model_; }
58
59 // Overridden from View:
60 virtual gfx::Size GetPreferredSize();
61 virtual void Layout();
62 virtual void SetEnabled(bool enabled);
63 virtual bool OverrideAccelerator(const Accelerator& accelerator);
64
65 protected:
66 virtual void Focus();
67 virtual void ViewHierarchyChanged(bool is_add, View* parent,
68 View* child);
69 virtual std::string GetClassName() const;
70
71 private:
72 // The object that actually implements the native combobox.
73 NativeComboboxWrapper* native_wrapper_;
74
75 // Our model.
76 Model* model_;
77
78 // Item change listener.
79 Listener* listener_;
80
81 // The current selection.
82 int selected_item_;
83
84 DISALLOW_COPY_AND_ASSIGN(Combobox);
85 };
86
87 } // namespace views
88
89 #endif // VIEWS_CONTROLS_COMBOBOX_COMBOBOX_H_
OLDNEW
« no previous file with comments | « views/controls/combo_box.cc ('k') | views/controls/combobox/combobox.cc » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698