diff options
| author | Manolo Gouy <Manolo> | 2011-09-08 10:56:51 +0000 |
|---|---|---|
| committer | Manolo Gouy <Manolo> | 2011-09-08 10:56:51 +0000 |
| commit | 28d33a29ad287b7d153d02c271d7caf441b0e203 (patch) | |
| tree | 28dd1842bf5caf34dea6bfadb1ba1b669632a430 | |
| parent | 8c6aad459de5cadd8a260afcf62899496de1e86a (diff) | |
Mac OS: print dialog uses only one window instead of two.
git-svn-id: file:///fltk/svn/fltk/branches/branch-1.3@9033 ea41ed52-d2ee-0310-a9c1-e6b18d33e121
| -rw-r--r-- | src/Fl_Quartz_Printer.mm | 32 |
1 files changed, 14 insertions, 18 deletions
diff --git a/src/Fl_Quartz_Printer.mm b/src/Fl_Quartz_Printer.mm index 088b1abb4..a045d5ed0 100644 --- a/src/Fl_Quartz_Printer.mm +++ b/src/Fl_Quartz_Printer.mm @@ -42,35 +42,30 @@ int Fl_System_Printer::start_job (int pagecount, int *frompage, int *topage) //returns 0 iff OK { OSStatus status = 0; + fl_open_display(); Fl_X::q_release_context(); #if MAC_OS_X_VERSION_MAX_ALLOWED >= MAC_OS_X_VERSION_10_5 - if( [NSPrintPanel instancesRespondToSelector:@selector(runModalWithPrintInfo:)] && - [NSPrintInfo instancesRespondToSelector:@selector(PMPrintSession)] ) { - NSAutoreleasePool *localPool; - localPool = [[NSAutoreleasePool alloc] init]; + if (fl_mac_os_version >= 100500) { NSPrintInfo *info = [NSPrintInfo sharedPrintInfo]; - NSPageLayout *layout = [NSPageLayout pageLayout]; - NSInteger retval = [layout runModal]; - if(retval == NSOKButton) { - NSPrintPanel *panel = [NSPrintPanel printPanel]; - retval = (NSInteger)[panel runModalWithPrintInfo:info];//from 10.5 only - } + NSPrintPanel *panel = [NSPrintPanel printPanel]; + //from 10.5 + [panel setOptions:NSPrintPanelShowsCopies | NSPrintPanelShowsPageRange | NSPrintPanelShowsPageSetupAccessory]; + NSInteger retval = [panel runModalWithPrintInfo:info];//from 10.5 if(retval != NSOKButton) { - Fl::first_window()->show(); - [localPool release]; + Fl_Window *w = Fl::first_window(); + if (w) w->show(); return 1; } - printSession = (PMPrintSession)[info PMPrintSession]; - pageFormat = (PMPageFormat)[info PMPageFormat]; - printSettings = (PMPrintSettings)[info PMPrintSettings]; + printSession = (PMPrintSession)[info PMPrintSession];//from 10.5 + pageFormat = (PMPageFormat)[info PMPageFormat];//from 10.5 + printSettings = (PMPrintSettings)[info PMPrintSettings];//from 10.5 UInt32 from32, to32; PMGetFirstPage(printSettings, &from32); if (frompage) *frompage = (int)from32; PMGetLastPage(printSettings, &to32); if (topage) *topage = (int)to32; if(topage && *topage > pagecount) *topage = pagecount; - status = PMSessionBeginCGDocumentNoDialog(printSession, printSettings, pageFormat); - [localPool release]; + status = PMSessionBeginCGDocumentNoDialog(printSession, printSettings, pageFormat);//from 10.4 } else { #endif @@ -289,7 +284,8 @@ void Fl_System_Printer::end_job (void) PMSessionEndDocumentNoDialog(printSession); Fl_Display_Device::display_device()->set_current(); fl_gc = 0; - Fl::first_window()->show(); + Fl_Window *w = Fl::first_window(); + if (w) w->show(); } #endif // __APPLE__ |
