root/dwt/printing/PrinterData.d

Revision 246:fd9c62a2998e, 5.8 kB (checked in by Frank Benoit <benoit@tionex.de>, 5 months ago)

Updater SWT 3.4M7 to 3.4

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