summaryrefslogtreecommitdiffstats
path: root/ChangeLog.1999
diff options
context:
space:
mode:
authorjan.nijtmans <nijtmans@users.sourceforge.net>2020-11-23 09:16:00 (GMT)
committerjan.nijtmans <nijtmans@users.sourceforge.net>2020-11-23 09:16:00 (GMT)
commita1dd05a17089ddf2b20cc4bea8c98d3f2355bec6 (patch)
tree08f0999b162e691dce5475c77afd00e20a8a460d /ChangeLog.1999
parent55383ed9b1e8a412476319e9d62767a8e45cfd9c (diff)
downloadtcl-a1dd05a17089ddf2b20cc4bea8c98d3f2355bec6.zip
tcl-a1dd05a17089ddf2b20cc4bea8c98d3f2355bec6.tar.gz
tcl-a1dd05a17089ddf2b20cc4bea8c98d3f2355bec6.tar.bz2
More ©-sign consolidation
Diffstat (limited to 'ChangeLog.1999')
0 files changed, 0 insertions, 0 deletions
8.5%;'/> -rw-r--r--macosx/tkMacOSXKeyboard.c395
-rw-r--r--macosx/tkMacOSXMenu.c4903
-rw-r--r--macosx/tkMacOSXMenubutton.c1104
-rw-r--r--macosx/tkMacOSXMenus.c612
-rw-r--r--macosx/tkMacOSXMouseEvent.c1104
-rw-r--r--macosx/tkMacOSXNotify.c279
-rw-r--r--macosx/tkMacOSXPort.h7
-rw-r--r--macosx/tkMacOSXPrivate.h422
-rw-r--r--macosx/tkMacOSXRegion.c155
-rw-r--r--macosx/tkMacOSXScale.c17
-rw-r--r--macosx/tkMacOSXScrlbr.c1104
-rw-r--r--macosx/tkMacOSXSend.c39
-rw-r--r--macosx/tkMacOSXSubwindows.c748
-rw-r--r--macosx/tkMacOSXTest.c17
-rw-r--r--macosx/tkMacOSXWindowEvent.c1259
-rw-r--r--macosx/tkMacOSXWm.c2287
-rw-r--r--macosx/tkMacOSXWm.h58
-rw-r--r--macosx/tkMacOSXXCursors.r958
-rw-r--r--macosx/tkMacOSXXStubs.c422
-rw-r--r--macosx/ttkMacOSXTheme.c546
-rw-r--r--unix/Makefile.in125
-rwxr-xr-xunix/configure11430
-rwxr-xr-x[-rw-r--r--]unix/configure.in53
-rwxr-xr-x[-rw-r--r--]unix/install-sh0
-rw-r--r--xlib/xgc.c40
74 files changed, 16597 insertions, 30270 deletions
diff --git a/generic/tk.decls b/generic/tk.decls
index f08f2ef..b7c8a77 100644
--- a/generic/tk.decls
+++ b/generic/tk.decls
@@ -10,6 +10,8 @@
#
# See the file "license.terms" for information on usage and redistribution
# of this file, and for a DISCLAIMER OF ALL WARRANTIES.
+#
+# RCS: @(#) $Id$
library tk
@@ -1127,10 +1129,10 @@ declare 6 aqua {
void TkMacOSXInvalClipRgns(Tk_Window tkwin)
}
declare 7 aqua {
- GWorldPtr TkMacOSXGetDrawablePort(Drawable drawable)
+ void *TkMacOSXGetDrawablePort(Drawable drawable)
}
declare 8 aqua {
- ControlRef TkMacOSXGetRootControl(Drawable drawable)
+ void *TkMacOSXGetRootControl(Drawable drawable)
}
declare 9 aqua {
void Tk_MacOSXSetupTkNotifier(void)
diff --git a/generic/tkInt.decls b/generic/tkInt.decls
index c6e4bc7..84e1bc3 100644
--- a/generic/tkInt.decls
+++ b/generic/tkInt.decls
@@ -834,22 +834,22 @@ declare 12 aqua {
#}
declare 14 aqua {
- int TkMacOSXDoHLEvent(EventRecord *theEvent)
+ int TkMacOSXDoHLEvent(void *theEvent)
}
# removed duplicate from tkPlat table(tk.decls)
#declare 15 aqua {
-# GWorldPtr TkMacOSXGetDrawablePort(Drawable drawable)
+# void *TkMacOSXGetDrawablePort(Drawable drawable)
#}
declare 16 aqua {
- Window TkMacOSXGetXWindow(WindowRef macWinPtr)
+ Window TkMacOSXGetXWindow(void *macWinPtr)
}
declare 17 aqua {
- int TkMacOSXGrowToplevel(WindowRef whichWindow, Point start)
+ int TkMacOSXGrowToplevel(void *whichWindow, XPoint start)
}
declare 18 aqua {
- void TkMacOSXHandleMenuSelect(MenuID theMenu, MenuItemIndex theItem,
+ void TkMacOSXHandleMenuSelect(short theMenu, unsigned short theItem,
int optionKeyPressed)
}
@@ -872,13 +872,13 @@ declare 23 aqua {
void TkMacOSXMakeRealWindowExist(TkWindow *winPtr)
}
declare 24 aqua {
- BitMapPtr TkMacOSXMakeStippleMap(Drawable d1, Drawable d2)
+ void * TkMacOSXMakeStippleMap(Drawable d1, Drawable d2)
}
declare 25 aqua {
void TkMacOSXMenuClick(void)
}
declare 26 aqua {
- void TkMacOSXRegisterOffScreenWindow(Window window, GWorldPtr portPtr)
+ void TkMacOSXRegisterOffScreenWindow(Window window, void *portPtr)
}
declare 27 aqua {
int TkMacOSXResizable(TkWindow *winPtr)
@@ -893,28 +893,28 @@ declare 30 aqua {
void TkMacOSXSetUpClippingRgn(Drawable drawable)
}
declare 31 aqua {
- void TkMacOSXSetUpGraphicsPort(GC gc, GWorldPtr destPort)
+ void TkMacOSXSetUpGraphicsPort(GC gc, void *destPort)
}
declare 32 aqua {
void TkMacOSXUpdateClipRgn(TkWindow *winPtr)
}
declare 33 aqua {
- void TkMacOSXUnregisterMacWindow(WindowRef portPtr)
+ void TkMacOSXUnregisterMacWindow(void *portPtr)
}
declare 34 aqua {
int TkMacOSXUseMenuID(short macID)
}
declare 35 aqua {
- RgnHandle TkMacOSXVisableClipRgn(TkWindow *winPtr)
+ TkRegion TkMacOSXVisableClipRgn(TkWindow *winPtr)
}
declare 36 aqua {
- void TkMacOSXWinBounds(TkWindow *winPtr, Rect *geometry)
+ void TkMacOSXWinBounds(TkWindow *winPtr, void *geometry)
}
declare 37 aqua {
- void TkMacOSXWindowOffset(WindowRef wRef, int *xOffset, int *yOffset)
+ void TkMacOSXWindowOffset(void *wRef, int *xOffset, int *yOffset)
}
declare 38 aqua {
- int TkSetMacColor(unsigned long pixel, RGBColor *macColor)
+ int TkSetMacColor(unsigned long pixel, void *macColor)
}
declare 39 aqua {
void TkSetWMName(TkWindow *winPtr, Tk_Uid titleUid)
@@ -923,7 +923,7 @@ declare 40 aqua {
void TkSuspendClipboard(void)
}
declare 41 aqua {
- int TkMacOSXZoomToplevel(WindowPtr whichWindow, short zoomPart)
+ int TkMacOSXZoomToplevel(void *whichWindow, short zoomPart)
}
declare 42 aqua {
Tk_Window Tk_TopCoordsToWindow(Tk_Window tkwin, int rootX, int rootY,
@@ -939,7 +939,7 @@ declare 45 aqua {
void TkMacOSXPreprocessMenu(void)
}
declare 46 aqua {
- int TkpIsWindowFloating(WindowRef window)
+ int TkpIsWindowFloating(void *window)
}
declare 47 aqua {
Tk_Window TkMacOSXGetCapture(void)
diff --git a/generic/tkIntPlatDecls.h b/generic/tkIntPlatDecls.h
index d0753f1..6319c3d 100644
--- a/generic/tkIntPlatDecls.h
+++ b/generic/tkIntPlatDecls.h
@@ -8,6 +8,8 @@
*
* Copyright (c) 1998-1999 by Scriptics Corporation.
* All rights reserved.
+ *
+ * RCS: @(#) $Id$
*/
#ifndef _TKINTPLATDECLS
@@ -337,25 +339,24 @@ EXTERN void TkMacOSXHandleTearoffMenu(void);
#ifndef TkMacOSXDoHLEvent_TCL_DECLARED
#define TkMacOSXDoHLEvent_TCL_DECLARED
/* 14 */
-EXTERN int TkMacOSXDoHLEvent(EventRecord *theEvent);
+EXTERN int TkMacOSXDoHLEvent(VOID *theEvent);
#endif
/* Slot 15 is reserved */
#ifndef TkMacOSXGetXWindow_TCL_DECLARED
#define TkMacOSXGetXWindow_TCL_DECLARED
/* 16 */
-EXTERN Window TkMacOSXGetXWindow(WindowRef macWinPtr);
+EXTERN Window TkMacOSXGetXWindow(VOID *macWinPtr);
#endif
#ifndef TkMacOSXGrowToplevel_TCL_DECLARED
#define TkMacOSXGrowToplevel_TCL_DECLARED
/* 17 */
-EXTERN int TkMacOSXGrowToplevel(WindowRef whichWindow,
- Point start);
+EXTERN int TkMacOSXGrowToplevel(VOID *whichWindow, XPoint start);
#endif
#ifndef TkMacOSXHandleMenuSelect_TCL_DECLARED
#define TkMacOSXHandleMenuSelect_TCL_DECLARED
/* 18 */
-EXTERN void TkMacOSXHandleMenuSelect(MenuID theMenu,
- MenuItemIndex theItem, int optionKeyPressed);
+EXTERN void TkMacOSXHandleMenuSelect(short theMenu,
+ unsigned short theItem, int optionKeyPressed);
#endif
/* Slot 19 is reserved */
/* Slot 20 is reserved */
@@ -379,7 +380,7 @@ EXTERN void TkMacOSXMakeRealWindowExist(TkWindow *winPtr);
#ifndef TkMacOSXMakeStippleMap_TCL_DECLARED
#define TkMacOSXMakeStippleMap_TCL_DECLARED
/* 24 */
-EXTERN BitMapPtr TkMacOSXMakeStippleMap(Drawable d1, Drawable d2);
+EXTERN VOID * TkMacOSXMakeStippleMap(Drawable d1, Drawable d2);
#endif
#ifndef TkMacOSXMenuClick_TCL_DECLARED
#define TkMacOSXMenuClick_TCL_DECLARED
@@ -390,7 +391,7 @@ EXTERN void TkMacOSXMenuClick(void);
#define TkMacOSXRegisterOffScreenWindow_TCL_DECLARED
/* 26 */
EXTERN void TkMacOSXRegisterOffScreenWindow(Window window,
- GWorldPtr portPtr);
+ VOID *portPtr);
#endif
#ifndef TkMacOSXResizable_TCL_DECLARED
#define TkMacOSXResizable_TCL_DECLARED
@@ -415,7 +416,7 @@ EXTERN void TkMacOSXSetUpClippingRgn(Drawable drawable);
#ifndef TkMacOSXSetUpGraphicsPort_TCL_DECLARED
#define TkMacOSXSetUpGraphicsPort_TCL_DECLARED
/* 31 */
-EXTERN void TkMacOSXSetUpGraphicsPort(GC gc, GWorldPtr destPort);
+EXTERN void TkMacOSXSetUpGraphicsPort(GC gc, VOID *destPort);
#endif
#ifndef TkMacOSXUpdateClipRgn_TCL_DECLARED
#define TkMacOSXUpdateClipRgn_TCL_DECLARED
@@ -425,7 +426,7 @@ EXTERN void TkMacOSXUpdateClipRgn(TkWindow *winPtr);
#ifndef TkMacOSXUnregisterMacWindow_TCL_DECLARED
#define TkMacOSXUnregisterMacWindow_TCL_DECLARED
/* 33 */
-EXTERN void TkMacOSXUnregisterMacWindow(WindowRef portPtr);
+EXTERN void TkMacOSXUnregisterMacWindow(VOID *portPtr);
#endif
#ifndef TkMacOSXUseMenuID_TCL_DECLARED
#define TkMacOSXUseMenuID_TCL_DECLARED
@@ -435,24 +436,23 @@ EXTERN int TkMacOSXUseMenuID(short macID);
#ifndef TkMacOSXVisableClipRgn_TCL_DECLARED
#define TkMacOSXVisableClipRgn_TCL_DECLARED
/* 35 */
-EXTERN RgnHandle TkMacOSXVisableClipRgn(TkWindow *winPtr);
+EXTERN TkRegion TkMacOSXVisableClipRgn(TkWindow *winPtr);
#endif
#ifndef TkMacOSXWinBounds_TCL_DECLARED
#define TkMacOSXWinBounds_TCL_DECLARED
/* 36 */
-EXTERN void TkMacOSXWinBounds(TkWindow *winPtr, Rect *geometry);
+EXTERN void TkMacOSXWinBounds(TkWindow *winPtr, VOID *geometry);
#endif
#ifndef TkMacOSXWindowOffset_TCL_DECLARED
#define TkMacOSXWindowOffset_TCL_DECLARED
/* 37 */
-EXTERN void TkMacOSXWindowOffset(WindowRef wRef, int *xOffset,
+EXTERN void TkMacOSXWindowOffset(VOID *wRef, int *xOffset,
int *yOffset);
#endif
#ifndef TkSetMacColor_TCL_DECLARED
#define TkSetMacColor_TCL_DECLARED
/* 38 */
-EXTERN int TkSetMacColor(unsigned long pixel,
- RGBColor *macColor);
+EXTERN int TkSetMacColor(unsigned long pixel, VOID *macColor);
#endif
#ifndef TkSetWMName_TCL_DECLARED
#define TkSetWMName_TCL_DECLARED
@@ -467,7 +467,7 @@ EXTERN void TkSuspendClipboard(void);
#ifndef TkMacOSXZoomToplevel_TCL_DECLARED
#define TkMacOSXZoomToplevel_TCL_DECLARED
/* 41 */
-EXTERN int TkMacOSXZoomToplevel(WindowPtr whichWindow,
+EXTERN int TkMacOSXZoomToplevel(VOID *whichWindow,
short zoomPart);
#endif
#ifndef Tk_TopCoordsToWindow_TCL_DECLARED
@@ -494,7 +494,7 @@ EXTERN void TkMacOSXPreprocessMenu(void);
#ifndef TkpIsWindowFloating_TCL_DECLARED
#define TkpIsWindowFloating_TCL_DECLARED
/* 46 */
-EXTERN int TkpIsWindowFloating(WindowRef window);
+EXTERN int TkpIsWindowFloating(VOID *window);
#endif
#ifndef TkMacOSXGetCapture_TCL_DECLARED
#define TkMacOSXGetCapture_TCL_DECLARED
@@ -668,39 +668,39 @@ typedef struct TkIntPlatStubs {
void (*tkMacOSXInstallCursor) (int resizeOverride); /* 11 */
void (*tkMacOSXHandleTearoffMenu) (void); /* 12 */
VOID *reserved13;
- int (*tkMacOSXDoHLEvent) (EventRecord *theEvent); /* 14 */
+ int (*tkMacOSXDoHLEvent) (VOID *theEvent); /* 14 */
VOID *reserved15;
- Window (*tkMacOSXGetXWindow) (WindowRef macWinPtr); /* 16 */
- int (*tkMacOSXGrowToplevel) (WindowRef whichWindow, Point start); /* 17 */
- void (*tkMacOSXHandleMenuSelect) (MenuID theMenu, MenuItemIndex theItem, int optionKeyPressed); /* 18 */
+ Window (*tkMacOSXGetXWindow) (VOID *macWinPtr); /* 16 */
+ int (*tkMacOSXGrowToplevel) (VOID *whichWindow, XPoint start); /* 17 */
+ void (*tkMacOSXHandleMenuSelect) (short theMenu, unsigned short theItem, int optionKeyPressed); /* 18 */
VOID *reserved19;
VOID *reserved20;
void (*tkMacOSXInvalidateWindow) (MacDrawable *macWin, int flag); /* 21 */
int (*tkMacOSXIsCharacterMissing) (Tk_Font tkfont, unsigned int searchChar); /* 22 */
void (*tkMacOSXMakeRealWindowExist) (TkWindow *winPtr); /* 23 */
- BitMapPtr (*tkMacOSXMakeStippleMap) (Drawable d1, Drawable d2); /* 24 */
+ VOID * (*tkMacOSXMakeStippleMap) (Drawable d1, Drawable d2); /* 24 */
void (*tkMacOSXMenuClick) (void); /* 25 */
- void (*tkMacOSXRegisterOffScreenWindow) (Window window, GWorldPtr portPtr); /* 26 */
+ void (*tkMacOSXRegisterOffScreenWindow) (Window window, VOID *portPtr); /* 26 */
int (*tkMacOSXResizable) (TkWindow *winPtr); /* 27 */
void (*tkMacOSXSetHelpMenuItemCount) (void); /* 28 */
void (*tkMacOSXSetScrollbarGrow) (TkWindow *winPtr, int flag); /* 29 */
void (*tkMacOSXSetUpClippingRgn) (Drawable drawable); /* 30 */
- void (*tkMacOSXSetUpGraphicsPort) (GC gc, GWorldPtr destPort); /* 31 */
+ void (*tkMacOSXSetUpGraphicsPort) (GC gc, VOID *destPort); /* 31 */
void (*tkMacOSXUpdateClipRgn) (TkWindow *winPtr); /* 32 */
- void (*tkMacOSXUnregisterMacWindow) (WindowRef portPtr); /* 33 */
+ void (*tkMacOSXUnregisterMacWindow) (VOID *portPtr); /* 33 */
int (*tkMacOSXUseMenuID) (short macID); /* 34 */
- RgnHandle (*tkMacOSXVisableClipRgn) (TkWindow *winPtr); /* 35 */
- void (*tkMacOSXWinBounds) (TkWindow *winPtr, Rect *geometry); /* 36 */
- void (*tkMacOSXWindowOffset) (WindowRef wRef, int *xOffset, int *yOffset); /* 37 */
- int (*tkSetMacColor) (unsigned long pixel, RGBColor *macColor); /* 38 */
+ TkRegion (*tkMacOSXVisableClipRgn) (TkWindow *winPtr); /* 35 */
+ void (*tkMacOSXWinBounds) (TkWindow *winPtr, VOID *geometry); /* 36 */
+ void (*tkMacOSXWindowOffset) (VOID *wRef, int *xOffset, int *yOffset); /* 37 */
+ int (*tkSetMacColor) (unsigned long pixel, VOID *macColor); /* 38 */
void (*tkSetWMName) (TkWindow *winPtr, Tk_Uid titleUid); /* 39 */
void (*tkSuspendClipboard) (void); /* 40 */
- int (*tkMacOSXZoomToplevel) (WindowPtr whichWindow, short zoomPart); /* 41 */
+ int (*tkMacOSXZoomToplevel) (VOID *whichWindow, short zoomPart); /* 41 */
Tk_Window (*tk_TopCoordsToWindow) (Tk_Window tkwin, int rootX, int rootY, int *newX, int *newY); /* 42 */
MacDrawable * (*tkMacOSXContainerId) (TkWindow *winPtr); /* 43 */
MacDrawable * (*tkMacOSXGetHostToplevel) (TkWindow *winPtr); /* 44 */
void (*tkMacOSXPreprocessMenu) (void); /* 45 */
- int (*tkpIsWindowFloating) (WindowRef window); /* 46 */
+ int (*tkpIsWindowFloating) (VOID *window); /* 46 */
Tk_Window (*tkMacOSXGetCapture) (void); /* 47 */
VOID *reserved48;
Window (*tkGetTransientMaster) (TkWindow *winPtr); /* 49 */
diff --git a/generic/tkPlatDecls.h b/generic/tkPlatDecls.h
index 476fa4a..ec1a0a9 100644
--- a/generic/tkPlatDecls.h
+++ b/generic/tkPlatDecls.h
@@ -7,6 +7,8 @@
*
* See the file "license.terms" for information on usage and redistribution
* of this file, and for a DISCLAIMER OF ALL WARRANTIES.
+ *
+ * RCS: @(#) $Id$
*/
#ifndef _TKPLATDECLS
@@ -108,12 +110,12 @@ EXTERN void TkMacOSXInvalClipRgns(Tk_Window tkwin);
#ifndef TkMacOSXGetDrawablePort_TCL_DECLARED
#define TkMacOSXGetDrawablePort_TCL_DECLARED
/* 7 */
-EXTERN GWorldPtr TkMacOSXGetDrawablePort(Drawable drawable);
+EXTERN VOID * TkMacOSXGetDrawablePort(Drawable drawable);
#endif
#ifndef TkMacOSXGetRootControl_TCL_DECLARED
#define TkMacOSXGetRootControl_TCL_DECLARED
/* 8 */
-EXTERN ControlRef TkMacOSXGetRootControl(Drawable drawable);
+EXTERN VOID * TkMacOSXGetRootControl(Drawable drawable);
#endif
#ifndef Tk_MacOSXSetupTkNotifier_TCL_DECLARED
#define Tk_MacOSXSetupTkNotifier_TCL_DECLARED
@@ -147,8 +149,8 @@ typedef struct TkPlatStubs {
void (*tkMacOSXInitAppleEvents) (Tcl_Interp *interp); /* 4 */
void (*tkGenWMConfigureEvent) (Tk_Window tkwin, int x, int y, int width, int height, int flags); /* 5 */
void (*tkMacOSXInvalClipRgns) (Tk_Window tkwin); /* 6 */
- GWorldPtr (*tkMacOSXGetDrawablePort) (Drawable drawable); /* 7 */
- ControlRef (*tkMacOSXGetRootControl) (Drawable drawable); /* 8 */
+ VOID * (*tkMacOSXGetDrawablePort) (Drawable drawable); /* 7 */
+ VOID * (*tkMacOSXGetRootControl) (Drawable drawable); /* 8 */
void (*tk_MacOSXSetupTkNotifier) (void); /* 9 */
int (*tk_MacOSXIsAppInFront) (void); /* 10 */
#endif /* AQUA */
diff --git a/generic/tkUtil.c b/generic/tkUtil.c
index bfa5d5c..bb926c4 100644
--- a/generic/tkUtil.c
+++ b/generic/tkUtil.c
@@ -9,6 +9,8 @@
*
* See the file "license.terms" for information on usage and redistribution of
* this file, and for a DISCLAIMER OF ALL WARRANTIES.
+ *
+ * RCS: @(#) $Id$
*/
#include "tkInt.h"
@@ -976,6 +978,89 @@ TkFindStateNumObj(
}
/*
+ * ----------------------------------------------------------------------
+ *
+ * TkBackgroundEvalObjv --
+ *
+ * Evaluate a command while ensuring that we do not affect the
+ * interpreters state. This is important when evaluating script
+ * during background tasks.
+ *
+ * Results:
+ * A standard Tcl result code.
+ *
+ * Side Effects:
+ * The interpreters variables and code may be modified by the script
+ * but the result will not be modified.
+ *
+ * ----------------------------------------------------------------------
+ */
+
+int
+TkBackgroundEvalObjv(
+ Tcl_Interp *interp,
+ int objc,
+ Tcl_Obj *const *objv,
+ int flags)
+{
+ Tcl_DString errorInfo, errorCode;
+ Tcl_SavedResult state;
+ int n, r = TCL_OK;
+
+ Tcl_DStringInit(&errorInfo);
+ Tcl_DStringInit(&errorCode);
+
+ Tcl_Preserve(interp);
+
+ /*
+ * Record the state of the interpreter
+ */
+
+ Tcl_SaveResult(interp, &state);
+ Tcl_DStringAppend(&errorInfo,
+ Tcl_GetVar(interp, "errorInfo", TCL_GLOBAL_ONLY), -1);
+ Tcl_DStringAppend(&errorCode,
+ Tcl_GetVar(interp, "errorCode", TCL_GLOBAL_ONLY), -1);
+
+ /*
+ * Evaluate the command and handle any error.
+ */
+
+ for (n = 0; n < objc; ++n) {
+ Tcl_IncrRefCount(objv[n]);
+ }
+ r = Tcl_EvalObjv(interp, objc, objv, flags);
+ for (n = 0; n < objc; ++n) {
+ Tcl_DecrRefCount(objv[n]);
+ }
+ if (r == TCL_ERROR) {
+ Tcl_AddErrorInfo(interp, "\n (background event handler)");
+ Tcl_BackgroundError(interp);
+ }
+
+ Tcl_Release(interp);
+
+ /*
+ * Restore the state of the interpreter
+ */
+
+ Tcl_SetVar(interp, "errorInfo",
+ Tcl_DStringValue(&errorInfo), TCL_GLOBAL_ONLY);
+ Tcl_SetVar(interp, "errorCode",
+ Tcl_DStringValue(&errorCode), TCL_GLOBAL_ONLY);
+ Tcl_RestoreResult(interp, &state);
+
+ /*
+ * Clean up references.
+ */
+
+ Tcl_DStringFree(&errorInfo);
+ Tcl_DStringFree(&errorCode);
+
+ return r;
+}
+
+/*
* Local Variables:
* mode: c
* c-basic-offset: 4
diff --git a/macosx/GNUmakefile b/macosx/GNUmakefile
index 333961c..bbcdca7 100644
--- a/macosx/GNUmakefile
+++ b/macosx/GNUmakefile
@@ -9,6 +9,8 @@
# See the file "license.terms" for information on usage and redistribution of
# this file, and for a DISCLAIMER OF ALL WARRANTIES.
#
+# RCS: @(#) $Id$
+#
########################################################################################################
#-------------------------------------------------------------------------------------------------------
diff --git a/macosx/README b/macosx/README
index d0357df..59924bb 100644
--- a/macosx/README
+++ b/macosx/README
@@ -1,8 +1,11 @@
Tcl/Tk Mac OS X README
----------------------
+RCS: @(#) $Id$
+
This is the README file for the Mac OS X/Darwin version of Tcl/Tk.
+
1. Where to go for support
--------------------------
@@ -16,11 +19,16 @@ before asking on the list, many questions have already been answered).
http://groups.google.com/group/comp.lang.tcl/
- The Tcl'ers Wiki also has many pages dealing with Tcl & Tk on Mac OS X, see
- http://wiki.tcl.tk/_/ref?N=3753
- http://wiki.tcl.tk/_/ref?N=8361
+ http://wiki.tcl.tk/references/3753!
+ http://wiki.tcl.tk/references/8361!
- Please report bugs with Tcl or Tk on Mac OS X to the sourceforge bug trackers:
- http://tcl.sourceforge.net/
+ Tcl: http://sf.net/tracker/?func=add&group_id=10894&atid=110894
+ Tk: http://sf.net/tracker/?func=add&group_id=12997&atid=112997
+please make sure that your report Tk specific bugs to the tktoolkit project bug
+tracker rather than the tcl project bug tracker.
+Mac OS X specific bugs should in general be assigned to user 'das'.
+
2. Using Tcl/Tk on Mac OS X
---------------------------
@@ -28,12 +36,11 @@ before asking on the list, many questions have already been answered).
- There are two versions of Tk available on Mac OS X: TkAqua using the native
aqua widgets and look&feel, and TkX11 using the traditional unix X11 wigets.
TkX11 requires an X11 server to be installed, such as Apple's X11 (which is
-available as an optional install on recent Mac OS X retail disks).
+available as an optional or default install on recent Mac OS X).
TkAqua and TkX11 can be distinguished at runtime via [tk windowingsystem].
-- At a minimum, Mac OS X 10.1 is required to run Tcl and TkX11, and OS X 10.2 is
-required to run TkAqua. However OS X 10.3 or higher is recommended (certain
-[file] operations behave incorrectly on earlier releases).
+- At a minimum, Mac OS X 10.3 is required to run Tcl and TkX11.
+TkAqua requires Mac OS X 10.5 or later (starting with the Cocoa-based Tk 8.5.7).
- Unless weak-linking is used, Tcl/Tk built on Mac OS X 10.x will not run on
10.y with y < x; on the other hand Tcl/Tk built on 10.y will always run on 10.x
@@ -52,36 +59,36 @@ brings up the Tk console window at startup. This is the case when double
clicking Wish in the Finder (or using 'open Wish.app' from the Terminal).
- Tcl extensions can be installed in any of:
- $HOME/Library/Tcl /Library/Tcl /Network/Library/Tcl /System/Library/Tcl
- $HOME/Library/Frameworks /Library/Frameworks /Network/Library/Frameworks
- /System/Library/Frameworks (searched in that order).
+ $HOME/Library/Tcl /Library/Tcl /System/Library/Tcl
+ $HOME/Library/Frameworks /Library/Frameworks /System/Library/Frameworks
+ (searched in that order).
Given a potential package directory $pkg, Tcl on OSX checks for the file
$pkg/Resources/Scripts/pkgIndex.tcl as well as the usual $pkg/pkgIndex.tcl.
This allows building extensions as frameworks with all script files contained in
the Resources/Scripts directory of the framework.
- [load]able binary extensions can linked as either ordinary shared libraries
-(.dylib) or as MachO bundles (since 8.4.10/8.5a3); only bundles can be unloaded,
-and bundles are also loaded more efficiently from VFS (no temporary copy to the
-native filesystem required).
+(.dylib) or as MachO bundles (since 8.4.10/8.5a3); bundles have the advantage
+that they are [load]ed more efficiently from a tcl VFS (no temporary copy to the
+native filesystem required), and prior to Mac OS X 10.5, only bundles can be
+[unload]ed.
- The 'deploy' target of macosx/GNUmakefile installs the html manpages into the
standard documentation location in the Tcl/Tk frameworks:
Tcl.framework/Resources/Documentation/Reference/Tcl
Tk.framework/Resources/Documentation/Reference/Tk
-No nroff manpages are installed by default by the GNUmakefiles.
+No nroff manpages are installed by default by the GNUmakefile.
- The Tcl and Tk frameworks can be installed in any of the system's standard
framework directories:
- $HOME/Library/Frameworks /Library/Frameworks
- /Network/Library/Frameworks /System/Library/Frameworks
+ $HOME/Library/Frameworks /Library/Frameworks /System/Library/Frameworks
-- /usr/bin/wish8.x is a script that calls a copy of 'Wish' contained in
+- ${prefix}/bin/wish8.x is a script that calls a copy of 'Wish' contained in
Tk.framework/Resources
-- if 'Wish' is started from the Finder or via 'open', $argv contains a
-"-psn_XXXX" argument. This is the Wish's carbon process serial number, you may
-need to filter it out for cross platform compatibility of your scripts.
+- if 'Wish' is started from the Finder or via 'open', $argv may contain a
+"-psn_XXXX" argument. This is the process serial number, you may need to filter
+it out for cross platform compatibility of your scripts.
- the env array is different when Wish is started from the Finder (i.e. via
LaunchServices) than when it (or tclsh) is invoked from the Terminal, in
@@ -89,47 +96,136 @@ particular PATH may not be what you expect. (Wish started by LaunchServices
inherits loginwindow's environment variables, which are essentially those set in
$HOME/.MacOSX/environment.plist, and are unrelated to those set in your shell).
-- As of Tk 8.4.7, TkAqua has a version of the low-level drawing primitives using
-the CoreGraphics routines - the code is primarily due to James Tittle. There
-were numerous problems with the QD version, mostly due to the different drawing
-model of QD & Tk. CG also trivially supports dashed lines, and the various end
-caps & miters. The old QD code is retained for now, just in case there are any
-compatibility problems. To switch back to the QD drawing, put
- set tk::mac::useCGDrawing 0
-in your script before you do drawing.
-All CG drawing is antialiased by default, but (outline) linewidth can be used to
-control whether a line/shape is drawn antialiased. The antialiasing threshold is
-0 by default (i.e. antialias everything), it can be changed by setting
+- TkAqua drawing is antialiased by default, but (outline) linewidth can be used
+to control whether a line/shape is drawn antialiased. The antialiasing threshold
+is 0 by default (i.e. antialias everything), it can be changed by setting
set tk::mac::CGAntialiasLimit <limit>
in your script before drawing, in which case lines (or shapes with outlines)
thinner than <limit> pixels will not be antialiased.
-- ATSUI text antialiasing by default uses the standard OS antialising settings.
+- Text antialiasing by default uses the standard OS antialising settings.
Setting the global variable '::tk::mac::antialiasedtext' allows to control text
antialiasing from Tcl: a value of 1 enables AA, 0 disables AA and -1 restores
the default behaviour of respecting the OS settings.
- Scrollbars: There are two scrollbar variants in Aqua, normal & small. The
-normal scrollbar has a small dimension of 15, the small variant 11. Access to
-the small variant was added in Tk 8.4.2.
-
-- Cursors: You can now put up and spin the Classic MacOS spinner, and the
-counting hands and watch cursor. The way this is done is each of the spinners
-have a base name:
- spinning: The circular B&W circular spinner
- countinguphand: The counting up hand
- countingdownhand: The counting down hand
- countingupanddownhand: The counting up then down hand
- watch: The watch cursor
-Then to get the sequential variants, add an integer to the end of the base name.
-So, for instance this code will spin the spinner:
- proc spinCursor {widget count} {
- $widget configure -cursor spinning$count
- after 100 spinCursor [incr count]
- }
-This was added in Tk 8.4.2
-
-- If you want to use Remote Debugging with Xcode 1.5 or 2.2, you need to set the
+normal scrollbar has a small dimension of 15, the small variant 11.
+Access to the small variant was added in Tk 8.4.2.
+
+- The default metrics of native buttons, radiobuttons, checkboxes and
+menubuttons in the Cocoa-based Tk 8.5.7 and later preserve compatibility with
+the older Carbon-based implementation, you can turn off the compatibility
+metrics to get more native-looking spacing by setting:
+ set tk::mac::useCompatibilityMetrics 0
+
+- TkAqua provides access to native OS X images via the Tk native bitmap facility
+(including any image file readable by NSImage). A native bitmap name is
+interpreted as follows (in order):
+ - predefined builtin 32x32 icon name (stop, caution, document, etc)
+ - name defined by [tk::mac::iconBitmap]
+ - NSImage named image name
+ - NSImage url string
+ - 4-char OSType of IconServices icon
+the syntax of [tk::mac::iconBitmap] is as follows:
+ tk::mac::iconBitmap name width height -kind value
+where -kind is one of
+ -file icon of file at given path
+ -fileType icon of given file type
+ -osType icon of given 4-char OSType file type
+ -systemType icon for given IconServices 4-char OSType
+ -namedImage named NSImage for given name
+ -imageFile image at given path
+This support was added with the Cocoa-based Tk 8.5.7.
+
+- TkAqua cursor names are interpred as follows (in order):
+ - standard or platform-specific Tk cursor name (c.f. cursors.n)
+ - @path to any image file readable by NSImage
+ - NSImage named image name
+Support for the latter two was added with the Cocoa-based Tk 8.5.7.
+
+- The standard Tk dialog commands [tk_getOpenFile], [tk_chooseDirectory],
+[tk_getSaveFile] and [tk_messageBox] all take an additional optional -command
+parameter on TkAqua. If it is present, the given command prefix is evaluated at
+the global level when the dialog closes, with the dialog command's result
+appended (the dialog command itself returning an emtpy result). If the -parent
+option is also present, the dialog is configured as a modeless (window-modal)
+sheet attached to the parent window and the dialog command returns immediately.
+Support for -command was added with the Cocoa-based Tk 8.5.7.
+
+- The TkAqua-specific [tk::mac::standardAboutPanel] command brings the standard
+Cocoa about panel to the front, with all its information filled in from your
+application bundle files (i.e. standard about panel with no options specified).
+See Apple Technote TN2179 and the AppKit documentation for -[NSApplication
+orderFrontStandardAboutPanelWithOptions:] for details on the Info.plist keys and
+app bundle files used by the about panel.
+This support was added with the Cocoa-based Tk 8.5.7.
+
+- TkAqua has three special menu names that give access to the standard
+Application, Window and Help menus, see menu.n for details.
+By default, the platform-specific standard Help menu item "YourApp Help" peforms
+the default Cocoa action of showing the Help Book configured in the
+application's Info.plist (or displaying an alert if no Help Book is set). This
+action can be customized by defining a procedure named [tk::mac::ShowHelp], if
+present, this procedure is invoked instead by the standard Help menu item.
+Support for the Window menu and [tk::mac::ShowHelp] was added with the
+Cocoa-based Tk 8.5.7.
+
+- The TkAqua-specific command [tk::unsupported::MacWindowStyle style] is used to
+get and set Mac OS X-specific toplevel window class and attributes. Note that
+the window class and many attributes have to be set before the window is first
+mapped for the change to have any effect.
+The command has the following syntax:
+ tk::unsupported::MacWindowStyle style window ?class? ?attributes?
+The 2 argument form returns a list of the current class and attributes for the
+given window. The 3 argument form sets the class for the given window using the
+default attributes for that class. The 4 argument form sets the class and the
+list of attributes for the given window.
+Window class names:
+ standardDocument, standardFloating, resizable, fullZoom, horizontalZoom,
+ verticalZoom, closeBox, collapseBox, toolbarButton, sideTitlebar,
+ noTitleBar, unifiedTitleAndToolbar, metal, hud, noShadow, doesNotCycle,
+ noActivates, hideOnSuspend, inWindowMenu, ignoreClicks, doesNotHide,
+ canJoinAllSpaces, moveToActiveSpace, nonActivating, black, dark, light,
+ gray, red, green, blue, cyan, yellow, magenta, orange, purple,
+ brown, clear, opacity
+Note that not all attributes are valid for all window classes.
+Support for the 3 argument form was added with the Cocoa-based Tk 8.5.7, at the
+same time support for some legacy Carbon-specific classes and attributes was
+removed (they are still accepted by the command but no longer have any effect).
+
+The color window attributes (black, dark, red, etc.) and the "opacity" allow one to set the background and opacity of a textured ("metal") window. This allows a Tk window to implement a window without the dividing line between the titlebar and the rest of the window, or the "unified toolbar" effect, which is increasingly standard in Mac applications. An example:
+
+toplevel .f
+tk::unsupported::MacWindowStyle style .f document {metal light opaque closeBox collapseBox resizable standardDocument }
+
+pack [label .f.f -bg #ababab -text "This is a textured window\nwith opacity and a gray background\nsimilar to other Mac applications"] -fill both -expand yes
+
+The color attributes correspond to system-defined NSColor constants (e.g., red is [NSColor redColor]. The "light" and "dark" attributes correspond to lightGrayColor and darkGrayColor, respectively (because of the way the attributes are parsed, using "lightgray" and "darkgray" would cause a conflict with the core "gray" attribute).
+
+Below are the corresponding hex and/or Tk-defined colors that can be used from Tk widgets to match the NSColor-based attributes:
+
+black #000000
+dark #545454
+light #ababab
+white #ffffff
+gray #7f7f7f
+red #ff0000
+green #00ff00
+blue #0000ff
+cyan #00ffff
+yellow #ffff00
+magenta #ff00ff
+orange #ff8000
+purple #800080
+brown #996633
+clear systemTransparent
+
+- The Cocoa-based TkAqua can be distinguished from the older Carbon-based
+version via the [winfo server .] command, example output on Mac OS X 10.5.7:
+ Cocoa-based: CG409.3 Apple AppKit GC 949.46 Mac OS X 1057
+ Carbon-based: QD10R30 Apple 1057
+
+- If you want to use Remote Debugging with Xcode, you need to set the
environment variable XCNOSTDIN to 1 in the Executable editor for Wish. That will
cause us to force closing stdin & stdout. Otherwise, given how Xcode launches
Wish remotely, they will be left open and then Wish & gdb will fight for stdin.
@@ -138,13 +234,13 @@ Wish remotely, they will be left open and then Wish & gdb will fight for stdin.
3. Building Tcl/Tk on Mac OS X
------------------------------
-- At least Mac OS X 10.1 is required to build Tcl and TkX11 and OS X 10.2 is
-required to build TkAqua. Apple's Developer Tools need to be installed (only the
-most recent version matching your OS release is supported). The Developer Tools
-installer is available on Mac OS X retail disks or is present in
-/Applications/Installers on Macs that came with OS X preinstalled. The most
-recent version can be downloaded from the ADC website http://connect.apple.com
-(after you register for free ADC membership).
+- At least Mac OS X 10.3 is required to build Tcl and TkX11, and Mac OS X 10.5
+is required to build TkAqua.
+Apple's Xcode Developer Tools need to be installed (only the most recent version
+matching your OS release is supported), the Xcode installer is available on Mac
+OS X install media or may be present in /Applications/Installers on Macs that
+came with OS X preinstalled. The most recent version can always be downloaded
+from the ADC website http://connect.apple.com (free ADC membership required).
- Tcl/Tk are most easily built as Mac OS X frameworks via GNUmakefile in
tcl/macosx and tk/macosx (see below for details), but can also be built with the
@@ -156,94 +252,64 @@ The Mac OS X specific configure flags are --enable-aqua, --enable-framework and
select based notifier). Note that --enable-aqua is incompatible with
--disable-corefoundation (for both Tcl and Tk configure).
-- It is also possible to build with Apple's IDE via the projects in tk/macosx,
-take care to only use the project matching your DevTools and OS version:
- * Wish.pbproj for Xcode or ProjectBuilder on 10.3 and earlier, this has a
- 'Tk' target that simply calls through to the tcl/macosx/GNUMakefile. It
- requires a build of the 'Tcl' target of tcl/macosx/Tcl.pbproj.
- * Wish.xcode Xcode 2.4 on 10.4 and Xcode 2.5 on 10.4 and later, which
- additionally has native 'tktest' and 'tktest-X11' targets for
- debugging, these targets' 'Debug' build configuration has ZeroLink and
- Fix&Continue enabled, use the 'DebugNoFixZL' build configuration if you
- need a debug build without these features. The following build
- configurations are available:
- 'DebugUnthreaded': debug build with threading turned off.
- 'DebugNoCF': debug build with corefoundation turned off
- (for 'tktest-X11' only).
- 'DebugNoCFUnthreaded': debug build with corefoundation turned off
- (for 'tktest-X11' only) and with threading turned off.
- 'DebugMemCompile': debug build with memory and bytecode debugging on.
- 'DebugLeaks': debug build with PURIFY defined.
- 'DebugGCov': debug build with generation of gcov data files enabled.
- 'ReleaseUniversal': builds the targets as universal binaries for the
- ppc and i386 architectures.
- 'ReleaseUniversal10.4uSDK': same as 'ReleaseUniversal' but builds
- against the 10.4u SDK, required to build universal binaries on
- PowerPC Tiger (where the system libraries are not universal).
- 'ReleasePPC10.3.9SDK': builds for PowerPC against the 10.3.9 SDK, useful
- for verifying on Tiger that building on Panther would succeed.
- 'ReleasePPC10.2.8SDK': builds for PowerPC with gcc-3.3 against the
- 10.2.8 SDK, useful to verify on Tiger that building on Jaguar
- would succeed.
- * Wish.xcodeproj for Xcode 3.1 on 10.5 and later, which has the following
- additional build configurations:
- 'ReleaseUniversal10.5SDK': same as 'ReleaseUniversal' but builds
- against the 10.5 SDK on Leopard (with 10.5 deployment target).
- 'Debug gcc42': same as 'Debug' but builds with gcc 4.2.
- 'Debug llvmgcc42': same as 'Debug' but builds with llvm-gcc 4.2.
- 'ReleaseUniversal gcc42': same as 'ReleaseUniversal' but builds with
- gcc 4.2.
- 'ReleaseUniversal llvmgcc42': same as 'ReleaseUniversal' but builds
- with llvm-gcc 4.2.
- 'Debug64bit': builds the 'tktest-X11' target as 64bit with debugging
- enabled (requires a 64bit capable processor).
- Note that all non-SDK configurations have 10.5 deployment target and
- that all Universal configurations build the 'tktest-X11' target
- also for the ppc64 and x86_64 architectures.
-
-Notes about the native targets of the Xcode projects:
- * the Xcode projects refer to the toplevel tcl and tk source dirs through
- the TCL_SRCROOT and TK_SRCROOT user build settings, by default these are
- set to the project-relative paths '../../tcl' and '../../tk', if your
- source directories are named differently, e.g. '../../tcl8.5', you'll
- need to manually change the TCL_SRCROOT and TK_SRCROOT settings by
- editing your ${USER}.pbxuser file (located inside the Wish.xcodeproj
- bundle directory) with a text editor.
- * the native targets need a version of the unix configure scripts with config
- headers enabled, this is automatically generated as tcl/macosx/configure
- and tk/macosx/configure by the project but that requires 2.59 versions
- of autoconf & autoheader. These are not available on Mac OS X 10.5 by
- default and need to be installed manually. By default they are assumed
- to be installed as /usr/local/bin/autoconf-2.59 and
- /usr/local/bin/autoheader-2.59, set the AUTOCONF and AUTOHEADER build
- settings in ${USER}.pbxuser to their true locations if necessary.
-
-- To build universal binaries outside of Wish.xcodeproj, set CFLAGS as follows:
- export CFLAGS="-arch ppc -arch i386 \
- -isysroot /Developer/SDKs/MacOSX10.4u.sdk -mmacosx-version-min=10.4"
-This requires Mac OS X 10.4 and Xcode 2.2 (_not_ Xcode 2.1) and will work on any
-of the architectures (the -isysroot flag is only required on PowerPC Tiger).
+- It is also possible to build with the Xcode IDE via the projects in
+tk/macosx, take care to use the project matching your DevTools and OS version:
+ Tk.xcode: for Xcode 3.1 on 10.5
+ Tk.xcodeproj: for Xcode 3.2 on 10.6
+These have the following targets:
+ Tk: calls through to tk/macosx/GNUMakefile,
+ requires a corresponding build of the Tcl
+ target of tcl/macosx/Tcl.xcode.
+ tktest: static build of TkAqua tktest for debugging.
+ tktest-X11: static build of TkX11 tktest for debugging.
+The following build configurations are available:
+ Debug: debug build for the active architecture,
+ with Fix & Continue enabled.
+ Debug gcc42: use gcc 4.2 compiler.
+ Debug gcc42 nogc: disable Objective-C garbage collection.
+ Debug llvmgcc42: use llvm-gcc 4.2 compiler.
+ DebugNoFixAndContinue: disable Fix & Continue.
+ DebugUnthreaded: disable threading.
+ DebugNoCF: disable corefoundation (X11 only).
+ DebugNoCFUnthreaded: disable corefoundation an threading.
+ DebugMemCompile: enable memory and bytecode debugging.
+ DebugLeaks: define PURIFY.
+ DebugGCov: enable generation of gcov data files.
+ Debug64bit: configure with --enable-64bit (requires
+ building on a 64bit capable processor).
+ Release: release build for the active architecture.
+ ReleaseUniversal: 32/64-bit universal build.
+ ReleaseUniversal gcc42: use gcc 4.2 compiler.
+ ReleaseUniversal llvmgcc42: use llvm-gcc 4.2 compiler.
+ ReleaseUniversal10.5SDK: build against the 10.5 SDK (with 10.5
+ deployment target).
+ Note that the non-SDK configurations have their deployment target set to
+ 10.5 (Tk.xcode) resp. 10.6 (Tk.xcodeproj).
+The Xcode projects refer to the toplevel tcl and tk source directories via the
+the TCL_SRCROOT and TK_SRCROOT user build settings, by default these are set to
+the project-relative paths '../../tcl' and '../../tk', if your source
+directories are named differently, e.g. '../../tcl8.6' and '../../tk8.6', you
+need to manually change the TCL_SRCROOT and TK_SRCROOT settings by editing your
+${USER}.pbxuser file (located inside the Tk.xcodeproj bundle directory) with a
+text editor.
+
+- To build universal binaries outside of the Xcode IDE, set CFLAGS as follows:
+ export CFLAGS="-arch i386 -arch x86_64 -arch ppc"
+This requires Mac OS X 10.4 and Xcode 2.4 (or Xcode 2.2 if -arch x86_64 is
+omitted, but _not_ Xcode 2.1) and will work on any architecture (on PowerPC
+Tiger you need to add "-isysroot /Developer/SDKs/MacOSX10.4u.sdk").
Note that configure requires CFLAGS to contain a least one architecture that can
-be run on the build machine (i.e. ppc on PowerPC, ppc or i386 on Intel).
-Universal builds of Tk TEA extensions are also possible with CFLAGS set as
-above, they will be [load]able by universal as well as thin binaries of Tk.
-Note that while Tcl can be built for 64-bit architectures, neither TkAqua nor
-TkX11 can be built for 64-bit as the corresponding GUI libraries are not
-available for 64bit at present. However, linking a universal 'ppc i386' Tk
-binary against a universal 'ppc ppc64 i386 x86_64' Tcl binary works just fine.
-The Tk configure script automatically removes the 64-bit -arch flags from CFLAGS
-to facilitate universal building of both Tcl and Tk with the same CFLAGS; the
-same happens with configure in Tk extensions based on TEA 3.5 or later.
+be run on the build machine (i.e. ppc on G3/G4, ppc or ppc64 on G5, ppc or i386
+on Core and ppc, i386 or x86_64 on Core2/Xeon).
+Universal builds of Tcl TEA extensions are also possible with CFLAGS set as
+above, they will be [load]able by universal as well as thin binaries of Tcl.
- To enable weak-linking, set the MACOSX_DEPLOYMENT_TARGET environment variable
-to the minimal OS version (>= 10.2) the binaries should be able to run on, e.g:
- export MACOSX_DEPLOYMENT_TARGET=10.2
-This requires Mac OS X 10.2 and gcc 3.1; if you have gcc 4 or later you can set
-CFLAGS instead:
- export CFLAGS="-mmacosx-version-min=10.2"
-The Wish.xcode project is setup to produce binaries that can run on 10.2 or
-later (except for the Universal and SDK configurations).
-Support for weak-linking was added to the code for 8.4.14/8.5a5.
+to the minimal OS version the binaries should be able to run on, e.g:
+ export MACOSX_DEPLOYMENT_TARGET=10.4
+This requires at least gcc 3.1; with gcc 4 or later, set/add to CFLAGS instead:
+ export CFLAGS="-mmacosx-version-min=10.4"
+Support for weak-linking was added with 8.4.14/8.5a5.
Detailed Instructions for building with macosx/GNUmakefile
----------------------------------------------------------
@@ -257,26 +323,25 @@ trees in a common parent directory.
[ or you can pass an argument of BUILD_DIR=/somewhere to the tcl and tk make. ]
- The following instructions assume the Tcl and Tk source trees are named
-"tcl${ver}" and "tk${ver}", respectively, where ${ver} is a shell variable
-containing the Tcl and Tk version number (for example '8.4.12').
-Setup the shell variable as follows:
- set ver="8.4.12" ;: if your shell is csh
- ver="8.4.12" ;: if your shell is sh
-The source trees will be named this way only if you are building from a release
-archive, if you are building from CVS, the version numbers will be missing; so
-set ${ver} to the empty string instead:
- set ver="" ;: if your shell is csh
- ver="" ;: if your shell is sh
-
-- The following steps will build Tcl and Tk from the Terminal, assuming you are
-located in the directory containing the tcl and tk source trees:
+"tcl${ver}" and "tk${ver}" (where ${ver} is a shell variable containing the
+Tcl/Tk version number, e.g. '8.6').
+Setup this shell variable as follows:
+ ver="8.6"
+If you are building from CVS, omit this step (CVS source tree names usually do
+not contain a version number).
+
+- Setup environment variables as desired, e.g. for a universal build on 10.5:
+ CFLAGS="-arch i386 -arch x86_64 -arch ppc -mmacosx-version-min=10.5"
+ export CFLAGS
+
+- Change to the directory containing the Tcl and Tk source trees and build:
make -C tcl${ver}/macosx
make -C tk${ver}/macosx
-and the following will then install Tcl and Tk onto the root volume (admin
-password required):
+
+- Install Tcl and Tk onto the root volume (admin password required):
sudo make -C tcl${ver}/macosx install
sudo make -C tk${ver}/macosx install
-if you don't have the admin password, you can install into your home directory,
+if you don't have an admin password, you can install into your home directory
instead by passing an INSTALL_ROOT argument to make:
make -C tcl${ver}/macosx install INSTALL_ROOT="${HOME}/"
make -C tk${ver}/macosx install INSTALL_ROOT="${HOME}/"
@@ -289,27 +354,27 @@ This allows switching to the debug libraries at runtime by setting
(c.f. man dyld for more details)
If you only want to build and install the debug or optimized build, use the
-'develop' or 'deploy' target variants of the GNUmakefiles, respectively.
+'develop' or 'deploy' target variants of the GNUmakefile, respectively.
For example, to build and install only the optimized versions:
make -C tcl${ver}/macosx deploy
make -C tk${ver}/macosx deploy
sudo make -C tcl${ver}/macosx install-deploy
sudo make -C tk${ver}/macosx install-deploy
-- The GNUmakefiles can also build a version of 'Wish' that has the Tcl and Tk
+- The GNUmakefile can also build a version of Wish.app that has the Tcl and Tk
frameworks embedded in its application package. This allows for standalone
deployment of the application with no installation required, e.g. from read-only
-media. To build & install in this manner, use the 'embedded' target variants of
-the GNUmakefiles. For example, to build a standalone 'Wish.app'
-in ./embedded/Applications/Utilities:
+media. To build & install in this manner, use the 'embedded' variants of
+the GNUmakefile targets.
+For example, to build a standalone 'Wish.app' in ./emb/Applications/Utilities:
make -C tcl${ver}/macosx embedded
make -C tk${ver}/macosx embedded
- sudo make -C tcl${ver}/macosx install-embedded INSTALL_ROOT=`pwd`/embedded/
- sudo make -C tk${ver}/macosx install-embedded INSTALL_ROOT=`pwd`/embedded/
+ sudo make -C tcl${ver}/macosx install-embedded INSTALL_ROOT=`pwd`/emb/
+ sudo make -C tk${ver}/macosx install-embedded INSTALL_ROOT=`pwd`/emb/
Notes:
* if you've already built standard TclTkAqua, building embedded does not
require any new compiling or linking, so you can skip the first two makes.
- (making relinking unnecessary was added in 8.4.2)
+ (making relinking unnecessary was added with 8.4.2)
* the embedded frameworks include only optimized builds and no documentation.
* the standalone Wish has the directory Wish.app/Contents/lib in its
auto_path. Thus you can place tcl extensions in this directory (i.e. embed
@@ -325,4 +390,4 @@ make overrides to the tk/macosx GNUmakefile, e.g.
TCL_FRAMEWORK_DIR=$HOME/Library/Frameworks TCLSH_DIR=$HOME/usr/bin
sudo make -C tk${ver}/macosx install \
TCL_FRAMEWORK_DIR=$HOME/Library/Frameworks TCLSH_DIR=$HOME/usr/bin
-The Makefile variables TCL_FRAMEWORK_DIR and TCLSH_DIR were added in Tk 8.4.3.
+The Makefile variables TCL_FRAMEWORK_DIR and TCLSH_DIR were added with Tk 8.4.3.
diff --git a/macosx/Tk-Info.plist.in b/macosx/Tk-Info.plist.in
index 1705a98..7cbe63d 100644
--- a/macosx/Tk-Info.plist.in
+++ b/macosx/Tk-Info.plist.in
@@ -1,10 +1,13 @@
<?xml version="1.0" encoding="UTF-8"?>
<!DOCTYPE plist PUBLIC "-//Apple Computer//DTD PLIST 1.0//EN" "http://www.apple.com/DTDs/PropertyList-1.0.dtd">
<!--
- Copyright (c) 2005-2007 Daniel A. Steffen <das@users.sourceforge.net>
+ Copyright (c) 2005-2009 Daniel A. Steffen <das@users.sourceforge.net>
+ Copyright 2008-2009, Apple Inc.
See the file "license.terms" for information on usage and redistribution of
this file, and for a DISCLAIMER OF ALL WARRANTIES.
+
+ RCS: @(#) $Id$
-->
<plist version="1.0">
<dict>
@@ -16,7 +19,7 @@
<string>Tk @TK_WINDOWINGSYSTEM@ @TK_VERSION@@TK_PATCH_LEVEL@,
Copyright © 1989-@TK_YEAR@ Tcl Core Team,
Copyright © 2002-@TK_YEAR@ Daniel A. Steffen,
-Copyright © 2001-2002 Apple Inc.,
+Copyright © 2001-2009 Apple Inc.,
Copyright © 2001-2002 Jim Ingham &amp; Ian Reid</string>
<key>CFBundleIdentifier</key>
<string>com.tcltk.tklibrary</string>
diff --git a/macosx/Tk.icns b/macosx/Tk.icns
new file mode 100644
index 0000000..394b588
--- /dev/null
+++ b/macosx/Tk.icns
Binary files differ
diff --git a/macosx/Tk.tiff b/macosx/Tk.tiff
new file mode 100644
index 0000000..1e2aed5
--- /dev/null
+++ b/macosx/Tk.tiff
Binary files differ
diff --git a/macosx/Wish-Common.xcconfig b/macosx/Wish-Common.xcconfig
index d9646a9..cc1c8fc 100644
--- a/macosx/Wish-Common.xcconfig
+++ b/macosx/Wish-Common.xcconfig
@@ -4,15 +4,19 @@
// This file contains the Xcode build settings comon to all
// project configurations in Wish.xcodeproj.
//
-// Copyright (c) 2007-2008 Daniel A. Steffen <das@users.sourceforge.net>
+// Copyright (c) 2007-2009 Daniel A. Steffen <das@users.sourceforge.net>
+// Copyright 2008-2009, Apple Inc.
//
// See the file "license.terms" for information on usage and redistribution
// of this file, and for a DISCLAIMER OF ALL WARRANTIES.
+//
+// RCS: @(#) $Id$
+//
HEADER_SEARCH_PATHS = $(TK_SRCROOT)/generic $(TK_SRCROOT)/xlib "$(DERIVED_FILE_DIR)/tcl" "$(DERIVED_FILE_DIR)/tk" $(HEADER_SEARCH_PATHS)
REZ_SEARCH_PATHS = $(TK_SRCROOT)/generic $(TCL_SRCROOT)/generic $(REZ_SEARCH_PATHS)
OTHER_LDFLAGS = -headerpad_max_install_names -sectcreate __TEXT __info_plist "$(DERIVED_FILE_DIR)/tk/Wish-Info.plist" $(OTHER_LDFLAGS)
-OTHER_LDFLAGS_AQUA = -sectcreate __TEXT __tk_rsrc "$(REZ_COLLECTOR_DIR)/$(PRODUCT_NAME).rsrc"
+OTHER_LDFLAGS_AQUA =
INSTALL_PATH = $(APPLICATION_INSTALL_PATH)
INSTALL_MODE_FLAG = go-w,a+rX
GCC_PREFIX_HEADER = $(DERIVED_FILE_DIR)/tk/tkConfig.h
@@ -24,7 +28,7 @@ GCC = $(DEVELOPER_DIR)/usr/bin/gcc
GCC_VERSION = 4.0
CC = $(GCC)-$(GCC_VERSION)
LD = $(CC)
-WARNING_CFLAGS_GCC3 = -Wall -Wno-implicit-int -Wno-unused-parameter -Wno-deprecated-declarations
+WARNING_CFLAGS_GCC3 = -Wall -Wno-implicit-int -Wno-unused-parameter
WARNING_CFLAGS = -Wextra -Wno-missing-field-initializers -Winit-self -Wpointer-arith -Wcast-align -Wdisabled-optimization -Winline $(WARNING_CFLAGS_GCC3) $(WARNING_CFLAGS)
REZ_RESOURCE_MAP_READ_ONLY = YES
APPLICATION_INSTALL_PATH = /Applications/Utilities
diff --git a/macosx/Wish-Debug.xcconfig b/macosx/Wish-Debug.xcconfig
index 09def97..f489038 100644
--- a/macosx/Wish-Debug.xcconfig
+++ b/macosx/Wish-Debug.xcconfig
@@ -8,6 +8,9 @@
//
// See the file "license.terms" for information on usage and redistribution
// of this file, and for a DISCLAIMER OF ALL WARRANTIES.
+//
+// RCS: @(#) $Id$
+//
#include "Wish-Common.xcconfig"
diff --git a/macosx/Wish-Info.plist.in b/macosx/Wish-Info.plist.in
index 85b0b08..f0de87d 100644
--- a/macosx/Wish-Info.plist.in
+++ b/macosx/Wish-Info.plist.in
@@ -1,10 +1,13 @@
<?xml version="1.0" encoding="UTF-8"?>
<!DOCTYPE plist PUBLIC "-//Apple Computer//DTD PLIST 1.0//EN" "http://www.apple.com/DTDs/PropertyList-1.0.dtd">
<!--
- Copyright (c) 2005-2007 Daniel A. Steffen <das@users.sourceforge.net>
+ Copyright (c) 2005-2009 Daniel A. Steffen <das@users.sourceforge.net>
+ Copyright 2008-2009, Apple Inc.
See the file "license.terms" for information on usage and redistribution of
this file, and for a DISCLAIMER OF ALL WARRANTIES.
+
+ RCS: @(#) $Id$
-->
<plist version="1.0">
<dict>
@@ -41,7 +44,7 @@
<string>Wish Shell @TK_VERSION@@TK_PATCH_LEVEL@,
Copyright © 1989-@TK_YEAR@ Tcl Core Team,
Copyright © 2002-@TK_YEAR@ Daniel A. Steffen,
-Copyright © 2001-2002 Apple Inc.,
+Copyright © 2001-2009 Apple Inc.,
Copyright © 2001-2002 Jim Ingham &amp; Ian Reid</string>
<key>CFBundleIconFile</key>
<string>Wish.icns</string>
@@ -64,10 +67,12 @@ Copyright © 2001-2002 Jim Ingham &amp; Ian Reid</string>
<key>CFBundleVersion</key>
<string>@TK_VERSION@@TK_PATCH_LEVEL@</string>
<key>LSMinimumSystemVersion</key>
- <string>10.2.0</string>
+ <string>10.5.0</string>
<key>LSRequiresCarbon</key>
<true/>
<key>NSAppleScriptEnabled</key>
<true/>
+ <key>OSAScriptingDefinition</key>
+ <string>Wish.sdef</string>
</dict>
</plist>
diff --git a/macosx/Wish-Release.xcconfig b/macosx/Wish-Release.xcconfig
index d843341..2e83e55 100644
--- a/macosx/Wish-Release.xcconfig
+++ b/macosx/Wish-Release.xcconfig
@@ -8,6 +8,9 @@
//
// See the file "license.terms" for information on usage and redistribution
// of this file, and for a DISCLAIMER OF ALL WARRANTIES.
+//
+// RCS: @(#) $Id$
+//
#include "Wish-Common.xcconfig"
diff --git a/macosx/Wish.icns b/macosx/Wish.icns
index 060bfbd..394b588 100644
--- a/macosx/Wish.icns
+++ b/macosx/Wish.icns
Binary files differ
diff --git a/macosx/Wish.pbproj/default.pbxuser b/macosx/Wish.pbproj/default.pbxuser
deleted file mode 100644
index aafee5a..0000000
--- a/macosx/Wish.pbproj/default.pbxuser
+++ /dev/null
@@ -1,178 +0,0 @@
-// !$*UTF8*$!
-{
- F537552A016C352C01DC9062 = {
- activeBuildStyle = F537552C016C352C01DC9062;
- activeExecutable = F9F6B1E308E8648C00C9CB24;
- activeTarget = F9D6747B08E84DC100688CAA;
- addToTargets = (
- );
- codeSenseManager = F9D7368F06AD399F00DC3A31;
- executables = (
- F9F6B1EB08E864DC00C9CB24,
- F9F6B1E308E8648C00C9CB24,
- );
- sourceControlManager = F9D7368E06AD399F00DC3A31;
- userBuildSettings = {
- SYMROOT = "${SRCROOT}/../../build/tk";
- };
- };
- F9D6747B08E84DC100688CAA = {
- activeExec = 0;
- };
- F9D7368E06AD399F00DC3A31 = {
- fallbackIsa = XCSourceControlManager;
- isSCMEnabled = 0;
- isa = PBXSourceControlManager;
- scmConfiguration = {
- };
- scmType = scm.cvs;
- };
- F9D7368F06AD399F00DC3A31 = {
- indexTemplatePath = "";
- isa = PBXCodeSenseManager;
- usesDefaults = 1;
- wantsCodeCompletion = 1;
- wantsCodeCompletionAutoSuggestions = 1;
- wantsCodeCompletionCaseSensitivity = 1;
- wantsCodeCompletionListAlways = 1;
- wantsCodeCompletionOnlyMatchingItems = 1;
- wantsCodeCompletionParametersIncluded = 1;
- wantsCodeCompletionPlaceholdersInserted = 1;
- wantsCodeCompletionTabCompletes = 1;
- wantsIndex = 1;
- };
- F9F6B1E308E8648C00C9CB24 = {
- activeArgIndex = 2147483647;
- activeArgIndices = (
- );
- argumentStrings = (
- );
- configStateDict = {
- "PBXLSLaunchAction-0" = {
- PBXLSLaunchAction = 0;
- PBXLSLaunchStartAction = 1;
- PBXLSLaunchStdioStyle = 2;
- PBXLSLaunchStyle = 0;
- class = PBXLSRunLaunchConfig;
- displayName = "Executable Runner";
- identifier = com.apple.Xcode.launch.runConfig;
- remoteHostInfo = "";
- startActionInfo = "";
- };
- "PBXLSLaunchAction-1" = {
- PBXLSLaunchAction = 1;
- PBXLSLaunchStartAction = 1;
- PBXLSLaunchStdioStyle = 2;
- PBXLSLaunchStyle = 0;
- class = PBXGDB_LaunchConfig;
- displayName = GDB;
- identifier = com.apple.Xcode.launch.GDBMI_Config;
- remoteHostInfo = "";
- startActionInfo = "";
- };
- };
- cppStopOnCatchEnabled = 0;
- cppStopOnThrowEnabled = 0;
- customDataFormattersEnabled = 1;
- debuggerPlugin = GDBDebugging;
- disassemblyDisplayState = 0;
- dylibVariantSuffix = _debug;
- enableDebugStr = 0;
- environmentEntries = (
- {
- active = NO;
- name = DYLD_PRINT_LIBRARIES;
- },
- );
- isa = PBXExecutable;
- launchableReference = F9F6B1E408E8648C00C9CB24;
- libgmallocEnabled = 0;
- name = Wish;
- shlibInfoDictList = (
- );
- sourceDirectories = (
- );
- };
- F9F6B1E408E8648C00C9CB24 = {
- isa = PBXFileReference;
- lastKnownFileType = wrapper.application;
- path = Wish.app;
- refType = 3;
- sourceTree = BUILT_PRODUCTS_DIR;
- };
- F9F6B1EB08E864DC00C9CB24 = {
- activeArgIndex = 2147483647;
- activeArgIndices = (
- NO,
- NO,
- NO,
- );
- argumentStrings = (
- "${SRCROOT}/../../tcl/tests/all.tcl",
- "${SRCROOT}/../../tk/tests/all.tcl",
- "-verbose \"\"",
- );
- configStateDict = {
- "PBXLSLaunchAction-0" = {
- PBXLSLaunchAction = 0;
- PBXLSLaunchStartAction = 1;
- PBXLSLaunchStdioStyle = 2;
- PBXLSLaunchStyle = 0;
- class = PBXLSRunLaunchConfig;
- displayName = "Executable Runner";
- identifier = com.apple.Xcode.launch.runConfig;
- remoteHostInfo = "";
- startActionInfo = "";
- };
- "PBXLSLaunchAction-1" = {
- PBXLSLaunchAction = 1;
- PBXLSLaunchStartAction = 1;
- PBXLSLaunchStdioStyle = 2;
- PBXLSLaunchStyle = 0;
- class = PBXGDB_LaunchConfig;
- displayName = GDB;
- identifier = com.apple.Xcode.launch.GDBMI_Config;
- remoteHostInfo = "";
- startActionInfo = "";
- };
- };
- cppStopOnCatchEnabled = 0;
- cppStopOnThrowEnabled = 0;
- customDataFormattersEnabled = 1;
- debuggerPlugin = GDBDebugging;
- disassemblyDisplayState = 0;
- dylibVariantSuffix = _debug;
- enableDebugStr = 0;
- environmentEntries = (
- {
- active = YES;
- name = TCL_LIBRARY;
- value = "${SRCROOT}/../../tcl/library";
- },
- {
- active = YES;
- name = TK_LIBRARY;
- value = "${SRCROOT}/../../tk/library";
- },
- {
- active = NO;
- name = DYLD_PRINT_LIBRARIES;
- },
- );
- isa = PBXExecutable;
- launchableReference = F9F6B1EC08E864DC00C9CB24;
- libgmallocEnabled = 0;
- name = tktest;
- shlibInfoDictList = (
- );
- sourceDirectories = (
- );
- };
- F9F6B1EC08E864DC00C9CB24 = {
- isa = PBXFileReference;
- lastKnownFileType = "compiled.mach-o.executable";
- path = tktest;
- refType = 3;
- sourceTree = BUILT_PRODUCTS_DIR;
- };
-}
diff --git a/macosx/Wish.pbproj/jingham.pbxuser b/macosx/Wish.pbproj/jingham.pbxuser
deleted file mode 100644
index aafee5a..0000000
--- a/macosx/Wish.pbproj/jingham.pbxuser
+++ /dev/null
@@ -1,178 +0,0 @@
-// !$*UTF8*$!
-{
- F537552A016C352C01DC9062 = {
- activeBuildStyle = F537552C016C352C01DC9062;
- activeExecutable = F9F6B1E308E8648C00C9CB24;
- activeTarget = F9D6747B08E84DC100688CAA;
- addToTargets = (
- );
- codeSenseManager = F9D7368F06AD399F00DC3A31;
- executables = (
- F9F6B1EB08E864DC00C9CB24,
- F9F6B1E308E8648C00C9CB24,
- );
- sourceControlManager = F9D7368E06AD399F00DC3A31;
- userBuildSettings = {
- SYMROOT = "${SRCROOT}/../../build/tk";
- };
- };
- F9D6747B08E84DC100688CAA = {
- activeExec = 0;
- };
- F9D7368E06AD399F00DC3A31 = {
- fallbackIsa = XCSourceControlManager;
- isSCMEnabled = 0;
- isa = PBXSourceControlManager;
- scmConfiguration = {
- };
- scmType = scm.cvs;
- };
- F9D7368F06AD399F00DC3A31 = {
- indexTemplatePath = "";
- isa = PBXCodeSenseManager;
- usesDefaults = 1;
- wantsCodeCompletion = 1;
- wantsCodeCompletionAutoSuggestions = 1;
- wantsCodeCompletionCaseSensitivity = 1;
- wantsCodeCompletionListAlways = 1;
- wantsCodeCompletionOnlyMatchingItems = 1;
- wantsCodeCompletionParametersIncluded = 1;
- wantsCodeCompletionPlaceholdersInserted = 1;
- wantsCodeCompletionTabCompletes = 1;
- wantsIndex = 1;
- };
- F9F6B1E308E8648C00C9CB24 = {
- activeArgIndex = 2147483647;
- activeArgIndices = (
- );
- argumentStrings = (
- );
- configStateDict = {
- "PBXLSLaunchAction-0" = {
- PBXLSLaunchAction = 0;
- PBXLSLaunchStartAction = 1;
- PBXLSLaunchStdioStyle = 2;
- PBXLSLaunchStyle = 0;
- class = PBXLSRunLaunchConfig;
- displayName = "Executable Runner";
- identifier = com.apple.Xcode.launch.runConfig;
- remoteHostInfo = "";
- startActionInfo = "";
- };
- "PBXLSLaunchAction-1" = {
- PBXLSLaunchAction = 1;
- PBXLSLaunchStartAction = 1;
- PBXLSLaunchStdioStyle = 2;
- PBXLSLaunchStyle = 0;
- class = PBXGDB_LaunchConfig;
- displayName = GDB;
- identifier = com.apple.Xcode.launch.GDBMI_Config;
- remoteHostInfo = "";
- startActionInfo = "";
- };
- };
- cppStopOnCatchEnabled = 0;
- cppStopOnThrowEnabled = 0;
- customDataFormattersEnabled = 1;
- debuggerPlugin = GDBDebugging;
- disassemblyDisplayState = 0;
- dylibVariantSuffix = _debug;
- enableDebugStr = 0;
- environmentEntries = (
- {
- active = NO;
- name = DYLD_PRINT_LIBRARIES;
- },
- );
- isa = PBXExecutable;
- launchableReference = F9F6B1E408E8648C00C9CB24;
- libgmallocEnabled = 0;
- name = Wish;
- shlibInfoDictList = (
- );
- sourceDirectories = (
- );
- };
- F9F6B1E408E8648C00C9CB24 = {
- isa = PBXFileReference;
- lastKnownFileType = wrapper.application;
- path = Wish.app;
- refType = 3;
- sourceTree = BUILT_PRODUCTS_DIR;
- };
- F9F6B1EB08E864DC00C9CB24 = {
- activeArgIndex = 2147483647;
- activeArgIndices = (
- NO,
- NO,
- NO,
- );
- argumentStrings = (
- "${SRCROOT}/../../tcl/tests/all.tcl",
- "${SRCROOT}/../../tk/tests/all.tcl",
- "-verbose \"\"",
- );
- configStateDict = {
- "PBXLSLaunchAction-0" = {
- PBXLSLaunchAction = 0;
- PBXLSLaunchStartAction = 1;
- PBXLSLaunchStdioStyle = 2;
- PBXLSLaunchStyle = 0;
- class = PBXLSRunLaunchConfig;
- displayName = "Executable Runner";
- identifier = com.apple.Xcode.launch.runConfig;
- remoteHostInfo = "";
- startActionInfo = "";
- };
- "PBXLSLaunchAction-1" = {
- PBXLSLaunchAction = 1;
- PBXLSLaunchStartAction = 1;
- PBXLSLaunchStdioStyle = 2;
- PBXLSLaunchStyle = 0;
- class = PBXGDB_LaunchConfig;
- displayName = GDB;
- identifier = com.apple.Xcode.launch.GDBMI_Config;
- remoteHostInfo = "";
- startActionInfo = "";
- };
- };
- cppStopOnCatchEnabled = 0;
- cppStopOnThrowEnabled = 0;
- customDataFormattersEnabled = 1;
- debuggerPlugin = GDBDebugging;
- disassemblyDisplayState = 0;
- dylibVariantSuffix = _debug;
- enableDebugStr = 0;
- environmentEntries = (
- {
- active = YES;
- name = TCL_LIBRARY;
- value = "${SRCROOT}/../../tcl/library";
- },
- {
- active = YES;
- name = TK_LIBRARY;
- value = "${SRCROOT}/../../tk/library";
- },
- {
- active = NO;
- name = DYLD_PRINT_LIBRARIES;
- },
- );
- isa = PBXExecutable;
- launchableReference = F9F6B1EC08E864DC00C9CB24;
- libgmallocEnabled = 0;
- name = tktest;
- shlibInfoDictList = (
- );
- sourceDirectories = (
- );
- };
- F9F6B1EC08E864DC00C9CB24 = {
- isa = PBXFileReference;
- lastKnownFileType = "compiled.mach-o.executable";
- path = tktest;
- refType = 3;
- sourceTree = BUILT_PRODUCTS_DIR;
- };
-}
diff --git a/macosx/Wish.pbproj/project.pbxproj b/macosx/Wish.pbproj/project.pbxproj
deleted file mode 100644
index b1c72e5..0000000
--- a/macosx/Wish.pbproj/project.pbxproj
+++ /dev/null
@@ -1,2312 +0,0 @@
-// !$*UTF8*$!
-{
- archiveVersion = 1;
- classes = {
- };
- objectVersion = 39;
- objects = {
- 4C148E2007ECCFAC0033822E = {
- fileEncoding = 5;
- isa = PBXFileReference;
- lastKnownFileType = sourcecode.c.h;
- name = tkEntry.h;
- path = ../generic/tkEntry.h;
- refType = 2;
- sourceTree = SOURCE_ROOT;
- };
- 4C148E2407ECCFCF0033822E = {
- fileEncoding = 5;
- isa = PBXFileReference;
- lastKnownFileType = sourcecode.c.c;
- path = tkMacOSXEntry.c;
- refType = 4;
- sourceTree = "<group>";
- };
- 4C3B4CF6040B18B200C916F0 = {
- fileEncoding = 5;
- isa = PBXFileReference;
- lastKnownFileType = sourcecode.rez;
- path = tkMacOSXAETE.r;
- refType = 4;
- sourceTree = "<group>";
- };
- 4C8A204405E0421900C18A82 = {
- fileEncoding = 5;
- isa = PBXFileReference;
- lastKnownFileType = sourcecode.c.c;
- path = tkMacOSXCarbonEvents.c;
- refType = 4;
- sourceTree = "<group>";
- };
- 4CB2D7CF0619F8EB0081E375 = {
- fileEncoding = 5;
- isa = PBXFileReference;
- lastKnownFileType = sourcecode.c.c;
- path = tkMacOSXScale.c;
- refType = 4;
- sourceTree = "<group>";
- };
-//4C0
-//4C1
-//4C2
-//4C3
-//4C4
-//950
-//951
-//952
-//953
-//954
- 95911CC7081532D8006F6BCB = {
- isa = PBXFileReference;
- lastKnownFileType = wrapper.framework;
- name = IOKit.framework;
- path = /System/Library/Frameworks/IOKit.framework;
- refType = 0;
- sourceTree = "<absolute>";
- };
-//950
-//951
-//952
-//953
-//954
-//F50
-//F51
-//F52
-//F53
-//F54
- F50D96120196176E01DC9062 = {
- isa = PBXFileReference;
- lastKnownFileType = wrapper.framework;
- name = ApplicationServices.framework;
- path = /System/Library/Frameworks/ApplicationServices.framework;
- refType = 0;
- sourceTree = "<absolute>";
- };
- F537552A016C352C01DC9062 = {
- buildSettings = {
- };
- buildStyles = (
- F537552C016C352C01DC9062,
- F537552D016C352C01DC9062,
- );
- hasScannedForEncodings = 1;
- isa = PBXProject;
- mainGroup = F537552B016C352C01DC9062;
- productRefGroup = F53755DD016C38D201DC9062;
- projectDirPath = "";
- targets = (
- F9D6747B08E84DC100688CAA,
- );
- };
- F537552B016C352C01DC9062 = {
- children = (
- F92ED9910403D0F0006F146B,
- F5C88659017D625C01DC9062,
- F5DF07A7016CD03801DC9062,
- F5375688016C3F1001DC9062,
- F5375531016C376E01DC9062,
- F537552E016C376E01DC9062,
- F537553C016C376E01DC9062,
- F53755C9016C389901DC9062,
- F53755CC016C389901DC9062,
- F537567C016C3ADB01DC9062,
- F53755DD016C38D201DC9062,
- );
- isa = PBXGroup;
- refType = 4;
- sourceTree = "<group>";
- };
- F537552C016C352C01DC9062 = {
- buildSettings = {
- BUILD_STYLE = Development;
- MAKE_TARGET = develop;
- };
- isa = PBXBuildStyle;
- name = Development;
- };
- F537552D016C352C01DC9062 = {
- buildSettings = {
- BUILD_STYLE = Deployment;
- MAKE_TARGET = deploy;
- };
- isa = PBXBuildStyle;
- name = Deployment;
- };
- F537552E016C376E01DC9062 = {
- children = (
- F537552F016C376E01DC9062,
- F5375530016C376E01DC9062,
- );
- isa = PBXGroup;
- name = Generic;
- refType = 4;
- sourceTree = "<group>";
- };
- F537552F016C376E01DC9062 = {
- children = (
- F5375569016C37A601DC9062,
- F537556A016C37A601DC9062,
- F537556B016C37A601DC9062,
- F537556C016C37A601DC9062,
- F537556D016C37A601DC9062,
- F537556E016C37A601DC9062,
- F537556F016C37A601DC9062,
- F5375570016C37A601DC9062,
- 4C148E2007ECCFAC0033822E,
- F5375571016C37A601DC9062,
- F5375572016C37A601DC9062,
- F5375573016C37A601DC9062,
- F5375574016C37A601DC9062,
- F5375575016C37A601DC9062,
- F5375576016C37A601DC9062,
- F5375577016C37A601DC9062,
- F5375578016C37A601DC9062,
- F5375579016C37A601DC9062,
- F537557A016C37A601DC9062,
- F537557B016C37A601DC9062,
- F537557C016C37A601DC9062,
- F537557D016C37A601DC9062,
- F537557E016C37A601DC9062,
- F537557F016C37A601DC9062,
- F5BFE58F02F8C45B01DC9062,
- );
- isa = PBXGroup;
- name = Headers;
- refType = 4;
- sourceTree = "<group>";
- };
- F5375530016C376E01DC9062 = {
- children = (
- F5375580016C389901DC9062,
- F5375581016C389901DC9062,
- F5375582016C389901DC9062,
- F5375583016C389901DC9062,
- F5375584016C389901DC9062,
- F5375585016C389901DC9062,
- F5375586016C389901DC9062,
- F5375587016C389901DC9062,
- F5375588016C389901DC9062,
- F5375589016C389901DC9062,
- F537558A016C389901DC9062,
- F537558B016C389901DC9062,
- F537558C016C389901DC9062,
- F537558D016C389901DC9062,
- F537558E016C389901DC9062,
- F537558F016C389901DC9062,
- F5375590016C389901DC9062,
- F5375591016C389901DC9062,
- F5375592016C389901DC9062,
- F5375593016C389901DC9062,
- F5375594016C389901DC9062,
- F5375595016C389901DC9062,
- F5375596016C389901DC9062,
- F5375597016C389901DC9062,
- F5375598016C389901DC9062,
- F5375599016C389901DC9062,
- F537559A016C389901DC9062,
- F537559B016C389901DC9062,
- F537559C016C389901DC9062,
- F537559D016C389901DC9062,
- F537559E016C389901DC9062,
- F537559F016C389901DC9062,
- F53755A0016C389901DC9062,
- F53755A1016C389901DC9062,
- F53755A2016C389901DC9062,
- F53755A3016C389901DC9062,
- F53755A4016C389901DC9062,
- F53755A5016C389901DC9062,
- F53755A6016C389901DC9062,
- F53755A7016C389901DC9062,
- F53755A8016C389901DC9062,
- F53755A9016C389901DC9062,
- F53755AA016C389901DC9062,
- F53755AB016C389901DC9062,
- F53755AC016C389901DC9062,
- F53755AD016C389901DC9062,
- F53755AE016C389901DC9062,
- F53755AF016C389901DC9062,
- F53755B0016C389901DC9062,
- F53755B1016C389901DC9062,
- F53755B2016C389901DC9062,
- F55BC46802B2D38B01DC9062,
- F53755B3016C389901DC9062,
- F53755B4016C389901DC9062,
- F53755B5016C389901DC9062,
- F53755B6016C389901DC9062,
- F53755B7016C389901DC9062,
- F53755B8016C389901DC9062,
- F53755B9016C389901DC9062,
- F53755BA016C389901DC9062,
- F53755BB016C389901DC9062,
- F5BFE58B02F8C41501DC9062,
- F53755BC016C389901DC9062,
- F53755BD016C389901DC9062,
- F53755BE016C389901DC9062,
- F53755BF016C389901DC9062,
- F53755C0016C389901DC9062,
- F53755C1016C389901DC9062,
- F53755C2016C389901DC9062,
- F53755C3016C389901DC9062,
- F53755C4016C389901DC9062,
- F53755C5016C389901DC9062,
- F5BFE58C02F8C41501DC9062,
- F53755C6016C389901DC9062,
- F53755C7016C389901DC9062,
- F53755C8016C389901DC9062,
- );
- isa = PBXGroup;
- name = Source;
- refType = 4;
- sourceTree = "<group>";
- };
- F5375531016C376E01DC9062 = {
- children = (
- F5375532016C376E01DC9062,
- F537553B016C376E01DC9062,
- );
- isa = PBXGroup;
- name = Resources;
- refType = 4;
- sourceTree = "<group>";
- };
- F5375532016C376E01DC9062 = {
- children = (
- F5375533016C376E01DC9062,
- 4C3B4CF6040B18B200C916F0,
- F5375535016C376E01DC9062,
- F5375538016C376E01DC9062,
- F537553A016C376E01DC9062,
- );
- isa = PBXGroup;
- name = "Resource Manager Resources";
- refType = 4;
- sourceTree = "<group>";
- };
- F5375533016C376E01DC9062 = {
- fileEncoding = 5;
- isa = PBXFileReference;
- lastKnownFileType = sourcecode.rez;
- path = tkAboutDlg.r;
- refType = 4;
- sourceTree = "<group>";
- };
- F5375535016C376E01DC9062 = {
- fileEncoding = 5;
- isa = PBXFileReference;
- lastKnownFileType = sourcecode.rez;
- path = tkMacOSXCursors.r;
- refType = 4;
- sourceTree = "<group>";
- };
- F5375538016C376E01DC9062 = {
- fileEncoding = 5;
- isa = PBXFileReference;
- lastKnownFileType = sourcecode.rez;
- path = tkMacOSXMenu.r;
- refType = 4;
- sourceTree = "<group>";
- };
- F537553A016C376E01DC9062 = {
- fileEncoding = 5;
- isa = PBXFileReference;
- lastKnownFileType = sourcecode.rez;
- path = tkMacOSXXCursors.r;
- refType = 4;
- sourceTree = "<group>";
- };
- F537553B016C376E01DC9062 = {
- isa = PBXFileReference;
- lastKnownFileType = image.icns;
- path = Wish.icns;
- refType = 4;
- sourceTree = "<group>";
- };
- F537553C016C376E01DC9062 = {
- children = (
- F537553D016C376E01DC9062,
- F5375546016C376E01DC9062,
- );
- isa = PBXGroup;
- name = "MacOS X";
- refType = 4;
- sourceTree = "<group>";
- };
- F537553D016C376E01DC9062 = {
- children = (
- F537553E016C376E01DC9062,
- F537553F016C376E01DC9062,
- F5375540016C376E01DC9062,
- F5375541016C376E01DC9062,
- F5375542016C376E01DC9062,
- F5375543016C376E01DC9062,
- F5375545016C376E01DC9062,
- );
- isa = PBXGroup;
- name = Headers;
- refType = 4;
- sourceTree = "<group>";
- };
- F537553E016C376E01DC9062 = {
- fileEncoding = 5;
- isa = PBXFileReference;
- lastKnownFileType = sourcecode.c.h;
- path = tkMacOSX.h;
- refType = 2;
- sourceTree = SOURCE_ROOT;
- };
- F537553F016C376E01DC9062 = {
- fileEncoding = 5;
- isa = PBXFileReference;
- lastKnownFileType = sourcecode.c.h;
- path = tkMacOSXDebug.h;
- refType = 2;
- sourceTree = SOURCE_ROOT;
- };
- F5375540016C376E01DC9062 = {
- fileEncoding = 5;
- isa = PBXFileReference;
- lastKnownFileType = sourcecode.c.h;
- path = tkMacOSXDefault.h;
- refType = 2;
- sourceTree = SOURCE_ROOT;
- };
- F5375541016C376E01DC9062 = {
- fileEncoding = 5;
- isa = PBXFileReference;
- lastKnownFileType = sourcecode.c.h;
- path = tkMacOSXEvent.h;
- refType = 2;
- sourceTree = SOURCE_ROOT;
- };
- F5375542016C376E01DC9062 = {
- fileEncoding = 5;
- isa = PBXFileReference;
- lastKnownFileType = sourcecode.c.h;
- path = tkMacOSXInt.h;
- refType = 2;
- sourceTree = SOURCE_ROOT;
- };
- F5375543016C376E01DC9062 = {
- fileEncoding = 5;
- isa = PBXFileReference;
- lastKnownFileType = sourcecode.c.h;
- path = tkMacOSXPort.h;
- refType = 2;
- sourceTree = SOURCE_ROOT;
- };
- F5375545016C376E01DC9062 = {
- fileEncoding = 5;
- isa = PBXFileReference;
- lastKnownFileType = sourcecode.c.h;
- path = tkMacOSXWm.h;
- refType = 2;
- sourceTree = SOURCE_ROOT;
- };
- F5375546016C376E01DC9062 = {
- children = (
- F5375549016C376E01DC9062,
- F537554A016C376E01DC9062,
- 4C8A204405E0421900C18A82,
- F537554B016C376E01DC9062,
- F537554C016C376E01DC9062,
- F537554D016C376E01DC9062,
- F537554E016C376E01DC9062,
- F537554F016C376E01DC9062,
- F5375550016C376E01DC9062,
- F5375551016C376E01DC9062,
- F5375552016C376E01DC9062,
- 4C148E2407ECCFCF0033822E,
- F5375553016C376E01DC9062,
- F5375554016C376E01DC9062,
- F5375555016C376E01DC9062,
- F5375556016C376E01DC9062,
- F5375557016C376E01DC9062,
- F5375558016C376E01DC9062,
- F5375559016C376E01DC9062,
- F537555A016C376E01DC9062,
- F537555B016C376E01DC9062,
- F537555C016C376E01DC9062,
- F537555D016C376E01DC9062,
- F537555E016C376E01DC9062,
- 4CB2D7CF0619F8EB0081E375,
- F5375560016C376E01DC9062,
- F5375561016C376E01DC9062,
- F5375562016C376E01DC9062,
- F5375563016C376E01DC9062,
- F5375565016C376E01DC9062,
- F5375567016C376E01DC9062,
- F5375568016C376E01DC9062,
- );
- isa = PBXGroup;
- name = Source;
- refType = 4;
- sourceTree = "<group>";
- };
- F5375548016C376E01DC9062 = {
- fileEncoding = 5;
- isa = PBXFileReference;
- lastKnownFileType = sourcecode.c.c;
- name = tkAppInit.c;
- path = ../unix/tkAppInit.c;
- refType = 2;
- sourceTree = SOURCE_ROOT;
- };
- F5375549016C376E01DC9062 = {
- fileEncoding = 5;
- isa = PBXFileReference;
- lastKnownFileType = sourcecode.c.c;
- path = tkMacOSXBitmap.c;
- refType = 4;
- sourceTree = "<group>";
- };
- F537554A016C376E01DC9062 = {
- fileEncoding = 5;
- isa = PBXFileReference;
- lastKnownFileType = sourcecode.c.c;
- path = tkMacOSXButton.c;
- refType = 4;
- sourceTree = "<group>";
- };
- F537554B016C376E01DC9062 = {
- fileEncoding = 5;
- isa = PBXFileReference;
- lastKnownFileType = sourcecode.c.c;
- path = tkMacOSXClipboard.c;
- refType = 4;
- sourceTree = "<group>";
- };
- F537554C016C376E01DC9062 = {
- fileEncoding = 5;
- isa = PBXFileReference;
- lastKnownFileType = sourcecode.c.c;
- path = tkMacOSXColor.c;
- refType = 4;
- sourceTree = "<group>";
- };
- F537554D016C376E01DC9062 = {
- fileEncoding = 5;
- isa = PBXFileReference;
- lastKnownFileType = sourcecode.c.c;
- path = tkMacOSXConfig.c;
- refType = 4;
- sourceTree = "<group>";
- };
- F537554E016C376E01DC9062 = {
- fileEncoding = 5;
- isa = PBXFileReference;
- lastKnownFileType = sourcecode.c.c;
- path = tkMacOSXCursor.c;
- refType = 4;
- sourceTree = "<group>";
- };
- F537554F016C376E01DC9062 = {
- fileEncoding = 5;
- isa = PBXFileReference;
- lastKnownFileType = sourcecode.c.c;
- path = tkMacOSXDebug.c;
- refType = 4;
- sourceTree = "<group>";
- };
- F5375550016C376E01DC9062 = {
- fileEncoding = 5;
- isa = PBXFileReference;
- lastKnownFileType = sourcecode.c.c;
- path = tkMacOSXDialog.c;
- refType = 4;
- sourceTree = "<group>";
- };
- F5375551016C376E01DC9062 = {
- fileEncoding = 5;
- isa = PBXFileReference;
- lastKnownFileType = sourcecode.c.c;
- path = tkMacOSXDraw.c;
- refType = 4;
- sourceTree = "<group>";
- };
- F5375552016C376E01DC9062 = {
- fileEncoding = 5;
- isa = PBXFileReference;
- lastKnownFileType = sourcecode.c.c;
- path = tkMacOSXEmbed.c;
- refType = 4;
- sourceTree = "<group>";
- };
- F5375553016C376E01DC9062 = {
- fileEncoding = 5;
- isa = PBXFileReference;
- lastKnownFileType = sourcecode.c.c;
- path = tkMacOSXEvent.c;
- refType = 4;
- sourceTree = "<group>";
- };
- F5375554016C376E01DC9062 = {
- fileEncoding = 5;
- isa = PBXFileReference;
- lastKnownFileType = sourcecode.c.c;
- path = tkMacOSXFont.c;
- refType = 4;
- sourceTree = "<group>";
- };
- F5375555016C376E01DC9062 = {
- fileEncoding = 5;
- isa = PBXFileReference;
- lastKnownFileType = sourcecode.c.c;
- path = tkMacOSXHLEvents.c;
- refType = 4;
- sourceTree = "<group>";
- };
- F5375556016C376E01DC9062 = {
- fileEncoding = 5;
- isa = PBXFileReference;
- lastKnownFileType = sourcecode.c.c;
- path = tkMacOSXInit.c;
- refType = 4;
- sourceTree = "<group>";
- };
- F5375557016C376E01DC9062 = {
- fileEncoding = 5;
- isa = PBXFileReference;
- lastKnownFileType = sourcecode.c.c;
- path = tkMacOSXKeyboard.c;
- refType = 4;
- sourceTree = "<group>";
- };
- F5375558016C376E01DC9062 = {
- fileEncoding = 5;
- isa = PBXFileReference;
- lastKnownFileType = sourcecode.c.c;
- path = tkMacOSXKeyEvent.c;
- refType = 4;
- sourceTree = "<group>";
- };
- F5375559016C376E01DC9062 = {
- fileEncoding = 5;
- isa = PBXFileReference;
- lastKnownFileType = sourcecode.c.c;
- path = tkMacOSXMenu.c;
- refType = 4;
- sourceTree = "<group>";
- };
- F537555A016C376E01DC9062 = {
- fileEncoding = 5;
- isa = PBXFileReference;
- lastKnownFileType = sourcecode.c.c;
- path = tkMacOSXMenubutton.c;
- refType = 4;
- sourceTree = "<group>";
- };
- F537555B016C376E01DC9062 = {
- fileEncoding = 5;
- isa = PBXFileReference;
- lastKnownFileType = sourcecode.c.c;
- path = tkMacOSXMenus.c;
- refType = 4;
- sourceTree = "<group>";
- };
- F537555C016C376E01DC9062 = {
- fileEncoding = 5;
- isa = PBXFileReference;
- lastKnownFileType = sourcecode.c.c;
- path = tkMacOSXMouseEvent.c;
- refType = 4;
- sourceTree = "<group>";
- };
- F537555D016C376E01DC9062 = {
- fileEncoding = 5;
- isa = PBXFileReference;
- lastKnownFileType = sourcecode.c.c;
- path = tkMacOSXNotify.c;
- refType = 4;
- sourceTree = "<group>";
- };
- F537555E016C376E01DC9062 = {
- fileEncoding = 5;
- isa = PBXFileReference;
- lastKnownFileType = sourcecode.c.c;
- path = tkMacOSXRegion.c;
- refType = 4;
- sourceTree = "<group>";
- };
- F5375560016C376E01DC9062 = {
- fileEncoding = 5;
- isa = PBXFileReference;
- lastKnownFileType = sourcecode.c.c;
- path = tkMacOSXScrlbr.c;
- refType = 4;
- sourceTree = "<group>";
- };
- F5375561016C376E01DC9062 = {
- fileEncoding = 5;
- isa = PBXFileReference;
- lastKnownFileType = sourcecode.c.c;
- path = tkMacOSXSend.c;
- refType = 4;
- sourceTree = "<group>";
- };
- F5375562016C376E01DC9062 = {
- fileEncoding = 5;
- isa = PBXFileReference;
- lastKnownFileType = sourcecode.c.c;
- path = tkMacOSXSubwindows.c;
- refType = 4;
- sourceTree = "<group>";
- };
- F5375563016C376E01DC9062 = {
- fileEncoding = 5;
- isa = PBXFileReference;
- lastKnownFileType = sourcecode.c.c;
- path = tkMacOSXTest.c;
- refType = 4;
- sourceTree = "<group>";
- };
- F5375565016C376E01DC9062 = {
- fileEncoding = 5;
- isa = PBXFileReference;
- lastKnownFileType = sourcecode.c.c;
- path = tkMacOSXWindowEvent.c;
- refType = 4;
- sourceTree = "<group>";
- };
- F5375567016C376E01DC9062 = {
- fileEncoding = 5;
- isa = PBXFileReference;
- lastKnownFileType = sourcecode.c.c;
- path = tkMacOSXWm.c;
- refType = 4;
- sourceTree = "<group>";
- };
- F5375568016C376E01DC9062 = {
- fileEncoding = 5;
- isa = PBXFileReference;
- lastKnownFileType = sourcecode.c.c;
- path = tkMacOSXXStubs.c;
- refType = 4;
- sourceTree = "<group>";
- };
- F5375569016C37A601DC9062 = {
- fileEncoding = 5;
- isa = PBXFileReference;
- lastKnownFileType = sourcecode.c.h;
- name = default.h;
- path = ../generic/default.h;
- refType = 2;
- sourceTree = SOURCE_ROOT;
- };
- F537556A016C37A601DC9062 = {
- fileEncoding = 5;
- isa = PBXFileReference;
- lastKnownFileType = sourcecode.c.h;
- name = ks_names.h;
- path = ../generic/ks_names.h;
- refType = 2;
- sourceTree = SOURCE_ROOT;
- };
- F537556B016C37A601DC9062 = {
- fileEncoding = 5;
- isa = PBXFileReference;
- lastKnownFileType = sourcecode.c.h;
- name = tk.h;
- path = ../generic/tk.h;
- refType = 2;
- sourceTree = SOURCE_ROOT;
- };
- F537556C016C37A601DC9062 = {
- fileEncoding = 5;
- isa = PBXFileReference;
- lastKnownFileType = sourcecode.c.h;
- name = tk3d.h;
- path = ../generic/tk3d.h;
- refType = 2;
- sourceTree = SOURCE_ROOT;
- };
- F537556D016C37A601DC9062 = {
- fileEncoding = 5;
- isa = PBXFileReference;
- lastKnownFileType = sourcecode.c.h;
- name = tkButton.h;
- path = ../generic/tkButton.h;
- refType = 2;
- sourceTree = SOURCE_ROOT;
- };
- F537556E016C37A601DC9062 = {
- fileEncoding = 5;
- isa = PBXFileReference;
- lastKnownFileType = sourcecode.c.h;
- name = tkCanvas.h;
- path = ../generic/tkCanvas.h;
- refType = 2;
- sourceTree = SOURCE_ROOT;
- };
- F537556F016C37A601DC9062 = {
- fileEncoding = 5;
- isa = PBXFileReference;
- lastKnownFileType = sourcecode.c.h;
- name = tkColor.h;
- path = ../generic/tkColor.h;
- refType = 2;
- sourceTree = SOURCE_ROOT;
- };
- F5375570016C37A601DC9062 = {
- fileEncoding = 5;
- isa = PBXFileReference;
- lastKnownFileType = sourcecode.c.h;
- name = tkDecls.h;
- path = ../generic/tkDecls.h;
- refType = 2;
- sourceTree = SOURCE_ROOT;
- };
- F5375571016C37A601DC9062 = {
- fileEncoding = 5;
- isa = PBXFileReference;
- lastKnownFileType = sourcecode.c.h;
- name = tkFileFilter.h;
- path = ../generic/tkFileFilter.h;
- refType = 2;
- sourceTree = SOURCE_ROOT;
- };
- F5375572016C37A601DC9062 = {
- fileEncoding = 5;
- isa = PBXFileReference;
- lastKnownFileType = sourcecode.c.h;
- name = tkFont.h;
- path = ../generic/tkFont.h;
- refType = 2;
- sourceTree = SOURCE_ROOT;
- };
- F5375573016C37A601DC9062 = {
- fileEncoding = 5;
- isa = PBXFileReference;
- lastKnownFileType = sourcecode.c.h;
- name = tkInitScript.h;
- path = ../generic/tkInitScript.h;
- refType = 2;
- sourceTree = SOURCE_ROOT;
- };
- F5375574016C37A601DC9062 = {
- fileEncoding = 5;
- isa = PBXFileReference;
- lastKnownFileType = sourcecode.c.h;
- name = tkInt.h;
- path = ../generic/tkInt.h;
- refType = 2;
- sourceTree = SOURCE_ROOT;
- };
- F5375575016C37A601DC9062 = {
- fileEncoding = 5;
- isa = PBXFileReference;
- lastKnownFileType = sourcecode.c.h;
- name = tkIntDecls.h;
- path = ../generic/tkIntDecls.h;
- refType = 2;
- sourceTree = SOURCE_ROOT;
- };
- F5375576016C37A601DC9062 = {
- fileEncoding = 5;
- isa = PBXFileReference;
- lastKnownFileType = sourcecode.c.h;
- name = tkIntPlatDecls.h;
- path = ../generic/tkIntPlatDecls.h;
- refType = 2;
- sourceTree = SOURCE_ROOT;
- };
- F5375577016C37A601DC9062 = {
- fileEncoding = 5;
- isa = PBXFileReference;
- lastKnownFileType = sourcecode.c.h;
- name = tkIntXlibDecls.h;
- path = ../generic/tkIntXlibDecls.h;
- refType = 2;
- sourceTree = SOURCE_ROOT;
- };
- F5375578016C37A601DC9062 = {
- fileEncoding = 5;
- isa = PBXFileReference;
- lastKnownFileType = sourcecode.c.h;
- name = tkMenu.h;
- path = ../generic/tkMenu.h;
- refType = 2;
- sourceTree = SOURCE_ROOT;
- };
- F5375579016C37A601DC9062 = {
- fileEncoding = 5;
- isa = PBXFileReference;
- lastKnownFileType = sourcecode.c.h;
- name = tkMenubutton.h;
- path = ../generic/tkMenubutton.h;
- refType = 2;
- sourceTree = SOURCE_ROOT;
- };
- F537557A016C37A601DC9062 = {
- fileEncoding = 5;
- isa = PBXFileReference;
- lastKnownFileType = sourcecode.c.h;
- name = tkPlatDecls.h;
- path = ../generic/tkPlatDecls.h;
- refType = 2;
- sourceTree = SOURCE_ROOT;
- };
- F537557B016C37A601DC9062 = {
- fileEncoding = 5;
- isa = PBXFileReference;
- lastKnownFileType = sourcecode.c.h;
- name = tkPort.h;
- path = ../generic/tkPort.h;
- refType = 2;
- sourceTree = SOURCE_ROOT;
- };
- F537557C016C37A601DC9062 = {
- fileEncoding = 5;
- isa = PBXFileReference;
- lastKnownFileType = sourcecode.c.h;
- name = tkScale.h;
- path = ../generic/tkScale.h;
- refType = 2;
- sourceTree = SOURCE_ROOT;
- };
- F537557D016C37A601DC9062 = {
- fileEncoding = 5;
- isa = PBXFileReference;
- lastKnownFileType = sourcecode.c.h;
- name = tkScrollbar.h;
- path = ../generic/tkScrollbar.h;
- refType = 2;
- sourceTree = SOURCE_ROOT;
- };
- F537557E016C37A601DC9062 = {
- fileEncoding = 5;
- isa = PBXFileReference;
- lastKnownFileType = sourcecode.c.h;
- name = tkSelect.h;
- path = ../generic/tkSelect.h;
- refType = 2;
- sourceTree = SOURCE_ROOT;
- };
- F537557F016C37A601DC9062 = {
- fileEncoding = 5;
- isa = PBXFileReference;
- lastKnownFileType = sourcecode.c.h;
- name = tkText.h;
- path = ../generic/tkText.h;
- refType = 2;
- sourceTree = SOURCE_ROOT;
- };
- F5375580016C389901DC9062 = {
- fileEncoding = 5;
- isa = PBXFileReference;
- lastKnownFileType = sourcecode.c.c;
- name = tk3d.c;
- path = ../generic/tk3d.c;
- refType = 2;
- sourceTree = SOURCE_ROOT;
- };
- F5375581016C389901DC9062 = {
- fileEncoding = 5;
- isa = PBXFileReference;
- lastKnownFileType = sourcecode.c.c;
- name = tkArgv.c;
- path = ../generic/tkArgv.c;
- refType = 2;
- sourceTree = SOURCE_ROOT;
- };
- F5375582016C389901DC9062 = {
- fileEncoding = 5;
- isa = PBXFileReference;
- lastKnownFileType = sourcecode.c.c;
- name = tkAtom.c;
- path = ../generic/tkAtom.c;
- refType = 2;
- sourceTree = SOURCE_ROOT;
- };
- F5375583016C389901DC9062 = {
- fileEncoding = 5;
- isa = PBXFileReference;
- lastKnownFileType = sourcecode.c.c;
- name = tkBind.c;
- path = ../generic/tkBind.c;
- refType = 2;
- sourceTree = SOURCE_ROOT;
- };
- F5375584016C389901DC9062 = {
- fileEncoding = 5;
- isa = PBXFileReference;
- lastKnownFileType = sourcecode.c.c;
- name = tkBitmap.c;
- path = ../generic/tkBitmap.c;
- refType = 2;
- sourceTree = SOURCE_ROOT;
- };
- F5375585016C389901DC9062 = {
- fileEncoding = 5;
- isa = PBXFileReference;
- lastKnownFileType = sourcecode.c.c;
- name = tkButton.c;
- path = ../generic/tkButton.c;
- refType = 2;
- sourceTree = SOURCE_ROOT;
- };
- F5375586016C389901DC9062 = {
- fileEncoding = 5;
- isa = PBXFileReference;
- lastKnownFileType = sourcecode.c.c;
- name = tkCanvArc.c;
- path = ../generic/tkCanvArc.c;
- refType = 2;
- sourceTree = SOURCE_ROOT;
- };
- F5375587016C389901DC9062 = {
- fileEncoding = 5;
- isa = PBXFileReference;
- lastKnownFileType = sourcecode.c.c;
- name = tkCanvas.c;
- path = ../generic/tkCanvas.c;
- refType = 2;
- sourceTree = SOURCE_ROOT;
- };
- F5375588016C389901DC9062 = {
- fileEncoding = 5;
- isa = PBXFileReference;
- lastKnownFileType = sourcecode.c.c;
- name = tkCanvBmap.c;
- path = ../generic/tkCanvBmap.c;
- refType = 2;
- sourceTree = SOURCE_ROOT;
- };
- F5375589016C389901DC9062 = {
- fileEncoding = 5;
- isa = PBXFileReference;
- lastKnownFileType = sourcecode.c.c;
- name = tkCanvImg.c;
- path = ../generic/tkCanvImg.c;
- refType = 2;
- sourceTree = SOURCE_ROOT;
- };
- F537558A016C389901DC9062 = {
- fileEncoding = 5;
- isa = PBXFileReference;
- lastKnownFileType = sourcecode.c.c;
- name = tkCanvLine.c;
- path = ../generic/tkCanvLine.c;
- refType = 2;
- sourceTree = SOURCE_ROOT;
- };
- F537558B016C389901DC9062 = {
- fileEncoding = 5;
- isa = PBXFileReference;
- lastKnownFileType = sourcecode.c.c;
- name = tkCanvPoly.c;
- path = ../generic/tkCanvPoly.c;
- refType = 2;
- sourceTree = SOURCE_ROOT;
- };
- F537558C016C389901DC9062 = {
- fileEncoding = 5;
- isa = PBXFileReference;
- lastKnownFileType = sourcecode.c.c;
- name = tkCanvPs.c;
- path = ../generic/tkCanvPs.c;
- refType = 2;
- sourceTree = SOURCE_ROOT;
- };
- F537558D016C389901DC9062 = {
- fileEncoding = 5;
- isa = PBXFileReference;
- lastKnownFileType = sourcecode.c.c;
- name = tkCanvText.c;
- path = ../generic/tkCanvText.c;
- refType = 2;
- sourceTree = SOURCE_ROOT;
- };
- F537558E016C389901DC9062 = {
- fileEncoding = 5;
- isa = PBXFileReference;
- lastKnownFileType = sourcecode.c.c;
- name = tkCanvUtil.c;
- path = ../generic/tkCanvUtil.c;
- refType = 2;
- sourceTree = SOURCE_ROOT;
- };
- F537558F016C389901DC9062 = {
- fileEncoding = 5;
- isa = PBXFileReference;
- lastKnownFileType = sourcecode.c.c;
- name = tkCanvWind.c;
- path = ../generic/tkCanvWind.c;
- refType = 2;
- sourceTree = SOURCE_ROOT;
- };
- F5375590016C389901DC9062 = {
- fileEncoding = 5;
- isa = PBXFileReference;
- lastKnownFileType = sourcecode.c.c;
- name = tkClipboard.c;
- path = ../generic/tkClipboard.c;
- refType = 2;
- sourceTree = SOURCE_ROOT;
- };
- F5375591016C389901DC9062 = {
- fileEncoding = 5;
- isa = PBXFileReference;
- lastKnownFileType = sourcecode.c.c;
- name = tkCmds.c;
- path = ../generic/tkCmds.c;
- refType = 2;
- sourceTree = SOURCE_ROOT;
- };
- F5375592016C389901DC9062 = {
- fileEncoding = 5;
- isa = PBXFileReference;
- lastKnownFileType = sourcecode.c.c;
- name = tkColor.c;
- path = ../generic/tkColor.c;
- refType = 2;
- sourceTree = SOURCE_ROOT;
- };
- F5375593016C389901DC9062 = {
- fileEncoding = 5;
- isa = PBXFileReference;
- lastKnownFileType = sourcecode.c.c;
- name = tkConfig.c;
- path = ../generic/tkConfig.c;
- refType = 2;
- sourceTree = SOURCE_ROOT;
- };
- F5375594016C389901DC9062 = {
- fileEncoding = 5;
- isa = PBXFileReference;
- lastKnownFileType = sourcecode.c.c;
- name = tkConsole.c;
- path = ../generic/tkConsole.c;
- refType = 2;
- sourceTree = SOURCE_ROOT;
- };
- F5375595016C389901DC9062 = {
- fileEncoding = 5;
- isa = PBXFileReference;
- lastKnownFileType = sourcecode.c.c;
- name = tkCursor.c;
- path = ../generic/tkCursor.c;
- refType = 2;
- sourceTree = SOURCE_ROOT;
- };
- F5375596016C389901DC9062 = {
- fileEncoding = 5;
- isa = PBXFileReference;
- lastKnownFileType = sourcecode.c.c;
- name = tkEntry.c;
- path = ../generic/tkEntry.c;
- refType = 2;
- sourceTree = SOURCE_ROOT;
- };
- F5375597016C389901DC9062 = {
- fileEncoding = 5;
- isa = PBXFileReference;
- lastKnownFileType = sourcecode.c.c;
- name = tkError.c;
- path = ../generic/tkError.c;
- refType = 2;
- sourceTree = SOURCE_ROOT;
- };
- F5375598016C389901DC9062 = {
- fileEncoding = 5;
- isa = PBXFileReference;
- lastKnownFileType = sourcecode.c.c;
- name = tkEvent.c;
- path = ../generic/tkEvent.c;
- refType = 2;
- sourceTree = SOURCE_ROOT;
- };
- F5375599016C389901DC9062 = {
- fileEncoding = 5;
- isa = PBXFileReference;
- lastKnownFileType = sourcecode.c.c;
- name = tkFileFilter.c;
- path = ../generic/tkFileFilter.c;
- refType = 2;
- sourceTree = SOURCE_ROOT;
- };
- F537559A016C389901DC9062 = {
- fileEncoding = 5;
- isa = PBXFileReference;
- lastKnownFileType = sourcecode.c.c;
- name = tkFocus.c;
- path = ../generic/tkFocus.c;
- refType = 2;
- sourceTree = SOURCE_ROOT;
- };
- F537559B016C389901DC9062 = {
- fileEncoding = 5;
- isa = PBXFileReference;
- lastKnownFileType = sourcecode.c.c;
- name = tkFont.c;
- path = ../generic/tkFont.c;
- refType = 2;
- sourceTree = SOURCE_ROOT;
- };
- F537559C016C389901DC9062 = {
- fileEncoding = 5;
- isa = PBXFileReference;
- lastKnownFileType = sourcecode.c.c;
- name = tkFrame.c;
- path = ../generic/tkFrame.c;
- refType = 2;
- sourceTree = SOURCE_ROOT;
- };
- F537559D016C389901DC9062 = {
- fileEncoding = 5;
- isa = PBXFileReference;
- lastKnownFileType = sourcecode.c.c;
- name = tkGC.c;
- path = ../generic/tkGC.c;
- refType = 2;
- sourceTree = SOURCE_ROOT;
- };
- F537559E016C389901DC9062 = {
- fileEncoding = 5;
- isa = PBXFileReference;
- lastKnownFileType = sourcecode.c.c;
- name = tkGeometry.c;
- path = ../generic/tkGeometry.c;
- refType = 2;
- sourceTree = SOURCE_ROOT;
- };
- F537559F016C389901DC9062 = {
- fileEncoding = 5;
- isa = PBXFileReference;
- lastKnownFileType = sourcecode.c.c;
- name = tkGet.c;
- path = ../generic/tkGet.c;
- refType = 2;
- sourceTree = SOURCE_ROOT;
- };
- F53755A0016C389901DC9062 = {
- fileEncoding = 5;
- isa = PBXFileReference;
- lastKnownFileType = sourcecode.c.c;
- name = tkGrab.c;
- path = ../generic/tkGrab.c;
- refType = 2;
- sourceTree = SOURCE_ROOT;
- };
- F53755A1016C389901DC9062 = {
- fileEncoding = 5;
- isa = PBXFileReference;
- lastKnownFileType = sourcecode.c.c;
- name = tkGrid.c;
- path = ../generic/tkGrid.c;
- refType = 2;
- sourceTree = SOURCE_ROOT;
- };
- F53755A2016C389901DC9062 = {
- fileEncoding = 5;
- isa = PBXFileReference;
- lastKnownFileType = sourcecode.c.c;
- name = tkImage.c;
- path = ../generic/tkImage.c;
- refType = 2;
- sourceTree = SOURCE_ROOT;
- };
- F53755A3016C389901DC9062 = {
- fileEncoding = 5;
- isa = PBXFileReference;
- lastKnownFileType = sourcecode.c.c;
- name = tkImgBmap.c;
- path = ../generic/tkImgBmap.c;
- refType = 2;
- sourceTree = SOURCE_ROOT;
- };
- F53755A4016C389901DC9062 = {
- fileEncoding = 5;
- isa = PBXFileReference;
- lastKnownFileType = sourcecode.c.c;
- name = tkImgGIF.c;
- path = ../generic/tkImgGIF.c;
- refType = 2;
- sourceTree = SOURCE_ROOT;
- };
- F53755A5016C389901DC9062 = {
- fileEncoding = 5;
- isa = PBXFileReference;
- lastKnownFileType = sourcecode.c.c;
- name = tkImgPhoto.c;
- path = ../generic/tkImgPhoto.c;
- refType = 2;
- sourceTree = SOURCE_ROOT;
- };
- F53755A6016C389901DC9062 = {
- fileEncoding = 5;
- isa = PBXFileReference;
- lastKnownFileType = sourcecode.c.c;
- name = tkImgPPM.c;
- path = ../generic/tkImgPPM.c;
- refType = 2;
- sourceTree = SOURCE_ROOT;
- };
- F53755A7016C389901DC9062 = {
- fileEncoding = 5;
- isa = PBXFileReference;
- lastKnownFileType = sourcecode.c.c;
- name = tkImgUtil.c;
- path = ../generic/tkImgUtil.c;
- refType = 2;
- sourceTree = SOURCE_ROOT;
- };
- F53755A8016C389901DC9062 = {
- fileEncoding = 5;
- isa = PBXFileReference;
- lastKnownFileType = sourcecode.c.c;
- name = tkListbox.c;
- path = ../generic/tkListbox.c;
- refType = 2;
- sourceTree = SOURCE_ROOT;
- };
- F53755A9016C389901DC9062 = {
- fileEncoding = 5;
- isa = PBXFileReference;
- lastKnownFileType = sourcecode.c.c;
- name = tkMacWinMenu.c;
- path = ../generic/tkMacWinMenu.c;
- refType = 2;
- sourceTree = SOURCE_ROOT;
- };
- F53755AA016C389901DC9062 = {
- fileEncoding = 5;
- isa = PBXFileReference;
- lastKnownFileType = sourcecode.c.c;
- name = tkMain.c;
- path = ../generic/tkMain.c;
- refType = 2;
- sourceTree = SOURCE_ROOT;
- };
- F53755AB016C389901DC9062 = {
- fileEncoding = 5;
- isa = PBXFileReference;
- lastKnownFileType = sourcecode.c.c;
- name = tkMenu.c;
- path = ../generic/tkMenu.c;
- refType = 2;
- sourceTree = SOURCE_ROOT;
- };
- F53755AC016C389901DC9062 = {
- fileEncoding = 5;
- isa = PBXFileReference;
- lastKnownFileType = sourcecode.c.c;
- name = tkMenubutton.c;
- path = ../generic/tkMenubutton.c;
- refType = 2;
- sourceTree = SOURCE_ROOT;
- };
- F53755AD016C389901DC9062 = {
- fileEncoding = 5;
- isa = PBXFileReference;
- lastKnownFileType = sourcecode.c.c;
- name = tkMenuDraw.c;
- path = ../generic/tkMenuDraw.c;
- refType = 2;
- sourceTree = SOURCE_ROOT;
- };
- F53755AE016C389901DC9062 = {
- fileEncoding = 5;
- isa = PBXFileReference;
- lastKnownFileType = sourcecode.c.c;
- name = tkMessage.c;
- path = ../generic/tkMessage.c;
- refType = 2;
- sourceTree = SOURCE_ROOT;
- };
- F53755AF016C389901DC9062 = {
- fileEncoding = 5;
- isa = PBXFileReference;
- lastKnownFileType = sourcecode.c.c;
- name = tkObj.c;
- path = ../generic/tkObj.c;
- refType = 2;
- sourceTree = SOURCE_ROOT;
- };
- F53755B0016C389901DC9062 = {
- fileEncoding = 5;
- isa = PBXFileReference;
- lastKnownFileType = sourcecode.c.c;
- name = tkOldConfig.c;
- path = ../generic/tkOldConfig.c;
- refType = 2;
- sourceTree = SOURCE_ROOT;
- };
- F53755B1016C389901DC9062 = {
- fileEncoding = 5;
- isa = PBXFileReference;
- lastKnownFileType = sourcecode.c.c;
- name = tkOption.c;
- path = ../generic/tkOption.c;
- refType = 2;
- sourceTree = SOURCE_ROOT;
- };
- F53755B2016C389901DC9062 = {
- fileEncoding = 5;
- isa = PBXFileReference;
- lastKnownFileType = sourcecode.c.c;
- name = tkPack.c;
- path = ../generic/tkPack.c;
- refType = 2;
- sourceTree = SOURCE_ROOT;
- };
- F53755B3016C389901DC9062 = {
- fileEncoding = 5;
- isa = PBXFileReference;
- lastKnownFileType = sourcecode.c.c;
- name = tkPlace.c;
- path = ../generic/tkPlace.c;
- refType = 2;
- sourceTree = SOURCE_ROOT;
- };
- F53755B4016C389901DC9062 = {
- fileEncoding = 5;
- isa = PBXFileReference;
- lastKnownFileType = sourcecode.c.c;
- name = tkPointer.c;
- path = ../generic/tkPointer.c;
- refType = 2;
- sourceTree = SOURCE_ROOT;
- };
- F53755B5016C389901DC9062 = {
- fileEncoding = 5;
- isa = PBXFileReference;
- lastKnownFileType = sourcecode.c.c;
- name = tkRectOval.c;
- path = ../generic/tkRectOval.c;
- refType = 2;
- sourceTree = SOURCE_ROOT;
- };
- F53755B6016C389901DC9062 = {
- fileEncoding = 5;
- isa = PBXFileReference;
- lastKnownFileType = sourcecode.c.c;
- name = tkScale.c;
- path = ../generic/tkScale.c;
- refType = 2;
- sourceTree = SOURCE_ROOT;
- };
- F53755B7016C389901DC9062 = {
- fileEncoding = 5;
- isa = PBXFileReference;
- lastKnownFileType = sourcecode.c.c;
- name = tkScrollbar.c;
- path = ../generic/tkScrollbar.c;
- refType = 2;
- sourceTree = SOURCE_ROOT;
- };
- F53755B8016C389901DC9062 = {
- fileEncoding = 5;
- isa = PBXFileReference;
- lastKnownFileType = sourcecode.c.c;
- name = tkSelect.c;
- path = ../generic/tkSelect.c;
- refType = 2;
- sourceTree = SOURCE_ROOT;
- };
- F53755B9016C389901DC9062 = {
- fileEncoding = 5;
- isa = PBXFileReference;
- lastKnownFileType = sourcecode.c.c;
- name = tkStubImg.c;
- path = ../generic/tkStubImg.c;
- refType = 2;
- sourceTree = SOURCE_ROOT;
- };
- F53755BA016C389901DC9062 = {
- fileEncoding = 5;
- isa = PBXFileReference;
- lastKnownFileType = sourcecode.c.c;
- name = tkStubInit.c;
- path = ../generic/tkStubInit.c;
- refType = 2;
- sourceTree = SOURCE_ROOT;
- };
- F53755BB016C389901DC9062 = {
- fileEncoding = 5;
- isa = PBXFileReference;
- lastKnownFileType = sourcecode.c.c;
- name = tkStubLib.c;
- path = ../generic/tkStubLib.c;
- refType = 2;
- sourceTree = SOURCE_ROOT;
- };
- F53755BC016C389901DC9062 = {
- fileEncoding = 5;
- isa = PBXFileReference;
- lastKnownFileType = sourcecode.c.c;
- name = tkTest.c;
- path = ../generic/tkTest.c;
- refType = 2;
- sourceTree = SOURCE_ROOT;
- };
- F53755BD016C389901DC9062 = {
- fileEncoding = 5;
- isa = PBXFileReference;
- lastKnownFileType = sourcecode.c.c;
- name = tkText.c;
- path = ../generic/tkText.c;
- refType = 2;
- sourceTree = SOURCE_ROOT;
- };
- F53755BE016C389901DC9062 = {
- fileEncoding = 5;
- isa = PBXFileReference;
- lastKnownFileType = sourcecode.c.c;
- name = tkTextBTree.c;
- path = ../generic/tkTextBTree.c;
- refType = 2;
- sourceTree = SOURCE_ROOT;
- };
- F53755BF016C389901DC9062 = {
- fileEncoding = 5;
- isa = PBXFileReference;
- lastKnownFileType = sourcecode.c.c;
- name = tkTextDisp.c;
- path = ../generic/tkTextDisp.c;
- refType = 2;
- sourceTree = SOURCE_ROOT;
- };
- F53755C0016C389901DC9062 = {
- fileEncoding = 5;
- isa = PBXFileReference;
- lastKnownFileType = sourcecode.c.c;
- name = tkTextImage.c;
- path = ../generic/tkTextImage.c;
- refType = 2;
- sourceTree = SOURCE_ROOT;
- };
- F53755C1016C389901DC9062 = {
- fileEncoding = 5;
- isa = PBXFileReference;
- lastKnownFileType = sourcecode.c.c;
- name = tkTextIndex.c;
- path = ../generic/tkTextIndex.c;
- refType = 2;
- sourceTree = SOURCE_ROOT;
- };
- F53755C2016C389901DC9062 = {
- fileEncoding = 5;
- isa = PBXFileReference;
- lastKnownFileType = sourcecode.c.c;
- name = tkTextMark.c;
- path = ../generic/tkTextMark.c;
- refType = 2;
- sourceTree = SOURCE_ROOT;
- };
- F53755C3016C389901DC9062 = {
- fileEncoding = 5;
- isa = PBXFileReference;
- lastKnownFileType = sourcecode.c.c;
- name = tkTextTag.c;
- path = ../generic/tkTextTag.c;
- refType = 2;
- sourceTree = SOURCE_ROOT;
- };
- F53755C4016C389901DC9062 = {
- fileEncoding = 5;
- isa = PBXFileReference;
- lastKnownFileType = sourcecode.c.c;
- name = tkTextWind.c;
- path = ../generic/tkTextWind.c;
- refType = 2;
- sourceTree = SOURCE_ROOT;
- };
- F53755C5016C389901DC9062 = {
- fileEncoding = 5;
- isa = PBXFileReference;
- lastKnownFileType = sourcecode.c.c;
- name = tkTrig.c;
- path = ../generic/tkTrig.c;
- refType = 2;
- sourceTree = SOURCE_ROOT;
- };
- F53755C6016C389901DC9062 = {
- fileEncoding = 5;
- isa = PBXFileReference;
- lastKnownFileType = sourcecode.c.c;
- name = tkUtil.c;
- path = ../generic/tkUtil.c;
- refType = 2;
- sourceTree = SOURCE_ROOT;
- };
- F53755C7016C389901DC9062 = {
- fileEncoding = 5;
- isa = PBXFileReference;
- lastKnownFileType = sourcecode.c.c;
- name = tkVisual.c;
- path = ../generic/tkVisual.c;
- refType = 2;
- sourceTree = SOURCE_ROOT;
- };
- F53755C8016C389901DC9062 = {
- fileEncoding = 5;
- isa = PBXFileReference;
- lastKnownFileType = sourcecode.c.c;
- name = tkWindow.c;
- path = ../generic/tkWindow.c;
- refType = 2;
- sourceTree = SOURCE_ROOT;
- };
- F53755C9016C389901DC9062 = {
- children = (
- F5375548016C376E01DC9062,
- F53755CA016C389901DC9062,
- F53755CB016C389901DC9062,
- );
- isa = PBXGroup;
- name = Unix;
- refType = 4;
- sourceTree = "<group>";
- };
- F53755CA016C389901DC9062 = {
- fileEncoding = 5;
- isa = PBXFileReference;
- lastKnownFileType = sourcecode.c.c;
- name = tkUnix3d.c;
- path = ../unix/tkUnix3d.c;
- refType = 2;
- sourceTree = SOURCE_ROOT;
- };
- F53755CB016C389901DC9062 = {
- fileEncoding = 5;
- isa = PBXFileReference;
- lastKnownFileType = sourcecode.c.c;
- name = tkUnixScale.c;
- path = ../unix/tkUnixScale.c;
- refType = 2;
- sourceTree = SOURCE_ROOT;
- };
- F53755CC016C389901DC9062 = {
- children = (
- F53755CD016C389901DC9062,
- F53755D7016C389901DC9062,
- );
- isa = PBXGroup;
- name = "X Emulation";
- refType = 4;
- sourceTree = "<group>";
- };
- F53755CD016C389901DC9062 = {
- children = (
- F53755CE016C389901DC9062,
- F53755CF016C389901DC9062,
- F53755D0016C389901DC9062,
- F53755D1016C389901DC9062,
- F53755D2016C389901DC9062,
- F53755D3016C389901DC9062,
- F53755D4016C389901DC9062,
- F53755D5016C389901DC9062,
- F53755D6016C389901DC9062,
- );
- isa = PBXGroup;
- name = Headers;
- refType = 4;
- sourceTree = "<group>";
- };
- F53755CE016C389901DC9062 = {
- fileEncoding = 5;
- isa = PBXFileReference;
- lastKnownFileType = sourcecode.c.h;
- name = xbytes.h;
- path = ../xlib/xbytes.h;
- refType = 2;
- sourceTree = SOURCE_ROOT;
- };
- F53755CF016C389901DC9062 = {
- fileEncoding = 5;
- isa = PBXFileReference;
- lastKnownFileType = sourcecode.c.h;
- name = cursorfont.h;
- path = ../xlib/X11/cursorfont.h;
- refType = 2;
- sourceTree = SOURCE_ROOT;
- };
- F53755D0016C389901DC9062 = {
- fileEncoding = 5;
- isa = PBXFileReference;
- lastKnownFileType = sourcecode.c.h;
- name = keysym.h;
- path = ../xlib/X11/keysym.h;
- refType = 2;
- sourceTree = SOURCE_ROOT;
- };
- F53755D1016C389901DC9062 = {
- fileEncoding = 5;
- isa = PBXFileReference;
- lastKnownFileType = sourcecode.c.h;
- name = keysymdef.h;
- path = ../xlib/X11/keysymdef.h;
- refType = 2;
- sourceTree = SOURCE_ROOT;
- };
- F53755D2016C389901DC9062 = {
- fileEncoding = 5;
- isa = PBXFileReference;
- lastKnownFileType = sourcecode.c.h;
- name = X.h;
- path = ../xlib/X11/X.h;
- refType = 2;
- sourceTree = SOURCE_ROOT;
- };
- F53755D3016C389901DC9062 = {
- fileEncoding = 5;
- isa = PBXFileReference;
- lastKnownFileType = sourcecode.c.h;
- name = Xatom.h;
- path = ../xlib/X11/Xatom.h;
- refType = 2;
- sourceTree = SOURCE_ROOT;
- };
- F53755D4016C389901DC9062 = {
- fileEncoding = 5;
- isa = PBXFileReference;
- lastKnownFileType = sourcecode.c.h;
- name = Xfuncproto.h;
- path = ../xlib/X11/Xfuncproto.h;
- refType = 2;
- sourceTree = SOURCE_ROOT;
- };
- F53755D5016C389901DC9062 = {
- fileEncoding = 5;
- isa = PBXFileReference;
- lastKnownFileType = sourcecode.c.h;
- name = Xlib.h;
- path = ../xlib/X11/Xlib.h;
- refType = 2;
- sourceTree = SOURCE_ROOT;
- };
- F53755D6016C389901DC9062 = {
- fileEncoding = 5;
- isa = PBXFileReference;
- lastKnownFileType = sourcecode.c.h;
- name = Xutil.h;
- path = ../xlib/X11/Xutil.h;
- refType = 2;
- sourceTree = SOURCE_ROOT;
- };
- F53755D7016C389901DC9062 = {
- children = (
- F53755D8016C389901DC9062,
- F53755D9016C389901DC9062,
- F53755DA016C389901DC9062,
- F53755DB016C389901DC9062,
- F53755DC016C389901DC9062,
- );
- isa = PBXGroup;
- name = Source;
- refType = 4;
- sourceTree = "<group>";
- };
- F53755D8016C389901DC9062 = {
- fileEncoding = 5;
- isa = PBXFileReference;
- lastKnownFileType = sourcecode.c.c;
- name = xcolors.c;
- path = ../xlib/xcolors.c;
- refType = 2;
- sourceTree = SOURCE_ROOT;
- };
- F53755D9016C389901DC9062 = {
- fileEncoding = 5;
- isa = PBXFileReference;
- lastKnownFileType = sourcecode.c.c;
- name = xdraw.c;
- path = ../xlib/xdraw.c;
- refType = 2;
- sourceTree = SOURCE_ROOT;
- };
- F53755DA016C389901DC9062 = {
- fileEncoding = 5;
- isa = PBXFileReference;
- lastKnownFileType = sourcecode.c.c;
- name = xgc.c;
- path = ../xlib/xgc.c;
- refType = 2;
- sourceTree = SOURCE_ROOT;
- };
- F53755DB016C389901DC9062 = {
- fileEncoding = 5;
- isa = PBXFileReference;
- lastKnownFileType = sourcecode.c.c;
- name = ximage.c;
- path = ../xlib/ximage.c;
- refType = 2;
- sourceTree = SOURCE_ROOT;
- };
- F53755DC016C389901DC9062 = {
- fileEncoding = 5;
- isa = PBXFileReference;
- lastKnownFileType = sourcecode.c.c;
- name = xutil.c;
- path = ../xlib/xutil.c;
- refType = 2;
- sourceTree = SOURCE_ROOT;
- };
- F53755DD016C38D201DC9062 = {
- children = (
- F9F6B1C008E863C200C9CB24,
- F9F6B1BF08E863B300C9CB24,
- F9F6B1BE08E8639A00C9CB24,
- );
- isa = PBXGroup;
- name = Products;
- refType = 4;
- sourceTree = "<group>";
- };
- F537567C016C3ADB01DC9062 = {
- children = (
- F5875C7B016FEF1D01DC9062,
- F50D96120196176E01DC9062,
- F537567D016C3ADB01DC9062,
- 95911CC7081532D8006F6BCB,
- );
- isa = PBXGroup;
- name = "External Frameworks";
- refType = 4;
- sourceTree = "<group>";
- };
- F537567D016C3ADB01DC9062 = {
- isa = PBXFileReference;
- lastKnownFileType = wrapper.framework;
- name = Carbon.framework;
- path = /System/Library/Frameworks/Carbon.framework;
- refType = 0;
- sourceTree = "<absolute>";
- };
- F5375688016C3F1001DC9062 = {
- children = (
- F5375689016C3F1001DC9062,
- F537568A016C3F1001DC9062,
- F537568B016C3F1001DC9062,
- F537568C016C3F1001DC9062,
- F537568D016C3F1001DC9062,
- F537568E016C3F1001DC9062,
- F537568F016C3F1001DC9062,
- F5375690016C3F1001DC9062,
- F5375691016C3F1001DC9062,
- F5375692016C3F1001DC9062,
- );
- isa = PBXGroup;
- name = Bitmaps;
- refType = 4;
- sourceTree = "<group>";
- };
- F5375689016C3F1001DC9062 = {
- isa = PBXFileReference;
- lastKnownFileType = image.bmp;
- name = error.xbm;
- path = ../bitmaps/error.xbm;
- refType = 2;
- sourceTree = SOURCE_ROOT;
- };
- F537568A016C3F1001DC9062 = {
- isa = PBXFileReference;
- lastKnownFileType = image.bmp;
- name = gray12.xbm;
- path = ../bitmaps/gray12.xbm;
- refType = 2;
- sourceTree = SOURCE_ROOT;
- };
- F537568B016C3F1001DC9062 = {
- isa = PBXFileReference;
- lastKnownFileType = image.bmp;
- name = gray25.xbm;
- path = ../bitmaps/gray25.xbm;
- refType = 2;
- sourceTree = SOURCE_ROOT;
- };
- F537568C016C3F1001DC9062 = {
- isa = PBXFileReference;
- lastKnownFileType = image.bmp;
- name = gray50.xbm;
- path = ../bitmaps/gray50.xbm;
- refType = 2;
- sourceTree = SOURCE_ROOT;
- };
- F537568D016C3F1001DC9062 = {
- isa = PBXFileReference;
- lastKnownFileType = image.bmp;
- name = gray75.xbm;
- path = ../bitmaps/gray75.xbm;
- refType = 2;
- sourceTree = SOURCE_ROOT;
- };
- F537568E016C3F1001DC9062 = {
- isa = PBXFileReference;
- lastKnownFileType = image.bmp;
- name = hourglass.xbm;
- path = ../bitmaps/hourglass.xbm;
- refType = 2;
- sourceTree = SOURCE_ROOT;
- };
- F537568F016C3F1001DC9062 = {
- isa = PBXFileReference;
- lastKnownFileType = image.bmp;
- name = info.xbm;
- path = ../bitmaps/info.xbm;
- refType = 2;
- sourceTree = SOURCE_ROOT;
- };
- F5375690016C3F1001DC9062 = {
- isa = PBXFileReference;
- lastKnownFileType = image.bmp;
- name = questhead.xbm;
- path = ../bitmaps/questhead.xbm;
- refType = 2;
- sourceTree = SOURCE_ROOT;
- };
- F5375691016C3F1001DC9062 = {
- isa = PBXFileReference;
- lastKnownFileType = image.bmp;
- name = question.xbm;
- path = ../bitmaps/question.xbm;
- refType = 2;
- sourceTree = SOURCE_ROOT;
- };
- F5375692016C3F1001DC9062 = {
- isa = PBXFileReference;
- lastKnownFileType = image.bmp;
- name = warning.xbm;
- path = ../bitmaps/warning.xbm;
- refType = 2;
- sourceTree = SOURCE_ROOT;
- };
- F55BC46802B2D38B01DC9062 = {
- fileEncoding = 5;
- isa = PBXFileReference;
- lastKnownFileType = sourcecode.c.c;
- name = tkPanedWindow.c;
- path = ../generic/tkPanedWindow.c;
- refType = 2;
- sourceTree = SOURCE_ROOT;
- };
- F55BC46A02B2D3F301DC9062 = {
- isa = PBXFileReference;
- lastKnownFileType = text;
- name = panedwindow.tcl;
- path = ../library/panedwindow.tcl;
- refType = 2;
- sourceTree = SOURCE_ROOT;
- };
- F5875C7B016FEF1D01DC9062 = {
- isa = PBXFileReference;
- lastKnownFileType = wrapper.framework;
- name = Tcl.framework;
- path = ../tcl/Tcl.framework;
- refType = 3;
- sourceTree = BUILT_PRODUCTS_DIR;
- };
- F5BFE58B02F8C41501DC9062 = {
- fileEncoding = 5;
- isa = PBXFileReference;
- lastKnownFileType = sourcecode.c.c;
- name = tkStyle.c;
- path = ../generic/tkStyle.c;
- refType = 2;
- sourceTree = SOURCE_ROOT;
- };
- F5BFE58C02F8C41501DC9062 = {
- fileEncoding = 5;
- isa = PBXFileReference;
- lastKnownFileType = sourcecode.c.c;
- name = tkUndo.c;
- path = ../generic/tkUndo.c;
- refType = 2;
- sourceTree = SOURCE_ROOT;
- };
- F5BFE58F02F8C45B01DC9062 = {
- fileEncoding = 5;
- isa = PBXFileReference;
- lastKnownFileType = sourcecode.c.h;
- name = tkUndo.h;
- path = ../generic/tkUndo.h;
- refType = 2;
- sourceTree = SOURCE_ROOT;
- };
- F5C2EA33034D71B2016F146B = {
- isa = PBXFileReference;
- lastKnownFileType = text;
- name = mkpsenc.tcl;
- path = ../library/mkpsenc.tcl;
- refType = 2;
- sourceTree = SOURCE_ROOT;
- };
- F5C88659017D625C01DC9062 = {
- children = (
- F5C8865A017D625C01DC9062,
- F5C8865B017D625C01DC9062,
- );
- isa = PBXGroup;
- name = "Header Tools";
- refType = 4;
- sourceTree = "<group>";
- };
- F5C8865A017D625C01DC9062 = {
- isa = PBXFileReference;
- lastKnownFileType = text;
- name = tk.decls;
- path = ../generic/tk.decls;
- refType = 2;
- sourceTree = SOURCE_ROOT;
- };
- F5C8865B017D625C01DC9062 = {
- isa = PBXFileReference;
- lastKnownFileType = text;
- name = tkInt.decls;
- path = ../generic/tkInt.decls;
- refType = 2;
- sourceTree = SOURCE_ROOT;
- };
- F5DF07A7016CD03801DC9062 = {
- children = (
- F5DF0928016CD3F901DC9062,
- F5DF0929016CD3F901DC9062,
- F5DF092A016CD3F901DC9062,
- F5DF092B016CD3F901DC9062,
- F5DF092C016CD3F901DC9062,
- F5DF092D016CD3F901DC9062,
- F5DF092E016CD3F901DC9062,
- F5DF092F016CD3F901DC9062,
- F5DF0930016CD3F901DC9062,
- F5DF0931016CD3F901DC9062,
- F5DF0932016CD3F901DC9062,
- F5DF0933016CD3F901DC9062,
- F5DF0934016CD3F901DC9062,
- F5C2EA33034D71B2016F146B,
- F5DF0935016CD3F901DC9062,
- F5DF0936016CD3F901DC9062,
- F5DF0937016CD3F901DC9062,
- F5DF0938016CD3F901DC9062,
- F5DF0939016CD3F901DC9062,
- F55BC46A02B2D3F301DC9062,
- F5DF093A016CD3F901DC9062,
- F5DF093B016CD3F901DC9062,
- F5DF093C016CD3F901DC9062,
- F5DF093D016CD3F901DC9062,
- F5DF093E016CD3F901DC9062,
- F5DF093F016CD3F901DC9062,
- F5DF0940016CD3F901DC9062,
- F5DF0941016CD3F901DC9062,
- F5DF0942016CD3F901DC9062,
- F5DF0943016CD3F901DC9062,
- F5DF0944016CD3F901DC9062,
- F5DF0945016CD3F901DC9062,
- );
- isa = PBXGroup;
- name = Scripts;
- refType = 4;
- sourceTree = "<group>";
- };
- F5DF0928016CD3F901DC9062 = {
- isa = PBXFileReference;
- lastKnownFileType = text;
- name = bgerror.tcl;
- path = ../library/bgerror.tcl;
- refType = 2;
- sourceTree = SOURCE_ROOT;
- };
- F5DF0929016CD3F901DC9062 = {
- isa = PBXFileReference;
- lastKnownFileType = text;
- name = button.tcl;
- path = ../library/button.tcl;
- refType = 2;
- sourceTree = SOURCE_ROOT;
- };
- F5DF092A016CD3F901DC9062 = {
- isa = PBXFileReference;
- lastKnownFileType = text;
- name = choosedir.tcl;
- path = ../library/choosedir.tcl;
- refType = 2;
- sourceTree = SOURCE_ROOT;
- };
- F5DF092B016CD3F901DC9062 = {
- isa = PBXFileReference;
- lastKnownFileType = text;
- name = clrpick.tcl;
- path = ../library/clrpick.tcl;
- refType = 2;
- sourceTree = SOURCE_ROOT;
- };
- F5DF092C016CD3F901DC9062 = {
- isa = PBXFileReference;
- lastKnownFileType = text;
- name = comdlg.tcl;
- path = ../library/comdlg.tcl;
- refType = 2;
- sourceTree = SOURCE_ROOT;
- };
- F5DF092D016CD3F901DC9062 = {
- isa = PBXFileReference;
- lastKnownFileType = text;
- name = console.tcl;
- path = ../library/console.tcl;
- refType = 2;
- sourceTree = SOURCE_ROOT;
- };
- F5DF092E016CD3F901DC9062 = {
- includeInIndex = 0;
- isa = PBXFileReference;
- lastKnownFileType = folder;
- name = demos;
- path = ../library/demos;
- refType = 2;
- sourceTree = SOURCE_ROOT;
- };
- F5DF092F016CD3F901DC9062 = {
- isa = PBXFileReference;
- lastKnownFileType = text;
- name = dialog.tcl;
- path = ../library/dialog.tcl;
- refType = 2;
- sourceTree = SOURCE_ROOT;
- };
- F5DF0930016CD3F901DC9062 = {
- isa = PBXFileReference;
- lastKnownFileType = text;
- name = entry.tcl;
- path = ../library/entry.tcl;
- refType = 2;
- sourceTree = SOURCE_ROOT;
- };
- F5DF0931016CD3F901DC9062 = {
- isa = PBXFileReference;
- lastKnownFileType = text;
- name = focus.tcl;
- path = ../library/focus.tcl;
- refType = 2;
- sourceTree = SOURCE_ROOT;
- };
- F5DF0932016CD3F901DC9062 = {
- includeInIndex = 0;
- isa = PBXFileReference;
- lastKnownFileType = folder;
- name = images;
- path = ../library/images;
- refType = 2;
- sourceTree = SOURCE_ROOT;
- };
- F5DF0933016CD3F901DC9062 = {
- isa = PBXFileReference;
- lastKnownFileType = text;
- name = listbox.tcl;
- path = ../library/listbox.tcl;
- refType = 2;
- sourceTree = SOURCE_ROOT;
- };
- F5DF0934016CD3F901DC9062 = {
- isa = PBXFileReference;
- lastKnownFileType = text;
- name = menu.tcl;
- path = ../library/menu.tcl;
- refType = 2;
- sourceTree = SOURCE_ROOT;
- };
- F5DF0935016CD3F901DC9062 = {
- isa = PBXFileReference;
- lastKnownFileType = text;
- name = msgbox.tcl;
- path = ../library/msgbox.tcl;
- refType = 2;
- sourceTree = SOURCE_ROOT;
- };
- F5DF0936016CD3F901DC9062 = {
- includeInIndex = 0;
- isa = PBXFileReference;
- lastKnownFileType = folder;
- name = msgs;
- path = ../library/msgs;
- refType = 2;
- sourceTree = SOURCE_ROOT;
- };
- F5DF0937016CD3F901DC9062 = {
- isa = PBXFileReference;
- lastKnownFileType = text;
- name = obsolete.tcl;
- path = ../library/obsolete.tcl;
- refType = 2;
- sourceTree = SOURCE_ROOT;
- };
- F5DF0938016CD3F901DC9062 = {
- isa = PBXFileReference;
- lastKnownFileType = text;
- name = optMenu.tcl;
- path = ../library/optMenu.tcl;
- refType = 2;
- sourceTree = SOURCE_ROOT;
- };
- F5DF0939016CD3F901DC9062 = {
- isa = PBXFileReference;
- lastKnownFileType = text;
- name = palette.tcl;
- path = ../library/palette.tcl;
- refType = 2;
- sourceTree = SOURCE_ROOT;
- };
- F5DF093A016CD3F901DC9062 = {
- isa = PBXFileReference;
- lastKnownFileType = text;
- name = prolog.ps;
- path = ../generic/prolog.ps;
- refType = 2;
- sourceTree = SOURCE_ROOT;
- };
- F5DF093B016CD3F901DC9062 = {
- isa = PBXFileReference;
- lastKnownFileType = text;
- name = safetk.tcl;
- path = ../library/safetk.tcl;
- refType = 2;
- sourceTree = SOURCE_ROOT;
- };
- F5DF093C016CD3F901DC9062 = {
- isa = PBXFileReference;
- lastKnownFileType = text;
- name = scale.tcl;
- path = ../library/scale.tcl;
- refType = 2;
- sourceTree = SOURCE_ROOT;
- };
- F5DF093D016CD3F901DC9062 = {
- isa = PBXFileReference;
- lastKnownFileType = text;
- name = scrlbar.tcl;
- path = ../library/scrlbar.tcl;
- refType = 2;
- sourceTree = SOURCE_ROOT;
- };
- F5DF093E016CD3F901DC9062 = {
- isa = PBXFileReference;
- lastKnownFileType = text;
- name = spinbox.tcl;
- path = ../library/spinbox.tcl;
- refType = 2;
- sourceTree = SOURCE_ROOT;
- };
- F5DF093F016CD3F901DC9062 = {
- fileEncoding = 5;
- isa = PBXFileReference;
- lastKnownFileType = text;
- name = tclIndex;
- path = ../library/tclIndex;
- refType = 2;
- sourceTree = SOURCE_ROOT;
- };
- F5DF0940016CD3F901DC9062 = {
- isa = PBXFileReference;
- lastKnownFileType = text;
- name = tearoff.tcl;
- path = ../library/tearoff.tcl;
- refType = 2;
- sourceTree = SOURCE_ROOT;
- };
- F5DF0941016CD3F901DC9062 = {
- isa = PBXFileReference;
- lastKnownFileType = text;
- name = text.tcl;
- path = ../library/text.tcl;
- refType = 2;
- sourceTree = SOURCE_ROOT;
- };
- F5DF0942016CD3F901DC9062 = {
- isa = PBXFileReference;
- lastKnownFileType = text;
- name = tk.tcl;
- path = ../library/tk.tcl;
- refType = 2;
- sourceTree = SOURCE_ROOT;
- };
- F5DF0943016CD3F901DC9062 = {
- isa = PBXFileReference;
- lastKnownFileType = text;
- name = tkfbox.tcl;
- path = ../library/tkfbox.tcl;
- refType = 2;
- sourceTree = SOURCE_ROOT;
- };
- F5DF0944016CD3F901DC9062 = {
- isa = PBXFileReference;
- lastKnownFileType = text;
- name = unsupported.tcl;
- path = ../library/unsupported.tcl;
- refType = 2;
- sourceTree = SOURCE_ROOT;
- };
- F5DF0945016CD3F901DC9062 = {
- isa = PBXFileReference;
- lastKnownFileType = text;
- name = xmfbox.tcl;
- path = ../library/xmfbox.tcl;
- refType = 2;
- sourceTree = SOURCE_ROOT;
- };
-//F50
-//F51
-//F52
-//F53
-//F54
-//F90
-//F91
-//F92
-//F93
-//F94
- F92ED9910403D0F0006F146B = {
- fileEncoding = 5;
- isa = PBXFileReference;
- lastKnownFileType = text;
- name = ChangeLog;
- path = ../ChangeLog;
- refType = 2;
- sourceTree = SOURCE_ROOT;
- };
- F9D6747B08E84DC100688CAA = {
- buildArgumentsString = "-c \"cd \\\"${TK_SRCROOT}/macosx\\\" && ACTION=${ACTION} && CFLAGS=\\\"${CFLAGS}\\\" gnumake \\${ACTION:+\\${ACTION/clean/distclean}-}${MAKE_TARGET} INSTALL_ROOT=\\\"${DSTROOT}\\\" INSTALL_PATH=\\\"${INSTALL_PATH}\\\" PREFIX=\\\"${PREFIX}\\\" BINDIR=\\\"${BINDIR}\\\" MANDIR=\\\"${MANDIR}\\\" TCL_BUILD_DIR=\\\"${TCL_BUILD_DIR}\\\" APPLICATION_INSTALL_PATH=\\\"${APPLICATION_INSTALL_PATH}\\\" \\${EXTRA_MAKE_FLAGS} ${ALL_SETTINGS}\"";
- buildPhases = (
- );
- buildSettings = {
- APPLICATION_INSTALL_PATH = /Applications/Utilities;
- BINDIR = "${PREFIX}/bin";
- CFLAGS = "";
- INSTALL_PATH = /Library/Frameworks;
- MANDIR = "${PREFIX}/man";
- PREFIX = /usr/local;
- PRODUCT_NAME = Tk;
- TCL_BUILD_DIR = "${SYMROOT}/../tcl/${BUILD_STYLE}";
- TCL_SRCROOT = "${SRCROOT}/../../tcl";
- TEMP_DIR = "${PROJECT_TEMP_DIR}";
- TK_SRCROOT = "${SRCROOT}/../../tk";
- };
- buildToolPath = /bin/bash;
- buildWorkingDirectory = "${SRCROOT}";
- dependencies = (
- );
- isa = PBXLegacyTarget;
- name = Tk;
- passBuildSettingsInEnvironment = 0;
- productName = Tk;
- };
- F9F6B1BE08E8639A00C9CB24 = {
- isa = PBXFileReference;
- lastKnownFileType = wrapper.framework;
- path = Tk.framework;
- refType = 3;
- sourceTree = BUILT_PRODUCTS_DIR;
- };
- F9F6B1BF08E863B300C9CB24 = {
- isa = PBXFileReference;
- lastKnownFileType = wrapper.application;
- path = Wish.app;
- refType = 3;
- sourceTree = BUILT_PRODUCTS_DIR;
- };
- F9F6B1C008E863C200C9CB24 = {
- isa = PBXFileReference;
- lastKnownFileType = "compiled.mach-o.executable";
- path = tktest;
- refType = 3;
- sourceTree = BUILT_PRODUCTS_DIR;
- };
- };
- rootObject = F537552A016C352C01DC9062;
-}
diff --git a/macosx/Wish.sdef b/macosx/Wish.sdef
new file mode 100644
index 0000000..d9de8bd
--- /dev/null
+++ b/macosx/Wish.sdef
@@ -0,0 +1,39 @@
+<?xml version="1.0" encoding="UTF-8"?>
+<!DOCTYPE dictionary SYSTEM "file://localhost/System/Library/DTDs/sdef.dtd">
+<!--
+ Copyright (c) 1997 Sun Microsystems, Inc.
+ Copyright 2009 Kevin Walzer/WordTech Communications LLC.
+ Copyright (c) 2009 Daniel A. Steffen <das@users.sourceforge.net>
+
+ See the file "license.terms" for information on usage and redistribution of
+ this file, and for a DISCLAIMER OF ALL WARRANTIES.
+
+ RCS: @(#) $Id$
+-->
+<dictionary title="Wish Terminology">
+ <suite name="Standard Suite" code="reqd" description="Common commands for all applications.">
+ <command name="open" code="aevtodoc" description="Open a document.">
+ <direct-parameter description="The file(s) to be opened.">
+ <type type="file"/>
+ <type type="file" list="yes"/>
+ </direct-parameter>
+ </command>
+ <command name="print" code="aevtpdoc" description="Print a document.">
+ <direct-parameter description="The file(s) to be printed.">
+ <type type="file" list="yes"/>
+ <type type="specifier"/>
+ </direct-parameter>
+ </command>
+ <command name="quit" code="aevtquit" description="Quit the application."/>
+ </suite>
+ <suite name="Wish Suite" code="WIsH" description="Commands for the Wish application.">
+ <command name="do script" code="miscdosc" description="Execute a Tcl script.">
+ <direct-parameter description="Script to execute" type="text">
+ <type type="text"/>
+ </direct-parameter>
+ <result description="Result">
+ <type type="text"/>
+ </result>
+ </command>
+ </suite>
+</dictionary>
diff --git a/macosx/Wish.xcode/default.pbxuser b/macosx/Wish.xcode/default.pbxuser
index c832f6b..188bbeb 100644
--- a/macosx/Wish.xcode/default.pbxuser
+++ b/macosx/Wish.xcode/default.pbxuser
@@ -11,11 +11,11 @@
F9FD31F50CC1AD070073837D /* tktest-X11 */,
);
perUserDictionary = {
- com.apple.ide.smrt.PBXUserSmartGroupsKey.Rev10 = <040b747970656473747265616d8103e88401408484840e4e534d757461626c654172726179008484074e534172726179008484084e534f626a65637400858401690192848484134e534d757461626c6544696374696f6e6172790084840c4e5344696374696f6e6172790095960792848484084e53537472696e67019584012b146162736f6c75746550617468546f42756e646c658692849a9a008692849a9a046e616d658692849a9a14496d706c656d656e746174696f6e2046696c65738692849a9a03636c7a8692849a9a1550425846696c656e616d65536d61727447726f75708692849a9a0b6465736372697074696f6e8692849a9a103c6e6f206465736372697074696f6e3e8692849a9a08676c6f62616c49448692849a9a183143433045413430303433353045463930303434343130428692849a9a195042585472616e7369656e744c6f636174696f6e4174546f708692849a9a06626f74746f6d8692849a9a0b707265666572656e63657386928497960892849a9a1250425850726f6a65637453636f70654b65798692849a9a035945538692849a9a05696d6167658692849a9a0b536d617274466f6c6465728692849a9a0763616e536176658692848484084e534e756d626572008484074e5356616c7565009584012a849696018692849a9a0572656765788692849a9a065c2e286329248692849a9a04726f6f748692849a9a093c50524f4a4543543e8692849a9a097265637572736976658692ad92849a9a0669734c656166869284ae9db096008692849a9a07666e6d617463688692849a9a0086868686>;
+ com.apple.ide.smrt.PBXUserSmartGroupsKey.Rev10 = <040b73747265616d747970656481e8038401408484840e4e534d757461626c654172726179008484074e534172726179008484084e534f626a65637400858401690192848484134e534d757461626c6544696374696f6e6172790084840c4e5344696374696f6e6172790095960792848484084e53537472696e67019584012b046e616d658692849a9a14496d706c656d656e746174696f6e2046696c65738692849a9a146162736f6c75746550617468546f42756e646c658692849a9a008692849a9a195042585472616e7369656e744c6f636174696f6e4174546f708692849a9a06626f74746f6d8692849a9a03636c7a8692849a9a1550425846696c656e616d65536d61727447726f75708692849a9a0b6465736372697074696f6e8692849a9a103c6e6f206465736372697074696f6e3e8692849a9a0b707265666572656e63657386928497960892849a9a07666e6d617463688692849a9a008692849a9a05696d6167658692849a9a0b536d617274466f6c6465728692849a9a04726f6f748692849a9a093c50524f4a4543543e8692849a9a0572656765788692849a9a065c2e286329248692849a9a097265637572736976658692848484084e534e756d626572008484074e5356616c7565009584012a849696018692849a9a0669734c656166869284b09db296008692849a9a0763616e536176658692af92849a9a1250425850726f6a65637453636f70654b65798692849a9a03594553868692849a9a08676c6f62616c49448692849a9a18314343304541343030343335304546393030343434313042868686>;
};
sourceControlManager = F944EB9C08F798180049FDD4 /* Source Control */;
userBuildSettings = {
- GCC = "${DEVELOPER_DIR}/usr/bin/gcc";
+ CODE_SIGN_IDENTITY = "";
SYMROOT = "${SRCROOT}/../../build/tk";
TCL_SRCROOT = "${SRCROOT}/../../tcl";
TK_SRCROOT = "${SRCROOT}/../../tk";
@@ -29,7 +29,6 @@
};
F944EB8F08F798100049FDD4 /* tktest */ = {
isa = PBXExecutable;
- activeArgIndex = 0;
activeArgIndices = (
YES,
NO,
@@ -49,6 +48,7 @@
"-skip window-2.9",
);
autoAttachOnCrash = 1;
+ breakpointsEnabled = 1;
configStateDict = {
"PBXLSLaunchAction-0" = {
PBXLSLaunchAction = 0;
@@ -95,6 +95,11 @@
value = /Library/Tcl;
},
{
+ active = YES;
+ name = TK_SRCROOT;
+ value = "${TK_SRCROOT}";
+ },
+ {
active = NO;
name = DYLD_PRINT_LIBRARIES;
},
@@ -148,7 +153,7 @@
scmConfiguration = {
CVSToolPath = /usr/bin/cvs;
CVSUseSSH = NO;
- SubversionToolPath = /usr/local/bin/svn;
+ SubversionToolPath = /usr/bin/svn;
};
scmType = scm.cvs;
};
@@ -164,7 +169,6 @@
};
F9E61D1C090A4282002B3151 /* Wish */ = {
isa = PBXExecutable;
- activeArgIndex = 0;
activeArgIndices = (
YES,
);
@@ -172,6 +176,7 @@
"${TK_SRCROOT}/library/demos/widget",
);
autoAttachOnCrash = 1;
+ breakpointsEnabled = 1;
configStateDict = {
"PBXLSLaunchAction-0" = {
PBXLSLaunchAction = 0;
@@ -222,7 +227,6 @@
};
F9FD31F50CC1AD070073837D /* tktest-X11 */ = {
isa = PBXExecutable;
- activeArgIndex = 0;
activeArgIndices = (
YES,
NO,
@@ -242,6 +246,7 @@
"-skip window-2.9",
);
autoAttachOnCrash = 1;
+ breakpointsEnabled = 1;
configStateDict = {
"PBXLSLaunchAction-0" = {
PBXLSLaunchAction = 0;
diff --git a/macosx/Wish.xcode/project.pbxproj b/macosx/Wish.xcode/project.pbxproj
index 24c0a82..d553ba0 100644
--- a/macosx/Wish.xcode/project.pbxproj
+++ b/macosx/Wish.xcode/project.pbxproj
@@ -3,11 +3,12 @@
archiveVersion = 1;
classes = {
};
- objectVersion = 42;
+ objectVersion = 45;
objects = {
/* Begin PBXBuildFile section */
F9067BCD0BFBA2900074F726 /* tkOldTest.c in Sources */ = {isa = PBXBuildFile; fileRef = F966BAFE08F27A39005CB29B /* tkOldTest.c */; };
+ F94523A20E6FC2AC00C1D987 /* Cocoa.framework in Frameworks */ = {isa = PBXBuildFile; fileRef = F94523A10E6FC2AC00C1D987 /* Cocoa.framework */; };
F966BDCF08F27A3F005CB29B /* tk3d.c in Sources */ = {isa = PBXBuildFile; fileRef = F966BAAC08F27A39005CB29B /* tk3d.c */; };
F966BDD108F27A3F005CB29B /* tkArgv.c in Sources */ = {isa = PBXBuildFile; fileRef = F966BAAE08F27A39005CB29B /* tkArgv.c */; };
F966BDD208F27A3F005CB29B /* tkAtom.c in Sources */ = {isa = PBXBuildFile; fileRef = F966BAAF08F27A39005CB29B /* tkAtom.c */; };
@@ -85,7 +86,6 @@
F966BE3508F27A40005CB29B /* tkWindow.c in Sources */ = {isa = PBXBuildFile; fileRef = F966BB1208F27A39005CB29B /* tkWindow.c */; };
F966BEDB08F27A40005CB29B /* tkMacOSXBitmap.c in Sources */ = {isa = PBXBuildFile; fileRef = F966BBC508F27A3B005CB29B /* tkMacOSXBitmap.c */; };
F966BEDC08F27A40005CB29B /* tkMacOSXButton.c in Sources */ = {isa = PBXBuildFile; fileRef = F966BBC608F27A3B005CB29B /* tkMacOSXButton.c */; };
- F966BEDD08F27A40005CB29B /* tkMacOSXCarbonEvents.c in Sources */ = {isa = PBXBuildFile; fileRef = F966BBC708F27A3B005CB29B /* tkMacOSXCarbonEvents.c */; };
F966BEDE08F27A40005CB29B /* tkMacOSXClipboard.c in Sources */ = {isa = PBXBuildFile; fileRef = F966BBC808F27A3B005CB29B /* tkMacOSXClipboard.c */; };
F966BEDF08F27A40005CB29B /* tkMacOSXColor.c in Sources */ = {isa = PBXBuildFile; fileRef = F966BBC908F27A3B005CB29B /* tkMacOSXColor.c */; };
F966BEE008F27A40005CB29B /* tkMacOSXConfig.c in Sources */ = {isa = PBXBuildFile; fileRef = F966BBCA08F27A3B005CB29B /* tkMacOSXConfig.c */; };
@@ -281,7 +281,7 @@
F96D49A908F272C4004A47F5 /* tclMacOSXBundle.c in Sources */ = {isa = PBXBuildFile; fileRef = F96D433908F272B5004A47F5 /* tclMacOSXBundle.c */; };
F96D49AD08F272C4004A47F5 /* tclMacOSXFCmd.c in Sources */ = {isa = PBXBuildFile; fileRef = F96D433D08F272B5004A47F5 /* tclMacOSXFCmd.c */; };
F96D49AE08F272C4004A47F5 /* tclMacOSXNotify.c in Sources */ = {isa = PBXBuildFile; fileRef = F96D433E08F272B5004A47F5 /* tclMacOSXNotify.c */; };
- F96D4AC608F272C9004A47F5 /* tclLoadDyld.c in Sources */ = {isa = PBXBuildFile; fileRef = F96D445B08F272B9004A47F5 /* tclLoadDyld.c */; };
+ F96D4AC608F272C9004A47F5 /* tclLoadDyld.c in Sources */ = {isa = PBXBuildFile; fileRef = F96D445B08F272B9004A47F5 /* tclLoadDyld.c */; settings = {COMPILER_FLAGS = "-Wno-deprecated-declarations"; }; };
F96D4ACA08F272C9004A47F5 /* tclUnixChan.c in Sources */ = {isa = PBXBuildFile; fileRef = F96D445F08F272B9004A47F5 /* tclUnixChan.c */; };
F96D4ACB08F272C9004A47F5 /* tclUnixEvent.c in Sources */ = {isa = PBXBuildFile; fileRef = F96D446008F272B9004A47F5 /* tclUnixEvent.c */; };
F96D4ACC08F272C9004A47F5 /* tclUnixFCmd.c in Sources */ = {isa = PBXBuildFile; fileRef = F96D446108F272B9004A47F5 /* tclUnixFCmd.c */; };
@@ -292,6 +292,7 @@
F96D4AD208F272CA004A47F5 /* tclUnixSock.c in Sources */ = {isa = PBXBuildFile; fileRef = F96D446708F272B9004A47F5 /* tclUnixSock.c */; };
F96D4AD408F272CA004A47F5 /* tclUnixThrd.c in Sources */ = {isa = PBXBuildFile; fileRef = F96D446908F272B9004A47F5 /* tclUnixThrd.c */; };
F96D4AD608F272CA004A47F5 /* tclUnixTime.c in Sources */ = {isa = PBXBuildFile; fileRef = F96D446B08F272B9004A47F5 /* tclUnixTime.c */; };
+ F9C9CC000E84059800E00935 /* ApplicationServices.framework in Frameworks */ = {isa = PBXBuildFile; fileRef = F9C9CBFF0E84059800E00935 /* ApplicationServices.framework */; };
F9E61D28090A481F002B3151 /* bn_mp_cmp_d.c in Sources */ = {isa = PBXBuildFile; fileRef = F96D427108F272B3004A47F5 /* bn_mp_cmp_d.c */; };
F9E61D29090A486C002B3151 /* bn_mp_neg.c in Sources */ = {isa = PBXBuildFile; fileRef = F96D42A208F272B3004A47F5 /* bn_mp_neg.c */; };
F9E61D2A090A4891002B3151 /* bn_mp_sqrt.c in Sources */ = {isa = PBXBuildFile; fileRef = F96D42C008F272B3004A47F5 /* bn_mp_sqrt.c */; };
@@ -303,10 +304,7 @@
F9E61D30090A48E2002B3151 /* bn_mp_to_unsigned_bin_n.c in Sources */ = {isa = PBXBuildFile; fileRef = F96D42C708F272B3004A47F5 /* bn_mp_to_unsigned_bin_n.c */; };
F9E61D31090A48F9002B3151 /* bn_mp_to_unsigned_bin.c in Sources */ = {isa = PBXBuildFile; fileRef = F96D42C608F272B3004A47F5 /* bn_mp_to_unsigned_bin.c */; };
F9E61D32090A48FA002B3151 /* bn_mp_unsigned_bin_size.c in Sources */ = {isa = PBXBuildFile; fileRef = F96D42CC08F272B3004A47F5 /* bn_mp_unsigned_bin_size.c */; };
- F9EA4AF008FA3BD500B1F5F0 /* tkMacOSXXCursors.r in Rez */ = {isa = PBXBuildFile; fileRef = F966BBF408F27A3C005CB29B /* tkMacOSXXCursors.r */; };
- F9EA4AF208FA3BD800B1F5F0 /* tkMacOSXCursors.r in Rez */ = {isa = PBXBuildFile; fileRef = F966BBCC08F27A3B005CB29B /* tkMacOSXCursors.r */; };
- F9EA4AF308FA3BDA00B1F5F0 /* tkMacOSXAETE.r in Rez */ = {isa = PBXBuildFile; fileRef = F966BBC408F27A3B005CB29B /* tkMacOSXAETE.r */; };
- F9EA4AF408FA3BDB00B1F5F0 /* tkAboutDlg.r in Rez */ = {isa = PBXBuildFile; fileRef = F966BBC108F27A3B005CB29B /* tkAboutDlg.r */; };
+ F9F4415E0C8BAE6F00BCCD67 /* tclDTrace.d in Sources */ = {isa = PBXBuildFile; fileRef = F9F4415D0C8BAE6F00BCCD67 /* tclDTrace.d */; };
F9FC77B80AB29E9100B7077D /* tclUnixCompat.c in Sources */ = {isa = PBXBuildFile; fileRef = F9FC77B70AB29E9100B7077D /* tclUnixCompat.c */; };
F9FD30BC0CC1AD070073837D /* regcomp.c in Sources */ = {isa = PBXBuildFile; fileRef = F96D3ED008F272A7004A47F5 /* regcomp.c */; };
F9FD30BD0CC1AD070073837D /* regerror.c in Sources */ = {isa = PBXBuildFile; fileRef = F96D3ED308F272A7004A47F5 /* regerror.c */; };
@@ -443,7 +441,7 @@
F9FD31400CC1AD070073837D /* tclMacOSXBundle.c in Sources */ = {isa = PBXBuildFile; fileRef = F96D433908F272B5004A47F5 /* tclMacOSXBundle.c */; };
F9FD31410CC1AD070073837D /* tclMacOSXFCmd.c in Sources */ = {isa = PBXBuildFile; fileRef = F96D433D08F272B5004A47F5 /* tclMacOSXFCmd.c */; };
F9FD31420CC1AD070073837D /* tclMacOSXNotify.c in Sources */ = {isa = PBXBuildFile; fileRef = F96D433E08F272B5004A47F5 /* tclMacOSXNotify.c */; };
- F9FD31430CC1AD070073837D /* tclLoadDyld.c in Sources */ = {isa = PBXBuildFile; fileRef = F96D445B08F272B9004A47F5 /* tclLoadDyld.c */; };
+ F9FD31430CC1AD070073837D /* tclLoadDyld.c in Sources */ = {isa = PBXBuildFile; fileRef = F96D445B08F272B9004A47F5 /* tclLoadDyld.c */; settings = {COMPILER_FLAGS = "-Wno-deprecated-declarations"; }; };
F9FD31440CC1AD070073837D /* tclUnixChan.c in Sources */ = {isa = PBXBuildFile; fileRef = F96D445F08F272B9004A47F5 /* tclUnixChan.c */; };
F9FD31450CC1AD070073837D /* tclUnixCompat.c in Sources */ = {isa = PBXBuildFile; fileRef = F9FC77B70AB29E9100B7077D /* tclUnixCompat.c */; };
F9FD31460CC1AD070073837D /* tclUnixEvent.c in Sources */ = {isa = PBXBuildFile; fileRef = F96D446008F272B9004A47F5 /* tclUnixEvent.c */; };
@@ -564,6 +562,7 @@
F9FD31DA0CC1AD070073837D /* tkAppInit.c in Sources */ = {isa = PBXBuildFile; fileRef = F966BC7508F27A3D005CB29B /* tkAppInit.c */; settings = {COMPILER_FLAGS = "-DTK_TEST"; }; };
F9FD31DB0CC1AD070073837D /* tkUnix3d.c in Sources */ = {isa = PBXBuildFile; fileRef = F966BC7908F27A3D005CB29B /* tkUnix3d.c */; };
F9FD31DC0CC1AD070073837D /* tkUnixScale.c in Sources */ = {isa = PBXBuildFile; fileRef = F966BC8C08F27A3D005CB29B /* tkUnixScale.c */; };
+ F9FD31E20CC1AD070073837D /* tclDTrace.d in Sources */ = {isa = PBXBuildFile; fileRef = F9F4415D0C8BAE6F00BCCD67 /* tclDTrace.d */; };
F9FD31E40CC1AD070073837D /* CoreFoundation.framework in Frameworks */ = {isa = PBXBuildFile; fileRef = F966C07408F2820D005CB29B /* CoreFoundation.framework */; };
F9FD31F80CC1ADB70073837D /* tkUnixCursor.c in Sources */ = {isa = PBXBuildFile; fileRef = F966BC7D08F27A3D005CB29B /* tkUnixCursor.c */; };
F9FD31FA0CC1ADB70073837D /* tkUnixKey.c in Sources */ = {isa = PBXBuildFile; fileRef = F966BC8708F27A3D005CB29B /* tkUnixKey.c */; };
@@ -605,6 +604,9 @@
F936FCDA0CCD984600716967 /* ttknote.tcl */ = {isa = PBXFileReference; explicitFileType = text.script; fileEncoding = 4; path = ttknote.tcl; sourceTree = "<group>"; };
F936FCDB0CCD984600716967 /* combo.tcl */ = {isa = PBXFileReference; explicitFileType = text.script; fileEncoding = 4; path = combo.tcl; sourceTree = "<group>"; };
F93E5EFD09CF8711008FA367 /* tkMacOSXFont.h */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.h; path = tkMacOSXFont.h; sourceTree = "<group>"; };
+ F94523A10E6FC2AC00C1D987 /* Cocoa.framework */ = {isa = PBXFileReference; lastKnownFileType = wrapper.framework; name = Cocoa.framework; path = /System/Library/Frameworks/Cocoa.framework; sourceTree = "<absolute>"; };
+ F95D8D4B0F1715610006B020 /* Tk.icns */ = {isa = PBXFileReference; lastKnownFileType = image.icns; path = Tk.icns; sourceTree = "<group>"; };
+ F95D8D4C0F1715610006B020 /* Tk.tiff */ = {isa = PBXFileReference; lastKnownFileType = image.tiff; path = Tk.tiff; sourceTree = "<group>"; };
F95FAFF90B34F1130072E431 /* macOSXLoad.test */ = {isa = PBXFileReference; explicitFileType = text.script; fileEncoding = 4; path = macOSXLoad.test; sourceTree = "<group>"; };
F962F7C60DADC26200648DB8 /* vsapi.test */ = {isa = PBXFileReference; explicitFileType = text.script; fileEncoding = 4; path = vsapi.test; sourceTree = "<group>"; };
F966BA0408F27A37005CB29B /* error.xbm */ = {isa = PBXFileReference; explicitFileType = sourcecode.c.h; fileEncoding = 4; path = error.xbm; sourceTree = "<group>"; };
@@ -962,51 +964,47 @@
F966BBBB08F27A3B005CB29B /* GNUmakefile */ = {isa = PBXFileReference; explicitFileType = sourcecode.make; fileEncoding = 4; path = GNUmakefile; sourceTree = "<group>"; };
F966BBBE08F27A3B005CB29B /* README */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = text; path = README; sourceTree = "<group>"; };
F966BBC008F27A3B005CB29B /* Tk-Info.plist.in */ = {isa = PBXFileReference; explicitFileType = text.plist; fileEncoding = 4; path = "Tk-Info.plist.in"; sourceTree = "<group>"; };
- F966BBC108F27A3B005CB29B /* tkAboutDlg.r */ = {isa = PBXFileReference; fileEncoding = 30; lastKnownFileType = sourcecode.rez; path = tkAboutDlg.r; sourceTree = "<group>"; };
F966BBC208F27A3B005CB29B /* tkMacOSX.h */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.h; path = tkMacOSX.h; sourceTree = "<group>"; };
- F966BBC408F27A3B005CB29B /* tkMacOSXAETE.r */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.rez; path = tkMacOSXAETE.r; sourceTree = "<group>"; };
- F966BBC508F27A3B005CB29B /* tkMacOSXBitmap.c */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.c; path = tkMacOSXBitmap.c; sourceTree = "<group>"; };
- F966BBC608F27A3B005CB29B /* tkMacOSXButton.c */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.c; path = tkMacOSXButton.c; sourceTree = "<group>"; };
- F966BBC708F27A3B005CB29B /* tkMacOSXCarbonEvents.c */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.c; path = tkMacOSXCarbonEvents.c; sourceTree = "<group>"; };
- F966BBC808F27A3B005CB29B /* tkMacOSXClipboard.c */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.c; path = tkMacOSXClipboard.c; sourceTree = "<group>"; };
- F966BBC908F27A3B005CB29B /* tkMacOSXColor.c */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.c; path = tkMacOSXColor.c; sourceTree = "<group>"; };
- F966BBCA08F27A3B005CB29B /* tkMacOSXConfig.c */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.c; path = tkMacOSXConfig.c; sourceTree = "<group>"; };
- F966BBCB08F27A3B005CB29B /* tkMacOSXCursor.c */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.c; path = tkMacOSXCursor.c; sourceTree = "<group>"; };
- F966BBCC08F27A3B005CB29B /* tkMacOSXCursors.r */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.rez; path = tkMacOSXCursors.r; sourceTree = "<group>"; };
- F966BBCD08F27A3B005CB29B /* tkMacOSXDebug.c */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.c; path = tkMacOSXDebug.c; sourceTree = "<group>"; };
+ F966BBC508F27A3B005CB29B /* tkMacOSXBitmap.c */ = {isa = PBXFileReference; explicitFileType = sourcecode.c.objc; fileEncoding = 4; path = tkMacOSXBitmap.c; sourceTree = "<group>"; };
+ F966BBC608F27A3B005CB29B /* tkMacOSXButton.c */ = {isa = PBXFileReference; explicitFileType = sourcecode.c.objc; fileEncoding = 4; path = tkMacOSXButton.c; sourceTree = "<group>"; };
+ F966BBC808F27A3B005CB29B /* tkMacOSXClipboard.c */ = {isa = PBXFileReference; explicitFileType = sourcecode.c.objc; fileEncoding = 4; path = tkMacOSXClipboard.c; sourceTree = "<group>"; };
+ F966BBC908F27A3B005CB29B /* tkMacOSXColor.c */ = {isa = PBXFileReference; explicitFileType = sourcecode.c.objc; fileEncoding = 4; path = tkMacOSXColor.c; sourceTree = "<group>"; };
+ F966BBCA08F27A3B005CB29B /* tkMacOSXConfig.c */ = {isa = PBXFileReference; explicitFileType = sourcecode.c.objc; fileEncoding = 4; path = tkMacOSXConfig.c; sourceTree = "<group>"; };
+ F966BBCB08F27A3B005CB29B /* tkMacOSXCursor.c */ = {isa = PBXFileReference; explicitFileType = sourcecode.c.objc; fileEncoding = 4; path = tkMacOSXCursor.c; sourceTree = "<group>"; };
+ F966BBCC08F27A3B005CB29B /* tkMacOSXCursors.h */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.h; path = tkMacOSXCursors.h; sourceTree = "<group>"; };
+ F966BBCD08F27A3B005CB29B /* tkMacOSXDebug.c */ = {isa = PBXFileReference; explicitFileType = sourcecode.c.objc; fileEncoding = 4; path = tkMacOSXDebug.c; sourceTree = "<group>"; };
F966BBCE08F27A3B005CB29B /* tkMacOSXDebug.h */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.h; path = tkMacOSXDebug.h; sourceTree = "<group>"; };
F966BBCF08F27A3B005CB29B /* tkMacOSXDefault.h */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.h; path = tkMacOSXDefault.h; sourceTree = "<group>"; };
- F966BBD008F27A3B005CB29B /* tkMacOSXDialog.c */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.c; path = tkMacOSXDialog.c; sourceTree = "<group>"; };
- F966BBD108F27A3B005CB29B /* tkMacOSXDraw.c */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.c; path = tkMacOSXDraw.c; sourceTree = "<group>"; };
- F966BBD208F27A3B005CB29B /* tkMacOSXEmbed.c */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.c; path = tkMacOSXEmbed.c; sourceTree = "<group>"; };
- F966BBD308F27A3B005CB29B /* tkMacOSXEntry.c */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.c; path = tkMacOSXEntry.c; sourceTree = "<group>"; };
- F966BBD408F27A3B005CB29B /* tkMacOSXEvent.c */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.c; path = tkMacOSXEvent.c; sourceTree = "<group>"; };
+ F966BBD008F27A3B005CB29B /* tkMacOSXDialog.c */ = {isa = PBXFileReference; explicitFileType = sourcecode.c.objc; fileEncoding = 4; path = tkMacOSXDialog.c; sourceTree = "<group>"; };
+ F966BBD108F27A3B005CB29B /* tkMacOSXDraw.c */ = {isa = PBXFileReference; explicitFileType = sourcecode.c.objc; fileEncoding = 4; path = tkMacOSXDraw.c; sourceTree = "<group>"; };
+ F966BBD208F27A3B005CB29B /* tkMacOSXEmbed.c */ = {isa = PBXFileReference; explicitFileType = sourcecode.c.objc; fileEncoding = 4; path = tkMacOSXEmbed.c; sourceTree = "<group>"; };
+ F966BBD308F27A3B005CB29B /* tkMacOSXEntry.c */ = {isa = PBXFileReference; explicitFileType = sourcecode.c.objc; fileEncoding = 4; path = tkMacOSXEntry.c; sourceTree = "<group>"; };
+ F966BBD408F27A3B005CB29B /* tkMacOSXEvent.c */ = {isa = PBXFileReference; explicitFileType = sourcecode.c.objc; fileEncoding = 4; path = tkMacOSXEvent.c; sourceTree = "<group>"; };
F966BBD508F27A3B005CB29B /* tkMacOSXEvent.h */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.h; path = tkMacOSXEvent.h; sourceTree = "<group>"; };
- F966BBD608F27A3B005CB29B /* tkMacOSXFont.c */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.c; path = tkMacOSXFont.c; sourceTree = "<group>"; };
- F966BBD708F27A3B005CB29B /* tkMacOSXHLEvents.c */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.c; path = tkMacOSXHLEvents.c; sourceTree = "<group>"; };
- F966BBD808F27A3B005CB29B /* tkMacOSXInit.c */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.c; path = tkMacOSXInit.c; sourceTree = "<group>"; };
+ F966BBD608F27A3B005CB29B /* tkMacOSXFont.c */ = {isa = PBXFileReference; explicitFileType = sourcecode.c.objc; fileEncoding = 4; path = tkMacOSXFont.c; sourceTree = "<group>"; };
+ F966BBD708F27A3B005CB29B /* tkMacOSXHLEvents.c */ = {isa = PBXFileReference; explicitFileType = sourcecode.c.objc; fileEncoding = 4; path = tkMacOSXHLEvents.c; sourceTree = "<group>"; };
+ F966BBD808F27A3B005CB29B /* tkMacOSXInit.c */ = {isa = PBXFileReference; explicitFileType = sourcecode.c.objc; fileEncoding = 4; path = tkMacOSXInit.c; sourceTree = "<group>"; };
F966BBDA08F27A3B005CB29B /* tkMacOSXInt.h */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.h; path = tkMacOSXInt.h; sourceTree = "<group>"; };
- F966BBDB08F27A3B005CB29B /* tkMacOSXKeyboard.c */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.c; path = tkMacOSXKeyboard.c; sourceTree = "<group>"; };
- F966BBDC08F27A3B005CB29B /* tkMacOSXKeyEvent.c */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.c; path = tkMacOSXKeyEvent.c; sourceTree = "<group>"; };
- F966BBDD08F27A3B005CB29B /* tkMacOSXMenu.c */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.c; path = tkMacOSXMenu.c; sourceTree = "<group>"; };
- F966BBE008F27A3B005CB29B /* tkMacOSXMenubutton.c */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.c; path = tkMacOSXMenubutton.c; sourceTree = "<group>"; };
- F966BBE108F27A3B005CB29B /* tkMacOSXMenus.c */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.c; path = tkMacOSXMenus.c; sourceTree = "<group>"; };
- F966BBE208F27A3B005CB29B /* tkMacOSXMouseEvent.c */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.c; path = tkMacOSXMouseEvent.c; sourceTree = "<group>"; };
- F966BBE308F27A3B005CB29B /* tkMacOSXNotify.c */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.c; path = tkMacOSXNotify.c; sourceTree = "<group>"; };
+ F966BBDB08F27A3B005CB29B /* tkMacOSXKeyboard.c */ = {isa = PBXFileReference; explicitFileType = sourcecode.c.objc; fileEncoding = 4; path = tkMacOSXKeyboard.c; sourceTree = "<group>"; };
+ F966BBDC08F27A3B005CB29B /* tkMacOSXKeyEvent.c */ = {isa = PBXFileReference; explicitFileType = sourcecode.c.objc; fileEncoding = 4; path = tkMacOSXKeyEvent.c; sourceTree = "<group>"; };
+ F966BBDD08F27A3B005CB29B /* tkMacOSXMenu.c */ = {isa = PBXFileReference; explicitFileType = sourcecode.c.objc; fileEncoding = 4; path = tkMacOSXMenu.c; sourceTree = "<group>"; };
+ F966BBE008F27A3B005CB29B /* tkMacOSXMenubutton.c */ = {isa = PBXFileReference; explicitFileType = sourcecode.c.objc; fileEncoding = 4; path = tkMacOSXMenubutton.c; sourceTree = "<group>"; };
+ F966BBE108F27A3B005CB29B /* tkMacOSXMenus.c */ = {isa = PBXFileReference; explicitFileType = sourcecode.c.objc; fileEncoding = 4; path = tkMacOSXMenus.c; sourceTree = "<group>"; };
+ F966BBE208F27A3B005CB29B /* tkMacOSXMouseEvent.c */ = {isa = PBXFileReference; explicitFileType = sourcecode.c.objc; fileEncoding = 4; path = tkMacOSXMouseEvent.c; sourceTree = "<group>"; };
+ F966BBE308F27A3B005CB29B /* tkMacOSXNotify.c */ = {isa = PBXFileReference; explicitFileType = sourcecode.c.objc; fileEncoding = 4; path = tkMacOSXNotify.c; sourceTree = "<group>"; };
F966BBEA08F27A3C005CB29B /* tkMacOSXPort.h */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.h; path = tkMacOSXPort.h; sourceTree = "<group>"; };
- F966BBEB08F27A3C005CB29B /* tkMacOSXRegion.c */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.c; path = tkMacOSXRegion.c; sourceTree = "<group>"; };
- F966BBEC08F27A3C005CB29B /* tkMacOSXScale.c */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.c; path = tkMacOSXScale.c; sourceTree = "<group>"; };
- F966BBED08F27A3C005CB29B /* tkMacOSXScrlbr.c */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.c; path = tkMacOSXScrlbr.c; sourceTree = "<group>"; };
- F966BBEE08F27A3C005CB29B /* tkMacOSXSend.c */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.c; path = tkMacOSXSend.c; sourceTree = "<group>"; };
- F966BBEF08F27A3C005CB29B /* tkMacOSXSubwindows.c */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.c; path = tkMacOSXSubwindows.c; sourceTree = "<group>"; };
- F966BBF008F27A3C005CB29B /* tkMacOSXTest.c */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.c; path = tkMacOSXTest.c; sourceTree = "<group>"; };
- F966BBF108F27A3C005CB29B /* tkMacOSXWindowEvent.c */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.c; path = tkMacOSXWindowEvent.c; sourceTree = "<group>"; };
- F966BBF208F27A3C005CB29B /* tkMacOSXWm.c */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.c; path = tkMacOSXWm.c; sourceTree = "<group>"; };
+ F966BBEB08F27A3C005CB29B /* tkMacOSXRegion.c */ = {isa = PBXFileReference; explicitFileType = sourcecode.c.objc; fileEncoding = 4; path = tkMacOSXRegion.c; sourceTree = "<group>"; };
+ F966BBEC08F27A3C005CB29B /* tkMacOSXScale.c */ = {isa = PBXFileReference; explicitFileType = sourcecode.c.objc; fileEncoding = 4; path = tkMacOSXScale.c; sourceTree = "<group>"; };
+ F966BBED08F27A3C005CB29B /* tkMacOSXScrlbr.c */ = {isa = PBXFileReference; explicitFileType = sourcecode.c.objc; fileEncoding = 4; path = tkMacOSXScrlbr.c; sourceTree = "<group>"; };
+ F966BBEE08F27A3C005CB29B /* tkMacOSXSend.c */ = {isa = PBXFileReference; explicitFileType = sourcecode.c.objc; fileEncoding = 4; path = tkMacOSXSend.c; sourceTree = "<group>"; };
+ F966BBEF08F27A3C005CB29B /* tkMacOSXSubwindows.c */ = {isa = PBXFileReference; explicitFileType = sourcecode.c.objc; fileEncoding = 4; path = tkMacOSXSubwindows.c; sourceTree = "<group>"; };
+ F966BBF008F27A3C005CB29B /* tkMacOSXTest.c */ = {isa = PBXFileReference; explicitFileType = sourcecode.c.objc; fileEncoding = 4; path = tkMacOSXTest.c; sourceTree = "<group>"; };
+ F966BBF108F27A3C005CB29B /* tkMacOSXWindowEvent.c */ = {isa = PBXFileReference; explicitFileType = sourcecode.c.objc; fileEncoding = 4; path = tkMacOSXWindowEvent.c; sourceTree = "<group>"; };
+ F966BBF208F27A3C005CB29B /* tkMacOSXWm.c */ = {isa = PBXFileReference; explicitFileType = sourcecode.c.objc; fileEncoding = 4; path = tkMacOSXWm.c; sourceTree = "<group>"; };
F966BBF308F27A3C005CB29B /* tkMacOSXWm.h */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.h; path = tkMacOSXWm.h; sourceTree = "<group>"; };
- F966BBF408F27A3C005CB29B /* tkMacOSXXCursors.r */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.rez; path = tkMacOSXXCursors.r; sourceTree = "<group>"; };
- F966BBF508F27A3C005CB29B /* tkMacOSXXStubs.c */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.c; path = tkMacOSXXStubs.c; sourceTree = "<group>"; };
+ F966BBF408F27A3C005CB29B /* tkMacOSXXCursors.h */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.h; path = tkMacOSXXCursors.h; sourceTree = "<group>"; };
+ F966BBF508F27A3C005CB29B /* tkMacOSXXStubs.c */ = {isa = PBXFileReference; explicitFileType = sourcecode.c.objc; fileEncoding = 4; path = tkMacOSXXStubs.c; sourceTree = "<group>"; };
F966BBF708F27A3C005CB29B /* Wish-Info.plist.in */ = {isa = PBXFileReference; explicitFileType = text.plist; fileEncoding = 4; path = "Wish-Info.plist.in"; sourceTree = "<group>"; };
- F966BBF808F27A3C005CB29B /* Wish.icns */ = {isa = PBXFileReference; lastKnownFileType = image.icns; path = Wish.icns; sourceTree = "<group>"; };
F966BC0308F27A3C005CB29B /* README */ = {isa = PBXFileReference; explicitFileType = text; fileEncoding = 4; path = README; sourceTree = "<group>"; };
F966BC0508F27A3C005CB29B /* all.tcl */ = {isa = PBXFileReference; explicitFileType = text.script; fileEncoding = 4; path = all.tcl; sourceTree = "<group>"; };
F966BC0608F27A3C005CB29B /* arc.tcl */ = {isa = PBXFileReference; explicitFileType = text.script; fileEncoding = 4; path = arc.tcl; sourceTree = "<group>"; };
@@ -1309,7 +1307,7 @@
F968887F0AF788F6000797B5 /* ttk_Theme.3 */ = {isa = PBXFileReference; explicitFileType = text.man; fileEncoding = 4; path = ttk_Theme.3; sourceTree = "<group>"; };
F96888800AF788F6000797B5 /* ttk_treeview.n */ = {isa = PBXFileReference; explicitFileType = text.man; fileEncoding = 4; path = ttk_treeview.n; sourceTree = "<group>"; };
F96888810AF788F6000797B5 /* ttk_widget.n */ = {isa = PBXFileReference; explicitFileType = text.man; fileEncoding = 4; path = ttk_widget.n; sourceTree = "<group>"; };
- F96888840AF78938000797B5 /* ttkMacOSXTheme.c */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.c; path = ttkMacOSXTheme.c; sourceTree = "<group>"; };
+ F96888840AF78938000797B5 /* ttkMacOSXTheme.c */ = {isa = PBXFileReference; explicitFileType = sourcecode.c.objc; fileEncoding = 4; path = ttkMacOSXTheme.c; sourceTree = "<group>"; };
F96888860AF78953000797B5 /* ttkWinMonitor.c */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.c; path = ttkWinMonitor.c; sourceTree = "<group>"; };
F96888870AF78953000797B5 /* ttkWinTheme.c */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.c; path = ttkWinTheme.c; sourceTree = "<group>"; };
F96888880AF78953000797B5 /* ttkWinXPTheme.c */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.c; path = ttkWinXPTheme.c; sourceTree = "<group>"; };
@@ -2039,6 +2037,7 @@
F9A3084B08F2D4CE00BAE1AB /* Wish.app */ = {isa = PBXFileReference; explicitFileType = wrapper.application; includeInIndex = 0; path = Wish.app; sourceTree = BUILT_PRODUCTS_DIR; };
F9A3084E08F2D4F400BAE1AB /* Tcl.framework */ = {isa = PBXFileReference; includeInIndex = 0; lastKnownFileType = wrapper.framework; path = Tcl.framework; sourceTree = BUILT_PRODUCTS_DIR; };
F9A493240CEBF38300B78AE2 /* chanio.test */ = {isa = PBXFileReference; explicitFileType = text.script; fileEncoding = 4; path = chanio.test; sourceTree = "<group>"; };
+ F9C9CBFF0E84059800E00935 /* ApplicationServices.framework */ = {isa = PBXFileReference; lastKnownFileType = wrapper.framework; name = ApplicationServices.framework; path = /System/Library/Frameworks/ApplicationServices.framework; sourceTree = "<absolute>"; };
F9D1360A0CDC252C00DBE0B5 /* mclist.tcl */ = {isa = PBXFileReference; explicitFileType = text.script; fileEncoding = 4; path = mclist.tcl; sourceTree = "<group>"; };
F9ECB1120B26521500A28025 /* pkgIndex.tcl */ = {isa = PBXFileReference; explicitFileType = text.script; fileEncoding = 4; path = pkgIndex.tcl; sourceTree = "<group>"; };
F9ECB1130B26521500A28025 /* platform.tcl */ = {isa = PBXFileReference; explicitFileType = text.script; fileEncoding = 4; path = platform.tcl; sourceTree = "<group>"; };
@@ -2047,6 +2046,7 @@
F9ECB1CB0B26534C00A28025 /* mathop.test */ = {isa = PBXFileReference; explicitFileType = text.script; fileEncoding = 4; path = mathop.test; sourceTree = "<group>"; };
F9ECB1E10B26543C00A28025 /* platform_shell.n */ = {isa = PBXFileReference; explicitFileType = text.man; fileEncoding = 4; path = platform_shell.n; sourceTree = "<group>"; };
F9ECB1E20B26543C00A28025 /* platform.n */ = {isa = PBXFileReference; explicitFileType = text.man; fileEncoding = 4; path = platform.n; sourceTree = "<group>"; };
+ F9F4415D0C8BAE6F00BCCD67 /* tclDTrace.d */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.dtrace; path = tclDTrace.d; sourceTree = "<group>"; };
F9F4EFDC0CC7B3CA00378A27 /* ttkpane.tcl */ = {isa = PBXFileReference; explicitFileType = text.script; fileEncoding = 4; languageSpecificationIdentifier = shell; path = ttkpane.tcl; sourceTree = "<group>"; };
F9F4EFDD0CC7B3CB00378A27 /* ttkmenu.tcl */ = {isa = PBXFileReference; explicitFileType = text.script; fileEncoding = 4; languageSpecificationIdentifier = shell; path = ttkmenu.tcl; sourceTree = "<group>"; };
F9FC77B70AB29E9100B7077D /* tclUnixCompat.c */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.c; path = tclUnixCompat.c; sourceTree = "<group>"; };
@@ -2067,6 +2067,8 @@
F966C07508F2820D005CB29B /* CoreFoundation.framework in Frameworks */,
F966C07708F2821B005CB29B /* Carbon.framework in Frameworks */,
F966C07908F28233005CB29B /* IOKit.framework in Frameworks */,
+ F94523A20E6FC2AC00C1D987 /* Cocoa.framework in Frameworks */,
+ F9C9CC000E84059800E00935 /* ApplicationServices.framework in Frameworks */,
);
runOnlyForDeploymentPostprocessing = 0;
};
@@ -2095,7 +2097,7 @@
F966C06F08F281DC005CB29B /* Frameworks */,
1AB674ADFE9D54B511CA2CBB /* Products */,
);
- comments = "Copyright (c) 2004-2008 Daniel A. Steffen <das@users.sourceforge.net>\n\nSee the file \"license.terms\" for information on usage and redistribution of\nthis file, and for a DISCLAIMER OF ALL WARRANTIES.\n";
+ comments = "Copyright (c) 2004-2009 Daniel A. Steffen <das@users.sourceforge.net>\nCopyright 2008-2009, Apple Inc.\n\nSee the file \"license.terms\" for information on usage and redistribution of\nthis file, and for a DISCLAIMER OF ALL WARRANTIES.\n\nRCS: @(#) $Id$\n";
name = Wish;
path = .;
sourceTree = SOURCE_ROOT;
@@ -2539,17 +2541,14 @@
F966BBBB08F27A3B005CB29B /* GNUmakefile */,
F966BBBE08F27A3B005CB29B /* README */,
F966BBC008F27A3B005CB29B /* Tk-Info.plist.in */,
- F966BBC108F27A3B005CB29B /* tkAboutDlg.r */,
F966BBC208F27A3B005CB29B /* tkMacOSX.h */,
- F966BBC408F27A3B005CB29B /* tkMacOSXAETE.r */,
F966BBC508F27A3B005CB29B /* tkMacOSXBitmap.c */,
F966BBC608F27A3B005CB29B /* tkMacOSXButton.c */,
- F966BBC708F27A3B005CB29B /* tkMacOSXCarbonEvents.c */,
F966BBC808F27A3B005CB29B /* tkMacOSXClipboard.c */,
F966BBC908F27A3B005CB29B /* tkMacOSXColor.c */,
F966BBCA08F27A3B005CB29B /* tkMacOSXConfig.c */,
F966BBCB08F27A3B005CB29B /* tkMacOSXCursor.c */,
- F966BBCC08F27A3B005CB29B /* tkMacOSXCursors.r */,
+ F966BBCC08F27A3B005CB29B /* tkMacOSXCursors.h */,
F966BBCD08F27A3B005CB29B /* tkMacOSXDebug.c */,
F966BBCE08F27A3B005CB29B /* tkMacOSXDebug.h */,
F966BBCF08F27A3B005CB29B /* tkMacOSXDefault.h */,
@@ -2582,10 +2581,11 @@
F966BBF108F27A3C005CB29B /* tkMacOSXWindowEvent.c */,
F966BBF208F27A3C005CB29B /* tkMacOSXWm.c */,
F966BBF308F27A3C005CB29B /* tkMacOSXWm.h */,
- F966BBF408F27A3C005CB29B /* tkMacOSXXCursors.r */,
+ F966BBF408F27A3C005CB29B /* tkMacOSXXCursors.h */,
F966BBF508F27A3C005CB29B /* tkMacOSXXStubs.c */,
F96888840AF78938000797B5 /* ttkMacOSXTheme.c */,
- F966BBF808F27A3C005CB29B /* Wish.icns */,
+ F95D8D4B0F1715610006B020 /* Tk.icns */,
+ F95D8D4C0F1715610006B020 /* Tk.tiff */,
F966BBF708F27A3C005CB29B /* Wish-Info.plist.in */,
F97AE7F10B65C1E900310EA2 /* Wish-Common.xcconfig */,
F97AE8330B65C87F00310EA2 /* Wish-Debug.xcconfig */,
@@ -2848,8 +2848,10 @@
F966C06F08F281DC005CB29B /* Frameworks */ = {
isa = PBXGroup;
children = (
+ F9C9CBFF0E84059800E00935 /* ApplicationServices.framework */,
F966C07408F2820D005CB29B /* CoreFoundation.framework */,
F966C07608F2821B005CB29B /* Carbon.framework */,
+ F94523A10E6FC2AC00C1D987 /* Cocoa.framework */,
F966C07808F28233005CB29B /* IOKit.framework */,
F9FD32140CC1AF170073837D /* libX11.dylib */,
F9FD32150CC1AF170073837D /* libXext.dylib */,
@@ -3247,6 +3249,7 @@
F96D3EEA08F272A7004A47F5 /* tclDate.c */,
F96D3EEB08F272A7004A47F5 /* tclDecls.h */,
F96D3EEC08F272A7004A47F5 /* tclDictObj.c */,
+ F9F4415D0C8BAE6F00BCCD67 /* tclDTrace.d */,
F96D3EED08F272A7004A47F5 /* tclEncoding.c */,
F96D3EEE08F272A7004A47F5 /* tclEnv.c */,
F96D3EEF08F272A7004A47F5 /* tclEvent.c */,
@@ -3865,10 +3868,8 @@
buildPhases = (
F9A5C5F508F651A2008AE941 /* ShellScript */,
F9A5C5F608F651AB008AE941 /* ShellScript */,
- F9EA4ADE08FA3B7F00B1F5F0 /* Rez */,
8DD76FAB0486AB0100D96B5E /* Sources */,
8DD76FAD0486AB0100D96B5E /* Frameworks */,
- F95FA74C0B32CE190072E431 /* ShellScript */,
);
buildRules = (
);
@@ -3919,7 +3920,11 @@
/* Begin PBXProject section */
08FB7793FE84155DC02AAC07 /* Project object */ = {
isa = PBXProject;
+ attributes = {
+ BuildIndependentTargetsInParallel = YES;
+ };
buildConfigurationList = F95CC8B509158F3100EA5ACE /* Build configuration list for PBXProject "Wish" */;
+ compatibilityVersion = "Xcode 3.1";
hasScannedForEncodings = 1;
mainGroup = 08FB7794FE84155DC02AAC07 /* Wish */;
projectDirPath = "";
@@ -3932,37 +3937,7 @@
};
/* End PBXProject section */
-/* Begin PBXRezBuildPhase section */
- F9EA4ADE08FA3B7F00B1F5F0 /* Rez */ = {
- isa = PBXRezBuildPhase;
- buildActionMask = 2147483647;
- files = (
- F9EA4AF008FA3BD500B1F5F0 /* tkMacOSXXCursors.r in Rez */,
- F9EA4AF208FA3BD800B1F5F0 /* tkMacOSXCursors.r in Rez */,
- F9EA4AF308FA3BDA00B1F5F0 /* tkMacOSXAETE.r in Rez */,
- F9EA4AF408FA3BDB00B1F5F0 /* tkAboutDlg.r in Rez */,
- );
- runOnlyForDeploymentPostprocessing = 0;
- };
-/* End PBXRezBuildPhase section */
-
/* Begin PBXShellScriptBuildPhase section */
- F95FA74C0B32CE190072E431 /* ShellScript */ = {
- isa = PBXShellScriptBuildPhase;
- buildActionMask = 2147483647;
- files = (
- );
- inputPaths = (
- "$(TARGET_BUILD_DIR)/$(PRODUCT_NAME)",
- "$(REZ_COLLECTOR_DIR)/$(PRODUCT_NAME).rsrc",
- );
- outputPaths = (
- "$(TARGET_TEMP_DIR)/stamp",
- );
- runOnlyForDeploymentPostprocessing = 0;
- shellPath = /bin/bash;
- shellScript = "touch -t $(date -r $(expr $(date '+%s') + 5) '+%Y%m%d%H%M.%S') \"${TARGET_TEMP_DIR}/stamp\"\n\n## Xcode bug workaround: Rezzing does not take place for commandline tool targets\n## even when a ResourceManager Resources phase is present, but this script phase's\n## input dependency on the final merged resource file forces the Rezzing.\n\nif [ \"${ZERO_LINK}\" = \"YES\" ]; then\n ## ZeroLinking ignores OTHER_LDFLAGS, so our resource file doesn't get linked into the executable.\n ## workaround: copy resource data into resource fork of zerolink launcher (will only work on HFS+).\n cp -f \"${SCRIPT_INPUT_FILE_1}\" \"${SCRIPT_INPUT_FILE_0}/..namedfork/rsrc\"\nfi\n";
- };
F97AF02F0B665DA900310EA2 /* ShellScript */ = {
isa = PBXShellScriptBuildPhase;
buildActionMask = 2147483647;
@@ -3977,6 +3952,7 @@
runOnlyForDeploymentPostprocessing = 0;
shellPath = /bin/bash;
shellScript = "gnumake -C \"${TK_SRCROOT}/macosx\" -j \"$(sysctl -n hw.activecpu)\" \"$(echo \"${ACTION}\" | sed -e s/build// -e s/clean/distclean/ -e s/..\\*/\\&-/)${MAKE_TARGET}\" CFLAGS_WARNING=\"${WARNING_CFLAGS}\" CFLAGS_OPTIMIZE=\"-O${GCC_OPTIMIZATION_LEVEL}\" SYMROOT=\"${BUILT_PRODUCTS_DIR}\" OBJ_DIR=\"${OBJECT_FILE_DIR}\" INSTALL_ROOT=\"${DSTROOT}\" PREFIX=\"${PREFIX}\" BINDIR=\"${BINDIR}\" LIBDIR=\"${FRAMEWORK_INSTALL_PATH}\" MANDIR=\"${MANDIR}\" EXTRA_CONFIGURE_ARGS=\"${CONFIGURE_ARGS}\" APPLICATION_INSTALL_PATH=\"${APPLICATION_INSTALL_PATH}\" TCL_BUILD_DIR=\"${TCL_BUILD_DIR}\" TCL_FRAMEWORK_DIR=\"${TCL_FRAMEWORK_DIR}\" ${EXTRA_MAKE_FLAGS}\nresult=$?\nif [ -e \"${BUILT_PRODUCTS_DIR}/tktest\" ]; then\n\trm -f \"${BUILT_PRODUCTS_DIR}/tktest\"\nfi\necho \"Done\"\nrm -f \"${SCRIPT_INPUT_FILE_0}\"\nexit ${result}\n";
+ showEnvVarsInLog = 0;
};
F9A5C5F508F651A2008AE941 /* ShellScript */ = {
isa = PBXShellScriptBuildPhase;
@@ -3998,6 +3974,7 @@
runOnlyForDeploymentPostprocessing = 0;
shellPath = /bin/bash;
shellScript = "## tcl configure shell script phase\n\ncd \"${TCL_SRCROOT}\"/macosx &&\nif [ configure.ac -nt configure -o ../unix/configure.in -nt configure -o ../unix/tcl.m4 -nt configure -o ../unix/aclocal.m4 -nt configure ]; then\n echo \"Running autoconf & autoheader in tcl/macosx\"\n rm -rf autom4te.cache\n ${AUTOCONF:-${DEVELOPER_DIR}/usr/bin/autoconf} && ${AUTOHEADER:-${DEVELOPER_DIR}/usr/bin/autoheader} || exit $?\n rm -rf autom4te.cache\nfi\n\ncd \"${DERIVED_FILE_DIR}\" && mkdir -p tcl && cd tcl &&\nif [ \"${TCL_SRCROOT}\"/macosx/configure -nt config.status ]; then\n echo \"Configuring Tcl\"\n \"${TCL_SRCROOT}\"/macosx/configure --cache-file=../config.cache --prefix=${PREFIX} --bindir=${BINDIR} --libdir=${LIBDIR} --mandir=${MANDIR} --includedir=${INCLUDEDIR} --disable-shared ${CONFIGURE_ARGS}\nelse\n ./config.status\nfi\n";
+ showEnvVarsInLog = 0;
};
F9A5C5F608F651AB008AE941 /* ShellScript */ = {
isa = PBXShellScriptBuildPhase;
@@ -4017,6 +3994,7 @@
runOnlyForDeploymentPostprocessing = 0;
shellPath = /bin/bash;
shellScript = "## tk configure shell script phase\n\ncd \"${TK_SRCROOT}\"/macosx &&\nif [ configure.ac -nt configure -o ../unix/configure.in -nt configure -o ../unix/tcl.m4 -nt configure -o ../unix/aclocal.m4 -nt configure ]; then\n echo \"Running autoconf & autoheader in tk/macosx\"\n rm -rf autom4te.cache\n ${AUTOCONF:-${DEVELOPER_DIR}/usr/bin/autoconf} && ${AUTOHEADER:-${DEVELOPER_DIR}/usr/bin/autoheader} || exit $?\n rm -rf autom4te.cache\nfi\n\ncd \"${DERIVED_FILE_DIR}\" && mkdir -p tk && cd tk &&\nif [ \"${TK_SRCROOT}\"/macosx/configure -nt config.status ]; then\n echo \"Configuring Tk\"\n \"${TK_SRCROOT}\"/macosx/configure --cache-file=../config.cache --prefix=${PREFIX} --bindir=${BINDIR} --libdir=${LIBDIR} --mandir=${MANDIR} --includedir=${INCLUDEDIR} --disable-shared --enable-aqua --with-tcl=../tcl ${CONFIGURE_ARGS}\nelse\n ./config.status\nfi";
+ showEnvVarsInLog = 0;
};
F9FD30B40CC1AD070073837D /* ShellScript */ = {
isa = PBXShellScriptBuildPhase;
@@ -4038,6 +4016,7 @@
runOnlyForDeploymentPostprocessing = 0;
shellPath = /bin/bash;
shellScript = "## tcl configure shell script phase\n\ncd \"${TCL_SRCROOT}\"/macosx &&\nif [ configure.ac -nt configure -o ../unix/configure.in -nt configure -o ../unix/tcl.m4 -nt configure -o ../unix/aclocal.m4 -nt configure ]; then\n echo \"Running autoconf & autoheader in tcl/macosx\"\n rm -rf autom4te.cache\n ${AUTOCONF:-${DEVELOPER_DIR}/usr/bin/autoconf} && ${AUTOHEADER:-${DEVELOPER_DIR}/usr/bin/autoheader} || exit $?\n rm -rf autom4te.cache\nfi\n\ncd \"${DERIVED_FILE_DIR}\" && mkdir -p tcl && cd tcl &&\nif [ \"${TCL_SRCROOT}\"/macosx/configure -nt config.status ]; then\n echo \"Configuring Tcl\"\n \"${TCL_SRCROOT}\"/macosx/configure --cache-file=../config.cache --prefix=${PREFIX} --bindir=${BINDIR} --libdir=${LIBDIR} --mandir=${MANDIR} --includedir=${INCLUDEDIR} --disable-shared --disable-corefoundation ${CONFIGURE_ARGS}\nelse\n ./config.status\nfi\n";
+ showEnvVarsInLog = 0;
};
F9FD30B50CC1AD070073837D /* ShellScript */ = {
isa = PBXShellScriptBuildPhase;
@@ -4057,6 +4036,7 @@
runOnlyForDeploymentPostprocessing = 0;
shellPath = /bin/bash;
shellScript = "## tk configure shell script phase\n\ncd \"${TK_SRCROOT}\"/macosx &&\nif [ configure.ac -nt configure -o ../unix/configure.in -nt configure -o ../unix/tcl.m4 -nt configure -o ../unix/aclocal.m4 -nt configure ]; then\n echo \"Running autoconf & autoheader in tk/macosx\"\n rm -rf autom4te.cache\n ${AUTOCONF:-${DEVELOPER_DIR}/usr/bin/autoconf} && ${AUTOHEADER:-${DEVELOPER_DIR}/usr/bin/autoheader} || exit $?\n rm -rf autom4te.cache\nfi\n\ncd \"${DERIVED_FILE_DIR}\" && mkdir -p tk && cd tk &&\nif [ \"${TK_SRCROOT}\"/macosx/configure -nt config.status ]; then\n echo \"Configuring Tk\"\n PATH=\"${PATH}:/usr/X11R6/bin\" \"${TK_SRCROOT}\"/macosx/configure --cache-file=../config.cache --prefix=${PREFIX} --bindir=${BINDIR} --libdir=${LIBDIR} --mandir=${MANDIR} --includedir=${INCLUDEDIR} --disable-shared --disable-corefoundation --enable-xft --with-tcl=../tcl ${CONFIGURE_ARGS}\nelse\n ./config.status\nfi";
+ showEnvVarsInLog = 0;
};
/* End PBXShellScriptBuildPhase section */
@@ -4212,6 +4192,7 @@
F96D4AD208F272CA004A47F5 /* tclUnixSock.c in Sources */,
F96D4AD408F272CA004A47F5 /* tclUnixThrd.c in Sources */,
F96D4AD608F272CA004A47F5 /* tclUnixTime.c in Sources */,
+ F9F4415E0C8BAE6F00BCCD67 /* tclDTrace.d in Sources */,
F966BDCF08F27A3F005CB29B /* tk3d.c in Sources */,
F966BDD108F27A3F005CB29B /* tkArgv.c in Sources */,
F966BDD208F27A3F005CB29B /* tkAtom.c in Sources */,
@@ -4321,7 +4302,6 @@
F96888230AF786D5000797B5 /* ttkWidget.c in Sources */,
F966BEDB08F27A40005CB29B /* tkMacOSXBitmap.c in Sources */,
F966BEDC08F27A40005CB29B /* tkMacOSXButton.c in Sources */,
- F966BEDD08F27A40005CB29B /* tkMacOSXCarbonEvents.c in Sources */,
F966BEDE08F27A40005CB29B /* tkMacOSXClipboard.c in Sources */,
F966BEDF08F27A40005CB29B /* tkMacOSXColor.c in Sources */,
F966BEE008F27A40005CB29B /* tkMacOSXConfig.c in Sources */,
@@ -4513,6 +4493,7 @@
F9FD314C0CC1AD070073837D /* tclUnixSock.c in Sources */,
F9FD314D0CC1AD070073837D /* tclUnixThrd.c in Sources */,
F9FD314E0CC1AD070073837D /* tclUnixTime.c in Sources */,
+ F9FD31E20CC1AD070073837D /* tclDTrace.d in Sources */,
F9FD314F0CC1AD070073837D /* tk3d.c in Sources */,
F9FD31500CC1AD070073837D /* tkArgv.c in Sources */,
F9FD31510CC1AD070073837D /* tkAtom.c in Sources */,
@@ -4648,6 +4629,77 @@
/* End PBXSourcesBuildPhase section */
/* Begin XCBuildConfiguration section */
+ F90E36D50F3B5C8400810A10 /* Debug gcc42 nogc */ = {
+ isa = XCBuildConfiguration;
+ baseConfigurationReference = F97AE8330B65C87F00310EA2 /* Wish-Debug.xcconfig */;
+ buildSettings = {
+ ARCHS = (
+ "$(NATIVE_ARCH_32_BIT)",
+ "$(NATIVE_ARCH_64_BIT)",
+ );
+ CPPFLAGS = "-arch $(CURRENT_ARCH) $(CPPFLAGS)";
+ GCC_C_LANGUAGE_STANDARD = gnu99;
+ GCC_ENABLE_OBJC_GC = unsupported;
+ GCC_ENABLE_PASCAL_STRINGS = NO;
+ GCC_INPUT_FILETYPE = sourcecode.c.objc;
+ GCC_VERSION = 4.2;
+ MACOSX_DEPLOYMENT_TARGET = 10.5;
+ ONLY_ACTIVE_ARCH = YES;
+ PREBINDING = NO;
+ };
+ name = "Debug gcc42 nogc";
+ };
+ F90E36D60F3B5C8400810A10 /* Debug gcc42 nogc */ = {
+ isa = XCBuildConfiguration;
+ buildSettings = {
+ PRODUCT_NAME = Wish;
+ SKIP_INSTALL = NO;
+ };
+ name = "Debug gcc42 nogc";
+ };
+ F90E36D70F3B5C8400810A10 /* Debug gcc42 nogc */ = {
+ isa = XCBuildConfiguration;
+ buildSettings = {
+ CONFIGURE_ARGS = "tcl_cv_cc_visibility_hidden=no $(CONFIGURE_ARGS)";
+ GCC_DYNAMIC_NO_PIC = NO;
+ GCC_ENABLE_FIX_AND_CONTINUE = YES;
+ GCC_PREPROCESSOR_DEFINITIONS = (
+ "__private_extern__=extern",
+ "$(GCC_PREPROCESSOR_DEFINITIONS)",
+ );
+ GCC_SYMBOLS_PRIVATE_EXTERN = NO;
+ OTHER_LDFLAGS = (
+ "$(OTHER_LDFLAGS_AQUA)",
+ "$(OTHER_LDFLAGS)",
+ );
+ PRODUCT_NAME = tktest;
+ };
+ name = "Debug gcc42 nogc";
+ };
+ F90E36D80F3B5C8400810A10 /* Debug gcc42 nogc */ = {
+ isa = XCBuildConfiguration;
+ buildSettings = {
+ CONFIGURE_ARGS = "tcl_cv_cc_visibility_hidden=no $(CONFIGURE_ARGS)";
+ GCC_DYNAMIC_NO_PIC = NO;
+ GCC_ENABLE_FIX_AND_CONTINUE = YES;
+ GCC_PREPROCESSOR_DEFINITIONS = (
+ "__private_extern__=extern",
+ "$(GCC_PREPROCESSOR_DEFINITIONS)",
+ );
+ GCC_SYMBOLS_PRIVATE_EXTERN = NO;
+ HEADER_SEARCH_PATHS = (
+ /usr/X11R6/include,
+ /usr/X11R6/include/freetype2,
+ "$(HEADER_SEARCH_PATHS)",
+ );
+ LIBRARY_SEARCH_PATHS = (
+ /usr/X11R6/lib,
+ "$(LIBRARY_SEARCH_PATHS)",
+ );
+ PRODUCT_NAME = "tktest-X11";
+ };
+ name = "Debug gcc42 nogc";
+ };
F91BCC4F093152310042A6BF /* ReleaseUniversal */ = {
isa = XCBuildConfiguration;
buildSettings = {
@@ -4671,12 +4723,13 @@
isa = XCBuildConfiguration;
baseConfigurationReference = F97AE82B0B65C69B00310EA2 /* Wish-Release.xcconfig */;
buildSettings = {
- ARCHS = (
- ppc,
- i386,
- );
- CFLAGS = "-arch ppc -arch i386 $(CFLAGS)";
- MACOSX_DEPLOYMENT_TARGET = 10.4;
+ ARCHS = "$(ARCHS_STANDARD_32_64_BIT)";
+ CFLAGS = "-arch i386 -arch x86_64 -arch ppc $(CFLAGS)";
+ GCC_C_LANGUAGE_STANDARD = gnu99;
+ GCC_ENABLE_OBJC_GC = supported;
+ GCC_ENABLE_PASCAL_STRINGS = NO;
+ GCC_INPUT_FILETYPE = sourcecode.c.objc;
+ MACOSX_DEPLOYMENT_TARGET = 10.5;
PREBINDING = NO;
};
name = ReleaseUniversal;
@@ -4720,8 +4773,18 @@
isa = XCBuildConfiguration;
baseConfigurationReference = F97AE8330B65C87F00310EA2 /* Wish-Debug.xcconfig */;
buildSettings = {
+ ARCHS = (
+ "$(NATIVE_ARCH_32_BIT)",
+ "$(NATIVE_ARCH_64_BIT)",
+ );
CONFIGURE_ARGS = "$(CONFIGURE_ARGS) --enable-symbols=all";
- MACOSX_DEPLOYMENT_TARGET = 10.2;
+ CPPFLAGS = "-arch $(CURRENT_ARCH) $(CPPFLAGS)";
+ GCC_C_LANGUAGE_STANDARD = gnu99;
+ GCC_ENABLE_OBJC_GC = supported;
+ GCC_ENABLE_PASCAL_STRINGS = NO;
+ GCC_INPUT_FILETYPE = sourcecode.c.objc;
+ MACOSX_DEPLOYMENT_TARGET = 10.5;
+ ONLY_ACTIVE_ARCH = YES;
PREBINDING = NO;
};
name = DebugMemCompile;
@@ -4730,9 +4793,19 @@
isa = XCBuildConfiguration;
baseConfigurationReference = F97AE8330B65C87F00310EA2 /* Wish-Debug.xcconfig */;
buildSettings = {
+ ARCHS = (
+ "$(NATIVE_ARCH_32_BIT)",
+ "$(NATIVE_ARCH_64_BIT)",
+ );
+ CPPFLAGS = "-arch $(CURRENT_ARCH) $(CPPFLAGS)";
+ GCC_C_LANGUAGE_STANDARD = gnu99;
+ GCC_ENABLE_OBJC_GC = supported;
+ GCC_ENABLE_PASCAL_STRINGS = NO;
GCC_GENERATE_TEST_COVERAGE_FILES = YES;
+ GCC_INPUT_FILETYPE = sourcecode.c.objc;
GCC_INSTRUMENT_PROGRAM_FLOW_ARCS = YES;
- MACOSX_DEPLOYMENT_TARGET = 10.2;
+ MACOSX_DEPLOYMENT_TARGET = 10.5;
+ ONLY_ACTIVE_ARCH = YES;
OTHER_LDFLAGS = (
"$(OTHER_LDFLAGS)",
"-lgcov",
@@ -4816,7 +4889,6 @@
"$(OTHER_LDFLAGS)",
);
PRODUCT_NAME = tktest;
- ZERO_LINK = YES;
};
name = Debug;
};
@@ -4846,7 +4918,17 @@
isa = XCBuildConfiguration;
baseConfigurationReference = F97AE8330B65C87F00310EA2 /* Wish-Debug.xcconfig */;
buildSettings = {
- MACOSX_DEPLOYMENT_TARGET = 10.2;
+ ARCHS = (
+ "$(NATIVE_ARCH_32_BIT)",
+ "$(NATIVE_ARCH_64_BIT)",
+ );
+ CPPFLAGS = "-arch $(CURRENT_ARCH) $(CPPFLAGS)";
+ GCC_C_LANGUAGE_STANDARD = gnu99;
+ GCC_ENABLE_OBJC_GC = supported;
+ GCC_ENABLE_PASCAL_STRINGS = NO;
+ GCC_INPUT_FILETYPE = sourcecode.c.objc;
+ MACOSX_DEPLOYMENT_TARGET = 10.5;
+ ONLY_ACTIVE_ARCH = YES;
PREBINDING = NO;
};
name = Debug;
@@ -4855,8 +4937,13 @@
isa = XCBuildConfiguration;
baseConfigurationReference = F97AE82B0B65C69B00310EA2 /* Wish-Release.xcconfig */;
buildSettings = {
- MACOSX_DEPLOYMENT_TARGET = 10.2;
- PREBINDING = YES;
+ ARCHS = "$(NATIVE_ARCH_32_BIT)";
+ GCC_C_LANGUAGE_STANDARD = gnu99;
+ GCC_ENABLE_OBJC_GC = supported;
+ GCC_ENABLE_PASCAL_STRINGS = NO;
+ GCC_INPUT_FILETYPE = sourcecode.c.objc;
+ MACOSX_DEPLOYMENT_TARGET = 10.5;
+ PREBINDING = NO;
};
name = Release;
};
@@ -4864,7 +4951,17 @@
isa = XCBuildConfiguration;
baseConfigurationReference = F97AE8330B65C87F00310EA2 /* Wish-Debug.xcconfig */;
buildSettings = {
- MACOSX_DEPLOYMENT_TARGET = 10.2;
+ ARCHS = (
+ "$(NATIVE_ARCH_32_BIT)",
+ "$(NATIVE_ARCH_64_BIT)",
+ );
+ CPPFLAGS = "-arch $(CURRENT_ARCH) $(CPPFLAGS)";
+ GCC_C_LANGUAGE_STANDARD = gnu99;
+ GCC_ENABLE_OBJC_GC = supported;
+ GCC_ENABLE_PASCAL_STRINGS = NO;
+ GCC_INPUT_FILETYPE = sourcecode.c.objc;
+ MACOSX_DEPLOYMENT_TARGET = 10.5;
+ ONLY_ACTIVE_ARCH = YES;
PREBINDING = NO;
};
name = DebugNoFixZL;
@@ -4890,7 +4987,6 @@
"$(LIBRARY_SEARCH_PATHS)",
);
PRODUCT_NAME = "tktest-X11";
- ZERO_LINK = YES;
};
name = Debug;
};
@@ -4929,6 +5025,8 @@
F97258AC0A86873D00096C78 /* ReleaseUniversal */ = {
isa = XCBuildConfiguration;
buildSettings = {
+ ARCHS = "$(ARCHS_STANDARD_32_64_BIT)";
+ CFLAGS = "-arch i386 -arch x86_64 -arch ppc $(CFLAGS)";
HEADER_SEARCH_PATHS = (
/usr/X11R6/include,
/usr/X11R6/include/freetype2,
@@ -4942,39 +5040,26 @@
};
name = ReleaseUniversal;
};
- F97AED080B660A6C00310EA2 /* ReleaseUniversal10.4uSDK */ = {
+ F97AED1B0B660B2100310EA2 /* Debug64bit */ = {
isa = XCBuildConfiguration;
buildSettings = {
- HEADER_SEARCH_PATHS = (
- /usr/X11R6/include,
- /usr/X11R6/include/freetype2,
- "$(HEADER_SEARCH_PATHS)",
- );
- LIBRARY_SEARCH_PATHS = (
- /usr/X11R6/lib,
- "$(LIBRARY_SEARCH_PATHS)",
- );
- PRODUCT_NAME = "tktest-X11";
+ PRODUCT_NAME = Wish;
+ SKIP_INSTALL = NO;
};
- name = ReleaseUniversal10.4uSDK;
+ name = Debug64bit;
};
- F97AED0F0B660AA300310EA2 /* ReleasePPC10.3.9SDK */ = {
+ F97AED1C0B660B2100310EA2 /* Debug64bit */ = {
isa = XCBuildConfiguration;
buildSettings = {
- HEADER_SEARCH_PATHS = (
- /usr/X11R6/include,
- /usr/X11R6/include/freetype2,
- "$(HEADER_SEARCH_PATHS)",
- );
- LIBRARY_SEARCH_PATHS = (
- /usr/X11R6/lib,
- "$(LIBRARY_SEARCH_PATHS)",
+ OTHER_LDFLAGS = (
+ "$(OTHER_LDFLAGS_AQUA)",
+ "$(OTHER_LDFLAGS)",
);
- PRODUCT_NAME = "tktest-X11";
+ PRODUCT_NAME = tktest;
};
- name = ReleasePPC10.3.9SDK;
+ name = Debug64bit;
};
- F97AED160B660AF100310EA2 /* ReleasePPC10.2.8SDK */ = {
+ F97AED1D0B660B2100310EA2 /* Debug64bit */ = {
isa = XCBuildConfiguration;
buildSettings = {
HEADER_SEARCH_PATHS = (
@@ -4988,14 +5073,40 @@
);
PRODUCT_NAME = "tktest-X11";
};
- name = ReleasePPC10.2.8SDK;
+ name = Debug64bit;
+ };
+ F97AED1E0B660B2100310EA2 /* Debug64bit */ = {
+ isa = XCBuildConfiguration;
+ baseConfigurationReference = F97AE8330B65C87F00310EA2 /* Wish-Debug.xcconfig */;
+ buildSettings = {
+ ARCHS = "$(NATIVE_ARCH_64_BIT)";
+ CONFIGURE_ARGS = "--enable-64bit $(CONFIGURE_ARGS)";
+ CPPFLAGS = "-arch $(NATIVE_ARCH_64_BIT) $(CPPFLAGS)";
+ GCC_C_LANGUAGE_STANDARD = gnu99;
+ GCC_ENABLE_OBJC_GC = supported;
+ GCC_ENABLE_PASCAL_STRINGS = NO;
+ GCC_INPUT_FILETYPE = sourcecode.c.objc;
+ MACOSX_DEPLOYMENT_TARGET = 10.5;
+ PREBINDING = NO;
+ };
+ name = Debug64bit;
};
F987512F0DE7B57E00B1C9EC /* DebugNoCF */ = {
isa = XCBuildConfiguration;
baseConfigurationReference = F97AE8330B65C87F00310EA2 /* Wish-Debug.xcconfig */;
buildSettings = {
+ ARCHS = (
+ "$(NATIVE_ARCH_32_BIT)",
+ "$(NATIVE_ARCH_64_BIT)",
+ );
CONFIGURE_ARGS = "$(CONFIGURE_ARGS) --disable-corefoundation";
- MACOSX_DEPLOYMENT_TARGET = 10.2;
+ CPPFLAGS = "-arch $(CURRENT_ARCH) $(CPPFLAGS)";
+ GCC_C_LANGUAGE_STANDARD = gnu99;
+ GCC_ENABLE_OBJC_GC = supported;
+ GCC_ENABLE_PASCAL_STRINGS = NO;
+ GCC_INPUT_FILETYPE = sourcecode.c.objc;
+ MACOSX_DEPLOYMENT_TARGET = 10.5;
+ ONLY_ACTIVE_ARCH = YES;
PREBINDING = NO;
};
name = DebugNoCF;
@@ -5041,8 +5152,18 @@
isa = XCBuildConfiguration;
baseConfigurationReference = F97AE8330B65C87F00310EA2 /* Wish-Debug.xcconfig */;
buildSettings = {
+ ARCHS = (
+ "$(NATIVE_ARCH_32_BIT)",
+ "$(NATIVE_ARCH_64_BIT)",
+ );
CONFIGURE_ARGS = "$(CONFIGURE_ARGS) --disable-threads --disable-corefoundation";
- MACOSX_DEPLOYMENT_TARGET = 10.2;
+ CPPFLAGS = "-arch $(CURRENT_ARCH) $(CPPFLAGS)";
+ GCC_C_LANGUAGE_STANDARD = gnu99;
+ GCC_ENABLE_OBJC_GC = supported;
+ GCC_ENABLE_PASCAL_STRINGS = NO;
+ GCC_INPUT_FILETYPE = sourcecode.c.objc;
+ MACOSX_DEPLOYMENT_TARGET = 10.5;
+ ONLY_ACTIVE_ARCH = YES;
PREBINDING = NO;
};
name = DebugNoCFUnthreaded;
@@ -5084,47 +5205,136 @@
};
name = DebugNoCFUnthreaded;
};
- F99EE73B0BE835310060D4AF /* DebugUnthreaded */ = {
+ F9988AB10D814C6500B6B03B /* Debug gcc42 */ = {
isa = XCBuildConfiguration;
+ baseConfigurationReference = F97AE8330B65C87F00310EA2 /* Wish-Debug.xcconfig */;
buildSettings = {
- PRODUCT_NAME = Wish;
- SKIP_INSTALL = NO;
+ ARCHS = (
+ "$(NATIVE_ARCH_32_BIT)",
+ "$(NATIVE_ARCH_64_BIT)",
+ );
+ CPPFLAGS = "-arch $(CURRENT_ARCH) $(CPPFLAGS)";
+ GCC_C_LANGUAGE_STANDARD = gnu99;
+ GCC_ENABLE_OBJC_GC = supported;
+ GCC_ENABLE_PASCAL_STRINGS = NO;
+ GCC_INPUT_FILETYPE = sourcecode.c.objc;
+ GCC_VERSION = 4.2;
+ MACOSX_DEPLOYMENT_TARGET = 10.5;
+ ONLY_ACTIVE_ARCH = YES;
+ PREBINDING = NO;
};
- name = DebugUnthreaded;
+ name = "Debug gcc42";
};
- F99EE73C0BE835310060D4AF /* DebugLeaks */ = {
+ F9988AB20D814C6500B6B03B /* Debug gcc42 */ = {
isa = XCBuildConfiguration;
buildSettings = {
PRODUCT_NAME = Wish;
SKIP_INSTALL = NO;
};
- name = DebugLeaks;
+ name = "Debug gcc42";
};
- F99EE73D0BE835310060D4AF /* DebugUnthreaded */ = {
+ F9988AB30D814C6500B6B03B /* Debug gcc42 */ = {
isa = XCBuildConfiguration;
buildSettings = {
+ CONFIGURE_ARGS = "tcl_cv_cc_visibility_hidden=no $(CONFIGURE_ARGS)";
+ GCC_DYNAMIC_NO_PIC = NO;
+ GCC_ENABLE_FIX_AND_CONTINUE = YES;
+ GCC_PREPROCESSOR_DEFINITIONS = (
+ "__private_extern__=extern",
+ "$(GCC_PREPROCESSOR_DEFINITIONS)",
+ );
+ GCC_SYMBOLS_PRIVATE_EXTERN = NO;
OTHER_LDFLAGS = (
"$(OTHER_LDFLAGS_AQUA)",
"$(OTHER_LDFLAGS)",
);
PRODUCT_NAME = tktest;
};
- name = DebugUnthreaded;
+ name = "Debug gcc42";
};
- F99EE73E0BE835310060D4AF /* DebugLeaks */ = {
+ F9988AB40D814C6500B6B03B /* Debug gcc42 */ = {
+ isa = XCBuildConfiguration;
+ buildSettings = {
+ CONFIGURE_ARGS = "tcl_cv_cc_visibility_hidden=no $(CONFIGURE_ARGS)";
+ GCC_DYNAMIC_NO_PIC = NO;
+ GCC_ENABLE_FIX_AND_CONTINUE = YES;
+ GCC_PREPROCESSOR_DEFINITIONS = (
+ "__private_extern__=extern",
+ "$(GCC_PREPROCESSOR_DEFINITIONS)",
+ );
+ GCC_SYMBOLS_PRIVATE_EXTERN = NO;
+ HEADER_SEARCH_PATHS = (
+ /usr/X11R6/include,
+ /usr/X11R6/include/freetype2,
+ "$(HEADER_SEARCH_PATHS)",
+ );
+ LIBRARY_SEARCH_PATHS = (
+ /usr/X11R6/lib,
+ "$(LIBRARY_SEARCH_PATHS)",
+ );
+ PRODUCT_NAME = "tktest-X11";
+ };
+ name = "Debug gcc42";
+ };
+ F9988AB50D814C7500B6B03B /* Debug llvmgcc42 */ = {
+ isa = XCBuildConfiguration;
+ baseConfigurationReference = F97AE8330B65C87F00310EA2 /* Wish-Debug.xcconfig */;
+ buildSettings = {
+ ARCHS = (
+ "$(NATIVE_ARCH_32_BIT)",
+ "$(NATIVE_ARCH_64_BIT)",
+ );
+ CC = "$(DEVELOPER_DIR)/usr/bin/llvm-gcc-4.2";
+ CPPFLAGS = "-arch $(CURRENT_ARCH) $(CPPFLAGS)";
+ GCC_C_LANGUAGE_STANDARD = gnu99;
+ GCC_ENABLE_OBJC_GC = supported;
+ GCC_ENABLE_PASCAL_STRINGS = NO;
+ GCC_INPUT_FILETYPE = sourcecode.c.objc;
+ GCC_VERSION = com.apple.compilers.llvmgcc42;
+ MACOSX_DEPLOYMENT_TARGET = 10.5;
+ ONLY_ACTIVE_ARCH = YES;
+ PREBINDING = NO;
+ };
+ name = "Debug llvmgcc42";
+ };
+ F9988AB60D814C7500B6B03B /* Debug llvmgcc42 */ = {
+ isa = XCBuildConfiguration;
+ buildSettings = {
+ PRODUCT_NAME = Wish;
+ SKIP_INSTALL = NO;
+ };
+ name = "Debug llvmgcc42";
+ };
+ F9988AB70D814C7500B6B03B /* Debug llvmgcc42 */ = {
isa = XCBuildConfiguration;
buildSettings = {
+ CONFIGURE_ARGS = "tcl_cv_cc_visibility_hidden=no $(CONFIGURE_ARGS)";
+ GCC_DYNAMIC_NO_PIC = NO;
+ GCC_ENABLE_FIX_AND_CONTINUE = YES;
+ GCC_PREPROCESSOR_DEFINITIONS = (
+ "__private_extern__=extern",
+ "$(GCC_PREPROCESSOR_DEFINITIONS)",
+ );
+ GCC_SYMBOLS_PRIVATE_EXTERN = NO;
OTHER_LDFLAGS = (
"$(OTHER_LDFLAGS_AQUA)",
"$(OTHER_LDFLAGS)",
);
PRODUCT_NAME = tktest;
};
- name = DebugLeaks;
+ name = "Debug llvmgcc42";
};
- F99EE73F0BE835310060D4AF /* DebugUnthreaded */ = {
+ F9988AB80D814C7500B6B03B /* Debug llvmgcc42 */ = {
isa = XCBuildConfiguration;
buildSettings = {
+ CONFIGURE_ARGS = "tcl_cv_cc_visibility_hidden=no $(CONFIGURE_ARGS)";
+ GCC_DYNAMIC_NO_PIC = NO;
+ GCC_ENABLE_FIX_AND_CONTINUE = YES;
+ GCC_PREPROCESSOR_DEFINITIONS = (
+ "__private_extern__=extern",
+ "$(GCC_PREPROCESSOR_DEFINITIONS)",
+ );
+ GCC_SYMBOLS_PRIVATE_EXTERN = NO;
HEADER_SEARCH_PATHS = (
/usr/X11R6/include,
/usr/X11R6/include/freetype2,
@@ -5136,11 +5346,48 @@
);
PRODUCT_NAME = "tktest-X11";
};
- name = DebugUnthreaded;
+ name = "Debug llvmgcc42";
};
- F99EE7400BE835310060D4AF /* DebugLeaks */ = {
+ F9988BB10D81586D00B6B03B /* ReleaseUniversal gcc42 */ = {
isa = XCBuildConfiguration;
+ baseConfigurationReference = F97AE82B0B65C69B00310EA2 /* Wish-Release.xcconfig */;
buildSettings = {
+ ARCHS = "$(ARCHS_STANDARD_32_64_BIT)";
+ CFLAGS = "-arch i386 -arch x86_64 -arch ppc $(CFLAGS)";
+ GCC_C_LANGUAGE_STANDARD = gnu99;
+ GCC_ENABLE_OBJC_GC = supported;
+ GCC_ENABLE_PASCAL_STRINGS = NO;
+ GCC_INPUT_FILETYPE = sourcecode.c.objc;
+ GCC_VERSION = 4.2;
+ MACOSX_DEPLOYMENT_TARGET = 10.5;
+ PREBINDING = NO;
+ };
+ name = "ReleaseUniversal gcc42";
+ };
+ F9988BB20D81586D00B6B03B /* ReleaseUniversal gcc42 */ = {
+ isa = XCBuildConfiguration;
+ buildSettings = {
+ PRODUCT_NAME = Wish;
+ SKIP_INSTALL = NO;
+ };
+ name = "ReleaseUniversal gcc42";
+ };
+ F9988BB30D81586D00B6B03B /* ReleaseUniversal gcc42 */ = {
+ isa = XCBuildConfiguration;
+ buildSettings = {
+ OTHER_LDFLAGS = (
+ "$(OTHER_LDFLAGS_AQUA)",
+ "$(OTHER_LDFLAGS)",
+ );
+ PRODUCT_NAME = tktest;
+ };
+ name = "ReleaseUniversal gcc42";
+ };
+ F9988BB40D81586D00B6B03B /* ReleaseUniversal gcc42 */ = {
+ isa = XCBuildConfiguration;
+ buildSettings = {
+ ARCHS = "$(ARCHS_STANDARD_32_64_BIT)";
+ CFLAGS = "-arch i386 -arch x86_64 -arch ppc $(CFLAGS)";
HEADER_SEARCH_PATHS = (
/usr/X11R6/include,
/usr/X11R6/include/freetype2,
@@ -5152,40 +5399,37 @@
);
PRODUCT_NAME = "tktest-X11";
};
- name = DebugLeaks;
+ name = "ReleaseUniversal gcc42";
};
- F99EE7410BE835310060D4AF /* DebugUnthreaded */ = {
+ F9988BB50D81587400B6B03B /* ReleaseUniversal llvmgcc42 */ = {
isa = XCBuildConfiguration;
- baseConfigurationReference = F97AE8330B65C87F00310EA2 /* Wish-Debug.xcconfig */;
- buildSettings = {
- CONFIGURE_ARGS = "$(CONFIGURE_ARGS) --disable-threads";
- MACOSX_DEPLOYMENT_TARGET = 10.2;
- PREBINDING = NO;
- };
- name = DebugUnthreaded;
- };
- F99EE7420BE835310060D4AF /* DebugLeaks */ = {
- isa = XCBuildConfiguration;
- baseConfigurationReference = F97AE8330B65C87F00310EA2 /* Wish-Debug.xcconfig */;
+ baseConfigurationReference = F97AE82B0B65C69B00310EA2 /* Wish-Release.xcconfig */;
buildSettings = {
- GCC_PREPROCESSOR_DEFINITIONS = (
- PURIFY,
- "$(GCC_PREPROCESSOR_DEFINITIONS)",
- );
- MACOSX_DEPLOYMENT_TARGET = 10.2;
+ ARCHS = "$(ARCHS_STANDARD_32_64_BIT)";
+ CC = "$(DEVELOPER_DIR)/usr/bin/llvm-gcc-4.2";
+ CFLAGS = "-arch i386 -arch x86_64 -arch ppc $(CFLAGS)";
+ DEBUG_INFORMATION_FORMAT = dwarf;
+ GCC_C_LANGUAGE_STANDARD = gnu99;
+ GCC_ENABLE_OBJC_GC = supported;
+ GCC_ENABLE_PASCAL_STRINGS = NO;
+ GCC_INPUT_FILETYPE = sourcecode.c.objc;
+ GCC_OPTIMIZATION_LEVEL = 4;
+ GCC_VERSION = com.apple.compilers.llvmgcc42;
+ MACOSX_DEPLOYMENT_TARGET = 10.5;
PREBINDING = NO;
+ TCL_CONFIGURE_ARGS = "$(TCL_CONFIGURE_ARGS) --disable-dtrace";
};
- name = DebugLeaks;
+ name = "ReleaseUniversal llvmgcc42";
};
- F9DB62080B65ADA800A370FB /* ReleaseUniversal10.4uSDK */ = {
+ F9988BB60D81587400B6B03B /* ReleaseUniversal llvmgcc42 */ = {
isa = XCBuildConfiguration;
buildSettings = {
PRODUCT_NAME = Wish;
SKIP_INSTALL = NO;
};
- name = ReleaseUniversal10.4uSDK;
+ name = "ReleaseUniversal llvmgcc42";
};
- F9DB62090B65ADA800A370FB /* ReleaseUniversal10.4uSDK */ = {
+ F9988BB70D81587400B6B03B /* ReleaseUniversal llvmgcc42 */ = {
isa = XCBuildConfiguration;
buildSettings = {
OTHER_LDFLAGS = (
@@ -5194,34 +5438,43 @@
);
PRODUCT_NAME = tktest;
};
- name = ReleaseUniversal10.4uSDK;
+ name = "ReleaseUniversal llvmgcc42";
};
- F9DB620A0B65ADA800A370FB /* ReleaseUniversal10.4uSDK */ = {
+ F9988BB80D81587400B6B03B /* ReleaseUniversal llvmgcc42 */ = {
isa = XCBuildConfiguration;
- baseConfigurationReference = F97AE82B0B65C69B00310EA2 /* Wish-Release.xcconfig */;
buildSettings = {
- ARCHS = (
- ppc,
- i386,
+ ARCHS = "$(ARCHS_STANDARD_32_64_BIT)";
+ CFLAGS = "-arch i386 -arch x86_64 -arch ppc $(CFLAGS)";
+ HEADER_SEARCH_PATHS = (
+ /usr/X11R6/include,
+ /usr/X11R6/include/freetype2,
+ "$(HEADER_SEARCH_PATHS)",
);
- CFLAGS = "-arch ppc -arch i386 $(CFLAGS)";
- CPPFLAGS = "-isysroot $(SDKROOT) $(CPPFLAGS)";
- MACOSX_DEPLOYMENT_TARGET = 10.4;
- PREBINDING = NO;
- SDKROOT = /Developer/SDKs/MacOSX10.4u.sdk;
+ LIBRARY_SEARCH_PATHS = (
+ /usr/X11R6/lib,
+ "$(LIBRARY_SEARCH_PATHS)",
+ );
+ PRODUCT_NAME = "tktest-X11";
+ };
+ name = "ReleaseUniversal llvmgcc42";
+ };
+ F99EE73B0BE835310060D4AF /* DebugUnthreaded */ = {
+ isa = XCBuildConfiguration;
+ buildSettings = {
+ PRODUCT_NAME = Wish;
+ SKIP_INSTALL = NO;
};
- name = ReleaseUniversal10.4uSDK;
+ name = DebugUnthreaded;
};
- F9DB621F0B65AFDE00A370FB /* ReleasePPC10.3.9SDK */ = {
+ F99EE73C0BE835310060D4AF /* DebugLeaks */ = {
isa = XCBuildConfiguration;
buildSettings = {
- LDFLAGS = "-force_cpusubtype_ALL $(LDFLAGS)";
PRODUCT_NAME = Wish;
SKIP_INSTALL = NO;
};
- name = ReleasePPC10.3.9SDK;
+ name = DebugLeaks;
};
- F9DB62200B65AFDE00A370FB /* ReleasePPC10.3.9SDK */ = {
+ F99EE73D0BE835310060D4AF /* DebugUnthreaded */ = {
isa = XCBuildConfiguration;
buildSettings = {
OTHER_LDFLAGS = (
@@ -5230,30 +5483,103 @@
);
PRODUCT_NAME = tktest;
};
- name = ReleasePPC10.3.9SDK;
+ name = DebugUnthreaded;
};
- F9DB62210B65AFDE00A370FB /* ReleasePPC10.3.9SDK */ = {
+ F99EE73E0BE835310060D4AF /* DebugLeaks */ = {
isa = XCBuildConfiguration;
- baseConfigurationReference = F97AE82B0B65C69B00310EA2 /* Wish-Release.xcconfig */;
buildSettings = {
- ARCHS = ppc;
- CFLAGS = "$(PER_ARCH_CFLAGS_ppc) $(CFLAGS)";
- CPPFLAGS = "-arch ppc -isysroot $(SDKROOT) $(CPPFLAGS)";
- MACOSX_DEPLOYMENT_TARGET = 10.3;
- PREBINDING = YES;
- SDKROOT = /Developer/SDKs/MacOSX10.3.9.sdk;
+ OTHER_LDFLAGS = (
+ "$(OTHER_LDFLAGS_AQUA)",
+ "$(OTHER_LDFLAGS)",
+ );
+ PRODUCT_NAME = tktest;
};
- name = ReleasePPC10.3.9SDK;
+ name = DebugLeaks;
};
- F9DB62350B65B03A00A370FB /* ReleasePPC10.2.8SDK */ = {
+ F99EE73F0BE835310060D4AF /* DebugUnthreaded */ = {
+ isa = XCBuildConfiguration;
+ buildSettings = {
+ HEADER_SEARCH_PATHS = (
+ /usr/X11R6/include,
+ /usr/X11R6/include/freetype2,
+ "$(HEADER_SEARCH_PATHS)",
+ );
+ LIBRARY_SEARCH_PATHS = (
+ /usr/X11R6/lib,
+ "$(LIBRARY_SEARCH_PATHS)",
+ );
+ PRODUCT_NAME = "tktest-X11";
+ };
+ name = DebugUnthreaded;
+ };
+ F99EE7400BE835310060D4AF /* DebugLeaks */ = {
+ isa = XCBuildConfiguration;
+ buildSettings = {
+ HEADER_SEARCH_PATHS = (
+ /usr/X11R6/include,
+ /usr/X11R6/include/freetype2,
+ "$(HEADER_SEARCH_PATHS)",
+ );
+ LIBRARY_SEARCH_PATHS = (
+ /usr/X11R6/lib,
+ "$(LIBRARY_SEARCH_PATHS)",
+ );
+ PRODUCT_NAME = "tktest-X11";
+ };
+ name = DebugLeaks;
+ };
+ F99EE7410BE835310060D4AF /* DebugUnthreaded */ = {
+ isa = XCBuildConfiguration;
+ baseConfigurationReference = F97AE8330B65C87F00310EA2 /* Wish-Debug.xcconfig */;
+ buildSettings = {
+ ARCHS = (
+ "$(NATIVE_ARCH_32_BIT)",
+ "$(NATIVE_ARCH_64_BIT)",
+ );
+ CONFIGURE_ARGS = "$(CONFIGURE_ARGS) --disable-threads";
+ CPPFLAGS = "-arch $(CURRENT_ARCH) $(CPPFLAGS)";
+ GCC_C_LANGUAGE_STANDARD = gnu99;
+ GCC_ENABLE_OBJC_GC = supported;
+ GCC_ENABLE_PASCAL_STRINGS = NO;
+ GCC_INPUT_FILETYPE = sourcecode.c.objc;
+ MACOSX_DEPLOYMENT_TARGET = 10.5;
+ ONLY_ACTIVE_ARCH = YES;
+ PREBINDING = NO;
+ };
+ name = DebugUnthreaded;
+ };
+ F99EE7420BE835310060D4AF /* DebugLeaks */ = {
+ isa = XCBuildConfiguration;
+ baseConfigurationReference = F97AE8330B65C87F00310EA2 /* Wish-Debug.xcconfig */;
+ buildSettings = {
+ ARCHS = (
+ "$(NATIVE_ARCH_32_BIT)",
+ "$(NATIVE_ARCH_64_BIT)",
+ );
+ CPPFLAGS = "-arch $(CURRENT_ARCH) $(CPPFLAGS)";
+ GCC_C_LANGUAGE_STANDARD = gnu99;
+ GCC_ENABLE_OBJC_GC = unsupported;
+ GCC_ENABLE_PASCAL_STRINGS = NO;
+ GCC_INPUT_FILETYPE = sourcecode.c.objc;
+ GCC_PREPROCESSOR_DEFINITIONS = (
+ PURIFY,
+ "$(GCC_PREPROCESSOR_DEFINITIONS)",
+ );
+ MACOSX_DEPLOYMENT_TARGET = 10.5;
+ ONLY_ACTIVE_ARCH = YES;
+ PREBINDING = NO;
+ };
+ name = DebugLeaks;
+ };
+ F9EEED960C2FEFD300396116 /* ReleaseUniversal10.5SDK */ = {
isa = XCBuildConfiguration;
buildSettings = {
PRODUCT_NAME = Wish;
SKIP_INSTALL = NO;
};
- name = ReleasePPC10.2.8SDK;
+ name = ReleaseUniversal10.5SDK;
};
- F9DB62360B65B03A00A370FB /* ReleasePPC10.2.8SDK */ = {
+ F9EEED970C2FEFD300396116 /* ReleaseUniversal10.5SDK */ = {
isa = XCBuildConfiguration;
buildSettings = {
OTHER_LDFLAGS = (
@@ -5262,28 +5588,42 @@
);
PRODUCT_NAME = tktest;
};
- name = ReleasePPC10.2.8SDK;
+ name = ReleaseUniversal10.5SDK;
};
- F9DB62370B65B03A00A370FB /* ReleasePPC10.2.8SDK */ = {
+ F9EEED980C2FEFD300396116 /* ReleaseUniversal10.5SDK */ = {
isa = XCBuildConfiguration;
- baseConfigurationReference = F97AE82B0B65C69B00310EA2 /* Wish-Release.xcconfig */;
buildSettings = {
- ARCHS = ppc;
- CFLAGS = "$(PER_ARCH_CFLAGS_ppc) -fconstant-cfstrings $(CFLAGS)";
- CPPFLAGS = "-arch ppc -D__CONSTANT_CFSTRINGS__ -DMAC_OS_X_VERSION_MIN_REQUIRED=1020 -nostdinc -isystem $(SDKROOT)/usr/include/gcc/darwin/$(GCC_VERSION) -isystem $(SDKROOT)/usr/include -F$(SDKROOT)/System/Library/Frameworks";
- DEBUG_INFORMATION_FORMAT = stabs;
- GCC = /usr/bin/gcc;
- GCC_VERSION = 3.3;
- LDFLAGS = "-L$(SDKROOT)/usr/lib/gcc/darwin/$(GCC_VERSION) -Wl,-syslibroot,$(SDKROOT)";
- MACOSX_DEPLOYMENT_TARGET = 10.2;
- PREBINDING = YES;
- SDKROOT = /Developer/SDKs/MacOSX10.2.8.sdk;
- WARNING_CFLAGS = (
- "$(WARNING_CFLAGS_GCC3)",
- "-Wno-long-double",
+ ARCHS = "$(ARCHS_STANDARD_32_64_BIT)";
+ CFLAGS = "-arch i386 -arch x86_64 -arch ppc $(CFLAGS)";
+ HEADER_SEARCH_PATHS = (
+ /usr/X11R6/include,
+ /usr/X11R6/include/freetype2,
+ "$(HEADER_SEARCH_PATHS)",
);
+ LIBRARY_SEARCH_PATHS = (
+ /usr/X11R6/lib,
+ "$(LIBRARY_SEARCH_PATHS)",
+ );
+ PRODUCT_NAME = "tktest-X11";
+ };
+ name = ReleaseUniversal10.5SDK;
+ };
+ F9EEED990C2FEFD300396116 /* ReleaseUniversal10.5SDK */ = {
+ isa = XCBuildConfiguration;
+ baseConfigurationReference = F97AE82B0B65C69B00310EA2 /* Wish-Release.xcconfig */;
+ buildSettings = {
+ ARCHS = "$(ARCHS_STANDARD_32_64_BIT)";
+ CFLAGS = "-arch i386 -arch x86_64 -arch ppc $(CFLAGS)";
+ CPPFLAGS = "-isysroot $(SDKROOT) $(CPPFLAGS)";
+ GCC_C_LANGUAGE_STANDARD = gnu99;
+ GCC_ENABLE_OBJC_GC = supported;
+ GCC_ENABLE_PASCAL_STRINGS = NO;
+ GCC_INPUT_FILETYPE = sourcecode.c.objc;
+ MACOSX_DEPLOYMENT_TARGET = 10.5;
+ PREBINDING = NO;
+ SDKROOT = macosx10.5;
};
- name = ReleasePPC10.2.8SDK;
+ name = ReleaseUniversal10.5SDK;
};
/* End XCBuildConfiguration section */
@@ -5292,6 +5632,9 @@
isa = XCConfigurationList;
buildConfigurations = (
F95CC8AC09158F3100EA5ACE /* Debug */,
+ F9988AB20D814C6500B6B03B /* Debug gcc42 */,
+ F90E36D60F3B5C8400810A10 /* Debug gcc42 nogc */,
+ F9988AB60D814C7500B6B03B /* Debug llvmgcc42 */,
F95CC8AE09158F3100EA5ACE /* DebugNoFixZL */,
F99EE73B0BE835310060D4AF /* DebugUnthreaded */,
F98751300DE7B57E00B1C9EC /* DebugNoCF */,
@@ -5299,11 +5642,12 @@
F93084370BB93D2800CD0B9E /* DebugMemCompile */,
F99EE73C0BE835310060D4AF /* DebugLeaks */,
F9359B260DF212DA00E04F67 /* DebugGCov */,
+ F97AED1B0B660B2100310EA2 /* Debug64bit */,
F95CC8AD09158F3100EA5ACE /* Release */,
F91BCC4F093152310042A6BF /* ReleaseUniversal */,
- F9DB62080B65ADA800A370FB /* ReleaseUniversal10.4uSDK */,
- F9DB621F0B65AFDE00A370FB /* ReleasePPC10.3.9SDK */,
- F9DB62350B65B03A00A370FB /* ReleasePPC10.2.8SDK */,
+ F9988BB20D81586D00B6B03B /* ReleaseUniversal gcc42 */,
+ F9988BB60D81587400B6B03B /* ReleaseUniversal llvmgcc42 */,
+ F9EEED960C2FEFD300396116 /* ReleaseUniversal10.5SDK */,
);
defaultConfigurationIsVisible = 0;
defaultConfigurationName = Debug;
@@ -5312,6 +5656,9 @@
isa = XCConfigurationList;
buildConfigurations = (
F95CC8B109158F3100EA5ACE /* Debug */,
+ F9988AB30D814C6500B6B03B /* Debug gcc42 */,
+ F90E36D70F3B5C8400810A10 /* Debug gcc42 nogc */,
+ F9988AB70D814C7500B6B03B /* Debug llvmgcc42 */,
F95CC8B309158F3100EA5ACE /* DebugNoFixZL */,
F99EE73D0BE835310060D4AF /* DebugUnthreaded */,
F98751310DE7B57E00B1C9EC /* DebugNoCF */,
@@ -5319,11 +5666,12 @@
F93084380BB93D2800CD0B9E /* DebugMemCompile */,
F99EE73E0BE835310060D4AF /* DebugLeaks */,
F9359B270DF212DA00E04F67 /* DebugGCov */,
+ F97AED1C0B660B2100310EA2 /* Debug64bit */,
F95CC8B209158F3100EA5ACE /* Release */,
F91BCC50093152310042A6BF /* ReleaseUniversal */,
- F9DB62090B65ADA800A370FB /* ReleaseUniversal10.4uSDK */,
- F9DB62200B65AFDE00A370FB /* ReleasePPC10.3.9SDK */,
- F9DB62360B65B03A00A370FB /* ReleasePPC10.2.8SDK */,
+ F9988BB30D81586D00B6B03B /* ReleaseUniversal gcc42 */,
+ F9988BB70D81587400B6B03B /* ReleaseUniversal llvmgcc42 */,
+ F9EEED970C2FEFD300396116 /* ReleaseUniversal10.5SDK */,
);
defaultConfigurationIsVisible = 0;
defaultConfigurationName = Debug;
@@ -5332,6 +5680,9 @@
isa = XCConfigurationList;
buildConfigurations = (
F95CC8B609158F3100EA5ACE /* Debug */,
+ F9988AB10D814C6500B6B03B /* Debug gcc42 */,
+ F90E36D50F3B5C8400810A10 /* Debug gcc42 nogc */,
+ F9988AB50D814C7500B6B03B /* Debug llvmgcc42 */,
F95CC8B809158F3100EA5ACE /* DebugNoFixZL */,
F99EE7410BE835310060D4AF /* DebugUnthreaded */,
F987512F0DE7B57E00B1C9EC /* DebugNoCF */,
@@ -5339,11 +5690,12 @@
F930843A0BB93D2800CD0B9E /* DebugMemCompile */,
F99EE7420BE835310060D4AF /* DebugLeaks */,
F9359B250DF212DA00E04F67 /* DebugGCov */,
+ F97AED1E0B660B2100310EA2 /* Debug64bit */,
F95CC8B709158F3100EA5ACE /* Release */,
F91BCC51093152310042A6BF /* ReleaseUniversal */,
- F9DB620A0B65ADA800A370FB /* ReleaseUniversal10.4uSDK */,
- F9DB62210B65AFDE00A370FB /* ReleasePPC10.3.9SDK */,
- F9DB62370B65B03A00A370FB /* ReleasePPC10.2.8SDK */,
+ F9988BB10D81586D00B6B03B /* ReleaseUniversal gcc42 */,
+ F9988BB50D81587400B6B03B /* ReleaseUniversal llvmgcc42 */,
+ F9EEED990C2FEFD300396116 /* ReleaseUniversal10.5SDK */,
);
defaultConfigurationIsVisible = 0;
defaultConfigurationName = Debug;
@@ -5352,6 +5704,9 @@
isa = XCConfigurationList;
buildConfigurations = (
F97258A90A86873D00096C78 /* Debug */,
+ F9988AB40D814C6500B6B03B /* Debug gcc42 */,
+ F90E36D80F3B5C8400810A10 /* Debug gcc42 nogc */,
+ F9988AB80D814C7500B6B03B /* Debug llvmgcc42 */,
F97258AB0A86873D00096C78 /* DebugNoFixZL */,
F99EE73F0BE835310060D4AF /* DebugUnthreaded */,
F98751320DE7B57E00B1C9EC /* DebugNoCF */,
@@ -5359,11 +5714,12 @@
F93084390BB93D2800CD0B9E /* DebugMemCompile */,
F99EE7400BE835310060D4AF /* DebugLeaks */,
F9359B280DF212DA00E04F67 /* DebugGCov */,
+ F97AED1D0B660B2100310EA2 /* Debug64bit */,
F97258AA0A86873D00096C78 /* Release */,
F97258AC0A86873D00096C78 /* ReleaseUniversal */,
- F97AED080B660A6C00310EA2 /* ReleaseUniversal10.4uSDK */,
- F97AED0F0B660AA300310EA2 /* ReleasePPC10.3.9SDK */,
- F97AED160B660AF100310EA2 /* ReleasePPC10.2.8SDK */,
+ F9988BB40D81586D00B6B03B /* ReleaseUniversal gcc42 */,
+ F9988BB80D81587400B6B03B /* ReleaseUniversal llvmgcc42 */,
+ F9EEED980C2FEFD300396116 /* ReleaseUniversal10.5SDK */,
);
defaultConfigurationIsVisible = 0;
defaultConfigurationName = Debug;
diff --git a/macosx/Wish.xcodeproj/default.pbxuser b/macosx/Wish.xcodeproj/default.pbxuser
index cd9a9a6..188bbeb 100644
--- a/macosx/Wish.xcodeproj/default.pbxuser
+++ b/macosx/Wish.xcodeproj/default.pbxuser
@@ -15,8 +15,6 @@
};
sourceControlManager = F944EB9C08F798180049FDD4 /* Source Control */;
userBuildSettings = {
- AUTOCONF = "/usr/local/bin/autoconf-2.59";
- AUTOHEADER = "/usr/local/bin/autoheader-2.59";
CODE_SIGN_IDENTITY = "";
SYMROOT = "${SRCROOT}/../../build/tk";
TCL_SRCROOT = "${SRCROOT}/../../tcl";
@@ -97,6 +95,11 @@
value = /Library/Tcl;
},
{
+ active = YES;
+ name = TK_SRCROOT;
+ value = "${TK_SRCROOT}";
+ },
+ {
active = NO;
name = DYLD_PRINT_LIBRARIES;
},
diff --git a/macosx/Wish.xcodeproj/project.pbxproj b/macosx/Wish.xcodeproj/project.pbxproj
index fe78b0b..d38f46d 100644
--- a/macosx/Wish.xcodeproj/project.pbxproj
+++ b/macosx/Wish.xcodeproj/project.pbxproj
@@ -3,11 +3,12 @@
archiveVersion = 1;
classes = {
};
- objectVersion = 45;
+ objectVersion = 46;
objects = {
/* Begin PBXBuildFile section */
F9067BCD0BFBA2900074F726 /* tkOldTest.c in Sources */ = {isa = PBXBuildFile; fileRef = F966BAFE08F27A39005CB29B /* tkOldTest.c */; };
+ F94523A20E6FC2AC00C1D987 /* Cocoa.framework in Frameworks */ = {isa = PBXBuildFile; fileRef = F94523A10E6FC2AC00C1D987 /* Cocoa.framework */; };
F966BDCF08F27A3F005CB29B /* tk3d.c in Sources */ = {isa = PBXBuildFile; fileRef = F966BAAC08F27A39005CB29B /* tk3d.c */; };
F966BDD108F27A3F005CB29B /* tkArgv.c in Sources */ = {isa = PBXBuildFile; fileRef = F966BAAE08F27A39005CB29B /* tkArgv.c */; };
F966BDD208F27A3F005CB29B /* tkAtom.c in Sources */ = {isa = PBXBuildFile; fileRef = F966BAAF08F27A39005CB29B /* tkAtom.c */; };
@@ -85,7 +86,6 @@
F966BE3508F27A40005CB29B /* tkWindow.c in Sources */ = {isa = PBXBuildFile; fileRef = F966BB1208F27A39005CB29B /* tkWindow.c */; };
F966BEDB08F27A40005CB29B /* tkMacOSXBitmap.c in Sources */ = {isa = PBXBuildFile; fileRef = F966BBC508F27A3B005CB29B /* tkMacOSXBitmap.c */; };
F966BEDC08F27A40005CB29B /* tkMacOSXButton.c in Sources */ = {isa = PBXBuildFile; fileRef = F966BBC608F27A3B005CB29B /* tkMacOSXButton.c */; };
- F966BEDD08F27A40005CB29B /* tkMacOSXCarbonEvents.c in Sources */ = {isa = PBXBuildFile; fileRef = F966BBC708F27A3B005CB29B /* tkMacOSXCarbonEvents.c */; };
F966BEDE08F27A40005CB29B /* tkMacOSXClipboard.c in Sources */ = {isa = PBXBuildFile; fileRef = F966BBC808F27A3B005CB29B /* tkMacOSXClipboard.c */; };
F966BEDF08F27A40005CB29B /* tkMacOSXColor.c in Sources */ = {isa = PBXBuildFile; fileRef = F966BBC908F27A3B005CB29B /* tkMacOSXColor.c */; };
F966BEE008F27A40005CB29B /* tkMacOSXConfig.c in Sources */ = {isa = PBXBuildFile; fileRef = F966BBCA08F27A3B005CB29B /* tkMacOSXConfig.c */; };
@@ -281,7 +281,7 @@
F96D49A908F272C4004A47F5 /* tclMacOSXBundle.c in Sources */ = {isa = PBXBuildFile; fileRef = F96D433908F272B5004A47F5 /* tclMacOSXBundle.c */; };
F96D49AD08F272C4004A47F5 /* tclMacOSXFCmd.c in Sources */ = {isa = PBXBuildFile; fileRef = F96D433D08F272B5004A47F5 /* tclMacOSXFCmd.c */; };
F96D49AE08F272C4004A47F5 /* tclMacOSXNotify.c in Sources */ = {isa = PBXBuildFile; fileRef = F96D433E08F272B5004A47F5 /* tclMacOSXNotify.c */; };
- F96D4AC608F272C9004A47F5 /* tclLoadDyld.c in Sources */ = {isa = PBXBuildFile; fileRef = F96D445B08F272B9004A47F5 /* tclLoadDyld.c */; };
+ F96D4AC608F272C9004A47F5 /* tclLoadDyld.c in Sources */ = {isa = PBXBuildFile; fileRef = F96D445B08F272B9004A47F5 /* tclLoadDyld.c */; settings = {COMPILER_FLAGS = "-Wno-deprecated-declarations"; }; };
F96D4ACA08F272C9004A47F5 /* tclUnixChan.c in Sources */ = {isa = PBXBuildFile; fileRef = F96D445F08F272B9004A47F5 /* tclUnixChan.c */; };
F96D4ACB08F272C9004A47F5 /* tclUnixEvent.c in Sources */ = {isa = PBXBuildFile; fileRef = F96D446008F272B9004A47F5 /* tclUnixEvent.c */; };
F96D4ACC08F272C9004A47F5 /* tclUnixFCmd.c in Sources */ = {isa = PBXBuildFile; fileRef = F96D446108F272B9004A47F5 /* tclUnixFCmd.c */; };
@@ -292,6 +292,7 @@
F96D4AD208F272CA004A47F5 /* tclUnixSock.c in Sources */ = {isa = PBXBuildFile; fileRef = F96D446708F272B9004A47F5 /* tclUnixSock.c */; };
F96D4AD408F272CA004A47F5 /* tclUnixThrd.c in Sources */ = {isa = PBXBuildFile; fileRef = F96D446908F272B9004A47F5 /* tclUnixThrd.c */; };
F96D4AD608F272CA004A47F5 /* tclUnixTime.c in Sources */ = {isa = PBXBuildFile; fileRef = F96D446B08F272B9004A47F5 /* tclUnixTime.c */; };
+ F9C9CC000E84059800E00935 /* ApplicationServices.framework in Frameworks */ = {isa = PBXBuildFile; fileRef = F9C9CBFF0E84059800E00935 /* ApplicationServices.framework */; };
F9E61D28090A481F002B3151 /* bn_mp_cmp_d.c in Sources */ = {isa = PBXBuildFile; fileRef = F96D427108F272B3004A47F5 /* bn_mp_cmp_d.c */; };
F9E61D29090A486C002B3151 /* bn_mp_neg.c in Sources */ = {isa = PBXBuildFile; fileRef = F96D42A208F272B3004A47F5 /* bn_mp_neg.c */; };
F9E61D2A090A4891002B3151 /* bn_mp_sqrt.c in Sources */ = {isa = PBXBuildFile; fileRef = F96D42C008F272B3004A47F5 /* bn_mp_sqrt.c */; };
@@ -303,10 +304,6 @@
F9E61D30090A48E2002B3151 /* bn_mp_to_unsigned_bin_n.c in Sources */ = {isa = PBXBuildFile; fileRef = F96D42C708F272B3004A47F5 /* bn_mp_to_unsigned_bin_n.c */; };
F9E61D31090A48F9002B3151 /* bn_mp_to_unsigned_bin.c in Sources */ = {isa = PBXBuildFile; fileRef = F96D42C608F272B3004A47F5 /* bn_mp_to_unsigned_bin.c */; };
F9E61D32090A48FA002B3151 /* bn_mp_unsigned_bin_size.c in Sources */ = {isa = PBXBuildFile; fileRef = F96D42CC08F272B3004A47F5 /* bn_mp_unsigned_bin_size.c */; };
- F9EA4AF008FA3BD500B1F5F0 /* tkMacOSXXCursors.r in Rez */ = {isa = PBXBuildFile; fileRef = F966BBF408F27A3C005CB29B /* tkMacOSXXCursors.r */; };
- F9EA4AF208FA3BD800B1F5F0 /* tkMacOSXCursors.r in Rez */ = {isa = PBXBuildFile; fileRef = F966BBCC08F27A3B005CB29B /* tkMacOSXCursors.r */; };
- F9EA4AF308FA3BDA00B1F5F0 /* tkMacOSXAETE.r in Rez */ = {isa = PBXBuildFile; fileRef = F966BBC408F27A3B005CB29B /* tkMacOSXAETE.r */; };
- F9EA4AF408FA3BDB00B1F5F0 /* tkAboutDlg.r in Rez */ = {isa = PBXBuildFile; fileRef = F966BBC108F27A3B005CB29B /* tkAboutDlg.r */; };
F9F4415E0C8BAE6F00BCCD67 /* tclDTrace.d in Sources */ = {isa = PBXBuildFile; fileRef = F9F4415D0C8BAE6F00BCCD67 /* tclDTrace.d */; };
F9FC77B80AB29E9100B7077D /* tclUnixCompat.c in Sources */ = {isa = PBXBuildFile; fileRef = F9FC77B70AB29E9100B7077D /* tclUnixCompat.c */; };
F9FD30BC0CC1AD070073837D /* regcomp.c in Sources */ = {isa = PBXBuildFile; fileRef = F96D3ED008F272A7004A47F5 /* regcomp.c */; };
@@ -444,7 +441,7 @@
F9FD31400CC1AD070073837D /* tclMacOSXBundle.c in Sources */ = {isa = PBXBuildFile; fileRef = F96D433908F272B5004A47F5 /* tclMacOSXBundle.c */; };
F9FD31410CC1AD070073837D /* tclMacOSXFCmd.c in Sources */ = {isa = PBXBuildFile; fileRef = F96D433D08F272B5004A47F5 /* tclMacOSXFCmd.c */; };
F9FD31420CC1AD070073837D /* tclMacOSXNotify.c in Sources */ = {isa = PBXBuildFile; fileRef = F96D433E08F272B5004A47F5 /* tclMacOSXNotify.c */; };
- F9FD31430CC1AD070073837D /* tclLoadDyld.c in Sources */ = {isa = PBXBuildFile; fileRef = F96D445B08F272B9004A47F5 /* tclLoadDyld.c */; };
+ F9FD31430CC1AD070073837D /* tclLoadDyld.c in Sources */ = {isa = PBXBuildFile; fileRef = F96D445B08F272B9004A47F5 /* tclLoadDyld.c */; settings = {COMPILER_FLAGS = "-Wno-deprecated-declarations"; }; };
F9FD31440CC1AD070073837D /* tclUnixChan.c in Sources */ = {isa = PBXBuildFile; fileRef = F96D445F08F272B9004A47F5 /* tclUnixChan.c */; };
F9FD31450CC1AD070073837D /* tclUnixCompat.c in Sources */ = {isa = PBXBuildFile; fileRef = F9FC77B70AB29E9100B7077D /* tclUnixCompat.c */; };
F9FD31460CC1AD070073837D /* tclUnixEvent.c in Sources */ = {isa = PBXBuildFile; fileRef = F96D446008F272B9004A47F5 /* tclUnixEvent.c */; };
@@ -607,6 +604,9 @@
F936FCDA0CCD984600716967 /* ttknote.tcl */ = {isa = PBXFileReference; explicitFileType = text.script; fileEncoding = 4; path = ttknote.tcl; sourceTree = "<group>"; };
F936FCDB0CCD984600716967 /* combo.tcl */ = {isa = PBXFileReference; explicitFileType = text.script; fileEncoding = 4; path = combo.tcl; sourceTree = "<group>"; };
F93E5EFD09CF8711008FA367 /* tkMacOSXFont.h */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.h; path = tkMacOSXFont.h; sourceTree = "<group>"; };
+ F94523A10E6FC2AC00C1D987 /* Cocoa.framework */ = {isa = PBXFileReference; lastKnownFileType = wrapper.framework; name = Cocoa.framework; path = /System/Library/Frameworks/Cocoa.framework; sourceTree = "<absolute>"; };
+ F95D8D4B0F1715610006B020 /* Tk.icns */ = {isa = PBXFileReference; lastKnownFileType = image.icns; path = Tk.icns; sourceTree = "<group>"; };
+ F95D8D4C0F1715610006B020 /* Tk.tiff */ = {isa = PBXFileReference; lastKnownFileType = image.tiff; path = Tk.tiff; sourceTree = "<group>"; };
F95FAFF90B34F1130072E431 /* macOSXLoad.test */ = {isa = PBXFileReference; explicitFileType = text.script; fileEncoding = 4; path = macOSXLoad.test; sourceTree = "<group>"; };
F962F7C60DADC26200648DB8 /* vsapi.test */ = {isa = PBXFileReference; explicitFileType = text.script; fileEncoding = 4; path = vsapi.test; sourceTree = "<group>"; };
F966BA0408F27A37005CB29B /* error.xbm */ = {isa = PBXFileReference; explicitFileType = sourcecode.c.h; fileEncoding = 4; path = error.xbm; sourceTree = "<group>"; };
@@ -964,51 +964,47 @@
F966BBBB08F27A3B005CB29B /* GNUmakefile */ = {isa = PBXFileReference; explicitFileType = sourcecode.make; fileEncoding = 4; path = GNUmakefile; sourceTree = "<group>"; };
F966BBBE08F27A3B005CB29B /* README */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = text; path = README; sourceTree = "<group>"; };
F966BBC008F27A3B005CB29B /* Tk-Info.plist.in */ = {isa = PBXFileReference; explicitFileType = text.plist; fileEncoding = 4; path = "Tk-Info.plist.in"; sourceTree = "<group>"; };
- F966BBC108F27A3B005CB29B /* tkAboutDlg.r */ = {isa = PBXFileReference; fileEncoding = 30; lastKnownFileType = sourcecode.rez; path = tkAboutDlg.r; sourceTree = "<group>"; };
F966BBC208F27A3B005CB29B /* tkMacOSX.h */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.h; path = tkMacOSX.h; sourceTree = "<group>"; };
- F966BBC408F27A3B005CB29B /* tkMacOSXAETE.r */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.rez; path = tkMacOSXAETE.r; sourceTree = "<group>"; };
- F966BBC508F27A3B005CB29B /* tkMacOSXBitmap.c */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.c; path = tkMacOSXBitmap.c; sourceTree = "<group>"; };
- F966BBC608F27A3B005CB29B /* tkMacOSXButton.c */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.c; path = tkMacOSXButton.c; sourceTree = "<group>"; };
- F966BBC708F27A3B005CB29B /* tkMacOSXCarbonEvents.c */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.c; path = tkMacOSXCarbonEvents.c; sourceTree = "<group>"; };
- F966BBC808F27A3B005CB29B /* tkMacOSXClipboard.c */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.c; path = tkMacOSXClipboard.c; sourceTree = "<group>"; };
- F966BBC908F27A3B005CB29B /* tkMacOSXColor.c */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.c; path = tkMacOSXColor.c; sourceTree = "<group>"; };
- F966BBCA08F27A3B005CB29B /* tkMacOSXConfig.c */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.c; path = tkMacOSXConfig.c; sourceTree = "<group>"; };
- F966BBCB08F27A3B005CB29B /* tkMacOSXCursor.c */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.c; path = tkMacOSXCursor.c; sourceTree = "<group>"; };
- F966BBCC08F27A3B005CB29B /* tkMacOSXCursors.r */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.rez; path = tkMacOSXCursors.r; sourceTree = "<group>"; };
- F966BBCD08F27A3B005CB29B /* tkMacOSXDebug.c */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.c; path = tkMacOSXDebug.c; sourceTree = "<group>"; };
+ F966BBC508F27A3B005CB29B /* tkMacOSXBitmap.c */ = {isa = PBXFileReference; explicitFileType = sourcecode.c.objc; fileEncoding = 4; path = tkMacOSXBitmap.c; sourceTree = "<group>"; };
+ F966BBC608F27A3B005CB29B /* tkMacOSXButton.c */ = {isa = PBXFileReference; explicitFileType = sourcecode.c.objc; fileEncoding = 4; path = tkMacOSXButton.c; sourceTree = "<group>"; };
+ F966BBC808F27A3B005CB29B /* tkMacOSXClipboard.c */ = {isa = PBXFileReference; explicitFileType = sourcecode.c.objc; fileEncoding = 4; path = tkMacOSXClipboard.c; sourceTree = "<group>"; };
+ F966BBC908F27A3B005CB29B /* tkMacOSXColor.c */ = {isa = PBXFileReference; explicitFileType = sourcecode.c.objc; fileEncoding = 4; path = tkMacOSXColor.c; sourceTree = "<group>"; };
+ F966BBCA08F27A3B005CB29B /* tkMacOSXConfig.c */ = {isa = PBXFileReference; explicitFileType = sourcecode.c.objc; fileEncoding = 4; path = tkMacOSXConfig.c; sourceTree = "<group>"; };
+ F966BBCB08F27A3B005CB29B /* tkMacOSXCursor.c */ = {isa = PBXFileReference; explicitFileType = sourcecode.c.objc; fileEncoding = 4; path = tkMacOSXCursor.c; sourceTree = "<group>"; };
+ F966BBCC08F27A3B005CB29B /* tkMacOSXCursors.h */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.h; path = tkMacOSXCursors.h; sourceTree = "<group>"; };
+ F966BBCD08F27A3B005CB29B /* tkMacOSXDebug.c */ = {isa = PBXFileReference; explicitFileType = sourcecode.c.objc; fileEncoding = 4; path = tkMacOSXDebug.c; sourceTree = "<group>"; };
F966BBCE08F27A3B005CB29B /* tkMacOSXDebug.h */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.h; path = tkMacOSXDebug.h; sourceTree = "<group>"; };
F966BBCF08F27A3B005CB29B /* tkMacOSXDefault.h */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.h; path = tkMacOSXDefault.h; sourceTree = "<group>"; };
- F966BBD008F27A3B005CB29B /* tkMacOSXDialog.c */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.c; path = tkMacOSXDialog.c; sourceTree = "<group>"; };
- F966BBD108F27A3B005CB29B /* tkMacOSXDraw.c */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.c; path = tkMacOSXDraw.c; sourceTree = "<group>"; };
- F966BBD208F27A3B005CB29B /* tkMacOSXEmbed.c */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.c; path = tkMacOSXEmbed.c; sourceTree = "<group>"; };
- F966BBD308F27A3B005CB29B /* tkMacOSXEntry.c */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.c; path = tkMacOSXEntry.c; sourceTree = "<group>"; };
- F966BBD408F27A3B005CB29B /* tkMacOSXEvent.c */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.c; path = tkMacOSXEvent.c; sourceTree = "<group>"; };
+ F966BBD008F27A3B005CB29B /* tkMacOSXDialog.c */ = {isa = PBXFileReference; explicitFileType = sourcecode.c.objc; fileEncoding = 4; path = tkMacOSXDialog.c; sourceTree = "<group>"; };
+ F966BBD108F27A3B005CB29B /* tkMacOSXDraw.c */ = {isa = PBXFileReference; explicitFileType = sourcecode.c.objc; fileEncoding = 4; path = tkMacOSXDraw.c; sourceTree = "<group>"; };
+ F966BBD208F27A3B005CB29B /* tkMacOSXEmbed.c */ = {isa = PBXFileReference; explicitFileType = sourcecode.c.objc; fileEncoding = 4; path = tkMacOSXEmbed.c; sourceTree = "<group>"; };
+ F966BBD308F27A3B005CB29B /* tkMacOSXEntry.c */ = {isa = PBXFileReference; explicitFileType = sourcecode.c.objc; fileEncoding = 4; path = tkMacOSXEntry.c; sourceTree = "<group>"; };
+ F966BBD408F27A3B005CB29B /* tkMacOSXEvent.c */ = {isa = PBXFileReference; explicitFileType = sourcecode.c.objc; fileEncoding = 4; path = tkMacOSXEvent.c; sourceTree = "<group>"; };
F966BBD508F27A3B005CB29B /* tkMacOSXEvent.h */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.h; path = tkMacOSXEvent.h; sourceTree = "<group>"; };
- F966BBD608F27A3B005CB29B /* tkMacOSXFont.c */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.c; path = tkMacOSXFont.c; sourceTree = "<group>"; };
- F966BBD708F27A3B005CB29B /* tkMacOSXHLEvents.c */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.c; path = tkMacOSXHLEvents.c; sourceTree = "<group>"; };
- F966BBD808F27A3B005CB29B /* tkMacOSXInit.c */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.c; path = tkMacOSXInit.c; sourceTree = "<group>"; };
+ F966BBD608F27A3B005CB29B /* tkMacOSXFont.c */ = {isa = PBXFileReference; explicitFileType = sourcecode.c.objc; fileEncoding = 4; path = tkMacOSXFont.c; sourceTree = "<group>"; };
+ F966BBD708F27A3B005CB29B /* tkMacOSXHLEvents.c */ = {isa = PBXFileReference; explicitFileType = sourcecode.c.objc; fileEncoding = 4; path = tkMacOSXHLEvents.c; sourceTree = "<group>"; };
+ F966BBD808F27A3B005CB29B /* tkMacOSXInit.c */ = {isa = PBXFileReference; explicitFileType = sourcecode.c.objc; fileEncoding = 4; path = tkMacOSXInit.c; sourceTree = "<group>"; };
F966BBDA08F27A3B005CB29B /* tkMacOSXInt.h */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.h; path = tkMacOSXInt.h; sourceTree = "<group>"; };
- F966BBDB08F27A3B005CB29B /* tkMacOSXKeyboard.c */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.c; path = tkMacOSXKeyboard.c; sourceTree = "<group>"; };
- F966BBDC08F27A3B005CB29B /* tkMacOSXKeyEvent.c */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.c; path = tkMacOSXKeyEvent.c; sourceTree = "<group>"; };
- F966BBDD08F27A3B005CB29B /* tkMacOSXMenu.c */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.c; path = tkMacOSXMenu.c; sourceTree = "<group>"; };
- F966BBE008F27A3B005CB29B /* tkMacOSXMenubutton.c */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.c; path = tkMacOSXMenubutton.c; sourceTree = "<group>"; };
- F966BBE108F27A3B005CB29B /* tkMacOSXMenus.c */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.c; path = tkMacOSXMenus.c; sourceTree = "<group>"; };
- F966BBE208F27A3B005CB29B /* tkMacOSXMouseEvent.c */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.c; path = tkMacOSXMouseEvent.c; sourceTree = "<group>"; };
- F966BBE308F27A3B005CB29B /* tkMacOSXNotify.c */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.c; path = tkMacOSXNotify.c; sourceTree = "<group>"; };
+ F966BBDB08F27A3B005CB29B /* tkMacOSXKeyboard.c */ = {isa = PBXFileReference; explicitFileType = sourcecode.c.objc; fileEncoding = 4; path = tkMacOSXKeyboard.c; sourceTree = "<group>"; };
+ F966BBDC08F27A3B005CB29B /* tkMacOSXKeyEvent.c */ = {isa = PBXFileReference; explicitFileType = sourcecode.c.objc; fileEncoding = 4; path = tkMacOSXKeyEvent.c; sourceTree = "<group>"; };
+ F966BBDD08F27A3B005CB29B /* tkMacOSXMenu.c */ = {isa = PBXFileReference; explicitFileType = sourcecode.c.objc; fileEncoding = 4; path = tkMacOSXMenu.c; sourceTree = "<group>"; };
+ F966BBE008F27A3B005CB29B /* tkMacOSXMenubutton.c */ = {isa = PBXFileReference; explicitFileType = sourcecode.c.objc; fileEncoding = 4; path = tkMacOSXMenubutton.c; sourceTree = "<group>"; };
+ F966BBE108F27A3B005CB29B /* tkMacOSXMenus.c */ = {isa = PBXFileReference; explicitFileType = sourcecode.c.objc; fileEncoding = 4; path = tkMacOSXMenus.c; sourceTree = "<group>"; };
+ F966BBE208F27A3B005CB29B /* tkMacOSXMouseEvent.c */ = {isa = PBXFileReference; explicitFileType = sourcecode.c.objc; fileEncoding = 4; path = tkMacOSXMouseEvent.c; sourceTree = "<group>"; };
+ F966BBE308F27A3B005CB29B /* tkMacOSXNotify.c */ = {isa = PBXFileReference; explicitFileType = sourcecode.c.objc; fileEncoding = 4; path = tkMacOSXNotify.c; sourceTree = "<group>"; };
F966BBEA08F27A3C005CB29B /* tkMacOSXPort.h */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.h; path = tkMacOSXPort.h; sourceTree = "<group>"; };
- F966BBEB08F27A3C005CB29B /* tkMacOSXRegion.c */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.c; path = tkMacOSXRegion.c; sourceTree = "<group>"; };
- F966BBEC08F27A3C005CB29B /* tkMacOSXScale.c */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.c; path = tkMacOSXScale.c; sourceTree = "<group>"; };
- F966BBED08F27A3C005CB29B /* tkMacOSXScrlbr.c */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.c; path = tkMacOSXScrlbr.c; sourceTree = "<group>"; };
- F966BBEE08F27A3C005CB29B /* tkMacOSXSend.c */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.c; path = tkMacOSXSend.c; sourceTree = "<group>"; };
- F966BBEF08F27A3C005CB29B /* tkMacOSXSubwindows.c */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.c; path = tkMacOSXSubwindows.c; sourceTree = "<group>"; };
- F966BBF008F27A3C005CB29B /* tkMacOSXTest.c */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.c; path = tkMacOSXTest.c; sourceTree = "<group>"; };
- F966BBF108F27A3C005CB29B /* tkMacOSXWindowEvent.c */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.c; path = tkMacOSXWindowEvent.c; sourceTree = "<group>"; };
- F966BBF208F27A3C005CB29B /* tkMacOSXWm.c */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.c; path = tkMacOSXWm.c; sourceTree = "<group>"; };
+ F966BBEB08F27A3C005CB29B /* tkMacOSXRegion.c */ = {isa = PBXFileReference; explicitFileType = sourcecode.c.objc; fileEncoding = 4; path = tkMacOSXRegion.c; sourceTree = "<group>"; };
+ F966BBEC08F27A3C005CB29B /* tkMacOSXScale.c */ = {isa = PBXFileReference; explicitFileType = sourcecode.c.objc; fileEncoding = 4; path = tkMacOSXScale.c; sourceTree = "<group>"; };
+ F966BBED08F27A3C005CB29B /* tkMacOSXScrlbr.c */ = {isa = PBXFileReference; explicitFileType = sourcecode.c.objc; fileEncoding = 4; path = tkMacOSXScrlbr.c; sourceTree = "<group>"; };
+ F966BBEE08F27A3C005CB29B /* tkMacOSXSend.c */ = {isa = PBXFileReference; explicitFileType = sourcecode.c.objc; fileEncoding = 4; path = tkMacOSXSend.c; sourceTree = "<group>"; };
+ F966BBEF08F27A3C005CB29B /* tkMacOSXSubwindows.c */ = {isa = PBXFileReference; explicitFileType = sourcecode.c.objc; fileEncoding = 4; path = tkMacOSXSubwindows.c; sourceTree = "<group>"; };
+ F966BBF008F27A3C005CB29B /* tkMacOSXTest.c */ = {isa = PBXFileReference; explicitFileType = sourcecode.c.objc; fileEncoding = 4; path = tkMacOSXTest.c; sourceTree = "<group>"; };
+ F966BBF108F27A3C005CB29B /* tkMacOSXWindowEvent.c */ = {isa = PBXFileReference; explicitFileType = sourcecode.c.objc; fileEncoding = 4; path = tkMacOSXWindowEvent.c; sourceTree = "<group>"; };
+ F966BBF208F27A3C005CB29B /* tkMacOSXWm.c */ = {isa = PBXFileReference; explicitFileType = sourcecode.c.objc; fileEncoding = 4; path = tkMacOSXWm.c; sourceTree = "<group>"; };
F966BBF308F27A3C005CB29B /* tkMacOSXWm.h */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.h; path = tkMacOSXWm.h; sourceTree = "<group>"; };
- F966BBF408F27A3C005CB29B /* tkMacOSXXCursors.r */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.rez; path = tkMacOSXXCursors.r; sourceTree = "<group>"; };
- F966BBF508F27A3C005CB29B /* tkMacOSXXStubs.c */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.c; path = tkMacOSXXStubs.c; sourceTree = "<group>"; };
+ F966BBF408F27A3C005CB29B /* tkMacOSXXCursors.h */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.h; path = tkMacOSXXCursors.h; sourceTree = "<group>"; };
+ F966BBF508F27A3C005CB29B /* tkMacOSXXStubs.c */ = {isa = PBXFileReference; explicitFileType = sourcecode.c.objc; fileEncoding = 4; path = tkMacOSXXStubs.c; sourceTree = "<group>"; };
F966BBF708F27A3C005CB29B /* Wish-Info.plist.in */ = {isa = PBXFileReference; explicitFileType = text.plist; fileEncoding = 4; path = "Wish-Info.plist.in"; sourceTree = "<group>"; };
- F966BBF808F27A3C005CB29B /* Wish.icns */ = {isa = PBXFileReference; lastKnownFileType = image.icns; path = Wish.icns; sourceTree = "<group>"; };
F966BC0308F27A3C005CB29B /* README */ = {isa = PBXFileReference; explicitFileType = text; fileEncoding = 4; path = README; sourceTree = "<group>"; };
F966BC0508F27A3C005CB29B /* all.tcl */ = {isa = PBXFileReference; explicitFileType = text.script; fileEncoding = 4; path = all.tcl; sourceTree = "<group>"; };
F966BC0608F27A3C005CB29B /* arc.tcl */ = {isa = PBXFileReference; explicitFileType = text.script; fileEncoding = 4; path = arc.tcl; sourceTree = "<group>"; };
@@ -1311,7 +1307,7 @@
F968887F0AF788F6000797B5 /* ttk_Theme.3 */ = {isa = PBXFileReference; explicitFileType = text.man; fileEncoding = 4; path = ttk_Theme.3; sourceTree = "<group>"; };
F96888800AF788F6000797B5 /* ttk_treeview.n */ = {isa = PBXFileReference; explicitFileType = text.man; fileEncoding = 4; path = ttk_treeview.n; sourceTree = "<group>"; };
F96888810AF788F6000797B5 /* ttk_widget.n */ = {isa = PBXFileReference; explicitFileType = text.man; fileEncoding = 4; path = ttk_widget.n; sourceTree = "<group>"; };
- F96888840AF78938000797B5 /* ttkMacOSXTheme.c */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.c; path = ttkMacOSXTheme.c; sourceTree = "<group>"; };
+ F96888840AF78938000797B5 /* ttkMacOSXTheme.c */ = {isa = PBXFileReference; explicitFileType = sourcecode.c.objc; fileEncoding = 4; path = ttkMacOSXTheme.c; sourceTree = "<group>"; };
F96888860AF78953000797B5 /* ttkWinMonitor.c */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.c; path = ttkWinMonitor.c; sourceTree = "<group>"; };
F96888870AF78953000797B5 /* ttkWinTheme.c */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.c; path = ttkWinTheme.c; sourceTree = "<group>"; };
F96888880AF78953000797B5 /* ttkWinXPTheme.c */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.c; path = ttkWinXPTheme.c; sourceTree = "<group>"; };
@@ -2041,6 +2037,7 @@
F9A3084B08F2D4CE00BAE1AB /* Wish.app */ = {isa = PBXFileReference; explicitFileType = wrapper.application; includeInIndex = 0; path = Wish.app; sourceTree = BUILT_PRODUCTS_DIR; };
F9A3084E08F2D4F400BAE1AB /* Tcl.framework */ = {isa = PBXFileReference; includeInIndex = 0; lastKnownFileType = wrapper.framework; path = Tcl.framework; sourceTree = BUILT_PRODUCTS_DIR; };
F9A493240CEBF38300B78AE2 /* chanio.test */ = {isa = PBXFileReference; explicitFileType = text.script; fileEncoding = 4; path = chanio.test; sourceTree = "<group>"; };
+ F9C9CBFF0E84059800E00935 /* ApplicationServices.framework */ = {isa = PBXFileReference; lastKnownFileType = wrapper.framework; name = ApplicationServices.framework; path = /System/Library/Frameworks/ApplicationServices.framework; sourceTree = "<absolute>"; };
F9D1360A0CDC252C00DBE0B5 /* mclist.tcl */ = {isa = PBXFileReference; explicitFileType = text.script; fileEncoding = 4; path = mclist.tcl; sourceTree = "<group>"; };
F9ECB1120B26521500A28025 /* pkgIndex.tcl */ = {isa = PBXFileReference; explicitFileType = text.script; fileEncoding = 4; path = pkgIndex.tcl; sourceTree = "<group>"; };
F9ECB1130B26521500A28025 /* platform.tcl */ = {isa = PBXFileReference; explicitFileType = text.script; fileEncoding = 4; path = platform.tcl; sourceTree = "<group>"; };
@@ -2070,6 +2067,8 @@
F966C07508F2820D005CB29B /* CoreFoundation.framework in Frameworks */,
F966C07708F2821B005CB29B /* Carbon.framework in Frameworks */,
F966C07908F28233005CB29B /* IOKit.framework in Frameworks */,
+ F94523A20E6FC2AC00C1D987 /* Cocoa.framework in Frameworks */,
+ F9C9CC000E84059800E00935 /* ApplicationServices.framework in Frameworks */,
);
runOnlyForDeploymentPostprocessing = 0;
};
@@ -2098,7 +2097,7 @@
F966C06F08F281DC005CB29B /* Frameworks */,
1AB674ADFE9D54B511CA2CBB /* Products */,
);
- comments = "Copyright (c) 2004-2008 Daniel A. Steffen <das@users.sourceforge.net>\n\nSee the file \"license.terms\" for information on usage and redistribution of\nthis file, and for a DISCLAIMER OF ALL WARRANTIES.\n";
+ comments = "Copyright (c) 2004-2009 Daniel A. Steffen <das@users.sourceforge.net>\nCopyright 2008-2009, Apple Inc.\n\nSee the file \"license.terms\" for information on usage and redistribution of\nthis file, and for a DISCLAIMER OF ALL WARRANTIES.\n\nRCS: @(#) $Id$\n";
name = Wish;
path = .;
sourceTree = SOURCE_ROOT;
@@ -2542,17 +2541,14 @@
F966BBBB08F27A3B005CB29B /* GNUmakefile */,
F966BBBE08F27A3B005CB29B /* README */,
F966BBC008F27A3B005CB29B /* Tk-Info.plist.in */,
- F966BBC108F27A3B005CB29B /* tkAboutDlg.r */,
F966BBC208F27A3B005CB29B /* tkMacOSX.h */,
- F966BBC408F27A3B005CB29B /* tkMacOSXAETE.r */,
F966BBC508F27A3B005CB29B /* tkMacOSXBitmap.c */,
F966BBC608F27A3B005CB29B /* tkMacOSXButton.c */,
- F966BBC708F27A3B005CB29B /* tkMacOSXCarbonEvents.c */,
F966BBC808F27A3B005CB29B /* tkMacOSXClipboard.c */,
F966BBC908F27A3B005CB29B /* tkMacOSXColor.c */,
F966BBCA08F27A3B005CB29B /* tkMacOSXConfig.c */,
F966BBCB08F27A3B005CB29B /* tkMacOSXCursor.c */,
- F966BBCC08F27A3B005CB29B /* tkMacOSXCursors.r */,
+ F966BBCC08F27A3B005CB29B /* tkMacOSXCursors.h */,
F966BBCD08F27A3B005CB29B /* tkMacOSXDebug.c */,
F966BBCE08F27A3B005CB29B /* tkMacOSXDebug.h */,
F966BBCF08F27A3B005CB29B /* tkMacOSXDefault.h */,
@@ -2585,10 +2581,11 @@
F966BBF108F27A3C005CB29B /* tkMacOSXWindowEvent.c */,
F966BBF208F27A3C005CB29B /* tkMacOSXWm.c */,
F966BBF308F27A3C005CB29B /* tkMacOSXWm.h */,
- F966BBF408F27A3C005CB29B /* tkMacOSXXCursors.r */,
+ F966BBF408F27A3C005CB29B /* tkMacOSXXCursors.h */,
F966BBF508F27A3C005CB29B /* tkMacOSXXStubs.c */,
F96888840AF78938000797B5 /* ttkMacOSXTheme.c */,
- F966BBF808F27A3C005CB29B /* Wish.icns */,
+ F95D8D4B0F1715610006B020 /* Tk.icns */,
+ F95D8D4C0F1715610006B020 /* Tk.tiff */,
F966BBF708F27A3C005CB29B /* Wish-Info.plist.in */,
F97AE7F10B65C1E900310EA2 /* Wish-Common.xcconfig */,
F97AE8330B65C87F00310EA2 /* Wish-Debug.xcconfig */,
@@ -2851,8 +2848,10 @@
F966C06F08F281DC005CB29B /* Frameworks */ = {
isa = PBXGroup;
children = (
+ F9C9CBFF0E84059800E00935 /* ApplicationServices.framework */,
F966C07408F2820D005CB29B /* CoreFoundation.framework */,
F966C07608F2821B005CB29B /* Carbon.framework */,
+ F94523A10E6FC2AC00C1D987 /* Cocoa.framework */,
F966C07808F28233005CB29B /* IOKit.framework */,
F9FD32140CC1AF170073837D /* libX11.dylib */,
F9FD32150CC1AF170073837D /* libXext.dylib */,
@@ -3869,10 +3868,8 @@
buildPhases = (
F9A5C5F508F651A2008AE941 /* ShellScript */,
F9A5C5F608F651AB008AE941 /* ShellScript */,
- F9EA4ADE08FA3B7F00B1F5F0 /* Rez */,
8DD76FAB0486AB0100D96B5E /* Sources */,
8DD76FAD0486AB0100D96B5E /* Frameworks */,
- F95FA74C0B32CE190072E431 /* ShellScript */,
);
buildRules = (
);
@@ -3927,7 +3924,7 @@
BuildIndependentTargetsInParallel = YES;
};
buildConfigurationList = F95CC8B509158F3100EA5ACE /* Build configuration list for PBXProject "Wish" */;
- compatibilityVersion = "Xcode 3.1";
+ compatibilityVersion = "Xcode 3.2";
hasScannedForEncodings = 1;
mainGroup = 08FB7794FE84155DC02AAC07 /* Wish */;
projectDirPath = "";
@@ -3940,38 +3937,7 @@
};
/* End PBXProject section */
-/* Begin PBXRezBuildPhase section */
- F9EA4ADE08FA3B7F00B1F5F0 /* Rez */ = {
- isa = PBXRezBuildPhase;
- buildActionMask = 2147483647;
- files = (
- F9EA4AF008FA3BD500B1F5F0 /* tkMacOSXXCursors.r in Rez */,
- F9EA4AF208FA3BD800B1F5F0 /* tkMacOSXCursors.r in Rez */,
- F9EA4AF308FA3BDA00B1F5F0 /* tkMacOSXAETE.r in Rez */,
- F9EA4AF408FA3BDB00B1F5F0 /* tkAboutDlg.r in Rez */,
- );
- runOnlyForDeploymentPostprocessing = 0;
- };
-/* End PBXRezBuildPhase section */
-
/* Begin PBXShellScriptBuildPhase section */
- F95FA74C0B32CE190072E431 /* ShellScript */ = {
- isa = PBXShellScriptBuildPhase;
- buildActionMask = 2147483647;
- files = (
- );
- inputPaths = (
- "$(TARGET_BUILD_DIR)/$(PRODUCT_NAME)",
- "$(REZ_COLLECTOR_DIR)/$(PRODUCT_NAME).rsrc",
- );
- outputPaths = (
- "$(TARGET_TEMP_DIR)/stamp",
- );
- runOnlyForDeploymentPostprocessing = 0;
- shellPath = /bin/bash;
- shellScript = "touch -t $(date -r $(expr $(date '+%s') + 5) '+%Y%m%d%H%M.%S') \"${TARGET_TEMP_DIR}/stamp\"\n\n## Xcode bug workaround: Rezzing does not take place for commandline tool targets\n## even when a ResourceManager Resources phase is present, but this script phase's\n## input dependency on the final merged resource file forces the Rezzing.\n";
- showEnvVarsInLog = 0;
- };
F97AF02F0B665DA900310EA2 /* ShellScript */ = {
isa = PBXShellScriptBuildPhase;
buildActionMask = 2147483647;
@@ -4336,7 +4302,6 @@
F96888230AF786D5000797B5 /* ttkWidget.c in Sources */,
F966BEDB08F27A40005CB29B /* tkMacOSXBitmap.c in Sources */,
F966BEDC08F27A40005CB29B /* tkMacOSXButton.c in Sources */,
- F966BEDD08F27A40005CB29B /* tkMacOSXCarbonEvents.c in Sources */,
F966BEDE08F27A40005CB29B /* tkMacOSXClipboard.c in Sources */,
F966BEDF08F27A40005CB29B /* tkMacOSXColor.c in Sources */,
F966BEE008F27A40005CB29B /* tkMacOSXConfig.c in Sources */,
@@ -4664,6 +4629,77 @@
/* End PBXSourcesBuildPhase section */
/* Begin XCBuildConfiguration section */
+ F90E36D50F3B5C8400810A10 /* Debug gcc42 nogc */ = {
+ isa = XCBuildConfiguration;
+ baseConfigurationReference = F97AE8330B65C87F00310EA2 /* Wish-Debug.xcconfig */;
+ buildSettings = {
+ ARCHS = (
+ "$(NATIVE_ARCH_32_BIT)",
+ "$(NATIVE_ARCH_64_BIT)",
+ );
+ CPPFLAGS = "-arch $(CURRENT_ARCH) $(CPPFLAGS)";
+ GCC_C_LANGUAGE_STANDARD = gnu99;
+ GCC_ENABLE_OBJC_GC = unsupported;
+ GCC_ENABLE_PASCAL_STRINGS = NO;
+ GCC_INPUT_FILETYPE = sourcecode.c.objc;
+ GCC_VERSION = 4.2;
+ MACOSX_DEPLOYMENT_TARGET = 10.6;
+ ONLY_ACTIVE_ARCH = YES;
+ PREBINDING = NO;
+ };
+ name = "Debug gcc42 nogc";
+ };
+ F90E36D60F3B5C8400810A10 /* Debug gcc42 nogc */ = {
+ isa = XCBuildConfiguration;
+ buildSettings = {
+ PRODUCT_NAME = Wish;
+ SKIP_INSTALL = NO;
+ };
+ name = "Debug gcc42 nogc";
+ };
+ F90E36D70F3B5C8400810A10 /* Debug gcc42 nogc */ = {
+ isa = XCBuildConfiguration;
+ buildSettings = {
+ CONFIGURE_ARGS = "tcl_cv_cc_visibility_hidden=no $(CONFIGURE_ARGS)";
+ GCC_DYNAMIC_NO_PIC = NO;
+ GCC_ENABLE_FIX_AND_CONTINUE = YES;
+ GCC_PREPROCESSOR_DEFINITIONS = (
+ "__private_extern__=extern",
+ "$(GCC_PREPROCESSOR_DEFINITIONS)",
+ );
+ GCC_SYMBOLS_PRIVATE_EXTERN = NO;
+ OTHER_LDFLAGS = (
+ "$(OTHER_LDFLAGS_AQUA)",
+ "$(OTHER_LDFLAGS)",
+ );
+ PRODUCT_NAME = tktest;
+ };
+ name = "Debug gcc42 nogc";
+ };
+ F90E36D80F3B5C8400810A10 /* Debug gcc42 nogc */ = {
+ isa = XCBuildConfiguration;
+ buildSettings = {
+ CONFIGURE_ARGS = "tcl_cv_cc_visibility_hidden=no $(CONFIGURE_ARGS)";
+ GCC_DYNAMIC_NO_PIC = NO;
+ GCC_ENABLE_FIX_AND_CONTINUE = YES;
+ GCC_PREPROCESSOR_DEFINITIONS = (
+ "__private_extern__=extern",
+ "$(GCC_PREPROCESSOR_DEFINITIONS)",
+ );
+ GCC_SYMBOLS_PRIVATE_EXTERN = NO;
+ HEADER_SEARCH_PATHS = (
+ /usr/X11R6/include,
+ /usr/X11R6/include/freetype2,
+ "$(HEADER_SEARCH_PATHS)",
+ );
+ LIBRARY_SEARCH_PATHS = (
+ /usr/X11R6/lib,
+ "$(LIBRARY_SEARCH_PATHS)",
+ );
+ PRODUCT_NAME = "tktest-X11";
+ };
+ name = "Debug gcc42 nogc";
+ };
F91BCC4F093152310042A6BF /* ReleaseUniversal */ = {
isa = XCBuildConfiguration;
buildSettings = {
@@ -4687,9 +4723,13 @@
isa = XCBuildConfiguration;
baseConfigurationReference = F97AE82B0B65C69B00310EA2 /* Wish-Release.xcconfig */;
buildSettings = {
- ARCHS = "$(ARCHS_STANDARD_32_BIT)";
- CFLAGS = "-arch i386 -arch ppc $(CFLAGS)";
- MACOSX_DEPLOYMENT_TARGET = 10.5;
+ ARCHS = "$(ARCHS_STANDARD_32_64_BIT)";
+ CFLAGS = "-arch i386 -arch x86_64 -arch ppc $(CFLAGS)";
+ GCC_C_LANGUAGE_STANDARD = gnu99;
+ GCC_ENABLE_OBJC_GC = supported;
+ GCC_ENABLE_PASCAL_STRINGS = NO;
+ GCC_INPUT_FILETYPE = sourcecode.c.objc;
+ MACOSX_DEPLOYMENT_TARGET = 10.6;
PREBINDING = NO;
};
name = ReleaseUniversal;
@@ -4733,8 +4773,18 @@
isa = XCBuildConfiguration;
baseConfigurationReference = F97AE8330B65C87F00310EA2 /* Wish-Debug.xcconfig */;
buildSettings = {
+ ARCHS = (
+ "$(NATIVE_ARCH_32_BIT)",
+ "$(NATIVE_ARCH_64_BIT)",
+ );
CONFIGURE_ARGS = "$(CONFIGURE_ARGS) --enable-symbols=all";
- MACOSX_DEPLOYMENT_TARGET = 10.5;
+ CPPFLAGS = "-arch $(CURRENT_ARCH) $(CPPFLAGS)";
+ GCC_C_LANGUAGE_STANDARD = gnu99;
+ GCC_ENABLE_OBJC_GC = supported;
+ GCC_ENABLE_PASCAL_STRINGS = NO;
+ GCC_INPUT_FILETYPE = sourcecode.c.objc;
+ MACOSX_DEPLOYMENT_TARGET = 10.6;
+ ONLY_ACTIVE_ARCH = YES;
PREBINDING = NO;
};
name = DebugMemCompile;
@@ -4743,9 +4793,19 @@
isa = XCBuildConfiguration;
baseConfigurationReference = F97AE8330B65C87F00310EA2 /* Wish-Debug.xcconfig */;
buildSettings = {
+ ARCHS = (
+ "$(NATIVE_ARCH_32_BIT)",
+ "$(NATIVE_ARCH_64_BIT)",
+ );
+ CPPFLAGS = "-arch $(CURRENT_ARCH) $(CPPFLAGS)";
+ GCC_C_LANGUAGE_STANDARD = gnu99;
+ GCC_ENABLE_OBJC_GC = supported;
+ GCC_ENABLE_PASCAL_STRINGS = NO;
GCC_GENERATE_TEST_COVERAGE_FILES = YES;
+ GCC_INPUT_FILETYPE = sourcecode.c.objc;
GCC_INSTRUMENT_PROGRAM_FLOW_ARCS = YES;
- MACOSX_DEPLOYMENT_TARGET = 10.5;
+ MACOSX_DEPLOYMENT_TARGET = 10.6;
+ ONLY_ACTIVE_ARCH = YES;
OTHER_LDFLAGS = (
"$(OTHER_LDFLAGS)",
"-lgcov",
@@ -4858,7 +4918,17 @@
isa = XCBuildConfiguration;
baseConfigurationReference = F97AE8330B65C87F00310EA2 /* Wish-Debug.xcconfig */;
buildSettings = {
- MACOSX_DEPLOYMENT_TARGET = 10.5;
+ ARCHS = (
+ "$(NATIVE_ARCH_32_BIT)",
+ "$(NATIVE_ARCH_64_BIT)",
+ );
+ CPPFLAGS = "-arch $(CURRENT_ARCH) $(CPPFLAGS)";
+ GCC_C_LANGUAGE_STANDARD = gnu99;
+ GCC_ENABLE_OBJC_GC = supported;
+ GCC_ENABLE_PASCAL_STRINGS = NO;
+ GCC_INPUT_FILETYPE = sourcecode.c.objc;
+ MACOSX_DEPLOYMENT_TARGET = 10.6;
+ ONLY_ACTIVE_ARCH = YES;
PREBINDING = NO;
};
name = Debug;
@@ -4867,7 +4937,12 @@
isa = XCBuildConfiguration;
baseConfigurationReference = F97AE82B0B65C69B00310EA2 /* Wish-Release.xcconfig */;
buildSettings = {
- MACOSX_DEPLOYMENT_TARGET = 10.5;
+ ARCHS = "$(NATIVE_ARCH_32_BIT)";
+ GCC_C_LANGUAGE_STANDARD = gnu99;
+ GCC_ENABLE_OBJC_GC = supported;
+ GCC_ENABLE_PASCAL_STRINGS = NO;
+ GCC_INPUT_FILETYPE = sourcecode.c.objc;
+ MACOSX_DEPLOYMENT_TARGET = 10.6;
PREBINDING = NO;
};
name = Release;
@@ -4876,7 +4951,17 @@
isa = XCBuildConfiguration;
baseConfigurationReference = F97AE8330B65C87F00310EA2 /* Wish-Debug.xcconfig */;
buildSettings = {
- MACOSX_DEPLOYMENT_TARGET = 10.5;
+ ARCHS = (
+ "$(NATIVE_ARCH_32_BIT)",
+ "$(NATIVE_ARCH_64_BIT)",
+ );
+ CPPFLAGS = "-arch $(CURRENT_ARCH) $(CPPFLAGS)";
+ GCC_C_LANGUAGE_STANDARD = gnu99;
+ GCC_ENABLE_OBJC_GC = supported;
+ GCC_ENABLE_PASCAL_STRINGS = NO;
+ GCC_INPUT_FILETYPE = sourcecode.c.objc;
+ MACOSX_DEPLOYMENT_TARGET = 10.6;
+ ONLY_ACTIVE_ARCH = YES;
PREBINDING = NO;
};
name = DebugNoFixZL;
@@ -4941,7 +5026,7 @@
isa = XCBuildConfiguration;
buildSettings = {
ARCHS = "$(ARCHS_STANDARD_32_64_BIT)";
- CFLAGS = "-arch i386 -arch x86_64 -arch ppc -arch ppc64 $(CFLAGS)";
+ CFLAGS = "-arch i386 -arch x86_64 -arch ppc $(CFLAGS)";
HEADER_SEARCH_PATHS = (
/usr/X11R6/include,
/usr/X11R6/include/freetype2,
@@ -4955,54 +5040,6 @@
};
name = ReleaseUniversal;
};
- F97AED080B660A6C00310EA2 /* ReleaseUniversal10.4uSDK */ = {
- isa = XCBuildConfiguration;
- buildSettings = {
- HEADER_SEARCH_PATHS = (
- /usr/X11R6/include,
- /usr/X11R6/include/freetype2,
- "$(HEADER_SEARCH_PATHS)",
- );
- LIBRARY_SEARCH_PATHS = (
- /usr/X11R6/lib,
- "$(LIBRARY_SEARCH_PATHS)",
- );
- PRODUCT_NAME = "tktest-X11";
- };
- name = ReleaseUniversal10.4uSDK;
- };
- F97AED0F0B660AA300310EA2 /* ReleasePPC10.3.9SDK */ = {
- isa = XCBuildConfiguration;
- buildSettings = {
- HEADER_SEARCH_PATHS = (
- /usr/X11R6/include,
- /usr/X11R6/include/freetype2,
- "$(HEADER_SEARCH_PATHS)",
- );
- LIBRARY_SEARCH_PATHS = (
- /usr/X11R6/lib,
- "$(LIBRARY_SEARCH_PATHS)",
- );
- PRODUCT_NAME = "tktest-X11";
- };
- name = ReleasePPC10.3.9SDK;
- };
- F97AED160B660AF100310EA2 /* ReleasePPC10.2.8SDK */ = {
- isa = XCBuildConfiguration;
- buildSettings = {
- HEADER_SEARCH_PATHS = (
- /usr/X11R6/include,
- /usr/X11R6/include/freetype2,
- "$(HEADER_SEARCH_PATHS)",
- );
- LIBRARY_SEARCH_PATHS = (
- /usr/X11R6/lib,
- "$(LIBRARY_SEARCH_PATHS)",
- );
- PRODUCT_NAME = "tktest-X11";
- };
- name = ReleasePPC10.2.8SDK;
- };
F97AED1B0B660B2100310EA2 /* Debug64bit */ = {
isa = XCBuildConfiguration;
buildSettings = {
@@ -5045,7 +5082,11 @@
ARCHS = "$(NATIVE_ARCH_64_BIT)";
CONFIGURE_ARGS = "--enable-64bit $(CONFIGURE_ARGS)";
CPPFLAGS = "-arch $(NATIVE_ARCH_64_BIT) $(CPPFLAGS)";
- MACOSX_DEPLOYMENT_TARGET = 10.5;
+ GCC_C_LANGUAGE_STANDARD = gnu99;
+ GCC_ENABLE_OBJC_GC = supported;
+ GCC_ENABLE_PASCAL_STRINGS = NO;
+ GCC_INPUT_FILETYPE = sourcecode.c.objc;
+ MACOSX_DEPLOYMENT_TARGET = 10.6;
PREBINDING = NO;
};
name = Debug64bit;
@@ -5054,8 +5095,18 @@
isa = XCBuildConfiguration;
baseConfigurationReference = F97AE8330B65C87F00310EA2 /* Wish-Debug.xcconfig */;
buildSettings = {
+ ARCHS = (
+ "$(NATIVE_ARCH_32_BIT)",
+ "$(NATIVE_ARCH_64_BIT)",
+ );
CONFIGURE_ARGS = "$(CONFIGURE_ARGS) --disable-corefoundation";
- MACOSX_DEPLOYMENT_TARGET = 10.5;
+ CPPFLAGS = "-arch $(CURRENT_ARCH) $(CPPFLAGS)";
+ GCC_C_LANGUAGE_STANDARD = gnu99;
+ GCC_ENABLE_OBJC_GC = supported;
+ GCC_ENABLE_PASCAL_STRINGS = NO;
+ GCC_INPUT_FILETYPE = sourcecode.c.objc;
+ MACOSX_DEPLOYMENT_TARGET = 10.6;
+ ONLY_ACTIVE_ARCH = YES;
PREBINDING = NO;
};
name = DebugNoCF;
@@ -5101,8 +5152,18 @@
isa = XCBuildConfiguration;
baseConfigurationReference = F97AE8330B65C87F00310EA2 /* Wish-Debug.xcconfig */;
buildSettings = {
+ ARCHS = (
+ "$(NATIVE_ARCH_32_BIT)",
+ "$(NATIVE_ARCH_64_BIT)",
+ );
CONFIGURE_ARGS = "$(CONFIGURE_ARGS) --disable-threads --disable-corefoundation";
- MACOSX_DEPLOYMENT_TARGET = 10.5;
+ CPPFLAGS = "-arch $(CURRENT_ARCH) $(CPPFLAGS)";
+ GCC_C_LANGUAGE_STANDARD = gnu99;
+ GCC_ENABLE_OBJC_GC = supported;
+ GCC_ENABLE_PASCAL_STRINGS = NO;
+ GCC_INPUT_FILETYPE = sourcecode.c.objc;
+ MACOSX_DEPLOYMENT_TARGET = 10.6;
+ ONLY_ACTIVE_ARCH = YES;
PREBINDING = NO;
};
name = DebugNoCFUnthreaded;
@@ -5148,8 +5209,18 @@
isa = XCBuildConfiguration;
baseConfigurationReference = F97AE8330B65C87F00310EA2 /* Wish-Debug.xcconfig */;
buildSettings = {
+ ARCHS = (
+ "$(NATIVE_ARCH_32_BIT)",
+ "$(NATIVE_ARCH_64_BIT)",
+ );
+ CPPFLAGS = "-arch $(CURRENT_ARCH) $(CPPFLAGS)";
+ GCC_C_LANGUAGE_STANDARD = gnu99;
+ GCC_ENABLE_OBJC_GC = supported;
+ GCC_ENABLE_PASCAL_STRINGS = NO;
+ GCC_INPUT_FILETYPE = sourcecode.c.objc;
GCC_VERSION = 4.2;
- MACOSX_DEPLOYMENT_TARGET = 10.5;
+ MACOSX_DEPLOYMENT_TARGET = 10.6;
+ ONLY_ACTIVE_ARCH = YES;
PREBINDING = NO;
};
name = "Debug gcc42";
@@ -5209,9 +5280,19 @@
isa = XCBuildConfiguration;
baseConfigurationReference = F97AE8330B65C87F00310EA2 /* Wish-Debug.xcconfig */;
buildSettings = {
+ ARCHS = (
+ "$(NATIVE_ARCH_32_BIT)",
+ "$(NATIVE_ARCH_64_BIT)",
+ );
CC = "$(DEVELOPER_DIR)/usr/bin/llvm-gcc-4.2";
+ CPPFLAGS = "-arch $(CURRENT_ARCH) $(CPPFLAGS)";
+ GCC_C_LANGUAGE_STANDARD = gnu99;
+ GCC_ENABLE_OBJC_GC = supported;
+ GCC_ENABLE_PASCAL_STRINGS = NO;
+ GCC_INPUT_FILETYPE = sourcecode.c.objc;
GCC_VERSION = com.apple.compilers.llvmgcc42;
- MACOSX_DEPLOYMENT_TARGET = 10.5;
+ MACOSX_DEPLOYMENT_TARGET = 10.6;
+ ONLY_ACTIVE_ARCH = YES;
PREBINDING = NO;
};
name = "Debug llvmgcc42";
@@ -5271,10 +5352,14 @@
isa = XCBuildConfiguration;
baseConfigurationReference = F97AE82B0B65C69B00310EA2 /* Wish-Release.xcconfig */;
buildSettings = {
- ARCHS = "$(ARCHS_STANDARD_32_BIT)";
- CFLAGS = "-arch i386 -arch ppc $(CFLAGS)";
+ ARCHS = "$(ARCHS_STANDARD_32_64_BIT)";
+ CFLAGS = "-arch i386 -arch x86_64 -arch ppc $(CFLAGS)";
+ GCC_C_LANGUAGE_STANDARD = gnu99;
+ GCC_ENABLE_OBJC_GC = supported;
+ GCC_ENABLE_PASCAL_STRINGS = NO;
+ GCC_INPUT_FILETYPE = sourcecode.c.objc;
GCC_VERSION = 4.2;
- MACOSX_DEPLOYMENT_TARGET = 10.5;
+ MACOSX_DEPLOYMENT_TARGET = 10.6;
PREBINDING = NO;
};
name = "ReleaseUniversal gcc42";
@@ -5302,7 +5387,7 @@
isa = XCBuildConfiguration;
buildSettings = {
ARCHS = "$(ARCHS_STANDARD_32_64_BIT)";
- CFLAGS = "-arch i386 -arch x86_64 -arch ppc -arch ppc64 $(CFLAGS)";
+ CFLAGS = "-arch i386 -arch x86_64 -arch ppc $(CFLAGS)";
HEADER_SEARCH_PATHS = (
/usr/X11R6/include,
/usr/X11R6/include/freetype2,
@@ -5320,17 +5405,20 @@
isa = XCBuildConfiguration;
baseConfigurationReference = F97AE82B0B65C69B00310EA2 /* Wish-Release.xcconfig */;
buildSettings = {
- ARCHS = "$(ARCHS_STANDARD_32_BIT)";
+ ARCHS = (
+ "$(NATIVE_ARCH_32_BIT)",
+ "$(NATIVE_ARCH_64_BIT)",
+ );
CC = "$(DEVELOPER_DIR)/usr/bin/llvm-gcc-4.2";
- CFLAGS = "-arch i386 -arch ppc $(CFLAGS)";
+ CFLAGS = "-arch i386 -arch x86_64 $(CFLAGS)";
DEBUG_INFORMATION_FORMAT = dwarf;
+ GCC_C_LANGUAGE_STANDARD = gnu99;
+ GCC_ENABLE_OBJC_GC = supported;
+ GCC_ENABLE_PASCAL_STRINGS = NO;
+ GCC_INPUT_FILETYPE = sourcecode.c.objc;
GCC_OPTIMIZATION_LEVEL = 4;
GCC_VERSION = com.apple.compilers.llvmgcc42;
- MACOSX_DEPLOYMENT_TARGET = 10.5;
- OTHER_CFLAGS = (
- "$(OTHER_CFLAGS)",
- "-emit-llvm",
- );
+ MACOSX_DEPLOYMENT_TARGET = 10.6;
PREBINDING = NO;
TCL_CONFIGURE_ARGS = "$(TCL_CONFIGURE_ARGS) --disable-dtrace";
};
@@ -5359,7 +5447,7 @@
isa = XCBuildConfiguration;
buildSettings = {
ARCHS = "$(ARCHS_STANDARD_32_64_BIT)";
- CFLAGS = "-arch i386 -arch x86_64 -arch ppc -arch ppc64 $(CFLAGS)";
+ CFLAGS = "-arch i386 -arch x86_64 -arch ppc $(CFLAGS)";
HEADER_SEARCH_PATHS = (
/usr/X11R6/include,
/usr/X11R6/include/freetype2,
@@ -5447,8 +5535,18 @@
isa = XCBuildConfiguration;
baseConfigurationReference = F97AE8330B65C87F00310EA2 /* Wish-Debug.xcconfig */;
buildSettings = {
+ ARCHS = (
+ "$(NATIVE_ARCH_32_BIT)",
+ "$(NATIVE_ARCH_64_BIT)",
+ );
CONFIGURE_ARGS = "$(CONFIGURE_ARGS) --disable-threads";
- MACOSX_DEPLOYMENT_TARGET = 10.5;
+ CPPFLAGS = "-arch $(CURRENT_ARCH) $(CPPFLAGS)";
+ GCC_C_LANGUAGE_STANDARD = gnu99;
+ GCC_ENABLE_OBJC_GC = supported;
+ GCC_ENABLE_PASCAL_STRINGS = NO;
+ GCC_INPUT_FILETYPE = sourcecode.c.objc;
+ MACOSX_DEPLOYMENT_TARGET = 10.6;
+ ONLY_ACTIVE_ARCH = YES;
PREBINDING = NO;
};
name = DebugUnthreaded;
@@ -5457,120 +5555,25 @@
isa = XCBuildConfiguration;
baseConfigurationReference = F97AE8330B65C87F00310EA2 /* Wish-Debug.xcconfig */;
buildSettings = {
+ ARCHS = (
+ "$(NATIVE_ARCH_32_BIT)",
+ "$(NATIVE_ARCH_64_BIT)",
+ );
+ CPPFLAGS = "-arch $(CURRENT_ARCH) $(CPPFLAGS)";
+ GCC_C_LANGUAGE_STANDARD = gnu99;
+ GCC_ENABLE_OBJC_GC = unsupported;
+ GCC_ENABLE_PASCAL_STRINGS = NO;
+ GCC_INPUT_FILETYPE = sourcecode.c.objc;
GCC_PREPROCESSOR_DEFINITIONS = (
PURIFY,
"$(GCC_PREPROCESSOR_DEFINITIONS)",
);
- MACOSX_DEPLOYMENT_TARGET = 10.5;
+ MACOSX_DEPLOYMENT_TARGET = 10.6;
+ ONLY_ACTIVE_ARCH = YES;
PREBINDING = NO;
};
name = DebugLeaks;
};
- F9DB62080B65ADA800A370FB /* ReleaseUniversal10.4uSDK */ = {
- isa = XCBuildConfiguration;
- buildSettings = {
- PRODUCT_NAME = Wish;
- SKIP_INSTALL = NO;
- };
- name = ReleaseUniversal10.4uSDK;
- };
- F9DB62090B65ADA800A370FB /* ReleaseUniversal10.4uSDK */ = {
- isa = XCBuildConfiguration;
- buildSettings = {
- OTHER_LDFLAGS = (
- "$(OTHER_LDFLAGS_AQUA)",
- "$(OTHER_LDFLAGS)",
- );
- PRODUCT_NAME = tktest;
- };
- name = ReleaseUniversal10.4uSDK;
- };
- F9DB620A0B65ADA800A370FB /* ReleaseUniversal10.4uSDK */ = {
- isa = XCBuildConfiguration;
- baseConfigurationReference = F97AE82B0B65C69B00310EA2 /* Wish-Release.xcconfig */;
- buildSettings = {
- ARCHS = "$(ARCHS_STANDARD_32_BIT)";
- CFLAGS = "-arch i386 -arch ppc $(CFLAGS)";
- CPPFLAGS = "-isysroot $(SDKROOT) $(CPPFLAGS)";
- MACOSX_DEPLOYMENT_TARGET = 10.4;
- PREBINDING = NO;
- SDKROOT = macosx10.4;
- };
- name = ReleaseUniversal10.4uSDK;
- };
- F9DB621F0B65AFDE00A370FB /* ReleasePPC10.3.9SDK */ = {
- isa = XCBuildConfiguration;
- buildSettings = {
- LDFLAGS = "-force_cpusubtype_ALL $(LDFLAGS)";
- PRODUCT_NAME = Wish;
- SKIP_INSTALL = NO;
- };
- name = ReleasePPC10.3.9SDK;
- };
- F9DB62200B65AFDE00A370FB /* ReleasePPC10.3.9SDK */ = {
- isa = XCBuildConfiguration;
- buildSettings = {
- OTHER_LDFLAGS = (
- "$(OTHER_LDFLAGS_AQUA)",
- "$(OTHER_LDFLAGS)",
- );
- PRODUCT_NAME = tktest;
- };
- name = ReleasePPC10.3.9SDK;
- };
- F9DB62210B65AFDE00A370FB /* ReleasePPC10.3.9SDK */ = {
- isa = XCBuildConfiguration;
- baseConfigurationReference = F97AE82B0B65C69B00310EA2 /* Wish-Release.xcconfig */;
- buildSettings = {
- ARCHS = ppc;
- CFLAGS = "$(PER_ARCH_CFLAGS_ppc) $(CFLAGS)";
- CPPFLAGS = "-arch ppc -isysroot $(SDKROOT) $(CPPFLAGS)";
- MACOSX_DEPLOYMENT_TARGET = 10.3;
- PREBINDING = YES;
- SDKROOT = "$(DEVELOPER_SDK_DIR)/MacOSX10.3.9.sdk";
- };
- name = ReleasePPC10.3.9SDK;
- };
- F9DB62350B65B03A00A370FB /* ReleasePPC10.2.8SDK */ = {
- isa = XCBuildConfiguration;
- buildSettings = {
- PRODUCT_NAME = Wish;
- SKIP_INSTALL = NO;
- };
- name = ReleasePPC10.2.8SDK;
- };
- F9DB62360B65B03A00A370FB /* ReleasePPC10.2.8SDK */ = {
- isa = XCBuildConfiguration;
- buildSettings = {
- OTHER_LDFLAGS = (
- "$(OTHER_LDFLAGS_AQUA)",
- "$(OTHER_LDFLAGS)",
- );
- PRODUCT_NAME = tktest;
- };
- name = ReleasePPC10.2.8SDK;
- };
- F9DB62370B65B03A00A370FB /* ReleasePPC10.2.8SDK */ = {
- isa = XCBuildConfiguration;
- baseConfigurationReference = F97AE82B0B65C69B00310EA2 /* Wish-Release.xcconfig */;
- buildSettings = {
- ARCHS = ppc;
- CFLAGS = "$(PER_ARCH_CFLAGS_ppc) -fconstant-cfstrings $(CFLAGS)";
- CPPFLAGS = "-arch ppc -D__CONSTANT_CFSTRINGS__ -DMAC_OS_X_VERSION_MIN_REQUIRED=1020 -nostdinc -isystem $(SDKROOT)/usr/include/gcc/darwin/$(GCC_VERSION) -isystem $(SDKROOT)/usr/include -F$(SDKROOT)/System/Library/Frameworks";
- DEBUG_INFORMATION_FORMAT = stabs;
- GCC = /usr/bin/gcc;
- GCC_VERSION = 3.3;
- LDFLAGS = "-L$(SDKROOT)/usr/lib/gcc/darwin/$(GCC_VERSION) -Wl,-syslibroot,$(SDKROOT)";
- MACOSX_DEPLOYMENT_TARGET = 10.2;
- PREBINDING = YES;
- SDKROOT = "$(DEVELOPER_SDK_DIR)/MacOSX10.2.8.sdk";
- WARNING_CFLAGS = (
- "$(WARNING_CFLAGS_GCC3)",
- "-Wno-long-double",
- );
- };
- name = ReleasePPC10.2.8SDK;
- };
F9EEED960C2FEFD300396116 /* ReleaseUniversal10.5SDK */ = {
isa = XCBuildConfiguration;
buildSettings = {
@@ -5594,7 +5597,7 @@
isa = XCBuildConfiguration;
buildSettings = {
ARCHS = "$(ARCHS_STANDARD_32_64_BIT)";
- CFLAGS = "-arch i386 -arch x86_64 -arch ppc -arch ppc64 $(CFLAGS)";
+ CFLAGS = "-arch i386 -arch x86_64 -arch ppc $(CFLAGS)";
HEADER_SEARCH_PATHS = (
/usr/X11R6/include,
/usr/X11R6/include/freetype2,
@@ -5612,9 +5615,13 @@
isa = XCBuildConfiguration;
baseConfigurationReference = F97AE82B0B65C69B00310EA2 /* Wish-Release.xcconfig */;
buildSettings = {
- ARCHS = "$(ARCHS_STANDARD_32_BIT)";
- CFLAGS = "-arch i386 -arch ppc $(CFLAGS)";
+ ARCHS = "$(ARCHS_STANDARD_32_64_BIT)";
+ CFLAGS = "-arch i386 -arch x86_64 -arch ppc $(CFLAGS)";
CPPFLAGS = "-isysroot $(SDKROOT) $(CPPFLAGS)";
+ GCC_C_LANGUAGE_STANDARD = gnu99;
+ GCC_ENABLE_OBJC_GC = supported;
+ GCC_ENABLE_PASCAL_STRINGS = NO;
+ GCC_INPUT_FILETYPE = sourcecode.c.objc;
MACOSX_DEPLOYMENT_TARGET = 10.5;
PREBINDING = NO;
SDKROOT = macosx10.5;
@@ -5629,6 +5636,7 @@
buildConfigurations = (
F95CC8AC09158F3100EA5ACE /* Debug */,
F9988AB20D814C6500B6B03B /* Debug gcc42 */,
+ F90E36D60F3B5C8400810A10 /* Debug gcc42 nogc */,
F9988AB60D814C7500B6B03B /* Debug llvmgcc42 */,
F95CC8AE09158F3100EA5ACE /* DebugNoFixZL */,
F99EE73B0BE835310060D4AF /* DebugUnthreaded */,
@@ -5643,9 +5651,6 @@
F9988BB20D81586D00B6B03B /* ReleaseUniversal gcc42 */,
F9988BB60D81587400B6B03B /* ReleaseUniversal llvmgcc42 */,
F9EEED960C2FEFD300396116 /* ReleaseUniversal10.5SDK */,
- F9DB62080B65ADA800A370FB /* ReleaseUniversal10.4uSDK */,
- F9DB621F0B65AFDE00A370FB /* ReleasePPC10.3.9SDK */,
- F9DB62350B65B03A00A370FB /* ReleasePPC10.2.8SDK */,
);
defaultConfigurationIsVisible = 0;
defaultConfigurationName = Debug;
@@ -5655,6 +5660,7 @@
buildConfigurations = (
F95CC8B109158F3100EA5ACE /* Debug */,
F9988AB30D814C6500B6B03B /* Debug gcc42 */,
+ F90E36D70F3B5C8400810A10 /* Debug gcc42 nogc */,
F9988AB70D814C7500B6B03B /* Debug llvmgcc42 */,
F95CC8B309158F3100EA5ACE /* DebugNoFixZL */,
F99EE73D0BE835310060D4AF /* DebugUnthreaded */,
@@ -5669,9 +5675,6 @@
F9988BB30D81586D00B6B03B /* ReleaseUniversal gcc42 */,
F9988BB70D81587400B6B03B /* ReleaseUniversal llvmgcc42 */,
F9EEED970C2FEFD300396116 /* ReleaseUniversal10.5SDK */,
- F9DB62090B65ADA800A370FB /* ReleaseUniversal10.4uSDK */,
- F9DB62200B65AFDE00A370FB /* ReleasePPC10.3.9SDK */,
- F9DB62360B65B03A00A370FB /* ReleasePPC10.2.8SDK */,
);
defaultConfigurationIsVisible = 0;
defaultConfigurationName = Debug;
@@ -5681,6 +5684,7 @@
buildConfigurations = (
F95CC8B609158F3100EA5ACE /* Debug */,
F9988AB10D814C6500B6B03B /* Debug gcc42 */,
+ F90E36D50F3B5C8400810A10 /* Debug gcc42 nogc */,
F9988AB50D814C7500B6B03B /* Debug llvmgcc42 */,
F95CC8B809158F3100EA5ACE /* DebugNoFixZL */,
F99EE7410BE835310060D4AF /* DebugUnthreaded */,
@@ -5695,9 +5699,6 @@
F9988BB10D81586D00B6B03B /* ReleaseUniversal gcc42 */,
F9988BB50D81587400B6B03B /* ReleaseUniversal llvmgcc42 */,
F9EEED990C2FEFD300396116 /* ReleaseUniversal10.5SDK */,
- F9DB620A0B65ADA800A370FB /* ReleaseUniversal10.4uSDK */,
- F9DB62210B65AFDE00A370FB /* ReleasePPC10.3.9SDK */,
- F9DB62370B65B03A00A370FB /* ReleasePPC10.2.8SDK */,
);
defaultConfigurationIsVisible = 0;
defaultConfigurationName = Debug;
@@ -5707,6 +5708,7 @@
buildConfigurations = (
F97258A90A86873D00096C78 /* Debug */,
F9988AB40D814C6500B6B03B /* Debug gcc42 */,
+ F90E36D80F3B5C8400810A10 /* Debug gcc42 nogc */,
F9988AB80D814C7500B6B03B /* Debug llvmgcc42 */,
F97258AB0A86873D00096C78 /* DebugNoFixZL */,
F99EE73F0BE835310060D4AF /* DebugUnthreaded */,
@@ -5721,9 +5723,6 @@
F9988BB40D81586D00B6B03B /* ReleaseUniversal gcc42 */,
F9988BB80D81587400B6B03B /* ReleaseUniversal llvmgcc42 */,
F9EEED980C2FEFD300396116 /* ReleaseUniversal10.5SDK */,
- F97AED080B660A6C00310EA2 /* ReleaseUniversal10.4uSDK */,
- F97AED0F0B660AA300310EA2 /* ReleasePPC10.3.9SDK */,
- F97AED160B660AF100310EA2 /* ReleasePPC10.2.8SDK */,
);
defaultConfigurationIsVisible = 0;
defaultConfigurationName = Debug;
diff --git a/macosx/configure.ac b/macosx/configure.ac
index 229af64..8e4b251 100644
--- a/macosx/configure.ac
+++ b/macosx/configure.ac
@@ -2,6 +2,8 @@
dnl This file is an input file used by the GNU "autoconf" program to
dnl generate the file "configure", which is run during Tk installation
dnl to configure the system for the local environment.
+#
+# RCS: @(#) $Id$
dnl Ensure that the config (auto)headers support is used, then just
dnl include the configure sources from ../unix:
diff --git a/macosx/tkAboutDlg.r b/macosx/tkAboutDlg.r
deleted file mode 100644
index 1492b90..0000000
--- a/macosx/tkAboutDlg.r
+++ /dev/null
@@ -1,382 +0,0 @@
-/*
- * tkAboutDlg.r --
- *
- * This file creates resources for the Tk "About Box" dialog.
- *
- * Copyright (c) 1996 Sun Microsystems, Inc.
- * Copyright (c) 2006-2008 Daniel A. Steffen <das@users.sourceforge.net>
- *
- * See the file "license.terms" for information on usage and redistribution
- * of this file, and for a DISCLAIMER OF ALL WARRANTIES.
- */
-
-/*
- * The folowing include and defines help construct
- * the version string for Tcl.
- */
-
-#define RC_INVOKED
-#include <Carbon.r>
-#include <tcl.h>
-#include "tk.h"
-
-/*
- * The following two resources define the default "About Box" for Mac Tk.
- * This dialog appears if the "About Tk..." menu item is selected from
- * the Apple menu. This dialog may be overridden by defining a Tcl procedure
- * with the name of "tkAboutDialog". If this procedure is defined the
- * default dialog will not be shown and the Tcl procedure is expected to
- * create and manage an About Dialog box.
- */
-
-resource 'DLOG' (128, "About Box", purgeable) {
- {60, 40, 332, 404},
- kWindowMovableModalDialogProc,
- visible,
- noGoAway,
- 0x0,
- 128,
- "About Tcl & Tk",
- centerMainScreen
-};
-
-resource 'DITL' (128, "About Box", purgeable) {
- {
- {232, 147, 252, 217}, Button {enabled, "Ok"},
- { 20, 108, 212, 344}, StaticText {disabled,
- "Tcl " TCL_PATCH_LEVEL " & Tk " TK_PATCH_LEVEL "\n\n"
- "© 1987-2009 Tcl Core Team." "\n\n"
- "© 2002-2009 Daniel A. Steffen." "\n\n"
- "© 2001-2009 Apple Inc." "\n\n"
- "© 2001-2002 Jim Ingham & Ian Reid" "\n"
- "© 1998-2000 Jim Ingham & Ray Johnson" "\n"
- "© 1998-2000 Scriptics Inc." "\n"
- "© 1996-1997 Sun Microsystems Inc."},
- { 20, 24, 120, 92}, Picture {enabled, 128}
- }
-};
-
-resource 'dlgx' (128, "About Box", purgeable) {
- versionZero {
- kDialogFlagsUseThemeBackground | kDialogFlagsUseControlHierarchy
- | kDialogFlagsHandleMovableModal | kDialogFlagsUseThemeControls
- }
-};
-
-data 'PICT' (128, purgeable) {
- $"13A4 0000 0000 0064 0044 0011 02FF 0C00"
- $"FFFE 0000 0048 0000 0048 0000 0000 0000"
- $"0064 0044 0000 0000 0001 000A 0000 0000"
- $"0064 0044 0099 8044 0000 0000 0064 0044"
- $"0000 0000 0000 0000 0048 0000 0048 0000"
- $"0000 0008 0001 0008 0000 0000 0108 00D8"
- $"0000 0000 0001 5A5A 8000 00FF 3736 FF00"
- $"FF00 FF00 3535 FF00 FF00 CC00 3434 FF00"
- $"FF00 9900 3333 FF00 FF00 6600 3736 FF00"
- $"FF00 3300 3535 FF00 FF00 0000 3434 FF00"
- $"CC00 FF00 3333 FF00 CC00 CC00 3736 FF00"
- $"CC00 9900 3535 FF00 CC00 6600 FAFA FF00"
- $"CC00 3300 3333 FF00 CC00 0000 3130 FF00"
- $"9900 FF00 2F2F FF00 9900 CC00 FAFA FF00"
- $"9900 9900 F9F9 FF00 9900 6600 3130 FF00"
- $"9900 3300 2F2F FF00 9900 0000 2E2E FF00"
- $"6600 FF00 F9F9 FF00 6600 CC00 3130 FF00"
- $"6600 9900 2F2F FF00 6600 6600 2E2E FF00"
- $"6600 3300 2D2D FF00 6600 0000 3130 FF00"
- $"3300 FF00 2F2F FF00 3300 CC00 2E2E FF00"
- $"3300 9900 2D2D FF00 3300 6600 3130 FF00"
- $"3300 3300 2F2F FF00 3300 0000 2E2E FF00"
- $"0000 FF00 2D2D FF00 0000 CC00 3130 FF00"
- $"0000 9900 2F2F FF00 0000 6600 2E2E FF00"
- $"0000 3300 2DF8 FF00 0000 0000 2B2A CC00"
- $"FF00 FF00 2929 CC00 FF00 CC00 2828 CC00"
- $"FF00 9900 27F8 CC00 FF00 6600 2B2A CC00"
- $"FF00 3300 2929 CC00 FF00 0000 2828 CC00"
- $"CC00 FF00 2727 CC00 CC00 CC00 2B2A CC00"
- $"CC00 9900 2929 CC00 CC00 6600 2828 CC00"
- $"CC00 3300 2727 CC00 CC00 0000 2B2A CC00"
- $"9900 FF00 2929 CC00 9900 CC00 2828 CC00"
- $"9900 9900 2727 CC00 9900 6600 DBDB CC00"
- $"9900 3300 4747 CC00 9900 0000 4646 CC00"
- $"6600 FF00 4545 CC00 6600 CC00 DBDB CC00"
- $"6600 9900 4747 CC00 6600 6600 4646 CC00"
- $"6600 3300 4545 CC00 6600 0000 DBDB CC00"
- $"3300 FF00 4747 CC00 3300 CC00 4646 CC00"
- $"3300 9900 4545 CC00 3300 6600 DBDB CC00"
- $"3300 3300 4141 CC00 3300 0000 4040 CC00"
- $"0000 FF00 3F3F CC00 0000 CC00 4342 CC00"
- $"0000 9900 4141 CC00 0000 6600 4040 CC00"
- $"0000 3300 3F3F CC00 0000 0000 4342 9900"
- $"FF00 FF00 4141 9900 FF00 CC00 4040 9900"
- $"FF00 9900 3F3F 9900 FF00 6600 4342 9900"
- $"FF00 3300 4141 9900 FF00 0000 4040 9900"
- $"CC00 FF00 3F3F 9900 CC00 CC00 4342 9900"
- $"CC00 9900 4141 9900 CC00 6600 4040 9900"
- $"CC00 3300 3F3F 9900 CC00 0000 4342 9900"
- $"9900 FF00 4141 9900 9900 CC00 4040 9900"
- $"9900 9900 3F3F 9900 9900 6600 3D3C 9900"
- $"9900 3300 3B3B 9900 9900 0000 3A3A 9900"
- $"6600 FF00 3939 9900 6600 CC00 3D3C 9900"
- $"6600 9900 3B3B 9900 6600 6600 3A3A 9900"
- $"6600 3300 3939 9900 6600 0000 3D3C 9900"
- $"3300 FF00 3B3B 9900 3300 CC00 3A3A 9900"
- $"3300 9900 3939 9900 3300 6600 3D3C 9900"
- $"3300 3300 3B3B 9900 3300 0000 3A3A 9900"
- $"0000 FF00 3939 9900 0000 CC00 3D3C 9900"
- $"0000 9900 3B3B 9900 0000 6600 3A3A 9900"
- $"0000 3300 3939 9900 0000 0000 3D3C 6600"
- $"FF00 FF00 3B3B 6600 FF00 CC00 3A3A 6600"
- $"FF00 9900 3939 6600 FF00 6600 3D3C 6600"
- $"FF00 3300 3B3B 6600 FF00 0000 3A3A 6600"
- $"CC00 FF00 3939 6600 CC00 CC00 3736 6600"
- $"CC00 9900 3535 6600 CC00 6600 3434 6600"
- $"CC00 3300 3333 6600 CC00 0000 3736 6600"
- $"9900 FF00 3535 6600 9900 CC00 3434 6600"
- $"9900 9900 3333 6600 9900 6600 3736 6600"
- $"9900 3300 3535 6600 9900 0000 3434 6600"
- $"6600 FF00 3333 6600 6600 CC00 3736 6600"
- $"6600 9900 3535 6600 6600 6600 3434 6600"
- $"6600 3300 3333 6600 6600 0000 3736 6600"
- $"3300 FF00 3535 6600 3300 CC00 3434 6600"
- $"3300 9900 3333 6600 3300 6600 3736 6600"
- $"3300 3300 3535 6600 3300 0000 3434 6600"
- $"0000 FF00 3333 6600 0000 CC00 3130 6600"
- $"0000 9900 2F2F 6600 0000 6600 2E2E 6600"
- $"0000 3300 F9F9 6600 0000 0000 3130 3300"
- $"FF00 FF00 2F2F 3300 FF00 CC00 2E2E 3300"
- $"FF00 9900 F9F9 3300 FF00 6600 3130 3300"
- $"FF00 3300 2F2F 3300 FF00 0000 2E2E 3300"
- $"CC00 FF00 2D2D 3300 CC00 CC00 3130 3300"
- $"CC00 9900 2F2F 3300 CC00 6600 2E2E 3300"
- $"CC00 3300 2D2D 3300 CC00 0000 3130 3300"
- $"9900 FF00 2F2F 3300 9900 CC00 2E2E 3300"
- $"9900 9900 2D2D 3300 9900 6600 3130 3300"
- $"9900 3300 2F2F 3300 9900 0000 2E2E 3300"
- $"6600 FF00 2DF8 3300 6600 CC00 2B2A 3300"
- $"6600 9900 2929 3300 6600 6600 2828 3300"
- $"6600 3300 27F8 3300 6600 0000 2B2A 3300"
- $"3300 FF00 2929 3300 3300 CC00 2828 3300"
- $"3300 9900 2727 3300 3300 6600 2B2A 3300"
- $"3300 3300 2929 3300 3300 0000 2828 3300"
- $"0000 FF00 2727 3300 0000 CC00 2B2A 3300"
- $"0000 9900 2929 3300 0000 6600 2828 3300"
- $"0000 3300 2727 3300 0000 0000 4948 0000"
- $"FF00 FF00 4747 0000 FF00 CC00 4646 0000"
- $"FF00 9900 4545 0000 FF00 6600 4948 0000"
- $"FF00 3300 4747 0000 FF00 0000 4646 0000"
- $"CC00 FF00 4545 0000 CC00 CC00 4948 0000"
- $"CC00 9900 4747 0000 CC00 6600 4646 0000"
- $"CC00 3300 4545 0000 CC00 0000 4342 0000"
- $"9900 FF00 4141 0000 9900 CC00 4040 0000"
- $"9900 9900 3F3F 0000 9900 6600 4342 0000"
- $"9900 3300 4141 0000 9900 0000 4040 0000"
- $"6600 FF00 3F3F 0000 6600 CC00 4342 0000"
- $"6600 9900 4141 0000 6600 6600 4040 0000"
- $"6600 3300 3F3F 0000 6600 0000 4342 0000"
- $"3300 FF00 4141 0000 3300 CC00 4040 0000"
- $"3300 9900 3F3F 0000 3300 6600 4342 0000"
- $"3300 3300 4141 0000 3300 0000 4040 0000"
- $"0000 FF00 3F3F 0000 0000 CC00 4342 0000"
- $"0000 9900 4141 0000 0000 6600 4040 0000"
- $"0000 3300 3F3F EE00 0000 0000 3D3C DD00"
- $"0000 0000 3B3B BB00 0000 0000 3A3A AA00"
- $"0000 0000 3939 8800 0000 0000 3D3C 7700"
- $"0000 0000 3B3B 5500 0000 0000 3A3A 4400"
- $"0000 0000 3939 2200 0000 0000 3D3C 1100"
- $"0000 0000 3B3B 0000 EE00 0000 3A3A 0000"
- $"DD00 0000 3939 0000 BB00 0000 3D3C 0000"
- $"AA00 0000 3B3B 0000 8800 0000 3A3A 0000"
- $"7700 0000 3939 0000 5500 0000 3D3C 0000"
- $"4400 0000 3B3B 0000 2200 0000 3A3A 0000"
- $"1100 0000 3939 0000 0000 EE00 3D3C 0000"
- $"0000 DD00 3B3B 0000 0000 BB00 3A3A 0000"
- $"0000 AA00 3939 0000 0000 8800 3D3C 0000"
- $"0000 7700 3B3B 0000 0000 5500 3A3A 0000"
- $"0000 4400 3939 0000 0000 2200 3736 0000"
- $"0000 1100 3535 EE00 EE00 EE00 3434 DD00"
- $"DD00 DD00 3333 BB00 BB00 BB00 3736 AA00"
- $"AA00 AA00 3535 8800 8800 8800 3434 7700"
- $"7700 7700 3333 5500 5500 5500 3736 4400"
- $"4400 4400 3535 2200 2200 2200 3434 1100"
- $"1100 1100 3333 0000 0000 0000 0000 0000"
- $"0064 0044 0000 0000 0064 0044 0000 000A"
- $"0000 0000 0064 0044 02BD 0013 E800 01F5"
- $"F6FE 07FE 0E02 3232 33FD 3900 0EE6 001D"
- $"FC00 01F5 F5FE 0700 08FE 0E02 3232 33FE"
- $"3900 3AFC 40F2 4102 4033 07E9 0017 0100"
- $"0EFC 40DC 4102 390E F5F5 0002 F5F5 F6FE"
- $"0702 0E07 0016 0100 32D5 4104 4039 0E32"
- $"33FD 3900 3AFC 40FC 4101 3200 0801 000E"
- $"C141 010E 0008 0100 0EC1 4101 0800 0801"
- $"000E C141 0107 0008 0100 0EC1 4101 0700"
- $"0901 0007 C241 0240 F500 0E01 0007 E841"
- $"0147 47DD 4102 4000 0012 0100 07F0 4100"
- $"47FA 4101 3B3B DD41 0240 0000 1901 0007"
- $"F141 0C47 3B0B 3B47 4141 4711 0505 3B47"
- $"DF41 023A 0000 1701 00F6 F041 010B 0BFE"
- $"4105 473B 0505 113B DE41 0239 0000 1A02"
- $"00F5 40F3 410C 473B 053B 4741 4741 0B0B"
- $"3B47 47DE 4102 3900 0018 0200 F540 F341"
- $"0247 110B FE41 0447 1105 4147 DC41 0233"
- $"0000 1B02 0000 40F3 4103 4711 1147 FE41"
- $"0205 3547 F741 FD47 E941 0232 0000 1E02"
- $"0000 40F2 4106 113B 4741 4735 0BF7 4106"
- $"4741 390E 0E40 47EA 4102 0E00 0021 0200"
- $"0040 F241 0711 3B47 4141 0B35 47F9 4102"
- $"4740 07FE 0002 F640 47EB 4102 0E00 0023"
- $"0200 0040 F341 0847 3541 4147 3B05 4147"
- $"FA41 0947 3AF6 00F5 4F55 F50E 47EB 4102"
- $"0700 0022 0200 003A F341 0147 3BFE 4101"
- $"0B0B F941 0547 3AF5 0055 C8FE CE01 5640"
- $"EB41 0207 0000 1F02 0000 39F0 4104 4741"
- $"053B 47FB 4104 4740 F5F5 A4FC CE01 C85D"
- $"EB41 02F6 0000 1F02 0000 39F0 4104 473B"
- $"0541 47FC 4104 4740 07F6 C8FA CE00 64EC"
- $"4103 40F5 0000 1C02 0000 39F0 4102 4711"
- $"0BFA 4103 4708 2AC8 FACE 0164 D8EC 4100"
- $"40FE 0025 0200 0039 EF41 020B 3B47 FC41"
- $"0347 0FF5 A4FB CE02 C887 D8FC 41FE 47FC"
- $"4100 47F9 4100 3AFE 0028 0200 0039 EF41"
- $"020B 3B47 FD41 0347 3900 A4FA CE00 ABFA"
- $"4109 3B11 3B41 4147 3B0B 3B47 FA41 0039"
- $"FE00 2402 0000 33F1 4102 4741 0BFA 4101"
- $"0779 F9CE 0064 FA41 0235 050B FD41 010B"
- $"0BF9 4100 39FE 0028 0200 0032 F141 0247"
- $"3B0B FC41 0247 39F6 F9CE 0187 D8FB 4103"
- $"4741 050B FE41 0247 110B F941 0039 FE00"
- $"2C02 0000 32F1 4102 473B 11FB 4101 0879"
- $"FACE 05AA 4041 4147 47FE 410A 4741 0511"
- $"4741 4147 3511 47FA 4100 32FE 002F 0200"
- $"000E F141 0347 3B11 47FE 4103 4740 F6C8"
- $"FACE 0564 D841 4039 39FE 4104 473B 053B"
- $"47FE 4102 3541 47FA 4100 0EFE 0027 0200"
- $"000E F141 0347 3B3B 47FE 4102 470F 79FA"
- $"CE0C 8741 4032 F500 003A 4741 473B 05F2"
- $"4100 0EFE 0027 0200 000E F141 0347 3B3B"
- $"47FD 4101 0EA4 FACE 01AB AAFE C808 7900"
- $"3947 4147 110B 47F3 4100 07FE 001C 0200"
- $"000E EA41 0240 2BC8 F5CE 0881 0033 4741"
- $"410B 3B47 F341 0007 FE00 1A02 0000 08EB"
- $"4102 473A 55F4 CE06 5D00 3947 4741 0BF1"
- $"4100 F6FE 001C 0200 0007 EB41 0247 3979"
- $"F4CE 0739 0039 4747 3511 47F3 4101 40F5"
- $"FE00 1C02 0000 07EB 4102 4739 A4F5 CE08"
- $"AB0E 0040 4741 1141 47F3 4100 40FD 001B"
- $"0200 0007 EB41 0247 39A4 F5CE 0787 0707"
- $"4147 4111 47F2 4100 40FD 001B 0200 0007"
- $"EB41 0247 39C8 F5CE 0763 F532 4747 3B3B"
- $"47F2 4100 3AFD 001A 0300 00F6 40EC 4102"
- $"4739 C8F5 CE05 39F5 4047 413B F041 0039"
- $"FD00 1C03 0000 F540 EB41 0140 C8FD CE01"
- $"C8A4 FCCE 03AB 080E 47ED 4100 39FD 001A"
- $"FE00 0040 EB41 0040 FCCE 01A4 C8FC CE03"
- $"FA07 4047 ED41 0032 FD00 1AFE 0000 40EA"
- $"4100 AAFE CE02 87F9 C8FC CE02 560F 47EC"
- $"4100 32FD 0019 FE00 0040 EA41 00AB FECE"
- $"0264 56C8 FDCE 01C8 32EA 4100 0EFD 001B"
- $"FE00 0040 ED41 030E 4047 87FE CE01 4055"
- $"FCCE 01FA 40EA 4100 08FD 001A FE00 003A"
- $"ED41 0807 0740 FBCE CEAB 3979 FDCE 00AB"
- $"E841 0007 FD00 1CFE 0000 3AED 4108 0700"
- $"F6A4 CECE 8733 79FD CE02 4147 47EA 4100"
- $"07FD 001E FE00 0039 ED41 0807 2AA4 C8CE"
- $"CE88 0E9D FECE 0364 1C39 39EB 4101 40F5"
- $"FD00 1CFE 0000 39ED 4101 074F FDCE 0264"
- $"F7A4 FECE 03AB 80F6 07EB 4100 40FC 001C"
- $"FE00 0039 ED41 0108 79FE CE03 AB40 2BA4"
- $"FCCE 02F7 0E47 EC41 0040 FC00 1CFE 0000"
- $"39ED 4101 0879 FECE 03AB 40F6 C8FC CE02"
- $"F615 47EC 4100 40FC 001E FE00 003A EE41"
- $"0247 0E79 FECE 03AB 40F5 C8FD CE03 A4F5"
- $"3A47 EC41 0040 FC00 1EFE 0000 3AEE 4102"
- $"470E 56FE CE03 FB3A F6C8 FDCE 0280 F540"
- $"EB41 0140 F5FD 001E FE00 0040 EE41 0947"
- $"0F56 CECE C888 39F6 C8FD CE02 5601 40EB"
- $"4101 40F5 FD00 1CFE 0000 40EE 4109 4739"
- $"32CE CEC8 8839 2AC8 FDCE 0156 07E9 4100"
- $"F6FD 001B FE00 0040 EE41 0847 3A32 CECE"
- $"C864 152A FCCE 0132 07E9 4100 07FD 001A"
- $"FE00 0040 ED41 0740 32AB CEC8 6439 4EFC"
- $"CE01 3A07 E941 0007 FD00 1D03 0000 F540"
- $"ED41 0740 0EAB CECE 640F 4EFD CE03 AB40"
- $"0840 EA41 0007 FD00 1B03 0000 F540 EC41"
- $"060F 81CE CE64 334E FDCE 02AB 400E E941"
- $"000E FD00 1C02 0000 F6EC 4107 4715 FACE"
- $"CE64 334E FDCE 0387 0F0E 47EA 4100 0EFD"
- $"001C 0200 0007 EC41 0747 16F9 CEC8 6433"
- $"4EFD CE03 6308 4047 EA41 000E FD00 1A02"
- $"0000 07EB 4106 40F9 CEC8 6439 4EFD CE02"
- $"3940 47E9 4100 32FD 001B 0200 0007 EA41"
- $"0539 CECE 8839 F6FE CE04 AB41 4139 40EA"
- $"4100 32FD 001C 0200 0007 EB41 0E47 3AC8"
- $"CE88 39F6 C8CE CE64 15F6 F540 EA41 0033"
- $"FD00 1A02 0000 07EA 410C 40A4 CE87 392A"
- $"C8CE AB41 40F8 F6E9 4100 39FD 001B 0200"
- $"000E EB41 0D47 41AB C887 39F5 C8CE ABAB"
- $"CEA4 07E9 4100 39FD 001C 0200 000E ED41"
- $"0947 3939 4787 C8AB 40F5 C8FD CE01 A40E"
- $"E941 0039 FD00 1D02 0000 0EED 4109 473A"
- $"0007 80CE AB40 F5C8 FDCE 0255 0E47 EA41"
- $"0039 FD00 1B02 0000 0EEB 4107 0779 C8CE"
- $"CE40 F6A4 FDCE 022B 3947 EA41 003A FD00"
- $"1C02 0000 0EEC 4102 4739 79FE CE02 6407"
- $"A4FE CE02 A407 40E9 4100 40FD 001A 0200"
- $"0032 EA41 0632 A4CE CE88 0879 FECE 02F9"
- $"0F47 E941 0040 FD00 1A02 0000 32EB 4107"
- $"4740 F7C8 CE87 0E79 FECE 0132 40E8 4100"
- $"40FD 0019 0200 0033 EA41 0B47 40F8 C8AB"
- $"0E55 CECE 8015 47E8 4100 40FD 0017 0200"
- $"0033 E941 0847 40F9 A439 4FCE CE5D E641"
- $"0140 F5FE 0014 0200 0039 E841 0647 64FB"
- $"392B C8AB E441 00F6 FE00 1102 0000 39E5"
- $"4103 40F6 8764 E441 0007 FE00 1E02 0000"
- $"39EB 4102 3A0E 0EFD 4102 0740 47F6 4104"
- $"400F 0839 47F4 4100 07FE 0027 0200 0039"
- $"FB41 0147 47F2 4102 0800 40FE 4102 0839"
- $"47FC 4101 4747 FC41 0339 0039 47F4 4100"
- $"07FE 0029 0200 0039 FB41 0140 39F3 4109"
- $"470E F540 4141 470E 3347 FC41 0139 3AFD"
- $"4104 4739 0039 47F4 4100 08FE 0036 0200"
- $"003A FC41 0347 0E00 40FC 4102 4741 40FC"
- $"4109 470E F540 4141 4733 0E47 FE41 0447"
- $"4000 0E47 FE41 0447 3900 3941 FE40 F741"
- $"000E FE00 3A02 0000 3AFD 410E 4740 0700"
- $"0E40 4741 4147 390E 390E 40FE 4108 470E"
- $"F540 4141 4739 0EFC 4103 0F00 0739 FE41"
- $"0747 3900 3940 080F 39F7 4100 0EFE 0035"
- $"0200 0040 FB41 020E 0040 FE41 0D47 4000"
- $"3941 0032 4741 4147 0EF5 40FE 4101 4008"
- $"FC41 023A 000E FD41 0547 3900 3939 33F5"
- $"4100 0EFE 0039 0200 0040 FC41 0347 0E00"
- $"40FE 4106 4732 0040 4139 40FE 4103 470E"
- $"F540 FD41 0108 40FE 4104 4740 000E 47FE"
- $"4106 4739 0007 F540 47F6 4100 32FE 003A"
- $"0200 0040 FC41 0C47 0E00 4047 4141 470E"
- $"0040 4747 FD41 0347 0EF5 40FE 410A 470E"
- $"3947 4141 4740 000E 47FE 4107 4739 000E"
- $"0007 4147 F741 0032 FE00 3802 0000 40FC"
- $"4102 470E 00FD 4106 4739 003A 4740 39FE"
- $"4102 470E F5FD 410A 4733 3347 4141 4740"
- $"000E 47FE 4106 4739 0039 3900 0EF6 4100"
- $"33FE 003A 0200 F540 FC41 0447 3200 0E39"
- $"FD41 0B0E 0E40 333A 4741 413A 07F5 39FE"
- $"4102 473A 0EFD 410F 40F5 0733 4041 4140"
- $"0E00 0E40 0700 0E40 F841 0039 FE00 2902"
- $"00F5 40FA 4101 3939 FB41 023A 3A40 FD41"
- $"FD40 FD41 0240 0E40 FD41 0240 3940 FD41"
- $"FA40 F741 0039 FE00 2A01 00F6 F941 0147"
- $"47FB 4101 4747 FB41 0147 47FB 4101 3940"
- $"FD41 0147 47FB 4100 47FE 4100 47F6 4100"
- $"39FE 000D 0100 07E1 4100 40E4 4100 3AFE"
- $"0009 0100 07C3 4100 3AFE 0009 0100 07C3"
- $"4100 40FE 0009 0100 07C3 4100 40FE 0009"
- $"0100 07C3 4100 40FE 000A 0100 0EC3 4103"
- $"40F5 0000 0901 000E C241 02F6 0000 0901"
- $"000E C241 0207 0000 0901 000E C241 0207"
- $"0000 1101 000E ED41 FE40 003A F940 E241"
- $"0207 0000 2B01 0032 F941 FE40 FE39 0632"
- $"0E0E 0707 F6F5 F800 02F5 F5F6 FB07 FB0E"
- $"0332 3233 33FB 3901 3A3A FB40 0207 0000"
- $"0E0A 000E 3939 320E 0E07 07F6 F5C8 0002"
- $"BD00 00FF"
-};
diff --git a/macosx/tkMacOSX.h b/macosx/tkMacOSX.h
index a2a35a5..4ae9920 100644
--- a/macosx/tkMacOSX.h
+++ b/macosx/tkMacOSX.h
@@ -4,11 +4,13 @@
* Declarations of Macintosh specific exported variables and procedures.
*
* Copyright (c) 1995-1997 Sun Microsystems, Inc.
- * Copyright 2001, Apple Computer, Inc.
- * Copyright (c) 2005-2007 Daniel A. Steffen <das@users.sourceforge.net>
+ * Copyright 2001-2009, Apple Inc.
+ * Copyright (c) 2005-2009 Daniel A. Steffen <das@users.sourceforge.net>
*
* See the file "license.terms" for information on usage and redistribution
* of this file, and for a DISCLAIMER OF ALL WARRANTIES.
+ *
+ * RCS: @(#) $Id$
*/
#ifndef _TKMAC
@@ -18,18 +20,16 @@
#include "tk.h"
#endif
-#include <Carbon/Carbon.h>
-
/*
* Structures and function types for handling Netscape-type in process
* embedding where Tk does not control the top-level
*/
-typedef int (Tk_MacOSXEmbedRegisterWinProc) (int winID, Tk_Window window);
-typedef GWorldPtr (Tk_MacOSXEmbedGetGrafPortProc) (Tk_Window window);
+typedef int (Tk_MacOSXEmbedRegisterWinProc) (long winID, Tk_Window window);
+typedef void* (Tk_MacOSXEmbedGetGrafPortProc) (Tk_Window window);
typedef int (Tk_MacOSXEmbedMakeContainerExistProc) (Tk_Window window);
-typedef void (Tk_MacOSXEmbedGetClipProc) (Tk_Window window, RgnHandle rgn);
-typedef void (Tk_MacOSXEmbedGetOffsetInParentProc) (Tk_Window window, Point *ulCorner);
+typedef void (Tk_MacOSXEmbedGetClipProc) (Tk_Window window, TkRegion rgn);
+typedef void (Tk_MacOSXEmbedGetOffsetInParentProc) (Tk_Window window, void *ulCorner);
#include "tkPlatDecls.h"
diff --git a/macosx/tkMacOSXAETE.r b/macosx/tkMacOSXAETE.r
deleted file mode 100644
index 54bb8cc..0000000
--- a/macosx/tkMacOSXAETE.r
+++ /dev/null
@@ -1,51 +0,0 @@
-/*
- * tclMacAETE.r --
- *
- * This file creates the Apple Event Terminology resources
- * for use by Wish.app.
- *
- * Copyright (c) 1997 Sun Microsystems, Inc.
- *
- * See the file "license.terms" for information on usage and redistribution
- * of this file, and for a DISCLAIMER OF ALL WARRANTIES.
- */
-
-#define SystemSevenOrLater 1
-
-#include <Carbon.r>
-
-/*
- * The following resources defines the Apple Events that Tk can be
- * sent from Apple Script.
- */
-
-resource 'aete' (0, "Wish Suite") {
- 0x01, 0x00, english, roman,
- {
- "Required Suite",
- "Events that every application should support",
- 'reqd', 1, 1,
- {},
- {},
- {},
- {},
-
- "Wish Suite", "Events for the Wish application", 'WIsH', 1, 1,
- {
- "do script", "Execute a Tcl script", 'misc', kAEDoScript,
- 'TEXT', "Result", replyOptional, singleItem,
- notEnumerated, reserved, reserved, reserved, reserved,
- reserved, reserved, reserved, reserved, reserved,
- reserved, reserved, reserved, reserved,
- 'TEXT', "Script to execute", directParamRequired,
- singleItem, notEnumerated, changesState, reserved,
- reserved, reserved, reserved, reserved, reserved,
- reserved, reserved, reserved, reserved, reserved,
- reserved,
- {},
- },
- {},
- {},
- {},
- }
-};
diff --git a/macosx/tkMacOSXBitmap.c b/macosx/tkMacOSXBitmap.c
index c5b2df9..55512be 100644
--- a/macosx/tkMacOSXBitmap.c
+++ b/macosx/tkMacOSXBitmap.c
@@ -4,31 +4,16 @@
* This file handles the implementation of native bitmaps.
*
* Copyright (c) 1996-1997 Sun Microsystems, Inc.
- * Copyright 2001, Apple Computer, Inc.
- * Copyright (c) 2006-2007 Daniel A. Steffen <das@users.sourceforge.net>
+ * Copyright 2001-2009, Apple Inc.
+ * Copyright (c) 2006-2009 Daniel A. Steffen <das@users.sourceforge.net>
*
* See the file "license.terms" for information on usage and redistribution
* of this file, and for a DISCLAIMER OF ALL WARRANTIES.
+ *
+ * RCS: @(#) $Id$
*/
-#include "tkMacOSXInt.h"
-
-/*
- * Depending on the resource type there are different ways to
- * draw native icons.
- */
-#define TYPE1 0 /* Family icon suite. */
-#define TYPE2 1 /* ICON resource. */
-#define TYPE3 2 /* cicn resource. */
-
-/*
- * This data structure describes the id and type of a given icon.
- * It is used as the source for native icons.
- */
-typedef struct {
- int id; /* Resource Id for Icon. */
- long int type; /* Type of icon. */
-} NativeIcon;
+#include "tkMacOSXPrivate.h"
/*
* This structure holds information about native bitmaps.
@@ -36,9 +21,7 @@ typedef struct {
typedef struct {
const char *name; /* Name of icon. */
- long int type; /* Type of icon. */
- int id; /* Id of icon. */
- int size; /* Size of icon. */
+ OSType iconType; /* OSType of icon. */
} BuiltInIcon;
/*
@@ -47,24 +30,42 @@ typedef struct {
*/
static BuiltInIcon builtInIcons[] = {
- {"document", TYPE1, kGenericDocumentIconResource, 32},
- {"stationery", TYPE1, kGenericStationeryIconResource, 32},
- {"edition", TYPE1, kGenericEditionFileIconResource, 32},
- {"application", TYPE1, kGenericApplicationIconResource, 32},
- {"accessory", TYPE1, kGenericDeskAccessoryIconResource, 32},
- {"folder", TYPE1, kGenericFolderIconResource, 32},
- {"pfolder", TYPE1, kPrivateFolderIconResource, 32},
- {"trash", TYPE1, kTrashIconResource, 32},
- {"floppy", TYPE1, kFloppyIconResource, 32},
- {"ramdisk", TYPE1, kGenericRAMDiskIconResource, 32},
- {"cdrom", TYPE1, kGenericCDROMIconResource, 32},
- {"preferences", TYPE1, kGenericPreferencesIconResource, 32},
- {"querydoc", TYPE1, kGenericQueryDocumentIconResource, 32},
- {"stop", TYPE2, kStopIcon, 32},
- {"note", TYPE2, kNoteIcon, 32},
- {"caution", TYPE2, kCautionIcon, 32},
- {NULL, 0, 0, 0}
+ {"document", kGenericDocumentIcon},
+ {"stationery", kGenericStationeryIcon},
+ {"edition", kGenericEditionFileIcon},
+ {"application", kGenericApplicationIcon},
+ {"accessory", kGenericDeskAccessoryIcon},
+ {"folder", kGenericFolderIcon},
+ {"pfolder", kPrivateFolderIcon},
+ {"trash", kTrashIcon},
+ {"floppy", kGenericFloppyIcon},
+ {"ramdisk", kGenericRAMDiskIcon},
+ {"cdrom", kGenericCDROMIcon},
+ {"preferences", kGenericPreferencesIcon},
+ {"querydoc", kGenericQueryDocumentIcon},
+ {"stop", kAlertStopIcon},
+ {"note", kAlertNoteIcon},
+ {"caution", kAlertCautionIcon},
+ {NULL}
+};
+
+#define builtInIconSize 32
+
+static Tcl_HashTable iconBitmapTable = {};
+typedef struct {
+ int kind, width, height;
+ char *value;
+} IconBitmap;
+
+static const char *iconBitmapOptionStrings[] = {
+ "-file", "-fileType", "-osType", "-systemType", "-namedImage",
+ "-imageFile", NULL
+};
+enum iconBitmapOptions {
+ ICON_FILE, ICON_FILETYPE, ICON_OSTYPE, ICON_SYSTEMTYPE, ICON_NAMEDIMAGE,
+ ICON_IMAGEFILE,
};
+
/*
*----------------------------------------------------------------------
@@ -92,7 +93,7 @@ TkpDefineNativeBitmaps(void)
for (builtInPtr = builtInIcons; builtInPtr->name != NULL; builtInPtr++) {
Tcl_HashEntry *predefHashPtr;
- const char * name;
+ Tk_Uid name;
int isNew;
name = Tk_GetUid(builtInPtr->name);
@@ -100,14 +101,9 @@ TkpDefineNativeBitmaps(void)
if (isNew) {
TkPredefBitmap *predefPtr = (TkPredefBitmap *)
ckalloc(sizeof(TkPredefBitmap));
- NativeIcon *nativeIconPtr = (NativeIcon *)
- ckalloc(sizeof(NativeIcon));
-
- nativeIconPtr->id = builtInPtr->id;
- nativeIconPtr->type = builtInPtr->type;
- predefPtr->source = (char *) nativeIconPtr;
- predefPtr->width = builtInPtr->size;
- predefPtr->height = builtInPtr->size;
+ predefPtr->source = UINT2PTR(builtInPtr->iconType);
+ predefPtr->width = builtInIconSize;
+ predefPtr->height = builtInIconSize;
predefPtr->native = 1;
Tcl_SetHashValue(predefHashPtr, predefPtr);
}
@@ -117,17 +113,54 @@ TkpDefineNativeBitmaps(void)
/*
*----------------------------------------------------------------------
*
+ * GetBitmapForIcon --
+ *
+ * Results:
+ * Bitmap for the given IconRef.
+ *
+ * Side effects:
+ * None.
+ *
+ *----------------------------------------------------------------------
+ */
+
+static Pixmap
+GetBitmapForIcon(
+ Display *display,
+ IconRef icon,
+ CGSize size)
+{
+ TkMacOSXDrawingContext dc;
+ Pixmap pixmap;
+
+ pixmap = Tk_GetPixmap(display, None, size.width, size.height, 0);
+ if (TkMacOSXSetupDrawingContext(pixmap, NULL, 1, &dc)) {
+ if (dc.context) {
+ const CGAffineTransform t = { .a = 1, .b = 0, .c = 0, .d = -1,
+ .tx = 0, .ty = size.height };
+ const CGRect r = { .origin = { .x = 0, .y = 0 }, .size = size };
+
+ CGContextConcatCTM(dc.context, t);
+ PlotIconRefInContext(dc.context, &r, kAlignAbsoluteCenter,
+ kTransformNone, NULL, kPlotIconRefNormalFlags, icon);
+ }
+ TkMacOSXRestoreDrawingContext(&dc);
+ }
+ return pixmap;
+}
+
+/*
+ *----------------------------------------------------------------------
+ *
* TkpCreateNativeBitmap --
*
- * Add native bitmaps.
+ * Create native bitmap.
*
* Results:
- * A standard Tcl result. If an error occurs then TCL_ERROR is
- * returned and a message is left in the interp's result.
+ * Native bitmap.
*
* Side effects:
- * "Name" is entered into the bitmap table and may be used from
- * here on to refer to the given bitmap.
+ * None.
*
*----------------------------------------------------------------------
*/
@@ -135,41 +168,58 @@ TkpDefineNativeBitmaps(void)
Pixmap
TkpCreateNativeBitmap(
Display *display,
- CONST char *source) /* Info about the icon to build. */
+ const char *source) /* Info about the icon to build. */
{
- Pixmap pix;
- Rect destRect;
- CGrafPtr savePort;
- Boolean portChanged;
- const NativeIcon *nativeIconPtr;
-
- pix = Tk_GetPixmap(display, None, 32, 32, 0);
- portChanged = QDSwapPort(TkMacOSXGetDrawablePort(pix), &savePort);
+ Pixmap pixmap;
+ IconRef icon;
+ OSErr err;
- nativeIconPtr = (const NativeIcon *) source;
- SetRect(&destRect, 0, 0, 32, 32);
- if (nativeIconPtr->type == TYPE1) {
- RGBColor white = {0xFFFF, 0xFFFF, 0xFFFF};
-
- RGBForeColor(&white);
- PaintRect(&destRect);
- PlotIconID(&destRect, atAbsoluteCenter, ttNone, nativeIconPtr->id);
- } else if (nativeIconPtr->type == TYPE2) {
- Handle icon = GetIcon(nativeIconPtr->id);
-
- if (icon != NULL) {
- RGBColor black = {0, 0, 0};
-
- RGBForeColor(&black);
- PlotIcon(&destRect, icon);
- ReleaseResource(icon);
- }
+ err = ChkErr(GetIconRef, kOnSystemDisk, kSystemIconsCreator,
+ PTR2UINT(source), &icon);
+ if (err == noErr) {
+ pixmap = GetBitmapForIcon(display, icon, CGSizeMake(builtInIconSize,
+ builtInIconSize));
+ ReleaseIconRef(icon);
+ } else {
+ pixmap = Tk_GetPixmap(display, None, builtInIconSize,
+ builtInIconSize, 0);
}
+ return pixmap;
+}
+
+/*
+ *----------------------------------------------------------------------
+ *
+ * OSTypeFromString --
+ *
+ * Helper to convert string to OSType.
+ *
+ * Results:
+ * A standard Tcl result.
+ *
+ * Side effects:
+ * t is set to OSType if conversion successful.
+ *
+ *----------------------------------------------------------------------
+ */
+
+static int
+OSTypeFromString(const char *s, OSType *t) {
+ int result = TCL_ERROR;
+ Tcl_DString ds;
+ Tcl_Encoding encoding = Tcl_GetEncoding(NULL, "macRoman");
- if (portChanged) {
- QDSwapPort(savePort, NULL);
+ Tcl_UtfToExternalDString(encoding, s, -1, &ds);
+ if (Tcl_DStringLength(&ds) <= 4) {
+ char string[4] = {};
+ memcpy(string, Tcl_DStringValue(&ds), (size_t) Tcl_DStringLength(&ds));
+ *t = (OSType) string[0] << 24 | (OSType) string[1] << 16 |
+ (OSType) string[2] << 8 | (OSType) string[3];
+ result = TCL_OK;
}
- return pix;
+ Tcl_DStringFree(&ds);
+ Tcl_FreeEncoding(encoding);
+ return result;
}
/*
@@ -177,15 +227,19 @@ TkpCreateNativeBitmap(
*
* TkpGetNativeAppBitmap --
*
- * Add native bitmaps.
+ * Get a named native bitmap.
+ *
+ * Attemps to interpret the given name in order as:
+ * - name defined by ::tk::mac::iconBitmap
+ * - NSImage named image name
+ * - NSImage url string
+ * - 4-char OSType of IconServices icon
*
* Results:
- * A standard Tcl result. If an error occurs then TCL_ERROR is
- * returned and a message is left in the interp's result.
+ * Native bitmap or None.
*
* Side effects:
- * "Name" is entered into the bitmap table and may be used from
- * here on to refer to the given bitmap.
+ * None.
*
*----------------------------------------------------------------------
*/
@@ -193,78 +247,211 @@ TkpCreateNativeBitmap(
Pixmap
TkpGetNativeAppBitmap(
Display *display, /* The display. */
- CONST char *name, /* The name of the bitmap. */
+ const char *name, /* The name of the bitmap. */
int *width, /* The width & height of the bitmap. */
int *height)
{
- Pixmap pix;
- CGrafPtr savePort;
- Boolean portChanged;
- Rect destRect;
- Handle resource;
- int type = -1, destWrote;
- Str255 nativeName;
- Tcl_Encoding encoding;
-
- /*
- * macRoman is the encoding that the resource fork uses.
- */
+ Tcl_HashEntry *hPtr;
+ Pixmap pixmap = None;
+ NSString *string;
+ NSImage *image = nil;
+ NSSize size = { .width = builtInIconSize, .height = builtInIconSize };
- encoding = Tcl_GetEncoding(NULL, "macRoman");
- Tcl_UtfToExternal(NULL, encoding, name, strlen(name), 0, NULL,
- (char *) &nativeName[1], 255, NULL, &destWrote, NULL);
- nativeName[0] = destWrote;
- Tcl_FreeEncoding(encoding);
-
- resource = GetNamedResource('cicn', nativeName);
- if (resource != NULL) {
- type = TYPE3;
+ if (iconBitmapTable.buckets &&
+ (hPtr = Tcl_FindHashEntry(&iconBitmapTable, name))) {
+ OSType type;
+ IconBitmap *iconBitmap = Tcl_GetHashValue(hPtr);
+ name = NULL;
+ size = NSMakeSize(iconBitmap->width, iconBitmap->height);
+ switch (iconBitmap->kind) {
+ case ICON_FILE:
+ string = [[NSString stringWithUTF8String:iconBitmap->value]
+ stringByExpandingTildeInPath];
+ image = [[NSWorkspace sharedWorkspace] iconForFile:string];
+ break;
+ case ICON_FILETYPE:
+ string = [NSString stringWithUTF8String:iconBitmap->value];
+ image = [[NSWorkspace sharedWorkspace] iconForFileType:string];
+ break;
+ case ICON_OSTYPE:
+ if (OSTypeFromString(iconBitmap->value, &type) == TCL_OK) {
+ string = NSFileTypeForHFSTypeCode(type);
+ image = [[NSWorkspace sharedWorkspace] iconForFileType:string];
+ }
+ break;
+ case ICON_SYSTEMTYPE:
+ name = iconBitmap->value;
+ break;
+ case ICON_NAMEDIMAGE:
+ string = [NSString stringWithUTF8String:iconBitmap->value];
+ image = [NSImage imageNamed:string];
+ break;
+ case ICON_IMAGEFILE:
+ string = [[NSString stringWithUTF8String:iconBitmap->value]
+ stringByExpandingTildeInPath];
+ image = [[[NSImage alloc] initWithContentsOfFile:string]
+ autorelease];
+ break;
+ }
+ if (image) {
+ [image setSize:size];
+ }
} else {
- resource = GetNamedResource('ICON', nativeName);
- if (resource != NULL) {
- type = TYPE2;
+ string = [NSString stringWithUTF8String:name];
+ image = [NSImage imageNamed:string];
+ if (!image) {
+ NSURL *url = [NSURL URLWithString:string];
+ if (url) {
+ image = [[[NSImage alloc] initWithContentsOfURL:url]
+ autorelease];
+ }
+ }
+ if (image) {
+ size = [image size];
}
}
+ if (image) {
+ TkMacOSXDrawingContext dc;
+ int depth = 0;
- if (resource == NULL) {
- return (Pixmap) NULL;
- }
-
- pix = Tk_GetPixmap(display, None, 32, 32, 0);
- portChanged = QDSwapPort(TkMacOSXGetDrawablePort(pix), &savePort);
-
- SetRect(&destRect, 0, 0, 32, 32);
- if (type == TYPE2) {
- RGBColor black = {0, 0, 0};
+#ifdef MAC_OSX_TK_TODO
+ for (NSImageRep *r in [image representations]) {
+ NSInteger bitsPerSample = [r bitsPerSample];
+ if (bitsPerSample && bitsPerSample > depth) {
+ depth = bitsPerSample;
+ };
+ }
+ if (depth == 1) {
+ /* TODO: convert BW NSImage to CGImageMask */
+ }
+#endif
+ pixmap = Tk_GetPixmap(display, None, size.width, size.height, depth);
+ *width = size.width;
+ *height = size.height;
+ if (TkMacOSXSetupDrawingContext(pixmap, NULL, 1, &dc)) {
+ if (dc.context) {
+ CGAffineTransform t = { .a = 1, .b = 0, .c = 0, .d = -1,
+ .tx = 0, .ty = size.height};
- RGBForeColor(&black);
- PlotIcon(&destRect, resource);
- ReleaseResource(resource);
- } else if (type == TYPE3) {
- RGBColor white = {0xFFFF, 0xFFFF, 0xFFFF};
- short id;
- ResType theType;
- Str255 dummy;
+ CGContextConcatCTM(dc.context, t);
+ [NSGraphicsContext saveGraphicsState];
+ [NSGraphicsContext setCurrentContext:[NSGraphicsContext
+ graphicsContextWithGraphicsPort:dc.context flipped:NO]];
+ [image drawAtPoint:NSZeroPoint fromRect:NSZeroRect
+ operation:NSCompositeCopy fraction:1.0];
+ [NSGraphicsContext restoreGraphicsState];
+ }
+ TkMacOSXRestoreDrawingContext(&dc);
+ }
+ } else if (name) {
+ OSType iconType;
+ if (OSTypeFromString(name, &iconType) == TCL_OK) {
+ IconRef icon;
+ OSErr err = ChkErr(GetIconRef, kOnSystemDisk, kSystemIconsCreator,
+ iconType, &icon);
+ if (err == noErr) {
+ pixmap = GetBitmapForIcon(display, icon, NSSizeToCGSize(size));
+ *width = size.width;
+ *height = size.height;
+ ReleaseIconRef(icon);
+ }
+ }
+ }
+ return pixmap;
+}
+
+/*
+ *----------------------------------------------------------------------
+ *
+ * TkMacOSXIconBitmapObjCmd --
+ *
+ * Implements the ::tk::mac::iconBitmap command.
+ *
+ * Results:
+ * A standard Tcl result.
+ *
+ * Side effects:
+ * none
+ *
+ *----------------------------------------------------------------------
+ */
- /*
- * We need to first paint the background white. Also, for some reason
- * we *must* use GetCIcon instead of GetNamedResource for PlotCIcon to
- * work - so we use GetResInfo to get the id.
- */
+int
+TkMacOSXIconBitmapObjCmd(
+ ClientData clientData, /* Unused. */
+ Tcl_Interp *interp, /* Current interpreter. */
+ int objc, /* Number of arguments. */
+ Tcl_Obj *const objv[]) /* Argument objects. */
+{
+ Tcl_HashEntry *hPtr;
+ int i = 1, len, isNew, result = TCL_ERROR;
+ const char *name, *value;
+ IconBitmap ib, *iconBitmap;
- RGBForeColor(&white);
- PaintRect(&destRect);
- GetResInfo(resource, &id, &theType, dummy);
- ReleaseResource(resource);
- resource = (Handle) GetCIcon(id);
- PlotCIcon(&destRect, (CIconHandle) resource);
- DisposeCIcon((CIconHandle) resource);
+ if (objc != 6) {
+ Tcl_WrongNumArgs(interp, 1, objv, "name width height "
+ "-file|-fileType|-osType|-systemType|-namedImage|-imageFile "
+ "value");
+ goto end;
}
-
- *width = 32;
- *height = 32;
- if (portChanged) {
- QDSwapPort(savePort, NULL);
+ name = Tcl_GetStringFromObj(objv[i++], &len);
+ if (!len) {
+ Tcl_AppendResult(interp, "empty bitmap name", NULL);
+ goto end;
+ }
+ if (Tcl_GetIntFromObj(interp, objv[i++], &ib.width) != TCL_OK) {
+ goto end;
+ }
+ if (Tcl_GetIntFromObj(interp, objv[i++], &ib.height) != TCL_OK) {
+ goto end;
+ }
+ if (Tcl_GetIndexFromObj(interp, objv[i++], iconBitmapOptionStrings,
+ "kind", TCL_EXACT, &ib.kind) != TCL_OK) {
+ goto end;
+ }
+ value = Tcl_GetStringFromObj(objv[i++], &len);
+ if (!len) {
+ Tcl_AppendResult(interp, "empty bitmap value", NULL);
+ goto end;
+ }
+#if 0
+ if ((kind == ICON_TYPE || kind == ICON_SYSTEM)) {
+ Tcl_DString ds;
+ Tcl_Encoding encoding = Tcl_GetEncoding(NULL, "macRoman");
+ Tcl_UtfToExternalDString(encoding, value, -1, &ds);
+ len = Tcl_DStringLength(&ds);
+ Tcl_DStringFree(&ds);
+ Tcl_FreeEncoding(encoding);
+ if (len > 4) {
+ Tcl_AppendResult(interp, "invalid bitmap value", NULL);
+ goto end;
+ }
}
- return pix;
+#endif
+ ib.value = ckalloc(len + 1);
+ strcpy(ib.value, value);
+ if (!iconBitmapTable.buckets) {
+ Tcl_InitHashTable(&iconBitmapTable, TCL_STRING_KEYS);
+ }
+ hPtr = Tcl_CreateHashEntry(&iconBitmapTable, name, &isNew);
+ if (!isNew) {
+ iconBitmap = Tcl_GetHashValue(hPtr);
+ ckfree(iconBitmap->value);
+ } else {
+ iconBitmap = (IconBitmap *) ckalloc(sizeof(IconBitmap));
+ Tcl_SetHashValue(hPtr, iconBitmap);
+ }
+ *iconBitmap = ib;
+ result = TCL_OK;
+end:
+ return result;
}
+
+/*
+ * Local Variables:
+ * mode: c
+ * c-basic-offset: 4
+ * fill-column: 79
+ * coding: utf-8
+ * End:
+ */
diff --git a/macosx/tkMacOSXButton.c b/macosx/tkMacOSXButton.c
index 184380f..61382c4 100644
--- a/macosx/tkMacOSXButton.c
+++ b/macosx/tkMacOSXButton.c
@@ -5,11 +5,13 @@
* button widgets.
*
* Copyright (c) 1996-1997 by Sun Microsystems, Inc.
- * Copyright 2001, Apple Computer, Inc.
- * Copyright (c) 2006-2007 Daniel A. Steffen <das@users.sourceforge.net>
+ * Copyright 2001-2009, Apple Inc.
+ * Copyright (c) 2006-2009 Daniel A. Steffen <das@users.sourceforge.net>
*
* See the file "license.terms" for information on usage and redistribution
* of this file, and for a DISCLAIMER OF ALL WARRANTIES.
+ *
+ * RCS: @(#) $Id$
*/
#include "tkMacOSXPrivate.h"
@@ -17,98 +19,60 @@
#include "tkMacOSXFont.h"
#include "tkMacOSXDebug.h"
-#define DEFAULT_USE_TK_TEXT 0
-
-#define CONTROL_INITIALIZED 1
-#define FIRST_DRAW 2
-#define ACTIVE 4
-
-#define MAX_VALUE 2
-
/*
- * Default insets for controls
- */
+#ifdef TK_MAC_DEBUG
+#define TK_MAC_DEBUG_BUTTON
+#endif
+*/
-#define DEF_INSET_LEFT 2
-#define DEF_INSET_RIGHT 2
-#define DEF_INSET_TOP 2
-#define DEF_INSET_BOTTOM 4
+typedef struct MacButton {
+ TkButton info;
+ NSButton *button;
+ NSImage *image, *selectImage, *tristateImage;
+#if TK_MAC_BUTTON_USE_COMPATIBILITY_METRICS
+ int fix;
+#endif
+} MacButton;
-/*
- * Some defines used to control what type of control is drawn.
- */
+#if TK_MAC_BUTTON_USE_COMPATIBILITY_METRICS
-#define DRAW_LABEL 0 /* Labels are treated genericly. */
-#define DRAW_CONTROL 1 /* Draw using the Native control. */
-#define DRAW_CUSTOM 2 /* Make our own button drawing. */
-#define DRAW_BEVEL 3
+int tkMacOSXUseCompatibilityMetrics = 1;
/*
- * Declaration of Mac specific button structure.
+ * Use the following heuristic conversion constants to make NSButton-based
+ * widget metrics match up with the old Carbon control buttons (for the
+ * default Lucida Grande 13 font).
*/
-typedef struct {
- SInt16 initialValue;
- SInt16 minValue;
- SInt16 maxValue;
- SInt16 procID;
- int isBevel;
-} MacControlParams;
+#define NATIVE_BUTTON_INSET 2
+#define NATIVE_BUTTON_EXTRA_H 2
typedef struct {
- int drawType;
- Tk_3DBorder border;
- int relief;
- int offset; /* 0 means this is a normal widget. 1 means
- * it is an image button, so we offset the
- * image to make the button appear to move
- * up and down as the relief changes. */
- GC gc;
- int hasImageOrBitmap;
-} DrawParams;
-
-typedef struct {
- TkButton info; /* Generic button info */
- int id;
- int usingControl;
- int useTkText;
- int flags; /* Initialisation status */
- MacControlParams params;
- WindowRef windowRef;
- unsigned long userPaneBackground;
- ControlRef userPane; /* Carbon control */
- ControlRef control; /* Carbon control */
- Str255 controlTitle;
- ControlFontStyleRec fontStyle;
- /*
- * The following are used to store the image content for
- * beveled buttons, i.e. buttons with images.
- */
- ControlButtonContentInfo bevelButtonContent;
- OpenCPicParams picParams;
-} MacButton;
+ int trimW, trimH, inset, shrinkH, offsetX, offsetY;
+} BoundsFix;
+
+#define fixForTypeStyle(type, style) ( \
+ type == NSSwitchButton ? 0 : \
+ type == NSRadioButton ? 1 : \
+ style == NSRoundedBezelStyle ? 2 : \
+ style == NSRegularSquareBezelStyle ? 3 : \
+ style == NSShadowlessSquareBezelStyle ? 4 : \
+ INT_MIN)
+
+static const BoundsFix boundsFixes[] = {
+ [fixForTypeStyle(NSSwitchButton,0)] = { 2, 2, -1, 0, 2, 1 },
+ [fixForTypeStyle(NSRadioButton,0)] = { 0, 2, -1, 0, 1, 1 },
+ [fixForTypeStyle(0,NSRoundedBezelStyle)] = { 28, 16, -6, 0, 0, 3 },
+ [fixForTypeStyle(0,NSRegularSquareBezelStyle)] = { 28, 15, -2, -1 },
+ [fixForTypeStyle(0,NSShadowlessSquareBezelStyle)] = { 2, 2 },
+};
-/*
- * Forward declarations for procedures defined later in this file:
- */
+#endif
-static OSStatus SetUserPaneDrawProc(ControlRef control,
- ControlUserPaneDrawProcPtr upp);
-static OSStatus SetUserPaneSetUpSpecialBackgroundProc(ControlRef control,
- ControlUserPaneBackgroundProcPtr upp);
-static void UserPaneDraw(ControlRef control, ControlPartCode cpc);
-static void UserPaneBackgroundProc(ControlHandle,
- ControlBackgroundPtr info);
-
-static void ButtonEventProc(ClientData clientData, XEvent *eventPtr);
-static int UpdateControlColors(MacButton *mbPtr);
-static void TkMacOSXComputeControlParams(TkButton *butPtr,
- MacControlParams *paramsPtr);
-static int TkMacOSXComputeDrawParams(TkButton *butPtr, DrawParams *dpPtr);
-static void TkMacOSXDrawControl(MacButton *butPtr, GWorldPtr destPort, GC gc,
- Pixmap pixmap);
-static void SetupBevelButton(MacButton *butPtr, ControlRef controlHandle,
- GWorldPtr destPort, GC gc, Pixmap pixmap);
+static void DisplayNativeButton(TkButton *butPtr);
+static void ComputeNativeButtonGeometry(TkButton *butPtr);
+static void DisplayUnixButton(TkButton *butPtr);
+static void ComputeUnixButtonGeometry(TkButton *butPtr);
/*
* The class procedure table for the button widgets.
@@ -119,8 +83,6 @@ Tk_ClassProcs tkpButtonProcs = {
TkButtonWorldChanged, /* worldChangedProc */
};
-static int bCount;
-
/*
*----------------------------------------------------------------------
@@ -144,20 +106,40 @@ TkpCreateButton(
{
MacButton *macButtonPtr = (MacButton *) ckalloc(sizeof(MacButton));
- Tk_CreateEventHandler(tkwin, ActivateMask,
- ButtonEventProc, (ClientData) macButtonPtr);
- macButtonPtr->id = bCount++;
- macButtonPtr->usingControl = 0;
- macButtonPtr->flags = 0;
- macButtonPtr->userPaneBackground = PIXEL_MAGIC << 24;
- macButtonPtr->userPane = NULL;
- macButtonPtr->control = NULL;
- macButtonPtr->controlTitle[0] = 0;
- macButtonPtr->controlTitle[1] = 0;
- bzero(&macButtonPtr->params, sizeof(macButtonPtr->params));
- bzero(&macButtonPtr->fontStyle, sizeof(macButtonPtr->fontStyle));
-
- return (TkButton *)macButtonPtr;
+ macButtonPtr->button = nil;
+ macButtonPtr->image = nil;
+ macButtonPtr->selectImage = nil;
+ macButtonPtr->tristateImage = nil;
+
+ return (TkButton *) macButtonPtr;
+}
+
+/*
+ *----------------------------------------------------------------------
+ *
+ * TkpDestroyButton --
+ *
+ * Free data structures associated with the button control.
+ *
+ * Results:
+ * None.
+ *
+ * Side effects:
+ * Restores the default control state.
+ *
+ *----------------------------------------------------------------------
+ */
+
+void
+TkpDestroyButton(
+ TkButton *butPtr)
+{
+ MacButton *macButtonPtr = (MacButton *) butPtr;
+
+ TkMacOSXMakeCollectableAndRelease(macButtonPtr->button);
+ TkMacOSXMakeCollectableAndRelease(macButtonPtr->selectImage);
+ TkMacOSXMakeCollectableAndRelease(macButtonPtr->selectImage);
+ TkMacOSXMakeCollectableAndRelease(macButtonPtr->tristateImage);
}
/*
@@ -182,313 +164,22 @@ void
TkpDisplayButton(
ClientData clientData) /* Information about widget. */
{
- MacButton *macButtonPtr = (MacButton *) clientData;
TkButton *butPtr = (TkButton *) clientData;
- Tk_Window tkwin = butPtr->tkwin;
- CGrafPtr destPort, savePort;
- Boolean portChanged;
- Pixmap pixmap;
- int width, height, fullWidth, fullHeight, textXOffset, textYOffset;
- int borderWidth, wasUsingControl;
- int haveImage = 0, haveText = 0, imageWidth = 0, imageHeight = 0;
- int imageXOffset = 0, imageYOffset = 0; /* image information that will
- * be used to restrict disabled
- * pixmap as well */
- DrawParams drawParams, *dpPtr = &drawParams;
butPtr->flags &= ~REDRAW_PENDING;
- if ((butPtr->tkwin == NULL) || !Tk_IsMapped(tkwin)) {
+ if (!butPtr->tkwin || !Tk_IsMapped(butPtr->tkwin)) {
return;
}
- pixmap = (Pixmap) Tk_WindowId(tkwin);
- wasUsingControl = macButtonPtr->usingControl;
-
- if (TkMacOSXComputeDrawParams(butPtr, &drawParams) ) {
- macButtonPtr->usingControl = 1;
- if (butPtr->type == TYPE_BUTTON) {
- macButtonPtr->useTkText = 0;
- } else {
- macButtonPtr->useTkText = 1;
- }
- } else {
- macButtonPtr->usingControl = 0;
- macButtonPtr->useTkText = 1;
- }
-
- /*
- * See the comment in UpdateControlColors as to why we use the
- * highlightbackground for the border of Macintosh buttons.
- */
-
- if (macButtonPtr->useTkText) {
- if (butPtr->type == TYPE_BUTTON) {
- Tk_Fill3DRectangle(tkwin, pixmap, butPtr->highlightBorder, 0, 0,
- Tk_Width(tkwin), Tk_Height(tkwin), 0, TK_RELIEF_FLAT);
- } else {
- Tk_Fill3DRectangle(tkwin, pixmap, butPtr->normalBorder, 0, 0,
- Tk_Width(tkwin), Tk_Height(tkwin), 0, TK_RELIEF_FLAT);
- }
- }
-
- /*
- * Set up clipping region. Make sure the we are using the port
- * for this button, or we will set the wrong window's clip.
- */
-
- destPort = TkMacOSXGetDrawablePort(pixmap);
- portChanged = QDSwapPort(destPort, &savePort);
- TkMacOSXSetUpClippingRgn(pixmap);
-
- /*
- * Draw the native portion of the buttons. Start by creating the control
- * if it doesn't already exist. Then configure the Macintosh control from
- * the Tk info. Finally, we call Draw1Control to draw to the screen.
- */
-
- if (macButtonPtr->usingControl) {
- borderWidth = 0;
- TkMacOSXDrawControl(macButtonPtr, destPort, dpPtr->gc, pixmap);
- } else if (wasUsingControl && macButtonPtr->userPane) {
- DisposeControl(macButtonPtr->userPane);
- macButtonPtr->userPane = NULL;
- macButtonPtr->control = NULL;
- macButtonPtr->flags = 0;
- }
-
- if ((dpPtr->drawType == DRAW_CUSTOM) || (dpPtr->drawType == DRAW_LABEL)) {
- borderWidth = butPtr->borderWidth;
- }
-
- /*
- * Display image or bitmap or text for button. This has
- * already been done under Appearance with the Bevel
- * button types.
- */
-
- if (dpPtr->drawType == DRAW_BEVEL) {
- goto applyStipple;
- }
-
- if (butPtr->image != None) {
- Tk_SizeOfImage(butPtr->image, &width, &height);
- haveImage = 1;
- } else if (butPtr->bitmap != None) {
- Tk_SizeOfBitmap(butPtr->display, butPtr->bitmap, &width, &height);
- haveImage = 1;
- }
- imageWidth = width;
- imageHeight = height;
-
- haveText = (butPtr->textWidth != 0 && butPtr->textHeight != 0);
- if (butPtr->compound != COMPOUND_NONE && haveImage && haveText) {
- int x, y;
-
- textXOffset = 0;
- textYOffset = 0;
- fullWidth = 0;
- fullHeight = 0;
-
- switch ((enum compound) butPtr->compound) {
- case COMPOUND_TOP:
- case COMPOUND_BOTTOM:
- /*
- * Image is above or below text.
- */
- if (butPtr->compound == COMPOUND_TOP) {
- textYOffset = height + butPtr->padY;
- } else {
- imageYOffset = butPtr->textHeight + butPtr->padY;
- }
- fullHeight = height + butPtr->textHeight + butPtr->padY;
- fullWidth = (width > butPtr->textWidth ? width :
- butPtr->textWidth);
- textXOffset = (fullWidth - butPtr->textWidth)/2;
- imageXOffset = (fullWidth - width)/2;
- break;
-
- case COMPOUND_LEFT:
- case COMPOUND_RIGHT:
- /*
- * Image is left or right of text.
- */
-
- if (butPtr->compound == COMPOUND_LEFT) {
- textXOffset = width + butPtr->padX;
- } else {
- imageXOffset = butPtr->textWidth + butPtr->padX;
- }
- fullWidth = butPtr->textWidth + butPtr->padX + width;
- fullHeight = (height > butPtr->textHeight ? height :
- butPtr->textHeight);
- textYOffset = (fullHeight - butPtr->textHeight)/2;
- imageYOffset = (fullHeight - height)/2;
- break;
-
- case COMPOUND_CENTER:
- /*
- * Image and text are superimposed.
- */
-
- fullWidth = (width > butPtr->textWidth ? width :
- butPtr->textWidth);
- fullHeight = (height > butPtr->textHeight ? height :
- butPtr->textHeight);
- textXOffset = (fullWidth - butPtr->textWidth)/2;
- imageXOffset = (fullWidth - width)/2;
- textYOffset = (fullHeight - butPtr->textHeight)/2;
- imageYOffset = (fullHeight - height)/2;
- break;
-
- case COMPOUND_NONE:
- break;
- }
-
- TkComputeAnchor(butPtr->anchor, tkwin, butPtr->padX, butPtr->padY,
- butPtr->indicatorSpace + fullWidth, fullHeight, &x, &y);
-
- x += butPtr->indicatorSpace;
-
- x += dpPtr->offset;
- y += dpPtr->offset;
- if (dpPtr->relief == TK_RELIEF_RAISED) {
- x -= dpPtr->offset;
- y -= dpPtr->offset;
- } else if (dpPtr->relief == TK_RELIEF_SUNKEN) {
- x += dpPtr->offset;
- y += dpPtr->offset;
- }
- imageXOffset += x;
- imageYOffset += y;
- if (butPtr->image != NULL) {
- if ((butPtr->selectImage != NULL) && (butPtr->flags & SELECTED)) {
- Tk_RedrawImage(butPtr->selectImage, 0, 0, width, height,
- pixmap, imageXOffset, imageYOffset);
- } else if ((butPtr->tristateImage != NULL) &&
- (butPtr->flags & TRISTATED)) {
- Tk_RedrawImage(butPtr->tristateImage, 0, 0, width, height,
- pixmap, imageXOffset, imageYOffset);
- } else {
- Tk_RedrawImage(butPtr->image, 0, 0, width, height,
- pixmap, imageXOffset, imageYOffset);
- }
- } else {
- XSetClipOrigin(butPtr->display, dpPtr->gc, imageXOffset,
- imageYOffset);
- XCopyPlane(butPtr->display, butPtr->bitmap, pixmap, dpPtr->gc,
- 0, 0, width, height, imageXOffset, imageYOffset, 1);
- XSetClipOrigin(butPtr->display, dpPtr->gc, 0, 0);
- }
-
- if (macButtonPtr->useTkText) {
- Tk_DrawTextLayout(butPtr->display, pixmap, dpPtr->gc,
- butPtr->textLayout, x + textXOffset, y + textYOffset, 0,
- -1);
- Tk_UnderlineTextLayout(butPtr->display, pixmap, dpPtr->gc,
- butPtr->textLayout, x + textXOffset, y + textYOffset,
- butPtr->underline);
- }
- y += fullHeight/2;
- } else if (haveImage) {
- int x = 0, y;
-
- TkComputeAnchor(butPtr->anchor, tkwin, 0, 0,
- butPtr->indicatorSpace + width, height, &x, &y);
- x += butPtr->indicatorSpace;
-
- x += dpPtr->offset;
- y += dpPtr->offset;
- if (dpPtr->relief == TK_RELIEF_RAISED) {
- x -= dpPtr->offset;
- y -= dpPtr->offset;
- } else if (dpPtr->relief == TK_RELIEF_SUNKEN) {
- x += dpPtr->offset;
- y += dpPtr->offset;
- }
- imageXOffset += x;
- imageYOffset += y;
- if (butPtr->image != NULL) {
- if ((butPtr->selectImage != NULL) && (butPtr->flags & SELECTED)) {
- Tk_RedrawImage(butPtr->selectImage, 0, 0, width, height,
- pixmap, imageXOffset, imageYOffset);
- } else if ((butPtr->tristateImage != NULL) &&
- (butPtr->flags & TRISTATED)) {
- Tk_RedrawImage(butPtr->tristateImage, 0, 0, width, height,
- pixmap, imageXOffset, imageYOffset);
- } else {
- Tk_RedrawImage(butPtr->image, 0, 0, width, height,
- pixmap, imageXOffset, imageYOffset);
- }
- } else {
- XSetClipOrigin(butPtr->display, dpPtr->gc, x, y);
- XCopyPlane(butPtr->display, butPtr->bitmap, pixmap, dpPtr->gc,
- 0, 0, width, height, x, y, 1);
- XSetClipOrigin(butPtr->display, dpPtr->gc, 0, 0);
- }
- y += height/2;
- } else if (macButtonPtr->useTkText) {
- int x = 0, y;
-
- TkComputeAnchor(butPtr->anchor, tkwin, butPtr->padX, butPtr->padY,
- butPtr->indicatorSpace + butPtr->textWidth,
- butPtr->textHeight, &x, &y);
- x += butPtr->indicatorSpace;
- Tk_DrawTextLayout(butPtr->display, pixmap, dpPtr->gc,
- butPtr->textLayout, x, y, 0, -1);
- }
-
- /*
- * If the button is disabled with a stipple rather than a special
- * foreground color, generate the stippled effect. If the widget
- * is selected and we use a different background color when selected,
- * must temporarily modify the GC so the stippling is the right color.
- */
- applyStipple:
- if (macButtonPtr->useTkText) {
- if ((butPtr->state == STATE_DISABLED)
- && ((butPtr->disabledFg == NULL) || (butPtr->image != NULL))) {
- if ((butPtr->flags & SELECTED) && !butPtr->indicatorOn
- && (butPtr->selectBorder != NULL)) {
- XSetForeground(butPtr->display, butPtr->stippleGC,
- Tk_3DBorderColor(butPtr->selectBorder)->pixel);
- }
-
- /*
- * Stipple the whole button if no disabledFg was specified,
- * otherwise restrict stippling only to displayed image
- */
-
- if (butPtr->disabledFg == NULL) {
- XFillRectangle(butPtr->display, pixmap, butPtr->stippleGC,
- 0, 0, (unsigned) Tk_Width(tkwin),
- (unsigned) Tk_Height(tkwin));
- } else {
- XFillRectangle(butPtr->display, pixmap, butPtr->stippleGC,
- imageXOffset, imageYOffset,
- (unsigned) imageWidth, (unsigned) imageHeight);
- }
- if ((butPtr->flags & SELECTED) && !butPtr->indicatorOn
- && (butPtr->selectBorder != NULL)) {
- XSetForeground(butPtr->display, butPtr->stippleGC,
- Tk_3DBorderColor(butPtr->normalBorder)->pixel);
- }
- }
-
- /*
- * Draw the border and traversal highlight last. This way, if the
- * button's contents overflow they'll be covered up by the border.
- */
-
- if (dpPtr->relief != TK_RELIEF_FLAT) {
- int inset = butPtr->highlightWidth;
-
- Tk_Draw3DRectangle(tkwin, pixmap, dpPtr->border, inset, inset,
- Tk_Width(tkwin) - 2*inset, Tk_Height(tkwin) - 2*inset,
- borderWidth, dpPtr->relief);
- }
- }
- if (portChanged) {
- QDSwapPort(savePort, NULL);
+ switch (butPtr->type) {
+ case TYPE_LABEL:
+ DisplayUnixButton(butPtr);
+ break;
+ case TYPE_BUTTON:
+ case TYPE_CHECK_BUTTON:
+ case TYPE_RADIO_BUTTON:
+ DisplayNativeButton(butPtr);
+ break;
}
}
@@ -512,890 +203,838 @@ TkpDisplayButton(
void
TkpComputeButtonGeometry(
- TkButton *butPtr) /* Button whose geometry may have changed. */
+ register TkButton *butPtr) /* Button whose geometry may have changed. */
{
- int width, height, avgWidth, haveImage = 0, haveText = 0;
- int xInset, yInset, txtWidth, txtHeight;
- Tk_FontMetrics fm;
- DrawParams drawParams;
-
- /*
- * First figure out the size of the contents of the button.
- */
-
- width = 0;
- height = 0;
- txtWidth = 0;
- txtHeight = 0;
- avgWidth = 0;
-
- butPtr->indicatorSpace = 0;
- if (butPtr->image != NULL) {
- Tk_SizeOfImage(butPtr->image, &width, &height);
- haveImage = 1;
- } else if (butPtr->bitmap != None) {
- Tk_SizeOfBitmap(butPtr->display, butPtr->bitmap, &width, &height);
- haveImage = 1;
- }
-
- if (haveImage == 0 || butPtr->compound != COMPOUND_NONE) {
- Tk_FreeTextLayout(butPtr->textLayout);
- butPtr->textLayout = Tk_ComputeTextLayout(butPtr->tkfont,
- Tcl_GetString(butPtr->textPtr), -1, butPtr->wrapLength,
- butPtr->justify, 0, &butPtr->textWidth, &butPtr->textHeight);
-
- txtWidth = butPtr->textWidth;
- txtHeight = butPtr->textHeight;
- avgWidth = Tk_TextWidth(butPtr->tkfont, "0", 1);
- Tk_GetFontMetrics(butPtr->tkfont, &fm);
- haveText = (txtWidth != 0 && txtHeight != 0);
- }
-
- /*
- * If the button is compound (ie, it shows both an image and text),
- * the new geometry is a combination of the image and text geometry.
- * We only honor the compound bit if the button has both text and an
- * image, because otherwise it is not really a compound button.
- */
-
- if (butPtr->compound != COMPOUND_NONE && haveImage && haveText) {
- switch ((enum compound) butPtr->compound) {
- case COMPOUND_TOP:
- case COMPOUND_BOTTOM:
- /*
- * Image is above or below text.
- */
-
- height += txtHeight + butPtr->padY;
- width = (width > txtWidth ? width : txtWidth);
- break;
- case COMPOUND_LEFT:
- case COMPOUND_RIGHT:
- /*
- * Image is left or right of text.
- */
-
- width += txtWidth + butPtr->padX;
- height = (height > txtHeight ? height : txtHeight);
- break;
- case COMPOUND_CENTER:
- /*
- * Image and text are superimposed.
- */
-
- width = (width > txtWidth ? width : txtWidth);
- height = (height > txtHeight ? height : txtHeight);
- break;
- case COMPOUND_NONE:
- break;
- }
- if (butPtr->width > 0) {
- width = butPtr->width;
- }
- if (butPtr->height > 0) {
- height = butPtr->height;
- }
-
- if ((butPtr->type >= TYPE_CHECK_BUTTON) && butPtr->indicatorOn) {
- butPtr->indicatorSpace = height;
- if (butPtr->type == TYPE_CHECK_BUTTON) {
- butPtr->indicatorDiameter = (65 * height)/100;
- } else {
- butPtr->indicatorDiameter = (75 * height)/100;
- }
- }
+ MacButton *macButtonPtr = (MacButton *) butPtr;
- width += 2 * butPtr->padX;
- height += 2 * butPtr->padY;
- } else if (haveImage) {
- if (butPtr->width > 0) {
- width = butPtr->width;
- }
- if (butPtr->height > 0) {
- height = butPtr->height;
- }
- if ((butPtr->type >= TYPE_CHECK_BUTTON) && butPtr->indicatorOn) {
- butPtr->indicatorSpace = height;
- if (butPtr->type == TYPE_CHECK_BUTTON) {
- butPtr->indicatorDiameter = (65 * height)/100;
- } else {
- butPtr->indicatorDiameter = (75 * height)/100;
- }
- }
- } else {
- width = txtWidth;
- height = txtHeight;
- if (butPtr->width > 0) {
- width = butPtr->width * avgWidth;
- }
- if (butPtr->height > 0) {
- height = butPtr->height * fm.linespace;
- }
- if ((butPtr->type >= TYPE_CHECK_BUTTON) && butPtr->indicatorOn) {
- butPtr->indicatorDiameter = fm.linespace;
- if (butPtr->type == TYPE_CHECK_BUTTON) {
- butPtr->indicatorDiameter =
- (80 * butPtr->indicatorDiameter)/100;
- }
- butPtr->indicatorSpace = butPtr->indicatorDiameter + avgWidth;
- }
- }
-
- /*
- * Now figure out the size of the border decorations for the button.
- */
-
- if (butPtr->highlightWidth < 0) {
- butPtr->highlightWidth = 0;
- }
-
- /*
- * The width and height calculation for Appearance buttons with images &
- * non-Appearance buttons with images is different. In the latter case,
- * we add the borderwidth to the inset, since we are going to stamp a
- * 3-D border over the image. In the former, we add it to the height,
- * directly, since Appearance will draw the border as part of our control.
- *
- * When issuing the geometry request, add extra space for the indicator,
- * if any, and for the border and padding, plus if this is an image two
- * extra pixels so the display can be offset by 1 pixel in either
- * direction for the raised or lowered effect.
- *
- * The highlight width corresponds to the default ring on the Macintosh.
- * As such, the highlight width is only added if the button is the default
- * button. The actual width of the default ring is one less than the
- * highlight width as there is also one pixel of spacing.
- * Appearance buttons with images do not have a highlight ring, because the
- * Bevel button type does not support one.
- */
-
- if ((butPtr->image == None) && (butPtr->bitmap == None)) {
- width += 2*butPtr->padX;
- height += 2*butPtr->padY;
- }
-
- if ((butPtr->type == TYPE_BUTTON)) {
- if ((butPtr->image == None) && (butPtr->bitmap == None)) {
- butPtr->inset = 0;
- if (butPtr->defaultState != STATE_DISABLED) {
- butPtr->inset += butPtr->highlightWidth;
- }
- } else {
- butPtr->inset = 0;
- width += (2 * butPtr->borderWidth + 4);
- height += (2 * butPtr->borderWidth + 4);
+ switch (butPtr->type) {
+ case TYPE_LABEL:
+ if (macButtonPtr->button && [macButtonPtr->button superview]) {
+ [macButtonPtr->button removeFromSuperviewWithoutNeedingDisplay];
}
- } else if (butPtr->type == TYPE_LABEL) {
- butPtr->inset = butPtr->borderWidth;
- } else if (butPtr->indicatorOn) {
- butPtr->inset = 0;
- } else {
- /*
- * Under Appearance, the Checkbutton or radiobutton with an image
- * is represented by a BevelButton with the Sticky defProc...
- * So we must set its height in the same way as the Button
- * with an image or bitmap.
- */
-
- if (butPtr->image != None || butPtr->bitmap != None) {
- int border;
-
- butPtr->inset = 0;
- if (butPtr->borderWidth <= 2) {
- border = 6;
- } else {
- border = 2 * butPtr->borderWidth + 2;
- }
- width += border;
- height += border;
- } else {
- butPtr->inset = butPtr->borderWidth;
+ ComputeUnixButtonGeometry(butPtr);
+ break;
+ case TYPE_BUTTON:
+ case TYPE_CHECK_BUTTON:
+ case TYPE_RADIO_BUTTON:
+ if (!macButtonPtr->button) {
+ NSButton *button = [[NSButton alloc] initWithFrame:NSZeroRect];
+ macButtonPtr->button = TkMacOSXMakeUncollectable(button);
}
+ ComputeNativeButtonGeometry(butPtr);
+ break;
}
-
- if (TkMacOSXComputeDrawParams(butPtr, &drawParams)) {
- xInset = butPtr->indicatorSpace + DEF_INSET_LEFT + DEF_INSET_RIGHT;
- yInset = DEF_INSET_TOP + DEF_INSET_BOTTOM;
- } else {
- xInset = butPtr->indicatorSpace+butPtr->inset*2;
- yInset = butPtr->inset*2;
- }
- Tk_GeometryRequest(butPtr->tkwin, width + xInset, height + yInset);
- Tk_SetInternalBorder(butPtr->tkwin, butPtr->inset);
}
/*
*----------------------------------------------------------------------
*
- * TkpDestroyButton --
+ * TkpButtonSetDefaults --
*
- * Free data structures associated with the button control.
+ * This procedure is invoked before option tables are created for
+ * buttons. It modifies some of the default values to match the current
+ * values defined for this platform.
*
* Results:
- * None.
+ * Some of the default values in *specPtr are modified.
*
* Side effects:
- * Restores the default control state.
+ * Updates some of.
*
*----------------------------------------------------------------------
*/
void
-TkpDestroyButton(
- TkButton *butPtr)
+TkpButtonSetDefaults(
+ Tk_OptionSpec *specPtr) /* Points to an array of option specs,
+ * terminated by one with type
+ * TK_OPTION_END. */
{
- MacButton *mbPtr = (MacButton *) butPtr; /* Mac button. */
-
- if (mbPtr->userPane) {
- DisposeControl(mbPtr->userPane);
- mbPtr->userPane = NULL;
+#if TK_MAC_BUTTON_USE_COMPATIBILITY_METRICS
+ if (!tkMacOSXUseCompatibilityMetrics) {
+ while (specPtr->type != TK_CONFIG_END) {
+ switch (specPtr->internalOffset) {
+ case Tk_Offset(TkButton, highlightWidth):
+ specPtr->defValue = DEF_BUTTON_HIGHLIGHT_WIDTH_NOCM;
+ break;
+ case Tk_Offset(TkButton, padX):
+ specPtr->defValue = DEF_BUTTON_PADX_NOCM;
+ break;
+ case Tk_Offset(TkButton, padY):
+ specPtr->defValue = DEF_BUTTON_PADY_NOCM;
+ break;
+ }
+ specPtr++;
+ }
}
+#endif
}
+
+#pragma mark -
+#pragma mark Native Buttons:
+
/*
*----------------------------------------------------------------------
*
- * TkMacOSXInitControl --
+ * DisplayNativeButton --
*
- * This procedure initialises a Carbon control.
+ * This procedure is invoked to display a button widget. It is
+ * normally invoked as an idle handler.
*
* Results:
- * 0 on success, 1 on failure.
+ * None.
*
* Side effects:
- * A background pane control and the control itself is created
- * The contol is embedded in the background control
- * The background control is embedded in the root control
- * of the containing window
- * The creation parameters for the control are also computed
+ * Commands are output to X to display the button in its
+ * current mode. The REDRAW_PENDING flag is cleared.
*
*----------------------------------------------------------------------
*/
-static int
-TkMacOSXInitControl(
- MacButton *mbPtr, /* Mac button. */
- GWorldPtr destPort,
- GC gc,
- Pixmap pixmap,
- Rect *paneRect,
- Rect *cntrRect)
+static void
+DisplayNativeButton(
+ TkButton *butPtr)
{
- TkButton *butPtr = (TkButton *) mbPtr;
- ControlRef rootControl;
- SInt16 procID, initialValue, minValue, maxValue;
- Boolean initiallyVisible;
- SInt32 controlReference;
-
- rootControl = TkMacOSXGetRootControl(Tk_WindowId(butPtr->tkwin));
- mbPtr->windowRef = TkMacOSXDrawableWindow(Tk_WindowId(butPtr->tkwin));
+ MacButton *macButtonPtr = (MacButton *) butPtr;
+ NSButton *button = macButtonPtr->button;
+ Tk_Window tkwin = butPtr->tkwin;
+ TkWindow *winPtr = (TkWindow *) tkwin;
+ MacDrawable *macWin = (MacDrawable *) winPtr->window;
+ TkMacOSXDrawingContext dc;
+ NSView *view = TkMacOSXDrawableView(macWin);
+ CGFloat viewHeight = [view bounds].size.height;
+ CGAffineTransform t = { .a = 1, .b = 0, .c = 0, .d = -1, .tx = 0,
+ .ty = viewHeight};
+ NSRect frame;
+ int enabled;
+ NSCellStateValue state;
+
+ if (!view ||
+ !TkMacOSXSetupDrawingContext((Drawable) macWin, NULL, 1, &dc)) {
+ return;
+ }
+ CGContextConcatCTM(dc.context, t);
/*
- * Set up the user pane.
+ * We cannot change the background color of the button itself, only the
+ * color of the background of its container.
+ * This will be the color that peeks around the rounded corners of the
+ * button. We make this the highlightbackground rather than the background,
+ * because if you color the background of a frame containing a
+ * button, you usually also color the highlightbackground as well,
+ * or you will get a thin grey ring around the button.
*/
- initiallyVisible = false;
- initialValue = kControlSupportsEmbedding|kControlHasSpecialBackground;
- minValue = 0;
- maxValue = 1;
- procID = kControlUserPaneProc;
- controlReference = (SInt32)mbPtr;
- mbPtr->userPane = NewControl(mbPtr->windowRef, paneRect, "\p",
- initiallyVisible, initialValue, minValue, maxValue, procID,
- controlReference);
-
- if (!mbPtr->userPane) {
- TkMacOSXDbgMsg("Failed to create user pane control");
- return 1;
+ Tk_Fill3DRectangle(tkwin, (Pixmap) macWin, butPtr->type == TYPE_BUTTON ?
+ butPtr->highlightBorder : butPtr->normalBorder, 0, 0,
+ Tk_Width(tkwin), Tk_Height(tkwin), 0, TK_RELIEF_FLAT);
+ if ([button superview] != view) {
+ [view addSubview:button];
}
- if (ChkErr(EmbedControl, mbPtr->userPane,rootControl) != noErr) {
- return 1;
+ if (macButtonPtr->tristateImage) {
+ NSImage *selectImage = macButtonPtr->selectImage ?
+ macButtonPtr->selectImage : macButtonPtr->image;
+ [button setImage:(butPtr->flags & TRISTATED ?
+ selectImage : macButtonPtr->image)];
+ [button setAlternateImage:(butPtr->flags & TRISTATED ?
+ macButtonPtr->tristateImage : selectImage)];
}
-
- SetUserPaneSetUpSpecialBackgroundProc(mbPtr->userPane,
- UserPaneBackgroundProc);
- SetUserPaneDrawProc(mbPtr->userPane,UserPaneDraw);
- initiallyVisible = false;
- TkMacOSXComputeControlParams(butPtr,&mbPtr->params);
- mbPtr->control = NewControl(mbPtr->windowRef, cntrRect, "\p",
- initiallyVisible, mbPtr->params.initialValue,
- mbPtr->params.minValue, mbPtr->params.maxValue,
- mbPtr->params.procID, controlReference);
-
- if (!mbPtr->control) {
- TkMacOSXDbgMsg("Failed to create control of type %d\n", procID);
- return 1;
+ if (butPtr->flags & SELECTED) {
+ state = NSOnState;
+ } else if (butPtr->flags & TRISTATED) {
+ state = NSMixedState;
+ } else {
+ state = NSOffState;
+ }
+ [button setState:state];
+ enabled = !(butPtr->state == STATE_DISABLED);
+ [button setEnabled:enabled];
+ if (enabled) {
+ //[button highlight:(butPtr->state == STATE_ACTIVE)];
+ //[cell setHighlighted:(butPtr->state == STATE_ACTIVE)];
}
- if (ChkErr(EmbedControl, mbPtr->control,mbPtr->userPane) != noErr ) {
- return 1;
+ if (butPtr->type == TYPE_BUTTON && butPtr->defaultState == STATE_ACTIVE) {
+ //[[view window] setDefaultButtonCell:cell];
+ [button setKeyEquivalent:@"\r"];
+ } else {
+ [button setKeyEquivalent:@""];
}
-
- mbPtr->flags |= (CONTROL_INITIALIZED | FIRST_DRAW);
- if (IsWindowActive(mbPtr->windowRef)) {
- mbPtr->flags |= ACTIVE;
+ frame = NSMakeRect(macWin->xOff, macWin->yOff, Tk_Width(tkwin),
+ Tk_Height(tkwin));
+#if TK_MAC_BUTTON_USE_COMPATIBILITY_METRICS
+ if (tkMacOSXUseCompatibilityMetrics) {
+ BoundsFix boundsFix = boundsFixes[macButtonPtr->fix];
+ frame = NSOffsetRect(frame, boundsFix.offsetX, boundsFix.offsetY);
+ frame.size.height -= boundsFix.shrinkH + NATIVE_BUTTON_EXTRA_H;
+ frame = NSInsetRect(frame, boundsFix.inset + NATIVE_BUTTON_INSET,
+ boundsFix.inset + NATIVE_BUTTON_INSET);
}
- return 0;
+#endif
+ frame.origin.y = viewHeight - (frame.origin.y + frame.size.height);
+ if (!NSEqualRects(frame, [button frame])) {
+ [button setFrame:frame];
+ }
+ [button displayRectIgnoringOpacity:[button bounds]];
+ TkMacOSXRestoreDrawingContext(&dc);
+#ifdef TK_MAC_DEBUG_BUTTON
+ TKLog(@"button %s frame %@ width %d height %d",
+ ((TkWindow *)butPtr->tkwin)->pathName, NSStringFromRect(frame),
+ Tk_Width(tkwin), Tk_Height(tkwin));
+#endif
}
/*
- *--------------------------------------------------------------
+ *----------------------------------------------------------------------
*
- * TkMacOSXDrawControl --
+ * ComputeNativeButtonGeometry --
*
- * This function draws the tk button using Mac controls
- * In addition, this code may apply custom colors passed
- * in the TkButton.
+ * After changes in a button's text or bitmap, this procedure
+ * recomputes the button's geometry and passes this information
+ * along to the geometry manager for the window.
*
* Results:
* None.
*
* Side effects:
- * The control is created, or reinitialised as needed.
+ * The button's window may change size.
*
- *--------------------------------------------------------------
+ *----------------------------------------------------------------------
*/
static void
-TkMacOSXDrawControl(
- MacButton *mbPtr, /* Mac button. */
- GWorldPtr destPort, /* Off screen GWorld. */
- GC gc, /* The GC we are drawing into - needed for the
- * bevel button */
- Pixmap pixmap) /* The pixmap we are drawing into - needed for
- * the bevel button */
+ComputeNativeButtonGeometry(
+ TkButton *butPtr) /* Button whose geometry may have changed. */
{
- TkButton *butPtr = (TkButton *) mbPtr;
- TkWindow *winPtr;
- Rect paneRect, cntrRect;
- int active, enabled;
- int rebuild;
-
- winPtr = (TkWindow *) butPtr->tkwin;
+ MacButton *macButtonPtr = (MacButton *) butPtr;
+ NSButton *button = macButtonPtr->button;
+ NSButtonCell *cell = [button cell];
+ NSButtonType type = -1;
+ NSBezelStyle style = 0;
+ NSInteger highlightsBy = 0, showsStateBy = 0;
+ NSFont *font;
+ NSRect bounds = NSZeroRect, titleRect = NSZeroRect;
+ int haveImage = (butPtr->image || butPtr->bitmap != None), haveText = 0;
+ int haveCompound = (butPtr->compound != COMPOUND_NONE);
+ int width, height, border = 0;
- paneRect.left = winPtr->privatePtr->xOff;
- paneRect.top = winPtr->privatePtr->yOff;
- paneRect.right = paneRect.left + Tk_Width(butPtr->tkwin);
- paneRect.bottom = paneRect.top + Tk_Height(butPtr->tkwin);
-
- cntrRect = paneRect;
-
-/*
- cntrRect.left += butPtr->inset;
- cntrRect.top += butPtr->inset;
- cntrRect.right -= butPtr->inset;
- cntrRect.bottom -= butPtr->inset;
-*/
- cntrRect.left += DEF_INSET_LEFT;
- cntrRect.top += DEF_INSET_TOP;
- cntrRect.right -= DEF_INSET_RIGHT;
- cntrRect.bottom -= DEF_INSET_BOTTOM;
-
- /*
- * The control has been previously initialised.
- * It may need to be re-initialised
- */
-#ifdef TK_REBUILD_TOPLEVEL
- rebuild = (winPtr->flags & TK_REBUILD_TOPLEVEL);
- winPtr->flags &= ~TK_REBUILD_TOPLEVEL;
-#else
- rebuild = 0;
+ butPtr->indicatorSpace = 0;
+ butPtr->inset = 0;
+ if (butPtr->highlightWidth < 0) {
+ butPtr->highlightWidth = 0;
+ }
+ switch (butPtr->type) {
+ case TYPE_BUTTON:
+ type = NSMomentaryPushInButton;
+ if (!haveImage) {
+ style = NSRoundedBezelStyle;
+ butPtr->inset = butPtr->defaultState != STATE_DISABLED ?
+ butPtr->highlightWidth : 0;
+ [button setImage:nil];
+ [button setImagePosition:NSNoImage];
+ } else {
+ style = NSShadowlessSquareBezelStyle;
+ highlightsBy = butPtr->selectImage || butPtr->bitmap ?
+ NSContentsCellMask : 0;
+ border = butPtr->borderWidth;
+ }
+ break;
+ case TYPE_RADIO_BUTTON:
+ case TYPE_CHECK_BUTTON:
+ if (!haveImage /*|| butPtr->indicatorOn*/) { // TODO: indicatorOn
+ type = butPtr->type == TYPE_RADIO_BUTTON ?
+ NSRadioButton : NSSwitchButton;
+ butPtr->inset = /*butPtr->indicatorOn ? 0 :*/ butPtr->borderWidth;
+ } else {
+ type = NSPushOnPushOffButton;
+ style = NSShadowlessSquareBezelStyle;
+ highlightsBy = butPtr->selectImage || butPtr->bitmap ?
+ NSContentsCellMask : 0;
+ showsStateBy = butPtr->selectImage || butPtr->tristateImage ?
+ NSContentsCellMask : 0;
+#if TK_MAC_BUTTON_USE_COMPATIBILITY_METRICS
+ if (tkMacOSXUseCompatibilityMetrics) {
+ border = butPtr->borderWidth > 1 ? butPtr->borderWidth - 1 : 1;
+ } else
#endif
- if (mbPtr->flags) {
- MacControlParams params;
-
- TkMacOSXComputeControlParams(butPtr, &params);
- if (rebuild || bcmp(&params, &mbPtr->params, sizeof(params))) {
- /*
- * The type of control has changed.
- * Clean it up and clear the flag.
- */
-
- if (mbPtr->userPane) {
- DisposeControl(mbPtr->userPane);
- mbPtr->userPane = NULL;
- mbPtr->control = NULL;
+ {
+ border = butPtr->borderWidth;
}
- mbPtr->flags = 0;
}
+ break;
+ }
+ [button setButtonType:type];
+ if (style) {
+ [button setBezelStyle:style];
}
- if (!(mbPtr->flags & CONTROL_INITIALIZED)) {
- if (TkMacOSXInitControl(mbPtr, destPort, gc, pixmap, &paneRect,
- &cntrRect)) {
- return;
+ if (highlightsBy) {
+ [cell setHighlightsBy:highlightsBy|[cell highlightsBy]];
+ }
+ if (showsStateBy) {
+ [cell setShowsStateBy:showsStateBy|[cell showsStateBy]];
+ }
+#if 0
+ if (style == NSShadowlessSquareBezelStyle) {
+ NSControlSize controlSize = NSRegularControlSize;
+
+ if (butPtr->borderWidth <= 2) {
+ controlSize = NSMiniControlSize;
+ } else if (butPtr->borderWidth == 3) {
+ controlSize = NSSmallControlSize;
}
+ [cell setControlSize:controlSize];
}
- SetControlBounds(mbPtr->userPane, &paneRect);
- SetControlBounds(mbPtr->control, &cntrRect);
+#endif
+ [button setAllowsMixedState:YES];
- if (!mbPtr->useTkText) {
- Str255 controlTitle;
- ControlFontStyleRec fontStyle;
- Tk_Font font;
+ if (!haveImage || haveCompound) {
int len;
+ char *text = Tcl_GetStringFromObj(butPtr->textPtr, &len);
- if (((mbPtr->info.image == NULL) && (mbPtr->info.bitmap == None))
- || (mbPtr->info.compound != COMPOUND_NONE)) {
- len = TkFontGetFirstTextLayout(butPtr->textLayout,
- &font, (char*) controlTitle);
- controlTitle[len] = 0;
- } else {
- len = 0;
- controlTitle[0] = 0;
- }
- if (rebuild || bcmp(mbPtr->controlTitle, controlTitle, len+1)) {
- CFStringRef cf = CFStringCreateWithCString(NULL,
- (char*) controlTitle, kCFStringEncodingUTF8);
-
- if (cf != NULL) {
- SetControlTitleWithCFString(mbPtr->control, cf);
- CFRelease(cf);
- }
- bcopy(controlTitle, mbPtr->controlTitle, len+1);
- }
if (len) {
- TkMacOSXInitControlFontStyle(font, &fontStyle);
- if (bcmp(&mbPtr->fontStyle, &fontStyle, sizeof(fontStyle)) ) {
- ChkErr(SetControlFontStyle, mbPtr->control, &fontStyle);
- bcopy(&fontStyle, &mbPtr->fontStyle, sizeof(fontStyle));
- }
+ NSString *title = [[NSString alloc] initWithBytes:text length:len
+ encoding:NSUTF8StringEncoding];
+ [button setTitle:title];
+ [title release];
+ haveText = 1;
}
}
- if (mbPtr->params.isBevel) {
- /*
- * Initialiase the image/button parameters.
- */
-
- SetupBevelButton(mbPtr, mbPtr->control, destPort, gc, pixmap);
- }
+ haveCompound = (haveCompound && haveImage && haveText);
+ if (haveText) {
+ NSTextAlignment alignment = NSNaturalTextAlignment;
- if (butPtr->flags & SELECTED) {
- SetControlValue(mbPtr->control, 1);
- } else if (butPtr->flags & TRISTATED) {
- SetControlValue(mbPtr->control, 2);
+ switch (butPtr->justify) {
+ case TK_JUSTIFY_LEFT:
+ alignment = NSLeftTextAlignment;
+ break;
+ case TK_JUSTIFY_RIGHT:
+ alignment = NSRightTextAlignment;
+ break;
+ case TK_JUSTIFY_CENTER:
+ alignment = NSCenterTextAlignment;
+ break;
+ }
+ [button setAlignment:alignment];
} else {
- SetControlValue(mbPtr->control, 0);
+ [button setTitle:@""];
}
-
- active = ((mbPtr->flags & ACTIVE) != 0);
- if (active != IsControlActive(mbPtr->control)) {
- if (active) {
- ChkErr(ActivateControl, mbPtr->control);
- } else {
- ChkErr(DeactivateControl, mbPtr->control);
- }
+ font = TkMacOSXNSFontForFont(butPtr->tkfont);
+ if (font) {
+ [button setFont:font];
}
- enabled = !(butPtr->state == STATE_DISABLED);
- if (enabled != IsControlEnabled(mbPtr->control)) {
- if (enabled) {
- ChkErr(EnableControl, mbPtr->control);
+ TkMacOSXMakeCollectableAndRelease(macButtonPtr->image);
+ TkMacOSXMakeCollectableAndRelease(macButtonPtr->selectImage);
+ TkMacOSXMakeCollectableAndRelease(macButtonPtr->tristateImage);
+ if (haveImage) {
+ int width, height;
+ NSImage *image, *selectImage = nil, *tristateImage = nil;
+ NSCellImagePosition pos = NSImageOnly;
+
+ if (butPtr->image) {
+ Tk_SizeOfImage(butPtr->image, &width, &height);
+ image = TkMacOSXGetNSImageWithTkImage(butPtr->display,
+ butPtr->image, width, height);
+ if (butPtr->selectImage) {
+ selectImage = TkMacOSXGetNSImageWithTkImage(butPtr->display,
+ butPtr->selectImage, width, height);
+ }
+ if (butPtr->tristateImage) {
+ tristateImage = TkMacOSXGetNSImageWithTkImage(butPtr->display,
+ butPtr->tristateImage, width, height);
+ }
} else {
- ChkErr(DisableControl, mbPtr->control);
+ Tk_SizeOfBitmap(butPtr->display, butPtr->bitmap, &width, &height);
+ image = TkMacOSXGetNSImageWithBitmap(butPtr->display,
+ butPtr->bitmap, butPtr->normalTextGC, width, height);
+ selectImage = TkMacOSXGetNSImageWithBitmap(butPtr->display,
+ butPtr->bitmap, butPtr->activeTextGC, width, height);
}
- }
- if (active && enabled) {
- if (butPtr->state == STATE_ACTIVE) {
- if (mbPtr->params.isBevel) {
- HiliteControl(mbPtr->control, kControlButtonPart);
- } else {
- switch (butPtr->type) {
- case TYPE_BUTTON:
- HiliteControl(mbPtr->control, kControlButtonPart);
- break;
- case TYPE_RADIO_BUTTON:
- HiliteControl(mbPtr->control, kControlRadioButtonPart);
- break;
- case TYPE_CHECK_BUTTON:
- HiliteControl(mbPtr->control, kControlCheckBoxPart);
- break;
- }
+ [button setImage:image];
+ if (selectImage) {
+ [button setAlternateImage:selectImage];
+ }
+ if (tristateImage) {
+ macButtonPtr->image = TkMacOSXMakeUncollectableAndRetain(image);
+ if (selectImage) {
+ macButtonPtr->selectImage =
+ TkMacOSXMakeUncollectableAndRetain(selectImage);
}
- } else {
- HiliteControl(mbPtr->control, kControlNoPart);
+ macButtonPtr->tristateImage =
+ TkMacOSXMakeUncollectableAndRetain(tristateImage);
}
+ if (haveCompound) {
+ switch ((enum compound) butPtr->compound) {
+ case COMPOUND_TOP:
+ pos = NSImageAbove;
+ break;
+ case COMPOUND_BOTTOM:
+ pos = NSImageBelow;
+ break;
+ case COMPOUND_LEFT:
+ pos = NSImageLeft;
+ break;
+ case COMPOUND_RIGHT:
+ pos = NSImageRight;
+ break;
+ case COMPOUND_CENTER:
+ pos = NSImageOverlaps;
+ break;
+ case COMPOUND_NONE:
+ pos = NSImageOnly;
+ break;
+ }
+ }
+ [button setImagePosition:pos];
}
- UpdateControlColors(mbPtr);
- if (butPtr->type == TYPE_BUTTON && !mbPtr->params.isBevel) {
- Boolean isDefault;
+ // if font is too tall, we can't use the fixed-height rounded bezel
+ if (!haveImage && haveText && style == NSRoundedBezelStyle) {
+ Tk_FontMetrics fm;
+ Tk_GetFontMetrics(butPtr->tkfont, &fm);
+ if (fm.linespace > 18) {
+ [button setBezelStyle:(style = NSRegularSquareBezelStyle)];
+ }
+ }
- if (butPtr->defaultState == STATE_ACTIVE) {
- isDefault = true;
- } else {
- isDefault = false;
+ bounds.size = [cell cellSize];
+ if (haveText) {
+ titleRect = [cell titleRectForBounds:bounds];
+ if (butPtr->wrapLength > 0 &&
+ titleRect.size.width > butPtr->wrapLength) {
+ if (style == NSRoundedBezelStyle) {
+ [button setBezelStyle:(style = NSRegularSquareBezelStyle)];
+ bounds.size = [cell cellSize];
+ titleRect = [cell titleRectForBounds:bounds];
+ }
+ bounds.size.width -= titleRect.size.width - butPtr->wrapLength;
+ bounds.size.height = 40000.0;
+ [cell setWraps:YES];
+ bounds.size = [cell cellSizeForBounds:bounds];
+#ifdef TK_MAC_DEBUG_BUTTON
+ titleRect = [cell titleRectForBounds:bounds];
+#endif
+#if TK_MAC_BUTTON_USE_COMPATIBILITY_METRICS
+ if (tkMacOSXUseCompatibilityMetrics) {
+ bounds.size.height += 3;
+ }
+#endif
}
- ChkErr(SetControlData, mbPtr->control, kControlNoPart,
- kControlPushButtonDefaultTag, sizeof(isDefault), &isDefault);
}
+ width = lround(bounds.size.width);
+ height = lround(bounds.size.height);
+#if TK_MAC_BUTTON_USE_COMPATIBILITY_METRICS
+ if (tkMacOSXUseCompatibilityMetrics) {
+ macButtonPtr->fix = fixForTypeStyle(type, style);
+ width -= boundsFixes[macButtonPtr->fix].trimW;
+ height -= boundsFixes[macButtonPtr->fix].trimH;
+ }
+#endif
- if (mbPtr->flags & FIRST_DRAW) {
- ShowControl(mbPtr->userPane);
- ShowControl(mbPtr->control);
- mbPtr->flags ^= FIRST_DRAW;
+ if (haveImage || haveCompound) {
+ if (butPtr->width > 0) {
+ width = butPtr->width;
+ }
+ if (butPtr->height > 0) {
+ height = butPtr->height;
+ }
} else {
- SetControlVisibility(mbPtr->control, true, true);
- Draw1Control(mbPtr->userPane);
- }
+ if (butPtr->width > 0) {
+ int avgWidth = Tk_TextWidth(butPtr->tkfont, "0", 1);
+ width = butPtr->width * avgWidth;
+ }
+ if (butPtr->height > 0) {
+ Tk_FontMetrics fm;
- if (mbPtr->params.isBevel) {
- if (mbPtr->bevelButtonContent.contentType ==
- kControlContentPictHandle) {
- KillPicture(mbPtr->bevelButtonContent.u.picture);
+ Tk_GetFontMetrics(butPtr->tkfont, &fm);
+ height = butPtr->height * fm.linespace;
}
}
+ if (!haveImage || haveCompound) {
+ width += 2*butPtr->padX;
+ height += 2*butPtr->padY;
+ }
+ if (haveImage) {
+ width += 2*border;
+ height += 2*border;
+ }
+#if TK_MAC_BUTTON_USE_COMPATIBILITY_METRICS
+ if (tkMacOSXUseCompatibilityMetrics) {
+ width += 2*NATIVE_BUTTON_INSET;
+ height += 2*NATIVE_BUTTON_INSET + NATIVE_BUTTON_EXTRA_H;
+ }
+#endif
+ Tk_GeometryRequest(butPtr->tkwin, width, height);
+ Tk_SetInternalBorder(butPtr->tkwin, butPtr->inset);
+#ifdef TK_MAC_DEBUG_BUTTON
+ TKLog(@"button %s bounds %@ titleRect %@ width %d height %d inset %d borderWidth %d",
+ ((TkWindow *)butPtr->tkwin)->pathName, NSStringFromRect(bounds),
+ NSStringFromRect(titleRect), width, height, butPtr->inset,
+ butPtr->borderWidth);
+#endif
}
+
+
+#pragma mark -
+#pragma mark Unix Buttons:
+
/*
- *--------------------------------------------------------------
+ *----------------------------------------------------------------------
*
- * SetupBevelButton --
+ * DisplayUnixButton --
*
- * Sets up the Bevel Button with image by copying the
- * source image onto the PicHandle for the button.
+ * This procedure is invoked to display a button widget. It is
+ * normally invoked as an idle handler.
*
* Results:
- * None
+ * None.
*
* Side effects:
- * The image or bitmap for the button is copied over to a picture.
+ * Commands are output to X to display the button in its
+ * current mode. The REDRAW_PENDING flag is cleared.
*
- *--------------------------------------------------------------
+ *----------------------------------------------------------------------
*/
void
-SetupBevelButton(
- MacButton *mbPtr, /* Mac button. */
- ControlRef controlHandle, /* The control to set this picture to. */
- GWorldPtr destPort, /* Off screen GWorld. */
- GC gc, /* The GC we are drawing into - needed for the
- * bevel button. */
- Pixmap pixmap) /* The pixmap we are drawing into - needed for
- * the bevel button. */
+DisplayUnixButton(
+ TkButton *butPtr)
{
- TkButton *butPtr = (TkButton *) mbPtr;
- int height, width;
- ControlButtonGraphicAlignment theAlignment;
- CGrafPtr savePort;
- Boolean portChanged = false;
+ GC gc;
+ Tk_3DBorder border;
+ Pixmap pixmap;
+ int x = 0; /* Initialization only needed to stop compiler
+ * warning. */
+ int y, relief;
+ Tk_Window tkwin = butPtr->tkwin;
+ int width = 0, height = 0, fullWidth, fullHeight;
+ int textXOffset, textYOffset;
+ int haveImage = 0, haveText = 0;
+ int imageWidth, imageHeight;
+ int imageXOffset = 0, imageYOffset = 0;
+ /* image information that will be used to
+ * restrict disabled pixmap as well */
+
+ border = butPtr->normalBorder;
+ if ((butPtr->state == STATE_DISABLED) && (butPtr->disabledFg != NULL)) {
+ gc = butPtr->disabledGC;
+ } else if ((butPtr->state == STATE_ACTIVE)
+ && !Tk_StrictMotif(butPtr->tkwin)) {
+ gc = butPtr->activeTextGC;
+ border = butPtr->activeBorder;
+ } else {
+ gc = butPtr->normalTextGC;
+ }
+ if ((butPtr->flags & SELECTED) && (butPtr->state != STATE_ACTIVE)
+ && (butPtr->selectBorder != NULL) && !butPtr->indicatorOn) {
+ border = butPtr->selectBorder;
+ }
+
+ relief = butPtr->relief;
+
+ pixmap = (Pixmap) Tk_WindowId(tkwin);
+ Tk_Fill3DRectangle(tkwin, pixmap, border, 0, 0, Tk_Width(tkwin),
+ Tk_Height(tkwin), 0, TK_RELIEF_FLAT);
+
+ /*
+ * Display image or bitmap or text for button.
+ */
- if (butPtr->image != None) {
+ if (butPtr->image != NULL) {
Tk_SizeOfImage(butPtr->image, &width, &height);
- } else {
+ haveImage = 1;
+ } else if (butPtr->bitmap != None) {
Tk_SizeOfBitmap(butPtr->display, butPtr->bitmap, &width, &height);
+ haveImage = 1;
}
+ imageWidth = width;
+ imageHeight = height;
- if ((butPtr->width > 0) && (butPtr->width < width)) {
- width = butPtr->width;
- }
- if ((butPtr->height > 0) && (butPtr->height < height)) {
- height = butPtr->height;
- }
+ haveText = (butPtr->textWidth != 0 && butPtr->textHeight != 0);
- {
- portChanged = QDSwapPort(destPort, &savePort);
- mbPtr->picParams.version = -2;
- mbPtr->picParams.hRes = 0x00480000;
- mbPtr->picParams.vRes = 0x00480000;
- mbPtr->picParams.srcRect.top = 0;
- mbPtr->picParams.srcRect.left = 0;
- mbPtr->picParams.srcRect.bottom = height;
- mbPtr->picParams.srcRect.right = width;
- mbPtr->picParams.reserved1 = 0;
- mbPtr->picParams.reserved2 = 0;
- mbPtr->bevelButtonContent.contentType = kControlContentPictHandle;
- mbPtr->bevelButtonContent.u.picture = OpenCPicture(&mbPtr->picParams);
- if (!mbPtr->bevelButtonContent.u.picture) {
- TkMacOSXDbgMsg("OpenCPicture failed");
- }
- tkPictureIsOpen = 1;
+ if (butPtr->compound != COMPOUND_NONE && haveImage && haveText) {
+ textXOffset = 0;
+ textYOffset = 0;
+ fullWidth = 0;
+ fullHeight = 0;
- /*
- * TO DO - There is one case where XCopyPlane calls CopyDeepMask,
- * which does not get recorded in the picture. So the bitmap code
- * will fail in that case.
- */
- }
+ switch ((enum compound) butPtr->compound) {
+ case COMPOUND_TOP:
+ case COMPOUND_BOTTOM:
+ /*
+ * Image is above or below text.
+ */
- if (butPtr->selectImage != NULL && (butPtr->flags & SELECTED)) {
- Tk_RedrawImage(butPtr->selectImage, 0, 0, width, height, pixmap, 0, 0);
- } else if (butPtr->tristateImage != NULL && (butPtr->flags & TRISTATED)) {
- Tk_RedrawImage(butPtr->tristateImage, 0, 0, width, height, pixmap, 0,
- 0);
- } else if (butPtr->image != NULL) {
- Tk_RedrawImage(butPtr->image, 0, 0, width, height, pixmap, 0, 0);
- } else {
- XSetClipOrigin(butPtr->display, gc, 0, 0);
- XCopyPlane(butPtr->display, butPtr->bitmap, pixmap, gc, 0, 0, width,
- height, 0, 0, 1);
- }
+ if (butPtr->compound == COMPOUND_TOP) {
+ textYOffset = height + butPtr->padY;
+ } else {
+ imageYOffset = butPtr->textHeight + butPtr->padY;
+ }
+ fullHeight = height + butPtr->textHeight + butPtr->padY;
+ fullWidth = (width > butPtr->textWidth ? width :
+ butPtr->textWidth);
+ textXOffset = (fullWidth - butPtr->textWidth)/2;
+ imageXOffset = (fullWidth - width)/2;
+ break;
+ case COMPOUND_LEFT:
+ case COMPOUND_RIGHT:
+ /*
+ * Image is left or right of text.
+ */
- {
- ClosePicture();
- tkPictureIsOpen = 0;
- if (portChanged) {
- QDSwapPort(savePort, NULL);
- }
- }
- ChkErr(SetControlData, controlHandle, kControlButtonPart,
- kControlBevelButtonContentTag,
- sizeof(ControlButtonContentInfo),
- (char *) &mbPtr->bevelButtonContent);
-
- if (butPtr->anchor == TK_ANCHOR_N) {
- theAlignment = kControlBevelButtonAlignTop;
- } else if (butPtr->anchor == TK_ANCHOR_NE) {
- theAlignment = kControlBevelButtonAlignTopRight;
- } else if (butPtr->anchor == TK_ANCHOR_E) {
- theAlignment = kControlBevelButtonAlignRight;
- } else if (butPtr->anchor == TK_ANCHOR_SE) {
- theAlignment = kControlBevelButtonAlignBottomRight;
- } else if (butPtr->anchor == TK_ANCHOR_S) {
- theAlignment = kControlBevelButtonAlignBottom;
- } else if (butPtr->anchor == TK_ANCHOR_SW) {
- theAlignment = kControlBevelButtonAlignBottomLeft;
- } else if (butPtr->anchor == TK_ANCHOR_W) {
- theAlignment = kControlBevelButtonAlignLeft;
- } else if (butPtr->anchor == TK_ANCHOR_NW) {
- theAlignment = kControlBevelButtonAlignTopLeft;
- } else if (butPtr->anchor == TK_ANCHOR_CENTER) {
- theAlignment = kControlBevelButtonAlignCenter;
- }
- ChkErr(SetControlData, controlHandle, kControlButtonPart,
- kControlBevelButtonGraphicAlignTag,
- sizeof(ControlButtonGraphicAlignment), (char *) &theAlignment);
-
- if (butPtr->compound != COMPOUND_NONE) {
- ControlButtonTextPlacement thePlacement =
- kControlBevelButtonPlaceNormally;
-
- if (butPtr->compound == COMPOUND_TOP) {
- thePlacement = kControlBevelButtonPlaceBelowGraphic;
- } else if (butPtr->compound == COMPOUND_BOTTOM) {
- thePlacement = kControlBevelButtonPlaceAboveGraphic;
- } else if (butPtr->compound == COMPOUND_LEFT) {
- thePlacement = kControlBevelButtonPlaceToRightOfGraphic;
- } else if (butPtr->compound == COMPOUND_RIGHT) {
- thePlacement = kControlBevelButtonPlaceToLeftOfGraphic;
+ if (butPtr->compound == COMPOUND_LEFT) {
+ textXOffset = width + butPtr->padX;
+ } else {
+ imageXOffset = butPtr->textWidth + butPtr->padX;
+ }
+ fullWidth = butPtr->textWidth + butPtr->padX + width;
+ fullHeight = (height > butPtr->textHeight ? height :
+ butPtr->textHeight);
+ textYOffset = (fullHeight - butPtr->textHeight)/2;
+ imageYOffset = (fullHeight - height)/2;
+ break;
+ case COMPOUND_CENTER:
+ /*
+ * Image and text are superimposed.
+ */
+
+ fullWidth = (width > butPtr->textWidth ? width :
+ butPtr->textWidth);
+ fullHeight = (height > butPtr->textHeight ? height :
+ butPtr->textHeight);
+ textXOffset = (fullWidth - butPtr->textWidth)/2;
+ imageXOffset = (fullWidth - width)/2;
+ textYOffset = (fullHeight - butPtr->textHeight)/2;
+ imageYOffset = (fullHeight - height)/2;
+ break;
+ case COMPOUND_NONE:
+ break;
}
- ChkErr(SetControlData, controlHandle, kControlButtonPart,
- kControlBevelButtonTextPlaceTag,
- sizeof(ControlButtonTextPlacement), (char *) &thePlacement);
- }
-}
-
-/*
- *--------------------------------------------------------------
- *
- * SetUserPaneDrawProc --
- *
- * Utility function to add a UserPaneDrawProc
- * to a userPane control. From MoreControls code
- * from Apple DTS.
- *
- * Results:
- * MacOS system error.
- *
- * Side effects:
- * The user pane gets a new UserPaneDrawProc.
- *
- *--------------------------------------------------------------
- */
-OSStatus
-SetUserPaneDrawProc(
- ControlRef control,
- ControlUserPaneDrawProcPtr upp)
-{
- ControlUserPaneDrawUPP myControlUserPaneDrawUPP;
+ TkComputeAnchor(butPtr->anchor, tkwin, butPtr->padX, butPtr->padY,
+ fullWidth, fullHeight, &x, &y);
- myControlUserPaneDrawUPP = NewControlUserPaneDrawUPP(upp);
- return SetControlData(control, kControlNoPart,
- kControlUserPaneDrawProcTag, sizeof(myControlUserPaneDrawUPP),
- (Ptr) &myControlUserPaneDrawUPP);
-}
-
-/*
- *--------------------------------------------------------------
- *
- * SetUserPaneSetUpSpecialBackgroundProc --
- *
- * Utility function to add a UserPaneBackgroundProc
- * to a userPane control
- *
- * Results:
- * MacOS system error.
- *
- * Side effects:
- * The user pane gets a new UserPaneBackgroundProc.
- *
- *--------------------------------------------------------------
- */
+ imageXOffset += x;
+ imageYOffset += y;
-OSStatus
-SetUserPaneSetUpSpecialBackgroundProc(
- ControlRef control,
- ControlUserPaneBackgroundProcPtr upp)
-{
- ControlUserPaneBackgroundUPP myControlUserPaneBackgroundUPP;
+ if (butPtr->image != NULL) {
+ /*
+ * Do boundary clipping, so that Tk_RedrawImage is passed valid
+ * coordinates. [Bug 979239]
+ */
- myControlUserPaneBackgroundUPP = NewControlUserPaneBackgroundUPP(upp);
- return SetControlData(control, kControlNoPart,
- kControlUserPaneBackgroundProcTag,
- sizeof(myControlUserPaneBackgroundUPP),
- (Ptr) &myControlUserPaneBackgroundUPP);
-}
-
-/*
- *--------------------------------------------------------------
- *
- * UserPaneDraw --
- *
- * This function draws the background of the user pane that will
- * lie under checkboxes and radiobuttons.
- *
- * Results:
- * None.
- *
- * Side effects:
- * The user pane gets updated to the current color.
- *
- *--------------------------------------------------------------
- */
+ if (imageXOffset < 0) {
+ imageXOffset = 0;
+ }
+ if (imageYOffset < 0) {
+ imageYOffset = 0;
+ }
+ if (width > Tk_Width(tkwin)) {
+ width = Tk_Width(tkwin);
+ }
+ if (height > Tk_Height(tkwin)) {
+ height = Tk_Height(tkwin);
+ }
+ if ((width + imageXOffset) > Tk_Width(tkwin)) {
+ imageXOffset = Tk_Width(tkwin) - width;
+ }
+ if ((height + imageYOffset) > Tk_Height(tkwin)) {
+ imageYOffset = Tk_Height(tkwin) - height;
+ }
-void
-UserPaneDraw(
- ControlRef control,
- ControlPartCode cpc)
-{
- MacButton *mbPtr = (MacButton *)(intptr_t)GetControlReference(control);
- Rect contrlRect;
- CGrafPtr port;
-
- GetPort(&port);
- GetControlBounds(control,&contrlRect);
- TkMacOSXSetColorInPort(mbPtr->userPaneBackground, 0, NULL, port);
- EraseRect(&contrlRect);
-}
-
-/*
- *--------------------------------------------------------------
- *
- * UserPaneBackgroundProc --
- *
- * This function sets up the background of the user pane that will
- * lie under checkboxes and radiobuttons.
- *
- * Results:
- * None.
- *
- * Side effects:
- * The user pane background gets set to the current color.
- *
- *--------------------------------------------------------------
- */
+ if ((butPtr->selectImage != NULL) && (butPtr->flags & SELECTED)) {
+ Tk_RedrawImage(butPtr->selectImage, 0, 0,
+ width, height, pixmap, imageXOffset, imageYOffset);
+ } else if ((butPtr->tristateImage != NULL) && (butPtr->flags & TRISTATED)) {
+ Tk_RedrawImage(butPtr->tristateImage, 0, 0,
+ width, height, pixmap, imageXOffset, imageYOffset);
+ } else {
+ Tk_RedrawImage(butPtr->image, 0, 0, width,
+ height, pixmap, imageXOffset, imageYOffset);
+ }
+ } else {
+ XSetClipOrigin(butPtr->display, gc, imageXOffset, imageYOffset);
+ XCopyPlane(butPtr->display, butPtr->bitmap, pixmap, gc,
+ 0, 0, (unsigned int) width, (unsigned int) height,
+ imageXOffset, imageYOffset, 1);
+ XSetClipOrigin(butPtr->display, gc, 0, 0);
+ }
-void
-UserPaneBackgroundProc(
- ControlHandle control,
- ControlBackgroundPtr info)
-{
- MacButton * mbPtr = (MacButton *)(intptr_t)GetControlReference(control);
+ Tk_DrawTextLayout(butPtr->display, pixmap, gc,
+ butPtr->textLayout, x + textXOffset, y + textYOffset, 0, -1);
+ Tk_UnderlineTextLayout(butPtr->display, pixmap, gc,
+ butPtr->textLayout, x + textXOffset, y + textYOffset,
+ butPtr->underline);
+ y += fullHeight/2;
+ } else {
+ if (haveImage) {
+ TkComputeAnchor(butPtr->anchor, tkwin, 0, 0,
+ width, height, &x, &y);
+ imageXOffset += x;
+ imageYOffset += y;
+ if (butPtr->image != NULL) {
+ /*
+ * Do boundary clipping, so that Tk_RedrawImage is passed
+ * valid coordinates. [Bug 979239]
+ */
- if (info->colorDevice) {
- CGrafPtr port;
-
- GetPort(&port);
- TkMacOSXSetColorInPort(mbPtr->userPaneBackground, 0, NULL, port);
- }
-}
-
-/*
- *--------------------------------------------------------------
- *
- * UpdateControlColors --
- *
- * This function will review the colors used to display
- * a Macintosh button. If any non-standard colors are
- * used we create a custom palette for the button, populate
- * with the colors for the button and install the palette.
- *
- * Under Appearance, we just set the pointer that will be
- * used by the UserPaneDrawProc.
- *
- * Results:
- * None.
- *
- * Side effects:
- * The Macintosh control may get a custom palette installed.
- *
- *--------------------------------------------------------------
- */
+ if (imageXOffset < 0) {
+ imageXOffset = 0;
+ }
+ if (imageYOffset < 0) {
+ imageYOffset = 0;
+ }
+ if (width > Tk_Width(tkwin)) {
+ width = Tk_Width(tkwin);
+ }
+ if (height > Tk_Height(tkwin)) {
+ height = Tk_Height(tkwin);
+ }
+ if ((width + imageXOffset) > Tk_Width(tkwin)) {
+ imageXOffset = Tk_Width(tkwin) - width;
+ }
+ if ((height + imageYOffset) > Tk_Height(tkwin)) {
+ imageYOffset = Tk_Height(tkwin) - height;
+ }
-static int
-UpdateControlColors(
- MacButton *mbPtr)
-{
- XColor *xcolor;
- TkButton *butPtr = (TkButton *) mbPtr;
+ if ((butPtr->selectImage != NULL) &&
+ (butPtr->flags & SELECTED)) {
+ Tk_RedrawImage(butPtr->selectImage, 0, 0, width,
+ height, pixmap, imageXOffset, imageYOffset);
+ } else if ((butPtr->tristateImage != NULL) &&
+ (butPtr->flags & TRISTATED)) {
+ Tk_RedrawImage(butPtr->tristateImage, 0, 0, width,
+ height, pixmap, imageXOffset, imageYOffset);
+ } else {
+ Tk_RedrawImage(butPtr->image, 0, 0, width, height, pixmap,
+ imageXOffset, imageYOffset);
+ }
+ } else {
+ XSetClipOrigin(butPtr->display, gc, x, y);
+ XCopyPlane(butPtr->display, butPtr->bitmap, pixmap, gc, 0, 0,
+ (unsigned int) width, (unsigned int) height, x, y, 1);
+ XSetClipOrigin(butPtr->display, gc, 0, 0);
+ }
+ y += height/2;
+ } else {
+ TkComputeAnchor(butPtr->anchor, tkwin, butPtr->padX, butPtr->padY,
+ butPtr->textWidth, butPtr->textHeight, &x, &y);
+
+ Tk_DrawTextLayout(butPtr->display, pixmap, gc, butPtr->textLayout,
+ x, y, 0, -1);
+ Tk_UnderlineTextLayout(butPtr->display, pixmap, gc,
+ butPtr->textLayout, x, y, butPtr->underline);
+ y += butPtr->textHeight/2;
+ }
+ }
/*
- * Under Appearance we cannot change the background of the
- * button itself. However, the color we are setting is the color
- * of the containing userPane. This will be the color that peeks
- * around the rounded corners of the button.
- * We make this the highlightbackground rather than the background,
- * because if you color the background of a frame containing a
- * button, you usually also color the highlightbackground as well,
- * or you will get a thin grey ring around the button.
+ * If the button is disabled with a stipple rather than a special
+ * foreground color, generate the stippled effect. If the widget is
+ * selected and we use a different background color when selected, must
+ * temporarily modify the GC so the stippling is the right color.
*/
- if (butPtr->type == TYPE_BUTTON) {
- xcolor = Tk_3DBorderColor(butPtr->highlightBorder);
- } else {
- xcolor = Tk_3DBorderColor(butPtr->normalBorder);
+ if ((butPtr->state == STATE_DISABLED)
+ && ((butPtr->disabledFg == NULL) || (butPtr->image != NULL))) {
+ if ((butPtr->flags & SELECTED) && !butPtr->indicatorOn
+ && (butPtr->selectBorder != NULL)) {
+ XSetForeground(butPtr->display, butPtr->stippleGC,
+ Tk_3DBorderColor(butPtr->selectBorder)->pixel);
+ }
+
+ /*
+ * Stipple the whole button if no disabledFg was specified, otherwise
+ * restrict stippling only to displayed image
+ */
+
+ if (butPtr->disabledFg == NULL) {
+ XFillRectangle(butPtr->display, pixmap, butPtr->stippleGC, 0, 0,
+ (unsigned) Tk_Width(tkwin), (unsigned) Tk_Height(tkwin));
+ } else {
+ XFillRectangle(butPtr->display, pixmap, butPtr->stippleGC,
+ imageXOffset, imageYOffset,
+ (unsigned) imageWidth, (unsigned) imageHeight);
+ }
+ if ((butPtr->flags & SELECTED) && !butPtr->indicatorOn
+ && (butPtr->selectBorder != NULL)) {
+ XSetForeground(butPtr->display, butPtr->stippleGC,
+ Tk_3DBorderColor(butPtr->normalBorder)->pixel);
+ }
}
- mbPtr->userPaneBackground = xcolor->pixel;
- return false;
-}
-
-/*
- *--------------------------------------------------------------
- *
- * ButtonEventProc --
- *
- * This procedure is invoked by the Tk dispatcher for various
- * events on buttons.
- *
- * Results:
- * None.
- *
- * Side effects:
- * When it gets exposed, it is redisplayed.
- *
- *--------------------------------------------------------------
- */
+ /*
+ * Draw the border and traversal highlight last. This way, if the button's
+ * contents overflow they'll be covered up by the border. This code is
+ * complicated by the possible combinations of focus highlight and default
+ * rings. We draw the focus and highlight rings using the highlight border
+ * and highlight foreground color.
+ */
-static void
-ButtonEventProc(
- ClientData clientData, /* Information about window. */
- XEvent *eventPtr) /* Information about event. */
-{
- TkButton *buttonPtr = (TkButton *) clientData;
- MacButton *mbPtr = (MacButton *) clientData;
+ if (relief != TK_RELIEF_FLAT) {
+ int inset = butPtr->highlightWidth;
- if (eventPtr->type == ActivateNotify
- || eventPtr->type == DeactivateNotify) {
- if ((buttonPtr->tkwin == NULL) || (!Tk_IsMapped(buttonPtr->tkwin))) {
- return;
+ if (butPtr->defaultState == DEFAULT_ACTIVE) {
+ /*
+ * Draw the default ring with 2 pixels of space between the
+ * default ring and the button and the default ring and the focus
+ * ring. Note that we need to explicitly draw the space in the
+ * highlightBorder color to ensure that we overwrite any overflow
+ * text and/or a different button background color.
+ */
+
+ Tk_Draw3DRectangle(tkwin, pixmap, butPtr->highlightBorder, inset,
+ inset, Tk_Width(tkwin) - 2*inset,
+ Tk_Height(tkwin) - 2*inset, 2, TK_RELIEF_FLAT);
+ inset += 2;
+ Tk_Draw3DRectangle(tkwin, pixmap, butPtr->highlightBorder, inset,
+ inset, Tk_Width(tkwin) - 2*inset,
+ Tk_Height(tkwin) - 2*inset, 1, TK_RELIEF_SUNKEN);
+ inset++;
+ Tk_Draw3DRectangle(tkwin, pixmap, butPtr->highlightBorder, inset,
+ inset, Tk_Width(tkwin) - 2*inset,
+ Tk_Height(tkwin) - 2*inset, 2, TK_RELIEF_FLAT);
+
+ inset += 2;
+ } else if (butPtr->defaultState == DEFAULT_NORMAL) {
+ /*
+ * Leave room for the default ring and write over any text or
+ * background color.
+ */
+
+ Tk_Draw3DRectangle(tkwin, pixmap, butPtr->highlightBorder, 0,
+ 0, Tk_Width(tkwin), Tk_Height(tkwin), 5, TK_RELIEF_FLAT);
+ inset += 5;
}
- if (eventPtr->type == ActivateNotify) {
- mbPtr->flags |= ACTIVE;
+
+ /*
+ * Draw the button border.
+ */
+
+ Tk_Draw3DRectangle(tkwin, pixmap, border, inset, inset,
+ Tk_Width(tkwin) - 2*inset, Tk_Height(tkwin) - 2*inset,
+ butPtr->borderWidth, relief);
+ }
+ if (butPtr->highlightWidth > 0) {
+ GC gc;
+
+ if (butPtr->flags & GOT_FOCUS) {
+ gc = Tk_GCForColor(butPtr->highlightColorPtr, pixmap);
} else {
- mbPtr->flags &= ~ACTIVE;
+ gc = Tk_GCForColor(Tk_3DBorderColor(butPtr->highlightBorder),
+ pixmap);
}
- if ((buttonPtr->flags & REDRAW_PENDING) == 0) {
- Tcl_DoWhenIdle(TkpDisplayButton, (ClientData) buttonPtr);
- buttonPtr->flags |= REDRAW_PENDING;
+
+ /*
+ * Make sure the focus ring shrink-wraps the actual button, not the
+ * padding space left for a default ring.
+ */
+
+ if (butPtr->defaultState == DEFAULT_NORMAL) {
+ TkDrawInsetFocusHighlight(tkwin, gc, butPtr->highlightWidth,
+ pixmap, 5);
+ } else {
+ Tk_DrawFocusHighlight(tkwin, gc, butPtr->highlightWidth, pixmap);
}
}
}
@@ -1403,217 +1042,150 @@ ButtonEventProc(
/*
*----------------------------------------------------------------------
*
- * TkMacOSXComputeControlParams --
+ * ComputeUnixButtonGeometry --
*
- * This procedure computes the various parameters used
- * when creating a Carbon control (NewControl).
- * These are determined by the various tk button parameters
+ * After changes in a button's text or bitmap, this procedure
+ * recomputes the button's geometry and passes this information
+ * along to the geometry manager for the window.
*
* Results:
* None.
*
* Side effects:
- * Sets the control initialisation parameters
+ * The button's window may change size.
*
*----------------------------------------------------------------------
*/
-static void
-TkMacOSXComputeControlParams(
- TkButton *butPtr,
- MacControlParams *paramsPtr)
+void
+ComputeUnixButtonGeometry(
+ register TkButton *butPtr) /* Button whose geometry may have changed. */
{
- paramsPtr->isBevel = 0;
+ int width, height, avgWidth, txtWidth, txtHeight;
+ int haveImage = 0, haveText = 0;
+ Tk_FontMetrics fm;
+
+ butPtr->inset = butPtr->highlightWidth + butPtr->borderWidth;
/*
- * Determine ProcID based on button type and dimensions.
+ * Leave room for the default ring if needed.
*/
- switch (butPtr->type) {
- case TYPE_BUTTON:
- if ((butPtr->image == None) && (butPtr->bitmap == None)) {
- paramsPtr->initialValue = 1;
- paramsPtr->minValue = 0;
- paramsPtr->maxValue = 1;
- paramsPtr->procID = kControlPushButtonProc;
- } else {
- paramsPtr->initialValue = 0;
- paramsPtr->minValue = kControlBehaviorOffsetContents |
- kControlContentPictHandle;
- paramsPtr->maxValue = 1;
- if (butPtr->borderWidth <= 2) {
- paramsPtr->procID = kControlBevelButtonSmallBevelProc;
- } else if (butPtr->borderWidth == 3) {
- paramsPtr->procID = kControlBevelButtonNormalBevelProc;
- } else {
- paramsPtr->procID = kControlBevelButtonLargeBevelProc;
- }
- paramsPtr->isBevel = 1;
- }
- break;
- case TYPE_RADIO_BUTTON:
- if (((butPtr->image == None) && (butPtr->bitmap == None))
- || (butPtr->indicatorOn)) {
- paramsPtr->initialValue = 1;
- paramsPtr->minValue = 0;
- paramsPtr->maxValue = MAX_VALUE;
- paramsPtr->procID = kControlRadioButtonProc;
- } else {
- paramsPtr->initialValue = 0;
- paramsPtr->minValue = kControlBehaviorOffsetContents |
- kControlBehaviorSticky | kControlContentPictHandle;
- paramsPtr->maxValue = MAX_VALUE;
- if (butPtr->borderWidth <= 2) {
- paramsPtr->procID = kControlBevelButtonSmallBevelProc;
- } else if (butPtr->borderWidth == 3) {
- paramsPtr->procID = kControlBevelButtonNormalBevelProc;
- } else {
- paramsPtr->procID = kControlBevelButtonLargeBevelProc;
- }
- paramsPtr->isBevel = 1;
- }
- break;
- case TYPE_CHECK_BUTTON:
- if (((butPtr->image == None) && (butPtr->bitmap == None))
- || (butPtr->indicatorOn)) {
- paramsPtr->initialValue = 1;
- paramsPtr->minValue = 0;
- paramsPtr->maxValue = MAX_VALUE;
- paramsPtr->procID = kControlCheckBoxProc;
- } else {
- paramsPtr->initialValue = 0;
- paramsPtr->minValue = kControlBehaviorOffsetContents |
- kControlBehaviorSticky | kControlContentPictHandle;
- paramsPtr->maxValue = MAX_VALUE;
- if (butPtr->borderWidth <= 2) {
- paramsPtr->procID = kControlBevelButtonSmallBevelProc;
- } else if (butPtr->borderWidth == 3) {
- paramsPtr->procID = kControlBevelButtonNormalBevelProc;
- } else {
- paramsPtr->procID = kControlBevelButtonLargeBevelProc;
- }
- paramsPtr->isBevel = 1;
- }
- break;
+ if (butPtr->defaultState != DEFAULT_DISABLED) {
+ butPtr->inset += 5;
}
-}
-
-/*
- *----------------------------------------------------------------------
- *
- * TkMacOSXComputeDrawParams --
- *
- * This procedure computes the various parameters used
- * when drawing a button
- * These are determined by the various tk button parameters
- *
- * Results:
- * 1 if control will be used, 0 otherwise.
- *
- * Side effects:
- * Sets the button draw parameters
- *
- *----------------------------------------------------------------------
- */
+ butPtr->indicatorSpace = 0;
-static int
-TkMacOSXComputeDrawParams(
- TkButton *butPtr,
- DrawParams *dpPtr)
-{
- dpPtr->hasImageOrBitmap = ((butPtr->image != NULL)
- || (butPtr->bitmap != None));
- dpPtr->offset = (butPtr->type == TYPE_BUTTON)
- && dpPtr->hasImageOrBitmap;
- dpPtr->border = butPtr->normalBorder;
- if ((butPtr->state == STATE_DISABLED) && (butPtr->disabledFg != NULL)) {
- dpPtr->gc = butPtr->disabledGC;
- } else if (butPtr->type == TYPE_BUTTON && butPtr->state == STATE_ACTIVE) {
- dpPtr->gc = butPtr->activeTextGC;
- dpPtr->border = butPtr->activeBorder;
- } else {
- dpPtr->gc = butPtr->normalTextGC;
- }
+ width = 0;
+ height = 0;
+ txtWidth = 0;
+ txtHeight = 0;
+ avgWidth = 0;
- if ((butPtr->flags & SELECTED) && (butPtr->state != STATE_ACTIVE)
- && (butPtr->selectBorder != NULL) && !butPtr->indicatorOn) {
- dpPtr->border = butPtr->selectBorder;
+ if (butPtr->image != NULL) {
+ Tk_SizeOfImage(butPtr->image, &width, &height);
+ haveImage = 1;
+ } else if (butPtr->bitmap != None) {
+ Tk_SizeOfBitmap(butPtr->display, butPtr->bitmap, &width, &height);
+ haveImage = 1;
}
- /*
- * Override the relief specified for the button if this is a
- * checkbutton or radiobutton and there's no indicator.
- * However, don't do this in the presence of Appearance, since
- * then the bevel button will take care of the relief.
- */
+ if (haveImage == 0 || butPtr->compound != COMPOUND_NONE) {
+ Tk_FreeTextLayout(butPtr->textLayout);
- dpPtr->relief = butPtr->relief;
+ butPtr->textLayout = Tk_ComputeTextLayout(butPtr->tkfont,
+ Tcl_GetString(butPtr->textPtr), -1, butPtr->wrapLength,
+ butPtr->justify, 0, &butPtr->textWidth, &butPtr->textHeight);
- if ((butPtr->type >= TYPE_CHECK_BUTTON) && !butPtr->indicatorOn) {
- if (!dpPtr->hasImageOrBitmap) {
- dpPtr->relief = (butPtr->flags & SELECTED) ? TK_RELIEF_SUNKEN
- : TK_RELIEF_RAISED;
- }
+ txtWidth = butPtr->textWidth;
+ txtHeight = butPtr->textHeight;
+ avgWidth = Tk_TextWidth(butPtr->tkfont, "0", 1);
+ Tk_GetFontMetrics(butPtr->tkfont, &fm);
+ haveText = (txtWidth != 0 && txtHeight != 0);
}
/*
- * Determine the draw type
+ * If the button is compound (i.e., it shows both an image and text), the
+ * new geometry is a combination of the image and text geometry. We only
+ * honor the compound bit if the button has both text and an image,
+ * because otherwise it is not really a compound button.
*/
- if (butPtr->type == TYPE_LABEL) {
- dpPtr->drawType = DRAW_LABEL;
- } else if (butPtr->type == TYPE_BUTTON) {
- if (!dpPtr->hasImageOrBitmap) {
- dpPtr->drawType = DRAW_CONTROL;
- } else if (butPtr->image != None) {
- dpPtr->drawType = DRAW_BEVEL;
- } else {
+ if (butPtr->compound != COMPOUND_NONE && haveImage && haveText) {
+ switch ((enum compound) butPtr->compound) {
+ case COMPOUND_TOP:
+ case COMPOUND_BOTTOM:
/*
- * TO DO - The current way the we draw bitmaps (XCopyPlane)
- * uses CopyDeepMask in this one case. The Picture recording
- * does not record this call, and so we can't use the
- * Appearance bevel button here. The only case that would
- * exercise this is if you use a bitmap, with
- * -data & -mask specified. We should probably draw the
- * appearance button and overprint the image in this case.
- * This just punts and draws the old-style, ugly, button.
+ * Image is above or below text.
*/
- if (dpPtr->gc->clip_mask == 0) {
- dpPtr->drawType = DRAW_BEVEL;
- } else {
- TkpClipMask *clipPtr = (TkpClipMask *) dpPtr->gc->clip_mask;
+ height += txtHeight + butPtr->padY;
+ width = (width > txtWidth ? width : txtWidth);
+ break;
+ case COMPOUND_LEFT:
+ case COMPOUND_RIGHT:
+ /*
+ * Image is left or right of text.
+ */
- if ((clipPtr->type == TKP_CLIP_PIXMAP) &&
- (clipPtr->value.pixmap != butPtr->bitmap)) {
- dpPtr->drawType = DRAW_CUSTOM;
- } else {
- dpPtr->drawType = DRAW_BEVEL;
- }
- }
+ width += txtWidth + butPtr->padX;
+ height = (height > txtHeight ? height : txtHeight);
+ break;
+ case COMPOUND_CENTER:
+ /*
+ * Image and text are superimposed.
+ */
+
+ width = (width > txtWidth ? width : txtWidth);
+ height = (height > txtHeight ? height : txtHeight);
+ break;
+ case COMPOUND_NONE:
+ break;
}
- } else if (butPtr->indicatorOn) {
- dpPtr->drawType = DRAW_CONTROL;
- } else if (dpPtr->hasImageOrBitmap) {
- if (dpPtr->gc->clip_mask == 0) {
- dpPtr->drawType = DRAW_BEVEL;
+ if (butPtr->width > 0) {
+ width = butPtr->width;
+ }
+ if (butPtr->height > 0) {
+ height = butPtr->height;
+ }
+
+ width += 2*butPtr->padX;
+ height += 2*butPtr->padY;
+ } else {
+ if (haveImage) {
+ if (butPtr->width > 0) {
+ width = butPtr->width;
+ }
+ if (butPtr->height > 0) {
+ height = butPtr->height;
+ }
} else {
- TkpClipMask *clipPtr = (TkpClipMask*) dpPtr->gc->clip_mask;
+ width = txtWidth;
+ height = txtHeight;
- if ((clipPtr->type == TKP_CLIP_PIXMAP) &&
- (clipPtr->value.pixmap != butPtr->bitmap)) {
- dpPtr->drawType = DRAW_CUSTOM;
- } else {
- dpPtr->drawType = DRAW_BEVEL;
+ if (butPtr->width > 0) {
+ width = butPtr->width * avgWidth;
+ }
+ if (butPtr->height > 0) {
+ height = butPtr->height * fm.linespace;
}
}
- } else {
- dpPtr->drawType = DRAW_CUSTOM;
}
- if ((dpPtr->drawType == DRAW_CONTROL) || (dpPtr->drawType == DRAW_BEVEL)) {
- return 1;
- } else {
- return 0;
+ if (!haveImage) {
+ width += 2*butPtr->padX;
+ height += 2*butPtr->padY;
}
+ Tk_GeometryRequest(butPtr->tkwin, (int) (width
+ + 2*butPtr->inset), (int) (height + 2*butPtr->inset));
+ Tk_SetInternalBorder(butPtr->tkwin, butPtr->inset);
}
+
+/*
+ * Local Variables:
+ * mode: c
+ * c-basic-offset: 4
+ * fill-column: 79
+ * coding: utf-8
+ * End:
+ */
diff --git a/macosx/tkMacOSXClipboard.c b/macosx/tkMacOSXClipboard.c
index ae56383..639e82f 100644
--- a/macosx/tkMacOSXClipboard.c
+++ b/macosx/tkMacOSXClipboard.c
@@ -4,30 +4,96 @@
* This file manages the clipboard for the Tk toolkit.
*
* Copyright (c) 1995-1997 Sun Microsystems, Inc.
- * Copyright 2001, Apple Computer, Inc.
- * Copyright (c) 2006-2007 Daniel A. Steffen <das@users.sourceforge.net>
+ * Copyright 2001-2009, Apple Inc.
+ * Copyright (c) 2006-2009 Daniel A. Steffen <das@users.sourceforge.net>
*
* See the file "license.terms" for information on usage and redistribution
* of this file, and for a DISCLAIMER OF ALL WARRANTIES.
+ *
+ * RCS: @(#) $Id$
*/
#include "tkMacOSXPrivate.h"
#include "tkSelect.h"
+static NSInteger changeCount = -1;
+static Tk_Window clipboardOwner = NULL;
+
+#pragma mark TKApplication(TKClipboard)
+
+@implementation TKApplication(TKClipboard)
+- (void)tkProvidePasteboard:(TkDisplay *)dispPtr
+ pasteboard:(NSPasteboard *)sender provideDataForType:(NSString *)type {
+ NSMutableString *string = [NSMutableString new];
+
+ if (dispPtr && dispPtr->clipboardActive &&
+ [type isEqualToString:NSStringPboardType]) {
+ for (TkClipboardTarget *targetPtr = dispPtr->clipTargetPtr; targetPtr;
+ targetPtr = targetPtr->nextPtr) {
+ if (targetPtr->type == XA_STRING ||
+ targetPtr->type == dispPtr->utf8Atom) {
+ for (TkClipboardBuffer *cbPtr = targetPtr->firstBufferPtr;
+ cbPtr; cbPtr = cbPtr->nextPtr) {
+ NSString *s = [[NSString alloc] initWithBytesNoCopy:
+ cbPtr->buffer length:cbPtr->length
+ encoding:NSUTF8StringEncoding freeWhenDone:NO];
+ [string appendString:s];
+ [s release];
+ }
+ break;
+ }
+ }
+ }
+ [sender setString:string forType:type];
+ [string release];
+}
+- (void)tkProvidePasteboard:(TkDisplay *)dispPtr {
+ if (dispPtr && dispPtr->clipboardActive) {
+ [self tkProvidePasteboard:dispPtr
+ pasteboard:[NSPasteboard generalPasteboard]
+ provideDataForType:NSStringPboardType];
+ }
+}
+- (void)pasteboard:(NSPasteboard *)sender provideDataForType:(NSString *)type {
+ [self tkProvidePasteboard:TkGetDisplayList() pasteboard:sender
+ provideDataForType:type];
+}
+- (void)tkCheckPasteboard {
+ if (clipboardOwner && [[NSPasteboard generalPasteboard] changeCount] !=
+ changeCount) {
+ TkDisplay *dispPtr = TkGetDisplayList();
+
+ if (dispPtr) {
+ XEvent event;
+
+ event.xany.type = SelectionClear;
+ event.xany.serial = NextRequest(Tk_Display(clipboardOwner));
+ event.xany.send_event = False;
+ event.xany.window = Tk_WindowId(clipboardOwner);
+ event.xany.display = Tk_Display(clipboardOwner);
+ event.xselectionclear.selection = dispPtr->clipboardAtom;
+ Tk_QueueWindowEvent(&event, TCL_QUEUE_TAIL);
+ }
+ clipboardOwner = NULL;
+ }
+}
+@end
+
+#pragma mark -
/*
*----------------------------------------------------------------------
*
* TkSelGetSelection --
*
- * Retrieve the specified selection from another process. For
- * now, only fetching XA_STRING from CLIPBOARD is supported.
- * Eventually other types should be allowed.
+ * Retrieve the specified selection from another process. For now, only
+ * fetching XA_STRING from CLIPBOARD is supported. Eventually other types
+ * should be allowed.
*
* Results:
- * The return value is a standard Tcl return value.
- * If an error occurs (such as no selection exists)
- * then an error message is left in the interp's result.
+ * The return value is a standard Tcl return value. If an error occurs
+ * (such as no selection exists) then an error message is left in the
+ * interp's result.
*
* Side effects:
* None.
@@ -48,109 +114,36 @@ TkSelGetSelection(
* once it has been retrieved. */
ClientData clientData) /* Arbitrary value to pass to proc. */
{
- int result;
- OSStatus err;
- long length;
- ScrapRef scrapRef;
- char *buf;
-
- if ((selection == Tk_InternAtom(tkwin, "CLIPBOARD"))
- && (target == XA_STRING)) {
- /*
- * Get the scrap from the Macintosh global clipboard.
- */
-
- err = ChkErr(GetCurrentScrap, &scrapRef);
- if (err != noErr) {
- Tcl_AppendResult(interp, Tk_GetAtomName(tkwin, selection),
- " GetCurrentScrap failed.", NULL);
- return TCL_ERROR;
- }
-
- /*
- * Try UNICODE first
- */
- err = ChkErr(GetScrapFlavorSize, scrapRef, kScrapFlavorTypeUnicode,
- &length);
- if (err == noErr && length > 0) {
- Tcl_DString ds;
- char *data;
-
- buf = (char *) ckalloc(length + 2);
- buf[length] = 0;
- buf[length+1] = 0; /* 2-byte unicode null */
- err = ChkErr(GetScrapFlavorData, scrapRef, kScrapFlavorTypeUnicode,
- &length, buf);
- if (err == noErr) {
- Tcl_DStringInit(&ds);
- Tcl_UniCharToUtfDString((Tcl_UniChar *)buf,
- Tcl_UniCharLen((Tcl_UniChar *)buf), &ds);
- for (data = Tcl_DStringValue(&ds); *data != '\0'; data++) {
- if (*data == '\r') {
- *data = '\n';
- }
- }
- result = (*proc)(clientData, interp, Tcl_DStringValue(&ds));
- Tcl_DStringFree(&ds);
- ckfree(buf);
- return result;
- }
- }
-
- err = ChkErr(GetScrapFlavorSize, scrapRef, 'TEXT', &length);
- if (err != noErr) {
- Tcl_AppendResult(interp, Tk_GetAtomName(tkwin, selection),
- " GetScrapFlavorSize failed.", NULL);
- return TCL_ERROR;
- }
- if (length > 0) {
- Tcl_DString encodedText;
- char *data;
-
- buf = (char *) ckalloc(length + 1);
- buf[length] = 0;
- err = ChkErr(GetScrapFlavorData, scrapRef, 'TEXT', &length, buf);
- if (err != noErr) {
- Tcl_AppendResult(interp, Tk_GetAtomName(tkwin, selection),
- " GetScrapFlavorData failed.", NULL);
- return TCL_ERROR;
- }
-
- /*
- * Tcl expects '\n' not '\r' as the line break character.
- */
-
- for (data = buf; *data != '\0'; data++) {
- if (*data == '\r') {
- *data = '\n';
- }
- }
-
- Tcl_ExternalToUtfDString(TkMacOSXCarbonEncoding, buf, length,
- &encodedText);
- result = (*proc)(clientData, interp,
- Tcl_DStringValue(&encodedText));
- Tcl_DStringFree(&encodedText);
-
- ckfree(buf);
- return result;
+ int result = TCL_ERROR;
+ TkDisplay *dispPtr = ((TkWindow *) tkwin)->dispPtr;
+
+ if (dispPtr && selection == dispPtr->clipboardAtom && (target == XA_STRING
+ || target == dispPtr->utf8Atom)) {
+ NSString *string = nil;
+ NSPasteboard *pb = [NSPasteboard generalPasteboard];
+ NSString *type = [pb availableTypeFromArray:[NSArray arrayWithObject:
+ NSStringPboardType]];
+
+ if (type) {
+ string = [pb stringForType:type];
}
+ result = proc(clientData, interp, string ? (char*)[string UTF8String]
+ : "");
+ } else {
+ Tcl_AppendResult(interp, Tk_GetAtomName(tkwin, selection),
+ " selection doesn't exist or form \"",
+ Tk_GetAtomName(tkwin, target), "\" not defined", NULL);
}
-
- Tcl_AppendResult(interp, Tk_GetAtomName(tkwin, selection),
- " selection doesn't exist or form \"",
- Tk_GetAtomName(tkwin, target), "\" not defined", NULL);
- return TCL_ERROR;
+ return result;
}
/*
*----------------------------------------------------------------------
*
- * TkSetSelectionOwner --
+ * XSetSelectionOwner --
*
- * This function claims ownership of the specified selection.
- * If the selection is CLIPBOARD, then we empty the system
- * clipboard.
+ * This function claims ownership of the specified selection. If the
+ * selection is CLIPBOARD, then we empty the system clipboard.
*
* Results:
* None.
@@ -168,27 +161,41 @@ XSetSelectionOwner(
Window owner, /* Window to be the owner. */
Time time) /* The current time? */
{
- Tk_Window tkwin;
- TkDisplay *dispPtr;
-
- /*
- * This is a gross hack because the Tk_InternAtom interface is broken.
- * It expects a Tk_Window, even though it only needs a Tk_Display.
- */
-
- tkwin = (Tk_Window) TkGetMainInfoList()->winPtr;
+ TkDisplay *dispPtr = TkGetDisplayList();
- if (selection == Tk_InternAtom(tkwin, "CLIPBOARD")) {
- /*
- * Only claim and empty the clipboard if we aren't already the
- * owner of the clipboard.
- */
-
- dispPtr = TkGetMainInfoList()->winPtr->dispPtr;
+ if (dispPtr && selection == dispPtr->clipboardAtom) {
+ clipboardOwner = owner ? Tk_IdToWindow(display, owner) : NULL;
if (!dispPtr->clipboardActive) {
- ClearCurrentScrap();
+ NSPasteboard *pb = [NSPasteboard generalPasteboard];
+ changeCount = [pb declareTypes:[NSArray array] owner:NSApp];
}
}
+}
+
+/*
+ *----------------------------------------------------------------------
+ *
+ * TkMacOSXSelDeadWindow --
+ *
+ * This function is invoked just before a TkWindow is deleted. It
+ * performs selection-related cleanup.
+ *
+ * Results:
+ * None.
+ *
+ * Side effects:
+ * clipboardOwner is cleared.
+ *
+ *----------------------------------------------------------------------
+ */
+
+void
+TkMacOSXSelDeadWindow(
+ TkWindow *winPtr)
+{
+ if (winPtr && winPtr == (TkWindow *)clipboardOwner) {
+ clipboardOwner = NULL;
+ }
return Success;
}
@@ -197,9 +204,8 @@ XSetSelectionOwner(
*
* TkSelUpdateClipboard --
*
- * This function is called to force the clipboard to be updated
- * after new data is added. On the Mac we don't need to do
- * anything.
+ * This function is called to force the clipboard to be updated after new
+ * data is added.
*
* Results:
* None.
@@ -216,6 +222,9 @@ TkSelUpdateClipboard(
TkClipboardTarget *targetPtr)
/* Info about the content. */
{
+ NSPasteboard *pb = [NSPasteboard generalPasteboard];
+ changeCount = [pb addTypes:[NSArray arrayWithObject:NSStringPboardType]
+ owner:NSApp];
}
/*
@@ -223,8 +232,7 @@ TkSelUpdateClipboard(
*
* TkSelEventProc --
*
- * This procedure is invoked whenever a selection-related
- * event occurs.
+ * This procedure is invoked whenever a selection-related event occurs.
*
* Results:
* None.
@@ -242,6 +250,7 @@ TkSelEventProc(
* SelectionRequest, or SelectionNotify. */
{
if (eventPtr->type == SelectionClear) {
+ clipboardOwner = NULL;
TkSelClearSelection(tkwin, eventPtr);
}
}
@@ -251,9 +260,8 @@ TkSelEventProc(
*
* TkSelPropProc --
*
- * This procedure is invoked when property-change events
- * occur on windows not known to the toolkit. This is a stub
- * function under Windows.
+ * This procedure is invoked when property-change events occur on windows
+ * not known to the toolkit. This is a stub function under Windows.
*
* Results:
* None.
@@ -276,7 +284,6 @@ TkSelPropProc(
* TkSuspendClipboard --
*
* Handle clipboard conversion as required by the suppend event.
- * This function is also called on exit.
*
* Results:
* None.
@@ -290,80 +297,14 @@ TkSelPropProc(
void
TkSuspendClipboard(void)
{
- TkClipboardTarget *targetPtr;
- TkClipboardBuffer *cbPtr;
- TkDisplay *dispPtr;
- char *buffer, *p, *endPtr, *buffPtr;
- long length;
- ScrapRef scrapRef;
-
- dispPtr = TkGetDisplayList();
- if ((dispPtr == NULL) || !dispPtr->clipboardActive) {
- return;
- }
-
- for (targetPtr = dispPtr->clipTargetPtr; targetPtr != NULL;
- targetPtr = targetPtr->nextPtr) {
- if (targetPtr->type == XA_STRING) {
- break;
- }
- }
- if (targetPtr != NULL) {
- Tcl_DString encodedText, unicodedText;
-
- length = 0;
- for (cbPtr = targetPtr->firstBufferPtr; cbPtr != NULL;
- cbPtr = cbPtr->nextPtr) {
- length += cbPtr->length;
- }
-
- buffer = ckalloc(length);
- buffPtr = buffer;
- for (cbPtr = targetPtr->firstBufferPtr; cbPtr != NULL;
- cbPtr = cbPtr->nextPtr) {
- for (p = cbPtr->buffer, endPtr = p + cbPtr->length;
- p < endPtr; p++) {
- if (*p == '\n') {
- *buffPtr++ = '\r';
- } else {
- *buffPtr++ = *p;
- }
- }
- }
-
- ClearCurrentScrap();
- GetCurrentScrap(&scrapRef);
- Tcl_UtfToExternalDString(TkMacOSXCarbonEncoding, buffer, length,
- &encodedText);
- PutScrapFlavor(scrapRef, 'TEXT', 0, Tcl_DStringLength(&encodedText),
- Tcl_DStringValue(&encodedText));
- Tcl_DStringFree(&encodedText);
-
- /*
- * Also put unicode data on scrap.
- */
-
- Tcl_DStringInit(&unicodedText);
- Tcl_UtfToUniCharDString(buffer, length, &unicodedText);
- PutScrapFlavor(scrapRef, kScrapFlavorTypeUnicode, 0,
- Tcl_DStringLength(&unicodedText),
- Tcl_DStringValue(&unicodedText));
- Tcl_DStringFree(&unicodedText);
-
- ckfree(buffer);
- }
-
- /*
- * The system now owns the scrap. We tell Tk that it has
- * lost the selection so that it will look for it the next time
- * it needs it. (Window list NULL if quiting.)
- */
-
- if (TkGetMainInfoList() != NULL) {
- Tk_ClearSelection((Tk_Window) TkGetMainInfoList()->winPtr,
- Tk_InternAtom((Tk_Window) TkGetMainInfoList()->winPtr,
- "CLIPBOARD"));
- }
-
- return;
+ changeCount = [[NSPasteboard generalPasteboard] changeCount];
}
+
+/*
+ * Local Variables:
+ * mode: c
+ * c-basic-offset: 4
+ * fill-column: 79
+ * coding: utf-8
+ * End:
+ */
diff --git a/macosx/tkMacOSXColor.c b/macosx/tkMacOSXColor.c
index 4150846..69d3be8 100644
--- a/macosx/tkMacOSXColor.c
+++ b/macosx/tkMacOSXColor.c
@@ -7,21 +7,18 @@
*
* Copyright (c) 1990-1994 The Regents of the University of California.
* Copyright (c) 1994-1996 Sun Microsystems, Inc.
- * Copyright 2001, Apple Computer, Inc.
- * Copyright (c) 2006-2007 Daniel A. Steffen <das@users.sourceforge.net>
+ * Copyright 2001-2009, Apple Inc.
+ * Copyright (c) 2006-2009 Daniel A. Steffen <das@users.sourceforge.net>
*
* See the file "license.terms" for information on usage and redistribution
* of this file, and for a DISCLAIMER OF ALL WARRANTIES.
+ *
+ * RCS: @(#) $Id$
*/
#include "tkMacOSXPrivate.h"
#include "tkColor.h"
-#if MAC_OS_X_VERSION_MIN_REQUIRED < 1040
-/* Undocumented CG API for creating CGPattern from CGImage */
-extern CGPatternRef CGPatternCreateWithImage(CGImageRef img, int i) WEAK_IMPORT_ATTRIBUTE;
-#endif
-
struct SystemColorMapEntry {
const char *name;
ThemeBrush brush;
@@ -176,7 +173,7 @@ static const struct SystemColorMapEntry systemColorMap[] = {
{ NULL, 0, 0, 0 }
};
#define MAX_PIXELCODE 165
-
+
/*
*----------------------------------------------------------------------
*
@@ -202,7 +199,7 @@ GetThemeFromPixelCode(
ThemeTextColor *textColor,
ThemeBackgroundKind *background)
{
- if (code >= MIN_PIXELCODE && code <= MAX_PIXELCODE && code != PIXEL_MAGIC) {
+ if (code >= MIN_PIXELCODE && code <= MAX_PIXELCODE) {
*brush = systemColorMap[code - MIN_PIXELCODE].brush;
*textColor = systemColorMap[code - MIN_PIXELCODE].textColor;
*background = systemColorMap[code - MIN_PIXELCODE].background;
@@ -211,7 +208,8 @@ GetThemeFromPixelCode(
*textColor = 0;
*background = 0;
}
- if (!*brush && !*textColor && !*background && code != PIXEL_MAGIC) {
+ if (!*brush && !*textColor && !*background && code != PIXEL_MAGIC &&
+ code != TRANSPARENT_PIXEL) {
return false;
} else {
return true;
@@ -240,23 +238,45 @@ GetThemeColor(
ThemeBrush brush,
ThemeTextColor textColor,
ThemeBackgroundKind background,
- RGBColor *c)
+ CGColorRef *c)
{
OSStatus err = noErr;
if (brush) {
- err = ChkErr(GetThemeBrushAsColor,
- brush == kThemeBrushMenuBackgroundSelected ?
- kThemeBrushFocusHighlight : brush, 32, true, c);
- } else if (textColor) {
- err = ChkErr(GetThemeTextColor, textColor, 32, true, c);
+ err = ChkErr(HIThemeBrushCreateCGColor, brush, c);
+ /*} else if (textColor) {
+ err = ChkErr(GetThemeTextColor, textColor, 32, true, c);*/
} else {
- c->red = (pixel >> 16) & 0xff;
- c->green = (pixel >> 8) & 0xff;
- c->blue = (pixel ) & 0xff;
- c->red |= c->red << 8;
- c->green |= c->green << 8;
- c->blue |= c->blue << 8;
+ CGFloat rgba[4] = {0, 0, 0, 1};
+
+ switch ((pixel >> 24) & 0xff) {
+ case PIXEL_MAGIC: {
+ unsigned short red, green, blue;
+ red = (pixel >> 16) & 0xff;
+ green = (pixel >> 8) & 0xff;
+ blue = (pixel ) & 0xff;
+ red |= red << 8;
+ green |= green << 8;
+ blue |= blue << 8;
+ rgba[0] = red / 65535.0;
+ rgba[1] = green / 65535.0;
+ rgba[2] = blue / 65535.0;
+ break;
+ }
+ case TRANSPARENT_PIXEL:
+ rgba[3] = 0.0;
+ break;
+ }
+
+ // this attempts to find something roughly fitting for any display
+// *c = CGColorCreateGenericRGB(rgba[0], rgba[1], rgba[2], rgba[3]);
+
+ // may be off for non-main display but in most cases better than prev
+ static CGColorSpaceRef deviceRGBSpace = NULL;
+ if (!deviceRGBSpace) {
+ deviceRGBSpace = CGDisplayCopyColorSpace(CGMainDisplayID());
+ }
+ *c = CGColorCreate(deviceRGBSpace, rgba );
}
return err;
}
@@ -266,14 +286,14 @@ GetThemeColor(
*
* TkSetMacColor --
*
- * Populates a Macintosh RGBColor structure from a X style
- * pixel value.
+ * Creates a CGColorRef from a X style pixel value.
*
* Results:
* Returns false if not a real pixel, true otherwise.
*
* Side effects:
- * The variable macColor is updated to the pixels value.
+ * The variable macColor is set to a new CGColorRef, the caller is
+ * responsible for releasing it!
*
*----------------------------------------------------------------------
*/
@@ -281,8 +301,9 @@ GetThemeColor(
int
TkSetMacColor(
unsigned long pixel, /* Pixel value to convert. */
- RGBColor *macColor) /* Mac color struct to modify. */
+ void *macColor) /* CGColorRef to modify. */
{
+ CGColorRef *color = (CGColorRef*)macColor;
OSStatus err = -1;
ThemeBrush brush;
ThemeTextColor textColor;
@@ -291,7 +312,7 @@ TkSetMacColor(
if (GetThemeFromPixelCode((pixel >> 24) & 0xff, &brush, &textColor,
&background)) {
err = ChkErr(GetThemeColor, pixel, brush, textColor, background,
- macColor);
+ color);
}
return (err == noErr);
}
@@ -299,81 +320,149 @@ TkSetMacColor(
/*
*----------------------------------------------------------------------
*
- * TkMacOSXSetColorInPort --
+ * TkpInitGCCache, TkpFreeGCCache, CopyCachedColor, SetCachedColor --
*
- * Sets fore or back color in the given QD port from an X pixel
- * value, and if the pixel code indicates a system color, sets
- * the corresponding brush, textColor or background via
- * Appearance mgr APIs.
+ * Maintain a per-GC cache of previously converted CGColorRefs
*
* Results:
- * None.
+ * None resp. retained CGColorRef for CopyCachedColor()
*
* Side effects:
- * If penPat is non-NULL it is set to the forground color/pattern.
+ * None.
*
*----------------------------------------------------------------------
*/
void
-TkMacOSXSetColorInPort(
- unsigned long pixel,
- int fg,
- PixPatHandle penPat,
- CGrafPtr port)
+TkpInitGCCache(
+ GC gc)
{
- OSStatus err;
- RGBColor c;
- ThemeBrush brush;
- ThemeTextColor textColor;
- ThemeBackgroundKind background;
- int setPenPat = 0;
+ bzero(TkpGetGCCache(gc), sizeof(TkpGCCache));
+}
- if (GetThemeFromPixelCode((pixel >> 24) & 0xff, &brush, &textColor,
- &background)) {
- CGrafPtr savePort;
- Boolean portChanged;
+void
+TkpFreeGCCache(
+ GC gc)
+{
+ TkpGCCache *gcCache = TkpGetGCCache(gc);
- 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);
- }
- }
- err = -1;
- if (brush) {
- err = ChkErr(SetThemeBackground,
- brush == kThemeBrushMenuBackgroundSelected ?
- kThemeBrushFocusHighlight : brush, 32, true);
- } else if (textColor && fg) {
- err = ChkErr(SetThemeTextColor, textColor, 32, true);
- } else if (background) {
- Rect bounds;
+ if (gcCache->cachedForegroundColor) {
+ CFRelease(gcCache->cachedForegroundColor);
+ }
+ if (gcCache->cachedBackgroundColor) {
+ CFRelease(gcCache->cachedBackgroundColor);
+ }
+}
- GetPortBounds(port, &bounds);
- err = ChkErr(ApplyThemeBackground, background, &bounds,
- kThemeStateActive, 32, true);
+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 (penPat && err == noErr && (brush || background)) {
- GetPortBackPixPat(port, penPat);
- setPenPat = 1;
+ if (cgColor) {
+ CFRetain(cgColor);
}
- if (portChanged) {
- QDSwapPort(savePort, NULL);
+ }
+ 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;
}
- } else {
- TkMacOSXDbgMsg("Ignored unknown pixel value 0x%lx", pixel);
}
- if (penPat && !setPenPat) {
- GetPortBackPixPat(port, penPat);
+}
+
+/*
+ *----------------------------------------------------------------------
+ *
+ * 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.
+ *
+ * Results:
+ * Returns nil if not a real pixel, NSColor* otherwise.
+ *
+ * Side effects:
+ * None
+ *
+ *----------------------------------------------------------------------
+ */
+
+NSColor*
+TkMacOSXGetNSColor(
+ GC gc,
+ unsigned long pixel) /* Pixel value to convert. */
+{
+ CGColorRef cgColor = TkMacOSXCreateCGColor(gc, pixel);
+ 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);
+ }
+ return nsColor;
}
/*
@@ -397,136 +486,52 @@ TkMacOSXSetColorInPort(
void
TkMacOSXSetColorInContext(
+ GC gc,
unsigned long pixel,
CGContextRef context)
{
OSStatus err = -1;
- RGBColor c;
+ CGColorRef cgColor = CopyCachedColor(gc, pixel);
ThemeBrush brush;
ThemeTextColor textColor;
ThemeBackgroundKind background;
- if (GetThemeFromPixelCode((pixel >> 24) & 0xff, &brush, &textColor,
- &background)) {
+ if (!cgColor && GetThemeFromPixelCode((pixel >> 24) & 0xff, &brush,
+ &textColor, &background)) {
if (brush) {
- TK_IF_MAC_OS_X_API (4, HIThemeSetFill,
- err = ChkErr(HIThemeSetFill, brush, NULL, context,
+ err = ChkErr(HIThemeSetFill, brush, NULL, context,
+ kHIThemeOrientationNormal);
+ if (err == noErr) {
+ err = ChkErr(HIThemeSetStroke, brush, NULL, context,
kHIThemeOrientationNormal);
- TK_IF_MAC_OS_X_API_COND (4, HIThemeSetFill, err == noErr,
- err = ChkErr(HIThemeSetStroke, brush, NULL, context,
- kHIThemeOrientationNormal);
- ) TK_ENDIF
- ) TK_ENDIF
+ }
} else if (textColor) {
- TK_IF_MAC_OS_X_API (4, HIThemeSetTextFill,
- err = ChkErr(HIThemeSetTextFill, textColor, NULL, context,
- kHIThemeOrientationNormal);
- ) TK_ENDIF
+ err = ChkErr(HIThemeSetTextFill, textColor, NULL, context,
+ kHIThemeOrientationNormal);
} else if (background) {
- TK_IF_MAC_OS_X_API (3, CGContextGetClipBoundingBox,
- CGRect rect = CGContextGetClipBoundingBox(context);
- HIThemeBackgroundDrawInfo info = { 0, kThemeStateActive,
- background };
-
- TK_IF_MAC_OS_X_API (3, HIThemeApplyBackground,
- TK_IF_HI_TOOLBOX (3, /* c.f. QA1377 */
- err = ChkErr(HIThemeApplyBackground, &rect, &info,
- context, kHIThemeOrientationNormal);
- ) TK_ENDIF
- ) TK_ENDIF
- ) TK_ENDIF
+ CGRect rect = CGContextGetClipBoundingBox(context);
+ HIThemeBackgroundDrawInfo info = { 0, kThemeStateActive,
+ background };
+
+ err = ChkErr(HIThemeApplyBackground, &rect, &info,
+ context, kHIThemeOrientationNormal);
}
if (err == noErr) {
return;
}
-#if MAC_OS_X_VERSION_MIN_REQUIRED < 1040
- /*
- * Convert Appearance theme pattern to CGPattern:
- */
- if ((brush || background) && CGPatternCreateWithImage != NULL) {
- static PixPatHandle pixpat = NULL;
- static GWorldPtr patGWorld = NULL;
- static uint32_t bitmapInfo = 0;
- const short patDim = 16;
- const Rect bounds = {0, 0, patDim, patDim};
- CGrafPtr savePort;
- Boolean portChanged;
- PixMapHandle pixmap;
- long rowbytes;
- CGImageRef img;
- CGColorSpaceRef rgbCspace;
- CGDataProviderRef provider;
-
- if (!pixpat) {
- pixpat = NewPixPat();
- err = ChkErr(NewGWorld, &patGWorld, 32, &bounds, NULL, NULL, 0
-#ifdef __LITTLE_ENDIAN__
- | kNativeEndianPixMap
-#endif
- );
- if (!pixpat || err != noErr || !patGWorld) {
- Tcl_Panic("TkMacOSXSetColorInContext(): "
- "pattern initialization failed !");
- }
- TK_IF_HI_TOOLBOX (4,
- bitmapInfo = kCGBitmapByteOrder32Host;
- ) TK_ENDIF
- }
- portChanged = QDSwapPort(patGWorld, &savePort);
- TkMacOSXSetColorInPort(pixel, 1, pixpat, patGWorld);
-#ifdef TK_MAC_DEBUG
- Rect patBounds;
- GetPixBounds((**pixpat).patMap, &patBounds);
- if (patBounds.right > patDim || patBounds.bottom > patDim) {
- Tcl_Panic("TkMacOSXSetColorInContext(): "
- "pattern larger than expected !");
- }
-#endif /* TK_MAC_DEBUG */
- FillCRect(&bounds, pixpat);
- if (portChanged) {
- QDSwapPort(savePort, NULL);
- }
- pixmap = GetPortPixMap(patGWorld);
- rowbytes = GetPixRowBytes(pixmap);
- provider = CGDataProviderCreateWithData(&patGWorld,
- GetPixBaseAddr(pixmap), rowbytes * patDim, NULL);
- rgbCspace = CGColorSpaceCreateDeviceRGB();
- img = CGImageCreate(patDim, patDim, 8, 32,
- rowbytes, rgbCspace, kCGImageAlphaFirst | bitmapInfo,
- provider, NULL, 0, kCGRenderingIntentDefault);
- CGColorSpaceRelease(rgbCspace);
- CGDataProviderRelease(provider);
- if (img) {
- CGPatternRef pat = CGPatternCreateWithImage(img, 2);
- CGColorSpaceRef patCSpace = CGColorSpaceCreatePattern(NULL);
- const float alpha = 1;
-
- CGContextSetFillColorSpace(context, patCSpace);
- CGContextSetFillPattern(context, pat, &alpha);
- CGContextSetStrokeColorSpace(context, patCSpace);
- CGContextSetStrokePattern(context, pat, &alpha);
- CGColorSpaceRelease(patCSpace);
- CGPatternRelease(pat);
- CGImageRelease(img);
- return;
- }
- }
-#endif /* MAC_OS_X_VERSION_MIN_REQUIRED < 1040 */
- err = ChkErr(GetThemeColor, pixel, brush, textColor, background, &c);
+ err = ChkErr(GetThemeColor, pixel, brush, textColor, background,
+ &cgColor);
if (err == noErr) {
- double r = c.red / 65535.0;
- double g = c.green / 65535.0;
- double b = c.blue / 65535.0;
-
- CGContextSetRGBFillColor(context, r, g, b, 1.0);
- CGContextSetRGBStrokeColor(context, r, g, b, 1.0);
+ SetCachedColor(gc, pixel, cgColor);
}
- } else if (((pixel >> 24) & 0xff) == TRANSPARENT_PIXEL) {
- CGContextSetRGBFillColor(context, 0.0, 0.0, 0.0, 0.0);
- CGContextSetRGBStrokeColor(context, 0.0, 0.0, 0.0, 0.0);
- } else {
+ } else if (!cgColor) {
TkMacOSXDbgMsg("Ignored unknown pixel value 0x%lx", pixel);
}
+ if (cgColor) {
+ CGContextSetFillColorWithColor(context, cgColor);
+ CGContextSetStrokeColorWithColor(context, cgColor);
+ CGColorRelease(cgColor);
+ }
}
/*
@@ -553,8 +558,8 @@ TkpGetColor(
Tk_Uid name) /* Name of color to allocated (in form
* suitable for passing to XParseColor). */
{
- Display *display = Tk_Display(tkwin);
- Colormap colormap = Tk_Colormap(tkwin);
+ Display *display = tkwin != None ? Tk_Display(tkwin) : NULL;
+ Colormap colormap = tkwin!= None ? Tk_Colormap(tkwin) : None;
TkColor *tkColPtr;
XColor color;
@@ -571,7 +576,7 @@ TkpGetColor(
Tcl_DecrRefCount(strPtr);
if (result == TCL_OK) {
OSStatus err;
- RGBColor c;
+ CGColorRef c;
unsigned char pixelCode = idx + MIN_PIXELCODE;
ThemeBrush brush = systemColorMap[idx].brush;
ThemeTextColor textColor = systemColorMap[idx].textColor;
@@ -579,15 +584,29 @@ TkpGetColor(
err = ChkErr(GetThemeColor, 0, brush, textColor, background, &c);
if (err == noErr) {
- color.red = c.red;
- color.green = c.green;
- color.blue = c.blue;
+ const size_t n = CGColorGetNumberOfComponents(c);
+ const CGFloat *rgba = CGColorGetComponents(c);
+
+ switch (n) {
+ case 4:
+ color.red = rgba[0] * 65535.0;
+ color.green = rgba[1] * 65535.0;
+ color.blue = rgba[2] * 65535.0;
+ break;
+ case 2:
+ color.red = color.green = color.blue = rgba[0] * 65535.0;
+ break;
+ default:
+ Tcl_Panic("CGColor with %d components", n);
+ }
color.pixel = ((((((pixelCode << 8)
| ((color.red >> 8) & 0xff)) << 8)
| ((color.green >> 8) & 0xff)) << 8)
| ((color.blue >> 8) & 0xff));
+ CGColorRelease(c);
goto validXColor;
}
+ CGColorRelease(c);
}
}
@@ -639,37 +658,6 @@ TkpGetColorByValue(
return tkColPtr;
}
-#if !TK_DRAW_IN_CONTEXT
-/*
- *----------------------------------------------------------------------
- *
- * TkMacOSXCompareColors --
- *
- * On Mac, color codes may specify symbolic values like "highlight
- * foreground", but we really need the actual values to compare.
- * Maybe see also: "TIP #154: Add Named Colors to Tk".
- *
- * Results:
- * Returns true if both colors are the same, false otherwise.
- *
- * Side effects:
- * None.
- *
- *----------------------------------------------------------------------
- */
-
-int
-TkMacOSXCompareColors(
- unsigned long c1,
- unsigned long c2)
-{
- RGBColor col1, col2;
- return TkSetMacColor(c1,&col1) &&
- TkSetMacColor(c1,&col2) &&
- !memcmp(&col1,&col2,sizeof(col1));
-}
-#endif /* !TK_DRAW_IN_CONTEXT */
-
/*
*----------------------------------------------------------------------
*
@@ -736,3 +724,12 @@ XFreeColors(
*/
return Success;
}
+
+/*
+ * Local Variables:
+ * mode: c
+ * c-basic-offset: 4
+ * fill-column: 79
+ * coding: utf-8
+ * End:
+ */
diff --git a/macosx/tkMacOSXConfig.c b/macosx/tkMacOSXConfig.c
index 4c803f0..bd2ca44 100644
--- a/macosx/tkMacOSXConfig.c
+++ b/macosx/tkMacOSXConfig.c
@@ -5,10 +5,12 @@
* the configuration package.
*
* Copyright (c) 1997 by Sun Microsystems, Inc.
- * Copyright 2001, Apple Computer, Inc.
+ * Copyright 2001, Apple Inc.
*
* See the file "license.terms" for information on usage and redistribution
* of this file, and for a DISCLAIMER OF ALL WARRANTIES.
+ *
+ * RCS: @(#) $Id$
*/
#include "tkInt.h"
diff --git a/macosx/tkMacOSXCursor.c b/macosx/tkMacOSXCursor.c
index 4c5b332..aac8414 100644
--- a/macosx/tkMacOSXCursor.c
+++ b/macosx/tkMacOSXCursor.c
@@ -4,26 +4,30 @@
* This file contains Macintosh specific cursor related routines.
*
* Copyright (c) 1995-1997 Sun Microsystems, Inc.
- * Copyright 2001, Apple Computer, Inc.
- * Copyright (c) 2006-2007 Daniel A. Steffen <das@users.sourceforge.net>
+ * Copyright 2001-2009, Apple Inc.
+ * Copyright (c) 2006-2009 Daniel A. Steffen <das@users.sourceforge.net>
*
- * See the file "license.terms" for information on usage and redistribution of
- * this file, and for a DISCLAIMER OF ALL WARRANTIES.
+ * See the file "license.terms" for information on usage and redistribution
+ * of this file, and for a DISCLAIMER OF ALL WARRANTIES.
+ *
+ * RCS: @(#) $Id$
*/
#include "tkMacOSXPrivate.h"
+#include "tkMacOSXCursors.h"
+#include "tkMacOSXXCursors.h"
/*
- * There are three different ways to set the cursor on the Mac. The default
- * theme cursors (listed in cursorNames below), color resource cursors, &
- * normal cursors.
+ * Mac Cursor Types.
*/
#define NONE -1 /* Hidden cursor */
-#define THEME 0 /* Theme cursors */
-#define ANIMATED 1 /* Animated theme cursors */
-#define COLOR 2 /* Cursors of type crsr. */
-#define NORMAL 3 /* Cursors of type CURS. */
+#define SELECTOR 1 /* NSCursor class method */
+#define IMAGENAMED 2 /* Named NSImage */
+#define IMAGEPATH 3 /* Path to NSImage */
+#define IMAGEBITMAP 4 /* Pointer to 16x16 cursor bitmap data */
+
+#define pix 16 /* Pixel width & height of cursor bitmap data */
/*
* The following data structure contains the system specific data necessary to
@@ -32,60 +36,151 @@
typedef struct {
TkCursor info; /* Generic cursor info used by tkCursor.c */
- Handle macCursor; /* Resource containing Macintosh cursor. For
- * theme cursors, this is -1. */
- int type; /* Type of Mac cursor: for theme cursors this
- * is the theme cursor constant, otherwise one
- * of crsr or CURS. */
- int count; /* For animating cursors, the count for the
- * cursor. */
+ NSCursor *macCursor; /* Macintosh cursor */
+ int type; /* Type of Mac cursor */
} TkMacOSXCursor;
/*
* The table below is used to map from the name of a predefined cursor
- * to its resource identifier.
+ * to a NSCursor.
*/
struct CursorName {
const char *name;
- int id;
+ const int kind;
+ id id1, id2;
+ NSPoint hotspot;
};
-static struct CursorName noneCursorName = {"none", 0};
-
-static struct CursorName themeCursorNames[] = {
- {"arrow", kThemeArrowCursor},
- {"copyarrow", kThemeCopyArrowCursor},
- {"aliasarrow", kThemeAliasArrowCursor},
- {"contextualmenuarrow", kThemeContextualMenuArrowCursor},
- {"ibeam", kThemeIBeamCursor},
- {"text", kThemeIBeamCursor},
- {"xterm", kThemeIBeamCursor},
- {"cross", kThemeCrossCursor},
- {"crosshair", kThemeCrossCursor},
- {"cross-hair", kThemeCrossCursor},
- {"plus", kThemePlusCursor},
- {"closedhand", kThemeClosedHandCursor},
- {"openhand", kThemeOpenHandCursor},
- {"pointinghand", kThemePointingHandCursor},
- {"resizeleft", kThemeResizeLeftCursor},
- {"resizeright", kThemeResizeRightCursor},
- {"resizeleftright", kThemeResizeLeftRightCursor},
- {"resizeup", kThemeResizeUpCursor},
- {"resizedown", kThemeResizeDownCursor},
- {"resizeupdown", kThemeResizeUpDownCursor},
- {"notallowed", kThemeNotAllowedCursor},
- {"poof", kThemePoofCursor},
- {NULL, 0}
-};
-
-static struct CursorName animatedThemeCursorNames[] = {
- {"watch", kThemeWatchCursor},
- {"countinguphand", kThemeCountingUpHandCursor},
- {"countingdownhand", kThemeCountingDownHandCursor},
- {"countingupanddownhand", kThemeCountingUpAndDownHandCursor},
- {"spinning", kThemeSpinningCursor},
- {NULL, 0}
+#define MacCursorData(n) ((id)tkMacOSXCursors[TK_MAC_CURSOR_##n])
+#define MacXCursorData(n) ((id)tkMacOSXXCursors[TK_MAC_XCURSOR_##n])
+
+static const struct CursorName cursorNames[] = {
+ {"none", NONE, nil},
+ {"arrow", SELECTOR, @"arrowCursor"},
+ {"top_left_arrow", SELECTOR, @"arrowCursor"},
+ {"left_ptr", SELECTOR, @"arrowCursor"},
+ {"copyarrow", SELECTOR, @"dragCopyCursor", @"_copyDragCursor"},
+ {"aliasarrow", SELECTOR, @"dragLinkCursor", @"_linkDragCursor"},
+ {"contextualmenuarrow", SELECTOR, @"contextualMenuCursor"},
+ {"movearrow", SELECTOR, @"_moveCursor"},
+ {"ibeam", SELECTOR, @"IBeamCursor"},
+ {"text", SELECTOR, @"IBeamCursor"},
+ {"xterm", SELECTOR, @"IBeamCursor"},
+ {"cross", SELECTOR, @"crosshairCursor"},
+ {"crosshair", SELECTOR, @"crosshairCursor"},
+ {"cross-hair", SELECTOR, @"crosshairCursor"},
+ {"tcross", SELECTOR, @"crosshairCursor"},
+ {"hand", SELECTOR, @"openHandCursor"},
+ {"openhand", SELECTOR, @"openHandCursor"},
+ {"closedhand", SELECTOR, @"closedHandCursor"},
+ {"fist", SELECTOR, @"closedHandCursor"},
+ {"pointinghand", SELECTOR, @"pointingHandCursor"},
+ {"resize", SELECTOR, @"arrowCursor"},
+ {"resizeleft", SELECTOR, @"resizeLeftCursor"},
+ {"resizeright", SELECTOR, @"resizeRightCursor"},
+ {"resizeleftright", SELECTOR, @"resizeLeftRightCursor"},
+ {"resizeup", SELECTOR, @"resizeUpCursor"},
+ {"resizedown", SELECTOR, @"resizeDownCursor"},
+ {"resizeupdown", SELECTOR, @"resizeUpDownCursor"},
+ {"resizebottomleft", SELECTOR, @"_bottomLeftResizeCursor"},
+ {"resizetopleft", SELECTOR, @"_topLeftResizeCursor"},
+ {"resizebottomright", SELECTOR, @"_bottomRightResizeCursor"},
+ {"resizetopright", SELECTOR, @"_topRightResizeCursor"},
+ {"notallowed", SELECTOR, @"operationNotAllowedCursor"},
+ {"poof", SELECTOR, @"disappearingItemCursor"},
+ {"wait", SELECTOR, @"busyButClickableCursor"},
+ {"spinning", SELECTOR, @"busyButClickableCursor"},
+ {"countinguphand", SELECTOR, @"busyButClickableCursor"},
+ {"countingdownhand", SELECTOR, @"busyButClickableCursor"},
+ {"countingupanddownhand", SELECTOR, @"busyButClickableCursor"},
+ {"help", IMAGENAMED, @"NSHelpCursor", nil, {8, 8}},
+// {"hand", IMAGEBITMAP, MacCursorData(hand)},
+ {"bucket", IMAGEBITMAP, MacCursorData(bucket)},
+ {"cancel", IMAGEBITMAP, MacCursorData(cancel)},
+// {"resize", IMAGEBITMAP, MacCursorData(resize)},
+ {"eyedrop", IMAGEBITMAP, MacCursorData(eyedrop)},
+ {"eyedrop-full", IMAGEBITMAP, MacCursorData(eyedrop_full)},
+ {"zoom-in", IMAGEBITMAP, MacCursorData(zoom_in)},
+ {"zoom-out", IMAGEBITMAP, MacCursorData(zoom_out)},
+ {"X_cursor", IMAGEBITMAP, MacXCursorData(X_cursor)},
+// {"arrow", IMAGEBITMAP, MacXCursorData(arrow)},
+ {"based_arrow_down", IMAGEBITMAP, MacXCursorData(based_arrow_down)},
+ {"based_arrow_up", IMAGEBITMAP, MacXCursorData(based_arrow_up)},
+ {"boat", IMAGEBITMAP, MacXCursorData(boat)},
+ {"bogosity", IMAGEBITMAP, MacXCursorData(bogosity)},
+ {"bottom_left_corner", IMAGEBITMAP, MacXCursorData(bottom_left_corner)},
+ {"bottom_right_corner", IMAGEBITMAP, MacXCursorData(bottom_right_corner)},
+ {"bottom_side", IMAGEBITMAP, MacXCursorData(bottom_side)},
+ {"bottom_tee", IMAGEBITMAP, MacXCursorData(bottom_tee)},
+ {"box_spiral", IMAGEBITMAP, MacXCursorData(box_spiral)},
+ {"center_ptr", IMAGEBITMAP, MacXCursorData(center_ptr)},
+ {"circle", IMAGEBITMAP, MacXCursorData(circle)},
+ {"clock", IMAGEBITMAP, MacXCursorData(clock)},
+ {"coffee_mug", IMAGEBITMAP, MacXCursorData(coffee_mug)},
+// {"cross", IMAGEBITMAP, MacXCursorData(cross)},
+ {"cross_reverse", IMAGEBITMAP, MacXCursorData(cross_reverse)},
+// {"crosshair", IMAGEBITMAP, MacXCursorData(crosshair)},
+ {"diamond_cross", IMAGEBITMAP, MacXCursorData(diamond_cross)},
+ {"dot", IMAGEBITMAP, MacXCursorData(dot)},
+ {"dotbox", IMAGEBITMAP, MacXCursorData(dotbox)},
+ {"double_arrow", IMAGEBITMAP, MacXCursorData(double_arrow)},
+ {"draft_large", IMAGEBITMAP, MacXCursorData(draft_large)},
+ {"draft_small", IMAGEBITMAP, MacXCursorData(draft_small)},
+ {"draped_box", IMAGEBITMAP, MacXCursorData(draped_box)},
+ {"exchange", IMAGEBITMAP, MacXCursorData(exchange)},
+ {"fleur", IMAGEBITMAP, MacXCursorData(fleur)},
+ {"gobbler", IMAGEBITMAP, MacXCursorData(gobbler)},
+ {"gumby", IMAGEBITMAP, MacXCursorData(gumby)},
+ {"hand1", IMAGEBITMAP, MacXCursorData(hand1)},
+ {"hand2", IMAGEBITMAP, MacXCursorData(hand2)},
+ {"heart", IMAGEBITMAP, MacXCursorData(heart)},
+ {"icon", IMAGEBITMAP, MacXCursorData(icon)},
+ {"iron_cross", IMAGEBITMAP, MacXCursorData(iron_cross)},
+// {"left_ptr", IMAGEBITMAP, MacXCursorData(left_ptr)},
+ {"left_side", IMAGEBITMAP, MacXCursorData(left_side)},
+ {"left_tee", IMAGEBITMAP, MacXCursorData(left_tee)},
+ {"leftbutton", IMAGEBITMAP, MacXCursorData(leftbutton)},
+ {"ll_angle", IMAGEBITMAP, MacXCursorData(ll_angle)},
+ {"lr_angle", IMAGEBITMAP, MacXCursorData(lr_angle)},
+ {"man", IMAGEBITMAP, MacXCursorData(man)},
+ {"middlebutton", IMAGEBITMAP, MacXCursorData(middlebutton)},
+ {"mouse", IMAGEBITMAP, MacXCursorData(mouse)},
+ {"pencil", IMAGEBITMAP, MacXCursorData(pencil)},
+ {"pirate", IMAGEBITMAP, MacXCursorData(pirate)},
+ {"plus", IMAGEBITMAP, MacXCursorData(plus)},
+ {"question_arrow", IMAGEBITMAP, MacXCursorData(question_arrow)},
+ {"right_ptr", IMAGEBITMAP, MacXCursorData(right_ptr)},
+ {"right_side", IMAGEBITMAP, MacXCursorData(right_side)},
+ {"right_tee", IMAGEBITMAP, MacXCursorData(right_tee)},
+ {"rightbutton", IMAGEBITMAP, MacXCursorData(rightbutton)},
+ {"rtl_logo", IMAGEBITMAP, MacXCursorData(rtl_logo)},
+ {"sailboat", IMAGEBITMAP, MacXCursorData(sailboat)},
+ {"sb_down_arrow", IMAGEBITMAP, MacXCursorData(sb_down_arrow)},
+ {"sb_h_double_arrow", IMAGEBITMAP, MacXCursorData(sb_h_double_arrow)},
+ {"sb_left_arrow", IMAGEBITMAP, MacXCursorData(sb_left_arrow)},
+ {"sb_right_arrow", IMAGEBITMAP, MacXCursorData(sb_right_arrow)},
+ {"sb_up_arrow", IMAGEBITMAP, MacXCursorData(sb_up_arrow)},
+ {"sb_v_double_arrow", IMAGEBITMAP, MacXCursorData(sb_v_double_arrow)},
+ {"shuttle", IMAGEBITMAP, MacXCursorData(shuttle)},
+ {"sizing", IMAGEBITMAP, MacXCursorData(sizing)},
+ {"spider", IMAGEBITMAP, MacXCursorData(spider)},
+ {"spraycan", IMAGEBITMAP, MacXCursorData(spraycan)},
+ {"star", IMAGEBITMAP, MacXCursorData(star)},
+ {"target", IMAGEBITMAP, MacXCursorData(target)},
+// {"tcross", IMAGEBITMAP, MacXCursorData(tcross)},
+// {"top_left_arrow", IMAGEBITMAP, MacXCursorData(top_left_arrow)},
+ {"top_left_corner", IMAGEBITMAP, MacXCursorData(top_left_corner)},
+ {"top_right_corner", IMAGEBITMAP, MacXCursorData(top_right_corner)},
+ {"top_side", IMAGEBITMAP, MacXCursorData(top_side)},
+ {"top_tee", IMAGEBITMAP, MacXCursorData(top_tee)},
+ {"trek", IMAGEBITMAP, MacXCursorData(trek)},
+ {"ul_angle", IMAGEBITMAP, MacXCursorData(ul_angle)},
+ {"umbrella", IMAGEBITMAP, MacXCursorData(umbrella)},
+ {"ur_angle", IMAGEBITMAP, MacXCursorData(ur_angle)},
+ {"watch", IMAGEBITMAP, MacXCursorData(watch)},
+// {"xterm", IMAGEBITMAP, MacXCursorData(xterm)},
+ {NULL}
};
/*
@@ -116,9 +211,8 @@ static void FindCursorByName(TkMacOSXCursor *macCursorPtr, const char *string);
* FindCursorByName --
*
* Retrieve a system cursor by name, and fill the macCursorPtr
- * structure. If the cursor cannot be found, the macCursor field will be
- * NULL. The function first attempts to load a color cursor. If that
- * fails it will attempt to load a black & white cursor.
+ * structure. If the cursor cannot be found, the macCursor field
+ * will be nil.
*
* Results:
* Fills the macCursorPtr record.
@@ -132,41 +226,127 @@ static void FindCursorByName(TkMacOSXCursor *macCursorPtr, const char *string);
void
FindCursorByName(
TkMacOSXCursor *macCursorPtr,
- const char *string)
+ const char *name)
{
- Handle resource;
- Str255 curName;
- int destWrote, inCurLen;
- Tcl_Encoding encoding;
+ NSString *path = nil;
+ NSImage *image = nil;
+ NSPoint hotSpot = NSZeroPoint;
+ int haveHotSpot = 0, result = TCL_ERROR;
+ NSCursor *macCursor = nil;
- inCurLen = strlen(string);
- if (inCurLen > 255) {
- return;
- }
-
- /*
- * macRoman is the encoding that the resource fork uses.
- */
+ if (name[0] == '@') {
+ /*
+ * System cursor of type @filename
+ */
- encoding = Tcl_GetEncoding(NULL, "macRoman");
- Tcl_UtfToExternal(NULL, encoding, string, inCurLen, 0, NULL,
- (char *) &curName[1], 255, NULL, &destWrote, NULL);
- curName[0] = destWrote;
- Tcl_FreeEncoding(encoding);
-
- resource = GetNamedResource('crsr', curName);
- if (resource) {
- short id;
- Str255 theName;
- ResType theType;
-
- GetResInfo(resource, &id, &theType, theName);
- macCursorPtr->macCursor = (Handle) GetCCursor(id);
- macCursorPtr->type = COLOR;
+ macCursorPtr->type = IMAGEPATH;
+ path = [NSString stringWithUTF8String:&name[1]];
} else {
- macCursorPtr->macCursor = GetNamedResource('CURS', curName);
- macCursorPtr->type = NORMAL;
+ Tcl_Obj *strPtr = Tcl_NewStringObj(name, -1);
+ int idx;
+
+ result = Tcl_GetIndexFromObjStruct(NULL, strPtr, cursorNames,
+ sizeof(struct CursorName), NULL, TCL_EXACT, &idx);
+ Tcl_DecrRefCount(strPtr);
+ if (result == TCL_OK) {
+ macCursorPtr->type = cursorNames[idx].kind;
+ switch (cursorNames[idx].kind) {
+ case SELECTOR: {
+ SEL selector = NSSelectorFromString(cursorNames[idx].id1);
+ if ([NSCursor respondsToSelector:selector]) {
+ macCursor = [[NSCursor performSelector:selector] retain];
+ } else if (cursorNames[idx].id2) {
+ selector = NSSelectorFromString(cursorNames[idx].id2);
+ if ([NSCursor respondsToSelector:selector]) {
+ macCursor = [[NSCursor performSelector:selector] retain];
+ }
+ }
+ break;
+ }
+ case IMAGENAMED:
+ image = [[NSImage imageNamed:cursorNames[idx].id1] retain];
+ hotSpot = cursorNames[idx].hotspot;
+ haveHotSpot = 1;
+ break;
+ case IMAGEPATH:
+ path = [NSApp tkFrameworkImagePath:cursorNames[idx].id1];
+ break;
+ case IMAGEBITMAP: {
+ unsigned char *bitmap = (unsigned char *)(cursorNames[idx].id1);
+ NSBitmapImageRep *bitmapImageRep = NULL;
+ CGImageRef img = NULL, mask = NULL, maskedImg = NULL;
+ static const CGFloat decodeWB[] = {1, 0};
+ CGColorSpaceRef colorspace = CGColorSpaceCreateWithName(
+ kCGColorSpaceGenericGray);
+ CGDataProviderRef provider = CGDataProviderCreateWithData(NULL,
+ bitmap, pix*pix/8, NULL);
+ if (provider) {
+ img = CGImageCreate(pix, pix, 1, 1, pix/8, colorspace,
+ kCGBitmapByteOrderDefault, provider, decodeWB, 0,
+ kCGRenderingIntentDefault);
+ CFRelease(provider);
+ }
+ provider = CGDataProviderCreateWithData(NULL, bitmap +
+ pix*pix/8, pix*pix/8, NULL);
+ if (provider) {
+ mask = CGImageMaskCreate(pix, pix, 1, 1, pix/8, provider,
+ decodeWB, 0);
+ CFRelease(provider);
+ }
+ if (img && mask) {
+ maskedImg = CGImageCreateWithMask(img, mask);
+ }
+ if (maskedImg) {
+ bitmapImageRep = [[NSBitmapImageRep alloc]
+ initWithCGImage:maskedImg];
+ CFRelease(maskedImg);
+ }
+ if (mask) { CFRelease(mask); }
+ if (img) { CFRelease(img); }
+ if (colorspace) { CFRelease(colorspace); }
+ if (bitmapImageRep) {
+ image = [[NSImage alloc] initWithSize:NSMakeSize(pix, pix)];
+ [image addRepresentation:bitmapImageRep];
+ [bitmapImageRep release];
+ }
+ uint16_t *hotSpotData = (uint16_t*)(bitmap + 2*pix*pix/8);
+ hotSpot.y = CFSwapInt16BigToHost(*hotSpotData++);
+ hotSpot.x = CFSwapInt16BigToHost(*hotSpotData);
+ haveHotSpot = 1;
+ break;
+ }
+ }
+ }
}
+ if (path) {
+ image = [[NSImage alloc] initWithContentsOfFile:path];
+ }
+ if (!image && !macCursor && result != TCL_OK) {
+ macCursorPtr->type = IMAGENAMED;
+ image = [[NSImage imageNamed:[NSString stringWithUTF8String:name]]
+ retain];
+ haveHotSpot = 0;
+ }
+ if (image) {
+ if (!haveHotSpot && [[path pathExtension] isEqualToString:@"cur"]) {
+ NSData *data = [NSData dataWithContentsOfFile:path];
+ if ([data length] > 14) {
+ uint16_t *hotSpotData = (uint16_t*)((char*) [data bytes] + 10);
+ hotSpot.x = CFSwapInt16LittleToHost(*hotSpotData++);
+ hotSpot.y = CFSwapInt16LittleToHost(*hotSpotData);
+ haveHotSpot = 1;
+ }
+ }
+ if (!haveHotSpot) {
+ NSSize size = [image size];
+ hotSpot.x = size.width * 0.5;
+ hotSpot.y = size.height * 0.5;
+ }
+ hotSpot.y = -hotSpot.y;
+ macCursor = [[NSCursor alloc] initWithImage:image hotSpot:hotSpot];
+ [image release];
+ }
+ macCursorPtr->macCursor = TkMacOSXMakeUncollectable(macCursor);
}
/*
@@ -192,81 +372,32 @@ TkGetCursorByName(
Tk_Uid string) /* Description of cursor. See manual entry
* for details on legal syntax. */
{
- struct CursorName *namePtr;
- TkMacOSXCursor *macCursorPtr;
- int count = -1;
-
- macCursorPtr = (TkMacOSXCursor *) ckalloc(sizeof(TkMacOSXCursor));
- macCursorPtr->info.cursor = (Tk_Cursor) macCursorPtr;
+ TkMacOSXCursor *macCursorPtr = NULL;
+ const char **argv = NULL;
+ int argc;
/*
- * To find a cursor we must first determine if it is one of the builtin
- * cursors or the standard arrow cursor. Otherwise, we attempt to load the
- * cursor as a named Mac resource.
+ * All cursor names are valid lists of one element (for
+ * TkX11-compatibility), even unadorned system cursor names.
*/
- if (strcmp(noneCursorName.name, string) == 0) {
- namePtr = &noneCursorName;
- macCursorPtr->type = NONE;
- } else {
- for (namePtr = themeCursorNames; namePtr->name != NULL; namePtr++) {
- if (strcmp(namePtr->name, string) == 0) {
- macCursorPtr->type = THEME;
- break;
- }
- }
- }
-
- if (namePtr->name == NULL) {
- for (namePtr = animatedThemeCursorNames;
- namePtr->name != NULL; namePtr++) {
- int namelen = strlen(namePtr->name);
-
- if (strncmp(namePtr->name, string, namelen) == 0) {
- const char *numPtr = string + namelen;
-
- if (*numPtr) {
- int result = Tcl_GetInt(NULL, numPtr, &count);
-
- if (result != TCL_OK) {
- continue;
- }
- }
- macCursorPtr->type = ANIMATED;
- break;
- }
- }
- }
-
- if (namePtr->name != NULL) {
- macCursorPtr->macCursor = (Handle) namePtr;
- macCursorPtr->count = count;
- } else {
- FindCursorByName(macCursorPtr, string);
-
- if (macCursorPtr->macCursor == NULL) {
- const char **argv;
- int argc;
-
- /*
- * The user may be trying to specify an XCursor with fore & back
- * colors. We don't want this to be an error, so pick off the
- * first word, and try again.
- */
-
- if (Tcl_SplitList(interp, string, &argc, &argv) == TCL_OK ) {
- if (argc > 1) {
- FindCursorByName(macCursorPtr, argv[0]);
- }
- ckfree((char *) argv);
- }
+ if (Tcl_SplitList(interp, string, &argc, &argv) == TCL_OK) {
+ if (argc) {
+ macCursorPtr = (TkMacOSXCursor *) ckalloc(sizeof(TkMacOSXCursor));
+ macCursorPtr->info.cursor = (Tk_Cursor) macCursorPtr;
+ macCursorPtr->macCursor = nil;
+ macCursorPtr->type = 0;
+ FindCursorByName(macCursorPtr, argv[0]);
}
+ ckfree((char *) argv);
}
-
- if (macCursorPtr->macCursor == NULL) {
- ckfree((char *)macCursorPtr);
+ if (!macCursorPtr || (!macCursorPtr->macCursor &&
+ macCursorPtr->type != NONE)) {
Tcl_AppendResult(interp, "bad cursor spec \"", string, "\"", NULL);
- return NULL;
+ if (macCursorPtr) {
+ ckfree((char *)macCursorPtr);
+ macCursorPtr = NULL;
+ }
}
return (TkCursor *) macCursorPtr;
}
@@ -290,8 +421,8 @@ TkGetCursorByName(
TkCursor *
TkCreateCursorFromData(
Tk_Window tkwin, /* Window in which cursor will be used. */
- CONST char *source, /* Bitmap data for cursor shape. */
- CONST char *mask, /* Bitmap data for cursor mask. */
+ const char *source, /* Bitmap data for cursor shape. */
+ const char *mask, /* Bitmap data for cursor mask. */
int width, int height, /* Dimensions of cursor. */
int xHot, int yHot, /* Location of hot-spot in cursor. */
XColor fgColor, /* Foreground color for cursor. */
@@ -323,15 +454,7 @@ TkpFreeCursor(
{
TkMacOSXCursor *macCursorPtr = (TkMacOSXCursor *) cursorPtr;
- switch (macCursorPtr->type) {
- case COLOR:
- DisposeCCursor((CCrsrHandle) macCursorPtr->macCursor);
- break;
- case NORMAL:
- ReleaseResource(macCursorPtr->macCursor);
- break;
- }
-
+ TkMacOSXMakeCollectableAndRelease(macCursorPtr->macCursor);
if (macCursorPtr == gCurrentCursor) {
gCurrentCursor = NULL;
}
@@ -359,59 +482,34 @@ TkMacOSXInstallCursor(
int resizeOverride)
{
TkMacOSXCursor *macCursorPtr = gCurrentCursor;
- CCrsrHandle ccursor;
- CursHandle cursor;
- static unsigned int cursorStep = 0;
static int cursorHidden = 0;
int cursorNone = 0;
gResizeOverride = resizeOverride;
- if (resizeOverride) {
- cursor = (CursHandle) GetNamedResource('CURS', "\presize");
- if (cursor) {
- SetCursor(*cursor);
- } else {
- TkMacOSXDbgMsg("Resize cursor failed: %d", ResError());
- }
- } else if (macCursorPtr == NULL) {
- SetThemeCursor(kThemeArrowCursor);
+ if (resizeOverride || !macCursorPtr) {
+ [[NSCursor arrowCursor] set];
} else {
- struct CursorName *namePtr;
-
switch (macCursorPtr->type) {
case NONE:
if (!cursorHidden) {
cursorHidden = 1;
- HideCursor();
+ [NSCursor hide];
}
cursorNone = 1;
break;
- case THEME:
- namePtr = (struct CursorName *) macCursorPtr->macCursor;
- SetThemeCursor(namePtr->id);
- break;
- case ANIMATED:
- namePtr = (struct CursorName *) macCursorPtr->macCursor;
- if (macCursorPtr->count == -1) {
- SetAnimatedThemeCursor(namePtr->id, cursorStep++);
- } else {
- SetAnimatedThemeCursor(namePtr->id, macCursorPtr->count);
- }
- break;
- case COLOR:
- ccursor = (CCrsrHandle) macCursorPtr->macCursor;
- SetCCursor(ccursor);
- break;
- case NORMAL:
- cursor = (CursHandle) macCursorPtr->macCursor;
- SetCursor(*cursor);
+ case SELECTOR:
+ case IMAGENAMED:
+ case IMAGEPATH:
+ case IMAGEBITMAP:
+ default:
+ [macCursorPtr->macCursor set];
break;
}
}
if (cursorHidden && !cursorNone) {
cursorHidden = 0;
- ShowCursor();
+ [NSCursor unhide];
}
}
@@ -485,3 +583,12 @@ Tk_MacOSXTkOwnsCursor(
{
gTkOwnsCursor = tkOwnsIt;
}
+
+/*
+ * Local Variables:
+ * mode: c
+ * c-basic-offset: 4
+ * fill-column: 79
+ * coding: utf-8
+ * End:
+ */
diff --git a/macosx/tkMacOSXCursors.r b/macosx/tkMacOSXCursors.r
deleted file mode 100644
index f947ddf..0000000
--- a/macosx/tkMacOSXCursors.r
+++ /dev/null
@@ -1,128 +0,0 @@
-/*
- * tkMacOSXCursors.r --
- *
- * This file defines a set of Macintosh cursor resources that
- * are only available on the Macintosh platform.
- *
- * Copyright (c) 1995-1996 Sun Microsystems, Inc.
- *
- * See the file "license.terms" for information on usage and redistribution
- * of this file, and for a DISCLAIMER OF ALL WARRANTIES.
- */
-
-/*
- * These are resource definitions for Macintosh cursors.
- * The are identified and loaded by the "name" of the
- * cursor. However, the ids must be unique.
- */
-
-data 'CURS' (1000, "hand") {
- $"0180 1A70 2648 264A 124D 1249 6809 9801"
- $"8802 4002 2002 2004 1004 0808 0408 0408"
- $"0180 1BF0 3FF8 3FFA 1FFF 1FFF 6FFF FFFF"
- $"FFFE 7FFE 3FFE 3FFC 1FFC 0FF8 07F8 07F8"
- $"0009 0008"
-};
-
-data 'CURS' (1002, "bucket") {
- $"0000 0000 0600 0980 0940 0B30 0D18 090C"
- $"129C 212C 104C 088C 050C 0208 0000 0000"
- $"0000 0000 0600 0980 09C0 0BF0 0FF8 0FFC"
- $"1FFC 3FEC 1FCC 0F8C 070C 0208 0000 0000"
- $"000D 000C"
-};
-
-data 'CURS' (1003, "cancel") {
- $"0000 0000 0000 0000 3180 4A40 4A40 3F80"
- $"0A00 3F80 4A40 4A46 3186 0000 0000 0000"
- $"0000 0000 0000 3180 7BC0 FFE0 FFE0 7FC0"
- $"3F80 7FC0 FFE6 FFEF 7BCF 3186 0000 0000"
- $"0008 0005"
-};
-
-data 'CURS' (1004, "resize") {
- $"FFFF 8001 BF01 A181 A1F9 A18D A18D BF8D"
- $"9F8D 880D 880D 880D 8FFD 87FD 8001 FFFF"
- $"FFFF FFFF FFFF FFFF FFFF FFFF FFFF FFFF"
- $"FFFF FFFF FFFF FFFF FFFF FFFF FFFF FFFF"
- $"0008 0008"
-};
-
-data 'CURS' (1005, "eyedrop") {
- $"000E 001F 001F 00FF 007E 00B8 0118 0228"
- $"0440 0880 1100 2200 4400 4800 B000 4000"
- $"000E 001F 001F 00FF 007E 00F8 01F8 03E8"
- $"07C0 0F80 1F00 3E00 7C00 7800 F000 4000"
- $"000F 0000"
-};
-
-data 'CURS' (1006, "eyedrop-full") {
- $"000E 001F 001F 00FF 007E 00B8 0118 0328"
- $"07C0 0F80 1F00 3E00 7C00 7800 F000 4000"
- $"000E 001F 001F 00FF 007E 00F8 01F8 03E8"
- $"07C0 0F80 1F00 3E00 7C00 7800 F000 4000"
- $"000F 0000"
-};
-
-data 'CURS' (1007, "zoom-in") {
- $"0780 1860 2790 5868 5028 A014 AFD4 AFD4"
- $"A014 5028 5868 2798 187C 078E 0007 0003"
- $"0780 1FE0 3FF0 7878 7038 E01C EFDC EFDC"
- $"E01C 7038 7878 3FF8 1FFC 078E 0007 0003"
- $"0007 0007"
-};
-
-data 'CURS' (1008, "zoom-out") {
- $"0780 1860 2790 5868 5328 A314 AFD4 AFD4"
- $"A314 5328 5868 2798 187C 078E 0007 0003"
- $"0780 1FE0 3FF0 7878 7338 E31C EFDC EFDC"
- $"E31C 7338 7878 3FF8 1FFC 078E 0007 0003"
- $"0007 0007"
-};
-
-/*
- * The following are resource definitions for color
- * cursors on the Macintosh. If a color cursor and
- * a black & white cursor are both defined with the
- * same name preference will be given to the color
- * cursors.
- */
-
-data 'crsr' (1000, "hand") {
- $"8001 0000 0060 0000 0092 0000 0000 0000"
- $"0000 0000 0180 1A70 2648 264A 124D 1249"
- $"6809 9801 8802 4002 2002 2004 1004 0808"
- $"0408 0408 0180 1BF0 3FF8 3FFA 1FFF 1FFF"
- $"6FFF FFFF FFFE 7FFE 3FFE 3FFC 1FFC 0FF8"
- $"07F8 07F8 0008 0008 0000 0000 0000 0000"
- $"0000 0000 8004 0000 0000 0010 0010 0000"
- $"0000 0000 0000 0048 0000 0048 0000 0000"
- $"0002 0001 0002 0000 0000 0000 00D2 0000"
- $"0000 0003 C000 03CD 7F00 0D7D 75C0 0D7D"
- $"75CC 035D 75F7 035D 75D7 3CD5 55D7 D7D5"
- $"5557 D5D5 555C 3555 555C 0D55 555C 0D55"
- $"5570 0355 5570 00D5 55C0 0035 55C0 0035"
- $"55C0 0000 0000 0000 0002 0000 FFFF FFFF"
- $"FFFF 0001 FFFF CCCC 9999 0003 0000 0000"
- $"0000"
-};
-
-data 'crsr' (1001, "fist") {
- $"8001 0000 0060 0000 0092 0000 0000 0000"
- $"0000 0000 0000 0000 0000 0000 0DB0 124C"
- $"100A 0802 1802 2002 2002 2004 1004 0808"
- $"0408 0408 0000 0000 0000 0000 0DB0 1FFC"
- $"1FFE 0FFE 1FFE 3FFE 3FFE 3FFC 1FFC 0FF8"
- $"07F8 07F8 0008 0008 0000 0000 0000 0000"
- $"0000 0000 8004 0000 0000 0010 0010 0000"
- $"0000 0000 0000 0048 0000 0048 0000 0000"
- $"0002 0001 0002 0000 0000 0000 00D2 0000"
- $"0000 0000 0000 0000 0000 0000 0000 0000"
- $"0000 00F3 CF00 035D 75F0 0355 55DC 00D5"
- $"555C 03D5 555C 0D55 555C 0D55 555C 0D55"
- $"5570 0355 5570 00D5 55C0 0035 55C0 0035"
- $"55C0 0000 0000 0000 0002 0000 FFFF FFFF"
- $"FFFF 0001 FFFF CCCC 9999 0003 0000 0000"
- $"0000"
-};
-
diff --git a/macosx/tkMacOSXDebug.c b/macosx/tkMacOSXDebug.c
index 9d1ebf6..1004353 100644
--- a/macosx/tkMacOSXDebug.c
+++ b/macosx/tkMacOSXDebug.c
@@ -1,58 +1,16 @@
/*
* tkMacOSXDebug.c --
*
- * Implementation of Macintosh specific functions for debugging MacOS events,
- * regions, etc...
+ * Implementation of Macintosh specific functions for debugging MacOS
+ * events, regions, etc...
*
- * Copyright 2001, Apple Computer, Inc.
- * Copyright (c) 2006-2007 Daniel A. Steffen <das@users.sourceforge.net>
+ * Copyright 2001-2009, Apple Inc.
+ * Copyright (c) 2006-2009 Daniel A. Steffen <das@users.sourceforge.net>
*
- * See the file "license.terms" for information on usage and redistribution of
- * this file, and for a DISCLAIMER OF ALL WARRANTIES.
+ * See the file "license.terms" for information on usage and redistribution
+ * of this file, and for a DISCLAIMER OF ALL WARRANTIES.
*
- * The following terms apply to all files originating from Apple
- * Computer, Inc. ("Apple") and associated with the software
- * unless explicitly disclaimed in individual files.
- *
- *
- * Apple hereby grants permission to use, copy, modify,
- * distribute, and license this software and its documentation
- * for any purpose, provided that existing copyright notices are
- * retained in all copies and that this notice is included
- * verbatim in any distributions. No written agreement, license,
- * or royalty fee is required for any of the authorized
- * uses. Modifications to this software may be copyrighted by
- * their authors and need not follow the licensing terms
- * described here, provided that the new terms are clearly
- * indicated on the first page of each file where they apply.
- *
- *
- * IN NO EVENT SHALL APPLE, THE AUTHORS OR DISTRIBUTORS OF THE
- * SOFTWARE BE LIABLE TO ANY PARTY FOR DIRECT, INDIRECT, SPECIAL,
- * INCIDENTAL, OR CONSEQUENTIAL DAMAGES ARISING OUT OF THE USE OF
- * THIS SOFTWARE, ITS DOCUMENTATION, OR ANY DERIVATIVES THEREOF,
- * EVEN IF APPLE OR THE AUTHORS HAVE BEEN ADVISED OF THE
- * POSSIBILITY OF SUCH DAMAGE. APPLE, THE AUTHORS AND
- * DISTRIBUTORS SPECIFICALLY DISCLAIM ANY WARRANTIES, INCLUDING,
- * BUT NOT LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY,
- * FITNESS FOR A PARTICULAR PURPOSE, AND NON-INFRINGEMENT. THIS
- * SOFTWARE IS PROVIDED ON AN "AS IS" BASIS, AND APPLE,THE
- * AUTHORS AND DISTRIBUTORS HAVE NO OBLIGATION TO PROVIDE
- * MAINTENANCE, SUPPORT, UPDATES, ENHANCEMENTS, OR MODIFICATIONS.
- *
- * GOVERNMENT USE: If you are acquiring this software on behalf
- * of the U.S. government, the Government shall have only
- * "Restricted Rights" in the software and related documentation
- * as defined in the Federal Acquisition Regulations (FARs) in
- * Clause 52.227.19 (c) (2). If you are acquiring the software
- * on behalf of the Department of Defense, the software shall be
- * classified as "Commercial Computer Software" and the
- * Government shall have only "Restricted Rights" as defined in
- * Clause 252.227-7013 (c) (1) of DFARs. Notwithstanding the
- * foregoing, the authors grant the U.S. Government and others
- * acting in its behalf permission to use and distribute the
- * software in accordance with the terms specified in this
- * license.
+ * RCS: @(#) $Id$
*/
#include "tkMacOSXPrivate.h"
@@ -60,423 +18,6 @@
#ifdef TK_MAC_DEBUG
-typedef struct {
- EventKind kind;
- const char * name;
-} MyEventName;
-
-typedef struct {
- EventClass c;
- MyEventName * names;
-} MyEventNameList;
-
-static MyEventName windowEventNames [] = {
- { kEventWindowUpdate,"Update"},
- { kEventWindowDrawContent,"DrawContent"},
- { kEventWindowActivated,"Activated"},
- { kEventWindowDeactivated,"Deactivated"},
- { kEventWindowGetClickActivation,"GetClickActivation"},
- { kEventWindowShowing,"Showing"},
- { kEventWindowHiding,"Hiding"},
- { kEventWindowShown,"Shown"},
- { kEventWindowHidden,"Hidden"},
- { kEventWindowBoundsChanging,"BoundsChanging"},
- { kEventWindowBoundsChanged,"BoundsChanged"},
- { kEventWindowResizeStarted,"ResizeStarted"},
- { kEventWindowResizeCompleted,"ResizeCompleted"},
- { kEventWindowDragStarted,"DragStarted"},
- { kEventWindowDragCompleted,"DragCompleted"},
- { kEventWindowClickDragRgn,"ClickDragRgn"},
- { kEventWindowClickResizeRgn,"ClickResizeRgn"},
- { kEventWindowClickCollapseRgn,"ClickCollapseRgn"},
- { kEventWindowClickCloseRgn,"ClickCloseRgn"},
- { kEventWindowClickZoomRgn,"ClickZoomRgn"},
- { kEventWindowClickContentRgn,"ClickContentRgn"},
- { kEventWindowClickProxyIconRgn,"ClickProxyIconRgn"},
- { kEventWindowCursorChange,"CursorChange" },
- { kEventWindowCollapse,"Collapse"},
- { kEventWindowCollapsed,"Collapsed"},
- { kEventWindowCollapseAll,"CollapseAll"},
- { kEventWindowExpand,"Expand"},
- { kEventWindowExpanded,"Expanded"},
- { kEventWindowExpandAll,"ExpandAll"},
- { kEventWindowCollapse,"Collapse"},
- { kEventWindowClose,"Close"},
- { kEventWindowClosed,"Closed"},
- { kEventWindowCloseAll,"CloseAll"},
- { kEventWindowZoom,"Zoom"},
- { kEventWindowZoomed,"Zoomed"},
- { kEventWindowZoomAll,"ZoomAll"},
- { kEventWindowContextualMenuSelect,"ContextualMenuSelect"},
- { kEventWindowPathSelect,"PathSelect"},
- { kEventWindowGetIdealSize,"GetIdealSize"},
- { kEventWindowGetMinimumSize,"GetMinimumSize"},
- { kEventWindowGetMaximumSize,"GetMaximumSize"},
- { kEventWindowConstrain,"Constrain"},
- { kEventWindowHandleContentClick,"HandleContentClick"},
- { kEventWindowProxyBeginDrag,"ProxyBeginDra}"},
- { kEventWindowProxyEndDrag,"ProxyEndDrag"},
- { kEventWindowFocusAcquired,"FocusAcquired"},
- { kEventWindowFocusRelinquish,"FocusRelinquish"},
- { kEventWindowDrawFrame,"DrawFrame"},
- { kEventWindowDrawPart,"DrawPart"},
- { kEventWindowGetRegion,"GetRegion"},
- { kEventWindowHitTest,"HitTest"},
- { kEventWindowInit,"Init"},
- { kEventWindowDispose,"Dispose"},
- { kEventWindowDragHilite,"DragHilite"},
- { kEventWindowModified,"Modified"},
- { kEventWindowSetupProxyDragImage,"SetupProxyDragImage"},
- { kEventWindowStateChanged,"StateChanged"},
- { kEventWindowMeasureTitle,"MeasureTitle"},
- { kEventWindowDrawGrowBox,"DrawGrowBox"},
- { kEventWindowGetGrowImageRegion,"GetGrowImageRegion"},
- { kEventWindowPaint,"Paint"},
- { 0, NULL },
-};
-
-static MyEventName mouseEventNames [] = {
- { kEventMouseMoved, "Moved"},
- { kEventMouseUp, "Up"},
- { kEventMouseDown, "Down"},
- { kEventMouseDragged, "Dragged"},
- { kEventMouseWheelMoved, "WheelMoved"},
- { 0, NULL}
-};
-
-static MyEventName keyboardEventNames [] = {
- { kEventRawKeyDown, "Down"},
- { kEventRawKeyRepeat, "Repeat"},
- { kEventRawKeyUp, "Up"},
- { kEventRawKeyModifiersChanged, "ModifiersChanged"},
- { kEventHotKeyPressed, "HotKeyPressed"},
- { kEventHotKeyReleased, "HotKeyReleased"},
- { 0, NULL}
-};
-
-static MyEventName appEventNames [] = {
- { kEventAppActivated, "Activated"},
- { kEventAppDeactivated, "Deactivated"},
- { kEventAppQuit, "Quit"},
- { kEventAppLaunchNotification, "LaunchNotification"},
- { kEventAppLaunched, "Launched"},
- { kEventAppTerminated, "Terminated"},
- { kEventAppFrontSwitched, "FrontSwitched"},
- { 0, NULL}
-};
-
-static MyEventName menuEventNames [] = {
- { kEventMenuBeginTracking, "BeginTracking"},
- { kEventMenuEndTracking, "EndTracking"},
- { kEventMenuChangeTrackingMode, "ChangeTrackingMode"},
- { kEventMenuOpening, "Opening"},
- { kEventMenuClosed, "Closed"},
- { kEventMenuTargetItem, "TargetItem"},
- { kEventMenuMatchKey, "MatchKey"},
- { kEventMenuEnableItems, "EnableItems"},
- { kEventMenuDispose, "Dispose"},
- { 0, NULL }
-};
-
-static MyEventName controlEventNames [] = {
- { kEventControlInitialize, "Initialize" },
- { kEventControlDispose, "Dispose" },
- { kEventControlGetOptimalBounds, "GetOptimalBounds" },
- { kEventControlHit, "Hit" },
- { kEventControlSimulateHit, "SimulateHit" },
- { kEventControlHitTest, "HitTest" },
- { kEventControlDraw, "Draw" },
- { kEventControlApplyBackground, "ApplyBackground" },
- { kEventControlApplyTextColor, "ApplyTextColor" },
- { kEventControlSetFocusPart, "SetFocusPart" },
- { kEventControlGetFocusPart, "GetFocusPart" },
- { kEventControlActivate, "Activate" },
- { kEventControlDeactivate, "Deactivate" },
- { kEventControlSetCursor, "SetCursor" },
- { kEventControlContextualMenuClick, "ContextualMenuClick" },
- { kEventControlClick, "Click" },
- { kEventControlTrack, "Track" },
- { kEventControlGetScrollToHereStartPoint, "GetScrollToHereStartPoint" },
- { kEventControlGetIndicatorDragConstraint, "GetIndicatorDragConstraint" },
- { kEventControlIndicatorMoved, "IndicatorMoved" },
- { kEventControlGhostingFinished, "GhostingFinished" },
- { kEventControlGetActionProcPart, "GetActionProcPart" },
- { kEventControlGetPartRegion, "GetPartRegion" },
- { kEventControlGetPartBounds, "GetPartBounds" },
- { kEventControlSetData, "SetData" },
- { kEventControlGetData, "GetData" },
- { kEventControlValueFieldChanged, "ValueFieldChanged" },
- { kEventControlAddedSubControl, "AddedSubControl" },
- { kEventControlRemovingSubControl, "RemovingSubControl" },
- { kEventControlBoundsChanged, "BoundsChanged" },
- { kEventControlOwningWindowChanged, "OwningWindowChanged" },
- { kEventControlArbitraryMessage, "ArbitraryMessage" },
- { 0, NULL }
-};
-
-static MyEventName commandEventNames [] = {
- { kEventCommandProcess, "Process" },
- { kEventCommandUpdateStatus, "UpdateStatus" },
- { 0, NULL }
-};
-
-static MyEventNameList eventNameList [] = {
- { kEventClassWindow, windowEventNames },
- { kEventClassMouse, mouseEventNames },
- { kEventClassKeyboard, keyboardEventNames },
- { kEventClassApplication, appEventNames },
- { kEventClassMenu, menuEventNames },
- { kEventClassControl, controlEventNames },
- { kEventClassCommand, commandEventNames },
- { 0, NULL}
-};
-
-#ifdef TK_MACOSXDEBUG_UNUSED
-static MyEventName classicEventNames [] = {
- { nullEvent,"nullEvent" },
- { mouseDown,"mouseDown" },
- { mouseUp,"mouseUp" },
- { keyDown,"keyDown" },
- { keyUp,"keyUp" },
- { autoKey,"autoKey" },
- { updateEvt,"updateEvt" },
- { diskEvt,"diskEvt" },
- { activateEvt,"activateEvt" },
- { osEvt,"osEvt" },
- { kHighLevelEvent,"kHighLevelEvent" },
- { 0, NULL }
-};
-#endif /* TK_MACOSXDEBUG_UNUSED */
-
-MODULE_SCOPE char *
-TkMacOSXCarbonEventToAscii(EventRef eventRef)
-{
- EventClass eventClass;
- EventKind eventKind;
- MyEventNameList * list = eventNameList;
- MyEventName * names = NULL;
- static char str[256];
- char *buf = str;
- int *iPtr = (int*)str;
- int found = 0;
-
- eventClass = GetEventClass(eventRef);
- eventKind = GetEventKind(eventRef);
-
- *iPtr = eventClass;
- buf[4] = 0;
- strcat(buf, " ");
- buf += strlen(buf);
- while (list->names && (!names) ) {
- if (eventClass == list->c) {
- names = list -> names;
- } else {
- list++;
- }
- }
- while (names && names->name) {
- if (eventKind == names->kind) {
- snprintf(buf, 250, "%-20s", names->name);
- break;
- } else {
- names++;
- }
- }
- if (!found) {
- snprintf(buf, 250, "%-20d", eventKind);
- }
- return str;
-}
-
-#ifdef TK_MACOSXDEBUG_UNUSED
-MODULE_SCOPE char *
-TkMacOSXCarbonEventKindToAscii(EventRef eventRef, char * buf )
-{
- EventClass eventClass;
- EventKind eventKind;
- MyEventNameList * list = eventNameList;
- MyEventName * names = NULL;
- int found = 0;
- eventClass = GetEventClass(eventRef);
- eventKind = GetEventKind(eventRef);
- while (list->names && (!names) ) {
- if (eventClass == list -> c) {
- names = list -> names;
- } else {
- list++;
- }
- }
- if (names) {
- found = 0;
- while ( names->name && !found ) {
- if (eventKind == names->kind) {
- sprintf(buf,"%s",names->name);
- found = 1;
- } else {
- names++;
- }
- }
- }
- if (!found) {
- sprintf ( buf,"%d", eventKind );
- } else {
- sprintf ( buf,"%d", eventKind );
- }
- return buf;
-}
-
-MODULE_SCOPE char *
-TkMacOSXClassicEventToAscii(EventRecord * eventPtr, char * buf )
-{
- MyEventName * names = NULL;
- int found = 0;
- names = classicEventNames;
- while ( names -> name && !found )
- if (eventPtr->what == names->kind) {
- int * iPtr;
- char cBuf[8];
- iPtr=(int *) &cBuf;
- *iPtr = eventPtr->message;
- cBuf[4] = 0;
- sprintf(buf, "%-16s %08x %04x %s", names->name,
- (int) eventPtr->message,
- eventPtr->modifiers,
- cBuf);
- found = 1;
- } else {
- names++;
- }
- if (!found) {
- sprintf(buf,"%-16d %08x %08x, %s",
- eventPtr->what, (int) eventPtr->message,
- eventPtr->modifiers, buf);
- }
- return buf;
-
-}
-
-MODULE_SCOPE void
-TkMacOSXPrintPoint(char * tag, Point * p )
-{
- TkMacOSXDbgMsg("%s %4d %4d", tag,p->h,p->v );
-}
-
-MODULE_SCOPE void
-TkMacOSXPrintRect(char * tag, Rect * r )
-{
- TkMacOSXDbgMsg("%s %4d %4d %4d %4d (%dx%d)",
- tag, r->left, r->top, r->right, r->bottom,
- r->right - r->left + 1, r->bottom - r->top + 1);
-}
-
-MODULE_SCOPE void
-TkMacOSXPrintRegion(char * tag, RgnHandle rgn )
-{
- Rect r;
- GetRegionBounds(rgn,&r);
- TkMacOSXPrintRect(tag,&r);
-}
-
-MODULE_SCOPE void
-TkMacOSXPrintWindowTitle(char * tag, WindowRef window )
-{
- Str255 title;
- GetWTitle(window,title);
- title [title[0] + 1] = 0;
- TkMacOSXDbgMsg("%s %s", tag, title +1 );
-}
-
-typedef struct {
- int msg;
- char * name;
-} MsgName;
-
-static MsgName msgNames [] = {
- { kMenuDrawMsg, "Draw"},
- { kMenuSizeMsg, "Size"},
- { kMenuPopUpMsg, "PopUp"},
- { kMenuCalcItemMsg, "CalcItem" },
- { kMenuThemeSavvyMsg, "ThemeSavvy"},
- { kMenuInitMsg, "Init" },
- { kMenuDisposeMsg, "Dispose" },
- { kMenuFindItemMsg, "FindItem" },
- { kMenuHiliteItemMsg, "HiliteItem" },
- { kMenuDrawItemsMsg, "DrawItems" },
- { -1, NULL }
-};
-
-MODULE_SCOPE char *
-TkMacOSXMenuMessageToAscii(int msg, char * s)
-{
- MsgName * msgNamePtr;
- for (msgNamePtr = msgNames;msgNamePtr->name;) {
- if (msgNamePtr->msg == msg) {
- strcpy(s,msgNamePtr->name);
- return s;
- } else {
- msgNamePtr++;
- }
- }
- sprintf(s,"unknown : %d", msg );
- return s;
-}
-
-static MsgName trackingNames [] = {
- { kMouseTrackingMousePressed , "MousePressed " },
- { kMouseTrackingMouseReleased , "MouseReleased " },
- { kMouseTrackingMouseExited , "MouseExited " },
- { kMouseTrackingMouseEntered , "MouseEntered " },
- { kMouseTrackingMouseMoved , "MouseMoved " },
- { kMouseTrackingKeyModifiersChanged, "KeyModifiersChanged" },
- { kMouseTrackingUserCancelled , "UserCancelled " },
- { kMouseTrackingTimedOut , "TimedOut " },
- { -1, NULL }
-};
-
-MODULE_SCOPE char *
-TkMacOSXMouseTrackingResultToAscii(MouseTrackingResult r, char * buf)
-{
- MsgName * namePtr;
- for (namePtr = trackingNames; namePtr->name; namePtr++) {
- if (namePtr->msg == r) {
- strcpy(buf, namePtr->name);
- return buf;
- }
- }
- sprintf(buf, "Unknown mouse tracking result : %d", r);
- return buf;
-}
-#endif /* TK_MACOSXDEBUG_UNUSED */
-
-MODULE_SCOPE void
-TkMacOSXDebugFlashRegion(
- Drawable d,
- HIShapeRef rgn)
-{
- TkMacOSXInitNamedDebugSymbol(HIToolbox, int, QDDebugFlashRegion,
- CGrafPtr port, RgnHandle region);
- CFShow(rgn);
- if (d && rgn && QDDebugFlashRegion && !HIShapeIsEmpty(rgn)) {
- CGrafPtr port = TkMacOSXGetDrawablePort(d);
-
- if (port) {
- static RgnHandle qdRgn = NULL;
-
- if (!qdRgn) {
- qdRgn = NewRgn();
- }
- ChkErr(HIShapeGetAsQDRgn, rgn, qdRgn);
-
- /*
- * Carbon-internal region flashing SPI (c.f. Technote 2124)
- */
-
- QDDebugFlashRegion(port, qdRgn);
- SetEmptyRgn(qdRgn);
- }
- }
-}
-
#include <mach-o/dyld.h>
#include <mach-o/nlist.h>
@@ -485,19 +26,17 @@ TkMacOSXDebugFlashRegion(
*
* TkMacOSXGetNamedDebugSymbol --
*
+ * Dynamically acquire address of a named symbol from a loaded dynamic
+ * library, so that we can use API that may not be available on all OS
+ * versions. For debugging purposes, if we cannot find the symbol with
+ * the usual dynamic library APIs, we manually walk the symbol table of
+ * the loaded library. This allows access to unexported symbols such as
+ * private_extern internal debugging functions. If module is NULL or the
+ * empty string, search all loaded libraries (could be very expensive and
+ * should be avoided).
*
- * Dynamically acquire address of a named symbol from a loaded
- * dynamic library, so that we can use API that may not be
- * available on all OS versions.
- * For debugging purposes, if we cannot find the symbol with the
- * usual dynamic library APIs, we manually walk the symbol table
- * of the loaded library. This allows access to unexported
- * symbols such as private_extern internal debugging functions.
- * If module is NULL or the empty string, search all loaded
- * libraries (could be very expensive and should be avoided).
- *
- * THIS FUCTION IS ONLY TO BE USED FOR DEBUGGING PURPOSES, IT MAY
- * BREAK UNEXPECTEDLY IN THE FUTURE !
+ * THIS FUCTION IS ONLY TO BE USED FOR DEBUGGING PURPOSES, IT MAY BREAK
+ * UNEXPECTEDLY IN THE FUTURE!
*
* Results:
* Address of given symbol or NULL if unavailable.
@@ -510,10 +49,11 @@ TkMacOSXDebugFlashRegion(
MODULE_SCOPE void *
TkMacOSXGetNamedDebugSymbol(
- const char* module,
- const char* symbol)
+ const char *module,
+ const char *symbol)
{
- void* addr = TkMacOSXGetNamedSymbol(module, symbol);
+ void *addr = TkMacOSXGetNamedSymbol(module, symbol);
+
#ifndef __LP64__
if (!addr) {
const struct mach_header *mh = NULL;
@@ -572,7 +112,7 @@ TkMacOSXGetNamedDebugSymbol(
nsect += ns;
}
} else if (!st && lc->cmd == LC_SYMTAB) {
- st = (struct symtab_command*) lc;
+ st = (struct symtab_command *) lc;
break;
}
lc = (struct load_command *)((char *) lc + lc->cmdsize);
@@ -584,11 +124,14 @@ TkMacOSXGetNamedDebugSymbol(
uint32_t strsize = st->strsize;
int32_t strx;
- /* Offset file positions by difference to actual position
- in memory of last segment before symbol table: */
+ /*
+ * Offset file positions by difference to actual position
+ * in memory of last segment before symbol table:
+ */
+
base = (intptr_t) sg->vmaddr + slide - sg->fileoff;
- strings = (char*)(base + st->stroff);
- sym = (struct nlist*)(base + st->symoff);
+ strings = (char *) (base + st->stroff);
+ sym = (struct nlist *) (base + st->symoff);
m = st->nsyms;
for (j = 0; j < m; j++) {
/* Find symbol with given name in __text section */
@@ -613,5 +156,13 @@ TkMacOSXGetNamedDebugSymbol(
#endif /* __LP64__ */
return addr;
}
-
#endif /* TK_MAC_DEBUG */
+
+/*
+ * Local Variables:
+ * mode: c
+ * c-basic-offset: 4
+ * fill-column: 79
+ * coding: utf-8
+ * End:
+ */
diff --git a/macosx/tkMacOSXDebug.h b/macosx/tkMacOSXDebug.h
index 8dc8109..b61ae1e 100644
--- a/macosx/tkMacOSXDebug.h
+++ b/macosx/tkMacOSXDebug.h
@@ -4,55 +4,13 @@
* Declarations of Macintosh specific functions for debugging MacOS events,
* regions, etc...
*
- * Copyright 2001, Apple Computer, Inc.
- * Copyright (c) 2005-2007 Daniel A. Steffen <das@users.sourceforge.net>
+ * Copyright 2001-2009, Apple Inc.
+ * Copyright (c) 2005-2009 Daniel A. Steffen <das@users.sourceforge.net>
*
- * See the file "license.terms" for information on usage and redistribution of
- * this file, and for a DISCLAIMER OF ALL WARRANTIES.
+ * See the file "license.terms" for information on usage and redistribution
+ * of this file, and for a DISCLAIMER OF ALL WARRANTIES.
*
- * The following terms apply to all files originating from Apple
- * Computer, Inc. ("Apple") and associated with the software
- * unless explicitly disclaimed in individual files.
- *
- *
- * Apple hereby grants permission to use, copy, modify,
- * distribute, and license this software and its documentation
- * for any purpose, provided that existing copyright notices are
- * retained in all copies and that this notice is included
- * verbatim in any distributions. No written agreement, license,
- * or royalty fee is required for any of the authorized
- * uses. Modifications to this software may be copyrighted by
- * their authors and need not follow the licensing terms
- * described here, provided that the new terms are clearly
- * indicated on the first page of each file where they apply.
- *
- *
- * IN NO EVENT SHALL APPLE, THE AUTHORS OR DISTRIBUTORS OF THE
- * SOFTWARE BE LIABLE TO ANY PARTY FOR DIRECT, INDIRECT, SPECIAL,
- * INCIDENTAL, OR CONSEQUENTIAL DAMAGES ARISING OUT OF THE USE OF
- * THIS SOFTWARE, ITS DOCUMENTATION, OR ANY DERIVATIVES THEREOF,
- * EVEN IF APPLE OR THE AUTHORS HAVE BEEN ADVISED OF THE
- * POSSIBILITY OF SUCH DAMAGE. APPLE, THE AUTHORS AND
- * DISTRIBUTORS SPECIFICALLY DISCLAIM ANY WARRANTIES, INCLUDING,
- * BUT NOT LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY,
- * FITNESS FOR A PARTICULAR PURPOSE, AND NON-INFRINGEMENT. THIS
- * SOFTWARE IS PROVIDED ON AN "AS IS" BASIS, AND APPLE,THE
- * AUTHORS AND DISTRIBUTORS HAVE NO OBLIGATION TO PROVIDE
- * MAINTENANCE, SUPPORT, UPDATES, ENHANCEMENTS, OR MODIFICATIONS.
- *
- * GOVERNMENT USE: If you are acquiring this software on behalf
- * of the U.S. government, the Government shall have only
- * "Restricted Rights" in the software and related documentation
- * as defined in the Federal Acquisition Regulations (FARs) in
- * Clause 52.227.19 (c) (2). If you are acquiring the software
- * on behalf of the Department of Defense, the software shall be
- * classified as "Commercial Computer Software" and the
- * Government shall have only "Restricted Rights" as defined in
- * Clause 252.227-7013 (c) (1) of DFARs. Notwithstanding the
- * foregoing, the authors grant the U.S. Government and others
- * acting in its behalf permission to use and distribute the
- * software in accordance with the terms specified in this
- * license.
+ * RCS: @(#) $Id$
*/
#ifndef _TKMACDEBUG
@@ -64,24 +22,6 @@
#ifdef TK_MAC_DEBUG
-MODULE_SCOPE char* TkMacOSXCarbonEventToAscii(EventRef eventRef);
-
-#ifdef TK_MACOSXDEBUG_UNUSED
-MODULE_SCOPE char* TkMacOSXCarbonEventKindToAscii(EventRef eventRef, char * buf );
-MODULE_SCOPE char* TkMacOSXClassicEventToAscii(EventRecord * eventPtr, char * buf );
-
-MODULE_SCOPE void TkMacOSXPrintRect(char * tag, Rect * r );
-MODULE_SCOPE void TkMacOSXPrintPoint(char * tag, Point * p );
-
-MODULE_SCOPE void TkMacOSXPrintRegion(char * tag, RgnHandle rgn );
-MODULE_SCOPE void TkMacOSXPrintWindowTitle(char * tag, WindowRef window );
-MODULE_SCOPE char* TkMacOSXMenuMessageToAscii(int msg, char * s);
-
-MODULE_SCOPE char* TkMacOSXMouseTrackingResultToAscii(MouseTrackingResult r, char * buf );
-#endif
-
-MODULE_SCOPE void TkMacOSXDebugFlashRegion(Drawable d, HIShapeRef rgn);
-
MODULE_SCOPE void* TkMacOSXGetNamedDebugSymbol(const char* module, const char* symbol);
/* Macro to abstract common use of TkMacOSXGetNamedDebugSymbol to initialize named symbols */
diff --git a/macosx/tkMacOSXDefault.h b/macosx/tkMacOSXDefault.h
index f969064..c1dce3b 100644
--- a/macosx/tkMacOSXDefault.h
+++ b/macosx/tkMacOSXDefault.h
@@ -6,16 +6,22 @@
*
* Copyright (c) 1991-1994 The Regents of the University of California.
* Copyright (c) 1994-1997 Sun Microsystems, Inc.
- * Copyright 2001, Apple Computer, Inc.
- * Copyright (c) 2006-2007 Daniel A. Steffen <das@users.sourceforge.net>
+ * Copyright 2001-2009, Apple Inc.
+ * Copyright (c) 2006-2009 Daniel A. Steffen <das@users.sourceforge.net>
*
* See the file "license.terms" for information on usage and redistribution
* of this file, and for a DISCLAIMER OF ALL WARRANTIES.
+ *
+ * RCS: @(#) $Id$
*/
#ifndef _TKMACDEFAULT
#define _TKMACDEFAULT
+#ifndef TK_MAC_BUTTON_USE_COMPATIBILITY_METRICS
+#define TK_MAC_BUTTON_USE_COMPATIBILITY_METRICS 1
+#endif
+
/*
* The definitions below provide symbolic names for the default colors.
* NORMAL_BG - Normal background color.
@@ -27,17 +33,17 @@
* DISABLED - Foreground color when widget is disabled.
*/
-#define BLACK "Black"
-#define WHITE "White"
-#define NORMAL_BG "systemWindowBody"
-#define ACTIVE_BG "systemButtonFacePressed"
-#define ACTIVE_FG "systemPushButtonPressedText"
-#define SELECT_BG "systemHighlight"
-#define SELECT_FG None
-#define INACTIVE_SELECT_BG "systemHighlightSecondary"
-#define TROUGH "#c3c3c3"
-#define INDICATOR "#b03060"
-#define DISABLED "#a3a3a3"
+#define BLACK "Black"
+#define WHITE "White"
+#define NORMAL_BG "systemWindowBody"
+#define ACTIVE_BG "systemButtonFacePressed"
+#define ACTIVE_FG "systemPushButtonPressedText"
+#define SELECT_BG "systemHighlight"
+#define SELECT_FG None
+#define INACTIVE_SELECT_BG "systemHighlightSecondary"
+#define TROUGH "#c3c3c3"
+#define INDICATOR "#b03060"
+#define DISABLED "#a3a3a3"
/*
* Defaults for labels, buttons, checkbuttons, and radiobuttons:
@@ -68,17 +74,32 @@
#define DEF_BUTTON_HIGHLIGHT_BG_MONO DEF_BUTTON_BG_MONO
#define DEF_BUTTON_HIGHLIGHT "systemButtonFrame"
#define DEF_LABEL_HIGHLIGHT_WIDTH "0"
+#if TK_MAC_BUTTON_USE_COMPATIBILITY_METRICS
#define DEF_BUTTON_HIGHLIGHT_WIDTH "4"
-#define DEF_BUTTON_IMAGE (char *) NULL
+#define DEF_BUTTON_HIGHLIGHT_WIDTH_NOCM "1"
+#else
+#define DEF_BUTTON_HIGHLIGHT_WIDTH "1"
+#endif
+#define DEF_BUTTON_IMAGE ((char *) NULL)
#define DEF_BUTTON_INDICATOR "1"
#define DEF_BUTTON_JUSTIFY "center"
#define DEF_BUTTON_OFF_VALUE "0"
#define DEF_BUTTON_ON_VALUE "1"
#define DEF_BUTTON_TRISTATE_VALUE ""
#define DEF_BUTTON_OVER_RELIEF ""
+#if TK_MAC_BUTTON_USE_COMPATIBILITY_METRICS
#define DEF_BUTTON_PADX "12"
+#define DEF_BUTTON_PADX_NOCM "1"
+#else
+#define DEF_BUTTON_PADX "1"
+#endif
#define DEF_LABCHKRAD_PADX "1"
+#if TK_MAC_BUTTON_USE_COMPATIBILITY_METRICS
#define DEF_BUTTON_PADY "3"
+#define DEF_BUTTON_PADY_NOCM "1"
+#else
+#define DEF_BUTTON_PADY "1"
+#endif
#define DEF_LABCHKRAD_PADY "1"
#define DEF_BUTTON_RELIEF "flat"
#define DEF_LABCHKRAD_RELIEF "flat"
@@ -86,10 +107,10 @@
#define DEF_BUTTON_REPEAT_INTERVAL "0"
#define DEF_BUTTON_SELECT_COLOR INDICATOR
#define DEF_BUTTON_SELECT_MONO BLACK
-#define DEF_BUTTON_SELECT_IMAGE (char *) NULL
+#define DEF_BUTTON_SELECT_IMAGE ((char *) NULL)
#define DEF_BUTTON_STATE "normal"
#define DEF_LABEL_TAKE_FOCUS "0"
-#define DEF_BUTTON_TAKE_FOCUS (char *) NULL
+#define DEF_BUTTON_TAKE_FOCUS ((char *) NULL)
#define DEF_BUTTON_TEXT ""
#define DEF_BUTTON_TEXT_VARIABLE ""
#define DEF_BUTTON_UNDERLINE "-1"
@@ -127,7 +148,7 @@
#define DEF_CANVAS_SELECT_BD_MONO "0"
#define DEF_CANVAS_SELECT_FG_COLOR SELECT_FG
#define DEF_CANVAS_SELECT_FG_MONO WHITE
-#define DEF_CANVAS_TAKE_FOCUS (char *) NULL
+#define DEF_CANVAS_TAKE_FOCUS ((char *) NULL)
#define DEF_CANVAS_WIDTH "10c"
#define DEF_CANVAS_X_SCROLL_CMD ""
#define DEF_CANVAS_X_SCROLL_INCREMENT "0"
@@ -183,9 +204,9 @@
#define DEF_ENTRY_SELECT_BD_MONO "0"
#define DEF_ENTRY_SELECT_FG_COLOR SELECT_FG
#define DEF_ENTRY_SELECT_FG_MONO WHITE
-#define DEF_ENTRY_SHOW (char *) NULL
+#define DEF_ENTRY_SHOW ((char *) NULL)
#define DEF_ENTRY_STATE "normal"
-#define DEF_ENTRY_TAKE_FOCUS (char *) NULL
+#define DEF_ENTRY_TAKE_FOCUS ((char *) NULL)
#define DEF_ENTRY_TEXT_VARIABLE ""
#define DEF_ENTRY_WIDTH "20"
@@ -251,36 +272,36 @@
#define DEF_LISTBOX_SELECT_MODE "browse"
#define DEF_LISTBOX_SET_GRID "0"
#define DEF_LISTBOX_STATE "normal"
-#define DEF_LISTBOX_TAKE_FOCUS (char *) NULL
+#define DEF_LISTBOX_TAKE_FOCUS ((char *) NULL)
#define DEF_LISTBOX_WIDTH "20"
/*
* Defaults for individual entries of menus:
*/
-#define DEF_MENU_ENTRY_ACTIVE_BG (char *) NULL
-#define DEF_MENU_ENTRY_ACTIVE_FG (char *) NULL
-#define DEF_MENU_ENTRY_ACCELERATOR (char *) NULL
-#define DEF_MENU_ENTRY_BG (char *) NULL
+#define DEF_MENU_ENTRY_ACTIVE_BG ((char *) NULL)
+#define DEF_MENU_ENTRY_ACTIVE_FG ((char *) NULL)
+#define DEF_MENU_ENTRY_ACCELERATOR ((char *) NULL)
+#define DEF_MENU_ENTRY_BG ((char *) NULL)
#define DEF_MENU_ENTRY_BITMAP None
#define DEF_MENU_ENTRY_COLUMN_BREAK "0"
-#define DEF_MENU_ENTRY_COMMAND (char *) NULL
+#define DEF_MENU_ENTRY_COMMAND ((char *) NULL)
#define DEF_MENU_ENTRY_COMPOUND "none"
-#define DEF_MENU_ENTRY_FG (char *) NULL
-#define DEF_MENU_ENTRY_FONT (char *) NULL
+#define DEF_MENU_ENTRY_FG ((char *) NULL)
+#define DEF_MENU_ENTRY_FONT ((char *) NULL)
#define DEF_MENU_ENTRY_HIDE_MARGIN "0"
-#define DEF_MENU_ENTRY_IMAGE (char *) NULL
+#define DEF_MENU_ENTRY_IMAGE ((char *) NULL)
#define DEF_MENU_ENTRY_INDICATOR "1"
-#define DEF_MENU_ENTRY_LABEL (char *) NULL
-#define DEF_MENU_ENTRY_MENU (char *) NULL
+#define DEF_MENU_ENTRY_LABEL ((char *) NULL)
+#define DEF_MENU_ENTRY_MENU ((char *) NULL)
#define DEF_MENU_ENTRY_OFF_VALUE "0"
#define DEF_MENU_ENTRY_ON_VALUE "1"
-#define DEF_MENU_ENTRY_SELECT_IMAGE (char *) NULL
+#define DEF_MENU_ENTRY_SELECT_IMAGE ((char *) NULL)
#define DEF_MENU_ENTRY_STATE "normal"
-#define DEF_MENU_ENTRY_VALUE (char *) NULL
-#define DEF_MENU_ENTRY_CHECK_VARIABLE (char *) NULL
+#define DEF_MENU_ENTRY_VALUE ((char *) NULL)
+#define DEF_MENU_ENTRY_CHECK_VARIABLE ((char *) NULL)
#define DEF_MENU_ENTRY_RADIO_VARIABLE "selectedButton"
-#define DEF_MENU_ENTRY_SELECT (char *) NULL
+#define DEF_MENU_ENTRY_SELECT ((char *) NULL)
#define DEF_MENU_ENTRY_UNDERLINE "-1"
/*
@@ -311,7 +332,7 @@
*/
#define DEF_MENU_TEAROFF "0"
-#define DEF_MENU_TEAROFF_CMD (char *) NULL
+#define DEF_MENU_TEAROFF_CMD ((char *) NULL)
#define DEF_MENU_TITLE ""
#define DEF_MENU_TYPE "normal"
@@ -339,13 +360,12 @@
#define DEF_MENUBUTTON_HIGHLIGHT_BG_MONO DEF_MENUBUTTON_BG_MONO
#define DEF_MENUBUTTON_HIGHLIGHT BLACK
#define DEF_MENUBUTTON_HIGHLIGHT_WIDTH "0"
-#define DEF_MENUBUTTON_IMAGE (char *) NULL
-#define DEF_MENUBUTTON_INDICATOR "0"
-/* #define DEF_MENUBUTTON_JUSTIFY "center" */
+#define DEF_MENUBUTTON_IMAGE ((char *) NULL)
+#define DEF_MENUBUTTON_INDICATOR "1"
#define DEF_MENUBUTTON_JUSTIFY "left"
#define DEF_MENUBUTTON_MENU ""
-#define DEF_MENUBUTTON_PADX "4p"
-#define DEF_MENUBUTTON_PADY "3p"
+#define DEF_MENUBUTTON_PADX "4"
+#define DEF_MENUBUTTON_PADY "3"
#define DEF_MENUBUTTON_RELIEF "flat"
#define DEF_MENUBUTTON_STATE "normal"
#define DEF_MENUBUTTON_TAKE_FOCUS "0"
@@ -448,7 +468,7 @@
#define DEF_SCALE_SLIDER_LENGTH "30"
#define DEF_SCALE_SLIDER_RELIEF "raised"
#define DEF_SCALE_STATE "normal"
-#define DEF_SCALE_TAKE_FOCUS (char *) NULL
+#define DEF_SCALE_TAKE_FOCUS ((char *) NULL)
#define DEF_SCALE_TICK_INTERVAL "0"
#define DEF_SCALE_TO "100"
#define DEF_SCALE_VARIABLE ""
@@ -475,7 +495,7 @@
#define DEF_SCROLLBAR_RELIEF "flat"
#define DEF_SCROLLBAR_REPEAT_DELAY "300"
#define DEF_SCROLLBAR_REPEAT_INTERVAL "100"
-#define DEF_SCROLLBAR_TAKE_FOCUS (char *) NULL
+#define DEF_SCROLLBAR_TAKE_FOCUS ((char *) NULL)
#define DEF_SCROLLBAR_TROUGH_COLOR TROUGH
#define DEF_SCROLLBAR_TROUGH_MONO WHITE
#define DEF_SCROLLBAR_WIDTH "15"
@@ -522,7 +542,7 @@
#define DEF_TEXT_STATE "normal"
#define DEF_TEXT_TABS ""
#define DEF_TEXT_TABSTYLE "tabular"
-#define DEF_TEXT_TAKE_FOCUS (char *) NULL
+#define DEF_TEXT_TAKE_FOCUS ((char *) NULL)
#define DEF_TEXT_UNDO "0"
#define DEF_TEXT_WIDTH "80"
#define DEF_TEXT_WRAP "char"
diff --git a/macosx/tkMacOSXDialog.c b/macosx/tkMacOSXDialog.c
index c99cdbc..7827f85 100644
--- a/macosx/tkMacOSXDialog.c
+++ b/macosx/tkMacOSXDialog.c
@@ -4,106 +4,218 @@
* Contains the Mac implementation of the common dialog boxes.
*
* Copyright (c) 1996-1997 Sun Microsystems, Inc.
- * Copyright 2001, Apple Computer, Inc.
- * Copyright (c) 2006-2007 Daniel A. Steffen <das@users.sourceforge.net>
+ * Copyright 2001-2009, Apple Inc.
+ * Copyright (c) 2006-2009 Daniel A. Steffen <das@users.sourceforge.net>
*
* See the file "license.terms" for information on usage and redistribution
* of this file, and for a DISCLAIMER OF ALL WARRANTIES.
+ *
+ * RCS: @(#) $Id$
*/
#include "tkMacOSXPrivate.h"
#include "tkFileFilter.h"
-#ifndef StrLength
-#define StrLength(s) (*((unsigned char *) (s)))
-#endif
-#ifndef StrBody
-#define StrBody(s) ((char *) (s) + 1)
-#endif
-
-#define OPEN_POPUP_ITEM 10
-
-#define SAVE_FILE 0
-#define OPEN_FILE 1
-#define CHOOSE_FOLDER 2
-
-#define MATCHED 0
-#define UNMATCHED 1
-
-#define TK_DEFAULT_ABOUT 128
-
-/*
- * The following structures are used in the GetFileName() function. They store
- * information about the file dialog and the file filters.
- */
-
-typedef struct _OpenFileData {
- FileFilterList fl; /* List of file filters. */
- SInt16 curType; /* The filetype currently being listed. */
- short initialType; /* Type to use initially */
- short popupItem; /* Item number of the popup in the dialog. */
- short usePopup; /* True if we show the popup menu (this */
- /* is an open operation and the */
- /* -filetypes option is set). */
-} OpenFileData;
-
-typedef struct NavHandlerUserData {
- OpenFileData *ofdPtr;
- NavReplyRecord reply;
- OSStatus err;
- CFStringRef saveNameRef;
- int sheet;
- WindowRef dialogWindow, origUnavailWindow;
- WindowModality origModality;
-} NavHandlerUserData;
-
-/*
- * The following structure is used in the tk_messageBox implementation.
- */
-
+static const char *colorOptionStrings[] = {
+ "-initialcolor", "-parent", "-title", NULL
+};
+enum colorOptions {
+ COLOR_INITIAL, COLOR_PARENT, COLOR_TITLE
+};
+
+static const char *openOptionStrings[] = {
+ "-defaultextension", "-filetypes", "-initialdir", "-initialfile",
+ "-message", "-multiple", "-parent", "-title", "-typevariable",
+ "-command", NULL
+};
+enum openOptions {
+ OPEN_DEFAULT, OPEN_FILETYPES, OPEN_INITDIR, OPEN_INITFILE,
+ OPEN_MESSAGE, OPEN_MULTIPLE, OPEN_PARENT, OPEN_TITLE,
+ OPEN_TYPEVARIABLE, OPEN_COMMAND,
+};
+static const char *saveOptionStrings[] = {
+ "-defaultextension", "-filetypes", "-initialdir", "-initialfile",
+ "-message", "-parent", "-title", "-typevariable", "-command",
+ "-confirmoverwrite", NULL
+};
+enum saveOptions {
+ SAVE_DEFAULT, SAVE_FILETYPES, SAVE_INITDIR, SAVE_INITFILE,
+ SAVE_MESSAGE, SAVE_PARENT, SAVE_TITLE, SAVE_TYPEVARIABLE, SAVE_COMMAND,
+ SAVE_CONFIRMOW
+};
+static const char *chooseOptionStrings[] = {
+ "-initialdir", "-message", "-mustexist", "-parent", "-title", "-command",
+ NULL
+};
+enum chooseOptions {
+ CHOOSE_INITDIR, CHOOSE_MESSAGE, CHOOSE_MUSTEXIST, CHOOSE_PARENT,
+ CHOOSE_TITLE, CHOOSE_COMMAND,
+};
typedef struct {
- int buttonIndex;
- WindowRef dialogWindow, origUnavailWindow;
- WindowModality origModality;
- EventHandlerRef handlerRef;
-} AlertHandlerUserData;
-
-
-static OSStatus AlertHandler(EventHandlerCallRef callRef,
- EventRef eventRef, void *userData);
-static Boolean MatchOneType(StringPtr fileNamePtr, OSType fileType,
- OpenFileData *myofdPtr, FileFilter *filterPtr);
-static pascal Boolean OpenFileFilterProc(AEDesc* theItem, void* info,
- NavCallBackUserData callBackUD,
- NavFilterModes filterMode);
-static pascal void OpenEventProc(NavEventCallbackMessage callBackSelector,
- NavCBRecPtr callBackParms,
- NavCallBackUserData callBackUD);
-static void InitFileDialogs(void);
-static int NavServicesGetFile(Tcl_Interp *interp,
- OpenFileData *ofd, AEDesc *initialDescPtr,
- char *initialFile, AEDescList *selectDescPtr,
- CFStringRef title, CFStringRef message,
- const char *initialType, int multiple,
- int confirmOverwrite, int isOpen,
- Tk_Window parent);
-static int HandleInitialDirectory(Tcl_Interp *interp,
- char *initialFile, char *initialDir, FSRef *dirRef,
- AEDescList *selectDescPtr, AEDesc *dirDescPtr);
+ Tcl_Interp *interp;
+ Tcl_Obj *cmdObj;
+ int multiple;
+} FilePanelCallbackInfo;
+
+static const char *alertOptionStrings[] = {
+ "-default", "-detail", "-icon", "-message", "-parent", "-title",
+ "-type", "-command", NULL
+};
+enum alertOptions {
+ ALERT_DEFAULT, ALERT_DETAIL, ALERT_ICON, ALERT_MESSAGE, ALERT_PARENT,
+ ALERT_TITLE, ALERT_TYPE, ALERT_COMMAND,
+};
+typedef struct {
+ Tcl_Interp *interp;
+ Tcl_Obj *cmdObj;
+ int typeIndex;
+} AlertCallbackInfo;
+static const char *alertTypeStrings[] = {
+ "abortretryignore", "ok", "okcancel", "retrycancel", "yesno",
+ "yesnocancel", NULL
+};
+enum alertTypeOptions {
+ TYPE_ABORTRETRYIGNORE, TYPE_OK, TYPE_OKCANCEL, TYPE_RETRYCANCEL,
+ TYPE_YESNO, TYPE_YESNOCANCEL
+};
+static const char *alertIconStrings[] = {
+ "error", "info", "question", "warning", NULL
+};
+enum alertIconOptions {
+ ICON_ERROR, ICON_INFO, ICON_QUESTION, ICON_WARNING
+};
+static const char *alertButtonStrings[] = {
+ "abort", "retry", "ignore", "ok", "cancel", "yes", "no", NULL
+};
+
+static const NSString *const alertButtonNames[][3] = {
+ [TYPE_ABORTRETRYIGNORE] = {@"Abort", @"Retry", @"Ignore"},
+ [TYPE_OK] = {@"OK"},
+ [TYPE_OKCANCEL] = {@"OK", @"Cancel"},
+ [TYPE_RETRYCANCEL] = {@"Retry", @"Cancel"},
+ [TYPE_YESNO] = {@"Yes", @"No"},
+ [TYPE_YESNOCANCEL] = {@"Yes", @"No", @"Cancel"},
+};
+static const NSAlertStyle alertStyles[] = {
+ [ICON_ERROR] = NSWarningAlertStyle,
+ [ICON_INFO] = NSInformationalAlertStyle,
+ [ICON_QUESTION] = NSWarningAlertStyle,
+ [ICON_WARNING] = NSCriticalAlertStyle,
+};
/*
- * Have we initialized the file dialog subsystem
+ * Need to map from 'alertButtonStrings' and its corresponding integer,
+ * index to the native button index, which is 1, 2, 3, from right to left.
+ * This is necessary to do for each separate '-type' of button sets.
*/
-static int fileDlgInited = 0;
+static const short alertButtonIndexAndTypeToNativeButtonIndex[][7] = {
+ /* abort retry ignore ok cancel yes no */
+ [TYPE_ABORTRETRYIGNORE] = {1, 2, 3, 0, 0, 0, 0},
+ [TYPE_OK] = {0, 0, 0, 1, 0, 0, 0},
+ [TYPE_OKCANCEL] = {0, 0, 0, 1, 2, 0, 0},
+ [TYPE_RETRYCANCEL] = {0, 1, 0, 0, 2, 0, 0},
+ [TYPE_YESNO] = {0, 0, 0, 0, 0, 1, 2},
+ [TYPE_YESNOCANCEL] = {0, 0, 0, 0, 3, 1, 2},
+};
/*
- * Filter and hook functions used by the tk_getOpenFile and tk_getSaveFile
- * commands.
+ * Need also the inverse mapping, from NSAlertFirstButtonReturn etc to the
+ * descriptive button text string index.
*/
-static NavObjectFilterUPP openFileFilterUPP;
-static NavEventUPP openFileEventUPP;
+static const short alertNativeButtonIndexAndTypeToButtonIndex[][3] = {
+ [TYPE_ABORTRETRYIGNORE] = {0, 1, 2},
+ [TYPE_OK] = {3, 0, 0},
+ [TYPE_OKCANCEL] = {3, 4, 0},
+ [TYPE_RETRYCANCEL] = {1, 4, 0},
+ [TYPE_YESNO] = {5, 6, 0},
+ [TYPE_YESNOCANCEL] = {5, 6, 4},
+};
+
+#pragma mark TKApplication(TKDialog)
+
+@interface NSColorPanel(TKDialog)
+- (void)_setUseModalAppearance:(BOOL)flag;
+@end
+
+@implementation TKApplication(TKDialog)
+- (void)tkFilePanelDidEnd:(NSSavePanel *)panel returnCode:(NSInteger)returnCode
+ contextInfo:(void *)contextInfo {
+ FilePanelCallbackInfo *callbackInfo = contextInfo;
+
+ if (returnCode == NSFileHandlingPanelOKButton) {
+ Tcl_Obj *resultObj;
+ if (callbackInfo->multiple) {
+ resultObj = Tcl_NewListObj(0, NULL);
+ for (NSString *name in [(NSOpenPanel*)panel filenames]) {
+ Tcl_ListObjAppendElement(callbackInfo->interp, resultObj,
+ Tcl_NewStringObj([name UTF8String], -1));
+ }
+ } else {
+ resultObj = Tcl_NewStringObj([[panel filename] UTF8String], -1);
+ }
+ if (callbackInfo->cmdObj) {
+ Tcl_Obj **objv, **tmpv;
+ int objc, result = Tcl_ListObjGetElements(callbackInfo->interp,
+ callbackInfo->cmdObj, &objc, &objv);
+ if (result == TCL_OK && objc) {
+ tmpv = (Tcl_Obj **) ckalloc(sizeof(Tcl_Obj *) * (objc + 2));
+ memcpy(tmpv, objv, sizeof(Tcl_Obj *) * objc);
+ tmpv[objc] = resultObj;
+ TkBackgroundEvalObjv(callbackInfo->interp, objc + 1, tmpv,
+ TCL_EVAL_GLOBAL);
+ ckfree((char *)tmpv);
+ }
+ } else {
+ Tcl_SetObjResult(callbackInfo->interp, resultObj);
+ }
+ } else if (returnCode == NSFileHandlingPanelCancelButton) {
+ Tcl_ResetResult(callbackInfo->interp);
+ }
+ if (panel == [NSApp modalWindow]) {
+ [NSApp stopModalWithCode:returnCode];
+ }
+ if (callbackInfo->cmdObj) {
+ Tcl_DecrRefCount(callbackInfo->cmdObj);
+ ckfree((char*) callbackInfo);
+ }
+}
+- (void)tkAlertDidEnd:(NSAlert *)alert returnCode:(NSInteger)returnCode
+ contextInfo:(void *)contextInfo {
+ AlertCallbackInfo *callbackInfo = contextInfo;
+
+ if (returnCode != NSAlertErrorReturn) {
+ Tcl_Obj *resultObj = Tcl_NewStringObj(alertButtonStrings[
+ alertNativeButtonIndexAndTypeToButtonIndex[callbackInfo->
+ typeIndex][returnCode - NSAlertFirstButtonReturn]], -1);
+ if (callbackInfo->cmdObj) {
+ Tcl_Obj **objv, **tmpv;
+ int objc, result = Tcl_ListObjGetElements(callbackInfo->interp,
+ callbackInfo->cmdObj, &objc, &objv);
+ if (result == TCL_OK && objc) {
+ tmpv = (Tcl_Obj **) ckalloc(sizeof(Tcl_Obj *) * (objc + 2));
+ memcpy(tmpv, objv, sizeof(Tcl_Obj *) * objc);
+ tmpv[objc] = resultObj;
+ TkBackgroundEvalObjv(callbackInfo->interp, objc + 1, tmpv,
+ TCL_EVAL_GLOBAL);
+ ckfree((char *)tmpv);
+ }
+ } else {
+ Tcl_SetObjResult(callbackInfo->interp, resultObj);
+ }
+ }
+ if ([alert window] == [NSApp modalWindow]) {
+ [NSApp stopModalWithCode:returnCode];
+ }
+ if (callbackInfo->cmdObj) {
+ Tcl_DecrRefCount(callbackInfo->cmdObj);
+ ckfree((char*) callbackInfo);
+ }
+}
+@end
+
+#pragma mark -
/*
*----------------------------------------------------------------------
@@ -127,35 +239,21 @@ Tk_ChooseColorObjCmd(
ClientData clientData, /* Main window associated with interpreter. */
Tcl_Interp *interp, /* Current interpreter. */
int objc, /* Number of arguments. */
- Tcl_Obj *CONST objv[]) /* Argument objects. */
+ Tcl_Obj *const objv[]) /* Argument objects. */
{
- OSStatus err;
int result = TCL_ERROR;
Tk_Window parent, tkwin = clientData;
- const char *title;
- int i, srcRead, dstWrote;
- CMError cmerr;
- CMProfileRef prof;
- NColorPickerInfo cpinfo;
- static RGBColor color = {0xffff, 0xffff, 0xffff};
- static const char *optionStrings[] = {
- "-initialcolor", "-parent", "-title", NULL
- };
- enum options {
- COLOR_INITIAL, COLOR_PARENT, COLOR_TITLE
- };
-
- title = "Choose a color:";
- bzero(&cpinfo, sizeof(cpinfo));
- cpinfo.theColor.color.rgb.red = color.red;
- cpinfo.theColor.color.rgb.green = color.green;
- cpinfo.theColor.color.rgb.blue = color.blue;
+ const char *title = NULL;
+ int i;
+ NSColor *color = nil, *initialColor = nil;
+ NSColorPanel *colorPanel;
+ NSInteger returnCode, numberOfComponents = 0;
for (i = 1; i < objc; i += 2) {
int index;
const char *option, *value;
- if (Tcl_GetIndexFromObj(interp, objv[i], optionStrings, "option",
+ if (Tcl_GetIndexFromObj(interp, objv[i], colorOptionStrings, "option",
TCL_EXACT, &index) != TCL_OK) {
goto end;
}
@@ -167,7 +265,7 @@ Tk_ChooseColorObjCmd(
}
value = Tcl_GetString(objv[i + 1]);
- switch ((enum options) index) {
+ switch (index) {
case COLOR_INITIAL: {
XColor *colorPtr;
@@ -175,9 +273,7 @@ Tk_ChooseColorObjCmd(
if (colorPtr == NULL) {
goto end;
}
- cpinfo.theColor.color.rgb.red = colorPtr->red;
- cpinfo.theColor.color.rgb.green = colorPtr->green;
- cpinfo.theColor.color.rgb.blue = colorPtr->blue;
+ initialColor = TkMacOSXGetNSColor(NULL, colorPtr->pixel);
Tk_FreeColor(colorPtr);
break;
}
@@ -194,36 +290,41 @@ Tk_ChooseColorObjCmd(
}
}
}
-
- cmerr = CMGetDefaultProfileBySpace(cmRGBData, &prof);
- cpinfo.theColor.profile = prof;
- cpinfo.dstProfile = prof;
- cpinfo.flags = kColorPickerDialogIsMoveable | kColorPickerDialogIsModal;
- cpinfo.placeWhere = kCenterOnMainScreen;
- /* Currently, this does not actually change the colorpicker title */
- Tcl_UtfToExternal(NULL, TkMacOSXCarbonEncoding, title, -1, 0, NULL,
- StrBody(cpinfo.prompt), 255, &srcRead, &dstWrote, NULL);
- StrLength(cpinfo.prompt) = (unsigned char) dstWrote;
-
- TkMacOSXTrackingLoop(1);
- err = ChkErr(NPickColor, &cpinfo);
- TkMacOSXTrackingLoop(0);
- cmerr = CMCloseProfile(prof);
- if ((err == noErr) && (cpinfo.newColorChosen != 0)) {
+ colorPanel = [NSColorPanel sharedColorPanel];
+ [colorPanel orderOut:NSApp];
+ [colorPanel setContinuous:NO];
+ [colorPanel setBecomesKeyOnlyIfNeeded:NO];
+ [colorPanel setShowsAlpha: NO];
+ [colorPanel _setUseModalAppearance:YES];
+ if (title) {
+ NSString *s = [[NSString alloc] initWithUTF8String:title];
+ [colorPanel setTitle:s];
+ [s release];
+ }
+ if (initialColor) {
+ [colorPanel setColor:initialColor];
+ }
+ returnCode = [NSApp runModalForWindow:colorPanel];
+ if (returnCode == NSOKButton) {
+ color = [[colorPanel color] colorUsingColorSpace:
+ [NSColorSpace genericRGBColorSpace]];
+ numberOfComponents = [color numberOfComponents];
+ }
+ if (color && numberOfComponents >= 3 && numberOfComponents <= 4) {
+ CGFloat components[4];
char colorstr[8];
- color.red = cpinfo.theColor.color.rgb.red;
- color.green = cpinfo.theColor.color.rgb.green;
- color.blue = cpinfo.theColor.color.rgb.blue;
- snprintf(colorstr, 8, "#%02x%02x%02x", color.red >> 8,
- color.green >> 8, color.blue >> 8);
+ [color getComponents:components];
+ snprintf(colorstr, 8, "#%02x%02x%02x",
+ (short)(components[0] * 255),
+ (short)(components[1] * 255),
+ (short)(components[2] * 255));
Tcl_SetObjResult(interp, Tcl_NewStringObj(colorstr, 7));
} else {
Tcl_ResetResult(interp);
}
result = TCL_OK;
-
- end:
+end:
return result;
}
@@ -248,85 +349,61 @@ Tk_GetOpenFileObjCmd(
ClientData clientData, /* Main window associated with interpreter. */
Tcl_Interp *interp, /* Current interpreter. */
int objc, /* Number of arguments. */
- Tcl_Obj *CONST objv[]) /* Argument objects. */
+ Tcl_Obj *const objv[]) /* Argument objects. */
{
- int i, result = TCL_ERROR, multiple = 0;
- OpenFileData ofd;
- Tk_Window parent = NULL;
- CFStringRef message = NULL, title = NULL;
- AEDesc initialDesc = {typeNull, NULL};
- FSRef dirRef;
- AEDesc *initialPtr = NULL;
- AEDescList selectDesc = {typeNull, NULL};
- char *initialFile = NULL, *initialDir = NULL;
- Tcl_Obj *typeVariablePtr = NULL;
- const char *initialtype = NULL;
- static const char *openOptionStrings[] = {
- "-defaultextension", "-filetypes", "-initialdir", "-initialfile",
- "-message", "-multiple", "-parent", "-title", "-typevariable", NULL
- };
- enum openOptions {
- OPEN_DEFAULT, OPEN_FILETYPES, OPEN_INITDIR, OPEN_INITFILE,
- OPEN_MESSAGE, OPEN_MULTIPLE, OPEN_PARENT, OPEN_TITLE,
- OPEN_TYPEVARIABLE,
- };
-
- if (!fileDlgInited) {
- InitFileDialogs();
- }
- TkInitFileFilters(&ofd.fl);
- ofd.curType = 0;
- ofd.initialType = -1;
- ofd.popupItem = OPEN_POPUP_ITEM;
- ofd.usePopup = 1;
-
+ Tk_Window tkwin = clientData;
+ char *str;
+ int i, result = TCL_ERROR, haveParentOption = 0;
+ int index, len, multiple = 0;
+ FileFilterList fl;
+ Tcl_Obj *cmdObj = NULL, *typeVariablePtr = NULL;
+ FilePanelCallbackInfo callbackInfoStruct;
+ FilePanelCallbackInfo *callbackInfo = &callbackInfoStruct;
+ NSString *directory = nil, *filename = nil;
+ NSString *message, *title, *type;
+ NSWindow *parent;
+ NSMutableArray *fileTypes = nil;
+ NSOpenPanel *panel = [NSOpenPanel openPanel];
+ NSInteger returnCode = NSAlertErrorReturn;
+
+ TkInitFileFilters(&fl);
for (i = 1; i < objc; i += 2) {
- char *choice;
- int index, choiceLen;
- char *string;
- Tcl_Obj *types;
-
if (Tcl_GetIndexFromObj(interp, objv[i], openOptionStrings, "option",
TCL_EXACT, &index) != TCL_OK) {
goto end;
}
if (i + 1 == objc) {
- string = Tcl_GetString(objv[i]);
- Tcl_AppendResult(interp, "value for \"", string, "\" missing",
- NULL);
+ str = Tcl_GetString(objv[i]);
+ Tcl_AppendResult(interp, "value for \"", str, "\" missing", NULL);
goto end;
}
-
switch (index) {
case OPEN_DEFAULT:
break;
case OPEN_FILETYPES:
- types = objv[i + 1];
- if (TkGetFileFilters(interp, &ofd.fl, types, 0) != TCL_OK) {
+ if (TkGetFileFilters(interp, &fl, objv[i + 1], 0) != TCL_OK) {
goto end;
}
break;
case OPEN_INITDIR:
- initialDir = Tcl_GetStringFromObj(objv[i + 1], &choiceLen);
- /* empty strings should be like no selection given */
- if (choiceLen == 0) {
- initialDir = NULL;
+ str = Tcl_GetStringFromObj(objv[i + 1], &len);
+ if (len) {
+ directory = [[[NSString alloc] initWithUTF8String:str]
+ autorelease];
}
break;
case OPEN_INITFILE:
- initialFile = Tcl_GetStringFromObj(objv[i + 1], &choiceLen);
- /* empty strings should be like no selection given */
- if (choiceLen == 0) {
- initialFile = NULL;
+ str = Tcl_GetStringFromObj(objv[i + 1], &len);
+ if (len) {
+ filename = [[[NSString alloc] initWithUTF8String:str]
+ autorelease];
}
break;
case OPEN_MESSAGE:
- choice = Tcl_GetStringFromObj(objv[i + 1], &choiceLen);
- if (message) {
- CFRelease(message);
- }
- message = CFStringCreateWithBytes(NULL, (unsigned char *) choice,
- choiceLen, kCFStringEncodingUTF8, false);
+ message = [[NSString alloc] initWithUTF8String:
+ Tcl_GetString(objv[i + 1])];
+ [panel setMessage:message];
+ [message release];
break;
case OPEN_MULTIPLE:
if (Tcl_GetBooleanFromObj(interp, objv[i + 1],
@@ -335,68 +412,96 @@ Tk_GetOpenFileObjCmd(
}
break;
case OPEN_PARENT:
- choice = Tcl_GetStringFromObj(objv[i + 1], &choiceLen);
- parent = Tk_NameToWindow(interp, choice, clientData);
- if (parent == NULL) {
+ str = Tcl_GetStringFromObj(objv[i + 1], &len);
+ tkwin = Tk_NameToWindow(interp, str, tkwin);
+ if (!tkwin) {
goto end;
}
+ haveParentOption = 1;
break;
case OPEN_TITLE:
- choice = Tcl_GetStringFromObj(objv[i + 1], &choiceLen);
- if (title) {
- CFRelease(title);
- }
- title = CFStringCreateWithBytes(NULL, (unsigned char *) choice,
- choiceLen, kCFStringEncodingUTF8, false);
+ title = [[NSString alloc] initWithUTF8String:
+ Tcl_GetString(objv[i + 1])];
+ [panel setTitle:title];
+ [title release];
break;
case OPEN_TYPEVARIABLE:
typeVariablePtr = objv[i + 1];
break;
+ case OPEN_COMMAND:
+ cmdObj = objv[i+1];
+ break;
}
}
-
- if (HandleInitialDirectory(interp, initialFile, initialDir, &dirRef,
- &selectDesc, &initialDesc) != TCL_OK) {
- goto end;
- }
- if (initialDesc.descriptorType == typeFSRef) {
- initialPtr = &initialDesc;
- }
- if (typeVariablePtr) {
- initialtype = Tcl_GetVar(interp, Tcl_GetString(typeVariablePtr),
- TCL_GLOBAL_ONLY);
- }
- result = NavServicesGetFile(interp, &ofd, initialPtr, NULL, &selectDesc,
- title, message, initialtype, multiple, false, OPEN_FILE, parent);
-
- if (typeVariablePtr) {
- FileFilter *filterPtr = ofd.fl.filters;
- int i = ofd.curType;
-
- while (filterPtr && i-- > 0) {
- filterPtr = filterPtr->next;
- }
- if (Tcl_SetVar(interp, Tcl_GetString(typeVariablePtr),
- filterPtr ? filterPtr->name : "",
- TCL_GLOBAL_ONLY|TCL_LEAVE_ERR_MSG) == NULL) {
- result = TCL_ERROR;
+ if (fl.filters) {
+ fileTypes = [NSMutableArray array];
+ for (FileFilter *filterPtr = fl.filters; filterPtr;
+ filterPtr = filterPtr->next) {
+ for (FileFilterClause *clausePtr = filterPtr->clauses; clausePtr;
+ clausePtr = clausePtr->next) {
+ for (GlobPattern *globPtr = clausePtr->patterns; globPtr;
+ globPtr = globPtr->next) {
+ str = globPtr->pattern;
+ while (*str && (*str == '*' || *str == '.')) {
+ str++;
+ }
+ if (*str) {
+ type = [[NSString alloc] initWithUTF8String:str];
+ if (![fileTypes containsObject:type]) {
+ [fileTypes addObject:type];
+ }
+ [type release];
+ }
+ }
+ for (MacFileType *mfPtr = clausePtr->macTypes; mfPtr;
+ mfPtr = mfPtr->next) {
+ if (mfPtr->type) {
+ type = NSFileTypeForHFSTypeCode(mfPtr->type);
+ if (![fileTypes containsObject:type]) {
+ [fileTypes addObject:type];
+ }
+ }
+ }
+ }
}
}
-
- end:
- TkFreeFileFilters(&ofd.fl);
- if (initialDesc.dataHandle) {
- ChkErr(AEDisposeDesc, &initialDesc);
- }
- if (selectDesc.dataHandle) {
- ChkErr(AEDisposeDesc, &selectDesc);
+ [panel setAllowsMultipleSelection:multiple];
+ if (cmdObj) {
+ callbackInfo = (FilePanelCallbackInfo *)
+ ckalloc(sizeof(FilePanelCallbackInfo));
+ if (Tcl_IsShared(cmdObj)) {
+ cmdObj = Tcl_DuplicateObj(cmdObj);
+ }
+ Tcl_IncrRefCount(cmdObj);
}
- if (title) {
- CFRelease(title);
+ callbackInfo->cmdObj = cmdObj;
+ callbackInfo->interp = interp;
+ callbackInfo->multiple = multiple;
+ parent = TkMacOSXDrawableWindow(((TkWindow *) tkwin)->window);
+ if (haveParentOption && parent && ![parent attachedSheet]) {
+ [panel beginSheetForDirectory:directory file:filename types:fileTypes
+ modalForWindow:parent modalDelegate:NSApp didEndSelector:
+ @selector(tkFilePanelDidEnd:returnCode:contextInfo:)
+ contextInfo:callbackInfo];
+ returnCode = cmdObj ? NSAlertOtherReturn :
+ [NSApp runModalForWindow:panel];
+ } else {
+ returnCode = [panel runModalForDirectory:directory file:filename
+ types:fileTypes];
+ [NSApp tkFilePanelDidEnd:panel returnCode:returnCode
+ contextInfo:callbackInfo];
}
- if (message) {
- CFRelease(message);
+ result = (returnCode != NSAlertErrorReturn) ? TCL_OK : TCL_ERROR;
+ if (typeVariablePtr && result == TCL_OK) {
+ /*
+ * The -typevariable option is not really supported.
+ */
+
+ Tcl_SetVar(interp, Tcl_GetString(typeVariablePtr), "",
+ TCL_GLOBAL_ONLY);
}
+end:
+ TkFreeFileFilters(&fl);
return result;
}
@@ -405,7 +510,8 @@ Tk_GetOpenFileObjCmd(
*
* Tk_GetSaveFileObjCmd --
*
- * Same as Tk_GetOpenFileCmd but opens a "save file" dialog box instead.
+ * This procedure implements the "save file" dialog box for the Mac
+ * platform. See the user documentation for details on what it does.
*
* Results:
* A standard Tcl result.
@@ -420,123 +526,154 @@ Tk_GetSaveFileObjCmd(
ClientData clientData, /* Main window associated with interpreter. */
Tcl_Interp *interp, /* Current interpreter. */
int objc, /* Number of arguments. */
- Tcl_Obj *CONST objv[]) /* Argument objects. */
+ Tcl_Obj *const objv[]) /* Argument objects. */
{
- int i, result = TCL_ERROR;
+ Tk_Window tkwin = clientData;
+ char *str;
+ int i, result = TCL_ERROR, haveParentOption = 0;
int confirmOverwrite = 1;
- char *initialFile = NULL;
- Tk_Window parent = NULL;
- AEDesc initialDesc = {typeNull, NULL};
- AEDesc *initialPtr = NULL;
- FSRef dirRef;
- CFStringRef title = NULL, message = NULL;
- OpenFileData ofd;
- static const char *saveOptionStrings[] = {
- "-defaultextension", "-filetypes", "-initialdir", "-initialfile",
- "-message", "-parent", "-title", "-typevariable",
- "-confirmoverwrite", NULL
- };
- enum saveOptions {
- SAVE_DEFAULT, SAVE_FILETYPES, SAVE_INITDIR, SAVE_INITFILE,
- SAVE_MESSAGE, SAVE_PARENT, SAVE_TITLE, SAVE_TYPEVARIABLE,
- SAVE_CONFIRMOW
- };
-
- if (!fileDlgInited) {
- InitFileDialogs();
- }
-
- TkInitFileFilters(&ofd.fl);
- ofd.curType = 0;
- ofd.usePopup = 0;
-
+ int index, len;
+ FileFilterList fl;
+ Tcl_Obj *cmdObj = NULL;
+ FilePanelCallbackInfo callbackInfoStruct;
+ FilePanelCallbackInfo *callbackInfo = &callbackInfoStruct;
+ NSString *directory = nil, *filename = nil, *defaultType = nil;
+ NSString *message, *title, *type;
+ NSWindow *parent;
+ NSMutableArray *fileTypes = nil;
+ NSSavePanel *panel = [NSSavePanel savePanel];
+ NSInteger returnCode = NSAlertErrorReturn;
+
+ TkInitFileFilters(&fl);
for (i = 1; i < objc; i += 2) {
- char *choice, *string;
- int index, choiceLen;
- Tcl_Obj *types;
-
if (Tcl_GetIndexFromObj(interp, objv[i], saveOptionStrings, "option",
TCL_EXACT, &index) != TCL_OK) {
goto end;
}
if (i + 1 == objc) {
- string = Tcl_GetString(objv[i]);
- Tcl_AppendResult(interp, "value for \"", string, "\" missing",
+ str = Tcl_GetString(objv[i]);
+ Tcl_AppendResult(interp, "value for \"", str, "\" missing",
NULL);
goto end;
}
switch (index) {
case SAVE_DEFAULT:
+ str = Tcl_GetStringFromObj(objv[i + 1], &len);
+ while (*str && (*str == '*' || *str == '.')) {
+ str++;
+ }
+ if (*str) {
+ defaultType = [[[NSString alloc] initWithUTF8String:str]
+ autorelease];
+ }
break;
case SAVE_FILETYPES:
- types = objv[i + 1];
- if (TkGetFileFilters(interp, &ofd.fl, types, 0) != TCL_OK) {
+ if (TkGetFileFilters(interp, &fl, objv[i + 1], 0) != TCL_OK) {
goto end;
}
break;
case SAVE_INITDIR:
- choice = Tcl_GetStringFromObj(objv[i + 1], &choiceLen);
- /* empty strings should be like no selection given */
- if (choiceLen && HandleInitialDirectory(interp, NULL, choice,
- &dirRef, NULL, &initialDesc) != TCL_OK) {
- goto end;
+ str = Tcl_GetStringFromObj(objv[i + 1], &len);
+ if (len) {
+ directory = [[[NSString alloc] initWithUTF8String:str]
+ autorelease];
}
break;
case SAVE_INITFILE:
- initialFile = Tcl_GetStringFromObj(objv[i + 1], &choiceLen);
- /* empty strings should be like no selection given */
- if (choiceLen == 0) {
- initialFile = NULL;
+ str = Tcl_GetStringFromObj(objv[i + 1], &len);
+ if (len) {
+ filename = [[[NSString alloc] initWithUTF8String:str]
+ autorelease];
}
break;
case SAVE_MESSAGE:
- choice = Tcl_GetStringFromObj(objv[i + 1], &choiceLen);
- if (message) {
- CFRelease(message);
- }
- message = CFStringCreateWithBytes(NULL, (unsigned char *) choice,
- choiceLen, kCFStringEncodingUTF8, false);
+ message = [[NSString alloc] initWithUTF8String:
+ Tcl_GetString(objv[i + 1])];
+ [panel setMessage:message];
+ [message release];
break;
case SAVE_PARENT:
- choice = Tcl_GetStringFromObj(objv[i + 1], &choiceLen);
- parent = Tk_NameToWindow(interp, choice, (Tk_Window) clientData);
- if (parent == NULL) {
+ str = Tcl_GetStringFromObj(objv[i + 1], &len);
+ tkwin = Tk_NameToWindow(interp, str, tkwin);
+ if (!tkwin) {
goto end;
}
+ haveParentOption = 1;
break;
case SAVE_TITLE:
- choice = Tcl_GetStringFromObj(objv[i + 1], &choiceLen);
- if (title) {
- CFRelease(title);
- }
- title = CFStringCreateWithBytes(NULL, (unsigned char *) choice,
- choiceLen, kCFStringEncodingUTF8, false);
+ title = [[NSString alloc] initWithUTF8String:
+ Tcl_GetString(objv[i + 1])];
+ [panel setTitle:title];
+ [title release];
+ break;
+ case SAVE_TYPEVARIABLE:
+ break;
+ case SAVE_COMMAND:
+ cmdObj = objv[i+1];
break;
case SAVE_CONFIRMOW:
- if (Tcl_GetBooleanFromObj(interp, objv[i + 1], &confirmOverwrite)
- != TCL_OK) {
- return TCL_ERROR;
+ if (Tcl_GetBooleanFromObj(interp, objv[i + 1],
+ &confirmOverwrite) != TCL_OK) {
+ goto end;
}
break;
}
}
-
- if (initialDesc.descriptorType == typeFSRef) {
- initialPtr = &initialDesc;
- }
- result = NavServicesGetFile(interp, &ofd, initialPtr, initialFile, NULL,
- title, message, NULL, false, confirmOverwrite, SAVE_FILE, parent);
- TkFreeFileFilters(&ofd.fl);
- end:
- if (initialDesc.dataHandle) {
- ChkErr(AEDisposeDesc, &initialDesc);
+ if (fl.filters || defaultType) {
+ fileTypes = [NSMutableArray array];
+ [fileTypes addObject:defaultType ? defaultType : (id)kUTTypeContent];
+ for (FileFilter *filterPtr = fl.filters; filterPtr;
+ filterPtr = filterPtr->next) {
+ for (FileFilterClause *clausePtr = filterPtr->clauses; clausePtr;
+ clausePtr = clausePtr->next) {
+ for (GlobPattern *globPtr = clausePtr->patterns; globPtr;
+ globPtr = globPtr->next) {
+ str = globPtr->pattern;
+ while (*str && (*str == '*' || *str == '.')) {
+ str++;
+ }
+ if (*str) {
+ type = [[NSString alloc] initWithUTF8String:str];
+ if (![fileTypes containsObject:type]) {
+ [fileTypes addObject:type];
+ }
+ [type release];
+ }
+ }
+ }
+ }
+ [panel setAllowedFileTypes:fileTypes];
+ [panel setAllowsOtherFileTypes:YES];
}
- if (title) {
- CFRelease(title);
+ [panel setCanSelectHiddenExtension:YES];
+ [panel setExtensionHidden:NO];
+ if (cmdObj) {
+ callbackInfo = (FilePanelCallbackInfo *)
+ ckalloc(sizeof(FilePanelCallbackInfo));
+ if (Tcl_IsShared(cmdObj)) {
+ cmdObj = Tcl_DuplicateObj(cmdObj);
+ }
+ Tcl_IncrRefCount(cmdObj);
}
- if (message) {
- CFRelease(message);
+ callbackInfo->cmdObj = cmdObj;
+ callbackInfo->interp = interp;
+ callbackInfo->multiple = 0;
+ parent = TkMacOSXDrawableWindow(((TkWindow *) tkwin)->window);
+ if (haveParentOption && parent && ![parent attachedSheet]) {
+ [panel beginSheetForDirectory:directory file:filename
+ modalForWindow:parent modalDelegate:NSApp didEndSelector:
+ @selector(tkFilePanelDidEnd:returnCode:contextInfo:)
+ contextInfo:callbackInfo];
+ returnCode = cmdObj ? NSAlertOtherReturn :
+ [NSApp runModalForWindow:panel];
+ } else {
+ returnCode = [panel runModalForDirectory:directory file:filename];
+ [NSApp tkFilePanelDidEnd:panel returnCode:returnCode
+ contextInfo:callbackInfo];
}
+ result = (returnCode != NSAlertErrorReturn) ? TCL_OK : TCL_ERROR;
+end:
+ TkFreeFileFilters(&fl);
return result;
}
@@ -563,186 +700,109 @@ Tk_ChooseDirectoryObjCmd(
ClientData clientData, /* Main window associated with interpreter. */
Tcl_Interp *interp, /* Current interpreter. */
int objc, /* Number of arguments. */
- Tcl_Obj *CONST objv[]) /* Argument objects. */
+ Tcl_Obj *const objv[]) /* Argument objects. */
{
- int i, result = TCL_ERROR;
- Tk_Window parent = NULL;
- AEDesc initialDesc = {typeNull, NULL}, *initialPtr = NULL;
- FSRef dirRef;
- CFStringRef message = NULL, title = NULL;
- OpenFileData ofd;
- static const char *chooseOptionStrings[] = {
- "-initialdir", "-message", "-mustexist", "-parent", "-title", NULL
- };
- enum chooseOptions {
- CHOOSE_INITDIR, CHOOSE_MESSAGE, CHOOSE_MUSTEXIST, CHOOSE_PARENT,
- CHOOSE_TITLE
- };
-
- if (!fileDlgInited) {
- InitFileDialogs();
- }
+ Tk_Window tkwin = clientData;
+ char *str;
+ int i, result = TCL_ERROR, haveParentOption = 0;
+ int index, len, mustexist = 0;
+ Tcl_Obj *cmdObj = NULL;
+ FilePanelCallbackInfo callbackInfoStruct;
+ FilePanelCallbackInfo *callbackInfo = &callbackInfoStruct;
+ NSString *directory = nil, *filename = nil;
+ NSString *message, *title;
+ NSWindow *parent;
+ NSOpenPanel *panel = [NSOpenPanel openPanel];
+ NSInteger returnCode = NSAlertErrorReturn;
for (i = 1; i < objc; i += 2) {
- char *string, *choice;
- int index, choiceLen;
-
if (Tcl_GetIndexFromObj(interp, objv[i], chooseOptionStrings, "option",
TCL_EXACT, &index) != TCL_OK) {
goto end;
}
if (i + 1 == objc) {
- string = Tcl_GetString(objv[i]);
- Tcl_AppendResult(interp, "value for \"", string, "\" missing",
- NULL);
+ str = Tcl_GetString(objv[i]);
+ Tcl_AppendResult(interp, "value for \"", str, "\" missing", NULL);
goto end;
}
switch (index) {
case CHOOSE_INITDIR:
- choice = Tcl_GetStringFromObj(objv[i + 1], &choiceLen);
- if (choiceLen && HandleInitialDirectory(interp, NULL, choice,
- &dirRef, NULL, &initialDesc) != TCL_OK) {
- goto end;
+ str = Tcl_GetStringFromObj(objv[i + 1], &len);
+ if (len) {
+ directory = [[[NSString alloc] initWithUTF8String:str]
+ autorelease];
}
break;
case CHOOSE_MESSAGE:
- choice = Tcl_GetStringFromObj(objv[i + 1], &choiceLen);
- if (message) {
- CFRelease(message);
+ message = [[NSString alloc] initWithUTF8String:
+ Tcl_GetString(objv[i + 1])];
+ [panel setMessage:message];
+ [message release];
+ break;
+ case CHOOSE_MUSTEXIST:
+ if (Tcl_GetBooleanFromObj(interp, objv[i + 1],
+ &mustexist) != TCL_OK) {
+ goto end;
}
- message = CFStringCreateWithBytes(NULL, (unsigned char *) choice,
- choiceLen, kCFStringEncodingUTF8, false);
break;
case CHOOSE_PARENT:
- choice = Tcl_GetStringFromObj(objv[i + 1], &choiceLen);
- parent = Tk_NameToWindow(interp, choice, clientData);
- if (parent == NULL) {
+ str = Tcl_GetStringFromObj(objv[i + 1], &len);
+ tkwin = Tk_NameToWindow(interp, str, tkwin);
+ if (!tkwin) {
goto end;
}
+ haveParentOption = 1;
break;
case CHOOSE_TITLE:
- choice = Tcl_GetStringFromObj(objv[i + 1], &choiceLen);
- if (title) {
- CFRelease(title);
- }
- title = CFStringCreateWithBytes(NULL, (unsigned char *) choice,
- choiceLen, kCFStringEncodingUTF8, false);
+ title = [[NSString alloc] initWithUTF8String:
+ Tcl_GetString(objv[i + 1])];
+ [panel setTitle:title];
+ [title release];
+ break;
+ case CHOOSE_COMMAND:
+ cmdObj = objv[i+1];
break;
}
}
-
- TkInitFileFilters(&ofd.fl);
- ofd.usePopup = 0;
- if (initialDesc.descriptorType == typeFSRef) {
- initialPtr = &initialDesc;
- }
- result = NavServicesGetFile(interp, &ofd, initialPtr, NULL, NULL, title,
- message, NULL, false, false, CHOOSE_FOLDER, parent);
- TkFreeFileFilters(&ofd.fl);
- end:
- if (initialDesc.dataHandle) {
- ChkErr(AEDisposeDesc, &initialDesc);
- }
- if (title) {
- CFRelease(title);
- }
- if (message) {
- CFRelease(message);
- }
- return result;
-}
-
-/*
- *----------------------------------------------------------------------
- *
- * HandleInitialDirectory --
- *
- * Helper for -initialdir setup.
- *
- * Results:
- * Tcl result.
- *
- * Side effects:
- * None.
- *
- *----------------------------------------------------------------------
- */
-
-int
-HandleInitialDirectory(
- Tcl_Interp *interp,
- char *initialFile,
- char *initialDir,
- FSRef *dirRef,
- AEDescList *selectDescPtr,
- AEDesc *dirDescPtr)
-{
- Tcl_DString ds;
- OSStatus err;
- Boolean isDirectory;
- char *dirName = NULL;
- int result = TCL_ERROR;
-
- if (initialDir) {
- dirName = Tcl_TranslateFileName(interp, initialDir, &ds);
- if (dirName == NULL) {
- goto end;
- }
- err = ChkErr(FSPathMakeRef, (unsigned char *) dirName, dirRef,
- &isDirectory);
- if (err != noErr) {
- Tcl_AppendResult(interp, "bad directory \"", initialDir, "\"",
- NULL);
- goto end;
- }
- if (!isDirectory) {
- Tcl_AppendResult(interp, "-intialdir \"", initialDir, "\""
- " is a file, not a directory.", NULL);
- goto end;
- }
- ChkErr(AECreateDesc, typeFSRef, dirRef, sizeof(*dirRef), dirDescPtr);
- }
-
- if (initialFile && selectDescPtr) {
- FSRef fileRef;
- AEDesc fileDesc;
- char *namePtr;
-
- if (initialDir) {
- Tcl_DStringAppend(&ds, "/", 1);
- Tcl_DStringAppend(&ds, initialFile, -1);
- namePtr = Tcl_DStringValue(&ds);
- } else {
- namePtr = initialFile;
+ [panel setPrompt:@"Choose"];
+ [panel setCanChooseFiles:NO];
+ [panel setCanChooseDirectories:YES];
+ [panel setCanCreateDirectories:!mustexist];
+ if (cmdObj) {
+ callbackInfo = (FilePanelCallbackInfo *)
+ ckalloc(sizeof(FilePanelCallbackInfo));
+ if (Tcl_IsShared(cmdObj)) {
+ cmdObj = Tcl_DuplicateObj(cmdObj);
}
-
- ChkErr(AECreateList, NULL, 0, false, selectDescPtr);
-
- err = ChkErr(FSPathMakeRef, (unsigned char *) namePtr, &fileRef,
- &isDirectory);
- if (err != noErr) {
- Tcl_AppendResult(interp, "bad initialfile \"", initialFile,
- "\" file does not exist.", NULL);
- goto end;
- }
- ChkErr(AECreateDesc, typeFSRef, &fileRef, sizeof(fileRef), &fileDesc);
- ChkErr(AEPutDesc, selectDescPtr, 1, &fileDesc);
- ChkErr(AEDisposeDesc, &fileDesc);
+ Tcl_IncrRefCount(cmdObj);
}
- result = TCL_OK;
- end:
- if (dirName) {
- Tcl_DStringFree(&ds);
+ callbackInfo->cmdObj = cmdObj;
+ callbackInfo->interp = interp;
+ callbackInfo->multiple = 0;
+ parent = TkMacOSXDrawableWindow(((TkWindow *) tkwin)->window);
+ if (haveParentOption && parent && ![parent attachedSheet]) {
+ [panel beginSheetForDirectory:directory file:filename
+ modalForWindow:parent modalDelegate:NSApp didEndSelector:
+ @selector(tkFilePanelDidEnd:returnCode:contextInfo:)
+ contextInfo:callbackInfo];
+ returnCode = cmdObj ? NSAlertOtherReturn :
+ [NSApp runModalForWindow:panel];
+ } else {
+ returnCode = [panel runModalForDirectory:directory file:filename];
+ [NSApp tkFilePanelDidEnd:panel returnCode:returnCode
+ contextInfo:callbackInfo];
}
+ result = (returnCode != NSAlertErrorReturn) ? TCL_OK : TCL_ERROR;
+end:
return result;
}
/*
*----------------------------------------------------------------------
*
- * InitFileDialogs --
+ * TkAboutDlg --
*
- * Initialize file dialog subsystem.
+ * Displays the default Tk About box.
*
* Results:
* None.
@@ -754,634 +814,74 @@ HandleInitialDirectory(
*/
void
-InitFileDialogs(void)
-{
- fileDlgInited = 1;
- openFileFilterUPP = NewNavObjectFilterUPP(OpenFileFilterProc);
- openFileEventUPP = NewNavEventUPP(OpenEventProc);
-}
-
-/*
- *----------------------------------------------------------------------
- *
- * NavServicesGetFile --
- *
- * Common wrapper for NavServices API.
- *
- * Results:
- * Tcl result.
- *
- * Side effects:
- * None.
- *
- *----------------------------------------------------------------------
- */
-
-int
-NavServicesGetFile(
- Tcl_Interp *interp,
- OpenFileData *ofdPtr,
- AEDesc *initialDescPtr,
- char *initialFile,
- AEDescList *selectDescPtr,
- CFStringRef title,
- CFStringRef message,
- const char *initialtype,
- int multiple,
- int confirmOverwrite,
- int isOpen,
- Tk_Window parent)
+TkAboutDlg(void)
{
- NavHandlerUserData data;
- NavDialogCreationOptions options;
- NavDialogRef dialogRef = NULL;
- CFStringRef *menuItemNames = NULL;
- OSStatus err;
- Tcl_Obj *theResult = NULL;
- int result = TCL_ERROR;
-
- bzero(&data, sizeof(data));
- err = NavGetDefaultDialogCreationOptions(&options);
- if (err != noErr) {
- return result;
- }
- options.optionFlags = kNavDontAutoTranslate | kNavDontAddTranslateItems
- | kNavSupportPackages | kNavAllFilesInPopup;
- if (multiple) {
- options.optionFlags |= kNavAllowMultipleFiles;
- }
- if (!confirmOverwrite) {
- options.optionFlags |= kNavDontConfirmReplacement;
- }
- options.modality = kWindowModalityAppModal;
- if (parent && ((TkWindow *) parent)->window != None &&
- TkMacOSXHostToplevelExists(parent)) {
- options.parentWindow = TkMacOSXDrawableWindow(Tk_WindowId(parent));
- TK_IF_HI_TOOLBOX (5,
- /*
- * Impossible to modify dialog modality with the Cocoa-based
- * NavServices implementation.
- */
- ) TK_ELSE_HI_TOOLBOX (5,
- if (options.parentWindow) {
- options.modality = kWindowModalityWindowModal;
- data.sheet = 1;
- }
- ) TK_ENDIF
- }
-
- /*
- * Now process the selection list. We have to use the popupExtension
- * to fill the menu.
- */
-
- if (ofdPtr && ofdPtr->usePopup) {
- FileFilter *filterPtr = ofdPtr->fl.filters;
-
- if (filterPtr == NULL) {
- ofdPtr->usePopup = 0;
- }
- }
- if (ofdPtr && ofdPtr->usePopup) {
- FileFilter *filterPtr;
- int index = 0;
- ofdPtr->curType = 0;
-
- menuItemNames = (CFStringRef *)
- ckalloc(ofdPtr->fl.numFilters * sizeof(CFStringRef));
-
- for (filterPtr = ofdPtr->fl.filters; filterPtr != NULL;
- filterPtr = filterPtr->next, index++) {
- menuItemNames[index] = CFStringCreateWithCString(NULL,
- filterPtr->name, kCFStringEncodingUTF8);
- if (initialtype && strcmp(filterPtr->name, initialtype) == 0) {
- ofdPtr->initialType = index;
- }
- }
- options.popupExtension = CFArrayCreate(NULL,
- (const void **) menuItemNames, ofdPtr->fl.numFilters, NULL);
- } else {
- options.optionFlags |= kNavNoTypePopup;
- options.popupExtension = NULL;
- }
- options.clientName = CFSTR("Wish");
- options.message = message;
- options.windowTitle = title;
- if (initialFile) {
- options.saveFileName = CFStringCreateWithCString(NULL, initialFile,
- kCFStringEncodingUTF8);
+ NSImage *image;
+ NSString *path = [NSApp tkFrameworkImagePath:@"Tk.tiff"];
+ if (path) {
+ image = [[[NSImage alloc] initWithContentsOfFile:path] autorelease];
} else {
- options.saveFileName = NULL;
- }
- if (isOpen == OPEN_FILE) {
- data.ofdPtr = ofdPtr;
- err = ChkErr(NavCreateGetFileDialog, &options, NULL,
- openFileEventUPP, NULL, openFileFilterUPP, &data, &dialogRef);
- } else if (isOpen == SAVE_FILE) {
- err = ChkErr(NavCreatePutFileDialog, &options, 'TEXT', 'WIsH',
- openFileEventUPP, &data, &dialogRef);
- } else if (isOpen == CHOOSE_FOLDER) {
- err = ChkErr(NavCreateChooseFolderDialog, &options,
- openFileEventUPP, openFileFilterUPP, &data, &dialogRef);
- }
- if (err == noErr && dialogRef) {
- if (initialDescPtr) {
- ChkErr(NavCustomControl, dialogRef, kNavCtlSetLocation,
- initialDescPtr);
- }
- if (selectDescPtr && selectDescPtr->descriptorType != typeNull) {
- ChkErr(NavCustomControl, dialogRef, kNavCtlSetSelection,
- selectDescPtr);
- }
- TkMacOSXTrackingLoop(1);
- err = ChkErr(NavDialogRun, dialogRef);
- if (err == noErr) {
- if (data.sheet) {
- data.dialogWindow = NavDialogGetWindow(dialogRef);
- ChkErr(GetWindowModality, data.dialogWindow,
- &data.origModality, &data.origUnavailWindow);
- ChkErr(SetWindowModality, data.dialogWindow,
- kWindowModalityAppModal, NULL);
- ChkErr(RunAppModalLoopForWindow, data.dialogWindow);
- }
- err = data.err;
- }
- TkMacOSXTrackingLoop(0);
- }
-
- /*
- * Most commands assume that the file dialogs return a single item, not a
- * list. So only build a list if multiple is true...
- */
-
- if (err == noErr) {
- if (multiple) {
- theResult = Tcl_NewListObj(0, NULL);
- } else {
- theResult = Tcl_NewObj();
- }
- if (!theResult) {
- err = memFullErr;
- }
+ image = [NSApp applicationIconImage];
}
- if (err == noErr && data.reply.validRecord) {
- AEDesc resultDesc;
- long count, i;
- FSRef fsRef;
- char pathPtr[PATH_MAX + 1];
- char saveName[PATH_MAX + 1];
-
- err = ChkErr(AECountItems, &data.reply.selection, &count);
- if (err != noErr) {
- /*
- * There was an error when counting the items? Treat as if no
- * items were chosen.
- */
-
- goto installResult;
- }
-
- /*
- * Process the chosen files. This will be one unless -multiple was
- * specified.
- */
-
- for (i = 1; i <= count; i++) {
- /*
- * Get the name of the selected file.
- */
-
- err = ChkErr(AEGetNthDesc, &data.reply.selection, i,
- typeFSRef, NULL, &resultDesc);
- if (err != noErr) {
- continue;
- }
- err = ChkErr(AEGetDescData, &resultDesc, &fsRef, sizeof(fsRef));
- if (err != noErr) {
- goto nextFilename;
- }
- err = ChkErr(FSRefMakePath, &fsRef, (unsigned char *) pathPtr,
- PATH_MAX + 1);
- if (err != noErr) {
- goto nextFilename;
- }
-
- /*
- * If we're saving the file, we're creating a new filename and
- * must therefore check whether it is a legal filename (not
- * exceeding path length limits, etc.)
- */
-
- if (isOpen == SAVE_FILE) {
- if (!data.saveNameRef) {
- TkMacOSXDbgMsg("NavDialogGetSaveFileName failed");
- goto nextFilename;
- }
-
- if (!CFStringGetCString(data.saveNameRef, saveName,
- PATH_MAX + 1, kCFStringEncodingUTF8)) {
- TkMacOSXDbgMsg("CFStringGetCString failed");
- goto nextFilename;
- }
-
- if (strlen(pathPtr) + strlen(saveName) >= PATH_MAX) {
- TkMacOSXDbgMsg("Path name too long");
- goto nextFilename;
- }
-
- strcat(pathPtr, "/");
- strcat(pathPtr, saveName);
- }
-
- /*
- * Got a valid file name; put it in the result object.
- */
-
- if (multiple) {
- Tcl_ListObjAppendElement(interp, theResult,
- Tcl_NewStringObj(pathPtr, -1));
- } else {
- Tcl_SetStringObj(theResult, pathPtr, -1);
- }
-
- nextFilename:
- ChkErr(AEDisposeDesc, &resultDesc);
- }
-
- installResult:
- Tcl_SetObjResult(interp, theResult);
- result = TCL_OK;
- } else if (err == userCanceledErr) {
- Tcl_ResetResult(interp);
- result = TCL_OK;
- }
-
- /*
- * Clean up any allocated memory.
- */
-
- if (data.reply.validRecord) {
- ChkErr(NavDisposeReply, &data.reply);
- }
- if (data.saveNameRef) {
- CFRelease(data.saveNameRef);
- }
- if (options.saveFileName) {
- CFRelease(options.saveFileName);
- }
- if (options.clientName) {
- CFRelease(options.clientName);
- }
- if (menuItemNames) {
- int i;
-
- for (i = 0; i < ofdPtr->fl.numFilters; i++) {
- CFRelease(menuItemNames[i]);
- }
- ckfree((void *) menuItemNames);
- }
- if (options.popupExtension) {
- CFRelease(options.popupExtension);
- }
- return result;
+ NSDateFormatter *dateFormatter = [[NSDateFormatter alloc] init];
+ [dateFormatter setFormatterBehavior:NSDateFormatterBehavior10_4];
+ [dateFormatter setDateFormat:@"Y"];
+ NSString *year = [dateFormatter stringFromDate:[NSDate date]];
+ [dateFormatter release];
+ NSMutableParagraphStyle *style = [[[NSParagraphStyle defaultParagraphStyle]
+ mutableCopy] autorelease];
+ [style setAlignment:NSCenterTextAlignment];
+ NSDictionary *options = [NSDictionary dictionaryWithObjectsAndKeys:
+ @"Tcl & Tk", @"ApplicationName",
+ @"Tcl " TCL_VERSION " & Tk " TK_VERSION, @"ApplicationVersion",
+ @TK_PATCH_LEVEL, @"Version",
+ image, @"ApplicationIcon",
+ [NSString stringWithFormat:@"Copyright %1$C 1987-%2$@.", 0xA9,
+ year], @"Copyright",
+ [[[NSAttributedString alloc] initWithString:
+ [NSString stringWithFormat:
+ @"%1$C 1987-%2$@ Tcl Core Team." "\n\n"
+ "%1$C 2002-%2$@ 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:
+ [NSDictionary dictionaryWithObject:style
+ forKey:NSParagraphStyleAttributeName]] autorelease], @"Credits",
+ nil];
+ [NSApp orderFrontStandardAboutPanelWithOptions:options];
}
/*
*----------------------------------------------------------------------
*
- * OpenEventProc --
+ * TkMacOSXStandardAboutPanelObjCmd --
*
- * NavServices event handling callback.
+ * Implements the ::tk::mac::standardAboutPanel command.
*
* Results:
- * None.
- *
- * Side effects:
- * None.
- *
- *----------------------------------------------------------------------
- */
-
-pascal void
-OpenEventProc(
- NavEventCallbackMessage callBackSelector,
- NavCBRecPtr callBackParams,
- NavCallBackUserData callBackUD)
-{
- NavHandlerUserData *data = (NavHandlerUserData*) callBackUD;
- OpenFileData *ofd = data->ofdPtr;
-
- switch (callBackSelector) {
- case kNavCBStart:
- if (ofd && ofd->initialType >= 0) {
- /* Select initial filter */
- FileFilter *filterPtr = ofd->fl.filters;
- int i = ofd->initialType;
-
- while (filterPtr && i-- > 0) {
- filterPtr = filterPtr->next;
- }
- if (filterPtr) {
- NavMenuItemSpec selectItem;
-
- selectItem.version = kNavMenuItemSpecVersion;
- selectItem.menuCreator = 0;
- selectItem.menuType = ofd->initialType;
- selectItem.menuItemName[0] = strlen(filterPtr->name);
- strncpy((char *) &selectItem.menuItemName[1],
- filterPtr->name, 255);
- ChkErr(NavCustomControl, callBackParams->context,
- kNavCtlSelectCustomType, &selectItem);
- }
- }
- break;
- case kNavCBPopupMenuSelect:
- ofd->curType = ((NavMenuItemSpec *)
- callBackParams->eventData.eventDataParms.param)->menuType;
- break;
- case kNavCBAccept:
- case kNavCBCancel:
- if (data->sheet) {
- ChkErr(QuitAppModalLoopForWindow, data->dialogWindow);
- ChkErr(SetWindowModality, data->dialogWindow,
- data->origModality, data->origUnavailWindow);
- }
- break;
- case kNavCBUserAction:
- if (data->reply.validRecord) {
- ChkErr(NavDisposeReply, &data->reply);
- data->reply.validRecord = 0;
- }
- data->err = NavDialogGetReply(callBackParams->context,
- &data->reply);
- if (callBackParams->userAction == kNavUserActionSaveAs) {
- data->saveNameRef = NavDialogGetSaveFileName(
- callBackParams->context);
- if (data->saveNameRef) {
- CFRetain(data->saveNameRef);
- }
- }
- break;
- case kNavCBTerminate:
- NavDialogDispose(callBackParams->context);
- break;
- case kNavCBEvent:
- TkMacOSXRunTclEventLoop();
- break;
- }
-}
-
-/*
- *----------------------------------------------------------------------
- *
- * OpenFileFilterProc --
- *
- * NavServices file filter callback.
- *
- * Results:
- * Whether to use the file in question.
- *
- * Side effects:
- * None.
- *
- *----------------------------------------------------------------------
- */
-
-pascal Boolean
-OpenFileFilterProc(
- AEDesc *theItem,
- void *info,
- NavCallBackUserData callBackUD,
- NavFilterModes filterMode)
-{
- OpenFileData *ofdPtr = ((NavHandlerUserData *) callBackUD)->ofdPtr;
- int result = MATCHED;
-
- if (ofdPtr && ofdPtr->usePopup && ofdPtr->fl.numFilters > 0 &&
- ((theItem->descriptorType == typeFSS)
- || (theItem->descriptorType == typeFSRef))) {
- NavFileOrFolderInfo *theInfo = info;
- char fileName[256];
- OSType fileType;
- StringPtr fileNamePtr = NULL;
- Tcl_DString fileNameDString;
- int i;
- FileFilter *filterPtr;
-
- if (!theInfo->isFolder) {
- fileType = theInfo->fileAndFolder.fileInfo.finderInfo.fdType;
- Tcl_DStringInit(&fileNameDString);
-
- if (theItem->descriptorType == typeFSS) {
- int len;
-
- fileNamePtr = ((FSSpec *) *theItem->dataHandle)->name;
- len = fileNamePtr[0];
- strncpy(fileName, (char *) fileNamePtr + 1, len);
- fileName[len] = '\0';
- fileNamePtr = (unsigned char *) fileName;
- } else if ((theItem->descriptorType == typeFSRef)) {
- OSStatus err;
- FSRef *theRef = (FSRef *) *theItem->dataHandle;
- HFSUniStr255 uniFileName;
-
- err = ChkErr(FSGetCatalogInfo, theRef, kFSCatInfoNone,
- NULL, &uniFileName, NULL, NULL);
-
- if (err == noErr) {
- Tcl_UniCharToUtfDString((Tcl_UniChar *)uniFileName.unicode,
- uniFileName.length, &fileNameDString);
- fileNamePtr = (unsigned char *)
- Tcl_DStringValue(&fileNameDString);
- }
- }
- if (ofdPtr->usePopup) {
- i = ofdPtr->curType;
- for (filterPtr = ofdPtr->fl.filters; filterPtr && i>0; i--) {
- filterPtr = filterPtr->next;
- }
- if (filterPtr) {
- result = MatchOneType(fileNamePtr, fileType, ofdPtr,
- filterPtr);
- } else {
- result = UNMATCHED;
- }
- } else {
- /*
- * We are not using the popup menu. In this case, the file is
- * considered matched if it matches any of the file filters.
- */
-
- result = UNMATCHED;
- for (filterPtr = ofdPtr->fl.filters; filterPtr;
- filterPtr = filterPtr->next) {
- if (MatchOneType(fileNamePtr, fileType, ofdPtr,
- filterPtr) == MATCHED) {
- result = MATCHED;
- break;
- }
- }
- }
- Tcl_DStringFree(&fileNameDString);
- }
- }
- return (result == MATCHED);
-}
-
-/*
- *----------------------------------------------------------------------
- *
- * MatchOneType --
- *
- * Match a file with one file type in the list of file types.
- *
- * Results:
- * Returns MATCHED if the file matches with the file type; returns
- * UNMATCHED otherwise.
- *
- * Side effects:
- * None
- *
- *----------------------------------------------------------------------
- */
-
-Boolean
-MatchOneType(
- StringPtr fileNamePtr, /* Name of the file */
- OSType fileType, /* Type of the file, 0 means there was no
- * specified type. */
- OpenFileData *ofdPtr, /* Information about this file dialog */
- FileFilter *filterPtr) /* Match the file described by pb against this
- * filter */
-{
- FileFilterClause *clausePtr;
-
- /*
- * A file matches with a file type if it matches with at least one clause
- * of the type.
- *
- * If the clause has both glob patterns and ostypes, the file must match
- * with at least one pattern AND at least one ostype.
- *
- * If the clause has glob patterns only, the file must match with at least
- * one pattern.
- *
- * If the clause has mac types only, the file must match with at least one
- * mac type.
- *
- * If the clause has neither glob patterns nor mac types, it's considered
- * an error.
- */
-
- for (clausePtr = filterPtr->clauses; clausePtr;
- clausePtr = clausePtr->next) {
- int macMatched = 0;
- int globMatched = 0;
- GlobPattern *globPtr;
- MacFileType *mfPtr;
-
- if (clausePtr->patterns == NULL) {
- globMatched = 1;
- }
- if (clausePtr->macTypes == NULL) {
- macMatched = 1;
- }
-
- for (globPtr = clausePtr->patterns; globPtr;
- globPtr = globPtr->next) {
- char *q, *ext;
-
- if (fileNamePtr == NULL) {
- continue;
- }
- ext = globPtr->pattern;
-
- if (ext[0] == '\0') {
- /*
- * We don't want any extensions: OK if the filename doesn't
- * have "." in it
- */
-
- for (q = (char*) fileNamePtr; *q; q++) {
- if (*q == '.') {
- goto glob_unmatched;
- }
- }
- goto glob_matched;
- }
-
- if (Tcl_StringMatch((char*) fileNamePtr, ext)) {
- goto glob_matched;
- }
- glob_unmatched:
- continue;
-
- glob_matched:
- globMatched = 1;
- break;
- }
-
- for (mfPtr = clausePtr->macTypes; mfPtr; mfPtr = mfPtr->next) {
- if (fileType == mfPtr->type) {
- macMatched = 1;
- break;
- }
- }
-
- /*
- * On Mac OS X, it is not uncommon for files to have NO file type. But
- * folks with Tcl code on Classic MacOS pretty much assume that a
- * generic file will have type TEXT. So if we were strict about
- * matching types when the source file had NO type set, they would
- * have to add another rule always with no fileType. To avoid that, we
- * pass the macMatch side of the test if no fileType is set.
- */
-
- if (globMatched && (macMatched || (fileType == 0))) {
- return MATCHED;
- }
- }
-
- return UNMATCHED;
-}
-
-/*
- *----------------------------------------------------------------------
- *
- * TkAboutDlg --
- *
- * Displays the default Tk About box. This code uses Macintosh resources
- * to define the content of the About Box.
- *
- * Results:
- * None.
+ * A standard Tcl result.
*
* Side effects:
- * None.
+ * none
*
*----------------------------------------------------------------------
*/
-void
-TkAboutDlg(void)
+int
+TkMacOSXStandardAboutPanelObjCmd(
+ ClientData clientData, /* Unused. */
+ Tcl_Interp *interp, /* Current interpreter. */
+ int objc, /* Number of arguments. */
+ Tcl_Obj *const objv[]) /* Argument objects. */
{
- DialogPtr aboutDlog;
- WindowRef windowRef;
- short itemHit = -9;
-
- aboutDlog = GetNewDialog(TK_DEFAULT_ABOUT, NULL, (void *) (-1));
- if (!aboutDlog) {
- return;
- }
- windowRef = GetDialogWindow(aboutDlog);
- SelectWindow(windowRef);
- TkMacOSXTrackingLoop(1);
- while (itemHit != 1) {
- ModalDialog(NULL, &itemHit);
+ if (objc > 1) {
+ Tcl_WrongNumArgs(interp, 1, objv, NULL);
+ return TCL_ERROR;
}
- TkMacOSXTrackingLoop(0);
- DisposeDialog(aboutDlog);
- SelectWindow(ActiveNonFloatingWindow());
+ [NSApp orderFrontStandardAboutPanelWithOptions:nil];
+ return TCL_OK;
}
/*
@@ -1405,106 +905,33 @@ Tk_MessageBoxObjCmd(
ClientData clientData, /* Main window associated with interpreter. */
Tcl_Interp *interp, /* Current interpreter. */
int objc, /* Number of arguments. */
- Tcl_Obj *CONST objv[]) /* Argument objects. */
+ Tcl_Obj *const objv[]) /* Argument objects. */
{
Tk_Window tkwin = clientData;
- AlertStdCFStringAlertParamRec paramCFStringRec;
- AlertType alertType;
- DialogRef dialogRef;
- CFStringRef messageTextCF = NULL, finemessageTextCF = NULL;
- OSStatus err;
- SInt16 itemHit;
- Boolean haveDefaultOption = false, haveParentOption = false;
char *str;
- int index, defaultButtonIndex;
- int defaultNativeButtonIndex; /* 1, 2, 3: right to left */
- int typeIndex, i, indexDefaultOption = 0, result = TCL_ERROR;
-
- static const char *movableAlertStrings[] = {
- "-default", "-detail", "-icon", "-message", "-parent", "-title",
- "-type", NULL
- };
- static const char *movableTypeStrings[] = {
- "abortretryignore", "ok", "okcancel", "retrycancel", "yesno",
- "yesnocancel", NULL
- };
- static const char *movableButtonStrings[] = {
- "abort", "retry", "ignore", "ok", "cancel", "yes", "no", NULL
- };
- static const char *movableIconStrings[] = {
- "error", "info", "question", "warning", NULL
- };
- enum movableAlertOptions {
- ALERT_DEFAULT, ALERT_DETAIL, ALERT_ICON, ALERT_MESSAGE, ALERT_PARENT,
- ALERT_TITLE, ALERT_TYPE
- };
- enum movableTypeOptions {
- TYPE_ABORTRETRYIGNORE, TYPE_OK, TYPE_OKCANCEL, TYPE_RETRYCANCEL,
- TYPE_YESNO, TYPE_YESNOCANCEL
- };
- enum movableButtonOptions {
- TEXT_ABORT, TEXT_RETRY, TEXT_IGNORE, TEXT_OK, TEXT_CANCEL, TEXT_YES,
- TEXT_NO
- };
- enum movableIconOptions {
- ICON_ERROR, ICON_INFO, ICON_QUESTION, ICON_WARNING
- };
-
- /*
- * Need to map from 'movableButtonStrings' and its corresponding integer,
- * index to the native button index, which is 1, 2, 3, from right to left.
- * This is necessary to do for each separate '-type' of button sets.
- */
-
- short buttonIndexAndTypeToNativeButtonIndex[][7] = {
- /* abort retry ignore ok cancel yes no */
- {1, 2, 3, 0, 0, 0, 0}, /* abortretryignore */
- {0, 0, 0, 1, 0, 0, 0}, /* ok */
- {0, 0, 0, 1, 2, 0, 0}, /* okcancel */
- {0, 1, 0, 0, 2, 0, 0}, /* retrycancel */
- {0, 0, 0, 0, 0, 1, 2}, /* yesno */
- {0, 0, 0, 0, 3, 1, 2}, /* yesnocancel */
- };
-
- /*
- * Need also the inverse mapping, from native button (1, 2, 3) to the
- * descriptive button text string index.
- */
-
- short nativeButtonIndexAndTypeToButtonIndex[][4] = {
- {-1, 0, 1, 2}, /* abortretryignore */
- {-1, 3, 0, 0}, /* ok */
- {-1, 3, 4, 0}, /* okcancel */
- {-1, 1, 4, 0}, /* retrycancel */
- {-1, 5, 6, 0}, /* yesno */
- {-1, 5, 6, 4}, /* yesnocancel */
- };
-
- alertType = kAlertPlainAlert;
+ int i, result = TCL_ERROR, haveParentOption = 0;
+ int index, typeIndex, iconIndex, indexDefaultOption = 0;
+ int defaultNativeButtonIndex = 1; /* 1, 2, 3: right to left */
+ Tcl_Obj *cmdObj = NULL;
+ AlertCallbackInfo callbackInfoStruct, *callbackInfo = &callbackInfoStruct;
+ NSString *message, *title;
+ NSWindow *parent;
+ NSArray *buttons;
+ NSAlert *alert = [NSAlert new];
+ NSInteger returnCode = NSAlertErrorReturn;
+
+ iconIndex = ICON_INFO;
typeIndex = TYPE_OK;
-
- ChkErr(GetStandardAlertDefaultParams, &paramCFStringRec,
- kStdCFStringAlertVersionOne);
- paramCFStringRec.movable = true;
- paramCFStringRec.helpButton = false;
- paramCFStringRec.defaultButton = kAlertStdAlertOKButton;
- paramCFStringRec.cancelButton = kAlertStdAlertCancelButton;
-
for (i = 1; i < objc; i += 2) {
- int iconIndex;
- char *string;
-
- if (Tcl_GetIndexFromObj(interp, objv[i], movableAlertStrings, "option",
+ if (Tcl_GetIndexFromObj(interp, objv[i], alertOptionStrings, "option",
TCL_EXACT, &index) != TCL_OK) {
goto end;
}
if (i + 1 == objc) {
- string = Tcl_GetString(objv[i]);
- Tcl_AppendResult(interp, "value for \"", string, "\" missing",
- NULL);
+ str = Tcl_GetString(objv[i]);
+ Tcl_AppendResult(interp, "value for \"", str, "\" missing", NULL);
goto end;
}
-
switch (index) {
case ALERT_DEFAULT:
/*
@@ -1512,111 +939,65 @@ Tk_MessageBoxObjCmd(
* know the '-type' as well.
*/
- haveDefaultOption = true;
indexDefaultOption = i;
break;
case ALERT_DETAIL:
- str = Tcl_GetString(objv[i + 1]);
- if (finemessageTextCF) {
- CFRelease(finemessageTextCF);
- }
- finemessageTextCF = CFStringCreateWithCString(NULL, str,
- kCFStringEncodingUTF8);
+ message = [[NSString alloc] initWithUTF8String:
+ Tcl_GetString(objv[i + 1])];
+ [alert setInformativeText:message];
+ [message release];
break;
case ALERT_ICON:
- if (Tcl_GetIndexFromObj(interp, objv[i + 1], movableIconStrings,
+ if (Tcl_GetIndexFromObj(interp, objv[i + 1], alertIconStrings,
"value", TCL_EXACT, &iconIndex) != TCL_OK) {
goto end;
}
- switch (iconIndex) {
- case ICON_ERROR:
- alertType = kAlertStopAlert;
- break;
- case ICON_INFO:
- alertType = kAlertNoteAlert;
- break;
- case ICON_QUESTION:
- alertType = kAlertCautionAlert;
- break;
- case ICON_WARNING:
- alertType = kAlertCautionAlert;
- break;
- }
break;
case ALERT_MESSAGE:
- str = Tcl_GetString(objv[i + 1]);
- if (messageTextCF) {
- CFRelease(messageTextCF);
- }
- messageTextCF = CFStringCreateWithCString(NULL, str,
- kCFStringEncodingUTF8);
+ message = [[NSString alloc] initWithUTF8String:
+ Tcl_GetString(objv[i + 1])];
+ [alert setMessageText:message];
+ [message release];
break;
case ALERT_PARENT:
str = Tcl_GetString(objv[i + 1]);
tkwin = Tk_NameToWindow(interp, str, tkwin);
- if (tkwin == NULL) {
+ if (!tkwin) {
goto end;
}
- if (((TkWindow *) tkwin)->window != None &&
- TkMacOSXHostToplevelExists(tkwin)) {
- haveParentOption = true;
- }
+ haveParentOption = 1;
break;
case ALERT_TITLE:
+ title = [[NSString alloc] initWithUTF8String:
+ Tcl_GetString(objv[i + 1])];
+ [[alert window] setTitle:title];
+ [title release];
break;
case ALERT_TYPE:
- if (Tcl_GetIndexFromObj(interp, objv[i + 1], movableTypeStrings,
+ if (Tcl_GetIndexFromObj(interp, objv[i + 1], alertTypeStrings,
"value", TCL_EXACT, &typeIndex) != TCL_OK) {
goto end;
}
- switch (typeIndex) {
- case TYPE_ABORTRETRYIGNORE:
- paramCFStringRec.defaultText = CFSTR("Abort");
- paramCFStringRec.cancelText = CFSTR("Retry");
- paramCFStringRec.otherText = CFSTR("Ignore");
- paramCFStringRec.cancelButton = kAlertStdAlertOtherButton;
- break;
- case TYPE_OK:
- paramCFStringRec.defaultText = CFSTR("OK");
- break;
- case TYPE_OKCANCEL:
- paramCFStringRec.defaultText = CFSTR("OK");
- paramCFStringRec.cancelText = CFSTR("Cancel");
- break;
- case TYPE_RETRYCANCEL:
- paramCFStringRec.defaultText = CFSTR("Retry");
- paramCFStringRec.cancelText = CFSTR("Cancel");
- break;
- case TYPE_YESNO:
- paramCFStringRec.defaultText = CFSTR("Yes");
- paramCFStringRec.cancelText = CFSTR("No");
- break;
- case TYPE_YESNOCANCEL:
- paramCFStringRec.defaultText = CFSTR("Yes");
- paramCFStringRec.cancelText = CFSTR("No");
- paramCFStringRec.otherText = CFSTR("Cancel");
- paramCFStringRec.cancelButton = kAlertStdAlertOtherButton;
- break;
- }
+ break;
+ case ALERT_COMMAND:
+ cmdObj = objv[i+1];
break;
}
}
-
- if (haveDefaultOption) {
+ if (indexDefaultOption) {
/*
* Any '-default' option needs to know the '-type' option, which is why
* we do this here.
*/
- str = Tcl_GetString(objv[indexDefaultOption + 1]);
if (Tcl_GetIndexFromObj(interp, objv[indexDefaultOption + 1],
- movableButtonStrings, "value", TCL_EXACT, &defaultButtonIndex)
+ alertButtonStrings, "value", TCL_EXACT, &index)
!= TCL_OK) {
goto end;
}
@@ -1626,135 +1007,62 @@ Tk_MessageBoxObjCmd(
*/
defaultNativeButtonIndex =
- buttonIndexAndTypeToNativeButtonIndex[typeIndex][defaultButtonIndex];
- if (defaultNativeButtonIndex == 0) {
+ alertButtonIndexAndTypeToNativeButtonIndex[typeIndex][index];
+ if (!defaultNativeButtonIndex) {
Tcl_SetObjResult(interp,
Tcl_NewStringObj("Illegal default option", -1));
goto end;
}
- paramCFStringRec.defaultButton = defaultNativeButtonIndex;
- if (paramCFStringRec.cancelButton == defaultNativeButtonIndex) {
- paramCFStringRec.cancelButton = 0;
- }
}
- ChkErr(SetThemeCursor, kThemeArrowCursor);
-
- if (haveParentOption) {
- AlertHandlerUserData data;
- static EventHandlerUPP handler = NULL;
- WindowRef windowRef;
- const EventTypeSpec kEvents[] = {
- {kEventClassCommand, kEventProcessCommand}
- };
-
- bzero(&data, sizeof(data));
- if (!handler) {
- handler = NewEventHandlerUPP(AlertHandler);
- }
- windowRef = TkMacOSXDrawableWindow(Tk_WindowId(tkwin));
- if (!windowRef) {
- goto end;
- }
- err = ChkErr(CreateStandardSheet, alertType, messageTextCF,
- finemessageTextCF, &paramCFStringRec, NULL, &dialogRef);
- if(err != noErr) {
- goto end;
- }
- data.dialogWindow = GetDialogWindow(dialogRef);
- err = ChkErr(ShowSheetWindow, data.dialogWindow, windowRef);
- if(err != noErr) {
- DisposeDialog(dialogRef);
- goto end;
- }
- ChkErr(GetWindowModality, data.dialogWindow, &data.origModality,
- &data.origUnavailWindow);
- ChkErr(SetWindowModality, data.dialogWindow, kWindowModalityAppModal,
- NULL);
- ChkErr(InstallEventHandler, GetWindowEventTarget(data.dialogWindow),
- handler, GetEventTypeCount(kEvents), kEvents, &data,
- &data.handlerRef);
- TkMacOSXTrackingLoop(1);
- ChkErr(RunAppModalLoopForWindow, data.dialogWindow);
- TkMacOSXTrackingLoop(0);
- itemHit = data.buttonIndex;
- } else {
- err = ChkErr(CreateStandardAlert, alertType, messageTextCF,
- finemessageTextCF, &paramCFStringRec, &dialogRef);
- if(err != noErr) {
- goto end;
- }
- TkMacOSXTrackingLoop(1);
- err = ChkErr(RunStandardAlert, dialogRef, NULL, &itemHit);
- TkMacOSXTrackingLoop(0);
- if (err != noErr) {
- goto end;
- }
+ [alert setIcon:[NSApp applicationIconImage]];
+ [alert setAlertStyle:alertStyles[iconIndex]];
+ i = 0;
+ while (i < 3 && alertButtonNames[typeIndex][i]) {
+ [alert addButtonWithTitle:(NSString*)alertButtonNames[typeIndex][i++]];
}
- if (err == noErr) {
- /*
- * Map 'itemHit' (1, 2, 3) to descriptive text string.
- */
-
- int ind = nativeButtonIndexAndTypeToButtonIndex[typeIndex][itemHit];
-
- Tcl_SetObjResult(interp, Tcl_NewStringObj(movableButtonStrings[ind],
- -1));
- result = TCL_OK;
+ buttons = [alert buttons];
+ for (NSButton *b in buttons) {
+ NSString *ke = [b keyEquivalent];
+ if (([ke isEqualToString:@"\r"] || [ke isEqualToString:@"\033"]) &&
+ ![b keyEquivalentModifierMask]) {
+ [b setKeyEquivalent:@""];
+ }
}
-
- end:
- if (finemessageTextCF) {
- CFRelease(finemessageTextCF);
+ [[buttons objectAtIndex:[buttons count]-1] setKeyEquivalent:@"\033"];
+ [[buttons objectAtIndex:defaultNativeButtonIndex-1] setKeyEquivalent:@"\r"];
+ if (cmdObj) {
+ callbackInfo = (AlertCallbackInfo *) ckalloc(sizeof(AlertCallbackInfo));
+ if (Tcl_IsShared(cmdObj)) {
+ cmdObj = Tcl_DuplicateObj(cmdObj);
+ }
+ Tcl_IncrRefCount(cmdObj);
}
- if (messageTextCF) {
- CFRelease(messageTextCF);
+ callbackInfo->cmdObj = cmdObj;
+ callbackInfo->interp = interp;
+ callbackInfo->typeIndex = typeIndex;
+ parent = TkMacOSXDrawableWindow(((TkWindow *) tkwin)->window);
+ if (haveParentOption && parent && ![parent attachedSheet]) {
+ [alert beginSheetModalForWindow:parent modalDelegate:NSApp
+ didEndSelector:@selector(tkAlertDidEnd:returnCode:contextInfo:)
+ contextInfo:callbackInfo];
+ returnCode = cmdObj ? NSAlertOtherReturn :
+ [NSApp runModalForWindow:[alert window]];
+ } else {
+ returnCode = [alert runModal];
+ [NSApp tkAlertDidEnd:alert returnCode:returnCode
+ contextInfo:callbackInfo];
}
+ result = (returnCode != NSAlertErrorReturn) ? TCL_OK : TCL_ERROR;
+end:
+ [alert release];
return result;
}
/*
- *----------------------------------------------------------------------
- *
- * AlertHandler --
- *
- * Carbon event handler for the Standard Sheet dialog.
- *
- * Results:
- * OSStatus if event handled or not.
- *
- * Side effects:
- * May set userData.
- *
- *----------------------------------------------------------------------
+ * Local Variables:
+ * mode: c
+ * c-basic-offset: 4
+ * fill-column: 79
+ * coding: utf-8
+ * End:
*/
-
-OSStatus
-AlertHandler(
- EventHandlerCallRef callRef,
- EventRef eventRef,
- void *userData)
-{
- AlertHandlerUserData *data = userData;
- HICommand cmd;
-
- ChkErr(GetEventParameter,eventRef, kEventParamDirectObject, typeHICommand,
- NULL, sizeof(cmd), NULL, &cmd);
- switch (cmd.commandID) {
- case kHICommandOK:
- data->buttonIndex = 1;
- break;
- case kHICommandCancel:
- data->buttonIndex = 2;
- break;
- case kHICommandOther:
- data->buttonIndex = 3;
- break;
- }
- if (data->buttonIndex) {
- ChkErr(QuitAppModalLoopForWindow, data->dialogWindow);
- ChkErr(RemoveEventHandler, data->handlerRef);
- ChkErr(SetWindowModality, data->dialogWindow,
- data->origModality, data->origUnavailWindow);
- }
- return eventNotHandledErr;
-}
diff --git a/macosx/tkMacOSXDraw.c b/macosx/tkMacOSXDraw.c
index f17bcee..8183d6e 100644
--- a/macosx/tkMacOSXDraw.c
+++ b/macosx/tkMacOSXDraw.c
@@ -6,11 +6,13 @@
* Xlib functions.
*
* Copyright (c) 1995-1997 Sun Microsystems, Inc.
- * Copyright 2001, Apple Computer, Inc.
- * Copyright (c) 2006-2007 Daniel A. Steffen <das@users.sourceforge.net>
+ * Copyright 2001-2009, Apple Inc.
+ * Copyright (c) 2006-2009 Daniel A. Steffen <das@users.sourceforge.net>
*
* See the file "license.terms" for information on usage and redistribution
* of this file, and for a DISCLAIMER OF ALL WARRANTIES.
+ *
+ * RCS: @(#) $Id$
*/
#include "tkMacOSXPrivate.h"
@@ -20,6 +22,7 @@
/*
#ifdef TK_MAC_DEBUG
#define TK_MAC_DEBUG_DRAWING
+#define TK_MAC_DEBUG_IMAGE_DRAWING
#endif
*/
@@ -31,18 +34,6 @@
*/
#define NON_AA_CG_OFFSET .999
-/*
- * Temporary region that can be reused.
- */
-
-RgnHandle tkMacOSXtmpQdRgn = NULL;
-
-int tkMacOSXUseCGDrawing = 1;
-
-int tkPictureIsOpen;
-
-static PixPatHandle penPat = NULL, tmpPixPat = NULL;
-
static int cgAntiAliasLimit = 0;
#define notAA(w) ((w) < cgAntiAliasLimit)
@@ -54,7 +45,11 @@ static int useThemedFrame = 0;
*/
static void ClipToGC(Drawable d, GC gc, HIShapeRef *clipRgnPtr);
-static void NoQDClip(CGrafPtr port);
+static CGImageRef CreateCGImageWithXImage(XImage *ximage);
+static CGContextRef GetCGContextForDrawable(Drawable d);
+static void DrawCGImage(Drawable d, GC gc, CGContextRef context, CGImageRef image,
+ unsigned long imageForeground, unsigned long imageBackground,
+ CGRect imageBounds, CGRect srcBounds, CGRect dstBounds);
/*
@@ -87,11 +82,6 @@ TkMacOSXInitCGDrawing(
if (Tcl_CreateNamespace(interp, "::tk::mac", NULL, NULL) == NULL) {
Tcl_ResetResult(interp);
}
- if (Tcl_LinkVar(interp, "::tk::mac::useCGDrawing",
- (char *) &tkMacOSXUseCGDrawing, TCL_LINK_BOOLEAN) != TCL_OK) {
- Tcl_ResetResult(interp);
- }
- tkMacOSXUseCGDrawing = enable;
if (Tcl_LinkVar(interp, "::tk::mac::CGAntialiasLimit",
(char *) &cgAntiAliasLimit, TCL_LINK_INT) != TCL_OK) {
@@ -111,17 +101,14 @@ TkMacOSXInitCGDrawing(
(char *) &useThemedFrame, TCL_LINK_BOOLEAN) != TCL_OK) {
Tcl_ResetResult(interp);
}
-
- if (tkMacOSXtmpQdRgn == NULL) {
- tkMacOSXtmpQdRgn = NewRgn();
+#if TK_MAC_BUTTON_USE_COMPATIBILITY_METRICS
+ if (Tcl_LinkVar(interp, "::tk::mac::useCompatibilityMetrics",
+ (char *) &tkMacOSXUseCompatibilityMetrics, TCL_LINK_BOOLEAN)
+ != TCL_OK) {
+ Tcl_ResetResult(interp);
}
+#endif
}
-#ifdef TK_MAC_DEBUG_DRAWING
- TkMacOSXInitNamedDebugSymbol(QD, void, QD_DebugPrint, char*);
- if (QD_DebugPrint) {
- ; /* gdb: b *QD_DebugPrint */
- }
-#endif /* TK_MAC_DEBUG_WINDOWS */
return TCL_OK;
}
@@ -157,53 +144,76 @@ XCopyArea(
int dest_y)
{
TkMacOSXDrawingContext dc;
- MacDrawable *srcDraw = (MacDrawable *) src, *dstDraw = (MacDrawable *) dst;
+ MacDrawable *srcDraw = (MacDrawable *) src;
display->request++;
if (!width || !height) {
/* TkMacOSXDbgMsg("Drawing of emtpy area requested"); */
return;
}
- {
- CGrafPtr srcPort;
-
- srcPort = TkMacOSXGetDrawablePort(src);
- if (srcPort) {
- Rect srcRect, dstRect, *srcPtr = &srcRect, *dstPtr = &dstRect;
- const BitMap *srcBit, *dstBit;
- RGBColor black = {0, 0, 0}, white = {0xffff, 0xffff, 0xffff};
-
- if (!TkMacOSXSetupDrawingContext(dst, gc, 0, &dc)) {
- return;
+ if (srcDraw->flags & TK_IS_PIXMAP) {
+ if (!TkMacOSXSetupDrawingContext(dst, gc, 1, &dc)) {
+ return;
+ }
+ if (dc.context) {
+ CGImageRef img = TkMacOSXCreateCGImageWithDrawable(src);
+
+ if (img) {
+ DrawCGImage(dst, gc, dc.context, img, gc->foreground,
+ gc->background, CGRectMake(0, 0,
+ srcDraw->size.width, srcDraw->size.height),
+ CGRectMake(src_x, src_y, width, height),
+ CGRectMake(dest_x, dest_y, width, height));
+ CFRelease(img);
+ } else {
+ TkMacOSXDbgMsg("Invalid source drawable");
}
- if (dc.context) {
- TkMacOSXDbgMsg("Ignored CG drawing of QD drawable");
- goto end;
+ } else {
+ TkMacOSXDbgMsg("Invalid destination drawable");
+ }
+ TkMacOSXRestoreDrawingContext(&dc);
+ } else if (TkMacOSXDrawableWindow(src)) {
+ NSView *view = TkMacOSXDrawableView(srcDraw);
+ NSWindow *w = [view window];
+ NSInteger gs = [w windowNumber] > 0 ? [w gState] : 0;
+ /* // alternative using per-view gState:
+ NSInteger gs = [view gState];
+ if (!gs) {
+ [view allocateGState];
+ if ([view lockFocusIfCanDraw]) {
+ [view unlockFocus];
}
- if (!dc.port) {
- TkMacOSXDbgMsg("Invalid destination drawable");
- goto end;
+ gs = [view gState];
+ }
+ */
+ if (!gs || !TkMacOSXSetupDrawingContext(dst, gc, 1, &dc)) {
+ return;
+ }
+ if (dc.context) {
+ NSGraphicsContext *gc = nil;
+ CGFloat boundsH = [view bounds].size.height;
+ NSRect srcRect = NSMakeRect(srcDraw->xOff + src_x, boundsH -
+ height - (srcDraw->yOff + src_y), width, height);
+
+ if (((MacDrawable *) dst)->flags & TK_IS_PIXMAP) {
+ gc = [NSGraphicsContext graphicsContextWithGraphicsPort:
+ dc.context flipped:NO];
+ if (gc) {
+ [NSGraphicsContext saveGraphicsState];
+ [NSGraphicsContext setCurrentContext:gc];
+ }
}
- 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);
+ NSCopyBits(gs, srcRect, NSMakePoint(dest_x,
+ dc.portBounds.size.height - dest_y));
+ if (gc) {
+ [NSGraphicsContext restoreGraphicsState];
}
- RGBForeColor(&black);
- RGBBackColor(&white);
- CopyBits(srcBit, dstBit, srcPtr, dstPtr, srcCopy, NULL);
-end:
- TkMacOSXRestoreDrawingContext(&dc);
} else {
- TkMacOSXDbgMsg("Invalid source drawable");
+ TkMacOSXDbgMsg("Invalid destination drawable");
}
+ TkMacOSXRestoreDrawingContext(&dc);
+ } else {
+ TkMacOSXDbgMsg("Invalid source drawable");
}
}
@@ -241,7 +251,7 @@ XCopyPlane(
unsigned long plane) /* Which plane to copy. */
{
TkMacOSXDrawingContext dc;
- MacDrawable *srcDraw = (MacDrawable *) src, *dstDraw = (MacDrawable *) dst;
+ MacDrawable *srcDraw = (MacDrawable *) src;
display->request++;
if (!width || !height) {
@@ -251,73 +261,37 @@ XCopyPlane(
if (plane != 1) {
Tcl_Panic("Unexpected plane specified for XCopyPlane");
}
- {
- CGrafPtr srcPort;
+ if (srcDraw->flags & TK_IS_PIXMAP) {
+ if (!TkMacOSXSetupDrawingContext(dst, gc, 1, &dc)) {
+ return;
+ }
+ if (dc.context) {
+ CGImageRef img = TkMacOSXCreateCGImageWithDrawable(src);
- srcPort = TkMacOSXGetDrawablePort(src);
- if (srcPort) {
- Rect srcRect, dstRect, *srcPtr = &srcRect, *dstPtr = &dstRect;
- const BitMap *srcBit, *dstBit;
- TkpClipMask *clipPtr = (TkpClipMask *) gc->clip_mask;
+ if (img) {
+ TkpClipMask *clipPtr = (TkpClipMask *) gc->clip_mask;
+ unsigned long imageBackground = gc->background;
- if (!TkMacOSXSetupDrawingContext(dst, gc, 0, &dc)) {
- return;
- }
- if (dc.context) {
- TkMacOSXDbgMsg("Ignored CG drawing of QD drawable");
- goto end;
- }
- if (!dc.port) {
- TkMacOSXDbgMsg("Invalid destination drawable");
- goto end;
- }
- 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) {
- /*
- * Opaque bitmaps.
- */
-
- 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 ignore the forecolor.
- */
- short tmode = GetPixDepth(GetPortPixMap(srcPort)) == 1 ?
- srcOr : transparent;
-
- 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);
+ if (clipPtr && clipPtr->type == TKP_CLIP_PIXMAP &&
+ clipPtr->value.pixmap == src) {
+ imageBackground = TRANSPARENT_PIXEL << 24;
}
+ DrawCGImage(dst, gc, dc.context, img, gc->foreground,
+ imageBackground, CGRectMake(0, 0,
+ srcDraw->size.width, srcDraw->size.height),
+ CGRectMake(src_x, src_y, width, height),
+ CGRectMake(dest_x, dest_y, width, height));
+ CFRelease(img);
+ } else {
+ TkMacOSXDbgMsg("Invalid source drawable");
}
-end:
- TkMacOSXRestoreDrawingContext(&dc);
} else {
- TkMacOSXDbgMsg("Invalid source drawable");
+ TkMacOSXDbgMsg("Invalid destination drawable");
}
+ TkMacOSXRestoreDrawingContext(&dc);
+ } else {
+ XCopyArea(display, src, dst, gc, src_x, src_y, width, height, dest_x,
+ dest_y);
}
}
@@ -354,182 +328,424 @@ TkPutImage(
unsigned int height) /* distination and source. */
{
TkMacOSXDrawingContext dc;
- MacDrawable *dstDraw = (MacDrawable *) d;
display->request++;
- if (!TkMacOSXSetupDrawingContext(d, gc, 0, &dc)) {
+ if (!TkMacOSXSetupDrawingContext(d, gc, 1, &dc)) {
return BadDrawable;
}
if (dc.context) {
- TkMacOSXDbgMsg("Ignored CG drawing of XImage");
- } else {
- 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, sliceRowBytes, lastSliceRowBytes;
- int slices, sliceWidth, lastSliceWidth;
-
- dstBit = GetPortBitMapForCopyBits(dc.port);
- SetRect(srcPtr, src_x, src_y, src_x + width, src_y + height);
- if (tkPictureIsOpen) {
- dstPtr = srcPtr;
+ CGImageRef img = CreateCGImageWithXImage(image);
+
+ if (img) {
+ DrawCGImage(d, gc, dc.context, img, gc->foreground, gc->background,
+ CGRectMake(0, 0, image->width, image->height),
+ CGRectMake(src_x, src_y, width, height),
+ CGRectMake(dest_x, dest_y, width, height));
+ CFRelease(img);
} else {
- SetRect(dstPtr, dstDraw->xOff + dest_x, dstDraw->yOff + dest_y,
- dstDraw->xOff + dest_x + width,
- dstDraw->yOff + dest_y + height);
+ TkMacOSXDbgMsg("Invalid source drawable");
}
- RGBForeColor(&black);
- RGBBackColor(&white);
- if (image->obdata) {
- /*
- * Image from XGetImage, copy from containing GWorld directly.
- */
+ } else {
+ TkMacOSXDbgMsg("Invalid destination drawable");
+ }
+ TkMacOSXRestoreDrawingContext(&dc);
+}
+
+/*
+ *----------------------------------------------------------------------
+ *
+ * CreateCGImageWithXImage --
+ *
+ * Create CGImage from XImage, copying the image data.
+ *
+ * Results:
+ * CGImage, release after use.
+ *
+ * Side effects:
+ * None.
+ *
+ *----------------------------------------------------------------------
+ */
- 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;
+static void ReleaseData(void *info, const void *data, size_t size) {
+ ckfree(info);
+}
+
+CGImageRef
+CreateCGImageWithXImage(
+ XImage *image)
+{
+ CGImageRef img = NULL;
+ size_t bitsPerComponent, bitsPerPixel;
+ size_t len = image->bytes_per_line * image->height;
+ const CGFloat *decode = NULL;
+ CGBitmapInfo bitmapInfo;
+ CGDataProviderRef provider = NULL;
+ char *data = NULL;
+ CGDataProviderReleaseDataCallback releaseData = ReleaseData;
+
+ if (image->obdata) {
+ /*
+ * Image from XGetImage
+ */
+
+ img = TkMacOSXCreateCGImageWithDrawable((Pixmap) image->obdata);
+ } else if (image->bits_per_pixel == 1) {
+ /*
+ * BW image
+ */
+
+ static const CGFloat decodeWB[2] = {1, 0};
+
+ bitsPerComponent = 1;
+ bitsPerPixel = 1;
+ decode = decodeWB;
+ if (image->bitmap_bit_order != MSBFirst) {
+ char *srcPtr = image->data + image->xoffset;
+ char *endPtr = srcPtr + len;
+ char *destPtr = (data = ckalloc(len));
+
+ while (srcPtr < endPtr) {
+ *destPtr++ = xBitReverseTable[(unsigned char)(*(srcPtr++))];
}
- bitmap.bounds.top = bitmap.bounds.left = 0;
- bitmap.bounds.bottom = (short) image->height;
- dataPtr = image->data + image->xoffset;
- 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;
- if (image->bitmap_bit_order != MSBFirst) {
- for (i = 0; i < image->height; i++) {
- for (j = 0; j < sliceRowBytes; j++) {
- *newPtr = xBitReverseTable[(unsigned char)*oldPtr];
- newPtr++; oldPtr++;
- }
- if (odd) {
- *newPtr++ = 0;
- }
- oldPtr += rowBytes - sliceRowBytes;
- }
- } else {
- for (i = 0; i < image->height; i++) {
- memcpy(newPtr, oldPtr, sliceRowBytes);
- newPtr += sliceRowBytes;
- if (odd) {
- *newPtr++ = 0;
- }
- oldPtr += rowBytes;
- }
- }
- 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
- */
-
- 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;
- pixmap.pixelFormat = image->byte_order == MSBFirst ?
- k32ARGBPixelFormat : k32BGRAPixelFormat;
- pixmap.pmTable = NULL;
- pixmap.pmExt = 0;
- if (rowBytes > maxRowBytes) {
- slices = rowBytes / maxRowBytes;
- sliceRowBytes = maxRowBytes;
- lastSliceRowBytes = rowBytes - (slices * maxRowBytes);
- if (!lastSliceRowBytes) {
- slices--;
- lastSliceRowBytes = maxRowBytes;
+ data = memcpy(ckalloc(len), image->data + image->xoffset,
+ len);
+ }
+ if (data) {
+ provider = CGDataProviderCreateWithData(data, data, len, releaseData);
+ }
+ if (provider) {
+ img = CGImageMaskCreate(image->width, image->height, bitsPerComponent,
+ bitsPerPixel, image->bytes_per_line,
+ provider, decode, 0);
+ }
+ } else if (image->format == ZPixmap && image->bits_per_pixel == 32) {
+ /*
+ * Color image
+ */
+
+ CGColorSpaceRef colorspace = CGColorSpaceCreateWithName(kCGColorSpaceGenericRGB);
+
+ bitsPerComponent = 8;
+ bitsPerPixel = 32;
+ bitmapInfo = (image->byte_order == MSBFirst ?
+ kCGBitmapByteOrder32Big : kCGBitmapByteOrder32Little) |
+ kCGImageAlphaNoneSkipFirst;
+ data = memcpy(ckalloc(len), image->data + image->xoffset, len);
+ if (data) {
+ provider = CGDataProviderCreateWithData(data, data, len, releaseData);
+ }
+ if (provider) {
+ img = CGImageCreate(image->width, image->height, bitsPerComponent,
+ bitsPerPixel, image->bytes_per_line, colorspace, bitmapInfo,
+ provider, decode, 0, kCGRenderingIntentDefault);
+ }
+ if (colorspace) {
+ CFRelease(colorspace);
+ }
+ } else {
+ TkMacOSXDbgMsg("Unsupported image type");
+ }
+ if (provider) {
+ CFRelease(provider);
+ }
+
+ return img;
+}
+
+/*
+ *----------------------------------------------------------------------
+ *
+ * TkMacOSXCreateCGImageWithDrawable --
+ *
+ * Create a CGImage from the given Drawable.
+ *
+ * Results:
+ * CGImage, release after use.
+ *
+ * Side effects:
+ * None.
+ *
+ *----------------------------------------------------------------------
+ */
+
+CGImageRef
+TkMacOSXCreateCGImageWithDrawable(
+ Drawable drawable)
+{
+ CGImageRef img = NULL;
+ CGContextRef context = GetCGContextForDrawable(drawable);
+
+ if (context) {
+ img = CGBitmapContextCreateImage(context);
+ }
+ return img;
+}
+
+/*
+ *----------------------------------------------------------------------
+ *
+ * CreateNSImageWithPixmap --
+ *
+ * Create NSImage for Pixmap.
+ *
+ * Results:
+ * NSImage.
+ *
+ * Side effects:
+ * None.
+ *
+ *----------------------------------------------------------------------
+ */
+
+static NSImage*
+CreateNSImageWithPixmap(
+ Pixmap pixmap,
+ int width,
+ int height)
+{
+ CGImageRef cgImage;
+ NSImage *nsImage;
+ NSBitmapImageRep *bitmapImageRep;
+
+ cgImage = TkMacOSXCreateCGImageWithDrawable(pixmap);
+ nsImage = [[NSImage alloc] initWithSize:NSMakeSize(width, height)];
+ bitmapImageRep = [[NSBitmapImageRep alloc] initWithCGImage:cgImage];
+ [nsImage addRepresentation:bitmapImageRep];
+ [bitmapImageRep release];
+ CFRelease(cgImage);
+
+ return nsImage;
+}
+
+/*
+ *----------------------------------------------------------------------
+ *
+ * TkMacOSXGetNSImageWithTkImage --
+ *
+ * Get autoreleased NSImage for Tk_Image.
+ *
+ * Results:
+ * NSImage.
+ *
+ * Side effects:
+ * None.
+ *
+ *----------------------------------------------------------------------
+ */
+
+NSImage*
+TkMacOSXGetNSImageWithTkImage(
+ Display *display,
+ Tk_Image image,
+ int width,
+ int height)
+{
+ Pixmap pixmap = Tk_GetPixmap(display, None, width, height, 0);
+ NSImage *nsImage;
+
+ Tk_RedrawImage(image, 0, 0, width, height, pixmap, 0, 0);
+ nsImage = CreateNSImageWithPixmap(pixmap, width, height);
+ Tk_FreePixmap(display, pixmap);
+
+ return [nsImage autorelease];
+}
+
+/*
+ *----------------------------------------------------------------------
+ *
+ * TkMacOSXGetNSImageWithBitmap --
+ *
+ * Get autoreleased NSImage for Bitmap.
+ *
+ * Results:
+ * NSImage.
+ *
+ * Side effects:
+ * None.
+ *
+ *----------------------------------------------------------------------
+ */
+
+NSImage*
+TkMacOSXGetNSImageWithBitmap(
+ Display *display,
+ Pixmap bitmap,
+ GC gc,
+ int width,
+ int height)
+{
+ Pixmap pixmap = Tk_GetPixmap(display, None, width, height, 0);
+ NSImage *nsImage;
+
+ unsigned long origBackground = gc->background;
+
+ gc->background = TRANSPARENT_PIXEL << 24;
+ XSetClipOrigin(display, gc, 0, 0);
+ XCopyPlane(display, bitmap, pixmap, gc, 0, 0, width, height, 0, 0, 1);
+ gc->background = origBackground;
+ nsImage = CreateNSImageWithPixmap(pixmap, width, height);
+ Tk_FreePixmap(display, pixmap);
+
+ return [nsImage autorelease];
+}
+
+/*
+ *----------------------------------------------------------------------
+ *
+ * GetCGContextForDrawable --
+ *
+ * Get CGContext for given Drawable, creating one if necessary.
+ *
+ * Results:
+ * CGContext.
+ *
+ * Side effects:
+ * None.
+ *
+ *----------------------------------------------------------------------
+ */
+
+CGContextRef
+GetCGContextForDrawable(
+ Drawable d)
+{
+ MacDrawable *macDraw = (MacDrawable *) d;
+
+ if (macDraw && (macDraw->flags & TK_IS_PIXMAP) && !macDraw->context) {
+ const size_t bitsPerComponent = 8;
+ size_t bitsPerPixel, bytesPerRow, len;
+ CGColorSpaceRef colorspace = NULL;
+ CGBitmapInfo bitmapInfo =
+#ifdef __LITTLE_ENDIAN__
+ kCGBitmapByteOrder32Host;
+#else
+ kCGBitmapByteOrderDefault;
+#endif
+ char *data;
+ CGRect bounds = CGRectMake(0, 0, macDraw->size.width,
+ macDraw->size.height);
+
+ if (macDraw->flags & TK_IS_BW_PIXMAP) {
+ bitsPerPixel = 8;
+ bitmapInfo = kCGImageAlphaOnly;
+ } else {
+ colorspace = CGColorSpaceCreateWithName(kCGColorSpaceGenericRGB);
+ bitsPerPixel = 32;
+ bitmapInfo |= kCGImageAlphaPremultipliedFirst;
+ }
+ bytesPerRow = ((size_t) macDraw->size.width * bitsPerPixel + 127) >> 3
+ & ~15;
+ len = macDraw->size.height * bytesPerRow;
+ data = ckalloc(len);
+ bzero(data, len);
+ macDraw->context = CGBitmapContextCreate(data, macDraw->size.width,
+ macDraw->size.height, bitsPerComponent, bytesPerRow,
+ colorspace, bitmapInfo);
+ if (macDraw->context) {
+ CGContextClearRect(macDraw->context, bounds);
+ }
+ if (colorspace) {
+ CFRelease(colorspace);
+ }
+ }
+
+ return (macDraw ? macDraw->context : NULL);
+}
+
+/*
+ *----------------------------------------------------------------------
+ *
+ * DrawCGImage --
+ *
+ * Draw CG image into drawable.
+ *
+ * Results:
+ * None.
+ *
+ * Side effects:
+ * None.
+ *
+ *----------------------------------------------------------------------
+ */
+
+void
+DrawCGImage(
+ Drawable d,
+ GC gc,
+ CGContextRef context,
+ CGImageRef image,
+ unsigned long imageForeground,
+ unsigned long imageBackground,
+ CGRect imageBounds,
+ CGRect srcBounds,
+ CGRect dstBounds)
+{
+ MacDrawable *macDraw = (MacDrawable *) d;
+
+ if (macDraw && context && image) {
+ CGImageRef subImage = NULL;
+
+ if (!CGRectEqualToRect(imageBounds, srcBounds)) {
+ if (!CGRectContainsRect(imageBounds, srcBounds)) {
+ TkMacOSXDbgMsg("Mismatch of sub CGImage bounds");
+ }
+ subImage = CGImageCreateWithImageInRect(image, CGRectOffset(
+ srcBounds, -imageBounds.origin.x, -imageBounds.origin.y));
+ if (subImage) {
+ image = subImage;
+ }
+ }
+ dstBounds = CGRectOffset(dstBounds, macDraw->xOff, macDraw->yOff);
+ if (CGImageIsMask(image)) {
+ /*CGContextSaveGState(context);*/
+ if (macDraw->flags & TK_IS_BW_PIXMAP) {
+ if (imageBackground != TRANSPARENT_PIXEL << 24) {
+ CGContextClearRect(context, dstBounds);
}
- sliceWidth = (long) image->width * maxRowBytes / rowBytes;
- lastSliceWidth = image->width - (sliceWidth * slices);
- dataPtr = image->data + image->xoffset;
- 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);
+ CGContextSetRGBFillColor(context, 0.0, 0.0, 0.0, 1.0);
} else {
- pixmap.bounds.right = (short) image->width;
- pixmap.baseAddr = image->data + image->xoffset;
- pixmap.rowBytes = rowBytes | 0x8000;
- CopyBits((BitMap*) &pixmap, dstBit, srcPtr, dstPtr, srcCopy, NULL);
+ if (imageBackground != TRANSPARENT_PIXEL << 24) {
+ TkMacOSXSetColorInContext(gc, imageBackground, context);
+ CGContextFillRect(context, dstBounds);
+ }
+ TkMacOSXSetColorInContext(gc, imageForeground, context);
}
}
+#ifdef TK_MAC_DEBUG_IMAGE_DRAWING
+ CGContextSaveGState(context);
+ CGContextSetLineWidth(context, 1.0);
+ CGContextSetRGBStrokeColor(context, 0, 0, 0, 0.1);
+ CGContextSetRGBFillColor(context, 0, 1, 0, 0.1);
+ CGContextFillRect(context, dstBounds);
+ CGContextStrokeRect(context, dstBounds);
+ CGPoint p[4] = {dstBounds.origin,
+ CGPointMake(CGRectGetMaxX(dstBounds), CGRectGetMaxY(dstBounds)),
+ CGPointMake(CGRectGetMinX(dstBounds), CGRectGetMaxY(dstBounds)),
+ CGPointMake(CGRectGetMaxX(dstBounds), CGRectGetMinY(dstBounds))
+ };
+ CGContextStrokeLineSegments(context, p, 4);
+ CGContextRestoreGState(context);
+ TkMacOSXDbgMsg("Drawing CGImage at (x=%f, y=%f), (w=%f, h=%f)",
+ dstBounds.origin.x, dstBounds.origin.y,
+ dstBounds.size.width, dstBounds.size.height);
+#else /* TK_MAC_DEBUG_IMAGE_DRAWING */
+ CGContextSaveGState(context);
+ CGContextTranslateCTM(context, 0, dstBounds.origin.y + CGRectGetMaxY(dstBounds));
+ CGContextScaleCTM(context, 1, -1);
+ CGContextDrawImage(context, dstBounds, image);
+ CGContextRestoreGState(context);
+#endif /* TK_MAC_DEBUG_IMAGE_DRAWING */
+ /*if (CGImageIsMask(image)) {
+ CGContextRestoreGState(context);
+ }*/
+ if (subImage) {
+ CFRelease(subImage);
+ }
+ } else {
+ TkMacOSXDbgMsg("Drawing of empty CGImage requested");
}
- TkMacOSXRestoreDrawingContext(&dc);
return Success;
}
@@ -567,7 +783,7 @@ XDrawLines(
}
display->request++;
- if (!TkMacOSXSetupDrawingContext(d, gc, tkMacOSXUseCGDrawing, &dc)) {
+ if (!TkMacOSXSetupDrawingContext(d, gc, 1, &dc)) {
return BadDrawable;
}
if (dc.context) {
@@ -590,23 +806,6 @@ XDrawLines(
}
}
CGContextStrokePath(dc.context);
- } else {
- int o = -lw/2;
-
- /* This is broken for fat lines, it is not possible to correctly
- * imitate X11 drawing of oblique fat lines with QD line drawing,
- * we should draw a filled polygon instead. */
-
- MoveTo((short) (macWin->xOff + points[0].x + o),
- (short) (macWin->yOff + points[0].y + o));
- for (i = 1; i < npoints; i++) {
- if (mode == CoordModeOrigin) {
- LineTo((short) (macWin->xOff + points[i].x + o),
- (short) (macWin->yOff + points[i].y + o));
- } else {
- Line((short) points[i].x, (short) points[i].y);
- }
- }
}
TkMacOSXRestoreDrawingContext(&dc);
return Success;
@@ -641,7 +840,7 @@ XDrawSegments(
int i, lw = gc->line_width;
display->request++;
- if (!TkMacOSXSetupDrawingContext(d, gc, tkMacOSXUseCGDrawing, &dc)) {
+ if (!TkMacOSXSetupDrawingContext(d, gc, 1, &dc)) {
return;
}
if (dc.context) {
@@ -657,19 +856,6 @@ XDrawSegments(
macWin->yOff + segments[i].y2 + o);
CGContextStrokePath(dc.context);
}
- } else {
- int o = -lw/2;
-
- /* This is broken for fat lines, it is not possible to correctly
- * imitate X11 drawing of oblique fat lines with QD line drawing,
- * we should draw a filled polygon instead. */
-
- for (i = 0; i < nsegments; i++) {
- MoveTo((short) (macWin->xOff + segments[i].x1 + o),
- (short) (macWin->yOff + segments[i].y1 + o));
- LineTo((short) (macWin->xOff + segments[i].x2 + o),
- (short) (macWin->yOff + segments[i].y2 + o));
- }
}
TkMacOSXRestoreDrawingContext(&dc);
}
@@ -705,7 +891,7 @@ XFillPolygon(
int i;
display->request++;
- if (!TkMacOSXSetupDrawingContext(d, gc, tkMacOSXUseCGDrawing, &dc)) {
+ if (!TkMacOSXSetupDrawingContext(d, gc, 1, &dc)) {
return;
}
if (dc.context) {
@@ -728,23 +914,6 @@ XFillPolygon(
}
}
CGContextEOFillPath(dc.context);
- } else {
- PolyHandle polygon;
-
- polygon = OpenPoly();
- MoveTo((short) (macWin->xOff + points[0].x),
- (short) (macWin->yOff + points[0].y));
- for (i = 1; i < npoints; i++) {
- if (mode == CoordModeOrigin) {
- LineTo((short) (macWin->xOff + points[i].x),
- (short) (macWin->yOff + points[i].y));
- } else {
- Line((short) points[i].x, (short) points[i].y);
- }
- }
- ClosePoly();
- FillCPoly(polygon, dc.penPat);
- KillPoly(polygon);
}
TkMacOSXRestoreDrawingContext(&dc);
}
@@ -783,7 +952,7 @@ XDrawRectangle(
}
display->request++;
- if (!TkMacOSXSetupDrawingContext(d, gc, tkMacOSXUseCGDrawing, &dc)) {
+ if (!TkMacOSXSetupDrawingContext(d, gc, 1, &dc)) {
return;
}
if (dc.context) {
@@ -795,15 +964,6 @@ XDrawRectangle(
macWin->yOff + y + o,
width, height);
CGContextStrokeRect(dc.context, rect);
- } else {
- Rect theRect;
- int o = -lw/2;
-
- theRect.left = (short) (macWin->xOff + x + o);
- theRect.top = (short) (macWin->yOff + y + o);
- theRect.right = (short) (theRect.left + width + lw);
- theRect.bottom = (short) (theRect.top + height + lw);
- FrameRect(&theRect);
}
TkMacOSXRestoreDrawingContext(&dc);
}
@@ -849,7 +1009,7 @@ XDrawRectangles(
int i, lw = gc->line_width;
display->request++;
- if (!TkMacOSXSetupDrawingContext(d, gc, tkMacOSXUseCGDrawing, &dc)) {
+ if (!TkMacOSXSetupDrawingContext(d, gc, 1, &dc)) {
return;
}
if (dc.context) {
@@ -866,17 +1026,6 @@ XDrawRectangles(
rectPtr->width, rectPtr->height);
CGContextStrokeRect(dc.context, rect);
}
- } else {
- Rect theRect;
- int o = -lw/2;
-
- for (i = 0, rectPtr = rectArr; i < nRects;i++, rectPtr++) {
- theRect.left = (short) (macWin->xOff + rectPtr->x + o);
- theRect.top = (short) (macWin->yOff + rectPtr->y + o);
- theRect.right = (short) (theRect.left + rectPtr->width + lw);
- theRect.bottom = (short) (theRect.top + rectPtr->height + lw);
- FrameRect(&theRect);
- }
}
TkMacOSXRestoreDrawingContext(&dc);
}
@@ -912,7 +1061,7 @@ XFillRectangles(
int i;
display->request++;
- if (!TkMacOSXSetupDrawingContext(d, gc, tkMacOSXUseCGDrawing, &dc)) {
+ if (!TkMacOSXSetupDrawingContext(d, gc, 1, &dc)) {
return BadDrawable;
}
if (dc.context) {
@@ -928,16 +1077,6 @@ XFillRectangles(
rectPtr->width, rectPtr->height);
CGContextFillRect(dc.context, rect);
}
- } else {
- Rect theRect;
-
- for (i = 0, rectPtr = rectangles; i < n_rectangles; i++, rectPtr++) {
- theRect.left = (short) (macWin->xOff + rectPtr->x);
- theRect.top = (short) (macWin->yOff + rectPtr->y);
- theRect.right = (short) (theRect.left + rectPtr->width);
- theRect.bottom = (short) (theRect.top + rectPtr->height);
- FillCRect(&theRect, dc.penPat);
- }
}
TkMacOSXRestoreDrawingContext(&dc);
return Success;
@@ -979,7 +1118,7 @@ XDrawArc(
}
display->request++;
- if (!TkMacOSXSetupDrawingContext(d, gc, tkMacOSXUseCGDrawing, &dc)) {
+ if (!TkMacOSXSetupDrawingContext(d, gc, 1, &dc)) {
return;
}
if (dc.context) {
@@ -990,10 +1129,9 @@ XDrawArc(
macWin->xOff + x + o,
macWin->yOff + y + o,
width, height);
- TK_IF_MAC_OS_X_API_COND (4, CGContextStrokeEllipseInRect,
- angle1 == 0 && angle2 == 23040,
+ if (angle1 == 0 && angle2 == 23040) {
CGContextStrokeEllipseInRect(dc.context, rect);
- ) TK_ELSE (
+ } else {
CGMutablePathRef p = CGPathCreateMutable();
CGAffineTransform t = CGAffineTransformIdentity;
CGPoint c = CGPointMake(CGRectGetMidX(rect), CGRectGetMidY(rect));
@@ -1008,19 +1146,7 @@ XDrawArc(
CGContextAddPath(dc.context, p);
CGPathRelease(p);
CGContextStrokePath(dc.context);
- ) TK_ENDIF
- } else {
- Rect theRect;
- short start, extent;
- int o = -lw/2;
-
- theRect.left = (short) (macWin->xOff + x + o);
- theRect.top = (short) (macWin->yOff + y + o);
- theRect.right = (short) (theRect.left + width + lw);
- theRect.bottom = (short) (theRect.top + height + lw);
- start = (short) (90 - (angle1/64));
- extent = (short) (-(angle2/64));
- FrameArc(&theRect, start, extent);
+ }
}
TkMacOSXRestoreDrawingContext(&dc);
}
@@ -1064,7 +1190,7 @@ XDrawArcs(
int i, lw = gc->line_width;
display->request++;
- if (!TkMacOSXSetupDrawingContext(d, gc, tkMacOSXUseCGDrawing, &dc)) {
+ if (!TkMacOSXSetupDrawingContext(d, gc, 1, &dc)) {
return;
}
if (dc.context) {
@@ -1081,10 +1207,9 @@ XDrawArcs(
macWin->yOff + arcPtr->y + o,
arcPtr->width, arcPtr->height);
- TK_IF_MAC_OS_X_API_COND (4, CGContextStrokeEllipseInRect,
- arcPtr->angle1 == 0 && arcPtr->angle2 == 23040,
+ if (arcPtr->angle1 == 0 && arcPtr->angle2 == 23040) {
CGContextStrokeEllipseInRect(dc.context, rect);
- ) TK_ELSE (
+ } else {
CGMutablePathRef p = CGPathCreateMutable();
CGAffineTransform t = CGAffineTransformIdentity;
CGPoint c = CGPointMake(CGRectGetMidX(rect),
@@ -1103,21 +1228,7 @@ XDrawArcs(
CGContextAddPath(dc.context, p);
CGPathRelease(p);
CGContextStrokePath(dc.context);
- ) TK_ENDIF
- }
- } else {
- Rect theRect;
- short start, extent;
- int o = -lw/2;
-
- for (i = 0, arcPtr = arcArr;i < nArcs;i++, arcPtr++) {
- theRect.left = (short) (macWin->xOff + arcPtr->x + o);
- theRect.top = (short) (macWin->yOff + arcPtr->y + o);
- theRect.right = (short) (theRect.left + arcPtr->width + lw);
- theRect.bottom = (short) (theRect.top + arcPtr->height + lw);
- start = (short) (90 - (arcPtr->angle1/64));
- extent = (short) (-(arcPtr->angle2/64));
- FrameArc(&theRect, start, extent);
+ }
}
}
TkMacOSXRestoreDrawingContext(&dc);
@@ -1160,7 +1271,7 @@ XFillArc(
}
display->request++;
- if (!TkMacOSXSetupDrawingContext(d, gc, tkMacOSXUseCGDrawing, &dc)) {
+ if (!TkMacOSXSetupDrawingContext(d, gc, 1, &dc)) {
return;
}
if (dc.context) {
@@ -1176,10 +1287,9 @@ XFillArc(
macWin->yOff + y + o,
width - u, height - u);
- TK_IF_MAC_OS_X_API_COND (4, CGContextFillEllipseInRect,
- angle1 == 0 && angle2 == 23040,
+ if (angle1 == 0 && angle2 == 23040) {
CGContextFillEllipseInRect(dc.context, rect);
- ) TK_ELSE (
+ } else {
CGMutablePathRef p = CGPathCreateMutable();
CGAffineTransform t = CGAffineTransformIdentity;
CGPoint c = CGPointMake(CGRectGetMidX(rect), CGRectGetMidY(rect));
@@ -1198,49 +1308,6 @@ XFillArc(
CGContextAddPath(dc.context, p);
CGPathRelease(p);
CGContextFillPath(dc.context);
- ) TK_ENDIF
- } else {
- Rect theRect;
- short start, extent;
- int o = -lw/2;
- PolyHandle polygon;
- double sin1, cos1, sin2, cos2, angle;
- double boxWidth, boxHeight;
- double vertex[2], center1[2], center2[2];
-
- theRect.left = (short) (macWin->xOff + x + o);
- theRect.top = (short) (macWin->yOff + y + o);
- theRect.right = (short) (theRect.left + width + lw);
- theRect.bottom = (short) (theRect.top + height + lw);
- start = (short) (90 - (angle1/64));
- extent = (short) (-(angle2/64));
- if (gc->arc_mode == ArcChord) {
- boxWidth = theRect.right - theRect.left;
- boxHeight = theRect.bottom - theRect.top;
- angle = radians(-angle1/64.0);
- sin1 = sin(angle);
- cos1 = cos(angle);
- angle -= radians(angle2/64.0);
- sin2 = sin(angle);
- cos2 = cos(angle);
- vertex[0] = (theRect.left + theRect.right)/2.0;
- vertex[1] = (theRect.top + theRect.bottom)/2.0;
- center1[0] = vertex[0] + cos1*boxWidth/2.0;
- center1[1] = vertex[1] + sin1*boxHeight/2.0;
- center2[0] = vertex[0] + cos2*boxWidth/2.0;
- center2[1] = vertex[1] + sin2*boxHeight/2.0;
-
- polygon = OpenPoly();
- MoveTo((short) ((theRect.left + theRect.right)/2),
- (short) ((theRect.top + theRect.bottom)/2));
- LineTo((short) (center1[0] + .5), (short) (center1[1] + .5));
- LineTo((short) (center2[0] + .5), (short) (center2[1] + .5));
- ClosePoly();
- FillCArc(&theRect, start, extent, dc.penPat);
- FillCPoly(polygon, dc.penPat);
- KillPoly(polygon);
- } else {
- FillCArc(&theRect, start, extent, dc.penPat);
}
}
TkMacOSXRestoreDrawingContext(&dc);
@@ -1277,7 +1344,7 @@ XFillArcs(
int i, lw = gc->line_width;
display->request++;
- if (!TkMacOSXSetupDrawingContext(d, gc, tkMacOSXUseCGDrawing, &dc)) {
+ if (!TkMacOSXSetupDrawingContext(d, gc, 1, &dc)) {
return;
}
if (dc.context) {
@@ -1297,10 +1364,9 @@ XFillArcs(
macWin->xOff + arcPtr->x + o,
macWin->yOff + arcPtr->y + o,
arcPtr->width - u, arcPtr->height - u);
- TK_IF_MAC_OS_X_API_COND (4, CGContextFillEllipseInRect,
- arcPtr->angle1 == 0 && arcPtr->angle2 == 23040,
+ if (arcPtr->angle1 == 0 && arcPtr->angle2 == 23040) {
CGContextFillEllipseInRect(dc.context, rect);
- ) TK_ELSE (
+ } else {
CGMutablePathRef p = CGPathCreateMutable();
CGAffineTransform t = CGAffineTransformIdentity;
CGPoint c = CGPointMake(CGRectGetMidX(rect),
@@ -1323,52 +1389,6 @@ XFillArcs(
CGContextAddPath(dc.context, p);
CGPathRelease(p);
CGContextFillPath(dc.context);
- ) TK_ENDIF
- }
- } else {
- Rect theRect;
- short start, extent;
- int o = -lw/2;
- PolyHandle polygon;
- double sin1, cos1, sin2, cos2, angle;
- double boxWidth, boxHeight;
- double vertex[2], center1[2], center2[2];
-
- for (i = 0, arcPtr = arcArr;i<nArcs;i++, arcPtr++) {
- theRect.left = (short) (macWin->xOff + arcPtr->x + o);
- theRect.top = (short) (macWin->yOff + arcPtr->y + o);
- theRect.right = (short) (theRect.left + arcPtr->width + lw);
- theRect.bottom = (short) (theRect.top + arcPtr->height + lw);
- start = (short) (90 - (arcPtr->angle1/64));
- extent = (short) (- (arcPtr->angle2/64));
-
- if (gc->arc_mode == ArcChord) {
- boxWidth = theRect.right - theRect.left;
- boxHeight = theRect.bottom - theRect.top;
- angle = radians(-arcPtr->angle1/64.0);
- sin1 = sin(angle);
- cos1 = cos(angle);
- angle -= radians(arcPtr->angle2/64.0);
- sin2 = sin(angle);
- cos2 = cos(angle);
- vertex[0] = (theRect.left + theRect.right)/2.0;
- vertex[1] = (theRect.top + theRect.bottom)/2.0;
- center1[0] = vertex[0] + cos1*boxWidth/2.0;
- center1[1] = vertex[1] + sin1*boxHeight/2.0;
- center2[0] = vertex[0] + cos2*boxWidth/2.0;
- center2[1] = vertex[1] + sin2*boxHeight/2.0;
-
- polygon = OpenPoly();
- MoveTo((short) ((theRect.left + theRect.right)/2),
- (short) ((theRect.top + theRect.bottom)/2));
- LineTo((short) (center1[0] + .5), (short) (center1[1] + .5));
- LineTo((short) (center2[0] + .5), (short) (center2[1] + .5));
- ClosePoly();
- FillCArc(&theRect, start, extent, dc.penPat);
- FillCPoly(polygon, dc.penPat);
- KillPoly(polygon);
- } else {
- FillCArc(&theRect, start, extent, dc.penPat);
}
}
}
@@ -1421,56 +1441,39 @@ TkScrollWindow(
int dx, int dy, /* Distance rectangle should be moved. */
TkRegion damageRgn) /* Region to accumulate damage in. */
{
- MacDrawable *destDraw = (MacDrawable *) Tk_WindowId(tkwin);
- CGrafPtr destPort, savePort;
- Boolean portChanged;
- Rect scrollRect;
+ MacDrawable *macDraw = (MacDrawable *) Tk_WindowId(tkwin);
+ NSView *view = TkMacOSXDrawableView(macDraw);
+ CGRect visRect, srcRect, dstRect;
+ CGFloat boundsH;
+ HIShapeRef dmgRgn, dstRgn;
int result;
- HIShapeRef dmgRgn;
-
- /*
- * Due to the implementation below the behavior may be differnt
- * than X in certain cases that should never occur in Tk. The
- * scrollRect is the source rect extended by the offset (the union
- * of the source rect and the offset rect). Everything
- * in the extended scrollRect is scrolled. On X, it's possible
- * to "skip" over an area if the offset makes the source and
- * destination rects disjoint and non-aligned.
- */
-
- 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 {
- scrollRect.right += dx;
- }
- if (dy < 0) {
- scrollRect.top += dy;
- } else {
- scrollRect.bottom += dy;
- }
- destPort = TkMacOSXGetDrawablePort(Tk_WindowId(tkwin));
- TkMacOSXSetUpClippingRgn(Tk_WindowId(tkwin));
- TkMacOSXCheckTmpQdRgnEmpty();
- portChanged = QDSwapPort(destPort, &savePort);
- ScrollRect(&scrollRect, dx, dy, tkMacOSXtmpQdRgn);
- if (portChanged) {
- QDSwapPort(savePort, NULL);
+ if (view && !CGRectIsEmpty(visRect = NSRectToCGRect([view visibleRect]))) {
+ boundsH = [view bounds].size.height;
+ srcRect = CGRectMake(macDraw->xOff + x, boundsH - height -
+ (macDraw->yOff + y), width, height);
+ dstRect = CGRectIntersection(CGRectOffset(srcRect, dx, -dy), visRect);
+ srcRect = CGRectIntersection(srcRect, visRect);
+ if (!CGRectIsEmpty(srcRect) && !CGRectIsEmpty(dstRect)) {
+ /*
+ CGRect sRect = CGRectIntersection(CGRectOffset(dstRect, -dx, dy),
+ srcRect);
+ NSCopyBits(0, NSRectFromCGRect(sRect),
+ NSPointFromCGPoint(CGRectOffset(sRect, dx, -dy).origin));
+ */
+ [view scrollRect:NSRectFromCGRect(srcRect) by:NSMakeSize(dx, -dy)];
+ }
+ srcRect.origin.y = boundsH - srcRect.size.height - srcRect.origin.y;
+ dstRect.origin.y = boundsH - dstRect.size.height - dstRect.origin.y;
+ srcRect = CGRectUnion(srcRect, dstRect);
+ dmgRgn = HIShapeCreateMutableWithRect(&srcRect);
+ dstRgn = HIShapeCreateWithRect(&dstRect);
+ ChkErr(HIShapeDifference, dmgRgn, dstRgn, (HIMutableShapeRef) dmgRgn);
+ CFRelease(dstRgn);
+ TkMacOSXInvalidateViewRegion(view, dmgRgn);
+ } else {
+ dmgRgn = HIShapeCreateEmpty();
}
-
- /*
- * Fortunately, the region returned by ScrollRect is semantically
- * the same as what we need to return in this function. If the
- * region is empty we return zero to denote that no damage was
- * created.
- */
-
- dmgRgn = HIShapeCreateWithQDRgn(tkMacOSXtmpQdRgn);
- SetEmptyRgn(tkMacOSXtmpQdRgn);
TkMacOSXSetWithNativeRegion(damageRgn, dmgRgn);
result = HIShapeIsEmpty(dmgRgn) ? 0 : 1;
CFRelease(dmgRgn);
@@ -1489,7 +1492,7 @@ TkScrollWindow(
* None.
*
* Side effects:
- * The current port is adjusted.
+ * None.
*
*----------------------------------------------------------------------
*/
@@ -1497,42 +1500,12 @@ TkScrollWindow(
void
TkMacOSXSetUpGraphicsPort(
GC gc, /* GC to apply to current port. */
- GWorldPtr destPort)
+ void *destPort)
{
- CGrafPtr savePort;
- Boolean portChanged;
-
- portChanged = QDSwapPort(destPort, &savePort);
- PenNormal();
- if (gc) {
- if (!penPat) {
- if (!tmpPixPat) {
- penPat = NewPixPat();
- } else {
- penPat = tmpPixPat;
- tmpPixPat = NULL;
- }
- }
- TkMacOSXSetColorInPort(gc->foreground, 1, penPat, destPort);
- PenPixPat(penPat);
- if(gc->function == GXxor) {
- PenMode(patXor);
- }
- if (gc->line_width > 1) {
- PenSize(gc->line_width, gc->line_width);
- }
- if (gc->line_style != LineSolid) {
- /*
- * FIXME: Here the dash pattern should be set in the drawing
- * environment. This is not possible with QuickDraw line drawing.
- */
- }
- }
- if (portChanged) {
- QDSwapPort(savePort, NULL);
- }
+ Tcl_Panic("TkMacOSXSetUpGraphicsPort: Obsolete, no more QD!");
}
+
/*
*----------------------------------------------------------------------
*
@@ -1559,101 +1532,98 @@ TkMacOSXSetupDrawingContext(
TkMacOSXDrawingContext *dcPtr)
{
MacDrawable *macDraw = ((MacDrawable*)d);
- int dontDraw = 0;
- TkMacOSXDrawingContext dc = {NULL, NULL, NULL, NULL, NULL, NULL, NULL,
- {SHRT_MIN, SHRT_MIN, SHRT_MAX, SHRT_MAX}, false};
-
- if (tkPictureIsOpen) {
- if (useCG) {
- TkMacOSXDbgMsg("Ignored CG Drawing with QD Picture open");
- dontDraw = 1;
- }
- } else {
- dc.clipRgn = TkMacOSXGetClipRgn(d);
- }
+ int dontDraw = 0, isWin = 0;
+ TkMacOSXDrawingContext dc = {};
+ CGRect clipBounds;
+
+ dc.clipRgn = TkMacOSXGetClipRgn(d);
if (!dontDraw) {
ClipToGC(d, gc, &dc.clipRgn);
dontDraw = dc.clipRgn ? HIShapeIsEmpty(dc.clipRgn) : 0;
}
if (dontDraw) {
- if (dc.clipRgn) {
- CFRelease(dc.clipRgn);
- dc.clipRgn = NULL;
- }
goto end;
}
if (useCG) {
- dc.context = macDraw->context;
+ dc.context = GetCGContextForDrawable(d);
}
if (!dc.context || !(macDraw->flags & TK_IS_PIXMAP)) {
- dc.port = TkMacOSXGetDrawablePort(d);
- if (dc.port) {
- GetPortBounds(dc.port, &dc.portBounds);
- }
+ isWin = (TkMacOSXDrawableWindow(d) != nil);
}
if (dc.context) {
- if (!dc.port) {
- CGRect r;
-
- TK_IF_MAC_OS_X_API (3, CGContextGetClipBoundingBox,
- r = CGContextGetClipBoundingBox(dc.context);
- ) TK_ELSE_MAC_OS_X (3,
- r.origin = CGPointZero;
- r.size = macDraw->size;
- ) TK_ENDIF
- SetRect(&dc.portBounds, r.origin.x + macDraw->xOff,
- r.origin.y + macDraw->yOff,
- r.origin.x + r.size.width + macDraw->xOff,
- r.origin.y + r.size.height + macDraw->yOff);
- }
- CGContextSaveGState(dc.context);
- dc.saveState = (void*)1;
- dc.port = NULL;
- } else if (dc.port) {
- dc.portChanged = QDSwapPort(dc.port, &dc.savePort);
- if (useCG && ChkErr(QDBeginCGContext, dc.port, &dc.context) == noErr) {
- SyncCGContextOriginWithPort(dc.context, dc.port);
+ dc.portBounds = clipBounds = CGContextGetClipBoundingBox(dc.context);
+ } else if (isWin) {
+ NSView *view = TkMacOSXDrawableView(macDraw);
+ if (view) {
+ if (view != [NSView focusView]) {
+ dc.focusLocked = [view lockFocusIfCanDraw];
+ dontDraw = !dc.focusLocked;
+ } else {
+ dontDraw = ![view canDraw];
+ }
+ if (dontDraw) {
+ goto end;
+ }
+ [[view window] disableFlushWindow];
+ dc.view = view;
+ dc.context = [[NSGraphicsContext currentContext] graphicsPort];
+ dc.portBounds = NSRectToCGRect([view bounds]);
+ if (dc.clipRgn) {
+ clipBounds = CGContextGetClipBoundingBox(dc.context);
+ }
} else {
- dc.context = NULL;
+ Tcl_Panic("TkMacOSXSetupDrawingContext(): "
+ "no NSView to draw into !");
}
} else {
Tcl_Panic("TkMacOSXSetupDrawingContext(): "
- "no port or context to draw into !");
+ "no context to draw into !");
}
if (dc.context) {
- CGContextConcatCTM(dc.context, CGAffineTransformMake(1.0, 0.0, 0.0,
- -1.0, 0.0, dc.portBounds.bottom - dc.portBounds.top));
+ CGAffineTransform t = { .a = 1, .b = 0, .c = 0, .d = -1, .tx = 0,
+ .ty = dc.portBounds.size.height};
+ dc.portBounds.origin.x += macDraw->xOff;
+ dc.portBounds.origin.y += macDraw->yOff;
+ if (!dc.focusLocked) {
+ CGContextSaveGState(dc.context);
+ }
+ CGContextSetTextDrawingMode(dc.context, kCGTextFill);
+ CGContextConcatCTM(dc.context, t);
if (dc.clipRgn) {
#ifdef TK_MAC_DEBUG_DRAWING
CGContextSaveGState(dc.context);
ChkErr(HIShapeReplacePathInCGContext, dc.clipRgn, dc.context);
- CGContextSetRGBFillColor(dc.context, 1.0, 0.0, 0.0, 0.2);
+ CGContextSetRGBFillColor(dc.context, 1.0, 0.0, 0.0, 0.1);
CGContextEOFillPath(dc.context);
CGContextRestoreGState(dc.context);
#endif /* TK_MAC_DEBUG_DRAWING */
- ChkErr(HIShapeReplacePathInCGContext, dc.clipRgn, dc.context);
- CGContextEOClip(dc.context);
+ CGRect r;
+ if (!HIShapeIsRectangular(dc.clipRgn) || !CGRectContainsRect(
+ *HIShapeGetBounds(dc.clipRgn, &r),
+ CGRectApplyAffineTransform(clipBounds, t))) {
+ ChkErr(HIShapeReplacePathInCGContext, dc.clipRgn, dc.context);
+ CGContextEOClip(dc.context);
+ }
}
if (gc) {
static const CGLineCap cgCap[] = {
- [CapNotLast] = kCGLineCapButt,
- [CapButt] = kCGLineCapButt,
- [CapRound] = kCGLineCapRound,
- [CapProjecting] = kCGLineCapSquare,
+ [CapNotLast] = kCGLineCapButt,
+ [CapButt] = kCGLineCapButt,
+ [CapRound] = kCGLineCapRound,
+ [CapProjecting] = kCGLineCapSquare,
};
static const CGLineJoin cgJoin[] = {
- [JoinMiter] = kCGLineJoinMiter,
- [JoinRound] = kCGLineJoinRound,
- [JoinBevel] = kCGLineJoinBevel,
+ [JoinMiter] = kCGLineJoinMiter,
+ [JoinRound] = kCGLineJoinRound,
+ [JoinBevel] = kCGLineJoinBevel,
};
bool shouldAntialias;
double w = gc->line_width;
- TkMacOSXSetColorInContext(gc->foreground, dc.context);
- if (dc.port) {
+ TkMacOSXSetColorInContext(gc, gc->foreground, dc.context);
+ if (isWin) {
CGContextSetPatternPhase(dc.context, CGSizeMake(
- dc.portBounds.right - dc.portBounds.left,
- dc.portBounds.bottom - dc.portBounds.top));
+ dc.portBounds.size.width, dc.portBounds.size.height));
}
if(gc->function != GXcopy) {
TkMacOSXDbgMsg("Logical functions other than GXcopy are "
@@ -1670,8 +1640,8 @@ TkMacOSXSetupDrawingContext(
if (gc->line_style != LineSolid) {
int num = 0;
char *p = &(gc->dashes);
- double dashOffset = gc->dash_offset;
- float lengths[10];
+ CGFloat dashOffset = gc->dash_offset;
+ CGFloat lengths[10];
while (p[num] != '\0' && num < 10) {
lengths[num] = p[num];
@@ -1688,26 +1658,12 @@ TkMacOSXSetupDrawingContext(
cgJoin[(unsigned)gc->join_style]);
}
}
- } else if (dc.port) {
- PixPatHandle savePat = penPat;
-
- ChkErr(GetThemeDrawingState, &dc.saveState);
- penPat = NULL;
- TkMacOSXSetUpGraphicsPort(gc, dc.port);
- dc.penPat = penPat;
- penPat = savePat;
- dc.saveClip = NewRgn();
- GetPortClipRegion(dc.port, dc.saveClip);
- if (dc.clipRgn) {
- ChkErr(HIShapeSetQDClip, dc.clipRgn, dc.port);
- } else {
- NoQDClip(dc.port);
- }
- if (!tkPictureIsOpen) {
- ShowPen();
- }
}
end:
+ if (dontDraw && dc.clipRgn) {
+ CFRelease(dc.clipRgn);
+ dc.clipRgn = NULL;
+ }
*dcPtr = dc;
return !dontDraw;
}
@@ -1734,38 +1690,16 @@ TkMacOSXRestoreDrawingContext(
{
if (dcPtr->context) {
CGContextSynchronize(dcPtr->context);
- if (dcPtr->saveState) {
+ [[dcPtr->view window] enableFlushWindow];
+ if (dcPtr->focusLocked) {
+ [dcPtr->view unlockFocus];
+ } else {
CGContextRestoreGState(dcPtr->context);
}
- if (dcPtr->port) {
- ChkErr(QDEndCGContext, dcPtr->port, &(dcPtr->context));
- }
- } else if (dcPtr->port) {
- if (!tkPictureIsOpen) {
- HidePen();
- }
- PenNormal();
- if (dcPtr->saveClip) {
- SetPortClipRegion(dcPtr->port, dcPtr->saveClip);
- DisposeRgn(dcPtr->saveClip);
- }
- if (dcPtr->penPat) {
- if (!tmpPixPat) {
- tmpPixPat = dcPtr->penPat;
- } else {
- DisposePixPat(dcPtr->penPat);
- }
- }
- if (dcPtr->saveState) {
- ChkErr(SetThemeDrawingState, dcPtr->saveState, true);
- }
}
if (dcPtr->clipRgn) {
CFRelease(dcPtr->clipRgn);
}
- if (dcPtr->portChanged) {
- QDSwapPort(dcPtr->savePort, NULL);
- }
#ifdef TK_MAC_DEBUG
bzero(dcPtr, sizeof(TkMacOSXDrawingContext));
#endif /* TK_MAC_DEBUG */
@@ -1794,35 +1728,31 @@ TkMacOSXGetClipRgn(
{
MacDrawable *macDraw = (MacDrawable *) drawable;
HIShapeRef clipRgn = NULL;
- CGRect r;
if (macDraw->winPtr && macDraw->flags & TK_CLIP_INVALID) {
TkMacOSXUpdateClipRgn(macDraw->winPtr);
#ifdef TK_MAC_DEBUG_DRAWING
- TkMacOSXDbgMsg("%s visRgn ", macDraw->winPtr->pathName);
- TkMacOSXDebugFlashRegion(drawable, macDraw->visRgn);
+ TkMacOSXDbgMsg("%s", macDraw->winPtr->pathName);
+ NSView *view = TkMacOSXDrawableView(macDraw);
+ if ([view lockFocusIfCanDraw]) {
+ CGContextRef context = [[NSGraphicsContext currentContext] graphicsPort];
+ CGContextSaveGState(context);
+ CGContextConcatCTM(context, CGAffineTransformMake(1.0, 0.0, 0.0,
+ -1.0, 0.0, [view bounds].size.height));
+ ChkErr(HIShapeReplacePathInCGContext, macDraw->visRgn, context);
+ CGContextSetRGBFillColor(context, 0.0, 1.0, 0.0, 0.1);
+ CGContextEOFillPath(context);
+ CGContextRestoreGState(context);
+ [view unlockFocus];
+ }
#endif /* TK_MAC_DEBUG_DRAWING */
}
- if (macDraw->flags & TK_CLIPPED_DRAW) {
- r = CGRectOffset(macDraw->drawRect, macDraw->xOff, macDraw->yOff);
- }
- if (macDraw->visRgn) {
- if (macDraw->flags & TK_CLIPPED_DRAW) {
- HIShapeRef rgn = HIShapeCreateWithRect(&r);
-
- clipRgn = HIShapeCreateIntersection(macDraw->visRgn, rgn);
- CFRelease(rgn);
- } else {
- clipRgn = HIShapeCreateCopy(macDraw->visRgn);
- }
- } else if (macDraw->flags & TK_CLIPPED_DRAW) {
- clipRgn = HIShapeCreateWithRect(&r);
+ if (macDraw->drawRgn) {
+ clipRgn = HIShapeCreateCopy(macDraw->drawRgn);
+ } else if (macDraw->visRgn) {
+ clipRgn = HIShapeCreateCopy(macDraw->visRgn);
}
-#ifdef TK_MAC_DEBUG_DRAWING
- TkMacOSXDbgMsg("%s clipRgn ", macDraw->winPtr->pathName);
- TkMacOSXDebugFlashRegion(drawable, clipRgn);
-#endif /* TK_MAC_DEBUG_DRAWING */
return clipRgn;
}
@@ -1839,7 +1769,7 @@ TkMacOSXGetClipRgn(
* None.
*
* Side effects:
- * The clipping region in the current port is changed.
+ * None.
*
*----------------------------------------------------------------------
*/
@@ -1848,16 +1778,6 @@ void
TkMacOSXSetUpClippingRgn(
Drawable drawable) /* Drawable to update. */
{
- CGrafPtr port = TkMacOSXGetDrawablePort(drawable);
-
- if (port) {
- HIShapeRef clipRgn = TkMacOSXGetClipRgn(drawable);
-
- if (clipRgn) {
- ChkErr(HIShapeSetQDClip, clipRgn, port);
- CFRelease(clipRgn);
- }
- }
}
/*
@@ -1866,7 +1786,7 @@ TkMacOSXSetUpClippingRgn(
* TkpClipDrawableToRect --
*
* Clip all drawing into the drawable d to the given rectangle.
- * If width and height are negative, reset to no clipping.
+ * If width or height are negative, reset to no clipping.
*
* Results:
* None.
@@ -1885,13 +1805,38 @@ TkpClipDrawableToRect(
int width, int height)
{
MacDrawable *macDraw = (MacDrawable *) d;
+ NSView *view = TkMacOSXDrawableView(macDraw);
- if (width < 0 && height < 0) {
- macDraw->drawRect = CGRectNull;
- macDraw->flags &= ~TK_CLIPPED_DRAW;
+ if (macDraw->drawRgn) {
+ CFRelease(macDraw->drawRgn);
+ macDraw->drawRgn = NULL;
+ }
+ if (width >= 0 && height >= 0) {
+ CGRect drawRect = CGRectMake(x + macDraw->xOff, y + macDraw->yOff,
+ width, height);
+ HIShapeRef drawRgn = HIShapeCreateWithRect(&drawRect);
+
+ if (macDraw->winPtr && macDraw->flags & TK_CLIP_INVALID) {
+ TkMacOSXUpdateClipRgn(macDraw->winPtr);
+ }
+ if (macDraw->visRgn) {
+ macDraw->drawRgn = HIShapeCreateIntersection(macDraw->visRgn,
+ drawRgn);
+ CFRelease(drawRgn);
+ } else {
+ macDraw->drawRgn = drawRgn;
+ }
+ if (view && view != [NSView focusView] && [view lockFocusIfCanDraw]) {
+ drawRect.origin.y = [view bounds].size.height -
+ (drawRect.origin.y + drawRect.size.height);
+ NSRectClip(NSRectFromCGRect(drawRect));
+ macDraw->flags |= TK_FOCUSED_VIEW;
+ }
} else {
- macDraw->drawRect = CGRectMake(x, y, width, height);
- macDraw->flags |= TK_CLIPPED_DRAW;
+ if (view && (macDraw->flags & TK_FOCUSED_VIEW)) {
+ [view unlockFocus];
+ macDraw->flags &= ~TK_FOCUSED_VIEW;
+ }
}
}
@@ -1924,9 +1869,7 @@ ClipToGC(
int yOffset = ((MacDrawable *) d)->yOff + gc->clip_y_origin;
HIShapeRef clipRgn = *clipRgnPtr, gcClipRgn;
- if (!tkPictureIsOpen) {
- TkMacOSXOffsetRegion(gcClip, xOffset, yOffset);
- }
+ TkMacOSXOffsetRegion(gcClip, xOffset, yOffset);
gcClipRgn = TkMacOSXGetNativeRegion(gcClip);
if (clipRgn) {
*clipRgnPtr = HIShapeCreateIntersection(gcClipRgn, clipRgn);
@@ -1935,39 +1878,8 @@ ClipToGC(
*clipRgnPtr = HIShapeCreateCopy(gcClipRgn);
}
CFRelease(gcClipRgn);
- if (!tkPictureIsOpen) {
- TkMacOSXOffsetRegion(gcClip, -xOffset, -yOffset);
- }
- }
-}
-
-/*
- *----------------------------------------------------------------------
- *
- * NoQDClip --
- *
- * Helper function to setup a QD port to not clip anything.
- *
- * Results:
- * None.
- *
- * Side effects:
- * None.
- *
- *----------------------------------------------------------------------
- */
-
-static void
-NoQDClip(
- CGrafPtr port)
-{
- static RgnHandle noClipRgn = NULL;
-
- if (!noClipRgn) {
- noClipRgn = NewRgn();
- SetRectRgn(noClipRgn, SHRT_MIN, SHRT_MIN, SHRT_MAX, SHRT_MAX);
+ TkMacOSXOffsetRegion(gcClip, -xOffset, -yOffset);
}
- SetPortClipRegion(port, noClipRgn);
}
/*
@@ -1989,45 +1901,12 @@ NoQDClip(
*----------------------------------------------------------------------
*/
-BitMapPtr
+void *
TkMacOSXMakeStippleMap(
Drawable drawable, /* Window to apply stipple. */
Drawable stipple) /* The stipple pattern. */
{
- CGrafPtr stipplePort;
- BitMapPtr bitmapPtr;
- const BitMap *stippleBitmap;
- Rect portRect;
- int width, height, stippleHeight, stippleWidth, i, j;
- Rect bounds;
-
- GetPortBounds(TkMacOSXGetDrawablePort(drawable), &portRect);
- width = portRect.right - portRect.left;
- height = portRect.bottom - portRect.top;
- bitmapPtr = (BitMap *) ckalloc(sizeof(BitMap));
- bitmapPtr->bounds.top = bitmapPtr->bounds.left = 0;
- bitmapPtr->bounds.right = (short) width;
- bitmapPtr->bounds.bottom = (short) height;
- bitmapPtr->rowBytes = (width / 8) + 1;
- bitmapPtr->baseAddr = ckalloc(height * bitmapPtr->rowBytes);
-
- stipplePort = TkMacOSXGetDrawablePort(stipple);
- stippleBitmap = GetPortBitMapForCopyBits(stipplePort);
- GetPortBounds(stipplePort, &portRect);
- stippleWidth = portRect.right - portRect.left;
- stippleHeight = portRect.bottom - portRect.top;
-
- for (i = 0; i < height; i += stippleHeight) {
- for (j = 0; j < width; j += stippleWidth) {
- bounds.left = j;
- bounds.top = i;
- bounds.right = j + stippleWidth;
- bounds.bottom = i + stippleHeight;
- CopyBits(stippleBitmap, bitmapPtr, &portRect, &bounds, srcCopy,
- NULL);
- }
- }
- return bitmapPtr;
+ return NULL;
}
/*
@@ -2115,3 +1994,12 @@ TkpDrawFrame(
Tk_Height(tkwin) - 2 * highlightWidth,
borderWidth, relief);
}
+
+/*
+ * Local Variables:
+ * mode: c
+ * c-basic-offset: 4
+ * fill-column: 79
+ * coding: utf-8
+ * End:
+ */
diff --git a/macosx/tkMacOSXEmbed.c b/macosx/tkMacOSXEmbed.c
index 85bfe05..3f195aa 100644
--- a/macosx/tkMacOSXEmbed.c
+++ b/macosx/tkMacOSXEmbed.c
@@ -8,14 +8,16 @@
* Tk application is allowed on the Macintosh.
*
* Copyright (c) 1996-1997 Sun Microsystems, Inc.
- * Copyright 2001, Apple Computer, Inc.
- * Copyright (c) 2006-2008 Daniel A. Steffen <das@users.sourceforge.net>
+ * Copyright 2001-2009, Apple Inc.
+ * Copyright (c) 2006-2009 Daniel A. Steffen <das@users.sourceforge.net>
*
- * See the file "license.terms" for information on usage and redistribution of
- * this file, and for a DISCLAIMER OF ALL WARRANTIES.
+ * See the file "license.terms" for information on usage and redistribution
+ * of this file, and for a DISCLAIMER OF ALL WARRANTIES.
+ *
+ * RCS: @(#) $Id$
*/
-#include "tkMacOSXInt.h"
+#include "tkMacOSXPrivate.h"
/*
* One of the following structures exists for each container in this
@@ -143,10 +145,10 @@ TkpMakeWindow(
winPtr->privatePtr = macWin;
macWin->visRgn = NULL;
macWin->aboveVisRgn = NULL;
- macWin->drawRect = CGRectNull;
+ macWin->drawRgn = NULL;
macWin->referenceCount = 0;
macWin->flags = TK_CLIP_INVALID;
- macWin->grafPtr = NULL;
+ macWin->view = nil;
macWin->context = NULL;
macWin->size = CGSizeZero;
if (Tk_IsTopLevel(macWin->winPtr)) {
@@ -157,7 +159,7 @@ TkpMakeWindow(
macWin->xOff = 0;
macWin->yOff = 0;
macWin->toplevel = macWin;
- } else {
+ } else if (winPtr->parentPtr) {
macWin->xOff = winPtr->parentPtr->privatePtr->xOff +
winPtr->parentPtr->changes.border_width +
winPtr->changes.x;
@@ -199,7 +201,7 @@ TkpUseWindow(
* string is bogus. */
Tk_Window tkwin, /* Tk window that does not yet have an
* associated X window. */
- CONST char *string) /* String identifying an X window to use for
+ const char *string) /* String identifying an X window to use for
* tkwin; must be an integer value. */
{
TkWindow *winPtr = (TkWindow *) tkwin;
@@ -277,12 +279,12 @@ TkpUseWindow(
* correctly find the container's port.
*/
- macWin->grafPtr = NULL;
+ macWin->view = nil;
macWin->context = NULL;
macWin->size = CGSizeZero;
macWin->visRgn = NULL;
macWin->aboveVisRgn = NULL;
- macWin->drawRect = CGRectNull;
+ macWin->drawRgn = NULL;
macWin->referenceCount = 0;
macWin->flags = TK_CLIP_INVALID;
macWin->toplevel = macWin;
@@ -310,7 +312,7 @@ TkpUseWindow(
*/
if (tkMacOSXEmbedHandler == NULL ||
- tkMacOSXEmbedHandler->registerWinProc((int) parent,
+ tkMacOSXEmbedHandler->registerWinProc((long) parent,
(Tk_Window) winPtr) != TCL_OK) {
Tcl_AppendResult(interp, "The window ID ", string,
" does not correspond to a valid Tk Window.", NULL);
@@ -561,7 +563,7 @@ TkpTestembedCmd(
ClientData clientData, /* Main window for application. */
Tcl_Interp *interp, /* Current interpreter. */
int argc, /* Number of arguments. */
- CONST char **argv) /* Argument strings. */
+ const char **argv) /* Argument strings. */
{
int all;
Container *containerPtr;
@@ -640,6 +642,7 @@ TkpRedirectKeyEvent(
XEvent *eventPtr) /* X event to redirect (should be KeyPress or
* KeyRelease). */
{
+ /* TODO: Implement this or decide it definitely needs no implementation */
}
/*
@@ -1085,7 +1088,7 @@ EmbedWindowDeleted(
XEvent event;
event.xany.serial =
- Tk_Display(containerPtr->parentPtr)->request;
+ LastKnownRequestProcessed(Tk_Display(containerPtr->parentPtr));
event.xany.send_event = False;
event.xany.display = Tk_Display(containerPtr->parentPtr);
@@ -1116,3 +1119,12 @@ EmbedWindowDeleted(
ckfree((char *) containerPtr);
}
}
+
+/*
+ * Local Variables:
+ * mode: c
+ * c-basic-offset: 4
+ * fill-column: 79
+ * coding: utf-8
+ * End:
+ */
diff --git a/macosx/tkMacOSXEntry.c b/macosx/tkMacOSXEntry.c
index 64b8f3a..61a3586 100644
--- a/macosx/tkMacOSXEntry.c
+++ b/macosx/tkMacOSXEntry.c
@@ -4,70 +4,29 @@
* This file implements the native aqua entry widget.
*
* Copyright 2001, Apple Computer, Inc.
- * Copyright (c) 2006-2007 Daniel A. Steffen <das@users.sourceforge.net>
+ * Copyright (c) 2006-2009 Daniel A. Steffen <das@users.sourceforge.net>
+ * Copyright 2008-2009, Apple Inc.
*
- * See the file "license.terms" for information on usage and redistribution of
- * this file, and for a DISCLAIMER OF ALL WARRANTIES.
+ * See the file "license.terms" for information on usage and redistribution
+ * of this file, and for a DISCLAIMER OF ALL WARRANTIES.
*
- * The following terms apply to all files originating from Apple
- * Computer, Inc. ("Apple") and associated with the software
- * unless explicitly disclaimed in individual files.
- *
- *
- * Apple hereby grants permission to use, copy, modify,
- * distribute, and license this software and its documentation
- * for any purpose, provided that existing copyright notices are
- * retained in all copies and that this notice is included
- * verbatim in any distributions. No written agreement, license,
- * or royalty fee is required for any of the authorized
- * uses. Modifications to this software may be copyrighted by
- * their authors and need not follow the licensing terms
- * described here, provided that the new terms are clearly
- * indicated on the first page of each file where they apply.
- *
- *
- * IN NO EVENT SHALL APPLE, THE AUTHORS OR DISTRIBUTORS OF THE
- * SOFTWARE BE LIABLE TO ANY PARTY FOR DIRECT, INDIRECT, SPECIAL,
- * INCIDENTAL, OR CONSEQUENTIAL DAMAGES ARISING OUT OF THE USE OF
- * THIS SOFTWARE, ITS DOCUMENTATION, OR ANY DERIVATIVES THEREOF,
- * EVEN IF APPLE OR THE AUTHORS HAVE BEEN ADVISED OF THE
- * POSSIBILITY OF SUCH DAMAGE. APPLE, THE AUTHORS AND
- * DISTRIBUTORS SPECIFICALLY DISCLAIM ANY WARRANTIES, INCLUDING,
- * BUT NOT LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY,
- * FITNESS FOR A PARTICULAR PURPOSE, AND NON-INFRINGEMENT. THIS
- * SOFTWARE IS PROVIDED ON AN "AS IS" BASIS, AND APPLE,THE
- * AUTHORS AND DISTRIBUTORS HAVE NO OBLIGATION TO PROVIDE
- * MAINTENANCE, SUPPORT, UPDATES, ENHANCEMENTS, OR MODIFICATIONS.
- *
- * GOVERNMENT USE: If you are acquiring this software on behalf
- * of the U.S. government, the Government shall have only
- * "Restricted Rights" in the software and related documentation
- * as defined in the Federal Acquisition Regulations (FARs) in
- * Clause 52.227.19 (c) (2). If you are acquiring the software
- * on behalf of the Department of Defense, the software shall be
- * classified as "Commercial Computer Software" and the
- * Government shall have only "Restricted Rights" as defined in
- * Clause 252.227-7013 (c) (1) of DFARs. Notwithstanding the
- * foregoing, the authors grant the U.S. Government and others
- * acting in its behalf permission to use and distribute the
- * software in accordance with the terms specified in this
- * license.
+ * RCS: @(#) $Id$
*/
#include "tkMacOSXPrivate.h"
-#include "tkMacOSXDefault.h"
#include "tkEntry.h"
-static ThemeButtonKind ComputeIncDecParameters (int height, int *width);
+static ThemeButtonKind ComputeIncDecParameters(int height, int *width);
+#define HIOrientation kHIThemeOrientationNormal
+
/*
*--------------------------------------------------------------
*
* ComputeIncDecParameters --
*
- * This procedure figures out which of the kThemeIncDec
- * buttons to use. It also sets width to the width of the
- * IncDec button.
+ * This procedure figures out which of the kThemeIncDec buttons to use.
+ * It also sets width to the width of the IncDec button.
*
* Results:
* The ThemeButtonKind of the button we should use.
@@ -77,51 +36,43 @@ static ThemeButtonKind ComputeIncDecParameters (int height, int *width);
*
*--------------------------------------------------------------
*/
+
static ThemeButtonKind
-ComputeIncDecParameters(int height, int *width)
+ComputeIncDecParameters(
+ int height,
+ int *width)
{
ThemeButtonKind kind;
- TK_IF_HI_TOOLBOX (3,
- if (height < 11 || height > 28) {
- *width = 0;
- kind = (ThemeButtonKind) 0;
- } else {
- if (height >= 21) {
- *width = 13;
- kind = kThemeIncDecButton;
- } else if (height >= 18) {
- *width = 12;
- kind = kThemeIncDecButtonSmall;
- } else {
- *width = 11;
- kind = kThemeIncDecButtonMini;
- }
- }
- ) TK_ELSE_HI_TOOLBOX (3,
- if (height < 21 || height > 28) {
- *width = 0;
- kind = (ThemeButtonKind) 0;
- } else {
+ if (height < 11 || height > 28) {
+ *width = 0;
+ kind = (ThemeButtonKind) 0;
+ } else {
+ if (height >= 21) {
*width = 13;
kind = kThemeIncDecButton;
+ } else if (height >= 18) {
+ *width = 12;
+ kind = kThemeIncDecButtonSmall;
+ } else {
+ *width = 11;
+ kind = kThemeIncDecButtonMini;
}
- ) TK_ENDIF
+ }
return kind;
}
-
+
/*
*--------------------------------------------------------------
*
* TkpDrawEntryBorderAndFocus --
*
- * This procedure redraws the border of an entry window.
- * It overrides the generic border drawing code if the
- * entry widget parameters are such that the native widget
- * drawing is a good fit.
- * This version just returns 1, so platforms that don't
- * do special native drawing don't have to implement it.
+ * This procedure redraws the border of an entry window. It overrides the
+ * generic border drawing code if the entry widget parameters are such
+ * that the native widget drawing is a good fit. This version just
+ * returns 1, so platforms that don't do special native drawing don't
+ * have to implement it.
*
* Results:
* 1 if it has drawn the border, 0 if not.
@@ -131,21 +82,31 @@ ComputeIncDecParameters(int height, int *width)
*
*--------------------------------------------------------------
*/
+
int
-TkpDrawEntryBorderAndFocus(Entry *entryPtr, Drawable d, int isSpinbox)
+TkpDrawEntryBorderAndFocus(
+ Entry *entryPtr,
+ Drawable d,
+ int isSpinbox)
{
- Rect bounds;
+ CGRect bounds;
TkMacOSXDrawingContext dc;
GC bgGC;
Tk_Window tkwin = entryPtr->tkwin;
- ThemeDrawState drawState;
int oldWidth = 0;
MacDrawable *macDraw = (MacDrawable *) d;
+ const HIThemeFrameDrawInfo info = {
+ .version = 0,
+ .kind = kHIThemeFrameTextFieldSquare,
+ .state = (entryPtr->state == STATE_DISABLED ? kThemeStateInactive :
+ kThemeStateActive),
+ .isFocused = (entryPtr->flags & GOT_FOCUS ? 1 : 0),
+ };
/*
- * I use 6 as the borderwidth. 2 of the 5 go into the actual frame the
- * 3 are because the Mac OS Entry widgets leave more space around the
- * Text than Tk does on X11.
+ * I use 6 as the borderwidth. 2 of the 5 go into the actual frame the 3
+ * are because the Mac OS Entry widgets leave more space around the Text
+ * than Tk does on X11.
*/
if (entryPtr->borderWidth != MAC_OSX_ENTRY_BORDER
@@ -155,76 +116,61 @@ TkpDrawEntryBorderAndFocus(Entry *entryPtr, Drawable d, int isSpinbox)
}
/*
- * For the spinbox, we have to make the entry part smaller by the size
- * of the buttons. We also leave 2 pixels to the left (as per the HIG)
- * and space for one pixel to the right, 'cause it makes the buttons look
+ * For the spinbox, we have to make the entry part smaller by the size of
+ * the buttons. We also leave 2 pixels to the left (as per the HIG) and
+ * space for one pixel to the right, 'cause it makes the buttons look
* nicer.
*/
if (isSpinbox) {
- ThemeButtonKind buttonKind;
int incDecWidth;
oldWidth = Tk_Width(tkwin);
- buttonKind = ComputeIncDecParameters(Tk_Height(tkwin)
- - 2 * MAC_OSX_FOCUS_WIDTH, &incDecWidth);
+ ComputeIncDecParameters(Tk_Height(tkwin) - 2 * MAC_OSX_FOCUS_WIDTH,
+ &incDecWidth);
Tk_Width(tkwin) -= incDecWidth + 1;
}
/*
- * The focus ring is drawn with an Alpha at the outside
- * part of the ring, so we have to draw over the edges of the
- * ring before drawing the focus or the text will peep through.
+ * The focus ring is drawn with an Alpha at the outside part of the ring,
+ * so we have to draw over the edges of the ring before drawing the focus
+ * or the text will peep through.
*/
bgGC = Tk_GCForColor(entryPtr->highlightBgColorPtr, d);
TkDrawInsetFocusHighlight(entryPtr->tkwin, bgGC, MAC_OSX_FOCUS_WIDTH, d, 0);
/*
- * Inset the entry Frame by the maximum width of the focus rect,
- * which is 3 according to the Carbon docs.
+ * Inset the entry Frame by the maximum width of the focus rect, which is
+ * 3 according to the Carbon docs.
*/
- bounds.left = macDraw->xOff + MAC_OSX_FOCUS_WIDTH;
- bounds.top = macDraw->yOff + MAC_OSX_FOCUS_WIDTH;
- bounds.right = macDraw->xOff + Tk_Width(tkwin) - MAC_OSX_FOCUS_WIDTH;
- bounds.bottom = macDraw->yOff + Tk_Height(tkwin) - MAC_OSX_FOCUS_WIDTH;
- if (entryPtr->state == STATE_DISABLED) {
- drawState = kThemeStateInactive;
- } else {
- drawState = kThemeStateActive;
- }
- if (!TkMacOSXSetupDrawingContext(d, NULL, 0, &dc)) {
+ bounds.origin.x = macDraw->xOff + MAC_OSX_FOCUS_WIDTH;
+ bounds.origin.y = macDraw->yOff + MAC_OSX_FOCUS_WIDTH;
+ bounds.size.width = Tk_Width(tkwin) - 2*MAC_OSX_FOCUS_WIDTH;
+ bounds.size.height = Tk_Height(tkwin) - 2*MAC_OSX_FOCUS_WIDTH;
+ if (!TkMacOSXSetupDrawingContext(d, NULL, 1, &dc)) {
return 0;
}
- DrawThemeEditTextFrame(&bounds, drawState);
- if (entryPtr->flags & GOT_FOCUS) {
- /*
- * Don't call this if we don't have the focus, because then it
- * erases the focus rect to white, but we've already drawn the
- * highlightbackground above.
- */
-
- DrawThemeFocusRect(&bounds, (entryPtr->flags & GOT_FOCUS) != 0);
- }
+ ChkErr(HIThemeDrawFrame, &bounds, &info, dc.context, HIOrientation);
+ TkMacOSXRestoreDrawingContext(&dc);
if (isSpinbox) {
Tk_Width(tkwin) = oldWidth;
}
- TkMacOSXRestoreDrawingContext(&dc);
return 1;
}
+
/*
*--------------------------------------------------------------
*
* TkpDrawSpinboxButtons --
*
- * This procedure redraws the buttons of an spinbox widget.
- * It overrides the generic button drawing code if the
- * spinbox widget parameters are such that the native widget
- * drawing is a good fit.
- * This version just returns 0, so platforms that don't
- * do special native drawing don't have to implement it.
+ * This procedure redraws the buttons of an spinbox widget. It overrides
+ * the generic button drawing code if the spinbox widget parameters are
+ * such that the native widget drawing is a good fit. This version just
+ * returns 0, so platforms that don't do special native drawing don't
+ * have to implement it.
*
* Results:
* 1 if it has drawn the border, 0 if not.
@@ -236,15 +182,11 @@ TkpDrawEntryBorderAndFocus(Entry *entryPtr, Drawable d, int isSpinbox)
*/
int
-TkpDrawSpinboxButtons(Spinbox *sbPtr, Drawable d)
+TkpDrawSpinboxButtons(
+ Spinbox *sbPtr,
+ Drawable d)
{
- Rect inBounds;
- ThemeButtonKind inKind;
- ThemeButtonDrawInfo inNewInfo;
- ThemeButtonDrawInfo * inPrevInfo = NULL;
- ThemeEraseUPP inEraseProc = NULL;
- ThemeButtonDrawUPP inLabelProc = NULL;
- UInt32 inUserData = 0;
+ CGRect bounds;
Tk_Window tkwin = sbPtr->entry.tkwin;
int height = Tk_Height(tkwin);
int buttonHeight = height - 2 * MAC_OSX_FOCUS_WIDTH;
@@ -253,6 +195,10 @@ TkpDrawSpinboxButtons(Spinbox *sbPtr, Drawable d)
XRectangle rects[1];
GC bgGC;
MacDrawable *macDraw = (MacDrawable *) d;
+ HIThemeButtonDrawInfo info = {
+ .version = 0,
+ .adornment = kThemeAdornmentNone,
+ };
/*
* FIXME: RAISED really makes more sense
@@ -263,56 +209,61 @@ TkpDrawSpinboxButtons(Spinbox *sbPtr, Drawable d)
}
/*
- * The actual sizes of the IncDec button are 21 for the normal,
- * 18 for the small and 15 for the mini. But the spinbox still
- * looks okay if the entry is a little bigger than this, so we
- * give it a little slop.
+ * The actual sizes of the IncDec button are 21 for the normal, 18 for the
+ * small and 15 for the mini. But the spinbox still looks okay if the
+ * entry is a little bigger than this, so we give it a little slop.
*/
- inKind = ComputeIncDecParameters(buttonHeight, &incDecWidth);
- if (inKind == (ThemeButtonKind) 0) {
+ info.kind = ComputeIncDecParameters(buttonHeight, &incDecWidth);
+ if (info.kind == (ThemeButtonKind) 0) {
return 0;
}
if (sbPtr->entry.state == STATE_DISABLED) {
- inNewInfo.state = kThemeStateInactive;
- inNewInfo.value = kThemeButtonOff;
+ info.state = kThemeStateInactive;
+ info.value = kThemeButtonOff;
} else if (sbPtr->selElement == SEL_BUTTONUP) {
- inNewInfo.state = kThemeStatePressedUp;
- inNewInfo.value = kThemeButtonOn;
+ info.state = kThemeStatePressedUp;
+ info.value = kThemeButtonOn;
} else if (sbPtr->selElement == SEL_BUTTONDOWN) {
- inNewInfo.state = kThemeStatePressedDown;
- inNewInfo.value = kThemeButtonOn;
+ info.state = kThemeStatePressedDown;
+ info.value = kThemeButtonOn;
} else {
- inNewInfo.state = kThemeStateActive;
- inNewInfo.value = kThemeButtonOff;
+ info.state = kThemeStateActive;
+ info.value = kThemeButtonOff;
}
- inNewInfo.adornment = kThemeAdornmentNone;
-
- inBounds.left = macDraw->xOff + Tk_Width(tkwin) - incDecWidth - 1;
- inBounds.right = macDraw->xOff + Tk_Width(tkwin) - 1;
- inBounds.top = macDraw->yOff + MAC_OSX_FOCUS_WIDTH;
- inBounds.bottom = macDraw->yOff + Tk_Height(tkwin) - MAC_OSX_FOCUS_WIDTH;
+ bounds.origin.x = macDraw->xOff + Tk_Width(tkwin) - incDecWidth - 1;
+ bounds.origin.y = macDraw->yOff + MAC_OSX_FOCUS_WIDTH;
+ bounds.size.width = incDecWidth;
+ bounds.size.height = Tk_Height(tkwin) - 2*MAC_OSX_FOCUS_WIDTH;
- /* We had to make the entry part of the window smaller so that we
- * wouldn't overdraw the spin buttons with the focus highlight. So
- * now we have to draw the highlightbackground.
+ /*
+ * We had to make the entry part of the window smaller so that we wouldn't
+ * overdraw the spin buttons with the focus highlight. So now we have to
+ * draw the highlightbackground.
*/
bgGC = Tk_GCForColor(sbPtr->entry.highlightBgColorPtr, d);
- rects[0].x = inBounds.left;
+ rects[0].x = bounds.origin.x;
rects[0].y = 0;
rects[0].width = Tk_Width(tkwin);
rects[0].height = Tk_Height(tkwin);
XFillRectangles(Tk_Display(tkwin), d, bgGC, rects, 1);
- if (!TkMacOSXSetupDrawingContext(d, NULL, 0, &dc)) {
+ if (!TkMacOSXSetupDrawingContext(d, NULL, 1, &dc)) {
return 0;
}
- ChkErr(DrawThemeButton, &inBounds, inKind, &inNewInfo, inPrevInfo,
- inEraseProc, inLabelProc, inUserData);
+ ChkErr(HIThemeDrawButton, &bounds, &info, dc.context, HIOrientation, NULL);
TkMacOSXRestoreDrawingContext(&dc);
return 1;
}
-
+
+/*
+ * Local Variables:
+ * mode: c
+ * c-basic-offset: 4
+ * fill-column: 79
+ * coding: utf-8
+ * End:
+ */
diff --git a/macosx/tkMacOSXEvent.c b/macosx/tkMacOSXEvent.c
index 5da46a9..193d0fa 100644
--- a/macosx/tkMacOSXEvent.c
+++ b/macosx/tkMacOSXEvent.c
@@ -4,267 +4,153 @@
* This file contains the basic Mac OS X Event handling routines.
*
* Copyright (c) 1995-1997 Sun Microsystems, Inc.
- * Copyright 2001, Apple Computer, Inc.
- * Copyright (c) 2005-2007 Daniel A. Steffen <das@users.sourceforge.net>
+ * Copyright 2001-2009, Apple Inc.
+ * Copyright (c) 2005-2009 Daniel A. Steffen <das@users.sourceforge.net>
*
* See the file "license.terms" for information on usage and redistribution
* of this file, and for a DISCLAIMER OF ALL WARRANTIES.
+ *
+ * RCS: @(#) $Id$
*/
#include "tkMacOSXPrivate.h"
#include "tkMacOSXEvent.h"
#include "tkMacOSXDebug.h"
-
-/*
- *----------------------------------------------------------------------
- *
- * TkMacOSXFlushWindows --
- *
- * This routine flushes all the Carbon windows of the application. It
- * is called by XSync().
- *
- * Results:
- * None.
- *
- * Side effects:
- * Flushes all Carbon windows
- *
- *----------------------------------------------------------------------
- */
+#pragma mark TKApplication(TKEvent)
-MODULE_SCOPE void
-TkMacOSXFlushWindows(void)
-{
- WindowRef wRef = GetWindowList();
+enum {
+ NSWindowWillMoveEventType = 20
+};
- while (wRef) {
- TK_IF_MAC_OS_X_API (3, HIWindowFlush,
- ChkErr(HIWindowFlush, wRef);
- ) TK_ELSE_MAC_OS_X (3,
- CGrafPtr portPtr = GetWindowPort(wRef);
+@implementation TKApplication(TKEvent)
+/* TODO: replace by +[addLocalMonitorForEventsMatchingMask ? */
+- (NSEvent *)tkProcessEvent:(NSEvent *)theEvent {
+#ifdef TK_MAC_DEBUG_EVENTS
+ TKLog(@"-[%@(%p) %s] %@", [self class], self, _cmd, theEvent);
+#endif
+ NSEvent *processedEvent = theEvent;
+ NSEventType type = [theEvent type];
+ NSInteger subtype;
+ NSUInteger flags;
- if (QDIsPortBuffered(portPtr)) {
- QDFlushPortBuffer(portPtr, NULL);
- }
- ) TK_ENDIF
- wRef = GetNextWindow(wRef);
- }
-}
-
-/*
- *----------------------------------------------------------------------
- *
- * TkMacOSXProcessEvent --
- *
- * This dispatches a filtered Carbon event to the appropriate handler
- *
- * Note on MacEventStatus.stopProcessing: Please be conservative in the
- * individual handlers and don't assume the event is fully handled
- * unless you *really* need to ensure that other handlers don't see the
- * event anymore. Some OS manager or library might be interested in
- * events even after they are already handled on the Tk level.
- *
- * Results:
- * 0 on success
- * -1 on failure
- *
- * Side effects:
- * Converts a Carbon event to a Tk event
- *
- *----------------------------------------------------------------------
- */
+ switch ((NSInteger)type) {
+ case NSAppKitDefined:
+ subtype = [theEvent subtype];
-MODULE_SCOPE int
-TkMacOSXProcessEvent(
- TkMacOSXEvent *eventPtr,
- MacEventStatus *statusPtr)
-{
- switch (eventPtr->eClass) {
- case kEventClassMouse:
- TkMacOSXProcessMouseEvent(eventPtr, statusPtr);
- break;
- case kEventClassWindow:
- TkMacOSXProcessWindowEvent(eventPtr, statusPtr);
- break;
- case kEventClassKeyboard:
- TkMacOSXProcessKeyboardEvent(eventPtr, statusPtr);
- break;
- case kEventClassApplication:
- TkMacOSXProcessApplicationEvent(eventPtr, statusPtr);
+ switch (subtype) {
+ case NSApplicationActivatedEventType:
break;
- case kEventClassAppearance:
- TkMacOSXProcessAppearanceEvent(eventPtr, statusPtr);
+ case NSApplicationDeactivatedEventType:
break;
- case kEventClassMenu:
- TkMacOSXProcessMenuEvent(eventPtr, statusPtr);
+ case NSWindowExposedEventType:
+ case NSScreenChangedEventType:
break;
- case kEventClassCommand:
- TkMacOSXProcessCommandEvent(eventPtr, statusPtr);
- break;
- default: {
- TkMacOSXDbgMsg("Unrecognised event: %s",
- TkMacOSXCarbonEventToAscii(eventPtr->eventRef));
+ case NSWindowMovedEventType:
break;
+ case NSWindowWillMoveEventType:
+ break;
+
+ default:
+ break;
+ }
+ break;
+ case NSKeyUp:
+ case NSKeyDown:
+ case NSFlagsChanged:
+ flags = [theEvent modifierFlags];
+ processedEvent = [self tkProcessKeyEvent:theEvent];
+ break;
+ case NSLeftMouseDown:
+ case NSLeftMouseUp:
+ case NSRightMouseDown:
+ case NSRightMouseUp:
+ case NSLeftMouseDragged:
+ case NSRightMouseDragged:
+ case NSMouseMoved:
+ case NSMouseEntered:
+ case NSMouseExited:
+ case NSScrollWheel:
+ case NSOtherMouseDown:
+ case NSOtherMouseUp:
+ case NSOtherMouseDragged:
+ case NSTabletPoint:
+ case NSTabletProximity:
+ processedEvent = [self tkProcessMouseEvent:theEvent];
+ break;
+#if 0
+ case NSSystemDefined:
+ subtype = [theEvent subtype];
+ break;
+ case NSApplicationDefined: {
+ id win;
+ win = [theEvent window];
+ break;
}
+ case NSCursorUpdate:
+ break;
+#if MAC_OS_X_VERSION_MAX_ALLOWED >= 1060
+ case NSEventTypeGesture:
+ case NSEventTypeMagnify:
+ case NSEventTypeRotate:
+ case NSEventTypeSwipe:
+ case NSEventTypeBeginGesture:
+ case NSEventTypeEndGesture:
+ break;
+#endif
+#endif
+
+ default:
+ break;
}
- return 0;
+ return processedEvent;
}
+@end
+
+#pragma mark -
/*
*----------------------------------------------------------------------
*
- * TkMacOSXProcessMenuEvent --
+ * TkMacOSXFlushWindows --
*
- * This routine processes the event in eventPtr, and
- * generates the appropriate Tk events from it.
+ * This routine flushes all the windows of the application. It is
+ * called by XSync().
*
* Results:
- * True if event(s) are generated - false otherwise.
+ * None.
*
* Side effects:
- * Additional events may be place on the Tk event queue.
+ * Flushes all Carbon windows
*
*----------------------------------------------------------------------
*/
-MODULE_SCOPE int
-TkMacOSXProcessMenuEvent(
- TkMacOSXEvent *eventPtr,
- MacEventStatus *statusPtr)
+MODULE_SCOPE void
+TkMacOSXFlushWindows(void)
{
- int menuContext;
- OSStatus err;
+ NSInteger windowCount;
+ NSInteger *windowNumbers;
- switch (eventPtr->eKind) {
- case kEventMenuBeginTracking:
- case kEventMenuEndTracking:
- case kEventMenuOpening:
- case kEventMenuTargetItem:
- break;
- default:
- return 0;
- break;
- }
- err = ChkErr(GetEventParameter, eventPtr->eventRef, kEventParamMenuContext,
- typeUInt32, NULL, sizeof(menuContext), NULL, &menuContext);
- if (err == noErr && ((menuContext & kMenuContextMenuBarTracking) ||
- (menuContext & kMenuContextPopUpTracking))) {
- switch (eventPtr->eKind) {
- MenuRef menu;
-
- case kEventMenuBeginTracking:
- TkMacOSXClearMenubarActive();
-
- /*
- * Handle -postcommand
- */
-
- TkMacOSXPreprocessMenu();
- TkMacOSXTrackingLoop(1);
- break;
- case kEventMenuEndTracking:
- TkMacOSXTrackingLoop(0);
- break;
- case kEventMenuOpening:
- err = ChkErr(GetEventParameter, eventPtr->eventRef,
- kEventParamDirectObject, typeMenuRef, NULL,
- sizeof(menu), NULL, &menu);
- if (err == noErr) {
- TkMacOSXClearActiveMenu(menu);
- return TkMacOSXGenerateParentMenuSelectEvent(menu);
- }
- break;
- case kEventMenuTargetItem:
- err = ChkErr(GetEventParameter, eventPtr->eventRef,
- kEventParamDirectObject, typeMenuRef, NULL,
- sizeof(menu), NULL, &menu);
- if (err == noErr) {
- MenuItemIndex index;
-
- err = ChkErr(GetEventParameter, eventPtr->eventRef,
- kEventParamMenuItemIndex, typeMenuItemIndex, NULL,
- sizeof(index), NULL, &index);
- if (err == noErr) {
- return TkMacOSXGenerateMenuSelectEvent(menu, index);
- }
- }
- break;
+ NSCountWindows(&windowCount);
+ if(windowCount) {
+ windowNumbers = (NSInteger *) ckalloc(windowCount * sizeof(NSInteger));
+ NSWindowList(windowCount, windowNumbers);
+ for (NSInteger index = 0; index < windowCount; index++) {
+ NSWindow *w = [NSApp windowWithWindowNumber:windowNumbers[index]];
+ if (TkMacOSXGetXWindow(w)) {
+ [w flushWindow];
+ }
}
+ ckfree((char*) windowNumbers);
}
- return 0;
}
/*
- *----------------------------------------------------------------------
- *
- * TkMacOSXProcessCommandEvent --
- *
- * This routine processes the event in eventPtr, and
- * generates the appropriate Tk events from it.
- *
- * Results:
- * True if event(s) are generated - false otherwise.
- *
- * Side effects:
- * Additional events may be place on the Tk event queue.
- *
- *----------------------------------------------------------------------
+ * Local Variables:
+ * mode: c
+ * c-basic-offset: 4
+ * fill-column: 79
+ * coding: utf-8
+ * End:
*/
-
-MODULE_SCOPE int
-TkMacOSXProcessCommandEvent(
- TkMacOSXEvent *eventPtr,
- MacEventStatus * statusPtr)
-{
- HICommand command;
- int menuContext;
- OSStatus err;
-
- switch (eventPtr->eKind) {
- case kEventCommandProcess:
- case kEventCommandUpdateStatus:
- break;
- default:
- return 0;
- break;
- }
- err = ChkErr(GetEventParameter, eventPtr->eventRef,
- kEventParamDirectObject, typeHICommand, NULL, sizeof(command),
- NULL, &command);
- if (err == noErr && (command.attributes & kHICommandFromMenu)) {
- if (eventPtr->eKind == kEventCommandProcess) {
- err = ChkErr(GetEventParameter, eventPtr->eventRef,
- kEventParamMenuContext, typeUInt32, NULL,
- sizeof(menuContext), NULL, &menuContext);
- if (err == noErr && (menuContext & kMenuContextMenuBar) &&
- (menuContext & kMenuContextMenuBarTracking)) {
- TkMacOSXHandleMenuSelect(GetMenuID(command.menu.menuRef),
- command.menu.menuItemIndex,
- (GetCurrentEventKeyModifiers() & optionKey) != 0);
- return 1;
- }
- } else {
- Tcl_CmdInfo dummy;
- if (command.commandID == kHICommandPreferences && eventPtr->interp) {
- if (Tcl_GetCommandInfo(eventPtr->interp,
- "::tk::mac::ShowPreferences", &dummy)) {
- if (!IsMenuItemEnabled(command.menu.menuRef,
- command.menu.menuItemIndex)) {
- EnableMenuItem(command.menu.menuRef,
- command.menu.menuItemIndex);
- }
- } else {
- if (IsMenuItemEnabled(command.menu.menuRef,
- command.menu.menuItemIndex)) {
- DisableMenuItem(command.menu.menuRef,
- command.menu.menuItemIndex);
- }
- }
- statusPtr->stopProcessing = 1;
- return 1;
- }
- }
- }
- return 0;
-}
diff --git a/macosx/tkMacOSXEvent.h b/macosx/tkMacOSXEvent.h
index 19b44f1..440733f 100644
--- a/macosx/tkMacOSXEvent.h
+++ b/macosx/tkMacOSXEvent.h
@@ -4,55 +4,13 @@
* Declarations of Macintosh specific functions for implementing the
* Mac OS X Notifier.
*
- * Copyright 2001, Apple Computer, Inc.
- * Copyright (c) 2005-2007 Daniel A. Steffen <das@users.sourceforge.net>
+ * Copyright 2001-2009, Apple Inc.
+ * Copyright (c) 2005-2009 Daniel A. Steffen <das@users.sourceforge.net>
*
- * See the file "license.terms" for information on usage and redistribution of
- * this file, and for a DISCLAIMER OF ALL WARRANTIES.
+ * See the file "license.terms" for information on usage and redistribution
+ * of this file, and for a DISCLAIMER OF ALL WARRANTIES.
*
- * The following terms apply to all files originating from Apple
- * Computer, Inc. ("Apple") and associated with the software
- * unless explicitly disclaimed in individual files.
- *
- *
- * Apple hereby grants permission to use, copy, modify,
- * distribute, and license this software and its documentation
- * for any purpose, provided that existing copyright notices are
- * retained in all copies and that this notice is included
- * verbatim in any distributions. No written agreement, license,
- * or royalty fee is required for any of the authorized
- * uses. Modifications to this software may be copyrighted by
- * their authors and need not follow the licensing terms
- * described here, provided that the new terms are clearly
- * indicated on the first page of each file where they apply.
- *
- *
- * IN NO EVENT SHALL APPLE, THE AUTHORS OR DISTRIBUTORS OF THE
- * SOFTWARE BE LIABLE TO ANY PARTY FOR DIRECT, INDIRECT, SPECIAL,
- * INCIDENTAL, OR CONSEQUENTIAL DAMAGES ARISING OUT OF THE USE OF
- * THIS SOFTWARE, ITS DOCUMENTATION, OR ANY DERIVATIVES THEREOF,
- * EVEN IF APPLE OR THE AUTHORS HAVE BEEN ADVISED OF THE
- * POSSIBILITY OF SUCH DAMAGE. APPLE, THE AUTHORS AND
- * DISTRIBUTORS SPECIFICALLY DISCLAIM ANY WARRANTIES, INCLUDING,
- * BUT NOT LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY,
- * FITNESS FOR A PARTICULAR PURPOSE, AND NON-INFRINGEMENT. THIS
- * SOFTWARE IS PROVIDED ON AN "AS IS" BASIS, AND APPLE,THE
- * AUTHORS AND DISTRIBUTORS HAVE NO OBLIGATION TO PROVIDE
- * MAINTENANCE, SUPPORT, UPDATES, ENHANCEMENTS, OR MODIFICATIONS.
- *
- * GOVERNMENT USE: If you are acquiring this software on behalf
- * of the U.S. government, the Government shall have only
- * "Restricted Rights" in the software and related documentation
- * as defined in the Federal Acquisition Regulations (FARs) in
- * Clause 52.227.19 (c) (2). If you are acquiring the software
- * on behalf of the Department of Defense, the software shall be
- * classified as "Commercial Computer Software" and the
- * Government shall have only "Restricted Rights" as defined in
- * Clause 252.227-7013 (c) (1) of DFARs. Notwithstanding the
- * foregoing, the authors grant the U.S. Government and others
- * acting in its behalf permission to use and distribute the
- * software in accordance with the terms specified in this
- * license.
+ * RCS: @(#) $Id$
*/
#ifndef _TKMACEVENT
@@ -62,44 +20,6 @@
#include "tkMacOSXInt.h"
#endif
-typedef struct {
- int stopProcessing;
- int err;
- char errMsg[1024];
-} MacEventStatus;
-
-/*
- * The event information in passed in the following structures
- */
-typedef struct {
- EventRef eventRef;
- UInt32 eClass; /* Defines the class of event : see CarbonEvents.h */
- UInt32 eKind; /* Defines the kind of the event : see CarbonEvents.h */
- Tcl_Interp *interp; /* Interp to handle events in */
- EventHandlerCallRef callRef;
-} TkMacOSXEvent;
-
MODULE_SCOPE void TkMacOSXFlushWindows(void);
-MODULE_SCOPE int TkMacOSXProcessEvent(TkMacOSXEvent *eventPtr,
- MacEventStatus *statusPtr);
-MODULE_SCOPE int TkMacOSXProcessMouseEvent(TkMacOSXEvent *e,
- MacEventStatus *statusPtr);
-MODULE_SCOPE int TkMacOSXProcessWindowEvent(TkMacOSXEvent *e,
- MacEventStatus *statusPtr);
-MODULE_SCOPE int TkMacOSXProcessKeyboardEvent(TkMacOSXEvent *e,
- MacEventStatus *statusPtr);
-MODULE_SCOPE int TkMacOSXProcessApplicationEvent(TkMacOSXEvent *e,
- MacEventStatus *statusPtr);
-MODULE_SCOPE int TkMacOSXProcessAppearanceEvent(TkMacOSXEvent *e,
- MacEventStatus *statusPtr);
-MODULE_SCOPE int TkMacOSXProcessMenuEvent(TkMacOSXEvent *e,
- MacEventStatus *statusPtr);
-MODULE_SCOPE int TkMacOSXProcessCommandEvent(TkMacOSXEvent *e,
- MacEventStatus *statusPtr);
-MODULE_SCOPE int TkMacOSXKeycodeToUnicode(
- UniChar * uniChars, int maxChars,
- EventKind eKind,
- UInt32 keycode, UInt32 modifiers,
- UInt32 * deadKeyStatePtr);
#endif
diff --git a/macosx/tkMacOSXFont.c b/macosx/tkMacOSXFont.c
index 1cf8951..67ed044 100644
--- a/macosx/tkMacOSXFont.c
+++ b/macosx/tkMacOSXFont.c
@@ -2,38 +2,16 @@
* tkMacOSXFont.c --
*
* Contains the Macintosh implementation of the platform-independant
- * font package interface. This version uses ATSU instead of Quickdraw.
+ * font package interface.
*
* Copyright 2002-2004 Benjamin Riefenstahl, Benjamin.Riefenstahl@epost.de
- * Copyright (c) 2006-2008 Daniel A. Steffen <das@users.sourceforge.net>
- *
- * Some functions were originally copied verbatim from the QuickDraw version
- * of tkMacOSXFont.c, which had these copyright notices:
- *
- * Copyright (c) 1990-1994 The Regents of the University of California.
- * Copyright (c) 1994-1997 Sun Microsystems, Inc.
- * Copyright 2001, Apple Computer, Inc.
+ * Copyright (c) 2006-2009 Daniel A. Steffen <das@users.sourceforge.net>
+ * Copyright 2008-2009, Apple Inc.
*
* See the file "license.terms" for information on usage and redistribution
* of this file, and for a DISCLAIMER OF ALL WARRANTIES.
*
- * Todos:
- *
- * - Get away from Font Manager and Quickdraw functions as much as possible,
- * replace with ATS functions instead.
- *
- * - Use Font Manager functions to translate ids from ATS to Font Manager
- * instead of just assuming that they are the same.
- *
- * - Get a second font register going for fonts that are not assigned to a
- * font family by the OS. On my system I have 27 fonts of that type,
- * Hebrew, Arabic and Hindi fonts that actually come with the system.
- * FMGetFontFamilyInstanceFromFont() returns -981 (kFMInvalidFontFamilyErr)
- * for these and they are not listed when enumerating families, but they
- * are when enumerating fonts directly. The problem that the OS sees may
- * be that at least some of them do not contain any Latin characters. Note
- * that such fonts can not be used for controls, because controls
- * definitely require a family id (this assertion needs testing).
+ * RCS: @(#) $Id$
*/
#include "tkMacOSXPrivate.h"
@@ -46,19 +24,6 @@
*/
/*
- * Problem: The sum of two parts is not the same as the whole. In particular
- * the width of two separately measured strings will usually be larger than
- * the width of them pasted together. Tk has a design bug here, because it
- * generally assumes that this kind of arithmetic works.
- * To workaround this, #define TK_MAC_COALESCE_LINE to 1 below, we then avoid
- * lines that tremble and shiver while the cursor passes through them by
- * undercutting the system and behind the scenes pasting strings together that
- * look like they are on the same line and adjacent and that are drawn with
- * the same font. To do this we need some global data.
- */
-#define TK_MAC_COALESCE_LINE 0
-
-/*
* The following structure represents our Macintosh-specific implementation
* of a font object.
*/
@@ -67,87 +32,11 @@ typedef struct {
TkFont font; /* Stuff used by generic font package. Must
* be first in structure. */
- /*
- * The ATSU view of the font and other text properties. Used for drawing
- * and measuring.
- */
-
- ATSUFontID atsuFontId; /* == FMFont. */
- ATSUTextLayout atsuLayout; /* ATSU layout object, representing the whole
- * text that ATSU sees with some option
- * bits. */
- ATSUStyle atsuStyle; /* ATSU style object, representing a run of
- * text with the same properties. */
-
- /*
- * The QuickDraw view of the font. Used to configure controls.
- */
-
- FMFontFamily qdFont; /* == FMFontFamilyId, Carbon replacement for
- * QD face numbers. */
- short qdSize; /* Font size in points. */
- short qdStyle; /* QuickDraw style bits. */
+ NSFont *nsFont;
+ NSDictionary *nsAttributes;
} MacFont;
/*
- * Information about font families, initialized at startup time. Font
- * families are described by a mapping from UTF-8 names to MacOS font family
- * IDs. The whole list is kept as the sorted array "familyList", allocated
- * with ckrealloc().
- *
- * Note: This would have been easier, if we could just have used Tcl hash
- * arrays. Unfortunately there seems to be no pre-packaged
- * non-case-sensitive version of that available.
- */
-
-typedef struct {
- const char * name;
- FMFontFamily familyId;
-} MacFontFamily;
-
-static MacFontFamily * familyList = NULL;
-static int
- familyListNextFree = 0, /* The next free slot in familyList. */
- familyListMaxValid = 0, /* The top of the sorted area. */
- familyListSize = 0; /* The size of the whole array. */
-
-/*
- * A simple one-shot sub-allocator for fast and efficient allocation of
- * strings. Used by the familyList array for the names. These strings are
- * only allocated once at startup and never freed. If you ever need to
- * re-initialize this, you can just ckfree() all the StringBlocks in the list
- * and start over.
- */
-
-#define STRING_BLOCK_MAX (1024-8) /* Make sizeof(StringBlock) ==
- * 1024. */
-typedef struct StringBlock {
- struct StringBlock *next; /* Starting from "stringMemory" these
- * blocks form a linked list. */
- int nextFree; /* Top of the used area in the
- * "strings" member. */
- char strings[STRING_BLOCK_MAX]; /* The actual memory managed here. */
-} StringBlock;
-
-static StringBlock *stringMemory = NULL;
-
-#if TK_MAC_COALESCE_LINE
-static Tcl_DString currentLine; /* The current line as seen so far. This
- * contains a Tcl_UniChar DString. */
-static int
- currentY = -1, /* The Y position (row in pixels) of the
- * current line. */
- currentLeft = -1, /* The left edge (pixels) of the current
- * line. */
- currentRight = -1; /* The right edge (pixels) of the current
- * line. */
-static const MacFont *currentFontPtr = NULL;
- /* The font of the current line. */
-#endif /* TK_MAC_COALESCE_LINE */
-
-static int antialiasedTextEnabled;
-
-/*
* The names for our "native" fonts.
*/
@@ -187,172 +76,227 @@ static const struct SystemFontMapEntry systemFontMap[] = {
};
#undef ThemeFont
-/*
- * Procedures used only in this file.
- */
-
-static void LayoutSetString(const MacFont *fontPtr,
- const TkMacOSXDrawingContext *drawingContextPtr,
- const UniChar * uchars, int ulen);
-
-/*
- * The actual workers.
- */
-
-static int MeasureStringWidth(const MacFont *fontPtr, int start, int end);
-
-#if TK_MAC_COALESCE_LINE
-static const Tcl_UniChar *UpdateLineBuffer(const MacFont *fontPtr,
- const TkMacOSXDrawingContext *drawingContextPtr, const char *source,
- int numBytes, int x, int y, int * offset);
-#endif /* TK_MAC_COALESCE_LINE */
-
-/*
- * Initialization and setup of a font data structure.
- */
-
-static const char *FamilyNameForFamilyID(FMFontFamily familyId);
-static void InitFont(FMFontFamily familyId, const char *familyName,
- int size, int qdStyle, MacFont *fontPtr);
-static void InitATSUObjects(FMFontFamily familyId, short qdsize, short qdStyle,
- ATSUFontID *fontIdPtr, ATSUTextLayout *layoutPtr, ATSUStyle *stylePtr);
-static void InitATSUStyle(ATSUFontID fontId, short ptSize, short qdStyle,
- ATSUStyle style);
-static void SetFontFeatures(ATSUFontID fontId, int fixed, short size,
- ATSUStyle style);
-static void AdjustFontHeight(MacFont *fontPtr);
-static void InitATSULayout(const TkMacOSXDrawingContext *drawingContextPtr,
- ATSUTextLayout layout, int fixed);
-static void ReleaseFont(MacFont *fontPtr);
-
-/*
- * Finding fonts by name.
- */
-
-static const MacFontFamily *FindFontFamilyOrAlias(const char *name);
-static const MacFontFamily *FindFontFamilyOrAliasOrFallback(const char *name);
-
-/*
- * Doing interesting things with font families and fonts.
- */
-
-static void InitFontFamilies(void);
-static OSStatus GetFontFamilyName(FMFontFamily fontFamily, char *name,
- int numBytes);
-
-/*
- * Accessor functions and internal utilities for the font family list.
- */
-
-static const MacFontFamily *AddFontFamily(const char *name,
- FMFontFamily familyId);
-static const MacFontFamily *FindFontFamily(const char *name);
-static Tcl_Obj *EnumFontFamilies(void);
+static int antialiasedTextEnabled = -1;
+static NSCharacterSet *whitespaceCharacterSet = nil;
+static NSCharacterSet *lineendingCharacterSet = nil;
-static OSStatus FontFamilyEnumCallback(ATSFontFamilyRef family, void *refCon);
-static void SortFontFamilies(void);
-static int CompareFontFamilies(const void *vp1, const void *vp2);
-static const char *AddString(const char *in);
-
-static OSStatus GetThemeFontAndFamily(const ThemeFontID themeFontId,
- FMFontFamily *fontFamily, unsigned char *fontName, SInt16 *fontSize,
- Style *fontStyle);
-static void InitSystemFonts(TkMainInfo *mainPtr);
+static void GetTkFontAttributesForNSFont(NSFont *nsFont,
+ TkFontAttributes *faPtr);
+static NSFont *FindNSFont(const char *familyName, NSFontTraitMask traits,
+ NSInteger weight, CGFloat size, int fallbackToDefault);
+static void InitFont(NSFont *nsFont, const TkFontAttributes *reqFaPtr,
+ MacFont * fontPtr);
static int CreateNamedSystemFont(Tcl_Interp *interp, Tk_Window tkwin,
const char* name, TkFontAttributes *faPtr);
-
+static void DrawCharsInContext(Display *display, Drawable drawable, GC gc,
+ Tk_Font tkfont, const char *source, int numBytes, int rangeStart,
+ int rangeLength, int x, int y, double angle);
+
+@interface NSFont(TKFont)
+- (NSFont *)bestMatchingFontForCharacters:(const UTF16Char *)characters
+ length:(NSUInteger)length attributes:(NSDictionary *)attributes
+ actualCoveredLength:(NSUInteger *)coveredLength;
+@end
+
+#pragma mark -
+#pragma mark Font Helpers:
+
+#define GetNSFontTraitsFromTkFontAttributes(faPtr) \
+ ((faPtr)->weight == TK_FW_BOLD ? NSBoldFontMask : NSUnboldFontMask) | \
+ ((faPtr)->slant == TK_FS_ITALIC ? NSItalicFontMask : NSUnitalicFontMask)
/*
- *-------------------------------------------------------------------------
+ *---------------------------------------------------------------------------
*
- * TkpFontPkgInit --
+ * GetTkFontAttributesForNSFont --
*
- * This procedure is called when an application is created. It
- * initializes all the structures that are used by the
- * platform-dependant code on a per application basis.
+ * Fill in TkFontAttributes for given NSFont.
*
* Results:
* None.
*
* Side effects:
- * Initialization of variables local to this file.
+ * None.
*
- *-------------------------------------------------------------------------
+ *---------------------------------------------------------------------------
*/
-void
-TkpFontPkgInit(
- TkMainInfo *mainPtr) /* The application being created. */
+static void
+GetTkFontAttributesForNSFont(
+ NSFont *nsFont,
+ TkFontAttributes *faPtr)
{
- InitFontFamilies();
- InitSystemFonts(mainPtr);
+ NSFontTraitMask traits = [[NSFontManager sharedFontManager]
+ traitsOfFont:nsFont];
-#if TK_MAC_COALESCE_LINE
- Tcl_DStringInit(&currentLine);
-#endif
+ faPtr->family = Tk_GetUid([[nsFont familyName] UTF8String]);
+ faPtr->size = [nsFont pointSize];
+ faPtr->weight = (traits & NSBoldFontMask ? TK_FW_BOLD : TK_FW_NORMAL);
+ faPtr->slant = (traits & NSItalicFontMask ? TK_FS_ITALIC : TK_FS_ROMAN);
}
/*
- *-------------------------------------------------------------------------
+ *---------------------------------------------------------------------------
*
- * InitSystemFonts --
+ * FindNSFont --
*
- * Initialize named system fonts.
+ * Find NSFont for given attributes. Use default values for missing
+ * attributes, and do a case-insensitive search for font family names
+ * if necessary. If fallbackToDefault flag is set, use the system font
+ * as a last resort.
*
* Results:
- *
* None.
*
* Side effects:
- *
* None.
*
- *-------------------------------------------------------------------------
+ *---------------------------------------------------------------------------
*/
-static void
-InitSystemFonts(
- TkMainInfo *mainPtr)
+static NSFont *
+FindNSFont(
+ const char *familyName,
+ NSFontTraitMask traits,
+ NSInteger weight,
+ CGFloat size,
+ int fallbackToDefault)
{
- Tcl_Interp *interp = mainPtr->interp;
- Tk_Window tkwin = (Tk_Window) mainPtr->winPtr;
- const struct SystemFontMapEntry *systemFont = systemFontMap;
- TkFontAttributes fa;
+ NSFontManager *fm = [NSFontManager sharedFontManager];
+ NSFont *nsFont, *dflt = nil;
+ #define defaultFont (dflt ? dflt : (dflt = [NSFont systemFontOfSize:0]))
+ NSString *family;
- /* force this for now */
- if (!mainPtr->winPtr->mainPtr) {
- mainPtr->winPtr->mainPtr = mainPtr;
+ if (familyName) {
+ family = [[[NSString alloc] initWithUTF8String:familyName] autorelease];
+ } else {
+ family = [defaultFont familyName];
}
- TkInitFontAttributes(&fa);
- while (systemFont->systemName) {
- Str255 fontName;
- SInt16 fontSize;
- Style fontStyle;
-
- if (GetThemeFont(systemFont->id, smSystemScript, fontName,
- &fontSize, &fontStyle) == noErr) {
- CopyPascalStringToC(fontName, (char*)fontName);
- fa.family = Tk_GetUid((char*)fontName);
- fa.size = fontSize;
- fa.weight = (fontStyle & bold) ? TK_FW_BOLD : TK_FW_NORMAL;
- fa.slant = (fontStyle & italic) ? TK_FS_ITALIC : TK_FS_ROMAN;
- fa.underline = ((fontStyle & underline) != 0);
- CreateNamedSystemFont(interp, tkwin, systemFont->systemName, &fa);
- if (systemFont->tkName) {
- CreateNamedSystemFont(interp, tkwin, systemFont->tkName, &fa);
- }
- if (systemFont->tkName1) {
- CreateNamedSystemFont(interp, tkwin, systemFont->tkName1, &fa);
+ if (size == 0.0) {
+ size = [defaultFont pointSize];
+ }
+ nsFont = [fm fontWithFamily:family traits:traits weight:weight size:size];
+ if (!nsFont) {
+ NSArray *availableFamilies = [fm availableFontFamilies];
+ NSString *caseFamily = nil;
+
+ for (NSString *f in availableFamilies) {
+ if ([family caseInsensitiveCompare:f] == NSOrderedSame) {
+ caseFamily = f;
+ break;
}
}
- systemFont++;
+ if (caseFamily) {
+ nsFont = [fm fontWithFamily:caseFamily traits:traits weight:weight
+ size:size];
+ }
}
- fa.family = Tk_GetUid("monaco");
- fa.size = 11;
- fa.weight = TK_FW_NORMAL;
- fa.slant = TK_FS_ROMAN;
- fa.underline = 0;
- CreateNamedSystemFont(interp, tkwin, "TkFixedFont", &fa);
+ if (!nsFont) {
+ nsFont = [NSFont fontWithName:family size:size];
+ }
+ if (!nsFont && fallbackToDefault) {
+ nsFont = [fm convertFont:defaultFont toFamily:family];
+ nsFont = [fm convertFont:nsFont toSize:size];
+ nsFont = [fm convertFont:nsFont toHaveTrait:traits];
+ }
+ #undef defaultFont
+ return nsFont;
+}
+
+/*
+ *---------------------------------------------------------------------------
+ *
+ * InitFont --
+ *
+ * Helper for TkpGetNativeFont() and TkpGetFontFromAttributes().
+ *
+ * Results:
+ * Fills the MacFont structure.
+ *
+ * Side effects:
+ * Memory allocated.
+ *
+ *---------------------------------------------------------------------------
+ */
+
+static void
+InitFont(
+ NSFont *nsFont,
+ const TkFontAttributes *reqFaPtr, /* Can be NULL */
+ MacFont *fontPtr)
+{
+ TkFontAttributes *faPtr;
+ TkFontMetrics *fmPtr;
+ NSDictionary *nsAttributes;
+ NSRect bounds;
+ CGFloat kern = 0.0;
+ NSFontRenderingMode renderingMode = NSFontDefaultRenderingMode;
+ int ascent, descent/*, dontAA*/;
+ static const UniChar ch[] = {'.', 'W', ' ', 0xc4, 0xc1, 0xc2, 0xc3, 0xc7};
+ /* ., W, Space, Auml, Aacute, Acirc, Atilde, Ccedilla */
+ #define nCh (sizeof(ch) / sizeof(UniChar))
+ CGGlyph glyphs[nCh];
+ CGRect boundingRects[nCh];
+
+ fontPtr->font.fid = (Font) fontPtr;
+ faPtr = &fontPtr->font.fa;
+ if (reqFaPtr) {
+ *faPtr = *reqFaPtr;
+ } else {
+ TkInitFontAttributes(faPtr);
+ }
+ fontPtr->nsFont = nsFont;
+ // some don't like antialiasing on fixed-width even if bigger than limit
+// dontAA = [nsFont isFixedPitch] && fontPtr->font.fa.size <= 10;
+ if (antialiasedTextEnabled >= 0/* || dontAA*/) {
+ renderingMode = (antialiasedTextEnabled == 0/* || dontAA*/) ?
+ NSFontIntegerAdvancementsRenderingMode :
+ NSFontAntialiasedRenderingMode;
+ }
+ nsFont = [nsFont screenFontWithRenderingMode:renderingMode];
+ GetTkFontAttributesForNSFont(nsFont, faPtr);
+ fmPtr = &fontPtr->font.fm;
+ fmPtr->ascent = floor([nsFont ascender] + [nsFont leading] + 0.5);
+ fmPtr->descent = floor(-[nsFont descender] + 0.5);
+ fmPtr->maxWidth = [nsFont maximumAdvancement].width;
+ fmPtr->fixed = [nsFont isFixedPitch]; /* Does not work for all fonts */
+
+ /*
+ * The ascent, descent and fixed fields are not correct for all fonts, as
+ * a workaround deduce that info from the metrics of some typical glyphs,
+ * along with screenfont kerning (space advance difference to printer font)
+ */
+
+ bounds = [nsFont boundingRectForFont];
+ if (CTFontGetGlyphsForCharacters((CTFontRef) nsFont, ch, glyphs, nCh)) {
+ fmPtr->fixed = [nsFont advancementForGlyph:glyphs[0]].width ==
+ [nsFont advancementForGlyph:glyphs[1]].width;
+ bounds = NSRectFromCGRect(CTFontGetBoundingRectsForGlyphs((CTFontRef)
+ nsFont, kCTFontDefaultOrientation, ch, boundingRects, nCh));
+ kern = [nsFont advancementForGlyph:glyphs[2]].width -
+ [fontPtr->nsFont advancementForGlyph:glyphs[2]].width;
+ }
+ descent = floor(-bounds.origin.y + 0.5);
+ ascent = floor(bounds.size.height + bounds.origin.y + 0.5);
+ if (ascent > fmPtr->ascent) {
+ fmPtr->ascent = ascent;
+ }
+ if (descent > fmPtr->descent) {
+ fmPtr->descent = descent;
+ }
+ nsAttributes = [NSDictionary dictionaryWithObjectsAndKeys:
+ nsFont, NSFontAttributeName,
+ [NSNumber numberWithInt:faPtr->underline ?
+ NSUnderlineStyleSingle|NSUnderlinePatternSolid :
+ NSUnderlineStyleNone], NSUnderlineStyleAttributeName,
+ [NSNumber numberWithInt:faPtr->overstrike ?
+ NSUnderlineStyleSingle|NSUnderlinePatternSolid :
+ NSUnderlineStyleNone], NSStrikethroughStyleAttributeName,
+ [NSNumber numberWithInt:fmPtr->fixed ? 0 : 1],
+ NSLigatureAttributeName,
+ [NSNumber numberWithDouble:kern], NSKernAttributeName, nil];
+ fontPtr->nsAttributes = TkMacOSXMakeUncollectableAndRetain(nsAttributes);
+ #undef nCh
}
/*
@@ -383,37 +327,84 @@ CreateNamedSystemFont(
TkDeleteNamedFont(NULL, tkwin, name);
return TkCreateNamedFont(interp, tkwin, name, faPtr);
}
+
+#pragma mark -
+#pragma mark Font handling:
/*
- *---------------------------------------------------------------------------
+ *-------------------------------------------------------------------------
+ *
+ * TkpFontPkgInit --
*
- * GetThemeFontAndFamily --
+ * This procedure is called when an application is created. It
+ * initializes all the structures that are used by the
+ * platform-dependant code on a per application basis.
+ * Note that this is called before TkpInit() !
*
- * Wrapper around the GetThemeFont and FMGetFontFamilyFromName APIs.
+ * Results:
+ * None.
*
- *---------------------------------------------------------------------------
+ * Side effects:
+ * Initialize named system fonts.
+ *
+ *-------------------------------------------------------------------------
*/
-OSStatus
-GetThemeFontAndFamily(
- const ThemeFontID themeFontId,
- FMFontFamily* fontFamily,
- unsigned char *fontName,
- SInt16 *fontSize,
- Style *fontStyle)
+void
+TkpFontPkgInit(
+ TkMainInfo *mainPtr) /* The application being created. */
{
- OSStatus err = ChkErr(GetThemeFont, themeFontId, smSystemScript, fontName,
- fontSize, fontStyle);
+ Tcl_Interp *interp = mainPtr->interp;
+ Tk_Window tkwin = (Tk_Window) mainPtr->winPtr;
+ const struct SystemFontMapEntry *systemFont = systemFontMap;
+ NSFont *nsFont;
+ TkFontAttributes fa;
+ NSMutableCharacterSet *cs;
+ NSAutoreleasePool *pool = [NSAutoreleasePool new];
- if (err == noErr) {
- *fontFamily = FMGetFontFamilyFromName(fontName);
- if (*fontFamily == kInvalidFontFamily) {
- err = kFMInvalidFontFamilyErr;
- TkMacOSXDbgMsg("FMGetFontFamilyFromName failed.");
+ /* force this for now */
+ if (!mainPtr->winPtr->mainPtr) {
+ mainPtr->winPtr->mainPtr = mainPtr;
+ }
+ while (systemFont->systemName) {
+ nsFont = (NSFont*) CTFontCreateUIFontForLanguage(
+ HIThemeGetUIFontType(systemFont->id), 0, NULL);
+ if (nsFont) {
+ TkInitFontAttributes(&fa);
+ GetTkFontAttributesForNSFont(nsFont, &fa);
+ CreateNamedSystemFont(interp, tkwin, systemFont->systemName, &fa);
+ if (systemFont->tkName) {
+ CreateNamedSystemFont(interp, tkwin, systemFont->tkName, &fa);
+ }
+ if (systemFont->tkName1) {
+ CreateNamedSystemFont(interp, tkwin, systemFont->tkName1, &fa);
+ }
+ CFRelease(nsFont);
}
+ systemFont++;
}
-
- return err;
+ TkInitFontAttributes(&fa);
+ nsFont = (NSFont*) CTFontCreateUIFontForLanguage(
+ kCTFontUserFixedPitchFontType, 11, NULL);
+ if (nsFont) {
+ GetTkFontAttributesForNSFont(nsFont, &fa);
+ CFRelease(nsFont);
+ } else {
+ fa.family = Tk_GetUid("Monaco");
+ fa.size = 11;
+ fa.weight = TK_FW_NORMAL;
+ fa.slant = TK_FS_ROMAN;
+ }
+ CreateNamedSystemFont(interp, tkwin, "TkFixedFont", &fa);
+ if (!whitespaceCharacterSet) {
+ whitespaceCharacterSet = [[NSCharacterSet
+ whitespaceAndNewlineCharacterSet] retain];
+ cs = [whitespaceCharacterSet mutableCopy];
+ [cs removeCharactersInString:@" "];
+ lineendingCharacterSet = [cs copy];
+ [cs release];
+ }
+ [pool drain];
}
/*
@@ -447,12 +438,9 @@ TkpGetNativeFont(
Tk_Window tkwin, /* For display where font will be used. */
const char *name) /* Platform-specific font name. */
{
+ MacFont *fontPtr = NULL;
ThemeFontID themeFontId;
- FMFontFamily fontFamily;
- Str255 fontName;
- SInt16 fontSize;
- Style fontStyle;
- MacFont *fontPtr;
+ CTFontRef ctFont;
if (strcmp(name, SYSTEMFONT_NAME) == 0) {
themeFontId = kThemeSystemFont;
@@ -463,14 +451,12 @@ TkpGetNativeFont(
} else {
return NULL;
}
- if (GetThemeFontAndFamily(themeFontId, &fontFamily, fontName, &fontSize,
- &fontStyle) != noErr) {
- return NULL;
+ ctFont = CTFontCreateUIFontForLanguage(HIThemeGetUIFontType(
+ themeFontId), 0, NULL);
+ if (ctFont) {
+ fontPtr = (MacFont *) ckalloc(sizeof(MacFont));
+ InitFont((NSFont*) ctFont, NULL, fontPtr);
}
- CopyPascalStringToC(fontName, (char*)fontName);
-
- fontPtr = (MacFont *) ckalloc(sizeof(MacFont));
- InitFont(fontFamily, (char*)fontName, fontSize, fontStyle, fontPtr);
return (TkFont *) fontPtr;
}
@@ -516,41 +502,34 @@ TkpGetFontFromAttributes(
const TkFontAttributes *faPtr)
/* Set of attributes to match. */
{
- short qdStyle;
- FMFontFamily familyId;
- const char *name;
- const MacFontFamily *familyPtr;
MacFont *fontPtr;
+ int points = TkFontGetPoints(tkwin, faPtr->size);
+ NSFontTraitMask traits = GetNSFontTraitsFromTkFontAttributes(faPtr);
+ NSInteger weight = (faPtr->weight == TK_FW_BOLD ? 9 : 5);
+ NSFont *nsFont;
- familyId = GetAppFont();
- name = NULL;
- qdStyle = 0;
+ nsFont = FindNSFont(faPtr->family, traits, weight, points, 0);
+ if (!nsFont) {
+ char *const *aliases = TkFontGetAliasList(faPtr->family);
- if (faPtr->family != NULL) {
- familyPtr = FindFontFamilyOrAliasOrFallback(faPtr->family);
- if (familyPtr != NULL) {
- name = familyPtr->name;
- familyId = familyPtr->familyId;
+ while (aliases && !nsFont) {
+ nsFont = FindNSFont(*aliases++, traits, weight, points, 0);
}
}
-
- if (faPtr->weight != TK_FW_NORMAL) {
- qdStyle |= bold;
- }
- if (faPtr->slant != TK_FS_ROMAN) {
- qdStyle |= italic;
+ if (!nsFont) {
+ nsFont = FindNSFont(faPtr->family, traits, weight, points, 1);
}
- if (faPtr->underline) {
- qdStyle |= underline;
+ if (!nsFont) {
+ Tcl_Panic("Could not deternmine NSFont from TkFontAttributes");
}
if (tkFontPtr == NULL) {
fontPtr = (MacFont *) ckalloc(sizeof(MacFont));
} else {
fontPtr = (MacFont *) tkFontPtr;
- ReleaseFont(fontPtr);
+ TkpDeleteFont(tkFontPtr);
}
- InitFont(familyId, name, TkFontGetPoints(tkwin, faPtr->size),
- qdStyle, fontPtr);
+ CFRetain(nsFont); /* Always needed to allow unconditional CFRelease below */
+ InitFont(nsFont, faPtr, fontPtr);
return (TkFont *) fontPtr;
}
@@ -578,7 +557,10 @@ void
TkpDeleteFont(
TkFont *tkFontPtr) /* Token of font to be deleted. */
{
- ReleaseFont((MacFont *) tkFontPtr);
+ MacFont *fontPtr = (MacFont *) tkFontPtr;
+
+ TkMacOSXMakeCollectableAndRelease(fontPtr->nsAttributes);
+ CFRelease(fontPtr->nsFont); /* Either a CTFontRef or a CFRetained NSFont */
}
/*
@@ -604,7 +586,14 @@ TkpGetFontFamilies(
Tcl_Interp *interp, /* Interp to hold result. */
Tk_Window tkwin) /* For display to query. */
{
- Tcl_SetObjResult(interp, EnumFontFamilies());
+ Tcl_Obj *resultPtr = Tcl_NewListObj(0, NULL);
+ NSArray *list = [[NSFontManager sharedFontManager] availableFontFamilies];
+
+ for (NSString *family in list) {
+ Tcl_ListObjAppendElement(NULL, resultPtr,
+ Tcl_NewStringObj([family UTF8String], -1));
+ }
+ Tcl_SetObjResult(interp, resultPtr);
}
/*
@@ -630,10 +619,23 @@ TkpGetSubFonts(
Tcl_Interp *interp, /* Interp to hold result. */
Tk_Font tkfont) /* Font object to query. */
{
- /* We don't know much about our fallback fonts, ATSU does all that for
- * us. We could use ATSUMatchFont to implement this function. But as
- * the information is only used for testing, such an effort seems not
- * very useful. */
+ MacFont *fontPtr = (MacFont *) tkfont;
+ Tcl_Obj *resultPtr = Tcl_NewListObj(0, NULL);
+
+ if (fontPtr->nsFont) {
+ NSArray *list = [[fontPtr->nsFont fontDescriptor]
+ objectForKey:NSFontCascadeListAttribute];
+
+ for (NSFontDescriptor *subFontDesc in list) {
+ NSString *family = [subFontDesc objectForKey:NSFontFamilyAttribute];
+
+ if (family) {
+ Tcl_ListObjAppendElement(NULL, resultPtr,
+ Tcl_NewStringObj([family UTF8String], -1));
+ }
+ }
+ }
+ Tcl_SetObjResult(interp, resultPtr);
}
/*
@@ -660,72 +662,23 @@ TkpGetFontAttrsForChar(
Tcl_UniChar c, /* Character of interest */
TkFontAttributes* faPtr) /* Output: Font attributes */
{
- const MacFont * fontPtr = (const MacFont *) tkfont;
- UniChar uchar = c;
- TkMacOSXDrawingContext drawingContext;
- OSStatus err;
- ATSUFontID fontId;
- UniCharArrayOffset changedOffset;
- UniCharCount changedLength;
-
- /*
- * Most of the attributes are just copied from the base font. This
- * assumes that all fonts can have all attributes.
- */
+ MacFont *fontPtr = (MacFont *) tkfont;
+ NSFont *nsFont = fontPtr->nsFont;
*faPtr = fontPtr->font.fa;
+ if (nsFont && ![[nsFont coveredCharacterSet] characterIsMember:c]) {
+ UTF16Char ch = c;
- /*
- * But the name of the actual font may still differ, so we activate the
- * string as an ATSU layout and ask ATSU about the fallback.
- */
- if (!TkMacOSXSetupDrawingContext(Tk_WindowId(tkwin), NULL, 1,
- &drawingContext)) {
- Tcl_Panic("TkpGetFontAttrsForChar: drawingContext not setup");
- }
-
- LayoutSetString(fontPtr, &drawingContext, &uchar, 1);
-
- fontId = fontPtr->atsuFontId;
- err = ATSUMatchFontsToText(
- fontPtr->atsuLayout, 0, 1,
- &fontId, &changedOffset, &changedLength);
- if (err != kATSUFontsMatched && err != noErr) {
- TkMacOSXDbgMsg("Can't match \\u%04X", (unsigned) c);
- }
-
- if (err == kATSUFontsMatched) {
- /*
- * A fallback was used and the actual font is in fontId. Determine
- * the name.
- */
-
- FMFontFamily fontFamilyId;
- FMFontStyle fontStyle;
- int i;
-
- err = ChkErr(FMGetFontFamilyInstanceFromFont, fontId, &fontFamilyId,
- &fontStyle);
- if (err == noErr) {
- /*
- * Find the canonical name in our global list.
- */
-
- for (i=0; i<familyListMaxValid; ++i) {
- if (fontFamilyId == familyList[i].familyId) {
- faPtr->family = familyList[i].name;
- break;
- }
- }
- if (i >= familyListMaxValid) {
- TkMacOSXDbgMsg("Can't find font %d for \\u%04X", fontFamilyId,
- (unsigned) c);
- }
+ nsFont = [nsFont bestMatchingFontForCharacters:&ch
+ length:1 attributes:nil actualCoveredLength:NULL];
+ if (nsFont) {
+ GetTkFontAttributesForNSFont(nsFont, faPtr);
}
}
-
- TkMacOSXRestoreDrawingContext(&drawingContext);
}
+
+#pragma mark -
+#pragma mark Measuring and drawing:
/*
*---------------------------------------------------------------------------
@@ -837,263 +790,128 @@ TkpMeasureCharsInContext(
* terminating character. */
{
const MacFont *fontPtr = (const MacFont *) tkfont;
- int curX = -1, curByte = 0;
- UniChar *uchars;
- int ulen;
- UniCharArrayOffset urstart, urlen, urend;
- Tcl_DString ucharBuffer;
- int forceCharacterMode = 0;
-
- /*
- * Sanity checks.
- */
-
- if (rangeStart < 0 || (rangeStart+rangeLength) > numBytes) {
- TkMacOSXDbgMsg("Bad parameters");
+ NSString *string;
+ NSAttributedString *attributedString;
+ CTTypesetterRef typesetter;
+ CFIndex start, len;
+ CFRange range = {0, 0};
+ CTLineRef line;
+ CGFloat offset = 0;
+ CFIndex index;
+ double width;
+ int length, fit;
+
+ if (rangeStart < 0 || rangeLength <= 0 ||
+ rangeStart + rangeLength > numBytes ||
+ (maxLength == 0 && !(flags & TK_AT_LEAST_ONE))) {
*lengthPtr = 0;
return 0;
}
-
- /*
- * Get simple no-brainers out of the way.
- */
-
- if (rangeLength == 0 || (maxLength == 0 && !(flags & TK_AT_LEAST_ONE))) {
- *lengthPtr = 0;
- return 0;
+#if 0
+ /* Back-compatibility with ATSUI renderer, appears not to be needed */
+ if (rangeStart == 0 && maxLength == 1 && (flags & TK_ISOLATE_END) &&
+ !(flags & TK_AT_LEAST_ONE)) {
+ length = 0;
+ fit = 0;
+ goto done;
+ }
+#endif
+ if (maxLength > 32767) {
+ maxLength = 32767;
+ }
+ string = [[NSString alloc] initWithBytesNoCopy:(void*)source
+ length:numBytes encoding:NSUTF8StringEncoding freeWhenDone:NO];
+ if (!string) {
+ length = 0;
+ fit = rangeLength;
+ goto done;
+ }
+ attributedString = [[NSAttributedString alloc] initWithString:string
+ attributes:fontPtr->nsAttributes];
+ typesetter = CTTypesetterCreateWithAttributedString(
+ (CFAttributedStringRef)attributedString);
+ start = Tcl_NumUtfChars(source, rangeStart);
+ len = Tcl_NumUtfChars(source + rangeStart, rangeLength);
+ if (start > 0) {
+ range.length = start;
+ line = CTTypesetterCreateLine(typesetter, range);
+ offset = CTLineGetTypographicBounds(line, NULL, NULL, NULL);
+ CFRelease(line);
}
-
- Tcl_DStringInit(&ucharBuffer);
- uchars = Tcl_UtfToUniCharDString(source, numBytes, &ucharBuffer);
- ulen = Tcl_DStringLength(&ucharBuffer) / sizeof(Tcl_UniChar);
- LayoutSetString(fontPtr, NULL, uchars, ulen);
-
- urstart = Tcl_NumUtfChars(source, rangeStart);
- urlen = Tcl_NumUtfChars(source+rangeStart,rangeLength);
- urend = urstart + urlen;
-
if (maxLength < 0) {
- curX = MeasureStringWidth(fontPtr, urstart, urend);
- curByte = rangeLength;
+ index = len;
+ range.length = len;
+ line = CTTypesetterCreateLine(typesetter, range);
+ width = CTLineGetTypographicBounds(line, NULL, NULL, NULL);
+ CFRelease(line);
} else {
- UniCharArrayOffset offset = 0;
- OSStatus err;
-
- /*
- * Have some upper limit on the size actually used.
- */
-
- if (maxLength > 32767) {
- maxLength = 32767;
- }
-
- offset = urstart;
- err = noErr;
-
- if (maxLength > 1) {
- /*
- * Let the system do some work by calculating a line break.
- *
- * Somehow ATSUBreakLine seems to assume that it needs at least
- * one pixel padding. So we add one to the limit. Note also
- * that ATSUBreakLine sometimes runs into an endless loop when
- * the third parameter is equal or less than IntToFixed(2), so we
- * need at least IntToFixed(3) (at least that's the current state
- * of my knowledge).
- */
-
- err = ATSUBreakLine(fontPtr->atsuLayout, urstart,
- IntToFixed(maxLength+1), false, /* !iUseAsSoftLineBreak */
- &offset);
-
- /*
- * There is no way to signal an error from this routine, so we
- * use predefined offset=urstart and otherwise ignore the
- * possibility.
- */
-
- if ((err != noErr) && (err != kATSULineBreakInWord)) {
- TkMacOSXDbgMsg("ATSUBreakLine failed: %ld for '%.*s'", err,
- rangeLength, source+rangeStart);
- }
-
-#ifdef TK_MAC_DEBUG_FONTS
- TkMacOSXDbgMsg("measure: '%.*s', break offset=%ld, errcode=%ld",
- rangeLength, source+rangeStart, offset, err);
-#endif
-
- /*
- * ATSUBreakLine includes the whitespace that separates words,
- * but we don't want that. Besides, ATSUBreakLine thinks that
- * spaces don't occupy pixels at the end of the break, which is
- * also something we like to decide for ourself.
- */
-
- while ((offset > urstart) && (uchars[offset-1] == ' ')) {
- offset--;
- }
- }
-
- /*
- * Fix up left-overs for the TK_WHOLE_WORDS case.
- */
+ double maxWidth = maxLength + offset;
+ NSCharacterSet *cs;
+ index = start;
if (flags & TK_WHOLE_WORDS) {
- if ((flags & TK_AT_LEAST_ONE) && ((offset == urstart)
- || ((offset != urend) && (uchars[offset] != ' ')))) {
- /*
- * With TK_AT_LEAST_ONE, if we are the the start of the
- * range, we need to add at least one character. If we are
- * not at the end of a word, we must be in the middle of the
- * first word still and we want to just use what we have so
- * far. In both cases we still need to find the right
- * character boundary, so we set a flag that gets us into the
- * code for character mode below.
- */
-
- forceCharacterMode = 1;
-
- } else {
- /*
- * If we are not at the end of a word, we must be in the
- * middle of the first word still. Return 0.
- */
-
- if ((offset != urend) && (uchars[offset] != ' ')) {
- offset = urstart;
- curX = 0;
- }
+ index = CTTypesetterSuggestLineBreak(typesetter, start, maxWidth);
+ if (index <= start && (flags & TK_AT_LEAST_ONE)) {
+ flags &= ~TK_WHOLE_WORDS;
}
}
-
- if (offset > urend) {
- offset = urend;
+ if (index <= start && !(flags & TK_WHOLE_WORDS)) {
+ index = CTTypesetterSuggestClusterBreak(typesetter, start, maxWidth);
}
-
- /*
- * If "flags" says that we don't actually want a word break, we need
- * to find the next character break ourself, as ATSUBreakLine will
- * only give us word breaks. Do a simple linear search.
- *
- * Even do this, if ATSUBreakLine returned kATSULineBreakInWord,
- * because we have not accounted correctly for all of the flags yet,
- * like TK_AT_LEAST_ONE.
- */
-
- if ((!(flags & TK_WHOLE_WORDS) || forceCharacterMode) && (offset <= urend)) {
- UniCharArrayOffset lastOffset = offset;
- UniCharArrayOffset nextoffset;
- int lastX = -1;
- int wantonemorechar = -1; /* undecided */
-
- while (offset <= urend) {
- if (flags & TK_ISOLATE_END) {
- LayoutSetString(fontPtr, NULL, uchars, offset);
- }
- curX = MeasureStringWidth(fontPtr, urstart, offset);
-
-#ifdef TK_MAC_DEBUG_FONTS
- TkMacOSXDbgMsg("measure: '%.*s', try until=%ld, width=%d",
- rangeLength, source+rangeStart, offset, curX);
-#endif
-
- if (curX > maxLength) {
- /*
- * Even if we are over the limit, we may want another
- * character in some situations. Than we keep looking
- * for one more character.
- */
-
- if (wantonemorechar == -1) {
- wantonemorechar = ((flags & TK_AT_LEAST_ONE) &&
- (lastOffset == urstart)) ||
- ((flags & TK_PARTIAL_OK) &&
- (lastX != maxLength));
- if (!wantonemorechar) {
- break;
- }
- lastX = curX;
- }
-
- /*
- * There may belong combining marks to this character.
- * Wait for a new curX to collect them all.
- */
-
- if (lastX != curX) {
- break;
- }
- }
-
- /*
- * Save this position, so we can come back to it.
- */
-
- lastX = curX;
- lastOffset = offset;
-
- /*
- * Increment offset by one character, taking combining marks
- * into account.
- */
-
- if (offset >= urend) {
- break;
- }
- nextoffset = 0;
- if (flags & TK_ISOLATE_END) {
- LayoutSetString(fontPtr, NULL, uchars, ulen);
- }
- err = ChkErr(ATSUNextCursorPosition, fontPtr->atsuLayout,
- offset, kATSUByCluster, &nextoffset);
- if (err != noErr) {
- break;
- }
- if (nextoffset <= offset) {
-#ifdef TK_MAC_DEBUG_FONTS
- TkMacOSXDbgMsg("ATSUNextCursorPosition: Can't move further"
- " (shouldn't happen, bad data?)");
-#endif
- break;
- }
-
- offset = nextoffset;
- }
-
- /*
- * We have overshot one character, so backup one position.
- */
-
- curX = lastX;
- offset = lastOffset;
+ cs = (index < len || (flags & TK_WHOLE_WORDS)) ?
+ whitespaceCharacterSet : lineendingCharacterSet;
+ while (index > start &&
+ [cs characterIsMember:[string characterAtIndex:(index - 1)]]) {
+ index--;
+ }
+ if (index <= start && (flags & TK_AT_LEAST_ONE)) {
+ index = start + 1;
+ }
+ if (index > 0) {
+ range.length = index;
+ line = CTTypesetterCreateLine(typesetter, range);
+ width = CTLineGetTypographicBounds(line, NULL, NULL, NULL);
+ CFRelease(line);
+ } else {
+ width = 0;
+ }
+ if (width < maxWidth && (flags & TK_PARTIAL_OK) && index < len) {
+ range.length = ++index;
+ line = CTTypesetterCreateLine(typesetter, range);
+ width = CTLineGetTypographicBounds(line, NULL, NULL, NULL);
+ CFRelease(line);
}
- if (curX < 0) {
- if (flags & TK_ISOLATE_END) {
- LayoutSetString(fontPtr, NULL, uchars, offset);
- }
- curX = MeasureStringWidth(fontPtr, urstart, offset);
+ /* The call to CTTypesetterSuggestClusterBreak above will always
+ return at least one character regardless of whether it exceeded
+ it or not. Clean that up now. */
+ while (width > maxWidth && !(flags & TK_PARTIAL_OK) && index > start) {
+ range.length = --index;
+ line = CTTypesetterCreateLine(typesetter, range);
+ width = CTLineGetTypographicBounds(line, NULL, NULL, NULL);
+ CFRelease(line);
}
- curByte = Tcl_UtfAtIndex(source, offset) - source;
- curByte -= rangeStart;
}
-
- Tcl_DStringFree(&ucharBuffer);
-
+ CFRelease(typesetter);
+ [attributedString release];
+ [string release];
+ length = ceil(width - offset);
+ fit = (Tcl_UtfAtIndex(source, index) - source) - rangeStart;
+done:
#ifdef TK_MAC_DEBUG_FONTS
- TkMacOSXDbgMsg("measure: '%.*s', maxLength=%d, flags=%s%s%s%s "
- "-> width=%d, bytes=%d",
- rangeLength, source+rangeStart, maxLength,
+ TkMacOSXDbgMsg("measure: source=\"%s\" range=\"%.*s\" maxLength=%d "
+ "flags='%s%s%s%s' -> width=%d bytesFit=%d\n", source, rangeLength,
+ source+rangeStart, maxLength,
flags & TK_PARTIAL_OK ? "partialOk " : "",
flags & TK_WHOLE_WORDS ? "wholeWords " : "",
flags & TK_AT_LEAST_ONE ? "atLeastOne " : "",
flags & TK_ISOLATE_END ? "isolateEnd " : "",
- curX, curByte);
+ length, fit);
+//if (!(rangeLength==1 && rangeStart == 0)) fprintf(stderr, " measure len=%d (max=%d, w=%.0f) from %d (nb=%d): source=\"%s\": index=%d return %d\n",rangeLength,maxLength,width,rangeStart,numBytes, source+rangeStart, index, fit);
#endif
-
- *lengthPtr = curX;
- return curByte;
+ *lengthPtr = length;
+ return fit;
}
/*
@@ -1133,8 +951,8 @@ Tk_DrawChars(
int x, int y) /* Coordinates at which to place origin of the
* string when drawing. */
{
- TkpDrawCharsInContext(display, drawable, gc, tkfont, source, numBytes,
- 0, numBytes, x, y);
+ DrawCharsInContext(display, drawable, gc, tkfont, source, numBytes,
+ 0, numBytes, x, y, 0.0);
}
/*
@@ -1178,1219 +996,148 @@ TkpDrawCharsInContext(
* whole (not just the range) string when
* drawing. */
{
- const MacFont * fontPtr = (const MacFont *) tkfont;
+ DrawCharsInContext(display, drawable, gc, tkfont, source, numBytes,
+ rangeStart, rangeLength, x, y, 0.0);
+}
+
+static void
+DrawCharsInContext(
+ Display *display, /* Display on which to draw. */
+ Drawable drawable, /* Window or pixmap in which to draw. */
+ GC gc, /* Graphics context for drawing characters. */
+ Tk_Font tkfont, /* Font in which characters will be drawn; must
+ * be the same as font used in GC. */
+ const char * source, /* UTF-8 string to be displayed. Need not be
+ * '\0' terminated. All Tk meta-characters
+ * (tabs, control characters, and newlines)
+ * should be stripped out of the string that
+ * is passed to this function. If they are not
+ * stripped out, they will be displayed as
+ * regular printing characters. */
+ int numBytes, /* Number of bytes in string. */
+ int rangeStart, /* Index of first byte to draw. */
+ int rangeLength, /* Length of range to draw in bytes. */
+ int x, int y, /* Coordinates at which to place origin of the
+ * whole (not just the range) string when
+ * drawing. */
+ double angle)
+{
+ const MacFont *fontPtr = (const MacFont *) tkfont;
+ NSString *string;
+ NSMutableDictionary *attributes;
+ NSAttributedString *attributedString;
+ CTTypesetterRef typesetter;
+ CFIndex start, len;
+ CTLineRef line;
MacDrawable *macWin = (MacDrawable *) drawable;
- Fixed fx, fy;
- int ulen, urstart, urlen;
- const UniChar * uchars;
- int lineOffset;
TkMacOSXDrawingContext drawingContext;
-#if !TK_MAC_COALESCE_LINE
- Tcl_DString runString;
-#endif
-
- if (!TkMacOSXSetupDrawingContext(drawable, gc, tkMacOSXUseCGDrawing,
- &drawingContext)) {
+ CGContextRef context;
+ CGColorRef fg;
+ NSFont *nsFont;
+ CGAffineTransform t;
+ int h;
+
+ if (rangeStart < 0 || rangeLength <= 0 ||
+ rangeStart + rangeLength > numBytes ||
+ !TkMacOSXSetupDrawingContext(drawable, gc, 1, &drawingContext)) {
return;
}
-
-#if 0
- /*
- * TODO: implement stippled text drawing
- */
-
- if ((gc->fill_style == FillStippled
- || gc->fill_style == FillOpaqueStippled)
- && gc->stipple != None) {
- #error Stippling not implemented
+ string = [[NSString alloc] initWithBytesNoCopy:(void*)source
+ length:numBytes encoding:NSUTF8StringEncoding freeWhenDone:NO];
+ if (!string) {
+ return;
}
-#endif
-
+ context = drawingContext.context;
+ fg = TkMacOSXCreateCGColor(gc, gc->foreground);
+ attributes = [fontPtr->nsAttributes mutableCopy];
+ [attributes setObject:(id)fg forKey:(id)kCTForegroundColorAttributeName];
+ CFRelease(fg);
+ nsFont = [attributes objectForKey:NSFontAttributeName];
+ [nsFont setInContext:[NSGraphicsContext graphicsContextWithGraphicsPort:
+ context flipped:NO]];
+ CGContextSetTextMatrix(context, CGAffineTransformIdentity);
+ attributedString = [[NSAttributedString alloc] initWithString:string
+ attributes:attributes];
+ typesetter = CTTypesetterCreateWithAttributedString(
+ (CFAttributedStringRef)attributedString);
x += macWin->xOff;
y += macWin->yOff;
- /* Turn the y coordinate upside-down for Quarz drawing. */
- if (drawingContext.context) {
- CGContextConcatCTM(drawingContext.context, CGAffineTransformMake(1.0,
- 0.0, 0.0, -1.0, 0.0, drawingContext.portBounds.bottom -
- drawingContext.portBounds.top));
- y = drawingContext.portBounds.bottom -
- drawingContext.portBounds.top - y;
- }
- fy = IntToFixed(y);
-
-#if TK_MAC_COALESCE_LINE
- UpdateLineBuffer(
- fontPtr, &drawingContext, source, numBytes, x, y, &lineOffset);
-
- fx = IntToFixed(currentLeft);
-
- uchars = (const Tcl_UniChar*) Tcl_DStringValue(&currentLine);
- ulen = Tcl_DStringLength(&currentLine) / sizeof(uchars[0]);
-#else
- lineOffset = 0;
- fx = IntToFixed(x);
-
- Tcl_DStringInit(&runString);
- uchars = Tcl_UtfToUniCharDString(source, numBytes, &runString);
- ulen = Tcl_DStringLength(&runString) / sizeof(uchars[0]);
-
- LayoutSetString(fontPtr, &drawingContext, uchars, ulen);
-#endif
-
- urstart = Tcl_NumUtfChars(source, rangeStart);
- urlen = Tcl_NumUtfChars(source+rangeStart,rangeLength);
-
- ChkErr(ATSUDrawText, fontPtr->atsuLayout, lineOffset+urstart, urlen, fx,
- fy);
-
-#if !TK_MAC_COALESCE_LINE
- Tcl_DStringFree(&runString);
-#endif
-
- TkMacOSXRestoreDrawingContext(&drawingContext);
-}
-
-/*
- *---------------------------------------------------------------------------
- *
- * MeasureStringWidth --
- *
- * Low-level measuring of strings.
- *
- * Results:
- * The width of the string in pixels.
- *
- * Side effects:
- * None.
- *
- * Assumptions:
- * fontPtr->atsuLayout is setup with the actual string data to measure.
- *
- *---------------------------------------------------------------------------
- */
-static int
-MeasureStringWidth(
- const MacFont *fontPtr, /* Contains font, ATSU layout and string data
- * to measure. */
- int start, int end) /* Start and end positions to measure in that
- * string. */
-{
- /*
- * This implementation of measuring via ATSUGetGlyphBounds() does not
- * quite conform with the specification given for [font measure]:
- *
- * The return value is the total width in pixels of text, not
- * including the extra pixels used by highly exagerrated characters
- * such as cursive "f".
- *
- * Instead the result of ATSUGetGlyphBounds() *does* include these
- * "extra pixels".
- */
-
- ATSTrapezoid bounds;
- ItemCount numBounds;
-
- if (end <= start) {
- return 0;
- }
-
- bounds.upperRight.x = bounds.upperLeft.x = 0;
- ChkErr(ATSUGetGlyphBounds, fontPtr->atsuLayout, 0, 0, start, end-start,
- kATSUseFractionalOrigins, 1, &bounds, &numBounds);
-#ifdef TK_MAC_DEBUG_FONTS
- if (numBounds < 1 || numBounds > 1) {
- TkMacOSXDbgMsg("ATSUGetGlyphBounds: %s output",
- numBounds < 1 ? "No " : "More");
+ h = drawingContext.portBounds.size.height;
+ y = h - y;
+ t = CGAffineTransformMake(1.0, 0.0, 0.0, -1.0, 0.0, h);
+ if (angle != 0.0) {
+ t = CGAffineTransformTranslate(CGAffineTransformRotate(
+ CGAffineTransformTranslate(t, x, y), angle*M_PI/180.0), -x, -y);
}
-#endif
-
- return FixedToInt(bounds.upperRight.x - bounds.upperLeft.x);
-}
-
-#if TK_MAC_COALESCE_LINE
-/*
- *-------------------------------------------------------------------------
- *
- * UpdateLineBuffer --
- *
- * See the general dicussion of TK_MAC_COALESCE_LINE on the header
- * pages. This function maintains the data for this feature.
- *
- * Results:
- *
- * The Tcl_UniChar string of the whole line as seen so far.
- *
- * Side effects:
- * "*offset" is filled with the index of the first new character in
- * "currentLine". The globals currentLine, currentY, currentLeft,
- * currentRight and currentFontPtr are updated as necessary.
- *
- * The currentLine string is set as the current text in
- * fontPtr->atsuLayout (see LayoutSetString()).
- *
- *-------------------------------------------------------------------------
- */
-
-static const Tcl_UniChar *
-UpdateLineBuffer(
- const MacFont *fontPtr, /* The font to be used for the new piece of
- * text. */
- const TkMacOSXDrawingContext *drawingContextPtr,
- /* The Quarz drawing parameters. Needed for
- * measuring the new piece. */
- const char *source, /* A new piece of line to be added. */
- int numBytes, /* Length of the new piece. */
- int x, int y, /* Position of the new piece in the window. */
- int *offset) /* Filled with the offset of the new piece in
- * currentLine. */
-{
- const Tcl_UniChar * uchars;
- int ulen;
-
- if (y != currentY
- || x < currentRight-1 || x > currentRight+2
- || currentFontPtr != fontPtr) {
- Tcl_DStringFree(&currentLine);
- Tcl_DStringInit(&currentLine);
- currentY = y;
- currentLeft = x;
- currentFontPtr = fontPtr;
- *offset = 0;
- } else {
- *offset = Tcl_DStringLength(&currentLine) / 2;
+ CGContextConcatCTM(context, t);
+ CGContextSetTextPosition(context, x, y);
+ start = Tcl_NumUtfChars(source, rangeStart);
+ len = Tcl_NumUtfChars(source, rangeStart + rangeLength);
+ if (start > 0) {
+ CGRect clipRect = CGRectInfinite, startBounds;
+ line = CTTypesetterCreateLine(typesetter, CFRangeMake(0, start));
+ startBounds = CTLineGetImageBounds(line, context);
+ CFRelease(line);
+ clipRect.origin.x = startBounds.origin.x + startBounds.size.width;
+ CGContextClipToRect(context, clipRect);
}
-
- Tcl_UtfToUniCharDString(source, numBytes, &currentLine);
- uchars = (const Tcl_UniChar*) Tcl_DStringValue(&currentLine);
- ulen = Tcl_DStringLength(&currentLine) / sizeof(*uchars);
- LayoutSetString(fontPtr, drawingContextPtr, uchars, ulen);
- currentRight = x + MeasureStringWidth(fontPtr, *offset, ulen);
-
- return uchars;
-}
-#endif /* TK_MAC_COALESCE_LINE */
-
-/*
- *---------------------------------------------------------------------------
- *
- * FamilyNameForFamilyID --
- *
- * Helper for InitFont() and TkMacOSXFontDescriptionForFMFontInfo().
- * Retrieves font family names for a given font family ID.
- *
- * Results:
- * Font family name or NULL.
- *
- * Side effects:
- * None.
- *
- *---------------------------------------------------------------------------
- */
-
-static const char *
-FamilyNameForFamilyID(
- FMFontFamily familyId)
-{
- OSStatus err;
- char name[256] = "";
- const MacFontFamily * familyPtr = NULL;
-
- err = ChkErr(GetFontFamilyName, familyId, name, sizeof(name));
- if (err == noErr) {
- /*
- * We find the canonical font name, so we can avoid unnecessary
- * memory management.
- */
-
- familyPtr = FindFontFamily(name);
-#ifdef TK_MAC_DEBUG_FONTS
- if (!familyPtr) {
- TkMacOSXDbgMsg("Font family '%s' not found", name);
- }
-#endif
- }
- return familyPtr ? familyPtr->name : NULL;
-}
-
-/*
- *---------------------------------------------------------------------------
- *
- * InitFont --
- *
- * Helper for TkpGetNativeFont() and TkpGetFontFromAttributes().
- * Initializes the memory for a MacFont that wraps the
- * platform-specific data.
- *
- * The caller is responsible for initializing the fields of the TkFont
- * that are used exclusively by the generic TkFont code, and for
- * releasing those fields before calling TkpDeleteFont().
- *
- * Results:
- * Fills the MacFont structure.
- *
- * Side effects:
- * Memory allocated.
- *
- *---------------------------------------------------------------------------
- */
-
-static void
-InitFont(
- FMFontFamily familyId, /* The font family to initialize for. */
- const char * familyName, /* The font family name, if known. Otherwise
- * this can be NULL. */
- int size, /* Point size for the font. */
- int qdStyle, /* QuickDraw style bits. */
- MacFont * fontPtr) /* Filled with information constructed from the
- * above arguments. */
-{
- FontInfo fi;
- TkFontAttributes * faPtr;
- TkFontMetrics * fmPtr;
- int periodWidth, wWidth;
-
- if (size == 0) {
- size = GetDefFontSize();
- }
- ChkErr(FetchFontInfo, familyId, size, qdStyle, &fi);
- if (!familyName) {
- familyName = FamilyNameForFamilyID(familyId);
- }
-
- fontPtr->font.fid = (Font) fontPtr;
-
- faPtr = &fontPtr->font.fa;
- faPtr->family = familyName;
- faPtr->size = size;
- faPtr->weight = (qdStyle & bold) ? TK_FW_BOLD : TK_FW_NORMAL;
- faPtr->slant = (qdStyle & italic) ? TK_FS_ITALIC : TK_FS_ROMAN;
- faPtr->underline = ((qdStyle & underline) != 0);
- faPtr->overstrike = 0;
-
- fmPtr = &fontPtr->font.fm;
-
- /*
- * Note: Macs measure the line height as ascent + descent +
- * leading. Leading as a separate entity does not exist in X11
- * and Tk. We add it to the ascent at the moment, because adding
- * it to the descent, as the Mac docs would indicate, would change
- * the position of self-drawn underlines.
- */
-
- fmPtr->ascent = fi.ascent + fi.leading;
- fmPtr->descent = fi.descent;
- fmPtr->maxWidth = fi.widMax;
-
- fontPtr->qdFont = familyId;
- fontPtr->qdSize = size;
- fontPtr->qdStyle = (short) qdStyle;
-
- InitATSUObjects(familyId, size, qdStyle, &fontPtr->atsuFontId,
- &fontPtr->atsuLayout, &fontPtr->atsuStyle);
-
- Tk_MeasureChars((Tk_Font)fontPtr, ".", 1, -1, 0, &periodWidth);
- Tk_MeasureChars((Tk_Font)fontPtr, "W", 1, -1, 0, &wWidth);
- fmPtr->fixed = periodWidth == wWidth;
-
- SetFontFeatures(fontPtr->atsuFontId, fmPtr->fixed, size,
- fontPtr->atsuStyle);
-
- AdjustFontHeight(fontPtr);
+ line = CTTypesetterCreateLine(typesetter, CFRangeMake(0, len));
+ CTLineDraw(line, context);
+ CFRelease(line);
+ CFRelease(typesetter);
+ [attributedString release];
+ [string release];
+ [attributes release];
+ TkMacOSXRestoreDrawingContext(&drawingContext);
}
-
-/*
- *---------------------------------------------------------------------------
- *
- * InitATSUObjects --
- *
- * Helper for InitFont(). Initializes the ATSU data handles for a
- * MacFont.
- *
- * Results:
- * Sets up all we know and can do at this point in time in fontIdPtr,
- * layoutPtr and stylePtr.
- *
- * Side effects:
- * Allocates data structures inside of ATSU.
- *
- *---------------------------------------------------------------------------
- */
-
-static void
-InitATSUObjects(
- FMFontFamily familyId, /* The font family to use. */
- short ptSize, short qdStyles,
- /* The additional font parameters. */
- ATSUFontID *fontIdPtr, /* Filled with the font id. */
- ATSUTextLayout *layoutPtr, /* Filled with the ATSU layout handle. */
- ATSUStyle *stylePtr) /* Filled with the ATSU style handle,
- * configured with all parameters. */
-{
- FMFontStyle stylesDone, stylesLeft;
-
- /*
- * Defaults in case of error.
- */
-
- *fontIdPtr = GetAppFont();
- *stylePtr = 0;
- *layoutPtr = 0;
-
- /*
- * Generate a font id from family id and QD style bits.
- */
-
- ChkErr(FMGetFontFromFontFamilyInstance, familyId, qdStyles, fontIdPtr,
- &stylesDone);
-
- /*
- * We see what style bits are left and tell ATSU to synthesize what's
- * left like QD does it.
- */
-
- stylesLeft = qdStyles & ~(unsigned)stylesDone;
-
- /*
- * Create the style and set its attributes.
- */
- ChkErr(ATSUCreateStyle, stylePtr);
- InitATSUStyle(*fontIdPtr, ptSize, stylesLeft, *stylePtr);
-
- /*
- * Create the layout. Note: We can't set the layout attributes here,
- * because the text and the style must be set first.
- */
-
- ChkErr(ATSUCreateTextLayout, layoutPtr);
- /*InitATSULayout(*layoutPtr);*/
-}
+#pragma mark -
+#pragma mark Accessors:
/*
*---------------------------------------------------------------------------
*
- * InitATSUStyle --
+ * TkMacOSXNSFontForFont --
*
- * Helper for InitATSUObjects(). Initializes the ATSU style for a
- * MacFont.
+ * Return an NSFont for the given Tk_Font.
*
* Results:
- * Sets up all parameters needed for an ATSU style.
+ * NSFont*.
*
* Side effects:
- * Allocates data structures for the style inside of ATSU.
- *
- *---------------------------------------------------------------------------
- */
-
-static void
-InitATSUStyle(
- ATSUFontID fontId, /* The font id to use. */
- short ptSize, short qdStyles,
- /* Additional font parameters. */
- ATSUStyle style) /* The style handle to configure. */
-{
- /*
- * Attributes for the style.
- */
-
- Fixed fsize = IntToFixed(ptSize);
- Boolean
- isBold = (qdStyles&bold) != 0,
- isUnderline = (qdStyles&underline) != 0,
- isItalic = (qdStyles&italic) != 0;
-
- ATSStyleRenderingOptions options =
- antialiasedTextEnabled == -1 ? kATSStyleNoOptions :
- antialiasedTextEnabled == 0 ? kATSStyleNoAntiAliasing :
- kATSStyleApplyAntiAliasing;
-
- static const ATSUAttributeTag styleTags[] = {
- kATSUFontTag, kATSUSizeTag,
- kATSUQDBoldfaceTag, kATSUQDItalicTag, kATSUQDUnderlineTag,
- kATSUStyleRenderingOptionsTag,
- };
- static const ByteCount styleSizes[] = {
- sizeof(ATSUFontID), sizeof(Fixed),
- sizeof(Boolean), sizeof(Boolean), sizeof(Boolean),
- sizeof(ATSStyleRenderingOptions),
- };
- const ATSUAttributeValuePtr styleValues[] = {
- &fontId, &fsize,
- &isBold, &isItalic, &isUnderline,
- &options,
- };
-
- ChkErr(ATSUSetAttributes, style, sizeof(styleTags)/sizeof(styleTags[0]),
- styleTags, styleSizes, styleValues);
-}
-
-/*
- *---------------------------------------------------------------------------
- *
- * SetFontFeatures --
- *
- * Helper for InitFont(). Request specific font features of the ATSU
- * style object for a MacFont.
- *
- * Results:
* None.
*
- * Side effects:
- * Specific font features are enabled on the ATSU style object.
- *
- *---------------------------------------------------------------------------
- */
-
-static void
-SetFontFeatures(
- ATSUFontID fontId, /* The font id to use. */
- int fixed, /* Is this a fixed font? */
- short size, /* Size of the font */
- ATSUStyle style) /* The style handle to configure. */
-{
- /*
- * Don't use the standard latin ligatures, if this is determined to be a
- * fixed-width font.
- */
-
- static const ATSUFontFeatureType fixed_featureTypes[] = {
- kLigaturesType, kLigaturesType
- };
- static const ATSUFontFeatureSelector fixed_featureSelectors[] = {
- kCommonLigaturesOffSelector, kRareLigaturesOffSelector
- };
-
- if (fixed) {
- ChkErr(ATSUSetFontFeatures, style, sizeof(fixed_featureTypes) /
- sizeof(fixed_featureTypes[0]), fixed_featureTypes,
- fixed_featureSelectors);
- if (size <= 10) {
- /*
- * Disable antialiasing of fixed-width fonts with sizes <= 10
- */
-
- const ATSStyleRenderingOptions options = kATSStyleNoAntiAliasing;
- const ATSUAttributeTag styleTag = kATSUStyleRenderingOptionsTag;
- const ByteCount styleSize = sizeof(ATSStyleRenderingOptions);
- const ConstATSUAttributeValuePtr styleValue = &options;
-
- ChkErr(ATSUSetAttributes, style, 1, &styleTag, &styleSize,
- (ATSUAttributeValuePtr*) &styleValue);
- }
- }
-}
-
-/*
- *---------------------------------------------------------------------------
- *
- * AdjustFontHeight --
- *
- * Helper for InitFont(). Check font height against some real world
- * examples.
- *
- * Results:
- * None.
- *
- * Side effects:
- * The metrics in fontPtr->font.fm are adjusted so that typical combined
- * characters fit into ascent+descent.
- *
- *---------------------------------------------------------------------------
- */
-
-static void
-AdjustFontHeight(
- MacFont * fontPtr)
-{
- /*
- * The standard values for ascent, descent and leading as determined in
- * InitFont do not take composition into account, they are designed for
- * plain ASCII characters. This code measures the actual size of some
- * typical composed characters from the Latin-1 range and corrects these
- * factors, especially the ascent.
- *
- * A font requested with a pixel size may thus have a larger line height
- * than requested.
- *
- * An alternative would be to instruct ATSU to shrink oversized combined
- * characters. I think I have seen that feature somewhere, but I can't
- * find it now [BR].
- */
-
- static const UniChar chars[]
- /* Auml, Aacute, Acirc, Atilde, Ccedilla */
- = {0x00C4, 0x00C1, 0x00C2, 0x00C3, 0x00C7};
- static const int charslen = sizeof(chars) / sizeof(chars[0]);
- Rect size;
- OSStatus err;
-
- LayoutSetString(fontPtr, NULL, chars, charslen);
-
- size.top = size.bottom = 0;
- err = ChkErr(ATSUMeasureTextImage, fontPtr->atsuLayout, 0, charslen, 0, 0,
- &size);
-
- if (err == noErr) {
- TkFontMetrics * fmPtr = &fontPtr->font.fm;
- int ascent = -size.top;
- int descent = size.bottom;
-
- if (ascent > fmPtr->ascent) {
- fmPtr->ascent = ascent;
- }
- if (descent > fmPtr->descent) {
- fmPtr->descent = descent;
- }
- }
-}
-
-/*
- *---------------------------------------------------------------------------
- *
- * InitATSULayout --
- *
- * Helper for LayoutSetString(). Initializes the ATSU layout
- * object for a MacFont and a specific string.
- *
- * Results:
- * Sets up all parameters needed for an ATSU layout object.
- *
- * Side effects:
- * Allocates data structures for the layout object inside of ATSU.
- *
- * Assumptions:
- * The actual string data and style information is already set by
- * ATSUSetTextPointerLocation() and ATSUSetRunStyle() (see
- * LayoutSetString()).
- *
*---------------------------------------------------------------------------
*/
-static void
-InitATSULayout(
- const TkMacOSXDrawingContext *drawingContextPtr,
- /* Specifies the CGContext to use. */
- ATSUTextLayout layout, /* The layout object to configure. */
- int fixed) /* Is this a fixed font? */
+MODULE_SCOPE NSFont*
+TkMacOSXNSFontForFont(
+ Tk_Font tkfont)
{
- /*
- * Attributes for the layout.
- */
-
- ATSLineLayoutOptions layoutOptions = 0
-#if TK_MAC_COALESCE_LINE
- /*
- * Options to use unconditionally when we try to do coalescing.
- */
- | kATSLineDisableAllLayoutOperations
- | kATSLineFractDisable
- | kATSLineUseDeviceMetrics
-#endif
- ;
- CGContextRef context = drawingContextPtr ?
- drawingContextPtr->context : NULL;
-
- static const ATSUAttributeTag layoutTags[] = {
- kATSUCGContextTag,
- kATSULineLayoutOptionsTag,
- };
- static const ByteCount layoutSizes[] = {
- sizeof(CGContextRef),
- sizeof(ATSLineLayoutOptions),
- };
- const ATSUAttributeValuePtr layoutValues[] = {
- &context,
- &layoutOptions,
- };
-
- /*
- * Ensure W(abcdefg) == W(a)*7 for fixed fonts (Latin scripts only).
- */
-
- if (fixed) {
- layoutOptions |= kATSLineFractDisable | kATSLineUseDeviceMetrics;
- }
-
- ChkErr(ATSUSetLayoutControls, layout, sizeof(layoutTags) /
- sizeof(layoutTags[0]), layoutTags, layoutSizes, layoutValues);
- ChkErr(ATSUSetTransientFontMatching, layout, true);
+ return tkfont ? ((MacFont *)tkfont)->nsFont : nil;
}
/*
*---------------------------------------------------------------------------
*
- * LayoutSetString --
+ * TkMacOSXNSFontAttributesForFont --
*
- * Setup the MacFont for a specific string.
+ * Return an NSDictionary of font attributes for the given Tk_Font.
*
* Results:
- * Sets up all parameters so that ATSU can work with the objects in
- * MacFont.
+ * NSFont*.
*
* Side effects:
- * Sets parameters on the layout object fontPtr->atsuLayout.
- *
- *---------------------------------------------------------------------------
- */
-
-void
-LayoutSetString(
- const MacFont *fontPtr, /* The fontPtr to configure. */
- const TkMacOSXDrawingContext *drawingContextPtr,
- /* For the CGContext to be used.*/
- const UniChar *uchars, int ulen)
- /* The UniChar string to set into
- * fontPtr->atsuLayout. */
-{
- ChkErr(ATSUSetTextPointerLocation, fontPtr->atsuLayout, uchars,
- kATSUFromTextBeginning, ulen, ulen);
-
- /*
- * Styles can only be set after the text is set.
- */
-
- ChkErr(ATSUSetRunStyle, fontPtr->atsuLayout, fontPtr->atsuStyle,
- kATSUFromTextBeginning, kATSUToTextEnd);
-
- /*
- * Layout attributes can only be set after the styles are set.
- */
-
- InitATSULayout(drawingContextPtr, fontPtr->atsuLayout,
- fontPtr->font.fm.fixed);
-}
-
-/*
- *-------------------------------------------------------------------------
- *
- * ReleaseFont --
- *
- * Called to release the Macintosh-specific contents of a TkFont. The
- * caller is responsible for freeing the memory used by the font
- * itself.
- *
- * Results:
* None.
*
- * Side effects:
- * Memory is freed.
- *
*---------------------------------------------------------------------------
*/
-static void
-ReleaseFont(
- MacFont *fontPtr) /* The font to delete. */
+MODULE_SCOPE NSDictionary*
+TkMacOSXNSFontAttributesForFont(
+ Tk_Font tkfont)
{
- ATSUDisposeTextLayout(fontPtr->atsuLayout);
- ATSUDisposeStyle(fontPtr->atsuStyle);
-}
-
-/*
- *-------------------------------------------------------------------------
- *
- * FindFontFamilyOrAlias, FindFontFamilyOrAliasOrFallback --
- *
- * Determine if any physical screen font exists on the system with the
- * given family name. If the family exists, then it should be possible
- * to construct some physical screen font with that family name.
- *
- * FindFontFamilyOrAlias also considers font aliases as determined by
- * TkFontGetAliasList().
- *
- * FindFontFamilyOrAliasOrFallback also considers font aliases as
- * determined by TkFontGetFallbacks().
- *
- * The overall algorithm to get the closest font to the one requested is
- * this:
- *
- * try fontname
- * try all aliases for fontname
- * foreach fallback for fontname
- * try the fallback
- * try all aliases for the fallback
- *
- * Results:
- *
- * The return value is NULL if the specified font family does not exist,
- * a valid MacFontFamily* otherwise.
- *
- * Side effects:
- *
- * None.
- *
- *-------------------------------------------------------------------------
- */
-
-static const MacFontFamily *
-FindFontFamilyOrAlias(
- const char *name) /* Name or alias name of the font to find. */
-{
- const MacFontFamily * familyPtr;
- char ** aliases;
- int i;
-
- familyPtr = FindFontFamily(name);
- if (familyPtr != NULL) {
- return familyPtr;
- }
-
- aliases = TkFontGetAliasList(name);
- if (aliases != NULL) {
- for (i = 0; aliases[i] != NULL; i++) {
- familyPtr = FindFontFamily(aliases[i]);
- if (familyPtr != NULL) {
- return familyPtr;
- }
- }
- }
- return NULL;
-}
-
-static const MacFontFamily *
-FindFontFamilyOrAliasOrFallback(
- const char *name) /* Name or alias name of the font to find. */
-{
- const MacFontFamily * familyPtr;
- const char * fallback;
- char *** fallbacks;
- int i, j;
-
- familyPtr = FindFontFamilyOrAlias(name);
- if (familyPtr != NULL) {
- return familyPtr;
- }
- fallbacks = TkFontGetFallbacks();
- for (i = 0; fallbacks[i] != NULL; i++) {
- for (j = 0; (fallback = fallbacks[i][j]) != NULL; j++) {
- if (strcasecmp(name, fallback) == 0) {
- for (j = 0; (fallback = fallbacks[i][j]) != NULL; j++) {
- familyPtr = FindFontFamilyOrAlias(fallback);
- if (familyPtr != NULL) {
- return familyPtr;
- }
- }
- }
- break; /* benny: This "break" is a carry-over from
- * tkMacOSXFont.c, but what is actually its purpose
- * ???? */
- }
- }
-
-
- /*
- * FIXME: We would have liked to recover by re-enumerating fonts. But
- * that doesn't work, because Carbon seems to cache the inital list of
- * fonts. Fonts newly installed don't show up with
- * FMCreateFontFamilyIterator()/FMGetNextFontFamily() without a restart
- * of the app. Similar problem with fonts removed.
- */
-
-#ifdef TK_MAC_DEBUG_FONTS
- TkMacOSXDbgMsg("Font family '%s' not found", name);
-#endif
-
- return NULL;
-}
-
-/*
- *-------------------------------------------------------------------------
- *
- * InitFontFamilies --
- *
- * Helper to TkpFontPkgInit. Use the Font Manager to fill in the
- * familyList global array.
- *
- * Results:
- *
- * None.
- *
- * Side effects:
- *
- * Allocates memory.
- *
- *-------------------------------------------------------------------------
- */
-
-static void
-InitFontFamilies(void)
-{
- FMFontFamily fontFamily;
- Str255 fontName;
- SInt16 fontSize;
- Style fontStyle;
-
- /*
- * Has this been called before?
- */
-
- if (familyListNextFree > 0) {
- return;
- }
-
- ChkErr(ATSFontFamilyApplyFunction, FontFamilyEnumCallback,NULL);
-
- if (GetThemeFontAndFamily(kThemeSystemFont, &fontFamily, fontName,
- &fontSize, &fontStyle) == noErr) {
- AddFontFamily(SYSTEMFONT_NAME, fontFamily);
- }
- if (GetThemeFontAndFamily(kThemeApplicationFont, &fontFamily, fontName,
- &fontSize, &fontStyle) == noErr) {
- AddFontFamily(APPLFONT_NAME, fontFamily);
- }
- if (GetThemeFontAndFamily(kThemeMenuItemFont, &fontFamily, fontName,
- &fontSize, &fontStyle) == noErr) {
- AddFontFamily(MENUITEMFONT_NAME, fontFamily);
- }
-
- SortFontFamilies();
-}
-
-/*
- *-------------------------------------------------------------------------
- *
- * FontFamilyEnumCallback --
- *
- * Callback for ATSFontFamilyApplyFunction().
- *
- * Results:
- *
- * noErr.
- *
- * Side effects:
- *
- * None.
- *
- *-------------------------------------------------------------------------
- */
-
-static OSStatus
-FontFamilyEnumCallback(
- ATSFontFamilyRef family,
- void *refCon)
-{
- OSStatus err;
- char name[260] = "";
-
- (void) refCon;
-
- err = ChkErr(GetFontFamilyName, family, name, sizeof(name));
- if (err == noErr) {
- AddFontFamily(name, family);
- }
-
- return noErr;
-}
-
-/*
- *-------------------------------------------------------------------------
- *
- * GetFontFamilyName --
- *
- * Use the Font Manager to get the name of a given FMFontfamily. This
- * currently gets the standard, non-localized QuickDraw name. Other
- * names would be possible, see docs for ATSUFindFontName for a
- * selection. The MacOSX font selector seems to use the localized
- * family name given by ATSUFindFontName(kFontFamilyName), but that API
- * doesn't give us a name at all for some fonts.
- *
- * Results:
- * An OS error code, noErr on success. name is filled with the
- * resulting name.
- *
- * Side effects:
- * None.
- *
- *-------------------------------------------------------------------------
- */
-
-static OSStatus
-GetFontFamilyName(
- FMFontFamily fontFamily, /* The font family for which to find the
- * name. */
- char * name, int numBytes) /* Filled with the result. */
-{
- OSStatus err;
- Str255 nativeName;
- CFStringRef cfString;
- TextEncoding encoding;
- ScriptCode nameencoding;
-
- nativeName[0] = 0;
- name[0] = 0;
- err = ChkErr(FMGetFontFamilyName, fontFamily, nativeName);
- if (err != noErr) {
- return err;
- }
-
- /*
- * QuickDraw font names are encoded with the script that the font uses.
- * So we determine that encoding and than we reencode the name. We
- * pre-set the encoding with the default value, so we do not need to
- * check result codes here.
- */
-
- encoding = kTextEncodingMacRoman;
- ChkErr(FMGetFontFamilyTextEncoding, fontFamily, &encoding);
- nameencoding = encoding;
- ChkErr(RevertTextEncodingToScriptInfo, encoding, &nameencoding, NULL,
- NULL);
-
- /*
- * Note: We could use Tcl facilities to do the re-encoding here. We'd
- * have to maintain tables to map OS encoding codes to Tcl encoding names
- * like tkMacOSXFont.c did. Using native re-encoding directly instead is
- * a lot easier and future-proof than that. There is one snag, though: I
- * have seen CFStringGetCString() crash with invalid encoding ids. But
- * than if that happens it would be a bug in
- * FMGetFontFamilyTextEncoding() or RevertTextEncodingToScriptInfo().
- * Another problem is that users have seen CFStringCreate return null
- * (Bug #2548661). This is due to font names with a bad encoding.
- */
-
- cfString = CFStringCreateWithPascalStringNoCopy(
- NULL, nativeName, nameencoding, kCFAllocatorNull);
- if (cfString == NULL) {
- TkMacOSXDbgMsg("CFStringCreate: "
- "'%.*s' could not be decoded with encoding %d",
- nativeName[0], nativeName+1, (int) nameencoding);
- return kTextMalformedInputErr;
- }
-
- CFStringGetCString(cfString, name, numBytes, kCFStringEncodingUTF8);
- CFRelease(cfString);
-
- return noErr;
-}
-
-/*
- *-------------------------------------------------------------------------
- *
- * FindFontFamily --
- *
- * Find the font family with the given name in the global familyList.
- * Uses bsearch() for convenient access. Comparision is done
- * non-case-sensitively with CompareFontFamilies() which see.
- *
- * Results:
- *
- * MacFontFamily: A pair of family id and the actual name registered for
- * the font.
- *
- * Side effects:
- *
- * None.
- *
- * Assumption:
- *
- * Requires the familyList array to be sorted.
- *
- *-------------------------------------------------------------------------
- */
-
-static const MacFontFamily *
-FindFontFamily(
- const char *name) /* The family name. Note: Names are compared
- * non-case-sensitive. */
-{
- const MacFontFamily key = {name,-1};
-
- if(familyListMaxValid <= 0) {
- return NULL;
- }
-
- return bsearch(&key, familyList, familyListMaxValid, sizeof(*familyList),
- CompareFontFamilies);
-}
-
-/*
- *-------------------------------------------------------------------------
- *
- * EnumFontFamilies --
- *
- * Create a Tcl list with the registered names in the global familyList.
- *
- * Results:
- * A Tcl list of names.
- *
- * Side effects:
- * None.
- *
- *-------------------------------------------------------------------------
- */
-
-static Tcl_Obj *
-EnumFontFamilies(void)
-{
- int i;
- Tcl_Obj * tclList;
-
- tclList = Tcl_NewListObj(0, NULL);
- for (i=0; i<familyListMaxValid; ++i) {
- Tcl_ListObjAppendElement(NULL, tclList,
- Tcl_NewStringObj(familyList[i].name, -1));
- }
-
- return tclList;
-}
-
-/*
- *-------------------------------------------------------------------------
- *
- * AddFontFamily --
- *
- * Register a font family in familyList. Until SortFontFamilies() is
- * called, this is not actually available for FindFontFamily().
- *
- * Results:
- *
- * MacFontFamily: The new pair of family id and the actual name
- * registered for the font.
- *
- * Side effects:
- *
- * New entry in familyList and familyListNextFree updated.
- *
- *-------------------------------------------------------------------------
- */
-
-static const MacFontFamily *
-AddFontFamily(
- const char *name, /* Font family name to register. */
- FMFontFamily familyId) /* Font family id to register. */
-{
- MacFontFamily * familyPtr;
-
- if (familyListNextFree >= familyListSize) {
- familyListSize += 100;
- familyList = (MacFontFamily *) ckrealloc((void*) familyList,
- familyListSize * sizeof(*familyList));
- }
-
- familyPtr = familyList + familyListNextFree;
- ++familyListNextFree;
-
- familyPtr->name = AddString(name);
- familyPtr->familyId = familyId;
-
- return familyPtr;
-}
-
-/*
- *-------------------------------------------------------------------------
- *
- * SortFontFamilies --
- *
- * Sort the entries in familyList. Only after calling
- * SortFontFamilies(), the new families registered with AddFontFamily()
- * are actually available for FindFontFamily(), because FindFontFamily()
- * requires the array to be sorted.
- *
- * Results:
- *
- * None.
- *
- * Side effects:
- *
- * familyList is sorted and familyListMaxValid is updated.
- *
- *-------------------------------------------------------------------------
- */
-
-static void
-SortFontFamilies(void)
-{
- if (familyListNextFree > 0) {
- qsort(familyList, familyListNextFree, sizeof(*familyList),
- CompareFontFamilies);
- }
- familyListMaxValid = familyListNextFree;
-}
-
-/*
- *-------------------------------------------------------------------------
- *
- * CompareFontFamilies --
- *
- * Comparison function used by SortFontFamilies() and FindFontFamily().
- *
- * Results:
- * Result as required to generate a stable sort order for bsearch() and
- * qsort(). The ordering is not case-sensitive as far as
- * Tcl_UtfNcasecmp() (which see) can provide that.
- *
- * Note: It would be faster to compare first the length and the actual
- * strings only as a tie-breaker, but than the ordering wouldn't look so
- * pretty in [font families] ;-).
- *
- * Side effects:
- * None.
- *
- *-------------------------------------------------------------------------
- */
-
-static int
-CompareFontFamilies(
- const void * vp1,
- const void * vp2)
-{
- const char * name1;
- const char * name2;
- int len1, len2, diff;
-
- name1 = ((const MacFontFamily *) vp1)->name;
- name2 = ((const MacFontFamily *) vp2)->name;
-
- len1 = Tcl_NumUtfChars(name1, -1);
- len2 = Tcl_NumUtfChars(name2, -1);
-
- diff = Tcl_UtfNcasecmp(name1, name2, len1<len2 ? len1 : len2);
-
- return diff == 0 ? len1-len2 : diff;
-}
-
-/*
- *-------------------------------------------------------------------------
- *
- * AddString --
- *
- * Helper for AddFontFamily(). Allocates a string in the one-shot
- * allocator.
- *
- * Results:
- * A duplicated string in the one-shot allocator.
- *
- * Side effects:
- * May allocate a new memory block.
- *
- *-------------------------------------------------------------------------
- */
-
-static const char *
-AddString(
- const char *in) /* String to add, zero-terminated. */
-{
- int len;
- char *result;
-
- len = strlen(in) +1;
-
- if (stringMemory == NULL
- || (stringMemory->nextFree+len) > STRING_BLOCK_MAX) {
- StringBlock * newblock = (StringBlock *) ckalloc(sizeof(StringBlock));
-
- newblock->next = stringMemory;
- newblock->nextFree = 0;
- stringMemory = newblock;
- }
-
- result = stringMemory->strings + stringMemory->nextFree;
- stringMemory->nextFree += len;
-
- memcpy(result, in, len);
-
- return result;
+ return tkfont ? ((MacFont *)tkfont)->nsAttributes : nil;
}
/*
@@ -2415,54 +1162,12 @@ TkMacOSXIsCharacterMissing(
Tk_Font tkfont, /* The font we are looking in. */
unsigned int searchChar) /* The character we are looking for. */
{
- /* Background: This function is private and only used in
- * tkMacOSXMenu.c:FindMarkCharacter().
- *
- * We could use ATSUMatchFont() to implement. We'd have to change the
- * definition of the encoding of the parameter searchChar from MacRoman
- * to UniChar for that.
- *
- * The system uses font fallback for controls, so we don't really need
- * this. */
-
return 0;
}
/*
*----------------------------------------------------------------------
*
- * TkMacOSXInitControlFontStyle --
- *
- * This procedure sets up the appropriate ControlFontStyleRec
- * for a Mac control.
- *
- * Results:
- * None.
- *
- * Side effects:
- * None.
- *
- *----------------------------------------------------------------------
- */
-
-void
-TkMacOSXInitControlFontStyle(
- Tk_Font tkfont, /* Tk font object to use for the control. */
- ControlFontStylePtr fsPtr) /* The style object to configure. */
-{
- const MacFont * fontPtr = (MacFont *) tkfont;
-
- fsPtr->flags = kControlUseFontMask | kControlUseSizeMask |
- kControlUseFaceMask | kControlUseJustMask;
- fsPtr->font = fontPtr->qdFont;
- fsPtr->size = fontPtr->qdSize;
- fsPtr->style = fontPtr->qdStyle;
- fsPtr->just = teCenter;
-}
-
-/*
- *----------------------------------------------------------------------
- *
* TkMacOSXUseAntialiasedText --
*
* Enables or disables application-wide use of antialiased text (where
diff --git a/macosx/tkMacOSXFont.h b/macosx/tkMacOSXFont.h
index 6ce310d..3bb4557 100644
--- a/macosx/tkMacOSXFont.h
+++ b/macosx/tkMacOSXFont.h
@@ -6,11 +6,13 @@
*
* Copyright (c) 1990-1994 The Regents of the University of California.
* Copyright (c) 1994-1997 Sun Microsystems, Inc.
- * Copyright 2001, Apple Computer, Inc.
- * Copyright (c) 2006-2007 Daniel A. Steffen <das@users.sourceforge.net>
+ * Copyright 2001-2009, Apple Inc.
+ * Copyright (c) 2006-2009 Daniel A. Steffen <das@users.sourceforge.net>
*
* See the file "license.terms" for information on usage and redistribution
* of this file, and for a DISCLAIMER OF ALL WARRANTIES.
+ *
+ * RCS: @(#) $Id$
*/
#ifndef TKMACOSXFONT_H
@@ -22,11 +24,4 @@
#include "tkMacOSXInt.h"
#endif
-/*
- * Function prototypes
- */
-
-MODULE_SCOPE void TkMacOSXInitControlFontStyle(Tk_Font tkfont,
- ControlFontStylePtr fsPtr);
-
#endif /*TKMACOSXFONT_H*/
diff --git a/macosx/tkMacOSXHLEvents.c b/macosx/tkMacOSXHLEvents.c
index 14ce7d9..a886408 100644
--- a/macosx/tkMacOSXHLEvents.c
+++ b/macosx/tkMacOSXHLEvents.c
@@ -5,11 +5,13 @@
* only event that really does anything is the Quit event.
*
* Copyright (c) 1995-1997 Sun Microsystems, Inc.
- * Copyright 2001, Apple Computer, Inc.
+ * Copyright 2001-2009, Apple Inc.
* Copyright (c) 2006-2009 Daniel A. Steffen <das@users.sourceforge.net>
*
- * See the file "license.terms" for information on usage and redistribution of
- * this file, and for a DISCLAIMER OF ALL WARRANTIES.
+ * See the file "license.terms" for information on usage and redistribution
+ * of this file, and for a DISCLAIMER OF ALL WARRANTIES.
+ *
+ * RCS: @(#) $Id$
*/
#include "tkMacOSXPrivate.h"
@@ -31,22 +33,38 @@ typedef struct KillEvent {
*/
static OSErr QuitHandler(const AppleEvent *event,
- AppleEvent *reply, long handlerRefcon);
+ AppleEvent *reply, SRefCon handlerRefcon);
static OSErr OappHandler(const AppleEvent *event,
- AppleEvent *reply, long handlerRefcon);
+ AppleEvent *reply, SRefCon handlerRefcon);
static OSErr RappHandler(const AppleEvent *event,
- AppleEvent *reply, long handlerRefcon);
+ AppleEvent *reply, SRefCon handlerRefcon);
static OSErr OdocHandler(const AppleEvent *event,
- AppleEvent *reply, long handlerRefcon);
+ AppleEvent *reply, SRefCon handlerRefcon);
static OSErr PrintHandler(const AppleEvent *event,
- AppleEvent *reply, long handlerRefcon);
+ AppleEvent *reply, SRefCon handlerRefcon);
static OSErr ScriptHandler(const AppleEvent *event,
- AppleEvent *reply, long handlerRefcon);
+ AppleEvent *reply, SRefCon handlerRefcon);
static OSErr PrefsHandler(const AppleEvent *event,
- AppleEvent *reply, long handlerRefcon);
+ AppleEvent *reply, SRefCon handlerRefcon);
static int MissedAnyParameters(const AppleEvent *theEvent);
static int ReallyKillMe(Tcl_Event *eventPtr, int flags);
static OSStatus FSRefToDString(const FSRef *fsref, Tcl_DString *ds);
+
+#pragma mark TKApplication(TKHLEvents)
+
+@implementation TKApplication(TKHLEvents)
+
+- (void)terminate:(id)sender {
+ QuitHandler(NULL, NULL, (SRefCon) _eventInterp);
+}
+
+- (void)preferences:(id)sender {
+ PrefsHandler(NULL, NULL, (SRefCon) _eventInterp);
+}
+
+@end
+
+#pragma mark -
/*
*----------------------------------------------------------------------
@@ -83,32 +101,32 @@ TkMacOSXInitAppleEvents(
QuitHandlerUPP = NewAEEventHandlerUPP(QuitHandler);
ChkErr(AEInstallEventHandler, kCoreEventClass, kAEQuitApplication,
- QuitHandlerUPP, (long) interp, false);
+ QuitHandlerUPP, (SRefCon) interp, false);
OappHandlerUPP = NewAEEventHandlerUPP(OappHandler);
ChkErr(AEInstallEventHandler, kCoreEventClass, kAEOpenApplication,
- OappHandlerUPP, (long) interp, false);
+ OappHandlerUPP, (SRefCon) interp, false);
RappHandlerUPP = NewAEEventHandlerUPP(RappHandler);
ChkErr(AEInstallEventHandler, kCoreEventClass, kAEReopenApplication,
- RappHandlerUPP, (long) interp, false);
+ RappHandlerUPP, (SRefCon) interp, false);
OdocHandlerUPP = NewAEEventHandlerUPP(OdocHandler);
ChkErr(AEInstallEventHandler, kCoreEventClass, kAEOpenDocuments,
- OdocHandlerUPP, (long) interp, false);
+ OdocHandlerUPP, (SRefCon) interp, false);
PrintHandlerUPP = NewAEEventHandlerUPP(PrintHandler);
ChkErr(AEInstallEventHandler, kCoreEventClass, kAEPrintDocuments,
- PrintHandlerUPP, (long) interp, false);
+ PrintHandlerUPP, (SRefCon) interp, false);
PrefsHandlerUPP = NewAEEventHandlerUPP(PrefsHandler);
ChkErr(AEInstallEventHandler, kCoreEventClass, kAEShowPreferences,
- PrefsHandlerUPP, (long) interp, false);
+ PrefsHandlerUPP, (SRefCon) interp, false);
if (interp) {
ScriptHandlerUPP = NewAEEventHandlerUPP(ScriptHandler);
ChkErr(AEInstallEventHandler, kAEMiscStandards, kAEDoScript,
- ScriptHandlerUPP, (long) interp, false);
+ ScriptHandlerUPP, (SRefCon) interp, false);
}
}
}
@@ -131,9 +149,9 @@ TkMacOSXInitAppleEvents(
int
TkMacOSXDoHLEvent(
- EventRecord *theEvent)
+ void *theEvent)
{
- return AEProcessAppleEvent(theEvent);
+ return AEProcessAppleEvent((EventRecord *)theEvent);
}
/*
@@ -156,7 +174,7 @@ static OSErr
QuitHandler(
const AppleEvent *event,
AppleEvent *reply,
- long handlerRefcon)
+ SRefCon handlerRefcon)
{
Tcl_Interp *interp = (Tcl_Interp *) handlerRefcon;
KillEvent *eventPtr;
@@ -199,14 +217,15 @@ static OSErr
OappHandler(
const AppleEvent *event,
AppleEvent *reply,
- long handlerRefcon)
+ SRefCon handlerRefcon)
{
Tcl_CmdInfo dummy;
Tcl_Interp *interp = (Tcl_Interp *) handlerRefcon;
if (interp &&
Tcl_GetCommandInfo(interp, "::tk::mac::OpenApplication", &dummy)){
- if (Tcl_GlobalEval(interp, "::tk::mac::OpenApplication") != TCL_OK) {
+ int code = Tcl_GlobalEval(interp, "::tk::mac::OpenApplication");
+ if (code != TCL_OK) {
Tcl_BackgroundError(interp);
}
}
@@ -233,7 +252,7 @@ static OSErr
RappHandler(
const AppleEvent *event,
AppleEvent *reply,
- long handlerRefcon)
+ SRefCon handlerRefcon)
{
Tcl_CmdInfo dummy;
Tcl_Interp *interp = (Tcl_Interp *) handlerRefcon;
@@ -242,7 +261,8 @@ RappHandler(
if (interp && Tcl_GetCommandInfo(interp,
"::tk::mac::ReopenApplication", &dummy)) {
- if (Tcl_GlobalEval(interp, "::tk::mac::ReopenApplication") != TCL_OK){
+ int code = Tcl_GlobalEval(interp, "::tk::mac::ReopenApplication");
+ if (code != TCL_OK){
Tcl_BackgroundError(interp);
}
}
@@ -270,14 +290,15 @@ static OSErr
PrefsHandler(
const AppleEvent *event,
AppleEvent *reply,
- long handlerRefcon)
+ SRefCon handlerRefcon)
{
Tcl_CmdInfo dummy;
Tcl_Interp *interp = (Tcl_Interp *) handlerRefcon;
if (interp &&
Tcl_GetCommandInfo(interp, "::tk::mac::ShowPreferences", &dummy)){
- if (Tcl_GlobalEval(interp, "::tk::mac::ShowPreferences") != TCL_OK) {
+ int code = Tcl_GlobalEval(interp, "::tk::mac::ShowPreferences");
+ if (code != TCL_OK) {
Tcl_BackgroundError(interp);
}
}
@@ -304,7 +325,7 @@ static OSErr
OdocHandler(
const AppleEvent *event,
AppleEvent *reply,
- long handlerRefcon)
+ SRefCon handlerRefcon)
{
Tcl_Interp *interp = (Tcl_Interp *) handlerRefcon;
AEDescList fileSpecList;
@@ -315,6 +336,7 @@ OdocHandler(
AEKeyword keyword;
Tcl_DString command, pathName;
Tcl_CmdInfo dummy;
+ int code;
/*
* Don't bother if we don't have an interp or the open document procedure
@@ -365,8 +387,9 @@ OdocHandler(
* Now handle the event by evaluating a script.
*/
- if (Tcl_EvalEx(interp, Tcl_DStringValue(&command),
- Tcl_DStringLength(&command), TCL_EVAL_GLOBAL) != TCL_OK) {
+ code = Tcl_EvalEx(interp, Tcl_DStringValue(&command),
+ Tcl_DStringLength(&command), TCL_EVAL_GLOBAL);
+ if (code != TCL_OK) {
Tcl_BackgroundError(interp);
}
Tcl_DStringFree(&command);
@@ -393,7 +416,7 @@ static OSErr
PrintHandler(
const AppleEvent * event,
AppleEvent * reply,
- long handlerRefcon)
+ SRefCon handlerRefcon)
{
Tcl_Interp *interp = (Tcl_Interp *) handlerRefcon;
AEDescList fileSpecList;
@@ -404,6 +427,7 @@ PrintHandler(
AEKeyword keyword;
Tcl_DString command, pathName;
Tcl_CmdInfo dummy;
+ int code;
/*
* Don't bother if we don't have an interp or the print document procedure
@@ -449,8 +473,9 @@ PrintHandler(
* Now handle the event by evaluating a script.
*/
- if (Tcl_EvalEx(interp, Tcl_DStringValue(&command),
- Tcl_DStringLength(&command), TCL_EVAL_GLOBAL) != TCL_OK) {
+ code = Tcl_EvalEx(interp, Tcl_DStringValue(&command),
+ Tcl_DStringLength(&command), TCL_EVAL_GLOBAL);
+ if (code != TCL_OK) {
Tcl_BackgroundError(interp);
}
Tcl_DStringFree(&command);
@@ -477,7 +502,7 @@ static OSErr
ScriptHandler(
const AppleEvent *event,
AppleEvent *reply,
- long handlerRefcon)
+ SRefCon handlerRefcon)
{
OSStatus theErr;
AEDescList theDesc;
@@ -602,8 +627,9 @@ ReallyKillMe(
Tcl_Interp *interp = ((KillEvent *) eventPtr)->interp;
Tcl_CmdInfo dummy;
int quit = Tcl_GetCommandInfo(interp, "::tk::mac::Quit", &dummy);
+ int code = Tcl_GlobalEval(interp, quit ? "::tk::mac::Quit" : "exit");
- if (Tcl_GlobalEval(interp, quit ? "::tk::mac::Quit" : "exit") != TCL_OK) {
+ if (code != TCL_OK) {
/*
* Should be never reached...
*/
@@ -678,6 +704,7 @@ FSRefToDString(
* Local Variables:
* mode: c
* c-basic-offset: 4
- * fill-column: 78
+ * fill-column: 79
+ * coding: utf-8
* End:
*/
diff --git a/macosx/tkMacOSXInit.c b/macosx/tkMacOSXInit.c
index 47c8c18..2290809 100644
--- a/macosx/tkMacOSXInit.c
+++ b/macosx/tkMacOSXInit.c
@@ -5,11 +5,13 @@
* functions.
*
* Copyright (c) 1995-1997 Sun Microsystems, Inc.
- * Copyright 2001, Apple Computer, Inc.
- * Copyright (c) 2005-2008 Daniel A. Steffen <das@users.sourceforge.net>
+ * Copyright 2001-2009, Apple Inc.
+ * Copyright (c) 2005-2009 Daniel A. Steffen <das@users.sourceforge.net>
*
* See the file "license.terms" for information on usage and redistribution of
* this file, and for a DISCLAIMER OF ALL WARRANTIES.
+ *
+ * RCS: @(#) $Id$
*/
#include "tkMacOSXPrivate.h"
@@ -18,77 +20,162 @@
#include <sys/stat.h>
#include <sys/utsname.h>
-#include <mach-o/dyld.h>
-#include <mach-o/getsect.h>
+#include <dlfcn.h>
+#include <objc/objc-auto.h>
+
+static char tkLibPath[PATH_MAX + 1] = "";
/*
- * Define the following to 0 to not attempt to use an undocumented SPI to
- * notify the window server that an unbundled executable is a full GUI
- * application after loading Tk.
+ * If the App is in an App package, then we want to add the Scripts directory
+ * to the auto_path.
*/
-#ifndef MAC_OSX_TK_USE_CPS_SPI
-#define MAC_OSX_TK_USE_CPS_SPI 1
+static char scriptPath[PATH_MAX + 1] = "";
+
+int tkMacOSXGCEnabled = 0;
+long tkMacOSXMacOSXVersion = 0;
+
+#pragma mark TKApplication(TKInit)
+
+#if MAC_OS_X_VERSION_MIN_REQUIRED < 1060
+#define NSTextInputContextKeyboardSelectionDidChangeNotification @"NSTextInputContextKeyboardSelectionDidChangeNotification"
+static void keyboardChanged(CFNotificationCenterRef center, void *observer, CFStringRef name, const void *object, CFDictionaryRef userInfo) {
+ [[NSNotificationCenter defaultCenter] postNotificationName:NSTextInputContextKeyboardSelectionDidChangeNotification object:nil userInfo:nil];
+}
#endif
-/*
- * The following structures are used to map the script/language codes of a
- * font to the name that should be passed to Tcl_GetEncoding() to obtain the
- * encoding for that font. The set of numeric constants is fixed and defined
- * by Apple.
- */
+@interface TKApplication(TKKeyboard)
+- (void)keyboardChanged:(NSNotification *)notification;
+@end
+
+#if MAC_OS_X_VERSION_MAX_ALLOWED >= 1060
+#define TKApplication_NSApplicationDelegate <NSApplicationDelegate>
+#else
+#define TKApplication_NSApplicationDelegate
+#endif
+@interface TKApplication(TKWindowEvent) TKApplication_NSApplicationDelegate
+- (void)_setupWindowNotifications;
+@end
-typedef struct Map {
- CFStringEncoding numKey;
- const char *strKey;
-} Map;
-
-static Map scriptMap[] = {
- {smRoman, "macRoman"},
- {smJapanese, "macJapan"},
- {smTradChinese, "macChinese"},
- {smKorean, "macKorean"},
- {smArabic, "macArabic"},
- {smHebrew, "macHebrew"},
- {smGreek, "macGreek"},
- {smCyrillic, "macCyrillic"},
- {smRSymbol, "macRSymbol"},
- {smDevanagari, "macDevanagari"},
- {smGurmukhi, "macGurmukhi"},
- {smGujarati, "macGujarati"},
- {smOriya, "macOriya"},
- {smBengali, "macBengali"},
- {smTamil, "macTamil"},
- {smTelugu, "macTelugu"},
- {smKannada, "macKannada"},
- {smMalayalam, "macMalayalam"},
- {smSinhalese, "macSinhalese"},
- {smBurmese, "macBurmese"},
- {smKhmer, "macKhmer"},
- {smThai, "macThailand"},
- {smLaotian, "macLaos"},
- {smGeorgian, "macGeorgia"},
- {smArmenian, "macArmenia"},
- {smSimpChinese, "macSimpChinese"},
- {smTibetan, "macTIbet"},
- {smMongolian, "macMongolia"},
- {smGeez, "macEthiopia"},
- {smEastEurRoman, "macCentEuro"},
- {smVietnamese, "macVietnam"},
- {smExtArabic, "macSindhi"},
- {0, NULL}
-};
-
-Tcl_Encoding TkMacOSXCarbonEncoding = NULL;
+@interface TKApplication(TKScrlbr)
+- (void)_setupScrollBarNotifications;
+@end
+
+@interface TKApplication(TKMenus)
+- (void)_setupMenus;
+@end
+
+@implementation TKApplication
+@end
+
+@implementation TKApplication(TKInit)
+#ifdef TK_MAC_DEBUG_NOTIFICATIONS
+- (void)_postedNotification:(NSNotification *)notification {
+ TKLog(@"-[%@(%p) %s] %@", [self class], self, _cmd, notification);
+}
+#endif
+- (void)_setupApplicationNotifications {
+ NSNotificationCenter *nc = [NSNotificationCenter defaultCenter];
+#define observe(n, s) [nc addObserver:self selector:@selector(s) name:(n) object:nil]
+ observe(NSApplicationDidBecomeActiveNotification, applicationActivate:);
+ observe(NSApplicationDidResignActiveNotification, applicationDeactivate:);
+ observe(NSApplicationDidUnhideNotification, applicationShowHide:);
+ observe(NSApplicationDidHideNotification, applicationShowHide:);
+ observe(NSApplicationDidChangeScreenParametersNotification, displayChanged:);
+ observe(NSTextInputContextKeyboardSelectionDidChangeNotification, keyboardChanged:);
+#undef observe
+#if MAC_OS_X_VERSION_MIN_REQUIRED < 1060
+ CFNotificationCenterAddObserver(CFNotificationCenterGetDistributedCenter(), NULL, &keyboardChanged, kTISNotifySelectedKeyboardInputSourceChanged, NULL, CFNotificationSuspensionBehaviorCoalesce);
+#endif
+}
+- (void)_setupEventLoop {
+ _running = 1;
+ if (!_appFlags._hasBeenRun) {
+ _appFlags._hasBeenRun = YES;
+ [self finishLaunching];
+ }
+ [self setWindowsNeedUpdate:YES];
+}
+- (void)_setup:(Tcl_Interp *)interp {
+ _eventInterp = interp;
+ _defaultMainMenu = nil;
+ [self _setupMenus];
+ [self setDelegate:self];
+#ifdef TK_MAC_DEBUG_NOTIFICATIONS
+ [[NSNotificationCenter defaultCenter] addObserver:self
+ selector:@selector(_postedNotification:) name:nil object:nil];
+#endif
+ [self _setupWindowNotifications];
+ [self _setupScrollBarNotifications];
+ [self _setupApplicationNotifications];
+}
+- (NSString *)tkFrameworkImagePath:(NSString*)image {
+ NSString *path = nil;
+ if (tkLibPath[0] != '\0') {
+ path = [[NSBundle bundleWithPath:[[NSString stringWithUTF8String:
+ tkLibPath] stringByAppendingString:@"/../.."]]
+ pathForImageResource:image];
+ }
+ if (!path) {
+ const char *tk_library = Tcl_GetVar2(_eventInterp, "tk_library", NULL,
+ TCL_GLOBAL_ONLY);
+ if (tk_library) {
+ NSFileManager *fm = [NSFileManager defaultManager];
+ path = [[NSString stringWithUTF8String:tk_library]
+ stringByAppendingFormat:@"/%@", image];
+ if (![fm isReadableFileAtPath:path]) {
+ path = [[NSString stringWithUTF8String:tk_library]
+ stringByAppendingFormat:@"/../macosx/%@", image];
+ if (![fm isReadableFileAtPath:path]) {
+ path = nil;
+ }
+ }
+ }
+ }
+#ifdef TK_MAC_DEBUG
+ if (!path && getenv("TK_SRCROOT")) {
+ path = [[NSString stringWithUTF8String:getenv("TK_SRCROOT")]
+ stringByAppendingFormat:@"/macosx/%@", image];
+ if (![[NSFileManager defaultManager] isReadableFileAtPath:path]) {
+ path = nil;
+ }
+ }
+#endif
+ return path;
+}
+@end
+#pragma mark -
+
/*
- * If the App is in an App package, then we want to add the Scripts directory
- * to the auto_path.
+ *----------------------------------------------------------------------
+ *
+ * DoWindowActivate --
+ *
+ * Idle handler that sets the application icon to the generic Tk icon.
+ *
+ * Results:
+ * None.
+ *
+ * Side effects:
+ * None.
+ *
+ *----------------------------------------------------------------------
*/
-static char scriptPath[PATH_MAX + 1] = "";
-
-float tkMacOSXToolboxVersionNumber = 0;
+static void
+SetApplicationIcon(
+ ClientData clientData)
+{
+ NSString *path = [NSApp tkFrameworkImagePath:@"Tk.icns"];
+ if (path) {
+ NSImage *image = [[NSImage alloc] initWithContentsOfFile:path];
+ if (image) {
+ [NSApp setApplicationIconImage:image];
+ [image release];
+ }
+ }
+}
/*
*----------------------------------------------------------------------
@@ -112,11 +199,8 @@ int
TkpInit(
Tcl_Interp *interp)
{
- static char tkLibPath[PATH_MAX + 1];
static int initialized = 0;
- Tk_MacOSXSetupTkNotifier();
-
/*
* Since it is possible for TkInit to be called multiple times and we
* don't want to do the following initialization multiple times we protect
@@ -127,122 +211,56 @@ TkpInit(
int bundledExecutable = 0;
CFBundleRef bundleRef;
CFURLRef bundleUrl = NULL;
- CFStringEncoding encoding;
- const char *encodingStr = NULL;
- int i;
struct utsname name;
- long osVersion = 0;
+ struct stat st;
initialized = 1;
-
+
/*
* Initialize/check OS version variable for runtime checks.
*/
-
+
+#if MAC_OS_X_VERSION_MIN_REQUIRED < 1050
+# error Mac OS X 10.5 required
+#endif
+
if (!uname(&name)) {
- osVersion = strtol(name.release, NULL, 10) - 4;
+ tkMacOSXMacOSXVersion = (strtod(name.release, NULL) + 96) * 10;
}
- if (osVersion && osVersion < (MAC_OS_X_VERSION_MIN_REQUIRED-1000)/10) {
+ if (tkMacOSXMacOSXVersion &&
+ tkMacOSXMacOSXVersion/10 < MAC_OS_X_VERSION_MIN_REQUIRED/10) {
Tcl_Panic("Mac OS X 10.%d or later required !",
- (MAC_OS_X_VERSION_MIN_REQUIRED-1000)/10);
+ (MAC_OS_X_VERSION_MIN_REQUIRED/10)-100);
}
- TK_IF_MAC_OS_X_API (3, &kHIToolboxVersionNumber,
- tkMacOSXToolboxVersionNumber = kHIToolboxVersionNumber;
- ) TK_ELSE_MAC_OS_X (3,
- if (osVersion > 5) {
- tkMacOSXToolboxVersionNumber = INFINITY;
- } else if (osVersion >= 3) {
- static const float tbVersions[3] = {
- kHIToolboxVersionNumber10_3,
- kHIToolboxVersionNumber10_4,
- kHIToolboxVersionNumber10_5,
- };
-
- tkMacOSXToolboxVersionNumber = tbVersions[osVersion-3];
- }
- ) TK_ENDIF
+#ifdef TK_FRAMEWORK
/*
* When Tk is in a framework, force tcl_findLibrary to look in the
* framework scripts directory.
* FIXME: Should we come up with a more generic way of doing this?
*/
-#ifdef TK_FRAMEWORK
if (Tcl_MacOSXOpenVersionedBundleResources(interp,
- "com.tcltk.tklibrary", TK_FRAMEWORK_VERSION, 1, PATH_MAX,
- tkLibPath) != TCL_OK)
-#endif
- {
- /* Tk.framework not found, check if resource file is open */
- Handle rsrc = Get1NamedResource('CURS', "\phand");
- if (rsrc) {
- ReleaseResource(rsrc);
- } else {
-#ifndef __LP64__
- const struct mach_header *image;
- char *data = NULL;
- uint32_t size;
- int fd = -1;
- char fileName[L_tmpnam + 15];
- uint32_t i, n;
-
- /* Get resource data from __tk_rsrc section of tk dylib file*/
- n = _dyld_image_count();
- for (i = 0; i < n; i++) {
- image = _dyld_get_image_header(i);
- if (image) {
- data = getsectdatafromheader(image, SEG_TEXT,
- "__tk_rsrc", (void *) &size);
- if (data) {
- data += _dyld_get_image_vmaddr_slide(i);
- break;
- }
- }
- }
- while (data) {
- FSRef ref;
- SInt16 refNum;
-
- /*
- * Write resource data to temporary file and open it.
- */
-
- strcpy(fileName, P_tmpdir);
- if (fileName[strlen(fileName) - 1] != '/') {
- strcat(fileName, "/");
- }
- strcat(fileName, "tkMacOSX_XXXXXX");
- fd = mkstemp(fileName);
- if (fd == -1) {
- break;
- }
- fcntl(fd, F_SETFD, FD_CLOEXEC);
- if (write(fd, data, size) == -1) {
- break;
- }
- if(ChkErr(FSPathMakeRef, (unsigned char *) fileName, &ref,
- NULL) != noErr) {
- break;
- }
- ChkErr(FSOpenResourceFile, &ref, 0, NULL, fsRdPerm,
- &refNum);
- break;
- }
- if (fd != -1) {
- unlink(fileName);
- close(fd);
- }
-#endif /* __LP64__ */
- }
+ "com.tcltk.tklibrary", TK_FRAMEWORK_VERSION, 0, PATH_MAX,
+ tkLibPath) != TCL_OK) {
+ TkMacOSXDbgMsg("Tcl_MacOSXOpenVersionedBundleResources failed");
}
+#endif
- /*
- * If we are loaded into an executable that is not a bundled
- * application, the window server does not let us come to the
- * foreground. For such an executable, notify the window server that
- * we are now a full GUI application.
- */
+ static NSAutoreleasePool *pool = nil;
+ if (!pool) {
+ pool = [NSAutoreleasePool new];
+ }
+ tkMacOSXGCEnabled = ([NSGarbageCollector defaultCollector] != nil);
+ [[NSUserDefaults standardUserDefaults] registerDefaults:
+ [NSDictionary dictionaryWithObjectsAndKeys:
+ [NSNumber numberWithBool:YES],
+ @"_NSCanWrapButtonTitles",
+ [NSNumber numberWithInt:-1],
+ @"NSStringDrawingTypesetterBehavior",
+ nil]];
+ [TKApplication sharedApplication];
+ [NSApp _setup:interp];
/* Check whether we are a bundled executable: */
bundleRef = CFBundleGetMainBundle();
@@ -277,60 +295,34 @@ TkpInit(
CFRelease(bundleUrl);
}
- /*
- * If we are not a bundled executable, notify the window server that
- * we are a foregroundable app.
- */
-
if (!bundledExecutable) {
+ /*
+ * If we are loaded into an executable that is not a bundled
+ * application, the window server does not let us come to the
+ * foreground. For such an executable, notify the window server
+ * that we are now a full GUI application.
+ */
+
OSStatus err = procNotFound;
ProcessSerialNumber psn = { 0, kCurrentProcess };
- TK_IF_MAC_OS_X_API (3, TransformProcessType,
- err = ChkErr(TransformProcessType, &psn,
- kProcessTransformToForegroundApplication);
- ) TK_ENDIF
-#if MAC_OSX_TK_USE_CPS_SPI
- if (err != noErr) {
- /*
- * When building or running on 10.2 or when the above fails,
- * attempt to use undocumented CPS SPI to notify the window
- * server. Load the SPI symbol dynamically, so that we don't
- * break if it ever disappears or changes its name.
- */
-
- TkMacOSXInitNamedSymbol(CoreGraphics, OSStatus,
- CPSEnableForegroundOperation, ProcessSerialNumberPtr);
- if (CPSEnableForegroundOperation) {
- ChkErr(CPSEnableForegroundOperation, &psn);
- }
- }
-#endif /* MAC_OSX_TK_USE_CPS_SPI */
+ err = ChkErr(TransformProcessType, &psn,
+ kProcessTransformToForegroundApplication);
+
+ /*
+ * Set application icon to generic Tk icon, do it at idle time
+ * instead of now to ensure tk_library is setup.
+ */
+
+ Tcl_DoWhenIdle(SetApplicationIcon, NULL);
}
+ [NSApp _setupEventLoop];
TkMacOSXInitAppleEvents(interp);
- TkMacOSXInitCarbonEvents(interp);
- TkMacOSXInitMenus(interp);
TkMacOSXUseAntialiasedText(interp, -1);
TkMacOSXInitCGDrawing(interp, TRUE, 0);
- TkMacOSXInitKeyboard(interp);
-
- encoding = CFStringGetSystemEncoding();
-
- for (i = 0; scriptMap[i].strKey != NULL; i++) {
- if (scriptMap[i].numKey == encoding) {
- encodingStr = scriptMap[i].strKey;
- break;
- }
- }
- if (encodingStr == NULL) {
- encodingStr = "macRoman";
- }
-
- TkMacOSXCarbonEncoding = Tcl_GetEncoding(NULL, encodingStr);
- if (TkMacOSXCarbonEncoding == NULL) {
- TkMacOSXCarbonEncoding = Tcl_GetEncoding(NULL, NULL);
- }
+ [pool drain];
+ pool = [NSAutoreleasePool new];
/*
* FIXME: Close stdin & stdout for remote debugging otherwise we will
@@ -348,36 +340,36 @@ TkpInit(
* clicking Wish) then use the Tk based console interpreter.
*/
- if (!isatty(0)) {
- struct stat st;
+ if (getenv("TK_CONSOLE") ||
+ (!isatty(0) && (fstat(0, &st) ||
+ (S_ISCHR(st.st_mode) && st.st_blocks == 0)))) {
+ Tk_InitConsoleChannels(interp);
+ Tcl_RegisterChannel(interp, Tcl_GetStdChannel(TCL_STDIN));
+ Tcl_RegisterChannel(interp, Tcl_GetStdChannel(TCL_STDOUT));
+ Tcl_RegisterChannel(interp, Tcl_GetStdChannel(TCL_STDERR));
- if (fstat(0, &st) || (S_ISCHR(st.st_mode) && st.st_blocks == 0)) {
- Tk_InitConsoleChannels(interp);
- Tcl_RegisterChannel(interp, Tcl_GetStdChannel(TCL_STDIN));
- Tcl_RegisterChannel(interp, Tcl_GetStdChannel(TCL_STDOUT));
- Tcl_RegisterChannel(interp, Tcl_GetStdChannel(TCL_STDERR));
-
- /*
- * Only show the console if we don't have a startup script
- * and tcl_interactive hasn't been set already.
- */
+ /*
+ * Only show the console if we don't have a startup script
+ * and tcl_interactive hasn't been set already.
+ */
- if (Tcl_GetStartupScript(NULL) == NULL) {
- const char *intvar = Tcl_GetVar(interp,
- "tcl_interactive", TCL_GLOBAL_ONLY);
+ if (Tcl_GetStartupScript(NULL) == NULL) {
+ const char *intvar = Tcl_GetVar(interp,
+ "tcl_interactive", TCL_GLOBAL_ONLY);
- if (intvar == NULL) {
- Tcl_SetVar(interp, "tcl_interactive", "1",
- TCL_GLOBAL_ONLY);
- }
- }
- if (Tk_CreateConsoleWindow(interp) == TCL_ERROR) {
- return TCL_ERROR;
+ if (intvar == NULL) {
+ Tcl_SetVar(interp, "tcl_interactive", "1",
+ TCL_GLOBAL_ONLY);
}
}
+ if (Tk_CreateConsoleWindow(interp) == TCL_ERROR) {
+ return TCL_ERROR;
+ }
}
}
+ Tk_MacOSXSetupTkNotifier();
+
if (tkLibPath[0] != '\0') {
Tcl_SetVar(interp, "tk_library", tkLibPath, TCL_GLOBAL_ONLY);
}
@@ -386,6 +378,11 @@ TkpInit(
Tcl_SetVar(interp, "auto_path", scriptPath,
TCL_GLOBAL_ONLY|TCL_LIST_ELEMENT|TCL_APPEND_VALUE);
}
+
+ Tcl_CreateObjCommand(interp, "::tk::mac::standardAboutPanel",
+ TkMacOSXStandardAboutPanelObjCmd, NULL, NULL);
+ Tcl_CreateObjCommand(interp, "::tk::mac::iconBitmap",
+ TkMacOSXIconBitmapObjCmd, NULL, NULL);
return TCL_OK;
}
@@ -446,8 +443,8 @@ TkpGetAppName(
void
TkpDisplayWarning(
- CONST char *msg, /* Message to be displayed. */
- CONST char *title) /* Title of warning. */
+ const char *msg, /* Message to be displayed. */
+ const char *title) /* Title of warning. */
{
Tcl_Channel errChannel = Tcl_GetStdChannel(TCL_STDERR);
@@ -517,8 +514,7 @@ TkMacOSXDefaultStartupScript(void)
*
* Dynamically acquire address of a named symbol from a loaded dynamic
* library, so that we can use API that may not be available on all OS
- * versions. If module is non-NULL and not the empty string, use twolevel
- * namespace lookup.
+ * versions.
*
* Results:
* Address of given symbol or NULL if unavailable.
@@ -534,22 +530,11 @@ TkMacOSXGetNamedSymbol(
const char* module,
const char* symbol)
{
- NSSymbol nsSymbol = NULL;
-
- if (module && *module) {
- if (NSIsSymbolNameDefinedWithHint(symbol, module)) {
- nsSymbol = NSLookupAndBindSymbolWithHint(symbol, module);
- }
- } else {
- if (NSIsSymbolNameDefined(symbol)) {
- nsSymbol = NSLookupAndBindSymbol(symbol);
- }
- }
-
- if (!nsSymbol) {
- return NULL;
+ void *addr = dlsym(RTLD_NEXT, symbol);
+ if (!addr) {
+ (void) dlerror(); /* Clear dlfcn error state */
}
- return NSAddressOfSymbol(nsSymbol);
+ return addr;
}
/*
diff --git a/macosx/tkMacOSXInt.h b/macosx/tkMacOSXInt.h
index da9bfab..eb34c51 100644
--- a/macosx/tkMacOSXInt.h
+++ b/macosx/tkMacOSXInt.h
@@ -4,11 +4,13 @@
* Declarations of Macintosh specific shared variables and procedures.
*
* Copyright (c) 1995-1997 Sun Microsystems, Inc.
- * Copyright 2001, Apple Computer, Inc.
- * Copyright (c) 2005-2007 Daniel A. Steffen <das@users.sourceforge.net>
+ * Copyright 2001-2009, Apple Inc.
+ * Copyright (c) 2005-2009 Daniel A. Steffen <das@users.sourceforge.net>
*
* See the file "license.terms" for information on usage and redistribution
* of this file, and for a DISCLAIMER OF ALL WARRANTIES.
+ *
+ * RCS: @(#) $Id$
*/
#ifndef _TKMACINT
@@ -18,10 +20,6 @@
#include "tkInt.h"
#endif
-#define TextStyle MacTextStyle
-#include <Carbon/Carbon.h>
-#undef TextStyle
-
/*
* Include platform specific public interfaces.
*/
@@ -30,17 +28,46 @@
#include "tkMacOSX.h"
#endif
+/*
+ * Define compatibility platform types used in the structures below so that
+ * this header can be included without pulling in the platform headers.
+ */
+
+#ifndef _TKMACPRIV
+# ifndef CGGEOMETRY_H_
+# ifndef CGFLOAT_DEFINED
+# if __LP64__
+# define CGFloat double
+# else
+# define CGFloat float
+# endif
+# endif
+# define CGSize struct {CGFloat width; CGFloat height;}
+# endif
+# ifndef CGCONTEXT_H_
+# define CGContextRef void *
+# endif
+# ifndef CGCOLOR_H_
+# define CGColorRef void *
+# endif
+# ifndef __HISHAPE__
+# define HIShapeRef void *
+# endif
+# ifndef _APPKITDEFINES_H
+# define NSView void *
+# endif
+#endif
+
struct TkWindowPrivate {
TkWindow *winPtr; /* Ptr to tk window or NULL if Pixmap */
- CGrafPtr grafPtr;
+ NSView *view;
CGContextRef context;
- ControlRef rootControl;
int xOff; /* X offset from toplevel window */
int yOff; /* Y offset from toplevel window */
CGSize size;
HIShapeRef visRgn; /* Visible region of window */
HIShapeRef aboveVisRgn; /* Visible region of window & its children */
- CGRect drawRect; /* Clipped drawing rect */
+ HIShapeRef drawRgn; /* Clipped drawing region */
int referenceCount; /* Don't delete toplevel until children are
* gone. */
struct TkWindowPrivate *toplevel;
@@ -50,18 +77,6 @@ struct TkWindowPrivate {
typedef struct TkWindowPrivate MacDrawable;
/*
- * This list is used to keep track of toplevel windows that have a Mac
- * window attached. This is useful for several things, not the least
- * of which is maintaining floating windows.
- */
-
-typedef struct TkMacOSXWindowList {
- struct TkMacOSXWindowList *nextPtr;
- /* The next window in the list. */
- TkWindow *winPtr; /* This window */
-} TkMacOSXWindowList;
-
-/*
* Defines use for the flags field of the MacDrawable data structure.
*/
@@ -69,7 +84,7 @@ typedef struct TkMacOSXWindowList {
#define TK_CLIP_INVALID 0x02
#define TK_HOST_EXISTS 0x04
#define TK_DRAWN_UNDER_MENU 0x08
-#define TK_CLIPPED_DRAW 0x10
+#define TK_FOCUSED_VIEW 0x10
#define TK_IS_PIXMAP 0x20
#define TK_IS_BW_PIXMAP 0x40
@@ -101,6 +116,46 @@ typedef struct {
MODULE_SCOPE TkMacOSXEmbedHandler *tkMacOSXEmbedHandler;
/*
+ * 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.
+ */
+
+#ifndef _TKMACPRIV
+# ifndef CGGEOMETRY_H_
+# ifndef CGFLOAT_DEFINED
+# undef CGFloat
+# endif
+# undef CGSize
+# endif
+# ifndef CGCONTEXT_H_
+# undef CGContextRef
+# endif
+# ifndef CGCOLOR_H_
+# undef CGColorRef
+# endif
+# ifndef __HISHAPE__
+# undef HIShapeRef
+# endif
+# ifndef _APPKITDEFINES_H
+# undef NSView
+# endif
+#endif
+
+/*
* Defines used for TkMacOSXInvalidateWindow
*/
@@ -115,12 +170,13 @@ MODULE_SCOPE TkMacOSXEmbedHandler *tkMacOSXEmbedHandler;
(((TkWindow *) (tkwin))->privatePtr->toplevel->flags & TK_HOST_EXISTS)
/*
- * Defines use for the flags argument to TkGenWMConfigureEvent.
+ * Defines used for the flags argument to TkGenWMConfigureEvent.
*/
#define TK_LOCATION_CHANGED 1
#define TK_SIZE_CHANGED 2
#define TK_BOTH_CHANGED 3
+#define TK_MACOSX_HANDLE_EVENT_IMMEDIATELY 1024
/*
* Defines for tkTextDisp.c
@@ -129,32 +185,6 @@ MODULE_SCOPE TkMacOSXEmbedHandler *tkMacOSXEmbedHandler;
#define TK_LAYOUT_WITH_BASE_CHUNKS 1
#define TK_DRAW_IN_CONTEXT 1
-#if !TK_DRAW_IN_CONTEXT
-MODULE_SCOPE int TkMacOSXCompareColors(unsigned long c1, unsigned long c2);
-#endif
-
-/*
- * Globals shared among TkAqua.
- */
-
-MODULE_SCOPE MenuHandle tkCurrentAppleMenu; /* Handle to current Apple Menu */
-MODULE_SCOPE MenuHandle tkAppleMenu; /* Handle to default Apple Menu */
-MODULE_SCOPE MenuHandle tkFileMenu; /* Handles to menus */
-MODULE_SCOPE MenuHandle tkEditMenu; /* Handles to menus */
-MODULE_SCOPE int tkPictureIsOpen; /* If this is 1, we are drawing to a
- * picture The clipping should then be
- * done relative to the bounds of the
- * picture rather than the window. As
- * of OS X.0.4, something is seriously
- * wrong: The clipping bounds only
- * seem to work if the top,left values
- * are 0,0 The destination rectangle
- * for CopyBits should also have
- * top,left values of 0,0
- */
-MODULE_SCOPE TkMacOSXWindowList *tkMacOSXWindowListPtr; /* List of toplevels */
-MODULE_SCOPE Tcl_Encoding TkMacOSXCarbonEncoding;
-
/*
* Prototypes of internal procs not in the stubs table.
*/
diff --git a/macosx/tkMacOSXKeyEvent.c b/macosx/tkMacOSXKeyEvent.c
index e599fe3..1d24960 100644
--- a/macosx/tkMacOSXKeyEvent.c
+++ b/macosx/tkMacOSXKeyEvent.c
@@ -1,58 +1,15 @@
/*
* tkMacOSXKeyEvent.c --
*
- * This file implements functions that decode & handle keyboard events
- * on MacOS X.
+ * This file implements functions that decode & handle keyboard events on
+ * MacOS X.
*
- * Copyright 2001, Apple Computer, Inc.
- * Copyright (c) 2006-2007 Daniel A. Steffen <das@users.sourceforge.net>
+ * Copyright 2001-2009, Apple Inc.
+ * Copyright (c) 2006-2009 Daniel A. Steffen <das@users.sourceforge.net>
+ * Copyright (c) 2012 Adrian Robert.
*
* See the file "license.terms" for information on usage and redistribution of
* this file, and for a DISCLAIMER OF ALL WARRANTIES.
- *
- * The following terms apply to all files originating from Apple
- * Computer, Inc. ("Apple") and associated with the software
- * unless explicitly disclaimed in individual files.
- *
- *
- * Apple hereby grants permission to use, copy, modify,
- * distribute, and license this software and its documentation
- * for any purpose, provided that existing copyright notices are
- * retained in all copies and that this notice is included
- * verbatim in any distributions. No written agreement, license,
- * or royalty fee is required for any of the authorized
- * uses. Modifications to this software may be copyrighted by
- * their authors and need not follow the licensing terms
- * described here, provided that the new terms are clearly
- * indicated on the first page of each file where they apply.
- *
- *
- * IN NO EVENT SHALL APPLE, THE AUTHORS OR DISTRIBUTORS OF THE
- * SOFTWARE BE LIABLE TO ANY PARTY FOR DIRECT, INDIRECT, SPECIAL,
- * INCIDENTAL, OR CONSEQUENTIAL DAMAGES ARISING OUT OF THE USE OF
- * THIS SOFTWARE, ITS DOCUMENTATION, OR ANY DERIVATIVES THEREOF,
- * EVEN IF APPLE OR THE AUTHORS HAVE BEEN ADVISED OF THE
- * POSSIBILITY OF SUCH DAMAGE. APPLE, THE AUTHORS AND
- * DISTRIBUTORS SPECIFICALLY DISCLAIM ANY WARRANTIES, INCLUDING,
- * BUT NOT LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY,
- * FITNESS FOR A PARTICULAR PURPOSE, AND NON-INFRINGEMENT. THIS
- * SOFTWARE IS PROVIDED ON AN "AS IS" BASIS, AND APPLE,THE
- * AUTHORS AND DISTRIBUTORS HAVE NO OBLIGATION TO PROVIDE
- * MAINTENANCE, SUPPORT, UPDATES, ENHANCEMENTS, OR MODIFICATIONS.
- *
- * GOVERNMENT USE: If you are acquiring this software on behalf
- * of the U.S. government, the Government shall have only
- * "Restricted Rights" in the software and related documentation
- * as defined in the Federal Acquisition Regulations (FARs) in
- * Clause 52.227.19 (c) (2). If you are acquiring the software
- * on behalf of the Department of Defense, the software shall be
- * classified as "Commercial Computer Software" and the
- * Government shall have only "Restricted Rights" as defined in
- * Clause 252.227-7013 (c) (1) of DFARs. Notwithstanding the
- * foregoing, the authors grant the U.S. Government and others
- * acting in its behalf permission to use and distribute the
- * software in accordance with the terms specified in this
- * license.
*/
#include "tkMacOSXPrivate.h"
@@ -63,954 +20,423 @@
#define TK_MAC_DEBUG_KEYBOARD
#endif
*/
+#define NS_KEYLOG 0
-typedef struct {
- WindowRef whichWindow;
- int global_x, global_y;
- int local_x, local_y;
- unsigned int state;
- UInt32 keyCode;
- UInt32 keyModifiers;
- UInt32 message;
- unsigned char ch;
-} KeyEventData;
static Tk_Window grabWinPtr = NULL;
/* Current grab window, NULL if no grab. */
static Tk_Window keyboardGrabWinPtr = NULL;
/* Current keyboard grab window. */
-static UInt32 deadKeyStateUp = 0;
- /* The deadkey state for the current sequence
- * of keyup events or 0 if not in a deadkey
- * sequence */
-static UInt32 deadKeyStateDown = 0;
- /* Ditto for keydown */
-
-/*
- * Declarations for functions used only in this file.
- */
-
-static int InitKeyData(KeyEventData *keyEventDataPtr);
-static int InitKeyEvent(XEvent *eventPtr, KeyEventData *e, UInt32 savedKeyCode,
- UInt32 savedModifiers);
-static int GenerateKeyEvent(UInt32 eKind, KeyEventData *e, UInt32 savedKeyCode,
- UInt32 savedModifiers, const UniChar *chars, int numChars);
-static int GetKeyboardLayout(Ptr *resourcePtr, TextEncoding *encodingPtr);
-static TextEncoding GetKCHREncoding(ScriptCode script, SInt32 layoutid);
-static int KeycodeToUnicodeViaUnicodeResource(UniChar *uniChars, int maxChars,
- Ptr uchr, EventKind eKind, UInt32 keycode, UInt32 modifiers,
- UInt32 *deadKeyStatePtr);
-static int KeycodeToUnicodeViaKCHRResource(UniChar *uniChars, int maxChars,
- Ptr kchr, TextEncoding encoding, EventKind eKind, UInt32 keycode,
- UInt32 modifiers, UInt32 *deadKeyStatePtr);
-
-
-/*
- *----------------------------------------------------------------------
- *
- * TkMacOSXProcessKeyboardEvent --
- *
- * This routine processes the event in eventPtr, and
- * generates the appropriate Tk events from it.
- *
- * Results:
- * True if event(s) are generated - false otherwise.
- *
- * Side effects:
- * Additional events may be place on the Tk event queue.
- *
- *----------------------------------------------------------------------
- */
-
-MODULE_SCOPE int
-TkMacOSXProcessKeyboardEvent(
- TkMacOSXEvent *eventPtr,
- MacEventStatus *statusPtr)
-{
- static UInt32 savedKeyCode = 0;
- static UInt32 savedModifiers = 0;
- static UniChar savedChar = 0;
- OSStatus err;
- KeyEventData keyEventData;
- MenuRef menuRef;
- MenuItemIndex menuItemIndex;
- int eventGenerated;
- UniChar uniChars[5]; /* make this larger, if needed */
- UInt32 uniCharsLen = 0;
-
- if (!InitKeyData(&keyEventData)) {
- statusPtr->err = 1;
- return false;
- }
-
- /*
- * Because of the way that Tk operates, we can't in general funnel menu
- * accelerators through IsMenuKeyEvent. Tk treats accelerators as mere
- * decoration, and the user has to install bindings to get them to fire.
- *
- * However, the only way to trigger the Hide & Hide Others functions
- * is by invoking the Menu command for Hide. So there is no nice way to
- * provide a Tk command to hide the app which would be available for a
- * binding. So I am going to hijack Command-H and Command-Shift-H
- * here, and run the menu commands. Since the HI Guidelines explicitly
- * reserve these for Hide, this isn't such a bad thing. Also, if you do
- * rebind Command-H to another menu item, Hide will lose its binding.
- *
- * Note that I don't really do anything at this point,
- * I just mark stopProcessing as 0 and return, and then the
- * RecieveAndProcessEvent code will dispatch the event to the default
- * handler.
- */
-
- if ((eventPtr->eKind == kEventRawKeyDown
- || eventPtr->eKind == kEventRawKeyRepeat)
- && IsMenuKeyEvent(tkCurrentAppleMenu, eventPtr->eventRef,
- kMenuEventQueryOnly, &menuRef, &menuItemIndex)) {
- MenuCommand menuCmd;
-
- GetMenuItemCommandID (menuRef, menuItemIndex, &menuCmd);
- switch (menuCmd) {
- case kHICommandHide:
- case kHICommandHideOthers:
- case kHICommandShowAll:
- case kHICommandPreferences:
- case kHICommandQuit:
- statusPtr->stopProcessing = 0;
-
- /*
- * TODO: may not be on event on queue.
- */
-
- return 0;
- break;
- default:
- break;
- }
- }
-
- err = ChkErr(GetEventParameter, eventPtr->eventRef,
- kEventParamKeyMacCharCodes, typeChar, NULL,
- sizeof(keyEventData.ch), NULL, &keyEventData.ch);
- if (err != noErr) {
- statusPtr->err = 1;
- return false;
- }
- err = ChkErr(GetEventParameter, eventPtr->eventRef, kEventParamKeyCode,
- typeUInt32, NULL, sizeof(keyEventData.keyCode), NULL,
- &keyEventData.keyCode);
- if (err != noErr) {
- statusPtr->err = 1;
- return false;
- }
- err = ChkErr(GetEventParameter, eventPtr->eventRef,
- kEventParamKeyModifiers, typeUInt32, NULL,
- sizeof(keyEventData.keyModifiers), NULL,
- &keyEventData.keyModifiers);
- if (err != noErr) {
- statusPtr->err = 1;
- return false;
- }
-
- switch (eventPtr->eKind) {
- case kEventRawKeyUp:
- case kEventRawKeyDown:
- case kEventRawKeyRepeat: {
- UInt32 *deadKeyStatePtr;
-
- if (kEventRawKeyDown == eventPtr->eKind) {
- deadKeyStatePtr = &deadKeyStateDown;
- } else {
- deadKeyStatePtr = &deadKeyStateUp;
- }
+static NSModalSession modalSession = NULL;
- uniCharsLen = TkMacOSXKeycodeToUnicode(uniChars,
- sizeof(uniChars)/sizeof(*uniChars), eventPtr->eKind,
- keyEventData.keyCode, keyEventData.keyModifiers,
- deadKeyStatePtr);
- break;
- }
- }
-
- if (kEventRawKeyUp == eventPtr->eKind) {
- /*
- * For some reason the deadkey processing for KeyUp doesn't work
- * sometimes, so we fudge and use the last detected KeyDown.
- */
-
- if ((0 == uniCharsLen) && (0 != savedChar)) {
- uniChars[0] = savedChar;
- uniCharsLen = 1;
- }
+static BOOL processingCompose = NO;
+static BOOL finishedCompose = NO;
- /*
- * Suppress keyup events while we have a deadkey sequence on keydown.
- * We still *do* want to collect deadkey state in this situation if
- * the system provides it, that's why we do this only after
- * TkMacOSXKeycodeToUnicode().
- */
+static int caret_x = 0, caret_y = 0, caret_height = 0;
- if (0 != deadKeyStateDown) {
- uniCharsLen = 0;
- }
- }
+static void setupXEvent(XEvent *xEvent, NSWindow *w, unsigned int state);
+static unsigned isFunctionKey(unsigned int code);
- keyEventData.message = keyEventData.ch|(keyEventData.keyCode << 8);
- eventGenerated = GenerateKeyEvent(eventPtr->eKind, &keyEventData,
- savedKeyCode, savedModifiers, uniChars, uniCharsLen);
+#pragma mark TKApplication(TKKeyEvent)
- savedModifiers = keyEventData.keyModifiers;
+@implementation TKApplication(TKKeyEvent)
- if ((kEventRawKeyDown == eventPtr->eKind) && (uniCharsLen > 0)) {
- savedChar = uniChars[0];
- } else {
- savedChar = 0;
- }
-
- statusPtr->stopProcessing = 1;
-
- if (eventGenerated == 0) {
- savedKeyCode = keyEventData.message;
- return false;
- } else if (eventGenerated == -1) {
- savedKeyCode = 0;
- statusPtr->stopProcessing = 0;
- return false;
- } else {
- savedKeyCode = 0;
- return true;
- }
-}
-
-/*
- *----------------------------------------------------------------------
- *
- * GenerateKeyEvent --
- *
- * Given Macintosh keyUp, keyDown & autoKey events (in their "raw"
- * form) and a list of unicode characters this function generates the
- * appropriate X key events.
- *
- * Parameter eKind is a raw keyboard event. e contains the data sent
- * with the event. savedKeyCode and savedModifiers contain the values
- * from the last event that came before (see
- * TkMacOSXProcessKeyboardEvent()). chars/numChars has the Unicode
- * characters for which we want to create events.
- *
- * Results:
- * 1 if an event was generated, -1 for any error.
- *
- * Side effects:
- * Additional events may be place on the Tk event queue.
- *
- *----------------------------------------------------------------------
- */
-
-static int
-GenerateKeyEvent(
- UInt32 eKind,
- KeyEventData * e,
- UInt32 savedKeyCode,
- UInt32 savedModifiers,
- const UniChar * chars,
- int numChars)
+- (NSEvent *) tkProcessKeyEvent: (NSEvent *) theEvent
{
- XEvent event;
- int i;
-
- if (-1 == InitKeyEvent(&event, e, savedKeyCode, savedModifiers)) {
- return -1;
- }
-
- if (kEventRawKeyModifiersChanged == eKind) {
- if (savedModifiers > e->keyModifiers) {
- event.xany.type = KeyRelease;
- } else {
- event.xany.type = KeyPress;
- }
-
- /*
- * Use special '-1' to signify a special keycode to our
- * platform specific code in tkMacOSXKeyboard.c. This is
- * rather like what happens on Windows.
- */
-
- event.xany.send_event = -1;
-
- /*
- * Set keycode (which was zero) to the changed modifier
- */
-
- event.xkey.keycode = (e->keyModifiers ^ savedModifiers);
- Tk_QueueWindowEvent(&event, TCL_QUEUE_TAIL);
-
- } else {
- for (i = 0; i < numChars; ++i) {
- /*
- * Encode one char in the trans_chars array that was already
- * introduced for MS Windows. Don't encode the string, if it is
- * a control character but was not generated with a real control
- * modifier. Such control characters get generated by KeyTrans()
- * for special keys, but we rather want to identify those by
- * their KeySyms.
- */
-
- event.xkey.trans_chars[0] = 0;
- if ((controlKey & e->keyModifiers) || (chars[i] >= ' ')) {
- int done;
- done = Tcl_UniCharToUtf(chars[i],event.xkey.trans_chars);
- event.xkey.trans_chars[done] = 0;
- }
+#ifdef TK_MAC_DEBUG_EVENTS
+ TKLog(@"-[%@(%p) %s] %@", [self class], self, _cmd, theEvent);
+#endif
+ NSWindow* w;
+ NSEventType type = [theEvent type];
+ NSUInteger modifiers, len = 0;
+ BOOL repeat = NO;
+ unsigned short keyCode;
+ NSString *characters = nil, *charactersIgnoringModifiers = nil;
+ static NSUInteger savedModifiers = 0;
+ static NSMutableArray *nsEvArray;
+
+ if (nsEvArray == nil)
+ {
+ nsEvArray = [[NSMutableArray alloc] initWithCapacity: 1];
+ processingCompose = NO;
+ }
+
+ switch (type) {
+ case NSKeyUp:
+ if (finishedCompose)
+ {
+ // if we were composing, swallow the last release since we already sent
+ finishedCompose = NO;
+ return theEvent;
+ }
+ case NSKeyDown:
+ repeat = [theEvent isARepeat];
+ characters = [theEvent characters];
+ charactersIgnoringModifiers = [theEvent charactersIgnoringModifiers];
+ len = [charactersIgnoringModifiers length];
+ case NSFlagsChanged:
+ modifiers = [theEvent modifierFlags];
+ keyCode = [theEvent keyCode];
+ w = [self windowWithWindowNumber:[theEvent windowNumber]];
+#if defined(TK_MAC_DEBUG_EVENTS) || NS_KEYLOG == 1
+ NSLog(@"-[%@(%p) %s] r=%d mods=%u '%@' '%@' code=%u c=%d %@ %d", [self class], self, _cmd, repeat, modifiers, characters, charactersIgnoringModifiers, keyCode,([charactersIgnoringModifiers length] == 0) ? 0 : [charactersIgnoringModifiers characterAtIndex: 0], w, type);
+#endif
+ break;
- switch(eKind) {
- case kEventRawKeyDown:
- event.xany.type = KeyPress;
- Tk_QueueWindowEvent(&event, TCL_QUEUE_TAIL);
- break;
- case kEventRawKeyUp:
- event.xany.type = KeyRelease;
- Tk_QueueWindowEvent(&event, TCL_QUEUE_TAIL);
- break;
- case kEventRawKeyRepeat:
- event.xany.type = KeyRelease;
- Tk_QueueWindowEvent(&event, TCL_QUEUE_TAIL);
- event.xany.type = KeyPress;
- Tk_QueueWindowEvent(&event, TCL_QUEUE_TAIL);
- break;
- default:
- TkMacOSXDbgMsg("Invalid parameter eKind %ld", eKind);
- return -1;
- }
- }
+ default:
+ return theEvent;
}
- return 1;
+ if (!processingCompose) {
+ unsigned int state = 0;
+
+ if (modifiers & NSAlphaShiftKeyMask) {
+ state |= LockMask;
+ }
+ if (modifiers & NSShiftKeyMask) {
+ state |= ShiftMask;
+ }
+ if (modifiers & NSControlKeyMask) {
+ state |= ControlMask;
+ }
+ if (modifiers & NSCommandKeyMask) {
+ state |= Mod1Mask; /* command key */
+ }
+ if (modifiers & NSAlternateKeyMask) {
+ state |= Mod2Mask; /* option key */
+ }
+ if (modifiers & NSNumericPadKeyMask) {
+ state |= Mod3Mask;
+ }
+ if (modifiers & NSFunctionKeyMask) {
+ state |= Mod4Mask;
+ }
+
+ /*
+ * The focus must be in the FrontWindow on the Macintosh. We then query Tk
+ * to determine the exact Tk window that owns the focus.
+ */
+
+ TkWindow *winPtr = TkMacOSXGetTkWindow(w);
+ Tk_Window tkwin = (Tk_Window) winPtr;
+
+ if (!tkwin) {
+ TkMacOSXDbgMsg("tkwin == NULL");
+ return theEvent;
+ }
+ tkwin = (Tk_Window) winPtr->dispPtr->focusPtr;
+ if (!tkwin) {
+ TkMacOSXDbgMsg("tkwin == NULL");
+ return theEvent;
+ }
+
+ /*
+ * If it's a function key, or we have modifiers other than Shift or Alt,
+ * pass it straight to Tk. Otherwise we'll send for input processing.
+ */
+ int code = (len == 0) ?
+ 0 : [charactersIgnoringModifiers characterAtIndex: 0];
+ if (type != NSKeyDown || isFunctionKey(code)
+ || (len > 0 && state & (ControlMask | Mod1Mask | Mod3Mask | Mod4Mask))) {
+
+ XEvent xEvent;
+ setupXEvent(&xEvent, w, state);
+
+ if (type == NSFlagsChanged) {
+ if (savedModifiers > modifiers) {
+ xEvent.xany.type = KeyRelease;
+ } else {
+ xEvent.xany.type = KeyPress;
+ }
+
+ /*
+ * Use special '-1' to signify a special keycode to our platform
+ * specific code in tkMacOSXKeyboard.c. This is rather like what
+ * happens on Windows.
+ */
+
+ xEvent.xany.send_event = -1;
+
+ /*
+ * Set keycode (which was zero) to the changed modifier
+ */
+
+ xEvent.xkey.keycode = (modifiers ^ savedModifiers);
+ } else {
+ if (type == NSKeyUp || repeat) {
+ xEvent.xany.type = KeyRelease;
+ } else {
+ xEvent.xany.type = KeyPress;
+ }
+
+ /* For command key, take input manager's word so things
+ like dvorak / qwerty layout work. */
+ if ((modifiers & NSCommandKeyMask) == NSCommandKeyMask
+ && (modifiers & NSAlternateKeyMask) != NSAlternateKeyMask
+ && len > 0 && !isFunctionKey(code)) {
+ // head off keycode-based translation in tkMacOSXKeyboard.c
+ xEvent.xkey.nbytes = [characters length]; //len
+ }
+
+ if ([characters length] > 0) {
+ xEvent.xkey.keycode =
+ (keyCode << 16) | (UInt16) [characters characterAtIndex:0];
+ if (![characters getCString:xEvent.xkey.trans_chars
+ maxLength:XMaxTransChars encoding:NSUTF8StringEncoding]) {
+ /* prevent SF bug 2907388 (crash on some composite chars) */
+ //PENDING: we might not need this anymore
+ TkMacOSXDbgMsg("characters too long");
+ return theEvent;
+ }
+ }
+
+ if (repeat) {
+ Tk_QueueWindowEvent(&xEvent, TCL_QUEUE_TAIL);
+ xEvent.xany.type = KeyPress;
+ xEvent.xany.serial = LastKnownRequestProcessed(Tk_Display(tkwin));
+ }
+ }
+ Tk_QueueWindowEvent(&xEvent, TCL_QUEUE_TAIL);
+ savedModifiers = modifiers;
+ return theEvent;
+ } /* if send straight to TK */
+
+ } /* if not processing compose */
+
+ if (type == NSKeyDown) {
+ if (NS_KEYLOG)
+ fprintf (stderr, "keyDown: %s compose sequence.\n",
+ processingCompose == YES ? "Continue" : "Begin");
+ processingCompose = YES;
+ [nsEvArray addObject: theEvent];
+ [[w contentView] interpretKeyEvents: nsEvArray];
+ [nsEvArray removeObject: theEvent];
+ }
+
+ savedModifiers = modifiers;
+
+ return theEvent;
}
-
-/*
- *----------------------------------------------------------------------
- *
- * InitKeyData --
- *
- * This routine initializes a KeyEventData structure by asking the OS
- * and Tk for all the global information needed here.
- *
- * Results:
- * True if the current front window can be found in Tk data structures
- * - false otherwise.
- *
- * Side Effects:
- * None
- *
- *----------------------------------------------------------------------
- */
-
-static int
-InitKeyData(
- KeyEventData *keyEventDataPtr)
-{
- memset(keyEventDataPtr, 0, sizeof(*keyEventDataPtr));
+@end
- keyEventDataPtr->whichWindow = ActiveNonFloatingWindow();
- if (keyEventDataPtr->whichWindow == NULL) {
- return false;
- }
- XQueryPointer(NULL, None, NULL, NULL, &keyEventDataPtr->global_x,
- &keyEventDataPtr->global_y, &keyEventDataPtr->local_x,
- &keyEventDataPtr->local_y, &keyEventDataPtr->state);
-
- return true;
-}
-/*
- *----------------------------------------------------------------------
- *
- * InitKeyEvent --
- *
- * Initialize an XEvent structure by asking Tk for global information.
- * Also uses a KeyEventData structure and other current state.
- *
- * Results:
- * 1 on success, -1 for any error.
- *
- * Side effects:
- * Additional events may be place on the Tk event queue.
- *
- *----------------------------------------------------------------------
- */
-/*
- * We have a general problem here. How do we handle 'Option-char'
- * keypresses? The problem is that we might want to bind to some of these
- * (e.g. Cmd-Opt-d is 'uncomment' in Alpha). OTOH Option-d actually produces
- * a real character on MacOS, namely a mathematical delta.
- *
- * The current behaviour is that a binding goes by the combinations of
- * modifiers and base keysym, that is Option-d. The string value of the
- * event is the mathematical delta character, so if no binding calls
- * [break], the text widget will insert that character.
- *
- * Note that this is similar to control combinations on all platforms. They
- * also generate events that have the base character as keysym and a real
- * control character as character value. So Ctrl+C gets us the keysym XK_C,
- * the modifier Control (so you can bind <Control-C>) and a string value as
- * "\u0003".
- *
- * For a different solutions we may want for the event to contain keysyms for
- * *both* the 'Opt-d' side of things and the mathematical delta. Then a
- * binding on Opt-d will trigger, but a binding on mathematical delta would
- * also trigger. This would require changes in the core, though.
- */
+@implementation TKContentView(TKKeyEvent)
+/* <NSTextInput> implementation (called through interpretKeyEvents:]). */
-static int
-InitKeyEvent(
- XEvent * eventPtr,
- KeyEventData * e,
- UInt32 savedKeyCode,
- UInt32 savedModifiers)
+/* <NSTextInput>: called when done composing;
+ NOTE: also called when we delete over working text, followed immed.
+ by doCommandBySelector: deleteBackward: */
+- (void)insertText: (id)aString
{
- Window window;
- Tk_Window tkwin;
- TkDisplay *dispPtr;
+ int i, len = [(NSString *)aString length];
+ XEvent xEvent;
+ TkWindow *winPtr = TkMacOSXGetTkWindow([self window]);
+ Tk_Window tkwin = (Tk_Window) winPtr;
- /*
- * The focus must be in the FrontWindow on the Macintosh.
- * We then query Tk to determine the exact Tk window
- * that owns the focus.
- */
+ if (NS_KEYLOG)
+ NSLog (@"insertText '%@'\tlen = %d", aString, len);
+ processingCompose = NO;
+ finishedCompose = YES;
- window = TkMacOSXGetXWindow(e->whichWindow);
- dispPtr = TkGetDisplayList();
- tkwin = Tk_IdToWindow(dispPtr->display, window);
+ /* first, clear any working text */
+ if (_workingText != nil)
+ [self deleteWorkingText];
- if (!tkwin) {
- TkMacOSXDbgMsg("tkwin == NULL");
- return -1;
- }
+ /* now insert the string as keystrokes */
+ setupXEvent(&xEvent, [self window], 0);
+ xEvent.xany.type = KeyPress;
- tkwin = (Tk_Window) ((TkWindow *) tkwin)->dispPtr->focusPtr;
- if (!tkwin) {
- TkMacOSXDbgMsg("tkwin == NULL");
- return -1;
+ for (i =0; i<len; i++)
+ {
+ xEvent.xkey.keycode = (UInt16) [aString characterAtIndex: i];
+ [[aString substringWithRange: NSMakeRange(i,1)]
+ getCString: xEvent.xkey.trans_chars
+ maxLength: XMaxTransChars encoding: NSUTF8StringEncoding];
+ xEvent.xkey.nbytes = strlen(xEvent.xkey.trans_chars);
+ xEvent.xany.type = KeyPress;
+ Tk_QueueWindowEvent(&xEvent, TCL_QUEUE_TAIL);
+
+ xEvent.xany.type = KeyRelease;
+ xEvent.xany.serial = LastKnownRequestProcessed(Tk_Display(tkwin));
+ Tk_QueueWindowEvent(&xEvent, TCL_QUEUE_TAIL);
+ xEvent.xany.serial = LastKnownRequestProcessed(Tk_Display(tkwin));
}
-
- memset(eventPtr, 0, sizeof(XEvent));
- eventPtr->xany.send_event = false;
- eventPtr->xany.serial = Tk_Display(tkwin)->request;
-
- eventPtr->xkey.same_screen = true;
- eventPtr->xkey.subwindow = None;
- eventPtr->xkey.time = TkpGetMS();
- eventPtr->xkey.x_root = e->global_x;
- eventPtr->xkey.y_root = e->global_y;
- eventPtr->xkey.window = Tk_WindowId(tkwin);
- eventPtr->xkey.display = Tk_Display(tkwin);
- eventPtr->xkey.root = XRootWindow(Tk_Display(tkwin), 0);
- eventPtr->xkey.state = e->state;
- eventPtr->xkey.trans_chars[0] = 0;
-
- Tk_TopCoordsToWindow(tkwin, e->local_x, e->local_y, &eventPtr->xkey.x,
- &eventPtr->xkey.y);
-
- eventPtr->xkey.keycode = e->ch | ((savedKeyCode & charCodeMask) << 8) |
- ((e->message&keyCodeMask) << 8);
-
- return 1;
}
-
-/*
- *----------------------------------------------------------------------
- *
- * GetKeyboardLayout --
- *
- * Queries the OS for a pointer to a keyboard resource.
- *
- * This function works with the keyboard layout switch menu. It uses
- * Keyboard Layout Services, where available.
- *
- * Results:
- * 1 if there is returned a Unicode 'uchr' resource in *resourcePtr, 0
- * if it is a classic 'KCHR' resource. A pointer to the actual resource
- * data goes into *resourcePtr. If the resource is a 'KCHR' resource,
- * the corresponding Mac encoding goes into *encodingPtr.
- *
- * Side effects:
- * Sets some internal static variables.
- *
- *----------------------------------------------------------------------
- */
-static int
-GetKeyboardLayout(
- Ptr *resourcePtr,
- TextEncoding *encodingPtr)
-{
- static KeyboardLayoutRef lastLayout = NULL;
- static SInt32 lastLayoutId;
- static TextEncoding lastEncoding = kTextEncodingMacRoman;
- static Ptr uchr = NULL;
- static Ptr KCHR = NULL;
- int hasLayoutChanged = false;
- KeyboardLayoutRef currentLayout = NULL;
- SInt32 currentLayoutId = 0;
- ScriptCode currentKeyScript;
-
- currentKeyScript = GetScriptManagerVariable(smKeyScript);
-
- /*
- * Use the Keyboard Layout Services.
- */
- KLGetCurrentKeyboardLayout(&currentLayout);
+/* <NSTextInput>: inserts display of composing characters */
+- (void)setMarkedText: (id)aString selectedRange: (NSRange)selRange
+{
+ NSString *str = [aString respondsToSelector: @selector (string)] ?
+ [aString string] : aString;
+ if (NS_KEYLOG)
+ NSLog (@"setMarkedText '%@' len =%d range %d from %d", str, [str length],
+ selRange.length, selRange.location);
- if (currentLayout != NULL) {
+ if (_workingText != nil)
+ [self deleteWorkingText];
+ if ([str length] == 0)
+ return;
- /*
- * The layout pointer could in theory be the same for different
- * layouts, only the id gives us the information that the
- * keyboard has actually changed. OTOH the layout object can
- * also change and it could still be the same layoutid.
- */
+ processingCompose = YES;
+ _workingText = [str copy];
- KLGetKeyboardLayoutProperty(currentLayout, kKLIdentifier,
- (const void**)&currentLayoutId);
+ //PENDING: insert workingText underlined
+}
- if ((lastLayout != currentLayout)
- || (lastLayoutId != currentLayoutId)) {
-#ifdef TK_MAC_DEBUG_KEYBOARD
- TkMacOSXDbgMsg("Use KLS");
-#endif
+/* delete display of composing characters [not in <NSTextInput>] */
+- (void)deleteWorkingText
+{
+ if (_workingText == nil)
+ return;
+ if (NS_KEYLOG)
+ NSLog(@"deleteWorkingText len = %d\n", [_workingText length]);
+ [_workingText release];
+ _workingText = nil;
+ processingCompose = NO;
+
+ //PENDING: delete working text
+}
- hasLayoutChanged = true;
-
- /*
- * Reinitialize all relevant variables.
- */
-
- lastLayout = currentLayout;
- lastLayoutId = currentLayoutId;
- uchr = NULL;
- KCHR = NULL;
-
- if ((KLGetKeyboardLayoutProperty(currentLayout,
- kKLuchrData, (const void**)&uchr)
- == noErr)
- && (uchr != NULL)) {
- /* done */
- } else if ((KLGetKeyboardLayoutProperty(currentLayout,
- kKLKCHRData, (const void**)&KCHR)
- == noErr)
- && (KCHR != NULL)) {
- /* done */
- }
- }
- }
- if (hasLayoutChanged) {
-#ifdef TK_MAC_DEBUG_KEYBOARD
- if (KCHR) {
- TkMacOSXDbgMsg("New 'KCHR' layout %ld", currentLayoutId);
- } else if (uchr) {
- TkMacOSXDbgMsg("New 'uchr' layout %ld", currentLayoutId);
- } else {
- TkMacOSXDbgMsg("Use cached layout (should have been %ld)",
- currentLayoutId);
- }
-#endif
+- (BOOL)hasMarkedText
+{
+ return _workingText != nil;
+}
- deadKeyStateUp = deadKeyStateDown = 0;
-
- /*
- * If we did get a new 'KCHR', compute its encoding and put it into
- * lastEncoding.
- *
- * If we didn't get a new 'KCHR' and if we have no 'uchr' either, get
- * some 'KCHR' from the OS cache and leave lastEncoding at its
- * current value. This should better not happen, it doesn't really
- * work.
- */
-
- if (KCHR) {
- lastEncoding = GetKCHREncoding(currentKeyScript, currentLayoutId);
-#ifdef TK_MAC_DEBUG_KEYBOARD
- TkMacOSXDbgMsg("New 'KCHR' encoding %lu (%lu + 0x%lX)",
- lastEncoding, lastEncoding & 0xFFFFL,
- lastEncoding & ~0xFFFFL);
-#endif
- } else if (!uchr) {
- KCHR = (Ptr)(intptr_t)GetScriptManagerVariable(smKCHRCache);
- }
- }
- if (uchr) {
- *resourcePtr = uchr;
- return 1;
- } else {
- *resourcePtr = KCHR;
- *encodingPtr = lastEncoding;
- return 0;
- }
+- (NSRange)markedRange
+{
+ NSRange rng = _workingText != nil
+ ? NSMakeRange (0, [_workingText length]) : NSMakeRange (NSNotFound, 0);
+ if (NS_KEYLOG)
+ NSLog (@"markedRange request");
+ return rng;
}
-
-/*
- *----------------------------------------------------------------------
- *
- * GetKCHREncoding --
- *
- * Upgrade a WorldScript code to a TEC encoding based on the keyboard
- * layout id.
- *
- * Results:
- * The TEC code that corresponds best to the combination of WorldScript
- * code and 'KCHR' id.
- *
- * Side effects:
- * None.
- *
- * Rationale and Notes:
- * WorldScript codes are sometimes not unique encodings. E.g. Icelandic
- * uses script smRoman (0), but the actual encoding is
- * kTextEncodingMacIcelandic (37). ftp://ftp.unicode.org/Public
- * /MAPPINGS/VENDORS/APPLE/README.TXT has a good summary of these
- * variants. So we need to upgrade the script to an encoding with
- * GetTextEncodingFromScriptInfo().
- *
- * 'KCHR' ids are usually region codes (see the comments in Script.h).
- * Where they are not, we get a paramErr from the OS function and have
- * appropriate fallbacks.
- *
- *----------------------------------------------------------------------
- */
-static TextEncoding
-GetKCHREncoding(
- ScriptCode script,
- SInt32 layoutid)
-{
- RegionCode region = layoutid;
- TextEncoding encoding = script;
- if (GetTextEncodingFromScriptInfo(script, kTextLanguageDontCare, region,
- &encoding) == noErr) {
- return encoding;
- }
+- (void)unmarkText
+{
+ if (NS_KEYLOG)
+ NSLog (@"unmark (accept) text");
+ [self deleteWorkingText];
+ processingCompose = NO;
+}
- /*
- * GetTextEncodingFromScriptInfo() doesn't know about more exotic
- * layouts. This provides a fallback for good measure. In an ideal
- * world, exotic layouts would always provide a 'uchr' resource anyway,
- * so we wouldn't need this.
- *
- * We can add more keyboard layouts, if we get actual complaints. Farsi
- * or other Celtic/Gaelic layouts would be candidates.
- */
- switch (layoutid) {
- /*
- * Icelandic and Faroese (planned). These layouts are sold by Apple
- * Iceland for legacy applications.
- */
+/* used to position char selection windows, etc. */
+- (NSRect)firstRectForCharacterRange: (NSRange)theRange
+{
+ NSRect rect;
+ NSPoint pt;
- case 1800: case 1821:
- return kTextEncodingMacIcelandic;
+ pt.x = caret_x;
+ pt.y = caret_y;
- /*
- * Irish and Welsh. These layouts are mentioned in <Script.h>.
- *
- * FIXME: This may have to be kTextEncodingMacGaelic instead, but I
- * can't locate layouts of this type for testing.
- */
+ pt = [self convertPoint: pt toView: nil];
+ pt = [[self window] convertBaseToScreen: pt];
+ pt.y -= caret_height;
- case 581: case 779:
- return kTextEncodingMacCeltic;
- }
+ rect.origin = pt;
+ rect.size.width = caret_height;
+ rect.size.height = caret_height;
+ return rect;
+}
- /*
- * The valid script codes are also the valid default encoding codes, so
- * if nothing else helps, fall back on those.
- */
- return script;
+- (NSInteger)conversationIdentifier
+{
+ return (NSInteger)self;
}
-
-/*
- *----------------------------------------------------------------------
- *
- * KeycodeToUnicodeViaUnicodeResource --
- *
- * Given MacOS key event data this function generates the Unicode
- * characters. It does this using a 'uchr' and the UCKeyTranslate
- * API.
- *
- * The parameter deadKeyStatePtr can be NULL, if no deadkey handling
- * is needed.
- *
- * Tested and known to work with US, Hebrew, Greek and Russian layouts
- * as well as "Unicode Hex Input".
- *
- * Results:
- * The number of characters generated if any, 0 if we are waiting for
- * another byte of a dead-key sequence. Fills in the uniChars array
- * with a Unicode string.
- *
- * Side Effects:
- * None
- *
- *----------------------------------------------------------------------
- */
-static int
-KeycodeToUnicodeViaUnicodeResource(
- UniChar *uniChars,
- int maxChars,
- Ptr uchr,
- EventKind eKind,
- UInt32 keycode,
- UInt32 modifiers,
- UInt32 *deadKeyStatePtr)
+
+- (void)doCommandBySelector: (SEL)aSelector
{
- int action;
- unsigned long keyboardType;
- OptionBits options = 0;
- UInt32 dummy_state;
- UniCharCount actuallength;
- OSStatus err;
-
- keycode &= 0xFF;
- modifiers = (modifiers >> 8) & 0xFF;
- keyboardType = LMGetKbdType();
-
- if (NULL==deadKeyStatePtr) {
- options = kUCKeyTranslateNoDeadKeysMask;
- dummy_state = 0;
- deadKeyStatePtr = &dummy_state;
+ if (NS_KEYLOG)
+ NSLog (@"doCommandBySelector: %@", NSStringFromSelector (aSelector));
+ processingCompose = NO;
+ if (aSelector == @selector (deleteBackward:))
+ {
+ /* happens when user backspaces over an ongoing composition:
+ throw a 'delete' into the event queue */
+ XEvent xEvent;
+ setupXEvent(&xEvent, [self window], 0);
+ xEvent.xany.type = KeyPress;
+ xEvent.xkey.nbytes = 1;
+ xEvent.xkey.keycode = (0x33 << 16) | 0x7F;
+ xEvent.xkey.trans_chars[0] = 0x7F;
+ xEvent.xkey.trans_chars[1] = 0x0;
+ Tk_QueueWindowEvent(&xEvent, TCL_QUEUE_TAIL);
}
+}
- switch(eKind) {
- case kEventRawKeyDown:
- action = kUCKeyActionDown;
- break;
- case kEventRawKeyUp:
- action = kUCKeyActionUp;
- break;
- case kEventRawKeyRepeat:
- action = kUCKeyActionAutoKey;
- break;
- default:
- TkMacOSXDbgMsg("Invalid parameter eKind %d", eKind);
- return 0;
- }
- err = ChkErr(UCKeyTranslate, (const UCKeyboardLayout *) uchr, keycode,
- action, modifiers, keyboardType, options, deadKeyStatePtr,
- maxChars, &actuallength, uniChars);
+- (NSArray *)validAttributesForMarkedText
+{
+ static NSArray *arr = nil;
+ if (arr == nil) arr = [NSArray new];
+ /* [[NSArray arrayWithObject: NSUnderlineStyleAttributeName] retain]; */
+ return arr;
+}
- if ((0 == actuallength) && (0 != *deadKeyStatePtr)) {
- /*
- * More data later
- */
- return 0;
- }
+- (NSRange)selectedRange
+{
+ if (NS_KEYLOG)
+ NSLog (@"selectedRange request");
+ return NSMakeRange (NSNotFound, 0);
+}
- /*
- * some IMEs leave residue :-(
- */
- *deadKeyStatePtr = 0;
+- (NSUInteger)characterIndexForPoint: (NSPoint)thePoint
+{
+ if (NS_KEYLOG)
+ NSLog (@"characterIndexForPoint request");
+ return 0;
+}
- if (err != noErr) {
- actuallength = 0;
- }
- return actuallength;
+- (NSAttributedString *)attributedSubstringFromRange: (NSRange)theRange
+{
+ static NSAttributedString *str = nil;
+ if (str == nil) str = [NSAttributedString new];
+ if (NS_KEYLOG)
+ NSLog (@"attributedSubstringFromRange request");
+ return str;
}
+/* End <NSTextInput> impl. */
+@end
-/*
- *----------------------------------------------------------------------
- *
- * KeycodeToUnicodeViaKCHRResource --
- *
- * Given MacOS key event data this function generates the Unicode
- * characters. It does this using a 'KCHR' and the KeyTranslate API.
- *
- * The parameter deadKeyStatePtr can be NULL, if no deadkey handling
- * is needed.
- *
- * Results:
- * The number of characters generated if any, 0 if we are waiting for
- * another byte of a dead-key sequence. Fills in the uniChars array
- * with a Unicode string.
- *
- * Side Effects:
- * None
- *
- *----------------------------------------------------------------------
- */
-
-static int
-KeycodeToUnicodeViaKCHRResource(
- UniChar *uniChars,
- int maxChars,
- Ptr kchr,
- TextEncoding encoding,
- EventKind eKind,
- UInt32 keycode,
- UInt32 modifiers,
- UInt32 *deadKeyStatePtr)
-{
- UInt32 result;
- char macBuff[3];
- char *macStr;
- int macStrLen;
- UInt32 dummy_state = 0;
-
- if (NULL == deadKeyStatePtr) {
- deadKeyStatePtr = &dummy_state;
- }
-
- keycode |= modifiers;
- result = KeyTranslate(kchr, keycode, deadKeyStatePtr);
-
- if ((0 == result) && (0 != dummy_state)) {
- /*
- * 'dummy_state' gets only filled if the caller did not want deadkey
- * processing (deadKeyStatePtr was NULL originally), but we still
- * have a deadkey. We just push the keycode for the space bar to get
- * the real key value.
- */
-
- result = KeyTranslate(kchr, 0x31, deadKeyStatePtr);
- *deadKeyStatePtr = 0;
- }
- if ((0 == result) && (0 != *deadKeyStatePtr)) {
- /*
- * More data later
- */
- return 0;
- }
-
- macBuff[0] = (char) (result >> 16);
- macBuff[1] = (char) result;
- macBuff[2] = 0;
-
- if (0 != macBuff[0]) {
- /*
- * If the first byte is valid, the second is too
- */
-
- macStr = macBuff;
- macStrLen = 2;
- } else if (0 != macBuff[1]) {
- /*
- * Only the second is valid
- */
-
- macStr = macBuff+1;
- macStrLen = 1;
- } else {
- /*
- * No valid bytes at all -- shouldn't happen
- */
-
- macStr = NULL;
- macStrLen = 0;
- }
-
- if (macStrLen <= 0) {
- return 0;
- } else {
-
- /*
- * Use the CFString conversion routines. This is the easiest and
- * most compatible way to get from an 8-bit string and a MacOS script
- * code to a Unicode string.
- *
- * FIXME: The system ships with an Irish 'KCHR' but without the
- * corresponding macCeltic encoding, which triggers the error below.
- * Tcl doesn't have the macCeltic encoding either right now, so until
- * we get that, we can just as well stick to this code. The right
- * fix would be to use the Tcl encodings and add macCeltic and
- * probably others there. Suitable Unicode data files for the
- * missing encodings are available from www.evertype.com.
- */
-
- CFStringRef cfString;
- int uniStrLen;
-
- cfString = CFStringCreateWithCStringNoCopy(NULL, macStr, encoding,
- kCFAllocatorNull);
- if (cfString == NULL) {
- TkMacOSXDbgMsg("CFString: Can't convert with encoding %ld",
- encoding);
- return 0;
- }
-
- uniStrLen = CFStringGetLength(cfString);
- if (uniStrLen > maxChars) {
- uniStrLen = maxChars;
- }
- CFStringGetCharacters(cfString, CFRangeMake(0,uniStrLen), uniChars);
- CFRelease(cfString);
-
- return uniStrLen;
- }
-}
-
/*
- *----------------------------------------------------------------------
- *
- * TkMacOSXKeycodeToUnicode --
- *
- * Given MacOS key event data this function generates the Unicode
- * characters. It does this using OS resources and APIs.
- *
- * The parameter deadKeyStatePtr can be NULL, if no deadkey handling
- * is needed.
- *
- * This function is called from XKeycodeToKeysym() in
- * tkMacOSKeyboard.c.
- *
- * Results:
- * The number of characters generated if any, 0 if we are waiting for
- * another byte of a dead-key sequence. Fills in the uniChars array
- * with a Unicode string.
- *
- * Side Effects:
- * None
- *
- *----------------------------------------------------------------------
+ * Set up basic fields in xevent for keyboard input.
*/
-
-MODULE_SCOPE int
-TkMacOSXKeycodeToUnicode(
- UniChar *uniChars,
- int maxChars,
- EventKind eKind,
- UInt32 keycode,
- UInt32 modifiers,
- UInt32 *deadKeyStatePtr)
+static void
+setupXEvent(XEvent *xEvent, NSWindow *w, unsigned int state)
{
- Ptr resource = NULL;
- TextEncoding encoding;
- int len;
-
-
- if (GetKeyboardLayout(&resource,&encoding)) {
- len = KeycodeToUnicodeViaUnicodeResource(
- uniChars, maxChars, resource, eKind,
- keycode, modifiers, deadKeyStatePtr);
- } else {
- len = KeycodeToUnicodeViaKCHRResource(
- uniChars, maxChars, resource, encoding, eKind,
- keycode, modifiers, deadKeyStatePtr);
- }
-
- return len;
+ TkWindow *winPtr = TkMacOSXGetTkWindow(w);
+ Tk_Window tkwin = (Tk_Window) winPtr;
+
+ memset(xEvent, 0, sizeof(XEvent));
+ xEvent->xany.serial = LastKnownRequestProcessed(Tk_Display(tkwin));
+ xEvent->xany.send_event = false;
+ xEvent->xany.display = Tk_Display(tkwin);
+ xEvent->xany.window = Tk_WindowId(tkwin);
+
+ xEvent->xkey.root = XRootWindow(Tk_Display(tkwin), 0);
+ xEvent->xkey.subwindow = None;
+ xEvent->xkey.time = TkpGetMS();
+ xEvent->xkey.state = state;
+ xEvent->xkey.same_screen = true;
+ xEvent->xkey.trans_chars[0] = 0;
+ xEvent->xkey.nbytes = 0;
}
+
+#pragma mark -
/*
*----------------------------------------------------------------------
@@ -1038,6 +464,17 @@ XGrabKeyboard(
Time time)
{
keyboardGrabWinPtr = Tk_IdToWindow(display, grab_window);
+ if (keyboardGrabWinPtr && grabWinPtr) {
+ NSWindow *w = TkMacOSXDrawableWindow(grab_window);
+ MacDrawable *macWin = (MacDrawable *) grab_window;
+
+ if (w && macWin->toplevel->winPtr == (TkWindow*) grabWinPtr) {
+ if (modalSession) {
+ Tcl_Panic("XGrabKeyboard: already grabbed");
+ }
+ modalSession = [NSApp beginModalSessionForWindow:[w retain]];
+ }
+ }
return GrabSuccess;
}
@@ -1062,6 +499,13 @@ XUngrabKeyboard(
Display* display,
Time time)
{
+ if (modalSession) {
+ NSWindow *w = keyboardGrabWinPtr ? TkMacOSXDrawableWindow(
+ ((TkWindow *) keyboardGrabWinPtr)->window) : nil;
+ [NSApp endModalSession:modalSession];
+ [w release];
+ modalSession = NULL;
+ }
keyboardGrabWinPtr = NULL;
}
@@ -1072,6 +516,7 @@ XUngrabKeyboard(
*
* Results:
* Returns the current grab window
+ *
* Side effects:
* None.
*
@@ -1087,12 +532,31 @@ TkMacOSXGetCapture(void)
/*
*----------------------------------------------------------------------
*
+ * TkMacOSXGetModalSession --
+ *
+ * Results:
+ * Returns the current modal session
+ *
+ * Side effects:
+ * None.
+ *
+ *----------------------------------------------------------------------
+ */
+
+MODULE_SCOPE NSModalSession
+TkMacOSXGetModalSession(void)
+{
+ return modalSession;
+}
+
+/*
+ *----------------------------------------------------------------------
+ *
* TkpSetCapture --
*
- * This function captures the mouse so that all future events
- * will be reported to this window, even if the mouse is outside
- * the window. If the specified window is NULL, then the mouse
- * is released.
+ * This function captures the mouse so that all future events will be
+ * reported to this window, even if the mouse is outside the window. If
+ * the specified window is NULL, then the mouse is released.
*
* Results:
* None.
@@ -1110,24 +574,6 @@ TkpSetCapture(
while (winPtr && !Tk_IsTopLevel(winPtr)) {
winPtr = winPtr->parentPtr;
}
-#if 0
- {
- TkWindow *w = NULL;
- WindowModality m;
-
- if (winPtr) {
- w = winPtr;
- m = kWindowModalityAppModal;
- } else if (grabWinPtr) {
- w = (TkWindow*)grabWinPtr;
- m = kWindowModalityNone;
- }
- if (w && w->window != None && TkMacOSXHostToplevelExists(w)) {
- ChkErr(SetWindowModality, TkMacOSXDrawableWindow(w->window), m,
- NULL);
- }
- }
-#endif
grabWinPtr = (Tk_Window) winPtr;
}
@@ -1136,9 +582,9 @@ TkpSetCapture(
*
* Tk_SetCaretPos --
*
- * This enables correct placement of the XIM caret. This is called
- * by widgets to indicate their cursor placement, and the caret
- * location is used by TkpGetString to place the XIM caret.
+ * This enables correct placement of the XIM caret. This is called by
+ * widgets to indicate their cursor placement, and the caret location is
+ * used by TkpGetString to place the XIM caret.
*
* Results:
* None
@@ -1155,31 +601,123 @@ Tk_SetCaretPos(
int x,
int y,
int height)
-{
+ {
+ TkCaret *caretPtr = &(((TkWindow *) tkwin)->dispPtr->caret);
+
+ /*
+ * Prevent processing anything if the values haven't changed. Windows only
+ * has one display, so we can do this with statics.
+ */
+
+ if ((caretPtr->winPtr == ((TkWindow *) tkwin))
+ && (caretPtr->x == x) && (caretPtr->y == y)) {
+ return;
+ }
+
+ caretPtr->winPtr = ((TkWindow *) tkwin);
+ caretPtr->x = x;
+ caretPtr->y = y;
+ caretPtr->height = height;
+
+ /*
+ * As in Windows, adjust to the toplevel to get the coords right.
+ */
+
+ while (!Tk_IsTopLevel(tkwin)) {
+ x += Tk_X(tkwin);
+ y += Tk_Y(tkwin);
+ tkwin = Tk_Parent(tkwin);
+ if (tkwin == NULL) {
+ return;
+ }
+ }
+
+ /* But adjust for fact that NS uses flipped view. */
+ y = Tk_Height(tkwin) - y;
+
+ caret_x = x;
+ caret_y = y;
+ caret_height = height;
}
-/*
- *----------------------------------------------------------------------
- *
- * TkMacOSXInitKeyboard --
- *
- * This procedure initializes the keyboard layout.
- *
- * Results:
- * None.
- *
- * Side effects:
- * None.
- *
- *----------------------------------------------------------------------
- */
-MODULE_SCOPE void
-TkMacOSXInitKeyboard(
- Tcl_Interp *interp)
+static unsigned convert_ns_to_X_keysym[] =
{
- Ptr resource;
- TextEncoding encoding;
-
- GetKeyboardLayout(&resource, &encoding);
-}
+ NSHomeFunctionKey, 0x50,
+ NSLeftArrowFunctionKey, 0x51,
+ NSUpArrowFunctionKey, 0x52,
+ NSRightArrowFunctionKey, 0x53,
+ NSDownArrowFunctionKey, 0x54,
+ NSPageUpFunctionKey, 0x55,
+ NSPageDownFunctionKey, 0x56,
+ NSEndFunctionKey, 0x57,
+ NSBeginFunctionKey, 0x58,
+ NSSelectFunctionKey, 0x60,
+ NSPrintFunctionKey, 0x61,
+ NSExecuteFunctionKey, 0x62,
+ NSInsertFunctionKey, 0x63,
+ NSUndoFunctionKey, 0x65,
+ NSRedoFunctionKey, 0x66,
+ NSMenuFunctionKey, 0x67,
+ NSFindFunctionKey, 0x68,
+ NSHelpFunctionKey, 0x6A,
+ NSBreakFunctionKey, 0x6B,
+
+ NSF1FunctionKey, 0xBE,
+ NSF2FunctionKey, 0xBF,
+ NSF3FunctionKey, 0xC0,
+ NSF4FunctionKey, 0xC1,
+ NSF5FunctionKey, 0xC2,
+ NSF6FunctionKey, 0xC3,
+ NSF7FunctionKey, 0xC4,
+ NSF8FunctionKey, 0xC5,
+ NSF9FunctionKey, 0xC6,
+ NSF10FunctionKey, 0xC7,
+ NSF11FunctionKey, 0xC8,
+ NSF12FunctionKey, 0xC9,
+ NSF13FunctionKey, 0xCA,
+ NSF14FunctionKey, 0xCB,
+ NSF15FunctionKey, 0xCC,
+ NSF16FunctionKey, 0xCD,
+ NSF17FunctionKey, 0xCE,
+ NSF18FunctionKey, 0xCF,
+ NSF19FunctionKey, 0xD0,
+ NSF20FunctionKey, 0xD1,
+ NSF21FunctionKey, 0xD2,
+ NSF22FunctionKey, 0xD3,
+ NSF23FunctionKey, 0xD4,
+ NSF24FunctionKey, 0xD5,
+
+ NSBackspaceCharacter, 0x08, /* 8: Not on some KBs. */
+ NSDeleteCharacter, 0xFF, /* 127: Big 'delete' key upper right. */
+ NSDeleteFunctionKey, 0x9F, /* 63272: Del forw key off main array. */
+
+ NSTabCharacter, 0x09,
+ 0x19, 0x09, /* left tab->regular since pass shift */
+ NSCarriageReturnCharacter, 0x0D,
+ NSNewlineCharacter, 0x0D,
+ NSEnterCharacter, 0x8D,
+
+ 0x1B, 0x1B /* escape */
+};
+
+
+static unsigned isFunctionKey(unsigned code)
+{
+ const unsigned last_keysym = (sizeof (convert_ns_to_X_keysym)
+ / sizeof (convert_ns_to_X_keysym[0]));
+ unsigned keysym;
+ for (keysym = 0; keysym < last_keysym; keysym += 2)
+ if (code == convert_ns_to_X_keysym[keysym])
+ return 0xFF00 | convert_ns_to_X_keysym[keysym+1];
+ return 0;
+ }
+
+/*
+ * Local Variables:
+ * mode: objc
+ * c-basic-offset: 4
+ * fill-column: 79
+ * coding: utf-8
+ * End:
+ */
diff --git a/macosx/tkMacOSXKeyboard.c b/macosx/tkMacOSXKeyboard.c
index 6bf3643..f776562 100644
--- a/macosx/tkMacOSXKeyboard.c
+++ b/macosx/tkMacOSXKeyboard.c
@@ -4,17 +4,15 @@
* Routines to support keyboard events on the Macintosh.
*
* Copyright (c) 1995-1997 Sun Microsystems, Inc.
- * Copyright 2001, Apple Computer, Inc.
- * Copyright (c) 2005-2007 Daniel A. Steffen <das@users.sourceforge.net>
+ * Copyright 2001-2009, Apple Inc.
+ * Copyright (c) 2005-2009 Daniel A. Steffen <das@users.sourceforge.net>
*
* See the file "license.terms" for information on usage and redistribution
* of this file, and for a DISCLAIMER OF ALL WARRANTIES.
*/
-#include "tkMacOSXInt.h"
-#include "tkMacOSXEvent.h" /* for TkMacOSXKeycodeToUnicode()
- * FIXME: That function should probably move
- * here. */
+#include "tkMacOSXPrivate.h"
+#include "tkMacOSXEvent.h"
/*
* A couple of simple definitions to make code a bit more self-explaining.
@@ -106,6 +104,8 @@ static Tcl_HashTable vkeyTable; /* virtualkeyArray hashed by virtual
static int latin1Table[LATIN1_MAX+1]; /* Reverse mapping table for
* controls, ASCII and Latin-1. */
+static int keyboardChanged = 1;
+
/*
* Prototypes for static functions used in this file.
*/
@@ -113,7 +113,23 @@ static int latin1Table[LATIN1_MAX+1]; /* Reverse mapping table for
static void InitKeyMaps (void);
static void InitLatin1Table(Display *display);
static int XKeysymToMacKeycode(Display *display, KeySym keysym);
+static int KeycodeToUnicode(UniChar * uniChars, int maxChars,
+ UInt16 keyaction, UInt32 keycode, UInt32 modifiers,
+ UInt32 * deadKeyStatePtr);
+
+#pragma mark TKApplication(TKKeyboard)
+
+@implementation TKApplication(TKKeyboard)
+- (void) keyboardChanged: (NSNotification *) notification
+{
+#ifdef TK_MAC_DEBUG_NOTIFICATIONS
+ TKLog(@"-[%@(%p) %s] %@", [self class], self, _cmd, notification);
+#endif
+ keyboardChanged = 1;
+}
+@end
+#pragma mark -
/*
*----------------------------------------------------------------------
@@ -144,13 +160,13 @@ InitKeyMaps(void)
Tcl_InitHashTable(&keycodeTable, TCL_ONE_WORD_KEYS);
for (kPtr = keyArray; kPtr->keycode != 0; kPtr++) {
- hPtr = Tcl_CreateHashEntry(&keycodeTable, (char *) kPtr->keycode,
+ hPtr = Tcl_CreateHashEntry(&keycodeTable, INT2PTR(kPtr->keycode),
&dummy);
Tcl_SetHashValue(hPtr, kPtr->keysym);
}
Tcl_InitHashTable(&vkeyTable, TCL_ONE_WORD_KEYS);
for (kPtr = virtualkeyArray; kPtr->keycode != 0; kPtr++) {
- hPtr = Tcl_CreateHashEntry(&vkeyTable, (char *) kPtr->keycode,
+ hPtr = Tcl_CreateHashEntry(&vkeyTable, INT2PTR(kPtr->keycode),
&dummy);
Tcl_SetHashValue(hPtr, kPtr->keysym);
}
@@ -162,10 +178,10 @@ InitKeyMaps(void)
*
* InitLatin1Table --
*
- * Creates a simple table to be used for mapping from keysyms to
- * keycodes. Always needs to be called before using latin1Table,
- * because the keyboard layout may have changed, and than the table must
- * be re-computed.
+ * Creates a simple table to be used for mapping from keysyms to keycodes.
+ * Always needs to be called before using latin1Table, because the
+ * keyboard layout may have changed, and than the table must be
+ * re-computed.
*
* Results:
* None.
@@ -180,57 +196,128 @@ static void
InitLatin1Table(
Display *display)
{
- static Boolean latin1_initialized = false;
- static SInt16 lastKeyLayoutID = -1;
+ int keycode;
+ KeySym keysym;
+ int state;
+ int modifiers;
- SInt16 keyScript;
- SInt16 keyLayoutID;
+ memset(latin1Table, 0, sizeof(latin1Table));
- keyScript = GetScriptManagerVariable(smKeyScript);
- keyLayoutID = GetScriptVariable(keyScript,smScriptKeys);
+ /*
+ * In the common X11 implementations, a keymap has four columns
+ * "plain", "Shift", "Mode_switch" and "Mode_switch + Shift". We don't
+ * use "Mode_switch", but we use "Option" instead. (This is similar to
+ * Apple's X11 implementation, where "Mode_switch" is used as an alias
+ * for "Option".)
+ *
+ * So here we go through all 4 columns of the keymap and find all
+ * Latin-1 compatible keycodes. We go through the columns back-to-front
+ * from the more exotic columns to the more simple, so that simple
+ * keycode-modifier combinations are preferred in the resulting table.
+ */
+
+ for (state = 3; state >= 0; state--) {
+ modifiers = 0;
+ if (state & 1) {
+ modifiers |= shiftKey;
+ }
+ if (state & 2) {
+ modifiers |= optionKey;
+ }
- if (!latin1_initialized || (lastKeyLayoutID != keyLayoutID)) {
- int keycode;
- KeySym keysym;
- int state;
- int modifiers;
+ for (keycode = 0; keycode <= MAC_KEYCODE_MAX; keycode++) {
+ keysym = XKeycodeToKeysym(display,keycode<<16,state);
+ if (keysym <= LATIN1_MAX) {
+ latin1Table[keysym] = keycode | modifiers;
+ }
+ }
+ }
+}
+
+/*
+ *----------------------------------------------------------------------
+ *
+ * KeycodeToUnicode --
+ *
+ * Given MacOS key event data this function generates the Unicode
+ * characters. It does this using OS resources and APIs.
+ *
+ * The parameter deadKeyStatePtr can be NULL, if no deadkey handling is
+ * needed.
+ *
+ * This function is called from XKeycodeToKeysym() in tkMacOSKeyboard.c.
+ *
+ * Results:
+ * The number of characters generated if any, 0 if we are waiting for
+ * another byte of a dead-key sequence. Fills in the uniChars array with a
+ * Unicode string.
+ *
+ * Side Effects:
+ * None
+ *
+ *----------------------------------------------------------------------
+ */
- latin1_initialized = true;
- lastKeyLayoutID = keyLayoutID;
+static int
+KeycodeToUnicode(
+ UniChar *uniChars,
+ int maxChars,
+ UInt16 keyaction,
+ UInt32 keycode,
+ UInt32 modifiers,
+ UInt32 *deadKeyStatePtr)
+{
+ static const void *uchr = NULL;
+ static UInt32 keyboardType = 0;
+ UniCharCount actuallength = 0;
- memset(latin1Table, 0, sizeof(latin1Table));
+ if (keyboardChanged) {
+ TISInputSourceRef currentKeyboardLayout =
+ TISCopyCurrentKeyboardLayoutInputSource();
- /*
- * In the common X11 implementations, a keymap has four columns
- * "plain", "Shift", "Mode_switch" and "Mode_switch + Shift". We
- * don't use "Mode_switch", but we use "Option" instead. (This is
- * similar to Apple's X11 implementation, where "Mode_switch" is used
- * as an alias for "Option".)
- *
- * So here we go through all 4 columns of the keymap and find all
- * Latin-1 compatible keycodes. We go through the columns
- * back-to-front from the more exotic columns to the more simple, so
- * that simple keycode-modifier combinations are preferred in the
- * resulting table.
- */
+ if (currentKeyboardLayout) {
+ CFDataRef keyLayoutData = (CFDataRef) TISGetInputSourceProperty(
+ currentKeyboardLayout, kTISPropertyUnicodeKeyLayoutData);
- for (state = 3; state >= 0; state--) {
- modifiers = 0;
- if (state & 1) {
- modifiers |= shiftKey;
- }
- if (state & 2) {
- modifiers |= optionKey;
+ if (keyLayoutData) {
+ uchr = CFDataGetBytePtr(keyLayoutData);
+ keyboardType = LMGetKbdType();
}
+ CFRelease(currentKeyboardLayout);
+ }
+ keyboardChanged = 0;
+ }
+ if (uchr) {
+ OptionBits options = 0;
+ UInt32 dummyState;
+ OSStatus err;
+
+ keycode &= 0xFF;
+ modifiers = (modifiers >> 8) & 0xFF;
+
+ if (!deadKeyStatePtr) {
+ options = kUCKeyTranslateNoDeadKeysMask;
+ dummyState = 0;
+ deadKeyStatePtr = &dummyState;
+ }
- for (keycode = 0; keycode <= MAC_KEYCODE_MAX; keycode++) {
- keysym = XKeycodeToKeysym(display,keycode<<16,state);
- if (keysym <= LATIN1_MAX) {
- latin1Table[keysym] = keycode | modifiers;
- }
- }
+ err = ChkErr(UCKeyTranslate, uchr, keycode, keyaction, modifiers,
+ keyboardType, options, deadKeyStatePtr, maxChars,
+ &actuallength, uniChars);
+
+ if (!actuallength && *deadKeyStatePtr) {
+ /*
+ * More data later
+ */
+
+ return 0;
+ }
+ *deadKeyStatePtr = 0;
+ if (err != noErr) {
+ actuallength = 0;
}
}
+ return actuallength;
}
/*
@@ -267,21 +354,21 @@ XKeycodeToKeysym(
}
/*
- * When determining what keysym to produce we first check to see if the
- * key is a function key. We then check to see if the character is
- * another non-printing key. Finally, we return the key syms for all
- * ASCII and Latin-1 chars.
+ * When determining what keysym to produce we first check to see if the key
+ * is a function key. We then check to see if the character is another
+ * non-printing key. Finally, we return the key syms for all ASCII and
+ * Latin-1 chars.
*/
newKeycode = keycode >> 16;
- if ((keycode & 0xFFFF) == 0x10) {
- hPtr = Tcl_FindHashEntry(&vkeyTable, (char *) newKeycode);
+ if ((keycode & 0xFFFF) >= 0xF700) { /* NSEvent.h function key unicodes */
+ hPtr = Tcl_FindHashEntry(&vkeyTable, INT2PTR(newKeycode));
if (hPtr != NULL) {
return (KeySym) Tcl_GetHashValue(hPtr);
}
}
- hPtr = Tcl_FindHashEntry(&keycodeTable, (char *) newKeycode);
+ hPtr = Tcl_FindHashEntry(&keycodeTable, INT2PTR(newKeycode));
if (hPtr != NULL) {
return (KeySym) Tcl_GetHashValue(hPtr);
}
@@ -298,13 +385,12 @@ XKeycodeToKeysym(
}
newChar = 0;
- TkMacOSXKeycodeToUnicode(
- &newChar, 1, kEventRawKeyDown,
- newKeycode & 0x00FF, newKeycode & 0xFF00, NULL);
+ KeycodeToUnicode(&newChar, 1, kUCKeyActionDown, newKeycode & 0x00FF,
+ newKeycode & 0xFF00, NULL);
/*
- * X11 keysyms are identical to Unicode for ASCII and Latin-1. Give up
- * for other characters for now.
+ * X11 keysyms are identical to Unicode for ASCII and Latin-1. Give up for
+ * other characters for now.
*/
if ((newChar >= XK_space) && (newChar <= LATIN1_MAX)) {
@@ -361,15 +447,15 @@ TkpGetString(
XModifierKeymap *
XGetModifierMapping(
- Display* display)
+ Display *display)
{
- XModifierKeymap * modmap;
+ XModifierKeymap *modmap;
(void) display; /*unused*/
/*
- * MacOSX doesn't use the key codes for the modifiers for anything, and
- * we don't generate them either. So there is no modifier map.
+ * MacOSX doesn't use the key codes for the modifiers for anything, and we
+ * don't generate them either. So there is no modifier map.
*/
modmap = (XModifierKeymap *) ckalloc(sizeof(XModifierKeymap));
@@ -411,9 +497,9 @@ XFreeModifiermap(
* XKeysymToString, XStringToKeysym --
*
* These X window functions map keysyms to strings & strings to keysyms.
- * However, Tk already does this for the most common keysyms.
- * Therefore, these functions only need to support keysyms that will be
- * specific to the Macintosh. Currently, there are none.
+ * However, Tk already does this for the most common keysyms. Therefore,
+ * these functions only need to support keysyms that will be specific to
+ * the Macintosh. Currently, there are none.
*
* Results:
* None.
@@ -443,8 +529,8 @@ XStringToKeysym(
*
* XKeysymToMacKeycode --
*
- * An internal function like XKeysymToKeycode but only generating the
- * Mac specific keycode plus the modifiers Shift and Option.
+ * An internal function like XKeysymToKeycode but only generating the Mac
+ * specific keycode plus the modifiers Shift and Option.
*
* Results:
* A Mac keycode with the actual keycode in the low byte and Mac-style
@@ -461,45 +547,44 @@ XKeysymToMacKeycode(
Display *display,
KeySym keysym)
{
- if (keysym <= LATIN1_MAX) {
+ KeyInfo *kPtr;
+ if (keysym <= LATIN1_MAX) {
/*
* Handle keysyms in the Latin-1 range where keysym and Unicode
* character code point are the same.
*/
- InitLatin1Table(display);
+ if (keyboardChanged) {
+ InitLatin1Table(display);
+ keyboardChanged = 0;
+ }
return latin1Table[keysym];
+ }
- } else {
-
- /*
- * Handle special keys from our exception tables. Don't mind if this
- * is slow, neither the test suite nor [event generate] need to be
- * optimized (we hope).
- */
-
- KeyInfo *kPtr;
+ /*
+ * Handle special keys from our exception tables. Don't mind if this is
+ * slow, neither the test suite nor [event generate] need to be optimized
+ * (we hope).
+ */
- for (kPtr = keyArray; kPtr->keycode != 0; kPtr++) {
- if (kPtr->keysym == keysym) {
- return kPtr->keycode;
- }
+ for (kPtr = keyArray; kPtr->keycode != 0; kPtr++) {
+ if (kPtr->keysym == keysym) {
+ return kPtr->keycode;
}
- for (kPtr = virtualkeyArray; kPtr->keycode != 0; kPtr++) {
- if (kPtr->keysym == keysym) {
- return kPtr->keycode;
- }
+ }
+ for (kPtr = virtualkeyArray; kPtr->keycode != 0; kPtr++) {
+ if (kPtr->keysym == keysym) {
+ return kPtr->keycode;
}
+ }
- /*
- * For other keysyms (not Latin-1 and not special keys), we'd need a
- * generic keysym-to-unicode table. We don't have that, so we give
- * up here.
- */
+ /*
+ * For other keysyms (not Latin-1 and not special keys), we'd need a
+ * generic keysym-to-unicode table. We don't have that, so we give up here.
+ */
- return 0;
- }
+ return 0;
}
/*
@@ -507,9 +592,9 @@ XKeysymToMacKeycode(
*
* XKeysymToKeycode --
*
- * The function XKeysymToKeycode takes an X11 keysym and converts it
- * into a Mac keycode. It is in the stubs table for compatibility but
- * not used anywhere in the core.
+ * The function XKeysymToKeycode takes an X11 keysym and converts it into
+ * a Mac keycode. It is in the stubs table for compatibility but not used
+ * anywhere in the core.
*
* Results:
* A 32 bit keycode with the the mac keycode (without modifiers) in the
@@ -545,32 +630,6 @@ XKeysymToKeycode(
return result;
}
-
-/*
-NB: Keep this commented code for a moment for reference.
-
- if ((keysym >= XK_space) && (XK_asciitilde)) {
- if (keysym == 'a') {
- virtualKeyCode = 0x00;
- } else if (keysym == 'b' || keysym == 'B') {
- virtualKeyCode = 0x0B;
- } else if (keysym == 'c') {
- virtualKeyCode = 0x08;
- } else if (keysym == 'x' || keysym == 'X') {
- virtualKeyCode = 0x07;
- } else if (keysym == 'z') {
- virtualKeyCode = 0x06;
- } else if (keysym == ' ') {
- virtualKeyCode = 0x31;
- } else if (keysym == XK_Return) {
- virtualKeyCode = 0x24;
- keysym = '\r';
- }
- keycode = keysym + (virtualKeyCode <<16);
- }
-
- return keycode;
-*/
/*
*----------------------------------------------------------------------
@@ -579,8 +638,8 @@ NB: Keep this commented code for a moment for reference.
*
* The function TkpSetKeycodeAndState takes a keysym and fills in the
* appropriate members of an XEvent. It is similar to XKeysymToKeycode,
- * but it also sets the modifier mask in the XEvent. It is used by
- * [event generate] and it is in the stubs table.
+ * but it also sets the modifier mask in the XEvent. It is used by [event
+ * generate] and it is in the stubs table.
*
* Results:
* Fills an XEvent, sets the member xkey.keycode with a keycode
@@ -625,8 +684,8 @@ TkpSetKeycodeAndState(
}
if (keysym <= LATIN1_MAX) {
- int done;
- done = Tcl_UniCharToUtf(keysym,eventPtr->xkey.trans_chars);
+ int done = Tcl_UniCharToUtf(keysym, eventPtr->xkey.trans_chars);
+
eventPtr->xkey.trans_chars[done] = 0;
} else {
eventPtr->xkey.trans_chars[0] = 0;
@@ -676,28 +735,30 @@ TkpGetKeySym(
if (eventPtr->xany.send_event == -1) {
int modifier = eventPtr->xkey.keycode;
- if (modifier == cmdKey) {
+
+ if (modifier == NSCommandKeyMask) {
return XK_Meta_L;
- } else if (modifier == shiftKey) {
+ } else if (modifier == NSShiftKeyMask) {
return XK_Shift_L;
- } else if (modifier == alphaLock) {
+ } else if (modifier == NSAlphaShiftKeyMask) {
return XK_Caps_Lock;
- } else if (modifier == optionKey) {
+ } else if (modifier == NSAlternateKeyMask) {
return XK_Alt_L;
- } else if (modifier == controlKey) {
+ } else if (modifier == NSControlKeyMask) {
return XK_Control_L;
- } else if (modifier == kEventKeyModifierNumLockMask) {
+ } else if (modifier == NSNumericPadKeyMask) {
return XK_Num_Lock;
- } else if (modifier == kEventKeyModifierFnMask) {
+ } else if (modifier == NSFunctionKeyMask) {
return XK_Super_L;
+/*
} else if (modifier == rightShiftKey) {
return XK_Shift_R;
} else if (modifier == rightOptionKey) {
return XK_Alt_R;
} else if (modifier == rightControlKey) {
return XK_Control_R;
+*/
} else {
-
/*
* If we get here, we probably need to implement something new.
*/
@@ -706,11 +767,17 @@ TkpGetKeySym(
}
}
+ /* If nbytes has been set, it's not a function key, but a regular key that
+ has been translated in tkMacOSXKeyEvent.c; just use that. */
+ if (eventPtr->xkey.nbytes) {
+ return eventPtr->xkey.keycode & 0xFFFF;
+ }
+
/*
- * Figure out which of the four slots in the keymap vector to use for
- * this key. Refer to Xlib documentation for more info on how this
- * computation works. (Note: We use "Option" in keymap columns 2 and 3
- * where other implementations have "Mode_switch".)
+ * Figure out which of the four slots in the keymap vector to use for this
+ * key. Refer to Xlib documentation for more info on how this computation
+ * works. (Note: We use "Option" in keymap columns 2 and 3 where other
+ * implementations have "Mode_switch".)
*/
index = 0;
@@ -728,7 +795,7 @@ TkpGetKeySym(
if ((eventPtr->xkey.state & ShiftMask)
|| (/* (dispPtr->lockUsage != LU_IGNORE)
- && */ (eventPtr->xkey.state & LockMask))) {
+ && */ (eventPtr->xkey.state & LockMask))) {
index |= 1;
}
@@ -740,17 +807,16 @@ TkpGetKeySym(
/*
* Special handling: If the key was shifted because of Lock, but lock is
- * only caps lock, not shift lock, and the shifted keysym isn't
- * upper-case alphabetic, then switch back to the unshifted keysym.
+ * only caps lock, not shift lock, and the shifted keysym isn't upper-case
+ * alphabetic, then switch back to the unshifted keysym.
*/
if ((index & 1) && !(eventPtr->xkey.state & ShiftMask)
/*&& (dispPtr->lockUsage == LU_CAPS)*/ ) {
-
/*
- * FIXME: Keysyms are only identical to Unicode for ASCII and
- * Latin-1, so we can't use Tcl_UniCharIsUpper() for keysyms outside
- * that range. This may be a serious problem here.
+ * FIXME: Keysyms are only identical to Unicode for ASCII and Latin-1,
+ * so we can't use Tcl_UniCharIsUpper() for keysyms outside that range.
+ * This may be a serious problem here.
*/
if ((sym == NoSymbol) || (sym > LATIN1_MAX)
@@ -778,9 +844,9 @@ TkpGetKeySym(
*
* TkpInitKeymapInfo --
*
- * This procedure is invoked to scan keymap information to recompute
- * stuff that's important for binding, such as the modifier key (if any)
- * that corresponds to the "Mode_switch" keysym.
+ * This procedure is invoked to scan keymap information to recompute stuff
+ * that's important for binding, such as the modifier key (if any) that
+ * corresponds to the "Mode_switch" keysym.
*
* Results:
* None.
@@ -800,8 +866,8 @@ TkpInitKeymapInfo(
/*
* Behaviours that are variable on X11 are defined constant on MacOSX.
- * lockUsage is only used above in TkpGetKeySym(), nowhere else
- * currently. There is no offical "Mode_switch" key.
+ * lockUsage is only used above in TkpGetKeySym(), nowhere else currently.
+ * There is no offical "Mode_switch" key.
*/
dispPtr->lockUsage = LU_CAPS;
@@ -825,10 +891,10 @@ TkpInitKeymapInfo(
/*
* MacOSX doesn't use the keycodes for the modifiers for anything, and we
- * don't generate them either (the keycodes actually given in the
- * simulated modifier events are bogus). So there is no modifier map.
- * If we ever want to simulate real modifier keycodes, the list will be
- * constant in the Carbon implementation.
+ * don't generate them either (the keycodes actually given in the simulated
+ * modifier events are bogus). So there is no modifier map. If we ever want
+ * to simulate real modifier keycodes, the list will be constant in the
+ * Carbon implementation.
*/
if (dispPtr->modKeyCodes != NULL) {
@@ -837,3 +903,12 @@ TkpInitKeymapInfo(
dispPtr->numModKeyCodes = 0;
dispPtr->modKeyCodes = NULL;
}
+
+/*
+ * Local Variables:
+ * mode: objc
+ * c-basic-offset: 4
+ * fill-column: 79
+ * coding: utf-8
+ * End:
+ */
diff --git a/macosx/tkMacOSXMenu.c b/macosx/tkMacOSXMenu.c
index 386fe50..979361a 100644
--- a/macosx/tkMacOSXMenu.c
+++ b/macosx/tkMacOSXMenu.c
@@ -4,18 +4,20 @@
* This module implements the Mac-platform specific features of menus.
*
* Copyright (c) 1996-1997 by Sun Microsystems, Inc.
- * Copyright 2001, Apple Computer, Inc.
- * Copyright (c) 2005-2007 Daniel A. Steffen <das@users.sourceforge.net>
+ * Copyright 2001-2009, Apple Inc.
+ * Copyright (c) 2005-2009 Daniel A. Steffen <das@users.sourceforge.net>
+ * Copyright (c) 2012 Adrian Robert.
*
* See the file "license.terms" for information on usage and redistribution
* of this file, and for a DISCLAIMER OF ALL WARRANTIES.
*/
-
+
#include "tkMacOSXPrivate.h"
#include "tkMenubutton.h"
#include "tkMenu.h"
#include "tkColor.h"
#include "tkFont.h"
+#include "tkMacOSXWm.h"
#include "tkMacOSXDebug.h"
/*
@@ -24,1564 +26,497 @@
#endif
*/
-#define USE_TK_MDEF
-
-typedef struct MacMenu {
- MenuRef menuHdl; /* The Menu Manager data structure. */
-#ifdef USE_TK_MDEF
- int useMDEF; /* true if this menu uses the MDEF */
-#endif
-} MacMenu;
-
-typedef struct MenuEntryUserData {
- Drawable mdefDrawable;
- TkMenuEntry *mePtr;
- Tk_Font tkfont;
- Tk_FontMetrics *fmPtr;
-} MenuEntryUserData;
-
-/*
- * Platform specific flags for menu entries
- *
- * ENTRY_COMMAND_ACCEL Indicates the entry has the command key
- * in its accelerator string.
- * ENTRY_OPTION_ACCEL Indicates the entry has the option key
- * in its accelerator string.
- * ENTRY_SHIFT_ACCEL Indicates the entry has the shift key
- * in its accelerator string.
- * ENTRY_CONTROL_ACCEL Indicates the entry has the control key
- * in its accelerator string.
- */
-
-#define ENTRY_COMMAND_ACCEL ENTRY_PLATFORM_FLAG1
-#define ENTRY_OPTION_ACCEL ENTRY_PLATFORM_FLAG2
-#define ENTRY_SHIFT_ACCEL ENTRY_PLATFORM_FLAG3
-#define ENTRY_CONTROL_ACCEL ENTRY_PLATFORM_FLAG4
-#define ENTRY_ACCEL_MASK (ENTRY_COMMAND_ACCEL | ENTRY_OPTION_ACCEL \
- | ENTRY_SHIFT_ACCEL | ENTRY_CONTROL_ACCEL)
-#define MODIFIER_NUM 4
-
-/*
- * This structure is used to keep track of subfields within Macintosh menu
- * items.
- */
-
-typedef struct EntryGeometry {
- int accelTextStart; /* Offset into the accel string where
- * the text starts. Everything before
- * this is modifier key descriptions.
- */
- int modifierWidth; /* Width of modifier symbols. */
- int accelTextWidth; /* Width of the text after the modifier
- * keys. */
- int nonAccelMargin; /* The width of the margin for entries
- * without accelerators. */
- int modifierNum; /* Number of modifiers */
- Tcl_UniChar modifierUniChars[MODIFIER_NUM];
- /* Modifiers in unicode */
- char accelGlyph; /* Accelerator glyph, if any */
-} EntryGeometry;
-
-/*
- * Structure to keep track of toplevel windows and their menubars.
- */
-
-typedef struct TopLevelMenubarList {
- struct TopLevelMenubarList *nextPtr;
- /* The next window in the list. */
- Tk_Window tkwin; /* The toplevel window. */
- TkMenu *menuPtr; /* The menu associated with this
- * toplevel. */
-} TopLevelMenubarList;
-
-/*
- * Platform-specific flags for menus.
- *
- * MENU_APPLE_MENU 0 indicates a custom Apple menu has
- * not been installed; 1 a custom Apple
- * menu has been installed.
- * MENU_HELP_MENU 0 indicates a custom Help menu has
- * not been installed; 1 a custom Help
- * menu has been installed.
- * MENU_RECONFIGURE_PENDING 1 indicates that an idle handler has
- * been scheduled to reconfigure the
- * Macintosh MenuHandle.
- */
-
-#define MENU_APPLE_MENU MENU_PLATFORM_FLAG1
-#define MENU_HELP_MENU MENU_PLATFORM_FLAG2
-#define MENU_RECONFIGURE_PENDING MENU_PLATFORM_FLAG3
-
-#define CASCADE_CMD (0x1b) /* The special command char for cascade
- * menus. */
-#define MENUBAR_REDRAW_PENDING 1
-
-static int gNoTkMenus = 0; /* This is used by Tk_MacOSXTurnOffMenus as the
- * flag that Tk is not to draw any menus. */
-
-static Tcl_HashTable commandTable;
- /* The list of menuInstancePtrs associated with
- * menu ids */
-static short currentAppleMenuID;
- /* The id of the current Apple menu. 0 for
- * none. */
-static short currentHelpMenuID; /* The id of the current Help menu. 0 for
- * none. */
-static Tcl_Interp *currentMenuBarInterp;
- /* The interpreter of the window that owns
- * the current menubar. */
-static char *currentMenuBarName;
- /* Malloced. Name of current menu in menu bar.
- * NULL if no menu set. TO DO: make this a
- * DString. */
-static Tk_Window currentMenuBarOwner;
- /* Which window owns the current menu bar. */
-static int inPostMenu; /* We cannot be re-entrant like X
- * windows. */
-static short lastMenuID; /* To pass to NewMenu; need to figure out
- * a good way to do this. */
-static short lastCascadeID;
- /* Cascades have to have ids that are
- * less than 256. */
-static int menuBarFlags; /* Used for whether the menu bar needs
- * redrawing or not. */
-
-struct MenuCommandHandlerData { /* This is the ClientData we pass to */
- TkMenu *menuPtr; /* Tcl_DoWhenIdle to move handling */
- int index; /* menu commands to the event loop. */
+#define ENTRY_HELP_MENU ENTRY_PLATFORM_FLAG1
+#define ENTRY_APPLE_MENU ENTRY_PLATFORM_FLAG2
+#define ENTRY_WINDOWS_MENU ENTRY_PLATFORM_FLAG3
+
+#define sl(s) ((int) (sizeof(s "") - 1))
+
+#define SPECIALMENU(n, f) {.name = "." #n, .len = sl(#n) + 1, \
+ .flag = ENTRY_##f##_MENU }
+static const struct {
+ const char *name; const size_t len; const int flag;
+} specialMenus[] = {
+ SPECIALMENU(help, HELP),
+ SPECIALMENU(apple, APPLE),
+ SPECIALMENU(window, WINDOWS),
+ {NULL}
};
-
-static TopLevelMenubarList *windowListPtr;
- /* A list of windows that have menubars set. */
-
-/*
- * Array of unicode, charcode and utf representations of the most common
- * special menu symbols.
- */
-typedef struct MenuSymbol {
- const Tcl_UniChar unicode;
- const char charCode;
- /* char padding; */
- int utfLen, width;
- char utf[TCL_UTF_MAX + 1];
-} MenuSymbol;
-
-static MenuSymbol menuSymbols[] = {
- {kCommandUnicode, kCommandCharCode},
- {kOptionUnicode, kMenuOptionGlyph},
- {kControlUnicode, kMenuControlGlyph},
- {kShiftUnicode, kMenuShiftGlyph},
- {kCheckUnicode, kCheckCharCode},
- {kDiamondUnicode, kDiamondCharCode},
- {kBulletUnicode, kBulletCharCode},
- {0x2026, kNullCharCode},
- {0, 0},
+#undef SPECIALMENU
+
+#define MODIFIER(n, f) {.name = #n, .len = sl(#n), .mask = f }
+static const struct {
+ const char *name; const size_t len; const NSUInteger mask;
+} modifiers[] = {
+ MODIFIER(Control, NSControlKeyMask),
+ MODIFIER(Ctrl, NSControlKeyMask),
+ MODIFIER(Option, NSAlternateKeyMask),
+ MODIFIER(Opt, NSAlternateKeyMask),
+ MODIFIER(Alt, NSAlternateKeyMask),
+ MODIFIER(Shift, NSShiftKeyMask),
+ MODIFIER(Command, NSCommandKeyMask),
+ MODIFIER(Cmd, NSCommandKeyMask),
+ MODIFIER(Meta, NSCommandKeyMask),
+ {NULL}
};
-
-enum MenuSymbolIdx {
- COMMAND_SYMBOL,
- OPTION_SYMBOL,
- CONTROL_SYMBOL,
- SHIFT_SYMBOL,
- CHECK_SYMBOL,
- DIAMDOND_SYMBOL,
- BULLET_SYMBOL,
- ELLIPSIS_SYMBOL,
+#undef MODIFIER
+
+#define ACCEL(n, c) {.name = #n, .len = sl(#n), .ch = c }
+static const struct {
+ const char *name; const size_t len; const UniChar ch;
+} specialAccelerators[] = {
+ ACCEL(PageUp, NSPageUpFunctionKey),
+ ACCEL(PageDown, NSPageDownFunctionKey),
+ ACCEL(Left, NSLeftArrowFunctionKey),
+ ACCEL(Right, NSRightArrowFunctionKey),
+ ACCEL(Up, NSUpArrowFunctionKey),
+ ACCEL(Down, NSDownArrowFunctionKey),
+ ACCEL(Escape, 0x001b),
+ ACCEL(Clear, NSClearDisplayFunctionKey),
+ ACCEL(Enter, NSEnterCharacter),
+ ACCEL(Backspace, NSBackspaceCharacter),
+ ACCEL(Space, ' '),
+ ACCEL(Tab, NSTabCharacter),
+ ACCEL(BackTab, NSBackTabCharacter),
+ ACCEL(Delete, NSDeleteCharacter),
+ ACCEL(Home, NSHomeFunctionKey),
+ ACCEL(End, NSEndFunctionKey),
+ ACCEL(Return, NSCarriageReturnCharacter),
+ ACCEL(Help, NSHelpFunctionKey),
+ ACCEL(Power, 0x233d),
+ ACCEL(Eject, 0xf804),
+ {NULL}
};
+#undef ACCEL
+#undef sl
-MenuRef tkCurrentAppleMenu = NULL;
-
-static SInt32 menuMarkColumnWidth = 0, menuMarkIndent = 0;
+static int gNoTkMenus = 0; /* This is used by Tk_MacOSXTurnOffMenus as
+ * the flag that Tk is not to draw any
+ * menus. */
+static int inPostMenu = 0;
+static unsigned long defaultBg = 0, defaultFg = 0;
+static SInt32 menuMarkColumnWidth = 0, menuIconTrailingEdgeMargin = 0;
static SInt32 menuTextLeadingEdgeMargin = 0, menuTextTrailingEdgeMargin = 0;
static SInt16 menuItemExtraHeight = 0, menuItemExtraWidth = 0;
static SInt16 menuSeparatorHeight = 0;
-/*
- * Forward declarations for procedures defined later in this file:
- */
-
-MODULE_SCOPE int TkMacOSXGetNewMenuID(Tcl_Interp *interp, TkMenu *menuInstPtr,
- int cascade, short *menuIDPtr);
-MODULE_SCOPE void TkMacOSXFreeMenuID(short menuID);
-
-static void CompleteIdlers(TkMenu *menuPtr);
-static void DrawMenuBarWhenIdle(ClientData clientData);
-static void DrawMenuEntryAccelerator(TkMenu *menuPtr, TkMenuEntry *mePtr,
- Drawable d, GC gc, Tk_Font tkfont, const Tk_FontMetrics *fmPtr,
- Tk_3DBorder activeBorder, int x, int y, int width, int height,
- int drawArrow);
-static void DrawMenuEntryBackground(TkMenu *menuPtr, TkMenuEntry *mePtr,
- Drawable d, Tk_3DBorder activeBorder, Tk_3DBorder bgBorder, int x,
- int y, int width, int heigth);
-static void DrawMenuEntryIndicator(TkMenu *menuPtr, TkMenuEntry *mePtr,
- Drawable d, GC gc, GC indicatorGC, Tk_Font tkfont,
- const Tk_FontMetrics *fmPtr, int x, int y, int width, int height);
-static void DrawMenuEntryLabel(TkMenu * menuPtr, TkMenuEntry *mePtr,
- Drawable d, GC gc, Tk_Font tkfont, const Tk_FontMetrics *fmPtr, int x,
- int y, int width, int height);
-static void DrawMenuSeparator(TkMenu *menuPtr, TkMenuEntry *mePtr, Drawable d,
- GC gc, Tk_Font tkfont, const Tk_FontMetrics *fmPtr, int x, int y,
- int width, int height);
-static void DrawTearoffEntry(TkMenu *menuPtr, TkMenuEntry *mePtr, Drawable d,
- GC gc, Tk_Font tkfont, const Tk_FontMetrics *fmPtr, int x, int y,
- int width, int height);
-static void EventuallyInvokeMenu(ClientData data);
-static void GetEntryText(TkMenuEntry *mePtr, Tcl_DString *dStringPtr);
-static void GetMenuAccelGeometry(TkMenu *menuPtr, TkMenuEntry *mePtr,
- Tk_Font tkfont, const Tk_FontMetrics *fmPtr, int *modWidthPtr,
- int *textWidthPtr, int *heightPtr);
-static void GetMenuLabelGeometry(TkMenuEntry *mePtr, Tk_Font tkfont,
- const Tk_FontMetrics *fmPtr, int *widthPtr, int *heightPtr);
-static void GetMenuIndicatorGeometry(TkMenu *menuPtr, TkMenuEntry *mePtr,
- Tk_Font tkfont, const Tk_FontMetrics *fmPtr, int *widthPtr,
- int *heightPtr);
-static void GetMenuSeparatorGeometry(TkMenu *menuPtr, TkMenuEntry *mePtr,
- Tk_Font tkfont, const Tk_FontMetrics *fmPtr, int *widthPtr,
- int *heightPtr);
-static TkMenuEntry* GetParentMenuEntry(TkMenu *menuPtr);
-static void GetTearoffEntryGeometry(TkMenu *menuPtr, TkMenuEntry *mePtr,
- Tk_Font tkfont, const Tk_FontMetrics *fmPtr, int *widthPtr,
- int *heightPtr);
-static char FindMarkCharacter(TkMenuEntry *mePtr);
-static int GetUtfMarkCharacter(char markChar, const char **markUtfPtr);
-static TkMenu* MenuPtrForMenuRef(MenuRef menu);
-static int ParseAccelerators(const char **accelStringPtr, int *modifierNumPtr,
- Tcl_UniChar *modifierUniChars, int *modifierWidth);
-static void MenuSelectEvent(TkMenu *menuPtr);
-static void ReconfigureIndividualMenu(TkMenu *menuPtr, MenuHandle macMenuHdl,
- int base);
-static void ReconfigureMacintoshMenu(ClientData clientData);
-static void RecursivelyClearActiveMenu(TkMenu *menuPtr);
-static void RecursivelyDeleteMenu(TkMenu *menuPtr);
-static void RecursivelyInsertMenu(TkMenu *menuPtr);
-static void SetDefaultMenubar(void);
-static int SetMenuCascade(TkMenu *menuPtr);
-
-#ifdef USE_TK_MDEF
-#define SCREEN_MARGIN 5
-static MacDrawable macMDEFDrawable;
- /* Drawable for use by MDEF code */
-static int MDEFScrollFlag = 0; /* Used so that popups don't scroll too soon.*/
-static MenuItemDrawingUPP tkThemeMenuItemDrawingUPP;
- /* Points to the UPP for theme Item drawing. */
-static Tcl_Obj *useMDEFVar;
-
-static void DrawMenuBackground(TkMenu *menuPtr, Rect *menuRectPtr,
- Drawable d);
-static void MenuDefProc(short message, MenuHandle menu, Rect *menuRectPtr,
- Point hitPt, short *whichItem );
-static void HandleMenuHiliteMsg(MenuRef menu, Rect *menuRectPtr, Point hitPt,
- SInt16 *whichItem, TkMenu *menuPtr);
-static void HandleMenuDrawMsg(MenuRef menu, Rect *menuRectPtr, Point hitPt,
- SInt16 *whichItem, TkMenu *menuPtr);
-static void HandleMenuFindItemMsg(MenuRef menu, Rect *menuRectPtr,
- Point hitPt, SInt16 *whichItem, TkMenu *menuPtr);
-static void HandleMenuPopUpMsg(MenuRef menu, Rect *menuRectPtr, Point hitPt,
- SInt16 *whichItem, TkMenu *menuPtr);
-static void HandleMenuCalcItemMsg(MenuRef menu, Rect *menuRectPtr, Point hitPt,
- SInt16 *whichItem, TkMenu *menuPtr);
-static void AppearanceEntryDrawWrapper(TkMenuEntry *mePtr, Rect * menuRectPtr,
- MenuTrackingData *mtdPtr, Drawable d, Tk_FontMetrics *fmPtr,
- Tk_Font tkfont, int erase);
-static pascal void ThemeMenuItemDrawingProc(const Rect *inBounds,
- SInt16 inDepth, Boolean inIsColorDevice, SInt32 inUserData);
-#else /* USE_TK_MDEF */
-# define useMDEF 0
-#endif /* USE_TK_MDEF */
-
-#define IS_THEME_MENU_FONT(tkfont) (strcmp(Tk_NameOfFont(tkfont), "menu") == 0)
-
-
-/*
- *----------------------------------------------------------------------
- *
- * DrawThemeText --
- *
- * Wrapper for DrawThemeTextBox API.
- *
- * Results:
- * None.
- *
- * Side effects:
- * None.
- *
- *----------------------------------------------------------------------
- */
+static void CheckForSpecialMenu(TkMenu *menuPtr);
+static NSString *ParseAccelerator(const char *accel, NSUInteger *maskPtr);
+static int GenerateMenuSelectEvent(TKMenu *menu, NSMenuItem *menuItem);
+static void MenuSelectEvent(TkMenu *menuPtr);
+static void RecursivelyClearActiveMenu(TkMenu *menuPtr);
+static int ModifierCharWidth(Tk_Font tkfont);
+
+#pragma mark TKMenu
+
+@interface TKMenu(TKMenuPrivate)
+- (id) initWithTkMenu: (TkMenu *) tkMenu;
+- (TkMenu *) tkMenu;
+- (int) tkIndexOfItem: (NSMenuItem *) menuItem;
+- (void) insertItem: (NSMenuItem *) newItem atTkIndex: (NSInteger) index;
+@end
+
+#if MAC_OS_X_VERSION_MAX_ALLOWED >= 1060
+#define TKMenu_NSMenuDelegate <NSMenuDelegate>
+#else
+#define TKMenu_NSMenuDelegate
+#endif
+@interface TKMenu(TKMenuDelegate) TKMenu_NSMenuDelegate
+@end
-static void
-DrawThemeText(
- Drawable d,
- GC gc,
- CFStringRef string,
- ThemeFontID font,
- ThemeDrawState drawState,
- const Rect* bounds,
- int baseline,
- int just)
+@implementation TKMenu
+- (void) setSpecial: (NSUInteger) special
{
- TkMacOSXDrawingContext dc;
- Rect adjustedBounds;
-
- /*
- * Menu item text drawn with the .Keyboard font (used for
- * kThemeMenuItemCmdKeyFont) won't always have the same ascent and
- * baseline as text drawn with the regular menu item font, since the
- * glyphs in the .Keyboard font may have a different height. Therefore, we
- * first determine the baseline of the text and then adjust the bounds
- * rect so the baseline aligns with the overall baseline of the menu item.
- */
- if (font == kThemeMenuItemCmdKeyFont) {
- Point size;
- SInt16 cmdKeyBaseline;
-
- GetThemeTextDimensions(string, font, drawState, false, &size,
- &cmdKeyBaseline);
- adjustedBounds = *bounds;
- OffsetRect(&adjustedBounds, 0, baseline - bounds->top - size.v -
- cmdKeyBaseline);
- bounds = &adjustedBounds;
- }
- if (TkMacOSXSetupDrawingContext(d, gc, 1, &dc)) {
- ChkErr(DrawThemeTextBox, string, font, drawState, false, bounds, just,
- dc.context);
- TkMacOSXRestoreDrawingContext(&dc);
- }
+ NSAssert(!_tkSpecial, @"Cannot change specialness of a special menu");
+ _tkSpecial = special;
}
-
-/*
- *----------------------------------------------------------------------
- *
- * MeasureThemeText --
- *
- * Wrapper for GetThemeTextDimensions API.
- *
- * Results:
- * None.
- *
- * Side effects:
- * None.
- *
- *----------------------------------------------------------------------
- */
-
-static int
-MeasureThemeText(
- CFStringRef string,
- ThemeFontID font)
+- (BOOL) isSpecial: (NSUInteger) special
{
- Point pt;
-
- ChkErr(GetThemeTextDimensions, string, font, kThemeStateActive, false, &pt,
- NULL);
- return pt.h;
+ return (_tkSpecial == special);
}
-
-/*
- *----------------------------------------------------------------------
- *
- * TkMacOSXUseID --
- *
- * Take the ID out of the available list for new menus. Used by the
- * default menu bar's menus so that they do not get created at the tk
- * level. See TkMacOSXGetNewMenuID for more information.
- *
- * Results:
- * Returns TCL_OK if the id was not in use. Returns TCL_ERROR if the
- * id was in use.
- *
- * Side effects:
- * A hash table entry in the command table is created with a NULL
- * value.
- *
- *----------------------------------------------------------------------
- */
+@end
-int
-TkMacOSXUseMenuID(
- short macID) /* The id to take out of the table */
+@implementation TKMenu(TKMenuPrivate)
+
+- (id) initWithTitle: (NSString *) aTitle
{
- Tcl_HashEntry *commandEntryPtr;
- int newEntry;
- int iMacID = macID; /* Do this to remove compiler warning */
-
- TkMenuInit();
- commandEntryPtr = Tcl_CreateHashEntry(&commandTable, (char *) iMacID,
- &newEntry);
- if (!newEntry) {
- return TCL_ERROR;
+ self = [super initWithTitle:aTitle];
+ if (self) {
+ _tkMenu = NULL;
+ _tkOffset = 0;
+ _tkItemCount = 0;
+ _tkSpecial = 0;
+ [self setDelegate:self];
}
- Tcl_SetHashValue(commandEntryPtr, NULL);
- return TCL_OK;
+ return self;
}
-
-/*
- *----------------------------------------------------------------------
- *
- * TkMacOSXGetNewMenuID --
- *
- * Allocates a new menu id and marks it in use. Each menu on the
- * mac must be designated by a unique id, which is a short. In
- * addition, some ids are reserved by the system. Since Tk uses
- * mostly dynamic menus, we must allocate and free these ids on
- * the fly. We use the id as a key into a hash table; if there
- * is no hash entry, we know that we can use the id.
- *
- * Carbon allows a much larger number of menus than the old APIs.
- * I believe this is 32768, but am not sure. This code just uses
- * 2000 as the upper limit. Unfortunately tk leaks menus when
- * cloning, under some circumstances (see bug on sourceforge).
- *
- * Results:
- * Returns TCL_OK if succesful; TCL_ERROR if there are no more
- * ids of the appropriate type to allocate. menuIDPtr contains
- * the new id if succesful.
- *
- * Side effects:
- * An entry is created for the menu in the command hash table,
- * and the hash entry is stored in the appropriate field in the
- * menu data structure.
- *
- *----------------------------------------------------------------------
- */
-int
-TkMacOSXGetNewMenuID(
- Tcl_Interp *interp, /* Used for error reporting */
- TkMenu *menuPtr, /* The menu we are working with */
- int cascade, /* 0 if we are working with a normal menu;
- * 1 if we are working with a cascade */
- short *menuIDPtr) /* The resulting id */
+- (id) initWithTkMenu: (TkMenu *) tkMenu
{
- int found = 0;
- int newEntry;
- Tcl_HashEntry *commandEntryPtr = NULL;
- short returnID = *menuIDPtr;
-
- /*
- * The following code relies on shorts and unsigned chars wrapping
- * when the highest value is incremented. Also, the values between
- * 236 and 255 inclusive are reserved for DA's by the Mac OS.
- */
-
- if (!cascade) {
- short curID = lastMenuID + 1;
+ NSString *title = [[NSString alloc] initWithUTF8String:
+ Tk_PathName(tkMenu->tkwin)];
- if (curID == 236) {
- curID = 256;
- }
-
- while (curID != lastMenuID) {
- int iCurID = curID;
- commandEntryPtr = Tcl_CreateHashEntry(&commandTable,
- (char *) iCurID, &newEntry);
- if (newEntry == 1) {
- found = 1;
- lastMenuID = returnID = curID;
- break;
- }
- curID++;
- if (curID == 236) {
- curID = 256;
- }
- }
- } else {
- /*
- * Cascade ids must be between 0 and 235 only, so they must be
- * dealt with separately.
- */
-
- short curID = lastCascadeID + 1;
-
- if (curID == 2000) {
- curID = 0;
- }
-
- while (curID != lastCascadeID) {
- int iCurID = curID;
- commandEntryPtr = Tcl_CreateHashEntry(&commandTable,
- (char *) iCurID, &newEntry);
- if (newEntry == 1) {
- found = 1;
- lastCascadeID = returnID = curID;
- break;
- }
- curID++;
- if (curID == 2000) {
- curID = 0;
- }
- }
- }
-
- if (!found) {
- Tcl_ResetResult(interp);
- Tcl_AppendResult(interp, "No more menus can be allocated.", NULL);
- return TCL_ERROR;
+ self = [self initWithTitle:title];
+ [title release];
+ if (self) {
+ _tkMenu = tkMenu;
}
- Tcl_SetHashValue(commandEntryPtr, (char *) menuPtr);
- *menuIDPtr = returnID;
- return TCL_OK;
+ return self;
}
-
-/*
- *----------------------------------------------------------------------
- *
- * TkMacOSXFreeMenuID --
- *
- * Marks the id as free.
- *
- * Results:
- * None.
- *
- * Side effects:
- * The hash table entry for the ID is cleared.
- *
- *----------------------------------------------------------------------
- */
-void
-TkMacOSXFreeMenuID(
- short menuID) /* The id to free */
+- (id) copyWithZone: (NSZone *) zone
{
- Tcl_HashEntry *entryPtr = Tcl_FindHashEntry(&commandTable,
- (char*)(intptr_t)menuID);
+ TKMenu *copy = [super copyWithZone:zone];
- if (entryPtr != NULL) {
- Tcl_DeleteHashEntry(entryPtr);
- }
- if (menuID == currentAppleMenuID) {
- currentAppleMenuID = 0;
- }
- if (menuID == currentHelpMenuID) {
- currentHelpMenuID = 0;
- }
+ NSAssert(_tkMenu == nil, @"Cannot copy tkMenu");
+ copy->_tkMenu = _tkMenu;
+ copy->_tkOffset = _tkOffset;
+ copy->_tkItemCount = _tkItemCount;
+ copy->_tkSpecial = _tkSpecial;
+ return copy;
}
-
-/*
- *----------------------------------------------------------------------
- *
- * MenuPtrForMenuRef --
- *
- * Returns a pointer to the TkMenu corresponding to a given
- * Carbon MenuRef.
- *
- * Results:
- * Returns a pointer to a TkMenu or NULL.
- *
- * Side effects:
- * None.
- *
- *----------------------------------------------------------------------
- */
-TkMenu*
-MenuPtrForMenuRef(
- MenuRef menu)
+- (TkMenu *) tkMenu
{
- TkMenu *menuPtr = NULL;
- MenuID menuID = GetMenuID(menu);
- Tcl_HashEntry *commandEntryPtr = Tcl_FindHashEntry(&commandTable,
- (char*)(intptr_t)menuID);
-
- if (commandEntryPtr) {
- menuPtr = (TkMenu *) Tcl_GetHashValue(commandEntryPtr);
- }
- return menuPtr;
+ return _tkMenu;
}
-
-/*
- *----------------------------------------------------------------------
- *
- * GetParentMenuEntry --
- *
- * Returns a pointer to the parent's TkMenuEntry of a given TkMenu.
- *
- * Results:
- * Returns a pointer to a TkMenuEntry or NULL.
- *
- * Side effects:
- * None.
- *
- *----------------------------------------------------------------------
- */
-TkMenuEntry*
-GetParentMenuEntry(
- TkMenu *menuPtr)
+- (int) tkIndexOfItem: (NSMenuItem *) menuItem
{
- TkMenuEntry *cascadeEntryPtr;
+ return [self indexOfItem:menuItem] - _tkOffset;
+}
- for (cascadeEntryPtr = menuPtr->menuRefPtr->parentEntryPtr;
- cascadeEntryPtr != NULL;
- cascadeEntryPtr = cascadeEntryPtr->nextCascadePtr) {
- const char *name = (cascadeEntryPtr->namePtr == NULL) ? ""
- : Tcl_GetString(cascadeEntryPtr->namePtr);
+- (void) insertItem: (NSMenuItem *) newItem atTkIndex: (NSInteger) index
+{
+ [super insertItem:newItem atIndex:index + _tkOffset];
+ _tkItemCount++;
+}
- if (strcmp(name, Tk_PathName(menuPtr->tkwin)) == 0) {
- break;
+- (void) insertItem: (NSMenuItem *) newItem atIndex: (NSInteger) index
+{
+ if (_tkMenu && index >= 0) {
+ if ((NSUInteger)index <= _tkOffset) {
+ _tkOffset++;
+ } else {
+ NSAssert((NSUInteger)index >= _tkItemCount + _tkOffset,
+ @"Cannot insert in the middle of Tk menu");
}
}
- return cascadeEntryPtr;
+ [super insertItem:newItem atIndex:index];
}
-
-/*
- *----------------------------------------------------------------------
- *
- * TkpNewMenu --
- *
- * Gets a new blank menu. Only the platform specific options are filled
- * in.
- *
- * Results:
- * Returns a standard TCL error.
- *
- * Side effects:
- * Allocates a Macintosh menu handle and puts in the platformData
- * field of the menuPtr.
- *
- *----------------------------------------------------------------------
- */
-int
-TkpNewMenu(
- TkMenu *menuPtr) /* The common structure we are making the
- * platform structure for. */
+- (void) removeItemAtIndex: (NSInteger) index
{
- short menuID;
- MenuRef macMenuHdl;
-#ifdef USE_TK_MDEF
- MenuDefSpec menuDefSpec;
- Tcl_Obj *useMDEFObjPtr;
- int useMDEF = 1;
-#endif
- int error = TCL_OK;
- OSStatus err;
- CFStringRef cfStr;
-
- error = TkMacOSXGetNewMenuID(menuPtr->interp, menuPtr, 0, &menuID);
- if (error != TCL_OK) {
- return error;
- }
- err = ChkErr(CreateNewMenu, menuID, kMenuAttrDoNotUseUserCommandKeys,
- &macMenuHdl);
- if (err != noErr) {
- Tcl_AppendResult(menuPtr->interp, "CreateNewMenu failed.", NULL);
- return TCL_ERROR;
- }
- cfStr = CFStringCreateWithCString(NULL, Tk_PathName(menuPtr->tkwin),
- kCFStringEncodingUTF8);
- if (!cfStr) {
- Tcl_AppendResult(menuPtr->interp, "CFStringCreateWithCString failed.",
- NULL);
- return TCL_ERROR;
- }
- err = ChkErr(SetMenuTitleWithCFString, macMenuHdl, cfStr);
- CFRelease(cfStr);
- if (err != noErr) {
- Tcl_AppendResult(menuPtr->interp, "SetMenuTitleWithCFString failed.",
- NULL);
- return TCL_ERROR;
+ if (_tkMenu && index >= 0) {
+ if ((NSUInteger)index < _tkOffset) {
+ _tkOffset--;
+ } else if ((NSUInteger)index < _tkItemCount + _tkOffset) {
+ _tkItemCount--;
+ }
}
+ [super removeItemAtIndex:index];
+}
- menuPtr->platformData = (TkMenuPlatformData) ckalloc(sizeof(MacMenu));
- ((MacMenu *) menuPtr->platformData)->menuHdl = macMenuHdl;
+- (NSMenuItem *) newTkMenuItem: (TkMenuEntry *) mePtr
+{
+ NSMenuItem *menuItem = [[NSMenuItem alloc] initWithTitle:@""
+ action:@selector(tkMenuItemInvoke:) keyEquivalent:@""];
-#ifdef USE_TK_MDEF
- /*
- * Check whether we want to use the custom mdef or not. For now
- * the default is to use it unless the variable is explicitly
- * set to no.
- */
+ [menuItem setTarget:self];
+ [menuItem setTag:(NSInteger)mePtr];
+ return menuItem;
+}
+@end
- useMDEFObjPtr = Tcl_ObjGetVar2(menuPtr->interp, useMDEFVar, NULL,
- TCL_GLOBAL_ONLY);
- if (useMDEFObjPtr == NULL || Tcl_GetBooleanFromObj(NULL, useMDEFObjPtr,
- &useMDEF) == TCL_ERROR || useMDEF) {
- menuDefSpec.defType = kMenuDefProcPtr;
- menuDefSpec.u.defProc = MenuDefProc;
- ChkErr(SetMenuDefinition, macMenuHdl, &menuDefSpec);
- }
- ((MacMenu *) menuPtr->platformData)->useMDEF = useMDEF;
-#endif /* USE_TK_MDEF */
-
- if ((currentMenuBarInterp == menuPtr->interp)
- && (currentMenuBarName != NULL)) {
- Tk_Window parentWin = Tk_Parent(menuPtr->tkwin);
-
- if (strcmp(currentMenuBarName, Tk_PathName(parentWin)) == 0) {
- if ((strcmp(Tk_PathName(menuPtr->tkwin)
- + strlen(Tk_PathName(parentWin)), ".apple") == 0)
- || (strcmp(Tk_PathName(menuPtr->tkwin)
- + strlen(Tk_PathName(parentWin)), ".help") == 0)) {
- if (!(menuBarFlags & MENUBAR_REDRAW_PENDING)) {
- Tcl_DoWhenIdle(DrawMenuBarWhenIdle, NULL);
- menuBarFlags |= MENUBAR_REDRAW_PENDING;
- }
- }
- }
- }
+@implementation TKMenu(TKMenuActions)
+// target methods
- menuPtr->menuFlags |= MENU_RECONFIGURE_PENDING;
- Tcl_DoWhenIdle(ReconfigureMacintoshMenu, (ClientData) menuPtr);
- return TCL_OK;
+- (BOOL) validateMenuItem: (NSMenuItem *) menuItem
+{
+ return [menuItem isEnabled];
}
-
-/*
- *----------------------------------------------------------------------
- *
- * TkpDestroyMenu --
- *
- * Destroys platform-specific menu structures.
- *
- * Results:
- * None.
- *
- * Side effects:
- * All platform-specific allocations are freed up.
- *
- *----------------------------------------------------------------------
- */
-void
-TkpDestroyMenu(
- TkMenu *menuPtr) /* The common menu structure */
+- (void) tkMenuItemInvoke: (id) sender
{
- MenuRef macMenuHdl = ((MacMenu *) menuPtr->platformData)->menuHdl;
+ /*
+ * With the delegate matching key equivalents, when a menu action is sent
+ * in response to a key equivalent, sender is the whole menu and not the
+ * the specific menu item, use this to ignore key equivalents for our
+ * menus (as Tk handles them directly via bindings).
+ */
- if (menuPtr->menuFlags & MENU_RECONFIGURE_PENDING) {
- Tcl_CancelIdleCall(ReconfigureMacintoshMenu, (ClientData) menuPtr);
- menuPtr->menuFlags &= ~MENU_RECONFIGURE_PENDING;
- }
- if (GetMenuID(macMenuHdl) == currentHelpMenuID) {
- MenuRef helpMenuHdl;
- MenuItemIndex helpIndex;
+ if ([sender isKindOfClass:[NSMenuItem class]]) {
+ NSMenuItem *menuItem = (NSMenuItem *)sender;
+ TkMenu *menuPtr = (TkMenu *)_tkMenu;
+ TkMenuEntry *mePtr = (TkMenuEntry *)[menuItem tag];
+
+ if (menuPtr && mePtr) {
+ Tcl_Interp *interp = menuPtr->interp;
+ /*Add time for errors to fire if necessary. This is sub-optimal but avoids issues with Tcl/Cocoa event loop integration.*/
+ Tcl_Sleep(100);
- if ((HMGetHelpMenu(&helpMenuHdl,&helpIndex) == noErr)
- && (helpMenuHdl != NULL)) {
- int i, count = CountMenuItems(helpMenuHdl);
+ Tcl_Preserve(interp);
+ Tcl_Preserve(menuPtr);
- for (i = helpIndex; i <= count; i++) {
- DeleteMenuItem(helpMenuHdl, helpIndex);
+ int result = TkInvokeMenu(interp, menuPtr, mePtr->index);
+
+ if (result != TCL_OK && result != TCL_CONTINUE &&
+ result != TCL_BREAK) {
+ Tcl_AddErrorInfo(interp, "\n (menu invoke)");
+ Tcl_BackgroundError(interp);
}
+ Tcl_Release(menuPtr);
+ Tcl_Release(interp);
}
- currentHelpMenuID = 0;
- }
- if (menuPtr->platformData != NULL) {
- MenuID menuID = GetMenuID(macMenuHdl);
-
- DeleteMenu(menuID);
- TkMacOSXFreeMenuID(menuID);
- DisposeMenu(macMenuHdl);
- ckfree((char *) menuPtr->platformData);
- menuPtr->platformData = NULL;
}
}
-
-/*
- *----------------------------------------------------------------------
- *
- * SetMenuCascade --
- *
- * Does any cleanup to change a menu from a normal to a cascade.
- *
- * Results:
- * Standard Tcl error.
- *
- * Side effects:
- * The mac menu id is reset.
- *
- *----------------------------------------------------------------------
- */
+@end
-int
-SetMenuCascade(
- TkMenu* menuPtr) /* The menu we are setting up to be a
- * cascade. */
-{
- MenuHandle macMenuHdl = ((MacMenu *) menuPtr->platformData)->menuHdl;
- MenuID newMenuID, menuID = GetMenuID(macMenuHdl);
- int error = TCL_OK;
-
- if (menuID >= 256) {
- error = TkMacOSXGetNewMenuID(menuPtr->interp, menuPtr, 1, &newMenuID);
- if (error == TCL_OK) {
- TkMacOSXFreeMenuID(menuID);
- SetMenuID(macMenuHdl,newMenuID);
- }
- }
- return error;
-}
-
-/*
- *----------------------------------------------------------------------
- *
- * TkpDestroyMenuEntry --
- *
- * Cleans up platform-specific menu entry items.
- *
- * Results:
- * None
- *
- * Side effects:
- * All platform-specific allocations are freed up.
- *
- *----------------------------------------------------------------------
- */
+@implementation TKMenu(TKMenuDelegate)
+#define keyEquivModifiersMatch(km, m) (( \
+ ((km) & NSCommandKeyMask) != ((m) & NSCommandKeyMask) || \
+ ((km) & NSAlternateKeyMask) != ((m) & NSAlternateKeyMask) || \
+ ((km) & NSControlKeyMask) != ((m) & NSControlKeyMask) || \
+ (((km) & NSShiftKeyMask) != ((m) & NSShiftKeyMask) && \
+ ((m) & NSFunctionKeyMask))) ? NO : YES)
-void
-TkpDestroyMenuEntry(
- TkMenuEntry *mePtr) /* The common structure for the menu entry. */
+- (BOOL) menuHasKeyEquivalent: (NSMenu *) menu forEvent: (NSEvent *) event
+ target: (id *) target action: (SEL *) action
{
- TkMenu *menuPtr = mePtr->menuPtr;
+ /*Use lowercaseString to keep "shift" from firing twice if bound to different procedure.*/
+ NSString *key = [[event charactersIgnoringModifiers] lowercaseString];
+ NSUInteger modifiers = [event modifierFlags] &
+ NSDeviceIndependentModifierFlagsMask;
- ckfree((char *) mePtr->platformEntryData);
- if ((menuPtr->platformData != NULL)
- && !(menuPtr->menuFlags & MENU_RECONFIGURE_PENDING)) {
- menuPtr->menuFlags |= MENU_RECONFIGURE_PENDING;
- Tcl_DoWhenIdle(ReconfigureMacintoshMenu, (ClientData) menuPtr);
+ if (modifiers == (NSCommandKeyMask | NSShiftKeyMask) &&
+ [key compare:@"?"] == NSOrderedSame) {
+ return NO;
}
-}
-
-/*
- *----------------------------------------------------------------------
- *
- * GetEntryText --
- *
- * Given a menu entry, gives back the text that should go in it.
- * Separators should be done by the caller, as they have to be
- * handled specially. This is primarily used to do a substitution
- * between "..." and the ellipsis character which looks nicer.
- *
- * Results:
- * itemText points to the new text for the item.
- *
- * Side effects:
- * None.
- *
- *----------------------------------------------------------------------
- */
-void
-GetEntryText(
- TkMenuEntry *mePtr, /* A pointer to the menu entry. */
- Tcl_DString *dStringPtr) /* The DString to put the text into. This
- * will be initialized by this routine. */
-{
-#ifdef USE_TK_MDEF
- const int useMDEF = ((MacMenu *) mePtr->menuPtr->platformData)->useMDEF;
-#endif
- int noLabel = (mePtr->labelPtr == NULL || mePtr->labelLength == 0);
-
- Tcl_DStringInit(dStringPtr);
- if (mePtr->type == TEAROFF_ENTRY && (useMDEF || noLabel)) {
- Tcl_DStringAppend(dStringPtr, "(Tear-off)", -1);
- } else if (mePtr->imagePtr != NULL && (useMDEF || noLabel) &&
- mePtr->compound == COMPOUND_NONE) {
- Tcl_DStringAppend(dStringPtr, "(Image)", -1);
- } else if (mePtr->bitmapPtr != NULL && (useMDEF || noLabel) &&
- mePtr->compound == COMPOUND_NONE) {
- Tcl_DStringAppend(dStringPtr, "(Pixmap)", -1);
- } else if (noLabel) {
- /*
- * The Mac menu manager does not like null strings.
- */
-
- Tcl_DStringAppend(dStringPtr, " ", -1);
- } else {
- int length;
- char *text = Tcl_GetStringFromObj(mePtr->labelPtr, &length);
- char *dStringText;
- int i;
-
- for (i = 0; *text; text++, i++) {
- if ((*text == '.') && (*(text+1) == '.') && (*(text+2) == '.')) {
- Tcl_DStringAppend(dStringPtr, menuSymbols[ELLIPSIS_SYMBOL].utf,
- menuSymbols[ELLIPSIS_SYMBOL].utfLen);
- i += menuSymbols[ELLIPSIS_SYMBOL].utfLen - 1;
- text += 2;
- } else {
- Tcl_DStringSetLength(dStringPtr,
- Tcl_DStringLength(dStringPtr) + 1);
- dStringText = Tcl_DStringValue(dStringPtr);
- dStringText[i] = *text;
+ // For command key, take input manager's word so things
+ // like dvorak / qwerty layout work.
+ if (([event modifierFlags] & NSCommandKeyMask) == NSCommandKeyMask) {
+ key = [event characters];
+ }
+
+ NSArray *itemArray = [self itemArray];
+
+ for (NSMenuItem *item in itemArray) {
+ if ([item isEnabled] && [[item keyEquivalent] compare:key] ==
+ NSOrderedSame) {
+ NSUInteger keyEquivModifiers = [item keyEquivalentModifierMask];
+
+ if (keyEquivModifiersMatch(keyEquivModifiers, modifiers)) {
+ *target = [item target];
+ *action = [item action];
+ return YES;
}
}
}
+ return NO;
}
-
-/*
- *----------------------------------------------------------------------
- *
- * FindMarkCharacter --
- *
- * Finds the Macintosh mark character based on the font of the
- * item. We calculate a good mark character based on the font
- * that this item is rendered in.
- *
- * Results:
- * Mark char.
- *
- * Side effects:
- * None.
- *
- *----------------------------------------------------------------------
- */
-char
-FindMarkCharacter(
- TkMenuEntry *mePtr) /* The entry we are finding the character
- * for. */
+- (void) menuWillOpen: (NSMenu *) menu
{
- static const char markChars[] = {kCheckCharCode, kDiamondCharCode,
- kBulletCharCode, '-', kCheckCharCode};
- const char *markChar = markChars;
- int i = sizeof(markChars);
- Tk_Font tkfont;
-
- tkfont = Tk_GetFontFromObj(mePtr->menuPtr->tkwin,
- (mePtr->fontPtr == NULL) ? mePtr->menuPtr->fontPtr
- : mePtr->fontPtr);
-
- while (--i) {
- if (!TkMacOSXIsCharacterMissing(tkfont, *markChar)) {
- break;
- }
- markChar++;
+ if (_tkMenu) {
+ //RecursivelyClearActiveMenu(_tkMenu);
+ GenerateMenuSelectEvent((TKMenu *)[self supermenu],
+ [self itemInSupermenu]);
}
- return *markChar;
}
-
-/*
- *----------------------------------------------------------------------
- *
- * GetUtfMarkCharacter --
- *
- * Get the utf8 string for the given mark character, taking into
- * account the special menu font char codes.
- *
- * Results:
- * Length of returned utf8 string.
- *
- * Side effects:
- * None.
- *
- *----------------------------------------------------------------------
- */
-int
-GetUtfMarkCharacter(
- char markChar,
- const char **markUtfPtr)
+- (void) menuDidClose: (NSMenu *) menu
{
- const MenuSymbol *ms = menuSymbols;
- int len = 0;
-
- while (ms->unicode) {
- if (ms->charCode && ms->charCode == markChar) {
- *markUtfPtr = ms->utf;
- len = ms->utfLen;
- break;
- }
- ms++;
+ if (_tkMenu) {
+ RecursivelyClearActiveMenu(_tkMenu);
}
- if (!len) {
- static char markUtf[TCL_UTF_MAX + 1];
-
- Tcl_ExternalToUtf(NULL, TkMacOSXCarbonEncoding, &markChar, 1, 0, NULL,
- markUtf, TCL_UTF_MAX + 1, NULL, &len, NULL);
- *markUtfPtr = markUtf;
- }
- return len;
}
-
-/*
- *----------------------------------------------------------------------
- *
- * ParseAccelerators --
- *
- * Parse menu accelerator string.
- *
- * Results:
- * Accelerator flags.
- *
- * Side effects:
- * None.
- *
- *----------------------------------------------------------------------
- */
-int
-ParseAccelerators(
- const char **accelStringPtr,
- int *modifierNumPtr,
- Tcl_UniChar *modifierUniChars,
- int *modifierWidth)
+- (void) menu: (NSMenu *) menu willHighlightItem: (NSMenuItem *) item
{
- struct Modif {
- const char *name;
- const size_t len;
- const int flag, symbol;
- };
-#define MODIF(n, f) { #n, sizeof(#n)-1, ENTRY_##f##_ACCEL, f##_SYMBOL }
- static const struct Modif modifs[] = {
- MODIF(Control, CONTROL),
- MODIF(Ctrl, CONTROL),
- MODIF(Option, OPTION),
- MODIF(Opt, OPTION),
- MODIF(Alt, OPTION),
- MODIF(Shift, SHIFT),
- MODIF(Command, COMMAND),
- MODIF(Cmd, COMMAND),
- MODIF(Meta, COMMAND),
- { NULL, 0, 0, 0}
- };
-#undef MODIF
- const char *accelString = *accelStringPtr;
- int flags = 0, num = 0, seen = 0, width = 0;
- const struct Modif *m;
-
- while (1) {
- m = modifs;
- while (m->name) {
- int l = m->len;
-
- if (!strncasecmp(accelString, m->name, l) &&
- (accelString[l] == '-' || accelString[l] == '+')) {
- flags |= m->flag;
- accelString += l+1;
- break;
- }
- m++;
- }
- if (!m->name || !*accelString) {
- break;
- }
- }
- m = modifs;
- while (m->name && num < MODIFIER_NUM) {
- if (flags & m->flag && !(seen & m->flag)) {
- modifierUniChars[num++] = menuSymbols[m->symbol].unicode;
- width += menuSymbols[m->symbol].width;
- seen |= m->flag;
- }
- m++;
+ if (_tkMenu) {
+ GenerateMenuSelectEvent(self, item);
}
- *accelStringPtr = accelString;
- *modifierNumPtr = num;
- *modifierWidth = width;
- return flags;
}
-
-/*
- *----------------------------------------------------------------------
- *
- * TkpConfigureMenuEntry --
- *
- * Processes configurations for menu entries.
- *
- * Results:
- * Returns standard TCL result. If TCL_ERROR is returned, then
- * the interp's result contains an error message.
- *
- * Side effects:
- * Configuration information get set for mePtr; old resources
- * get freed, if any need it.
- *
- *----------------------------------------------------------------------
- */
-int
-TkpConfigureMenuEntry(
- TkMenuEntry *mePtr) /* Information about menu entry; may
- * or may not already have values for
- * some fields. */
+- (void) menuNeedsUpdate: (NSMenu *) menu
{
- TkMenu *menuPtr = mePtr->menuPtr;
- EntryGeometry *geometryPtr = (EntryGeometry *) mePtr->platformEntryData;
-
- /*
- * Cascade menus have to have menu IDs of less than 256. So
- * we need to change the child menu if this has been configured
- * for a cascade item.
- */
-
- if (mePtr->type == CASCADE_ENTRY) {
- if ((mePtr->childMenuRefPtr != NULL)
- && (mePtr->childMenuRefPtr->menuPtr != NULL)) {
- MenuHandle childMenuHdl = ((MacMenu *) mePtr
- ->childMenuRefPtr->menuPtr->platformData)->menuHdl;
+ TkMenu *menuPtr = (TkMenu *) _tkMenu;
- if (childMenuHdl != NULL) {
- int error = SetMenuCascade(mePtr->childMenuRefPtr->menuPtr);
+ if (menuPtr) {
+ Tcl_Interp *interp = menuPtr->interp;
- if (error != TCL_OK) {
- return error;
- }
+ Tcl_Preserve(interp);
+ Tcl_Preserve(menuPtr);
- if (menuPtr->menuType == MENUBAR) {
- CFStringRef cfStr = CFStringCreateWithCString(NULL,
- (!(mePtr->labelPtr) ? "" :
- Tcl_GetString(mePtr->labelPtr)),
- kCFStringEncodingUTF8);
+ int result = TkPostCommand(_tkMenu);
- if (cfStr) {
- SetMenuTitleWithCFString(childMenuHdl, cfStr);
- CFRelease(cfStr);
- }
- }
- }
+ if (result!=TCL_OK && result!=TCL_CONTINUE && result!=TCL_BREAK) {
+ Tcl_AddErrorInfo(interp, "\n (menu preprocess)");
+ Tcl_BackgroundError(interp);
}
+ Tcl_Release(menuPtr);
+ Tcl_Release(interp);
}
+}
+@end
- /*
- * We need to parse the accelerator string. If it has the strings
- * for Command, Control, Shift or Option, we need to flag it
- * so we can draw the symbols for it. We also need to precalcuate
- * the position of the first real character we are drawing.
- */
+#pragma mark TKApplication(TKMenu)
- if (0 == mePtr->accelLength) {
- geometryPtr->accelTextStart = -1;
- } else {
- const char *accelString = (mePtr->accelPtr == NULL) ? ""
- : Tcl_GetString(mePtr->accelPtr);
- const char *accelStart = accelString;
-
- mePtr->entryFlags &= ~ENTRY_ACCEL_MASK;
- mePtr->entryFlags |= ParseAccelerators(&accelString,
- &geometryPtr->modifierNum, geometryPtr->modifierUniChars,
- &geometryPtr->modifierWidth);
- geometryPtr->accelTextStart = (ptrdiff_t)(accelString - accelStart);
- }
+@interface NSApplication(TKMenu)
+- (void) setAppleMenu: (NSMenu *) menu;
+@end
- if (!(menuPtr->menuFlags & MENU_RECONFIGURE_PENDING)) {
- menuPtr->menuFlags |= MENU_RECONFIGURE_PENDING;
- Tcl_DoWhenIdle(ReconfigureMacintoshMenu, (ClientData) menuPtr);
- }
+@implementation TKApplication(TKMenu)
- return TCL_OK;
+- (void) menuBeginTracking: (NSNotification *) notification
+{
+#ifdef TK_MAC_DEBUG_NOTIFICATIONS
+ TKLog(@"-[%@(%p) %s] %@", [self class], self, _cmd, notification);
+#endif
+ //TkMacOSXClearMenubarActive();
+ //TkMacOSXPreprocessMenu();
}
-
-/*
- *----------------------------------------------------------------------
- *
- * ReconfigureIndividualMenu --
- *
- * This routine redoes the guts of the menu. It works from
- * a base item and offset, so that a regular menu will
- * just have all of its items added, but the help menu will
- * have all of its items appended after the apple-defined
- * items.
- *
- * Results:
- * None.
- *
- * Side effects:
- * The Macintosh menu handle is updated
- *
- *----------------------------------------------------------------------
- */
-void
-ReconfigureIndividualMenu(
- TkMenu *menuPtr, /* The menu we are affecting. */
- MenuHandle macMenuHdl, /* The macintosh menu we are affecting.
- * Will not necessarily be
- * menuPtr->platformData because this could
- * be the help menu. */
- int base) /* The last index that we do not want
- * touched. 0 for normal menus;
- * # of system help menu items
- * for help menus. */
+- (void) menuEndTracking: (NSNotification *) notification
{
- int count;
- int index;
- TkMenuEntry *mePtr;
- int parentDisabled = 0;
-
-#ifdef TK_MAC_DEBUG_MENUS
- /*
- * Carbon-internal menu debugging (c.f. Technote 2124)
- */
-
- TkMacOSXInitNamedDebugSymbol(HIToolbox, void, DebugPrintMenu,
- MenuRef menu);
- if (DebugPrintMenu) {
- DebugPrintMenu(macMenuHdl);
- }
+#ifdef TK_MAC_DEBUG_NOTIFICATIONS
+ TKLog(@"-[%@(%p) %s] %@", [self class], self, _cmd, notification);
#endif
-
- mePtr = GetParentMenuEntry(menuPtr);
- if (mePtr && mePtr->state == ENTRY_DISABLED) {
- parentDisabled = 1;
+ if (!inPostMenu) {
+ TkMacOSXClearMenubarActive();
}
+}
- /*
- * First, we get rid of all of the old items.
- */
-
- count = CountMenuItems(macMenuHdl);
- for (index = base; index < count; index++) {
- DeleteMenuItem(macMenuHdl, base + 1);
+- (void) tkSetMainMenu: (TKMenu *) menu
+{
+ if (gNoTkMenus) {
+ return;
}
- count = menuPtr->numEntries;
+ TKMenu *applicationMenu = nil;
- for (index = 1; index <= count; index++) {
- mePtr = menuPtr->entries[index - 1];
+ if (menu) {
+ NSMenuItem *applicationMenuItem = [menu numberOfItems] ?
+ [menu itemAtIndex:0] : nil;
- /*
- * We have to do separators separately because SetMenuItemText
- * does not parse meta-characters.
- */
+ if (![menu isSpecial:tkMainMenu]) {
+ TkMenuEntry *mePtr = (TkMenuEntry *)[applicationMenuItem tag];
- if (mePtr->type == SEPARATOR_ENTRY) {
- AppendMenuItemTextWithCFString(macMenuHdl, NULL,
- kMenuItemAttrSeparator | kMenuItemAttrDisabled, 0, NULL);
- } else {
- Tcl_DString itemTextDString;
- CFStringRef cfStr;
-
- GetEntryText(mePtr, &itemTextDString);
- cfStr = CFStringCreateWithCString(NULL,
- Tcl_DStringValue(&itemTextDString), kCFStringEncodingUTF8);
- if (cfStr) {
- AppendMenuItemTextWithCFString(macMenuHdl, cfStr, 0, 0, NULL);
- CFRelease(cfStr);
- } else {
- AppendMenuItemTextWithCFString(macMenuHdl, CFSTR ("<Error>"),
- 0, 0, NULL);
+ if (!mePtr || !(mePtr->entryFlags & ENTRY_APPLE_MENU)) {
+ applicationMenuItem = [NSMenuItem itemWithSubmenu:
+ [[_defaultApplicationMenu copy] autorelease]];
+ [menu insertItem:applicationMenuItem atIndex:0];
}
- Tcl_DStringFree(&itemTextDString);
-
- /*
- * Set enabling and disabling correctly.
- */
-
- if (parentDisabled || (mePtr->state == ENTRY_DISABLED)) {
- DisableMenuItem(macMenuHdl, base + index);
- } else {
- EnableMenuItem(macMenuHdl, base + index);
+ [menu setSpecial:tkMainMenu];
+ }
+ applicationMenu = (TKMenu *)[applicationMenuItem submenu];
+ if (![applicationMenu isSpecial:tkApplicationMenu]) {
+ for (NSMenuItem *item in _defaultApplicationMenuItems) {
+ [applicationMenu addItem:[[item copy] autorelease]];
}
+ [applicationMenu setSpecial:tkApplicationMenu];
+ }
- /*
- * Set the check mark for check entries and radio entries.
- */
+ NSArray *itemArray = [menu itemArray];
- SetItemMark(macMenuHdl, base + index, 0);
- if ((mePtr->type == CHECK_BUTTON_ENTRY)
- || (mePtr->type == RADIO_BUTTON_ENTRY)) {
- CheckMenuItem(macMenuHdl, base + index, (mePtr->entryFlags
- & ENTRY_SELECTED) && mePtr->indicatorOn);
- if (mePtr->indicatorOn
- && (mePtr->entryFlags & ENTRY_SELECTED)) {
- SetItemMark(macMenuHdl, base + index,
- FindMarkCharacter(mePtr));
- }
- }
+ for (NSMenuItem *item in itemArray) {
+ TkMenuEntry *mePtr = (TkMenuEntry *)[item tag];
+ TKMenu *submenu = (TKMenu *)[item submenu];
- if (mePtr->type == CASCADE_ENTRY) {
- if ((mePtr->childMenuRefPtr != NULL)
- && (mePtr->childMenuRefPtr->menuPtr != NULL)) {
- MenuHandle childMenuHdl =
- ((MacMenu *) mePtr->childMenuRefPtr
- ->menuPtr->platformData)->menuHdl;
-
- if (childMenuHdl != NULL) {
- ChkErr(SetMenuItemHierarchicalID, macMenuHdl,
- base + index, GetMenuID(childMenuHdl));
- }
- /*
- * If we changed the highligthing of this menu, its
- * children all have to be reconfigured so that
- * their state will be reflected in the menubar.
- */
-
- if (!(mePtr->childMenuRefPtr->menuPtr->menuFlags
- & MENU_RECONFIGURE_PENDING)) {
- mePtr->childMenuRefPtr->menuPtr->menuFlags
- |= MENU_RECONFIGURE_PENDING;
- Tcl_DoWhenIdle(ReconfigureMacintoshMenu,
- (ClientData) mePtr->childMenuRefPtr->menuPtr);
- }
- }
- }
+ if (mePtr && submenu) {
+ if ((mePtr->entryFlags & ENTRY_WINDOWS_MENU) &&
+ ![submenu isSpecial:tkWindowsMenu]) {
+ NSInteger index = 0;
- if ((mePtr->type != CASCADE_ENTRY) && (mePtr->accelPtr != NULL)) {
- int accelLen, modifiers = 0, hasCmd = 0;
- EntryGeometry *geometryPtr =
- (EntryGeometry*)mePtr->platformEntryData;
- int offset = geometryPtr->accelTextStart;
- char *accel = Tcl_GetStringFromObj(mePtr->accelPtr, &accelLen);
-
- accelLen -= offset;
- accel += offset;
- if (mePtr->entryFlags & ENTRY_OPTION_ACCEL) {
- modifiers |= kMenuOptionModifier;
- }
- if (mePtr->entryFlags & ENTRY_SHIFT_ACCEL) {
- modifiers |= kMenuShiftModifier;
- }
- if (mePtr->entryFlags & ENTRY_CONTROL_ACCEL) {
- modifiers |= kMenuControlModifier;
- }
- if (mePtr->entryFlags & ENTRY_COMMAND_ACCEL) {
- hasCmd = 1;
- }
- if (accelLen == 1) {
- if (hasCmd || (modifiers != 0 && modifiers !=
- kMenuShiftModifier)) {
- SetItemCmd(macMenuHdl, base + index, accel[0]);
- if (!hasCmd) {
- modifiers |= kMenuNoCommandModifier;
- }
- }
- } else {
- /*
- * Convert from accelerator names to Carbon menu glyphs.
- */
- struct Glyph {
- const char *name;
- const size_t len;
- const char glyph;
- };
-#define GLYPH(n, g) { #n, sizeof(#n)-1, kMenu##g##Glyph }
- static const struct Glyph glyphs[] = {
- GLYPH(PageUp, PageUp),
- GLYPH(PageDown, PageDown),
- GLYPH(Left, LeftArrow),
- GLYPH(Right, RightArrow),
- GLYPH(Up, UpArrow),
- GLYPH(Down, DownArrow),
- GLYPH(Escape, Escape),
- GLYPH(Clear, Clear),
- GLYPH(Enter, Enter),
- GLYPH(Backspace,DeleteLeft),
- GLYPH(Space, Space),
- GLYPH(Tab, TabRight),
- GLYPH(Delete, DeleteRight),
- GLYPH(Home, NorthwestArrow),
- GLYPH(End, SoutheastArrow),
- GLYPH(Return, Return),
- GLYPH(Help, Help),
- GLYPH(Power, Power),
- { NULL, 0, 0}
- };
-#undef GLYPH
- const struct Glyph *g = glyphs;
- char glyph = 0;
-
- if (accel[0] == 'F' && accelLen < 4 &&
- (accel[1] > '0' && accel[1] <= '9')) {
- int fkey = accel[1] - '0';
-
- if (accelLen == 3) {
- if (accel[2] >= '0' && accel[2] <= '9') {
- fkey = 10 * fkey + (accel[2] - '0');
- } else {
- fkey = 0;
- }
- }
- if (fkey >= 1 && fkey <= 12) {
- glyph = kMenuF1Glyph + fkey - 1;
- } else if (fkey >= 13 && fkey <= 15) {
- glyph = kMenuF13Glyph + fkey - 13;
- }
- } else while (g->name) {
- if (accel[0] == g->name[0] &&
- (size_t)accelLen == g->len &&
- !strncasecmp(accel, g->name, g->len)) {
- glyph = g->glyph;
- break;
- }
- g++;
+ for (NSMenuItem *i in _defaultWindowsMenuItems) {
+ [submenu insertItem:[[i copy] autorelease] atIndex:
+ index++];
}
- if (glyph) {
- ChkErr(SetMenuItemKeyGlyph, macMenuHdl, base + index,
- glyph);
- if (!hasCmd) {
- modifiers |= kMenuNoCommandModifier;
- }
- geometryPtr->accelGlyph = glyph;
+ [self setWindowsMenu:submenu];
+ [submenu setSpecial:tkWindowsMenu];
+ } else if ((mePtr->entryFlags & ENTRY_HELP_MENU) &&
+ ![submenu isSpecial:tkHelpMenu]) {
+ NSInteger index = 0;
+
+ for (NSMenuItem *i in _defaultHelpMenuItems) {
+ [submenu insertItem:[[i copy] autorelease] atIndex:
+ index++];
}
+ [submenu setSpecial:tkHelpMenu];
}
- ChkErr(SetMenuItemModifiers, macMenuHdl, base + index,
- modifiers);
}
}
+ } else {
+ menu = _defaultMainMenu;
+ applicationMenu = _defaultApplicationMenu;
}
-}
-
-/*
- *----------------------------------------------------------------------
- *
- * ReconfigureMacintoshMenu --
- *
- * Rebuilds the Macintosh MenuHandle items from the menu. Called
- * usually as an idle handler, but can be called synchronously
- * if the menu is about to be posted.
- *
- * Results:
- * None.
- *
- * Side effects:
- * Configuration information get set for mePtr; old resources
- * get freed, if any need it.
- *
- *----------------------------------------------------------------------
- */
-
-void
-ReconfigureMacintoshMenu(
- ClientData clientData) /* Information about menu entry; may
- * or may not already have values for
- * some fields. */
-{
- TkMenu *menuPtr = (TkMenu *) clientData;
- MenuHandle macMenuHdl = ((MacMenu *) menuPtr->platformData)->menuHdl;
- MenuHandle helpMenuHdl = NULL;
-
- menuPtr->menuFlags &= ~MENU_RECONFIGURE_PENDING;
-
- if (NULL == macMenuHdl) {
- return;
- }
-
- ReconfigureIndividualMenu(menuPtr, macMenuHdl, 0);
- if (GetMenuID(macMenuHdl) == currentHelpMenuID) {
- MenuItemIndex helpIndex;
- HMGetHelpMenu(&helpMenuHdl,&helpIndex);
- if (helpMenuHdl != NULL) {
- ReconfigureIndividualMenu(menuPtr, helpMenuHdl, helpIndex - 1);
- }
- }
+ NSMenuItem *servicesMenuItem =
+ [applicationMenu itemWithTitle:@"Services"];
- if (menuPtr->menuType == MENUBAR) {
- if (!(menuBarFlags & MENUBAR_REDRAW_PENDING)) {
- Tcl_DoWhenIdle(DrawMenuBarWhenIdle, NULL);
- menuBarFlags |= MENUBAR_REDRAW_PENDING;
- }
+ if (servicesMenuItem && [servicesMenuItem submenu] != _servicesMenu) {
+ [[_servicesMenu itemInSupermenu] setSubmenu:nil];
+ [servicesMenuItem setSubmenu:_servicesMenu];
}
+ [self setAppleMenu:applicationMenu];
+ [self setMainMenu:menu];
}
+@end
+
+#pragma mark -
/*
*----------------------------------------------------------------------
*
- * CompleteIdlers --
+ * TkpNewMenu --
*
- * Completes all idle handling so that the menus are in sync when
- * the user invokes them with the mouse.
+ * Gets a new blank menu. Only the platform specific options are filled
+ * in.
*
* Results:
- * None.
+ * Returns a standard Tcl error.
*
* Side effects:
- * The Macintosh menu handles are flushed out.
+ * Allocates a NSMenu and puts it into the platformData field of the
+ * menuPtr.
*
*----------------------------------------------------------------------
*/
-void
-CompleteIdlers(
- TkMenu *menuPtr) /* The menu we are completing. */
+int
+TkpNewMenu(
+ TkMenu *menuPtr) /* The common structure we are making the
+ * platform structure for. */
{
- int i;
-
- if (menuPtr->menuFlags & MENU_RECONFIGURE_PENDING) {
- Tcl_CancelIdleCall(ReconfigureMacintoshMenu, (ClientData) menuPtr);
- ReconfigureMacintoshMenu((ClientData) menuPtr);
- }
-
- for (i = 0; i < menuPtr->numEntries; i++) {
- if ((menuPtr->entries[i]->type == CASCADE_ENTRY) &&
- (menuPtr->entries[i]->childMenuRefPtr != NULL) &&
- (menuPtr->entries[i]->childMenuRefPtr->menuPtr != NULL)) {
- CompleteIdlers(menuPtr->entries[i]->childMenuRefPtr->menuPtr);
- }
- }
+ TKMenu *menu = [[TKMenu alloc] initWithTkMenu:menuPtr];
+ menuPtr->platformData = (TkMenuPlatformData)
+ TkMacOSXMakeUncollectable(menu);
+ CheckForSpecialMenu(menuPtr);
+ return TCL_OK;
}
/*
*----------------------------------------------------------------------
*
- * TkpPostMenu --
+ * TkpDestroyMenu --
*
- * Posts a menu on the screen
+ * Destroys platform-specific menu structures.
*
* Results:
* None.
*
* Side effects:
- * The menu is posted and handled.
+ * All platform-specific allocations are freed up.
*
*----------------------------------------------------------------------
*/
-int
-TkpPostMenu(
- Tcl_Interp *interp, /* The interpreter this menu lives in */
- TkMenu *menuPtr, /* The menu we are posting */
- int x, /* The global x-coordinate of the top, left-
- * hand corner of where the menu is supposed
- * to be posted. */
- int y) /* The global y-coordinate */
+void
+TkpDestroyMenu(
+ TkMenu *menuPtr) /* The common menu structure */
{
- MenuHandle macMenuHdl = ((MacMenu *) menuPtr->platformData)->menuHdl;
- long popUpResult;
- int result;
-
- if (inPostMenu > 0) {
- Tcl_AppendResult(interp,
- "Cannot call post menu while already posting menu", NULL);
- result = TCL_ERROR;
- } else {
- short menuID;
- Window window;
- int oldWidth = menuPtr->totalWidth;
-
- inPostMenu++;
- result = TkPreprocessMenu(menuPtr);
- /*
- * The post commands could have deleted the menu, which means
- * we are dead and should go away.
- */
-
- if (result != TCL_OK || !menuPtr->tkwin) {
- goto endPostMenu;
- }
-
- CompleteIdlers(menuPtr);
- if (menuBarFlags & MENUBAR_REDRAW_PENDING) {
- Tcl_CancelIdleCall(DrawMenuBarWhenIdle, NULL);
- DrawMenuBarWhenIdle(NULL);
- }
- RecursivelyInsertMenu(menuPtr);
-
- TkMacOSXTrackingLoop(1);
- popUpResult = PopUpMenuSelect(macMenuHdl, y, x, menuPtr->active);
- TkMacOSXTrackingLoop(0);
- menuPtr->totalWidth = oldWidth;
-
- /*
- * Simulate the mouse up.
- */
-
- window = Tk_WindowId(menuPtr->tkwin);
- TkGenerateButtonEventForXPointer(window);
-
- /*
- * Dispatch the command.
- */
-
- menuID = HiWord(popUpResult);
- if (menuID != 0) {
- result = TkMacOSXDispatchMenuEvent(menuID, LoWord(popUpResult));
- }
-
-endPostMenu:
- inPostMenu--;
- }
- return result;
+ TkMacOSXMakeCollectableAndRelease(menuPtr->platformData);
}
/*
@@ -1590,9 +525,8 @@ endPostMenu:
* TkpMenuNewEntry --
*
* Adds a pointer to a new menu entry structure with the platform-
- * specific fields filled in. The Macintosh uses the
- * platformEntryData field of the TkMenuEntry record to store
- * geometry information.
+ * specific fields filled in. The Macintosh uses the platformEntryData
+ * field of the TkMenuEntry record.
*
* Results:
* Standard TCL error.
@@ -1608,490 +542,238 @@ int
TkpMenuNewEntry(
TkMenuEntry *mePtr) /* The menu we are adding an entry to */
{
- EntryGeometry *geometryPtr =
- (EntryGeometry *) ckalloc(sizeof(EntryGeometry));
- TkMenu *menuPtr = mePtr->menuPtr;
-
- geometryPtr->accelTextStart = 0;
- geometryPtr->accelTextWidth = 0;
- geometryPtr->nonAccelMargin = 0;
- geometryPtr->modifierWidth = 0;
- geometryPtr->modifierNum = 0;
- geometryPtr->accelGlyph = 0;
- mePtr->platformEntryData = (TkMenuPlatformEntryData) geometryPtr;
- if (!(menuPtr->menuFlags & MENU_RECONFIGURE_PENDING)) {
- menuPtr->menuFlags |= MENU_RECONFIGURE_PENDING;
- Tcl_DoWhenIdle(ReconfigureMacintoshMenu, (ClientData) menuPtr);
+ TKMenu *menu = (TKMenu *) mePtr->menuPtr->platformData;
+ NSMenuItem *menuItem;
+ if (mePtr->type == SEPARATOR_ENTRY || mePtr->type == TEAROFF_ENTRY) {
+ menuItem = [[NSMenuItem separatorItem] retain];
+ } else {
+ menuItem = [menu newTkMenuItem:mePtr];
}
- return TCL_OK;
-}
-
-/*
- *----------------------------------------------------------------------
- *
- * Tk_MacOSXTurnOffMenus --
- *
- * Turns off all the menu drawing code. This is more than just disabling
- * the "menu" command, this means that Tk will NEVER touch the menubar.
- * It is needed in the Plugin, where Tk does not own the menubar.
- *
- * Results:
- * None.
- *
- * Side effects:
- * A flag is set which will disable all menu drawing.
- *
- *----------------------------------------------------------------------
- */
+ mePtr->platformEntryData = (TkMenuPlatformEntryData)
+ TkMacOSXMakeUncollectable(menuItem);
-void
-Tk_MacOSXTurnOffMenus(void)
-{
- gNoTkMenus = 1;
+ /*
+ * Caller TkMenuEntry() already did this same insertion into the generic
+ * TkMenu so we just match it for the platform menu.
+ */
+
+ [menu insertItem:menuItem atTkIndex:mePtr->index];
+ return TCL_OK;
}
/*
*----------------------------------------------------------------------
*
- * DrawMenuBarWhenIdle --
+ * TkpConfigureMenuEntry --
*
- * Update the menu bar next time there is an idle event.
+ * Processes configurations for menu entries.
*
* Results:
- * None.
+ * Returns standard TCL result. If TCL_ERROR is returned, then the
+ * interp's result contains an error message.
*
* Side effects:
- * Menu bar is redrawn.
+ * Configuration information get set for mePtr; old resources get freed,
+ * if any need it.
*
*----------------------------------------------------------------------
*/
-void
-DrawMenuBarWhenIdle(
- ClientData clientData) /* ignored here */
-{
- TkMenuReferences *menuRefPtr;
- TkMenu *appleMenuPtr, *helpMenuPtr, *menuBarPtr = NULL;
- MenuHandle macMenuHdl;
- Tcl_HashEntry *hashEntryPtr;
-
- /*
- * If we have been turned off, exit.
- */
-
- if (gNoTkMenus) {
- return;
- }
-
- /*
- * We need to clear the apple and help menus of any extra items.
- */
-
- if (currentAppleMenuID != 0) {
- hashEntryPtr = Tcl_FindHashEntry(&commandTable,
- (char*)(intptr_t)currentAppleMenuID);
- appleMenuPtr = (TkMenu *) Tcl_GetHashValue(hashEntryPtr);
- TkpDestroyMenu(appleMenuPtr);
- TkpNewMenu(appleMenuPtr);
- appleMenuPtr->menuFlags &= ~MENU_APPLE_MENU;
- appleMenuPtr->menuFlags |= MENU_RECONFIGURE_PENDING;
- Tcl_DoWhenIdle(ReconfigureMacintoshMenu, (ClientData) appleMenuPtr);
- }
-
- if (currentHelpMenuID != 0) {
- hashEntryPtr = Tcl_FindHashEntry(&commandTable,
- (char*)(intptr_t)currentHelpMenuID);
- helpMenuPtr = (TkMenu *) Tcl_GetHashValue(hashEntryPtr);
- TkpDestroyMenu(helpMenuPtr);
- TkpNewMenu(helpMenuPtr);
- helpMenuPtr->menuFlags &= ~MENU_HELP_MENU;
- helpMenuPtr->menuFlags |= MENU_RECONFIGURE_PENDING;
- Tcl_DoWhenIdle(ReconfigureMacintoshMenu,
- (ClientData) helpMenuPtr);
- }
-
- /*
- * We need to find the clone of this menu that is the menubar.
- * Once we do that, for every cascade in the menu, we need to
- * insert the Mac menu in the Mac menubar. Finally, we need
- * to redraw the menubar.
- */
-
- menuRefPtr = NULL;
- if (currentMenuBarName != NULL) {
- menuRefPtr = TkFindMenuReferences(currentMenuBarInterp,
- currentMenuBarName);
- }
- if (menuRefPtr) {
- TkMenu *menuPtr;
- TkMenu *cascadeMenuPtr;
- char *appleMenuName, *helpMenuName;
- int appleIndex = -1, helpIndex = -1, i;
-
- menuPtr = menuRefPtr->menuPtr;
- if (menuPtr != NULL) {
- TkMenuReferences *specialMenuRefPtr;
- TkMenuEntry *specialEntryPtr;
-
- appleMenuName = ckalloc(strlen(currentMenuBarName) + 1 +
- strlen(".apple") + 1);
- sprintf(appleMenuName, "%s.apple", Tk_PathName(menuPtr->tkwin));
- specialMenuRefPtr = TkFindMenuReferences(currentMenuBarInterp,
- appleMenuName);
- if ((specialMenuRefPtr != NULL)
- && (specialMenuRefPtr->menuPtr != NULL)) {
- for (specialEntryPtr = specialMenuRefPtr->parentEntryPtr;
- specialEntryPtr != NULL;
- specialEntryPtr = specialEntryPtr->nextCascadePtr) {
- if (specialEntryPtr->menuPtr == menuPtr) {
- appleIndex = specialEntryPtr->index;
- break;
- }
- }
- }
- ckfree(appleMenuName);
-
- helpMenuName = ckalloc(strlen(currentMenuBarName) + 1 +
- strlen(".help") + 1);
- sprintf(helpMenuName, "%s.help", Tk_PathName(menuPtr->tkwin));
- specialMenuRefPtr = TkFindMenuReferences(currentMenuBarInterp,
- helpMenuName);
- if ((specialMenuRefPtr != NULL)
- && (specialMenuRefPtr->menuPtr != NULL)) {
- for (specialEntryPtr = specialMenuRefPtr->parentEntryPtr;
- specialEntryPtr != NULL;
- specialEntryPtr = specialEntryPtr->nextCascadePtr) {
- if (specialEntryPtr->menuPtr == menuPtr) {
- helpIndex = specialEntryPtr->index;
- break;
- }
- }
- }
- ckfree(helpMenuName);
- }
-
- for (menuBarPtr = menuPtr;
- (menuBarPtr != NULL) && (menuBarPtr->menuType != MENUBAR);
- menuBarPtr = menuBarPtr->nextInstancePtr) {
- /*
- * Null loop body.
- */
- }
-
- if (menuBarPtr) {
- if (menuBarPtr->tearoff != menuPtr->tearoff) {
- if (menuBarPtr->tearoff) {
- appleIndex = (-1 == appleIndex) ? appleIndex
- : appleIndex + 1;
- helpIndex = (-1 == helpIndex) ? helpIndex
- : helpIndex + 1;
- } else {
- appleIndex = (-1 == appleIndex) ? appleIndex
- : appleIndex - 1;
- helpIndex = (-1 == helpIndex) ? helpIndex
- : helpIndex - 1;
- }
- }
- ClearMenuBar();
+int
+TkpConfigureMenuEntry(
+ TkMenuEntry *mePtr) /* Information about menu entry; may or may
+ * not already have values for some fields. */
+{
+ NSMenuItem *menuItem = (NSMenuItem *) mePtr->platformEntryData;
+ NSString *title = @"";
+ NSAttributedString *attributedTitle = nil;
+ NSImage *image = nil;
+ NSString *keyEquivalent = @"";
+ NSUInteger modifierMask = NSCommandKeyMask;
+ NSMenu *submenu = nil;
+ NSDictionary *attributes;
+ int imageWidth, imageHeight;
+ GC gc = (mePtr->textGC ? mePtr->textGC : mePtr->menuPtr->textGC);
+ Tcl_Obj *fontPtr = (mePtr->fontPtr ? mePtr->fontPtr :
+ mePtr->menuPtr->fontPtr);
+
+ if (mePtr->image) {
+ Tk_SizeOfImage(mePtr->image, &imageWidth, &imageHeight);
+ image = TkMacOSXGetNSImageWithTkImage(mePtr->menuPtr->display,
+ mePtr->image, imageWidth, imageHeight);
+ } else if (mePtr->bitmapPtr != None) {
+ Pixmap bitmap = Tk_GetBitmapFromObj(mePtr->menuPtr->tkwin,
+ mePtr->bitmapPtr);
+
+ Tk_SizeOfBitmap(mePtr->menuPtr->display, bitmap, &imageWidth,
+ &imageHeight);
+ image = TkMacOSXGetNSImageWithBitmap(mePtr->menuPtr->display, bitmap,
+ gc, imageWidth, imageHeight);
+ }
+ [menuItem setImage:image];
+ if ((!image || mePtr->compound != COMPOUND_NONE) && mePtr->labelPtr &&
+ mePtr->labelLength) {
+ title = [[[NSString alloc] initWithBytes:Tcl_GetString(mePtr->labelPtr)
+ length:mePtr->labelLength encoding:NSUTF8StringEncoding]
+ autorelease];
+ if ([title hasSuffix:@"..."]) {
+ title = [NSString stringWithFormat:@"%@%C",
+ [title substringToIndex:[title length] - 3], 0x2026];
+ }
+ }
+ [menuItem setTitle:title];
+ if (strcmp(Tcl_GetString(fontPtr), "menu") || gc->foreground != defaultFg
+ || gc->background != defaultBg) {
+ attributes = TkMacOSXNSFontAttributesForFont(Tk_GetFontFromObj(
+ mePtr->menuPtr->tkwin, fontPtr));
+ if (gc->foreground != defaultFg || gc->background != defaultBg) {
+ NSColor *color = TkMacOSXGetNSColor(gc,
+ gc->foreground!=defaultFg? gc->foreground:gc->background);
+
+ attributes = [[attributes mutableCopy] autorelease];
+ [(NSMutableDictionary *)attributes setObject:color
+ forKey:NSForegroundColorAttributeName];
+ }
+ if (attributes) {
+ attributedTitle = [[[NSAttributedString alloc]
+ initWithString:title attributes:attributes] autorelease];
+ }
+ }
+ [menuItem setAttributedTitle:attributedTitle];
+ [menuItem setEnabled:!(mePtr->state == ENTRY_DISABLED)];
+ [menuItem setState:((mePtr->type == CHECK_BUTTON_ENTRY ||
+ mePtr->type == RADIO_BUTTON_ENTRY) && mePtr->indicatorOn &&
+ (mePtr->entryFlags & ENTRY_SELECTED) ? NSOnState : NSOffState)];
+ if (mePtr->type != CASCADE_ENTRY && mePtr->accelPtr && mePtr->accelLength) {
+ keyEquivalent = ParseAccelerator(Tcl_GetString(mePtr->accelPtr),
+ &modifierMask);
+ }
+ [menuItem setKeyEquivalent:keyEquivalent];
+ [menuItem setKeyEquivalentModifierMask:modifierMask];
+ if (mePtr->type == CASCADE_ENTRY && mePtr->namePtr) {
+ TkMenuReferences *menuRefPtr;
+
+ menuRefPtr = TkFindMenuReferencesObj(mePtr->menuPtr->interp,
+ mePtr->namePtr);
+ if (menuRefPtr && menuRefPtr->menuPtr) {
+ CheckForSpecialMenu(menuRefPtr->menuPtr);
+ submenu = (TKMenu *) menuRefPtr->menuPtr->platformData;
+ if ([submenu supermenu] && [menuItem submenu] != submenu) {
+ /*
+ * This happens during a clone, where the parent menu is
+ * cloned before its children, so just ignore this temprary
+ * setting, it will be changed shortly (c.f. tkMenu.c
+ * CloneMenu())
+ */
- if (appleIndex == -1) {
- InsertMenu(tkAppleMenu, 0);
- currentAppleMenuID = 0;
- tkCurrentAppleMenu = tkAppleMenu;
+ submenu = nil;
} else {
- short appleID;
-
- appleMenuPtr = menuBarPtr->entries[appleIndex]
- ->childMenuRefPtr->menuPtr;
- TkpDestroyMenu(appleMenuPtr);
- TkMacOSXGetNewMenuID(appleMenuPtr->interp, appleMenuPtr, 0,
- &appleID);
- macMenuHdl = NewMenu(appleID, "\p\024");
- appleMenuPtr->platformData =
- (TkMenuPlatformData) ckalloc(sizeof(MacMenu));
- ((MacMenu *)appleMenuPtr->platformData)->menuHdl
- = macMenuHdl;
- appleMenuPtr->menuFlags |= MENU_APPLE_MENU;
- if (!(appleMenuPtr->menuFlags
- & MENU_RECONFIGURE_PENDING)) {
- appleMenuPtr->menuFlags |= MENU_RECONFIGURE_PENDING;
- Tcl_DoWhenIdle(ReconfigureMacintoshMenu,
- (ClientData) appleMenuPtr);
+ [submenu setTitle:title];
+
+ if ([menuItem isEnabled]) {
+ /* This menuItem might have been previously disabled (XXX:
+ track this), which would have disabled entries; we must
+ re-enable the entries here. */
+ int i = 0;
+ NSArray *itemArray = [submenu itemArray];
+ for (NSMenuItem *item in itemArray) {
+ TkMenuEntry *submePtr = menuRefPtr->menuPtr->entries[i];
+ [item setEnabled: !(submePtr->state == ENTRY_DISABLED)];
+ i++;
+ }
}
- InsertMenu(macMenuHdl, 0);
- RecursivelyInsertMenu(appleMenuPtr);
- currentAppleMenuID = appleID;
- tkCurrentAppleMenu = macMenuHdl;
- }
- if (helpIndex == -1) {
- currentHelpMenuID = 0;
- }
- for (i = 0; i < menuBarPtr->numEntries; i++) {
- if (i == appleIndex) {
- if (menuBarPtr->entries[i]->state == ENTRY_DISABLED) {
- DisableMenuItem(((MacMenu *) menuBarPtr->entries[i]
- ->childMenuRefPtr->menuPtr
- ->platformData)->menuHdl, 0);
- } else {
- EnableMenuItem(((MacMenu *) menuBarPtr->entries[i]
- ->childMenuRefPtr->menuPtr
- ->platformData)->menuHdl, 0);
- }
- continue;
- } else if (i == helpIndex) {
- TkMenu *helpMenuPtr = menuBarPtr->entries[i]
- ->childMenuRefPtr->menuPtr;
-
- if (helpMenuPtr == NULL) {
- continue;
- }
- helpMenuPtr->menuFlags |= MENU_HELP_MENU;
- if (!(helpMenuPtr->menuFlags
- & MENU_RECONFIGURE_PENDING)) {
- helpMenuPtr->menuFlags
- |= MENU_RECONFIGURE_PENDING;
- Tcl_DoWhenIdle(ReconfigureMacintoshMenu,
- (ClientData) helpMenuPtr);
- }
- macMenuHdl =
- ((MacMenu *) helpMenuPtr->platformData)->menuHdl;
- currentHelpMenuID = GetMenuID(macMenuHdl);
- } else if (menuBarPtr->entries[i]->type
- == CASCADE_ENTRY) {
- if ((menuBarPtr->entries[i]->childMenuRefPtr != NULL)
- && menuBarPtr->entries[i]->childMenuRefPtr
- ->menuPtr != NULL) {
- cascadeMenuPtr = menuBarPtr->entries[i]
- ->childMenuRefPtr->menuPtr;
- macMenuHdl = ((MacMenu *) cascadeMenuPtr
- ->platformData)->menuHdl;
- DeleteMenu(GetMenuID(macMenuHdl));
- InsertMenu(macMenuHdl, 0);
- RecursivelyInsertMenu(cascadeMenuPtr);
- if (menuBarPtr->entries[i]->state == ENTRY_DISABLED) {
- DisableMenuItem(((MacMenu *) menuBarPtr->entries[i]
- ->childMenuRefPtr->menuPtr
- ->platformData)->menuHdl, 0);
- } else {
- EnableMenuItem(((MacMenu *) menuBarPtr->entries[i]
- ->childMenuRefPtr->menuPtr
- ->platformData)->menuHdl, 0);
- }
- }
- }
}
}
}
- if (!menuRefPtr || !menuBarPtr) {
- SetDefaultMenubar();
- }
- DrawMenuBar();
- menuBarFlags &= ~MENUBAR_REDRAW_PENDING;
-}
-
-/*
- *----------------------------------------------------------------------
- *
- * RecursivelyInsertMenu --
- *
- * Puts all of the cascades of this menu in the Mac hierarchical list.
- *
- * Results:
- * None.
- *
- * Side effects:
- * The menubar is changed.
- *
- *----------------------------------------------------------------------
- */
-
-void
-RecursivelyInsertMenu(
- TkMenu *menuPtr) /* All of the cascade items in this menu
- * will be inserted into the mac menubar. */
-{
- int i;
- TkMenu *cascadeMenuPtr;
- MenuHandle macMenuHdl;
+ [menuItem setSubmenu:submenu];
- for (i = 0; i < menuPtr->numEntries; i++) {
- if (menuPtr->entries[i]->type == CASCADE_ENTRY) {
- if ((menuPtr->entries[i]->childMenuRefPtr != NULL) &&
- (menuPtr->entries[i]->childMenuRefPtr->menuPtr != NULL)) {
- cascadeMenuPtr = menuPtr->entries[i]->childMenuRefPtr->menuPtr;
- macMenuHdl =
- ((MacMenu *) cascadeMenuPtr->platformData)->menuHdl;
- InsertMenu(macMenuHdl, -1);
- RecursivelyInsertMenu(cascadeMenuPtr);
- }
- }
- }
+ return TCL_OK;
}
/*
*----------------------------------------------------------------------
*
- * RecursivelyDeleteMenu --
+ * TkpDestroyMenuEntry --
*
- * Takes all of the cascades of this menu out of the Mac hierarchical
- * list.
+ * Cleans up platform-specific menu entry items.
*
* Results:
- * None.
+ * None
*
* Side effects:
- * The menubar is changed.
+ * All platform-specific allocations are freed up.
*
*----------------------------------------------------------------------
*/
void
-RecursivelyDeleteMenu(
- TkMenu *menuPtr) /* All of the cascade items in this menu
- * will be deleted from the mac menubar. */
+TkpDestroyMenuEntry(
+ TkMenuEntry *mePtr)
{
- int i;
- TkMenu *cascadeMenuPtr;
- MenuHandle macMenuHdl;
+ if (mePtr->platformEntryData && mePtr->menuPtr->platformData) {
+ TKMenu *menu = (TKMenu *) mePtr->menuPtr->platformData;
+ NSMenuItem *menuItem = (NSMenuItem *) mePtr->platformEntryData;
+ NSInteger index = [menu indexOfItem:menuItem];
- for (i = 0; i < menuPtr->numEntries; i++) {
- if (menuPtr->entries[i]->type == CASCADE_ENTRY) {
- if ((menuPtr->entries[i]->childMenuRefPtr != NULL) &&
- (menuPtr->entries[i]->childMenuRefPtr->menuPtr != NULL)) {
- cascadeMenuPtr = menuPtr->entries[i]->childMenuRefPtr->menuPtr;
- macMenuHdl =
- ((MacMenu *) cascadeMenuPtr->platformData)->menuHdl;
- DeleteMenu(GetMenuID(macMenuHdl));
- RecursivelyDeleteMenu(cascadeMenuPtr);
- }
+ if (index > -1) {
+ [menu removeItemAtIndex:index];
}
}
+ TkMacOSXMakeCollectableAndRelease(mePtr->platformEntryData);
}
/*
*----------------------------------------------------------------------
*
- * SetDefaultMenubar --
- *
- * Puts the Apple, File and Edit menus into the Macintosh menubar.
- *
- * Results:
- * None.
- *
- * Side effects:
- * The menubar is changed.
- *
- *----------------------------------------------------------------------
- */
-
-void
-SetDefaultMenubar(void)
-{
- if (currentMenuBarName != NULL) {
- ckfree(currentMenuBarName);
- currentMenuBarName = NULL;
- }
- currentMenuBarOwner = NULL;
- ClearMenuBar();
- InsertMenu(tkAppleMenu, 0);
- InsertMenu(tkFileMenu, 0);
- InsertMenu(tkEditMenu, 0);
- if (!(menuBarFlags & MENUBAR_REDRAW_PENDING)) {
- Tcl_DoWhenIdle(DrawMenuBarWhenIdle, NULL);
- menuBarFlags |= MENUBAR_REDRAW_PENDING;
- }
-}
-
-/*
- *----------------------------------------------------------------------
- *
- * TkpSetMainMenubar --
+ * TkpPostMenu --
*
- * Puts the menu associated with a window into the menubar. Should
- * only be called when the window is in front.
+ * Posts a menu on the screen
*
* Results:
* None.
*
* Side effects:
- * The menubar is changed.
+ * The menu is posted and handled.
*
*----------------------------------------------------------------------
*/
-void
-TkpSetMainMenubar(
- Tcl_Interp *interp, /* The interpreter of the application */
- Tk_Window tkwin, /* The frame we are setting up */
- char *menuName) /* The name of the menu to put in front.
- * If NULL, use the default menu bar.
- */
+int
+TkpPostMenu(
+ Tcl_Interp *interp, /* The interpreter this menu lives in */
+ TkMenu *menuPtr, /* The menu we are posting */
+ int x, /* The global x-coordinate of the top, left-
+ * hand corner of where the menu is supposed
+ * to be posted. */
+ int y) /* The global y-coordinate */
{
- TkWindow *winPtr = (TkWindow *) tkwin;
- WindowRef macWindowPtr;
- WindowRef frontNonFloating;
-
- macWindowPtr = TkMacOSXDrawableWindow(winPtr->window);
-
- frontNonFloating = ActiveNonFloatingWindow();
- if ((macWindowPtr == NULL) || (macWindowPtr != frontNonFloating)) {
- return;
+ NSWindow *win = [NSApp keyWindow];
+ if (!win) {
+ return TCL_ERROR;
}
- if ((currentMenuBarInterp != interp) || (currentMenuBarOwner != tkwin)
- || (currentMenuBarName == NULL) || (menuName == NULL)
- || (strcmp(menuName, currentMenuBarName) != 0)) {
- Tk_Window searchWindow;
- TopLevelMenubarList *listPtr;
+ inPostMenu = 1;
- if (currentMenuBarName != NULL) {
- ckfree(currentMenuBarName);
- }
+ int oldMode = Tcl_SetServiceMode(TCL_SERVICE_NONE);
+ NSView *view = [win contentView];
+ NSRect frame = NSMakeRect(x + 9, tkMacOSXZeroScreenHeight - y - 9, 1, 1);
- if (menuName == NULL) {
- searchWindow = tkwin;
- if (strcmp(Tk_Class(searchWindow), "Menu") == 0) {
- TkMenuReferences *menuRefPtr;
+ frame.origin = [view convertPoint:
+ [win convertScreenToBase:frame.origin] fromView:nil];
- menuRefPtr = TkFindMenuReferences(interp, Tk_PathName(tkwin));
- if (menuRefPtr != NULL) {
- TkMenu *menuPtr = menuRefPtr->menuPtr;
+ NSMenu *menu = (NSMenu *) menuPtr->platformData;
+ NSPopUpButtonCell *popUpButtonCell = [[NSPopUpButtonCell alloc]
+ initTextCell:@"" pullsDown:NO];
- if (menuPtr != NULL) {
- searchWindow = menuPtr->masterMenuPtr->tkwin;
- }
- }
- }
- for (; searchWindow != NULL;
- searchWindow = Tk_Parent(searchWindow)) {
- for (listPtr = windowListPtr; listPtr != NULL;
- listPtr = listPtr->nextPtr) {
- if (listPtr->tkwin == searchWindow) {
- break;
- }
- }
- if (listPtr != NULL) {
- menuName = Tk_PathName(
- listPtr->menuPtr->masterMenuPtr->tkwin);
- break;
- }
- }
- }
-
- if (menuName == NULL) {
- currentMenuBarName = NULL;
- } else {
- currentMenuBarName = ckalloc(strlen(menuName) + 1);
- strcpy(currentMenuBarName, menuName);
- }
- currentMenuBarOwner = tkwin;
- currentMenuBarInterp = interp;
- }
- if (!(menuBarFlags & MENUBAR_REDRAW_PENDING)) {
- Tcl_DoWhenIdle(DrawMenuBarWhenIdle, NULL);
- menuBarFlags |= MENUBAR_REDRAW_PENDING;
- }
+ [popUpButtonCell setAltersStateOfSelectedItem:NO];
+ [popUpButtonCell setMenu:menu];
+ [popUpButtonCell selectItem:nil];
+ [popUpButtonCell performClickWithFrame:frame inView:view];
+ [popUpButtonCell release];
+ Tcl_SetServiceMode(oldMode);
+ inPostMenu = 0;
+ return TCL_OK;
}
/*
@@ -2105,8 +787,8 @@ TkpSetMainMenubar(
* None.
*
* Side effects:
- * On Windows and UNIX, associates the platform menu with the
- * platform window.
+ * On Windows and UNIX, associates the platform menu with the platform
+ * window.
*
*----------------------------------------------------------------------
*/
@@ -2116,276 +798,115 @@ TkpSetWindowMenuBar(
Tk_Window tkwin, /* The window we are setting the menu in */
TkMenu *menuPtr) /* The menu we are setting */
{
- TopLevelMenubarList *listPtr, *prevPtr;
-
- /*
- * Remove any existing reference to this window.
- */
-
- for (prevPtr = NULL, listPtr = windowListPtr;
- listPtr != NULL;
- prevPtr = listPtr, listPtr = listPtr->nextPtr) {
- if (listPtr->tkwin == tkwin) {
- break;
- }
- }
-
- if (listPtr != NULL) {
- if (prevPtr != NULL) {
- prevPtr->nextPtr = listPtr->nextPtr;
- } else {
- windowListPtr = listPtr->nextPtr;
- }
- ckfree((char *) listPtr);
- }
+ TkWindow *winPtr = (TkWindow *) tkwin;
- if (menuPtr != NULL) {
- listPtr = (TopLevelMenubarList *) ckalloc(sizeof(TopLevelMenubarList));
- listPtr->nextPtr = windowListPtr;
- windowListPtr = listPtr;
- listPtr->tkwin = tkwin;
- listPtr->menuPtr = menuPtr;
+ if (winPtr->wmInfoPtr) {
+ winPtr->wmInfoPtr->menuPtr = menuPtr;
}
}
/*
*----------------------------------------------------------------------
*
- * EventuallyInvokeMenu --
+ * TkpSetMainMenubar --
*
- * This IdleTime callback actually invokes the menu command
- * scheduled in TkMacOSXDispatchMenuEvent.
+ * Puts the menu associated with a window into the menubar. Should only
+ * be called when the window is in front.
*
* Results:
* None.
*
* Side effects:
- * Commands get executed.
+ * The menubar is changed.
*
*----------------------------------------------------------------------
*/
void
-EventuallyInvokeMenu (
- ClientData data)
+TkpSetMainMenubar(
+ Tcl_Interp *interp, /* The interpreter of the application */
+ Tk_Window tkwin, /* The frame we are setting up */
+ char *menuName) /* The name of the menu to put in front. If
+ * NULL, use the default menu bar. */
{
- struct MenuCommandHandlerData *realData =
- (struct MenuCommandHandlerData *) data;
- int code;
+ static Tcl_Interp *currentInterp = NULL;
+ TKMenu *menu = nil;
- code = TkInvokeMenu(realData->menuPtr->interp, realData->menuPtr,
- realData->index);
+ if (menuName) {
+ TkWindow *winPtr = (TkWindow *) tkwin;
- if (code != TCL_OK && code != TCL_CONTINUE && code != TCL_BREAK) {
- Tcl_AddErrorInfo(realData->menuPtr->interp, "\n (menu invoke)");
- Tcl_BackgroundError(realData->menuPtr->interp);
- }
-
- if (realData->menuPtr->tkwin) {
- RecursivelyClearActiveMenu(realData->menuPtr);
- }
- TkMacOSXClearMenubarActive();
-
- Tcl_Release(realData->menuPtr->interp);
- Tcl_Release(realData->menuPtr);
-}
-
-/*
- *----------------------------------------------------------------------
- *
- * TkMacOSXDispatchMenuEvent --
- *
- * Given a menu id and an item, dispatches the command associated
- * with it.
- *
- * Results:
- * None.
- *
- * Side effects:
- * Commands for the event are scheduled for execution at idle time.
- *
- *----------------------------------------------------------------------
- */
-
-int
-TkMacOSXDispatchMenuEvent(
- int menuID, /* The menu id of the menu we are invoking */
- int index) /* The one-based index of the item that was
- * selected. */
-{
- int result = TCL_OK;
-
- if (menuID != 0) {
- if (menuID == kHMHelpMenuID) {
- if (currentMenuBarOwner != NULL) {
- TkMenuReferences *helpMenuRef;
- char *helpMenuName = ckalloc(strlen(currentMenuBarName)
- + strlen(".help") + 1);
-
- sprintf(helpMenuName, "%s.help", currentMenuBarName);
- helpMenuRef = TkFindMenuReferences(currentMenuBarInterp,
- helpMenuName);
- ckfree(helpMenuName);
- if ((helpMenuRef != NULL) && (helpMenuRef->menuPtr != NULL)) {
- MenuRef outHelpMenu;
- MenuItemIndex itemIndex;
- int newIndex;
-
- HMGetHelpMenu(&outHelpMenu, &itemIndex);
- newIndex = index - itemIndex;
- result = TkInvokeMenu(currentMenuBarInterp,
- helpMenuRef->menuPtr, newIndex);
- }
- }
+ if (winPtr->wmInfoPtr && winPtr->wmInfoPtr->menuPtr &&
+ winPtr->wmInfoPtr->menuPtr->masterMenuPtr &&
+ winPtr->wmInfoPtr->menuPtr->masterMenuPtr->tkwin &&
+ !strcmp(menuName, Tk_PathName(
+ winPtr->wmInfoPtr->menuPtr->masterMenuPtr->tkwin))) {
+ menu = (TKMenu *) winPtr->wmInfoPtr->menuPtr->platformData;
} else {
- Tcl_HashEntry *commandEntryPtr =
- Tcl_FindHashEntry(&commandTable, (char*)(intptr_t)menuID);
- if (commandEntryPtr != NULL) {
- TkMenu *menuPtr = (TkMenu *) Tcl_GetHashValue(commandEntryPtr);
-
- if ((currentAppleMenuID == menuID)
- && (index > menuPtr->numEntries + 1)) {
- /*
- * We don't need to do anything here, the standard
- * Application event handler will open the built-in
- * Apple menu item for us.
- */
- result = TCL_OK;
- } else {
- struct MenuCommandHandlerData *data
- = (struct MenuCommandHandlerData *)
- ckalloc(sizeof(struct MenuCommandHandlerData));
-
- Tcl_Preserve(menuPtr->interp);
- Tcl_Preserve(menuPtr);
- data->menuPtr = menuPtr;
- data->index = index - 1;
- Tcl_DoWhenIdle(EventuallyInvokeMenu,
- (ClientData) data);
- /* result = TkInvokeMenu(menuPtr->interp, menuPtr, index - 1); */
- }
- } else {
- return TCL_ERROR;
+ TkMenuReferences *menuRefPtr = TkFindMenuReferences(interp,
+ menuName);
+
+ if (menuRefPtr && menuRefPtr->menuPtr &&
+ menuRefPtr->menuPtr->platformData) {
+ menu = (TKMenu *) menuRefPtr->menuPtr->platformData;
}
}
}
- return result;
-}
-
-/*
- *----------------------------------------------------------------------
- *
- * GetMenuIndicatorGeometry --
- *
- * Gets the width and height of the indicator area of a menu.
- *
- * Results:
- * widthPtr and heightPtr are set.
- *
- * Side effects:
- * None.
- *
- *----------------------------------------------------------------------
- */
-
-void
-GetMenuIndicatorGeometry (
- TkMenu *menuPtr, /* The menu we are drawing */
- TkMenuEntry *mePtr, /* The entry we are measuring */
- Tk_Font tkfont, /* Precalculated font */
- const Tk_FontMetrics *fmPtr,/* Precalculated font metrics */
- int *widthPtr, /* The resulting width */
- int *heightPtr) /* The resulting height */
-{
- *heightPtr = fmPtr->linespace + menuItemExtraHeight;
- if (IS_THEME_MENU_FONT(tkfont)) {
- *widthPtr = menuMarkColumnWidth;
- } else {
- const char markChar = FindMarkCharacter(mePtr);
- const char *markUtf = NULL;
- int len;
-
- len = GetUtfMarkCharacter(markChar, &markUtf);
- *widthPtr = Tk_TextWidth(tkfont, markUtf, len) + 2*menuMarkIndent;
+ if (menu || interp != currentInterp) {
+ [NSApp tkSetMainMenu:menu];
}
+ currentInterp = interp;
}
/*
*----------------------------------------------------------------------
*
- * GetMenuAccelGeometry --
+ * CheckForSpecialMenu --
*
- * Gets the width and height of the accelerator area of a menu.
+ * Given a menu, check to see whether or not it is a cascade in a menubar
+ * with one of the special names .apple, .help or .window If it is, the
+ * entry that points to this menu will be marked.
*
* Results:
- * widthPtr and heightPtr are set.
+ * None.
*
* Side effects:
- * None.
+ * Will set entryFlags appropriately.
*
*----------------------------------------------------------------------
*/
-void
-GetMenuAccelGeometry (
- TkMenu *menuPtr, /* The menu we are measuring */
- TkMenuEntry *mePtr, /* The entry we are measuring */
- Tk_Font tkfont, /* The precalculated font */
- const Tk_FontMetrics *fmPtr,/* The precalculated font metrics */
- int *modWidthPtr, /* The width of all of the key
- * modifier symbols. */
- int *textWidthPtr, /* The resulting width */
- int *heightPtr) /* The resulting height */
+static void
+CheckForSpecialMenu(
+ TkMenu *menuPtr) /* The menu we are checking */
{
- *heightPtr = fmPtr->linespace + menuItemExtraHeight;
- *modWidthPtr = menuSymbols[COMMAND_SYMBOL].width;
- *textWidthPtr = 0;
- if (mePtr->type != CASCADE_ENTRY && mePtr->accelLength > 0) {
- const char *accel = (mePtr->accelPtr == NULL) ? ""
- : Tcl_GetString(mePtr->accelPtr);
- EntryGeometry *geometryPtr = (EntryGeometry*)mePtr->platformEntryData;
-
- if (IS_THEME_MENU_FONT(tkfont)) {
- CFStringRef cfStr;
- int width = 0;
- int maxWidth = ((TkFont *)tkfont)->fm.maxWidth;
-
- if (geometryPtr->accelGlyph) {
- cfStr = CFStringCreateWithBytes(NULL,
- (UInt8*)&geometryPtr->accelGlyph, 1,
- kTextEncodingMacKeyboardGlyphs, false);
- if (cfStr) {
- width = MeasureThemeText(cfStr, kThemeMenuItemCmdKeyFont);
- CFRelease(cfStr);
- }
- }
- if ((mePtr->entryFlags & ENTRY_ACCEL_MASK) == 0) {
- if (!geometryPtr->accelGlyph) {
- width = Tk_TextWidth(tkfont, accel, mePtr->accelLength);
- }
- *textWidthPtr = maxWidth;
- if (width < maxWidth) {
- *modWidthPtr = 0;
- } else {
- *modWidthPtr = width - maxWidth;
- }
- } else {
- if (!geometryPtr->accelGlyph) {
- width = Tk_TextWidth(tkfont, accel +
- geometryPtr->accelTextStart, mePtr->accelLength -
- geometryPtr->accelTextStart);
- }
- if (width < maxWidth) {
- *textWidthPtr = maxWidth;
+ if (!menuPtr->masterMenuPtr->tkwin) {
+ return;
+ }
+ for (TkMenuEntry *cascadeEntryPtr = menuPtr->menuRefPtr->parentEntryPtr;
+ cascadeEntryPtr;
+ cascadeEntryPtr = cascadeEntryPtr->nextCascadePtr) {
+ if (cascadeEntryPtr->menuPtr->menuType == MENUBAR
+ && cascadeEntryPtr->menuPtr->masterMenuPtr->tkwin) {
+ TkMenu *masterMenuPtr = cascadeEntryPtr->menuPtr->masterMenuPtr;
+ int i = 0;
+ Tcl_DString ds;
+
+ Tcl_DStringInit(&ds);
+ Tcl_DStringAppend(&ds, Tk_PathName(masterMenuPtr->tkwin), -1);
+ while (specialMenus[i].name) {
+ Tcl_DStringAppend(&ds, specialMenus[i].name,
+ specialMenus[i].len);
+ if (strcmp(Tcl_DStringValue(&ds),
+ Tk_PathName(menuPtr->masterMenuPtr->tkwin)) == 0) {
+ cascadeEntryPtr->entryFlags |= specialMenus[i].flag;
} else {
- *textWidthPtr = width;
- }
- if (geometryPtr->modifierNum) {
- *modWidthPtr = geometryPtr->modifierWidth;
+ cascadeEntryPtr->entryFlags &= ~specialMenus[i].flag;
}
+ Tcl_DStringSetLength(&ds, Tcl_DStringLength(&ds) -
+ specialMenus[i].len);
+ i++;
}
- } else {
- *textWidthPtr = Tk_TextWidth(tkfont, accel, mePtr->accelLength);
+ Tcl_DStringFree(&ds);
}
}
}
@@ -2393,48 +914,12 @@ GetMenuAccelGeometry (
/*
*----------------------------------------------------------------------
*
- * GetTearoffEntryGeometry --
- *
- * Gets the width and height of of a tearoff entry.
- *
- * Results:
- * widthPtr and heightPtr are set.
- *
- * Side effects:
- * None.
- *
- *----------------------------------------------------------------------
- */
-
-void
-GetTearoffEntryGeometry (
- TkMenu *menuPtr, /* The menu we are drawing */
- TkMenuEntry *mePtr, /* The entry we are measuring */
- Tk_Font tkfont, /* The precalculated font */
- const Tk_FontMetrics *fmPtr,/* The precalculated font metrics */
- int *widthPtr, /* The resulting width */
- int *heightPtr) /* The resulting height */
-{
-#ifdef USE_TK_MDEF
- const int useMDEF = ((MacMenu *) menuPtr->platformData)->useMDEF;
-#endif
- if (useMDEF && menuPtr->menuType != TEAROFF_MENU) {
- *heightPtr = fmPtr->linespace + menuItemExtraHeight;
- *widthPtr = menuPtr->totalWidth;
- } else {
- *widthPtr = *heightPtr = 0;
- }
-}
-
-/*
- *----------------------------------------------------------------------
- *
- * GetMenuSeparatorGeometry --
+ * ParseAccelerator --
*
- * Gets the width and height of menu separator.
+ * Parse accelerator string.
*
* Results:
- * widthPtr and heightPtr are set.
+ * Accelerator string & flags.
*
* Side effects:
* None.
@@ -2442,705 +927,96 @@ GetTearoffEntryGeometry (
*----------------------------------------------------------------------
*/
-void
-GetMenuSeparatorGeometry(
- TkMenu *menuPtr, /* The menu we are drawing */
- TkMenuEntry *mePtr, /* The entry we are measuring */
- Tk_Font tkfont, /* The precalculated font */
- const Tk_FontMetrics *fmPtr,/* The precalcualted font metrics */
- int *widthPtr, /* The resulting width */
- int *heightPtr) /* The resulting height */
+static NSString *
+ParseAccelerator(
+ const char *accel,
+ NSUInteger *maskPtr)
{
- *widthPtr = 0;
- *heightPtr = menuSeparatorHeight;
-}
-
-/*
- *----------------------------------------------------------------------
- *
- * DrawMenuEntryIndicator --
- *
- * This procedure draws the indicator part of a menu.
- *
- * Results:
- * None.
- *
- * Side effects:
- * Commands are output to X to display the menu in its
- * current mode.
- *
- *----------------------------------------------------------------------
- */
-
-void
-DrawMenuEntryIndicator(
- TkMenu *menuPtr, /* The menu we are drawing */
- TkMenuEntry *mePtr, /* The entry we are drawing */
- Drawable d, /* The drawable we are drawing */
- GC gc, /* The GC we are drawing with */
- GC indicatorGC, /* The GC to use for the indicator */
- Tk_Font tkfont, /* The precalculated font */
- const Tk_FontMetrics *fmPtr,/* The precalculated font metrics */
- int x, /* topleft hand corner of entry */
- int y, /* topleft hand corner of entry */
- int width, /* width of entry */
- int height) /* height of entry */
-{
- if ((mePtr->type == CHECK_BUTTON_ENTRY) ||
- (mePtr->type == RADIO_BUTTON_ENTRY)) {
- if (mePtr->indicatorOn && (mePtr->entryFlags & ENTRY_SELECTED)) {
- short mark;
- int baseline = y + (height + fmPtr->ascent - fmPtr->descent)/2;
-
- GetItemMark(((MacMenu *) menuPtr->platformData)->menuHdl,
- mePtr->index + 1, &mark);
- if (IS_THEME_MENU_FONT(tkfont)) {
- ThemeFontID font = kThemeMenuItemMarkFont;
- TextEncoding encoding = GetApplicationTextEncoding();
- CFStringRef cfStr;
- ThemeDrawState drawState;
- Rect bounds = {y, x + menuMarkIndent, y + height, x + width};
-
- if (mark < kSpaceCharCode) {
- font = kThemeMenuItemCmdKeyFont;
- encoding = kTextEncodingMacKeyboardGlyphs;
- }
- switch (mePtr->state) {
- case ENTRY_ACTIVE:
- drawState = kThemeStatePressed;
- break;
- case ENTRY_DISABLED:
- drawState = kThemeStateInactive;
- break;
- default:
- drawState = kThemeStateActive;
- break;
- }
- cfStr = CFStringCreateWithBytes(NULL, (UInt8*)&mark, 1,
- encoding, false);
- if (cfStr) {
- DrawThemeText(d, gc, cfStr, font, drawState, &bounds,
- baseline, teFlushDefault);
- CFRelease(cfStr);
- }
- } else if (mark != 0) {
- const char *markUtf = NULL;
- int len;
+ unichar ch = 0;
+ size_t len;
+ int i;
- len = GetUtfMarkCharacter(mark, &markUtf);
- Tk_DrawChars(menuPtr->display, d, gc, tkfont, markUtf, len,
- x + menuMarkIndent, baseline);
+ *maskPtr = 0;
+ while (1) {
+ i = 0;
+ while (modifiers[i].name) {
+ int l = modifiers[i].len;
+
+ if (!strncasecmp(accel, modifiers[i].name, l) &&
+ (accel[l] == '-' || accel[l] == '+')) {
+ *maskPtr |= modifiers[i].mask;
+ accel += l+1;
+ break;
}
+ i++;
+ }
+ if (!modifiers[i].name || !*accel) {
+ break;
}
}
-}
-
-#ifdef USE_TK_MDEF
-/*
- *----------------------------------------------------------------------
- *
- * DrawMenuBackground --
- *
- * If Appearance is present, draws the Appearance background
- *
- * Results:
- * Nothing
- *
- * Side effects:
- * Commands are output to X to display the menu in its
- * current mode.
- *
- *----------------------------------------------------------------------
- */
-void
-DrawMenuBackground(
- TkMenu *menuPtr,
- Rect *menuRectPtr, /* The menu rect */
- Drawable d) /* What we are drawing into */
-{
- Tk_3DBorder border;
-
- EraseMenuBackground(((MacMenu *) menuPtr->platformData)->menuHdl,
- menuRectPtr, ((MacDrawable*)d)->context);
- border = Tk_Get3DBorderFromObj(menuPtr->tkwin, menuPtr->borderPtr);
- Tk_Fill3DRectangle(menuPtr->tkwin, d, border,
- menuRectPtr->left, menuRectPtr->top,
- menuRectPtr->right - menuRectPtr->left,
- menuRectPtr->bottom - menuRectPtr->top, 0, TK_RELIEF_FLAT);
-}
-#endif /* USE_TK_MDEF */
-
-/*
- *----------------------------------------------------------------------
- *
- * DrawMenuEntryAccelerator --
- *
- * This procedure draws the accelerator part of a menu.
- *
- * Results:
- * None.
- *
- * Side effects:
- * Commands are output to X to display the menu in its
- * current mode.
- *
- *----------------------------------------------------------------------
- */
+ len = strlen(accel);
+ if (len > 1) {
+ i = 0;
+ if (accel[0] == 'F' && len < 4 && accel[1] > '0' && accel[1] <= '9') {
+ int fkey = accel[1] - '0';
-void
-DrawMenuEntryAccelerator(
- TkMenu *menuPtr, /* The menu we are drawing */
- TkMenuEntry *mePtr, /* The entry we are drawing */
- Drawable d, /* The drawable we are drawing in */
- GC gc, /* The gc to draw into */
- Tk_Font tkfont, /* The precalculated font */
- const Tk_FontMetrics *fmPtr,/* The precalculated font metrics */
- Tk_3DBorder activeBorder, /* border for menu background */
- int x, /* The left side of the entry */
- int y, /* The top of the entry */
- int width, /* The width of the entry */
- int height, /* The height of the entry */
- int drawArrow) /* Whether or not to draw cascade arrow */
-{
- if (mePtr->type != CASCADE_ENTRY && mePtr->accelLength > 0) {
- const char *accel = (mePtr->accelPtr == NULL) ? ""
- : Tcl_GetString(mePtr->accelPtr);
- EntryGeometry *geometryPtr = (EntryGeometry*)mePtr->platformEntryData;
- int leftEdge = x + width - geometryPtr->accelTextWidth;
- int baseline = y + (height + fmPtr->ascent - fmPtr->descent) / 2;
-
- if (IS_THEME_MENU_FONT(tkfont)) {
- CFStringRef cfStr;
- ThemeDrawState drawState;
-
- switch (mePtr->state) {
- case ENTRY_ACTIVE:
- drawState = kThemeStatePressed;
- break;
- case ENTRY_DISABLED:
- drawState = kThemeStateInactive;
- break;
- default:
- drawState = kThemeStateActive;
- break;
- }
- if ((mePtr->entryFlags & ENTRY_ACCEL_MASK) == 0) {
- leftEdge -= geometryPtr->modifierWidth;
- }
- if (geometryPtr->accelGlyph) {
- Rect bounds = {y, leftEdge, y + height, leftEdge +
- geometryPtr->accelTextWidth};
-
- cfStr = CFStringCreateWithBytes(NULL,
- (UInt8*)&geometryPtr->accelGlyph, 1,
- kTextEncodingMacKeyboardGlyphs, false);
- if (cfStr) {
- DrawThemeText(d, gc, cfStr, kThemeMenuItemCmdKeyFont,
- drawState, &bounds, baseline, teFlushDefault);
- CFRelease(cfStr);
+ if (len == 3) {
+ if (accel[2] >= '0' && accel[2] <= '9') {
+ fkey = 10 * fkey + (accel[2] - '0');
+ } else {
+ fkey = 0;
}
- } else {
- Tk_DrawChars(menuPtr->display, d, gc, tkfont, accel +
- geometryPtr->accelTextStart, mePtr->accelLength -
- geometryPtr->accelTextStart, leftEdge, baseline);
}
- if (geometryPtr->modifierNum) {
- Rect bounds = {y, leftEdge - geometryPtr->modifierWidth,
- y + height, leftEdge};
-
- cfStr = CFStringCreateWithCharacters(NULL,
- geometryPtr->modifierUniChars,
- geometryPtr->modifierNum);
- if (cfStr) {
- DrawThemeText(d, gc, cfStr, kThemeMenuItemCmdKeyFont,
- drawState, &bounds, baseline, teFlushDefault);
- CFRelease(cfStr);
- }
+ if (fkey >= 1 && fkey <= 15) {
+ ch = NSF1FunctionKey + fkey - 1;
}
- } else {
- Tk_DrawChars(menuPtr->display, d, gc, tkfont, accel,
- mePtr->accelLength, leftEdge, baseline);
+ } else while (specialAccelerators[i].name) {
+ if (accel[0] == specialAccelerators[i].name[0] &&
+ len == specialAccelerators[i].len && !strncasecmp(accel,
+ specialAccelerators[i].name, specialAccelerators[i].len)) {
+ ch = specialAccelerators[i].ch;
+ break;
+ }
+ i++;
}
}
-}
-
-/*
- *----------------------------------------------------------------------
- *
- * DrawMenuSeparator --
- *
- * The menu separator is drawn.
- *
- * Results:
- * None.
- *
- * Side effects:
- * Commands are output to X to display the menu in its
- * current mode.
- *
- *----------------------------------------------------------------------
- */
-
-void
-DrawMenuSeparator(
- TkMenu *menuPtr, /* The menu we are drawing */
- TkMenuEntry *mePtr, /* The entry we are drawing */
- Drawable d, /* The drawable we are drawing into */
- GC gc, /* The gc we are drawing with */
- Tk_Font tkfont, /* The precalculated font */
- const Tk_FontMetrics *fmPtr,/* The precalculated font metrics */
- int x, /* left coordinate of entry */
- int y, /* top coordinate of entry */
- int width, /* width of entry */
- int height) /* height of entry */
-{
- TkMacOSXDrawingContext dc;
- Rect r;
-
- r.top = y;
- r.left = x;
- r.bottom = y + height;
- r.right = x + width;
- if (TkMacOSXSetupDrawingContext(d, gc, 1, &dc)) {
- ChkErr(DrawThemeMenuSeparator, &r);
- TkMacOSXRestoreDrawingContext(&dc);
- }
-}
-
-#ifdef USE_TK_MDEF
-/*
- *----------------------------------------------------------------------
- *
- * AppearanceEntryDrawWrapper --
- *
- * It routes to the Appearance Managers DrawThemeEntry, which will
- * then call us back after setting up the drawing context.
- *
- * Results:
- * A menu entry is drawn
- *
- * Side effects:
- * None
- *
- *----------------------------------------------------------------------
- */
-void
-AppearanceEntryDrawWrapper(
- TkMenuEntry *mePtr,
- Rect *menuRectPtr,
- MenuTrackingData *mtdPtr,
- Drawable d,
- Tk_FontMetrics *fmPtr,
- Tk_Font tkfont,
- int erase)
-{
- MenuEntryUserData meData;
- Rect itemRect;
- ThemeMenuState theState;
- ThemeMenuItemType theType;
- Tk_FontMetrics entryMetrics;
-
- meData.mePtr = mePtr;
- meData.mdefDrawable = d;
- if (mePtr->fontPtr == NULL) {
- meData.fmPtr = fmPtr;
- meData.tkfont = tkfont;
- } else {
- meData.tkfont = Tk_GetFontFromObj(mePtr->menuPtr->tkwin,
- mePtr->fontPtr);
- Tk_GetFontMetrics(meData.tkfont, &entryMetrics);
- fmPtr = &entryMetrics;
- }
- itemRect.left = menuRectPtr->left + mePtr->x;
- itemRect.top = mtdPtr->virtualMenuTop + mePtr->y;
- itemRect.right = mePtr->entryFlags & ENTRY_LAST_COLUMN ?
- menuRectPtr->right : itemRect.left + mePtr->width;
- itemRect.bottom = itemRect.top + mePtr->height;
-
- if (mePtr->state == ENTRY_ACTIVE) {
- theState = kThemeMenuSelected;
- } else if (mePtr->state == ENTRY_DISABLED) {
- theState = kThemeMenuDisabled;
- } else {
- theState = kThemeMenuActive;
- }
- if (mePtr->type == CASCADE_ENTRY) {
- theType = kThemeMenuItemHierarchical;
+ if (ch) {
+ return [[[NSString alloc] initWithCharacters:&ch length:1] autorelease];
} else {
- theType = kThemeMenuItemPlain;
+ return [[[[NSString alloc] initWithUTF8String:accel] autorelease]
+ lowercaseString];
}
- if (erase) {
- DisableScreenUpdates();
- DrawMenuBackground(mePtr->menuPtr, &itemRect, d);
- }
- DrawThemeMenuItem(menuRectPtr, &itemRect,
- mtdPtr->virtualMenuTop, mtdPtr->virtualMenuBottom, theState,
- theType | kThemeMenuItemNoBackground, tkThemeMenuItemDrawingUPP,
- (unsigned long) &meData);
- if (erase) {
- EnableScreenUpdates();
- }
-}
-
-/*
- *----------------------------------------------------------------------
- *
- * ThemeMenuItemDrawingProc --
- *
- * This routine is called from the Appearance DrawThemeMenuEntry
- *
- * Results:
- * A menu entry is drawn
- *
- * Side effects:
- * None
- *
- *----------------------------------------------------------------------
- */
-pascal void
-ThemeMenuItemDrawingProc(
- const Rect *inBounds,
- SInt16 inDepth,
- Boolean inIsColorDevice,
- SInt32 inUserData)
-{
- MenuEntryUserData *meData = (MenuEntryUserData *) inUserData;
-
- TkpDrawMenuEntry(meData->mePtr, meData->mdefDrawable, meData->tkfont,
- meData->fmPtr, inBounds->left, inBounds->top, inBounds->right -
- inBounds->left + menuItemExtraWidth, inBounds->bottom -
- inBounds->top + menuItemExtraHeight, 0, 1);
-}
-#endif /* USE_TK_MDEF */
-
-/*
- *----------------------------------------------------------------------
- *
- * TkMacOSXHandleTearoffMenu() --
- *
- * This routine sees if the MDEF has set a menu and a mouse position
- * for tearing off and makes a tearoff menu if it has.
- *
- * Results:
- * menuPtr->interp will have the result of the tearoff command.
- *
- * Side effects:
- * A new tearoff menu is created if it is supposed to be.
- *
- *----------------------------------------------------------------------
- */
-
-void
-TkMacOSXHandleTearoffMenu(void)
-{
- /*
- * Obsolete: Nothing to do.
- */
}
/*
*--------------------------------------------------------------
*
- * TkpInitializeMenuBindings --
+ * ModifierCharWidth --
*
- * For every interp, initializes the bindings for Windows
- * menus. Does nothing on Mac or XWindows.
+ * Helper mesuring width of command char in given font.
*
* Results:
- * None.
+ * Width of command char.
*
* Side effects:
- * C-level bindings are setup for the interp which will
- * handle Alt-key sequences for menus without beeping
- * or interfering with user-defined Alt-key bindings.
- *
- *--------------------------------------------------------------
- */
-
-void
-TkpInitializeMenuBindings(
- Tcl_Interp *interp, /* The interpreter to set. */
- Tk_BindingTable bindingTable)
- /* The table to add to. */
-{
- /*
- * Nothing to do.
- */
-}
-
-/*
- *--------------------------------------------------------------
- *
- * TkpComputeMenubarGeometry --
- *
- * This procedure is invoked to recompute the size and
- * layout of a menu that is a menubar clone.
- *
- * Results:
* None.
*
- * Side effects:
- * Fields of menu entries are changed to reflect their
- * current positions, and the size of the menu window
- * itself may be changed.
- *
*--------------------------------------------------------------
*/
-void
-TkpComputeMenubarGeometry(
- TkMenu *menuPtr) /* Structure describing menu. */
-{
- TkpComputeStandardMenuGeometry(menuPtr);
-}
-
-/*
- *----------------------------------------------------------------------
- *
- * DrawTearoffEntry --
- *
- * This procedure draws a tearoff entry.
- *
- * Results:
- * None.
- *
- * Side effects:
- * Commands are output to X to display the menu in its
- * current mode.
- *
- *----------------------------------------------------------------------
- */
-
-void
-DrawTearoffEntry(
- TkMenu *menuPtr, /* The menu we are drawing */
- TkMenuEntry *mePtr, /* The entry we are drawing */
- Drawable d, /* The drawable we are drawing into */
- GC gc, /* The gc we are drawing with */
- Tk_Font tkfont, /* The font we are drawing with */
- const Tk_FontMetrics *fmPtr,/* The metrics we are drawing with */
- int x, /* Left edge of entry. */
- int y, /* Top edge of entry. */
- int width, /* Width of entry. */
- int height) /* Height of entry. */
-{
- XPoint points[2];
- int margin, segmentWidth, maxX;
- Tk_3DBorder border;
-
- if (menuPtr->menuType != MASTER_MENU ) {
- return;
- }
-
- margin = fmPtr->linespace/2;
- points[0].x = x;
- points[0].y = y + height/2;
- points[1].y = points[0].y;
- segmentWidth = 6;
- maxX = x + menuPtr->totalWidth - 1;
- border = Tk_Get3DBorderFromObj(menuPtr->tkwin, menuPtr->borderPtr);
-
- while (points[0].x < maxX) {
- points[1].x = points[0].x + segmentWidth;
- if (points[1].x > maxX) {
- points[1].x = maxX;
- }
- Tk_Draw3DPolygon(menuPtr->tkwin, d, border, points, 2, 1,
- TK_RELIEF_RAISED);
- points[0].x += 2*segmentWidth;
- }
-}
-
-/*
- *----------------------------------------------------------------------
- *
- * TkMacOSXSetHelpMenuItemCount --
- *
- * Has to be called after the first call to InsertMenu. Sets
- * up the global variable for the number of items in the
- * unmodified help menu.
- * NB. Nobody uses this any more, since you can get the number
- * of system help items from HMGetHelpMenu trivially.
- * But it is in the stubs table...
- *
- * Results:
- * None.
- *
- * Side effects:
- * Nothing.
- *
- *----------------------------------------------------------------------
- */
-
-void
-TkMacOSXSetHelpMenuItemCount(void)
-{
- /*
- * Obsolete: Nothing to do.
- */
-}
-
-/*
- *----------------------------------------------------------------------
- *
- * TkMacOSXMenuClick --
- *
- * Prepares a menubar for MenuSelect or MenuKey.
- *
- * Results:
- * None.
- *
- * Side effects:
- * Any pending configurations of the menubar are completed.
- *
- *----------------------------------------------------------------------
- */
-
-void
-TkMacOSXMenuClick(void)
-{
- TkMenu *menuPtr;
- TkMenuReferences *menuRefPtr;
-
- if ((currentMenuBarInterp != NULL) && (currentMenuBarName != NULL)) {
- menuRefPtr = TkFindMenuReferences(currentMenuBarInterp,
- currentMenuBarName);
- for (menuPtr = menuRefPtr->menuPtr->masterMenuPtr;
- menuPtr != NULL; menuPtr = menuPtr->nextInstancePtr) {
- if (menuPtr->menuType == MENUBAR) {
- CompleteIdlers(menuPtr);
- break;
- }
- }
- }
-
- if (menuBarFlags & MENUBAR_REDRAW_PENDING) {
- Tcl_CancelIdleCall(DrawMenuBarWhenIdle, NULL);
- DrawMenuBarWhenIdle(NULL);
- }
-}
-
-/*
- *----------------------------------------------------------------------
- *
- * TkpDrawMenuEntry --
- *
- * Draws the given menu entry at the given coordinates with the
- * given attributes.
- *
- * Results:
- * None.
- *
- * Side effects:
- * X Server commands are executed to display the menu entry.
- *
- *----------------------------------------------------------------------
- */
-
-void
-TkpDrawMenuEntry(
- TkMenuEntry *mePtr, /* The entry to draw */
- Drawable d, /* What to draw into */
- Tk_Font tkfont, /* Precalculated font for menu */
- const Tk_FontMetrics *menuMetricsPtr,
- /* Precalculated metrics for menu */
- int x, /* X-coordinate of topleft of entry */
- int y, /* Y-coordinate of topleft of entry */
- int width, /* Width of the entry rectangle */
- int height, /* Height of the current rectangle */
- int strictMotif, /* Boolean flag */
- int drawArrow) /* Whether or not to draw the cascade
- * arrow for cascade items. Only applies
- * to Windows. */
+static int
+ModifierCharWidth(
+ Tk_Font tkfont)
{
- GC gc;
- TkMenu *menuPtr = mePtr->menuPtr;
- int padY = (menuPtr->menuType == MENUBAR) ? 3 : 0;
- GC indicatorGC;
- Tk_3DBorder bgBorder, activeBorder;
- const Tk_FontMetrics *fmPtr;
- Tk_FontMetrics entryMetrics;
- int adjustedY = y + padY;
- int adjustedHeight = height - 2 * padY;
-
- /*
- * Choose the gc for drawing the foreground part of the entry.
- * Under Appearance, we pass a null (appearanceGC) to tell
- * ourselves not to change whatever color the appearance manager has set.
- */
+ static NSString *cmdChar = nil;
- if ((mePtr->state == ENTRY_ACTIVE) && !strictMotif) {
- gc = mePtr->activeGC;
- if (gc == NULL) {
- gc = menuPtr->activeGC;
- }
- } else {
- TkMenuEntry *parentEntryPtr = GetParentMenuEntry(menuPtr);
-
- if (((parentEntryPtr && parentEntryPtr->state == ENTRY_DISABLED) ||
- (mePtr->state == ENTRY_DISABLED)) &&
- (menuPtr->disabledFgPtr != NULL)) {
- gc = mePtr->disabledGC;
- if (gc == NULL) {
- gc = menuPtr->disabledGC;
- }
- } else {
- gc = mePtr->textGC;
- if (gc == NULL) {
- gc = menuPtr->textGC;
- }
- }
- }
-
- indicatorGC = mePtr->indicatorGC;
- if (indicatorGC == NULL) {
- indicatorGC = menuPtr->indicatorGC;
- }
+ if (!cmdChar) {
+ unichar cmd = kCommandUnicode;
- bgBorder = Tk_Get3DBorderFromObj(menuPtr->tkwin,
- (mePtr->borderPtr == NULL)
- ? menuPtr->borderPtr : mePtr->borderPtr);
- if (strictMotif) {
- activeBorder = bgBorder;
- } else {
- activeBorder = Tk_Get3DBorderFromObj(menuPtr->tkwin,
- (mePtr->activeBorderPtr == NULL)
- ? menuPtr->activeBorderPtr : mePtr->activeBorderPtr);
- }
-
- if (mePtr->fontPtr == NULL) {
- fmPtr = menuMetricsPtr;
- } else {
- tkfont = Tk_GetFontFromObj(menuPtr->tkwin, mePtr->fontPtr);
- Tk_GetFontMetrics(tkfont, &entryMetrics);
- fmPtr = &entryMetrics;
- }
-
- /*
- * Need to draw the entire background, including padding. On Unix,
- * for menubars, we have to draw the rest of the entry taking
- * into account the padding.
- */
-
- DrawMenuEntryBackground(menuPtr, mePtr, d, activeBorder, bgBorder, x, y,
- width, height);
-
- if (mePtr->type == SEPARATOR_ENTRY) {
- DrawMenuSeparator(menuPtr, mePtr, d, gc, tkfont,
- fmPtr, x, adjustedY, width, adjustedHeight);
- } else if (mePtr->type == TEAROFF_ENTRY) {
- DrawTearoffEntry(menuPtr, mePtr, d, gc, tkfont, fmPtr, x, adjustedY,
- width, adjustedHeight);
- } else {
- DrawMenuEntryLabel(menuPtr, mePtr, d, gc, tkfont, fmPtr, x,
- adjustedY, width, adjustedHeight);
- DrawMenuEntryAccelerator(menuPtr, mePtr, d, gc, tkfont, fmPtr,
- activeBorder, x, adjustedY, width, adjustedHeight, drawArrow);
- if (!mePtr->hideMargin) {
- DrawMenuEntryIndicator(menuPtr, mePtr, d, gc, indicatorGC, tkfont,
- fmPtr, x, adjustedY, width, adjustedHeight);
- }
+ cmdChar = [[NSString alloc] initWithCharacters:&cmd length:1];
}
+ return [cmdChar sizeWithAttributes:
+ TkMacOSXNSFontAttributesForFont(tkfont)].width;
}
/*
@@ -3148,16 +1024,15 @@ TkpDrawMenuEntry(
*
* TkpComputeStandardMenuGeometry --
*
- * This procedure is invoked to recompute the size and
- * layout of a menu that is not a menubar clone.
+ * This procedure is invoked to recompute the size and layout of a menu
+ * that is not a menubar clone.
*
* Results:
* None.
*
* Side effects:
- * Fields of menu entries are changed to reflect their
- * current positions, and the size of the menu window
- * itself may be changed.
+ * Fields of menu entries are changed to reflect their current positions,
+ * and the size of the menu window itself may be changed.
*
*--------------------------------------------------------------
*/
@@ -3168,13 +1043,12 @@ TkpComputeStandardMenuGeometry(
{
Tk_Font tkfont, menuFont;
Tk_FontMetrics menuMetrics, entryMetrics, *fmPtr;
- int x, y, height, modifierWidth, labelWidth, indicatorSpace;
- int windowWidth, windowHeight, accelWidth, maxAccelTextWidth;
- int i, j, lastColumnBreak, maxModifierWidth, maxWidth, nonAccelMargin;
- int maxNonAccelMargin, maxEntryWithAccelWidth, maxEntryWithoutAccelWidth;
+ int modifierCharWidth, menuModifierCharWidth;
+ int x, y, modifierWidth, labelWidth, indicatorSpace;
+ int windowWidth, windowHeight, accelWidth;
+ int i, j, lastColumnBreak, maxWidth;
int entryWidth, maxIndicatorSpace, borderWidth, activeBorderWidth;
TkMenuEntry *mePtr, *columnEntryPtr;
- EntryGeometry *geometryPtr;
int haveAccel = 0;
if (menuPtr->tkwin == NULL) {
@@ -3186,25 +1060,22 @@ TkpComputeStandardMenuGeometry(
Tk_GetPixelsFromObj(NULL, menuPtr->tkwin, menuPtr->activeBorderWidthPtr,
&activeBorderWidth);
x = y = borderWidth;
- indicatorSpace = labelWidth = accelWidth = maxAccelTextWidth = 0;
- windowHeight = windowWidth = maxWidth = lastColumnBreak = 0;
- maxModifierWidth = nonAccelMargin = maxNonAccelMargin = 0;
- maxEntryWithAccelWidth = maxEntryWithoutAccelWidth = 0;
+ windowHeight = maxWidth = lastColumnBreak = 0;
maxIndicatorSpace = 0;
/*
- * On the Mac especially, getting font metrics can be quite slow,
- * so we want to do it intelligently. We are going to precalculate
- * them and pass them down to all of the measuring and drawing
- * routines. We will measure the font metrics of the menu once.
- * If an entry does not have its own font set, then we give
- * the geometry/drawing routines the menu's font and metrics.
- * If an entry has its own font, we will measure that font and
- * give all of the geometry/drawing the entry's font and metrics.
+ * On the Mac especially, getting font metrics can be quite slow, so we
+ * want to do it intelligently. We are going to precalculate them and pass
+ * them down to all of the measuring and drawing routines. We will measure
+ * the font metrics of the menu once. If an entry does not have its own
+ * font set, then we give the geometry/drawing routines the menu's font
+ * and metrics. If an entry has its own font, we will measure that font
+ * and give all of the geometry/drawing the entry's font and metrics.
*/
menuFont = Tk_GetFontFromObj(menuPtr->tkwin, menuPtr->fontPtr);
Tk_GetFontMetrics(menuFont, &menuMetrics);
+ menuModifierCharWidth = ModifierCharWidth(menuFont);
for (i = 0; i < menuPtr->numEntries; i++) {
mePtr = menuPtr->entries[i];
@@ -3219,10 +1090,12 @@ TkpComputeStandardMenuGeometry(
if (mePtr->fontPtr == NULL) {
tkfont = menuFont;
fmPtr = &menuMetrics;
+ modifierCharWidth = menuModifierCharWidth;
} else {
tkfont = Tk_GetFontFromObj(menuPtr->tkwin, mePtr->fontPtr);
Tk_GetFontMetrics(tkfont, &entryMetrics);
fmPtr = &entryMetrics;
+ modifierCharWidth = ModifierCharWidth(tkfont);
}
if ((i > 0) && mePtr->columnBreak) {
@@ -3231,120 +1104,106 @@ TkpComputeStandardMenuGeometry(
}
for (j = lastColumnBreak; j < i; j++) {
columnEntryPtr = menuPtr->entries[j];
- geometryPtr =
- (EntryGeometry *) columnEntryPtr->platformEntryData;
-
columnEntryPtr->indicatorSpace = maxIndicatorSpace;
columnEntryPtr->width = maxIndicatorSpace + maxWidth
+ 2 * activeBorderWidth;
- geometryPtr->accelTextWidth = maxAccelTextWidth;
- geometryPtr->modifierWidth = maxModifierWidth;
columnEntryPtr->x = x;
columnEntryPtr->entryFlags &= ~ENTRY_LAST_COLUMN;
- if (maxEntryWithoutAccelWidth > maxEntryWithAccelWidth) {
- geometryPtr->nonAccelMargin = maxEntryWithoutAccelWidth
- - maxEntryWithAccelWidth;
- if (geometryPtr->nonAccelMargin > maxNonAccelMargin) {
- geometryPtr->nonAccelMargin = maxNonAccelMargin;
- }
- } else {
- geometryPtr->nonAccelMargin = 0;
- }
}
x += maxIndicatorSpace + maxWidth + 2 * borderWidth;
- windowWidth = x;
- maxWidth = maxIndicatorSpace = maxAccelTextWidth = 0;
- maxModifierWidth = maxNonAccelMargin = maxEntryWithAccelWidth = 0;
- maxEntryWithoutAccelWidth = 0;
+ maxWidth = maxIndicatorSpace = 0;
lastColumnBreak = i;
y = borderWidth;
}
- geometryPtr = (EntryGeometry *) mePtr->platformEntryData;
-
- if (mePtr->type == SEPARATOR_ENTRY) {
- GetMenuSeparatorGeometry(menuPtr, mePtr, tkfont,
- fmPtr, &entryWidth, &height);
- mePtr->height = height;
- } else if (mePtr->type == TEAROFF_ENTRY) {
- GetTearoffEntryGeometry(menuPtr, mePtr, tkfont,
- fmPtr, &entryWidth, &height);
- mePtr->height = height;
+ accelWidth = modifierWidth = indicatorSpace = 0;
+ if (mePtr->type == SEPARATOR_ENTRY || mePtr->type == TEAROFF_ENTRY) {
+ mePtr->height = menuSeparatorHeight;
} else {
/*
- * For each entry, compute the height required by that
- * particular entry, plus three widths: the width of the
- * label, the width to allow for an indicator to be displayed
- * to the left of the label (if any), and the width of the
- * accelerator to be displayed to the right of the label
- * (if any). These sizes depend, of course, on the type
- * of the entry.
+ * For each entry, compute the height required by that particular
+ * entry, plus three widths: the width of the label, the width to
+ * allow for an indicator to be displayed to the left of the label
+ * (if any), and the width of the accelerator to be displayed to
+ * the right of the label (if any). These sizes depend, of course,
+ * on the type of the entry.
*/
- GetMenuLabelGeometry(mePtr, tkfont, fmPtr, &labelWidth, &height);
- mePtr->height = height;
+ NSMenuItem *menuItem = (NSMenuItem *) mePtr->platformEntryData;
+ int haveImage = 0, width = 0, height = 0;
- nonAccelMargin = 0;
- if (mePtr->type == CASCADE_ENTRY) {
- GetMenuAccelGeometry(menuPtr, mePtr, tkfont, fmPtr,
- &modifierWidth, &accelWidth, &height);
- } else if (mePtr->accelLength == 0) {
- if (haveAccel && !mePtr->hideMargin) {
- if (IS_THEME_MENU_FONT(tkfont)) {
- nonAccelMargin = menuSymbols[COMMAND_SYMBOL].width;
- } else {
- nonAccelMargin = Tk_TextWidth(tkfont,
- menuSymbols[COMMAND_SYMBOL].utf,
- menuSymbols[COMMAND_SYMBOL].utfLen);
- }
+ if (mePtr->image) {
+ Tk_SizeOfImage(mePtr->image, &width, &height);
+ haveImage = 1;
+ } else if (mePtr->bitmapPtr) {
+ Pixmap bitmap = Tk_GetBitmapFromObj(menuPtr->tkwin,
+ mePtr->bitmapPtr);
+
+ Tk_SizeOfBitmap(menuPtr->display, bitmap, &width, &height);
+ haveImage = 1;
+ }
+ if (!haveImage || (mePtr->compound != COMPOUND_NONE)) {
+ NSAttributedString *attrTitle = [menuItem attributedTitle];
+ NSSize size;
+
+ if (attrTitle) {
+ size = [attrTitle size];
+ } else {
+ size = [[menuItem title] sizeWithAttributes:
+ TkMacOSXNSFontAttributesForFont(tkfont)];
}
- accelWidth = modifierWidth = 0;
- } else {
- GetMenuAccelGeometry(menuPtr, mePtr, tkfont,
- fmPtr, &modifierWidth, &accelWidth, &height);
- if (height > mePtr->height) {
- mePtr->height = height;
+ size.width += menuTextLeadingEdgeMargin +
+ menuTextTrailingEdgeMargin;
+ if (size.height < fmPtr->linespace) {
+ size.height = fmPtr->linespace;
+ }
+ if (haveImage && (mePtr->compound != COMPOUND_NONE)) {
+ int margin = width + menuIconTrailingEdgeMargin;
+
+ if (margin > menuTextLeadingEdgeMargin) {
+ margin = menuTextLeadingEdgeMargin;
+ }
+ width += size.width + menuIconTrailingEdgeMargin - margin;
+ if (size.height > height) {
+ height = size.height;
+ }
+ } else {
+ width = size.width;
+ height = size.height;
}
}
+ labelWidth = width + menuItemExtraWidth;
+ mePtr->height = height + menuItemExtraHeight;
- if (!(mePtr->hideMargin)) {
- GetMenuIndicatorGeometry(menuPtr, mePtr, tkfont,
- fmPtr, &indicatorSpace, &height);
- if (height > mePtr->height) {
- mePtr->height = height;
+ if (mePtr->type == CASCADE_ENTRY) {
+ modifierWidth = modifierCharWidth;
+ } else if (mePtr->accelLength == 0) {
+ if (haveAccel && !mePtr->hideMargin) {
+ modifierWidth = modifierCharWidth;
}
} else {
- indicatorSpace = 0;
- }
+ NSUInteger modifMask = [menuItem keyEquivalentModifierMask];
+ int i = 0;
- if (nonAccelMargin > maxNonAccelMargin) {
- maxNonAccelMargin = nonAccelMargin;
- }
- if (accelWidth > maxAccelTextWidth) {
- maxAccelTextWidth = accelWidth;
+ while (modifiers[i].name) {
+ if (modifMask & modifiers[i].mask) {
+ modifMask &= ~modifiers[i].mask;
+ modifierWidth += modifierCharWidth;
+ }
+ i++;
+ }
+ accelWidth = [[menuItem keyEquivalent] sizeWithAttributes:
+ TkMacOSXNSFontAttributesForFont(tkfont)].width;
}
- if (modifierWidth > maxModifierWidth) {
- maxModifierWidth = modifierWidth;
+ if (!mePtr->hideMargin) {
+ indicatorSpace = menuMarkColumnWidth;
}
if (indicatorSpace > maxIndicatorSpace) {
maxIndicatorSpace = indicatorSpace;
}
-
- entryWidth = labelWidth + modifierWidth + accelWidth
- + nonAccelMargin;
-
+ entryWidth = labelWidth + modifierWidth + accelWidth;
if (entryWidth > maxWidth) {
maxWidth = entryWidth;
}
-
- if (mePtr->accelLength > 0) {
- if (entryWidth > maxEntryWithAccelWidth) {
- maxEntryWithAccelWidth = entryWidth;
- }
- } else {
- if (entryWidth > maxEntryWithoutAccelWidth) {
- maxEntryWithoutAccelWidth = entryWidth;
- }
- }
mePtr->height += 2 * activeBorderWidth;
}
mePtr->y = y;
@@ -3356,33 +1215,16 @@ TkpComputeStandardMenuGeometry(
for (j = lastColumnBreak; j < menuPtr->numEntries; j++) {
columnEntryPtr = menuPtr->entries[j];
- geometryPtr = (EntryGeometry *) columnEntryPtr->platformEntryData;
-
columnEntryPtr->indicatorSpace = maxIndicatorSpace;
columnEntryPtr->width = maxIndicatorSpace + maxWidth
+ 2 * activeBorderWidth;
- geometryPtr->accelTextWidth = maxAccelTextWidth;
columnEntryPtr->x = x;
columnEntryPtr->entryFlags |= ENTRY_LAST_COLUMN;
- if (maxEntryWithoutAccelWidth > maxEntryWithAccelWidth) {
- geometryPtr->nonAccelMargin = maxEntryWithoutAccelWidth
- - maxEntryWithAccelWidth;
- if (geometryPtr->nonAccelMargin > maxNonAccelMargin) {
- geometryPtr->nonAccelMargin = maxNonAccelMargin;
- }
- } else {
- geometryPtr->nonAccelMargin = 0;
- }
}
windowWidth = x + maxIndicatorSpace + maxWidth
+ 2 * activeBorderWidth + borderWidth;
windowHeight += borderWidth;
- /*
- * The X server doesn't like zero dimensions, so round up to at least
- * 1 (a zero-sized menu should never really occur, anyway).
- */
-
if (windowWidth <= 0) {
windowWidth = 1;
}
@@ -3396,353 +1238,7 @@ TkpComputeStandardMenuGeometry(
/*
*----------------------------------------------------------------------
*
- * DrawMenuEntryLabel --
- *
- * This procedure draws the label part of a menu.
- *
- * Results:
- * None.
- *
- * Side effects:
- * Commands are output to X to display the menu in its
- * current mode.
- *
- *----------------------------------------------------------------------
- */
-
-void
-DrawMenuEntryLabel(
- TkMenu *menuPtr, /* The menu we are drawing */
- TkMenuEntry *mePtr, /* The entry we are drawing */
- Drawable d, /* What we are drawing into */
- GC gc, /* The gc we are drawing into */
- Tk_Font tkfont, /* The precalculated font */
- const Tk_FontMetrics *fmPtr,/* The precalculated font metrics */
- int x, /* left edge */
- int y, /* right edge */
- int width, /* width of entry */
- int height) /* height of entry */
-{
- int imageWidth, imageHeight, textWidth = 0, textHeight = 0;
- int indicatorSpace = mePtr->indicatorSpace;
- int leftEdge = x + indicatorSpace;
- int haveImage = 0, haveText = 0;
- int imageXOffset = 0, imageYOffset = 0;
- int textXOffset = 0, textYOffset = 0;
- Pixmap bitmap = (Pixmap) NULL;
- Tcl_DString itemTextDString;
-
- /*
- * Work out what we will need to draw first.
- */
-
- if (mePtr->image != NULL) {
- Tk_SizeOfImage(mePtr->image, &imageWidth, &imageHeight);
- haveImage = 1;
- } else if (mePtr->bitmapPtr != NULL) {
- bitmap = Tk_GetBitmapFromObj(menuPtr->tkwin, mePtr->bitmapPtr);
- Tk_SizeOfBitmap(menuPtr->display, bitmap, &imageWidth, &imageHeight);
- haveImage = 1;
- }
- if (!haveImage || (mePtr->compound != COMPOUND_NONE)) {
- if (mePtr->labelLength > 0) {
- GetEntryText(mePtr, &itemTextDString);
- if (mePtr->compound != COMPOUND_NONE) {
- textWidth = Tk_TextWidth(tkfont,
- Tcl_DStringValue(&itemTextDString),
- Tcl_DStringLength(&itemTextDString)) +
- menuTextLeadingEdgeMargin + menuTextTrailingEdgeMargin;
- textHeight = fmPtr->linespace;
- }
- haveText = 1;
- }
- }
-
- /*
- * Now work out what the relative positions are.
- */
-
- if (haveImage && haveText && (mePtr->compound != COMPOUND_NONE)) {
- int fullWidth = (imageWidth > textWidth ? imageWidth : textWidth);
-
- switch ((enum compound) mePtr->compound) {
- case COMPOUND_TOP:
- textXOffset = (fullWidth - textWidth)/2;
- textYOffset = imageHeight/2 + 2;
- imageXOffset = (fullWidth - imageWidth)/2;
- imageYOffset = -textHeight/2;
- break;
- case COMPOUND_BOTTOM:
- textXOffset = (fullWidth - textWidth)/2;
- textYOffset = -imageHeight/2;
- imageXOffset = (fullWidth - imageWidth)/2;
- imageYOffset = textHeight/2 + 2;
- break;
- case COMPOUND_LEFT:
- /*
- * Position image in the indicator space to the left of the
- * entries, unless this entry is a radio|check button because
- * then the indicator space will be used.
- */
-
- textXOffset = imageWidth + 2 - menuTextLeadingEdgeMargin;
- if ((mePtr->type != CHECK_BUTTON_ENTRY)
- && (mePtr->type != RADIO_BUTTON_ENTRY)) {
- textXOffset -= indicatorSpace;
- imageXOffset = -indicatorSpace;
- }
- if (textXOffset < 0) {
- textXOffset = 0;
- }
- break;
- case COMPOUND_RIGHT:
- imageXOffset = textWidth + 2 - menuTextTrailingEdgeMargin;
- break;
- case COMPOUND_CENTER:
- textXOffset = (fullWidth - textWidth)/2;
- imageXOffset = (fullWidth - imageWidth)/2;
- break;
- case COMPOUND_NONE:
- /*
- * Never reached.
- */
- break;
- }
- }
-
- /*
- * Draw label and/or bitmap or image for entry.
- */
-
- if (mePtr->image != NULL) {
- if ((mePtr->selectImage != NULL)
- && (mePtr->entryFlags & ENTRY_SELECTED)) {
- Tk_RedrawImage(mePtr->selectImage, 0, 0, imageWidth, imageHeight,
- d, leftEdge + imageXOffset,
- y + (mePtr->height - imageHeight)/2 + imageYOffset);
- } else {
- Tk_RedrawImage(mePtr->image, 0, 0, imageWidth, imageHeight,
- d, leftEdge + imageXOffset,
- y + (mePtr->height - imageHeight)/2 + imageYOffset);
- }
- } else if (mePtr->bitmapPtr != NULL) {
- XCopyPlane(menuPtr->display, bitmap, d, gc, 0, 0, imageWidth,
- imageHeight, leftEdge + imageXOffset,
- y + (mePtr->height - imageHeight)/2 + imageYOffset, 1);
- }
- if (haveText) {
- int baseline = y + (height + fmPtr->ascent - fmPtr->descent)/2;
-
- Tk_DrawChars(menuPtr->display, d, gc, tkfont,
- Tcl_DStringValue(&itemTextDString),
- Tcl_DStringLength(&itemTextDString),
- leftEdge + menuTextLeadingEdgeMargin + textXOffset,
- baseline + textYOffset);
- Tcl_DStringFree(&itemTextDString);
- }
-
- if (mePtr->state == ENTRY_DISABLED) {
- if (menuPtr->disabledFgPtr == NULL) {
- /* XFillRectangle(menuPtr->display, d, menuPtr->disabledGC, x, y,
- width, height); */
- } else if ((mePtr->image != NULL)
- && (menuPtr->disabledImageGC != None)) {
- XFillRectangle(menuPtr->display, d, menuPtr->disabledImageGC,
- leftEdge + imageXOffset,
- y + (mePtr->height - imageHeight)/2 + imageYOffset,
- imageWidth, imageHeight);
- }
- }
-}
-
-/*
- *----------------------------------------------------------------------
- *
- * DrawMenuEntryBackground --
- *
- * This procedure draws the background part of a menu entry.
- * Under Appearance, we only draw the background if the entry's
- * border is set, we DO NOT inherit it from the menu...
- *
- * Results:
- * None.
- *
- * Side effects:
- * Commands are output to X to display the menu in its
- * current mode.
- *
- *----------------------------------------------------------------------
- */
-
-void
-DrawMenuEntryBackground(
- TkMenu *menuPtr, /* The menu we are drawing. */
- TkMenuEntry *mePtr, /* The entry we are drawing. */
- Drawable d, /* What we are drawing into */
- Tk_3DBorder activeBorder, /* Border for active items */
- Tk_3DBorder bgBorder, /* Border for the background */
- int x, /* left edge */
- int y, /* top edge */
- int width, /* width of rectangle to draw */
- int height) /* height of rectangle to draw */
-{
- if ((menuPtr->menuType == TEAROFF_MENU)
- || ((mePtr->state == ENTRY_ACTIVE)
- && (mePtr->activeBorderPtr != None))
- || ((mePtr->state != ENTRY_ACTIVE) && (mePtr->borderPtr != None))) {
- if (mePtr->state == ENTRY_ACTIVE) {
- bgBorder = activeBorder;
- }
- Tk_Fill3DRectangle(menuPtr->tkwin, d, bgBorder,
- x, y, width, height, 0, TK_RELIEF_FLAT);
- }
-}
-
-/*
- *----------------------------------------------------------------------
- *
- * GetMenuLabelGeometry --
- *
- * Figures out the size of the label portion of a menu item.
- *
- * Results:
- * widthPtr and heightPtr are filled in with the correct geometry
- * information.
- *
- * Side effects:
- * None.
- *
- *----------------------------------------------------------------------
- */
-
-void
-GetMenuLabelGeometry(
- TkMenuEntry *mePtr, /* The entry we are computing */
- Tk_Font tkfont, /* The precalculated font */
- const Tk_FontMetrics *fmPtr,/* The precalculated metrics */
- int *widthPtr, /* The resulting width of the label portion */
- int *heightPtr) /* The resulting height of the label portion */
-{
- TkMenu *menuPtr = mePtr->menuPtr;
- int haveImage = 0, tornOff = (menuPtr->menuType == TEAROFF_MENU);
-#ifdef USE_TK_MDEF
- const int useMDEF = ((MacMenu *) menuPtr->platformData)->useMDEF;
-#endif
-
- if (mePtr->image != NULL && (useMDEF || tornOff)) {
- Tk_SizeOfImage(mePtr->image, widthPtr, heightPtr);
- haveImage = 1;
- } else if (mePtr->bitmapPtr != NULL && (useMDEF || tornOff)) {
- Pixmap bitmap = Tk_GetBitmapFromObj(menuPtr->tkwin, mePtr->bitmapPtr);
- Tk_SizeOfBitmap(menuPtr->display, bitmap, widthPtr, heightPtr);
- haveImage = 1;
- }
- if (!haveImage || (mePtr->compound != COMPOUND_NONE)) {
- int textWidth = 0, textHeight = fmPtr->linespace;
-
- if (mePtr->labelPtr != NULL) {
- Tcl_DString itemTextDString;
-
- GetEntryText(mePtr, &itemTextDString);
- textWidth = Tk_TextWidth(tkfont,
- Tcl_DStringValue(&itemTextDString),
- Tcl_DStringLength(&itemTextDString)) +
- menuTextLeadingEdgeMargin + menuTextTrailingEdgeMargin;
- Tcl_DStringFree(&itemTextDString);
-
- if (haveImage && (mePtr->compound != COMPOUND_NONE)) {
- switch ((enum compound) mePtr->compound) {
- int margin;
-
- case COMPOUND_TOP:
- case COMPOUND_BOTTOM:
- if (textWidth > *widthPtr) {
- *widthPtr = textWidth;
- }
- *heightPtr += textHeight + 2;
- break;
- case COMPOUND_LEFT:
- margin = *widthPtr + 2;
- if (margin > menuTextLeadingEdgeMargin) {
- margin = menuTextLeadingEdgeMargin;
- }
- *widthPtr += textWidth + 2 - margin;
- if (textHeight > *heightPtr) {
- *heightPtr = textHeight;
- }
- break;
- case COMPOUND_RIGHT:
- margin = menuTextTrailingEdgeMargin;
- *widthPtr += textWidth + 2 - margin;
- if (textHeight > *heightPtr) {
- *heightPtr = textHeight;
- }
- break;
- case COMPOUND_CENTER:
- if (textWidth > *widthPtr) {
- *widthPtr = textWidth;
- }
- if (textHeight > *heightPtr) {
- *heightPtr = textHeight;
- }
- break;
- case COMPOUND_NONE:
- /*
- * Never reached.
- */
- break;
- }
- goto labelGeomDone;
- }
- }
- *widthPtr = textWidth;
- *heightPtr = textHeight;
- }
-
-labelGeomDone:
- *heightPtr += menuItemExtraHeight;
- *widthPtr += menuItemExtraWidth;
-}
-
-/*
- *----------------------------------------------------------------------
- *
- * TkMacOSXGenerateParentMenuSelectEvent --
- *
- * Respond to a hierarchical menu being opened.
- *
- * Results:
- * True if event(s) are generated - false otherwise.
- *
- * Side effects:
- * Places a virtual event on the event queue.
- *
- *----------------------------------------------------------------------
- */
-
-int
-TkMacOSXGenerateParentMenuSelectEvent(
- MenuRef menu)
-{
- TkMenu *menuPtr = MenuPtrForMenuRef(menu);
-
- if (menuPtr) {
- TkMenuEntry *parentEntryPtr = GetParentMenuEntry(menuPtr);
-
- if (parentEntryPtr && (menuPtr = parentEntryPtr->menuPtr)) {
- TkActivateMenuEntry(menuPtr, parentEntryPtr->index);
- MenuSelectEvent(menuPtr);
- Tcl_ServiceAll();
- return true;
- }
- }
- return false;
-}
-
-/*
- *----------------------------------------------------------------------
- *
- * TkMacOSXGenerateMenuSelectEvent --
+ * GenerateMenuSelectEvent --
*
* Respond to a menu item being selected.
*
@@ -3756,34 +1252,34 @@ TkMacOSXGenerateParentMenuSelectEvent(
*/
int
-TkMacOSXGenerateMenuSelectEvent(
- MenuRef menu,
- MenuItemIndex index)
+GenerateMenuSelectEvent(
+ TKMenu *menu,
+ NSMenuItem *menuItem)
{
- TkMenu *menuPtr = MenuPtrForMenuRef(menu);
- int item = index - 1;
+ TkMenu *menuPtr = [menu tkMenu];
if (menuPtr) {
- if (item < 0 || item >= menuPtr->numEntries ||
- (menuPtr->entries[item])->state == ENTRY_DISABLED) {
+ int index = [menu tkIndexOfItem:menuItem];
+
+ if (index < 0 || index >= menuPtr->numEntries ||
+ (menuPtr->entries[index])->state == ENTRY_DISABLED) {
TkActivateMenuEntry(menuPtr, -1);
} else {
- TkActivateMenuEntry(menuPtr, item);
+ TkActivateMenuEntry(menuPtr, index);
MenuSelectEvent(menuPtr);
- Tcl_ServiceAll();
return true;
}
}
return false;
}
-
+
/*
*----------------------------------------------------------------------
*
* MenuSelectEvent --
*
- * Generates a "MenuSelect" virtual event. This can be used to
- * do context-sensitive menu help.
+ * Generates a "MenuSelect" virtual event. This can be used to do
+ * context-sensitive menu help.
*
* Results:
* None.
@@ -3802,46 +1298,22 @@ MenuSelectEvent(
bzero(&event, sizeof(XVirtualEvent));
event.type = VirtualEvent;
- event.serial = menuPtr->display->request;
+ event.serial = LastKnownRequestProcessed(menuPtr->display);
event.send_event = false;
event.display = menuPtr->display;
- Tk_MakeWindowExist(menuPtr->tkwin);
event.event = Tk_WindowId(menuPtr->tkwin);
event.root = XRootWindow(menuPtr->display, 0);
event.subwindow = None;
event.time = TkpGetMS();
-
XQueryPointer(NULL, None, NULL, NULL, &event.x_root, &event.y_root, NULL,
NULL, &event.state);
event.same_screen = true;
event.name = Tk_GetUid("MenuSelect");
- Tk_QueueWindowEvent((XEvent *) &event, TCL_QUEUE_TAIL);
-}
-
-/*
- *----------------------------------------------------------------------
- *
- * TkMacOSXClearActiveMenu --
- *
- * Clears Tk's active entry for the given MenuRef.
- *
- * Results:
- * None.
- *
- * Side effects:
- * Generates <<MenuSelect>> virtual events.
- *
- *----------------------------------------------------------------------
- */
-
-void
-TkMacOSXClearActiveMenu(
- MenuRef menu)
-{
- TkMenu *menuPtr = MenuPtrForMenuRef(menu);
-
- if (menuPtr) {
- RecursivelyClearActiveMenu(menuPtr);
+ Tk_MakeWindowExist(menuPtr->tkwin);
+ if (Tcl_GetServiceMode() != TCL_SERVICE_NONE) {
+ Tk_HandleEvent((XEvent *) &event);
+ } else {
+ Tk_QueueWindowEvent((XEvent *) &event, TCL_QUEUE_TAIL);
}
}
@@ -3866,16 +1338,15 @@ RecursivelyClearActiveMenu(
TkMenu *menuPtr) /* The menu to reset. */
{
int i;
- TkMenuEntry *mePtr;
TkActivateMenuEntry(menuPtr, -1);
for (i = 0; i < menuPtr->numEntries; i++) {
- mePtr = menuPtr->entries[i];
- if (mePtr->type == CASCADE_ENTRY) {
- if ((mePtr->childMenuRefPtr != NULL)
- && (mePtr->childMenuRefPtr->menuPtr != NULL)) {
- RecursivelyClearActiveMenu(mePtr->childMenuRefPtr->menuPtr);
- }
+ TkMenuEntry *mePtr = menuPtr->entries[i];
+
+ if (mePtr->type == CASCADE_ENTRY
+ && (mePtr->childMenuRefPtr != NULL)
+ && (mePtr->childMenuRefPtr->menuPtr != NULL)) {
+ RecursivelyClearActiveMenu(mePtr->childMenuRefPtr->menuPtr);
}
}
}
@@ -3899,20 +1370,13 @@ RecursivelyClearActiveMenu(
void
TkMacOSXClearMenubarActive(void)
{
- TkMenuReferences *menuBarRefPtr;
-
- if (currentMenuBarName != NULL) {
- menuBarRefPtr = TkFindMenuReferences(currentMenuBarInterp,
- currentMenuBarName);
- if ((menuBarRefPtr != NULL) && (menuBarRefPtr->menuPtr != NULL)) {
- TkMenu *menuPtr;
-
- for (menuPtr = menuBarRefPtr->menuPtr->masterMenuPtr;
- menuPtr != NULL; menuPtr = menuPtr->nextInstancePtr) {
- if (menuPtr->menuType == MENUBAR) {
- RecursivelyClearActiveMenu(menuPtr);
- }
- }
+ NSMenu *mainMenu = [NSApp mainMenu];
+
+ if (mainMenu && [mainMenu isKindOfClass:[TKMenu class]]) {
+ TkMenu *menuPtr = [(TKMenu *) mainMenu tkMenu];
+
+ if (menuPtr && menuPtr->numEntries && menuPtr->entries) {
+ RecursivelyClearActiveMenu(menuPtr);
}
}
}
@@ -3920,29 +1384,25 @@ TkMacOSXClearMenubarActive(void)
/*
*----------------------------------------------------------------------
*
- * TkpMenuNotifyToplevelCreate --
+ * Tk_MacOSXTurnOffMenus --
*
- * This routine reconfigures the menu and the clones indicated by
- * menuName becuase a toplevel has been created and any system
- * menus need to be created. Only applicable to Windows.
+ * Turns off all the menu drawing code. This is more than just disabling
+ * the "menu" command, this means that Tk will NEVER touch the menubar.
+ * It is needed in the Plugin, where Tk does not own the menubar.
*
* Results:
* None.
*
* Side effects:
- * An idle handler is set up to do the reconfiguration.
+ * A flag is set which will disable all menu drawing.
*
*----------------------------------------------------------------------
*/
void
-TkpMenuNotifyToplevelCreate(
- Tcl_Interp *interp, /* The interp the menu lives in. */
- char *menuName) /* The name of the menu to reconfigure. */
+Tk_MacOSXTurnOffMenus(void)
{
- /*
- * Nothing to do.
- */
+ gNoTkMenus = 1;
}
/*
@@ -3964,66 +1424,46 @@ TkpMenuNotifyToplevelCreate(
void
TkpMenuInit(void)
{
- MenuSymbol *ms = menuSymbols;
- CFStringRef cfStr;
-
- lastMenuID = 256;
- Tcl_InitHashTable(&commandTable, TCL_ONE_WORD_KEYS);
- currentMenuBarOwner = NULL;
- currentAppleMenuID = 0;
- currentHelpMenuID = 0;
- currentMenuBarInterp = NULL;
- currentMenuBarName = NULL;
- windowListPtr = NULL;
-
-#ifdef USE_TK_MDEF
- tkThemeMenuItemDrawingUPP
- = NewMenuItemDrawingUPP(ThemeMenuItemDrawingProc);
- useMDEFVar = Tcl_NewStringObj("::tk::mac::useCustomMDEF", -1);
- macMDEFDrawable.winPtr = NULL;
- macMDEFDrawable.xOff = 0;
- macMDEFDrawable.yOff = 0;
- macMDEFDrawable.visRgn = NULL;
- macMDEFDrawable.aboveVisRgn = NULL;
- macMDEFDrawable.drawRect = CGRectNull;
- macMDEFDrawable.referenceCount = 0;
- macMDEFDrawable.toplevel = NULL;
- macMDEFDrawable.flags = 0;
- macMDEFDrawable.grafPtr = NULL;
- macMDEFDrawable.context = NULL;
- macMDEFDrawable.size = CGSizeZero;
-#endif
+ TkColor *tkColPtr;
+
+ NSNotificationCenter *nc = [NSNotificationCenter defaultCenter];
+
+#define observe(n, s) \
+ [nc addObserver:NSApp selector:@selector(s) name:(n) object:nil]
+ observe(NSMenuDidBeginTrackingNotification, menuBeginTracking:);
+ observe(NSMenuDidEndTrackingNotification, menuEndTracking:);
+#undef observe
+
+ [NSMenuItem setUsesUserKeyEquivalents:NO];
+ tkColPtr = TkpGetColor(None, DEF_MENU_BG_COLOR);
+ defaultBg = tkColPtr->color.pixel;
+ ckfree((char *) tkColPtr);
+ tkColPtr = TkpGetColor(None, DEF_MENU_FG);
+ defaultFg = tkColPtr->color.pixel;
+ ckfree((char *) tkColPtr);
ChkErr(GetThemeMetric, kThemeMetricMenuMarkColumnWidth,
&menuMarkColumnWidth);
- ChkErr(GetThemeMetric, kThemeMetricMenuMarkIndent, &menuMarkIndent);
ChkErr(GetThemeMetric, kThemeMetricMenuTextLeadingEdgeMargin,
&menuTextLeadingEdgeMargin);
ChkErr(GetThemeMetric, kThemeMetricMenuTextTrailingEdgeMargin,
&menuTextTrailingEdgeMargin);
+ ChkErr(GetThemeMetric, kThemeMetricMenuIconTrailingEdgeMargin,
+ &menuIconTrailingEdgeMargin);
ChkErr(GetThemeMenuItemExtra, kThemeMenuItemPlain, &menuItemExtraHeight,
&menuItemExtraWidth);
ChkErr(GetThemeMenuSeparatorHeight, &menuSeparatorHeight);
-
- while (ms->unicode) {
- ms->utfLen = Tcl_UniCharToUtf(ms->unicode, ms->utf);
- ms->utf[ms->utfLen] = 0;
- cfStr = CFStringCreateWithCharacters(NULL, &ms->unicode, 1);
- if (cfStr) {
- ms->width = MeasureThemeText(cfStr, kThemeMenuItemCmdKeyFont);
- CFRelease(cfStr);
- }
- ms++;
- }
}
+
+#pragma mark -
+#pragma mark NOPs
/*
*----------------------------------------------------------------------
*
* TkpMenuThreadInit --
*
- * Does platform-specific initialization of thread-specific
- * menu state.
+ * Does platform-specific initialization of thread-specific menu state.
*
* Results:
* None.
@@ -4045,696 +1485,273 @@ TkpMenuThreadInit(void)
/*
*----------------------------------------------------------------------
*
- * TkpPreprocessMacMenu --
+ * TkpMenuNotifyToplevelCreate --
*
- * Handle preprocessing of menubar if it exists.
+ * This routine reconfigures the menu and the clones indicated by
+ * menuName because a toplevel has been created and any system menus need
+ * to be created. Only applicable to Windows.
*
* Results:
- * None.
+ * None.
*
* Side effects:
- * All post commands for the current menubar get executed.
+ * An idle handler is set up to do the reconfiguration.
*
*----------------------------------------------------------------------
*/
void
-TkMacOSXPreprocessMenu(void)
+TkpMenuNotifyToplevelCreate(
+ Tcl_Interp *interp, /* The interp the menu lives in. */
+ char *menuName) /* The name of the menu to reconfigure. */
{
- if ((currentMenuBarName != NULL) && (currentMenuBarInterp != NULL)) {
- TkMenuReferences *mbRefPtr =
- TkFindMenuReferences(currentMenuBarInterp,currentMenuBarName);
-
- if ((mbRefPtr != NULL) && (mbRefPtr->menuPtr != NULL)) {
- int code;
-
- Tcl_Preserve((ClientData) currentMenuBarInterp);
- code = TkPreprocessMenu(mbRefPtr->menuPtr->masterMenuPtr);
- if ((code != TCL_OK) && (code != TCL_CONTINUE)
- && (code != TCL_BREAK)) {
- Tcl_AddErrorInfo(currentMenuBarInterp,
- "\n (menu preprocess)");
- Tcl_BackgroundError(currentMenuBarInterp);
- }
- Tcl_Release((ClientData) currentMenuBarInterp);
- }
- }
+ /*
+ * Nothing to do.
+ */
}
-#ifdef USE_TK_MDEF
-#pragma mark MDEF
/*
- *----------------------------------------------------------------------
+ *--------------------------------------------------------------
*
- * MenuDefProc --
+ * TkpInitializeMenuBindings --
*
- * This routine is the MDEF handler for Tk. It receives all messages
- * for the menu and dispatches them.
+ * For every interp, initializes the bindings for Windows menus. Does
+ * nothing on Mac or XWindows.
*
* Results:
* None.
*
* Side effects:
- * This routine causes menus to be drawn and will certainly allocate
- * memory as a result. Also, the menu can scroll up and down, and
- * various other interface actions can take place.
+ * C-level bindings are setup for the interp which will handle Alt-key
+ * sequences for menus without beeping or interfering with user-defined
+ * Alt-key bindings.
*
- *----------------------------------------------------------------------
+ *--------------------------------------------------------------
*/
void
-MenuDefProc(
- SInt16 message, /* What action are we taking? */
- MenuRef menu, /* The menu we are working with */
- Rect *menuRectPtr, /* A pointer to the rect for the
- * whole menu. */
- Point hitPt, /* Where the mouse was clicked for
- * the appropriate messages. */
- SInt16 *whichItem) /* Output result. Which item was
- * hit by the user? */
+TkpInitializeMenuBindings(
+ Tcl_Interp *interp, /* The interpreter to set. */
+ Tk_BindingTable bindingTable)
+ /* The table to add to. */
{
- TkMenu *menuPtr;
- Tcl_HashEntry *commandEntryPtr;
- MenuID menuID;
-
- menuID = GetMenuID(menu);
- commandEntryPtr = Tcl_FindHashEntry(&commandTable, (char*)(intptr_t)menuID);
-
- if (!commandEntryPtr) return;
- menuPtr = (TkMenu *) Tcl_GetHashValue(commandEntryPtr);
+ /*
+ * Nothing to do.
+ */
+}
+
+/*
+ *--------------------------------------------------------------
+ *
+ * TkpComputeMenubarGeometry --
+ *
+ * This procedure is invoked to recompute the size and layout of a menu
+ * that is a menubar clone.
+ *
+ * Results:
+ * None.
+ *
+ * Side effects:
+ * Fields of menu entries are changed to reflect their current positions,
+ * and the size of the menu window itself may be changed.
+ *
+ *--------------------------------------------------------------
+ */
- switch (message) {
- case kMenuInitMsg:
- *whichItem = noErr;
- break;
- case kMenuDisposeMsg:
- break;
- case kMenuHiliteItemMsg:
- HandleMenuHiliteMsg(menu, menuRectPtr, hitPt, whichItem, menuPtr);
- break;
- case kMenuCalcItemMsg:
- HandleMenuCalcItemMsg(menu, menuRectPtr, hitPt, whichItem,
- menuPtr);
- break;
- case kMenuDrawItemsMsg:
-#ifdef TK_MAC_DEBUG_MENUS
- TkMacOSXDbgMsg("MDEF: DrawItemsMsg");
-#endif
- /*
- * We do nothing here, because we don't support the Menu Managers
- * dynamic item groups
- */
- break;
- case kMenuThemeSavvyMsg:
- *whichItem = kThemeSavvyMenuResponse;
- break;
- case kMenuSizeMsg:
-#ifdef TK_MAC_DEBUG_MENUS
- TkMacOSXDbgMsg("MDEF: SizeMsg %d, %d", hitPt.h, hitPt.v);
-#endif
- SetMenuWidth(menu, hitPt.h < menuPtr->totalWidth ? hitPt.h :
- menuPtr->totalWidth);
- SetMenuHeight(menu, hitPt.v < menuPtr->totalHeight ? hitPt.v :
- menuPtr->totalHeight);
- break;
- case kMenuDrawMsg:
- HandleMenuDrawMsg(menu, menuRectPtr, hitPt, whichItem, menuPtr);
- break;
- case kMenuFindItemMsg:
- HandleMenuFindItemMsg(menu, menuRectPtr, hitPt, whichItem,
- menuPtr);
- break;
- case kMenuPopUpMsg:
- HandleMenuPopUpMsg(menu, menuRectPtr, hitPt, whichItem, menuPtr);
- break;
- }
+void
+TkpComputeMenubarGeometry(
+ TkMenu *menuPtr) /* Structure describing menu. */
+{
+ TkpComputeStandardMenuGeometry(menuPtr);
}
+
/*
*----------------------------------------------------------------------
*
- * HandleMenuHiliteMsg --
+ * TkpDrawMenuEntry --
*
- * Handles the MenuDefProc's hilite message.
+ * Draws the given menu entry at the given coordinates with the given
+ * attributes.
*
* Results:
- * A menu entry is drawn
+ * None.
*
* Side effects:
- * None
+ * X Server commands are executed to display the menu entry.
*
*----------------------------------------------------------------------
*/
void
-HandleMenuHiliteMsg(
- MenuRef menu,
- Rect *menuRectPtr,
- Point hitPt,
- SInt16 *whichItem,
- TkMenu *menuPtr)
+TkpDrawMenuEntry(
+ TkMenuEntry *mePtr, /* The entry to draw */
+ Drawable d, /* What to draw into */
+ Tk_Font tkfont, /* Precalculated font for menu */
+ const Tk_FontMetrics *menuMetricsPtr,
+ /* Precalculated metrics for menu */
+ int x, /* X-coordinate of topleft of entry */
+ int y, /* Y-coordinate of topleft of entry */
+ int width, /* Width of the entry rectangle */
+ int height, /* Height of the current rectangle */
+ int strictMotif, /* Boolean flag */
+ int drawArrow) /* Whether or not to draw the cascade arrow
+ * for cascade items. Only applies to
+ * Windows. */
{
- OSStatus err;
- Tk_Font tkfont;
- Tk_FontMetrics fontMetrics;
- MDEFHiliteItemData *hidPtr = (MDEFHiliteItemData *)whichItem;
- int oldItem = hidPtr->previousItem - 1;
- int newItem = hidPtr->newItem - 1;
- MenuTrackingData mtd, *mtdPtr = &mtd;
-
-#ifdef TK_MAC_DEBUG_MENUS
- TkMacOSXDbgMsg("MDEF: HiliteMsg %d -> %d", hidPtr->previousItem,
- hidPtr->newItem);
-#endif
- GetPort(&macMDEFDrawable.grafPtr);
- macMDEFDrawable.context = (CGContextRef) hidPtr->context;
-
- err = ChkErr(GetMenuTrackingData, menu, mtdPtr);
- if (err != noErr) {
- return;
- }
-
- tkfont = Tk_GetFontFromObj(menuPtr->tkwin, menuPtr->fontPtr);
- Tk_GetFontMetrics(tkfont, &fontMetrics);
- if (oldItem >= 0) {
- AppearanceEntryDrawWrapper(menuPtr->entries[oldItem], menuRectPtr,
- mtdPtr, (Drawable) &macMDEFDrawable, &fontMetrics, tkfont, 1);
- }
- if (newItem >= 0) {
- AppearanceEntryDrawWrapper(menuPtr->entries[newItem], menuRectPtr,
- mtdPtr, (Drawable) &macMDEFDrawable, &fontMetrics, tkfont, 0);
- }
}
+
+#pragma mark Obsolete
/*
*----------------------------------------------------------------------
*
- * HandleMenuDrawMsg --
+ * TkMacOSXPreprocessMenu --
*
- * Handles the MenuDefProc's draw message.
+ * Handle preprocessing of menubar if it exists.
*
* Results:
- * A menu entry is drawn
+ * None.
*
* Side effects:
- * None
+ * All post commands for the current menubar get executed.
*
*----------------------------------------------------------------------
*/
void
-HandleMenuDrawMsg(
- MenuRef menu,
- Rect *menuRectPtr,
- Point hitPt,
- SInt16 *whichItem,
- TkMenu *menuPtr)
+TkMacOSXPreprocessMenu(void)
{
- Tk_Font menuFont;
- Tk_FontMetrics fontMetrics;
- TkMenuEntry *mePtr;
- int i;
- Rect menuClipRect, bounds;
- MDEFDrawData *ddPtr = (MDEFDrawData*)whichItem;
- MenuTrackingData *mtdPtr = &(ddPtr->trackingData);
- TkWindow *winPtr = (TkWindow*)menuPtr->tkwin;
-
- GetPort(&macMDEFDrawable.grafPtr);
- GetPortBounds(macMDEFDrawable.grafPtr, &bounds);
- macMDEFDrawable.context = (CGContextRef) ddPtr->context;
-#ifdef TK_MAC_DEBUG_MENUS
- TkMacOSXDbgMsg("MDEF: DrawMsg %d - %d; %d - %d", menuRectPtr->top,
- menuRectPtr->bottom, bounds.top, bounds.bottom);
-#endif
- winPtr->changes.x = menuRectPtr->left;
- winPtr->changes.y = menuRectPtr->top;
- winPtr->changes.width = menuRectPtr->right - menuRectPtr->left;
- winPtr->changes.height = menuRectPtr->bottom - menuRectPtr->top;
- TkpClipDrawableToRect(menuPtr->display, (Drawable) &macMDEFDrawable,
- 0, 0, -1, -1);
-#if 0
- if (menuPtr->menuRefPtr->topLevelListPtr != NULL) {
- menuType = kThemeMenuTypePullDown;
- } else if (menuPtr->menuRefPtr->parentEntryPtr != NULL) {
- menuType = kThemeMenuTypeHierarchical;
- } else {
- menuType = kThemeMenuTypePopUp;
- }
-#endif
- DrawMenuBackground(menuPtr, menuRectPtr, (Drawable) &macMDEFDrawable);
- menuFont = Tk_GetFontFromObj(menuPtr->tkwin, menuPtr->fontPtr);
- Tk_GetFontMetrics(menuFont, &fontMetrics);
- menuClipRect = *menuRectPtr;
- mtdPtr->virtualMenuBottom = mtdPtr->virtualMenuTop + menuPtr->totalHeight;
-
- /*
- * Next, figure out scrolling information.
- */
-
- if ((menuRectPtr->bottom - menuRectPtr->top) < menuPtr->totalHeight) {
- short arrowHeight = fontMetrics.linespace + 1;
- Rect arrowRect, eraseRect;
- ThemeMenuState menuState = IsMenuItemEnabled(menu, 0) ?
- kThemeMenuActive : kThemeMenuDisabled;
-
- if (mtdPtr->virtualMenuTop < menuRectPtr->top) {
- arrowRect = bounds;
- /*arrowRect.top += 1;*/
- arrowRect.bottom = arrowRect.top + arrowHeight;
- eraseRect = arrowRect;
- eraseRect.top = menuRectPtr->top;
- menuClipRect.top = arrowRect.bottom;
- ChkErr(EraseMenuBackground, menu, &eraseRect,
- macMDEFDrawable.context);
- ChkErr(DrawThemeMenuItem, menuRectPtr, &arrowRect,
- mtdPtr->virtualMenuTop, mtdPtr->virtualMenuBottom,
- menuState, kThemeMenuItemScrollUpArrow, NULL, 0);
-#ifdef TK_MAC_DEBUG_MENUS
- TkMacOSXDbgMsg("upArrow: %d - %d, %d - %d", arrowRect.top,
- arrowRect.bottom, arrowRect.left, arrowRect.right);
-#endif
- }
- if (mtdPtr->virtualMenuBottom > menuRectPtr->bottom) {
- arrowRect = bounds;
- arrowRect.bottom -= 1;
- arrowRect.top = arrowRect.bottom - arrowHeight;
- eraseRect = arrowRect;
- eraseRect.bottom = menuRectPtr->bottom;
- menuClipRect.bottom = arrowRect.top;
- ChkErr(EraseMenuBackground, menu, &eraseRect,
- macMDEFDrawable.context);
- ChkErr(DrawThemeMenuItem, menuRectPtr, &arrowRect,
- mtdPtr->virtualMenuTop, mtdPtr->virtualMenuBottom,
- menuState, kThemeMenuItemScrollDownArrow, NULL, 0);
-#ifdef TK_MAC_DEBUG_MENUS
- TkMacOSXDbgMsg("downArrow: %d - %d, %d - %d", arrowRect.top,
- arrowRect.bottom, arrowRect.left, arrowRect.right);
-#endif
- }
- TkpClipDrawableToRect(menuPtr->display, (Drawable) &macMDEFDrawable,
- menuClipRect.left, menuClipRect.top, menuClipRect.right -
- menuClipRect.left, menuClipRect.bottom - menuClipRect.top);
- }
+}
+
+/*
+ *----------------------------------------------------------------------
+ *
+ * TkMacOSXUseID --
+ *
+ * Take the ID out of the available list for new menus. Used by the
+ * default menu bar's menus so that they do not get created at the tk
+ * level. See TkMacOSXGetNewMenuID for more information.
+ *
+ * Results:
+ * Returns TCL_OK if the id was not in use. Returns TCL_ERROR if the id
+ * was in use.
+ *
+ * Side effects:
+ * A hash table entry in the command table is created with a NULL value.
+ *
+ *----------------------------------------------------------------------
+ */
- /*
- * Now, actually draw the menu. Don't draw entries that
- * are higher than the top arrow, and don't draw entries
- * that are lower than the bottom.
- */
+int
+TkMacOSXUseMenuID(
+ short macID) /* The id to take out of the table */
+{
+ return TCL_OK;
+}
+
+/*
+ *----------------------------------------------------------------------
+ *
+ * TkMacOSXDispatchMenuEvent --
+ *
+ * Given a menu id and an item, dispatches the command associated with
+ * it.
+ *
+ * Results:
+ * None.
+ *
+ * Side effects:
+ * Commands for the event are scheduled for execution at idle time.
+ *
+ *----------------------------------------------------------------------
+ */
- for (i = 0; i < menuPtr->numEntries; i++) {
- mePtr = menuPtr->entries[i];
- if (mtdPtr->virtualMenuTop + mePtr->y + mePtr->height <
- menuClipRect.top || mtdPtr->virtualMenuTop + mePtr->y >
- menuClipRect.bottom) {
- continue;
- }
- AppearanceEntryDrawWrapper(mePtr, menuRectPtr, mtdPtr,
- (Drawable) &macMDEFDrawable, &fontMetrics, menuFont, 0);
- }
- MDEFScrollFlag = 1;
+int
+TkMacOSXDispatchMenuEvent(
+ int menuID, /* The menu id of the menu we are invoking */
+ int index) /* The one-based index of the item that was
+ * selected. */
+{
+ return TCL_ERROR;
}
/*
*----------------------------------------------------------------------
*
- * HandleMenuFindItemMsg --
+ * TkMacOSXHandleTearoffMenu() --
*
- * Handles the MenuDefProc's FindItems message. We have to
- * respond by filling in the itemSelected, itemUnderMouse and
- * itemRect fields. This is also the time to scroll the menu if
- * it is too long to fit on the screen.
+ * This routine sees if the MDEF has set a menu and a mouse position for
+ * tearing off and makes a tearoff menu if it has.
*
* Results:
- * The Menu system is informed of the selected item & the item
- * under the mouse.
+ * menuPtr->interp will have the result of the tearoff command.
*
* Side effects:
- * The menu might get scrolled.
+ * A new tearoff menu is created if it is supposed to be.
*
*----------------------------------------------------------------------
*/
+
void
-HandleMenuFindItemMsg(
- MenuRef menu,
- Rect *menuRectPtr,
- Point hitPt,
- SInt16 *whichItem,
- TkMenu *menuPtr)
+TkMacOSXHandleTearoffMenu(void)
{
- Tk_Font menuFont;
- Tk_FontMetrics fontMetrics;
- TkMenuEntry *mePtr;
- int i, newItem = -1, itemUnderMouse = -1;
- Rect itemRect = {0, 0, 0, 0}, menuClipRect, bounds;
- int hasTopScroll, hasBottomScroll;
- MDEFFindItemData *fiPtr = (MDEFFindItemData *)whichItem;
- MenuTrackingData *mtdPtr = &(fiPtr->trackingData), topMtd;
- enum {
- DONT_SCROLL, DOWN_SCROLL, UP_SCROLL
- } scrollDirection;
- short arrowHeight;
-
-#ifdef TK_MAC_DEBUG_MENUS
- static Point lastHitPt = {0, 0};
- if (hitPt.h != lastHitPt.h || hitPt.v != lastHitPt.v) {
- lastHitPt = hitPt;
- TkMacOSXDbgMsg("MDEF: FindItemMsg: %d, %d", hitPt.h, hitPt.v);
- }
-#endif
-
- GetPort(&macMDEFDrawable.grafPtr);
- GetPortBounds(macMDEFDrawable.grafPtr, &bounds);
- macMDEFDrawable.context = (CGContextRef) fiPtr->context;
-
/*
- * Now we need to take care of scrolling the menu.
- */
-
- menuFont = Tk_GetFontFromObj(menuPtr->tkwin, menuPtr->fontPtr);
- Tk_GetFontMetrics(menuFont, &fontMetrics);
- arrowHeight = fontMetrics.linespace + 1;
- menuClipRect = *menuRectPtr;
- hasTopScroll = mtdPtr->virtualMenuTop < menuRectPtr->top;
- hasBottomScroll = mtdPtr->virtualMenuBottom > menuRectPtr->bottom;
- scrollDirection = DONT_SCROLL;
- if (hasTopScroll) {
- menuClipRect.top = bounds.top + arrowHeight;
- if (hitPt.v < menuClipRect.top) {
- newItem = -1;
- scrollDirection = DOWN_SCROLL;
- }
- }
- if (hasBottomScroll) {
- menuClipRect.bottom = bounds.bottom - 1 - arrowHeight;
- if (hitPt.v > menuClipRect.bottom) {
- newItem = -1;
- scrollDirection = UP_SCROLL;
- }
- }
- if (MDEFScrollFlag) {
- scrollDirection = DONT_SCROLL;
- MDEFScrollFlag = 0;
- }
- /*
- * Don't scroll if there are other menus open above us
+ * Obsolete: Nothing to do.
*/
- ChkErr(GetMenuTrackingData, NULL, &topMtd);
- if (menu != topMtd.menu) {
- scrollDirection = DONT_SCROLL;
- }
- if (scrollDirection == DONT_SCROLL) {
- /*
- * Find out which item was hit. If it is the same as the old item,
- * we don't need to do anything.
- */
-
- if (PtInRect(hitPt, menuRectPtr)) {
- for (i = 0; i < menuPtr->numEntries; i++) {
- mePtr = menuPtr->entries[i];
- itemRect.left = menuRectPtr->left + mePtr->x;
- itemRect.top = mtdPtr->virtualMenuTop + mePtr->y;
- itemRect.right = mePtr->entryFlags & ENTRY_LAST_COLUMN ?
- menuRectPtr->right : itemRect.left + mePtr->width;
- itemRect.bottom = itemRect.top + mePtr->height;
- if (PtInRect(hitPt, &itemRect)) {
- if ((mePtr->type == SEPARATOR_ENTRY)
- || (mePtr->state == ENTRY_DISABLED)) {
- newItem = -1;
- itemUnderMouse = i;
- } else {
- TkMenuEntry *parentEntryPtr =
- GetParentMenuEntry(menuPtr);
-
- if (parentEntryPtr &&
- parentEntryPtr->state == ENTRY_DISABLED) {
- newItem = -1;
- itemUnderMouse = i;
- } else {
- newItem = i;
- itemUnderMouse = i;
- }
- }
- break;
- }
- }
- }
- } else {
- short scrollAmt;
- unsigned long scrollDelay;
- Rect arrowRect, eraseRect, scrolledMenuClipRect;
- ThemeMenuState menuState = IsMenuItemEnabled(menu, 0) ?
- kThemeMenuActive : kThemeMenuDisabled;
- int oldItem = mtdPtr->itemSelected - 1;
- short d;
-
- TkpClipDrawableToRect(menuPtr->display, (Drawable) &macMDEFDrawable,
- 0, 0, -1, -1);
- scrollAmt = fontMetrics.linespace + menuItemExtraHeight;
- if (scrollDirection == UP_SCROLL) {
- scrollAmt = -scrollAmt;
- d = hitPt.v - bounds.bottom;
- } else {
- d = bounds.top - hitPt.v;
- }
- scrollDelay = (d >= scrollAmt/2) ? 1 : 10;
- menuClipRect = *menuRectPtr;
- if (mtdPtr->virtualMenuTop + scrollAmt < menuRectPtr->top) {
- arrowRect = bounds;
- /*arrowRect.top += 1;*/
- arrowRect.bottom = arrowRect.top + arrowHeight;
- eraseRect = arrowRect;
- eraseRect.top = menuRectPtr->top;
- menuClipRect.top = arrowRect.bottom;
- if (!hasTopScroll) {
- ChkErr(EraseMenuBackground, menu, &eraseRect,
- macMDEFDrawable.context);
- ChkErr(DrawThemeMenuItem, menuRectPtr, &arrowRect,
- mtdPtr->virtualMenuTop + scrollAmt,
- mtdPtr->virtualMenuBottom + scrollAmt,
- menuState, kThemeMenuItemScrollUpArrow, NULL, 0);
-#ifdef TK_MAC_DEBUG_MENUS
- TkMacOSXDbgMsg("upArrow: %d - %d, %d - %d", arrowRect.top,
- arrowRect.bottom, arrowRect.left, arrowRect.right);
-#endif
- }
- }
- if (mtdPtr->virtualMenuBottom + scrollAmt > menuRectPtr->bottom) {
- arrowRect = bounds;
- arrowRect.bottom -= 1;
- arrowRect.top = arrowRect.bottom - arrowHeight;
- eraseRect = arrowRect;
- eraseRect.bottom = menuRectPtr->bottom;
- menuClipRect.bottom = arrowRect.top;
- if (!hasBottomScroll) {
- ChkErr(EraseMenuBackground, menu, &eraseRect,
- macMDEFDrawable.context);
- ChkErr(DrawThemeMenuItem, menuRectPtr, &arrowRect,
- mtdPtr->virtualMenuTop + scrollAmt,
- mtdPtr->virtualMenuBottom + scrollAmt,
- menuState, kThemeMenuItemScrollDownArrow, NULL, 0);
-#ifdef TK_MAC_DEBUG_MENUS
- TkMacOSXDbgMsg("downArrow: %d - %d, %d - %d", arrowRect.top,
- arrowRect.bottom, arrowRect.left, arrowRect.right);
-#endif
- }
- }
- TkpClipDrawableToRect(menuPtr->display, (Drawable) &macMDEFDrawable,
- menuClipRect.left, menuClipRect.top, menuClipRect.right -
- menuClipRect.left, menuClipRect.bottom - menuClipRect.top);
- TkActivateMenuEntry(menuPtr, -1);
- if (oldItem >= 0) {
- AppearanceEntryDrawWrapper(menuPtr->entries[oldItem], menuRectPtr,
- mtdPtr, (Drawable) &macMDEFDrawable, &fontMetrics,
- menuFont, 1);
- }
- ChkErr(ScrollMenuImage, menu, &menuClipRect, 0, scrollAmt,
- macMDEFDrawable.context);
- mtdPtr->virtualMenuTop += scrollAmt;
- mtdPtr->virtualMenuBottom += scrollAmt;
- scrolledMenuClipRect = menuClipRect;
- OffsetRect(&scrolledMenuClipRect, 0, scrollAmt);
- menuClipRect = bounds;
- if (mtdPtr->virtualMenuTop < menuRectPtr->top) {
- menuClipRect.top += arrowHeight;
- }
- if (mtdPtr->virtualMenuBottom > menuRectPtr->bottom) {
- menuClipRect.bottom -= arrowHeight;
- }
- TkpClipDrawableToRect(menuPtr->display, (Drawable) &macMDEFDrawable,
- menuClipRect.left, menuClipRect.top, menuClipRect.right -
- menuClipRect.left, menuClipRect.bottom - menuClipRect.top);
- if (scrolledMenuClipRect.bottom < menuClipRect.bottom) {
- menuClipRect.top = scrolledMenuClipRect.bottom;
- } else if (scrolledMenuClipRect.top < menuClipRect.top) {
- menuClipRect.bottom = scrolledMenuClipRect.top;
- }
- for (i = 0; i < menuPtr->numEntries; i++) {
- mePtr = menuPtr->entries[i];
- if (mtdPtr->virtualMenuTop + mePtr->y + mePtr->height <
- menuClipRect.top || mtdPtr->virtualMenuTop + mePtr->y >
- menuClipRect.bottom) {
- continue;
- }
-#ifdef TK_MAC_DEBUG_MENUS
- TkMacOSXDbgMsg("Drawing item %i", i);
-#endif
- AppearanceEntryDrawWrapper(mePtr, menuRectPtr, mtdPtr,
- (Drawable) &macMDEFDrawable, &fontMetrics, menuFont, 1);
- }
- Delay(scrollDelay, NULL);
- }
- mtdPtr->itemSelected = newItem + 1;
- mtdPtr->itemUnderMouse = itemUnderMouse + 1;
- mtdPtr->itemRect = itemRect;
}
/*
*----------------------------------------------------------------------
*
- * HandleMenuPopUpMsg --
+ * TkMacOSXSetHelpMenuItemCount --
*
- * Handles the MenuDefProc's PopUp message. The menu is
- * posted with the selected item at the point given in hitPt.
+ * Has to be called after the first call to InsertMenu. Sets up the
+ * global variable for the number of items in the unmodified help menu.
+ * NB. Nobody uses this any more, since you can get the number of system
+ * help items from HMGetHelpMenu trivially. But it is in the stubs
+ * table...
*
* Results:
- * A menu is posted.
+ * None.
*
* Side effects:
- * None.
+ * Nothing.
*
*----------------------------------------------------------------------
*/
+
void
-HandleMenuPopUpMsg(
- MenuRef menu,
- Rect *menuRectPtr,
- Point hitPt,
- SInt16 *whichItem,
- TkMenu *menuPtr)
+TkMacOSXSetHelpMenuItemCount(void)
{
- int maxMenuHeight;
- int oldItem;
- Rect portRect;
- BitMap screenBits;
- static SInt16 menuBarHeight = 0;
-
-#ifdef TK_MAC_DEBUG_MENUS
- TkMacOSXDbgMsg("MDEF: PopUpMsg");
-#endif
-
- if (!menuBarHeight) {
- ChkErr(GetThemeMenuBarHeight, &menuBarHeight);
- }
- GetQDGlobalsScreenBits(&screenBits);
-
- /*
- * Note that for some oddball reason, h and v are reversed in the
- * point given to us by the MDEF.
- */
-
- oldItem = *whichItem;
- if (oldItem >= menuPtr->numEntries) {
- oldItem = -1;
- }
- portRect.top = 0;
- portRect.bottom = 1280;
- maxMenuHeight = screenBits.bounds.bottom - screenBits.bounds.top
- - menuBarHeight - SCREEN_MARGIN;
- if (menuPtr->totalHeight > maxMenuHeight) {
- menuRectPtr->top = menuBarHeight;
- } else {
- int delta;
-
- menuRectPtr->top = hitPt.h;
- if (oldItem >= 0) {
- menuRectPtr->top -= menuPtr->entries[oldItem]->y;
- }
-
- if (menuRectPtr->top < menuBarHeight) {
- /*
- * Displace downward if the menu would stick off the top of the
- * screen.
- */
-
- menuRectPtr->top = menuBarHeight + SCREEN_MARGIN;
- } else {
- /*
- * Or upward if the menu sticks off the bottom end...
- */
-
- delta = menuRectPtr->top + menuPtr->totalHeight - maxMenuHeight;
- if (delta > 0) {
- menuRectPtr->top -= delta;
- }
- }
- }
- menuRectPtr->left = hitPt.v;
- menuRectPtr->right = menuRectPtr->left + menuPtr->totalWidth;
- menuRectPtr->bottom = menuRectPtr->top +
- ((maxMenuHeight < menuPtr->totalHeight)
- ? maxMenuHeight : menuPtr->totalHeight);
- if (menuRectPtr->top == menuBarHeight) {
- *whichItem = hitPt.h;
- } else {
- *whichItem = menuRectPtr->top;
- }
}
/*
*----------------------------------------------------------------------
*
- * HandleMenuCalcItemMsg --
+ * TkMacOSXMenuClick --
*
- * Handles the MenuDefProc's CalcItem message. It is supposed
- * to calculate the Rect of the menu entry in whichItem in the
- * menu, and put that in menuRectPtr. I assume this works, but I
- * have never seen the MenuManager send this message.
+ * Prepares a menubar for MenuSelect or MenuKey.
*
* Results:
- * The Menu Manager is informed of the bounding rect of a
- * menu rect.
+ * None.
*
* Side effects:
- * None.
+ * Any pending configurations of the menubar are completed.
*
*----------------------------------------------------------------------
*/
void
-HandleMenuCalcItemMsg(
- MenuRef menu,
- Rect *menuRectPtr,
- Point hitPt,
- SInt16 *whichItem,
- TkMenu *menuPtr)
+TkMacOSXMenuClick(void)
{
- TkMenuEntry *mePtr;
- MenuTrackingData mtd, *mtdPtr = &mtd;
- OSStatus err;
- int virtualTop, item = *whichItem-1;
-
- err = ChkErr(GetMenuTrackingData, menu, mtdPtr);
- if (err == noErr) {
- virtualTop = mtdPtr->virtualMenuTop;
- } else {
- virtualTop = 0;
- }
-
- if (item >= 0 && item < menuPtr->numEntries) {
- mePtr = menuPtr->entries[item];
- menuRectPtr->left = mePtr->x;
- menuRectPtr->top = mePtr->y + virtualTop;
- if (mePtr->entryFlags & ENTRY_LAST_COLUMN) {
- menuRectPtr->right = menuPtr->totalWidth;
- } else {
- menuRectPtr->right = mePtr->x + mePtr->width;
- }
- menuRectPtr->bottom = menuRectPtr->top + mePtr->height;
- }
-#ifdef TK_MAC_DEBUG_MENUS
- TkMacOSXDbgMsg("MDEF: CalcItemMsg %d: %d, %d", *whichItem,
- menuRectPtr->left, menuRectPtr->top);
-#endif
}
-#endif /* USE_TK_MDEF */
+
+/*
+ * Local Variables:
+ * mode: objc
+ * c-basic-offset: 4
+ * fill-column: 79
+ * coding: utf-8
+ * End:
+ */
diff --git a/macosx/tkMacOSXMenubutton.c b/macosx/tkMacOSXMenubutton.c
index ca4fe34..3a1c80e 100644
--- a/macosx/tkMacOSXMenubutton.c
+++ b/macosx/tkMacOSXMenubutton.c
@@ -5,97 +5,78 @@
* menubutton widget.
*
* Copyright (c) 1996 by Sun Microsystems, Inc.
- * Copyright 2001, Apple Computer, Inc.
- * Copyright (c) 2006-2007 Daniel A. Steffen <das@users.sourceforge.net>
+ * Copyright 2001-2009, Apple Inc.
+ * Copyright (c) 2006-2009 Daniel A. Steffen <das@users.sourceforge.net>
*
* See the file "license.terms" for information on usage and redistribution
* of this file, and for a DISCLAIMER OF ALL WARRANTIES.
+ *
+ * RCS: @(#) $Id$
*/
#include "tkMacOSXPrivate.h"
-#include "tkMenu.h"
#include "tkMenubutton.h"
#include "tkMacOSXFont.h"
#include "tkMacOSXDebug.h"
-#define kShadowOffset (3) /* amount to offset shadow from frame */
-#define kTriangleWidth (11) /* width of the triangle */
-#define kTriangleHeight (6) /* height of the triangle */
-#define kTriangleMargin (5) /* margin around triangle */
-
-#define TK_POPUP_OFFSET 32 /* size of popup marker */
-
-#define FIRST_DRAW 2
-#define ACTIVE 4
-
-MODULE_SCOPE int TkMacOSXGetNewMenuID(Tcl_Interp *interp, TkMenu *menuInstPtr,
- int cascade, short *menuIDPtr);
-MODULE_SCOPE void TkMacOSXFreeMenuID(short menuID);
+/*
+#ifdef TK_MAC_DEBUG
+#define TK_MAC_DEBUG_MENUBUTTON
+#endif
+*/
-typedef struct {
- SInt16 initialValue;
- SInt16 minValue;
- SInt16 maxValue;
- SInt16 procID;
- int isBevel;
-} MenuButtonControlParams;
+typedef struct MacMenuButton {
+ TkMenuButton info;
+ NSPopUpButton *button;
+#if TK_MAC_BUTTON_USE_COMPATIBILITY_METRICS
+ int fix;
+#endif
+} MacMenuButton;
-typedef struct {
- int len;
- Str255 title;
- ControlFontStyleRec style;
-} ControlTitleParams;
+#if TK_MAC_BUTTON_USE_COMPATIBILITY_METRICS
/*
- * Declaration of Mac specific button structure.
+ * Use the following heuristic conversion constants to make NSButton-based
+ * widget metrics match up with the old Carbon control buttons (for the
+ * default Lucida Grande 13 font).
+ * TODO: provide a scriptable way to turn this off and use the raw NSButton
+ * metrics (will also need dynamic adjustment of the default padding,
+ * c.f. tkMacOSXDefault.h).
*/
-typedef struct MacMenuButton {
- TkMenuButton info; /* Generic button info. */
- WindowRef windowRef;
- ControlRef userPane;
- ControlRef control;
- MenuRef menuRef;
- unsigned long userPaneBackground;
- int flags;
- MenuButtonControlParams params;
- ControlTitleParams titleParams;
- ControlButtonContentInfo bevelButtonContent;
- OpenCPicParams picParams;
-} MacMenuButton;
+typedef struct {
+ int trimW, trimH, inset, shrinkW, offsetX, offsetY;
+} BoundsFix;
+
+#define fixForStyle(style) ( \
+ style == NSRoundedBezelStyle ? 1 : \
+ style == NSRegularSquareBezelStyle ? 2 : \
+ style == NSShadowlessSquareBezelStyle ? 3 : \
+ INT_MIN)
+
+static const BoundsFix boundsFixes[] = {
+ [fixForStyle(NSRoundedBezelStyle)] = { 14, 10, -2, -1},
+ [fixForStyle(NSRegularSquareBezelStyle)] = { 6, 13, -2, 1, 1},
+ [fixForStyle(NSShadowlessSquareBezelStyle)] = { 15, 0, 2 },
+};
+
+#endif
/*
* Forward declarations for procedures defined later in this file:
*/
-static OSStatus SetUserPaneDrawProc(ControlRef control,
- ControlUserPaneDrawProcPtr upp);
-static OSStatus SetUserPaneSetUpSpecialBackgroundProc(ControlRef control,
- ControlUserPaneBackgroundProcPtr upp);
-static void UserPaneDraw(ControlRef control, ControlPartCode cpc);
-static void UserPaneBackgroundProc(ControlHandle,
- ControlBackgroundPtr info);
-static int MenuButtonInitControl (MacMenuButton *mbPtr, Rect *paneRect,
- Rect *cntrRect );
static void MenuButtonEventProc(ClientData clientData, XEvent *eventPtr);
-static int UpdateControlColors(MacMenuButton *mbPtr);
-static void ComputeMenuButtonControlParams(TkMenuButton *mbPtr,
- MenuButtonControlParams * paramsPtr);
-static void ComputeControlTitleParams(TkMenuButton *mbPtr,
- ControlTitleParams *paramsPtr);
-static void CompareControlTitleParams(ControlTitleParams *p1Ptr,
- ControlTitleParams *p2Ptr, int *titleChanged, int *styleChanged);
/*
- * The structure below defines menubutton class behavior by means of
- * procedures that can be invoked from generic window code.
+ * The structure below defines menubutton class behavior by means of functions
+ * that can be invoked from generic window code.
*/
Tk_ClassProcs tkpMenubuttonClass = {
sizeof(Tk_ClassProcs), /* size */
TkMenuButtonWorldChanged, /* worldChangedProc */
};
-
/*
*----------------------------------------------------------------------
@@ -117,309 +98,114 @@ TkMenuButton *
TkpCreateMenuButton(
Tk_Window tkwin)
{
- MacMenuButton *mbPtr = (MacMenuButton *) ckalloc(sizeof(MacMenuButton));
+ MacMenuButton *macButtonPtr =
+ (MacMenuButton *) ckalloc(sizeof(MacMenuButton));
- Tk_CreateEventHandler(tkwin, ActivateMask,
- MenuButtonEventProc, (ClientData) mbPtr);
- mbPtr->flags = 0;
- mbPtr->userPaneBackground = PIXEL_MAGIC << 24;
- mbPtr->userPane = NULL;
- mbPtr->control = NULL;
- mbPtr->menuRef = NULL;
- bzero(&mbPtr->params, sizeof(mbPtr->params));
- bzero(&mbPtr->titleParams, sizeof(mbPtr->titleParams));
+ macButtonPtr->button = nil;
- return (TkMenuButton *) mbPtr;
+ Tk_CreateEventHandler(tkwin, ActivateMask,
+ MenuButtonEventProc, (ClientData) macButtonPtr);
+ return (TkMenuButton *) macButtonPtr;
}
/*
*----------------------------------------------------------------------
*
- * TkpDisplayMenuButton --
+ * TkpDestroyMenuButton --
*
- * This procedure is invoked to display a menubutton widget.
+ * Free data structures associated with the menubutton control.
*
* Results:
* None.
*
* Side effects:
- * Commands are output to X to display the menubutton in its
- * current mode.
+ * Restores the default control state.
*
*----------------------------------------------------------------------
*/
void
-TkpDisplayMenuButton(
- ClientData clientData) /* Information about widget. */
+TkpDestroyMenuButton(
+ TkMenuButton *mbPtr)
{
- TkMenuButton *butPtr = (TkMenuButton *) clientData;
- Tk_Window tkwin = butPtr->tkwin;
- TkWindow *winPtr;
- Pixmap pixmap;
- MacMenuButton *mbPtr = (MacMenuButton *) butPtr;
- CGrafPtr destPort, savePort;
- Boolean portChanged = false;
- int hasImageOrBitmap = 0, width, height;
- OSStatus err;
- ControlButtonGraphicAlignment theAlignment;
- Rect paneRect, cntrRect;
- int active, enabled;
+ MacMenuButton *macButtonPtr = (MacMenuButton *) mbPtr;
- butPtr->flags &= ~REDRAW_PENDING;
- if ((butPtr->tkwin == NULL) || !Tk_IsMapped(tkwin)) {
- return;
- }
- pixmap = (Pixmap) Tk_WindowId(tkwin);
- TkMacOSXSetUpClippingRgn(Tk_WindowId(tkwin));
-
- winPtr = (TkWindow *)butPtr->tkwin;
- paneRect.left = winPtr->privatePtr->xOff;
- paneRect.top = winPtr->privatePtr->yOff;
- paneRect.right = paneRect.left+Tk_Width(butPtr->tkwin);
- paneRect.bottom = paneRect.top+Tk_Height(butPtr->tkwin);
-
- cntrRect = paneRect;
-
- cntrRect.left += butPtr->inset;
- cntrRect.top += butPtr->inset;
- cntrRect.right -= butPtr->inset;
- cntrRect.bottom -= butPtr->inset;
-
- if (mbPtr->userPane) {
- MenuButtonControlParams params;
- bzero(&params, sizeof(params));
- ComputeMenuButtonControlParams(butPtr, &params);
- if (
-#ifdef TK_REBUILD_TOPLEVEL
- (winPtr->flags & TK_REBUILD_TOPLEVEL) ||
-#endif
- bcmp(&params,&mbPtr->params,sizeof(params))) {
- if (mbPtr->userPane) {
- DisposeControl(mbPtr->userPane);
- mbPtr->userPane = NULL;
- mbPtr->control = NULL;
- }
- }
- }
- if (!mbPtr->userPane) {
- if (MenuButtonInitControl(mbPtr, &paneRect, &cntrRect)) {
- TkMacOSXDbgMsg("Init Control failed");
- return;
- }
- }
- SetControlBounds(mbPtr->userPane, &paneRect);
- SetControlBounds(mbPtr->control, &cntrRect);
-
- if (butPtr->image != None) {
- Tk_SizeOfImage(butPtr->image, &width, &height);
- hasImageOrBitmap = 1;
- } else if (butPtr->bitmap != None) {
- Tk_SizeOfBitmap(butPtr->display, butPtr->bitmap, &width, &height);
- hasImageOrBitmap = 1;
- }
-
- /*
- * We need to cache the title and its style
- */
-
- if (!(mbPtr->flags & FIRST_DRAW)) {
- ControlTitleParams titleParams;
- int titleChanged;
- int styleChanged;
-
- ComputeControlTitleParams(butPtr, &titleParams);
- CompareControlTitleParams(&titleParams, &mbPtr->titleParams,
- &titleChanged, &styleChanged);
- if (titleChanged) {
- CFStringRef cf = CFStringCreateWithCString(NULL,
- (char*) titleParams.title, kCFStringEncodingUTF8);
-
- if (hasImageOrBitmap) {
- SetControlTitleWithCFString(mbPtr->control, cf);
- } else {
- SetMenuItemTextWithCFString(mbPtr->menuRef, 1, cf);
- }
- CFRelease(cf);
- bcopy(titleParams.title, mbPtr->titleParams.title,
- titleParams.len + 1);
- mbPtr->titleParams.len = titleParams.len;
- }
- if ((titleChanged||styleChanged) && titleParams .len) {
- if (hasImageOrBitmap) {
- err = ChkErr(SetControlFontStyle, mbPtr->control,
- &titleParams.style);
- if (err != noErr) {
- return;
- }
- }
- bcopy(&titleParams.style, &mbPtr->titleParams.style,
- sizeof(titleParams.style));
- }
- }
- if (hasImageOrBitmap) {
- {
- destPort = TkMacOSXGetDrawablePort(Tk_WindowId(tkwin));
- portChanged = QDSwapPort(destPort, &savePort);
- mbPtr->picParams.version = -2;
- mbPtr->picParams.hRes = 0x00480000;
- mbPtr->picParams.vRes = 0x00480000;
- mbPtr->picParams.srcRect.top = 0;
- mbPtr->picParams.srcRect.left = 0;
- mbPtr->picParams.srcRect.bottom = height;
- mbPtr->picParams.srcRect.right = width;
- mbPtr->picParams.reserved1 = 0;
- mbPtr->picParams.reserved2 = 0;
- mbPtr->bevelButtonContent.contentType = kControlContentPictHandle;
- mbPtr->bevelButtonContent.u.picture = OpenCPicture(&mbPtr->picParams);
- if (!mbPtr->bevelButtonContent.u.picture) {
- TkMacOSXDbgMsg("OpenCPicture failed");
- }
- tkPictureIsOpen = 1;
-
- /*
- * TO DO - There is one case where XCopyPlane calls CopyDeepMask,
- * which does not get recorded in the picture. So the bitmap code
- * will fail in that case.
- */
- }
- if (butPtr->image != NULL) {
- Tk_RedrawImage(butPtr->image, 0, 0, width, height, pixmap, 0, 0);
- } else {
- GC gc;
-
- if (butPtr->state == STATE_DISABLED) {
- gc = butPtr->disabledGC;
- } else if (butPtr->state == STATE_ACTIVE) {
- gc = butPtr->activeTextGC;
- } else {
- gc = butPtr->normalTextGC;
- }
- XCopyPlane(butPtr->display, butPtr->bitmap, pixmap, gc, 0, 0,
- width, height, 0, 0, 1);
- }
- {
- ClosePicture();
- tkPictureIsOpen = 0;
- if (portChanged) {
- QDSwapPort(savePort, NULL);
- }
- }
- ChkErr(SetControlData, mbPtr->control, kControlButtonPart,
- kControlBevelButtonContentTag,
- sizeof(ControlButtonContentInfo),
- (char *) &mbPtr->bevelButtonContent);
- switch (butPtr->anchor) {
- case TK_ANCHOR_N:
- theAlignment = kControlBevelButtonAlignTop;
- break;
- case TK_ANCHOR_NE:
- theAlignment = kControlBevelButtonAlignTopRight;
- break;
- case TK_ANCHOR_E:
- theAlignment = kControlBevelButtonAlignRight;
- break;
- case TK_ANCHOR_SE:
- theAlignment = kControlBevelButtonAlignBottomRight;
- break;
- case TK_ANCHOR_S:
- theAlignment = kControlBevelButtonAlignBottom;
- break;
- case TK_ANCHOR_SW:
- theAlignment = kControlBevelButtonAlignBottomLeft;
- break;
- case TK_ANCHOR_W:
- theAlignment = kControlBevelButtonAlignLeft;
- break;
- case TK_ANCHOR_NW:
- theAlignment = kControlBevelButtonAlignTopLeft;
- break;
- case TK_ANCHOR_CENTER:
- theAlignment = kControlBevelButtonAlignCenter;
- break;
- }
-
- ChkErr(SetControlData, mbPtr->control, kControlButtonPart,
- kControlBevelButtonGraphicAlignTag,
- sizeof(ControlButtonGraphicAlignment), (char *) &theAlignment);
- }
- active = ((mbPtr->flags & ACTIVE) != 0);
- if (active != IsControlActive(mbPtr->control)) {
- if (active) {
- ChkErr(ActivateControl, mbPtr->control);
- } else {
- ChkErr(DeactivateControl, mbPtr->control);
- }
- }
- enabled = !(butPtr->state == STATE_DISABLED);
- if (enabled != IsControlEnabled(mbPtr->control)) {
- if (enabled) {
- ChkErr(EnableControl, mbPtr->control);
- } else {
- ChkErr(DisableControl, mbPtr->control);
- }
- }
- if (active && enabled) {
- if (butPtr->state == STATE_ACTIVE) {
- if (hasImageOrBitmap) {
- HiliteControl(mbPtr->control, kControlButtonPart);
- } else {
- HiliteControl(mbPtr->control, kControlLabelPart);
- }
- } else {
- HiliteControl(mbPtr->control, kControlNoPart);
- }
- }
- UpdateControlColors(mbPtr);
- if (mbPtr->flags & FIRST_DRAW) {
- ShowControl(mbPtr->control);
- ShowControl(mbPtr->userPane);
- mbPtr->flags ^= FIRST_DRAW;
- } else {
- SetControlVisibility(mbPtr->control, true, true);
- Draw1Control(mbPtr->userPane);
- }
- if (hasImageOrBitmap) {
- if (mbPtr->bevelButtonContent.contentType ==
- kControlContentPictHandle) {
- KillPicture(mbPtr->bevelButtonContent.u.picture);
- }
- }
+ TkMacOSXMakeCollectableAndRelease(macButtonPtr->button);
}
/*
*----------------------------------------------------------------------
*
- * TkpDestroyMenuButton --
+ * TkpDisplayMenuButton --
*
- * Free data structures associated with the menubutton control.
+ * This function is invoked to display a menubutton widget.
*
* Results:
* None.
*
* Side effects:
- * Restores the default control state.
+ * Commands are output to X to display the menubutton in its current
+ * mode.
*
*----------------------------------------------------------------------
*/
void
-TkpDestroyMenuButton(
- TkMenuButton *mbPtr)
+TkpDisplayMenuButton(
+ ClientData clientData) /* Information about widget. */
{
- MacMenuButton *macMbPtr = (MacMenuButton *) mbPtr;
-
- if (macMbPtr->userPane) {
- DisposeControl(macMbPtr->userPane);
- macMbPtr->userPane = NULL;
+ TkMenuButton *mbPtr = (TkMenuButton *) clientData;
+ MacMenuButton *macButtonPtr = (MacMenuButton *) mbPtr;
+ NSPopUpButton *button = macButtonPtr->button;
+ Tk_Window tkwin = mbPtr->tkwin;
+ TkWindow *winPtr = (TkWindow *) tkwin;
+ MacDrawable *macWin = (MacDrawable *) winPtr->window;
+ TkMacOSXDrawingContext dc;
+ NSView *view = TkMacOSXDrawableView(macWin);
+ CGFloat viewHeight = [view bounds].size.height;
+ CGAffineTransform t = { .a = 1, .b = 0, .c = 0, .d = -1, .tx = 0,
+ .ty = viewHeight};
+ NSRect frame;
+ int enabled;
+
+ mbPtr->flags &= ~REDRAW_PENDING;
+ if (!tkwin || !Tk_IsMapped(tkwin) || !view ||
+ !TkMacOSXSetupDrawingContext((Drawable) macWin, NULL, 1, &dc)) {
+ return;
}
- if (macMbPtr->menuRef) {
- short menuID = GetMenuID(macMbPtr->menuRef);
-
- TkMacOSXFreeMenuID(menuID);
- DisposeMenu(macMbPtr->menuRef);
- macMbPtr->menuRef = NULL;
+ CGContextConcatCTM(dc.context, t);
+ Tk_Fill3DRectangle(tkwin, (Pixmap) macWin, mbPtr->normalBorder, 0, 0,
+ Tk_Width(tkwin), Tk_Height(tkwin), 0, TK_RELIEF_FLAT);
+ if ([button superview] != view) {
+ [view addSubview:button];
}
+ enabled = !(mbPtr->state == STATE_DISABLED);
+ [button setEnabled:enabled];
+ if (enabled) {
+ [[button cell] setHighlighted:(mbPtr->state == STATE_ACTIVE)];
+ }
+ frame = NSMakeRect(macWin->xOff, macWin->yOff, Tk_Width(tkwin),
+ Tk_Height(tkwin));
+ frame = NSInsetRect(frame, mbPtr->inset, mbPtr->inset);
+#if TK_MAC_BUTTON_USE_COMPATIBILITY_METRICS
+ if (tkMacOSXUseCompatibilityMetrics) {
+ BoundsFix boundsFix = boundsFixes[macButtonPtr->fix];
+ frame = NSOffsetRect(frame, boundsFix.offsetX, boundsFix.offsetY);
+ frame.size.width -= boundsFix.shrinkW;
+ frame = NSInsetRect(frame, boundsFix.inset, boundsFix.inset);
+ }
+#endif
+ frame.origin.y = viewHeight - (frame.origin.y + frame.size.height);
+ if (!NSEqualRects(frame, [button frame])) {
+ [button setFrame:frame];
+ }
+ [button displayRectIgnoringOpacity:[button bounds]];
+ TkMacOSXRestoreDrawingContext(&dc);
+#ifdef TK_MAC_DEBUG_MENUBUTTON
+ TKLog(@"menubutton %s frame %@ width %d height %d",
+ ((TkWindow *)mbPtr->tkwin)->pathName, NSStringFromRect(frame),
+ Tk_Width(tkwin), Tk_Height(tkwin));
+#endif
}
/*
@@ -427,7 +213,7 @@ TkpDestroyMenuButton(
*
* TkpComputeMenuButtonGeometry --
*
- * After changes in a menu button's text or bitmap, this procedure
+ * After changes in a menu button's text or bitmap, this function
* recomputes the menu button's geometry and passes this information
* along to the geometry manager for the window.
*
@@ -441,482 +227,205 @@ TkpDestroyMenuButton(
*/
void
-TkpComputeMenuButtonGeometry(mbPtr)
- register TkMenuButton *mbPtr; /* Widget record for menu button. */
+TkpComputeMenuButtonGeometry(
+ TkMenuButton *mbPtr) /* Widget record for menu button. */
{
- int width, height, mm, pixels;
- int hasImageOrBitmap = 0;
-
- mbPtr->inset = mbPtr->highlightWidth + mbPtr->borderWidth;
- if (mbPtr->image != None) {
- Tk_SizeOfImage(mbPtr->image, &width, &height);
- hasImageOrBitmap = 1;
- } else if (mbPtr->bitmap != None) {
- Tk_SizeOfBitmap(mbPtr->display, mbPtr->bitmap, &width, &height);
- hasImageOrBitmap = 1;
+ MacMenuButton *macButtonPtr = (MacMenuButton *) mbPtr;
+ NSPopUpButton *button = macButtonPtr->button;
+ NSPopUpButtonCell *cell;
+ NSMenuItem *menuItem;
+ NSBezelStyle style = NSRoundedBezelStyle;
+ NSFont *font;
+ NSRect bounds = NSZeroRect, titleRect = NSZeroRect;
+ int haveImage = (mbPtr->image || mbPtr->bitmap != None), haveText = 0;
+ int haveCompound = (mbPtr->compound != COMPOUND_NONE);
+ int width, height;
+
+ if (!button) {
+ button = [[NSPopUpButton alloc] initWithFrame:NSZeroRect pullsDown:YES];
+ macButtonPtr->button = TkMacOSXMakeUncollectable(button);
+ cell = [button cell];
+ [cell setUsesItemFromMenu:NO];
+ menuItem = [[[NSMenuItem alloc] initWithTitle:@""
+ action:NULL keyEquivalent:@""] autorelease];
+ [cell setMenuItem:menuItem];
} else {
- hasImageOrBitmap = 0;
- Tk_FreeTextLayout(mbPtr->textLayout);
- mbPtr->textLayout = Tk_ComputeTextLayout(mbPtr->tkfont, mbPtr->text,
- -1, mbPtr->wrapLength, mbPtr->justify, 0, &mbPtr->textWidth,
- &mbPtr->textHeight);
- width = mbPtr->textWidth;
- height = mbPtr->textHeight;
- if (mbPtr->width > 0) {
- width = mbPtr->width * Tk_TextWidth(mbPtr->tkfont, "0", 1);
- }
- if (mbPtr->height > 0) {
- Tk_FontMetrics fm;
+ cell = [button cell];
+ menuItem = [cell menuItem];
+ }
+ if (haveImage) {
+ style = NSShadowlessSquareBezelStyle;
+ } else if (!mbPtr->indicatorOn) {
+ style = NSRegularSquareBezelStyle;
+ }
+ [button setBezelStyle:style];
+ [cell setArrowPosition:(mbPtr->indicatorOn ? NSPopUpArrowAtBottom :
+ NSPopUpNoArrow)];
+#if 0
+ NSControlSize controlSize = NSRegularControlSize;
+
+ if (mbPtr->borderWidth <= 2) {
+ controlSize = NSMiniControlSize;
+ } else if (mbPtr->borderWidth == 3) {
+ controlSize = NSSmallControlSize;
+ }
+ [cell setControlSize:controlSize];
+#endif
- Tk_GetFontMetrics(mbPtr->tkfont, &fm);
- height = mbPtr->height * fm.linespace;
- }
- width += 2*mbPtr->padX;
- height += 2*mbPtr->padY;
+ if (mbPtr->text && *(mbPtr->text) && (!haveImage || haveCompound)) {
+ NSString *title = [[NSString alloc] initWithUTF8String:mbPtr->text];
+ [button setTitle:title];
+ [title release];
+ haveText = 1;
}
- if (hasImageOrBitmap) {
- if (mbPtr->width > 0) {
- width = mbPtr->width;
- }
- if (mbPtr->height > 0) {
- height = mbPtr->height;
+ haveCompound = (haveCompound && haveImage && haveText);
+ if (haveText) {
+ NSTextAlignment alignment = NSNaturalTextAlignment;
+
+ switch (mbPtr->justify) {
+ case TK_JUSTIFY_LEFT:
+ alignment = NSLeftTextAlignment;
+ break;
+ case TK_JUSTIFY_RIGHT:
+ alignment = NSRightTextAlignment;
+ break;
+ case TK_JUSTIFY_CENTER:
+ alignment = NSCenterTextAlignment;
+ break;
}
- mbPtr->inset = mbPtr->highlightWidth + 2;
- width += (2 * mbPtr->borderWidth + 4);
- height += (2 * mbPtr->borderWidth + 4);
+ [button setAlignment:alignment];
} else {
- width += TK_POPUP_OFFSET;
+ [button setTitle:@""];
}
- if (mbPtr->indicatorOn) {
- mm = WidthMMOfScreen(Tk_Screen(mbPtr->tkwin));
- pixels = WidthOfScreen(Tk_Screen(mbPtr->tkwin));
- mbPtr->indicatorHeight = kTriangleHeight;
- mbPtr->indicatorWidth = kTriangleWidth + kTriangleMargin;
- width += mbPtr->indicatorWidth;
- } else {
- mbPtr->indicatorHeight = 0;
- mbPtr->indicatorWidth = 0;
+ font = TkMacOSXNSFontForFont(mbPtr->tkfont);
+ if (font) {
+ [button setFont:font];
}
-
- Tk_GeometryRequest(mbPtr->tkwin, (int) (width + 2*mbPtr->inset),
- (int) (height + 2*mbPtr->inset));
- Tk_SetInternalBorder(mbPtr->tkwin, mbPtr->inset);
-}
-
-/*
- *----------------------------------------------------------------------
- *
- * ComputeMenuButtonControlParams --
- *
- * This procedure computes the various parameters used
- * when creating a Carbon control (NewControl)
- * These are determined by the various tk menu button parameters
- *
- * Results:
- * None.
- *
- * Side effects:
- * Sets the control initialisation parameters
- *
- *----------------------------------------------------------------------
- */
-
-static void
-ComputeMenuButtonControlParams(
- TkMenuButton *mbPtr,
- MenuButtonControlParams *paramsPtr)
-{
- int fakeMenuID = 256;
-
- /*
- * Determine ProcID based on button type and dimensions
- *
- * We need to set minValue to some non-zero value,
- * Otherwise, the markers do not show up
- */
-
- paramsPtr->minValue = kControlBehaviorMultiValueMenu;
- paramsPtr->maxValue = 0;
- if (mbPtr->image || mbPtr->bitmap) {
- paramsPtr->isBevel = 1;
- if (mbPtr->borderWidth <= 2) {
- paramsPtr->procID = kControlBevelButtonSmallBevelProc;
- } else if (mbPtr->borderWidth == 3) {
- paramsPtr->procID = kControlBevelButtonNormalBevelProc;
+ if (haveImage) {
+ int width, height;
+ NSImage *image;
+ NSCellImagePosition pos = NSImageOnly;
+
+ if (mbPtr->image) {
+ Tk_SizeOfImage(mbPtr->image, &width, &height);
+ image = TkMacOSXGetNSImageWithTkImage(mbPtr->display,
+ mbPtr->image, width, height);
} else {
- paramsPtr->procID = kControlBevelButtonLargeBevelProc;
+ Tk_SizeOfBitmap(mbPtr->display, mbPtr->bitmap, &width, &height);
+ image = TkMacOSXGetNSImageWithBitmap(mbPtr->display,
+ mbPtr->bitmap, mbPtr->normalTextGC, width, height);
}
- if (mbPtr->indicatorOn) {
- paramsPtr->initialValue = fakeMenuID;
- } else {
- paramsPtr->initialValue = 0;
+ if (haveCompound) {
+ switch ((enum compound) mbPtr->compound) {
+ case COMPOUND_TOP:
+ pos = NSImageAbove;
+ break;
+ case COMPOUND_BOTTOM:
+ pos = NSImageBelow;
+ break;
+ case COMPOUND_LEFT:
+ pos = NSImageLeft;
+ break;
+ case COMPOUND_RIGHT:
+ pos = NSImageRight;
+ break;
+ case COMPOUND_CENTER:
+ pos = NSImageOverlaps;
+ break;
+ case COMPOUND_NONE:
+ pos = NSImageOnly;
+ break;
+ }
}
+ [button setImagePosition:pos];
+ [menuItem setImage:image];
+ bounds.size = cell ? [cell cellSize] : NSZeroSize;
+ if (bounds.size.height < height + 8) { /* workaround AppKit sizing bug */
+ bounds.size.height = height + 8;
+ }
+#if TK_MAC_BUTTON_USE_COMPATIBILITY_METRICS
+ if (!mbPtr->indicatorOn && tkMacOSXUseCompatibilityMetrics) {
+ bounds.size.width -= 16;
+ }
+#endif
} else {
- paramsPtr->isBevel = 0;
- paramsPtr->procID = kControlPopupButtonProc
- + kControlPopupVariableWidthVariant;
- paramsPtr->minValue = -12345;
- paramsPtr->maxValue = -1;
- paramsPtr->initialValue = 0;
- }
-}
-
-/*
- *----------------------------------------------------------------------
- *
- * returns 0 if same, 1 otherwise
- *
- *----------------------------------------------------------------------
- */
-
-static void
-CompareControlTitleParams(
- ControlTitleParams *p1Ptr,
- ControlTitleParams *p2Ptr,
- int *titleChanged,
- int *styleChanged)
-{
- if (p1Ptr->len != p2Ptr->len) {
- *titleChanged = 1;
- } else if (bcmp(p1Ptr->title,p2Ptr->title,p1Ptr->len)) {
- *titleChanged = 1;
- } else {
- *titleChanged = 0;
- }
-
- if (p1Ptr->len && p2Ptr->len) {
- *styleChanged = bcmp(&p1Ptr->style, &p2Ptr->style,
- sizeof(p2Ptr->style));
- } else {
- *styleChanged = p1Ptr->len||p2Ptr->len;
- }
-}
-
-static void
-ComputeControlTitleParams(
- TkMenuButton *butPtr,
- ControlTitleParams *paramsPtr)
-{
- Tk_Font font;
-
- paramsPtr->len = TkFontGetFirstTextLayout(butPtr->textLayout, &font,
- (char*) paramsPtr->title);
- paramsPtr->title[paramsPtr->len] = 0;
- if (paramsPtr->len) {
- TkMacOSXInitControlFontStyle(font,&paramsPtr->style);
- }
-}
-
-/*
- *----------------------------------------------------------------------
- *
- * MenuButtonInitControl --
- *
- * This procedure initialises a Carbon control
- *
- * Results:
- * 0 on success, 1 on failure.
- *
- * Side effects:
- * A background pane control and the control itself is created
- * The contol is embedded in the background control
- * The background control is embedded in the root control
- * of the containing window
- * The creation parameters for the control are also computed
- *
- *----------------------------------------------------------------------
- */
-int
-MenuButtonInitControl(
- MacMenuButton *mbPtr, /* Mac button. */
- Rect *paneRect,
- Rect *cntrRect)
-{
- OSStatus err;
- TkMenuButton *butPtr = (TkMenuButton *) mbPtr;
- SInt16 procID, initialValue, minValue, maxValue;
- Boolean initiallyVisible;
- SInt32 controlReference;
- short menuID;
- ControlRef rootControl =
- TkMacOSXGetRootControl(Tk_WindowId(butPtr->tkwin));
-
- mbPtr->windowRef = TkMacOSXDrawableWindow(Tk_WindowId(butPtr->tkwin));
-
- /*
- * Set up the user pane
- */
-
- initiallyVisible = false;
- initialValue = kControlSupportsEmbedding | kControlHasSpecialBackground;
- minValue = 0;
- maxValue = 1;
- procID = kControlUserPaneProc;
- controlReference = (SInt32)mbPtr;
- mbPtr->userPane = NewControl(mbPtr->windowRef, paneRect, "\p",
- initiallyVisible, initialValue, minValue, maxValue, procID,
- controlReference);
- if (!mbPtr->userPane) {
- TkMacOSXDbgMsg("Failed to create user pane control");
- return 1;
- }
- err = ChkErr(EmbedControl, mbPtr->userPane, rootControl);
- if (err != noErr) {
- return 1;
- }
- SetUserPaneSetUpSpecialBackgroundProc(mbPtr->userPane,
- UserPaneBackgroundProc);
- SetUserPaneDrawProc(mbPtr->userPane,UserPaneDraw);
- initiallyVisible = false;
- ComputeMenuButtonControlParams(butPtr,&mbPtr->params);
-
- /*
- * Do this only if we are using bevel buttons.
- */
-
- ComputeControlTitleParams(butPtr, &mbPtr->titleParams);
- mbPtr->control = NewControl(mbPtr->windowRef,
- cntrRect, "\p" /* mbPtr->titleParams.title */,
- initiallyVisible, mbPtr->params.initialValue,
- mbPtr->params.minValue, mbPtr->params.maxValue,
- mbPtr->params.procID, controlReference);
- if (!mbPtr->control) {
- TkMacOSXDbgMsg("Failed to create control of type %d",
- mbPtr->params.procID);
- return 1;
+ bounds.size = cell ? [cell cellSize] : NSZeroSize;
}
- err = ChkErr(EmbedControl, mbPtr->control, mbPtr->userPane);
- if (err != noErr ) {
- return 1;
- }
- if (mbPtr->params.isBevel) {
- CFStringRef cf = CFStringCreateWithCString(NULL,
- (char*) mbPtr->titleParams.title, kCFStringEncodingUTF8);
-
- SetControlTitleWithCFString(mbPtr->control, cf);
- CFRelease(cf);
- if (mbPtr->titleParams.len) {
- err = ChkErr(SetControlFontStyle, mbPtr->control,
- &mbPtr->titleParams.style);
- if (err != noErr) {
- return 1;
+ if (haveText) {
+ titleRect = cell ? [cell titleRectForBounds:bounds] : NSZeroRect;
+ if (mbPtr->wrapLength > 0 &&
+ titleRect.size.width > mbPtr->wrapLength) {
+ if (style == NSRoundedBezelStyle) {
+ [button setBezelStyle:(style = NSRegularSquareBezelStyle)];
+ bounds.size = cell ? [cell cellSize] : NSZeroSize;
+ titleRect = cell ? [cell titleRectForBounds:bounds] : NSZeroRect;
}
+ bounds.size.width -= titleRect.size.width - mbPtr->wrapLength;
+ bounds.size.height = 40000.0;
+ [cell setWraps:YES];
+ bounds.size = cell ? [cell cellSizeForBounds:bounds] : NSZeroSize;
+#ifdef TK_MAC_DEBUG_MENUBUTTON
+ titleRect = cell ? [cell titleRectForBounds:bounds] : NSZeroRect;
+#endif
+#if TK_MAC_BUTTON_USE_COMPATIBILITY_METRICS
+ if (tkMacOSXUseCompatibilityMetrics) {
+ bounds.size.height += 3;
+ }
+#endif
}
- } else {
- CFStringRef cfStr;
+ }
+ width = lround(bounds.size.width);
+ height = lround(bounds.size.height);
+#if TK_MAC_BUTTON_USE_COMPATIBILITY_METRICS
+ if (tkMacOSXUseCompatibilityMetrics) {
+ macButtonPtr->fix = fixForStyle(style);
+ width -= boundsFixes[macButtonPtr->fix].trimW;
+ height -= boundsFixes[macButtonPtr->fix].trimH;
+ }
+#endif
- err = TkMacOSXGetNewMenuID(mbPtr->info.interp, (TkMenu *) mbPtr, 0,
- &menuID);
- if (err != TCL_OK) {
- return 1;
- }
- err = ChkErr(CreateNewMenu, menuID, kMenuAttrDoNotUseUserCommandKeys,
- &(mbPtr->menuRef));
- if (err != noErr) {
- return 1;
+ if (haveImage || haveCompound) {
+ if (mbPtr->width > 0) {
+ width = mbPtr->width;
}
- cfStr = CFStringCreateWithCString(NULL, Tk_PathName(mbPtr->info.tkwin),
- kCFStringEncodingUTF8);
- if (!cfStr) {
- TkMacOSXDbgMsg("CFStringCreateWithCString failed");
- return 1;
+ if (mbPtr->height > 0) {
+ height = mbPtr->height;
}
- err = ChkErr(SetMenuTitleWithCFString, mbPtr->menuRef, cfStr);
- CFRelease(cfStr);
- if (err != noErr) {
- return 1;
+ } else {
+ if (mbPtr->width > 0) {
+ int avgWidth = Tk_TextWidth(mbPtr->tkfont, "0", 1);
+ width = mbPtr->width * avgWidth;
}
- cfStr = CFStringCreateWithCString(NULL,
- (char*) mbPtr->titleParams.title, kCFStringEncodingUTF8);
- AppendMenuItemText(mbPtr->menuRef, "\px");
- if (cfStr) {
- SetMenuItemTextWithCFString(mbPtr->menuRef, 1, cfStr);
- CFRelease(cfStr);
+ if (mbPtr->height > 0) {
+ Tk_FontMetrics fm;
+
+ Tk_GetFontMetrics(mbPtr->tkfont, &fm);
+ height = mbPtr->height * fm.linespace;
}
- ChkErr(SetControlData, mbPtr->control, kControlNoPart,
- kControlPopupButtonMenuRefTag, sizeof(mbPtr->menuRef),
- &mbPtr->menuRef);
- SetControlMinimum(mbPtr->control, 1);
- SetControlMaximum(mbPtr->control, 1);
- SetControlValue(mbPtr->control, 1);
}
- mbPtr->flags |= FIRST_DRAW;
- if (IsWindowActive(mbPtr->windowRef)) {
- mbPtr->flags |= ACTIVE;
+ if (!haveImage || haveCompound) {
+ width += 2*mbPtr->padX;
+ height += 2*mbPtr->padY;
}
- return 0;
-}
-
-/*
- *--------------------------------------------------------------
- *
- * SetUserPane
- *
- * Utility function to add a UserPaneDrawProc
- * to a userPane control. From MoreControls code
- * from Apple DTS.
- *
- * Results:
- * MacOS system error.
- *
- * Side effects:
- * The user pane gets a new UserPaneDrawProc.
- *
- *--------------------------------------------------------------
- */
-OSStatus
-SetUserPaneDrawProc(
- ControlRef control,
- ControlUserPaneDrawProcPtr upp)
-{
- ControlUserPaneDrawUPP myControlUserPaneDrawUPP =
- NewControlUserPaneDrawUPP(upp);
-
- return SetControlData(control, kControlNoPart,kControlUserPaneDrawProcTag,
- sizeof(myControlUserPaneDrawUPP), (Ptr)&myControlUserPaneDrawUPP);
-}
-
-/*
- *--------------------------------------------------------------
- *
- * SetUserPaneSetUpSpecialBackgroundProc --
- *
- * Utility function to add a UserPaneBackgroundProc
- * to a userPane control
- *
- * Results:
- * MacOS system error.
- *
- * Side effects:
- * The user pane gets a new UserPaneBackgroundProc.
- *
- *--------------------------------------------------------------
- */
-
-OSStatus
-SetUserPaneSetUpSpecialBackgroundProc(
- ControlRef control,
- ControlUserPaneBackgroundProcPtr upp)
-{
- ControlUserPaneBackgroundUPP myControlUserPaneBackgroundUPP =
- NewControlUserPaneBackgroundUPP(upp);
-
- return SetControlData(control, kControlNoPart,
- kControlUserPaneBackgroundProcTag,
- sizeof(myControlUserPaneBackgroundUPP),
- (Ptr) &myControlUserPaneBackgroundUPP);
-}
-
-/*
- *--------------------------------------------------------------
- *
- * UserPaneDraw --
- *
- * This function draws the background of the user pane that will
- * lie under checkboxes and radiobuttons.
- *
- * Results:
- * None.
- *
- * Side effects:
- * The user pane gets updated to the current color.
- *
- *--------------------------------------------------------------
- */
-
-void
-UserPaneDraw(
- ControlRef control,
- ControlPartCode cpc)
-{
- Rect contrlRect;
- MacMenuButton * mbPtr =
- (MacMenuButton *)(intptr_t)GetControlReference(control);
- CGrafPtr port;
-
- GetPort(&port);
- GetControlBounds(control,&contrlRect);
- TkMacOSXSetColorInPort(mbPtr->userPaneBackground, 0, NULL, port);
- EraseRect (&contrlRect);
-}
-
-/*
- *--------------------------------------------------------------
- *
- * UserPaneBackgroundProc --
- *
- * This function sets up the background of the user pane that will
- * lie under checkboxes and radiobuttons.
- *
- * Results:
- * None.
- *
- * Side effects:
- * The user pane background gets set to the current color.
- *
- *--------------------------------------------------------------
- */
-
-void
-UserPaneBackgroundProc(
- ControlHandle control,
- ControlBackgroundPtr info)
-{
- MacMenuButton *mbPtr =
- (MacMenuButton *)(intptr_t)GetControlReference(control);
-
- if (info->colorDevice) {
- CGrafPtr port;
-
- GetPort(&port);
- TkMacOSXSetColorInPort(mbPtr->userPaneBackground, 0, NULL, port);
+ if (mbPtr->highlightWidth < 0) {
+ mbPtr->highlightWidth = 0;
}
-}
-
-/*
- *--------------------------------------------------------------
- *
- * UpdateControlColors --
- *
- * This function will review the colors used to display
- * a Macintosh button. If any non-standard colors are
- * used we create a custom palette for the button, populate
- * with the colors for the button and install the palette.
- *
- * Under Appearance, we just set the pointer that will be
- * used by the UserPaneDrawProc.
- *
- * Results:
- * None.
- *
- * Side effects:
- * The Macintosh control may get a custom palette installed.
- *
- *--------------------------------------------------------------
- */
-
-static int
-UpdateControlColors(
- MacMenuButton *mbPtr)
-{
- XColor *xcolor;
- TkMenuButton * butPtr = (TkMenuButton *) mbPtr;
-
- /*
- * Under Appearance we cannot change the background of the
- * button itself. However, the color we are setting is the color
- * of the containing userPane. This will be the color that peeks
- * around the rounded corners of the button.
- * We make this the highlightbackground rather than the background,
- * because if you color the background of a frame containing a
- * button, you usually also color the highlightbackground as well,
- * or you will get a thin grey ring around the button.
- */
-
- xcolor = Tk_3DBorderColor(butPtr->normalBorder);
- mbPtr->userPaneBackground = xcolor->pixel;
-
- return false;
+ if (haveImage) {
+ mbPtr->inset = mbPtr->highlightWidth;
+ width += 2*mbPtr->borderWidth;
+ height += 2*mbPtr->borderWidth;
+ } else {
+ mbPtr->inset = mbPtr->highlightWidth + mbPtr->borderWidth;
+ }
+ Tk_GeometryRequest(mbPtr->tkwin, width + 2 * mbPtr->inset,
+ height + 2 * mbPtr->inset);
+ Tk_SetInternalBorder(mbPtr->tkwin, mbPtr->inset);
+#ifdef TK_MAC_DEBUG_MENUBUTTON
+ TKLog(@"menubutton %s bounds %@ titleRect %@ width %d height %d inset %d borderWidth %d",
+ ((TkWindow *)mbPtr->tkwin)->pathName, NSStringFromRect(bounds),
+ NSStringFromRect(titleRect), width, height, mbPtr->inset,
+ mbPtr->borderWidth);
+#endif
}
/*
@@ -931,7 +440,7 @@ UpdateControlColors(
* None.
*
* Side effects:
- * When it gets exposed, it is redisplayed.
+ * When activation state changes, it is redisplayed.
*
*--------------------------------------------------------------
*/
@@ -941,22 +450,27 @@ MenuButtonEventProc(
ClientData clientData, /* Information about window. */
XEvent *eventPtr) /* Information about event. */
{
- TkMenuButton *buttonPtr = (TkMenuButton *) clientData;
- MacMenuButton *mbPtr = (MacMenuButton *) clientData;
+ TkMenuButton *mbPtr = (TkMenuButton *) clientData;
- if (eventPtr->type == ActivateNotify
- || eventPtr->type == DeactivateNotify) {
- if ((buttonPtr->tkwin == NULL) || (!Tk_IsMapped(buttonPtr->tkwin))) {
- return;
- }
- if (eventPtr->type == ActivateNotify) {
- mbPtr->flags |= ACTIVE;
- } else {
- mbPtr->flags &= ~ACTIVE;
- }
- if ((buttonPtr->flags & REDRAW_PENDING) == 0) {
- Tcl_DoWhenIdle(TkpDisplayMenuButton, (ClientData) buttonPtr);
- buttonPtr->flags |= REDRAW_PENDING;
+ if (!mbPtr->tkwin || !Tk_IsMapped(mbPtr->tkwin)) {
+ return;
+ }
+ switch (eventPtr->type) {
+ case ActivateNotify:
+ case DeactivateNotify:
+ if (!(mbPtr->flags & REDRAW_PENDING)) {
+ Tcl_DoWhenIdle(TkpDisplayMenuButton, (ClientData) mbPtr);
+ mbPtr->flags |= REDRAW_PENDING;
}
+ break;
}
}
+
+/*
+ * Local Variables:
+ * mode: c
+ * c-basic-offset: 4
+ * fill-column: 79
+ * coding: utf-8
+ * End:
+ */
diff --git a/macosx/tkMacOSXMenus.c b/macosx/tkMacOSXMenus.c
index 2b5126c..e9f275e 100644
--- a/macosx/tkMacOSXMenus.c
+++ b/macosx/tkMacOSXMenus.c
@@ -1,45 +1,242 @@
/*
* tkMacOSXMenus.c --
*
- * These calls set up and manage the menubar for the
- * Macintosh version of Tk.
+ * These calls set up the default menus for Tk.
*
* Copyright (c) 1995-1996 Sun Microsystems, Inc.
- * Copyright 2001, Apple Computer, Inc.
- * Copyright (c) 2005-2007 Daniel A. Steffen <das@users.sourceforge.net>
+ * Copyright 2001-2009, Apple Inc.
+ * Copyright (c) 2005-2009 Daniel A. Steffen <das@users.sourceforge.net>
*
* See the file "license.terms" for information on usage and redistribution
* of this file, and for a DISCLAIMER OF ALL WARRANTIES.
+ *
+ * RCS: @(#) $Id$
*/
#include "tkMacOSXPrivate.h"
+#include "tkMenu.h"
+
+static void GenerateEditEvent(const char *name);
+static Tcl_Obj * GetWidgetDemoPath(Tcl_Interp *interp);
-#define kAppleMenu 256
-#define kAppleAboutItem 1
-#define kFileMenu 2
-#define kEditMenu 3
+#pragma mark TKApplication(TKMenus)
-#define kSourceItem 1
-#define kDemoItem 2
-#define kCloseItem 3
+@implementation TKApplication(TKMenus)
+- (void)_setupMenus {
+ if (_defaultMainMenu) {
+ return;
+ }
+ TkMenuInit();
+ NSString *applicationName = [[NSBundle mainBundle]
+ objectForInfoDictionaryKey:@"CFBundleName"];
+ if (!applicationName) {
+ applicationName = [[NSProcessInfo processInfo] processName];
+ }
+ NSString *aboutName = (applicationName &&
+ ![applicationName isEqualToString:@"Wish"] &&
+ ![applicationName hasPrefix:@"tclsh"]) ?
+ applicationName : @"Tcl & Tk";
+ _servicesMenu = [NSMenu menuWithTitle:@"Services"];
+ _defaultApplicationMenuItems = [[NSArray arrayWithObjects:
+ [NSMenuItem separatorItem],
+ [NSMenuItem itemWithTitle:
+ [NSString stringWithFormat:@"Preferences%C", 0x2026]
+ action:@selector(preferences:) keyEquivalent:@","],
+ [NSMenuItem separatorItem],
+ [NSMenuItem itemWithTitle:@"Services" submenu:_servicesMenu],
+ [NSMenuItem separatorItem],
+ [NSMenuItem itemWithTitle:
+ [NSString stringWithFormat:@"Hide %@", applicationName]
+ action:@selector(hide:) keyEquivalent:@"h"],
+ [NSMenuItem itemWithTitle:@"Hide Others"
+ action:@selector(hideOtherApplications:) keyEquivalent:@"h"
+ keyEquivalentModifierMask:
+ NSCommandKeyMask|NSAlternateKeyMask],
+ [NSMenuItem itemWithTitle:@"Show All"
+ action:@selector(unhideAllApplications:)],
+ [NSMenuItem separatorItem],
+ [NSMenuItem itemWithTitle:
+ [NSString stringWithFormat:@"Quit %@", applicationName]
+ action: @selector(terminate:) keyEquivalent:@"q"],
+ nil] retain];
+ _defaultApplicationMenu = [TKMenu menuWithTitle:applicationName
+ menuItems:_defaultApplicationMenuItems];
+ [_defaultApplicationMenu insertItem:
+ [NSMenuItem itemWithTitle:
+ [NSString stringWithFormat:@"About %@", aboutName]
+ action:@selector(orderFrontStandardAboutPanel:)] atIndex:0];
+ TKMenu *fileMenu = [TKMenu menuWithTitle:@"File" menuItems:
+ [NSArray arrayWithObjects:
+ [NSMenuItem itemWithTitle:
+ [NSString stringWithFormat:@"Source%C", 0x2026]
+ action:@selector(tkSource:)],
+ [NSMenuItem itemWithTitle:@"Run Widget Demo"
+ action:@selector(tkDemo:)],
+ [NSMenuItem itemWithTitle:@"Close" action:@selector(performClose:)
+ target:nil keyEquivalent:@"w"],
+ nil]];
+ TKMenu *editMenu = [TKMenu menuWithTitle:@"Edit" menuItems:
+ [NSArray arrayWithObjects:
+ [NSMenuItem itemWithTitle:@"Undo" action:@selector(undo:)
+ target:nil keyEquivalent:@"z"],
+ [NSMenuItem itemWithTitle:@"Redo" action:@selector(redo:)
+ target:nil keyEquivalent:@"y"],
+ [NSMenuItem separatorItem],
+ [NSMenuItem itemWithTitle:@"Cut" action:@selector(cut:)
+ target:nil keyEquivalent:@"x"],
+ [NSMenuItem itemWithTitle:@"Copy" action:@selector(copy:)
+ target:nil keyEquivalent:@"c"],
+ [NSMenuItem itemWithTitle:@"Paste" action:@selector(paste:)
+ target:nil keyEquivalent:@"v"],
+ [NSMenuItem itemWithTitle:@"Delete" action:@selector(delete:)
+ target:nil],
+ nil]];
+ _defaultWindowsMenuItems = [[NSArray arrayWithObjects:
+ [NSMenuItem itemWithTitle:@"Minimize"
+ action:@selector(performMiniaturize:) target:nil
+ keyEquivalent:@"m"],
+ [NSMenuItem itemWithTitle:@"Zoom" action:@selector(performZoom:)
+ target:nil],
+ [NSMenuItem separatorItem],
+ [NSMenuItem itemWithTitle:@"Bring All to Front"
+ action:@selector(arrangeInFront:)],
+ nil] retain];
+ TKMenu *windowsMenu = [TKMenu menuWithTitle:@"Window" menuItems:
+ _defaultWindowsMenuItems];
+ _defaultHelpMenuItems = [[NSArray arrayWithObjects:
+ [NSMenuItem itemWithTitle:
+ [NSString stringWithFormat:@"%@ Help", applicationName]
+ action:@selector(showHelp:) keyEquivalent:@"?"],
+ nil] retain];
+ TKMenu *helpMenu = [TKMenu menuWithTitle:@"Help" menuItems:
+ _defaultHelpMenuItems];
+ [self setServicesMenu:_servicesMenu];
+ [self setWindowsMenu:windowsMenu];
+ _defaultMainMenu = [[TKMenu menuWithTitle:@"" submenus:[NSArray
+ arrayWithObjects:_defaultApplicationMenu, fileMenu, editMenu,
+ windowsMenu, helpMenu, nil]] retain];
+ [_defaultMainMenu setSpecial:tkMainMenu];
+ [_defaultApplicationMenu setSpecial:tkApplicationMenu];
+ [windowsMenu setSpecial:tkWindowsMenu];
+ [helpMenu setSpecial:tkHelpMenu];
+ [self tkSetMainMenu:nil];
+}
+- (void)dealloc {
+ [_defaultMainMenu release];
+ [_defaultHelpMenuItems release];
+ [_defaultWindowsMenuItems release];
+ [_defaultApplicationMenuItems release];
+ [super dealloc];
+}
+- (BOOL)validateUserInterfaceItem:(id <NSValidatedUserInterfaceItem>)anItem {
+ SEL action = [anItem action];
-#define EDIT_CUT 1
-#define EDIT_COPY 2
-#define EDIT_PASTE 3
-#define EDIT_CLEAR 4
+ if (sel_isEqual(action, @selector(preferences:))) {
+ Tcl_CmdInfo dummy;
+ return (_eventInterp && Tcl_GetCommandInfo(_eventInterp,
+ "::tk::mac::ShowPreferences", &dummy));
+ } else if (sel_isEqual(action, @selector(tkDemo:))) {
+ BOOL haveDemo = NO;
+ if (_eventInterp) {
+ Tcl_Obj *path = GetWidgetDemoPath(_eventInterp);
-MenuRef tkAppleMenu;
-MenuRef tkFileMenu;
-MenuRef tkEditMenu;
+ if (path) {
+ Tcl_IncrRefCount(path);
+ haveDemo = (Tcl_FSAccess(path, R_OK) == 0);
+ Tcl_DecrRefCount(path);
+ }
+ }
+ return haveDemo;
+ } else {
+ return [super validateUserInterfaceItem:anItem];
+ }
+}
+- (void)orderFrontStandardAboutPanel:(id)sender {
+ Tcl_CmdInfo dummy;
+ if (!_eventInterp || !Tcl_GetCommandInfo(_eventInterp, "tkAboutDialog",
+ &dummy) || (GetCurrentEventKeyModifiers() & optionKey)) {
+ TkAboutDlg();
+ } else {
+ int code = Tcl_EvalEx(_eventInterp, "tkAboutDialog", -1,
+ TCL_EVAL_GLOBAL);
+ if (code != TCL_OK) {
+ Tcl_BackgroundError(_eventInterp);
+ }
+ Tcl_ResetResult(_eventInterp);
+ }
+}
+- (void)showHelp:(id)sender {
+ Tcl_CmdInfo dummy;
+ if (!_eventInterp || !Tcl_GetCommandInfo(_eventInterp,
+ "::tk::mac::ShowHelp", &dummy)) {
+ [super showHelp:sender];
+ } else {
+ int code = Tcl_EvalEx(_eventInterp, "::tk::mac::ShowHelp", -1,
+ TCL_EVAL_GLOBAL);
+ if (code != TCL_OK) {
+ Tcl_BackgroundError(_eventInterp);
+ }
+ Tcl_ResetResult(_eventInterp);
+ }
+}
+- (void)tkSource:(id)sender {
+ if (_eventInterp) {
+ if (Tcl_EvalEx(_eventInterp, "tk_getOpenFile -filetypes {"
+ "{{TCL Scripts} {.tcl} TEXT} {{Text Files} {} TEXT}}",
+ -1, TCL_EVAL_GLOBAL) == TCL_OK) {
+ Tcl_Obj *path = Tcl_GetObjResult(_eventInterp);
+ int len;
+ Tcl_GetStringFromObj(path, &len);
+ if (len) {
+ Tcl_IncrRefCount(path);
+ int code = Tcl_FSEvalFile(_eventInterp, path);
+ if (code != TCL_OK) {
+ Tcl_BackgroundError(_eventInterp);
+ }
+ Tcl_DecrRefCount(path);
+ }
+ }
+ Tcl_ResetResult(_eventInterp);
+ }
+}
+- (void)tkDemo:(id)sender {
+ if (_eventInterp) {
+ Tcl_Obj *path = GetWidgetDemoPath(_eventInterp);
+ if (path) {
+ Tcl_IncrRefCount(path);
+ int code = Tcl_FSEvalFile(_eventInterp, path);
+ if (code != TCL_OK) {
+ Tcl_BackgroundError(_eventInterp);
+ }
+ Tcl_DecrRefCount(path);
+ Tcl_ResetResult(_eventInterp);
+ }
+ }
+}
+@end
-static Tcl_Interp * gInterp = NULL; /* Standard menu interpreter. */
-static EventHandlerRef menuEventHandlerRef = NULL;
+#pragma mark TKContentView(TKMenus)
-static void GenerateEditEvent(int flag);
-static Tcl_Obj* GetWidgetDemoPath(Tcl_Interp *interp);
-static OSStatus MenuEventHandlerProc(EventHandlerCallRef callRef,
- EventRef event, void *userData);
+@implementation TKContentView(TKMenus)
+- (BOOL)validateUserInterfaceItem:(id <NSValidatedUserInterfaceItem>)anItem {
+ return YES;
+}
+#define EDIT_ACTION(a, e) \
+ - (void) a:(id)sender { \
+ if ([sender isKindOfClass:[NSMenuItem class]]) { \
+ GenerateEditEvent(#e); \
+ } \
+ }
+EDIT_ACTION(cut, Cut)
+EDIT_ACTION(copy, Copy)
+EDIT_ACTION(paste, Paste)
+EDIT_ACTION(delete, Clear)
+EDIT_ACTION(undo, Undo)
+EDIT_ACTION(redo, Redo)
+#undef EDIT_ACTION
+@end
+#pragma mark -
/*
*----------------------------------------------------------------------
@@ -57,20 +254,22 @@ static OSStatus MenuEventHandlerProc(EventHandlerCallRef callRef,
*----------------------------------------------------------------------
*/
-Tcl_Obj*
+static Tcl_Obj *
GetWidgetDemoPath(
Tcl_Interp *interp)
{
- Tcl_Obj *libpath , *result = NULL;
+ Tcl_Obj *libpath, *result = NULL;
- libpath = Tcl_GetVar2Ex(gInterp, "tk_library", NULL, TCL_GLOBAL_ONLY);
+ libpath = Tcl_GetVar2Ex(interp, "tk_library", NULL, TCL_GLOBAL_ONLY);
if (libpath) {
Tcl_Obj *demo[2] = { Tcl_NewStringObj("demos", 5),
Tcl_NewStringObj("widget", 6) };
-
+
Tcl_IncrRefCount(libpath);
result = Tcl_FSJoinToPath(libpath, 2, demo);
Tcl_DecrRefCount(libpath);
+ } else {
+ Tcl_ResetResult(interp);
}
return result;
}
@@ -93,151 +292,11 @@ GetWidgetDemoPath(
void
TkMacOSXHandleMenuSelect(
- MenuID theMenu,
- MenuItemIndex theItem,
+ short theMenu,
+ unsigned short theItem,
int optionKeyPressed)
{
- Tk_Window tkwin;
- Window window;
- TkDisplay *dispPtr;
-
- if (theItem == 0) {
- TkMacOSXClearMenubarActive();
- return;
- }
-
- switch (theMenu) {
- case kAppleMenu:
- switch (theItem) {
- case kAppleAboutItem:
- {
- Tcl_CmdInfo dummy;
- if (optionKeyPressed || gInterp == NULL ||
- Tcl_GetCommandInfo(gInterp,
- "tkAboutDialog", &dummy) == 0) {
- TkAboutDlg();
- } else {
- if (Tcl_EvalEx(gInterp, "tkAboutDialog", -1,
- TCL_EVAL_GLOBAL) != TCL_OK) {
- Tcl_BackgroundError(gInterp);
- }
- Tcl_ResetResult(gInterp);
- }
- break;
- }
- }
- break;
- case kFileMenu:
- switch (theItem) {
- case kSourceItem:
- if (gInterp) {
- if(Tcl_EvalEx(gInterp, "tk_getOpenFile -filetypes {"
- "{{TCL Scripts} {.tcl} TEXT} "
- "{{Text Files} {} TEXT}}", -1, TCL_EVAL_GLOBAL)
- == TCL_OK) {
- Tcl_Obj *path = Tcl_GetObjResult(gInterp);
- int len;
-
- Tcl_GetStringFromObj(path, &len);
- if (len) {
- Tcl_IncrRefCount(path);
- if (Tcl_FSEvalFile(gInterp, path)
- == TCL_ERROR) {
- Tcl_BackgroundError(gInterp);
- }
- Tcl_DecrRefCount(path);
- }
- }
- Tcl_ResetResult(gInterp);
- }
- break;
- case kDemoItem:
- if (gInterp) {
- Tcl_Obj *path = GetWidgetDemoPath(gInterp);
-
- if (path) {
- Tcl_IncrRefCount(path);
- if (Tcl_FSEvalFile(gInterp, path)
- == TCL_ERROR) {
- Tcl_BackgroundError(gInterp);
- }
- Tcl_DecrRefCount(path);
- Tcl_ResetResult(gInterp);
- }
- }
- break;
- case kCloseItem:
- /* Send close event */
- window = TkMacOSXGetXWindow(ActiveNonFloatingWindow());
- dispPtr = TkGetDisplayList();
- tkwin = Tk_IdToWindow(dispPtr->display, window);
- TkGenWMDestroyEvent(tkwin);
- break;
- }
- break;
- case kEditMenu:
- /*
- * This implementation just send the keysyms Tk thinks are
- * associated with function keys that do Cut, Copy & Paste on
- * a Sun keyboard.
- */
- GenerateEditEvent(theItem);
- break;
- default:
- TkMacOSXDispatchMenuEvent(theMenu, theItem);
- break;
- }
- /*
- * Finally we unhighlight the menu.
- */
- HiliteMenu(0);
-}
-
-/*
- *----------------------------------------------------------------------
- *
- * MenuEventHandlerProc --
- *
- * One-time handler of kEventMenuEnableItems for the edit menu.
- *
- * Results:
- * OS status code.
- *
- * Side effects:
- * None.
- *
- *----------------------------------------------------------------------
- */
-
-static OSStatus
-MenuEventHandlerProc(
- EventHandlerCallRef callRef,
- EventRef event,
- void *userData)
-{
- OSStatus result = eventNotHandledErr, err;
- int menuContext;
-
- err = ChkErr(GetEventParameter, event, kEventParamMenuContext, typeUInt32,
- NULL, sizeof(menuContext), NULL, &menuContext);
- if (err == noErr && (menuContext & kMenuContextMenuBarTracking)) {
- if (gInterp) {
- Tcl_Obj *path = GetWidgetDemoPath(gInterp);
-
- if (path) {
- Tcl_IncrRefCount(path);
- if (Tcl_FSAccess(path, R_OK) == 0) {
- EnableMenuItem(tkFileMenu, kDemoItem);
- }
- Tcl_DecrRefCount(path);
- }
- }
- ChkErr(RemoveEventHandler, menuEventHandlerRef);
- menuEventHandlerRef = NULL;
- result = noErr;
- }
-
- return result;
+ Tcl_Panic("TkMacOSXHandleMenuSelect: Obsolete, no more Carbon!");
}
/*
@@ -260,75 +319,7 @@ void
TkMacOSXInitMenus(
Tcl_Interp *interp)
{
- OSStatus err;
- EventHandlerUPP menuEventHandlerUPP;
- const EventTypeSpec menuEventTypes[] = {
- {kEventClassMenu, kEventMenuEnableItems},
- };
-
- gInterp = interp;
- if (TkMacOSXUseMenuID(kAppleMenu) != TCL_OK) {
- Tcl_Panic("Menu ID %d is already in use!", kAppleMenu);
- }
- err = ChkErr(CreateNewMenu, kAppleMenu, kMenuAttrDoNotUseUserCommandKeys,
- &tkAppleMenu);
- if (err != noErr) {
- Tcl_Panic("CreateNewMenu failed !");
- }
- SetMenuTitle(tkAppleMenu, "\p\024");
- InsertMenu(tkAppleMenu, 0);
- AppendMenu(tkAppleMenu, "\pAbout Tcl & Tk\xc9");
- AppendMenu(tkAppleMenu, "\p(-");
-
- if (TkMacOSXUseMenuID(kFileMenu) != TCL_OK) {
- Tcl_Panic("Menu ID %d is already in use!", kFileMenu);
- }
- err = ChkErr(CreateNewMenu, kFileMenu, kMenuAttrDoNotUseUserCommandKeys,
- &tkFileMenu);
- if (err != noErr) {
- Tcl_Panic("CreateNewMenu failed !");
- }
- SetMenuTitle(tkFileMenu, "\pFile");
- InsertMenu(tkFileMenu, 0);
- InsertMenuItem(tkFileMenu, "\pSource\xc9", kSourceItem - 1);
- InsertMenuItem(tkFileMenu, "\pRun Widget Demo", kDemoItem - 1);
- InsertMenuItem(tkFileMenu, "\pClose/W", kCloseItem - 1);
- DisableMenuItem(tkFileMenu, kDemoItem);
- menuEventHandlerUPP = NewEventHandlerUPP(MenuEventHandlerProc);
- ChkErr(InstallEventHandler, GetMenuEventTarget(tkFileMenu),
- menuEventHandlerUPP, GetEventTypeCount(menuEventTypes),
- menuEventTypes, NULL, &menuEventHandlerRef);
- DisposeEventHandlerUPP(menuEventHandlerUPP);
-
- if (TkMacOSXUseMenuID(kEditMenu) != TCL_OK) {
- Tcl_Panic("Menu ID %d is already in use!", kEditMenu);
- }
- err = ChkErr(CreateNewMenu, kEditMenu, kMenuAttrDoNotUseUserCommandKeys,
- &tkEditMenu);
- if (err != noErr) {
- Tcl_Panic("CreateNewMenu failed !");
- }
- SetMenuTitle(tkEditMenu, "\pEdit");
- InsertMenu(tkEditMenu, 0);
- AppendMenu(tkEditMenu, "\pCut/X");
- AppendMenu(tkEditMenu, "\pCopy/C");
- AppendMenu(tkEditMenu, "\pPaste/V");
- AppendMenu(tkEditMenu, "\pClear");
- if (TkMacOSXUseMenuID(kHMHelpMenuID) != TCL_OK) {
- Tcl_Panic("Help menu ID %s is already in use!", kHMHelpMenuID);
- }
-
- /*
- * Workaround a Carbon bug with kHICommandPreferences: the first call to
- * IsMenuKeyEvent returns false for the preferences menu item key shorcut
- * event (even if the corresponding menu item is dynamically enabled by a
- * kEventCommandUpdateStatus handler), unless the kHICommandPreferences
- * menu item has previously been enabled manually. [Bug 1481503]
- */
- EnableMenuCommand(NULL, kHICommandPreferences);
-
- DrawMenuBar();
- return;
+ [NSApp _setupMenus];
}
/*
@@ -336,8 +327,8 @@ TkMacOSXInitMenus(
*
* GenerateEditEvent --
*
- * Takes an edit menu item and posts the corasponding a virtual
- * event to Tk's event queue.
+ * Takes an edit menu item and posts the corasponding a virtual event to
+ * Tk's event queue.
*
* Results:
* None.
@@ -350,50 +341,133 @@ TkMacOSXInitMenus(
static void
GenerateEditEvent(
- int flag)
+ const char *name)
{
XVirtualEvent event;
int x, y;
- Tk_Window tkwin;
- Window window;
- TkDisplay *dispPtr;
+ TkWindow *winPtr = TkMacOSXGetTkWindow([NSApp keyWindow]);
+ Tk_Window tkwin = (Tk_Window) winPtr;
- window = TkMacOSXGetXWindow(ActiveNonFloatingWindow());
- dispPtr = TkGetDisplayList();
- tkwin = Tk_IdToWindow(dispPtr->display, window);
- tkwin = (Tk_Window) ((TkWindow *) tkwin)->dispPtr->focusPtr;
if (tkwin == NULL) {
return;
}
-
+ tkwin = (Tk_Window) winPtr->dispPtr->focusPtr;
+ if (tkwin == NULL) {
+ return;
+ }
bzero(&event, sizeof(XVirtualEvent));
event.type = VirtualEvent;
- event.serial = Tk_Display(tkwin)->request;
+ event.serial = LastKnownRequestProcessed(Tk_Display(tkwin));
event.send_event = false;
event.display = Tk_Display(tkwin);
event.event = Tk_WindowId(tkwin);
event.root = XRootWindow(Tk_Display(tkwin), 0);
event.subwindow = None;
event.time = TkpGetMS();
-
- XQueryPointer(NULL, None, NULL, NULL,
+ XQueryPointer(NULL, winPtr->window, NULL, NULL,
&event.x_root, &event.y_root, &x, &y, &event.state);
- tkwin = Tk_TopCoordsToWindow(tkwin, x, y, &event.x, &event.y);
+ Tk_TopCoordsToWindow(tkwin, x, y, &event.x, &event.y);
event.same_screen = true;
+ event.name = Tk_GetUid(name);
+ Tk_QueueWindowEvent((XEvent *) &event, TCL_QUEUE_TAIL);
+}
- switch (flag) {
- case EDIT_CUT:
- event.name = Tk_GetUid("Cut");
- break;
- case EDIT_COPY:
- event.name = Tk_GetUid("Copy");
- break;
- case EDIT_PASTE:
- event.name = Tk_GetUid("Paste");
- break;
- case EDIT_CLEAR:
- event.name = Tk_GetUid("Clear");
- break;
+#pragma mark -
+#pragma mark NSMenu & NSMenuItem Utilities
+
+@implementation NSMenu(TKUtils)
++ (id)menuWithTitle:(NSString *)title {
+ NSMenu *m = [[self alloc] initWithTitle:title];
+ return [m autorelease];
+}
++ (id)menuWithTitle:(NSString *)title menuItems:(NSArray *)items {
+ NSMenu *m = [[self alloc] initWithTitle:title];
+ for (NSMenuItem *i in items) {
+ [m addItem:i];
}
- Tk_QueueWindowEvent((XEvent *) &event, TCL_QUEUE_TAIL);
+ return [m autorelease];
+}
++ (id)menuWithTitle:(NSString *)title submenus:(NSArray *)submenus {
+ NSMenu *m = [[self alloc] initWithTitle:title];
+ for (NSMenu *i in submenus) {
+ [m addItem:[NSMenuItem itemWithSubmenu:i]];
+ }
+ return [m autorelease];
+}
+- (NSMenuItem *)itemWithSubmenu:(NSMenu *)submenu {
+ return [self itemAtIndex:[self indexOfItemWithSubmenu:submenu]];
}
+- (NSMenuItem *)itemInSupermenu {
+ NSMenu *supermenu = [self supermenu];
+ return (supermenu ? [supermenu itemWithSubmenu:self] : nil);
+}
+@end
+
+@implementation NSMenuItem(TKUtils)
++ (id)itemWithSubmenu:(NSMenu *)submenu {
+ NSMenuItem *i = [[self alloc] initWithTitle:[submenu title] action:NULL
+ keyEquivalent:@""];
+ [i setSubmenu:submenu];
+ return [i autorelease];
+}
++ (id)itemWithTitle:(NSString *)title submenu:(NSMenu *)submenu {
+ NSMenuItem *i = [[self alloc] initWithTitle:title action:NULL
+ keyEquivalent:@""];
+ [i setSubmenu:submenu];
+ return [i autorelease];
+}
++ (id)itemWithTitle:(NSString *)title action:(SEL)action {
+ NSMenuItem *i = [[self alloc] initWithTitle:title action:action
+ keyEquivalent:@""];
+ [i setTarget:NSApp];
+ return [i autorelease];
+}
++ (id)itemWithTitle:(NSString *)title action:(SEL)action
+ target:(id)target {
+ NSMenuItem *i = [[self alloc] initWithTitle:title action:action
+ keyEquivalent:@""];
+ [i setTarget:target];
+ return [i autorelease];
+}
++ (id)itemWithTitle:(NSString *)title action:(SEL)action
+ keyEquivalent:(NSString *)keyEquivalent {
+ NSMenuItem *i = [[self alloc] initWithTitle:title action:action
+ keyEquivalent:keyEquivalent];
+ [i setTarget:NSApp];
+ return [i autorelease];
+}
++ (id)itemWithTitle:(NSString *)title action:(SEL)action
+ target:(id)target keyEquivalent:(NSString *)keyEquivalent {
+ NSMenuItem *i = [[self alloc] initWithTitle:title action:action
+ keyEquivalent:keyEquivalent];
+ [i setTarget:target];
+ return [i autorelease];
+}
++ (id)itemWithTitle:(NSString *)title action:(SEL)action
+ keyEquivalent:(NSString *)keyEquivalent
+ keyEquivalentModifierMask:(NSUInteger)keyEquivalentModifierMask {
+ NSMenuItem *i = [[self alloc] initWithTitle:title action:action
+ keyEquivalent:keyEquivalent];
+ [i setTarget:NSApp];
+ [i setKeyEquivalentModifierMask:keyEquivalentModifierMask];
+ return [i autorelease];
+}
++ (id)itemWithTitle:(NSString *)title action:(SEL)action
+ target:(id)target keyEquivalent:(NSString *)keyEquivalent
+ keyEquivalentModifierMask:(NSUInteger)keyEquivalentModifierMask {
+ NSMenuItem *i = [[self alloc] initWithTitle:title action:action
+ keyEquivalent:keyEquivalent];
+ [i setTarget:target];
+ [i setKeyEquivalentModifierMask:keyEquivalentModifierMask];
+ return [i autorelease];
+}
+@end
+
+/*
+ * Local Variables:
+ * mode: c
+ * c-basic-offset: 4
+ * fill-column: 79
+ * coding: utf-8
+ * End:
+ */
diff --git a/macosx/tkMacOSXMouseEvent.c b/macosx/tkMacOSXMouseEvent.c
index 46398f6..f57c184 100644
--- a/macosx/tkMacOSXMouseEvent.c
+++ b/macosx/tkMacOSXMouseEvent.c
@@ -1,58 +1,16 @@
/*
* tkMacOSXMouseEvent.c --
*
- * This file implements functions that decode & handle mouse events
- * on MacOS X.
+ * This file implements functions that decode & handle mouse events on
+ * MacOS X.
*
- * Copyright 2001, Apple Computer, Inc.
- * Copyright (c) 2005-2007 Daniel A. Steffen <das@users.sourceforge.net>
+ * Copyright 2001-2009, Apple Inc.
+ * Copyright (c) 2005-2009 Daniel A. Steffen <das@users.sourceforge.net>
*
* See the file "license.terms" for information on usage and redistribution of
* this file, and for a DISCLAIMER OF ALL WARRANTIES.
*
- * The following terms apply to all files originating from Apple
- * Computer, Inc. ("Apple") and associated with the software
- * unless explicitly disclaimed in individual files.
- *
- *
- * Apple hereby grants permission to use, copy, modify,
- * distribute, and license this software and its documentation
- * for any purpose, provided that existing copyright notices are
- * retained in all copies and that this notice is included
- * verbatim in any distributions. No written agreement, license,
- * or royalty fee is required for any of the authorized
- * uses. Modifications to this software may be copyrighted by
- * their authors and need not follow the licensing terms
- * described here, provided that the new terms are clearly
- * indicated on the first page of each file where they apply.
- *
- *
- * IN NO EVENT SHALL APPLE, THE AUTHORS OR DISTRIBUTORS OF THE
- * SOFTWARE BE LIABLE TO ANY PARTY FOR DIRECT, INDIRECT, SPECIAL,
- * INCIDENTAL, OR CONSEQUENTIAL DAMAGES ARISING OUT OF THE USE OF
- * THIS SOFTWARE, ITS DOCUMENTATION, OR ANY DERIVATIVES THEREOF,
- * EVEN IF APPLE OR THE AUTHORS HAVE BEEN ADVISED OF THE
- * POSSIBILITY OF SUCH DAMAGE. APPLE, THE AUTHORS AND
- * DISTRIBUTORS SPECIFICALLY DISCLAIM ANY WARRANTIES, INCLUDING,
- * BUT NOT LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY,
- * FITNESS FOR A PARTICULAR PURPOSE, AND NON-INFRINGEMENT. THIS
- * SOFTWARE IS PROVIDED ON AN "AS IS" BASIS, AND APPLE,THE
- * AUTHORS AND DISTRIBUTORS HAVE NO OBLIGATION TO PROVIDE
- * MAINTENANCE, SUPPORT, UPDATES, ENHANCEMENTS, OR MODIFICATIONS.
- *
- * GOVERNMENT USE: If you are acquiring this software on behalf
- * of the U.S. government, the Government shall have only
- * "Restricted Rights" in the software and related documentation
- * as defined in the Federal Acquisition Regulations (FARs) in
- * Clause 52.227.19 (c) (2). If you are acquiring the software
- * on behalf of the Department of Defense, the software shall be
- * classified as "Commercial Computer Software" and the
- * Government shall have only "Restricted Rights" as defined in
- * Clause 252.227-7013 (c) (1) of DFARs. Notwithstanding the
- * foregoing, the authors grant the U.S. Government and others
- * acting in its behalf permission to use and distribute the
- * software in accordance with the terms specified in this
- * license.
+ * RCS: @(#) $Id$
*/
#include "tkMacOSXPrivate.h"
@@ -61,698 +19,198 @@
#include "tkMacOSXDebug.h"
typedef struct {
- WindowRef whichWin;
- WindowRef activeNonFloating;
- WindowPartCode windowPart;
- unsigned int state;
- long delta;
- Window window;
- Point global;
- Point local;
+ unsigned int state;
+ long delta;
+ Window window;
+ Point global;
+ Point local;
} MouseEventData;
-/*
- * Declarations of static variables used in this file.
- */
+static int GenerateButtonEvent(MouseEventData *medPtr);
+static unsigned int ButtonModifiers2State(UInt32 buttonState,
+ UInt32 keyModifiers);
-static int gEatButtonUp = 0; /* 1 if we need to eat the next up event */
+#pragma mark TKApplication(TKMouseEvent)
-/*
- * Declarations of functions used only in this file.
- */
+enum {
+ NSWindowWillMoveEventType = 20
+};
-static void BringWindowForward(WindowRef wRef, int isFrontProcess,
- int frontWindowOnly);
-static int GeneratePollingEvents(MouseEventData * medPtr);
-static int GenerateMouseWheelEvent(MouseEventData * medPtr);
-static int GenerateButtonEvent(MouseEventData * medPtr);
-static int GenerateToolbarButtonEvent(MouseEventData * medPtr);
-static int HandleWindowTitlebarMouseDown(MouseEventData * medPtr, Tk_Window tkwin);
-static unsigned int ButtonModifiers2State(UInt32 buttonState, UInt32 keyModifiers);
-static Tk_Window GetGrabWindowForWindow(Tk_Window tkwin);
+@implementation TKApplication(TKMouseEvent)
+- (NSEvent *)tkProcessMouseEvent:(NSEvent *)theEvent {
+#ifdef TK_MAC_DEBUG_EVENTS
+ TKLog(@"-[%@(%p) %s] %@", [self class], self, _cmd, theEvent);
+#endif
+ id win;
+ NSEventType type = [theEvent type];
+#if 0
+ NSTrackingArea *trackingArea = nil;
+ NSInteger eventNumber, clickCount, buttonNumber;
+#endif
-static int TkMacOSXGetEatButtonUp(void);
-static void TkMacOSXSetEatButtonUp(int f);
+ switch (type) {
+ case NSMouseEntered:
+ case NSMouseExited:
+ case NSCursorUpdate:
+#if 0
+ trackingArea = [theEvent trackingArea];
+#endif
+ /* fall through */
+ case NSLeftMouseDown:
+ case NSLeftMouseUp:
+ case NSRightMouseDown:
+ case NSRightMouseUp:
+ case NSOtherMouseDown:
+ case NSOtherMouseUp:
+
+ case NSLeftMouseDragged:
+ case NSRightMouseDragged:
+ case NSOtherMouseDragged:
+
+ case NSMouseMoved:
+#if 0
+ eventNumber = [theEvent eventNumber];
+ if (!trackingArea) {
+ clickCount = [theEvent clickCount];
+ buttonNumber = [theEvent buttonNumber];
+ }
+#endif
-
-/*
- *----------------------------------------------------------------------
- *
- * TkMacOSXProcessMouseEvent --
- *
- * This routine processes the event in eventPtr, and
- * generates the appropriate Tk events from it.
- *
- * Results:
- * True if event(s) are generated - false otherwise.
- *
- * Side effects:
- * Additional events may be place on the Tk event queue.
- *
- *----------------------------------------------------------------------
- */
+ case NSTabletPoint:
+ case NSTabletProximity:
-MODULE_SCOPE int
-TkMacOSXProcessMouseEvent(TkMacOSXEvent *eventPtr, MacEventStatus * statusPtr)
-{
- Tk_Window tkwin;
- Point where, where2;
- int result;
- TkDisplay * dispPtr;
- OSStatus err;
- MouseEventData mouseEventData, * medPtr = &mouseEventData;
- int isFrontProcess;
+ case NSScrollWheel:
+ win = [self windowWithWindowNumber:[theEvent windowNumber]];
+ break;
- switch (eventPtr->eKind) {
- case kEventMouseDown:
- case kEventMouseUp:
- case kEventMouseMoved:
- case kEventMouseDragged:
- case kEventMouseWheelMoved:
- break;
- default:
- return false;
- break;
- }
- err = ChkErr(GetEventParameter, eventPtr->eventRef,
- kEventParamMouseLocation,
- typeQDPoint, NULL,
- sizeof(where), NULL,
- &where);
- if (err != noErr) {
- GetGlobalMouse(&where);
- }
- err = ChkErr(GetEventParameter, eventPtr->eventRef,
- kEventParamWindowRef,
- typeWindowRef, NULL,
- sizeof(WindowRef), NULL,
- &medPtr->whichWin);
- if (err == noErr) {
- err = ChkErr(GetEventParameter, eventPtr->eventRef,
- kEventParamWindowPartCode,
- typeWindowPartCode, NULL,
- sizeof(WindowPartCode), NULL,
- &medPtr->windowPart);
- }
- if (err != noErr) {
- medPtr->windowPart = FindWindow(where, &medPtr->whichWin);
+ default:
+ return theEvent;
+ break;
}
- medPtr->window = TkMacOSXGetXWindow(medPtr->whichWin);
- if (medPtr->whichWin != NULL && medPtr->window == None) {
- return false;
+
+ NSPoint global, local = [theEvent locationInWindow];
+ if (win) {
+ global = [win convertBaseToScreen:local];
+ local.y = [win frame].size.height - local.y;
+ global.y = tkMacOSXZeroScreenHeight - global.y;
+ } else {
+ local.y = tkMacOSXZeroScreenHeight - local.y;
+ global = local;
}
- if (eventPtr->eKind == kEventMouseDown) {
- if (IsWindowActive(medPtr->whichWin) && IsWindowPathSelectEvent(
- medPtr->whichWin, eventPtr->eventRef)) {
- ChkErr(WindowPathSelect, medPtr->whichWin, NULL, NULL);
- return false;
- }
- if (medPtr->windowPart == inProxyIcon) {
- TkMacOSXTrackingLoop(1);
- err = ChkErr(TrackWindowProxyDrag, medPtr->whichWin, where);
- TkMacOSXTrackingLoop(0);
- if (err == errUserWantsToDragWindow) {
- medPtr->windowPart = inDrag;
- } else {
- return false;
- }
- }
+
+ Window window = TkMacOSXGetXWindow(win);
+ Tk_Window tkwin = window ? Tk_IdToWindow(TkGetDisplayList()->display,
+ window) : NULL;
+ if (!tkwin) {
+ tkwin = TkMacOSXGetCapture();
}
- isFrontProcess = Tk_MacOSXIsAppInFront();
- if (isFrontProcess) {
- medPtr->state = ButtonModifiers2State(GetCurrentEventButtonState(),
- GetCurrentEventKeyModifiers());
- } else {
- medPtr->state = ButtonModifiers2State(GetCurrentButtonState(),
- GetCurrentKeyModifiers());
+ if (!tkwin) {
+ return theEvent;
}
- medPtr->global = where;
- err = ChkErr(GetEventParameter, eventPtr->eventRef,
- kEventParamWindowMouseLocation,
- typeQDPoint, NULL,
- sizeof(Point), NULL,
- &medPtr->local);
+
+ /*
+ MacDrawable *macWin = (MacDrawable *) window;
+ NSView *view = TkMacOSXDrawableView(macWin);
+ local = [view convertPoint:local fromView:nil];
+ local.y = NSHeight([view bounds]) - local.y;
+ */
+ TkWindow *winPtr = (TkWindow *) tkwin;
+ local.x -= winPtr->wmInfoPtr->xInParent;
+ local.y -= winPtr->wmInfoPtr->yInParent;
+
+ int win_x, win_y;
+ tkwin = Tk_TopCoordsToWindow(tkwin, local.x, local.y,
+ &win_x, &win_y);
+
+ unsigned int state = 0;
+ NSInteger button = [theEvent buttonNumber];
+ EventRef eventRef = (EventRef)[theEvent eventRef];
+ UInt32 buttons;
+ OSStatus err = GetEventParameter(eventRef, kEventParamMouseChord,
+ typeUInt32, NULL, sizeof(UInt32), NULL, &buttons);
if (err == noErr) {
- if (medPtr->whichWin) {
- Rect widths;
- GetWindowStructureWidths(medPtr->whichWin, &widths);
- medPtr->local.h -= widths.left;
- medPtr->local.v -= widths.top;
- }
+ state |= (buttons & ((1<<5) - 1)) << 8;
} else {
- medPtr->local = where;
- if (medPtr->whichWin) {
- QDGlobalToLocalPoint(GetWindowPort(medPtr->whichWin),
- &medPtr->local);
- }
- }
- medPtr->activeNonFloating = ActiveNonFloatingWindow();
- dispPtr = TkGetDisplayList();
- tkwin = Tk_IdToWindow(dispPtr->display, medPtr->window);
-
- if (eventPtr->eKind != kEventMouseDown) {
- int res = false;
-
- switch (eventPtr->eKind) {
- case kEventMouseUp:
- /*
- * The window manager only needs to know about mouse down
- * events and sometimes we need to "eat" the mouse up.
- * Otherwise, we just pass the event to Tk.
- */
- if (TkMacOSXGetEatButtonUp()) {
- TkMacOSXSetEatButtonUp(false);
- } else {
- res = GenerateButtonEvent(medPtr);
- }
- break;
- case kEventMouseWheelMoved:
- err = ChkErr(GetEventParameter, eventPtr->eventRef,
- kEventParamMouseWheelDelta, typeLongInteger, NULL,
- sizeof(long), NULL, &medPtr->delta);
- if (err != noErr ) {
- statusPtr->err = 1;
- } else {
- EventMouseWheelAxis axis;
- err = ChkErr(GetEventParameter, eventPtr->eventRef,
- kEventParamMouseWheelAxis, typeMouseWheelAxis,
- NULL, sizeof(EventMouseWheelAxis), NULL, &axis);
- if (err == noErr && axis == kEventMouseWheelAxisX) {
- medPtr->state |= ShiftMask;
- }
- res = GenerateMouseWheelEvent(medPtr);
- }
- break;
- case kEventMouseMoved:
- case kEventMouseDragged:
- res = GeneratePollingEvents(medPtr);
+ if (button < 5) {
+ switch (type) {
+ case NSLeftMouseDown:
+ case NSRightMouseDown:
+ case NSLeftMouseDragged:
+ case NSRightMouseDragged:
+ case NSOtherMouseDown:
+ state |= 1 << (button + 8);
break;
default:
- Tcl_Panic("Unknown mouse event !");
- }
- if (res) {
- statusPtr->stopProcessing = 1;
- }
- return res;
- }
- TkMacOSXSetEatButtonUp(false);
- if (medPtr->whichWin) {
- /*
- * We got a mouse down in a window
- * See if this is the activate click
- * This click moves the window forward. We don't want
- * the corresponding mouse-up to be reported to the application
- * or else it will mess up some Tk scripts.
- */
-
- if (!(TkpIsWindowFloating(medPtr->whichWin))
- && (medPtr->whichWin != medPtr->activeNonFloating
- || !isFrontProcess)) {
- int frontWindowOnly = 1;
- int cmdDragGrow = ((medPtr->windowPart == inDrag ||
- medPtr->windowPart == inGrow) && medPtr->state & Mod1Mask);
-
- if (!cmdDragGrow) {
- Tk_Window grabWin = GetGrabWindowForWindow(tkwin);
-
- frontWindowOnly = !grabWin;
- if (grabWin && grabWin != tkwin) {
- TkMacOSXSetEatButtonUp(true);
- BringWindowForward(TkMacOSXDrawableWindow(
- ((TkWindow*)grabWin)->window), isFrontProcess,
- frontWindowOnly);
- return false;
- }
- }
-
- /*
- * Clicks in the titlebar widgets are handled without bringing the
- * window forward.
- */
- if ((result = HandleWindowTitlebarMouseDown(medPtr, tkwin)) != -1) {
- statusPtr->stopProcessing = 1;
- return result;
- } else {
- /*
- * Only windows with the kWindowNoActivatesAttribute can
- * receive mouse events in the background.
- */
- if (!(((TkWindow *)tkwin)->wmInfoPtr->attributes &
- kWindowNoActivatesAttribute)) {
- /*
- * Allow background window dragging & growing with Command
- * down.
- */
- if (!cmdDragGrow) {
- TkMacOSXSetEatButtonUp(true);
- BringWindowForward(medPtr->whichWin, isFrontProcess,
- frontWindowOnly);
- }
- /*
- * Allow dragging & growing of windows that were/are in the
- * background.
- */
- if (!(medPtr->windowPart == inDrag ||
- medPtr->windowPart == inGrow)) {
- return false;
- }
- }
- }
- } else {
- if ((result = HandleWindowTitlebarMouseDown(medPtr, tkwin)) != -1) {
- statusPtr->stopProcessing = 1;
- return result;
- }
- }
- switch (medPtr->windowPart) {
- case inDrag: {
- WindowAttributes attributes;
-
- GetWindowAttributes(medPtr->whichWin, &attributes);
- if (!(attributes & kWindowAsyncDragAttribute)) {
- TkMacOSXTrackingLoop(1);
- DragWindow(medPtr->whichWin, where, NULL);
- TkMacOSXTrackingLoop(0);
- where2.h = where2.v = 0;
- QDLocalToGlobalPoint(GetWindowPort(medPtr->whichWin),
- &where2);
- if (EqualPt(where, where2)) {
- return false;
- }
- return true;
- }
break;
}
- case inGrow:
- /*
- * Generally the content region is the domain of Tk
- * sub-windows. However, one exception is the grow
- * region. A button down in this area will be handled
- * by the window manager. Note: this means that Tk
- * may not get button down events in this area!
- */
- if (TkMacOSXGrowToplevel(medPtr->whichWin, where) == true) {
- statusPtr->stopProcessing = 1;
- return true;
- } else {
- return GenerateButtonEvent(medPtr);
- }
- break;
- case inContent:
- return GenerateButtonEvent(medPtr);
- break;
- default:
- return false;
- break;
}
}
- return false;
-}
-
-/*
- *----------------------------------------------------------------------
- *
- * HandleWindowTitlebarMouseDown --
- *
- * Handle clicks in window titlebar.
- *
- * Results:
- * 1 if event was handled, 0 if event was not handled,
- * -1 if MouseDown was not in window titlebar.
- *
- * Side effects:
- * Additional events may be place on the Tk event queue.
- *
- *----------------------------------------------------------------------
- */
-
-int
-HandleWindowTitlebarMouseDown(MouseEventData * medPtr, Tk_Window tkwin)
-{
- int result = INT_MAX;
-
- switch (medPtr->windowPart) {
- case inGoAway:
- case inCollapseBox:
- case inZoomIn:
- case inZoomOut:
- case inToolbarButton:
- if (!IsWindowActive(medPtr->whichWin)) {
- WindowRef frontWindow = FrontNonFloatingWindow();
- WindowModality frontWindowModality = kWindowModalityNone;
+ NSUInteger modifiers = [theEvent modifierFlags];
- if (frontWindow && frontWindow != medPtr->whichWin) {
- ChkErr(GetWindowModality, frontWindow,
- &frontWindowModality, NULL);
- }
- if (frontWindowModality == kWindowModalityAppModal) {
- result = 0;
- }
- }
- break;
- default:
- result = -1;
- break;
+ if (modifiers & NSAlphaShiftKeyMask) {
+ state |= LockMask;
}
-
- if (result == INT_MAX) {
- result = 0;
- TkMacOSXTrackingLoop(1);
- switch (medPtr->windowPart) {
- case inGoAway:
- if (TrackGoAway(medPtr->whichWin, medPtr->global) && tkwin) {
- TkGenWMDestroyEvent(tkwin);
- result = 1;
- }
- break;
- case inCollapseBox:
- if (TrackBox(medPtr->whichWin, medPtr->global,
- medPtr->windowPart) && tkwin) {
- TkpWmSetState((TkWindow *)tkwin, IconicState);
- result = 1;
- }
- break;
- case inZoomIn:
- case inZoomOut:
- if (TrackBox(medPtr->whichWin, medPtr->global,
- medPtr->windowPart)) {
- result = TkMacOSXZoomToplevel(medPtr->whichWin,
- medPtr->windowPart);
- }
- break;
- case inToolbarButton:
- if (TrackBox(medPtr->whichWin, medPtr->global,
- medPtr->windowPart)) {
- result = GenerateToolbarButtonEvent(medPtr);
- }
- break;
- }
- TkMacOSXTrackingLoop(0);
+ if (modifiers & NSShiftKeyMask) {
+ state |= ShiftMask;
}
-
- return result;
-}
-
-/*
- *----------------------------------------------------------------------
- *
- * GeneratePollingEvents --
- *
- * This function polls the mouse position and generates X Motion,
- * Enter & Leave events. The cursor is also updated at this
- * time.
- *
- * Results:
- * True if event(s) are generated - false otherwise.
- *
- * Side effects:
- * Additional events may be place on the Tk event queue.
- * The cursor may be changed.
- *
- *----------------------------------------------------------------------
- */
-
-static int
-GeneratePollingEvents(MouseEventData * medPtr)
-{
- Tk_Window tkwin, rootwin, grabWin;
- int local_x, local_y;
- TkDisplay *dispPtr;
-
-
- grabWin = TkMacOSXGetCapture();
-
- if ((!TkpIsWindowFloating(medPtr->whichWin)
- && (medPtr->activeNonFloating != medPtr->whichWin))) {
- /*
- * If the window for this event is not floating, and is not the
- * active non-floating window, don't generate polling events.
- * We don't send events to backgrounded windows. So either send
- * it to the grabWin, or NULL if there is no grabWin.
- */
-
- tkwin = grabWin;
- } else {
- /*
- * First check whether the toplevel containing this mouse
- * event is the grab window. If not, then send the event
- * to the grab window. Otherwise, set tkWin to the subwindow
- * which most closely contains the mouse event.
- */
-
- dispPtr = TkGetDisplayList();
- rootwin = Tk_IdToWindow(dispPtr->display, medPtr->window);
- if ((rootwin == NULL)
- || ((grabWin != NULL) && (rootwin != grabWin))) {
- tkwin = grabWin;
- } else {
- tkwin = Tk_TopCoordsToWindow(rootwin,
- medPtr->local.h, medPtr->local.v,
- &local_x, &local_y);
- }
+ if (modifiers & NSControlKeyMask) {
+ state |= ControlMask;
}
-
- /*
- * The following call will generate the appropiate X events and
- * adjust any state that Tk must remember.
- */
-
- Tk_UpdatePointer(tkwin, medPtr->global.h, medPtr->global.v,
- medPtr->state);
-
- return true;
-}
-
-/*
- *----------------------------------------------------------------------
- *
- * BringWindowForward --
- *
- * Bring this background window to the front.
- *
- * Results:
- * None.
- *
- * Side effects:
- * The window is brought forward.
- *
- *----------------------------------------------------------------------
- */
-
-static void
-BringWindowForward(
- WindowRef wRef,
- int isFrontProcess,
- int frontWindowOnly)
-{
- if (wRef && !TkpIsWindowFloating(wRef) && IsValidWindowPtr(wRef)) {
- WindowRef frontWindow = FrontNonFloatingWindow();
- WindowModality frontWindowModality = kWindowModalityNone;
-
- if (frontWindow && frontWindow != wRef) {
- ChkErr(GetWindowModality, frontWindow, &frontWindowModality, NULL);
- }
- if (frontWindowModality != kWindowModalityAppModal) {
- Window window = TkMacOSXGetXWindow(wRef);
-
- if (window != None) {
- TkDisplay *dispPtr = TkGetDisplayList();
- TkWindow * winPtr = (TkWindow *)Tk_IdToWindow(dispPtr->display,
- window);
-
- if (winPtr && winPtr->wmInfoPtr &&
- winPtr->wmInfoPtr->master != None) {
- TkWindow *masterWinPtr = (TkWindow *)Tk_IdToWindow(
- dispPtr->display, winPtr->wmInfoPtr->master);
-
- if (masterWinPtr && masterWinPtr->window != None &&
- TkMacOSXHostToplevelExists(masterWinPtr)) {
- WindowRef masterMacWin =
- TkMacOSXDrawableWindow(masterWinPtr->window);
-
- if (masterMacWin) {
- BringToFront(masterMacWin);
- }
- }
- }
- }
- SelectWindow(wRef);
- } else {
- frontWindowOnly = 0;
- }
+ if (modifiers & NSCommandKeyMask) {
+ state |= Mod1Mask; /* command key */
}
- if (!isFrontProcess) {
- ProcessSerialNumber ourPsn = {0, kCurrentProcess};
-
- ChkErr(SetFrontProcessWithOptions, &ourPsn, frontWindowOnly ?
- kSetFrontProcessFrontWindowOnly : 0);
+ if (modifiers & NSAlternateKeyMask) {
+ state |= Mod2Mask; /* option key */
}
-}
-
-/*
- *----------------------------------------------------------------------
- *
- * TkMacOSXBringWindowForward --
- *
- * Bring this window to the front in response to a mouse click. If
- * a grab is in effect, bring the grab window to the front instead.
- *
- * Results:
- * None.
- *
- * Side effects:
- * The window is brought forward.
- *
- *----------------------------------------------------------------------
- */
-
-void
-TkMacOSXBringWindowForward(
- WindowRef wRef)
-{
- TkDisplay *dispPtr = TkGetDisplayList();
- Tk_Window tkwin = Tk_IdToWindow(dispPtr->display,TkMacOSXGetXWindow(wRef));
- Tk_Window grabWin = GetGrabWindowForWindow(tkwin);
-
- if (grabWin && grabWin != tkwin) {
- wRef = TkMacOSXDrawableWindow(((TkWindow*)grabWin)->window);
+ if (modifiers & NSNumericPadKeyMask) {
+ state |= Mod3Mask;
}
- TkMacOSXSetEatButtonUp(true);
- BringWindowForward(wRef, Tk_MacOSXIsAppInFront(), !grabWin);
-}
-
-/*
- *----------------------------------------------------------------------
- *
- * GetGrabWindowForWindow --
- *
- * Get the grab window for the given window, if any.
- *
- * Results:
- * Grab Tk_Window or None.
- *
- * Side effects:
- * None.
- *
- *----------------------------------------------------------------------
- */
-
-Tk_Window
-GetGrabWindowForWindow(
- Tk_Window tkwin)
-{
- Tk_Window grabWin = TkMacOSXGetCapture();
-
- if (!grabWin) {
- int grabState = TkGrabState((TkWindow*)tkwin);
-
- if (grabState != TK_GRAB_NONE && grabState != TK_GRAB_IN_TREE) {
- grabWin = (Tk_Window) (((TkWindow*)tkwin)->dispPtr->grabWinPtr);
- }
+ if (modifiers & NSFunctionKeyMask) {
+ state |= Mod4Mask;
}
-
- return grabWin;
-}
-
-/*
- *----------------------------------------------------------------------
- *
- * GenerateMouseWheelEvent --
- *
- * Generates a "MouseWheel" Tk event.
- *
- * Results:
- * None.
- *
- * Side effects:
- * Places a mousewheel event on the event queue.
- *
- *----------------------------------------------------------------------
- */
-
-static int
-GenerateMouseWheelEvent(MouseEventData * medPtr)
-{
- Tk_Window tkwin, rootwin;
- TkDisplay *dispPtr;
- TkWindow *winPtr;
- XEvent xEvent;
- dispPtr = TkGetDisplayList();
- rootwin = Tk_IdToWindow(dispPtr->display, medPtr->window);
- if (rootwin == NULL) {
- tkwin = NULL;
+ if (type != NSScrollWheel) {
+#ifdef TK_MAC_DEBUG_EVENTS
+ TKLog(@"UpdatePointer %p x %f.0 y %f.0 %d", tkwin, global.x, global.y, state);
+#endif
+ Tk_UpdatePointer(tkwin, global.x, global.y, state);
} else {
- tkwin = Tk_TopCoordsToWindow(rootwin,
- medPtr->local.h, medPtr->local.v,
- &xEvent.xbutton.x, &xEvent.xbutton.y);
- }
-
- /*
- * The following call will generate the appropiate X events and
- * adjust any state that Tk must remember.
- */
-
- if (!tkwin) {
- tkwin = TkMacOSXGetCapture();
- }
- if (!tkwin) {
- return false;
+ CGFloat delta;
+ int coarseDelta;
+ XEvent xEvent;
+
+ xEvent.type = MouseWheelEvent;
+ xEvent.xbutton.x = local.x;
+ xEvent.xbutton.y = local.y;
+ xEvent.xbutton.x_root = global.x;
+ xEvent.xbutton.y_root = global.y;
+ xEvent.xany.send_event = false;
+ xEvent.xany.display = Tk_Display(tkwin);
+ xEvent.xany.window = Tk_WindowId(tkwin);
+
+ delta = [theEvent deltaY];
+ if (delta != 0.0) {
+ coarseDelta = (delta > -1.0 && delta < 1.0) ? (signbit(delta) ? -1 : 1) : lround(delta);
+ xEvent.xbutton.state = state;
+ xEvent.xkey.keycode = coarseDelta;
+ xEvent.xany.serial = LastKnownRequestProcessed(Tk_Display(tkwin));
+ Tk_QueueWindowEvent(&xEvent, TCL_QUEUE_TAIL);
+ }
+ delta = [theEvent deltaX];
+ if (delta != 0.0) {
+ coarseDelta = (delta > -1.0 && delta < 1.0) ? (signbit(delta) ? -1 : 1) : lround(delta);
+ xEvent.xbutton.state = state | ShiftMask;
+ xEvent.xkey.keycode = coarseDelta;
+ xEvent.xany.serial = LastKnownRequestProcessed(Tk_Display(tkwin));
+ Tk_QueueWindowEvent(&xEvent, TCL_QUEUE_TAIL);
+ }
}
- winPtr = (TkWindow *) tkwin;
- xEvent.type = MouseWheelEvent;
- xEvent.xkey.keycode = medPtr->delta;
- xEvent.xbutton.x_root = medPtr->global.h;
- xEvent.xbutton.y_root = medPtr->global.v;
- xEvent.xbutton.state = medPtr->state;
- xEvent.xany.serial = LastKnownRequestProcessed(winPtr->display);
- xEvent.xany.send_event = false;
- xEvent.xany.display = winPtr->display;
- xEvent.xany.window = Tk_WindowId(winPtr);
- Tk_QueueWindowEvent(&xEvent, TCL_QUEUE_TAIL);
- return true;
-}
-
-/*
- *----------------------------------------------------------------------
- *
- * TkMacOSXGetEatButtonUp --
- *
- * Results:
- * Returns the flag indicating if we need to eat the
- * next mouse up event
- *
- * Side effects:
- * None.
- *
- *----------------------------------------------------------------------
- */
-int
-TkMacOSXGetEatButtonUp(void)
-{
- return gEatButtonUp;
-}
-
-/*
- *----------------------------------------------------------------------
- *
- * TkMacOSXSetEatButtonUp --
- *
- * Results:
- * None.
- *
- * Side effects:
- * Sets the flag indicating if we need to eat the
- * next mouse up event
- *
- *----------------------------------------------------------------------
- */
-void
-TkMacOSXSetEatButtonUp(int f)
-{
- gEatButtonUp = f;
+ return theEvent;
}
+@end
+
+#pragma mark -
/*
*----------------------------------------------------------------------
@@ -779,7 +237,7 @@ TkMacOSXModifierState(void)
keyModifiers = isFrontProcess ? GetCurrentEventKeyModifiers() :
GetCurrentKeyModifiers();
- return (EventModifiers)(keyModifiers & USHRT_MAX);
+ return (EventModifiers) (keyModifiers & USHRT_MAX);
}
/*
@@ -790,8 +248,8 @@ TkMacOSXModifierState(void)
* Returns the current state of the button & modifier keys.
*
* Results:
- * A bitwise inclusive OR of a subset of the following:
- * Button1Mask, ShiftMask, LockMask, ControlMask, Mod*Mask.
+ * A bitwise inclusive OR of a subset of the following: Button1Mask,
+ * ShiftMask, LockMask, ControlMask, Mod*Mask.
*
* Side effects:
* None.
@@ -805,10 +263,8 @@ TkMacOSXButtonKeyState(void)
UInt32 buttonState = 0, keyModifiers;
int isFrontProcess = (GetCurrentEvent() && Tk_MacOSXIsAppInFront());
- if (!TkMacOSXGetEatButtonUp()) {
- buttonState = isFrontProcess ? GetCurrentEventButtonState() :
- GetCurrentButtonState();
- }
+ buttonState = isFrontProcess ? GetCurrentEventButtonState() :
+ GetCurrentButtonState();
keyModifiers = isFrontProcess ? GetCurrentEventKeyModifiers() :
GetCurrentKeyModifiers();
@@ -833,11 +289,16 @@ TkMacOSXButtonKeyState(void)
*/
static unsigned int
-ButtonModifiers2State(UInt32 buttonState, UInt32 keyModifiers)
+ButtonModifiers2State(
+ UInt32 buttonState,
+ UInt32 keyModifiers)
{
unsigned int state;
- /* Tk supports at most 5 buttons */
+ /*
+ * Tk supports at most 5 buttons.
+ */
+
state = (buttonState & ((1<<5) - 1)) << 8;
if (keyModifiers & alphaLock) {
@@ -871,12 +332,12 @@ ButtonModifiers2State(UInt32 buttonState, UInt32 keyModifiers)
* XQueryPointer --
*
* Check the current state of the mouse. This is not a complete
- * implementation of this function. It only computes the root
- * coordinates and the current mask.
+ * implementation of this function. It only computes the root coordinates
+ * and the current mask.
*
* Results:
- * Sets root_x_return, root_y_return, and mask_return. Returns
- * true on success.
+ * Sets root_x_return, root_y_return, and mask_return. Returns true on
+ * success.
*
* Side effects:
* None.
@@ -886,71 +347,42 @@ ButtonModifiers2State(UInt32 buttonState, UInt32 keyModifiers)
Bool
XQueryPointer(
- Display* display,
+ Display *display,
Window w,
- Window* root_return,
- Window* child_return,
- int* root_x_return,
- int* root_y_return,
- int* win_x_return,
- int* win_y_return,
- unsigned int* mask_return)
+ Window *root_return,
+ Window *child_return,
+ int *root_x_return,
+ int *root_y_return,
+ int *win_x_return,
+ int *win_y_return,
+ unsigned int *mask_return)
{
int getGlobal = (root_x_return && root_y_return);
- int getLocal = (win_x_return && win_y_return);
+ int getLocal = (win_x_return && win_y_return && w != None);
if (getGlobal || getLocal) {
- Point where, local;
- OSStatus err = noErr;
- int gotMouseLoc = 0;
- EventRef ev = GetCurrentEvent();
+ NSPoint global = [NSEvent mouseLocation];
- if (ev && getLocal) {
- err = ChkErr(GetEventParameter, ev, kEventParamWindowMouseLocation,
- typeQDPoint, NULL, sizeof(Point), NULL, &local);
- gotMouseLoc = (err == noErr);
- }
- if (getGlobal || !gotMouseLoc) {
- if (ev) {
- err = ChkErr(GetEventParameter, ev, kEventParamMouseLocation,
- typeQDPoint, NULL, sizeof(Point), NULL, &where);
- }
- if (!ev || err != noErr) {
- GetGlobalMouse(&where);
- }
- }
if (getLocal) {
- WindowRef whichWin;
- if (ev) {
- err = ChkErr(GetEventParameter, ev, kEventParamWindowRef,
- typeWindowRef, NULL, sizeof(WindowRef), NULL,
- &whichWin);
- }
- if (!ev || err != noErr) {
- FindWindow(where, &whichWin);
- }
- if (gotMouseLoc) {
- if (whichWin) {
- Rect widths;
+ MacDrawable *macWin = (MacDrawable *) w;
+ NSWindow *win = TkMacOSXDrawableWindow(w);
- ChkErr(GetWindowStructureWidths, whichWin, &widths);
- local.h -= widths.left;
- local.v -= widths.top;
- }
- } else {
- local = where;
- if (whichWin) {
- QDGlobalToLocalPoint(GetWindowPort(whichWin), &local);
+ if (win) {
+ NSPoint local;
+
+ local = [win convertScreenToBase:global];
+ local.y = [win frame].size.height - local.y;
+ if (macWin->winPtr && macWin->winPtr->wmInfoPtr) {
+ local.x -= macWin->winPtr->wmInfoPtr->xInParent;
+ local.y -= macWin->winPtr->wmInfoPtr->yInParent;
}
+ *win_x_return = local.x;
+ *win_y_return = local.y;
}
}
if (getGlobal) {
- *root_x_return = where.h;
- *root_y_return = where.v;
- }
- if (getLocal) {
- *win_x_return = local.h;
- *win_y_return = local.v;
+ *root_x_return = global.x;
+ *root_y_return = tkMacOSXZeroScreenHeight - global.y;
}
}
if (mask_return) {
@@ -964,35 +396,34 @@ XQueryPointer(
*
* TkGenerateButtonEventForXPointer --
*
- * This procedure generates an X button event for the current
- * pointer state as reported by XQueryPointer().
+ * This procedure generates an X button event for the current pointer
+ * state as reported by XQueryPointer().
*
* Results:
* True if event(s) are generated - false otherwise.
*
* Side effects:
- * Additional events may be place on the Tk event queue.
- * Grab state may also change.
+ * Additional events may be place on the Tk event queue. Grab state may
+ * also change.
*
*----------------------------------------------------------------------
*/
MODULE_SCOPE int
TkGenerateButtonEventForXPointer(
- Window window) /* X Window containing button event. */
+ Window window) /* X Window containing button event. */
{
MouseEventData med;
int global_x, global_y, local_x, local_y;
bzero(&med, sizeof(MouseEventData));
- XQueryPointer(NULL, None, NULL, NULL, &global_x, &global_y,
+ XQueryPointer(NULL, window, NULL, NULL, &global_x, &global_y,
&local_x, &local_y, &med.state);
med.global.h = global_x;
med.global.v = global_y;
med.local.h = local_x;
med.local.v = local_y;
med.window = window;
- med.activeNonFloating = ActiveNonFloatingWindow();
return GenerateButtonEvent(&med);
}
@@ -1002,27 +433,29 @@ TkGenerateButtonEventForXPointer(
*
* TkGenerateButtonEvent --
*
- * Given a global x & y position and the button key status this
- * procedure generates the appropiate X button event. It also
- * handles the state changes needed to implement implicit grabs.
+ * Given a global x & y position and the button key status this procedure
+ * generates the appropiate X button event. It also handles the state
+ * changes needed to implement implicit grabs.
*
* Results:
- * True if event(s) are generated - false otherwise.
+ * True if event(s) are generated, false otherwise.
*
* Side effects:
- * Additional events may be place on the Tk event queue.
- * Grab state may also change.
+ * Additional events may be place on the Tk event queue. Grab state may
+ * also change.
*
*----------------------------------------------------------------------
*/
int
TkGenerateButtonEvent(
- int x, /* X location of mouse */
- int y, /* Y location of mouse */
- Window window, /* X Window containing button event. */
- unsigned int state) /* Button Key state suitable for X event */
+ int x, /* X location of mouse, */
+ int y, /* Y location of mouse. */
+ Window window, /* X Window containing button event. */
+ unsigned int state) /* Button Key state suitable for X event. */
{
+ MacDrawable *macWin = (MacDrawable *) window;
+ NSWindow *win = TkMacOSXDrawableWindow(window);
MouseEventData med;
bzero(&med, sizeof(MouseEventData));
@@ -1030,10 +463,20 @@ TkGenerateButtonEvent(
med.window = window;
med.global.h = x;
med.global.v = y;
- FindWindow(med.global, &med.whichWin);
- med.activeNonFloating = ActiveNonFloatingWindow();
med.local = med.global;
- QDGlobalToLocalPoint(GetWindowPort(med.whichWin), &med.local);
+
+ if (win) {
+ NSPoint local = NSMakePoint(x, tkMacOSXZeroScreenHeight - y);
+
+ local = [win convertScreenToBase:local];
+ local.y = [win frame].size.height - local.y;
+ if (macWin->winPtr && macWin->winPtr->wmInfoPtr) {
+ local.x -= macWin->winPtr->wmInfoPtr->xInParent;
+ local.y -= macWin->winPtr->wmInfoPtr->yInParent;
+ }
+ med.local.h = local.x;
+ med.local.v = tkMacOSXZeroScreenHeight - local.y;
+ }
return GenerateButtonEvent(&med);
}
@@ -1043,21 +486,22 @@ TkGenerateButtonEvent(
*
* GenerateButtonEvent --
*
- * Generate an X button event from a MouseEventData structure.
- * Handles the state changes needed to implement implicit grabs.
+ * Generate an X button event from a MouseEventData structure. Handles
+ * the state changes needed to implement implicit grabs.
*
* Results:
* True if event(s) are generated - false otherwise.
*
* Side effects:
- * Additional events may be place on the Tk event queue.
- * Grab state may also change.
+ * Additional events may be place on the Tk event queue. Grab state may
+ * also change.
*
*----------------------------------------------------------------------
*/
static int
-GenerateButtonEvent(MouseEventData * medPtr)
+GenerateButtonEvent(
+ MouseEventData *medPtr)
{
Tk_Window tkwin;
int dummy;
@@ -1065,11 +509,12 @@ GenerateButtonEvent(MouseEventData * medPtr)
#if UNUSED
/*
- * ButtonDown events will always occur in the front
- * window. ButtonUp events, however, may occur anywhere
- * on the screen. ButtonUp events should only be sent
- * to Tk if in the front window or during an implicit grab.
+ * ButtonDown events will always occur in the front window. ButtonUp
+ * events, however, may occur anywhere on the screen. ButtonUp events
+ * should only be sent to Tk if in the front window or during an implicit
+ * grab.
*/
+
if ((medPtr->activeNonFloating == NULL)
|| ((!(TkpIsWindowFloating(medPtr->whichWin))
&& (medPtr->activeNonFloating != medPtr->whichWin))
@@ -1087,61 +532,14 @@ GenerateButtonEvent(MouseEventData * medPtr)
}
Tk_UpdatePointer(tkwin, medPtr->global.h, medPtr->global.v, medPtr->state);
-
return true;
}
/*
- *----------------------------------------------------------------------
- *
- * GenerateToolbarButtonEvent --
- *
- * Generates a "ToolbarButton" virtual event.
- * This can be used to manage disappearing toolbars.
- *
- * Results:
- * None.
- *
- * Side effects:
- * Places a virtual event on the event queue.
- *
- *----------------------------------------------------------------------
+ * Local Variables:
+ * mode: c
+ * c-basic-offset: 4
+ * fill-column: 79
+ * coding: utf-8
+ * End:
*/
-
-static int
-GenerateToolbarButtonEvent(MouseEventData * medPtr)
-{
- Tk_Window rootwin, tkwin = NULL;
- TkDisplay *dispPtr;
- TkWindow *winPtr;
- XVirtualEvent event;
-
- dispPtr = TkGetDisplayList();
- rootwin = Tk_IdToWindow(dispPtr->display, medPtr->window);
- if (rootwin) {
- tkwin = Tk_TopCoordsToWindow(rootwin,
- medPtr->local.h, medPtr->local.v, &event.x, &event.y);
- }
- if (!tkwin) {
- return true;
- }
- winPtr = (TkWindow *)tkwin;
-
- bzero(&event, sizeof(XVirtualEvent));
- event.type = VirtualEvent;
- event.serial = LastKnownRequestProcessed(winPtr->display);
- event.send_event = false;
- event.display = winPtr->display;
- event.event = winPtr->window;
- event.root = XRootWindow(winPtr->display, 0);
- event.subwindow = None;
- event.time = TkpGetMS();
- event.x_root = medPtr->global.h;
- event.y_root = medPtr->global.v;
- event.state = medPtr->state;
- event.same_screen = true;
- event.name = Tk_GetUid("ToolbarButton");
-
- Tk_QueueWindowEvent((XEvent *) &event, TCL_QUEUE_TAIL);
- return true;
-}
diff --git a/macosx/tkMacOSXNotify.c b/macosx/tkMacOSXNotify.c
index d368292..2274a31 100644
--- a/macosx/tkMacOSXNotify.c
+++ b/macosx/tkMacOSXNotify.c