comparison dwt/printing/PrinterData.d @ 0:380af2bdd8e5

Upload of whole dwt tree
author Jacob Carlborg <doob@me.com> <jacob.carlborg@gmail.com>
date Sat, 09 Aug 2008 17:00:02 +0200
parents
children 649b8e223d5a
comparison
equal deleted inserted replaced
-1:000000000000 0:380af2bdd8e5
1 /*******************************************************************************
2 * Copyright (c) 2000, 2006 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 *******************************************************************************/
11 module dwt.printing.PrinterData;
12
13 import dwt.dwthelper.utils;
14
15
16 import dwt.graphics.DeviceData;
17
18 /**
19 * Instances of this class are descriptions of a print job
20 * in terms of the printer, and the scope and type of printing
21 * that is desired. For example, the number of pages and copies
22 * can be specified, as well as whether or not the print job
23 * should go to a file.
24 * <p>
25 * Application code does <em>not</em> need to explicitly release the
26 * resources managed by each instance when those instances are no longer
27 * required, and thus no <code>dispose()</code> method is provided.
28 * </p>
29 *
30 * @see Printer
31 * @see Printer#getPrinterList
32 * @see PrintDialog#open
33 */
34
35 public final class PrinterData extends DeviceData {
36
37 /**
38 * the printer driver
39 * On Windows systems, this is the name of the driver (often "winspool").
40 * On Mac OSX, this is the destination type ("Printer", "Fax", "File", or "Preview").
41 * On X/Window systems, this is the name of a display connection to the
42 * Xprt server (the default is ":1").
43 * On GTK+, this is the backend type name (eg. GtkPrintBackendCups).
44 */
45 // TODO: note that this api is not finalized for GTK+
46 public String driver;
47
48 /**
49 * the name of the printer
50 * On Windows systems, this is the name of the 'device'.
51 * On Mac OSX, X/Window systems, and GTK+, this is the printer's 'name'.
52 */
53 public String name;
54
55 /**
56 * the scope of the print job, expressed as one of the following values:
57 * <dl>
58 * <dt><code>ALL_PAGES</code></dt>
59 * <dd>Print all pages in the current document</dd>
60 * <dt><code>PAGE_RANGE</code></dt>
61 * <dd>Print the range of pages specified by startPage and endPage</dd>
62 * <dt><code>SELECTION</code></dt>
63 * <dd>Print the current selection</dd>
64 * </dl>
65 */
66 public int scope = ALL_PAGES;
67
68 /**
69 * the start page of a page range, used when scope is PAGE_RANGE.
70 * This value can be from 1 to the maximum number of pages for the platform.
71 */
72 public int startPage = 0;
73
74 /**
75 * the end 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 endPage = 0;
79
80 /**
81 * whether or not the print job should go to a file
82 */
83 public bool printToFile = false;
84
85 /**
86 * the name of the file to print to if printToFile is true.
87 * Note that this field is ignored if printToFile is false.
88 */
89 public String fileName;
90
91 /**
92 * the number of copies to print.
93 * Note that this field may be controlled by the printer driver
94 * In other words, the printer itself may be capable of printing
95 * multiple copies, and if so, the value of this field will always be 1.
96 */
97 public int copyCount = 1;
98
99 /**
100 * whether or not the printer should collate the printed paper
101 * Note that this field may be controlled by the printer driver.
102 * In other words, the printer itself may be capable of doing the
103 * collation, and if so, the value of this field will always be false.
104 */
105 public bool collate = false;
106
107 /**
108 * <code>scope</code> field value indicating that
109 * all pages should be printed
110 */
111 public static final int ALL_PAGES = 0;
112
113 /**
114 * <code>scope</code> field value indicating that
115 * the range of pages specified by startPage and endPage
116 * should be printed
117 */
118 public static final int PAGE_RANGE = 1;
119
120 /**
121 * <code>scope</code> field value indicating that
122 * the current selection should be printed
123 */
124 public static final int SELECTION = 2;
125
126 /**
127 * private, platform-specific data
128 * On Windows, this contains a copy of the DEVMODE struct
129 * returned from the <code>PrintDialog</code>.
130 * On GTK, this contains a copy of the print_settings and page_setup
131 * returned from the <code>PrintDialog</code>.
132 * On OS X Carbon, this contains a copy of the PrintSettings and PageFormat
133 * returned from the <code>PrintDialog</code>.
134 * This field is not currently used on the X/Window System.
135 */
136 byte [] otherData;
137
138 /**
139 * Constructs an instance of this class that can be
140 * used to print to the default printer.
141 *
142 * @see Printer#getDefaultPrinterData
143 */
144 public PrinterData() {
145 }
146
147 /**
148 * Constructs an instance of this class with the given
149 * printer driver and printer name.
150 *
151 * @param driver the printer driver for the printer
152 * @param name the name of the printer
153 *
154 * @see #driver
155 * @see #name
156 */
157 public PrinterData(String driver, String name) {
158 this.driver = driver;
159 this.name = name;
160 }
161
162 /**
163 * Returns a string containing a concise, human-readable
164 * description of the receiver.
165 *
166 * @return a string representation of the receiver
167 */
168 public String toString() {
169 return "PrinterData {" + "driver = " + driver + ", name = " + name + "}"; //$NON-NLS-1$ //$NON-NLS-2$ //$NON-NLS-3$ //$NON-NLS-4$
170 }
171 }