summaryrefslogtreecommitdiff
path: root/src
diff options
context:
space:
mode:
Diffstat (limited to 'src')
-rw-r--r--src/Fl_cocoa.mm17
1 files changed, 17 insertions, 0 deletions
diff --git a/src/Fl_cocoa.mm b/src/Fl_cocoa.mm
index 9cad4f3b6..e5db31868 100644
--- a/src/Fl_cocoa.mm
+++ b/src/Fl_cocoa.mm
@@ -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