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-Script-Surfaces.html
27  * outPack = cairo
28  * outFile = Script
29  * strct   = cairo_device_t
30  * realStrct=
31  * ctorStrct=
32  * clss    = Script
33  * interf  = 
34  * class Code: No
35  * interface Code: No
36  * template for:
37  * extend  = cairo_device_t
38  * implements:
39  * prefixes:
40  * 	- cairo_script_
41  * omit structs:
42  * omit prefixes:
43  * 	- cairo_script_surface_
44  * omit code:
45  * omit signals:
46  * imports:
47  * 	- glib.Str
48  * 	- cairo.Script
49  * 	- cairo.RecordingSurface
50  * structWrap:
51  * 	- cairo_device_t* -> Script
52  * 	- cairo_surface_t* -> RecordingSurface
53  * module aliases:
54  * local aliases:
55  * overrides:
56  */
57 
58 module cairo.Script;
59 
60 public  import gtkc.cairotypes;
61 
62 private import gtkc.cairo;
63 private import glib.ConstructionException;
64 
65 
66 private import glib.Str;
67 private import cairo.Script;
68 private import cairo.RecordingSurface;
69 
70 
71 
72 private import cairo.Device;
73 
74 /**
75  * The script surface provides the ability to render to a native
76  * script that matches the cairo drawing model. The scripts can
77  * be replayed using tools under the util/cairo-script directoriy,
78  * or with cairo-perf-trace.
79  */
80 public class Script : Device
81 {
82 	
83 	/** the main Gtk struct */
84 	protected cairo_device_t* cairo_device;
85 	
86 	
87 	public cairo_device_t* getScriptStruct()
88 	{
89 		return cairo_device;
90 	}
91 	
92 	
93 	/** the main Gtk struct as a void* */
94 	protected override void* getStruct()
95 	{
96 		return cast(void*)cairo_device;
97 	}
98 	
99 	/**
100 	 * Sets our main struct and passes it to the parent class
101 	 */
102 	public this (cairo_device_t* cairo_device)
103 	{
104 		super(cast(cairo_device_t*)cairo_device);
105 		this.cairo_device = cairo_device;
106 	}
107 	
108 	/**
109 	 */
110 	
111 	/**
112 	 * Creates a output device for emitting the script, used when
113 	 * creating the individual surfaces.
114 	 * Since 1.12
115 	 * Params:
116 	 * filename = the name (path) of the file to write the script to
117 	 * Returns: a pointer to the newly created device. The caller owns the surface and should call cairo_device_destroy() when done with it. This function always returns a valid pointer, but it will return a pointer to a "nil" device if an error such as out of memory occurs. You can use cairo_device_status() to check for this.
118 	 */
119 	public static Script create(string filename)
120 	{
121 		// cairo_device_t * cairo_script_create (const char *filename);
122 		auto p = cairo_script_create(Str.toStringz(filename));
123 		
124 		if(p is null)
125 		{
126 			return null;
127 		}
128 		
129 		return new Script(cast(cairo_device_t*) p);
130 	}
131 	
132 	/**
133 	 * Creates a output device for emitting the script, used when
134 	 * creating the individual surfaces.
135 	 * Since 1.12
136 	 * Params:
137 	 * writeFunc = callback function passed the bytes written to the script
138 	 * closure = user data to be passed to the callback
139 	 * Returns: a pointer to the newly created device. The caller owns the surface and should call cairo_device_destroy() when done with it. This function always returns a valid pointer, but it will return a pointer to a "nil" device if an error such as out of memory occurs. You can use cairo_device_status() to check for this.
140 	 */
141 	public static Script createForStream(cairo_write_func_t writeFunc, void* closure)
142 	{
143 		// cairo_device_t * cairo_script_create_for_stream (cairo_write_func_t write_func,  void *closure);
144 		auto p = cairo_script_create_for_stream(writeFunc, closure);
145 		
146 		if(p is null)
147 		{
148 			return null;
149 		}
150 		
151 		return new Script(cast(cairo_device_t*) p);
152 	}
153 	
154 	/**
155 	 * Converts the record operations in recording_surface into a script.
156 	 * Since 1.12
157 	 * Params:
158 	 * recordingSurface = the recording surface to replay
159 	 * Returns: CAIRO_STATUS_SUCCESS on successful completion or an error code.
160 	 */
161 	public cairo_status_t fromRecordingSurface(RecordingSurface recordingSurface)
162 	{
163 		// cairo_status_t cairo_script_from_recording_surface (cairo_device_t *script,  cairo_surface_t *recording_surface);
164 		return cairo_script_from_recording_surface(cairo_device, (recordingSurface is null) ? null : recordingSurface.getRecordingSurfaceStruct());
165 	}
166 	
167 	/**
168 	 * Queries the script for its current output mode.
169 	 * Since 1.12
170 	 * Params:
171 	 * script = The script (output device) to query
172 	 * Returns: the current output mode of the script
173 	 */
174 	public cairo_script_mode_t getMode()
175 	{
176 		// cairo_script_mode_t cairo_script_get_mode (cairo_device_t *script);
177 		return cairo_script_get_mode(cairo_device);
178 	}
179 	
180 	/**
181 	 * Change the output mode of the script
182 	 * Since 1.12
183 	 * Params:
184 	 * script = The script (output device)
185 	 * mode = the new mode
186 	 */
187 	public void setMode(cairo_script_mode_t mode)
188 	{
189 		// void cairo_script_set_mode (cairo_device_t *script,  cairo_script_mode_t mode);
190 		cairo_script_set_mode(cairo_device, mode);
191 	}
192 	
193 	/**
194 	 * Emit a string verbatim into the script.
195 	 * Since 1.12
196 	 * Params:
197 	 * comment = the string to emit
198 	 */
199 	public void writeComment(string comment)
200 	{
201 		// void cairo_script_write_comment (cairo_device_t *script,  const char *comment,  int len);
202 		cairo_script_write_comment(cairo_device, cast(char*)comment.ptr, cast(int) comment.length);
203 	}
204 }