Tk Source Code

Check-in [2cb92ba5]
Login

Many hyperlinks are disabled.
Use anonymous login to enable hyperlinks.

Overview
Comment:
* generic/tkMain.c: * macosx/tkMacOSXAppInit.c (removed): * macosx/Wish.pbproj/project.pbxproj: * macosx/tkMacOSXInit.c: * macosx/tkMacOSXInt.h: changes to make TkAqua dynamically loadable, enabling [package require Tk] from tclsh. Startup code from tkMacOSXAppInit.c moved into tkMacOSXInit.c, added code that notifies the window server that an unbundled executable is a full GUI application after loading Tk. [Patch 1035348]
* doc/wm.n: documented [wm attributes] on Mac OS X. [Bug 606665] * macosx/tkMacOSXWm.c: implemented TIP 222 [wm attributes -alpha] on Mac OS X. [Patch 892194] WmIconbitmapCmd: adopted FSRef changes from [wm atttrs -titlepath].
* macosx/tkMacOSXSubwindows.c: synced spacing/formatting with core-8-4-branch.
* generic/tkRectOval.c: * macosx/README: * macosx/tkMacOSXDefault.h: * macosx/tkMacOSXDraw.c: * macosx/tkMacOSXInit.c: * macosx/tkMacOSXInt.h: * macosx/tkMacOSXMenu.c: * macosx/tkMacOSXWm.c: forward port from core-8-4-branch of Jim's and my changes for CG drawing and [wm attributes] (corresponds to 8.4 changes dating from 09-18, 07-27, 07-24).
* macosx/tkMacOSXMouseEvent.c: endianness fixes.
* macosx/Wish.pbproj/project.pbxproj: corrected path to html help inside framework.
* macosx/Makefile: prevent parallel make from building several targets at the same time.
Downloads: Tarball | ZIP archive | SQL archive
Timelines: family | ancestors | descendants | both | trunk
Files: files | file ages | folders
SHA1: 2cb92ba546de97e1bff0e5eb1d37986387b3f015
User & Date: das 2004-11-11 01:24:29
References
2017-11-04
08:22 New ticket [c8c52b9d] OS X - Lots of menu.test tests fail (items are off by one). artifact: 245bbe4f user: fvogel
Context
2004-11-11
11:33
* generic/tkEvent.c (InvokeInputMethods): Call XSetICFocus whenever the window receives focus. This fixes bug #905830 but avoids #1000051. check-in: b769b452 user: rmax tags: trunk
01:24
* generic/tkMain.c: * macosx/tkMacOSXAppInit.c (removed): * macosx/Wish.pbproj/project.pbxproj: * macosx/tkMacOSXInit.c: * macosx/tkMacOSXInt.h: changes to make TkAqua dynamically loadable, enabling [package require Tk] from tclsh. Startup code from tkMacOSXAppInit.c moved into tkMacOSXInit.c, added code that notifies the window server that an unbundled executable is a full GUI application after loading Tk. [Patch 1035348]
* doc/wm.n: documented [wm attributes] on Mac OS X. [Bug 606665] * macosx/tkMacOSXWm.c: implemented TIP 222 [wm attributes -alpha] on Mac OS X. [Patch 892194] WmIconbitmapCmd: adopted FSRef changes from [wm atttrs -titlepath].
* macosx/tkMacOSXSubwindows.c: synced spacing/formatting with core-8-4-branch.
* generic/tkRectOval.c: * macosx/README: * macosx/tkMacOSXDefault.h: * macosx/tkMacOSXDraw.c: * macosx/tkMacOSXInit.c: * macosx/tkMacOSXInt.h: * macosx/tkMacOSXMenu.c: * macosx/tkMacOSXWm.c: forward port from core-8-4-branch of Jim's and my changes for CG drawing and [wm attributes] (corresponds to 8.4 changes dating from 09-18, 07-27, 07-24).
* macosx/tkMacOSXMouseEvent.c: endianness fixes.
* macosx/Wish.pbproj/project.pbxproj: corrected path to html help inside framework.
* macosx/Makefile: prevent parallel make from building several targets at the same time.
check-in: 2cb92ba5 user: das tags: trunk
2004-11-09
12:46
fix to MacOSX compound button layout check-in: 468121ce user: vincentdarley tags: trunk
Changes
Hide Diffs Unified Diffs Ignore Whitespace Patch

Changes to ChangeLog.








































1
2
3
4
5
6
7







































2004-11-09  Vince Darley  <[email protected]>

	* macosx/tkMacOSXButton.c: fix to dynamic reconfiguration of
	button '-compound' options (cosmetic problem), [Bug 1055023]

	* tests/text.test: added 'knownBug' 20.172.1 in text widget
	multiline search routines.
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>







1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
2004-11-11  Daniel Steffen  <[email protected]>

	* generic/tkMain.c:
	* macosx/tkMacOSXAppInit.c (removed):
	* macosx/Wish.pbproj/project.pbxproj: 
	* macosx/tkMacOSXInit.c:
	* macosx/tkMacOSXInt.h: changes to make TkAqua dynamically loadable,
	enabling [package require Tk] from tclsh. Startup code from
	tkMacOSXAppInit.c moved into tkMacOSXInit.c, added code that
	notifies the window server that an unbundled executable is a full
	GUI application after loading Tk. [Patch 1035348]

	* doc/wm.n: documented [wm attributes] on Mac OS X. [Bug 606665]
	* macosx/tkMacOSXWm.c: implemented TIP 222 [wm attributes -alpha] on
	Mac OS X. [Patch 892194]
	WmIconbitmapCmd: adopted FSRef changes from [wm atttrs -titlepath].

	* macosx/tkMacOSXSubwindows.c: synced spacing/formatting with
	core-8-4-branch.

	* generic/tkRectOval.c:
	* macosx/README:
	* macosx/tkMacOSXDefault.h:
	* macosx/tkMacOSXDraw.c:
	* macosx/tkMacOSXInit.c:
	* macosx/tkMacOSXInt.h:
	* macosx/tkMacOSXMenu.c:
	* macosx/tkMacOSXWm.c: forward port from core-8-4-branch of Jim's
	and my changes for CG drawing and [wm attributes] (corresponds to
	8.4 changes dating from 09-18, 07-27, 07-24).

	* macosx/tkMacOSXMouseEvent.c: endianness fixes.

	* macosx/Wish.pbproj/project.pbxproj: corrected path to html help
	inside framework.

	* macosx/Makefile: prevent parallel make from building several
	targets at the same time.

2004-11-09  Vince Darley  <[email protected]>

	* macosx/tkMacOSXButton.c: fix to dynamic reconfiguration of
	button '-compound' options (cosmetic problem), [Bug 1055023]

	* tests/text.test: added 'knownBug' 20.172.1 in text widget
	multiline search routines.

Changes to doc/wm.n.

1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
'\"
'\" Copyright (c) 1991-1994 The Regents of the University of California.
'\" Copyright (c) 1994-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.
'\" 
'\" RCS: @(#) $Id: wm.n,v 1.20 2004/10/28 12:25:53 dkf Exp $
'\" 
.so man.macros
.TH wm n 8.5 Tk "Tk Built-In Commands"
.BS
'\" Note:  do not modify the .SH NAME line immediately below!
.SH NAME
wm \- Communicate with window manager







|







1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
'\"
'\" Copyright (c) 1991-1994 The Regents of the University of California.
'\" Copyright (c) 1994-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.
'\" 
'\" RCS: @(#) $Id: wm.n,v 1.21 2004/11/11 01:24:31 das Exp $
'\" 
.so man.macros
.TH wm n 8.5 Tk "Tk Built-In Commands"
.BS
'\" Note:  do not modify the .SH NAME line immediately below!
.SH NAME
wm \- Communicate with window manager
66
67
68
69
70
71
72
73

74




75
76
77
78
79
80
81
\fB\-alpha\fR sets the alpha transparency level of the toplevel.  It accepts
a value from \fB0.0\fR (fully transparent) to \fB1.0\fR (opaque).  Values
outside that range will be constrained.  This is supported on Windows
2000/XP+.  Where not supported, the \fB\-alpha\fR value remains at
\fB1.0\fR.
.VE 8.5
.PP
On Macintosh, there are currently two attribute values:

\fB\-modified\fR and \fB\-titlepath\fR.




