Added showPrintDialog.

This commit is contained in:
Robert Greene 2004-06-13 03:34:50 +00:00
parent cb50b1748f
commit 4818d61436

View File

@ -23,6 +23,10 @@ import org.eclipse.swt.custom.ScrolledComposite;
import org.eclipse.swt.graphics.FontMetrics; import org.eclipse.swt.graphics.FontMetrics;
import org.eclipse.swt.graphics.GC; import org.eclipse.swt.graphics.GC;
import org.eclipse.swt.graphics.Rectangle; import org.eclipse.swt.graphics.Rectangle;
import org.eclipse.swt.printing.PrintDialog;
import org.eclipse.swt.printing.Printer;
import org.eclipse.swt.printing.PrinterData;
import org.eclipse.swt.widgets.Control;
import org.eclipse.swt.widgets.Shell; import org.eclipse.swt.widgets.Shell;
/** /**
@ -63,4 +67,13 @@ public class SwtUtil {
composite.getHorizontalBar().setIncrement(fontWidth); composite.getHorizontalBar().setIncrement(fontWidth);
composite.getHorizontalBar().setPageIncrement(pageWidth); composite.getHorizontalBar().setPageIncrement(pageWidth);
} }
/**
* Display the Print dialog helper method.
*/
public static Printer showPrintDialog(Control control) {
PrintDialog dialog = new PrintDialog(control.getShell());
PrinterData printerData = dialog.open();
if (printerData == null) return null;
return new Printer(printerData);
}
} }