1 /* GTK - The GIMP Toolkit
2 * Copyright (C) 2001 Red Hat, Inc.
4 * This library is free software; you can redistribute it and/or
5 * modify it under the terms of the GNU Lesser General Public
6 * License as published by the Free Software Foundation; either
7 * version 2 of the License, or (at your option) any later version.
9 * This library is distributed in the hope that it will be useful,
10 * but WITHOUT ANY WARRANTY; without even the implied warranty of
11 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
12 * Lesser General Public License for more details.
14 * You should have received a copy of the GNU Lesser General Public
15 * License along with this library; if not, write to the
16 * Free Software Foundation, Inc., 59 Temple Place - Suite 330,
17 * Boston, MA 02111-1307, USA.
21 * Modified by the GTK+ Team and others 1997-2000. See the AUTHORS
22 * file for a list of people on the GTK+ Team. See the ChangeLog
23 * files for a list of changes. These files are distributed with
24 * GTK+ at ftp://ftp.gtk.org/pub/gtk/.
32 #include "gtkvscale.h"
33 #include "gtkorientable.h"
38 * @Short_description: A vertical slider widget for selecting a value from a range
41 * The #GtkVScale widget is used to allow the user to select a value using
42 * a vertical slider. To create one, use gtk_hscale_new_with_range().
44 * The position to show the current value, and the number of decimal places
45 * shown can be set using the parent #GtkScale class's functions.
48 G_DEFINE_TYPE (GtkVScale, gtk_vscale, GTK_TYPE_SCALE)
51 gtk_vscale_class_init (GtkVScaleClass *class)
53 GtkRangeClass *range_class = GTK_RANGE_CLASS (class);
55 range_class->slider_detail = "vscale";
59 gtk_vscale_init (GtkVScale *vscale)
61 gtk_orientable_set_orientation (GTK_ORIENTABLE (vscale),
62 GTK_ORIENTATION_VERTICAL);
66 * @adjustment: the #GtkAdjustment which sets the range of the scale.
68 * Creates a new #GtkVScale.
70 * Returns: a new #GtkVScale.
73 gtk_vscale_new (GtkAdjustment *adjustment)
75 g_return_val_if_fail (adjustment == NULL || GTK_IS_ADJUSTMENT (adjustment),
78 return g_object_new (GTK_TYPE_VSCALE,
79 "adjustment", adjustment,
84 * gtk_vscale_new_with_range:
87 * @step: step increment (tick size) used with keyboard shortcuts
89 * Creates a new vertical scale widget that lets the user input a
90 * number between @min and @max (including @min and @max) with the
91 * increment @step. @step must be nonzero; it's the distance the
92 * slider moves when using the arrow keys to adjust the scale value.
94 * Note that the way in which the precision is derived works best if @step
95 * is a power of ten. If the resulting precision is not suitable for your
96 * needs, use gtk_scale_set_digits() to correct it.
98 * Return value: a new #GtkVScale
101 gtk_vscale_new_with_range (gdouble min,
109 g_return_val_if_fail (min < max, NULL);
110 g_return_val_if_fail (step != 0.0, NULL);
112 adj = gtk_adjustment_new (min, min, max, step, 10 * step, 0);
114 if (fabs (step) >= 1.0 || step == 0.0)
120 digits = abs ((gint) floor (log10 (fabs (step))));
125 scale = g_object_new (GTK_TYPE_VSCALE,
130 return GTK_WIDGET (scale);