annotate src/xs_curve.c @ 359:b1a858b8cb1a

Re-indentation all (non-generated) code.
author Matti Hamalainen <ccr@tnsp.org>
date Mon, 07 Nov 2005 09:50:04 +0000
parents 4f247b19c9ea
children df6f12a00305
Ignore whitespace changes - Everywhere: Within whitespace: At end of lines:
rev   line source
358
4f247b19c9ea Add new files
Matti Hamalainen <ccr@tnsp.org>
parents:
diff changeset
1 /* GTK - The GIMP Toolkit
4f247b19c9ea Add new files
Matti Hamalainen <ccr@tnsp.org>
parents:
diff changeset
2 * Copyright (C) 1997 David Mosberger
4f247b19c9ea Add new files
Matti Hamalainen <ccr@tnsp.org>
parents:
diff changeset
3 *
4f247b19c9ea Add new files
Matti Hamalainen <ccr@tnsp.org>
parents:
diff changeset
4 * This library is free software; you can redistribute it and/or
4f247b19c9ea Add new files
Matti Hamalainen <ccr@tnsp.org>
parents:
diff changeset
5 * modify it under the terms of the GNU Library General Public
4f247b19c9ea Add new files
Matti Hamalainen <ccr@tnsp.org>
parents:
diff changeset
6 * License as published by the Free Software Foundation; either
4f247b19c9ea Add new files
Matti Hamalainen <ccr@tnsp.org>
parents:
diff changeset
7 * version 2 of the License, or (at your option) any later version.
4f247b19c9ea Add new files
Matti Hamalainen <ccr@tnsp.org>
parents:
diff changeset
8 *
4f247b19c9ea Add new files
Matti Hamalainen <ccr@tnsp.org>
parents:
diff changeset
9 * This library is distributed in the hope that it will be useful,
4f247b19c9ea Add new files
Matti Hamalainen <ccr@tnsp.org>
parents:
diff changeset
10 * but WITHOUT ANY WARRANTY; without even the implied warranty of
4f247b19c9ea Add new files
Matti Hamalainen <ccr@tnsp.org>
parents:
diff changeset
11 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
4f247b19c9ea Add new files
Matti Hamalainen <ccr@tnsp.org>
parents:
diff changeset
12 * Library General Public License for more details.
4f247b19c9ea Add new files
Matti Hamalainen <ccr@tnsp.org>
parents:
diff changeset
13 *
4f247b19c9ea Add new files
Matti Hamalainen <ccr@tnsp.org>
parents:
diff changeset
14 * You should have received a copy of the GNU Library General Public
4f247b19c9ea Add new files
Matti Hamalainen <ccr@tnsp.org>
parents:
diff changeset
15 * License along with this library; if not, write to the
4f247b19c9ea Add new files
Matti Hamalainen <ccr@tnsp.org>
parents:
diff changeset
16 * Free Software Foundation, Inc., 59 Temple Place - Suite 330,
4f247b19c9ea Add new files
Matti Hamalainen <ccr@tnsp.org>
parents:
diff changeset
17 * Boston, MA 02111-1307, USA.
4f247b19c9ea Add new files
Matti Hamalainen <ccr@tnsp.org>
parents:
diff changeset
18 */
4f247b19c9ea Add new files
Matti Hamalainen <ccr@tnsp.org>
parents:
diff changeset
19
4f247b19c9ea Add new files
Matti Hamalainen <ccr@tnsp.org>
parents:
diff changeset
20 /*
4f247b19c9ea Add new files
Matti Hamalainen <ccr@tnsp.org>
parents:
diff changeset
21 * Modified by the GTK+ Team and others 1997-1999. See the AUTHORS
4f247b19c9ea Add new files
Matti Hamalainen <ccr@tnsp.org>
parents:
diff changeset
22 * file for a list of people on the GTK+ Team. See the ChangeLog
4f247b19c9ea Add new files
Matti Hamalainen <ccr@tnsp.org>
parents:
diff changeset
23 * files for a list of changes. These files are distributed with
4f247b19c9ea Add new files
Matti Hamalainen <ccr@tnsp.org>
parents:
diff changeset
24 * GTK+ at ftp://ftp.gtk.org/pub/gtk/.
4f247b19c9ea Add new files
Matti Hamalainen <ccr@tnsp.org>
parents:
diff changeset
25 */
4f247b19c9ea Add new files
Matti Hamalainen <ccr@tnsp.org>
parents:
diff changeset
26
4f247b19c9ea Add new files
Matti Hamalainen <ccr@tnsp.org>
parents:
diff changeset
27 #include <stdlib.h>
4f247b19c9ea Add new files
Matti Hamalainen <ccr@tnsp.org>
parents:
diff changeset
28 #include <string.h>
4f247b19c9ea Add new files
Matti Hamalainen <ccr@tnsp.org>
parents:
diff changeset
29 #include <math.h>
4f247b19c9ea Add new files
Matti Hamalainen <ccr@tnsp.org>
parents:
diff changeset
30
4f247b19c9ea Add new files
Matti Hamalainen <ccr@tnsp.org>
parents:
diff changeset
31 #include "xs_curve.h"
4f247b19c9ea Add new files
Matti Hamalainen <ccr@tnsp.org>
parents:
diff changeset
32 #include <gtk/gtkdrawingarea.h>
4f247b19c9ea Add new files
Matti Hamalainen <ccr@tnsp.org>
parents:
diff changeset
33 #include <gtk/gtkmain.h>
4f247b19c9ea Add new files
Matti Hamalainen <ccr@tnsp.org>
parents:
diff changeset
34 #include <gtk/gtksignal.h>
4f247b19c9ea Add new files
Matti Hamalainen <ccr@tnsp.org>
parents:
diff changeset
35 /*
4f247b19c9ea Add new files
Matti Hamalainen <ccr@tnsp.org>
parents:
diff changeset
36 #include <gtk/gtktable.h>
4f247b19c9ea Add new files
Matti Hamalainen <ccr@tnsp.org>
parents:
diff changeset
37 #include <gtk/gtkradiobutton.h>
4f247b19c9ea Add new files
Matti Hamalainen <ccr@tnsp.org>
parents:
diff changeset
38 */
4f247b19c9ea Add new files
Matti Hamalainen <ccr@tnsp.org>
parents:
diff changeset
39
4f247b19c9ea Add new files
Matti Hamalainen <ccr@tnsp.org>
parents:
diff changeset
40 #define RADIUS 3 /* radius of the control points */
4f247b19c9ea Add new files
Matti Hamalainen <ccr@tnsp.org>
parents:
diff changeset
41 #define MIN_DISTANCE 8 /* min distance between control points */
4f247b19c9ea Add new files
Matti Hamalainen <ccr@tnsp.org>
parents:
diff changeset
42
4f247b19c9ea Add new files
Matti Hamalainen <ccr@tnsp.org>
parents:
diff changeset
43 #define GRAPH_MASK (GDK_EXPOSURE_MASK | \
4f247b19c9ea Add new files
Matti Hamalainen <ccr@tnsp.org>
parents:
diff changeset
44 GDK_POINTER_MOTION_MASK | \
4f247b19c9ea Add new files
Matti Hamalainen <ccr@tnsp.org>
parents:
diff changeset
45 GDK_POINTER_MOTION_HINT_MASK | \
4f247b19c9ea Add new files
Matti Hamalainen <ccr@tnsp.org>
parents:
diff changeset
46 GDK_ENTER_NOTIFY_MASK | \
4f247b19c9ea Add new files
Matti Hamalainen <ccr@tnsp.org>
parents:
diff changeset
47 GDK_BUTTON_PRESS_MASK | \
4f247b19c9ea Add new files
Matti Hamalainen <ccr@tnsp.org>
parents:
diff changeset
48 GDK_BUTTON_RELEASE_MASK | \
4f247b19c9ea Add new files
Matti Hamalainen <ccr@tnsp.org>
parents:
diff changeset
49 GDK_BUTTON1_MOTION_MASK)
4f247b19c9ea Add new files
Matti Hamalainen <ccr@tnsp.org>
parents:
diff changeset
50
359
b1a858b8cb1a Re-indentation all (non-generated) code.
Matti Hamalainen <ccr@tnsp.org>
parents: 358
diff changeset
51 enum
b1a858b8cb1a Re-indentation all (non-generated) code.
Matti Hamalainen <ccr@tnsp.org>
parents: 358
diff changeset
52 {
b1a858b8cb1a Re-indentation all (non-generated) code.
Matti Hamalainen <ccr@tnsp.org>
parents: 358
diff changeset
53 ARG_0,
b1a858b8cb1a Re-indentation all (non-generated) code.
Matti Hamalainen <ccr@tnsp.org>
parents: 358
diff changeset
54 ARG_CURVE_TYPE,
b1a858b8cb1a Re-indentation all (non-generated) code.
Matti Hamalainen <ccr@tnsp.org>
parents: 358
diff changeset
55 ARG_MIN_X,
b1a858b8cb1a Re-indentation all (non-generated) code.
Matti Hamalainen <ccr@tnsp.org>
parents: 358
diff changeset
56 ARG_MAX_X,
b1a858b8cb1a Re-indentation all (non-generated) code.
Matti Hamalainen <ccr@tnsp.org>
parents: 358
diff changeset
57 ARG_MIN_Y,
b1a858b8cb1a Re-indentation all (non-generated) code.
Matti Hamalainen <ccr@tnsp.org>
parents: 358
diff changeset
58 ARG_MAX_Y
358
4f247b19c9ea Add new files
Matti Hamalainen <ccr@tnsp.org>
parents:
diff changeset
59 };
4f247b19c9ea Add new files
Matti Hamalainen <ccr@tnsp.org>
parents:
diff changeset
60
4f247b19c9ea Add new files
Matti Hamalainen <ccr@tnsp.org>
parents:
diff changeset
61 static GtkDrawingAreaClass *parent_class = NULL;
4f247b19c9ea Add new files
Matti Hamalainen <ccr@tnsp.org>
parents:
diff changeset
62 static guint curve_type_changed_signal = 0;
4f247b19c9ea Add new files
Matti Hamalainen <ccr@tnsp.org>
parents:
diff changeset
63
4f247b19c9ea Add new files
Matti Hamalainen <ccr@tnsp.org>
parents:
diff changeset
64
4f247b19c9ea Add new files
Matti Hamalainen <ccr@tnsp.org>
parents:
diff changeset
65 /* forward declarations: */
359
b1a858b8cb1a Re-indentation all (non-generated) code.
Matti Hamalainen <ccr@tnsp.org>
parents: 358
diff changeset
66 static void gtk_curve_class_init(GtkCurveClass * class);
b1a858b8cb1a Re-indentation all (non-generated) code.
Matti Hamalainen <ccr@tnsp.org>
parents: 358
diff changeset
67 static void gtk_curve_init(GtkCurve * curve);
b1a858b8cb1a Re-indentation all (non-generated) code.
Matti Hamalainen <ccr@tnsp.org>
parents: 358
diff changeset
68 static void gtk_curve_set_arg(GtkObject * object, GtkArg * arg, guint arg_id);
b1a858b8cb1a Re-indentation all (non-generated) code.
Matti Hamalainen <ccr@tnsp.org>
parents: 358
diff changeset
69 static void gtk_curve_get_arg(GtkObject * object, GtkArg * arg, guint arg_id);
b1a858b8cb1a Re-indentation all (non-generated) code.
Matti Hamalainen <ccr@tnsp.org>
parents: 358
diff changeset
70 static void gtk_curve_finalize(GtkObject * object);
b1a858b8cb1a Re-indentation all (non-generated) code.
Matti Hamalainen <ccr@tnsp.org>
parents: 358
diff changeset
71 static gint gtk_curve_graph_events(GtkWidget * widget, GdkEvent * event, GtkCurve * c);
b1a858b8cb1a Re-indentation all (non-generated) code.
Matti Hamalainen <ccr@tnsp.org>
parents: 358
diff changeset
72 static void gtk_curve_size_graph(GtkCurve * curve);
358
4f247b19c9ea Add new files
Matti Hamalainen <ccr@tnsp.org>
parents:
diff changeset
73
359
b1a858b8cb1a Re-indentation all (non-generated) code.
Matti Hamalainen <ccr@tnsp.org>
parents: 358
diff changeset
74 GtkType gtk_curve_get_type(void)
358
4f247b19c9ea Add new files
Matti Hamalainen <ccr@tnsp.org>
parents:
diff changeset
75 {
359
b1a858b8cb1a Re-indentation all (non-generated) code.
Matti Hamalainen <ccr@tnsp.org>
parents: 358
diff changeset
76 static GtkType curve_type = 0;
358
4f247b19c9ea Add new files
Matti Hamalainen <ccr@tnsp.org>
parents:
diff changeset
77
359
b1a858b8cb1a Re-indentation all (non-generated) code.
Matti Hamalainen <ccr@tnsp.org>
parents: 358
diff changeset
78 if (!curve_type) {
b1a858b8cb1a Re-indentation all (non-generated) code.
Matti Hamalainen <ccr@tnsp.org>
parents: 358
diff changeset
79 static const GtkTypeInfo curve_info = {
b1a858b8cb1a Re-indentation all (non-generated) code.
Matti Hamalainen <ccr@tnsp.org>
parents: 358
diff changeset
80 "GtkCurve",
b1a858b8cb1a Re-indentation all (non-generated) code.
Matti Hamalainen <ccr@tnsp.org>
parents: 358
diff changeset
81 sizeof(GtkCurve),
b1a858b8cb1a Re-indentation all (non-generated) code.
Matti Hamalainen <ccr@tnsp.org>
parents: 358
diff changeset
82 sizeof(GtkCurveClass),
b1a858b8cb1a Re-indentation all (non-generated) code.
Matti Hamalainen <ccr@tnsp.org>
parents: 358
diff changeset
83 (GtkClassInitFunc) gtk_curve_class_init,
b1a858b8cb1a Re-indentation all (non-generated) code.
Matti Hamalainen <ccr@tnsp.org>
parents: 358
diff changeset
84 (GtkObjectInitFunc) gtk_curve_init,
b1a858b8cb1a Re-indentation all (non-generated) code.
Matti Hamalainen <ccr@tnsp.org>
parents: 358
diff changeset
85 /* reserved_1 */ NULL,
b1a858b8cb1a Re-indentation all (non-generated) code.
Matti Hamalainen <ccr@tnsp.org>
parents: 358
diff changeset
86 /* reserved_2 */ NULL,
b1a858b8cb1a Re-indentation all (non-generated) code.
Matti Hamalainen <ccr@tnsp.org>
parents: 358
diff changeset
87 (GtkClassInitFunc) NULL,
b1a858b8cb1a Re-indentation all (non-generated) code.
Matti Hamalainen <ccr@tnsp.org>
parents: 358
diff changeset
88 };
358
4f247b19c9ea Add new files
Matti Hamalainen <ccr@tnsp.org>
parents:
diff changeset
89
359
b1a858b8cb1a Re-indentation all (non-generated) code.
Matti Hamalainen <ccr@tnsp.org>
parents: 358
diff changeset
90 curve_type = gtk_type_unique(GTK_TYPE_DRAWING_AREA, &curve_info);
b1a858b8cb1a Re-indentation all (non-generated) code.
Matti Hamalainen <ccr@tnsp.org>
parents: 358
diff changeset
91 }
b1a858b8cb1a Re-indentation all (non-generated) code.
Matti Hamalainen <ccr@tnsp.org>
parents: 358
diff changeset
92 return curve_type;
358
4f247b19c9ea Add new files
Matti Hamalainen <ccr@tnsp.org>
parents:
diff changeset
93 }
4f247b19c9ea Add new files
Matti Hamalainen <ccr@tnsp.org>
parents:
diff changeset
94
359
b1a858b8cb1a Re-indentation all (non-generated) code.
Matti Hamalainen <ccr@tnsp.org>
parents: 358
diff changeset
95 static void gtk_curve_class_init(GtkCurveClass * class)
358
4f247b19c9ea Add new files
Matti Hamalainen <ccr@tnsp.org>
parents:
diff changeset
96 {
359
b1a858b8cb1a Re-indentation all (non-generated) code.
Matti Hamalainen <ccr@tnsp.org>
parents: 358
diff changeset
97 GtkObjectClass *object_class;
b1a858b8cb1a Re-indentation all (non-generated) code.
Matti Hamalainen <ccr@tnsp.org>
parents: 358
diff changeset
98
b1a858b8cb1a Re-indentation all (non-generated) code.
Matti Hamalainen <ccr@tnsp.org>
parents: 358
diff changeset
99 parent_class = gtk_type_class(GTK_TYPE_DRAWING_AREA);
b1a858b8cb1a Re-indentation all (non-generated) code.
Matti Hamalainen <ccr@tnsp.org>
parents: 358
diff changeset
100
b1a858b8cb1a Re-indentation all (non-generated) code.
Matti Hamalainen <ccr@tnsp.org>
parents: 358
diff changeset
101 object_class = (GtkObjectClass *) class;
b1a858b8cb1a Re-indentation all (non-generated) code.
Matti Hamalainen <ccr@tnsp.org>
parents: 358
diff changeset
102
b1a858b8cb1a Re-indentation all (non-generated) code.
Matti Hamalainen <ccr@tnsp.org>
parents: 358
diff changeset
103 object_class->set_arg = gtk_curve_set_arg;
b1a858b8cb1a Re-indentation all (non-generated) code.
Matti Hamalainen <ccr@tnsp.org>
parents: 358
diff changeset
104 object_class->get_arg = gtk_curve_get_arg;
b1a858b8cb1a Re-indentation all (non-generated) code.
Matti Hamalainen <ccr@tnsp.org>
parents: 358
diff changeset
105 object_class->finalize = gtk_curve_finalize;
b1a858b8cb1a Re-indentation all (non-generated) code.
Matti Hamalainen <ccr@tnsp.org>
parents: 358
diff changeset
106
b1a858b8cb1a Re-indentation all (non-generated) code.
Matti Hamalainen <ccr@tnsp.org>
parents: 358
diff changeset
107 curve_type_changed_signal =
b1a858b8cb1a Re-indentation all (non-generated) code.
Matti Hamalainen <ccr@tnsp.org>
parents: 358
diff changeset
108 gtk_signal_new("curve_type_changed", GTK_RUN_FIRST, object_class->type,
b1a858b8cb1a Re-indentation all (non-generated) code.
Matti Hamalainen <ccr@tnsp.org>
parents: 358
diff changeset
109 GTK_SIGNAL_OFFSET(GtkCurveClass, curve_type_changed),
b1a858b8cb1a Re-indentation all (non-generated) code.
Matti Hamalainen <ccr@tnsp.org>
parents: 358
diff changeset
110 gtk_marshal_NONE__NONE, GTK_TYPE_NONE, 0);
b1a858b8cb1a Re-indentation all (non-generated) code.
Matti Hamalainen <ccr@tnsp.org>
parents: 358
diff changeset
111 gtk_object_class_add_signals(object_class, &curve_type_changed_signal, 1);
b1a858b8cb1a Re-indentation all (non-generated) code.
Matti Hamalainen <ccr@tnsp.org>
parents: 358
diff changeset
112
b1a858b8cb1a Re-indentation all (non-generated) code.
Matti Hamalainen <ccr@tnsp.org>
parents: 358
diff changeset
113 gtk_object_add_arg_type("GtkCurve::curve_type", GTK_TYPE_CURVE_TYPE, GTK_ARG_READWRITE, ARG_CURVE_TYPE);
b1a858b8cb1a Re-indentation all (non-generated) code.
Matti Hamalainen <ccr@tnsp.org>
parents: 358
diff changeset
114 gtk_object_add_arg_type("GtkCurve::min_x", GTK_TYPE_FLOAT, GTK_ARG_READWRITE, ARG_MIN_X);
b1a858b8cb1a Re-indentation all (non-generated) code.
Matti Hamalainen <ccr@tnsp.org>
parents: 358
diff changeset
115 gtk_object_add_arg_type("GtkCurve::max_x", GTK_TYPE_FLOAT, GTK_ARG_READWRITE, ARG_MAX_X);
b1a858b8cb1a Re-indentation all (non-generated) code.
Matti Hamalainen <ccr@tnsp.org>
parents: 358
diff changeset
116 gtk_object_add_arg_type("GtkCurve::min_y", GTK_TYPE_FLOAT, GTK_ARG_READWRITE, ARG_MIN_Y);
b1a858b8cb1a Re-indentation all (non-generated) code.
Matti Hamalainen <ccr@tnsp.org>
parents: 358
diff changeset
117 gtk_object_add_arg_type("GtkCurve::max_y", GTK_TYPE_FLOAT, GTK_ARG_READWRITE, ARG_MAX_Y);
358
4f247b19c9ea Add new files
Matti Hamalainen <ccr@tnsp.org>
parents:
diff changeset
118 }
4f247b19c9ea Add new files
Matti Hamalainen <ccr@tnsp.org>
parents:
diff changeset
119
359
b1a858b8cb1a Re-indentation all (non-generated) code.
Matti Hamalainen <ccr@tnsp.org>
parents: 358
diff changeset
120 static void gtk_curve_init(GtkCurve * curve)
358
4f247b19c9ea Add new files
Matti Hamalainen <ccr@tnsp.org>
parents:
diff changeset
121 {
359
b1a858b8cb1a Re-indentation all (non-generated) code.
Matti Hamalainen <ccr@tnsp.org>
parents: 358
diff changeset
122 gint old_mask;
358
4f247b19c9ea Add new files
Matti Hamalainen <ccr@tnsp.org>
parents:
diff changeset
123
359
b1a858b8cb1a Re-indentation all (non-generated) code.
Matti Hamalainen <ccr@tnsp.org>
parents: 358
diff changeset
124 curve->cursor_type = GDK_TOP_LEFT_ARROW;
b1a858b8cb1a Re-indentation all (non-generated) code.
Matti Hamalainen <ccr@tnsp.org>
parents: 358
diff changeset
125 curve->pixmap = NULL;
b1a858b8cb1a Re-indentation all (non-generated) code.
Matti Hamalainen <ccr@tnsp.org>
parents: 358
diff changeset
126 curve->curve_type = GTK_CURVE_TYPE_SPLINE;
b1a858b8cb1a Re-indentation all (non-generated) code.
Matti Hamalainen <ccr@tnsp.org>
parents: 358
diff changeset
127 curve->height = 0;
b1a858b8cb1a Re-indentation all (non-generated) code.
Matti Hamalainen <ccr@tnsp.org>
parents: 358
diff changeset
128 curve->grab_point = -1;
358
4f247b19c9ea Add new files
Matti Hamalainen <ccr@tnsp.org>
parents:
diff changeset
129
359
b1a858b8cb1a Re-indentation all (non-generated) code.
Matti Hamalainen <ccr@tnsp.org>
parents: 358
diff changeset
130 curve->num_points = 0;
b1a858b8cb1a Re-indentation all (non-generated) code.
Matti Hamalainen <ccr@tnsp.org>
parents: 358
diff changeset
131 curve->point = 0;
358
4f247b19c9ea Add new files
Matti Hamalainen <ccr@tnsp.org>
parents:
diff changeset
132
359
b1a858b8cb1a Re-indentation all (non-generated) code.
Matti Hamalainen <ccr@tnsp.org>
parents: 358
diff changeset
133 curve->num_ctlpoints = 0;
b1a858b8cb1a Re-indentation all (non-generated) code.
Matti Hamalainen <ccr@tnsp.org>
parents: 358
diff changeset
134 curve->ctlpoint = NULL;
358
4f247b19c9ea Add new files
Matti Hamalainen <ccr@tnsp.org>
parents:
diff changeset
135
359
b1a858b8cb1a Re-indentation all (non-generated) code.
Matti Hamalainen <ccr@tnsp.org>
parents: 358
diff changeset
136 curve->min_x = 0.0;
b1a858b8cb1a Re-indentation all (non-generated) code.
Matti Hamalainen <ccr@tnsp.org>
parents: 358
diff changeset
137 curve->max_x = 1.0;
b1a858b8cb1a Re-indentation all (non-generated) code.
Matti Hamalainen <ccr@tnsp.org>
parents: 358
diff changeset
138 curve->min_y = 0.0;
b1a858b8cb1a Re-indentation all (non-generated) code.
Matti Hamalainen <ccr@tnsp.org>
parents: 358
diff changeset
139 curve->max_y = 1.0;
358
4f247b19c9ea Add new files
Matti Hamalainen <ccr@tnsp.org>
parents:
diff changeset
140
359
b1a858b8cb1a Re-indentation all (non-generated) code.
Matti Hamalainen <ccr@tnsp.org>
parents: 358
diff changeset
141 old_mask = gtk_widget_get_events(GTK_WIDGET(curve));
b1a858b8cb1a Re-indentation all (non-generated) code.
Matti Hamalainen <ccr@tnsp.org>
parents: 358
diff changeset
142 gtk_widget_set_events(GTK_WIDGET(curve), old_mask | GRAPH_MASK);
b1a858b8cb1a Re-indentation all (non-generated) code.
Matti Hamalainen <ccr@tnsp.org>
parents: 358
diff changeset
143 gtk_signal_connect(GTK_OBJECT(curve), "event", (GtkSignalFunc) gtk_curve_graph_events, curve);
b1a858b8cb1a Re-indentation all (non-generated) code.
Matti Hamalainen <ccr@tnsp.org>
parents: 358
diff changeset
144 gtk_curve_size_graph(curve);
358
4f247b19c9ea Add new files
Matti Hamalainen <ccr@tnsp.org>
parents:
diff changeset
145 }
4f247b19c9ea Add new files
Matti Hamalainen <ccr@tnsp.org>
parents:
diff changeset
146
359
b1a858b8cb1a Re-indentation all (non-generated) code.
Matti Hamalainen <ccr@tnsp.org>
parents: 358
diff changeset
147 static void gtk_curve_set_arg(GtkObject * object, GtkArg * arg, guint arg_id)
358
4f247b19c9ea Add new files
Matti Hamalainen <ccr@tnsp.org>
parents:
diff changeset
148 {
359
b1a858b8cb1a Re-indentation all (non-generated) code.
Matti Hamalainen <ccr@tnsp.org>
parents: 358
diff changeset
149 GtkCurve *curve = GTK_CURVE(object);
b1a858b8cb1a Re-indentation all (non-generated) code.
Matti Hamalainen <ccr@tnsp.org>
parents: 358
diff changeset
150
b1a858b8cb1a Re-indentation all (non-generated) code.
Matti Hamalainen <ccr@tnsp.org>
parents: 358
diff changeset
151 switch (arg_id) {
b1a858b8cb1a Re-indentation all (non-generated) code.
Matti Hamalainen <ccr@tnsp.org>
parents: 358
diff changeset
152 case ARG_CURVE_TYPE:
b1a858b8cb1a Re-indentation all (non-generated) code.
Matti Hamalainen <ccr@tnsp.org>
parents: 358
diff changeset
153 gtk_curve_set_curve_type(curve, GTK_VALUE_ENUM(*arg));
b1a858b8cb1a Re-indentation all (non-generated) code.
Matti Hamalainen <ccr@tnsp.org>
parents: 358
diff changeset
154 break;
b1a858b8cb1a Re-indentation all (non-generated) code.
Matti Hamalainen <ccr@tnsp.org>
parents: 358
diff changeset
155 case ARG_MIN_X:
b1a858b8cb1a Re-indentation all (non-generated) code.
Matti Hamalainen <ccr@tnsp.org>
parents: 358
diff changeset
156 gtk_curve_set_range(curve, GTK_VALUE_FLOAT(*arg), curve->max_x, curve->min_y, curve->max_y);
b1a858b8cb1a Re-indentation all (non-generated) code.
Matti Hamalainen <ccr@tnsp.org>
parents: 358
diff changeset
157 break;
b1a858b8cb1a Re-indentation all (non-generated) code.
Matti Hamalainen <ccr@tnsp.org>
parents: 358
diff changeset
158 case ARG_MAX_X:
b1a858b8cb1a Re-indentation all (non-generated) code.
Matti Hamalainen <ccr@tnsp.org>
parents: 358
diff changeset
159 gtk_curve_set_range(curve, curve->min_x, GTK_VALUE_FLOAT(*arg), curve->min_y, curve->max_y);
b1a858b8cb1a Re-indentation all (non-generated) code.
Matti Hamalainen <ccr@tnsp.org>
parents: 358
diff changeset
160 break;
b1a858b8cb1a Re-indentation all (non-generated) code.
Matti Hamalainen <ccr@tnsp.org>
parents: 358
diff changeset
161 case ARG_MIN_Y:
b1a858b8cb1a Re-indentation all (non-generated) code.
Matti Hamalainen <ccr@tnsp.org>
parents: 358
diff changeset
162 gtk_curve_set_range(curve, curve->min_x, curve->max_x, GTK_VALUE_FLOAT(*arg), curve->max_y);
b1a858b8cb1a Re-indentation all (non-generated) code.
Matti Hamalainen <ccr@tnsp.org>
parents: 358
diff changeset
163 break;
b1a858b8cb1a Re-indentation all (non-generated) code.
Matti Hamalainen <ccr@tnsp.org>
parents: 358
diff changeset
164 case ARG_MAX_Y:
b1a858b8cb1a Re-indentation all (non-generated) code.
Matti Hamalainen <ccr@tnsp.org>
parents: 358
diff changeset
165 gtk_curve_set_range(curve, curve->min_x, curve->max_x, curve->min_y, GTK_VALUE_FLOAT(*arg));
b1a858b8cb1a Re-indentation all (non-generated) code.
Matti Hamalainen <ccr@tnsp.org>
parents: 358
diff changeset
166 break;
b1a858b8cb1a Re-indentation all (non-generated) code.
Matti Hamalainen <ccr@tnsp.org>
parents: 358
diff changeset
167 }
358
4f247b19c9ea Add new files
Matti Hamalainen <ccr@tnsp.org>
parents:
diff changeset
168 }
4f247b19c9ea Add new files
Matti Hamalainen <ccr@tnsp.org>
parents:
diff changeset
169
359
b1a858b8cb1a Re-indentation all (non-generated) code.
Matti Hamalainen <ccr@tnsp.org>
parents: 358
diff changeset
170 static void gtk_curve_get_arg(GtkObject * object, GtkArg * arg, guint arg_id)
358
4f247b19c9ea Add new files
Matti Hamalainen <ccr@tnsp.org>
parents:
diff changeset
171 {
359
b1a858b8cb1a Re-indentation all (non-generated) code.
Matti Hamalainen <ccr@tnsp.org>
parents: 358
diff changeset
172 GtkCurve *curve = GTK_CURVE(object);
358
4f247b19c9ea Add new files
Matti Hamalainen <ccr@tnsp.org>
parents:
diff changeset
173
359
b1a858b8cb1a Re-indentation all (non-generated) code.
Matti Hamalainen <ccr@tnsp.org>
parents: 358
diff changeset
174 switch (arg_id) {
b1a858b8cb1a Re-indentation all (non-generated) code.
Matti Hamalainen <ccr@tnsp.org>
parents: 358
diff changeset
175 case ARG_CURVE_TYPE:
b1a858b8cb1a Re-indentation all (non-generated) code.
Matti Hamalainen <ccr@tnsp.org>
parents: 358
diff changeset
176 GTK_VALUE_ENUM(*arg) = curve->curve_type;
b1a858b8cb1a Re-indentation all (non-generated) code.
Matti Hamalainen <ccr@tnsp.org>
parents: 358
diff changeset
177 break;
b1a858b8cb1a Re-indentation all (non-generated) code.
Matti Hamalainen <ccr@tnsp.org>
parents: 358
diff changeset
178 case ARG_MIN_X:
b1a858b8cb1a Re-indentation all (non-generated) code.
Matti Hamalainen <ccr@tnsp.org>
parents: 358
diff changeset
179 GTK_VALUE_FLOAT(*arg) = curve->min_x;
b1a858b8cb1a Re-indentation all (non-generated) code.
Matti Hamalainen <ccr@tnsp.org>
parents: 358
diff changeset
180 break;
b1a858b8cb1a Re-indentation all (non-generated) code.
Matti Hamalainen <ccr@tnsp.org>
parents: 358
diff changeset
181 case ARG_MAX_X:
b1a858b8cb1a Re-indentation all (non-generated) code.
Matti Hamalainen <ccr@tnsp.org>
parents: 358
diff changeset
182 GTK_VALUE_FLOAT(*arg) = curve->max_x;
b1a858b8cb1a Re-indentation all (non-generated) code.
Matti Hamalainen <ccr@tnsp.org>
parents: 358
diff changeset
183 break;
b1a858b8cb1a Re-indentation all (non-generated) code.
Matti Hamalainen <ccr@tnsp.org>
parents: 358
diff changeset
184 case ARG_MIN_Y:
b1a858b8cb1a Re-indentation all (non-generated) code.
Matti Hamalainen <ccr@tnsp.org>
parents: 358
diff changeset
185 GTK_VALUE_FLOAT(*arg) = curve->min_y;
b1a858b8cb1a Re-indentation all (non-generated) code.
Matti Hamalainen <ccr@tnsp.org>
parents: 358
diff changeset
186 break;
b1a858b8cb1a Re-indentation all (non-generated) code.
Matti Hamalainen <ccr@tnsp.org>
parents: 358
diff changeset
187 case ARG_MAX_Y:
b1a858b8cb1a Re-indentation all (non-generated) code.
Matti Hamalainen <ccr@tnsp.org>
parents: 358
diff changeset
188 GTK_VALUE_FLOAT(*arg) = curve->max_y;
b1a858b8cb1a Re-indentation all (non-generated) code.
Matti Hamalainen <ccr@tnsp.org>
parents: 358
diff changeset
189 break;
b1a858b8cb1a Re-indentation all (non-generated) code.
Matti Hamalainen <ccr@tnsp.org>
parents: 358
diff changeset
190 default:
b1a858b8cb1a Re-indentation all (non-generated) code.
Matti Hamalainen <ccr@tnsp.org>
parents: 358
diff changeset
191 arg->type = GTK_TYPE_INVALID;
b1a858b8cb1a Re-indentation all (non-generated) code.
Matti Hamalainen <ccr@tnsp.org>
parents: 358
diff changeset
192 break;
b1a858b8cb1a Re-indentation all (non-generated) code.
Matti Hamalainen <ccr@tnsp.org>
parents: 358
diff changeset
193 }
358
4f247b19c9ea Add new files
Matti Hamalainen <ccr@tnsp.org>
parents:
diff changeset
194 }
4f247b19c9ea Add new files
Matti Hamalainen <ccr@tnsp.org>
parents:
diff changeset
195
359
b1a858b8cb1a Re-indentation all (non-generated) code.
Matti Hamalainen <ccr@tnsp.org>
parents: 358
diff changeset
196 static int project(gfloat value, gfloat min, gfloat max, int norm)
358
4f247b19c9ea Add new files
Matti Hamalainen <ccr@tnsp.org>
parents:
diff changeset
197 {
359
b1a858b8cb1a Re-indentation all (non-generated) code.
Matti Hamalainen <ccr@tnsp.org>
parents: 358
diff changeset
198 return (norm - 1) * ((value - min) / (max - min)) + 0.5;
358
4f247b19c9ea Add new files
Matti Hamalainen <ccr@tnsp.org>
parents:
diff changeset
199 }
4f247b19c9ea Add new files
Matti Hamalainen <ccr@tnsp.org>
parents:
diff changeset
200
359
b1a858b8cb1a Re-indentation all (non-generated) code.
Matti Hamalainen <ccr@tnsp.org>
parents: 358
diff changeset
201 static gfloat unproject(gint value, gfloat min, gfloat max, int norm)
358
4f247b19c9ea Add new files
Matti Hamalainen <ccr@tnsp.org>
parents:
diff changeset
202 {
359
b1a858b8cb1a Re-indentation all (non-generated) code.
Matti Hamalainen <ccr@tnsp.org>
parents: 358
diff changeset
203 return value / (gfloat) (norm - 1) * (max - min) + min;
358
4f247b19c9ea Add new files
Matti Hamalainen <ccr@tnsp.org>
parents:
diff changeset
204 }
4f247b19c9ea Add new files
Matti Hamalainen <ccr@tnsp.org>
parents:
diff changeset
205
4f247b19c9ea Add new files
Matti Hamalainen <ccr@tnsp.org>
parents:
diff changeset
206 /* Solve the tridiagonal equation system that determines the second
4f247b19c9ea Add new files
Matti Hamalainen <ccr@tnsp.org>
parents:
diff changeset
207 derivatives for the interpolation points. (Based on Numerical
4f247b19c9ea Add new files
Matti Hamalainen <ccr@tnsp.org>
parents:
diff changeset
208 Recipies 2nd Edition.) */
359
b1a858b8cb1a Re-indentation all (non-generated) code.
Matti Hamalainen <ccr@tnsp.org>
parents: 358
diff changeset
209 static void spline_solve(int n, gfloat x[], gfloat y[], gfloat y2[])
358
4f247b19c9ea Add new files
Matti Hamalainen <ccr@tnsp.org>
parents:
diff changeset
210 {
359
b1a858b8cb1a Re-indentation all (non-generated) code.
Matti Hamalainen <ccr@tnsp.org>
parents: 358
diff changeset
211 gfloat p, sig, *u;
b1a858b8cb1a Re-indentation all (non-generated) code.
Matti Hamalainen <ccr@tnsp.org>
parents: 358
diff changeset
212 gint i, k;
358
4f247b19c9ea Add new files
Matti Hamalainen <ccr@tnsp.org>
parents:
diff changeset
213
359
b1a858b8cb1a Re-indentation all (non-generated) code.
Matti Hamalainen <ccr@tnsp.org>
parents: 358
diff changeset
214 u = g_malloc((n - 1) * sizeof(u[0]));
358
4f247b19c9ea Add new files
Matti Hamalainen <ccr@tnsp.org>
parents:
diff changeset
215
359
b1a858b8cb1a Re-indentation all (non-generated) code.
Matti Hamalainen <ccr@tnsp.org>
parents: 358
diff changeset
216 y2[0] = u[0] = 0.0; /* set lower boundary condition to "natural" */
358
4f247b19c9ea Add new files
Matti Hamalainen <ccr@tnsp.org>
parents:
diff changeset
217
359
b1a858b8cb1a Re-indentation all (non-generated) code.
Matti Hamalainen <ccr@tnsp.org>
parents: 358
diff changeset
218 for (i = 1; i < n - 1; ++i) {
b1a858b8cb1a Re-indentation all (non-generated) code.
Matti Hamalainen <ccr@tnsp.org>
parents: 358
diff changeset
219 sig = (x[i] - x[i - 1]) / (x[i + 1] - x[i - 1]);
b1a858b8cb1a Re-indentation all (non-generated) code.
Matti Hamalainen <ccr@tnsp.org>
parents: 358
diff changeset
220 p = sig * y2[i - 1] + 2.0;
b1a858b8cb1a Re-indentation all (non-generated) code.
Matti Hamalainen <ccr@tnsp.org>
parents: 358
diff changeset
221 y2[i] = (sig - 1.0) / p;
b1a858b8cb1a Re-indentation all (non-generated) code.
Matti Hamalainen <ccr@tnsp.org>
parents: 358
diff changeset
222 u[i] = ((y[i + 1] - y[i])
b1a858b8cb1a Re-indentation all (non-generated) code.
Matti Hamalainen <ccr@tnsp.org>
parents: 358
diff changeset
223 / (x[i + 1] - x[i]) - (y[i] - y[i - 1]) / (x[i] - x[i - 1]));
b1a858b8cb1a Re-indentation all (non-generated) code.
Matti Hamalainen <ccr@tnsp.org>
parents: 358
diff changeset
224 u[i] = (6.0 * u[i] / (x[i + 1] - x[i - 1]) - sig * u[i - 1]) / p;
b1a858b8cb1a Re-indentation all (non-generated) code.
Matti Hamalainen <ccr@tnsp.org>
parents: 358
diff changeset
225 }
358
4f247b19c9ea Add new files
Matti Hamalainen <ccr@tnsp.org>
parents:
diff changeset
226
359
b1a858b8cb1a Re-indentation all (non-generated) code.
Matti Hamalainen <ccr@tnsp.org>
parents: 358
diff changeset
227 y2[n - 1] = 0.0;
b1a858b8cb1a Re-indentation all (non-generated) code.
Matti Hamalainen <ccr@tnsp.org>
parents: 358
diff changeset
228 for (k = n - 2; k >= 0; --k)
b1a858b8cb1a Re-indentation all (non-generated) code.
Matti Hamalainen <ccr@tnsp.org>
parents: 358
diff changeset
229 y2[k] = y2[k] * y2[k + 1] + u[k];
358
4f247b19c9ea Add new files
Matti Hamalainen <ccr@tnsp.org>
parents:
diff changeset
230
359
b1a858b8cb1a Re-indentation all (non-generated) code.
Matti Hamalainen <ccr@tnsp.org>
parents: 358
diff changeset
231 g_free(u);
358
4f247b19c9ea Add new files
Matti Hamalainen <ccr@tnsp.org>
parents:
diff changeset
232 }
4f247b19c9ea Add new files
Matti Hamalainen <ccr@tnsp.org>
parents:
diff changeset
233
359
b1a858b8cb1a Re-indentation all (non-generated) code.
Matti Hamalainen <ccr@tnsp.org>
parents: 358
diff changeset
234 static gfloat spline_eval(int n, gfloat x[], gfloat y[], gfloat y2[], gfloat val)
358
4f247b19c9ea Add new files
Matti Hamalainen <ccr@tnsp.org>
parents:
diff changeset
235 {
359
b1a858b8cb1a Re-indentation all (non-generated) code.
Matti Hamalainen <ccr@tnsp.org>
parents: 358
diff changeset
236 gint k_lo, k_hi, k;
b1a858b8cb1a Re-indentation all (non-generated) code.
Matti Hamalainen <ccr@tnsp.org>
parents: 358
diff changeset
237 gfloat h, b, a;
358
4f247b19c9ea Add new files
Matti Hamalainen <ccr@tnsp.org>
parents:
diff changeset
238
359
b1a858b8cb1a Re-indentation all (non-generated) code.
Matti Hamalainen <ccr@tnsp.org>
parents: 358
diff changeset
239 /* do a binary search for the right interval: */
b1a858b8cb1a Re-indentation all (non-generated) code.
Matti Hamalainen <ccr@tnsp.org>
parents: 358
diff changeset
240 k_lo = 0;
b1a858b8cb1a Re-indentation all (non-generated) code.
Matti Hamalainen <ccr@tnsp.org>
parents: 358
diff changeset
241 k_hi = n - 1;
b1a858b8cb1a Re-indentation all (non-generated) code.
Matti Hamalainen <ccr@tnsp.org>
parents: 358
diff changeset
242 while (k_hi - k_lo > 1) {
b1a858b8cb1a Re-indentation all (non-generated) code.
Matti Hamalainen <ccr@tnsp.org>
parents: 358
diff changeset
243 k = (k_hi + k_lo) / 2;
b1a858b8cb1a Re-indentation all (non-generated) code.
Matti Hamalainen <ccr@tnsp.org>
parents: 358
diff changeset
244 if (x[k] > val)
b1a858b8cb1a Re-indentation all (non-generated) code.
Matti Hamalainen <ccr@tnsp.org>
parents: 358
diff changeset
245 k_hi = k;
b1a858b8cb1a Re-indentation all (non-generated) code.
Matti Hamalainen <ccr@tnsp.org>
parents: 358
diff changeset
246 else
b1a858b8cb1a Re-indentation all (non-generated) code.
Matti Hamalainen <ccr@tnsp.org>
parents: 358
diff changeset
247 k_lo = k;
b1a858b8cb1a Re-indentation all (non-generated) code.
Matti Hamalainen <ccr@tnsp.org>
parents: 358
diff changeset
248 }
358
4f247b19c9ea Add new files
Matti Hamalainen <ccr@tnsp.org>
parents:
diff changeset
249
359
b1a858b8cb1a Re-indentation all (non-generated) code.
Matti Hamalainen <ccr@tnsp.org>
parents: 358
diff changeset
250 h = x[k_hi] - x[k_lo];
b1a858b8cb1a Re-indentation all (non-generated) code.
Matti Hamalainen <ccr@tnsp.org>
parents: 358
diff changeset
251 g_assert(h > 0.0);
358
4f247b19c9ea Add new files
Matti Hamalainen <ccr@tnsp.org>
parents:
diff changeset
252
359
b1a858b8cb1a Re-indentation all (non-generated) code.
Matti Hamalainen <ccr@tnsp.org>
parents: 358
diff changeset
253 a = (x[k_hi] - val) / h;
b1a858b8cb1a Re-indentation all (non-generated) code.
Matti Hamalainen <ccr@tnsp.org>
parents: 358
diff changeset
254 b = (val - x[k_lo]) / h;
b1a858b8cb1a Re-indentation all (non-generated) code.
Matti Hamalainen <ccr@tnsp.org>
parents: 358
diff changeset
255 return a * y[k_lo] + b * y[k_hi] + ((a * a * a - a) * y2[k_lo] + (b * b * b - b) * y2[k_hi]) * (h * h) / 6.0;
358
4f247b19c9ea Add new files
Matti Hamalainen <ccr@tnsp.org>
parents:
diff changeset
256 }
4f247b19c9ea Add new files
Matti Hamalainen <ccr@tnsp.org>
parents:
diff changeset
257
359
b1a858b8cb1a Re-indentation all (non-generated) code.
Matti Hamalainen <ccr@tnsp.org>
parents: 358
diff changeset
258 static void gtk_curve_interpolate(GtkCurve * c, gint width, gint height)
358
4f247b19c9ea Add new files
Matti Hamalainen <ccr@tnsp.org>
parents:
diff changeset
259 {
359
b1a858b8cb1a Re-indentation all (non-generated) code.
Matti Hamalainen <ccr@tnsp.org>
parents: 358
diff changeset
260 gfloat *vector;
b1a858b8cb1a Re-indentation all (non-generated) code.
Matti Hamalainen <ccr@tnsp.org>
parents: 358
diff changeset
261 int i;
358
4f247b19c9ea Add new files
Matti Hamalainen <ccr@tnsp.org>
parents:
diff changeset
262
359
b1a858b8cb1a Re-indentation all (non-generated) code.
Matti Hamalainen <ccr@tnsp.org>
parents: 358
diff changeset
263 vector = g_malloc(width * sizeof(vector[0]));
358
4f247b19c9ea Add new files
Matti Hamalainen <ccr@tnsp.org>
parents:
diff changeset
264
359
b1a858b8cb1a Re-indentation all (non-generated) code.
Matti Hamalainen <ccr@tnsp.org>
parents: 358
diff changeset
265 gtk_curve_get_vector(c, width, vector);
358
4f247b19c9ea Add new files
Matti Hamalainen <ccr@tnsp.org>
parents:
diff changeset
266
359
b1a858b8cb1a Re-indentation all (non-generated) code.
Matti Hamalainen <ccr@tnsp.org>
parents: 358
diff changeset
267 c->height = height;
b1a858b8cb1a Re-indentation all (non-generated) code.
Matti Hamalainen <ccr@tnsp.org>
parents: 358
diff changeset
268 if (c->num_points != width) {
b1a858b8cb1a Re-indentation all (non-generated) code.
Matti Hamalainen <ccr@tnsp.org>
parents: 358
diff changeset
269 c->num_points = width;
b1a858b8cb1a Re-indentation all (non-generated) code.
Matti Hamalainen <ccr@tnsp.org>
parents: 358
diff changeset
270 if (c->point)
b1a858b8cb1a Re-indentation all (non-generated) code.
Matti Hamalainen <ccr@tnsp.org>
parents: 358
diff changeset
271 g_free(c->point);
b1a858b8cb1a Re-indentation all (non-generated) code.
Matti Hamalainen <ccr@tnsp.org>
parents: 358
diff changeset
272 c->point = g_malloc(c->num_points * sizeof(c->point[0]));
b1a858b8cb1a Re-indentation all (non-generated) code.
Matti Hamalainen <ccr@tnsp.org>
parents: 358
diff changeset
273 }
358
4f247b19c9ea Add new files
Matti Hamalainen <ccr@tnsp.org>
parents:
diff changeset
274
359
b1a858b8cb1a Re-indentation all (non-generated) code.
Matti Hamalainen <ccr@tnsp.org>
parents: 358
diff changeset
275 for (i = 0; i < width; ++i) {
b1a858b8cb1a Re-indentation all (non-generated) code.
Matti Hamalainen <ccr@tnsp.org>
parents: 358
diff changeset
276 c->point[i].x = RADIUS + i;
b1a858b8cb1a Re-indentation all (non-generated) code.
Matti Hamalainen <ccr@tnsp.org>
parents: 358
diff changeset
277 c->point[i].y = RADIUS + height - project(vector[i], c->min_y, c->max_y, height);
b1a858b8cb1a Re-indentation all (non-generated) code.
Matti Hamalainen <ccr@tnsp.org>
parents: 358
diff changeset
278 }
358
4f247b19c9ea Add new files
Matti Hamalainen <ccr@tnsp.org>
parents:
diff changeset
279
359
b1a858b8cb1a Re-indentation all (non-generated) code.
Matti Hamalainen <ccr@tnsp.org>
parents: 358
diff changeset
280 g_free(vector);
358
4f247b19c9ea Add new files
Matti Hamalainen <ccr@tnsp.org>
parents:
diff changeset
281 }
4f247b19c9ea Add new files
Matti Hamalainen <ccr@tnsp.org>
parents:
diff changeset
282
359
b1a858b8cb1a Re-indentation all (non-generated) code.
Matti Hamalainen <ccr@tnsp.org>
parents: 358
diff changeset
283 static void gtk_curve_draw(GtkCurve * c, gint width, gint height)
358
4f247b19c9ea Add new files
Matti Hamalainen <ccr@tnsp.org>
parents:
diff changeset
284 {
359
b1a858b8cb1a Re-indentation all (non-generated) code.
Matti Hamalainen <ccr@tnsp.org>
parents: 358
diff changeset
285 GtkStateType state;
b1a858b8cb1a Re-indentation all (non-generated) code.
Matti Hamalainen <ccr@tnsp.org>
parents: 358
diff changeset
286 GtkStyle *style;
b1a858b8cb1a Re-indentation all (non-generated) code.
Matti Hamalainen <ccr@tnsp.org>
parents: 358
diff changeset
287 gint i;
b1a858b8cb1a Re-indentation all (non-generated) code.
Matti Hamalainen <ccr@tnsp.org>
parents: 358
diff changeset
288
b1a858b8cb1a Re-indentation all (non-generated) code.
Matti Hamalainen <ccr@tnsp.org>
parents: 358
diff changeset
289 if (!c->pixmap)
b1a858b8cb1a Re-indentation all (non-generated) code.
Matti Hamalainen <ccr@tnsp.org>
parents: 358
diff changeset
290 return;
358
4f247b19c9ea Add new files
Matti Hamalainen <ccr@tnsp.org>
parents:
diff changeset
291
359
b1a858b8cb1a Re-indentation all (non-generated) code.
Matti Hamalainen <ccr@tnsp.org>
parents: 358
diff changeset
292 if (c->height != height || c->num_points != width)
b1a858b8cb1a Re-indentation all (non-generated) code.
Matti Hamalainen <ccr@tnsp.org>
parents: 358
diff changeset
293 gtk_curve_interpolate(c, width, height);
358
4f247b19c9ea Add new files
Matti Hamalainen <ccr@tnsp.org>
parents:
diff changeset
294
359
b1a858b8cb1a Re-indentation all (non-generated) code.
Matti Hamalainen <ccr@tnsp.org>
parents: 358
diff changeset
295 state = GTK_STATE_NORMAL;
b1a858b8cb1a Re-indentation all (non-generated) code.
Matti Hamalainen <ccr@tnsp.org>
parents: 358
diff changeset
296 if (!GTK_WIDGET_IS_SENSITIVE(GTK_WIDGET(c)))
b1a858b8cb1a Re-indentation all (non-generated) code.
Matti Hamalainen <ccr@tnsp.org>
parents: 358
diff changeset
297 state = GTK_STATE_INSENSITIVE;
358
4f247b19c9ea Add new files
Matti Hamalainen <ccr@tnsp.org>
parents:
diff changeset
298
359
b1a858b8cb1a Re-indentation all (non-generated) code.
Matti Hamalainen <ccr@tnsp.org>
parents: 358
diff changeset
299 style = GTK_WIDGET(c)->style;
358
4f247b19c9ea Add new files
Matti Hamalainen <ccr@tnsp.org>
parents:
diff changeset
300
359
b1a858b8cb1a Re-indentation all (non-generated) code.
Matti Hamalainen <ccr@tnsp.org>
parents: 358
diff changeset
301 /* clear the pixmap: */
b1a858b8cb1a Re-indentation all (non-generated) code.
Matti Hamalainen <ccr@tnsp.org>
parents: 358
diff changeset
302 gtk_paint_flat_box(style, c->pixmap, GTK_STATE_NORMAL, GTK_SHADOW_NONE,
b1a858b8cb1a Re-indentation all (non-generated) code.
Matti Hamalainen <ccr@tnsp.org>
parents: 358
diff changeset
303 NULL, GTK_WIDGET(c), "curve_bg", 0, 0, width + RADIUS * 2, height + RADIUS * 2);
b1a858b8cb1a Re-indentation all (non-generated) code.
Matti Hamalainen <ccr@tnsp.org>
parents: 358
diff changeset
304 /* draw the grid lines: (XXX make more meaningful) */
b1a858b8cb1a Re-indentation all (non-generated) code.
Matti Hamalainen <ccr@tnsp.org>
parents: 358
diff changeset
305 for (i = 0; i < 5; i++) {
b1a858b8cb1a Re-indentation all (non-generated) code.
Matti Hamalainen <ccr@tnsp.org>
parents: 358
diff changeset
306 gdk_draw_line(c->pixmap, style->dark_gc[state],
b1a858b8cb1a Re-indentation all (non-generated) code.
Matti Hamalainen <ccr@tnsp.org>
parents: 358
diff changeset
307 RADIUS, i * (height / 4.0) + RADIUS, width + RADIUS, i * (height / 4.0) + RADIUS);
b1a858b8cb1a Re-indentation all (non-generated) code.
Matti Hamalainen <ccr@tnsp.org>
parents: 358
diff changeset
308 gdk_draw_line(c->pixmap, style->dark_gc[state],
b1a858b8cb1a Re-indentation all (non-generated) code.
Matti Hamalainen <ccr@tnsp.org>
parents: 358
diff changeset
309 i * (width / 4.0) + RADIUS, RADIUS, i * (width / 4.0) + RADIUS, height + RADIUS);
b1a858b8cb1a Re-indentation all (non-generated) code.
Matti Hamalainen <ccr@tnsp.org>
parents: 358
diff changeset
310 }
358
4f247b19c9ea Add new files
Matti Hamalainen <ccr@tnsp.org>
parents:
diff changeset
311
359
b1a858b8cb1a Re-indentation all (non-generated) code.
Matti Hamalainen <ccr@tnsp.org>
parents: 358
diff changeset
312 gdk_draw_points(c->pixmap, style->fg_gc[state], c->point, c->num_points);
b1a858b8cb1a Re-indentation all (non-generated) code.
Matti Hamalainen <ccr@tnsp.org>
parents: 358
diff changeset
313 if (c->curve_type != GTK_CURVE_TYPE_FREE)
b1a858b8cb1a Re-indentation all (non-generated) code.
Matti Hamalainen <ccr@tnsp.org>
parents: 358
diff changeset
314 for (i = 0; i < c->num_ctlpoints; ++i) {
b1a858b8cb1a Re-indentation all (non-generated) code.
Matti Hamalainen <ccr@tnsp.org>
parents: 358
diff changeset
315 gint x, y;
358
4f247b19c9ea Add new files
Matti Hamalainen <ccr@tnsp.org>
parents:
diff changeset
316
359
b1a858b8cb1a Re-indentation all (non-generated) code.
Matti Hamalainen <ccr@tnsp.org>
parents: 358
diff changeset
317 if (c->ctlpoint[i][0] < c->min_x)
b1a858b8cb1a Re-indentation all (non-generated) code.
Matti Hamalainen <ccr@tnsp.org>
parents: 358
diff changeset
318 continue;
358
4f247b19c9ea Add new files
Matti Hamalainen <ccr@tnsp.org>
parents:
diff changeset
319
359
b1a858b8cb1a Re-indentation all (non-generated) code.
Matti Hamalainen <ccr@tnsp.org>
parents: 358
diff changeset
320 x = project(c->ctlpoint[i][0], c->min_x, c->max_x, width);
b1a858b8cb1a Re-indentation all (non-generated) code.
Matti Hamalainen <ccr@tnsp.org>
parents: 358
diff changeset
321 y = height - project(c->ctlpoint[i][1], c->min_y, c->max_y, height);
358
4f247b19c9ea Add new files
Matti Hamalainen <ccr@tnsp.org>
parents:
diff changeset
322
359
b1a858b8cb1a Re-indentation all (non-generated) code.
Matti Hamalainen <ccr@tnsp.org>
parents: 358
diff changeset
323 /* draw a bullet: */
b1a858b8cb1a Re-indentation all (non-generated) code.
Matti Hamalainen <ccr@tnsp.org>
parents: 358
diff changeset
324 gdk_draw_arc(c->pixmap, style->fg_gc[state], TRUE, x, y, RADIUS * 2, RADIUS * 2, 0, 360 * 64);
b1a858b8cb1a Re-indentation all (non-generated) code.
Matti Hamalainen <ccr@tnsp.org>
parents: 358
diff changeset
325 }
b1a858b8cb1a Re-indentation all (non-generated) code.
Matti Hamalainen <ccr@tnsp.org>
parents: 358
diff changeset
326 gdk_draw_pixmap(GTK_WIDGET(c)->window, style->fg_gc[state], c->pixmap,
b1a858b8cb1a Re-indentation all (non-generated) code.
Matti Hamalainen <ccr@tnsp.org>
parents: 358
diff changeset
327 0, 0, 0, 0, width + RADIUS * 2, height + RADIUS * 2);
358
4f247b19c9ea Add new files
Matti Hamalainen <ccr@tnsp.org>
parents:
diff changeset
328 }
4f247b19c9ea Add new files
Matti Hamalainen <ccr@tnsp.org>
parents:
diff changeset
329
359
b1a858b8cb1a Re-indentation all (non-generated) code.
Matti Hamalainen <ccr@tnsp.org>
parents: 358
diff changeset
330 static gint gtk_curve_graph_events(GtkWidget * widget, GdkEvent * event, GtkCurve * c)
358
4f247b19c9ea Add new files
Matti Hamalainen <ccr@tnsp.org>
parents:
diff changeset
331 {
359
b1a858b8cb1a Re-indentation all (non-generated) code.
Matti Hamalainen <ccr@tnsp.org>
parents: 358
diff changeset
332 GdkCursorType new_type = c->cursor_type;
b1a858b8cb1a Re-indentation all (non-generated) code.
Matti Hamalainen <ccr@tnsp.org>
parents: 358
diff changeset
333 gint i, src, dst, leftbound, rightbound;
b1a858b8cb1a Re-indentation all (non-generated) code.
Matti Hamalainen <ccr@tnsp.org>
parents: 358
diff changeset
334 GdkEventButton *bevent;
b1a858b8cb1a Re-indentation all (non-generated) code.
Matti Hamalainen <ccr@tnsp.org>
parents: 358
diff changeset
335 GdkEventMotion *mevent;
b1a858b8cb1a Re-indentation all (non-generated) code.
Matti Hamalainen <ccr@tnsp.org>
parents: 358
diff changeset
336 GtkWidget *w;
b1a858b8cb1a Re-indentation all (non-generated) code.
Matti Hamalainen <ccr@tnsp.org>
parents: 358
diff changeset
337 gint tx, ty;
b1a858b8cb1a Re-indentation all (non-generated) code.
Matti Hamalainen <ccr@tnsp.org>
parents: 358
diff changeset
338 gint cx, x, y, width, height;
b1a858b8cb1a Re-indentation all (non-generated) code.
Matti Hamalainen <ccr@tnsp.org>
parents: 358
diff changeset
339 gint closest_point = 0;
b1a858b8cb1a Re-indentation all (non-generated) code.
Matti Hamalainen <ccr@tnsp.org>
parents: 358
diff changeset
340 gfloat rx, ry, min_x;
b1a858b8cb1a Re-indentation all (non-generated) code.
Matti Hamalainen <ccr@tnsp.org>
parents: 358
diff changeset
341 guint distance;
b1a858b8cb1a Re-indentation all (non-generated) code.
Matti Hamalainen <ccr@tnsp.org>
parents: 358
diff changeset
342 gint x1, x2, y1, y2;
b1a858b8cb1a Re-indentation all (non-generated) code.
Matti Hamalainen <ccr@tnsp.org>
parents: 358
diff changeset
343
b1a858b8cb1a Re-indentation all (non-generated) code.
Matti Hamalainen <ccr@tnsp.org>
parents: 358
diff changeset
344 w = GTK_WIDGET(c);
b1a858b8cb1a Re-indentation all (non-generated) code.
Matti Hamalainen <ccr@tnsp.org>
parents: 358
diff changeset
345 width = w->allocation.width - RADIUS * 2;
b1a858b8cb1a Re-indentation all (non-generated) code.
Matti Hamalainen <ccr@tnsp.org>
parents: 358
diff changeset
346 height = w->allocation.height - RADIUS * 2;
358
4f247b19c9ea Add new files
Matti Hamalainen <ccr@tnsp.org>
parents:
diff changeset
347
359
b1a858b8cb1a Re-indentation all (non-generated) code.
Matti Hamalainen <ccr@tnsp.org>
parents: 358
diff changeset
348 if ((width < 0) || (height < 0))
b1a858b8cb1a Re-indentation all (non-generated) code.
Matti Hamalainen <ccr@tnsp.org>
parents: 358
diff changeset
349 return FALSE;
b1a858b8cb1a Re-indentation all (non-generated) code.
Matti Hamalainen <ccr@tnsp.org>
parents: 358
diff changeset
350
b1a858b8cb1a Re-indentation all (non-generated) code.
Matti Hamalainen <ccr@tnsp.org>
parents: 358
diff changeset
351 /* get the pointer position */
b1a858b8cb1a Re-indentation all (non-generated) code.
Matti Hamalainen <ccr@tnsp.org>
parents: 358
diff changeset
352 gdk_window_get_pointer(w->window, &tx, &ty, NULL);
b1a858b8cb1a Re-indentation all (non-generated) code.
Matti Hamalainen <ccr@tnsp.org>
parents: 358
diff changeset
353 x = CLAMP((tx - RADIUS), 0, width - 1);
b1a858b8cb1a Re-indentation all (non-generated) code.
Matti Hamalainen <ccr@tnsp.org>
parents: 358
diff changeset
354 y = CLAMP((ty - RADIUS), 0, height - 1);
b1a858b8cb1a Re-indentation all (non-generated) code.
Matti Hamalainen <ccr@tnsp.org>
parents: 358
diff changeset
355
b1a858b8cb1a Re-indentation all (non-generated) code.
Matti Hamalainen <ccr@tnsp.org>
parents: 358
diff changeset
356 min_x = c->min_x;
b1a858b8cb1a Re-indentation all (non-generated) code.
Matti Hamalainen <ccr@tnsp.org>
parents: 358
diff changeset
357
b1a858b8cb1a Re-indentation all (non-generated) code.
Matti Hamalainen <ccr@tnsp.org>
parents: 358
diff changeset
358 distance = ~0U;
b1a858b8cb1a Re-indentation all (non-generated) code.
Matti Hamalainen <ccr@tnsp.org>
parents: 358
diff changeset
359 for (i = 0; i < c->num_ctlpoints; ++i) {
b1a858b8cb1a Re-indentation all (non-generated) code.
Matti Hamalainen <ccr@tnsp.org>
parents: 358
diff changeset
360 cx = project(c->ctlpoint[i][0], min_x, c->max_x, width);
b1a858b8cb1a Re-indentation all (non-generated) code.
Matti Hamalainen <ccr@tnsp.org>
parents: 358
diff changeset
361 if ((guint) abs(x - cx) < distance) {
b1a858b8cb1a Re-indentation all (non-generated) code.
Matti Hamalainen <ccr@tnsp.org>
parents: 358
diff changeset
362 distance = abs(x - cx);
b1a858b8cb1a Re-indentation all (non-generated) code.
Matti Hamalainen <ccr@tnsp.org>
parents: 358
diff changeset
363 closest_point = i;
b1a858b8cb1a Re-indentation all (non-generated) code.
Matti Hamalainen <ccr@tnsp.org>
parents: 358
diff changeset
364 }
b1a858b8cb1a Re-indentation all (non-generated) code.
Matti Hamalainen <ccr@tnsp.org>
parents: 358
diff changeset
365 }
358
4f247b19c9ea Add new files
Matti Hamalainen <ccr@tnsp.org>
parents:
diff changeset
366
359
b1a858b8cb1a Re-indentation all (non-generated) code.
Matti Hamalainen <ccr@tnsp.org>
parents: 358
diff changeset
367 switch (event->type) {
b1a858b8cb1a Re-indentation all (non-generated) code.
Matti Hamalainen <ccr@tnsp.org>
parents: 358
diff changeset
368 case GDK_CONFIGURE:
b1a858b8cb1a Re-indentation all (non-generated) code.
Matti Hamalainen <ccr@tnsp.org>
parents: 358
diff changeset
369 if (c->pixmap)
b1a858b8cb1a Re-indentation all (non-generated) code.
Matti Hamalainen <ccr@tnsp.org>
parents: 358
diff changeset
370 gdk_pixmap_unref(c->pixmap);
b1a858b8cb1a Re-indentation all (non-generated) code.
Matti Hamalainen <ccr@tnsp.org>
parents: 358
diff changeset
371 c->pixmap = 0;
b1a858b8cb1a Re-indentation all (non-generated) code.
Matti Hamalainen <ccr@tnsp.org>
parents: 358
diff changeset
372 /* fall through */
b1a858b8cb1a Re-indentation all (non-generated) code.
Matti Hamalainen <ccr@tnsp.org>
parents: 358
diff changeset
373 case GDK_EXPOSE:
b1a858b8cb1a Re-indentation all (non-generated) code.
Matti Hamalainen <ccr@tnsp.org>
parents: 358
diff changeset
374 if (!c->pixmap)
b1a858b8cb1a Re-indentation all (non-generated) code.
Matti Hamalainen <ccr@tnsp.org>
parents: 358
diff changeset
375 c->pixmap = gdk_pixmap_new(w->window, w->allocation.width, w->allocation.height, -1);
b1a858b8cb1a Re-indentation all (non-generated) code.
Matti Hamalainen <ccr@tnsp.org>
parents: 358
diff changeset
376 gtk_curve_draw(c, width, height);
b1a858b8cb1a Re-indentation all (non-generated) code.
Matti Hamalainen <ccr@tnsp.org>
parents: 358
diff changeset
377 break;
358
4f247b19c9ea Add new files
Matti Hamalainen <ccr@tnsp.org>
parents:
diff changeset
378
359
b1a858b8cb1a Re-indentation all (non-generated) code.
Matti Hamalainen <ccr@tnsp.org>
parents: 358
diff changeset
379 case GDK_BUTTON_PRESS:
b1a858b8cb1a Re-indentation all (non-generated) code.
Matti Hamalainen <ccr@tnsp.org>
parents: 358
diff changeset
380 gtk_grab_add(widget);
358
4f247b19c9ea Add new files
Matti Hamalainen <ccr@tnsp.org>
parents:
diff changeset
381
359
b1a858b8cb1a Re-indentation all (non-generated) code.
Matti Hamalainen <ccr@tnsp.org>
parents: 358
diff changeset
382 bevent = (GdkEventButton *) event;
b1a858b8cb1a Re-indentation all (non-generated) code.
Matti Hamalainen <ccr@tnsp.org>
parents: 358
diff changeset
383 new_type = GDK_TCROSS;
358
4f247b19c9ea Add new files
Matti Hamalainen <ccr@tnsp.org>
parents:
diff changeset
384
359
b1a858b8cb1a Re-indentation all (non-generated) code.
Matti Hamalainen <ccr@tnsp.org>
parents: 358
diff changeset
385 switch (c->curve_type) {
b1a858b8cb1a Re-indentation all (non-generated) code.
Matti Hamalainen <ccr@tnsp.org>
parents: 358
diff changeset
386 case GTK_CURVE_TYPE_LINEAR:
b1a858b8cb1a Re-indentation all (non-generated) code.
Matti Hamalainen <ccr@tnsp.org>
parents: 358
diff changeset
387 case GTK_CURVE_TYPE_SPLINE:
b1a858b8cb1a Re-indentation all (non-generated) code.
Matti Hamalainen <ccr@tnsp.org>
parents: 358
diff changeset
388 if (distance > MIN_DISTANCE) {
b1a858b8cb1a Re-indentation all (non-generated) code.
Matti Hamalainen <ccr@tnsp.org>
parents: 358
diff changeset
389 /* insert a new control point */
b1a858b8cb1a Re-indentation all (non-generated) code.
Matti Hamalainen <ccr@tnsp.org>
parents: 358
diff changeset
390 if (c->num_ctlpoints > 0) {
b1a858b8cb1a Re-indentation all (non-generated) code.
Matti Hamalainen <ccr@tnsp.org>
parents: 358
diff changeset
391 cx = project(c->ctlpoint[closest_point][0], min_x, c->max_x, width);
b1a858b8cb1a Re-indentation all (non-generated) code.
Matti Hamalainen <ccr@tnsp.org>
parents: 358
diff changeset
392 if (x > cx)
b1a858b8cb1a Re-indentation all (non-generated) code.
Matti Hamalainen <ccr@tnsp.org>
parents: 358
diff changeset
393 ++closest_point;
b1a858b8cb1a Re-indentation all (non-generated) code.
Matti Hamalainen <ccr@tnsp.org>
parents: 358
diff changeset
394 }
b1a858b8cb1a Re-indentation all (non-generated) code.
Matti Hamalainen <ccr@tnsp.org>
parents: 358
diff changeset
395 ++c->num_ctlpoints;
b1a858b8cb1a Re-indentation all (non-generated) code.
Matti Hamalainen <ccr@tnsp.org>
parents: 358
diff changeset
396 c->ctlpoint = g_realloc(c->ctlpoint, c->num_ctlpoints * sizeof(*c->ctlpoint));
b1a858b8cb1a Re-indentation all (non-generated) code.
Matti Hamalainen <ccr@tnsp.org>
parents: 358
diff changeset
397 for (i = c->num_ctlpoints - 1; i > closest_point; --i)
b1a858b8cb1a Re-indentation all (non-generated) code.
Matti Hamalainen <ccr@tnsp.org>
parents: 358
diff changeset
398 memcpy(c->ctlpoint + i, c->ctlpoint + i - 1, sizeof(*c->ctlpoint));
b1a858b8cb1a Re-indentation all (non-generated) code.
Matti Hamalainen <ccr@tnsp.org>
parents: 358
diff changeset
399 }
b1a858b8cb1a Re-indentation all (non-generated) code.
Matti Hamalainen <ccr@tnsp.org>
parents: 358
diff changeset
400 c->grab_point = closest_point;
b1a858b8cb1a Re-indentation all (non-generated) code.
Matti Hamalainen <ccr@tnsp.org>
parents: 358
diff changeset
401 c->ctlpoint[c->grab_point][0] = unproject(x, min_x, c->max_x, width);
b1a858b8cb1a Re-indentation all (non-generated) code.
Matti Hamalainen <ccr@tnsp.org>
parents: 358
diff changeset
402 c->ctlpoint[c->grab_point][1] = unproject(height - y, c->min_y, c->max_y, height);
b1a858b8cb1a Re-indentation all (non-generated) code.
Matti Hamalainen <ccr@tnsp.org>
parents: 358
diff changeset
403
b1a858b8cb1a Re-indentation all (non-generated) code.
Matti Hamalainen <ccr@tnsp.org>
parents: 358
diff changeset
404 gtk_curve_interpolate(c, width, height);
b1a858b8cb1a Re-indentation all (non-generated) code.
Matti Hamalainen <ccr@tnsp.org>
parents: 358
diff changeset
405 break;
b1a858b8cb1a Re-indentation all (non-generated) code.
Matti Hamalainen <ccr@tnsp.org>
parents: 358
diff changeset
406
b1a858b8cb1a Re-indentation all (non-generated) code.
Matti Hamalainen <ccr@tnsp.org>
parents: 358
diff changeset
407 case GTK_CURVE_TYPE_FREE:
b1a858b8cb1a Re-indentation all (non-generated) code.
Matti Hamalainen <ccr@tnsp.org>
parents: 358
diff changeset
408 c->point[x].x = RADIUS + x;
b1a858b8cb1a Re-indentation all (non-generated) code.
Matti Hamalainen <ccr@tnsp.org>
parents: 358
diff changeset
409 c->point[x].y = RADIUS + y;
b1a858b8cb1a Re-indentation all (non-generated) code.
Matti Hamalainen <ccr@tnsp.org>
parents: 358
diff changeset
410 c->grab_point = x;
b1a858b8cb1a Re-indentation all (non-generated) code.
Matti Hamalainen <ccr@tnsp.org>
parents: 358
diff changeset
411 c->last = y;
b1a858b8cb1a Re-indentation all (non-generated) code.
Matti Hamalainen <ccr@tnsp.org>
parents: 358
diff changeset
412 break;
b1a858b8cb1a Re-indentation all (non-generated) code.
Matti Hamalainen <ccr@tnsp.org>
parents: 358
diff changeset
413 }
b1a858b8cb1a Re-indentation all (non-generated) code.
Matti Hamalainen <ccr@tnsp.org>
parents: 358
diff changeset
414 gtk_curve_draw(c, width, height);
b1a858b8cb1a Re-indentation all (non-generated) code.
Matti Hamalainen <ccr@tnsp.org>
parents: 358
diff changeset
415 break;
b1a858b8cb1a Re-indentation all (non-generated) code.
Matti Hamalainen <ccr@tnsp.org>
parents: 358
diff changeset
416
b1a858b8cb1a Re-indentation all (non-generated) code.
Matti Hamalainen <ccr@tnsp.org>
parents: 358
diff changeset
417 case GDK_BUTTON_RELEASE:
b1a858b8cb1a Re-indentation all (non-generated) code.
Matti Hamalainen <ccr@tnsp.org>
parents: 358
diff changeset
418 gtk_grab_remove(widget);
358
4f247b19c9ea Add new files
Matti Hamalainen <ccr@tnsp.org>
parents:
diff changeset
419
359
b1a858b8cb1a Re-indentation all (non-generated) code.
Matti Hamalainen <ccr@tnsp.org>
parents: 358
diff changeset
420 /* delete inactive points: */
b1a858b8cb1a Re-indentation all (non-generated) code.
Matti Hamalainen <ccr@tnsp.org>
parents: 358
diff changeset
421 if (c->curve_type != GTK_CURVE_TYPE_FREE) {
b1a858b8cb1a Re-indentation all (non-generated) code.
Matti Hamalainen <ccr@tnsp.org>
parents: 358
diff changeset
422 for (src = dst = 0; src < c->num_ctlpoints; ++src) {
b1a858b8cb1a Re-indentation all (non-generated) code.
Matti Hamalainen <ccr@tnsp.org>
parents: 358
diff changeset
423 if (c->ctlpoint[src][0] >= min_x) {
b1a858b8cb1a Re-indentation all (non-generated) code.
Matti Hamalainen <ccr@tnsp.org>
parents: 358
diff changeset
424 memcpy(c->ctlpoint + dst, c->ctlpoint + src, sizeof(*c->ctlpoint));
b1a858b8cb1a Re-indentation all (non-generated) code.
Matti Hamalainen <ccr@tnsp.org>
parents: 358
diff changeset
425 ++dst;
b1a858b8cb1a Re-indentation all (non-generated) code.
Matti Hamalainen <ccr@tnsp.org>
parents: 358
diff changeset
426 }
b1a858b8cb1a Re-indentation all (non-generated) code.
Matti Hamalainen <ccr@tnsp.org>
parents: 358
diff changeset
427 }
b1a858b8cb1a Re-indentation all (non-generated) code.
Matti Hamalainen <ccr@tnsp.org>
parents: 358
diff changeset
428 if (dst < src) {
b1a858b8cb1a Re-indentation all (non-generated) code.
Matti Hamalainen <ccr@tnsp.org>
parents: 358
diff changeset
429 c->num_ctlpoints -= (src - dst);
b1a858b8cb1a Re-indentation all (non-generated) code.
Matti Hamalainen <ccr@tnsp.org>
parents: 358
diff changeset
430 if (c->num_ctlpoints <= 0) {
b1a858b8cb1a Re-indentation all (non-generated) code.
Matti Hamalainen <ccr@tnsp.org>
parents: 358
diff changeset
431 c->num_ctlpoints = 1;
b1a858b8cb1a Re-indentation all (non-generated) code.
Matti Hamalainen <ccr@tnsp.org>
parents: 358
diff changeset
432 c->ctlpoint[0][0] = min_x;
b1a858b8cb1a Re-indentation all (non-generated) code.
Matti Hamalainen <ccr@tnsp.org>
parents: 358
diff changeset
433 c->ctlpoint[0][1] = c->min_y;
b1a858b8cb1a Re-indentation all (non-generated) code.
Matti Hamalainen <ccr@tnsp.org>
parents: 358
diff changeset
434 gtk_curve_interpolate(c, width, height);
b1a858b8cb1a Re-indentation all (non-generated) code.
Matti Hamalainen <ccr@tnsp.org>
parents: 358
diff changeset
435 gtk_curve_draw(c, width, height);
b1a858b8cb1a Re-indentation all (non-generated) code.
Matti Hamalainen <ccr@tnsp.org>
parents: 358
diff changeset
436 }
b1a858b8cb1a Re-indentation all (non-generated) code.
Matti Hamalainen <ccr@tnsp.org>
parents: 358
diff changeset
437 c->ctlpoint = g_realloc(c->ctlpoint, c->num_ctlpoints * sizeof(*c->ctlpoint));
b1a858b8cb1a Re-indentation all (non-generated) code.
Matti Hamalainen <ccr@tnsp.org>
parents: 358
diff changeset
438 }
b1a858b8cb1a Re-indentation all (non-generated) code.
Matti Hamalainen <ccr@tnsp.org>
parents: 358
diff changeset
439 }
b1a858b8cb1a Re-indentation all (non-generated) code.
Matti Hamalainen <ccr@tnsp.org>
parents: 358
diff changeset
440 new_type = GDK_FLEUR;
b1a858b8cb1a Re-indentation all (non-generated) code.
Matti Hamalainen <ccr@tnsp.org>
parents: 358
diff changeset
441 c->grab_point = -1;
b1a858b8cb1a Re-indentation all (non-generated) code.
Matti Hamalainen <ccr@tnsp.org>
parents: 358
diff changeset
442 break;
358
4f247b19c9ea Add new files
Matti Hamalainen <ccr@tnsp.org>
parents:
diff changeset
443
359
b1a858b8cb1a Re-indentation all (non-generated) code.
Matti Hamalainen <ccr@tnsp.org>
parents: 358
diff changeset
444 case GDK_MOTION_NOTIFY:
b1a858b8cb1a Re-indentation all (non-generated) code.
Matti Hamalainen <ccr@tnsp.org>
parents: 358
diff changeset
445 mevent = (GdkEventMotion *) event;
358
4f247b19c9ea Add new files
Matti Hamalainen <ccr@tnsp.org>
parents:
diff changeset
446
359
b1a858b8cb1a Re-indentation all (non-generated) code.
Matti Hamalainen <ccr@tnsp.org>
parents: 358
diff changeset
447 switch (c->curve_type) {
b1a858b8cb1a Re-indentation all (non-generated) code.
Matti Hamalainen <ccr@tnsp.org>
parents: 358
diff changeset
448 case GTK_CURVE_TYPE_LINEAR:
b1a858b8cb1a Re-indentation all (non-generated) code.
Matti Hamalainen <ccr@tnsp.org>
parents: 358
diff changeset
449 case GTK_CURVE_TYPE_SPLINE:
b1a858b8cb1a Re-indentation all (non-generated) code.
Matti Hamalainen <ccr@tnsp.org>
parents: 358
diff changeset
450 if (c->grab_point == -1) {
b1a858b8cb1a Re-indentation all (non-generated) code.
Matti Hamalainen <ccr@tnsp.org>
parents: 358
diff changeset
451 /* if no point is grabbed... */
b1a858b8cb1a Re-indentation all (non-generated) code.
Matti Hamalainen <ccr@tnsp.org>
parents: 358
diff changeset
452 if (distance <= MIN_DISTANCE)
b1a858b8cb1a Re-indentation all (non-generated) code.
Matti Hamalainen <ccr@tnsp.org>
parents: 358
diff changeset
453 new_type = GDK_FLEUR;
b1a858b8cb1a Re-indentation all (non-generated) code.
Matti Hamalainen <ccr@tnsp.org>
parents: 358
diff changeset
454 else
b1a858b8cb1a Re-indentation all (non-generated) code.
Matti Hamalainen <ccr@tnsp.org>
parents: 358
diff changeset
455 new_type = GDK_TCROSS;
b1a858b8cb1a Re-indentation all (non-generated) code.
Matti Hamalainen <ccr@tnsp.org>
parents: 358
diff changeset
456 } else {
b1a858b8cb1a Re-indentation all (non-generated) code.
Matti Hamalainen <ccr@tnsp.org>
parents: 358
diff changeset
457 /* drag the grabbed point */
b1a858b8cb1a Re-indentation all (non-generated) code.
Matti Hamalainen <ccr@tnsp.org>
parents: 358
diff changeset
458 new_type = GDK_TCROSS;
b1a858b8cb1a Re-indentation all (non-generated) code.
Matti Hamalainen <ccr@tnsp.org>
parents: 358
diff changeset
459
b1a858b8cb1a Re-indentation all (non-generated) code.
Matti Hamalainen <ccr@tnsp.org>
parents: 358
diff changeset
460 leftbound = -MIN_DISTANCE;
b1a858b8cb1a Re-indentation all (non-generated) code.
Matti Hamalainen <ccr@tnsp.org>
parents: 358
diff changeset
461 if (c->grab_point > 0)
b1a858b8cb1a Re-indentation all (non-generated) code.
Matti Hamalainen <ccr@tnsp.org>
parents: 358
diff changeset
462 leftbound = project(c->ctlpoint[c->grab_point - 1][0], min_x, c->max_x, width);
b1a858b8cb1a Re-indentation all (non-generated) code.
Matti Hamalainen <ccr@tnsp.org>
parents: 358
diff changeset
463
b1a858b8cb1a Re-indentation all (non-generated) code.
Matti Hamalainen <ccr@tnsp.org>
parents: 358
diff changeset
464 rightbound = width + RADIUS * 2 + MIN_DISTANCE;
b1a858b8cb1a Re-indentation all (non-generated) code.
Matti Hamalainen <ccr@tnsp.org>
parents: 358
diff changeset
465 if (c->grab_point + 1 < c->num_ctlpoints)
b1a858b8cb1a Re-indentation all (non-generated) code.
Matti Hamalainen <ccr@tnsp.org>
parents: 358
diff changeset
466 rightbound = project(c->ctlpoint[c->grab_point + 1][0], min_x, c->max_x, width);
358
4f247b19c9ea Add new files
Matti Hamalainen <ccr@tnsp.org>
parents:
diff changeset
467
359
b1a858b8cb1a Re-indentation all (non-generated) code.
Matti Hamalainen <ccr@tnsp.org>
parents: 358
diff changeset
468 if (tx <= leftbound || tx >= rightbound
b1a858b8cb1a Re-indentation all (non-generated) code.
Matti Hamalainen <ccr@tnsp.org>
parents: 358
diff changeset
469 || ty > height + RADIUS * 2 + MIN_DISTANCE || ty < -MIN_DISTANCE)
b1a858b8cb1a Re-indentation all (non-generated) code.
Matti Hamalainen <ccr@tnsp.org>
parents: 358
diff changeset
470 c->ctlpoint[c->grab_point][0] = min_x - 1.0;
b1a858b8cb1a Re-indentation all (non-generated) code.
Matti Hamalainen <ccr@tnsp.org>
parents: 358
diff changeset
471 else {
b1a858b8cb1a Re-indentation all (non-generated) code.
Matti Hamalainen <ccr@tnsp.org>
parents: 358
diff changeset
472 rx = unproject(x, min_x, c->max_x, width);
b1a858b8cb1a Re-indentation all (non-generated) code.
Matti Hamalainen <ccr@tnsp.org>
parents: 358
diff changeset
473 ry = unproject(height - y, c->min_y, c->max_y, height);
b1a858b8cb1a Re-indentation all (non-generated) code.
Matti Hamalainen <ccr@tnsp.org>
parents: 358
diff changeset
474 c->ctlpoint[c->grab_point][0] = rx;
b1a858b8cb1a Re-indentation all (non-generated) code.
Matti Hamalainen <ccr@tnsp.org>
parents: 358
diff changeset
475 c->ctlpoint[c->grab_point][1] = ry;
b1a858b8cb1a Re-indentation all (non-generated) code.
Matti Hamalainen <ccr@tnsp.org>
parents: 358
diff changeset
476 }
b1a858b8cb1a Re-indentation all (non-generated) code.
Matti Hamalainen <ccr@tnsp.org>
parents: 358
diff changeset
477 gtk_curve_interpolate(c, width, height);
b1a858b8cb1a Re-indentation all (non-generated) code.
Matti Hamalainen <ccr@tnsp.org>
parents: 358
diff changeset
478 gtk_curve_draw(c, width, height);
b1a858b8cb1a Re-indentation all (non-generated) code.
Matti Hamalainen <ccr@tnsp.org>
parents: 358
diff changeset
479 }
b1a858b8cb1a Re-indentation all (non-generated) code.
Matti Hamalainen <ccr@tnsp.org>
parents: 358
diff changeset
480 break;
b1a858b8cb1a Re-indentation all (non-generated) code.
Matti Hamalainen <ccr@tnsp.org>
parents: 358
diff changeset
481
b1a858b8cb1a Re-indentation all (non-generated) code.
Matti Hamalainen <ccr@tnsp.org>
parents: 358
diff changeset
482 case GTK_CURVE_TYPE_FREE:
b1a858b8cb1a Re-indentation all (non-generated) code.
Matti Hamalainen <ccr@tnsp.org>
parents: 358
diff changeset
483 if (c->grab_point != -1) {
b1a858b8cb1a Re-indentation all (non-generated) code.
Matti Hamalainen <ccr@tnsp.org>
parents: 358
diff changeset
484 if (c->grab_point > x) {
b1a858b8cb1a Re-indentation all (non-generated) code.
Matti Hamalainen <ccr@tnsp.org>
parents: 358
diff changeset
485 x1 = x;
b1a858b8cb1a Re-indentation all (non-generated) code.
Matti Hamalainen <ccr@tnsp.org>
parents: 358
diff changeset
486 x2 = c->grab_point;
b1a858b8cb1a Re-indentation all (non-generated) code.
Matti Hamalainen <ccr@tnsp.org>
parents: 358
diff changeset
487 y1 = y;
b1a858b8cb1a Re-indentation all (non-generated) code.
Matti Hamalainen <ccr@tnsp.org>
parents: 358
diff changeset
488 y2 = c->last;
b1a858b8cb1a Re-indentation all (non-generated) code.
Matti Hamalainen <ccr@tnsp.org>
parents: 358
diff changeset
489 } else {
b1a858b8cb1a Re-indentation all (non-generated) code.
Matti Hamalainen <ccr@tnsp.org>
parents: 358
diff changeset
490 x1 = c->grab_point;
b1a858b8cb1a Re-indentation all (non-generated) code.
Matti Hamalainen <ccr@tnsp.org>
parents: 358
diff changeset
491 x2 = x;
b1a858b8cb1a Re-indentation all (non-generated) code.
Matti Hamalainen <ccr@tnsp.org>
parents: 358
diff changeset
492 y1 = c->last;
b1a858b8cb1a Re-indentation all (non-generated) code.
Matti Hamalainen <ccr@tnsp.org>
parents: 358
diff changeset
493 y2 = y;
b1a858b8cb1a Re-indentation all (non-generated) code.
Matti Hamalainen <ccr@tnsp.org>
parents: 358
diff changeset
494 }
b1a858b8cb1a Re-indentation all (non-generated) code.
Matti Hamalainen <ccr@tnsp.org>
parents: 358
diff changeset
495
b1a858b8cb1a Re-indentation all (non-generated) code.
Matti Hamalainen <ccr@tnsp.org>
parents: 358
diff changeset
496 if (x2 != x1)
b1a858b8cb1a Re-indentation all (non-generated) code.
Matti Hamalainen <ccr@tnsp.org>
parents: 358
diff changeset
497 for (i = x1; i <= x2; i++) {
b1a858b8cb1a Re-indentation all (non-generated) code.
Matti Hamalainen <ccr@tnsp.org>
parents: 358
diff changeset
498 c->point[i].x = RADIUS + i;
b1a858b8cb1a Re-indentation all (non-generated) code.
Matti Hamalainen <ccr@tnsp.org>
parents: 358
diff changeset
499 c->point[i].y = RADIUS + (y1 + ((y2 - y1) * (i - x1)) / (x2 - x1));
b1a858b8cb1a Re-indentation all (non-generated) code.
Matti Hamalainen <ccr@tnsp.org>
parents: 358
diff changeset
500 } else {
b1a858b8cb1a Re-indentation all (non-generated) code.
Matti Hamalainen <ccr@tnsp.org>
parents: 358
diff changeset
501 c->point[x].x = RADIUS + x;
b1a858b8cb1a Re-indentation all (non-generated) code.
Matti Hamalainen <ccr@tnsp.org>
parents: 358
diff changeset
502 c->point[x].y = RADIUS + y;
b1a858b8cb1a Re-indentation all (non-generated) code.
Matti Hamalainen <ccr@tnsp.org>
parents: 358
diff changeset
503 }
b1a858b8cb1a Re-indentation all (non-generated) code.
Matti Hamalainen <ccr@tnsp.org>
parents: 358
diff changeset
504 c->grab_point = x;
b1a858b8cb1a Re-indentation all (non-generated) code.
Matti Hamalainen <ccr@tnsp.org>
parents: 358
diff changeset
505 c->last = y;
b1a858b8cb1a Re-indentation all (non-generated) code.
Matti Hamalainen <ccr@tnsp.org>
parents: 358
diff changeset
506 gtk_curve_draw(c, width, height);
b1a858b8cb1a Re-indentation all (non-generated) code.
Matti Hamalainen <ccr@tnsp.org>
parents: 358
diff changeset
507 }
b1a858b8cb1a Re-indentation all (non-generated) code.
Matti Hamalainen <ccr@tnsp.org>
parents: 358
diff changeset
508 if (mevent->state & GDK_BUTTON1_MASK)
b1a858b8cb1a Re-indentation all (non-generated) code.
Matti Hamalainen <ccr@tnsp.org>
parents: 358
diff changeset
509 new_type = GDK_TCROSS;
b1a858b8cb1a Re-indentation all (non-generated) code.
Matti Hamalainen <ccr@tnsp.org>
parents: 358
diff changeset
510 else
b1a858b8cb1a Re-indentation all (non-generated) code.
Matti Hamalainen <ccr@tnsp.org>
parents: 358
diff changeset
511 new_type = GDK_PENCIL;
b1a858b8cb1a Re-indentation all (non-generated) code.
Matti Hamalainen <ccr@tnsp.org>
parents: 358
diff changeset
512 break;
358
4f247b19c9ea Add new files
Matti Hamalainen <ccr@tnsp.org>
parents:
diff changeset
513 }
359
b1a858b8cb1a Re-indentation all (non-generated) code.
Matti Hamalainen <ccr@tnsp.org>
parents: 358
diff changeset
514 if (new_type != (GdkCursorType) c->cursor_type) {
b1a858b8cb1a Re-indentation all (non-generated) code.
Matti Hamalainen <ccr@tnsp.org>
parents: 358
diff changeset
515 GdkCursor *cursor;
b1a858b8cb1a Re-indentation all (non-generated) code.
Matti Hamalainen <ccr@tnsp.org>
parents: 358
diff changeset
516
b1a858b8cb1a Re-indentation all (non-generated) code.
Matti Hamalainen <ccr@tnsp.org>
parents: 358
diff changeset
517 c->cursor_type = new_type;
358
4f247b19c9ea Add new files
Matti Hamalainen <ccr@tnsp.org>
parents:
diff changeset
518
359
b1a858b8cb1a Re-indentation all (non-generated) code.
Matti Hamalainen <ccr@tnsp.org>
parents: 358
diff changeset
519 cursor = gdk_cursor_new(c->cursor_type);
b1a858b8cb1a Re-indentation all (non-generated) code.
Matti Hamalainen <ccr@tnsp.org>
parents: 358
diff changeset
520 gdk_window_set_cursor(w->window, cursor);
b1a858b8cb1a Re-indentation all (non-generated) code.
Matti Hamalainen <ccr@tnsp.org>
parents: 358
diff changeset
521 gdk_cursor_destroy(cursor);
b1a858b8cb1a Re-indentation all (non-generated) code.
Matti Hamalainen <ccr@tnsp.org>
parents: 358
diff changeset
522 }
b1a858b8cb1a Re-indentation all (non-generated) code.
Matti Hamalainen <ccr@tnsp.org>
parents: 358
diff changeset
523 break;
358
4f247b19c9ea Add new files
Matti Hamalainen <ccr@tnsp.org>
parents:
diff changeset
524
359
b1a858b8cb1a Re-indentation all (non-generated) code.
Matti Hamalainen <ccr@tnsp.org>
parents: 358
diff changeset
525 default:
b1a858b8cb1a Re-indentation all (non-generated) code.
Matti Hamalainen <ccr@tnsp.org>
parents: 358
diff changeset
526 break;
358
4f247b19c9ea Add new files
Matti Hamalainen <ccr@tnsp.org>
parents:
diff changeset
527 }
359
b1a858b8cb1a Re-indentation all (non-generated) code.
Matti Hamalainen <ccr@tnsp.org>
parents: 358
diff changeset
528 return FALSE;
b1a858b8cb1a Re-indentation all (non-generated) code.
Matti Hamalainen <ccr@tnsp.org>
parents: 358
diff changeset
529 }
358
4f247b19c9ea Add new files
Matti Hamalainen <ccr@tnsp.org>
parents:
diff changeset
530
359
b1a858b8cb1a Re-indentation all (non-generated) code.
Matti Hamalainen <ccr@tnsp.org>
parents: 358
diff changeset
531 void gtk_curve_set_curve_type(GtkCurve * c, GtkCurveType new_type)
b1a858b8cb1a Re-indentation all (non-generated) code.
Matti Hamalainen <ccr@tnsp.org>
parents: 358
diff changeset
532 {
b1a858b8cb1a Re-indentation all (non-generated) code.
Matti Hamalainen <ccr@tnsp.org>
parents: 358
diff changeset
533 gfloat rx, dx;
b1a858b8cb1a Re-indentation all (non-generated) code.
Matti Hamalainen <ccr@tnsp.org>
parents: 358
diff changeset
534 gint x, i;
b1a858b8cb1a Re-indentation all (non-generated) code.
Matti Hamalainen <ccr@tnsp.org>
parents: 358
diff changeset
535
b1a858b8cb1a Re-indentation all (non-generated) code.
Matti Hamalainen <ccr@tnsp.org>
parents: 358
diff changeset
536 if (new_type != c->curve_type) {
b1a858b8cb1a Re-indentation all (non-generated) code.
Matti Hamalainen <ccr@tnsp.org>
parents: 358
diff changeset
537 gint width, height;
b1a858b8cb1a Re-indentation all (non-generated) code.
Matti Hamalainen <ccr@tnsp.org>
parents: 358
diff changeset
538
b1a858b8cb1a Re-indentation all (non-generated) code.
Matti Hamalainen <ccr@tnsp.org>
parents: 358
diff changeset
539 width = GTK_WIDGET(c)->allocation.width - RADIUS * 2;
b1a858b8cb1a Re-indentation all (non-generated) code.
Matti Hamalainen <ccr@tnsp.org>
parents: 358
diff changeset
540 height = GTK_WIDGET(c)->allocation.height - RADIUS * 2;
358
4f247b19c9ea Add new files
Matti Hamalainen <ccr@tnsp.org>
parents:
diff changeset
541
359
b1a858b8cb1a Re-indentation all (non-generated) code.
Matti Hamalainen <ccr@tnsp.org>
parents: 358
diff changeset
542 if (new_type == GTK_CURVE_TYPE_FREE) {
b1a858b8cb1a Re-indentation all (non-generated) code.
Matti Hamalainen <ccr@tnsp.org>
parents: 358
diff changeset
543 gtk_curve_interpolate(c, width, height);
b1a858b8cb1a Re-indentation all (non-generated) code.
Matti Hamalainen <ccr@tnsp.org>
parents: 358
diff changeset
544 c->curve_type = new_type;
b1a858b8cb1a Re-indentation all (non-generated) code.
Matti Hamalainen <ccr@tnsp.org>
parents: 358
diff changeset
545 } else if (c->curve_type == GTK_CURVE_TYPE_FREE) {
b1a858b8cb1a Re-indentation all (non-generated) code.
Matti Hamalainen <ccr@tnsp.org>
parents: 358
diff changeset
546 if (c->ctlpoint)
b1a858b8cb1a Re-indentation all (non-generated) code.
Matti Hamalainen <ccr@tnsp.org>
parents: 358
diff changeset
547 g_free(c->ctlpoint);
b1a858b8cb1a Re-indentation all (non-generated) code.
Matti Hamalainen <ccr@tnsp.org>
parents: 358
diff changeset
548 c->num_ctlpoints = 9;
b1a858b8cb1a Re-indentation all (non-generated) code.
Matti Hamalainen <ccr@tnsp.org>
parents: 358
diff changeset
549 c->ctlpoint = g_malloc(c->num_ctlpoints * sizeof(*c->ctlpoint));
b1a858b8cb1a Re-indentation all (non-generated) code.
Matti Hamalainen <ccr@tnsp.org>
parents: 358
diff changeset
550
b1a858b8cb1a Re-indentation all (non-generated) code.
Matti Hamalainen <ccr@tnsp.org>
parents: 358
diff changeset
551 rx = 0.0;
b1a858b8cb1a Re-indentation all (non-generated) code.
Matti Hamalainen <ccr@tnsp.org>
parents: 358
diff changeset
552 dx = (width - 1) / (gfloat) (c->num_ctlpoints - 1);
b1a858b8cb1a Re-indentation all (non-generated) code.
Matti Hamalainen <ccr@tnsp.org>
parents: 358
diff changeset
553
b1a858b8cb1a Re-indentation all (non-generated) code.
Matti Hamalainen <ccr@tnsp.org>
parents: 358
diff changeset
554 for (i = 0; i < c->num_ctlpoints; ++i, rx += dx) {
b1a858b8cb1a Re-indentation all (non-generated) code.
Matti Hamalainen <ccr@tnsp.org>
parents: 358
diff changeset
555 x = (int) (rx + 0.5);
b1a858b8cb1a Re-indentation all (non-generated) code.
Matti Hamalainen <ccr@tnsp.org>
parents: 358
diff changeset
556 c->ctlpoint[i][0] = unproject(x, c->min_x, c->max_x, width);
b1a858b8cb1a Re-indentation all (non-generated) code.
Matti Hamalainen <ccr@tnsp.org>
parents: 358
diff changeset
557 c->ctlpoint[i][1] =
b1a858b8cb1a Re-indentation all (non-generated) code.
Matti Hamalainen <ccr@tnsp.org>
parents: 358
diff changeset
558 unproject(RADIUS + height - c->point[x].y, c->min_y, c->max_y, height);
b1a858b8cb1a Re-indentation all (non-generated) code.
Matti Hamalainen <ccr@tnsp.org>
parents: 358
diff changeset
559 }
b1a858b8cb1a Re-indentation all (non-generated) code.
Matti Hamalainen <ccr@tnsp.org>
parents: 358
diff changeset
560 c->curve_type = new_type;
b1a858b8cb1a Re-indentation all (non-generated) code.
Matti Hamalainen <ccr@tnsp.org>
parents: 358
diff changeset
561 gtk_curve_interpolate(c, width, height);
b1a858b8cb1a Re-indentation all (non-generated) code.
Matti Hamalainen <ccr@tnsp.org>
parents: 358
diff changeset
562 } else {
b1a858b8cb1a Re-indentation all (non-generated) code.
Matti Hamalainen <ccr@tnsp.org>
parents: 358
diff changeset
563 c->curve_type = new_type;
b1a858b8cb1a Re-indentation all (non-generated) code.
Matti Hamalainen <ccr@tnsp.org>
parents: 358
diff changeset
564 gtk_curve_interpolate(c, width, height);
358
4f247b19c9ea Add new files
Matti Hamalainen <ccr@tnsp.org>
parents:
diff changeset
565 }
359
b1a858b8cb1a Re-indentation all (non-generated) code.
Matti Hamalainen <ccr@tnsp.org>
parents: 358
diff changeset
566 gtk_signal_emit(GTK_OBJECT(c), curve_type_changed_signal);
b1a858b8cb1a Re-indentation all (non-generated) code.
Matti Hamalainen <ccr@tnsp.org>
parents: 358
diff changeset
567 gtk_curve_draw(c, width, height);
b1a858b8cb1a Re-indentation all (non-generated) code.
Matti Hamalainen <ccr@tnsp.org>
parents: 358
diff changeset
568 }
b1a858b8cb1a Re-indentation all (non-generated) code.
Matti Hamalainen <ccr@tnsp.org>
parents: 358
diff changeset
569 }
b1a858b8cb1a Re-indentation all (non-generated) code.
Matti Hamalainen <ccr@tnsp.org>
parents: 358
diff changeset
570
b1a858b8cb1a Re-indentation all (non-generated) code.
Matti Hamalainen <ccr@tnsp.org>
parents: 358
diff changeset
571 static void gtk_curve_size_graph(GtkCurve * curve)
b1a858b8cb1a Re-indentation all (non-generated) code.
Matti Hamalainen <ccr@tnsp.org>
parents: 358
diff changeset
572 {
b1a858b8cb1a Re-indentation all (non-generated) code.
Matti Hamalainen <ccr@tnsp.org>
parents: 358
diff changeset
573 gint width, height;
b1a858b8cb1a Re-indentation all (non-generated) code.
Matti Hamalainen <ccr@tnsp.org>
parents: 358
diff changeset
574 gfloat aspect;
b1a858b8cb1a Re-indentation all (non-generated) code.
Matti Hamalainen <ccr@tnsp.org>
parents: 358
diff changeset
575
b1a858b8cb1a Re-indentation all (non-generated) code.
Matti Hamalainen <ccr@tnsp.org>
parents: 358
diff changeset
576 width = (curve->max_x - curve->min_x) + 1;
b1a858b8cb1a Re-indentation all (non-generated) code.
Matti Hamalainen <ccr@tnsp.org>
parents: 358
diff changeset
577 height = (curve->max_y - curve->min_y) + 1;
b1a858b8cb1a Re-indentation all (non-generated) code.
Matti Hamalainen <ccr@tnsp.org>
parents: 358
diff changeset
578 aspect = width / (gfloat) height;
b1a858b8cb1a Re-indentation all (non-generated) code.
Matti Hamalainen <ccr@tnsp.org>
parents: 358
diff changeset
579 if (width > gdk_screen_width() / 4)
b1a858b8cb1a Re-indentation all (non-generated) code.
Matti Hamalainen <ccr@tnsp.org>
parents: 358
diff changeset
580 width = gdk_screen_width() / 4;
b1a858b8cb1a Re-indentation all (non-generated) code.
Matti Hamalainen <ccr@tnsp.org>
parents: 358
diff changeset
581 if (height > gdk_screen_height() / 4)
b1a858b8cb1a Re-indentation all (non-generated) code.
Matti Hamalainen <ccr@tnsp.org>
parents: 358
diff changeset
582 height = gdk_screen_height() / 4;
b1a858b8cb1a Re-indentation all (non-generated) code.
Matti Hamalainen <ccr@tnsp.org>
parents: 358
diff changeset
583
b1a858b8cb1a Re-indentation all (non-generated) code.
Matti Hamalainen <ccr@tnsp.org>
parents: 358
diff changeset
584 if (aspect < 1.0)
b1a858b8cb1a Re-indentation all (non-generated) code.
Matti Hamalainen <ccr@tnsp.org>
parents: 358
diff changeset
585 width = height * aspect;
b1a858b8cb1a Re-indentation all (non-generated) code.
Matti Hamalainen <ccr@tnsp.org>
parents: 358
diff changeset
586 else
b1a858b8cb1a Re-indentation all (non-generated) code.
Matti Hamalainen <ccr@tnsp.org>
parents: 358
diff changeset
587 height = width / aspect;
b1a858b8cb1a Re-indentation all (non-generated) code.
Matti Hamalainen <ccr@tnsp.org>
parents: 358
diff changeset
588
b1a858b8cb1a Re-indentation all (non-generated) code.
Matti Hamalainen <ccr@tnsp.org>
parents: 358
diff changeset
589 gtk_drawing_area_size(GTK_DRAWING_AREA(curve), width + RADIUS * 2, height + RADIUS * 2);
b1a858b8cb1a Re-indentation all (non-generated) code.
Matti Hamalainen <ccr@tnsp.org>
parents: 358
diff changeset
590 }
b1a858b8cb1a Re-indentation all (non-generated) code.
Matti Hamalainen <ccr@tnsp.org>
parents: 358
diff changeset
591
b1a858b8cb1a Re-indentation all (non-generated) code.
Matti Hamalainen <ccr@tnsp.org>
parents: 358
diff changeset
592 static void gtk_curve_reset_vector(GtkCurve * curve)
b1a858b8cb1a Re-indentation all (non-generated) code.
Matti Hamalainen <ccr@tnsp.org>
parents: 358
diff changeset
593 {
b1a858b8cb1a Re-indentation all (non-generated) code.
Matti Hamalainen <ccr@tnsp.org>
parents: 358
diff changeset
594 if (curve->ctlpoint)
b1a858b8cb1a Re-indentation all (non-generated) code.
Matti Hamalainen <ccr@tnsp.org>
parents: 358
diff changeset
595 g_free(curve->ctlpoint);
b1a858b8cb1a Re-indentation all (non-generated) code.
Matti Hamalainen <ccr@tnsp.org>
parents: 358
diff changeset
596
b1a858b8cb1a Re-indentation all (non-generated) code.
Matti Hamalainen <ccr@tnsp.org>
parents: 358
diff changeset
597 curve->num_ctlpoints = 2;
b1a858b8cb1a Re-indentation all (non-generated) code.
Matti Hamalainen <ccr@tnsp.org>
parents: 358
diff changeset
598 curve->ctlpoint = g_malloc(2 * sizeof(curve->ctlpoint[0]));
b1a858b8cb1a Re-indentation all (non-generated) code.
Matti Hamalainen <ccr@tnsp.org>
parents: 358
diff changeset
599 curve->ctlpoint[0][0] = curve->min_x;
b1a858b8cb1a Re-indentation all (non-generated) code.
Matti Hamalainen <ccr@tnsp.org>
parents: 358
diff changeset
600 curve->ctlpoint[0][1] = curve->min_y;
b1a858b8cb1a Re-indentation all (non-generated) code.
Matti Hamalainen <ccr@tnsp.org>
parents: 358
diff changeset
601 curve->ctlpoint[1][0] = curve->max_x;
b1a858b8cb1a Re-indentation all (non-generated) code.
Matti Hamalainen <ccr@tnsp.org>
parents: 358
diff changeset
602 curve->ctlpoint[1][1] = curve->max_y;
b1a858b8cb1a Re-indentation all (non-generated) code.
Matti Hamalainen <ccr@tnsp.org>
parents: 358
diff changeset
603
b1a858b8cb1a Re-indentation all (non-generated) code.
Matti Hamalainen <ccr@tnsp.org>
parents: 358
diff changeset
604 if (curve->pixmap) {
b1a858b8cb1a Re-indentation all (non-generated) code.
Matti Hamalainen <ccr@tnsp.org>
parents: 358
diff changeset
605 gint width, height;
b1a858b8cb1a Re-indentation all (non-generated) code.
Matti Hamalainen <ccr@tnsp.org>
parents: 358
diff changeset
606
b1a858b8cb1a Re-indentation all (non-generated) code.
Matti Hamalainen <ccr@tnsp.org>
parents: 358
diff changeset
607 width = GTK_WIDGET(curve)->allocation.width - RADIUS * 2;
b1a858b8cb1a Re-indentation all (non-generated) code.
Matti Hamalainen <ccr@tnsp.org>
parents: 358
diff changeset
608 height = GTK_WIDGET(curve)->allocation.height - RADIUS * 2;
b1a858b8cb1a Re-indentation all (non-generated) code.
Matti Hamalainen <ccr@tnsp.org>
parents: 358
diff changeset
609
b1a858b8cb1a Re-indentation all (non-generated) code.
Matti Hamalainen <ccr@tnsp.org>
parents: 358
diff changeset
610 if (curve->curve_type == GTK_CURVE_TYPE_FREE) {
b1a858b8cb1a Re-indentation all (non-generated) code.
Matti Hamalainen <ccr@tnsp.org>
parents: 358
diff changeset
611 curve->curve_type = GTK_CURVE_TYPE_LINEAR;
b1a858b8cb1a Re-indentation all (non-generated) code.
Matti Hamalainen <ccr@tnsp.org>
parents: 358
diff changeset
612 gtk_curve_interpolate(curve, width, height);
b1a858b8cb1a Re-indentation all (non-generated) code.
Matti Hamalainen <ccr@tnsp.org>
parents: 358
diff changeset
613 curve->curve_type = GTK_CURVE_TYPE_FREE;
b1a858b8cb1a Re-indentation all (non-generated) code.
Matti Hamalainen <ccr@tnsp.org>
parents: 358
diff changeset
614 } else
b1a858b8cb1a Re-indentation all (non-generated) code.
Matti Hamalainen <ccr@tnsp.org>
parents: 358
diff changeset
615 gtk_curve_interpolate(curve, width, height);
b1a858b8cb1a Re-indentation all (non-generated) code.
Matti Hamalainen <ccr@tnsp.org>
parents: 358
diff changeset
616 gtk_curve_draw(curve, width, height);
b1a858b8cb1a Re-indentation all (non-generated) code.
Matti Hamalainen <ccr@tnsp.org>
parents: 358
diff changeset
617 }
b1a858b8cb1a Re-indentation all (non-generated) code.
Matti Hamalainen <ccr@tnsp.org>
parents: 358
diff changeset
618 }
b1a858b8cb1a Re-indentation all (non-generated) code.
Matti Hamalainen <ccr@tnsp.org>
parents: 358
diff changeset
619
b1a858b8cb1a Re-indentation all (non-generated) code.
Matti Hamalainen <ccr@tnsp.org>
parents: 358
diff changeset
620 void gtk_curve_reset(GtkCurve * c)
b1a858b8cb1a Re-indentation all (non-generated) code.
Matti Hamalainen <ccr@tnsp.org>
parents: 358
diff changeset
621 {
b1a858b8cb1a Re-indentation all (non-generated) code.
Matti Hamalainen <ccr@tnsp.org>
parents: 358
diff changeset
622 GtkCurveType old_type;
b1a858b8cb1a Re-indentation all (non-generated) code.
Matti Hamalainen <ccr@tnsp.org>
parents: 358
diff changeset
623
b1a858b8cb1a Re-indentation all (non-generated) code.
Matti Hamalainen <ccr@tnsp.org>
parents: 358
diff changeset
624 old_type = c->curve_type;
b1a858b8cb1a Re-indentation all (non-generated) code.
Matti Hamalainen <ccr@tnsp.org>
parents: 358
diff changeset
625 c->curve_type = GTK_CURVE_TYPE_SPLINE;
b1a858b8cb1a Re-indentation all (non-generated) code.
Matti Hamalainen <ccr@tnsp.org>
parents: 358
diff changeset
626 gtk_curve_reset_vector(c);
b1a858b8cb1a Re-indentation all (non-generated) code.
Matti Hamalainen <ccr@tnsp.org>
parents: 358
diff changeset
627
b1a858b8cb1a Re-indentation all (non-generated) code.
Matti Hamalainen <ccr@tnsp.org>
parents: 358
diff changeset
628 if (old_type != GTK_CURVE_TYPE_SPLINE)
b1a858b8cb1a Re-indentation all (non-generated) code.
Matti Hamalainen <ccr@tnsp.org>
parents: 358
diff changeset
629 gtk_signal_emit(GTK_OBJECT(c), curve_type_changed_signal);
b1a858b8cb1a Re-indentation all (non-generated) code.
Matti Hamalainen <ccr@tnsp.org>
parents: 358
diff changeset
630 }
b1a858b8cb1a Re-indentation all (non-generated) code.
Matti Hamalainen <ccr@tnsp.org>
parents: 358
diff changeset
631
b1a858b8cb1a Re-indentation all (non-generated) code.
Matti Hamalainen <ccr@tnsp.org>
parents: 358
diff changeset
632 void gtk_curve_set_gamma(GtkCurve * c, gfloat gamma)
b1a858b8cb1a Re-indentation all (non-generated) code.
Matti Hamalainen <ccr@tnsp.org>
parents: 358
diff changeset
633 {
b1a858b8cb1a Re-indentation all (non-generated) code.
Matti Hamalainen <ccr@tnsp.org>
parents: 358
diff changeset
634 gfloat x, one_over_gamma, height, one_over_width;
b1a858b8cb1a Re-indentation all (non-generated) code.
Matti Hamalainen <ccr@tnsp.org>
parents: 358
diff changeset
635 GtkCurveType old_type;
b1a858b8cb1a Re-indentation all (non-generated) code.
Matti Hamalainen <ccr@tnsp.org>
parents: 358
diff changeset
636 gint i;
b1a858b8cb1a Re-indentation all (non-generated) code.
Matti Hamalainen <ccr@tnsp.org>
parents: 358
diff changeset
637
b1a858b8cb1a Re-indentation all (non-generated) code.
Matti Hamalainen <ccr@tnsp.org>
parents: 358
diff changeset
638 if (c->num_points < 2)
b1a858b8cb1a Re-indentation all (non-generated) code.
Matti Hamalainen <ccr@tnsp.org>
parents: 358
diff changeset
639 return;
b1a858b8cb1a Re-indentation all (non-generated) code.
Matti Hamalainen <ccr@tnsp.org>
parents: 358
diff changeset
640
b1a858b8cb1a Re-indentation all (non-generated) code.
Matti Hamalainen <ccr@tnsp.org>
parents: 358
diff changeset
641 old_type = c->curve_type;
b1a858b8cb1a Re-indentation all (non-generated) code.
Matti Hamalainen <ccr@tnsp.org>
parents: 358
diff changeset
642 c->curve_type = GTK_CURVE_TYPE_FREE;
b1a858b8cb1a Re-indentation all (non-generated) code.
Matti Hamalainen <ccr@tnsp.org>
parents: 358
diff changeset
643
b1a858b8cb1a Re-indentation all (non-generated) code.
Matti Hamalainen <ccr@tnsp.org>
parents: 358
diff changeset
644 if (gamma <= 0)
b1a858b8cb1a Re-indentation all (non-generated) code.
Matti Hamalainen <ccr@tnsp.org>
parents: 358
diff changeset
645 one_over_gamma = 1.0;
b1a858b8cb1a Re-indentation all (non-generated) code.
Matti Hamalainen <ccr@tnsp.org>
parents: 358
diff changeset
646 else
b1a858b8cb1a Re-indentation all (non-generated) code.
Matti Hamalainen <ccr@tnsp.org>
parents: 358
diff changeset
647 one_over_gamma = 1.0 / gamma;
b1a858b8cb1a Re-indentation all (non-generated) code.
Matti Hamalainen <ccr@tnsp.org>
parents: 358
diff changeset
648 one_over_width = 1.0 / (c->num_points - 1);
b1a858b8cb1a Re-indentation all (non-generated) code.
Matti Hamalainen <ccr@tnsp.org>
parents: 358
diff changeset
649 height = c->height;
b1a858b8cb1a Re-indentation all (non-generated) code.
Matti Hamalainen <ccr@tnsp.org>
parents: 358
diff changeset
650 for (i = 0; i < c->num_points; ++i) {
b1a858b8cb1a Re-indentation all (non-generated) code.
Matti Hamalainen <ccr@tnsp.org>
parents: 358
diff changeset
651 x = (gfloat) i / (c->num_points - 1);
b1a858b8cb1a Re-indentation all (non-generated) code.
Matti Hamalainen <ccr@tnsp.org>
parents: 358
diff changeset
652 c->point[i].x = RADIUS + i;
b1a858b8cb1a Re-indentation all (non-generated) code.
Matti Hamalainen <ccr@tnsp.org>
parents: 358
diff changeset
653 c->point[i].y = RADIUS + (height * (1.0 - pow(x, one_over_gamma)) + 0.5);
b1a858b8cb1a Re-indentation all (non-generated) code.
Matti Hamalainen <ccr@tnsp.org>
parents: 358
diff changeset
654 }
b1a858b8cb1a Re-indentation all (non-generated) code.
Matti Hamalainen <ccr@tnsp.org>
parents: 358
diff changeset
655
b1a858b8cb1a Re-indentation all (non-generated) code.
Matti Hamalainen <ccr@tnsp.org>
parents: 358
diff changeset
656 if (old_type != GTK_CURVE_TYPE_FREE)
b1a858b8cb1a Re-indentation all (non-generated) code.
Matti Hamalainen <ccr@tnsp.org>
parents: 358
diff changeset
657 gtk_signal_emit(GTK_OBJECT(c), curve_type_changed_signal);
b1a858b8cb1a Re-indentation all (non-generated) code.
Matti Hamalainen <ccr@tnsp.org>
parents: 358
diff changeset
658
b1a858b8cb1a Re-indentation all (non-generated) code.
Matti Hamalainen <ccr@tnsp.org>
parents: 358
diff changeset
659 gtk_curve_draw(c, c->num_points, c->height);
b1a858b8cb1a Re-indentation all (non-generated) code.
Matti Hamalainen <ccr@tnsp.org>
parents: 358
diff changeset
660 }
b1a858b8cb1a Re-indentation all (non-generated) code.
Matti Hamalainen <ccr@tnsp.org>
parents: 358
diff changeset
661
b1a858b8cb1a Re-indentation all (non-generated) code.
Matti Hamalainen <ccr@tnsp.org>
parents: 358
diff changeset
662 void gtk_curve_set_range(GtkCurve * curve, gfloat min_x, gfloat max_x, gfloat min_y, gfloat max_y)
b1a858b8cb1a Re-indentation all (non-generated) code.
Matti Hamalainen <ccr@tnsp.org>
parents: 358
diff changeset
663 {
b1a858b8cb1a Re-indentation all (non-generated) code.
Matti Hamalainen <ccr@tnsp.org>
parents: 358
diff changeset
664 curve->min_x = min_x;
b1a858b8cb1a Re-indentation all (non-generated) code.
Matti Hamalainen <ccr@tnsp.org>
parents: 358
diff changeset
665 curve->max_x = max_x;
b1a858b8cb1a Re-indentation all (non-generated) code.
Matti Hamalainen <ccr@tnsp.org>
parents: 358
diff changeset
666 curve->min_y = min_y;
b1a858b8cb1a Re-indentation all (non-generated) code.
Matti Hamalainen <ccr@tnsp.org>
parents: 358
diff changeset
667 curve->max_y = max_y;
b1a858b8cb1a Re-indentation all (non-generated) code.
Matti Hamalainen <ccr@tnsp.org>
parents: 358
diff changeset
668
b1a858b8cb1a Re-indentation all (non-generated) code.
Matti Hamalainen <ccr@tnsp.org>
parents: 358
diff changeset
669 gtk_curve_size_graph(curve);
b1a858b8cb1a Re-indentation all (non-generated) code.
Matti Hamalainen <ccr@tnsp.org>
parents: 358
diff changeset
670 gtk_curve_reset_vector(curve);
b1a858b8cb1a Re-indentation all (non-generated) code.
Matti Hamalainen <ccr@tnsp.org>
parents: 358
diff changeset
671 }
b1a858b8cb1a Re-indentation all (non-generated) code.
Matti Hamalainen <ccr@tnsp.org>
parents: 358
diff changeset
672
b1a858b8cb1a Re-indentation all (non-generated) code.
Matti Hamalainen <ccr@tnsp.org>
parents: 358
diff changeset
673 void gtk_curve_set_vector(GtkCurve * c, int veclen, gfloat vector[])
b1a858b8cb1a Re-indentation all (non-generated) code.
Matti Hamalainen <ccr@tnsp.org>
parents: 358
diff changeset
674 {
b1a858b8cb1a Re-indentation all (non-generated) code.
Matti Hamalainen <ccr@tnsp.org>
parents: 358
diff changeset
675 GtkCurveType old_type;
b1a858b8cb1a Re-indentation all (non-generated) code.
Matti Hamalainen <ccr@tnsp.org>
parents: 358
diff changeset
676 gfloat rx, dx, ry;
b1a858b8cb1a Re-indentation all (non-generated) code.
Matti Hamalainen <ccr@tnsp.org>
parents: 358
diff changeset
677 gint i, height;
b1a858b8cb1a Re-indentation all (non-generated) code.
Matti Hamalainen <ccr@tnsp.org>
parents: 358
diff changeset
678
b1a858b8cb1a Re-indentation all (non-generated) code.
Matti Hamalainen <ccr@tnsp.org>
parents: 358
diff changeset
679 old_type = c->curve_type;
b1a858b8cb1a Re-indentation all (non-generated) code.
Matti Hamalainen <ccr@tnsp.org>
parents: 358
diff changeset
680 c->curve_type = GTK_CURVE_TYPE_FREE;
b1a858b8cb1a Re-indentation all (non-generated) code.
Matti Hamalainen <ccr@tnsp.org>
parents: 358
diff changeset
681
b1a858b8cb1a Re-indentation all (non-generated) code.
Matti Hamalainen <ccr@tnsp.org>
parents: 358
diff changeset
682 if (c->point)
b1a858b8cb1a Re-indentation all (non-generated) code.
Matti Hamalainen <ccr@tnsp.org>
parents: 358
diff changeset
683 height = GTK_WIDGET(c)->allocation.height - RADIUS * 2;
b1a858b8cb1a Re-indentation all (non-generated) code.
Matti Hamalainen <ccr@tnsp.org>
parents: 358
diff changeset
684 else {
b1a858b8cb1a Re-indentation all (non-generated) code.
Matti Hamalainen <ccr@tnsp.org>
parents: 358
diff changeset
685 height = (c->max_y - c->min_y);
b1a858b8cb1a Re-indentation all (non-generated) code.
Matti Hamalainen <ccr@tnsp.org>
parents: 358
diff changeset
686 if (height > gdk_screen_height() / 4)
b1a858b8cb1a Re-indentation all (non-generated) code.
Matti Hamalainen <ccr@tnsp.org>
parents: 358
diff changeset
687 height = gdk_screen_height() / 4;
b1a858b8cb1a Re-indentation all (non-generated) code.
Matti Hamalainen <ccr@tnsp.org>
parents: 358
diff changeset
688
b1a858b8cb1a Re-indentation all (non-generated) code.
Matti Hamalainen <ccr@tnsp.org>
parents: 358
diff changeset
689 c->height = height;
b1a858b8cb1a Re-indentation all (non-generated) code.
Matti Hamalainen <ccr@tnsp.org>
parents: 358
diff changeset
690 c->num_points = veclen;
b1a858b8cb1a Re-indentation all (non-generated) code.
Matti Hamalainen <ccr@tnsp.org>
parents: 358
diff changeset
691 c->point = g_malloc(c->num_points * sizeof(c->point[0]));
b1a858b8cb1a Re-indentation all (non-generated) code.
Matti Hamalainen <ccr@tnsp.org>
parents: 358
diff changeset
692 }
b1a858b8cb1a Re-indentation all (non-generated) code.
Matti Hamalainen <ccr@tnsp.org>
parents: 358
diff changeset
693 rx = 0;
b1a858b8cb1a Re-indentation all (non-generated) code.
Matti Hamalainen <ccr@tnsp.org>
parents: 358
diff changeset
694 dx = (veclen - 1.0) / (c->num_points - 1.0);
b1a858b8cb1a Re-indentation all (non-generated) code.
Matti Hamalainen <ccr@tnsp.org>
parents: 358
diff changeset
695
b1a858b8cb1a Re-indentation all (non-generated) code.
Matti Hamalainen <ccr@tnsp.org>
parents: 358
diff changeset
696 for (i = 0; i < c->num_points; ++i, rx += dx) {
b1a858b8cb1a Re-indentation all (non-generated) code.
Matti Hamalainen <ccr@tnsp.org>
parents: 358
diff changeset
697 ry = vector[(int) (rx + 0.5)];
b1a858b8cb1a Re-indentation all (non-generated) code.
Matti Hamalainen <ccr@tnsp.org>
parents: 358
diff changeset
698 if (ry > c->max_y)
b1a858b8cb1a Re-indentation all (non-generated) code.
Matti Hamalainen <ccr@tnsp.org>
parents: 358
diff changeset
699 ry = c->max_y;
b1a858b8cb1a Re-indentation all (non-generated) code.
Matti Hamalainen <ccr@tnsp.org>
parents: 358
diff changeset
700 if (ry < c->min_y)
b1a858b8cb1a Re-indentation all (non-generated) code.
Matti Hamalainen <ccr@tnsp.org>
parents: 358
diff changeset
701 ry = c->min_y;
b1a858b8cb1a Re-indentation all (non-generated) code.
Matti Hamalainen <ccr@tnsp.org>
parents: 358
diff changeset
702 c->point[i].x = RADIUS + i;
b1a858b8cb1a Re-indentation all (non-generated) code.
Matti Hamalainen <ccr@tnsp.org>
parents: 358
diff changeset
703 c->point[i].y = RADIUS + height - project(ry, c->min_y, c->max_y, height);
b1a858b8cb1a Re-indentation all (non-generated) code.
Matti Hamalainen <ccr@tnsp.org>
parents: 358
diff changeset
704 }
b1a858b8cb1a Re-indentation all (non-generated) code.
Matti Hamalainen <ccr@tnsp.org>
parents: 358
diff changeset
705 if (old_type != GTK_CURVE_TYPE_FREE)
b1a858b8cb1a Re-indentation all (non-generated) code.
Matti Hamalainen <ccr@tnsp.org>
parents: 358
diff changeset
706 gtk_signal_emit(GTK_OBJECT(c), curve_type_changed_signal);
b1a858b8cb1a Re-indentation all (non-generated) code.
Matti Hamalainen <ccr@tnsp.org>
parents: 358
diff changeset
707
b1a858b8cb1a Re-indentation all (non-generated) code.
Matti Hamalainen <ccr@tnsp.org>
parents: 358
diff changeset
708 gtk_curve_draw(c, c->num_points, height);
b1a858b8cb1a Re-indentation all (non-generated) code.
Matti Hamalainen <ccr@tnsp.org>
parents: 358
diff changeset
709 }
b1a858b8cb1a Re-indentation all (non-generated) code.
Matti Hamalainen <ccr@tnsp.org>
parents: 358
diff changeset
710
b1a858b8cb1a Re-indentation all (non-generated) code.
Matti Hamalainen <ccr@tnsp.org>
parents: 358
diff changeset
711 void gtk_curve_get_vector(GtkCurve * c, int veclen, gfloat vector[])
b1a858b8cb1a Re-indentation all (non-generated) code.
Matti Hamalainen <ccr@tnsp.org>
parents: 358
diff changeset
712 {
b1a858b8cb1a Re-indentation all (non-generated) code.
Matti Hamalainen <ccr@tnsp.org>
parents: 358
diff changeset
713 gfloat rx, ry, dx, dy, min_x, delta_x, *mem, *xv, *yv, *y2v, prev;
b1a858b8cb1a Re-indentation all (non-generated) code.
Matti Hamalainen <ccr@tnsp.org>
parents: 358
diff changeset
714 gint dst, i, x, next, num_active_ctlpoints = 0, first_active = -1;
b1a858b8cb1a Re-indentation all (non-generated) code.
Matti Hamalainen <ccr@tnsp.org>
parents: 358
diff changeset
715
b1a858b8cb1a Re-indentation all (non-generated) code.
Matti Hamalainen <ccr@tnsp.org>
parents: 358
diff changeset
716 min_x = c->min_x;
b1a858b8cb1a Re-indentation all (non-generated) code.
Matti Hamalainen <ccr@tnsp.org>
parents: 358
diff changeset
717
b1a858b8cb1a Re-indentation all (non-generated) code.
Matti Hamalainen <ccr@tnsp.org>
parents: 358
diff changeset
718 if (c->curve_type != GTK_CURVE_TYPE_FREE) {
b1a858b8cb1a Re-indentation all (non-generated) code.
Matti Hamalainen <ccr@tnsp.org>
parents: 358
diff changeset
719 /* count active points: */
b1a858b8cb1a Re-indentation all (non-generated) code.
Matti Hamalainen <ccr@tnsp.org>
parents: 358
diff changeset
720 prev = min_x - 1.0;
b1a858b8cb1a Re-indentation all (non-generated) code.
Matti Hamalainen <ccr@tnsp.org>
parents: 358
diff changeset
721 for (i = num_active_ctlpoints = 0; i < c->num_ctlpoints; ++i)
b1a858b8cb1a Re-indentation all (non-generated) code.
Matti Hamalainen <ccr@tnsp.org>
parents: 358
diff changeset
722 if (c->ctlpoint[i][0] > prev) {
b1a858b8cb1a Re-indentation all (non-generated) code.
Matti Hamalainen <ccr@tnsp.org>
parents: 358
diff changeset
723 if (first_active < 0)
b1a858b8cb1a Re-indentation all (non-generated) code.
Matti Hamalainen <ccr@tnsp.org>
parents: 358
diff changeset
724 first_active = i;
b1a858b8cb1a Re-indentation all (non-generated) code.
Matti Hamalainen <ccr@tnsp.org>
parents: 358
diff changeset
725 prev = c->ctlpoint[i][0];
b1a858b8cb1a Re-indentation all (non-generated) code.
Matti Hamalainen <ccr@tnsp.org>
parents: 358
diff changeset
726 ++num_active_ctlpoints;
b1a858b8cb1a Re-indentation all (non-generated) code.
Matti Hamalainen <ccr@tnsp.org>
parents: 358
diff changeset
727 }
b1a858b8cb1a Re-indentation all (non-generated) code.
Matti Hamalainen <ccr@tnsp.org>
parents: 358
diff changeset
728
b1a858b8cb1a Re-indentation all (non-generated) code.
Matti Hamalainen <ccr@tnsp.org>
parents: 358
diff changeset
729 /* handle degenerate case: */
b1a858b8cb1a Re-indentation all (non-generated) code.
Matti Hamalainen <ccr@tnsp.org>
parents: 358
diff changeset
730 if (num_active_ctlpoints < 2) {
b1a858b8cb1a Re-indentation all (non-generated) code.
Matti Hamalainen <ccr@tnsp.org>
parents: 358
diff changeset
731 if (num_active_ctlpoints > 0)
b1a858b8cb1a Re-indentation all (non-generated) code.
Matti Hamalainen <ccr@tnsp.org>
parents: 358
diff changeset
732 ry = c->ctlpoint[first_active][1];
b1a858b8cb1a Re-indentation all (non-generated) code.
Matti Hamalainen <ccr@tnsp.org>
parents: 358
diff changeset
733 else
b1a858b8cb1a Re-indentation all (non-generated) code.
Matti Hamalainen <ccr@tnsp.org>
parents: 358
diff changeset
734 ry = c->min_y;
b1a858b8cb1a Re-indentation all (non-generated) code.
Matti Hamalainen <ccr@tnsp.org>
parents: 358
diff changeset
735 if (ry < c->min_y)
b1a858b8cb1a Re-indentation all (non-generated) code.
Matti Hamalainen <ccr@tnsp.org>
parents: 358
diff changeset
736 ry = c->min_y;
b1a858b8cb1a Re-indentation all (non-generated) code.
Matti Hamalainen <ccr@tnsp.org>
parents: 358
diff changeset
737 if (ry > c->max_y)
b1a858b8cb1a Re-indentation all (non-generated) code.
Matti Hamalainen <ccr@tnsp.org>
parents: 358
diff changeset
738 ry = c->max_y;
b1a858b8cb1a Re-indentation all (non-generated) code.
Matti Hamalainen <ccr@tnsp.org>
parents: 358
diff changeset
739 for (x = 0; x < veclen; ++x)
b1a858b8cb1a Re-indentation all (non-generated) code.
Matti Hamalainen <ccr@tnsp.org>
parents: 358
diff changeset
740 vector[x] = ry;
b1a858b8cb1a Re-indentation all (non-generated) code.
Matti Hamalainen <ccr@tnsp.org>
parents: 358
diff changeset
741 return;
358
4f247b19c9ea Add new files
Matti Hamalainen <ccr@tnsp.org>
parents:
diff changeset
742 }
4f247b19c9ea Add new files
Matti Hamalainen <ccr@tnsp.org>
parents:
diff changeset
743 }
4f247b19c9ea Add new files
Matti Hamalainen <ccr@tnsp.org>
parents:
diff changeset
744
359
b1a858b8cb1a Re-indentation all (non-generated) code.
Matti Hamalainen <ccr@tnsp.org>
parents: 358
diff changeset
745 switch (c->curve_type) {
358
4f247b19c9ea Add new files
Matti Hamalainen <ccr@tnsp.org>
parents:
diff changeset
746 case GTK_CURVE_TYPE_SPLINE:
359
b1a858b8cb1a Re-indentation all (non-generated) code.
Matti Hamalainen <ccr@tnsp.org>
parents: 358
diff changeset
747 mem = g_malloc(3 * num_active_ctlpoints * sizeof(gfloat));
b1a858b8cb1a Re-indentation all (non-generated) code.
Matti Hamalainen <ccr@tnsp.org>
parents: 358
diff changeset
748 xv = mem;
b1a858b8cb1a Re-indentation all (non-generated) code.
Matti Hamalainen <ccr@tnsp.org>
parents: 358
diff changeset
749 yv = mem + num_active_ctlpoints;
b1a858b8cb1a Re-indentation all (non-generated) code.
Matti Hamalainen <ccr@tnsp.org>
parents: 358
diff changeset
750 y2v = mem + 2 * num_active_ctlpoints;
358
4f247b19c9ea Add new files
Matti Hamalainen <ccr@tnsp.org>
parents:
diff changeset
751
359
b1a858b8cb1a Re-indentation all (non-generated) code.
Matti Hamalainen <ccr@tnsp.org>
parents: 358
diff changeset
752 prev = min_x - 1.0;
b1a858b8cb1a Re-indentation all (non-generated) code.
Matti Hamalainen <ccr@tnsp.org>
parents: 358
diff changeset
753 for (i = dst = 0; i < c->num_ctlpoints; ++i)
b1a858b8cb1a Re-indentation all (non-generated) code.
Matti Hamalainen <ccr@tnsp.org>
parents: 358
diff changeset
754 if (c->ctlpoint[i][0] > prev) {
b1a858b8cb1a Re-indentation all (non-generated) code.
Matti Hamalainen <ccr@tnsp.org>
parents: 358
diff changeset
755 prev = c->ctlpoint[i][0];
b1a858b8cb1a Re-indentation all (non-generated) code.
Matti Hamalainen <ccr@tnsp.org>
parents: 358
diff changeset
756 xv[dst] = c->ctlpoint[i][0];
b1a858b8cb1a Re-indentation all (non-generated) code.
Matti Hamalainen <ccr@tnsp.org>
parents: 358
diff changeset
757 yv[dst] = c->ctlpoint[i][1];
b1a858b8cb1a Re-indentation all (non-generated) code.
Matti Hamalainen <ccr@tnsp.org>
parents: 358
diff changeset
758 ++dst;
b1a858b8cb1a Re-indentation all (non-generated) code.
Matti Hamalainen <ccr@tnsp.org>
parents: 358
diff changeset
759 }
358
4f247b19c9ea Add new files
Matti Hamalainen <ccr@tnsp.org>
parents:
diff changeset
760
359
b1a858b8cb1a Re-indentation all (non-generated) code.
Matti Hamalainen <ccr@tnsp.org>
parents: 358
diff changeset
761 spline_solve(num_active_ctlpoints, xv, yv, y2v);
b1a858b8cb1a Re-indentation all (non-generated) code.
Matti Hamalainen <ccr@tnsp.org>
parents: 358
diff changeset
762
b1a858b8cb1a Re-indentation all (non-generated) code.
Matti Hamalainen <ccr@tnsp.org>
parents: 358
diff changeset
763 rx = min_x;
b1a858b8cb1a Re-indentation all (non-generated) code.
Matti Hamalainen <ccr@tnsp.org>
parents: 358
diff changeset
764 dx = (c->max_x - min_x) / (veclen - 1);
b1a858b8cb1a Re-indentation all (non-generated) code.
Matti Hamalainen <ccr@tnsp.org>
parents: 358
diff changeset
765 for (x = 0; x < veclen; ++x, rx += dx) {
b1a858b8cb1a Re-indentation all (non-generated) code.
Matti Hamalainen <ccr@tnsp.org>
parents: 358
diff changeset
766 ry = spline_eval(num_active_ctlpoints, xv, yv, y2v, rx);
b1a858b8cb1a Re-indentation all (non-generated) code.
Matti Hamalainen <ccr@tnsp.org>
parents: 358
diff changeset
767 if (ry < c->min_y)
b1a858b8cb1a Re-indentation all (non-generated) code.
Matti Hamalainen <ccr@tnsp.org>
parents: 358
diff changeset
768 ry = c->min_y;
b1a858b8cb1a Re-indentation all (non-generated) code.
Matti Hamalainen <ccr@tnsp.org>
parents: 358
diff changeset
769 if (ry > c->max_y)
b1a858b8cb1a Re-indentation all (non-generated) code.
Matti Hamalainen <ccr@tnsp.org>
parents: 358
diff changeset
770 ry = c->max_y;
b1a858b8cb1a Re-indentation all (non-generated) code.
Matti Hamalainen <ccr@tnsp.org>
parents: 358
diff changeset
771 vector[x] = ry;
358
4f247b19c9ea Add new files
Matti Hamalainen <ccr@tnsp.org>
parents:
diff changeset
772 }
4f247b19c9ea Add new files
Matti Hamalainen <ccr@tnsp.org>
parents:
diff changeset
773
359
b1a858b8cb1a Re-indentation all (non-generated) code.
Matti Hamalainen <ccr@tnsp.org>
parents: 358
diff changeset
774 g_free(mem);
b1a858b8cb1a Re-indentation all (non-generated) code.
Matti Hamalainen <ccr@tnsp.org>
parents: 358
diff changeset
775 break;
358
4f247b19c9ea Add new files
Matti Hamalainen <ccr@tnsp.org>
parents:
diff changeset
776
359
b1a858b8cb1a Re-indentation all (non-generated) code.
Matti Hamalainen <ccr@tnsp.org>
parents: 358
diff changeset
777 case GTK_CURVE_TYPE_LINEAR:
b1a858b8cb1a Re-indentation all (non-generated) code.
Matti Hamalainen <ccr@tnsp.org>
parents: 358
diff changeset
778 dx = (c->max_x - min_x) / (veclen - 1);
b1a858b8cb1a Re-indentation all (non-generated) code.
Matti Hamalainen <ccr@tnsp.org>
parents: 358
diff changeset
779 rx = min_x;
b1a858b8cb1a Re-indentation all (non-generated) code.
Matti Hamalainen <ccr@tnsp.org>
parents: 358
diff changeset
780 ry = c->min_y;
b1a858b8cb1a Re-indentation all (non-generated) code.
Matti Hamalainen <ccr@tnsp.org>
parents: 358
diff changeset
781 dy = 0.0;
b1a858b8cb1a Re-indentation all (non-generated) code.
Matti Hamalainen <ccr@tnsp.org>
parents: 358
diff changeset
782 i = first_active;
b1a858b8cb1a Re-indentation all (non-generated) code.
Matti Hamalainen <ccr@tnsp.org>
parents: 358
diff changeset
783 for (x = 0; x < veclen; ++x, rx += dx) {
b1a858b8cb1a Re-indentation all (non-generated) code.
Matti Hamalainen <ccr@tnsp.org>
parents: 358
diff changeset
784 if (rx >= c->ctlpoint[i][0]) {
b1a858b8cb1a Re-indentation all (non-generated) code.
Matti Hamalainen <ccr@tnsp.org>
parents: 358
diff changeset
785 if (rx > c->ctlpoint[i][0])
b1a858b8cb1a Re-indentation all (non-generated) code.
Matti Hamalainen <ccr@tnsp.org>
parents: 358
diff changeset
786 ry = c->min_y;
b1a858b8cb1a Re-indentation all (non-generated) code.
Matti Hamalainen <ccr@tnsp.org>
parents: 358
diff changeset
787 dy = 0.0;
b1a858b8cb1a Re-indentation all (non-generated) code.
Matti Hamalainen <ccr@tnsp.org>
parents: 358
diff changeset
788 next = i + 1;
b1a858b8cb1a Re-indentation all (non-generated) code.
Matti Hamalainen <ccr@tnsp.org>
parents: 358
diff changeset
789 while (next < c->num_ctlpoints && c->ctlpoint[next][0] <= c->ctlpoint[i][0])
b1a858b8cb1a Re-indentation all (non-generated) code.
Matti Hamalainen <ccr@tnsp.org>
parents: 358
diff changeset
790 ++next;
b1a858b8cb1a Re-indentation all (non-generated) code.
Matti Hamalainen <ccr@tnsp.org>
parents: 358
diff changeset
791 if (next < c->num_ctlpoints) {
b1a858b8cb1a Re-indentation all (non-generated) code.
Matti Hamalainen <ccr@tnsp.org>
parents: 358
diff changeset
792 delta_x = c->ctlpoint[next][0] - c->ctlpoint[i][0];
b1a858b8cb1a Re-indentation all (non-generated) code.
Matti Hamalainen <ccr@tnsp.org>
parents: 358
diff changeset
793 dy = ((c->ctlpoint[next][1] - c->ctlpoint[i][1])
b1a858b8cb1a Re-indentation all (non-generated) code.
Matti Hamalainen <ccr@tnsp.org>
parents: 358
diff changeset
794 / delta_x);
b1a858b8cb1a Re-indentation all (non-generated) code.
Matti Hamalainen <ccr@tnsp.org>
parents: 358
diff changeset
795 dy *= dx;
b1a858b8cb1a Re-indentation all (non-generated) code.
Matti Hamalainen <ccr@tnsp.org>
parents: 358
diff changeset
796 ry = c->ctlpoint[i][1];
b1a858b8cb1a Re-indentation all (non-generated) code.
Matti Hamalainen <ccr@tnsp.org>
parents: 358
diff changeset
797 i = next;
b1a858b8cb1a Re-indentation all (non-generated) code.
Matti Hamalainen <ccr@tnsp.org>
parents: 358
diff changeset
798 }
b1a858b8cb1a Re-indentation all (non-generated) code.
Matti Hamalainen <ccr@tnsp.org>
parents: 358
diff changeset
799 }
b1a858b8cb1a Re-indentation all (non-generated) code.
Matti Hamalainen <ccr@tnsp.org>
parents: 358
diff changeset
800 vector[x] = ry;
b1a858b8cb1a Re-indentation all (non-generated) code.
Matti Hamalainen <ccr@tnsp.org>
parents: 358
diff changeset
801 ry += dy;
b1a858b8cb1a Re-indentation all (non-generated) code.
Matti Hamalainen <ccr@tnsp.org>
parents: 358
diff changeset
802 }
b1a858b8cb1a Re-indentation all (non-generated) code.
Matti Hamalainen <ccr@tnsp.org>
parents: 358
diff changeset
803 break;
358
4f247b19c9ea Add new files
Matti Hamalainen <ccr@tnsp.org>
parents:
diff changeset
804
359
b1a858b8cb1a Re-indentation all (non-generated) code.
Matti Hamalainen <ccr@tnsp.org>
parents: 358
diff changeset
805 case GTK_CURVE_TYPE_FREE:
b1a858b8cb1a Re-indentation all (non-generated) code.
Matti Hamalainen <ccr@tnsp.org>
parents: 358
diff changeset
806 if (c->point) {
b1a858b8cb1a Re-indentation all (non-generated) code.
Matti Hamalainen <ccr@tnsp.org>
parents: 358
diff changeset
807 rx = 0.0;
b1a858b8cb1a Re-indentation all (non-generated) code.
Matti Hamalainen <ccr@tnsp.org>
parents: 358
diff changeset
808 dx = c->num_points / (double) veclen;
b1a858b8cb1a Re-indentation all (non-generated) code.
Matti Hamalainen <ccr@tnsp.org>
parents: 358
diff changeset
809 for (x = 0; x < veclen; ++x, rx += dx)
b1a858b8cb1a Re-indentation all (non-generated) code.
Matti Hamalainen <ccr@tnsp.org>
parents: 358
diff changeset
810 vector[x] = unproject(RADIUS + c->height - c->point[(int) rx].y,
b1a858b8cb1a Re-indentation all (non-generated) code.
Matti Hamalainen <ccr@tnsp.org>
parents: 358
diff changeset
811 c->min_y, c->max_y, c->height);
b1a858b8cb1a Re-indentation all (non-generated) code.
Matti Hamalainen <ccr@tnsp.org>
parents: 358
diff changeset
812 } else
b1a858b8cb1a Re-indentation all (non-generated) code.
Matti Hamalainen <ccr@tnsp.org>
parents: 358
diff changeset
813 memset(vector, 0, veclen * sizeof(vector[0]));
b1a858b8cb1a Re-indentation all (non-generated) code.
Matti Hamalainen <ccr@tnsp.org>
parents: 358
diff changeset
814 break;
358
4f247b19c9ea Add new files
Matti Hamalainen <ccr@tnsp.org>
parents:
diff changeset
815 }
4f247b19c9ea Add new files
Matti Hamalainen <ccr@tnsp.org>
parents:
diff changeset
816 }
4f247b19c9ea Add new files
Matti Hamalainen <ccr@tnsp.org>
parents:
diff changeset
817
359
b1a858b8cb1a Re-indentation all (non-generated) code.
Matti Hamalainen <ccr@tnsp.org>
parents: 358
diff changeset
818 GtkWidget *gtk_curve_new(void)
358
4f247b19c9ea Add new files
Matti Hamalainen <ccr@tnsp.org>
parents:
diff changeset
819 {
359
b1a858b8cb1a Re-indentation all (non-generated) code.
Matti Hamalainen <ccr@tnsp.org>
parents: 358
diff changeset
820 return gtk_type_new(gtk_curve_get_type());
358
4f247b19c9ea Add new files
Matti Hamalainen <ccr@tnsp.org>
parents:
diff changeset
821 }
4f247b19c9ea Add new files
Matti Hamalainen <ccr@tnsp.org>
parents:
diff changeset
822
359
b1a858b8cb1a Re-indentation all (non-generated) code.
Matti Hamalainen <ccr@tnsp.org>
parents: 358
diff changeset
823 static void gtk_curve_finalize(GtkObject * object)
358
4f247b19c9ea Add new files
Matti Hamalainen <ccr@tnsp.org>
parents:
diff changeset
824 {
359
b1a858b8cb1a Re-indentation all (non-generated) code.
Matti Hamalainen <ccr@tnsp.org>
parents: 358
diff changeset
825 GtkCurve *curve;
358
4f247b19c9ea Add new files
Matti Hamalainen <ccr@tnsp.org>
parents:
diff changeset
826
359
b1a858b8cb1a Re-indentation all (non-generated) code.
Matti Hamalainen <ccr@tnsp.org>
parents: 358
diff changeset
827 g_return_if_fail(object != NULL);
b1a858b8cb1a Re-indentation all (non-generated) code.
Matti Hamalainen <ccr@tnsp.org>
parents: 358
diff changeset
828 g_return_if_fail(GTK_IS_CURVE(object));
358
4f247b19c9ea Add new files
Matti Hamalainen <ccr@tnsp.org>
parents:
diff changeset
829
359
b1a858b8cb1a Re-indentation all (non-generated) code.
Matti Hamalainen <ccr@tnsp.org>
parents: 358
diff changeset
830 curve = GTK_CURVE(object);
b1a858b8cb1a Re-indentation all (non-generated) code.
Matti Hamalainen <ccr@tnsp.org>
parents: 358
diff changeset
831 if (curve->pixmap)
b1a858b8cb1a Re-indentation all (non-generated) code.
Matti Hamalainen <ccr@tnsp.org>
parents: 358
diff changeset
832 gdk_pixmap_unref(curve->pixmap);
b1a858b8cb1a Re-indentation all (non-generated) code.
Matti Hamalainen <ccr@tnsp.org>
parents: 358
diff changeset
833 if (curve->point)
b1a858b8cb1a Re-indentation all (non-generated) code.
Matti Hamalainen <ccr@tnsp.org>
parents: 358
diff changeset
834 g_free(curve->point);
b1a858b8cb1a Re-indentation all (non-generated) code.
Matti Hamalainen <ccr@tnsp.org>
parents: 358
diff changeset
835 if (curve->ctlpoint)
b1a858b8cb1a Re-indentation all (non-generated) code.
Matti Hamalainen <ccr@tnsp.org>
parents: 358
diff changeset
836 g_free(curve->ctlpoint);
358
4f247b19c9ea Add new files
Matti Hamalainen <ccr@tnsp.org>
parents:
diff changeset
837
359
b1a858b8cb1a Re-indentation all (non-generated) code.
Matti Hamalainen <ccr@tnsp.org>
parents: 358
diff changeset
838 (*GTK_OBJECT_CLASS(parent_class)->finalize) (object);
358
4f247b19c9ea Add new files
Matti Hamalainen <ccr@tnsp.org>
parents:
diff changeset
839 }