summaryrefslogtreecommitdiffstats
path: root/win
diff options
context:
space:
mode:
authorjan.nijtmans <nijtmans@users.sourceforge.net>2025-10-31 19:28:42 (GMT)
committerjan.nijtmans <nijtmans@users.sourceforge.net>2025-10-31 19:28:42 (GMT)
commitc25f14940d3c7823cae0a783f34c6f147518a1b3 (patch)
treed598543193e4ffbb2336840441fd696a854ab6cc /win
parent3d21e16ae679d4c1ae0b73441536c7429a72657d (diff)
parent2f48a0563a693aeccaf7550989d0539a3c940d95 (diff)
downloadtk-core-tk-print-fixes.zip
tk-core-tk-print-fixes.tar.gz
tk-core-tk-print-fixes.tar.bz2
Diffstat (limited to 'win')
-rw-r--r--win/Makefile.in29
-rwxr-xr-xwin/configure71
-rw-r--r--win/configure.ac7
-rw-r--r--win/makefile.vc5
-rw-r--r--win/rules.vc14
-rw-r--r--win/stubs.c9
-rw-r--r--win/tcl.m424
-rw-r--r--win/tkWin.h2
-rw-r--r--win/tkWin32Dll.c2
-rw-r--r--win/tkWin3d.c32
-rw-r--r--win/tkWinClipboard.c12
-rw-r--r--win/tkWinColor.c4
-rw-r--r--win/tkWinCursor.c4
-rw-r--r--win/tkWinDialog.c37
-rw-r--r--win/tkWinDraw.c2
-rw-r--r--win/tkWinEmbed.c28
-rw-r--r--win/tkWinFont.c50
-rw-r--r--win/tkWinGDI.c135
-rw-r--r--win/tkWinImage.c6
-rw-r--r--win/tkWinInt.h12
-rw-r--r--win/tkWinKey.c2
-rw-r--r--win/tkWinMenu.c75
-rw-r--r--win/tkWinPixmap.c10
-rw-r--r--win/tkWinPointer.c11
-rw-r--r--win/tkWinRegion.c47
-rw-r--r--win/tkWinSend.c5
-rw-r--r--win/tkWinSysTray.c85
-rw-r--r--win/tkWinTest.c20
-rw-r--r--win/tkWinWm.c163
-rw-r--r--win/tkWinX.c66
-rw-r--r--win/ttkWinMonitor.c6
-rw-r--r--win/ttkWinTheme.c115
-rw-r--r--win/ttkWinVistaTheme.c (renamed from win/ttkWinXPTheme.c)420
-rw-r--r--win/winMain.c157
-rw-r--r--win/wish.exe.manifest.in4
35 files changed, 679 insertions, 992 deletions
diff --git a/win/Makefile.in b/win/Makefile.in
index c477e0d..5abf481 100644
--- a/win/Makefile.in
+++ b/win/Makefile.in
@@ -406,7 +406,7 @@ TK_OBJS = \
TTK_OBJS = \
ttkWinMonitor.$(OBJEXT) \
ttkWinTheme.$(OBJEXT) \
- ttkWinXPTheme.$(OBJEXT) \
+ ttkWinVistaTheme.$(OBJEXT) \
ttkBlink.$(OBJEXT) \
ttkButton.$(OBJEXT) \
ttkCache.$(OBJEXT) \
@@ -432,6 +432,7 @@ TTK_OBJS = \
ttkState.$(OBJEXT) \
ttkTagSet.$(OBJEXT) \
ttkTheme.$(OBJEXT) \
+ ttkToggleswitch.$(OBJEXT) \
ttkTrace.$(OBJEXT) \
ttkTrack.$(OBJEXT) \
ttkTreeview.$(OBJEXT) \
@@ -534,7 +535,7 @@ install-binaries: binaries
echo "if {![package vsatisfies [package provide Tcl] 9.0]} return";\
echo "if {(\$$::tcl_platform(platform) eq \"unix\") && ([info exists ::env(DISPLAY)]";\
echo " || ([info exists ::argv] && (\"-display\" in \$$::argv)))} {";\
- echo " package ifneeded tk $(VERSION)$(PATCH_LEVEL) [list load [file normalize [file join \$$dir .. .. bin libtcl9tk$(VERSION).dll]]]";\
+ echo " package ifneeded tk $(VERSION)$(PATCH_LEVEL) [list load [file normalize [file join \$$dir .. .. bin cygtcl9tk$(VERSION).dll]]]";\
echo "} else {";\
echo " package ifneeded tk $(VERSION)$(PATCH_LEVEL) [list load [file normalize [file join \$$dir .. .. bin $(TK_DLL_FILE)]]]";\
echo "}";\
@@ -547,6 +548,9 @@ install-binaries: binaries
$(COPY) $$i "$(LIB_INSTALL_DIR)"; \
fi; \
done
+ @echo "Installing pkg-config file to $(LIB_INSTALL_DIR)/pkgconfig/"
+ @$(MKDIR) "$(LIB_INSTALL_DIR)/pkgconfig"
+ @$(INSTALL_DATA) tk.pc "$(LIB_INSTALL_DIR)/pkgconfig/tk.pc"
install-libraries: libraries
@for i in "$$($(CYGPATH) $(prefix)/lib)" \
@@ -636,6 +640,27 @@ install-demos:
done;
install-doc: doc
+ @for i in "$(MAN_INSTALL_DIR)" "$(MAN1_INSTALL_DIR)" "$(MAN3_INSTALL_DIR)" "$(MANN_INSTALL_DIR)" ; \
+ do \
+ if [ ! -d "$$i" ] ; then \
+ echo "Making directory $$i"; \
+ mkdir -p "$$i"; \
+ chmod 755 "$$i"; \
+ else true; \
+ fi; \
+ done;
+ @echo "Installing and cross-linking top-level (.1) docs";
+ @for i in $(ROOT_DIR)/doc/*.1; do \
+ $(SHELL) $(UNIX_DIR)/installManPage $(MAN_FLAGS) $$i "$(MAN1_INSTALL_DIR)"; \
+ done
+ @echo "Installing and cross-linking C API (.3) docs";
+ @for i in $(ROOT_DIR)/doc/*.3; do \
+ $(SHELL) $(UNIX_DIR)/installManPage $(MAN_FLAGS) $$i "$(MAN3_INSTALL_DIR)"; \
+ done
+ @echo "Installing and cross-linking command (.n) docs";
+ @for i in $(ROOT_DIR)/doc/*.n; do \
+ $(SHELL) $(UNIX_DIR)/installManPage $(MAN_FLAGS) $$i "$(MANN_INSTALL_DIR)"; \
+ done
# Optional target to install private headers
install-private-headers: libraries
diff --git a/win/configure b/win/configure
index 21e4e37..fa216fd 100755
--- a/win/configure
+++ b/win/configure
@@ -641,6 +641,8 @@ ac_includes_default="\
ac_header_c_list=
ac_subst_vars='LTLIBOBJS
LIBOBJS
+XFT_LIBS
+XLIBSW
RES
RC_DEFINES
RC_DEFINE
@@ -2408,7 +2410,7 @@ SHELL=/bin/sh
TK_VERSION=9.1
TK_MAJOR_VERSION=9
TK_MINOR_VERSION=1
-TK_PATCH_LEVEL="a0"
+TK_PATCH_LEVEL="a1"
VER=$TK_MAJOR_VERSION$TK_MINOR_VERSION
#------------------------------------------------------------------------
@@ -4363,7 +4365,7 @@ printf "%s\n" "$ac_cv_win32" >&6; }
if test "$ac_cv_win32" != "yes"; then
as_fn_error $? "${CC} cannot produce win32 executables." "$LINENO" 5
fi
- if test "$do64bit" != "arm64"; then
+ if test "$do64bit" != "arm64" -a "$do64bit" != "aarch64"; then
extra_cflags="$extra_cflags -DHAVE_CPUID=1"
fi
@@ -4453,8 +4455,6 @@ printf "%s\n" "$ac_cv_municode" >&6; }
CFLAGS=$hold_cflags
if test "$ac_cv_municode" = "yes" ; then
extra_ldflags="$extra_ldflags -municode"
- else
- extra_cflags="$extra_cflags -DTCL_BROKEN_MAINARGS"
fi
hold_cflags=$CFLAGS; CFLAGS="$CFLAGS -fno-lto"
{ printf "%s\n" "$as_me:${as_lineno-$LINENO}: checking for working -fno-lto" >&5
@@ -4493,6 +4493,44 @@ printf "%s\n" "$ac_cv_nolto" >&6; }
else
CFLAGS_NOLTO=""
fi
+
+ { printf "%s\n" "$as_me:${as_lineno-$LINENO}: checking if the linker understands --disable-high-entropy-va" >&5
+printf %s "checking if the linker understands --disable-high-entropy-va... " >&6; }
+if test ${tcl_cv_ld_high_entropy+y}
+then :
+ printf %s "(cached) " >&6
+else case e in #(
+ e)
+ hold_cflags=$CFLAGS; CFLAGS="$CFLAGS -Wl,--disable-high-entropy-va"
+ cat confdefs.h - <<_ACEOF >conftest.$ac_ext
+/* end confdefs.h. */
+
+int
+main (void)
+{
+
+ ;
+ return 0;
+}
+_ACEOF
+if ac_fn_c_try_link "$LINENO"
+then :
+ tcl_cv_ld_high_entropy=yes
+else case e in #(
+ e) tcl_cv_ld_high_entropy=no ;;
+esac
+fi
+rm -f core conftest.err conftest.$ac_objext conftest.beam \
+ conftest$ac_exeext conftest.$ac_ext
+ CFLAGS=$hold_cflags ;;
+esac
+fi
+{ printf "%s\n" "$as_me:${as_lineno-$LINENO}: result: $tcl_cv_ld_high_entropy" >&5
+printf "%s\n" "$tcl_cv_ld_high_entropy" >&6; }
+ if test $tcl_cv_ld_high_entropy = yes; then
+ extra_ldflags="$extra_ldflags -Wl,--disable-high-entropy-va"
+ fi
+
{ printf "%s\n" "$as_me:${as_lineno-$LINENO}: checking if the compiler understands -finput-charset" >&5
printf %s "checking if the compiler understands -finput-charset... " >&6; }
if test ${tcl_cv_cc_input_charset+y}
@@ -4548,14 +4586,15 @@ main (void)
return 0;
}
_ACEOF
-if ac_fn_c_try_compile "$LINENO"
+if ac_fn_c_try_link "$LINENO"
then :
ac_cv_enable_auto_image_base=yes
else case e in #(
e) ac_cv_enable_auto_image_base=no ;;
esac
fi
-rm -f core conftest.err conftest.$ac_objext conftest.beam conftest.$ac_ext
+rm -f core conftest.err conftest.$ac_objext conftest.beam \
+ conftest$ac_exeext conftest.$ac_ext
;;
esac
fi
@@ -4573,7 +4612,7 @@ printf %s "checking compiler flags... " >&6; }
SHLIB_LD_LIBS='${LIBS}'
LIBS="-lnetapi32 -lkernel32 -luser32 -ladvapi32 -luserenv -lws2_32"
# mingw needs to link ole32 and oleaut32 for [send], but MSVC doesn't
- LIBS_GUI="-lgdi32 -lcomdlg32 -limm32 -lcomctl32 -lshell32 -luuid -lole32 -loleaut32 -lwinspool"
+ LIBS_GUI="-lgdi32 -lcomdlg32 -limm32 -lcomctl32 -lshell32 -luuid -loleacc -lole32 -loleaut32 -lwinspool -luxtheme -luiautomationcore"
STLIB_LD='${AR} cr'
RC_OUT=-o
RC_TYPE=
@@ -4728,7 +4767,7 @@ printf "%s\n" "using shared flags" >&6; }
EXESUFFIX=".exe"
case "x`echo \${VisualStudioVersion}`" in
x1[4-9]*)
- lflags="${lflags} -nodefaultlib:libucrt.lib"
+ lflags="${lflags} -nodefaultlib:ucrt.lib"
;;
*)
;;
@@ -4787,7 +4826,7 @@ printf "%s\n" " Using 64-bit $MACHINE mode" >&6; }
LINKBIN="link"
fi
- LIBS_GUI="gdi32.lib comdlg32.lib imm32.lib comctl32.lib shell32.lib uuid.lib winspool.lib"
+ LIBS_GUI="gdi32.lib comdlg32.lib imm32.lib comctl32.lib shell32.lib uuid.lib winspool.lib uxtheme.lib oleacc.lib ole32.lib uiautomationcore.lib"
SHLIB_LD="${LINKBIN} -dll -incremental:no ${lflags}"
SHLIB_LD_LIBS='${LIBS}'
@@ -4977,15 +5016,6 @@ printf "%s\n" "#define EXCEPTION_DISPOSITION int" >>confdefs.h
fi
- ac_fn_c_check_header_compile "$LINENO" "stdbool.h" "ac_cv_header_stdbool_h" "$ac_includes_default"
-if test "x$ac_cv_header_stdbool_h" = xyes
-then :
-
-printf "%s\n" "#define HAVE_STDBOOL_H 1" >>confdefs.h
-
-fi
-
-
# See if the compiler supports casting to a union type.
# This is used to stop gcc from printing a compiler
# warning when initializing a union member.
@@ -5998,6 +6028,10 @@ TK_WIN_VERSION="$TK_VERSION.$TK_RELEASE_LEVEL.`echo $TK_PATCH_LEVEL | tr -d ab.`
+
+ac_config_files="$ac_config_files tk.pc:../unix/tk.pc.in"
+
+
ac_config_files="$ac_config_files Makefile tkConfig.sh wish.exe.manifest"
cat >confcache <<\_ACEOF
@@ -6701,6 +6735,7 @@ cat >>$CONFIG_STATUS <<\_ACEOF || ac_write_fail=1
for ac_config_target in $ac_config_targets
do
case $ac_config_target in
+ "tk.pc") CONFIG_FILES="$CONFIG_FILES tk.pc:../unix/tk.pc.in" ;;
"Makefile") CONFIG_FILES="$CONFIG_FILES Makefile" ;;
"tkConfig.sh") CONFIG_FILES="$CONFIG_FILES tkConfig.sh" ;;
"wish.exe.manifest") CONFIG_FILES="$CONFIG_FILES wish.exe.manifest" ;;
diff --git a/win/configure.ac b/win/configure.ac
index 39d3d2b..ee7b309 100644
--- a/win/configure.ac
+++ b/win/configure.ac
@@ -15,7 +15,7 @@ SHELL=/bin/sh
TK_VERSION=9.1
TK_MAJOR_VERSION=9
TK_MINOR_VERSION=1
-TK_PATCH_LEVEL="a0"
+TK_PATCH_LEVEL="a1"
VER=$TK_MAJOR_VERSION$TK_MINOR_VERSION
#------------------------------------------------------------------------
@@ -356,6 +356,11 @@ AC_SUBST(RC_INCLUDE)
AC_SUBST(RC_DEFINE)
AC_SUBST(RC_DEFINES)
AC_SUBST(RES)
+AC_SUBST(XLIBSW)
+AC_SUBST(XFT_LIBS)
+AC_CONFIG_FILES([
+ tk.pc:../unix/tk.pc.in
+])
AC_CONFIG_FILES([Makefile tkConfig.sh wish.exe.manifest])
AC_OUTPUT
diff --git a/win/makefile.vc b/win/makefile.vc
index 28e4535..4663822 100644
--- a/win/makefile.vc
+++ b/win/makefile.vc
@@ -272,7 +272,7 @@ TKOBJS = \
TTK_OBJS = \
$(TMP_DIR)\ttkWinMonitor.obj \
$(TMP_DIR)\ttkWinTheme.obj \
- $(TMP_DIR)\ttkWinXPTheme.obj \
+ $(TMP_DIR)\ttkWinVistaTheme.obj \
$(TMP_DIR)\ttkBlink.obj \
$(TMP_DIR)\ttkButton.obj \
$(TMP_DIR)\ttkCache.obj \
@@ -298,6 +298,7 @@ TTK_OBJS = \
$(TMP_DIR)\ttkState.obj \
$(TMP_DIR)\ttkTagSet.obj \
$(TMP_DIR)\ttkTheme.obj \
+ $(TMP_DIR)\ttkToggleswitch.obj \
$(TMP_DIR)\ttkTrace.obj \
$(TMP_DIR)\ttkTrack.obj \
$(TMP_DIR)\ttkTreeview.obj \
@@ -732,7 +733,7 @@ install-binaries:
if {![package vsatisfies [package provide Tcl] 9.0]} return
if {($$::tcl_platform(platform) eq "unix") && ([info exists ::env(DISPLAY)]
|| ([info exists ::argv] && ("-display" in $$::argv)))} {
- package ifneeded tk $(TK_PATCH_LEVEL) [list load [file normalize [file join $$dir .. .. bin libtcl9tk$(DOTVERSION).dll]]]
+ package ifneeded tk $(TK_PATCH_LEVEL) [list load [file normalize [file join $$dir .. .. bin cygtcl9tk$(DOTVERSION).dll]]]
} else {
package ifneeded tk $(TK_PATCH_LEVEL) [list load [file normalize [file join $$dir .. .. bin $(TKLIBNAME)]]]
}
diff --git a/win/rules.vc b/win/rules.vc
index 0b47765..15ae8a0 100644
--- a/win/rules.vc
+++ b/win/rules.vc
@@ -804,10 +804,10 @@ DOTSEPARATED=$(DOTSEPARATED:b=.)
# MSVCRT - 1 -> link to dynamic C runtime even when building static Tcl build
# 0 -> link to static C runtime for static Tcl build.
# Does not impact shared Tcl builds (STATIC_BUILD == 0)
-# Default: 1 for Tcl 8.7 and up, 0 otherwise.
+# Default: 1 for Tcl 9.0 and up, 0 otherwise.
# TCL_USE_STATIC_PACKAGES - 1 -> statically link the registry and dde extensions
# in the Tcl and Wish shell. 0 -> keep them as shared libraries. Does
-# not impact shared Tcl builds. Implied by STATIC_BUILD since Tcl 8.7.
+# not impact shared Tcl builds. Implied by STATIC_BUILD since Tcl 9.0.
# USE_THREAD_ALLOC - 1 -> Use a shared global free pool for allocation.
# 0 -> Use the non-thread allocator.
# UNCHECKED - 1 -> when doing a debug build with symbols, use the release
@@ -1042,7 +1042,7 @@ WARNINGS = $(WARNINGS) -Wp64
# different compilers, build configurations etc.,
#
# Naming convention (suffixes):
-# t = full thread support. (Not used for Tcl >= 8.7)
+# t = full thread support. (Not used for Tcl >= 9.0)
# s = static library (as opposed to an import library)
# g = linked to the debug enabled C run-time.
# x = special static build when it links to the dynamic C run-time.
@@ -1173,7 +1173,7 @@ TCLSTUBLIB = $(_TCLDIR)\lib\tclstub.lib
!endif
TCLIMPLIB = $(_TCLDIR)\lib\tcl$(TCL_VERSION)$(SUFX:t=).lib
# When building extensions, may be linking against Tcl that does not add
-# "t" suffix (e.g. 8.5 or 8.7). If lib not found check for that possibility.
+# "t" suffix (e.g. 8.6). If lib not found check for that possibility.
!if !exist("$(TCLIMPLIB)")
TCLIMPLIB = $(_TCLDIR)\lib\tcl$(TCL_VERSION)t$(SUFX:t=).lib
!endif
@@ -1197,7 +1197,7 @@ TCLSTUBLIB = $(_TCLDIR)\win\$(BUILDDIRTOP)\tclstub.lib
!endif
TCLIMPLIB = $(_TCLDIR)\win\$(BUILDDIRTOP)\tcl$(TCL_VERSION)$(SUFX:t=).lib
# When building extensions, may be linking against Tcl that does not add
-# "t" suffix (e.g. 8.5 or 8.7). If lib not found check for that possibility.
+# "t" suffix (e.g. 8.6). If lib not found check for that possibility.
!if !exist("$(TCLIMPLIB)")
TCLIMPLIB = $(_TCLDIR)\win\$(BUILDDIRTOP)\tcl$(TCL_VERSION)t$(SUFX:t=).lib
!endif
@@ -1262,7 +1262,7 @@ WISH = $(_TKDIR)\bin\$(WISHNAME)
TKSTUBLIB = $(_TKDIR)\lib\$(TKSTUBLIBNAME)
TKIMPLIB = $(_TKDIR)\lib\$(TKIMPLIBNAME)
# When building extensions, may be linking against Tk that does not add
-# "t" suffix (e.g. 8.5 or 8.7). If lib not found check for that possibility.
+# "t" suffix (e.g. 8.6). If lib not found check for that possibility.
!if !exist("$(TKIMPLIB)")
TKIMPLIBNAME = tk$(TK_VERSION)$(SUFX:t=).lib
TKIMPLIB = $(_TKDIR)\lib\$(TKIMPLIBNAME)
@@ -1276,7 +1276,7 @@ WISH = $(_TKDIR)\win\$(BUILDDIRTOP)\$(WISHNAME)
TKSTUBLIB = $(_TKDIR)\win\$(BUILDDIRTOP)\$(TKSTUBLIBNAME)
TKIMPLIB = $(_TKDIR)\win\$(BUILDDIRTOP)\$(TKIMPLIBNAME)
# When building extensions, may be linking against Tk that does not add
-# "t" suffix (e.g. 8.5 or 8.7). If lib not found check for that possibility.
+# "t" suffix (e.g. 8.6). If lib not found check for that possibility.
!if !exist("$(TKIMPLIB)")
TKIMPLIBNAME = tk$(TK_VERSION)$(SUFX:t=).lib
TKIMPLIB = $(_TKDIR)\win\$(BUILDDIRTOP)\$(TKIMPLIBNAME)
diff --git a/win/stubs.c b/win/stubs.c
index 2cd4d34..12771f1 100644
--- a/win/stubs.c
+++ b/win/stubs.c
@@ -440,12 +440,3 @@ XVisualIDFromVisual(
{
return visual->visualid;
}
-
-int
-XOffsetRegion(
- TCL_UNUSED(Region),
- TCL_UNUSED(int),
- TCL_UNUSED(int))
-{
- return 0;
-}
diff --git a/win/tcl.m4 b/win/tcl.m4
index 17281ff..4bdf97c 100644
--- a/win/tcl.m4
+++ b/win/tcl.m4
@@ -593,7 +593,7 @@ AC_DEFUN([SC_CONFIG_CFLAGS], [
if test "$ac_cv_win32" != "yes"; then
AC_MSG_ERROR([${CC} cannot produce win32 executables.])
fi
- if test "$do64bit" != "arm64"; then
+ if test "$do64bit" != "arm64" -a "$do64bit" != "aarch64"; then
extra_cflags="$extra_cflags -DHAVE_CPUID=1"
fi
@@ -610,8 +610,6 @@ AC_DEFUN([SC_CONFIG_CFLAGS], [
CFLAGS=$hold_cflags
if test "$ac_cv_municode" = "yes" ; then
extra_ldflags="$extra_ldflags -municode"
- else
- extra_cflags="$extra_cflags -DTCL_BROKEN_MAINARGS"
fi
hold_cflags=$CFLAGS; CFLAGS="$CFLAGS -fno-lto"
AC_CACHE_CHECK(for working -fno-lto,
@@ -626,6 +624,16 @@ AC_DEFUN([SC_CONFIG_CFLAGS], [
else
CFLAGS_NOLTO=""
fi
+
+ AC_CACHE_CHECK([if the linker understands --disable-high-entropy-va],
+ tcl_cv_ld_high_entropy, [
+ hold_cflags=$CFLAGS; CFLAGS="$CFLAGS -Wl,--disable-high-entropy-va"
+ AC_LINK_IFELSE([AC_LANG_PROGRAM([[]], [[]])],[tcl_cv_ld_high_entropy=yes],[tcl_cv_ld_high_entropy=no])
+ CFLAGS=$hold_cflags])
+ if test $tcl_cv_ld_high_entropy = yes; then
+ extra_ldflags="$extra_ldflags -Wl,--disable-high-entropy-va"
+ fi
+
AC_CACHE_CHECK([if the compiler understands -finput-charset],
tcl_cv_cc_input_charset, [
hold_cflags=$CFLAGS; CFLAGS="$CFLAGS -finput-charset=UTF-8"
@@ -639,7 +647,7 @@ AC_DEFUN([SC_CONFIG_CFLAGS], [
hold_cflags=$CFLAGS; CFLAGS="$CFLAGS -Wl,--enable-auto-image-base"
AC_CACHE_CHECK(for working --enable-auto-image-base,
ac_cv_enable_auto_image_base,
- AC_COMPILE_IFELSE([AC_LANG_PROGRAM([])],
+ AC_LINK_IFELSE([AC_LANG_PROGRAM([])],
[ac_cv_enable_auto_image_base=yes],
[ac_cv_enable_auto_image_base=no])
)
@@ -654,7 +662,7 @@ AC_DEFUN([SC_CONFIG_CFLAGS], [
SHLIB_LD_LIBS='${LIBS}'
LIBS="-lnetapi32 -lkernel32 -luser32 -ladvapi32 -luserenv -lws2_32"
# mingw needs to link ole32 and oleaut32 for [send], but MSVC doesn't
- LIBS_GUI="-lgdi32 -lcomdlg32 -limm32 -lcomctl32 -lshell32 -luuid -lole32 -loleaut32 -lwinspool"
+ LIBS_GUI="-lgdi32 -lcomdlg32 -limm32 -lcomctl32 -lshell32 -luuid -loleacc -lole32 -loleaut32 -lwinspool -luxtheme -luiautomationcore"
STLIB_LD='${AR} cr'
RC_OUT=-o
RC_TYPE=
@@ -785,7 +793,7 @@ AC_DEFUN([SC_CONFIG_CFLAGS], [
EXESUFFIX=".exe"
case "x`echo \${VisualStudioVersion}`" in
x1[[4-9]]*)
- lflags="${lflags} -nodefaultlib:libucrt.lib"
+ lflags="${lflags} -nodefaultlib:ucrt.lib"
;;
*)
;;
@@ -843,7 +851,7 @@ AC_DEFUN([SC_CONFIG_CFLAGS], [
LINKBIN="link"
fi
- LIBS_GUI="gdi32.lib comdlg32.lib imm32.lib comctl32.lib shell32.lib uuid.lib winspool.lib"
+ LIBS_GUI="gdi32.lib comdlg32.lib imm32.lib comctl32.lib shell32.lib uuid.lib winspool.lib uxtheme.lib oleacc.lib ole32.lib uiautomationcore.lib"
SHLIB_LD="${LINKBIN} -dll -incremental:no ${lflags}"
SHLIB_LD_LIBS='${LIBS}'
@@ -938,8 +946,6 @@ AC_DEFUN([SC_CONFIG_CFLAGS], [
[Defined when cygwin/mingw does not support EXCEPTION DISPOSITION])
fi
- AC_CHECK_HEADER(stdbool.h, [AC_DEFINE(HAVE_STDBOOL_H, 1, [Do we have <stdbool.h>?])],)
-
# See if the compiler supports casting to a union type.
# This is used to stop gcc from printing a compiler
# warning when initializing a union member.
diff --git a/win/tkWin.h b/win/tkWin.h
index 460d0c1..69b58c6 100644
--- a/win/tkWin.h
+++ b/win/tkWin.h
@@ -80,6 +80,6 @@
*--------------------------------------------------------------
*/
-#include "tkPlatDecls.h"
+#include "tkPlatDecls.h" /* IWYU pragma: export */
#endif /* _TKWIN */
diff --git a/win/tkWin32Dll.c b/win/tkWin32Dll.c
index 1e4bf1b..fa8839c 100644
--- a/win/tkWin32Dll.c
+++ b/win/tkWin32Dll.c
@@ -12,7 +12,7 @@
#include "tkWinInt.h"
#ifndef STATIC_BUILD
-#ifdef HAVE_NO_SEH
+#if defined(HAVE_NO_SEH) && !defined(__aarch64__)
/*
* Unlike Borland and Microsoft, we don't register exception handlers by
diff --git a/win/tkWin3d.c b/win/tkWin3d.c
index c5dfeb4..54bba58 100644
--- a/win/tkWin3d.c
+++ b/win/tkWin3d.c
@@ -336,7 +336,7 @@ TkpGetShadows(
{
XColor lightColor, darkColor;
int tmp1, tmp2;
- int r, g, b;
+ unsigned short r, g, b;
XGCValues gcValues;
if (borderPtr->lightGC != NULL) {
@@ -404,18 +404,18 @@ TkpGetShadows(
* Compute the dark shadow color
*/
- r = (int) borderPtr->bgColorPtr->red;
- g = (int) borderPtr->bgColorPtr->green;
- b = (int) borderPtr->bgColorPtr->blue;
+ r = borderPtr->bgColorPtr->red;
+ g = borderPtr->bgColorPtr->green;
+ b = borderPtr->bgColorPtr->blue;
if (r*0.5*r + g*1.0*g + b*0.28*b < MAX_INTENSITY*0.05*MAX_INTENSITY) {
- darkColor.red = (MAX_INTENSITY + 3*r)/4;
- darkColor.green = (MAX_INTENSITY + 3*g)/4;
- darkColor.blue = (MAX_INTENSITY + 3*b)/4;
+ darkColor.red = (unsigned short)((MAX_INTENSITY + 3*r)/4);
+ darkColor.green = (unsigned short)((MAX_INTENSITY + 3*g)/4);
+ darkColor.blue = (unsigned short)((MAX_INTENSITY + 3*b)/4);
} else {
- darkColor.red = (60 * r)/100;
- darkColor.green = (60 * g)/100;
- darkColor.blue = (60 * b)/100;
+ darkColor.red = (unsigned short)((60 * r)/100);
+ darkColor.green = (unsigned short)((60 * g)/100);
+ darkColor.blue = (unsigned short)((60 * b)/100);
}
/*
@@ -431,28 +431,28 @@ TkpGetShadows(
*/
if (g > MAX_INTENSITY*0.95) {
- lightColor.red = (90 * r)/100;
- lightColor.green = (90 * g)/100;
- lightColor.blue = (90 * b)/100;
+ lightColor.red = (unsigned short)((90 * r)/100);
+ lightColor.green = (unsigned short)((90 * g)/100);
+ lightColor.blue = (unsigned short)((90 * b)/100);
} else {
tmp1 = (14 * r)/10;
if (tmp1 > MAX_INTENSITY) {
tmp1 = MAX_INTENSITY;
}
tmp2 = (MAX_INTENSITY + r)/2;
- lightColor.red = (tmp1 > tmp2) ? tmp1 : tmp2;
+ lightColor.red = (unsigned short)((tmp1 > tmp2) ? tmp1 : tmp2);
tmp1 = (14 * g)/10;
if (tmp1 > MAX_INTENSITY) {
tmp1 = MAX_INTENSITY;
}
tmp2 = (MAX_INTENSITY + g)/2;
- lightColor.green = (tmp1 > tmp2) ? tmp1 : tmp2;
+ lightColor.green = (unsigned short)((tmp1 > tmp2) ? tmp1 : tmp2);
tmp1 = (14 * b)/10;
if (tmp1 > MAX_INTENSITY) {
tmp1 = MAX_INTENSITY;
}
tmp2 = (MAX_INTENSITY + b)/2;
- lightColor.blue = (tmp1 > tmp2) ? tmp1 : tmp2;
+ lightColor.blue = (unsigned short)((tmp1 > tmp2) ? tmp1 : tmp2);
}
/*
diff --git a/win/tkWinClipboard.c b/win/tkWinClipboard.c
index f51bf8a..4fcff8b 100644
--- a/win/tkWinClipboard.c
+++ b/win/tkWinClipboard.c
@@ -62,7 +62,7 @@ TkSelGetSelection(
if (!OpenClipboard(NULL)) {
Tcl_SetObjResult(interp, Tcl_ObjPrintf(
"clipboard cannot be opened, another application grabbed it"));
- Tcl_SetErrorCode(interp, "TK", "CLIPBOARD", "BUSY", NULL);
+ Tcl_SetErrorCode(interp, "TK", "CLIPBOARD", "BUSY", (char *)NULL);
return TCL_ERROR;
}
@@ -204,7 +204,7 @@ TkSelGetSelection(
Tcl_SetObjResult(interp, Tcl_ObjPrintf(
"%s selection doesn't exist or form \"%s\" not defined",
Tk_GetAtomName(tkwin, selection), Tk_GetAtomName(tkwin, target)));
- Tcl_SetErrorCode(interp, "TK", "SELECTION", "EXISTS", NULL);
+ Tcl_SetErrorCode(interp, "TK", "SELECTION", "EXISTS", (char *)NULL);
return TCL_ERROR;
}
@@ -366,11 +366,13 @@ TkWinClipboardRender(
void
TkSelUpdateClipboard(
TkWindow *winPtr,
- TCL_UNUSED(TkClipboardTarget *))
+ clipboardOption opt)
{
- HWND hwnd = TkWinGetHWND(winPtr->window);
+ if (opt == CLIPBOARD_APPEND || opt == CLIPBOARD_CLEAR) {
+ HWND hwnd = TkWinGetHWND(winPtr->window);
- UpdateClipboard(hwnd);
+ UpdateClipboard(hwnd);
+ }
}
/*
diff --git a/win/tkWinColor.c b/win/tkWinColor.c
index 9735665..9fb8727 100644
--- a/win/tkWinColor.c
+++ b/win/tkWinColor.c
@@ -156,7 +156,7 @@ FindSystemColor(
TkColor *
TkpGetColor(
Tk_Window tkwin, /* Window in which color will be used. */
- Tk_Uid name) /* Name of color to allocated (in form
+ const char *name) /* Name of color to allocated (in form
* suitable for passing to XParseColor). */
{
WinColor *winColPtr;
@@ -494,7 +494,7 @@ XCreateColormap(
logPalettePtr = (LOGPALETTE *) logPalBuf;
logPalettePtr->palVersion = 0x300;
sysPal = (HPALETTE) GetStockObject(DEFAULT_PALETTE);
- logPalettePtr->palNumEntries = GetPaletteEntries(sysPal, 0, 256,
+ logPalettePtr->palNumEntries = (WORD)GetPaletteEntries(sysPal, 0, 256,
logPalettePtr->palPalEntry);
cmap = (TkWinColormap *)ckalloc(sizeof(TkWinColormap));
diff --git a/win/tkWinCursor.c b/win/tkWinCursor.c
index 4281761..6ebeb86 100644
--- a/win/tkWinCursor.c
+++ b/win/tkWinCursor.c
@@ -133,7 +133,7 @@ TkGetCursorByName(
if (Tcl_IsSafe(interp)) {
Tcl_SetObjResult(interp, Tcl_NewStringObj(
"cannot get cursor from a file in a safe interpreter", TCL_INDEX_NONE));
- Tcl_SetErrorCode(interp, "TK", "SAFE", "CURSOR_FILE", NULL);
+ Tcl_SetErrorCode(interp, "TK", "SAFE", "CURSOR_FILE", (char *)NULL);
ckfree(argv);
ckfree(cursorPtr);
return NULL;
@@ -169,7 +169,7 @@ TkGetCursorByName(
ckfree(argv);
Tcl_SetObjResult(interp, Tcl_ObjPrintf(
"bad cursor spec \"%s\"", string));
- Tcl_SetErrorCode(interp, "TK", "VALUE", "CURSOR", NULL);
+ Tcl_SetErrorCode(interp, "TK", "VALUE", "CURSOR", (char *)NULL);
return NULL;
}
ckfree(argv);
diff --git a/win/tkWinDialog.c b/win/tkWinDialog.c
index 1a94c33..42bc607 100644
--- a/win/tkWinDialog.c
+++ b/win/tkWinDialog.c
@@ -193,12 +193,12 @@ static UINT CALLBACK ColorDlgHookProc(HWND hDlg, UINT uMsg, WPARAM wParam,
LPARAM lParam);
static void CleanupOFNOptions(OFNOpts *optsPtr);
static int ParseOFNOptions(void *clientData,
- Tcl_Interp *interp, int objc,
+ Tcl_Interp *interp, Tcl_Size objc,
Tcl_Obj *const objv[], enum OFNOper oper, OFNOpts *optsPtr);
static int GetFileNameVista(Tcl_Interp *interp, OFNOpts *optsPtr,
enum OFNOper oper);
static int GetFileName(void *clientData,
- Tcl_Interp *interp, int objc,
+ Tcl_Interp *interp, Tcl_Size objc,
Tcl_Obj *const objv[], enum OFNOper oper);
static int MakeFilterVista(Tcl_Interp *interp, OFNOpts *optsPtr,
DWORD *countPtr, COMDLG_FILTERSPEC **dlgFilterPtrPtr,
@@ -314,7 +314,8 @@ Tk_ChooseColorObjCmd(
{
Tk_Window tkwin = (Tk_Window)clientData, parent;
HWND hWnd;
- int i, oldMode, winCode, result;
+ Tcl_Size i;
+ int oldMode, winCode, result;
CHOOSECOLORW chooseColor;
static int inited = 0;
static COLORREF dwCustColors[16];
@@ -368,7 +369,7 @@ Tk_ChooseColorObjCmd(
if (i + 1 == objc) {
Tcl_SetObjResult(interp, Tcl_ObjPrintf(
"value for \"%s\" missing", Tcl_GetString(optionPtr)));
- Tcl_SetErrorCode(interp, "TK", "COLORDIALOG", "VALUE", NULL);
+ Tcl_SetErrorCode(interp, "TK", "COLORDIALOG", "VALUE", (char *)NULL);
return TCL_ERROR;
}
@@ -591,12 +592,12 @@ static int
ParseOFNOptions(
void *clientData, /* Main window associated with interpreter. */
Tcl_Interp *interp, /* Current interpreter. */
- int objc, /* Number of arguments. */
+ Tcl_Size objc, /* Number of arguments. */
Tcl_Obj *const objv[], /* Argument objects. */
enum OFNOper oper, /* 1 for Open, 0 for Save */
OFNOpts *optsPtr) /* Output, uninitialized on entry */
{
- int i;
+ Tcl_Size i;
Tcl_DString ds;
enum options {
FILE_DEFAULT, FILE_TYPES, FILE_INITDIR, FILE_INITFILE, FILE_PARENT,
@@ -662,7 +663,7 @@ ParseOFNOptions(
} else if (i + 1 == objc) {
Tcl_SetObjResult(interp, Tcl_ObjPrintf(
"value for \"%s\" missing", options[index].name));
- Tcl_SetErrorCode(interp, "TK", "FILEDIALOG", "VALUE", NULL);
+ Tcl_SetErrorCode(interp, "TK", "FILEDIALOG", "VALUE", (char *)NULL);
goto error_return;
}
@@ -1054,7 +1055,7 @@ static int
GetFileName(
void *clientData, /* Main window associated with interpreter. */
Tcl_Interp *interp, /* Current interpreter. */
- int objc, /* Number of arguments. */
+ Tcl_Size objc, /* Number of arguments. */
Tcl_Obj *const objv[], /* Argument objects. */
enum OFNOper oper) /* 1 to call GetOpenFileName(), 0 to call
* GetSaveFileName(). */
@@ -1333,8 +1334,8 @@ Tk_MessageBoxObjCmd(
Tk_Window tkwin = (Tk_Window)clientData, parent;
HWND hWnd;
Tcl_Obj *messageObj, *titleObj, *detailObj, *tmpObj;
- int defaultBtn, icon, type;
- int i, oldMode, winCode;
+ int defaultBtn, icon, type, oldMode, winCode;
+ Tcl_Size i;
UINT flags;
static const char *const optionStrings[] = {
"-default", "-detail", "-icon", "-message",
@@ -1372,7 +1373,7 @@ Tk_MessageBoxObjCmd(
if (i + 1 == objc) {
Tcl_SetObjResult(interp, Tcl_ObjPrintf(
"value for \"%s\" missing", Tcl_GetString(optionPtr)));
- Tcl_SetErrorCode(interp, "TK", "MSGBOX", "VALUE", NULL);
+ Tcl_SetErrorCode(interp, "TK", "MSGBOX", "VALUE", (char *)NULL);
return TCL_ERROR;
}
@@ -1444,7 +1445,7 @@ Tk_MessageBoxObjCmd(
Tcl_SetObjResult(interp, Tcl_ObjPrintf(
"invalid default button \"%s\"",
TkFindStateString(buttonMap, defaultBtn)));
- Tcl_SetErrorCode(interp, "TK", "MSGBOX", "DEFAULT", NULL);
+ Tcl_SetErrorCode(interp, "TK", "MSGBOX", "DEFAULT", (char *)NULL);
return TCL_ERROR;
}
break;
@@ -1763,15 +1764,15 @@ HookProc(
* any of the options (which may be NULL in the structure)
*/
-enum FontchooserOption {
+typedef enum {
FontchooserCmd, FontchooserFont, FontchooserParent, FontchooserTitle,
FontchooserVisible
-};
+} FontchooserOption;
static Tcl_Obj *
FontchooserCget(
HookData *hdPtr,
- int optionIndex)
+ FontchooserOption optionIndex)
{
Tcl_Obj *resObj = NULL;
@@ -1857,7 +1858,7 @@ FontchooserConfigureCmd(
for (i = 0; r == TCL_OK && optionStrings[i] != NULL; ++i) {
keyObj = Tcl_NewStringObj(optionStrings[i], TCL_INDEX_NONE);
- valueObj = FontchooserCget(hdPtr, i);
+ valueObj = FontchooserCget(hdPtr, (FontchooserOption)i);
r = Tcl_DictObjPut(interp, dictObj, keyObj, valueObj);
}
if (r == TCL_OK) {
@@ -1884,7 +1885,7 @@ FontchooserConfigureCmd(
if (i + 1 == objc) {
Tcl_SetObjResult(interp, Tcl_ObjPrintf(
"value for \"%s\" missing", Tcl_GetString(objv[i])));
- Tcl_SetErrorCode(interp, "TK", "FONTDIALOG", "VALUE", NULL);
+ Tcl_SetErrorCode(interp, "TK", "FONTDIALOG", "VALUE", (char *)NULL);
return TCL_ERROR;
}
switch (optionIndex) {
@@ -1893,7 +1894,7 @@ FontchooserConfigureCmd(
"\"-visible\": use the show or hide command";
Tcl_SetObjResult(interp, Tcl_NewStringObj(msg, TCL_INDEX_NONE));
- Tcl_SetErrorCode(interp, "TK", "FONTDIALOG", "READONLY", NULL);
+ Tcl_SetErrorCode(interp, "TK", "FONTDIALOG", "READONLY", (char *)NULL);
return TCL_ERROR;
}
case FontchooserParent: {
diff --git a/win/tkWinDraw.c b/win/tkWinDraw.c
index a7ab9c0..333820a 100644
--- a/win/tkWinDraw.c
+++ b/win/tkWinDraw.c
@@ -29,7 +29,7 @@ const int tkpWinRopModes[] = {
R2_MASKPENNOT, /* GXandReverse */
R2_COPYPEN, /* GXcopy */
R2_MASKNOTPEN, /* GXandInverted */
- R2_NOT, /* GXnoop */
+ R2_NOP, /* GXnoop */
R2_XORPEN, /* GXxor */
R2_MERGEPEN, /* GXor */
R2_NOTMERGEPEN, /* GXnor */
diff --git a/win/tkWinEmbed.c b/win/tkWinEmbed.c
index de4eaba..0d1868b 100644
--- a/win/tkWinEmbed.c
+++ b/win/tkWinEmbed.c
@@ -164,7 +164,7 @@ void Tk_MapEmbeddedWindow(
{
if(!(winPtr->flags & TK_ALREADY_DEAD)) {
HWND hwnd = (HWND)winPtr->privatePtr;
- int state = SendMessageW(hwnd, TK_STATE, -1, (WPARAM)-1) - 1;
+ int state = (int)SendMessageW(hwnd, TK_STATE, -1, (WPARAM)-1) - 1;
if (state < 0 || state > 3) {
state = NormalState;
@@ -238,7 +238,7 @@ Tk_UseWindow(
* tkwin; must be an integer value. */
{
TkWindow *winPtr = (TkWindow *) tkwin;
- int id;
+ Tcl_Size id;
HWND hwnd;
/*
ThreadSpecificData *tsdPtr = (ThreadSpecificData *)
@@ -249,7 +249,7 @@ Tk_UseWindow(
if (winPtr->window != None) {
Tcl_SetObjResult(interp, Tcl_NewStringObj(
"can't modify container after widget is created", TCL_INDEX_NONE));
- Tcl_SetErrorCode(interp, "TK", "EMBED", "POST_CREATE", NULL);
+ Tcl_SetErrorCode(interp, "TK", "EMBED", "POST_CREATE", (char *)NULL);
return TCL_ERROR;
}
*/
@@ -282,7 +282,7 @@ Tk_UseWindow(
if (interp != NULL) {
Tcl_SetObjResult(interp, Tcl_ObjPrintf(
"window \"%s\" does not exist", string));
- Tcl_SetErrorCode(interp, "TK", "EMBED", "EXIST", NULL);
+ Tcl_SetErrorCode(interp, "TK", "EMBED", "EXIST", (char *)NULL);
}
return TCL_ERROR;
}
@@ -292,13 +292,13 @@ Tk_UseWindow(
if (!SendMessageW(hwnd, TK_INFO, TK_CONTAINER_ISAVAILABLE, 0)) {
Tcl_SetObjResult(interp, Tcl_NewStringObj(
"The container is already in use", TCL_INDEX_NONE));
- Tcl_SetErrorCode(interp, "TK", "EMBED", "IN_USE", NULL);
+ Tcl_SetErrorCode(interp, "TK", "EMBED", "IN_USE", (char *)NULL);
return TCL_ERROR;
}
} else if (id == -PTR2INT(hwnd)) {
Tcl_SetObjResult(interp, Tcl_NewStringObj(
"the window to use is not a Tk container", TCL_INDEX_NONE));
- Tcl_SetErrorCode(interp, "TK", "EMBED", "CONTAINER", NULL);
+ Tcl_SetErrorCode(interp, "TK", "EMBED", "CONTAINER", (char *)NULL);
return TCL_ERROR;
} else {
/*
@@ -314,7 +314,7 @@ Tk_UseWindow(
MB_OKCANCEL | MB_ICONWARNING)) {
Tcl_SetObjResult(interp, Tcl_NewStringObj(
"Operation has been canceled", TCL_INDEX_NONE));
- Tcl_SetErrorCode(interp, "TK", "EMBED", "CANCEL", NULL);
+ Tcl_SetErrorCode(interp, "TK", "EMBED", "CANCEL", (char *)NULL);
return TCL_ERROR;
}
}
@@ -426,7 +426,7 @@ TkWinEmbeddedEventProc(
WPARAM wParam,
LPARAM lParam)
{
- int result = 1;
+ Tcl_Size result = 1;
Container *containerPtr;
ThreadSpecificData *tsdPtr = (ThreadSpecificData *)
Tcl_GetThreadData(&dataKey, sizeof(ThreadSpecificData));
@@ -460,8 +460,8 @@ TkWinEmbeddedEventProc(
*
* TK_CONTAINER_VERIFY - request the container to verify its
* identification
- * result = (long)hwnd if this window is a container
- * -(long)hwnd otherwise
+ * result = (Tcl_Size)hwnd if this window is a container
+ * -(Tcl_Size)hwnd otherwise
*
* lParam - N/A
*/
@@ -550,7 +550,7 @@ TkWinEmbeddedEventProc(
* others - the message is processed.
*/
- EmbedGeometryRequest(containerPtr, (int)wParam, lParam);
+ EmbedGeometryRequest(containerPtr, (int)wParam, (int)lParam);
break;
case TK_RAISEWINDOW:
@@ -687,7 +687,7 @@ TkWinEmbeddedEventProc(
*/
result = TkpWinToplevelMove(containerPtr->parentPtr,
- wParam, lParam);
+ (int)wParam, (int)lParam);
break;
case TK_OVERRIDEREDIRECT:
@@ -706,7 +706,7 @@ TkWinEmbeddedEventProc(
* toplevel. Otherwise 0.
*/
if (topwinPtr) {
- result = 1 + TkpWinToplevelOverrideRedirect(topwinPtr, wParam);
+ result = 1 + TkpWinToplevelOverrideRedirect(topwinPtr, (int)wParam);
} else {
result = 0;
}
@@ -751,7 +751,7 @@ TkWinEmbeddedEventProc(
if (topwinPtr) {
if (wParam <= 3) {
- TkpWmSetState(topwinPtr, wParam);
+ TkpWmSetState(topwinPtr, (int)wParam);
}
result = 1+TkpWmGetState(topwinPtr);
} else {
diff --git a/win/tkWinFont.c b/win/tkWinFont.c
index 04b1105..b1dc52e 100644
--- a/win/tkWinFont.c
+++ b/win/tkWinFont.c
@@ -853,7 +853,7 @@ Tk_MeasureChars(
p - start, &runString);
size.cx = 0;
familyPtr->getTextExtentPoint32Proc(hdc, wstr,
- Tcl_DStringLength(&runString) >> familyPtr->isWideFont,
+ (int)(Tcl_DStringLength(&runString) >> familyPtr->isWideFont),
&size);
Tcl_DStringFree(&runString);
if (maxLength >= 0 && (curX+size.cx) > maxLength) {
@@ -880,7 +880,7 @@ Tk_MeasureChars(
p - start, &runString);
size.cx = 0;
familyPtr->getTextExtentPoint32Proc(hdc, wstr,
- Tcl_DStringLength(&runString) >> familyPtr->isWideFont,
+ (int)(Tcl_DStringLength(&runString) >> familyPtr->isWideFont),
&size);
Tcl_DStringFree(&runString);
if (maxLength >= 0 && (curX+size.cx) > maxLength) {
@@ -914,7 +914,7 @@ Tk_MeasureChars(
size.cx = 0;
familyPtr->getTextExtentPoint32Proc(hdc,
(WCHAR *) Tcl_DStringValue(&runString),
- Tcl_DStringLength(&runString) >> familyPtr->isWideFont,
+ (int)(Tcl_DStringLength(&runString) >> familyPtr->isWideFont),
&size);
if ((curX+size.cx) > maxLength) {
break;
@@ -1128,7 +1128,7 @@ Tk_DrawChars(
* Compute the bounding box and create a compatible bitmap.
*/
- GetTextExtentPointA(dcMem, source, numBytes, &size);
+ GetTextExtentPointA(dcMem, source, (int)numBytes, &size);
GetTextMetricsW(dcMem, &tm);
size.cx -= tm.tmOverhang;
bitmap = CreateCompatibleBitmap(dc, size.cx, size.cy);
@@ -1143,11 +1143,11 @@ Tk_DrawChars(
*/
PatBlt(dcMem, 0, 0, size.cx, size.cy, BLACKNESS);
- MultiFontTextOut(dc, fontPtr, source, numBytes, x, y, 0.0);
+ MultiFontTextOut(dc, fontPtr, source, (int)numBytes, x, y, 0.0);
BitBlt(dc, x, y - tm.tmAscent, size.cx, size.cy, dcMem,
0, 0, 0xEA02E9);
PatBlt(dcMem, 0, 0, size.cx, size.cy, WHITENESS);
- MultiFontTextOut(dc, fontPtr, source, numBytes, x, y, 0.0);
+ MultiFontTextOut(dc, fontPtr, source, (int)numBytes, x, y, 0.0);
BitBlt(dc, x, y - tm.tmAscent, size.cx, size.cy, dcMem,
0, 0, 0x8A0E06);
@@ -1164,7 +1164,7 @@ Tk_DrawChars(
SetTextAlign(dc, TA_LEFT | TA_BASELINE);
SetTextColor(dc, gc->foreground);
SetBkMode(dc, TRANSPARENT);
- MultiFontTextOut(dc, fontPtr, source, numBytes, x, y, 0.0);
+ MultiFontTextOut(dc, fontPtr, source, (int)numBytes, x, y, 0.0);
} else {
HBITMAP oldBitmap, bitmap;
HDC dcMem;
@@ -1182,13 +1182,13 @@ Tk_DrawChars(
* Compute the bounding box and create a compatible bitmap.
*/
- GetTextExtentPointA(dcMem, source, numBytes, &size);
+ GetTextExtentPointA(dcMem, source, (int)numBytes, &size);
GetTextMetricsW(dcMem, &tm);
size.cx -= tm.tmOverhang;
bitmap = CreateCompatibleBitmap(dc, size.cx, size.cy);
oldBitmap = (HBITMAP)SelectObject(dcMem, bitmap);
- MultiFontTextOut(dcMem, fontPtr, source, numBytes, 0, tm.tmAscent,
+ MultiFontTextOut(dcMem, fontPtr, source, (int)numBytes, 0, tm.tmAscent,
0.0);
BitBlt(dc, x, y - tm.tmAscent, size.cx, size.cy, dcMem,
0, 0, (DWORD) tkpWinBltModes[gc->function]);
@@ -1276,7 +1276,7 @@ TkDrawAngledChars(
* Compute the bounding box and create a compatible bitmap.
*/
- GetTextExtentPointA(dcMem, source, numBytes, &size);
+ GetTextExtentPointA(dcMem, source, (int)numBytes, &size);
GetTextMetricsW(dcMem, &tm);
size.cx -= tm.tmOverhang;
bitmap = CreateCompatibleBitmap(dc, size.cx, size.cy);
@@ -1291,11 +1291,11 @@ TkDrawAngledChars(
*/
PatBlt(dcMem, 0, 0, size.cx, size.cy, BLACKNESS);
- MultiFontTextOut(dc, fontPtr, source, numBytes, x, y, angle);
+ MultiFontTextOut(dc, fontPtr, source, (int)numBytes, x, y, angle);
BitBlt(dc, (int)x, (int)y - tm.tmAscent, size.cx, size.cy, dcMem,
0, 0, 0xEA02E9);
PatBlt(dcMem, 0, 0, size.cx, size.cy, WHITENESS);
- MultiFontTextOut(dc, fontPtr, source, numBytes, x, y, angle);
+ MultiFontTextOut(dc, fontPtr, source, (int)numBytes, x, y, angle);
BitBlt(dc, (int)x, (int)y - tm.tmAscent, size.cx, size.cy, dcMem,
0, 0, 0x8A0E06);
@@ -1312,7 +1312,7 @@ TkDrawAngledChars(
SetTextAlign(dc, TA_LEFT | TA_BASELINE);
SetTextColor(dc, gc->foreground);
SetBkMode(dc, TRANSPARENT);
- MultiFontTextOut(dc, fontPtr, source, numBytes, x, y, angle);
+ MultiFontTextOut(dc, fontPtr, source, (int)numBytes, x, y, angle);
} else {
HBITMAP oldBitmap, bitmap;
HDC dcMem;
@@ -1330,13 +1330,13 @@ TkDrawAngledChars(
* Compute the bounding box and create a compatible bitmap.
*/
- GetTextExtentPointA(dcMem, source, numBytes, &size);
+ GetTextExtentPointA(dcMem, source, (int)numBytes, &size);
GetTextMetricsW(dcMem, &tm);
size.cx -= tm.tmOverhang;
bitmap = CreateCompatibleBitmap(dc, size.cx, size.cy);
oldBitmap = (HBITMAP)SelectObject(dcMem, bitmap);
- MultiFontTextOut(dcMem, fontPtr, source, numBytes, 0, tm.tmAscent,
+ MultiFontTextOut(dcMem, fontPtr, source, (int)numBytes, 0, tm.tmAscent,
angle);
BitBlt(dc, (int)x, (int)y - tm.tmAscent, size.cx, size.cy, dcMem,
0, 0, (DWORD) tkpWinBltModes[gc->function]);
@@ -1493,10 +1493,10 @@ MultiFontTextOut(
familyPtr = lastSubFontPtr->familyPtr;
WCHAR *wstr = (WCHAR *)Tcl_UtfToExternalDString(familyPtr->encoding, source,
p - source, &runString);
- familyPtr->textOutProc(hdc, (int)(x-(double)tm.tmOverhang/2.0), y,
- wstr, Tcl_DStringLength(&runString) >> familyPtr->isWideFont);
+ familyPtr->textOutProc(hdc, (int)(x-(double)tm.tmOverhang/2.0), (int)y,
+ wstr, (int)(Tcl_DStringLength(&runString) >> familyPtr->isWideFont));
familyPtr->getTextExtentPoint32Proc(hdc,
- wstr, Tcl_DStringLength(&runString) >> familyPtr->isWideFont,
+ wstr, (int)(Tcl_DStringLength(&runString) >> familyPtr->isWideFont),
&size);
x += cosA*size.cx;
y -= sinA*size.cx;
@@ -1513,8 +1513,8 @@ MultiFontTextOut(
familyPtr = lastSubFontPtr->familyPtr;
WCHAR *wstr = (WCHAR *)Tcl_UtfToExternalDString(familyPtr->encoding, source,
p - source, &runString);
- familyPtr->textOutProc(hdc, (int)(x-(double)tm.tmOverhang/2.0), y,
- wstr, Tcl_DStringLength(&runString) >> familyPtr->isWideFont);
+ familyPtr->textOutProc(hdc, (int)(x-(double)tm.tmOverhang/2.0), (int)y,
+ wstr, (int)(Tcl_DStringLength(&runString) >> familyPtr->isWideFont));
Tcl_DStringFree(&runString);
}
SelectObject(hdc, oldFont);
@@ -2500,9 +2500,9 @@ GetScreenFont(
lf.lfEscapement = ROUND16(angle * 10);
lf.lfOrientation = ROUND16(angle * 10);
lf.lfWeight = (faPtr->weight == TK_FW_NORMAL) ? FW_NORMAL : FW_BOLD;
- lf.lfItalic = faPtr->slant;
- lf.lfUnderline = faPtr->underline;
- lf.lfStrikeOut = faPtr->overstrike;
+ lf.lfItalic = (BYTE)faPtr->slant;
+ lf.lfUnderline = (BYTE)faPtr->underline;
+ lf.lfStrikeOut = (BYTE)faPtr->overstrike;
lf.lfCharSet = DEFAULT_CHARSET;
lf.lfOutPrecision = OUT_TT_PRECIS;
lf.lfClipPrecision = CLIP_DEFAULT_PRECIS;
@@ -2800,9 +2800,9 @@ LoadFontRanges(
endCount = (USHORT *)ckalloc(cbData);
offset = encTable.offset + sizeof(subTable.segment);
- GetFontData(hdc, cmapKey, (DWORD) offset, endCount, cbData);
+ GetFontData(hdc, cmapKey, (DWORD) offset, endCount, (DWORD)cbData);
offset += cbData + sizeof(USHORT);
- GetFontData(hdc, cmapKey, (DWORD) offset, startCount, cbData);
+ GetFontData(hdc, cmapKey, (DWORD) offset, startCount, (DWORD)cbData);
if (swapped) {
for (j = 0; j < segCount; j++) {
SwapShort(&endCount[j]);
diff --git a/win/tkWinGDI.c b/win/tkWinGDI.c
index bc4f743..25314d1 100644
--- a/win/tkWinGDI.c
+++ b/win/tkWinGDI.c
@@ -116,6 +116,7 @@ typedef struct WinprintData {
* array. The first element is the subcommand name, and the second a standard
* Tcl command handler.
*/
+
static const struct gdi_command {
const char *command_string;
Tcl_ObjCmdProc2 *command;
@@ -163,7 +164,7 @@ static Tcl_Size ParseColor (
if (objc == 0) {
Tcl_AppendResult(interp, "option \"", Tcl_GetString(objv[-1]),
- "\" needs an additional argument", NULL);
+ "\" needs an additional argument", (char *)NULL);
return -1;
}
@@ -179,7 +180,7 @@ static Tcl_Size ParseColor (
return 1;
}
- Tcl_AppendResult(interp, "unknown color name \"", colorname, "\"", NULL);
+ Tcl_AppendResult(interp, "unknown color name \"", colorname, "\"", (char *)NULL);
return -1;
}
@@ -196,7 +197,7 @@ static Tcl_Size ParseDash (
if (objc == 0) {
Tcl_AppendResult(interp,
- "option \"-dash\" needs an additional argument", NULL);
+ "option \"-dash\" needs an additional argument", (char *)NULL);
return -1;
}
@@ -234,7 +235,7 @@ static Tcl_Size ParseAnchor (
if (objc == 0) {
Tcl_AppendResult(interp,
- "option \"-anchor\" needs an additional argument", NULL);
+ "option \"-anchor\" needs an additional argument", (char *)NULL);
return -1;
}
@@ -259,7 +260,7 @@ static Tcl_Size ParseFont (
if (objc == 0) {
Tcl_AppendResult(interp,
- "option \"-font\" needs an additional argument", NULL);
+ "option \"-font\" needs an additional argument", (char *)NULL);
return -1;
}
@@ -271,7 +272,7 @@ static Tcl_Size ParseFont (
if (Tcl_ListObjGetElements(NULL, objv[0], &fcount, &fobjs) != TCL_OK
|| (fcount < 2 || fcount > 6)) {
Tcl_AppendResult(interp, "bad font description \"", fstring,
- "\"", NULL);
+ "\"", (char *)NULL);
return -1;
}
@@ -281,7 +282,7 @@ static Tcl_Size ParseFont (
if (Tcl_GetIntFromObj(interp, fobjs[1], &size) != TCL_OK) {
const char *value = Tcl_GetString(fobjs[1]);
Tcl_AppendResult(interp, "bad size \"", value,
- "\"; should be an integer", NULL);
+ "\"; should be an integer", (char *)NULL);
return -1;
}
@@ -300,7 +301,7 @@ static Tcl_Size ParseJoinStyle (
if (objc == 0) {
Tcl_AppendResult(interp,
- "option \"-joinstyle\" needs an additional argument", NULL);
+ "option \"-joinstyle\" needs an additional argument", (char *)NULL);
return -1;
}
@@ -350,7 +351,7 @@ static Tcl_Size ParseStyle (
if (objc == 0) {
Tcl_AppendResult(interp,
- "option \"-style\" needs an additional argument", NULL);
+ "option \"-style\" needs an additional argument", (char *)NULL);
return -1;
}
@@ -383,7 +384,7 @@ static int GdiArc(
{
WinprintData *dataPtr = (WinprintData *)clientData;
if (dataPtr->printDC == NULL) {
- Tcl_AppendResult(interp, "device context not initialized", NULL);
+ Tcl_AppendResult(interp, "device context not initialized", (char *)NULL);
return TCL_ERROR;
}
@@ -587,7 +588,7 @@ static int GdiPhoto(
{
WinprintData *dataPtr = (WinprintData *)clientData;
if (dataPtr->printDC == NULL) {
- Tcl_AppendResult(interp, "device context not initialized", NULL);
+ Tcl_AppendResult(interp, "device context not initialized", (char *)NULL);
return TCL_ERROR;
}
HDC hDC = dataPtr->printDC;
@@ -653,14 +654,14 @@ static int GdiPhoto(
}
if (! photoname) { /* No photo provided. */
- Tcl_AppendResult(interp, "no photo name provided", NULL);
+ Tcl_AppendResult(interp, "no photo name provided", (char *)NULL);
return TCL_ERROR;
}
photo_handle = Tk_FindPhoto(interp, photoname);
if (! photo_handle) {
Tcl_AppendResult(interp, "photo name \"", photoname,
- "\" can't be located", NULL);
+ "\" can't be located", (char *)NULL);
return TCL_ERROR;
}
Tk_PhotoGetImage(photo_handle, &img_block);
@@ -677,7 +678,7 @@ static int GdiPhoto(
pbuf = (char *)attemptckalloc(sll * ny * sizeof(char));
if (! pbuf) { /* Memory allocation failure. */
Tcl_AppendResult(interp,
- "::tk::print::_gdi photo failed--out of memory", NULL);
+ "::tk::print::_gdi photo failed--out of memory", (char *)NULL);
return TCL_ERROR;
}
@@ -882,7 +883,7 @@ static Tcl_Size ParseArrow (
if (objc == 0) {
Tcl_AppendResult(interp,
- "option \"-arrow\" needs an additional argument", NULL);
+ "option \"-arrow\" needs an additional argument", (char *)NULL);
return -1;
}
@@ -915,7 +916,7 @@ static Tcl_Size ParseArrShp(
if (objc == 0) {
Tcl_AppendResult(interp,
- "option \"-arrowshape\" requires an additional argument", NULL);
+ "option \"-arrowshape\" requires an additional argument", (char *)NULL);
return -1;
}
if (Tcl_ListObjGetElements(interp, objv[0], &count, &shpObjs) != TCL_OK) {
@@ -926,7 +927,7 @@ static Tcl_Size ParseArrShp(
Tcl_GetDoubleFromObj(NULL, shpObjs[1], &a1) != TCL_OK ||
Tcl_GetDoubleFromObj(NULL, shpObjs[2], &a2) != TCL_OK) {
Tcl_AppendResult(interp, "arrow shape should be a list ",
- "with three numbers", NULL);
+ "with three numbers", (char *)NULL);
return -1;
}
arrowShape[0] = ROUND32(a0);
@@ -952,7 +953,7 @@ static Tcl_Size ParseCapStyle (
if (objc == 0) {
Tcl_AppendResult(interp,
- "option \"-capstyle\" needs an additional argument", NULL);
+ "option \"-capstyle\" needs an additional argument", (char *)NULL);
return -1;
}
@@ -1000,7 +1001,7 @@ static Tcl_Size ParseSmooth(
if (objc == 0) {
Tcl_AppendResult(interp,
- "option \"-smooth\" requires an additional argument", NULL);
+ "option \"-smooth\" requires an additional argument", (char *)NULL);
return -1;
}
/* Argument is a boolean value, "bezier" or "raw". */
@@ -1011,7 +1012,7 @@ static Tcl_Size ParseSmooth(
if (Tcl_GetIndexFromObjStruct(interp, objv[0], smoothmethods,
sizeof(struct SmoothMethod), "smooth method", 0, &index) != TCL_OK) {
- Tcl_AppendResult(interp, " or a boolean value", NULL);
+ Tcl_AppendResult(interp, " or a boolean value", (char *)NULL);
return -1;
}
*(int *)dstPtr = smoothmethods[index].method;
@@ -1038,7 +1039,7 @@ static int GdiLine(
{
WinprintData *dataPtr = (WinprintData *)clientData;
if (dataPtr->printDC == NULL) {
- Tcl_AppendResult(interp, "device context not initialized", NULL);
+ Tcl_AppendResult(interp, "device context not initialized", (char *)NULL);
return TCL_ERROR;
}
HDC hDC = dataPtr->printDC;
@@ -1078,7 +1079,7 @@ static int GdiLine(
}
polypoints = (POINT *)attemptckalloc((objc - 2)/2 * sizeof(POINT));
if (polypoints == NULL) {
- Tcl_AppendResult(interp, "Out of memory in GdiLine", NULL);
+ Tcl_AppendResult(interp, "Out of memory in GdiLine", (char *)NULL);
return TCL_ERROR;
}
polypoints[0].x = ROUND32(p1x);
@@ -1266,7 +1267,7 @@ static int GdiOval(
{
WinprintData *dataPtr = (WinprintData *)clientData;
if (dataPtr->printDC == NULL) {
- Tcl_AppendResult(interp, "device context not initialized", NULL);
+ Tcl_AppendResult(interp, "device context not initialized", (char *)NULL);
return TCL_ERROR;
}
HDC hDC = dataPtr->printDC;
@@ -1375,7 +1376,7 @@ static int GdiPolygon(
{
WinprintData *dataPtr = (WinprintData *)clientData;
if (dataPtr->printDC == NULL) {
- Tcl_AppendResult(interp, "device context not initialized", NULL);
+ Tcl_AppendResult(interp, "device context not initialized", (char *)NULL);
return TCL_ERROR;
}
HDC hDC = dataPtr->printDC;
@@ -1411,7 +1412,7 @@ static int GdiPolygon(
polypoints = (POINT *)attemptckalloc((objc - 2)/2 * sizeof(POINT));
if (polypoints == NULL) {
/* TODO: unreachable */
- Tcl_AppendResult(interp, "Out of memory in GdiPolygon", NULL);
+ Tcl_AppendResult(interp, "Out of memory in GdiPolygon", (char *)NULL);
return TCL_ERROR;
}
polypoints[0].x = ROUND32(p1x);
@@ -1515,7 +1516,7 @@ static int GdiRectangle(
{
WinprintData *dataPtr = (WinprintData *)clientData;
if (dataPtr->printDC == NULL) {
- Tcl_AppendResult(interp, "device context not initialized", NULL);
+ Tcl_AppendResult(interp, "device context not initialized", (char *)NULL);
return TCL_ERROR;
}
HDC hDC = dataPtr->printDC;
@@ -1634,7 +1635,7 @@ static int GdiCharWidths(
*/
WinprintData *dataPtr = (WinprintData *)clientData;
if (dataPtr->printDC == NULL) {
- Tcl_AppendResult(interp, "device context not initialized", NULL);
+ Tcl_AppendResult(interp, "device context not initialized", (char *)NULL);
return TCL_ERROR;
}
HDC hDC = dataPtr->printDC;
@@ -1675,7 +1676,7 @@ static int GdiCharWidths(
/* is an error not providing a font */
if (! fontobj) {
- Tcl_AppendResult(interp, "error: font must be specified", NULL);
+ Tcl_AppendResult(interp, "error: font must be specified", (char *)NULL);
return TCL_ERROR;
}
@@ -1728,7 +1729,7 @@ static int GdiCharWidths(
}
/* The return value should be the array name(?). */
- Tcl_AppendResult(interp, aryvarname, NULL);
+ Tcl_AppendResult(interp, aryvarname, (char *)NULL);
return TCL_OK;
}
@@ -1792,7 +1793,7 @@ static Tcl_Size ParseJustify (
if (objc == 0) {
Tcl_AppendResult(interp,
- "option \"-justify\" needs an additional argument", NULL);
+ "option \"-justify\" needs an additional argument", (char *)NULL);
return -1;
}
@@ -1812,7 +1813,7 @@ static int GdiText(
{
WinprintData *dataPtr = (WinprintData *)clientData;
if (dataPtr->printDC == NULL) {
- Tcl_AppendResult(interp, "device context not initialized", NULL);
+ Tcl_AppendResult(interp, "device context not initialized", (char *)NULL);
return TCL_ERROR;
}
HDC hDC = dataPtr->printDC;
@@ -1880,7 +1881,7 @@ static int GdiText(
}
/* is an error not providing a font */
if (! fontobj) {
- Tcl_AppendResult(interp, "error: font must be specified", NULL);
+ Tcl_AppendResult(interp, "error: font must be specified", (char *)NULL);
return TCL_ERROR;
}
@@ -2027,7 +2028,7 @@ static int GdiTextPlain(
{
WinprintData *dataPtr = (WinprintData *)clientData;
if (dataPtr->printDC == NULL) {
- Tcl_AppendResult(interp, "device context not initialized", NULL);
+ Tcl_AppendResult(interp, "device context not initialized", (char *)NULL);
return TCL_ERROR;
}
HDC hDC = dataPtr->printDC;
@@ -2213,7 +2214,7 @@ static int GdiMap(
{
WinprintData *dataPtr = (WinprintData *)clientData;
if (dataPtr->printDC == NULL) {
- Tcl_AppendResult(interp, "device context not initialized", NULL);
+ Tcl_AppendResult(interp, "device context not initialized", (char *)NULL);
return TCL_ERROR;
}
HDC hDC = dataPtr->printDC;
@@ -2227,7 +2228,7 @@ static int GdiMap(
SIZE vextent; /* Viewport extent. */
POINT worigin; /* Device origin. */
POINT vorigin; /* Viewport origin. */
- int argno;
+ Tcl_Size argno;
/* Keep track of what parts of the function need to be executed. */
int need_usage = 0;
@@ -2239,13 +2240,13 @@ static int GdiMap(
/* Required parameter: HDC for printer. */
if (objc < 2) {
- Tcl_AppendResult(interp, usage_message, NULL);
+ Tcl_AppendResult(interp, usage_message, (char *)NULL);
return TCL_ERROR;
}
if ((mapmode = GdiGetHdcInfo(hDC, &worigin, &wextent, &vorigin, &vextent)) == 0) {
/* Failed!. */
- Tcl_AppendResult(interp, "Cannot get current HDC info", NULL);
+ Tcl_AppendResult(interp, "Cannot get current HDC info", (char *)NULL);
return TCL_ERROR;
}
@@ -2337,7 +2338,7 @@ static int GdiMap(
}
if (need_usage) {
- Tcl_AppendResult(interp, usage_message, NULL);
+ Tcl_AppendResult(interp, usage_message, (char *)NULL);
return TCL_ERROR;
}
@@ -2400,7 +2401,7 @@ static int GdiCopyBits(
{
WinprintData *dataPtr = (WinprintData *)clientData;
if (dataPtr->printDC == NULL) {
- Tcl_AppendResult(interp, "device context not initialized", NULL);
+ Tcl_AppendResult(interp, "device context not initialized", (char *)NULL);
return TCL_ERROR;
}
HDC dst = dataPtr->printDC;
@@ -2454,7 +2455,7 @@ static int GdiCopyBits(
* purpose.
*/
if ((workwin = mainWin = Tk_MainWindow(interp)) == 0) {
- Tcl_AppendResult(interp, "Can't find main Tk window", NULL);
+ Tcl_AppendResult(interp, "Can't find main Tk window", (char *)NULL);
return TCL_ERROR;
}
@@ -2463,7 +2464,7 @@ static int GdiCopyBits(
*/
/* HDC is required. */
if (objc < 2) {
- Tcl_AppendResult(interp, usage_message, NULL);
+ Tcl_AppendResult(interp, usage_message, (char *)NULL);
return TCL_ERROR;
}
@@ -2509,7 +2510,7 @@ static int GdiCopyBits(
int count = sscanf(Tcl_GetString(objv[++k]), "%f%f%f%f", &a, &b, &c, &d);
if (count < 2) { /* Can't make heads or tails of it.... */
- Tcl_AppendResult(interp, usage_message, NULL);
+ Tcl_AppendResult(interp, usage_message, (char *)NULL);
return TCL_ERROR;
}
src_x = (int)a;
@@ -2524,7 +2525,7 @@ static int GdiCopyBits(
count = sscanf(Tcl_GetString(objv[++k]), "%f%f%f%f", &a, &b, &c, &d);
if (count < 2) { /* Can't make heads or tails of it.... */
- Tcl_AppendResult(interp, usage_message, NULL);
+ Tcl_AppendResult(interp, usage_message, (char *)NULL);
return TCL_ERROR;
}
dst_x = (int)a;
@@ -2560,7 +2561,7 @@ static int GdiCopyBits(
* Check to ensure no incompatible arguments were used.
*/
if (do_window && do_screen) {
- Tcl_AppendResult(interp, usage_message, NULL);
+ Tcl_AppendResult(interp, usage_message, (char *)NULL);
return TCL_ERROR;
}
@@ -2574,7 +2575,7 @@ static int GdiCopyBits(
}
if ((wnd = Tk_WindowId(workwin)) == 0) {
- Tcl_AppendResult(interp, "Can't get id for Tk window", NULL);
+ Tcl_AppendResult(interp, "Can't get id for Tk window", (char *)NULL);
return TCL_ERROR;
}
@@ -2582,7 +2583,7 @@ static int GdiCopyBits(
if ((hwnd = Tk_GetHWND(wnd)) == 0) {
Tcl_AppendResult(interp, "Can't get Windows handle for Tk window",
- NULL);
+ (char *)NULL);
return TCL_ERROR;
}
@@ -2603,7 +2604,7 @@ static int GdiCopyBits(
/* Given the HWND, we can get the window's device context. */
if ((src = GetWindowDC(hwnd)) == 0) {
- Tcl_AppendResult(interp, "Can't get device context for Tk window", NULL);
+ Tcl_AppendResult(interp, "Can't get device context for Tk window", (char *)NULL);
return TCL_ERROR;
}
@@ -2619,13 +2620,13 @@ static int GdiCopyBits(
hgt = tl.bottom - tl.top;
} else {
if ((hgt = Tk_Height(workwin)) <= 0) {
- Tcl_AppendResult(interp, "Can't get height of Tk window", NULL);
+ Tcl_AppendResult(interp, "Can't get height of Tk window", (char *)NULL);
ReleaseDC(hwnd,src);
return TCL_ERROR;
}
if ((wid = Tk_Width(workwin)) <= 0) {
- Tcl_AppendResult(interp, "Can't get width of Tk window", NULL);
+ Tcl_AppendResult(interp, "Can't get width of Tk window", (char *)NULL);
ReleaseDC(hwnd,src);
return TCL_ERROR;
}
@@ -2688,14 +2689,14 @@ static int GdiCopyBits(
/* GdiFlush();. */
if (!hDib) {
- Tcl_AppendResult(interp, "Can't create DIB", NULL);
+ Tcl_AppendResult(interp, "Can't create DIB", (char *)NULL);
ReleaseDC(hwnd,src);
return TCL_ERROR;
}
lpDIBHdr = (LPBITMAPINFOHEADER) GlobalLock(hDib);
if (!lpDIBHdr) {
- Tcl_AppendResult(interp, "Can't get DIB header", NULL);
+ Tcl_AppendResult(interp, "Can't get DIB header", (char *)NULL);
ReleaseDC(hwnd,src);
return TCL_ERROR;
}
@@ -3970,7 +3971,7 @@ static int PrintSelectPrinter(
WinprintData *dataPtr = (WinprintData *)clientData;
if (dataPtr->printDC != NULL) {
Tcl_AppendResult(interp, "device context still in use: call "
- "_closedoc first", NULL);
+ "_closedoc first", (char *)NULL);
return TCL_ERROR;
}
PRINTDLGW pd;
@@ -4015,11 +4016,11 @@ static int PrintSelectPrinter(
devnames = (LPDEVNAMES) GlobalLock(pd.hDevNames);
if (! devmode) {
Tcl_AppendResult(interp, "selected printer doesn't have extended info",
- NULL);
+ (char *)NULL);
return TCL_ERROR;
}
if (! devnames) {
- Tcl_AppendResult(interp, "can't get device names", NULL);
+ Tcl_AppendResult(interp, "can't get device names", (char *)NULL);
return TCL_ERROR;
}
@@ -4057,7 +4058,7 @@ static int PrintSelectPrinter(
Tcl_NewIntObj(paper_height), 0);
} else {
Tcl_UnsetVar(interp, "::tk::print::printer_name", 0);
- Tcl_AppendResult(interp, "selected printer doesn't have name", NULL);
+ Tcl_AppendResult(interp, "selected printer doesn't have name", (char *)NULL);
DeleteDC(dataPtr->printDC);
dataPtr->printDC = NULL;
returnVal = TCL_ERROR;
@@ -4091,7 +4092,7 @@ int PrintOpenPrinter(
{
WinprintData *dataPtr = (WinprintData *)clientData;
if (dataPtr->printDC == NULL) {
- Tcl_AppendResult(interp, "device context not initialized", NULL);
+ Tcl_AppendResult(interp, "device context not initialized", (char *)NULL);
return TCL_ERROR;
}
Tcl_DString ds;
@@ -4111,7 +4112,7 @@ int PrintOpenPrinter(
Tcl_DStringInit(&ds);
if ((OpenPrinterW(Tcl_UtfToWCharDString(printer, -1, &ds),
(LPHANDLE)&dataPtr->printDC, NULL)) == FALSE) {
- Tcl_AppendResult(interp, "unable to open printer", NULL);
+ Tcl_AppendResult(interp, "unable to open printer", (char *)NULL);
Tcl_DStringFree(&ds);
return TCL_ERROR;
}
@@ -4141,7 +4142,7 @@ int PrintClosePrinter(
{
WinprintData *dataPtr = (WinprintData *)clientData;
if (dataPtr->printDC == NULL) {
- Tcl_AppendResult(interp, "device context not initialized", NULL);
+ Tcl_AppendResult(interp, "device context not initialized", (char *)NULL);
return TCL_ERROR;
}
@@ -4169,7 +4170,7 @@ int PrintOpenDoc(
{
WinprintData *dataPtr = (WinprintData *)clientData;
if (dataPtr->printDC == NULL) {
- Tcl_AppendResult(interp, "device context not initialized", NULL);
+ Tcl_AppendResult(interp, "device context not initialized", (char *)NULL);
return TCL_ERROR;
}
int output = 0;
@@ -4195,7 +4196,7 @@ int PrintOpenDoc(
*/
output = StartDocW(dataPtr->printDC, &dataPtr->di);
if (output <= 0) {
- Tcl_AppendResult(interp, "unable to start document", NULL);
+ Tcl_AppendResult(interp, "unable to start document", (char *)NULL);
return TCL_ERROR;
}
@@ -4225,7 +4226,7 @@ int PrintOpenDoc(
Tcl_SetObjResult(interp, Tcl_NewListObj(2, ret));
} else {
Tcl_AppendResult(interp, "_opendoc: can't determine font ",
- "width and height", NULL);
+ "width and height", (char *)NULL);
return TCL_ERROR;
}
}
@@ -4254,12 +4255,12 @@ int PrintCloseDoc(
{
WinprintData *dataPtr = (WinprintData *)clientData;
if (dataPtr->printDC == NULL) {
- Tcl_AppendResult(interp, "device context not initialized", NULL);
+ Tcl_AppendResult(interp, "device context not initialized", (char *)NULL);
return TCL_ERROR;
}
if (EndDoc(dataPtr->printDC) <= 0) {
- Tcl_AppendResult(interp, "unable to close document", NULL);
+ Tcl_AppendResult(interp, "unable to close document", (char *)NULL);
return TCL_ERROR;
}
/* delete the font object that might be created as default */
@@ -4292,13 +4293,13 @@ int PrintOpenPage(
{
WinprintData *dataPtr = (WinprintData *)clientData;
if (dataPtr->printDC == NULL) {
- Tcl_AppendResult(interp, "device context not initialized", NULL);
+ Tcl_AppendResult(interp, "device context not initialized", (char *)NULL);
return TCL_ERROR;
}
/*Start an individual page.*/
if (StartPage(dataPtr->printDC) <= 0) {
- Tcl_AppendResult(interp, "unable to start page", NULL);
+ Tcl_AppendResult(interp, "unable to start page", (char *)NULL);
return TCL_ERROR;
}
@@ -4326,12 +4327,12 @@ int PrintClosePage(
{
WinprintData *dataPtr = (WinprintData *)clientData;
if (dataPtr->printDC == NULL) {
- Tcl_AppendResult(interp, "device context not initialized", NULL);
+ Tcl_AppendResult(interp, "device context not initialized", (char *)NULL);
return TCL_ERROR;
}
if (EndPage(dataPtr->printDC) <= 0) {
- Tcl_AppendResult(interp, "unable to close page", NULL);
+ Tcl_AppendResult(interp, "unable to close page", (char *)NULL);
return TCL_ERROR;
}
return TCL_OK;
diff --git a/win/tkWinImage.c b/win/tkWinImage.c
index 72f4d50..ee9507a 100644
--- a/win/tkWinImage.c
+++ b/win/tkWinImage.c
@@ -170,7 +170,7 @@ PutPixel(
* Pixel is bit in MSBFirst order.
*/
- int mask = (0x80 >> (x%8));
+ unsigned char mask = (0x80 >> (x%8));
if (pixel) {
(*destPtr) |= mask;
@@ -295,7 +295,7 @@ XGetImageZPixmap(
HBITMAP hbmp, hbmpPrev;
BITMAPINFO *bmInfo = NULL;
HPALETTE hPal, hPalPrev1 = 0, hPalPrev2 = 0;
- int size;
+ size_t size;
unsigned int n;
unsigned int depth;
unsigned char *data;
@@ -357,7 +357,7 @@ XGetImageZPixmap(
bmInfo->bmiHeader.biWidth = width;
bmInfo->bmiHeader.biHeight = -(int) height;
bmInfo->bmiHeader.biPlanes = 1;
- bmInfo->bmiHeader.biBitCount = depth;
+ bmInfo->bmiHeader.biBitCount = (WORD)depth;
bmInfo->bmiHeader.biCompression = BI_RGB;
bmInfo->bmiHeader.biSizeImage = 0;
bmInfo->bmiHeader.biXPelsPerMeter = 0;
diff --git a/win/tkWinInt.h b/win/tkWinInt.h
index 36aa6a4..aaea20c 100644
--- a/win/tkWinInt.h
+++ b/win/tkWinInt.h
@@ -142,7 +142,7 @@ MODULE_SCOPE const int tkpWinBltModes[];
* Internal functions used by more than one source file.
*/
-#include "tkIntPlatDecls.h"
+#include "tkIntPlatDecls.h" /* IWYU pragma: export */
#ifdef __cplusplus
extern "C" {
@@ -185,12 +185,14 @@ MODULE_SCOPE Tcl_Encoding TkWinGetUnicodeEncoding(void);
MODULE_SCOPE void TkWinSetupSystemFonts(TkMainInfo *mainPtr);
/*
- * Values returned by TkWinGetPlatformTheme.
+ * Values used to be returned by TkWinGetPlatformTheme.
*/
-#define TK_THEME_WIN_CLASSIC 1
-#define TK_THEME_WIN_XP 2
-#define TK_THEME_WIN_VISTA 3
+#ifndef TK_NO_DEPRECATED
+# define TK_THEME_WIN_CLASSIC 1
+# define TK_THEME_WIN_XP 2
+# define TK_THEME_WIN_VISTA 3
+#endif
/*
* The following is implemented in tkWinWm and used by tkWinEmbed.c
diff --git a/win/tkWinKey.c b/win/tkWinKey.c
index 61cb06e..b343ec5 100644
--- a/win/tkWinKey.c
+++ b/win/tkWinKey.c
@@ -97,7 +97,7 @@ TkpGetString(
* result. */
{
XKeyEvent *keyEv = &eventPtr->xkey;
- int len;
+ Tcl_Size len;
char buf[6];
Tcl_DStringInit(dsPtr);
diff --git a/win/tkWinMenu.c b/win/tkWinMenu.c
index 6d974b2..12bfef4 100644
--- a/win/tkWinMenu.c
+++ b/win/tkWinMenu.c
@@ -333,7 +333,7 @@ TkpNewMenu(
if (winMenuHdl == NULL) {
Tcl_SetObjResult(menuPtr->interp, Tcl_NewStringObj(
"No more menus can be allocated.", TCL_INDEX_NONE));
- Tcl_SetErrorCode(menuPtr->interp, "TK", "MENU", "SYSTEM_RESOURCES", NULL);
+ Tcl_SetErrorCode(menuPtr->interp, "TK", "MENU", "SYSTEM_RESOURCES", (char *)NULL);
return TCL_ERROR;
}
@@ -576,7 +576,8 @@ ReconfigureWindowsMenu(
LPCWSTR lpNewItem;
UINT flags;
UINT itemID;
- int i, count, systemMenu = 0, base;
+ Tcl_Size i, count;
+ int systemMenu = 0, base;
Tcl_DString translatedText;
if (NULL == winMenuHdl) {
@@ -652,7 +653,7 @@ ReconfigureWindowsMenu(
flags |= MF_MENUBREAK;
}
- itemID = PTR2INT(mePtr->platformEntryData);
+ itemID = (UINT)PTR2INT(mePtr->platformEntryData);
if ((mePtr->type == CASCADE_ENTRY)
&& (mePtr->childMenuRefPtr != NULL)
&& (mePtr->childMenuRefPtr->menuPtr != NULL)) {
@@ -672,7 +673,7 @@ ReconfigureWindowsMenu(
* If the MF_POPUP flag is set, then the id is interpreted
* as the handle of a submenu.
*/
- itemID = PTR2INT(childMenuHdl);
+ itemID = (UINT)PTR2INT(childMenuHdl);
}
}
if ((menuPtr->menuType == MENUBAR)
@@ -1925,18 +1926,16 @@ DrawMenuEntryAccelerator(
* Draw disabled 3D text highlight only with the Win95/98 look.
*/
- if (TkWinGetPlatformTheme() != TK_THEME_WIN_XP) {
- if ((mePtr->state == ENTRY_DISABLED)
- && (menuPtr->disabledFgPtr != NULL) && (accel != NULL)) {
- COLORREF oldFgColor = gc->foreground;
+ if ((mePtr->state == ENTRY_DISABLED)
+ && (menuPtr->disabledFgPtr != NULL) && (accel != NULL)) {
+ COLORREF oldFgColor = gc->foreground;
- gc->foreground = GetSysColor(COLOR_3DHILIGHT);
- if (!(mePtr->entryFlags & ENTRY_PLATFORM_FLAG1)) {
- Tk_DrawChars(menuPtr->display, d, gc, tkfont, accel,
- mePtr->accelLength, leftEdge + 1, baseline + 1);
- }
- gc->foreground = oldFgColor;
+ gc->foreground = GetSysColor(COLOR_3DHILIGHT);
+ if (!(mePtr->entryFlags & ENTRY_PLATFORM_FLAG1)) {
+ Tk_DrawChars(menuPtr->display, d, gc, tkfont, accel,
+ mePtr->accelLength, leftEdge + 1, baseline + 1);
}
+ gc->foreground = oldFgColor;
}
if (accel != NULL) {
@@ -2063,9 +2062,9 @@ DrawMenuSeparator(
XPoint points[2];
Tk_3DBorder border;
- points[0].x = x;
- points[0].y = y + height / 2;
- points[1].x = x + width - 1;
+ points[0].x = (short)x;
+ points[0].y = (short)(y + height / 2);
+ points[1].x = (short)(x + width - 1);
points[1].y = points[0].y;
border = Tk_Get3DBorderFromObj(menuPtr->tkwin, menuPtr->borderPtr);
Tk_Draw3DPolygon(menuPtr->tkwin, d, border, points, 2, 1,
@@ -2102,7 +2101,7 @@ DrawMenuUnderline(
int height) /* Height of entry */
{
if ((mePtr->underline >= 0) && (mePtr->labelPtr != NULL)) {
- int len;
+ Tcl_Size len;
len = Tcl_GetCharLength(mePtr->labelPtr);
if (mePtr->underline < len) {
@@ -2469,22 +2468,20 @@ DrawMenuEntryLabel(
int baseline = y + (height + fmPtr->ascent - fmPtr->descent) / 2;
const char *label = Tcl_GetString(mePtr->labelPtr);
- if (TkWinGetPlatformTheme() != TK_THEME_WIN_XP) {
- /*
- * Win 95/98 systems draw disabled menu text with a 3D
- * highlight, unless the menu item is highlighted,
- */
+ /*
+ * Win 95/98 systems draw disabled menu text with a 3D
+ * highlight, unless the menu item is highlighted,
+ */
- if ((mePtr->state == ENTRY_DISABLED) &&
- !(mePtr->entryFlags & ENTRY_PLATFORM_FLAG1)) {
- COLORREF oldFgColor = gc->foreground;
+ if ((mePtr->state == ENTRY_DISABLED) &&
+ !(mePtr->entryFlags & ENTRY_PLATFORM_FLAG1)) {
+ COLORREF oldFgColor = gc->foreground;
- gc->foreground = GetSysColor(COLOR_3DHILIGHT);
- Tk_DrawChars(menuPtr->display, d, gc, tkfont, label,
- mePtr->labelLength, leftEdge + textXOffset + 1,
- baseline + textYOffset + 1);
- gc->foreground = oldFgColor;
- }
+ gc->foreground = GetSysColor(COLOR_3DHILIGHT);
+ Tk_DrawChars(menuPtr->display, d, gc, tkfont, label,
+ mePtr->labelLength, leftEdge + textXOffset + 1,
+ baseline + textYOffset + 1);
+ gc->foreground = oldFgColor;
}
Tk_DrawChars(menuPtr->display, d, gc, tkfont, label,
mePtr->labelLength, leftEdge + textXOffset,
@@ -2570,21 +2567,21 @@ DrawTearoffEntry(
return;
}
- points[0].x = x;
- points[0].y = y + height/2;
+ points[0].x = (short)x;
+ points[0].y = (short)(y + height/2);
points[1].y = points[0].y;
segmentWidth = 6;
maxX = x + width - 1;
border = Tk_Get3DBorderFromObj(menuPtr->tkwin, menuPtr->borderPtr);
while (points[0].x < maxX) {
- points[1].x = points[0].x + segmentWidth;
+ points[1].x = points[0].x + (short)segmentWidth;
if (points[1].x > maxX) {
- points[1].x = maxX;
+ points[1].x = (short)maxX;
}
Tk_Draw3DPolygon(menuPtr->tkwin, d, border, points, 2, 1,
TK_RELIEF_RAISED);
- points[0].x += 2*segmentWidth;
+ points[0].x += (short)(2*segmentWidth);
}
}
@@ -3383,10 +3380,6 @@ SetDefaults(
metrics.cbSize = sizeof(metrics);
- if (TkWinGetPlatformTheme() != TK_THEME_WIN_VISTA) {
- metrics.cbSize -= sizeof(int);
- }
-
SystemParametersInfoW(SPI_GETNONCLIENTMETRICS, metrics.cbSize,
&metrics, 0);
menuFont = CreateFontIndirectW(&metrics.lfMenuFont);
diff --git a/win/tkWinPixmap.c b/win/tkWinPixmap.c
index ad26c12..74e58c9 100644
--- a/win/tkWinPixmap.c
+++ b/win/tkWinPixmap.c
@@ -37,7 +37,7 @@ Tk_GetPixmap(
int depth)
{
TkWinDrawable *newTwdPtr, *twdPtr;
- int planes;
+ DWORD planes;
Screen *screen;
LastKnownRequestProcessed(display)++;
@@ -59,11 +59,11 @@ Tk_GetPixmap(
screen = ScreenOfDisplay(display, 0);
planes = 1;
if (depth == DefaultDepthOfScreen(screen)) {
- planes = PTR2INT(screen->ext_data);
+ planes = (DWORD)PTR2INT(screen->ext_data);
depth /= planes;
}
newTwdPtr->bitmap.handle =
- CreateBitmap(width, height, (DWORD) planes, (DWORD) depth, NULL);
+ CreateBitmap(width, height, planes, (DWORD) depth, NULL);
/*
* CreateBitmap tries to use memory on the graphics card. If it fails,
@@ -81,8 +81,8 @@ Tk_GetPixmap(
bitmapInfo.bmiHeader.biSize = sizeof(bitmapInfo.bmiHeader);
bitmapInfo.bmiHeader.biWidth = width;
bitmapInfo.bmiHeader.biHeight = height;
- bitmapInfo.bmiHeader.biPlanes = planes;
- bitmapInfo.bmiHeader.biBitCount = depth;
+ bitmapInfo.bmiHeader.biPlanes = (WORD)planes;
+ bitmapInfo.bmiHeader.biBitCount = (WORD)depth;
bitmapInfo.bmiHeader.biCompression = BI_RGB;
bitmapInfo.bmiHeader.biSizeImage = 0;
dc = GetDC(NULL);
diff --git a/win/tkWinPointer.c b/win/tkWinPointer.c
index 5ccd862..4dc6a89 100644
--- a/win/tkWinPointer.c
+++ b/win/tkWinPointer.c
@@ -49,10 +49,10 @@ static void MouseTimerProc(void *clientData);
*----------------------------------------------------------------------
*/
-int
+unsigned int
TkWinGetModifierState(void)
{
- int state = 0;
+ unsigned int state = 0;
if (GetKeyState(VK_SHIFT) & 0x8000) {
state |= ShiftMask;
@@ -143,7 +143,7 @@ TkWinPointerEvent(
}
tkwin = Tk_HWNDToWindow(hwnd);
- state = TkWinGetModifierState();
+ state = (int)TkWinGetModifierState();
Tk_UpdatePointer(tkwin, pos.x, pos.y, state);
@@ -525,7 +525,7 @@ XSetInputFocus(
*----------------------------------------------------------------------
*/
-int
+size_t
TkpChangeFocus(
TkWindow *winPtr, /* Window that is to receive the X focus. */
int force) /* Non-zero means claim the focus even if it
@@ -534,7 +534,8 @@ TkpChangeFocus(
{
TkDisplay *dispPtr = winPtr->dispPtr;
Window focusWindow;
- int dummy, serial;
+ int dummy;
+ size_t serial;
TkWindow *winPtr2;
if (!force) {
diff --git a/win/tkWinRegion.c b/win/tkWinRegion.c
index b6f87dc..cc9272c 100644
--- a/win/tkWinRegion.c
+++ b/win/tkWinRegion.c
@@ -300,6 +300,53 @@ TkpCopyRegion(
{
CombineRgn((HRGN)dst, (HRGN)src, NULL, RGN_COPY);
}
+
+int
+XUnionRegion(
+ Region srca,
+ Region srcb,
+ Region dr_return)
+{
+ CombineRgn((HRGN)dr_return, (HRGN)srca, (HRGN)srcb, RGN_OR);
+ return 1;
+}
+
+int
+XOffsetRegion(
+ Region r,
+ int dx,
+ int dy)
+{
+ OffsetRgn((HRGN)r, dx, dy);
+ return 1;
+}
+
+Bool
+XPointInRegion(
+ Region r,
+ int x,
+ int y)
+{
+ return PtInRegion((HRGN)r, x, y);
+}
+
+Bool
+XEqualRegion(
+ Region r1,
+ Region r2)
+{
+ return EqualRgn((HRGN)r1, (HRGN)r2);
+}
+
+int
+XXorRegion(
+ Region sra,
+ Region srb,
+ Region dr_return)
+{
+ CombineRgn((HRGN)dr_return, (HRGN)sra, (HRGN)srb, RGN_XOR);
+ return 0;
+}
/*
* Local Variables:
diff --git a/win/tkWinSend.c b/win/tkWinSend.c
index 89ff7db..b4f57d5 100644
--- a/win/tkWinSend.c
+++ b/win/tkWinSend.c
@@ -147,7 +147,7 @@ Tk_SetAppName(
if (FAILED(hr)) {
Tcl_SetObjResult(interp, Tcl_NewStringObj(
"failed to initialize the COM library", TCL_INDEX_NONE));
- Tcl_SetErrorCode(interp, "TK", "SEND", "COM", NULL);
+ Tcl_SetErrorCode(interp, "TK", "SEND", "COM", (char *)NULL);
return "";
}
tsdPtr->initialized = 1;
@@ -334,7 +334,8 @@ Tk_SendObjCmd(
};
const char *stringRep;
int result = TCL_OK;
- int i, async = 0, index;
+ int async = 0, index;
+ Tcl_Size i;
/*
* Process the command options.
diff --git a/win/tkWinSysTray.c b/win/tkWinSysTray.c
index 927f1fb..b44dce5 100644
--- a/win/tkWinSysTray.c
+++ b/win/tkWinSysTray.c
@@ -101,10 +101,12 @@ DrawXORMask(
int x, y;
/* Sanity checks */
- if (lpIcon == NULL)
+ if (lpIcon == NULL) {
return FALSE;
- if (lpIcon->lpBits == NULL)
+ }
+ if (lpIcon->lpBits == NULL) {
return FALSE;
+ }
/* Account for height*2 thing */
lpIcon->lpbi->bmiHeader.biHeight /= 2;
@@ -152,10 +154,12 @@ DrawANDMask(
int x, y;
/* Sanity checks */
- if (lpIcon == NULL)
+ if (lpIcon == NULL) {
return FALSE;
- if (lpIcon->lpBits == NULL)
+ }
+ if (lpIcon->lpBits == NULL) {
return FALSE;
+ }
/* Need a bitmap header for the mono mask */
lpbi = ckalloc(sizeof(BITMAPINFO) + (2 * sizeof(RGBQUAD)));
@@ -233,7 +237,8 @@ TaskbarOperation(
Tcl_DString dst;
Tcl_DStringInit(&dst);
str = (WCHAR *)Tcl_UtfToWCharDString(Tcl_GetString(icoPtr->taskbar_txt), TCL_INDEX_NONE, &dst);
- wcsncpy(ni.szTip, str, (Tcl_DStringLength(&dst) + 2) / 2);
+ wcsncpy(ni.szTip, str, sizeof(ni.szTip) / sizeof(WCHAR) - 1);
+ ni.szTip[sizeof(ni.szTip) / sizeof(WCHAR) - 1] = '\0';
Tcl_DStringFree(&dst);
} else {
ni.szTip[0] = 0;
@@ -352,10 +357,11 @@ static IcoInfo *
GetIcoPtr(
Tcl_Interp *interp,
IcoInterpInfo *icoInterpPtr,
- const char *string)
+ Tcl_Obj *obj)
{
IcoInfo *icoPtr;
unsigned id;
+ const char *string = Tcl_GetString(obj);
const char *start;
char *end;
@@ -395,15 +401,15 @@ notfound:
*----------------------------------------------------------------------
*/
-static int
+static size_t
GetInt(
- long theint,
+ Tcl_Size theint,
char *buffer,
size_t len)
{
- snprintf(buffer, len, "0x%lx", theint);
+ snprintf(buffer, len, "0x%" TCL_SIZE_MODIFIER "x", theint);
buffer[len - 1] = 0;
- return (int) strlen(buffer);
+ return strlen(buffer);
}
/*
@@ -457,7 +463,7 @@ TaskbarExpandPercents(
LPARAM lParam,
char *before,
char *after,
- int *aftersize)
+ size_t *aftersize)
{
#define SPACELEFT (*aftersize-(dst-after)-1)
#define AFTERLEN ((*aftersize>0)?(*aftersize*2):1024)
@@ -467,7 +473,7 @@ TaskbarExpandPercents(
dst = after;
while (*before) {
const char *ptr = before;
- int len = 1;
+ size_t len = 1;
if(*before == '%') {
switch(before[1]){
case 'M':
@@ -479,7 +485,7 @@ TaskbarExpandPercents(
}
/* case 'W': {
before++;
- len = (int)strlen(winstring);
+ len = strlen(winstring);
ptr = winstring;
break;
}
@@ -558,14 +564,15 @@ TaskbarExpandPercents(
if (SPACELEFT < len) {
char *newspace;
ptrdiff_t dist = dst - after;
- int alloclen = ALLOCLEN;
+ size_t alloclen = ALLOCLEN;
newspace = (char *)ckalloc(alloclen);
- if (dist>0)
+ if (dist>0) {
memcpy(newspace, after, dist);
+ }
if (after && *aftersize) {
ckfree(after);
}
- *aftersize =alloclen;
+ *aftersize = alloclen;
after = newspace;
dst = after + dist;
}
@@ -573,7 +580,7 @@ TaskbarExpandPercents(
memcpy(dst, ptr, len);
}
dst += len;
- if ((dst-after)>(*aftersize-1)) {
+ if ((dst-after)>((Tcl_Size)*aftersize-1)) {
printf("oops\n");
}
before++;
@@ -606,7 +613,7 @@ TaskbarEval(
{
const char *msgstring = "none";
char evalspace[200];
- int evalsize = 200;
+ size_t evalsize = 200;
char *expanded;
int fixup = 0;
@@ -823,8 +830,9 @@ CreateTaskbarHandlerWindow(void) {
static int registered = 0;
HINSTANCE hInstance = GETHINSTANCE;
if (!registered) {
- if (!RegisterHandlerClass(hInstance))
+ if (!RegisterHandlerClass(hInstance)) {
return 0;
+ }
registered = 1;
}
return CreateWindow(HANDLER_CLASS, "", WS_OVERLAPPED, 0, 0,
@@ -915,7 +923,7 @@ WinSystrayCmd(
int cmd, opt;
HICON hIcon;
- int i;
+ Tcl_Size i;
IcoInterpInfo *icoInterpPtr = (IcoInterpInfo*) clientData;
IcoInfo *icoPtr = NULL;
@@ -943,7 +951,7 @@ WinSystrayCmd(
Tcl_WrongNumArgs(interp, 2, objv, "id option value");
return TCL_ERROR;
}
- icoPtr = GetIcoPtr(interp, icoInterpPtr, Tcl_GetString(objv[2]));
+ icoPtr = GetIcoPtr(interp, icoInterpPtr, objv[2]);
if (icoPtr == NULL) {
return TCL_ERROR;
}
@@ -1032,7 +1040,7 @@ WinSystrayCmd(
Tcl_WrongNumArgs(interp, 2, objv, "id");
return TCL_ERROR;
}
- icoPtr = GetIcoPtr(interp, icoInterpPtr, Tcl_GetString(objv[2]));
+ icoPtr = GetIcoPtr(interp, icoInterpPtr, objv[2]);
if (icoPtr == NULL) {
return TCL_ERROR;
}
@@ -1067,11 +1075,7 @@ WinSysNotifyCmd(
{
IcoInterpInfo *icoInterpPtr = (IcoInterpInfo*) clientData;
IcoInfo *icoPtr;
- Tcl_DString infodst;
- Tcl_DString titledst;
NOTIFYICONDATAW ni;
- char *msgtitle;
- char *msginfo;
if (objc < 2) {
Tcl_WrongNumArgs(interp, 1, objv, "command ...");
@@ -1087,7 +1091,7 @@ WinSysNotifyCmd(
return TCL_ERROR;
}
- icoPtr = GetIcoPtr(interp, icoInterpPtr, Tcl_GetString(objv[2]));
+ icoPtr = GetIcoPtr(interp, icoInterpPtr, objv[2]);
if (icoPtr == NULL) {
return TCL_ERROR;
}
@@ -1100,24 +1104,17 @@ WinSysNotifyCmd(
ni.hIcon = icoPtr->hIcon;
ni.dwInfoFlags = NIIF_INFO; /* Use a sane platform-specific icon here.*/
- msgtitle = Tcl_GetString(objv[3]);
- msginfo = Tcl_GetString(objv[4]);
-
/* Balloon notification for system tray icon. */
- if (msgtitle != NULL) {
- WCHAR *title;
- Tcl_DStringInit(&titledst);
- title = Tcl_UtfToWCharDString(msgtitle, TCL_INDEX_NONE, &titledst);
- wcsncpy(ni.szInfoTitle, title, (Tcl_DStringLength(&titledst) + 2) / 2);
- Tcl_DStringFree(&titledst);
- }
- if (msginfo != NULL) {
- WCHAR *info;
- Tcl_DStringInit(&infodst);
- info = Tcl_UtfToWCharDString(msginfo, TCL_INDEX_NONE, &infodst);
- wcsncpy(ni.szInfo, info, (Tcl_DStringLength(&infodst) + 2) / 2);
- Tcl_DStringFree(&infodst);
- }
+ Tcl_DString dst;
+ Tcl_DStringInit(&dst);
+ WCHAR *title = Tcl_UtfToWCharDString(Tcl_GetString(objv[3]), TCL_INDEX_NONE, &dst);
+ wcsncpy(ni.szInfoTitle, title, sizeof(ni.szInfoTitle) / sizeof(WCHAR) - 1);
+ ni.szInfoTitle[sizeof(ni.szInfoTitle) / sizeof(WCHAR) - 1] = '\0';
+ Tcl_DStringSetLength(&dst, 0);
+ WCHAR *info = Tcl_UtfToWCharDString(Tcl_GetString(objv[4]), TCL_INDEX_NONE, &dst);
+ wcsncpy(ni.szInfo, info, sizeof(ni.szInfo) / sizeof(WCHAR) - 1);
+ ni.szInfo[sizeof(ni.szInfo) / sizeof(WCHAR) - 1] = '\0';
+ Tcl_DStringFree(&dst);
Shell_NotifyIconW(NIM_MODIFY, &ni);
return TCL_OK;
diff --git a/win/tkWinTest.c b/win/tkWinTest.c
index 254ef8d..0c5e0f8 100644
--- a/win/tkWinTest.c
+++ b/win/tkWinTest.c
@@ -129,7 +129,7 @@ AppendSystemError(
Tcl_Interp *interp, /* Current interpreter. */
DWORD error) /* Result code from error. */
{
- int length;
+ Tcl_Size length;
WCHAR *wMsgPtr, **wMsgPtrPtr = &wMsgPtr;
const char *msg;
char id[TCL_INTEGER_SPACE], msgBuf[24 + TCL_INTEGER_SPACE];
@@ -154,8 +154,8 @@ AppendSystemError(
0, NULL);
if (length > 0) {
wMsgPtr = (WCHAR *) LocalAlloc(LPTR, (length + 1) * sizeof(WCHAR));
- MultiByteToWideChar(CP_ACP, 0, msgPtr, length + 1, wMsgPtr,
- length + 1);
+ MultiByteToWideChar(CP_ACP, 0, msgPtr, (int)length + 1, wMsgPtr,
+ (int)length + 1);
LocalFree(msgPtr);
}
}
@@ -191,7 +191,7 @@ AppendSystemError(
}
snprintf(id, sizeof(id), "%ld", error);
- Tcl_SetErrorCode(interp, "WINDOWS", id, msg, NULL);
+ Tcl_SetErrorCode(interp, "WINDOWS", id, msg, (char *)NULL);
Tcl_AppendToObj(resultPtr, msg, length);
Tcl_SetObjResult(interp, resultPtr);
@@ -453,24 +453,27 @@ TestfindwindowObjCmd(
Tcl_DStringInit(&classString);
windowClass = Tcl_UtfToWCharDString(Tcl_GetString(objv[2]), TCL_INDEX_NONE, &classString);
}
- if (title[0] == 0)
+ if (title[0] == 0) {
title = NULL;
+ }
/* We want find a window the belongs to us and not some other process */
hwnd = NULL;
myPid = GetCurrentProcessId();
while (1) {
DWORD pid, tid;
hwnd = FindWindowExW(NULL, hwnd, windowClass, title);
- if (hwnd == NULL)
+ if (hwnd == NULL) {
break;
+ }
tid = GetWindowThreadProcessId(hwnd, &pid);
if (tid == 0) {
/* Window has gone */
hwnd = NULL;
break;
}
- if (pid == myPid)
+ if (pid == myPid) {
break; /* Found it */
+ }
}
if (hwnd == NULL) {
@@ -517,8 +520,9 @@ TestgetwindowinfoObjCmd(
return TCL_ERROR;
}
- if (Tcl_GetWideIntFromObj(interp, objv[1], &hwnd) != TCL_OK)
+ if (Tcl_GetWideIntFromObj(interp, objv[1], &hwnd) != TCL_OK) {
return TCL_ERROR;
+ }
cch = GetClassNameW((HWND)INT2PTR(hwnd), buf, cchBuf);
if (cch == 0) {
diff --git a/win/tkWinWm.c b/win/tkWinWm.c
index 1b9a9c5..187c05f 100644
--- a/win/tkWinWm.c
+++ b/win/tkWinWm.c
@@ -549,24 +549,16 @@ MakeIconOrCursorFromResource(
* Let the OS do the real work :)
*/
- hIcon = (HICON) CreateIconFromResourceEx(lpIcon->lpBits,
- lpIcon->dwNumBytes, isIcon, 0x00030000,
- (*(LPBITMAPINFOHEADER) lpIcon->lpBits).biWidth,
- (*(LPBITMAPINFOHEADER) lpIcon->lpBits).biHeight/2, 0);
+ hIcon = (HICON)CreateIconFromResourceEx(lpIcon->lpBits,
+ lpIcon->dwNumBytes, isIcon, 0x00030000, 0, 0, 0);
/*
- * It failed, odds are good we're on NT so try the non-Ex way.
+ * It failed, the non-Ex way might work as a fallback.
*/
if (hIcon == NULL) {
- /*
- * We would break on NT if we try with a 16bpp image.
- */
-
- if (lpIcon->lpbi->bmiHeader.biBitCount != 16) {
- hIcon = CreateIconFromResource(lpIcon->lpBits, lpIcon->dwNumBytes,
- isIcon, 0x00030000);
- }
+ hIcon = CreateIconFromResource(lpIcon->lpBits, lpIcon->dwNumBytes,
+ isIcon, 0x00030000);
}
return hIcon;
}
@@ -795,7 +787,7 @@ WinSetIcon(
if (InitWindowClass(titlebaricon) != TCL_OK) {
Tcl_SetObjResult(interp, Tcl_NewStringObj(
"Unable to set icon", TCL_INDEX_NONE));
- Tcl_SetErrorCode(interp, "TK", "WM", "ICON", "FAILED", NULL);
+ Tcl_SetErrorCode(interp, "TK", "WM", "ICON", "FAILED", (char *)NULL);
return TCL_ERROR;
}
} else {
@@ -852,7 +844,7 @@ WinSetIcon(
if (hwnd == NULL) {
Tcl_SetObjResult(interp, Tcl_NewStringObj(
"Can't set icon; window has no wrapper.", TCL_INDEX_NONE));
- Tcl_SetErrorCode(interp, "TK", "WM", "ICON", "WRAPPER", NULL);
+ Tcl_SetErrorCode(interp, "TK", "WM", "ICON", "WRAPPER", (char *)NULL);
return TCL_ERROR;
}
}
@@ -1105,6 +1097,50 @@ ReadIconFromFile(
*/
static BOOL
+SetSizeAndColorFromHICON( /* Helper for AdjustIconImagePointers */
+ HICON hicon,
+ LPICONIMAGE lpImage)
+{
+ ICONINFO info;
+ BOOL bRes;
+ BITMAP bmp;
+
+ memset(&info, 0, sizeof(info));
+
+ bRes = GetIconInfo(hicon, &info);
+ if (!bRes) {
+ return FALSE;
+ }
+
+ if (info.hbmColor) {
+ const int nWrittenBytes = GetObject(info.hbmColor, sizeof(bmp), &bmp);
+
+ if (nWrittenBytes > 0) {
+ lpImage->Width = bmp.bmWidth;
+ lpImage->Height = bmp.bmHeight;
+ lpImage->Colors = bmp.bmBitsPixel;
+ }
+ } else if (info.hbmMask) {
+ // Icon has no color plane, image data stored in mask
+ const int nWrittenBytes = GetObject(info.hbmMask, sizeof(bmp), &bmp);
+
+ if (nWrittenBytes > 0) {
+ lpImage->Width = bmp.bmWidth;
+ lpImage->Height = bmp.bmHeight / 2;
+ lpImage->Colors = 1;
+ }
+ }
+
+ if (info.hbmColor) {
+ DeleteObject(info.hbmColor);
+ }
+ if (info.hbmMask) {
+ DeleteObject(info.hbmMask);
+ }
+ return TRUE;
+}
+
+static BOOL
AdjustIconImagePointers(
LPICONIMAGE lpImage)
{
@@ -1123,24 +1159,10 @@ AdjustIconImagePointers(
lpImage->lpbi = (LPBITMAPINFO) lpImage->lpBits;
/*
- * Width - simple enough.
- */
-
- lpImage->Width = lpImage->lpbi->bmiHeader.biWidth;
-
- /*
- * Icons are stored in funky format where height is doubled so account for
- * that.
+ * Width, height, and number of colors.
*/
- lpImage->Height = (lpImage->lpbi->bmiHeader.biHeight)/2;
-
- /*
- * How many colors?
- */
-
- lpImage->Colors = lpImage->lpbi->bmiHeader.biPlanes
- * lpImage->lpbi->bmiHeader.biBitCount;
+ SetSizeAndColorFromHICON(lpImage->hIcon, lpImage);
/*
* XOR bits follow the header and color table.
@@ -1153,7 +1175,7 @@ AdjustIconImagePointers(
*/
lpImage->lpAND = lpImage->lpXOR +
- lpImage->Height*BytesPerLine((LPBITMAPINFOHEADER) lpImage->lpbi);
+ lpImage->Height * BytesPerLine((LPBITMAPINFOHEADER) lpImage->lpbi);
return TRUE;
}
@@ -1483,7 +1505,7 @@ ReadIconOrCursorFromFile(
if (dwBytesRead != lpIR->nNumImages * sizeof(ICONDIRENTRY)) {
Tcl_SetObjResult(interp, Tcl_ObjPrintf(
"error reading file: %s", Tcl_PosixError(interp)));
- Tcl_SetErrorCode(interp, "TK", "WM", "ICON", "READ", NULL);
+ Tcl_SetErrorCode(interp, "TK", "WM", "ICON", "READ", (char *)NULL);
Tcl_Close(NULL, channel);
ckfree(lpIDE);
ckfree(lpIR);
@@ -1533,17 +1555,17 @@ ReadIconOrCursorFromFile(
}
/*
- * Set the internal pointers appropriately.
+ * Create the icon from the resource, and set the internal pointers appropriately.
*/
+ lpIR->IconImages[i].hIcon =
+ MakeIconOrCursorFromResource(&lpIR->IconImages[i], isIcon);
if (!AdjustIconImagePointers(&lpIR->IconImages[i])) {
Tcl_SetObjResult(interp, Tcl_NewStringObj(
"Error converting to internal format", TCL_INDEX_NONE));
- Tcl_SetErrorCode(interp, "TK", "WM", "ICON", "FORMAT", NULL);
+ Tcl_SetErrorCode(interp, "TK", "WM", "ICON", "FORMAT", (char *)NULL);
goto readError;
}
- lpIR->IconImages[i].hIcon =
- MakeIconOrCursorFromResource(&lpIR->IconImages[i], isIcon);
}
/*
@@ -2552,8 +2574,9 @@ TkWmDeadWindow(
}
}
}
- if (wmPtr->numTransients != 0)
+ if (wmPtr->numTransients != 0) {
Tcl_Panic("numTransients should be 0");
+ }
if (wmPtr->title != NULL) {
ckfree(wmPtr->title);
@@ -2916,7 +2939,7 @@ WmAspectCmd(
if ((numer1 <= 0) || (denom1 <= 0) || (numer2 <= 0) || (denom2 <= 0)) {
Tcl_SetObjResult(interp, Tcl_NewStringObj(
"aspect number can't be <= 0", TCL_INDEX_NONE));
- Tcl_SetErrorCode(interp, "TK", "VALUE", "ASPECT", NULL);
+ Tcl_SetErrorCode(interp, "TK", "VALUE", "ASPECT", (char *)NULL);
return TCL_ERROR;
}
wmPtr->minAspect.x = numer1;
@@ -3035,14 +3058,14 @@ WmAttributesCmd(
Tcl_SetObjResult(interp, Tcl_ObjPrintf(
"can't set topmost flag on %s: it is an embedded window",
winPtr->pathName));
- Tcl_SetErrorCode(interp, "TK", "WM", "ATTR", "TOPMOST", NULL);
+ Tcl_SetErrorCode(interp, "TK", "WM", "ATTR", "TOPMOST", (char *)NULL);
return TCL_ERROR;
}
} else if (i == 3) {
Tcl_SetObjResult(interp, Tcl_ObjPrintf(
"bad attribute \"%s\": must be -alpha, -disabled, -fullscreen, -toolwindow, -topmost, or -transparentcolor",
string));
- Tcl_SetErrorCode(interp, "TK", "WM", "ATTR", "UNRECOGNIZED", NULL);
+ Tcl_SetErrorCode(interp, "TK", "WM", "ATTR", "UNRECOGNIZED", (char *)NULL);
return TCL_ERROR;
} else {
goto configArgs;
@@ -3217,7 +3240,7 @@ WmAttributesCmd(
Tcl_SetObjResult(interp, Tcl_ObjPrintf(
"can't set fullscreen attribute for \"%s\":"
" max width/height is too small", winPtr->pathName));
- Tcl_SetErrorCode(interp, "TK", "WM", "ATTR", "SMALL_MAX", NULL);
+ Tcl_SetErrorCode(interp, "TK", "WM", "ATTR", "SMALL_MAX", (char *)NULL);
return TCL_ERROR;
}
}
@@ -3497,7 +3520,7 @@ WmDeiconifyCmd(
Tcl_SetObjResult(interp, Tcl_ObjPrintf(
"can't deiconify %s: it is an icon for %s",
Tcl_GetString(objv[2]), Tk_PathName(wmPtr->iconFor)));
- Tcl_SetErrorCode(interp, "TK", "WM", "DEICONIFY", "ICON", NULL);
+ Tcl_SetErrorCode(interp, "TK", "WM", "DEICONIFY", "ICON", (char *)NULL);
return TCL_ERROR;
}
if (winPtr->flags & TK_EMBEDDED) {
@@ -3505,7 +3528,7 @@ WmDeiconifyCmd(
Tcl_SetObjResult(interp, Tcl_ObjPrintf(
"can't deiconify %s: the container does not support the request",
winPtr->pathName));
- Tcl_SetErrorCode(interp, "TK", "WM", "COMMUNICATION", NULL);
+ Tcl_SetErrorCode(interp, "TK", "WM", "COMMUNICATION", (char *)NULL);
return TCL_ERROR;
}
return TCL_OK;
@@ -3801,25 +3824,25 @@ WmGridCmd(
if (reqWidth < 0) {
Tcl_SetObjResult(interp, Tcl_NewStringObj(
"baseWidth can't be < 0", TCL_INDEX_NONE));
- Tcl_SetErrorCode(interp, "TK", "VALUE", "GRID", NULL);
+ Tcl_SetErrorCode(interp, "TK", "VALUE", "GRID", (char *)NULL);
return TCL_ERROR;
}
if (reqHeight < 0) {
Tcl_SetObjResult(interp, Tcl_NewStringObj(
"baseHeight can't be < 0", TCL_INDEX_NONE));
- Tcl_SetErrorCode(interp, "TK", "VALUE", "GRID", NULL);
+ Tcl_SetErrorCode(interp, "TK", "VALUE", "GRID", (char *)NULL);
return TCL_ERROR;
}
if (widthInc <= 0) {
Tcl_SetObjResult(interp, Tcl_NewStringObj(
"widthInc can't be <= 0", TCL_INDEX_NONE));
- Tcl_SetErrorCode(interp, "TK", "VALUE", "GRID", NULL);
+ Tcl_SetErrorCode(interp, "TK", "VALUE", "GRID", (char *)NULL);
return TCL_ERROR;
}
if (heightInc <= 0) {
Tcl_SetObjResult(interp, Tcl_NewStringObj(
"heightInc can't be <= 0", TCL_INDEX_NONE));
- Tcl_SetErrorCode(interp, "TK", "VALUE", "GRID", NULL);
+ Tcl_SetErrorCode(interp, "TK", "VALUE", "GRID", (char *)NULL);
return TCL_ERROR;
}
Tk_SetGrid((Tk_Window) winPtr, reqWidth, reqHeight, widthInc,
@@ -4045,7 +4068,7 @@ WmIconbitmapCmd(
if (strcmp(argv3, "-default")) {
Tcl_SetObjResult(interp, Tcl_ObjPrintf(
"illegal option \"%s\" must be \"-default\"", argv3));
- Tcl_SetErrorCode(interp, "TK", "WM", "ICONBITMAP", "OPTION",NULL);
+ Tcl_SetErrorCode(interp, "TK", "WM", "ICONBITMAP", "OPTION", (char *)NULL);
return TCL_ERROR;
}
useWinPtr = NULL;
@@ -4175,7 +4198,7 @@ WmIconifyCmd(
Tcl_SetObjResult(interp, Tcl_ObjPrintf(
"can't iconify \"%s\": the container does not support the request",
winPtr->pathName));
- Tcl_SetErrorCode(interp, "TK", "WM", "ICONIFY", "EMBEDDED", NULL);
+ Tcl_SetErrorCode(interp, "TK", "WM", "ICONIFY", "EMBEDDED", (char *)NULL);
return TCL_ERROR;
}
}
@@ -4191,14 +4214,14 @@ WmIconifyCmd(
Tcl_SetObjResult(interp, Tcl_ObjPrintf(
"can't iconify \"%s\": it is a transient",
winPtr->pathName));
- Tcl_SetErrorCode(interp, "TK", "WM", "ICONIFY", "TRANSIENT", NULL);
+ Tcl_SetErrorCode(interp, "TK", "WM", "ICONIFY", "TRANSIENT", (char *)NULL);
return TCL_ERROR;
}
if (wmPtr->iconFor != NULL) {
Tcl_SetObjResult(interp, Tcl_ObjPrintf(
"can't iconify \"%s\": it is an icon for \"%s\"",
winPtr->pathName, Tk_PathName(wmPtr->iconFor)));
- Tcl_SetErrorCode(interp, "TK", "WM", "ICONIFY", "ICON", NULL);
+ Tcl_SetErrorCode(interp, "TK", "WM", "ICONIFY", "ICON", (char *)NULL);
return TCL_ERROR;
}
TkpWmSetState(winPtr, IconicState);
@@ -4374,7 +4397,7 @@ WmIconphotoCmd(
Tcl_SetObjResult(interp, Tcl_ObjPrintf(
"can't use \"%s\" as iconphoto: not a photo image",
Tcl_GetString(objv[i])));
- Tcl_SetErrorCode(interp, "TK", "WM", "ICONPHOTO", "PHOTO", NULL);
+ Tcl_SetErrorCode(interp, "TK", "WM", "ICONPHOTO", "PHOTO", (char *)NULL);
return TCL_ERROR;
}
}
@@ -4402,7 +4425,7 @@ WmIconphotoCmd(
Tcl_SetObjResult(interp, Tcl_ObjPrintf(
"failed to create an iconphoto with image \"%s\"",
Tcl_GetString(objv[i])));
- Tcl_SetErrorCode(interp, "TK", "WM", "ICONPHOTO", "ICON", NULL);
+ Tcl_SetErrorCode(interp, "TK", "WM", "ICONPHOTO", "ICON", (char *)NULL);
return TCL_ERROR;
}
lpIR->IconImages[i-startObj].Width = width;
@@ -4548,7 +4571,7 @@ WmIconwindowCmd(
Tcl_SetObjResult(interp, Tcl_ObjPrintf(
"can't use %s as icon window: not at top level",
Tcl_GetString(objv[3])));
- Tcl_SetErrorCode(interp, "TK", "WM", "ICONWINDOW", "INNER", NULL);
+ Tcl_SetErrorCode(interp, "TK", "WM", "ICONWINDOW", "INNER", (char *)NULL);
return TCL_ERROR;
}
wmPtr2 = ((TkWindow *) tkwin2)->wmInfoPtr;
@@ -4556,7 +4579,7 @@ WmIconwindowCmd(
Tcl_SetObjResult(interp, Tcl_ObjPrintf(
"%s is already an icon for %s",
Tcl_GetString(objv[3]), Tk_PathName(wmPtr2->iconFor)));
- Tcl_SetErrorCode(interp, "TK", "WM", "ICONWINDOW", "ICON", NULL);
+ Tcl_SetErrorCode(interp, "TK", "WM", "ICONWINDOW", "ICON", (char *)NULL);
return TCL_ERROR;
}
if (wmPtr->icon != NULL) {
@@ -4627,7 +4650,7 @@ WmManageCmd(
Tcl_SetObjResult(interp, Tcl_ObjPrintf(
"window \"%s\" is not manageable: must be a frame,"
" labelframe or toplevel", Tk_PathName(frameWin)));
- Tcl_SetErrorCode(interp, "TK", "WM", "MANAGE", NULL);
+ Tcl_SetErrorCode(interp, "TK", "WM", "MANAGE", (char *)NULL);
return TCL_ERROR;
}
TkFocusSplit(winPtr);
@@ -4788,7 +4811,7 @@ WmOverrideredirectCmd(
if (curValue < 0) {
Tcl_SetObjResult(interp, Tcl_NewStringObj(
"Container does not support overrideredirect", TCL_INDEX_NONE));
- Tcl_SetErrorCode(interp, "TK", "WM", "COMMUNICATION", NULL);
+ Tcl_SetErrorCode(interp, "TK", "WM", "COMMUNICATION", (char *)NULL);
return TCL_ERROR;
}
} else {
@@ -5184,21 +5207,21 @@ WmStackorderCmd(
Tcl_SetObjResult(interp, Tcl_ObjPrintf(
"window \"%s\" isn't a top-level window",
winPtr2->pathName));
- Tcl_SetErrorCode(interp, "TK", "WM", "STACK", "TOPLEVEL", NULL);
+ Tcl_SetErrorCode(interp, "TK", "WM", "STACK", "TOPLEVEL", (char *)NULL);
return TCL_ERROR;
}
if (!Tk_IsMapped(winPtr)) {
Tcl_SetObjResult(interp, Tcl_ObjPrintf(
"window \"%s\" isn't mapped", winPtr->pathName));
- Tcl_SetErrorCode(interp, "TK", "WM", "STACK", "MAPPED", NULL);
+ Tcl_SetErrorCode(interp, "TK", "WM", "STACK", "MAPPED", (char *)NULL);
return TCL_ERROR;
}
if (!Tk_IsMapped(winPtr2)) {
Tcl_SetObjResult(interp, Tcl_ObjPrintf(
"window \"%s\" isn't mapped", winPtr2->pathName));
- Tcl_SetErrorCode(interp, "TK", "WM", "STACK", "MAPPED", NULL);
+ Tcl_SetErrorCode(interp, "TK", "WM", "STACK", "MAPPED", (char *)NULL);
return TCL_ERROR;
}
@@ -5211,7 +5234,7 @@ WmStackorderCmd(
if (windows == NULL) {
Tcl_SetObjResult(interp, Tcl_NewStringObj(
"TkWmStackorderToplevel failed", TCL_INDEX_NONE));
- Tcl_SetErrorCode(interp, "TK", "WM", "COMMUNICATION", NULL);
+ Tcl_SetErrorCode(interp, "TK", "WM", "COMMUNICATION", (char *)NULL);
return TCL_ERROR;
}
@@ -5288,7 +5311,7 @@ WmStateCmd(
Tcl_SetObjResult(interp, Tcl_ObjPrintf(
"can't change state of %s: it is an icon for %s",
Tcl_GetString(objv[2]), Tk_PathName(wmPtr->iconFor)));
- Tcl_SetErrorCode(interp, "TK", "WM", "STATE", "ICON", NULL);
+ Tcl_SetErrorCode(interp, "TK", "WM", "STATE", "ICON", (char *)NULL);
return TCL_ERROR;
}
if (Tcl_GetIndexFromObj(interp, objv[3], optionStrings,
@@ -5320,7 +5343,7 @@ WmStateCmd(
Tcl_SetObjResult(interp, Tcl_ObjPrintf(
"can't change state of %s: the container does not support the request",
winPtr->pathName));
- Tcl_SetErrorCode(interp, "TK", "WM", "COMMUNICATION", NULL);
+ Tcl_SetErrorCode(interp, "TK", "WM", "COMMUNICATION", (char *)NULL);
return TCL_ERROR;
}
return TCL_OK;
@@ -5532,7 +5555,7 @@ WmTransientCmd(
Tcl_SetObjResult(interp, Tcl_ObjPrintf(
"can't make \"%s\" a transient: it is an icon for %s",
Tcl_GetString(objv[2]), Tk_PathName(wmPtr->iconFor)));
- Tcl_SetErrorCode(interp, "TK", "WM", "TRANSIENT", "ICON", NULL);
+ Tcl_SetErrorCode(interp, "TK", "WM", "TRANSIENT", "ICON", (char *)NULL);
return TCL_ERROR;
}
@@ -5542,7 +5565,7 @@ WmTransientCmd(
Tcl_SetObjResult(interp, Tcl_ObjPrintf(
"can't make \"%s\" a container: it is an icon for %s",
Tcl_GetString(objv[3]), Tk_PathName(wmPtr2->iconFor)));
- Tcl_SetErrorCode(interp, "TK", "WM", "TRANSIENT", "ICON", NULL);
+ Tcl_SetErrorCode(interp, "TK", "WM", "TRANSIENT", "ICON", (char *)NULL);
return TCL_ERROR;
}
for (w = containerPtr; w != NULL && w->wmInfoPtr != NULL;
@@ -5551,7 +5574,7 @@ WmTransientCmd(
Tcl_SetObjResult(interp, Tcl_ObjPrintf(
"can't set \"%s\" as container: would cause management loop",
Tk_PathName(containerPtr)));
- Tcl_SetErrorCode(interp, "TK", "WM", "TRANSIENT", "SELF", NULL);
+ Tcl_SetErrorCode(interp, "TK", "WM", "TRANSIENT", "SELF", (char *)NULL);
return TCL_ERROR;
}
}
@@ -5624,7 +5647,7 @@ WmWithdrawCmd(
Tcl_SetObjResult(interp, Tcl_ObjPrintf(
"can't withdraw %s: it is an icon for %s",
Tcl_GetString(objv[2]), Tk_PathName(wmPtr->iconFor)));
- Tcl_SetErrorCode(interp, "TK", "WM", "WITHDRAW", "ICON", NULL);
+ Tcl_SetErrorCode(interp, "TK", "WM", "WITHDRAW", "ICON", (char *)NULL);
return TCL_ERROR;
}
@@ -5633,7 +5656,7 @@ WmWithdrawCmd(
Tcl_SetObjResult(interp, Tcl_ObjPrintf(
"can't withdraw %s: the container does not support the request",
Tcl_GetString(objv[2])));
- Tcl_SetErrorCode(interp, "TK", "WM", "COMMUNICATION", NULL);
+ Tcl_SetErrorCode(interp, "TK", "WM", "COMMUNICATION", (char *)NULL);
return TCL_ERROR;
}
} else {
@@ -6353,7 +6376,7 @@ ParseGeometry(
error:
Tcl_SetObjResult(interp, Tcl_ObjPrintf(
"bad geometry specifier \"%s\"", string));
- Tcl_SetErrorCode(interp, "TK", "VALUE", "GEOMETRY", NULL);
+ Tcl_SetErrorCode(interp, "TK", "VALUE", "GEOMETRY", (char *)NULL);
return TCL_ERROR;
}
diff --git a/win/tkWinX.c b/win/tkWinX.c
index 819f9df..a6aea8e 100644
--- a/win/tkWinX.c
+++ b/win/tkWinX.c
@@ -87,7 +87,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 tkWinTheme = 0; /* See TkWinGetPlatformTheme */
static Tcl_Encoding keyInputEncoding = NULL;
/* The current character encoding for
* keyboard input */
@@ -334,69 +333,6 @@ TkWinXCleanup(
/*
*----------------------------------------------------------------------
*
- * TkWinGetPlatformTheme --
- *
- * Return the Windows drawing style we should be using.
- *
- * 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
- * TK_THEME_WIN_VISTA Vista or higher
- *
- *----------------------------------------------------------------------
- */
-
-int
-TkWinGetPlatformTheme(void)
-{
- if (tkWinTheme == 0) {
- OSVERSIONINFOW os;
-
- os.dwOSVersionInfoSize = sizeof(OSVERSIONINFOW);
- GetVersionExW(&os);
-
- if (os.dwPlatformId != VER_PLATFORM_WIN32_NT) {
- Tcl_Panic("Windows NT is the only supported platform");
- }
-
- /*
- * 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.dwMajorVersion == 5 && os.dwMinorVersion >= 1) {
- HKEY hKey;
- LPCWSTR szSubKey = L"Control Panel\\Appearance";
- LPCWSTR szCurrent = L"Current";
- DWORD dwSize = 200;
- WCHAR pBuffer[200];
-
- memset(pBuffer, 0, dwSize);
- if (RegOpenKeyExW(HKEY_CURRENT_USER, szSubKey, 0L,
- KEY_READ, &hKey) != ERROR_SUCCESS) {
- tkWinTheme = TK_THEME_WIN_XP;
- } else {
- RegQueryValueExW(hKey, szCurrent, NULL, NULL, (LPBYTE) pBuffer, &dwSize);
- RegCloseKey(hKey);
- if (wcscmp(pBuffer, L"Windows Standard") == 0) {
- tkWinTheme = TK_THEME_WIN_CLASSIC;
- } else {
- tkWinTheme = TK_THEME_WIN_XP;
- }
- }
- } else if (os.dwMajorVersion > 5) {
- tkWinTheme = TK_THEME_WIN_VISTA;
- } else {
- tkWinTheme = TK_THEME_WIN_CLASSIC;
- }
- }
- return tkWinTheme;
-}
-
-/*
- *----------------------------------------------------------------------
- *
* TkGetDefaultScreenName --
*
* Returns the name of the screen that Tk should use during
@@ -1196,7 +1132,7 @@ GenerateXEvent(
event.key.nbytes = 0;
event.x.xkey.state = state;
event.x.xany.serial = scrollCounter++;
- event.x.xkey.keycode = (unsigned int)(-(delta << 16));
+ event.x.xkey.keycode = -((unsigned int)delta << 16);
} else {
event.x.type = MouseWheelEvent;
event.x.xany.send_event = -1;
diff --git a/win/ttkWinMonitor.c b/win/ttkWinMonitor.c
index 32d2a07..217730f 100644
--- a/win/ttkWinMonitor.c
+++ b/win/ttkWinMonitor.c
@@ -127,7 +127,7 @@ WndProc(HWND hwnd, UINT msg, WPARAM wp, LPARAM lp)
* the theme to 'winnative' (by setting the ui to 'best performance'),
* which is a machine-wide change, and then sign back on to the original user.
* Ttk_UseTheme needs to be executed again in order to process the fallback
- * from vista/xpnative to winnative.
+ * from vista to winnative.
*/
theme = Ttk_GetCurrentTheme(interp);
@@ -145,7 +145,7 @@ WndProc(HWND hwnd, UINT msg, WPARAM wp, LPARAM lp)
*/
MODULE_SCOPE int TtkWinTheme_Init(Tcl_Interp *, HWND hwnd);
-MODULE_SCOPE int TtkXPTheme_Init(Tcl_Interp *, HWND hwnd);
+MODULE_SCOPE int TtkWinVistaTheme_Init(Tcl_Interp *, HWND hwnd);
MODULE_SCOPE int Ttk_WinPlatformInit(Tcl_Interp *interp);
MODULE_SCOPE int Ttk_WinPlatformInit(Tcl_Interp *interp)
@@ -156,7 +156,7 @@ MODULE_SCOPE int Ttk_WinPlatformInit(Tcl_Interp *interp)
Ttk_RegisterCleanup(interp, hwnd, DestroyThemeMonitorWindow);
TtkWinTheme_Init(interp, hwnd);
- TtkXPTheme_Init(interp, hwnd);
+ TtkWinVistaTheme_Init(interp, hwnd);
return TCL_OK;
}
diff --git a/win/ttkWinTheme.c b/win/ttkWinTheme.c
index c97d670..0b63311 100644
--- a/win/ttkWinTheme.c
+++ b/win/ttkWinTheme.c
@@ -105,8 +105,8 @@ typedef struct {
#define BASE_DIM 16
#define _FIXEDSIZE 0x80000000UL
#define _HALFMETRIC 0x40000000UL
-#define FIXEDSIZE(id) (id|_FIXEDSIZE)
-#define HALFMETRIC(id) (id|_HALFMETRIC)
+#define FIXEDSIZE(id) ((id)|_FIXEDSIZE)
+#define HALFMETRIC(id) ((id)|_HALFMETRIC)
#define GETMETRIC(m) \
((m) & _FIXEDSIZE ? (int)((m) & ~_FIXEDSIZE) : GetSystemMetrics((m)&0xFFFFFFF))
@@ -158,14 +158,14 @@ static void FrameControlElementSize(
if ((p->cxId & _FIXEDSIZE) && cx == BASE_DIM) {
double scalingLevel = TkScalingLevel(tkwin);
- cx *= scalingLevel;
- cy *= scalingLevel;
+ cx = (int)(cx * scalingLevel);
+ cy = (int)(cy * scalingLevel);
/*
* Update the corresponding element of the array FrameControlElements
*/
- p->cxId = FIXEDSIZE(cx);
- p->cyId = FIXEDSIZE(cy);
+ p->cxId = FIXEDSIZE((unsigned long)cx);
+ p->cyId = FIXEDSIZE((unsigned long)cy);
}
if (p->cxId & _HALFMETRIC) cx /= 2;
@@ -189,8 +189,8 @@ static void FrameControlElementDraw(
HDC hdc = TkWinGetDrawableDC(Tk_Display(tkwin), d, &dcState);
DrawFrameControl(hdc, &rc,
- elementData->classId,
- elementData->partId|Ttk_StateTableLookup(elementData->stateMap, state));
+ (UINT)elementData->classId,
+ (UINT)(elementData->partId|Ttk_StateTableLookup(elementData->stateMap, state)));
TkWinReleaseDrawableDC(d, hdc, &dcState);
}
@@ -223,8 +223,8 @@ static void BorderElementSize(
TCL_UNUSED(int *), /* heightPtr */
Ttk_Padding *paddingPtr)
{
- paddingPtr->left = paddingPtr->right = GetSystemMetrics(SM_CXEDGE);
- paddingPtr->top = paddingPtr->bottom = GetSystemMetrics(SM_CYEDGE);
+ paddingPtr->left = paddingPtr->right = (short)GetSystemMetrics(SM_CXEDGE);
+ paddingPtr->top = paddingPtr->bottom = (short)GetSystemMetrics(SM_CYEDGE);
}
static void BorderElementDraw(
@@ -282,8 +282,8 @@ static void FieldElementSize(
TCL_UNUSED(int *), /* heightPtr */
Ttk_Padding *paddingPtr)
{
- paddingPtr->left = paddingPtr->right = GetSystemMetrics(SM_CXEDGE);
- paddingPtr->top = paddingPtr->bottom = GetSystemMetrics(SM_CYEDGE);
+ paddingPtr->left = paddingPtr->right = (short)GetSystemMetrics(SM_CXEDGE);
+ paddingPtr->top = paddingPtr->bottom = (short)GetSystemMetrics(SM_CYEDGE);
}
static void FieldElementDraw(
@@ -352,8 +352,8 @@ static void ButtonBorderElementSize(
Tk_GetReliefFromObj(NULL, bd->reliefObj, &relief);
Ttk_GetButtonDefaultStateFromObj(NULL, bd->defaultStateObj, &defaultState);
- cx = GetSystemMetrics(SM_CXEDGE);
- cy = GetSystemMetrics(SM_CYEDGE);
+ cx = (short)GetSystemMetrics(SM_CXEDGE);
+ cy = (short)GetSystemMetrics(SM_CYEDGE);
/* Space for default indicator:
*/
@@ -366,7 +366,7 @@ static void ButtonBorderElementSize(
cx += 2;
cy += 2;
- *paddingPtr = Ttk_MakePadding(cx,cy,cx,cy);
+ *paddingPtr = Ttk_MakePadding(cx, cy, cx, cy);
}
static void ButtonBorderElementDraw(
@@ -391,7 +391,7 @@ static void ButtonBorderElementDraw(
XColor *highlightColor =
Tk_GetColorFromObj(tkwin, bd->highlightColorObj);
GC gc = Tk_GCForColor(highlightColor, d);
- XDrawRectangle(Tk_Display(tkwin), d, gc, b.x,b.y,b.width-1,b.height-1);
+ XDrawRectangle(Tk_Display(tkwin), d, gc, b.x, b.y, (UINT)(b.width - 1), (UINT)(b.height - 1));
}
if (defaultState != TTK_BUTTON_DEFAULT_DISABLED) {
++b.x; ++b.y; b.width -= 2; b.height -= 2;
@@ -402,7 +402,7 @@ static void ButtonBorderElementDraw(
rc = BoxToRect(b);
DrawFrameControl(hdc, &rc,
DFC_BUTTON, /* classId */
- DFCS_BUTTONPUSH | Ttk_StateTableLookup(pushbutton_statemap, state));
+ (UINT)(DFCS_BUTTONPUSH | Ttk_StateTableLookup(pushbutton_statemap, state)));
TkWinReleaseDrawableDC(d, hdc, &dcState);
@@ -489,7 +489,7 @@ static void FillFocusElementDraw(
FillFocusElement *focus = (FillFocusElement *)elementRecord;
XColor *fillColor = Tk_GetColorFromObj(tkwin, focus->fillColorObj);
GC gc = Tk_GCForColor(fillColor, d);
- XFillRectangle(Tk_Display(tkwin), d, gc, b.x, b.y, b.width, b.height);
+ XFillRectangle(Tk_Display(tkwin), d, gc, b.x, b.y, (unsigned)b.width, (unsigned)b.height);
TkWinDrawDottedRect(Tk_Display(tkwin), d, -1, b.x, b.y,
b.width, b.height);
@@ -638,8 +638,9 @@ static void ThumbElementDraw(
HDC hdc;
/* Windows doesn't show a thumb when the scrollbar is disabled */
- if (state & TTK_STATE_DISABLED)
+ if (state & TTK_STATE_DISABLED) {
return;
+ }
hdc = TkWinGetDrawableDC(Tk_Display(tkwin), d, &dcState);
DrawEdge(hdc, &rc, EDGE_RAISED, BF_RECT | BF_MIDDLE);
@@ -783,7 +784,7 @@ static void TabElementDraw(
Tk_3DBorder border = Tk_Get3DBorderFromObj(tkwin, tab->backgroundObj);
XPoint pts[6];
double scalingLevel = TkScalingLevel(tkwin);
- int cut = round(2 * scalingLevel);
+ int cut = (int)round(2 * scalingLevel);
Display *disp = Tk_Display(tkwin);
int borderWidth = 1;
@@ -816,36 +817,36 @@ static void TabElementDraw(
switch (nbTabsStickBit) {
default:
case TTK_STICK_S:
- pts[0].x = b.x; pts[0].y = b.y + b.height-1;
- pts[1].x = b.x; pts[1].y = b.y + cut;
- pts[2].x = b.x + cut; pts[2].y = b.y;
- pts[3].x = b.x + b.width-1 - cut; pts[3].y = b.y;
- pts[4].x = b.x + b.width-1; pts[4].y = b.y + cut;
- pts[5].x = b.x + b.width-1; pts[5].y = b.y + b.height;
+ pts[0].x = (short)b.x; pts[0].y = (short)(b.y + b.height - 1);
+ pts[1].x = (short)b.x; pts[1].y = (short)(b.y + cut);
+ pts[2].x = (short)(b.x + cut); pts[2].y = (short)b.y;
+ pts[3].x = (short)(b.x + b.width - 1 - cut); pts[3].y = (short)b.y;
+ pts[4].x = (short)(b.x + b.width - 1); pts[4].y = (short)(b.y + cut);
+ pts[5].x = (short)(b.x + b.width - 1); pts[5].y = (short)(b.y + b.height);
break;
case TTK_STICK_N:
- pts[0].x = b.x; pts[0].y = b.y;
- pts[1].x = b.x; pts[1].y = b.y + b.height-1 - cut;
- pts[2].x = b.x + cut; pts[2].y = b.y + b.height-1;
- pts[3].x = b.x + b.width-1 - cut; pts[3].y = b.y + b.height-1;
- pts[4].x = b.x + b.width-1; pts[4].y = b.y + b.height-1 - cut;
- pts[5].x = b.x + b.width-1; pts[5].y = b.y-1;
+ pts[0].x = (short)b.x; pts[0].y = (short)b.y;
+ pts[1].x = (short)b.x; pts[1].y = (short)(b.y + b.height - 1 - cut);
+ pts[2].x = (short)(b.x + cut); pts[2].y = (short)(b.y + b.height - 1);
+ pts[3].x = (short)(b.x + b.width - 1 - cut); pts[3].y = (short)(b.y + b.height - 1);
+ pts[4].x = (short)(b.x + b.width - 1); pts[4].y = (short)(b.y + b.height - 1 - cut);
+ pts[5].x = (short)(b.x + b.width - 1); pts[5].y = (short)(b.y - 1);
break;
case TTK_STICK_E:
- pts[0].x = b.x + b.width-1; pts[0].y = b.y;
- pts[1].x = b.x + cut; pts[1].y = b.y;
- pts[2].x = b.x; pts[2].y = b.y + cut;
- pts[3].x = b.x; pts[3].y = b.y + b.height-1 - cut;
- pts[4].x = b.x + cut; pts[4].y = b.y + b.height-1;
- pts[5].x = b.x + b.width; pts[5].y = b.y + b.height-1;
+ pts[0].x = (short)(b.x + b.width - 1); pts[0].y = (short)b.y;
+ pts[1].x = (short)(b.x + cut); pts[1].y = (short)b.y;
+ pts[2].x = (short)b.x; pts[2].y = (short)(b.y + cut);
+ pts[3].x = (short)b.x; pts[3].y = (short)(b.y + b.height - 1 - cut);
+ pts[4].x = (short)(b.x + cut); pts[4].y = (short)(b.y + b.height - 1);
+ pts[5].x = (short)(b.x + b.width); pts[5].y = (short)(b.y + b.height - 1);
break;
case TTK_STICK_W:
- pts[0].x = b.x; pts[0].y = b.y;
- pts[1].x = b.x + b.width-1 - cut; pts[1].y = b.y;
- pts[2].x = b.x + b.width-1; pts[2].y = b.y + cut;
- pts[3].x = b.x + b.width-1; pts[3].y = b.y + b.height-1 - cut;
- pts[4].x = b.x + b.width-1 - cut; pts[4].y = b.y + b.height-1;
- pts[5].x = b.x-1; pts[5].y = b.y + b.height-1;
+ pts[0].x = (short)b.x; pts[0].y = (short)b.y;
+ pts[1].x = (short)(b.x + b.width - 1 - cut); pts[1].y = (short)b.y;
+ pts[2].x = (short)(b.x + b.width - 1); pts[2].y = (short)(b.y + cut);
+ pts[3].x = (short)(b.x + b.width - 1); pts[3].y = (short)(b.y + b.height - 1 - cut);
+ pts[4].x = (short)(b.x + b.width - 1 - cut); pts[4].y = (short)(b.y + b.height - 1);
+ pts[5].x = (short)(b.x - 1); pts[5].y = (short)(b.y + b.height - 1);
break;
}
@@ -897,8 +898,8 @@ static void ClientElementSize(
TCL_UNUSED(int *), /* heightPtr */
Ttk_Padding *paddingPtr)
{
- paddingPtr->left = paddingPtr->right = GetSystemMetrics(SM_CXEDGE);
- paddingPtr->top = paddingPtr->bottom = GetSystemMetrics(SM_CYEDGE);
+ paddingPtr->left = paddingPtr->right = (short)GetSystemMetrics(SM_CXEDGE);
+ paddingPtr->top = paddingPtr->bottom = (short)GetSystemMetrics(SM_CYEDGE);
}
static void ClientElementDraw(
@@ -961,23 +962,23 @@ TtkWinTheme_Init(
return TCL_ERROR;
}
- Ttk_RegisterElementSpec(themePtr, "border", &BorderElementSpec, NULL);
- Ttk_RegisterElementSpec(themePtr, "Button.border",
+ Ttk_RegisterElement(NULL, themePtr, "border", &BorderElementSpec, NULL);
+ Ttk_RegisterElement(NULL, themePtr, "Button.border",
&ButtonBorderElementSpec, NULL);
- Ttk_RegisterElementSpec(themePtr, "field", &FieldElementSpec, NULL);
- Ttk_RegisterElementSpec(themePtr, "focus", &FocusElementSpec, NULL);
- Ttk_RegisterElementSpec(themePtr, "Combobox.focus",
+ Ttk_RegisterElement(NULL, themePtr, "field", &FieldElementSpec, NULL);
+ Ttk_RegisterElement(NULL, themePtr, "focus", &FocusElementSpec, NULL);
+ Ttk_RegisterElement(NULL, themePtr, "Combobox.focus",
&ComboboxFocusElementSpec, NULL);
- Ttk_RegisterElementSpec(themePtr, "thumb", &ThumbElementSpec, NULL);
- Ttk_RegisterElementSpec(themePtr, "slider", &SliderElementSpec, NULL);
- Ttk_RegisterElementSpec(themePtr, "Scrollbar.trough", &TroughElementSpec,
+ Ttk_RegisterElement(NULL, themePtr, "thumb", &ThumbElementSpec, NULL);
+ Ttk_RegisterElement(NULL, themePtr, "slider", &SliderElementSpec, NULL);
+ Ttk_RegisterElement(NULL, themePtr, "Scrollbar.trough", &TroughElementSpec,
TroughClientDataInit(interp));
- Ttk_RegisterElementSpec(themePtr, "tab", &TabElementSpec, NULL);
- Ttk_RegisterElementSpec(themePtr, "client", &ClientElementSpec, NULL);
+ Ttk_RegisterElement(NULL, themePtr, "tab", &TabElementSpec, NULL);
+ Ttk_RegisterElement(NULL, themePtr, "client", &ClientElementSpec, NULL);
for (fce = FrameControlElements; fce->name != 0; ++fce) {
- Ttk_RegisterElementSpec(themePtr, fce->name,
+ Ttk_RegisterElement(NULL, themePtr, fce->name,
&FrameControlElementSpec, (void *)fce);
}
diff --git a/win/ttkWinXPTheme.c b/win/ttkWinVistaTheme.c
index 8fd1f58..d71374d 100644
--- a/win/ttkWinXPTheme.c
+++ b/win/ttkWinVistaTheme.c
@@ -1,5 +1,5 @@
/*
- * Tk theme engine which uses the Windows XP "Visual Styles" API
+ * Tk theme engine which uses the Windows "Visual Styles" API
* Adapted from Georgios Petasis' XP theme patch.
*
* Copyright © 2003 Georgios Petasis, petasis@iit.demokritos.gr.
@@ -20,129 +20,29 @@
#include <uxtheme.h>
#include <vssym32.h>
#include "ttk/ttkThemeInt.h"
-
-typedef HTHEME (STDAPICALLTYPE OpenThemeDataProc)(HWND hwnd,
- LPCWSTR pszClassList);
-typedef HRESULT (STDAPICALLTYPE CloseThemeDataProc)(HTHEME hTheme);
-typedef HRESULT (STDAPICALLTYPE DrawThemeBackgroundProc)(HTHEME hTheme,
- HDC hdc, int iPartId, int iStateId, const RECT *pRect,
- OPTIONAL const RECT *pClipRect);
-typedef HRESULT (STDAPICALLTYPE DrawThemeEdgeProc)(HTHEME hTheme,
- HDC hdc, int iPartId, int iStateId, const RECT *pDestRect,
- unsigned int uEdge, unsigned int uFlags,
- OPTIONAL RECT *pContentRect);
-typedef HRESULT (STDAPICALLTYPE GetThemePartSizeProc)(HTHEME,HDC,
- int iPartId, int iStateId,
- RECT *prc, enum THEMESIZE eSize, SIZE *psz);
-typedef int (STDAPICALLTYPE GetThemeSysSizeProc)(HTHEME,int);
-/* GetThemeTextExtent and DrawThemeText only used with BROKEN_TEXT_ELEMENT */
-typedef HRESULT (STDAPICALLTYPE GetThemeTextExtentProc)(HTHEME hTheme, HDC hdc,
- int iPartId, int iStateId, LPCWSTR pszText, int iCharCount,
- DWORD dwTextFlags, const RECT *pBoundingRect, RECT *pExtent);
-typedef HRESULT (STDAPICALLTYPE DrawThemeTextProc)(HTHEME hTheme, HDC hdc,
- int iPartId, int iStateId, LPCWSTR pszText, int iCharCount,
- DWORD dwTextFlags, DWORD dwTextFlags2, const RECT *pRect);
-typedef BOOL (STDAPICALLTYPE IsThemeActiveProc)(void);
-typedef BOOL (STDAPICALLTYPE IsAppThemedProc)(void);
-
-typedef struct
-{
- OpenThemeDataProc *OpenThemeData;
- CloseThemeDataProc *CloseThemeData;
- GetThemePartSizeProc *GetThemePartSize;
- GetThemeSysSizeProc *GetThemeSysSize;
- DrawThemeBackgroundProc *DrawThemeBackground;
- DrawThemeEdgeProc *DrawThemeEdge;
- DrawThemeTextProc *DrawThemeText;
- GetThemeTextExtentProc *GetThemeTextExtent;
- IsThemeActiveProc *IsThemeActive;
- IsAppThemedProc *IsAppThemed;
-
- HWND stubWindow;
-} XPThemeProcs;
-
-typedef struct
-{
- HINSTANCE hlibrary;
- XPThemeProcs *procs;
-} XPThemeData;
-
-/*
- *----------------------------------------------------------------------
- *
- * LoadXPThemeProcs --
- * Initialize XP theming support.
- *
- * XP theme support is included in UXTHEME.DLL
- * We dynamically load this DLL at runtime instead of linking
- * to it at build-time.
- *
- * Returns:
- * A pointer to an XPThemeProcs table if successful, NULL otherwise.
- */
-
-static XPThemeProcs *
-LoadXPThemeProcs(HINSTANCE *phlib)
-{
- /*
- * Load the library "uxtheme.dll", where the native widget
- * drawing routines are implemented. This will only succeed
- * if we are running at least on Windows XP.
- */
- HINSTANCE handle;
- *phlib = handle = LoadLibraryW(L"uxtheme.dll");
- if (handle != 0)
- {
- /*
- * We have successfully loaded the library. Proceed in storing the
- * addresses of the functions we want to use.
- */
- XPThemeProcs *procs = (XPThemeProcs *)ckalloc(sizeof(XPThemeProcs));
-#define LOADPROC(name) \
- (0 != (procs->name = (name ## Proc *)(void *)GetProcAddress(handle, #name) ))
-
- if ( LOADPROC(OpenThemeData)
- && LOADPROC(CloseThemeData)
- && LOADPROC(GetThemePartSize)
- && LOADPROC(GetThemeSysSize)
- && LOADPROC(DrawThemeBackground)
- && LOADPROC(DrawThemeEdge)
- && LOADPROC(GetThemeTextExtent)
- && LOADPROC(DrawThemeText)
- && LOADPROC(IsThemeActive)
- && LOADPROC(IsAppThemed)
- )
- {
- return procs;
- }
-#undef LOADPROC
- ckfree(procs);
- }
- return 0;
-}
+#ifdef _MSC_VER
+# pragma comment (lib, "uxtheme.lib")
+#endif
/*
- * XPThemeDeleteProc --
+ * VistaThemeDeleteProc --
*
* Release any theme allocated resources.
*/
static void
-XPThemeDeleteProc(void *clientData)
+VistaThemeDeleteProc(
+ TCL_UNUSED(void *))
{
- XPThemeData *themeData = (XPThemeData *)clientData;
- FreeLibrary(themeData->hlibrary);
- ckfree(clientData);
}
static int
-XPThemeEnabled(
+VistaThemeEnabled(
TCL_UNUSED(Ttk_Theme),
- void *clientData)
+ TCL_UNUSED(void *))
{
- XPThemeData *themeData = (XPThemeData *)clientData;
- int active = themeData->procs->IsThemeActive();
- int themed = themeData->procs->IsAppThemed();
+ int active = IsThemeActive();
+ int themed = IsAppThemed();
return (active && themed);
}
@@ -163,7 +63,7 @@ BoxToRect(Ttk_Box b)
}
/*
- * Map Tk state bitmaps to XP style enumerated values.
+ * Map Tk state bitmaps to Vista style enumerated values.
*/
static const Ttk_StateTable null_statemap[] = { {0,0,0} };
@@ -352,7 +252,7 @@ static const Ttk_StateTable tabitem_statemap[] =
*
* The following structure is passed as the 'clientData' pointer
* to most elements in this theme. It contains data relevant
- * to a single XP Theme "part".
+ * to a single Vista Theme "part".
*
* <<NOTE-GetThemeMargins>>:
* In theory, we should be call GetThemeMargins(...TMT_CONTENTRECT...)
@@ -368,14 +268,14 @@ static const Ttk_StateTable tabitem_statemap[] =
* BP_PUSHBUTTONS). Set the IGNORE_THEMESIZE flag to skip this call.
*/
-typedef struct /* XP element specifications */
+typedef struct /* Vista element specifications */
{
const char *elementName; /* Tk theme engine element name */
const Ttk_ElementSpec *elementSpec;
/* Element spec (usually GenericElementSpec) */
LPCWSTR className; /* Windows window class name */
int partId; /* BP_PUSHBUTTON, BP_CHECKBUTTON, etc. */
- const Ttk_StateTable *statemap; /* Map Tk states to XP states */
+ const Ttk_StateTable *statemap; /* Map Tk states to Vista states */
Ttk_Padding padding; /* See NOTE-GetThemeMargins */
unsigned flags;
# define IGNORE_THEMESIZE 0x80000000U /* See NOTE-GetThemePartSize */
@@ -391,7 +291,7 @@ typedef struct
* Static data, initialized when element is registered:
*/
const ElementInfo *info;
- XPThemeProcs *procs; /* Pointer to theme procedure table */
+ HWND parentHwnd;
/*
* Dynamic data, allocated by InitElementData:
@@ -406,11 +306,11 @@ typedef struct
} ElementData;
static ElementData *
-NewElementData(XPThemeProcs *procs, const ElementInfo *info)
+NewElementData(HWND hwnd, const ElementInfo *info)
{
- ElementData *elementData = (ElementData *)ckalloc(sizeof(ElementData));
+ ElementData *elementData = (ElementData *)Tcl_Alloc(sizeof(ElementData));
- elementData->procs = procs;
+ elementData->parentHwnd = hwnd;
elementData->info = info;
elementData->hTheme = elementData->hDC = 0;
@@ -426,12 +326,12 @@ static void DestroyElementData(void *clientData)
{
ElementData *elementData = (ElementData *)clientData;
if (elementData->info->flags & HEAP_ELEMENT) {
- ckfree((void *)elementData->info->statemap);
- ckfree((void *)elementData->info->className);
- ckfree((void *)elementData->info->elementName);
- ckfree((void *)elementData->info);
+ Tcl_Free((void *)elementData->info->statemap);
+ Tcl_Free((void *)elementData->info->className);
+ Tcl_Free((void *)elementData->info->elementName);
+ Tcl_Free((void *)elementData->info);
}
- ckfree(clientData);
+ Tcl_Free(clientData);
}
/*
@@ -453,19 +353,20 @@ InitElementData(ElementData *elementData, Tk_Window tkwin, Drawable d)
if (win) {
elementData->hwnd = Tk_GetHWND(win);
} else {
- elementData->hwnd = elementData->procs->stubWindow;
+ elementData->hwnd = elementData->parentHwnd;
}
- elementData->hTheme = elementData->procs->OpenThemeData(
- elementData->hwnd, elementData->info->className);
+ elementData->hTheme = OpenThemeData(
+ elementData->hwnd, elementData->info->className);
- if (!elementData->hTheme)
+ if (!elementData->hTheme) {
return 0;
+ }
elementData->drawable = d;
if (d != 0) {
elementData->hDC = TkWinGetDrawableDC(Tk_Display(tkwin), d,
- &elementData->dcState);
+ &elementData->dcState);
}
return 1;
@@ -474,7 +375,7 @@ InitElementData(ElementData *elementData, Tk_Window tkwin, Drawable d)
static void
FreeElementData(ElementData *elementData)
{
- elementData->procs->CloseThemeData(elementData->hTheme);
+ CloseThemeData(elementData->hTheme);
if (elementData->drawable != 0) {
TkWinReleaseDrawableDC(
elementData->drawable, elementData->hDC, &elementData->dcState);
@@ -484,7 +385,7 @@ FreeElementData(ElementData *elementData)
/*----------------------------------------------------------------------
* +++ Generic element implementation.
*
- * Used for elements which are handled entirely by the XP Theme API,
+ * Used for elements which are handled entirely by the Vista Theme API,
* such as radiobutton and checkbutton indicators, scrollbar arrows, etc.
*/
@@ -500,11 +401,12 @@ static void GenericElementSize(
HRESULT result;
SIZE size;
- if (!InitElementData(elementData, tkwin, 0))
+ if (!InitElementData(elementData, tkwin, 0)) {
return;
+ }
if (!(elementData->info->flags & IGNORE_THEMESIZE)) {
- result = elementData->procs->GetThemePartSize(
+ result = GetThemePartSize(
elementData->hTheme,
NULL,
elementData->info->partId,
@@ -548,7 +450,7 @@ static void GenericElementDraw(
}
rc = BoxToRect(b);
- elementData->procs->DrawThemeBackground(
+ DrawThemeBackground(
elementData->hTheme,
elementData->hDC,
elementData->info->partId,
@@ -571,7 +473,7 @@ static const Ttk_ElementSpec GenericElementSpec =
/*----------------------------------------------------------------------
* +++ Sized element implementation.
*
- * Used for elements which are handled entirely by the XP Theme API,
+ * Used for elements which are handled entirely by the Vista Theme API,
* but that require a fixed size adjustment.
* Note that GetThemeSysSize calls through to GetSystemMetrics
*/
@@ -583,20 +485,23 @@ GenericSizedElementSize(
{
ElementData *elementData = (ElementData *)clientData;
- if (!InitElementData(elementData, tkwin, 0))
+ if (!InitElementData(elementData, tkwin, 0)) {
return;
+ }
GenericElementSize(clientData, elementRecord, tkwin,
widthPtr, heightPtr, paddingPtr);
- *widthPtr = elementData->procs->GetThemeSysSize(NULL,
+ *widthPtr = GetThemeSysSize(NULL,
(elementData->info->flags >> 8) & 0xff);
- *heightPtr = elementData->procs->GetThemeSysSize(NULL,
+ *heightPtr = GetThemeSysSize(NULL,
elementData->info->flags & 0xff);
- if (elementData->info->flags & HALF_HEIGHT)
+ if (elementData->info->flags & HALF_HEIGHT) {
*heightPtr /= 2;
- if (elementData->info->flags & HALF_WIDTH)
+ }
+ if (elementData->info->flags & HALF_WIDTH) {
*widthPtr /= 2;
+ }
}
static const Ttk_ElementSpec GenericSizedElementSpec = {
@@ -619,8 +524,9 @@ SpinboxArrowElementSize(
{
ElementData *elementData = (ElementData *)clientData;
- if (!InitElementData(elementData, tkwin, 0))
+ if (!InitElementData(elementData, tkwin, 0)) {
return;
+ }
GenericSizedElementSize(clientData, elementRecord, tkwin,
widthPtr, heightPtr, paddingPtr);
@@ -651,19 +557,21 @@ static void ThumbElementDraw(
Ttk_State state)
{
ElementData *elementData = (ElementData *)clientData;
- unsigned stateId = Ttk_StateTableLookup(elementData->info->statemap, state);
+ int stateId = Ttk_StateTableLookup(elementData->info->statemap, state);
RECT rc = BoxToRect(b);
/*
* Don't draw the thumb if we are disabled.
*/
- if (state & TTK_STATE_DISABLED)
+ if (state & TTK_STATE_DISABLED) {
return;
+ }
- if (!InitElementData(elementData, tkwin, d))
+ if (!InitElementData(elementData, tkwin, d)) {
return;
+ }
- elementData->procs->DrawThemeBackground(elementData->hTheme,
+ DrawThemeBackground(elementData->hTheme,
elementData->hDC, elementData->info->partId, stateId,
&rc, NULL);
@@ -801,8 +709,9 @@ static void TabElementDraw(
RECT rc = BoxToRect(b);
- if (!InitElementData(elementData, tkwin, d))
+ if (!InitElementData(elementData, tkwin, d)) {
return;
+ }
if (nbTabsStickBit == TTK_STICK_S) {
if (state & TTK_STATE_FIRST) {
@@ -812,7 +721,7 @@ static void TabElementDraw(
/*
* Draw the border and fill into rc
*/
- elementData->procs->DrawThemeBackground(
+ DrawThemeBackground(
elementData->hTheme, elementData->hDC, partId, stateId, &rc, NULL);
} else {
/*
@@ -820,7 +729,7 @@ static void TabElementDraw(
*/
RECT rc2 = rc;
--rc2.top; --rc2.left; ++rc2.bottom; ++rc2.right;
- elementData->procs->DrawThemeBackground(
+ DrawThemeBackground(
elementData->hTheme, elementData->hDC, partId, stateId, &rc2, &rc);
}
@@ -832,17 +741,17 @@ static void TabElementDraw(
case TTK_STICK_S:
break;
case TTK_STICK_N:
- elementData->procs->DrawThemeEdge(
+ DrawThemeEdge(
elementData->hTheme, elementData->hDC, partId, stateId, &rc,
BDR_RAISEDINNER, BF_FLAT|BF_LEFT|BF_RIGHT|BF_BOTTOM, NULL);
break;
case TTK_STICK_E:
- elementData->procs->DrawThemeEdge(
+ DrawThemeEdge(
elementData->hTheme, elementData->hDC, partId, stateId, &rc,
BDR_RAISEDINNER, BF_FLAT|BF_LEFT|BF_TOP|BF_BOTTOM, NULL);
break;
case TTK_STICK_W:
- elementData->procs->DrawThemeEdge(
+ DrawThemeEdge(
elementData->hTheme, elementData->hDC, partId, stateId, &rc,
BDR_RAISEDINNER, BF_FLAT|BF_TOP|BF_RIGHT|BF_BOTTOM, NULL);
break;
@@ -905,116 +814,6 @@ static const Ttk_ElementSpec TreeIndicatorElementSpec =
TreeIndicatorElementDraw
};
-#ifdef BROKEN_TEXT_ELEMENT
-
-/*
- *----------------------------------------------------------------------
- * Text element (does not work yet).
- *
- * According to "Using Windows XP Visual Styles", we need to select
- * a font into the DC before calling DrawThemeText().
- * There's just no easy way to get an HFONT out of a Tk_Font.
- * Maybe GetThemeFont() would work?
- *
- */
-
-typedef struct
-{
- Tcl_Obj *textObj;
- Tcl_Obj *fontObj;
-} TextElement;
-
-static const Ttk_ElementOptionSpec TextElementOptions[] =
-{
- { "-text", TK_OPTION_STRING,
- offsetof(TextElement,textObj), "" },
- { "-font", TK_OPTION_FONT,
- offsetof(TextElement,fontObj), DEFAULT_FONT },
- { NULL }
-};
-
-static void TextElementSize(
- void *clientData, void *elementRecord, Tk_Window tkwin,
- int *widthPtr, int *heightPtr, Ttk_Padding *paddingPtr)
-{
- TextElement *element = elementRecord;
- ElementData *elementData = clientData;
- RECT rc = {0, 0};
- HRESULT hr = S_OK;
- const char *src;
- Tcl_Size len;
- Tcl_DString ds;
-
- if (!InitElementData(elementData, tkwin, 0))
- return;
-
- src = Tcl_GetStringFromObj(element->textObj, &len);
- Tcl_DStringInit(&ds);
- hr = elementData->procs->GetThemeTextExtent(
- elementData->hTheme,
- elementData->hDC,
- elementData->info->partId,
- Ttk_StateTableLookup(elementData->info->statemap, 0),
- Tcl_UtfToWCharDString(src, len, &ds),
- -1,
- DT_LEFT /* | DT_BOTTOM | DT_NOPREFIX */,
- NULL,
- &rc);
-
- if (SUCCEEDED(hr)) {
- *widthPtr = rc.right - rc.left;
- *heightPtr = rc.bottom - rc.top;
- }
- if (*widthPtr < 80) *widthPtr = 80;
- if (*heightPtr < 20) *heightPtr = 20;
-
- Tcl_DStringFree(&ds);
- FreeElementData(elementData);
-}
-
-static void TextElementDraw(
- void *clientData, void *elementRecord, Tk_Window tkwin,
- Drawable d, Ttk_Box b, Ttk_State state)
-{
- TextElement *element = elementRecord;
- ElementData *elementData = clientData;
- RECT rc = BoxToRect(b);
- HRESULT hr = S_OK;
- const char *src;
- Tcl_Size len;
- Tcl_DString ds;
-
- if (!InitElementData(elementData, tkwin, d))
- return;
-
- src = Tcl_GetStringFromObj(element->textObj, &len);
- Tcl_DStringInit(&ds);
- hr = elementData->procs->DrawThemeText(
- elementData->hTheme,
- elementData->hDC,
- elementData->info->partId,
- Ttk_StateTableLookup(elementData->info->statemap, state),
- Tcl_UtfToWCharDString(src, len, &ds),
- -1,
- DT_LEFT /* | DT_BOTTOM | DT_NOPREFIX */,
- (state & TTK_STATE_DISABLED) ? DTT_GRAYED : 0,
- &rc);
-
- Tcl_DStringFree(&ds);
- FreeElementData(elementData);
-}
-
-static const Ttk_ElementSpec TextElementSpec =
-{
- TK_STYLE_VERSION_2,
- sizeof(TextElement),
- TextElementOptions,
- TextElementSize,
- TextElementDraw
-};
-
-#endif /* BROKEN_TEXT_ELEMENT */
-
/*----------------------------------------------------------------------
* +++ Widget layouts:
*/
@@ -1062,7 +861,7 @@ TTK_LAYOUT("Vertical.TScale",
TTK_END_LAYOUT_TABLE
/*----------------------------------------------------------------------
- * +++ XP element info table:
+ * +++ Vista element info table:
*/
#define PAD(l,t,r,b) {l,t,r,b}
@@ -1157,10 +956,6 @@ static const ElementInfo ElementInfoTable[] = {
{ "Spinbox.downarrow", &SpinboxArrowElementSpec, L"SPIN",
SPNP_DOWN, spinbutton_statemap, NOPAD,
PAD_MARGINS | ((SM_CXVSCROLL << 8) | SM_CYVSCROLL) },
-#ifdef BROKEN_TEXT_ELEMENT
- { "Labelframe.text", &TextElementSpec, L"BUTTON",
- BP_GROUPBOX, groupbox_statemap, NOPAD, 0 },
-#endif
{ 0, 0, 0, 0, 0, NOPAD, 0 }
};
#undef PAD
@@ -1185,11 +980,12 @@ GetSysFlagFromObj(Tcl_Interp *interp, Tcl_Obj *objPtr, int *resultPtr)
Tcl_Obj **objv;
Tcl_Size i, objc;
- if (Tcl_ListObjGetElements(interp, objPtr, &objc, &objv) != TCL_OK)
+ if (Tcl_ListObjGetElements(interp, objPtr, &objc, &objv) != TCL_OK) {
return TCL_ERROR;
+ }
if (objc != 2) {
Tcl_SetObjResult(interp, Tcl_NewStringObj("wrong # args", TCL_INDEX_NONE));
- Tcl_SetErrorCode(interp, "TCL", "WRONGARGS", NULL);
+ Tcl_SetErrorCode(interp, "TCL", "WRONGARGS", (char *)NULL);
return TCL_ERROR;
}
for (i = 0; i < objc; ++i) {
@@ -1223,14 +1019,14 @@ Ttk_CreateVsapiElement(
Tcl_Size objc,
Tcl_Obj *const objv[])
{
- XPThemeData *themeData = (XPThemeData *)clientData;
+ HWND hwnd = (HWND)clientData;
ElementInfo *elementPtr = NULL;
void *elementData;
LPCWSTR className;
int partId = 0;
Ttk_StateTable *stateTable;
Ttk_Padding pad = {0, 0, 0, 0};
- int flags = 0;
+ unsigned flags = 0;
Tcl_Size length = 0;
char *name;
LPWSTR wname;
@@ -1246,7 +1042,7 @@ Ttk_CreateVsapiElement(
if (objc < 2) {
Tcl_SetObjResult(interp, Tcl_NewStringObj(
"missing required arguments 'class' and/or 'partId'", TCL_INDEX_NONE));
- Tcl_SetErrorCode(interp, "TTK", "VSAPI", "REQUIRED", NULL);
+ Tcl_SetErrorCode(interp, "TTK", "VSAPI", "REQUIRED", (char *)NULL);
return TCL_ERROR;
}
@@ -1267,7 +1063,7 @@ Ttk_CreateVsapiElement(
Tcl_SetObjResult(interp, Tcl_ObjPrintf(
"Missing value for \"%s\".",
Tcl_GetString(objv[i])));
- Tcl_SetErrorCode(interp, "TTK", "VSAPI", "MISSING", NULL);
+ Tcl_SetErrorCode(interp, "TTK", "VSAPI", "MISSING", (char *)NULL);
goto retErr;
}
if (Tcl_GetIndexFromObj(interp, objv[i], optionStrings,
@@ -1289,14 +1085,14 @@ Ttk_CreateVsapiElement(
if (Tcl_GetIntFromObj(interp, objv[i+1], &tmp) != TCL_OK) {
goto retErr;
}
- pad.left = pad.right = tmp;
+ pad.left = pad.right = (short)tmp;
flags |= IGNORE_THEMESIZE;
break;
case O_HEIGHT:
if (Tcl_GetIntFromObj(interp, objv[i+1], &tmp) != TCL_OK) {
goto retErr;
}
- pad.top = pad.bottom = tmp;
+ pad.top = pad.bottom = (short)tmp;
flags |= IGNORE_THEMESIZE;
break;
case O_SYSSIZE:
@@ -1310,15 +1106,17 @@ Ttk_CreateVsapiElement(
if (Tcl_GetBooleanFromObj(interp, objv[i+1], &tmp) != TCL_OK) {
goto retErr;
}
- if (tmp)
+ if (tmp) {
flags |= HALF_HEIGHT;
+ }
break;
case O_HALFWIDTH:
if (Tcl_GetBooleanFromObj(interp, objv[i+1], &tmp) != TCL_OK) {
goto retErr;
}
- if (tmp)
+ if (tmp) {
flags |= HALF_WIDTH;
+ }
break;
}
}
@@ -1329,11 +1127,12 @@ Ttk_CreateVsapiElement(
Tcl_Obj **specs;
Tcl_Size n, j, count;
int status = TCL_OK;
- if (Tcl_ListObjGetElements(interp, objv[2], &count, &specs) != TCL_OK)
+ if (Tcl_ListObjGetElements(interp, objv[2], &count, &specs) != TCL_OK) {
goto retErr;
+ }
/* we over-allocate to ensure there is a terminating entry */
- stateTable = (Ttk_StateTable *)ckalloc(sizeof(Ttk_StateTable) * (count + 1));
- memset(stateTable, 0, sizeof(Ttk_StateTable) * (count + 1));
+ stateTable = (Ttk_StateTable *)Tcl_Alloc(sizeof(Ttk_StateTable) * ((size_t)count + 1));
+ memset(stateTable, 0, sizeof(Ttk_StateTable) * ((size_t)count + 1));
for (n = 0, j = 0; status == TCL_OK && n < count; n += 2, ++j) {
Ttk_StateSpec spec = {0,0};
status = Ttk_GetStateSpecFromObj(interp, specs[n], &spec);
@@ -1345,34 +1144,34 @@ Ttk_CreateVsapiElement(
}
}
if (status != TCL_OK) {
- ckfree(stateTable);
+ Tcl_Free(stateTable);
Tcl_DStringFree(&classBuf);
return status;
}
} else {
- stateTable = (Ttk_StateTable *)ckalloc(sizeof(Ttk_StateTable));
+ stateTable = (Ttk_StateTable *)Tcl_Alloc(sizeof(Ttk_StateTable));
memset(stateTable, 0, sizeof(Ttk_StateTable));
}
- elementPtr = (ElementInfo *)ckalloc(sizeof(ElementInfo));
+ elementPtr = (ElementInfo *)Tcl_Alloc(sizeof(ElementInfo));
elementPtr->elementSpec = elementSpec;
elementPtr->partId = partId;
elementPtr->statemap = stateTable;
elementPtr->padding = pad;
- elementPtr->flags = HEAP_ELEMENT | flags;
+ elementPtr->flags = HEAP_ELEMENT | (unsigned)flags;
/* set the element name to an allocated copy */
- name = (char *)ckalloc(strlen(elementName) + 1);
+ name = (char *)Tcl_Alloc(strlen(elementName) + 1);
strcpy(name, elementName);
elementPtr->elementName = name;
/* set the class name to an allocated copy */
- wname = (LPWSTR)ckalloc(Tcl_DStringLength(&classBuf) + sizeof(WCHAR));
+ wname = (LPWSTR)Tcl_Alloc((size_t)Tcl_DStringLength(&classBuf) + sizeof(WCHAR));
wcscpy(wname, className);
elementPtr->className = wname;
- elementData = NewElementData(themeData->procs, elementPtr);
- Ttk_RegisterElementSpec(
+ elementData = NewElementData(hwnd, elementPtr);
+ Ttk_RegisterElement(NULL,
theme, elementName, elementPtr->elementSpec, elementData);
Ttk_RegisterCleanup(interp, elementData, DestroyElementData);
@@ -1390,70 +1189,47 @@ retErr:
*/
MODULE_SCOPE int
-TtkXPTheme_Init(Tcl_Interp *interp, HWND hwnd)
+TtkWinVistaTheme_Init(Tcl_Interp *interp, HWND hwnd)
{
- XPThemeData *themeData;
- XPThemeProcs *procs;
- HINSTANCE hlibrary;
- Ttk_Theme themePtr, parentPtr, vistaPtr;
+ Ttk_Theme themePtr, parentPtr;
const ElementInfo *infoPtr;
- procs = LoadXPThemeProcs(&hlibrary);
- if (!procs)
- return TCL_ERROR;
- procs->stubWindow = hwnd;
-
/*
* Create the new style engine.
*/
parentPtr = Ttk_GetTheme(interp, "winnative");
- themePtr = Ttk_CreateTheme(interp, "xpnative", parentPtr);
+ themePtr = Ttk_CreateTheme(interp, "vista", parentPtr);
- if (!themePtr)
+ if (!themePtr) {
return TCL_ERROR;
+ }
/*
* Set theme data and cleanup proc
*/
- themeData = (XPThemeData *)ckalloc(sizeof(XPThemeData));
- themeData->procs = procs;
- themeData->hlibrary = hlibrary;
-
- Ttk_SetThemeEnabledProc(themePtr, XPThemeEnabled, themeData);
- Ttk_RegisterCleanup(interp, themeData, XPThemeDeleteProc);
- Ttk_RegisterElementFactory(interp, "vsapi", Ttk_CreateVsapiElement, themeData);
-
- /*
- * Create the vista theme on suitable platform versions and set the theme
- * enable function. The theme itself is defined in script.
- */
-
- if (TkWinGetPlatformTheme() == TK_THEME_WIN_VISTA) {
- vistaPtr = Ttk_CreateTheme(interp, "vista", themePtr);
- if (vistaPtr) {
- Ttk_SetThemeEnabledProc(vistaPtr, XPThemeEnabled, themeData);
- }
- }
+ Ttk_SetThemeEnabledProc(themePtr, VistaThemeEnabled, hwnd);
+ Ttk_RegisterCleanup(interp, hwnd, VistaThemeDeleteProc);
+ Ttk_RegisterElementFactory(interp, "vsapi", Ttk_CreateVsapiElement, hwnd);
/*
* New elements:
*/
for (infoPtr = ElementInfoTable; infoPtr->elementName != 0; ++infoPtr) {
- void *clientData = NewElementData(procs, infoPtr);
- Ttk_RegisterElementSpec(
+ void *clientData = NewElementData(hwnd, infoPtr);
+ Ttk_RegisterElement(NULL,
themePtr, infoPtr->elementName, infoPtr->elementSpec, clientData);
Ttk_RegisterCleanup(interp, clientData, DestroyElementData);
}
- Ttk_RegisterElementSpec(themePtr, "Scale.trough", &ttkNullElementSpec, 0);
+ Ttk_RegisterElement(NULL, themePtr, "Scale.trough", &ttkNullElementSpec, 0);
/*
* Layouts:
*/
Ttk_RegisterLayouts(themePtr, LayoutTable);
- Tcl_PkgProvide(interp, "ttk::theme::xpnative", TTK_VERSION);
+ Tcl_PkgProvide(interp, "ttk::theme::vista", TTK_VERSION);
return TCL_OK;
}
diff --git a/win/winMain.c b/win/winMain.c
index e77e8dd..b431a4c 100644
--- a/win/winMain.c
+++ b/win/winMain.c
@@ -72,9 +72,6 @@ extern Tcl_LibraryInitProc Dde_SafeInit;
#ifdef __cplusplus
}
#endif
-#ifdef TCL_BROKEN_MAINARGS
-static void setargv(int *argcPtr, TCHAR ***argvPtr);
-#endif
/*
* Forward declarations for procedures defined later in this file:
@@ -131,19 +128,11 @@ MODULE_SCOPE int TK_LOCAL_MAIN_HOOK(int *argc, TCHAR ***argv);
*/
int APIENTRY
-#ifdef TCL_BROKEN_MAINARGS
-WinMain(
- HINSTANCE hInstance,
- HINSTANCE hPrevInstance,
- LPSTR lpszCmdLine,
- int nCmdShow)
-#else
_tWinMain(
HINSTANCE hInstance,
HINSTANCE hPrevInstance,
LPTSTR lpszCmdLine,
int nCmdShow)
-#endif
{
TCHAR **argv;
int argc;
@@ -172,12 +161,8 @@ _tWinMain(
* Get our args from the c-runtime. Ignore lpszCmdLine.
*/
-#if defined(TCL_BROKEN_MAINARGS)
- setargv(&argc, &argv);
-#else
argc = __argc;
argv = __targv;
-#endif
/*
* Forward slashes substituted for backslashes.
@@ -307,21 +292,11 @@ Tcl_AppInit(
*----------------------------------------------------------------------
*/
-#ifdef TCL_BROKEN_MAINARGS
-int
-main(
- int argc,
- char **dummy)
-{
- TCHAR **argv;
- (void)dummy;
-#else
int
_tmain(
int argc,
TCHAR **argv)
{
-#endif
/*
* Set up the default locale to be standard "C" locale so parsing is
* performed correctly.
@@ -329,13 +304,6 @@ _tmain(
setlocale(LC_ALL, "C");
-#ifdef TCL_BROKEN_MAINARGS
- /*
- * Get our args from the c-runtime. Ignore argc/argv.
- */
-
- setargv(&argc, &argv);
-#endif
/*
* Console emulation widget not required as this entry is from the
* console subsystem, thus stdin,out,err already have end-points.
@@ -351,131 +319,6 @@ _tmain(
return 0;
}
#endif /* !__GNUC__ || TK_TEST */
-
-
-/*
- *-------------------------------------------------------------------------
- *
- * setargv --
- *
- * Parse the Windows command line string into argc/argv. Done here
- * because we don't trust the builtin argument parser in crt0. Windows
- * applications are responsible for breaking their command line into
- * arguments.
- *
- * 2N backslashes + quote -> N backslashes + begin quoted string
- * 2N + 1 backslashes + quote -> literal
- * N backslashes + non-quote -> literal
- * quote + quote in a quoted string -> single quote
- * quote + quote not in quoted string -> empty string
- * quote -> begin quoted string
- *
- * Results:
- * Fills argcPtr with the number of arguments and argvPtr with the array
- * of arguments.
- *
- * Side effects:
- * Memory allocated.
- *
- *--------------------------------------------------------------------------
- */
-
-#ifdef TCL_BROKEN_MAINARGS
-static void
-setargv(
- int *argcPtr, /* Filled with number of argument strings. */
- TCHAR ***argvPtr) /* Filled with argument strings (malloc'd). */
-{
- TCHAR *cmdLine, *p, *arg, *argSpace;
- TCHAR **argv;
- int argc, size, inquote, copy, slashes;
-
- cmdLine = GetCommandLine();
-
- /*
- * Precompute an overly pessimistic guess at the number of arguments in
- * the command line by counting non-space spans.
- */
-
- size = 2;
- for (p = cmdLine; *p != '\0'; p++) {
- if ((*p == ' ') || (*p == '\t')) { /* INTL: ISO space. */
- size++;
- while ((*p == ' ') || (*p == '\t')) { /* INTL: ISO space. */
- p++;
- }
- if (*p == '\0') {
- break;
- }
- }
- }
-
- /* Make sure we don't call ckalloc through the (not yet initialized) stub table */
- #undef Tcl_Alloc
- #undef Tcl_DbCkalloc
-
- argSpace = (TCHAR *)ckalloc(size * sizeof(char *)
- + (_tcslen(cmdLine) * sizeof(TCHAR)) + sizeof(TCHAR));
- argv = (TCHAR **) argSpace;
- argSpace += size * (sizeof(char *)/sizeof(TCHAR));
- size--;
-
- p = cmdLine;
- for (argc = 0; argc < size; argc++) {
- argv[argc] = arg = argSpace;
- while ((*p == ' ') || (*p == '\t')) { /* INTL: ISO space. */
- p++;
- }
- if (*p == '\0') {
- break;
- }
-
- inquote = 0;
- slashes = 0;
- while (1) {
- copy = 1;
- while (*p == '\\') {
- slashes++;
- p++;
- }
- if (*p == '"') {
- if ((slashes & 1) == 0) {
- copy = 0;
- if ((inquote) && (p[1] == '"')) {
- p++;
- copy = 1;
- } else {
- inquote = !inquote;
- }
- }
- slashes >>= 1;
- }
-
- while (slashes) {
- *arg = '\\';
- arg++;
- slashes--;
- }
-
- if ((*p == '\0') || (!inquote &&
- ((*p == ' ') || (*p == '\t')))) { /* INTL: ISO space. */
- break;
- }
- if (copy != 0) {
- *arg = *p;
- arg++;
- }
- p++;
- }
- *arg = '\0';
- argSpace = arg + 1;
- }
- argv[argc] = NULL;
-
- *argcPtr = argc;
- *argvPtr = argv;
-}
-#endif /* TCL_BROKEN_MAINARGS */
/*
* Local Variables:
diff --git a/win/wish.exe.manifest.in b/win/wish.exe.manifest.in
index 20a79a4..9fefac9 100644
--- a/win/wish.exe.manifest.in
+++ b/win/wish.exe.manifest.in
@@ -35,10 +35,6 @@
xmlns="http://schemas.microsoft.com/SMI/2005/WindowsSettings">
<dpiAware>true</dpiAware>
</asmv3:windowsSettings>
- <asmv3:windowsSettings
- xmlns="http://schemas.microsoft.com/SMI/2019/WindowsSettings">
- <activeCodePage>UTF-8</activeCodePage>
- </asmv3:windowsSettings>
</asmv3:application>
<dependency>
<dependentAssembly>