.PP
On Unix, there are currently no special attribute values.
.RE
.VE 8.4
.TP
\fBwm client \fIwindow\fR ?\fIname\fR?
If \fIname\fR is specified, this command stores \fIname\fR (which







|
>
|
>
>
>
>







66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
\fB\-alpha\fR sets the alpha transparency level of the toplevel.  It accepts
a value from \fB0.0\fR (fully transparent) to \fB1.0\fR (opaque).  Values
outside that range will be constrained.  This is supported on Windows
2000/XP+.  Where not supported, the \fB\-alpha\fR value remains at
\fB1.0\fR.
.VE 8.5
.PP
On Mac OS X, \fB\-modified\fR gets or sets the modification state of the
window (determines whether the window close widget contains the modification
indicator). \fB\-titlepath\fR gets or sets the path of the file referenced as
the window proxy icon (which can be dragged and dropped in lieu of the file's
finder icon). \fB\-alpha\fR sets the alpha transparency level of the window,
it accepts a value from \fB0.0\fR (fully transparent) to \fB1.0\fR (opaque),
values outside that range will be constrained.
.PP
On Unix, there are currently no special attribute values.
.RE
.VE 8.4
.TP
\fBwm client \fIwindow\fR ?\fIname\fR?
If \fIname\fR is specified, this command stores \fIname\fR (which

Changes to generic/tkMain.c.

9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33



34
35
36
37
38
39
40
 *
 * Copyright (c) 1990-1994 The Regents of the University of California.
 * Copyright (c) 1994-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.
 *
 * RCS: @(#) $Id: tkMain.c,v 1.17 2004/03/17 18:15:43 das Exp $
 */

#include <ctype.h>
#include <stdio.h>
#include <string.h>
#include <tcl.h>
#include <tclInt.h>
#include <tk.h>
#include "tkInt.h"
#ifdef NO_STDLIB_H
#   include "../compat/stdlib.h"
#else
#   include <stdlib.h>
#endif
#ifdef __WIN32__
#include "tkWinInt.h"
#endif





typedef struct ThreadSpecificData {
    Tcl_Interp *interp;         /* Interpreter for this thread. */
    Tcl_DString command;        /* Used to assemble lines of terminal input
				 * into Tcl commands. */
    Tcl_DString line;           /* Used to read the next line from the







|

















>
>
>







9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
 *
 * Copyright (c) 1990-1994 The Regents of the University of California.
 * Copyright (c) 1994-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.
 *
 * RCS: @(#) $Id: tkMain.c,v 1.18 2004/11/11 01:24:31 das Exp $
 */

#include <ctype.h>
#include <stdio.h>
#include <string.h>
#include <tcl.h>
#include <tclInt.h>
#include <tk.h>
#include "tkInt.h"
#ifdef NO_STDLIB_H
#   include "../compat/stdlib.h"
#else
#   include <stdlib.h>
#endif
#ifdef __WIN32__
#include "tkWinInt.h"
#endif
#ifdef MAC_OSX_TK
#include "tkMacOSXInt.h"
#endif


typedef struct ThreadSpecificData {
    Tcl_Interp *interp;         /* Interpreter for this thread. */
    Tcl_DString command;        /* Used to assemble lines of terminal input
				 * into Tcl commands. */
    Tcl_DString line;           /* Used to read the next line from the
121
122
123
124
125
126
127






128
129
130
131
132
133
134
    
    Tcl_FindExecutable(argv[0]);
    tsdPtr->interp = interp;

#if defined(__WIN32__)
    Tk_InitConsoleChannels(interp);
#endif






    
#ifdef TCL_MEM_DEBUG
    Tcl_InitMemory(interp);
#endif

    /*
     * If the application has not already set a startup script, parse







>
>
>
>
>
>







124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
    
    Tcl_FindExecutable(argv[0]);
    tsdPtr->interp = interp;

#if defined(__WIN32__)
    Tk_InitConsoleChannels(interp);
#endif

#ifdef MAC_OSX_TK
    if (Tcl_GetStartupScript(NULL) == NULL) {
        TkMacOSXDefaultStartupScript();
    }
#endif
    
#ifdef TCL_MEM_DEBUG
    Tcl_InitMemory(interp);
#endif

    /*
     * If the application has not already set a startup script, parse

Changes to generic/tkRectOval.c.

1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
/* 
 * tkRectOval.c --
 *
 *	This file implements rectangle and oval items for canvas
 *	widgets.
 *
 * Copyright (c) 1991-1994 The Regents of the University of California.
 * Copyright (c) 1994-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.
 *
 * RCS: @(#) $Id: tkRectOval.c,v 1.11 2004/01/13 02:06:00 davygrvy Exp $
 */

#include <stdio.h>
#include "tk.h"
#include "tkInt.h"
#include "tkPort.h"
#include "tkCanvas.h"












|







1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
/* 
 * tkRectOval.c --
 *
 *	This file implements rectangle and oval items for canvas
 *	widgets.
 *
 * Copyright (c) 1991-1994 The Regents of the University of California.
 * Copyright (c) 1994-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.
 *
 * RCS: @(#) $Id: tkRectOval.c,v 1.12 2004/11/11 01:24:32 das Exp $
 */

#include <stdio.h>
#include "tk.h"
#include "tkInt.h"
#include "tkPort.h"
#include "tkCanvas.h"
668
669
670
671
672
673
674






675

676
677
678
679
680
681
682
	 */
#ifdef __WIN32__
	bloat = 1;
#else
	bloat = 0;
#endif
    } else {






	bloat = (int) (width+1)/2;

    }

    /*
     * Special note:  the rectangle is always drawn at least 1x1 in
     * size, so round up the upper coordinates to be at least 1 unit
     * greater than the lower ones.
     */







>
>
>
>
>
>

>







668
669
670
671
672
673
674
675
676
677
678
679
680
681
682
683
684
685
686
687
688
689
	 */
#ifdef __WIN32__
	bloat = 1;
#else
	bloat = 0;
#endif
    } else {
#ifdef MAC_OSX_TK
	/* Mac OS X CoreGraphics needs correct rounding here 
	 * otherwise it will draw outside the bounding box.
	 * Probably correct on other platforms as well? */
	bloat = (int) (width+1.5)/2;
#else
	bloat = (int) (width+1)/2;
#endif
    }

    /*
     * Special note:  the rectangle is always drawn at least 1x1 in
     * size, so round up the upper coordinates to be at least 1 unit
     * greater than the lower ones.
     */

Changes to macosx/Makefile.

1
2
3
4
5
6
7
8
9
10
11
12
13
################################################################################
#
# Makefile to build AquaTk on Mac OS X packaged as a Framework
#	uses Project Builder command line tool 'pbxbuild'
#
# RCS: @(#) $Id: Makefile,v 1.14 2004/07/20 11:49:16 das Exp $
#
################################################################################

#-------------------------------------------------------------------------------
# customizable settings

DESTDIR			?=





|







1
2
3
4
5
6
7
8
9
10
11
12
13
################################################################################
#
# Makefile to build AquaTk on Mac OS X packaged as a Framework
#	uses Project Builder command line tool 'pbxbuild'
#
# RCS: @(#) $Id: Makefile,v 1.15 2004/11/11 01:24:32 das Exp $
#
################################################################################

#-------------------------------------------------------------------------------
# customizable settings

DESTDIR			?=
123
124
125
126
127
128
129
130


131
	rmdir -p Library/Frameworks 2>&-;

################################################################################

.PHONY: all install embedded clean develop deploy install-develop install-deploy \
embedded-develop embedded-deploy install-embedded-develop install-embedded-deploy \
clean-develop clean-deploy cleanup-embedded



################################################################################








>
>

123
124
125
126
127
128
129
130
131
132
133
	rmdir -p Library/Frameworks 2>&-;

################################################################################

.PHONY: all install embedded clean develop deploy install-develop install-deploy \
embedded-develop embedded-deploy install-embedded-develop install-embedded-deploy \
clean-develop clean-deploy cleanup-embedded

.NOTPARALLEL:

################################################################################

Changes to macosx/README.

1
2
3
4
5
6
7
8
9
10
11
TclTkAqua README 
----------------

RCS: @(#) $Id: README,v 1.9 2003/10/01 14:35:32 das Exp $

This is the README file for the Mac OS X native versions of Tcl & Tk.


1. General
----------




|







1
2
3
4
5
6
7
8
9
10
11
TclTkAqua README 
----------------

RCS: @(#) $Id: README,v 1.10 2004/11/11 01:24:32 das Exp $

This is the README file for the Mac OS X native versions of Tcl & Tk.


1. General
----------

78
79
80
81
82
83
84




















85
86
87
88
89
90
91
need to filter it out for cross platform compatibility of your scripts.

- the env array is different when Wish is started from the Finder than when
it (or tclsh) is invoked from the Terminal, in particular PATH may not be what
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).





















- 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).

- the format of binary extensions expected by [load] is that of ordinary shared
libraries (.dylib) and not MachO bundles, at present loading of MachO bundles is







>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>







78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
need to filter it out for cross platform compatibility of your scripts.

- the env array is different when Wish is started from the Finder than when
it (or tclsh) is invoked from the Terminal, in particular PATH may not be what
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 <limit>

in your script before drawing, in which case only lines thinner that <limit> pixels 
will not be antialiased.

- 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).

- the format of binary extensions expected by [load] is that of ordinary shared
libraries (.dylib) and not MachO bundles, at present loading of MachO bundles is

Changes to macosx/Wish.pbproj/project.pbxproj.

54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
//4C4
//F50
//F51
//F52
//F53
//F54
		F50D96120196176E01DC9062 = {
			fallbackIsa = PBXFileReference;
			isa = PBXFrameworkReference;
			lastKnownFileType = wrapper.framework;
			name = ApplicationServices.framework;
			path = /System/Library/Frameworks/ApplicationServices.framework;
			refType = 0;
			sourceTree = "<absolute>";
		};
		F50D96130196176E01DC9062 = {







|
<







54
55
56
57
58
59
60
61

62
63
64
65
66
67
68
//4C4
//F50
//F51
//F52
//F53
//F54
		F50D96120196176E01DC9062 = {
			isa = PBXFileReference;

			lastKnownFileType = wrapper.framework;
			name = ApplicationServices.framework;
			path = /System/Library/Frameworks/ApplicationServices.framework;
			refType = 0;
			sourceTree = "<absolute>";
		};
		F50D96130196176E01DC9062 = {
159
160
161
162
163
164
165
166
167
168
169
170
171
172
173
		F52D38C5031F4259016F146B = {
			buildActionMask = 2147483647;
			files = (
			);
			isa = PBXShellScriptBuildPhase;
			runOnlyForDeploymentPostprocessing = 0;
			shellPath = /bin/sh;
			shellScript = "if [ \"${BUILD_STYLE}\" = \"Development\" ]; then\n\t# keep copy of debug library around, so that\n\t# Deployment build can be installed on top\n\t# of Development build without overwriting it\n\tcd \"${TARGET_BUILD_DIR}/${PRODUCT_NAME}.${WRAPPER_EXTENSION}/Versions/${FRAMEWORK_VERSION}\"\n\tcp -fp \"${PRODUCT_NAME}\" \"${PRODUCT_NAME}_debug\"\n\tln -fs \"Versions/Current/${PRODUCT_NAME}_debug\" ../..\n\tcp -fp \"libtkstub${FRAMEWORK_VERSION}.a\" \"libtkstub${FRAMEWORK_VERSION}g.a\"\n\n\t# force Deployment build to be relinked next time\n\tif [ -f \"${OBJROOT}/Deployment.build/${PROJECT_NAME}.build/${TARGET_NAME}.build/Objects-normal/LinkFileList\" ]; then\n\t    touch -t `date -r \\`expr \\\\\\`date +\"%s\"\\\\\\` + 30\\` +\"%Y%m%d%H%M.%S\"` \"${OBJROOT}/Deployment.build/${PROJECT_NAME}.build/${TARGET_NAME}.build/Objects-normal/LinkFileList\"\n\tfi\nelse\n\t# force Development build to be relinked next time\n\tif [ -f \"${OBJROOT}/Development.build/${PROJECT_NAME}.build/${TARGET_NAME}.build/Objects-normal/LinkFileList\" ]; then\n\t    touch -t `date -r \\`expr \\\\\\`date +\"%s\"\\\\\\` + 30\\` +\"%Y%m%d%H%M.%S\"` \"${OBJROOT}/Development.build/${PROJECT_NAME}.build/${TARGET_NAME}.build/Objects-normal/LinkFileList\"\n\tfi\nfi\n\n# fixup Framework structure\ncd \"${TARGET_BUILD_DIR}/${PRODUCT_NAME}.${WRAPPER_EXTENSION}/Versions/${FRAMEWORK_VERSION}\"\nln -fs `ls libtkstub* | sed -e \"s|.*|Versions/${FRAMEWORK_VERSION}/&|\"` ../..\nln -fs \"Versions/Current/tkConfig.sh\" ../..\nranlib libtkstub${FRAMEWORK_VERSION}*.a";
		};
		F537552A016C352C01DC9062 = {
			buildSettings = {
			};
			buildStyles = (
				F537552C016C352C01DC9062,
				F537552D016C352C01DC9062,







|







158
159
160
161
162
163
164
165
166
167
168
169
170
171
172
		F52D38C5031F4259016F146B = {
			buildActionMask = 2147483647;
			files = (
			);
			isa = PBXShellScriptBuildPhase;
			runOnlyForDeploymentPostprocessing = 0;
			shellPath = /bin/sh;
			shellScript = "if [ \"${BUILD_STYLE}\" = \"Development\" ]; then\n\t# keep copy of debug library around, so that\n\t# Deployment build can be installed on top\n\t# of Development build without overwriting it\n\tcd \"${TARGET_BUILD_DIR}/${PRODUCT_NAME}.${WRAPPER_EXTENSION}/Versions/${FRAMEWORK_VERSION}\"\n\tcp -fp \"${PRODUCT_NAME}\" \"${PRODUCT_NAME}_debug\"\n\tln -fs \"Versions/Current/${PRODUCT_NAME}_debug\" ../..\n\tcp -fp \"libtkstub${FRAMEWORK_VERSION}.a\" \"libtkstub${FRAMEWORK_VERSION}g.a\"\n\n\t# force Deployment build to be relinked next time\n\tif [ -f \"${OBJROOT}/Deployment.build/${PROJECT_NAME}.build/${TARGET_NAME}.build/Objects-normal/LinkFileList\" ]; then\n\t    touch -t `date -r \\`expr \\\\\\`date +\"%s\"\\\\\\` + 30\\` +\"%Y%m%d%H%M.%S\"` \"${OBJROOT}/Deployment.build/${PROJECT_NAME}.build/${TARGET_NAME}.build/Objects-normal/LinkFileList\"\n\tfi\nelse\n\t# force Development build to be relinked next time\n\tif [ -f \"${OBJROOT}/Development.build/${PROJECT_NAME}.build/${TARGET_NAME}.build/Objects-normal/LinkFileList\" ]; then\n\t    touch -t `date -r \\`expr \\\\\\`date +\"%s\"\\\\\\` + 30\\` +\"%Y%m%d%H%M.%S\"` \"${OBJROOT}/Development.build/${PROJECT_NAME}.build/${TARGET_NAME}.build/Objects-normal/LinkFileList\"\n\tfi\nfi\n\n# fixup Framework structure\ncd \"${TARGET_BUILD_DIR}/${PRODUCT_NAME}.${WRAPPER_EXTENSION}/Versions/${FRAMEWORK_VERSION}\"\nln -fs `ls libtkstub* | sed -e \"s|.*|Versions/${FRAMEWORK_VERSION}/&|\"` ../..\nln -fs \"Versions/Current/tkConfig.sh\" ../..\nranlib libtkstub${FRAMEWORK_VERSION}*.a\n\n# create pkgIndex\n( echo \"if {[package vcompare [package provide Tcl] ${FRAMEWORK_VERSION}] != 0} { return }\" && \\\n  echo \"package ifneeded Tk ${FRAMEWORK_VERSION} [list load [file join \\$dir .. .. Tk] Tk]\" \\\n) > \"Resources/Scripts/pkgIndex.tcl\"";
		};
		F537552A016C352C01DC9062 = {
			buildSettings = {
			};
			buildStyles = (
				F537552C016C352C01DC9062,
				F537552D016C352C01DC9062,
198
199
200
201
202
203
204
205
206
207
208
209
210
211
212
213
214
215
216
217
218
219
220
221
222
223
224
225
226
227
228
229
				F53755DD016C38D201DC9062,
			);
			isa = PBXGroup;
			refType = 4;
			sourceTree = "<group>";
		};
		F537552C016C352C01DC9062 = {
			buildRules = (
			);
			buildSettings = {
				GCC_DYNAMIC_NO_PIC = NO;
				GCC_ENABLE_FIX_AND_CONTINUE = YES;
				GCC_GENERATE_DEBUGGING_SYMBOLS = YES;
				GCC_OPTIMIZATION_LEVEL = 0;
				OTHER_LDFLAGS = "\U0001-prebind";
				TEMP_DIR = "${OBJROOT}/Development.build/$(PROJECT_NAME).build/$(TARGET_NAME).build";
				UNSTRIPPED_PRODUCT = YES;
				ZERO_LINK = YES;
			};
			isa = PBXBuildStyle;
			name = Development;
		};
		F537552D016C352C01DC9062 = {
			buildRules = (
			);
			buildSettings = {
				DEBUGGING_SYMBOLS = NO;
				GCC_ENABLE_FIX_AND_CONTINUE = NO;
				OPTIMIZATION_CFLAGS = "-Os";
				OTHER_LDFLAGS = "\U0001-prebind";
				TEMP_DIR = "${OBJROOT}/Deployment.build/$(PROJECT_NAME).build/$(TARGET_NAME).build";
				ZERO_LINK = NO;







<
<














<
<







197
198
199
200
201
202
203


204
205
206
207
208
209
210
211
212
213
214
215
216
217


218
219
220
221
222
223
224
				F53755DD016C38D201DC9062,
			);
			isa = PBXGroup;
			refType = 4;
			sourceTree = "<group>";
		};
		F537552C016C352C01DC9062 = {


			buildSettings = {
				GCC_DYNAMIC_NO_PIC = NO;
				GCC_ENABLE_FIX_AND_CONTINUE = YES;
				GCC_GENERATE_DEBUGGING_SYMBOLS = YES;
				GCC_OPTIMIZATION_LEVEL = 0;
				OTHER_LDFLAGS = "\U0001-prebind";
				TEMP_DIR = "${OBJROOT}/Development.build/$(PROJECT_NAME).build/$(TARGET_NAME).build";
				UNSTRIPPED_PRODUCT = YES;
				ZERO_LINK = YES;
			};
			isa = PBXBuildStyle;
			name = Development;
		};
		F537552D016C352C01DC9062 = {


			buildSettings = {
				DEBUGGING_SYMBOLS = NO;
				GCC_ENABLE_FIX_AND_CONTINUE = NO;
				OPTIMIZATION_CFLAGS = "-Os";
				OTHER_LDFLAGS = "\U0001-prebind";
				TEMP_DIR = "${OBJROOT}/Deployment.build/$(PROJECT_NAME).build/$(TARGET_NAME).build";
				ZERO_LINK = NO;
498
499
500
501
502
503
504
505
506
507
508
509
510
511
512
			lastKnownFileType = sourcecode.c.h;
			path = tkMacOSXWm.h;
			refType = 2;
			sourceTree = SOURCE_ROOT;
		};
		F5375546016C376E01DC9062 = {
			children = (
				F5375548016C376E01DC9062,
				F5375549016C376E01DC9062,
				F537554A016C376E01DC9062,
				4C8A204405E0421900C18A82,
				F537554B016C376E01DC9062,
				F537554C016C376E01DC9062,
				F537554D016C376E01DC9062,
				F537554E016C376E01DC9062,







<







493
494
495
496
497
498
499

500
501
502
503
504
505
506
			lastKnownFileType = sourcecode.c.h;
			path = tkMacOSXWm.h;
			refType = 2;
			sourceTree = SOURCE_ROOT;
		};
		F5375546016C376E01DC9062 = {
			children = (

				F5375549016C376E01DC9062,
				F537554A016C376E01DC9062,
				4C8A204405E0421900C18A82,
				F537554B016C376E01DC9062,
				F537554C016C376E01DC9062,
				F537554D016C376E01DC9062,
				F537554E016C376E01DC9062,
539
540
541
542
543
544
545
546

547
548
549
550
551
552
553
554
555
			refType = 4;
			sourceTree = "<group>";
		};
		F5375548016C376E01DC9062 = {
			fileEncoding = 5;
			isa = PBXFileReference;
			lastKnownFileType = sourcecode.c.c;
			path = tkMacOSXAppInit.c;

			refType = 4;
			sourceTree = "<group>";
		};
		F5375549016C376E01DC9062 = {
			fileEncoding = 5;
			isa = PBXFileReference;
			lastKnownFileType = sourcecode.c.c;
			path = tkMacOSXBitmap.c;
			refType = 4;







|
>
|
|







533
534
535
536
537
538
539
540
541
542
543
544
545
546
547
548
549
550
			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;
1641
1642
1643
1644
1645
1646
1647

1648
1649
1650
1651
1652
1653
1654
			name = tkWindow.c;
			path = ../generic/tkWindow.c;
			refType = 2;
			sourceTree = SOURCE_ROOT;
		};
		F53755C9016C389901DC9062 = {
			children = (

				F53755CA016C389901DC9062,
				F53755CB016C389901DC9062,
			);
			isa = PBXGroup;
			name = Unix;
			refType = 4;
			sourceTree = "<group>";







>







1636
1637
1638
1639
1640
1641
1642
1643
1644
1645
1646
1647
1648
1649
1650
			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>";
1846
1847
1848
1849
1850
1851
1852
1853
1854
1855
1856
1857
1858
1859
1860
1861
			isa = PBXGroup;
			name = Products;
			refType = 4;
			sourceTree = "<group>";
		};
		F53755DE016C38D201DC9062 = {
			explicitFileType = wrapper.framework;
			fallbackIsa = PBXFileReference;
			isa = PBXFrameworkReference;
			path = Tk.framework;
			refType = 3;
			sourceTree = BUILT_PRODUCTS_DIR;
		};
		F53755DF016C38D201DC9062 = {
			buildPhases = (
				F5877FB7031F97ED016F146B,







|
<







1842
1843
1844
1845
1846
1847
1848
1849

1850
1851
1852
1853
1854
1855
1856
			isa = PBXGroup;
			name = Products;
			refType = 4;
			sourceTree = "<group>";
		};
		F53755DE016C38D201DC9062 = {
			explicitFileType = wrapper.framework;
			isa = PBXFileReference;

			path = Tk.framework;
			refType = 3;
			sourceTree = BUILT_PRODUCTS_DIR;
		};
		F53755DF016C38D201DC9062 = {
			buildPhases = (
				F5877FB7031F97ED016F146B,
1869
1870
1871
1872
1873
1874
1875
1876
1877
1878
1879
1880
1881
1882
1883
				F548F8C80313C9E0016F146B,
				F5C1D51901B88F9A01DC9062,
				F52D38C5031F4259016F146B,
				F5877FBC031FA968016F146B,
				F9A61D2F04C2C861006F5A0B,
			);
			buildSettings = {
				DOCDIR = "${INSTALL_PATH}/${PRODUCT_NAME}.${WRAPPER_EXTENSION}/Versions/${FRAMEWORK_VERSION}/Resources/English.lproj/Documentation/Reference";
				DYLIB_COMPATIBILITY_VERSION = 8.5;
				DYLIB_CURRENT_VERSION = "$(FRAMEWORK_VERSION)";
				DYLIB_INSTALL_PATH = /Library/Frameworks;
				FRAMEWORK_SEARCH_PATHS = "\"$(TCL_FRAMEWORK_DIR)\"";
				FRAMEWORK_VERSION = 8.5;
				GLOBAL_CFLAGS = "`source \"${TCL_FRAMEWORK_DIR}/Tcl.framework/tclConfig.sh\"; echo $${}{TCL_EXTRA_CFLAGS} $${}{TCL_DEFS} | sed -e 's|\\\\\\\\\\\\\\\"|\\\"|g' | sed -e 's| -DTCL_WIDE_INT_TYPE=long. long||'` -U_REENTRANT";
				HEADER_SEARCH_PATHS = "\"$(TCL_FRAMEWORK_DIR)/Tcl.framework/Headers\" \"$(TCL_FRAMEWORK_DIR)/Tcl.framework/PrivateHeaders\" . ../bitmaps ../generic ../xlib";







|







1864
1865
1866
1867
1868
1869
1870
1871
1872
1873
1874
1875
1876
1877
1878
				F548F8C80313C9E0016F146B,
				F5C1D51901B88F9A01DC9062,
				F52D38C5031F4259016F146B,
				F5877FBC031FA968016F146B,
				F9A61D2F04C2C861006F5A0B,
			);
			buildSettings = {
				DOCDIR = "${INSTALL_PATH}/${PRODUCT_NAME}.${WRAPPER_EXTENSION}/Versions/${FRAMEWORK_VERSION}/Resources/Documentation/Reference";
				DYLIB_COMPATIBILITY_VERSION = 8.5;
				DYLIB_CURRENT_VERSION = "$(FRAMEWORK_VERSION)";
				DYLIB_INSTALL_PATH = /Library/Frameworks;
				FRAMEWORK_SEARCH_PATHS = "\"$(TCL_FRAMEWORK_DIR)\"";
				FRAMEWORK_VERSION = 8.5;
				GLOBAL_CFLAGS = "`source \"${TCL_FRAMEWORK_DIR}/Tcl.framework/tclConfig.sh\"; echo $${}{TCL_EXTRA_CFLAGS} $${}{TCL_DEFS} | sed -e 's|\\\\\\\\\\\\\\\"|\\\"|g' | sed -e 's| -DTCL_WIDE_INT_TYPE=long. long||'` -U_REENTRANT";
				HEADER_SEARCH_PATHS = "\"$(TCL_FRAMEWORK_DIR)/Tcl.framework/Headers\" \"$(TCL_FRAMEWORK_DIR)/Tcl.framework/PrivateHeaders\" . ../bitmaps ../generic ../xlib";
1913
1914
1915
1916
1917
1918
1919
1920
1921
1922
1923
1924
1925
1926
1927
<plist version=\"1.0\">
<dict>
	<key>CFBundleDevelopmentRegion</key>
	<string>English</string>
	<key>CFBundleExecutable</key>
	<string>Tk</string>
	<key>CFBundleGetInfoString</key>
	<string>Tk Library 8.5, Copyright © 2003 Tcl Core Team.
MacOS X Port by Jim Ingham &lt;[email protected]&gt; &amp; Ian Reid, Copyright © 2001-2002, Apple Computer, Inc.</string>
	<key>CFBundleIconFile</key>
	<string></string>
	<key>CFBundleIdentifier</key>
	<string>com.tcltk.tklibrary</string>
	<key>CFBundleInfoDictionaryVersion</key>
	<string>6.0</string>







|







1908
1909
1910
1911
1912
1913
1914
1915
1916
1917
1918
1919
1920
1921
1922
<plist version=\"1.0\">
<dict>
	<key>CFBundleDevelopmentRegion</key>
	<string>English</string>
	<key>CFBundleExecutable</key>
	<string>Tk</string>
	<key>CFBundleGetInfoString</key>
	<string>Tk Library 8.5, Copyright © 2004 Tcl Core Team.
MacOS X Port by Jim Ingham &lt;[email protected]&gt; &amp; Ian Reid, Copyright © 2001-2002, Apple Computer, Inc.</string>
	<key>CFBundleIconFile</key>
	<string></string>
	<key>CFBundleIdentifier</key>
	<string>com.tcltk.tklibrary</string>
	<key>CFBundleInfoDictionaryVersion</key>
	<string>6.0</string>
3052
3053
3054
3055
3056
3057
3058
3059
3060
3061
3062
3063
3064
3065
3066
3067
			);
			isa = PBXGroup;
			name = "External Frameworks";
			refType = 4;
			sourceTree = "<group>";
		};
		F537567D016C3ADB01DC9062 = {
			fallbackIsa = PBXFileReference;
			isa = PBXFrameworkReference;
			lastKnownFileType = wrapper.framework;
			name = Carbon.framework;
			path = /System/Library/Frameworks/Carbon.framework;
			refType = 0;
			sourceTree = "<absolute>";
		};
		F537567E016C3ADB01DC9062 = {







|
<







3047
3048
3049
3050
3051
3052
3053
3054

3055
3056
3057
3058
3059
3060
3061
			);
			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>";
		};
		F537567E016C3ADB01DC9062 = {
3256
3257
3258
3259
3260
3261
3262
3263
3264
3265
3266
3267
3268
3269
3270
3271
			fileRef = F53755BB016C389901DC9062;
			isa = PBXBuildFile;
			settings = {
			};
		};
		F537569F016C4DD401DC9062 = {
			explicitFileType = wrapper.application;
			fallbackIsa = PBXFileReference;
			isa = PBXApplicationReference;
			path = "Wish Shell.app";
			refType = 3;
			sourceTree = BUILT_PRODUCTS_DIR;
		};
		F53756A0016C4DD401DC9062 = {
			buildPhases = (
				F5877FB8031F982D016F146B,







|
<







3250
3251
3252
3253
3254
3255
3256
3257

3258
3259
3260
3261
3262
3263
3264
			fileRef = F53755BB016C389901DC9062;
			isa = PBXBuildFile;
			settings = {
			};
		};
		F537569F016C4DD401DC9062 = {
			explicitFileType = wrapper.application;
			isa = PBXFileReference;

			path = "Wish Shell.app";
			refType = 3;
			sourceTree = BUILT_PRODUCTS_DIR;
		};
		F53756A0016C4DD401DC9062 = {
			buildPhases = (
				F5877FB8031F982D016F146B,
3356
3357
3358
3359
3360
3361
3362
3363
3364
3365
3366
3367
3368
3369
3370
3371
</plist>
";
		};
		F53756A1016C4DD401DC9062 = {
			buildActionMask = 2147483647;
			files = (
				F53756AC016C4E1D01DC9062,
				F53756AD016C4E1D01DC9062,
				F53756AE016C4E1D01DC9062,
			);
			isa = PBXHeadersBuildPhase;
			runOnlyForDeploymentPostprocessing = 0;
		};
		F53756A2016C4DD401DC9062 = {
			buildActionMask = 2147483647;
			files = (







<
<







3349
3350
3351
3352
3353
3354
3355


3356
3357
3358
3359
3360
3361
3362
</plist>
";
		};
		F53756A1016C4DD401DC9062 = {
			buildActionMask = 2147483647;
			files = (
				F53756AC016C4E1D01DC9062,


			);
			isa = PBXHeadersBuildPhase;
			runOnlyForDeploymentPostprocessing = 0;
		};
		F53756A2016C4DD401DC9062 = {
			buildActionMask = 2147483647;
			files = (
3428
3429
3430
3431
3432
3433
3434
3435
3436
3437
3438
3439
3440
3441
3442
3443
3444
3445
3446
3447
3448
3449
3450
3451
3452
3453
		};
		F53756AC016C4E1D01DC9062 = {
			fileRef = F537556B016C37A601DC9062;
			isa = PBXBuildFile;
			settings = {
			};
		};
		F53756AD016C4E1D01DC9062 = {
			fileRef = F5375570016C37A601DC9062;
			isa = PBXBuildFile;
			settings = {
			};
		};
		F53756AE016C4E1D01DC9062 = {
			fileRef = F537553E016C376E01DC9062;
			isa = PBXBuildFile;
			settings = {
			};
		};
		F53756B2016C525F01DC9062 = {
			isa = PBXTargetDependency;
			target = F53755DF016C38D201DC9062;
			targetProxy = 4C8A204105E041E800C18A82;
		};
		F548F8C80313C9E0016F146B = {
			buildActionMask = 2147483647;







<
<
<
<
<
<
<
<
<
<
<
<







3419
3420
3421
3422
3423
3424
3425












3426
3427
3428
3429
3430
3431
3432
		};
		F53756AC016C4E1D01DC9062 = {
			fileRef = F537556B016C37A601DC9062;
			isa = PBXBuildFile;
			settings = {
			};
		};












		F53756B2016C525F01DC9062 = {
			isa = PBXTargetDependency;
			target = F53755DF016C38D201DC9062;
			targetProxy = 4C8A204105E041E800C18A82;
		};
		F548F8C80313C9E0016F146B = {
			buildActionMask = 2147483647;
3510
3511
3512
3513
3514
3515
3516
3517
3518
3519
3520
3521
3522
3523
3524
3525
			name = TkStubLibrary;
			productInstallPath = /usr/local/lib;
			productName = TkStub;
			productReference = F548F8CF0313CEF0016F146B;
		};
		F548F8CF0313CEF0016F146B = {
			explicitFileType = "compiled.mach-o.dylib";
			fallbackIsa = PBXFileReference;
			isa = PBXLibraryReference;
			path = libtkstub8.5.a;
			refType = 3;
			sourceTree = BUILT_PRODUCTS_DIR;
		};
		F548F8D00313CF11016F146B = {
			fileRef = F53755B9016C389901DC9062;
			isa = PBXBuildFile;







|
<







3489
3490
3491
3492
3493
3494
3495
3496

3497
3498
3499
3500
3501
3502
3503
			name = TkStubLibrary;
			productInstallPath = /usr/local/lib;
			productName = TkStub;
			productReference = F548F8CF0313CEF0016F146B;
		};
		F548F8CF0313CEF0016F146B = {
			explicitFileType = "compiled.mach-o.dylib";
			isa = PBXFileReference;

			path = libtkstub8.5.a;
			refType = 3;
			sourceTree = BUILT_PRODUCTS_DIR;
		};
		F548F8D00313CF11016F146B = {
			fileRef = F53755B9016C389901DC9062;
			isa = PBXBuildFile;
3572
3573
3574
3575
3576
3577
3578
3579
3580
3581
3582
3583
3584
3585
3586
3587
		F55BC46B02B2D3F301DC9062 = {
			fileRef = F55BC46A02B2D3F301DC9062;
			isa = PBXBuildFile;
			settings = {
			};
		};
		F5875C7B016FEF1D01DC9062 = {
			fallbackIsa = PBXFileReference;
			isa = PBXFrameworkReference;
			lastKnownFileType = wrapper.framework;
			name = Tcl.framework;
			path = ../tcl/Tcl.framework;
			refType = 3;
			sourceTree = BUILT_PRODUCTS_DIR;
		};
		F5875C7D016FEF1D01DC9062 = {







|
<







3550
3551
3552
3553
3554
3555
3556
3557

3558
3559
3560
3561
3562
3563
3564
		F55BC46B02B2D3F301DC9062 = {
			fileRef = F55BC46A02B2D3F301DC9062;
			isa = PBXBuildFile;
			settings = {
			};
		};
		F5875C7B016FEF1D01DC9062 = {
			isa = PBXFileReference;

			lastKnownFileType = wrapper.framework;
			name = Tcl.framework;
			path = ../tcl/Tcl.framework;
			refType = 3;
			sourceTree = BUILT_PRODUCTS_DIR;
		};
		F5875C7D016FEF1D01DC9062 = {
4047
4048
4049
4050
4051
4052
4053
4054
4055
4056
4057
4058
4059
4060
4061
4062
4063
			lastKnownFileType = text;
			name = console.tcl;
			path = ../library/console.tcl;
			refType = 2;
			sourceTree = SOURCE_ROOT;
		};
		F5DF092E016CD3F901DC9062 = {
			fallbackIsa = PBXFileReference;
			includeInIndex = 0;
			isa = PBXFolderReference;
			lastKnownFileType = folder;
			name = demos;
			path = ../library/demos;
			refType = 2;
			sourceTree = SOURCE_ROOT;
		};
		F5DF092F016CD3F901DC9062 = {







<

|







4024
4025
4026
4027
4028
4029
4030

4031
4032
4033
4034
4035
4036
4037
4038
4039
			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 = {
4081
4082
4083
4084
4085
4086
4087
4088
4089
4090
4091
4092
4093
4094
4095
4096
4097
			lastKnownFileType = text;
			name = focus.tcl;
			path = ../library/focus.tcl;
			refType = 2;
			sourceTree = SOURCE_ROOT;
		};
		F5DF0932016CD3F901DC9062 = {
			fallbackIsa = PBXFileReference;
			includeInIndex = 0;
			isa = PBXFolderReference;
			lastKnownFileType = folder;
			name = images;
			path = ../library/images;
			refType = 2;
			sourceTree = SOURCE_ROOT;
		};
		F5DF0933016CD3F901DC9062 = {







<

|







4057
4058
4059
4060
4061
4062
4063

4064
4065
4066
4067
4068
4069
4070
4071
4072
			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 = {
4115
4116
4117
4118
4119
4120
4121
4122
4123
4124
4125
4126
4127
4128
4129
4130
4131
			lastKnownFileType = text;
			name = msgbox.tcl;
			path = ../library/msgbox.tcl;
			refType = 2;
			sourceTree = SOURCE_ROOT;
		};
		F5DF0936016CD3F901DC9062 = {
			fallbackIsa = PBXFileReference;
			includeInIndex = 0;
			isa = PBXFolderReference;
			lastKnownFileType = folder;
			name = msgs;
			path = ../library/msgs;
			refType = 2;
			sourceTree = SOURCE_ROOT;
		};
		F5DF0937016CD3F901DC9062 = {







<

|







4090
4091
4092
4093
4094
4095
4096

4097
4098
4099
4100
4101
4102
4103
4104
4105
			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 = {

Deleted macosx/tkMacOSXAppInit.c.

1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
165
166
167
168
169
170
171
172
173
174
175
176
177
178
179
180
181
182
183
184
185
186
187
188
189
190
191
192
193
194
195
196
197
198
199
200
201
202
203
204
205
206
207
208
209
210
211
212
213
214
215
216
217
218
219
220
221
222
223
224
225
226
227
228
229
230
231
232
233
234
235
236
237
238
239
240
241
242
243
/* 
 * tkAppInit.c --
 *
 *        Provides a default version of the Tcl_AppInit procedure for
 *        use in wish and similar Tk-based applications.
 *
 * Copyright (c) 1993 The Regents of the University of California.
 * Copyright (c) 1994-1997 Sun Microsystems, Inc.
 * Copyright 2001, Apple Computer, Inc.
 *
 * See the file "license.terms" for information on usage and redistribution
 * of this file, and for a DISCLAIMER OF ALL WARRANTIES.
 *
 * RCS: @(#) $Id: tkMacOSXAppInit.c,v 1.5 2004/02/16 00:19:41 wolfsuit Exp $
 */
#include <pthread.h>
#include <sys/stat.h>
#include "tk.h"
#include "tclInt.h"
#include "locale.h"

#include <Carbon/Carbon.h>
#include "tkPort.h"
#include "tkMacOSX.h"
#include "tkMacOSXEvent.h"

/*
 * If the App is in an App package, then we want to add the Scripts
 * directory to the auto_path.  But we have to wait till after the
 * Tcl_Init is run, or it gets blown away.  This stores what we
 * figured out in main.
 */
 
char scriptPath[PATH_MAX + 1];

extern Tcl_Interp *gStdoutInterp;

#ifdef TK_TEST
extern int                Tktest_Init _ANSI_ARGS_((Tcl_Interp *interp));
#endif /* TK_TEST */

/*
 *----------------------------------------------------------------------
 *
 * main --
 *
 *        This is the main program for the application.
 *
 * Results:
 *        None: Tk_Main never returns here, so this procedure never
 *        returns either.
 *
 * Side effects:
 *        Whatever the application does.
 *
 *----------------------------------------------------------------------
 */

int
main(argc, argv)
    int argc;                        /* Number of command-line arguments. */
    char **argv;                /* Values of command-line arguments. */
{
    int textEncoding; /* 
                       * Variable used to take care of
                       * lazy font initialization
                       */
    CFBundleRef bundleRef;

    /*
     * The following #if block allows you to change the AppInit
     * function by using a #define of TCL_LOCAL_APPINIT instead
     * of rewriting this entire file.  The #if checks for that
     * #define and uses Tcl_AppInit if it doesn't exist.
     */
    
#ifndef TK_LOCAL_APPINIT
#define TK_LOCAL_APPINIT Tcl_AppInit    
#endif
    extern int TK_LOCAL_APPINIT _ANSI_ARGS_((Tcl_Interp *interp));

    scriptPath[0] = '\0';

    /*
     * The following #if block allows you to change how Tcl finds the startup
     * script, prime the library or encoding paths, fiddle with the argv,
     * etc., without needing to rewrite Tk_Main().  Note, if you use this
     * hook, then I won't do the CFBundle lookup, since if you are messing
     * around at this level, you probably don't want me to do this for you...
     */
    
#ifdef TK_LOCAL_MAIN_HOOK
    extern int TK_LOCAL_MAIN_HOOK _ANSI_ARGS_((int *argc, char ***argv));
    TK_LOCAL_MAIN_HOOK(&argc, &argv);
#else

    /*
     * On MacOS X, we look for a file in the Resources/Scripts directory
     * called AppMain.tcl and if found, we set argv[1] to that, so that
     * the rest of the code will find it, and add the Scripts folder to
     * the auto_path.  If we don't find the startup script, we just bag
     * it, assuming the user is starting up some other way.
     */
    
    bundleRef = CFBundleGetMainBundle();
    
    if (bundleRef != NULL) {
        CFURLRef appMainURL;
        appMainURL = CFBundleCopyResourceURL(bundleRef, 
                CFSTR("AppMain"), 
                CFSTR("tcl"), 
                CFSTR("Scripts"));

        if (appMainURL != NULL) {
            CFURLRef scriptFldrURL;
            char *startupScript = malloc(PATH_MAX + 1);
                            
            if (CFURLGetFileSystemRepresentation (appMainURL, true,
                    startupScript, PATH_MAX)) {
                TclSetStartupScriptFileName(startupScript);
                scriptFldrURL = CFBundleCopyResourceURL(bundleRef,
                        CFSTR("Scripts"),
                        NULL,
                        NULL);
                CFURLGetFileSystemRepresentation(scriptFldrURL, 
                        true, scriptPath, PATH_MAX);
                CFRelease(scriptFldrURL);
            } else {
                free(startupScript);
            }
            CFRelease(appMainURL);
        }
    }

#endif
    textEncoding = GetApplicationTextEncoding();
    
    /*
     * Now add the scripts folder to the auto_path.
     */
     
    Tk_Main(argc,argv,TK_LOCAL_APPINIT);
    return 0;                        /* Needed only to prevent compiler warning. */
}

/*
 *----------------------------------------------------------------------
 *
 * Tcl_AppInit --
 *
 *        This procedure performs application-specific initialization.
 *        Most applications, especially those that incorporate additional
 *        packages, will have their own version of this procedure.
 *
 * Results:
 *        Returns a standard Tcl completion code, and leaves an error
 *        message in the interp's result if an error occurs.
 *
 * Side effects:
 *        Depends on the startup script.
 *
 *----------------------------------------------------------------------
 */

int
Tcl_AppInit(interp)
    Tcl_Interp *interp;                /* Interpreter for application. */
{        
    if (Tcl_Init(interp) == TCL_ERROR) {
        return TCL_ERROR;
    }    
    if (Tk_Init(interp) == TCL_ERROR) {
        return TCL_ERROR;
    }
    Tcl_StaticPackage(interp, "Tk", Tk_Init, Tk_SafeInit);

    if (scriptPath[0] != '\0') {
        Tcl_SetVar(interp, "auto_path", scriptPath,
                TCL_GLOBAL_ONLY|TCL_LIST_ELEMENT|TCL_APPEND_VALUE);
    }
    
#ifdef TK_TEST
    if (Tktest_Init(interp) == TCL_ERROR) {
        return TCL_ERROR;
    }
    Tcl_StaticPackage(interp, "Tktest", Tktest_Init,
            (Tcl_PackageInitProc *) NULL);
#endif /* TK_TEST */

    /*
     * If we don't have a TTY and stdin is a special character file of length 0,
     * (e.g. /dev/null, which is what Finder sets when double clicking Wish)
     * then use the Tk based console interpreter.
     */

    if (!isatty(0)) {
	struct stat st;
	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));
	    if (Tk_CreateConsoleWindow(interp) == TCL_ERROR) {
		goto error;
	    }
	    /* Only show the console if we don't have a startup script */
	    if (TclGetStartupScriptPath() == NULL) {
		Tcl_Eval(interp, "console show");
	    }
	}
    }
    
    /*
     * Call the init procedures for included packages.  Each call should
     * look like this:
     *
     * if (Mod_Init(interp) == TCL_ERROR) {
     *     return TCL_ERROR;
     * }
     *
     * where "Mod" is the name of the module.
     */

    /*
     * Call Tcl_CreateCommand for application-specific commands, if
     * they weren't already created by the init procedures called above.
     */

    
    /*
     * Specify a user-specific startup file to invoke if the application
     * is run interactively.  Typically the startup file is "~/.apprc"
     * where "app" is the name of the application.  If this line is deleted
     * then no user-specific startup file will be run under any conditions.
     */
     
    Tcl_SetVar(interp, "tcl_rcFileName", "~/.wishrc", TCL_GLOBAL_ONLY);

    return TCL_OK;

    error:
    return TCL_ERROR;
}
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<






































































































































































































































































































































































































































































































Changes to macosx/tkMacOSXDefault.h.

1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
/*
 * tkMacOSXDefault.h --
 *
 *	This file defines the defaults for all options for all of
 *	the Tk widgets.
 *
 * Copyright (c) 1991-1994 The Regents of the University of California.
 * Copyright (c) 1994-1997 Sun Microsystems, Inc.
 * Copyright 2001, Apple Computer, Inc.
 *
 * See the file "license.terms" for information on usage and redistribution
 * of this file, and for a DISCLAIMER OF ALL WARRANTIES.
 *
 * RCS: @(#) $Id: tkMacOSXDefault.h,v 1.5 2004/10/24 17:22:55 dkf Exp $
 */

#ifndef _TKMACDEFAULT
#define _TKMACDEFAULT

/*
 * The definitions below provide symbolic names for the default colors.













|







1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
/*
 * tkMacOSXDefault.h --
 *
 *	This file defines the defaults for all options for all of
 *	the Tk widgets.
 *
 * Copyright (c) 1991-1994 The Regents of the University of California.
 * Copyright (c) 1994-1997 Sun Microsystems, Inc.
 * Copyright 2001, Apple Computer, Inc.
 *
 * See the file "license.terms" for information on usage and redistribution
 * of this file, and for a DISCLAIMER OF ALL WARRANTIES.
 *
 * RCS: @(#) $Id: tkMacOSXDefault.h,v 1.6 2004/11/11 01:24:32 das Exp $
 */

#ifndef _TKMACDEFAULT
#define _TKMACDEFAULT

/*
 * The definitions below provide symbolic names for the default colors.
291
292
293
294
295
296
297





298
299
300
301
302
303
304
305
#define DEF_MENU_FONT			"system"
#define DEF_MENU_FG			"SystemMenuText"
#define DEF_MENU_POST_COMMAND		""
#define DEF_MENU_RELIEF			"flat"
#define DEF_MENU_SELECT_COLOR		"SystemMenuActive"
#define DEF_MENU_SELECT_MONO		BLACK
#define DEF_MENU_TAKE_FOCUS		"0"





#define DEF_MENU_TEAROFF		"1"
#define DEF_MENU_TEAROFF_CMD		(char *) NULL
#define DEF_MENU_TITLE			""
#define DEF_MENU_TYPE			"normal"

/*
 * Defaults for menubuttons:
 */







>
>
>
>
>
|







291
292
293
294
295
296
297
298
299
300
301
302
303
304
305
306
307
308
309
310
#define DEF_MENU_FONT			"system"
#define DEF_MENU_FG			"SystemMenuText"
#define DEF_MENU_POST_COMMAND		""
#define DEF_MENU_RELIEF			"flat"
#define DEF_MENU_SELECT_COLOR		"SystemMenuActive"
#define DEF_MENU_SELECT_MONO		BLACK
#define DEF_MENU_TAKE_FOCUS		"0"

/*
 * FIXME: Turn the default back to 1 when we make tearoff menus work again.
 */
 
#define DEF_MENU_TEAROFF		"0"
#define DEF_MENU_TEAROFF_CMD		(char *) NULL
#define DEF_MENU_TITLE			""
#define DEF_MENU_TYPE			"normal"

/*
 * Defaults for menubuttons:
 */

Changes to macosx/tkMacOSXDraw.c.

1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16

17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43

44
45
46
47
48
49
50
51
52
53































54
55
56
57
58
59
60
/* 
 * tkMacOSXDraw.c --
 *
 *        This file contains functions that perform drawing to
 *        Xlib windows.  Most of the functions simple emulate
 *        Xlib functions.
 *
 * Copyright (c) 1995-1997 Sun Microsystems, Inc.
 * Copyright 2001, Apple Computer, Inc.
 *
 * See the file "license.terms" for information on usage and redistribution
 * of this file, and for a DISCLAIMER OF ALL WARRANTIES.
 *
 * RCS: @(#) $Id: tkMacOSXDraw.c,v 1.4 2004/02/23 10:48:10 das Exp $
 */


#include "tkInt.h"
#include "X11/X.h"
#include "X11/Xlib.h"
#include <stdio.h>

#include <Carbon/Carbon.h>
#include "tkMacOSXInt.h"
#include "tkPort.h"
#include "tkMacOSXDebug.h"

#ifndef PI
#    define PI 3.14159265358979323846
#endif
#define RGBFLOATRED( c )	(float)((float)(c.red) / 65535.0)
#define RGBFLOATGREEN( c )	(float)((float)(c.green) / 65535.0)
#define RGBFLOATBLUE( c )	(float)((float)(c.blue) / 65535.0)

/*
 * Temporary regions that can be reused.
 */

static RgnHandle tmpRgn = NULL;
static RgnHandle tmpRgn2 = NULL;

static PixPatHandle gPenPat = NULL;

static int useCGDrawing = 0;


/*
 * Prototypes for functions used only in this file.
 */
static unsigned char    InvertByte _ANSI_ARGS_((unsigned char data));

void TkMacOSXSetUpCGContext(MacDrawable *macWin,
    CGrafPtr destPort, GC gc,  CGContextRef *contextPtr);
void TkMacOSXReleaseCGContext(MacDrawable *macWin, CGrafPtr destPort, 
        CGContextRef *context);































/*
 *----------------------------------------------------------------------
 *
 * XCopyArea --
 *
 *        Copies data from one drawable to another using block transfer
 *        routines.













|


>













|
|
|










|
>










>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>







1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
/* 
 * tkMacOSXDraw.c --
 *
 *        This file contains functions that perform drawing to
 *        Xlib windows.  Most of the functions simple emulate
 *        Xlib functions.
 *
 * Copyright (c) 1995-1997 Sun Microsystems, Inc.
 * Copyright 2001, Apple Computer, Inc.
 *
 * See the file "license.terms" for information on usage and redistribution
 * of this file, and for a DISCLAIMER OF ALL WARRANTIES.
 *
 * RCS: @(#) $Id: tkMacOSXDraw.c,v 1.5 2004/11/11 01:24:32 das Exp $
 */

#include "tclInt.h"
#include "tkInt.h"
#include "X11/X.h"
#include "X11/Xlib.h"
#include <stdio.h>

#include <Carbon/Carbon.h>
#include "tkMacOSXInt.h"
#include "tkPort.h"
#include "tkMacOSXDebug.h"

#ifndef PI
#    define PI 3.14159265358979323846
#endif
#define RGBFLOATRED(c)	(float)((float)(c.red) / 65535.0f)
#define RGBFLOATGREEN(c)	(float)((float)(c.green) / 65535.0f)
#define RGBFLOATBLUE(c)	(float)((float)(c.blue) / 65535.0f)

/*
 * Temporary regions that can be reused.
 */

static RgnHandle tmpRgn = NULL;
static RgnHandle tmpRgn2 = NULL;

static PixPatHandle gPenPat = NULL;

static int useCGDrawing = 1;
static int tkMacOSXCGAntiAliasLimit = 1;

/*
 * Prototypes for functions used only in this file.
 */
static unsigned char    InvertByte _ANSI_ARGS_((unsigned char data));

void TkMacOSXSetUpCGContext(MacDrawable *macWin,
    CGrafPtr destPort, GC gc,  CGContextRef *contextPtr);
void TkMacOSXReleaseCGContext(MacDrawable *macWin, CGrafPtr destPort, 
        CGContextRef *context);
static inline double radians(double degrees) { return degrees * PI / 180.0f; }

int 
TkMacOSXInitCGDrawing(interp, enable, limit)
        Tcl_Interp *interp;
        int enable;
        int limit;
{
    static Boolean initialized = FALSE;
    
    if (!initialized) {
        if (Tcl_CreateNamespace(interp, "::tk::mac", NULL, NULL) == NULL) {
            Tcl_ResetResult(interp);
        }
        if (Tcl_LinkVar(interp, "::tk::mac::useCGDrawing",
                (char *) &useCGDrawing, 
                TCL_LINK_BOOLEAN) != TCL_OK) {
            Tcl_ResetResult(interp);
        }
        useCGDrawing = enable;
        
        if (Tcl_LinkVar(interp, "::tk::mac::CGAntialiasLimit",
                (char *) &tkMacOSXCGAntiAliasLimit, 
                TCL_LINK_INT) != TCL_OK) {
            Tcl_ResetResult(interp);
        }
        tkMacOSXCGAntiAliasLimit = limit;
    }
    return TCL_OK;
}

/*
 *----------------------------------------------------------------------
 *
 * XCopyArea --
 *
 *        Copies data from one drawable to another using block transfer
 *        routines.
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147

148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
165
166
167
168
169
170
171
172
173
174
175
176
177
178
179
180
181
    
    if (tmpRgn2 == NULL) {
        tmpRgn2 = NewRgn();
    }
    srcPtr = &srcRect;
    SetRect(&srcRect, (short) (srcDraw->xOff + src_x),
            (short) (srcDraw->yOff + src_y),
            (short) (srcDraw->xOff + src_x + width ),
            (short) (srcDraw->yOff + src_y + height));        
    if (tkPictureIsOpen ) {
        dstPtr = &srcRect;
    } else {
        dstPtr = &dstRect;
        SetRect(&dstRect, (short) (dstDraw->xOff + dest_x),
            (short) (dstDraw->yOff + dest_y), 
            (short) (dstDraw->xOff + dest_x + width ),
            (short) (dstDraw->yOff + dest_y + height));        
    }
    TkMacOSXSetUpClippingRgn(dst);
    /*
     *  We will change the clip rgn in this routine, so we need to 
     *  be able to restore it when we exit.
     */
 
    GetClip(tmpRgn2);
    if (tkPictureIsOpen) {
        /*
         * When rendering into a picture, after a call to "OpenCPicture"
         * the clipping is seriously WRONG and also INCONSISTENT with the
         * clipping for single plane bitmaps.
         * To circumvent this problem,  we clip to the whole window 
         * In this case, would have also clipped to the srcRect
         * ClipRect(&srcRect);
         */

        GetPortBounds(dstPort,&clpRect);
        dstPtr = &srcRect;
        ClipRect(&clpRect);
    }
    if (!gc->clip_mask ) { 
    } else if (((TkpClipMask*)gc->clip_mask)->type == TKP_CLIP_REGION) {
        RgnHandle clipRgn = (RgnHandle)
            ((TkpClipMask*)gc->clip_mask)->value.region;
 
        int xOffset, yOffset;
        if (tmpRgn == NULL) {
            tmpRgn = NewRgn();
        }
        if (!tkPictureIsOpen) {
            xOffset = dstDraw->xOff + gc->clip_x_origin;
            yOffset = dstDraw->yOff + gc->clip_y_origin;
            OffsetRgn(clipRgn, xOffset, yOffset);
        }
        GetClip(tmpRgn);
        SectRgn(tmpRgn, clipRgn, tmpRgn);
        SetClip(tmpRgn);
        if (!tkPictureIsOpen) {
             OffsetRgn(clipRgn, -xOffset, -yOffset);
        }
    }
    srcBit = GetPortBitMapForCopyBits( srcPort );
    dstBit = GetPortBitMapForCopyBits( dstPort );
    tmode = srcCopy;

    CopyBits(srcBit, dstBit, srcPtr, dstPtr, tmode, NULL);
    RGBForeColor(&origForeColor);
    RGBBackColor(&origBackColor);
    SetClip(tmpRgn2);
    SetGWorld(saveWorld, saveDevice);







|

|





|


















>




|


|

















|
|







147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
165
166
167
168
169
170
171
172
173
174
175
176
177
178
179
180
181
182
183
184
185
186
187
188
189
190
191
192
193
194
195
196
197
198
199
200
201
202
203
204
205
206
207
208
209
210
211
212
213
214
215
    
    if (tmpRgn2 == NULL) {
        tmpRgn2 = NewRgn();
    }
    srcPtr = &srcRect;
    SetRect(&srcRect, (short) (srcDraw->xOff + src_x),
            (short) (srcDraw->yOff + src_y),
            (short) (srcDraw->xOff + src_x + width),
            (short) (srcDraw->yOff + src_y + height));        
    if (tkPictureIsOpen) {
        dstPtr = &srcRect;
    } else {
        dstPtr = &dstRect;
        SetRect(&dstRect, (short) (dstDraw->xOff + dest_x),
            (short) (dstDraw->yOff + dest_y), 
            (short) (dstDraw->xOff + dest_x + width),
            (short) (dstDraw->yOff + dest_y + height));        
    }
    TkMacOSXSetUpClippingRgn(dst);
    /*
     *  We will change the clip rgn in this routine, so we need to 
     *  be able to restore it when we exit.
     */
 
    GetClip(tmpRgn2);
    if (tkPictureIsOpen) {
        /*
         * When rendering into a picture, after a call to "OpenCPicture"
         * the clipping is seriously WRONG and also INCONSISTENT with the
         * clipping for single plane bitmaps.
         * To circumvent this problem,  we clip to the whole window 
         * In this case, would have also clipped to the srcRect
         * ClipRect(&srcRect);
         */

        GetPortBounds(dstPort,&clpRect);
        dstPtr = &srcRect;
        ClipRect(&clpRect);
    }
    if (!gc->clip_mask) { 
    } else if (((TkpClipMask*)gc->clip_mask)->type == TKP_CLIP_REGION) {
        RgnHandle clipRgn = (RgnHandle)
                ((TkpClipMask*)gc->clip_mask)->value.region;
 
        int xOffset, yOffset;
        if (tmpRgn == NULL) {
            tmpRgn = NewRgn();
        }
        if (!tkPictureIsOpen) {
            xOffset = dstDraw->xOff + gc->clip_x_origin;
            yOffset = dstDraw->yOff + gc->clip_y_origin;
            OffsetRgn(clipRgn, xOffset, yOffset);
        }
        GetClip(tmpRgn);
        SectRgn(tmpRgn, clipRgn, tmpRgn);
        SetClip(tmpRgn);
        if (!tkPictureIsOpen) {
             OffsetRgn(clipRgn, -xOffset, -yOffset);
        }
    }
    srcBit = GetPortBitMapForCopyBits(srcPort);
    dstBit = GetPortBitMapForCopyBits(dstPort);
    tmode = srcCopy;

    CopyBits(srcBit, dstBit, srcPtr, dstPtr, tmode, NULL);
    RGBForeColor(&origForeColor);
    RGBBackColor(&origBackColor);
    SetClip(tmpRgn2);
    SetGWorld(saveWorld, saveDevice);
221
222
223
224
225
226
227
228
229
230
231
232
233
234
235
236
237
238
239
240
241
242
243
244
245
246
247
248
249
250
251
252
253
254
255
256
257

258
259
260
261
262
263
264
265
266
267
268
269
270
271
272
273
274
275
276
277
278
279
280

281
282
283
284
285
286
287
288
289
290
291

292
293
294
295
296
297
298
299
300
301
302

303
304
305
306
307
308
309
310
311
312
    const BitMap * mskBit;
    MacDrawable *srcDraw = (MacDrawable *) src;
    MacDrawable *dstDraw = (MacDrawable *) dst;
    GWorldPtr srcPort, dstPort, mskPort;
    CGrafPtr saveWorld;
    GDHandle saveDevice;
    RGBColor macColor; 
    TkpClipMask *clipPtr = (TkpClipMask*)gc->clip_mask;
    short tmode;

    srcPort = TkMacOSXGetDrawablePort(src);
    dstPort = TkMacOSXGetDrawablePort(dst);
    
    if (tmpRgn == NULL) {
        tmpRgn = NewRgn();
    }
    display->request++;
    GetGWorld(&saveWorld, &saveDevice);
    SetGWorld(dstPort, NULL);

    TkMacOSXSetUpClippingRgn(dst);


    srcBit = GetPortBitMapForCopyBits ( srcPort );
    dstBit = GetPortBitMapForCopyBits ( dstPort );
    SetRect(&srcRect, (short) (srcDraw->xOff + src_x),
            (short) (srcDraw->yOff + src_y),
            (short) (srcDraw->xOff + src_x + width),
            (short) (srcDraw->yOff + src_y + height));
    srcPtr = &srcRect;
    if (tkPictureIsOpen) {
        /*
         * When rendering into a picture, after a call to "OpenCPicture"
         * the clipping is seriously WRONG and also INCONSISTENT with the
         * clipping for color bitmaps.
         * To circumvent this problem,  we clip to the whole window 
         */

        Rect clpRect;
        GetPortBounds(dstPort,&clpRect);
        ClipRect(&clpRect);
        dstPtr = &srcRect;
    } else {
        dstPtr = &dstRect;
        SetRect(&dstRect, (short) (dstDraw->xOff + dest_x),
            (short) (dstDraw->yOff + dest_y), 
            (short) (dstDraw->xOff + dest_x + width),
            (short) (dstDraw->yOff + dest_y + height));
    }
    tmode = srcOr;
    tmode = srcCopy + transparent;

    if (TkSetMacColor(gc->foreground, &macColor) == true) {
        RGBForeColor(&macColor);
    }

    if (clipPtr == NULL || clipPtr->type == TKP_CLIP_REGION) {

        /*
         * Case 1: opaque bitmaps.
         */

        TkSetMacColor(gc->background, &macColor);
        RGBBackColor(&macColor);
        tmode = srcCopy;
        CopyBits(srcBit, dstBit, srcPtr, dstPtr, tmode, NULL);
    } else if (clipPtr->type == TKP_CLIP_PIXMAP) {
        if (clipPtr->value.pixmap == src) {
            PixMapHandle pm;
            /*
             * Case 2: transparent bitmaps.  If it's color we ignore
             * the forecolor.
             */

            pm = GetPortPixMap(srcPort);
            if (GetPixDepth(pm) == 1) {
                tmode = srcOr;
            } else {
                tmode = transparent;
            }
            CopyBits(srcBit, dstBit, srcPtr, dstPtr, tmode, NULL);
        } else {
            /*
             * Case 3: two arbitrary bitmaps.         
             */

            tmode = srcCopy;
            mskPort = TkMacOSXGetDrawablePort(clipPtr->value.pixmap);
            mskBit = GetPortBitMapForCopyBits ( mskPort );
            CopyDeepMask(srcBit, mskBit, dstBit,
                srcPtr, srcPtr, dstPtr, tmode, NULL);
        }
    }

    SetGWorld(saveWorld, saveDevice);
}







|















|
|












>







|
|
|









<



>











>











>


|







255
256
257
258
259
260
261
262
263
264
265
266
267
268
269
270
271
272
273
274
275
276
277
278
279
280
281
282
283
284
285
286
287
288
289
290
291
292
293
294
295
296
297
298
299
300
301
302
303
304
305
306
307
308
309
310
311

312
313
314
315
316
317
318
319
320
321
322
323
324
325
326
327
328
329
330
331
332
333
334
335
336
337
338
339
340
341
342
343
344
345
346
347
348
349
    const BitMap * mskBit;
    MacDrawable *srcDraw = (MacDrawable *) src;
    MacDrawable *dstDraw = (MacDrawable *) dst;
    GWorldPtr srcPort, dstPort, mskPort;
    CGrafPtr saveWorld;
    GDHandle saveDevice;
    RGBColor macColor; 
    TkpClipMask *clipPtr = (TkpClipMask *) gc->clip_mask;
    short tmode;

    srcPort = TkMacOSXGetDrawablePort(src);
    dstPort = TkMacOSXGetDrawablePort(dst);
    
    if (tmpRgn == NULL) {
        tmpRgn = NewRgn();
    }
    display->request++;
    GetGWorld(&saveWorld, &saveDevice);
    SetGWorld(dstPort, NULL);

    TkMacOSXSetUpClippingRgn(dst);


    srcBit = GetPortBitMapForCopyBits(srcPort);
    dstBit = GetPortBitMapForCopyBits(dstPort);
    SetRect(&srcRect, (short) (srcDraw->xOff + src_x),
            (short) (srcDraw->yOff + src_y),
            (short) (srcDraw->xOff + src_x + width),
            (short) (srcDraw->yOff + src_y + height));
    srcPtr = &srcRect;
    if (tkPictureIsOpen) {
        /*
         * When rendering into a picture, after a call to "OpenCPicture"
         * the clipping is seriously WRONG and also INCONSISTENT with the
         * clipping for color bitmaps.
         * To circumvent this problem,  we clip to the whole window 
         */

        Rect clpRect;
        GetPortBounds(dstPort,&clpRect);
        ClipRect(&clpRect);
        dstPtr = &srcRect;
    } else {
        dstPtr = &dstRect;
        SetRect(&dstRect, (short) (dstDraw->xOff + dest_x),
                (short) (dstDraw->yOff + dest_y), 
                (short) (dstDraw->xOff + dest_x + width),
                (short) (dstDraw->yOff + dest_y + height));
    }
    tmode = srcOr;
    tmode = srcCopy + transparent;

    if (TkSetMacColor(gc->foreground, &macColor) == true) {
        RGBForeColor(&macColor);
    }

    if (clipPtr == NULL || clipPtr->type == TKP_CLIP_REGION) {

        /*
         * Case 1: opaque bitmaps.
         */

        TkSetMacColor(gc->background, &macColor);
        RGBBackColor(&macColor);
        tmode = srcCopy;
        CopyBits(srcBit, dstBit, srcPtr, dstPtr, tmode, NULL);
    } else if (clipPtr->type == TKP_CLIP_PIXMAP) {
        if (clipPtr->value.pixmap == src) {
            PixMapHandle pm;
            /*
             * Case 2: transparent bitmaps.  If it's color we ignore
             * the forecolor.
             */

            pm = GetPortPixMap(srcPort);
            if (GetPixDepth(pm) == 1) {
                tmode = srcOr;
            } else {
                tmode = transparent;
            }
            CopyBits(srcBit, dstBit, srcPtr, dstPtr, tmode, NULL);
        } else {
            /*
             * Case 3: two arbitrary bitmaps.         
             */

            tmode = srcCopy;
            mskPort = TkMacOSXGetDrawablePort(clipPtr->value.pixmap);
            mskBit = GetPortBitMapForCopyBits(mskPort);
            CopyDeepMask(srcBit, mskBit, dstBit,
                srcPtr, srcPtr, dstPtr, tmode, NULL);
        }
    }

    SetGWorld(saveWorld, saveDevice);
}
364
365
366
367
368
369
370
371
372
373
374
375
376
377
378

    TkMacOSXSetUpClippingRgn(d);

    if (image->obdata) {
        /* Image from XGetImage, copy from containing GWorld directly */
        GWorldPtr srcPort = TkMacOSXGetDrawablePort((Drawable)image->obdata);
        CopyBits(GetPortBitMapForCopyBits(srcPort),
                GetPortBitMapForCopyBits (destPort),
                &srcRect, &destRect, srcCopy, NULL);
    } else if (image->depth == 1) {

        /* 
         * This code assumes a pixel depth of 1 
         */








|







401
402
403
404
405
406
407
408
409
410
411
412
413
414
415

    TkMacOSXSetUpClippingRgn(d);

    if (image->obdata) {
        /* Image from XGetImage, copy from containing GWorld directly */
        GWorldPtr srcPort = TkMacOSXGetDrawablePort((Drawable)image->obdata);
        CopyBits(GetPortBitMapForCopyBits(srcPort),
                GetPortBitMapForCopyBits(destPort),
                &srcRect, &destRect, srcCopy, NULL);
    } else if (image->depth == 1) {

        /* 
         * This code assumes a pixel depth of 1 
         */

399
400
401
402
403
404
405
406
407
408
409
410

411


412
413
414
415
416
417
418
            newData = (char *) ckalloc(image->height * image->bytes_per_line);
            for (i = 0; i < image->height * image->bytes_per_line; i++) {
                newData[i] = InvertByte((unsigned char) image->data[i]);
            }                
            bitmap.baseAddr = newData;
            bitmap.rowBytes = image->bytes_per_line;
        }
        destBits = GetPortBitMapForCopyBits ( destPort );
        CopyBits(&bitmap, destBits, 
                &srcRect, &destRect, srcCopy, NULL);

    } else {

        /* Color image */


        PixMap pixmap;
            
        pixmap.bounds.left = 0;
        pixmap.bounds.top = 0;
        pixmap.bounds.right = (short) image->width;
        pixmap.bounds.bottom = (short) image->height;
        pixmap.pixelType = RGBDirect;







|




>
|
>
>







436
437
438
439
440
441
442
443
444
445
446
447
448
449
450
451
452
453
454
455
456
457
458
            newData = (char *) ckalloc(image->height * image->bytes_per_line);
            for (i = 0; i < image->height * image->bytes_per_line; i++) {
                newData[i] = InvertByte((unsigned char) image->data[i]);
            }                
            bitmap.baseAddr = newData;
            bitmap.rowBytes = image->bytes_per_line;
        }
        destBits = GetPortBitMapForCopyBits(destPort);
        CopyBits(&bitmap, destBits, 
                &srcRect, &destRect, srcCopy, NULL);

    } else {
        /* 
         * Color image 
         */

        PixMap pixmap;
            
        pixmap.bounds.left = 0;
        pixmap.bounds.top = 0;
        pixmap.bounds.right = (short) image->width;
        pixmap.bounds.bottom = (short) image->height;
        pixmap.pixelType = RGBDirect;
426
427
428
429
430
431
432
433
434
435
436
437
438
439
440
        pixmap.cmpSize = 8;
        pixmap.pixelFormat = k32ARGBPixelFormat;
        pixmap.pmTable = NULL;
        pixmap.pmExt = 0;
        pixmap.baseAddr = image->data;
        pixmap.rowBytes = image->bytes_per_line | 0x8000;
        
        CopyBits((BitMap *) &pixmap, GetPortBitMapForCopyBits ( destPort ), 
            &srcRect, &destRect, srcCopy, NULL);
    }
    
    if (newData != NULL) {
        ckfree(newData);
    }
    SetGWorld(saveWorld, saveDevice);







|







466
467
468
469
470
471
472
473
474
475
476
477
478
479
480
        pixmap.cmpSize = 8;
        pixmap.pixelFormat = k32ARGBPixelFormat;
        pixmap.pmTable = NULL;
        pixmap.pmExt = 0;
        pixmap.baseAddr = image->data;
        pixmap.rowBytes = image->bytes_per_line | 0x8000;
        
        CopyBits((BitMap *) &pixmap, GetPortBitMapForCopyBits(destPort), 
            &srcRect, &destRect, srcCopy, NULL);
    }
    
    if (newData != NULL) {
        ckfree(newData);
    }
    SetGWorld(saveWorld, saveDevice);
473
474
475
476
477
478
479



480












481
482
483
484
485
486
487
488

489
490
491
492
493
494
495
    destPort = TkMacOSXGetDrawablePort(d);

    display->request++;
    GetGWorld(&saveWorld, &saveDevice);
    SetGWorld(destPort, NULL);

    TkMacOSXSetUpClippingRgn(d);
















    TkMacOSXSetUpGraphicsPort(gc, destPort);

    for (i = 0; i < n_rectangles; i++) {
        theRect.left = (short) (macWin->xOff + rectangles[i].x);
        theRect.top = (short) (macWin->yOff + rectangles[i].y);
        theRect.right = (short) (theRect.left + rectangles[i].width);
        theRect.bottom = (short) (theRect.top + rectangles[i].height);
        FillCRect(&theRect, gPenPat);

    }

    SetGWorld(saveWorld, saveDevice);
}

/*
 *----------------------------------------------------------------------







>
>
>
|
>
>
>
>
>
>
>
>
>
>
>
>
|

|
|
|
|
|
|
>







513
514
515
516
517
518
519
520
521
522
523
524
525
526
527
528
529
530
531
532
533
534
535
536
537
538
539
540
541
542
543
544
545
546
547
548
549
550
551
    destPort = TkMacOSXGetDrawablePort(d);

    display->request++;
    GetGWorld(&saveWorld, &saveDevice);
    SetGWorld(destPort, NULL);

    TkMacOSXSetUpClippingRgn(d);
    if (useCGDrawing) {
        CGContextRef outContext;
	CGRect	rect;
        
        TkMacOSXSetUpCGContext(macWin, destPort, gc, &outContext);

	for (i = 0; i < n_rectangles; i++) {
	    rect = CGRectMake((float)(macWin->xOff + rectangles[i].x),
				(float)(macWin->yOff + rectangles[i].y),
				(float)rectangles[i].width,
				(float)rectangles[i].height);
	    
	    CGContextFillRect(outContext, rect);
	}
        TkMacOSXReleaseCGContext(macWin, destPort, &outContext);
    } else {
        TkMacOSXSetUpGraphicsPort(gc, destPort);

	for (i = 0; i < n_rectangles; i++) {
            theRect.left = (short) (macWin->xOff + rectangles[i].x);
            theRect.top = (short) (macWin->yOff + rectangles[i].y);
            theRect.right = (short) (theRect.left + rectangles[i].width);
            theRect.bottom = (short) (theRect.top + rectangles[i].height);
            FillCRect(&theRect, gPenPat);
        }
    }

    SetGWorld(saveWorld, saveDevice);
}

/*
 *----------------------------------------------------------------------
535
536
537
538
539
540
541
542
543
544
545

546
547
548




549
550
551
552
553
554
555

    if (useCGDrawing) {
        CGContextRef outContext;
        
        TkMacOSXSetUpCGContext(macWin, destPort, gc, &outContext);
        
        CGContextBeginPath(outContext);
        CGContextMoveToPoint(outContext, (float) points[0].x,
                (float) points[0].y);
        if (mode == CoordModeOrigin) {
            for (i = 1; i < npoints; i++) {

                CGContextAddLineToPoint(outContext,
                        (float) points[i].x,
                        (float) points[i].y); 




            }
        }
        
        CGContextStrokePath(outContext);
        TkMacOSXReleaseCGContext(macWin, destPort, &outContext);
    } else {
        TkMacOSXSetUpGraphicsPort(gc, destPort);







|
|
|
|
>

|
|
>
>
>
>







591
592
593
594
595
596
597
598
599
600
601
602
603
604
605
606
607
608
609
610
611
612
613
614
615
616

    if (useCGDrawing) {
        CGContextRef outContext;
        
        TkMacOSXSetUpCGContext(macWin, destPort, gc, &outContext);
        
        CGContextBeginPath(outContext);
        CGContextMoveToPoint(outContext, (float)(macWin->xOff + points[0].x),
                (float)(macWin->yOff + points[0].y));

        for (i = 1; i < npoints; i++) {
	    if(mode==CoordModeOrigin) {
                CGContextAddLineToPoint(outContext,
                        (float) (macWin->xOff + points[i].x),
                        (float) (macWin->yOff + points[i].y));
	    } else {
		CGContextAddLineToPoint(outContext,
                        (float)(macWin->xOff + points[i].x),
                        (float)(macWin->yOff + points[i].y));
            }
        }
        
        CGContextStrokePath(outContext);
        TkMacOSXReleaseCGContext(macWin, destPort, &outContext);
    } else {
        TkMacOSXSetUpGraphicsPort(gc, destPort);
581
582
583
584
585
586
587
588
589
590
591
592
593
594
595
 *
 *        Draw unconnected lines.
 *
 * Results:
 *        None.
 *
 * Side effects:
 *        Renders a series of connected lines.
 *
 *----------------------------------------------------------------------
 */

void XDrawSegments(
    Display *display,
    Drawable  d,







|







642
643
644
645
646
647
648
649
650
651
652
653
654
655
656
 *
 *        Draw unconnected lines.
 *
 * Results:
 *        None.
 *
 * Side effects:
 *        Renders a series of unconnected lines.
 *
 *----------------------------------------------------------------------
 */

void XDrawSegments(
    Display *display,
    Drawable  d,
613
614
615
616
617
618
619
620
621

622
623
624
625
626
627
628
629


630
631
632
633
634
635
636
    TkMacOSXSetUpClippingRgn(d);

    if (useCGDrawing) {
        CGContextRef outContext;

        TkMacOSXSetUpCGContext(macWin, destPort, gc, &outContext);

        CGContextBeginPath(outContext);
        for (i = 0; i < nsegments; i++) {

            CGContextMoveToPoint(outContext,
                    (float) segments[i].x1,
                    (float) segments[i].y1);
            CGContextAddLineToPoint (outContext,
                    (float) segments[i].x2,
                    (float) segments[i].y2);
        }
        CGContextStrokePath(outContext);


        TkMacOSXReleaseCGContext(macWin, destPort, &outContext);
    } else {
        TkMacOSXSetUpGraphicsPort(gc, destPort);

        ShowPen();

        PenPixPat(gPenPat);







<

>

|
|

|
|
<
|
>
>







674
675
676
677
678
679
680

681
682
683
684
685
686
687
688

689
690
691
692
693
694
695
696
697
698
    TkMacOSXSetUpClippingRgn(d);

    if (useCGDrawing) {
        CGContextRef outContext;

        TkMacOSXSetUpCGContext(macWin, destPort, gc, &outContext);


        for (i = 0; i < nsegments; i++) {
	    CGContextBeginPath(outContext);
            CGContextMoveToPoint(outContext,
                    (float)(macWin->xOff + segments[i].x1),
                    (float)(macWin->yOff + segments[i].y1));
            CGContextAddLineToPoint (outContext,
                    (float)(macWin->xOff + segments[i].x2),
                    (float)(macWin->yOff + segments[i].y2));

            CGContextStrokePath(outContext);

        }
        TkMacOSXReleaseCGContext(macWin, destPort, &outContext);
    } else {
        TkMacOSXSetUpGraphicsPort(gc, destPort);

        ShowPen();

        PenPixPat(gPenPat);
689
690
691
692
693
694
695
696
697
698
699
700
701
702
703



704
705
706
707
708
709
710
711
712
713
714
    
    if (useCGDrawing) {
        CGContextRef outContext;
        
        TkMacOSXSetUpCGContext(macWin, destPort, gc, &outContext);
        
        CGContextBeginPath(outContext);
        CGContextMoveToPoint(outContext, (float) (points[0].x),
                (float) (points[0].y));
        for (i = 1; i < npoints; i++) {
            
            if (mode == CoordModePrevious) {
                CGContextAddLineToPoint(outContext, (float) points[i].x,
                        (float) points[i].y);
            } else {



            }
        }
        //CGContextStrokePath(outContext);
        CGContextFillPath(outContext);
        TkMacOSXReleaseCGContext(macWin, destPort, &outContext);
    } else {
        TkMacOSXSetUpGraphicsPort(gc, destPort);
    
        PenNormal();
        polygon = OpenPoly();
    







|
|



|


>
>
>


<
|







751
752
753
754
755
756
757
758
759
760
761
762
763
764
765
766
767
768
769
770

771
772
773
774
775
776
777
778
    
    if (useCGDrawing) {
        CGContextRef outContext;
        
        TkMacOSXSetUpCGContext(macWin, destPort, gc, &outContext);
        
        CGContextBeginPath(outContext);
        CGContextMoveToPoint(outContext, (float) (macWin->xOff + points[0].x),
                (float) (macWin->yOff + points[0].y));
        for (i = 1; i < npoints; i++) {
            
            if (mode == CoordModePrevious) {
                CGContextAddLineToPoint(outContext, (float)points[i].x, 
                        (float) points[i].y);
            } else {
		CGContextAddLineToPoint(outContext, 
                        (float)(macWin->xOff + points[i].x),
                        (float)(macWin->yOff + points[i].y));
            }
        }

	CGContextEOFillPath(outContext);
        TkMacOSXReleaseCGContext(macWin, destPort, &outContext);
    } else {
        TkMacOSXSetUpGraphicsPort(gc, destPort);
    
        PenNormal();
        polygon = OpenPoly();
    
768
769
770
771
772
773
774



775









776
777
778
779
780
781
782
783
784
785
786
787
788
789
790
791
792
793
794
    destPort = TkMacOSXGetDrawablePort(d);

    display->request++;
    GetGWorld(&saveWorld, &saveDevice);
    SetGWorld(destPort, NULL);

    TkMacOSXSetUpClippingRgn(d);













    TkMacOSXSetUpGraphicsPort(gc, destPort);

    theRect.left = (short) (macWin->xOff + x);
    theRect.top = (short) (macWin->yOff + y);
    theRect.right = (short) (theRect.left + width);
    theRect.bottom = (short) (theRect.top + height);
        
    ShowPen();
    PenPixPat(gPenPat);
    FrameRect(&theRect);
    HidePen();

    SetGWorld(saveWorld, saveDevice);
}

/*
 *----------------------------------------------------------------------
 *
 * XDrawRectangles --







>
>
>
|
>
>
>
>
>
>
>
>
>
|

|
|
|
|

|
|
|
|
|







832
833
834
835
836
837
838
839
840
841
842
843
844
845
846
847
848
849
850
851
852
853
854
855
856
857
858
859
860
861
862
863
864
865
866
867
868
869
870
    destPort = TkMacOSXGetDrawablePort(d);

    display->request++;
    GetGWorld(&saveWorld, &saveDevice);
    SetGWorld(destPort, NULL);

    TkMacOSXSetUpClippingRgn(d);
    if (useCGDrawing) {
        CGContextRef outContext;
	CGRect	rect;
        
        TkMacOSXSetUpCGContext(macWin, destPort, gc, &outContext);

	rect = CGRectMake((float) ((float) macWin->xOff + (float) x),
	        (float) ((float) macWin->yOff + (float) y),
	        (float) width,
		(float) height);
	CGContextStrokeRect(outContext, rect);
        TkMacOSXReleaseCGContext(macWin, destPort, &outContext);
    } else {
        TkMacOSXSetUpGraphicsPort(gc, destPort);

        theRect.left = (short) (macWin->xOff + x);
        theRect.top = (short) (macWin->yOff + y);
        theRect.right = (short) (theRect.left + width);
        theRect.bottom = (short) (theRect.top + height);
        
        ShowPen();
        PenPixPat(gPenPat);
        FrameRect(&theRect);
        HidePen();
    }
    SetGWorld(saveWorld, saveDevice);
}

/*
 *----------------------------------------------------------------------
 *
 * XDrawRectangles --
819
820
821
822
823
824
825
826
827
828
829
830
831
832
833
834
835
836
837
838
839
840



841

842







843




844
845
846
847
848
849
850
851
852
853
854
855
856
857
858
859
860
861
862
    Display *display,
    Drawable drawable,
    GC gc,
    XRectangle *rectArr,
    int nRects)
{
    MacDrawable *macWin = (MacDrawable *) drawable;
    Rect     rect;
    CGrafPtr saveWorld;
    GDHandle saveDevice;
    GWorldPtr destPort;
    XRectangle * rectPtr;
    int       i;

    destPort = TkMacOSXGetDrawablePort(drawable);

    display->request++;
    GetGWorld(&saveWorld, &saveDevice);
    SetGWorld(destPort, NULL);

    TkMacOSXSetUpClippingRgn(drawable);




    TkMacOSXSetUpGraphicsPort(gc, destPort);














    ShowPen();
    PenPixPat(gPenPat);

    for (i = 0, rectPtr = rectArr; i < nRects;i++, rectPtr++ ) {
        rect.left = (short) (macWin->xOff + rectPtr->x);
        rect.top = (short) (macWin->yOff + rectPtr->y);
        rect.right = (short) (rect.left + rectPtr->width);
        rect.bottom = (short) (rect.top + rectPtr->height);
        FrameRect(&rect);
    }
    HidePen();

    SetGWorld(saveWorld, saveDevice);
}

/*
 *----------------------------------------------------------------------
 *
 * XDrawArc --







|














>
>
>
|
>

>
>
>
>
>
>
>
|
>
>
>
>
|
|

|
|
|
|
|
|
|
|
|







895
896
897
898
899
900
901
902
903
904
905
906
907
908
909
910
911
912
913
914
915
916
917
918
919
920
921
922
923
924
925
926
927
928
929
930
931
932
933
934
935
936
937
938
939
940
941
942
943
944
945
946
947
948
949
950
951
952
953
    Display *display,
    Drawable drawable,
    GC gc,
    XRectangle *rectArr,
    int nRects)
{
    MacDrawable *macWin = (MacDrawable *) drawable;
    Rect     theRect;
    CGrafPtr saveWorld;
    GDHandle saveDevice;
    GWorldPtr destPort;
    XRectangle * rectPtr;
    int       i;

    destPort = TkMacOSXGetDrawablePort(drawable);

    display->request++;
    GetGWorld(&saveWorld, &saveDevice);
    SetGWorld(destPort, NULL);

    TkMacOSXSetUpClippingRgn(drawable);

    if (useCGDrawing) {
        CGContextRef outContext;
	CGRect	rect;

        TkMacOSXSetUpCGContext(macWin, destPort, gc, &outContext);

        for (i = 0, rectPtr = rectArr; i < nRects; i++, rectPtr++) {
	    rect = CGRectMake((float) ((float) macWin->xOff 
                    + (float) rectPtr->x),
		    (float) ((float) macWin->yOff + (float) rectPtr->y),
		    (float) rectPtr->width,
		    (float) rectPtr->height);
	    CGContextStrokeRect(outContext, rect);
	}
        TkMacOSXReleaseCGContext(macWin, destPort, &outContext);
    } else {
	TkMacOSXSetUpGraphicsPort(gc, destPort);

        ShowPen();
        PenPixPat(gPenPat);

        for (i = 0, rectPtr = rectArr; i < nRects;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);
            FrameRect(&theRect);
        }
        HidePen();
    }
    SetGWorld(saveWorld, saveDevice);
}

/*
 *----------------------------------------------------------------------
 *
 * XDrawArc --
886
887
888
889
890
891
892
893
894
895
896
897
898
899
900
901
902
903
904
905
906
907
908
909
910
911
912
913









914
915
916
917
918
919
920
921
922
923
924
925

926
927
928
929




930





931
932
933
934
935
936
937
938
939
940
941
942
943
{
    MacDrawable *macWin = (MacDrawable *) d;
    Rect theRect;
    short start, extent;
    CGrafPtr saveWorld;
    GDHandle saveDevice;
    GWorldPtr destPort;
    float fX = (float) x,
          fY = (float) y,
          fWidth = (float) width,
          fHeight = (float) height;

    if (width == 0 || height == 0) {
        return;
    }
    
    destPort = TkMacOSXGetDrawablePort(d);

    display->request++;
    GetGWorld(&saveWorld, &saveDevice);
    SetGWorld(destPort, NULL);

    TkMacOSXSetUpClippingRgn(d);

    if (useCGDrawing) {
        CGContextRef outContext;
        CGAffineTransform transform;
        int clockwise = angle1 ? 0 : 1;










        TkMacOSXSetUpCGContext(macWin, destPort, gc, &outContext);

        CGContextBeginPath(outContext);
        
        /*
         * If we are drawing an oval, we have to squash the coordinate
         * system before drawing, since CGContextAddArcToPoint only draws
         * circles.
         */

        CGContextSaveGState(outContext);

        transform = CGAffineTransformMakeTranslation((float) (x + width/2),
                (float) (y + height/2));
        transform = CGAffineTransformScale(transform, 1.0, fHeight/fWidth);
        CGContextConcatCTM(outContext, transform);










        CGContextAddArc(outContext, 0.0, 0.0,
                (float) width/2,
                (float) angle1, (float) angle2, clockwise);

        CGContextRestoreGState(outContext);

        CGContextStrokePath(outContext);
        TkMacOSXReleaseCGContext(macWin, destPort, &outContext);
    } else {
        TkMacOSXSetUpGraphicsPort(gc, destPort);


        theRect.left = (short) (macWin->xOff + x);







<
<
<
<















|
|
>
>
>
>
>
>
>
>
>



<
<







>
|
|
|
|
>
>
>
>

>
>
>
>
>
|
<
<

|
<







977
978
979
980
981
982
983




984
985
986
987
988
989
990
991
992
993
994
995
996
997
998
999
1000
1001
1002
1003
1004
1005
1006
1007
1008
1009
1010
1011
1012


1013
1014
1015
1016
1017
1018
1019
1020
1021
1022
1023
1024
1025
1026
1027
1028
1029
1030
1031
1032
1033
1034
1035


1036
1037

1038
1039
1040
1041
1042
1043
1044
{
    MacDrawable *macWin = (MacDrawable *) d;
    Rect theRect;
    short start, extent;
    CGrafPtr saveWorld;
    GDHandle saveDevice;
    GWorldPtr destPort;





    if (width == 0 || height == 0) {
        return;
    }
    
    destPort = TkMacOSXGetDrawablePort(d);

    display->request++;
    GetGWorld(&saveWorld, &saveDevice);
    SetGWorld(destPort, NULL);

    TkMacOSXSetUpClippingRgn(d);

    if (useCGDrawing) {
        CGContextRef outContext;
	CGRect	boundingRect;
        int clockwise;
	float a,b;
	CGPoint	center;
	float arc1, arc2;

	if (angle2 > 0) {
	    clockwise = 1;
	} else {
	    clockwise = 0;
        }

        TkMacOSXSetUpCGContext(macWin, destPort, gc, &outContext);



        /*
         * If we are drawing an oval, we have to squash the coordinate
         * system before drawing, since CGContextAddArcToPoint only draws
         * circles.
         */

        CGContextSaveGState(outContext);
	boundingRect = CGRectMake(	(float)(macWin->xOff + x),
					(float)(macWin->yOff + y),
					(float)(width),
					(float)(height));

	center = CGPointMake(CGRectGetMidX(boundingRect), 
                CGRectGetMidY(boundingRect));
	a = CGRectGetWidth(boundingRect)/2;
	b = CGRectGetHeight(boundingRect)/2;

	CGContextTranslateCTM(outContext, center.x, center.y);
	CGContextBeginPath(outContext);
	CGContextScaleCTM(outContext, a, b);
	arc1 = radians(-(angle1/64));
	arc2 = radians(-(angle2/64)) + arc1;
	CGContextAddArc(outContext, 0.0, 0.0, 1, arc1, arc2, clockwise);



	CGContextRestoreGState(outContext);

        CGContextStrokePath(outContext);
        TkMacOSXReleaseCGContext(macWin, destPort, &outContext);
    } else {
        TkMacOSXSetUpGraphicsPort(gc, destPort);


        theRect.left = (short) (macWin->xOff + x);
999
1000
1001
1002
1003
1004
1005


1006

1007





1008




1009































1010
1011
1012
1013
1014
1015
1016
1017
1018
1019
1020
1021
1022
1023
1024
1025
1026
1027
1028
1029
    destPort = TkMacOSXGetDrawablePort(d);

    display->request++;
    GetGWorld(&saveWorld, &saveDevice);
    SetGWorld(destPort, NULL);

    TkMacOSXSetUpClippingRgn(d);




    TkMacOSXSetUpGraphicsPort(gc, destPort);










































    ShowPen();
    PenPixPat(gPenPat);
    for (i = 0, arcPtr = arcArr;i < nArcs;i++, arcPtr++ ) {
        rect.left = (short) (macWin->xOff + arcPtr->x);
        rect.top = (short) (macWin->yOff + arcPtr->y);
        rect.right = (short) (rect.left + arcPtr->width);
        rect.bottom = (short) (rect.top + arcPtr->height);
        start = (short) (90 - (arcPtr->angle1 / 64));
        extent = (short) (-(arcPtr->angle2 / 64));
        FrameArc(&rect, start, extent);
    }
    HidePen();

    SetGWorld(saveWorld, saveDevice);
}

/*
 *----------------------------------------------------------------------
 *
 * XFillArc --







>
>

>
|
>
>
>
>
>
|
>
>
>
>
|
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
|
|
|
|
|
|
|
|
|
|
|
|
|







1100
1101
1102
1103
1104
1105
1106
1107
1108
1109
1110
1111
1112
1113
1114
1115
1116
1117
1118
1119
1120
1121
1122
1123
1124
1125
1126
1127
1128
1129
1130
1131
1132
1133
1134
1135
1136
1137
1138
1139
1140
1141
1142
1143
1144
1145
1146
1147
1148
1149
1150
1151
1152
1153
1154
1155
1156
1157
1158
1159
1160
1161
1162
1163
1164
1165
1166
1167
1168
1169
1170
1171
1172
1173
    destPort = TkMacOSXGetDrawablePort(d);

    display->request++;
    GetGWorld(&saveWorld, &saveDevice);
    SetGWorld(destPort, NULL);

    TkMacOSXSetUpClippingRgn(d);
    if (useCGDrawing) {
        CGContextRef outContext;

        TkMacOSXSetUpCGContext(macWin, destPort, gc, &outContext);

	for (i=0, arcPtr = arcArr; i < nArcs; i++, arcPtr++) {
	    CGRect	boundingRect;
	    int clockwise;
	    float a,b, arc1, arc2;
	    CGPoint center;
	   
	    if (arcPtr[i].angle2 > 0) {
		clockwise = 1;
	    } else {
		clockwise = 0;
	    }

        /*
         * If we are drawing an oval, we have to squash the coordinate
         * system before drawing, since CGContextAddArcToPoint only draws
         * circles.
         */

	    CGContextSaveGState(outContext);
	    CGContextBeginPath(outContext);
	    boundingRect = CGRectMake(	(float)(macWin->xOff + arcPtr[i].x),
					(float)(macWin->yOff + arcPtr[i].y),
					(float)arcPtr[i].width,
					(float)arcPtr[i].height);
	    
	    center = CGPointMake(CGRectGetMidX(boundingRect), 
                    CGRectGetMidY(boundingRect));
	    a = CGRectGetWidth(boundingRect)/2;
	    b = CGRectGetHeight(boundingRect)/2;
	    
	    CGContextTranslateCTM(outContext, center.x, center.y);
	    CGContextScaleCTM(outContext, a, b);
	    arc1 = radians(-(arcPtr[i].angle1/64));
	    arc2 = radians(-(arcPtr[i].angle2/64)) + arc1;
	    CGContextAddArc(outContext, 0.0, 0.0, 1, arc1, arc2, clockwise);
	    CGContextRestoreGState(outContext);
	    CGContextStrokePath(outContext);
	}
        TkMacOSXReleaseCGContext(macWin, destPort, &outContext);
    } else {
	TkMacOSXSetUpGraphicsPort(gc, destPort);

        ShowPen();
        PenPixPat(gPenPat);
        for (i = 0, arcPtr = arcArr;i < nArcs;i++, arcPtr++) {
            rect.left = (short) (macWin->xOff + arcPtr->x);
            rect.top = (short) (macWin->yOff + arcPtr->y);
            rect.right = (short) (rect.left + arcPtr->width);
            rect.bottom = (short) (rect.top + arcPtr->height);
            start = (short) (90 - (arcPtr->angle1 / 64));
            extent = (short) (-(arcPtr->angle2 / 64));
            FrameArc(&rect, start, extent);
        }
        HidePen();
    }
    SetGWorld(saveWorld, saveDevice);
}

/*
 *----------------------------------------------------------------------
 *
 * XFillArc --
1066
1067
1068
1069
1070
1071
1072

















































1073
1074
1075
1076
1077
1078
1079
1080
1081
1082
1083
1084
1085
1086
1087
1088
1089
1090
1091
1092
1093
1094
1095
1096
1097
1098
1099
1100
1101
1102
1103
1104
1105
1106
1107
1108
1109
1110
1111
1112
1113
1114
1115
1116
1117
1118
1119
1120
1121
1122
1123
1124

    display->request++;
    GetGWorld(&saveWorld, &saveDevice);
    SetGWorld(destPort, NULL);

    TkMacOSXSetUpClippingRgn(d);


















































    TkMacOSXSetUpGraphicsPort(gc, destPort);

    theRect.left = (short) (macWin->xOff + x);
    theRect.top = (short) (macWin->yOff + y);
    theRect.right = (short) (theRect.left + width);
    theRect.bottom = (short) (theRect.top + height);
    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 = -(angle1/64.0)*PI/180.0;
            sin1 = sin(angle);
            cos1 = cos(angle);
            angle -= (angle2/64.0)*PI/180.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] + 0.5), (short) (center1[1] + 0.5));
        LineTo((short) (center2[0] + 0.5), (short) (center2[1] + 0.5));
        ClosePoly();

        ShowPen();
        FillCArc(&theRect, start, extent, gPenPat);
        FillCPoly(polygon, gPenPat);
        HidePen();

        KillPoly(polygon);
    } else {
        ShowPen();
        FillCArc(&theRect, start, extent, gPenPat);
        HidePen();
    }

    SetGWorld(saveWorld, saveDevice);
}

/*  
 *----------------------------------------------------------------------
 *  
 * XFillArcs --  







>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
|

|
|
|
|
|
|

|















|
|
|

|
|
|

|
|
|
|

|
|
|
|
|
|
|







1210
1211
1212
1213
1214
1215
1216
1217
1218
1219
1220
1221
1222
1223
1224
1225
1226
1227
1228
1229
1230
1231
1232
1233
1234
1235
1236
1237
1238
1239
1240
1241
1242
1243
1244
1245
1246
1247
1248
1249
1250
1251
1252
1253
1254
1255
1256
1257
1258
1259
1260
1261
1262
1263
1264
1265
1266
1267
1268
1269
1270
1271
1272
1273
1274
1275
1276
1277
1278
1279
1280
1281
1282
1283
1284
1285
1286
1287
1288
1289
1290
1291
1292
1293
1294
1295
1296
1297
1298
1299
1300
1301
1302
1303
1304
1305
1306
1307
1308
1309
1310
1311
1312
1313
1314
1315
1316
1317

    display->request++;
    GetGWorld(&saveWorld, &saveDevice);
    SetGWorld(destPort, NULL);

    TkMacOSXSetUpClippingRgn(d);

    if (useCGDrawing) {
        CGContextRef outContext;
	CGRect	boundingRect;
        int clockwise;
	float a,b;
	CGPoint	center;

	if (angle2 > 0) {
            clockwise = 1;
	} else {
            clockwise = 0;
        }

        TkMacOSXSetUpCGContext(macWin, destPort, gc, &outContext);
	
	boundingRect = CGRectMake((float) (macWin->xOff + x),
	        (float) (macWin->yOff + y),
		(float) width,
		(float) height);
	center = CGPointMake(CGRectGetMidX(boundingRect), 
                CGRectGetMidY(boundingRect));
	a = CGRectGetWidth(boundingRect)/2;
	b = CGRectGetHeight(boundingRect)/2;

	if (gc->arc_mode == ArcChord) {
	  float arc1, arc2;

	    CGContextBeginPath(outContext);
	    CGContextTranslateCTM(outContext, center.x, center.y);
	    CGContextScaleCTM(outContext, a, b);
	    arc1 = radians(-(angle1/64));
	    arc2 = radians(-(angle2/64)) + arc1;
	    CGContextAddArc(outContext, 0.0, 0.0, 1, arc1, arc2, clockwise);
	    CGContextFillPath(outContext);
	} else if (gc->arc_mode == ArcPieSlice) {
            float arc1, arc2;

	    CGContextTranslateCTM(outContext, center.x, center.y);
	    CGContextScaleCTM(outContext,a,b);
	    arc1 = radians(-(angle1/64));
	    arc2 = radians(-(angle2/64)) + arc1;
	    CGContextAddArc(outContext, 0.0, 0.0, 1, arc1, arc2, clockwise);
	    CGContextAddLineToPoint(outContext, 0.0f, 0.0f);
	    CGContextClosePath(outContext);
	    CGContextFillPath(outContext);
	}
	
        TkMacOSXReleaseCGContext(macWin, destPort, &outContext);
    } else {
        TkMacOSXSetUpGraphicsPort(gc, destPort);

        theRect.left = (short) (macWin->xOff + x);
        theRect.top = (short) (macWin->yOff + y);
        theRect.right = (short) (theRect.left + width);
        theRect.bottom = (short) (theRect.top + height);
        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 = -(angle1/64.0)*PI/180.0;
            sin1 = sin(angle);
            cos1 = cos(angle);
            angle -= (angle2/64.0)*PI/180.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] + 0.5), (short) (center1[1] + 0.5));
            LineTo((short) (center2[0] + 0.5), (short) (center2[1] + 0.5));
            ClosePoly();

            ShowPen();
            FillCArc(&theRect, start, extent, gPenPat);
            FillCPoly(polygon, gPenPat);
            HidePen();

            KillPoly(polygon);
        } else {
            ShowPen();
            FillCArc(&theRect, start, extent, gPenPat);
            HidePen();
        }
    }
    SetGWorld(saveWorld, saveDevice);
}

/*  
 *----------------------------------------------------------------------
 *  
 * XFillArcs --  
1158
1159
1160
1161
1162
1163
1164
























































































1165
1166
1167
1168
1169
1170
1171
1172
1173
1174
1175
1176
1177
1178
1179
1180
1181
1182
1183
1184
1185
1186
1187
1188
1189
1190
1191
1192
1193
1194
1195
1196
1197
1198
1199
1200
1201
1202
1203
1204
1205
1206
1207
1208

1209
1210
1211
1212
1213
1214
1215

    display->request++;
    GetGWorld(&saveWorld, &saveDevice);
    SetGWorld(destPort, NULL);

    TkMacOSXSetUpClippingRgn(d);

























































































    TkMacOSXSetUpGraphicsPort(gc, destPort);

    for (i = 0, arcPtr = arcArr;i<nArcs;i++, arcPtr++ ) {
        rect.left = (short) (macWin->xOff + arcPtr->x);
        rect.top = (short) (macWin->yOff + arcPtr->y);
        rect.right = (short) (rect.left + arcPtr->width);
        rect.bottom = (short) (rect.top + arcPtr->height);
        start = (short) (90 - (arcPtr->angle1 / 64));
        extent = (short) (- (arcPtr->angle2 / 64));

        if (gc->arc_mode == ArcChord) {
            boxWidth = rect.right - rect.left;
            boxHeight = rect.bottom - rect.top;
            angle = -(arcPtr->angle1/64.0)*PI/180.0;
            sin1 = sin(angle);
            cos1 = cos(angle);
            angle -= (arcPtr->angle2/64.0)*PI/180.0;
            sin2 = sin(angle);
            cos2 = cos(angle);
            vertex[0] = (rect.left + rect.right)/2.0;
            vertex[1] = (rect.top + rect.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) ((rect.left + rect.right)/2),
                    (short) ((rect.top + rect.bottom)/2));
    
            LineTo((short) (center1[0] + 0.5), (short) (center1[1] + 0.5));
            LineTo((short) (center2[0] + 0.5), (short) (center2[1] + 0.5));
            ClosePoly();
    
            ShowPen();
            FillCArc(&rect, start, extent, gPenPat);
            FillCPoly(polygon, gPenPat);
            HidePen();

            KillPoly(polygon);
        } else {
            ShowPen();
            FillCArc(&rect, start, extent, gPenPat);
            HidePen();

        }
    }
    SetGWorld(saveWorld, saveDevice);
}

/* 
 *----------------------------------------------------------------------







>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
|

|
|
|
|
|
|
|

|
|
|
|
|
|
|
|
|
|
|
|
|
|
|

|
|
|

|
|
|

|
|
|
|

|
|
|
|
|
>







1351
1352
1353
1354
1355
1356
1357
1358
1359
1360
1361
1362
1363
1364
1365
1366
1367
1368
1369
1370
1371
1372
1373
1374
1375
1376
1377
1378
1379
1380
1381
1382
1383
1384
1385
1386
1387
1388
1389
1390
1391
1392
1393
1394
1395
1396
1397
1398
1399
1400
1401
1402
1403
1404
1405
1406
1407
1408
1409
1410
1411
1412
1413
1414
1415
1416
1417
1418
1419
1420
1421
1422
1423
1424
1425
1426
1427
1428
1429
1430
1431
1432
1433
1434
1435
1436
1437
1438
1439
1440
1441
1442
1443
1444
1445
1446
1447
1448
1449
1450
1451
1452
1453
1454
1455
1456
1457
1458
1459
1460
1461
1462
1463
1464
1465
1466
1467
1468
1469
1470
1471
1472
1473
1474
1475
1476
1477
1478
1479
1480
1481
1482
1483
1484
1485
1486
1487
1488
1489
1490
1491
1492
1493
1494
1495
1496
1497

    display->request++;
    GetGWorld(&saveWorld, &saveDevice);
    SetGWorld(destPort, NULL);

    TkMacOSXSetUpClippingRgn(d);

    if (useCGDrawing) {
        CGContextRef outContext;
        
        TkMacOSXSetUpCGContext(macWin, destPort, gc, &outContext);
	for (i = 0, arcPtr = arcArr; i < nArcs; i++, arcPtr++) {
	    CGRect	boundingRect;
	    int clockwise = arcPtr[i].angle1;
	    float a,b;
	    CGPoint center;
	    
	    if (arcPtr[i].angle2 > 0) {
		clockwise = 1;
	    } else {
		clockwise = 0;
            }

	    /*
	     * If we are drawing an oval, we have to squash the coordinate
	     * system before drawing, since CGContextAddArcToPoint only draws
	     * circles.
	     */

	    if (gc->arc_mode == ArcChord) {
	    
		CGContextBeginPath(outContext);
		boundingRect = CGRectMake((float)(macWin->xOff + arcPtr[i].x),
	                (float)(macWin->yOff + arcPtr[i].y),
			(float)arcPtr[i].width,
			(float)arcPtr[i].height);
		center = CGPointMake(CGRectGetMidX(boundingRect), 
                        CGRectGetMidY(boundingRect));
		a = CGRectGetWidth(boundingRect)/2.0;
		b = CGRectGetHeight(boundingRect)/2.0;
		
		angle = -(arcPtr->angle1/64.0)*PI/180.0;
		sin1 = sin(angle);
		cos1 = cos(angle);
		angle -= (arcPtr->angle2/64.0)*PI/180.0;
		sin2 = sin(angle);
		cos2 = cos(angle);
		vertex[0] = (CGRectGetMinX(boundingRect) 
                        + CGRectGetMaxX(boundingRect))/2.0;
		vertex[1] = (CGRectGetMaxY(boundingRect) 
                        + CGRectGetMinY(boundingRect))/2.0;
		center1[0] = vertex[0] + cos1*a;
		center1[1] = vertex[1] + sin1*b;
		center2[0] = vertex[0] + cos2*a;
		center2[1] = vertex[1] + sin2*b;

		CGContextScaleCTM(outContext, a, b);
		
		CGContextBeginPath(outContext);
		CGContextMoveToPoint(outContext, (float) vertex[0],
		        (float) vertex[1]);
		CGContextAddLineToPoint(outContext,
			(float) (center1[0] + 0.5),
			(float) (center1[1] + 0.5));
		CGContextAddLineToPoint(outContext,
			(float) (center2[0] + 0.5),
		        (float) (center2[1] + 0.5));
		CGContextFillPath(outContext);
	    } else if (gc->arc_mode == ArcPieSlice) {
	        float arc1, arc2;
		CGContextBeginPath(outContext);
		boundingRect = CGRectMake((float)(macWin->xOff + arcPtr[i].x),
		        (float)(macWin->yOff + arcPtr[i].y),
			(float)arcPtr[i].width,
			(float)arcPtr[i].height);
		center = CGPointMake(CGRectGetMidX(boundingRect), 
                        CGRectGetMidY(boundingRect));
		a = CGRectGetWidth(boundingRect)/2;
		b = CGRectGetHeight(boundingRect)/2;
		
		CGContextTranslateCTM(outContext, center.x, center.y);
		CGContextScaleCTM(outContext, a, b);
		arc1 = radians(-(arcPtr[i].angle1/64));
		arc2 = radians(-(arcPtr[i].angle2/64)) + arc1;
		CGContextAddArc(outContext, 0.0, 0.0, 1, 
                        arc1, arc2, clockwise);
		CGContextAddLineToPoint(outContext, 0.0f, 0.0f);
		CGContextClosePath(outContext);
		CGContextFillPath(outContext);
	    }
	}
        
        TkMacOSXReleaseCGContext(macWin, destPort, &outContext);
    } else {
    
        TkMacOSXSetUpGraphicsPort(gc, destPort);

        for (i = 0, arcPtr = arcArr;i<nArcs;i++, arcPtr++) {
            rect.left = (short) (macWin->xOff + arcPtr->x);
            rect.top = (short) (macWin->yOff + arcPtr->y);
            rect.right = (short) (rect.left + arcPtr->width);
            rect.bottom = (short) (rect.top + arcPtr->height);
            start = (short) (90 - (arcPtr->angle1 / 64));
            extent = (short) (- (arcPtr->angle2 / 64));

            if (gc->arc_mode == ArcChord) {
                boxWidth = rect.right - rect.left;
                boxHeight = rect.bottom - rect.top;
                angle = -(arcPtr->angle1/64.0)*PI/180.0;
                sin1 = sin(angle);
                cos1 = cos(angle);
                angle -= (arcPtr->angle2/64.0)*PI/180.0;
                sin2 = sin(angle);
                cos2 = cos(angle);
                vertex[0] = (rect.left + rect.right)/2.0;
                vertex[1] = (rect.top + rect.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) ((rect.left + rect.right)/2),
                        (short) ((rect.top + rect.bottom)/2));
    
                LineTo((short) (center1[0] + 0.5), (short) (center1[1] + 0.5));
                LineTo((short) (center2[0] + 0.5), (short) (center2[1] + 0.5));
                ClosePoly();
    
                ShowPen();
                FillCArc(&rect, start, extent, gPenPat);
                FillCPoly(polygon, gPenPat);
                HidePen();

                KillPoly(polygon);
            } else {
                ShowPen();
                FillCArc(&rect, start, extent, gPenPat);
                HidePen();
            }
        }
    }
    SetGWorld(saveWorld, saveDevice);
}

/* 
 *----------------------------------------------------------------------
1385
1386
1387
1388
1389
1390
1391
1392
1393
1394
1395
1396
1397
1398
1399
1400
1401
1402
1403
1404
1405
1406
1407
1408
1409
1410
1411
1412
1413
1414
1415
1416
1417
1418
1419
1420
    if(gc->function == GXxor) {
        PenMode(patXor);
    }
    if (gc->line_width > 1) {
        PenSize(gc->line_width, gc->line_width);
    }
    if (gc->line_style != LineSolid) {
        unsigned char *p = (unsigned char *) &(gc->dashes);
        /*
         * Here the dash pattern should be set in the drawing,
         * environment, but I don't know how to do that for the Mac.
         *
         * p[] is an array of unsigned chars containing the dash list.
         * A '\0' indicates the end of this list.
         *
         * Someone knows how to implement this? If you have a more
         * complete implementation of SetUpGraphicsPort() for
         * the Mac (or for Windows), please let me know.
         *
         *        Jan Nijtmans
         *        CMG Arnhem, B.V.
         *        email: [email protected] (private)
         *               [email protected] (work)
         *        url:   http://purl.oclc.org/net/nijtmans/
         *
         * FIXME:
         * This is not possible with QuickDraw line drawing, we either
         * have to convert all line drawings to regions, or, on Mac OS X
         * we can use CG to draw our lines instead of QuickDraw.
         */
    }
}
/*
 *----------------------------------------------------------------------
 *
 * TkMacOSXSetUpGraphicsPort --







<


















|
|
|







1667
1668
1669
1670
1671
1672
1673

1674
1675
1676
1677
1678
1679
1680
1681
1682
1683
1684
1685
1686
1687
1688
1689
1690
1691
1692
1693
1694
1695
1696
1697
1698
1699
1700
1701
    if(gc->function == GXxor) {
        PenMode(patXor);
    }
    if (gc->line_width > 1) {
        PenSize(gc->line_width, gc->line_width);
    }
    if (gc->line_style != LineSolid) {

        /*
         * Here the dash pattern should be set in the drawing,
         * environment, but I don't know how to do that for the Mac.
         *
         * p[] is an array of unsigned chars containing the dash list.
         * A '\0' indicates the end of this list.
         *
         * Someone knows how to implement this? If you have a more
         * complete implementation of SetUpGraphicsPort() for
         * the Mac (or for Windows), please let me know.
         *
         *        Jan Nijtmans
         *        CMG Arnhem, B.V.
         *        email: [email protected] (private)
         *               [email protected] (work)
         *        url:   http://purl.oclc.org/net/nijtmans/
         *
         * FIXME:
         * This is not possible with QuickDraw line drawing.  As of
         * Tk 8.4.7 we have a complete set of drawing routines using
         * CG, so there is no reason to support this here.
         */
    }
}
/*
 *----------------------------------------------------------------------
 *
 * TkMacOSXSetUpGraphicsPort --
1437
1438
1439
1440
1441
1442
1443
1444

1445
1446
1447
1448

1449



1450



1451


1452
1453
1454
1455
1456
1457
1458
1459
1460
1461
1462

1463
1464
1465
1466




1467
1468

1469


1470
1471
1472
1473
1474
1475

1476
1477
1478
1479
1480



1481
1482
1483
1484
1485
1486
1487







1488

1489
1490
1491
1492

1493
1494
1495





1496
1497
1498
1499



1500
1501
1502
1503
1504
1505






1506
1507
1508
1509
1510
1511






1512
1513
1514
1515
1516
1517
1518
1519
1520
1521
1522
1523
1524
1525
1526
1527
1528
1529
1530
1531
    GC gc,
    CGContextRef *contextPtr)                /* GC to apply to current port. */
{
    RGBColor macColor;
    CGContextRef outContext;
    OSStatus err;
    Rect boundsRect;
    CGAffineTransform coordsTransform;


    err = QDBeginCGContext(destPort, contextPtr);
    outContext = *contextPtr;
    

    CGContextSaveGState(outContext);



    



    GetPortBounds(destPort, &boundsRect);


    
    CGContextResetCTM(outContext);
    coordsTransform = CGAffineTransformMake(1.0, 0.0, 0.0, -1.0, 0, 
            (float)(boundsRect.bottom - boundsRect.top));
    CGContextConcatCTM(outContext, coordsTransform);
    
    if (macWin->clipRgn != NULL) {
        ClipCGContextToRegion(outContext, &boundsRect, macWin->clipRgn);
    } else {
        RgnHandle clipRgn = NewRgn();
        GetPortClipRegion(destPort, clipRgn);

        ClipCGContextToRegion(outContext, &boundsRect, 
                clipRgn);
        DisposeRgn(clipRgn);
    }





    /* Now offset the CTM to the subwindow offset */

    


    CGContextTranslateCTM(outContext, macWin->xOff, macWin->yOff);

    if (TkSetMacColor(gc->foreground, &macColor) == true) {                
        CGContextSetRGBStrokeColor(outContext, RGBFLOATRED(macColor), 
                RGBFLOATGREEN(macColor), 
                RGBFLOATBLUE(macColor), 1.0);

    }
    if (TkSetMacColor(gc->background, &macColor) == true) {                
        CGContextSetRGBFillColor(outContext, RGBFLOATRED(macColor), 
                RGBFLOATGREEN(macColor), 
                RGBFLOATBLUE(macColor), 1.0);



    }
    
    if(gc->function == GXxor) {
    }
    
    CGContextSetLineWidth(outContext, (float) gc->line_width);








    if (gc->line_style != LineSolid) {

        unsigned char *p = (unsigned char *) &(gc->dashes);
        /*
         * Here the dash pattern should be set in the drawing,
         * environment, but I don't know how to do that for the Mac.

         *
         * p[] is an array of unsigned chars containing the dash list.
         * A '\0' indicates the end of this list.





         *
         * Someone knows how to implement this? If you have a more
         * complete implementation of SetUpGraphicsPort() for
         * the Mac (or for Windows), please let me know.



         *
         *        Jan Nijtmans
         *        CMG Arnhem, B.V.
         *        email: [email protected] (private)
         *               [email protected] (work)
         *        url:   http://purl.oclc.org/net/nijtmans/






         *
         * FIXME:
         * This is not possible with QuickDraw line drawing, we either
         * have to convert all line drawings to regions, or, on Mac OS X
         * we can use CG to draw our lines instead of QuickDraw.
         */






    }
}

void
TkMacOSXReleaseCGContext(
        MacDrawable *macWin,
        CGrafPtr destPort, 
        CGContextRef *outContext)
{
    CGContextResetCTM(*outContext);
    CGContextRestoreGState(*outContext);
    QDEndCGContext(destPort, outContext);

}

/*
 *----------------------------------------------------------------------
 *
 * TkMacOSXSetUpClippingRgn --
 *







|
>



|
>
|
>
>
>
|
>
>
>
|
>
>
|
|
<
|
<

<
|
<
<
|
>
|
<
|
|
>
>
>
>
|
<
>
|
>
>
|
|
<
<
<
<
>
|
|

|
|
>
>
>







>
>
>
>
>
>
>
|
>
|
<
|
<
>
|
<
|
>
>
>
>
>
|
<
<
<
>
>
>
|
|
<
<
<
<
>
>
>
>
>
>
|
<
<
<
<
<
>
>
>
>
>
>









|
<

<







1718
1719
1720
1721
1722
1723
1724
1725
1726
1727
1728
1729
1730
1731
1732
1733
1734
1735
1736
1737
1738
1739
1740
1741
1742
1743
1744

1745

1746

1747


1748
1749
1750

1751
1752
1753
1754
1755
1756
1757

1758
1759
1760
1761
1762
1763




1764
1765
1766
1767
1768
1769
1770
1771
1772
1773
1774
1775
1776
1777
1778
1779
1780
1781
1782
1783
1784
1785
1786
1787
1788
1789

1790

1791
1792

1793
1794
1795
1796
1797
1798
1799



1800
1801
1802
1803
1804




1805
1806
1807
1808
1809
1810
1811





1812
1813
1814
1815
1816
1817
1818
1819
1820
1821
1822
1823
1824
1825
1826
1827

1828

1829
1830
1831
1832
1833
1834
1835
    GC gc,
    CGContextRef *contextPtr)                /* GC to apply to current port. */
{
    RGBColor macColor;
    CGContextRef outContext;
    OSStatus err;
    Rect boundsRect;
    CGAffineTransform coordsTransform;        
    static RgnHandle clipRgn = NULL;

    err = QDBeginCGContext(destPort, contextPtr);
    outContext = *contextPtr;
 
    /*
     * Now clip the CG Context to the port.  Note, we have already
     * set up the port with our clip region, so we can just get
     * the clip back out of there.  If we use the macWin->clipRgn
     * directly at this point, we get some odd drawing effects.
     * 
     * We also have to intersect our clip region with the port
     * visible region so we don't overwrite the window decoration.
     */
     
    if (!clipRgn) {
        clipRgn = NewRgn();
    }


    GetPortBounds(destPort, &boundsRect);

    

    RectRgn(clipRgn, &boundsRect);


    SectRegionWithPortClipRegion(destPort, clipRgn);
    SectRegionWithPortVisibleRegion(destPort, clipRgn);
    ClipCGContextToRegion(outContext, &boundsRect, clipRgn);

    SetEmptyRgn(clipRgn);
    
    /*
     * Note: You have to call SyncCGContextOriginWithPort
     * AFTER all the clip region manipulations.
     */
     

    SyncCGContextOriginWithPort(outContext, destPort);

    coordsTransform = CGAffineTransformMake(1.0f, 0.0f, 0.0f, -1.0f, 0.0f, 
            (float) (boundsRect.bottom - boundsRect.top));
    CGContextConcatCTM(outContext, coordsTransform);
    




    /* Now offset the CTM to the subwindow offset */

    if (TkSetMacColor(gc->foreground, &macColor) == true) {                
        CGContextSetRGBFillColor(outContext, RGBFLOATRED(macColor), 
               RGBFLOATGREEN(macColor), 
               RGBFLOATBLUE(macColor), 1.0f);
	CGContextSetRGBStrokeColor(outContext, RGBFLOATRED(macColor),
               RGBFLOATGREEN(macColor),
               RGBFLOATBLUE(macColor), 1.0f);
    }
    
    if(gc->function == GXxor) {
    }
    
    CGContextSetLineWidth(outContext, (float) gc->line_width);

    /* When should we antialias? */
    if (gc->line_width < tkMacOSXCGAntiAliasLimit) {
	CGContextSetShouldAntialias(outContext, 0);
    } else {
	CGContextSetShouldAntialias(outContext, 1);
    }

    if (gc->line_style != LineSolid) { 
        int num = 0;
        char *p = &(gc->dashes);

        float dashOffset = (float) gc->dash_offset;

        float lengths[10];


        while (p[num] != '\0') {
            lengths[num] = (float) (p[num]);
            num++;
        }
        CGContextSetLineDash(outContext, dashOffset, lengths, num);
    }
    



    if (gc->cap_style == CapButt) {	
        /*
         *  What about CapNotLast, CapProjecting?
         */





	CGContextSetLineCap(outContext, kCGLineCapButt);
    } else if (gc->cap_style == CapRound) {
	CGContextSetLineCap(outContext, kCGLineCapRound);
    } else if (gc->cap_style == CapProjecting) {
	CGContextSetLineCap(outContext, kCGLineCapSquare);
    }
   





    if (gc->join_style == JoinMiter) {
	CGContextSetLineJoin(outContext, kCGLineJoinMiter);
    } else if (gc->join_style == JoinRound) {
	CGContextSetLineJoin(outContext, kCGLineJoinRound);
    } else if (gc->join_style == JoinBevel) {
	CGContextSetLineJoin(outContext, kCGLineJoinBevel);
    }
}

void
TkMacOSXReleaseCGContext(
        MacDrawable *macWin,
        CGrafPtr destPort, 
        CGContextRef *outContext)
{
    CGContextSynchronize(*outContext);

    QDEndCGContext(destPort, outContext);

}

/*
 *----------------------------------------------------------------------
 *
 * TkMacOSXSetUpClippingRgn --
 *
1613
1614
1615
1616
1617
1618
1619
1620
1621
1622
1623
1624
1625
1626
1627
    int width, height, stippleHeight, stippleWidth;
    int i, j;
    char * data;
    Rect bounds;

    destPort = TkMacOSXGetDrawablePort(drawable);
    
    GetPortBounds ( destPort, &portRect );
    width = portRect.right - portRect.left;
    height = portRect.bottom - portRect.top;
    
    bitmapPtr = (BitMap *) ckalloc(sizeof(BitMap));
    data = (char *) ckalloc(height * ((width / 8) + 1));
    bitmapPtr->bounds.top = bitmapPtr->bounds.left = 0;
    bitmapPtr->bounds.right = (short) width;







|







1917
1918
1919
1920
1921
1922
1923
1924
1925
1926
1927
1928
1929
1930
1931
    int width, height, stippleHeight, stippleWidth;
    int i, j;
    char * data;
    Rect bounds;

    destPort = TkMacOSXGetDrawablePort(drawable);
    
    GetPortBounds (destPort, &portRect);
    width = portRect.right - portRect.left;
    height = portRect.bottom - portRect.top;
    
    bitmapPtr = (BitMap *) ckalloc(sizeof(BitMap));
    data = (char *) ckalloc(height * ((width / 8) + 1));
    bitmapPtr->bounds.top = bitmapPtr->bounds.left = 0;
    bitmapPtr->bounds.right = (short) width;
1636
1637
1638
1639
1640
1641
1642
1643
1644
1645
1646
1647
1648
1649
1650
    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(GetPortBitMapForCopyBits ( destPort ), bitmapPtr, 
                &portRect, &bounds, srcCopy, NULL);
        }
    }
    return bitmapPtr;
}

/*







|







1940
1941
1942
1943
1944
1945
1946
1947
1948
1949
1950
1951
1952
1953
1954
    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(GetPortBitMapForCopyBits(destPort), bitmapPtr, 
                &portRect, &bounds, srcCopy, NULL);
        }
    }
    return bitmapPtr;
}

/*
1712
1713
1714
1715
1716
1717
1718
1719

1720
1721
1722
        Drawable drawable)
{
    if (highlightWidth == 1) {
        TkDrawInsetFocusHighlight (tkwin, fgGC, highlightWidth, drawable, 0);
    } else {
        TkDrawInsetFocusHighlight (tkwin, bgGC, highlightWidth, drawable, 0);
        if (fgGC != bgGC) {
            TkDrawInsetFocusHighlight (tkwin, fgGC, highlightWidth - 1, drawable, 0);

        }
    }
}







|
>



2016
2017
2018
2019
2020
2021
2022
2023
2024
2025
2026
2027
        Drawable drawable)
{
    if (highlightWidth == 1) {
        TkDrawInsetFocusHighlight (tkwin, fgGC, highlightWidth, drawable, 0);
    } else {
        TkDrawInsetFocusHighlight (tkwin, bgGC, highlightWidth, drawable, 0);
        if (fgGC != bgGC) {
            TkDrawInsetFocusHighlight (tkwin, fgGC, highlightWidth - 1, 
                    drawable, 0);
        }
    }
}

Changes to macosx/tkMacOSXInit.c.

1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17



18
19
20
21
22
23
24









25
26
27
28
29
30
31
/* 
 * tkMacOSXInit.c --
 *
 *        This file contains Mac OS X -specific interpreter initialization
 *        functions.
 *
 * Copyright (c) 1995-1997 Sun Microsystems, Inc.
 * Copyright 2001, Apple Computer, Inc.
 *
 * 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.5 2004/02/16 00:19:42 wolfsuit Exp $
 */

#include "tkInt.h"
#include "tkMacOSXInt.h"




/*
 * The Init script (common to Windows and Unix platforms) is
 * defined in tkInitScript.h
 */
#include "tkInitScript.h"










/*
 * 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.
 */













|




>
>
>







>
>
>
>
>
>
>
>
>







1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
/* 
 * tkMacOSXInit.c --
 *
 *        This file contains Mac OS X -specific interpreter initialization
 *        functions.
 *
 * Copyright (c) 1995-1997 Sun Microsystems, Inc.
 * Copyright 2001, Apple Computer, Inc.
 *
 * 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.6 2004/11/11 01:24:32 das Exp $
 */

#include "tkInt.h"
#include "tkMacOSXInt.h"
#include "tclInt.h"
#include <sys/stat.h>
#include <mach-o/dyld.h>

/*
 * The Init script (common to Windows and Unix platforms) is
 * defined in tkInitScript.h
 */
#include "tkInitScript.h"

/*
 * 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.
 */
#ifndef MAC_OSX_TK_USE_CPS_SPI
#define MAC_OSX_TK_USE_CPS_SPI 1
#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.
 */

68
69
70
71
72
73
74





75
76
77
78
79
80
81
    {smVietnamese,	"macVietnam"},
    {smExtArabic,	"macSindhi"},
    {NULL,		NULL}
};

Tcl_Encoding TkMacOSXCarbonEncoding = NULL;







/*
 *----------------------------------------------------------------------
 *
 * TkpInit --
 *
 *        Performs Mac-specific interpreter initialization related to the







>
>
>
>
>







80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
    {smVietnamese,	"macVietnam"},
    {smExtArabic,	"macSindhi"},
    {NULL,		NULL}
};

Tcl_Encoding TkMacOSXCarbonEncoding = NULL;

/*
 * If the App is in an App package, then we want to add the Scripts
 * directory to the auto_path.      
 */
static char scriptPath[PATH_MAX + 1] = "";

/*
 *----------------------------------------------------------------------
 *
 * TkpInit --
 *
 *        Performs Mac-specific interpreter initialization related to the
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109




110

111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149





150



















































































151





152
153
154
155
156
157
158
 *----------------------------------------------------------------------
 */

int
TkpInit(interp)
    Tcl_Interp *interp;
{
    char tkLibPath[1024];
    int result;
    static int menusInitialized = false;
    static int carbonEncodingInitialized = false;

    /* 
     * Since it is possible for TkInit to be called multiple times
     * and we don't want to do the menu initialization multiple times
     * we protect against doing it more than once.
     */

    if (menusInitialized == false) {




    	menusInitialized = true;

        Tk_MacOSXSetupTkNotifier();
        TkMacOSXInitAppleEvents(interp);
        TkMacOSXInitCarbonEvents(interp);
        TkMacOSXInitMenus(interp);
        TkMacOSXUseAntialiasedText(interp, TRUE);
    }
 
    if (carbonEncodingInitialized == false) {
	CFStringEncoding encoding;
	char *encodingStr = NULL;
	int  i;
	
	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);
	}
    }
    
    /*
     * 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?
     */
     
    result = Tcl_MacOSXOpenVersionedBundleResources(interp, 
    	    "com.tcltk.tklibrary", TK_VERSION, 1, 1024, tkLibPath);
     





    if (result != TCL_ERROR) {



















































































        Tcl_SetVar(interp, "tk_library", tkLibPath, TCL_GLOBAL_ONLY);





    }
    
    return Tcl_Eval(interp, initScript);
}

/*
 *----------------------------------------------------------------------







|
<
|
<



|



|
>
>
>
>
|
>





<
|
<
<
<
<

















<
|
|
|
|
|
|
|
|
|
|
>
>
>
>
>
|
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>

>
>
>
>
>







108
109
110
111
112
113
114
115

116

117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135

136




137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153

154
155
156
157
158
159
160
161
162
163
164
165
166
167
168
169
170
171
172
173
174
175
176
177
178
179
180
181
182
183
184
185
186
187
188
189
190
191
192
193
194
195
196
197
198
199
200
201
202
203
204
205
206
207
208
209
210
211
212
213
214
215
216
217
218
219
220
221
222
223
224
225
226
227
228
229
230
231
232
233
234
235
236
237
238
239
240
241
242
243
244
245
246
247
248
249
250
251
252
253
254
255
256
257
258
259
260
261
262
263
264
265
 *----------------------------------------------------------------------
 */

int
TkpInit(interp)
    Tcl_Interp *interp;
{
    static char tkLibPath[PATH_MAX + 1];

    static int tkMacOSXInitialized = false;


    /* 
     * Since it is possible for TkInit to be called multiple times
     * and we don't want to do the initialization multiple times
     * we protect against doing it more than once.
     */

    if (tkMacOSXInitialized == false) {
	CFStringEncoding encoding;
	char *encodingStr = NULL;
	int  i;

    	tkMacOSXInitialized = true;

        Tk_MacOSXSetupTkNotifier();
        TkMacOSXInitAppleEvents(interp);
        TkMacOSXInitCarbonEvents(interp);
        TkMacOSXInitMenus(interp);
        TkMacOSXUseAntialiasedText(interp, TRUE);

        TkMacOSXInitCGDrawing(interp, TRUE, 3);




	
	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);
	}

        
        /*
         * 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?
         */
         
        Tcl_MacOSXOpenVersionedBundleResources(interp, 
                "com.tcltk.tklibrary", TK_VERSION, 1, 1024, tkLibPath);
                 
        /*
         * If we don't have a TTY and stdin is a special character file of length 0,
         * (e.g. /dev/null, which is what Finder sets when double clicking Wish)
         * then use the Tk based console interpreter.
         */
    
        if (!isatty(0)) {
            struct stat st;
            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));
                if (Tk_CreateConsoleWindow(interp) == TCL_OK) {
                    /* Only show the console if we don't have a startup script */
                    if (Tcl_GetStartupScript(NULL) == NULL) {
                        Tcl_Eval(interp, "console show");
                    }
                }
            }
        }
