summaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorwolfsuit <wolfsuit>2004-07-25 01:57:30 (GMT)
committerwolfsuit <wolfsuit>2004-07-25 01:57:30 (GMT)
commit836a1e8661f2764927233aae65d7733ac10e91b9 (patch)
treecbe9b8f26567cbfa81936df1c5d421995b5845b2
parent414f93c79cebe9bca7f62cdc42368e81cb469174 (diff)
downloadtk-836a1e8661f2764927233aae65d7733ac10e91b9.zip
tk-836a1e8661f2764927233aae65d7733ac10e91b9.tar.gz
tk-836a1e8661f2764927233aae65d7733ac10e91b9.tar.bz2
Finish the implementation of the CG version of the X Drawing layer.
Add support for returning values for the wm attributes commands, and use FSRef's rather than FSSpec's.
-rw-r--r--ChangeLog35
-rw-r--r--macosx/README21
-rw-r--r--macosx/tkMacOSXInit.c3
-rw-r--r--macosx/tkMacOSXInt.h3
-rw-r--r--macosx/tkMacOSXWm.c207
5 files changed, 209 insertions, 60 deletions
diff --git a/ChangeLog b/ChangeLog
index c546e97..d5fc18b 100644
--- a/ChangeLog
+++ b/ChangeLog
@@ -1,3 +1,38 @@
+2004-07-24 Jim Ingham <jingham@apple.com>
+
+ Mac OS X: Complete the implementation of the CG version of
+ the X drawing emulation layer.
+
+ This was mostly done by James Tittle (tigital<at>mac<dot>com),
+ with a little help from me.
+
+ macosx/tkMacOSXint.h: Add declaration of TkMacOSXInitCGDrawing.
+ macosx/tkMacOSXInit.c: Call it.
+ macosx/tkMacOSXDraw.c (TkMacOSXInitCGDrawing): New function
+ set up the variables controlling the use of cg drawing.
+ (XFillRectangles): Make the CG branch work.
+ (XDrawLines): Ditto
+ (XDrawSegments): Ditto
+ (XFillPolygon): Ditto
+ (XDrawRectangle): Ditto
+ (XDrawRectangles): Ditto
+ (XDrawArc): Ditto
+ (XDrawArcs): Ditto
+ (XFillArc): Ditto
+ (XFillArcs): Ditto
+ (TkMacOSXSetupCGContext): Make this actually work.
+ (TkMacOSXReleaseCGContext): Ditto.
+
+ Mac OS X: Add support for reading the wm attributes -titlepath
+ command, and convert to using FSRef's.
+ This was done by Neil Madden (nem<at>cs<dot>nott<dot>ac<dot>uk).
+
+ macosx/tkMacOSXWm.c (WmAttrGetModifiedStatus): New function.
+ (WmAttrGetTitlePath) New function.
+ (WmAttributesCmd): Convert command parsing to use the options index.
+ Use the two above functions to report results. Convert the titlepath
+ code to use FSRef's.
+
2004-07-23 Benjamin Riefenstahl <Benjamin.Riefenstahl@epost.de>
[Merge from HEAD]
diff --git a/macosx/README b/macosx/README
index 07302c0..7514ad8 100644
--- a/macosx/README
+++ b/macosx/README
@@ -1,7 +1,7 @@
TclTkAqua README
----------------
-RCS: @(#) $Id: README,v 1.6.2.3 2003/10/01 14:35:39 das Exp $
+RCS: @(#) $Id: README,v 1.6.2.4 2004/07/25 01:57:41 wolfsuit Exp $
This is the README file for the Mac OS X native versions of Tcl & Tk.
@@ -83,6 +83,25 @@ you expect. (Wish started from the Finder inherits the Finder's environment
variables, which are essentially those set in $HOME/.MacOSX/environment.plist
and not those set by your shell configuration files).
+- As of Tk 8.4.7, AquaTk 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. So this is a great improvement.
+
+The old QD code is retained for now, just in case there are any
+compatibility problems. To switch back to the QD drawing, just put:
+
+set tk::mac::useCGDrawing 0
+
+in your script before you do drawing. Also the CG drawing can anti-alias line drawing.
+However, anti-aliased thin lines look washed out, so the threshold for antialiasing
+is set to 3 pixel width lines. You can change this if you want by putting:
+
+set tk::mac::CGAntialiasLimit <pixel limit>
+
+in your script before drawing.
+
- Quickdraw text antialiasing is enabled by default when available (from 10.1.5
onwards). Changing the global boolean variable '::tk::mac::antialiasedtext'
allows to dis/enable antialiasing on the fly from tcl (even for existing text).
diff --git a/macosx/tkMacOSXInit.c b/macosx/tkMacOSXInit.c
index c8c9ef3..5f415c8 100644
--- a/macosx/tkMacOSXInit.c
+++ b/macosx/tkMacOSXInit.c
@@ -10,7 +10,7 @@
* See the file "license.terms" for information on usage and redistribution
* of this file, and for a DISCLAIMER OF ALL WARRANTIES.
*
- * RCS: @(#) $Id: tkMacOSXInit.c,v 1.3.2.1 2003/05/13 08:41:48 das Exp $
+ * RCS: @(#) $Id: tkMacOSXInit.c,v 1.3.2.2 2004/07/25 01:57:41 wolfsuit Exp $
*/
#include "tkInt.h"
@@ -112,6 +112,7 @@ TkpInit(interp)
TkMacOSXInitAppleEvents(interp);
TkMacOSXInitMenus(interp);
TkMacOSXUseAntialiasedText(interp, TRUE);
+ TkMacOSXInitCGDrawing(interp, TRUE, 3);
}
if (carbonEncodingInitialized == false) {
diff --git a/macosx/tkMacOSXInt.h b/macosx/tkMacOSXInt.h
index 4d7b840..12ac566 100644
--- a/macosx/tkMacOSXInt.h
+++ b/macosx/tkMacOSXInt.h
@@ -9,7 +9,7 @@
* See the file "license.terms" for information on usage and redistribution
* of this file, and for a DISCLAIMER OF ALL WARRANTIES.
*
- * RCS: @(#) $Id: tkMacOSXInt.h,v 1.3 2002/10/16 19:44:05 das Exp $
+ * RCS: @(#) $Id: tkMacOSXInt.h,v 1.3.2.1 2004/07/25 01:57:41 wolfsuit Exp $
*/
#ifndef _TKMACINT
@@ -151,6 +151,7 @@ extern TkMacOSXWindowList *tkMacOSXWindowListPtr;
extern Tcl_Encoding TkMacOSXCarbonEncoding;
extern int TkMacOSXUseAntialiasedText(Tcl_Interp *interp, int enable);
+extern int TkMacOSXInitCGDrawing(Tcl_Interp *interp, int enable, int antiAlias);
#include "tkIntPlatDecls.h"
diff --git a/macosx/tkMacOSXWm.c b/macosx/tkMacOSXWm.c
index 4a5203b..9e17a9d 100644
--- a/macosx/tkMacOSXWm.c
+++ b/macosx/tkMacOSXWm.c
@@ -12,7 +12,7 @@
* See the file "license.terms" for information on usage and redistribution
* of this file, and for a DISCLAIMER OF ALL WARRANTIES.
*
- * RCS: @(#) $Id: tkMacOSXWm.c,v 1.7.2.3 2004/02/16 00:42:34 wolfsuit Exp $
+ * RCS: @(#) $Id: tkMacOSXWm.c,v 1.7.2.4 2004/07/25 01:57:41 wolfsuit Exp $
*/
#include <Carbon/Carbon.h>
@@ -86,6 +86,10 @@ static int WmAspectCmd _ANSI_ARGS_((Tk_Window tkwin,
static int WmAttributesCmd _ANSI_ARGS_((Tk_Window tkwin,
TkWindow *winPtr, Tcl_Interp *interp, int objc,
Tcl_Obj *CONST objv[]));
+static void WmAttrGetModifiedStatus(WindowRef macWindow, Tcl_Obj
+ *result);
+static void WmAttrGetTitlePath(WindowRef macWindow, Tcl_Obj
+ *result);
static int WmClientCmd _ANSI_ARGS_((Tk_Window tkwin,
TkWindow *winPtr, Tcl_Interp *interp, int objc,
Tcl_Obj *CONST objv[]));
@@ -755,77 +759,166 @@ Tcl_Interp *interp; /* Current interpreter. */
int objc; /* Number of arguments. */
Tcl_Obj *CONST objv[]; /* Argument objects. */
{
- char buf[TCL_INTEGER_SPACE];
int i;
+ int index;
WindowRef macWindow;
-
+ Tcl_Obj *result = NULL;
+ const char *optionTable[] = {
+ "-modified",
+ "-titlepath",
+ (char *)NULL
+ };
+ enum optionIdx {
+ WmAttrModifiedIdx,
+ WmAttrTitlePathIdx
+ };
+
+ /* Must have objc >= 3 at this point. */
if (objc < 3) {
-configArgs:
- Tcl_AppendResult(interp, "wrong # arguments: must be \"",
- Tcl_GetStringFromObj (objv[0], NULL), " attributes window",
- " ?-modified ?bool??",
- " ?-titlepath ?path??",
- "\"", (char *) NULL);
- return TCL_ERROR;
+ Tcl_WrongNumArgs(interp, 0, objv,
+ "wm attributes window ?-modified ?bool?? ?-titlepath ?path??");
+ return TCL_ERROR;
}
+
macWindow = GetWindowFromPort(TkMacOSXGetDrawablePort(winPtr->window));
+
if (objc == 3) {
- FSSpec spec;
- sprintf(buf, "%d", (IsWindowModified(macWindow) == true));
- Tcl_AppendResult(interp, "-modified ", buf, (char *) NULL);
- if (GetWindowProxyFSSpec(macWindow, &spec) == noErr) {
- Tcl_AppendResult(interp, " -titlepath", (char *) NULL);
- /* Need to get the path from the spec */
- Tcl_AppendElement(interp, "<read_unimplemented>");
- } else {
- Tcl_AppendResult(interp, " -titlepath {}", (char *) NULL);
- }
+ result = Tcl_NewObj();
+ Tcl_AppendToObj(result, "-modified ", -1);
+ WmAttrGetModifiedStatus(macWindow, result);
+ Tcl_AppendToObj(result, " -titlepath ", -1);
+ WmAttrGetTitlePath(macWindow, result);
+ Tcl_SetObjResult(interp, result);
return TCL_OK;
}
+ if (objc == 4) {
+ if (Tcl_GetIndexFromObj(interp, objv[3], optionTable, "option", 0,
+ &index) != TCL_OK) {
+ return TCL_ERROR;
+ }
+ result = Tcl_NewObj();
+ switch (index) {
+ case WmAttrModifiedIdx:
+ WmAttrGetModifiedStatus(macWindow, result);
+ break;
+ case WmAttrTitlePathIdx:
+ WmAttrGetTitlePath(macWindow, result);
+ break;
+ }
+ Tcl_SetObjResult(interp, result);
+ return TCL_OK;
+ }
+
+ if ( (objc - 3) % 2 != 0 ) {
+ Tcl_WrongNumArgs(interp, 3, objv,
+ "?-modified ?bool?? ?-titlepath ?path??");
+ return TCL_ERROR;
+ }
for (i = 3; i < objc; i += 2) {
- int length;
- char *argPtr = Tcl_GetStringFromObj(objv[i], &length);
- if ((length < 2) || (*argPtr != '-')) {
- goto configArgs;
- }
- if (strncmp(argPtr, "-modified", length) == 0) {
- int boolean;
- if (i < objc - 1) {
- if (Tcl_GetBooleanFromObj(interp, objv[i+1], &boolean) != TCL_OK) {
- return TCL_ERROR;
- }
- SetWindowModified(macWindow, boolean);
- }
- } else if (strncmp(argPtr, "-titlepath", length) == 0) {
- if (i < objc - 1) {
- OSErr err;
- FSSpec spec;
- FSRef ref;
- Boolean isDirectory;
- err = FSPathMakeRef(Tcl_GetStringFromObj(objv[i+1], NULL), &ref, &isDirectory);
+ int boolean;
+ OSErr err;
+ FSRef ref;
+ AliasHandle alias;
+ Boolean isDirectory;
+
+ if (Tcl_GetIndexFromObj(interp, objv[i], optionTable, "option", 0,
+ &index) != TCL_OK) {
+ return TCL_ERROR;
+ }
+ switch (index) {
+ case WmAttrModifiedIdx:
+ if (Tcl_GetBooleanFromObj(interp, objv[i+1], &boolean) !=
+ TCL_OK) {
+ return TCL_ERROR;
+ }
+ result = objv[i+1];
+ SetWindowModified(macWindow, boolean);
+ break;
+ case WmAttrTitlePathIdx:
+ err = FSPathMakeRef(
+ Tcl_GetStringFromObj(objv[i+1], NULL),
+ &ref, &isDirectory);
if (err == noErr) {
- err = FSGetCatalogInfo(&ref, kFSCatInfoNone, NULL, NULL,
- &spec, NULL);
- if (err == noErr) {
- if (SetWindowProxyFSSpec(macWindow,&spec) != noErr) {
- Tcl_AppendResult(interp, "couldn't set window proxy title path",
- (char *) NULL);
- return TCL_ERROR;
- }
- }
+ err = FSNewAlias(NULL, &ref, &alias);
}
- }
- } else {
- goto configArgs;
- }
- if (i == objc - 2) {
- /* Want to return last result */
- Tcl_SetObjResult(interp, objv[i+1]);
- }
+ if (err == noErr) {
+ err = SetWindowProxyAlias(macWindow, alias);
+ }
+ if (err != noErr) {
+ Tcl_SetObjResult(interp,
+ Tcl_NewStringObj("couldn't set window proxy title path",
+ -1));
+ return TCL_ERROR;
+ } else {
+ result = objv[i+1];
+ }
+ break;
+ }
}
+ Tcl_SetObjResult(interp, result);
return TCL_OK;
}
+
+/*
+ *----------------------------------------------------------------------
+ * WmAttrGetModifiedStatus --
+ *
+ * Helper procedure to retrieve the -modified option for the wm
+ * attributes command.
+ *
+ * Results:
+ * Nothing.
+ *
+ * Side effects:
+ * Appends the modified status of the given window to the Tcl_Obj
+ * passed in.
+ *
+ *----------------------------------------------------------------------
+ */
+static void WmAttrGetModifiedStatus(WindowRef macWindow, Tcl_Obj *result)
+{
+ Tcl_AppendObjToObj(result, Tcl_NewBooleanObj(
+ (IsWindowModified(macWindow) == true)));
+}
+
+/*
+ *----------------------------------------------------------------------
+ * WmAttrGetTitlePath --
+ *
+ * Helper procedure to retrieve the -titlepath option for the wm
+ * attributes command.
+ *
+ * Results:
+ * Nothing.
+ *
+ * Side effects:
+ * Appends the proxy file path of the given window to the Tcl_Obj
+ * passed in.
+ *
+ *----------------------------------------------------------------------
+ */
+static void WmAttrGetTitlePath(WindowRef macWindow, Tcl_Obj *result)
+{
+ FSRef ref;
+ AliasHandle alias;
+ Boolean wasChanged;
+ UInt8 path[2048];
+ OSStatus err;
+ err = GetWindowProxyAlias(macWindow, &alias);
+ if (err == noErr) {
+ err = FSResolveAlias(NULL, alias, &ref, &wasChanged);
+ }
+ if (err == noErr) {
+ err = FSRefMakePath(&ref, path, 2048);
+ }
+ if (err == noErr) {
+ Tcl_AppendToObj(result, path, -1);
+ } else {
+ Tcl_AppendToObj(result, "{}", -1);
+ }
+}
+
/*
*----------------------------------------------------------------------
*