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

Unified 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, 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 side-by-side diff with in-line comments
Download patch
« no previous file with comments | « views/controls/listbox/listbox.h ('k') | views/controls/listbox/native_listbox_win.h » ('j') | no next file with comments »
Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
Index: views/controls/listbox/listbox.cc
===================================================================
--- views/controls/listbox/listbox.cc (revision 0)
+++ views/controls/listbox/listbox.cc (revision 0)
@@ -0,0 +1,58 @@
+// Copyright (c) 2010 The Chromium Authors. All rights reserved.
+// Use of this source code is governed by a BSD-style license that can be
+// found in the LICENSE file.
+
+#include "views/controls/listbox/listbox.h"
+
+#include "views/controls/listbox/native_listbox_wrapper.h"
+#include "views/controls/native/native_view_host.h"
+#include "views/fill_layout.h"
+
+namespace views {
+
+// Listbox ------------------------------------------------------------------
+
+Listbox::Listbox(
+ const std::vector<string16>& strings, Listbox::Listener* listener)
+ : strings_(strings),
+ listener_(listener),
+ native_wrapper_(NULL) {
+ SetLayoutManager(new FillLayout());
+}
+
+Listbox::~Listbox() {
+}
+
+int Listbox::GetRowCount() const {
+ return static_cast<int>(strings_.size());
+}
+
+int Listbox::SelectedRow() const {
+ if (!native_wrapper_)
+ return -1;
+ return native_wrapper_->SelectedRow();
+}
+
+void Listbox::SelectRow(int model_row) {
+ if (!native_wrapper_)
+ return;
+ native_wrapper_->SelectRow(model_row);
+}
+
+void Listbox::ViewHierarchyChanged(bool is_add, View* parent, View* child) {
+ if (is_add && !native_wrapper_ && GetWidget()) {
+ // The native wrapper's lifetime will be managed by the view hierarchy after
+ // we call AddChildView.
+ native_wrapper_ = CreateWrapper();
+ AddChildView(native_wrapper_->GetView());
+ }
+}
+
+////////////////////////////////////////////////////////////////////////////////
+// Listbox, protected:
+
+NativeListboxWrapper* Listbox::CreateWrapper() {
+ return NativeListboxWrapper::CreateNativeWrapper(this, strings_, listener_);
+}
+
+} // namespace views
Property changes on: views\controls\listbox\listbox.cc
___________________________________________________________________
Added: svn:eol-style
+ LF
« 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