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
This commit is contained in:
Manolo Gouy 2014-10-26 15:23:03 +00:00
parent 9d5fde73b6
commit ffdc36dcb6
2 changed files with 25 additions and 2 deletions

View File

@ -3,7 +3,7 @@
// //
// Printing support for the Fast Light Tool Kit (FLTK). // 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 // 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 // the file "COPYING" which should have been included with this file. If this
@ -84,6 +84,9 @@ public:
void untranslate(void); void untranslate(void);
int end_page (void); int end_page (void);
void end_job (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 */ /** \brief The destructor */
~Fl_System_Printer(void); ~Fl_System_Printer(void);
}; // class Fl_System_Printer }; // class Fl_System_Printer

View File

@ -3,7 +3,7 @@
// //
// Mac OS X-specific printing support (objective-c++) for the Fast Light Tool Kit (FLTK). // 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 // 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 // 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(); 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__ #endif // __APPLE__
// //