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-Script-Surfaces.html 27 * outPack = cairo 28 * outFile = Script 29 * strct = cairo_device_t 30 * realStrct= 31 * ctorStrct= 32 * clss = Script 33 * interf = 34 * class Code: No 35 * interface Code: No 36 * template for: 37 * extend = cairo_device_t 38 * implements: 39 * prefixes: 40 * - cairo_script_ 41 * omit structs: 42 * omit prefixes: 43 * - cairo_script_surface_ 44 * omit code: 45 * omit signals: 46 * imports: 47 * - glib.Str 48 * - cairo.Script 49 * - cairo.RecordingSurface 50 * structWrap: 51 * - cairo_device_t* -> Script 52 * - cairo_surface_t* -> RecordingSurface 53 * module aliases: 54 * local aliases: 55 * overrides: 56 */ 57 58 module cairo.Script; 59 60 public import gtkc.cairotypes; 61 62 private import gtkc.cairo; 63 private import glib.ConstructionException; 64 65 private import glib.Str; 66 private import cairo.Script; 67 private import cairo.RecordingSurface; 68 69 70 private import cairo.Device; 71 72 /** 73 * The script surface provides the ability to render to a native 74 * script that matches the cairo drawing model. The scripts can 75 * be replayed using tools under the util/cairo-script directoriy, 76 * or with cairo-perf-trace. 77 */ 78 public class Script : Device 79 { 80 81 /** the main Gtk struct */ 82 protected cairo_device_t* cairo_device; 83 84 85 /** Get the main Gtk struct */ 86 public cairo_device_t* getScriptStruct() 87 { 88 return cairo_device; 89 } 90 91 92 /** the main Gtk struct as a void* */ 93 protected override void* getStruct() 94 { 95 return cast(void*)cairo_device; 96 } 97 98 /** 99 * Sets our main struct and passes it to the parent class 100 */ 101 public this (cairo_device_t* cairo_device) 102 { 103 super(cast(cairo_device_t*)cairo_device); 104 this.cairo_device = cairo_device; 105 } 106 107 /** 108 */ 109 110 /** 111 * Creates a output device for emitting the script, used when 112 * creating the individual surfaces. 113 * Since 1.12 114 * Params: 115 * filename = the name (path) of the file to write the script to 116 * Returns: a pointer to the newly created device. The caller owns the surface and should call cairo_device_destroy() when done with it. This function always returns a valid pointer, but it will return a pointer to a "nil" device if an error such as out of memory occurs. You can use cairo_device_status() to check for this. 117 */ 118 public static Script create(string filename) 119 { 120 // cairo_device_t * cairo_script_create (const char *filename); 121 auto p = cairo_script_create(Str.toStringz(filename)); 122 123 if(p is null) 124 { 125 return null; 126 } 127 128 return new Script(cast(cairo_device_t*) p); 129 } 130 131 /** 132 * Creates a output device for emitting the script, used when 133 * creating the individual surfaces. 134 * Since 1.12 135 * Params: 136 * writeFunc = callback function passed the bytes written to the script 137 * closure = user data to be passed to the callback 138 * Returns: a pointer to the newly created device. The caller owns the surface and should call cairo_device_destroy() when done with it. This function always returns a valid pointer, but it will return a pointer to a "nil" device if an error such as out of memory occurs. You can use cairo_device_status() to check for this. 139 */ 140 public static Script createForStream(cairo_write_func_t writeFunc, void* closure) 141 { 142 // cairo_device_t * cairo_script_create_for_stream (cairo_write_func_t write_func, void *closure); 143 auto p = cairo_script_create_for_stream(writeFunc, closure); 144 145 if(p is null) 146 { 147 return null; 148 } 149 150 return new Script(cast(cairo_device_t*) p); 151 } 152 153 /** 154 * Converts the record operations in recording_surface into a script. 155 * Since 1.12 156 * Params: 157 * recordingSurface = the recording surface to replay 158 * Returns: CAIRO_STATUS_SUCCESS on successful completion or an error code. 159 */ 160 public cairo_status_t fromRecordingSurface(RecordingSurface recordingSurface) 161 { 162 // cairo_status_t cairo_script_from_recording_surface (cairo_device_t *script, cairo_surface_t *recording_surface); 163 return cairo_script_from_recording_surface(cairo_device, (recordingSurface is null) ? null : recordingSurface.getRecordingSurfaceStruct()); 164 } 165 166 /** 167 * Queries the script for its current output mode. 168 * Since 1.12 169 * Params: 170 * script = The script (output device) to query 171 * Returns: the current output mode of the script 172 */ 173 public cairo_script_mode_t getMode() 174 { 175 // cairo_script_mode_t cairo_script_get_mode (cairo_device_t *script); 176 return cairo_script_get_mode(cairo_device); 177 } 178 179 /** 180 * Change the output mode of the script 181 * Since 1.12 182 * Params: 183 * script = The script (output device) 184 * mode = the new mode 185 */ 186 public void setMode(cairo_script_mode_t mode) 187 { 188 // void cairo_script_set_mode (cairo_device_t *script, cairo_script_mode_t mode); 189 cairo_script_set_mode(cairo_device, mode); 190 } 191 192 /** 193 * Emit a string verbatim into the script. 194 * Since 1.12 195 * Params: 196 * comment = the string to emit 197 */ 198 public void writeComment(string comment) 199 { 200 // void cairo_script_write_comment (cairo_device_t *script, const char *comment, int len); 201 cairo_script_write_comment(cairo_device, cast(char*)comment.ptr, cast(int) comment.length); 202 } 203 }