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