changeset 118:10760eb00d08

Ported dwt.printing.PrinterData
author Jacob Carlborg <doob@me.com>
date Wed, 31 Dec 2008 15:51:54 +0100
parents bb00974d5ded
children d9893755f670
files dwt/printing/PrintDialog.d dwt/printing/PrinterData.d
diffstat 2 files changed, 23 insertions(+), 15 deletions(-) [+]
line wrap: on
line diff
--- 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 <doob@me.com>
  *******************************************************************************/
 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 <a href="http://www.eclipse.org/swt/examples.php">DWT Example: ControlExample, Dialog tab</a>
  * @see <a href="http://www.eclipse.org/swt/">Sample code and further information</a>
  */
-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;
     }
--- 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 <doob@me.com>
  *******************************************************************************/
 module dwt.printing.PrinterData;
 
@@ -34,7 +37,7 @@
  * @see <a href="http://www.eclipse.org/swt/">Sample code and further information</a>
  */
 
-public final class PrinterData extends DeviceData {
+public final class PrinterData : DeviceData {
     
     /**
      * the printer driver
@@ -65,7 +68,7 @@
      * <dd>Print the current selection</dd>
      * </dl>
      */
-    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$
     }
 }