File: tslider.h

package info (click to toggle)
nip2 8.9.1-2
  • links: PTS
  • area: main
  • in suites: forky, sid
  • size: 23,404 kB
  • sloc: ansic: 64,076; sh: 4,681; yacc: 1,133; makefile: 927; lex: 386; xml: 40; perl: 17
file content (94 lines) | stat: -rw-r--r-- 2,998 bytes parent folder | download | duplicates (7)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
/* A slider with an entry widget.
 */

/*

    Copyright (C) 1991-2003 The National Gallery

    This program is free software; you can redistribute it and/or modify
    it under the terms of the GNU General Public License as published by
    the Free Software Foundation; either version 2 of the License, or
    (at your option) any later version.

    This program is distributed in the hope that it will be useful,
    but WITHOUT ANY WARRANTY; without even the implied warranty of
    MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
    GNU General Public License for more details.

    You should have received a copy of the GNU General Public License along
    with this program; if not, write to the Free Software Foundation, Inc.,
    51 Franklin Street, Fifth Floor, Boston, MA  02110-1301  USA

 */

/*

    These files are distributed with VIPS - http://www.vips.ecs.soton.ac.uk

 */

#define TYPE_TSLIDER (tslider_get_type())
#define TSLIDER( obj ) (GTK_CHECK_CAST( (obj), TYPE_TSLIDER, Tslider ))
#define TSLIDER_CLASS( klass ) \
	(GTK_CHECK_CLASS_CAST( (klass), TYPE_TSLIDER, TsliderClass ))
#define IS_TSLIDER( obj ) (GTK_CHECK_TYPE( (obj), TYPE_TSLIDER ))
#define IS_TSLIDER_CLASS( klass ) \
	(GTK_CHECK_CLASS_TYPE( (klass), TYPE_TSLIDER ))

typedef double (*tslider_fn)( double from, double to, double value );

typedef struct _Tslider {
	GtkHBox parent_class;

	/* Our state.
	 */
	double from;
	double to;

	double value;		/* Real value, as displayed in text */
	double svalue;		/* Slider value ... secret linear scale */
	int digits;		/* How many sf to display */

	/* Keep last from/to/value settings here. Can't
	 * use from/to since double and float don't compare reliably.
	 */
	double last_from, last_to, last_svalue;

	GtkWidget *entry;
	GtkWidget *slider;
	GtkAdjustment *adj;

	/* Optional functions ... how to make a value from a slider
	 * position, how to make a slider position from a value.
	 * If these are defined, text and slider are linked for you.
	 */
	gboolean auto_link;
	tslider_fn value_to_slider;
	tslider_fn slider_to_value;

	/* Ignore scroll events. In workspaces, we want the scroll-wheel to
	 * just scroll the workspace and not adjust sliders. 
	 */
	gboolean ignore_scroll;
} Tslider;

typedef struct _TsliderClass {
	GtkHBoxClass parent_class;

	void (*changed)( Tslider * );		/* from/to/value change */
	void (*activate)( Tslider * );		/* enter in text */
	void (*slider_changed)( Tslider * );	/* slider drag */
	void (*text_changed)( Tslider * );	/* text has been touched */
} TsliderClass;

void tslider_changed( Tslider * );

GtkType tslider_get_type( void );
Tslider *tslider_new( void );

void tslider_set_conversions( Tslider *tslider, 
	tslider_fn value_to_slider, tslider_fn slider_to_value );
double tslider_log_value_to_slider( double from, double to, double value );
double tslider_log_slider_to_value( double from, double to, double value );

void tslider_set_ignore_scroll( Tslider *tslider, gboolean ignore_scroll );