Mercurial > projects > dwt-win
diff 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 |
line wrap: on
line diff
--- a/dwt/printing/PrintDialog.d Mon May 05 00:12:38 2008 +0200 +++ b/dwt/printing/PrintDialog.d Sat May 17 17:34:28 2008 +0200 @@ -38,6 +38,7 @@ */ public class PrintDialog : Dialog { + PrinterData printerData; int scope_ = PrinterData.ALL_PAGES; int startPage = 1, endPage = 1; bool printToFile = false; @@ -97,15 +98,39 @@ } /** + * Sets the printer data that will be used when the dialog + * is opened. + * + * @param data the data that will be used when the dialog is opened + * + * @since 3.4 + */ +public void setPrinterData(PrinterData data) { + this.printerData = data; +} + +/** + * Returns the printer data that will be used when the dialog + * is opened. + * + * @return the data that will be used when the dialog is opened + * + * @since 3.4 + */ +public PrinterData getPrinterData() { + return printerData; +} + +/** * Returns the print job scope that the user selected * before pressing OK in the dialog. This will be one * of the following values: * <dl> - * <dt><code>ALL_PAGES</code></dt> + * <dt><code>PrinterData.ALL_PAGES</code></dt> * <dd>Print all pages in the current document</dd> - * <dt><code>PAGE_RANGE</code></dt> + * <dt><code>PrinterData.PAGE_RANGE</code></dt> * <dd>Print the range of pages specified by startPage and endPage</dd> - * <dt><code>SELECTION</code></dt> + * <dt><code>PrinterData.SELECTION</code></dt> * <dd>Print the current selection</dd> * </dl> * @@ -120,11 +145,11 @@ * setting when the dialog is opened. This can have one of * the following values: * <dl> - * <dt><code>ALL_PAGES</code></dt> + * <dt><code>PrinterData.ALL_PAGES</code></dt> * <dd>Print all pages in the current document</dd> - * <dt><code>PAGE_RANGE</code></dt> + * <dt><code>PrinterData.PAGE_RANGE</code></dt> * <dd>Print the range of pages specified by startPage and endPage</dd> - * <dt><code>SELECTION</code></dt> + * <dt><code>PrinterData.SELECTION</code></dt> * <dd>Print the current selection</dd> * </dl> * @@ -139,7 +164,7 @@ * before pressing OK in the dialog. * <p> * This value can be from 1 to the maximum number of pages for the platform. - * Note that it is only valid if the scope is <code>PAGE_RANGE</code>. + * Note that it is only valid if the scope is <code>PrinterData.PAGE_RANGE</code>. * </p> * * @return the start page setting that the user selected @@ -153,7 +178,7 @@ * is opened. * <p> * This value can be from 1 to the maximum number of pages for the platform. - * Note that it is only valid if the scope is <code>PAGE_RANGE</code>. + * Note that it is only valid if the scope is <code>PrinterData.PAGE_RANGE</code>. * </p> * * @param startPage the startPage setting when the dialog is opened @@ -167,7 +192,7 @@ * before pressing OK in the dialog. * <p> * This value can be from 1 to the maximum number of pages for the platform. - * Note that it is only valid if the scope is <code>PAGE_RANGE</code>. + * Note that it is only valid if the scope is <code>PrinterData.PAGE_RANGE</code>. * </p> * * @return the end page setting that the user selected @@ -181,7 +206,7 @@ * is opened. * <p> * This value can be from 1 to the maximum number of pages for the platform. - * Note that it is only valid if the scope is <code>PAGE_RANGE</code>. + * Note that it is only valid if the scope is <code>PrinterData.PAGE_RANGE</code>. * </p> * * @param endPage the end page setting when the dialog is opened @@ -234,6 +259,17 @@ pd.lStructSize = PRINTDLG.sizeof; Control parent = getParent(); if (parent !is null) pd.hwndOwner = parent.handle; + void* lpInitData; + auto hHeap = OS.GetProcessHeap(); + if (printerData !is null) { + byte buffer [] = printerData.otherData; + if (buffer !is null && buffer.length !is 0) { + /* If user setup info from a previous print dialog was specified, restore the DEVMODE struct. */ + lpInitData = OS.HeapAlloc(hHeap, OS.HEAP_ZERO_MEMORY, buffer.length); + OS.MoveMemory(lpInitData, buffer.ptr, buffer.length); + pd.hDevMode = lpInitData; + } + } pd.Flags = OS.PD_USEDEVMODECOPIESANDCOLLATE; if (printToFile) pd.Flags |= OS.PD_PRINTTOFILE; switch (scope_) { @@ -328,6 +364,7 @@ data.otherData = new byte[size]; OS.MoveMemory(data.otherData.ptr, ptr, size); OS.GlobalUnlock(hMem); + if (lpInitData !is null) OS.HeapFree(hHeap, 0, lpInitData); endPage = data.endPage; printToFile = data.printToFile;