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

Side by Side Diff: views/examples/combobox_example.cc

Issue 6366008: views: Move implementations of ComboboxExample and SliderExample to source file. (Closed) Base URL: svn://svn.chromium.org/chrome/trunk/src
Patch Set: Slider is only implemented in gtk Created 9 years, 11 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
OLDNEW
(Empty)
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
3 // found in the LICENSE file.
4
5 #include "views/examples/combobox_example.h"
6
7 #include "base/stringprintf.h"
8 #include "base/utf_string_conversions.h"
9 #include "ui/base/models/combobox_model.h"
10 #include "views/fill_layout.h"
11
12 namespace {
13
14 // An sample combobox model that generates list of "Item <index>".
15 class ComboboxModelExample : public ui::ComboboxModel {
16 public:
17 ComboboxModelExample() {}
18 virtual ~ComboboxModelExample() {}
19
20 // Overridden from ui::ComboboxModel:
21 virtual int GetItemCount() OVERRIDE { return 10; }
22
23 // Overridden from ui::ComboboxModel:
24 virtual string16 GetItemAt(int index) OVERRIDE {
25 return WideToUTF16Hack(base::StringPrintf(L"Item %d", index));
26 }
27
28 private:
29 DISALLOW_COPY_AND_ASSIGN(ComboboxModelExample);
30 };
31
32 } // namespace
33
34 namespace examples {
35
36 ComboboxExample::ComboboxExample(ExamplesMain* main) : ExampleBase(main) {
37 }
38
39 ComboboxExample::~ComboboxExample() {
40 }
41
42 std::wstring ComboboxExample::GetExampleTitle() {
43 return L"Combo Box";
44 }
45
46 void ComboboxExample::CreateExampleView(views::View* container) {
47 combobox_ = new views::Combobox(new ComboboxModelExample());
48 combobox_->set_listener(this);
49 combobox_->SetSelectedItem(3);
50
51 container->SetLayoutManager(new views::FillLayout);
52 container->AddChildView(combobox_);
53 }
54
55 void ComboboxExample::ItemChanged(views::Combobox* combo_box,
56 int prev_index,
57 int new_index) {
58 PrintStatus(L"Selected: index=%d, label=%ls",
59 new_index, UTF16ToWideHack(
60 combo_box->model()->GetItemAt(new_index)).c_str());
61 }
62
63 } // namespace examples
OLDNEW

Powered by Google App Engine
This is Rietveld 408576698