1 /*
2  * This file is part of gtkD.
3  *
4  * gtkD is free software; you can redistribute it and/or modify
5  * it under the terms of the GNU Lesser General Public License
6  * as published by the Free Software Foundation; either version 3
7  * of the License, or (at your option) any later version, with
8  * some exceptions, please read the COPYING file.
9  *
10  * gtkD is distributed in the hope that it will be useful,
11  * but WITHOUT ANY WARRANTY; without even the implied warranty of
12  * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
13  * GNU Lesser General Public License for more details.
14  *
15  * You should have received a copy of the GNU Lesser General Public License
16  * along with gtkD; if not, write to the Free Software
17  * Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110, USA
18  */
19  
20 // generated automatically - do not change
21 // find conversion definition on APILookup.txt
22 // implement new conversion functionalities on the wrap.utils pakage
23 
24 /*
25  * Conversion parameters:
26  * inFile  = GtkCurve.html
27  * outPack = gtk
28  * outFile = Curve
29  * strct   = GtkCurve
30  * realStrct=
31  * ctorStrct=
32  * clss    = Curve
33  * interf  = 
34  * class Code: No
35  * interface Code: No
36  * template for:
37  * extend  = 
38  * implements:
39  * prefixes:
40  * 	- gtk_curve_
41  * 	- gtk_
42  * omit structs:
43  * omit prefixes:
44  * omit code:
45  * omit signals:
46  * imports:
47  * structWrap:
48  * module aliases:
49  * local aliases:
50  * overrides:
51  */
52 
53 module gtk.Curve;
54 
55 public  import gtkc.gtktypes;
56 
57 private import gtkc.gtk;
58 private import glib.ConstructionException;
59 private import gobject.ObjectG;
60 
61 private import gobject.Signals;
62 public  import gtkc.gdktypes;
63 
64 
65 
66 
67 private import gtk.DrawingArea;
68 
69 /**
70  * Description
71  * The GtkCurve widget allows the user to edit a curve covering a range of
72  * values. It is typically used to fine-tune color balances in graphics
73  * applications like the Gimp.
74  * The GtkCurve widget has 3 modes of operation - spline, linear and free.
75  * In spline mode the user places points on the curve which are automatically
76  * connected together into a smooth curve. In linear mode the user places points
77  * on the curve which are connected by straight lines. In free mode the user can
78  * draw the points of the curve freely, and they are not connected at all.
79  * As of GTK+ 2.20, GtkCurve has been deprecated since it is too specialized.
80  */
81 public class Curve : DrawingArea
82 {
83 	
84 	/** the main Gtk struct */
85 	protected GtkCurve* gtkCurve;
86 	
87 	
88 	public GtkCurve* getCurveStruct()
89 	{
90 		return gtkCurve;
91 	}
92 	
93 	
94 	/** the main Gtk struct as a void* */
95 	protected override void* getStruct()
96 	{
97 		return cast(void*)gtkCurve;
98 	}
99 	
100 	/**
101 	 * Sets our main struct and passes it to the parent class
102 	 */
103 	public this (GtkCurve* gtkCurve)
104 	{
105 		super(cast(GtkDrawingArea*)gtkCurve);
106 		this.gtkCurve = gtkCurve;
107 	}
108 	
109 	protected override void setStruct(GObject* obj)
110 	{
111 		super.setStruct(obj);
112 		gtkCurve = cast(GtkCurve*)obj;
113 	}
114 	
115 	/**
116 	 */
117 	int[string] connectedSignals;
118 	
119 	void delegate(Curve)[] onCurveTypeChangedListeners;
120 	/**
121 	 * Emitted when the curve type has been changed.
122 	 * The curve type can be changed explicitly with a call to
123 	 * gtk_curve_set_curve_type(). It is also changed as a side-effect of
124 	 * calling gtk_curve_reset() or gtk_curve_set_gamma().
125 	 * See Also
126 	 * GtkGammaCurve
127 	 * a subclass for editing gamma curves.
128 	 */
129 	void addOnCurveTypeChanged(void delegate(Curve) dlg, ConnectFlags connectFlags=cast(ConnectFlags)0)
130 	{
131 		if ( !("curve-type-changed" in connectedSignals) )
132 		{
133 			Signals.connectData(
134 			getStruct(),
135 			"curve-type-changed",
136 			cast(GCallback)&callBackCurveTypeChanged,
137 			cast(void*)this,
138 			null,
139 			connectFlags);
140 			connectedSignals["curve-type-changed"] = 1;
141 		}
142 		onCurveTypeChangedListeners ~= dlg;
143 	}
144 	extern(C) static void callBackCurveTypeChanged(GtkCurve* curveStruct, Curve _curve)
145 	{
146 		foreach ( void delegate(Curve) dlg ; _curve.onCurveTypeChangedListeners )
147 		{
148 			dlg(_curve);
149 		}
150 	}
151 	
152 	
153 	/**
154 	 * Warning
155 	 * gtk_curve_new has been deprecated since version 2.20 and should not be used in newly-written code. Don't use this widget anymore.
156 	 * Creates a new GtkCurve.
157 	 * Throws: ConstructionException GTK+ fails to create the object.
158 	 */
159 	public this ()
160 	{
161 		// GtkWidget * gtk_curve_new (void);
162 		auto p = gtk_curve_new();
163 		if(p is null)
164 		{
165 			throw new ConstructionException("null returned by gtk_curve_new()");
166 		}
167 		this(cast(GtkCurve*) p);
168 	}
169 	
170 	/**
171 	 * Warning
172 	 * gtk_curve_reset has been deprecated since version 2.20 and should not be used in newly-written code. Don't use this widget anymore.
173 	 * Resets the curve to a straight line from the minimum x and y values to the
174 	 * maximum x and y values (i.e. from the bottom-left to the top-right corners).
175 	 * The curve type is not changed.
176 	 */
177 	public void reset()
178 	{
179 		// void gtk_curve_reset (GtkCurve *curve);
180 		gtk_curve_reset(gtkCurve);
181 	}
182 	
183 	/**
184 	 * Warning
185 	 * gtk_curve_set_gamma has been deprecated since version 2.20 and should not be used in newly-written code. Don't use this widget anymore.
186 	 * Recomputes the entire curve using the given gamma value.
187 	 * A gamma value of 1 results in a straight line. Values greater than 1 result
188 	 * in a curve above the straight line. Values less than 1 result in a curve
189 	 * below the straight line. The curve type is changed to GTK_CURVE_TYPE_FREE.
190 	 * FIXME: Needs a more precise definition of gamma.
191 	 * Params:
192 	 * gamma = the gamma value.
193 	 */
194 	public void setGamma(float gamma)
195 	{
196 		// void gtk_curve_set_gamma (GtkCurve *curve,  gfloat gamma_);
197 		gtk_curve_set_gamma(gtkCurve, gamma);
198 	}
199 	
200 	/**
201 	 * Warning
202 	 * gtk_curve_set_range has been deprecated since version 2.20 and should not be used in newly-written code. Don't use this widget anymore.
203 	 * Sets the minimum and maximum x and y values of the curve.
204 	 * The curve is also reset with a call to gtk_curve_reset().
205 	 * Params:
206 	 * minX = the minimum x value.
207 	 * maxX = the maximum x value.
208 	 * minY = the minimum y value.
209 	 * maxY = the maximum y value.
210 	 */
211 	public void setRange(float minX, float maxX, float minY, float maxY)
212 	{
213 		// void gtk_curve_set_range (GtkCurve *curve,  gfloat min_x,  gfloat max_x,  gfloat min_y,  gfloat max_y);
214 		gtk_curve_set_range(gtkCurve, minX, maxX, minY, maxY);
215 	}
216 	
217 	/**
218 	 * Warning
219 	 * gtk_curve_get_vector has been deprecated since version 2.20 and should not be used in newly-written code. Don't use this widget anymore.
220 	 * Returns a vector of points representing the curve.
221 	 * Params:
222 	 * vector = returns the points.
223 	 */
224 	public void getVector(float[] vector)
225 	{
226 		// void gtk_curve_get_vector (GtkCurve *curve,  int veclen,  gfloat vector[]);
227 		gtk_curve_get_vector(gtkCurve, cast(int) vector.length, vector.ptr);
228 	}
229 	
230 	/**
231 	 * Warning
232 	 * gtk_curve_set_vector has been deprecated since version 2.20 and should not be used in newly-written code. Don't use this widget anymore.
233 	 * Sets the vector of points on the curve.
234 	 * The curve type is set to GTK_CURVE_TYPE_FREE.
235 	 * Params:
236 	 * vector = the points on the curve.
237 	 */
238 	public void setVector(float[] vector)
239 	{
240 		// void gtk_curve_set_vector (GtkCurve *curve,  int veclen,  gfloat vector[]);
241 		gtk_curve_set_vector(gtkCurve, cast(int) vector.length, vector.ptr);
242 	}
243 	
244 	/**
245 	 * Warning
246 	 * gtk_curve_set_curve_type has been deprecated since version 2.20 and should not be used in newly-written code. Don't use this widget anymore.
247 	 * Sets the type of the curve. The curve will remain unchanged except when
248 	 * changing from a free curve to a linear or spline curve, in which case the
249 	 * curve will be changed as little as possible.
250 	 * Params:
251 	 * type = the type of the curve.
252 	 */
253 	public void setCurveType(GtkCurveType type)
254 	{
255 		// void gtk_curve_set_curve_type (GtkCurve *curve,  GtkCurveType type);
256 		gtk_curve_set_curve_type(gtkCurve, type);
257 	}
258 }