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