#if MAC_OSX_TK_USE_CPS_SPI
        /*
         * 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, we attempt to use an undocumented SPI to
         * notify the window server that we are now a full GUI application.
         */
        {
            /* Check whether we are a bundled executable: */
            int bundledExecutable = 0;
            CFBundleRef bundleRef = CFBundleGetMainBundle();
            CFURLRef bundleUrl = NULL;
            if (bundleRef) {
                bundleUrl = CFBundleCopyBundleURL(bundleRef);
            }
            if (bundleUrl) {
                /*
                 * A bundled executable is two levels down from its main bundle
                 * directory (e.g. Wish.app/Contents/MacOS/Wish), whereas
                 * an unbundled executable's main bundle directory is just
                 * the directory containing the executable.
                 * So to check whether we are bundled, we delete the last three
                 * path components of the executable's url and compare the
                 * resulting url with the main bundle url.
                 */
                int j = 3;
                CFURLRef url = CFBundleCopyExecutableURL(bundleRef);
                while (url && j--) {
                    CFURLRef parent = CFURLCreateCopyDeletingLastPathComponent(NULL, url);
                    CFRelease(url);
                    url = parent;
                }
                if (url) {
                    bundledExecutable = CFEqual(bundleUrl, url);
                    CFRelease(url);
                }
                CFRelease(bundleUrl);
            }
            
            /* If we are not a bundled executable, attempt to use the CPS SPI: */
            if (!bundledExecutable) {
                /*
                 * Load the CPS SPI symbol dynamically, so that we don't break
                 * if it every disappears or changes its name.
                 */
                OSErr (*cpsEnableForegroundOperation)(ProcessSerialNumberPtr) = NULL;
                NSSymbol nsSymbol;
                if(NSIsSymbolNameDefinedWithHint(
                        "_CPSEnableForegroundOperation", "CoreGraphics")) {
                    nsSymbol = NSLookupAndBindSymbolWithHint(
                        "_CPSEnableForegroundOperation", "CoreGraphics");
                    if(nsSymbol) {
                        cpsEnableForegroundOperation = NSAddressOfSymbol(nsSymbol);
                    }
                }
                if (cpsEnableForegroundOperation) {
                    ProcessSerialNumber psn = { 0, kCurrentProcess };
                    /*
                     * Let the window server know that we are a foregroundable app
                     */
                    cpsEnableForegroundOperation(&psn);
                }
            }
        }
