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