diff options
author | sky@chromium.org <sky@chromium.org@0039d316-1c4b-4281-b951-d872f2087c98> | 2009-09-17 22:28:22 +0000 |
---|---|---|
committer | sky@chromium.org <sky@chromium.org@0039d316-1c4b-4281-b951-d872f2087c98> | 2009-09-17 22:28:22 +0000 |
commit | ae1a5145ea0b24a56b808b5b249c4b3910e81165 (patch) | |
tree | 8ddcae2154cc5e9a53ed19378f007426859a5e5b /views/controls/slider/slider.h | |
parent | 8a7bcb02f938026aba0b7978818f7ae39688ff1a (diff) | |
download | chromium_src-ae1a5145ea0b24a56b808b5b249c4b3910e81165.zip chromium_src-ae1a5145ea0b24a56b808b5b249c4b3910e81165.tar.gz chromium_src-ae1a5145ea0b24a56b808b5b249c4b3910e81165.tar.bz2 |
Lands http://codereview.chromium.org/211002 for Charlie:
Add touchpad speed factor setting to Chrome OS touchpad settings page.
Created slider widget with native gtk widget.
TEST=none
BUG=none
Review URL: http://codereview.chromium.org/209016
git-svn-id: svn://svn.chromium.org/chrome/trunk/src@26511 0039d316-1c4b-4281-b951-d872f2087c98
Diffstat (limited to 'views/controls/slider/slider.h')
-rw-r--r-- | views/controls/slider/slider.h | 111 |
1 files changed, 111 insertions, 0 deletions
diff --git a/views/controls/slider/slider.h b/views/controls/slider/slider.h new file mode 100644 index 0000000..2e44d8a --- /dev/null +++ b/views/controls/slider/slider.h @@ -0,0 +1,111 @@ +// 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_CONTROLS_SLIDER_SLIDER_H_ +#define VIEWS_CONTROLS_SLIDER_SLIDER_H_ + +#if defined(OS_LINUX) +#include <gdk/gdk.h> +#endif + +#include <string> + +#include "base/basictypes.h" +#include "views/view.h" + +namespace views { + +class NativeSliderWrapper; +class Slider; + +// An interface implemented by an object to let it know that the slider value +// was changed. +class SliderListener { + public: + virtual void SliderValueChanged(Slider* sender) = 0; +}; + +// This class implements a ChromeView that wraps a native slider. +class Slider : public View { + public: + // The slider's class name. + static const char kViewClassName[]; + + enum StyleFlags { + STYLE_HORIZONTAL = 0, // Horizontal is default type. + STYLE_VERTICAL = 1<<0, + STYLE_DRAW_VALUE = 1<<1, // Display current value next to the slider. + STYLE_ONE_DIGIT = 1<<2, // 1 decimal place of precision for value. + STYLE_TWO_DIGITS = 1<<3, // 2 decimal places of precision for value. + STYLE_UPDATE_ON_RELEASE = 1<<4, // The slider will only notify value + // changed on release of mouse + }; + + Slider(); + Slider(double min, double max, double step, StyleFlags style, + SliderListener* listener); + virtual ~Slider(); + + // Cause the slider to notify the listener that the value has changed. + virtual void NotifyValueChanged(); + + // Gets/Sets the value in the slider. + const double value() const { return value_; } + void SetValue(double value); + + // Accessor for |style_|. + StyleFlags style() const { return style_; } + + // Accessor for |min_|. + const double min() const { return min_; } + + // Accessor for |max_|. + const double max() const { return max_; } + + // Accessor for |step_|. + const double step() const { return step_; } + + // Overridden from View: + virtual void Layout(); + virtual gfx::Size GetPreferredSize(); + virtual bool IsFocusable() const; + virtual void SetEnabled(bool enabled); + + protected: + virtual void Focus(); + virtual void ViewHierarchyChanged(bool is_add, View* parent, View* child); + virtual std::string GetClassName() const; + + // Creates a new native wrapper properly initialized and returns it. Ownership + // is passed to the caller. + NativeSliderWrapper* CreateWrapper(); + + private: + // The object that actually implements the native slider. + NativeSliderWrapper* native_wrapper_; + + // The slider's listener. Notified when slider value changed. + SliderListener* listener_; + + // The mask of style options for this Slider. + StyleFlags style_; + + // The minimum value of the slider. + double min_; + + // The maximum value of the slider. + double max_; + + // The step increment of the slider. + double step_; + + // The value displayed in the slider. + double value_; + + DISALLOW_COPY_AND_ASSIGN(Slider); +}; + +} // namespace views + +#endif // VIEWS_CONTROLS_SLIDER_SLIDER_H_ |