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-Raster-Sources.html 27 * outPack = cairo 28 * outFile = RasterSource 29 * strct = cairo_pattern_t 30 * realStrct= 31 * ctorStrct= 32 * clss = RasterSource 33 * interf = 34 * class Code: Yes 35 * interface Code: No 36 * template for: 37 * extend = cairo_pattern_t 38 * implements: 39 * prefixes: 40 * - cairo_raster_source_pattern_ 41 * omit structs: 42 * omit prefixes: 43 * omit code: 44 * - cairo_pattern_create_raster_source 45 * omit signals: 46 * imports: 47 * structWrap: 48 * module aliases: 49 * local aliases: 50 * overrides: 51 */ 52 53 module cairo.RasterSource; 54 55 public import gtkc.cairotypes; 56 57 private import gtkc.cairo; 58 private import glib.ConstructionException; 59 60 61 62 private import cairo.Pattern; 63 64 /** 65 * The raster source provides the ability to supply arbitrary pixel data 66 * whilst rendering. The pixels are queried at the time of rasterisation 67 * by means of user callback functions, allowing for the ultimate 68 * flexibility. For example, in handling compressed image sources, you 69 * may keep a MRU cache of decompressed images and decompress sources on the 70 * fly and discard old ones to conserve memory. 71 * 72 * For the raster source to be effective, you must at least specify 73 * the acquire and release callbacks which are used to retrieve the pixel 74 * data for the region of interest and demark when it can be freed afterwards. 75 * Other callbacks are provided for when the pattern is copied temporarily 76 * during rasterisation, or more permanently as a snapshot in order to keep 77 * the pixel data available for printing. 78 */ 79 public class RasterSource : Pattern 80 { 81 82 /** the main Gtk struct */ 83 protected cairo_pattern_t* cairo_pattern; 84 85 86 /** Get the main Gtk struct */ 87 public cairo_pattern_t* getRasterSourceStruct() 88 { 89 return cairo_pattern; 90 } 91 92 93 /** the main Gtk struct as a void* */ 94 protected override void* getStruct() 95 { 96 return cast(void*)cairo_pattern; 97 } 98 99 /** 100 * Sets our main struct and passes it to the parent class 101 */ 102 public this (cairo_pattern_t* cairo_pattern) 103 { 104 super(cast(cairo_pattern_t*)cairo_pattern); 105 this.cairo_pattern = cairo_pattern; 106 } 107 108 /** 109 * Creates a new user pattern for providing pixel data. 110 * 111 * Use the setter functions to associate callbacks with the returned 112 * pattern. The only mandatory callback is acquire. 113 * 114 * Since 1.12 115 * 116 * Params: 117 * userData = the user data to be passed to all callbacks 118 * content = content type for the pixel data that will be returned. 119 * Knowing the content type ahead of time is used for analysing 120 * the operation and picking the appropriate rendering path. 121 * width = maximum size of the sample area 122 * height = maximum size of the sample area 123 */ 124 public this(void* userData, CairoContent content, int width, int height) 125 { 126 // cairo_pattern_t * cairo_pattern_create_raster_source (void *user_data, cairo_content_t content, int width, int height); 127 this(cairo_pattern_create_raster_source(userData, content, width, height)); 128 } 129 130 /** 131 */ 132 133 /** 134 * Updates the user data that is provided to all callbacks. 135 * Since 1.12 136 * Params: 137 * data = the user data to be passed to all callbacks 138 */ 139 public void setCallbackData(void* data) 140 { 141 // void cairo_raster_source_pattern_set_callback_data (cairo_pattern_t *pattern, void *data); 142 cairo_raster_source_pattern_set_callback_data(cairo_pattern, data); 143 } 144 145 /** 146 * Queries the current user data. 147 * Since 1.12 148 * Returns: the current user-data passed to each callback 149 */ 150 public void* getCallbackData() 151 { 152 // void * cairo_raster_source_pattern_get_callback_data (cairo_pattern_t *pattern); 153 return cairo_raster_source_pattern_get_callback_data(cairo_pattern); 154 } 155 156 /** 157 * Specifies the callbacks used to generate the image surface for a rendering 158 * operation (acquire) and the function used to cleanup that surface afterwards. 159 * The acquire callback should create a surface (preferably an image 160 * surface created to match the target using 161 * cairo_surface_create_similar_image()) that defines at least the region 162 * of interest specified by extents. The surface is allowed to be the entire 163 * sample area, but if it does contain a subsection of the sample area, 164 * the surface extents should be provided by setting the device offset (along 165 * with its width and height) using cairo_surface_set_device_offset(). 166 * Since 1.12 167 * Params: 168 * acquire = acquire callback 169 * release = release callback 170 */ 171 public void setAcquire(cairo_raster_source_acquire_func_t acquire, cairo_raster_source_release_func_t release) 172 { 173 // void cairo_raster_source_pattern_set_acquire (cairo_pattern_t *pattern, cairo_raster_source_acquire_func_t acquire, cairo_raster_source_release_func_t release); 174 cairo_raster_source_pattern_set_acquire(cairo_pattern, acquire, release); 175 } 176 177 /** 178 * Queries the current acquire and release callbacks. 179 * Since 1.12 180 * Params: 181 * acquire = return value for the current acquire callback 182 * release = return value for the current release callback 183 */ 184 public void getAcquire(cairo_raster_source_acquire_func_t* acquire, cairo_raster_source_release_func_t* release) 185 { 186 // void cairo_raster_source_pattern_get_acquire (cairo_pattern_t *pattern, cairo_raster_source_acquire_func_t *acquire, cairo_raster_source_release_func_t *release); 187 cairo_raster_source_pattern_get_acquire(cairo_pattern, acquire, release); 188 } 189 190 /** 191 * Sets the callback that will be used whenever a snapshot is taken of the 192 * pattern, that is whenever the current contents of the pattern should be 193 * preserved for later use. This is typically invoked whilst printing. 194 * Since 1.12 195 * Params: 196 * snapshot = snapshot callback 197 */ 198 public void setSnapshot(cairo_raster_source_snapshot_func_t snapshot) 199 { 200 // void cairo_raster_source_pattern_set_snapshot (cairo_pattern_t *pattern, cairo_raster_source_snapshot_func_t snapshot); 201 cairo_raster_source_pattern_set_snapshot(cairo_pattern, snapshot); 202 } 203 204 /** 205 * Queries the current snapshot callback. 206 * Since 1.12 207 * Returns: the current snapshot callback 208 */ 209 public cairo_raster_source_snapshot_func_t getSnapshot() 210 { 211 // cairo_raster_source_snapshot_func_t cairo_raster_source_pattern_get_snapshot (cairo_pattern_t *pattern); 212 return cairo_raster_source_pattern_get_snapshot(cairo_pattern); 213 } 214 215 /** 216 * Updates the copy callback which is used whenever a temporary copy of the 217 * pattern is taken. 218 * Since 1.12 219 * Params: 220 * copy = the copy callback 221 */ 222 public void setCopy(cairo_raster_source_copy_func_t copy) 223 { 224 // void cairo_raster_source_pattern_set_copy (cairo_pattern_t *pattern, cairo_raster_source_copy_func_t copy); 225 cairo_raster_source_pattern_set_copy(cairo_pattern, copy); 226 } 227 228 /** 229 * Queries the current copy callback. 230 * Since 1.12 231 * Returns: the current copy callback 232 */ 233 public cairo_raster_source_copy_func_t getCopy() 234 { 235 // cairo_raster_source_copy_func_t cairo_raster_source_pattern_get_copy (cairo_pattern_t *pattern); 236 return cairo_raster_source_pattern_get_copy(cairo_pattern); 237 } 238 239 /** 240 * Updates the finish callback which is used whenever a pattern (or a copy 241 * thereof) will no longer be used. 242 * Since 1.12 243 * Params: 244 * finish = the finish callback 245 */ 246 public void setFinish(cairo_raster_source_finish_func_t finish) 247 { 248 // void cairo_raster_source_pattern_set_finish (cairo_pattern_t *pattern, cairo_raster_source_finish_func_t finish); 249 cairo_raster_source_pattern_set_finish(cairo_pattern, finish); 250 } 251 252 /** 253 * Queries the current finish callback. 254 * Since 1.12 255 * Returns: the current finish callback 256 */ 257 public cairo_raster_source_finish_func_t getFinish() 258 { 259 // cairo_raster_source_finish_func_t cairo_raster_source_pattern_get_finish (cairo_pattern_t *pattern); 260 return cairo_raster_source_pattern_get_finish(cairo_pattern); 261 } 262 }