diff options
author | das <das> | 2002-10-16 19:44:03 (GMT) |
---|---|---|
committer | das <das> | 2002-10-16 19:44:03 (GMT) |
commit | 64d539d78e921586faa1e06ad5b9a68076339426 (patch) | |
tree | a3de38595586e599fadda3d5a3812472f5108f3b /macosx | |
parent | 2e07b35ed88ed49ca201b23ec54d40cc1d3ceb39 (diff) | |
download | tk-64d539d78e921586faa1e06ad5b9a68076339426.zip tk-64d539d78e921586faa1e06ad5b9a68076339426.tar.gz tk-64d539d78e921586faa1e06ad5b9a68076339426.tar.bz2 |
* macosx/Wish.pbproj/project.pbxproj: added TEXT document
type to plist so that files can be dragged onto Wish Shell.
* macosx/tkMacOSXInt.h:
* macosx/tkMacOSXInit.c:
* macosx/tkMacOSXFont.c: added private proc
TkMacOSXUseAntialiasedText() to enable/disable quickdraw
text antialiasing where available, default is enabled.
Added a linked boolean ::tk::mac::antialiasedtext with
write trace to allow control of antialiasing from tcl.
Diffstat (limited to 'macosx')
-rw-r--r-- | macosx/Wish.pbproj/project.pbxproj | 17 | ||||
-rw-r--r-- | macosx/tkMacOSXFont.c | 90 | ||||
-rw-r--r-- | macosx/tkMacOSXInit.c | 5 | ||||
-rw-r--r-- | macosx/tkMacOSXInt.h | 4 |
4 files changed, 112 insertions, 4 deletions
diff --git a/macosx/Wish.pbproj/project.pbxproj b/macosx/Wish.pbproj/project.pbxproj index dfe39a7..45ab708 100644 --- a/macosx/Wish.pbproj/project.pbxproj +++ b/macosx/Wish.pbproj/project.pbxproj @@ -2776,6 +2776,23 @@ MacOS X Port by Jim Ingham <jingham@apple.com> & Ian Reid, Copyright  <dict> <key>CFBundleDevelopmentRegion</key> <string>English</string> + <key>CFBundleDocumentTypes</key> + <array> + <dict> + <key>CFBundleTypeExtensions</key> + <array> + <string>*</string> + </array> + <key>CFBundleTypeName</key> + <string>NSStringPboardType</string> + <key>CFBundleTypeOSTypes</key> + <array> + <string>TEXT</string> + </array> + <key>CFBundleTypeRole</key> + <string>Viewer</string> + </dict> + </array> <key>CFBundleExecutable</key> <string>Wish Shell</string> <key>CFBundleGetInfoString</key> diff --git a/macosx/tkMacOSXFont.c b/macosx/tkMacOSXFont.c index 40e637d..1a6556c 100644 --- a/macosx/tkMacOSXFont.c +++ b/macosx/tkMacOSXFont.c @@ -11,10 +11,12 @@ * See the file "license.terms" for information on usage and redistribution * of this file, and for a DISCLAIMER OF ALL WARRANTIES. * - * RCS: @(#) $Id: tkMacOSXFont.c,v 1.2 2002/08/31 06:12:29 das Exp $ + * RCS: @(#) $Id: tkMacOSXFont.c,v 1.3 2002/10/16 19:44:05 das Exp $ */ #include <Carbon/Carbon.h> +#include "tclInt.h" + #include "tkMacOSXInt.h" #include "tkFont.h" @@ -2189,3 +2191,89 @@ TkMacOSXInitControlFontStyle(Tk_Font tkfont, ControlFontStylePtr fsPtr) fsPtr->style = fontPtr->style; fsPtr->just = teCenter; } + +/* + *---------------------------------------------------------------------- + * + * TkMacOSXUseAntialiasedText -- + * + * Enables or disables application-wide use of quickdraw + * antialiased text (where available). + * Sets up a linked tcl global boolean variable with write trace + * to allow disabling of antialiased text from tcl. + * + * Results: + * TCL_OK if facility was sucessfully enabled/disabled. + * TCL_ERROR if an error occurred or if facility is not available. + * + * Side effects: + * None. + * + *---------------------------------------------------------------------- + */ + +#include <mach-o/dyld.h> + +/* define constants from 10.2 Quickdraw.h to enable compilation in 10.1 */ +#define kQDUseTrueTypeScalerGlyphs (1 << 0) +#define kQDUseCGTextRendering (1 << 1) +#define kQDUseCGTextMetrics (1 << 2) + +static int TkMacOSXAntialiasedTextEnabled = FALSE; + +static char * +TkMacOSXAntialiasedTextVariableProc(clientData, interp, name1, name2, flags) + ClientData clientData; + Tcl_Interp *interp; + CONST char *name1; + CONST char *name2; + int flags; +{ + TkMacOSXUseAntialiasedText(interp, TkMacOSXAntialiasedTextEnabled); + return (char *) NULL; +} + +int TkMacOSXUseAntialiasedText(interp, enable) + Tcl_Interp *interp; + int enable; +{ + static Boolean initialized = FALSE; + static UInt32 (*swaptextflags)(UInt32) = NULL; + + if(!initialized) { + NSSymbol nsSymbol=NULL; + if(NSIsSymbolNameDefinedWithHint("_QDSwapTextFlags", "QD")) { + nsSymbol = NSLookupAndBindSymbolWithHint("_QDSwapTextFlags", "QD"); + } else if(NSIsSymbolNameDefinedWithHint("_SwapQDTextFlags", "QD")) { + nsSymbol = NSLookupAndBindSymbolWithHint("_SwapQDTextFlags", "QD"); + } + if(nsSymbol) { + swaptextflags = NSAddressOfSymbol(nsSymbol); + } + initialized = TRUE; + + TkMacOSXAntialiasedTextEnabled = (swaptextflags ? enable : FALSE); + if (Tcl_CreateNamespace(interp, "::tk::mac", NULL, NULL) == NULL) { + Tcl_ResetResult(interp); + } + if (Tcl_TraceVar(interp, "::tk::mac::antialiasedtext", + TCL_GLOBAL_ONLY | TCL_TRACE_WRITES, + TkMacOSXAntialiasedTextVariableProc, NULL) != TCL_OK) { + Tcl_ResetResult(interp); + } + if (Tcl_LinkVar(interp, "::tk::mac::antialiasedtext", + (char *) &TkMacOSXAntialiasedTextEnabled, + TCL_LINK_BOOLEAN) != TCL_OK) { + Tcl_ResetResult(interp); + } + } + if(swaptextflags) { + swaptextflags(enable ? kQDUseCGTextRendering | kQDUseCGTextMetrics + : kQDUseTrueTypeScalerGlyphs); + TkMacOSXAntialiasedTextEnabled = enable; + return TCL_OK; + } else { + TkMacOSXAntialiasedTextEnabled = FALSE; + return TCL_ERROR; + } +} diff --git a/macosx/tkMacOSXInit.c b/macosx/tkMacOSXInit.c index ffcab99..2180769 100644 --- a/macosx/tkMacOSXInit.c +++ b/macosx/tkMacOSXInit.c @@ -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: tkMacOSXInit.c,v 1.2 2002/08/31 06:12:30 das Exp $ + * RCS: @(#) $Id: tkMacOSXInit.c,v 1.3 2002/10/16 19:44:05 das Exp $ */ #include "tkInt.h" @@ -72,7 +72,7 @@ static Map scriptMap[] = { Tcl_Encoding TkMacOSXCarbonEncoding = NULL; - + /* *---------------------------------------------------------------------- * @@ -111,6 +111,7 @@ TkpInit(interp) Tk_MacOSXSetupTkNotifier(); TkMacOSXInitAppleEvents(interp); TkMacOSXInitMenus(interp); + TkMacOSXUseAntialiasedText(interp, TRUE); } if (carbonEncodingInitialized == false) { diff --git a/macosx/tkMacOSXInt.h b/macosx/tkMacOSXInt.h index b609d6e..4d7b840 100644 --- a/macosx/tkMacOSXInt.h +++ b/macosx/tkMacOSXInt.h @@ -9,7 +9,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.2 2002/08/31 06:12:30 das Exp $ + * RCS: @(#) $Id: tkMacOSXInt.h,v 1.3 2002/10/16 19:44:05 das Exp $ */ #ifndef _TKMACINT @@ -150,6 +150,8 @@ extern TkMacOSXWindowList *tkMacOSXWindowListPtr; extern Tcl_Encoding TkMacOSXCarbonEncoding; +extern int TkMacOSXUseAntialiasedText(Tcl_Interp *interp, int enable); + #include "tkIntPlatDecls.h" #endif /* _TKMACINT */ |