質問

I would like to create a custom SWT PrintDialog. However it seems not possible.

In SWT PrintDialog one can click "preferences" to open the native printer driver preferences dialog. Is it possible to open the "native printer driver preferences dialog" without using org.eclipse.swt.printing.PrintDialog and read the drivers preferences (PrinterData)?

役に立ちましたか?

解決

PrintDialog is very platform specific. The Mac version, for example, does not have a Preferences option. The class contains a lot of undocumented low level code interfacing to a particular platform. It is possible to use the low level code in your own class but this is not supported and you would need some experience of the platform API.

Just to illustrate the difference, here is the first few lines of the open method on Windows:

public PrinterData open() {
    /* Get the owner HWND for the dialog */
    Control parent = getParent();
    int style = getStyle();
    long /*int*/ hwndOwner = parent.handle;
    long /*int*/ hwndParent = parent.handle;

and the Mac OS X code:

public PrinterData open() {
    PrinterData data = null;
    NSPrintPanel panel = NSPrintPanel.printPanel();
    NSPrintInfo printInfo = new NSPrintInfo(NSPrintInfo.sharedPrintInfo().copy());
    if (printerData.duplex != SWT.DEFAULT) {
        long /*int*/ settings = printInfo.PMPrintSettings();

and Linux:

public PrinterData open() {
    if (OS.GTK_VERSION < OS.VERSION (2, 10, 0)) {
        return Printer.getDefaultPrinterData();
    } else {
       byte [] titleBytes = Converter.wcsToMbcs (null, getText(), true);
       long /*int*/ topHandle = getParent().handle;
        while (topHandle != 0 && !OS.GTK_IS_WINDOW(topHandle)) {
            topHandle = OS.gtk_widget_get_parent(topHandle);
        }
ライセンス: CC-BY-SA帰属
所属していません StackOverflow
scroll top