Import Tk 8.5.15 (as of svn r89086)

This commit is contained in:
Zachary Ware
2017-09-04 14:25:47 -05:00
parent 4b29e0458f
commit 27e7dfc7da
883 changed files with 499023 additions and 6 deletions

315
macosx/GNUmakefile Normal file
View File

@@ -0,0 +1,315 @@
########################################################################################################
#
# Makefile wrapper to build tk on Mac OS X in a way compatible with the tk/macosx Xcode buildsystem
# uses the standard unix build system in tk/unix (which can be used directly instead of this
# if you are not using the tk/macosx projects).
#
# Copyright (c) 2002-2008 Daniel A. Steffen <das@users.sourceforge.net>
#
# See the file "license.terms" for information on usage and redistribution of
# this file, and for a DISCLAIMER OF ALL WARRANTIES.
#
########################################################################################################
#-------------------------------------------------------------------------------------------------------
# customizable settings
DESTDIR ?=
INSTALL_ROOT ?= ${DESTDIR}
BUILD_DIR ?= ${CURDIR}/../../build
SYMROOT ?= ${BUILD_DIR}/${PROJECT}
OBJROOT ?= ${SYMROOT}
EXTRA_CONFIGURE_ARGS ?=
EXTRA_MAKE_ARGS ?=
INSTALL_PATH ?= /Library/Frameworks
APPLICATION_INSTALL_PATH ?= /Applications/Utilities
PREFIX ?= /usr/local
BINDIR ?= ${PREFIX}/bin
LIBDIR ?= ${INSTALL_PATH}
MANDIR ?= ${PREFIX}/man
# tcl build directory (containing tclConfig.sh and Makefile)
TCL_BUILD_DIR ?= ${BUILD_DIR}/tcl/${BUILD_STYLE}
# location of installed tcl, only used if tcl in TCL_BUILD_DIR can't be found
TCL_FRAMEWORK_DIR ?= /Library/Frameworks
TCLSH_DIR ?= ${PREFIX}
# set to non-empty value to install manpages in addition to html help:
INSTALL_MANPAGES ?=
# set to non-empty value to build TkX11 instead of TkAqua:
TK_X11 ?=
#-------------------------------------------------------------------------------------------------------
# meta targets
meta := all install embedded install-embedded clean distclean test
styles := develop deploy
all := ${styles}
all : ${all}
install := ${styles:%=install-%}
install : ${install}
install-%: action := install-
embedded := ${styles:%=embedded-%}
embedded : embedded-deploy
install-embedded := ${embedded:%=install-%}
install-embedded : install-embedded-deploy
clean := ${styles:%=clean-%}
clean : ${clean}
clean-%: action := clean-
distclean := ${styles:%=distclean-%}
distclean : ${distclean}
distclean-%: action := distclean-
test := ${styles:%=test-%}
test : ${test}
test-%: action := test-
targets := $(foreach v,${meta},${$v})
#-------------------------------------------------------------------------------------------------------
# build styles
BUILD_STYLE =
CONFIGURE_ARGS =
OBJ_DIR = ${OBJROOT}/${BUILD_STYLE}
empty :=
space := ${empty} ${empty}
objdir = $(subst ${space},\ ,${OBJ_DIR})
develop_make_args := BUILD_STYLE=Development CONFIGURE_ARGS=--enable-symbols
deploy_make_args := BUILD_STYLE=Deployment INSTALL_TARGET=install-strip
embedded_make_args := EMBEDDED_BUILD=1
install_make_args := INSTALL_BUILD=1
${targets}:
${MAKE} ${action}${PROJECT} \
$(foreach s,${styles} embedded install,$(if $(findstring $s,$@),${${s}_make_args}))
#-------------------------------------------------------------------------------------------------------
# project specific settings
PROJECT := tk
PRODUCT_NAME := Tk
UNIX_DIR := ${CURDIR}/../unix
VERSION := $(shell awk -F= '/^TK_VERSION/ {print $$2; nextfile}' ${UNIX_DIR}/configure.in)
TCL_VERSION := ${VERSION}
wish := wish
WISH = wish${VERSION}
BUILD_TARGET := all tktest
INSTALL_TARGET := install
ifneq ($(wildcard $(subst ${space},\ ,${TCL_BUILD_DIR})/tclConfig.sh),)
TCL_DIR := ${TCL_BUILD_DIR}
TCL_FRAMEWORK_DIR := ${TCL_BUILD_DIR}/..
MAKE_VARS :=
else
TCL_DIR := ${TCL_FRAMEWORK_DIR}/Tcl.framework
TCL_EXE := ${TCLSH_DIR}/tclsh${TCL_VERSION}
MAKE_VARS := TCL_EXE
export DYLD_FRAMEWORK_PATH := ${TCL_FRAMEWORK_DIR}
endif
export CPPROG := cp -p
ifeq (${TK_X11},)
override CONFIGURE_ARGS := ${CONFIGURE_ARGS} --enable-aqua
else
override CONFIGURE_ARGS := ${CONFIGURE_ARGS} --enable-xft
VERSION := ${VERSION}-X11
wish := ${wish}-X11
override EMBEDDED_BUILD :=
endif
INSTALL_TARGETS = install-binaries install-libraries
ifeq (${EMBEDDED_BUILD},)
INSTALL_TARGETS += install-private-headers install-demos
endif
ifeq (${INSTALL_BUILD}_${EMBEDDED_BUILD}_${BUILD_STYLE},1__Deployment)
INSTALL_TARGETS += html-tk
ifneq (${INSTALL_MANPAGES},)
INSTALL_TARGETS += install-doc
endif
endif
MAKE_VARS += INSTALL_ROOT INSTALL_TARGETS VERSION
MAKE_ARGS_V = $(foreach v,${MAKE_VARS},$v='${$v}')
build-${PROJECT}: target = ${BUILD_TARGET}
install-${PROJECT}: target = ${INSTALL_TARGET}
clean-${PROJECT} distclean-${PROJECT} test-${PROJECT}: \
target = $*
DO_MAKE = +${MAKE} -C "${OBJ_DIR}" ${target} ${MAKE_ARGS_V} ${MAKE_ARGS} ${EXTRA_MAKE_ARGS}
#-------------------------------------------------------------------------------------------------------
# locations for custom tk install actions
ifeq (${INSTALL_BUILD},1)
TOP_DIR := ${INSTALL_ROOT}/
APP_DIR := ${APPLICATION_INSTALL_PATH}
FMWK_DIR := ${LIBDIR}
else
TOP_DIR := ${SYMROOT}
APP_DIR := .
FMWK_DIR := .
endif
TCL_FMWK_DIR := ${FMWK_DIR}/Tcl.framework/Versions/${TCL_VERSION}
TK_FMWK_DIR := ${FMWK_DIR}/${PRODUCT_NAME}.framework/Versions/${VERSION}
#-------------------------------------------------------------------------------------------------------
# build rules
${PROJECT}:
${MAKE} install-${PROJECT} INSTALL_ROOT="${OBJ_DIR}/"
${objdir}/Makefile: ${UNIX_DIR}/Makefile.in ${UNIX_DIR}/configure \
${UNIX_DIR}/tkConfig.sh.in Tk-Info.plist.in Wish-Info.plist.in
mkdir -p "${OBJ_DIR}" && cd "${OBJ_DIR}" && \
if [ ${UNIX_DIR}/configure -nt config.status ]; then ${UNIX_DIR}/configure -C \
--prefix="${PREFIX}" --bindir="${BINDIR}" --libdir="${LIBDIR}" \
--mandir="${MANDIR}" --enable-threads --enable-framework \
--with-tcl="${TCL_DIR}" \
${CONFIGURE_ARGS} ${EXTRA_CONFIGURE_ARGS}; else ./config.status; fi
ifneq (${VERSION},${TCL_VERSION})
@cd "${OBJ_DIR}" && sed -e 's#/Versions/${TCL_VERSION}#/Versions/${VERSION}#' \
tkConfig.sh > tkConfig.sh.1 && mv -f tkConfig.sh.1 tkConfig.sh
endif
build-${PROJECT}: ${objdir}/Makefile
${DO_MAKE}
ifeq (${INSTALL_BUILD},)
# symolic link hackery to trick
# 'make install INSTALL_ROOT=${OBJ_DIR}'
# into building Tk.framework and wish in ${SYMROOT}
@cd "${OBJ_DIR}" && mkdir -p $(dir $(subst ${space},\ ,./${LIBDIR})) $(dir $(subst ${space},\ ,./${BINDIR})) "${SYMROOT}" && \
rm -rf "./${LIBDIR}" "./${BINDIR}" && ln -fs "${SYMROOT}" "./${LIBDIR}" && \
ln -fs "${SYMROOT}" "./${BINDIR}" && ln -fs "${OBJ_DIR}/tktest" "${SYMROOT}"
ifeq (${TK_X11},)
@rm -f "${OBJ_DIR}/${BINDIR}" && \
ln -fs Wish.app/Contents/MacOS/Wish "${SYMROOT}/${WISH}"
endif
# Create symbolic link to Tcl.framework in ${SYMROOT}if necessary
@cd "${SYMROOT}" && if [ ! -e Tcl.framework -o -L Tcl.framework ]; then \
rm -f Tcl.framework && ln -s "${TCL_FRAMEWORK_DIR}/Tcl.framework" . ; fi
endif
install-${PROJECT}: build-${PROJECT}
ifeq (${EMBEDDED_BUILD}_${INSTALL_ROOT},1_)
@echo "Cannot install-embedded with empty INSTALL_ROOT !" && false
endif
ifeq (${EMBEDDED_BUILD},1)
@rm -rf "${INSTALL_ROOT}/${LIBDIR}/Tk.framework"
endif
${DO_MAKE}
ifeq (${EMBEDDED_BUILD}_${TK_X11},1_)
# workaround bug with 'cp -pRH' on Darwin 6 and earlier
@if [ "`uname -r | awk -F. '{print $$1}'`" -lt 7 ]; then \
mkdir -p "${TOP_DIR}"/{"${TCL_FMWK_DIR}","${TK_FMWK_DIR}"}/PrivateHeaders; fi
endif
ifeq (${INSTALL_BUILD},1)
ifeq (${EMBEDDED_BUILD},1)
# if we are embedding frameworks, don't install wish
@rm -f "${INSTALL_ROOT}${BINDIR}/${WISH}" && \
rmdir -p "${INSTALL_ROOT}${BINDIR}" 2>&- || true
else
# redo prebinding (when not building for Mac OS X 10.4 or later only)
@if [ "`echo "$${MACOSX_DEPLOYMENT_TARGET}" | \
awk -F '10\\.' '{print int($$2)}'`" -lt 4 -a "`echo "$${CFLAGS}" | \
awk -F '-mmacosx-version-min=10\\.' '{print int($$2)}'`" -lt 4 ]; \
then cd ${INSTALL_ROOT}/; \
if [ ! -d usr/lib ]; then mkdir -p usr && ln -fs /usr/lib usr/ && RM_USRLIB=1; fi; \
if [ -n "${TK_X11}" -a ! -d usr/X11R6 ]; then mkdir -p usr && ln -fs /usr/X11R6 usr/ && RM_USRX11=1; fi; \
if [ ! -d System ]; then ln -fs /System . && RM_SYSTEM=1; fi; \
if [ ! -d "./${LIBDIR}/Tcl.framework" ]; then ln -fs "${TCL_FRAMEWORK_DIR}/Tcl.framework" "./${LIBDIR}"; RM_TCL=1; fi; \
redo_prebinding -r . "./${TK_FMWK_DIR}/${PRODUCT_NAME}"; \
if [ -z "${TK_X11}" ]; then redo_prebinding -r . "./${TK_FMWK_DIR}/Resources/Wish.app/Contents/MacOS/Wish"; \
else redo_prebinding -r . "./${BINDIR}/${WISH}"; fi; \
if [ -n "$${RM_USRLIB:-}" ]; then rm -f usr/lib; rmdir -p usr 2>&-; fi; \
if [ -n "$${RM_USRX11:-}" ]; then rm -f usr/X11R6; rmdir -p usr 2>&-; fi; \
if [ -n "$${RM_SYSTEM:-}" ]; then rm -f System; fi; \
if [ -n "$${RM_TCL:-}" ]; then rm -f "./${LIBDIR}/Tcl.framework"; fi; fi
# install wish symbolic link
@ln -fs ${WISH} "${INSTALL_ROOT}${BINDIR}/${wish}"
endif
endif
ifeq (${BUILD_STYLE}_${EMBEDDED_BUILD},Development_)
# keep copy of debug library around, so that
# Deployment build can be installed on top
# of Development build without overwriting
# the debug library
@cd "${INSTALL_ROOT}${LIBDIR}/${PRODUCT_NAME}.framework/Versions/${VERSION}" && \
ln -f "${PRODUCT_NAME}" "${PRODUCT_NAME}_debug"
endif
ifeq (${TK_X11},)
ifeq (${EMBEDDED_BUILD},)
# install Wish.app link in APPLICATION_INSTALL_PATH and setup 'Wish Shell' compatibility links
@cd "${TOP_DIR}" && if [ -n "${APP_DIR}" ]; then mkdir -p "./${APP_DIR}" && rm -rf "./${APP_DIR}/Wish.app" && \
ln -fsh "./$$(echo "${APP_DIR}" | sed -e 's#/[^/][^/]*#/..#g')/${FMWK_DIR}/${PRODUCT_NAME}.framework/Resources/Wish.app" "./${APP_DIR}" && \
ln -fsh Wish.app "./${APP_DIR}/Wish Shell.app"; fi && \
ln -fsh Wish.app "./${TK_FMWK_DIR}/Resources/Wish Shell.app" && \
ln -fsh Wish "./${TK_FMWK_DIR}/Resources/Wish.app/Contents/MacOS/Wish Shell"
else
# if we are embedding frameworks, move them into the app and fix their install names
@cd "${TOP_DIR}" && \
rm -rf "./${APP_DIR}/Wish.app" && mkdir -p "./${APP_DIR}" && \
mv -f "./${TK_FMWK_DIR}/Resources/Wish.app" "./${APP_DIR}" && \
ln -fsh Wish.app "./${APP_DIR}/Wish Shell.app" && \
rm -rf "./${APP_DIR}/Wish.app/Contents/Frameworks" && \
mkdir -p "./${APP_DIR}/Wish.app/Contents/Frameworks" && \
${CPPROG} -RH "./${FMWK_DIR}"/T{cl,k}.framework "./${APP_DIR}/Wish.app/Contents/Frameworks" && \
cd "./${APP_DIR}/Wish.app/Contents" && \
rm -rf Frameworks/Tcl.framework/{,/Versions/${TCL_VERSION}}/{Headers,PrivateHeaders,*_debug,lib*.a,*Config.sh} && \
rm -rf Frameworks/Tk.framework/{,/Versions/${VERSION}}/{Headers,PrivateHeaders,*_debug,lib*.a,*Config.sh} && \
fix_install_id ( ) { \
chmod -RH a+w "$$1"; \
install_name_tool -id $$(otool -L "$$1" | awk "/$$2\.framework.*[^:]\$$/ {sub(\"^.*/Frameworks\",\"@executable_path/../Frameworks\",\$$1); print \$$1}") "$$1"; \
chmod -RH a-w "$$1"; \
} && \
fix_install_name ( ) { \
chmod -RH a+w "$$1"; \
install_name_tool -change $$(otool -L "$$1" | awk "/$$2\.framework.*[^:]\$$/ {print \$$1; sub(\"^.*/Frameworks\",\"@executable_path/../Frameworks\",\$$1); print \$$1}") "$$1"; \
chmod -RH a-w "$$1"; \
} && \
fix_install_id Frameworks/Tcl.framework/Tcl Tcl && fix_install_id Frameworks/Tk.framework/Tk Tk && \
fix_install_name MacOS/Wish Tcl && fix_install_name MacOS/Wish Tk
ifeq (${INSTALL_BUILD},1)
@cd "${TOP_DIR}" && rm -rf "./${FMWK_DIR}"/T{cl,k}.framework && rmdir -p "./${FMWK_DIR}" 2>&- || true
endif
endif
endif
clean-${PROJECT}: %-${PROJECT}:
${DO_MAKE}
rm -rf "${SYMROOT}"/{${PRODUCT_NAME}.framework,${WISH},tktest}
rm -f "${OBJ_DIR}"{"${LIBDIR}","${BINDIR}"} && \
rmdir -p "${OBJ_DIR}"$(dir $(subst ${space},\ ,${LIBDIR})) 2>&- || true && \
rmdir -p "${OBJ_DIR}"$(dir $(subst ${space},\ ,${BINDIR})) 2>&- || true
distclean-${PROJECT}: %-${PROJECT}: clean-${PROJECT}
${DO_MAKE}
rm -rf "${OBJ_DIR}"
test-${PROJECT}: %-${PROJECT}: build-${PROJECT}
${DO_MAKE}
#-------------------------------------------------------------------------------------------------------
.PHONY: ${meta} ${targets} ${PROJECT} build-${PROJECT} install-${PROJECT} \
clean-${PROJECT} distclean-${PROJECT}
.NOTPARALLEL:
#-------------------------------------------------------------------------------------------------------

388
macosx/README Normal file
View File

@@ -0,0 +1,388 @@
Tcl/Tk Mac OS X README
----------------------
This is the README file for the Mac OS X/Darwin version of Tcl/Tk.
1. Where to go for support
--------------------------
- The tcl-mac mailing list on sourceforge is the best place to ask questions
specific to Tcl & Tk on Mac OS X:
http://lists.sourceforge.net/lists/listinfo/tcl-mac
(this page also has a link to searchable archives of the list, please check them
before asking on the list, many questions have already been answered).
- For general Tcl/Tk questions, the newsgroup comp.lang.tcl is your best bet:
http://groups.google.com/group/comp.lang.tcl/
- The Tcl'ers Wiki also has many pages dealing with Tcl & Tk on Mac OS X, see
http://wiki.tcl.tk/_/ref?N=3753
http://wiki.tcl.tk/_/ref?N=8361
- Please report bugs with Tk on Mac OS X to the tracker:
http://core.tcl.tk/tk/reportlist
2. Using Tcl/Tk on Mac OS X
---------------------------
- There are two versions of Tk available on Mac OS X: TkAqua using the native
aqua widgets and look&feel, and TkX11 using the traditional unix X11 wigets.
TkX11 requires an X11 server to be installed, such as Apple's X11 (which is
available as an optional or default install on recent Mac OS X).
TkAqua and TkX11 can be distinguished at runtime via [tk windowingsystem].
- At a minimum, Mac OS X 10.3 is required to run Tcl and TkX11.
TkAqua requires Mac OS X 10.5 or later (starting with the Cocoa-based Tk 8.5.7).
- Unless weak-linking is used, Tcl/Tk built on Mac OS X 10.x will not run on
10.y with y < x; on the other hand Tcl/Tk built on 10.y will always run on 10.x
with y <= x (but without any of the fixes and optimizations that would be
available in a binary built on 10.x).
Weak-linking is available on OS X 10.2 or later, it additionally allows Tcl/Tk
built on 10.x to run on any 10.y with x > y >= z (for a chosen z >= 2).
- Wish checks the Resources/Scripts directory in its application bundle for a
file called AppMain.tcl, if found it is used as the startup script and the
Scripts folder is added to the auto_path. This can be used to emulate the old
OS9 TclTk droplets.
- If standard input is a special file of zero length (e.g. /dev/null), Wish
brings up the Tk console window at startup. This is the case when double
clicking Wish in the Finder (or using 'open Wish.app' from the Terminal).
- Tcl extensions can be installed in any of:
$HOME/Library/Tcl /Library/Tcl /System/Library/Tcl
$HOME/Library/Frameworks /Library/Frameworks /System/Library/Frameworks
(searched in that order).
Given a potential package directory $pkg, Tcl on OSX checks for the file
$pkg/Resources/Scripts/pkgIndex.tcl as well as the usual $pkg/pkgIndex.tcl.
This allows building extensions as frameworks with all script files contained in
the Resources/Scripts directory of the framework.
- [load]able binary extensions can linked as either ordinary shared libraries
(.dylib) or as MachO bundles (since 8.4.10/8.5a3); bundles have the advantage
that they are [load]ed more efficiently from a tcl VFS (no temporary copy to the
native filesystem required), and prior to Mac OS X 10.5, only bundles can be
[unload]ed.
- The 'deploy' target of macosx/GNUmakefile installs the html manpages into the
standard documentation location in the Tcl/Tk frameworks:
Tcl.framework/Resources/Documentation/Reference/Tcl
Tk.framework/Resources/Documentation/Reference/Tk
No nroff manpages are installed by default by the GNUmakefile.
- The Tcl and Tk frameworks can be installed in any of the system's standard
framework directories:
$HOME/Library/Frameworks /Library/Frameworks /System/Library/Frameworks
- ${prefix}/bin/wish8.x is a script that calls a copy of 'Wish' contained in
Tk.framework/Resources
- if 'Wish' is started from the Finder or via 'open', $argv may contain a
"-psn_XXXX" argument. This is the process serial number, you may need to filter
it out for cross platform compatibility of your scripts.
- the env array is different when Wish is started from the Finder (i.e. via
LaunchServices) than when it (or tclsh) is invoked from the Terminal, in
particular PATH may not be what you expect. (Wish started by LaunchServices
inherits loginwindow's environment variables, which are essentially those set in
$HOME/.MacOSX/environment.plist, and are unrelated to those set in your shell).
- TkAqua drawing is antialiased by default, but (outline) linewidth can be used
to control whether a line/shape is drawn antialiased. The antialiasing threshold
is 0 by default (i.e. antialias everything), it can be changed by setting
set tk::mac::CGAntialiasLimit <limit>
in your script before drawing, in which case lines (or shapes with outlines)
thinner than <limit> pixels will not be antialiased.
- Text antialiasing by default uses the standard OS antialising settings.
Setting the global variable '::tk::mac::antialiasedtext' allows to control text
antialiasing from Tcl: a value of 1 enables AA, 0 disables AA and -1 restores
the default behaviour of respecting the OS settings.
- Scrollbars: There are two scrollbar variants in Aqua, normal & small. The
normal scrollbar has a small dimension of 15, the small variant 11.
Access to the small variant was added in Tk 8.4.2.
- The default metrics of native buttons, radiobuttons, checkboxes and
menubuttons in the Cocoa-based Tk 8.5.7 and later preserve compatibility with
the older Carbon-based implementation, you can turn off the compatibility
metrics to get more native-looking spacing by setting:
set tk::mac::useCompatibilityMetrics 0
- TkAqua provides access to native OS X images via the Tk native bitmap facility
(including any image file readable by NSImage). A native bitmap name is
interpreted as follows (in order):
- predefined builtin 32x32 icon name (stop, caution, document, etc)
- name defined by [tk::mac::iconBitmap]
- NSImage named image name
- NSImage url string
- 4-char OSType of IconServices icon
the syntax of [tk::mac::iconBitmap] is as follows:
tk::mac::iconBitmap name width height -kind value
where -kind is one of
-file icon of file at given path
-fileType icon of given file type
-osType icon of given 4-char OSType file type
-systemType icon for given IconServices 4-char OSType
-namedImage named NSImage for given name
-imageFile image at given path
This support was added with the Cocoa-based Tk 8.5.7.
- TkAqua cursor names are interpred as follows (in order):
- standard or platform-specific Tk cursor name (c.f. cursors.n)
- @path to any image file readable by NSImage
- NSImage named image name
Support for the latter two was added with the Cocoa-based Tk 8.5.7.
- The standard Tk dialog commands [tk_getOpenFile], [tk_chooseDirectory],
[tk_getSaveFile] and [tk_messageBox] all take an additional optional -command
parameter on TkAqua. If it is present, the given command prefix is evaluated at
the global level when the dialog closes, with the dialog command's result
appended (the dialog command itself returning an emtpy result). If the -parent
option is also present, the dialog is configured as a modeless (window-modal)
sheet attached to the parent window and the dialog command returns immediately.
Support for -command was added with the Cocoa-based Tk 8.5.7.
- The TkAqua-specific [tk::mac::standardAboutPanel] command brings the standard
Cocoa about panel to the front, with all its information filled in from your
application bundle files (i.e. standard about panel with no options specified).
See Apple Technote TN2179 and the AppKit documentation for -[NSApplication
orderFrontStandardAboutPanelWithOptions:] for details on the Info.plist keys and
app bundle files used by the about panel.
This support was added with the Cocoa-based Tk 8.5.7.
- TkAqua has three special menu names that give access to the standard
Application, Window and Help menus, see menu.n for details.
By default, the platform-specific standard Help menu item "YourApp Help" peforms
the default Cocoa action of showing the Help Book configured in the
application's Info.plist (or displaying an alert if no Help Book is set). This
action can be customized by defining a procedure named [tk::mac::ShowHelp], if
present, this procedure is invoked instead by the standard Help menu item.
Support for the Window menu and [tk::mac::ShowHelp] was added with the
Cocoa-based Tk 8.5.7.
- The TkAqua-specific command [tk::unsupported::MacWindowStyle style] is used to
get and set Mac OS X-specific toplevel window class and attributes. Note that
the window class and many attributes have to be set before the window is first
mapped for the change to have any effect.
The command has the following syntax:
tk::unsupported::MacWindowStyle style window ?class? ?attributes?
The 2 argument form returns a list of the current class and attributes for the
given window. The 3 argument form sets the class for the given window using the
default attributes for that class. The 4 argument form sets the class and the
list of attributes for the given window.
Window class names:
document, modal, floating, utility, toolbar, simple, help, overlay
Window attribute names:
standardDocument, standardFloating, resizable, fullZoom, horizontalZoom,
verticalZoom, closeBox, collapseBox, toolbarButton, sideTitlebar,
noTitleBar, unifiedTitleAndToolbar, metal, hud, noShadow, doesNotCycle,
noActivates, hideOnSuspend, inWindowMenu, ignoreClicks, doesNotHide,
canJoinAllSpaces, moveToActiveSpace, nonActivating, black, dark, light,
gray, red, green, blue, cyan, yellow, magenta, orange, purple,
brown, clear, opacity
Note that not all attributes are valid for all window classes.
Support for the 3 argument form was added with the Cocoa-based Tk 8.5.7, at the
same time support for some legacy Carbon-specific classes and attributes was
removed (they are still accepted by the command but no longer have any effect).
The color window attributes (black, dark, red, etc.) and the "opacity" allow one to set the background and opacity of a textured ("metal") window. This allows a Tk window to implement a window without the dividing line between the titlebar and the rest of the window, or the "unified toolbar" effect, which is increasingly standard in Mac applications. An example:
toplevel .f
tk::unsupported::MacWindowStyle style .f document {metal light opaque closeBox collapseBox resizable standardDocument }
pack [label .f.f -bg #ababab -text "This is a textured window\nwith opacity and a gray background\nsimilar to other Mac applications"] -fill both -expand yes
The color attributes correspond to system-defined NSColor constants (e.g., red is [NSColor redColor]. The "light" and "dark" attributes correspond to lightGrayColor and darkGrayColor, respectively (because of the way the attributes are parsed, using "lightgray" and "darkgray" would cause a conflict with the core "gray" attribute).
Below are the corresponding hex and/or Tk-defined colors that can be used from Tk widgets to match the NSColor-based attributes:
black #000000
dark #545454
light #ababab
white #ffffff
gray #7f7f7f
red #ff0000
green #00ff00
blue #0000ff
cyan #00ffff
yellow #ffff00
magenta #ff00ff
orange #ff8000
purple #800080
brown #996633
clear systemTransparent
- The Cocoa-based TkAqua can be distinguished from the older Carbon-based
version via the [winfo server .] command, example output on Mac OS X 10.5.7:
Cocoa-based: CG409.3 Apple AppKit GC 949.46 Mac OS X 1057
Carbon-based: QD10R30 Apple 1057
- If you want to use Remote Debugging with Xcode, you need to set the
environment variable XCNOSTDIN to 1 in the Executable editor for Wish. That will
cause us to force closing stdin & stdout. Otherwise, given how Xcode launches
Wish remotely, they will be left open and then Wish & gdb will fight for stdin.
3. Building Tcl/Tk on Mac OS X
------------------------------
- At least Mac OS X 10.3 is required to build Tcl and TkX11, and Mac OS X 10.5
is required to build TkAqua.
Apple's Xcode Developer Tools need to be installed (only the most recent version
matching your OS release is supported), the Xcode installer is available on Mac
OS X install media or may be present in /Applications/Installers on Macs that
came with OS X preinstalled. The most recent version can always be downloaded
from the ADC website http://connect.apple.com (free ADC membership required).
- Tcl/Tk are most easily built as Mac OS X frameworks via GNUmakefile in
tcl/macosx and tk/macosx (see below for details), but can also be built with the
standard unix configure and make buildsystem in tcl/unix resp. tk/unix as on any
other unix platform (indeed, the GNUmakefiles are just wrappers around the unix
buildsystem).
The Mac OS X specific configure flags are --enable-aqua, --enable-framework and
--disable-corefoundation (which disables CF and notably reverts to the standard
select based notifier). Note that --enable-aqua is incompatible with
--disable-corefoundation (for both Tcl and Tk configure).
- It is also possible to build with the Xcode IDE via the projects in
tk/macosx, take care to use the project matching your DevTools and OS version:
Tk.xcode: for Xcode 3.1 on 10.5
Tk.xcodeproj: for Xcode 3.2 on 10.6
These have the following targets:
Tk: calls through to tk/macosx/GNUMakefile,
requires a corresponding build of the Tcl
target of tcl/macosx/Tcl.xcode.
tktest: static build of TkAqua tktest for debugging.
tktest-X11: static build of TkX11 tktest for debugging.
The following build configurations are available:
Debug: debug build for the active architecture,
with Fix & Continue enabled.
Debug gcc42: use gcc 4.2 compiler.
Debug gcc42 nogc: disable Objective-C garbage collection.
Debug llvmgcc42: use llvm-gcc 4.2 compiler.
DebugNoFixAndContinue: disable Fix & Continue.
DebugUnthreaded: disable threading.
DebugNoCF: disable corefoundation (X11 only).
DebugNoCFUnthreaded: disable corefoundation an threading.
DebugMemCompile: enable memory and bytecode debugging.
DebugLeaks: define PURIFY.
DebugGCov: enable generation of gcov data files.
Debug64bit: configure with --enable-64bit (requires
building on a 64bit capable processor).
Release: release build for the active architecture.
ReleaseUniversal: 32/64-bit universal build.
ReleaseUniversal gcc42: use gcc 4.2 compiler.
ReleaseUniversal llvmgcc42: use llvm-gcc 4.2 compiler.
ReleaseUniversal10.5SDK: build against the 10.5 SDK (with 10.5
deployment target).
Note that the non-SDK configurations have their deployment target set to
10.5 (Tk.xcode) resp. 10.6 (Tk.xcodeproj).
The Xcode projects refer to the toplevel tcl and tk source directories via the
the TCL_SRCROOT and TK_SRCROOT user build settings, by default these are set to
the project-relative paths '../../tcl' and '../../tk', if your source
directories are named differently, e.g. '../../tcl8.5' and '../../tk8.5', you
need to manually change the TCL_SRCROOT and TK_SRCROOT settings by editing your
${USER}.pbxuser file (located inside the Tk.xcodeproj bundle directory) with a
text editor.
- To build universal binaries outside of the Xcode IDE, set CFLAGS as follows:
export CFLAGS="-arch i386 -arch x86_64 -arch ppc"
This requires Mac OS X 10.4 and Xcode 2.4 (or Xcode 2.2 if -arch x86_64 is
omitted, but _not_ Xcode 2.1) and will work on any architecture (on PowerPC
Tiger you need to add "-isysroot /Developer/SDKs/MacOSX10.4u.sdk").
Note that configure requires CFLAGS to contain a least one architecture that can
be run on the build machine (i.e. ppc on G3/G4, ppc or ppc64 on G5, ppc or i386
on Core and ppc, i386 or x86_64 on Core2/Xeon).
Universal builds of Tcl TEA extensions are also possible with CFLAGS set as
above, they will be [load]able by universal as well as thin binaries of Tcl.
- To enable weak-linking, set the MACOSX_DEPLOYMENT_TARGET environment variable
to the minimal OS version the binaries should be able to run on, e.g:
export MACOSX_DEPLOYMENT_TARGET=10.4
This requires at least gcc 3.1; with gcc 4 or later, set/add to CFLAGS instead:
export CFLAGS="-mmacosx-version-min=10.4"
Support for weak-linking was added with 8.4.14/8.5a5.
Detailed Instructions for building with macosx/GNUmakefile
----------------------------------------------------------
- Unpack the Tcl and Tk source release archives and place the tcl and tk source
trees in a common parent directory.
[ If you don't want have the two source trees in one directory, you'll need to ]
[ create the following symbolic link for the build to work as setup by default ]
[ ln -fs /path_to_tcl/build /path_to_tk/build ]
[ (where /path_to_{tcl,tk} is the directory containing the tcl resp. tk tree) ]
[ or you can pass an argument of BUILD_DIR=/somewhere to the tcl and tk make. ]
- The following instructions assume the Tcl and Tk source trees are named
"tcl${ver}" and "tk${ver}" (where ${ver} is a shell variable containing the
Tcl/Tk version number, e.g. '8.5').
Setup this shell variable as follows:
ver="8.5"
If you are building from CVS, omit this step (CVS source tree names usually do
not contain a version number).
- Setup environment variables as desired, e.g. for a universal build on 10.5:
CFLAGS="-arch i386 -arch x86_64 -arch ppc -mmacosx-version-min=10.5"
export CFLAGS
- Change to the directory containing the Tcl and Tk source trees and build:
make -C tcl${ver}/macosx
make -C tk${ver}/macosx
- Install Tcl and Tk onto the root volume (admin password required):
sudo make -C tcl${ver}/macosx install
sudo make -C tk${ver}/macosx install
if you don't have an admin password, you can install into your home directory
instead by passing an INSTALL_ROOT argument to make:
make -C tcl${ver}/macosx install INSTALL_ROOT="${HOME}/"
make -C tk${ver}/macosx install INSTALL_ROOT="${HOME}/"
- The default GNUmakefile targets will build _both_ debug and optimized versions
of the Tcl and Tk frameworks with the standard convention of naming the debug
library Tcl.framework/Tcl_debug resp. Tk.framework/Tk_debug.
This allows switching to the debug libraries at runtime by setting
export DYLD_IMAGE_SUFFIX=_debug
(c.f. man dyld for more details)
If you only want to build and install the debug or optimized build, use the
'develop' or 'deploy' target variants of the GNUmakefile, respectively.
For example, to build and install only the optimized versions:
make -C tcl${ver}/macosx deploy
make -C tk${ver}/macosx deploy
sudo make -C tcl${ver}/macosx install-deploy
sudo make -C tk${ver}/macosx install-deploy
- The GNUmakefile can also build a version of Wish.app that has the Tcl and Tk
frameworks embedded in its application package. This allows for standalone
deployment of the application with no installation required, e.g. from read-only
media. To build & install in this manner, use the 'embedded' variants of
the GNUmakefile targets.
For example, to build a standalone 'Wish.app' in ./emb/Applications/Utilities:
make -C tcl${ver}/macosx embedded
make -C tk${ver}/macosx embedded
sudo make -C tcl${ver}/macosx install-embedded INSTALL_ROOT=`pwd`/emb/
sudo make -C tk${ver}/macosx install-embedded INSTALL_ROOT=`pwd`/emb/
Notes:
* if you've already built standard TclTkAqua, building embedded does not
require any new compiling or linking, so you can skip the first two makes.
(making relinking unnecessary was added with 8.4.2)
* the embedded frameworks include only optimized builds and no documentation.
* the standalone Wish has the directory Wish.app/Contents/lib in its
auto_path. Thus you can place tcl extensions in this directory (i.e. embed
them in the app package) and load them with [package require].
- It is possible to build Tk against an installed Tcl.framework; but you will
still need a tcl sourcetree in the location specified in TCL_SRC_DIR in
Tcl.framework/tclConfig.sh. Also, linking with Tcl.framework has to work exactly
as indicated in TCL_LIB_SPEC in Tcl.framework/tclConfig.sh.
If you used non-default install locations for Tcl.framework, specify them as
make overrides to the tk/macosx GNUmakefile, e.g.
make -C tk${ver}/macosx \
TCL_FRAMEWORK_DIR=$HOME/Library/Frameworks TCLSH_DIR=$HOME/usr/bin
sudo make -C tk${ver}/macosx install \
TCL_FRAMEWORK_DIR=$HOME/Library/Frameworks TCLSH_DIR=$HOME/usr/bin
The Makefile variables TCL_FRAMEWORK_DIR and TCLSH_DIR were added with Tk 8.4.3.

37
macosx/Tk-Info.plist.in Normal file
View File

@@ -0,0 +1,37 @@
<?xml version="1.0" encoding="UTF-8"?>
<!DOCTYPE plist PUBLIC "-//Apple Computer//DTD PLIST 1.0//EN" "http://www.apple.com/DTDs/PropertyList-1.0.dtd">
<!--
Copyright (c) 2005-2009 Daniel A. Steffen <das@users.sourceforge.net>
Copyright 2008-2009, Apple Inc.
See the file "license.terms" for information on usage and redistribution of
this file, and for a DISCLAIMER OF ALL WARRANTIES.
-->
<plist version="1.0">
<dict>
<key>CFBundleDevelopmentRegion</key>
<string>English</string>
<key>CFBundleExecutable</key>
<string>@TK_LIB_FILE@</string>
<key>CFBundleGetInfoString</key>
<string>Tk @TK_WINDOWINGSYSTEM@ @TK_VERSION@@TK_PATCH_LEVEL@,
Copyright © 1989-@TK_YEAR@ Tcl Core Team,
Copyright © 2002-@TK_YEAR@ Daniel A. Steffen,
Copyright © 2001-2009 Apple Inc.,
Copyright © 2001-2002 Jim Ingham &amp; Ian Reid</string>
<key>CFBundleIdentifier</key>
<string>com.tcltk.tklibrary</string>
<key>CFBundleInfoDictionaryVersion</key>
<string>6.0</string>
<key>CFBundleName</key>
<string>Tk @TK_WINDOWINGSYSTEM@ @TK_VERSION@</string>
<key>CFBundlePackageType</key>
<string>FMWK</string>
<key>CFBundleShortVersionString</key>
<string>@TK_VERSION@@TK_PATCH_LEVEL@</string>
<key>CFBundleSignature</key>
<string>Tk </string>
<key>CFBundleVersion</key>
<string>@TK_VERSION@@TK_PATCH_LEVEL@</string>
</dict>
</plist>

BIN
macosx/Tk.icns Normal file

Binary file not shown.

BIN
macosx/Tk.tiff Normal file

Binary file not shown.

View File

@@ -0,0 +1,50 @@
//
// Wish-Common.xcconfig --
//
// This file contains the Xcode build settings comon to all
// project configurations in Wish.xcodeproj.
//
// Copyright (c) 2007-2009 Daniel A. Steffen <das@users.sourceforge.net>
// Copyright 2008-2009, Apple Inc.
//
// See the file "license.terms" for information on usage and redistribution
// of this file, and for a DISCLAIMER OF ALL WARRANTIES.
//
HEADER_SEARCH_PATHS = $(TK_SRCROOT)/generic $(TK_SRCROOT)/xlib "$(DERIVED_FILE_DIR)/tcl" "$(DERIVED_FILE_DIR)/tk" $(HEADER_SEARCH_PATHS)
REZ_SEARCH_PATHS = $(TK_SRCROOT)/generic $(TCL_SRCROOT)/generic $(REZ_SEARCH_PATHS)
OTHER_LDFLAGS = -headerpad_max_install_names -sectcreate __TEXT __info_plist "$(DERIVED_FILE_DIR)/tk/Wish-Info.plist" $(OTHER_LDFLAGS)
OTHER_LDFLAGS_AQUA =
INSTALL_PATH = $(APPLICATION_INSTALL_PATH)
INSTALL_MODE_FLAG = go-w,a+rX
GCC_PREFIX_HEADER = $(DERIVED_FILE_DIR)/tk/tkConfig.h
OTHER_CFLAGS = -imacros "$(DERIVED_FILE_DIR)/tcl/tclConfig.h" $(OTHER_CFLAGS)
GCC_GENERATE_DEBUGGING_SYMBOLS = YES
GCC_NO_COMMON_BLOCKS = YES
GCC_DYNAMIC_NO_PIC = YES
GCC = $(DEVELOPER_DIR)/usr/bin/gcc
GCC_VERSION = 4.0
CC = $(GCC)-$(GCC_VERSION)
LD = $(CC)
WARNING_CFLAGS_GCC3 = -Wall -Wno-implicit-int -Wno-unused-parameter
WARNING_CFLAGS = -Wextra -Wno-missing-field-initializers -Winit-self -Wpointer-arith -Wcast-align -Wdisabled-optimization -Winline $(WARNING_CFLAGS_GCC3) $(WARNING_CFLAGS)
REZ_RESOURCE_MAP_READ_ONLY = YES
APPLICATION_INSTALL_PATH = /Applications/Utilities
BINDIR = $(PREFIX)/bin
CFLAGS = $(CFLAGS)
CPPFLAGS = -mmacosx-version-min=$(MACOSX_DEPLOYMENT_TARGET) $(CPPFLAGS)
FRAMEWORK_INSTALL_PATH = /Library/Frameworks
INCLUDEDIR = $(PREFIX)/include
LIBDIR = $(PREFIX)/lib
MANDIR = $(PREFIX)/man
PER_ARCH_CFLAGS_ppc = -mcpu=G3 -mtune=G4 $(PER_ARCH_CFLAGS_ppc)
PREFIX = /usr/local
TCL_BUILD_DIR = $(OBJROOT)/../tcl/Tcl.build/$(CONFIGURATION)/Tcl.build/Objects
TCL_CONFIGURE_ARGS = --enable-threads --enable-dtrace
TCL_FRAMEWORK_DIR = $(SYMROOT)/../tcl/$(CONFIGURATION)
TCL_LIBRARY = $(LIBDIR)/tcl$(VERSION)
TCL_PACKAGE_PATH = "$(LIBDIR)"
TCL_DEFS = HAVE_TCL_CONFIG_H
TK_LIBRARY = $(LIBDIR)/tk$(VERSION)
TK_DEFS = HAVE_TK_CONFIG_H TCL_NO_DEPRECATED
VERSION = 8.5

View File

@@ -0,0 +1,20 @@
//
// Wish-Debug.xcconfig --
//
// This file contains the Xcode build settings for all Debug
// project configurations in Wish.xcodeproj.
//
// Copyright (c) 2007 Daniel A. Steffen <das@users.sourceforge.net>
//
// See the file "license.terms" for information on usage and redistribution
// of this file, and for a DISCLAIMER OF ALL WARRANTIES.
//
#include "Wish-Common.xcconfig"
DEBUG_INFORMATION_FORMAT = dwarf
DEPLOYMENT_POSTPROCESSING = NO
GCC_OPTIMIZATION_LEVEL = 0
GCC_PREPROCESSOR_DEFINITIONS = DEBUGLEVEL=4 $(TCL_DEFS) $(TK_DEFS) $(GCC_PREPROCESSOR_DEFINITIONS)
CONFIGURE_ARGS = --enable-symbols $(TCL_CONFIGURE_ARGS) $(CONFIGURE_ARGS)
MAKE_TARGET = develop

76
macosx/Wish-Info.plist.in Normal file
View File

@@ -0,0 +1,76 @@
<?xml version="1.0" encoding="UTF-8"?>
<!DOCTYPE plist PUBLIC "-//Apple Computer//DTD PLIST 1.0//EN" "http://www.apple.com/DTDs/PropertyList-1.0.dtd">
<!--
Copyright (c) 2005-2009 Daniel A. Steffen <das@users.sourceforge.net>
Copyright 2008-2009, Apple Inc.
See the file "license.terms" for information on usage and redistribution of
this file, and for a DISCLAIMER OF ALL WARRANTIES.
-->
<plist version="1.0">
<dict>
<key>CFBundleDevelopmentRegion</key>
<string>English</string>
<key>CFBundleDocumentTypes</key>
<array>
<dict>
<key>CFBundleTypeExtensions</key>
<array>
<string>tcl</string>
<string>TCL</string>
<string>*</string>
</array>
<key>CFBundleTypeMIMETypes</key>
<array>
<string>application/x-tcl</string>
<string>text/plain</string>
</array>
<key>CFBundleTypeName</key>
<string>NSStringPboardType</string>
<key>CFBundleTypeOSTypes</key>
<array>
<string>TEXT</string>
<string>****</string>
</array>
<key>CFBundleTypeRole</key>
<string>Viewer</string>
</dict>
</array>
<key>CFBundleExecutable</key>
<string>Wish</string>
<key>CFBundleGetInfoString</key>
<string>Wish Shell @TK_VERSION@@TK_PATCH_LEVEL@,
Copyright © 1989-@TK_YEAR@ Tcl Core Team,
Copyright © 2002-@TK_YEAR@ Daniel A. Steffen,
Copyright © 2001-2009 Apple Inc.,
Copyright © 2001-2002 Jim Ingham &amp; Ian Reid</string>
<key>CFBundleIconFile</key>
<string>Wish.icns</string>
<key>CFBundleIdentifier</key>
<string>com.tcltk.wish</string>
<key>CFBundleInfoDictionaryVersion</key>
<string>6.0</string>
<key>CFBundleLocalizations</key>
<array>
@CFBUNDLELOCALIZATIONS@
</array>
<key>CFBundleName</key>
<string>Wish</string>
<key>CFBundlePackageType</key>
<string>APPL</string>
<key>CFBundleShortVersionString</key>
<string>@TK_VERSION@@TK_PATCH_LEVEL@</string>
<key>CFBundleSignature</key>
<string>WiSH</string>
<key>CFBundleVersion</key>
<string>@TK_VERSION@@TK_PATCH_LEVEL@</string>
<key>LSMinimumSystemVersion</key>
<string>10.5.0</string>
<key>LSRequiresCarbon</key>
<true/>
<key>NSAppleScriptEnabled</key>
<true/>
<key>OSAScriptingDefinition</key>
<string>Wish.sdef</string>
</dict>
</plist>

View File

@@ -0,0 +1,20 @@
//
// Wish-Release.xcconfig --
//
// This file contains the Xcode build settings for all Release
// project configurations in Wish.xcodeproj.
//
// Copyright (c) 2007 Daniel A. Steffen <das@users.sourceforge.net>
//
// See the file "license.terms" for information on usage and redistribution
// of this file, and for a DISCLAIMER OF ALL WARRANTIES.
//
#include "Wish-Common.xcconfig"
DEBUG_INFORMATION_FORMAT = dwarf-with-dsym
// DEPLOYMENT_POSTPROCESSING = YES
GCC_OPTIMIZATION_LEVEL = s
GCC_PREPROCESSOR_DEFINITIONS = NDEBUG $(TCL_DEFS) $(TK_DEFS) $(GCC_PREPROCESSOR_DEFINITIONS)
CONFIGURE_ARGS = --disable-symbols $(TCL_CONFIGURE_ARGS) $(CONFIGURE_ARGS)
MAKE_TARGET = deploy

BIN
macosx/Wish.icns Normal file

Binary file not shown.

37
macosx/Wish.sdef Normal file
View File

@@ -0,0 +1,37 @@
<?xml version="1.0" encoding="UTF-8"?>
<!DOCTYPE dictionary SYSTEM "file://localhost/System/Library/DTDs/sdef.dtd">
<!--
Copyright (c) 1997 Sun Microsystems, Inc.
Copyright 2009 Kevin Walzer/WordTech Communications LLC.
Copyright (c) 2009 Daniel A. Steffen <das@users.sourceforge.net>
See the file "license.terms" for information on usage and redistribution of
this file, and for a DISCLAIMER OF ALL WARRANTIES.
-->
<dictionary title="Wish Terminology">
<suite name="Standard Suite" code="reqd" description="Common commands for all applications.">
<command name="open" code="aevtodoc" description="Open a document.">
<direct-parameter description="The file(s) to be opened.">
<type type="file"/>
<type type="file" list="yes"/>
</direct-parameter>
</command>
<command name="print" code="aevtpdoc" description="Print a document.">
<direct-parameter description="The file(s) to be printed.">
<type type="file" list="yes"/>
<type type="specifier"/>
</direct-parameter>
</command>
<command name="quit" code="aevtquit" description="Quit the application."/>
</suite>
<suite name="Wish Suite" code="WIsH" description="Commands for the Wish application.">
<command name="do script" code="miscdosc" description="Execute a Tcl script.">
<direct-parameter description="Script to execute" type="text">
<type type="text"/>
</direct-parameter>
<result description="Result">
<type type="text"/>
</result>
</command>
</suite>
</dictionary>

View File

@@ -0,0 +1,342 @@
// !$*UTF8*$!
{
08FB7793FE84155DC02AAC07 /* Project object */ = {
activeBuildConfigurationName = Debug;
activeExecutable = F9E61D1C090A4282002B3151 /* Wish */;
activeTarget = F9E61D16090A3E94002B3151 /* Tk */;
codeSenseManager = F944EB9D08F798180049FDD4 /* Code sense */;
executables = (
F9E61D1C090A4282002B3151 /* Wish */,
F944EB8F08F798100049FDD4 /* tktest */,
F9FD31F50CC1AD070073837D /* tktest-X11 */,
);
perUserDictionary = {
com.apple.ide.smrt.PBXUserSmartGroupsKey.Rev10 = <040b73747265616d747970656481e8038401408484840e4e534d757461626c654172726179008484074e534172726179008484084e534f626a65637400858401690192848484134e534d757461626c6544696374696f6e6172790084840c4e5344696374696f6e6172790095960792848484084e53537472696e67019584012b046e616d658692849a9a14496d706c656d656e746174696f6e2046696c65738692849a9a146162736f6c75746550617468546f42756e646c658692849a9a008692849a9a195042585472616e7369656e744c6f636174696f6e4174546f708692849a9a06626f74746f6d8692849a9a03636c7a8692849a9a1550425846696c656e616d65536d61727447726f75708692849a9a0b6465736372697074696f6e8692849a9a103c6e6f206465736372697074696f6e3e8692849a9a0b707265666572656e63657386928497960892849a9a07666e6d617463688692849a9a008692849a9a05696d6167658692849a9a0b536d617274466f6c6465728692849a9a04726f6f748692849a9a093c50524f4a4543543e8692849a9a0572656765788692849a9a065c2e286329248692849a9a097265637572736976658692848484084e534e756d626572008484074e5356616c7565009584012a849696018692849a9a0669734c656166869284b09db296008692849a9a0763616e536176658692af92849a9a1250425850726f6a65637453636f70654b65798692849a9a03594553868692849a9a08676c6f62616c49448692849a9a18314343304541343030343335304546393030343434313042868686>;
};
sourceControlManager = F944EB9C08F798180049FDD4 /* Source Control */;
userBuildSettings = {
CODE_SIGN_IDENTITY = "";
SYMROOT = "${SRCROOT}/../../build/tk";
TCL_SRCROOT = "${SRCROOT}/../../tcl";
TK_SRCROOT = "${SRCROOT}/../../tk";
};
};
8DD76FA90486AB0100D96B5E /* tktest */ = {
activeExec = 0;
executables = (
F944EB8F08F798100049FDD4 /* tktest */,
);
};
F944EB8F08F798100049FDD4 /* tktest */ = {
isa = PBXExecutable;
activeArgIndices = (
YES,
NO,
NO,
NO,
NO,
NO,
NO,
);
argumentStrings = (
"${TK_SRCROOT}/library/demos/widget",
"${TK_SRCROOT}/tests/all.tcl",
"${TK_SRCROOT}/tests/ttk/all.tcl",
"-geometry +0+0",
"-singleproc 1",
"-verbose \"bet\"",
"-skip window-2.9",
);
autoAttachOnCrash = 1;
breakpointsEnabled = 1;
configStateDict = {
"PBXLSLaunchAction-0" = {
PBXLSLaunchAction = 0;
PBXLSLaunchStartAction = 1;
PBXLSLaunchStdioStyle = 2;
PBXLSLaunchStyle = 0;
class = PBXLSRunLaunchConfig;
displayName = "Executable Runner";
identifier = com.apple.Xcode.launch.runConfig;
remoteHostInfo = "";
startActionInfo = "";
};
"PBXLSLaunchAction-1" = {
PBXLSLaunchAction = 1;
PBXLSLaunchStartAction = 1;
PBXLSLaunchStdioStyle = 2;
PBXLSLaunchStyle = 0;
class = PBXGDB_LaunchConfig;
displayName = GDB;
identifier = com.apple.Xcode.launch.GDBMI_Config;
remoteHostInfo = "";
startActionInfo = "";
};
};
customDataFormattersEnabled = 1;
debuggerPlugin = GDBDebugging;
disassemblyDisplayState = 0;
dylibVariantSuffix = "";
enableDebugStr = 0;
environmentEntries = (
{
active = YES;
name = TCL_LIBRARY;
value = "${TCL_SRCROOT}/library";
},
{
active = YES;
name = TK_LIBRARY;
value = "${TK_SRCROOT}/library";
},
{
active = YES;
name = TCLLIBPATH;
value = /Library/Tcl;
},
{
active = YES;
name = TK_SRCROOT;
value = "${TK_SRCROOT}";
},
{
active = NO;
name = DYLD_PRINT_LIBRARIES;
},
{
active = NO;
name = EventDebug;
value = 1;
},
{
active = NO;
name = MallocBadFreeAbort;
value = 1;
},
{
active = NO;
name = MallocLogFile;
value = /tmp/malloc.log;
},
{
active = NO;
name = MallocStackLogging;
value = 1;
},
{
active = NO;
name = MallocStackLoggingNoCompact;
value = 1;
},
{
active = NO;
name = MallocPreScribble;
value = 1;
},
{
active = NO;
name = MallocScribble;
value = 1;
},
);
executableSystemSymbolLevel = 0;
executableUserSymbolLevel = 0;
libgmallocEnabled = 0;
name = tktest;
sourceDirectories = (
);
};
F944EB9C08F798180049FDD4 /* Source Control */ = {
isa = PBXSourceControlManager;
fallbackIsa = XCSourceControlManager;
isSCMEnabled = 0;
scmConfiguration = {
CVSToolPath = /usr/bin/cvs;
CVSUseSSH = NO;
SubversionToolPath = /usr/bin/svn;
};
scmType = scm.cvs;
};
F944EB9D08F798180049FDD4 /* Code sense */ = {
isa = PBXCodeSenseManager;
indexTemplatePath = "";
};
F9E61D16090A3E94002B3151 /* Tk */ = {
activeExec = 0;
executables = (
F9E61D1C090A4282002B3151 /* Wish */,
);
};
F9E61D1C090A4282002B3151 /* Wish */ = {
isa = PBXExecutable;
activeArgIndices = (
YES,
);
argumentStrings = (
"${TK_SRCROOT}/library/demos/widget",
);
autoAttachOnCrash = 1;
breakpointsEnabled = 1;
configStateDict = {
"PBXLSLaunchAction-0" = {
PBXLSLaunchAction = 0;
PBXLSLaunchStartAction = 1;
PBXLSLaunchStdioStyle = 2;
PBXLSLaunchStyle = 0;
class = PBXLSRunLaunchConfig;
displayName = "Executable Runner";
identifier = com.apple.Xcode.launch.runConfig;
remoteHostInfo = "";
startActionInfo = "";
};
"PBXLSLaunchAction-1" = {
PBXLSLaunchAction = 1;
PBXLSLaunchStartAction = 1;
PBXLSLaunchStdioStyle = 2;
PBXLSLaunchStyle = 0;
class = PBXGDB_LaunchConfig;
displayName = GDB;
identifier = com.apple.Xcode.launch.GDBMI_Config;
remoteHostInfo = "";
startActionInfo = "";
};
};
customDataFormattersEnabled = 1;
debuggerPlugin = GDBDebugging;
disassemblyDisplayState = 0;
dylibVariantSuffix = "";
enableDebugStr = 0;
environmentEntries = (
{
active = NO;
name = DYLD_PRINT_LIBRARIES;
},
);
executableSystemSymbolLevel = 0;
executableUserSymbolLevel = 0;
libgmallocEnabled = 0;
name = Wish;
sourceDirectories = (
);
};
F97258A50A86873C00096C78 /* tktest-X11 */ = {
activeExec = 0;
executables = (
F9FD31F50CC1AD070073837D /* tktest-X11 */,
);
};
F9FD31F50CC1AD070073837D /* tktest-X11 */ = {
isa = PBXExecutable;
activeArgIndices = (
YES,
NO,
NO,
NO,
NO,
NO,
NO,
);
argumentStrings = (
"${TK_SRCROOT}/library/demos/widget",
"${TK_SRCROOT}/tests/all.tcl",
"${TK_SRCROOT}/tests/ttk/all.tcl",
"-geometry +0+0",
"-singleproc 1",
"-verbose \"bet\"",
"-skip window-2.9",
);
autoAttachOnCrash = 1;
breakpointsEnabled = 1;
configStateDict = {
"PBXLSLaunchAction-0" = {
PBXLSLaunchAction = 0;
PBXLSLaunchStartAction = 1;
PBXLSLaunchStdioStyle = 2;
PBXLSLaunchStyle = 0;
class = PBXLSRunLaunchConfig;
displayName = "Executable Runner";
identifier = com.apple.Xcode.launch.runConfig;
remoteHostInfo = "";
startActionInfo = "";
};
"PBXLSLaunchAction-1" = {
PBXLSLaunchAction = 1;
PBXLSLaunchStartAction = 1;
PBXLSLaunchStdioStyle = 2;
PBXLSLaunchStyle = 0;
class = PBXGDB_LaunchConfig;
displayName = GDB;
identifier = com.apple.Xcode.launch.GDBMI_Config;
remoteHostInfo = "";
startActionInfo = "";
};
};
customDataFormattersEnabled = 1;
debuggerPlugin = GDBDebugging;
disassemblyDisplayState = 0;
dylibVariantSuffix = "";
enableDebugStr = 0;
environmentEntries = (
{
active = YES;
name = TCL_LIBRARY;
value = "${TCL_SRCROOT}/library";
},
{
active = YES;
name = TK_LIBRARY;
value = "${TK_SRCROOT}/library";
},
{
active = YES;
name = TCLLIBPATH;
value = /Library/Tcl;
},
{
active = YES;
name = DISPLAY;
value = ":0";
},
{
active = NO;
name = DYLD_PRINT_LIBRARIES;
},
{
active = NO;
name = MallocBadFreeAbort;
value = 1;
},
{
active = NO;
name = MallocLogFile;
value = /tmp/malloc.log;
},
{
active = NO;
name = MallocStackLogging;
value = 1;
},
{
active = NO;
name = MallocStackLoggingNoCompact;
value = 1;
},
{
active = NO;
name = MallocPreScribble;
value = 1;
},
{
active = NO;
name = MallocScribble;
value = 1;
},
);
executableSystemSymbolLevel = 0;
executableUserSymbolLevel = 0;
libgmallocEnabled = 0;
name = "tktest-X11";
sourceDirectories = (
);
};
}

File diff suppressed because it is too large Load Diff

View File

@@ -0,0 +1,342 @@
// !$*UTF8*$!
{
08FB7793FE84155DC02AAC07 /* Project object */ = {
activeBuildConfigurationName = Debug;
activeExecutable = F9E61D1C090A4282002B3151 /* Wish */;
activeTarget = F9E61D16090A3E94002B3151 /* Tk */;
codeSenseManager = F944EB9D08F798180049FDD4 /* Code sense */;
executables = (
F9E61D1C090A4282002B3151 /* Wish */,
F944EB8F08F798100049FDD4 /* tktest */,
F9FD31F50CC1AD070073837D /* tktest-X11 */,
);
perUserDictionary = {
com.apple.ide.smrt.PBXUserSmartGroupsKey.Rev10 = <040b73747265616d747970656481e8038401408484840e4e534d757461626c654172726179008484074e534172726179008484084e534f626a65637400858401690192848484134e534d757461626c6544696374696f6e6172790084840c4e5344696374696f6e6172790095960792848484084e53537472696e67019584012b046e616d658692849a9a14496d706c656d656e746174696f6e2046696c65738692849a9a146162736f6c75746550617468546f42756e646c658692849a9a008692849a9a195042585472616e7369656e744c6f636174696f6e4174546f708692849a9a06626f74746f6d8692849a9a03636c7a8692849a9a1550425846696c656e616d65536d61727447726f75708692849a9a0b6465736372697074696f6e8692849a9a103c6e6f206465736372697074696f6e3e8692849a9a0b707265666572656e63657386928497960892849a9a07666e6d617463688692849a9a008692849a9a05696d6167658692849a9a0b536d617274466f6c6465728692849a9a04726f6f748692849a9a093c50524f4a4543543e8692849a9a0572656765788692849a9a065c2e286329248692849a9a097265637572736976658692848484084e534e756d626572008484074e5356616c7565009584012a849696018692849a9a0669734c656166869284b09db296008692849a9a0763616e536176658692af92849a9a1250425850726f6a65637453636f70654b65798692849a9a03594553868692849a9a08676c6f62616c49448692849a9a18314343304541343030343335304546393030343434313042868686>;
};
sourceControlManager = F944EB9C08F798180049FDD4 /* Source Control */;
userBuildSettings = {
CODE_SIGN_IDENTITY = "";
SYMROOT = "${SRCROOT}/../../build/tk";
TCL_SRCROOT = "${SRCROOT}/../../tcl";
TK_SRCROOT = "${SRCROOT}/../../tk";
};
};
8DD76FA90486AB0100D96B5E /* tktest */ = {
activeExec = 0;
executables = (
F944EB8F08F798100049FDD4 /* tktest */,
);
};
F944EB8F08F798100049FDD4 /* tktest */ = {
isa = PBXExecutable;
activeArgIndices = (
YES,
NO,
NO,
NO,
NO,
NO,
NO,
);
argumentStrings = (
"${TK_SRCROOT}/library/demos/widget",
"${TK_SRCROOT}/tests/all.tcl",
"${TK_SRCROOT}/tests/ttk/all.tcl",
"-geometry +0+0",
"-singleproc 1",
"-verbose \"bet\"",
"-skip window-2.9",
);
autoAttachOnCrash = 1;
breakpointsEnabled = 1;
configStateDict = {
"PBXLSLaunchAction-0" = {
PBXLSLaunchAction = 0;
PBXLSLaunchStartAction = 1;
PBXLSLaunchStdioStyle = 2;
PBXLSLaunchStyle = 0;
class = PBXLSRunLaunchConfig;
displayName = "Executable Runner";
identifier = com.apple.Xcode.launch.runConfig;
remoteHostInfo = "";
startActionInfo = "";
};
"PBXLSLaunchAction-1" = {
PBXLSLaunchAction = 1;
PBXLSLaunchStartAction = 1;
PBXLSLaunchStdioStyle = 2;
PBXLSLaunchStyle = 0;
class = PBXGDB_LaunchConfig;
displayName = GDB;
identifier = com.apple.Xcode.launch.GDBMI_Config;
remoteHostInfo = "";
startActionInfo = "";
};
};
customDataFormattersEnabled = 1;
debuggerPlugin = GDBDebugging;
disassemblyDisplayState = 0;
dylibVariantSuffix = "";
enableDebugStr = 0;
environmentEntries = (
{
active = YES;
name = TCL_LIBRARY;
value = "${TCL_SRCROOT}/library";
},
{
active = YES;
name = TK_LIBRARY;
value = "${TK_SRCROOT}/library";
},
{
active = YES;
name = TCLLIBPATH;
value = /Library/Tcl;
},
{
active = YES;
name = TK_SRCROOT;
value = "${TK_SRCROOT}";
},
{
active = NO;
name = DYLD_PRINT_LIBRARIES;
},
{
active = NO;
name = EventDebug;
value = 1;
},
{
active = NO;
name = MallocBadFreeAbort;
value = 1;
},
{
active = NO;
name = MallocLogFile;
value = /tmp/malloc.log;
},
{
active = NO;
name = MallocStackLogging;
value = 1;
},
{
active = NO;
name = MallocStackLoggingNoCompact;
value = 1;
},
{
active = NO;
name = MallocPreScribble;
value = 1;
},
{
active = NO;
name = MallocScribble;
value = 1;
},
);
executableSystemSymbolLevel = 0;
executableUserSymbolLevel = 0;
libgmallocEnabled = 0;
name = tktest;
sourceDirectories = (
);
};
F944EB9C08F798180049FDD4 /* Source Control */ = {
isa = PBXSourceControlManager;
fallbackIsa = XCSourceControlManager;
isSCMEnabled = 0;
scmConfiguration = {
CVSToolPath = /usr/bin/cvs;
CVSUseSSH = NO;
SubversionToolPath = /usr/bin/svn;
};
scmType = scm.cvs;
};
F944EB9D08F798180049FDD4 /* Code sense */ = {
isa = PBXCodeSenseManager;
indexTemplatePath = "";
};
F9E61D16090A3E94002B3151 /* Tk */ = {
activeExec = 0;
executables = (
F9E61D1C090A4282002B3151 /* Wish */,
);
};
F9E61D1C090A4282002B3151 /* Wish */ = {
isa = PBXExecutable;
activeArgIndices = (
YES,
);
argumentStrings = (
"${TK_SRCROOT}/library/demos/widget",
);
autoAttachOnCrash = 1;
breakpointsEnabled = 1;
configStateDict = {
"PBXLSLaunchAction-0" = {
PBXLSLaunchAction = 0;
PBXLSLaunchStartAction = 1;
PBXLSLaunchStdioStyle = 2;
PBXLSLaunchStyle = 0;
class = PBXLSRunLaunchConfig;
displayName = "Executable Runner";
identifier = com.apple.Xcode.launch.runConfig;
remoteHostInfo = "";
startActionInfo = "";
};
"PBXLSLaunchAction-1" = {
PBXLSLaunchAction = 1;
PBXLSLaunchStartAction = 1;
PBXLSLaunchStdioStyle = 2;
PBXLSLaunchStyle = 0;
class = PBXGDB_LaunchConfig;
displayName = GDB;
identifier = com.apple.Xcode.launch.GDBMI_Config;
remoteHostInfo = "";
startActionInfo = "";
};
};
customDataFormattersEnabled = 1;
debuggerPlugin = GDBDebugging;
disassemblyDisplayState = 0;
dylibVariantSuffix = "";
enableDebugStr = 0;
environmentEntries = (
{
active = NO;
name = DYLD_PRINT_LIBRARIES;
},
);
executableSystemSymbolLevel = 0;
executableUserSymbolLevel = 0;
libgmallocEnabled = 0;
name = Wish;
sourceDirectories = (
);
};
F97258A50A86873C00096C78 /* tktest-X11 */ = {
activeExec = 0;
executables = (
F9FD31F50CC1AD070073837D /* tktest-X11 */,
);
};
F9FD31F50CC1AD070073837D /* tktest-X11 */ = {
isa = PBXExecutable;
activeArgIndices = (
YES,
NO,
NO,
NO,
NO,
NO,
NO,
);
argumentStrings = (
"${TK_SRCROOT}/library/demos/widget",
"${TK_SRCROOT}/tests/all.tcl",
"${TK_SRCROOT}/tests/ttk/all.tcl",
"-geometry +0+0",
"-singleproc 1",
"-verbose \"bet\"",
"-skip window-2.9",
);
autoAttachOnCrash = 1;
breakpointsEnabled = 1;
configStateDict = {
"PBXLSLaunchAction-0" = {
PBXLSLaunchAction = 0;
PBXLSLaunchStartAction = 1;
PBXLSLaunchStdioStyle = 2;
PBXLSLaunchStyle = 0;
class = PBXLSRunLaunchConfig;
displayName = "Executable Runner";
identifier = com.apple.Xcode.launch.runConfig;
remoteHostInfo = "";
startActionInfo = "";
};
"PBXLSLaunchAction-1" = {
PBXLSLaunchAction = 1;
PBXLSLaunchStartAction = 1;
PBXLSLaunchStdioStyle = 2;
PBXLSLaunchStyle = 0;
class = PBXGDB_LaunchConfig;
displayName = GDB;
identifier = com.apple.Xcode.launch.GDBMI_Config;
remoteHostInfo = "";
startActionInfo = "";
};
};
customDataFormattersEnabled = 1;
debuggerPlugin = GDBDebugging;
disassemblyDisplayState = 0;
dylibVariantSuffix = "";
enableDebugStr = 0;
environmentEntries = (
{
active = YES;
name = TCL_LIBRARY;
value = "${TCL_SRCROOT}/library";
},
{
active = YES;
name = TK_LIBRARY;
value = "${TK_SRCROOT}/library";
},
{
active = YES;
name = TCLLIBPATH;
value = /Library/Tcl;
},
{
active = YES;
name = DISPLAY;
value = ":0";
},
{
active = NO;
name = DYLD_PRINT_LIBRARIES;
},
{
active = NO;
name = MallocBadFreeAbort;
value = 1;
},
{
active = NO;
name = MallocLogFile;
value = /tmp/malloc.log;
},
{
active = NO;
name = MallocStackLogging;
value = 1;
},
{
active = NO;
name = MallocStackLoggingNoCompact;
value = 1;
},
{
active = NO;
name = MallocPreScribble;
value = 1;
},
{
active = NO;
name = MallocScribble;
value = 1;
},
);
executableSystemSymbolLevel = 0;
executableUserSymbolLevel = 0;
libgmallocEnabled = 0;
name = "tktest-X11";
sourceDirectories = (
);
};
}

File diff suppressed because it is too large Load Diff

12890
macosx/configure vendored Normal file

File diff suppressed because it is too large Load Diff

11
macosx/configure.ac Normal file
View File

@@ -0,0 +1,11 @@
#! /bin/bash -norc
dnl This file is an input file used by the GNU "autoconf" program to
dnl generate the file "configure", which is run during Tk installation
dnl to configure the system for the local environment.
dnl Ensure that the config (auto)headers support is used, then just
dnl include the configure sources from ../unix:
m4_include(../unix/aclocal.m4)
m4_define(SC_USE_CONFIG_HEADERS)
m4_include(../unix/configure.in)

39
macosx/license.terms Normal file
View File

@@ -0,0 +1,39 @@
This software is copyrighted by the Regents of the University of
California, Sun Microsystems, Inc., and other parties. The following
terms apply to all files associated with the software unless explicitly
disclaimed in individual files.
The authors hereby grant permission to use, copy, modify, distribute,
and license this software and its documentation for any purpose, provided
that existing copyright notices are retained in all copies and that this
notice is included verbatim in any distributions. No written agreement,
license, or royalty fee is required for any of the authorized uses.
Modifications to this software may be copyrighted by their authors
and need not follow the licensing terms described here, provided that
the new terms are clearly indicated on the first page of each file where
they apply.
IN NO EVENT SHALL THE AUTHORS OR DISTRIBUTORS BE LIABLE TO ANY PARTY
FOR DIRECT, INDIRECT, SPECIAL, INCIDENTAL, OR CONSEQUENTIAL DAMAGES
ARISING OUT OF THE USE OF THIS SOFTWARE, ITS DOCUMENTATION, OR ANY
DERIVATIVES THEREOF, EVEN IF THE AUTHORS HAVE BEEN ADVISED OF THE
POSSIBILITY OF SUCH DAMAGE.
THE AUTHORS AND DISTRIBUTORS SPECIFICALLY DISCLAIM ANY WARRANTIES,
INCLUDING, BUT NOT LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY,
FITNESS FOR A PARTICULAR PURPOSE, AND NON-INFRINGEMENT. THIS SOFTWARE
IS PROVIDED ON AN "AS IS" BASIS, AND THE AUTHORS AND DISTRIBUTORS HAVE
NO OBLIGATION TO PROVIDE MAINTENANCE, SUPPORT, UPDATES, ENHANCEMENTS, OR
MODIFICATIONS.
GOVERNMENT USE: If you are acquiring this software on behalf of the
U.S. government, the Government shall have only "Restricted Rights"
in the software and related documentation as defined in the Federal
Acquisition Regulations (FARs) in Clause 52.227.19 (c) (2). If you
are acquiring the software on behalf of the Department of Defense, the
software shall be classified as "Commercial Computer Software" and the
Government shall have only "Restricted Rights" as defined in Clause
252.227-7013 (b) (3) of DFARs. Notwithstanding the foregoing, the
authors grant the U.S. Government and others acting in its behalf
permission to use and distribute the software in accordance with the
terms specified in this license.

34
macosx/tkMacOSX.h Normal file
View File

@@ -0,0 +1,34 @@
/*
* tkMacOSX.h --
*
* Declarations of Macintosh specific exported variables and procedures.
*
* Copyright (c) 1995-1997 Sun Microsystems, Inc.
* Copyright 2001-2009, Apple Inc.
* Copyright (c) 2005-2009 Daniel A. Steffen <das@users.sourceforge.net>
*
* See the file "license.terms" for information on usage and redistribution
* of this file, and for a DISCLAIMER OF ALL WARRANTIES.
*/
#ifndef _TKMAC
#define _TKMAC
#ifndef _TK
#include "tk.h"
#endif
/*
* Structures and function types for handling Netscape-type in process
* embedding where Tk does not control the top-level
*/
typedef int (Tk_MacOSXEmbedRegisterWinProc) (long winID, Tk_Window window);
typedef void* (Tk_MacOSXEmbedGetGrafPortProc) (Tk_Window window);
typedef int (Tk_MacOSXEmbedMakeContainerExistProc) (Tk_Window window);
typedef void (Tk_MacOSXEmbedGetClipProc) (Tk_Window window, TkRegion rgn);
typedef void (Tk_MacOSXEmbedGetOffsetInParentProc) (Tk_Window window, void *ulCorner);
#include "tkPlatDecls.h"
#endif /* _TKMAC */

455
macosx/tkMacOSXBitmap.c Normal file
View File

@@ -0,0 +1,455 @@
/*
* tkMacOSXBitmap.c --
*
* This file handles the implementation of native bitmaps.
*
* Copyright (c) 1996-1997 Sun Microsystems, Inc.
* Copyright 2001-2009, Apple Inc.
* Copyright (c) 2006-2009 Daniel A. Steffen <das@users.sourceforge.net>
*
* See the file "license.terms" for information on usage and redistribution
* of this file, and for a DISCLAIMER OF ALL WARRANTIES.
*/
#include "tkMacOSXPrivate.h"
/*
* This structure holds information about native bitmaps.
*/
typedef struct {
const char *name; /* Name of icon. */
OSType iconType; /* OSType of icon. */
} BuiltInIcon;
/*
* This array mapps a string name to the supported builtin icons
* on the Macintosh.
*/
static BuiltInIcon builtInIcons[] = {
{"document", kGenericDocumentIcon},
{"stationery", kGenericStationeryIcon},
{"edition", kGenericEditionFileIcon},
{"application", kGenericApplicationIcon},
{"accessory", kGenericDeskAccessoryIcon},
{"folder", kGenericFolderIcon},
{"pfolder", kPrivateFolderIcon},
{"trash", kTrashIcon},
{"floppy", kGenericFloppyIcon},
{"ramdisk", kGenericRAMDiskIcon},
{"cdrom", kGenericCDROMIcon},
{"preferences", kGenericPreferencesIcon},
{"querydoc", kGenericQueryDocumentIcon},
{"stop", kAlertStopIcon},
{"note", kAlertNoteIcon},
{"caution", kAlertCautionIcon},
{NULL}
};
#define builtInIconSize 32
static Tcl_HashTable iconBitmapTable = {};
typedef struct {
int kind, width, height;
char *value;
} IconBitmap;
static const char *iconBitmapOptionStrings[] = {
"-file", "-fileType", "-osType", "-systemType", "-namedImage",
"-imageFile", NULL
};
enum iconBitmapOptions {
ICON_FILE, ICON_FILETYPE, ICON_OSTYPE, ICON_SYSTEMTYPE, ICON_NAMEDIMAGE,
ICON_IMAGEFILE,
};
/*
*----------------------------------------------------------------------
*
* TkpDefineNativeBitmaps --
*
* Add native bitmaps.
*
* Results:
* A standard Tcl result. If an error occurs then TCL_ERROR is
* returned and a message is left in the interp's result.
*
* Side effects:
* "Name" is entered into the bitmap table and may be used from
* here on to refer to the given bitmap.
*
*----------------------------------------------------------------------
*/
void
TkpDefineNativeBitmaps(void)
{
Tcl_HashTable *tablePtr = TkGetBitmapPredefTable();
BuiltInIcon *builtInPtr;
for (builtInPtr = builtInIcons; builtInPtr->name != NULL; builtInPtr++) {
Tcl_HashEntry *predefHashPtr;
Tk_Uid name;
int isNew;
name = Tk_GetUid(builtInPtr->name);
predefHashPtr = Tcl_CreateHashEntry(tablePtr, name, &isNew);
if (isNew) {
TkPredefBitmap *predefPtr = (TkPredefBitmap *)
ckalloc(sizeof(TkPredefBitmap));
predefPtr->source = UINT2PTR(builtInPtr->iconType);
predefPtr->width = builtInIconSize;
predefPtr->height = builtInIconSize;
predefPtr->native = 1;
Tcl_SetHashValue(predefHashPtr, predefPtr);
}
}
}
/*
*----------------------------------------------------------------------
*
* GetBitmapForIcon --
*
* Results:
* Bitmap for the given IconRef.
*
* Side effects:
* None.
*
*----------------------------------------------------------------------
*/
static Pixmap
GetBitmapForIcon(
Display *display,
IconRef icon,
CGSize size)
{
TkMacOSXDrawingContext dc;
Pixmap pixmap;
pixmap = Tk_GetPixmap(display, None, size.width, size.height, 0);
if (TkMacOSXSetupDrawingContext(pixmap, NULL, 1, &dc)) {
if (dc.context) {
const CGAffineTransform t = { .a = 1, .b = 0, .c = 0, .d = -1,
.tx = 0, .ty = size.height };
const CGRect r = { .origin = { .x = 0, .y = 0 }, .size = size };
CGContextConcatCTM(dc.context, t);
PlotIconRefInContext(dc.context, &r, kAlignAbsoluteCenter,
kTransformNone, NULL, kPlotIconRefNormalFlags, icon);
}
TkMacOSXRestoreDrawingContext(&dc);
}
return pixmap;
}
/*
*----------------------------------------------------------------------
*
* TkpCreateNativeBitmap --
*
* Create native bitmap.
*
* Results:
* Native bitmap.
*
* Side effects:
* None.
*
*----------------------------------------------------------------------
*/
Pixmap
TkpCreateNativeBitmap(
Display *display,
const char *source) /* Info about the icon to build. */
{
Pixmap pixmap;
IconRef icon;
OSErr err;
err = ChkErr(GetIconRef, kOnSystemDisk, kSystemIconsCreator,
PTR2UINT(source), &icon);
if (err == noErr) {
pixmap = GetBitmapForIcon(display, icon, CGSizeMake(builtInIconSize,
builtInIconSize));
ReleaseIconRef(icon);
} else {
pixmap = Tk_GetPixmap(display, None, builtInIconSize,
builtInIconSize, 0);
}
return pixmap;
}
/*
*----------------------------------------------------------------------
*
* OSTypeFromString --
*
* Helper to convert string to OSType.
*
* Results:
* A standard Tcl result.
*
* Side effects:
* t is set to OSType if conversion successful.
*
*----------------------------------------------------------------------
*/
static int
OSTypeFromString(const char *s, OSType *t) {
int result = TCL_ERROR;
Tcl_DString ds;
Tcl_Encoding encoding = Tcl_GetEncoding(NULL, "macRoman");
Tcl_UtfToExternalDString(encoding, s, -1, &ds);
if (Tcl_DStringLength(&ds) <= 4) {
char string[4] = {};
memcpy(string, Tcl_DStringValue(&ds), (size_t) Tcl_DStringLength(&ds));
*t = (OSType) string[0] << 24 | (OSType) string[1] << 16 |
(OSType) string[2] << 8 | (OSType) string[3];
result = TCL_OK;
}
Tcl_DStringFree(&ds);
Tcl_FreeEncoding(encoding);
return result;
}
/*
*----------------------------------------------------------------------
*
* TkpGetNativeAppBitmap --
*
* Get a named native bitmap.
*
* Attemps to interpret the given name in order as:
* - name defined by ::tk::mac::iconBitmap
* - NSImage named image name
* - NSImage url string
* - 4-char OSType of IconServices icon
*
* Results:
* Native bitmap or None.
*
* Side effects:
* None.
*
*----------------------------------------------------------------------
*/
Pixmap
TkpGetNativeAppBitmap(
Display *display, /* The display. */
const char *name, /* The name of the bitmap. */
int *width, /* The width & height of the bitmap. */
int *height)
{
Tcl_HashEntry *hPtr;
Pixmap pixmap = None;
NSString *string;
NSImage *image = nil;
NSSize size = { .width = builtInIconSize, .height = builtInIconSize };
if (iconBitmapTable.buckets &&
(hPtr = Tcl_FindHashEntry(&iconBitmapTable, name))) {
OSType type;
IconBitmap *iconBitmap = Tcl_GetHashValue(hPtr);
name = NULL;
size = NSMakeSize(iconBitmap->width, iconBitmap->height);
switch (iconBitmap->kind) {
case ICON_FILE:
string = [[NSString stringWithUTF8String:iconBitmap->value]
stringByExpandingTildeInPath];
image = [[NSWorkspace sharedWorkspace] iconForFile:string];
break;
case ICON_FILETYPE:
string = [NSString stringWithUTF8String:iconBitmap->value];
image = [[NSWorkspace sharedWorkspace] iconForFileType:string];
break;
case ICON_OSTYPE:
if (OSTypeFromString(iconBitmap->value, &type) == TCL_OK) {
string = NSFileTypeForHFSTypeCode(type);
image = [[NSWorkspace sharedWorkspace] iconForFileType:string];
}
break;
case ICON_SYSTEMTYPE:
name = iconBitmap->value;
break;
case ICON_NAMEDIMAGE:
string = [NSString stringWithUTF8String:iconBitmap->value];
image = [NSImage imageNamed:string];
break;
case ICON_IMAGEFILE:
string = [[NSString stringWithUTF8String:iconBitmap->value]
stringByExpandingTildeInPath];
image = [[[NSImage alloc] initWithContentsOfFile:string]
autorelease];
break;
}
if (image) {
[image setSize:size];
}
} else {
string = [NSString stringWithUTF8String:name];
image = [NSImage imageNamed:string];
if (!image) {
NSURL *url = [NSURL URLWithString:string];
if (url) {
image = [[[NSImage alloc] initWithContentsOfURL:url]
autorelease];
}
}
if (image) {
size = [image size];
}
}
if (image) {
TkMacOSXDrawingContext dc;
int depth = 0;
#ifdef MAC_OSX_TK_TODO
for (NSImageRep *r in [image representations]) {
NSInteger bitsPerSample = [r bitsPerSample];
if (bitsPerSample && bitsPerSample > depth) {
depth = bitsPerSample;
};
}
if (depth == 1) {
/* TODO: convert BW NSImage to CGImageMask */
}
#endif
pixmap = Tk_GetPixmap(display, None, size.width, size.height, depth);
*width = size.width;
*height = size.height;
if (TkMacOSXSetupDrawingContext(pixmap, NULL, 1, &dc)) {
if (dc.context) {
CGAffineTransform t = { .a = 1, .b = 0, .c = 0, .d = -1,
.tx = 0, .ty = size.height};
CGContextConcatCTM(dc.context, t);
[NSGraphicsContext saveGraphicsState];
[NSGraphicsContext setCurrentContext:[NSGraphicsContext
graphicsContextWithGraphicsPort:dc.context flipped:NO]];
[image drawAtPoint:NSZeroPoint fromRect:NSZeroRect
operation:NSCompositeCopy fraction:1.0];
[NSGraphicsContext restoreGraphicsState];
}
TkMacOSXRestoreDrawingContext(&dc);
}
} else if (name) {
OSType iconType;
if (OSTypeFromString(name, &iconType) == TCL_OK) {
IconRef icon;
OSErr err = ChkErr(GetIconRef, kOnSystemDisk, kSystemIconsCreator,
iconType, &icon);
if (err == noErr) {
pixmap = GetBitmapForIcon(display, icon, NSSizeToCGSize(size));
*width = size.width;
*height = size.height;
ReleaseIconRef(icon);
}
}
}
return pixmap;
}
/*
*----------------------------------------------------------------------
*
* TkMacOSXIconBitmapObjCmd --
*
* Implements the ::tk::mac::iconBitmap command.
*
* Results:
* A standard Tcl result.
*
* Side effects:
* none
*
*----------------------------------------------------------------------
*/
int
TkMacOSXIconBitmapObjCmd(
ClientData clientData, /* Unused. */
Tcl_Interp *interp, /* Current interpreter. */
int objc, /* Number of arguments. */
Tcl_Obj *const objv[]) /* Argument objects. */
{
Tcl_HashEntry *hPtr;
int i = 1, len, isNew, result = TCL_ERROR;
const char *name, *value;
IconBitmap ib, *iconBitmap;
if (objc != 6) {
Tcl_WrongNumArgs(interp, 1, objv, "name width height "
"-file|-fileType|-osType|-systemType|-namedImage|-imageFile "
"value");
goto end;
}
name = Tcl_GetStringFromObj(objv[i++], &len);
if (!len) {
Tcl_AppendResult(interp, "empty bitmap name", NULL);
goto end;
}
if (Tcl_GetIntFromObj(interp, objv[i++], &ib.width) != TCL_OK) {
goto end;
}
if (Tcl_GetIntFromObj(interp, objv[i++], &ib.height) != TCL_OK) {
goto end;
}
if (Tcl_GetIndexFromObj(interp, objv[i++], iconBitmapOptionStrings,
"kind", TCL_EXACT, &ib.kind) != TCL_OK) {
goto end;
}
value = Tcl_GetStringFromObj(objv[i++], &len);
if (!len) {
Tcl_AppendResult(interp, "empty bitmap value", NULL);
goto end;
}
#if 0
if ((kind == ICON_TYPE || kind == ICON_SYSTEM)) {
Tcl_DString ds;
Tcl_Encoding encoding = Tcl_GetEncoding(NULL, "macRoman");
Tcl_UtfToExternalDString(encoding, value, -1, &ds);
len = Tcl_DStringLength(&ds);
Tcl_DStringFree(&ds);
Tcl_FreeEncoding(encoding);
if (len > 4) {
Tcl_AppendResult(interp, "invalid bitmap value", NULL);
goto end;
}
}
#endif
ib.value = ckalloc(len + 1);
strcpy(ib.value, value);
if (!iconBitmapTable.buckets) {
Tcl_InitHashTable(&iconBitmapTable, TCL_STRING_KEYS);
}
hPtr = Tcl_CreateHashEntry(&iconBitmapTable, name, &isNew);
if (!isNew) {
iconBitmap = Tcl_GetHashValue(hPtr);
ckfree(iconBitmap->value);
} else {
iconBitmap = (IconBitmap *) ckalloc(sizeof(IconBitmap));
Tcl_SetHashValue(hPtr, iconBitmap);
}
*iconBitmap = ib;
result = TCL_OK;
end:
return result;
}
/*
* Local Variables:
* mode: objc
* c-basic-offset: 4
* fill-column: 79
* coding: utf-8
* End:
*/

1179
macosx/tkMacOSXButton.c Normal file

File diff suppressed because it is too large Load Diff

308
macosx/tkMacOSXClipboard.c Normal file
View File

@@ -0,0 +1,308 @@
/*
* tkMacOSXClipboard.c --
*
* This file manages the clipboard for the Tk toolkit.
*
* Copyright (c) 1995-1997 Sun Microsystems, Inc.
* Copyright 2001-2009, Apple Inc.
* Copyright (c) 2006-2009 Daniel A. Steffen <das@users.sourceforge.net>
*
* See the file "license.terms" for information on usage and redistribution
* of this file, and for a DISCLAIMER OF ALL WARRANTIES.
*/
#include "tkMacOSXPrivate.h"
#include "tkSelect.h"
static NSInteger changeCount = -1;
static Tk_Window clipboardOwner = NULL;
#pragma mark TKApplication(TKClipboard)
@implementation TKApplication(TKClipboard)
- (void)tkProvidePasteboard:(TkDisplay *)dispPtr
pasteboard:(NSPasteboard *)sender provideDataForType:(NSString *)type {
NSMutableString *string = [NSMutableString new];
if (dispPtr && dispPtr->clipboardActive &&
[type isEqualToString:NSStringPboardType]) {
for (TkClipboardTarget *targetPtr = dispPtr->clipTargetPtr; targetPtr;
targetPtr = targetPtr->nextPtr) {
if (targetPtr->type == XA_STRING ||
targetPtr->type == dispPtr->utf8Atom) {
for (TkClipboardBuffer *cbPtr = targetPtr->firstBufferPtr;
cbPtr; cbPtr = cbPtr->nextPtr) {
NSString *s = [[NSString alloc] initWithBytesNoCopy:
cbPtr->buffer length:cbPtr->length
encoding:NSUTF8StringEncoding freeWhenDone:NO];
[string appendString:s];
[s release];
}
break;
}
}
}
[sender setString:string forType:type];
[string release];
}
- (void)tkProvidePasteboard:(TkDisplay *)dispPtr {
if (dispPtr && dispPtr->clipboardActive) {
[self tkProvidePasteboard:dispPtr
pasteboard:[NSPasteboard generalPasteboard]
provideDataForType:NSStringPboardType];
}
}
- (void)pasteboard:(NSPasteboard *)sender provideDataForType:(NSString *)type {
[self tkProvidePasteboard:TkGetDisplayList() pasteboard:sender
provideDataForType:type];
}
- (void)tkCheckPasteboard {
if (clipboardOwner && [[NSPasteboard generalPasteboard] changeCount] !=
changeCount) {
TkDisplay *dispPtr = TkGetDisplayList();
if (dispPtr) {
XEvent event;
event.xany.type = SelectionClear;
event.xany.serial = NextRequest(Tk_Display(clipboardOwner));
event.xany.send_event = False;
event.xany.window = Tk_WindowId(clipboardOwner);
event.xany.display = Tk_Display(clipboardOwner);
event.xselectionclear.selection = dispPtr->clipboardAtom;
Tk_QueueWindowEvent(&event, TCL_QUEUE_TAIL);
}
clipboardOwner = NULL;
}
}
@end
#pragma mark -
/*
*----------------------------------------------------------------------
*
* TkSelGetSelection --
*
* Retrieve the specified selection from another process. For now, only
* fetching XA_STRING from CLIPBOARD is supported. Eventually other types
* should be allowed.
*
* Results:
* The return value is a standard Tcl return value. If an error occurs
* (such as no selection exists) then an error message is left in the
* interp's result.
*
* Side effects:
* None.
*
*----------------------------------------------------------------------
*/
int
TkSelGetSelection(
Tcl_Interp *interp, /* Interpreter to use for reporting errors. */
Tk_Window tkwin, /* Window on whose behalf to retrieve the
* selection (determines display from which to
* retrieve). */
Atom selection, /* Selection to retrieve. */
Atom target, /* Desired form in which selection is to be
* returned. */
Tk_GetSelProc *proc, /* Procedure to call to process the selection,
* once it has been retrieved. */
ClientData clientData) /* Arbitrary value to pass to proc. */
{
int result = TCL_ERROR;
TkDisplay *dispPtr = ((TkWindow *) tkwin)->dispPtr;
if (dispPtr && selection == dispPtr->clipboardAtom && (target == XA_STRING
|| target == dispPtr->utf8Atom)) {
NSString *string = nil;
NSPasteboard *pb = [NSPasteboard generalPasteboard];
NSString *type = [pb availableTypeFromArray:[NSArray arrayWithObject:
NSStringPboardType]];
if (type) {
string = [pb stringForType:type];
}
result = proc(clientData, interp, string ? (char*)[string UTF8String]
: "");
} else {
Tcl_AppendResult(interp, Tk_GetAtomName(tkwin, selection),
" selection doesn't exist or form \"",
Tk_GetAtomName(tkwin, target), "\" not defined", NULL);
}
return result;
}
/*
*----------------------------------------------------------------------
*
* XSetSelectionOwner --
*
* This function claims ownership of the specified selection. If the
* selection is CLIPBOARD, then we empty the system clipboard.
*
* Results:
* None.
*
* Side effects:
* None.
*
*----------------------------------------------------------------------
*/
int
XSetSelectionOwner(
Display *display, /* X Display. */
Atom selection, /* What selection to own. */
Window owner, /* Window to be the owner. */
Time time) /* The current time? */
{
TkDisplay *dispPtr = TkGetDisplayList();
if (dispPtr && selection == dispPtr->clipboardAtom) {
clipboardOwner = owner ? Tk_IdToWindow(display, owner) : NULL;
if (!dispPtr->clipboardActive) {
NSPasteboard *pb = [NSPasteboard generalPasteboard];
changeCount = [pb declareTypes:[NSArray array] owner:NSApp];
}
}
return Success;
}
/*
*----------------------------------------------------------------------
*
* TkMacOSXSelDeadWindow --
*
* This function is invoked just before a TkWindow is deleted. It
* performs selection-related cleanup.
*
* Results:
* None.
*
* Side effects:
* clipboardOwner is cleared.
*
*----------------------------------------------------------------------
*/
void
TkMacOSXSelDeadWindow(
TkWindow *winPtr)
{
if (winPtr && winPtr == (TkWindow *)clipboardOwner) {
clipboardOwner = NULL;
}
}
/*
*----------------------------------------------------------------------
*
* TkSelUpdateClipboard --
*
* This function is called to force the clipboard to be updated after new
* data is added.
*
* Results:
* None.
*
* Side effects:
* None.
*
*----------------------------------------------------------------------
*/
void
TkSelUpdateClipboard(
TkWindow *winPtr, /* Window associated with clipboard. */
TkClipboardTarget *targetPtr)
/* Info about the content. */
{
NSPasteboard *pb = [NSPasteboard generalPasteboard];
changeCount = [pb addTypes:[NSArray arrayWithObject:NSStringPboardType]
owner:NSApp];
}
/*
*--------------------------------------------------------------
*
* TkSelEventProc --
*
* This procedure is invoked whenever a selection-related event occurs.
*
* Results:
* None.
*
* Side effects:
* Lots: depends on the type of event.
*
*--------------------------------------------------------------
*/
void
TkSelEventProc(
Tk_Window tkwin, /* Window for which event was targeted. */
register XEvent *eventPtr) /* X event: either SelectionClear,
* SelectionRequest, or SelectionNotify. */
{
if (eventPtr->type == SelectionClear) {
clipboardOwner = NULL;
TkSelClearSelection(tkwin, eventPtr);
}
}
/*
*----------------------------------------------------------------------
*
* TkSelPropProc --
*
* This procedure is invoked when property-change events occur on windows
* not known to the toolkit. This is a stub function under Windows.
*
* Results:
* None.
*
* Side effects:
* None.
*
*----------------------------------------------------------------------
*/
void
TkSelPropProc(
register XEvent *eventPtr) /* X PropertyChange event. */
{
}
/*
*----------------------------------------------------------------------
*
* TkSuspendClipboard --
*
* Handle clipboard conversion as required by the suppend event.
*
* Results:
* None.
*
* Side effects:
* The local scrap is moved to the global scrap.
*
*----------------------------------------------------------------------
*/
void
TkSuspendClipboard(void)
{
changeCount = [[NSPasteboard generalPasteboard] changeCount];
}
/*
* Local Variables:
* mode: objc
* c-basic-offset: 4
* fill-column: 79
* coding: utf-8
* End:
*/

733
macosx/tkMacOSXColor.c Normal file
View File

@@ -0,0 +1,733 @@
/*
* tkMacOSXColor.c --
*
* This file maintains a database of color values for the Tk
* toolkit, in order to avoid round-trips to the server to
* map color names to pixel values.
*
* Copyright (c) 1990-1994 The Regents of the University of California.
* Copyright (c) 1994-1996 Sun Microsystems, Inc.
* Copyright 2001-2009, Apple Inc.
* Copyright (c) 2006-2009 Daniel A. Steffen <das@users.sourceforge.net>
*
* See the file "license.terms" for information on usage and redistribution
* of this file, and for a DISCLAIMER OF ALL WARRANTIES.
*/
#include "tkMacOSXPrivate.h"
#include "tkColor.h"
struct SystemColorMapEntry {
const char *name;
ThemeBrush brush;
ThemeTextColor textColor;
ThemeBackgroundKind background;
}; /* unsigned char pixelCode; */
/*
* Array of system color definitions: the array index is required to equal the
* color's (pixelCode - MIN_PIXELCODE), i.e. the array order needs to be kept
* in sync with the public pixel code values in tkMacOSXPort.h !
*/
#define MIN_PIXELCODE 30
static const struct SystemColorMapEntry systemColorMap[] = {
{ "Transparent", 0, 0, 0 }, /* 30: TRANSPARENT_PIXEL */
{ "Highlight", kThemeBrushPrimaryHighlightColor, 0, 0 }, /* 31: HIGHLIGHT_PIXEL */
{ "HighlightSecondary", kThemeBrushSecondaryHighlightColor, 0, 0 }, /* 32: HIGHLIGHT_SECONDARY_PIXEL */
{ "HighlightText", kThemeBrushBlack, 0, 0 }, /* 33: HIGHLIGHT_TEXT_PIXEL */
{ "HighlightAlternate", kThemeBrushAlternatePrimaryHighlightColor, 0, 0 }, /* 34: HIGHLIGHT_ALTERNATE_PIXEL */
{ "ButtonText", 0, kThemeTextColorPushButtonActive, 0 }, /* 35: CONTROL_TEXT_PIXEL */
{ "PrimaryHighlightColor", kThemeBrushPrimaryHighlightColor, 0, 0 }, /* 36 */
{ "ButtonFace", kThemeBrushButtonFaceActive, 0, 0 }, /* 37: CONTROL_BODY_PIXEL */
{ "SecondaryHighlightColor", kThemeBrushSecondaryHighlightColor, 0, 0 }, /* 38 */
{ "ButtonFrame", kThemeBrushButtonFrameActive, 0, 0 }, /* 39: CONTROL_FRAME_PIXEL */
{ "AlternatePrimaryHighlightColor", kThemeBrushAlternatePrimaryHighlightColor, 0, 0 }, /* 40 */
{ "WindowBody", kThemeBrushDocumentWindowBackground, 0, 0 }, /* 41: WINDOW_BODY_PIXEL */
{ "SheetBackground", kThemeBrushSheetBackground, 0, 0 }, /* 42 */
{ "MenuActive", kThemeBrushMenuBackgroundSelected, 0, 0 }, /* 43: MENU_ACTIVE_PIXEL */
{ "Black", kThemeBrushBlack, 0, 0 }, /* 44 */
{ "MenuActiveText", 0, kThemeTextColorMenuItemSelected, 0 }, /* 45: MENU_ACTIVE_TEXT_PIXEL */
{ "White", kThemeBrushWhite, 0, 0 }, /* 46 */
{ "Menu", kThemeBrushMenuBackground, 0, 0 }, /* 47: MENU_BACKGROUND_PIXEL */
{ "DialogBackgroundActive", kThemeBrushDialogBackgroundActive, 0, 0 }, /* 48 */
{ "MenuDisabled", 0, kThemeTextColorMenuItemDisabled, 0 }, /* 49: MENU_DISABLED_PIXEL */
{ "DialogBackgroundInactive", kThemeBrushDialogBackgroundInactive, 0, 0 }, /* 50 */
{ "MenuText", 0, kThemeTextColorMenuItemActive, 0 }, /* 51: MENU_TEXT_PIXEL */
{ "AppearanceColor", 0, 0, 0 }, /* 52: APPEARANCE_PIXEL */
{ "AlertBackgroundActive", kThemeBrushAlertBackgroundActive, 0, 0 }, /* 53 */
{ "AlertBackgroundInactive", kThemeBrushAlertBackgroundInactive, 0, 0 }, /* 54 */
{ "ModelessDialogBackgroundActive", kThemeBrushModelessDialogBackgroundActive, 0, 0 }, /* 55 */
{ "ModelessDialogBackgroundInactive", kThemeBrushModelessDialogBackgroundInactive, 0, 0 }, /* 56 */
{ "UtilityWindowBackgroundActive", kThemeBrushUtilityWindowBackgroundActive, 0, 0 }, /* 57 */
{ "UtilityWindowBackgroundInactive", kThemeBrushUtilityWindowBackgroundInactive, 0, 0 }, /* 58 */
{ "ListViewSortColumnBackground", kThemeBrushListViewSortColumnBackground, 0, 0 }, /* 59 */
{ "ListViewBackground", kThemeBrushListViewBackground, 0, 0 }, /* 60 */
{ "IconLabelBackground", kThemeBrushIconLabelBackground, 0, 0 }, /* 61 */
{ "ListViewSeparator", kThemeBrushListViewSeparator, 0, 0 }, /* 62 */
{ "ChasingArrows", kThemeBrushChasingArrows, 0, 0 }, /* 63 */
{ "DragHilite", kThemeBrushDragHilite, 0, 0 }, /* 64 */
{ "DocumentWindowBackground", kThemeBrushDocumentWindowBackground, 0, 0 }, /* 65 */
{ "FinderWindowBackground", kThemeBrushFinderWindowBackground, 0, 0 }, /* 66 */
{ "ScrollBarDelimiterActive", kThemeBrushScrollBarDelimiterActive, 0, 0 }, /* 67 */
{ "ScrollBarDelimiterInactive", kThemeBrushScrollBarDelimiterInactive, 0, 0 }, /* 68 */
{ "FocusHighlight", kThemeBrushFocusHighlight, 0, 0 }, /* 69 */
{ "PopupArrowActive", kThemeBrushPopupArrowActive, 0, 0 }, /* 70 */
{ "PopupArrowPressed", kThemeBrushPopupArrowPressed, 0, 0 }, /* 71 */
{ "PopupArrowInactive", kThemeBrushPopupArrowInactive, 0, 0 }, /* 72 */
{ "AppleGuideCoachmark", kThemeBrushAppleGuideCoachmark, 0, 0 }, /* 73 */
{ "IconLabelBackgroundSelected", kThemeBrushIconLabelBackgroundSelected, 0, 0 }, /* 74 */
{ "StaticAreaFill", kThemeBrushStaticAreaFill, 0, 0 }, /* 75 */
{ "ActiveAreaFill", kThemeBrushActiveAreaFill, 0, 0 }, /* 76 */
{ "ButtonFrameActive", kThemeBrushButtonFrameActive, 0, 0 }, /* 77 */
{ "ButtonFrameInactive", kThemeBrushButtonFrameInactive, 0, 0 }, /* 78 */
{ "ButtonFaceActive", kThemeBrushButtonFaceActive, 0, 0 }, /* 79 */
{ "ButtonFaceInactive", kThemeBrushButtonFaceInactive, 0, 0 }, /* 80 */
{ "ButtonFacePressed", kThemeBrushButtonFacePressed, 0, 0 }, /* 81 */
{ "ButtonActiveDarkShadow", kThemeBrushButtonActiveDarkShadow, 0, 0 }, /* 82 */
{ "ButtonActiveDarkHighlight", kThemeBrushButtonActiveDarkHighlight, 0, 0 }, /* 83 */
{ "ButtonActiveLightShadow", kThemeBrushButtonActiveLightShadow, 0, 0 }, /* 84 */
{ "ButtonActiveLightHighlight", kThemeBrushButtonActiveLightHighlight, 0, 0 }, /* 85 */
{ "ButtonInactiveDarkShadow", kThemeBrushButtonInactiveDarkShadow, 0, 0 }, /* 86 */
{ "ButtonInactiveDarkHighlight", kThemeBrushButtonInactiveDarkHighlight, 0, 0 }, /* 87 */
{ "ButtonInactiveLightShadow", kThemeBrushButtonInactiveLightShadow, 0, 0 }, /* 88 */
{ "ButtonInactiveLightHighlight", kThemeBrushButtonInactiveLightHighlight, 0, 0 }, /* 89 */
{ "ButtonPressedDarkShadow", kThemeBrushButtonPressedDarkShadow, 0, 0 }, /* 90 */
{ "ButtonPressedDarkHighlight", kThemeBrushButtonPressedDarkHighlight, 0, 0 }, /* 91 */
{ "ButtonPressedLightShadow", kThemeBrushButtonPressedLightShadow, 0, 0 }, /* 92 */
{ "ButtonPressedLightHighlight", kThemeBrushButtonPressedLightHighlight, 0, 0 }, /* 93 */
{ "BevelActiveLight", kThemeBrushBevelActiveLight, 0, 0 }, /* 94 */
{ "BevelActiveDark", kThemeBrushBevelActiveDark, 0, 0 }, /* 95 */
{ "BevelInactiveLight", kThemeBrushBevelInactiveLight, 0, 0 }, /* 96 */
{ "BevelInactiveDark", kThemeBrushBevelInactiveDark, 0, 0 }, /* 97 */
{ "NotificationWindowBackground", kThemeBrushNotificationWindowBackground, 0, 0 }, /* 98 */
{ "MovableModalBackground", kThemeBrushMovableModalBackground, 0, 0 }, /* 99 */
{ "SheetBackgroundOpaque", kThemeBrushSheetBackgroundOpaque, 0, 0 }, /* 100 */
{ "DrawerBackground", kThemeBrushDrawerBackground, 0, 0 }, /* 101 */
{ "ToolbarBackground", kThemeBrushToolbarBackground, 0, 0 }, /* 102 */
{ "SheetBackgroundTransparent", kThemeBrushSheetBackgroundTransparent, 0, 0 }, /* 103 */
{ "MenuBackground", kThemeBrushMenuBackground, 0, 0 }, /* 104 */
{ "Pixel", 0, 0, 0 }, /* 105: PIXEL_MAGIC */
{ "MenuBackgroundSelected", kThemeBrushMenuBackgroundSelected, 0, 0 }, /* 106 */
{ "ListViewOddRowBackground", kThemeBrushListViewOddRowBackground, 0, 0 }, /* 107 */
{ "ListViewEvenRowBackground", kThemeBrushListViewEvenRowBackground, 0, 0 }, /* 108 */
{ "ListViewColumnDivider", kThemeBrushListViewColumnDivider, 0, 0 }, /* 109 */
{ "BlackText", 0, kThemeTextColorBlack, 0 }, /* 110 */
{ "DialogActiveText", 0, kThemeTextColorDialogActive, 0 }, /* 111 */
{ "DialogInactiveText", 0, kThemeTextColorDialogInactive, 0 }, /* 112 */
{ "AlertActiveText", 0, kThemeTextColorAlertActive, 0 }, /* 113 */
{ "AlertInactiveText", 0, kThemeTextColorAlertInactive, 0 }, /* 114 */
{ "ModelessDialogActiveText", 0, kThemeTextColorModelessDialogActive, 0 }, /* 115 */
{ "ModelessDialogInactiveText", 0, kThemeTextColorModelessDialogInactive, 0 }, /* 116 */
{ "WindowHeaderActiveText", 0, kThemeTextColorWindowHeaderActive, 0 }, /* 117 */
{ "WindowHeaderInactiveText", 0, kThemeTextColorWindowHeaderInactive, 0 }, /* 118 */
{ "PlacardActiveText", 0, kThemeTextColorPlacardActive, 0 }, /* 119 */
{ "PlacardInactiveText", 0, kThemeTextColorPlacardInactive, 0 }, /* 120 */
{ "PlacardPressedText", 0, kThemeTextColorPlacardPressed, 0 }, /* 121 */
{ "PushButtonActiveText", 0, kThemeTextColorPushButtonActive, 0 }, /* 122 */
{ "PushButtonInactiveText", 0, kThemeTextColorPushButtonInactive, 0 }, /* 123 */
{ "PushButtonPressedText", 0, kThemeTextColorPushButtonPressed, 0 }, /* 124 */
{ "BevelButtonActiveText", 0, kThemeTextColorBevelButtonActive, 0 }, /* 125 */
{ "BevelButtonInactiveText", 0, kThemeTextColorBevelButtonInactive, 0 }, /* 126 */
{ "BevelButtonPressedText", 0, kThemeTextColorBevelButtonPressed, 0 }, /* 127 */
{ "PopupButtonActiveText", 0, kThemeTextColorPopupButtonActive, 0 }, /* 128 */
{ "PopupButtonInactiveText", 0, kThemeTextColorPopupButtonInactive, 0 }, /* 129 */
{ "PopupButtonPressedText", 0, kThemeTextColorPopupButtonPressed, 0 }, /* 130 */
{ "IconLabelText", 0, kThemeTextColorIconLabel, 0 }, /* 131 */
{ "ListViewText", 0, kThemeTextColorListView, 0 }, /* 132 */
{ "DocumentWindowTitleActiveText", 0, kThemeTextColorDocumentWindowTitleActive, 0 }, /* 133 */
{ "DocumentWindowTitleInactiveText", 0, kThemeTextColorDocumentWindowTitleInactive, 0 }, /* 134 */
{ "MovableModalWindowTitleActiveText", 0, kThemeTextColorMovableModalWindowTitleActive, 0 }, /* 135 */
{ "MovableModalWindowTitleInactiveText",0, kThemeTextColorMovableModalWindowTitleInactive, 0 }, /* 136 */
{ "UtilityWindowTitleActiveText", 0, kThemeTextColorUtilityWindowTitleActive, 0 }, /* 137 */
{ "UtilityWindowTitleInactiveText", 0, kThemeTextColorUtilityWindowTitleInactive, 0 }, /* 138 */
{ "PopupWindowTitleActiveText", 0, kThemeTextColorPopupWindowTitleActive, 0 }, /* 139 */
{ "PopupWindowTitleInactiveText", 0, kThemeTextColorPopupWindowTitleInactive, 0 }, /* 140 */
{ "RootMenuActiveText", 0, kThemeTextColorRootMenuActive, 0 }, /* 141 */
{ "RootMenuSelectedText", 0, kThemeTextColorRootMenuSelected, 0 }, /* 142 */
{ "RootMenuDisabledText", 0, kThemeTextColorRootMenuDisabled, 0 }, /* 143 */
{ "MenuItemActiveText", 0, kThemeTextColorMenuItemActive, 0 }, /* 144 */
{ "MenuItemSelectedText", 0, kThemeTextColorMenuItemSelected, 0 }, /* 145 */
{ "MenuItemDisabledText", 0, kThemeTextColorMenuItemDisabled, 0 }, /* 146 */
{ "PopupLabelActiveText", 0, kThemeTextColorPopupLabelActive, 0 }, /* 147 */
{ "PopupLabelInactiveText", 0, kThemeTextColorPopupLabelInactive, 0 }, /* 148 */
{ "TabFrontActiveText", 0, kThemeTextColorTabFrontActive, 0 }, /* 149 */
{ "TabNonFrontActiveText", 0, kThemeTextColorTabNonFrontActive, 0 }, /* 150 */
{ "TabNonFrontPressedText", 0, kThemeTextColorTabNonFrontPressed, 0 }, /* 151 */
{ "TabFrontInactiveText", 0, kThemeTextColorTabFrontInactive, 0 }, /* 152 */
{ "TabNonFrontInactiveText", 0, kThemeTextColorTabNonFrontInactive, 0 }, /* 153 */
{ "IconLabelSelectedText", 0, kThemeTextColorIconLabelSelected, 0 }, /* 154 */
{ "BevelButtonStickyActiveText", 0, kThemeTextColorBevelButtonStickyActive, 0 }, /* 155 */
{ "BevelButtonStickyInactiveText", 0, kThemeTextColorBevelButtonStickyInactive, 0 }, /* 156 */
{ "NotificationText", 0, kThemeTextColorNotification, 0 }, /* 157 */
{ "SystemDetailText", 0, kThemeTextColorSystemDetail, 0 }, /* 158 */
{ "WhiteText", 0, kThemeTextColorWhite, 0 }, /* 159 */
{ "TabPaneBackground", 0, 0, kThemeBackgroundTabPane }, /* 160 */
{ "PlacardBackground", 0, 0, kThemeBackgroundPlacard }, /* 161 */
{ "WindowHeaderBackground", 0, 0, kThemeBackgroundWindowHeader }, /* 162 */
{ "ListViewWindowHeaderBackground", 0, 0, kThemeBackgroundListViewWindowHeader }, /* 163 */
{ "SecondaryGroupBoxBackground", 0, 0, kThemeBackgroundSecondaryGroupBox }, /* 164 */
{ "MetalBackground", 0, 0, kThemeBackgroundMetal }, /* 165 */
{ NULL, 0, 0, 0 }
};
#define MAX_PIXELCODE 165
/*
*----------------------------------------------------------------------
*
* GetThemeFromPixelCode --
*
* When given a pixel code corresponding to a theme system color,
* set one of brush, textColor or background to the corresponding
* Appearance Mgr theme constant.
*
* Results:
* Returns false if not a real pixel, true otherwise.
*
* Side effects:
* None.
*
*----------------------------------------------------------------------
*/
static int
GetThemeFromPixelCode(
unsigned char code,
ThemeBrush *brush,
ThemeTextColor *textColor,
ThemeBackgroundKind *background)
{
if (code >= MIN_PIXELCODE && code <= MAX_PIXELCODE) {
*brush = systemColorMap[code - MIN_PIXELCODE].brush;
*textColor = systemColorMap[code - MIN_PIXELCODE].textColor;
*background = systemColorMap[code - MIN_PIXELCODE].background;
} else {
*brush = 0;
*textColor = 0;
*background = 0;
}
if (!*brush && !*textColor && !*background && code != PIXEL_MAGIC &&
code != TRANSPARENT_PIXEL) {
return false;
} else {
return true;
}
}
/*
*----------------------------------------------------------------------
*
* GetThemeColor --
*
* Get RGB color for a given system color or pixel value.
*
* Results:
* OSStatus
*
* Side effects:
* None.
*
*----------------------------------------------------------------------
*/
static OSStatus
GetThemeColor(
unsigned long pixel,
ThemeBrush brush,
ThemeTextColor textColor,
ThemeBackgroundKind background,
CGColorRef *c)
{
OSStatus err = noErr;
if (brush) {
err = ChkErr(HIThemeBrushCreateCGColor, brush, c);
/*} else if (textColor) {
err = ChkErr(GetThemeTextColor, textColor, 32, true, c);*/
} else {
CGFloat rgba[4] = {0, 0, 0, 1};
switch ((pixel >> 24) & 0xff) {
case PIXEL_MAGIC: {
unsigned short red, green, blue;
red = (pixel >> 16) & 0xff;
green = (pixel >> 8) & 0xff;
blue = (pixel ) & 0xff;
red |= red << 8;
green |= green << 8;
blue |= blue << 8;
rgba[0] = red / 65535.0;
rgba[1] = green / 65535.0;
rgba[2] = blue / 65535.0;
break;
}
case TRANSPARENT_PIXEL:
rgba[3] = 0.0;
break;
}
// this attempts to find something roughly fitting for any display
// *c = CGColorCreateGenericRGB(rgba[0], rgba[1], rgba[2], rgba[3]);
// may be off for non-main display but in most cases better than prev
static CGColorSpaceRef deviceRGBSpace = NULL;
if (!deviceRGBSpace) {
deviceRGBSpace = CGDisplayCopyColorSpace(CGMainDisplayID());
}
*c = CGColorCreate(deviceRGBSpace, rgba );
}
return err;
}
/*
*----------------------------------------------------------------------
*
* TkSetMacColor --
*
* Creates a CGColorRef from a X style pixel value.
*
* Results:
* Returns false if not a real pixel, true otherwise.
*
* Side effects:
* The variable macColor is set to a new CGColorRef, the caller is
* responsible for releasing it!
*
*----------------------------------------------------------------------
*/
int
TkSetMacColor(
unsigned long pixel, /* Pixel value to convert. */
void *macColor) /* CGColorRef to modify. */
{
CGColorRef *color = (CGColorRef*)macColor;
OSStatus err = -1;
ThemeBrush brush;
ThemeTextColor textColor;
ThemeBackgroundKind background;
if (GetThemeFromPixelCode((pixel >> 24) & 0xff, &brush, &textColor,
&background)) {
err = ChkErr(GetThemeColor, pixel, brush, textColor, background,
color);
}
return (err == noErr);
}
/*
*----------------------------------------------------------------------
*
* TkpInitGCCache, TkpFreeGCCache, CopyCachedColor, SetCachedColor --
*
* Maintain a per-GC cache of previously converted CGColorRefs
*
* Results:
* None resp. retained CGColorRef for CopyCachedColor()
*
* Side effects:
* None.
*
*----------------------------------------------------------------------
*/
void
TkpInitGCCache(
GC gc)
{
bzero(TkpGetGCCache(gc), sizeof(TkpGCCache));
}
void
TkpFreeGCCache(
GC gc)
{
TkpGCCache *gcCache = TkpGetGCCache(gc);
if (gcCache->cachedForegroundColor) {
CFRelease(gcCache->cachedForegroundColor);
}
if (gcCache->cachedBackgroundColor) {
CFRelease(gcCache->cachedBackgroundColor);
}
}
static CGColorRef
CopyCachedColor(
GC gc,
unsigned long pixel)
{
TkpGCCache *gcCache = TkpGetGCCache(gc);
CGColorRef cgColor = NULL;
if (gcCache) {
if (gcCache->cachedForeground == pixel) {
cgColor = gcCache->cachedForegroundColor;
} else if (gcCache->cachedBackground == pixel) {
cgColor = gcCache->cachedBackgroundColor;
}
if (cgColor) {
CFRetain(cgColor);
}
}
return cgColor;
}
static void
SetCachedColor(
GC gc,
unsigned long pixel,
CGColorRef cgColor)
{
TkpGCCache *gcCache = TkpGetGCCache(gc);
if (gcCache && cgColor) {
if (gc->foreground == pixel) {
if (gcCache->cachedForegroundColor) {
CFRelease(gcCache->cachedForegroundColor);
}
gcCache->cachedForegroundColor = (CGColorRef) CFRetain(cgColor);
gcCache->cachedForeground = pixel;
} else if (gc->background == pixel) {
if (gcCache->cachedBackgroundColor) {
CFRelease(gcCache->cachedBackgroundColor);
}
gcCache->cachedBackgroundColor = (CGColorRef) CFRetain(cgColor);
gcCache->cachedBackground = pixel;
}
}
}
/*
*----------------------------------------------------------------------
*
* TkMacOSXCreateCGColor --
*
* Creates a CGColorRef from a X style pixel value.
*
* Results:
* Returns NULL if not a real pixel, CGColorRef otherwise.
*
* Side effects:
* None
*
*----------------------------------------------------------------------
*/
CGColorRef
TkMacOSXCreateCGColor(
GC gc,
unsigned long pixel) /* Pixel value to convert. */
{
CGColorRef cgColor = CopyCachedColor(gc, pixel);
if (!cgColor && TkSetMacColor(pixel, &cgColor)) {
SetCachedColor(gc, pixel, cgColor);
}
return cgColor;
}
/*
*----------------------------------------------------------------------
*
* TkMacOSXGetNSColor --
*
* Creates an autoreleased NSColor from a X style pixel value.
*
* Results:
* Returns nil if not a real pixel, NSColor* otherwise.
*
* Side effects:
* None
*
*----------------------------------------------------------------------
*/
NSColor*
TkMacOSXGetNSColor(
GC gc,
unsigned long pixel) /* Pixel value to convert. */
{
CGColorRef cgColor = TkMacOSXCreateCGColor(gc, pixel);
NSColor *nsColor = nil;
if (cgColor) {
NSColorSpace *colorSpace = [[NSColorSpace alloc]
initWithCGColorSpace:CGColorGetColorSpace(cgColor)];
nsColor = [NSColor colorWithColorSpace:colorSpace
components:CGColorGetComponents(cgColor)
count:CGColorGetNumberOfComponents(cgColor)];
[colorSpace release];
CFRelease(cgColor);
}
return nsColor;
}
/*
*----------------------------------------------------------------------
*
* TkMacOSXSetColorInContext --
*
* Sets fill and stroke color in the given CG context from an X
* pixel value, or if the pixel code indicates a system color,
* sets the corresponding brush, textColor or background via
* HITheme APIs if available or Appearance mgr APIs.
*
* Results:
* None.
*
* Side effects:
* None.
*
*----------------------------------------------------------------------
*/
void
TkMacOSXSetColorInContext(
GC gc,
unsigned long pixel,
CGContextRef context)
{
OSStatus err = -1;
CGColorRef cgColor = CopyCachedColor(gc, pixel);
ThemeBrush brush;
ThemeTextColor textColor;
ThemeBackgroundKind background;
if (!cgColor && GetThemeFromPixelCode((pixel >> 24) & 0xff, &brush,
&textColor, &background)) {
if (brush) {
err = ChkErr(HIThemeSetFill, brush, NULL, context,
kHIThemeOrientationNormal);
if (err == noErr) {
err = ChkErr(HIThemeSetStroke, brush, NULL, context,
kHIThemeOrientationNormal);
}
} else if (textColor) {
err = ChkErr(HIThemeSetTextFill, textColor, NULL, context,
kHIThemeOrientationNormal);
} else if (background) {
CGRect rect = CGContextGetClipBoundingBox(context);
HIThemeBackgroundDrawInfo info = { 0, kThemeStateActive,
background };
err = ChkErr(HIThemeApplyBackground, &rect, &info,
context, kHIThemeOrientationNormal);
}
if (err == noErr) {
return;
}
err = ChkErr(GetThemeColor, pixel, brush, textColor, background,
&cgColor);
if (err == noErr) {
SetCachedColor(gc, pixel, cgColor);
}
} else if (!cgColor) {
TkMacOSXDbgMsg("Ignored unknown pixel value 0x%lx", pixel);
}
if (cgColor) {
CGContextSetFillColorWithColor(context, cgColor);
CGContextSetStrokeColorWithColor(context, cgColor);
CGColorRelease(cgColor);
}
}
/*
*----------------------------------------------------------------------
*
* TkpGetColor --
*
* Allocate a new TkColor for the color with the given name.
*
* Results:
* Returns a newly allocated TkColor, or NULL on failure.
*
* Side effects:
* May invalidate the colormap cache associated with tkwin upon
* allocating a new colormap entry. Allocates a new TkColor
* structure.
*
*----------------------------------------------------------------------
*/
TkColor *
TkpGetColor(
Tk_Window tkwin, /* Window in which color will be used. */
Tk_Uid name) /* Name of color to allocated (in form
* suitable for passing to XParseColor). */
{
Display *display = tkwin != None ? Tk_Display(tkwin) : NULL;
Colormap colormap = tkwin!= None ? Tk_Colormap(tkwin) : None;
TkColor *tkColPtr;
XColor color;
/*
* Check to see if this is a system color. Otherwise, XParseColor
* will do all the work.
*/
if (strncasecmp(name, "system", 6) == 0) {
Tcl_Obj *strPtr = Tcl_NewStringObj(name+6, -1);
int idx, result;
result = Tcl_GetIndexFromObjStruct(NULL, strPtr, systemColorMap,
sizeof(struct SystemColorMapEntry), NULL, TCL_EXACT, &idx);
Tcl_DecrRefCount(strPtr);
if (result == TCL_OK) {
OSStatus err;
CGColorRef c;
unsigned char pixelCode = idx + MIN_PIXELCODE;
ThemeBrush brush = systemColorMap[idx].brush;
ThemeTextColor textColor = systemColorMap[idx].textColor;
ThemeBackgroundKind background = systemColorMap[idx].background;
err = ChkErr(GetThemeColor, 0, brush, textColor, background, &c);
if (err == noErr) {
const size_t n = CGColorGetNumberOfComponents(c);
const CGFloat *rgba = CGColorGetComponents(c);
switch (n) {
case 4:
color.red = rgba[0] * 65535.0;
color.green = rgba[1] * 65535.0;
color.blue = rgba[2] * 65535.0;
break;
case 2:
color.red = color.green = color.blue = rgba[0] * 65535.0;
break;
default:
Tcl_Panic("CGColor with %d components", n);
}
color.pixel = ((((((pixelCode << 8)
| ((color.red >> 8) & 0xff)) << 8)
| ((color.green >> 8) & 0xff)) << 8)
| ((color.blue >> 8) & 0xff));
CGColorRelease(c);
goto validXColor;
}
CGColorRelease(c);
}
}
if (TkParseColor(display, colormap, name, &color) == 0) {
return (TkColor *) NULL;
}
validXColor:
tkColPtr = (TkColor *) ckalloc(sizeof(TkColor));
tkColPtr->color = color;
return tkColPtr;
}
/*
*----------------------------------------------------------------------
*
* TkpGetColorByValue --
*
* Given a desired set of red-green-blue intensities for a color,
* locate a pixel value to use to draw that color in a given
* window.
*
* Results:
* The return value is a pointer to an TkColor structure that
* indicates the closest red, blue, and green intensities available
* to those specified in colorPtr, and also specifies a pixel
* value to use to draw in that color.
*
* Side effects:
* May invalidate the colormap cache for the specified window.
* Allocates a new TkColor structure.
*
*----------------------------------------------------------------------
*/
TkColor *
TkpGetColorByValue(
Tk_Window tkwin, /* Window in which color will be used. */
XColor *colorPtr) /* Red, green, and blue fields indicate
* desired color. */
{
TkColor *tkColPtr = (TkColor *) ckalloc(sizeof(TkColor));
tkColPtr->color.red = colorPtr->red;
tkColPtr->color.green = colorPtr->green;
tkColPtr->color.blue = colorPtr->blue;
tkColPtr->color.pixel = TkpGetPixel(&tkColPtr->color);
return tkColPtr;
}
/*
*----------------------------------------------------------------------
*
* Stub functions --
*
* These functions are just stubs for functions that either
* don't make sense on the Mac or have yet to be implemented.
*
* Results:
* None.
*
* Side effects:
* These calls do nothing - which may not be expected.
*
*----------------------------------------------------------------------
*/
Status
XAllocColor(
Display *display, /* Display. */
Colormap map, /* Not used. */
XColor *colorPtr) /* XColor struct to modify. */
{
display->request++;
colorPtr->pixel = TkpGetPixel(colorPtr);
return 1;
}
Colormap
XCreateColormap(
Display *display, /* Display. */
Window window, /* X window. */
Visual *visual, /* Not used. */
int alloc) /* Not used. */
{
static Colormap index = 1;
/*
* Just return a new value each time.
*/
return index++;
}
int
XFreeColormap(
Display* display, /* Display. */
Colormap colormap) /* Colormap. */
{
return Success;
}
int
XFreeColors(
Display* display, /* Display. */
Colormap colormap, /* Colormap. */
unsigned long* pixels, /* Array of pixels. */
int npixels, /* Number of pixels. */
unsigned long planes) /* Number of pixel planes. */
{
/*
* The Macintosh version of Tk uses TrueColor. Nothing
* needs to be done to release colors as there really is
* no colormap in the Tk sense.
*/
return Success;
}
/*
* Local Variables:
* mode: objc
* c-basic-offset: 4
* fill-column: 79
* coding: utf-8
* End:
*/

43
macosx/tkMacOSXConfig.c Normal file
View File

@@ -0,0 +1,43 @@
/*
* tkMacOSXConfig.c --
*
* This module implements the Macintosh system defaults for
* the configuration package.
*
* Copyright (c) 1997 by Sun Microsystems, Inc.
* Copyright 2001, Apple Inc.
*
* See the file "license.terms" for information on usage and redistribution
* of this file, and for a DISCLAIMER OF ALL WARRANTIES.
*/
#include "tkInt.h"
/*
*----------------------------------------------------------------------
*
* TkpGetSystemDefault --
*
* Given a dbName and className for a configuration option,
* return a string representation of the option.
*
* Results:
* Returns a Tk_Uid that is the string identifier that identifies
* this option. Returns NULL if there are no system defaults
* that match this pair.
*
* Side effects:
* None, once the package is initialized.
*
*----------------------------------------------------------------------
*/
Tcl_Obj *
TkpGetSystemDefault(
Tk_Window tkwin, /* A window to use. */
const char *dbName, /* The option database name. */
const char *className) /* The name of the option class. */
{
return NULL;
}

592
macosx/tkMacOSXCursor.c Normal file
View File

@@ -0,0 +1,592 @@
/*
* tkMacOSXCursor.c --
*
* This file contains Macintosh specific cursor related routines.
*
* Copyright (c) 1995-1997 Sun Microsystems, Inc.
* Copyright 2001-2009, Apple Inc.
* Copyright (c) 2006-2009 Daniel A. Steffen <das@users.sourceforge.net>
*
* See the file "license.terms" for information on usage and redistribution
* of this file, and for a DISCLAIMER OF ALL WARRANTIES.
*/
#include "tkMacOSXPrivate.h"
#include "tkMacOSXCursors.h"
#include "tkMacOSXXCursors.h"
/*
* Mac Cursor Types.
*/
#define NONE -1 /* Hidden cursor */
#define SELECTOR 1 /* NSCursor class method */
#define IMAGENAMED 2 /* Named NSImage */
#define IMAGEPATH 3 /* Path to NSImage */
#define IMAGEBITMAP 4 /* Pointer to 16x16 cursor bitmap data */
#define pix 16 /* Pixel width & height of cursor bitmap data */
/*
* The following data structure contains the system specific data necessary to
* control Windows cursors.
*/
typedef struct {
TkCursor info; /* Generic cursor info used by tkCursor.c */
NSCursor *macCursor; /* Macintosh cursor */
int type; /* Type of Mac cursor */
} TkMacOSXCursor;
/*
* The table below is used to map from the name of a predefined cursor
* to a NSCursor.
*/
struct CursorName {
const char *name;
const int kind;
id id1, id2;
NSPoint hotspot;
};
#define MacCursorData(n) ((id)tkMacOSXCursors[TK_MAC_CURSOR_##n])
#define MacXCursorData(n) ((id)tkMacOSXXCursors[TK_MAC_XCURSOR_##n])
static const struct CursorName cursorNames[] = {
{"none", NONE, nil},
{"arrow", SELECTOR, @"arrowCursor"},
{"top_left_arrow", SELECTOR, @"arrowCursor"},
{"left_ptr", SELECTOR, @"arrowCursor"},
{"copyarrow", SELECTOR, @"dragCopyCursor", @"_copyDragCursor"},
{"aliasarrow", SELECTOR, @"dragLinkCursor", @"_linkDragCursor"},
{"contextualmenuarrow", SELECTOR, @"contextualMenuCursor"},
{"movearrow", SELECTOR, @"_moveCursor"},
{"ibeam", SELECTOR, @"IBeamCursor"},
{"text", SELECTOR, @"IBeamCursor"},
{"xterm", SELECTOR, @"IBeamCursor"},
{"cross", SELECTOR, @"crosshairCursor"},
{"crosshair", SELECTOR, @"crosshairCursor"},
{"cross-hair", SELECTOR, @"crosshairCursor"},
{"tcross", SELECTOR, @"crosshairCursor"},
{"hand", SELECTOR, @"openHandCursor"},
{"openhand", SELECTOR, @"openHandCursor"},
{"closedhand", SELECTOR, @"closedHandCursor"},
{"fist", SELECTOR, @"closedHandCursor"},
{"pointinghand", SELECTOR, @"pointingHandCursor"},
{"resize", SELECTOR, @"arrowCursor"},
{"resizeleft", SELECTOR, @"resizeLeftCursor"},
{"resizeright", SELECTOR, @"resizeRightCursor"},
{"resizeleftright", SELECTOR, @"resizeLeftRightCursor"},
{"resizeup", SELECTOR, @"resizeUpCursor"},
{"resizedown", SELECTOR, @"resizeDownCursor"},
{"resizeupdown", SELECTOR, @"resizeUpDownCursor"},
{"resizebottomleft", SELECTOR, @"_bottomLeftResizeCursor"},
{"resizetopleft", SELECTOR, @"_topLeftResizeCursor"},
{"resizebottomright", SELECTOR, @"_bottomRightResizeCursor"},
{"resizetopright", SELECTOR, @"_topRightResizeCursor"},
{"notallowed", SELECTOR, @"operationNotAllowedCursor"},
{"poof", SELECTOR, @"disappearingItemCursor"},
{"wait", SELECTOR, @"busyButClickableCursor"},
{"spinning", SELECTOR, @"busyButClickableCursor"},
{"countinguphand", SELECTOR, @"busyButClickableCursor"},
{"countingdownhand", SELECTOR, @"busyButClickableCursor"},
{"countingupanddownhand", SELECTOR, @"busyButClickableCursor"},
{"help", IMAGENAMED, @"NSHelpCursor", nil, {8, 8}},
// {"hand", IMAGEBITMAP, MacCursorData(hand)},
{"bucket", IMAGEBITMAP, MacCursorData(bucket)},
{"cancel", IMAGEBITMAP, MacCursorData(cancel)},
// {"resize", IMAGEBITMAP, MacCursorData(resize)},
{"eyedrop", IMAGEBITMAP, MacCursorData(eyedrop)},
{"eyedrop-full", IMAGEBITMAP, MacCursorData(eyedrop_full)},
{"zoom-in", IMAGEBITMAP, MacCursorData(zoom_in)},
{"zoom-out", IMAGEBITMAP, MacCursorData(zoom_out)},
{"X_cursor", IMAGEBITMAP, MacXCursorData(X_cursor)},
// {"arrow", IMAGEBITMAP, MacXCursorData(arrow)},
{"based_arrow_down", IMAGEBITMAP, MacXCursorData(based_arrow_down)},
{"based_arrow_up", IMAGEBITMAP, MacXCursorData(based_arrow_up)},
{"boat", IMAGEBITMAP, MacXCursorData(boat)},
{"bogosity", IMAGEBITMAP, MacXCursorData(bogosity)},
{"bottom_left_corner", IMAGEBITMAP, MacXCursorData(bottom_left_corner)},
{"bottom_right_corner", IMAGEBITMAP, MacXCursorData(bottom_right_corner)},
{"bottom_side", IMAGEBITMAP, MacXCursorData(bottom_side)},
{"bottom_tee", IMAGEBITMAP, MacXCursorData(bottom_tee)},
{"box_spiral", IMAGEBITMAP, MacXCursorData(box_spiral)},
{"center_ptr", IMAGEBITMAP, MacXCursorData(center_ptr)},
{"circle", IMAGEBITMAP, MacXCursorData(circle)},
{"clock", IMAGEBITMAP, MacXCursorData(clock)},
{"coffee_mug", IMAGEBITMAP, MacXCursorData(coffee_mug)},
// {"cross", IMAGEBITMAP, MacXCursorData(cross)},
{"cross_reverse", IMAGEBITMAP, MacXCursorData(cross_reverse)},
// {"crosshair", IMAGEBITMAP, MacXCursorData(crosshair)},
{"diamond_cross", IMAGEBITMAP, MacXCursorData(diamond_cross)},
{"dot", IMAGEBITMAP, MacXCursorData(dot)},
{"dotbox", IMAGEBITMAP, MacXCursorData(dotbox)},
{"double_arrow", IMAGEBITMAP, MacXCursorData(double_arrow)},
{"draft_large", IMAGEBITMAP, MacXCursorData(draft_large)},
{"draft_small", IMAGEBITMAP, MacXCursorData(draft_small)},
{"draped_box", IMAGEBITMAP, MacXCursorData(draped_box)},
{"exchange", IMAGEBITMAP, MacXCursorData(exchange)},
{"fleur", IMAGEBITMAP, MacXCursorData(fleur)},
{"gobbler", IMAGEBITMAP, MacXCursorData(gobbler)},
{"gumby", IMAGEBITMAP, MacXCursorData(gumby)},
{"hand1", IMAGEBITMAP, MacXCursorData(hand1)},
{"hand2", IMAGEBITMAP, MacXCursorData(hand2)},
{"heart", IMAGEBITMAP, MacXCursorData(heart)},
{"icon", IMAGEBITMAP, MacXCursorData(icon)},
{"iron_cross", IMAGEBITMAP, MacXCursorData(iron_cross)},
// {"left_ptr", IMAGEBITMAP, MacXCursorData(left_ptr)},
{"left_side", IMAGEBITMAP, MacXCursorData(left_side)},
{"left_tee", IMAGEBITMAP, MacXCursorData(left_tee)},
{"leftbutton", IMAGEBITMAP, MacXCursorData(leftbutton)},
{"ll_angle", IMAGEBITMAP, MacXCursorData(ll_angle)},
{"lr_angle", IMAGEBITMAP, MacXCursorData(lr_angle)},
{"man", IMAGEBITMAP, MacXCursorData(man)},
{"middlebutton", IMAGEBITMAP, MacXCursorData(middlebutton)},
{"mouse", IMAGEBITMAP, MacXCursorData(mouse)},
{"pencil", IMAGEBITMAP, MacXCursorData(pencil)},
{"pirate", IMAGEBITMAP, MacXCursorData(pirate)},
{"plus", IMAGEBITMAP, MacXCursorData(plus)},
{"question_arrow", IMAGEBITMAP, MacXCursorData(question_arrow)},
{"right_ptr", IMAGEBITMAP, MacXCursorData(right_ptr)},
{"right_side", IMAGEBITMAP, MacXCursorData(right_side)},
{"right_tee", IMAGEBITMAP, MacXCursorData(right_tee)},
{"rightbutton", IMAGEBITMAP, MacXCursorData(rightbutton)},
{"rtl_logo", IMAGEBITMAP, MacXCursorData(rtl_logo)},
{"sailboat", IMAGEBITMAP, MacXCursorData(sailboat)},
{"sb_down_arrow", IMAGEBITMAP, MacXCursorData(sb_down_arrow)},
{"sb_h_double_arrow", IMAGEBITMAP, MacXCursorData(sb_h_double_arrow)},
{"sb_left_arrow", IMAGEBITMAP, MacXCursorData(sb_left_arrow)},
{"sb_right_arrow", IMAGEBITMAP, MacXCursorData(sb_right_arrow)},
{"sb_up_arrow", IMAGEBITMAP, MacXCursorData(sb_up_arrow)},
{"sb_v_double_arrow", IMAGEBITMAP, MacXCursorData(sb_v_double_arrow)},
{"shuttle", IMAGEBITMAP, MacXCursorData(shuttle)},
{"sizing", IMAGEBITMAP, MacXCursorData(sizing)},
{"spider", IMAGEBITMAP, MacXCursorData(spider)},
{"spraycan", IMAGEBITMAP, MacXCursorData(spraycan)},
{"star", IMAGEBITMAP, MacXCursorData(star)},
{"target", IMAGEBITMAP, MacXCursorData(target)},
// {"tcross", IMAGEBITMAP, MacXCursorData(tcross)},
// {"top_left_arrow", IMAGEBITMAP, MacXCursorData(top_left_arrow)},
{"top_left_corner", IMAGEBITMAP, MacXCursorData(top_left_corner)},
{"top_right_corner", IMAGEBITMAP, MacXCursorData(top_right_corner)},
{"top_side", IMAGEBITMAP, MacXCursorData(top_side)},
{"top_tee", IMAGEBITMAP, MacXCursorData(top_tee)},
{"trek", IMAGEBITMAP, MacXCursorData(trek)},
{"ul_angle", IMAGEBITMAP, MacXCursorData(ul_angle)},
{"umbrella", IMAGEBITMAP, MacXCursorData(umbrella)},
{"ur_angle", IMAGEBITMAP, MacXCursorData(ur_angle)},
{"watch", IMAGEBITMAP, MacXCursorData(watch)},
// {"xterm", IMAGEBITMAP, MacXCursorData(xterm)},
{NULL}
};
/*
* Declarations of static variables used in this file.
*/
static TkMacOSXCursor * gCurrentCursor = NULL;
/* A pointer to the current cursor. */
static int gResizeOverride = false;
/* A boolean indicating whether we should use
* the resize cursor during installations. */
static int gTkOwnsCursor = true;/* A boolean indicating whether Tk owns the
* cursor. If not (for instance, in the case
* where a Tk window is embedded in another
* app's window, and the cursor is out of the
* tk window, we will not attempt to adjust
* the cursor. */
/*
* Declarations of procedures local to this file
*/
static void FindCursorByName(TkMacOSXCursor *macCursorPtr, const char *string);
/*
*----------------------------------------------------------------------
*
* FindCursorByName --
*
* Retrieve a system cursor by name, and fill the macCursorPtr
* structure. If the cursor cannot be found, the macCursor field
* will be nil.
*
* Results:
* Fills the macCursorPtr record.
*
* Side effects:
* None
*
*----------------------------------------------------------------------
*/
void
FindCursorByName(
TkMacOSXCursor *macCursorPtr,
const char *name)
{
NSString *path = nil;
NSImage *image = nil;
NSPoint hotSpot = NSZeroPoint;
int haveHotSpot = 0, result = TCL_ERROR;
NSCursor *macCursor = nil;
if (name[0] == '@') {
/*
* System cursor of type @filename
*/
macCursorPtr->type = IMAGEPATH;
path = [NSString stringWithUTF8String:&name[1]];
} else {
Tcl_Obj *strPtr = Tcl_NewStringObj(name, -1);
int idx;
result = Tcl_GetIndexFromObjStruct(NULL, strPtr, cursorNames,
sizeof(struct CursorName), NULL, TCL_EXACT, &idx);
Tcl_DecrRefCount(strPtr);
if (result == TCL_OK) {
macCursorPtr->type = cursorNames[idx].kind;
switch (cursorNames[idx].kind) {
case SELECTOR: {
SEL selector = NSSelectorFromString(cursorNames[idx].id1);
if ([NSCursor respondsToSelector:selector]) {
macCursor = [[NSCursor performSelector:selector] retain];
} else if (cursorNames[idx].id2) {
selector = NSSelectorFromString(cursorNames[idx].id2);
if ([NSCursor respondsToSelector:selector]) {
macCursor = [[NSCursor performSelector:selector] retain];
}
}
break;
}
case IMAGENAMED:
image = [[NSImage imageNamed:cursorNames[idx].id1] retain];
hotSpot = cursorNames[idx].hotspot;
haveHotSpot = 1;
break;
case IMAGEPATH:
path = [NSApp tkFrameworkImagePath:cursorNames[idx].id1];
break;
case IMAGEBITMAP: {
unsigned char *bitmap = (unsigned char *)(cursorNames[idx].id1);
NSBitmapImageRep *bitmapImageRep = NULL;
CGImageRef img = NULL, mask = NULL, maskedImg = NULL;
static const CGFloat decodeWB[] = {1, 0};
CGColorSpaceRef colorspace = CGColorSpaceCreateWithName(
kCGColorSpaceGenericGray);
CGDataProviderRef provider = CGDataProviderCreateWithData(NULL,
bitmap, pix*pix/8, NULL);
if (provider) {
img = CGImageCreate(pix, pix, 1, 1, pix/8, colorspace,
kCGBitmapByteOrderDefault, provider, decodeWB, 0,
kCGRenderingIntentDefault);
CFRelease(provider);
}
provider = CGDataProviderCreateWithData(NULL, bitmap +
pix*pix/8, pix*pix/8, NULL);
if (provider) {
mask = CGImageMaskCreate(pix, pix, 1, 1, pix/8, provider,
decodeWB, 0);
CFRelease(provider);
}
if (img && mask) {
maskedImg = CGImageCreateWithMask(img, mask);
}
if (maskedImg) {
bitmapImageRep = [[NSBitmapImageRep alloc]
initWithCGImage:maskedImg];
CFRelease(maskedImg);
}
if (mask) { CFRelease(mask); }
if (img) { CFRelease(img); }
if (colorspace) { CFRelease(colorspace); }
if (bitmapImageRep) {
image = [[NSImage alloc] initWithSize:NSMakeSize(pix, pix)];
[image addRepresentation:bitmapImageRep];
[bitmapImageRep release];
}
uint16_t *hotSpotData = (uint16_t*)(bitmap + 2*pix*pix/8);
hotSpot.y = CFSwapInt16BigToHost(*hotSpotData++);
hotSpot.x = CFSwapInt16BigToHost(*hotSpotData);
haveHotSpot = 1;
break;
}
}
}
}
if (path) {
image = [[NSImage alloc] initWithContentsOfFile:path];
}
if (!image && !macCursor && result != TCL_OK) {
macCursorPtr->type = IMAGENAMED;
image = [[NSImage imageNamed:[NSString stringWithUTF8String:name]]
retain];
haveHotSpot = 0;
}
if (image) {
if (!haveHotSpot && [[path pathExtension] isEqualToString:@"cur"]) {
NSData *data = [NSData dataWithContentsOfFile:path];
if ([data length] > 14) {
uint16_t *hotSpotData = (uint16_t*)((char*) [data bytes] + 10);
hotSpot.x = CFSwapInt16LittleToHost(*hotSpotData++);
hotSpot.y = CFSwapInt16LittleToHost(*hotSpotData);
haveHotSpot = 1;
}
}
if (!haveHotSpot) {
NSSize size = [image size];
hotSpot.x = size.width * 0.5;
hotSpot.y = size.height * 0.5;
}
hotSpot.y = -hotSpot.y;
macCursor = [[NSCursor alloc] initWithImage:image hotSpot:hotSpot];
[image release];
}
macCursorPtr->macCursor = TkMacOSXMakeUncollectable(macCursor);
}
/*
*----------------------------------------------------------------------
*
* TkGetCursorByName --
*
* Retrieve a system cursor by name.
*
* Results:
* Returns a new cursor, or NULL on errors.
*
* Side effects:
* Allocates a new cursor.
*
*----------------------------------------------------------------------
*/
TkCursor *
TkGetCursorByName(
Tcl_Interp *interp, /* Interpreter to use for error reporting. */
Tk_Window tkwin, /* Window in which cursor will be used. */
Tk_Uid string) /* Description of cursor. See manual entry
* for details on legal syntax. */
{
TkMacOSXCursor *macCursorPtr = NULL;
const char **argv = NULL;
int argc;
/*
* All cursor names are valid lists of one element (for
* TkX11-compatibility), even unadorned system cursor names.
*/
if (Tcl_SplitList(interp, string, &argc, &argv) == TCL_OK) {
if (argc) {
macCursorPtr = (TkMacOSXCursor *) ckalloc(sizeof(TkMacOSXCursor));
macCursorPtr->info.cursor = (Tk_Cursor) macCursorPtr;
macCursorPtr->macCursor = nil;
macCursorPtr->type = 0;
FindCursorByName(macCursorPtr, argv[0]);
}
ckfree((char *) argv);
}
if (!macCursorPtr || (!macCursorPtr->macCursor &&
macCursorPtr->type != NONE)) {
Tcl_AppendResult(interp, "bad cursor spec \"", string, "\"", NULL);
if (macCursorPtr) {
ckfree((char *)macCursorPtr);
macCursorPtr = NULL;
}
}
return (TkCursor *) macCursorPtr;
}
/*
*----------------------------------------------------------------------
*
* TkCreateCursorFromData --
*
* Creates a cursor from the source and mask bits.
*
* Results:
* Returns a new cursor, or NULL on errors.
*
* Side effects:
* Allocates a new cursor.
*
*----------------------------------------------------------------------
*/
TkCursor *
TkCreateCursorFromData(
Tk_Window tkwin, /* Window in which cursor will be used. */
const char *source, /* Bitmap data for cursor shape. */
const char *mask, /* Bitmap data for cursor mask. */
int width, int height, /* Dimensions of cursor. */
int xHot, int yHot, /* Location of hot-spot in cursor. */
XColor fgColor, /* Foreground color for cursor. */
XColor bgColor) /* Background color for cursor. */
{
return NULL;
}
/*
*----------------------------------------------------------------------
*
* TkpFreeCursor --
*
* This procedure is called to release a cursor allocated by
* TkGetCursorByName.
*
* Results:
* None.
*
* Side effects:
* The cursor data structure is deallocated.
*
*----------------------------------------------------------------------
*/
void
TkpFreeCursor(
TkCursor *cursorPtr)
{
TkMacOSXCursor *macCursorPtr = (TkMacOSXCursor *) cursorPtr;
TkMacOSXMakeCollectableAndRelease(macCursorPtr->macCursor);
if (macCursorPtr == gCurrentCursor) {
gCurrentCursor = NULL;
}
}
/*
*----------------------------------------------------------------------
*
* TkMacOSXInstallCursor --
*
* Installs either the current cursor as defined by TkpSetCursor or a
* resize cursor as the cursor the Macintosh should currently display.
*
* Results:
* None.
*
* Side effects:
* Changes the Macintosh mouse cursor.
*
*----------------------------------------------------------------------
*/
void
TkMacOSXInstallCursor(
int resizeOverride)
{
TkMacOSXCursor *macCursorPtr = gCurrentCursor;
static int cursorHidden = 0;
int cursorNone = 0;
gResizeOverride = resizeOverride;
if (resizeOverride || !macCursorPtr) {
[[NSCursor arrowCursor] set];
} else {
switch (macCursorPtr->type) {
case NONE:
if (!cursorHidden) {
cursorHidden = 1;
[NSCursor hide];
}
cursorNone = 1;
break;
case SELECTOR:
case IMAGENAMED:
case IMAGEPATH:
case IMAGEBITMAP:
default:
[macCursorPtr->macCursor set];
break;
}
}
if (cursorHidden && !cursorNone) {
cursorHidden = 0;
[NSCursor unhide];
}
}
/*
*----------------------------------------------------------------------
*
* TkpSetCursor --
*
* Set the current cursor and install it.
*
* Results:
* None.
*
* Side effects:
* Changes the current cursor.
*
*----------------------------------------------------------------------
*/
void
TkpSetCursor(
TkpCursor cursor)
{
int cursorChanged = 1;
if (!gTkOwnsCursor) {
return;
}
if (cursor == None) {
/*
* This is a little tricky. We can't really tell whether
* gCurrentCursor is NULL because it was NULL last time around or
* because we just freed the current cursor. So if the input cursor is
* NULL, we always need to reset it, we can't trust the cursorChanged
* logic.
*/
gCurrentCursor = NULL;
} else {
if (gCurrentCursor == (TkMacOSXCursor *) cursor) {
cursorChanged = 0;
}
gCurrentCursor = (TkMacOSXCursor *) cursor;
}
if (Tk_MacOSXIsAppInFront() && cursorChanged) {
TkMacOSXInstallCursor(gResizeOverride);
}
}
/*
*----------------------------------------------------------------------
*
* Tk_MacOSXTkOwnsCursor --
*
* Sets whether Tk has the right to adjust the cursor.
*
* Results:
* None.
*
* Side effects:
* May keep Tk from changing the cursor.
*
*----------------------------------------------------------------------
*/
void
Tk_MacOSXTkOwnsCursor(
int tkOwnsIt)
{
gTkOwnsCursor = tkOwnsIt;
}
/*
* Local Variables:
* mode: objc
* c-basic-offset: 4
* fill-column: 79
* coding: utf-8
* End:
*/

89
macosx/tkMacOSXCursors.h Normal file
View File

@@ -0,0 +1,89 @@
/*
* tkMacOSXCursors.h --
*
* This file defines a set of Macintosh cursor resources that
* are only available on the Macintosh platform.
*
* Copyright (c) 1995-1996 Sun Microsystems, Inc.
* Copyright 2008-2009, Apple Inc.
* Copyright (c) 2008-2009 Daniel A. Steffen <das@users.sourceforge.net>
*
* See the file "license.terms" for information on usage and redistribution
* of this file, and for a DISCLAIMER OF ALL WARRANTIES.
*/
static const unsigned char tkMacOSXCursors[][68] = {
#define TK_MAC_CURSOR_hand 0
[TK_MAC_CURSOR_hand] = {
0x01, 0x80, 0x1A, 0x70, 0x26, 0x48, 0x26, 0x4A, 0x12, 0x4D, 0x12, 0x49, 0x68, 0x09, 0x98, 0x01,
0x88, 0x02, 0x40, 0x02, 0x20, 0x02, 0x20, 0x04, 0x10, 0x04, 0x08, 0x08, 0x04, 0x08, 0x04, 0x08,
0x01, 0x80, 0x1B, 0xF0, 0x3F, 0xF8, 0x3F, 0xFA, 0x1F, 0xFF, 0x1F, 0xFF, 0x6F, 0xFF, 0xFF, 0xFF,
0xFF, 0xFE, 0x7F, 0xFE, 0x3F, 0xFE, 0x3F, 0xFC, 0x1F, 0xFC, 0x0F, 0xF8, 0x07, 0xF8, 0x07, 0xF8,
0x00, 0x09, 0x00, 0x08,
},
#define TK_MAC_CURSOR_bucket 2
[TK_MAC_CURSOR_bucket] = {
0x00, 0x00, 0x00, 0x00, 0x06, 0x00, 0x09, 0x80, 0x09, 0x40, 0x0B, 0x30, 0x0D, 0x18, 0x09, 0x0C,
0x12, 0x9C, 0x21, 0x2C, 0x10, 0x4C, 0x08, 0x8C, 0x05, 0x0C, 0x02, 0x08, 0x00, 0x00, 0x00, 0x00,
0x00, 0x00, 0x00, 0x00, 0x06, 0x00, 0x09, 0x80, 0x09, 0xC0, 0x0B, 0xF0, 0x0F, 0xF8, 0x0F, 0xFC,
0x1F, 0xFC, 0x3F, 0xEC, 0x1F, 0xCC, 0x0F, 0x8C, 0x07, 0x0C, 0x02, 0x08, 0x00, 0x00, 0x00, 0x00,
0x00, 0x0D, 0x00, 0x0C,
},
#define TK_MAC_CURSOR_cancel 3
[TK_MAC_CURSOR_cancel] = {
0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x31, 0x80, 0x4A, 0x40, 0x4A, 0x40, 0x3F, 0x80,
0x0A, 0x00, 0x3F, 0x80, 0x4A, 0x40, 0x4A, 0x46, 0x31, 0x86, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00,
0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x31, 0x80, 0x7B, 0xC0, 0xFF, 0xE0, 0xFF, 0xE0, 0x7F, 0xC0,
0x3F, 0x80, 0x7F, 0xC0, 0xFF, 0xE6, 0xFF, 0xEF, 0x7B, 0xCF, 0x31, 0x86, 0x00, 0x00, 0x00, 0x00,
0x00, 0x08, 0x00, 0x05,
},
#define TK_MAC_CURSOR_resize 4
[TK_MAC_CURSOR_resize] = {
0xFF, 0xFF, 0x80, 0x01, 0xBF, 0x01, 0xA1, 0x81, 0xA1, 0xF9, 0xA1, 0x8D, 0xA1, 0x8D, 0xBF, 0x8D,
0x9F, 0x8D, 0x88, 0x0D, 0x88, 0x0D, 0x88, 0x0D, 0x8F, 0xFD, 0x87, 0xFD, 0x80, 0x01, 0xFF, 0xFF,
0xFF, 0xFF, 0xFF, 0xFF, 0xFF, 0xFF, 0xFF, 0xFF, 0xFF, 0xFF, 0xFF, 0xFF, 0xFF, 0xFF, 0xFF, 0xFF,
0xFF, 0xFF, 0xFF, 0xFF, 0xFF, 0xFF, 0xFF, 0xFF, 0xFF, 0xFF, 0xFF, 0xFF, 0xFF, 0xFF, 0xFF, 0xFF,
0x00, 0x08, 0x00, 0x08,
},
#define TK_MAC_CURSOR_eyedrop 5
[TK_MAC_CURSOR_eyedrop] = {
0x00, 0x0E, 0x00, 0x1F, 0x00, 0x1F, 0x00, 0xFF, 0x00, 0x7E, 0x00, 0xB8, 0x01, 0x18, 0x02, 0x28,
0x04, 0x40, 0x08, 0x80, 0x11, 0x00, 0x22, 0x00, 0x44, 0x00, 0x48, 0x00, 0xB0, 0x00, 0x40, 0x00,
0x00, 0x0E, 0x00, 0x1F, 0x00, 0x1F, 0x00, 0xFF, 0x00, 0x7E, 0x00, 0xF8, 0x01, 0xF8, 0x03, 0xE8,
0x07, 0xC0, 0x0F, 0x80, 0x1F, 0x00, 0x3E, 0x00, 0x7C, 0x00, 0x78, 0x00, 0xF0, 0x00, 0x40, 0x00,
0x00, 0x0F, 0x00, 0x00,
},
#define TK_MAC_CURSOR_eyedrop_full 6
[TK_MAC_CURSOR_eyedrop_full] = {
0x00, 0x0E, 0x00, 0x1F, 0x00, 0x1F, 0x00, 0xFF, 0x00, 0x7E, 0x00, 0xB8, 0x01, 0x18, 0x03, 0x28,
0x07, 0xC0, 0x0F, 0x80, 0x1F, 0x00, 0x3E, 0x00, 0x7C, 0x00, 0x78, 0x00, 0xF0, 0x00, 0x40, 0x00,
0x00, 0x0E, 0x00, 0x1F, 0x00, 0x1F, 0x00, 0xFF, 0x00, 0x7E, 0x00, 0xF8, 0x01, 0xF8, 0x03, 0xE8,
0x07, 0xC0, 0x0F, 0x80, 0x1F, 0x00, 0x3E, 0x00, 0x7C, 0x00, 0x78, 0x00, 0xF0, 0x00, 0x40, 0x00,
0x00, 0x0F, 0x00, 0x00,
},
#define TK_MAC_CURSOR_zoom_in 7
[TK_MAC_CURSOR_zoom_in] = {
0x07, 0x80, 0x18, 0x60, 0x27, 0x90, 0x58, 0x68, 0x53, 0x28, 0xA3, 0x14, 0xAF, 0xD4, 0xAF, 0xD4,
0xA3, 0x14, 0x53, 0x28, 0x58, 0x68, 0x27, 0x98, 0x18, 0x7C, 0x07, 0x8E, 0x00, 0x07, 0x00, 0x03,
0x07, 0x80, 0x1F, 0xE0, 0x3F, 0xF0, 0x78, 0x78, 0x73, 0x38, 0xE3, 0x1C, 0xEF, 0xDC, 0xEF, 0xDC,
0xE3, 0x1C, 0x73, 0x38, 0x78, 0x78, 0x3F, 0xF8, 0x1F, 0xFC, 0x07, 0x8E, 0x00, 0x07, 0x00, 0x03,
0x00, 0x07, 0x00, 0x07,
},
#define TK_MAC_CURSOR_zoom_out 8
[TK_MAC_CURSOR_zoom_out] = {
0x07, 0x80, 0x18, 0x60, 0x27, 0x90, 0x58, 0x68, 0x50, 0x28, 0xA0, 0x14, 0xAF, 0xD4, 0xAF, 0xD4,
0xA0, 0x14, 0x50, 0x28, 0x58, 0x68, 0x27, 0x98, 0x18, 0x7C, 0x07, 0x8E, 0x00, 0x07, 0x00, 0x03,
0x07, 0x80, 0x1F, 0xE0, 0x3F, 0xF0, 0x78, 0x78, 0x70, 0x38, 0xE0, 0x1C, 0xEF, 0xDC, 0xEF, 0xDC,
0xE0, 0x1C, 0x70, 0x38, 0x78, 0x78, 0x3F, 0xF8, 0x1F, 0xFC, 0x07, 0x8E, 0x00, 0x07, 0x00, 0x03,
0x00, 0x07, 0x00, 0x07,
},
};

166
macosx/tkMacOSXDebug.c Normal file
View File

@@ -0,0 +1,166 @@
/*
* tkMacOSXDebug.c --
*
* Implementation of Macintosh specific functions for debugging MacOS
* events, regions, etc...
*
* Copyright 2001-2009, Apple Inc.
* Copyright (c) 2006-2009 Daniel A. Steffen <das@users.sourceforge.net>
*
* See the file "license.terms" for information on usage and redistribution
* of this file, and for a DISCLAIMER OF ALL WARRANTIES.
*/
#include "tkMacOSXPrivate.h"
#include "tkMacOSXDebug.h"
#ifdef TK_MAC_DEBUG
#include <mach-o/dyld.h>
#include <mach-o/nlist.h>
/*
*----------------------------------------------------------------------
*
* TkMacOSXGetNamedDebugSymbol --
*
* Dynamically acquire address of a named symbol from a loaded dynamic
* library, so that we can use API that may not be available on all OS
* versions. For debugging purposes, if we cannot find the symbol with
* the usual dynamic library APIs, we manually walk the symbol table of
* the loaded library. This allows access to unexported symbols such as
* private_extern internal debugging functions. If module is NULL or the
* empty string, search all loaded libraries (could be very expensive and
* should be avoided).
*
* THIS FUCTION IS ONLY TO BE USED FOR DEBUGGING PURPOSES, IT MAY BREAK
* UNEXPECTEDLY IN THE FUTURE!
*
* Results:
* Address of given symbol or NULL if unavailable.
*
* Side effects:
* None.
*
*----------------------------------------------------------------------
*/
MODULE_SCOPE void *
TkMacOSXGetNamedDebugSymbol(
const char *module,
const char *symbol)
{
void *addr = TkMacOSXGetNamedSymbol(module, symbol);
#ifndef __LP64__
if (!addr) {
const struct mach_header *mh = NULL;
uint32_t i, n = _dyld_image_count();
size_t module_len = 0;
if (module && *module) {
module_len = strlen(module);
}
for (i = 0; i < n; i++) {
if (module && *module) {
/* Find image with given module name */
char *name;
const char *path = _dyld_get_image_name(i);
if (!path) {
continue;
}
name = strrchr(path, '/') + 1;
if (strncmp(name, module, module_len) != 0) {
continue;
}
}
mh = _dyld_get_image_header(i);
if (mh) {
struct load_command *lc;
struct symtab_command *st = NULL;
struct segment_command *sg = NULL;
uint32_t j, m, nsect = 0, txtsectx = 0;
lc = (struct load_command*)((const char*) mh +
sizeof(struct mach_header));
m = mh->ncmds;
for (j = 0; j < m; j++) {
/* Find symbol table and index of __text section */
if (lc->cmd == LC_SEGMENT) {
/* Find last segment before symbol table */
sg = (struct segment_command*) lc;
if (!txtsectx) {
/* Count total sections until (__TEXT, __text) */
uint32_t k, ns = sg->nsects;
if (strcmp(sg->segname, SEG_TEXT) == 0) {
struct section *s = (struct section *)(
(char *)sg +
sizeof(struct segment_command));
for(k = 0; k < ns; k++) {
if (strcmp(s->sectname, SECT_TEXT) == 0) {
txtsectx = nsect+k+1;
break;
}
s++;
}
}
nsect += ns;
}
} else if (!st && lc->cmd == LC_SYMTAB) {
st = (struct symtab_command *) lc;
break;
}
lc = (struct load_command *)((char *) lc + lc->cmdsize);
}
if (st && sg && txtsectx) {
intptr_t base, slide = _dyld_get_image_vmaddr_slide(i);
char *strings;
struct nlist *sym;
uint32_t strsize = st->strsize;
int32_t strx;
/*
* Offset file positions by difference to actual position
* in memory of last segment before symbol table:
*/
base = (intptr_t) sg->vmaddr + slide - sg->fileoff;
strings = (char *) (base + st->stroff);
sym = (struct nlist *) (base + st->symoff);
m = st->nsyms;
for (j = 0; j < m; j++) {
/* Find symbol with given name in __text section */
strx = sym->n_un.n_strx;
if ((sym->n_type & N_TYPE) == N_SECT &&
sym->n_sect == txtsectx &&
strx > 0 && (uint32_t) strx < strsize &&
strcmp(strings + strx, symbol) == 0) {
addr = (char*) sym->n_value + slide;
break;
}
sym++;
}
}
}
if (module && *module) {
/* If given a module name, only search corresponding image */
break;
}
}
}
#endif /* __LP64__ */
return addr;
}
#endif /* TK_MAC_DEBUG */
/*
* Local Variables:
* mode: objc
* c-basic-offset: 4
* fill-column: 79
* coding: utf-8
* End:
*/

34
macosx/tkMacOSXDebug.h Normal file
View File

@@ -0,0 +1,34 @@
/*
* tkMacOSXDebug.h --
*
* Declarations of Macintosh specific functions for debugging MacOS events,
* regions, etc...
*
* Copyright 2001-2009, Apple Inc.
* Copyright (c) 2005-2009 Daniel A. Steffen <das@users.sourceforge.net>
*
* See the file "license.terms" for information on usage and redistribution
* of this file, and for a DISCLAIMER OF ALL WARRANTIES.
*/
#ifndef _TKMACDEBUG
#define _TKMACDEBUG
#ifndef _TKMACINT
#include "tkMacOSXInt.h"
#endif
#ifdef TK_MAC_DEBUG
MODULE_SCOPE void* TkMacOSXGetNamedDebugSymbol(const char* module, const char* symbol);
/* Macro to abstract common use of TkMacOSXGetNamedDebugSymbol to initialize named symbols */
#define TkMacOSXInitNamedDebugSymbol(module, ret, symbol, ...) \
static ret (* symbol)(__VA_ARGS__) = (void*)(-1L); \
if (symbol == (void*)(-1L)) { \
symbol = TkMacOSXGetNamedDebugSymbol(STRINGIFY(module), STRINGIFY(_##symbol));\
}
#endif /* TK_MAC_DEBUG */
#endif

566
macosx/tkMacOSXDefault.h Normal file
View File

@@ -0,0 +1,566 @@
/*
* 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-2009, Apple Inc.
* Copyright (c) 2006-2009 Daniel A. Steffen <das@users.sourceforge.net>
*
* See the file "license.terms" for information on usage and redistribution
* of this file, and for a DISCLAIMER OF ALL WARRANTIES.
*/
#ifndef _TKMACDEFAULT
#define _TKMACDEFAULT
#ifndef TK_MAC_BUTTON_USE_COMPATIBILITY_METRICS
#define TK_MAC_BUTTON_USE_COMPATIBILITY_METRICS 1
#endif
/*
* The definitions below provide symbolic names for the default colors.
* NORMAL_BG - Normal background color.
* ACTIVE_BG - Background color when widget is active.
* SELECT_BG - Background color for selected text.
* SELECT_FG - Foreground color for selected text.
* TROUGH - Background color for troughs in scales and scrollbars.
* INDICATOR - Color for indicator when button is selected.
* DISABLED - Foreground color when widget is disabled.
*/
#define BLACK "Black"
#define WHITE "White"
#define NORMAL_BG "systemWindowBody"
#define ACTIVE_BG "systemButtonFacePressed"
#define ACTIVE_FG "systemPushButtonPressedText"
#define SELECT_BG "systemHighlight"
#define SELECT_FG None
#define INACTIVE_SELECT_BG "systemHighlightSecondary"
#define TROUGH "#c3c3c3"
#define INDICATOR "#b03060"
#define DISABLED "#a3a3a3"
/*
* Defaults for labels, buttons, checkbuttons, and radiobuttons:
*/
#define DEF_BUTTON_ANCHOR "center"
#define DEF_BUTTON_ACTIVE_BG_COLOR ACTIVE_BG
#define DEF_BUTTON_ACTIVE_BG_MONO BLACK
#define DEF_BUTTON_ACTIVE_FG_COLOR ACTIVE_FG
#define DEF_CHKRAD_ACTIVE_FG_COLOR DEF_BUTTON_ACTIVE_FG_COLOR
#define DEF_BUTTON_ACTIVE_FG_MONO WHITE
/* #define DEF_BUTTON_BG_COLOR "systemButtonFace"*/
#define DEF_BUTTON_BG_COLOR WHITE
#define DEF_BUTTON_BG_MONO WHITE
#define DEF_BUTTON_BITMAP ""
#define DEF_BUTTON_BORDER_WIDTH "2"
#define DEF_BUTTON_CURSOR ""
#define DEF_BUTTON_COMMAND ""
#define DEF_BUTTON_COMPOUND "none"
#define DEF_BUTTON_DEFAULT "disabled"
#define DEF_BUTTON_DISABLED_FG_COLOR DISABLED
#define DEF_BUTTON_DISABLED_FG_MONO ""
#define DEF_BUTTON_FG "systemButtonText"
#define DEF_CHKRAD_FG DEF_BUTTON_FG
#define DEF_BUTTON_FONT "TkDefaultFont"
#define DEF_BUTTON_HEIGHT "0"
#define DEF_BUTTON_HIGHLIGHT_BG_COLOR DEF_BUTTON_BG_COLOR
#define DEF_BUTTON_HIGHLIGHT_BG_MONO DEF_BUTTON_BG_MONO
#define DEF_BUTTON_HIGHLIGHT "systemButtonFrame"
#define DEF_LABEL_HIGHLIGHT_WIDTH "0"
#if TK_MAC_BUTTON_USE_COMPATIBILITY_METRICS
#define DEF_BUTTON_HIGHLIGHT_WIDTH "4"
#define DEF_BUTTON_HIGHLIGHT_WIDTH_NOCM "1"
#else
#define DEF_BUTTON_HIGHLIGHT_WIDTH "1"
#endif
#define DEF_BUTTON_IMAGE ((char *) NULL)
#define DEF_BUTTON_INDICATOR "1"
#define DEF_BUTTON_JUSTIFY "center"
#define DEF_BUTTON_OFF_VALUE "0"
#define DEF_BUTTON_ON_VALUE "1"
#define DEF_BUTTON_TRISTATE_VALUE ""
#define DEF_BUTTON_OVER_RELIEF ""
#if TK_MAC_BUTTON_USE_COMPATIBILITY_METRICS
#define DEF_BUTTON_PADX "12"
#define DEF_BUTTON_PADX_NOCM "1"
#else
#define DEF_BUTTON_PADX "1"
#endif
#define DEF_LABCHKRAD_PADX "1"
#if TK_MAC_BUTTON_USE_COMPATIBILITY_METRICS
#define DEF_BUTTON_PADY "3"
#define DEF_BUTTON_PADY_NOCM "1"
#else
#define DEF_BUTTON_PADY "1"
#endif
#define DEF_LABCHKRAD_PADY "1"
#define DEF_BUTTON_RELIEF "flat"
#define DEF_LABCHKRAD_RELIEF "flat"
#define DEF_BUTTON_REPEAT_DELAY "0"
#define DEF_BUTTON_REPEAT_INTERVAL "0"
#define DEF_BUTTON_SELECT_COLOR INDICATOR
#define DEF_BUTTON_SELECT_MONO BLACK
#define DEF_BUTTON_SELECT_IMAGE ((char *) NULL)
#define DEF_BUTTON_STATE "normal"
#define DEF_LABEL_TAKE_FOCUS "0"
#define DEF_BUTTON_TAKE_FOCUS ((char *) NULL)
#define DEF_BUTTON_TEXT ""
#define DEF_BUTTON_TEXT_VARIABLE ""
#define DEF_BUTTON_UNDERLINE "-1"
#define DEF_BUTTON_VALUE ""
#define DEF_BUTTON_WIDTH "0"
#define DEF_BUTTON_WRAP_LENGTH "0"
#define DEF_RADIOBUTTON_VARIABLE "selectedButton"
#define DEF_CHECKBUTTON_VARIABLE ""
/*
* Defaults for canvases:
*/
#define DEF_CANVAS_BG_COLOR NORMAL_BG
#define DEF_CANVAS_BG_MONO WHITE
#define DEF_CANVAS_BORDER_WIDTH "0"
#define DEF_CANVAS_CLOSE_ENOUGH "1"
#define DEF_CANVAS_CONFINE "1"
#define DEF_CANVAS_CURSOR ""
#define DEF_CANVAS_HEIGHT "7c"
#define DEF_CANVAS_HIGHLIGHT_BG NORMAL_BG
#define DEF_CANVAS_HIGHLIGHT BLACK
#define DEF_CANVAS_HIGHLIGHT_WIDTH "3"
#define DEF_CANVAS_INSERT_BG BLACK
#define DEF_CANVAS_INSERT_BD_COLOR "0"
#define DEF_CANVAS_INSERT_BD_MONO "0"
#define DEF_CANVAS_INSERT_OFF_TIME "300"
#define DEF_CANVAS_INSERT_ON_TIME "600"
#define DEF_CANVAS_INSERT_WIDTH "2"
#define DEF_CANVAS_RELIEF "flat"
#define DEF_CANVAS_SCROLL_REGION ""
#define DEF_CANVAS_SELECT_COLOR SELECT_BG
#define DEF_CANVAS_SELECT_MONO BLACK
#define DEF_CANVAS_SELECT_BD_COLOR "1"
#define DEF_CANVAS_SELECT_BD_MONO "0"
#define DEF_CANVAS_SELECT_FG_COLOR SELECT_FG
#define DEF_CANVAS_SELECT_FG_MONO WHITE
#define DEF_CANVAS_TAKE_FOCUS ((char *) NULL)
#define DEF_CANVAS_WIDTH "10c"
#define DEF_CANVAS_X_SCROLL_CMD ""
#define DEF_CANVAS_X_SCROLL_INCREMENT "0"
#define DEF_CANVAS_Y_SCROLL_CMD ""
#define DEF_CANVAS_Y_SCROLL_INCREMENT "0"
/*
* Defaults for entries:
*/
/*
* I test the following two values in TkpDrawEntryBorderAndFocus
* to determine whether to use the native entry widget. So if
* you change the defaults to be different from these, then you
* won't get the native widget by default.
*/
#define MAC_OSX_FOCUS_WIDTH 3
#define MAC_OSX_ENTRY_BORDER 2
#define MAC_OSX_ENTRY_RELIEF TK_RELIEF_SUNKEN
#define MAC_OSX_ENTRY_SELECT_RELIEF TK_RELIEF_FLAT
#define DEF_ENTRY_BG_COLOR NORMAL_BG
#define DEF_ENTRY_BG_MONO WHITE
#define DEF_ENTRY_BORDER_WIDTH "2"
#define DEF_ENTRY_CURSOR "xterm"
#define DEF_ENTRY_DISABLED_BG_COLOR NORMAL_BG
#define DEF_ENTRY_DISABLED_BG_MONO WHITE
#define DEF_ENTRY_DISABLED_FG DISABLED
#define DEF_ENTRY_EXPORT_SELECTION "1"
#define DEF_ENTRY_FONT "TkTextFont"
#define DEF_ENTRY_FG BLACK
#define DEF_ENTRY_HIGHLIGHT_BG NORMAL_BG
#define DEF_ENTRY_HIGHLIGHT BLACK
/* #define DEF_ENTRY_HIGHLIGHT_WIDTH "3" */
#define DEF_ENTRY_HIGHLIGHT_WIDTH "3"
#define DEF_ENTRY_INSERT_BG BLACK
#define DEF_ENTRY_INSERT_BD_COLOR "0"
#define DEF_ENTRY_INSERT_BD_MONO "0"
#define DEF_ENTRY_INSERT_OFF_TIME "300"
#define DEF_ENTRY_INSERT_ON_TIME "600"
/* #define DEF_ENTRY_INSERT_WIDTH "2" */
#define DEF_ENTRY_INSERT_WIDTH "1"
#define DEF_ENTRY_JUSTIFY "left"
#define DEF_ENTRY_READONLY_BG_COLOR NORMAL_BG
#define DEF_ENTRY_READONLY_BG_MONO WHITE
#define DEF_ENTRY_RELIEF "sunken"
/* #define DEF_ENTRY_RELIEF "solid" */
#define DEF_ENTRY_SCROLL_COMMAND ""
#define DEF_ENTRY_SELECT_COLOR SELECT_BG
#define DEF_ENTRY_SELECT_MONO BLACK
#define DEF_ENTRY_SELECT_BD_COLOR "1"
#define DEF_ENTRY_SELECT_BD_MONO "0"
#define DEF_ENTRY_SELECT_FG_COLOR SELECT_FG
#define DEF_ENTRY_SELECT_FG_MONO WHITE
#define DEF_ENTRY_SHOW ((char *) NULL)
#define DEF_ENTRY_STATE "normal"
#define DEF_ENTRY_TAKE_FOCUS ((char *) NULL)
#define DEF_ENTRY_TEXT_VARIABLE ""
#define DEF_ENTRY_WIDTH "20"
/*
* Defaults for frames:
*/
#define DEF_FRAME_BG_COLOR NORMAL_BG
#define DEF_FRAME_BG_MONO WHITE
#define DEF_FRAME_BORDER_WIDTH "0"
#define DEF_FRAME_CLASS "Frame"
#define DEF_FRAME_COLORMAP ""
#define DEF_FRAME_CONTAINER "0"
#define DEF_FRAME_CURSOR ""
#define DEF_FRAME_HEIGHT "0"
#define DEF_FRAME_HIGHLIGHT_BG NORMAL_BG
#define DEF_FRAME_HIGHLIGHT BLACK
#define DEF_FRAME_HIGHLIGHT_WIDTH "0"
#define DEF_FRAME_PADX "0"
#define DEF_FRAME_PADY "0"
#define DEF_FRAME_RELIEF "flat"
#define DEF_FRAME_TAKE_FOCUS "0"
#define DEF_FRAME_VISUAL ""
#define DEF_FRAME_WIDTH "0"
/*
* Defaults for labelframes:
*/
#define DEF_LABELFRAME_BORDER_WIDTH "2"
#define DEF_LABELFRAME_CLASS "Labelframe"
#define DEF_LABELFRAME_RELIEF "groove"
#define DEF_LABELFRAME_FG "systemButtonText"
#define DEF_LABELFRAME_FONT "TkDefaultFont"
#define DEF_LABELFRAME_TEXT ""
#define DEF_LABELFRAME_LABELANCHOR "nw"
/*
* Defaults for listboxes:
*/
#define DEF_LISTBOX_ACTIVE_STYLE "dotbox"
#define DEF_LISTBOX_BG_COLOR WHITE
#define DEF_LISTBOX_BG_MONO WHITE
#define DEF_LISTBOX_BORDER_WIDTH "1"
#define DEF_LISTBOX_CURSOR ""
#define DEF_LISTBOX_DISABLED_FG DISABLED
#define DEF_LISTBOX_EXPORT_SELECTION "1"
#define DEF_LISTBOX_FONT "TkTextFont"
#define DEF_LISTBOX_FG BLACK
#define DEF_LISTBOX_HEIGHT "10"
#define DEF_LISTBOX_HIGHLIGHT_BG NORMAL_BG
#define DEF_LISTBOX_HIGHLIGHT BLACK
#define DEF_LISTBOX_HIGHLIGHT_WIDTH "0"
#define DEF_LISTBOX_RELIEF "solid"
#define DEF_LISTBOX_SCROLL_COMMAND ""
#define DEF_LISTBOX_LIST_VARIABLE ""
#define DEF_LISTBOX_SELECT_COLOR SELECT_BG
#define DEF_LISTBOX_SELECT_MONO BLACK
#define DEF_LISTBOX_SELECT_BD "0"
#define DEF_LISTBOX_SELECT_FG_COLOR SELECT_FG
#define DEF_LISTBOX_SELECT_FG_MONO WHITE
#define DEF_LISTBOX_SELECT_MODE "browse"
#define DEF_LISTBOX_SET_GRID "0"
#define DEF_LISTBOX_STATE "normal"
#define DEF_LISTBOX_TAKE_FOCUS ((char *) NULL)
#define DEF_LISTBOX_WIDTH "20"
/*
* Defaults for individual entries of menus:
*/
#define DEF_MENU_ENTRY_ACTIVE_BG ((char *) NULL)
#define DEF_MENU_ENTRY_ACTIVE_FG ((char *) NULL)
#define DEF_MENU_ENTRY_ACCELERATOR ((char *) NULL)
#define DEF_MENU_ENTRY_BG ((char *) NULL)
#define DEF_MENU_ENTRY_BITMAP None
#define DEF_MENU_ENTRY_COLUMN_BREAK "0"
#define DEF_MENU_ENTRY_COMMAND ((char *) NULL)
#define DEF_MENU_ENTRY_COMPOUND "none"
#define DEF_MENU_ENTRY_FG ((char *) NULL)
#define DEF_MENU_ENTRY_FONT ((char *) NULL)
#define DEF_MENU_ENTRY_HIDE_MARGIN "0"
#define DEF_MENU_ENTRY_IMAGE ((char *) NULL)
#define DEF_MENU_ENTRY_INDICATOR "1"
#define DEF_MENU_ENTRY_LABEL ((char *) NULL)
#define DEF_MENU_ENTRY_MENU ((char *) NULL)
#define DEF_MENU_ENTRY_OFF_VALUE "0"
#define DEF_MENU_ENTRY_ON_VALUE "1"
#define DEF_MENU_ENTRY_SELECT_IMAGE ((char *) NULL)
#define DEF_MENU_ENTRY_STATE "normal"
#define DEF_MENU_ENTRY_VALUE ((char *) NULL)
#define DEF_MENU_ENTRY_CHECK_VARIABLE ((char *) NULL)
#define DEF_MENU_ENTRY_RADIO_VARIABLE "selectedButton"
#define DEF_MENU_ENTRY_SELECT ((char *) NULL)
#define DEF_MENU_ENTRY_UNDERLINE "-1"
/*
* Defaults for menus overall:
*/
#define DEF_MENU_ACTIVE_BG_COLOR "systemMenuActive"
#define DEF_MENU_ACTIVE_BG_MONO BLACK
#define DEF_MENU_ACTIVE_BORDER_WIDTH "0"
#define DEF_MENU_ACTIVE_FG_COLOR "systemMenuActiveText"
#define DEF_MENU_ACTIVE_FG_MONO WHITE
#define DEF_MENU_BG_COLOR "systemMenu"
#define DEF_MENU_BG_MONO WHITE
#define DEF_MENU_BORDER_WIDTH "0"
#define DEF_MENU_CURSOR "arrow"
#define DEF_MENU_DISABLED_FG_COLOR "systemMenuDisabled"
#define DEF_MENU_DISABLED_FG_MONO ""
#define DEF_MENU_FONT "menu" /* special: see tkMacOSXMenu.c */
#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:
*/
#define DEF_MENUBUTTON_ANCHOR "center"
#define DEF_MENUBUTTON_ACTIVE_BG_COLOR ACTIVE_BG
#define DEF_MENUBUTTON_ACTIVE_BG_MONO BLACK
#define DEF_MENUBUTTON_ACTIVE_FG_COLOR ACTIVE_FG
#define DEF_MENUBUTTON_ACTIVE_FG_MONO WHITE
#define DEF_MENUBUTTON_BG_COLOR NORMAL_BG
#define DEF_MENUBUTTON_BG_MONO WHITE
#define DEF_MENUBUTTON_BITMAP ""
#define DEF_MENUBUTTON_BORDER_WIDTH "2"
#define DEF_MENUBUTTON_CURSOR ""
#define DEF_MENUBUTTON_DIRECTION "below"
#define DEF_MENUBUTTON_DISABLED_FG_COLOR DISABLED
#define DEF_MENUBUTTON_DISABLED_FG_MONO ""
#define DEF_MENUBUTTON_FONT "TkDefaultFont"
#define DEF_MENUBUTTON_FG BLACK
#define DEF_MENUBUTTON_HEIGHT "0"
#define DEF_MENUBUTTON_HIGHLIGHT_BG_COLOR DEF_MENUBUTTON_BG_COLOR
#define DEF_MENUBUTTON_HIGHLIGHT_BG_MONO DEF_MENUBUTTON_BG_MONO
#define DEF_MENUBUTTON_HIGHLIGHT BLACK
#define DEF_MENUBUTTON_HIGHLIGHT_WIDTH "0"
#define DEF_MENUBUTTON_IMAGE ((char *) NULL)
#define DEF_MENUBUTTON_INDICATOR "1"
#define DEF_MENUBUTTON_JUSTIFY "left"
#define DEF_MENUBUTTON_MENU ""
#define DEF_MENUBUTTON_PADX "4"
#define DEF_MENUBUTTON_PADY "3"
#define DEF_MENUBUTTON_RELIEF "flat"
#define DEF_MENUBUTTON_STATE "normal"
#define DEF_MENUBUTTON_TAKE_FOCUS "0"
#define DEF_MENUBUTTON_TEXT ""
#define DEF_MENUBUTTON_TEXT_VARIABLE ""
#define DEF_MENUBUTTON_UNDERLINE "-1"
#define DEF_MENUBUTTON_WIDTH "0"
#define DEF_MENUBUTTON_WRAP_LENGTH "0"
/*
* Defaults for messages:
*/
#define DEF_MESSAGE_ANCHOR "center"
#define DEF_MESSAGE_ASPECT "150"
#define DEF_MESSAGE_BG_COLOR NORMAL_BG
#define DEF_MESSAGE_BG_MONO WHITE
#define DEF_MESSAGE_BORDER_WIDTH "1"
#define DEF_MESSAGE_CURSOR ""
#define DEF_MESSAGE_FG BLACK
#define DEF_MESSAGE_FONT "TkDefaultFont"
#define DEF_MESSAGE_HIGHLIGHT_BG NORMAL_BG
#define DEF_MESSAGE_HIGHLIGHT BLACK
#define DEF_MESSAGE_HIGHLIGHT_WIDTH "0"
#define DEF_MESSAGE_JUSTIFY "left"
#define DEF_MESSAGE_PADX "-1"
#define DEF_MESSAGE_PADY "-1"
#define DEF_MESSAGE_RELIEF "flat"
#define DEF_MESSAGE_TAKE_FOCUS "0"
#define DEF_MESSAGE_TEXT ""
#define DEF_MESSAGE_TEXT_VARIABLE ""
#define DEF_MESSAGE_WIDTH "0"
/*
* Defaults for panedwindows
*/
#define DEF_PANEDWINDOW_BG_COLOR NORMAL_BG
#define DEF_PANEDWINDOW_BG_MONO WHITE
#define DEF_PANEDWINDOW_BORDERWIDTH "1"
#define DEF_PANEDWINDOW_CURSOR ""
#define DEF_PANEDWINDOW_HANDLEPAD "8"
#define DEF_PANEDWINDOW_HANDLESIZE "8"
#define DEF_PANEDWINDOW_HEIGHT ""
#define DEF_PANEDWINDOW_OPAQUERESIZE "1"
#define DEF_PANEDWINDOW_ORIENT "horizontal"
#define DEF_PANEDWINDOW_RELIEF "flat"
#define DEF_PANEDWINDOW_SASHCURSOR ""
#define DEF_PANEDWINDOW_SASHPAD "0"
#define DEF_PANEDWINDOW_SASHRELIEF "flat"
#define DEF_PANEDWINDOW_SASHWIDTH "3"
#define DEF_PANEDWINDOW_SHOWHANDLE "0"
#define DEF_PANEDWINDOW_WIDTH ""
/*
* Defaults for panedwindow panes
*/
#define DEF_PANEDWINDOW_PANE_AFTER ""
#define DEF_PANEDWINDOW_PANE_BEFORE ""
#define DEF_PANEDWINDOW_PANE_HEIGHT ""
#define DEF_PANEDWINDOW_PANE_MINSIZE "0"
#define DEF_PANEDWINDOW_PANE_PADX "0"
#define DEF_PANEDWINDOW_PANE_PADY "0"
#define DEF_PANEDWINDOW_PANE_STICKY "nsew"
#define DEF_PANEDWINDOW_PANE_WIDTH ""
#define DEF_PANEDWINDOW_PANE_HIDE "0"
#define DEF_PANEDWINDOW_PANE_STRETCH "last"
/*
* Defaults for scales:
*/
#define DEF_SCALE_ACTIVE_BG_COLOR ACTIVE_BG
#define DEF_SCALE_ACTIVE_BG_MONO BLACK
#define DEF_SCALE_BG_COLOR NORMAL_BG
#define DEF_SCALE_BG_MONO WHITE
#define DEF_SCALE_BIG_INCREMENT "0"
#define DEF_SCALE_BORDER_WIDTH "1"
#define DEF_SCALE_COMMAND ""
#define DEF_SCALE_CURSOR ""
#define DEF_SCALE_DIGITS "0"
#define DEF_SCALE_FONT "TkDefaultFont"
#define DEF_SCALE_FG_COLOR BLACK
#define DEF_SCALE_FG_MONO BLACK
#define DEF_SCALE_FROM "0"
#define DEF_SCALE_HIGHLIGHT_BG_COLOR DEF_SCALE_BG_COLOR
#define DEF_SCALE_HIGHLIGHT_BG_MONO DEF_SCALE_BG_MONO
#define DEF_SCALE_HIGHLIGHT BLACK
#define DEF_SCALE_HIGHLIGHT_WIDTH "0"
#define DEF_SCALE_LABEL ""
#define DEF_SCALE_LENGTH "100"
#define DEF_SCALE_ORIENT "vertical"
#define DEF_SCALE_RELIEF "flat"
#define DEF_SCALE_REPEAT_DELAY "300"
#define DEF_SCALE_REPEAT_INTERVAL "100"
#define DEF_SCALE_RESOLUTION "1"
#define DEF_SCALE_TROUGH_COLOR TROUGH
#define DEF_SCALE_TROUGH_MONO WHITE
#define DEF_SCALE_SHOW_VALUE "1"
#define DEF_SCALE_SLIDER_LENGTH "30"
#define DEF_SCALE_SLIDER_RELIEF "raised"
#define DEF_SCALE_STATE "normal"
#define DEF_SCALE_TAKE_FOCUS ((char *) NULL)
#define DEF_SCALE_TICK_INTERVAL "0"
#define DEF_SCALE_TO "100"
#define DEF_SCALE_VARIABLE ""
#define DEF_SCALE_WIDTH "15"
/*
* Defaults for scrollbars:
*/
#define DEF_SCROLLBAR_ACTIVE_BG_COLOR ACTIVE_BG
#define DEF_SCROLLBAR_ACTIVE_BG_MONO BLACK
#define DEF_SCROLLBAR_ACTIVE_RELIEF "raised"
#define DEF_SCROLLBAR_BG_COLOR NORMAL_BG
#define DEF_SCROLLBAR_BG_MONO WHITE
#define DEF_SCROLLBAR_BORDER_WIDTH "0"
#define DEF_SCROLLBAR_COMMAND ""
#define DEF_SCROLLBAR_CURSOR ""
#define DEF_SCROLLBAR_EL_BORDER_WIDTH "-1"
#define DEF_SCROLLBAR_HIGHLIGHT_BG NORMAL_BG
#define DEF_SCROLLBAR_HIGHLIGHT BLACK
#define DEF_SCROLLBAR_HIGHLIGHT_WIDTH "0"
#define DEF_SCROLLBAR_JUMP "0"
#define DEF_SCROLLBAR_ORIENT "vertical"
#define DEF_SCROLLBAR_RELIEF "flat"
#define DEF_SCROLLBAR_REPEAT_DELAY "300"
#define DEF_SCROLLBAR_REPEAT_INTERVAL "100"
#define DEF_SCROLLBAR_TAKE_FOCUS ((char *) NULL)
#define DEF_SCROLLBAR_TROUGH_COLOR TROUGH
#define DEF_SCROLLBAR_TROUGH_MONO WHITE
#define DEF_SCROLLBAR_WIDTH "15"
/*
* Defaults for texts:
*/
#define DEF_TEXT_AUTO_SEPARATORS "1"
#define DEF_TEXT_BG_COLOR NORMAL_BG
#define DEF_TEXT_BG_MONO WHITE
#define DEF_TEXT_BLOCK_CURSOR "0"
#define DEF_TEXT_BORDER_WIDTH "0"
#define DEF_TEXT_CURSOR "xterm"
#define DEF_TEXT_FG BLACK
#define DEF_TEXT_EXPORT_SELECTION "1"
#define DEF_TEXT_FONT "TkFixedFont"
#define DEF_TEXT_HEIGHT "24"
#define DEF_TEXT_HIGHLIGHT_BG NORMAL_BG
#define DEF_TEXT_HIGHLIGHT BLACK
#define DEF_TEXT_HIGHLIGHT_WIDTH "3"
#define DEF_TEXT_INSERT_BG BLACK
#define DEF_TEXT_INSERT_BD_COLOR "0"
#define DEF_TEXT_INSERT_BD_MONO "0"
#define DEF_TEXT_INSERT_OFF_TIME "300"
#define DEF_TEXT_INSERT_ON_TIME "600"
#define DEF_TEXT_INSERT_WIDTH "1"
#define DEF_TEXT_MAX_UNDO "0"
#define DEF_TEXT_PADX "1"
#define DEF_TEXT_PADY "1"
#define DEF_TEXT_RELIEF "flat"
#define DEF_TEXT_INACTIVE_SELECT_COLOR INACTIVE_SELECT_BG
#define DEF_TEXT_SELECT_COLOR SELECT_BG
#define DEF_TEXT_SELECT_MONO BLACK
#define DEF_TEXT_SELECT_BD_COLOR "1"
#define DEF_TEXT_SELECT_BD_MONO "0"
#define DEF_TEXT_SELECT_FG_COLOR SELECT_FG
#define DEF_TEXT_SELECT_FG_MONO WHITE
#define DEF_TEXT_SELECT_RELIEF "flat"
#define DEF_TEXT_SET_GRID "0"
#define DEF_TEXT_SPACING1 "0"
#define DEF_TEXT_SPACING2 "0"
#define DEF_TEXT_SPACING3 "0"
#define DEF_TEXT_STATE "normal"
#define DEF_TEXT_TABS ""
#define DEF_TEXT_TABSTYLE "tabular"
#define DEF_TEXT_TAKE_FOCUS ((char *) NULL)
#define DEF_TEXT_UNDO "0"
#define DEF_TEXT_WIDTH "80"
#define DEF_TEXT_WRAP "char"
#define DEF_TEXT_XSCROLL_COMMAND ""
#define DEF_TEXT_YSCROLL_COMMAND ""
/*
* Defaults for canvas text:
*/
#define DEF_CANVTEXT_FONT "TkDefaultFont"
/*
* Defaults for toplevels (most of the defaults for frames also apply
* to toplevels):
*/
#define DEF_TOPLEVEL_CLASS "Toplevel"
#define DEF_TOPLEVEL_MENU ""
#define DEF_TOPLEVEL_SCREEN ""
#define DEF_TOPLEVEL_USE ""
#endif /* _TKMACDEFAULT */

1131
macosx/tkMacOSXDialog.c Normal file

File diff suppressed because it is too large Load Diff

2003
macosx/tkMacOSXDraw.c Normal file

File diff suppressed because it is too large Load Diff

1128
macosx/tkMacOSXEmbed.c Normal file

File diff suppressed because it is too large Load Diff

267
macosx/tkMacOSXEntry.c Normal file
View File

@@ -0,0 +1,267 @@
/*
* tkMacOSXEntry.c --
*
* This file implements the native aqua entry widget.
*
* Copyright 2001, Apple Computer, Inc.
* Copyright (c) 2006-2009 Daniel A. Steffen <das@users.sourceforge.net>
* Copyright 2008-2009, Apple Inc.
*
* See the file "license.terms" for information on usage and redistribution
* of this file, and for a DISCLAIMER OF ALL WARRANTIES.
*/
#include "tkMacOSXPrivate.h"
#include "tkEntry.h"
static ThemeButtonKind ComputeIncDecParameters(int height, int *width);
#define HIOrientation kHIThemeOrientationNormal
/*
*--------------------------------------------------------------
*
* ComputeIncDecParameters --
*
* This procedure figures out which of the kThemeIncDec buttons to use.
* It also sets width to the width of the IncDec button.
*
* Results:
* The ThemeButtonKind of the button we should use.
*
* Side effects:
* May draw the entry border into pixmap.
*
*--------------------------------------------------------------
*/
static ThemeButtonKind
ComputeIncDecParameters(
int height,
int *width)
{
ThemeButtonKind kind;
if (height < 11 || height > 28) {
*width = 0;
kind = (ThemeButtonKind) 0;
} else {
if (height >= 21) {
*width = 13;
kind = kThemeIncDecButton;
} else if (height >= 18) {
*width = 12;
kind = kThemeIncDecButtonSmall;
} else {
*width = 11;
kind = kThemeIncDecButtonMini;
}
}
return kind;
}
/*
*--------------------------------------------------------------
*
* TkpDrawEntryBorderAndFocus --
*
* This procedure redraws the border of an entry window. It overrides the
* generic border drawing code if the entry widget parameters are such
* that the native widget drawing is a good fit. This version just
* returns 1, so platforms that don't do special native drawing don't
* have to implement it.
*
* Results:
* 1 if it has drawn the border, 0 if not.
*
* Side effects:
* May draw the entry border into pixmap.
*
*--------------------------------------------------------------
*/
int
TkpDrawEntryBorderAndFocus(
Entry *entryPtr,
Drawable d,
int isSpinbox)
{
CGRect bounds;
TkMacOSXDrawingContext dc;
GC bgGC;
Tk_Window tkwin = entryPtr->tkwin;
int oldWidth = 0;
MacDrawable *macDraw = (MacDrawable *) d;
const HIThemeFrameDrawInfo info = {
.version = 0,
.kind = kHIThemeFrameTextFieldSquare,
.state = (entryPtr->state == STATE_DISABLED ? kThemeStateInactive :
kThemeStateActive),
.isFocused = (entryPtr->flags & GOT_FOCUS ? 1 : 0),
};
/*
* I use 6 as the borderwidth. 2 of the 5 go into the actual frame the 3
* are because the Mac OS Entry widgets leave more space around the Text
* than Tk does on X11.
*/
if (entryPtr->borderWidth != MAC_OSX_ENTRY_BORDER
|| entryPtr->highlightWidth != MAC_OSX_FOCUS_WIDTH
|| entryPtr->relief != MAC_OSX_ENTRY_RELIEF) {
return 0;
}
/*
* For the spinbox, we have to make the entry part smaller by the size of
* the buttons. We also leave 2 pixels to the left (as per the HIG) and
* space for one pixel to the right, 'cause it makes the buttons look
* nicer.
*/
if (isSpinbox) {
int incDecWidth;
oldWidth = Tk_Width(tkwin);
ComputeIncDecParameters(Tk_Height(tkwin) - 2 * MAC_OSX_FOCUS_WIDTH,
&incDecWidth);
Tk_Width(tkwin) -= incDecWidth + 1;
}
/*
* The focus ring is drawn with an Alpha at the outside part of the ring,
* so we have to draw over the edges of the ring before drawing the focus
* or the text will peep through.
*/
bgGC = Tk_GCForColor(entryPtr->highlightBgColorPtr, d);
TkDrawInsetFocusHighlight(entryPtr->tkwin, bgGC, MAC_OSX_FOCUS_WIDTH, d, 0);
/*
* Inset the entry Frame by the maximum width of the focus rect, which is
* 3 according to the Carbon docs.
*/
bounds.origin.x = macDraw->xOff + MAC_OSX_FOCUS_WIDTH;
bounds.origin.y = macDraw->yOff + MAC_OSX_FOCUS_WIDTH;
bounds.size.width = Tk_Width(tkwin) - 2*MAC_OSX_FOCUS_WIDTH;
bounds.size.height = Tk_Height(tkwin) - 2*MAC_OSX_FOCUS_WIDTH;
if (!TkMacOSXSetupDrawingContext(d, NULL, 1, &dc)) {
return 0;
}
ChkErr(HIThemeDrawFrame, &bounds, &info, dc.context, HIOrientation);
TkMacOSXRestoreDrawingContext(&dc);
if (isSpinbox) {
Tk_Width(tkwin) = oldWidth;
}
return 1;
}
/*
*--------------------------------------------------------------
*
* TkpDrawSpinboxButtons --
*
* This procedure redraws the buttons of an spinbox widget. It overrides
* the generic button drawing code if the spinbox widget parameters are
* such that the native widget drawing is a good fit. This version just
* returns 0, so platforms that don't do special native drawing don't
* have to implement it.
*
* Results:
* 1 if it has drawn the border, 0 if not.
*
* Side effects:
* May draw the entry border into pixmap.
*
*--------------------------------------------------------------
*/
int
TkpDrawSpinboxButtons(
Spinbox *sbPtr,
Drawable d)
{
CGRect bounds;
Tk_Window tkwin = sbPtr->entry.tkwin;
int height = Tk_Height(tkwin);
int buttonHeight = height - 2 * MAC_OSX_FOCUS_WIDTH;
int incDecWidth;
TkMacOSXDrawingContext dc;
XRectangle rects[1];
GC bgGC;
MacDrawable *macDraw = (MacDrawable *) d;
HIThemeButtonDrawInfo info = {
.version = 0,
.adornment = kThemeAdornmentNone,
};
/*
* FIXME: RAISED really makes more sense
*/
if (sbPtr->buRelief != TK_RELIEF_FLAT) {
return 0;
}
/*
* The actual sizes of the IncDec button are 21 for the normal, 18 for the
* small and 15 for the mini. But the spinbox still looks okay if the
* entry is a little bigger than this, so we give it a little slop.
*/
info.kind = ComputeIncDecParameters(buttonHeight, &incDecWidth);
if (info.kind == (ThemeButtonKind) 0) {
return 0;
}
if (sbPtr->entry.state == STATE_DISABLED) {
info.state = kThemeStateInactive;
info.value = kThemeButtonOff;
} else if (sbPtr->selElement == SEL_BUTTONUP) {
info.state = kThemeStatePressedUp;
info.value = kThemeButtonOn;
} else if (sbPtr->selElement == SEL_BUTTONDOWN) {
info.state = kThemeStatePressedDown;
info.value = kThemeButtonOn;
} else {
info.state = kThemeStateActive;
info.value = kThemeButtonOff;
}
bounds.origin.x = macDraw->xOff + Tk_Width(tkwin) - incDecWidth - 1;
bounds.origin.y = macDraw->yOff + MAC_OSX_FOCUS_WIDTH;
bounds.size.width = incDecWidth;
bounds.size.height = Tk_Height(tkwin) - 2*MAC_OSX_FOCUS_WIDTH;
/*
* We had to make the entry part of the window smaller so that we wouldn't
* overdraw the spin buttons with the focus highlight. So now we have to
* draw the highlightbackground.
*/
bgGC = Tk_GCForColor(sbPtr->entry.highlightBgColorPtr, d);
rects[0].x = bounds.origin.x;
rects[0].y = 0;
rects[0].width = Tk_Width(tkwin);
rects[0].height = Tk_Height(tkwin);
XFillRectangles(Tk_Display(tkwin), d, bgGC, rects, 1);
if (!TkMacOSXSetupDrawingContext(d, NULL, 1, &dc)) {
return 0;
}
ChkErr(HIThemeDrawButton, &bounds, &info, dc.context, HIOrientation, NULL);
TkMacOSXRestoreDrawingContext(&dc);
return 1;
}
/*
* Local Variables:
* mode: objc
* c-basic-offset: 4
* fill-column: 79
* coding: utf-8
* End:
*/

154
macosx/tkMacOSXEvent.c Normal file
View File

@@ -0,0 +1,154 @@
/*
* tkMacOSXEvent.c --
*
* This file contains the basic Mac OS X Event handling routines.
*
* Copyright (c) 1995-1997 Sun Microsystems, Inc.
* Copyright 2001-2009, Apple Inc.
* Copyright (c) 2005-2009 Daniel A. Steffen <das@users.sourceforge.net>
*
* See the file "license.terms" for information on usage and redistribution
* of this file, and for a DISCLAIMER OF ALL WARRANTIES.
*/
#include "tkMacOSXPrivate.h"
#include "tkMacOSXEvent.h"
#include "tkMacOSXDebug.h"
#pragma mark TKApplication(TKEvent)
enum {
NSWindowWillMoveEventType = 20
};
@implementation TKApplication(TKEvent)
/* TODO: replace by +[addLocalMonitorForEventsMatchingMask ? */
- (NSEvent *)tkProcessEvent:(NSEvent *)theEvent {
#ifdef TK_MAC_DEBUG_EVENTS
TKLog(@"-[%@(%p) %s] %@", [self class], self, _cmd, theEvent);
#endif
NSEvent *processedEvent = theEvent;
NSEventType type = [theEvent type];
NSInteger subtype;
NSUInteger flags;
switch ((NSInteger)type) {
case NSAppKitDefined:
subtype = [theEvent subtype];
switch (subtype) {
case NSApplicationActivatedEventType:
break;
case NSApplicationDeactivatedEventType:
break;
case NSWindowExposedEventType:
case NSScreenChangedEventType:
break;
case NSWindowMovedEventType:
break;
case NSWindowWillMoveEventType:
break;
default:
break;
}
break;
case NSKeyUp:
case NSKeyDown:
case NSFlagsChanged:
flags = [theEvent modifierFlags];
processedEvent = [self tkProcessKeyEvent:theEvent];
break;
case NSLeftMouseDown:
case NSLeftMouseUp:
case NSRightMouseDown:
case NSRightMouseUp:
case NSLeftMouseDragged:
case NSRightMouseDragged:
case NSMouseMoved:
case NSMouseEntered:
case NSMouseExited:
case NSScrollWheel:
case NSOtherMouseDown:
case NSOtherMouseUp:
case NSOtherMouseDragged:
case NSTabletPoint:
case NSTabletProximity:
processedEvent = [self tkProcessMouseEvent:theEvent];
break;
#if 0
case NSSystemDefined:
subtype = [theEvent subtype];
break;
case NSApplicationDefined: {
id win;
win = [theEvent window];
break;
}
case NSCursorUpdate:
break;
#if MAC_OS_X_VERSION_MAX_ALLOWED >= 1060
case NSEventTypeGesture:
case NSEventTypeMagnify:
case NSEventTypeRotate:
case NSEventTypeSwipe:
case NSEventTypeBeginGesture:
case NSEventTypeEndGesture:
break;
#endif
#endif
default:
break;
}
return processedEvent;
}
@end
#pragma mark -
/*
*----------------------------------------------------------------------
*
* TkMacOSXFlushWindows --
*
* This routine flushes all the windows of the application. It is
* called by XSync().
*
* Results:
* None.
*
* Side effects:
* Flushes all Carbon windows
*
*----------------------------------------------------------------------
*/
MODULE_SCOPE void
TkMacOSXFlushWindows(void)
{
NSInteger windowCount;
NSInteger *windowNumbers;
NSCountWindows(&windowCount);
if(windowCount) {
windowNumbers = (NSInteger *) ckalloc(windowCount * sizeof(NSInteger));
NSWindowList(windowCount, windowNumbers);
for (NSInteger index = 0; index < windowCount; index++) {
NSWindow *w = [NSApp windowWithWindowNumber:windowNumbers[index]];
if (TkMacOSXGetXWindow(w)) {
[w flushWindow];
}
}
ckfree((char*) windowNumbers);
}
}
/*
* Local Variables:
* mode: objc
* c-basic-offset: 4
* fill-column: 79
* coding: utf-8
* End:
*/

23
macosx/tkMacOSXEvent.h Normal file
View File

@@ -0,0 +1,23 @@
/*
* tkMacOSXEvent.h --
*
* Declarations of Macintosh specific functions for implementing the
* Mac OS X Notifier.
*
* Copyright 2001-2009, Apple Inc.
* Copyright (c) 2005-2009 Daniel A. Steffen <das@users.sourceforge.net>
*
* See the file "license.terms" for information on usage and redistribution
* of this file, and for a DISCLAIMER OF ALL WARRANTIES.
*/
#ifndef _TKMACEVENT
#define _TKMACEVENT
#ifndef _TKMACINT
#include "tkMacOSXInt.h"
#endif
MODULE_SCOPE void TkMacOSXFlushWindows(void);
#endif

1222
macosx/tkMacOSXFont.c Normal file

File diff suppressed because it is too large Load Diff

25
macosx/tkMacOSXFont.h Normal file
View File

@@ -0,0 +1,25 @@
/*
* tkMacOSXFont.h --
*
* Contains the Macintosh implementation of the platform-independant
* font package interface.
*
* Copyright (c) 1990-1994 The Regents of the University of California.
* Copyright (c) 1994-1997 Sun Microsystems, Inc.
* Copyright 2001-2009, Apple Inc.
* Copyright (c) 2006-2009 Daniel A. Steffen <das@users.sourceforge.net>
*
* See the file "license.terms" for information on usage and redistribution
* of this file, and for a DISCLAIMER OF ALL WARRANTIES.
*/
#ifndef TKMACOSXFONT_H
#define TKMACOSXFONT_H 1
#include "tkFont.h"
#ifndef _TKMACINT
#include "tkMacOSXInt.h"
#endif
#endif /*TKMACOSXFONT_H*/

708
macosx/tkMacOSXHLEvents.c Normal file
View File

@@ -0,0 +1,708 @@
/*
* tkMacOSXHLEvents.c --
*
* Implements high level event support for the Macintosh. Currently, the
* only event that really does anything is the Quit event.
*
* Copyright (c) 1995-1997 Sun Microsystems, Inc.
* Copyright 2001-2009, Apple Inc.
* Copyright (c) 2006-2009 Daniel A. Steffen <das@users.sourceforge.net>
*
* See the file "license.terms" for information on usage and redistribution
* of this file, and for a DISCLAIMER OF ALL WARRANTIES.
*/
#include "tkMacOSXPrivate.h"
/*
* This is a Tcl_Event structure that the Quit AppleEvent handler uses to
* schedule the ReallyKillMe function.
*/
typedef struct KillEvent {
Tcl_Event header; /* Information that is standard for all
* events. */
Tcl_Interp *interp; /* Interp that was passed to the Quit
* AppleEvent */
} KillEvent;
/*
* Static functions used only in this file.
*/
static OSErr QuitHandler(const AppleEvent *event,
AppleEvent *reply, SRefCon handlerRefcon);
static OSErr OappHandler(const AppleEvent *event,
AppleEvent *reply, SRefCon handlerRefcon);
static OSErr RappHandler(const AppleEvent *event,
AppleEvent *reply, SRefCon handlerRefcon);
static OSErr OdocHandler(const AppleEvent *event,
AppleEvent *reply, SRefCon handlerRefcon);
static OSErr PrintHandler(const AppleEvent *event,
AppleEvent *reply, SRefCon handlerRefcon);
static OSErr ScriptHandler(const AppleEvent *event,
AppleEvent *reply, SRefCon handlerRefcon);
static OSErr PrefsHandler(const AppleEvent *event,
AppleEvent *reply, SRefCon handlerRefcon);
static int MissedAnyParameters(const AppleEvent *theEvent);
static int ReallyKillMe(Tcl_Event *eventPtr, int flags);
static OSStatus FSRefToDString(const FSRef *fsref, Tcl_DString *ds);
#pragma mark TKApplication(TKHLEvents)
@implementation TKApplication(TKHLEvents)
- (void)terminate:(id)sender {
QuitHandler(NULL, NULL, (SRefCon) _eventInterp);
}
- (void)preferences:(id)sender {
PrefsHandler(NULL, NULL, (SRefCon) _eventInterp);
}
@end
#pragma mark -
/*
*----------------------------------------------------------------------
*
* TkMacOSXInitAppleEvents --
*
* Initilize the Apple Events on the Macintosh. This registers the core
* event handlers.
*
* Results:
* None.
*
* Side effects:
* None.
*
*----------------------------------------------------------------------
*/
void
TkMacOSXInitAppleEvents(
Tcl_Interp *interp) /* Interp to handle basic events. */
{
AEEventHandlerUPP OappHandlerUPP, RappHandlerUPP, OdocHandlerUPP;
AEEventHandlerUPP PrintHandlerUPP, QuitHandlerUPP, ScriptHandlerUPP;
AEEventHandlerUPP PrefsHandlerUPP;
static Boolean initialized = FALSE;
if (!initialized) {
initialized = TRUE;
/*
* Install event handlers for the core apple events.
*/
QuitHandlerUPP = NewAEEventHandlerUPP(QuitHandler);
ChkErr(AEInstallEventHandler, kCoreEventClass, kAEQuitApplication,
QuitHandlerUPP, (SRefCon) interp, false);
OappHandlerUPP = NewAEEventHandlerUPP(OappHandler);
ChkErr(AEInstallEventHandler, kCoreEventClass, kAEOpenApplication,
OappHandlerUPP, (SRefCon) interp, false);
RappHandlerUPP = NewAEEventHandlerUPP(RappHandler);
ChkErr(AEInstallEventHandler, kCoreEventClass, kAEReopenApplication,
RappHandlerUPP, (SRefCon) interp, false);
OdocHandlerUPP = NewAEEventHandlerUPP(OdocHandler);
ChkErr(AEInstallEventHandler, kCoreEventClass, kAEOpenDocuments,
OdocHandlerUPP, (SRefCon) interp, false);
PrintHandlerUPP = NewAEEventHandlerUPP(PrintHandler);
ChkErr(AEInstallEventHandler, kCoreEventClass, kAEPrintDocuments,
PrintHandlerUPP, (SRefCon) interp, false);
PrefsHandlerUPP = NewAEEventHandlerUPP(PrefsHandler);
ChkErr(AEInstallEventHandler, kCoreEventClass, kAEShowPreferences,
PrefsHandlerUPP, (SRefCon) interp, false);
if (interp) {
ScriptHandlerUPP = NewAEEventHandlerUPP(ScriptHandler);
ChkErr(AEInstallEventHandler, kAEMiscStandards, kAEDoScript,
ScriptHandlerUPP, (SRefCon) interp, false);
}
}
}
/*
*----------------------------------------------------------------------
*
* TkMacOSXDoHLEvent --
*
* Dispatch incomming highlevel events.
*
* Results:
* None.
*
* Side effects:
* Depends on the incoming event.
*
*----------------------------------------------------------------------
*/
int
TkMacOSXDoHLEvent(
void *theEvent)
{
return AEProcessAppleEvent((EventRecord *)theEvent);
}
/*
*----------------------------------------------------------------------
*
* QuitHandler --
*
* This is the 'quit' core Apple event handler.
*
* Results:
* None.
*
* Side effects:
* None.
*
*----------------------------------------------------------------------
*/
static OSErr
QuitHandler(
const AppleEvent *event,
AppleEvent *reply,
SRefCon handlerRefcon)
{
Tcl_Interp *interp = (Tcl_Interp *) handlerRefcon;
KillEvent *eventPtr;
if (interp) {
/*
* Call the exit command from the event loop, since you are not
* supposed to call ExitToShell in an Apple Event Handler. We put this
* at the head of Tcl's event queue because this message usually comes
* when the Mac is shutting down, and we want to kill the shell as
* quickly as possible.
*/
eventPtr = (KillEvent *) ckalloc(sizeof(KillEvent));
eventPtr->header.proc = ReallyKillMe;
eventPtr->interp = interp;
Tcl_QueueEvent((Tcl_Event *) eventPtr, TCL_QUEUE_HEAD);
}
return noErr;
}
/*
*----------------------------------------------------------------------
*
* OappHandler --
*
* This is the 'oapp' core Apple event handler.
*
* Results:
* None.
*
* Side effects:
* None.
*
*----------------------------------------------------------------------
*/
static OSErr
OappHandler(
const AppleEvent *event,
AppleEvent *reply,
SRefCon handlerRefcon)
{
Tcl_CmdInfo dummy;
Tcl_Interp *interp = (Tcl_Interp *) handlerRefcon;
if (interp &&
Tcl_GetCommandInfo(interp, "::tk::mac::OpenApplication", &dummy)){
int code = Tcl_EvalEx(interp, "::tk::mac::OpenApplication", -1, TCL_EVAL_GLOBAL);
if (code != TCL_OK) {
Tcl_BackgroundError(interp);
}
}
return noErr;
}
/*
*----------------------------------------------------------------------
*
* RappHandler --
*
* This is the 'rapp' core Apple event handler.
*
* Results:
* None.
*
* Side effects:
* None.
*
*----------------------------------------------------------------------
*/
static OSErr
RappHandler(
const AppleEvent *event,
AppleEvent *reply,
SRefCon handlerRefcon)
{
Tcl_CmdInfo dummy;
Tcl_Interp *interp = (Tcl_Interp *) handlerRefcon;
ProcessSerialNumber thePSN = {0, kCurrentProcess};
OSStatus err = ChkErr(SetFrontProcess, &thePSN);
if (interp && Tcl_GetCommandInfo(interp,
"::tk::mac::ReopenApplication", &dummy)) {
int code = Tcl_EvalEx(interp, "::tk::mac::ReopenApplication", -1, TCL_EVAL_GLOBAL);
if (code != TCL_OK){
Tcl_BackgroundError(interp);
}
}
return err;
}
/*
*----------------------------------------------------------------------
*
* PrefsHandler --
*
* This is the 'pref' core Apple event handler. Called when the user
* selects 'Preferences...' in MacOS X
*
* Results:
* None.
*
* Side effects:
* None.
*
*----------------------------------------------------------------------
*/
static OSErr
PrefsHandler(
const AppleEvent *event,
AppleEvent *reply,
SRefCon handlerRefcon)
{
Tcl_CmdInfo dummy;
Tcl_Interp *interp = (Tcl_Interp *) handlerRefcon;
if (interp &&
Tcl_GetCommandInfo(interp, "::tk::mac::ShowPreferences", &dummy)){
int code = Tcl_EvalEx(interp, "::tk::mac::ShowPreferences", -1, TCL_EVAL_GLOBAL);
if (code != TCL_OK) {
Tcl_BackgroundError(interp);
}
}
return noErr;
}
/*
*----------------------------------------------------------------------
*
* OdocHandler --
*
* This is the 'odoc' core Apple event handler.
*
* Results:
* None.
*
* Side effects:
* None.
*
*----------------------------------------------------------------------
*/
static OSErr
OdocHandler(
const AppleEvent *event,
AppleEvent *reply,
SRefCon handlerRefcon)
{
Tcl_Interp *interp = (Tcl_Interp *) handlerRefcon;
AEDescList fileSpecList;
FSRef file;
DescType type;
Size actual;
long count, index;
AEKeyword keyword;
Tcl_DString command, pathName;
Tcl_CmdInfo dummy;
int code;
/*
* Don't bother if we don't have an interp or the open document procedure
* doesn't exist.
*/
if (!interp ||
!Tcl_GetCommandInfo(interp, "::tk::mac::OpenDocument", &dummy)) {
return noErr;
}
/*
* If we get any errors while retrieving our parameters we just return with
* no error.
*/
if (ChkErr(AEGetParamDesc, event, keyDirectObject, typeAEList,
&fileSpecList) != noErr) {
return noErr;
}
if (MissedAnyParameters(event) != noErr) {
return noErr;
}
if (ChkErr(AECountItems, &fileSpecList, &count) != noErr) {
return noErr;
}
/*
* Convert our parameters into a script to evaluate, skipping things that
* we can't handle right.
*/
Tcl_DStringInit(&command);
Tcl_DStringAppend(&command, "::tk::mac::OpenDocument", -1);
for (index = 1; index <= count; index++) {
if (ChkErr(AEGetNthPtr, &fileSpecList, index, typeFSRef, &keyword,
&type, (Ptr) &file, sizeof(FSRef), &actual) != noErr) {
continue;
}
if (ChkErr(FSRefToDString, &file, &pathName) == noErr) {
Tcl_DStringAppendElement(&command, Tcl_DStringValue(&pathName));
Tcl_DStringFree(&pathName);
}
}
/*
* Now handle the event by evaluating a script.
*/
code = Tcl_EvalEx(interp, Tcl_DStringValue(&command),
Tcl_DStringLength(&command), TCL_EVAL_GLOBAL);
if (code != TCL_OK) {
Tcl_BackgroundError(interp);
}
Tcl_DStringFree(&command);
return noErr;
}
/*
*----------------------------------------------------------------------
*
* PrintHandler --
*
* This is the 'pdoc' core Apple event handler.
*
* Results:
* None.
*
* Side effects:
* None.
*
*----------------------------------------------------------------------
*/
static OSErr
PrintHandler(
const AppleEvent * event,
AppleEvent * reply,
SRefCon handlerRefcon)
{
Tcl_Interp *interp = (Tcl_Interp *) handlerRefcon;
AEDescList fileSpecList;
FSRef file;
DescType type;
Size actual;
long count, index;
AEKeyword keyword;
Tcl_DString command, pathName;
Tcl_CmdInfo dummy;
int code;
/*
* Don't bother if we don't have an interp or the print document procedure
* doesn't exist.
*/
if (!interp ||
!Tcl_GetCommandInfo(interp, "::tk::mac::PrintDocument", &dummy)) {
return noErr;
}
/*
* If we get any errors while retrieving our parameters we just return with
* no error.
*/
if (ChkErr(AEGetParamDesc, event, keyDirectObject, typeAEList,
&fileSpecList) != noErr) {
return noErr;
}
if (ChkErr(MissedAnyParameters, event) != noErr) {
return noErr;
}
if (ChkErr(AECountItems, &fileSpecList, &count) != noErr) {
return noErr;
}
Tcl_DStringInit(&command);
Tcl_DStringAppend(&command, "::tk::mac::PrintDocument", -1);
for (index = 1; index <= count; index++) {
if (ChkErr(AEGetNthPtr, &fileSpecList, index, typeFSRef, &keyword,
&type, (Ptr) &file, sizeof(FSRef), &actual) != noErr) {
continue;
}
if (ChkErr(FSRefToDString, &file, &pathName) == noErr) {
Tcl_DStringAppendElement(&command, Tcl_DStringValue(&pathName));
Tcl_DStringFree(&pathName);
}
}
/*
* Now handle the event by evaluating a script.
*/
code = Tcl_EvalEx(interp, Tcl_DStringValue(&command),
Tcl_DStringLength(&command), TCL_EVAL_GLOBAL);
if (code != TCL_OK) {
Tcl_BackgroundError(interp);
}
Tcl_DStringFree(&command);
return noErr;
}
/*
*----------------------------------------------------------------------
*
* ScriptHandler --
*
* This handler process the script event.
*
* Results:
* Schedules the given event to be processed.
*
* Side effects:
* None.
*
*----------------------------------------------------------------------
*/
static OSErr
ScriptHandler(
const AppleEvent *event,
AppleEvent *reply,
SRefCon handlerRefcon)
{
OSStatus theErr;
AEDescList theDesc;
Size size;
int tclErr = -1;
Tcl_Interp *interp = (Tcl_Interp *) handlerRefcon;
char errString[128];
/*
* The do script event receives one parameter that should be data or a
* file.
*/
theErr = AEGetParamDesc(event, keyDirectObject, typeWildCard,
&theDesc);
if (theErr != noErr) {
sprintf(errString, "AEDoScriptHandler: GetParamDesc error %d",
(int)theErr);
theErr = AEPutParamPtr(reply, keyErrorString, typeChar, errString,
strlen(errString));
} else if (MissedAnyParameters(event)) {
/*
* Return error if parameter is missing.
*/
sprintf(errString, "AEDoScriptHandler: extra parameters");
AEPutParamPtr(reply, keyErrorString, typeChar, errString,
strlen(errString));
theErr = -1771;
} else if (theDesc.descriptorType == (DescType) typeAlias &&
AEGetParamPtr(event, keyDirectObject, typeFSRef, NULL, NULL,
0, &size) == noErr && size == sizeof(FSRef)) {
/*
* We've had a file sent to us. Source it.
*/
FSRef file;
theErr = AEGetParamPtr(event, keyDirectObject, typeFSRef, NULL, &file,
size, NULL);
if (theErr == noErr) {
Tcl_DString scriptName;
theErr = FSRefToDString(&file, &scriptName);
if (theErr == noErr) {
tclErr = Tcl_EvalFile(interp, Tcl_DStringValue(&scriptName));
Tcl_DStringFree(&scriptName);
} else {
sprintf(errString, "AEDoScriptHandler: file not found");
AEPutParamPtr(reply, keyErrorString, typeChar, errString,
strlen(errString));
}
}
} else if (AEGetParamPtr(event, keyDirectObject, typeUTF8Text, NULL, NULL,
0, &size) == noErr && size) {
/*
* We've had some data sent to us. Evaluate it.
*/
char *data = ckalloc(size + 1);
theErr = AEGetParamPtr(event, keyDirectObject, typeUTF8Text, NULL, data,
size, NULL);
if (theErr == noErr) {
tclErr = Tcl_EvalEx(interp, data, size, TCL_EVAL_GLOBAL);
}
} else {
/*
* Umm, don't recognize what we've got...
*/
sprintf(errString, "AEDoScriptHandler: invalid script type '%-4.4s', "
"must be 'alis' or coercable to 'utf8'",
(char*) &theDesc.descriptorType);
AEPutParamPtr(reply, keyErrorString, typeChar, errString,
strlen(errString));
theErr = -1770;
}
/*
* If we actually go to run Tcl code - put the result in the reply.
*/
if (tclErr >= 0) {
int reslen;
const char *result =
Tcl_GetStringFromObj(Tcl_GetObjResult(interp), &reslen);
if (tclErr == TCL_OK) {
AEPutParamPtr(reply, keyDirectObject, typeChar, result, reslen);
} else {
AEPutParamPtr(reply, keyErrorString, typeChar, result, reslen);
AEPutParamPtr(reply, keyErrorNumber, typeSInt32, (Ptr) &tclErr,
sizeof(int));
}
}
AEDisposeDesc(&theDesc);
return theErr;
}
/*
*----------------------------------------------------------------------
*
* ReallyKillMe --
*
* This proc tries to kill the shell by running exit, called from an
* event scheduled by the "Quit" AppleEvent handler.
*
* Results:
* Runs the "exit" command which might kill the shell.
*
* Side effects:
* None.
*
*----------------------------------------------------------------------
*/
static int
ReallyKillMe(
Tcl_Event *eventPtr,
int flags)
{
Tcl_Interp *interp = ((KillEvent *) eventPtr)->interp;
Tcl_CmdInfo dummy;
int quit = Tcl_GetCommandInfo(interp, "::tk::mac::Quit", &dummy);
int code = Tcl_EvalEx(interp, quit ? "::tk::mac::Quit" : "exit", -1, TCL_EVAL_GLOBAL);
if (code != TCL_OK) {
/*
* Should be never reached...
*/
Tcl_BackgroundError(interp);
}
return 1;
}
/*
*----------------------------------------------------------------------
*
* MissedAnyParameters --
*
* Checks to see if parameters are still left in the event.
*
* Results:
* True or false.
*
* Side effects:
* None.
*
*----------------------------------------------------------------------
*/
static int
MissedAnyParameters(
const AppleEvent *theEvent)
{
DescType returnedType;
Size actualSize;
OSStatus err;
err = AEGetAttributePtr(theEvent, keyMissedKeywordAttr,
typeWildCard, &returnedType, NULL, 0, &actualSize);
return (err != errAEDescNotFound);
}
/*
*----------------------------------------------------------------------
*
* FSRefToDString --
*
* Get a POSIX path from an FSRef.
*
* Results:
* In the parameter ds.
*
* Side effects:
* None.
*
*----------------------------------------------------------------------
*/
static OSStatus
FSRefToDString(
const FSRef *fsref,
Tcl_DString *ds)
{
UInt8 fileName[PATH_MAX+1];
OSStatus err;
err = ChkErr(FSRefMakePath, fsref, fileName, sizeof(fileName));
if (err == noErr) {
Tcl_ExternalToUtfDString(NULL, (char*) fileName, -1, ds);
}
return err;
}
/*
* Local Variables:
* mode: objc
* c-basic-offset: 4
* fill-column: 79
* coding: utf-8
* End:
*/

585
macosx/tkMacOSXInit.c Normal file
View File

@@ -0,0 +1,585 @@
/*
* tkMacOSXInit.c --
*
* This file contains Mac OS X -specific interpreter initialization
* functions.
*
* Copyright (c) 1995-1997 Sun Microsystems, Inc.
* Copyright 2001-2009, Apple Inc.
* Copyright (c) 2005-2009 Daniel A. Steffen <das@users.sourceforge.net>
*
* See the file "license.terms" for information on usage and redistribution of
* this file, and for a DISCLAIMER OF ALL WARRANTIES.
*/
#include "tkMacOSXPrivate.h"
#include "tclInt.h" /* for Tcl_GetStartupScript() & Tcl_SetStartupScript() */
#include <sys/stat.h>
#include <sys/utsname.h>
#include <dlfcn.h>
#include <objc/objc-auto.h>
static char tkLibPath[PATH_MAX + 1] = "";
/*
* 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] = "";
int tkMacOSXGCEnabled = 0;
long tkMacOSXMacOSXVersion = 0;
#pragma mark TKApplication(TKInit)
#if MAC_OS_X_VERSION_MIN_REQUIRED < 1060
#define NSTextInputContextKeyboardSelectionDidChangeNotification @"NSTextInputContextKeyboardSelectionDidChangeNotification"
static void keyboardChanged(CFNotificationCenterRef center, void *observer, CFStringRef name, const void *object, CFDictionaryRef userInfo) {
[[NSNotificationCenter defaultCenter] postNotificationName:NSTextInputContextKeyboardSelectionDidChangeNotification object:nil userInfo:nil];
}
#endif
@interface TKApplication(TKKeyboard)
- (void)keyboardChanged:(NSNotification *)notification;
@end
#if MAC_OS_X_VERSION_MAX_ALLOWED >= 1060
#define TKApplication_NSApplicationDelegate <NSApplicationDelegate>
#else
#define TKApplication_NSApplicationDelegate
#endif
@interface TKApplication(TKWindowEvent) TKApplication_NSApplicationDelegate
- (void)_setupWindowNotifications;
@end
@interface TKApplication(TKScrlbr)
- (void)_setupScrollBarNotifications;
@end
@interface TKApplication(TKMenus)
- (void)_setupMenus;
@end
@implementation TKApplication
@end
@implementation TKApplication(TKInit)
#ifdef TK_MAC_DEBUG_NOTIFICATIONS
- (void)_postedNotification:(NSNotification *)notification {
TKLog(@"-[%@(%p) %s] %@", [self class], self, _cmd, notification);
}
#endif
- (void)_setupApplicationNotifications {
NSNotificationCenter *nc = [NSNotificationCenter defaultCenter];
#define observe(n, s) [nc addObserver:self selector:@selector(s) name:(n) object:nil]
observe(NSApplicationDidBecomeActiveNotification, applicationActivate:);
observe(NSApplicationDidResignActiveNotification, applicationDeactivate:);
observe(NSApplicationDidUnhideNotification, applicationShowHide:);
observe(NSApplicationDidHideNotification, applicationShowHide:);
observe(NSApplicationDidChangeScreenParametersNotification, displayChanged:);
observe(NSTextInputContextKeyboardSelectionDidChangeNotification, keyboardChanged:);
#undef observe
#if MAC_OS_X_VERSION_MIN_REQUIRED < 1060
CFNotificationCenterAddObserver(CFNotificationCenterGetDistributedCenter(), NULL, &keyboardChanged, kTISNotifySelectedKeyboardInputSourceChanged, NULL, CFNotificationSuspensionBehaviorCoalesce);
#endif
}
- (void)_setupEventLoop {
_running = 1;
if (!_appFlags._hasBeenRun) {
_appFlags._hasBeenRun = YES;
[self finishLaunching];
}
[self setWindowsNeedUpdate:YES];
}
- (void)_setup:(Tcl_Interp *)interp {
_eventInterp = interp;
_defaultMainMenu = nil;
[self _setupMenus];
[self setDelegate:self];
#ifdef TK_MAC_DEBUG_NOTIFICATIONS
[[NSNotificationCenter defaultCenter] addObserver:self
selector:@selector(_postedNotification:) name:nil object:nil];
#endif
[self _setupWindowNotifications];
[self _setupScrollBarNotifications];
[self _setupApplicationNotifications];
}
- (NSString *)tkFrameworkImagePath:(NSString*)image {
NSString *path = nil;
if (tkLibPath[0] != '\0') {
path = [[NSBundle bundleWithPath:[[NSString stringWithUTF8String:
tkLibPath] stringByAppendingString:@"/../.."]]
pathForImageResource:image];
}
if (!path) {
const char *tk_library = Tcl_GetVar2(_eventInterp, "tk_library", NULL,
TCL_GLOBAL_ONLY);
if (tk_library) {
NSFileManager *fm = [NSFileManager defaultManager];
path = [[NSString stringWithUTF8String:tk_library]
stringByAppendingFormat:@"/%@", image];
if (![fm isReadableFileAtPath:path]) {
path = [[NSString stringWithUTF8String:tk_library]
stringByAppendingFormat:@"/../macosx/%@", image];
if (![fm isReadableFileAtPath:path]) {
path = nil;
}
}
}
}
#ifdef TK_MAC_DEBUG
if (!path && getenv("TK_SRCROOT")) {
path = [[NSString stringWithUTF8String:getenv("TK_SRCROOT")]
stringByAppendingFormat:@"/macosx/%@", image];
if (![[NSFileManager defaultManager] isReadableFileAtPath:path]) {
path = nil;
}
}
#endif
return path;
}
@end
#pragma mark -
/*
*----------------------------------------------------------------------
*
* DoWindowActivate --
*
* Idle handler that sets the application icon to the generic Tk icon.
*
* Results:
* None.
*
* Side effects:
* None.
*
*----------------------------------------------------------------------
*/
static void
SetApplicationIcon(
ClientData clientData)
{
NSString *path = [NSApp tkFrameworkImagePath:@"Tk.icns"];
if (path) {
NSImage *image = [[NSImage alloc] initWithContentsOfFile:path];
if (image) {
[NSApp setApplicationIconImage:image];
[image release];
}
}
}
/*
*----------------------------------------------------------------------
*
* TkpInit --
*
* Performs Mac-specific interpreter initialization related to the
* tk_library variable.
*
* Results:
* Returns a standard Tcl result. Leaves an error message or result in
* the interp's result.
*
* Side effects:
* Sets "tk_library" Tcl variable, runs "tk.tcl" script.
*
*----------------------------------------------------------------------
*/
int
TkpInit(
Tcl_Interp *interp)
{
static int initialized = 0;
/*
* Since it is possible for TkInit to be called multiple times and we
* don't want to do the following initialization multiple times we protect
* against doing it more than once.
*/
if (!initialized) {
int bundledExecutable = 0;
CFBundleRef bundleRef;
CFURLRef bundleUrl = NULL;
struct utsname name;
struct stat st;
initialized = 1;
/*
* Initialize/check OS version variable for runtime checks.
*/
#if MAC_OS_X_VERSION_MIN_REQUIRED < 1050
# error Mac OS X 10.5 required
#endif
if (!uname(&name)) {
tkMacOSXMacOSXVersion = (strtod(name.release, NULL) + 96) * 10;
}
if (tkMacOSXMacOSXVersion &&
tkMacOSXMacOSXVersion/10 < MAC_OS_X_VERSION_MIN_REQUIRED/10) {
Tcl_Panic("Mac OS X 10.%d or later required !",
(MAC_OS_X_VERSION_MIN_REQUIRED/10)-100);
}
#ifdef TK_FRAMEWORK
/*
* When Tk is in a framework, force tcl_findLibrary to look in the
* framework scripts directory.
* FIXME: Should we come up with a more generic way of doing this?
*/
if (Tcl_MacOSXOpenVersionedBundleResources(interp,
"com.tcltk.tklibrary", TK_FRAMEWORK_VERSION, 0, PATH_MAX,
tkLibPath) != TCL_OK) {
TkMacOSXDbgMsg("Tcl_MacOSXOpenVersionedBundleResources failed");
}
#endif
static NSAutoreleasePool *pool = nil;
if (!pool) {
pool = [NSAutoreleasePool new];
}
tkMacOSXGCEnabled = ([NSGarbageCollector defaultCollector] != nil);
[[NSUserDefaults standardUserDefaults] registerDefaults:
[NSDictionary dictionaryWithObjectsAndKeys:
[NSNumber numberWithBool:YES],
@"_NSCanWrapButtonTitles",
[NSNumber numberWithInt:-1],
@"NSStringDrawingTypesetterBehavior",
nil]];
[TKApplication sharedApplication];
[NSApp _setup:interp];
/* Check whether we are a bundled executable: */
bundleRef = CFBundleGetMainBundle();
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 (!bundledExecutable) {
/*
* If we are loaded into an executable that is not a bundled
* application, the window server does not let us come to the
* foreground. For such an executable, notify the window server
* that we are now a full GUI application.
*/
OSStatus err = procNotFound;
ProcessSerialNumber psn = { 0, kCurrentProcess };
err = ChkErr(TransformProcessType, &psn,
kProcessTransformToForegroundApplication);
/*
* Set application icon to generic Tk icon, do it at idle time
* instead of now to ensure tk_library is setup.
*/
Tcl_DoWhenIdle(SetApplicationIcon, NULL);
}
[NSApp _setupEventLoop];
TkMacOSXInitAppleEvents(interp);
TkMacOSXUseAntialiasedText(interp, -1);
TkMacOSXInitCGDrawing(interp, TRUE, 0);
[pool drain];
pool = [NSAutoreleasePool new];
/*
* FIXME: Close stdin & stdout for remote debugging otherwise we will
* fight with gdb for stdin & stdout
*/
if (getenv("XCNOSTDIN") != NULL) {
close(0);
close(1);
}
/*
* 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 (getenv("TK_CONSOLE") ||
(!isatty(0) && (fstat(0, &st) ||
(S_ISCHR(st.st_mode) && st.st_blocks == 0)))) {
Tk_InitConsoleChannels(interp);
Tcl_RegisterChannel(interp, Tcl_GetStdChannel(TCL_STDIN));
Tcl_RegisterChannel(interp, Tcl_GetStdChannel(TCL_STDOUT));
Tcl_RegisterChannel(interp, Tcl_GetStdChannel(TCL_STDERR));
/*
* Only show the console if we don't have a startup script
* and tcl_interactive hasn't been set already.
*/
if (Tcl_GetStartupScript(NULL) == NULL) {
const char *intvar = Tcl_GetVar(interp,
"tcl_interactive", TCL_GLOBAL_ONLY);
if (intvar == NULL) {
Tcl_SetVar(interp, "tcl_interactive", "1",
TCL_GLOBAL_ONLY);
}
}
if (Tk_CreateConsoleWindow(interp) == TCL_ERROR) {
return TCL_ERROR;
}
}
}
Tk_MacOSXSetupTkNotifier();
if (tkLibPath[0] != '\0') {
Tcl_SetVar(interp, "tk_library", tkLibPath, TCL_GLOBAL_ONLY);
}
if (scriptPath[0] != '\0') {
Tcl_SetVar(interp, "auto_path", scriptPath,
TCL_GLOBAL_ONLY|TCL_LIST_ELEMENT|TCL_APPEND_VALUE);
}
Tcl_CreateObjCommand(interp, "::tk::mac::standardAboutPanel",
TkMacOSXStandardAboutPanelObjCmd, NULL, NULL);
Tcl_CreateObjCommand(interp, "::tk::mac::iconBitmap",
TkMacOSXIconBitmapObjCmd, NULL, NULL);
return TCL_OK;
}
/*
*----------------------------------------------------------------------
*
* TkpGetAppName --
*
* Retrieves the name of the current application from a platform specific
* location. For Unix, the application name is the tail of the path
* contained in the tcl variable argv0.
*
* Results:
* Returns the application name in the given Tcl_DString.
*
* Side effects:
* None.
*
*----------------------------------------------------------------------
*/
void
TkpGetAppName(
Tcl_Interp *interp,
Tcl_DString *namePtr) /* A previously initialized Tcl_DString. */
{
const char *p, *name;
name = Tcl_GetVar(interp, "argv0", TCL_GLOBAL_ONLY);
if ((name == NULL) || (*name == 0)) {
name = "tk";
} else {
p = strrchr(name, '/');
if (p != NULL) {
name = p+1;
}
}
Tcl_DStringAppend(namePtr, name, -1);
}
/*
*----------------------------------------------------------------------
*
* TkpDisplayWarning --
*
* This routines is called from Tk_Main to display warning messages that
* occur during startup.
*
* Results:
* None.
*
* Side effects:
* Generates messages on stdout.
*
*----------------------------------------------------------------------
*/
void
TkpDisplayWarning(
const char *msg, /* Message to be displayed. */
const char *title) /* Title of warning. */
{
Tcl_Channel errChannel = Tcl_GetStdChannel(TCL_STDERR);
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.
*
*----------------------------------------------------------------------
*/
MODULE_SCOPE void
TkMacOSXDefaultStartupScript(void)
{
CFBundleRef bundleRef;
bundleRef = CFBundleGetMainBundle();
if (bundleRef != NULL) {
CFURLRef appMainURL = CFBundleCopyResourceURL(bundleRef,
CFSTR("AppMain"), CFSTR("tcl"), CFSTR("Scripts"));
if (appMainURL != NULL) {
CFURLRef scriptFldrURL;
char startupScript[PATH_MAX + 1];
if (CFURLGetFileSystemRepresentation (appMainURL, true,
(unsigned char *) startupScript, PATH_MAX)) {
Tcl_SetStartupScript(Tcl_NewStringObj(startupScript,-1), NULL);
scriptFldrURL = CFURLCreateCopyDeletingLastPathComponent(NULL,
appMainURL);
if (scriptFldrURL != NULL) {
CFURLGetFileSystemRepresentation(scriptFldrURL, true,
(unsigned char *) scriptPath, PATH_MAX);
CFRelease(scriptFldrURL);
}
}
CFRelease(appMainURL);
}
}
}
/*
*----------------------------------------------------------------------
*
* TkMacOSXGetNamedSymbol --
*
* Dynamically acquire address of a named symbol from a loaded dynamic
* library, so that we can use API that may not be available on all OS
* versions.
*
* Results:
* Address of given symbol or NULL if unavailable.
*
* Side effects:
* None.
*
*----------------------------------------------------------------------
*/
MODULE_SCOPE void*
TkMacOSXGetNamedSymbol(
const char* module,
const char* symbol)
{
void *addr = dlsym(RTLD_NEXT, symbol);
if (!addr) {
(void) dlerror(); /* Clear dlfcn error state */
}
return addr;
}
/*
*----------------------------------------------------------------------
*
* TkMacOSXGetStringObjFromCFString --
*
* Get a string object from a CFString as efficiently as possible.
*
* Results:
* New string object or NULL if conversion failed.
*
* Side effects:
* None.
*
*----------------------------------------------------------------------
*/
MODULE_SCOPE Tcl_Obj*
TkMacOSXGetStringObjFromCFString(
CFStringRef str)
{
Tcl_Obj *obj = NULL;
const char *c = CFStringGetCStringPtr(str, kCFStringEncodingUTF8);
if (c) {
obj = Tcl_NewStringObj(c, -1);
} else {
CFRange all = CFRangeMake(0, CFStringGetLength(str));
CFIndex len;
if (CFStringGetBytes(str, all, kCFStringEncodingUTF8, 0, false, NULL,
0, &len) > 0 && len < INT_MAX) {
obj = Tcl_NewObj();
Tcl_SetObjLength(obj, len);
CFStringGetBytes(str, all, kCFStringEncodingUTF8, 0, false,
(UInt8*) obj->bytes, len, NULL);
}
}
return obj;
}
/*
* Local Variables:
* mode: objc
* c-basic-offset: 4
* fill-column: 79
* coding: utf-8
* End:
*/

206
macosx/tkMacOSXInt.h Normal file
View File

@@ -0,0 +1,206 @@
/*
* tkMacOSXInt.h --
*
* Declarations of Macintosh specific shared variables and procedures.
*
* Copyright (c) 1995-1997 Sun Microsystems, Inc.
* Copyright 2001-2009, Apple Inc.
* Copyright (c) 2005-2009 Daniel A. Steffen <das@users.sourceforge.net>
*
* See the file "license.terms" for information on usage and redistribution
* of this file, and for a DISCLAIMER OF ALL WARRANTIES.
*/
#ifndef _TKMACINT
#define _TKMACINT
#ifndef _TKINT
#include "tkInt.h"
#endif
/*
* Include platform specific public interfaces.
*/
#ifndef _TKMAC
#include "tkMacOSX.h"
#endif
/*
* Define compatibility platform types used in the structures below so that
* this header can be included without pulling in the platform headers.
*/
#ifndef _TKMACPRIV
# ifndef CGGEOMETRY_H_
# ifndef CGFLOAT_DEFINED
# if __LP64__
# define CGFloat double
# else
# define CGFloat float
# endif
# endif
# define CGSize struct {CGFloat width; CGFloat height;}
# endif
# ifndef CGCONTEXT_H_
# define CGContextRef void *
# endif
# ifndef CGCOLOR_H_
# define CGColorRef void *
# endif
# ifndef __HISHAPE__
# define HIShapeRef void *
# endif
# ifndef _APPKITDEFINES_H
# define NSView void *
# endif
#endif
struct TkWindowPrivate {
TkWindow *winPtr; /* Ptr to tk window or NULL if Pixmap */
NSView *view;
CGContextRef context;
int xOff; /* X offset from toplevel window */
int yOff; /* Y offset from toplevel window */
CGSize size;
HIShapeRef visRgn; /* Visible region of window */
HIShapeRef aboveVisRgn; /* Visible region of window & its children */
HIShapeRef drawRgn; /* Clipped drawing region */
int referenceCount; /* Don't delete toplevel until children are
* gone. */
struct TkWindowPrivate *toplevel;
/* Pointer to the toplevel datastruct. */
int flags; /* Various state see defines below. */
};
typedef struct TkWindowPrivate MacDrawable;
/*
* Defines use for the flags field of the MacDrawable data structure.
*/
#define TK_SCROLLBAR_GROW 0x01
#define TK_CLIP_INVALID 0x02
#define TK_HOST_EXISTS 0x04
#define TK_DRAWN_UNDER_MENU 0x08
#define TK_FOCUSED_VIEW 0x10
#define TK_IS_PIXMAP 0x20
#define TK_IS_BW_PIXMAP 0x40
/*
* I am reserving TK_EMBEDDED = 0x100 in the MacDrawable flags
* This is defined in tk.h. We need to duplicate the TK_EMBEDDED flag in the
* TkWindow structure for the window, but in the MacWin. This way we can
* still tell what the correct port is after the TKWindow structure has been
* freed. This actually happens when you bind destroy of a toplevel to
* Destroy of a child.
*/
/*
* This structure is for handling Netscape-type in process
* embedding where Tk does not control the top-level. It contains
* various functions that are needed by Mac specific routines, like
* TkMacOSXGetDrawablePort. The definitions of the function types
* are in tkMacOSX.h.
*/
typedef struct {
Tk_MacOSXEmbedRegisterWinProc *registerWinProc;
Tk_MacOSXEmbedGetGrafPortProc *getPortProc;
Tk_MacOSXEmbedMakeContainerExistProc *containerExistProc;
Tk_MacOSXEmbedGetClipProc *getClipProc;
Tk_MacOSXEmbedGetOffsetInParentProc *getOffsetProc;
} TkMacOSXEmbedHandler;
MODULE_SCOPE TkMacOSXEmbedHandler *tkMacOSXEmbedHandler;
/*
* GC CGColorRef cache for tkMacOSXColor.c
*/
typedef struct {
unsigned long cachedForeground;
CGColorRef cachedForegroundColor;
unsigned long cachedBackground;
CGColorRef cachedBackgroundColor;
} TkpGCCache;
MODULE_SCOPE TkpGCCache *TkpGetGCCache(GC gc);
MODULE_SCOPE void TkpInitGCCache(GC gc);
MODULE_SCOPE void TkpFreeGCCache(GC gc);
/*
* Undef compatibility platform types defined above.
*/
#ifndef _TKMACPRIV
# ifndef CGGEOMETRY_H_
# ifndef CGFLOAT_DEFINED
# undef CGFloat
# endif
# undef CGSize
# endif
# ifndef CGCONTEXT_H_
# undef CGContextRef
# endif
# ifndef CGCOLOR_H_
# undef CGColorRef
# endif
# ifndef __HISHAPE__
# undef HIShapeRef
# endif
# ifndef _APPKITDEFINES_H
# undef NSView
# endif
#endif
/*
* Defines used for TkMacOSXInvalidateWindow
*/
#define TK_WINDOW_ONLY 0
#define TK_PARENT_WINDOW 1
/*
* Accessor for the privatePtr flags field for the TK_HOST_EXISTS field
*/
#define TkMacOSXHostToplevelExists(tkwin) \
(((TkWindow *) (tkwin))->privatePtr->toplevel->flags & TK_HOST_EXISTS)
/*
* Defines used for the flags argument to TkGenWMConfigureEvent.
*/
#define TK_LOCATION_CHANGED 1
#define TK_SIZE_CHANGED 2
#define TK_BOTH_CHANGED 3
#define TK_MACOSX_HANDLE_EVENT_IMMEDIATELY 1024
/*
* Defines for tkTextDisp.c
*/
#define TK_LAYOUT_WITH_BASE_CHUNKS 1
#define TK_DRAW_IN_CONTEXT 1
/*
* Prototypes of internal procs not in the stubs table.
*/
MODULE_SCOPE void TkMacOSXDefaultStartupScript(void);
#if 0
MODULE_SCOPE int XSetClipRectangles(Display *d, GC gc, int clip_x_origin,
int clip_y_origin, XRectangle* rectangles, int n, int ordering);
#endif
MODULE_SCOPE void TkpClipDrawableToRect(Display *display, Drawable d, int x,
int y, int width, int height);
MODULE_SCOPE void TkpRetainRegion(TkRegion r);
MODULE_SCOPE void TkpReleaseRegion(TkRegion r);
/*
* Include the stubbed internal platform-specific API.
*/
#include "tkIntPlatDecls.h"
#endif /* _TKMACINT */

723
macosx/tkMacOSXKeyEvent.c Normal file
View File

@@ -0,0 +1,723 @@
/*
* tkMacOSXKeyEvent.c --
*
* This file implements functions that decode & handle keyboard events on
* MacOS X.
*
* Copyright 2001-2009, Apple Inc.
* Copyright (c) 2006-2009 Daniel A. Steffen <das@users.sourceforge.net>
* Copyright (c) 2012 Adrian Robert.
*
* See the file "license.terms" for information on usage and redistribution of
* this file, and for a DISCLAIMER OF ALL WARRANTIES.
*/
#include "tkMacOSXPrivate.h"
#include "tkMacOSXEvent.h"
/*
#ifdef TK_MAC_DEBUG
#define TK_MAC_DEBUG_KEYBOARD
#endif
*/
#define NS_KEYLOG 0
static Tk_Window grabWinPtr = NULL;
/* Current grab window, NULL if no grab. */
static Tk_Window keyboardGrabWinPtr = NULL;
/* Current keyboard grab window. */
static NSModalSession modalSession = NULL;
static BOOL processingCompose = NO;
static BOOL finishedCompose = NO;
static int caret_x = 0, caret_y = 0, caret_height = 0;
static void setupXEvent(XEvent *xEvent, NSWindow *w, unsigned int state);
static unsigned isFunctionKey(unsigned int code);
#pragma mark TKApplication(TKKeyEvent)
@implementation TKApplication(TKKeyEvent)
- (NSEvent *) tkProcessKeyEvent: (NSEvent *) theEvent
{
#ifdef TK_MAC_DEBUG_EVENTS
TKLog(@"-[%@(%p) %s] %@", [self class], self, _cmd, theEvent);
#endif
NSWindow* w;
NSEventType type = [theEvent type];
NSUInteger modifiers, len = 0;
BOOL repeat = NO;
unsigned short keyCode;
NSString *characters = nil, *charactersIgnoringModifiers = nil;
static NSUInteger savedModifiers = 0;
static NSMutableArray *nsEvArray;
if (nsEvArray == nil)
{
nsEvArray = [[NSMutableArray alloc] initWithCapacity: 1];
processingCompose = NO;
}
switch (type) {
case NSKeyUp:
if (finishedCompose)
{
// if we were composing, swallow the last release since we already sent
finishedCompose = NO;
return theEvent;
}
case NSKeyDown:
repeat = [theEvent isARepeat];
characters = [theEvent characters];
charactersIgnoringModifiers = [theEvent charactersIgnoringModifiers];
len = [charactersIgnoringModifiers length];
case NSFlagsChanged:
modifiers = [theEvent modifierFlags];
keyCode = [theEvent keyCode];
w = [self windowWithWindowNumber:[theEvent windowNumber]];
#if defined(TK_MAC_DEBUG_EVENTS) || NS_KEYLOG == 1
NSLog(@"-[%@(%p) %s] r=%d mods=%u '%@' '%@' code=%u c=%d %@ %d", [self class], self, _cmd, repeat, modifiers, characters, charactersIgnoringModifiers, keyCode,([charactersIgnoringModifiers length] == 0) ? 0 : [charactersIgnoringModifiers characterAtIndex: 0], w, type);
#endif
break;
default:
return theEvent;
}
if (!processingCompose) {
unsigned int state = 0;
if (modifiers & NSAlphaShiftKeyMask) {
state |= LockMask;
}
if (modifiers & NSShiftKeyMask) {
state |= ShiftMask;
}
if (modifiers & NSControlKeyMask) {
state |= ControlMask;
}
if (modifiers & NSCommandKeyMask) {
state |= Mod1Mask; /* command key */
}
if (modifiers & NSAlternateKeyMask) {
state |= Mod2Mask; /* option key */
}
if (modifiers & NSNumericPadKeyMask) {
state |= Mod3Mask;
}
if (modifiers & NSFunctionKeyMask) {
state |= Mod4Mask;
}
/*
* The focus must be in the FrontWindow on the Macintosh. We then query Tk
* to determine the exact Tk window that owns the focus.
*/
TkWindow *winPtr = TkMacOSXGetTkWindow(w);
Tk_Window tkwin = (Tk_Window) winPtr;
if (!tkwin) {
TkMacOSXDbgMsg("tkwin == NULL");
return theEvent;
}
tkwin = (Tk_Window) winPtr->dispPtr->focusPtr;
if (!tkwin) {
TkMacOSXDbgMsg("tkwin == NULL");
return theEvent;
}
/*
* If it's a function key, or we have modifiers other than Shift or Alt,
* pass it straight to Tk. Otherwise we'll send for input processing.
*/
int code = (len == 0) ?
0 : [charactersIgnoringModifiers characterAtIndex: 0];
if (type != NSKeyDown || isFunctionKey(code)
|| (len > 0 && state & (ControlMask | Mod1Mask | Mod3Mask | Mod4Mask))) {
XEvent xEvent;
setupXEvent(&xEvent, w, state);
if (type == NSFlagsChanged) {
if (savedModifiers > modifiers) {
xEvent.xany.type = KeyRelease;
} else {
xEvent.xany.type = KeyPress;
}
/*
* Use special '-1' to signify a special keycode to our platform
* specific code in tkMacOSXKeyboard.c. This is rather like what
* happens on Windows.
*/
xEvent.xany.send_event = -1;
/*
* Set keycode (which was zero) to the changed modifier
*/
xEvent.xkey.keycode = (modifiers ^ savedModifiers);
} else {
if (type == NSKeyUp || repeat) {
xEvent.xany.type = KeyRelease;
} else {
xEvent.xany.type = KeyPress;
}
/* For command key, take input manager's word so things
like dvorak / qwerty layout work. */
if ((modifiers & NSCommandKeyMask) == NSCommandKeyMask
&& (modifiers & NSAlternateKeyMask) != NSAlternateKeyMask
&& len > 0 && !isFunctionKey(code)) {
// head off keycode-based translation in tkMacOSXKeyboard.c
xEvent.xkey.nbytes = [characters length]; //len
}
if ([characters length] > 0) {
xEvent.xkey.keycode =
(keyCode << 16) | (UInt16) [characters characterAtIndex:0];
if (![characters getCString:xEvent.xkey.trans_chars
maxLength:XMaxTransChars encoding:NSUTF8StringEncoding]) {
/* prevent SF bug 2907388 (crash on some composite chars) */
//PENDING: we might not need this anymore
TkMacOSXDbgMsg("characters too long");
return theEvent;
}
}
if (repeat) {
Tk_QueueWindowEvent(&xEvent, TCL_QUEUE_TAIL);
xEvent.xany.type = KeyPress;
xEvent.xany.serial = LastKnownRequestProcessed(Tk_Display(tkwin));
}
}
Tk_QueueWindowEvent(&xEvent, TCL_QUEUE_TAIL);
savedModifiers = modifiers;
return theEvent;
} /* if send straight to TK */
} /* if not processing compose */
if (type == NSKeyDown) {
if (NS_KEYLOG)
fprintf (stderr, "keyDown: %s compose sequence.\n",
processingCompose == YES ? "Continue" : "Begin");
processingCompose = YES;
[nsEvArray addObject: theEvent];
[[w contentView] interpretKeyEvents: nsEvArray];
[nsEvArray removeObject: theEvent];
}
savedModifiers = modifiers;
return theEvent;
}
@end
@implementation TKContentView(TKKeyEvent)
/* <NSTextInput> implementation (called through interpretKeyEvents:]). */
/* <NSTextInput>: called when done composing;
NOTE: also called when we delete over working text, followed immed.
by doCommandBySelector: deleteBackward: */
- (void)insertText: (id)aString
{
int i, len = [(NSString *)aString length];
XEvent xEvent;
TkWindow *winPtr = TkMacOSXGetTkWindow([self window]);
Tk_Window tkwin = (Tk_Window) winPtr;
if (NS_KEYLOG)
NSLog (@"insertText '%@'\tlen = %d", aString, len);
processingCompose = NO;
finishedCompose = YES;
/* first, clear any working text */
if (_workingText != nil)
[self deleteWorkingText];
/* now insert the string as keystrokes */
setupXEvent(&xEvent, [self window], 0);
xEvent.xany.type = KeyPress;
for (i =0; i<len; i++)
{
xEvent.xkey.keycode = (UInt16) [aString characterAtIndex: i];
[[aString substringWithRange: NSMakeRange(i,1)]
getCString: xEvent.xkey.trans_chars
maxLength: XMaxTransChars encoding: NSUTF8StringEncoding];
xEvent.xkey.nbytes = strlen(xEvent.xkey.trans_chars);
xEvent.xany.type = KeyPress;
Tk_QueueWindowEvent(&xEvent, TCL_QUEUE_TAIL);
xEvent.xany.type = KeyRelease;
xEvent.xany.serial = LastKnownRequestProcessed(Tk_Display(tkwin));
Tk_QueueWindowEvent(&xEvent, TCL_QUEUE_TAIL);
xEvent.xany.serial = LastKnownRequestProcessed(Tk_Display(tkwin));
}
}
/* <NSTextInput>: inserts display of composing characters */
- (void)setMarkedText: (id)aString selectedRange: (NSRange)selRange
{
NSString *str = [aString respondsToSelector: @selector (string)] ?
[aString string] : aString;
if (NS_KEYLOG)
NSLog (@"setMarkedText '%@' len =%d range %d from %d", str, [str length],
selRange.length, selRange.location);
if (_workingText != nil)
[self deleteWorkingText];
if ([str length] == 0)
return;
processingCompose = YES;
_workingText = [str copy];
//PENDING: insert workingText underlined
}
/* delete display of composing characters [not in <NSTextInput>] */
- (void)deleteWorkingText
{
if (_workingText == nil)
return;
if (NS_KEYLOG)
NSLog(@"deleteWorkingText len = %d\n", [_workingText length]);
[_workingText release];
_workingText = nil;
processingCompose = NO;
//PENDING: delete working text
}
- (BOOL)hasMarkedText
{
return _workingText != nil;
}
- (NSRange)markedRange
{
NSRange rng = _workingText != nil
? NSMakeRange (0, [_workingText length]) : NSMakeRange (NSNotFound, 0);
if (NS_KEYLOG)
NSLog (@"markedRange request");
return rng;
}
- (void)unmarkText
{
if (NS_KEYLOG)
NSLog (@"unmark (accept) text");
[self deleteWorkingText];
processingCompose = NO;
}
/* used to position char selection windows, etc. */
- (NSRect)firstRectForCharacterRange: (NSRange)theRange
{
NSRect rect;
NSPoint pt;
pt.x = caret_x;
pt.y = caret_y;
pt = [self convertPoint: pt toView: nil];
pt = [[self window] convertBaseToScreen: pt];
pt.y -= caret_height;
rect.origin = pt;
rect.size.width = caret_height;
rect.size.height = caret_height;
return rect;
}
- (NSInteger)conversationIdentifier
{
return (NSInteger)self;
}
- (void)doCommandBySelector: (SEL)aSelector
{
if (NS_KEYLOG)
NSLog (@"doCommandBySelector: %@", NSStringFromSelector (aSelector));
processingCompose = NO;
if (aSelector == @selector (deleteBackward:))
{
/* happens when user backspaces over an ongoing composition:
throw a 'delete' into the event queue */
XEvent xEvent;
setupXEvent(&xEvent, [self window], 0);
xEvent.xany.type = KeyPress;
xEvent.xkey.nbytes = 1;
xEvent.xkey.keycode = (0x33 << 16) | 0x7F;
xEvent.xkey.trans_chars[0] = 0x7F;
xEvent.xkey.trans_chars[1] = 0x0;
Tk_QueueWindowEvent(&xEvent, TCL_QUEUE_TAIL);
}
}
- (NSArray *)validAttributesForMarkedText
{
static NSArray *arr = nil;
if (arr == nil) arr = [NSArray new];
/* [[NSArray arrayWithObject: NSUnderlineStyleAttributeName] retain]; */
return arr;
}
- (NSRange)selectedRange
{
if (NS_KEYLOG)
NSLog (@"selectedRange request");
return NSMakeRange (NSNotFound, 0);
}
- (NSUInteger)characterIndexForPoint: (NSPoint)thePoint
{
if (NS_KEYLOG)
NSLog (@"characterIndexForPoint request");
return 0;
}
- (NSAttributedString *)attributedSubstringFromRange: (NSRange)theRange
{
static NSAttributedString *str = nil;
if (str == nil) str = [NSAttributedString new];
if (NS_KEYLOG)
NSLog (@"attributedSubstringFromRange request");
return str;
}
/* End <NSTextInput> impl. */
@end
/*
* Set up basic fields in xevent for keyboard input.
*/
static void
setupXEvent(XEvent *xEvent, NSWindow *w, unsigned int state)
{
TkWindow *winPtr = TkMacOSXGetTkWindow(w);
Tk_Window tkwin = (Tk_Window) winPtr;
memset(xEvent, 0, sizeof(XEvent));
xEvent->xany.serial = LastKnownRequestProcessed(Tk_Display(tkwin));
xEvent->xany.send_event = false;
xEvent->xany.display = Tk_Display(tkwin);
xEvent->xany.window = Tk_WindowId(tkwin);
xEvent->xkey.root = XRootWindow(Tk_Display(tkwin), 0);
xEvent->xkey.subwindow = None;
xEvent->xkey.time = TkpGetMS();
xEvent->xkey.state = state;
xEvent->xkey.same_screen = true;
xEvent->xkey.trans_chars[0] = 0;
xEvent->xkey.nbytes = 0;
}
#pragma mark -
/*
*----------------------------------------------------------------------
*
* XGrabKeyboard --
*
* Simulates a keyboard grab by setting the focus.
*
* Results:
* Always returns GrabSuccess.
*
* Side effects:
* Sets the keyboard focus to the specified window.
*
*----------------------------------------------------------------------
*/
int
XGrabKeyboard(
Display* display,
Window grab_window,
Bool owner_events,
int pointer_mode,
int keyboard_mode,
Time time)
{
keyboardGrabWinPtr = Tk_IdToWindow(display, grab_window);
if (keyboardGrabWinPtr && grabWinPtr) {
NSWindow *w = TkMacOSXDrawableWindow(grab_window);
MacDrawable *macWin = (MacDrawable *) grab_window;
if (w && macWin->toplevel->winPtr == (TkWindow*) grabWinPtr) {
if (modalSession) {
Tcl_Panic("XGrabKeyboard: already grabbed");
}
modalSession = [NSApp beginModalSessionForWindow:[w retain]];
}
}
return GrabSuccess;
}
/*
*----------------------------------------------------------------------
*
* XUngrabKeyboard --
*
* Releases the simulated keyboard grab.
*
* Results:
* None.
*
* Side effects:
* Sets the keyboard focus back to the value before the grab.
*
*----------------------------------------------------------------------
*/
void
XUngrabKeyboard(
Display* display,
Time time)
{
if (modalSession) {
NSWindow *w = keyboardGrabWinPtr ? TkMacOSXDrawableWindow(
((TkWindow *) keyboardGrabWinPtr)->window) : nil;
[NSApp endModalSession:modalSession];
[w release];
modalSession = NULL;
}
keyboardGrabWinPtr = NULL;
}
/*
*----------------------------------------------------------------------
*
* TkMacOSXGetCapture --
*
* Results:
* Returns the current grab window
*
* Side effects:
* None.
*
*----------------------------------------------------------------------
*/
Tk_Window
TkMacOSXGetCapture(void)
{
return grabWinPtr;
}
/*
*----------------------------------------------------------------------
*
* TkMacOSXGetModalSession --
*
* Results:
* Returns the current modal session
*
* Side effects:
* None.
*
*----------------------------------------------------------------------
*/
MODULE_SCOPE NSModalSession
TkMacOSXGetModalSession(void)
{
return modalSession;
}
/*
*----------------------------------------------------------------------
*
* TkpSetCapture --
*
* This function captures the mouse so that all future events will be
* reported to this window, even if the mouse is outside the window. If
* the specified window is NULL, then the mouse is released.
*
* Results:
* None.
*
* Side effects:
* Sets the capture flag and captures the mouse.
*
*----------------------------------------------------------------------
*/
void
TkpSetCapture(
TkWindow *winPtr) /* Capture window, or NULL. */
{
while (winPtr && !Tk_IsTopLevel(winPtr)) {
winPtr = winPtr->parentPtr;
}
grabWinPtr = (Tk_Window) winPtr;
}
/*
*----------------------------------------------------------------------
*
* Tk_SetCaretPos --
*
* This enables correct placement of the XIM caret. This is called by
* widgets to indicate their cursor placement, and the caret location is
* used by TkpGetString to place the XIM caret.
*
* Results:
* None
*
* Side effects:
* None
*
*----------------------------------------------------------------------
*/
void
Tk_SetCaretPos(
Tk_Window tkwin,
int x,
int y,
int height)
{
TkCaret *caretPtr = &(((TkWindow *) tkwin)->dispPtr->caret);
/*
* Prevent processing anything if the values haven't changed. Windows only
* has one display, so we can do this with statics.
*/
if ((caretPtr->winPtr == ((TkWindow *) tkwin))
&& (caretPtr->x == x) && (caretPtr->y == y)) {
return;
}
caretPtr->winPtr = ((TkWindow *) tkwin);
caretPtr->x = x;
caretPtr->y = y;
caretPtr->height = height;
/*
* As in Windows, adjust to the toplevel to get the coords right.
*/
while (!Tk_IsTopLevel(tkwin)) {
x += Tk_X(tkwin);
y += Tk_Y(tkwin);
tkwin = Tk_Parent(tkwin);
if (tkwin == NULL) {
return;
}
}
/* But adjust for fact that NS uses flipped view. */
y = Tk_Height(tkwin) - y;
caret_x = x;
caret_y = y;
caret_height = height;
}
static unsigned convert_ns_to_X_keysym[] =
{
NSHomeFunctionKey, 0x50,
NSLeftArrowFunctionKey, 0x51,
NSUpArrowFunctionKey, 0x52,
NSRightArrowFunctionKey, 0x53,
NSDownArrowFunctionKey, 0x54,
NSPageUpFunctionKey, 0x55,
NSPageDownFunctionKey, 0x56,
NSEndFunctionKey, 0x57,
NSBeginFunctionKey, 0x58,
NSSelectFunctionKey, 0x60,
NSPrintFunctionKey, 0x61,
NSExecuteFunctionKey, 0x62,
NSInsertFunctionKey, 0x63,
NSUndoFunctionKey, 0x65,
NSRedoFunctionKey, 0x66,
NSMenuFunctionKey, 0x67,
NSFindFunctionKey, 0x68,
NSHelpFunctionKey, 0x6A,
NSBreakFunctionKey, 0x6B,
NSF1FunctionKey, 0xBE,
NSF2FunctionKey, 0xBF,
NSF3FunctionKey, 0xC0,
NSF4FunctionKey, 0xC1,
NSF5FunctionKey, 0xC2,
NSF6FunctionKey, 0xC3,
NSF7FunctionKey, 0xC4,
NSF8FunctionKey, 0xC5,
NSF9FunctionKey, 0xC6,
NSF10FunctionKey, 0xC7,
NSF11FunctionKey, 0xC8,
NSF12FunctionKey, 0xC9,
NSF13FunctionKey, 0xCA,
NSF14FunctionKey, 0xCB,
NSF15FunctionKey, 0xCC,
NSF16FunctionKey, 0xCD,
NSF17FunctionKey, 0xCE,
NSF18FunctionKey, 0xCF,
NSF19FunctionKey, 0xD0,
NSF20FunctionKey, 0xD1,
NSF21FunctionKey, 0xD2,
NSF22FunctionKey, 0xD3,
NSF23FunctionKey, 0xD4,
NSF24FunctionKey, 0xD5,
NSBackspaceCharacter, 0x08, /* 8: Not on some KBs. */
NSDeleteCharacter, 0xFF, /* 127: Big 'delete' key upper right. */
NSDeleteFunctionKey, 0x9F, /* 63272: Del forw key off main array. */
NSTabCharacter, 0x09,
0x19, 0x09, /* left tab->regular since pass shift */
NSCarriageReturnCharacter, 0x0D,
NSNewlineCharacter, 0x0D,
NSEnterCharacter, 0x8D,
0x1B, 0x1B /* escape */
};
static unsigned isFunctionKey(unsigned code)
{
const unsigned last_keysym = (sizeof (convert_ns_to_X_keysym)
/ sizeof (convert_ns_to_X_keysym[0]));
unsigned keysym;
for (keysym = 0; keysym < last_keysym; keysym += 2)
if (code == convert_ns_to_X_keysym[keysym])
return 0xFF00 | convert_ns_to_X_keysym[keysym+1];
return 0;
}
/*
* Local Variables:
* mode: objc
* c-basic-offset: 4
* fill-column: 79
* coding: utf-8
* End:
*/

914
macosx/tkMacOSXKeyboard.c Normal file
View File

@@ -0,0 +1,914 @@
/*
* tkMacOSXKeyboard.c --
*
* Routines to support keyboard events on the Macintosh.
*
* Copyright (c) 1995-1997 Sun Microsystems, Inc.
* Copyright 2001-2009, Apple Inc.
* Copyright (c) 2005-2009 Daniel A. Steffen <das@users.sourceforge.net>
*
* See the file "license.terms" for information on usage and redistribution
* of this file, and for a DISCLAIMER OF ALL WARRANTIES.
*/
#include "tkMacOSXPrivate.h"
#include "tkMacOSXEvent.h"
/*
* A couple of simple definitions to make code a bit more self-explaining.
*
* For the assignments of Mod1==meta==command and Mod2==alt==option, see also
* tkMacOSXMouseEvent.c.
*/
#define LATIN1_MAX 255
#define MAC_KEYCODE_MAX 0x7F
#define MAC_KEYCODE_MASK 0x7F
#define COMMAND_MASK Mod1Mask
#define OPTION_MASK Mod2Mask
/*
* Tables enumerating the special keys defined on Mac keyboards. These are
* necessary for correct keysym mappings for all keys where the keysyms are
* not identical with their ASCII or Latin-1 code points.
*/
typedef struct {
int keycode; /* Macintosh keycode. */
KeySym keysym; /* X windows keysym. */
} KeyInfo;
/*
* Notes on keyArray:
*
* 0x34, XK_Return - Powerbooks use this and some keymaps define it.
*
* 0x4C, XK_Return - XFree86 and Apple's X11 call this one XK_KP_Enter.
*
* 0x47, XK_Clear - This key is NumLock when used on PCs, but Mac
* applications don't use it like that, nor does Apple's X11.
*
* All other keycodes are taken from the published ADB keyboard layouts.
*/
static KeyInfo keyArray[] = {
{0x24, XK_Return},
{0x30, XK_Tab},
{0x33, XK_BackSpace},
{0x34, XK_Return},
{0x35, XK_Escape},
{0x47, XK_Clear},
{0x4C, XK_KP_Enter},
{0x72, XK_Help},
{0x73, XK_Home},
{0x74, XK_Page_Up},
{0x75, XK_Delete},
{0x77, XK_End},
{0x79, XK_Page_Down},
{0x7B, XK_Left},
{0x7C, XK_Right},
{0x7D, XK_Down},
{0x7E, XK_Up},
{0, 0}
};
static KeyInfo virtualkeyArray[] = {
{122, XK_F1},
{120, XK_F2},
{99, XK_F3},
{118, XK_F4},
{96, XK_F5},
{97, XK_F6},
{98, XK_F7},
{100, XK_F8},
{101, XK_F9},
{109, XK_F10},
{103, XK_F11},
{111, XK_F12},
{105, XK_F13},
{107, XK_F14},
{113, XK_F15},
{0, 0}
};
static int initialized = 0;
static Tcl_HashTable keycodeTable; /* keyArray hashed by keycode value. */
static Tcl_HashTable vkeyTable; /* virtualkeyArray hashed by virtual
* keycode value. */
static int latin1Table[LATIN1_MAX+1]; /* Reverse mapping table for
* controls, ASCII and Latin-1. */
static int keyboardChanged = 1;
/*
* Prototypes for static functions used in this file.
*/
static void InitKeyMaps (void);
static void InitLatin1Table(Display *display);
static int XKeysymToMacKeycode(Display *display, KeySym keysym);
static int KeycodeToUnicode(UniChar * uniChars, int maxChars,
UInt16 keyaction, UInt32 keycode, UInt32 modifiers,
UInt32 * deadKeyStatePtr);
#pragma mark TKApplication(TKKeyboard)
@implementation TKApplication(TKKeyboard)
- (void) keyboardChanged: (NSNotification *) notification
{
#ifdef TK_MAC_DEBUG_NOTIFICATIONS
TKLog(@"-[%@(%p) %s] %@", [self class], self, _cmd, notification);
#endif
keyboardChanged = 1;
}
@end
#pragma mark -
/*
*----------------------------------------------------------------------
*
* InitKeyMaps --
*
* Creates hash tables used by some of the functions in this file.
*
* FIXME: As keycodes are defined to be in the limited range 0-127, it
* would be easier and more efficient to use directly initialized plain
* arrays and drop this function.
*
* Results:
* None.
*
* Side effects:
* Allocates memory & creates some hash tables.
*
*----------------------------------------------------------------------
*/
static void
InitKeyMaps(void)
{
Tcl_HashEntry *hPtr;
KeyInfo *kPtr;
int dummy;
Tcl_InitHashTable(&keycodeTable, TCL_ONE_WORD_KEYS);
for (kPtr = keyArray; kPtr->keycode != 0; kPtr++) {
hPtr = Tcl_CreateHashEntry(&keycodeTable, INT2PTR(kPtr->keycode),
&dummy);
Tcl_SetHashValue(hPtr, kPtr->keysym);
}
Tcl_InitHashTable(&vkeyTable, TCL_ONE_WORD_KEYS);
for (kPtr = virtualkeyArray; kPtr->keycode != 0; kPtr++) {
hPtr = Tcl_CreateHashEntry(&vkeyTable, INT2PTR(kPtr->keycode),
&dummy);
Tcl_SetHashValue(hPtr, kPtr->keysym);
}
initialized = 1;
}
/*
*----------------------------------------------------------------------
*
* InitLatin1Table --
*
* Creates a simple table to be used for mapping from keysyms to keycodes.
* Always needs to be called before using latin1Table, because the
* keyboard layout may have changed, and than the table must be
* re-computed.
*
* Results:
* None.
*
* Side effects:
* Sets the global latin1Table.
*
*----------------------------------------------------------------------
*/
static void
InitLatin1Table(
Display *display)
{
int keycode;
KeySym keysym;
int state;
int modifiers;
memset(latin1Table, 0, sizeof(latin1Table));
/*
* In the common X11 implementations, a keymap has four columns
* "plain", "Shift", "Mode_switch" and "Mode_switch + Shift". We don't
* use "Mode_switch", but we use "Option" instead. (This is similar to
* Apple's X11 implementation, where "Mode_switch" is used as an alias
* for "Option".)
*
* So here we go through all 4 columns of the keymap and find all
* Latin-1 compatible keycodes. We go through the columns back-to-front
* from the more exotic columns to the more simple, so that simple
* keycode-modifier combinations are preferred in the resulting table.
*/
for (state = 3; state >= 0; state--) {
modifiers = 0;
if (state & 1) {
modifiers |= shiftKey;
}
if (state & 2) {
modifiers |= optionKey;
}
for (keycode = 0; keycode <= MAC_KEYCODE_MAX; keycode++) {
keysym = XKeycodeToKeysym(display,keycode<<16,state);
if (keysym <= LATIN1_MAX) {
latin1Table[keysym] = keycode | modifiers;
}
}
}
}
/*
*----------------------------------------------------------------------
*
* KeycodeToUnicode --
*
* Given MacOS key event data this function generates the Unicode
* characters. It does this using OS resources and APIs.
*
* The parameter deadKeyStatePtr can be NULL, if no deadkey handling is
* needed.
*
* This function is called from XKeycodeToKeysym() in tkMacOSKeyboard.c.
*
* Results:
* The number of characters generated if any, 0 if we are waiting for
* another byte of a dead-key sequence. Fills in the uniChars array with a
* Unicode string.
*
* Side Effects:
* None
*
*----------------------------------------------------------------------
*/
static int
KeycodeToUnicode(
UniChar *uniChars,
int maxChars,
UInt16 keyaction,
UInt32 keycode,
UInt32 modifiers,
UInt32 *deadKeyStatePtr)
{
static const void *uchr = NULL;
static UInt32 keyboardType = 0;
UniCharCount actuallength = 0;
if (keyboardChanged) {
TISInputSourceRef currentKeyboardLayout =
TISCopyCurrentKeyboardLayoutInputSource();
if (currentKeyboardLayout) {
CFDataRef keyLayoutData = (CFDataRef) TISGetInputSourceProperty(
currentKeyboardLayout, kTISPropertyUnicodeKeyLayoutData);
if (keyLayoutData) {
uchr = CFDataGetBytePtr(keyLayoutData);
keyboardType = LMGetKbdType();
}
CFRelease(currentKeyboardLayout);
}
keyboardChanged = 0;
}
if (uchr) {
OptionBits options = 0;
UInt32 dummyState;
OSStatus err;
keycode &= 0xFF;
modifiers = (modifiers >> 8) & 0xFF;
if (!deadKeyStatePtr) {
options = kUCKeyTranslateNoDeadKeysMask;
dummyState = 0;
deadKeyStatePtr = &dummyState;
}
err = ChkErr(UCKeyTranslate, uchr, keycode, keyaction, modifiers,
keyboardType, options, deadKeyStatePtr, maxChars,
&actuallength, uniChars);
if (!actuallength && *deadKeyStatePtr) {
/*
* More data later
*/
return 0;
}
*deadKeyStatePtr = 0;
if (err != noErr) {
actuallength = 0;
}
}
return actuallength;
}
/*
*----------------------------------------------------------------------
*
* XKeycodeToKeysym --
*
* Translate from a system-dependent keycode to a system-independent
* keysym.
*
* Results:
* Returns the translated keysym, or NoSymbol on failure.
*
* Side effects:
* None.
*
*----------------------------------------------------------------------
*/
KeySym
XKeycodeToKeysym(
Display* display,
KeyCode keycode,
int index)
{
register Tcl_HashEntry *hPtr;
int newKeycode;
UniChar newChar;
(void) display; /*unused*/
if (!initialized) {
InitKeyMaps();
}
/*
* When determining what keysym to produce we first check to see if the key
* is a function key. We then check to see if the character is another
* non-printing key. Finally, we return the key syms for all ASCII and
* Latin-1 chars.
*/
newKeycode = keycode >> 16;
if ((keycode & 0xFFFF) >= 0xF700) { /* NSEvent.h function key unicodes */
hPtr = Tcl_FindHashEntry(&vkeyTable, INT2PTR(newKeycode));
if (hPtr != NULL) {
return (KeySym) Tcl_GetHashValue(hPtr);
}
}
hPtr = Tcl_FindHashEntry(&keycodeTable, INT2PTR(newKeycode));
if (hPtr != NULL) {
return (KeySym) Tcl_GetHashValue(hPtr);
}
/*
* Add in the Mac modifier flags for shift and option.
*/
if (index & 1) {
newKeycode |= shiftKey;
}
if (index & 2) {
newKeycode |= optionKey;
}
newChar = 0;
KeycodeToUnicode(&newChar, 1, kUCKeyActionDown, newKeycode & 0x00FF,
newKeycode & 0xFF00, NULL);
/*
* X11 keysyms are identical to Unicode for ASCII and Latin-1. Give up for
* other characters for now.
*/
if ((newChar >= XK_space) && (newChar <= LATIN1_MAX)) {
return newChar;
}
return NoSymbol;
}
/*
*----------------------------------------------------------------------
*
* TkpGetString --
*
* Retrieve the string equivalent for the given keyboard event.
*
* Results:
* Returns the UTF string.
*
* Side effects:
* None.
*
*----------------------------------------------------------------------
*/
char *
TkpGetString(
TkWindow *winPtr, /* Window where event occurred: Needed to get
* input context. */
XEvent *eventPtr, /* X keyboard event. */
Tcl_DString *dsPtr) /* Uninitialized or empty string to hold
* result. */
{
(void) winPtr; /*unused*/
Tcl_DStringInit(dsPtr);
return Tcl_DStringAppend(dsPtr, eventPtr->xkey.trans_chars, -1);
}
/*
*----------------------------------------------------------------------
*
* XGetModifierMapping --
*
* Fetch the current keycodes used as modifiers.
*
* Results:
* Returns a new modifier map.
*
* Side effects:
* Allocates a new modifier map data structure.
*
*----------------------------------------------------------------------
*/
XModifierKeymap *
XGetModifierMapping(
Display *display)
{
XModifierKeymap *modmap;
(void) display; /*unused*/
/*
* MacOSX doesn't use the key codes for the modifiers for anything, and we
* don't generate them either. So there is no modifier map.
*/
modmap = (XModifierKeymap *) ckalloc(sizeof(XModifierKeymap));
modmap->max_keypermod = 0;
modmap->modifiermap = NULL;
return modmap;
}
/*
*----------------------------------------------------------------------
*
* XFreeModifiermap --
*
* Deallocate a modifier map that was created by XGetModifierMapping.
*
* Results:
* None.
*
* Side effects:
* Frees the datastructure referenced by modmap.
*
*----------------------------------------------------------------------
*/
int
XFreeModifiermap(
XModifierKeymap *modmap)
{
if (modmap->modifiermap != NULL) {
ckfree((char *) modmap->modifiermap);
}
ckfree((char *) modmap);
return Success;
}
/*
*----------------------------------------------------------------------
*
* XKeysymToString, XStringToKeysym --
*
* These X window functions map keysyms to strings & strings to keysyms.
* However, Tk already does this for the most common keysyms. Therefore,
* these functions only need to support keysyms that will be specific to
* the Macintosh. Currently, there are none.
*
* Results:
* None.
*
* Side effects:
* None.
*
*----------------------------------------------------------------------
*/
char *
XKeysymToString(
KeySym keysym)
{
return NULL;
}
KeySym
XStringToKeysym(
const char* string)
{
return NoSymbol;
}
/*
*----------------------------------------------------------------------
*
* XKeysymToMacKeycode --
*
* An internal function like XKeysymToKeycode but only generating the Mac
* specific keycode plus the modifiers Shift and Option.
*
* Results:
* A Mac keycode with the actual keycode in the low byte and Mac-style
* modifier bits in the high byte.
*
* Side effects:
* None.
*
*----------------------------------------------------------------------
*/
static int
XKeysymToMacKeycode(
Display *display,
KeySym keysym)
{
KeyInfo *kPtr;
if (keysym <= LATIN1_MAX) {
/*
* Handle keysyms in the Latin-1 range where keysym and Unicode
* character code point are the same.
*/
if (keyboardChanged) {
InitLatin1Table(display);
keyboardChanged = 0;
}
return latin1Table[keysym];
}
/*
* Handle special keys from our exception tables. Don't mind if this is
* slow, neither the test suite nor [event generate] need to be optimized
* (we hope).
*/
for (kPtr = keyArray; kPtr->keycode != 0; kPtr++) {
if (kPtr->keysym == keysym) {
return kPtr->keycode;
}
}
for (kPtr = virtualkeyArray; kPtr->keycode != 0; kPtr++) {
if (kPtr->keysym == keysym) {
return kPtr->keycode;
}
}
/*
* For other keysyms (not Latin-1 and not special keys), we'd need a
* generic keysym-to-unicode table. We don't have that, so we give up here.
*/
return 0;
}
/*
*----------------------------------------------------------------------
*
* XKeysymToKeycode --
*
* The function XKeysymToKeycode takes an X11 keysym and converts it into
* a Mac keycode. It is in the stubs table for compatibility but not used
* anywhere in the core.
*
* Results:
* A 32 bit keycode with the the mac keycode (without modifiers) in the
* higher 16 bits of the keycode and the ASCII or Latin-1 code in the
* lower 8 bits of the keycode.
*
* Side effects:
* None.
*
*----------------------------------------------------------------------
*/
KeyCode
XKeysymToKeycode(
Display* display,
KeySym keysym)
{
int macKeycode = XKeysymToMacKeycode(display, keysym);
KeyCode result;
/*
* See also TkpSetKeycodeAndState. The 0x0010 magic is used in
* XKeycodeToKeysym. For special keys like XK_Return the lower 8 bits of
* the keysym are usually a related ASCII control code.
*/
if ((keysym >= XK_F1) && (keysym <= XK_F35)) {
result = 0x0010;
} else {
result = 0x00FF & keysym;
}
result |= (macKeycode & MAC_KEYCODE_MASK) << 16;
return result;
}
/*
*----------------------------------------------------------------------
*
* TkpSetKeycodeAndState --
*
* The function TkpSetKeycodeAndState takes a keysym and fills in the
* appropriate members of an XEvent. It is similar to XKeysymToKeycode,
* but it also sets the modifier mask in the XEvent. It is used by [event
* generate] and it is in the stubs table.
*
* Results:
* Fills an XEvent, sets the member xkey.keycode with a keycode
* formatted the same as XKeysymToKeycode and the member xkey.state with
* the modifiers implied by the keysym. Also fills in xkey.trans_chars,
* so that the actual characters can be retrieved later.
*
* Side effects:
* None.
*
*----------------------------------------------------------------------
*/
void
TkpSetKeycodeAndState(
Tk_Window tkwin,
KeySym keysym,
XEvent *eventPtr)
{
if (keysym == NoSymbol) {
eventPtr->xkey.keycode = 0;
} else {
Display *display = Tk_Display(tkwin);
int macKeycode = XKeysymToMacKeycode(display, keysym);
/*
* See also XKeysymToKeycode.
*/
if ((keysym >= XK_F1) && (keysym <= XK_F35)) {
eventPtr->xkey.keycode = 0x0010;
} else {
eventPtr->xkey.keycode = 0x00FF & keysym;
}
eventPtr->xkey.keycode |= (macKeycode & MAC_KEYCODE_MASK) << 16;
if (shiftKey & macKeycode) {
eventPtr->xkey.state |= ShiftMask;
}
if (optionKey & macKeycode) {
eventPtr->xkey.state |= OPTION_MASK;
}
if (keysym <= LATIN1_MAX) {
int done = Tcl_UniCharToUtf(keysym, eventPtr->xkey.trans_chars);
eventPtr->xkey.trans_chars[done] = 0;
} else {
eventPtr->xkey.trans_chars[0] = 0;
}
}
}
/*
*----------------------------------------------------------------------
*
* TkpGetKeySym --
*
* Given an X KeyPress or KeyRelease event, map the keycode in the event
* into a keysym.
*
* Results:
* The return value is the keysym corresponding to eventPtr, or NoSymbol
* if no matching keysym could be found.
*
* Side effects:
* In the first call for a given display, keycode-to-keysym maps get
* loaded.
*
*----------------------------------------------------------------------
*/
KeySym
TkpGetKeySym(
TkDisplay *dispPtr, /* Display in which to map keycode. */
XEvent *eventPtr) /* Description of X event. */
{
KeySym sym;
int index;
/*
* Refresh the mapping information if it's stale.
*/
if (dispPtr->bindInfoStale) {
TkpInitKeymapInfo(dispPtr);
}
/*
* Handle pure modifier keys specially. We use -1 as a signal for
* this.
*/
if (eventPtr->xany.send_event == -1) {
int modifier = eventPtr->xkey.keycode;
if (modifier == NSCommandKeyMask) {
return XK_Meta_L;
} else if (modifier == NSShiftKeyMask) {
return XK_Shift_L;
} else if (modifier == NSAlphaShiftKeyMask) {
return XK_Caps_Lock;
} else if (modifier == NSAlternateKeyMask) {
return XK_Alt_L;
} else if (modifier == NSControlKeyMask) {
return XK_Control_L;
} else if (modifier == NSNumericPadKeyMask) {
return XK_Num_Lock;
} else if (modifier == NSFunctionKeyMask) {
return XK_Super_L;
/*
} else if (modifier == rightShiftKey) {
return XK_Shift_R;
} else if (modifier == rightOptionKey) {
return XK_Alt_R;
} else if (modifier == rightControlKey) {
return XK_Control_R;
*/
} else {
/*
* If we get here, we probably need to implement something new.
*/
return NoSymbol;
}
}
/* If nbytes has been set, it's not a function key, but a regular key that
has been translated in tkMacOSXKeyEvent.c; just use that. */
if (eventPtr->xkey.nbytes) {
return eventPtr->xkey.keycode & 0xFFFF;
}
/*
* Figure out which of the four slots in the keymap vector to use for this
* key. Refer to Xlib documentation for more info on how this computation
* works. (Note: We use "Option" in keymap columns 2 and 3 where other
* implementations have "Mode_switch".)
*/
index = 0;
/*
* We want Option key combinations to use their base chars as keysyms, so
* we ignore the option modifier here.
*/
#if 0
if (eventPtr->xkey.state & OPTION_MASK) {
index |= 2;
}
#endif
if ((eventPtr->xkey.state & ShiftMask)
|| (/* (dispPtr->lockUsage != LU_IGNORE)
&& */ (eventPtr->xkey.state & LockMask))) {
index |= 1;
}
/*
* First try of the actual translation.
*/
sym = XKeycodeToKeysym(dispPtr->display, eventPtr->xkey.keycode, index);
/*
* Special handling: If the key was shifted because of Lock, but lock is
* only caps lock, not shift lock, and the shifted keysym isn't upper-case
* alphabetic, then switch back to the unshifted keysym.
*/
if ((index & 1) && !(eventPtr->xkey.state & ShiftMask)
/*&& (dispPtr->lockUsage == LU_CAPS)*/ ) {
/*
* FIXME: Keysyms are only identical to Unicode for ASCII and Latin-1,
* so we can't use Tcl_UniCharIsUpper() for keysyms outside that range.
* This may be a serious problem here.
*/
if ((sym == NoSymbol) || (sym > LATIN1_MAX)
|| !Tcl_UniCharIsUpper(sym)) {
index &= ~1;
sym = XKeycodeToKeysym(dispPtr->display, eventPtr->xkey.keycode,
index);
}
}
/*
* Another bit of special handling: If this is a shifted key and there is
* no keysym defined, then use the keysym for the unshifted key.
*/
if ((index & 1) && (sym == NoSymbol)) {
sym = XKeycodeToKeysym(dispPtr->display, eventPtr->xkey.keycode,
index & ~1);
}
return sym;
}
/*
*--------------------------------------------------------------
*
* TkpInitKeymapInfo --
*
* This procedure is invoked to scan keymap information to recompute stuff
* that's important for binding, such as the modifier key (if any) that
* corresponds to the "Mode_switch" keysym.
*
* Results:
* None.
*
* Side effects:
* Keymap-related information in dispPtr is updated.
*
*--------------------------------------------------------------
*/
void
TkpInitKeymapInfo(
TkDisplay *dispPtr) /* Display for which to recompute keymap
* information. */
{
dispPtr->bindInfoStale = 0;
/*
* Behaviours that are variable on X11 are defined constant on MacOSX.
* lockUsage is only used above in TkpGetKeySym(), nowhere else currently.
* There is no offical "Mode_switch" key.
*/
dispPtr->lockUsage = LU_CAPS;
dispPtr->modeModMask = 0;
#if 0
/*
* With this, <Alt> and <Meta> become synonyms for <Command> and <Option>
* in bindings like they are (and always have been) in the keysyms that
* are reported by KeyPress events. But the init scripts like text.tcl
* have some disabling bindings for <Meta>, so we don't want this without
* some changes in those scripts. See also bug #700311.
*/
dispPtr->altModMask = OPTION_MASK;
dispPtr->metaModMask = COMMAND_MASK;
#else
dispPtr->altModMask = 0;
dispPtr->metaModMask = 0;
#endif
/*
* MacOSX doesn't use the keycodes for the modifiers for anything, and we
* don't generate them either (the keycodes actually given in the simulated
* modifier events are bogus). So there is no modifier map. If we ever want
* to simulate real modifier keycodes, the list will be constant in the
* Carbon implementation.
*/
if (dispPtr->modKeyCodes != NULL) {
ckfree((char *) dispPtr->modKeyCodes);
}
dispPtr->numModKeyCodes = 0;
dispPtr->modKeyCodes = NULL;
}
/*
* Local Variables:
* mode: objc
* c-basic-offset: 4
* fill-column: 79
* coding: utf-8
* End:
*/

1763
macosx/tkMacOSXMenu.c Normal file

File diff suppressed because it is too large Load Diff

474
macosx/tkMacOSXMenubutton.c Normal file
View File

@@ -0,0 +1,474 @@
/*
* tkMacOSXMenubutton.c --
*
* This file implements the Macintosh specific portion of the
* menubutton widget.
*
* Copyright (c) 1996 by Sun Microsystems, Inc.
* Copyright 2001-2009, Apple Inc.
* Copyright (c) 2006-2009 Daniel A. Steffen <das@users.sourceforge.net>
*
* See the file "license.terms" for information on usage and redistribution
* of this file, and for a DISCLAIMER OF ALL WARRANTIES.
*/
#include "tkMacOSXPrivate.h"
#include "tkMenubutton.h"
#include "tkMacOSXFont.h"
#include "tkMacOSXDebug.h"
/*
#ifdef TK_MAC_DEBUG
#define TK_MAC_DEBUG_MENUBUTTON
#endif
*/
typedef struct MacMenuButton {
TkMenuButton info;
NSPopUpButton *button;
#if TK_MAC_BUTTON_USE_COMPATIBILITY_METRICS
int fix;
#endif
} MacMenuButton;
#if TK_MAC_BUTTON_USE_COMPATIBILITY_METRICS
/*
* Use the following heuristic conversion constants to make NSButton-based
* widget metrics match up with the old Carbon control buttons (for the
* default Lucida Grande 13 font).
* TODO: provide a scriptable way to turn this off and use the raw NSButton
* metrics (will also need dynamic adjustment of the default padding,
* c.f. tkMacOSXDefault.h).
*/
typedef struct {
int trimW, trimH, inset, shrinkW, offsetX, offsetY;
} BoundsFix;
#define fixForStyle(style) ( \
style == NSRoundedBezelStyle ? 1 : \
style == NSRegularSquareBezelStyle ? 2 : \
style == NSShadowlessSquareBezelStyle ? 3 : \
INT_MIN)
static const BoundsFix boundsFixes[] = {
[fixForStyle(NSRoundedBezelStyle)] = { 14, 10, -2, -1},
[fixForStyle(NSRegularSquareBezelStyle)] = { 6, 13, -2, 1, 1},
[fixForStyle(NSShadowlessSquareBezelStyle)] = { 15, 0, 2 },
};
#endif
/*
* Forward declarations for procedures defined later in this file:
*/
static void MenuButtonEventProc(ClientData clientData, XEvent *eventPtr);
/*
* The structure below defines menubutton class behavior by means of functions
* that can be invoked from generic window code.
*/
Tk_ClassProcs tkpMenubuttonClass = {
sizeof(Tk_ClassProcs), /* size */
TkMenuButtonWorldChanged, /* worldChangedProc */
};
/*
*----------------------------------------------------------------------
*
* TkpCreateMenuButton --
*
* Allocate a new TkMenuButton structure.
*
* Results:
* Returns a newly allocated TkMenuButton structure.
*
* Side effects:
* Registers an event handler for the widget.
*
*----------------------------------------------------------------------
*/
TkMenuButton *
TkpCreateMenuButton(
Tk_Window tkwin)
{
MacMenuButton *macButtonPtr =
(MacMenuButton *) ckalloc(sizeof(MacMenuButton));
macButtonPtr->button = nil;
Tk_CreateEventHandler(tkwin, ActivateMask,
MenuButtonEventProc, (ClientData) macButtonPtr);
return (TkMenuButton *) macButtonPtr;
}
/*
*----------------------------------------------------------------------
*
* TkpDestroyMenuButton --
*
* Free data structures associated with the menubutton control.
*
* Results:
* None.
*
* Side effects:
* Restores the default control state.
*
*----------------------------------------------------------------------
*/
void
TkpDestroyMenuButton(
TkMenuButton *mbPtr)
{
MacMenuButton *macButtonPtr = (MacMenuButton *) mbPtr;
TkMacOSXMakeCollectableAndRelease(macButtonPtr->button);
}
/*
*----------------------------------------------------------------------
*
* TkpDisplayMenuButton --
*
* This function is invoked to display a menubutton widget.
*
* Results:
* None.
*
* Side effects:
* Commands are output to X to display the menubutton in its current
* mode.
*
*----------------------------------------------------------------------
*/
void
TkpDisplayMenuButton(
ClientData clientData) /* Information about widget. */
{
TkMenuButton *mbPtr = (TkMenuButton *) clientData;
MacMenuButton *macButtonPtr = (MacMenuButton *) mbPtr;
NSPopUpButton *button = macButtonPtr->button;
Tk_Window tkwin = mbPtr->tkwin;
TkWindow *winPtr = (TkWindow *) tkwin;
MacDrawable *macWin = (MacDrawable *) winPtr->window;
TkMacOSXDrawingContext dc;
NSView *view = TkMacOSXDrawableView(macWin);
CGFloat viewHeight = [view bounds].size.height;
CGAffineTransform t = { .a = 1, .b = 0, .c = 0, .d = -1, .tx = 0,
.ty = viewHeight};
NSRect frame;
int enabled;
mbPtr->flags &= ~REDRAW_PENDING;
if (!tkwin || !Tk_IsMapped(tkwin) || !view ||
!TkMacOSXSetupDrawingContext((Drawable) macWin, NULL, 1, &dc)) {
return;
}
CGContextConcatCTM(dc.context, t);
Tk_Fill3DRectangle(tkwin, (Pixmap) macWin, mbPtr->normalBorder, 0, 0,
Tk_Width(tkwin), Tk_Height(tkwin), 0, TK_RELIEF_FLAT);
if ([button superview] != view) {
[view addSubview:button];
}
enabled = !(mbPtr->state == STATE_DISABLED);
[button setEnabled:enabled];
if (enabled) {
[[button cell] setHighlighted:(mbPtr->state == STATE_ACTIVE)];
}
frame = NSMakeRect(macWin->xOff, macWin->yOff, Tk_Width(tkwin),
Tk_Height(tkwin));
frame = NSInsetRect(frame, mbPtr->inset, mbPtr->inset);
#if TK_MAC_BUTTON_USE_COMPATIBILITY_METRICS
if (tkMacOSXUseCompatibilityMetrics) {
BoundsFix boundsFix = boundsFixes[macButtonPtr->fix];
frame = NSOffsetRect(frame, boundsFix.offsetX, boundsFix.offsetY);
frame.size.width -= boundsFix.shrinkW;
frame = NSInsetRect(frame, boundsFix.inset, boundsFix.inset);
}
#endif
frame.origin.y = viewHeight - (frame.origin.y + frame.size.height);
if (!NSEqualRects(frame, [button frame])) {
[button setFrame:frame];
}
[button displayRectIgnoringOpacity:[button bounds]];
TkMacOSXRestoreDrawingContext(&dc);
#ifdef TK_MAC_DEBUG_MENUBUTTON
TKLog(@"menubutton %s frame %@ width %d height %d",
((TkWindow *)mbPtr->tkwin)->pathName, NSStringFromRect(frame),
Tk_Width(tkwin), Tk_Height(tkwin));
#endif
}
/*
*----------------------------------------------------------------------
*
* TkpComputeMenuButtonGeometry --
*
* After changes in a menu button's text or bitmap, this function
* recomputes the menu button's geometry and passes this information
* along to the geometry manager for the window.
*
* Results:
* None.
*
* Side effects:
* The menu button's window may change size.
*
*----------------------------------------------------------------------
*/
void
TkpComputeMenuButtonGeometry(
TkMenuButton *mbPtr) /* Widget record for menu button. */
{
MacMenuButton *macButtonPtr = (MacMenuButton *) mbPtr;
NSPopUpButton *button = macButtonPtr->button;
NSPopUpButtonCell *cell;
NSMenuItem *menuItem;
NSBezelStyle style = NSRoundedBezelStyle;
NSFont *font;
NSRect bounds = NSZeroRect, titleRect = NSZeroRect;
int haveImage = (mbPtr->image || mbPtr->bitmap != None), haveText = 0;
int haveCompound = (mbPtr->compound != COMPOUND_NONE);
int width, height;
if (!button) {
button = [[NSPopUpButton alloc] initWithFrame:NSZeroRect pullsDown:YES];
macButtonPtr->button = TkMacOSXMakeUncollectable(button);
cell = [button cell];
[cell setUsesItemFromMenu:NO];
menuItem = [[[NSMenuItem alloc] initWithTitle:@""
action:NULL keyEquivalent:@""] autorelease];
[cell setMenuItem:menuItem];
} else {
cell = [button cell];
menuItem = [cell menuItem];
}
if (haveImage) {
style = NSShadowlessSquareBezelStyle;
} else if (!mbPtr->indicatorOn) {
style = NSRegularSquareBezelStyle;
}
[button setBezelStyle:style];
[cell setArrowPosition:(mbPtr->indicatorOn ? NSPopUpArrowAtBottom :
NSPopUpNoArrow)];
#if 0
NSControlSize controlSize = NSRegularControlSize;
if (mbPtr->borderWidth <= 2) {
controlSize = NSMiniControlSize;
} else if (mbPtr->borderWidth == 3) {
controlSize = NSSmallControlSize;
}
[cell setControlSize:controlSize];
#endif
if (mbPtr->text && *(mbPtr->text) && (!haveImage || haveCompound)) {
NSString *title = [[NSString alloc] initWithUTF8String:mbPtr->text];
[button setTitle:title];
[title release];
haveText = 1;
}
haveCompound = (haveCompound && haveImage && haveText);
if (haveText) {
NSTextAlignment alignment = NSNaturalTextAlignment;
switch (mbPtr->justify) {
case TK_JUSTIFY_LEFT:
alignment = NSLeftTextAlignment;
break;
case TK_JUSTIFY_RIGHT:
alignment = NSRightTextAlignment;
break;
case TK_JUSTIFY_CENTER:
alignment = NSCenterTextAlignment;
break;
}
[button setAlignment:alignment];
} else {
[button setTitle:@""];
}
font = TkMacOSXNSFontForFont(mbPtr->tkfont);
if (font) {
[button setFont:font];
}
if (haveImage) {
int width, height;
NSImage *image;
NSCellImagePosition pos = NSImageOnly;
if (mbPtr->image) {
Tk_SizeOfImage(mbPtr->image, &width, &height);
image = TkMacOSXGetNSImageWithTkImage(mbPtr->display,
mbPtr->image, width, height);
} else {
Tk_SizeOfBitmap(mbPtr->display, mbPtr->bitmap, &width, &height);
image = TkMacOSXGetNSImageWithBitmap(mbPtr->display,
mbPtr->bitmap, mbPtr->normalTextGC, width, height);
}
if (haveCompound) {
switch ((enum compound) mbPtr->compound) {
case COMPOUND_TOP:
pos = NSImageAbove;
break;
case COMPOUND_BOTTOM:
pos = NSImageBelow;
break;
case COMPOUND_LEFT:
pos = NSImageLeft;
break;
case COMPOUND_RIGHT:
pos = NSImageRight;
break;
case COMPOUND_CENTER:
pos = NSImageOverlaps;
break;
case COMPOUND_NONE:
pos = NSImageOnly;
break;
}
}
[button setImagePosition:pos];
[menuItem setImage:image];
bounds.size = cell ? [cell cellSize] : NSZeroSize;
if (bounds.size.height < height + 8) { /* workaround AppKit sizing bug */
bounds.size.height = height + 8;
}
#if TK_MAC_BUTTON_USE_COMPATIBILITY_METRICS
if (!mbPtr->indicatorOn && tkMacOSXUseCompatibilityMetrics) {
bounds.size.width -= 16;
}
#endif
} else {
bounds.size = cell ? [cell cellSize] : NSZeroSize;
}
if (haveText) {
titleRect = cell ? [cell titleRectForBounds:bounds] : NSZeroRect;
if (mbPtr->wrapLength > 0 &&
titleRect.size.width > mbPtr->wrapLength) {
if (style == NSRoundedBezelStyle) {
[button setBezelStyle:(style = NSRegularSquareBezelStyle)];
bounds.size = cell ? [cell cellSize] : NSZeroSize;
titleRect = cell ? [cell titleRectForBounds:bounds] : NSZeroRect;
}
bounds.size.width -= titleRect.size.width - mbPtr->wrapLength;
bounds.size.height = 40000.0;
[cell setWraps:YES];
bounds.size = cell ? [cell cellSizeForBounds:bounds] : NSZeroSize;
#ifdef TK_MAC_DEBUG_MENUBUTTON
titleRect = cell ? [cell titleRectForBounds:bounds] : NSZeroRect;
#endif
#if TK_MAC_BUTTON_USE_COMPATIBILITY_METRICS
if (tkMacOSXUseCompatibilityMetrics) {
bounds.size.height += 3;
}
#endif
}
}
width = lround(bounds.size.width);
height = lround(bounds.size.height);
#if TK_MAC_BUTTON_USE_COMPATIBILITY_METRICS
if (tkMacOSXUseCompatibilityMetrics) {
macButtonPtr->fix = fixForStyle(style);
width -= boundsFixes[macButtonPtr->fix].trimW;
height -= boundsFixes[macButtonPtr->fix].trimH;
}
#endif
if (haveImage || haveCompound) {
if (mbPtr->width > 0) {
width = mbPtr->width;
}
if (mbPtr->height > 0) {
height = mbPtr->height;
}
} else {
if (mbPtr->width > 0) {
int avgWidth = Tk_TextWidth(mbPtr->tkfont, "0", 1);
width = mbPtr->width * avgWidth;
}
if (mbPtr->height > 0) {
Tk_FontMetrics fm;
Tk_GetFontMetrics(mbPtr->tkfont, &fm);
height = mbPtr->height * fm.linespace;
}
}
if (!haveImage || haveCompound) {
width += 2*mbPtr->padX;
height += 2*mbPtr->padY;
}
if (mbPtr->highlightWidth < 0) {
mbPtr->highlightWidth = 0;
}
if (haveImage) {
mbPtr->inset = mbPtr->highlightWidth;
width += 2*mbPtr->borderWidth;
height += 2*mbPtr->borderWidth;
} else {
mbPtr->inset = mbPtr->highlightWidth + mbPtr->borderWidth;
}
Tk_GeometryRequest(mbPtr->tkwin, width + 2 * mbPtr->inset,
height + 2 * mbPtr->inset);
Tk_SetInternalBorder(mbPtr->tkwin, mbPtr->inset);
#ifdef TK_MAC_DEBUG_MENUBUTTON
TKLog(@"menubutton %s bounds %@ titleRect %@ width %d height %d inset %d borderWidth %d",
((TkWindow *)mbPtr->tkwin)->pathName, NSStringFromRect(bounds),
NSStringFromRect(titleRect), width, height, mbPtr->inset,
mbPtr->borderWidth);
#endif
}
/*
*--------------------------------------------------------------
*
* MenuButtonEventProc --
*
* This procedure is invoked by the Tk dispatcher for various
* events on buttons.
*
* Results:
* None.
*
* Side effects:
* When activation state changes, it is redisplayed.
*
*--------------------------------------------------------------
*/
static void
MenuButtonEventProc(
ClientData clientData, /* Information about window. */
XEvent *eventPtr) /* Information about event. */
{
TkMenuButton *mbPtr = (TkMenuButton *) clientData;
if (!mbPtr->tkwin || !Tk_IsMapped(mbPtr->tkwin)) {
return;
}
switch (eventPtr->type) {
case ActivateNotify:
case DeactivateNotify:
if (!(mbPtr->flags & REDRAW_PENDING)) {
Tcl_DoWhenIdle(TkpDisplayMenuButton, (ClientData) mbPtr);
mbPtr->flags |= REDRAW_PENDING;
}
break;
}
}
/*
* Local Variables:
* mode: objc
* c-basic-offset: 4
* fill-column: 79
* coding: utf-8
* End:
*/

471
macosx/tkMacOSXMenus.c Normal file
View File

@@ -0,0 +1,471 @@
/*
* tkMacOSXMenus.c --
*
* These calls set up the default menus for Tk.
*
* Copyright (c) 1995-1996 Sun Microsystems, Inc.
* Copyright 2001-2009, Apple Inc.
* Copyright (c) 2005-2009 Daniel A. Steffen <das@users.sourceforge.net>
*
* See the file "license.terms" for information on usage and redistribution
* of this file, and for a DISCLAIMER OF ALL WARRANTIES.
*/
#include "tkMacOSXPrivate.h"
#include "tkMenu.h"
static void GenerateEditEvent(const char *name);
static Tcl_Obj * GetWidgetDemoPath(Tcl_Interp *interp);
#pragma mark TKApplication(TKMenus)
@implementation TKApplication(TKMenus)
- (void)_setupMenus {
if (_defaultMainMenu) {
return;
}
TkMenuInit();
NSString *applicationName = [[NSBundle mainBundle]
objectForInfoDictionaryKey:@"CFBundleName"];
if (!applicationName) {
applicationName = [[NSProcessInfo processInfo] processName];
}
NSString *aboutName = (applicationName &&
![applicationName isEqualToString:@"Wish"] &&
![applicationName hasPrefix:@"tclsh"]) ?
applicationName : @"Tcl & Tk";
_servicesMenu = [NSMenu menuWithTitle:@"Services"];
_defaultApplicationMenuItems = [[NSArray arrayWithObjects:
[NSMenuItem separatorItem],
[NSMenuItem itemWithTitle:
[NSString stringWithFormat:@"Preferences%C", 0x2026]
action:@selector(preferences:) keyEquivalent:@","],
[NSMenuItem separatorItem],
[NSMenuItem itemWithTitle:@"Services" submenu:_servicesMenu],
[NSMenuItem separatorItem],
[NSMenuItem itemWithTitle:
[NSString stringWithFormat:@"Hide %@", applicationName]
action:@selector(hide:) keyEquivalent:@"h"],
[NSMenuItem itemWithTitle:@"Hide Others"
action:@selector(hideOtherApplications:) keyEquivalent:@"h"
keyEquivalentModifierMask:
NSCommandKeyMask|NSAlternateKeyMask],
[NSMenuItem itemWithTitle:@"Show All"
action:@selector(unhideAllApplications:)],
[NSMenuItem separatorItem],
[NSMenuItem itemWithTitle:
[NSString stringWithFormat:@"Quit %@", applicationName]
action: @selector(terminate:) keyEquivalent:@"q"],
nil] retain];
_defaultApplicationMenu = [TKMenu menuWithTitle:applicationName
menuItems:_defaultApplicationMenuItems];
[_defaultApplicationMenu insertItem:
[NSMenuItem itemWithTitle:
[NSString stringWithFormat:@"About %@", aboutName]
action:@selector(orderFrontStandardAboutPanel:)] atIndex:0];
TKMenu *fileMenu = [TKMenu menuWithTitle:@"File" menuItems:
[NSArray arrayWithObjects:
[NSMenuItem itemWithTitle:
[NSString stringWithFormat:@"Source%C", 0x2026]
action:@selector(tkSource:)],
[NSMenuItem itemWithTitle:@"Run Widget Demo"
action:@selector(tkDemo:)],
[NSMenuItem itemWithTitle:@"Close" action:@selector(performClose:)
target:nil keyEquivalent:@"w"],
nil]];
TKMenu *editMenu = [TKMenu menuWithTitle:@"Edit" menuItems:
[NSArray arrayWithObjects:
[NSMenuItem itemWithTitle:@"Undo" action:@selector(undo:)
target:nil keyEquivalent:@"z"],
[NSMenuItem itemWithTitle:@"Redo" action:@selector(redo:)
target:nil keyEquivalent:@"y"],
[NSMenuItem separatorItem],
[NSMenuItem itemWithTitle:@"Cut" action:@selector(cut:)
target:nil keyEquivalent:@"x"],
[NSMenuItem itemWithTitle:@"Copy" action:@selector(copy:)
target:nil keyEquivalent:@"c"],
[NSMenuItem itemWithTitle:@"Paste" action:@selector(paste:)
target:nil keyEquivalent:@"v"],
[NSMenuItem itemWithTitle:@"Delete" action:@selector(delete:)
target:nil],
nil]];
_defaultWindowsMenuItems = [[NSArray arrayWithObjects:
[NSMenuItem itemWithTitle:@"Minimize"
action:@selector(performMiniaturize:) target:nil
keyEquivalent:@"m"],
[NSMenuItem itemWithTitle:@"Zoom" action:@selector(performZoom:)
target:nil],
[NSMenuItem separatorItem],
[NSMenuItem itemWithTitle:@"Bring All to Front"
action:@selector(arrangeInFront:)],
nil] retain];
TKMenu *windowsMenu = [TKMenu menuWithTitle:@"Window" menuItems:
_defaultWindowsMenuItems];
_defaultHelpMenuItems = [[NSArray arrayWithObjects:
[NSMenuItem itemWithTitle:
[NSString stringWithFormat:@"%@ Help", applicationName]
action:@selector(showHelp:) keyEquivalent:@"?"],
nil] retain];
TKMenu *helpMenu = [TKMenu menuWithTitle:@"Help" menuItems:
_defaultHelpMenuItems];
[self setServicesMenu:_servicesMenu];
[self setWindowsMenu:windowsMenu];
_defaultMainMenu = [[TKMenu menuWithTitle:@"" submenus:[NSArray
arrayWithObjects:_defaultApplicationMenu, fileMenu, editMenu,
windowsMenu, helpMenu, nil]] retain];
[_defaultMainMenu setSpecial:tkMainMenu];
[_defaultApplicationMenu setSpecial:tkApplicationMenu];
[windowsMenu setSpecial:tkWindowsMenu];
[helpMenu setSpecial:tkHelpMenu];
[self tkSetMainMenu:nil];
}
- (void)dealloc {
[_defaultMainMenu release];
[_defaultHelpMenuItems release];
[_defaultWindowsMenuItems release];
[_defaultApplicationMenuItems release];
[super dealloc];
}
- (BOOL)validateUserInterfaceItem:(id <NSValidatedUserInterfaceItem>)anItem {
SEL action = [anItem action];
if (sel_isEqual(action, @selector(preferences:))) {
Tcl_CmdInfo dummy;
return (_eventInterp && Tcl_GetCommandInfo(_eventInterp,
"::tk::mac::ShowPreferences", &dummy));
} else if (sel_isEqual(action, @selector(tkDemo:))) {
BOOL haveDemo = NO;
if (_eventInterp) {
Tcl_Obj *path = GetWidgetDemoPath(_eventInterp);
if (path) {
Tcl_IncrRefCount(path);
haveDemo = (Tcl_FSAccess(path, R_OK) == 0);
Tcl_DecrRefCount(path);
}
}
return haveDemo;
} else {
return [super validateUserInterfaceItem:anItem];
}
}
- (void)orderFrontStandardAboutPanel:(id)sender {
Tcl_CmdInfo dummy;
if (!_eventInterp || !Tcl_GetCommandInfo(_eventInterp, "tkAboutDialog",
&dummy) || (GetCurrentEventKeyModifiers() & optionKey)) {
TkAboutDlg();
} else {
int code = Tcl_EvalEx(_eventInterp, "tkAboutDialog", -1,
TCL_EVAL_GLOBAL);
if (code != TCL_OK) {
Tcl_BackgroundError(_eventInterp);
}
Tcl_ResetResult(_eventInterp);
}
}
- (void)showHelp:(id)sender {
Tcl_CmdInfo dummy;
if (!_eventInterp || !Tcl_GetCommandInfo(_eventInterp,
"::tk::mac::ShowHelp", &dummy)) {
[super showHelp:sender];
} else {
int code = Tcl_EvalEx(_eventInterp, "::tk::mac::ShowHelp", -1,
TCL_EVAL_GLOBAL);
if (code != TCL_OK) {
Tcl_BackgroundError(_eventInterp);
}
Tcl_ResetResult(_eventInterp);
}
}
- (void)tkSource:(id)sender {
if (_eventInterp) {
if (Tcl_EvalEx(_eventInterp, "tk_getOpenFile -filetypes {"
"{{TCL Scripts} {.tcl} TEXT} {{Text Files} {} TEXT}}",
-1, TCL_EVAL_GLOBAL) == TCL_OK) {
Tcl_Obj *path = Tcl_GetObjResult(_eventInterp);
int len;
Tcl_GetStringFromObj(path, &len);
if (len) {
Tcl_IncrRefCount(path);
int code = Tcl_FSEvalFile(_eventInterp, path);
if (code != TCL_OK) {
Tcl_BackgroundError(_eventInterp);
}
Tcl_DecrRefCount(path);
}
}
Tcl_ResetResult(_eventInterp);
}
}
- (void)tkDemo:(id)sender {
if (_eventInterp) {
Tcl_Obj *path = GetWidgetDemoPath(_eventInterp);
if (path) {
Tcl_IncrRefCount(path);
int code = Tcl_FSEvalFile(_eventInterp, path);
if (code != TCL_OK) {
Tcl_BackgroundError(_eventInterp);
}
Tcl_DecrRefCount(path);
Tcl_ResetResult(_eventInterp);
}
}
}
@end
#pragma mark TKContentView(TKMenus)
@implementation TKContentView(TKMenus)
- (BOOL)validateUserInterfaceItem:(id <NSValidatedUserInterfaceItem>)anItem {
return YES;
}
#define EDIT_ACTION(a, e) \
- (void) a:(id)sender { \
if ([sender isKindOfClass:[NSMenuItem class]]) { \
GenerateEditEvent(#e); \
} \
}
EDIT_ACTION(cut, Cut)
EDIT_ACTION(copy, Copy)
EDIT_ACTION(paste, Paste)
EDIT_ACTION(delete, Clear)
EDIT_ACTION(undo, Undo)
EDIT_ACTION(redo, Redo)
#undef EDIT_ACTION
@end
#pragma mark -
/*
*----------------------------------------------------------------------
*
* GetWidgetDemoPath --
*
* Get path to the widget demo.
*
* Results:
* pathObj with ref count 0.
*
* Side effects:
* None.
*
*----------------------------------------------------------------------
*/
static Tcl_Obj *
GetWidgetDemoPath(
Tcl_Interp *interp)
{
Tcl_Obj *libpath, *result = NULL;
libpath = Tcl_GetVar2Ex(interp, "tk_library", NULL, TCL_GLOBAL_ONLY);
if (libpath) {
Tcl_Obj *demo[2] = { Tcl_NewStringObj("demos", 5),
Tcl_NewStringObj("widget", 6) };
Tcl_IncrRefCount(libpath);
result = Tcl_FSJoinToPath(libpath, 2, demo);
Tcl_DecrRefCount(libpath);
} else {
Tcl_ResetResult(interp);
}
return result;
}
/*
*----------------------------------------------------------------------
*
* TkMacOSXHandleMenuSelect --
*
* Handles events that occur in the Menu bar.
*
* Results:
* None.
*
* Side effects:
* None.
*
*----------------------------------------------------------------------
*/
void
TkMacOSXHandleMenuSelect(
short theMenu,
unsigned short theItem,
int optionKeyPressed)
{
Tcl_Panic("TkMacOSXHandleMenuSelect: Obsolete, no more Carbon!");
}
/*
*----------------------------------------------------------------------
*
* TkMacOSXInitMenus --
*
* This procedure initializes the Macintosh menu bar.
*
* Results:
* None.
*
* Side effects:
* None.
*
*----------------------------------------------------------------------
*/
void
TkMacOSXInitMenus(
Tcl_Interp *interp)
{
[NSApp _setupMenus];
}
/*
*----------------------------------------------------------------------
*
* GenerateEditEvent --
*
* Takes an edit menu item and posts the corasponding a virtual event to
* Tk's event queue.
*
* Results:
* None.
*
* Side effects:
* May place events of queue.
*
*----------------------------------------------------------------------
*/
static void
GenerateEditEvent(
const char *name)
{
XVirtualEvent event;
int x, y;
TkWindow *winPtr = TkMacOSXGetTkWindow([NSApp keyWindow]);
Tk_Window tkwin = (Tk_Window) winPtr;
if (tkwin == NULL) {
return;
}
tkwin = (Tk_Window) winPtr->dispPtr->focusPtr;
if (tkwin == NULL) {
return;
}
bzero(&event, sizeof(XVirtualEvent));
event.type = VirtualEvent;
event.serial = LastKnownRequestProcessed(Tk_Display(tkwin));
event.send_event = false;
event.display = Tk_Display(tkwin);
event.event = Tk_WindowId(tkwin);
event.root = XRootWindow(Tk_Display(tkwin), 0);
event.subwindow = None;
event.time = TkpGetMS();
XQueryPointer(NULL, winPtr->window, NULL, NULL,
&event.x_root, &event.y_root, &x, &y, &event.state);
Tk_TopCoordsToWindow(tkwin, x, y, &event.x, &event.y);
event.same_screen = true;
event.name = Tk_GetUid(name);
Tk_QueueWindowEvent((XEvent *) &event, TCL_QUEUE_TAIL);
}
#pragma mark -
#pragma mark NSMenu & NSMenuItem Utilities
@implementation NSMenu(TKUtils)
+ (id)menuWithTitle:(NSString *)title {
NSMenu *m = [[self alloc] initWithTitle:title];
return [m autorelease];
}
+ (id)menuWithTitle:(NSString *)title menuItems:(NSArray *)items {
NSMenu *m = [[self alloc] initWithTitle:title];
for (NSMenuItem *i in items) {
[m addItem:i];
}
return [m autorelease];
}
+ (id)menuWithTitle:(NSString *)title submenus:(NSArray *)submenus {
NSMenu *m = [[self alloc] initWithTitle:title];
for (NSMenu *i in submenus) {
[m addItem:[NSMenuItem itemWithSubmenu:i]];
}
return [m autorelease];
}
- (NSMenuItem *)itemWithSubmenu:(NSMenu *)submenu {
return [self itemAtIndex:[self indexOfItemWithSubmenu:submenu]];
}
- (NSMenuItem *)itemInSupermenu {
NSMenu *supermenu = [self supermenu];
return (supermenu ? [supermenu itemWithSubmenu:self] : nil);
}
@end
@implementation NSMenuItem(TKUtils)
+ (id)itemWithSubmenu:(NSMenu *)submenu {
NSMenuItem *i = [[self alloc] initWithTitle:[submenu title] action:NULL
keyEquivalent:@""];
[i setSubmenu:submenu];
return [i autorelease];
}
+ (id)itemWithTitle:(NSString *)title submenu:(NSMenu *)submenu {
NSMenuItem *i = [[self alloc] initWithTitle:title action:NULL
keyEquivalent:@""];
[i setSubmenu:submenu];
return [i autorelease];
}
+ (id)itemWithTitle:(NSString *)title action:(SEL)action {
NSMenuItem *i = [[self alloc] initWithTitle:title action:action
keyEquivalent:@""];
[i setTarget:NSApp];
return [i autorelease];
}
+ (id)itemWithTitle:(NSString *)title action:(SEL)action
target:(id)target {
NSMenuItem *i = [[self alloc] initWithTitle:title action:action
keyEquivalent:@""];
[i setTarget:target];
return [i autorelease];
}
+ (id)itemWithTitle:(NSString *)title action:(SEL)action
keyEquivalent:(NSString *)keyEquivalent {
NSMenuItem *i = [[self alloc] initWithTitle:title action:action
keyEquivalent:keyEquivalent];
[i setTarget:NSApp];
return [i autorelease];
}
+ (id)itemWithTitle:(NSString *)title action:(SEL)action
target:(id)target keyEquivalent:(NSString *)keyEquivalent {
NSMenuItem *i = [[self alloc] initWithTitle:title action:action
keyEquivalent:keyEquivalent];
[i setTarget:target];
return [i autorelease];
}
+ (id)itemWithTitle:(NSString *)title action:(SEL)action
keyEquivalent:(NSString *)keyEquivalent
keyEquivalentModifierMask:(NSUInteger)keyEquivalentModifierMask {
NSMenuItem *i = [[self alloc] initWithTitle:title action:action
keyEquivalent:keyEquivalent];
[i setTarget:NSApp];
[i setKeyEquivalentModifierMask:keyEquivalentModifierMask];
return [i autorelease];
}
+ (id)itemWithTitle:(NSString *)title action:(SEL)action
target:(id)target keyEquivalent:(NSString *)keyEquivalent
keyEquivalentModifierMask:(NSUInteger)keyEquivalentModifierMask {
NSMenuItem *i = [[self alloc] initWithTitle:title action:action
keyEquivalent:keyEquivalent];
[i setTarget:target];
[i setKeyEquivalentModifierMask:keyEquivalentModifierMask];
return [i autorelease];
}
@end
/*
* Local Variables:
* mode: objc
* c-basic-offset: 4
* fill-column: 79
* coding: utf-8
* End:
*/

543
macosx/tkMacOSXMouseEvent.c Normal file
View File

@@ -0,0 +1,543 @@
/*
* tkMacOSXMouseEvent.c --
*
* This file implements functions that decode & handle mouse events on
* MacOS X.
*
* Copyright 2001-2009, Apple Inc.
* Copyright (c) 2005-2009 Daniel A. Steffen <das@users.sourceforge.net>
*
* See the file "license.terms" for information on usage and redistribution of
* this file, and for a DISCLAIMER OF ALL WARRANTIES.
*/
#include "tkMacOSXPrivate.h"
#include "tkMacOSXWm.h"
#include "tkMacOSXEvent.h"
#include "tkMacOSXDebug.h"
typedef struct {
unsigned int state;
long delta;
Window window;
Point global;
Point local;
} MouseEventData;
static int GenerateButtonEvent(MouseEventData *medPtr);
static unsigned int ButtonModifiers2State(UInt32 buttonState,
UInt32 keyModifiers);
#pragma mark TKApplication(TKMouseEvent)
enum {
NSWindowWillMoveEventType = 20
};
@implementation TKApplication(TKMouseEvent)
- (NSEvent *)tkProcessMouseEvent:(NSEvent *)theEvent {
#ifdef TK_MAC_DEBUG_EVENTS
TKLog(@"-[%@(%p) %s] %@", [self class], self, _cmd, theEvent);
#endif
id win;
NSEventType type = [theEvent type];
#if 0
NSTrackingArea *trackingArea = nil;
NSInteger eventNumber, clickCount, buttonNumber;
#endif
switch (type) {
case NSMouseEntered:
case NSMouseExited:
case NSCursorUpdate:
#if 0
trackingArea = [theEvent trackingArea];
#endif
/* fall through */
case NSLeftMouseDown:
case NSLeftMouseUp:
case NSRightMouseDown:
case NSRightMouseUp:
case NSOtherMouseDown:
case NSOtherMouseUp:
case NSLeftMouseDragged:
case NSRightMouseDragged:
case NSOtherMouseDragged:
case NSMouseMoved:
#if 0
eventNumber = [theEvent eventNumber];
if (!trackingArea) {
clickCount = [theEvent clickCount];
buttonNumber = [theEvent buttonNumber];
}
#endif
case NSTabletPoint:
case NSTabletProximity:
case NSScrollWheel:
win = [self windowWithWindowNumber:[theEvent windowNumber]];
break;
default:
return theEvent;
break;
}
NSPoint global, local = [theEvent locationInWindow];
if (win) {
global = [win convertBaseToScreen:local];
local.y = [win frame].size.height - local.y;
global.y = tkMacOSXZeroScreenHeight - global.y;
} else {
local.y = tkMacOSXZeroScreenHeight - local.y;
global = local;
}
Window window = TkMacOSXGetXWindow(win);
Tk_Window tkwin = window ? Tk_IdToWindow(TkGetDisplayList()->display,
window) : NULL;
if (!tkwin) {
tkwin = TkMacOSXGetCapture();
}
if (!tkwin) {
return theEvent;
}
/*
MacDrawable *macWin = (MacDrawable *) window;
NSView *view = TkMacOSXDrawableView(macWin);
local = [view convertPoint:local fromView:nil];
local.y = NSHeight([view bounds]) - local.y;
*/
TkWindow *winPtr = (TkWindow *) tkwin;
local.x -= winPtr->wmInfoPtr->xInParent;
local.y -= winPtr->wmInfoPtr->yInParent;
int win_x, win_y;
tkwin = Tk_TopCoordsToWindow(tkwin, local.x, local.y,
&win_x, &win_y);
unsigned int state = 0;
NSInteger button = [theEvent buttonNumber];
EventRef eventRef = (EventRef)[theEvent eventRef];
UInt32 buttons;
OSStatus err = GetEventParameter(eventRef, kEventParamMouseChord,
typeUInt32, NULL, sizeof(UInt32), NULL, &buttons);
if (err == noErr) {
state |= (buttons & ((1<<5) - 1)) << 8;
} else {
if (button < 5) {
switch (type) {
case NSLeftMouseDown:
case NSRightMouseDown:
case NSLeftMouseDragged:
case NSRightMouseDragged:
case NSOtherMouseDown:
state |= 1 << (button + 8);
break;
default:
break;
}
}
}
NSUInteger modifiers = [theEvent modifierFlags];
if (modifiers & NSAlphaShiftKeyMask) {
state |= LockMask;
}
if (modifiers & NSShiftKeyMask) {
state |= ShiftMask;
}
if (modifiers & NSControlKeyMask) {
state |= ControlMask;
}
if (modifiers & NSCommandKeyMask) {
state |= Mod1Mask; /* command key */
}
if (modifiers & NSAlternateKeyMask) {
state |= Mod2Mask; /* option key */
}
if (modifiers & NSNumericPadKeyMask) {
state |= Mod3Mask;
}
if (modifiers & NSFunctionKeyMask) {
state |= Mod4Mask;
}
if (type != NSScrollWheel) {
#ifdef TK_MAC_DEBUG_EVENTS
TKLog(@"UpdatePointer %p x %f.0 y %f.0 %d", tkwin, global.x, global.y, state);
#endif
Tk_UpdatePointer(tkwin, global.x, global.y, state);
} else {
CGFloat delta;
int coarseDelta;
XEvent xEvent;
xEvent.type = MouseWheelEvent;
xEvent.xbutton.x = local.x;
xEvent.xbutton.y = local.y;
xEvent.xbutton.x_root = global.x;
xEvent.xbutton.y_root = global.y;
xEvent.xany.send_event = false;
xEvent.xany.display = Tk_Display(tkwin);
xEvent.xany.window = Tk_WindowId(tkwin);
delta = [theEvent deltaY];
if (delta != 0.0) {
coarseDelta = (delta > -1.0 && delta < 1.0) ? (signbit(delta) ? -1 : 1) : lround(delta);
xEvent.xbutton.state = state;
xEvent.xkey.keycode = coarseDelta;
xEvent.xany.serial = LastKnownRequestProcessed(Tk_Display(tkwin));
Tk_QueueWindowEvent(&xEvent, TCL_QUEUE_TAIL);
}
delta = [theEvent deltaX];
if (delta != 0.0) {
coarseDelta = (delta > -1.0 && delta < 1.0) ? (signbit(delta) ? -1 : 1) : lround(delta);
xEvent.xbutton.state = state | ShiftMask;
xEvent.xkey.keycode = coarseDelta;
xEvent.xany.serial = LastKnownRequestProcessed(Tk_Display(tkwin));
Tk_QueueWindowEvent(&xEvent, TCL_QUEUE_TAIL);
}
}
return theEvent;
}
@end
#pragma mark -
/*
*----------------------------------------------------------------------
*
* TkMacOSXKeyModifiers --
*
* Returns the current state of the modifier keys.
*
* Results:
* An OS Modifier state.
*
* Side effects:
* None.
*
*----------------------------------------------------------------------
*/
EventModifiers
TkMacOSXModifierState(void)
{
UInt32 keyModifiers;
int isFrontProcess = (GetCurrentEvent() && Tk_MacOSXIsAppInFront());
keyModifiers = isFrontProcess ? GetCurrentEventKeyModifiers() :
GetCurrentKeyModifiers();
return (EventModifiers) (keyModifiers & USHRT_MAX);
}
/*
*----------------------------------------------------------------------
*
* TkMacOSXButtonKeyState --
*
* Returns the current state of the button & modifier keys.
*
* Results:
* A bitwise inclusive OR of a subset of the following: Button1Mask,
* ShiftMask, LockMask, ControlMask, Mod*Mask.
*
* Side effects:
* None.
*
*----------------------------------------------------------------------
*/
unsigned int
TkMacOSXButtonKeyState(void)
{
UInt32 buttonState = 0, keyModifiers;
int isFrontProcess = (GetCurrentEvent() && Tk_MacOSXIsAppInFront());
buttonState = isFrontProcess ? GetCurrentEventButtonState() :
GetCurrentButtonState();
keyModifiers = isFrontProcess ? GetCurrentEventKeyModifiers() :
GetCurrentKeyModifiers();
return ButtonModifiers2State(buttonState, keyModifiers);
}
/*
*----------------------------------------------------------------------
*
* ButtonModifiers2State --
*
* Converts Carbon mouse button state and modifier values into a Tk
* button/modifier state.
*
* Results:
* None.
*
* Side effects:
* None.
*
*----------------------------------------------------------------------
*/
static unsigned int
ButtonModifiers2State(
UInt32 buttonState,
UInt32 keyModifiers)
{
unsigned int state;
/*
* Tk supports at most 5 buttons.
*/
state = (buttonState & ((1<<5) - 1)) << 8;
if (keyModifiers & alphaLock) {
state |= LockMask;
}
if (keyModifiers & shiftKey) {
state |= ShiftMask;
}
if (keyModifiers & controlKey) {
state |= ControlMask;
}
if (keyModifiers & cmdKey) {
state |= Mod1Mask; /* command key */
}
if (keyModifiers & optionKey) {
state |= Mod2Mask; /* option key */
}
if (keyModifiers & kEventKeyModifierNumLockMask) {
state |= Mod3Mask;
}
if (keyModifiers & kEventKeyModifierFnMask) {
state |= Mod4Mask;
}
return state;
}
/*
*----------------------------------------------------------------------
*
* XQueryPointer --
*
* Check the current state of the mouse. This is not a complete
* implementation of this function. It only computes the root coordinates
* and the current mask.
*
* Results:
* Sets root_x_return, root_y_return, and mask_return. Returns true on
* success.
*
* Side effects:
* None.
*
*----------------------------------------------------------------------
*/
Bool
XQueryPointer(
Display *display,
Window w,
Window *root_return,
Window *child_return,
int *root_x_return,
int *root_y_return,
int *win_x_return,
int *win_y_return,
unsigned int *mask_return)
{
int getGlobal = (root_x_return && root_y_return);
int getLocal = (win_x_return && win_y_return && w != None);
if (getGlobal || getLocal) {
NSPoint global = [NSEvent mouseLocation];
if (getLocal) {
MacDrawable *macWin = (MacDrawable *) w;
NSWindow *win = TkMacOSXDrawableWindow(w);
if (win) {
NSPoint local;
local = [win convertScreenToBase:global];
local.y = [win frame].size.height - local.y;
if (macWin->winPtr && macWin->winPtr->wmInfoPtr) {
local.x -= macWin->winPtr->wmInfoPtr->xInParent;
local.y -= macWin->winPtr->wmInfoPtr->yInParent;
}
*win_x_return = local.x;
*win_y_return = local.y;
}
}
if (getGlobal) {
*root_x_return = global.x;
*root_y_return = tkMacOSXZeroScreenHeight - global.y;
}
}
if (mask_return) {
*mask_return = TkMacOSXButtonKeyState();
}
return True;
}
/*
*----------------------------------------------------------------------
*
* TkGenerateButtonEventForXPointer --
*
* This procedure generates an X button event for the current pointer
* state as reported by XQueryPointer().
*
* Results:
* True if event(s) are generated - false otherwise.
*
* Side effects:
* Additional events may be place on the Tk event queue. Grab state may
* also change.
*
*----------------------------------------------------------------------
*/
MODULE_SCOPE int
TkGenerateButtonEventForXPointer(
Window window) /* X Window containing button event. */
{
MouseEventData med;
int global_x, global_y, local_x, local_y;
bzero(&med, sizeof(MouseEventData));
XQueryPointer(NULL, window, NULL, NULL, &global_x, &global_y,
&local_x, &local_y, &med.state);
med.global.h = global_x;
med.global.v = global_y;
med.local.h = local_x;
med.local.v = local_y;
med.window = window;
return GenerateButtonEvent(&med);
}
/*
*----------------------------------------------------------------------
*
* TkGenerateButtonEvent --
*
* Given a global x & y position and the button key status this procedure
* generates the appropiate X button event. It also handles the state
* changes needed to implement implicit grabs.
*
* Results:
* True if event(s) are generated, false otherwise.
*
* Side effects:
* Additional events may be place on the Tk event queue. Grab state may
* also change.
*
*----------------------------------------------------------------------
*/
int
TkGenerateButtonEvent(
int x, /* X location of mouse, */
int y, /* Y location of mouse. */
Window window, /* X Window containing button event. */
unsigned int state) /* Button Key state suitable for X event. */
{
MacDrawable *macWin = (MacDrawable *) window;
NSWindow *win = TkMacOSXDrawableWindow(window);
MouseEventData med;
bzero(&med, sizeof(MouseEventData));
med.state = state;
med.window = window;
med.global.h = x;
med.global.v = y;
med.local = med.global;
if (win) {
NSPoint local = NSMakePoint(x, tkMacOSXZeroScreenHeight - y);
local = [win convertScreenToBase:local];
local.y = [win frame].size.height - local.y;
if (macWin->winPtr && macWin->winPtr->wmInfoPtr) {
local.x -= macWin->winPtr->wmInfoPtr->xInParent;
local.y -= macWin->winPtr->wmInfoPtr->yInParent;
}
med.local.h = local.x;
med.local.v = tkMacOSXZeroScreenHeight - local.y;
}
return GenerateButtonEvent(&med);
}
/*
*----------------------------------------------------------------------
*
* GenerateButtonEvent --
*
* Generate an X button event from a MouseEventData structure. Handles
* the state changes needed to implement implicit grabs.
*
* Results:
* True if event(s) are generated - false otherwise.
*
* Side effects:
* Additional events may be place on the Tk event queue. Grab state may
* also change.
*
*----------------------------------------------------------------------
*/
static int
GenerateButtonEvent(
MouseEventData *medPtr)
{
Tk_Window tkwin;
int dummy;
TkDisplay *dispPtr;
#if UNUSED
/*
* ButtonDown events will always occur in the front window. ButtonUp
* events, however, may occur anywhere on the screen. ButtonUp events
* should only be sent to Tk if in the front window or during an implicit
* grab.
*/
if ((medPtr->activeNonFloating == NULL)
|| ((!(TkpIsWindowFloating(medPtr->whichWin))
&& (medPtr->activeNonFloating != medPtr->whichWin))
&& TkMacOSXGetCapture() == NULL)) {
return false;
}
#endif
dispPtr = TkGetDisplayList();
tkwin = Tk_IdToWindow(dispPtr->display, medPtr->window);
if (tkwin != NULL) {
tkwin = Tk_TopCoordsToWindow(tkwin, medPtr->local.h, medPtr->local.v,
&dummy, &dummy);
}
Tk_UpdatePointer(tkwin, medPtr->global.h, medPtr->global.v, medPtr->state);
return true;
}
/*
* Local Variables:
* mode: objc
* c-basic-offset: 4
* fill-column: 79
* coding: utf-8
* End:
*/

312
macosx/tkMacOSXNotify.c Normal file
View File

@@ -0,0 +1,312 @@
/*
* tkMacOSXNotify.c --
*
* This file contains the implementation of a tcl event source
* for the AppKit event loop.
*
* Copyright (c) 1995-1997 Sun Microsystems, Inc.
* Copyright 2001-2009, Apple Inc.
* Copyright (c) 2005-2009 Daniel A. Steffen <das@users.sourceforge.net>
*
* See the file "license.terms" for information on usage and redistribution
* of this file, and for a DISCLAIMER OF ALL WARRANTIES.
*/
#include "tkMacOSXPrivate.h"
#include "tkMacOSXEvent.h"
#include <tclInt.h>
#include <pthread.h>
#import <objc/objc-auto.h>
typedef struct ThreadSpecificData {
int initialized, sendEventNestingLevel;
NSEvent *currentEvent;
} ThreadSpecificData;
static Tcl_ThreadDataKey dataKey;
#define TSD_INIT() ThreadSpecificData *tsdPtr = Tcl_GetThreadData(&dataKey, \
sizeof(ThreadSpecificData))
static void TkMacOSXNotifyExitHandler(ClientData clientData);
static void TkMacOSXEventsSetupProc(ClientData clientData, int flags);
static void TkMacOSXEventsCheckProc(ClientData clientData, int flags);
#pragma mark TKApplication(TKNotify)
@interface NSApplication(TKNotify)
- (void)_modalSession:(NSModalSession)session sendEvent:(NSEvent *)event;
@end
@implementation NSWindow(TKNotify)
- (id)tkDisplayIfNeeded {
if (![self isAutodisplay]) {
[self displayIfNeeded];
}
return nil;
}
@end
@implementation TKApplication(TKNotify)
- (NSEvent *)nextEventMatchingMask:(NSUInteger)mask
untilDate:(NSDate *)expiration inMode:(NSString *)mode
dequeue:(BOOL)deqFlag {
NSAutoreleasePool *pool = [NSAutoreleasePool new];
[NSApp makeWindowsPerform:@selector(tkDisplayIfNeeded) inOrder:NO];
int oldMode = Tcl_SetServiceMode(TCL_SERVICE_ALL);
NSEvent *event = [[super nextEventMatchingMask:mask untilDate:expiration
inMode:mode dequeue:deqFlag] retain];
Tcl_SetServiceMode(oldMode);
if (event) {
TSD_INIT();
if (tsdPtr->sendEventNestingLevel) {
if (![NSApp tkProcessEvent:event]) {
[event release];
event = nil;
}
}
}
[pool drain];
return [event autorelease];
}
- (void)sendEvent:(NSEvent *)theEvent {
TSD_INIT();
int oldMode = Tcl_SetServiceMode(TCL_SERVICE_ALL);
tsdPtr->sendEventNestingLevel++;
[super sendEvent:theEvent];
tsdPtr->sendEventNestingLevel--;
Tcl_SetServiceMode(oldMode);
[NSApp tkCheckPasteboard];
}
@end
#pragma mark -
/*
*----------------------------------------------------------------------
*
* GetRunLoopMode --
*
* Results:
* RunLoop mode that should be passed to -nextEventMatchingMask:
*
* Side effects:
* None.
*
*----------------------------------------------------------------------
*/
static NSString *
GetRunLoopMode(NSModalSession modalSession)
{
NSString *runLoopMode = nil;
if (modalSession) {
runLoopMode = NSModalPanelRunLoopMode;
} else if (TkMacOSXGetCapture()) {
runLoopMode = NSEventTrackingRunLoopMode;
}
if (!runLoopMode) {
runLoopMode = [[NSRunLoop currentRunLoop] currentMode];
}
if (!runLoopMode) {
runLoopMode = NSDefaultRunLoopMode;
}
return runLoopMode;
}
/*
*----------------------------------------------------------------------
*
* Tk_MacOSXSetupTkNotifier --
*
* This procedure is called during Tk initialization to create
* the event source for TkAqua events.
*
* Results:
* None.
*
* Side effects:
* A new event source is created.
*
*----------------------------------------------------------------------
*/
void
Tk_MacOSXSetupTkNotifier(void)
{
TSD_INIT();
if (!tsdPtr->initialized) {
tsdPtr->initialized = 1;
/*
* Install TkAqua event source in main event loop thread.
*/
if (CFRunLoopGetMain() == CFRunLoopGetCurrent()) {
if (!pthread_main_np()) {
/*
* Panic if main runloop is not on the main application thread.
*/
Tcl_Panic("Tk_MacOSXSetupTkNotifier: %s",
"first [load] of TkAqua has to occur in the main thread!");
}
Tcl_CreateEventSource(TkMacOSXEventsSetupProc,
TkMacOSXEventsCheckProc, GetMainEventQueue());
TkCreateExitHandler(TkMacOSXNotifyExitHandler, NULL);
Tcl_SetServiceMode(TCL_SERVICE_ALL);
TclMacOSXNotifierAddRunLoopMode(NSEventTrackingRunLoopMode);
TclMacOSXNotifierAddRunLoopMode(NSModalPanelRunLoopMode);
}
}
}
/*
*----------------------------------------------------------------------
*
* TkMacOSXNotifyExitHandler --
*
* This function is called during finalization to clean up the
* TkMacOSXNotify module.
*
* Results:
* None.
*
* Side effects:
* None.
*
*----------------------------------------------------------------------
*/
static void
TkMacOSXNotifyExitHandler(
ClientData clientData) /* Not used. */
{
TSD_INIT();
Tcl_DeleteEventSource(TkMacOSXEventsSetupProc,
TkMacOSXEventsCheckProc, GetMainEventQueue());
tsdPtr->initialized = 0;
}
/*
*----------------------------------------------------------------------
*
* TkMacOSXEventsSetupProc --
*
* This procedure implements the setup part of the TkAqua Events event
* source. It is invoked by Tcl_DoOneEvent before entering the notifier
* to check for events.
*
* Results:
* None.
*
* Side effects:
* If TkAqua events are queued, then the maximum block time will be set
* to 0 to ensure that the notifier returns control to Tcl.
*
*----------------------------------------------------------------------
*/
static void
TkMacOSXEventsSetupProc(
ClientData clientData,
int flags)
{
if (flags & TCL_WINDOW_EVENTS &&
![[NSRunLoop currentRunLoop] currentMode]) {
static Tcl_Time zeroBlockTime = { 0, 0 };
TSD_INIT();
if (!tsdPtr->currentEvent) {
NSEvent *currentEvent = [NSApp nextEventMatchingMask:NSAnyEventMask
untilDate:[NSDate distantPast]
inMode:GetRunLoopMode(TkMacOSXGetModalSession())
dequeue:YES];
if (currentEvent) {
tsdPtr->currentEvent =
TkMacOSXMakeUncollectableAndRetain(currentEvent);
}
}
if (tsdPtr->currentEvent) {
Tcl_SetMaxBlockTime(&zeroBlockTime);
}
}
}
/*
*----------------------------------------------------------------------
*
* TkMacOSXEventsCheckProc --
*
* This procedure processes events sitting in the TkAqua event queue.
*
* Results:
* None.
*
* Side effects:
* Moves applicable queued TkAqua events onto the Tcl event queue.
*
*----------------------------------------------------------------------
*/
static void
TkMacOSXEventsCheckProc(
ClientData clientData,
int flags)
{
if (flags & TCL_WINDOW_EVENTS &&
![[NSRunLoop currentRunLoop] currentMode]) {
NSEvent *currentEvent = nil;
NSAutoreleasePool *pool = nil;
NSModalSession modalSession;
TSD_INIT();
if (tsdPtr->currentEvent) {
currentEvent = TkMacOSXMakeCollectableAndAutorelease(
tsdPtr->currentEvent);
}
do {
modalSession = TkMacOSXGetModalSession();
if (!currentEvent) {
currentEvent = [NSApp nextEventMatchingMask:NSAnyEventMask
untilDate:[NSDate distantPast]
inMode:GetRunLoopMode(modalSession) dequeue:YES];
}
if (!currentEvent) {
break;
}
[currentEvent retain];
pool = [NSAutoreleasePool new];
if (tkMacOSXGCEnabled) {
objc_clear_stack(0);
}
if (![NSApp tkProcessEvent:currentEvent]) {
[currentEvent release];
currentEvent = nil;
}
if (currentEvent) {
#ifdef TK_MAC_DEBUG_EVENTS
TKLog(@" event: %@", currentEvent);
#endif
if (modalSession) {
[NSApp _modalSession:modalSession sendEvent:currentEvent];
} else {
[NSApp sendEvent:currentEvent];
}
[currentEvent release];
currentEvent = nil;
}
[pool drain];
pool = nil;
} while (1);
}
}
/*
* Local Variables:
* mode: objc
* c-basic-offset: 4
* fill-column: 79
* coding: utf-8
* End:
*/

203
macosx/tkMacOSXPort.h Normal file
View File

@@ -0,0 +1,203 @@
/*
* tkMacOSXPort.h --
*
* This file is included by all of the Tk C files. It contains
* information that may be configuration-dependent, such as
* #includes for system include files and a few other things.
*
* Copyright (c) 1994-1996 Sun Microsystems, Inc.
* Copyright 2001-2009, Apple Inc.
* Copyright (c) 2005-2009 Daniel A. Steffen <das@users.sourceforge.net>
*
* See the file "license.terms" for information on usage and redistribution
* of this file, and for a DISCLAIMER OF ALL WARRANTIES.
*/
#ifndef _TKMACPORT
#define _TKMACPORT
/*
* Macro to use instead of "void" for arguments that must have
* type "void *" in ANSI C; maps them to type "char *" in
* non-ANSI systems. This macro may be used in some of the include
* files below, which is why it is defined here.
*/
#ifndef VOID
# ifdef __STDC__
# define VOID void
# else
# define VOID char
# endif
#endif
#include <stdio.h>
#include <ctype.h>
#include <fcntl.h>
#include <limits.h>
#include <math.h>
#include <pwd.h>
#include <stdlib.h>
#include <string.h>
#include <sys/types.h>
#include <sys/file.h>
#ifdef HAVE_SYS_SELECT_H
# include <sys/select.h>
#endif
#include <sys/stat.h>
#ifndef _TCL
# include <tcl.h>
#endif
#if TIME_WITH_SYS_TIME
# include <sys/time.h>
# include <time.h>
#else
# if HAVE_SYS_TIME_H
# include <sys/time.h>
# else
# include <time.h>
# endif
#endif
#if HAVE_INTTYPES_H
# include <inttypes.h>
#endif
#include <unistd.h>
#include <X11/Xlib.h>
#include <X11/cursorfont.h>
#include <X11/keysym.h>
#include <X11/Xatom.h>
#include <X11/Xfuncproto.h>
#include <X11/Xutil.h>
#include "tkIntXlibDecls.h"
/*
* The following macro defines the type of the mask arguments to
* select:
*/
#ifndef NO_FD_SET
# define SELECT_MASK fd_set
#else
# ifndef _AIX
typedef long fd_mask;
# endif
# if defined(_IBMR2)
# define SELECT_MASK void
# else
# define SELECT_MASK int
# endif
#endif
/*
* The following macro defines the number of fd_masks in an fd_set:
*/
#ifndef FD_SETSIZE
# ifdef OPEN_MAX
# define FD_SETSIZE OPEN_MAX
# else
# define FD_SETSIZE 256
# endif
#endif
#if !defined(howmany)
# define howmany(x, y) (((x)+((y)-1))/(y))
#endif
#ifndef NFDBITS
# define NFDBITS NBBY*sizeof(fd_mask)
#endif
#define MASK_SIZE howmany(FD_SETSIZE, NFDBITS)
/*
* Define "NBBY" (number of bits per byte) if it's not already defined.
*/
#ifndef NBBY
# define NBBY 8
#endif
/*
* The following define causes Tk to use its internal keysym hash table
*/
#define REDO_KEYSYM_LOOKUP
/*
* Defines for X functions that are used by Tk but are treated as
* no-op functions on the Macintosh.
*/
#define XFlush(display)
#define XFree(data) {if ((data) != NULL) ckfree((char *) (data));}
#define XGrabServer(display)
#define XNoOp(display) {display->request++;}
#define XUngrabServer(display)
#define XSynchronize(display, bool) {display->request++;}
#define XVisualIDFromVisual(visual) (visual->visualid)
/*
* The following functions are not used on the Mac, so we stub them out.
*/
#define TkFreeWindowId(dispPtr,w)
#define TkInitXId(dispPtr)
#define TkpCmapStressed(tkwin,colormap) (0)
#define TkpFreeColor(tkColPtr)
#define TkSetPixmapColormap(p,c) {}
#define TkpSync(display)
/*
* The following macro returns the pixel value that corresponds to the
* RGB values in the given XColor structure.
*/
#define PIXEL_MAGIC ((unsigned char) 0x69)
#define TkpGetPixel(p) ((((((PIXEL_MAGIC << 8) \
| (((p)->red >> 8) & 0xff)) << 8) \
| (((p)->green >> 8) & 0xff)) << 8) \
| (((p)->blue >> 8) & 0xff))
/*
* This macro stores a representation of the window handle in a string.
* This should perhaps use the real size of an XID.
*/
#define TkpPrintWindowId(buf,w) \
sprintf((buf), "0x%x", (unsigned int) (w))
/*
* TkpScanWindowId is just an alias for Tcl_GetInt on Unix.
*/
#define TkpScanWindowId(i,s,wp) \
Tcl_GetInt((i),(s),(int *) (wp))
/*
* Turn off Tk double-buffering as Aqua windows are already double-buffered.
*/
#define TK_NO_DOUBLE_BUFFERING 1
/*
* Magic pixel code values for system colors.
*
* NOTE: values must be kept in sync with indices into the
* systemColorMap array in tkMacOSXColor.c !
*/
#define TRANSPARENT_PIXEL 30
#define HIGHLIGHT_PIXEL 31
#define HIGHLIGHT_SECONDARY_PIXEL 32
#define HIGHLIGHT_TEXT_PIXEL 33
#define HIGHLIGHT_ALTERNATE_PIXEL 34
#define CONTROL_TEXT_PIXEL 35
#define CONTROL_BODY_PIXEL 37
#define CONTROL_FRAME_PIXEL 39
#define WINDOW_BODY_PIXEL 41
#define MENU_ACTIVE_PIXEL 43
#define MENU_ACTIVE_TEXT_PIXEL 45
#define MENU_BACKGROUND_PIXEL 47
#define MENU_DISABLED_PIXEL 49
#define MENU_TEXT_PIXEL 51
#define APPEARANCE_PIXEL 52
#endif /* _TKMACPORT */

366
macosx/tkMacOSXPrivate.h Normal file
View File

@@ -0,0 +1,366 @@
/*
* tkMacOSXPrivate.h --
*
* Macros and declarations that are purely internal & private to TkAqua.
*
* Copyright (c) 2005-2009 Daniel A. Steffen <das@users.sourceforge.net>
* Copyright 2008-2009, Apple Inc.
*
* See the file "license.terms" for information on usage and redistribution
* of this file, and for a DISCLAIMER OF ALL WARRANTIES.
*/
#ifndef _TKMACPRIV
#define _TKMACPRIV
#if !__OBJC__
#error Objective-C compiler required
#endif
#define TextStyle MacTextStyle
#import <ApplicationServices/ApplicationServices.h>
#import <Cocoa/Cocoa.h>
#ifndef NO_CARBON_H
#import <Carbon/Carbon.h>
#endif
#undef TextStyle
#import <objc/runtime.h> /* for sel_isEqual() */
#ifndef _TKMACINT
#include "tkMacOSXInt.h"
#endif
#ifndef _TKMACDEFAULT
#include "tkMacOSXDefault.h"
#endif
/* Macros for Mac OS X API availability checking */
#define TK_IF_MAC_OS_X_API(vers, symbol, ...) \
tk_if_mac_os_x_10_##vers(symbol != NULL, 1, __VA_ARGS__)
#define TK_ELSE_MAC_OS_X(vers, ...) \
tk_else_mac_os_x_10_##vers(__VA_ARGS__)
#define TK_IF_MAC_OS_X_API_COND(vers, symbol, cond, ...) \
tk_if_mac_os_x_10_##vers(symbol != NULL, cond, __VA_ARGS__)
#define TK_ELSE(...) \
} else { __VA_ARGS__
#define TK_ENDIF \
}
/* Private macros that implement the checking macros above */
#define tk_if_mac_os_x_yes(chk, cond, ...) \
if (cond) { __VA_ARGS__
#define tk_else_mac_os_x_yes(...) \
} else {
#define tk_if_mac_os_x_chk(chk, cond, ...) \
if ((chk) && (cond)) { __VA_ARGS__
#define tk_else_mac_os_x_chk(...) \
} else { __VA_ARGS__
#define tk_if_mac_os_x_no(chk, cond, ...) \
if (0) {
#define tk_else_mac_os_x_no(...) \
} else { __VA_ARGS__
/* Private mapping macros defined according to Mac OS X version requirements */
/* 10.5 Leopard */
#if MAC_OS_X_VERSION_MIN_REQUIRED >= 1050
#define tk_if_mac_os_x_min_10_5 tk_if_mac_os_x_yes
#define tk_else_mac_os_x_min_10_5 tk_else_mac_os_x_yes
#if MAC_OS_X_VERSION_MAX_ALLOWED >= 1050
#define tk_if_mac_os_x_10_5 tk_if_mac_os_x_yes
#define tk_else_mac_os_x_10_5 tk_else_mac_os_x_yes
#endif /* MAC_OS_X_VERSION_MAX_ALLOWED */
#else /* MAC_OS_X_VERSION_MIN_REQUIRED */
#define tk_if_mac_os_x_min_10_5 tk_if_mac_os_x_chk
#define tk_else_mac_os_x_min_10_5 tk_else_mac_os_x_chk
#if MAC_OS_X_VERSION_MAX_ALLOWED >= 1050
#define tk_if_mac_os_x_10_5 tk_if_mac_os_x_chk
#define tk_else_mac_os_x_10_5 tk_else_mac_os_x_chk
#endif /* MAC_OS_X_VERSION_MAX_ALLOWED */
#endif /* MAC_OS_X_VERSION_MIN_REQUIRED */
#if MAC_OS_X_VERSION_MAX_ALLOWED < 1050
#define tk_if_mac_os_x_10_5 tk_if_mac_os_x_no
#define tk_else_mac_os_x_10_5 tk_else_mac_os_x_no
#endif /* MAC_OS_X_VERSION_MAX_ALLOWED */
/*
* Macros for DEBUG_ASSERT_MESSAGE et al from Debugging.h.
*/
#undef kComponentSignatureString
#undef COMPONENT_SIGNATURE
#define kComponentSignatureString "TkMacOSX"
#define COMPONENT_SIGNATURE 'Tk '
/*
* Macros abstracting checks only active in a debug build.
*/
#ifdef TK_MAC_DEBUG
#define TKLog(f, ...) NSLog(f, ##__VA_ARGS__)
/*
* Macro to do debug message output.
*/
#define TkMacOSXDbgMsg(m, ...) \
do { \
TKLog(@"%s:%d: %s(): " m, strrchr(__FILE__, '/')+1, \
__LINE__, __func__, ##__VA_ARGS__); \
} while (0)
/*
* Macro to do debug API failure message output.
*/
#define TkMacOSXDbgOSErr(f, err) \
do { \
TkMacOSXDbgMsg("%s failed: %d", #f, (int)(err)); \
} while (0)
/*
* Macro to do very common check for noErr return from given API and output
* debug message in case of failure.
*/
#define ChkErr(f, ...) ({ \
OSStatus err = f(__VA_ARGS__); \
if (err != noErr) { \
TkMacOSXDbgOSErr(f, err); \
} \
err;})
#else /* TK_MAC_DEBUG */
#define TKLog(f, ...)
#define TkMacOSXDbgMsg(m, ...)
#define TkMacOSXDbgOSErr(f, err)
#define ChkErr(f, ...) ({f(__VA_ARGS__);})
#endif /* TK_MAC_DEBUG */
/*
* Macro abstracting use of TkMacOSXGetNamedSymbol to init named symbols.
*/
#define TkMacOSXInitNamedSymbol(module, ret, symbol, ...) \
static ret (* symbol)(__VA_ARGS__) = (void*)(-1L); \
if (symbol == (void*)(-1L)) { \
symbol = TkMacOSXGetNamedSymbol(STRINGIFY(module), \
STRINGIFY(symbol)); \
}
/*
* Macros for GC
*/
#define TkMacOSXMakeUncollectable(x) ({ id o = (id)(x); \
if (o) { if(tkMacOSXGCEnabled) CFRetain(o); } o; })
#define TkMacOSXMakeUncollectableAndRetain(x) ({ id o = (id)(x); \
if (o) { if(tkMacOSXGCEnabled) CFRetain(o); else [o retain]; } o; })
#define TkMacOSXMakeCollectable(x) ({ id o = (id)(x); \
if (o) { x = nil; if (tkMacOSXGCEnabled) CFRelease(o); } o; })
#define TkMacOSXMakeCollectableAndRelease(x) ({ id o = (id)(x); \
if (o) { x = nil; if (tkMacOSXGCEnabled) CFRelease(o); \
else [o release]; } o; })
#define TkMacOSXMakeCollectableAndAutorelease(x) ({ id o = (id)(x); \
if (o) { x = nil; if (tkMacOSXGCEnabled) CFRelease(o); \
else [o autorelease]; } o; })
/*
* Structure encapsulating current drawing environment.
*/
typedef struct TkMacOSXDrawingContext {
CGContextRef context;
NSView *view;
HIShapeRef clipRgn;
CGRect portBounds;
int focusLocked;
} TkMacOSXDrawingContext;
/*
* Variables internal to TkAqua.
*/
MODULE_SCOPE CGFloat tkMacOSXZeroScreenHeight;
MODULE_SCOPE CGFloat tkMacOSXZeroScreenTop;
MODULE_SCOPE int tkMacOSXGCEnabled;
MODULE_SCOPE long tkMacOSXMacOSXVersion;
#if TK_MAC_BUTTON_USE_COMPATIBILITY_METRICS
MODULE_SCOPE int tkMacOSXUseCompatibilityMetrics;
#endif
/*
* Prototypes for TkMacOSXRegion.c.
*/
#if 0
MODULE_SCOPE void TkMacOSXEmtpyRegion(TkRegion r);
MODULE_SCOPE int TkMacOSXIsEmptyRegion(TkRegion r);
#endif
MODULE_SCOPE HIShapeRef TkMacOSXGetNativeRegion(TkRegion r);
MODULE_SCOPE void TkMacOSXSetWithNativeRegion(TkRegion r,
HIShapeRef rgn);
MODULE_SCOPE void TkMacOSXOffsetRegion(TkRegion r, short dx, short dy);
MODULE_SCOPE HIShapeRef TkMacOSXHIShapeCreateEmpty(void);
MODULE_SCOPE HIMutableShapeRef TkMacOSXHIShapeCreateMutableWithRect(
const CGRect *inRect);
MODULE_SCOPE OSStatus TkMacOSXHIShapeSetWithShape(
HIMutableShapeRef inDestShape,
HIShapeRef inSrcShape);
#if 0
MODULE_SCOPE OSStatus TkMacOSXHIShapeSetWithRect(HIMutableShapeRef inShape,
const CGRect *inRect);
#endif
MODULE_SCOPE OSStatus TkMacOSHIShapeDifferenceWithRect(
HIMutableShapeRef inShape, const CGRect *inRect);
MODULE_SCOPE OSStatus TkMacOSHIShapeUnionWithRect(HIMutableShapeRef inShape,
const CGRect *inRect);
MODULE_SCOPE OSStatus TkMacOSHIShapeUnion(HIShapeRef inShape1,
HIShapeRef inShape2, HIMutableShapeRef outResult);
/*
* Prototypes of TkAqua internal procs.
*/
MODULE_SCOPE void * TkMacOSXGetNamedSymbol(const char *module,
const char *symbol);
MODULE_SCOPE void TkMacOSXDisplayChanged(Display *display);
MODULE_SCOPE int TkMacOSXUseAntialiasedText(Tcl_Interp *interp,
int enable);
MODULE_SCOPE int TkMacOSXInitCGDrawing(Tcl_Interp *interp, int enable,
int antiAlias);
MODULE_SCOPE int TkMacOSXGenerateFocusEvent(TkWindow *winPtr,
int activeFlag);
MODULE_SCOPE WindowClass TkMacOSXWindowClass(TkWindow *winPtr);
MODULE_SCOPE int TkMacOSXIsWindowZoomed(TkWindow *winPtr);
MODULE_SCOPE int TkGenerateButtonEventForXPointer(Window window);
MODULE_SCOPE EventModifiers TkMacOSXModifierState(void);
MODULE_SCOPE int TkMacOSXSetupDrawingContext(Drawable d, GC gc,
int useCG, TkMacOSXDrawingContext *dcPtr);
MODULE_SCOPE void TkMacOSXRestoreDrawingContext(
TkMacOSXDrawingContext *dcPtr);
MODULE_SCOPE void TkMacOSXSetColorInContext(GC gc, unsigned long pixel,
CGContextRef context);
MODULE_SCOPE int TkMacOSXMakeFullscreen(TkWindow *winPtr,
NSWindow *window, int fullscreen,
Tcl_Interp *interp);
MODULE_SCOPE void TkMacOSXEnterExitFullscreen(TkWindow *winPtr,
int active);
MODULE_SCOPE NSWindow* TkMacOSXDrawableWindow(Drawable drawable);
MODULE_SCOPE NSView* TkMacOSXDrawableView(MacDrawable *macWin);
MODULE_SCOPE void TkMacOSXWinCGBounds(TkWindow *winPtr, CGRect *bounds);
MODULE_SCOPE HIShapeRef TkMacOSXGetClipRgn(Drawable drawable);
MODULE_SCOPE void TkMacOSXInvalidateViewRegion(NSView *view,
HIShapeRef rgn);
MODULE_SCOPE CGImageRef TkMacOSXCreateCGImageWithDrawable(Drawable drawable);
MODULE_SCOPE NSImage* TkMacOSXGetNSImageWithTkImage(Display *display,
Tk_Image image, int width, int height);
MODULE_SCOPE NSImage* TkMacOSXGetNSImageWithBitmap(Display *display,
Pixmap bitmap, GC gc, int width, int height);
MODULE_SCOPE CGColorRef TkMacOSXCreateCGColor(GC gc, unsigned long pixel);
MODULE_SCOPE NSColor* TkMacOSXGetNSColor(GC gc, unsigned long pixel);
MODULE_SCOPE Tcl_Obj * TkMacOSXGetStringObjFromCFString(CFStringRef str);
MODULE_SCOPE TkWindow* TkMacOSXGetTkWindow(NSWindow *w);
MODULE_SCOPE NSFont* TkMacOSXNSFontForFont(Tk_Font tkfont);
MODULE_SCOPE NSDictionary* TkMacOSXNSFontAttributesForFont(Tk_Font tkfont);
MODULE_SCOPE NSModalSession TkMacOSXGetModalSession(void);
MODULE_SCOPE void TkMacOSXSelDeadWindow(TkWindow *winPtr);
MODULE_SCOPE void TkMacOSXApplyWindowAttributes(TkWindow *winPtr,
NSWindow *macWindow);
MODULE_SCOPE int TkMacOSXStandardAboutPanelObjCmd(ClientData clientData,
Tcl_Interp *interp, int objc,
Tcl_Obj *const objv[]);
MODULE_SCOPE int TkMacOSXIconBitmapObjCmd(ClientData clientData,
Tcl_Interp *interp, int objc,
Tcl_Obj *const objv[]);
#pragma mark Private Objective-C Classes
#define VISIBILITY_HIDDEN __attribute__((visibility("hidden")))
enum { tkMainMenu = 1, tkApplicationMenu, tkWindowsMenu, tkHelpMenu};
VISIBILITY_HIDDEN
@interface TKMenu : NSMenu {
@private
void *_tkMenu;
NSUInteger _tkOffset, _tkItemCount, _tkSpecial;
}
- (void)setSpecial:(NSUInteger)special;
- (BOOL)isSpecial:(NSUInteger)special;
@end
VISIBILITY_HIDDEN
@interface TKApplication : NSApplication {
@private
Tcl_Interp *_eventInterp;
NSMenu *_servicesMenu;
TKMenu *_defaultMainMenu, *_defaultApplicationMenu;
NSArray *_defaultApplicationMenuItems, *_defaultWindowsMenuItems;
NSArray *_defaultHelpMenuItems;
}
@end
@interface TKApplication(TKInit)
- (NSString *)tkFrameworkImagePath:(NSString*)image;
@end
@interface TKApplication(TKEvent)
- (NSEvent *)tkProcessEvent:(NSEvent *)theEvent;
@end
@interface TKApplication(TKMouseEvent)
- (NSEvent *)tkProcessMouseEvent:(NSEvent *)theEvent;
@end
@interface TKApplication(TKKeyEvent)
- (NSEvent *)tkProcessKeyEvent:(NSEvent *)theEvent;
@end
@interface TKApplication(TKMenu)
- (void)tkSetMainMenu:(TKMenu *)menu;
@end
@interface TKApplication(TKClipboard)
- (void)tkProvidePasteboard:(TkDisplay *)dispPtr;
- (void)tkCheckPasteboard;
@end
VISIBILITY_HIDDEN
@interface TKContentView : NSView <NSTextInput> {
@private
id _savedSubviews;
BOOL _subviewsSetAside;
NSString *_workingText;
}
@end
@interface TKContentView(TKKeyEvent)
- (void) deleteWorkingText;
@end
VISIBILITY_HIDDEN
@interface TKWindow : NSWindow
@end
#pragma mark NSMenu & NSMenuItem Utilities
@interface NSMenu(TKUtils)
+ (id)menuWithTitle:(NSString *)title;
+ (id)menuWithTitle:(NSString *)title menuItems:(NSArray *)items;
+ (id)menuWithTitle:(NSString *)title submenus:(NSArray *)submenus;
- (NSMenuItem *)itemWithSubmenu:(NSMenu *)submenu;
- (NSMenuItem *)itemInSupermenu;
@end
@interface NSMenuItem(TKUtils)
+ (id)itemWithSubmenu:(NSMenu *)submenu;
+ (id)itemWithTitle:(NSString *)title submenu:(NSMenu *)submenu;
+ (id)itemWithTitle:(NSString *)title action:(SEL)action;
+ (id)itemWithTitle:(NSString *)title action:(SEL)action
target:(id)target;
+ (id)itemWithTitle:(NSString *)title action:(SEL)action
keyEquivalent:(NSString *)keyEquivalent;
+ (id)itemWithTitle:(NSString *)title action:(SEL)action
target:(id)target keyEquivalent:(NSString *)keyEquivalent;
+ (id)itemWithTitle:(NSString *)title action:(SEL)action
keyEquivalent:(NSString *)keyEquivalent
keyEquivalentModifierMask:(NSUInteger)keyEquivalentModifierMask;
+ (id)itemWithTitle:(NSString *)title action:(SEL)action
target:(id)target keyEquivalent:(NSString *)keyEquivalent
keyEquivalentModifierMask:(NSUInteger)keyEquivalentModifierMask;
@end
/* From WebKit/WebKit/mac/WebCoreSupport/WebChromeClient.mm: */
@interface NSWindow(TKGrowBoxRect)
- (NSRect)_growBoxRect;
@end
#endif /* _TKMACPRIV */

559
macosx/tkMacOSXRegion.c Normal file
View File

@@ -0,0 +1,559 @@
/*
* tkMacOSXRegion.c --
*
* Implements X window calls for manipulating regions
*
* Copyright (c) 1995-1996 Sun Microsystems, Inc.
* Copyright 2001-2009, Apple Inc.
* Copyright (c) 2006-2009 Daniel A. Steffen <das@users.sourceforge.net>
*
* See the file "license.terms" for information on usage and redistribution
* of this file, and for a DISCLAIMER OF ALL WARRANTIES.
*/
#include "tkMacOSXPrivate.h"
/*
*----------------------------------------------------------------------
*
* TkCreateRegion --
*
* Implements the equivelent of the X window function XCreateRegion. See
* Xwindow documentation for more details.
*
* Results:
* Returns an allocated region handle.
*
* Side effects:
* None.
*
*----------------------------------------------------------------------
*/
TkRegion
TkCreateRegion(void)
{
return (TkRegion) HIShapeCreateMutable();
}
/*
*----------------------------------------------------------------------
*
* TkDestroyRegion --
*
* Implements the equivelent of the X window function XDestroyRegion. See
* Xwindow documentation for more details.
*
* Results:
* None.
*
* Side effects:
* Memory is freed.
*
*----------------------------------------------------------------------
*/
void
TkDestroyRegion(
TkRegion r)
{
if (r) {
CFRelease(r);
}
}
/*
*----------------------------------------------------------------------
*
* TkIntersectRegion --
*
* Implements the equivalent of the X window function XIntersectRegion.
* See Xwindow documentation for more details.
*
* Results:
* None.
*
* Side effects:
* None.
*
*----------------------------------------------------------------------
*/
void
TkIntersectRegion(
TkRegion sra,
TkRegion srb,
TkRegion dr_return)
{
ChkErr(HIShapeIntersect, (HIShapeRef) sra, (HIShapeRef) srb,
(HIMutableShapeRef) dr_return);
}
/*
*----------------------------------------------------------------------
*
* TkSubtractRegion --
*
* Implements the equivalent of the X window function XSubtractRegion.
* See X window documentation for more details.
*
* Results:
* None.
*
* Side effects:
* None.
*
*----------------------------------------------------------------------
*/
void
TkSubtractRegion(
TkRegion sra,
TkRegion srb,
TkRegion dr_return)
{
ChkErr(HIShapeDifference, (HIShapeRef) sra, (HIShapeRef) srb,
(HIMutableShapeRef) dr_return);
}
/*
*----------------------------------------------------------------------
*
* TkUnionRectWithRegion --
*
* Implements the equivelent of the X window function
* XUnionRectWithRegion. See Xwindow documentation for more details.
*
* Results:
* None.
*
* Side effects:
* None.
*
*----------------------------------------------------------------------
*/
void
TkUnionRectWithRegion(
XRectangle* rectangle,
TkRegion src_region,
TkRegion dest_region_return)
{
const CGRect r = CGRectMake(rectangle->x, rectangle->y,
rectangle->width, rectangle->height);
if (src_region == dest_region_return) {
ChkErr(TkMacOSHIShapeUnionWithRect,
(HIMutableShapeRef) dest_region_return, &r);
} else {
HIShapeRef rectRgn = HIShapeCreateWithRect(&r);
ChkErr(TkMacOSHIShapeUnion, rectRgn, (HIShapeRef) src_region,
(HIMutableShapeRef) dest_region_return);
CFRelease(rectRgn);
}
}
/*
*----------------------------------------------------------------------
*
* TkRectInRegion --
*
* Implements the equivelent of the X window function XRectInRegion. See
* Xwindow documentation for more details.
*
* Results:
* Returns RectanglePart or RectangleOut. Note that this is not a
* complete implementation since it doesn't test for RectangleIn.
*
* Side effects:
* None.
*
*----------------------------------------------------------------------
*/
int
TkRectInRegion(
TkRegion region,
int x,
int y,
unsigned int width,
unsigned int height)
{
int result;
const CGRect r = CGRectMake(x, y, width, height);
result = HIShapeIntersectsRect((HIShapeRef) region, &r) ?
RectanglePart : RectangleOut;
return result;
}
/*
*----------------------------------------------------------------------
*
* TkClipBox --
*
* Implements the equivelent of the X window function XClipBox. See
* Xwindow documentation for more details.
*
* Results:
* None.
*
* Side effects:
* None.
*
*----------------------------------------------------------------------
*/
void
TkClipBox(
TkRegion r,
XRectangle* rect_return)
{
CGRect rect;
HIShapeGetBounds((HIShapeRef) r, &rect);
rect_return->x = rect.origin.x;
rect_return->y = rect.origin.y;
rect_return->width = rect.size.width;
rect_return->height = rect.size.height;
}
/*
*----------------------------------------------------------------------
*
* TkpBuildRegionFromAlphaData --
*
* Set up a rectangle of the given region based on the supplied alpha
* data.
*
* Results:
* None
*
* Side effects:
* The region is updated, with extra pixels added to it.
*
*----------------------------------------------------------------------
*/
void
TkpBuildRegionFromAlphaData(
TkRegion region, /* Region to update. */
unsigned int x, /* Where in region to update. */
unsigned int y, /* Where in region to update. */
unsigned int width, /* Size of rectangle to update. */
unsigned int height, /* Size of rectangle to update. */
unsigned char *dataPtr, /* Data to read from. */
unsigned int pixelStride, /* num bytes from one piece of alpha
* data to the next in the line. */
unsigned int lineStride) /* num bytes from one line of alpha
* data to the next line. */
{
unsigned char *lineDataPtr;
unsigned int x1, y1, end;
XRectangle rect;
for (y1 = 0; y1 < height; y1++) {
lineDataPtr = dataPtr;
for (x1 = 0; x1 < width; x1 = end) {
/*
* Search for first non-transparent pixel.
*/
while ((x1 < width) && !*lineDataPtr) {
x1++;
lineDataPtr += pixelStride;
}
end = x1;
/*
* Search for first transparent pixel.
*/
while ((end < width) && *lineDataPtr) {
end++;
lineDataPtr += pixelStride;
}
if (end > x1) {
rect.x = x + x1;
rect.y = y + y1;
rect.width = end - x1;
rect.height = 1;
TkUnionRectWithRegion(&rect, region, region);
}
}
dataPtr += lineStride;
}
}
/*
*----------------------------------------------------------------------
*
* TkpRetainRegion --
*
* Increases reference count of region.
*
* Results:
* None.
*
* Side effects:
* None.
*
*----------------------------------------------------------------------
*/
void
TkpRetainRegion(
TkRegion r)
{
CFRetain(r);
}
/*
*----------------------------------------------------------------------
*
* TkpReleaseRegion --
*
* Decreases reference count of region.
*
* Results:
* None.
*
* Side effects:
* May free memory.
*
*----------------------------------------------------------------------
*/
void
TkpReleaseRegion(
TkRegion r)
{
CFRelease(r);
}
#if 0
/*
*----------------------------------------------------------------------
*
* TkMacOSXEmtpyRegion --
*
* Set region to emtpy.
*
* Results:
* None.
*
* Side effects:
* None.
*
*----------------------------------------------------------------------
*/
void
TkMacOSXEmtpyRegion(
TkRegion r)
{
ChkErr(HIShapeSetEmpty, (HIMutableShapeRef) r);
}
/*
*----------------------------------------------------------------------
*
* TkMacOSXIsEmptyRegion --
*
* Return native region for given tk region.
*
* Results:
* 1 if empty, 0 otherwise.
*
* Side effects:
* None.
*
*----------------------------------------------------------------------
*/
int
TkMacOSXIsEmptyRegion(
TkRegion r)
{
return HIShapeIsEmpty((HIMutableShapeRef) r) ? 1 : 0;
}
#endif
/*
*----------------------------------------------------------------------
*
* TkMacOSXGetNativeRegion --
*
* Return native region for given tk region.
*
* Results:
* Native region, CFRelease when done.
*
* Side effects:
* None.
*
*----------------------------------------------------------------------
*/
HIShapeRef
TkMacOSXGetNativeRegion(
TkRegion r)
{
return (HIShapeRef) CFRetain(r);
}
/*
*----------------------------------------------------------------------
*
* TkMacOSXSetWithNativeRegion --
*
* Set region to the native region.
*
* Results:
* None.
*
* Side effects:
* None.
*
*----------------------------------------------------------------------
*/
void
TkMacOSXSetWithNativeRegion(
TkRegion r,
HIShapeRef rgn)
{
ChkErr(TkMacOSXHIShapeSetWithShape, (HIMutableShapeRef) r, rgn);
}
/*
*----------------------------------------------------------------------
*
* TkMacOSXOffsetRegion --
*
* Offsets region by given distances.
*
* Results:
* None.
*
* Side effects:
* None.
*
*----------------------------------------------------------------------
*/
void
TkMacOSXOffsetRegion(
TkRegion r,
short dx,
short dy)
{
ChkErr(HIShapeOffset, (HIMutableShapeRef) r, dx, dy);
}
/*
*----------------------------------------------------------------------
*
* TkMacOSXHIShapeCreateEmpty, TkMacOSXHIShapeCreateMutableWithRect,
* TkMacOSXHIShapeSetWithShape, TkMacOSXHIShapeSetWithRect,
* TkMacOSHIShapeDifferenceWithRect, TkMacOSHIShapeUnionWithRect,
* TkMacOSHIShapeUnion --
*
* Wrapper functions for missing/buggy HIShape API
*
*----------------------------------------------------------------------
*/
HIShapeRef
TkMacOSXHIShapeCreateEmpty(void)
{
HIShapeRef result;
result = HIShapeCreateEmpty();
return result;
}
HIMutableShapeRef
TkMacOSXHIShapeCreateMutableWithRect(
const CGRect *inRect)
{
HIMutableShapeRef result;
result = HIShapeCreateMutableWithRect(inRect);
return result;
}
OSStatus
TkMacOSXHIShapeSetWithShape(
HIMutableShapeRef inDestShape,
HIShapeRef inSrcShape)
{
OSStatus result;
result = HIShapeSetWithShape(inDestShape, inSrcShape);
return result;
}
#if 0
OSStatus
TkMacOSXHIShapeSetWithRect(
HIMutableShapeRef inShape,
const CGRect *inRect)
{
OSStatus result;
HIShapeRef rgn = HIShapeCreateWithRect(inRect);
result = TkMacOSXHIShapeSetWithShape(inShape, rgn);
CFRelease(rgn);
return result;
}
#endif
OSStatus
TkMacOSHIShapeDifferenceWithRect(
HIMutableShapeRef inShape,
const CGRect *inRect)
{
OSStatus result;
HIShapeRef rgn = HIShapeCreateWithRect(inRect);
result = HIShapeDifference(inShape, rgn, inShape);
CFRelease(rgn);
return result;
}
OSStatus
TkMacOSHIShapeUnionWithRect(
HIMutableShapeRef inShape,
const CGRect *inRect)
{
OSStatus result;
result = HIShapeUnionWithRect(inShape, inRect);
return result;
}
OSStatus
TkMacOSHIShapeUnion(
HIShapeRef inShape1,
HIShapeRef inShape2,
HIMutableShapeRef outResult)
{
OSStatus result;
result = HIShapeUnion(inShape1, inShape2, outResult);
return result;
}
/*
* Local Variables:
* mode: objc
* c-basic-offset: 4
* fill-column: 79
* coding: utf-8
* End:
*/

493
macosx/tkMacOSXScale.c Normal file
View File

@@ -0,0 +1,493 @@
/*
* tkMacOSXScale.c --
*
* This file implements the Macintosh specific portion of the
* scale widget.
*
* Copyright (c) 1996 by Sun Microsystems, Inc.
* Copyright (c) 1998-2000 by Scriptics Corporation.
* Copyright (c) 2006-2009 Daniel A. Steffen <das@users.sourceforge.net>
* Copyright 2008-2009, Apple Inc.
*
* See the file "license.terms" for information on usage and redistribution
* of this file, and for a DISCLAIMER OF ALL WARRANTIES.
*/
#include "tkMacOSXPrivate.h"
#include "tkScale.h"
#ifdef MAC_OSX_TK_TODO
/*
#ifdef TK_MAC_DEBUG
#define TK_MAC_DEBUG_SCALE
#endif
*/
/*
* Defines used in this file.
*/
#define slider 1110
#define inSlider 1
#define inInc 2
#define inDecr 3
/*
* Declaration of Macintosh specific scale structure.
*/
typedef struct MacScale {
TkScale info; /* Generic scale info. */
int flags; /* Flags. */
ControlRef scaleHandle; /* Handle to the Scale control struct. */
} MacScale;
/*
* Globals uses locally in this file.
*/
static ControlActionUPP scaleActionProc = NULL; /* Pointer to func. */
/*
* Forward declarations for procedures defined later in this file:
*/
static void MacScaleEventProc(ClientData clientData, XEvent *eventPtr);
static pascal void ScaleActionProc(ControlRef theControl,
ControlPartCode partCode);
/*
*----------------------------------------------------------------------
*
* TkpCreateScale --
*
* Allocate a new TkScale structure.
*
* Results:
* Returns a newly allocated TkScale structure.
*
* Side effects:
* None.
*
*----------------------------------------------------------------------
*/
TkScale *
TkpCreateScale(
Tk_Window tkwin)
{
MacScale *macScalePtr = (MacScale *) ckalloc(sizeof(MacScale));
macScalePtr->scaleHandle = NULL;
if (scaleActionProc == NULL) {
scaleActionProc = NewControlActionUPP(ScaleActionProc);
}
Tk_CreateEventHandler(tkwin, ButtonPressMask,
MacScaleEventProc, (ClientData) macScalePtr);
return (TkScale *) macScalePtr;
}
/*
*----------------------------------------------------------------------
*
* TkpDestroyScale --
*
* Free Macintosh specific resources.
*
* Results:
* None
*
* Side effects:
* The slider control is destroyed.
*
*----------------------------------------------------------------------
*/
void
TkpDestroyScale(
TkScale *scalePtr)
{
MacScale *macScalePtr = (MacScale *) scalePtr;
/*
* Free Macintosh control.
*/
if (macScalePtr->scaleHandle != NULL) {
DisposeControl(macScalePtr->scaleHandle);
}
}
/*
*----------------------------------------------------------------------
*
* TkpDisplayScale --
*
* This procedure is invoked as an idle handler to redisplay
* the contents of a scale widget.
*
* Results:
* None.
*
* Side effects:
* The scale gets redisplayed.
*
*----------------------------------------------------------------------
*/
void
TkpDisplayScale(
ClientData clientData) /* Widget record for scale. */
{
TkScale *scalePtr = (TkScale *) clientData;
Tk_Window tkwin = scalePtr->tkwin;
Tcl_Interp *interp = scalePtr->interp;
int result;
char string[PRINT_CHARS];
MacScale *macScalePtr = (MacScale *) clientData;
Rect r;
WindowRef windowRef;
CGrafPtr destPort, savePort;
Boolean portChanged;
MacDrawable *macDraw;
SInt32 initialValue, minValue, maxValue;
UInt16 numTicks;
#ifdef TK_MAC_DEBUG_SCALE
TkMacOSXDbgMsg("TkpDisplayScale");
#endif
scalePtr->flags &= ~REDRAW_PENDING;
if ((scalePtr->tkwin == NULL) || !Tk_IsMapped(scalePtr->tkwin)) {
goto done;
}
/*
* Invoke the scale's command if needed.
*/
Tcl_Preserve((ClientData) scalePtr);
if ((scalePtr->flags & INVOKE_COMMAND) && (scalePtr->command != NULL)) {
Tcl_Preserve((ClientData) interp);
sprintf(string, scalePtr->format, scalePtr->value);
result = Tcl_VarEval(interp, scalePtr->command, " ", string, NULL);
if (result != TCL_OK) {
Tcl_AddErrorInfo(interp, "\n (command executed by scale)");
Tcl_BackgroundError(interp);
}
Tcl_Release((ClientData) interp);
}
scalePtr->flags &= ~INVOKE_COMMAND;
if (scalePtr->flags & SCALE_DELETED) {
Tcl_Release((ClientData) scalePtr);
return;
}
Tcl_Release((ClientData) scalePtr);
/*
* Now handle the part of redisplay that is the same for
* horizontal and vertical scales: border and traversal
* highlight.
*/
if (scalePtr->highlightWidth != 0) {
GC gc = Tk_GCForColor(scalePtr->highlightColorPtr, Tk_WindowId(tkwin));
Tk_DrawFocusHighlight(tkwin, gc, scalePtr->highlightWidth,
Tk_WindowId(tkwin));
}
Tk_Draw3DRectangle(tkwin, Tk_WindowId(tkwin), scalePtr->bgBorder,
scalePtr->highlightWidth, scalePtr->highlightWidth,
Tk_Width(tkwin) - 2*scalePtr->highlightWidth,
Tk_Height(tkwin) - 2*scalePtr->highlightWidth,
scalePtr->borderWidth, scalePtr->relief);
/*
* Set up port for drawing Macintosh control.
*/
macDraw = (MacDrawable *) Tk_WindowId(tkwin);
destPort = TkMacOSXGetDrawablePort(Tk_WindowId(tkwin));
windowRef = TkMacOSXDrawableWindow(Tk_WindowId(tkwin));
portChanged = QDSwapPort(destPort, &savePort);
TkMacOSXSetUpClippingRgn(Tk_WindowId(tkwin));
/*
* Create Macintosh control.
*/
#define MAC_OSX_SCROLL_WIDTH 10
if (scalePtr->orient == ORIENT_HORIZONTAL) {
int offset = (Tk_Height(tkwin) - MAC_OSX_SCROLL_WIDTH)/2;
if (offset < 0) {
offset = 0;
}
r.left = macDraw->xOff + scalePtr->inset;
r.top = macDraw->yOff + offset;
r.right = macDraw->xOff+Tk_Width(tkwin) - scalePtr->inset;
r.bottom = macDraw->yOff + offset + MAC_OSX_SCROLL_WIDTH/2;
} else {
int offset = (Tk_Width(tkwin) - MAC_OSX_SCROLL_WIDTH)/2;
if (offset < 0) {
offset = 0;
}
r.left = macDraw->xOff + offset;
r.top = macDraw->yOff + scalePtr->inset;
r.right = macDraw->xOff + offset + MAC_OSX_SCROLL_WIDTH/2;
r.bottom = macDraw->yOff+Tk_Height(tkwin) - scalePtr->inset;
}
if (macScalePtr->scaleHandle == NULL) {
#ifdef TK_MAC_DEBUG_SCALE
TkMacOSXDbgMsg("Initialising scale");
#endif
initialValue = scalePtr->value;
if (scalePtr->orient == ORIENT_HORIZONTAL) {
minValue = scalePtr->fromValue;
maxValue = scalePtr->toValue;
} else {
minValue = scalePtr->fromValue;
maxValue = scalePtr->toValue;
}
if (scalePtr->tickInterval == 0) {
numTicks = 0;
} else {
numTicks = (maxValue - minValue)/scalePtr->tickInterval;
}
CreateSliderControl(windowRef, &r, initialValue, minValue, maxValue,
kControlSliderPointsDownOrRight, numTicks, 1, scaleActionProc,
&(macScalePtr->scaleHandle));
SetControlReference(macScalePtr->scaleHandle, (UInt32) scalePtr);
if (IsWindowActive(windowRef)) {
macScalePtr->flags |= ACTIVE;
}
} else {
SetControlBounds(macScalePtr->scaleHandle, &r);
SetControl32BitValue(macScalePtr->scaleHandle, scalePtr->value);
SetControl32BitMinimum(macScalePtr->scaleHandle, scalePtr->fromValue);
SetControl32BitMaximum(macScalePtr->scaleHandle, scalePtr->toValue);
}
/*
* Finally draw the control.
*/
SetControlVisibility(macScalePtr->scaleHandle,true,true);
HiliteControl(macScalePtr->scaleHandle,0);
Draw1Control(macScalePtr->scaleHandle);
if (portChanged) {
QDSwapPort(savePort, NULL);
}
done:
scalePtr->flags &= ~REDRAW_ALL;
}
/*
*----------------------------------------------------------------------
*
* TkpScaleElement --
*
* Determine which part of a scale widget lies under a given
* point.
*
* Results:
* The return value is either TROUGH1, SLIDER, TROUGH2, or
* OTHER, depending on which of the scale's active elements
* (if any) is under the point at (x,y).
*
* Side effects:
* None.
*
*----------------------------------------------------------------------
*/
int
TkpScaleElement(
TkScale *scalePtr, /* Widget record for scale. */
int x, int y) /* Coordinates within scalePtr's window. */
{
MacScale *macScalePtr = (MacScale *) scalePtr;
ControlPartCode part;
Point where;
Rect bounds;
CGrafPtr destPort, savePort;
Boolean portChanged;
#ifdef TK_MAC_DEBUG_SCALE
TkMacOSXDbgMsg("TkpScaleElement");
#endif
destPort = TkMacOSXGetDrawablePort(Tk_WindowId(scalePtr->tkwin));
portChanged = QDSwapPort(destPort, &savePort);
/*
* All of the calculations in this procedure mirror those in
* DisplayScrollbar. Be sure to keep the two consistent.
*/
TkMacOSXWinBounds((TkWindow *) scalePtr->tkwin, &bounds);
where.h = x + bounds.left;
where.v = y + bounds.top;
part = TestControl(macScalePtr->scaleHandle, where);
if (portChanged) {
QDSwapPort(savePort, NULL);
}
#ifdef TK_MAC_DEBUG_SCALE
fprintf (stderr,"ScalePart %d, pos ( %d %d )\n", part, where.h, where.v );
#endif
switch (part) {
case inSlider:
return SLIDER;
case inInc:
if (scalePtr->orient == ORIENT_VERTICAL) {
return TROUGH1;
} else {
return TROUGH2;
}
case inDecr:
if (scalePtr->orient == ORIENT_VERTICAL) {
return TROUGH2;
} else {
return TROUGH1;
}
default:
return OTHER;
}
}
/*
*--------------------------------------------------------------
*
* MacScaleEventProc --
*
* This procedure is invoked by the Tk dispatcher for
* ButtonPress events on scales.
*
* Results:
* None.
*
* Side effects:
* When the window gets deleted, internal structures get
* cleaned up. When it gets exposed, it is redisplayed.
*
*--------------------------------------------------------------
*/
static void
MacScaleEventProc(
ClientData clientData, /* Information about window. */
XEvent *eventPtr) /* Information about event. */
{
MacScale *macScalePtr = (MacScale *) clientData;
Point where;
Rect bounds;
int part;
CGrafPtr destPort, savePort;
Boolean portChanged;
#ifdef TK_MAC_DEBUG_SCALE
fprintf(stderr,"MacScaleEventProc\n" );
#endif
/*
* To call Macintosh control routines we must have the port
* set to the window containing the control. We will then test
* which part of the control was hit and act accordingly.
*/
destPort = TkMacOSXGetDrawablePort(Tk_WindowId(macScalePtr->info.tkwin));
portChanged = QDSwapPort(destPort, &savePort);
TkMacOSXSetUpClippingRgn(Tk_WindowId(macScalePtr->info.tkwin));
TkMacOSXWinBounds((TkWindow *) macScalePtr->info.tkwin, &bounds);
where.h = eventPtr->xbutton.x + bounds.left;
where.v = eventPtr->xbutton.y + bounds.top;
#ifdef TK_MAC_DEBUG_SCALE
TkMacOSXDbgMsg("calling TestControl");
#endif
part = TestControl(macScalePtr->scaleHandle, where);
if (part == 0) {
return;
}
TkMacOSXTrackingLoop(1);
part = HandleControlClick(macScalePtr->scaleHandle, where,
TkMacOSXModifierState(), scaleActionProc);
TkMacOSXTrackingLoop(0);
/*
* Update the value for the widget.
*/
macScalePtr->info.value = GetControlValue(macScalePtr->scaleHandle);
/* TkScaleSetValue(&macScalePtr->info, macScalePtr->info.value, 1, 0); */
/*
* The HandleControlClick call will "eat" the ButtonUp event. We now
* generate a ButtonUp event so Tk will unset implicit grabs etc.
*/
TkGenerateButtonEventForXPointer(Tk_WindowId(macScalePtr->info.tkwin));
if (portChanged) {
QDSwapPort(savePort, NULL);
}
}
/*
*--------------------------------------------------------------
*
* ScaleActionProc --
*
* Callback procedure used by the Macintosh toolbox call
* HandleControlClick. This call will update the display
* while the scrollbar is being manipulated by the user.
*
* Results:
* None.
*
* Side effects:
* May change the display.
*
*--------------------------------------------------------------
*/
static pascal void
ScaleActionProc(
ControlRef theControl, /* Handle to scrollbat control */
ControlPartCode partCode) /* Part of scrollbar that was "hit" */
{
int value;
TkScale *scalePtr = (TkScale *) GetControlReference(theControl);
#ifdef TK_MAC_DEBUG_SCALE
TkMacOSXDbgMsg("ScaleActionProc");
#endif
value = GetControlValue(theControl);
TkScaleSetValue(scalePtr, value, 1, 1);
Tcl_Preserve((ClientData) scalePtr);
TkMacOSXRunTclEventLoop();
Tcl_Release((ClientData) scalePtr);
}
#endif
/*
* Local Variables:
* mode: objc
* c-basic-offset: 4
* fill-column: 79
* coding: utf-8
* End:
*/

622
macosx/tkMacOSXScrlbr.c Normal file
View File

@@ -0,0 +1,622 @@
/*
* tkMacOSXScrollbar.c --
*
* This file implements the Macintosh specific portion of the scrollbar
* widget.
*
* Copyright (c) 1996 by Sun Microsystems, Inc.
* Copyright 2001-2009, Apple Inc.
* Copyright (c) 2006-2009 Daniel A. Steffen <das@users.sourceforge.net>
*
* See the file "license.terms" for information on usage and redistribution
* of this file, and for a DISCLAIMER OF ALL WARRANTIES.
*/
#include "tkMacOSXPrivate.h"
#include "tkScrollbar.h"
/*
#ifdef TK_MAC_DEBUG
#define TK_MAC_DEBUG_SCROLLBAR
#endif
*/
/*
* Declaration of Mac specific scrollbar structure.
*/
typedef struct MacScrollbar {
TkScrollbar info;
NSScroller *scroller;
int variant;
} MacScrollbar;
typedef struct ScrollbarMetrics {
SInt32 width, minThumbHeight;
int minHeight, topArrowHeight, bottomArrowHeight;
NSControlSize controlSize;
} ScrollbarMetrics;
static ScrollbarMetrics metrics[2] = {
{15, 54, 26, 14, 14, NSRegularControlSize}, /* kThemeScrollBarMedium */
{11, 40, 20, 10, 10, NSSmallControlSize}, /* kThemeScrollBarSmall */
};
/*
* Declarations for functions defined in this file.
*/
static void UpdateScrollbarMetrics(void);
static void ScrollbarEventProc(ClientData clientData,
XEvent *eventPtr);
/*
* The class procedure table for the scrollbar widget.
*/
Tk_ClassProcs tkpScrollbarProcs = {
sizeof(Tk_ClassProcs), /* size */
NULL, /* worldChangedProc */
NULL, /* createProc */
NULL /* modalProc */
};
#pragma mark TKApplication(TKScrlbr)
#define NSAppleAquaScrollBarVariantChanged @"AppleAquaScrollBarVariantChanged"
@implementation TKApplication(TKScrlbr)
- (void) tkScroller: (NSScroller *) scroller
{
NSScrollerPart hitPart = [scroller hitPart];
TkScrollbar *scrollPtr = (TkScrollbar *)[scroller tag];
Tcl_DString cmdString;
Tcl_Interp *interp;
int result;
if (!scrollPtr || !scrollPtr->command || !scrollPtr->commandSize ||
hitPart == NSScrollerNoPart) {
return;
}
Tcl_DStringInit(&cmdString);
Tcl_DStringAppend(&cmdString, scrollPtr->command,
scrollPtr->commandSize);
switch (hitPart) {
case NSScrollerKnob:
case NSScrollerKnobSlot: {
char valueString[TCL_DOUBLE_SPACE];
Tcl_PrintDouble(NULL, [scroller doubleValue] *
(1.0 - [scroller knobProportion]), valueString);
Tcl_DStringAppendElement(&cmdString, "moveto");
Tcl_DStringAppendElement(&cmdString, valueString);
break;
}
case NSScrollerDecrementLine:
case NSScrollerIncrementLine:
Tcl_DStringAppendElement(&cmdString, "scroll");
Tcl_DStringAppendElement(&cmdString,
(hitPart == NSScrollerDecrementLine) ? "-1" : "1");
Tcl_DStringAppendElement(&cmdString, "unit");
break;
case NSScrollerDecrementPage:
case NSScrollerIncrementPage:
Tcl_DStringAppendElement(&cmdString, "scroll");
Tcl_DStringAppendElement(&cmdString,
(hitPart == NSScrollerDecrementPage) ? "-1" : "1");
Tcl_DStringAppendElement(&cmdString, "page");
break;
}
interp = scrollPtr->interp;
Tcl_Preserve(interp);
Tcl_Preserve(scrollPtr);
result = Tcl_EvalEx(interp, Tcl_DStringValue(&cmdString),
Tcl_DStringLength(&cmdString), TCL_EVAL_GLOBAL);
if (result != TCL_OK && result != TCL_CONTINUE && result != TCL_BREAK) {
Tcl_AddErrorInfo(interp, "\n (scrollbar command)");
Tcl_BackgroundError(interp);
}
Tcl_Release(scrollPtr);
Tcl_Release(interp);
Tcl_DStringFree(&cmdString);
#ifdef TK_MAC_DEBUG_SCROLLBAR
TKLog(@"scroller %s value %f knobProportion %f",
((TkWindow *)scrollPtr->tkwin)->pathName, [scroller doubleValue],
[scroller knobProportion]);
#endif
}
- (void) scrollBarVariantChanged: (NSNotification *) notification
{
#ifdef TK_MAC_DEBUG_NOTIFICATIONS
TKLog(@"-[%@(%p) %s] %@", [self class], self, _cmd, notification);
#endif
UpdateScrollbarMetrics();
}
- (void) _setupScrollBarNotifications
{
NSNotificationCenter *nc = [NSNotificationCenter defaultCenter];
#define observe(n, s) [nc addObserver:self selector:@selector(s) name:(n) object:nil]
observe(NSAppleAquaScrollBarVariantChanged, scrollBarVariantChanged:);
#undef observe
UpdateScrollbarMetrics();
}
@end
#pragma mark -
/*
*----------------------------------------------------------------------
*
* UpdateScrollbarMetrics --
*
* This function retrieves the current system metrics for a scrollbar.
*
* Results:
* None.
*
* Side effects:
* Updates the geometry cache info for all scrollbars.
*
*----------------------------------------------------------------------
*/
static void
UpdateScrollbarMetrics(void)
{
const short height = 100, width = 50;
HIThemeTrackDrawInfo info = {
.version = 0,
.bounds = {{0, 0}, {width, height}},
.min = 0,
.max = 1,
.value = 0,
.attributes = kThemeTrackShowThumb,
.enableState = kThemeTrackActive,
.trackInfo.scrollbar = {.viewsize = 1, .pressState = 0},
};
CGRect bounds;
ChkErr(GetThemeMetric, kThemeMetricScrollBarWidth, &metrics[0].width);
ChkErr(GetThemeMetric, kThemeMetricScrollBarMinThumbHeight,
&metrics[0].minThumbHeight);
info.kind = kThemeScrollBarMedium;
ChkErr(HIThemeGetTrackDragRect, &info, &bounds);
metrics[0].topArrowHeight = bounds.origin.y;
metrics[0].bottomArrowHeight = height - (bounds.origin.y +
bounds.size.height);
metrics[0].minHeight = metrics[0].minThumbHeight +
metrics[0].topArrowHeight + metrics[0].bottomArrowHeight;
ChkErr(GetThemeMetric, kThemeMetricSmallScrollBarWidth, &metrics[1].width);
ChkErr(GetThemeMetric, kThemeMetricSmallScrollBarMinThumbHeight,
&metrics[1].minThumbHeight);
info.kind = kThemeScrollBarSmall;
ChkErr(HIThemeGetTrackDragRect, &info, &bounds);
metrics[1].topArrowHeight = bounds.origin.y;
metrics[1].bottomArrowHeight = height - (bounds.origin.y +
bounds.size.height);
metrics[1].minHeight = metrics[1].minThumbHeight +
metrics[1].topArrowHeight + metrics[1].bottomArrowHeight;
sprintf(tkDefScrollbarWidth, "%d", (int)(metrics[0].width));
}
/*
*----------------------------------------------------------------------
*
* TkpCreateScrollbar --
*
* Allocate a new TkScrollbar structure.
*
* Results:
* Returns a newly allocated TkScrollbar structure.
*
* Side effects:
* Registers an event handler for the widget.
*
*----------------------------------------------------------------------
*/
TkScrollbar *
TkpCreateScrollbar(
Tk_Window tkwin)
{
MacScrollbar *scrollPtr = (MacScrollbar *) ckalloc(sizeof(MacScrollbar));
scrollPtr->scroller = nil;
Tk_CreateEventHandler(tkwin, StructureNotifyMask|FocusChangeMask|
ActivateMask|ExposureMask, ScrollbarEventProc, (ClientData) scrollPtr);
return (TkScrollbar *) scrollPtr;
}
/*
*----------------------------------------------------------------------
*
* TkpDestroyScrollbar --
*
* Free data structures associated with the scrollbar control.
*
* Results:
* None.
*
* Side effects:
* None.
*
*----------------------------------------------------------------------
*/
void
TkpDestroyScrollbar(
TkScrollbar *scrollPtr)
{
MacScrollbar *macScrollPtr = (MacScrollbar *) scrollPtr;
NSScroller *scroller = macScrollPtr->scroller;
[scroller setTag:(NSInteger)0];
TkMacOSXMakeCollectableAndRelease(macScrollPtr->scroller);
}
/*
*--------------------------------------------------------------
*
* TkpDisplayScrollbar --
*
* This procedure redraws the contents of a scrollbar window. It is
* invoked as a do-when-idle handler, so it only runs when there's nothing
* else for the application to do.
*
* Results:
* None.
*
* Side effects:
* Information appears on the screen.
*
*--------------------------------------------------------------
*/
void
TkpDisplayScrollbar(
ClientData clientData) /* Information about window. */
{
TkScrollbar *scrollPtr = (TkScrollbar *) clientData;
MacScrollbar *macScrollPtr = (MacScrollbar *) clientData;
NSScroller *scroller = macScrollPtr->scroller;
Tk_Window tkwin = scrollPtr->tkwin;
TkWindow *winPtr = (TkWindow *) tkwin;
MacDrawable *macWin = (MacDrawable *) winPtr->window;
TkMacOSXDrawingContext dc;
NSView *view = TkMacOSXDrawableView(macWin);
CGFloat viewHeight = [view bounds].size.height;
CGAffineTransform t = { .a = 1, .b = 0, .c = 0, .d = -1, .tx = 0,
.ty = viewHeight};
NSRect frame;
double knobProportion = scrollPtr->lastFraction - scrollPtr->firstFraction;
scrollPtr->flags &= ~REDRAW_PENDING;
if (!scrollPtr->tkwin || !Tk_IsMapped(tkwin) || !view ||
!TkMacOSXSetupDrawingContext((Drawable) macWin, NULL, 1, &dc)) {
return;
}
CGContextConcatCTM(dc.context, t);
if (scrollPtr->highlightWidth != 0) {
GC fgGC, bgGC;
bgGC = Tk_GCForColor(scrollPtr->highlightBgColorPtr, (Pixmap) macWin);
if (scrollPtr->flags & GOT_FOCUS) {
fgGC = Tk_GCForColor(scrollPtr->highlightColorPtr, (Pixmap) macWin);
} else {
fgGC = bgGC;
}
TkpDrawHighlightBorder(tkwin, fgGC, bgGC, scrollPtr->highlightWidth,
(Pixmap) macWin);
}
Tk_Draw3DRectangle(tkwin, (Pixmap) macWin, scrollPtr->bgBorder,
scrollPtr->highlightWidth, scrollPtr->highlightWidth,
Tk_Width(tkwin) - 2*scrollPtr->highlightWidth,
Tk_Height(tkwin) - 2*scrollPtr->highlightWidth,
scrollPtr->borderWidth, scrollPtr->relief);
Tk_Fill3DRectangle(tkwin, (Pixmap) macWin, scrollPtr->bgBorder,
scrollPtr->inset, scrollPtr->inset,
Tk_Width(tkwin) - 2*scrollPtr->inset,
Tk_Height(tkwin) - 2*scrollPtr->inset, 0, TK_RELIEF_FLAT);
if ([scroller superview] != view) {
[view addSubview:scroller];
}
frame = NSMakeRect(macWin->xOff, macWin->yOff, Tk_Width(tkwin),
Tk_Height(tkwin));
frame = NSInsetRect(frame, scrollPtr->inset, scrollPtr->inset);
frame.origin.y = viewHeight - (frame.origin.y + frame.size.height);
NSWindow *w = [view window];
if ([w showsResizeIndicator]) {
NSRect growBox = [view convertRect:[w _growBoxRect] fromView:nil];
if (NSIntersectsRect(growBox, frame)) {
if (scrollPtr->vertical) {
CGFloat y = frame.origin.y;
frame.origin.y = growBox.origin.y + growBox.size.height;
frame.size.height -= frame.origin.y - y;
} else {
frame.size.width = growBox.origin.x - frame.origin.x;
}
TkMacOSXSetScrollbarGrow(winPtr, true);
}
}
if (!NSEqualRects(frame, [scroller frame])) {
[scroller setFrame:frame];
}
[scroller setEnabled:(knobProportion < 1.0 &&
(scrollPtr->vertical ? frame.size.height : frame.size.width) >
metrics[macScrollPtr->variant].minHeight)];
[scroller setDoubleValue:scrollPtr->firstFraction / (1.0 - knobProportion)];
[scroller setKnobProportion:knobProportion];
[scroller displayRectIgnoringOpacity:[scroller bounds]];
TkMacOSXRestoreDrawingContext(&dc);
#ifdef TK_MAC_DEBUG_SCROLLBAR
TKLog(@"scroller %s frame %@ width %d height %d",
((TkWindow *)scrollPtr->tkwin)->pathName, NSStringFromRect(frame),
Tk_Width(tkwin), Tk_Height(tkwin));
#endif
}
/*
*----------------------------------------------------------------------
*
* TkpComputeScrollbarGeometry --
*
* After changes in a scrollbar's size or configuration, this procedure
* recomputes various geometry information used in displaying the
* scrollbar.
*
* Results:
* None.
*
* Side effects:
* The scrollbar will be displayed differently.
*
*----------------------------------------------------------------------
*/
void
TkpComputeScrollbarGeometry(
register TkScrollbar *scrollPtr)
/* Scrollbar whose geometry may have
* changed. */
{
MacScrollbar *macScrollPtr = (MacScrollbar *) scrollPtr;
NSScroller *scroller = macScrollPtr->scroller;
int width, height, variant, fieldLength;
if (scrollPtr->highlightWidth < 0) {
scrollPtr->highlightWidth = 0;
}
scrollPtr->inset = scrollPtr->highlightWidth + scrollPtr->borderWidth;
width = Tk_Width(scrollPtr->tkwin) - 2 * scrollPtr->inset;
height = Tk_Height(scrollPtr->tkwin) - 2 * scrollPtr->inset;
variant = ((scrollPtr->vertical ? width : height) < metrics[0].width) ?
1 : 0;
macScrollPtr->variant = variant;
if (scroller) {
NSSize size = [scroller frame].size;
if ((size.width > size.height) ^ !scrollPtr->vertical) {
/*
* Orientation changed, need new scroller.
*/
if ([scroller superview]) {
[scroller removeFromSuperviewWithoutNeedingDisplay];
}
TkMacOSXMakeCollectableAndRelease(scroller);
}
}
if (!scroller) {
if ((width > height) ^ !scrollPtr->vertical) {
/* -[NSScroller initWithFrame:] determines horizonalness for the
* lifetime of the scroller via isHoriz = (width > height) */
if (scrollPtr->vertical) {
width = height;
} else if (width > 1) {
height = width - 1;
} else {
height = 1;
width = 2;
}
}
scroller = [[NSScroller alloc] initWithFrame:
NSMakeRect(0, 0, width, height)];
macScrollPtr->scroller = TkMacOSXMakeUncollectable(scroller);
[scroller setAction:@selector(tkScroller:)];
[scroller setTarget:NSApp];
[scroller setTag:(NSInteger)scrollPtr];
}
[[scroller cell] setControlSize:metrics[variant].controlSize];
scrollPtr->arrowLength = (metrics[variant].topArrowHeight +
metrics[variant].bottomArrowHeight) / 2;
fieldLength = (scrollPtr->vertical ? Tk_Height(scrollPtr->tkwin)
: Tk_Width(scrollPtr->tkwin))
- 2 * (scrollPtr->arrowLength + scrollPtr->inset);
if (fieldLength < 0) {
fieldLength = 0;
}
scrollPtr->sliderFirst = fieldLength * scrollPtr->firstFraction;
scrollPtr->sliderLast = fieldLength * scrollPtr->lastFraction;
/*
* Adjust the slider so that some piece of it is always displayed in the
* scrollbar and so that it has at least a minimal width (so it can be
* grabbed with the mouse).
*/
if (scrollPtr->sliderFirst > (fieldLength - 2*scrollPtr->borderWidth)) {
scrollPtr->sliderFirst = fieldLength - 2*scrollPtr->borderWidth;
}
if (scrollPtr->sliderFirst < 0) {
scrollPtr->sliderFirst = 0;
}
if (scrollPtr->sliderLast < (scrollPtr->sliderFirst +
metrics[variant].minThumbHeight)) {
scrollPtr->sliderLast = scrollPtr->sliderFirst +
metrics[variant].minThumbHeight;
}
if (scrollPtr->sliderLast > fieldLength) {
scrollPtr->sliderLast = fieldLength;
}
scrollPtr->sliderFirst += scrollPtr->inset +
metrics[variant].topArrowHeight;
scrollPtr->sliderLast += scrollPtr->inset +
metrics[variant].bottomArrowHeight;
/*
* Register the desired geometry for the window (leave enough space for
* the two arrows plus a minimum-size slider, plus border around the whole
* window, if any). Then arrange for the window to be redisplayed.
*/
if (scrollPtr->vertical) {
Tk_GeometryRequest(scrollPtr->tkwin, scrollPtr->width +
2 * scrollPtr->inset, 2 * (scrollPtr->arrowLength +
scrollPtr->borderWidth + scrollPtr->inset) +
metrics[variant].minThumbHeight);
} else {
Tk_GeometryRequest(scrollPtr->tkwin, 2 * (scrollPtr->arrowLength +
scrollPtr->borderWidth + scrollPtr->inset) +
metrics[variant].minThumbHeight, scrollPtr->width +
2 * scrollPtr->inset);
}
Tk_SetInternalBorder(scrollPtr->tkwin, scrollPtr->inset);
#ifdef TK_MAC_DEBUG_SCROLLBAR
TKLog(@"scroller %s bounds %@ width %d height %d inset %d borderWidth %d",
((TkWindow *)scrollPtr->tkwin)->pathName,
NSStringFromRect([scroller bounds]),
width, height, scrollPtr->inset, scrollPtr->borderWidth);
#endif
}
/*
*----------------------------------------------------------------------
*
* TkpConfigureScrollbar --
*
* This procedure is called after the generic code has finished
* processing configuration options, in order to configure platform
* specific options.
*
* Results:
* None.
*
* Side effects:
* None.
*
*----------------------------------------------------------------------
*/
void
TkpConfigureScrollbar(
register TkScrollbar *scrollPtr)
/* Information about widget; may or may not
* already have values for some fields. */
{
}
/*
*--------------------------------------------------------------
*
* TkpScrollbarPosition --
*
* Determine the scrollbar element corresponding to a given position.
*
* Results:
* One of TOP_ARROW, TOP_GAP, etc., indicating which element of the
* scrollbar covers the position given by (x, y). If (x,y) is outside the
* scrollbar entirely, then OUTSIDE is returned.
*
* Side effects:
* None.
*
*--------------------------------------------------------------
*/
int
TkpScrollbarPosition(
register TkScrollbar *scrollPtr,
/* Scrollbar widget record. */
int x, int y) /* Coordinates within scrollPtr's window. */
{
NSScroller *scroller = ((MacScrollbar *) scrollPtr)->scroller;
MacDrawable *macWin = (MacDrawable *)
((TkWindow *) scrollPtr->tkwin)->window;
NSView *view = TkMacOSXDrawableView(macWin);
switch ([scroller testPart:NSMakePoint(macWin->xOff + x,
[view bounds].size.height - (macWin->yOff + y))]) {
case NSScrollerDecrementLine:
return TOP_ARROW;
case NSScrollerDecrementPage:
return TOP_GAP;
case NSScrollerKnob:
return SLIDER;
case NSScrollerIncrementPage:
return BOTTOM_GAP;
case NSScrollerIncrementLine:
return BOTTOM_ARROW;
case NSScrollerKnobSlot:
case NSScrollerNoPart:
default:
return OUTSIDE;
}
}
/*
*--------------------------------------------------------------
*
* ScrollbarEventProc --
*
* This procedure is invoked by the Tk dispatcher for various events on
* scrollbars.
*
* Results:
* None.
*
* Side effects:
* When the window gets deleted, internal structures get cleaned up. When
* it gets exposed, it is redisplayed.
*
*--------------------------------------------------------------
*/
static void
ScrollbarEventProc(
ClientData clientData, /* Information about window. */
XEvent *eventPtr) /* Information about event. */
{
TkScrollbar *scrollPtr = (TkScrollbar *) clientData;
switch (eventPtr->type) {
case UnmapNotify:
TkMacOSXSetScrollbarGrow((TkWindow *) scrollPtr->tkwin, false);
break;
case ActivateNotify:
case DeactivateNotify:
TkScrollbarEventuallyRedraw((ClientData) scrollPtr);
break;
default:
TkScrollbarEventProc(clientData, eventPtr);
}
}
/*
* Local Variables:
* mode: objc
* c-basic-offset: 4
* fill-column: 79
* coding: utf-8
* End:
*/

515
macosx/tkMacOSXSend.c Normal file
View File

@@ -0,0 +1,515 @@
/*
* tkMacOSXSend.c --
*
* This file provides procedures that implement the "send" command,
* allowing commands to be passed from interpreter to interpreter. This
* current implementation for the Mac has most functionality stubed out.
*
* The current plan, which we have not had time to implement, is for the
* first Wish app to create a gestalt of type 'WIsH'. This gestalt will
* point to a table, in system memory, of Tk apps. Each Tk app, when it
* starts up, will register their name, and process ID, in this table.
* This will allow us to implement "tk appname".
*
* Then the send command will look up the process id of the target app in
* this table, and send an AppleEvent to that process. The AppleEvent
* handler is much like the do script handler, except that you have to
* specify the name of the tk app as well, since there may be many
* interps in one wish app, and you need to send it to the right one.
*
* Implementing this has been on our list of things to do, but what with
* the demise of Tcl at Sun, and the lack of resources at Scriptics it
* may not get done for awhile. So this sketch is offered for the brave
* to attempt if they need the functionality...
*
* Copyright (c) 1989-1994 The Regents of the University of California.
* Copyright (c) 1994-1998 Sun Microsystems, Inc.
* Copyright 2001-2009, Apple Inc.
* Copyright (c) 2005-2009 Daniel A. Steffen <das@users.sourceforge.net>
*
* See the file "license.terms" for information on usage and redistribution
* of this file, and for a DISCLAIMER OF ALL WARRANTIES.
*/
#include "tkMacOSXInt.h"
/*
* The following structure is used to keep track of the interpreters
* registered by this process.
*/
typedef struct RegisteredInterp {
char *name; /* Interpreter's name (malloc-ed). */
Tcl_Interp *interp; /* Interpreter associated with name. */
struct RegisteredInterp *nextPtr;
/* Next in list of names associated with
* interps in this process. NULL means end of
* list. */
} RegisteredInterp;
/*
* A registry of all interpreters for a display is kept in a property
* "InterpRegistry" on the root window of the display. It is organized as a
* series of zero or more concatenated strings (in no particular order), each
* of the form
* window space name '\0'
* where "window" is the hex id of the comm. window to use to talk to an
* interpreter named "name".
*
* When the registry is being manipulated by an application (e.g. to add or
* remove an entry), it is loaded into memory using a structure of the
* following type:
*/
typedef struct NameRegistry {
TkDisplay *dispPtr; /* Display from which the registry was
* read. */
int locked; /* Non-zero means that the display was locked
* when the property was read in. */
int modified; /* Non-zero means that the property has been
* modified, so it needs to be written out
* when the NameRegistry is closed. */
unsigned long propLength; /* Length of the property, in bytes. */
char *property; /* The contents of the property, or NULL if
* none. See format description above; this is
* *not* terminated by the first null
* character. Dynamically allocated. */
int allocedByX; /* Non-zero means must free property with
* XFree; zero means use ckfree. */
} NameRegistry;
static int initialized = 0; /* A flag to denote if we have initialized
* yet. */
static RegisteredInterp *interpListPtr = NULL;
/* List of all interpreters registered by this
* process. */
/*
* The information below is used for communication between processes during
* "send" commands. Each process keeps a private window, never even mapped,
* with one property, "Comm". When a command is sent to an interpreter, the
* command is appended to the comm property of the communication window
* associated with the interp's process. Similarly, when a result is returned
* from a sent command, it is also appended to the comm property.
*
* Each command and each result takes the form of ASCII text. For a command,
* the text consists of a zero character followed by several null-terminated
* ASCII strings. The first string consists of the single letter "c".
* Subsequent strings have the form "option value" where the following options
* are supported:
*
* -r commWindow serial
*
* This option means that a response should be sent to the window whose X
* identifier is "commWindow" (in hex), and the response should be
* identified with the serial number given by "serial" (in decimal). If
* this option isn't specified then the send is asynchronous and no
* response is sent.
*
* -n name
*
* "Name" gives the name of the application for which the command is
* intended. This option must be present.
*
* -s script
*
* "Script" is the script to be executed. This option must be present.
*
* The options may appear in any order. The -n and -s options must be present,
* but -r may be omitted for asynchronous RPCs. For compatibility with future
* releases that may add new features, there may be additional options
* present; as long as they start with a "-" character, they will be ignored.
*
*
* A result also consists of a zero character followed by several null-
* terminated ASCII strings. The first string consists of the single letter
* "r". Subsequent strings have the form "option value" where the following
* options are supported:
*
* -s serial
*
* Identifies the command for which this is the result. It is the same as
* the "serial" field from the -s option in the command. This option must
* be present.
*
* -c code
*
* "Code" is the completion code for the script, in decimal. If the code
* is omitted it defaults to TCL_OK.
*
* -r result
*
* "Result" is the result string for the script, which may be either a
* result or an error message. If this field is omitted then it defaults
* to an empty string.
*
* -i errorInfo
*
* "ErrorInfo" gives a string with which to initialize the errorInfo
* variable. This option may be omitted; it is ignored unless the
* completion code is TCL_ERROR.
*
* -e errorCode
*
* "ErrorCode" gives a string with with to initialize the errorCode
* variable. This option may be omitted; it is ignored unless the
* completion code is TCL_ERROR.
*
* Options may appear in any order, and only the -s option must be present. As
* with commands, there may be additional options besides these; unknown
* options are ignored.
*/
/*
* Maximum size property that can be read at one time by this module:
*/
#define MAX_PROP_WORDS 100000
/*
* Forward declarations for procedures defined later in this file:
*/
static int SendInit(Tcl_Interp *interp);
/*
*--------------------------------------------------------------
*
* Tk_SetAppName --
*
* This procedure is called to associate an ASCII name with a Tk
* application. If the application has already been named, the name
* replaces the old one.
*
* Results:
* The return value is the name actually given to the application. This
* will normally be the same as name, but if name was already in use for
* an application then a name of the form "name #2" will be chosen, with
* a high enough number to make the name unique.
*
* Side effects:
* Registration info is saved, thereby allowing the "send" command to be
* used later to invoke commands in the application. In addition, the
* "send" command is created in the application's interpreter. The
* registration will be removed automatically if the interpreter is
* deleted or the "send" command is removed.
*
*--------------------------------------------------------------
*/
const char *
Tk_SetAppName(
Tk_Window tkwin, /* Token for any window in the application to
* be named: it is just used to identify the
* application and the display. */
const char *name) /* The name that will be used to refer to the
* interpreter in later "send" commands. Must
* be globally unique. */
{
TkWindow *winPtr = (TkWindow *) tkwin;
Tcl_Interp *interp = winPtr->mainPtr->interp;
int i, suffix, offset, result;
RegisteredInterp *riPtr, *prevPtr;
const char *actualName;
Tcl_DString dString;
Tcl_Obj *resultObjPtr, *interpNamePtr;
char *interpName;
if (!initialized) {
SendInit(interp);
}
/*
* See if the application is already registered; if so, remove its current
* name from the registry. The deletion of the command will take care of
* disposing of this entry.
*/
for (riPtr = interpListPtr, prevPtr = NULL; riPtr != NULL;
prevPtr = riPtr, riPtr = riPtr->nextPtr) {
if (riPtr->interp == interp) {
if (prevPtr == NULL) {
interpListPtr = interpListPtr->nextPtr;
} else {
prevPtr->nextPtr = riPtr->nextPtr;
}
break;
}
}
/*
* Pick a name to use for the application. Use "name" if it's not already
* in use. Otherwise add a suffix such as " #2", trying larger and larger
* numbers until we eventually find one that is unique.
*/
actualName = name;
suffix = 1;
offset = 0;
Tcl_DStringInit(&dString);
TkGetInterpNames(interp, tkwin);
resultObjPtr = Tcl_GetObjResult(interp);
Tcl_IncrRefCount(resultObjPtr);
for (i = 0; ; ) {
result = Tcl_ListObjIndex(NULL, resultObjPtr, i, &interpNamePtr);
if (result != TCL_OK || interpNamePtr == NULL) {
break;
}
interpName = Tcl_GetString(interpNamePtr);
if (strcmp(actualName, interpName) == 0) {
if (suffix == 1) {
Tcl_DStringAppend(&dString, name, -1);
Tcl_DStringAppend(&dString, " #", 2);
offset = Tcl_DStringLength(&dString);
Tcl_DStringSetLength(&dString, offset + 10);
actualName = Tcl_DStringValue(&dString);
}
suffix++;
sprintf(Tcl_DStringValue(&dString) + offset, "%d", suffix);
i = 0;
} else {
i++;
}
}
Tcl_DecrRefCount(resultObjPtr);
Tcl_ResetResult(interp);
/*
* We have found a unique name. Now add it to the registry.
*/
riPtr = (RegisteredInterp *) ckalloc(sizeof(RegisteredInterp));
riPtr->interp = interp;
riPtr->name = ckalloc(strlen(actualName) + 1);
riPtr->nextPtr = interpListPtr;
interpListPtr = riPtr;
strcpy(riPtr->name, actualName);
/*
* TODO: DeleteProc
*/
Tcl_CreateObjCommand(interp, "send", Tk_SendObjCmd, riPtr, NULL);
if (Tcl_IsSafe(interp)) {
Tcl_HideCommand(interp, "send", "send");
}
Tcl_DStringFree(&dString);
return riPtr->name;
}
/*
*--------------------------------------------------------------
*
* Tk_SendObjCmd --
*
* This procedure is invoked to process the "send" Tcl command. See the
* user documentation for details on what it does.
*
* Results:
* A standard Tcl result.
*
* Side effects:
* See the user documentation.
*
*--------------------------------------------------------------
*/
int
Tk_SendObjCmd(
ClientData clientData, /* Used only for deletion */
Tcl_Interp *interp, /* The interp we are sending from */
int objc, /* Number of arguments */
Tcl_Obj *const objv[]) /* The arguments */
{
const char *sendOptions[] = {"-async", "-displayof", "-", NULL};
char *stringRep, *destName;
/*int async = 0;*/
int i, index, firstArg;
RegisteredInterp *riPtr;
Tcl_Obj *listObjPtr;
int result = TCL_OK;
for (i = 1; i < (objc - 1); ) {
stringRep = Tcl_GetString(objv[i]);
if (stringRep[0] == '-') {
if (Tcl_GetIndexFromObj(interp, objv[i], sendOptions, "option", 0,
&index) != TCL_OK) {
return TCL_ERROR;
}
if (index == 0) {
/*async = 1;*/
i++;
} else if (index == 1) {
i += 2;
} else {
i++;
}
} else {
break;
}
}
if (objc < (i + 2)) {
Tcl_WrongNumArgs(interp, 1, objv,
"?-option value ...? interpName arg ?arg ...?");
return TCL_ERROR;
}
destName = Tcl_GetString(objv[i]);
firstArg = i + 1;
/*
* See if the target interpreter is local. If so, execute the command
* directly without going through the DDE server. The only tricky thing is
* passing the result from the target interpreter to the invoking
* interpreter. Watch out: they could be the same!
*/
for (riPtr = interpListPtr; (riPtr != NULL)
&& (strcmp(destName, riPtr->name)); riPtr = riPtr->nextPtr) {
/*
* Empty loop body.
*/
}
if (riPtr != NULL) {
/*
* This command is to a local interp. No need to go through the
* server.
*/
Tcl_Interp *localInterp;
Tcl_Preserve(riPtr);
localInterp = riPtr->interp;
Tcl_Preserve(localInterp);
if (firstArg == (objc - 1)) {
/*
* This might be one of those cases where the new parser is
* faster.
*/
result = Tcl_EvalObjEx(localInterp, objv[firstArg],
TCL_EVAL_DIRECT);
} else {
listObjPtr = Tcl_NewListObj(0, NULL);
for (i = firstArg; i < objc; i++) {
Tcl_ListObjAppendList(interp, listObjPtr, objv[i]);
}
Tcl_IncrRefCount(listObjPtr);
result = Tcl_EvalObjEx(localInterp, listObjPtr, TCL_EVAL_DIRECT);
Tcl_DecrRefCount(listObjPtr);
}
if (interp != localInterp) {
if (result == TCL_ERROR) {
/* Tcl_Obj *errorObjPtr; */
/*
* An error occurred, so transfer error information from the
* destination interpreter back to our interpreter. Must clear
* interp's result before calling Tcl_AddErrorInfo, since
* Tcl_AddErrorInfo will store the interp's result in
* errorInfo before appending riPtr's $errorInfo; we've
* already got everything we need in riPtr's $errorInfo.
*/
Tcl_ResetResult(interp);
Tcl_AddErrorInfo(interp, Tcl_GetVar2(localInterp,
"errorInfo", NULL, TCL_GLOBAL_ONLY));
/* errorObjPtr = Tcl_GetObjVar2(localInterp, "errorCode", NULL,
TCL_GLOBAL_ONLY);
Tcl_SetObjErrorCode(interp, errorObjPtr); */
}
Tcl_SetObjResult(interp, Tcl_GetObjResult(localInterp));
}
Tcl_Release(riPtr);
Tcl_Release(localInterp);
} else {
/*
* TODO: This is a non-local request. Send the script to the server
* and poll it for a result.
*/
}
return result;
}
/*
*----------------------------------------------------------------------
*
* TkGetInterpNames --
*
* This procedure is invoked to fetch a list of all the interpreter names
* currently registered for the display of a particular window.
*
* Results:
* A standard Tcl return value. Interp->result will be set to hold a list
* of all the interpreter names defined for tkwin's display. If an error
* occurs, then TCL_ERROR is returned and interp->result will hold an
* error message.
*
* Side effects:
* None.
*
*----------------------------------------------------------------------
*/
int
TkGetInterpNames(
Tcl_Interp *interp, /* Interpreter for returning a result. */
Tk_Window tkwin) /* Window whose display is to be used for the
* lookup. */
{
Tcl_Obj *listObjPtr;
RegisteredInterp *riPtr;
listObjPtr = Tcl_NewListObj(0, NULL);
riPtr = interpListPtr;
while (riPtr != NULL) {
Tcl_ListObjAppendElement(interp, listObjPtr,
Tcl_NewStringObj(riPtr->name, -1));
riPtr = riPtr->nextPtr;
}
Tcl_SetObjResult(interp, listObjPtr);
return TCL_OK;
}
/*
*--------------------------------------------------------------
*
* SendInit --
*
* This procedure is called to initialize the communication channels for
* sending commands and receiving results.
*
* Results:
* None.
*
* Side effects:
* Sets up various data structures and windows.
*
*--------------------------------------------------------------
*/
static int
SendInit(
Tcl_Interp *interp) /* Interpreter to use for error reporting (no
* errors are ever returned, but the
* interpreter is needed anyway). */
{
return TCL_OK;
}
/*
* Local Variables:
* mode: objc
* c-basic-offset: 4
* fill-column: 79
* coding: utf-8
* End:
*/

1357
macosx/tkMacOSXSubwindows.c Normal file

File diff suppressed because it is too large Load Diff

90
macosx/tkMacOSXTest.c Normal file
View File

@@ -0,0 +1,90 @@
/*
* tkMacOSXTest.c --
*
* Contains commands for platform specific tests for
* the Macintosh platform.
*
* Copyright (c) 1996 Sun Microsystems, Inc.
* Copyright 2001-2009, Apple Inc.
* Copyright (c) 2005-2009 Daniel A. Steffen <das@users.sourceforge.net>
*
* See the file "license.terms" for information on usage and redistribution
* of this file, and for a DISCLAIMER OF ALL WARRANTIES.
*/
#include "tkMacOSXPrivate.h"
/*
* Forward declarations of procedures defined later in this file:
*/
static int DebuggerCmd (ClientData dummy, Tcl_Interp *interp,
int argc, const char **argv);
MODULE_SCOPE int TkplatformtestInit(Tcl_Interp *interp);
/*
*----------------------------------------------------------------------
*
* TkplatformtestInit --
*
* Defines commands that test platform specific functionality for
* Unix platforms.
*
* Results:
* A standard Tcl result.
*
* Side effects:
* Defines new commands.
*
*----------------------------------------------------------------------
*/
int
TkplatformtestInit(
Tcl_Interp *interp) /* Interpreter to add commands to. */
{
/*
* Add commands for platform specific tests on MacOS here.
*/
Tcl_CreateCommand(interp, "debugger", DebuggerCmd,
(ClientData) 0, (Tcl_CmdDeleteProc *) NULL);
return TCL_OK;
}
/*
*----------------------------------------------------------------------
*
* DebuggerCmd --
*
* This procedure simply calls the low level debugger.
*
* Results:
* A standard Tcl result.
*
* Side effects:
* None.
*
*----------------------------------------------------------------------
*/
static int
DebuggerCmd(
ClientData clientData, /* Not used. */
Tcl_Interp *interp, /* Not used. */
int argc, /* Not used. */
const char **argv) /* Not used. */
{
Debugger();
return TCL_OK;
}
/*
* Local Variables:
* mode: objc
* c-basic-offset: 4
* fill-column: 79
* coding: utf-8
* End:
*/

1105
macosx/tkMacOSXWindowEvent.c Normal file

File diff suppressed because it is too large Load Diff

6594
macosx/tkMacOSXWm.c Normal file

File diff suppressed because it is too large Load Diff

262
macosx/tkMacOSXWm.h Normal file
View File

@@ -0,0 +1,262 @@
/*
* tkMacOSXWm.h --
*
* Declarations of Macintosh specific window manager structures.
*
* Copyright 2001-2009, Apple Inc.
* Copyright (c) 2006-2009 Daniel A. Steffen <das@users.sourceforge.net>
*
* See the file "license.terms" for information on usage and redistribution
* of this file, and for a DISCLAIMER OF ALL WARRANTIES.
*/
#ifndef _TKMACWM
#define _TKMACWM
#include "tkMacOSXInt.h"
#include "tkMenu.h"
/*
* A data structure of the following type holds information for
* each window manager protocol (such as WM_DELETE_WINDOW) for
* which a handler (i.e. a Tcl command) has been defined for a
* particular top-level window.
*/
typedef struct ProtocolHandler {
Atom protocol; /* Identifies the protocol. */
struct ProtocolHandler *nextPtr;
/* Next in list of protocol handlers for
* the same top-level window, or NULL for
* end of list. */
Tcl_Interp *interp; /* Interpreter in which to invoke command. */
char command[4]; /* Tcl command to invoke when a client
* message for this protocol arrives.
* The actual size of the structure varies
* to accommodate the needs of the actual
* command. THIS MUST BE THE LAST FIELD OF
* THE STRUCTURE. */
} ProtocolHandler;
#define HANDLER_SIZE(cmdLength) \
((unsigned) (sizeof(ProtocolHandler) - 3 + cmdLength))
/*
* A data structure of the following type holds window-manager-related
* information for each top-level window in an application.
*/
typedef struct TkWmInfo {
TkWindow *winPtr; /* Pointer to main Tk information for
* this window. */
Window reparent; /* If the window has been reparented, this
* gives the ID of the ancestor of the window
* that is a child of the root window (may
* not be window's immediate parent). If
* the window isn't reparented, this has the
* value None. */
Tk_Uid titleUid; /* Title to display in window caption. If
* NULL, use name of widget. */
char *iconName; /* Name to display in icon. */
Window master; /* Master window for TRANSIENT_FOR property,
* or None. */
XWMHints hints; /* Various pieces of information for
* window manager. */
char *leaderName; /* Path name of leader of window group
* (corresponds to hints.window_group).
* Malloc-ed. Note: this field doesn't
* get updated if leader is destroyed. */
char *masterWindowName; /* Path name of window specified as master
* in "wm transient" command, or NULL.
* Malloc-ed. Note: this field doesn't
* get updated if masterWindowName is
* destroyed. */
Tk_Window icon; /* Window to use as icon for this window,
* or NULL. */
Tk_Window iconFor; /* Window for which this window is icon, or
* NULL if this isn't an icon for anyone. */
/*
* Information used to construct an XSizeHints structure for
* the window manager:
*/
int sizeHintsFlags; /* Flags word for XSizeHints structure.
* If the PBaseSize flag is set then the
* window is gridded; otherwise it isn't
* gridded. */
int minWidth, minHeight; /* Minimum dimensions of window, in
* grid units, not pixels. */
int maxWidth, maxHeight; /* Maximum dimensions of window, in
* grid units, not pixels. */
Tk_Window gridWin; /* Identifies the window that controls
* gridding for this top-level, or NULL if
* the top-level isn't currently gridded. */
int widthInc, heightInc; /* Increments for size changes (# pixels
* per step). */
struct {
int x; /* numerator */
int y; /* denominator */
} minAspect, maxAspect; /* Min/max aspect ratios for window. */
int reqGridWidth, reqGridHeight;
/* The dimensions of the window (in
* grid units) requested through
* the geometry manager. */
int gravity; /* Desired window gravity. */
/*
* Information used to manage the size and location of a window.
*/
int width, height; /* Desired dimensions of window, specified
* in grid units. These values are
* set by the "wm geometry" command and by
* ConfigureNotify events (for when wm
* resizes window). -1 means user hasn't
* requested dimensions. */
int x, y; /* Desired X and Y coordinates for window.
* These values are set by "wm geometry",
* plus by ConfigureNotify events (when wm
* moves window). These numbers are
* different than the numbers stored in
* winPtr->changes because (a) they could be
* measured from the right or bottom edge
* of the screen (see WM_NEGATIVE_X and
* WM_NEGATIVE_Y flags) and (b) if the window
* has been reparented then they refer to the
* parent rather than the window itself. */
int parentWidth, parentHeight;
/* Width and height of reparent, in pixels
* *including border*. If window hasn't been
* reparented then these will be the outer
* dimensions of the window, including
* border. */
int xInParent, yInParent; /* Offset of window within reparent, measured
* from upper-left outer corner of parent's
* border to upper-left outer corner of child's
* border. If not reparented then these are
* zero. */
int configX, configY; /* x,y position of toplevel when window is
* switched into fullscreen state, */
int configWidth, configHeight;
/* Dimensions passed to last request that we
* issued to change geometry of window. Used
* to eliminate redundant resize operations. */
/*
* Information about the virtual root window for this top-level,
* if there is one.
*/
Window vRoot; /* Virtual root window for this top-level,
* or None if there is no virtual root
* window (i.e. just use the screen's root). */
int vRootX, vRootY; /* Position of the virtual root inside the
* root window. If the WM_VROOT_OFFSET_STALE
* flag is set then this information may be
* incorrect and needs to be refreshed from
* the X server. If vRoot is None then these
* values are both 0. */
unsigned int vRootWidth, vRootHeight;
/* Dimensions of the virtual root window.
* If vRoot is None, gives the dimensions
* of the containing screen. This information
* is never stale, even though vRootX and
* vRootY can be. */
/*
* List of children of the toplevel which have private colormaps.
*/
TkWindow **cmapList; /* Array of window with private colormaps. */
int cmapCount; /* Number of windows in array. */
/*
* Miscellaneous information.
*/
ProtocolHandler *protPtr; /* First in list of protocol handlers for
* this window (NULL means none). */
int cmdArgc; /* Number of elements in cmdArgv below. */
const char **cmdArgv; /* Array of strings to store in the
* WM_COMMAND property. NULL means nothing
* available. */
char *clientMachine; /* String to store in WM_CLIENT_MACHINE
* property, or NULL. */
int flags; /* Miscellaneous flags, defined below. */
/*
* Macintosh information.
*/
WindowClass macClass;
UInt64 attributes, configAttributes;
TkWindow *scrollWinPtr; /* Ptr to scrollbar handling grow widget. */
TkMenu *menuPtr;
NSWindow *window;
} WmInfo;
/*
* Flag values for WmInfo structures:
*
* WM_NEVER_MAPPED - non-zero means window has never been
* mapped; need to update all info when
* window is first mapped.
* WM_UPDATE_PENDING - non-zero means a call to UpdateGeometryInfo
* has already been scheduled for this
* window; no need to schedule another one.
* WM_NEGATIVE_X - non-zero means x-coordinate is measured in
* pixels from right edge of screen, rather
* than from left edge.
* WM_NEGATIVE_Y - non-zero means y-coordinate is measured in
* pixels up from bottom of screen, rather than
* down from top.
* WM_UPDATE_SIZE_HINTS - non-zero means that new size hints need to be
* propagated to window manager.
* WM_SYNC_PENDING - set to non-zero while waiting for the window
* manager to respond to some state change.
* WM_VROOT_OFFSET_STALE - non-zero means that (x,y) offset information
* about the virtual root window is stale and
* needs to be fetched fresh from the X server.
* WM_ABOUT_TO_MAP - non-zero means that the window is about to
* be mapped by TkWmMapWindow. This is used
* by UpdateGeometryInfo to modify its behavior.
* WM_MOVE_PENDING - non-zero means the application has requested
* a new position for the window, but it hasn't
* been reflected through the window manager
* yet.
* WM_COLORMAPS_EXPLICIT - non-zero means the colormap windows were
* set explicitly via "wm colormapwindows".
* WM_ADDED_TOPLEVEL_COLORMAP - non-zero means that when "wm colormapwindows"
* was called the top-level itself wasn't
* specified, so we added it implicitly at
* the end of the list.
* WM_WIDTH_NOT_RESIZABLE - non-zero means that we're not supposed to
* allow the user to change the width of the
* window (controlled by "wm resizable"
* command).
* WM_HEIGHT_NOT_RESIZABLE - non-zero means that we're not supposed to
* allow the user to change the height of the
* window (controlled by "wm resizable"
* command).
*/
#define WM_NEVER_MAPPED 0x0001
#define WM_UPDATE_PENDING 0x0002
#define WM_NEGATIVE_X 0x0004
#define WM_NEGATIVE_Y 0x0008
#define WM_UPDATE_SIZE_HINTS 0x0010
#define WM_SYNC_PENDING 0x0020
#define WM_VROOT_OFFSET_STALE 0x0040
#define WM_ABOUT_TO_MAP 0x0080
#define WM_MOVE_PENDING 0x0100
#define WM_COLORMAPS_EXPLICIT 0x0200
#define WM_ADDED_TOPLEVEL_COLORMAP 0x0400
#define WM_WIDTH_NOT_RESIZABLE 0x0800
#define WM_HEIGHT_NOT_RESIZABLE 0x1000
#define WM_TOPMOST 0x2000
#define WM_FULLSCREEN 0x4000
#define WM_TRANSPARENT 0x8000
#endif

711
macosx/tkMacOSXXCursors.h Normal file
View File

@@ -0,0 +1,711 @@
/*
* tkMacOSXXCursors.h --
*
* This file defines a set of Macintosh cursors that
* emulate the X cursor set. All of these cursors were
* constructed and donated by Grant Neufeld. (gneufeld@ccs.carleton.ca)
*
* Copyright (c) 1995-1996 Sun Microsystems, Inc.
* Copyright 2008-2009, Apple Inc.
* Copyright (c) 2008-2009 Daniel A. Steffen <das@users.sourceforge.net>
*
* See the file "license.terms" for information on usage and redistribution
* of this file, and for a DISCLAIMER OF ALL WARRANTIES.
*/
static const unsigned char tkMacOSXXCursors[][68] = {
#define TK_MAC_XCURSOR_X_cursor 0
[TK_MAC_XCURSOR_X_cursor] = {
0xE0, 0x07, 0xF0, 0x0F, 0xF8, 0x1F, 0x7C, 0x3E, 0x3E, 0x7C, 0x1F, 0xF8, 0x0F, 0xF0, 0x07, 0xE0,
0x07, 0xE0, 0x0F, 0xF0, 0x1F, 0xF8, 0x3E, 0x7C, 0x7C, 0x3E, 0xF8, 0x1F, 0xF0, 0x0F, 0xE0, 0x07,
0xE0, 0x07, 0xF0, 0x0F, 0xF8, 0x1F, 0x7C, 0x3E, 0x3E, 0x7C, 0x1F, 0xF8, 0x0F, 0xF0, 0x07, 0xE0,
0x07, 0xE0, 0x0F, 0xF0, 0x1F, 0xF8, 0x3E, 0x7C, 0x7C, 0x3E, 0xF8, 0x1F, 0xF0, 0x0F, 0xE0, 0x07,
0x00, 0x07, 0x00, 0x07,
},
#define TK_MAC_XCURSOR_arrow 1
[TK_MAC_XCURSOR_arrow] = {
0x00, 0x00, 0x00, 0x06, 0x00, 0x1E, 0x00, 0x7C, 0x01, 0xFC, 0x07, 0xF8, 0x00, 0xF8, 0x01, 0xF0,
0x03, 0xB0, 0x07, 0x20, 0x0E, 0x20, 0x1C, 0x00, 0x38, 0x00, 0x70, 0x00, 0x20, 0x00, 0x00, 0x00,
0x00, 0x07, 0x00, 0x1F, 0x00, 0x7F, 0x01, 0xFE, 0x07, 0xFE, 0x1F, 0xFC, 0x7F, 0xFC, 0x03, 0xF8,
0x07, 0xF8, 0x0F, 0xF0, 0x1F, 0x70, 0x3E, 0x60, 0x7C, 0x60, 0xF8, 0x40, 0x70, 0x40, 0x20, 0x00,
0x00, 0x01, 0x00, 0x0E,
},
#define TK_MAC_XCURSOR_based_arrow_down 2
[TK_MAC_XCURSOR_based_arrow_down] = {
0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x1F, 0xE0, 0x00, 0x00, 0x1F, 0xE0, 0x03, 0x00, 0x03, 0x00,
0x03, 0x00, 0x0B, 0x40, 0x07, 0x80, 0x03, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00,
0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x1F, 0xE0, 0x00, 0x00, 0x1F, 0xE0, 0x07, 0x80, 0x07, 0x80,
0x3F, 0xF0, 0x1F, 0xE0, 0x0F, 0xC0, 0x07, 0x80, 0x03, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00,
0x00, 0x0B, 0x00, 0x06,
},
#define TK_MAC_XCURSOR_based_arrow_up 3
[TK_MAC_XCURSOR_based_arrow_up] = {
0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x03, 0x00, 0x07, 0x80, 0x0B, 0x40, 0x03, 0x00,
0x03, 0x00, 0x03, 0x00, 0x1F, 0xE0, 0x00, 0x00, 0x1F, 0xE0, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00,
0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x03, 0x00, 0x07, 0x80, 0x0F, 0xC0, 0x1F, 0xE0, 0x3F, 0xF0,
0x07, 0x80, 0x07, 0x80, 0x1F, 0xE0, 0x00, 0x00, 0x1F, 0xE0, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00,
0x00, 0x04, 0x00, 0x06,
},
#define TK_MAC_XCURSOR_boat 4
[TK_MAC_XCURSOR_boat] = {
0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x01, 0x00, 0x03, 0xC0, 0x84, 0x60, 0xFF, 0xFF,
0x00, 0x18, 0x00, 0x20, 0x00, 0x40, 0xFF, 0xC0, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00,
0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x01, 0x00, 0x03, 0xC0, 0x87, 0xE0, 0xFF, 0xFF,
0xFF, 0xF8, 0xFF, 0xE0, 0xFF, 0xC0, 0xFF, 0xC0, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00,
0x00, 0x07, 0x00, 0x0F,
},
#define TK_MAC_XCURSOR_bogosity 5
[TK_MAC_XCURSOR_bogosity] = {
0x00, 0x00, 0x71, 0x1C, 0x11, 0x10, 0x11, 0x10, 0x11, 0x10, 0x7F, 0xFC, 0x51, 0x14, 0x51, 0x14,
0x51, 0x14, 0x51, 0x14, 0x7F, 0xFC, 0x11, 0x10, 0x11, 0x10, 0x11, 0x10, 0x71, 0x1C, 0x00, 0x00,
0x00, 0x00, 0x71, 0x1C, 0x11, 0x10, 0x11, 0x10, 0x11, 0x10, 0x7F, 0xFC, 0x7F, 0xFC, 0x7F, 0xFC,
0x7F, 0xFC, 0x7F, 0xFC, 0x7F, 0xFC, 0x11, 0x10, 0x11, 0x10, 0x11, 0x10, 0x71, 0x1C, 0x00, 0x00,
0x00, 0x01, 0x00, 0x07,
},
#define TK_MAC_XCURSOR_bottom_left_corner 6
[TK_MAC_XCURSOR_bottom_left_corner] = {
0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0xC0, 0x00, 0xC0, 0x20, 0xC8, 0x40, 0xC8, 0x80,
0xC9, 0x00, 0xCA, 0x00, 0xCC, 0x00, 0xCF, 0xC0, 0xC0, 0x00, 0xC0, 0x00, 0xFF, 0xF0, 0xFF, 0xF0,
0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0xC0, 0x00, 0xC0, 0x20, 0xC8, 0x40, 0xC8, 0x80,
0xC9, 0x00, 0xCA, 0x00, 0xCC, 0x00, 0xCF, 0xC0, 0xC0, 0x00, 0xC0, 0x00, 0xFF, 0xF0, 0xFF, 0xF0,
0x00, 0x0F, 0x00, 0x00,
},
#define TK_MAC_XCURSOR_bottom_right_corner 7
[TK_MAC_XCURSOR_bottom_right_corner] = {
0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x03, 0x04, 0x03, 0x02, 0x13, 0x01, 0x13,
0x00, 0x93, 0x00, 0x53, 0x00, 0x33, 0x03, 0xF3, 0x00, 0x03, 0x00, 0x03, 0x0F, 0xFF, 0x0F, 0xFF,
0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x03, 0x04, 0x03, 0x02, 0x13, 0x01, 0x13,
0x00, 0x93, 0x00, 0x53, 0x00, 0x33, 0x03, 0xF3, 0x00, 0x03, 0x00, 0x03, 0x0F, 0xFF, 0x0F, 0xFF,
0x00, 0x0F, 0x00, 0x0F,
},
#define TK_MAC_XCURSOR_bottom_side 8
[TK_MAC_XCURSOR_bottom_side] = {
0x00, 0x00, 0x00, 0x00, 0x01, 0x00, 0x01, 0x00, 0x01, 0x00, 0x01, 0x00, 0x01, 0x00, 0x11, 0x10,
0x09, 0x20, 0x05, 0x40, 0x03, 0x80, 0x01, 0x00, 0x00, 0x00, 0x7F, 0xFC, 0x7F, 0xFC, 0x00, 0x00,
0x00, 0x00, 0x00, 0x00, 0x01, 0x00, 0x01, 0x00, 0x01, 0x00, 0x01, 0x00, 0x01, 0x00, 0x11, 0x10,
0x09, 0x20, 0x05, 0x40, 0x03, 0x80, 0x01, 0x00, 0x00, 0x00, 0x7F, 0xFC, 0x7F, 0xFC, 0x00, 0x00,
0x00, 0x0B, 0x00, 0x07,
},
#define TK_MAC_XCURSOR_bottom_tee 9
[TK_MAC_XCURSOR_bottom_tee] = {
0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x01, 0x80, 0x01, 0x80, 0x01, 0x80, 0x01, 0x80, 0x01, 0x80,
0x01, 0x80, 0x01, 0x80, 0x7F, 0xFE, 0x7F, 0xFE, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00,
0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x01, 0x80, 0x01, 0x80, 0x01, 0x80, 0x01, 0x80, 0x01, 0x80,
0x01, 0x80, 0x01, 0x80, 0x7F, 0xFE, 0x7F, 0xFE, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00,
0x00, 0x0B, 0x00, 0x07,
},
#define TK_MAC_XCURSOR_box_spiral 10
[TK_MAC_XCURSOR_box_spiral] = {
0xFF, 0xFE, 0x80, 0x00, 0xBF, 0xFE, 0xA0, 0x02, 0xAF, 0xFA, 0xA8, 0x0A, 0xAB, 0xEA, 0xAA, 0x2A,
0xAA, 0xAA, 0xAB, 0xAA, 0xA8, 0x2A, 0xAF, 0xEA, 0xA0, 0x0A, 0xBF, 0xFA, 0x80, 0x02, 0xFF, 0xFE,
0xFF, 0xFE, 0x80, 0x00, 0xBF, 0xFE, 0xA0, 0x02, 0xAF, 0xFA, 0xA8, 0x0A, 0xAB, 0xEA, 0xAA, 0x2A,
0xAA, 0xAA, 0xAB, 0xAA, 0xA8, 0x2A, 0xAF, 0xEA, 0xA0, 0x0A, 0xBF, 0xFA, 0x80, 0x02, 0xFF, 0xFE,
0x00, 0x08, 0x00, 0x08,
},
#define TK_MAC_XCURSOR_center_ptr 11
[TK_MAC_XCURSOR_center_ptr] = {
0x00, 0x00, 0x03, 0x00, 0x03, 0x00, 0x07, 0x80, 0x07, 0x80, 0x0F, 0xC0, 0x0F, 0xC0, 0x1F, 0xE0,
0x1F, 0xE0, 0x33, 0x30, 0x23, 0x10, 0x03, 0x00, 0x03, 0x00, 0x03, 0x00, 0x03, 0x00, 0x00, 0x00,
0x03, 0x00, 0x07, 0x80, 0x07, 0x80, 0x0F, 0xC0, 0x0F, 0xC0, 0x1F, 0xE0, 0x1F, 0xE0, 0x3F, 0xF0,
0x3F, 0xF0, 0x7F, 0xF8, 0x77, 0xB8, 0x67, 0x98, 0x07, 0x80, 0x07, 0x80, 0x07, 0x80, 0x07, 0x80,
0x00, 0x01, 0x00, 0x06,
},
#define TK_MAC_XCURSOR_circle 12
[TK_MAC_XCURSOR_circle] = {
0x00, 0x00, 0x03, 0xC0, 0x0F, 0xF0, 0x1F, 0xF8, 0x3C, 0x3C, 0x38, 0x1C, 0x70, 0x0E, 0x70, 0x0E,
0x70, 0x0E, 0x70, 0x0E, 0x38, 0x1C, 0x3C, 0x3C, 0x1F, 0xF8, 0x0F, 0xF0, 0x03, 0xC0, 0x00, 0x00,
0x03, 0xC0, 0x0F, 0xF0, 0x1F, 0xF8, 0x3F, 0xFC, 0x7F, 0xFE, 0x7C, 0x3E, 0xF8, 0x1F, 0xF8, 0x1F,
0xF8, 0x1F, 0xF8, 0x1F, 0x7C, 0x3E, 0x7F, 0xFE, 0x3F, 0xFC, 0x1F, 0xF8, 0x0F, 0xF0, 0x03, 0xC0,
0x00, 0x07, 0x00, 0x07,
},
#define TK_MAC_XCURSOR_clock 13
[TK_MAC_XCURSOR_clock] = {
0x1F, 0xF8, 0x33, 0xCC, 0x64, 0x66, 0x49, 0x92, 0x4F, 0x12, 0x44, 0x22, 0x63, 0xC6, 0x3F, 0xFC,
0x29, 0x94, 0x29, 0x94, 0x29, 0x94, 0x2B, 0xD4, 0x69, 0x96, 0x78, 0x1E, 0x7F, 0xFE, 0x7F, 0xFE,
0x1F, 0xF8, 0x3F, 0xFC, 0x7F, 0xFE, 0x7F, 0xFE, 0x7F, 0xFE, 0x7F, 0xFE, 0x7F, 0xFE, 0x3F, 0xFC,
0x3F, 0xFC, 0x3F, 0xFC, 0x3F, 0xFC, 0x3F, 0xFC, 0x7F, 0xFE, 0x7F, 0xFE, 0x7F, 0xFE, 0x7F, 0xFE,
0x00, 0x04, 0x00, 0x08,
},
#define TK_MAC_XCURSOR_coffee_mug 14
[TK_MAC_XCURSOR_coffee_mug] = {
0x03, 0xF8, 0x0C, 0x06, 0x10, 0x01, 0x1C, 0x07, 0x33, 0xF9, 0x70, 0x01, 0xD0, 0x01, 0x90, 0x01,
0x96, 0x0D, 0xDA, 0x55, 0x7A, 0x55, 0x36, 0xED, 0x10, 0xA1, 0x10, 0x01, 0x08, 0x02, 0x07, 0xFC,
0x03, 0xF8, 0x0F, 0xFE, 0x1F, 0xFF, 0x1F, 0xFF, 0x3F, 0xFF, 0x7F, 0xFF, 0xFF, 0xFF, 0xFF, 0xFF,
0xFF, 0xFF, 0xFF, 0xFF, 0x7F, 0xFF, 0x3F, 0xFF, 0x1F, 0xFF, 0x1F, 0xFF, 0x0F, 0xFE, 0x07, 0xFC,
0x00, 0x04, 0x00, 0x03,
},
#define TK_MAC_XCURSOR_cross 15
[TK_MAC_XCURSOR_cross] = {
0x02, 0x80, 0x02, 0x80, 0x02, 0x80, 0x02, 0x80, 0x02, 0x80, 0x02, 0x80, 0xFE, 0xFE, 0x00, 0x00,
0xFE, 0xFE, 0x02, 0x80, 0x02, 0x80, 0x02, 0x80, 0x02, 0x80, 0x02, 0x80, 0x02, 0x80, 0x00, 0x00,
0x03, 0x80, 0x03, 0x80, 0x03, 0x80, 0x03, 0x80, 0x03, 0x80, 0x03, 0x80, 0xFF, 0xFE, 0xFF, 0xFE,
0xFF, 0xFE, 0x03, 0x80, 0x03, 0x80, 0x03, 0x80, 0x03, 0x80, 0x03, 0x80, 0x03, 0x80, 0x00, 0x00,
0x00, 0x07, 0x00, 0x07,
},
#define TK_MAC_XCURSOR_cross_reverse 16
[TK_MAC_XCURSOR_cross_reverse] = {
0x42, 0x84, 0xA2, 0x8A, 0x52, 0x94, 0x2A, 0xA8, 0x16, 0xD0, 0x0A, 0xA0, 0xFD, 0x7E, 0x02, 0x80,
0xFD, 0x7E, 0x0A, 0xA0, 0x16, 0xD0, 0x2A, 0xA8, 0x52, 0x94, 0xA2, 0x8A, 0x42, 0x84, 0x00, 0x00,
0x43, 0x84, 0xE3, 0x8E, 0x73, 0x9C, 0x3B, 0xB8, 0x1F, 0xF0, 0x0F, 0xE0, 0xFF, 0xFE, 0xFF, 0xFE,
0xFF, 0xFE, 0x0F, 0xE0, 0x1F, 0xF0, 0x3B, 0xB8, 0x73, 0x9C, 0xE3, 0x8E, 0x43, 0x84, 0x00, 0x00,
0x00, 0x07, 0x00, 0x07,
},
#define TK_MAC_XCURSOR_crosshair 17
[TK_MAC_XCURSOR_crosshair] = {
0x01, 0x00, 0x01, 0x00, 0x01, 0x00, 0x01, 0x00, 0x01, 0x00, 0x01, 0x00, 0x01, 0x00, 0xFE, 0xFE,
0x01, 0x00, 0x01, 0x00, 0x01, 0x00, 0x01, 0x00, 0x01, 0x00, 0x01, 0x00, 0x01, 0x00, 0x00, 0x00,
0x01, 0x00, 0x01, 0x00, 0x01, 0x00, 0x01, 0x00, 0x01, 0x00, 0x01, 0x00, 0x01, 0x00, 0xFE, 0xFE,
0x01, 0x00, 0x01, 0x00, 0x01, 0x00, 0x01, 0x00, 0x01, 0x00, 0x01, 0x00, 0x01, 0x00, 0x00, 0x00,
0x00, 0x07, 0x00, 0x07,
},
#define TK_MAC_XCURSOR_diamond_cross 18
[TK_MAC_XCURSOR_diamond_cross] = {
0x02, 0x80, 0x06, 0xC0, 0x0A, 0xA0, 0x12, 0x90, 0x22, 0x88, 0x42, 0x84, 0xFE, 0xFE, 0x00, 0x00,
0xFE, 0xFE, 0x42, 0x84, 0x22, 0x88, 0x12, 0x90, 0x0A, 0xA0, 0x06, 0xC0, 0x02, 0x80, 0x00, 0x00,
0x02, 0x80, 0x06, 0xC0, 0x0E, 0xE0, 0x1E, 0xF0, 0x3E, 0xF8, 0x7E, 0xFC, 0xFE, 0xFE, 0x00, 0x00,
0xFE, 0xFE, 0x7E, 0xFC, 0x3E, 0xF8, 0x1E, 0xF0, 0x0E, 0xE0, 0x06, 0xC0, 0x02, 0x80, 0x00, 0x00,
0x00, 0x07, 0x00, 0x07,
},
#define TK_MAC_XCURSOR_dot 19
[TK_MAC_XCURSOR_dot] = {
0x00, 0x00, 0x00, 0x00, 0x07, 0x80, 0x1F, 0xE0, 0x1F, 0xE0, 0x3F, 0xF0, 0x3F, 0xF0, 0x3F, 0xF0,
0x3F, 0xF0, 0x1F, 0xE0, 0x1F, 0xE0, 0x07, 0x80, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00,
0x00, 0x00, 0x07, 0x80, 0x1F, 0xE0, 0x3F, 0xF0, 0x3F, 0xF0, 0x7F, 0xF8, 0x7F, 0xF8, 0x7F, 0xF8,
0x7F, 0xF8, 0x3F, 0xF0, 0x3F, 0xF0, 0x1F, 0xE0, 0x07, 0x80, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00,
0x00, 0x06, 0x00, 0x06,
},
#define TK_MAC_XCURSOR_dotbox 20
[TK_MAC_XCURSOR_dotbox] = {
0x00, 0x00, 0x00, 0x00, 0x3F, 0xFC, 0x20, 0x04, 0x20, 0x04, 0x20, 0x04, 0x20, 0x04, 0x21, 0x84,
0x21, 0x84, 0x20, 0x04, 0x20, 0x04, 0x20, 0x04, 0x20, 0x04, 0x3F, 0xFC, 0x00, 0x00, 0x00, 0x00,
0x00, 0x00, 0x00, 0x00, 0x3F, 0xFC, 0x3F, 0xFC, 0x30, 0x0C, 0x30, 0x0C, 0x31, 0x8C, 0x33, 0xCC,
0x33, 0xCC, 0x31, 0x8C, 0x30, 0x0C, 0x30, 0x0C, 0x3F, 0xFC, 0x3F, 0xFC, 0x00, 0x00, 0x00, 0x00,
0x00, 0x07, 0x00, 0x07,
},
#define TK_MAC_XCURSOR_double_arrow 21
[TK_MAC_XCURSOR_double_arrow] = {
0x00, 0x00, 0x01, 0x80, 0x03, 0xC0, 0x07, 0xE0, 0x0D, 0xB0, 0x19, 0x98, 0x01, 0x80, 0x01, 0x80,
0x01, 0x80, 0x01, 0x80, 0x19, 0x98, 0x0D, 0xB0, 0x07, 0xE0, 0x03, 0xC0, 0x01, 0x80, 0x00, 0x00,
0x01, 0x80, 0x03, 0xC0, 0x07, 0xE0, 0x0F, 0xF0, 0x1F, 0xF8, 0x3F, 0xFC, 0x3B, 0xDC, 0x03, 0xC0,
0x03, 0xC0, 0x3B, 0xDC, 0x3F, 0xFC, 0x1F, 0xF8, 0x0F, 0xF0, 0x07, 0xE0, 0x03, 0xC0, 0x01, 0x80,
0x00, 0x07, 0x00, 0x07,
},
#define TK_MAC_XCURSOR_draft_large 22
[TK_MAC_XCURSOR_draft_large] = {
0x00, 0x00, 0x00, 0x02, 0x00, 0x0C, 0x00, 0x3C, 0x00, 0xF8, 0x03, 0xF8, 0x0F, 0xF0, 0x00, 0xF0,
0x01, 0x60, 0x02, 0x60, 0x04, 0x40, 0x08, 0x40, 0x10, 0x00, 0x20, 0x00, 0x40, 0x00, 0x00, 0x00,
0x00, 0x03, 0x00, 0x0F, 0x00, 0x3E, 0x00, 0xFE, 0x03, 0xFC, 0x0F, 0xFC, 0x3F, 0xF8, 0xFF, 0xF8,
0x03, 0xF0, 0x07, 0xF0, 0x0E, 0xE0, 0x1C, 0xE0, 0x38, 0xC0, 0x70, 0xC0, 0xE0, 0x80, 0x40, 0x80,
0x00, 0x01, 0x00, 0x0E,
},
#define TK_MAC_XCURSOR_draft_small 23
[TK_MAC_XCURSOR_draft_small] = {
0x00, 0x00, 0x00, 0x02, 0x00, 0x0C, 0x00, 0x3C, 0x00, 0xF8, 0x03, 0xF8, 0x00, 0x70, 0x00, 0xB0,
0x01, 0x20, 0x02, 0x20, 0x04, 0x00, 0x08, 0x00, 0x10, 0x00, 0x20, 0x00, 0x40, 0x00, 0x00, 0x00,
0x00, 0x03, 0x00, 0x0F, 0x00, 0x3E, 0x00, 0xFE, 0x03, 0xFC, 0x0F, 0xFC, 0x3F, 0xF8, 0x01, 0xF8,
0x03, 0xF0, 0x07, 0x70, 0x0E, 0x60, 0x1C, 0x60, 0x38, 0x40, 0x70, 0x40, 0xE0, 0x00, 0x40, 0x00,
0x00, 0x01, 0x00, 0x0E,
},
#define TK_MAC_XCURSOR_draped_box 24
[TK_MAC_XCURSOR_draped_box] = {
0x00, 0x00, 0x00, 0x00, 0x3F, 0xFC, 0x22, 0x44, 0x26, 0x64, 0x2C, 0x34, 0x38, 0x1C, 0x21, 0x84,
0x21, 0x84, 0x38, 0x1C, 0x2C, 0x34, 0x26, 0x64, 0x22, 0x44, 0x3F, 0xFC, 0x00, 0x00, 0x00, 0x00,
0x00, 0x00, 0x00, 0x00, 0x3F, 0xFC, 0x3E, 0x7C, 0x3E, 0x7C, 0x3C, 0x3C, 0x39, 0x9C, 0x23, 0xC4,
0x23, 0xC4, 0x39, 0x9C, 0x3C, 0x3C, 0x3E, 0x7C, 0x3E, 0x7C, 0x3F, 0xFC, 0x00, 0x00, 0x00, 0x00,
0x00, 0x07, 0x00, 0x07,
},
#define TK_MAC_XCURSOR_exchange 25
[TK_MAC_XCURSOR_exchange] = {
0x00, 0x00, 0x47, 0xC0, 0x6F, 0xE0, 0x7C, 0x30, 0x48, 0x10, 0x4C, 0x00, 0x7E, 0x00, 0x00, 0x00,
0x00, 0x00, 0x00, 0xFC, 0x00, 0x64, 0x10, 0x24, 0x18, 0x7C, 0x0F, 0xEC, 0x07, 0xC4, 0x00, 0x00,
0xC7, 0xC0, 0xEF, 0xE0, 0xFF, 0xF0, 0xFF, 0xF8, 0xFC, 0x38, 0xFE, 0x10, 0xFF, 0x00, 0xFF, 0x80,
0x03, 0xFE, 0x01, 0xFE, 0x10, 0xFE, 0x38, 0x7E, 0x3F, 0xFE, 0x1F, 0xFE, 0x0F, 0xEE, 0x07, 0xC6,
0x00, 0x07, 0x00, 0x07,
},
#define TK_MAC_XCURSOR_fleur 26
[TK_MAC_XCURSOR_fleur] = {
0x00, 0x00, 0x01, 0x80, 0x03, 0xC0, 0x07, 0xE0, 0x01, 0x80, 0x11, 0x88, 0x31, 0x8C, 0x7F, 0xFE,
0x7F, 0xFE, 0x31, 0x8C, 0x11, 0x88, 0x01, 0x80, 0x07, 0xE0, 0x03, 0xC0, 0x01, 0x80, 0x00, 0x00,
0x01, 0x80, 0x03, 0xC0, 0x07, 0xE0, 0x0F, 0xF0, 0x17, 0xE8, 0x3B, 0xDC, 0x7F, 0xFE, 0xFF, 0xFF,
0xFF, 0xFF, 0x7F, 0xFE, 0x3B, 0xDC, 0x17, 0xE8, 0x0F, 0xF0, 0x07, 0xE0, 0x03, 0xC0, 0x01, 0x80,
0x00, 0x07, 0x00, 0x07,
},
#define TK_MAC_XCURSOR_gobbler 27
[TK_MAC_XCURSOR_gobbler] = {
0x00, 0x00, 0x00, 0x78, 0x00, 0x70, 0x40, 0x36, 0x4F, 0xB0, 0x7F, 0xF0, 0x7E, 0x30, 0x7C, 0x30,
0x30, 0x38, 0x00, 0xF0, 0x0F, 0xE0, 0x04, 0x00, 0x04, 0x00, 0x04, 0x00, 0x0F, 0x00, 0x00, 0x00,
0x00, 0xFC, 0x00, 0xFC, 0xE0, 0xFF, 0xFF, 0xFF, 0xFF, 0xFF, 0xFF, 0xF8, 0xFF, 0xF8, 0xFF, 0xF8,
0xFF, 0xFC, 0x7F, 0xFC, 0x3F, 0xF8, 0x1F, 0xF0, 0x0E, 0x00, 0x1F, 0x80, 0x1F, 0x80, 0x1F, 0x80,
0x00, 0x03, 0x00, 0x0E,
},
#define TK_MAC_XCURSOR_gumby 28
[TK_MAC_XCURSOR_gumby] = {
0x3F, 0x00, 0x10, 0xC0, 0xC8, 0x20, 0xEA, 0xA0, 0xC8, 0x20, 0xCB, 0xA0, 0xF8, 0x38, 0x38, 0x3E,
0x08, 0x26, 0x08, 0x26, 0x09, 0x2E, 0x09, 0x26, 0x09, 0x20, 0x11, 0x10, 0x21, 0x08, 0x3E, 0xF8,
0x3F, 0x00, 0x1F, 0xC0, 0xCF, 0xE0, 0xEF, 0xE0, 0xCF, 0xE0, 0xCF, 0xE0, 0xFF, 0xF8, 0x3F, 0xFE,
0x0F, 0xE6, 0x0F, 0xE6, 0x0F, 0xEE, 0x0F, 0xE6, 0x0F, 0xE0, 0x1F, 0xF0, 0x3F, 0xF8, 0x3E, 0xF8,
0x00, 0x00, 0x00, 0x02,
},
#define TK_MAC_XCURSOR_hand1 29
[TK_MAC_XCURSOR_hand1] = {
0x00, 0x0C, 0x00, 0x3C, 0x00, 0xF0, 0x01, 0xE0, 0x03, 0xC0, 0x07, 0xE0, 0x0F, 0xF0, 0x2F, 0xE0,
0x7F, 0xF0, 0x5F, 0xF0, 0x07, 0xE0, 0x07, 0xC0, 0x4A, 0x00, 0x62, 0x00, 0x34, 0x00, 0x18, 0x00,
0x00, 0x0C, 0x00, 0x3C, 0x00, 0xF0, 0x01, 0xE0, 0x03, 0xC0, 0x07, 0xE0, 0x0F, 0xF0, 0x2F, 0xE0,
0x7F, 0xF0, 0x7F, 0xF0, 0x7F, 0xE0, 0x7F, 0xC0, 0x7E, 0x00, 0x7E, 0x00, 0x3C, 0x00, 0x18, 0x00,
0x00, 0x00, 0x00, 0x0D,
},
#define TK_MAC_XCURSOR_hand2 30
[TK_MAC_XCURSOR_hand2] = {
0x00, 0x00, 0x3F, 0xC0, 0x40, 0x20, 0x3F, 0x10, 0x08, 0x08, 0x07, 0x08, 0x08, 0x08, 0x07, 0x14,
0x08, 0x22, 0x06, 0x41, 0x01, 0x82, 0x01, 0x24, 0x00, 0x88, 0x00, 0x50, 0x00, 0x20, 0x00, 0x00,
0x00, 0x00, 0x3F, 0xC0, 0x7F, 0xE0, 0x3F, 0xF0, 0x0F, 0xF8, 0x07, 0xF8, 0x0F, 0xF8, 0x07, 0xFC,
0x0F, 0xFE, 0x07, 0xFF, 0x01, 0xFE, 0x01, 0xFC, 0x00, 0xF8, 0x00, 0x70, 0x00, 0x20, 0x00, 0x00,
0x00, 0x02, 0x00, 0x01,
},
#define TK_MAC_XCURSOR_heart 31
[TK_MAC_XCURSOR_heart] = {
0x00, 0x00, 0x3E, 0xF8, 0x63, 0x8C, 0xC1, 0x06, 0x80, 0x02, 0x80, 0x02, 0x80, 0x02, 0x80, 0x02,
0xC0, 0x06, 0x60, 0x0C, 0x30, 0x18, 0x18, 0x30, 0x0C, 0x60, 0x06, 0xC0, 0x03, 0x80, 0x00, 0x00,
0x00, 0x00, 0x3E, 0xF8, 0x7F, 0xFC, 0xFF, 0xFE, 0xFF, 0xFE, 0xFF, 0xFE, 0xFF, 0xFE, 0xFF, 0xFE,
0xFF, 0xFE, 0x7F, 0xFC, 0x3F, 0xF8, 0x1F, 0xF0, 0x0F, 0xE0, 0x07, 0xC0, 0x03, 0x80, 0x00, 0x00,
0x00, 0x03, 0x00, 0x07,
},
#define TK_MAC_XCURSOR_icon 32
[TK_MAC_XCURSOR_icon] = {
0xFF, 0xFF, 0xD5, 0x55, 0xAA, 0xAB, 0xD5, 0x55, 0xA0, 0x0B, 0xD0, 0x05, 0xA0, 0x0B, 0xD0, 0x05,
0xA0, 0x0B, 0xD0, 0x05, 0xA0, 0x0B, 0xD0, 0x05, 0xAA, 0xAB, 0xD5, 0x55, 0xAA, 0xAB, 0xFF, 0xFF,
0xFF, 0xFF, 0xFF, 0xFF, 0xFF, 0xFF, 0xFF, 0xFF, 0xF0, 0x0F, 0xF0, 0x0F, 0xF0, 0x0F, 0xF0, 0x0F,
0xF0, 0x0F, 0xF0, 0x0F, 0xF0, 0x0F, 0xF0, 0x0F, 0xFF, 0xFF, 0xFF, 0xFF, 0xFF, 0xFF, 0xFF, 0xFF,
0x00, 0x07, 0x00, 0x07,
},
#define TK_MAC_XCURSOR_iron_cross 33
[TK_MAC_XCURSOR_iron_cross] = {
0x00, 0x00, 0x3F, 0xFC, 0x1F, 0xF8, 0x4F, 0xF2, 0x67, 0xE6, 0x73, 0xCE, 0x79, 0x9E, 0x7F, 0xFE,
0x7F, 0xFE, 0x79, 0x9E, 0x73, 0xCE, 0x67, 0xE6, 0x4F, 0xF2, 0x1F, 0xF8, 0x3F, 0xFC, 0x00, 0x00,
0x7F, 0xFE, 0x7F, 0xFE, 0xFF, 0xFF, 0xFF, 0xFF, 0xFF, 0xFF, 0xFF, 0xFF, 0xFF, 0xFF, 0xFF, 0xFF,
0xFF, 0xFF, 0xFF, 0xFF, 0xFF, 0xFF, 0xFF, 0xFF, 0xFF, 0xFF, 0xFF, 0xFF, 0x7F, 0xFE, 0x7F, 0xFE,
0x00, 0x07, 0x00, 0x06,
},
#define TK_MAC_XCURSOR_left_ptr 34
[TK_MAC_XCURSOR_left_ptr] = {
0x00, 0x00, 0x08, 0x00, 0x0C, 0x00, 0x0E, 0x00, 0x0F, 0x00, 0x0F, 0x80, 0x0F, 0xC0, 0x0F, 0xE0,
0x0F, 0xF0, 0x0F, 0x80, 0x0D, 0x80, 0x08, 0xC0, 0x00, 0xC0, 0x00, 0x60, 0x00, 0x60, 0x00, 0x00,
0x18, 0x00, 0x1C, 0x00, 0x1E, 0x00, 0x1F, 0x00, 0x1F, 0x80, 0x1F, 0xC0, 0x1F, 0xE0, 0x1F, 0xF0,
0x1F, 0xF8, 0x1F, 0xFC, 0x1F, 0xC0, 0x1D, 0xE0, 0x19, 0xE0, 0x10, 0xF0, 0x00, 0xF0, 0x00, 0x70,
0x00, 0x01, 0x00, 0x04,
},
#define TK_MAC_XCURSOR_left_side 35
[TK_MAC_XCURSOR_left_side] = {
0x00, 0x00, 0x60, 0x00, 0x60, 0x00, 0x60, 0x80, 0x61, 0x00, 0x62, 0x00, 0x64, 0x00, 0x6F, 0xFC,
0x64, 0x00, 0x62, 0x00, 0x61, 0x00, 0x60, 0x80, 0x60, 0x00, 0x60, 0x00, 0x00, 0x00, 0x00, 0x00,
0x00, 0x00, 0x60, 0x00, 0x60, 0x00, 0x60, 0x80, 0x61, 0x00, 0x62, 0x00, 0x64, 0x00, 0x6F, 0xFC,
0x64, 0x00, 0x62, 0x00, 0x61, 0x00, 0x60, 0x80, 0x60, 0x00, 0x60, 0x00, 0x00, 0x00, 0x00, 0x00,
0x00, 0x07, 0x00, 0x04,
},
#define TK_MAC_XCURSOR_left_tee 36
[TK_MAC_XCURSOR_left_tee] = {
0x00, 0x00, 0x0C, 0x00, 0x0C, 0x00, 0x0C, 0x00, 0x0C, 0x00, 0x0C, 0x00, 0x0C, 0x00, 0x0F, 0xF8,
0x0F, 0xF8, 0x0C, 0x00, 0x0C, 0x00, 0x0C, 0x00, 0x0C, 0x00, 0x0C, 0x00, 0x0C, 0x00, 0x00, 0x00,
0x00, 0x00, 0x0C, 0x00, 0x0C, 0x00, 0x0C, 0x00, 0x0C, 0x00, 0x0C, 0x00, 0x0C, 0x00, 0x0F, 0xF8,
0x0F, 0xF8, 0x0C, 0x00, 0x0C, 0x00, 0x0C, 0x00, 0x0C, 0x00, 0x0C, 0x00, 0x0C, 0x00, 0x00, 0x00,
0x00, 0x07, 0x00, 0x04,
},
#define TK_MAC_XCURSOR_leftbutton 37
[TK_MAC_XCURSOR_leftbutton] = {
0x80, 0x02, 0x7F, 0xFC, 0x7F, 0xFC, 0x44, 0x44, 0x45, 0x54, 0x45, 0x54, 0x45, 0x54, 0x45, 0x54,
0x44, 0x44, 0x7F, 0xFC, 0x7F, 0xFC, 0x7F, 0xFC, 0x7F, 0xFC, 0x7F, 0xFC, 0x7F, 0xFC, 0x80, 0x02,
0xFF, 0xFE, 0xFF, 0xFE, 0xFF, 0xFE, 0xFF, 0xFE, 0xFF, 0xFE, 0xFF, 0xFE, 0xFF, 0xFE, 0xFF, 0xFE,
0xFF, 0xFE, 0xFF, 0xFE, 0xFF, 0xFE, 0xFF, 0xFE, 0xFF, 0xFE, 0xFF, 0xFE, 0xFF, 0xFE, 0xFF, 0xFE,
0x00, 0x04, 0x00, 0x03,
},
#define TK_MAC_XCURSOR_ll_angle 38
[TK_MAC_XCURSOR_ll_angle] = {
0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x0C, 0x00, 0x0C, 0x00, 0x0C, 0x00, 0x0C, 0x00, 0x0C, 0x00,
0x0C, 0x00, 0x0C, 0x00, 0x0F, 0xF8, 0x0F, 0xF8, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00,
0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x0C, 0x00, 0x0C, 0x00, 0x0C, 0x00, 0x0C, 0x00, 0x0C, 0x00,
0x0C, 0x00, 0x0C, 0x00, 0x0F, 0xF8, 0x0F, 0xF8, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00,
0x00, 0x0B, 0x00, 0x04,
},
#define TK_MAC_XCURSOR_lr_angle 39
[TK_MAC_XCURSOR_lr_angle] = {
0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x30, 0x00, 0x30, 0x00, 0x30, 0x00, 0x30, 0x00, 0x30,
0x00, 0x30, 0x00, 0x30, 0x1F, 0xF0, 0x1F, 0xF0, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00,
0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x30, 0x00, 0x30, 0x00, 0x30, 0x00, 0x30, 0x00, 0x30,
0x00, 0x30, 0x00, 0x30, 0x1F, 0xF0, 0x1F, 0xF0, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00,
0x00, 0x0B, 0x00, 0x0B,
},
#define TK_MAC_XCURSOR_man 40
[TK_MAC_XCURSOR_man] = {
0x03, 0x80, 0x1E, 0xF0, 0x02, 0x80, 0x81, 0x00, 0x43, 0x87, 0x24, 0x4B, 0x1D, 0x70, 0x05, 0x40,
0x04, 0x40, 0x02, 0x80, 0x04, 0x40, 0x09, 0x20, 0x12, 0x90, 0x14, 0x50, 0x78, 0x3C, 0xF8, 0x3F,
0x03, 0x80, 0x1F, 0xF0, 0x03, 0x80, 0x81, 0x00, 0x43, 0x87, 0x27, 0xCB, 0x1F, 0xF0, 0x07, 0xC0,
0x07, 0xC0, 0x03, 0x80, 0x07, 0xC0, 0x0F, 0xE0, 0x1E, 0xF0, 0x1C, 0x70, 0x78, 0x3C, 0xF8, 0x3F,
0x00, 0x01, 0x00, 0x07,
},
#define TK_MAC_XCURSOR_middlebutton 41
[TK_MAC_XCURSOR_middlebutton] = {
0x80, 0x02, 0x7F, 0xFC, 0x7F, 0xFC, 0x44, 0x44, 0x54, 0x54, 0x54, 0x54, 0x54, 0x54, 0x54, 0x54,
0x44, 0x44, 0x7F, 0xFC, 0x7F, 0xFC, 0x7F, 0xFC, 0x7F, 0xFC, 0x7F, 0xFC, 0x7F, 0xFC, 0x80, 0x02,
0xFF, 0xFE, 0xFF, 0xFE, 0xFF, 0xFE, 0xFF, 0xFE, 0xFF, 0xFE, 0xFF, 0xFE, 0xFF, 0xFE, 0xFF, 0xFE,
0xFF, 0xFE, 0xFF, 0xFE, 0xFF, 0xFE, 0xFF, 0xFE, 0xFF, 0xFE, 0xFF, 0xFE, 0xFF, 0xFE, 0xFF, 0xFE,
0x00, 0x04, 0x00, 0x07,
},
#define TK_MAC_XCURSOR_mouse 42
[TK_MAC_XCURSOR_mouse] = {
0x06, 0x00, 0x01, 0x00, 0x01, 0x80, 0x0F, 0xF0, 0x10, 0x08, 0x17, 0xE8, 0x14, 0x28, 0x14, 0x28,
0x17, 0xE8, 0x10, 0x08, 0x10, 0x08, 0x10, 0x08, 0x10, 0x08, 0x10, 0x08, 0x10, 0x08, 0x0F, 0xF0,
0x06, 0x00, 0x01, 0x00, 0x01, 0x80, 0x0F, 0xF0, 0x1F, 0xF8, 0x1F, 0xF8, 0x1F, 0xF8, 0x1F, 0xF8,
0x1F, 0xF8, 0x1F, 0xF8, 0x1F, 0xF8, 0x1F, 0xF8, 0x1F, 0xF8, 0x1F, 0xF8, 0x1F, 0xF8, 0x0F, 0xF0,
0x00, 0x00, 0x00, 0x00,
},
#define TK_MAC_XCURSOR_pencil 43
[TK_MAC_XCURSOR_pencil] = {
0x00, 0x00, 0x00, 0xF0, 0x00, 0x88, 0x01, 0x08, 0x01, 0x90, 0x02, 0x70, 0x02, 0x20, 0x04, 0x40,
0x04, 0x40, 0x08, 0x80, 0x08, 0x80, 0x11, 0x00, 0x1E, 0x00, 0x1C, 0x00, 0x18, 0x00, 0x10, 0x00,
0x00, 0x00, 0x00, 0xF0, 0x00, 0xF8, 0x01, 0xF8, 0x01, 0xF0, 0x03, 0xF0, 0x03, 0xE0, 0x07, 0xC0,
0x07, 0xC0, 0x0F, 0x80, 0x0F, 0x80, 0x1F, 0x00, 0x1E, 0x00, 0x1C, 0x00, 0x18, 0x00, 0x10, 0x00,
0x00, 0x0F, 0x00, 0x03,
},
#define TK_MAC_XCURSOR_pirate 44
[TK_MAC_XCURSOR_pirate] = {
0x03, 0xC0, 0x07, 0xE0, 0x0F, 0xF0, 0x19, 0x98, 0x19, 0x98, 0x0F, 0xF0, 0x07, 0xE0, 0x03, 0xC0,
0x43, 0xC2, 0x43, 0xC3, 0x21, 0x84, 0x1C, 0x38, 0x03, 0xC0, 0x0F, 0xF1, 0x78, 0x1F, 0x40, 0x02,
0x07, 0xE0, 0x0F, 0xF0, 0x1F, 0xF8, 0x3F, 0xFC, 0x3F, 0xFC, 0x1F, 0xF8, 0x0F, 0xF0, 0x47, 0xE2,
0xE7, 0xE7, 0xE7, 0xE7, 0x7F, 0xFF, 0x3F, 0xFC, 0x1F, 0xF9, 0x7F, 0xFF, 0xFF, 0xFF, 0xF8, 0x1F,
0x00, 0x0A, 0x00, 0x07,
},
#define TK_MAC_XCURSOR_plus 45
[TK_MAC_XCURSOR_plus] = {
0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x01, 0x80, 0x01, 0x80, 0x01, 0x80, 0x01, 0x80, 0x1F, 0xF8,
0x1F, 0xF8, 0x01, 0x80, 0x01, 0x80, 0x01, 0x80, 0x01, 0x80, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00,
0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x01, 0x80, 0x01, 0x80, 0x01, 0x80, 0x01, 0x80, 0x1F, 0xF8,
0x1F, 0xF8, 0x01, 0x80, 0x01, 0x80, 0x01, 0x80, 0x01, 0x80, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00,
0x00, 0x07, 0x00, 0x07,
},
#define TK_MAC_XCURSOR_question_arrow 46
[TK_MAC_XCURSOR_question_arrow] = {
0x07, 0xC0, 0x0F, 0xE0, 0x1C, 0x70, 0x18, 0x30, 0x1C, 0x30, 0x0C, 0x70, 0x00, 0xE0, 0x03, 0xC0,
0x03, 0x80, 0x02, 0x80, 0x02, 0x80, 0x0E, 0xE0, 0x06, 0xC0, 0x03, 0x80, 0x01, 0x00, 0x00, 0x00,
0x07, 0xC0, 0x0F, 0xE0, 0x1C, 0x70, 0x18, 0x30, 0x1C, 0x30, 0x0C, 0x70, 0x00, 0xE0, 0x03, 0xC0,
0x03, 0x80, 0x02, 0x80, 0x3F, 0xF8, 0x1F, 0xF0, 0x0F, 0xE0, 0x07, 0xC0, 0x03, 0x80, 0x01, 0x00,
0x00, 0x0E, 0x00, 0x07,
},
#define TK_MAC_XCURSOR_right_ptr 47
[TK_MAC_XCURSOR_right_ptr] = {
0x00, 0x00, 0x00, 0x10, 0x00, 0x30, 0x00, 0x70, 0x00, 0xF0, 0x01, 0xF0, 0x03, 0xF0, 0x07, 0xF0,
0x0F, 0xF0, 0x01, 0xF0, 0x01, 0xB0, 0x03, 0x10, 0x03, 0x00, 0x06, 0x00, 0x06, 0x00, 0x00, 0x00,
0x00, 0x18, 0x00, 0x38, 0x00, 0x78, 0x00, 0xF8, 0x01, 0xF8, 0x03, 0xF8, 0x07, 0xF8, 0x0F, 0xF8,
0x1F, 0xF8, 0x3F, 0xF8, 0x03, 0xF8, 0x07, 0xB8, 0x07, 0x98, 0x0F, 0x08, 0x0F, 0x00, 0x0E, 0x00,
0x00, 0x01, 0x00, 0x0B,
},
#define TK_MAC_XCURSOR_right_side 48
[TK_MAC_XCURSOR_right_side] = {
0x00, 0x00, 0x00, 0x00, 0x00, 0x06, 0x00, 0x06, 0x01, 0x06, 0x00, 0x86, 0x00, 0x46, 0x00, 0x26,
0x3F, 0xF6, 0x00, 0x26, 0x00, 0x46, 0x00, 0x86, 0x01, 0x06, 0x00, 0x06, 0x00, 0x06, 0x00, 0x00,
0x00, 0x00, 0x00, 0x00, 0x00, 0x06, 0x00, 0x06, 0x01, 0x06, 0x00, 0x86, 0x00, 0x46, 0x00, 0x26,
0x3F, 0xF6, 0x00, 0x26, 0x00, 0x46, 0x00, 0x86, 0x01, 0x06, 0x00, 0x06, 0x00, 0x06, 0x00, 0x00,
0x00, 0x08, 0x00, 0x0B,
},
#define TK_MAC_XCURSOR_right_tee 49
[TK_MAC_XCURSOR_right_tee] = {
0x00, 0x00, 0x00, 0x30, 0x00, 0x30, 0x00, 0x30, 0x00, 0x30, 0x00, 0x30, 0x00, 0x30, 0x1F, 0xF0,
0x1F, 0xF0, 0x00, 0x30, 0x00, 0x30, 0x00, 0x30, 0x00, 0x30, 0x00, 0x30, 0x00, 0x30, 0x00, 0x00,
0x00, 0x00, 0x00, 0x30, 0x00, 0x30, 0x00, 0x30, 0x00, 0x30, 0x00, 0x30, 0x00, 0x30, 0x1F, 0xF0,
0x1F, 0xF0, 0x00, 0x30, 0x00, 0x30, 0x00, 0x30, 0x00, 0x30, 0x00, 0x30, 0x00, 0x30, 0x00, 0x00,
0x00, 0x07, 0x00, 0x0A,
},
#define TK_MAC_XCURSOR_rightbutton 50
[TK_MAC_XCURSOR_rightbutton] = {
0x80, 0x02, 0x7F, 0xFC, 0x7F, 0xFC, 0x44, 0x44, 0x55, 0x44, 0x55, 0x44, 0x55, 0x44, 0x55, 0x44,
0x44, 0x44, 0x7F, 0xFC, 0x7F, 0xFC, 0x7F, 0xFC, 0x7F, 0xFC, 0x7F, 0xFC, 0x7F, 0xFC, 0x80, 0x02,
0xFF, 0xFE, 0xFF, 0xFE, 0xFF, 0xFE, 0xFF, 0xFE, 0xFF, 0xFE, 0xFF, 0xFE, 0xFF, 0xFE, 0xFF, 0xFE,
0xFF, 0xFE, 0xFF, 0xFE, 0xFF, 0xFE, 0xFF, 0xFE, 0xFF, 0xFE, 0xFF, 0xFE, 0xFF, 0xFE, 0xFF, 0xFE,
0x00, 0x04, 0x00, 0x03,
},
#define TK_MAC_XCURSOR_rtl_logo 51
[TK_MAC_XCURSOR_rtl_logo] = {
0x00, 0x00, 0x7F, 0xFE, 0x40, 0x22, 0x40, 0x22, 0x40, 0x22, 0x7F, 0xE2, 0x44, 0x22, 0x44, 0x22,
0x44, 0x22, 0x44, 0x22, 0x47, 0xFE, 0x44, 0x02, 0x44, 0x02, 0x44, 0x02, 0x7F, 0xFE, 0x00, 0x00,
0x00, 0x00, 0x7F, 0xFE, 0x7F, 0xFE, 0x60, 0x76, 0x7F, 0xF6, 0x7F, 0xF6, 0x7C, 0x36, 0x6C, 0x36,
0x6C, 0x36, 0x6C, 0x3E, 0x6F, 0xFE, 0x6F, 0xFE, 0x6E, 0x06, 0x7F, 0xFE, 0x7F, 0xFE, 0x00, 0x00,
0x00, 0x07, 0x00, 0x07,
},
#define TK_MAC_XCURSOR_sailboat 52
[TK_MAC_XCURSOR_sailboat] = {
0x00, 0x00, 0x00, 0x40, 0x00, 0x40, 0x01, 0x60, 0x01, 0x60, 0x03, 0x60, 0x03, 0x70, 0x07, 0x70,
0x07, 0x70, 0x0F, 0x78, 0x0F, 0x78, 0x1F, 0x78, 0x1F, 0x7C, 0x3E, 0x38, 0x00, 0x00, 0x00, 0x00,
0x00, 0x40, 0x00, 0xE0, 0x01, 0xE0, 0x03, 0xF0, 0x03, 0xF0, 0x07, 0xF0, 0x07, 0xF8, 0x0F, 0xF8,
0x0F, 0xF8, 0x1F, 0xFC, 0x1F, 0xFC, 0x3F, 0xFC, 0x3F, 0xFE, 0x7F, 0x7C, 0x7E, 0x38, 0x00, 0x00,
0x00, 0x0C, 0x00, 0x08,
},
#define TK_MAC_XCURSOR_sb_down_arrow 53
[TK_MAC_XCURSOR_sb_down_arrow] = {
0x02, 0x80, 0x02, 0x80, 0x02, 0x80, 0x02, 0x80, 0x02, 0x80, 0x02, 0x80, 0x02, 0x80, 0x02, 0x80,
0x02, 0x80, 0x02, 0x80, 0x02, 0x80, 0x0F, 0xE0, 0x07, 0xC0, 0x03, 0x80, 0x01, 0x00, 0x00, 0x00,
0x03, 0x80, 0x03, 0x80, 0x03, 0x80, 0x03, 0x80, 0x03, 0x80, 0x03, 0x80, 0x03, 0x80, 0x03, 0x80,
0x03, 0x80, 0x03, 0x80, 0x03, 0x80, 0x1F, 0xF0, 0x0F, 0xE0, 0x07, 0xC0, 0x03, 0x80, 0x01, 0x00,
0x00, 0x0E, 0x00, 0x07,
},
#define TK_MAC_XCURSOR_sb_h_double_arrow 54
[TK_MAC_XCURSOR_sb_h_double_arrow] = {
0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x08, 0x10, 0x18, 0x18, 0x3F, 0xFC, 0x78, 0x1E,
0x3F, 0xFC, 0x18, 0x18, 0x08, 0x10, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00,
0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x08, 0x10, 0x18, 0x18, 0x38, 0x1C, 0x7F, 0xFE, 0xFF, 0xFF,
0x7F, 0xFE, 0x38, 0x1C, 0x18, 0x18, 0x08, 0x10, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00,
0x00, 0x07, 0x00, 0x07,
},
#define TK_MAC_XCURSOR_sb_left_arrow 55
[TK_MAC_XCURSOR_sb_left_arrow] = {
0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x08, 0x00, 0x18, 0x00, 0x3F, 0xFF, 0x78, 0x00,
0x3F, 0xFF, 0x18, 0x00, 0x08, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00,
0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x08, 0x00, 0x18, 0x00, 0x38, 0x00, 0x7F, 0xFF, 0xFF, 0xFF,
0x7F, 0xFF, 0x38, 0x00, 0x18, 0x00, 0x08, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00,
0x00, 0x07, 0x00, 0x01,
},
#define TK_MAC_XCURSOR_sb_right_arrow 56
[TK_MAC_XCURSOR_sb_right_arrow] = {
0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x10, 0x00, 0x18, 0xFF, 0xFC,
0x00, 0x1E, 0xFF, 0xFC, 0x00, 0x18, 0x00, 0x10, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00,
0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x10, 0x00, 0x18, 0x00, 0x1C, 0xFF, 0xFE,
0xFF, 0xFF, 0xFF, 0xFE, 0x00, 0x1C, 0x00, 0x18, 0x00, 0x10, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00,
0x00, 0x08, 0x00, 0x0E,
},
#define TK_MAC_XCURSOR_sb_up_arrow 57
[TK_MAC_XCURSOR_sb_up_arrow] = {
0x00, 0x00, 0x00, 0x80, 0x01, 0xC0, 0x03, 0xE0, 0x07, 0xF0, 0x01, 0x40, 0x01, 0x40, 0x01, 0x40,
0x01, 0x40, 0x01, 0x40, 0x01, 0x40, 0x01, 0x40, 0x01, 0x40, 0x01, 0x40, 0x01, 0x40, 0x01, 0x40,
0x00, 0x80, 0x01, 0xC0, 0x03, 0xE0, 0x07, 0xF0, 0x0F, 0xF8, 0x01, 0xC0, 0x01, 0xC0, 0x01, 0xC0,
0x01, 0xC0, 0x01, 0xC0, 0x01, 0xC0, 0x01, 0xC0, 0x01, 0xC0, 0x01, 0xC0, 0x01, 0xC0, 0x01, 0xC0,
0x00, 0x01, 0x00, 0x08,
},
#define TK_MAC_XCURSOR_sb_v_double_arrow 58
[TK_MAC_XCURSOR_sb_v_double_arrow] = {
0x00, 0x00, 0x01, 0x00, 0x03, 0x80, 0x07, 0xC0, 0x0F, 0xE0, 0x02, 0x80, 0x02, 0x80, 0x02, 0x80,
0x02, 0x80, 0x02, 0x80, 0x02, 0x80, 0x0F, 0xE0, 0x07, 0xC0, 0x03, 0x80, 0x01, 0x00, 0x00, 0x00,
0x01, 0x00, 0x03, 0x80, 0x07, 0xC0, 0x0F, 0xE0, 0x1F, 0xF0, 0x03, 0x80, 0x03, 0x80, 0x03, 0x80,
0x03, 0x80, 0x03, 0x80, 0x03, 0x80, 0x1F, 0xF0, 0x0F, 0xE0, 0x07, 0xC0, 0x03, 0x80, 0x01, 0x00,
0x00, 0x07, 0x00, 0x07,
},
#define TK_MAC_XCURSOR_shuttle 59
[TK_MAC_XCURSOR_shuttle] = {
0x00, 0x20, 0x00, 0x70, 0x00, 0xF8, 0x01, 0xDE, 0x05, 0xDE, 0x09, 0xDE, 0x11, 0xDE, 0x11, 0xDE,
0x11, 0xDE, 0x11, 0xDE, 0x31, 0xDE, 0x71, 0xDE, 0xFD, 0xDE, 0x18, 0x88, 0x00, 0x78, 0x00, 0x30,
0x00, 0x20, 0x00, 0x70, 0x00, 0xF8, 0x01, 0xFE, 0x07, 0xFE, 0x0F, 0xFE, 0x1F, 0xFE, 0x1F, 0xFE,
0x1F, 0xFE, 0x1F, 0xFE, 0x3F, 0xFE, 0x7F, 0xFE, 0xFF, 0xFE, 0x18, 0xF8, 0x00, 0x78, 0x00, 0x30,
0x00, 0x00, 0x00, 0x0A,
},
#define TK_MAC_XCURSOR_sizing 60
[TK_MAC_XCURSOR_sizing] = {
0x00, 0x00, 0x7F, 0x80, 0x40, 0x00, 0x40, 0x00, 0x40, 0x00, 0x47, 0xE0, 0x44, 0x20, 0x44, 0x22,
0x44, 0x22, 0x04, 0x22, 0x07, 0xE2, 0x00, 0x12, 0x00, 0x0A, 0x00, 0x06, 0x01, 0xFE, 0x00, 0x00,
0xFF, 0xC0, 0xFF, 0xC0, 0xFF, 0xC0, 0xE0, 0x00, 0xEF, 0xF0, 0xEF, 0xF0, 0xEC, 0x37, 0xEC, 0x37,
0xEC, 0x37, 0xEC, 0x37, 0x0F, 0xF7, 0x0F, 0xFF, 0x00, 0x1F, 0x03, 0xFF, 0x03, 0xFF, 0x03, 0xFF,
0x00, 0x0E, 0x00, 0x0E,
},
#define TK_MAC_XCURSOR_spider 61
[TK_MAC_XCURSOR_spider] = {
0x20, 0x10, 0x10, 0x20, 0x10, 0x20, 0x08, 0x40, 0x08, 0x40, 0x87, 0x87, 0x67, 0x98, 0x1F, 0xE0,
0x1F, 0xE0, 0x67, 0x98, 0x87, 0x87, 0x08, 0x40, 0x08, 0x40, 0x10, 0x20, 0x10, 0x20, 0x20, 0x10,
0x70, 0x38, 0x38, 0x70, 0x38, 0x70, 0x1C, 0xE0, 0x9F, 0xE7, 0xEF, 0xDF, 0xFF, 0xFF, 0x7F, 0xF8,
0x7F, 0xF8, 0xFF, 0xFF, 0xEF, 0xDF, 0x9F, 0xE7, 0x1C, 0xE0, 0x38, 0x70, 0x38, 0x70, 0x70, 0x38,
0x00, 0x07, 0x00, 0x07,
},
#define TK_MAC_XCURSOR_spraycan 62
[TK_MAC_XCURSOR_spraycan] = {
0x00, 0x18, 0x00, 0x40, 0x0D, 0x18, 0x1E, 0x40, 0x1A, 0x18, 0x3F, 0x00, 0x21, 0x00, 0x39, 0x00,
0x29, 0x00, 0x39, 0x00, 0x29, 0x00, 0x39, 0x00, 0x39, 0x00, 0x21, 0x00, 0x21, 0x00, 0x3F, 0x00,
0x00, 0x18, 0x00, 0x40, 0x0D, 0x18, 0x1E, 0x40, 0x1E, 0x18, 0x3F, 0x00, 0x3F, 0x00, 0x3F, 0x00,
0x3F, 0x00, 0x3F, 0x00, 0x3F, 0x00, 0x3F, 0x00, 0x3F, 0x00, 0x3F, 0x00, 0x3F, 0x00, 0x3F, 0x00,
0x00, 0x02, 0x00, 0x07,
},
#define TK_MAC_XCURSOR_star 63
[TK_MAC_XCURSOR_star] = {
0x01, 0x00, 0x02, 0x80, 0x02, 0x80, 0x02, 0x80, 0x04, 0x40, 0x04, 0x40, 0x04, 0x40, 0x39, 0x38,
0xC0, 0x06, 0x38, 0x38, 0x09, 0x20, 0x12, 0x90, 0x24, 0x48, 0x28, 0x28, 0x30, 0x18, 0x20, 0x08,
0x01, 0x00, 0x03, 0x80, 0x03, 0x80, 0x03, 0x80, 0x07, 0xC0, 0x07, 0xC0, 0x07, 0xC0, 0x3F, 0xF8,
0xFF, 0xFE, 0x3F, 0xF8, 0x0F, 0xE0, 0x1E, 0xF0, 0x3C, 0x78, 0x38, 0x38, 0x30, 0x18, 0x20, 0x08,
0x00, 0x07, 0x00, 0x07,
},
#define TK_MAC_XCURSOR_target 64
[TK_MAC_XCURSOR_target] = {
0x00, 0x00, 0x03, 0x80, 0x0F, 0xE0, 0x1C, 0x70, 0x30, 0x18, 0x60, 0x0C, 0xC1, 0x06, 0xC2, 0x86,
0xC1, 0x06, 0x60, 0x0C, 0x30, 0x18, 0x1C, 0x70, 0x0F, 0xE0, 0x03, 0x80, 0x00, 0x00, 0x00, 0x00,
0x00, 0x00, 0x03, 0x80, 0x0F, 0xE0, 0x1F, 0xF0, 0x3C, 0x78, 0x70, 0x1C, 0xE3, 0x8E, 0xE3, 0x8E,
0xE3, 0x8E, 0x70, 0x1C, 0x3C, 0x78, 0x1F, 0xF0, 0x0F, 0xE0, 0x03, 0x80, 0x00, 0x00, 0x00, 0x00,
0x00, 0x07, 0x00, 0x07,
},
#define TK_MAC_XCURSOR_tcross 65
[TK_MAC_XCURSOR_tcross] = {
0x01, 0x00, 0x01, 0x00, 0x01, 0x00, 0x01, 0x00, 0x01, 0x00, 0x01, 0x00, 0x01, 0x00, 0xFF, 0xFE,
0x01, 0x00, 0x01, 0x00, 0x01, 0x00, 0x01, 0x00, 0x01, 0x00, 0x01, 0x00, 0x01, 0x00, 0x00, 0x00,
0x01, 0x00, 0x01, 0x00, 0x01, 0x00, 0x01, 0x00, 0x01, 0x00, 0x01, 0x00, 0x01, 0x00, 0xFF, 0xFE,
0x01, 0x00, 0x01, 0x00, 0x01, 0x00, 0x01, 0x00, 0x01, 0x00, 0x01, 0x00, 0x01, 0x00, 0x00, 0x00,
0x00, 0x07, 0x00, 0x07,
},
#define TK_MAC_XCURSOR_top_left_arrow 66
[TK_MAC_XCURSOR_top_left_arrow] = {
0x00, 0x00, 0x60, 0x00, 0x78, 0x00, 0x3E, 0x00, 0x3F, 0x80, 0x1F, 0xE0, 0x1E, 0x00, 0x0D, 0x00,
0x0C, 0x80, 0x04, 0x40, 0x04, 0x20, 0x00, 0x10, 0x00, 0x08, 0x00, 0x04, 0x00, 0x00, 0x00, 0x00,
0xE0, 0x00, 0xF8, 0x00, 0xFE, 0x00, 0x7F, 0x80, 0x7F, 0xE0, 0x3F, 0xF8, 0x3F, 0xFE, 0x1F, 0x80,
0x1F, 0xC0, 0x0E, 0xE0, 0x0E, 0x70, 0x06, 0x38, 0x06, 0x1C, 0x02, 0x0E, 0x02, 0x04, 0x00, 0x00,
0x00, 0x01, 0x00, 0x01,
},
#define TK_MAC_XCURSOR_top_left_corner 67
[TK_MAC_XCURSOR_top_left_corner] = {
0xFF, 0xF0, 0xFF, 0xF0, 0xC0, 0x00, 0xC0, 0x00, 0xCF, 0xC0, 0xCC, 0x00, 0xCA, 0x00, 0xC9, 0x00,
0xC8, 0x80, 0xC8, 0x40, 0xC0, 0x20, 0xC0, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00,
0xFF, 0xF0, 0xFF, 0xF0, 0xC0, 0x00, 0xC0, 0x00, 0xCF, 0xC0, 0xCC, 0x00, 0xCA, 0x00, 0xC9, 0x00,
0xC8, 0x80, 0xC8, 0x40, 0xC0, 0x20, 0xC0, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00,
0x00, 0x00, 0x00, 0x00,
},
#define TK_MAC_XCURSOR_top_right_corner 68
[TK_MAC_XCURSOR_top_right_corner] = {
0x0F, 0xFF, 0x0F, 0xFF, 0x00, 0x03, 0x00, 0x03, 0x03, 0xF3, 0x00, 0x33, 0x00, 0x53, 0x00, 0x93,
0x01, 0x13, 0x02, 0x13, 0x04, 0x03, 0x00, 0x03, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00,
0x0F, 0xFF, 0x0F, 0xFF, 0x00, 0x03, 0x00, 0x03, 0x03, 0xF3, 0x00, 0x33, 0x00, 0x53, 0x00, 0x93,
0x01, 0x13, 0x02, 0x13, 0x04, 0x03, 0x00, 0x03, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00,
0x00, 0x00, 0x00, 0x0F,
},
#define TK_MAC_XCURSOR_top_side 69
[TK_MAC_XCURSOR_top_side] = {
0x00, 0x00, 0x7F, 0xFC, 0x7F, 0xFC, 0x00, 0x00, 0x01, 0x00, 0x03, 0x80, 0x05, 0x40, 0x09, 0x20,
0x11, 0x10, 0x01, 0x00, 0x01, 0x00, 0x01, 0x00, 0x01, 0x00, 0x01, 0x00, 0x00, 0x00, 0x00, 0x00,
0x00, 0x00, 0x7F, 0xFC, 0x7F, 0xFC, 0x00, 0x00, 0x01, 0x00, 0x03, 0x80, 0x05, 0x40, 0x09, 0x20,
0x11, 0x10, 0x01, 0x00, 0x01, 0x00, 0x01, 0x00, 0x01, 0x00, 0x01, 0x00, 0x00, 0x00, 0x00, 0x00,
0x00, 0x04, 0x00, 0x07,
},
#define TK_MAC_XCURSOR_top_tee 70
[TK_MAC_XCURSOR_top_tee] = {
0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x7F, 0xFE, 0x7F, 0xFE, 0x01, 0x80, 0x01, 0x80,
0x01, 0x80, 0x01, 0x80, 0x01, 0x80, 0x01, 0x80, 0x01, 0x80, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00,
0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x7F, 0xFE, 0x7F, 0xFE, 0x01, 0x80, 0x01, 0x80,
0x01, 0x80, 0x01, 0x80, 0x01, 0x80, 0x01, 0x80, 0x01, 0x80, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00,
0x00, 0x04, 0x00, 0x07,
},
#define TK_MAC_XCURSOR_trek 71
[TK_MAC_XCURSOR_trek] = {
0x01, 0x00, 0x00, 0x00, 0x03, 0x80, 0x07, 0xC0, 0x0F, 0xE0, 0x0E, 0xE0, 0x0F, 0xE0, 0x07, 0xC0,
0x03, 0x80, 0x01, 0x00, 0x0B, 0xA0, 0x0D, 0x60, 0x09, 0x20, 0x08, 0x20, 0x08, 0x20, 0x00, 0x00,
0x01, 0x00, 0x03, 0x80, 0x07, 0xC0, 0x0F, 0xE0, 0x1F, 0xF0, 0x1F, 0xF0, 0x1F, 0xF0, 0x0F, 0xE0,
0x07, 0xC0, 0x0B, 0xA0, 0x1F, 0xF0, 0x1F, 0xF0, 0x1F, 0xF0, 0x1D, 0x70, 0x1C, 0x70, 0x08, 0x20,
0x00, 0x00, 0x00, 0x07,
},
#define TK_MAC_XCURSOR_ul_angle 72
[TK_MAC_XCURSOR_ul_angle] = {
0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x0F, 0xF8, 0x0F, 0xF8, 0x0C, 0x00, 0x0C, 0x00, 0x0C, 0x00,
0x0C, 0x00, 0x0C, 0x00, 0x0C, 0x00, 0x0C, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00,
0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x0F, 0xF8, 0x0F, 0xF8, 0x0C, 0x00, 0x0C, 0x00, 0x0C, 0x00,
0x0C, 0x00, 0x0C, 0x00, 0x0C, 0x00, 0x0C, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00,
0x00, 0x03, 0x00, 0x04,
},
#define TK_MAC_XCURSOR_umbrella 73
[TK_MAC_XCURSOR_umbrella] = {
0x00, 0x00, 0x08, 0x90, 0x02, 0x28, 0x49, 0xA6, 0x27, 0xC8, 0x19, 0x30, 0x61, 0x0C, 0x01, 0x00,
0x01, 0x00, 0x01, 0x00, 0x01, 0x00, 0x01, 0x00, 0x01, 0x40, 0x01, 0x40, 0x00, 0x80, 0x00, 0x00,
0x00, 0x00, 0x0F, 0xF0, 0x1F, 0xF8, 0x7F, 0xFE, 0x7F, 0xFC, 0xFF, 0xFE, 0xFB, 0xBE, 0xE3, 0x8E,
0x03, 0x80, 0x03, 0x80, 0x03, 0x80, 0x03, 0xC0, 0x03, 0xE0, 0x03, 0xE0, 0x01, 0xC0, 0x00, 0x80,
0x00, 0x04, 0x00, 0x07,
},
#define TK_MAC_XCURSOR_ur_angle 74
[TK_MAC_XCURSOR_ur_angle] = {
0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x1F, 0xF0, 0x1F, 0xF0, 0x00, 0x30, 0x00, 0x30,
0x00, 0x30, 0x00, 0x30, 0x00, 0x30, 0x00, 0x30, 0x00, 0x30, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00,
0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x1F, 0xF0, 0x1F, 0xF0, 0x00, 0x30, 0x00, 0x30,
0x00, 0x30, 0x00, 0x30, 0x00, 0x30, 0x00, 0x30, 0x00, 0x30, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00,
0x00, 0x04, 0x00, 0x0B,
},
#define TK_MAC_XCURSOR_watch 75
[TK_MAC_XCURSOR_watch] = {
0x07, 0xE0, 0x07, 0xE0, 0x07, 0xE0, 0x07, 0xE0, 0x08, 0x10, 0x10, 0x88, 0x10, 0x88, 0x10, 0x8C,
0x13, 0x8C, 0x10, 0x08, 0x10, 0x08, 0x08, 0x10, 0x07, 0xE0, 0x07, 0xE0, 0x07, 0xE0, 0x07, 0xE0,
0x07, 0xE0, 0x07, 0xE0, 0x07, 0xE0, 0x07, 0xE0, 0x0F, 0xF0, 0x1F, 0xF8, 0x1F, 0xF8, 0x1F, 0xFC,
0x1F, 0xFC, 0x1F, 0xF8, 0x1F, 0xF8, 0x0F, 0xF0, 0x07, 0xE0, 0x07, 0xE0, 0x07, 0xE0, 0x07, 0xE0,
0x00, 0x08, 0x00, 0x0D,
},
#define TK_MAC_XCURSOR_xterm 76
[TK_MAC_XCURSOR_xterm] = {
0x0C, 0x60, 0x02, 0x80, 0x01, 0x00, 0x01, 0x00, 0x01, 0x00, 0x01, 0x00, 0x01, 0x00, 0x01, 0x00,
0x01, 0x00, 0x01, 0x00, 0x01, 0x00, 0x01, 0x00, 0x01, 0x00, 0x01, 0x00, 0x02, 0x80, 0x0C, 0x60,
0x0C, 0x60, 0x02, 0x80, 0x01, 0x00, 0x01, 0x00, 0x01, 0x00, 0x01, 0x00, 0x01, 0x00, 0x01, 0x00,
0x01, 0x00, 0x01, 0x00, 0x01, 0x00, 0x01, 0x00, 0x01, 0x00, 0x01, 0x00, 0x02, 0x80, 0x0C, 0x60,
0x00, 0x0B, 0x00, 0x07,
},
};

1370
macosx/tkMacOSXXStubs.c Normal file

File diff suppressed because it is too large Load Diff

1203
macosx/ttkMacOSXTheme.c Normal file

File diff suppressed because it is too large Load Diff