alternative to assert
[gtkD.git] / src / gtk / Curve.d
blob47388d095d81de3d7896320ec3cbfaa1d3467252
1 /*
2 * This file is part of duit.
4 * duit is free software; you can redistribute it and/or modify
5 * it under the terms of the GNU Lesser General Public License as published by
6 * the Free Software Foundation; either version 2.1 of the License, or
7 * (at your option) any later version.
9 * duit is distributed in the hope that it will be useful,
10 * but WITHOUT ANY WARRANTY; without even the implied warranty of
11 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
12 * GNU Lesser General Public License for more details.
14 * You should have received a copy of the GNU Lesser General Public License
15 * along with duit; if not, write to the Free Software
16 * Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA
19 // generated automatically - do not change
20 // find conversion definition on APILookup.txt
21 // implement new conversion functionalities on the wrap.utils pakage
24 * Conversion parameters:
25 * inFile = GtkCurve.html
26 * outPack = gtk
27 * outFile = Curve
28 * strct = GtkCurve
29 * realStrct=
30 * ctorStrct=
31 * clss = Curve
32 * interf =
33 * class Code: No
34 * interface Code: No
35 * template for:
36 * extend =
37 * implements:
38 * prefixes:
39 * - gtk_curve_
40 * - gtk_
41 * omit structs:
42 * omit prefixes:
43 * omit code:
44 * imports:
45 * structWrap:
46 * local aliases:
49 module gtk.Curve;
51 private import gtk.gtktypes;
53 private import lib.gtk;
56 /**
57 * Description
58 * Note
59 * This widget is considered too specialized/little-used for
60 * GTK+, and will in the future be moved to some other package. If
61 * your application needs this widget, feel free to use it, as the
62 * widget does work and is useful in some applications; it's just not
63 * of general interest. However, we are not accepting new features for
64 * the widget, and it will eventually move out of the GTK+
65 * distribution.
66 * The GtkCurve widget allows the user to edit a curve covering a range of
67 * values. It is typically used to fine-tune color balances in graphics
68 * applications like the Gimp.
69 * The GtkCurve widget has 3 modes of operation - spline, linear and free.
70 * In spline mode the user places points on the curve which are automatically
71 * connected together into a smooth curve. In linear mode the user places points
72 * on the curve which are connected by straight lines. In free mode the user can
73 * draw the points of the curve freely, and they are not connected at all.
75 private import gtk.DrawingArea;
76 public class Curve : DrawingArea
79 /** the main Gtk struct */
80 protected GtkCurve* gtkCurve;
83 public GtkCurve* getCurveStruct()
85 return gtkCurve;
89 /** the main Gtk struct as a void* */
90 protected void* getStruct()
92 return cast(void*)gtkCurve;
95 /**
96 * Sets our main struct and passes it to the parent class
98 public this (GtkCurve* gtkCurve)
100 super(cast(GtkDrawingArea*)gtkCurve);
101 this.gtkCurve = gtkCurve;
107 // imports for the signal processing
108 private import gobject.Signals;
109 private import gdk.gdktypes;
110 int[char[]] connectedSignals;
112 void delegate(Curve)[] onCurveTypeChangedListeners;
113 void addOnCurveTypeChanged(void delegate(Curve) dlg)
115 if ( !("curve-type-changed" in connectedSignals) )
117 Signals.connectData(
118 getStruct(),
119 "curve-type-changed",
120 cast(GCallback)&callBackCurveTypeChanged,
121 this,
122 null,
123 cast(ConnectFlags)0);
124 connectedSignals["curve-type-changed"] = 1;
126 onCurveTypeChangedListeners ~= dlg;
128 extern(C) static void callBackCurveTypeChanged(GtkCurve* curveStruct, Curve curve)
130 bit consumed = false;
132 foreach ( void delegate(Curve) dlg ; curve.onCurveTypeChangedListeners )
134 dlg(curve);
137 return consumed;
143 * Creates a new GtkCurve.
144 * Returns:
145 * a new GtkCurve.
147 public this ()
149 // GtkWidget* gtk_curve_new (void);
150 this(cast(GtkCurve*)gtk_curve_new() );
154 * Resets the curve to a straight line from the minimum x and y values to the
155 * maximum x and y values (i.e. from the bottom-left to the top-right corners).
156 * The curve type is not changed.
157 * curve:
158 * a GtkCurve.
160 public void reset()
162 // void gtk_curve_reset (GtkCurve *curve);
163 gtk_curve_reset(gtkCurve);
167 * Recomputes the entire curve using the given gamma value.
168 * A gamma value of 1 results in a straight line. Values greater than 1 result
169 * in a curve above the straight line. Values less than 1 result in a curve
170 * below the straight line. The curve type is changed to GTK_CURVE_TYPE_FREE.
171 * FIXME: Needs a more precise definition of gamma.
172 * curve:
173 * a GtkCurve.
174 * gamma_:
175 * the gamma value.
177 public void setGamma(float gamma)
179 // void gtk_curve_set_gamma (GtkCurve *curve, gfloat gamma_);
180 gtk_curve_set_gamma(gtkCurve, gamma);
184 * Sets the minimum and maximum x and y values of the curve.
185 * The curve is also reset with a call to gtk_curve_reset().
186 * curve:
187 * a GtkCurve.
188 * min_x:
189 * the minimum x value.
190 * max_x:
191 * the maximum x value.
192 * min_y:
193 * the minimum y value.
194 * max_y:
195 * the maximum y value.
197 public void setRange(float minX, float maxX, float minY, float maxY)
199 // void gtk_curve_set_range (GtkCurve *curve, gfloat min_x, gfloat max_x, gfloat min_y, gfloat max_y);
200 gtk_curve_set_range(gtkCurve, minX, maxX, minY, maxY);
204 * Returns a vector of points representing the curve.
205 * curve:
206 * a GtkCurve.
207 * veclen:
208 * the number of points to calculate.
209 * vector:
210 * returns the points.
212 public void getVector(int veclen, float[] vector)
214 // void gtk_curve_get_vector (GtkCurve *curve, int veclen, gfloat vector[]);
215 gtk_curve_get_vector(gtkCurve, veclen, vector);
219 * Sets the vector of points on the curve.
220 * The curve type is set to GTK_CURVE_TYPE_FREE.
221 * curve:
222 * a GtkCurve.
223 * veclen:
224 * the number of points.
225 * vector:
226 * the points on the curve.
228 public void setVector(int veclen, float[] vector)
230 // void gtk_curve_set_vector (GtkCurve *curve, int veclen, gfloat vector[]);
231 gtk_curve_set_vector(gtkCurve, veclen, vector);
235 * Sets the type of the curve. The curve will remain unchanged except when
236 * changing from a free curve to a linear or spline curve, in which case the
237 * curve will be changed as little as possible.
238 * curve:
239 * a GtkCurve.
240 * type:
241 * the type of the curve.
242 * Property Details
243 * The "curve-type" property
244 * "curve-type" GtkCurveType : Read / Write
245 * Is this curve linear, spline interpolated, or free-form.
246 * Default value: GTK_CURVE_TYPE_LINEAR
248 public void setCurveType(GtkCurveType type)
250 // void gtk_curve_set_curve_type (GtkCurve *curve, GtkCurveType type);
251 gtk_curve_set_curve_type(gtkCurve, type);