#endif /* MAC_OSX_TK_USE_CPS_SPI */
    }

    if (tkLibPath[0] != '\0') {
        Tcl_SetVar(interp, "tk_library", tkLibPath, TCL_GLOBAL_ONLY);
    }

    if (scriptPath[0] != '\0') {
        Tcl_SetVar(interp, "auto_path", scriptPath,
                TCL_GLOBAL_ONLY|TCL_LIST_ELEMENT|TCL_APPEND_VALUE);
    }
    
    return Tcl_Eval(interp, initScript);
}

/*
 *----------------------------------------------------------------------
217
218
219
220
221
222
223
























































    if (errChannel) {
        Tcl_WriteChars(errChannel, title, -1);
        Tcl_WriteChars(errChannel, ": ", 2);
        Tcl_WriteChars(errChannel, msg, -1);
        Tcl_WriteChars(errChannel, "\n", 1);
    }
}































































>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
324
325
326
327
328
329
330
331
332
333
334
335
336
337
338
339
340
341
342
343
344
345
346
347
348
349
350
351
352
353
354
355
356
357
358
359
360
361
362
363
364
365
366
367
368
369
370
371
372
373
374
375
376
377
378
379
380
381
382
383
384
385
386
    if (errChannel) {
        Tcl_WriteChars(errChannel, title, -1);
        Tcl_WriteChars(errChannel, ": ", 2);
        Tcl_WriteChars(errChannel, msg, -1);
        Tcl_WriteChars(errChannel, "\n", 1);
    }
}

/*
 *----------------------------------------------------------------------
 *
 * TkMacOSXDefaultStartupScript --
 *
 *
 *        On MacOS X, we look for a file in the Resources/Scripts
 *        directory called AppMain.tcl and if found, we set argv[1] to
 *        that, so that the rest of the code will find it, and add the
 *        Scripts folder to the auto_path.  If we don't find the startup
 *        script, we just bag it, assuming the user is starting up some
 *        other way.
 *       
 * Results:
 *        None.
 *
 * Side effects:
 *        Tcl_SetStartupScript() called when AppMain.tcl found.
 *
 *----------------------------------------------------------------------
 */

