# HG changeset patch # User Jacob Carlborg # Date 1230735114 -3600 # Node ID 10760eb00d08d73bbb1e14331cd54f8a69176d82 # Parent bb00974d5ded8874a097da18f6a11ccfc80c080e Ported dwt.printing.PrinterData diff -r bb00974d5ded -r 10760eb00d08 dwt/printing/PrintDialog.d --- a/dwt/printing/PrintDialog.d Wed Dec 31 15:48:20 2008 +0100 +++ b/dwt/printing/PrintDialog.d Wed Dec 31 15:51:54 2008 +0100 @@ -7,6 +7,9 @@ * * Contributors: * IBM Corporation - initial API and implementation + * + * Port to the D programming language: + * Jacob Carlborg *******************************************************************************/ module dwt.printing.PrintDialog; @@ -27,6 +30,8 @@ import dwt.widgets.Shell; import dwt.widgets.Widget; +import dwt.printing.PrinterData; + /** * Instances of this class allow the user to select * a printer and various print-related parameters @@ -40,9 +45,9 @@ * @see DWT Example: ControlExample, Dialog tab * @see Sample code and further information */ -public class PrintDialog extends Dialog { +public class PrintDialog : Dialog { PrinterData printerData; - int scope = PrinterData.ALL_PAGES; + int scope_ = PrinterData.ALL_PAGES; int startPage = 1, endPage = 1; bool printToFile = false; @@ -63,7 +68,7 @@ * @see Widget#checkSubclass * @see Widget#getStyle */ -public PrintDialog (Shell parent) { +public this (Shell parent) { this (parent, DWT.PRIMARY_MODAL); } @@ -95,7 +100,7 @@ * @see Widget#checkSubclass * @see Widget#getStyle */ -public PrintDialog (Shell parent, int style) { +public this (Shell parent, int style) { super (parent, style); checkSubclass (); } @@ -144,8 +149,8 @@ dict.setValue(OS.NSPrintSaveJob, OS.NSPrintJobDisposition); } //TODO - setting range not work. why? - dict.setValue(NSNumber.numberWithBool(scope is PrinterData.ALL_PAGES), OS.NSPrintAllPages); - if (scope is PrinterData.PAGE_RANGE) { + dict.setValue(NSNumber.numberWithBool(scope_ is PrinterData.ALL_PAGES), OS.NSPrintAllPages); + if (scope_ is PrinterData.PAGE_RANGE) { dict.setValue(NSNumber.numberWithInt(startPage), OS.NSPrintFirstPage); dict.setValue(NSNumber.numberWithInt(endPage), OS.NSPrintLastPage); } @@ -159,19 +164,19 @@ NSString filename = new NSString(dict.objectForKey(OS.NSPrintSavePath)); data.fileName = filename.getString(); } - data.scope = new NSNumber(dict.objectForKey(OS.NSPrintAllPages)).intValue() !is 0 ? PrinterData.ALL_PAGES : PrinterData.PAGE_RANGE; - if (data.scope is PrinterData.PAGE_RANGE) { + data.scope_ = new NSNumber(dict.objectForKey(OS.NSPrintAllPages)).intValue() !is 0 ? PrinterData.ALL_PAGES : PrinterData.PAGE_RANGE; + if (data.scope_ is PrinterData.PAGE_RANGE) { data.startPage = new NSNumber(dict.objectForKey(OS.NSPrintFirstPage)).intValue(); data.endPage = new NSNumber(dict.objectForKey(OS.NSPrintLastPage)).intValue(); } data.collate = new NSNumber(dict.objectForKey(OS.NSPrintMustCollate)).intValue() !is 0; data.copyCount = new NSNumber(dict.objectForKey(OS.NSPrintCopies)).intValue(); NSData nsData = NSKeyedArchiver.archivedDataWithRootObject(printInfo); - data.otherData = new byte[(int)/*64*/nsData.length()]; + data.otherData = new byte[nsData.length()]; OS.memmove(data.otherData, nsData.bytes(), data.otherData.length); printToFile = data.printToFile; - scope = data.scope; + scope_ = data.scope_; startPage = data.startPage; endPage = data.endPage; } diff -r bb00974d5ded -r 10760eb00d08 dwt/printing/PrinterData.d --- a/dwt/printing/PrinterData.d Wed Dec 31 15:48:20 2008 +0100 +++ b/dwt/printing/PrinterData.d Wed Dec 31 15:51:54 2008 +0100 @@ -7,6 +7,9 @@ * * Contributors: * IBM Corporation - initial API and implementation + * + * Port to the D programming language: + * Jacob Carlborg *******************************************************************************/ module dwt.printing.PrinterData; @@ -34,7 +37,7 @@ * @see Sample code and further information */ -public final class PrinterData extends DeviceData { +public final class PrinterData : DeviceData { /** * the printer driver @@ -65,7 +68,7 @@ *
Print the current selection
* */ - public int scope = ALL_PAGES; + public int scope_ = ALL_PAGES; /** * the start page of a page range, used when scope is PAGE_RANGE. @@ -143,7 +146,7 @@ * * @see Printer#getDefaultPrinterData */ - public PrinterData() { + public this() { } /** @@ -156,7 +159,7 @@ * @see #driver * @see #name */ - public PrinterData(String driver, String name) { + public this(String driver, String name) { this.driver = driver; this.name = name; } @@ -168,6 +171,6 @@ * @return a string representation of the receiver */ public String toString() { - return "PrinterData {" + "driver = " + driver + ", name = " + name + "}"; //$NON-NLS-1$ //$NON-NLS-2$ //$NON-NLS-3$ //$NON-NLS-4$ + return "PrinterData {" ~ "driver = " ~ driver ~ ", name = " ~ name ~ "}"; //$NON-NLS-1$ //$NON-NLS-2$ //$NON-NLS-3$ //$NON-NLS-4$ } }