summaryrefslogtreecommitdiffstats
path: root/macosx/tkMacOSXDraw.c
diff options
context:
space:
mode:
Diffstat (limited to 'macosx/tkMacOSXDraw.c')
-rw-r--r--macosx/tkMacOSXDraw.c68
1 files changed, 18 insertions, 50 deletions
diff --git a/macosx/tkMacOSXDraw.c b/macosx/tkMacOSXDraw.c
index 25744ab..fa23e5c 100644
--- a/macosx/tkMacOSXDraw.c
+++ b/macosx/tkMacOSXDraw.c
@@ -17,7 +17,7 @@
#include "tkMacOSXDebug.h"
#include "tkButton.h"
-#if MAC_OS_X_VERSION_MIN_REQUIRED >= 101400
+#if MAC_OS_X_VERSION_MAX_ALLOWED >= 101000
#define GET_CGCONTEXT [[NSGraphicsContext currentContext] CGContext]
#else
#define GET_CGCONTEXT [[NSGraphicsContext currentContext] graphicsPort]
@@ -43,6 +43,7 @@ static int cgAntiAliasLimit = 0;
static int useThemedToplevel = 0;
static int useThemedFrame = 0;
+static unsigned long transparentColor;
/*
* Prototypes for functions used only in this file.
@@ -69,11 +70,10 @@ static void ClipToGC(Drawable d, GC gc, HIShapeRef *clipRgnPtr);
MODULE_SCOPE int
TkMacOSXInitCGDrawing(
Tcl_Interp *interp,
- int enable,
+ TCL_UNUSED(int),
int limit)
{
static Boolean initialized = FALSE;
- (void)enable;
if (!initialized) {
initialized = TRUE;
@@ -100,6 +100,7 @@ TkMacOSXInitCGDrawing(
(char *) &useThemedFrame, TCL_LINK_BOOLEAN) != TCL_OK) {
Tcl_ResetResult(interp);
}
+ transparentColor = TkMacOSXClearPixel();
}
return TCL_OK;
}
@@ -546,7 +547,7 @@ TkMacOSXGetNSImageWithBitmap(
unsigned long origBackground = gc->background;
- gc->background = TRANSPARENT_PIXEL << 24;
+ gc->background = transparentColor;
XSetClipOrigin(display, gc, 0, 0);
XCopyPlane(display, bitmap, pixmap, gc, 0, 0, width, height, 0, 0, 1);
gc->background = origBackground;
@@ -665,17 +666,18 @@ TkMacOSXDrawCGImage(
dstBounds = CGRectOffset(dstBounds, macDraw->xOff, macDraw->yOff);
if (CGImageIsMask(image)) {
if (macDraw->flags & TK_IS_BW_PIXMAP) {
+
/*
* Set fill color to black; background comes from the context,
* or is transparent.
*/
- if (imageBackground != TRANSPARENT_PIXEL << 24) {
+ if (imageBackground != transparentColor) {
CGContextClearRect(context, dstBounds);
}
CGContextSetRGBFillColor(context, 0.0, 0.0, 0.0, 1.0);
} else {
- if (imageBackground != TRANSPARENT_PIXEL << 24) {
+ if (imageBackground != transparentColor) {
TkMacOSXSetColorInContext(gc, imageBackground, context);
CGContextFillRect(context, dstBounds);
}
@@ -863,13 +865,12 @@ XFillPolygon(
GC gc, /* Use this GC. */
XPoint *points, /* Array of points. */
int npoints, /* Number of points. */
- int shape, /* Shape to draw. */
+ TCL_UNUSED(int), /* Shape to draw. */
int mode) /* Drawing mode. */
{
MacDrawable *macWin = (MacDrawable *) d;
TkMacOSXDrawingContext dc;
int i;
- (void)shape;
display->request++;
if (!TkMacOSXSetupDrawingContext(d, gc, 1, &dc)) {
@@ -1442,7 +1443,7 @@ XFillArcs(
int
TkScrollWindow(
Tk_Window tkwin, /* The window to be scrolled. */
- GC gc, /* GC for window to be scrolled. */
+ TCL_UNUSED(GC), /* GC for window to be scrolled. */
int x, int y, /* Position rectangle to be scrolled. */
int width, int height,
int dx, int dy, /* Distance rectangle should be moved. */
@@ -1455,7 +1456,6 @@ TkScrollWindow(
HIShapeRef dmgRgn = NULL, extraRgn = NULL;
NSRect bounds, visRect, scrollSrc, scrollDst;
int result = 0;
- (void)gc;
if (view) {
/*
@@ -1539,12 +1539,9 @@ TkScrollWindow(
void
TkMacOSXSetUpGraphicsPort(
- GC gc, /* GC to apply to current port. */
- void *destPort)
+ TCL_UNUSED(GC), /* GC to apply to current port. */
+ TCL_UNUSED(void *))
{
- (void)gc;
- (void)destPort;
-
Tcl_Panic("TkMacOSXSetUpGraphicsPort: Obsolete, no more QD!");
}
@@ -1571,7 +1568,7 @@ Bool
TkMacOSXSetupDrawingContext(
Drawable d,
GC gc,
- int useCG, /* advisory only ! */
+ TCL_UNUSED(int),
TkMacOSXDrawingContext *dcPtr)
{
MacDrawable *macDraw = (MacDrawable *) d;
@@ -1579,7 +1576,6 @@ TkMacOSXSetupDrawingContext(
NSWindow *win = NULL;
TkMacOSXDrawingContext dc = {};
CGRect clipBounds;
- (void)useCG;
/*
* If the drawable is not a pixmap and it has an associated NSWindow then
@@ -1652,8 +1648,7 @@ TkMacOSXSetupDrawingContext(
* cycle.
*/
- CGRect currentClip = CGContextGetClipBoundingBox(
- [NSGraphicsContext currentContext].CGContext);
+ CGRect currentClip = CGContextGetClipBoundingBox(GET_CGCONTEXT);
if (!NSContainsRect(currentClip, clipBounds)) {
[view addTkDirtyRect:clipBounds];
}
@@ -1749,6 +1744,7 @@ TkMacOSXSetupDrawingContext(
int num = 0;
char *p = &gc->dashes;
CGFloat dashOffset = gc->dash_offset;
+ dashOffset -= (gc->line_width % 2) ? 0.5 : 0.0;
CGFloat lengths[10];
while (p[num] != '\0' && num < 10) {
@@ -1872,30 +1868,6 @@ TkMacOSXGetClipRgn(
/*
*----------------------------------------------------------------------
*
- * TkMacOSXSetUpClippingRgn --
- *
- * Set up the clipping region so that drawing only occurs on the specified
- * X subwindow.
- *
- * Results:
- * None.
- *
- * Side effects:
- * None.
- *
- *----------------------------------------------------------------------
- */
-
-void
-TkMacOSXSetUpClippingRgn(
- Drawable drawable) /* Drawable to update. */
-{
- (void)drawable;
-}
-
-/*
- *----------------------------------------------------------------------
- *
* TkpClipDrawableToRect --
*
* Clip all drawing into the drawable d to the given rectangle. If width
@@ -1912,13 +1884,12 @@ TkMacOSXSetUpClippingRgn(
void
TkpClipDrawableToRect(
- Display *display,
+ TCL_UNUSED(Display *),
Drawable d,
int x, int y,
int width, int height)
{
MacDrawable *macDraw = (MacDrawable *) d;
- (void)display;
if (macDraw->drawRgn) {
CFRelease(macDraw->drawRgn);
@@ -2004,12 +1975,9 @@ ClipToGC(
void *
TkMacOSXMakeStippleMap(
- Drawable drawable, /* Window to apply stipple. */
- Drawable stipple) /* The stipple pattern. */
+ TCL_UNUSED(Drawable), /* Window to apply stipple. */
+ TCL_UNUSED(Drawable)) /* The stipple pattern. */
{
- (void)drawable;
- (void)stipple;
-
return NULL;
}