void
TkMacOSXDefaultStartupScript(void)
{
    CFBundleRef bundleRef;
    
    bundleRef = CFBundleGetMainBundle();
    
    if (bundleRef != NULL) {
        CFURLRef appMainURL;
        appMainURL = CFBundleCopyResourceURL(bundleRef, 
                CFSTR("AppMain"), 
                CFSTR("tcl"), 
                CFSTR("Scripts"));

        if (appMainURL != NULL) {
            CFURLRef scriptFldrURL;
            char startupScript[PATH_MAX + 1];
                            
            if (CFURLGetFileSystemRepresentation (appMainURL, true,
                    startupScript, PATH_MAX)) {
                Tcl_SetStartupScript(Tcl_NewStringObj(startupScript, -1), NULL);
                scriptFldrURL = CFURLCreateCopyDeletingLastPathComponent(
                        NULL, appMainURL);
                if (scriptFldrURL != NULL) {
                    CFURLGetFileSystemRepresentation(scriptFldrURL, 
                            true, scriptPath, PATH_MAX);
                    CFRelease(scriptFldrURL);
                }
            }
            CFRelease(appMainURL);
        }
    }
}

Changes to macosx/tkMacOSXInt.h.

1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
/*
 * tkMacOSXInt.h --
 *
 *	Declarations of Macintosh specific shared variables and procedures.
 *
 * Copyright (c) 1995-1997 Sun Microsystems, Inc.
 * Copyright 2001, Apple Computer, Inc.
 *
 * 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.4 2004/02/16 00:19:42 wolfsuit Exp $
 */

