summaryrefslogtreecommitdiffstats
path: root/win
diff options
context:
space:
mode:
authorjan.nijtmans <nijtmans@users.sourceforge.net>2020-04-06 14:52:51 (GMT)
committerjan.nijtmans <nijtmans@users.sourceforge.net>2020-04-06 14:52:51 (GMT)
commit62a467f50761835b22b455d6ff0105b2e4bbe4dd (patch)
tree2b25b3d22463500bc2914c1f4b3040efe4d78175 /win
parent982463151a49ce643a07e3db2b5a536b1be07ba0 (diff)
parentd0f56684e57c15c590975be1a7f608b170a3ee40 (diff)
downloadtk-62a467f50761835b22b455d6ff0105b2e4bbe4dd.zip
tk-62a467f50761835b22b455d6ff0105b2e4bbe4dd.tar.gz
tk-62a467f50761835b22b455d6ff0105b2e4bbe4dd.tar.bz2
Better implementation of TkUtfToUniChar(), one that doesn't require cooperation of Tcl (TCL_UTF_MAX>3). Just let Tk do the splitting of 4-byte UTF-8 sequences into surrogates.
Diffstat (limited to 'win')
-rw-r--r--win/Makefile.in19
-rwxr-xr-xwin/configure250
-rw-r--r--win/configure.in2
-rw-r--r--win/makefile.vc12
-rw-r--r--win/rules.vc45
-rw-r--r--win/tcl.m443
-rw-r--r--win/tkWin32Dll.c2
-rw-r--r--win/tkWinClipboard.c28
-rw-r--r--win/tkWinDialog.c209
-rw-r--r--win/tkWinFont.c98
-rw-r--r--win/tkWinInit.c15
-rw-r--r--win/tkWinInt.h1
-rw-r--r--win/tkWinKey.c78
-rw-r--r--win/tkWinMenu.c208
-rw-r--r--win/tkWinPointer.c19
-rw-r--r--win/tkWinSend.c39
-rw-r--r--win/tkWinSendCom.c67
-rw-r--r--win/tkWinTest.c65
-rw-r--r--win/tkWinWm.c294
-rw-r--r--win/tkWinX.c63
-rw-r--r--win/ttkWinXPTheme.c91
21 files changed, 889 insertions, 759 deletions
diff --git a/win/Makefile.in b/win/Makefile.in
index 59074aa..43f9c81 100644
--- a/win/Makefile.in
+++ b/win/Makefile.in
@@ -150,7 +150,7 @@ MAN2TCL = man2tcl$(EXEEXT)
# makefile to look into these paths when resolving .c to .obj
# dependencies.
-VPATH = $(GENERIC_DIR):$(TTK_DIR):$(WIN_DIR):$(UNIX_DIR):$(XLIB_DIR):$(RC_DIR)
+VPATH = $(GENERIC_DIR):$(TTK_DIR):$(WIN_DIR):$(XLIB_DIR):$(RC_DIR)
# warning flags
CFLAGS_WARNING = @CFLAGS_WARNING@
@@ -168,7 +168,7 @@ LDFLAGS_OPTIMIZE = @LDFLAGS_OPTIMIZE@
#CFLAGS = $(CFLAGS_DEBUG)
#CFLAGS = $(CFLAGS_OPTIMIZE)
#CFLAGS = $(CFLAGS_DEBUG) $(CFLAGS_OPTIMIZE)
-CFLAGS = @CFLAGS@ @CFLAGS_DEFAULT@ -DUNICODE -D_UNICODE -D_ATL_XP_TARGETING
+CFLAGS = @CFLAGS@ @CFLAGS_DEFAULT@ -D_ATL_XP_TARGETING
# Special compiler flags to use when building man2tcl on Windows.
MAN2TCLFLAGS = @MAN2TCLFLAGS@
@@ -630,7 +630,7 @@ ${TEST_DLL_FILE}: ${TKTEST_OBJS} ${TK_STUB_LIB_FILE}
$(TCL_SRC_DIR)/win/cat.c:
cat32.${OBJEXT}: $(TCL_SRC_DIR)/win/cat.c
- $(CC) -c $(CC_SWITCHES) "$(TCL_SRC_DIR)/win/cat.c" $(CC_OBJNAME)
+ $(CC) -c $(CC_SWITCHES) -DUNICODE -D_UNICODE "$(TCL_SRC_DIR)/win/cat.c" $(CC_OBJNAME)
$(CAT32): cat32.${OBJEXT}
$(CC) $(CFLAGS) cat32.$(OBJEXT) $(CC_EXENAME) $(LIBS) $(LDFLAGS_CONSOLE)
@@ -656,10 +656,10 @@ ${TK_LIB_FILE}: ${TK_OBJS}
# Special case object file targets
winMain.$(OBJEXT): winMain.c
- $(CC) -c $(CC_SWITCHES) @DEPARG@ $(CC_OBJNAME)
+ $(CC) -c $(CC_SWITCHES) -DUNICODE=1 -D_UNICODE=1 @DEPARG@ $(CC_OBJNAME)
testMain.$(OBJEXT): winMain.c
- $(CC) -c $(CC_SWITCHES) @DEPARG@ -DTK_TEST $(CC_OBJNAME)
+ $(CC) -c $(CC_SWITCHES) -DTK_TEST -DUNICODE=1 -D_UNICODE=1 @DEPARG@ $(CC_OBJNAME)
tkTest.$(OBJEXT): tkTest.c
$(CC) -c $(CC_SWITCHES) @DEPARG@ $(CC_OBJNAME)
@@ -674,11 +674,18 @@ tkSquare.$(OBJEXT): tkSquare.c
$(CC) -c $(CC_SWITCHES) @DEPARG@ $(CC_OBJNAME)
tkMain2.$(OBJEXT): tkMain.c
- $(CC) -c $(CC_SWITCHES) -DBUILD_tk -DTK_ASCII_MAIN @DEPARG@ $(CC_OBJNAME)
+ $(CC) -c $(CC_SWITCHES) -DBUILD_tk -DUNICODE=1 -D_UNICODE=1 @DEPARG@ $(CC_OBJNAME)
+
+tkUnixMenubu.$(OBJEXT): ${UNIX_DIR}/tkUnixMenubu.c
+ $(CC) -c $(CC_SWITCHES) -DBUILD_tk -DBUILD_ttk @DEPARG@ $(CC_OBJNAME)
+
+tkUnixScale.$(OBJEXT): ${UNIX_DIR}/tkUnixScale.c
+ $(CC) -c $(CC_SWITCHES) -DBUILD_tk -DBUILD_ttk @DEPARG@ $(CC_OBJNAME)
# Extra dependency info
tkConsole.$(OBJEXT): configure Makefile
tkMain.$(OBJEXT): configure Makefile
+tkMain2.$(OBJEXT): configure Makefile
tkWindow.$(OBJEXT): configure Makefile
# Add the object extension to the implicit rules. By default .obj is not
diff --git a/win/configure b/win/configure
index 123c664..cc28aa3 100755
--- a/win/configure
+++ b/win/configure
@@ -1312,7 +1312,7 @@ SHELL=/bin/sh
TK_VERSION=8.6
TK_MAJOR_VERSION=8
TK_MINOR_VERSION=6
-TK_PATCH_LEVEL=".9"
+TK_PATCH_LEVEL=".10"
VER=$TK_MAJOR_VERSION$TK_MINOR_VERSION
#------------------------------------------------------------------------
@@ -3311,78 +3311,6 @@ fi
# after SC_ENABLE_SHARED checks the configure switches.
#--------------------------------------------------------------------
-# On IRIX 5.3, sys/types and inttypes.h are conflicting.
-
-
-
-
-
-
-
-
-
-for ac_header in sys/types.h sys/stat.h stdlib.h string.h memory.h strings.h \
- inttypes.h stdint.h unistd.h
-do
-as_ac_Header=`echo "ac_cv_header_$ac_header" | $as_tr_sh`
-echo "$as_me:$LINENO: checking for $ac_header" >&5
-echo $ECHO_N "checking for $ac_header... $ECHO_C" >&6
-if eval "test \"\${$as_ac_Header+set}\" = set"; then
- echo $ECHO_N "(cached) $ECHO_C" >&6
-else
- cat >conftest.$ac_ext <<_ACEOF
-/* confdefs.h. */
-_ACEOF
-cat confdefs.h >>conftest.$ac_ext
-cat >>conftest.$ac_ext <<_ACEOF
-/* end confdefs.h. */
-$ac_includes_default
-
-#include <$ac_header>
-_ACEOF
-rm -f conftest.$ac_objext
-if { (eval echo "$as_me:$LINENO: \"$ac_compile\"") >&5
- (eval $ac_compile) 2>conftest.er1
- ac_status=$?
- grep -v '^ *+' conftest.er1 >conftest.err
- rm -f conftest.er1
- cat conftest.err >&5
- echo "$as_me:$LINENO: \$? = $ac_status" >&5
- (exit $ac_status); } &&
- { ac_try='test -z "$ac_c_werror_flag"
- || test ! -s conftest.err'
- { (eval echo "$as_me:$LINENO: \"$ac_try\"") >&5
- (eval $ac_try) 2>&5
- ac_status=$?
- echo "$as_me:$LINENO: \$? = $ac_status" >&5
- (exit $ac_status); }; } &&
- { ac_try='test -s conftest.$ac_objext'
- { (eval echo "$as_me:$LINENO: \"$ac_try\"") >&5
- (eval $ac_try) 2>&5
- ac_status=$?
- echo "$as_me:$LINENO: \$? = $ac_status" >&5
- (exit $ac_status); }; }; then
- eval "$as_ac_Header=yes"
-else
- echo "$as_me: failed program was:" >&5
-sed 's/^/| /' conftest.$ac_ext >&5
-
-eval "$as_ac_Header=no"
-fi
-rm -f conftest.err conftest.$ac_objext conftest.$ac_ext
-fi
-echo "$as_me:$LINENO: result: `eval echo '${'$as_ac_Header'}'`" >&5
-echo "${ECHO_T}`eval echo '${'$as_ac_Header'}'`" >&6
-if test `eval echo '${'$as_ac_Header'}'` = yes; then
- cat >>confdefs.h <<_ACEOF
-#define `echo "HAVE_$ac_header" | $as_tr_cpp` 1
-_ACEOF
-
-fi
-
-done
-
-
# Step 0: Enable 64 bit support?
@@ -3541,14 +3469,14 @@ echo "${ECHO_T}$ac_cv_cross" >&6
if test "$ac_cv_cross" = "yes"; then
case "$do64bit" in
amd64|x64|yes)
- CC="x86_64-w64-mingw32-gcc"
+ CC="x86_64-w64-mingw32-${CC}"
LD="x86_64-w64-mingw32-ld"
AR="x86_64-w64-mingw32-ar"
RANLIB="x86_64-w64-mingw32-ranlib"
RC="x86_64-w64-mingw32-windres"
;;
*)
- CC="i686-w64-mingw32-gcc"
+ CC="i686-w64-mingw32-${CC}"
LD="i686-w64-mingw32-ld"
AR="i686-w64-mingw32-ar"
RANLIB="i686-w64-mingw32-ranlib"
@@ -3797,10 +3725,19 @@ echo "$as_me: error: ${CC} does not support the -shared option.
CFLAGS_DEBUG=-g
CFLAGS_OPTIMIZE="-O2 -fomit-frame-pointer"
- CFLAGS_WARNING="-Wall -Wdeclaration-after-statement"
+ CFLAGS_WARNING="-Wall -Wpointer-arith"
LDFLAGS_DEBUG=
LDFLAGS_OPTIMIZE=
+ case "${CC}" in
+ *++)
+ CFLAGS_WARNING="${CFLAGS_WARNING} -Wno-format"
+ ;;
+ *)
+ CFLAGS_WARNING="${CFLAGS_WARNING} -Wdeclaration-after-statement"
+ ;;
+ esac
+
# Specify the CC output file names based on the target name
CC_OBJNAME="-o \$@"
CC_EXENAME="-o \$@"
@@ -3923,29 +3860,15 @@ echo "${ECHO_T}using shared flags" >&6
LIBSUFFIX="\${DBGX}.lib"
LIBFLAGSUFFIX="\${DBGX}"
- # This is a 2-stage check to make sure we have the 64-bit SDK
- # We have to know where the SDK is installed.
- # This magic is based on MS Platform SDK for Win2003 SP1 - hobbs
if test "$do64bit" != "no" ; then
- if test "x${MSSDK}x" = "xx" ; then
- MSSDK="C:/Progra~1/Microsoft Platform SDK"
- fi
- MSSDK=`echo "$MSSDK" | sed -e 's!\\\!/!g'`
- PATH64=""
case "$do64bit" in
amd64|x64|yes)
MACHINE="AMD64" ; # assume AMD64 as default 64-bit build
- PATH64="${MSSDK}/Bin/Win64/x86/AMD64"
;;
ia64)
MACHINE="IA64"
- PATH64="${MSSDK}/Bin/Win64"
;;
esac
- if test ! -d "${PATH64}" ; then
- { echo "$as_me:$LINENO: WARNING: Could not find 64-bit $MACHINE SDK" >&5
-echo "$as_me: WARNING: Could not find 64-bit $MACHINE SDK" >&2;}
- fi
echo "$as_me:$LINENO: result: Using 64-bit $MACHINE mode" >&5
echo "${ECHO_T} Using 64-bit $MACHINE mode" >&6
fi
@@ -3961,81 +3884,12 @@ echo "${ECHO_T} Using 64-bit $MACHINE mode" >&6
esac
if test "$do64bit" != "no" ; then
- # The space-based-path will work for the Makefile, but will
- # not work if AC_TRY_COMPILE is called. TEA has the
- # TEA_PATH_NOSPACE to avoid this issue.
- # Check if _WIN64 is already recognized, and if so we don't
- # need to modify CC.
- echo "$as_me:$LINENO: checking whether _WIN64 is declared" >&5
-echo $ECHO_N "checking whether _WIN64 is declared... $ECHO_C" >&6
-if test "${ac_cv_have_decl__WIN64+set}" = set; then
- echo $ECHO_N "(cached) $ECHO_C" >&6
-else
- cat >conftest.$ac_ext <<_ACEOF
-/* confdefs.h. */
-_ACEOF
-cat confdefs.h >>conftest.$ac_ext
-cat >>conftest.$ac_ext <<_ACEOF
-/* end confdefs.h. */
-$ac_includes_default
-int
-main ()
-{
-#ifndef _WIN64
- char *p = (char *) _WIN64;
-#endif
-
- ;
- return 0;
-}
-_ACEOF
-rm -f conftest.$ac_objext
-if { (eval echo "$as_me:$LINENO: \"$ac_compile\"") >&5
- (eval $ac_compile) 2>conftest.er1
- ac_status=$?
- grep -v '^ *+' conftest.er1 >conftest.err
- rm -f conftest.er1
- cat conftest.err >&5
- echo "$as_me:$LINENO: \$? = $ac_status" >&5
- (exit $ac_status); } &&
- { ac_try='test -z "$ac_c_werror_flag"
- || test ! -s conftest.err'
- { (eval echo "$as_me:$LINENO: \"$ac_try\"") >&5
- (eval $ac_try) 2>&5
- ac_status=$?
- echo "$as_me:$LINENO: \$? = $ac_status" >&5
- (exit $ac_status); }; } &&
- { ac_try='test -s conftest.$ac_objext'
- { (eval echo "$as_me:$LINENO: \"$ac_try\"") >&5
- (eval $ac_try) 2>&5
- ac_status=$?
- echo "$as_me:$LINENO: \$? = $ac_status" >&5
- (exit $ac_status); }; }; then
- ac_cv_have_decl__WIN64=yes
-else
- echo "$as_me: failed program was:" >&5
-sed 's/^/| /' conftest.$ac_ext >&5
-
-ac_cv_have_decl__WIN64=no
-fi
-rm -f conftest.err conftest.$ac_objext conftest.$ac_ext
-fi
-echo "$as_me:$LINENO: result: $ac_cv_have_decl__WIN64" >&5
-echo "${ECHO_T}$ac_cv_have_decl__WIN64" >&6
-if test $ac_cv_have_decl__WIN64 = yes; then
- :
-else
- CC="\"${PATH64}/cl.exe\" -I\"${MSSDK}/Include\" \
- -I\"${MSSDK}/Include/crt\" \
- -I\"${MSSDK}/Include/crt/sys\""
-fi
-
- RC="\"${MSSDK}/bin/rc.exe\""
+ RC="rc"
CFLAGS_DEBUG="-nologo -Zi -Od ${runtime}d"
# Do not use -O2 for Win64 - this has proved buggy in code gen.
CFLAGS_OPTIMIZE="-nologo -O1 ${runtime}"
- lflags="${lflags} -nologo -MACHINE:${MACHINE} -LIBPATH:\"${MSSDK}/Lib/${MACHINE}\""
- LINKBIN="\"${PATH64}/link.exe\""
+ lflags="${lflags} -nologo -MACHINE:${MACHINE}"
+ LINKBIN="link"
# Avoid 'unresolved external symbol __security_cookie' errors.
# c.f. http://support.microsoft.com/?id=894573
LIBS="$LIBS bufferoverflowU.lib"
@@ -4497,6 +4351,78 @@ _ACEOF
# man2tcl needs this so that it can use errno.h
#--------------------------------------------------------------------
+# On IRIX 5.3, sys/types and inttypes.h are conflicting.
+
+
+
+
+
+
+
+
+
+for ac_header in sys/types.h sys/stat.h stdlib.h string.h memory.h strings.h \
+ inttypes.h stdint.h unistd.h
+do
+as_ac_Header=`echo "ac_cv_header_$ac_header" | $as_tr_sh`
+echo "$as_me:$LINENO: checking for $ac_header" >&5
+echo $ECHO_N "checking for $ac_header... $ECHO_C" >&6
+if eval "test \"\${$as_ac_Header+set}\" = set"; then
+ echo $ECHO_N "(cached) $ECHO_C" >&6
+else
+ cat >conftest.$ac_ext <<_ACEOF
+/* confdefs.h. */
+_ACEOF
+cat confdefs.h >>conftest.$ac_ext
+cat >>conftest.$ac_ext <<_ACEOF
+/* end confdefs.h. */
+$ac_includes_default
+
+#include <$ac_header>
+_ACEOF
+rm -f conftest.$ac_objext
+if { (eval echo "$as_me:$LINENO: \"$ac_compile\"") >&5
+ (eval $ac_compile) 2>conftest.er1
+ ac_status=$?
+ grep -v '^ *+' conftest.er1 >conftest.err
+ rm -f conftest.er1
+ cat conftest.err >&5
+ echo "$as_me:$LINENO: \$? = $ac_status" >&5
+ (exit $ac_status); } &&
+ { ac_try='test -z "$ac_c_werror_flag"
+ || test ! -s conftest.err'
+ { (eval echo "$as_me:$LINENO: \"$ac_try\"") >&5
+ (eval $ac_try) 2>&5
+ ac_status=$?
+ echo "$as_me:$LINENO: \$? = $ac_status" >&5
+ (exit $ac_status); }; } &&
+ { ac_try='test -s conftest.$ac_objext'
+ { (eval echo "$as_me:$LINENO: \"$ac_try\"") >&5
+ (eval $ac_try) 2>&5
+ ac_status=$?
+ echo "$as_me:$LINENO: \$? = $ac_status" >&5
+ (exit $ac_status); }; }; then
+ eval "$as_ac_Header=yes"
+else
+ echo "$as_me: failed program was:" >&5
+sed 's/^/| /' conftest.$ac_ext >&5
+
+eval "$as_ac_Header=no"
+fi
+rm -f conftest.err conftest.$ac_objext conftest.$ac_ext
+fi
+echo "$as_me:$LINENO: result: `eval echo '${'$as_ac_Header'}'`" >&5
+echo "${ECHO_T}`eval echo '${'$as_ac_Header'}'`" >&6
+if test `eval echo '${'$as_ac_Header'}'` = yes; then
+ cat >>confdefs.h <<_ACEOF
+#define `echo "HAVE_$ac_header" | $as_tr_cpp` 1
+_ACEOF
+
+fi
+
+done
+
+
if test "${ac_cv_header_errno_h+set}" = set; then
echo "$as_me:$LINENO: checking for errno.h" >&5
echo $ECHO_N "checking for errno.h... $ECHO_C" >&6
diff --git a/win/configure.in b/win/configure.in
index 167fd3d..e745000 100644
--- a/win/configure.in
+++ b/win/configure.in
@@ -14,7 +14,7 @@ SHELL=/bin/sh
TK_VERSION=8.6
TK_MAJOR_VERSION=8
TK_MINOR_VERSION=6
-TK_PATCH_LEVEL=".9"
+TK_PATCH_LEVEL=".10"
VER=$TK_MAJOR_VERSION$TK_MINOR_VERSION
#------------------------------------------------------------------------
diff --git a/win/makefile.vc b/win/makefile.vc
index 1008751..fda0ff2 100644
--- a/win/makefile.vc
+++ b/win/makefile.vc
@@ -306,8 +306,8 @@ PRJ_INCLUDES = -I"$(BITMAPDIR)" -I"$(XLIBDIR)"
CONFIG_DEFS =/DSTDC_HEADERS=1 /DHAVE_SYS_TYPES_H=1 /DHAVE_SYS_STAT_H=1 \
/DHAVE_STDLIB_H=1 /DHAVE_STRING_H=1 /DHAVE_MEMORY_H=1 \
- /DHAVE_STRINGS_H=1 /DHAVE_INTTYPES_H=1 /DHAVE_STDINT_H=1 \
- /DSUPPORT_CONFIG_EMBEDDED /DUNICODE /D_UNICODE \
+ /DHAVE_STRINGS_H=1 \
+ /DSUPPORT_CONFIG_EMBEDDED \
!if $(HAVE_UXTHEME_H)
/DHAVE_UXTHEME_H=1 \
!endif
@@ -455,7 +455,7 @@ $(TKTEST): $(TKTESTOBJS) $(TKSTUBLIB) $(TKIMPLIB)
$(CAT32): $(_TCLDIR)\win\cat.c
- $(cc32) $(cflags) $(crt) /D_CRT_NONSTDC_NO_DEPRECATE /DCONSOLE -Fo$(TMP_DIR)\ $?
+ $(cc32) $(cflags) $(crt) /D_CRT_NONSTDC_NO_DEPRECATE /DCONSOLE /DUNICODE /D_UNICODE -Fo$(TMP_DIR)\ $?
$(CONEXECMD) /DCONSOLE -stack:16384 $(TMP_DIR)\cat.obj
$(_VC_MANIFEST_EMBED_EXE)
@@ -531,7 +531,7 @@ install-pdbs:
#---------------------------------------------------------------------
$(TMP_DIR)\testMain.obj: $(WIN_DIR)\winMain.c
- $(cc32) $(appcflags_nostubs) /DTK_TEST \
+ $(cc32) $(appcflags_nostubs) /DTK_TEST /DUNICODE /D_UNICODE \
/DTCL_USE_STATIC_PACKAGES=$(TCL_USE_STATIC_PACKAGES) \
-Fo$@ $?
@@ -548,12 +548,12 @@ $(TMP_DIR)\tkSquare.obj: $(GENERICDIR)\tkSquare.c
$(cc32) $(appcflags_nostubs) -Fo$@ $?
$(TMP_DIR)\winMain.obj: $(WIN_DIR)\winMain.c
- $(cc32) $(appcflags_nostubs) \
+ $(cc32) $(appcflags_nostubs) /DUNICODE /D_UNICODE \
/DTCL_USE_STATIC_PACKAGES=$(TCL_USE_STATIC_PACKAGES) \
-Fo$@ $?
$(TMP_DIR)\tkMain2.obj: $(GENERICDIR)\tkMain.c
- $(cc32) $(pkgcflags) /DTK_ASCII_MAIN -Fo$@ $?
+ $(cc32) $(pkgcflags) /DUNICODE /D_UNICODE -Fo$@ $?
# The following objects are part of the stub library and should not
# be built as DLL objects but none of the symbols should be exported
diff --git a/win/rules.vc b/win/rules.vc
index cf80c91..872b3a0 100644
--- a/win/rules.vc
+++ b/win/rules.vc
@@ -24,7 +24,7 @@ _RULES_VC = 1
# For modifications that are not backward-compatible, you *must* change
# the major version.
RULES_VERSION_MAJOR = 1
-RULES_VERSION_MINOR = 4
+RULES_VERSION_MINOR = 6
# The PROJECT macro must be defined by parent makefile.
!if "$(PROJECT)" == ""
@@ -686,6 +686,7 @@ LINKERFLAGS = $(LINKERFLAGS) -ltcg
# configuration (ignored for Tcl itself)
# _USE_64BIT_TIME_T - forces a build using 64-bit time_t for 32-bit build
# (CRT library should support this)
+# TCL_UTF_MAX=4 - forces a build allowing 4-byte UTF-8 sequences internally.
# Further, LINKERFLAGS are modified based on above.
# Default values for all the above
@@ -750,7 +751,7 @@ TCL_USE_STATIC_PACKAGES = 0
TCL_THREADS = 0
USE_THREAD_ALLOC= 0
!else
-TCL_THREADS = 1
+TCL_THREADS = 1
USE_THREAD_ALLOC= 1
!endif
@@ -759,6 +760,11 @@ USE_THREAD_ALLOC= 1
_USE_64BIT_TIME_T = 1
!endif
+!if [nmakehlp -f $(OPTS) "utfmax"]
+!message *** Force allowing 4-byte UTF-8 sequences internally
+TCL_UTF_MAX = 4
+!endif
+
# Yes, it's weird that the "symbols" option controls DEBUG and
# the "pdbs" option controls SYMBOLS. That's historical.
!if [nmakehlp -f $(OPTS) "symbols"]
@@ -985,6 +991,19 @@ VERSION = $(DOTVERSION:.=)
!endif # $(DOING_TCL) ... etc.
+# Windows RC files have 3 version components. Ensure this irrespective
+# of how many components the package has specified. Basically, ensure
+# minimum 4 components by appending 4 0's and then pick out the first 4.
+# Also take care of the fact that DOTVERSION may have "a" or "b" instead
+# of "." separating the version components.
+DOTSEPARATED=$(DOTVERSION:a=.)
+DOTSEPARATED=$(DOTSEPARATED:b=.)
+!if [echo RCCOMMAVERSION = \> versions.vc] \
+ || [for /f "tokens=1,2,3,4,5* delims=." %a in ("$(DOTSEPARATED).0.0.0.0") do echo %a,%b,%c,%d >> versions.vc]
+!error *** Could not generate RCCOMMAVERSION ***
+!endif
+!include versions.vc
+
################################################################
# 10. Construct output directory and file paths
# Figure-out how to name our intermediate and output directories.
@@ -1278,6 +1297,14 @@ INCLUDE_INSTALL_DIR = $(_INSTALLDIR)\..\include
# define PRJ_LIBS before including rules.rc if additional libs are needed
OPTDEFINES = /DTCL_CFGVAL_ENCODING=$(CFG_ENCODING) /DSTDC_HEADERS
+!if $(VCVERSION) >= 1600
+OPTDEFINES = $(OPTDEFINES) /DHAVE_STDINT_H=1
+!else
+OPTDEFINES = $(OPTDEFINES) /DMP_NO_STDINT=1
+!endif
+!if $(VCVERSION) >= 1800
+OPTDEFINES = $(OPTDEFINES) /DHAVE_INTTYPES_H=1 /DHAVE_STDBOOL_H=1
+!endif
!if $(TCL_MEM_DEBUG)
OPTDEFINES = $(OPTDEFINES) /DTCL_MEM_DEBUG
@@ -1293,6 +1320,11 @@ OPTDEFINES = $(OPTDEFINES) /DUSE_THREAD_ALLOC=1
!endif
!if $(STATIC_BUILD)
OPTDEFINES = $(OPTDEFINES) /DSTATIC_BUILD
+!elseif $(TCL_VERSION) > 86
+OPTDEFINES = $(OPTDEFINES) /DTCL_WITH_EXTERNAL_TOMMATH
+!if "$(MACHINE)" == "AMD64"
+OPTDEFINES = $(OPTDEFINES) /DMP_64BIT
+!endif
!endif
!if $(TCL_NO_DEPRECATED)
OPTDEFINES = $(OPTDEFINES) /DTCL_NO_DEPRECATED
@@ -1322,11 +1354,14 @@ OPTDEFINES = $(OPTDEFINES) /DTCL_CFG_PROFILED
OPTDEFINES = $(OPTDEFINES) /DTCL_CFG_DO64BIT
!endif
!if $(VCVERSION) < 1300
-OPTDEFINES = $(OPTDEFINES) /DNO_STRTOI64
+OPTDEFINES = $(OPTDEFINES) /DNO_STRTOI64=1
!endif
!if "$(_USE_64BIT_TIME_T)" == "1"
-OPTDEFINES = $(OPTDEFINES) /D_USE_64BIT_TIME_T
+OPTDEFINES = $(OPTDEFINES) /D_USE_64BIT_TIME_T=1
+!endif
+!if "$(TCL_UTF_MAX)" == "4"
+OPTDEFINES = $(OPTDEFINES) /DTCL_UTF_MAX=4
!endif
# _ATL_XP_TARGETING - Newer SDK's need this to build for XP
@@ -1508,7 +1543,7 @@ GUIEXECMD = $(link32) $(guilflags) -out:$@ $(baselibs) $(tcllibs) $(tklibs)
RESCMD = $(rc32) -fo $@ -r -i "$(GENERICDIR)" -i "$(TMP_DIR)" \
$(TCL_INCLUDES) \
/DDEBUG=$(DEBUG) -d UNCHECKED=$(UNCHECKED) \
- /DCOMMAVERSION=$(DOTVERSION:.=,),0 \
+ /DCOMMAVERSION=$(RCCOMMAVERSION) \
/DDOTVERSION=\"$(DOTVERSION)\" \
/DVERSION=\"$(VERSION)\" \
/DSUFX=\"$(SUFX)\" \
diff --git a/win/tcl.m4 b/win/tcl.m4
index 84f0dff..c62af68 100644
--- a/win/tcl.m4
+++ b/win/tcl.m4
@@ -583,14 +583,14 @@ AC_DEFUN([SC_CONFIG_CFLAGS], [
if test "$ac_cv_cross" = "yes"; then
case "$do64bit" in
amd64|x64|yes)
- CC="x86_64-w64-mingw32-gcc"
+ CC="x86_64-w64-mingw32-${CC}"
LD="x86_64-w64-mingw32-ld"
AR="x86_64-w64-mingw32-ar"
RANLIB="x86_64-w64-mingw32-ranlib"
RC="x86_64-w64-mingw32-windres"
;;
*)
- CC="i686-w64-mingw32-gcc"
+ CC="i686-w64-mingw32-${CC}"
LD="i686-w64-mingw32-ld"
AR="i686-w64-mingw32-ar"
RANLIB="i686-w64-mingw32-ranlib"
@@ -727,10 +727,19 @@ AC_DEFUN([SC_CONFIG_CFLAGS], [
CFLAGS_DEBUG=-g
CFLAGS_OPTIMIZE="-O2 -fomit-frame-pointer"
- CFLAGS_WARNING="-Wall -Wdeclaration-after-statement"
+ CFLAGS_WARNING="-Wall -Wpointer-arith"
LDFLAGS_DEBUG=
LDFLAGS_OPTIMIZE=
+ case "${CC}" in
+ *++)
+ CFLAGS_WARNING="${CFLAGS_WARNING} -Wno-format"
+ ;;
+ *)
+ CFLAGS_WARNING="${CFLAGS_WARNING} -Wdeclaration-after-statement"
+ ;;
+ esac
+
# Specify the CC output file names based on the target name
CC_OBJNAME="-o \[$]@"
CC_EXENAME="-o \[$]@"
@@ -806,28 +815,15 @@ AC_DEFUN([SC_CONFIG_CFLAGS], [
LIBSUFFIX="\${DBGX}.lib"
LIBFLAGSUFFIX="\${DBGX}"
- # This is a 2-stage check to make sure we have the 64-bit SDK
- # We have to know where the SDK is installed.
- # This magic is based on MS Platform SDK for Win2003 SP1 - hobbs
if test "$do64bit" != "no" ; then
- if test "x${MSSDK}x" = "xx" ; then
- MSSDK="C:/Progra~1/Microsoft Platform SDK"
- fi
- MSSDK=`echo "$MSSDK" | sed -e 's!\\\!/!g'`
- PATH64=""
case "$do64bit" in
amd64|x64|yes)
MACHINE="AMD64" ; # assume AMD64 as default 64-bit build
- PATH64="${MSSDK}/Bin/Win64/x86/AMD64"
;;
ia64)
MACHINE="IA64"
- PATH64="${MSSDK}/Bin/Win64"
;;
esac
- if test ! -d "${PATH64}" ; then
- AC_MSG_WARN([Could not find 64-bit $MACHINE SDK])
- fi
AC_MSG_RESULT([ Using 64-bit $MACHINE mode])
fi
@@ -842,21 +838,12 @@ AC_DEFUN([SC_CONFIG_CFLAGS], [
esac
if test "$do64bit" != "no" ; then
- # The space-based-path will work for the Makefile, but will
- # not work if AC_TRY_COMPILE is called. TEA has the
- # TEA_PATH_NOSPACE to avoid this issue.
- # Check if _WIN64 is already recognized, and if so we don't
- # need to modify CC.
- AC_CHECK_DECL([_WIN64], [],
- [CC="\"${PATH64}/cl.exe\" -I\"${MSSDK}/Include\" \
- -I\"${MSSDK}/Include/crt\" \
- -I\"${MSSDK}/Include/crt/sys\""])
- RC="\"${MSSDK}/bin/rc.exe\""
+ RC="rc"
CFLAGS_DEBUG="-nologo -Zi -Od ${runtime}d"
# Do not use -O2 for Win64 - this has proved buggy in code gen.
CFLAGS_OPTIMIZE="-nologo -O1 ${runtime}"
- lflags="${lflags} -nologo -MACHINE:${MACHINE} -LIBPATH:\"${MSSDK}/Lib/${MACHINE}\""
- LINKBIN="\"${PATH64}/link.exe\""
+ lflags="${lflags} -nologo -MACHINE:${MACHINE}"
+ LINKBIN="link"
# Avoid 'unresolved external symbol __security_cookie' errors.
# c.f. http://support.microsoft.com/?id=894573
LIBS="$LIBS bufferoverflowU.lib"
diff --git a/win/tkWin32Dll.c b/win/tkWin32Dll.c
index 3c3d83a..88b0507 100644
--- a/win/tkWin32Dll.c
+++ b/win/tkWin32Dll.c
@@ -150,7 +150,7 @@ DllMain(
* Call TkFinalize
*/
- "movq $0x0, 0x0(%%esp)" "\n\t"
+ "movq $0x0, 0x0(%%rsp)" "\n\t"
"call TkFinalize" "\n\t"
/*
diff --git a/win/tkWinClipboard.c b/win/tkWinClipboard.c
index 8886f2a..bcea1c1 100644
--- a/win/tkWinClipboard.c
+++ b/win/tkWinClipboard.c
@@ -78,8 +78,9 @@ TkSelGetSelection(
CloseClipboard();
goto error;
}
- data = GlobalLock(handle);
- Tcl_WinTCharToUtf((LPCTSTR)data, -1, &ds);
+ data = (char *)GlobalLock(handle);
+ Tcl_DStringInit(&ds);
+ Tcl_WCharToUtfDString((WCHAR *)data, wcslen((WCHAR *)data), &ds);
GlobalUnlock(handle);
} else if (IsClipboardFormatAvailable(CF_TEXT)) {
/*
@@ -100,7 +101,7 @@ TkSelGetSelection(
Tcl_DStringInit(&ds);
Tcl_DStringAppend(&ds, "cp######", -1);
- data = GlobalLock(handle);
+ data = (char *)GlobalLock(handle);
/*
* Even though the documentation claims that GetLocaleInfo expects
@@ -130,7 +131,7 @@ TkSelGetSelection(
CloseClipboard();
goto error;
}
- data = GlobalLock(handle);
+ data = (char *)GlobalLock(handle);
Tcl_ExternalToUtfDString(encoding, data, -1, &ds);
GlobalUnlock(handle);
if (encoding) {
@@ -157,7 +158,8 @@ TkSelGetSelection(
Tcl_DStringAppend(&ds, "\n", 1);
}
len = wcslen(fname);
- Tcl_WinTCharToUtf((LPCTSTR)fname, len * sizeof(WCHAR), &dsTmp);
+ Tcl_DStringInit(&dsTmp);
+ Tcl_WCharToUtfDString(fname, len, &dsTmp);
Tcl_DStringAppend(&ds, Tcl_DStringValue(&dsTmp),
Tcl_DStringLength(&dsTmp));
Tcl_DStringFree(&dsTmp);
@@ -232,6 +234,8 @@ XSetSelectionOwner(
{
HWND hwnd = owner ? TkWinGetHWND(owner) : NULL;
Tk_Window tkwin;
+ (void)display;
+ (void)time;
/*
* This is a gross hack because the Tk_InternAtom interface is broken. It
@@ -281,6 +285,7 @@ TkWinClipboardRender(
char *buffer, *p, *rawText, *endPtr;
int length;
Tcl_DString ds;
+ (void)format;
for (targetPtr = dispPtr->clipTargetPtr; targetPtr != NULL;
targetPtr = targetPtr->nextPtr) {
@@ -312,7 +317,7 @@ TkWinClipboardRender(
* Copy the data and change EOL characters.
*/
- buffer = rawText = ckalloc(length + 1);
+ buffer = rawText = (char *)ckalloc(length + 1);
if (targetPtr != NULL) {
for (cbPtr = targetPtr->firstBufferPtr; cbPtr != NULL;
cbPtr = cbPtr->nextPtr) {
@@ -328,7 +333,7 @@ TkWinClipboardRender(
*buffer = '\0';
Tcl_DStringInit(&ds);
- Tcl_WinUtfToTChar(rawText, -1, &ds);
+ Tcl_UtfToWCharDString(rawText, -1, &ds);
ckfree(rawText);
handle = GlobalAlloc(GMEM_MOVEABLE|GMEM_DDESHARE,
Tcl_DStringLength(&ds) + 2);
@@ -336,7 +341,7 @@ TkWinClipboardRender(
Tcl_DStringFree(&ds);
return;
}
- buffer = GlobalLock(handle);
+ buffer = (char *)GlobalLock(handle);
memcpy(buffer, Tcl_DStringValue(&ds),
Tcl_DStringLength(&ds) + 2);
GlobalUnlock(handle);
@@ -367,6 +372,8 @@ TkSelUpdateClipboard(
TkClipboardTarget *targetPtr)
{
HWND hwnd = TkWinGetHWND(winPtr->window);
+ (void)targetPtr;
+
UpdateClipboard(hwnd);
}
@@ -419,7 +426,7 @@ UpdateClipboard(
void
TkSelEventProc(
Tk_Window tkwin, /* Window for which event was targeted. */
- register XEvent *eventPtr) /* X event: either SelectionClear,
+ XEvent *eventPtr) /* X event: either SelectionClear,
* SelectionRequest, or SelectionNotify. */
{
if (eventPtr->type == SelectionClear) {
@@ -446,8 +453,9 @@ TkSelEventProc(
void
TkSelPropProc(
- register XEvent *eventPtr) /* X PropertyChange event. */
+ XEvent *eventPtr) /* X PropertyChange event. */
{
+ (void)eventPtr;
}
/*
diff --git a/win/tkWinDialog.c b/win/tkWinDialog.c
index ab57ea5..3702efa 100644
--- a/win/tkWinDialog.c
+++ b/win/tkWinDialog.c
@@ -423,7 +423,7 @@ typedef struct IFileSaveDialogVtbl {
ULONG ( STDMETHODCALLTYPE *Release )( IFileSaveDialog *);
HRESULT ( STDMETHODCALLTYPE *Show )(
IFileSaveDialog *, HWND);
- HRESULT ( STDMETHODCALLTYPE *SetFileTypes )( IFileSaveDialog * this,
+ HRESULT ( STDMETHODCALLTYPE *SetFileTypes )( IFileSaveDialog *,
UINT, const TCLCOMDLG_FILTERSPEC *);
HRESULT ( STDMETHODCALLTYPE *SetFileTypeIndex )(
IFileSaveDialog *, UINT);
@@ -589,8 +589,7 @@ static UINT APIENTRY OFNHookProc(HWND hdlg, UINT uMsg, WPARAM wParam,
LPARAM lParam);
static LRESULT CALLBACK MsgBoxCBTProc(int nCode, WPARAM wParam, LPARAM lParam);
static void SetTkDialog(ClientData clientData);
-static const char *ConvertExternalFilename(WCHAR *filename,
- Tcl_DString *dsPtr);
+static const char *ConvertExternalFilename(LPCWSTR, Tcl_DString *);
static void LoadShellProcs(void);
@@ -630,20 +629,21 @@ struct ShellProcPointers {
* ShellProcs is populated.
*-------------------------------------------------------------------------
*/
-static void LoadShellProcs()
+static void LoadShellProcs(void)
{
static HMODULE shell32_handle = NULL;
- if (shell32_handle != NULL)
- return; /* We have already been through here. */
+ if (shell32_handle != NULL) {
+ return; /* We have already been through here. */
+ }
shell32_handle = GetModuleHandleW(L"shell32.dll");
- if (shell32_handle == NULL) /* Should never happen but check anyways. */
- return;
+ if (shell32_handle == NULL) { /* Should never happen but check anyways. */
+ return;
+ }
- ShellProcs.SHCreateItemFromParsingName =
- (SHCreateItemFromParsingNameProc*) GetProcAddress(shell32_handle,
- "SHCreateItemFromParsingName");
+ ShellProcs.SHCreateItemFromParsingName = (SHCreateItemFromParsingNameProc*)
+ (void *)GetProcAddress(shell32_handle, "SHCreateItemFromParsingName");
}
@@ -719,7 +719,7 @@ void
TkWinDialogDebug(
int debug)
{
- ThreadSpecificData *tsdPtr =
+ ThreadSpecificData *tsdPtr = (ThreadSpecificData *)
Tcl_GetThreadData(&dataKey, sizeof(ThreadSpecificData));
tsdPtr->debugFlag = debug;
@@ -751,7 +751,7 @@ Tk_ChooseColorObjCmd(
int objc, /* Number of arguments. */
Tcl_Obj *const objv[]) /* Argument objects. */
{
- Tk_Window tkwin = clientData, parent;
+ Tk_Window tkwin = (Tk_Window)clientData, parent;
HWND hWnd;
int i, oldMode, winCode, result;
CHOOSECOLORW chooseColor;
@@ -789,7 +789,7 @@ Tk_ChooseColorObjCmd(
chooseColor.lpCustColors = dwCustColors;
chooseColor.Flags = CC_RGBINIT | CC_FULLOPEN | CC_ENABLEHOOK;
chooseColor.lCustData = (LPARAM) NULL;
- chooseColor.lpfnHook = (LPOFNHOOKPROC) ColorDlgHookProc;
+ chooseColor.lpfnHook = (LPOFNHOOKPROC)(void *)ColorDlgHookProc;
chooseColor.lpTemplateName = (LPWSTR) interp;
for (i = 1; i < objc; i += 2) {
@@ -905,10 +905,11 @@ ColorDlgHookProc(
WPARAM wParam, /* First message parameter. */
LPARAM lParam) /* Second message parameter. */
{
- ThreadSpecificData *tsdPtr =
+ ThreadSpecificData *tsdPtr = (ThreadSpecificData *)
Tcl_GetThreadData(&dataKey, sizeof(ThreadSpecificData));
const char *title;
CHOOSECOLOR *ccPtr;
+ (void)wParam;
if (WM_INITDIALOG == uMsg) {
@@ -922,7 +923,8 @@ ColorDlgHookProc(
if ((title != NULL) && (title[0] != '\0')) {
Tcl_DString ds;
- SetWindowTextW(hDlg, (LPCWSTR)Tcl_WinUtfToTChar(title,-1,&ds));
+ Tcl_DStringInit(&ds);
+ SetWindowTextW(hDlg, Tcl_UtfToWCharDString(title, -1, &ds));
Tcl_DStringFree(&ds);
}
if (tsdPtr->debugFlag) {
@@ -1085,7 +1087,7 @@ ParseOFNOptions(
ZeroMemory(optsPtr, sizeof(*optsPtr));
// optsPtr->forceXPStyle = 1;
- optsPtr->tkwin = clientData;
+ optsPtr->tkwin = (Tk_Window)clientData;
optsPtr->confirmOverwrite = 1; /* By default we ask for confirmation */
Tcl_DStringInit(&optsPtr->utfDirString);
optsPtr->file[0] = 0;
@@ -1146,7 +1148,7 @@ ParseOFNOptions(
Tcl_DStringFree(&ds);
break;
case FILE_PARENT:
- optsPtr->tkwin = Tk_NameToWindow(interp, string, clientData);
+ optsPtr->tkwin = Tk_NameToWindow(interp, string, (Tk_Window)clientData);
if (optsPtr->tkwin == NULL)
goto error_return;
break;
@@ -1201,11 +1203,11 @@ error_return: /* interp should already hold error */
* If new dialogs are available, COM is also initialized.
*----------------------------------------------------------------------
*/
-static int VistaFileDialogsAvailable()
+static int VistaFileDialogsAvailable(void)
{
HRESULT hr;
IFileDialog *fdlgPtr = NULL;
- ThreadSpecificData *tsdPtr =
+ ThreadSpecificData *tsdPtr = (ThreadSpecificData *)
Tcl_GetThreadData(&dataKey, sizeof(ThreadSpecificData));
if (tsdPtr->newFileDialogsState == FDLG_STATE_INIT) {
@@ -1267,7 +1269,7 @@ static int GetFileNameVista(Tcl_Interp *interp, OFNOpts *optsPtr,
IShellItem *dirIf = NULL;
LPWSTR wstr;
Tcl_Obj *resultObj = NULL;
- ThreadSpecificData *tsdPtr =
+ ThreadSpecificData *tsdPtr = (ThreadSpecificData *)
Tcl_GetThreadData(&dataKey, sizeof(ThreadSpecificData));
int oldMode;
@@ -1371,8 +1373,9 @@ static int GetFileNameVista(Tcl_Interp *interp, OFNOpts *optsPtr,
const char *src;
src = Tcl_GetString(optsPtr->extObj);
- wstr = (LPWSTR) Tcl_WinUtfToTChar(src, optsPtr->extObj->length, &ds);
- if (wstr[0] == L'.')
+ Tcl_DStringInit(&ds);
+ wstr = Tcl_UtfToWCharDString(src, optsPtr->extObj->length, &ds);
+ if (wstr[0] == '.')
++wstr;
hr = fdlgIf->lpVtbl->SetDefaultExtension(fdlgIf, wstr);
Tcl_DStringFree(&ds);
@@ -1385,7 +1388,8 @@ static int GetFileNameVista(Tcl_Interp *interp, OFNOpts *optsPtr,
const char *src;
src = Tcl_GetString(optsPtr->titleObj);
- wstr = (LPWSTR) Tcl_WinUtfToTChar(src, optsPtr->titleObj->length, &ds);
+ Tcl_DStringInit(&ds);
+ wstr = Tcl_UtfToWCharDString(src, optsPtr->titleObj->length, &ds);
hr = fdlgIf->lpVtbl->SetTitle(fdlgIf, wstr);
Tcl_DStringFree(&ds);
if (FAILED(hr))
@@ -1407,7 +1411,7 @@ static int GetFileNameVista(Tcl_Interp *interp, OFNOpts *optsPtr,
if (normPath) {
LPCWSTR nativePath;
Tcl_IncrRefCount(normPath);
- nativePath = Tcl_FSGetNativePath(normPath); /* Points INTO normPath*/
+ nativePath = (LPCWSTR)Tcl_FSGetNativePath(normPath); /* Points INTO normPath*/
if (nativePath) {
hr = ShellProcs.SHCreateItemFromParsingName(
nativePath, NULL,
@@ -1511,7 +1515,8 @@ static int GetFileNameVista(Tcl_Interp *interp, OFNOpts *optsPtr,
Tcl_DString ftds;
Tcl_Obj *ftobj;
- Tcl_WinTCharToUtf((LPCTSTR)filterPtr[ftix-1].pszName, -1, &ftds);
+ Tcl_DStringInit(&ftds);
+ Tcl_WCharToUtfDString(filterPtr[ftix-1].pszName, wcslen(filterPtr[ftix-1].pszName), &ftds);
ftobj = Tcl_NewStringObj(Tcl_DStringValue(&ftds),
Tcl_DStringLength(&ftds));
Tcl_ObjSetVar2(interp, optsPtr->typeVariableObj, NULL,
@@ -1573,7 +1578,7 @@ static int GetFileNameXP(Tcl_Interp *interp, OFNOpts *optsPtr, enum OFNOper oper
Tcl_DString utfFilterString, ds;
Tcl_DString extString, filterString, dirString, titleString;
const char *str;
- ThreadSpecificData *tsdPtr =
+ ThreadSpecificData *tsdPtr = (ThreadSpecificData *)
Tcl_GetThreadData(&dataKey, sizeof(ThreadSpecificData));
ZeroMemory(&ofnData, sizeof(OFNData));
@@ -1598,7 +1603,7 @@ static int GetFileNameXP(Tcl_Interp *interp, OFNOpts *optsPtr, enum OFNOper oper
ofn.nMaxFile = TK_MULTI_MAX_PATH;
ofn.Flags = OFN_HIDEREADONLY | OFN_PATHMUSTEXIST | OFN_NOCHANGEDIR
| OFN_EXPLORER| OFN_ENABLEHOOK| OFN_ENABLESIZING;
- ofn.lpfnHook = (LPOFNHOOKPROC) OFNHookProc;
+ ofn.lpfnHook = (LPOFNHOOKPROC)(void *)OFNHookProc;
ofn.lCustData = (LPARAM) &ofnData;
if (oper != OFN_FILE_SAVE) {
@@ -1618,24 +1623,26 @@ static int GetFileNameXP(Tcl_Interp *interp, OFNOpts *optsPtr, enum OFNOper oper
*/
ofnData.dynFileBufferSize = 512;
- ofnData.dynFileBuffer = ckalloc(512 * sizeof(WCHAR));
+ ofnData.dynFileBuffer = (WCHAR *)ckalloc(512 * sizeof(WCHAR));
}
if (optsPtr->extObj != NULL) {
- str = Tcl_GetString(optsPtr->extObj);
- if (str[0] == '.')
- ++str;
- Tcl_WinUtfToTChar(str, -1, &extString);
- ofn.lpstrDefExt = (WCHAR *) Tcl_DStringValue(&extString);
+ str = Tcl_GetString(optsPtr->extObj);
+ if (str[0] == '.') {
+ ++str;
+ }
+ Tcl_DStringInit(&extString);
+ ofn.lpstrDefExt = Tcl_UtfToWCharDString(str, -1, &extString);
}
- Tcl_WinUtfToTChar(Tcl_DStringValue(&utfFilterString),
+ Tcl_DStringInit(&filterString);
+ ofn.lpstrFilter = Tcl_UtfToWCharDString(Tcl_DStringValue(&utfFilterString),
Tcl_DStringLength(&utfFilterString), &filterString);
- ofn.lpstrFilter = (WCHAR *) Tcl_DStringValue(&filterString);
ofn.nFilterIndex = filterIndex;
if (Tcl_DStringValue(&optsPtr->utfDirString)[0] != '\0') {
- Tcl_WinUtfToTChar(Tcl_DStringValue(&optsPtr->utfDirString),
+ Tcl_DStringInit(&dirString);
+ Tcl_UtfToWCharDString(Tcl_DStringValue(&optsPtr->utfDirString),
Tcl_DStringLength(&optsPtr->utfDirString), &dirString);
} else {
/*
@@ -1651,7 +1658,8 @@ static int GetFileNameXP(Tcl_Interp *interp, OFNOpts *optsPtr, enum OFNOper oper
Tcl_DStringValue(&optsPtr->utfDirString), &cwd) == NULL)) {
Tcl_ResetResult(interp);
} else {
- Tcl_WinUtfToTChar(Tcl_DStringValue(&cwd),
+ Tcl_DStringInit(&dirString);
+ Tcl_UtfToWCharDString(Tcl_DStringValue(&cwd),
Tcl_DStringLength(&cwd), &dirString);
}
Tcl_DStringFree(&cwd);
@@ -1659,8 +1667,8 @@ static int GetFileNameXP(Tcl_Interp *interp, OFNOpts *optsPtr, enum OFNOper oper
ofn.lpstrInitialDir = (WCHAR *) Tcl_DStringValue(&dirString);
if (optsPtr->titleObj != NULL) {
- Tcl_WinUtfToTChar(Tcl_GetString(optsPtr->titleObj), -1, &titleString);
- ofn.lpstrTitle = (WCHAR *) Tcl_DStringValue(&titleString);
+ Tcl_DStringInit(&titleString);
+ ofn.lpstrTitle = Tcl_UtfToWCharDString(Tcl_GetString(optsPtr->titleObj), -1, &titleString);
}
/*
@@ -1913,10 +1921,11 @@ OFNHookProc(
WPARAM wParam, /* Message parameter */
LPARAM lParam) /* Message parameter */
{
- ThreadSpecificData *tsdPtr =
+ ThreadSpecificData *tsdPtr = (ThreadSpecificData *)
Tcl_GetThreadData(&dataKey, sizeof(ThreadSpecificData));
OPENFILENAME *ofnPtr;
OFNData *ofnData;
+ (void)wParam;
if (uMsg == WM_INITDIALOG) {
TkWinSetUserData(hdlg, lParam);
@@ -1961,7 +1970,7 @@ OFNHookProc(
if ((selsize > 1) && (dirsize > 0)) {
if (ofnData->dynFileBufferSize < buffersize) {
- buffer = ckrealloc(buffer, buffersize * sizeof(WCHAR));
+ buffer = (WCHAR *)ckrealloc(buffer, buffersize * sizeof(WCHAR));
ofnData->dynFileBufferSize = buffersize;
ofnData->dynFileBuffer = buffer;
}
@@ -2007,7 +2016,7 @@ OFNHookProc(
if (TCL_PATH_ABSOLUTE ==
Tcl_GetPathType(Tcl_DStringValue(&tmpfile))) {
/* re-get the full path to the start of the buffer */
- buffer = (WCHAR *) ofnData->dynFileBuffer;
+ buffer = ofnData->dynFileBuffer;
SendMessageW(hdlg, CDM_GETSPEC, selsize, (LPARAM) buffer);
} else {
*(buffer-1) = '\\';
@@ -2093,7 +2102,7 @@ MakeFilter(
*/
const char *defaultFilter = "All Files (*.*)";
- p = filterStr = ckalloc(30);
+ p = filterStr = (char *)ckalloc(30);
strcpy(p, defaultFilter);
p+= strlen(defaultFilter);
@@ -2107,13 +2116,12 @@ MakeFilter(
*p = '\0';
} else {
- size_t len;
+ int len;
if (valuePtr == NULL) {
len = 0;
} else {
- (void) Tcl_GetString(valuePtr);
- len = valuePtr->length;
+ (void) Tcl_GetStringFromObj(valuePtr, &len);
}
/*
@@ -2130,7 +2138,7 @@ MakeFilter(
* twice the size of the string to format the filter
*/
- filterStr = ckalloc(len * 3);
+ filterStr = (char *)ckalloc(len * 3);
for (filterPtr = flist.filters, p = filterStr; filterPtr;
filterPtr = filterPtr->next) {
@@ -2283,7 +2291,7 @@ static int MakeFilterVista(
Tcl_DStringInit(&ds);
Tcl_DStringInit(&patterns);
- dlgFilterPtr = ckalloc(flist.numFilters * sizeof(*dlgFilterPtr));
+ dlgFilterPtr = (TCLCOMDLG_FILTERSPEC *)ckalloc(flist.numFilters * sizeof(*dlgFilterPtr));
for (i = 0, filterPtr = flist.filters;
filterPtr;
@@ -2297,10 +2305,11 @@ static int MakeFilterVista(
initialIndex = i+1; /* Windows filter indices are 1-based */
/* First stash away the text description of the pattern */
- Tcl_WinUtfToTChar(filterPtr->name, -1, &ds);
+ Tcl_DStringInit(&ds);
+ Tcl_UtfToWCharDString(filterPtr->name, -1, &ds);
nbytes = Tcl_DStringLength(&ds); /* # bytes, not Unicode chars */
nbytes += sizeof(WCHAR); /* Terminating \0 */
- dlgFilterPtr[i].pszName = ckalloc(nbytes);
+ dlgFilterPtr[i].pszName = (LPCWSTR)ckalloc(nbytes);
memmove((void *) dlgFilterPtr[i].pszName, Tcl_DStringValue(&ds), nbytes);
Tcl_DStringFree(&ds);
@@ -2325,10 +2334,11 @@ static int MakeFilterVista(
}
/* Again we need a Unicode form of the string */
- Tcl_WinUtfToTChar(Tcl_DStringValue(&patterns), -1, &ds);
+ Tcl_DStringInit(&ds);
+ Tcl_UtfToWCharDString(Tcl_DStringValue(&patterns), -1, &ds);
nbytes = Tcl_DStringLength(&ds); /* # bytes, not Unicode chars */
nbytes += sizeof(WCHAR); /* Terminating \0 */
- dlgFilterPtr[i].pszSpec = ckalloc(nbytes);
+ dlgFilterPtr[i].pszSpec = (LPCWSTR)ckalloc(nbytes);
memmove((void *)dlgFilterPtr[i].pszSpec, Tcl_DStringValue(&ds), nbytes);
Tcl_DStringFree(&ds);
Tcl_DStringSetLength(&patterns, 0);
@@ -2424,7 +2434,7 @@ Tk_ChooseDirectoryObjCmd(
int objc, /* Number of arguments. */
Tcl_Obj *const objv[]) /* Argument objects. */
{
- WCHAR path[MAX_PATH];
+ WCHAR path[MAX_PATH];
int oldMode, result;
LPCITEMIDLIST pidl; /* Returned by browser */
BROWSEINFOW bInfo; /* Used by browser */
@@ -2461,14 +2471,15 @@ Tk_ChooseDirectoryObjCmd(
if (utfDir[0] != '\0') {
LPCWSTR uniStr;
- Tcl_WinUtfToTChar(Tcl_DStringValue(&ofnOpts.utfDirString), -1,
+ Tcl_DStringInit(&tempString);
+ Tcl_UtfToWCharDString(Tcl_DStringValue(&ofnOpts.utfDirString), -1,
&tempString);
- uniStr = (WCHAR *) Tcl_DStringValue(&tempString);
+ uniStr = (WCHAR *) Tcl_DStringValue(&tempString);
- /* Convert possible relative path to full path to keep dialog happy. */
+ /* Convert possible relative path to full path to keep dialog happy. */
- GetFullPathNameW(uniStr, MAX_PATH, saveDir, NULL);
- wcsncpy(cdCBData.initDir, saveDir, MAX_PATH);
+ GetFullPathNameW(uniStr, MAX_PATH, saveDir, NULL);
+ wcsncpy(cdCBData.initDir, saveDir, MAX_PATH);
}
/* XXX - rest of this (original) code has no error checks at all. */
@@ -2493,8 +2504,8 @@ Tk_ChooseDirectoryObjCmd(
bInfo.lParam = (LPARAM) &cdCBData;
if (ofnOpts.titleObj != NULL) {
- bInfo.lpszTitle = (LPCWSTR)Tcl_WinUtfToTChar(
- Tcl_GetString(ofnOpts.titleObj), -1, &titleString);
+ Tcl_DStringInit(&titleString);
+ bInfo.lpszTitle = Tcl_UtfToWCharDString(Tcl_GetString(ofnOpts.titleObj), -1, &titleString);
} else {
bInfo.lpszTitle = L"Please choose a directory, then select OK.";
}
@@ -2618,7 +2629,7 @@ ChooseDirectoryValidateProc(
Tcl_DString tempString;
Tcl_DString initDirString;
WCHAR string[MAX_PATH];
- ThreadSpecificData *tsdPtr =
+ ThreadSpecificData *tsdPtr = (ThreadSpecificData *)
Tcl_GetThreadData(&dataKey, sizeof(ThreadSpecificData));
if (tsdPtr->debugFlag) {
@@ -2637,7 +2648,8 @@ ChooseDirectoryValidateProc(
* like ~ are converted correctly.
*/
- Tcl_WinTCharToUtf((LPCTSTR) lParam, -1, &initDirString);
+ Tcl_DStringInit(&initDirString);
+ Tcl_WCharToUtfDString((WCHAR *) lParam, wcslen((WCHAR *) lParam), &initDirString);
if (Tcl_TranslateFileName(chooseDirSharedData->interp,
Tcl_DStringValue(&initDirString), &tempString) == NULL) {
/*
@@ -2648,12 +2660,11 @@ ChooseDirectoryValidateProc(
chooseDirSharedData->retDir[0] = '\0';
return 1;
}
- Tcl_DStringFree(&initDirString);
- Tcl_WinUtfToTChar(Tcl_DStringValue(&tempString), -1, &initDirString);
- Tcl_DStringFree(&tempString);
- wcsncpy(string, (WCHAR *) Tcl_DStringValue(&initDirString),
+ Tcl_DStringSetLength(&initDirString, 0);
+ wcsncpy(string, Tcl_UtfToWCharDString(Tcl_DStringValue(&tempString), -1, &initDirString),
MAX_PATH);
Tcl_DStringFree(&initDirString);
+ Tcl_DStringFree(&tempString);
if (SetCurrentDirectoryW(string) == 0) {
@@ -2734,8 +2745,8 @@ ChooseDirectoryValidateProc(
ULONG ulCount, ulAttr;
if (SUCCEEDED(psfFolder->lpVtbl->ParseDisplayName(
- psfFolder, hwnd, NULL, (WCHAR *)
- initDir, &ulCount,&pidlMain,&ulAttr))
+ psfFolder, hwnd, NULL, initDir,
+ &ulCount,&pidlMain,&ulAttr))
&& (pidlMain != NULL)) {
SendMessageW(hwnd, BFFM_SETSELECTIONW, FALSE,
(LPARAM) pidlMain);
@@ -2781,7 +2792,7 @@ Tk_MessageBoxObjCmd(
int objc, /* Number of arguments. */
Tcl_Obj *const objv[]) /* Argument objects. */
{
- Tk_Window tkwin = clientData, parent;
+ Tk_Window tkwin = (Tk_Window)clientData, parent;
HWND hWnd;
Tcl_Obj *messageObj, *titleObj, *detailObj, *tmpObj;
int defaultBtn, icon, type;
@@ -2795,7 +2806,7 @@ Tk_MessageBoxObjCmd(
MSG_DEFAULT, MSG_DETAIL, MSG_ICON, MSG_MESSAGE,
MSG_PARENT, MSG_TITLE, MSG_TYPE
};
- ThreadSpecificData *tsdPtr =
+ ThreadSpecificData *tsdPtr = (ThreadSpecificData *)
Tcl_GetThreadData(&dataKey, sizeof(ThreadSpecificData));
Tcl_DString titleBuf, tmpBuf;
LPCWSTR titlePtr, tmpPtr;
@@ -2929,10 +2940,12 @@ Tk_MessageBoxObjCmd(
tsdPtr->hMsgBoxHook = SetWindowsHookExW(WH_CBT, MsgBoxCBTProc, NULL,
GetCurrentThreadId());
src = Tcl_GetString(tmpObj);
- tmpPtr = (LPCWSTR)Tcl_WinUtfToTChar(src, tmpObj->length, &tmpBuf);
+ Tcl_DStringInit(&tmpBuf);
+ tmpPtr = Tcl_UtfToWCharDString(src, tmpObj->length, &tmpBuf);
if (titleObj != NULL) {
src = Tcl_GetString(titleObj);
- titlePtr = (LPCWSTR)Tcl_WinUtfToTChar(src, titleObj->length, &titleBuf);
+ Tcl_DStringInit(&titleBuf);
+ titlePtr = Tcl_UtfToWCharDString(src, titleObj->length, &titleBuf);
} else {
titlePtr = L"";
Tcl_DStringInit(&titleBuf);
@@ -2963,7 +2976,7 @@ MsgBoxCBTProc(
WPARAM wParam,
LPARAM lParam)
{
- ThreadSpecificData *tsdPtr =
+ ThreadSpecificData *tsdPtr = (ThreadSpecificData *)
Tcl_GetThreadData(&dataKey, sizeof(ThreadSpecificData));
if (nCode == HCBT_CREATEWND) {
@@ -3010,7 +3023,7 @@ static void
SetTkDialog(
ClientData clientData)
{
- ThreadSpecificData *tsdPtr =
+ ThreadSpecificData *tsdPtr = (ThreadSpecificData *)
Tcl_GetThreadData(&dataKey, sizeof(ThreadSpecificData));
char buf[32];
@@ -3024,12 +3037,13 @@ SetTkDialog(
static const char *
ConvertExternalFilename(
- WCHAR *filename,
+ LPCWSTR filename,
Tcl_DString *dsPtr)
{
char *p;
- Tcl_WinTCharToUtf((LPCTSTR)filename, -1, dsPtr);
+ Tcl_DStringInit(dsPtr);
+ Tcl_WCharToUtfDString(filename, wcslen(filename), dsPtr);
for (p = Tcl_DStringValue(dsPtr); *p != '\0'; p++) {
/*
* Change the pathname to the Tcl "normalized" pathname, where back
@@ -3066,7 +3080,8 @@ GetFontObj(
int pt = 0;
resObj = Tcl_NewListObj(0, NULL);
- Tcl_WinTCharToUtf((LPCTSTR)plf->lfFaceName, -1, &ds);
+ Tcl_DStringInit(&ds);
+ Tcl_WCharToUtfDString(plf->lfFaceName, wcslen(plf->lfFaceName), &ds);
Tcl_ListObjAppendElement(NULL, resObj,
Tcl_NewStringObj(Tcl_DStringValue(&ds), -1));
Tcl_DStringFree(&ds);
@@ -3101,7 +3116,7 @@ ApplyLogfont(
Tcl_Obj **objv, **tmpv;
Tcl_ListObjGetElements(NULL, cmdObj, &objc, &objv);
- tmpv = ckalloc(sizeof(Tcl_Obj *) * (objc + 2));
+ tmpv = (Tcl_Obj **)ckalloc(sizeof(Tcl_Obj *) * (objc + 2));
memcpy(tmpv, objv, sizeof(Tcl_Obj *) * objc);
tmpv[objc] = GetFontObj(hdc, logfontPtr);
TkBackgroundEvalObjv(interp, objc+1, tmpv, TCL_EVAL_GLOBAL);
@@ -3139,7 +3154,7 @@ HookProc(
CHOOSEFONT *pcf = (CHOOSEFONT *) lParam;
HWND hwndCtrl;
static HookData *phd = NULL;
- ThreadSpecificData *tsdPtr =
+ ThreadSpecificData *tsdPtr = (ThreadSpecificData *)
Tcl_GetThreadData(&dataKey, sizeof(ThreadSpecificData));
if (WM_INITDIALOG == msg && lParam != 0) {
@@ -3152,7 +3167,8 @@ HookProc(
if (phd->titleObj != NULL) {
Tcl_DString title;
- Tcl_WinUtfToTChar(Tcl_GetString(phd->titleObj), -1, &title);
+ Tcl_DStringInit(&title);
+ Tcl_UtfToWCharDString(Tcl_GetString(phd->titleObj), -1, &title);
if (Tcl_DStringLength(&title) > 0) {
SetWindowTextW(hwndDlg, (LPCWSTR) Tcl_DStringValue(&title));
}
@@ -3281,14 +3297,14 @@ FontchooserConfigureCmd(
int objc,
Tcl_Obj *const objv[])
{
- Tk_Window tkwin = clientData;
+ Tk_Window tkwin = (Tk_Window)clientData;
HookData *hdPtr = NULL;
int i, r = TCL_OK;
static const char *const optionStrings[] = {
"-parent", "-title", "-font", "-command", "-visible", NULL
};
- hdPtr = Tcl_GetAssocData(interp, "::tk::fontchooser", NULL);
+ hdPtr = (HookData *)Tcl_GetAssocData(interp, "::tk::fontchooser", NULL);
/*
* With no arguments we return all the options in a dict.
@@ -3425,14 +3441,16 @@ FontchooserShowCmd(
Tcl_Obj *const objv[])
{
Tcl_DString ds;
- Tk_Window tkwin = clientData, parent;
+ Tk_Window tkwin = (Tk_Window)clientData, parent;
CHOOSEFONTW cf;
LOGFONTW lf;
HDC hdc;
HookData *hdPtr;
int r = TCL_OK, oldMode = 0;
+ (void)objc;
+ (void)objv;
- hdPtr = Tcl_GetAssocData(interp, "::tk::fontchooser", NULL);
+ hdPtr = (HookData *)Tcl_GetAssocData(interp, "::tk::fontchooser", NULL);
parent = tkwin;
if (hdPtr->parentObj) {
@@ -3469,8 +3487,8 @@ FontchooserShowCmd(
}
fontPtr = (TkFont *) f;
cf.Flags |= CF_INITTOLOGFONTSTRUCT;
- Tcl_WinUtfToTChar(fontPtr->fa.family, -1, &ds);
- wcsncpy(lf.lfFaceName, (WCHAR *)Tcl_DStringValue(&ds),
+ Tcl_DStringInit(&ds);
+ wcsncpy(lf.lfFaceName, Tcl_UtfToWCharDString(fontPtr->fa.family, -1, &ds),
LF_FACESIZE-1);
Tcl_DStringFree(&ds);
lf.lfFaceName[LF_FACESIZE-1] = 0;
@@ -3533,12 +3551,15 @@ FontchooserShowCmd(
static int
FontchooserHideCmd(
- ClientData clientData, /* Main window */
+ ClientData dummy, /* Main window */
Tcl_Interp *interp,
int objc,
Tcl_Obj *const objv[])
{
- HookData *hdPtr = Tcl_GetAssocData(interp, "::tk::fontchooser", NULL);
+ HookData *hdPtr = (HookData *)Tcl_GetAssocData(interp, "::tk::fontchooser", NULL);
+ (void)dummy;
+ (void)objc;
+ (void)objv;
if (hdPtr->hwnd && IsWindow(hdPtr->hwnd)) {
EndDialog(hdPtr->hwnd, 0);
@@ -3558,9 +3579,10 @@ FontchooserHideCmd(
*/
static void
-DeleteHookData(ClientData clientData, Tcl_Interp *interp)
+DeleteHookData(ClientData clientData, Tcl_Interp *dummy)
{
- HookData *hdPtr = clientData;
+ HookData *hdPtr = (HookData *)clientData;
+ (void)dummy;
if (hdPtr->parentObj) {
Tcl_DecrRefCount(hdPtr->parentObj);
@@ -3597,9 +3619,10 @@ const TkEnsemble tkFontchooserEnsemble[] = {
};
int
-TkInitFontchooser(Tcl_Interp *interp, ClientData clientData)
+TkInitFontchooser(Tcl_Interp *interp, ClientData dummy)
{
- HookData *hdPtr = ckalloc(sizeof(HookData));
+ HookData *hdPtr = (HookData *)ckalloc(sizeof(HookData));
+ (void)dummy;
memset(hdPtr, 0, sizeof(HookData));
Tcl_SetAssocData(interp, "::tk::fontchooser", DeleteHookData, hdPtr);
diff --git a/win/tkWinFont.c b/win/tkWinFont.c
index 321ecc4..cef505a 100644
--- a/win/tkWinFont.c
+++ b/win/tkWinFont.c
@@ -29,7 +29,8 @@
#define FONTMAP_SHIFT 10
#define FONTMAP_BITSPERPAGE (1 << FONTMAP_SHIFT)
-#define FONTMAP_PAGES (0x30000 / FONTMAP_BITSPERPAGE)
+#define FONTMAP_NUMCHARS 0x40000
+#define FONTMAP_PAGES (FONTMAP_NUMCHARS / FONTMAP_BITSPERPAGE)
typedef struct FontFamily {
struct FontFamily *nextPtr; /* Next in list of all known font families. */
@@ -299,8 +300,8 @@ TkpGetNativeFont(
}
tkwin = (Tk_Window) ((TkWindow *) tkwin)->mainPtr->winPtr;
- fontPtr = ckalloc(sizeof(WinFont));
- InitFont(tkwin, GetStockObject(object), 0, fontPtr);
+ fontPtr = (WinFont *)ckalloc(sizeof(WinFont));
+ InitFont(tkwin, (HFONT)GetStockObject(object), 0, fontPtr);
return (TkFont *) fontPtr;
}
@@ -557,7 +558,7 @@ TkpGetFontFromAttributes(
hFont = GetScreenFont(faPtr, faceName,
(int)(TkFontGetPixels(tkwin, faPtr->size) + 0.5), 0.0);
if (tkFontPtr == NULL) {
- fontPtr = ckalloc(sizeof(WinFont));
+ fontPtr = (WinFont *)ckalloc(sizeof(WinFont));
} else {
fontPtr = (WinFont *) tkFontPtr;
ReleaseFont(fontPtr);
@@ -657,10 +658,12 @@ WinFontFamilyEnumProc(
int fontType, /* Type of font (not used). */
LPARAM lParam) /* Result object to hold result. */
{
+ WCHAR *faceName = lfPtr->elfLogFont.lfFaceName;
Tcl_Obj *resultObj = (Tcl_Obj *) lParam;
Tcl_DString faceString;
- Tcl_WinTCharToUtf((LPCTSTR)lfPtr->elfLogFont.lfFaceName, -1, &faceString);
+ Tcl_DStringInit(&faceString);
+ Tcl_WCharToUtfDString(faceName, wcslen(faceName), &faceString);
Tcl_ListObjAppendElement(NULL, resultObj, Tcl_NewStringObj(
Tcl_DStringValue(&faceString), Tcl_DStringLength(&faceString)));
Tcl_DStringFree(&faceString);
@@ -749,7 +752,7 @@ TkpGetFontAttrsForChar(
* Get the font attributes.
*/
- oldfont = SelectObject(hdc, thisSubFontPtr->hFont0);
+ oldfont = (HFONT)SelectObject(hdc, thisSubFontPtr->hFont0);
GetTextMetricsW(hdc, &tm);
SelectObject(hdc, oldfont);
ReleaseDC(fontPtr->hwnd, hdc);
@@ -827,7 +830,7 @@ Tk_MeasureChars(
hdc = GetDC(fontPtr->hwnd);
lastSubFontPtr = &fontPtr->subFontArray[0];
- oldFont = SelectObject(hdc, lastSubFontPtr->hFont0);
+ oldFont = (HFONT)SelectObject(hdc, lastSubFontPtr->hFont0);
/*
* A three step process:
@@ -1036,6 +1039,7 @@ TkpMeasureCharsInContext(
* terminating character. */
{
(void) numBytes; /*unused*/
+
return Tk_MeasureChars(tkfont, source + rangeStart, rangeLength,
maxLength, flags, lengthPtr);
}
@@ -1116,7 +1120,7 @@ Tk_DrawChars(
stipple = CreatePatternBrush(twdPtr->bitmap.handle);
SetBrushOrgEx(dc, gc->ts_x_origin, gc->ts_y_origin, NULL);
- oldBrush = SelectObject(dc, stipple);
+ oldBrush = (HBRUSH)SelectObject(dc, stipple);
SetTextAlign(dcMem, TA_LEFT | TA_BASELINE);
SetTextColor(dcMem, gc->foreground);
@@ -1131,7 +1135,7 @@ Tk_DrawChars(
GetTextMetricsW(dcMem, &tm);
size.cx -= tm.tmOverhang;
bitmap = CreateCompatibleBitmap(dc, size.cx, size.cy);
- oldBitmap = SelectObject(dcMem, bitmap);
+ oldBitmap = (HBITMAP)SelectObject(dcMem, bitmap);
/*
* The following code is tricky because fonts are rendered in multiple
@@ -1185,7 +1189,7 @@ Tk_DrawChars(
GetTextMetricsW(dcMem, &tm);
size.cx -= tm.tmOverhang;
bitmap = CreateCompatibleBitmap(dc, size.cx, size.cy);
- oldBitmap = SelectObject(dcMem, bitmap);
+ oldBitmap = (HBITMAP)SelectObject(dcMem, bitmap);
MultiFontTextOut(dcMem, fontPtr, source, numBytes, 0, tm.tmAscent,
0.0);
@@ -1264,7 +1268,7 @@ TkDrawAngledChars(
stipple = CreatePatternBrush(twdPtr->bitmap.handle);
SetBrushOrgEx(dc, gc->ts_x_origin, gc->ts_y_origin, NULL);
- oldBrush = SelectObject(dc, stipple);
+ oldBrush = (HBRUSH)SelectObject(dc, stipple);
SetTextAlign(dcMem, TA_LEFT | TA_BASELINE);
SetTextColor(dcMem, gc->foreground);
@@ -1279,7 +1283,7 @@ TkDrawAngledChars(
GetTextMetricsW(dcMem, &tm);
size.cx -= tm.tmOverhang;
bitmap = CreateCompatibleBitmap(dc, size.cx, size.cy);
- oldBitmap = SelectObject(dcMem, bitmap);
+ oldBitmap = (HBITMAP)SelectObject(dcMem, bitmap);
/*
* The following code is tricky because fonts are rendered in multiple
@@ -1333,7 +1337,7 @@ TkDrawAngledChars(
GetTextMetricsW(dcMem, &tm);
size.cx -= tm.tmOverhang;
bitmap = CreateCompatibleBitmap(dc, size.cx, size.cy);
- oldBitmap = SelectObject(dcMem, bitmap);
+ oldBitmap = (HBITMAP)SelectObject(dcMem, bitmap);
MultiFontTextOut(dcMem, fontPtr, source, numBytes, 0, tm.tmAscent,
angle);
@@ -1391,7 +1395,6 @@ TkpDrawCharsInContext(
* drawing. */
{
int widthUntilStart;
-
(void) numBytes; /*unused*/
Tk_MeasureChars(tkfont, source, rangeStart, -1, 0, &widthUntilStart);
@@ -1497,9 +1500,9 @@ SelectFont(
double angle)
{
if (angle == 0.0) {
- return SelectObject(hdc, subFontPtr->hFont0);
+ return (HFONT)SelectObject(hdc, subFontPtr->hFont0);
} else if (angle == subFontPtr->angle) {
- return SelectObject(hdc, subFontPtr->hFontAngled);
+ return (HFONT)SelectObject(hdc, subFontPtr->hFontAngled);
} else {
if (subFontPtr->hFontAngled) {
DeleteObject(subFontPtr->hFontAngled);
@@ -1507,10 +1510,10 @@ SelectFont(
subFontPtr->hFontAngled = GetScreenFont(&fontPtr->font.fa,
subFontPtr->familyPtr->faceName, fontPtr->pixelSize, angle);
if (subFontPtr->hFontAngled == NULL) {
- return SelectObject(hdc, subFontPtr->hFont0);
+ return (HFONT)SelectObject(hdc, subFontPtr->hFont0);
}
subFontPtr->angle = angle;
- return SelectObject(hdc, subFontPtr->hFontAngled);
+ return (HFONT)SelectObject(hdc, subFontPtr->hFontAngled);
}
}
@@ -1562,12 +1565,13 @@ InitFont(
window = Tk_WindowId(tkwin);
hwnd = (window == None) ? NULL : TkWinGetHWND(window);
hdc = GetDC(hwnd);
- oldFont = SelectObject(hdc, hFont);
+ oldFont = (HFONT)SelectObject(hdc, hFont);
GetTextMetricsW(hdc, &tm);
GetTextFaceW(hdc, LF_FACESIZE, buf);
- Tcl_WinTCharToUtf((LPCTSTR)buf, -1, &faceString);
+ Tcl_DStringInit(&faceString);
+ Tcl_WCharToUtfDString(buf, wcslen(buf), &faceString);
fontPtr->font.fid = (Font) fontPtr;
fontPtr->hwnd = hwnd;
@@ -1739,15 +1743,16 @@ AllocFontFamily(
Tcl_DString faceString;
Tcl_Encoding encoding;
WCHAR buf[LF_FACESIZE];
- ThreadSpecificData *tsdPtr =
+ ThreadSpecificData *tsdPtr = (ThreadSpecificData *)
Tcl_GetThreadData(&dataKey, sizeof(ThreadSpecificData));
- hFont = SelectObject(hdc, hFont);
+ hFont = (HFONT)SelectObject(hdc, hFont);
GetTextFaceW(hdc, LF_FACESIZE, buf);
- Tcl_WinTCharToUtf((LPCTSTR)buf, -1, &faceString);
+ Tcl_DStringInit(&faceString);
+ Tcl_WCharToUtfDString(buf, wcslen(buf), &faceString);
faceName = Tk_GetUid(Tcl_DStringValue(&faceString));
Tcl_DStringFree(&faceString);
- hFont = SelectObject(hdc, hFont);
+ hFont = (HFONT)SelectObject(hdc, hFont);
familyPtr = tsdPtr->fontFamilyList;
for ( ; familyPtr != NULL; familyPtr = familyPtr->nextPtr) {
@@ -1757,7 +1762,7 @@ AllocFontFamily(
}
}
- familyPtr = ckalloc(sizeof(FontFamily));
+ familyPtr = (FontFamily *)ckalloc(sizeof(FontFamily));
memset(familyPtr, 0, sizeof(FontFamily));
familyPtr->nextPtr = tsdPtr->fontFamilyList;
tsdPtr->fontFamilyList = familyPtr;
@@ -1843,7 +1848,7 @@ FreeFontFamily(
{
int i;
FontFamily **familyPtrPtr;
- ThreadSpecificData *tsdPtr =
+ ThreadSpecificData *tsdPtr = (ThreadSpecificData *)
Tcl_GetThreadData(&dataKey, sizeof(ThreadSpecificData));
if (familyPtr == NULL) {
@@ -1920,7 +1925,7 @@ FindSubFontForChar(
SubFont *subFontPtr;
Tcl_DString ds;
- if ((ch < BASE_CHARS) || (ch >= 0x30000)) {
+ if ((ch < BASE_CHARS) || (ch >= FONTMAP_NUMCHARS)) {
return &fontPtr->subFontArray[0];
}
@@ -2047,7 +2052,10 @@ WinFontCanUseProc(
fontPtr = canUsePtr->fontPtr;
nameTriedPtr = canUsePtr->nameTriedPtr;
- fallbackName = Tcl_WinTCharToUtf((LPCTSTR)lfPtr->elfLogFont.lfFaceName, -1, &faceString);
+ fallbackName = (char *) lfPtr->elfLogFont.lfFaceName;
+ Tcl_DStringInit(&faceString);
+ Tcl_WCharToUtfDString((WCHAR *)fallbackName, wcslen((WCHAR *)fallbackName), &faceString);
+ fallbackName = Tcl_DStringValue(&faceString);
if (SeenName(fallbackName, nameTriedPtr) == 0) {
subFontPtr = CanUseFallback(hdc, fontPtr, fallbackName, ch,
@@ -2090,7 +2098,7 @@ FontMapLookup(
{
int row, bitOffset;
- if (ch < 0 || ch >= 0x30000) {
+ if (ch < 0 || ch >= FONTMAP_NUMCHARS) {
return 0;
}
@@ -2134,7 +2142,7 @@ FontMapInsert(
{
int row, bitOffset;
- if (ch >= 0 && ch < 0x30000) {
+ if (ch >= 0 && ch < FONTMAP_NUMCHARS) {
row = ch >> FONTMAP_SHIFT;
if (subFontPtr->fontMap[row] == NULL) {
FontMapLoadPage(subFontPtr, row);
@@ -2172,11 +2180,11 @@ FontMapLoadPage(
{
FontFamily *familyPtr;
Tcl_Encoding encoding;
- char src[XMaxTransChars], buf[16];
- USHORT *startCount, *endCount;
int i, j, bitOffset, end, segCount;
+ USHORT *startCount, *endCount;
+ char buf[16], src[6];
- subFontPtr->fontMap[row] = ckalloc(FONTMAP_BITSPERPAGE / 8);
+ subFontPtr->fontMap[row] = (char *)ckalloc(FONTMAP_BITSPERPAGE / 8);
memset(subFontPtr->fontMap[row], 0, FONTMAP_BITSPERPAGE / 8);
familyPtr = subFontPtr->familyPtr;
@@ -2225,7 +2233,7 @@ FontMapLoadPage(
end = (row + 1) << FONTMAP_SHIFT;
for (i = row << FONTMAP_SHIFT; i < end; i++) {
if (Tcl_UtfToExternal(NULL, encoding, src,
- Tcl_UniCharToUtf(i, src), TCL_ENCODING_STOPONERROR, NULL,
+ TkUniCharToUtf(i, src), TCL_ENCODING_STOPONERROR, NULL,
buf, sizeof(buf), NULL, NULL, NULL) != TCL_OK) {
continue;
}
@@ -2407,7 +2415,7 @@ CanUseFallback(
if (fontPtr->numSubFonts >= SUBFONT_SPACE) {
SubFont *newPtr;
- newPtr = ckalloc(sizeof(SubFont) * (fontPtr->numSubFonts + 1));
+ newPtr = (SubFont *)ckalloc(sizeof(SubFont) * (fontPtr->numSubFonts + 1));
memcpy(newPtr, fontPtr->subFontArray,
fontPtr->numSubFonts * sizeof(SubFont));
if (fontPtr->subFontArray != fontPtr->staticSubFonts) {
@@ -2455,7 +2463,6 @@ GetScreenFont(
double angle) /* What is the desired orientation of the
* font. */
{
- Tcl_DString ds;
HFONT hFont;
LOGFONTW lf;
@@ -2474,9 +2481,7 @@ GetScreenFont(
lf.lfQuality = DEFAULT_QUALITY;
lf.lfPitchAndFamily = DEFAULT_PITCH | FF_DONTCARE;
- Tcl_WinUtfToTChar(faceName, -1, &ds);
- wcsncpy(lf.lfFaceName, (WCHAR *)Tcl_DStringValue(&ds), LF_FACESIZE-1);
- Tcl_DStringFree(&ds);
+ MultiByteToWideChar(CP_UTF8, 0, faceName, -1, lf.lfFaceName, LF_FACESIZE);
lf.lfFaceName[LF_FACESIZE-1] = 0;
hFont = CreateFontIndirectW(&lf);
return hFont;
@@ -2525,7 +2530,8 @@ FamilyExists(
return 0;
}
- Tcl_WinUtfToTChar(faceName, -1, &faceString);
+ Tcl_DStringInit(&faceString);
+ Tcl_UtfToWCharDString(faceName, -1, &faceString);
/*
* If the family exists, WinFontExistProc() will be called and
@@ -2534,7 +2540,7 @@ FamilyExists(
* non-zero value.
*/
- result = EnumFontFamiliesW(hdc, (WCHAR*) Tcl_DStringValue(&faceString),
+ result = EnumFontFamiliesW(hdc, (WCHAR *)Tcl_DStringValue(&faceString),
(FONTENUMPROCW) WinFontExistProc, 0);
Tcl_DStringFree(&faceString);
return (result == 0);
@@ -2722,7 +2728,7 @@ LoadFontRanges(
endCount = NULL;
*symbolPtr = 0;
- hFont = SelectObject(hdc, hFont);
+ hFont = (HFONT)SelectObject(hdc, hFont);
i = 0;
s = (char *) &i;
@@ -2777,8 +2783,8 @@ LoadFontRanges(
segCount = subTable.segment.segCountX2 / 2;
cbData = segCount * sizeof(USHORT);
- startCount = ckalloc(cbData);
- endCount = ckalloc(cbData);
+ startCount = (USHORT *)ckalloc(cbData);
+ endCount = (USHORT *)ckalloc(cbData);
offset = encTable.offset + sizeof(subTable.segment);
GetFontData(hdc, cmapKey, (DWORD) offset, endCount, cbData);
@@ -2821,8 +2827,8 @@ LoadFontRanges(
segCount = 1;
cbData = segCount * sizeof(USHORT);
- startCount = ckalloc(cbData);
- endCount = ckalloc(cbData);
+ startCount = (USHORT *)ckalloc(cbData);
+ endCount = (USHORT *)ckalloc(cbData);
startCount[0] = 0x0000;
endCount[0] = 0x00ff;
}
diff --git a/win/tkWinInit.c b/win/tkWinInit.c
index a1ab098..854d62f 100644
--- a/win/tkWinInit.c
+++ b/win/tkWinInit.c
@@ -35,6 +35,7 @@ int
TkpInit(
Tcl_Interp *interp)
{
+ (void)interp;
/*
* This is necessary for static initialization, and is ok otherwise
* because TkWinXInit flips a static bit to do its work just once.
@@ -137,21 +138,21 @@ TkpDisplayWarning(
len = MultiByteToWideChar(CP_UTF8, 0, title, -1, titleString, TK_MAX_WARN_LEN);
msgString = &titleString[len + 1];
- titleString[TK_MAX_WARN_LEN - 1] = L'\0';
+ titleString[TK_MAX_WARN_LEN - 1] = '\0';
MultiByteToWideChar(CP_UTF8, 0, msg, -1, msgString, (TK_MAX_WARN_LEN - 1) - len);
/*
* Truncate MessageBox string if it is too long to not overflow the screen
* and cause possible oversized window error.
*/
- if (titleString[TK_MAX_WARN_LEN - 1] != L'\0') {
+ if (titleString[TK_MAX_WARN_LEN - 1] != '\0') {
memcpy(titleString + (TK_MAX_WARN_LEN - 5), L" ...", 5 * sizeof(WCHAR));
}
if (IsDebuggerPresent()) {
- titleString[len - 1] = L':';
- titleString[len] = L' ';
+ titleString[len - 1] = ':';
+ titleString[len] = ' ';
OutputDebugStringW(titleString);
} else {
- titleString[len - 1] = L'\0';
+ titleString[len - 1] = '\0';
MessageBoxW(NULL, msgString, titleString,
MB_OK | MB_ICONEXCLAMATION | MB_SYSTEMMODAL
| MB_SETFOREGROUND | MB_TOPMOST);
@@ -196,7 +197,8 @@ TkWin32ErrorObj(
*p = '\0';
}
- Tcl_WinTCharToUtf((LPCTSTR)lpBuffer, -1, &ds);
+ Tcl_DStringInit(&ds);
+ Tcl_WCharToUtfDString(lpBuffer, wcslen(lpBuffer), &ds);
errPtr = Tcl_NewStringObj(Tcl_DStringValue(&ds), Tcl_DStringLength(&ds));
Tcl_DStringFree(&ds);
@@ -206,7 +208,6 @@ TkWin32ErrorObj(
return errPtr;
}
-
/*
* Local Variables:
diff --git a/win/tkWinInt.h b/win/tkWinInt.h
index ef4f1bd..ccc57db 100644
--- a/win/tkWinInt.h
+++ b/win/tkWinInt.h
@@ -185,6 +185,7 @@ MODULE_SCOPE void TkWinSetupSystemFonts(TkMainInfo *mainPtr);
#define TK_THEME_WIN_CLASSIC 1
#define TK_THEME_WIN_XP 2
+#define TK_THEME_WIN_VISTA 3
/*
* The following is implemented in tkWinWm and used by tkWinEmbed.c
diff --git a/win/tkWinKey.c b/win/tkWinKey.c
index 234a158..c7fa20c 100644
--- a/win/tkWinKey.c
+++ b/win/tkWinKey.c
@@ -11,6 +11,7 @@
*/
#include "tkWinInt.h"
+#include "X11/XF86keysym.h"
/*
* The keymap table holds mappings of Windows keycodes to X keysyms. If
@@ -21,46 +22,47 @@
* like a worthwhile improvement to use the table.
*/
-#define MAX_KEYCODE 179 /* VK_MEDIA_PLAY_PAUSE is the last entry in our table below */
+#define MAX_KEYCODE 183 /* VK_LAUNCH_APP2 is the last entry in our table below */
/* cf. https://msdn.microsoft.com/en-us/library/windows/desktop/dd375731(v=vs.85).aspx */
static const KeySym keymap[] = {
- NoSymbol, NoSymbol, NoSymbol, XK_Cancel, NoSymbol,
- NoSymbol, NoSymbol, NoSymbol, XK_BackSpace, XK_Tab,
- NoSymbol, NoSymbol, XK_Clear, XK_Return, NoSymbol,
- NoSymbol, XK_Shift_L, XK_Control_L, XK_Alt_L, XK_Pause,
- XK_Caps_Lock, NoSymbol, NoSymbol, NoSymbol, NoSymbol,
- NoSymbol, NoSymbol, XK_Escape, NoSymbol, NoSymbol,
- NoSymbol, NoSymbol, XK_space, XK_Prior, XK_Next,
- XK_End, XK_Home, XK_Left, XK_Up, XK_Right,
- XK_Down, XK_Select, XK_Print, XK_Execute, NoSymbol,
- XK_Insert, XK_Delete, XK_Help, NoSymbol, NoSymbol,
- NoSymbol, NoSymbol, NoSymbol, NoSymbol, NoSymbol,
- NoSymbol, NoSymbol, NoSymbol, NoSymbol, NoSymbol,
- NoSymbol, NoSymbol, NoSymbol, NoSymbol, NoSymbol,
- NoSymbol, NoSymbol, NoSymbol, NoSymbol, NoSymbol,
- NoSymbol, NoSymbol, NoSymbol, NoSymbol, NoSymbol,
- NoSymbol, NoSymbol, NoSymbol, NoSymbol, NoSymbol,
- NoSymbol, NoSymbol, NoSymbol, NoSymbol, NoSymbol,
- NoSymbol, NoSymbol, NoSymbol, NoSymbol, NoSymbol,
- NoSymbol, XK_Win_L, XK_Win_R, XK_App, NoSymbol,
- NoSymbol, NoSymbol, NoSymbol, NoSymbol, NoSymbol,
- NoSymbol, NoSymbol, NoSymbol, NoSymbol, NoSymbol,
- NoSymbol, NoSymbol, NoSymbol, NoSymbol, NoSymbol,
- NoSymbol, NoSymbol, XK_F1, XK_F2, XK_F3,
- XK_F4, XK_F5, XK_F6, XK_F7, XK_F8,
- XK_F9, XK_F10, XK_F11, XK_F12, XK_F13,
- XK_F14, XK_F15, XK_F16, XK_F17, XK_F18,
- XK_F19, XK_F20, XK_F21, XK_F22, XK_F23,
- XK_F24, NoSymbol, NoSymbol, NoSymbol, NoSymbol,
- NoSymbol, NoSymbol, NoSymbol, NoSymbol, XK_Num_Lock,
- XK_Scroll_Lock, NoSymbol, NoSymbol, NoSymbol, NoSymbol,
+ NoSymbol, NoSymbol, NoSymbol, XK_Cancel, NoSymbol, /*0 0x0*/
+ NoSymbol, NoSymbol, NoSymbol, XK_BackSpace, XK_Tab, /*5 0x5*/
+ NoSymbol, NoSymbol, XK_Clear, XK_Return, NoSymbol, /*10 0xA*/
+ NoSymbol, XK_Shift_L, XK_Control_L, XK_Alt_L, XK_Pause, /*15 0xE*/
+ XK_Caps_Lock, NoSymbol, NoSymbol, NoSymbol, NoSymbol, /*20 0x14*/
+ NoSymbol, NoSymbol, XK_Escape, NoSymbol, NoSymbol, /*25 0x19*/
+ NoSymbol, NoSymbol, XK_space, XK_Prior, XK_Next, /*30 0x1E*/
+ XK_End, XK_Home, XK_Left, XK_Up, XK_Right, /*35 0x23*/
+ XK_Down, XK_Select, XK_Print, XK_Execute, NoSymbol, /*40 0x28*/
+ XK_Insert, XK_Delete, XK_Help, NoSymbol, NoSymbol, /*45 0x2D*/
+ NoSymbol, NoSymbol, NoSymbol, NoSymbol, NoSymbol, /*50 0x32*/
+ NoSymbol, NoSymbol, NoSymbol, NoSymbol, NoSymbol, /*55 0x37*/
+ NoSymbol, NoSymbol, NoSymbol, NoSymbol, NoSymbol, /*60 0x3C*/
+ NoSymbol, NoSymbol, NoSymbol, NoSymbol, NoSymbol, /*65 0x41*/
+ NoSymbol, NoSymbol, NoSymbol, NoSymbol, NoSymbol, /*70 0x46*/
+ NoSymbol, NoSymbol, NoSymbol, NoSymbol, NoSymbol, /*75 0x4B*/
+ NoSymbol, NoSymbol, NoSymbol, NoSymbol, NoSymbol, /*80 0x50*/
+ NoSymbol, NoSymbol, NoSymbol, NoSymbol, NoSymbol, /*85 0x55*/
+ NoSymbol, XK_Win_L, XK_Win_R, XK_App, NoSymbol, /*90 0x5A*/
+ NoSymbol, NoSymbol, NoSymbol, NoSymbol, NoSymbol, /*95 0x5F*/
+ NoSymbol, NoSymbol, NoSymbol, NoSymbol, NoSymbol, /*100 0x64*/
+ NoSymbol, NoSymbol, NoSymbol, NoSymbol, NoSymbol, /*105 0x69*/
+ NoSymbol, NoSymbol, XK_F1, XK_F2, XK_F3, /*110 0x6E*/
+ XK_F4, XK_F5, XK_F6, XK_F7, XK_F8, /*115 0x73*/
+ XK_F9, XK_F10, XK_F11, XK_F12, XK_F13, /*120 0x78*/
+ XK_F14, XK_F15, XK_F16, XK_F17, XK_F18, /*125 0x7D*/
+ XK_F19, XK_F20, XK_F21, XK_F22, XK_F23, /*130 0x82*/
+ XK_F24, NoSymbol, NoSymbol, NoSymbol, NoSymbol, /*135 0x87*/
+ NoSymbol, NoSymbol, NoSymbol, NoSymbol, XK_Num_Lock, /*140 0x8C*/
+ XK_Scroll_Lock, NoSymbol, NoSymbol, NoSymbol, NoSymbol, /*145 0x91*/
NoSymbol, NoSymbol, NoSymbol, NoSymbol, NoSymbol, /*150 0x96*/
- NoSymbol, NoSymbol, NoSymbol, NoSymbol, NoSymbol, /*155 0x9b*/
- NoSymbol, NoSymbol, NoSymbol, NoSymbol, NoSymbol, /*160 0xa0*/
- NoSymbol, NoSymbol, NoSymbol, NoSymbol, NoSymbol, /*165 0xa5*/
- NoSymbol, NoSymbol, NoSymbol, XK_XF86AudioMute, XK_XF86AudioLowerVolume, /*170 0xaa*/
- XK_XF86AudioRaiseVolume, XK_XF86AudioNext, XK_XF86AudioPrev, XK_XF86AudioStop, XK_XF86AudioPlay /*175 0xaf*/
+ NoSymbol, NoSymbol, NoSymbol, NoSymbol, NoSymbol, /*155 0x9B*/
+ NoSymbol, NoSymbol, NoSymbol, NoSymbol, NoSymbol, /*160 0xA0*/
+ NoSymbol, NoSymbol, NoSymbol, NoSymbol, NoSymbol, /*165 0xA5*/
+ NoSymbol, NoSymbol, NoSymbol, XF86XK_AudioMute, XF86XK_AudioLowerVolume, /*170 0xAA*/
+ XF86XK_AudioRaiseVolume, XF86XK_AudioNext, XF86XK_AudioPrev, XF86XK_AudioStop, XF86XK_AudioPlay, /*175 0xAF*/
+ XF86XK_Mail, XF86XK_AudioMedia, XF86XK_Launch0, XF86XK_Launch1 /*180 0xB4*/
};
/*
@@ -95,8 +97,8 @@ TkpGetString(
* result. */
{
XKeyEvent *keyEv = &eventPtr->xkey;
- char buf[6];
int len;
+ char buf[6];
Tcl_DStringInit(dsPtr);
if (keyEv->send_event == -1) {
@@ -122,7 +124,7 @@ TkpGetString(
if (((keysym != NoSymbol) && (keysym > 0) && (keysym < 256))
|| (keysym == XK_Return) || (keysym == XK_Tab)) {
- len = Tcl_UniCharToUtf(keysym & 255, buf);
+ len = TkUniCharToUtf(keysym & 255, buf);
Tcl_DStringAppend(dsPtr, buf, len);
}
}
diff --git a/win/tkWinMenu.c b/win/tkWinMenu.c
index ce9a482..daf32ec 100644
--- a/win/tkWinMenu.c
+++ b/win/tkWinMenu.c
@@ -233,13 +233,13 @@ GetNewID(
TkMenuEntry *mePtr, /* The menu we are working with. */
WORD *menuIDPtr) /* The resulting id. */
{
- ThreadSpecificData *tsdPtr =
+ ThreadSpecificData *tsdPtr = (ThreadSpecificData *)
Tcl_GetThreadData(&dataKey, sizeof(ThreadSpecificData));
WORD curID = tsdPtr->lastCommandID;
while (1) {
Tcl_HashEntry *commandEntryPtr;
- int new;
+ int isNew;
/*
* Try the next ID number, taking care to wrap rather than stray
@@ -255,8 +255,8 @@ GetNewID(
}
commandEntryPtr = Tcl_CreateHashEntry(&tsdPtr->commandTable,
- INT2PTR(curID), &new);
- if (new) {
+ INT2PTR(curID), &isNew);
+ if (isNew) {
Tcl_SetHashValue(commandEntryPtr, mePtr);
*menuIDPtr = curID;
tsdPtr->lastCommandID = curID;
@@ -285,7 +285,7 @@ static void
FreeID(
WORD commandID)
{
- ThreadSpecificData *tsdPtr =
+ ThreadSpecificData *tsdPtr = (ThreadSpecificData *)
Tcl_GetThreadData(&dataKey, sizeof(ThreadSpecificData));
/*
@@ -328,7 +328,7 @@ TkpNewMenu(
HMENU winMenuHdl;
Tcl_HashEntry *hashEntryPtr;
int newEntry;
- ThreadSpecificData *tsdPtr =
+ ThreadSpecificData *tsdPtr = (ThreadSpecificData *)
Tcl_GetThreadData(&dataKey, sizeof(ThreadSpecificData));
winMenuHdl = CreatePopupMenu();
@@ -374,7 +374,7 @@ TkpDestroyMenu(
{
HMENU winMenuHdl = (HMENU) menuPtr->platformData;
const char *searchName;
- ThreadSpecificData *tsdPtr =
+ ThreadSpecificData *tsdPtr = (ThreadSpecificData *)
Tcl_GetThreadData(&dataKey, sizeof(ThreadSpecificData));
if (menuPtr->menuFlags & MENU_RECONFIGURE_PENDING) {
@@ -388,7 +388,7 @@ TkpDestroyMenu(
if (menuPtr->menuFlags & MENU_SYSTEM_MENU) {
TkMenuEntry *searchEntryPtr;
Tcl_HashTable *tablePtr = TkGetMenuHashTable(menuPtr->interp);
- char *menuName = Tcl_GetHashKey(tablePtr,
+ char *menuName = (char *)Tcl_GetHashKey(tablePtr,
menuPtr->menuRefPtr->hashEntryPtr);
/*
@@ -420,7 +420,7 @@ TkpDestroyMenu(
if (tsdPtr->menuHWND != NULL) {
Tcl_HashEntry *hashEntryPtr =
- Tcl_FindHashEntry(&tsdPtr->winMenuTable, (char *) winMenuHdl);
+ Tcl_FindHashEntry(&tsdPtr->winMenuTable, winMenuHdl);
if (hashEntryPtr != NULL) {
Tcl_DeleteHashEntry(hashEntryPtr);
@@ -492,16 +492,16 @@ GetEntryText(
char *itemText;
if (mePtr->type == TEAROFF_ENTRY) {
- itemText = ckalloc(sizeof("(Tear-off)"));
+ itemText = (char *)ckalloc(sizeof("(Tear-off)"));
strcpy(itemText, "(Tear-off)");
} else if (mePtr->imagePtr != NULL) {
- itemText = ckalloc(sizeof("(Image)"));
+ itemText = (char *)ckalloc(sizeof("(Image)"));
strcpy(itemText, "(Image)");
} else if (mePtr->bitmapPtr != NULL) {
- itemText = ckalloc(sizeof("(Pixmap)"));
+ itemText = (char *)ckalloc(sizeof("(Pixmap)"));
strcpy(itemText, "(Pixmap)");
} else if (mePtr->labelPtr == NULL || mePtr->labelLength == 0) {
- itemText = ckalloc(sizeof("( )"));
+ itemText = (char *)ckalloc(sizeof("( )"));
strcpy(itemText, "( )");
} else {
int i;
@@ -541,7 +541,7 @@ GetEntryText(
}
}
- itemText = ckalloc(Tcl_DStringLength(&itemString) + 1);
+ itemText = (char *)ckalloc(Tcl_DStringLength(&itemString) + 1);
strcpy(itemText, Tcl_DStringValue(&itemString));
Tcl_DStringFree(&itemString);
}
@@ -569,7 +569,7 @@ static void
ReconfigureWindowsMenu(
ClientData clientData) /* The menu we are rebuilding */
{
- TkMenu *menuPtr = clientData;
+ TkMenu *menuPtr = (TkMenu *)clientData;
TkMenuEntry *mePtr;
HMENU winMenuHdl = (HMENU) menuPtr->platformData;
char *itemText = NULL;
@@ -609,7 +609,8 @@ ReconfigureWindowsMenu(
itemText = GetEntryText(menuPtr, mePtr);
if ((menuPtr->menuType == MENUBAR)
|| (menuPtr->menuFlags & MENU_SYSTEM_MENU)) {
- Tcl_WinUtfToTChar(itemText, -1, &translatedText);
+ Tcl_DStringInit(&translatedText);
+ Tcl_UtfToWCharDString(itemText, -1, &translatedText);
lpNewItem = (LPCWSTR) Tcl_DStringValue(&translatedText);
flags |= MF_STRING;
} else {
@@ -728,7 +729,7 @@ ReconfigureWindowsMenu(
if ((menuPtr->menuType == MENUBAR)
&& (menuPtr->parentTopLevelPtr != NULL)) {
- HANDLE bar = TkWinGetWrapperWindow(menuPtr->parentTopLevelPtr);
+ HWND bar = TkWinGetWrapperWindow(menuPtr->parentTopLevelPtr);
if (bar) {
DrawMenuBar(bar);
@@ -759,7 +760,7 @@ ReconfigureWindowsMenu(
int
TkpPostMenu(
- Tcl_Interp *interp,
+ Tcl_Interp *dummy,
TkMenu *menuPtr,
int x, int y, int index)
{
@@ -769,8 +770,9 @@ TkpPostMenu(
POINT point;
Tk_Window parentWindow = Tk_Parent(menuPtr->tkwin);
int oldServiceMode = Tcl_GetServiceMode();
- ThreadSpecificData *tsdPtr =
+ ThreadSpecificData *tsdPtr = (ThreadSpecificData *)
Tcl_GetThreadData(&dataKey, sizeof(ThreadSpecificData));
+ (void)dummy;
tsdPtr->inPostMenu++;
CallPendingReconfigureImmediately(menuPtr);
@@ -869,13 +871,14 @@ TkpPostMenu(
int
TkpPostTearoffMenu(
- Tcl_Interp *interp, /* The interpreter of the menu */
+ Tcl_Interp *dummy, /* The interpreter of the menu */
TkMenu *menuPtr, /* The menu we are posting */
int x, int y, int index) /* The root X,Y coordinates where we are
* posting */
{
int vRootX, vRootY, vRootWidth, vRootHeight;
int result;
+ (void)dummy;
if (index >= menuPtr->numEntries) {
index = menuPtr->numEntries - 1;
@@ -1064,7 +1067,7 @@ TkWinEmbeddedMenuProc(
{
static int nIdles = 0;
LRESULT lResult = 1;
- ThreadSpecificData *tsdPtr =
+ ThreadSpecificData *tsdPtr = (ThreadSpecificData *)
Tcl_GetThreadData(&dataKey, sizeof(ThreadSpecificData));
switch(message) {
@@ -1140,15 +1143,16 @@ TkWinHandleMenuEvent(
int returnResult = 0;
TkMenu *menuPtr;
TkMenuEntry *mePtr;
- ThreadSpecificData *tsdPtr =
+ ThreadSpecificData *tsdPtr = (ThreadSpecificData *)
Tcl_GetThreadData(&dataKey, sizeof(ThreadSpecificData));
+ (void)phwnd;
switch (*pMessage) {
case WM_UNINITMENUPOPUP:
hashEntryPtr = Tcl_FindHashEntry(&tsdPtr->winMenuTable,
- (char *) *pwParam);
+ *pwParam);
if (hashEntryPtr != NULL) {
- menuPtr = Tcl_GetHashValue(hashEntryPtr);
+ menuPtr = (TkMenu *)Tcl_GetHashValue(hashEntryPtr);
if ((menuPtr->menuRefPtr != NULL)
&& (menuPtr->menuRefPtr->parentEntryPtr != NULL)) {
TkPostSubmenu(menuPtr->interp,
@@ -1160,10 +1164,10 @@ TkWinHandleMenuEvent(
case WM_INITMENU:
TkMenuInit();
hashEntryPtr = Tcl_FindHashEntry(&tsdPtr->winMenuTable,
- (char *) *pwParam);
+ *pwParam);
if (hashEntryPtr != NULL) {
tsdPtr->oldServiceMode = Tcl_SetServiceMode(TCL_SERVICE_ALL);
- menuPtr = Tcl_GetHashValue(hashEntryPtr);
+ menuPtr = (TkMenu *)Tcl_GetHashValue(hashEntryPtr);
tsdPtr->modalMenuPtr = menuPtr;
CallPendingReconfigureImmediately(menuPtr);
RecursivelyClearActiveMenu(menuPtr);
@@ -1199,7 +1203,7 @@ TkWinHandleMenuEvent(
if (hashEntryPtr == NULL) {
break;
}
- mePtr = Tcl_GetHashValue(hashEntryPtr);
+ mePtr = (TkMenuEntry *)Tcl_GetHashValue(hashEntryPtr);
if (mePtr != NULL) {
TkMenuReferences *menuRefPtr;
TkMenuEntry *parentEntryPtr;
@@ -1245,16 +1249,16 @@ TkWinHandleMenuEvent(
case WM_MENUCHAR: {
hashEntryPtr = Tcl_FindHashEntry(&tsdPtr->winMenuTable,
- (char *) *plParam);
+ *plParam);
if (hashEntryPtr != NULL) {
int i, len, underline;
Tcl_Obj *labelPtr;
- LPCWSTR wlabel;
+ WCHAR *wlabel;
int menuChar;
Tcl_DString ds;
*plResult = 0;
- menuPtr = Tcl_GetHashValue(hashEntryPtr);
+ menuPtr = (TkMenu *)Tcl_GetHashValue(hashEntryPtr);
/*
* Assume we have something directly convertable to Tcl_UniChar.
* True at least for wide systems.
@@ -1272,8 +1276,9 @@ TkWinHandleMenuEvent(
const char *src = Tcl_GetStringFromObj(labelPtr, &len);
Tcl_DStringFree(&ds);
- wlabel = (LPCWSTR) Tcl_WinUtfToTChar(src, len, &ds);
- if ((underline < len) && (menuChar ==
+ Tcl_DStringInit(&ds);
+ wlabel = Tcl_UtfToWCharDString(src, len, &ds);
+ if ((underline + 1 < len + 1) && (menuChar ==
Tcl_UniCharToUpper(wlabel[underline]))) {
*plResult = (2 << 16) | i;
returnResult = 1;
@@ -1325,7 +1330,7 @@ TkWinHandleMenuEvent(
}
mePtr = (TkMenuEntry *) itemPtr->itemData;
menuPtr = mePtr->menuPtr;
- twdPtr = ckalloc(sizeof(TkWinDrawable));
+ twdPtr = (TkWinDrawable *)ckalloc(sizeof(TkWinDrawable));
twdPtr->type = TWD_WINDC;
twdPtr->winDC.hdc = itemPtr->hDC;
@@ -1389,9 +1394,9 @@ TkWinHandleMenuEvent(
menuPtr = NULL;
if (*plParam != 0) {
hashEntryPtr = Tcl_FindHashEntry(&tsdPtr->winMenuTable,
- (char *) *plParam);
+ *plParam);
if (hashEntryPtr != NULL) {
- menuPtr = Tcl_GetHashValue(hashEntryPtr);
+ menuPtr = (TkMenu *)Tcl_GetHashValue(hashEntryPtr);
}
}
@@ -1416,7 +1421,7 @@ TkWinHandleMenuEvent(
hashEntryPtr = Tcl_FindHashEntry(&tsdPtr->commandTable,
INT2PTR(entryIndex));
if (hashEntryPtr != NULL) {
- mePtr = Tcl_GetHashValue(hashEntryPtr);
+ mePtr = (TkMenuEntry *)Tcl_GetHashValue(hashEntryPtr);
}
}
}
@@ -1505,7 +1510,7 @@ TkpSetWindowMenuBar(
TkMenu *menuPtr) /* The menu we are inserting */
{
HMENU winMenuHdl;
- ThreadSpecificData *tsdPtr =
+ ThreadSpecificData *tsdPtr = (ThreadSpecificData *)
Tcl_GetThreadData(&dataKey, sizeof(ThreadSpecificData));
if (menuPtr != NULL) {
@@ -1514,7 +1519,7 @@ TkpSetWindowMenuBar(
winMenuHdl = (HMENU) menuPtr->platformData;
hashEntryPtr = Tcl_FindHashEntry(&tsdPtr->winMenuTable,
- (char *) winMenuHdl);
+ winMenuHdl);
Tcl_DeleteHashEntry(hashEntryPtr);
DestroyMenu(winMenuHdl);
winMenuHdl = CreateMenu();
@@ -1553,6 +1558,10 @@ TkpSetMainMenubar(
const char *menuName) /* The name of the menu to put in front. If
* NULL, use the default menu bar. */
{
+ (void)interp;
+ (void)tkwin;
+ (void)menuName;
+
/*
* Nothing to do.
*/
@@ -1583,6 +1592,10 @@ GetMenuIndicatorGeometry(
int *widthPtr, /* The resulting width */
int *heightPtr) /* The resulting height */
{
+ (void)menuPtr;
+ (void)tkfont;
+ (void)fmPtr;
+
*heightPtr = indicatorDimensions[0];
if (mePtr->hideMargin) {
*widthPtr = 0;
@@ -1631,7 +1644,13 @@ GetMenuAccelGeometry(
{
*heightPtr = fmPtr->linespace;
if (mePtr->type == CASCADE_ENTRY) {
- *widthPtr = 0;
+ /*
+ * Cascade entries have no accelerator but do show an arrow. Set
+ * this field width to the width of the OBM_MNARROW system bitmap
+ * used to display the arrow. I couldn't find how to query the
+ * system for this value, therefore I resort to hardcoding.
+ */
+ *widthPtr = CASCADE_ARROW_WIDTH;
} else if ((menuPtr->menuType != MENUBAR) && (mePtr->accelPtr != NULL)) {
const char *accel = Tcl_GetString(mePtr->accelPtr);
@@ -1666,6 +1685,9 @@ GetTearoffEntryGeometry(
int *widthPtr, /* The resulting width */
int *heightPtr) /* The resulting height */
{
+ (void)mePtr;
+ (void)tkfont;
+
if (menuPtr->menuType != MASTER_MENU) {
*heightPtr = 0;
} else {
@@ -1699,6 +1721,10 @@ GetMenuSeparatorGeometry(
int *widthPtr, /* The resulting width */
int *heightPtr) /* The resulting height */
{
+ (void)menuPtr;
+ (void)mePtr;
+ (void)tkfont;
+
*widthPtr = 0;
*heightPtr = fmPtr->linespace - (2 * fmPtr->descent);
}
@@ -1812,6 +1838,11 @@ DrawMenuEntryIndicator(
int width,
int height)
{
+ (void)tkfont;
+ (void)fmPtr;
+ (void)width;
+ (void)height;
+
if ((mePtr->type == CHECK_BUTTON_ENTRY)
|| (mePtr->type == RADIO_BUTTON_ENTRY)) {
if (mePtr->indicatorOn && (mePtr->entryFlags & ENTRY_SELECTED)) {
@@ -1892,6 +1923,9 @@ DrawMenuEntryAccelerator(
int baseline;
int leftEdge = x + mePtr->indicatorSpace + mePtr->labelWidth;
const char *accel;
+ (void)activeBorder;
+ (void)width;
+ (void)height;
if (menuPtr->menuType == MENUBAR) {
return;
@@ -1909,7 +1943,7 @@ DrawMenuEntryAccelerator(
* Draw disabled 3D text highlight only with the Win95/98 look.
*/
- if (TkWinGetPlatformTheme() == TK_THEME_WIN_CLASSIC) {
+ if (TkWinGetPlatformTheme() != TK_THEME_WIN_XP) {
if ((mePtr->state == ENTRY_DISABLED)
&& (menuPtr->disabledFgPtr != NULL) && (accel != NULL)) {
COLORREF oldFgColor = gc->foreground;
@@ -1935,8 +1969,9 @@ DrawMenuEntryAccelerator(
* DrawMenuEntryArrow --
*
* This function draws the arrow bitmap on the right side of a menu
- * entry. This function is only used when drawing the arrow for a
- * disabled cascade menu.
+ * entry. This function is only used when drawing the arrow for:
+ * - a disabled cascade item
+ * - a cascade item in any state in a torn-off menu
*
* Results:
* None.
@@ -1965,11 +2000,23 @@ DrawMenuEntryArrow(
COLORREF oldFgColor;
COLORREF oldBgColor;
RECT rect;
+ (void)gc;
+ (void)activeBorder;
if (!drawArrow || (mePtr->type != CASCADE_ENTRY)) {
return;
}
+ /*
+ * Don't draw the arrow if a submenu is not attached to this
+ * cascade entry.
+ */
+
+ if ((mePtr->childMenuRefPtr == NULL)
+ || (mePtr->childMenuRefPtr->menuPtr == NULL)) {
+ return;
+ }
+
oldFgColor = gc->foreground;
oldBgColor = gc->background;
@@ -2035,6 +2082,10 @@ DrawMenuSeparator(
{
XPoint points[2];
Tk_3DBorder border;
+ (void)mePtr;
+ (void)gc;
+ (void)tkfont;
+ (void)fmPtr;
points[0].x = x;
points[0].y = y + height / 2;
@@ -2074,6 +2125,9 @@ DrawMenuUnderline(
int width, /* Width of entry */
int height) /* Height of entry */
{
+ (void)fmPtr;
+ (void)width;
+
if ((mePtr->underline >= 0) && (mePtr->labelPtr != NULL)) {
int len;
@@ -2113,7 +2167,7 @@ DrawMenuUnderline(
static int
TkWinMenuKeyObjCmd(
- ClientData clientData, /* Unused. */
+ ClientData dummy, /* Unused. */
Tcl_Interp *interp, /* Current interpreter. */
int objc, /* Number of arguments. */
Tcl_Obj *const objv[]) /* Argument objects. */
@@ -2125,6 +2179,7 @@ TkWinMenuKeyObjCmd(
TkWindow *winPtr;
KeySym keySym;
int i;
+ (void)dummy;
if (objc != 3) {
Tcl_WrongNumArgs(interp, 1, objv, "window keySym");
@@ -2257,8 +2312,7 @@ TkpInitializeMenuBindings(
*/
(void) Tcl_CreateObjCommand(interp, "tk::WinMenuKey",
- TkWinMenuKeyObjCmd,
- (ClientData) Tk_MainWindow(interp), (Tcl_CmdDeleteProc *) NULL);
+ TkWinMenuKeyObjCmd, Tk_MainWindow(interp), NULL);
(void) Tk_CreateBinding(interp, bindingTable, (ClientData) uid,
"<Alt_L>", "tk::WinMenuKey %W %N", 0);
@@ -2441,7 +2495,7 @@ DrawMenuEntryLabel(
int baseline = y + (height + fmPtr->ascent - fmPtr->descent) / 2;
const char *label = Tcl_GetString(mePtr->labelPtr);
- if (TkWinGetPlatformTheme() == TK_THEME_WIN_CLASSIC) {
+ if (TkWinGetPlatformTheme() != TK_THEME_WIN_XP) {
/*
* Win 95/98 systems draw disabled menu text with a 3D
* highlight, unless the menu item is highlighted,
@@ -2537,6 +2591,10 @@ DrawTearoffEntry(
XPoint points[2];
int segmentWidth, maxX;
Tk_3DBorder border;
+ (void)mePtr;
+ (void)gc;
+ (void)tkfont;
+ (void)fmPtr;
if (menuPtr->menuType != MASTER_MENU) {
return;
@@ -2580,7 +2638,7 @@ DrawTearoffEntry(
int
TkpConfigureMenuEntry(
- register TkMenuEntry *mePtr)/* Information about menu entry; may or may
+ TkMenuEntry *mePtr)/* Information about menu entry; may or may
* not already have values for some fields. */
{
ScheduleMenuReconfigure(mePtr->menuPtr);
@@ -2644,7 +2702,7 @@ TkpDrawMenuEntry(
menuDc = TkWinGetDrawableDC(menuPtr->display, menuDrawable, &dcState);
memDc = CreateCompatibleDC(menuDc);
- oldBitmap = SelectObject(memDc,
+ oldBitmap = (HBITMAP)SelectObject(memDc,
CreateCompatibleBitmap(menuDc, width, height) );
memWinDraw.type = TWD_WINDC;
@@ -3101,27 +3159,28 @@ static void
MenuSelectEvent(
TkMenu *menuPtr) /* the menu we have selected. */
{
- XVirtualEvent event;
+ union {XEvent general; XVirtualEvent virt;} event;
union {DWORD msgpos; POINTS point;} root;
- event.type = VirtualEvent;
- event.serial = menuPtr->display->request;
- event.send_event = 0;
- event.display = menuPtr->display;
+ memset(&event, 0, sizeof(event));
+ event.virt.type = VirtualEvent;
+ event.virt.serial = menuPtr->display->request;
+ event.virt.send_event = 0;
+ event.virt.display = menuPtr->display;
Tk_MakeWindowExist(menuPtr->tkwin);
- event.event = Tk_WindowId(menuPtr->tkwin);
- event.root = XRootWindow(menuPtr->display, 0);
- event.subwindow = None;
- event.time = TkpGetMS();
+ event.virt.event = Tk_WindowId(menuPtr->tkwin);
+ event.virt.root = XRootWindow(menuPtr->display, 0);
+ event.virt.subwindow = None;
+ event.virt.time = TkpGetMS();
root.msgpos = GetMessagePos();
- event.x_root = root.point.x;
- event.y_root = root.point.y;
- event.state = TkWinGetModifierState();
- event.same_screen = 1;
- event.name = Tk_GetUid("MenuSelect");
- event.user_data = NULL;
- Tk_QueueWindowEvent((XEvent *) &event, TCL_QUEUE_TAIL);
+ event.virt.x_root = root.point.x;
+ event.virt.y_root = root.point.y;
+ event.virt.state = TkWinGetModifierState();
+ event.virt.same_screen = 1;
+ event.virt.name = Tk_GetUid("MenuSelect");
+ event.virt.user_data = NULL;
+ Tk_QueueWindowEvent(&event.general, TCL_QUEUE_TAIL);
}
/*
@@ -3186,8 +3245,9 @@ HWND
Tk_GetMenuHWND(
Tk_Window tkwin)
{
- ThreadSpecificData *tsdPtr =
+ ThreadSpecificData *tsdPtr = (ThreadSpecificData *)
Tcl_GetThreadData(&dataKey, sizeof(ThreadSpecificData));
+ (void)tkwin;
TkMenuInit();
return tsdPtr->embeddedMenuHWND;
@@ -3211,8 +3271,10 @@ Tk_GetMenuHWND(
static void
MenuExitHandler(
- ClientData clientData) /* Not used */
+ ClientData dummy) /* Not used */
{
+ (void)dummy;
+
UnregisterClassW(MENU_CLASS_NAME, Tk_GetHINSTANCE());
UnregisterClassW(EMBEDDED_MENU_CLASS_NAME, Tk_GetHINSTANCE());
}
@@ -3236,10 +3298,11 @@ MenuExitHandler(
static void
MenuThreadExitHandler(
- ClientData clientData) /* Not used */
+ ClientData dummy) /* Not used */
{
- ThreadSpecificData *tsdPtr =
+ ThreadSpecificData *tsdPtr = (ThreadSpecificData *)
Tcl_GetThreadData(&dataKey, sizeof(ThreadSpecificData));
+ (void)dummy;
DestroyWindow(tsdPtr->menuHWND);
DestroyWindow(tsdPtr->embeddedMenuHWND);
@@ -3276,6 +3339,8 @@ TkWinGetMenuSystemDefault(
const char *className) /* The name of the option class. */
{
Tcl_Obj *valuePtr = NULL;
+ (void)tkwin;
+ (void)className;
if ((strcmp(dbName, "activeBorderWidth") == 0) ||
(strcmp(dbName, "borderWidth") == 0)) {
@@ -3324,7 +3389,6 @@ SetDefaults(
int padding;
#endif
} nc;
- OSVERSIONINFOW os;
/*
* Set all of the default options. The loop will terminate when we run out
@@ -3344,9 +3408,7 @@ SetDefaults(
nc.metrics.cbSize = sizeof(nc);
- os.dwOSVersionInfoSize = sizeof(OSVERSIONINFOW);
- GetVersionExW(&os);
- if (os.dwMajorVersion < 6) {
+ if (TkWinGetPlatformTheme() != TK_THEME_WIN_VISTA) {
nc.metrics.cbSize -= sizeof(int);
}
@@ -3479,7 +3541,7 @@ TkpMenuInit(void)
void
TkpMenuThreadInit(void)
{
- ThreadSpecificData *tsdPtr =
+ ThreadSpecificData *tsdPtr = (ThreadSpecificData *)
Tcl_GetThreadData(&dataKey, sizeof(ThreadSpecificData));
tsdPtr->menuHWND = CreateWindowW(MENU_CLASS_NAME, L"MenuWindow", WS_POPUP,
diff --git a/win/tkWinPointer.c b/win/tkWinPointer.c
index 896500c..06cbe67 100644
--- a/win/tkWinPointer.c
+++ b/win/tkWinPointer.c
@@ -362,10 +362,25 @@ void TkSetCursorPos(
int y)
{
INPUT input;
+ int xscreen = (int)(GetSystemMetrics(SM_CXSCREEN) - 1);
+ int yscreen = (int)(GetSystemMetrics(SM_CYSCREEN) - 1);
input.type = INPUT_MOUSE;
- input.mi.dx = x * (65535.0 / (GetSystemMetrics(SM_CXSCREEN) - 1));
- input.mi.dy = y * (65535.0 / (GetSystemMetrics(SM_CYSCREEN) - 1));
+ input.mi.dx = (x * 65535 + xscreen/2) / xscreen;
+ input.mi.dy = (y * 65535 + yscreen/2) / yscreen;
+
+ /*
+ * Horrible workaround here. There is a bug on Win 10: when warping to
+ * pixel (x = 0, y = 0) the SendInput() below just does not move the
+ * mouse pointer. However, as soon as dx or dy is non zero it moves as
+ * expected. Given the scaling factor of 65535 (see above),
+ * (dx = 1 , dy = 0) still means pixel (x = 0, y = 0).
+ * See ticket [69b48f427e].
+ */
+ if (input.mi.dx == 0 && input.mi.dy == 0) {
+ input.mi.dx = 1;
+ }
+
input.mi.mouseData = 0;
input.mi.dwFlags = MOUSEEVENTF_ABSOLUTE | MOUSEEVENTF_MOVE;
input.mi.time = 0;
diff --git a/win/tkWinSend.c b/win/tkWinSend.c
index 8fa1eaf..d1d6777 100644
--- a/win/tkWinSend.c
+++ b/win/tkWinSend.c
@@ -121,6 +121,8 @@ Tk_SetAppName(
* be globally unique. */
{
#ifndef TK_SEND_ENABLED_ON_WINDOWS
+ (void)tkwin;
+
/*
* Temporarily disabled for bug #858822
*/
@@ -163,7 +165,7 @@ Tk_SetAppName(
if (riPtr == NULL) {
LPUNKNOWN *objPtr;
- riPtr = ckalloc(sizeof(RegisteredInterp));
+ riPtr = (RegisteredInterp *)ckalloc(sizeof(RegisteredInterp));
memset(riPtr, 0, sizeof(RegisteredInterp));
riPtr->interp = interp;
@@ -213,6 +215,8 @@ TkGetInterpNames(
* lookup. */
{
#ifndef TK_SEND_ENABLED_ON_WINDOWS
+ (void)interp;
+ (void)tkwin;
/*
* Temporarily disabled for bug #858822
*/
@@ -254,7 +258,8 @@ TkGetInterpNames(
if (*p) {
Tcl_DString ds;
- Tcl_WinTCharToUtf((LPCTSTR)(p + 1), -1, &ds);
+ Tcl_DStringInit(&ds);
+ Tcl_WCharToUtfDString(p + 1, wcslen(p + 1), &ds);
result = Tcl_ListObjAppendElement(interp,
objList,
Tcl_NewStringObj(Tcl_DStringValue(&ds),
@@ -619,7 +624,8 @@ BuildMoniker(
LPMONIKER pmkItem = NULL;
Tcl_DString dString;
- Tcl_WinUtfToTChar(name, -1, &dString);
+ Tcl_DStringInit(&dString);
+ Tcl_UtfToWCharDString(name, -1, &dString);
hr = CreateFileMoniker((LPOLESTR)Tcl_DStringValue(&dString), &pmkItem);
Tcl_DStringFree(&dString);
if (SUCCEEDED(hr)) {
@@ -733,7 +739,7 @@ Send(
* object. */
Tcl_Interp *interp, /* The local interpreter. */
int async, /* Flag for the calling style. */
- ClientData clientData, /* The RegisteredInterp structure for this
+ ClientData dummy, /* The RegisteredInterp structure for this
* interp. */
int objc, /* Number of arguments to be sent. */
Tcl_Obj *const objv[]) /* The arguments to be sent. */
@@ -747,6 +753,7 @@ Send(
DISPID dispid;
Tcl_DString ds;
const char *src;
+ (void)dummy;
cmd = Tcl_ConcatObj(objc, objv);
@@ -761,8 +768,8 @@ Send(
vCmd.vt = VT_BSTR;
src = Tcl_GetString(cmd);
- Tcl_WinUtfToTChar(src, cmd->length, &ds);
- vCmd.bstrVal = SysAllocString((WCHAR *) Tcl_DStringValue(&ds));
+ Tcl_DStringInit(&ds);
+ vCmd.bstrVal = SysAllocString(Tcl_UtfToWCharDString(src, cmd->length, &ds));
Tcl_DStringFree(&ds);
dp.cArgs = 1;
@@ -784,8 +791,8 @@ Send(
ehr = VariantChangeType(&vResult, &vResult, 0, VT_BSTR);
if (SUCCEEDED(ehr)) {
- Tcl_WinTCharToUtf((LPCTSTR)vResult.bstrVal, SysStringLen(vResult.bstrVal) *
- sizeof (WCHAR), &ds);
+ Tcl_DStringInit(&ds);
+ Tcl_WCharToUtfDString(vResult.bstrVal, SysStringLen(vResult.bstrVal), &ds);
Tcl_DStringResult(interp, &ds);
}
@@ -797,8 +804,9 @@ Send(
if (hr == DISP_E_EXCEPTION && ei.bstrSource != NULL) {
Tcl_Obj *opError, *opErrorCode, *opErrorInfo;
- Tcl_WinTCharToUtf((LPCTSTR)ei.bstrSource, SysStringLen(ei.bstrSource) *
- sizeof (WCHAR), &ds);
+
+ Tcl_DStringInit(&ds);
+ Tcl_WCharToUtfDString(ei.bstrSource, SysStringLen(ei.bstrSource), &ds);
opError = Tcl_NewStringObj(Tcl_DStringValue(&ds),
Tcl_DStringLength(&ds));
Tcl_DStringFree(&ds);
@@ -869,14 +877,14 @@ TkWinSend_SetExcepInfo(
/* TODO: Handle failure to append */
src = Tcl_GetString(opError);
- Tcl_WinUtfToTChar(src, opError->length, &ds);
+ Tcl_DStringInit(&ds);
pExcepInfo->bstrDescription =
- SysAllocString((WCHAR *) Tcl_DStringValue(&ds));
+ SysAllocString(Tcl_UtfToWCharDString(src, opError->length, &ds));
Tcl_DStringFree(&ds);
src = Tcl_GetString(opErrorCode);
- Tcl_WinUtfToTChar(src, opErrorCode->length, &ds);
+ Tcl_DStringInit(&ds);
pExcepInfo->bstrSource =
- SysAllocString((WCHAR *) Tcl_DStringValue(&ds));
+ SysAllocString(Tcl_UtfToWCharDString(src, opErrorCode->length, &ds));
Tcl_DStringFree(&ds);
Tcl_DecrRefCount(opErrorCode);
pExcepInfo->scode = E_FAIL;
@@ -923,7 +931,7 @@ TkWinSend_QueueCommand(
TRACE("SendQueueCommand()\n");
- evPtr = ckalloc(sizeof(SendEvent));
+ evPtr = (SendEvent *)ckalloc(sizeof(SendEvent));
evPtr->header.proc = SendEventProc;
evPtr->header.nextPtr = NULL;
evPtr->interp = interp;
@@ -965,6 +973,7 @@ SendEventProc(
int flags)
{
SendEvent *evPtr = (SendEvent *)eventPtr;
+ (void)flags;
TRACE("SendEventProc\n");
diff --git a/win/tkWinSendCom.c b/win/tkWinSendCom.c
index 3f4f387..536c6c1 100644
--- a/win/tkWinSendCom.c
+++ b/win/tkWinSendCom.c
@@ -166,17 +166,17 @@ WinSendCom_QueryInterface(
void **ppvObject)
{
HRESULT hr = E_NOINTERFACE;
- TkWinSendCom *this = (TkWinSendCom *) This;
+ TkWinSendCom *sendCom = (TkWinSendCom *) This;
*ppvObject = NULL;
if (memcmp(riid, &IID_IUnknown, sizeof(IID)) == 0
|| memcmp(riid, &IID_IDispatch, sizeof(IID)) == 0) {
- *ppvObject = (void **) this;
- this->lpVtbl->AddRef(This);
+ *ppvObject = (void **) sendCom;
+ sendCom->lpVtbl->AddRef(This);
hr = S_OK;
} else if (memcmp(riid, &IID_ISupportErrorInfo, sizeof(IID)) == 0) {
- *ppvObject = (void **) (this + 1);
- this->lpVtbl2->AddRef((ISupportErrorInfo *) (this + 1));
+ *ppvObject = (void **) (sendCom + 1);
+ sendCom->lpVtbl2->AddRef((ISupportErrorInfo *) (sendCom + 1));
hr = S_OK;
}
return hr;
@@ -186,9 +186,9 @@ static STDMETHODIMP_(ULONG)
WinSendCom_AddRef(
IDispatch *This)
{
- TkWinSendCom *this = (TkWinSendCom*)This;
+ TkWinSendCom *sendCom = (TkWinSendCom*)This;
- return InterlockedIncrement(&this->refcount);
+ return InterlockedIncrement(&sendCom->refcount);
}
static STDMETHODIMP_(ULONG)
@@ -196,9 +196,9 @@ WinSendCom_Release(
IDispatch *This)
{
long r = 0;
- TkWinSendCom *this = (TkWinSendCom*)This;
+ TkWinSendCom *sendCom = (TkWinSendCom*)This;
- if ((r = InterlockedDecrement(&this->refcount)) == 0) {
+ if ((r = InterlockedDecrement(&sendCom->refcount)) == 0) {
TkWinSendCom_Destroy(This);
}
return r;
@@ -210,6 +210,7 @@ WinSendCom_GetTypeInfoCount(
UINT *pctinfo)
{
HRESULT hr = E_POINTER;
+ (void)This;
if (pctinfo != NULL) {
*pctinfo = 0;
@@ -226,6 +227,9 @@ WinSendCom_GetTypeInfo(
ITypeInfo **ppTI)
{
HRESULT hr = E_POINTER;
+ (void)This;
+ (void)iTInfo;
+ (void)lcid;
if (ppTI) {
*ppTI = NULL;
@@ -244,6 +248,10 @@ WinSendCom_GetIDsOfNames(
DISPID *rgDispId)
{
HRESULT hr = E_POINTER;
+ (void)This;
+ (void)riid;
+ (void)cNames;
+ (void)lcid;
if (rgDispId) {
hr = DISP_E_UNKNOWNNAME;
@@ -269,7 +277,9 @@ WinSendCom_Invoke(
UINT *puArgErr)
{
HRESULT hr = DISP_E_MEMBERNOTFOUND;
- TkWinSendCom *this = (TkWinSendCom*)This;
+ TkWinSendCom *sendCom = (TkWinSendCom*)This;
+ (void)riid;
+ (void)lcid;
switch (dispidMember) {
case TKWINSENDCOM_DISPID_SEND:
@@ -277,7 +287,7 @@ WinSendCom_Invoke(
if (pDispParams->cArgs != 1) {
hr = DISP_E_BADPARAMCOUNT;
} else {
- hr = Send(this, pDispParams->rgvarg[0], pvarResult,
+ hr = Send(sendCom, pDispParams->rgvarg[0], pvarResult,
pExcepInfo, puArgErr);
}
}
@@ -288,7 +298,7 @@ WinSendCom_Invoke(
if (pDispParams->cArgs != 1) {
hr = DISP_E_BADPARAMCOUNT;
} else {
- hr = Async(this, pDispParams->rgvarg[0], pExcepInfo, puArgErr);
+ hr = Async(sendCom, pDispParams->rgvarg[0], pExcepInfo, puArgErr);
}
}
break;
@@ -313,27 +323,27 @@ ISupportErrorInfo_QueryInterface(
REFIID riid,
void **ppvObject)
{
- TkWinSendCom *this = (TkWinSendCom *)(This - 1);
+ TkWinSendCom *sendCom = (TkWinSendCom *)(This - 1);
- return this->lpVtbl->QueryInterface((IDispatch *) this, riid, ppvObject);
+ return sendCom->lpVtbl->QueryInterface((IDispatch *) sendCom, riid, ppvObject);
}
static STDMETHODIMP_(ULONG)
ISupportErrorInfo_AddRef(
ISupportErrorInfo *This)
{
- TkWinSendCom *this = (TkWinSendCom *)(This - 1);
+ TkWinSendCom *sendCom = (TkWinSendCom *)(This - 1);
- return InterlockedIncrement(&this->refcount);
+ return InterlockedIncrement(&sendCom->refcount);
}
static STDMETHODIMP_(ULONG)
ISupportErrorInfo_Release(
ISupportErrorInfo *This)
{
- TkWinSendCom *this = (TkWinSendCom *)(This - 1);
+ TkWinSendCom *sendCom = (TkWinSendCom *)(This - 1);
- return this->lpVtbl->Release((IDispatch *) this);
+ return sendCom->lpVtbl->Release((IDispatch *) sendCom);
}
static STDMETHODIMP
@@ -341,7 +351,10 @@ ISupportErrorInfo_InterfaceSupportsErrorInfo(
ISupportErrorInfo *This,
REFIID riid)
{
- /*TkWinSendCom *this = (TkWinSendCom*)(This - 1);*/
+ (void)This;
+ (void)riid;
+
+ /*TkWinSendCom *sendCom = (TkWinSendCom*)(This - 1);*/
return S_OK; /* or S_FALSE */
}
@@ -371,6 +384,7 @@ Async(
HRESULT hr = S_OK;
VARIANT vCmd;
Tcl_DString ds;
+ (void)puArgErr;
VariantInit(&vCmd);
@@ -385,8 +399,8 @@ Async(
if (SUCCEEDED(hr) && obj->interp) {
Tcl_Obj *scriptPtr;
- Tcl_WinTCharToUtf((LPCTSTR)vCmd.bstrVal, SysStringLen(vCmd.bstrVal) *
- sizeof (WCHAR), &ds);
+ Tcl_DStringInit(&ds);
+ Tcl_WCharToUtfDString(vCmd.bstrVal, SysStringLen(vCmd.bstrVal), &ds);
scriptPtr =
Tcl_NewStringObj(Tcl_DStringValue(&ds), Tcl_DStringLength(&ds));
Tcl_DStringFree(&ds);
@@ -427,9 +441,10 @@ Send(
HRESULT hr = S_OK;
int result = TCL_OK;
VARIANT v;
- register Tcl_Interp *interp = obj->interp;
+ Tcl_Interp *interp = obj->interp;
Tcl_Obj *scriptPtr;
Tcl_DString ds;
+ (void)puArgErr;
if (interp == NULL) {
return S_OK;
@@ -440,8 +455,8 @@ Send(
return hr;
}
- Tcl_WinTCharToUtf((LPCTSTR)v.bstrVal, SysStringLen(v.bstrVal) *
- sizeof(WCHAR), &ds);
+ Tcl_DStringInit(&ds);
+ Tcl_WCharToUtfDString(v.bstrVal, SysStringLen(v.bstrVal), &ds);
scriptPtr = Tcl_NewStringObj(Tcl_DStringValue(&ds), Tcl_DStringLength(&ds));
Tcl_DStringFree(&ds);
Tcl_Preserve(interp);
@@ -457,8 +472,8 @@ Send(
pvResult->vt = VT_BSTR;
obj = Tcl_GetObjResult(interp);
src = Tcl_GetString(obj);
- Tcl_WinUtfToTChar(src, obj->length, &ds);
- pvResult->bstrVal = SysAllocString((WCHAR *) Tcl_DStringValue(&ds));
+ Tcl_DStringInit(&ds);
+ pvResult->bstrVal = SysAllocString(Tcl_UtfToWCharDString(src, obj->length, &ds));
Tcl_DStringFree(&ds);
}
if (result == TCL_ERROR) {
diff --git a/win/tkWinTest.c b/win/tkWinTest.c
index 6911334..a202ba5 100644
--- a/win/tkWinTest.c
+++ b/win/tkWinTest.c
@@ -67,15 +67,15 @@ TkplatformtestInit(
*/
Tcl_CreateObjCommand(interp, "testclipboard", TestclipboardObjCmd,
- (ClientData) Tk_MainWindow(interp), NULL);
+ Tk_MainWindow(interp), NULL);
Tcl_CreateObjCommand(interp, "testwinevent", TestwineventObjCmd,
- (ClientData) Tk_MainWindow(interp), NULL);
+ Tk_MainWindow(interp), NULL);
Tcl_CreateObjCommand(interp, "testfindwindow", TestfindwindowObjCmd,
- (ClientData) Tk_MainWindow(interp), NULL);
+ Tk_MainWindow(interp), NULL);
Tcl_CreateObjCommand(interp, "testgetwindowinfo", TestgetwindowinfoObjCmd,
- (ClientData) Tk_MainWindow(interp), NULL);
+ Tk_MainWindow(interp), NULL);
Tcl_CreateObjCommand(interp, "testwinlocale", TestwinlocaleObjCmd,
- (ClientData) Tk_MainWindow(interp), NULL);
+ Tk_MainWindow(interp), NULL);
return TCL_OK;
}
@@ -177,7 +177,8 @@ AppendSystemError(
} else {
char *msgPtr;
- Tcl_WinTCharToUtf((LPCTSTR)wMsgPtr, -1, &ds);
+ Tcl_DStringInit(&ds);
+ Tcl_WCharToUtfDString(wMsgPtr, wcslen(wMsgPtr), &ds);
LocalFree(wMsgPtr);
msgPtr = Tcl_DStringValue(&ds);
@@ -230,6 +231,8 @@ SetSelectionResult(
Tcl_Interp *interp,
const char *selection)
{
+ (void)dummy;
+
Tcl_AppendResult(interp, selection, NULL);
return TCL_OK;
}
@@ -241,7 +244,7 @@ TestclipboardObjCmd(
int objc, /* Number of arguments. */
Tcl_Obj *const objv[]) /* Argument values. */
{
- Tk_Window tkwin = (Tk_Window) clientData;
+ Tk_Window tkwin = (Tk_Window)clientData;
if (objc != 1) {
Tcl_WrongNumArgs(interp, 1, objv, NULL);
@@ -270,7 +273,7 @@ TestclipboardObjCmd(
static int
TestwineventObjCmd(
- ClientData clientData, /* Main window for application. */
+ ClientData dummy, /* Main window for application. */
Tcl_Interp *interp, /* Current interpreter. */
int objc, /* Number of arguments. */
Tcl_Obj *const objv[]) /* Argument strings. */
@@ -293,6 +296,7 @@ TestwineventObjCmd(
{WM_COMMAND, "WM_COMMAND"},
{-1, NULL}
};
+ (void)dummy;
if ((objc == 3) && (strcmp(Tcl_GetString(objv[1]), "debug") == 0)) {
int b;
@@ -375,20 +379,20 @@ TestwineventObjCmd(
case WM_SETTEXT: {
Tcl_DString ds;
- control = TestFindControl(hwnd, id);
- if (control == NULL) {
- Tcl_SetObjResult(interp,
- Tcl_ObjPrintf("Could not find control with id %d", id));
- return TCL_ERROR;
- }
+ control = TestFindControl(hwnd, id);
+ if (control == NULL) {
+ Tcl_SetObjResult(interp,
+ Tcl_ObjPrintf("Could not find control with id %d", id));
+ return TCL_ERROR;
+ }
Tcl_UtfToExternalDString(NULL, Tcl_GetString(objv[4]), -1, &ds);
- result = SendMessageA(control, WM_SETTEXT, 0,
- (LPARAM) Tcl_DStringValue(&ds));
+ result = SendMessageA(control, WM_SETTEXT, 0,
+ (LPARAM) Tcl_DStringValue(&ds));
Tcl_DStringFree(&ds);
if (result == 0) {
- Tcl_SetObjResult(interp, Tcl_NewStringObj("failed to send text to dialog: ", -1));
- AppendSystemError(interp, GetLastError());
- return TCL_ERROR;
+ Tcl_SetObjResult(interp, Tcl_NewStringObj("failed to send text to dialog: ", -1));
+ AppendSystemError(interp, GetLastError());
+ return TCL_ERROR;
}
break;
}
@@ -427,7 +431,7 @@ TestwineventObjCmd(
static int
TestfindwindowObjCmd(
- ClientData clientData, /* Main window for application. */
+ ClientData dummy, /* Main window for application. */
Tcl_Interp *interp, /* Current interpreter. */
int objc, /* Number of arguments. */
Tcl_Obj *const objv[]) /* Argument values. */
@@ -437,6 +441,7 @@ TestfindwindowObjCmd(
HWND hwnd = NULL;
int r = TCL_OK;
DWORD myPid;
+ (void)dummy;
Tcl_DStringInit(&classString);
Tcl_DStringInit(&titleString);
@@ -446,9 +451,11 @@ TestfindwindowObjCmd(
return TCL_ERROR;
}
- title = (LPCWSTR)Tcl_WinUtfToTChar(Tcl_GetString(objv[1]), -1, &titleString);
+ Tcl_DStringInit(&titleString);
+ title = Tcl_UtfToWCharDString(Tcl_GetString(objv[1]), -1, &titleString);
if (objc == 3) {
- windowClass = (LPCWSTR)Tcl_WinUtfToTChar(Tcl_GetString(objv[2]), -1, &classString);
+ Tcl_DStringInit(&classString);
+ windowClass = Tcl_UtfToWCharDString(Tcl_GetString(objv[2]), -1, &classString);
}
if (title[0] == 0)
title = NULL;
@@ -497,7 +504,7 @@ EnumChildrenProc(
static int
TestgetwindowinfoObjCmd(
- ClientData clientData,
+ ClientData dummy,
Tcl_Interp *interp,
int objc,
Tcl_Obj *const objv[])
@@ -508,6 +515,7 @@ TestgetwindowinfoObjCmd(
WCHAR buf[512];
int cch, cchBuf = 256;
Tcl_DString ds;
+ (void)dummy;
if (objc != 2) {
Tcl_WrongNumArgs(interp, 1, objv, "hwnd");
@@ -523,8 +531,8 @@ TestgetwindowinfoObjCmd(
AppendSystemError(interp, GetLastError());
return TCL_ERROR;
} else {
- Tcl_DString ds;
- Tcl_WinTCharToUtf((LPCTSTR)buf, -1, &ds);
+ Tcl_DStringInit(&ds);
+ Tcl_WCharToUtfDString(buf, wcslen(buf), &ds);
classObj = Tcl_NewStringObj(Tcl_DStringValue(&ds), Tcl_DStringLength(&ds));
Tcl_DStringFree(&ds);
}
@@ -535,7 +543,8 @@ TestgetwindowinfoObjCmd(
Tcl_NewWideIntObj(GetWindowLongPtrW(INT2PTR(hwnd), GWL_ID)));
cch = GetWindowTextW(INT2PTR(hwnd), buf, cchBuf);
- Tcl_WinTCharToUtf((LPCTSTR)buf, cch * sizeof (WCHAR), &ds);
+ Tcl_DStringInit(&ds);
+ Tcl_WCharToUtfDString(buf, cch, &ds);
textObj = Tcl_NewStringObj(Tcl_DStringValue(&ds), Tcl_DStringLength(&ds));
Tcl_DStringFree(&ds);
@@ -553,11 +562,13 @@ TestgetwindowinfoObjCmd(
static int
TestwinlocaleObjCmd(
- ClientData clientData, /* Main window for application. */
+ ClientData dummy, /* Main window for application. */
Tcl_Interp *interp, /* Current interpreter. */
int objc, /* Number of arguments. */
Tcl_Obj *const objv[]) /* Argument values. */
{
+ (void)dummy;
+
if (objc != 1) {
Tcl_WrongNumArgs(interp, 1, objv, NULL);
return TCL_ERROR;
diff --git a/win/tkWinWm.c b/win/tkWinWm.c
index 117b539..9307503 100644
--- a/win/tkWinWm.c
+++ b/win/tkWinWm.c
@@ -66,7 +66,7 @@ typedef struct ProtocolHandler {
} ProtocolHandler;
#define HANDLER_SIZE(cmdLength) \
- ((unsigned) ((Tk_Offset(ProtocolHandler, command) + 1) + cmdLength))
+ ((Tk_Offset(ProtocolHandler, command) + 1) + cmdLength)
/*
* Helper type passed via lParam to TkWmStackorderToplevelEnumProc
@@ -856,7 +856,7 @@ static int
InitWindowClass(
WinIconPtr titlebaricon)
{
- ThreadSpecificData *tsdPtr =
+ ThreadSpecificData *tsdPtr = (ThreadSpecificData *)
Tcl_GetThreadData(&dataKey, sizeof(ThreadSpecificData));
if (!tsdPtr->initialized) {
@@ -1117,7 +1117,7 @@ TkWinGetIcon(
{
WmInfo *wmPtr;
HICON icon;
- ThreadSpecificData *tsdPtr =
+ ThreadSpecificData *tsdPtr = (ThreadSpecificData *)
Tcl_GetThreadData(&dataKey, sizeof(ThreadSpecificData));
if (tsdPtr->iconPtr != NULL) {
@@ -1241,10 +1241,10 @@ ReadIconFromFile(
if (file == NULL) {
return NULL;
}
- Tcl_WinUtfToTChar(file, -1, &ds2);
- Tcl_DStringFree(&ds);
- res = (DWORD *)SHGetFileInfoW((WCHAR *)Tcl_DStringValue(&ds2), 0, &sfiSM,
+ Tcl_DStringInit(&ds2);
+ res = (DWORD *)SHGetFileInfoW(Tcl_UtfToWCharDString(file, -1, &ds2), 0, &sfiSM,
sizeof(SHFILEINFO), SHGFI_SMALLICON|SHGFI_ICON);
+ Tcl_DStringFree(&ds);
if (res != 0) {
SHFILEINFOW sfi;
@@ -1260,7 +1260,7 @@ ReadIconFromFile(
size = sizeof(BlockOfIconImages)
+ ((res != 0) ? sizeof(ICONIMAGE) : 0);
- lpIR = ckalloc(size);
+ lpIR = (BlockOfIconImagesPtr)ckalloc(size);
if (lpIR == NULL) {
if (res != 0) {
DestroyIcon(sfi.hIcon);
@@ -1291,7 +1291,7 @@ ReadIconFromFile(
Tcl_DStringFree(&ds2);
}
if (lpIR != NULL) {
- titlebaricon = ckalloc(sizeof(WinIconInstance));
+ titlebaricon = (WinIconPtr)ckalloc(sizeof(WinIconInstance));
titlebaricon->iconBlock = lpIR;
titlebaricon->refCount = 1;
}
@@ -1367,7 +1367,7 @@ GetIconFromPixmap(
return NULL;
}
- lpIR = ckalloc(sizeof(BlockOfIconImages));
+ lpIR = (BlockOfIconImagesPtr)ckalloc(sizeof(BlockOfIconImages));
if (lpIR == NULL) {
DestroyIcon(hIcon);
return NULL;
@@ -1388,7 +1388,7 @@ GetIconFromPixmap(
lpIR->IconImages[0].lpXOR = 0;
lpIR->IconImages[0].lpAND = 0;
- titlebaricon = ckalloc(sizeof(WinIconInstance));
+ titlebaricon = (WinIconPtr)ckalloc(sizeof(WinIconInstance));
titlebaricon->iconBlock = lpIR;
titlebaricon->refCount = 1;
return titlebaricon;
@@ -1593,7 +1593,7 @@ ReadIconOrCursorFromFile(
* Allocate memory for the resource structure
*/
- lpIR = ckalloc(sizeof(BlockOfIconImages));
+ lpIR = (BlockOfIconImagesPtr)ckalloc(sizeof(BlockOfIconImages));
/*
* Read in the header
@@ -1611,14 +1611,14 @@ ReadIconOrCursorFromFile(
* Adjust the size of the struct to account for the images.
*/
- lpIR = ckrealloc(lpIR, sizeof(BlockOfIconImages)
+ lpIR = (BlockOfIconImagesPtr)ckrealloc(lpIR, sizeof(BlockOfIconImages)
+ (lpIR->nNumImages - 1) * sizeof(ICONIMAGE));
/*
* Allocate enough memory for the icon directory entries.
*/
- lpIDE = ckalloc(lpIR->nNumImages * sizeof(ICONDIRENTRY));
+ lpIDE = (LPICONDIRENTRY)ckalloc(lpIR->nNumImages * sizeof(ICONDIRENTRY));
/*
* Read in the icon directory entries.
@@ -1653,7 +1653,7 @@ ReadIconOrCursorFromFile(
* Allocate memory for the resource.
*/
- lpIR->IconImages[i].lpBits = ckalloc(lpIDE[i].dwBytesInRes);
+ lpIR->IconImages[i].lpBits = (LPBYTE)ckalloc(lpIDE[i].dwBytesInRes);
lpIR->IconImages[i].dwNumBytes = lpIDE[i].dwBytesInRes;
/*
@@ -1732,7 +1732,7 @@ static TkWindow *
GetTopLevel(
HWND hwnd)
{
- ThreadSpecificData *tsdPtr =
+ ThreadSpecificData *tsdPtr = (ThreadSpecificData *)
Tcl_GetThreadData(&dataKey, sizeof(ThreadSpecificData));
/*
@@ -1769,7 +1769,7 @@ SetLimits(
HWND hwnd,
MINMAXINFO *info)
{
- register WmInfo *wmPtr;
+ WmInfo *wmPtr;
int maxWidth, maxHeight;
int minWidth, minHeight;
int base;
@@ -1874,7 +1874,7 @@ TkWinWmCleanup(
}
initialized = 0;
- tsdPtr = Tcl_GetThreadData(&dataKey, sizeof(ThreadSpecificData));
+ tsdPtr = (ThreadSpecificData *)Tcl_GetThreadData(&dataKey, sizeof(ThreadSpecificData));
if (!tsdPtr->initialized) {
return;
@@ -1905,7 +1905,7 @@ void
TkWmNewWindow(
TkWindow *winPtr) /* Newly-created top-level window. */
{
- register WmInfo *wmPtr = ckalloc(sizeof(WmInfo));
+ WmInfo *wmPtr = (WmInfo *)ckalloc(sizeof(WmInfo));
/*
* Initialize full structure, then set what isn't NULL
@@ -1990,7 +1990,7 @@ static void
UpdateWrapper(
TkWindow *winPtr) /* Top-level window to redecorate. */
{
- register WmInfo *wmPtr = winPtr->wmInfoPtr;
+ WmInfo *wmPtr = winPtr->wmInfoPtr;
HWND parentHWND, oldWrapper = wmPtr->wrapper;
HWND child, nextHWND, focusHWND;
int x, y, width, height, state;
@@ -1999,7 +1999,7 @@ UpdateWrapper(
HICON hBigIcon = NULL;
Tcl_DString titleString;
int *childStateInfo = NULL;
- ThreadSpecificData *tsdPtr =
+ ThreadSpecificData *tsdPtr = (ThreadSpecificData *)
Tcl_GetThreadData(&dataKey, sizeof(ThreadSpecificData));
if (winPtr->window == None) {
@@ -2121,7 +2121,8 @@ UpdateWrapper(
*/
tsdPtr->createWindow = winPtr;
- Tcl_WinUtfToTChar(((wmPtr->title != NULL) ?
+ Tcl_DStringInit(&titleString);
+ Tcl_UtfToWCharDString(((wmPtr->title != NULL) ?
wmPtr->title : winPtr->nameUid), -1, &titleString);
wmPtr->wrapper = CreateWindowExW(wmPtr->exStyle,
@@ -2208,7 +2209,7 @@ UpdateWrapper(
WmInfo *wmPtr2;
- childStateInfo = ckalloc(wmPtr->numTransients * sizeof(int));
+ childStateInfo = (int *)ckalloc(wmPtr->numTransients * sizeof(int));
state = 0;
for (wmPtr2 = winPtr->dispPtr->firstWmPtr; wmPtr2 != NULL;
wmPtr2 = wmPtr2->nextPtr) {
@@ -2354,8 +2355,8 @@ TkWmMapWindow(
TkWindow *winPtr) /* Top-level window that's about to be
* mapped. */
{
- register WmInfo *wmPtr = winPtr->wmInfoPtr;
- ThreadSpecificData *tsdPtr =
+ WmInfo *wmPtr = winPtr->wmInfoPtr;
+ ThreadSpecificData *tsdPtr = (ThreadSpecificData *)
Tcl_GetThreadData(&dataKey, sizeof(ThreadSpecificData));
if (!tsdPtr->initialized) {
@@ -2580,7 +2581,7 @@ void
TkWmDeadWindow(
TkWindow *winPtr) /* Top-level window that's being deleted. */
{
- register WmInfo *wmPtr = winPtr->wmInfoPtr;
+ WmInfo *wmPtr = winPtr->wmInfoPtr;
WmInfo *wmPtr2;
if (wmPtr == NULL) {
@@ -2594,7 +2595,7 @@ TkWmDeadWindow(
if (winPtr->dispPtr->firstWmPtr == wmPtr) {
winPtr->dispPtr->firstWmPtr = wmPtr->nextPtr;
} else {
- register WmInfo *prevPtr;
+ WmInfo *prevPtr;
for (prevPtr = winPtr->dispPtr->firstWmPtr; ;
prevPtr = prevPtr->nextPtr) {
@@ -2741,6 +2742,8 @@ void
TkWmSetClass(
TkWindow *winPtr) /* Newly-created top-level window. */
{
+ (void)winPtr;
+
/* Do nothing */
return;
}
@@ -2762,7 +2765,6 @@ TkWmSetClass(
*----------------------------------------------------------------------
*/
- /* ARGSUSED */
int
Tk_WmObjCmd(
ClientData clientData, /* Main window associated with interpreter. */
@@ -2770,7 +2772,7 @@ Tk_WmObjCmd(
int objc, /* Number of arguments. */
Tcl_Obj *const objv[]) /* Argument objects. */
{
- Tk_Window tkwin = clientData;
+ Tk_Window tkwin = (Tk_Window)clientData;
static const char *const optionStrings[] = {
"aspect", "attributes", "client", "colormapwindows",
"command", "deiconify", "focusmodel", "forget", "frame",
@@ -2796,7 +2798,7 @@ Tk_WmObjCmd(
WMOPT_WITHDRAW
};
int index;
- size_t length;
+ int length;
const char *argv1;
TkWindow *winPtr, **winPtrPtr = &winPtr;
TkDisplay *dispPtr = ((TkWindow *) tkwin)->dispPtr;
@@ -2807,8 +2809,7 @@ Tk_WmObjCmd(
return TCL_ERROR;
}
- argv1 = Tcl_GetString(objv[1]);
- length = objv[1]->length;
+ argv1 = Tcl_GetStringFromObj(objv[1], &length);
if ((argv1[0] == 't') && !strncmp(argv1, "tracing", length)
&& (length >= 3)) {
int wmTracing;
@@ -2951,8 +2952,9 @@ WmAspectCmd(
int objc, /* Number of arguments. */
Tcl_Obj *const objv[]) /* Argument objects. */
{
- register WmInfo *wmPtr = winPtr->wmInfoPtr;
+ WmInfo *wmPtr = winPtr->wmInfoPtr;
int numer1, denom1, numer2, denom2;
+ (void)tkwin;
if ((objc != 3) && (objc != 7)) {
Tcl_WrongNumArgs(interp, 2, objv,
@@ -3021,11 +3023,11 @@ WmAttributesCmd(
int objc, /* Number of arguments. */
Tcl_Obj *const objv[]) /* Argument objects. */
{
- register WmInfo *wmPtr = winPtr->wmInfoPtr;
+ WmInfo *wmPtr = winPtr->wmInfoPtr;
LONG style, exStyle, styleBit, *stylePtr = NULL;
const char *string;
int i, boolean;
- size_t length;
+ int length;
int config_fullscreen = 0, updatewrapper = 0;
int fullscreen_attr_changed = 0, fullscreen_attr = 0;
@@ -3072,8 +3074,7 @@ WmAttributesCmd(
return TCL_OK;
}
for (i = 3; i < objc; i += 2) {
- string = Tcl_GetString(objv[i]);
- length = objv[i]->length;
+ string = Tcl_GetStringFromObj(objv[i], &length);
if ((length < 2) || (string[0] != '-')) {
goto configArgs;
}
@@ -3141,9 +3142,8 @@ WmAttributesCmd(
}
wmPtr->alpha = dval;
} else { /* -transparentcolor */
- const char *crefstr = Tcl_GetString(objv[i+1]);
+ const char *crefstr = Tcl_GetStringFromObj(objv[i+1], &length);
- length = objv[i+1]->length;
if (length == 0) {
/* reset to no transparent color */
if (wmPtr->crefObj) {
@@ -3319,9 +3319,10 @@ WmClientCmd(
int objc, /* Number of arguments. */
Tcl_Obj *const objv[]) /* Argument objects. */
{
- register WmInfo *wmPtr = winPtr->wmInfoPtr;
+ WmInfo *wmPtr = winPtr->wmInfoPtr;
const char *argv3;
- size_t length;
+ int length;
+ (void)tkwin;
if ((objc != 3) && (objc != 4)) {
Tcl_WrongNumArgs(interp, 2, objv, "window ?name?");
@@ -3334,8 +3335,7 @@ WmClientCmd(
}
return TCL_OK;
}
- argv3 = Tcl_GetString(objv[3]);
- length = objv[3]->length;
+ argv3 = Tcl_GetStringFromObj(objv[3], &length);
if (argv3[0] == 0) {
if (wmPtr->clientMachine != NULL) {
ckfree(wmPtr->clientMachine);
@@ -3350,7 +3350,7 @@ WmClientCmd(
if (wmPtr->clientMachine != NULL) {
ckfree(wmPtr->clientMachine);
}
- wmPtr->clientMachine = ckalloc(length + 1);
+ wmPtr->clientMachine = (char *)ckalloc(length + 1);
memcpy(wmPtr->clientMachine, argv3, length + 1);
if (!(wmPtr->flags & WM_NEVER_MAPPED)) {
XTextProperty textProp;
@@ -3390,7 +3390,7 @@ WmColormapwindowsCmd(
int objc, /* Number of arguments. */
Tcl_Obj *const objv[]) /* Argument objects. */
{
- register WmInfo *wmPtr = winPtr->wmInfoPtr;
+ WmInfo *wmPtr = winPtr->wmInfoPtr;
TkWindow **cmapList, *winPtr2, **winPtr2Ptr = &winPtr2;
int i, windowObjc, gotToplevel;
Tcl_Obj **windowObjv, *resultObj;
@@ -3417,7 +3417,7 @@ WmColormapwindowsCmd(
!= TCL_OK) {
return TCL_ERROR;
}
- cmapList = ckalloc((windowObjc + 1) * sizeof(TkWindow*));
+ cmapList = (TkWindow**)ckalloc((windowObjc + 1) * sizeof(TkWindow*));
gotToplevel = 0;
for (i = 0; i < windowObjc; i++) {
if (TkGetWindowFromObj(interp, tkwin, windowObjv[i],
@@ -3484,10 +3484,11 @@ WmCommandCmd(
int objc, /* Number of arguments. */
Tcl_Obj *const objv[]) /* Argument objects. */
{
- register WmInfo *wmPtr = winPtr->wmInfoPtr;
+ WmInfo *wmPtr = winPtr->wmInfoPtr;
const char *argv3;
int cmdArgc;
const char **cmdArgv;
+ (void)tkwin;
if ((objc != 3) && (objc != 4)) {
Tcl_WrongNumArgs(interp, 2, objv, "window ?value?");
@@ -3553,7 +3554,8 @@ WmDeiconifyCmd(
int objc, /* Number of arguments. */
Tcl_Obj *const objv[]) /* Argument objects. */
{
- register WmInfo *wmPtr = winPtr->wmInfoPtr;
+ WmInfo *wmPtr = winPtr->wmInfoPtr;
+ (void)tkwin;
if (objc != 3) {
Tcl_WrongNumArgs(interp, 2, objv, "window");
@@ -3605,7 +3607,7 @@ WmFocusmodelCmd(
int objc, /* Number of arguments. */
Tcl_Obj *const objv[]) /* Argument objects. */
{
- register WmInfo *wmPtr = winPtr->wmInfoPtr;
+ WmInfo *wmPtr = winPtr->wmInfoPtr;
static const char *const optionStrings[] = {
"active", "passive", NULL
};
@@ -3613,6 +3615,7 @@ WmFocusmodelCmd(
OPT_ACTIVE, OPT_PASSIVE
};
int index;
+ (void)tkwin;
if ((objc != 3) && (objc != 4)) {
Tcl_WrongNumArgs(interp, 2, objv, "window ?active|passive?");
@@ -3657,11 +3660,15 @@ static int
WmForgetCmd(
Tk_Window tkwin, /* Main window of the application. */
TkWindow *winPtr, /* Toplevel or Frame to work with */
- Tcl_Interp *interp, /* Current interpreter. */
+ Tcl_Interp *dummy, /* Current interpreter. */
int objc, /* Number of arguments. */
Tcl_Obj *const objv[]) /* Argument objects. */
{
- register Tk_Window frameWin = (Tk_Window) winPtr;
+ Tk_Window frameWin = (Tk_Window) winPtr;
+ (void)tkwin;
+ (void)dummy;
+ (void)objc;
+ (void)objv;
if (Tk_IsTopLevel(frameWin)) {
Tk_UnmapWindow(frameWin);
@@ -3709,9 +3716,10 @@ WmFrameCmd(
int objc, /* Number of arguments. */
Tcl_Obj *const objv[]) /* Argument objects. */
{
- register WmInfo *wmPtr = winPtr->wmInfoPtr;
+ WmInfo *wmPtr = winPtr->wmInfoPtr;
HWND hwnd;
char buf[TCL_INTEGER_SPACE];
+ (void)tkwin;
if (objc != 3) {
Tcl_WrongNumArgs(interp, 2, objv, "window");
@@ -3754,10 +3762,11 @@ WmGeometryCmd(
int objc, /* Number of arguments. */
Tcl_Obj *const objv[]) /* Argument objects. */
{
- register WmInfo *wmPtr = winPtr->wmInfoPtr;
+ WmInfo *wmPtr = winPtr->wmInfoPtr;
char xSign, ySign;
int width, height;
const char *argv3;
+ (void)tkwin;
if ((objc != 3) && (objc != 4)) {
Tcl_WrongNumArgs(interp, 2, objv, "window ?newGeometry?");
@@ -3822,8 +3831,9 @@ WmGridCmd(
int objc, /* Number of arguments. */
Tcl_Obj *const objv[]) /* Argument objects. */
{
- register WmInfo *wmPtr = winPtr->wmInfoPtr;
+ WmInfo *wmPtr = winPtr->wmInfoPtr;
int reqWidth, reqHeight, widthInc, heightInc;
+ (void)tkwin;
if ((objc != 3) && (objc != 7)) {
Tcl_WrongNumArgs(interp, 2, objv,
@@ -3920,10 +3930,10 @@ WmGroupCmd(
int objc, /* Number of arguments. */
Tcl_Obj *const objv[]) /* Argument objects. */
{
- register WmInfo *wmPtr = winPtr->wmInfoPtr;
+ WmInfo *wmPtr = winPtr->wmInfoPtr;
Tk_Window tkwin2;
const char *argv3;
- size_t length;
+ int length;
if ((objc != 3) && (objc != 4)) {
Tcl_WrongNumArgs(interp, 2, objv, "window ?pathName?");
@@ -3935,8 +3945,7 @@ WmGroupCmd(
}
return TCL_OK;
}
- argv3 = Tcl_GetString(objv[3]);
- length = objv[3]->length;
+ argv3 = Tcl_GetStringFromObj(objv[3], &length);
if (*argv3 == '\0') {
wmPtr->hints.flags &= ~WindowGroupHint;
if (wmPtr->leaderName != NULL) {
@@ -3953,7 +3962,7 @@ WmGroupCmd(
}
wmPtr->hints.window_group = Tk_WindowId(tkwin2);
wmPtr->hints.flags |= WindowGroupHint;
- wmPtr->leaderName = ckalloc(length + 1);
+ wmPtr->leaderName = (char *)ckalloc(length + 1);
memcpy(wmPtr->leaderName, argv3, length + 1);
}
return TCL_OK;
@@ -3984,9 +3993,10 @@ WmIconbitmapCmd(
int objc, /* Number of arguments. */
Tcl_Obj *const objv[]) /* Argument objects. */
{
- register WmInfo *wmPtr = winPtr->wmInfoPtr;
+ WmInfo *wmPtr = winPtr->wmInfoPtr;
TkWindow *useWinPtr = winPtr; /* window to apply to (NULL if -default) */
const char *string;
+ (void)tkwin;
if ((objc < 3) || (objc > 5)) {
Tcl_WrongNumArgs(interp, 2, objv, "window ?-default? ?image?");
@@ -4120,7 +4130,9 @@ WmIconifyCmd(
int objc, /* Number of arguments. */
Tcl_Obj *const objv[]) /* Argument objects. */
{
- register WmInfo *wmPtr = winPtr->wmInfoPtr;
+ WmInfo *wmPtr = winPtr->wmInfoPtr;
+ (void)tkwin;
+
if (objc != 3) {
Tcl_WrongNumArgs(interp, 2, objv, "window");
return TCL_ERROR;
@@ -4185,7 +4197,7 @@ WmIconmaskCmd(
int objc, /* Number of arguments. */
Tcl_Obj *const objv[]) /* Argument objects. */
{
- register WmInfo *wmPtr = winPtr->wmInfoPtr;
+ WmInfo *wmPtr = winPtr->wmInfoPtr;
Pixmap pixmap;
const char *argv3;
@@ -4243,9 +4255,10 @@ WmIconnameCmd(
int objc, /* Number of arguments. */
Tcl_Obj *const objv[]) /* Argument objects. */
{
- register WmInfo *wmPtr = winPtr->wmInfoPtr;
+ WmInfo *wmPtr = winPtr->wmInfoPtr;
const char *argv3;
- size_t length;
+ int length;
+ (void)tkwin;
if (objc > 4) {
Tcl_WrongNumArgs(interp, 2, objv, "window ?newName?");
@@ -4259,9 +4272,8 @@ WmIconnameCmd(
if (wmPtr->iconName != NULL) {
ckfree(wmPtr->iconName);
}
- argv3 = Tcl_GetString(objv[3]);
- length = objv[3]->length;
- wmPtr->iconName = ckalloc(length + 1);
+ argv3 = Tcl_GetStringFromObj(objv[3], &length);
+ wmPtr->iconName = (char *)ckalloc(length + 1);
memcpy(wmPtr->iconName, argv3, length + 1);
if (!(wmPtr->flags & WM_NEVER_MAPPED)) {
XSetIconName(winPtr->display, winPtr->window, wmPtr->iconName);
@@ -4307,6 +4319,7 @@ WmIconphotoCmd(
unsigned size;
BITMAPINFO bmInfo;
ICONINFO iconInfo;
+ (void)tkwin;
if (objc < 4) {
Tcl_WrongNumArgs(interp, 2, objv,
@@ -4344,7 +4357,7 @@ WmIconphotoCmd(
*/
size = sizeof(BlockOfIconImages) + (sizeof(ICONIMAGE) * (objc-startObj-1));
- lpIR = attemptckalloc(size);
+ lpIR = (BlockOfIconImagesPtr)attemptckalloc(size);
if (lpIR == NULL) {
return TCL_ERROR;
}
@@ -4384,9 +4397,9 @@ WmIconphotoCmd(
if (!iconInfo.hbmColor) {
ckfree(lpIR);
Tcl_SetObjResult(interp, Tcl_ObjPrintf(
- "failed to create color bitmap for \"%s\"",
+ "failed to create an iconphoto with image \"%s\"",
Tcl_GetString(objv[i])));
- Tcl_SetErrorCode(interp, "TK", "WM", "ICONPHOTO", "BITMAP", NULL);
+ Tcl_SetErrorCode(interp, "TK", "WM", "ICONPHOTO", "IMAGE", NULL);
return TCL_ERROR;
}
@@ -4449,7 +4462,7 @@ WmIconphotoCmd(
lpIR->IconImages[i-startObj].hIcon = hIcon;
}
- titlebaricon = ckalloc(sizeof(WinIconInstance));
+ titlebaricon = (WinIconPtr)ckalloc(sizeof(WinIconInstance));
titlebaricon->iconBlock = lpIR;
titlebaricon->refCount = 1;
if (WinSetIcon(interp, titlebaricon, (Tk_Window) useWinPtr) != TCL_OK) {
@@ -4488,8 +4501,9 @@ WmIconpositionCmd(
int objc, /* Number of arguments. */
Tcl_Obj *const objv[]) /* Argument objects. */
{
- register WmInfo *wmPtr = winPtr->wmInfoPtr;
+ WmInfo *wmPtr = winPtr->wmInfoPtr;
int x, y;
+ (void)tkwin;
if ((objc != 3) && (objc != 5)) {
Tcl_WrongNumArgs(interp, 2, objv, "window ?x y?");
@@ -4544,7 +4558,7 @@ WmIconwindowCmd(
int objc, /* Number of arguments. */
Tcl_Obj *const objv[]) /* Argument objects. */
{
- register WmInfo *wmPtr = winPtr->wmInfoPtr;
+ WmInfo *wmPtr = winPtr->wmInfoPtr;
Tk_Window tkwin2;
WmInfo *wmPtr2;
XSetWindowAttributes atts;
@@ -4654,8 +4668,11 @@ WmManageCmd(
int objc, /* Number of arguments. */
Tcl_Obj *const objv[]) /* Argument objects. */
{
- register Tk_Window frameWin = (Tk_Window) winPtr;
- register WmInfo *wmPtr = winPtr->wmInfoPtr;
+ Tk_Window frameWin = (Tk_Window) winPtr;
+ WmInfo *wmPtr = winPtr->wmInfoPtr;
+ (void)tkwin;
+ (void)objc;
+ (void)objv;
if (!Tk_IsTopLevel(frameWin)) {
if (!Tk_IsManageable(frameWin)) {
@@ -4708,8 +4725,9 @@ WmMaxsizeCmd(
int objc, /* Number of arguments. */
Tcl_Obj *const objv[]) /* Argument objects. */
{
- register WmInfo *wmPtr = winPtr->wmInfoPtr;
+ WmInfo *wmPtr = winPtr->wmInfoPtr;
int width, height;
+ (void)tkwin;
if ((objc != 3) && (objc != 5)) {
Tcl_WrongNumArgs(interp, 2, objv, "window ?width height?");
@@ -4759,8 +4777,9 @@ WmMinsizeCmd(
int objc, /* Number of arguments. */
Tcl_Obj *const objv[]) /* Argument objects. */
{
- register WmInfo *wmPtr = winPtr->wmInfoPtr;
+ WmInfo *wmPtr = winPtr->wmInfoPtr;
int width, height;
+ (void)tkwin;
if ((objc != 3) && (objc != 5)) {
Tcl_WrongNumArgs(interp, 2, objv, "window ?width height?");
@@ -4810,9 +4829,10 @@ WmOverrideredirectCmd(
int objc, /* Number of arguments. */
Tcl_Obj *const objv[]) /* Argument objects. */
{
- register WmInfo *wmPtr = winPtr->wmInfoPtr;
+ WmInfo *wmPtr = winPtr->wmInfoPtr;
int boolean, curValue;
XSetWindowAttributes atts;
+ (void)tkwin;
if ((objc != 3) && (objc != 4)) {
Tcl_WrongNumArgs(interp, 2, objv, "window ?boolean?");
@@ -4882,7 +4902,7 @@ WmPositionfromCmd(
int objc, /* Number of arguments. */
Tcl_Obj *const objv[]) /* Argument objects. */
{
- register WmInfo *wmPtr = winPtr->wmInfoPtr;
+ WmInfo *wmPtr = winPtr->wmInfoPtr;
static const char *const optionStrings[] = {
"program", "user", NULL
};
@@ -4890,6 +4910,7 @@ WmPositionfromCmd(
OPT_PROGRAM, OPT_USER
};
int index;
+ (void)tkwin;
if ((objc != 3) && (objc != 4)) {
Tcl_WrongNumArgs(interp, 2, objv, "window ?user/program?");
@@ -4950,12 +4971,13 @@ WmProtocolCmd(
int objc, /* Number of arguments. */
Tcl_Obj *const objv[]) /* Argument objects. */
{
- register WmInfo *wmPtr = winPtr->wmInfoPtr;
- register ProtocolHandler *protPtr, *prevPtr;
+ WmInfo *wmPtr = winPtr->wmInfoPtr;
+ ProtocolHandler *protPtr, *prevPtr;
Atom protocol;
const char *cmd;
- size_t cmdLength;
+ int cmdLength;
Tcl_Obj *resultObj;
+ (void)tkwin;
if ((objc < 3) || (objc > 5)) {
Tcl_WrongNumArgs(interp, 2, objv, "window ?name? ?command?");
@@ -5009,10 +5031,9 @@ WmProtocolCmd(
break;
}
}
- cmd = Tcl_GetString(objv[4]);
- cmdLength = objv[4]->length;
+ cmd = Tcl_GetStringFromObj(objv[4], &cmdLength);
if (cmdLength > 0) {
- protPtr = ckalloc(HANDLER_SIZE(cmdLength));
+ protPtr = (ProtocolHandler *)ckalloc(HANDLER_SIZE(cmdLength));
protPtr->protocol = protocol;
protPtr->nextPtr = wmPtr->protPtr;
wmPtr->protPtr = protPtr;
@@ -5047,8 +5068,9 @@ WmResizableCmd(
int objc, /* Number of arguments. */
Tcl_Obj *const objv[]) /* Argument objects. */
{
- register WmInfo *wmPtr = winPtr->wmInfoPtr;
+ WmInfo *wmPtr = winPtr->wmInfoPtr;
int width, height;
+ (void)tkwin;
if ((objc != 3) && (objc != 5)) {
Tcl_WrongNumArgs(interp, 2, objv, "window ?width height?");
@@ -5109,7 +5131,7 @@ WmSizefromCmd(
int objc, /* Number of arguments. */
Tcl_Obj *const objv[]) /* Argument objects. */
{
- register WmInfo *wmPtr = winPtr->wmInfoPtr;
+ WmInfo *wmPtr = winPtr->wmInfoPtr;
static const char *const optionStrings[] = {
"program", "user", NULL
};
@@ -5117,6 +5139,7 @@ WmSizefromCmd(
OPT_PROGRAM, OPT_USER
};
int index;
+ (void)tkwin;
if ((objc != 3) && (objc != 4)) {
Tcl_WrongNumArgs(interp, 2, objv, "window ?user|program?");
@@ -5195,18 +5218,18 @@ WmStackorderCmd(
if (objc == 3) {
windows = TkWmStackorderToplevel(winPtr);
- if (windows == NULL) {
- Tcl_Panic("TkWmStackorderToplevel failed");
- }
-
- resultObj = Tcl_NewObj();
- for (windowPtr = windows; *windowPtr ; windowPtr++) {
- Tcl_ListObjAppendElement(NULL, resultObj,
- TkNewWindowObj((Tk_Window) *windowPtr));
+ if (windows != NULL) {
+ resultObj = Tcl_NewObj();
+ for (windowPtr = windows; *windowPtr ; windowPtr++) {
+ Tcl_ListObjAppendElement(NULL, resultObj,
+ TkNewWindowObj((Tk_Window) *windowPtr));
+ }
+ Tcl_SetObjResult(interp, resultObj);
+ ckfree(windows);
+ return TCL_OK;
+ } else {
+ return TCL_ERROR;
}
- Tcl_SetObjResult(interp, resultObj);
- ckfree(windows);
- return TCL_OK;
} else {
TkWindow *winPtr2, **winPtr2Ptr = &winPtr2;
int index1 = -1, index2 = -1, result;
@@ -5306,7 +5329,7 @@ WmStateCmd(
int objc, /* Number of arguments. */
Tcl_Obj *const objv[]) /* Argument objects. */
{
- register WmInfo *wmPtr = winPtr->wmInfoPtr;
+ WmInfo *wmPtr = winPtr->wmInfoPtr;
static const char *const optionStrings[] = {
"normal", "iconic", "withdrawn", "zoomed", NULL
};
@@ -5314,6 +5337,7 @@ WmStateCmd(
OPT_NORMAL, OPT_ICONIC, OPT_WITHDRAWN, OPT_ZOOMED
};
int index;
+ (void)tkwin;
if ((objc < 3) || (objc > 4)) {
Tcl_WrongNumArgs(interp, 2, objv, "window ?state?");
@@ -5446,10 +5470,11 @@ WmTitleCmd(
int objc, /* Number of arguments. */
Tcl_Obj *const objv[]) /* Argument objects. */
{
- register WmInfo *wmPtr = winPtr->wmInfoPtr;
+ WmInfo *wmPtr = winPtr->wmInfoPtr;
const char *argv3;
- size_t length;
+ int length;
HWND wrapper;
+ (void)tkwin;
if (objc > 4) {
Tcl_WrongNumArgs(interp, 2, objv, "window ?newTitle?");
@@ -5468,7 +5493,8 @@ WmTitleCmd(
int size = 256;
GetWindowTextW(wrapper, buf, size);
- Tcl_WinTCharToUtf((LPCTSTR)buf, -1, &titleString);
+ Tcl_DStringInit(&titleString);
+ Tcl_WCharToUtfDString(buf, wcslen(buf), &titleString);
Tcl_SetObjResult(interp, Tcl_NewStringObj(
Tcl_DStringValue(&titleString),
Tcl_DStringLength(&titleString)));
@@ -5481,15 +5507,15 @@ WmTitleCmd(
if (wmPtr->title != NULL) {
ckfree(wmPtr->title);
}
- argv3 = Tcl_GetString(objv[3]);
- length = objv[3]->length;
- wmPtr->title = ckalloc(length + 1);
+ argv3 = Tcl_GetStringFromObj(objv[3], &length);
+ wmPtr->title = (char *)ckalloc(length + 1);
memcpy(wmPtr->title, argv3, length + 1);
if (!(wmPtr->flags & WM_NEVER_MAPPED) && wmPtr->wrapper != NULL) {
Tcl_DString titleString;
- Tcl_WinUtfToTChar(wmPtr->title, -1, &titleString);
+ Tcl_DStringInit(&titleString);
+ Tcl_UtfToWCharDString(wmPtr->title, -1, &titleString);
SetWindowTextW(wrapper, (LPCWSTR) Tcl_DStringValue(&titleString));
Tcl_DStringFree(&titleString);
}
@@ -5522,7 +5548,7 @@ WmTransientCmd(
int objc, /* Number of arguments. */
Tcl_Obj *const objv[]) /* Argument objects. */
{
- register WmInfo *wmPtr = winPtr->wmInfoPtr;
+ WmInfo *wmPtr = winPtr->wmInfoPtr;
TkWindow *masterPtr = wmPtr->masterPtr, **masterPtrPtr = &masterPtr, *w;
WmInfo *wmPtr2;
@@ -5650,7 +5676,8 @@ WmWithdrawCmd(
int objc, /* Number of arguments. */
Tcl_Obj *const objv[]) /* Argument objects. */
{
- register WmInfo *wmPtr = winPtr->wmInfoPtr;
+ WmInfo *wmPtr = winPtr->wmInfoPtr;
+ (void)tkwin;
if (objc != 3) {
Tcl_WrongNumArgs(interp, 2, objv, "window");
@@ -5695,13 +5722,12 @@ WmUpdateGeom(
}
}
- /*ARGSUSED*/
static void
WmWaitVisibilityOrMapProc(
ClientData clientData, /* Pointer to window. */
XEvent *eventPtr) /* Information about event. */
{
- TkWindow *winPtr = clientData;
+ TkWindow *winPtr = (TkWindow *)clientData;
TkWindow *masterPtr = winPtr->wmInfoPtr->masterPtr;
if (masterPtr == NULL)
@@ -5762,7 +5788,7 @@ Tk_SetGrid(
* of one grid unit. */
{
TkWindow *winPtr = (TkWindow *) tkwin;
- register WmInfo *wmPtr;
+ WmInfo *wmPtr;
/*
* Ensure widthInc and heightInc are greater than 0
@@ -5859,7 +5885,7 @@ Tk_UnsetGrid(
* controlling gridding. */
{
TkWindow *winPtr = (TkWindow *) tkwin;
- register WmInfo *wmPtr;
+ WmInfo *wmPtr;
/*
* Find the top-level window for tkwin, plus the window manager
@@ -5918,7 +5944,7 @@ TopLevelEventProc(
ClientData clientData, /* Window for which event occurred. */
XEvent *eventPtr) /* Event that just happened. */
{
- register TkWindow *winPtr = clientData;
+ TkWindow *winPtr = (TkWindow *)clientData;
if (eventPtr->type == DestroyNotify) {
Tk_ErrorHandler handler;
@@ -5958,7 +5984,6 @@ TopLevelEventProc(
*----------------------------------------------------------------------
*/
- /* ARGSUSED */
static void
TopLevelReqProc(
ClientData dummy, /* Not used. */
@@ -5966,6 +5991,7 @@ TopLevelReqProc(
{
TkWindow *winPtr = (TkWindow *) tkwin;
WmInfo *wmPtr;
+ (void)dummy;
wmPtr = winPtr->wmInfoPtr;
if (wmPtr) {
@@ -6009,8 +6035,8 @@ UpdateGeometryInfo(
int width, height; /* Size of client area. */
int min, max;
RECT rect;
- register TkWindow *winPtr = clientData;
- register WmInfo *wmPtr = winPtr->wmInfoPtr;
+ TkWindow *winPtr = (TkWindow *)clientData;
+ WmInfo *wmPtr = winPtr->wmInfoPtr;
wmPtr->flags &= ~WM_UPDATE_PENDING;
@@ -6290,10 +6316,10 @@ ParseGeometry(
TkWindow *winPtr) /* Pointer to top-level window whose geometry
* is to be changed. */
{
- register WmInfo *wmPtr = winPtr->wmInfoPtr;
+ WmInfo *wmPtr = winPtr->wmInfoPtr;
int x, y, width, height, flags;
char *end;
- register const char *p = string;
+ const char *p = string;
/*
* The leading "=" is optional.
@@ -6422,7 +6448,7 @@ Tk_GetRootCoords(
int *xPtr, /* Where to store x-displacement of (0,0). */
int *yPtr) /* Where to store y-displacement of (0,0). */
{
- register TkWindow *winPtr = (TkWindow *) tkwin;
+ TkWindow *winPtr = (TkWindow *) tkwin;
/*
* If the window is mapped, let Windows figure out the translation.
@@ -6519,6 +6545,8 @@ Tk_GetVRootGeometry(
int *widthPtr, int *heightPtr)
/* Store dimensions of virtual root here. */
{
+ (void)tkwin;
+
*xPtr = GetSystemMetrics(SM_XVIRTUALSCREEN);
*yPtr = GetSystemMetrics(SM_YVIRTUALSCREEN);
*widthPtr = GetSystemMetrics(SM_CXVIRTUALSCREEN);
@@ -6551,7 +6579,7 @@ Tk_MoveToplevelWindow(
int x, int y) /* New location for window (within parent). */
{
TkWindow *winPtr = (TkWindow *) tkwin;
- register WmInfo *wmPtr = winPtr->wmInfoPtr;
+ WmInfo *wmPtr = winPtr->wmInfoPtr;
if (!(winPtr->flags & TK_TOP_LEVEL)) {
Tcl_Panic("Tk_MoveToplevelWindow called with non-toplevel window");
@@ -6602,7 +6630,7 @@ TkWmProtocolEventProc(
XEvent *eventPtr) /* X event. */
{
WmInfo *wmPtr;
- register ProtocolHandler *protPtr;
+ ProtocolHandler *protPtr;
Atom protocol;
int result;
Tcl_Interp *interp;
@@ -6680,7 +6708,7 @@ TkWmStackorderToplevelEnumProc(
hPtr = Tcl_FindHashEntry(pair->table, (char *) hwnd);
if (hPtr != NULL) {
- childWinPtr = Tcl_GetHashValue(hPtr);
+ childWinPtr = (TkWindow *)Tcl_GetHashValue(hPtr);
/*
* Double check that same HWND does not get passed twice.
@@ -6780,7 +6808,7 @@ TkWmStackorderToplevel(
Tcl_InitHashTable(&table, TCL_ONE_WORD_KEYS);
TkWmStackorderToplevelWrapperMap(parentPtr, parentPtr->display, &table);
- windows = ckalloc((table.numEntries+1) * sizeof(TkWindow *));
+ windows = (TkWindow **)ckalloc((table.numEntries+1) * sizeof(TkWindow *));
/*
* Special cases: If zero or one toplevels were mapped there is no need to
@@ -6793,7 +6821,7 @@ TkWmStackorderToplevel(
goto done;
case 1:
hPtr = Tcl_FirstHashEntry(&table, &search);
- windows[0] = Tcl_GetHashValue(hPtr);
+ windows[0] = (TkWindow *)Tcl_GetHashValue(hPtr);
windows[1] = NULL;
goto done;
}
@@ -6812,8 +6840,6 @@ TkWmStackorderToplevel(
(LPARAM) &pair) == 0) {
ckfree(windows);
windows = NULL;
- } else if (pair.windowPtr != (windows-1)) {
- Tcl_Panic("num matched toplevel windows does not equal num children");
}
done:
@@ -6958,7 +6984,7 @@ TkWmAddToColormapWindows(
* Automatically add the toplevel itself as the last element of the list.
*/
- newPtr = ckalloc((count+2) * sizeof(TkWindow *));
+ newPtr = (TkWindow **)ckalloc((count+2) * sizeof(TkWindow *));
if (count > 0) {
memcpy(newPtr, oldPtr, count * sizeof(TkWindow*));
}
@@ -8254,7 +8280,7 @@ TkpGetWrapperWindow(
static void
GenerateActivateEvent(TkWindow * winPtr, const int *flagPtr)
{
- ActivateEvent *eventPtr = ckalloc(sizeof(ActivateEvent));
+ ActivateEvent *eventPtr = (ActivateEvent *)ckalloc(sizeof(ActivateEvent));
eventPtr->ev.proc = ActivateWindow;
eventPtr->winPtr = winPtr;
@@ -8357,7 +8383,7 @@ void
TkWinSetForegroundWindow(
TkWindow *winPtr)
{
- register WmInfo *wmPtr = winPtr->wmInfoPtr;
+ WmInfo *wmPtr = winPtr->wmInfoPtr;
if (wmPtr->wrapper != NULL) {
SetForegroundWindow(wmPtr->wrapper);
@@ -8387,7 +8413,7 @@ void
TkpWinToplevelWithDraw(
TkWindow *winPtr)
{
- register WmInfo *wmPtr = winPtr->wmInfoPtr;
+ WmInfo *wmPtr = winPtr->wmInfoPtr;
wmPtr->flags |= WM_WITHDRAWN;
TkpWmSetState(winPtr, WithdrawnState);
@@ -8438,7 +8464,7 @@ void
TkpWinToplevelDeiconify(
TkWindow *winPtr)
{
- register WmInfo *wmPtr = winPtr->wmInfoPtr;
+ WmInfo *wmPtr = winPtr->wmInfoPtr;
wmPtr->flags &= ~WM_WITHDRAWN;
@@ -8506,7 +8532,7 @@ long
TkpWinToplevelIsControlledByWm(
TkWindow *winPtr)
{
- register WmInfo *wmPtr = winPtr->wmInfoPtr;
+ WmInfo *wmPtr = winPtr->wmInfoPtr;
if (!wmPtr) {
return 0;
@@ -8536,7 +8562,7 @@ TkpWinToplevelMove(
TkWindow *winPtr,
int x, int y)
{
- register WmInfo *wmPtr = winPtr->wmInfoPtr;
+ WmInfo *wmPtr = winPtr->wmInfoPtr;
if (wmPtr && x >= 0 && y >= 0 && !TkpWinToplevelIsControlledByWm(winPtr)) {
Tk_MoveToplevelWindow((Tk_Window) winPtr, x, y);
@@ -8568,7 +8594,7 @@ TkpWinToplevelOverrideRedirect(
int reqValue)
{
int curValue;
- register WmInfo *wmPtr = winPtr->wmInfoPtr;
+ WmInfo *wmPtr = winPtr->wmInfoPtr;
curValue = Tk_Attributes((Tk_Window) winPtr)->override_redirect;
if (reqValue < 0) {
@@ -8615,7 +8641,7 @@ void
TkpWinToplevelDetachWindow(
TkWindow *winPtr)
{
- register WmInfo *wmPtr = winPtr->wmInfoPtr;
+ WmInfo *wmPtr = winPtr->wmInfoPtr;
if (winPtr->flags & TK_EMBEDDED) {
int state = SendMessageW(wmPtr->wrapper, TK_STATE, -1, -1) - 1;
diff --git a/win/tkWinX.c b/win/tkWinX.c
index c01096e..689268d 100644
--- a/win/tkWinX.c
+++ b/win/tkWinX.c
@@ -70,7 +70,6 @@ static const char winScreenName[] = ":0"; /* Default name of windows display. */
static HINSTANCE tkInstance = NULL; /* Application instance handle. */
static int childClassInitialized; /* Registered child class? */
static WNDCLASSW childClass; /* Window class for child windows. */
-static int tkPlatformId = 0; /* version of Windows platform */
static int tkWinTheme = 0; /* See TkWinGetPlatformTheme */
static Tcl_Encoding keyInputEncoding = NULL;
/* The current character encoding for
@@ -139,8 +138,8 @@ TkGetServerInfo(
if (!buffer[0]) {
HANDLE handle = GetModuleHandleW(L"NTDLL");
- int(__stdcall *getversion)(void *) =
- (int(__stdcall *)(void *))GetProcAddress(handle, "RtlGetVersion");
+ int(__stdcall *getversion)(void *) = (int(__stdcall *)(void *))
+ (void *)GetProcAddress(handle, "RtlGetVersion");
os.dwOSVersionInfoSize = sizeof(OSVERSIONINFOW);
if (!getversion || getversion(&os)) {
GetVersionExW(&os);
@@ -328,42 +327,38 @@ TkWinXCleanup(
/*
*----------------------------------------------------------------------
*
- * TkWinGetPlatformId --
+ * TkWinGetPlatformTheme --
*
- * Determines whether running under NT, 95, or Win32s, to allow runtime
- * conditional code. Win32s is no longer supported.
+ * Return the Windows drawing style we should be using.
*
* Results:
* The return value is one of:
- * VER_PLATFORM_WIN32s Win32s on Windows 3.1 (not supported)
- * VER_PLATFORM_WIN32_WINDOWS Win32 on Windows 95, 98, ME (not supported)
- * VER_PLATFORM_WIN32_NT Win32 on Windows XP, Vista, Windows 7, Windows 8
- * VER_PLATFORM_WIN32_CE Win32 on Windows CE
- *
- * Side effects:
- * None.
+ * TK_THEME_WIN_CLASSIC 95/98/NT or XP in classic mode
+ * TK_THEME_WIN_XP XP not in classic mode
+ * TK_THEME_WIN_VISTA Vista or higher
*
*----------------------------------------------------------------------
*/
int
-TkWinGetPlatformId(void)
+TkWinGetPlatformTheme(void)
{
- if (tkPlatformId == 0) {
+ if (tkWinTheme == 0) {
OSVERSIONINFOW os;
os.dwOSVersionInfoSize = sizeof(OSVERSIONINFOW);
GetVersionExW(&os);
- tkPlatformId = os.dwPlatformId;
+
+ if (os.dwPlatformId != VER_PLATFORM_WIN32_NT) {
+ Tcl_Panic("Windows NT is the only supported platform");
+ }
/*
- * Set tkWinTheme to be TK_THEME_WIN_XP or TK_THEME_WIN_CLASSIC. The
+ * Set tkWinTheme to be TK_THEME_WIN_(CLASSIC|XP|VISTA). The
* TK_THEME_WIN_CLASSIC could be set even when running under XP if the
* windows classic theme was selected.
*/
-
- if ((os.dwPlatformId == VER_PLATFORM_WIN32_NT) &&
- (os.dwMajorVersion == 5 && os.dwMinorVersion == 1)) {
+ if (os.dwMajorVersion == 5 && os.dwMinorVersion == 1) {
HKEY hKey;
LPCWSTR szSubKey = L"Control Panel\\Appearance";
LPCWSTR szCurrent = L"Current";
@@ -383,40 +378,39 @@ TkWinGetPlatformId(void)
tkWinTheme = TK_THEME_WIN_XP;
}
}
+ } else if (os.dwMajorVersion > 5) {
+ tkWinTheme = TK_THEME_WIN_VISTA;
} else {
tkWinTheme = TK_THEME_WIN_CLASSIC;
}
}
- return tkPlatformId;
+ return tkWinTheme;
}
/*
*----------------------------------------------------------------------
*
- * TkWinGetPlatformTheme --
+ * TkWinGetPlatformId --
*
- * Return the Windows drawing style we should be using.
+ * Determines whether running under NT, 95, or Win32s, to allow runtime
+ * conditional code. Win32s is no longer supported.
*
* Results:
- * The return value is one of:
- * TK_THEME_WIN_CLASSIC 95/98/NT or XP in classic mode
- * TK_THEME_WIN_XP XP not in classic mode
+ * The return value is always:
+ * VER_PLATFORM_WIN32_NT Win32 on Windows XP, Vista, Windows 7, Windows 8
*
* Side effects:
- * Could invoke TkWinGetPlatformId.
+ * None.
*
*----------------------------------------------------------------------
*/
int
-TkWinGetPlatformTheme(void)
+TkWinGetPlatformId(void)
{
- if (tkPlatformId == 0) {
- TkWinGetPlatformId();
- }
- return tkWinTheme;
+ return VER_PLATFORM_WIN32_NT;
}
-
+
/*
*----------------------------------------------------------------------
*
@@ -1478,8 +1472,7 @@ GetTranslatedKey(
if ((msg.message == WM_CHAR) && (msg.lParam & 0x20000000)) {
xkey->state = 0;
}
- xkey->trans_chars[xkey->nbytes] = (char) msg.wParam;
- xkey->nbytes++;
+ xkey->trans_chars[xkey->nbytes++] = (char) msg.wParam;
if (((unsigned short) msg.wParam) > ((unsigned short) 0xff)) {
/*
diff --git a/win/ttkWinXPTheme.c b/win/ttkWinXPTheme.c
index 1375bb6..4391fdd 100644
--- a/win/ttkWinXPTheme.c
+++ b/win/ttkWinXPTheme.c
@@ -106,9 +106,9 @@ LoadXPThemeProcs(HINSTANCE *phlib)
* We have successfully loaded the library. Proceed in storing the
* addresses of the functions we want to use.
*/
- XPThemeProcs *procs = ckalloc(sizeof(XPThemeProcs));
+ XPThemeProcs *procs = (XPThemeProcs *)ckalloc(sizeof(XPThemeProcs));
#define LOADPROC(name) \
- (0 != (procs->name = (name ## Proc *)GetProcAddress(handle, #name) ))
+ (0 != (procs->name = (name ## Proc *)(void *)GetProcAddress(handle, #name) ))
if ( LOADPROC(OpenThemeData)
&& LOADPROC(CloseThemeData)
@@ -138,7 +138,7 @@ LoadXPThemeProcs(HINSTANCE *phlib)
static void
XPThemeDeleteProc(void *clientData)
{
- XPThemeData *themeData = clientData;
+ XPThemeData *themeData = (XPThemeData *)clientData;
FreeLibrary(themeData->hlibrary);
ckfree(clientData);
}
@@ -146,9 +146,11 @@ XPThemeDeleteProc(void *clientData)
static int
XPThemeEnabled(Ttk_Theme theme, void *clientData)
{
- XPThemeData *themeData = clientData;
+ XPThemeData *themeData = (XPThemeData *)clientData;
int active = themeData->procs->IsThemeActive();
int themed = themeData->procs->IsAppThemed();
+ (void)theme;
+
return (active && themed);
}
@@ -382,12 +384,12 @@ typedef struct /* XP element specifications */
int partId; /* BP_PUSHBUTTON, BP_CHECKBUTTON, etc. */
Ttk_StateTable *statemap; /* Map Tk states to XP states */
Ttk_Padding padding; /* See NOTE-GetThemeMargins */
- int flags;
-# define IGNORE_THEMESIZE 0x80000000 /* See NOTE-GetThemePartSize */
-# define PAD_MARGINS 0x40000000 /* See NOTE-GetThemeMargins */
-# define HEAP_ELEMENT 0x20000000 /* ElementInfo is on heap */
-# define HALF_HEIGHT 0x10000000 /* Used by GenericSizedElements */
-# define HALF_WIDTH 0x08000000 /* Used by GenericSizedElements */
+ unsigned flags;
+# define IGNORE_THEMESIZE 0x80000000U /* See NOTE-GetThemePartSize */
+# define PAD_MARGINS 0x40000000U /* See NOTE-GetThemeMargins */
+# define HEAP_ELEMENT 0x20000000U /* ElementInfo is on heap */
+# define HALF_HEIGHT 0x10000000U /* Used by GenericSizedElements */
+# define HALF_WIDTH 0x08000000U /* Used by GenericSizedElements */
} ElementInfo;
typedef struct
@@ -413,7 +415,7 @@ typedef struct
static ElementData *
NewElementData(XPThemeProcs *procs, ElementInfo *info)
{
- ElementData *elementData = ckalloc(sizeof(ElementData));
+ ElementData *elementData = (ElementData *)ckalloc(sizeof(ElementData));
elementData->procs = procs;
elementData->info = info;
@@ -429,12 +431,12 @@ NewElementData(XPThemeProcs *procs, ElementInfo *info)
*/
static void DestroyElementData(void *clientData)
{
- ElementData *elementData = clientData;
+ ElementData *elementData = (ElementData *)clientData;
if (elementData->info->flags & HEAP_ELEMENT) {
- ckfree(elementData->info->statemap);
- ckfree(elementData->info->className);
- ckfree(elementData->info->elementName);
- ckfree(elementData->info);
+ ckfree((char *)elementData->info->statemap);
+ ckfree((char *)elementData->info->className);
+ ckfree((char *)elementData->info->elementName);
+ ckfree((char *)elementData->info);
}
ckfree(clientData);
}
@@ -497,9 +499,10 @@ static void GenericElementSize(
void *clientData, void *elementRecord, Tk_Window tkwin,
int *widthPtr, int *heightPtr, Ttk_Padding *paddingPtr)
{
- ElementData *elementData = clientData;
+ ElementData *elementData = (ElementData *)clientData;
HRESULT result;
SIZE size;
+ (void)elementRecord;
if (!InitElementData(elementData, tkwin, 0))
return;
@@ -533,8 +536,9 @@ static void GenericElementDraw(
void *clientData, void *elementRecord, Tk_Window tkwin,
Drawable d, Ttk_Box b, unsigned int state)
{
- ElementData *elementData = clientData;
+ ElementData *elementData = (ElementData *)clientData;
RECT rc;
+ (void)elementRecord;
if (!InitElementData(elementData, tkwin, d)) {
return;
@@ -578,7 +582,7 @@ GenericSizedElementSize(
void *clientData, void *elementRecord, Tk_Window tkwin,
int *widthPtr, int *heightPtr, Ttk_Padding *paddingPtr)
{
- ElementData *elementData = clientData;
+ ElementData *elementData = (ElementData *)clientData;
if (!InitElementData(elementData, tkwin, 0))
return;
@@ -614,7 +618,7 @@ SpinboxArrowElementSize(
void *clientData, void *elementRecord, Tk_Window tkwin,
int *widthPtr, int *heightPtr, Ttk_Padding *paddingPtr)
{
- ElementData *elementData = clientData;
+ ElementData *elementData = (ElementData *)clientData;
if (!InitElementData(elementData, tkwin, 0))
return;
@@ -643,9 +647,10 @@ static void ThumbElementDraw(
void *clientData, void *elementRecord, Tk_Window tkwin,
Drawable d, Ttk_Box b, unsigned int state)
{
- ElementData *elementData = clientData;
+ ElementData *elementData = (ElementData *)clientData;
unsigned stateId = Ttk_StateTableLookup(elementData->info->statemap, state);
RECT rc = BoxToRect(b);
+ (void)elementRecord;
/*
* Don't draw the thumb if we are disabled.
@@ -682,7 +687,7 @@ static void PbarElementSize(
void *clientData, void *elementRecord, Tk_Window tkwin,
int *widthPtr, int *heightPtr, Ttk_Padding *paddingPtr)
{
- ElementData *elementData = clientData;
+ ElementData *elementData = (ElementData *)clientData;
int nBars = 3;
GenericElementSize(clientData, elementRecord, tkwin,
@@ -722,9 +727,10 @@ static void TabElementDraw(
void *clientData, void *elementRecord, Tk_Window tkwin,
Drawable d, Ttk_Box b, unsigned int state)
{
- ElementData *elementData = clientData;
+ ElementData *elementData = (ElementData *)clientData;
int partId = elementData->info->partId;
RECT rc = BoxToRect(b);
+ (void)elementRecord;
if (!InitElementData(elementData, tkwin, d))
return;
@@ -812,7 +818,7 @@ typedef struct
Tcl_Obj *fontObj;
} TextElement;
-static Ttk_ElementOptionSpec TextElementOptions[] =
+static const Ttk_ElementOptionSpec TextElementOptions[] =
{
{ "-text", TK_OPTION_STRING,
Tk_Offset(TextElement,textObj), "" },
@@ -837,13 +843,13 @@ static void TextElementSize(
return;
src = Tcl_GetStringFromObj(element->textObj, &len);
- Tcl_WinUtfToTChar(src, len, &ds);
+ Tcl_DStringInit(&ds);
hr = elementData->procs->GetThemeTextExtent(
elementData->hTheme,
elementData->hDC,
elementData->info->partId,
Ttk_StateTableLookup(elementData->info->statemap, 0),
- (WCHAR *) Tcl_DStringValue(&ds),
+ Tcl_UtfToWCharDString(src, len, &ds),
-1,
DT_LEFT,// | DT_BOTTOM | DT_NOPREFIX,
NULL,
@@ -876,13 +882,13 @@ static void TextElementDraw(
return;
src = Tcl_GetStringFromObj(element->textObj, &len);
- Tcl_WinUtfToTChar(src, len, &ds);
+ Tcl_DStringInit(&ds);
hr = elementData->procs->DrawThemeText(
elementData->hTheme,
elementData->hDC,
elementData->info->partId,
Ttk_StateTableLookup(elementData->info->statemap, state),
- (WCHAR *) Tcl_DStringValue(&ds),
+ Tcl_UtfToWCharDString(src, len, &ds),
-1,
DT_LEFT,// | DT_BOTTOM | DT_NOPREFIX,
(state & TTK_STATE_DISABLED) ? DTT_GRAYED : 0,
@@ -1029,7 +1035,7 @@ static ElementInfo ElementInfoTable[] = {
{ "Menubutton.dropdown", &GenericElementSpec, L"TOOLBAR",
TP_SPLITBUTTONDROPDOWN,toolbutton_statemap, NOPAD,0 },
{ "Treeview.field", &GenericElementSpec, L"TREEVIEW",
- TVP_TREEITEM, treeview_statemap, PAD(1, 1, 1, 1), 0 },
+ TVP_TREEITEM, treeview_statemap, PAD(1, 1, 1, 1), IGNORE_THEMESIZE },
{ "Treeitem.indicator", &TreeIndicatorElementSpec, L"TREEVIEW",
TVP_GLYPH, tvpglyph_statemap, PAD(1,1,6,0), PAD_MARGINS },
{ "Treeheading.border", &GenericElementSpec, L"HEADER",
@@ -1058,7 +1064,7 @@ static ElementInfo ElementInfoTable[] = {
static int
GetSysFlagFromObj(Tcl_Interp *interp, Tcl_Obj *objPtr, int *resultPtr)
{
- static const char *names[] = {
+ static const char *const names[] = {
"SM_CXBORDER", "SM_CYBORDER", "SM_CXVSCROLL", "SM_CYVSCROLL",
"SM_CXHSCROLL", "SM_CYHSCROLL", "SM_CXMENUCHECK", "SM_CYMENUCHECK",
"SM_CXMENUSIZE", "SM_CYMENUSIZE", "SM_CXSIZE", "SM_CYSIZE", "SM_CXSMSIZE",
@@ -1112,7 +1118,7 @@ Ttk_CreateVsapiElement(
int objc,
Tcl_Obj *const objv[])
{
- XPThemeData *themeData = clientData;
+ XPThemeData *themeData = (XPThemeData *)clientData;
ElementInfo *elementPtr = NULL;
ClientData elementData;
LPCWSTR className;
@@ -1126,7 +1132,7 @@ Ttk_CreateVsapiElement(
Ttk_ElementSpec *elementSpec = &GenericElementSpec;
Tcl_DString classBuf;
- static const char *optionStrings[] =
+ static const char *const optionStrings[] =
{ "-padding","-width","-height","-margins", "-syssize",
"-halfheight", "-halfwidth", NULL };
enum { O_PADDING, O_WIDTH, O_HEIGHT, O_MARGINS, O_SYSSIZE,
@@ -1143,7 +1149,8 @@ Ttk_CreateVsapiElement(
return TCL_ERROR;
}
name = Tcl_GetStringFromObj(objv[0], &length);
- className = (LPCWSTR) Tcl_WinUtfToTChar(name, length, &classBuf);
+ Tcl_DStringInit(&classBuf);
+ className = Tcl_UtfToWCharDString(name, length, &classBuf);
/* flags or padding */
if (objc > 3) {
@@ -1218,7 +1225,7 @@ Ttk_CreateVsapiElement(
if (Tcl_ListObjGetElements(interp, objv[2], &count, &specs) != TCL_OK)
goto retErr;
/* we over-allocate to ensure there is a terminating entry */
- stateTable = ckalloc(sizeof(Ttk_StateTable) * (count + 1));
+ stateTable = (Ttk_StateTable *)ckalloc(sizeof(Ttk_StateTable) * (count + 1));
memset(stateTable, 0, sizeof(Ttk_StateTable) * (count + 1));
for (n = 0, j = 0; status == TCL_OK && n < count; n += 2, ++j) {
Ttk_StateSpec spec = {0,0};
@@ -1236,11 +1243,11 @@ Ttk_CreateVsapiElement(
return status;
}
} else {
- stateTable = ckalloc(sizeof(Ttk_StateTable));
+ stateTable = (Ttk_StateTable *)ckalloc(sizeof(Ttk_StateTable));
memset(stateTable, 0, sizeof(Ttk_StateTable));
}
- elementPtr = ckalloc(sizeof(ElementInfo));
+ elementPtr = (ElementInfo *)ckalloc(sizeof(ElementInfo));
elementPtr->elementSpec = elementSpec;
elementPtr->partId = partId;
elementPtr->statemap = stateTable;
@@ -1248,12 +1255,12 @@ Ttk_CreateVsapiElement(
elementPtr->flags = HEAP_ELEMENT | flags;
/* set the element name to an allocated copy */
- name = ckalloc(strlen(elementName) + 1);
+ name = (char *)ckalloc(strlen(elementName) + 1);
strcpy(name, elementName);
elementPtr->elementName = name;
/* set the class name to an allocated copy */
- wname = ckalloc(Tcl_DStringLength(&classBuf) + sizeof(WCHAR));
+ wname = (LPWSTR)ckalloc(Tcl_DStringLength(&classBuf) + sizeof(WCHAR));
wcscpy(wname, className);
elementPtr->className = wname;
@@ -1282,10 +1289,6 @@ MODULE_SCOPE int TtkXPTheme_Init(Tcl_Interp *interp, HWND hwnd)
HINSTANCE hlibrary;
Ttk_Theme themePtr, parentPtr, vistaPtr;
ElementInfo *infoPtr;
- OSVERSIONINFOW os;
-
- os.dwOSVersionInfoSize = sizeof(OSVERSIONINFOW);
- GetVersionExW(&os);
procs = LoadXPThemeProcs(&hlibrary);
if (!procs)
@@ -1305,7 +1308,7 @@ MODULE_SCOPE int TtkXPTheme_Init(Tcl_Interp *interp, HWND hwnd)
* Set theme data and cleanup proc
*/
- themeData = ckalloc(sizeof(XPThemeData));
+ themeData = (XPThemeData *)ckalloc(sizeof(XPThemeData));
themeData->procs = procs;
themeData->hlibrary = hlibrary;
@@ -1318,7 +1321,7 @@ MODULE_SCOPE int TtkXPTheme_Init(Tcl_Interp *interp, HWND hwnd)
* enable function. The theme itself is defined in script.
*/
- if (os.dwPlatformId == VER_PLATFORM_WIN32_NT && os.dwMajorVersion > 5) {
+ if (TkWinGetPlatformTheme() == TK_THEME_WIN_VISTA) {
vistaPtr = Ttk_CreateTheme(interp, "vista", themePtr);
if (vistaPtr) {
Ttk_SetThemeEnabledProc(vistaPtr, XPThemeEnabled, themeData);