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 private import glib.Str; 63 64 65 private import cairo.Surface; 66 67 /** 68 * The SVG surface is used to render cairo graphics to 69 * SVG files and is a multi-page vector surface backend. 70 */ 71 public class SvgSurface : Surface 72 { 73 74 /** the main Gtk struct */ 75 protected cairo_surface_t* cairo_surface; 76 77 78 /** Get the main Gtk struct */ 79 public cairo_surface_t* getSvgSurfaceStruct() 80 { 81 return cairo_surface; 82 } 83 84 85 /** the main Gtk struct as a void* */ 86 protected override void* getStruct() 87 { 88 return cast(void*)cairo_surface; 89 } 90 91 /** 92 * Sets our main struct and passes it to the parent class 93 */ 94 public this (cairo_surface_t* cairo_surface) 95 { 96 super(cast(cairo_surface_t*)cairo_surface); 97 this.cairo_surface = cairo_surface; 98 } 99 100 /** 101 */ 102 103 /** 104 * Creates a SVG surface of the specified size in points to be written 105 * to filename. 106 * The SVG surface backend recognizes the following MIME types for the 107 * data attached to a surface (see cairo_surface_set_mime_data()) when 108 * Since 1.2 109 * Params: 110 * filename = a filename for the SVG output (must be writable), NULL may be 111 * used to specify no output. This will generate a SVG surface that 112 * may be queried and used as a source, without generating a 113 * temporary file. 114 * widthInPoints = width of the surface, in points (1 point == 1/72.0 inch) 115 * heightInPoints = height of the surface, in points (1 point == 1/72.0 inch) 116 * 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. 117 */ 118 public static SvgSurface create(string filename, double widthInPoints, double heightInPoints) 119 { 120 // cairo_surface_t * cairo_svg_surface_create (const char *filename, double width_in_points, double height_in_points); 121 auto p = cairo_svg_surface_create(Str.toStringz(filename), widthInPoints, heightInPoints); 122 123 if(p is null) 124 { 125 return null; 126 } 127 128 return new SvgSurface(cast(cairo_surface_t*) p); 129 } 130 131 /** 132 * Creates a SVG surface of the specified size in points to be written 133 * incrementally to the stream represented by write_func and closure. 134 * Since 1.2 135 * Params: 136 * writeFunc = a cairo_write_func_t to accept the output data, may be NULL 137 * to indicate a no-op write_func. With a no-op write_func, 138 * the surface may be queried or used as a source without 139 * generating any temporary files. 140 * closure = the closure argument for write_func 141 * widthInPoints = width of the surface, in points (1 point == 1/72.0 inch) 142 * heightInPoints = height of the surface, in points (1 point == 1/72.0 inch) 143 * 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. 144 */ 145 public static SvgSurface createForStream(cairo_write_func_t writeFunc, void* closure, double widthInPoints, double heightInPoints) 146 { 147 // 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); 148 auto p = cairo_svg_surface_create_for_stream(writeFunc, closure, widthInPoints, heightInPoints); 149 150 if(p is null) 151 { 152 return null; 153 } 154 155 return new SvgSurface(cast(cairo_surface_t*) p); 156 } 157 158 /** 159 * Restricts the generated SVG file to version. See cairo_svg_get_versions() 160 * for a list of available version values that can be used here. 161 * This function should only be called before any drawing operations 162 * have been performed on the given surface. The simplest way to do 163 * this is to call this function immediately after creating the 164 * surface. 165 * Since 1.2 166 * Params: 167 * version = SVG version 168 */ 169 public void restrictToVersion(cairo_svg_version_t versio) 170 { 171 // void cairo_svg_surface_restrict_to_version (cairo_surface_t *surface, cairo_svg_version_t version); 172 cairo_svg_surface_restrict_to_version(cairo_surface, versio); 173 } 174 175 /** 176 * Used to retrieve the list of supported versions. See 177 * cairo_svg_surface_restrict_to_version(). 178 * Since 1.2 179 * Params: 180 * versions = supported version list 181 */ 182 public static void getVersions(out cairo_svg_version_t[] versions) 183 { 184 // void cairo_svg_get_versions (cairo_svg_version_t const **versions, int *num_versions); 185 cairo_svg_version_t* outversions = null; 186 int numVersions; 187 188 cairo_svg_get_versions(&outversions, &numVersions); 189 190 versions = outversions[0 .. numVersions]; 191 } 192 193 /** 194 * Get the string representation of the given version id. This function 195 * will return NULL if version isn't valid. See cairo_svg_get_versions() 196 * for a way to get the list of valid version ids. 197 * Since 1.2 198 * Params: 199 * version = a version id 200 * Returns: the string associated to given version. 201 */ 202 public static string versionToString(cairo_svg_version_t versio) 203 { 204 // const char * cairo_svg_version_to_string (cairo_svg_version_t version); 205 return Str.toString(cairo_svg_version_to_string(versio)); 206 } 207 }