diff options
| author | Manolo Gouy <Manolo> | 2014-10-11 14:33:43 +0000 |
|---|---|---|
| committer | Manolo Gouy <Manolo> | 2014-10-11 14:33:43 +0000 |
| commit | a3845fc51d1ec1393d187e59c325cfc8795ec2af (patch) | |
| tree | 7de934f9001ddfa342bb8b751297e7f691390ce2 /src | |
| parent | 6232a298f38bf77fa7cc4983b20dd43ad68a18c0 (diff) | |
Improved Fl_Paged_Device::print_window() when used on an Apple computer with a retina display:
the window tittle bar is printed at high resolution.
git-svn-id: file:///fltk/svn/fltk/branches/branch-1.3@10372 ea41ed52-d2ee-0310-a9c1-e6b18d33e121
Diffstat (limited to 'src')
| -rw-r--r-- | src/Fl_cocoa.mm | 27 |
1 files changed, 21 insertions, 6 deletions
diff --git a/src/Fl_cocoa.mm b/src/Fl_cocoa.mm index 1c76831f1..3f26f3342 100644 --- a/src/Fl_cocoa.mm +++ b/src/Fl_cocoa.mm @@ -3958,19 +3958,34 @@ void Fl_Paged_Device::print_window(Fl_Window *win, int x_offset, int y_offset) win->show(); fl_gc = NULL; Fl::check(); + BOOL to_quartz = dynamic_cast<Fl_Printer*>(this) != NULL; // capture the window title bar with no title - unsigned char *bitmap = Fl_X::bitmap_from_window_rect(win, 0, -bt, win->w(), bt, &bpp); + CGImageRef img = NULL; + unsigned char *bitmap = NULL; + if (to_quartz) + img = Fl_X::CGImage_from_window_rect(win, 0, -bt, win->w(), bt); + else + bitmap = Fl_X::bitmap_from_window_rect(win, 0, -bt, win->w(), bt, &bpp); win->label(title); // put back the window title // and print it this->set_current(); // back to the Fl_Paged_Device - Fl_RGB_Image *rgb = new Fl_RGB_Image(bitmap, win->w(), bt, bpp); - rgb->draw(x_offset, y_offset); - delete rgb; - delete[] bitmap; + if (img && to_quartz) { + CGRect rect = { { x_offset, y_offset }, { win->w(), bt } }; + Fl_X::q_begin_image(rect, 0, 0, win->w(), bt); + CGContextDrawImage(fl_gc, rect, img); + Fl_X::q_end_image(); + CFRelease(img); + } + else if(!to_quartz) { + Fl_RGB_Image *rgb = new Fl_RGB_Image(bitmap, win->w(), bt, bpp); + rgb->draw(x_offset, y_offset); + delete rgb; + delete[] bitmap; + } if (title) { // print the window title const int skip = 68; // approx width of the zone of the 3 window control buttons #if MAC_OS_X_VERSION_MAX_ALLOWED >= MAC_OS_X_VERSION_10_4 - if (fl_mac_os_version >= 100400 && dynamic_cast<Fl_Printer*>(this)) { // use Cocoa string drawing with exact title bar font + if (fl_mac_os_version >= 100400 && to_quartz) { // use Cocoa string drawing with exact title bar font NSGraphicsContext *current = [NSGraphicsContext currentContext]; [NSGraphicsContext setCurrentContext:[NSGraphicsContext graphicsContextWithGraphicsPort:fl_gc flipped:YES]];//10.4 NSDictionary *attr = [NSDictionary dictionaryWithObject:[NSFont titleBarFontOfSize:0] |