#ifndef _TKMACINT
#define _TKMACINT

#ifndef _TKINT
#include "tkInt.h"











|







1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
/*
 * tkMacOSXInt.h --
 *
 *	Declarations of Macintosh specific shared variables and procedures.
 *
 * Copyright (c) 1995-1997 Sun Microsystems, Inc.
 * Copyright 2001, Apple Computer, Inc.
 *
 * 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.5 2004/11/11 01:24:32 das Exp $
 */

#ifndef _TKMACINT
#define _TKMACINT

#ifndef _TKINT
#include "tkInt.h"
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
                                         */
extern TkMacOSXWindowList *tkMacOSXWindowListPtr;
					/* The list of toplevels */

extern Tcl_Encoding TkMacOSXCarbonEncoding;

extern int TkMacOSXUseAntialiasedText(Tcl_Interp *interp, int enable);

/* 
 * FIXME: Put this into the decls file? 
 */

extern void TkMacOSXInitCarbonEvents (Tcl_Interp *interp);

#include "tkIntPlatDecls.h"

#endif /* _TKMACINT */







|
<
<
<
|
|




147
148
149
150
151
152
153
154



155
156
157
158
159
160
                                         */
extern TkMacOSXWindowList *tkMacOSXWindowListPtr;
					/* The list of toplevels */

