Update to 24f58c58bb8d22c0e8e6c5ce43c536c47b719bc6
[gnt.git] / gntslider.h
blob7cd658434224bb89de9c1467130e3bb642e4cd46
1 /**
2 * @file gntslider.h Slider API
3 * @ingroup gnt
4 */
5 /*
6 * GNT - The GLib Ncurses Toolkit
8 * GNT is the legal property of its developers, whose names are too numerous
9 * to list here. Please refer to the COPYRIGHT file distributed with this
10 * source distribution.
12 * This library is free software; you can redistribute it and/or modify
13 * it under the terms of the GNU General Public License as published by
14 * the Free Software Foundation; either version 2 of the License, or
15 * (at your option) any later version.
17 * This program is distributed in the hope that it will be useful,
18 * but WITHOUT ANY WARRANTY; without even the implied warranty of
19 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
20 * GNU General Public License for more details.
22 * You should have received a copy of the GNU General Public License
23 * along with this program; if not, write to the Free Software
24 * Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02111-1301 USA
27 #ifndef GNT_SLIDER_H
28 #define GNT_SLIDER_H
30 #include "gntwidget.h"
31 #include "gnt.h"
32 #include "gntlabel.h"
34 #define GNT_TYPE_SLIDER (gnt_slider_get_gtype())
35 #define GNT_SLIDER(obj) (G_TYPE_CHECK_INSTANCE_CAST((obj), GNT_TYPE_SLIDER, GntSlider))
36 #define GNT_SLIDER_CLASS(klass) (G_TYPE_CHECK_CLASS_CAST((klass), GNT_TYPE_SLIDER, GntSliderClass))
37 #define GNT_IS_SLIDER(obj) (G_TYPE_CHECK_INSTANCE_TYPE((obj), GNT_TYPE_SLIDER))
38 #define GNT_IS_SLIDER_CLASS(klass) (G_TYPE_CHECK_CLASS_TYPE((klass), GNT_TYPE_SLIDER))
39 #define GNT_SLIDER_GET_CLASS(obj) (G_TYPE_INSTANCE_GET_CLASS((obj), GNT_TYPE_SLIDER, GntSliderClass))
41 #define GNT_SLIDER_FLAGS(obj) (GNT_SLIDER(obj)->priv.flags)
42 #define GNT_SLIDER_SET_FLAGS(obj, flags) (GNT_SLIDER_FLAGS(obj) |= flags)
43 #define GNT_SLIDER_UNSET_FLAGS(obj, flags) (GNT_SLIDER_FLAGS(obj) &= ~(flags))
45 typedef struct _GntSlider GntSlider;
46 typedef struct _GntSliderPriv GntSliderPriv;
47 typedef struct _GntSliderClass GntSliderClass;
49 struct _GntSlider
51 GntWidget parent;
53 gboolean vertical;
55 int max; /* maximum value */
56 int min; /* minimum value */
57 int step; /* amount to change at each step */
58 int current; /* current value */
59 int smallstep;
60 int largestep;
63 struct _GntSliderClass
65 GntWidgetClass parent;
67 void (*changed)(GntSlider *slider, int);
68 void (*gnt_reserved1)(void);
69 void (*gnt_reserved2)(void);
70 void (*gnt_reserved3)(void);
71 void (*gnt_reserved4)(void);
74 G_BEGIN_DECLS
76 /**
77 * @return The GType for GntSlider
79 * @since 2.0.0 (gnt), 2.1.0 (pidgin)
81 GType gnt_slider_get_gtype(void);
83 #define gnt_hslider_new(max, min) gnt_slider_new(FALSE, max, min)
84 #define gnt_vslider_new(max, min) gnt_slider_new(TRUE, max, min)
86 /**
87 * Create a new slider.
89 * @param orient A vertical slider is created if @c TRUE, otherwise the slider is horizontal.
90 * @param max The maximum value for the slider
91 * @param min The minimum value for the slider
93 * @return The newly created slider
95 * @since 2.0.0 (gnt), 2.1.0 (pidgin)
97 GntWidget * gnt_slider_new(gboolean orient, int max, int min);
99 /**
100 * Set the range of the slider.
102 * @param slider The slider
103 * @param max The maximum value
104 * @param min The minimum value
106 * @since 2.0.0 (gnt), 2.1.0 (pidgin)
108 void gnt_slider_set_range(GntSlider *slider, int max, int min);
111 * Sets the amount of change at each step.
113 * @param slider The slider
114 * @param step The amount for each step
116 * @since 2.0.0 (gnt), 2.1.0 (pidgin)
118 void gnt_slider_set_step(GntSlider *slider, int step);
121 * Sets the amount of change a small step.
123 * @param slider The slider
124 * @param step The amount for a small step (for the slider)
126 * @since 2.2.0
128 void gnt_slider_set_small_step(GntSlider *slider, int step);
131 * Sets the amount of change a large step.
133 * @param slider The slider
134 * @param step The amount for a large step (for the slider)
136 * @since 2.2.0
138 void gnt_slider_set_large_step(GntSlider *slider, int step);
141 * Advance the slider forward or backward.
143 * @param slider The slider
144 * @param steps The number of amounts to change, positive to change
145 * forward, negative to change backward
147 * @return The value of the slider after the change
149 * @since 2.0.0 (gnt), 2.1.0 (pidgin)
151 int gnt_slider_advance_step(GntSlider *slider, int steps);
154 * Set the current value for the slider.
156 * @param slider The slider
157 * @param value The current value
159 * @since 2.0.0 (gnt), 2.1.0 (pidgin)
161 void gnt_slider_set_value(GntSlider *slider, int value);
164 * Get the current value for the slider.
166 * @param slider The slider
169 * @since 2.0.0 (gnt), 2.1.0 (pidgin)
171 int gnt_slider_get_value(GntSlider *slider);
174 * Update a label with the value of the slider whenever the value changes.
176 * @param slider The slider
177 * @param label The label to update
179 * @since 2.0.0 (gnt), 2.1.0 (pidgin)
181 void gnt_slider_reflect_label(GntSlider *slider, GntLabel *label);
184 G_END_DECLS
186 #endif /* GNT_SLIDER_H */