page setup action for xpad
Sylvestre Koumar [Mon, 21 Sep 2009 12:22:48 +0000 (14:22 +0200)]
scilab/modules/xpad/src/java/org/scilab/modules/xpad/actions/PageSetupAction.java
scilab/modules/xpad/src/java/org/scilab/modules/xpad/actions/PrintAction.java

index 9113321..7bde358 100644 (file)
@@ -29,8 +29,8 @@ public class PageSetupAction extends DefaultAction {
        }
 
     public void doAction() {
-       //PrinterJob printerJob = PrinterJob.getPrinterJob();
-       //pageFormat = printerJob.pageDialog(new HashPrintRequestAttributeSet());
+       PrinterJob printTask = PrinterJob.getPrinterJob();
+       pageFormat = printTask.pageDialog(new HashPrintRequestAttributeSet());
     }
     
         public static MenuItem createMenu(Xpad editor) {
index 84ec4aa..c5a8c65 100644 (file)
@@ -14,6 +14,7 @@ package org.scilab.modules.xpad.actions;
 
 import java.awt.event.ActionEvent;
 import java.awt.event.KeyEvent;
+import java.awt.print.PageFormat;
 import java.awt.print.PrinterException;
 import java.awt.print.PrinterJob;
 
@@ -43,9 +44,15 @@ public class PrintAction extends DefaultAction {
        }
 
        public static boolean printXpadDocument(Xpad editor) {
-
+               
                PrinterJob printTask = PrinterJob.getPrinterJob();
-               printTask.setPrintable(new PrinterWriter(editor.getTextPane()));
+               
+               PageFormat pageFormat = PageSetupAction.getPageFormat();
+               if (pageFormat != null) {
+                       printTask.setPrintable(new PrinterWriter(editor.getTextPane()), pageFormat);
+               } else {
+                       printTask.setPrintable(new PrinterWriter(editor.getTextPane()));
+               }
 
                if (printTask.printDialog()) { 
                        try{