summaryrefslogtreecommitdiffstats
path: root/macosx
diff options
context:
space:
mode:
authorjan.nijtmans <nijtmans@users.sourceforge.net>2020-11-12 10:16:00 (GMT)
committerjan.nijtmans <nijtmans@users.sourceforge.net>2020-11-12 10:16:00 (GMT)
commit011db3181f22da410d14abd5df6dc1da7d0fed6f (patch)
tree4d01ddf684235961ad07ecd0e91e4b3136de618d /macosx
parent950726731dd2068e363d294fedc3d3a68da2698b (diff)
parenta57e550fe40ed58660f2b7e50f64f56bbc0e9518 (diff)
downloadtk-011db3181f22da410d14abd5df6dc1da7d0fed6f.zip
tk-011db3181f22da410d14abd5df6dc1da7d0fed6f.tar.gz
tk-011db3181f22da410d14abd5df6dc1da7d0fed6f.tar.bz2
Merge trunk. Clean-up win32 systray code (not completed yet, still some ANSI functions are used which cannot handle full Unicode)
Diffstat (limited to 'macosx')
-rw-r--r--macosx/Credits.html.in24
-rw-r--r--macosx/tkMacOSXColor.c146
-rw-r--r--macosx/tkMacOSXDialog.c61
-rw-r--r--macosx/tkMacOSXFont.c3
-rw-r--r--macosx/tkMacOSXInt.h15
-rw-r--r--macosx/tkMacOSXMenus.c2
-rw-r--r--macosx/tkMacOSXPrivate.h1
7 files changed, 42 insertions, 210 deletions
diff --git a/macosx/Credits.html.in b/macosx/Credits.html.in
new file mode 100644
index 0000000..cc409b1
--- /dev/null
+++ b/macosx/Credits.html.in
@@ -0,0 +1,24 @@
+<!doctype htmL>
+<html>
+<head>
+</head>
+<body style="font-size:120%;font-family:Arial,sans-serif;">
+<p>
+Tcl and Tk are distributed under a modified BSD license:<br>
+<a href="https:www.tcl.tk/software/tcltk/license.html">
+ https:www.tcl.tk/software/tcltk/license.html
+</a>
+</p>
+<ul style="list-style-type:none;">
+<li>&copy; 1987-@TK_YEAR@ Tcl Core Team and Contributers.</li>
+<li>&copy; 2011-@TK_YEAR@ Kevin Walzer/WordTech Communications LLC.</li>
+<li>&copy; 2014-@TK_YEAR@ Marc Culler.</li>
+<li>&copy; 2002-2012 Daniel A. Steffen.</li>
+<li>&copy; 2001-2009 Apple Inc.</li>
+<li>&copy; 2001-2002 Jim Ingham &amp; Ian Reid.</li>
+<li>&copy; 1998-2000 Jim Ingham &amp; Ray Johnson.</li>
+<li>&copy; 1998-2000 Scriptics Inc.</li>
+<li>&copy; 1996-1997 Sun Microsystems Inc.</li>
+</ul>
+</body>
+</html>
diff --git a/macosx/tkMacOSXColor.c b/macosx/tkMacOSXColor.c
index 2bcbd4e..4fe3ce4 100644
--- a/macosx/tkMacOSXColor.c
+++ b/macosx/tkMacOSXColor.c
@@ -282,6 +282,7 @@ GetRGBA(
if (!sRGB) {
sRGB = [NSColorSpace sRGBColorSpace];
}
+
switch (entry->type) {
case rgbColor:
rgba[0] = ((pixel >> 16) & 0xff) / 255.0;
@@ -430,22 +431,21 @@ TkMacOSXInDarkMode(Tk_Window tkwin)
* Sets the components of a CGColorRef from an XColor pixel value. The
* pixel value is used to look up the color in the system color table, and
* then SetCGColorComponents is called with the table entry and the pixel
- * value.
+ * value. The parameter macColor should be a pointer to a CGColorRef.
*
* Results:
* Returns false if the color is not found, true otherwise.
*
* Side effects:
- * The variable macColor is set to a new CGColorRef, the caller is
- * responsible for releasing it!
+ * The CGColorRef referenced by the variable macColor may be modified.
*
*----------------------------------------------------------------------
*/
int
TkSetMacColor(
- unsigned long pixel, /* Pixel value to convert. */
- void *macColor) /* CGColorRef to modify. */
+ unsigned long pixel, /* Pixel value to convert. */
+ void *macColor) /* CGColorRef to modify. */
{
CGColorRef *color = (CGColorRef*)macColor;
SystemColorDatum *entry = GetEntryFromPixel(pixel);
@@ -460,118 +460,6 @@ TkSetMacColor(
/*
*----------------------------------------------------------------------
*
- * TkpInitGCCache, TkpFreeGCCache, CopyCachedColor, SetCachedColor --
- *
- * Maintain a per-GC cache of previously converted CGColorRefs
- *
- * Results:
- * None resp. retained CGColorRef for CopyCachedColor()
- *
- * Side effects:
- * None.
- *
- *----------------------------------------------------------------------
- */
-
-void
-TkpInitGCCache(
- GC gc)
-{
- bzero(TkpGetGCCache(gc), sizeof(TkpGCCache));
-}
-
-void
-TkpFreeGCCache(
- GC gc)
-{
- TkpGCCache *gcCache = TkpGetGCCache(gc);
-
- if (gcCache->cachedForegroundColor) {
- CFRelease(gcCache->cachedForegroundColor);
- }
- if (gcCache->cachedBackgroundColor) {
- CFRelease(gcCache->cachedBackgroundColor);
- }
-}
-
-static CGColorRef
-CopyCachedColor(
- GC gc,
- unsigned long pixel)
-{
- TkpGCCache *gcCache = TkpGetGCCache(gc);
- CGColorRef cgColor = NULL;
-
- if (gcCache) {
- if (gcCache->cachedForeground == pixel) {
- cgColor = gcCache->cachedForegroundColor;
- } else if (gcCache->cachedBackground == pixel) {
- cgColor = gcCache->cachedBackgroundColor;
- }
- if (cgColor) {
- CFRetain(cgColor);
- }
- }
- return cgColor;
-}
-
-static void
-SetCachedColor(
- GC gc,
- unsigned long pixel,
- CGColorRef cgColor)
-{
- TkpGCCache *gcCache = TkpGetGCCache(gc);
-
- if (gcCache && cgColor) {
- if (gc->foreground == pixel) {
- if (gcCache->cachedForegroundColor) {
- CFRelease(gcCache->cachedForegroundColor);
- }
- gcCache->cachedForegroundColor = (CGColorRef) CFRetain(cgColor);
- gcCache->cachedForeground = pixel;
- } else if (gc->background == pixel) {
- if (gcCache->cachedBackgroundColor) {
- CFRelease(gcCache->cachedBackgroundColor);
- }
- gcCache->cachedBackgroundColor = (CGColorRef) CFRetain(cgColor);
- gcCache->cachedBackground = pixel;
- }
- }
-}
-
-/*
- *----------------------------------------------------------------------
- *
- * TkMacOSXCreateCGColor --
- *
- * Creates a CGColorRef from a X style pixel value.
- *
- * Results:
- * Returns NULL if not a real pixel, CGColorRef otherwise.
- *
- * Side effects:
- * None
- *
- *----------------------------------------------------------------------
- */
-
-CGColorRef
-TkMacOSXCreateCGColor(
- GC gc,
- unsigned long pixel) /* Pixel value to convert. */
-{
- CGColorRef cgColor = CopyCachedColor(gc, pixel);
-
- if (!cgColor && TkSetMacColor(pixel, &cgColor)) {
- SetCachedColor(gc, pixel, cgColor);
- }
- return cgColor;
-}
-
-/*
- *----------------------------------------------------------------------
- *
* TkMacOSXGetNSColor --
*
* Creates an autoreleased NSColor from a X style pixel value.
@@ -588,22 +476,16 @@ TkMacOSXCreateCGColor(
NSColor*
TkMacOSXGetNSColor(
- GC gc,
+ TCL_UNUSED(GC),
unsigned long pixel) /* Pixel value to convert. */
{
- CGColorRef cgColor = TkMacOSXCreateCGColor(gc, pixel);
+ CGColorRef cgColor;
NSColor *nsColor = nil;
- if (cgColor) {
- NSColorSpace *colorSpace = [[NSColorSpace alloc]
- initWithCGColorSpace:CGColorGetColorSpace(cgColor)];
-
- nsColor = [NSColor colorWithColorSpace:colorSpace
- components:CGColorGetComponents(cgColor)
- count:CGColorGetNumberOfComponents(cgColor)];
- [colorSpace release];
- CFRelease(cgColor);
- }
+ TkSetMacColor(pixel, &cgColor);
+ nsColor = [NSColor colorWithColorSpace:sRGB
+ components:CGColorGetComponents(cgColor)
+ count:CGColorGetNumberOfComponents(cgColor)];
return nsColor;
}
@@ -627,7 +509,7 @@ TkMacOSXGetNSColor(
void
TkMacOSXSetColorInContext(
- GC gc,
+ TCL_UNUSED(GC),
unsigned long pixel,
CGContextRef context)
{
@@ -646,9 +528,7 @@ TkMacOSXSetColorInContext(
}
break;
default:
- if (SetCGColorComponents(entry, pixel, &cgColor)){
- SetCachedColor(gc, pixel, cgColor);
- }
+ SetCGColorComponents(entry, pixel, &cgColor);
break;
}
}
diff --git a/macosx/tkMacOSXDialog.c b/macosx/tkMacOSXDialog.c
index 478da71..91383d2 100644
--- a/macosx/tkMacOSXDialog.c
+++ b/macosx/tkMacOSXDialog.c
@@ -1315,64 +1315,9 @@ Tk_ChooseDirectoryObjCmd(
void
TkAboutDlg(void)
{
- NSImage *image;
- NSString *path = [NSApp tkFrameworkImagePath: @"Tk.tiff"];
-
- if (path) {
- image = [[[NSImage alloc] initWithContentsOfFile:path] autorelease];
- } else {
- image = [NSApp applicationIconImage];
- }
-
- NSDateFormatter *dateFormatter = [[NSDateFormatter alloc] init];
-
- [dateFormatter setFormatterBehavior:NSDateFormatterBehavior10_4];
- [dateFormatter setDateFormat:@"Y"];
-
- NSString *year = [dateFormatter stringFromDate:[NSDate date]];
-
- [dateFormatter release];
-
- /*
- * This replaces the old about dialog with a standard alert that displays
- * correctly on 10.14.
- */
-
- NSString *version = @"Tcl " TCL_PATCH_LEVEL " & Tk " TCL_PATCH_LEVEL;
- NSString *url = @"www.tcl-lang.org";
- NSTextView *credits = [[NSTextView alloc] initWithFrame:NSMakeRect(0,0,300,300)];
- NSFont *font = [NSFont systemFontOfSize:[NSFont systemFontSize]];
- NSDictionary *textAttributes = [NSDictionary dictionaryWithObject:font
- forKey:NSFontAttributeName];
-
- [credits insertText: [[NSAttributedString alloc]
- initWithString:[NSString stringWithFormat: @"\n"
- "Tcl and Tk are distributed under a modified BSD license: "
- "www.tcl.tk/software/tcltk/license.html\n\n"
- "%1$C 1987-%2$@ Tcl Core Team and Contributers.\n\n"
- "%1$C 2011-%2$@ Kevin Walzer/WordTech Communications LLC.\n\n"
- "%1$C 2014-%2$@ Marc Culler.\n\n"
- "%1$C 2002-2012 Daniel A. Steffen.\n\n"
- "%1$C 2001-2009 Apple Inc.\n\n"
- "%1$C 2001-2002 Jim Ingham & Ian Reid\n\n"
- "%1$C 1998-2000 Jim Ingham & Ray Johnson\n\n"
- "%1$C 1998-2000 Scriptics Inc.\n\n"
- "%1$C 1996-1997 Sun Microsystems Inc.", 0xA9, year]
- attributes:textAttributes]
- replacementRange:NSMakeRange(0,0)];
- [credits setDrawsBackground:NO];
- [credits setEditable:NO];
-
- NSAlert *about = [[NSAlert alloc] init];
-
- [[about window] setTitle:@"About Tcl & Tk"];
- [about setMessageText: version];
- [about setInformativeText:url];
- about.accessoryView = credits;
- [about runModal];
- [about release];
+ [NSApp orderFrontStandardAboutPanel:nil];
}
-
+
/*
*----------------------------------------------------------------------
*
@@ -1400,7 +1345,7 @@ TkMacOSXStandardAboutPanelObjCmd(
Tcl_WrongNumArgs(interp, 1, objv, NULL);
return TCL_ERROR;
}
- TkAboutDlg();
+ [NSApp orderFrontStandardAboutPanel:nil];
return TCL_OK;
}
diff --git a/macosx/tkMacOSXFont.c b/macosx/tkMacOSXFont.c
index 6c66ed8..c062b16 100644
--- a/macosx/tkMacOSXFont.c
+++ b/macosx/tkMacOSXFont.c
@@ -1209,10 +1209,9 @@ TkpDrawAngledCharsInContext(
}
context = drawingContext.context;
- fg = TkMacOSXCreateCGColor(gc, gc->foreground);
+ TkSetMacColor(gc->foreground, &fg);
attributes = [fontPtr->nsAttributes mutableCopy];
[attributes setObject:(id)fg forKey:(id)kCTForegroundColorAttributeName];
- CFRelease(fg);
nsFont = [attributes objectForKey:NSFontAttributeName];
[nsFont setInContext:GET_NSCONTEXT(context, NO)];
CGContextSetTextMatrix(context, CGAffineTransformIdentity);
diff --git a/macosx/tkMacOSXInt.h b/macosx/tkMacOSXInt.h
index 6e7e3b2..b0af85b 100644
--- a/macosx/tkMacOSXInt.h
+++ b/macosx/tkMacOSXInt.h
@@ -101,21 +101,6 @@ typedef struct TkWindowPrivate MacDrawable;
*/
/*
- * GC CGColorRef cache for tkMacOSXColor.c
- */
-
-typedef struct {
- unsigned long cachedForeground;
- CGColorRef cachedForegroundColor;
- unsigned long cachedBackground;
- CGColorRef cachedBackgroundColor;
-} TkpGCCache;
-
-MODULE_SCOPE TkpGCCache *TkpGetGCCache(GC gc);
-MODULE_SCOPE void TkpInitGCCache(GC gc);
-MODULE_SCOPE void TkpFreeGCCache(GC gc);
-
-/*
* Undef compatibility platform types defined above.
*/
diff --git a/macosx/tkMacOSXMenus.c b/macosx/tkMacOSXMenus.c
index 80ee992..fe53f25 100644
--- a/macosx/tkMacOSXMenus.c
+++ b/macosx/tkMacOSXMenus.c
@@ -203,7 +203,7 @@ static Tcl_Obj * GetWidgetDemoPath(Tcl_Interp *interp);
if (!_eventInterp || !Tcl_FindCommand(_eventInterp, "tkAboutDialog",
NULL, 0) || (GetCurrentEventKeyModifiers() & optionKey)) {
- TkAboutDlg();
+ [super orderFrontStandardAboutPanel:nil];
} else {
int code = Tcl_EvalEx(_eventInterp, "tkAboutDialog", -1,
TCL_EVAL_GLOBAL);
diff --git a/macosx/tkMacOSXPrivate.h b/macosx/tkMacOSXPrivate.h
index 6bee883..ef2bd1d 100644
--- a/macosx/tkMacOSXPrivate.h
+++ b/macosx/tkMacOSXPrivate.h
@@ -272,7 +272,6 @@ MODULE_SCOPE NSImage* TkMacOSXGetNSImageFromTkImage(Display *display,
Tk_Image image, int width, int height);
MODULE_SCOPE NSImage* TkMacOSXGetNSImageFromBitmap(Display *display,
Pixmap bitmap, GC gc, int width, int height);
-MODULE_SCOPE CGColorRef TkMacOSXCreateCGColor(GC gc, unsigned long pixel);
MODULE_SCOPE NSColor* TkMacOSXGetNSColor(GC gc, unsigned long pixel);
MODULE_SCOPE NSFont* TkMacOSXNSFontForFont(Tk_Font tkfont);
MODULE_SCOPE NSDictionary* TkMacOSXNSFontAttributesForFont(Tk_Font tkfont);