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