extern Tcl_Encoding TkMacOSXCarbonEncoding;

extern int TkMacOSXUseAntialiasedText(Tcl_Interp *interp, int enable);
extern void TkMacOSXInitCarbonEvents (Tcl_Interp *interp);



extern int TkMacOSXInitCGDrawing(Tcl_Interp *interp, int enable, int antiAlias);
extern void TkMacOSXDefaultStartupScript(void);

#include "tkIntPlatDecls.h"

#endif /* _TKMACINT */

Changes to macosx/tkMacOSXMenu.c.

1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
/* 
 * tkMacOSXMenu.c --
 *
 *	This module implements the Mac-platform specific features of menus.
 *
 * Copyright (c) 1996-1997 by Sun Microsystems, Inc.
 * Copyright 2001, Apple Computer, Inc.
 *
 * See the file "license.terms" for information on usage and redistribution
 * of this file, and for a DISCLAIMER OF ALL WARRANTIES.
 *
 * RCS: @(#) $Id: tkMacOSXMenu.c,v 1.15 2004/09/03 14:09:05 dkf Exp $
 */
#include "tkMacOSXInt.h"
#include "tkMenubutton.h"
#include "tkMenu.h"
#include "tkColor.h"
#include "tkMacOSXInt.h"
#undef Status











|







1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
/* 
 * tkMacOSXMenu.c --
 *
 *	This module implements the Mac-platform specific features of menus.
 *
 * Copyright (c) 1996-1997 by Sun Microsystems, Inc.
 * Copyright 2001, Apple Computer, Inc.
 *
 * See the file "license.terms" for information on usage and redistribution
 * of this file, and for a DISCLAIMER OF ALL WARRANTIES.
 *
 * RCS: @(#) $Id: tkMacOSXMenu.c,v 1.16 2004/11/11 01:24:32 das Exp $
 */
#include "tkMacOSXInt.h"
#include "tkMenubutton.h"
#include "tkMenu.h"
#include "tkColor.h"
#include "tkMacOSXInt.h"
#undef Status
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
#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 SEPARATOR_TEXT "\p(-"
				/* The text for a menu separator. */

#define MENUBAR_REDRAW_PENDING 1
#define SCREEN_MARGIN 5

static int gNoTkMenus = 0;      /* This is used by Tk_MacOSXTurnOffMenus as the
                                 * flag that Tk is not to draw any menus. */
                                 
RgnHandle tkMenuCascadeRgn = NULL;







<
<
<







137
138
139
140
141
142
143



144
145
146
147
148
149
150
#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
#define SCREEN_MARGIN 5

static int gNoTkMenus = 0;      /* This is used by Tk_MacOSXTurnOffMenus as the
                                 * flag that Tk is not to draw any menus. */
                                 
RgnHandle tkMenuCascadeRgn = NULL;
1075
1076
1077
1078
1079
1080
1081
1082


