1 /******************************************************************************* 2 * Copyright (c) 2000, 2008 IBM Corporation and others. 3 * All rights reserved. This program and the accompanying materials 4 * are made available under the terms of the Eclipse Public License v1.0 5 * which accompanies this distribution, and is available at 6 * http://www.eclipse.org/legal/epl-v10.html 7 * 8 * Contributors: 9 * IBM Corporation - initial API and implementation 10 * Port to the D programming language: 11 * Frank Benoit <benoit@tionex.de> 12 *******************************************************************************/ 13 module org.eclipse.swt.printing.PrinterData; 14 15 import java.lang.all; 16 17 18 import org.eclipse.swt.graphics.DeviceData; 19 20 21 22 /** 23 * Instances of this class are descriptions of a print job 24 * in terms of the printer, and the scope and type of printing 25 * that is desired. For example, the number of pages and copies 26 * can be specified, as well as whether or not the print job 27 * should go to a file. 28 * <p> 29 * Application code does <em>not</em> need to explicitly release the 30 * resources managed by each instance when those instances are no longer 31 * required, and thus no <code>dispose()</code> method is provided. 32 * </p> 33 * 34 * @see Printer 35 * @see Printer#getPrinterList 36 * @see PrintDialog#open 37 * @see <a href="http://www.eclipse.org/swt/snippets/#printing">Printing snippets</a> 38 * @see <a href="http://www.eclipse.org/swt/">Sample code and further information</a> 39 */ 40 41 public final class PrinterData : DeviceData { 42 43 /** 44 * the printer driver 45 * On Windows systems, this is the name of the driver (often "winspool"). 46 * On Mac OSX, this is the destination type ("Printer", "Fax", "File", or "Preview"). 47 * On X/Window systems, this is the name of a display connection to the 48 * Xprt server (the default is ":1"). 49 * On GTK+, this is the backend type name (eg. GtkPrintBackendCups). 50 */ 51 // TODO: note that this api is not finalized for GTK+ 52 public String driver; 53 54 /** 55 * the name of the printer 56 * On Windows systems, this is the name of the 'device'. 57 * On Mac OSX, X/Window systems, and GTK+, this is the printer's 'name'. 58 */ 59 public String name; 60 61 /** 62 * the scope of the print job, expressed as one of the following values: 63 * <dl> 64 * <dt><code>ALL_PAGES</code></dt> 65 * <dd>Print all pages in the current document</dd> 66 * <dt><code>PAGE_RANGE</code></dt> 67 * <dd>Print the range of pages specified by startPage and endPage</dd> 68 * <dt><code>SELECTION</code></dt> 69 * <dd>Print the current selection</dd> 70 * </dl> 71 */ 72 public int scope_ = ALL_PAGES; 73 74 /** 75 * the start page of a page range, used when scope is PAGE_RANGE. 76 * This value can be from 1 to the maximum number of pages for the platform. 77 */ 78 public int startPage = 0; 79 80 /** 81 * the end page of a page range, used when scope is PAGE_RANGE. 82 * This value can be from 1 to the maximum number of pages for the platform. 83 */ 84 public int endPage = 0; 85 86 /** 87 * whether or not the print job should go to a file 88 */ 89 public bool printToFile = false; 90 91 /** 92 * the name of the file to print to if printToFile is true. 93 * Note that this field is ignored if printToFile is false. 94 */ 95 public String fileName; 96 97 /** 98 * the number of copies to print. 99 * Note that this field may be controlled by the printer driver 100 * In other words, the printer itself may be capable of printing 101 * multiple copies, and if so, the value of this field will always be 1. 102 */ 103 public int copyCount = 1; 104 105 /** 106 * whether or not the printer should collate the printed paper 107 * Note that this field may be controlled by the printer driver. 108 * In other words, the printer itself may be capable of doing the 109 * collation, and if so, the value of this field will always be false. 110 */ 111 public bool collate = false; 112 113 /** 114 * <code>scope</code> field value indicating that 115 * all pages should be printed 116 */ 117 public static const int ALL_PAGES = 0; 118 119 /** 120 * <code>scope</code> field value indicating that 121 * the range of pages specified by startPage and endPage 122 * should be printed 123 */ 124 public static const int PAGE_RANGE = 1; 125 126 /** 127 * <code>scope</code> field value indicating that 128 * the current selection should be printed 129 */ 130 public static const int SELECTION = 2; 131 132 /** 133 * private, platform-specific data 134 * On Windows, this contains a copy of the DEVMODE struct 135 * returned from the <code>PrintDialog</code>. 136 * On GTK, this contains a copy of the print_settings and page_setup 137 * returned from the <code>PrintDialog</code>. 138 * On OS X Carbon, this contains a copy of the PrintSettings and PageFormat 139 * returned from the <code>PrintDialog</code>. 140 * This field is not currently used on the X/Window System. 141 */ 142 char [] otherData; 143 144 /** 145 * Constructs an instance of this class that can be 146 * used to print to the default printer. 147 * 148 * @see Printer#getDefaultPrinterData 149 */ 150 public this() { 151 } 152 153 /** 154 * Constructs an instance of this class with the given 155 * printer driver and printer name. 156 * 157 * @param driver the printer driver for the printer 158 * @param name the name of the printer 159 * 160 * @see #driver 161 * @see #name 162 */ 163 public this(String driver, String name) { 164 this.driver = driver; 165 this.name = name; 166 } 167 168 /** 169 * Returns a string containing a concise, human-readable 170 * description of the receiver. 171 * 172 * @return a string representation of the receiver 173 */ 174 public override String toString() { 175 return Format( "PrinterData {{driver = {}, name = {}}", driver, name ); //$NON-NLS-1$ //$NON-NLS-2$ //$NON-NLS-3$ //$NON-NLS-4$ 176 } 177 }