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  = cairo-cairo-device-t.html
27  * outPack = cairo
28  * outFile = Device
29  * strct   = cairo_device_t
30  * realStrct=
31  * ctorStrct=
32  * clss    = Device
33  * interf  = 
34  * class Code: No
35  * interface Code: No
36  * template for:
37  * extend  = 
38  * implements:
39  * prefixes:
40  * 	- cairo_device_
41  * omit structs:
42  * omit prefixes:
43  * omit code:
44  * omit signals:
45  * imports:
46  * structWrap:
47  * 	- cairo_device_t* -> Device
48  * module aliases:
49  * local aliases:
50  * overrides:
51  */
52 
53 module cairo.Device;
54 
55 public  import gtkc.cairotypes;
56 
57 private import gtkc.cairo;
58 private import glib.ConstructionException;
59 
60 
61 
62 
63 /**
64  * Devices are the abstraction Cairo employs for the rendering system
65  * used by a cairo_surface_t. You can get the device of a surface using
66  * cairo_surface_get_device().
67  *
68  * Devices are created using custom functions specific to the rendering
69  * system you want to use. See the documentation for the surface types
70  * for those functions.
71  *
72  * An important function that devices fulfill is sharing access to the
73  * rendering system between Cairo and your application. If you want to
74  * access a device directly that you used to draw to with Cairo, you must
75  * first call cairo_device_flush() to ensure that Cairo finishes all
76  * operations on the device and resets it to a clean state.
77  *
78  * Cairo also provides the functions cairo_device_acquire() and
79  * cairo_device_release() to synchronize access to the rendering system
80  * in a multithreaded environment. This is done internally, but can also
81  * be used by applications.
82  *
83  * Putting this all together, a function that works with devices should
84  * look something like this:
85  *
86  * $(DDOC_COMMENT example)
87  *
88  * Note
89  *
90  * Please refer to the documentation of each backend for
91  * additional usage requirements, guarantees provided, and
92  * interactions with existing surface API of the device functions for
93  * surfaces of that type.
94  */
95 public class Device
96 {
97 	
98 	/** the main Gtk struct */
99 	protected cairo_device_t* cairo_device;
100 	
101 	
102 	/** Get the main Gtk struct */
103 	public cairo_device_t* getDeviceStruct()
104 	{
105 		return cairo_device;
106 	}
107 	
108 	
109 	/** the main Gtk struct as a void* */
110 	protected void* getStruct()
111 	{
112 		return cast(void*)cairo_device;
113 	}
114 	
115 	/**
116 	 * Sets our main struct and passes it to the parent class
117 	 */
118 	public this (cairo_device_t* cairo_device)
119 	{
120 		this.cairo_device = cairo_device;
121 	}
122 	
123 	/**
124 	 */
125 	
126 	/**
127 	 * Increases the reference count on device by one. This prevents
128 	 * device from being destroyed until a matching call to
129 	 * cairo_device_destroy() is made.
130 	 * The number of references to a cairo_device_t can be get using
131 	 * cairo_device_get_reference_count().
132 	 * Since 1.10
133 	 * Returns: the referenced cairo_device_t.
134 	 */
135 	public Device reference()
136 	{
137 		// cairo_device_t * cairo_device_reference (cairo_device_t *device);
138 		auto p = cairo_device_reference(cairo_device);
139 		
140 		if(p is null)
141 		{
142 			return null;
143 		}
144 		
145 		return new Device(cast(cairo_device_t*) p);
146 	}
147 	
148 	/**
149 	 * Decreases the reference count on device by one. If the result is
150 	 * zero, then device and all associated resources are freed. See
151 	 * cairo_device_reference().
152 	 * This function may acquire devices if the last reference was dropped.
153 	 * Since 1.10
154 	 */
155 	public void destroy()
156 	{
157 		// void cairo_device_destroy (cairo_device_t *device);
158 		cairo_device_destroy(cairo_device);
159 	}
160 	
161 	/**
162 	 * Checks whether an error has previously occurred for this
163 	 * device.
164 	 * Since 1.10
165 	 * Returns: CAIRO_STATUS_SUCCESS on success or an error code if the device is in an error state.
166 	 */
167 	public cairo_status_t status()
168 	{
169 		// cairo_status_t cairo_device_status (cairo_device_t *device);
170 		return cairo_device_status(cairo_device);
171 	}
172 	
173 	/**
174 	 * This function finishes the device and drops all references to
175 	 * external resources. All surfaces, fonts and other objects created
176 	 * for this device will be finished, too.
177 	 * Further operations on the device will not affect the device but
178 	 * will instead trigger a CAIRO_STATUS_DEVICE_FINISHED error.
179 	 * When the last call to cairo_device_destroy() decreases the
180 	 * reference count to zero, cairo will call cairo_device_finish() if
181 	 * it hasn't been called already, before freeing the resources
182 	 * associated with the device.
183 	 * This function may acquire devices.
184 	 * Since 1.10
185 	 */
186 	public void finish()
187 	{
188 		// void cairo_device_finish (cairo_device_t *device);
189 		cairo_device_finish(cairo_device);
190 	}
191 	
192 	/**
193 	 * Finish any pending operations for the device and also restore any
194 	 * temporary modifications cairo has made to the device's state.
195 	 * This function must be called before switching from using the
196 	 * device with Cairo to operating on it directly with native APIs.
197 	 * If the device doesn't support direct access, then this function
198 	 * does nothing.
199 	 * This function may acquire devices.
200 	 * Since 1.10
201 	 */
202 	public void flush()
203 	{
204 		// void cairo_device_flush (cairo_device_t *device);
205 		cairo_device_flush(cairo_device);
206 	}
207 	
208 	/**
209 	 * This function returns the type of the device. See cairo_device_type_t
210 	 * for available types.
211 	 * Since 1.10
212 	 * Params:
213 	 * device = a cairo_device_t
214 	 * Returns: The type of device.
215 	 */
216 	public cairo_device_type_t getType()
217 	{
218 		// cairo_device_type_t cairo_device_get_type (cairo_device_t *device);
219 		return cairo_device_get_type(cairo_device);
220 	}
221 	
222 	/**
223 	 * Returns the current reference count of device.
224 	 * Since 1.10
225 	 * Returns: the current reference count of device. If the object is a nil object, 0 will be returned.
226 	 */
227 	public uint getReferenceCount()
228 	{
229 		// unsigned int cairo_device_get_reference_count (cairo_device_t *device);
230 		return cairo_device_get_reference_count(cairo_device);
231 	}
232 	
233 	/**
234 	 * Attach user data to device. To remove user data from a surface,
235 	 * call this function with the key that was used to set it and NULL
236 	 * for data.
237 	 * Since 1.10
238 	 * Params:
239 	 * key = the address of a cairo_user_data_key_t to attach the user data to
240 	 * userData = the user data to attach to the cairo_device_t
241 	 * destroy = a cairo_destroy_func_t which will be called when the
242 	 * cairo_t is destroyed or when new user data is attached using the
243 	 * same key.
244 	 * Returns: CAIRO_STATUS_SUCCESS or CAIRO_STATUS_NO_MEMORY if a slot could not be allocated for the user data.
245 	 */
246 	public cairo_status_t setUserData(cairo_user_data_key_t* key, void* userData, cairo_destroy_func_t destroy)
247 	{
248 		// cairo_status_t cairo_device_set_user_data (cairo_device_t *device,  const cairo_user_data_key_t *key,  void *user_data,  cairo_destroy_func_t destroy);
249 		return cairo_device_set_user_data(cairo_device, key, userData, destroy);
250 	}
251 	
252 	/**
253 	 * Return user data previously attached to device using the
254 	 * specified key. If no user data has been attached with the given
255 	 * key this function returns NULL.
256 	 * Since 1.10
257 	 * Params:
258 	 * key = the address of the cairo_user_data_key_t the user data was
259 	 * attached to
260 	 * Returns: the user data previously attached or NULL.
261 	 */
262 	public void* getUserData(cairo_user_data_key_t* key)
263 	{
264 		// void * cairo_device_get_user_data (cairo_device_t *device,  const cairo_user_data_key_t *key);
265 		return cairo_device_get_user_data(cairo_device, key);
266 	}
267 	
268 	/**
269 	 * Acquires the device for the current thread. This function will block
270 	 * until no other thread has acquired the device.
271 	 * If the return value is CAIRO_STATUS_SUCCESS, you successfully acquired the
272 	 * device. From now on your thread owns the device and no other thread will be
273 	 * able to acquire it until a matching call to cairo_device_release(). It is
274 	 * allowed to recursively acquire the device multiple times from the same
275 	 * thread.
276 	 * Note
277 	 * You must never acquire two different devices at the same time
278 	 * unless this is explicitly allowed. Otherwise the possibility of deadlocks
279 	 * exist.
280 	 * As various Cairo functions can acquire devices when called, these functions
281 	 * may also cause deadlocks when you call them with an acquired device. So you
282 	 * must not have a device acquired when calling them. These functions are
283 	 * marked in the documentation.
284 	 * Since 1.10
285 	 * Returns: CAIRO_STATUS_SUCCESS on success or an error code if the device is in an error state and could not be acquired. After a successful call to cairo_device_acquire(), a matching call to cairo_device_release() is required.
286 	 */
287 	public cairo_status_t acquire()
288 	{
289 		// cairo_status_t cairo_device_acquire (cairo_device_t *device);
290 		return cairo_device_acquire(cairo_device);
291 	}
292 	
293 	/**
294 	 * Releases a device previously acquired using cairo_device_acquire(). See
295 	 * that function for details.
296 	 * Since 1.10
297 	 */
298 	public void release()
299 	{
300 		// void cairo_device_release (cairo_device_t *device);
301 		cairo_device_release(cairo_device);
302 	}
303 }