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-PostScript-Surfaces.html
27  * outPack = cairo
28  * outFile = PostScriptSurface
29  * strct   = cairo_surface_t
30  * realStrct=
31  * ctorStrct=
32  * clss    = PostScriptSurface
33  * interf  = 
34  * class Code: No
35  * interface Code: No
36  * template for:
37  * extend  = cairo_surface_t
38  * implements:
39  * prefixes:
40  * 	- cairo_ps_surface_
41  * 	- cairo_ps_
42  * omit structs:
43  * omit prefixes:
44  * omit code:
45  * omit signals:
46  * imports:
47  * 	- glib.Str
48  * structWrap:
49  * 	- cairo_surface_t* -> PostScriptSurface
50  * module aliases:
51  * local aliases:
52  * overrides:
53  */
54 
55 module cairo.PostScriptSurface;
56 
57 public  import cairo.c.types;
58 
59 private import cairo.c.functions;
60 private import glib.ConstructionException;
61 
62 private import glib.Str;
63 
64 
65 private import cairo.Surface;
66 
67 /**
68  * The PostScript surface is used to render cairo graphics to Adobe
69  * PostScript files and is a multi-page vector surface backend.
70  */
71 public class PostScriptSurface : 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* getPostScriptSurfaceStruct()
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 PostScript surface of the specified size in points to be
105 	 * written to filename. See cairo_ps_surface_create_for_stream() for
106 	 * a more flexible mechanism for handling the PostScript output than
107 	 * simply writing it to a named file.
108 	 * Note that the size of individual pages of the PostScript output can
109 	 * vary. See cairo_ps_surface_set_size().
110 	 * Since 1.2
111 	 * Params:
112 	 * filename = a filename for the PS output (must be writable), NULL may be
113 	 * used to specify no output. This will generate a PS surface that
114 	 * may be queried and used as a source, without generating a
115 	 * temporary file.
116 	 * widthInPoints = width of the surface, in points (1 point == 1/72.0 inch)
117 	 * heightInPoints = height of the surface, in points (1 point == 1/72.0 inch)
118 	 * 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.
119 	 */
120 	public static PostScriptSurface create(string filename, double widthInPoints, double heightInPoints)
121 	{
122 		// cairo_surface_t * cairo_ps_surface_create (const char *filename,  double width_in_points,  double height_in_points);
123 		auto p = cairo_ps_surface_create(Str.toStringz(filename), widthInPoints, heightInPoints);
124 		
125 		if(p is null)
126 		{
127 			return null;
128 		}
129 		
130 		return new PostScriptSurface(cast(cairo_surface_t*) p);
131 	}
132 	
133 	/**
134 	 * Creates a PostScript surface of the specified size in points to be
135 	 * written incrementally to the stream represented by write_func and
136 	 * closure. See cairo_ps_surface_create() for a more convenient way
137 	 * to simply direct the PostScript output to a named file.
138 	 * Note that the size of individual pages of the PostScript
139 	 * output can vary. See cairo_ps_surface_set_size().
140 	 * Since 1.2
141 	 * Params:
142 	 * writeFunc = a cairo_write_func_t to accept the output data, may be NULL
143 	 * to indicate a no-op write_func. With a no-op write_func,
144 	 * the surface may be queried or used as a source without
145 	 * generating any temporary files.
146 	 * closure = the closure argument for write_func
147 	 * widthInPoints = width of the surface, in points (1 point == 1/72.0 inch)
148 	 * heightInPoints = height of the surface, in points (1 point == 1/72.0 inch)
149 	 * 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.
150 	 */
151 	public static PostScriptSurface createForStream(cairo_write_func_t writeFunc, void* closure, double widthInPoints, double heightInPoints)
152 	{
153 		// cairo_surface_t * cairo_ps_surface_create_for_stream (cairo_write_func_t write_func,  void *closure,  double width_in_points,  double height_in_points);
154 		auto p = cairo_ps_surface_create_for_stream(writeFunc, closure, widthInPoints, heightInPoints);
155 		
156 		if(p is null)
157 		{
158 			return null;
159 		}
160 		
161 		return new PostScriptSurface(cast(cairo_surface_t*) p);
162 	}
163 	
164 	/**
165 	 * Restricts the generated PostSript file to level. See
166 	 * cairo_ps_get_levels() for a list of available level values that
167 	 * can be used here.
168 	 * This function should only be called before any drawing operations
169 	 * have been performed on the given surface. The simplest way to do
170 	 * this is to call this function immediately after creating the
171 	 * surface.
172 	 * Since 1.6
173 	 * Params:
174 	 * level = PostScript level
175 	 */
176 	public void restrictToLevel(cairo_ps_level_t level)
177 	{
178 		// void cairo_ps_surface_restrict_to_level (cairo_surface_t *surface,  cairo_ps_level_t level);
179 		cairo_ps_surface_restrict_to_level(cairo_surface, level);
180 	}
181 	
182 	/**
183 	 * Used to retrieve the list of supported levels. See
184 	 * cairo_ps_surface_restrict_to_level().
185 	 * Since 1.6
186 	 * Params:
187 	 * levels = supported level list
188 	 */
189 	public static void getLevels(out cairo_ps_level_t[] levels)
190 	{
191 		// void cairo_ps_get_levels (cairo_ps_level_t const **levels,  int *num_levels);
192 		cairo_ps_level_t* outlevels = null;
193 		int numLevels;
194 		
195 		cairo_ps_get_levels(&outlevels, &numLevels);
196 		
197 		levels = outlevels[0 .. numLevels];
198 	}
199 	
200 	/**
201 	 * Get the string representation of the given level id. This function
202 	 * will return NULL if level id isn't valid. See cairo_ps_get_levels()
203 	 * for a way to get the list of valid level ids.
204 	 * Since 1.6
205 	 * Params:
206 	 * level = a level id
207 	 * Returns: the string associated to given level.
208 	 */
209 	public static string levelToString(cairo_ps_level_t level)
210 	{
211 		// const char * cairo_ps_level_to_string (cairo_ps_level_t level);
212 		return Str.toString(cairo_ps_level_to_string(level));
213 	}
214 	
215 	/**
216 	 * If eps is TRUE, the PostScript surface will output Encapsulated
217 	 * PostScript.
218 	 * This function should only be called before any drawing operations
219 	 * have been performed on the current page. The simplest way to do
220 	 * this is to call this function immediately after creating the
221 	 * surface. An Encapsulated PostScript file should never contain more
222 	 * than one page.
223 	 * Since 1.6
224 	 * Params:
225 	 * eps = TRUE to output EPS format PostScript
226 	 */
227 	public void setEps(cairo_bool_t eps)
228 	{
229 		// void cairo_ps_surface_set_eps (cairo_surface_t *surface,  cairo_bool_t eps);
230 		cairo_ps_surface_set_eps(cairo_surface, eps);
231 	}
232 	
233 	/**
234 	 * Check whether the PostScript surface will output Encapsulated PostScript.
235 	 * Since 1.6
236 	 * Returns: TRUE if the surface will output Encapsulated PostScript.
237 	 */
238 	public cairo_bool_t getEps()
239 	{
240 		// cairo_bool_t cairo_ps_surface_get_eps (cairo_surface_t *surface);
241 		return cairo_ps_surface_get_eps(cairo_surface);
242 	}
243 	
244 	/**
245 	 * Changes the size of a PostScript surface for the current (and
246 	 * subsequent) pages.
247 	 * This function should only be called before any drawing operations
248 	 * have been performed on the current page. The simplest way to do
249 	 * this is to call this function immediately after creating the
250 	 * surface or immediately after completing a page with either
251 	 * cairo_show_page() or cairo_copy_page().
252 	 * Since 1.2
253 	 * Params:
254 	 * widthInPoints = new surface width, in points (1 point == 1/72.0 inch)
255 	 * heightInPoints = new surface height, in points (1 point == 1/72.0 inch)
256 	 */
257 	public void setSize(double widthInPoints, double heightInPoints)
258 	{
259 		// void cairo_ps_surface_set_size (cairo_surface_t *surface,  double width_in_points,  double height_in_points);
260 		cairo_ps_surface_set_size(cairo_surface, widthInPoints, heightInPoints);
261 	}
262 	
263 	/**
264 	 * This function indicates that subsequent calls to
265 	 * cairo_ps_surface_dsc_comment() should direct comments to the Setup
266 	 * section of the PostScript output.
267 	 * This function should be called at most once per surface, and must
268 	 * be called before any call to cairo_ps_surface_dsc_begin_page_setup()
269 	 * and before any drawing is performed to the surface.
270 	 * See cairo_ps_surface_dsc_comment() for more details.
271 	 * Since 1.2
272 	 */
273 	public void dscBeginSetup()
274 	{
275 		// void cairo_ps_surface_dsc_begin_setup (cairo_surface_t *surface);
276 		cairo_ps_surface_dsc_begin_setup(cairo_surface);
277 	}
278 	
279 	/**
280 	 * This function indicates that subsequent calls to
281 	 * cairo_ps_surface_dsc_comment() should direct comments to the
282 	 * PageSetup section of the PostScript output.
283 	 * This function call is only needed for the first page of a
284 	 * surface. It should be called after any call to
285 	 * cairo_ps_surface_dsc_begin_setup() and before any drawing is
286 	 * performed to the surface.
287 	 * See cairo_ps_surface_dsc_comment() for more details.
288 	 * Since 1.2
289 	 */
290 	public void dscBeginPageSetup()
291 	{
292 		// void cairo_ps_surface_dsc_begin_page_setup  (cairo_surface_t *surface);
293 		cairo_ps_surface_dsc_begin_page_setup(cairo_surface);
294 	}
295 	
296 	/**
297 	 * Emit a comment into the PostScript output for the given surface.
298 	 * The comment is expected to conform to the PostScript Language
299 	 * Document Structuring Conventions (DSC). Please see that manual for
300 	 * details on the available comments and their meanings. In
301 	 * particular, the %%IncludeFeature comment allows a
302 	 * device-independent means of controlling printer device features. So
303 	 * the PostScript Printer Description Files Specification will also be
304 	 * a useful reference.
305 	 * The comment string must begin with a percent character (%) and the
306 	 * total length of the string (including any initial percent
307 	 * characters) must not exceed 255 characters. Violating either of
308 	 * these conditions will place surface into an error state. But
309 	 * beyond these two conditions, this function will not enforce
310 	 * conformance of the comment with any particular specification.
311 	 * The comment string should not have a trailing newline.
312 	 * The DSC specifies different sections in which particular comments
313 	 * can appear. This function provides for comments to be emitted
314 	 * within three sections: the header, the Setup section, and the
315 	 * PageSetup section. Comments appearing in the first two sections
316 	 * apply to the entire document while comments in the BeginPageSetup
317 	 * section apply only to a single page.
318 	 * For comments to appear in the header section, this function should
319 	 * be called after the surface is created, but before a call to
320 	 * cairo_ps_surface_dsc_begin_setup().
321 	 * For comments to appear in the Setup section, this function should
322 	 * be called after a call to cairo_ps_surface_dsc_begin_setup() but
323 	 * before a call to cairo_ps_surface_dsc_begin_page_setup().
324 	 * For comments to appear in the PageSetup section, this function
325 	 * should be called after a call to
326 	 * cairo_ps_surface_dsc_begin_page_setup().
327 	 * Note that it is only necessary to call
328 	 * cairo_ps_surface_dsc_begin_page_setup() for the first page of any
329 	 * surface. After a call to cairo_show_page() or cairo_copy_page()
330 	 * comments are unambiguously directed to the PageSetup section of the
331 	 * current page. But it doesn't hurt to call this function at the
332 	 * beginning of every page as that consistency may make the calling
333 	 * code simpler.
334 	 * As a final note, cairo automatically generates several comments on
335 	 * its own. As such, applications must not manually generate any of
336 	 * Since 1.2
337 	 * Params:
338 	 * comment = a comment string to be emitted into the PostScript output
339 	 */
340 	public void dscComment(string comment)
341 	{
342 		// void cairo_ps_surface_dsc_comment (cairo_surface_t *surface,  const char *comment);
343 		cairo_ps_surface_dsc_comment(cairo_surface, Str.toStringz(comment));
344 	}
345 }