Chromium Code Reviews
chromiumcodereview-hr@appspot.gserviceaccount.com (chromiumcodereview-hr) | Please choose your nickname with Settings | Help | Chromium Project | Gerrit Changes | Sign out
(51)

Unified Diff: views/controls/slider/native_slider_gtk.cc

Issue 211002: Add touchpad speed factor setting to Chrome OS touchpad settings page... (Closed) Base URL: svn://chrome-svn/chrome/trunk/src/
Patch Set: '' Created 11 years, 3 months ago
Use n/p to move between diff chunks; N/P to move between comments. Draft comments are only viewable by you.
Jump to:
View side-by-side diff with in-line comments
Download patch
« no previous file with comments | « views/controls/slider/native_slider_gtk.h ('k') | views/controls/slider/native_slider_wrapper.h » ('j') | no next file with comments »
Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
Index: views/controls/slider/native_slider_gtk.cc
===================================================================
--- views/controls/slider/native_slider_gtk.cc (revision 0)
+++ views/controls/slider/native_slider_gtk.cc (revision 0)
@@ -0,0 +1,123 @@
+// 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 "base/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() {
+ Focus();
+}
+
+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
Property changes on: views/controls/slider/native_slider_gtk.cc
___________________________________________________________________
Added: svn:eol-style
+ LF
« no previous file with comments | « views/controls/slider/native_slider_gtk.h ('k') | views/controls/slider/native_slider_wrapper.h » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698