]> Pileus Git - ~andy/gtk/blob - gtk/gtkspinbutton.h
d33ca6b015b8bc56cee97058a235ab62029d0d48
[~andy/gtk] / gtk / gtkspinbutton.h
1 /* GTK - The GIMP Toolkit
2  * Copyright (C) 1995-1997 Peter Mattis, Spencer Kimball and Josh MacDonald
3  *
4  * GtkSpinButton widget for GTK+
5  * Copyright (C) 1998 Lars Hamann and Stefan Jeske
6  *
7  * This library is free software; you can redistribute it and/or
8  * modify it under the terms of the GNU Library General Public
9  * License as published by the Free Software Foundation; either
10  * version 2 of the License, or (at your option) any later version.
11  *
12  * This library is distributed in the hope that it will be useful,
13  * but WITHOUT ANY WARRANTY; without even the implied warranty of
14  * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the GNU
15  * Library General Public License for more details.
16  *
17  * You should have received a copy of the GNU Library General Public
18  * License along with this library; if not, write to the
19  * Free Software Foundation, Inc., 59 Temple Place - Suite 330,
20  * Boston, MA 02111-1307, USA.
21  */
22
23 #ifndef __GTK_SPIN_BUTTON_H__
24 #define __GTK_SPIN_BUTTON_H__
25
26
27 #include <gdk/gdk.h>
28 #include <gtk/gtkentry.h>
29 #include <gtk/gtkadjustment.h>
30
31
32 #ifdef __cplusplus
33 extern "C" {
34 #pragma }
35 #endif /* __cplusplus */
36
37
38 #define GTK_TYPE_SPIN_BUTTON                  (gtk_spin_button_get_type ())
39 #define GTK_SPIN_BUTTON(obj)                  (GTK_CHECK_CAST ((obj), GTK_TYPE_SPIN_BUTTON, GtkSpinButton))
40 #define GTK_SPIN_BUTTON_CLASS(klass)          (GTK_CHECK_CLASS_CAST ((klass), GTK_TYPE_SPIN_BUTTON, GtkSpinButtonClass))
41 #define GTK_IS_SPIN_BUTTON(obj)               (GTK_CHECK_TYPE ((obj), GTK_TYPE_SPIN_BUTTON))
42 #define GTK_IS_SPIN_BUTTON_CLASS(klass)       (GTK_CHECK_CLASS_TYPE ((klass), GTK_TYPE_SPIN_BUTTON))
43
44
45 typedef enum
46 {
47   GTK_UPDATE_ALWAYS,
48   GTK_UPDATE_IF_VALID
49 } GtkSpinButtonUpdatePolicy;
50
51 typedef enum
52 {
53   GTK_SPIN_STEP_FORWARD,
54   GTK_SPIN_STEP_BACKWARD,
55   GTK_SPIN_PAGE_FORWARD,
56   GTK_SPIN_PAGE_BACKWARD,
57   GTK_SPIN_HOME,
58   GTK_SPIN_END,
59   GTK_SPIN_USER_DEFINED
60 } GtkSpinType;
61
62
63 typedef struct _GtkSpinButton       GtkSpinButton;
64 typedef struct _GtkSpinButtonClass  GtkSpinButtonClass;
65
66
67 struct _GtkSpinButton
68 {
69   GtkEntry entry;
70   
71   GtkAdjustment *adjustment;
72   
73   GdkWindow *panel;
74   GtkShadowType shadow_type;
75   
76   guint32 timer;
77   guint32 ev_time;
78   
79   gfloat climb_rate;
80   gfloat timer_step;
81   
82   GtkSpinButtonUpdatePolicy update_policy;
83   
84   guint in_child : 2;
85   guint click_child : 2;
86   guint button : 2;
87   guint need_timer : 1;
88   guint timer_calls : 3;
89   guint digits : 3;
90   guint numeric : 1;
91   guint wrap : 1;
92   guint snap_to_ticks : 1;
93 };
94
95 struct _GtkSpinButtonClass
96 {
97   GtkEntryClass parent_class;
98 };
99
100
101 GtkType         gtk_spin_button_get_type           (void);
102
103 void            gtk_spin_button_configure          (GtkSpinButton  *spin_button,
104                                                     GtkAdjustment  *adjustment,
105                                                     gfloat          climb_rate,
106                                                     guint           digits);
107
108 GtkWidget*      gtk_spin_button_new                (GtkAdjustment  *adjustment,
109                                                     gfloat          climb_rate,
110                                                     guint           digits);
111
112 void            gtk_spin_button_set_adjustment     (GtkSpinButton  *spin_button,
113                                                     GtkAdjustment  *adjustment);
114
115 GtkAdjustment*  gtk_spin_button_get_adjustment     (GtkSpinButton  *spin_button);
116
117 void            gtk_spin_button_set_digits         (GtkSpinButton  *spin_button,
118                                                     guint           digits);
119
120 gfloat          gtk_spin_button_get_value_as_float (GtkSpinButton  *spin_button);
121
122 gint            gtk_spin_button_get_value_as_int   (GtkSpinButton  *spin_button);
123
124 void            gtk_spin_button_set_value          (GtkSpinButton  *spin_button, 
125                                                     gfloat          value);
126
127 void            gtk_spin_button_set_update_policy  (GtkSpinButton  *spin_button,
128                                                     GtkSpinButtonUpdatePolicy  policy);
129
130 void            gtk_spin_button_set_numeric        (GtkSpinButton  *spin_button,
131                                                     gboolean        numeric);
132
133 void            gtk_spin_button_spin               (GtkSpinButton  *spin_button,
134                                                     GtkSpinType     direction,
135                                                     gfloat          increment);
136
137 void            gtk_spin_button_set_wrap           (GtkSpinButton  *spin_button,
138                                                     gboolean        wrap);
139
140 void            gtk_spin_button_set_shadow_type    (GtkSpinButton  *spin_button,
141                                                     GtkShadowType   shadow_type);
142
143 void            gtk_spin_button_set_snap_to_ticks  (GtkSpinButton  *spin_button,
144                                                     gboolean        snap_to_ticks);
145
146 /* deprecated, defined for backwards compatibility */
147 #define gtk_spin_button_construct gtk_spin_button_configure
148
149
150 #ifdef __cplusplus
151 }
152 #endif /* __cplusplus */
153
154
155 #endif /* __GTK_SPIN_BUTTON_H__ */