]> Pileus Git - ~andy/gtk/blob - gtk/gtkrange.h
Added per-stepper API for GtkRange's stepper sensitivity as discussed in
[~andy/gtk] / gtk / gtkrange.h
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 #include <gdk/gdk.h>
32 #include <gtk/gtkadjustment.h>
33 #include <gtk/gtkwidget.h>
34
35
36 G_BEGIN_DECLS
37
38
39 #define GTK_TYPE_RANGE            (gtk_range_get_type ())
40 #define GTK_RANGE(obj)            (G_TYPE_CHECK_INSTANCE_CAST ((obj), GTK_TYPE_RANGE, GtkRange))
41 #define GTK_RANGE_CLASS(klass)    (G_TYPE_CHECK_CLASS_CAST ((klass), GTK_TYPE_RANGE, GtkRangeClass))
42 #define GTK_IS_RANGE(obj)         (G_TYPE_CHECK_INSTANCE_TYPE ((obj), GTK_TYPE_RANGE))
43 #define GTK_IS_RANGE_CLASS(klass) (G_TYPE_CHECK_CLASS_TYPE ((klass), GTK_TYPE_RANGE))
44 #define GTK_RANGE_GET_CLASS(obj)  (G_TYPE_INSTANCE_GET_CLASS ((obj), GTK_TYPE_RANGE, GtkRangeClass))
45
46 /* These two are private/opaque types, ignore */
47 typedef struct _GtkRangeLayout    GtkRangeLayout;
48 typedef struct _GtkRangeStepTimer GtkRangeStepTimer;
49
50 typedef struct _GtkRange        GtkRange;
51 typedef struct _GtkRangeClass   GtkRangeClass;
52
53 struct _GtkRange
54 {
55   GtkWidget widget;
56
57   GtkAdjustment *adjustment;
58   GtkUpdateType update_policy;
59   guint inverted : 1;
60
61   /*< protected >*/
62   
63   guint flippable : 1;
64   
65   /* Steppers are: < > ---- < >
66    *               a b      c d
67    */
68    
69   guint has_stepper_a : 1;
70   guint has_stepper_b : 1;
71   guint has_stepper_c : 1;
72   guint has_stepper_d : 1;
73
74   guint need_recalc : 1;
75
76   guint slider_size_fixed : 1;
77   
78   gint min_slider_size;
79
80   GtkOrientation orientation;
81
82   /* Area of entire stepper + trough assembly in widget->window coords */
83   GdkRectangle range_rect;
84   /* Slider range along the long dimension, in widget->window coords */
85   gint slider_start, slider_end;
86
87   /* Round off value to this many digits, -1 for no rounding */
88   gint round_digits;
89   
90   /*< private >*/
91   guint trough_click_forward : 1;  /* trough click was on the forward side of slider */
92   guint update_pending : 1;        /* need to emit value_changed */
93   GtkRangeLayout *layout;
94   GtkRangeStepTimer *timer;
95   gint slide_initial_slider_position;
96   gint slide_initial_coordinate;
97   guint update_timeout_id;
98   GdkWindow *event_window;
99 };
100
101 struct _GtkRangeClass
102 {
103   GtkWidgetClass parent_class;
104
105   /* what detail to pass to GTK drawing functions */
106   gchar *slider_detail;
107   gchar *stepper_detail;
108
109   void (* value_changed)    (GtkRange     *range);
110   void (* adjust_bounds)    (GtkRange     *range,
111                              gdouble       new_value);
112   
113   /* action signals for keybindings */
114   void (* move_slider)      (GtkRange     *range,
115                              GtkScrollType scroll);
116
117   /* Virtual functions */
118   void (* get_range_border) (GtkRange     *range,
119                              GtkBorder    *border_);
120
121   gboolean (* change_value) (GtkRange     *range,
122                              GtkScrollType scroll,
123                              gdouble       new_value);
124
125   /* Padding for future expansion */
126   void (*_gtk_reserved1) (void);
127   void (*_gtk_reserved2) (void);
128   void (*_gtk_reserved3) (void);
129 };
130
131
132 GType              gtk_range_get_type                      (void) G_GNUC_CONST;
133
134 void               gtk_range_set_update_policy             (GtkRange      *range,
135                                                             GtkUpdateType  policy);
136 GtkUpdateType      gtk_range_get_update_policy             (GtkRange      *range);
137
138 void               gtk_range_set_adjustment                (GtkRange      *range,
139                                                             GtkAdjustment *adjustment);
140 GtkAdjustment*     gtk_range_get_adjustment                (GtkRange      *range);
141
142 void               gtk_range_set_inverted                  (GtkRange      *range,
143                                                             gboolean       setting);
144 gboolean           gtk_range_get_inverted                  (GtkRange      *range);
145
146 void               gtk_range_set_lower_stepper_sensitivity (GtkRange      *range,
147                                                             GtkSensitivityType sensitivity);
148 GtkSensitivityType gtk_range_get_lower_stepper_sensitivity (GtkRange      *range);
149 void               gtk_range_set_upper_stepper_sensitivity (GtkRange      *range,
150                                                             GtkSensitivityType sensitivity);
151 GtkSensitivityType gtk_range_get_upper_stepper_sensitivity (GtkRange      *range);
152
153 void               gtk_range_set_increments                (GtkRange      *range,
154                                                             gdouble        step,
155                                                             gdouble        page);
156 void               gtk_range_set_range                     (GtkRange      *range,
157                                                             gdouble        min,
158                                                             gdouble        max);
159 void               gtk_range_set_value                     (GtkRange      *range,
160                                                             gdouble        value);
161 gdouble            gtk_range_get_value                     (GtkRange      *range);
162
163 gdouble           _gtk_range_get_wheel_delta               (GtkRange      *range,
164                                                             GdkScrollDirection direction);
165
166
167 G_END_DECLS
168
169
170 #endif /* __GTK_RANGE_H__ */