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-SVG-Surfaces.html 27 * outPack = cairo 28 * outFile = SvgSurface 29 * strct = cairo_surface_t 30 * realStrct= 31 * ctorStrct= 32 * clss = SvgSurface 33 * interf = 34 * class Code: No 35 * interface Code: No 36 * template for: 37 * extend = cairo_surface_t 38 * implements: 39 * prefixes: 40 * - cairo_svg_surface_ 41 * - cairo_svg_ 42 * omit structs: 43 * omit prefixes: 44 * omit code: 45 * omit signals: 46 * imports: 47 * - glib.Str 48 * structWrap: 49 * - cairo_surface_t* -> SvgSurface 50 * module aliases: 51 * local aliases: 52 * overrides: 53 */ 54 55 module cairo.SvgSurface; 56 57 public import gtkc.cairotypes; 58 59 private import gtkc.cairo; 60 private import glib.ConstructionException; 61 62 63 private import glib.Str; 64 65 66 67 private import cairo.Surface; 68 69 /** 70 * Description 71 * The SVG surface is used to render cairo graphics to 72 * SVG files and is a multi-page vector surface backend. 73 */ 74 public class SvgSurface : Surface 75 { 76 77 /** the main Gtk struct */ 78 protected cairo_surface_t* cairo_surface; 79 80 81 public cairo_surface_t* getSvgSurfaceStruct() 82 { 83 return cairo_surface; 84 } 85 86 87 /** the main Gtk struct as a void* */ 88 protected override void* getStruct() 89 { 90 return cast(void*)cairo_surface; 91 } 92 93 /** 94 * Sets our main struct and passes it to the parent class 95 */ 96 public this (cairo_surface_t* cairo_surface) 97 { 98 super(cast(cairo_surface_t*)cairo_surface); 99 this.cairo_surface = cairo_surface; 100 } 101 102 /** 103 */ 104 105 /** 106 * Creates a SVG surface of the specified size in points to be written 107 * to filename. 108 * The SVG surface backend recognizes the following MIME types for the 109 * data attached to a surface (see cairo_surface_set_mime_data()) when 110 * Since 1.2 111 * Params: 112 * filename = a filename for the SVG output (must be writable), NULL may be 113 * used to specify no output. This will generate a SVG surface that 114 * may be queried and used as a source, without generating a 115 * temporary file. 116 * widthInPoints = width of the surface, in points (1 point == 1/72.0 inch) 117 * heightInPoints = height of the surface, in points (1 point == 1/72.0 inch) 118 * Returns: a pointer to the newly created surface. The caller owns the surface and should call cairo_surface_destroy() when done with it. This function always returns a valid pointer, but it will return a pointer to a "nil" surface if an error such as out of memory occurs. You can use cairo_surface_status() to check for this. 119 */ 120 public static SvgSurface create(string filename, double widthInPoints, double heightInPoints) 121 { 122 // cairo_surface_t * cairo_svg_surface_create (const char *filename, double width_in_points, double height_in_points); 123 auto p = cairo_svg_surface_create(Str.toStringz(filename), widthInPoints, heightInPoints); 124 125 if(p is null) 126 { 127 return null; 128 } 129 130 return new SvgSurface(cast(cairo_surface_t*) p); 131 } 132 133 /** 134 * Creates a SVG surface of the specified size in points to be written 135 * incrementally to the stream represented by write_func and closure. 136 * Since 1.2 137 * Params: 138 * writeFunc = a cairo_write_func_t to accept the output data, may be NULL 139 * to indicate a no-op write_func. With a no-op write_func, 140 * the surface may be queried or used as a source without 141 * generating any temporary files. 142 * closure = the closure argument for write_func 143 * widthInPoints = width of the surface, in points (1 point == 1/72.0 inch) 144 * heightInPoints = height of the surface, in points (1 point == 1/72.0 inch) 145 * Returns: a pointer to the newly created surface. The caller owns the surface and should call cairo_surface_destroy() when done with it. This function always returns a valid pointer, but it will return a pointer to a "nil" surface if an error such as out of memory occurs. You can use cairo_surface_status() to check for this. 146 */ 147 public static SvgSurface createForStream(cairo_write_func_t writeFunc, void* closure, double widthInPoints, double heightInPoints) 148 { 149 // cairo_surface_t * cairo_svg_surface_create_for_stream (cairo_write_func_t write_func, void *closure, double width_in_points, double height_in_points); 150 auto p = cairo_svg_surface_create_for_stream(writeFunc, closure, widthInPoints, heightInPoints); 151 152 if(p is null) 153 { 154 return null; 155 } 156 157 return new SvgSurface(cast(cairo_surface_t*) p); 158 } 159 160 /** 161 * Restricts the generated SVG file to version. See cairo_svg_get_versions() 162 * for a list of available version values that can be used here. 163 * This function should only be called before any drawing operations 164 * have been performed on the given surface. The simplest way to do 165 * this is to call this function immediately after creating the 166 * surface. 167 * Since 1.2 168 * Params: 169 * version = SVG version 170 */ 171 public void restrictToVersion(cairo_svg_version_t versio) 172 { 173 // void cairo_svg_surface_restrict_to_version (cairo_surface_t *surface, cairo_svg_version_t version); 174 cairo_svg_surface_restrict_to_version(cairo_surface, versio); 175 } 176 177 /** 178 * Used to retrieve the list of supported versions. See 179 * cairo_svg_surface_restrict_to_version(). 180 * Since 1.2 181 * Params: 182 * versions = supported version list 183 */ 184 public static void getVersions(out cairo_svg_version_t[] versions) 185 { 186 // void cairo_svg_get_versions (cairo_svg_version_t const **versions, int *num_versions); 187 cairo_svg_version_t* outversions = null; 188 int numVersions; 189 190 cairo_svg_get_versions(&outversions, &numVersions); 191 192 versions = outversions[0 .. numVersions]; 193 } 194 195 /** 196 * Get the string representation of the given version id. This function 197 * will return NULL if version isn't valid. See cairo_svg_get_versions() 198 * for a way to get the list of valid version ids. 199 * Since 1.2 200 * Params: 201 * version = a version id 202 * Returns: the string associated to given version. 203 */ 204 public static string versionToString(cairo_svg_version_t versio) 205 { 206 // const char * cairo_svg_version_to_string (cairo_svg_version_t version); 207 return Str.toString(cairo_svg_version_to_string(versio)); 208 } 209 }