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