Mercurial > projects > dwt-linux
annotate dwt/printing/PrinterData.d @ 240:ce446666f5a2
Update to SWT 3.4M7
author | Frank Benoit <benoit@tionex.de> |
---|---|
date | Mon, 12 May 2008 19:13:01 +0200 |
parents | 380bad9f6852 |
children | c0d810de7093 |
rev | line source |
---|---|
150
f2e04420fd6c
reworked overrides and superclass aliases
Frank Benoit <benoit@tionex.de>
parents:
108
diff
changeset
|
1 /******************************************************************************* |
91 | 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 | |
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 | |
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+ | |
238 | 51 public String driver; |
91 | 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 */ | |
238 | 58 public String name; |
91 | 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 */ | |
238 | 94 public String fileName; |
91 | 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>. | |
240 | 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>. | |
91 | 139 * This field is not currently used on the X/Window System. |
140 */ | |
141 char [] 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 */ | |
238 | 162 public this(String driver, String name) { |
91 | 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 */ | |
238 | 173 public override String toString() { |
91 | 174 return Format( "PrinterData {{driver = {}, name = {}}", driver, name ); //$NON-NLS-1$ //$NON-NLS-2$ //$NON-NLS-3$ //$NON-NLS-4$ |
175 } | |
176 } |