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