18352
Sadrul Habib Chowdhury <imadil@gmail.com>
parents:
diff
changeset
|
1 /**
|
Sadrul Habib Chowdhury <imadil@gmail.com>
parents:
diff
changeset
|
2 * @file gntslider.h Slider API
|
Sadrul Habib Chowdhury <imadil@gmail.com>
parents:
diff
changeset
|
3 * @ingroup gnt
|
Sadrul Habib Chowdhury <imadil@gmail.com>
parents:
diff
changeset
|
4 */
|
Sadrul Habib Chowdhury <imadil@gmail.com>
parents:
diff
changeset
|
5 /*
|
Sadrul Habib Chowdhury <imadil@gmail.com>
parents:
diff
changeset
|
6 * GNT - The GLib Ncurses Toolkit
|
Sadrul Habib Chowdhury <imadil@gmail.com>
parents:
diff
changeset
|
7 *
|
Sadrul Habib Chowdhury <imadil@gmail.com>
parents:
diff
changeset
|
8 * GNT is the legal property of its developers, whose names are too numerous
|
Sadrul Habib Chowdhury <imadil@gmail.com>
parents:
diff
changeset
|
9 * to list here. Please refer to the COPYRIGHT file distributed with this
|
Sadrul Habib Chowdhury <imadil@gmail.com>
parents:
diff
changeset
|
10 * source distribution.
|
Sadrul Habib Chowdhury <imadil@gmail.com>
parents:
diff
changeset
|
11 *
|
Sadrul Habib Chowdhury <imadil@gmail.com>
parents:
diff
changeset
|
12 * This library is free software; you can redistribute it and/or modify
|
Sadrul Habib Chowdhury <imadil@gmail.com>
parents:
diff
changeset
|
13 * it under the terms of the GNU General Public License as published by
|
Sadrul Habib Chowdhury <imadil@gmail.com>
parents:
diff
changeset
|
14 * the Free Software Foundation; either version 2 of the License, or
|
Sadrul Habib Chowdhury <imadil@gmail.com>
parents:
diff
changeset
|
15 * (at your option) any later version.
|
Sadrul Habib Chowdhury <imadil@gmail.com>
parents:
diff
changeset
|
16 *
|
Sadrul Habib Chowdhury <imadil@gmail.com>
parents:
diff
changeset
|
17 * This program is distributed in the hope that it will be useful,
|
Sadrul Habib Chowdhury <imadil@gmail.com>
parents:
diff
changeset
|
18 * but WITHOUT ANY WARRANTY; without even the implied warranty of
|
Sadrul Habib Chowdhury <imadil@gmail.com>
parents:
diff
changeset
|
19 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
|
Sadrul Habib Chowdhury <imadil@gmail.com>
parents:
diff
changeset
|
20 * GNU General Public License for more details.
|
Sadrul Habib Chowdhury <imadil@gmail.com>
parents:
diff
changeset
|
21 *
|
Sadrul Habib Chowdhury <imadil@gmail.com>
parents:
diff
changeset
|
22 * You should have received a copy of the GNU General Public License
|
Sadrul Habib Chowdhury <imadil@gmail.com>
parents:
diff
changeset
|
23 * along with this program; if not, write to the Free Software
|
Sadrul Habib Chowdhury <imadil@gmail.com>
parents:
diff
changeset
|
24 * Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA
|
Sadrul Habib Chowdhury <imadil@gmail.com>
parents:
diff
changeset
|
25 */
|
Sadrul Habib Chowdhury <imadil@gmail.com>
parents:
diff
changeset
|
26
|
Sadrul Habib Chowdhury <imadil@gmail.com>
parents:
diff
changeset
|
27 #ifndef GNT_SLIDER_H
|
Sadrul Habib Chowdhury <imadil@gmail.com>
parents:
diff
changeset
|
28 #define GNT_SLIDER_H
|
Sadrul Habib Chowdhury <imadil@gmail.com>
parents:
diff
changeset
|
29
|
Sadrul Habib Chowdhury <imadil@gmail.com>
parents:
diff
changeset
|
30 #include "gntwidget.h"
|
Sadrul Habib Chowdhury <imadil@gmail.com>
parents:
diff
changeset
|
31 #include "gnt.h"
|
Sadrul Habib Chowdhury <imadil@gmail.com>
parents:
diff
changeset
|
32 #include "gntlabel.h"
|
Sadrul Habib Chowdhury <imadil@gmail.com>
parents:
diff
changeset
|
33
|
Sadrul Habib Chowdhury <imadil@gmail.com>
parents:
diff
changeset
|
34 #define GNT_TYPE_SLIDER (gnt_slider_get_gtype())
|
Sadrul Habib Chowdhury <imadil@gmail.com>
parents:
diff
changeset
|
35 #define GNT_SLIDER(obj) (G_TYPE_CHECK_INSTANCE_CAST((obj), GNT_TYPE_SLIDER, GntSlider))
|
Sadrul Habib Chowdhury <imadil@gmail.com>
parents:
diff
changeset
|
36 #define GNT_SLIDER_CLASS(klass) (G_TYPE_CHECK_CLASS_CAST((klass), GNT_TYPE_SLIDER, GntSliderClass))
|
Sadrul Habib Chowdhury <imadil@gmail.com>
parents:
diff
changeset
|
37 #define GNT_IS_SLIDER(obj) (G_TYPE_CHECK_INSTANCE_TYPE((obj), GNT_TYPE_SLIDER))
|
Sadrul Habib Chowdhury <imadil@gmail.com>
parents:
diff
changeset
|
38 #define GNT_IS_SLIDER_CLASS(klass) (G_TYPE_CHECK_CLASS_TYPE((klass), GNT_TYPE_SLIDER))
|
Sadrul Habib Chowdhury <imadil@gmail.com>
parents:
diff
changeset
|
39 #define GNT_SLIDER_GET_CLASS(obj) (G_TYPE_INSTANCE_GET_CLASS((obj), GNT_TYPE_SLIDER, GntSliderClass))
|
Sadrul Habib Chowdhury <imadil@gmail.com>
parents:
diff
changeset
|
40
|
Sadrul Habib Chowdhury <imadil@gmail.com>
parents:
diff
changeset
|
41 #define GNT_SLIDER_FLAGS(obj) (GNT_SLIDER(obj)->priv.flags)
|
Sadrul Habib Chowdhury <imadil@gmail.com>
parents:
diff
changeset
|
42 #define GNT_SLIDER_SET_FLAGS(obj, flags) (GNT_SLIDER_FLAGS(obj) |= flags)
|
Sadrul Habib Chowdhury <imadil@gmail.com>
parents:
diff
changeset
|
43 #define GNT_SLIDER_UNSET_FLAGS(obj, flags) (GNT_SLIDER_FLAGS(obj) &= ~(flags))
|
Sadrul Habib Chowdhury <imadil@gmail.com>
parents:
diff
changeset
|
44
|
Sadrul Habib Chowdhury <imadil@gmail.com>
parents:
diff
changeset
|
45 typedef struct _GntSlider GntSlider;
|
Sadrul Habib Chowdhury <imadil@gmail.com>
parents:
diff
changeset
|
46 typedef struct _GntSliderPriv GntSliderPriv;
|
Sadrul Habib Chowdhury <imadil@gmail.com>
parents:
diff
changeset
|
47 typedef struct _GntSliderClass GntSliderClass;
|
Sadrul Habib Chowdhury <imadil@gmail.com>
parents:
diff
changeset
|
48
|
Sadrul Habib Chowdhury <imadil@gmail.com>
parents:
diff
changeset
|
49 struct _GntSlider
|
Sadrul Habib Chowdhury <imadil@gmail.com>
parents:
diff
changeset
|
50 {
|
Sadrul Habib Chowdhury <imadil@gmail.com>
parents:
diff
changeset
|
51 GntWidget parent;
|
Sadrul Habib Chowdhury <imadil@gmail.com>
parents:
diff
changeset
|
52
|
Sadrul Habib Chowdhury <imadil@gmail.com>
parents:
diff
changeset
|
53 gboolean vertical;
|
Sadrul Habib Chowdhury <imadil@gmail.com>
parents:
diff
changeset
|
54
|
Sadrul Habib Chowdhury <imadil@gmail.com>
parents:
diff
changeset
|
55 int max; /* maximum value */
|
Sadrul Habib Chowdhury <imadil@gmail.com>
parents:
diff
changeset
|
56 int min; /* minimum value */
|
Sadrul Habib Chowdhury <imadil@gmail.com>
parents:
diff
changeset
|
57 int step; /* amount to change at each step */
|
Sadrul Habib Chowdhury <imadil@gmail.com>
parents:
diff
changeset
|
58 int current; /* current value */
|
Sadrul Habib Chowdhury <imadil@gmail.com>
parents:
diff
changeset
|
59 };
|
Sadrul Habib Chowdhury <imadil@gmail.com>
parents:
diff
changeset
|
60
|
Sadrul Habib Chowdhury <imadil@gmail.com>
parents:
diff
changeset
|
61 struct _GntSliderClass
|
Sadrul Habib Chowdhury <imadil@gmail.com>
parents:
diff
changeset
|
62 {
|
Sadrul Habib Chowdhury <imadil@gmail.com>
parents:
diff
changeset
|
63 GntWidgetClass parent;
|
Sadrul Habib Chowdhury <imadil@gmail.com>
parents:
diff
changeset
|
64
|
Sadrul Habib Chowdhury <imadil@gmail.com>
parents:
diff
changeset
|
65 void (*changed)(GntSlider *slider, int);
|
Sadrul Habib Chowdhury <imadil@gmail.com>
parents:
diff
changeset
|
66 void (*gnt_reserved1)(void);
|
Sadrul Habib Chowdhury <imadil@gmail.com>
parents:
diff
changeset
|
67 void (*gnt_reserved2)(void);
|
Sadrul Habib Chowdhury <imadil@gmail.com>
parents:
diff
changeset
|
68 void (*gnt_reserved3)(void);
|
Sadrul Habib Chowdhury <imadil@gmail.com>
parents:
diff
changeset
|
69 void (*gnt_reserved4)(void);
|
Sadrul Habib Chowdhury <imadil@gmail.com>
parents:
diff
changeset
|
70 };
|
Sadrul Habib Chowdhury <imadil@gmail.com>
parents:
diff
changeset
|
71
|
Sadrul Habib Chowdhury <imadil@gmail.com>
parents:
diff
changeset
|
72 G_BEGIN_DECLS
|
Sadrul Habib Chowdhury <imadil@gmail.com>
parents:
diff
changeset
|
73
|
Sadrul Habib Chowdhury <imadil@gmail.com>
parents:
diff
changeset
|
74 /**
|
Sadrul Habib Chowdhury <imadil@gmail.com>
parents:
diff
changeset
|
75 * @return The GType for GntSlider
|
Sadrul Habib Chowdhury <imadil@gmail.com>
parents:
diff
changeset
|
76 */
|
Sadrul Habib Chowdhury <imadil@gmail.com>
parents:
diff
changeset
|
77 GType gnt_slider_get_gtype(void);
|
Sadrul Habib Chowdhury <imadil@gmail.com>
parents:
diff
changeset
|
78
|
Sadrul Habib Chowdhury <imadil@gmail.com>
parents:
diff
changeset
|
79 #define gnt_hslider_new(max, min) gnt_slider_new(FALSE, max, min)
|
Sadrul Habib Chowdhury <imadil@gmail.com>
parents:
diff
changeset
|
80 #define gnt_vslider_new(max, min) gnt_slider_new(TRUE, max, min)
|
Sadrul Habib Chowdhury <imadil@gmail.com>
parents:
diff
changeset
|
81
|
Sadrul Habib Chowdhury <imadil@gmail.com>
parents:
diff
changeset
|
82 /**
|
Sadrul Habib Chowdhury <imadil@gmail.com>
parents:
diff
changeset
|
83 * Create a new slider.
|
Sadrul Habib Chowdhury <imadil@gmail.com>
parents:
diff
changeset
|
84 *
|
Sadrul Habib Chowdhury <imadil@gmail.com>
parents:
diff
changeset
|
85 * @param orient A vertical slider is created if @c TRUE, otherwise the slider is horizontal.
|
Sadrul Habib Chowdhury <imadil@gmail.com>
parents:
diff
changeset
|
86 * @param max The maximum value for the slider
|
Sadrul Habib Chowdhury <imadil@gmail.com>
parents:
diff
changeset
|
87 * @param min The minimum value for the slider
|
Sadrul Habib Chowdhury <imadil@gmail.com>
parents:
diff
changeset
|
88 *
|
Sadrul Habib Chowdhury <imadil@gmail.com>
parents:
diff
changeset
|
89 * @return The newly created slider
|
Sadrul Habib Chowdhury <imadil@gmail.com>
parents:
diff
changeset
|
90 */
|
Sadrul Habib Chowdhury <imadil@gmail.com>
parents:
diff
changeset
|
91 GntWidget * gnt_slider_new(gboolean orient, int max, int min);
|
Sadrul Habib Chowdhury <imadil@gmail.com>
parents:
diff
changeset
|
92
|
Sadrul Habib Chowdhury <imadil@gmail.com>
parents:
diff
changeset
|
93 /**
|
Sadrul Habib Chowdhury <imadil@gmail.com>
parents:
diff
changeset
|
94 * Set the range of the slider.
|
Sadrul Habib Chowdhury <imadil@gmail.com>
parents:
diff
changeset
|
95 *
|
Sadrul Habib Chowdhury <imadil@gmail.com>
parents:
diff
changeset
|
96 * @param slider The slider
|
Sadrul Habib Chowdhury <imadil@gmail.com>
parents:
diff
changeset
|
97 * @param max The maximum value
|
Sadrul Habib Chowdhury <imadil@gmail.com>
parents:
diff
changeset
|
98 * @param min The minimum value
|
Sadrul Habib Chowdhury <imadil@gmail.com>
parents:
diff
changeset
|
99 */
|
Sadrul Habib Chowdhury <imadil@gmail.com>
parents:
diff
changeset
|
100 void gnt_slider_set_range(GntSlider *slider, int max, int min);
|
Sadrul Habib Chowdhury <imadil@gmail.com>
parents:
diff
changeset
|
101
|
Sadrul Habib Chowdhury <imadil@gmail.com>
parents:
diff
changeset
|
102 /**
|
Sadrul Habib Chowdhury <imadil@gmail.com>
parents:
diff
changeset
|
103 * Sets the amount of change at each step.
|
Sadrul Habib Chowdhury <imadil@gmail.com>
parents:
diff
changeset
|
104 *
|
Sadrul Habib Chowdhury <imadil@gmail.com>
parents:
diff
changeset
|
105 * @param slider The slider
|
Sadrul Habib Chowdhury <imadil@gmail.com>
parents:
diff
changeset
|
106 * @param step The amount for each ste
|
Sadrul Habib Chowdhury <imadil@gmail.com>
parents:
diff
changeset
|
107 */
|
Sadrul Habib Chowdhury <imadil@gmail.com>
parents:
diff
changeset
|
108 void gnt_slider_set_step(GntSlider *slider, int step);
|
Sadrul Habib Chowdhury <imadil@gmail.com>
parents:
diff
changeset
|
109
|
Sadrul Habib Chowdhury <imadil@gmail.com>
parents:
diff
changeset
|
110 /**
|
Sadrul Habib Chowdhury <imadil@gmail.com>
parents:
diff
changeset
|
111 * Advance the slider forward or backward.
|
Sadrul Habib Chowdhury <imadil@gmail.com>
parents:
diff
changeset
|
112 *
|
Sadrul Habib Chowdhury <imadil@gmail.com>
parents:
diff
changeset
|
113 * @param slider The slider
|
Sadrul Habib Chowdhury <imadil@gmail.com>
parents:
diff
changeset
|
114 * @param steps The number of amounts to change, positive to change
|
Sadrul Habib Chowdhury <imadil@gmail.com>
parents:
diff
changeset
|
115 * forward, negative to change backward
|
Sadrul Habib Chowdhury <imadil@gmail.com>
parents:
diff
changeset
|
116 *
|
Sadrul Habib Chowdhury <imadil@gmail.com>
parents:
diff
changeset
|
117 * @return The value of the slider after the change
|
Sadrul Habib Chowdhury <imadil@gmail.com>
parents:
diff
changeset
|
118 */
|
Sadrul Habib Chowdhury <imadil@gmail.com>
parents:
diff
changeset
|
119 int gnt_slider_advance_step(GntSlider *slider, int steps);
|
Sadrul Habib Chowdhury <imadil@gmail.com>
parents:
diff
changeset
|
120
|
Sadrul Habib Chowdhury <imadil@gmail.com>
parents:
diff
changeset
|
121 /**
|
Sadrul Habib Chowdhury <imadil@gmail.com>
parents:
diff
changeset
|
122 * Set the current value for the slider.
|
Sadrul Habib Chowdhury <imadil@gmail.com>
parents:
diff
changeset
|
123 *
|
Sadrul Habib Chowdhury <imadil@gmail.com>
parents:
diff
changeset
|
124 * @param slider The slider
|
Sadrul Habib Chowdhury <imadil@gmail.com>
parents:
diff
changeset
|
125 * @param value The current value
|
Sadrul Habib Chowdhury <imadil@gmail.com>
parents:
diff
changeset
|
126 */
|
Sadrul Habib Chowdhury <imadil@gmail.com>
parents:
diff
changeset
|
127 void gnt_slider_set_value(GntSlider *slider, int value);
|
Sadrul Habib Chowdhury <imadil@gmail.com>
parents:
diff
changeset
|
128
|
Sadrul Habib Chowdhury <imadil@gmail.com>
parents:
diff
changeset
|
129 /**
|
Sadrul Habib Chowdhury <imadil@gmail.com>
parents:
diff
changeset
|
130 * Update a label with the value of the slider whenever the value changes.
|
Sadrul Habib Chowdhury <imadil@gmail.com>
parents:
diff
changeset
|
131 *
|
Sadrul Habib Chowdhury <imadil@gmail.com>
parents:
diff
changeset
|
132 * @param slider The slider
|
Sadrul Habib Chowdhury <imadil@gmail.com>
parents:
diff
changeset
|
133 * @param label The label to update
|
Sadrul Habib Chowdhury <imadil@gmail.com>
parents:
diff
changeset
|
134 */
|
Sadrul Habib Chowdhury <imadil@gmail.com>
parents:
diff
changeset
|
135 void gnt_slider_reflect_label(GntSlider *slider, GntLabel *label);
|
Sadrul Habib Chowdhury <imadil@gmail.com>
parents:
diff
changeset
|
136
|
Sadrul Habib Chowdhury <imadil@gmail.com>
parents:
diff
changeset
|
137 G_END_DECLS
|
Sadrul Habib Chowdhury <imadil@gmail.com>
parents:
diff
changeset
|
138
|
Sadrul Habib Chowdhury <imadil@gmail.com>
parents:
diff
changeset
|
139 #endif /* GNT_SLIDER_H */
|