OLD | NEW |
1 // Copyright (c) 2009 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_SLIDER_EXAMPLE_H_ | 5 #ifndef VIEWS_EXAMPLES_SLIDER_EXAMPLE_H_ |
6 #define VIEWS_EXAMPLES_SLIDER_EXAMPLE_H_ | 6 #define VIEWS_EXAMPLES_SLIDER_EXAMPLE_H_ |
7 #pragma once | 7 #pragma once |
8 | 8 |
| 9 #include <string> |
| 10 |
| 11 #include "base/basictypes.h" |
| 12 #include "base/compiler_specific.h" |
9 #include "views/controls/slider/slider.h" | 13 #include "views/controls/slider/slider.h" |
10 #include "views/examples/example_base.h" | 14 #include "views/examples/example_base.h" |
11 #include "views/fill_layout.h" | |
12 | 15 |
13 namespace examples { | 16 namespace examples { |
14 | 17 |
15 // SliderExample demonstrates how to use the Slider class. | 18 // SliderExample demonstrates how to use the Slider class. |
16 class SliderExample : public ExampleBase, views::SliderListener { | 19 class SliderExample : public ExampleBase, public views::SliderListener { |
17 public: | 20 public: |
18 explicit SliderExample(ExamplesMain* main) : ExampleBase(main) { | 21 explicit SliderExample(ExamplesMain* main); |
19 } | 22 virtual ~SliderExample(); |
20 | 23 |
21 virtual ~SliderExample() {} | 24 // Overridden from ExampleBase: |
22 | 25 virtual std::wstring GetExampleTitle() OVERRIDE; |
23 virtual std::wstring GetExampleTitle() { | 26 virtual void CreateExampleView(views::View* container) OVERRIDE; |
24 return L"Slider"; | |
25 } | |
26 | |
27 virtual void CreateExampleView(views::View* container) { | |
28 const double min = 0.0; | |
29 const double max = 100.0; | |
30 const double step = 1.0; | |
31 const views::Slider::StyleFlags style = | |
32 views::Slider::STYLE_DRAW_VALUE; | |
33 slider_ = new views::Slider(min, max, step, style, this); | |
34 | |
35 container->SetLayoutManager(new views::FillLayout); | |
36 container->AddChildView(slider_); | |
37 } | |
38 | 27 |
39 private: | 28 private: |
40 virtual void SliderValueChanged(views::Slider* sender) { | 29 // Overridden from views::SliderListener: |
41 PrintStatus(L"Value: %.1f", sender->value()); | 30 virtual void SliderValueChanged(views::Slider* sender) OVERRIDE; |
42 } | |
43 | 31 |
44 views::Slider* slider_; | 32 views::Slider* slider_; |
45 | 33 |
46 DISALLOW_COPY_AND_ASSIGN(SliderExample); | 34 DISALLOW_COPY_AND_ASSIGN(SliderExample); |
47 }; | 35 }; |
48 | 36 |
49 } // namespace examples | 37 } // namespace examples |
50 | 38 |
51 #endif // VIEWS_EXAMPLES_SLIDER_EXAMPLE_H_ | 39 #endif // VIEWS_EXAMPLES_SLIDER_EXAMPLE_H_ |
52 | |
OLD | NEW |