1083
1084
1085
1086
1087
1088
1089
1090
1091
1092
1093
1094
1095
1096
1097
1098
1099
1100
1101
1102
1103
    
    	/*
    	 * We have to do separators separately because SetMenuItemText
    	 * does not parse meta-characters.
    	 */
    
    	if (mePtr->type == SEPARATOR_ENTRY) {
    	    AppendMenu(macMenuHdl, SEPARATOR_TEXT);


    	} else {
    	    Tcl_DString itemTextDString;
    	    int destWrote;
            CFStringRef cf;    	    
	    GetEntryText(mePtr, &itemTextDString);
            cf = CFStringCreateWithCString(NULL,
                  Tcl_DStringValue(&itemTextDString), kCFStringEncodingUTF8);
	    AppendMenu(macMenuHdl, "\px");
	    if (cf != NULL) {
	      SetMenuItemTextWithCFString(macMenuHdl, base + index, cf);
	      CFRelease(cf);
	    } else {
	      cf = CFSTR ("<Error>");
	      SetMenuItemTextWithCFString(macMenuHdl, base + index, cf);
	    }
	    Tcl_DStringFree(&itemTextDString);
	
    	    /*
    	     * Set enabling and disabling correctly.
    	     */








|
>
>







<

|



|







1072
1073
1074
1075
1076
1077
1078
1079
1080
1081
1082
1083
1084
1085
1086
1087
1088

1089
1090
1091
1092
1093
1094
1095
1096
1097
1098
1099
1100
1101
    
    	/*
    	 * We have to do separators separately because SetMenuItemText
    	 * does not parse meta-characters.
    	 */
    
    	if (mePtr->type == SEPARATOR_ENTRY) {
    	    AppendMenuItemTextWithCFString (macMenuHdl, NULL, 
                    kMenuItemAttrSeparator | kMenuItemAttrDisabled,
                    0, NULL);
    	} else {
    	    Tcl_DString itemTextDString;
    	    int destWrote;
            CFStringRef cf;    	    
	    GetEntryText(mePtr, &itemTextDString);
            cf = CFStringCreateWithCString(NULL,
                  Tcl_DStringValue(&itemTextDString), kCFStringEncodingUTF8);

	    if (cf != NULL) {
              AppendMenuItemTextWithCFString (macMenuHdl, cf, 0, 0, NULL);
	      CFRelease(cf);
	    } else {
	      cf = CFSTR ("<Error>");
              AppendMenuItemTextWithCFString (macMenuHdl, cf, 0, 0, NULL);
	    }
	    Tcl_DStringFree(&itemTextDString);
	
    	    /*
    	     * Set enabling and disabling correctly.
    	     */

2099
2100
2101
2102
2103
2104
2105

2106
2107
2108
2109
2110
2111
2112
{
    struct MenuCommandHandlerData *realData
            = (struct MenuCommandHandlerData *) data;
    int code;

    code = TkInvokeMenu(realData->menuPtr->interp, realData->menuPtr,
            realData->index);

    if (code != TCL_OK && code != TCL_CONTINUE
            && code != TCL_BREAK) {
        Tcl_AddErrorInfo(realData->menuPtr->interp, "\n    (menu invoke)");
        Tcl_BackgroundError(realData->menuPtr->interp);
    }
    
    Tcl_Release(realData->menuPtr->interp);







>







2097
2098
2099
2100
2101
2102
2103
2104
2105
2106
2107
2108
2109
2110
2111
{
    struct MenuCommandHandlerData *realData
            = (struct MenuCommandHandlerData *) data;
    int code;

    code = TkInvokeMenu(realData->menuPtr->interp, realData->menuPtr,
            realData->index);
            
    if (code != TCL_OK && code != TCL_CONTINUE
            && code != TCL_BREAK) {
        Tcl_AddErrorInfo(realData->menuPtr->interp, "\n    (menu invoke)");
        Tcl_BackgroundError(realData->menuPtr->interp);
    }
    
    Tcl_Release(realData->menuPtr->interp);

Changes to macosx/tkMacOSXMouseEvent.c.

113
114
115
116
117
118
119

120
121
122
123
124
125
126
    Point          where, where2;
    int            xOffset, yOffset;
    TkDisplay *    dispPtr;
    Window         window;
    int            status,err;
    MouseEventData mouseEventData, * medPtr = &mouseEventData;
    KeyMap         keyMap;


    switch (eventPtr->eKind) {
        case kEventMouseUp:
        case kEventMouseDown:
        case kEventMouseMoved:
        case kEventMouseDragged:
        case kEventMouseWheelMoved:







>







113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
    Point          where, where2;
    int            xOffset, yOffset;
    TkDisplay *    dispPtr;
    Window         window;
    int            status,err;
    MouseEventData mouseEventData, * medPtr = &mouseEventData;
    KeyMap         keyMap;
    long           modif;

    switch (eventPtr->eKind) {
        case kEventMouseUp:
        case kEventMouseDown:
        case kEventMouseMoved:
        case kEventMouseDragged:
        case kEventMouseWheelMoved:
136
137
138
139
140
141
142

143

144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
            &where);
    if (status != noErr) {
        fprintf (stderr, "Failed to retrieve mouse location,%d\n", status);
        return 0;
    }
    medPtr->state = 0;
    GetKeys(keyMap);

    if (keyMap[1] & 2) { 

        medPtr->state |= LockMask;
    }
    if (keyMap[1] & 1) {
        medPtr->state |= ShiftMask;
    }
    if (keyMap[1] & 8) {
        medPtr->state |= ControlMask;
    }
    if (keyMap[1] & 32768) {
        medPtr->state |= Mod1Mask;              /* command key */
    }
    if (keyMap[1] & 4) {
        medPtr->state |= Mod2Mask;              /* option key */
    }
    if (eventPtr->eKind == kEventMouseDown 
            || eventPtr->eKind == kEventMouseDragged ) {
        EventMouseButton mouseButton;
        status = GetEventParameter(eventPtr->eventRef,
                kEventParamMouseButton,







>
|
>


|


|


|


|







137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
165
            &where);
    if (status != noErr) {
        fprintf (stderr, "Failed to retrieve mouse location,%d\n", status);
        return 0;
    }
    medPtr->state = 0;
    GetKeys(keyMap);
    modif = EndianS32_BtoN(*(long*)(&keyMap[1]));

    if (modif & 2) { 
        medPtr->state |= LockMask;
    }
    if (modif & 1) {
        medPtr->state |= ShiftMask;
    }
    if (modif & 8) {
        medPtr->state |= ControlMask;
    }
    if (modif & 32768) {
        medPtr->state |= Mod1Mask;              /* command key */
    }
    if (modif & 4) {
        medPtr->state |= Mod2Mask;              /* option key */
    }
    if (eventPtr->eKind == kEventMouseDown 
            || eventPtr->eKind == kEventMouseDragged ) {
        EventMouseButton mouseButton;
        status = GetEventParameter(eventPtr->eventRef,
                kEventParamMouseButton,
377
378
379
380
381
382
383
384
385
386
387
388
389
390
391
                
                /*
                 * Handle -postcommand
                 */
                 
                TkMacOSXPreprocessMenu();
                TkMacOSXHandleMenuSelect(MenuSelect(where),
                        theKeys[1] & 4);
                Tcl_SetServiceMode(oldMode);
                return true; /* TODO: may not be on event on queue. */
            }
            break;
        case inZoomIn:
        case inZoomOut:
            if (TkMacOSXZoomToplevel(medPtr->whichWin, where, 







|







380
381
382
383
384
385
386
387
388
389
390
391
392
393
394
                
                /*
                 * Handle -postcommand
                 */
                 
                TkMacOSXPreprocessMenu();
                TkMacOSXHandleMenuSelect(MenuSelect(where),
                        EndianS32_BtoN(*(long*)(&theKeys[1])) & 4);
                Tcl_SetServiceMode(oldMode);
                return true; /* TODO: may not be on event on queue. */
            }
            break;
        case inZoomIn:
        case inZoomOut:
            if (TkMacOSXZoomToplevel(medPtr->whichWin, where, 
674
675
676
677
678
679
680

681
682
683
684
685
686
687

688

689
690
691
692
693
694
695
696
697
698
699
700
701
702
703
704
705
706
707
708
709
710
711
 */

unsigned int
TkMacOSXButtonKeyState()
{
    unsigned int state = 0;
    KeyMap theKeys;


    if (Button() & !gEatButtonUp) {
        state |= Button1Mask;
    }

    GetKeys(theKeys);


    if (theKeys[1] & 2) {

        state |= LockMask;
    }

    if (theKeys[1] & 1) {
        state |= ShiftMask;
    }

    if (theKeys[1] & 8) {
        state |= ControlMask;
    }

    if (theKeys[1] & 32768) {
        state |= Mod1Mask;                /* command key */
    }

    if (theKeys[1] & 4) {
        state |= Mod2Mask;                /* option key */
    }

    return state;
}

/*







>






|
>
|
>



|



|



|



|







677
678
679
680
681
682
683
684
685
686
687
688
689
690
691
692
693
694
695
696
697
698
699
700
701
702
703
704
705
706
707
708
709
710
711
712
713
714
715
716
717
 */

unsigned int
TkMacOSXButtonKeyState()
{
    unsigned int state = 0;
    KeyMap theKeys;
    long modif;

    if (Button() & !gEatButtonUp) {
        state |= Button1Mask;
    }

    GetKeys(theKeys);
    
    modif = EndianS32_BtoN(*(long*)(&theKeys[1]));

    if (modif & 2) {
        state |= LockMask;
    }

    if (modif & 1) {
        state |= ShiftMask;
    }

    if (modif & 8) {
        state |= ControlMask;
    }

    if (modif & 32768) {
        state |= Mod1Mask;                /* command key */
    }

    if (modif & 4) {
        state |= Mod2Mask;                /* option key */
    }

    return state;
}

/*

Changes to macosx/tkMacOSXSubwindows.c.

1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
/* 
 * tkMacOSXSubwindows.c --
 *
 *	Implements subwindows for the macintosh version of Tk.
 *
 * Copyright (c) 1995-1997 Sun Microsystems, Inc.
 * Copyright 2001, Apple Computer, Inc.
 *
 * See the file "license.terms" for information on usage and redistribution
 * of this file, and for a DISCLAIMER OF ALL WARRANTIES.
 *
 * RCS: @(#) $Id: tkMacOSXSubwindows.c,v 1.5 2004/03/21 04:07:12 wolfsuit Exp $
 */

#include "tkInt.h"
#include "X11/X.h"
#include "X11/Xlib.h"
#include <stdio.h>












|







1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
/* 
 * tkMacOSXSubwindows.c --
 *
 *	Implements subwindows for the macintosh version of Tk.
 *
 * Copyright (c) 1995-1997 Sun Microsystems, Inc.
 * Copyright 2001, Apple Computer, Inc.
 *
 * See the file "license.terms" for information on usage and redistribution
 * of this file, and for a DISCLAIMER OF ALL WARRANTIES.
 *
 * RCS: @(#) $Id: tkMacOSXSubwindows.c,v 1.6 2004/11/11 01:24:32 das Exp $
 */

#include "tkInt.h"
#include "X11/X.h"
#include "X11/Xlib.h"
#include <stdio.h>

607
608
609
610
611
612
613
614
615
616
617
618
619
620
621
	    macWin->winPtr->changes.x;
	deltaY += macParent->yOff + parentBorderwidth +
	    macWin->winPtr->changes.y;
		
	UpdateOffsets(macWin->winPtr, deltaX, deltaY);
	TkMacOSXWinBounds(macWin->winPtr, &bounds);
	InvalWindowRect(GetWindowFromPort(destPort),&bounds);
        GenerateConfigureNotify(macWin->winPtr, 0);
    }
}

/*
 *----------------------------------------------------------------------
 *
 * XRaiseWindow --







|







607
608
609
610
611
612
613
614
615
616
617
618
619
620
621
	    macWin->winPtr->changes.x;
	deltaY += macParent->yOff + parentBorderwidth +
	    macWin->winPtr->changes.y;
		
	UpdateOffsets(macWin->winPtr, deltaX, deltaY);
	TkMacOSXWinBounds(macWin->winPtr, &bounds);
	InvalWindowRect(GetWindowFromPort(destPort),&bounds);
	GenerateConfigureNotify(macWin->winPtr, 0);
    }
}

/*
 *----------------------------------------------------------------------
 *
 * XRaiseWindow --

Changes to macosx/tkMacOSXWm.c.

8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
 *
 * Copyright (c) 1994-1997 Sun Microsystems, Inc.
 * Copyright 2001, Apple Computer, Inc.
 *
 * 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.14 2004/10/05 22:04:44 hobbs Exp $
 */
#include <Carbon/Carbon.h>

#include "tkPort.h"
#include "tkInt.h"
#include "tkMacOSXInt.h"
#include <errno.h>







|







8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
 *
 * Copyright (c) 1994-1997 Sun Microsystems, Inc.
 * Copyright 2001, Apple Computer, Inc.
 *
 * 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.15 2004/11/11 01:24:32 das Exp $
 */
#include <Carbon/Carbon.h>

#include "tkPort.h"
#include "tkInt.h"
#include "tkMacOSXInt.h"
#include <errno.h>
82
83
84
85
86
87
88





89
90
91
92
93
94
95
static void		UpdateVRootGeometry _ANSI_ARGS_((WmInfo *wmPtr));
static int 		WmAspectCmd _ANSI_ARGS_((Tk_Window tkwin,
                                      TkWindow *winPtr, Tcl_Interp *interp, int objc,
                                      Tcl_Obj *CONST objv[]));
static int 		WmAttributesCmd _ANSI_ARGS_((Tk_Window tkwin,
                                          TkWindow *winPtr, Tcl_Interp *interp, int objc,
                                          Tcl_Obj *CONST objv[]));





static int 		WmClientCmd _ANSI_ARGS_((Tk_Window tkwin,
                                      TkWindow *winPtr, Tcl_Interp *interp, int objc,
                                      Tcl_Obj *CONST objv[]));
static int 		WmColormapwindowsCmd _ANSI_ARGS_((Tk_Window tkwin,
                                               TkWindow *winPtr, Tcl_Interp *interp, int objc,
                                               Tcl_Obj *CONST objv[]));
static int 		WmCommandCmd _ANSI_ARGS_((Tk_Window tkwin,







>
>
>
>
>







82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
static void		UpdateVRootGeometry _ANSI_ARGS_((WmInfo *wmPtr));
static int 		WmAspectCmd _ANSI_ARGS_((Tk_Window tkwin,
                                      TkWindow *winPtr, Tcl_Interp *interp, int objc,
                                      Tcl_Obj *CONST objv[]));
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 void		WmAttrGetAlpha(WindowRef macWindow, Tcl_Obj *result);
static int 		WmClientCmd _ANSI_ARGS_((Tk_Window tkwin,
                                      TkWindow *winPtr, Tcl_Interp *interp, int objc,
                                      Tcl_Obj *CONST objv[]));
static int 		WmColormapwindowsCmd _ANSI_ARGS_((Tk_Window tkwin,
                                               TkWindow *winPtr, Tcl_Interp *interp, int objc,
                                               Tcl_Obj *CONST objv[]));
static int 		WmCommandCmd _ANSI_ARGS_((Tk_Window tkwin,
758
759
760
761
762
763
764
765
766

767












768

769
770
771
772
773
774

775

776
777
778

779
780
781
782

783
784

785
786
787


























788
789
790





















791

792
793

794
795



796




797



798

799
800









801

802
803
804

805


806







807










808
809
810
811
812
813
814
815
816
817
818
819
820
821
822
823
824


825

826


827
828
829










830




831



832



































833
834
835
836
837
838
839
WmAttributesCmd(tkwin, winPtr, interp, objc, objv)
Tk_Window tkwin;		/* Main window of the application. */
TkWindow *winPtr;           /* Toplevel to work with */
Tcl_Interp *interp;		/* Current interpreter. */
int objc;			/* Number of arguments. */
Tcl_Obj *CONST objv[];	/* Argument objects. */
{
    char buf[TCL_INTEGER_SPACE];
    int i;

    WindowRef macWindow;














    if (objc < 3) {
configArgs:
	Tcl_WrongNumArgs(interp, 1, objv,
		"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);
        }
        return TCL_OK;


























    }
    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);
                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;
                        }
                    }
                }
            }
        } else {
            goto configArgs;
        }


        if (i == objc - 2) {

            /* Want to return last result */


            Tcl_SetObjResult(interp, objv[i+1]);
        }
    }










    return TCL_OK;




}







































/*
 *----------------------------------------------------------------------
 *
 * WmClientCmd --
 *
 *	This procedure is invoked to process the "wm client" Tcl command.
 *	See the user documentation for details on what it does.







<

>

>
>
>
>
>
>
>
>
>
>
>
>

>

<

|
|

>

>

<
<
>
|
|
|
<
>
|
<
>
|
<

>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>


|
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
|
>
|
<
>
|
|
>
>
>
|
>
>
>
>
|
>
>
>
|
>
|
|
>
>
>
>
>
>
>
>
>
|
>
|
<
<
>
|
>
>
|
>
>
>
>
>
>
>
|
>
>
>
>
>
>
>
>
>
>
|
<
<
<
<
<
|
<
<
<
|
|
<
<
<
<
<
>
>
|
>
|
>
>
|
<
<
>
>
>
>
>
>
>
>
>
>
|
>
>
>
>
|
>
>
>
|
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>







763
764
765
766
767
768
769

770
771
772
773
774
775
776
777
778
779
780
781
782
783
784
785
786
787

788
789
790
791
792
793
794
795


796
797
798
799

800
801

802
803

804
805
806
807
808
809
810
811
812
813
814
815
816
817
818
819
820
821
822
823
824
825
826
827
828
829
830
831
832
833
834
835
836
837
838
839
840
841
842
843
844
845
846
847
848
849
850
851
852
853
854
855
856
857

858
859
860
861
862
863
864
865
866
867
868
869
870
871
872
873
874
875
876
877
878
879
880
881
882
883
884
885
886
887
888


889
890
891
892
893
894
895
896
897
898
899
900
901
902
903
904
905
906
907
908
909
910
911
912





913



914
915





916
917
918
919
920
921
922
923


924
925
926
927
928
929
930
931
932
933
934
935
936
937
938
939
940
941
942
943
944
945
946
947
948
949
950
951
952
953
954
955
956
957
958
959
960
961
962
963
964
965
966
967
968
969
970
971
972
973
974
975
976
977
978
979
980
981
982
983
984
985
WmAttributesCmd(tkwin, winPtr, interp, objc, objv)
Tk_Window tkwin;		/* Main window of the application. */
TkWindow *winPtr;           /* Toplevel to work with */
Tcl_Interp *interp;		/* Current interpreter. */
int objc;			/* Number of arguments. */
Tcl_Obj *CONST objv[];	/* Argument objects. */
{

    int i;
    int index;
    WindowRef macWindow;
    Tcl_Obj *result = NULL;
    const char *optionTable[] = {
	"-modified",
	"-titlepath",
	"-alpha",
	(char *)NULL
    };
    enum optionIdx {
	WmAttrModifiedIdx,
	WmAttrTitlePathIdx,
	WmAttrAlphaIdx,
    };

    /* Must have objc >= 3 at this point. */
    if (objc < 3) {

	Tcl_WrongNumArgs(interp, 1, objv,
	    "attributes window ?-modified ?bool?? ?-titlepath ?path?? ?-alpha ?double??");
	return TCL_ERROR;
    }

    macWindow = GetWindowFromPort(TkMacOSXGetDrawablePort(winPtr->window));

    if (objc == 3) {


	result = Tcl_NewObj();
	Tcl_AppendToObj(result, "-modified ", -1);
	WmAttrGetModifiedStatus(macWindow, result);
	Tcl_AppendToObj(result, " -titlepath ", -1);

	WmAttrGetTitlePath(macWindow, result);
	Tcl_AppendToObj(result, " -alpha ", -1);

	WmAttrGetAlpha(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;
	    case WmAttrAlphaIdx:
		WmAttrGetAlpha(macWindow, result);
		break;
	}
	Tcl_SetObjResult(interp, result);
	return TCL_OK;
    }

    if ( (objc - 3) % 2 != 0 ) {
	Tcl_WrongNumArgs(interp, 3, objv,
	    "?-modified ?bool?? ?-titlepath ?path?? ?-alpha ?double??");
	return TCL_ERROR;
    }
    for (i = 3; i < objc; i += 2) {
	int boolean;
	OSErr err;
	FSRef ref;
	AliasHandle alias;
	Boolean isDirectory;
	double dval;

	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 = FSNewAlias(NULL, &ref, &alias);
                }
		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;
	    case WmAttrAlphaIdx:
		if (Tcl_GetDoubleFromObj(interp, objv[i+1], &dval) !=
		    TCL_OK) {
		    return TCL_ERROR;
		}
		/*
		 * The user should give (transparent) 0 .. 1.0 (opaque)
		 */
		if (dval < 0.0) {
		    dval = 0.0;
		} else if (dval > 1.0) {
		    dval = 1.0;
		}
		result = Tcl_NewDoubleObj(dval);
		SetWindowAlpha(macWindow, dval);
		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);
    }
}

/*
 *----------------------------------------------------------------------
 * WmAttrGetAlpha --
 *
 *	Helper procedure to retrieve the -alpha option for the wm
 *	attributes command.
 *
 * Results:
 *	Nothing.
 * 
 * Side effects:
 *	Appends the alpha value of the given window to the Tcl_Obj 
 * 	passed in.
 *
 *----------------------------------------------------------------------
 */
static void WmAttrGetAlpha(WindowRef macWindow, Tcl_Obj *result)
{
    float fval;
    if (GetWindowAlpha(macWindow, &fval) != noErr) {
        fval = 1.0;
    }
    Tcl_AppendObjToObj(result, Tcl_NewDoubleObj(fval));
}

/*
 *----------------------------------------------------------------------
 *
 * WmClientCmd --
 *
 *	This procedure is invoked to process the "wm client" Tcl command.
 *	See the user documentation for details on what it does.
1447
1448
1449
1450
1451
1452
1453
1454
1455
1456
1457
1458
1459
1460
1461
1462
1463
1464
1465
1466
1467
1468
1469
1470
        if (wmPtr->hints.icon_pixmap != None) {
            Tk_FreeBitmap(winPtr->display, wmPtr->hints.icon_pixmap);
            wmPtr->hints.icon_pixmap = None;
        }
        wmPtr->hints.flags &= ~IconPixmapHint;
    } else {
        OSErr err;
        FSSpec spec;
        FSRef ref;
        Boolean isDirectory;
        err = FSPathMakeRef(Tcl_GetStringFromObj(objv[3], NULL), &ref, &isDirectory);
        if (err == noErr) {
            err = FSGetCatalogInfo (&ref, kFSCatInfoNone, NULL, NULL, &spec, NULL);
            if (err == noErr) {
                WindowRef macWin
                        = GetWindowFromPort(TkMacOSXGetDrawablePort(winPtr->window));
                SetWindowProxyFSSpec(macWin, &spec);
                return TCL_OK;
            }
        }
        pixmap = Tk_GetBitmap(interp, (Tk_Window) winPtr,
                              Tk_GetUid(Tcl_GetStringFromObj(objv[3], NULL)));
        if (pixmap == None) {
            return TCL_ERROR;







|




|



|







1593
1594
1595
1596
1597
1598
1599
1600
1601
1602
1603
1604
1605
1606
1607
1608
1609
1610
1611
1612
1613
1614
1615
1616
        if (wmPtr->hints.icon_pixmap != None) {
            Tk_FreeBitmap(winPtr->display, wmPtr->hints.icon_pixmap);
            wmPtr->hints.icon_pixmap = None;
        }
        wmPtr->hints.flags &= ~IconPixmapHint;
    } else {
        OSErr err;
        AliasHandle alias;
        FSRef ref;
        Boolean isDirectory;
        err = FSPathMakeRef(Tcl_GetStringFromObj(objv[3], NULL), &ref, &isDirectory);
        if (err == noErr) {
            err = FSNewAlias(NULL, &ref, &alias);
            if (err == noErr) {
                WindowRef macWin
                        = GetWindowFromPort(TkMacOSXGetDrawablePort(winPtr->window));
                SetWindowProxyAlias(macWin, alias);
                return TCL_OK;
            }
        }
        pixmap = Tk_GetBitmap(interp, (Tk_Window) winPtr,
                              Tk_GetUid(Tcl_GetStringFromObj(objv[3], NULL)));
        if (pixmap == None) {
            return TCL_ERROR;