Community
Participate
Working Groups
The print icon on the toolbar and the print option under the file menu are disable no matter what editor I am using.
This will not be implemented for R2.1.
*** Bug 42992 has been marked as a duplicate of this bug. ***
I want to try to help do this one, as I also need to be able to print things on my Mac from within Eclipse. I started doing research and found bug 24796 which indicates the depth of knowledge needed to implement printing in Eclipse - no wonder so few platforms have printing working yet! Anyway, I need some pointers to start, most importantly answers to two questions: 1) how does the printing item on the menu get enabled? I've been all over the kits for solaris and windows, and even re-installed the windows kit to see if there was a runtime mod, and I can't find it. 2) are the printing implementations actually located in JNI source kits, for example os.c? Thanks and have fun! - Bob
1) In Eclipse, the printing menu item gets enabled when Printer.getPrinterList () returns a non-empty list. 2) In SWT, the JNI is one-to-one mapping, read article: http://www.eclipse.org/articles/Article-SWT-Design-1/SWT-Design-1.html the printing implementation is located in the Printer class.
I've implemented a first cut of printing for Mac OS X. I've tested it with a Canon i950 inkjet printer and an IBM InfoPrint 12 PostScript printer. However, it should support any printer. PDF generation and preview works too. And it works really well with the new Panther printing options. Please note: As far as I know, Eclipse seems to support printing only via the StyledText widget in editors, so you cannot print arbitrary views. In addition the StyledText printing isn't fine tuned to print source code. You can download a version of SWT (3023) that supports printing here: http://www.weinand.org/eclipse/swt_3023_carbon_printing.dmg Mount the disk image and copy the enclosed folder into your Eclipse plugin folder (replacing the existing plugin).
I don't have mac, silenio will work on this intead.
So let me know if you need the source...
Andre, please could you attach the source? Thanks! Silenio
Do you plan to include this in M4?
You're kidding, right?
No, why? ;-)
Created attachment 6348 [details] Patch for jnigen/org.eclipse.swt.internal.carbon.OS.properties
Created attachment 6349 [details] Patch for OS.java, Printer.java, PrintDialog.java (doesn't include os.c, os_struct.{c,h} )
Issues: - Mac requires that PrintDialog and actual print loop takes place within the scope of a PMPrintSession object. SWT does not provide a good way to pass the PMPrintSession object from the PrintDialog to the Printer without a potential of leaking. Right now I'm streaming the handle of the PMPrintSession, PMPrintSettings and PMPageFormat to the PrinterData.otherData. However, if the PrinterData isn't used to create a Printer, the three objects will leak. - Mac assumes that an individual graphics context must be created for each page. SWT allows to create a GC for all pages (that is outside a startPage/endPage context). Read the comment for Printer.setupNewPage() for how I've tried to work around this issue. - Mac doesn't support to have more than one independent GC for the same Printer. SWT seems to allow this. - Using PMSessionBeginDocument & Co. would open a progress dialog for the duration of the print session. As a consequence Eclipse would receive a Deactivate event. If printing takes place in another thread (as it does in Eclipse StyledText), the event originates from the wrong thread and SWT would abort. Therefore I'm using the non-UI variants of PMSessionBeginDocument & Co. - Resolution for Mac printers is always 72 DPI, but because CG coordinate system uses doubles, this is not a limitation. However, SWT uses integers so it would make sense to scale the coordinate at least by a factor of 10.
Yet another issue: - Mac has a Page Setup dialog and a Print dialog. SWT only provides a single PrintDialog. So my PrintDialog first opens the Page Setup and then the Print dialog.
Created attachment 6359 [details] PrintDialog.open() using Sheets This version of PrintDialog.open() uses Sheets. Add to jnigen carbon property file: OS_PMSessionUseSheets= OS_PMSessionUseSheets_0=cast=(PMPrintSession) OS_PMSessionUseSheets_1=cast=(WindowRef) OS_PMSessionUseSheets_2=cast=(PMSheetDoneUPP)
I've posted a new version of SWT with MacOS X printing (using Sheets) here: http://www.weinand.org/eclipse/swt_3024_carbon_printing.dmg
Printing support has been released.
Silenio, thanks for integrating and adapting my patch. A nit: the Preview functionality no longer works (at least under Panther; I didn't check Jaguar).
Thank again to Andre for doing all the hard work.
It seems that the preview info is kept by the print session and not by the print settings object. There is no API to flatten and unflatten a print session, so the info is lost. I released code to fix this.