Some Eclipse Foundation services are deprecated, or will be soon. Please ensure you've read this important communication.
Bug 33637 - DCR - no printing on Mac [was Print on OSX 10.2.4]
Summary: DCR - no printing on Mac [was Print on OSX 10.2.4]
Status: RESOLVED FIXED
Alias: None
Product: Platform
Classification: Eclipse Project
Component: SWT (show other bugs)
Version: 2.1   Edit
Hardware: Macintosh Mac OS X - Carbon (unsup.)
: P3 critical with 4 votes (vote)
Target Milestone: ---   Edit
Assignee: Silenio Quarti CLA
QA Contact:
URL:
Whiteboard:
Keywords:
: 42992 (view as bug list)
Depends on:
Blocks:
 
Reported: 2003-03-02 20:20 EST by Duncan DeVore CLA
Modified: 2003-11-10 12:07 EST (History)
5 users (show)

See Also:


Attachments
Patch for jnigen/org.eclipse.swt.internal.carbon.OS.properties (4.99 KB, patch)
2003-10-07 11:52 EDT, Andre Weinand CLA
no flags Details | Diff
Patch for OS.java, Printer.java, PrintDialog.java (21.28 KB, patch)
2003-10-07 11:54 EDT, Andre Weinand CLA
no flags Details | Diff
PrintDialog.open() using Sheets (2.82 KB, text/plain)
2003-10-07 18:54 EDT, Andre Weinand CLA
no flags Details

Note You need to log in before you can comment on or make changes to this bug.
Description Duncan DeVore CLA 2003-03-02 20:20:04 EST
The print icon on the toolbar and the print option under the file menu are
disable no matter what editor I am using.
Comment 1 Veronika Irvine CLA 2003-03-10 11:17:10 EST
This will not be implemented for R2.1.
Comment 2 Silenio Quarti CLA 2003-09-12 16:59:49 EDT
*** Bug 42992 has been marked as a duplicate of this bug. ***
Comment 3 Bob Hays, Computer Geek CLA 2003-09-13 20:02:22 EDT
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
Comment 4 Felipe Heidrich CLA 2003-09-15 10:34:32 EDT
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.
Comment 5 Andre Weinand CLA 2003-10-05 18:44:57 EDT
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).

Comment 6 Felipe Heidrich CLA 2003-10-06 12:16:47 EDT
I don't have mac, silenio will work on this intead.
Comment 7 Andre Weinand CLA 2003-10-06 12:23:47 EDT
So let me know if you need the source...
Comment 8 Silenio Quarti CLA 2003-10-06 14:02:14 EDT
Andre, please could you attach the source? Thanks!

Silenio
Comment 9 Andre Weinand CLA 2003-10-06 15:16:18 EDT
Do you plan to include this in M4?
Comment 10 Steve Northover CLA 2003-10-06 15:36:06 EDT
You're kidding, right?
Comment 11 Andre Weinand CLA 2003-10-06 16:11:56 EDT
No, why? ;-)
Comment 12 Andre Weinand CLA 2003-10-07 11:52:35 EDT
Created attachment 6348 [details]
Patch for jnigen/org.eclipse.swt.internal.carbon.OS.properties
Comment 13 Andre Weinand CLA 2003-10-07 11:54:32 EDT
Created attachment 6349 [details]
Patch for OS.java, Printer.java, PrintDialog.java

(doesn't include os.c, os_struct.{c,h} )
Comment 14 Andre Weinand CLA 2003-10-07 12:23:55 EDT
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.
Comment 15 Andre Weinand CLA 2003-10-07 12:56:05 EDT
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.
Comment 16 Andre Weinand CLA 2003-10-07 18:54:06 EDT
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)
Comment 17 Andre Weinand CLA 2003-10-07 19:02:27 EDT
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
Comment 18 Silenio Quarti CLA 2003-11-07 15:05:15 EST
Printing support has been released.
Comment 19 Andre Weinand CLA 2003-11-07 18:36:20 EST
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).
Comment 20 Steve Northover CLA 2003-11-07 18:42:28 EST
Thank again to Andre for doing all the hard work.
Comment 21 Silenio Quarti CLA 2003-11-10 12:07:06 EST
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.