alternative to assert
[gtkD.git] / gtkD / src / gtk / Curve.d
blob4703ab6eecbacd7f3b1fe35b100aef803f75fb61
1 /*
2 * This file is part of gtkD.
4 * gtkD 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 * gtkD 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 gtkD; 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 * module aliases:
47 * local aliases:
50 module gtk.Curve;
52 version(noAssert)
54 version(Tango)
56 import tango.io.Stdout; // use the tango loging?
60 private import gtkc.gtktypes;
62 private import gtkc.gtk;
69 /**
70 * Description
71 * Note
72 * This widget is considered too specialized/little-used for
73 * GTK+, and will in the future be moved to some other package. If
74 * your application needs this widget, feel free to use it, as the
75 * widget does work and is useful in some applications; it's just not
76 * of general interest. However, we are not accepting new features for
77 * the widget, and it will eventually move out of the GTK+
78 * distribution.
79 * The GtkCurve widget allows the user to edit a curve covering a range of
80 * values. It is typically used to fine-tune color balances in graphics
81 * applications like the Gimp.
82 * The GtkCurve widget has 3 modes of operation - spline, linear and free.
83 * In spline mode the user places points on the curve which are automatically
84 * connected together into a smooth curve. In linear mode the user places points
85 * on the curve which are connected by straight lines. In free mode the user can
86 * draw the points of the curve freely, and they are not connected at all.
88 private import gtk.DrawingArea;
89 public class Curve : DrawingArea
92 /** the main Gtk struct */
93 protected GtkCurve* gtkCurve;
96 public GtkCurve* getCurveStruct()
98 return gtkCurve;
102 /** the main Gtk struct as a void* */
103 protected void* getStruct()
105 return cast(void*)gtkCurve;
109 * Sets our main struct and passes it to the parent class
111 public this (GtkCurve* gtkCurve)
113 version(noAssert)
115 if ( gtkCurve is null )
117 int zero = 0;
118 version(Tango)
120 Stdout("struct gtkCurve is null on constructor").newline;
122 else
124 printf("struct gtkCurve is null on constructor");
126 zero = zero / zero;
129 else
131 assert(gtkCurve !is null, "struct gtkCurve is null on constructor");
133 super(cast(GtkDrawingArea*)gtkCurve);
134 this.gtkCurve = gtkCurve;
140 // imports for the signal processing
141 private import gobject.Signals;
142 private import gtkc.gdktypes;
143 int[char[]] connectedSignals;
145 void delegate(Curve)[] onCurveTypeChangedListeners;
146 void addOnCurveTypeChanged(void delegate(Curve) dlg, ConnectFlags connectFlags=cast(ConnectFlags)0)
148 if ( !("curve-type-changed" in connectedSignals) )
150 Signals.connectData(
151 getStruct(),
152 "curve-type-changed",
153 cast(GCallback)&callBackCurveTypeChanged,
154 cast(void*)this,
155 null,
156 connectFlags);
157 connectedSignals["curve-type-changed"] = 1;
159 onCurveTypeChangedListeners ~= dlg;
161 extern(C) static void callBackCurveTypeChanged(GtkCurve* curveStruct, Curve curve)
163 bool consumed = false;
165 foreach ( void delegate(Curve) dlg ; curve.onCurveTypeChangedListeners )
167 dlg(curve);
170 return consumed;
176 * Creates a new GtkCurve.
177 * Returns:
178 * a new GtkCurve.
180 public this ()
182 // GtkWidget* gtk_curve_new (void);
183 this(cast(GtkCurve*)gtk_curve_new() );
187 * Resets the curve to a straight line from the minimum x and y values to the
188 * maximum x and y values (i.e. from the bottom-left to the top-right corners).
189 * The curve type is not changed.
190 * curve:
191 * a GtkCurve.
193 public void reset()
195 // void gtk_curve_reset (GtkCurve *curve);
196 gtk_curve_reset(gtkCurve);
200 * Recomputes the entire curve using the given gamma value.
201 * A gamma value of 1 results in a straight line. Values greater than 1 result
202 * in a curve above the straight line. Values less than 1 result in a curve
203 * below the straight line. The curve type is changed to GTK_CURVE_TYPE_FREE.
204 * FIXME: Needs a more precise definition of gamma.
205 * curve:
206 * a GtkCurve.
207 * gamma_:
208 * the gamma value.
210 public void setGamma(float gamma)
212 // void gtk_curve_set_gamma (GtkCurve *curve, gfloat gamma_);
213 gtk_curve_set_gamma(gtkCurve, gamma);
217 * Sets the minimum and maximum x and y values of the curve.
218 * The curve is also reset with a call to gtk_curve_reset().
219 * curve:
220 * a GtkCurve.
221 * min_x:
222 * the minimum x value.
223 * max_x:
224 * the maximum x value.
225 * min_y:
226 * the minimum y value.
227 * max_y:
228 * the maximum y value.
230 public void setRange(float minX, float maxX, float minY, float maxY)
232 // void gtk_curve_set_range (GtkCurve *curve, gfloat min_x, gfloat max_x, gfloat min_y, gfloat max_y);
233 gtk_curve_set_range(gtkCurve, minX, maxX, minY, maxY);
237 * Returns a vector of points representing the curve.
238 * curve:
239 * a GtkCurve.
240 * veclen:
241 * the number of points to calculate.
242 * vector:
243 * returns the points.
245 public void getVector(int veclen, float[] vector)
247 // void gtk_curve_get_vector (GtkCurve *curve, int veclen, gfloat vector[]);
248 gtk_curve_get_vector(gtkCurve, veclen, vector);
252 * Sets the vector of points on the curve.
253 * The curve type is set to GTK_CURVE_TYPE_FREE.
254 * curve:
255 * a GtkCurve.
256 * veclen:
257 * the number of points.
258 * vector:
259 * the points on the curve.
261 public void setVector(int veclen, float[] vector)
263 // void gtk_curve_set_vector (GtkCurve *curve, int veclen, gfloat vector[]);
264 gtk_curve_set_vector(gtkCurve, veclen, vector);
268 * Sets the type of the curve. The curve will remain unchanged except when
269 * changing from a free curve to a linear or spline curve, in which case the
270 * curve will be changed as little as possible.
271 * curve:
272 * a GtkCurve.
273 * type:
274 * the type of the curve.
275 * Property Details
276 * The "curve-type" property
277 * "curve-type" GtkCurveType : Read / Write
278 * Is this curve linear, spline interpolated, or free-form.
279 * Default value: GTK_CURVE_TYPE_LINEAR
281 public void setCurveType(GtkCurveType type)
283 // void gtk_curve_set_curve_type (GtkCurve *curve, GtkCurveType type);
284 gtk_curve_set_curve_type(gtkCurve, type);