Printdialog does not work under Linux [message #453808] |
Sun, 10 April 2005 11:54 |
Eclipse User |
|
|
|
Originally posted by: mrkissinger.cmail.cn
Hi,
I am trying to display a printdialog under Linux with SWT (source followed) but failed.
The codes are from a book named "SWT Developer Notebook".
The program works well under Linux, except PrintDialog class.
I thought this might be the code's bug. But I tried the same code under Windows 2000 professional, the
PrintDialog showed perfectly.
I tried to run eclipse under Linux, the "Print" icon is disabled.
I am not sure whether it's a bug in SWT or the setting of my Linux is wrong.
Can anybody help me?
My platform is:
Debian Linux (unstable).
Sun JDK 1.4
eclipse-platform-SDK-3.1M6-linux-gtk.tar.gz
Gtk+ 2.6.4 (By apt-get)
===========================================================
public void widgetSelected(SelectionEvent e)
{
PrintDialog printDialog = new PrintDialog(ImpactMenu.parent, SWT.NONE);
printDialog.setText("Print");
PrinterData printerData = printDialog.open( );
System.out.println("printerData: "+printerData);
if(!(printerData==null))
{
Printer p = new Printer(printerData);
p.startJob("PrintJob");
p.startPage( );
Rectangle trim = p.computeTrim(0, 0, 0, 0);
Point dpi = p.getDPI( );
int leftMargin = dpi.x + trim.x;
int topMargin = dpi.y / 2 + trim.y;
GC gc = new GC(p);
Font font = gc.getFont( );
String printText= "Printing Test";
Point extent = gc.stringExtent(printText);
gc.drawString(printText, leftMargin, topMargin +
font.getFontData( )[0].getHeight( ));
p.endPage( );
gc.dispose( );
p.endJob( );
p.dispose( );
}
}
|
|
|
Re: Printdialog does not work under Linux [message #453809 is a reply to message #453808] |
Sun, 10 April 2005 14:29 |
Benjamin Pasero Messages: 337 Registered: July 2009 |
Senior Member |
|
|
See
http://dev.eclipse.org/viewcvs/index.cgi/~checkout~/platform -swt-home/faq.html#printOnGTK
SWT is not supporting printing on Linux GTK and Motif.
Ben
>Hi,
> I am trying to display a printdialog under Linux with SWT (source followed) but failed.
> The codes are from a book named "SWT Developer Notebook".
> The program works well under Linux, except PrintDialog class.
> I thought this might be the code's bug. But I tried the same code under Windows 2000 professional, the
> PrintDialog showed perfectly.
>
> I tried to run eclipse under Linux, the "Print" icon is disabled.
>
> I am not sure whether it's a bug in SWT or the setting of my Linux is wrong.
> Can anybody help me?
>
> My platform is:
>
> Debian Linux (unstable).
> Sun JDK 1.4
> eclipse-platform-SDK-3.1M6-linux-gtk.tar.gz
> Gtk+ 2.6.4 (By apt-get)
>
>
>===========================================================
>
> public void widgetSelected(SelectionEvent e)
> {
> PrintDialog printDialog = new PrintDialog(ImpactMenu.parent, SWT.NONE);
> printDialog.setText("Print");
> PrinterData printerData = printDialog.open( );
>
> System.out.println("printerData: "+printerData);
>
> if(!(printerData==null))
> {
> Printer p = new Printer(printerData);
> p.startJob("PrintJob");
> p.startPage( );
> Rectangle trim = p.computeTrim(0, 0, 0, 0);
> Point dpi = p.getDPI( );
> int leftMargin = dpi.x + trim.x;
> int topMargin = dpi.y / 2 + trim.y;
> GC gc = new GC(p);
> Font font = gc.getFont( );
> String printText= "Printing Test";
> Point extent = gc.stringExtent(printText);
> gc.drawString(printText, leftMargin, topMargin +
> font.getFontData( )[0].getHeight( ));
> p.endPage( );
> gc.dispose( );
> p.endJob( );
> p.dispose( );
> }
> }
>
>
>
|
|
|
Powered by
FUDForum. Page generated in 0.03225 seconds