From fd6f23be1500b5efefed38ae033804ef95f66f1b Mon Sep 17 00:00:00 2001 From: das Date: Fri, 29 Jun 2007 03:20:00 +0000 Subject: * macosx/tkMacOSXScrlbr.c: correct int <-> dobule conversion issues that could lead to Carbon getting confused about scrollbar thumb size. * macosx/tkMacOSXDraw.c (XCopyArea, XCopyPlane, TkPutImage) use TkMacOSX{Setup,Restore}DrawingContext() to setup/restore clip & colors. (TkMacOSXSetupDrawingContext, TkMacOSXRestoreDrawingContext): add save and restore of QD port clip region; factor out clip region code common to CG and QD branches; check for port and context validity; handle tkPictureIsOpen flag during QD port setup. (TkScrollWindow): remove unnecessary scroll region manipulation * macosx/tkMacOSXDraw.c: remove second global QD temp region * macosx/tkMacOSXInt.h: (no longer necessary) and rename * macosx/tkMacOSXRegion.c: remaining global QD temp region. * macosx/tkMacOSXSubwindows.c: * macosx/tkMacOSXWindowEvent.c: * macosx/tkMacOSXDraw.c: make useCGDrawing variable MODULE_SCOPE * macosx/tkMacOSXFont.c: and respect it for ATSUI font drawing. * macosx/tkMacOSXButton.c: reduce reliance on current QD port * macosx/tkMacOSXColor.c: setting and remove unnecessary * macosx/tkMacOSXDebug.c: references to a drawable's QD port, * macosx/tkMacOSXDebug.h: notably replace GetWindowFromPort( * macosx/tkMacOSXDialog.c: TkMacOSXGetDrawablePort()) idiom by new * macosx/tkMacOSXDraw.c: TkMacOSXDrawableWindow() and change * macosx/tkMacOSXKeyEvent.c: TkMacOSXSetColorInPort() to take a port * macosx/tkMacOSXMenu.c: argument. * macosx/tkMacOSXMenubutton.c: * macosx/tkMacOSXMouseEvent.c: * macosx/tkMacOSXScale.c: * macosx/tkMacOSXScrlbr.c: * macosx/tkMacOSXSubwindows.c: * macosx/tkMacOSXWindowEvent.c: * macosx/tkMacOSXWm.c: * macosx/tkMacOSXInt.h: factor out macros, declarations * macosx/tkMacOSXPrivate.h (new): and prototypes that are purely internal and private to the 'macosx' sources into a new internal header file that does _not_ get installed into Tk.framework/PrivateHeaders. * macosx/tkMacOSXButton.c: #include new tkMacOSXPrivate.h * macosx/tkMacOSXCarbonEvents.c: instead of tkMacOSXInt.h. * macosx/tkMacOSXClipboard.c: * macosx/tkMacOSXColor.c: * macosx/tkMacOSXCursor.c: * macosx/tkMacOSXDebug.c: * macosx/tkMacOSXDialog.c: * macosx/tkMacOSXDraw.c: * macosx/tkMacOSXEntry.c: * macosx/tkMacOSXEvent.c: * macosx/tkMacOSXFont.c: * macosx/tkMacOSXHLEvents.c: * macosx/tkMacOSXInit.c: * macosx/tkMacOSXKeyEvent.c: * macosx/tkMacOSXMenu.c: * macosx/tkMacOSXMenubutton.c: * macosx/tkMacOSXMenus.c: * macosx/tkMacOSXMouseEvent.c: * macosx/tkMacOSXNotify.c: * macosx/tkMacOSXRegion.c: * macosx/tkMacOSXScale.c: * macosx/tkMacOSXScrlbr.c: * macosx/tkMacOSXSubwindows.c: * macosx/tkMacOSXWindowEvent.c: * macosx/tkMacOSXWm.c: * macosx/tkMacOSXXStubs.c: * macosx/ttkMacOSXTheme.c: --- ChangeLog | 84 +++++ macosx/tkMacOSXButton.c | 18 +- macosx/tkMacOSXCarbonEvents.c | 4 +- macosx/tkMacOSXClipboard.c | 4 +- macosx/tkMacOSXColor.c | 47 ++- macosx/tkMacOSXCursor.c | 4 +- macosx/tkMacOSXDebug.c | 20 +- macosx/tkMacOSXDebug.h | 4 +- macosx/tkMacOSXDialog.c | 10 +- macosx/tkMacOSXDraw.c | 753 ++++++++++++++++++++---------------------- macosx/tkMacOSXEntry.c | 4 +- macosx/tkMacOSXEvent.c | 4 +- macosx/tkMacOSXFont.c | 9 +- macosx/tkMacOSXHLEvents.c | 4 +- macosx/tkMacOSXInit.c | 4 +- macosx/tkMacOSXInt.h | 280 +--------------- macosx/tkMacOSXKeyEvent.c | 8 +- macosx/tkMacOSXMenu.c | 21 +- macosx/tkMacOSXMenubutton.c | 16 +- macosx/tkMacOSXMenus.c | 4 +- macosx/tkMacOSXMouseEvent.c | 14 +- macosx/tkMacOSXNotify.c | 4 +- macosx/tkMacOSXPrivate.h | 298 +++++++++++++++++ macosx/tkMacOSXRegion.c | 24 +- macosx/tkMacOSXScale.c | 6 +- macosx/tkMacOSXScrlbr.c | 34 +- macosx/tkMacOSXSubwindows.c | 262 +++++++-------- macosx/tkMacOSXWindowEvent.c | 37 ++- macosx/tkMacOSXWm.c | 30 +- macosx/tkMacOSXXStubs.c | 11 +- macosx/ttkMacOSXTheme.c | 4 +- 31 files changed, 1060 insertions(+), 966 deletions(-) create mode 100644 macosx/tkMacOSXPrivate.h diff --git a/ChangeLog b/ChangeLog index 1164f2f..0a16a05 100644 --- a/ChangeLog +++ b/ChangeLog @@ -1,3 +1,87 @@ +2007-06-29 Daniel Steffen + + * xlib/ximage.c: bitmaps created from the static .xbm + arrays always have LSBFirst bit order. + + * unix/configure.in: fix flag used to weak-link libXss. + * unix/configure: autoconf-2.59 + + * macosx/tkMacOSXScrlbr.c: correct int <-> dobule conversion issues + that could lead to Carbon getting confused about scrollbar thumb size. + + * macosx/tkMacOSXDraw.c (XCopyArea, XCopyPlane, TkPutImage) use + TkMacOSX{Setup,Restore}DrawingContext() to setup/restore clip & colors. + (TkMacOSXSetupDrawingContext, TkMacOSXRestoreDrawingContext): add save + and restore of QD port clip region; factor out clip region code common + to CG and QD branches; check for port and context validity; handle + tkPictureIsOpen flag during QD port setup. + (TkScrollWindow): remove unnecessary scroll region manipulation + + * macosx/tkMacOSXDraw.c: remove second global QD temp region + * macosx/tkMacOSXInt.h: (no longer necessary) and rename + * macosx/tkMacOSXRegion.c: remaining global QD temp region. + * macosx/tkMacOSXSubwindows.c: + * macosx/tkMacOSXWindowEvent.c: + + * macosx/tkMacOSXDraw.c: make useCGDrawing variable MODULE_SCOPE + * macosx/tkMacOSXFont.c: and respect it for ATSUI font drawing. + + * macosx/tkMacOSXButton.c: reduce reliance on current QD port + * macosx/tkMacOSXColor.c: setting and remove unnecessary + * macosx/tkMacOSXDebug.c: references to a drawable's QD port, + * macosx/tkMacOSXDebug.h: notably replace GetWindowFromPort( + * macosx/tkMacOSXDialog.c: TkMacOSXGetDrawablePort()) idiom by new + * macosx/tkMacOSXDraw.c: TkMacOSXDrawableWindow() and change + * macosx/tkMacOSXKeyEvent.c: TkMacOSXSetColorInPort() to take a port + * macosx/tkMacOSXMenu.c: argument. + * macosx/tkMacOSXMenubutton.c: + * macosx/tkMacOSXMouseEvent.c: + * macosx/tkMacOSXScale.c: + * macosx/tkMacOSXScrlbr.c: + * macosx/tkMacOSXSubwindows.c: + * macosx/tkMacOSXWindowEvent.c: + * macosx/tkMacOSXWm.c: + + * macosx/tkMacOSXInt.h: factor out macros, declarations + * macosx/tkMacOSXPrivate.h (new): and prototypes that are purely + internal and private to the 'macosx' sources into a new internal header + file that does _not_ get installed into Tk.framework/PrivateHeaders. + + * macosx/tkMacOSXButton.c: #include new tkMacOSXPrivate.h + * macosx/tkMacOSXCarbonEvents.c: instead of tkMacOSXInt.h. + * macosx/tkMacOSXClipboard.c: + * macosx/tkMacOSXColor.c: + * macosx/tkMacOSXCursor.c: + * macosx/tkMacOSXDebug.c: + * macosx/tkMacOSXDialog.c: + * macosx/tkMacOSXDraw.c: + * macosx/tkMacOSXEntry.c: + * macosx/tkMacOSXEvent.c: + * macosx/tkMacOSXFont.c: + * macosx/tkMacOSXHLEvents.c: + * macosx/tkMacOSXInit.c: + * macosx/tkMacOSXKeyEvent.c: + * macosx/tkMacOSXMenu.c: + * macosx/tkMacOSXMenubutton.c: + * macosx/tkMacOSXMenus.c: + * macosx/tkMacOSXMouseEvent.c: + * macosx/tkMacOSXNotify.c: + * macosx/tkMacOSXRegion.c: + * macosx/tkMacOSXScale.c: + * macosx/tkMacOSXScrlbr.c: + * macosx/tkMacOSXSubwindows.c: + * macosx/tkMacOSXWindowEvent.c: + * macosx/tkMacOSXWm.c: + * macosx/tkMacOSXXStubs.c: + * macosx/ttkMacOSXTheme.c: + + * macosx/Wish.xcodeproj/project.pbxproj: improve support for renamed + * macosx/Wish.xcodeproj/default.pbxuser: tcl and tk source dirs; add + * macosx/Wish-Common.xcconfig: 10.5 SDK build config; remove + tclMathOp.c. + + * macosx/README: document Wish.xcodeproj changes. + 2007-06-23 Daniel Steffen * generic/tkImgPhoto.c (ImgPhotoConfigureInstance, DisposeInstance): diff --git a/macosx/tkMacOSXButton.c b/macosx/tkMacOSXButton.c index c8f4fb0..652b11a 100644 --- a/macosx/tkMacOSXButton.c +++ b/macosx/tkMacOSXButton.c @@ -11,10 +11,10 @@ * See the file "license.terms" for information on usage and redistribution * of this file, and for a DISCLAIMER OF ALL WARRANTIES. * - * RCS: @(#) $Id: tkMacOSXButton.c,v 1.26 2007/05/31 13:38:13 das Exp $ + * RCS: @(#) $Id: tkMacOSXButton.c,v 1.27 2007/06/29 03:20:00 das Exp $ */ -#include "tkMacOSXInt.h" +#include "tkMacOSXPrivate.h" #include "tkButton.h" #include "tkMacOSXFont.h" #include "tkMacOSXDebug.h" @@ -797,8 +797,7 @@ TkMacOSXInitControl( SInt32 controlReference; rootControl = TkMacOSXGetRootControl(Tk_WindowId(butPtr->tkwin)); - mbPtr->windowRef = GetWindowFromPort( - TkMacOSXGetDrawablePort(Tk_WindowId(butPtr->tkwin))); + mbPtr->windowRef = TkMacOSXDrawableWindow(Tk_WindowId(butPtr->tkwin)); /* * Set up the user pane. @@ -1251,9 +1250,11 @@ UserPaneDraw( { MacButton *mbPtr = (MacButton *)(intptr_t)GetControlReference(control); Rect contrlRect; - + CGrafPtr port; + + GetPort(&port); GetControlBounds(control,&contrlRect); - TkMacOSXSetColorInPort(mbPtr->userPaneBackground, 0, NULL); + TkMacOSXSetColorInPort(mbPtr->userPaneBackground, 0, NULL, port); EraseRect(&contrlRect); } @@ -1282,7 +1283,10 @@ UserPaneBackgroundProc( MacButton * mbPtr = (MacButton *)(intptr_t)GetControlReference(control); if (info->colorDevice) { - TkMacOSXSetColorInPort(mbPtr->userPaneBackground, 0, NULL); + CGrafPtr port; + + GetPort(&port); + TkMacOSXSetColorInPort(mbPtr->userPaneBackground, 0, NULL, port); } } diff --git a/macosx/tkMacOSXCarbonEvents.c b/macosx/tkMacOSXCarbonEvents.c index a6916bc..6b28cf3 100644 --- a/macosx/tkMacOSXCarbonEvents.c +++ b/macosx/tkMacOSXCarbonEvents.c @@ -60,10 +60,10 @@ * software in accordance with the terms specified in this * license. * - * RCS: @(#) $Id: tkMacOSXCarbonEvents.c,v 1.16 2007/04/23 21:24:33 das Exp $ + * RCS: @(#) $Id: tkMacOSXCarbonEvents.c,v 1.17 2007/06/29 03:20:00 das Exp $ */ -#include "tkMacOSXInt.h" +#include "tkMacOSXPrivate.h" #include "tkMacOSXEvent.h" #include "tkMacOSXDebug.h" diff --git a/macosx/tkMacOSXClipboard.c b/macosx/tkMacOSXClipboard.c index 635d51b..2a8ea8e 100644 --- a/macosx/tkMacOSXClipboard.c +++ b/macosx/tkMacOSXClipboard.c @@ -10,10 +10,10 @@ * See the file "license.terms" for information on usage and redistribution * of this file, and for a DISCLAIMER OF ALL WARRANTIES. * - * RCS: @(#) $Id: tkMacOSXClipboard.c,v 1.10 2007/04/23 21:24:33 das Exp $ + * RCS: @(#) $Id: tkMacOSXClipboard.c,v 1.11 2007/06/29 03:20:00 das Exp $ */ -#include "tkMacOSXInt.h" +#include "tkMacOSXPrivate.h" #include "tkSelect.h" diff --git a/macosx/tkMacOSXColor.c b/macosx/tkMacOSXColor.c index 2194b7a..61403ab 100644 --- a/macosx/tkMacOSXColor.c +++ b/macosx/tkMacOSXColor.c @@ -13,10 +13,10 @@ * See the file "license.terms" for information on usage and redistribution * of this file, and for a DISCLAIMER OF ALL WARRANTIES. * - * RCS: @(#) $Id: tkMacOSXColor.c,v 1.11 2007/06/09 17:09:39 das Exp $ + * RCS: @(#) $Id: tkMacOSXColor.c,v 1.12 2007/06/29 03:20:00 das Exp $ */ -#include "tkMacOSXInt.h" +#include "tkMacOSXPrivate.h" #include "tkColor.h" #if MAC_OS_X_VERSION_MIN_REQUIRED < 1040 @@ -198,8 +198,11 @@ static const struct SystemColorMapEntry systemColorMap[] = { */ static int -GetThemeFromPixelCode(unsigned char code, ThemeBrush *brush, - ThemeTextColor *textColor, ThemeBackgroundKind *background) +GetThemeFromPixelCode( + unsigned char code, + ThemeBrush *brush, + ThemeTextColor *textColor, + ThemeBackgroundKind *background) { if (code >= MIN_PIXELCODE && code <= MAX_PIXELCODE && code != PIXEL_MAGIC) { *brush = systemColorMap[code - MIN_PIXELCODE].brush; @@ -234,8 +237,12 @@ GetThemeFromPixelCode(unsigned char code, ThemeBrush *brush, */ static OSStatus -GetThemeColor(unsigned long pixel, ThemeBrush brush, ThemeTextColor textColor, - ThemeBackgroundKind background, RGBColor *c) +GetThemeColor( + unsigned long pixel, + ThemeBrush brush, + ThemeTextColor textColor, + ThemeBackgroundKind background, + RGBColor *c) { OSStatus err = noErr; @@ -308,25 +315,32 @@ TkSetMacColor( */ void -TkMacOSXSetColorInPort(unsigned long pixel, int fg, PixPatHandle penPat) +TkMacOSXSetColorInPort( + unsigned long pixel, + int fg, + PixPatHandle penPat, + CGrafPtr port) { OSStatus err; RGBColor c; ThemeBrush brush; ThemeTextColor textColor; ThemeBackgroundKind background; + int setPenPat = 0; if (GetThemeFromPixelCode((pixel >> 24) & 0xff, &brush, &textColor, &background)) { - CGrafPtr port; + CGrafPtr savePort; + Boolean portChanged; - GetPort(&port); + portChanged = QDSwapPort(port, &savePort); err = ChkErr(GetThemeColor, pixel, brush, textColor, background, &c); if (err == noErr) { if (fg) { RGBForeColor(&c); if (penPat) { MakeRGBPat(penPat, &c); + setPenPat = 1; } } else { RGBBackColor(&c); @@ -346,9 +360,16 @@ TkMacOSXSetColorInPort(unsigned long pixel, int fg, PixPatHandle penPat) err = ChkErr(ApplyThemeBackground, background, &bounds, kThemeStateActive, 32, true); } - if (penPat && err == noErr && !textColor) { + if (penPat && err == noErr && (brush || background)) { GetPortBackPixPat(port, penPat); + setPenPat = 1; } + if (portChanged) { + QDSwapPort(savePort, NULL); + } + } + if (penPat && !setPenPat) { + GetPortBackPixPat(port, penPat); } } @@ -372,7 +393,9 @@ TkMacOSXSetColorInPort(unsigned long pixel, int fg, PixPatHandle penPat) */ void -TkMacOSXSetColorInContext(unsigned long pixel, CGContextRef context) +TkMacOSXSetColorInContext( + unsigned long pixel, + CGContextRef context) { OSStatus err = -1; RGBColor c; @@ -447,7 +470,7 @@ TkMacOSXSetColorInContext(unsigned long pixel, CGContextRef context) ) TK_ENDIF } portChanged = QDSwapPort(patGWorld, &savePort); - TkMacOSXSetColorInPort(pixel, 1, pixpat); + TkMacOSXSetColorInPort(pixel, 1, pixpat, patGWorld); #ifdef TK_MAC_DEBUG Rect patBounds; GetPixBounds((**pixpat).patMap, &patBounds); diff --git a/macosx/tkMacOSXCursor.c b/macosx/tkMacOSXCursor.c index bbb72e1..4838d7f 100644 --- a/macosx/tkMacOSXCursor.c +++ b/macosx/tkMacOSXCursor.c @@ -10,10 +10,10 @@ * See the file "license.terms" for information on usage and redistribution * of this file, and for a DISCLAIMER OF ALL WARRANTIES. * - * RCS: @(#) $Id: tkMacOSXCursor.c,v 1.11 2007/04/23 21:24:33 das Exp $ + * RCS: @(#) $Id: tkMacOSXCursor.c,v 1.12 2007/06/29 03:20:00 das Exp $ */ -#include "tkMacOSXInt.h" +#include "tkMacOSXPrivate.h" /* * There are three different ways to set the cursor on the Mac. diff --git a/macosx/tkMacOSXDebug.c b/macosx/tkMacOSXDebug.c index 7d1fae6..bceddab 100644 --- a/macosx/tkMacOSXDebug.c +++ b/macosx/tkMacOSXDebug.c @@ -54,10 +54,10 @@ * software in accordance with the terms specified in this * license. * - * RCS: @(#) $Id: tkMacOSXDebug.c,v 1.13 2007/05/30 06:35:54 das Exp $ + * RCS: @(#) $Id: tkMacOSXDebug.c,v 1.14 2007/06/29 03:20:00 das Exp $ */ -#include "tkMacOSXInt.h" +#include "tkMacOSXPrivate.h" #include "tkMacOSXDebug.h" #ifdef TK_MAC_DEBUG @@ -455,17 +455,21 @@ TkMacOSXMouseTrackingResultToAscii(MouseTrackingResult r, char * buf) MODULE_SCOPE void TkMacOSXDebugFlashRegion( - CGrafPtr port, + Drawable d, RgnHandle rgn) { TkMacOSXInitNamedDebugSymbol(HIToolbox, int, QDDebugFlashRegion, CGrafPtr port, RgnHandle region); - if (port && rgn && QDDebugFlashRegion) { - /* - * Carbon-internal region flashing SPI (c.f. Technote 2124) - */ + if (d && rgn && QDDebugFlashRegion && !EmptyRgn(rgn)) { + CGrafPtr port = TkMacOSXGetDrawablePort(d); - QDDebugFlashRegion(port, rgn); + if (port) { + /* + * Carbon-internal region flashing SPI (c.f. Technote 2124) + */ + + QDDebugFlashRegion(port, rgn); + } } } diff --git a/macosx/tkMacOSXDebug.h b/macosx/tkMacOSXDebug.h index a77ad9f..7ef4834 100644 --- a/macosx/tkMacOSXDebug.h +++ b/macosx/tkMacOSXDebug.h @@ -54,7 +54,7 @@ * software in accordance with the terms specified in this * license. * - * RCS: @(#) $Id: tkMacOSXDebug.h,v 1.11 2007/05/30 06:35:54 das Exp $ + * RCS: @(#) $Id: tkMacOSXDebug.h,v 1.12 2007/06/29 03:20:00 das Exp $ */ #ifndef _TKMACDEBUG @@ -82,7 +82,7 @@ MODULE_SCOPE char* TkMacOSXMenuMessageToAscii(int msg, char * s); MODULE_SCOPE char* TkMacOSXMouseTrackingResultToAscii(MouseTrackingResult r, char * buf ); #endif -MODULE_SCOPE void TkMacOSXDebugFlashRegion(CGrafPtr port, RgnHandle rgn); +MODULE_SCOPE void TkMacOSXDebugFlashRegion(Drawable d, RgnHandle rgn); MODULE_SCOPE void* TkMacOSXGetNamedDebugSymbol(const char* module, const char* symbol); diff --git a/macosx/tkMacOSXDialog.c b/macosx/tkMacOSXDialog.c index f8be9d0..a99242f 100644 --- a/macosx/tkMacOSXDialog.c +++ b/macosx/tkMacOSXDialog.c @@ -10,10 +10,10 @@ * See the file "license.terms" for information on usage and redistribution * of this file, and for a DISCLAIMER OF ALL WARRANTIES. * - * RCS: @(#) $Id: tkMacOSXDialog.c,v 1.26 2007/06/23 00:26:32 das Exp $ + * RCS: @(#) $Id: tkMacOSXDialog.c,v 1.27 2007/06/29 03:20:01 das Exp $ */ -#include "tkMacOSXInt.h" +#include "tkMacOSXPrivate.h" #include "tkFileFilter.h" #ifndef StrLength @@ -774,8 +774,7 @@ NavServicesGetFile( options.modality = kWindowModalityAppModal; if (parent && ((TkWindow*)parent)->window != None && TkMacOSXHostToplevelExists(parent)) { - options.parentWindow = GetWindowFromPort(TkMacOSXGetDrawablePort( - Tk_WindowId(parent))); + options.parentWindow = TkMacOSXDrawableWindow(Tk_WindowId(parent)); TK_IF_HI_TOOLBOX (5, /* * Impossible to modify dialog modality with the Cocoa-based @@ -1568,8 +1567,7 @@ Tk_MessageBoxObjCmd( if (!handler) { handler = NewEventHandlerUPP(AlertHandler); } - windowRef = GetWindowFromPort(TkMacOSXGetDrawablePort( - Tk_WindowId(tkwin))); + windowRef = TkMacOSXDrawableWindow(Tk_WindowId(tkwin)); if (!windowRef) { goto end; } diff --git a/macosx/tkMacOSXDraw.c b/macosx/tkMacOSXDraw.c index a5c00d6..cda02aa 100644 --- a/macosx/tkMacOSXDraw.c +++ b/macosx/tkMacOSXDraw.c @@ -12,10 +12,10 @@ * See the file "license.terms" for information on usage and redistribution * of this file, and for a DISCLAIMER OF ALL WARRANTIES. * - * RCS: @(#) $Id: tkMacOSXDraw.c,v 1.26 2007/06/09 17:09:40 das Exp $ + * RCS: @(#) $Id: tkMacOSXDraw.c,v 1.27 2007/06/29 03:20:01 das Exp $ */ -#include "tkMacOSXInt.h" +#include "tkMacOSXPrivate.h" #include "tkMacOSXDebug.h" /* @@ -33,17 +33,17 @@ #define NON_AA_CG_OFFSET .999 /* - * Temporary regions that can be reused. + * Temporary region that can be reused. */ -RgnHandle tkMacOSXtmpRgn1 = NULL; -RgnHandle tkMacOSXtmpRgn2 = NULL; +RgnHandle tkMacOSXtmpQdRgn = NULL; + +int tkMacOSXUseCGDrawing = 1; static PixPatHandle penPat = NULL; -static int useCGDrawing = 1; -static int tkMacOSXCGAntiAliasLimit = 0; -#define notAA(w) ((w) < tkMacOSXCGAntiAliasLimit) +static int cgAntiAliasLimit = 0; +#define notAA(w) ((w) < cgAntiAliasLimit) static int useThemedToplevel = 0; static int useThemedFrame = 0; @@ -87,16 +87,16 @@ TkMacOSXInitCGDrawing( Tcl_ResetResult(interp); } if (Tcl_LinkVar(interp, "::tk::mac::useCGDrawing", - (char *) &useCGDrawing, TCL_LINK_BOOLEAN) != TCL_OK) { + (char *) &tkMacOSXUseCGDrawing, TCL_LINK_BOOLEAN) != TCL_OK) { Tcl_ResetResult(interp); } - useCGDrawing = enable; + tkMacOSXUseCGDrawing = enable; if (Tcl_LinkVar(interp, "::tk::mac::CGAntialiasLimit", - (char *) &tkMacOSXCGAntiAliasLimit, TCL_LINK_INT) != TCL_OK) { + (char *) &cgAntiAliasLimit, TCL_LINK_INT) != TCL_OK) { Tcl_ResetResult(interp); } - tkMacOSXCGAntiAliasLimit = limit; + cgAntiAliasLimit = limit; /* * Piggy-back the themed drawing var init here. @@ -111,11 +111,8 @@ TkMacOSXInitCGDrawing( Tcl_ResetResult(interp); } - if (tkMacOSXtmpRgn1 == NULL) { - tkMacOSXtmpRgn1 = NewRgn(); - } - if (tkMacOSXtmpRgn2 == NULL) { - tkMacOSXtmpRgn2 = NewRgn(); + if (tkMacOSXtmpQdRgn == NULL) { + tkMacOSXtmpQdRgn = NewRgn(); } } #ifdef TK_MAC_DEBUG_DRAWING @@ -158,47 +155,37 @@ XCopyArea( int dest_x, /* Dest X & Y on dest rect. */ int dest_y) { - Rect srcRect, dstRect, *srcPtr = &srcRect, *dstPtr = &dstRect; + TkMacOSXDrawingContext dc; MacDrawable *srcDraw = (MacDrawable *) src, *dstDraw = (MacDrawable *) dst; - CGrafPtr srcPort, destPort, savePort; - Boolean portChanged; - const BitMap *srcBit, *dstBit; - RGBColor origForeColor, origBackColor; - RGBColor black = {0, 0, 0}, white = {0xffff, 0xffff, 0xffff}; display->request++; - srcPort = TkMacOSXGetDrawablePort(src); - destPort = TkMacOSXGetDrawablePort(dst); - srcBit = GetPortBitMapForCopyBits(srcPort); - dstBit = GetPortBitMapForCopyBits(destPort); - SetRect(srcPtr, srcDraw->xOff + src_x, srcDraw->yOff + src_y, - srcDraw->xOff + src_x + width, srcDraw->yOff + src_y + height); - TkMacOSXCheckTmpRgnEmpty(2); - GetPortClipRegion(destPort, tkMacOSXtmpRgn2); - if (tkPictureIsOpen) { - dstPtr = srcPtr; - NoQDClip(destPort); - } else { - SetRect(dstPtr, dstDraw->xOff + dest_x, dstDraw->yOff + dest_y, - dstDraw->xOff + dest_x + width, - dstDraw->yOff + dest_y + height); - TkMacOSXSetUpClippingRgn(dst); + if (!width || !height) { + TkMacOSXDbgMsg("Drawing of emtpy area requested"); + return; } - TkMacOSXCheckTmpRgnEmpty(1); - ClipToGC(dst, gc, destPort, tkMacOSXtmpRgn1); - portChanged = QDSwapPort(destPort, &savePort); - GetPortForeColor(destPort, &origForeColor); - GetPortBackColor(destPort, &origBackColor); - RGBForeColor(&black); - RGBBackColor(&white); - CopyBits(srcBit, dstBit, srcPtr, dstPtr, srcCopy, NULL); - RGBForeColor(&origForeColor); - RGBBackColor(&origBackColor); - SetPortClipRegion(destPort, tkMacOSXtmpRgn2); - SetEmptyRgn(tkMacOSXtmpRgn2); - if (portChanged) { - QDSwapPort(savePort, NULL); + if (!TkMacOSXSetupDrawingContext(dst, gc, 0, &dc)) { + Rect srcRect, dstRect, *srcPtr = &srcRect, *dstPtr = &dstRect; + CGrafPtr srcPort; + const BitMap *srcBit, *dstBit; + RGBColor black = {0, 0, 0}, white = {0xffff, 0xffff, 0xffff}; + + srcPort = TkMacOSXGetDrawablePort(src); + srcBit = GetPortBitMapForCopyBits(srcPort); + dstBit = GetPortBitMapForCopyBits(dc.port); + SetRect(srcPtr, srcDraw->xOff + src_x, srcDraw->yOff + src_y, + srcDraw->xOff + src_x + width, srcDraw->yOff + src_y + height); + if (tkPictureIsOpen) { + dstPtr = srcPtr; + } else { + SetRect(dstPtr, dstDraw->xOff + dest_x, dstDraw->yOff + dest_y, + dstDraw->xOff + dest_x + width, + dstDraw->yOff + dest_y + height); + } + RGBForeColor(&black); + RGBBackColor(&white); + CopyBits(srcBit, dstBit, srcPtr, dstPtr, srcCopy, NULL); } + TkMacOSXRestoreDrawingContext(&dc); } /* @@ -234,76 +221,66 @@ XCopyPlane( int dest_y, unsigned long plane) /* Which plane to copy. */ { - Rect srcRect, dstRect, *srcPtr = &srcRect, *dstPtr = &dstRect; + TkMacOSXDrawingContext dc; MacDrawable *srcDraw = (MacDrawable *) src, *dstDraw = (MacDrawable *) dst; - CGrafPtr srcPort, destPort, savePort; - Boolean portChanged; - const BitMap *srcBit, *dstBit; - RGBColor origForeColor, origBackColor; - TkpClipMask *clipPtr = (TkpClipMask *) gc->clip_mask; display->request++; - srcPort = TkMacOSXGetDrawablePort(src); - destPort = TkMacOSXGetDrawablePort(dst); - srcBit = GetPortBitMapForCopyBits(srcPort); - dstBit = GetPortBitMapForCopyBits(destPort); - SetRect(srcPtr, srcDraw->xOff + src_x, srcDraw->yOff + src_y, - srcDraw->xOff + src_x + width, srcDraw->yOff + src_y + height); - TkMacOSXCheckTmpRgnEmpty(2); - GetPortClipRegion(destPort, tkMacOSXtmpRgn2); - if (tkPictureIsOpen) { - dstPtr = srcPtr; - NoQDClip(destPort); - } else { - SetRect(dstPtr, dstDraw->xOff + dest_x, dstDraw->yOff + dest_y, - dstDraw->xOff + dest_x + width, - dstDraw->yOff + dest_y + height); - TkMacOSXSetUpClippingRgn(dst); + if (!width || !height) { + TkMacOSXDbgMsg("Drawing of emtpy area requested"); + return; } - TkMacOSXCheckTmpRgnEmpty(1); - GetPortClipRegion(destPort, tkMacOSXtmpRgn1); - ClipToGC(dst, gc, destPort, tkMacOSXtmpRgn1); - SetPortClipRegion(destPort, tkMacOSXtmpRgn1); - SetEmptyRgn(tkMacOSXtmpRgn1); - portChanged = QDSwapPort(destPort, &savePort); - GetPortForeColor(destPort, &origForeColor); - GetPortBackColor(destPort, &origBackColor); - TkMacOSXSetColorInPort(gc->foreground, 1, NULL); - if (!clipPtr || clipPtr->type == TKP_CLIP_REGION) { - /* - * Opaque bitmaps. - */ - - TkMacOSXSetColorInPort(gc->background, 0, NULL); - CopyBits(srcBit, dstBit, srcPtr, dstPtr, srcCopy, NULL); - } else if (clipPtr->type == TKP_CLIP_PIXMAP) { - if (clipPtr->value.pixmap == src) { - /* - * Transparent bitmaps. If it's color we ignore the forecolor. - */ - short tmode = GetPixDepth(GetPortPixMap(srcPort)) == 1 ? - srcOr : transparent; - - CopyBits(srcBit, dstBit, srcPtr, dstPtr, tmode, NULL); + if (plane != 1) { + Tcl_Panic("Unexpected plane specified for XCopyPlane"); + } + if (!TkMacOSXSetupDrawingContext(dst, gc, 0, &dc)) { + Rect srcRect, dstRect, *srcPtr = &srcRect, *dstPtr = &dstRect; + CGrafPtr srcPort; + const BitMap *srcBit, *dstBit; + TkpClipMask *clipPtr = (TkpClipMask *) gc->clip_mask; + + srcPort = TkMacOSXGetDrawablePort(src); + srcBit = GetPortBitMapForCopyBits(srcPort); + dstBit = GetPortBitMapForCopyBits(dc.port); + SetRect(srcPtr, srcDraw->xOff + src_x, srcDraw->yOff + src_y, + srcDraw->xOff + src_x + width, srcDraw->yOff + src_y + height); + if (tkPictureIsOpen) { + dstPtr = srcPtr; } else { + SetRect(dstPtr, dstDraw->xOff + dest_x, dstDraw->yOff + dest_y, + dstDraw->xOff + dest_x + width, + dstDraw->yOff + dest_y + height); + } + TkMacOSXSetColorInPort(gc->foreground, 1, NULL, dc.port); + if (!clipPtr || clipPtr->type == TKP_CLIP_REGION) { /* - * Two arbitrary bitmaps. + * Opaque bitmaps. */ - CGrafPtr mskPort = TkMacOSXGetDrawablePort(clipPtr->value.pixmap); - const BitMap *mskBit = GetPortBitMapForCopyBits(mskPort); + TkMacOSXSetColorInPort(gc->background, 0, NULL, dc.port); + CopyBits(srcBit, dstBit, srcPtr, dstPtr, srcCopy, NULL); + } else if (clipPtr->type == TKP_CLIP_PIXMAP) { + if (clipPtr->value.pixmap == src) { + /* + * Transparent bitmaps. If it's color we ignore the forecolor. + */ + short tmode = GetPixDepth(GetPortPixMap(srcPort)) == 1 ? + srcOr : transparent; - CopyDeepMask(srcBit, mskBit, dstBit, srcPtr, srcPtr, dstPtr, - srcCopy, NULL); + CopyBits(srcBit, dstBit, srcPtr, dstPtr, tmode, NULL); + } else { + /* + * Two arbitrary bitmaps. + */ + + CGrafPtr mskPort = TkMacOSXGetDrawablePort(clipPtr->value.pixmap); + const BitMap *mskBit = GetPortBitMapForCopyBits(mskPort); + + CopyDeepMask(srcBit, mskBit, dstBit, srcPtr, srcPtr, dstPtr, + srcCopy, NULL); + } } } - RGBForeColor(&origForeColor); - RGBBackColor(&origBackColor); - SetPortClipRegion(destPort, tkMacOSXtmpRgn2); - SetEmptyRgn(tkMacOSXtmpRgn2); - if (portChanged) { - QDSwapPort(savePort, NULL); - } + TkMacOSXRestoreDrawingContext(&dc); } /* @@ -338,184 +315,169 @@ TkPutImage( unsigned int width, /* Same width & height for both */ unsigned int height) /* distination and source. */ { - Rect srcRect, dstRect, *srcPtr = &srcRect, *dstPtr = &dstRect; + TkMacOSXDrawingContext dc; MacDrawable *dstDraw = (MacDrawable *) d; - CGrafPtr destPort, savePort; - Boolean portChanged; - const BitMap *dstBit; - RGBColor origForeColor, origBackColor; - RGBColor black = {0, 0, 0}, white = {0xffff, 0xffff, 0xffff}; - int i, j; - char *newData = NULL; - char *dataPtr, *newPtr, *oldPtr; - int rowBytes = image->bytes_per_line; - int slices, sliceRowBytes, lastSliceRowBytes, sliceWidth, lastSliceWidth; display->request++; - destPort = TkMacOSXGetDrawablePort(d); - dstBit = GetPortBitMapForCopyBits(destPort); - SetRect(srcPtr, src_x, src_y, src_x + width, src_y + height); - TkMacOSXCheckTmpRgnEmpty(2); - GetPortClipRegion(destPort, tkMacOSXtmpRgn2); - if (tkPictureIsOpen) { - dstPtr = srcPtr; - NoQDClip(destPort); - } else { - SetRect(dstPtr, dstDraw->xOff + dest_x, dstDraw->yOff + dest_y, - dstDraw->xOff + dest_x + width, - dstDraw->yOff + dest_y + height); - TkMacOSXSetUpClippingRgn(d); - } - TkMacOSXCheckTmpRgnEmpty(1); - ClipToGC(d, gc, destPort, tkMacOSXtmpRgn1); - portChanged = QDSwapPort(destPort, &savePort); - GetPortForeColor(destPort, &origForeColor); - GetPortBackColor(destPort, &origBackColor); - RGBForeColor(&black); - RGBBackColor(&white); - if (image->obdata) { - /* - * Image from XGetImage, copy from containing GWorld directly. - */ - - CopyBits(GetPortBitMapForCopyBits(TkMacOSXGetDrawablePort((Drawable) - image->obdata)), dstBit, srcPtr, dstPtr, srcCopy, NULL); - } else if (image->depth == 1) { - /* - * BW image - */ - - const int maxRowBytes = 0x3ffe; - BitMap bitmap; - int odd; - - if (rowBytes > maxRowBytes) { - slices = rowBytes / maxRowBytes; - sliceRowBytes = maxRowBytes; - lastSliceRowBytes = rowBytes - (slices * maxRowBytes); - if (!lastSliceRowBytes) { - slices--; - lastSliceRowBytes = maxRowBytes; - } - sliceWidth = (long) image->width * maxRowBytes / rowBytes; - lastSliceWidth = image->width - (sliceWidth * slices); + if (!TkMacOSXSetupDrawingContext(d, gc, 0, &dc)) { + Rect srcRect, dstRect, *srcPtr = &srcRect, *dstPtr = &dstRect; + const BitMap *dstBit; + RGBColor black = {0, 0, 0}, white = {0xffff, 0xffff, 0xffff}; + int i, j; + char *newData = NULL; + char *dataPtr, *newPtr, *oldPtr; + int rowBytes = image->bytes_per_line; + int slices, sliceRowBytes, lastSliceRowBytes, sliceWidth, lastSliceWidth; + + dstBit = GetPortBitMapForCopyBits(dc.port); + SetRect(srcPtr, src_x, src_y, src_x + width, src_y + height); + if (tkPictureIsOpen) { + dstPtr = srcPtr; } else { - slices = 0; - sliceRowBytes = lastSliceRowBytes = rowBytes; - sliceWidth = lastSliceWidth = image->width; + SetRect(dstPtr, dstDraw->xOff + dest_x, dstDraw->yOff + dest_y, + dstDraw->xOff + dest_x + width, + dstDraw->yOff + dest_y + height); } - bitmap.bounds.top = bitmap.bounds.left = 0; - bitmap.bounds.bottom = (short) image->height; - dataPtr = image->data; - do { - if (slices) { - bitmap.bounds.right = bitmap.bounds.left + sliceWidth; - } else { - sliceRowBytes = lastSliceRowBytes; - bitmap.bounds.right = bitmap.bounds.left + lastSliceWidth; - } - oldPtr = dataPtr; - odd = sliceRowBytes % 2; - if (!newData) { - newData = ckalloc(image->height * (sliceRowBytes+odd)); - } - newPtr = newData; - for (i = 0; i < image->height; i++) { - for (j = 0; j < sliceRowBytes; j++) { - *newPtr = InvertByte((unsigned char) *oldPtr); - newPtr++; oldPtr++; - } - if (odd) { - *newPtr++ = 0; - } - oldPtr += rowBytes - sliceRowBytes; - } - bitmap.baseAddr = newData; - bitmap.rowBytes = sliceRowBytes + odd; - CopyBits(&bitmap, dstBit, srcPtr, dstPtr, srcCopy, NULL); - if (slices) { - bitmap.bounds.left = bitmap.bounds.right; - dataPtr += sliceRowBytes; - } - } while (slices--); - ckfree(newData); - } else { - /* - * Color image - */ + RGBForeColor(&black); + RGBBackColor(&white); + if (image->obdata) { + /* + * Image from XGetImage, copy from containing GWorld directly. + */ - const int maxRowBytes = 0x3ffc; - PixMap pixmap; - - pixmap.bounds.left = 0; - pixmap.bounds.top = 0; - pixmap.bounds.bottom = (short) image->height; - pixmap.pixelType = RGBDirect; - pixmap.pmVersion = baseAddr32; /* 32bit clean */ - pixmap.packType = 0; - pixmap.packSize = 0; - pixmap.hRes = 0x00480000; - pixmap.vRes = 0x00480000; - pixmap.pixelSize = 32; - pixmap.cmpCount = 3; - pixmap.cmpSize = 8; -#ifdef WORDS_BIGENDIAN - pixmap.pixelFormat = k32ARGBPixelFormat; -#else - pixmap.pixelFormat = k32BGRAPixelFormat; -#endif - pixmap.pmTable = NULL; - pixmap.pmExt = 0; - if (rowBytes > maxRowBytes) { - slices = rowBytes / maxRowBytes; - sliceRowBytes = maxRowBytes; - lastSliceRowBytes = rowBytes - (slices * maxRowBytes); - if (!lastSliceRowBytes) { - slices--; - lastSliceRowBytes = maxRowBytes; + CopyBits(GetPortBitMapForCopyBits(TkMacOSXGetDrawablePort((Drawable) + image->obdata)), dstBit, srcPtr, dstPtr, srcCopy, NULL); + } else if (image->depth == 1) { + /* + * BW image + */ + + const int maxRowBytes = 0x3ffe; + BitMap bitmap; + int odd; + + if (rowBytes > maxRowBytes) { + slices = rowBytes / maxRowBytes; + sliceRowBytes = maxRowBytes; + lastSliceRowBytes = rowBytes - (slices * maxRowBytes); + if (!lastSliceRowBytes) { + slices--; + lastSliceRowBytes = maxRowBytes; + } + sliceWidth = (long) image->width * maxRowBytes / rowBytes; + lastSliceWidth = image->width - (sliceWidth * slices); + } else { + slices = 0; + sliceRowBytes = lastSliceRowBytes = rowBytes; + sliceWidth = lastSliceWidth = image->width; } - sliceWidth = (long) image->width * maxRowBytes / rowBytes; - lastSliceWidth = image->width - (sliceWidth * slices); + bitmap.bounds.top = bitmap.bounds.left = 0; + bitmap.bounds.bottom = (short) image->height; dataPtr = image->data; - newData = (char *) ckalloc(image->height * sliceRowBytes); do { if (slices) { - pixmap.bounds.right = pixmap.bounds.left + sliceWidth; + bitmap.bounds.right = bitmap.bounds.left + sliceWidth; } else { sliceRowBytes = lastSliceRowBytes; - pixmap.bounds.right = pixmap.bounds.left + lastSliceWidth; + bitmap.bounds.right = bitmap.bounds.left + lastSliceWidth; } oldPtr = dataPtr; + odd = sliceRowBytes % 2; + if (!newData) { + newData = ckalloc(image->height * (sliceRowBytes+odd)); + } newPtr = newData; for (i = 0; i < image->height; i++) { - memcpy(newPtr, oldPtr, sliceRowBytes); - oldPtr += rowBytes; - newPtr += sliceRowBytes; + for (j = 0; j < sliceRowBytes; j++) { + *newPtr = InvertByte((unsigned char) *oldPtr); + newPtr++; oldPtr++; + } + if (odd) { + *newPtr++ = 0; + } + oldPtr += rowBytes - sliceRowBytes; } - pixmap.baseAddr = newData; - pixmap.rowBytes = sliceRowBytes | 0x8000; - CopyBits((BitMap*) &pixmap, dstBit, srcPtr, dstPtr, srcCopy, - NULL); + bitmap.baseAddr = newData; + bitmap.rowBytes = sliceRowBytes + odd; + CopyBits(&bitmap, dstBit, srcPtr, dstPtr, srcCopy, NULL); if (slices) { - pixmap.bounds.left = pixmap.bounds.right; + bitmap.bounds.left = bitmap.bounds.right; dataPtr += sliceRowBytes; } } while (slices--); ckfree(newData); } else { - pixmap.bounds.right = (short) image->width; - pixmap.baseAddr = image->data; - pixmap.rowBytes = rowBytes | 0x8000; - CopyBits((BitMap*) &pixmap, dstBit, srcPtr, dstPtr, srcCopy, NULL); + /* + * Color image + */ + + const int maxRowBytes = 0x3ffc; + PixMap pixmap; + + pixmap.bounds.left = 0; + pixmap.bounds.top = 0; + pixmap.bounds.bottom = (short) image->height; + pixmap.pixelType = RGBDirect; + pixmap.pmVersion = baseAddr32; /* 32bit clean */ + pixmap.packType = 0; + pixmap.packSize = 0; + pixmap.hRes = 0x00480000; + pixmap.vRes = 0x00480000; + pixmap.pixelSize = 32; + pixmap.cmpCount = 3; + pixmap.cmpSize = 8; +#ifdef WORDS_BIGENDIAN + pixmap.pixelFormat = k32ARGBPixelFormat; +#else + pixmap.pixelFormat = k32BGRAPixelFormat; +#endif + pixmap.pmTable = NULL; + pixmap.pmExt = 0; + if (rowBytes > maxRowBytes) { + slices = rowBytes / maxRowBytes; + sliceRowBytes = maxRowBytes; + lastSliceRowBytes = rowBytes - (slices * maxRowBytes); + if (!lastSliceRowBytes) { + slices--; + lastSliceRowBytes = maxRowBytes; + } + sliceWidth = (long) image->width * maxRowBytes / rowBytes; + lastSliceWidth = image->width - (sliceWidth * slices); + dataPtr = image->data; + newData = (char *) ckalloc(image->height * sliceRowBytes); + do { + if (slices) { + pixmap.bounds.right = pixmap.bounds.left + sliceWidth; + } else { + sliceRowBytes = lastSliceRowBytes; + pixmap.bounds.right = pixmap.bounds.left + lastSliceWidth; + } + oldPtr = dataPtr; + newPtr = newData; + for (i = 0; i < image->height; i++) { + memcpy(newPtr, oldPtr, sliceRowBytes); + oldPtr += rowBytes; + newPtr += sliceRowBytes; + } + pixmap.baseAddr = newData; + pixmap.rowBytes = sliceRowBytes | 0x8000; + CopyBits((BitMap*) &pixmap, dstBit, srcPtr, dstPtr, srcCopy, + NULL); + if (slices) { + pixmap.bounds.left = pixmap.bounds.right; + dataPtr += sliceRowBytes; + } + } while (slices--); + ckfree(newData); + } else { + pixmap.bounds.right = (short) image->width; + pixmap.baseAddr = image->data; + pixmap.rowBytes = rowBytes | 0x8000; + CopyBits((BitMap*) &pixmap, dstBit, srcPtr, dstPtr, srcCopy, NULL); + } } } - RGBForeColor(&origForeColor); - RGBBackColor(&origBackColor); - SetPortClipRegion(destPort, tkMacOSXtmpRgn2); - SetEmptyRgn(tkMacOSXtmpRgn2); - if (portChanged) { - QDSwapPort(savePort, NULL); - } + TkMacOSXRestoreDrawingContext(&dc); } /* @@ -556,7 +518,7 @@ XDrawLines( } display->request++; - if (TkMacOSXSetupDrawingContext(d, gc, useCGDrawing, &dc)) { + if (TkMacOSXSetupDrawingContext(d, gc, tkMacOSXUseCGDrawing, &dc)) { double prevx, prevy; double o = (lw % 2) ? .5 : 0; @@ -626,7 +588,7 @@ XDrawSegments( int i, lw = gc->line_width; display->request++; - if (TkMacOSXSetupDrawingContext(d, gc, useCGDrawing, &dc)) { + if (TkMacOSXSetupDrawingContext(d, gc, tkMacOSXUseCGDrawing, &dc)) { double o = (lw % 2) ? .5 : 0; for (i = 0; i < nsegments; i++) { @@ -687,7 +649,7 @@ XFillPolygon( int i; display->request++; - if (TkMacOSXSetupDrawingContext(d, gc, useCGDrawing, &dc)) { + if (TkMacOSXSetupDrawingContext(d, gc, tkMacOSXUseCGDrawing, &dc)) { double prevx, prevy; double o = (gc->line_width % 2) ? .5 : 0; @@ -762,7 +724,7 @@ XDrawRectangle( } display->request++; - if (TkMacOSXSetupDrawingContext(d, gc, useCGDrawing, &dc)) { + if (TkMacOSXSetupDrawingContext(d, gc, tkMacOSXUseCGDrawing, &dc)) { CGRect rect; double o = (lw % 2) ? .5 : 0; @@ -825,7 +787,7 @@ XDrawRectangles( int i, lw = gc->line_width; display->request++; - if (TkMacOSXSetupDrawingContext(d, gc, useCGDrawing, &dc)) { + if (TkMacOSXSetupDrawingContext(d, gc, tkMacOSXUseCGDrawing, &dc)) { CGRect rect; double o = (lw % 2) ? .5 : 0; @@ -885,7 +847,7 @@ XFillRectangles( int i; display->request++; - if (TkMacOSXSetupDrawingContext(d, gc, useCGDrawing, &dc)) { + if (TkMacOSXSetupDrawingContext(d, gc, tkMacOSXUseCGDrawing, &dc)) { CGRect rect; for (i = 0, rectPtr = rectangles; i < n_rectangles; i++, rectPtr++) { @@ -948,7 +910,7 @@ XDrawArc( } display->request++; - if (TkMacOSXSetupDrawingContext(d, gc, useCGDrawing, &dc)) { + if (TkMacOSXSetupDrawingContext(d, gc, tkMacOSXUseCGDrawing, &dc)) { CGRect rect; double o = (lw % 2) ? .5 : 0; @@ -1030,7 +992,7 @@ XDrawArcs( int i, lw = gc->line_width; display->request++; - if (TkMacOSXSetupDrawingContext(d, gc, useCGDrawing, &dc)) { + if (TkMacOSXSetupDrawingContext(d, gc, tkMacOSXUseCGDrawing, &dc)) { CGRect rect; double o = (lw % 2) ? .5 : 0; @@ -1123,7 +1085,7 @@ XFillArc( } display->request++; - if (TkMacOSXSetupDrawingContext(d, gc, useCGDrawing, &dc)) { + if (TkMacOSXSetupDrawingContext(d, gc, tkMacOSXUseCGDrawing, &dc)) { CGRect rect; double o = (lw % 2) ? .5 : 0, u = 0; @@ -1237,7 +1199,7 @@ XFillArcs( int i, lw = gc->line_width; display->request++; - if (TkMacOSXSetupDrawingContext(d, gc, useCGDrawing, &dc)) { + if (TkMacOSXSetupDrawingContext(d, gc, tkMacOSXUseCGDrawing, &dc)) { CGRect rect; double o = (lw % 2) ? .5 : 0, u = 0; @@ -1381,7 +1343,7 @@ TkScrollWindow( MacDrawable *destDraw = (MacDrawable *) Tk_WindowId(tkwin); CGrafPtr destPort, savePort; Boolean portChanged; - Rect srcRect, scrollRect; + Rect scrollRect; int result; RgnHandle rgn = (RgnHandle) damageRgn; @@ -1395,11 +1357,10 @@ TkScrollWindow( * destination rects disjoint and non-aligned. */ - SetRect(&scrollRect, (short) (destDraw->xOff + x), - (short) (destDraw->yOff + y), - (short) (destDraw->xOff + x + width), - (short) (destDraw->yOff + y + height)); - srcRect = scrollRect; + scrollRect.left = destDraw->xOff + x; + scrollRect.top = destDraw->yOff + y; + scrollRect.right = scrollRect.left + width; + scrollRect.bottom = scrollRect.top + height; if (dx < 0) { scrollRect.left += dx; } else { @@ -1413,19 +1374,6 @@ TkScrollWindow( destPort = TkMacOSXGetDrawablePort(Tk_WindowId(tkwin)); TkMacOSXSetUpClippingRgn(Tk_WindowId(tkwin)); - TkMacOSXCheckTmpRgnEmpty(1); - TkMacOSXCheckTmpRgnEmpty(2); - RectRgn(rgn, &srcRect); - GetPortVisibleRegion(destPort,tkMacOSXtmpRgn1); - DiffRgn(rgn, tkMacOSXtmpRgn1, rgn); - OffsetRgn(rgn, dx, dy); - GetPortClipRegion(destPort, tkMacOSXtmpRgn2); - DiffRgn(tkMacOSXtmpRgn2, rgn, tkMacOSXtmpRgn2); - SetPortClipRegion(destPort, tkMacOSXtmpRgn2); - SetEmptyRgn(tkMacOSXtmpRgn2); - SetEmptyRgn(tkMacOSXtmpRgn1); - SetEmptyRgn(rgn); - portChanged = QDSwapPort(destPort, &savePort); ScrollRect(&scrollRect, dx, dy, rgn); if (portChanged) { @@ -1470,13 +1418,15 @@ TkMacOSXSetUpGraphicsPort( if (penPat == NULL) { penPat = NewPixPat(); } - TkMacOSXSetColorInPort(gc->foreground, 1, penPat); - PenPixPat(penPat); + TkMacOSXSetColorInPort(gc->foreground, 1, penPat, destPort); + SetPortPenPixPat(destPort, penPat); if(gc->function == GXxor) { - PenMode(patXor); + SetPortPenMode(destPort, patXor); } if (gc->line_width > 1) { - PenSize(gc->line_width, gc->line_width); + Point s = {gc->line_width, gc->line_width}; + + SetPortPenSize(destPort, s); } if (gc->line_style != LineSolid) { /* @@ -1516,13 +1466,21 @@ TkMacOSXSetupDrawingContext( Rect portBounds; dc->saveState = NULL; + dc->saveClip = NULL; dc->penPat = NULL; dc->portChanged = false; port = TkMacOSXGetDrawablePort(d); if (port) { GetPortBounds(port, &portBounds); + dc->saveClip = NewRgn(); + GetPortClipRegion(port, dc->saveClip); + if (tkPictureIsOpen) { + NoQDClip(port); + } else { + TkMacOSXSetUpClippingRgn(d); + } } - if (context) { + if (context && useCG) { if (!port) { TK_IF_MAC_OS_X_API (3, CGContextGetClipBoundingBox, CGRect r = CGContextGetClipBoundingBox(context); @@ -1533,113 +1491,111 @@ TkMacOSXSetupDrawingContext( r.origin.y + r.size.height + macDraw->yOff); ) TK_ENDIF } - TkMacOSXCheckTmpRgnEmpty(1); - RectRgn(tkMacOSXtmpRgn1, &portBounds); - if (port) { - TkMacOSXSetUpClippingRgn(d); - SectRegionWithPortClipRegion(port, tkMacOSXtmpRgn1); - SectRegionWithPortVisibleRegion(port, tkMacOSXtmpRgn1); - } else if (macDraw->flags & TK_CLIPPED_DRAW) { - OffsetRgn(macDraw->drawRgn, macDraw->xOff, macDraw->yOff); - SectRgn(macDraw->clipRgn, macDraw->drawRgn, tkMacOSXtmpRgn1); - OffsetRgn(macDraw->drawRgn, -macDraw->xOff, -macDraw->yOff); - } - ClipToGC(d, gc, NULL, tkMacOSXtmpRgn1); CGContextSaveGState(context); dc->saveState = (void*)1; - ClipCGContextToRegion(context, &portBounds, tkMacOSXtmpRgn1); - SetEmptyRgn(tkMacOSXtmpRgn1); port = NULL; - useCG = 1; } else if (port) { dc->portChanged = QDSwapPort(port, &(dc->savePort)); - TkMacOSXSetUpClippingRgn(d); - if (useCG) { - if (ChkErr(QDBeginCGContext, port, &context) == noErr) { - TkMacOSXCheckTmpRgnEmpty(1); - RectRgn(tkMacOSXtmpRgn1, &portBounds); - SectRegionWithPortClipRegion(port, tkMacOSXtmpRgn1); - SectRegionWithPortVisibleRegion(port, tkMacOSXtmpRgn1); - ClipToGC(d, gc, NULL, tkMacOSXtmpRgn1); - ClipCGContextToRegion(context, &portBounds, tkMacOSXtmpRgn1); - SetEmptyRgn(tkMacOSXtmpRgn1); - SyncCGContextOriginWithPort(context, port); - } else { - context = NULL; - useCG = 0; - } + if (useCG && ChkErr(QDBeginCGContext, port, &context) == noErr) { + SyncCGContextOriginWithPort(context, port); + } else { + context = NULL; + useCG = 0; } } else { Tcl_Panic("TkMacOSXSetupDrawingContext(): " "no port or context to draw into !"); } if (useCG) { - CGContextConcatCTM(context, CGAffineTransformMake(1.0, 0.0, 0.0, -1.0, - 0.0, portBounds.bottom - portBounds.top)); - if (gc) { - double w = gc->line_width; - - TkMacOSXSetColorInContext(gc->foreground, context); + if (tkPictureIsOpen) { + TkMacOSXDbgMsg("Ignored CG Drawing with QD Picture open"); + } else if (context) { + TkMacOSXCheckTmpQdRgnEmpty(); + RectRgn(tkMacOSXtmpQdRgn, &portBounds); if (port) { - CGContextSetPatternPhase(context, CGSizeMake(portBounds.right - - portBounds.left, portBounds.bottom - portBounds.top)); - } - if(gc->function == GXxor) { - TkMacOSXDbgMsg("GXxor mode not supported for CG drawing!"); - } - /* When should we antialias? */ - if (notAA(gc->line_width)) { - /* Make non-antialiased CG drawing look more like X11 */ - w -= (gc->line_width ? NON_AA_CG_OFFSET : 0); - CGContextSetShouldAntialias(context, 0); - } else { - CGContextSetShouldAntialias(context, 1); + SectRegionWithPortClipRegion(port, tkMacOSXtmpQdRgn); + SectRegionWithPortVisibleRegion(port, tkMacOSXtmpQdRgn); + } else if (macDraw->flags & TK_CLIPPED_DRAW) { + OffsetRgn(macDraw->drawRgn, macDraw->xOff, macDraw->yOff); + SectRgn(macDraw->clipRgn, macDraw->drawRgn, tkMacOSXtmpQdRgn); + OffsetRgn(macDraw->drawRgn, -macDraw->xOff, -macDraw->yOff); } - CGContextSetLineWidth(context, w); - if (gc->line_style != LineSolid) { - int num = 0; - char *p = &(gc->dashes); - double dashOffset = gc->dash_offset; - float lengths[10]; - - while (p[num] != '\0' && num < 10) { - lengths[num] = p[num]; - num++; + ClipToGC(d, gc, NULL, tkMacOSXtmpQdRgn); + ClipCGContextToRegion(context, &portBounds, tkMacOSXtmpQdRgn); + SetEmptyRgn(tkMacOSXtmpQdRgn); + CGContextConcatCTM(context, CGAffineTransformMake(1.0, 0.0, 0.0, + -1.0, 0.0, portBounds.bottom - portBounds.top)); + if (gc) { + double w = gc->line_width; + + TkMacOSXSetColorInContext(gc->foreground, context); + if (port) { + CGContextSetPatternPhase(context, + CGSizeMake(portBounds.right - portBounds.left, + portBounds.bottom - portBounds.top)); + } + if(gc->function != GXcopy) { + TkMacOSXDbgMsg("Logical functions other than GXcopy are " + "not supported for CG drawing!"); + } + /* When should we antialias? */ + if (notAA(gc->line_width)) { + /* Make non-antialiased CG drawing look more like X11 */ + w -= (gc->line_width ? NON_AA_CG_OFFSET : 0); + CGContextSetShouldAntialias(context, 0); + } else { + CGContextSetShouldAntialias(context, 1); + } + CGContextSetLineWidth(context, w); + if (gc->line_style != LineSolid) { + int num = 0; + char *p = &(gc->dashes); + double dashOffset = gc->dash_offset; + float lengths[10]; + + while (p[num] != '\0' && num < 10) { + lengths[num] = p[num]; + num++; + } + CGContextSetLineDash(context, dashOffset, lengths, num); + } + if (gc->cap_style == CapButt) { + /* + * What about CapNotLast, CapProjecting? + */ + + CGContextSetLineCap(context, kCGLineCapButt); + } else if (gc->cap_style == CapRound) { + CGContextSetLineCap(context, kCGLineCapRound); + } else if (gc->cap_style == CapProjecting) { + CGContextSetLineCap(context, kCGLineCapSquare); + } + if (gc->join_style == JoinMiter) { + CGContextSetLineJoin(context, kCGLineJoinMiter); + } else if (gc->join_style == JoinRound) { + CGContextSetLineJoin(context, kCGLineJoinRound); + } else if (gc->join_style == JoinBevel) { + CGContextSetLineJoin(context, kCGLineJoinBevel); } - CGContextSetLineDash(context, dashOffset, lengths, num); - } - if (gc->cap_style == CapButt) { - /* - * What about CapNotLast, CapProjecting? - */ - - CGContextSetLineCap(context, kCGLineCapButt); - } else if (gc->cap_style == CapRound) { - CGContextSetLineCap(context, kCGLineCapRound); - } else if (gc->cap_style == CapProjecting) { - CGContextSetLineCap(context, kCGLineCapSquare); - } - if (gc->join_style == JoinMiter) { - CGContextSetLineJoin(context, kCGLineJoinMiter); - } else if (gc->join_style == JoinRound) { - CGContextSetLineJoin(context, kCGLineJoinRound); - } else if (gc->join_style == JoinBevel) { - CGContextSetLineJoin(context, kCGLineJoinBevel); } } } else { - PixPatHandle savePat = penPat; - - ChkErr(GetThemeDrawingState, &(dc->saveState)); - penPat = NULL; - TkMacOSXSetUpGraphicsPort(gc, port); - dc->penPat = penPat; - penPat = savePat; - if (gc) { - TkMacOSXCheckTmpRgnEmpty(1); - ClipToGC(d, gc, port, tkMacOSXtmpRgn1); + if (port) { + PixPatHandle savePat = penPat; + + ChkErr(GetThemeDrawingState, &(dc->saveState)); + penPat = NULL; + TkMacOSXSetUpGraphicsPort(gc, port); + dc->penPat = penPat; + penPat = savePat; + if (gc) { + TkMacOSXCheckTmpQdRgnEmpty(); + ClipToGC(d, gc, port, tkMacOSXtmpQdRgn); + } + if (!tkPictureIsOpen) { + ShowPen(); + } } - ShowPen(); } dc->portBounds = portBounds; dc->port = port; @@ -1675,8 +1631,14 @@ TkMacOSXRestoreDrawingContext(TkMacOSXDrawingContext *dc) ChkErr(QDEndCGContext, dc->port, &(dc->context)); } } else { - HidePen(); + if (!tkPictureIsOpen) { + HidePen(); + } PenNormal(); + if (dc->saveClip) { + SetPortClipRegion(dc->port, dc->saveClip); + DisposeRgn(dc->saveClip); + } if (dc->penPat) { DisposePixPat(dc->penPat); } @@ -1719,18 +1681,19 @@ TkMacOSXSetUpClippingRgn( if (macDraw->winPtr && macDraw->flags & TK_CLIP_INVALID) { TkMacOSXUpdateClipRgn(macDraw->winPtr); #ifdef TK_MAC_DEBUG_DRAWING - TkMacOSXDebugFlashRegion(port, macDraw->clipRgn); + TkMacOSXDbgMsg("%s clipRgn ", macDraw->winPtr->pathName); + TkMacOSXDebugFlashRegion(drawable, macDraw->clipRgn); #endif /* TK_MAC_DEBUG_DRAWING */ } if (macDraw->clipRgn) { if (macDraw->flags & TK_CLIPPED_DRAW) { - TkMacOSXCheckTmpRgnEmpty(1); + TkMacOSXCheckTmpQdRgnEmpty(); OffsetRgn(macDraw->drawRgn, macDraw->xOff, macDraw->yOff); - SectRgn(macDraw->clipRgn, macDraw->drawRgn, tkMacOSXtmpRgn1); + SectRgn(macDraw->clipRgn, macDraw->drawRgn, tkMacOSXtmpQdRgn); OffsetRgn(macDraw->drawRgn, -macDraw->xOff, -macDraw->yOff); - SetPortClipRegion(port, tkMacOSXtmpRgn1); - SetEmptyRgn(tkMacOSXtmpRgn1); + SetPortClipRegion(port, tkMacOSXtmpQdRgn); + SetEmptyRgn(tkMacOSXtmpQdRgn); } else { SetPortClipRegion(port, macDraw->clipRgn); } @@ -1847,7 +1810,7 @@ NoQDClip( CGrafPtr port) { static RgnHandle noClipRgn = NULL; - + if (!noClipRgn) { noClipRgn = NewRgn(); SetRectRgn(noClipRgn, SHRT_MIN, SHRT_MIN, SHRT_MAX, SHRT_MAX); diff --git a/macosx/tkMacOSXEntry.c b/macosx/tkMacOSXEntry.c index 7b4ff54..3485ae4 100644 --- a/macosx/tkMacOSXEntry.c +++ b/macosx/tkMacOSXEntry.c @@ -53,10 +53,10 @@ * software in accordance with the terms specified in this * license. * - * RCS: @(#) $Id: tkMacOSXEntry.c,v 1.11 2007/06/09 17:09:40 das Exp $ + * RCS: @(#) $Id: tkMacOSXEntry.c,v 1.12 2007/06/29 03:20:01 das Exp $ */ -#include "tkMacOSXInt.h" +#include "tkMacOSXPrivate.h" #include "tkMacOSXDefault.h" #include "tkEntry.h" diff --git a/macosx/tkMacOSXEvent.c b/macosx/tkMacOSXEvent.c index d7d12cd..5f1c0e7 100644 --- a/macosx/tkMacOSXEvent.c +++ b/macosx/tkMacOSXEvent.c @@ -10,10 +10,10 @@ * See the file "license.terms" for information on usage and redistribution * of this file, and for a DISCLAIMER OF ALL WARRANTIES. * - * RCS: @(#) $Id: tkMacOSXEvent.c,v 1.20 2007/06/09 17:09:40 das Exp $ + * RCS: @(#) $Id: tkMacOSXEvent.c,v 1.21 2007/06/29 03:20:01 das Exp $ */ -#include "tkMacOSXInt.h" +#include "tkMacOSXPrivate.h" #include "tkMacOSXEvent.h" #include "tkMacOSXDebug.h" diff --git a/macosx/tkMacOSXFont.c b/macosx/tkMacOSXFont.c index 5db83da..fdd522a 100644 --- a/macosx/tkMacOSXFont.c +++ b/macosx/tkMacOSXFont.c @@ -35,10 +35,10 @@ * that such fonts can not be used for controls, because controls * definitely require a family id (this assertion needs testing). * - * RCS: @(#) $Id: tkMacOSXFont.c,v 1.27 2007/06/03 13:44:40 das Exp $ + * RCS: @(#) $Id: tkMacOSXFont.c,v 1.28 2007/06/29 03:20:01 das Exp $ */ -#include "tkMacOSXInt.h" +#include "tkMacOSXPrivate.h" #include "tkMacOSXFont.h" /* @@ -316,7 +316,7 @@ GetThemeFontAndFamily( TkFont * TkpGetNativeFont( Tk_Window tkwin, /* For display where font will be used. */ - const char * name) /* Platform-specific font name. */ + const char *name) /* Platform-specific font name. */ { ThemeFontID themeFontId; FMFontFamily fontFamily; @@ -1054,7 +1054,8 @@ TkpDrawCharsInContext( Tcl_DString runString; #endif - TkMacOSXSetupDrawingContext(drawable, gc, 1, &drawingContext); + TkMacOSXSetupDrawingContext(drawable, gc, tkMacOSXUseCGDrawing, + &drawingContext); #if 0 /* diff --git a/macosx/tkMacOSXHLEvents.c b/macosx/tkMacOSXHLEvents.c index 850d80f..7ca21c3 100644 --- a/macosx/tkMacOSXHLEvents.c +++ b/macosx/tkMacOSXHLEvents.c @@ -11,10 +11,10 @@ * See the file "license.terms" for information on usage and redistribution * of this file, and for a DISCLAIMER OF ALL WARRANTIES. * - * RCS: @(#) $Id: tkMacOSXHLEvents.c,v 1.13 2007/04/23 21:24:33 das Exp $ + * RCS: @(#) $Id: tkMacOSXHLEvents.c,v 1.14 2007/06/29 03:20:01 das Exp $ */ -#include "tkMacOSXInt.h" +#include "tkMacOSXPrivate.h" /* * This is a Tcl_Event structure that the Quit AppleEvent handler diff --git a/macosx/tkMacOSXInit.c b/macosx/tkMacOSXInit.c index 8fdbe9f..bf6ef38 100644 --- a/macosx/tkMacOSXInit.c +++ b/macosx/tkMacOSXInit.c @@ -11,10 +11,10 @@ * See the file "license.terms" for information on usage and redistribution * of this file, and for a DISCLAIMER OF ALL WARRANTIES. * - * RCS: @(#) $Id: tkMacOSXInit.c,v 1.31 2007/06/09 17:09:40 das Exp $ + * RCS: @(#) $Id: tkMacOSXInit.c,v 1.32 2007/06/29 03:20:01 das Exp $ */ -#include "tkMacOSXInt.h" +#include "tkMacOSXPrivate.h" #include "tclInt.h" /* for Tcl_GetStartupScript() & Tcl_SetStartupScript() */ diff --git a/macosx/tkMacOSXInt.h b/macosx/tkMacOSXInt.h index 6c70a03..f121665 100644 --- a/macosx/tkMacOSXInt.h +++ b/macosx/tkMacOSXInt.h @@ -10,7 +10,7 @@ * See the file "license.terms" for information on usage and redistribution * of this file, and for a DISCLAIMER OF ALL WARRANTIES. * - * RCS: @(#) $Id: tkMacOSXInt.h,v 1.27 2007/06/09 17:09:40 das Exp $ + * RCS: @(#) $Id: tkMacOSXInt.h,v 1.28 2007/06/29 03:20:01 das Exp $ */ #ifndef _TKMACINT @@ -26,159 +26,6 @@ #include #undef TextStyle -/* Define constants only available on Mac OS X 10.3 or later */ -#if MAC_OS_X_VERSION_MAX_ALLOWED < 1030 - #define kEventAppAvailableWindowBoundsChanged 110 - #define kEventParamTransactionID 'trns' - #define kEventParamWindowPartCode 'wpar' - #define typeWindowPartCode 'wpar' - #define kMenuAttrDoNotUseUserCommandKeys (1 << 7) - #define kSimpleWindowClass 18 - #define kWindowDoesNotCycleAttribute (1L << 15) - #define kWindowAsyncDragAttribute (1L << 23) - #define kThemeBrushAlternatePrimaryHighlightColor -5 - #define kThemeResizeUpCursor 19 - #define kThemeResizeDownCursor 19 - #define kThemeResizeUpDownCursor 19 - #define kThemePoofCursor 19 - #define kThemeBackgroundMetal 6 - #define kThemeIncDecButtonSmall 21 - #define kThemeIncDecButtonMini 22 - #define kAppearancePartUpButton 20 - #define kAppearancePartDownButton 21 - #define kAppearancePartPageUpArea 22 - #define kAppearancePartPageDownArea 23 - #define kAppearancePartIndicator 129 - #define kUIModeAllSuppressed 4 - #define FixedToInt(a) ((short)(((Fixed)(a) + fixed1/2) >> 16)) - #define IntToFixed(a) ((Fixed)(a) << 16) -#endif -/* Define constants only available on Mac OS X 10.4 or later */ -#if MAC_OS_X_VERSION_MAX_ALLOWED < 1040 - #define kWindowNoTitleBarAttribute (1L << 9) - #define kWindowMetalNoContentSeparatorAttribute (1L << 11) - #define kThemeDisclosureTriangle 6 - #define kThemeBrushListViewOddRowBackground 56 - #define kThemeBrushListViewEvenRowBackground 57 - #define kThemeBrushListViewColumnDivider 58 - #define kThemeMetricScrollBarMinThumbHeight 132 - #define kThemeMetricSmallScrollBarMinThumbHeight 134 - #define kThemeScrollBarMedium kThemeMediumScrollBar - #define kThemeScrollBarSmall kThemeSmallScrollBar - #ifdef __BIG_ENDIAN__ - #define kCGBitmapByteOrder32Host (4 << 12) - #else - #define kCGBitmapByteOrder32Host (2 << 12) - #endif - #endif -/* Define constants only available on Mac OS X 10.5 or later */ -#if MAC_OS_X_VERSION_MAX_ALLOWED < 1050 - #define kWindowUnifiedTitleAndToolbarAttribute (1L << 7) - #define kWindowTexturedSquareCornersAttribute (1L << 10) -#endif -/* HIToolbox version constants */ -#ifndef kHIToolboxVersionNumber10_3 - #define kHIToolboxVersionNumber10_3 (145) -#endif -#ifndef kHIToolboxVersionNumber10_4 - #define kHIToolboxVersionNumber10_4 (219) -#endif -#ifndef kHIToolboxVersionNumber10_5 - #define kHIToolboxVersionNumber10_5 (303) -#endif -/* Macros for HIToolbox runtime version checking */ -MODULE_SCOPE float tkMacOSXToolboxVersionNumber; -#define TK_IF_HI_TOOLBOX(vers, ...) \ - tk_if_mac_os_x_min_10_##vers(tkMacOSXToolboxVersionNumber >= \ - kHIToolboxVersionNumber10_##vers, 1, __VA_ARGS__) -#define TK_ELSE_HI_TOOLBOX(vers, ...) \ - tk_else_mac_os_x_min_10_##vers(__VA_ARGS__) -/* Macros for Mac OS X API availability checking */ -#define TK_IF_MAC_OS_X_API(vers, symbol, ...) \ - tk_if_mac_os_x_10_##vers(symbol != NULL, 1, __VA_ARGS__) -#define TK_ELSE_MAC_OS_X(vers, ...) \ - tk_else_mac_os_x_10_##vers(__VA_ARGS__) -#define TK_IF_MAC_OS_X_API_COND(vers, symbol, cond, ...) \ - tk_if_mac_os_x_10_##vers(symbol != NULL, cond, __VA_ARGS__) -#define TK_ELSE(...) \ - } else { __VA_ARGS__ -#define TK_ENDIF \ - } -/* Private macros that implement the checking macros above */ -#define tk_if_mac_os_x_yes(chk, cond, ...) \ - if (cond) { __VA_ARGS__ -#define tk_else_mac_os_x_yes(...) \ - } else { -#define tk_if_mac_os_x_chk(chk, cond, ...) \ - if ((chk) && (cond)) { __VA_ARGS__ -#define tk_else_mac_os_x_chk(...) \ - } else { __VA_ARGS__ -#define tk_if_mac_os_x_no(chk, cond, ...) \ - if (0) { -#define tk_else_mac_os_x_no(...) \ - } else { __VA_ARGS__ -/* Private mapping macros defined according to Mac OS X version requirements */ -/* 10.3 Panther */ -#if MAC_OS_X_VERSION_MIN_REQUIRED >= 1030 -#define tk_if_mac_os_x_min_10_3 tk_if_mac_os_x_yes -#define tk_else_mac_os_x_min_10_3 tk_else_mac_os_x_yes -#if MAC_OS_X_VERSION_MAX_ALLOWED >= 1030 -#define tk_if_mac_os_x_10_3 tk_if_mac_os_x_yes -#define tk_else_mac_os_x_10_3 tk_else_mac_os_x_yes -#endif /* MAC_OS_X_VERSION_MAX_ALLOWED */ -#else /* MAC_OS_X_VERSION_MIN_REQUIRED */ -#define tk_if_mac_os_x_min_10_3 tk_if_mac_os_x_chk -#define tk_else_mac_os_x_min_10_3 tk_else_mac_os_x_chk -#if MAC_OS_X_VERSION_MAX_ALLOWED >= 1030 -#define tk_if_mac_os_x_10_3 tk_if_mac_os_x_chk -#define tk_else_mac_os_x_10_3 tk_else_mac_os_x_chk -#endif /* MAC_OS_X_VERSION_MAX_ALLOWED */ -#endif /* MAC_OS_X_VERSION_MIN_REQUIRED */ -#if MAC_OS_X_VERSION_MAX_ALLOWED < 1030 -#define tk_if_mac_os_x_10_3 tk_if_mac_os_x_no -#define tk_else_mac_os_x_10_3 tk_else_mac_os_x_no -#endif /* MAC_OS_X_VERSION_MAX_ALLOWED */ -/* 10.4 Tiger */ -#if MAC_OS_X_VERSION_MIN_REQUIRED >= 1040 -#define tk_if_mac_os_x_min_10_4 tk_if_mac_os_x_yes -#define tk_else_mac_os_x_min_10_4 tk_else_mac_os_x_yes -#if MAC_OS_X_VERSION_MAX_ALLOWED >= 1040 -#define tk_if_mac_os_x_10_4 tk_if_mac_os_x_yes -#define tk_else_mac_os_x_10_4 tk_else_mac_os_x_yes -#endif /* MAC_OS_X_VERSION_MAX_ALLOWED */ -#else /* MAC_OS_X_VERSION_MIN_REQUIRED */ -#define tk_if_mac_os_x_min_10_4 tk_if_mac_os_x_chk -#define tk_else_mac_os_x_min_10_4 tk_else_mac_os_x_chk -#if MAC_OS_X_VERSION_MAX_ALLOWED >= 1040 -#define tk_if_mac_os_x_10_4 tk_if_mac_os_x_chk -#define tk_else_mac_os_x_10_4 tk_else_mac_os_x_chk -#endif /* MAC_OS_X_VERSION_MAX_ALLOWED */ -#endif /* MAC_OS_X_VERSION_MIN_REQUIRED */ -#if MAC_OS_X_VERSION_MAX_ALLOWED < 1040 -#define tk_if_mac_os_x_10_4 tk_if_mac_os_x_no -#define tk_else_mac_os_x_10_4 tk_else_mac_os_x_no -#endif /* MAC_OS_X_VERSION_MAX_ALLOWED */ -/* 10.5 Leopard */ -#if MAC_OS_X_VERSION_MIN_REQUIRED >= 1050 -#define tk_if_mac_os_x_min_10_5 tk_if_mac_os_x_yes -#define tk_else_mac_os_x_min_10_5 tk_else_mac_os_x_yes -#if MAC_OS_X_VERSION_MAX_ALLOWED >= 1050 -#define tk_if_mac_os_x_10_5 tk_if_mac_os_x_yes -#define tk_else_mac_os_x_10_5 tk_else_mac_os_x_yes -#endif /* MAC_OS_X_VERSION_MAX_ALLOWED */ -#else /* MAC_OS_X_VERSION_MIN_REQUIRED */ -#define tk_if_mac_os_x_min_10_5 tk_if_mac_os_x_chk -#define tk_else_mac_os_x_min_10_5 tk_else_mac_os_x_chk -#if MAC_OS_X_VERSION_MAX_ALLOWED >= 1050 -#define tk_if_mac_os_x_10_5 tk_if_mac_os_x_chk -#define tk_else_mac_os_x_10_5 tk_else_mac_os_x_chk -#endif /* MAC_OS_X_VERSION_MAX_ALLOWED */ -#endif /* MAC_OS_X_VERSION_MIN_REQUIRED */ -#if MAC_OS_X_VERSION_MAX_ALLOWED < 1050 -#define tk_if_mac_os_x_10_5 tk_if_mac_os_x_no -#define tk_else_mac_os_x_10_5 tk_else_mac_os_x_no -#endif /* MAC_OS_X_VERSION_MAX_ALLOWED */ - /* * Include platform specific public interfaces. */ @@ -255,19 +102,6 @@ typedef struct { MODULE_SCOPE TkMacOSXEmbedHandler *tkMacOSXEmbedHandler; /* - * Structure encapsulating current drawing environment. - */ - -typedef struct TkMacOSXDrawingContext { - CGContextRef context; - CGrafPtr port, savePort; - ThemeDrawingState saveState; - PixPatHandle penPat; - Rect portBounds; - Boolean portChanged; -} TkMacOSXDrawingContext; - -/* * Defines used for TkMacOSXInvalidateWindow */ @@ -294,72 +128,14 @@ typedef struct TkMacOSXDrawingContext { */ #define TK_LAYOUT_WITH_BASE_CHUNKS 1 -#define TK_DRAW_IN_CONTEXT 1 +#define TK_DRAW_IN_CONTEXT 1 #if !TK_DRAW_IN_CONTEXT MODULE_SCOPE int TkMacOSXCompareColors(unsigned long c1, unsigned long c2); #endif /* - * Macros abstracting checks only active in a debug build. - */ - -#ifdef TK_MAC_DEBUG -/* - * Macro to do debug message output. - */ -#define TkMacOSXDbgMsg(m, ...) do { \ - fprintf(stderr, "%s:%d: %s(): " m "\n", strrchr(__FILE__, '/')+1, \ - __LINE__, __func__, ##__VA_ARGS__); \ - } while (0) -/* - * Macro to do debug API failure message output. - */ -#if !defined(DEBUGLEVEL) || !DEBUGLEVEL -#define TkMacOSXDbgOSErr(f, err) do { \ - TkMacOSXDbgMsg("%s failed: %ld", #f, err); \ - } while (0) -#else -#define TkMacOSXDbgOSErr(f, err) do { \ - DEBUG_ASSERT_MESSAGE(kComponentSignatureString, #f " failed:", \ - __func__, 0, strrchr(__FILE__, '/')+1, __LINE__, err); \ - } while (0) -#endif -/* - * Macro to do very common check for noErr return from given API and output - * debug message in case of failure. - */ -#define ChkErr(f, ...) ({ \ - OSStatus err = f(__VA_ARGS__); \ - if (err != noErr) { \ - TkMacOSXDbgOSErr(f, err); \ - } \ - err;}) -/* - * Macro to check emptyness of shared temp regions before use in debug builds. - */ -#define TkMacOSXCheckTmpRgnEmpty(r) do { \ - if (!EmptyRgn(tkMacOSXtmpRgn##r)) { \ - Tcl_Panic("tkMacOSXtmpRgn%s nonempty", #r); \ - } \ - } while(0) -#else /* TK_MAC_DEBUG */ -#define TkMacOSXDbgMsg(m, ...) -#define TkMacOSXDbgOSErr(f, err) -#define ChkErr(f, ...) ({f(__VA_ARGS__);}) -#define TkMacOSXCheckTmpRgnEmpty(r) -#endif /* TK_MAC_DEBUG */ - -/* - * Variables shared among various Mac Tk modules but are not - * exported to the outside world. - */ - -MODULE_SCOPE RgnHandle tkMacOSXtmpRgn1; -MODULE_SCOPE RgnHandle tkMacOSXtmpRgn2; - -/* - * Globals shared among Macintosh Tk + * Globals shared among TkAqua. */ MODULE_SCOPE MenuHandle tkCurrentAppleMenu; /* Handle to current Apple Menu */ @@ -384,61 +160,13 @@ MODULE_SCOPE Tcl_Encoding TkMacOSXCarbonEncoding; * Prototypes of internal procs not in the stubs table. */ +MODULE_SCOPE void TkMacOSXDefaultStartupScript(void); #if 0 MODULE_SCOPE int XSetClipRectangles(Display *d, GC gc, int clip_x_origin, int clip_y_origin, XRectangle* rectangles, int n, int ordering); #endif MODULE_SCOPE void TkpClipDrawableToRect(Display *display, Drawable d, int x, int y, int width, int height); -MODULE_SCOPE void TkMacOSXDisplayChanged(Display *display); -MODULE_SCOPE void TkMacOSXInitScrollbarMetrics(void); -MODULE_SCOPE int TkMacOSXUseAntialiasedText(Tcl_Interp *interp, int enable); -MODULE_SCOPE void TkMacOSXInitCarbonEvents(Tcl_Interp *interp); -MODULE_SCOPE int TkMacOSXInitCGDrawing(Tcl_Interp *interp, int enable, - int antiAlias); -MODULE_SCOPE void TkMacOSXInitKeyboard(Tcl_Interp *interp); -MODULE_SCOPE void TkMacOSXDefaultStartupScript(void); -MODULE_SCOPE int TkMacOSXGenerateFocusEvent(Window window, int activeFlag); -MODULE_SCOPE int TkMacOSXGenerateParentMenuSelectEvent(MenuRef menu); -MODULE_SCOPE int TkMacOSXGenerateMenuSelectEvent(MenuRef menu, - MenuItemIndex index); -MODULE_SCOPE void TkMacOSXClearActiveMenu(MenuRef menu); -MODULE_SCOPE WindowClass TkMacOSXWindowClass(TkWindow *winPtr); -MODULE_SCOPE int TkMacOSXIsWindowZoomed(TkWindow *winPtr); -MODULE_SCOPE int TkGenerateButtonEventForXPointer(Window window); -MODULE_SCOPE EventModifiers TkMacOSXModifierState(void); -MODULE_SCOPE int TkMacOSXSetupDrawingContext(Drawable d, GC gc, int useCG, - TkMacOSXDrawingContext *dc); -MODULE_SCOPE void TkMacOSXRestoreDrawingContext(TkMacOSXDrawingContext *dc); -MODULE_SCOPE void TkMacOSXSetColorInPort(unsigned long pixel, int fg, - PixPatHandle penPat); -MODULE_SCOPE void TkMacOSXSetColorInContext(unsigned long pixel, - CGContextRef context); -MODULE_SCOPE int TkMacOSXRunTclEventLoop(void); -MODULE_SCOPE OSStatus TkMacOSXStartTclEventLoopCarbonTimer(void); -MODULE_SCOPE OSStatus TkMacOSXStopTclEventLoopCarbonTimer(void); -MODULE_SCOPE void TkMacOSXTrackingLoop(int tracking); -MODULE_SCOPE OSStatus TkMacOSXReceiveAndDispatchEvent(void); -MODULE_SCOPE void TkMacOSXInstallWindowCarbonEventHandler(Tcl_Interp *interp, - WindowRef window); -MODULE_SCOPE int TkMacOSXMakeFullscreen(TkWindow *winPtr, WindowRef window, - int fullscreen, Tcl_Interp *interp); -MODULE_SCOPE void TkMacOSXEnterExitFullscreen(TkWindow *winPtr, int active); -MODULE_SCOPE void TkMacOSXBringWindowForward(WindowRef wRef); - -MODULE_SCOPE void* TkMacOSXGetNamedSymbol(const char* module, - const char* symbol); - -/* - * Macro abstracting use of TkMacOSXGetNamedSymbol to init named symbols. - */ - -#define TkMacOSXInitNamedSymbol(module, ret, symbol, ...) \ - static ret (* symbol)(__VA_ARGS__) = (void*)(-1L); \ - if (symbol == (void*)(-1L)) { \ - symbol = TkMacOSXGetNamedSymbol(STRINGIFY(module), \ - STRINGIFY(_##symbol)); \ - } /* * Include the stubbed internal platform-specific API. diff --git a/macosx/tkMacOSXKeyEvent.c b/macosx/tkMacOSXKeyEvent.c index 9344288..8559b91 100644 --- a/macosx/tkMacOSXKeyEvent.c +++ b/macosx/tkMacOSXKeyEvent.c @@ -54,10 +54,10 @@ * software in accordance with the terms specified in this * license. * - * RCS: @(#) $Id: tkMacOSXKeyEvent.c,v 1.22 2007/06/03 13:44:40 das Exp $ + * RCS: @(#) $Id: tkMacOSXKeyEvent.c,v 1.23 2007/06/29 03:20:01 das Exp $ */ -#include "tkMacOSXInt.h" +#include "tkMacOSXPrivate.h" #include "tkMacOSXEvent.h" /* @@ -1123,8 +1123,8 @@ TkpSetCapture( m = kWindowModalityNone; } if (w && w->window != None && TkMacOSXHostToplevelExists(w)) { - ChkErr(SetWindowModality, GetWindowFromPort( - TkMacOSXGetDrawablePort(w->window)), m, NULL); + ChkErr(SetWindowModality, TkMacOSXDrawableWindow(w->window), m, + NULL); } } #endif diff --git a/macosx/tkMacOSXMenu.c b/macosx/tkMacOSXMenu.c index 1e983ea..35672b7 100644 --- a/macosx/tkMacOSXMenu.c +++ b/macosx/tkMacOSXMenu.c @@ -10,10 +10,10 @@ * See the file "license.terms" for information on usage and redistribution * of this file, and for a DISCLAIMER OF ALL WARRANTIES. * - * RCS: @(#) $Id: tkMacOSXMenu.c,v 1.41 2007/06/09 17:09:40 das Exp $ + * RCS: @(#) $Id: tkMacOSXMenu.c,v 1.42 2007/06/29 03:20:01 das Exp $ */ -#include "tkMacOSXInt.h" +#include "tkMacOSXPrivate.h" #include "tkMenubutton.h" #include "tkMenu.h" #include "tkColor.h" @@ -2030,15 +2030,10 @@ TkpSetMainMenubar( */ { TkWindow *winPtr = (TkWindow *) tkwin; - CGrafPtr winPort; WindowRef macWindowPtr; WindowRef frontNonFloating; - winPort = TkMacOSXGetDrawablePort(winPtr->window); - if (!winPort) { - return; - } - macWindowPtr = GetWindowFromPort(winPort); + macWindowPtr = TkMacOSXDrawableWindow(winPtr->window); frontNonFloating = ActiveNonFloatingWindow(); if ((macWindowPtr == NULL) || (macWindowPtr != frontNonFloating)) { @@ -3985,7 +3980,17 @@ TkpMenuInit(void) tkThemeMenuItemDrawingUPP = NewMenuItemDrawingUPP(ThemeMenuItemDrawingProc); useMDEFVar = Tcl_NewStringObj("::tk::mac::useCustomMDEF", -1); + macMDEFDrawable.winPtr = NULL; + macMDEFDrawable.xOff = 0; + macMDEFDrawable.yOff = 0; + macMDEFDrawable.clipRgn = NULL; + macMDEFDrawable.aboveClipRgn = NULL; macMDEFDrawable.drawRgn = NewRgn(); + macMDEFDrawable.referenceCount = 0; + macMDEFDrawable.toplevel = NULL; + macMDEFDrawable.flags = 0; + macMDEFDrawable.grafPtr = NULL; + macMDEFDrawable.context = NULL; #endif ChkErr(GetThemeMetric, kThemeMetricMenuMarkColumnWidth, diff --git a/macosx/tkMacOSXMenubutton.c b/macosx/tkMacOSXMenubutton.c index 5e05d19..beb8e71 100644 --- a/macosx/tkMacOSXMenubutton.c +++ b/macosx/tkMacOSXMenubutton.c @@ -11,10 +11,10 @@ * See the file "license.terms" for information on usage and redistribution * of this file, and for a DISCLAIMER OF ALL WARRANTIES. * - * RCS: @(#) $Id: tkMacOSXMenubutton.c,v 1.14 2007/04/23 21:24:33 das Exp $ + * RCS: @(#) $Id: tkMacOSXMenubutton.c,v 1.15 2007/06/29 03:20:02 das Exp $ */ -#include "tkMacOSXInt.h" +#include "tkMacOSXPrivate.h" #include "tkMenu.h" #include "tkMenubutton.h" #include "tkMacOSXFont.h" @@ -603,8 +603,7 @@ MenuButtonInitControl( ControlRef rootControl = TkMacOSXGetRootControl(Tk_WindowId(butPtr->tkwin)); - mbPtr->windowRef = GetWindowFromPort( - TkMacOSXGetDrawablePort(Tk_WindowId(butPtr->tkwin))); + mbPtr->windowRef = TkMacOSXDrawableWindow(Tk_WindowId(butPtr->tkwin)); /* * Set up the user pane @@ -792,9 +791,11 @@ UserPaneDraw( Rect contrlRect; MacMenuButton * mbPtr = (MacMenuButton *)(intptr_t)GetControlReference(control); + CGrafPtr port; + GetPort(&port); GetControlBounds(control,&contrlRect); - TkMacOSXSetColorInPort(mbPtr->userPaneBackground, 0, NULL); + TkMacOSXSetColorInPort(mbPtr->userPaneBackground, 0, NULL, port); EraseRect (&contrlRect); } @@ -824,7 +825,10 @@ UserPaneBackgroundProc( (MacMenuButton *)(intptr_t)GetControlReference(control); if (info->colorDevice) { - TkMacOSXSetColorInPort(mbPtr->userPaneBackground, 0, NULL); + CGrafPtr port; + + GetPort(&port); + TkMacOSXSetColorInPort(mbPtr->userPaneBackground, 0, NULL, port); } } diff --git a/macosx/tkMacOSXMenus.c b/macosx/tkMacOSXMenus.c index c915b34..4f991d2 100644 --- a/macosx/tkMacOSXMenus.c +++ b/macosx/tkMacOSXMenus.c @@ -11,10 +11,10 @@ * See the file "license.terms" for information on usage and redistribution * of this file, and for a DISCLAIMER OF ALL WARRANTIES. * - * RCS: @(#) $Id: tkMacOSXMenus.c,v 1.17 2007/06/03 13:44:40 das Exp $ + * RCS: @(#) $Id: tkMacOSXMenus.c,v 1.18 2007/06/29 03:20:02 das Exp $ */ -#include "tkMacOSXInt.h" +#include "tkMacOSXPrivate.h" #define kAppleMenu 256 #define kAppleAboutItem 1 diff --git a/macosx/tkMacOSXMouseEvent.c b/macosx/tkMacOSXMouseEvent.c index 1fa8388..41b75f1 100644 --- a/macosx/tkMacOSXMouseEvent.c +++ b/macosx/tkMacOSXMouseEvent.c @@ -54,10 +54,10 @@ * software in accordance with the terms specified in this * license. * - * RCS: @(#) $Id: tkMacOSXMouseEvent.c,v 1.30 2007/06/06 09:55:52 das Exp $ + * RCS: @(#) $Id: tkMacOSXMouseEvent.c,v 1.31 2007/06/29 03:20:02 das Exp $ */ -#include "tkMacOSXInt.h" +#include "tkMacOSXPrivate.h" #include "tkMacOSXWm.h" #include "tkMacOSXEvent.h" #include "tkMacOSXDebug.h" @@ -278,9 +278,8 @@ TkMacOSXProcessMouseEvent(TkMacOSXEvent *eventPtr, MacEventStatus * statusPtr) /* Now we want to set the focus to the local grabWin */ TkMacOSXSetEatButtonUp(true); grabWin = (Tk_Window) (((TkWindow*)tkwin)->dispPtr->grabWinPtr); - BringWindowForward(GetWindowFromPort( - TkMacOSXGetDrawablePort(((TkWindow*)grabWin)->window)), - isFrontProcess); + BringWindowForward(TkMacOSXDrawableWindow( + ((TkWindow*)grabWin)->window), isFrontProcess); statusPtr->stopProcessing = 1; return false; } @@ -291,9 +290,8 @@ TkMacOSXProcessMouseEvent(TkMacOSXEvent *eventPtr, MacEventStatus * statusPtr) grb = (TkWindow *)grabWin; /* Now we want to set the focus to the global grabWin */ TkMacOSXSetEatButtonUp(true); - BringWindowForward(GetWindowFromPort( - TkMacOSXGetDrawablePort(((TkWindow*)grabWin)->window)), - isFrontProcess); + BringWindowForward(TkMacOSXDrawableWindow( + ((TkWindow*)grabWin)->window), isFrontProcess); statusPtr->stopProcessing = 1; return false; } diff --git a/macosx/tkMacOSXNotify.c b/macosx/tkMacOSXNotify.c index ccafbf9..e5e8b85 100644 --- a/macosx/tkMacOSXNotify.c +++ b/macosx/tkMacOSXNotify.c @@ -11,10 +11,10 @@ * See the file "license.terms" for information on usage and redistribution * of this file, and for a DISCLAIMER OF ALL WARRANTIES. * - * RCS: @(#) $Id: tkMacOSXNotify.c,v 1.18 2007/04/23 21:24:34 das Exp $ + * RCS: @(#) $Id: tkMacOSXNotify.c,v 1.19 2007/06/29 03:20:02 das Exp $ */ -#include "tkMacOSXInt.h" +#include "tkMacOSXPrivate.h" #include "tkMacOSXEvent.h" #include diff --git a/macosx/tkMacOSXPrivate.h b/macosx/tkMacOSXPrivate.h new file mode 100644 index 0000000..19be7ec --- /dev/null +++ b/macosx/tkMacOSXPrivate.h @@ -0,0 +1,298 @@ +/* + * tkMacOSXPrivate.h -- + * + * Macros and declarations that are purely internal & private to TkAqua. + * + * Copyright (c) 2005-2007 Daniel A. Steffen + * + * See the file "license.terms" for information on usage and redistribution + * of this file, and for a DISCLAIMER OF ALL WARRANTIES. + * + * RCS: @(#) $Id: tkMacOSXPrivate.h,v 1.1 2007/06/29 03:20:02 das Exp $ + */ + +#ifndef _TKMACPRIV +#define _TKMACPRIV + +#ifndef _TKMACINT +#include "tkMacOSXInt.h" +#endif + +/* Define constants only available on Mac OS X 10.3 or later */ +#if MAC_OS_X_VERSION_MAX_ALLOWED < 1030 + #define kEventAppAvailableWindowBoundsChanged 110 + #define kEventParamTransactionID 'trns' + #define kEventParamWindowPartCode 'wpar' + #define typeWindowPartCode 'wpar' + #define kMenuAttrDoNotUseUserCommandKeys (1 << 7) + #define kSimpleWindowClass 18 + #define kWindowDoesNotCycleAttribute (1L << 15) + #define kWindowAsyncDragAttribute (1L << 23) + #define kThemeBrushAlternatePrimaryHighlightColor -5 + #define kThemeResizeUpCursor 19 + #define kThemeResizeDownCursor 19 + #define kThemeResizeUpDownCursor 19 + #define kThemePoofCursor 19 + #define kThemeBackgroundMetal 6 + #define kThemeIncDecButtonSmall 21 + #define kThemeIncDecButtonMini 22 + #define kAppearancePartUpButton 20 + #define kAppearancePartDownButton 21 + #define kAppearancePartPageUpArea 22 + #define kAppearancePartPageDownArea 23 + #define kAppearancePartIndicator 129 + #define kUIModeAllSuppressed 4 + #define FixedToInt(a) ((short)(((Fixed)(a) + fixed1/2) >> 16)) + #define IntToFixed(a) ((Fixed)(a) << 16) +#endif +/* Define constants only available on Mac OS X 10.4 or later */ +#if MAC_OS_X_VERSION_MAX_ALLOWED < 1040 + #define kWindowNoTitleBarAttribute (1L << 9) + #define kWindowMetalNoContentSeparatorAttribute (1L << 11) + #define kThemeDisclosureTriangle 6 + #define kThemeBrushListViewOddRowBackground 56 + #define kThemeBrushListViewEvenRowBackground 57 + #define kThemeBrushListViewColumnDivider 58 + #define kThemeMetricScrollBarMinThumbHeight 132 + #define kThemeMetricSmallScrollBarMinThumbHeight 134 + #define kThemeScrollBarMedium kThemeMediumScrollBar + #define kThemeScrollBarSmall kThemeSmallScrollBar + #ifdef __BIG_ENDIAN__ + #define kCGBitmapByteOrder32Host (4 << 12) + #else + #define kCGBitmapByteOrder32Host (2 << 12) + #endif + #endif +/* Define constants only available on Mac OS X 10.5 or later */ +#if MAC_OS_X_VERSION_MAX_ALLOWED < 1050 + #define kWindowUnifiedTitleAndToolbarAttribute (1L << 7) + #define kWindowTexturedSquareCornersAttribute (1L << 10) +#endif +/* HIToolbox version constants */ +#ifndef kHIToolboxVersionNumber10_3 + #define kHIToolboxVersionNumber10_3 (145) +#endif +#ifndef kHIToolboxVersionNumber10_4 + #define kHIToolboxVersionNumber10_4 (219) +#endif +#ifndef kHIToolboxVersionNumber10_5 + #define kHIToolboxVersionNumber10_5 (316) +#endif +/* Macros for HIToolbox runtime version checking */ +MODULE_SCOPE float tkMacOSXToolboxVersionNumber; +#define TK_IF_HI_TOOLBOX(vers, ...) \ + tk_if_mac_os_x_min_10_##vers(tkMacOSXToolboxVersionNumber >= \ + kHIToolboxVersionNumber10_##vers, 1, __VA_ARGS__) +#define TK_ELSE_HI_TOOLBOX(vers, ...) \ + tk_else_mac_os_x_min_10_##vers(__VA_ARGS__) +/* Macros for Mac OS X API availability checking */ +#define TK_IF_MAC_OS_X_API(vers, symbol, ...) \ + tk_if_mac_os_x_10_##vers(symbol != NULL, 1, __VA_ARGS__) +#define TK_ELSE_MAC_OS_X(vers, ...) \ + tk_else_mac_os_x_10_##vers(__VA_ARGS__) +#define TK_IF_MAC_OS_X_API_COND(vers, symbol, cond, ...) \ + tk_if_mac_os_x_10_##vers(symbol != NULL, cond, __VA_ARGS__) +#define TK_ELSE(...) \ + } else { __VA_ARGS__ +#define TK_ENDIF \ + } +/* Private macros that implement the checking macros above */ +#define tk_if_mac_os_x_yes(chk, cond, ...) \ + if (cond) { __VA_ARGS__ +#define tk_else_mac_os_x_yes(...) \ + } else { +#define tk_if_mac_os_x_chk(chk, cond, ...) \ + if ((chk) && (cond)) { __VA_ARGS__ +#define tk_else_mac_os_x_chk(...) \ + } else { __VA_ARGS__ +#define tk_if_mac_os_x_no(chk, cond, ...) \ + if (0) { +#define tk_else_mac_os_x_no(...) \ + } else { __VA_ARGS__ +/* Private mapping macros defined according to Mac OS X version requirements */ +/* 10.3 Panther */ +#if MAC_OS_X_VERSION_MIN_REQUIRED >= 1030 +#define tk_if_mac_os_x_min_10_3 tk_if_mac_os_x_yes +#define tk_else_mac_os_x_min_10_3 tk_else_mac_os_x_yes +#if MAC_OS_X_VERSION_MAX_ALLOWED >= 1030 +#define tk_if_mac_os_x_10_3 tk_if_mac_os_x_yes +#define tk_else_mac_os_x_10_3 tk_else_mac_os_x_yes +#endif /* MAC_OS_X_VERSION_MAX_ALLOWED */ +#else /* MAC_OS_X_VERSION_MIN_REQUIRED */ +#define tk_if_mac_os_x_min_10_3 tk_if_mac_os_x_chk +#define tk_else_mac_os_x_min_10_3 tk_else_mac_os_x_chk +#if MAC_OS_X_VERSION_MAX_ALLOWED >= 1030 +#define tk_if_mac_os_x_10_3 tk_if_mac_os_x_chk +#define tk_else_mac_os_x_10_3 tk_else_mac_os_x_chk +#endif /* MAC_OS_X_VERSION_MAX_ALLOWED */ +#endif /* MAC_OS_X_VERSION_MIN_REQUIRED */ +#if MAC_OS_X_VERSION_MAX_ALLOWED < 1030 +#define tk_if_mac_os_x_10_3 tk_if_mac_os_x_no +#define tk_else_mac_os_x_10_3 tk_else_mac_os_x_no +#endif /* MAC_OS_X_VERSION_MAX_ALLOWED */ +/* 10.4 Tiger */ +#if MAC_OS_X_VERSION_MIN_REQUIRED >= 1040 +#define tk_if_mac_os_x_min_10_4 tk_if_mac_os_x_yes +#define tk_else_mac_os_x_min_10_4 tk_else_mac_os_x_yes +#if MAC_OS_X_VERSION_MAX_ALLOWED >= 1040 +#define tk_if_mac_os_x_10_4 tk_if_mac_os_x_yes +#define tk_else_mac_os_x_10_4 tk_else_mac_os_x_yes +#endif /* MAC_OS_X_VERSION_MAX_ALLOWED */ +#else /* MAC_OS_X_VERSION_MIN_REQUIRED */ +#define tk_if_mac_os_x_min_10_4 tk_if_mac_os_x_chk +#define tk_else_mac_os_x_min_10_4 tk_else_mac_os_x_chk +#if MAC_OS_X_VERSION_MAX_ALLOWED >= 1040 +#define tk_if_mac_os_x_10_4 tk_if_mac_os_x_chk +#define tk_else_mac_os_x_10_4 tk_else_mac_os_x_chk +#endif /* MAC_OS_X_VERSION_MAX_ALLOWED */ +#endif /* MAC_OS_X_VERSION_MIN_REQUIRED */ +#if MAC_OS_X_VERSION_MAX_ALLOWED < 1040 +#define tk_if_mac_os_x_10_4 tk_if_mac_os_x_no +#define tk_else_mac_os_x_10_4 tk_else_mac_os_x_no +#endif /* MAC_OS_X_VERSION_MAX_ALLOWED */ +/* 10.5 Leopard */ +#if MAC_OS_X_VERSION_MIN_REQUIRED >= 1050 +#define tk_if_mac_os_x_min_10_5 tk_if_mac_os_x_yes +#define tk_else_mac_os_x_min_10_5 tk_else_mac_os_x_yes +#if MAC_OS_X_VERSION_MAX_ALLOWED >= 1050 +#define tk_if_mac_os_x_10_5 tk_if_mac_os_x_yes +#define tk_else_mac_os_x_10_5 tk_else_mac_os_x_yes +#endif /* MAC_OS_X_VERSION_MAX_ALLOWED */ +#else /* MAC_OS_X_VERSION_MIN_REQUIRED */ +#define tk_if_mac_os_x_min_10_5 tk_if_mac_os_x_chk +#define tk_else_mac_os_x_min_10_5 tk_else_mac_os_x_chk +#if MAC_OS_X_VERSION_MAX_ALLOWED >= 1050 +#define tk_if_mac_os_x_10_5 tk_if_mac_os_x_chk +#define tk_else_mac_os_x_10_5 tk_else_mac_os_x_chk +#endif /* MAC_OS_X_VERSION_MAX_ALLOWED */ +#endif /* MAC_OS_X_VERSION_MIN_REQUIRED */ +#if MAC_OS_X_VERSION_MAX_ALLOWED < 1050 +#define tk_if_mac_os_x_10_5 tk_if_mac_os_x_no +#define tk_else_mac_os_x_10_5 tk_else_mac_os_x_no +#endif /* MAC_OS_X_VERSION_MAX_ALLOWED */ + +/* + * Macros abstracting checks only active in a debug build. + */ + +#ifdef TK_MAC_DEBUG +/* + * Macro to do debug message output. + */ +#define TkMacOSXDbgMsg(m, ...) do { \ + fprintf(stderr, "%s:%d: %s(): " m "\n", strrchr(__FILE__, '/')+1, \ + __LINE__, __func__, ##__VA_ARGS__); \ + } while (0) +/* + * Macro to do debug API failure message output. + */ +#if !defined(DEBUGLEVEL) || !DEBUGLEVEL +#define TkMacOSXDbgOSErr(f, err) do { \ + TkMacOSXDbgMsg("%s failed: %ld", #f, err); \ + } while (0) +#else +#define TkMacOSXDbgOSErr(f, err) do { \ + DEBUG_ASSERT_MESSAGE(kComponentSignatureString, #f " failed:", \ + __func__, 0, strrchr(__FILE__, '/')+1, __LINE__, err); \ + } while (0) +#endif +/* + * Macro to do very common check for noErr return from given API and output + * debug message in case of failure. + */ +#define ChkErr(f, ...) ({ \ + OSStatus err = f(__VA_ARGS__); \ + if (err != noErr) { \ + TkMacOSXDbgOSErr(f, err); \ + } \ + err;}) +/* + * Macro to check emptyness of shared QD tmp region before use in debug builds. + */ +#define TkMacOSXCheckTmpQdRgnEmpty() do { \ + if (!EmptyRgn(tkMacOSXtmpQdRgn)) { \ + Tcl_Panic("tkMacOSXtmpQdRgn nonempty"); \ + } \ + } while(0) +#else /* TK_MAC_DEBUG */ +#define TkMacOSXDbgMsg(m, ...) +#define TkMacOSXDbgOSErr(f, err) +#define ChkErr(f, ...) ({f(__VA_ARGS__);}) +#define TkMacOSXCheckTmpQdRgnEmpty() +#endif /* TK_MAC_DEBUG */ + +/* + * Macro abstracting use of TkMacOSXGetNamedSymbol to init named symbols. + */ + +#define TkMacOSXInitNamedSymbol(module, ret, symbol, ...) \ + static ret (* symbol)(__VA_ARGS__) = (void*)(-1L); \ + if (symbol == (void*)(-1L)) { \ + symbol = TkMacOSXGetNamedSymbol(STRINGIFY(module), \ + STRINGIFY(_##symbol)); \ + } +MODULE_SCOPE void* TkMacOSXGetNamedSymbol(const char* module, + const char* symbol); + +/* + * Structure encapsulating current drawing environment. + */ + +typedef struct TkMacOSXDrawingContext { + CGContextRef context; + CGrafPtr port, savePort; + ThemeDrawingState saveState; + RgnHandle saveClip; + PixPatHandle penPat; + Rect portBounds; + Boolean portChanged; +} TkMacOSXDrawingContext; + +/* + * Variables internal to TkAqua. + */ + +MODULE_SCOPE RgnHandle tkMacOSXtmpQdRgn; +MODULE_SCOPE int tkMacOSXUseCGDrawing; + +/* + * Prototypes of TkAqua internal procs. + */ + +MODULE_SCOPE void TkMacOSXDisplayChanged(Display *display); +MODULE_SCOPE void TkMacOSXInitScrollbarMetrics(void); +MODULE_SCOPE int TkMacOSXUseAntialiasedText(Tcl_Interp *interp, int enable); +MODULE_SCOPE void TkMacOSXInitCarbonEvents(Tcl_Interp *interp); +MODULE_SCOPE int TkMacOSXInitCGDrawing(Tcl_Interp *interp, int enable, + int antiAlias); +MODULE_SCOPE void TkMacOSXInitKeyboard(Tcl_Interp *interp); +MODULE_SCOPE int TkMacOSXGenerateFocusEvent(Window window, int activeFlag); +MODULE_SCOPE int TkMacOSXGenerateParentMenuSelectEvent(MenuRef menu); +MODULE_SCOPE int TkMacOSXGenerateMenuSelectEvent(MenuRef menu, + MenuItemIndex index); +MODULE_SCOPE void TkMacOSXClearActiveMenu(MenuRef menu); +MODULE_SCOPE WindowClass TkMacOSXWindowClass(TkWindow *winPtr); +MODULE_SCOPE int TkMacOSXIsWindowZoomed(TkWindow *winPtr); +MODULE_SCOPE int TkGenerateButtonEventForXPointer(Window window); +MODULE_SCOPE EventModifiers TkMacOSXModifierState(void); +MODULE_SCOPE int TkMacOSXSetupDrawingContext(Drawable d, GC gc, int useCG, + TkMacOSXDrawingContext *dc); +MODULE_SCOPE void TkMacOSXRestoreDrawingContext(TkMacOSXDrawingContext *dc); +MODULE_SCOPE void TkMacOSXSetColorInPort(unsigned long pixel, int fg, + PixPatHandle penPat, CGrafPtr port); +MODULE_SCOPE void TkMacOSXSetColorInContext(unsigned long pixel, + CGContextRef context); +MODULE_SCOPE int TkMacOSXRunTclEventLoop(void); +MODULE_SCOPE OSStatus TkMacOSXStartTclEventLoopCarbonTimer(void); +MODULE_SCOPE OSStatus TkMacOSXStopTclEventLoopCarbonTimer(void); +MODULE_SCOPE void TkMacOSXTrackingLoop(int tracking); +MODULE_SCOPE OSStatus TkMacOSXReceiveAndDispatchEvent(void); +MODULE_SCOPE void TkMacOSXInstallWindowCarbonEventHandler(Tcl_Interp *interp, + WindowRef window); +MODULE_SCOPE int TkMacOSXMakeFullscreen(TkWindow *winPtr, WindowRef window, + int fullscreen, Tcl_Interp *interp); +MODULE_SCOPE void TkMacOSXEnterExitFullscreen(TkWindow *winPtr, int active); +MODULE_SCOPE void TkMacOSXBringWindowForward(WindowRef wRef); +MODULE_SCOPE WindowRef TkMacOSXDrawableWindow(Drawable drawable); + +#endif /* _TKMACPRIV */ diff --git a/macosx/tkMacOSXRegion.c b/macosx/tkMacOSXRegion.c index d0c355e..e2252da 100644 --- a/macosx/tkMacOSXRegion.c +++ b/macosx/tkMacOSXRegion.c @@ -10,10 +10,10 @@ * See the file "license.terms" for information on usage and redistribution * of this file, and for a DISCLAIMER OF ALL WARRANTIES. * - * RCS: @(#) $Id: tkMacOSXRegion.c,v 1.8 2007/06/09 17:09:40 das Exp $ + * RCS: @(#) $Id: tkMacOSXRegion.c,v 1.9 2007/06/29 03:20:02 das Exp $ */ -#include "tkMacOSXInt.h" +#include "tkMacOSXPrivate.h" /* @@ -139,12 +139,12 @@ TkUnionRectWithRegion( TkRegion src_region, TkRegion dest_region_return) { - TkMacOSXCheckTmpRgnEmpty(1); - SetRectRgn(tkMacOSXtmpRgn1, rectangle->x, rectangle->y, + TkMacOSXCheckTmpQdRgnEmpty(); + SetRectRgn(tkMacOSXtmpQdRgn, rectangle->x, rectangle->y, rectangle->x + rectangle->width, rectangle->y + rectangle->height); - UnionRgn((RgnHandle) src_region, tkMacOSXtmpRgn1, + UnionRgn((RgnHandle) src_region, tkMacOSXtmpQdRgn, (RgnHandle) dest_region_return); - SetEmptyRgn(tkMacOSXtmpRgn1); + SetEmptyRgn(tkMacOSXtmpQdRgn); } /* @@ -174,17 +174,17 @@ TkRectInRegion( { int result; - TkMacOSXCheckTmpRgnEmpty(1); - SetRectRgn(tkMacOSXtmpRgn1, x, y, x + width, y + height); - SectRgn((RgnHandle) region, tkMacOSXtmpRgn1, tkMacOSXtmpRgn1); - if (EmptyRgn(tkMacOSXtmpRgn1)) { + TkMacOSXCheckTmpQdRgnEmpty(); + SetRectRgn(tkMacOSXtmpQdRgn, x, y, x + width, y + height); + SectRgn((RgnHandle) region, tkMacOSXtmpQdRgn, tkMacOSXtmpQdRgn); + if (EmptyRgn(tkMacOSXtmpQdRgn)) { result = RectangleOut; - } else if (EqualRgn((RgnHandle) region, tkMacOSXtmpRgn1)) { + } else if (EqualRgn((RgnHandle) region, tkMacOSXtmpQdRgn)) { result = RectangleIn; } else { result = RectanglePart; } - SetEmptyRgn(tkMacOSXtmpRgn1); + SetEmptyRgn(tkMacOSXtmpQdRgn); return result; } diff --git a/macosx/tkMacOSXScale.c b/macosx/tkMacOSXScale.c index c35c11d..001cbf9 100644 --- a/macosx/tkMacOSXScale.c +++ b/macosx/tkMacOSXScale.c @@ -11,10 +11,10 @@ * See the file "license.terms" for information on usage and redistribution * of this file, and for a DISCLAIMER OF ALL WARRANTIES. * - * RCS: @(#) $Id: tkMacOSXScale.c,v 1.13 2007/06/09 17:09:40 das Exp $ + * RCS: @(#) $Id: tkMacOSXScale.c,v 1.14 2007/06/29 03:20:02 das Exp $ */ -#include "tkMacOSXInt.h" +#include "tkMacOSXPrivate.h" #include "tkScale.h" /* @@ -209,7 +209,7 @@ TkpDisplayScale( macDraw = (MacDrawable *) Tk_WindowId(tkwin); destPort = TkMacOSXGetDrawablePort(Tk_WindowId(tkwin)); - windowRef = GetWindowFromPort(destPort); + windowRef = TkMacOSXDrawableWindow(Tk_WindowId(tkwin)); portChanged = QDSwapPort(destPort, &savePort); TkMacOSXSetUpClippingRgn(Tk_WindowId(tkwin)); diff --git a/macosx/tkMacOSXScrlbr.c b/macosx/tkMacOSXScrlbr.c index 2ab6cfe..1301170 100644 --- a/macosx/tkMacOSXScrlbr.c +++ b/macosx/tkMacOSXScrlbr.c @@ -12,15 +12,15 @@ * See the file "license.terms" for information on usage and redistribution * of this file, and for a DISCLAIMER OF ALL WARRANTIES. * - * RCS: @(#) $Id: tkMacOSXScrlbr.c,v 1.24 2007/06/09 17:09:40 das Exp $ + * RCS: @(#) $Id: tkMacOSXScrlbr.c,v 1.25 2007/06/29 03:20:02 das Exp $ */ -#include "tkMacOSXInt.h" +#include "tkMacOSXPrivate.h" #include "tkScrollbar.h" #include "tkMacOSXDebug.h" #define MIN_SCROLLBAR_VALUE 0 -#define SCROLLBAR_SCALING_VALUE ((float)LONG_MAX) +#define SCROLLBAR_SCALING_VALUE ((double)(LONG_MAX>>1)) /* * Declaration of Mac specific scrollbar structure. @@ -230,7 +230,6 @@ TkpDisplayScrollbar( TkScrollbar *scrollPtr = (TkScrollbar *) clientData; MacScrollbar *macScrollPtr = (MacScrollbar *) clientData; Tk_Window tkwin = scrollPtr->tkwin; - MacDrawable *macDraw; CGrafPtr destPort, savePort; Boolean portChanged; WindowRef windowRef; @@ -264,22 +263,12 @@ TkpDisplayScrollbar( Tk_Height(tkwin) - 2*scrollPtr->highlightWidth, scrollPtr->borderWidth, scrollPtr->relief); - /* - * Set up port for drawing Macintosh control. - */ - macDraw = (MacDrawable *) Tk_WindowId(tkwin); - destPort = TkMacOSXGetDrawablePort(Tk_WindowId(tkwin)); - portChanged = QDSwapPort(destPort, &savePort); - TkMacOSXSetUpClippingRgn(Tk_WindowId(tkwin)); - if (macScrollPtr->sbHandle == NULL) { Rect r = {0, 0, 1, 1}; - windowRef = GetWindowFromPort(destPort); - CreateScrollBarControl(windowRef, &r, MIN_SCROLLBAR_VALUE + - SCROLLBAR_SCALING_VALUE/2, MIN_SCROLLBAR_VALUE, - SCROLLBAR_SCALING_VALUE, SCROLLBAR_SCALING_VALUE - - MIN_SCROLLBAR_VALUE, true, NULL, &(macScrollPtr->sbHandle)); + windowRef = TkMacOSXDrawableWindow(Tk_WindowId(tkwin)); + CreateScrollBarControl(windowRef, &r, 0, 0, 0, 0, true, NULL, + &(macScrollPtr->sbHandle)); SetControlReference(macScrollPtr->sbHandle, (SInt32) scrollPtr); if (IsWindowActive(windowRef)) { @@ -294,6 +283,13 @@ TkpDisplayScrollbar( UpdateControlValues(macScrollPtr); /* + * Set up port for drawing Macintosh control. + */ + destPort = TkMacOSXGetDrawablePort(Tk_WindowId(tkwin)); + portChanged = QDSwapPort(destPort, &savePort); + TkMacOSXSetUpClippingRgn(Tk_WindowId(tkwin)); + + /* * Scrollbars do not erase the complete control bounds if they are wider * than the standard width, so manually erase the extra space. */ @@ -770,7 +766,7 @@ ScrollbarBindProc( if (eventPtr->type == ButtonPress) { Point where; Rect bounds; - int part; + ControlPartCode part; CGrafPtr destPort, savePort; Boolean portChanged; Window window; @@ -1025,10 +1021,10 @@ UpdateControlValues( dViewSize = (scrollPtr->lastFraction - scrollPtr->firstFraction) * SCROLLBAR_SCALING_VALUE; - SetControlViewSize(macScrollPtr->sbHandle, dViewSize); SetControl32BitMinimum(macScrollPtr->sbHandle, MIN_SCROLLBAR_VALUE); SetControl32BitMaximum(macScrollPtr->sbHandle, MIN_SCROLLBAR_VALUE + SCROLLBAR_SCALING_VALUE - dViewSize); + SetControlViewSize(macScrollPtr->sbHandle, dViewSize); SetControl32BitValue(macScrollPtr->sbHandle, MIN_SCROLLBAR_VALUE + SCROLLBAR_SCALING_VALUE * scrollPtr->firstFraction); diff --git a/macosx/tkMacOSXSubwindows.c b/macosx/tkMacOSXSubwindows.c index d5c7616..46d299d 100644 --- a/macosx/tkMacOSXSubwindows.c +++ b/macosx/tkMacOSXSubwindows.c @@ -10,10 +10,10 @@ * See the file "license.terms" for information on usage and redistribution * of this file, and for a DISCLAIMER OF ALL WARRANTIES. * - * RCS: @(#) $Id: tkMacOSXSubwindows.c,v 1.22 2007/06/09 17:09:41 das Exp $ + * RCS: @(#) $Id: tkMacOSXSubwindows.c,v 1.23 2007/06/29 03:20:02 das Exp $ */ -#include "tkMacOSXInt.h" +#include "tkMacOSXPrivate.h" #include "tkMacOSXDebug.h" #include "tkMacOSXWm.h" @@ -54,7 +54,7 @@ XDestroyWindow( Window window) /* Window. */ { MacDrawable *macWin = (MacDrawable *) window; - CGrafPtr destPort; + /* * Remove any dangling pointers that may exist if * the window we are deleting is being tracked by @@ -79,7 +79,7 @@ XDestroyWindow( if (macWin->grafPtr != NULL) { TkWindow *focusPtr = TkGetFocusWin(macWin->winPtr); if (focusPtr == NULL || (focusPtr->mainPtr->winPtr == macWin->winPtr)) { - winRef = GetWindowFromPort(macWin->grafPtr); + winRef = TkMacOSXDrawableWindow(window); if (TkpIsWindowFloating (winRef)) { Window window; @@ -102,11 +102,11 @@ XDestroyWindow( */ if (!(Tk_IsEmbedded(macWin->winPtr))) { - destPort = TkMacOSXGetDrawablePort(window); - if (destPort != NULL) { + WindowRef winRef = TkMacOSXDrawableWindow(window); + + if (winRef) { TkMacOSXWindowList *listPtr, *prevPtr; - WindowRef winRef; - winRef = GetWindowFromPort(destPort); + TkMacOSXUnregisterMacWindow(winRef); DisposeWindow(winRef); @@ -175,7 +175,6 @@ XMapWindow( { MacDrawable *macWin = (MacDrawable *) window; XEvent event; - CGrafPtr destPort; /* * Under certain situations it's possible for this function to be @@ -190,19 +189,18 @@ XMapWindow( display->request++; macWin->winPtr->flags |= TK_MAPPED; - destPort = TkMacOSXGetDrawablePort (window); if (Tk_IsTopLevel(macWin->winPtr)) { if (!Tk_IsEmbedded(macWin->winPtr)) { /* * XXX This should be ShowSheetWindow for kSheetWindowClass * XXX windows that have a wmPtr->master parent set. */ - WindowRef wRef = GetWindowFromPort(destPort); + WindowRef wRef = TkMacOSXDrawableWindow(window); + if ((macWin->winPtr->wmInfoPtr->macClass == kSheetWindowClass) && (macWin->winPtr->wmInfoPtr->master != None)) { - ShowSheetWindow(wRef, - GetWindowFromPort(TkMacOSXGetDrawablePort( - macWin->winPtr->wmInfoPtr->master))); + ShowSheetWindow(wRef, TkMacOSXDrawableWindow( + macWin->winPtr->wmInfoPtr->master)); } else { ShowWindow(wRef); } @@ -256,11 +254,9 @@ XUnmapWindow( { MacDrawable *macWin = (MacDrawable *) window; XEvent event; - CGrafPtr destPort; display->request++; macWin->winPtr->flags &= ~TK_MAPPED; - destPort = TkMacOSXGetDrawablePort(window); if (Tk_IsTopLevel(macWin->winPtr)) { if (!Tk_IsEmbedded(macWin->winPtr) && macWin->winPtr->wmInfoPtr->hints.initial_state != IconicState) { @@ -268,7 +264,8 @@ XUnmapWindow( * XXX This should be HideSheetWindow for kSheetWindowClass * XXX windows that have a wmPtr->master parent set. */ - WindowRef wref = GetWindowFromPort(destPort); + WindowRef wref = TkMacOSXDrawableWindow(window); + if ((macWin->winPtr->wmInfoPtr->macClass == kSheetWindowClass) && (macWin->winPtr->wmInfoPtr->master != None)) { HideSheetWindow(wref); @@ -329,10 +326,9 @@ XResizeWindow( display->request++; if (Tk_IsTopLevel(macWin->winPtr) && !Tk_IsEmbedded(macWin->winPtr)) { - CGrafPtr destPort = TkMacOSXGetDrawablePort(window); + WindowRef w = TkMacOSXDrawableWindow(window); - if (destPort) { - WindowRef w = GetWindowFromPort(destPort); + if (w) { Rect bounds; ChkErr(GetWindowBounds, w, kWindowContentRgn, &bounds); @@ -374,10 +370,9 @@ XMoveResizeWindow( display->request++; if (Tk_IsTopLevel(macWin->winPtr) && !Tk_IsEmbedded(macWin->winPtr)) { - CGrafPtr destPort = TkMacOSXGetDrawablePort(window); + WindowRef w = TkMacOSXDrawableWindow(window); - if (destPort) { - WindowRef w = GetWindowFromPort(destPort); + if (w) { Rect bounds; bounds.left = x + macWin->winPtr->wmInfoPtr->xInParent; @@ -419,11 +414,9 @@ XMoveWindow( display->request++; if (Tk_IsTopLevel(macWin->winPtr) && !Tk_IsEmbedded(macWin->winPtr)) { - CGrafPtr destPort = TkMacOSXGetDrawablePort(window); - - if (destPort) { - WindowRef w = GetWindowFromPort(destPort); + WindowRef w = TkMacOSXDrawableWindow(window); + if (w) { ChkErr(MoveWindowStructure, w, x, y); } } else { @@ -651,13 +644,12 @@ XConfigureWindow( if (value_mask & CWStackMode) { Rect bounds; - CGrafPtr destPort; + WindowRef wRef = TkMacOSXDrawableWindow(w); - destPort = TkMacOSXGetDrawablePort(w); - if (destPort != NULL) { + if (wRef) { TkMacOSXInvalClipRgns((Tk_Window) winPtr->parentPtr); TkMacOSXWinBounds(winPtr, &bounds); - InvalWindowRect(GetWindowFromPort(destPort),&bounds); + InvalWindowRect(wRef, &bounds); } } @@ -698,18 +690,15 @@ TkMacOSXUpdateClipRgn( TkWindow *win2Ptr; if (Tk_IsMapped(winPtr)) { - int x, y; + Rect bounds; RgnHandle rgn = macWin->aboveClipRgn; /* * Start with a region defined by the window bounds. */ - x = macWin->xOff; - y = macWin->yOff; - SetRectRgn(rgn, (short) x, (short) y, - (short) (winPtr->changes.width + x), - (short) (winPtr->changes.height + y)); + TkMacOSXWinBounds(winPtr, &bounds); + RectRgn(rgn, &bounds); /* * Clip away the area of any windows that may obscure this @@ -726,7 +715,7 @@ TkMacOSXUpdateClipRgn( if (!Tk_IsTopLevel(winPtr)) { TkMacOSXUpdateClipRgn(winPtr->parentPtr); - TkMacOSXCheckTmpRgnEmpty(1); + TkMacOSXCheckTmpQdRgnEmpty(); if (winPtr->parentPtr) { SectRgn(rgn, winPtr->parentPtr->privatePtr->aboveClipRgn, rgn); @@ -736,24 +725,21 @@ TkMacOSXUpdateClipRgn( if (Tk_IsTopLevel(win2Ptr) || !Tk_IsMapped(win2Ptr)) { continue; } - x = win2Ptr->privatePtr->xOff; - y = win2Ptr->privatePtr->yOff; - SetRectRgn(tkMacOSXtmpRgn1, (short) x, (short) y, - (short) (win2Ptr->changes.width + x), - (short) (win2Ptr->changes.height + y)); - DiffRgn(rgn, tkMacOSXtmpRgn1, rgn); + TkMacOSXWinBounds(win2Ptr, &bounds); + RectRgn(tkMacOSXtmpQdRgn, &bounds); + DiffRgn(rgn, tkMacOSXtmpQdRgn, rgn); } } else if (Tk_IsEmbedded(winPtr)) { win2Ptr = TkpGetOtherWindow(winPtr); if (win2Ptr) { TkMacOSXUpdateClipRgn(win2Ptr); - TkMacOSXCheckTmpRgnEmpty(1); + TkMacOSXCheckTmpQdRgnEmpty(); SectRgn(rgn, win2Ptr->privatePtr->aboveClipRgn, rgn); } else if (tkMacOSXEmbedHandler != NULL) { - TkMacOSXCheckTmpRgnEmpty(1); + TkMacOSXCheckTmpQdRgnEmpty(); tkMacOSXEmbedHandler->getClipProc((Tk_Window) winPtr, - tkMacOSXtmpRgn1); - SectRgn(rgn, tkMacOSXtmpRgn1, rgn); + tkMacOSXtmpQdRgn); + SectRgn(rgn, tkMacOSXtmpQdRgn, rgn); } /* @@ -776,12 +762,9 @@ TkMacOSXUpdateClipRgn( win2Ptr = win2Ptr->nextPtr; continue; } - x = win2Ptr->privatePtr->xOff; - y = win2Ptr->privatePtr->yOff; - SetRectRgn(tkMacOSXtmpRgn1, (short) x, (short) y, - (short) (win2Ptr->changes.width + x), - (short) (win2Ptr->changes.height + y)); - DiffRgn(rgn, tkMacOSXtmpRgn1, rgn); + TkMacOSXWinBounds(win2Ptr, &bounds); + RectRgn(tkMacOSXtmpQdRgn, &bounds); + DiffRgn(rgn, tkMacOSXtmpQdRgn, rgn); win2Ptr = win2Ptr->nextPtr; } @@ -789,12 +772,9 @@ TkMacOSXUpdateClipRgn( win2Ptr = TkpGetOtherWindow(winPtr); if (win2Ptr) { if (Tk_IsMapped(win2Ptr)) { - x = win2Ptr->privatePtr->xOff; - y = win2Ptr->privatePtr->yOff; - SetRectRgn(tkMacOSXtmpRgn1, (short) x, (short) y, - (short) (win2Ptr->changes.width + x), - (short) (win2Ptr->changes.height + y)); - DiffRgn(rgn, tkMacOSXtmpRgn1, rgn); + TkMacOSXWinBounds(win2Ptr, &bounds); + RectRgn(tkMacOSXtmpQdRgn, &bounds); + DiffRgn(rgn, tkMacOSXtmpQdRgn, rgn); } } @@ -802,7 +782,7 @@ TkMacOSXUpdateClipRgn( * TODO: Here we should handle out of process embedding. */ } - SetEmptyRgn(tkMacOSXtmpRgn1); + SetEmptyRgn(tkMacOSXtmpQdRgn); } else { /* * An unmapped window has empty clip regions to prevent any @@ -824,8 +804,7 @@ TkMacOSXUpdateClipRgn( macWin->flags &= ~TK_CLIP_INVALID; #ifdef TK_MAC_DEBUG_CLIP_REGIONS - TkMacOSXDebugFlashRegion(TkMacOSXGetDrawablePort((Drawable) macWin), - macWin->visRgn); + TkMacOSXDebugFlashRegion((Drawable) macWin, macWin->clipRgn); #endif /* TK_MAC_DEBUG_CLIP_REGIONS */ } } @@ -881,11 +860,9 @@ TkMacOSXInvalidateWindow( * TK_PARENT_WINDOW */ { WindowRef windowRef; - CGrafPtr grafPtr; RgnHandle rgn; - grafPtr = TkMacOSXGetDrawablePort((Drawable)macWin); - windowRef = GetWindowFromPort(grafPtr); + windowRef = TkMacOSXDrawableWindow((Drawable)macWin); if (macWin->flags & TK_CLIP_INVALID) { TkMacOSXUpdateClipRgn(macWin->winPtr); } @@ -894,13 +871,44 @@ TkMacOSXInvalidateWindow( InvalWindowRgn(windowRef, rgn); } #ifdef TK_MAC_DEBUG_CLIP_REGIONS - TkMacOSXDebugFlashRegion(grafPtr, rgn); + TkMacOSXDebugFlashRegion((Drawable) macWin, rgn); #endif /* TK_MAC_DEBUG_CLIP_REGIONS */ } /* *---------------------------------------------------------------------- * + * TkMacOSXGetDrawableWindow -- + * + * This function returns the WindowRef for a given X drawable. + * + * Results: + * A WindowRef, or NULL for off screen pixmaps. + * + * Side effects: + * None. + * + *---------------------------------------------------------------------- + */ + +WindowRef +TkMacOSXDrawableWindow( + Drawable drawable) +{ + MacDrawable *macWin = (MacDrawable *) drawable; + WindowRef result = NULL; + + if (!macWin || !macWin->clipRgn) { + result = NULL; + } else { + result = GetWindowFromPort(TkMacOSXGetDrawablePort(drawable)); + } + return result; +} + +/* + *---------------------------------------------------------------------- + * * TkMacOSXGetDrawablePort -- * * This function returns the Graphics Port for a given X drawable. @@ -921,61 +929,53 @@ TkMacOSXGetDrawablePort( MacDrawable *macWin = (MacDrawable *) drawable; CGrafPtr resultPort = NULL; - if (macWin == NULL) { - return NULL; - } - - /* - * This is NULL for off-screen pixmaps. Then the portPtr - * always points to the off-screen port, and we don't - * have to worry about containment - */ + if (macWin) { + resultPort = macWin->grafPtr; + if (macWin->toplevel && macWin->clipRgn) { + /* + * If the Drawable is in an embedded window, use the Port of its + * container. + * + * TRICKY POINT: we can have cases when a toplevel is being + * destroyed where the winPtr for the toplevel has been freed, but + * the children are not all the way destroyed. The children will + * call this function as they are being destroyed, but + * Tk_IsEmbedded will return garbage. So we check the copy of the + * TK_EMBEDDED flag we put into the toplevel's macWin flags. + */ - if (macWin->clipRgn == NULL) { - return macWin->grafPtr; - } + if (macWin->toplevel->flags & TK_EMBEDDED) { + TkWindow *contWinPtr; - /* - * If the Drawable is in an embedded window, use the Port of its container. - * - * TRICKY POINT: we can have cases when a toplevel is being destroyed - * where the winPtr for the toplevel has been freed, but the children - * are not all the way destroyed. The children will call this function - * as they are being destroyed, but Tk_IsEmbedded will return garbage. - * So we check the copy of the TK_EMBEDDED flag we put into the - * toplevel's macWin flags. - */ - - if (!(macWin->toplevel->flags & TK_EMBEDDED)) { - return macWin->toplevel->grafPtr; - } else { - TkWindow *contWinPtr; + contWinPtr = TkpGetOtherWindow(macWin->toplevel->winPtr); - contWinPtr = TkpGetOtherWindow(macWin->toplevel->winPtr); + if (contWinPtr != NULL) { + resultPort = TkMacOSXGetDrawablePort( + (Drawable) contWinPtr->privatePtr); + } else if (tkMacOSXEmbedHandler != NULL) { + resultPort = tkMacOSXEmbedHandler->getPortProc( + (Tk_Window) macWin->winPtr); + } - if (contWinPtr != NULL) { - resultPort = TkMacOSXGetDrawablePort( - (Drawable) contWinPtr->privatePtr); - } else if (tkMacOSXEmbedHandler != NULL) { - resultPort = tkMacOSXEmbedHandler->getPortProc( - (Tk_Window) macWin->winPtr); - } + if (resultPort == NULL) { + /* + * FIXME: So far as I can tell, the only time that this + * happens is when we are tearing down an embedded child + * interpreter, and most of the time, this is harmless... + * However, we really need to find why the embedding loses. + */ + TkMacOSXDbgMsg("Couldn't find container"); + } - if (resultPort == NULL) { - /* - * FIXME: So far as I can tell, the only time that this happens is - * when we are tearing down an embedded child interpreter, and most - * of the time, this is harmless... However, we really need to - * find why the embedding loses. - */ - TkMacOSXDbgMsg("Couldn't find container"); - return NULL; + /* + * TODO: Here we should handle out of process embedding. + */ + } else { + resultPort = macWin->toplevel->grafPtr; + } } - - /* - * TODO: Here we should handle out of process embedding. - */ } + return resultPort; } @@ -1118,12 +1118,10 @@ TkMacOSXWinBounds( TkWindow *winPtr, Rect *bounds) { - bounds->left = (short) winPtr->privatePtr->xOff; - bounds->top = (short) winPtr->privatePtr->yOff; - bounds->right = (short) (winPtr->privatePtr->xOff + - winPtr->changes.width); - bounds->bottom = (short) (winPtr->privatePtr->yOff + - winPtr->changes.height); + bounds->left = winPtr->privatePtr->xOff; + bounds->top = winPtr->privatePtr->yOff; + bounds->right = bounds->left + winPtr->changes.width; + bounds->bottom = bounds->top + winPtr->changes.height; } /* @@ -1211,7 +1209,7 @@ Tk_GetPixmap( { QDErr err; GWorldPtr gWorld; - Rect bounds; + Rect bounds = {0, 0, height, width}; MacDrawable *macPix; if (display != NULL) { @@ -1227,19 +1225,10 @@ Tk_GetPixmap( macPix->referenceCount = 0; macPix->toplevel = NULL; macPix->flags = 0; + macPix->grafPtr = NULL; + macPix->context = NULL; - bounds.top = bounds.left = 0; - bounds.right = (short) width; - bounds.bottom = (short) height; - if (depth != 1) { - depth = 0; - } - /* - * Allocate memory for the off screen pixmap. If we fail - * try again from system memory. Eventually, we may have - * to panic. - */ - err = ChkErr(NewGWorld, &gWorld, depth, &bounds, NULL, NULL, 0 + err = ChkErr(NewGWorld, &gWorld, depth == 1 ? 1 : 0, &bounds, NULL, NULL, 0 #ifdef __LITTLE_ENDIAN__ | kNativeEndianPixMap #endif @@ -1248,7 +1237,6 @@ Tk_GetPixmap( Tcl_Panic("Out of memory: NewGWorld failed in Tk_GetPixmap"); } macPix->grafPtr = gWorld; - macPix->context = NULL; return (Pixmap) macPix; } @@ -1277,6 +1265,8 @@ Tk_FreePixmap( MacDrawable *macPix = (MacDrawable *) pixmap; display->request++; - DisposeGWorld(macPix->grafPtr); + if (macPix->grafPtr) { + DisposeGWorld(macPix->grafPtr); + } ckfree((char *) macPix); } diff --git a/macosx/tkMacOSXWindowEvent.c b/macosx/tkMacOSXWindowEvent.c index 1b71cad..fb53c81 100644 --- a/macosx/tkMacOSXWindowEvent.c +++ b/macosx/tkMacOSXWindowEvent.c @@ -54,10 +54,10 @@ * software in accordance with the terms specified in this * license. * - * RCS: @(#) $Id: tkMacOSXWindowEvent.c,v 1.26 2007/06/09 17:09:41 das Exp $ + * RCS: @(#) $Id: tkMacOSXWindowEvent.c,v 1.27 2007/06/29 03:20:02 das Exp $ */ -#include "tkMacOSXInt.h" +#include "tkMacOSXPrivate.h" #include "tkMacOSXWm.h" #include "tkMacOSXEvent.h" #include "tkMacOSXDebug.h" @@ -445,7 +445,7 @@ GenerateUpdateEvent(Window window) TkDisplay *dispPtr; TkWindow *winPtr; int result = 0; - Rect updateBounds; + Rect updateBounds, bounds; dispPtr = TkGetDisplayList(); winPtr = (TkWindow *)Tk_IdToWindow(dispPtr->display, window); @@ -453,23 +453,24 @@ GenerateUpdateEvent(Window window) if (winPtr ==NULL ){ return result; } - TkMacOSXCheckTmpRgnEmpty(1); + TkMacOSXCheckTmpQdRgnEmpty(); destPort = TkMacOSXGetDrawablePort(window); macWindow = GetWindowFromPort(destPort); - ChkErr(GetWindowRegion, macWindow, kWindowUpdateRgn, tkMacOSXtmpRgn1); - QDGlobalToLocalRegion(destPort, tkMacOSXtmpRgn1); - SectRegionWithPortVisibleRegion(destPort, tkMacOSXtmpRgn1); - GetRegionBounds(tkMacOSXtmpRgn1, &updateBounds); + ChkErr(GetWindowRegion, macWindow, kWindowUpdateRgn, tkMacOSXtmpQdRgn); + ChkErr(GetWindowBounds, macWindow, kWindowContentRgn, &bounds); + OffsetRgn(tkMacOSXtmpQdRgn, -bounds.left, -bounds.top); + SectRegionWithPortVisibleRegion(destPort, tkMacOSXtmpQdRgn); + GetRegionBounds(tkMacOSXtmpQdRgn, &updateBounds); #ifdef TK_MAC_DEBUG_CLIP_REGIONS - TkMacOSXDebugFlashRegion(destPort, tkMacOSXtmpRgn1); + TkMacOSXDebugFlashRegion(window, tkMacOSXtmpQdRgn); #endif /* TK_MAC_DEBUG_CLIP_REGIONS */ BeginUpdate(macWindow); if (winPtr->wmInfoPtr->flags & WM_TRANSPARENT) { - ClearPort(destPort, tkMacOSXtmpRgn1); + ClearPort(destPort, tkMacOSXtmpQdRgn); } - result = GenerateUpdates(tkMacOSXtmpRgn1, &updateBounds, winPtr); + result = GenerateUpdates(tkMacOSXtmpQdRgn, &updateBounds, winPtr); EndUpdate(macWindow); - SetEmptyRgn(tkMacOSXtmpRgn1); + SetEmptyRgn(tkMacOSXtmpQdRgn); if (result) { /* * Ensure there are no pending idle-time redraws that could prevent @@ -531,7 +532,6 @@ GenerateUpdates( } RectRgn(damageRgn, &bounds); SectRgn(damageRgn, updateRgn, damageRgn); - OffsetRgn(damageRgn, -bounds.left, -bounds.top); GetRegionBounds(damageRgn, &damageBounds); RectRgn(damageRgn, &bounds); UnionRgn(damageRgn, updateRgn, updateRgn); @@ -543,10 +543,10 @@ GenerateUpdates( event.xany.window = Tk_WindowId(winPtr); event.xany.display = Tk_Display(winPtr); event.type = Expose; - event.xexpose.x = damageBounds.left; - event.xexpose.y = damageBounds.top; - event.xexpose.width = damageBounds.right-damageBounds.left; - event.xexpose.height = damageBounds.bottom-damageBounds.top; + event.xexpose.x = damageBounds.left - bounds.left; + event.xexpose.y = damageBounds.top - bounds.top; + event.xexpose.width = damageBounds.right - damageBounds.left; + event.xexpose.height = damageBounds.bottom - damageBounds.top; event.xexpose.count = 0; Tk_QueueWindowEvent(&event, TCL_QUEUE_TAIL); @@ -954,6 +954,9 @@ ClearPort( GetPortBounds(port, &bounds); QDBeginCGContext(port, &context); + SyncCGContextOriginWithPort(context, port); + CGContextConcatCTM(context, CGAffineTransformMake(1.0, 0.0, 0.0, -1.0, 0.0, + bounds.bottom - bounds.top)); if (updateRgn) { ClipCGContextToRegion(context, &bounds, updateRgn); } diff --git a/macosx/tkMacOSXWm.c b/macosx/tkMacOSXWm.c index 0f5abf3..d307bce 100644 --- a/macosx/tkMacOSXWm.c +++ b/macosx/tkMacOSXWm.c @@ -13,10 +13,10 @@ * See the file "license.terms" for information on usage and redistribution * of this file, and for a DISCLAIMER OF ALL WARRANTIES. * - * RCS: @(#) $Id: tkMacOSXWm.c,v 1.54 2007/06/09 17:09:41 das Exp $ + * RCS: @(#) $Id: tkMacOSXWm.c,v 1.55 2007/06/29 03:20:02 das Exp $ */ -#include "tkMacOSXInt.h" +#include "tkMacOSXPrivate.h" #include "tkScrollbar.h" #include "tkMacOSXWm.h" #include "tkMacOSXEvent.h" @@ -997,7 +997,7 @@ WmAttributesCmd( if (!TkMacOSXHostToplevelExists(winPtr)) { TkMacOSXMakeRealWindowExist(winPtr); } - macWindow = GetWindowFromPort(TkMacOSXGetDrawablePort(winPtr->window)); + macWindow = TkMacOSXDrawableWindow(winPtr->window); if (objc == 3) { /* wm attributes $win */ Tcl_Obj *result = Tcl_NewListObj(0,0); @@ -1648,8 +1648,8 @@ WmIconbitmapCmd( if (!TkMacOSXHostToplevelExists(winPtr)) { TkMacOSXMakeRealWindowExist(winPtr); } - if (WmSetAttribute(winPtr, GetWindowFromPort(TkMacOSXGetDrawablePort( - winPtr->window)), interp, WMATT_TITLEPATH, objv[3]) == TCL_OK) { + if (WmSetAttribute(winPtr, TkMacOSXDrawableWindow(winPtr->window), interp, + WMATT_TITLEPATH, objv[3]) == TCL_OK) { if (!len) { if (wmPtr->hints.icon_pixmap != None) { Tk_FreeBitmap(winPtr->display, wmPtr->hints.icon_pixmap); @@ -4074,7 +4074,7 @@ TkWmRestackToplevel( TkWmMapWindow(winPtr); } - macWindow = GetWindowFromPort(TkMacOSXGetDrawablePort(winPtr->window)); + macWindow = TkMacOSXDrawableWindow(winPtr->window); /* * Get the window in which a raise or lower is in relation to. @@ -4086,8 +4086,7 @@ TkWmRestackToplevel( if (otherPtr->wmInfoPtr->flags & WM_NEVER_MAPPED) { TkWmMapWindow(otherPtr); } - otherMacWindow = GetWindowFromPort(TkMacOSXGetDrawablePort( - otherPtr->window)); + otherMacWindow = TkMacOSXDrawableWindow(otherPtr->window); } else { otherMacWindow = NULL; } @@ -4572,8 +4571,7 @@ TkSetWMName( title = CFStringCreateWithBytes(NULL, (const unsigned char*) titleUid, strlen(titleUid), kCFStringEncodingUTF8, false); if (title) { - WindowRef macWin = GetWindowFromPort( - TkMacOSXGetDrawablePort(winPtr->window)); + WindowRef macWin = TkMacOSXDrawableWindow(winPtr->window); SetWindowTitleWithCFString(macWin, title); CFRelease(title); @@ -4695,8 +4693,7 @@ TkMacOSXIsWindowZoomed( idealSize.v = maxHeight; } - return IsWindowInStandardState( - GetWindowFromPort(TkMacOSXGetDrawablePort(winPtr->window)), + return IsWindowInStandardState(TkMacOSXDrawableWindow(winPtr->window), &idealSize, NULL); } @@ -5442,7 +5439,7 @@ TkpWmSetState(winPtr, state) return; } - macWin = GetWindowFromPort(TkMacOSXGetDrawablePort (winPtr->window)); + macWin = TkMacOSXDrawableWindow(winPtr->window); if (state == WithdrawnState) { Tk_UnmapWindow((Tk_Window) winPtr); @@ -5694,7 +5691,7 @@ WmStackorderToplevelWrapperMap( if (Tk_IsMapped(winPtr) && Tk_IsTopLevel(winPtr) && (winPtr->display == display)) { - macWindow = GetWindowFromPort(TkMacOSXGetDrawablePort(winPtr->window)); + macWindow = TkMacOSXDrawableWindow(winPtr->window); hPtr = Tcl_CreateHashEntry(table, (const char *) macWindow, &newEntry); @@ -5831,8 +5828,7 @@ ApplyWindowClassAttributeChanges( return; } } - macWindow = GetWindowFromPort(TkMacOSXGetDrawablePort( - winPtr->window)); + macWindow = TkMacOSXDrawableWindow(winPtr->window); } if (wmPtr->macClass != oldClass) { TK_IF_MAC_OS_X_API (4, HIWindowChangeClass, @@ -5934,7 +5930,7 @@ ApplyMasterOverrideChanges( if (!TkMacOSXHostToplevelExists(winPtr)) { return; } - macWindow = GetWindowFromPort(TkMacOSXGetDrawablePort(winPtr->window)); + macWindow = TkMacOSXDrawableWindow(winPtr->window); } if (macWindow) { Tcl_Obj *val; diff --git a/macosx/tkMacOSXXStubs.c b/macosx/tkMacOSXXStubs.c index 54ef360..6b2b7dd 100644 --- a/macosx/tkMacOSXXStubs.c +++ b/macosx/tkMacOSXXStubs.c @@ -13,10 +13,10 @@ * See the file "license.terms" for information on usage and redistribution * of this file, and for a DISCLAIMER OF ALL WARRANTIES. * - * RCS: @(#) $Id: tkMacOSXXStubs.c,v 1.21 2007/06/23 00:26:32 das Exp $ + * RCS: @(#) $Id: tkMacOSXXStubs.c,v 1.22 2007/06/29 03:20:02 das Exp $ */ -#include "tkMacOSXInt.h" +#include "tkMacOSXPrivate.h" #include "tkMacOSXEvent.h" #include @@ -816,7 +816,7 @@ XCreateImage( if (bitmap_pad) { ximage->bitmap_pad = bitmap_pad; } else { - /* Use 16 byte alignment for best perfomance */ + /* Use 16 byte alignment for best Quartz perfomance */ ximage->bitmap_pad = 128; } if (bytes_per_line) { @@ -922,8 +922,7 @@ XGetImage( * * DestroyImage -- * - * This is a trivial wrapper around ckfree to make it possible to pass - * ckfree as a pointer. + * Destroys storage associated with an image. * * Results: * None. @@ -943,7 +942,7 @@ DestroyImage( Tk_FreePixmap((Display*) gMacDisplay, (Pixmap) image->obdata); } if (image->data) { - ckfree((char*) image->data); + ckfree(image->data); } ckfree((char*) image); } diff --git a/macosx/ttkMacOSXTheme.c b/macosx/ttkMacOSXTheme.c index cb8d137..2606264 100644 --- a/macosx/ttkMacOSXTheme.c +++ b/macosx/ttkMacOSXTheme.c @@ -27,10 +27,10 @@ * top-level window, not to the Tk_Window. BoxToRect() * accounts for this. * - * RCS: @(#) $Id: ttkMacOSXTheme.c,v 1.7 2007/04/27 04:40:39 jenglish Exp $ + * RCS: @(#) $Id: ttkMacOSXTheme.c,v 1.8 2007/06/29 03:20:02 das Exp $ */ -#include "tkMacOSXInt.h" +#include "tkMacOSXPrivate.h" #include "ttk/ttkTheme.h" #define BEGIN_DRAWING(d) { \ -- cgit v0.12