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