1 /* GTK - The GIMP Toolkit
2 * Copyright (C) 1995-1997 Peter Mattis, Spencer Kimball and Josh MacDonald
4 * This library is free software; you can redistribute it and/or
5 * modify it under the terms of the GNU Library 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.
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 * Library General Public License for more details.
14 * You should have received a copy of the GNU Library General Public
15 * License along with this library; if not, write to the Free
16 * Software Foundation, Inc., 675 Mass Ave, Cambridge, MA 02139, USA.
18 #include "gtkadjustment.h"
19 #include "gtksignal.h"
29 static void gtk_adjustment_class_init (GtkAdjustmentClass *klass);
30 static void gtk_adjustment_init (GtkAdjustment *adjustment);
33 static guint adjustment_signals[LAST_SIGNAL] = { 0 };
37 gtk_adjustment_get_type ()
39 static guint adjustment_type = 0;
43 GtkTypeInfo adjustment_info =
46 sizeof (GtkAdjustment),
47 sizeof (GtkAdjustmentClass),
48 (GtkClassInitFunc) gtk_adjustment_class_init,
49 (GtkObjectInitFunc) gtk_adjustment_init,
54 adjustment_type = gtk_type_unique (gtk_data_get_type (), &adjustment_info);
57 return adjustment_type;
61 gtk_adjustment_class_init (GtkAdjustmentClass *class)
63 GtkObjectClass *object_class;
65 object_class = (GtkObjectClass*) class;
67 adjustment_signals[CHANGED] =
68 gtk_signal_new ("changed",
69 GTK_RUN_FIRST | GTK_RUN_NO_RECURSE,
71 GTK_SIGNAL_OFFSET (GtkAdjustmentClass, changed),
72 gtk_signal_default_marshaller,
74 adjustment_signals[VALUE_CHANGED] =
75 gtk_signal_new ("value_changed",
76 GTK_RUN_FIRST | GTK_RUN_NO_RECURSE,
78 GTK_SIGNAL_OFFSET (GtkAdjustmentClass, value_changed),
79 gtk_signal_default_marshaller,
82 gtk_object_class_add_signals (object_class, adjustment_signals, LAST_SIGNAL);
84 class->changed = NULL;
85 class->value_changed = NULL;
89 gtk_adjustment_init (GtkAdjustment *adjustment)
91 adjustment->value = 0.0;
92 adjustment->lower = 0.0;
93 adjustment->upper = 0.0;
94 adjustment->step_increment = 0.0;
95 adjustment->page_increment = 0.0;
96 adjustment->page_size = 0.0;
100 gtk_adjustment_new (gfloat value,
103 gfloat step_increment,
104 gfloat page_increment,
107 GtkAdjustment *adjustment;
109 adjustment = gtk_type_new (gtk_adjustment_get_type ());
111 adjustment->value = value;
112 adjustment->lower = lower;
113 adjustment->upper = upper;
114 adjustment->step_increment = step_increment;
115 adjustment->page_increment = page_increment;
116 adjustment->page_size = page_size;
118 return GTK_OBJECT (adjustment);
122 gtk_adjustment_set_value (GtkAdjustment *adjustment,
125 g_return_if_fail (adjustment != NULL);
126 g_return_if_fail (GTK_IS_ADJUSTMENT (adjustment));
128 adjustment->value = CLAMP (value, adjustment->lower, adjustment->upper);
130 gtk_signal_emit_by_name (GTK_OBJECT (adjustment), "value_changed");