Have Fl_Paged_Device::print_window() print window title bars with rounded angles under Yosemite also.

git-svn-id: file:///fltk/svn/fltk/branches/branch-1.3@10529 ea41ed52-d2ee-0310-a9c1-e6b18d33e121
This commit is contained in:
Manolo Gouy 2015-01-21 12:09:50 +00:00
parent 18f5d4e309
commit bbd7d9cb59

View File

@ -4277,6 +4277,20 @@ int Fl_Window::decorated_h()
return h() + bt + by;
}
#if MAC_OS_X_VERSION_MAX_ALLOWED >= MAC_OS_X_VERSION_10_6
// clip the graphics context to round top angles, as in window title bars
static void apply_titlebar_clipping(CGContextRef gc, int w, int h) {
const CGFloat radius = 4;
CGContextMoveToPoint(gc, 0, 0);
CGContextAddLineToPoint(gc, 0, h - radius);
CGContextAddArcToPoint(gc, 0, h, radius, h, radius);
CGContextAddLineToPoint(gc, w - radius, h);
CGContextAddArcToPoint(gc, w, h, w, h - radius, radius);
CGContextAddLineToPoint(gc, w, 0);
CGContextClip(gc);
}
#endif
void Fl_Paged_Device::print_window(Fl_Window *win, int x_offset, int y_offset)
{
if (!win->shown() || win->parent() || !win->border() || !win->visible()) {
@ -4295,6 +4309,7 @@ void Fl_Paged_Device::print_window(Fl_Window *win, int x_offset, int y_offset)
CGContextSaveGState(fl_gc);
CGContextTranslateCTM(fl_gc, x_offset - 0.5, y_offset + bt - 0.5);
CGContextScaleCTM(fl_gc, 1, -1);
apply_titlebar_clipping(fl_gc, win->w(), bt);
[layer renderInContext:fl_gc]; // 10.5 // print all title bar
CGContextRestoreGState(fl_gc);
}
@ -4302,6 +4317,8 @@ void Fl_Paged_Device::print_window(Fl_Window *win, int x_offset, int y_offset)
CGColorSpaceRef cspace = CGColorSpaceCreateDeviceRGB ();
CGContextRef gc = CGBitmapContextCreate(NULL, win->w(), bt, 8, 0, cspace, kCGImageAlphaPremultipliedLast);
CGColorSpaceRelease(cspace);
CGContextClearRect(gc, CGRectMake(0, 0, win->w(), bt));
apply_titlebar_clipping(gc, win->w(), bt);
[layer renderInContext:gc]; // 10.5 // draw all title bar to bitmap
Fl_RGB_Image *image = new Fl_RGB_Image((const uchar*)CGBitmapContextGetData(gc), win->w(), bt, 4,
CGBitmapContextGetBytesPerRow(gc)); // 10.2