comparison dwt/printing/PrintDialog.d @ 213:36f5cb12e1a2

Update to SWT 3.4M7
author Frank Benoit <benoit@tionex.de>
date Sat, 17 May 2008 17:34:28 +0200
parents ab60f3309436
children fd9c62a2998e
comparison
equal deleted inserted replaced
212:ab60f3309436 213:36f5cb12e1a2
36 * within the DWT implementation. 36 * within the DWT implementation.
37 * </p> 37 * </p>
38 */ 38 */
39 39
40 public class PrintDialog : Dialog { 40 public class PrintDialog : Dialog {
41 PrinterData printerData;
41 int scope_ = PrinterData.ALL_PAGES; 42 int scope_ = PrinterData.ALL_PAGES;
42 int startPage = 1, endPage = 1; 43 int startPage = 1, endPage = 1;
43 bool printToFile = false; 44 bool printToFile = false;
44 45
45 /** 46 /**
95 super (parent, style); 96 super (parent, style);
96 checkSubclass (); 97 checkSubclass ();
97 } 98 }
98 99
99 /** 100 /**
101 * Sets the printer data that will be used when the dialog
102 * is opened.
103 *
104 * @param data the data that will be used when the dialog is opened
105 *
106 * @since 3.4
107 */
108 public void setPrinterData(PrinterData data) {
109 this.printerData = data;
110 }
111
112 /**
113 * Returns the printer data that will be used when the dialog
114 * is opened.
115 *
116 * @return the data that will be used when the dialog is opened
117 *
118 * @since 3.4
119 */
120 public PrinterData getPrinterData() {
121 return printerData;
122 }
123
124 /**
100 * Returns the print job scope that the user selected 125 * Returns the print job scope that the user selected
101 * before pressing OK in the dialog. This will be one 126 * before pressing OK in the dialog. This will be one
102 * of the following values: 127 * of the following values:
103 * <dl> 128 * <dl>
104 * <dt><code>ALL_PAGES</code></dt> 129 * <dt><code>PrinterData.ALL_PAGES</code></dt>
105 * <dd>Print all pages in the current document</dd> 130 * <dd>Print all pages in the current document</dd>
106 * <dt><code>PAGE_RANGE</code></dt> 131 * <dt><code>PrinterData.PAGE_RANGE</code></dt>
107 * <dd>Print the range of pages specified by startPage and endPage</dd> 132 * <dd>Print the range of pages specified by startPage and endPage</dd>
108 * <dt><code>SELECTION</code></dt> 133 * <dt><code>PrinterData.SELECTION</code></dt>
109 * <dd>Print the current selection</dd> 134 * <dd>Print the current selection</dd>
110 * </dl> 135 * </dl>
111 * 136 *
112 * @return the scope setting that the user selected 137 * @return the scope setting that the user selected
113 */ 138 */
118 /** 143 /**
119 * Sets the scope of the print job. The user will see this 144 * Sets the scope of the print job. The user will see this
120 * setting when the dialog is opened. This can have one of 145 * setting when the dialog is opened. This can have one of
121 * the following values: 146 * the following values:
122 * <dl> 147 * <dl>
123 * <dt><code>ALL_PAGES</code></dt> 148 * <dt><code>PrinterData.ALL_PAGES</code></dt>
124 * <dd>Print all pages in the current document</dd> 149 * <dd>Print all pages in the current document</dd>
125 * <dt><code>PAGE_RANGE</code></dt> 150 * <dt><code>PrinterData.PAGE_RANGE</code></dt>
126 * <dd>Print the range of pages specified by startPage and endPage</dd> 151 * <dd>Print the range of pages specified by startPage and endPage</dd>
127 * <dt><code>SELECTION</code></dt> 152 * <dt><code>PrinterData.SELECTION</code></dt>
128 * <dd>Print the current selection</dd> 153 * <dd>Print the current selection</dd>
129 * </dl> 154 * </dl>
130 * 155 *
131 * @param scope the scope setting when the dialog is opened 156 * @param scope the scope setting when the dialog is opened
132 */ 157 */
137 /** 162 /**
138 * Returns the start page setting that the user selected 163 * Returns the start page setting that the user selected
139 * before pressing OK in the dialog. 164 * before pressing OK in the dialog.
140 * <p> 165 * <p>
141 * This value can be from 1 to the maximum number of pages for the platform. 166 * This value can be from 1 to the maximum number of pages for the platform.
142 * Note that it is only valid if the scope is <code>PAGE_RANGE</code>. 167 * Note that it is only valid if the scope is <code>PrinterData.PAGE_RANGE</code>.
143 * </p> 168 * </p>
144 * 169 *
145 * @return the start page setting that the user selected 170 * @return the start page setting that the user selected
146 */ 171 */
147 public int getStartPage() { 172 public int getStartPage() {
151 /** 176 /**
152 * Sets the start page that the user will see when the dialog 177 * Sets the start page that the user will see when the dialog
153 * is opened. 178 * is opened.
154 * <p> 179 * <p>
155 * This value can be from 1 to the maximum number of pages for the platform. 180 * This value can be from 1 to the maximum number of pages for the platform.
156 * Note that it is only valid if the scope is <code>PAGE_RANGE</code>. 181 * Note that it is only valid if the scope is <code>PrinterData.PAGE_RANGE</code>.
157 * </p> 182 * </p>
158 * 183 *
159 * @param startPage the startPage setting when the dialog is opened 184 * @param startPage the startPage setting when the dialog is opened
160 */ 185 */
161 public void setStartPage(int startPage) { 186 public void setStartPage(int startPage) {
165 /** 190 /**
166 * Returns the end page setting that the user selected 191 * Returns the end page setting that the user selected
167 * before pressing OK in the dialog. 192 * before pressing OK in the dialog.
168 * <p> 193 * <p>
169 * This value can be from 1 to the maximum number of pages for the platform. 194 * This value can be from 1 to the maximum number of pages for the platform.
170 * Note that it is only valid if the scope is <code>PAGE_RANGE</code>. 195 * Note that it is only valid if the scope is <code>PrinterData.PAGE_RANGE</code>.
171 * </p> 196 * </p>
172 * 197 *
173 * @return the end page setting that the user selected 198 * @return the end page setting that the user selected
174 */ 199 */
175 public int getEndPage() { 200 public int getEndPage() {
179 /** 204 /**
180 * Sets the end page that the user will see when the dialog 205 * Sets the end page that the user will see when the dialog
181 * is opened. 206 * is opened.
182 * <p> 207 * <p>
183 * This value can be from 1 to the maximum number of pages for the platform. 208 * This value can be from 1 to the maximum number of pages for the platform.
184 * Note that it is only valid if the scope is <code>PAGE_RANGE</code>. 209 * Note that it is only valid if the scope is <code>PrinterData.PAGE_RANGE</code>.
185 * </p> 210 * </p>
186 * 211 *
187 * @param endPage the end page setting when the dialog is opened 212 * @param endPage the end page setting when the dialog is opened
188 */ 213 */
189 public void setEndPage(int endPage) { 214 public void setEndPage(int endPage) {
232 public PrinterData open() { 257 public PrinterData open() {
233 PRINTDLG pd; 258 PRINTDLG pd;
234 pd.lStructSize = PRINTDLG.sizeof; 259 pd.lStructSize = PRINTDLG.sizeof;
235 Control parent = getParent(); 260 Control parent = getParent();
236 if (parent !is null) pd.hwndOwner = parent.handle; 261 if (parent !is null) pd.hwndOwner = parent.handle;
262 void* lpInitData;
263 auto hHeap = OS.GetProcessHeap();
264 if (printerData !is null) {
265 byte buffer [] = printerData.otherData;
266 if (buffer !is null && buffer.length !is 0) {
267 /* If user setup info from a previous print dialog was specified, restore the DEVMODE struct. */
268 lpInitData = OS.HeapAlloc(hHeap, OS.HEAP_ZERO_MEMORY, buffer.length);
269 OS.MoveMemory(lpInitData, buffer.ptr, buffer.length);
270 pd.hDevMode = lpInitData;
271 }
272 }
237 pd.Flags = OS.PD_USEDEVMODECOPIESANDCOLLATE; 273 pd.Flags = OS.PD_USEDEVMODECOPIESANDCOLLATE;
238 if (printToFile) pd.Flags |= OS.PD_PRINTTOFILE; 274 if (printToFile) pd.Flags |= OS.PD_PRINTTOFILE;
239 switch (scope_) { 275 switch (scope_) {
240 case PrinterData.PAGE_RANGE: pd.Flags |= OS.PD_PAGENUMS; break; 276 case PrinterData.PAGE_RANGE: pd.Flags |= OS.PD_PAGENUMS; break;
241 case PrinterData.SELECTION: pd.Flags |= OS.PD_SELECTION; break; 277 case PrinterData.SELECTION: pd.Flags |= OS.PD_SELECTION; break;
326 size = OS.GlobalSize(hMem); 362 size = OS.GlobalSize(hMem);
327 ptr = OS.GlobalLock(hMem); 363 ptr = OS.GlobalLock(hMem);
328 data.otherData = new byte[size]; 364 data.otherData = new byte[size];
329 OS.MoveMemory(data.otherData.ptr, ptr, size); 365 OS.MoveMemory(data.otherData.ptr, ptr, size);
330 OS.GlobalUnlock(hMem); 366 OS.GlobalUnlock(hMem);
367 if (lpInitData !is null) OS.HeapFree(hHeap, 0, lpInitData);
331 368
332 endPage = data.endPage; 369 endPage = data.endPage;
333 printToFile = data.printToFile; 370 printToFile = data.printToFile;
334 scope_ = data.scope_; 371 scope_ = data.scope_;
335 startPage = data.startPage; 372 startPage = data.startPage;