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