1 /* A slider with an entry widget.
2  */
3 
4 /*
5 
6     Copyright (C) 1991-2003 The National Gallery
7 
8     This program is free software; you can redistribute it and/or modify
9     it under the terms of the GNU General Public License as published by
10     the Free Software Foundation; either version 2 of the License, or
11     (at your option) any later version.
12 
13     This program 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
16     GNU General Public License for more details.
17 
18     You should have received a copy of the GNU General Public License along
19     with this program; if not, write to the Free Software Foundation, Inc.,
20     51 Franklin Street, Fifth Floor, Boston, MA  02110-1301  USA
21 
22  */
23 
24 /*
25 
26     These files are distributed with VIPS - http://www.vips.ecs.soton.ac.uk
27 
28  */
29 
30 #define TYPE_TSLIDER (tslider_get_type())
31 #define TSLIDER( obj ) (GTK_CHECK_CAST( (obj), TYPE_TSLIDER, Tslider ))
32 #define TSLIDER_CLASS( klass ) \
33 	(GTK_CHECK_CLASS_CAST( (klass), TYPE_TSLIDER, TsliderClass ))
34 #define IS_TSLIDER( obj ) (GTK_CHECK_TYPE( (obj), TYPE_TSLIDER ))
35 #define IS_TSLIDER_CLASS( klass ) \
36 	(GTK_CHECK_CLASS_TYPE( (klass), TYPE_TSLIDER ))
37 
38 typedef double (*tslider_fn)( double from, double to, double value );
39 
40 typedef struct _Tslider {
41 	GtkHBox parent_class;
42 
43 	/* Our state.
44 	 */
45 	double from;
46 	double to;
47 
48 	double value;		/* Real value, as displayed in text */
49 	double svalue;		/* Slider value ... secret linear scale */
50 	int digits;		/* How many sf to display */
51 
52 	/* Keep last from/to/value settings here. Can't
53 	 * use from/to since double and float don't compare reliably.
54 	 */
55 	double last_from, last_to, last_svalue;
56 
57 	GtkWidget *entry;
58 	GtkWidget *slider;
59 	GtkAdjustment *adj;
60 
61 	/* Optional functions ... how to make a value from a slider
62 	 * position, how to make a slider position from a value.
63 	 * If these are defined, text and slider are linked for you.
64 	 */
65 	gboolean auto_link;
66 	tslider_fn value_to_slider;
67 	tslider_fn slider_to_value;
68 
69 	/* Ignore scroll events. In workspaces, we want the scroll-wheel to
70 	 * just scroll the workspace and not adjust sliders.
71 	 */
72 	gboolean ignore_scroll;
73 } Tslider;
74 
75 typedef struct _TsliderClass {
76 	GtkHBoxClass parent_class;
77 
78 	void (*changed)( Tslider * );		/* from/to/value change */
79 	void (*activate)( Tslider * );		/* enter in text */
80 	void (*slider_changed)( Tslider * );	/* slider drag */
81 	void (*text_changed)( Tslider * );	/* text has been touched */
82 } TsliderClass;
83 
84 void tslider_changed( Tslider * );
85 
86 GtkType tslider_get_type( void );
87 Tslider *tslider_new( void );
88 
89 void tslider_set_conversions( Tslider *tslider,
90 	tslider_fn value_to_slider, tslider_fn slider_to_value );
91 double tslider_log_value_to_slider( double from, double to, double value );
92 double tslider_log_slider_to_value( double from, double to, double value );
93 
94 void tslider_set_ignore_scroll( Tslider *tslider, gboolean ignore_scroll );
95