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  = GtkPrintContext.html
27  * outPack = gtk
28  * outFile = PrintContext
29  * strct   = GtkPrintContext
30  * realStrct=
31  * ctorStrct=
32  * clss    = PrintContext
33  * interf  = 
34  * class Code: No
35  * interface Code: No
36  * template for:
37  * extend  = 
38  * implements:
39  * prefixes:
40  * 	- gtk_print_context_
41  * omit structs:
42  * omit prefixes:
43  * omit code:
44  * omit signals:
45  * imports:
46  * 	- cairo.Context
47  * 	- pango.PgContext
48  * 	- pango.PgLayout
49  * 	- pango.PgFontMap
50  * 	- gtk.PageSetup
51  * structWrap:
52  * 	- GtkPageSetup* -> PageSetup
53  * 	- PangoContext* -> PgContext
54  * 	- PangoFontMap* -> PgFontMap
55  * 	- PangoLayout* -> PgLayout
56  * 	- cairo_t* -> Context
57  * module aliases:
58  * local aliases:
59  * overrides:
60  */
61 
62 module gtk.PrintContext;
63 
64 public  import gtkc.gtktypes;
65 
66 private import gtkc.gtk;
67 private import glib.ConstructionException;
68 private import gobject.ObjectG;
69 
70 private import cairo.Context;
71 private import pango.PgContext;
72 private import pango.PgLayout;
73 private import pango.PgFontMap;
74 private import gtk.PageSetup;
75 
76 
77 private import gobject.ObjectG;
78 
79 /**
80  * A GtkPrintContext encapsulates context information that is required when
81  * drawing pages for printing, such as the cairo context and important
82  * parameters like page size and resolution. It also lets you easily
83  * create PangoLayout and PangoContext objects that match the font metrics
84  * of the cairo surface.
85  *
86  * GtkPrintContext objects gets passed to the "begin-print",
87  * "end-print", "request-page-setup" and
88  * "draw-page" signals on the GtkPrintOperation.
89  *
90  * $(DDOC_COMMENT example)
91  *
92  * Printing support was added in GTK+ 2.10.
93  */
94 public class PrintContext : ObjectG
95 {
96 	
97 	/** the main Gtk struct */
98 	protected GtkPrintContext* gtkPrintContext;
99 	
100 	
101 	/** Get the main Gtk struct */
102 	public GtkPrintContext* getPrintContextStruct()
103 	{
104 		return gtkPrintContext;
105 	}
106 	
107 	
108 	/** the main Gtk struct as a void* */
109 	protected override void* getStruct()
110 	{
111 		return cast(void*)gtkPrintContext;
112 	}
113 	
114 	/**
115 	 * Sets our main struct and passes it to the parent class
116 	 */
117 	public this (GtkPrintContext* gtkPrintContext)
118 	{
119 		super(cast(GObject*)gtkPrintContext);
120 		this.gtkPrintContext = gtkPrintContext;
121 	}
122 	
123 	protected override void setStruct(GObject* obj)
124 	{
125 		super.setStruct(obj);
126 		gtkPrintContext = cast(GtkPrintContext*)obj;
127 	}
128 	
129 	/**
130 	 */
131 	
132 	/**
133 	 * Obtains the cairo context that is associated with the
134 	 * GtkPrintContext.
135 	 * Since 2.10
136 	 * Returns: the cairo context of context. [transfer none]
137 	 */
138 	public Context getCairoContext()
139 	{
140 		// cairo_t * gtk_print_context_get_cairo_context (GtkPrintContext *context);
141 		auto p = gtk_print_context_get_cairo_context(gtkPrintContext);
142 		
143 		if(p is null)
144 		{
145 			return null;
146 		}
147 		
148 		return ObjectG.getDObject!(Context)(cast(cairo_t*) p);
149 	}
150 	
151 	/**
152 	 * Sets a new cairo context on a print context.
153 	 * This function is intended to be used when implementing
154 	 * an internal print preview, it is not needed for printing,
155 	 * since GTK+ itself creates a suitable cairo context in that
156 	 * case.
157 	 * Since 2.10
158 	 * Params:
159 	 * cr = the cairo context
160 	 * dpiX = the horizontal resolution to use with cr
161 	 * dpiY = the vertical resolution to use with cr
162 	 */
163 	public void setCairoContext(Context cr, double dpiX, double dpiY)
164 	{
165 		// void gtk_print_context_set_cairo_context (GtkPrintContext *context,  cairo_t *cr,  double dpi_x,  double dpi_y);
166 		gtk_print_context_set_cairo_context(gtkPrintContext, (cr is null) ? null : cr.getContextStruct(), dpiX, dpiY);
167 	}
168 	
169 	/**
170 	 * Obtains the GtkPageSetup that determines the page
171 	 * dimensions of the GtkPrintContext.
172 	 * Since 2.10
173 	 * Returns: the page setup of context. [transfer none]
174 	 */
175 	public PageSetup getPageSetup()
176 	{
177 		// GtkPageSetup * gtk_print_context_get_page_setup (GtkPrintContext *context);
178 		auto p = gtk_print_context_get_page_setup(gtkPrintContext);
179 		
180 		if(p is null)
181 		{
182 			return null;
183 		}
184 		
185 		return ObjectG.getDObject!(PageSetup)(cast(GtkPageSetup*) p);
186 	}
187 	
188 	/**
189 	 * Obtains the width of the GtkPrintContext, in pixels.
190 	 * Since 2.10
191 	 * Returns: the width of context
192 	 */
193 	public double getWidth()
194 	{
195 		// gdouble gtk_print_context_get_width (GtkPrintContext *context);
196 		return gtk_print_context_get_width(gtkPrintContext);
197 	}
198 	
199 	/**
200 	 * Obtains the height of the GtkPrintContext, in pixels.
201 	 * Since 2.10
202 	 * Returns: the height of context
203 	 */
204 	public double getHeight()
205 	{
206 		// gdouble gtk_print_context_get_height (GtkPrintContext *context);
207 		return gtk_print_context_get_height(gtkPrintContext);
208 	}
209 	
210 	/**
211 	 * Obtains the horizontal resolution of the GtkPrintContext,
212 	 * in dots per inch.
213 	 * Since 2.10
214 	 * Returns: the horizontal resolution of context
215 	 */
216 	public double getDpiX()
217 	{
218 		// gdouble gtk_print_context_get_dpi_x (GtkPrintContext *context);
219 		return gtk_print_context_get_dpi_x(gtkPrintContext);
220 	}
221 	
222 	/**
223 	 * Obtains the vertical resolution of the GtkPrintContext,
224 	 * in dots per inch.
225 	 * Since 2.10
226 	 * Returns: the vertical resolution of context
227 	 */
228 	public double getDpiY()
229 	{
230 		// gdouble gtk_print_context_get_dpi_y (GtkPrintContext *context);
231 		return gtk_print_context_get_dpi_y(gtkPrintContext);
232 	}
233 	
234 	/**
235 	 * Returns a PangoFontMap that is suitable for use
236 	 * with the GtkPrintContext.
237 	 * Since 2.10
238 	 * Returns: the font map of context. [transfer none]
239 	 */
240 	public PgFontMap getPangoFontmap()
241 	{
242 		// PangoFontMap * gtk_print_context_get_pango_fontmap (GtkPrintContext *context);
243 		auto p = gtk_print_context_get_pango_fontmap(gtkPrintContext);
244 		
245 		if(p is null)
246 		{
247 			return null;
248 		}
249 		
250 		return ObjectG.getDObject!(PgFontMap)(cast(PangoFontMap*) p);
251 	}
252 	
253 	/**
254 	 * Creates a new PangoContext that can be used with the
255 	 * GtkPrintContext.
256 	 * Since 2.10
257 	 * Returns: a new Pango context for context. [transfer full]
258 	 */
259 	public PgContext createPangoContext()
260 	{
261 		// PangoContext * gtk_print_context_create_pango_context  (GtkPrintContext *context);
262 		auto p = gtk_print_context_create_pango_context(gtkPrintContext);
263 		
264 		if(p is null)
265 		{
266 			return null;
267 		}
268 		
269 		return ObjectG.getDObject!(PgContext)(cast(PangoContext*) p);
270 	}
271 	
272 	/**
273 	 * Creates a new PangoLayout that is suitable for use
274 	 * with the GtkPrintContext.
275 	 * Since 2.10
276 	 * Returns: a new Pango layout for context. [transfer full]
277 	 */
278 	public PgLayout createPangoLayout()
279 	{
280 		// PangoLayout * gtk_print_context_create_pango_layout  (GtkPrintContext *context);
281 		auto p = gtk_print_context_create_pango_layout(gtkPrintContext);
282 		
283 		if(p is null)
284 		{
285 			return null;
286 		}
287 		
288 		return ObjectG.getDObject!(PgLayout)(cast(PangoLayout*) p);
289 	}
290 	
291 	/**
292 	 * Obtains the hardware printer margins of the GtkPrintContext, in units.
293 	 * Since 2.20
294 	 * Params:
295 	 * top = top hardware printer margin. [out]
296 	 * bottom = bottom hardware printer margin. [out]
297 	 * left = left hardware printer margin. [out]
298 	 * right = right hardware printer margin. [out]
299 	 * Returns: TRUE if the hard margins were retrieved
300 	 */
301 	public int getHardMargins(out double top, out double bottom, out double left, out double right)
302 	{
303 		// gboolean gtk_print_context_get_hard_margins (GtkPrintContext *context,  gdouble *top,  gdouble *bottom,  gdouble *left,  gdouble *right);
304 		return gtk_print_context_get_hard_margins(gtkPrintContext, &top, &bottom, &left, &right);
305 	}
306 }