diff options
| author | Manolo Gouy <Manolo> | 2014-10-26 15:23:03 +0000 |
|---|---|---|
| committer | Manolo Gouy <Manolo> | 2014-10-26 15:23:03 +0000 |
| commit | ffdc36dcb690b458b240e90dfed06c27cb6a62bb (patch) | |
| tree | 43590cac795f83ab15ddbd370dc659e83a27410d | |
| parent | 9d5fde73b6a72008b88eabae1bfe82653c4ca872 (diff) | |
Print at high res with Fl_Paged_Device::print_window_part() when using a retina display
git-svn-id: file:///fltk/svn/fltk/branches/branch-1.3@10393 ea41ed52-d2ee-0310-a9c1-e6b18d33e121
| -rw-r--r-- | FL/Fl_Printer.H | 5 | ||||
| -rw-r--r-- | src/Fl_Quartz_Printer.mm | 22 |
2 files changed, 25 insertions, 2 deletions
diff --git a/FL/Fl_Printer.H b/FL/Fl_Printer.H index a70670473..d7840dcfe 100644 --- a/FL/Fl_Printer.H +++ b/FL/Fl_Printer.H @@ -3,7 +3,7 @@ // // Printing support for the Fast Light Tool Kit (FLTK). // -// Copyright 2010-2011 by Bill Spitzak and others. +// Copyright 2010-2014 by Bill Spitzak and others. // // This library is free software. Distribution and use rights are outlined in // the file "COPYING" which should have been included with this file. If this @@ -84,6 +84,9 @@ public: void untranslate(void); int end_page (void); void end_job (void); +#ifdef __APPLE__ + void print_window_part(Fl_Window *win, int x, int y, int w, int h, int delta_x, int delta_y); +#endif /** \brief The destructor */ ~Fl_System_Printer(void); }; // class Fl_System_Printer diff --git a/src/Fl_Quartz_Printer.mm b/src/Fl_Quartz_Printer.mm index 57e46e1bb..9eb901abf 100644 --- a/src/Fl_Quartz_Printer.mm +++ b/src/Fl_Quartz_Printer.mm @@ -3,7 +3,7 @@ // // Mac OS X-specific printing support (objective-c++) for the Fast Light Tool Kit (FLTK). // -// Copyright 2010-2012 by Bill Spitzak and others. +// Copyright 2010-2014 by Bill Spitzak and others. // // This library is free software. Distribution and use rights are outlined in // the file "COPYING" which should have been included with this file. If this @@ -315,6 +315,26 @@ void Fl_System_Printer::end_job (void) if (w) w->show(); } +// version that prints at high res if using a retina display +void Fl_System_Printer::print_window_part(Fl_Window *win, int x, int y, int w, int h, int delta_x, int delta_y) +{ + Fl_Surface_Device *current = Fl_Surface_Device::surface(); + Fl_Display_Device::display_device()->set_current(); + Fl_Window *save_front = Fl::first_window(); + win->show(); + fl_gc = NULL; + Fl::check(); + win->make_current(); + CGImageRef img = Fl_X::CGImage_from_window_rect(win, x, y, w, h); + if (save_front != win) save_front->show(); + current->set_current(); + CGRect rect = { { delta_x, delta_y }, { w, h } }; + Fl_X::q_begin_image(rect, 0, 0, w, h); + CGContextDrawImage(fl_gc, rect, img); + Fl_X::q_end_image(); + CFRelease(img); +} + #endif // __APPLE__ // |
