diff options
author | saintlou@chromium.org <saintlou@chromium.org@0039d316-1c4b-4281-b951-d872f2087c98> | 2011-04-21 15:22:53 +0000 |
---|---|---|
committer | saintlou@chromium.org <saintlou@chromium.org@0039d316-1c4b-4281-b951-d872f2087c98> | 2011-04-21 15:22:53 +0000 |
commit | 0a8f97d33bd031e8b2b4ca6e83cd1cbf5b9f99de (patch) | |
tree | 8a21288ff4dde51fe5317fda53703ed5f1380cab /views/controls | |
parent | dd34cd736e3665cbf28ec29f1a27a8df24f9a357 (diff) | |
download | chromium_src-0a8f97d33bd031e8b2b4ca6e83cd1cbf5b9f99de.zip chromium_src-0a8f97d33bd031e8b2b4ca6e83cd1cbf5b9f99de.tar.gz chromium_src-0a8f97d33bd031e8b2b4ca6e83cd1cbf5b9f99de.tar.bz2 |
remove unused class
BUG=none
TEST=none
Review URL: http://codereview.chromium.org/6880081
Patch from Emmanuel Saint-Loubert <saintlou@chromium.org>.
git-svn-id: svn://svn.chromium.org/chrome/trunk/src@82488 0039d316-1c4b-4281-b951-d872f2087c98
Diffstat (limited to 'views/controls')
-rw-r--r-- | views/controls/slider/native_slider_gtk.cc | 123 | ||||
-rw-r--r-- | views/controls/slider/native_slider_gtk.h | 53 | ||||
-rw-r--r-- | views/controls/slider/native_slider_wrapper.h | 49 | ||||
-rw-r--r-- | views/controls/slider/slider.cc | 116 | ||||
-rw-r--r-- | views/controls/slider/slider.h | 113 |
5 files changed, 0 insertions, 454 deletions
diff --git a/views/controls/slider/native_slider_gtk.cc b/views/controls/slider/native_slider_gtk.cc deleted file mode 100644 index 0fa30b5..0000000 --- a/views/controls/slider/native_slider_gtk.cc +++ /dev/null @@ -1,123 +0,0 @@ -// 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. - -#include <gtk/gtk.h> - -#include "views/controls/slider/native_slider_gtk.h" - -#include "ui/gfx/gtk_util.h" -#include "views/controls/slider/slider.h" - -namespace views { - -//////////////////////////////////////////////////////////////////////////////// -// NativeSliderGtk, public: - -NativeSliderGtk::NativeSliderGtk(Slider* slider) - : slider_(slider) { -} - -NativeSliderGtk::~NativeSliderGtk() { -} - -//////////////////////////////////////////////////////////////////////////////// -// NativeSliderGtk, NativeSliderWrapper implementation: - -void NativeSliderGtk::UpdateEnabled() { - if (!native_view()) - return; - SetEnabled(slider_->IsEnabled()); -} - -double NativeSliderGtk::GetValue() { - if (!native_view()) - return 0; - return gtk_range_get_value(GTK_RANGE(native_view())); -} - -void NativeSliderGtk::SetValue(double value) { - if (!native_view()) - return; - gtk_range_set_value(GTK_RANGE(native_view()), value); -} - -void NativeSliderGtk::SetFocus() { - OnFocus(); -} - -gfx::Size NativeSliderGtk::GetPreferredSize() { - if (!native_view()) - return gfx::Size(); - - if (preferred_size_.IsEmpty()) { - GtkRequisition size_request = { 0, 0 }; - gtk_widget_size_request(native_view(), &size_request); - preferred_size_.SetSize(size_request.width, size_request.height); - } - return preferred_size_; -} - -View* NativeSliderGtk::GetView() { - return this; -} - -gfx::NativeView NativeSliderGtk::GetTestingHandle() const { - return native_view(); -} - -// static -gboolean NativeSliderGtk::OnValueChangedHandler(GtkWidget* entry, - NativeSliderGtk* slider) { - return slider->OnValueChanged(); -} - -gboolean NativeSliderGtk::OnValueChanged() { - slider_->NotifyValueChanged(); - return false; -} -//////////////////////////////////////////////////////////////////////////////// -// NativeSliderGtk, NativeControlGtk overrides: - -void NativeSliderGtk::CreateNativeControl() { - GtkWidget* widget; - if (slider_->style() & Slider::STYLE_VERTICAL) - widget = gtk_vscale_new_with_range(slider_->min(), - slider_->max(), - slider_->step()); - else - widget = gtk_hscale_new_with_range(slider_->min(), - slider_->max(), - slider_->step()); - NativeControlCreated(widget); - - bool drawvalue = slider_->style() & Slider::STYLE_DRAW_VALUE; - gtk_scale_set_draw_value(GTK_SCALE(native_view()), drawvalue); - - int digits = 0; - if (slider_->style() & Slider::STYLE_ONE_DIGIT) - digits = 1; - else if (slider_->style() & Slider::STYLE_TWO_DIGITS) - digits = 2; - gtk_scale_set_digits(GTK_SCALE(native_view()), digits); - - if (slider_->style() & Slider::STYLE_UPDATE_ON_RELEASE) - gtk_range_set_update_policy(GTK_RANGE(native_view()), - GTK_UPDATE_DISCONTINUOUS); -} - -void NativeSliderGtk::NativeControlCreated(GtkWidget* widget) { - NativeControlGtk::NativeControlCreated(widget); - g_signal_connect(widget, "value_changed", - G_CALLBACK(OnValueChangedHandler), this); -} - -//////////////////////////////////////////////////////////////////////////////// -// NativeSliderWrapper, public: - -// static -NativeSliderWrapper* NativeSliderWrapper::CreateWrapper(Slider* field) { - return new NativeSliderGtk(field); -} - -} // namespace views diff --git a/views/controls/slider/native_slider_gtk.h b/views/controls/slider/native_slider_gtk.h deleted file mode 100644 index 36ac81d..0000000 --- a/views/controls/slider/native_slider_gtk.h +++ /dev/null @@ -1,53 +0,0 @@ -// 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_NATIVE_SLIDER_GTK_H_ -#define VIEWS_CONTROLS_SLIDER_NATIVE_SLIDER_GTK_H_ -#pragma once - -#include <gtk/gtk.h> - -#include "views/controls/native_control_gtk.h" -#include "views/controls/slider/native_slider_wrapper.h" - -namespace views { - -class NativeSliderGtk : public NativeControlGtk, - public NativeSliderWrapper { - public: - explicit NativeSliderGtk(Slider* parent); - ~NativeSliderGtk(); - - // Overridden from NativeSliderWrapper: - virtual void UpdateEnabled(); - virtual double GetValue(); - virtual void SetValue(double value); - virtual void SetFocus(); - virtual gfx::Size GetPreferredSize(); - virtual View* GetView(); - virtual gfx::NativeView GetTestingHandle() const; - - // Overridden from NativeControlGtk: - virtual void CreateNativeControl(); - virtual void NativeControlCreated(GtkWidget* widget); - - private: - // The slider we are bound to. - Slider* slider_; - - // The preferred size from the last size_request. See - // NativeButtonGtk::preferred_size_ for more detail why we need this. - gfx::Size preferred_size_; - - // Callback when the slider value changes. - static gboolean OnValueChangedHandler(GtkWidget* entry, - NativeSliderGtk* slider); - gboolean OnValueChanged(); - - DISALLOW_COPY_AND_ASSIGN(NativeSliderGtk); -}; - -} // namespace views - -#endif // VIEWS_CONTROLS_SLIDER_NATIVE_SLIDER_GTK_H_ diff --git a/views/controls/slider/native_slider_wrapper.h b/views/controls/slider/native_slider_wrapper.h deleted file mode 100644 index adfbf21..0000000 --- a/views/controls/slider/native_slider_wrapper.h +++ /dev/null @@ -1,49 +0,0 @@ -// Copyright (c) 2010 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_NATIVE_SLIDER_WRAPPER_H_ -#define VIEWS_CONTROLS_SLIDER_NATIVE_SLIDER_WRAPPER_H_ -#pragma once - -#include "ui/gfx/native_widget_types.h" - -namespace views { - -class Slider; -class View; - -// An interface implemented by an object that provides a platform-native slider. -class NativeSliderWrapper { - public: - // The Slider calls this when it is destroyed to clean up the wrapper object. - virtual ~NativeSliderWrapper() {} - - // Updates the enabled state of the native slider. - virtual void UpdateEnabled() = 0; - - // Gets the value of the slider. - virtual double GetValue() = 0; - - // Sets the value of the slider. - virtual void SetValue(double value) = 0; - - // Sets the focus to the slider. - virtual void SetFocus() = 0; - - // Returns the preferred size of the combobox. - virtual gfx::Size GetPreferredSize() = 0; - - // Retrieves the views::View that hosts the native control. - virtual View* GetView() = 0; - - // Returns a handle to the underlying native view for testing. - virtual gfx::NativeView GetTestingHandle() const = 0; - - // Creates an appropriate NativeSliderWrapper for the platform. - static NativeSliderWrapper* CreateWrapper(Slider* slider); -}; - -} // namespace views - -#endif // VIEWS_CONTROLS_SLIDER_NATIVE_SLIDER_WRAPPER_H_ diff --git a/views/controls/slider/slider.cc b/views/controls/slider/slider.cc deleted file mode 100644 index 70dc13e..0000000 --- a/views/controls/slider/slider.cc +++ /dev/null @@ -1,116 +0,0 @@ -// Copyright (c) 2010 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. - -#include "views/controls/slider/slider.h" - -#include <string> - -#include "views/controls/slider/native_slider_wrapper.h" -#include "views/controls/native/native_view_host.h" -#include "views/widget/widget.h" - -namespace views { - -// static -const char Slider::kViewClassName[] = "views/Slider"; - -///////////////////////////////////////////////////////////////////////////// -// Slider - -Slider::Slider() - : native_wrapper_(NULL), - listener_(NULL), - style_(STYLE_HORIZONTAL) { - SetFocusable(true); -} - -Slider::Slider(double min, double max, double step, StyleFlags style, - SliderListener* listener) - : native_wrapper_(NULL), - listener_(listener), - style_(style), - min_(min), - max_(max), - step_(step) { - SetFocusable(true); -} - -Slider::~Slider() { -} - -void Slider::NotifyValueChanged() { - if (native_wrapper_) - value_ = native_wrapper_->GetValue(); - if (listener_) - listener_->SliderValueChanged(this); -} - -void Slider::SetValue(double value) { - value_ = value; - if (native_wrapper_) - native_wrapper_->SetValue(value); -} - -//////////////////////////////////////////////////////////////////////////////// -// Slider, View overrides: - -void Slider::Layout() { - if (native_wrapper_) { - native_wrapper_->GetView()->SetBoundsRect(GetLocalBounds()); - native_wrapper_->GetView()->Layout(); - } -} - -gfx::Size Slider::GetPreferredSize() { - if (native_wrapper_) - return native_wrapper_->GetPreferredSize(); - return gfx::Size(); -} - -void Slider::SetEnabled(bool enabled) { - View::SetEnabled(enabled); - if (native_wrapper_) - native_wrapper_->UpdateEnabled(); -} - -void Slider::OnFocus() { - if (native_wrapper_) { - // Forward the focus to the wrapper if it exists. - native_wrapper_->SetFocus(); - } else { - // If there is no wrapper, cause the RootView to be focused so that we still - // get keyboard messages. - View::OnFocus(); - } -} - -void Slider::OnPaintFocusBorder(gfx::Canvas* canvas) { - if (NativeViewHost::kRenderNativeControlFocus) - View::OnPaintFocusBorder(canvas); -} - -void Slider::ViewHierarchyChanged(bool is_add, View* parent, View* child) { - if (is_add && !native_wrapper_ && GetWidget()) { - // The native wrapper's lifetime will be managed by the view hierarchy after - // we call AddChildView. - native_wrapper_ = NativeSliderWrapper::CreateWrapper(this); - AddChildView(native_wrapper_->GetView()); - native_wrapper_->UpdateEnabled(); - } -} - -std::string Slider::GetClassName() const { - return kViewClassName; -} - -NativeSliderWrapper* Slider::CreateWrapper() { - NativeSliderWrapper* native_wrapper = - NativeSliderWrapper::CreateWrapper(this); - - native_wrapper->UpdateEnabled(); - - return native_wrapper; -} - -} // namespace views diff --git a/views/controls/slider/slider.h b/views/controls/slider/slider.h deleted file mode 100644 index fe9bfbf..0000000 --- a/views/controls/slider/slider.h +++ /dev/null @@ -1,113 +0,0 @@ -// Copyright (c) 2010 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_ -#pragma once - -#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. - double value() const { return value_; } - void SetValue(double value); - - // Accessor for |style_|. - StyleFlags style() const { return style_; } - - // Accessor for |min_|. - double min() const { return min_; } - - // Accessor for |max_|. - double max() const { return max_; } - - // Accessor for |step_|. - double step() const { return step_; } - - // Overridden from View: - virtual void Layout() OVERRIDE; - virtual gfx::Size GetPreferredSize() OVERRIDE; - virtual void SetEnabled(bool enabled) OVERRIDE; - virtual void OnPaintFocusBorder(gfx::Canvas* canvas) OVERRIDE; - - protected: - virtual void OnFocus() OVERRIDE; - virtual void ViewHierarchyChanged(bool is_add, View* parent, - View* child) OVERRIDE; - virtual std::string GetClassName() const OVERRIDE; - - // 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_ |