diff options
author | satorux@chromium.org <satorux@chromium.org@0039d316-1c4b-4281-b951-d872f2087c98> | 2009-12-09 05:25:48 +0000 |
---|---|---|
committer | satorux@chromium.org <satorux@chromium.org@0039d316-1c4b-4281-b951-d872f2087c98> | 2009-12-09 05:25:48 +0000 |
commit | a503ce015c2360c620309b6366207ce7a7ab3ecb (patch) | |
tree | 667a493f1acbbed21a6b4f4741ec37ac3c8baeab /views | |
parent | a71ddc37a95308130bb4bf02e3f003595d324415 (diff) | |
download | chromium_src-a503ce015c2360c620309b6366207ce7a7ab3ecb.zip chromium_src-a503ce015c2360c620309b6366207ce7a7ab3ecb.tar.gz chromium_src-a503ce015c2360c620309b6366207ce7a7ab3ecb.tar.bz2 |
Add views/examples/slider_example.h
The example demonstrates how to use the Slider class.
BUG=none
TEST=manually
Review URL: http://codereview.chromium.org/466055
git-svn-id: svn://svn.chromium.org/chrome/trunk/src@34142 0039d316-1c4b-4281-b951-d872f2087c98
Diffstat (limited to 'views')
-rw-r--r-- | views/examples/examples_main.cc | 7 | ||||
-rw-r--r-- | views/examples/slider_example.h | 51 |
2 files changed, 57 insertions, 1 deletions
diff --git a/views/examples/examples_main.cc b/views/examples/examples_main.cc index 5aa3279..5c31786 100644 --- a/views/examples/examples_main.cc +++ b/views/examples/examples_main.cc @@ -16,6 +16,7 @@ #include "views/examples/message_box_example.h" #include "views/examples/radio_button_example.h" #include "views/examples/scroll_view_example.h" +#include "views/examples/slider_example.h" #include "views/examples/tabbed_pane_example.h" #if defined(OS_WIN) // TableView and TableView2 are not yet ported to Linux. @@ -79,7 +80,7 @@ void ExamplesMain::Run() { layout->AddView(status_label_); views::Window* window = - views::Window::CreateChromeWindow(NULL, gfx::Rect(0, 0, 700, 300), this); + views::Window::CreateChromeWindow(NULL, gfx::Rect(0, 0, 750, 300), this); examples::TextfieldExample textfield_example(this); tabbed_pane->AddTab(textfield_example.GetExampleTitle(), @@ -123,6 +124,10 @@ void ExamplesMain::Run() { tabbed_pane->AddTab(widget_example.GetExampleTitle(), widget_example.GetExampleView()); + examples::SliderExample slider_example(this); + tabbed_pane->AddTab(slider_example.GetExampleTitle(), + slider_example.GetExampleView()); + window->Show(); views::AcceleratorHandler accelerator_handler; MessageLoopForUI::current()->Run(&accelerator_handler); diff --git a/views/examples/slider_example.h b/views/examples/slider_example.h new file mode 100644 index 0000000..601e6c1 --- /dev/null +++ b/views/examples/slider_example.h @@ -0,0 +1,51 @@ +// Copyright (c) 2009 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. + +#ifndef VIEWS_EXAMPLES_SLIDER_EXAMPLE_H_ +#define VIEWS_EXAMPLES_SLIDER_EXAMPLE_H_ + +#include "views/controls/slider/slider.h" +#include "views/examples/example_base.h" +#include "views/fill_layout.h" + +namespace examples { + +// SliderExample demonstrates how to use the Slider class. +class SliderExample : public ExampleBase, views::SliderListener { + public: + explicit SliderExample(ExamplesMain* main) : ExampleBase(main) { + } + + virtual ~SliderExample() {} + + virtual std::wstring GetExampleTitle() { + return L"Slider"; + } + + virtual void CreateExampleView(views::View* container) { + const double min = 0.0; + const double max = 100.0; + const double step = 1.0; + const views::Slider::StyleFlags style = + views::Slider::STYLE_DRAW_VALUE; + slider_ = new views::Slider(min, max, step, style, this); + + container->SetLayoutManager(new views::FillLayout); + container->AddChildView(slider_); + } + + private: + virtual void SliderValueChanged(views::Slider* sender) { + PrintStatus(L"Value: %.1f", sender->value()); + } + + views::Slider* slider_; + + DISALLOW_COPY_AND_ASSIGN(SliderExample); +}; + +} // namespace examples + +#endif // VIEWS_EXAMPLES_SLIDER_EXAMPLE_H_ + |