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-PDF-Surfaces.html
27  * outPack = cairo
28  * outFile = PdfSurface
29  * strct   = cairo_surface_t
30  * realStrct=
31  * ctorStrct=
32  * clss    = PdfSurface
33  * interf  = 
34  * class Code: No
35  * interface Code: No
36  * template for:
37  * extend  = cairo_surface_t
38  * implements:
39  * prefixes:
40  * 	- cairo_pdf_surface_
41  * omit structs:
42  * omit prefixes:
43  * omit code:
44  * omit signals:
45  * imports:
46  * 	- glib.Str
47  * structWrap:
48  * 	- cairo_surface_t* -> PdfSurface
49  * module aliases:
50  * local aliases:
51  * overrides:
52  */
53 
54 module cairo.PdfSurface;
55 
56 public  import gtkc.cairotypes;
57 
58 private import gtkc.cairo;
59 private import glib.ConstructionException;
60 
61 
62 private import glib.Str;
63 
64 
65 
66 private import cairo.Surface;
67 
68 /**
69  * Description
70  * The PDF surface is used to render cairo graphics to Adobe
71  * PDF files and is a multi-page vector surface backend.
72  */
73 public class PdfSurface : Surface
74 {
75 	
76 	/** the main Gtk struct */
77 	protected cairo_surface_t* cairo_surface;
78 	
79 	
80 	public cairo_surface_t* getPdfSurfaceStruct()
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 PDF surface of the specified size in points to be written
106 	 * to filename.
107 	 * Since 1.2
108 	 * Params:
109 	 * filename = a filename for the PDF output (must be writable), NULL may be
110 	 *  used to specify no output. This will generate a PDF surface that
111 	 *  may be queried and used as a source, without generating a
112 	 *  temporary file.
113 	 * widthInPoints = width of the surface, in points (1 point == 1/72.0 inch)
114 	 * heightInPoints = height of the surface, in points (1 point == 1/72.0 inch)
115 	 * 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.
116 	 */
117 	public static PdfSurface create(string filename, double widthInPoints, double heightInPoints)
118 	{
119 		// cairo_surface_t * cairo_pdf_surface_create (const char *filename,  double width_in_points,  double height_in_points);
120 		auto p = cairo_pdf_surface_create(Str.toStringz(filename), widthInPoints, heightInPoints);
121 		
122 		if(p is null)
123 		{
124 			return null;
125 		}
126 		
127 		return new PdfSurface(cast(cairo_surface_t*) p);
128 	}
129 	
130 	/**
131 	 * Creates a PDF surface of the specified size in points to be written
132 	 * incrementally to the stream represented by write_func and closure.
133 	 * Since 1.2
134 	 * Params:
135 	 * writeFunc = a cairo_write_func_t to accept the output data, may be NULL
136 	 *  to indicate a no-op write_func. With a no-op write_func,
137 	 *  the surface may be queried or used as a source without
138 	 *  generating any temporary files.
139 	 * closure = the closure argument for write_func
140 	 * widthInPoints = width of the surface, in points (1 point == 1/72.0 inch)
141 	 * heightInPoints = height of the surface, in points (1 point == 1/72.0 inch)
142 	 * 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.
143 	 */
144 	public static PdfSurface createForStream(cairo_write_func_t writeFunc, void* closure, double widthInPoints, double heightInPoints)
145 	{
146 		// cairo_surface_t * cairo_pdf_surface_create_for_stream (cairo_write_func_t write_func,  void *closure,  double width_in_points,  double height_in_points);
147 		auto p = cairo_pdf_surface_create_for_stream(writeFunc, closure, widthInPoints, heightInPoints);
148 		
149 		if(p is null)
150 		{
151 			return null;
152 		}
153 		
154 		return new PdfSurface(cast(cairo_surface_t*) p);
155 	}
156 	
157 	/**
158 	 * Restricts the generated PDF file to version. See cairo_pdf_get_versions()
159 	 * for a list of available version values that can be used here.
160 	 * This function should only be called before any drawing operations
161 	 * have been performed on the given surface. The simplest way to do
162 	 * this is to call this function immediately after creating the
163 	 * surface.
164 	 * Since 1.10
165 	 * Params:
166 	 * version = PDF version
167 	 */
168 	public void restrictToVersion(cairo_pdf_version_t versio)
169 	{
170 		// void cairo_pdf_surface_restrict_to_version  (cairo_surface_t *surface,  cairo_pdf_version_t version);
171 		cairo_pdf_surface_restrict_to_version(cairo_surface, versio);
172 	}
173 	
174 	/**
175 	 * Used to retrieve the list of supported versions. See
176 	 * cairo_pdf_surface_restrict_to_version().
177 	 * Since 1.10
178 	 * Params:
179 	 * versions = supported version list
180 	 */
181 	public static void cairoPdfGetVersions(out cairo_pdf_version_t[] versions)
182 	{
183 		// void cairo_pdf_get_versions (cairo_pdf_version_t const **versions,  int *num_versions);
184 		cairo_pdf_version_t* outversions = null;
185 		int numVersions;
186 		
187 		cairo_pdf_get_versions(&outversions, &numVersions);
188 		
189 		versions = outversions[0 .. numVersions];
190 	}
191 	
192 	/**
193 	 * Get the string representation of the given version id. This function
194 	 * will return NULL if version isn't valid. See cairo_pdf_get_versions()
195 	 * for a way to get the list of valid version ids.
196 	 * Since 1.10
197 	 * Params:
198 	 * version = a version id
199 	 * Returns: the string associated to given version.
200 	 */
201 	public static string cairoPdfVersionToString(cairo_pdf_version_t versio)
202 	{
203 		// const char * cairo_pdf_version_to_string (cairo_pdf_version_t version);
204 		return Str.toString(cairo_pdf_version_to_string(versio));
205 	}
206 	
207 	/**
208 	 * Changes the size of a PDF surface for the current (and
209 	 * subsequent) pages.
210 	 * This function should only be called before any drawing operations
211 	 * have been performed on the current page. The simplest way to do
212 	 * this is to call this function immediately after creating the
213 	 * surface or immediately after completing a page with either
214 	 * cairo_show_page() or cairo_copy_page().
215 	 * Since 1.2
216 	 * Params:
217 	 * widthInPoints = new surface width, in points (1 point == 1/72.0 inch)
218 	 * heightInPoints = new surface height, in points (1 point == 1/72.0 inch)
219 	 */
220 	public void setSize(double widthInPoints, double heightInPoints)
221 	{
222 		// void cairo_pdf_surface_set_size (cairo_surface_t *surface,  double width_in_points,  double height_in_points);
223 		cairo_pdf_surface_set_size(cairo_surface, widthInPoints, heightInPoints);
224 	}
225 }