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