1/* GTK - The GIMP Toolkit
2 * Copyright (C) 1995-1997 Peter Mattis, Spencer Kimball and Josh MacDonald
3 *
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.
8 *
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.
13 *
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.
18 */
19
20/*
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/.
25 */
26
27#ifndef __GTK_RANGE_H__
28#define __GTK_RANGE_H__
29
30
31#if defined(GTK_DISABLE_SINGLE_INCLUDES) && !defined (__GTK_H_INSIDE__) && !defined (GTK_COMPILATION)
32#error "Only <gtk/gtk.h> can be included directly."
33#endif
34
35#include <gtk/gtkadjustment.h>
36#include <gtk/gtkwidget.h>
37
38
39G_BEGIN_DECLS
40
41
42#define GTK_TYPE_RANGE (gtk_range_get_type ())
43#define GTK_RANGE(obj) (G_TYPE_CHECK_INSTANCE_CAST ((obj), GTK_TYPE_RANGE, GtkRange))
44#define GTK_RANGE_CLASS(klass) (G_TYPE_CHECK_CLASS_CAST ((klass), GTK_TYPE_RANGE, GtkRangeClass))
45#define GTK_IS_RANGE(obj) (G_TYPE_CHECK_INSTANCE_TYPE ((obj), GTK_TYPE_RANGE))
46#define GTK_IS_RANGE_CLASS(klass) (G_TYPE_CHECK_CLASS_TYPE ((klass), GTK_TYPE_RANGE))
47#define GTK_RANGE_GET_CLASS(obj) (G_TYPE_INSTANCE_GET_CLASS ((obj), GTK_TYPE_RANGE, GtkRangeClass))
48
49/* These two are private/opaque types, ignore */
50typedef struct _GtkRangeLayout GtkRangeLayout;
51typedef struct _GtkRangeStepTimer GtkRangeStepTimer;
52
53typedef struct _GtkRange GtkRange;
54typedef struct _GtkRangeClass GtkRangeClass;
55
56struct _GtkRange
57{
58 GtkWidget widget;
59
60 GtkAdjustment *GSEAL (adjustment);
61 GtkUpdateType GSEAL (update_policy);
62 guint GSEAL (inverted) : 1;
63
64 /*< protected >*/
65
66 guint GSEAL (flippable) : 1;
67
68 /* Steppers are: < > ---- < >
69 * a b c d
70 */
71
72 guint GSEAL (has_stepper_a) : 1;
73 guint GSEAL (has_stepper_b) : 1;
74 guint GSEAL (has_stepper_c) : 1;
75 guint GSEAL (has_stepper_d) : 1;
76
77 guint GSEAL (need_recalc) : 1;
78
79 guint GSEAL (slider_size_fixed) : 1;
80
81 gint GSEAL (min_slider_size);
82
83 GtkOrientation GSEAL (orientation);
84
85 /* Area of entire stepper + trough assembly in widget->window coords */
86 GdkRectangle GSEAL (range_rect);
87 /* Slider range along the long dimension, in widget->window coords */
88 gint GSEAL (slider_start);
89 gint GSEAL (slider_end);
90
91 /* Round off value to this many digits, -1 for no rounding */
92 gint GSEAL (round_digits);
93
94 /*< private >*/
95 guint GSEAL (trough_click_forward) : 1; /* trough click was on the forward side of slider */
96 guint GSEAL (update_pending) : 1; /* need to emit value_changed */
97 GtkRangeLayout *GSEAL (layout);
98 GtkRangeStepTimer *GSEAL (timer);
99 gint GSEAL (slide_initial_slider_position);
100 gint GSEAL (slide_initial_coordinate);
101 guint GSEAL (update_timeout_id);
102 GdkWindow *GSEAL (event_window);
103};
104
105struct _GtkRangeClass
106{
107 GtkWidgetClass parent_class;
108
109 /* what detail to pass to GTK drawing functions */
110 gchar *slider_detail;
111 gchar *stepper_detail;
112
113 void (* value_changed) (GtkRange *range);
114 void (* adjust_bounds) (GtkRange *range,
115 gdouble new_value);
116
117 /* action signals for keybindings */
118 void (* move_slider) (GtkRange *range,
119 GtkScrollType scroll);
120
121 /* Virtual functions */
122 void (* get_range_border) (GtkRange *range,
123 GtkBorder *border_);
124
125 gboolean (* change_value) (GtkRange *range,
126 GtkScrollType scroll,
127 gdouble new_value);
128
129 /* Padding for future expansion */
130 void (*_gtk_reserved1) (void);
131 void (*_gtk_reserved2) (void);
132 void (*_gtk_reserved3) (void);
133};
134
135
136GType gtk_range_get_type (void) G_GNUC_CONST;
137
138#ifndef GTK_DISABLE_DEPRECATED
139void gtk_range_set_update_policy (GtkRange *range,
140 GtkUpdateType policy);
141GtkUpdateType gtk_range_get_update_policy (GtkRange *range);
142#endif /* GTK_DISABLE_DEPRECATED */
143
144void gtk_range_set_adjustment (GtkRange *range,
145 GtkAdjustment *adjustment);
146GtkAdjustment* gtk_range_get_adjustment (GtkRange *range);
147
148void gtk_range_set_inverted (GtkRange *range,
149 gboolean setting);
150gboolean gtk_range_get_inverted (GtkRange *range);
151
152void gtk_range_set_flippable (GtkRange *range,
153 gboolean flippable);
154gboolean gtk_range_get_flippable (GtkRange *range);
155
156void gtk_range_set_slider_size_fixed (GtkRange *range,
157 gboolean size_fixed);
158gboolean gtk_range_get_slider_size_fixed (GtkRange *range);
159
160void gtk_range_set_min_slider_size (GtkRange *range,
161 gboolean min_size);
162gint gtk_range_get_min_slider_size (GtkRange *range);
163
164void gtk_range_get_range_rect (GtkRange *range,
165 GdkRectangle *range_rect);
166void gtk_range_get_slider_range (GtkRange *range,
167 gint *slider_start,
168 gint *slider_end);
169
170void gtk_range_set_lower_stepper_sensitivity (GtkRange *range,
171 GtkSensitivityType sensitivity);
172GtkSensitivityType gtk_range_get_lower_stepper_sensitivity (GtkRange *range);
173void gtk_range_set_upper_stepper_sensitivity (GtkRange *range,
174 GtkSensitivityType sensitivity);
175GtkSensitivityType gtk_range_get_upper_stepper_sensitivity (GtkRange *range);
176
177void gtk_range_set_increments (GtkRange *range,
178 gdouble step,
179 gdouble page);
180void gtk_range_set_range (GtkRange *range,
181 gdouble min,
182 gdouble max);
183void gtk_range_set_value (GtkRange *range,
184 gdouble value);
185gdouble gtk_range_get_value (GtkRange *range);
186
187void gtk_range_set_show_fill_level (GtkRange *range,
188 gboolean show_fill_level);
189gboolean gtk_range_get_show_fill_level (GtkRange *range);
190void gtk_range_set_restrict_to_fill_level (GtkRange *range,
191 gboolean restrict_to_fill_level);
192gboolean gtk_range_get_restrict_to_fill_level (GtkRange *range);
193void gtk_range_set_fill_level (GtkRange *range,
194 gdouble fill_level);
195gdouble gtk_range_get_fill_level (GtkRange *range);
196void gtk_range_set_round_digits (GtkRange *range,
197 gint round_digits);
198gint gtk_range_get_round_digits (GtkRange *range);
199
200
201/* internal API */
202gdouble _gtk_range_get_wheel_delta (GtkRange *range,
203 GdkScrollDirection direction);
204
205void _gtk_range_set_stop_values (GtkRange *range,
206 gdouble *values,
207 gint n_values);
208gint _gtk_range_get_stop_positions (GtkRange *range,
209 gint **values);
210
211
212G_END_DECLS
213
214
215#endif /* __GTK_RANGE_H__ */
216