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

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

Issue 2815034: Win: Add listbox view. (Closed) Base URL: svn://svn.chromium.org/chrome/trunk/src/
Patch Set: '' Created 10 years, 5 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 | « no previous file | views/controls/listbox/listbox.cc » ('j') | no next file with comments »
Toggle Intra-line Diffs ('i') | Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
Property Changes:
Added: svn:eol-style
+ LF
OLDNEW
(Empty)
1 // Copyright (c) 2010 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_LISTBOX_LISTBOX_H_
6 #define VIEWS_CONTROLS_LISTBOX_LISTBOX_H_
7
8 #include "build/build_config.h"
9
10 #include <string>
11 #include <vector>
12
13 #include "base/string16.h"
14 #include "views/view.h"
15
16 namespace views {
17
18 class NativeListboxWrapper;
19
20 // A Listbox is a view that displays multiple rows of fixed strings.
21 // Exactly one of these strings is shown as selected at all times.
22 class Listbox : public View {
23 public:
24 // An interface implemented by an object to let it know that a listbox
25 // selection has changed.
26 class Listener {
27 public:
28 // This is called if the user changes the current selection of the
29 // listbox.
30 virtual void ListboxSelectionChanged(Listbox* sender) = 0;
31 };
32
33 // Creates a new listbox, given the list of strings. |listener| can be NULL.
34 // Listbox does not take ownership of |listener|.
35 Listbox(const std::vector<string16>& strings, Listbox::Listener* listener);
36 virtual ~Listbox();
37
38 // Returns the number of rows in the table.
39 int GetRowCount() const;
40
41 // Returns the 0-based index of the currently selected row, or -1 if nothing
42 // is selected. Note that as soon as a row has been selected once, there will
43 // always be a selected row.
44 int SelectedRow() const;
45
46 // Selects the specified row. Note that this does NOT call the listener's
47 // |ListboxSelectionChanged()| method.
48 void SelectRow(int row);
49
50 protected:
51 virtual NativeListboxWrapper* CreateWrapper();
52 virtual void ViewHierarchyChanged(bool is_add, View* parent, View* child);
53
54 private:
55 // Data stored in the listbox.
56 std::vector<string16> strings_;
57
58 // Listens to selection changes.
59 Listbox::Listener* listener_;
60
61 // The object that actually implements the table.
62 NativeListboxWrapper* native_wrapper_;
63
64 DISALLOW_COPY_AND_ASSIGN(Listbox);
65 };
66
67 } // namespace views
68
69 #endif // VIEWS_CONTROLS_LISTBOX_LISTBOX_H_
OLDNEW
« no previous file with comments | « no previous file | views/controls/listbox/listbox.cc » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698