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

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

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 | « views/controls/listbox/listbox.h ('k') | views/controls/listbox/native_listbox_win.h » ('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 #include "views/controls/listbox/listbox.h"
6
7 #include "views/controls/listbox/native_listbox_wrapper.h"
8 #include "views/controls/native/native_view_host.h"
9 #include "views/fill_layout.h"
10
11 namespace views {
12
13 // Listbox ------------------------------------------------------------------
14
15 Listbox::Listbox(
16 const std::vector<string16>& strings, Listbox::Listener* listener)
17 : strings_(strings),
18 listener_(listener),
19 native_wrapper_(NULL) {
20 SetLayoutManager(new FillLayout());
21 }
22
23 Listbox::~Listbox() {
24 }
25
26 int Listbox::GetRowCount() const {
27 return static_cast<int>(strings_.size());
28 }
29
30 int Listbox::SelectedRow() const {
31 if (!native_wrapper_)
32 return -1;
33 return native_wrapper_->SelectedRow();
34 }
35
36 void Listbox::SelectRow(int model_row) {
37 if (!native_wrapper_)
38 return;
39 native_wrapper_->SelectRow(model_row);
40 }
41
42 void Listbox::ViewHierarchyChanged(bool is_add, View* parent, View* child) {
43 if (is_add && !native_wrapper_ && GetWidget()) {
44 // The native wrapper's lifetime will be managed by the view hierarchy after
45 // we call AddChildView.
46 native_wrapper_ = CreateWrapper();
47 AddChildView(native_wrapper_->GetView());
48 }
49 }
50
51 ////////////////////////////////////////////////////////////////////////////////
52 // Listbox, protected:
53
54 NativeListboxWrapper* Listbox::CreateWrapper() {
55 return NativeListboxWrapper::CreateNativeWrapper(this, strings_, listener_);
56 }
57
58 } // namespace views
OLDNEW
« no previous file with comments | « views/controls/listbox/listbox.h ('k') | views/controls/listbox/native_listbox_win.h » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698