summaryrefslogtreecommitdiffstats
path: root/views/examples
diff options
context:
space:
mode:
authorsatorux@chromium.org <satorux@chromium.org@0039d316-1c4b-4281-b951-d872f2087c98>2009-12-10 02:18:29 +0000
committersatorux@chromium.org <satorux@chromium.org@0039d316-1c4b-4281-b951-d872f2087c98>2009-12-10 02:18:29 +0000
commit07ec104f30de62ac6114636eddb231df59021d34 (patch)
tree004794c622430c2562a31d7055c5a0fe19e275b9 /views/examples
parente5856a7a015a8a4d790b51136881a32364ee912a (diff)
downloadchromium_src-07ec104f30de62ac6114636eddb231df59021d34.zip
chromium_src-07ec104f30de62ac6114636eddb231df59021d34.tar.gz
chromium_src-07ec104f30de62ac6114636eddb231df59021d34.tar.bz2
Add views/examples/slider_example.h
The example demonstrates how to use the Slider class. BUG=none TEST=manually Committed: http://src.chromium.org/viewvc/chrome?view=rev&revision=34142 Review URL: http://codereview.chromium.org/466055 git-svn-id: svn://svn.chromium.org/chrome/trunk/src@34223 0039d316-1c4b-4281-b951-d872f2087c98
Diffstat (limited to 'views/examples')
-rw-r--r--views/examples/examples_main.cc14
-rw-r--r--views/examples/slider_example.h51
2 files changed, 63 insertions, 2 deletions
diff --git a/views/examples/examples_main.cc b/views/examples/examples_main.cc
index 5aa3279..0b8b7b1 100644
--- a/views/examples/examples_main.cc
+++ b/views/examples/examples_main.cc
@@ -16,9 +16,13 @@
#include "views/examples/message_box_example.h"
#include "views/examples/radio_button_example.h"
#include "views/examples/scroll_view_example.h"
+// Slider is not yet ported to Windows.
+#if defined(OS_LINUX)
+#include "views/examples/slider_example.h"
+#endif
#include "views/examples/tabbed_pane_example.h"
#if defined(OS_WIN)
-// TableView and TableView2 are not yet ported to Linux.
+// TableView is not yet ported to Linux.
#include "views/examples/table_example.h"
#endif
#include "views/examples/table2_example.h"
@@ -79,7 +83,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 +127,12 @@ void ExamplesMain::Run() {
tabbed_pane->AddTab(widget_example.GetExampleTitle(),
widget_example.GetExampleView());
+#if defined(OS_LINUX)
+ examples::SliderExample slider_example(this);
+ tabbed_pane->AddTab(slider_example.GetExampleTitle(),
+ slider_example.GetExampleView());
+#endif
+
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_
+