# HG changeset patch # User bsmith@81767d24-ef19-dc11-ae90-00e081727c95 # Date 1325351091 0 # Node ID 026c0b4d6ee93167da63e8f33ca3aa8cc70a9669 # Parent c98b2ce2d5b2e3dc648237a63fbebc84014dbfff Initial implmentation of DW_DRAW_NOAA on Mac... only works on pixmaps right now. diff -r c98b2ce2d5b2 -r 026c0b4d6ee9 dw.h --- a/dw.h Fri Dec 30 21:30:24 2011 +0000 +++ b/dw.h Sat Dec 31 17:04:51 2011 +0000 @@ -1402,11 +1402,11 @@ #define DW_HTML_STOP 5 #define DW_HTML_PRINT 6 -/* Drawing flags... used for Arc currently */ +/* Drawing flags */ #define DW_DRAW_DEFAULT 0 #define DW_DRAW_FILL 1 #define DW_DRAW_FULL (1 << 1) - +#define DW_DRAW_NOAA (1 << 2) /* Macro for casting resource IDs to HICN */ #define DW_RESOURCE(a) (a < 65536 ? (HICN)a : (HICN)0) diff -r c98b2ce2d5b2 -r 026c0b4d6ee9 mac/dw.m --- a/mac/dw.m Fri Dec 30 21:30:24 2011 +0000 +++ b/mac/dw.m Sat Dec 31 17:04:51 2011 +0000 @@ -5267,6 +5267,18 @@ } } +/* Internal function to create an image graphics context... + * with or without antialiasing enabled. + */ +id _create_gc(id image, bool antialiased) +{ + CGContextRef context = (CGContextRef)[[NSGraphicsContext graphicsContextWithBitmapImageRep:image] graphicsPort]; + NSGraphicsContext *gc = [NSGraphicsContext graphicsContextWithGraphicsPort:context flipped:YES]; + [gc setShouldAntialias:antialiased]; + CGContextSetAllowsAntialiasing(context, antialiased); + return gc; +} + /* Draw a polygon on a window (preferably a render window). * Parameters: * handle: Handle to the window. @@ -5286,9 +5298,9 @@ if(pixmap) { image = (id)pixmap->image; + id gc = _create_gc(image, flags & DW_DRAW_NOAA ? NO : YES); [NSGraphicsContext saveGraphicsState]; - [NSGraphicsContext setCurrentContext:[NSGraphicsContext - graphicsContextWithGraphicsPort:[[NSGraphicsContext graphicsContextWithBitmapImageRep:image] graphicsPort] flipped:YES]]; + [NSGraphicsContext setCurrentContext:gc]; } else { @@ -5344,9 +5356,9 @@ if(pixmap) { image = (id)pixmap->image; + id gc = _create_gc(image, flags & DW_DRAW_NOAA ? NO : YES); [NSGraphicsContext saveGraphicsState]; - [NSGraphicsContext setCurrentContext:[NSGraphicsContext - graphicsContextWithGraphicsPort:[[NSGraphicsContext graphicsContextWithBitmapImageRep:image] graphicsPort] flipped:YES]]; + [NSGraphicsContext setCurrentContext:gc]; } else { @@ -5404,9 +5416,9 @@ if(pixmap) { image = (id)pixmap->image; + id gc = _create_gc(image, flags & DW_DRAW_NOAA ? NO : YES); [NSGraphicsContext saveGraphicsState]; - [NSGraphicsContext setCurrentContext:[NSGraphicsContext - graphicsContextWithGraphicsPort:[[NSGraphicsContext graphicsContextWithBitmapImageRep:image] graphicsPort] flipped:YES]]; + [NSGraphicsContext setCurrentContext:gc]; } else { diff -r c98b2ce2d5b2 -r 026c0b4d6ee9 readme --- a/readme Fri Dec 30 21:30:24 2011 +0000 +++ b/readme Sat Dec 31 17:04:51 2011 +0000 @@ -50,6 +50,8 @@ Several types of widgets have this set by default now. Added faster and less buggy layout engine 2.0 for OS/2, Windows and Mac. Added auto-positioning on Mac; reimplemented auto-positioning on OS/2. +Added DW_DRAW_NOAA which can be passed to dw_draw_*() API functions + that accept the flags parameter to disable anti-aliasing. Fixed auto-sizing top-level windows on Windows; added on OS/2 and Mac. Fixed bubble help not being displayed on Windows. Fixed menu bar items remaining highlighted on Mac.