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