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

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

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
« no previous file with comments | « no previous file | views/examples/combobox_example.cc » ('j') | no next file with comments »
Toggle Intra-line Diffs ('i') | Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
OLDNEW
1 // Copyright (c) 2010 The Chromium Authors. All rights reserved. 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 2 // Use of this source code is governed by a BSD-style license that can be
3 // found in the LICENSE file. 3 // found in the LICENSE file.
4 4
5 #ifndef VIEWS_EXAMPLES_COMBOBOX_EXAMPLE_H_ 5 #ifndef VIEWS_EXAMPLES_COMBOBOX_EXAMPLE_H_
6 #define VIEWS_EXAMPLES_COMBOBOX_EXAMPLE_H_ 6 #define VIEWS_EXAMPLES_COMBOBOX_EXAMPLE_H_
7 #pragma once 7 #pragma once
8 8
9 #include "base/string_util.h" 9 #include "base/compiler_specific.h"
10 #include "base/utf_string_conversions.h"
11 #include "ui/base/models/combobox_model.h"
12 #include "views/controls/combobox/combobox.h" 10 #include "views/controls/combobox/combobox.h"
13 #include "views/examples/example_base.h" 11 #include "views/examples/example_base.h"
14 #include "views/fill_layout.h" 12 #include "views/fill_layout.h"
15 13
16 using ui::ComboboxModel; // TODO(beng): remove
17
18 namespace examples { 14 namespace examples {
19 15
20 // ComboboxExample
21 class ComboboxExample : public ExampleBase, public views::Combobox::Listener { 16 class ComboboxExample : public ExampleBase, public views::Combobox::Listener {
oshima 2011/01/24 04:17:23 move Combobox::Listener to next line
tfarina 2011/01/24 12:23:53 Done.
22 public: 17 public:
23 explicit ComboboxExample(ExamplesMain* main) : ExampleBase(main) { 18 explicit ComboboxExample(ExamplesMain* main);
24 combobox_ = new views::Combobox(new ComboboxModelExample()); 19 virtual ~ComboboxExample();
25 combobox_->set_listener(this);
26 combobox_->SetSelectedItem(3);
27 }
28 virtual ~ComboboxExample() {}
29 20
30 virtual std::wstring GetExampleTitle() { 21 // Overridden from ExampleBase:
31 return L"Combo Box"; 22 virtual std::wstring GetExampleTitle() OVERRIDE;
32 } 23 virtual void CreateExampleView(views::View* container) OVERRIDE;
33
34 virtual void CreateExampleView(views::View* container) {
35 container->SetLayoutManager(new views::FillLayout);
36 container->AddChildView(combobox_);
37 }
38 24
39 private: 25 private:
40 // An sample combobox model that generates list of "Item <index>". 26 // Overridden from views::Combobox::Listener:
41 class ComboboxModelExample : public ComboboxModel {
42 public:
43 ComboboxModelExample() {}
44 virtual ~ComboboxModelExample() {}
45
46 virtual int GetItemCount() {
47 return 10;
48 }
49
50 virtual string16 GetItemAt(int index) {
51 return WideToUTF16Hack(StringPrintf(L"Item %d", index));
52 }
53
54 private:
55 DISALLOW_COPY_AND_ASSIGN(ComboboxModelExample);
56 };
57
58 // Lister implementation.
59 virtual void ItemChanged(views::Combobox* combo_box, 27 virtual void ItemChanged(views::Combobox* combo_box,
60 int prev_index, 28 int prev_index,
61 int new_index) { 29 int new_index) OVERRIDE;
62 PrintStatus(L"Selected: index=%d, label=%ls",
63 new_index, UTF16ToWideHack(
64 combo_box->model()->GetItemAt(new_index)).c_str());
65 }
66 30
67 // This test only control. 31 // This test only control.
68 views::Combobox* combobox_; 32 views::Combobox* combobox_;
69 33
70 DISALLOW_COPY_AND_ASSIGN(ComboboxExample); 34 DISALLOW_COPY_AND_ASSIGN(ComboboxExample);
71 }; 35 };
72 36
73 } // namespace examples 37 } // namespace examples
74 38
75 #endif // VIEWS_EXAMPLES_COMBOBOX_EXAMPLE_H_ 39 #endif // VIEWS_EXAMPLES_COMBOBOX_EXAMPLE_H_
OLDNEW
« no previous file with comments | « no previous file | views/examples/combobox_example.cc » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698