KickJava   Java API By Example, From Geeks To Geeks.

Java > Open Source Codes > org > eclipse > swt > printing > PrinterData


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 package org.eclipse.swt.printing;
12
13
14 import org.eclipse.swt.graphics.*;
15
16 /**
17  * Instances of this class are descriptions of a print job
18  * in terms of the printer, and the scope and type of printing
19  * that is desired. For example, the number of pages and copies
20  * can be specified, as well as whether or not the print job
21  * should go to a file.
22  * <p>
23  * Application code does <em>not</em> need to explicitly release the
24  * resources managed by each instance when those instances are no longer
25  * required, and thus no <code>dispose()</code> method is provided.
26  * </p>
27  *
28  * @see Printer
29  * @see Printer#getPrinterList
30  * @see PrintDialog#open
31  */

32
33 public final class PrinterData extends DeviceData {
34     
35     /**
36      * the printer driver
37      * On Windows systems, this is the name of the driver (often "winspool").
38      * On Mac OSX, this is the destination type ("Printer", "Fax", "File", or "Preview").
39      * On X/Window systems, this is the name of a display connection to the
40      * Xprt server (the default is ":1").
41      * On GTK+, this is the backend type name (eg. GtkPrintBackendCups).
42      */

43     // TODO: note that this api is not finalized for GTK+
44
public String JavaDoc driver;
45     
46     /**
47      * the name of the printer
48      * On Windows systems, this is the name of the 'device'.
49      * On Mac OSX, X/Window systems, and GTK+, this is the printer's 'name'.
50      */

51     public String JavaDoc name;
52     
53     /**
54      * the scope of the print job, expressed as one of the following values:
55      * <dl>
56      * <dt><code>ALL_PAGES</code></dt>
57      * <dd>Print all pages in the current document</dd>
58      * <dt><code>PAGE_RANGE</code></dt>
59      * <dd>Print the range of pages specified by startPage and endPage</dd>
60      * <dt><code>SELECTION</code></dt>
61      * <dd>Print the current selection</dd>
62      * </dl>
63      */

64     public int scope = ALL_PAGES;
65     
66     /**
67      * the start page of a page range, used when scope is PAGE_RANGE.
68      * This value can be from 1 to the maximum number of pages for the platform.
69      */

70     public int startPage = 0;
71
72     /**
73      * the end page of a page range, used when scope is PAGE_RANGE.
74      * This value can be from 1 to the maximum number of pages for the platform.
75      */

76     public int endPage = 0;
77     
78     /**
79      * whether or not the print job should go to a file
80      */

81     public boolean printToFile = false;
82     
83     /**
84      * the name of the file to print to if printToFile is true.
85      * Note that this field is ignored if printToFile is false.
86      */

87     public String JavaDoc fileName;
88     
89     /**
90      * the number of copies to print.
91      * Note that this field may be controlled by the printer driver
92      * In other words, the printer itself may be capable of printing
93      * multiple copies, and if so, the value of this field will always be 1.
94      */

95     public int copyCount = 1;
96     
97     /**
98      * whether or not the printer should collate the printed paper
99      * Note that this field may be controlled by the printer driver.
100      * In other words, the printer itself may be capable of doing the
101      * collation, and if so, the value of this field will always be false.
102      */

103     public boolean collate = false;
104     
105     /**
106      * <code>scope</code> field value indicating that
107      * all pages should be printed
108      */

109     public static final int ALL_PAGES = 0;
110     
111     /**
112      * <code>scope</code> field value indicating that
113      * the range of pages specified by startPage and endPage
114      * should be printed
115      */

116     public static final int PAGE_RANGE = 1;
117     
118     /**
119      * <code>scope</code> field value indicating that
120      * the current selection should be printed
121      */

122     public static final int SELECTION = 2;
123     
124     /**
125      * private, platform-specific data
126      * On Windows, this contains a copy of the DEVMODE struct
127      * returned from the <code>PrintDialog</code>.
128      * This field is not currently used on the X/Window System.
129      */

130     byte [] otherData;
131
132     /**
133      * Constructs an instance of this class that can be
134      * used to print to the default printer.
135      *
136      * @see Printer#getDefaultPrinterData
137      */

138     public PrinterData() {
139     }
140
141     /**
142      * Constructs an instance of this class with the given
143      * printer driver and printer name.
144      *
145      * @param driver the printer driver for the printer
146      * @param name the name of the printer
147      *
148      * @see #driver
149      * @see #name
150      */

151     public PrinterData(String JavaDoc driver, String JavaDoc name) {
152         this.driver = driver;
153         this.name = name;
154     }
155
156     /**
157      * Returns a string containing a concise, human-readable
158      * description of the receiver.
159      *
160      * @return a string representation of the receiver
161      */

162     public String JavaDoc toString() {
163         return "PrinterData {" + "driver = " + driver + ", name = " + name + "}"; //$NON-NLS-1$ //$NON-NLS-2$ //$NON-NLS-3$ //$NON-NLS-4$
164
}
165 }
166
Popular Tags