2 /* $Id: scale.ccg,v 1.2 2004/01/19 19:48:44 murrayc Exp $ */
6 * Copyright 1998-2002 The gtkmm Development Team
8 * This library is free software; you can redistribute it and/or
9 * modify it under the terms of the GNU Library General Public
10 * License as published by the Free Software Foundation; either
11 * version 2 of the License, or (at your option) any later version.
13 * This library is distributed in the hope that it will be useful,
14 * but WITHOUT ANY WARRANTY; without even the implied warranty of
15 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
16 * Library General Public License for more details.
18 * You should have received a copy of the GNU Library General Public
19 * License along with this library; if not, write to the Free
20 * Software Foundation, Inc., 675 Mass Ave, Cambridge, MA 02139, USA.
23 #include <gtkmm/adjustment.h>
25 #include <gtk/gtkscale.h>
26 #include <gtk/gtkhscale.h>
27 #include <gtk/gtkvscale.h>
33 int Scale::calc_digits_(double step) const
37 //Copied from gtk_[h|v]scale_new_with_range():
38 if (fabs (step) >= 1.0 || step == 0.0)
41 digits = abs ((int) floor (log10 (fabs (step))));
49 VScale::VScale(double min, double max, double step)
51 _CONSTRUCT_SPECIFIC(Scale, VScale)
53 Adjustment* adjustment = manage(new Adjustment(min, min, max, step, 10 * step, step));
54 // The adjustment will be destroyed along with the object
55 set_adjustment(*adjustment);
57 set_digits( calc_digits_(step) );
60 VScale::VScale(Adjustment& adjustment)
62 _CONSTRUCT_SPECIFIC(Scale, VScale)
64 set_adjustment(adjustment);
69 _CONSTRUCT_SPECIFIC(Scale, VScale)
71 Adjustment* adjustment = manage(new Adjustment(0.0, 0.0, 0.0,
73 // The adjustment will be destroyed along with the object
74 set_adjustment(*adjustment);
78 HScale::HScale(double min, double max, double step)
80 _CONSTRUCT_SPECIFIC(Scale, HScale)
82 Adjustment* adjustment = manage(new Adjustment(min, min, max, step, 10 * step, step));
83 // The adjustment will be destroyed along with the object
84 set_adjustment(*adjustment);
86 set_digits( calc_digits_(step) );
91 _CONSTRUCT_SPECIFIC(Scale, HScale)
93 Adjustment* adjustment = manage(new Adjustment(0.0, 0.0, 0.0,
95 // The adjustment will be destroyed along with the object
96 set_adjustment(*adjustment);
99 HScale::HScale(Adjustment& adjustment)
101 _CONSTRUCT_SPECIFIC(Scale, HScale)
103 set_adjustment(adjustment);