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 = GtkPageSetup.html 27 * outPack = gtk 28 * outFile = PageSetup 29 * strct = GtkPageSetup 30 * realStrct= 31 * ctorStrct= 32 * clss = PageSetup 33 * interf = 34 * class Code: No 35 * interface Code: No 36 * template for: 37 * extend = 38 * implements: 39 * prefixes: 40 * - gtk_page_setup_ 41 * omit structs: 42 * omit prefixes: 43 * omit code: 44 * omit signals: 45 * imports: 46 * - glib.Str 47 * - glib.ErrorG 48 * - glib.GException 49 * - glib.KeyFile 50 * - gtk.PaperSize 51 * structWrap: 52 * - GKeyFile* -> KeyFile 53 * - GtkPageSetup* -> PageSetup 54 * - GtkPaperSize* -> PaperSize 55 * module aliases: 56 * local aliases: 57 * overrides: 58 */ 59 60 module gtk.PageSetup; 61 62 public import gtkc.gtktypes; 63 64 private import gtkc.gtk; 65 private import glib.ConstructionException; 66 private import gobject.ObjectG; 67 68 private import glib.Str; 69 private import glib.ErrorG; 70 private import glib.GException; 71 private import glib.KeyFile; 72 private import gtk.PaperSize; 73 74 75 private import gobject.ObjectG; 76 77 /** 78 * A GtkPageSetup object stores the page size, orientation and margins. 79 * The idea is that you can get one of these from the page setup dialog 80 * and then pass it to the GtkPrintOperation when printing. 81 * The benefit of splitting this out of the GtkPrintSettings is that 82 * these affect the actual layout of the page, and thus need to be set 83 * long before user prints. 84 * 85 * The margins specified in this object are the "print margins", i.e. the 86 * parts of the page that the printer cannot print on. These are different 87 * from the layout margins that a word processor uses; they are typically 88 * used to determine the minimal size for the layout 89 * margins. 90 * 91 * To obtain a GtkPageSetup use gtk_page_setup_new() to get the defaults, 92 * or use gtk_print_run_page_setup_dialog() to show the page setup dialog 93 * and receive the resulting page setup. 94 * 95 * $(DDOC_COMMENT example) 96 * 97 * Printing support was added in GTK+ 2.10. 98 */ 99 public class PageSetup : ObjectG 100 { 101 102 /** the main Gtk struct */ 103 protected GtkPageSetup* gtkPageSetup; 104 105 106 /** Get the main Gtk struct */ 107 public GtkPageSetup* getPageSetupStruct() 108 { 109 return gtkPageSetup; 110 } 111 112 113 /** the main Gtk struct as a void* */ 114 protected override void* getStruct() 115 { 116 return cast(void*)gtkPageSetup; 117 } 118 119 /** 120 * Sets our main struct and passes it to the parent class 121 */ 122 public this (GtkPageSetup* gtkPageSetup) 123 { 124 super(cast(GObject*)gtkPageSetup); 125 this.gtkPageSetup = gtkPageSetup; 126 } 127 128 protected override void setStruct(GObject* obj) 129 { 130 super.setStruct(obj); 131 gtkPageSetup = cast(GtkPageSetup*)obj; 132 } 133 134 /** 135 */ 136 137 /** 138 * Creates a new GtkPageSetup. 139 * Since 2.10 140 * Throws: ConstructionException GTK+ fails to create the object. 141 */ 142 public this () 143 { 144 // GtkPageSetup * gtk_page_setup_new (void); 145 auto p = gtk_page_setup_new(); 146 if(p is null) 147 { 148 throw new ConstructionException("null returned by gtk_page_setup_new()"); 149 } 150 this(cast(GtkPageSetup*) p); 151 } 152 153 /** 154 * Copies a GtkPageSetup. 155 * Since 2.10 156 * Returns: a copy of other. [transfer full] 157 */ 158 public PageSetup copy() 159 { 160 // GtkPageSetup * gtk_page_setup_copy (GtkPageSetup *other); 161 auto p = gtk_page_setup_copy(gtkPageSetup); 162 163 if(p is null) 164 { 165 return null; 166 } 167 168 return ObjectG.getDObject!(PageSetup)(cast(GtkPageSetup*) p); 169 } 170 171 /** 172 * Gets the page orientation of the GtkPageSetup. 173 * Since 2.10 174 * Returns: the page orientation 175 */ 176 public GtkPageOrientation getOrientation() 177 { 178 // GtkPageOrientation gtk_page_setup_get_orientation (GtkPageSetup *setup); 179 return gtk_page_setup_get_orientation(gtkPageSetup); 180 } 181 182 /** 183 * Sets the page orientation of the GtkPageSetup. 184 * Since 2.10 185 * Params: 186 * orientation = a GtkPageOrientation value 187 */ 188 public void setOrientation(GtkPageOrientation orientation) 189 { 190 // void gtk_page_setup_set_orientation (GtkPageSetup *setup, GtkPageOrientation orientation); 191 gtk_page_setup_set_orientation(gtkPageSetup, orientation); 192 } 193 194 /** 195 * Gets the paper size of the GtkPageSetup. 196 * Since 2.10 197 * Returns: the paper size 198 */ 199 public PaperSize getPaperSize() 200 { 201 // GtkPaperSize * gtk_page_setup_get_paper_size (GtkPageSetup *setup); 202 auto p = gtk_page_setup_get_paper_size(gtkPageSetup); 203 204 if(p is null) 205 { 206 return null; 207 } 208 209 return ObjectG.getDObject!(PaperSize)(cast(GtkPaperSize*) p); 210 } 211 212 /** 213 * Sets the paper size of the GtkPageSetup without 214 * changing the margins. See 215 * gtk_page_setup_set_paper_size_and_default_margins(). 216 * Since 2.10 217 * Params: 218 * size = a GtkPaperSize 219 */ 220 public void setPaperSize(PaperSize size) 221 { 222 // void gtk_page_setup_set_paper_size (GtkPageSetup *setup, GtkPaperSize *size); 223 gtk_page_setup_set_paper_size(gtkPageSetup, (size is null) ? null : size.getPaperSizeStruct()); 224 } 225 226 /** 227 * Gets the top margin in units of unit. 228 * Since 2.10 229 * Params: 230 * unit = the unit for the return value 231 * Returns: the top margin 232 */ 233 public double getTopMargin(GtkUnit unit) 234 { 235 // gdouble gtk_page_setup_get_top_margin (GtkPageSetup *setup, GtkUnit unit); 236 return gtk_page_setup_get_top_margin(gtkPageSetup, unit); 237 } 238 239 /** 240 * Sets the top margin of the GtkPageSetup. 241 * Since 2.10 242 * Params: 243 * margin = the new top margin in units of unit 244 * unit = the units for margin 245 */ 246 public void setTopMargin(double margin, GtkUnit unit) 247 { 248 // void gtk_page_setup_set_top_margin (GtkPageSetup *setup, gdouble margin, GtkUnit unit); 249 gtk_page_setup_set_top_margin(gtkPageSetup, margin, unit); 250 } 251 252 /** 253 * Gets the bottom margin in units of unit. 254 * Since 2.10 255 * Params: 256 * unit = the unit for the return value 257 * Returns: the bottom margin 258 */ 259 public double getBottomMargin(GtkUnit unit) 260 { 261 // gdouble gtk_page_setup_get_bottom_margin (GtkPageSetup *setup, GtkUnit unit); 262 return gtk_page_setup_get_bottom_margin(gtkPageSetup, unit); 263 } 264 265 /** 266 * Sets the bottom margin of the GtkPageSetup. 267 * Since 2.10 268 * Params: 269 * margin = the new bottom margin in units of unit 270 * unit = the units for margin 271 */ 272 public void setBottomMargin(double margin, GtkUnit unit) 273 { 274 // void gtk_page_setup_set_bottom_margin (GtkPageSetup *setup, gdouble margin, GtkUnit unit); 275 gtk_page_setup_set_bottom_margin(gtkPageSetup, margin, unit); 276 } 277 278 /** 279 * Gets the left margin in units of unit. 280 * Since 2.10 281 * Params: 282 * unit = the unit for the return value 283 * Returns: the left margin 284 */ 285 public double getLeftMargin(GtkUnit unit) 286 { 287 // gdouble gtk_page_setup_get_left_margin (GtkPageSetup *setup, GtkUnit unit); 288 return gtk_page_setup_get_left_margin(gtkPageSetup, unit); 289 } 290 291 /** 292 * Sets the left margin of the GtkPageSetup. 293 * Since 2.10 294 * Params: 295 * margin = the new left margin in units of unit 296 * unit = the units for margin 297 */ 298 public void setLeftMargin(double margin, GtkUnit unit) 299 { 300 // void gtk_page_setup_set_left_margin (GtkPageSetup *setup, gdouble margin, GtkUnit unit); 301 gtk_page_setup_set_left_margin(gtkPageSetup, margin, unit); 302 } 303 304 /** 305 * Gets the right margin in units of unit. 306 * Since 2.10 307 * Params: 308 * unit = the unit for the return value 309 * Returns: the right margin 310 */ 311 public double getRightMargin(GtkUnit unit) 312 { 313 // gdouble gtk_page_setup_get_right_margin (GtkPageSetup *setup, GtkUnit unit); 314 return gtk_page_setup_get_right_margin(gtkPageSetup, unit); 315 } 316 317 /** 318 * Sets the right margin of the GtkPageSetup. 319 * Since 2.10 320 * Params: 321 * margin = the new right margin in units of unit 322 * unit = the units for margin 323 */ 324 public void setRightMargin(double margin, GtkUnit unit) 325 { 326 // void gtk_page_setup_set_right_margin (GtkPageSetup *setup, gdouble margin, GtkUnit unit); 327 gtk_page_setup_set_right_margin(gtkPageSetup, margin, unit); 328 } 329 330 /** 331 * Sets the paper size of the GtkPageSetup and modifies 332 * the margins according to the new paper size. 333 * Since 2.10 334 * Params: 335 * size = a GtkPaperSize 336 */ 337 public void setPaperSizeAndDefaultMargins(PaperSize size) 338 { 339 // void gtk_page_setup_set_paper_size_and_default_margins (GtkPageSetup *setup, GtkPaperSize *size); 340 gtk_page_setup_set_paper_size_and_default_margins(gtkPageSetup, (size is null) ? null : size.getPaperSizeStruct()); 341 } 342 343 /** 344 * Returns the paper width in units of unit. 345 * Note that this function takes orientation, but 346 * not margins into consideration. 347 * See gtk_page_setup_get_page_width(). 348 * Since 2.10 349 * Params: 350 * unit = the unit for the return value 351 * Returns: the paper width. 352 */ 353 public double getPaperWidth(GtkUnit unit) 354 { 355 // gdouble gtk_page_setup_get_paper_width (GtkPageSetup *setup, GtkUnit unit); 356 return gtk_page_setup_get_paper_width(gtkPageSetup, unit); 357 } 358 359 /** 360 * Returns the paper height in units of unit. 361 * Note that this function takes orientation, but 362 * not margins into consideration. 363 * See gtk_page_setup_get_page_height(). 364 * Since 2.10 365 * Params: 366 * unit = the unit for the return value 367 * Returns: the paper height. 368 */ 369 public double getPaperHeight(GtkUnit unit) 370 { 371 // gdouble gtk_page_setup_get_paper_height (GtkPageSetup *setup, GtkUnit unit); 372 return gtk_page_setup_get_paper_height(gtkPageSetup, unit); 373 } 374 375 /** 376 * Returns the page width in units of unit. 377 * Note that this function takes orientation and 378 * margins into consideration. 379 * See gtk_page_setup_get_paper_width(). 380 * Since 2.10 381 * Params: 382 * unit = the unit for the return value 383 * Returns: the page width. 384 */ 385 public double getPageWidth(GtkUnit unit) 386 { 387 // gdouble gtk_page_setup_get_page_width (GtkPageSetup *setup, GtkUnit unit); 388 return gtk_page_setup_get_page_width(gtkPageSetup, unit); 389 } 390 391 /** 392 * Returns the page height in units of unit. 393 * Note that this function takes orientation and 394 * margins into consideration. 395 * See gtk_page_setup_get_paper_height(). 396 * Since 2.10 397 * Params: 398 * unit = the unit for the return value 399 * Returns: the page height. 400 */ 401 public double getPageHeight(GtkUnit unit) 402 { 403 // gdouble gtk_page_setup_get_page_height (GtkPageSetup *setup, GtkUnit unit); 404 return gtk_page_setup_get_page_height(gtkPageSetup, unit); 405 } 406 407 /** 408 * Reads the page setup from the file file_name. Returns a 409 * new GtkPageSetup object with the restored page setup, 410 * or NULL if an error occurred. See gtk_page_setup_to_file(). 411 * Since 2.12 412 * Params: 413 * fileName = the filename to read the page setup from. [type filename] 414 * Throws: GException on failure. 415 * Throws: ConstructionException GTK+ fails to create the object. 416 */ 417 public this (string fileName) 418 { 419 // GtkPageSetup * gtk_page_setup_new_from_file (const gchar *file_name, GError **error); 420 GError* err = null; 421 422 auto p = gtk_page_setup_new_from_file(Str.toStringz(fileName), &err); 423 424 if (err !is null) 425 { 426 throw new GException( new ErrorG(err) ); 427 } 428 429 if(p is null) 430 { 431 throw new ConstructionException("null returned by gtk_page_setup_new_from_file(Str.toStringz(fileName), &err)"); 432 } 433 this(cast(GtkPageSetup*) p); 434 } 435 436 /** 437 * Reads the page setup from the group group_name in the key file 438 * key_file. Returns a new GtkPageSetup object with the restored 439 * page setup, or NULL if an error occurred. 440 * Since 2.12 441 * Params: 442 * keyFile = the GKeyFile to retrieve the page_setup from 443 * groupName = the name of the group in the key_file to read, or NULL 444 * to use the default name "Page Setup". [allow-none] 445 * Throws: GException on failure. 446 * Throws: ConstructionException GTK+ fails to create the object. 447 */ 448 public this (KeyFile keyFile, string groupName) 449 { 450 // GtkPageSetup * gtk_page_setup_new_from_key_file (GKeyFile *key_file, const gchar *group_name, GError **error); 451 GError* err = null; 452 453 auto p = gtk_page_setup_new_from_key_file((keyFile is null) ? null : keyFile.getKeyFileStruct(), Str.toStringz(groupName), &err); 454 455 if (err !is null) 456 { 457 throw new GException( new ErrorG(err) ); 458 } 459 460 if(p is null) 461 { 462 throw new ConstructionException("null returned by gtk_page_setup_new_from_key_file((keyFile is null) ? null : keyFile.getKeyFileStruct(), Str.toStringz(groupName), &err)"); 463 } 464 this(cast(GtkPageSetup*) p); 465 } 466 467 /** 468 * Reads the page setup from the file file_name. 469 * See gtk_page_setup_to_file(). 470 * Since 2.14 471 * Params: 472 * fileName = the filename to read the page setup from. [type filename] 473 * Returns: TRUE on success 474 * Throws: GException on failure. 475 */ 476 public int loadFile(string fileName) 477 { 478 // gboolean gtk_page_setup_load_file (GtkPageSetup *setup, const char *file_name, GError **error); 479 GError* err = null; 480 481 auto p = gtk_page_setup_load_file(gtkPageSetup, Str.toStringz(fileName), &err); 482 483 if (err !is null) 484 { 485 throw new GException( new ErrorG(err) ); 486 } 487 488 return p; 489 } 490 491 /** 492 * Reads the page setup from the group group_name in the key file 493 * key_file. 494 * Since 2.14 495 * Params: 496 * keyFile = the GKeyFile to retrieve the page_setup from 497 * groupName = the name of the group in the key_file to read, or NULL 498 * to use the default name "Page Setup". [allow-none] 499 * Returns: TRUE on success 500 * Throws: GException on failure. 501 */ 502 public int loadKeyFile(KeyFile keyFile, string groupName) 503 { 504 // gboolean gtk_page_setup_load_key_file (GtkPageSetup *setup, GKeyFile *key_file, const gchar *group_name, GError **error); 505 GError* err = null; 506 507 auto p = gtk_page_setup_load_key_file(gtkPageSetup, (keyFile is null) ? null : keyFile.getKeyFileStruct(), Str.toStringz(groupName), &err); 508 509 if (err !is null) 510 { 511 throw new GException( new ErrorG(err) ); 512 } 513 514 return p; 515 } 516 517 /** 518 * This function saves the information from setup to file_name. 519 * Since 2.12 520 * Params: 521 * fileName = the file to save to. [type filename] 522 * Returns: TRUE on success 523 * Throws: GException on failure. 524 */ 525 public int toFile(string fileName) 526 { 527 // gboolean gtk_page_setup_to_file (GtkPageSetup *setup, const char *file_name, GError **error); 528 GError* err = null; 529 530 auto p = gtk_page_setup_to_file(gtkPageSetup, Str.toStringz(fileName), &err); 531 532 if (err !is null) 533 { 534 throw new GException( new ErrorG(err) ); 535 } 536 537 return p; 538 } 539 540 /** 541 * This function adds the page setup from setup to key_file. 542 * Since 2.12 543 * Params: 544 * keyFile = the GKeyFile to save the page setup to 545 * groupName = the group to add the settings to in key_file, 546 * or NULL to use the default name "Page Setup" 547 */ 548 public void toKeyFile(KeyFile keyFile, string groupName) 549 { 550 // void gtk_page_setup_to_key_file (GtkPageSetup *setup, GKeyFile *key_file, const gchar *group_name); 551 gtk_page_setup_to_key_file(gtkPageSetup, (keyFile is null) ? null : keyFile.getKeyFileStruct(), Str.toStringz(groupName)); 552 } 553 }