]> Pileus Git - ~andy/gtk/blob - gtk/gtkrange.h
add new signal 'adjust_bounds' to potentialy change the bounds before
[~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 #ifdef __cplusplus
37 extern "C" {
38 #endif /* __cplusplus */
39
40
41 #define GTK_TYPE_RANGE            (gtk_range_get_type ())
42 #define GTK_RANGE(obj)            (GTK_CHECK_CAST ((obj), GTK_TYPE_RANGE, GtkRange))
43 #define GTK_RANGE_CLASS(klass)    (GTK_CHECK_CLASS_CAST ((klass), GTK_TYPE_RANGE, GtkRangeClass))
44 #define GTK_IS_RANGE(obj)         (GTK_CHECK_TYPE ((obj), GTK_TYPE_RANGE))
45 #define GTK_IS_RANGE_CLASS(klass) (GTK_CHECK_CLASS_TYPE ((klass), GTK_TYPE_RANGE))
46 #define GTK_RANGE_GET_CLASS(obj)  (GTK_CHECK_GET_CLASS ((obj), GTK_TYPE_RANGE, GtkRangeClass))
47
48 /* These two are private/opaque types, ignore */
49 typedef struct _GtkRangeLayout    GtkRangeLayout;
50 typedef struct _GtkRangeStepTimer GtkRangeStepTimer;
51
52 typedef struct _GtkRange        GtkRange;
53 typedef struct _GtkRangeClass   GtkRangeClass;
54
55 struct _GtkRange
56 {
57   GtkWidget widget;
58
59   GtkAdjustment *adjustment;
60   GtkUpdateType update_policy;
61   guint inverted : 1;
62
63   /*< protected >*/
64   
65   guint flippable : 1;
66   
67   /* Steppers are: < > ---- < >
68    *               a b      c d
69    */
70    
71   guint has_stepper_a : 1;
72   guint has_stepper_b : 1;
73   guint has_stepper_c : 1;
74   guint has_stepper_d : 1;
75
76   guint need_recalc : 1;
77
78   guint slider_size_fixed : 1;
79   
80   gint min_slider_size;
81
82   GtkOrientation orientation;
83
84   /* Area of entire stepper + trough assembly in widget->window coords */
85   GdkRectangle range_rect;
86   /* Slider range along the long dimension, in widget->window coords */
87   gint slider_start, slider_end;
88
89   /* Round off value to this many digits, -1 for no rounding */
90   gint round_digits;
91   
92   /*< private >*/
93   guint trough_click_forward : 1;  /* trough click was on the forward side of slider */
94   guint update_pending : 1;        /* need to emit value_changed */
95   GtkRangeLayout *layout;
96   GtkRangeStepTimer *timer;
97   gint slide_initial_slider_position;
98   gint slide_initial_coordinate;
99   guint update_timeout_id;
100   GdkWindow *event_window;
101 };
102
103 struct _GtkRangeClass
104 {
105   GtkWidgetClass parent_class;
106
107   /* what detail to pass to GTK drawing functions */
108   gchar *slider_detail;
109   gchar *stepper_detail;
110
111   void (* value_changed)    (GtkRange     *range);
112   void (* adjust_bounds)    (GtkRange     *range,
113                              gdouble       new_value);
114   
115   /* action signals for keybindings */
116   void (* move_slider)      (GtkRange     *range,
117                              GtkScrollType scroll);
118
119   /* Virtual functions */
120   void (* get_range_border) (GtkRange     *range,
121                              GtkBorder    *border);
122 };
123
124
125 GtkType        gtk_range_get_type               (void) G_GNUC_CONST;
126
127 void           gtk_range_set_update_policy (GtkRange      *range,
128                                             GtkUpdateType  policy);
129 GtkUpdateType  gtk_range_get_update_policy (GtkRange      *range);
130 void           gtk_range_set_adjustment    (GtkRange      *range,
131                                             GtkAdjustment *adjustment);
132 GtkAdjustment* gtk_range_get_adjustment    (GtkRange      *range);
133 void           gtk_range_set_inverted      (GtkRange      *range,
134                                             gboolean       setting);
135 gboolean       gtk_range_get_inverted      (GtkRange      *range);
136 void           gtk_range_set_increments    (GtkRange      *range,
137                                             gdouble        step,
138                                             gdouble        page);
139 void           gtk_range_set_range         (GtkRange      *range,
140                                             gdouble        min,
141                                             gdouble        max);
142 void           gtk_range_set_value         (GtkRange      *range,
143                                             gdouble        value);
144 gdouble        gtk_range_get_value         (GtkRange      *range);
145
146
147 #ifdef __cplusplus
148 }
149 #endif /* __cplusplus */
150
151
152 #endif /* __GTK_RANGE_H__ */