From ee16a52044d53a25664ecc7f02b042e3fb638baf Mon Sep 17 00:00:00 2001 From: fvogel Date: Thu, 18 Aug 2016 19:05:41 +0000 Subject: =?UTF-8?q?Implementation=20of=20TIP=20#442=20by=20Ren=C3=A9=20Zau?= =?UTF-8?q?mseil=20-=20Display=20text=20in=20progressbars?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- generic/ttk/ttkProgress.c | 27 ++++++++++++++++++++++++++- library/ttk/vistaTheme.tcl | 1 + 2 files changed, 27 insertions(+), 1 deletion(-) diff --git a/generic/ttk/ttkProgress.c b/generic/ttk/ttkProgress.c index eed90ec..bd0b814 100644 --- a/generic/ttk/ttkProgress.c +++ b/generic/ttk/ttkProgress.c @@ -30,6 +30,12 @@ typedef struct { Tcl_Obj *maximumObj; Tcl_Obj *valueObj; Tcl_Obj *phaseObj; + Tcl_Obj *textObj; + Tcl_Obj *fontObj; + Tcl_Obj *foregroundObj; + Tcl_Obj *anchorObj; + Tcl_Obj *justifyObj; + Tcl_Obj *wrapLengthObj; int mode; Ttk_TraceHandle *variableTrace; /* Trace handle for -variable option */ @@ -68,6 +74,24 @@ static Tk_OptionSpec ProgressbarOptionSpecs[] = {TK_OPTION_INT, "-phase", "phase", "Phase", "0", Tk_Offset(Progressbar,progress.phaseObj), -1, 0, 0, 0 }, + {TK_OPTION_STRING, "-text", "text", "Text", "", + Tk_Offset(Progressbar,progress.textObj), -1, + 0,0,GEOMETRY_CHANGED }, + {TK_OPTION_FONT, "-font", "font", "Font", + DEFAULT_FONT, Tk_Offset(Progressbar,progress.fontObj), -1, + TK_OPTION_NULL_OK,0,GEOMETRY_CHANGED }, + {TK_OPTION_COLOR, "-foreground", "textColor", "TextColor", + "black", Tk_Offset(Progressbar,progress.foregroundObj), -1, + TK_OPTION_NULL_OK,0,0 }, + {TK_OPTION_ANCHOR, "-anchor", "anchor", "Anchor", + "w", Tk_Offset(Progressbar,progress.anchorObj), -1, + TK_OPTION_NULL_OK, 0, GEOMETRY_CHANGED}, + {TK_OPTION_JUSTIFY, "-justify", "justify", "Justify", + "left", Tk_Offset(Progressbar,progress.justifyObj), -1, + TK_OPTION_NULL_OK,0,GEOMETRY_CHANGED }, + {TK_OPTION_PIXELS, "-wraplength", "wrapLength", "WrapLength", + "0", Tk_Offset(Progressbar, progress.wrapLengthObj), -1, + TK_OPTION_NULL_OK,0,GEOMETRY_CHANGED}, WIDGET_TAKEFOCUS_FALSE, WIDGET_INHERIT_OPTIONS(ttkCoreOptionSpecs) @@ -522,7 +546,8 @@ TTK_END_LAYOUT TTK_BEGIN_LAYOUT(HorizontalProgressbarLayout) TTK_GROUP("Horizontal.Progressbar.trough", TTK_FILL_BOTH, - TTK_NODE("Horizontal.Progressbar.pbar", TTK_PACK_LEFT|TTK_FILL_Y)) + TTK_NODE("Horizontal.Progressbar.pbar", TTK_PACK_LEFT|TTK_FILL_Y) + TTK_NODE("Horizontal.Progressbar.text", TTK_PACK_LEFT)) TTK_END_LAYOUT /* diff --git a/library/ttk/vistaTheme.tcl b/library/ttk/vistaTheme.tcl index 1ec824a..c284a52 100644 --- a/library/ttk/vistaTheme.tcl +++ b/library/ttk/vistaTheme.tcl @@ -182,6 +182,7 @@ namespace eval ttk::theme::vista { ttk::style layout Horizontal.TProgressbar { Horizontal.Progressbar.trough -sticky nswe -children { Horizontal.Progressbar.pbar -side left -sticky ns + Horizontal.Progressbar.text -sticky nesw } } ttk::style element create Vertical.Progressbar.pbar vsapi \ -- cgit v0.12 From 2e7b097afc15bc6b6fad5e18b7bd69d961e9b349 Mon Sep 17 00:00:00 2001 From: "jan.nijtmans" Date: Tue, 17 Jan 2017 12:39:57 +0000 Subject: tag Tk_FreeXId() as deprecated. Remove the function from the build if TK_NO_DEPRECATED is defined. --- generic/tk.decls | 2 +- generic/tk.h | 4 +- generic/tkDecls.h | 8 +- generic/tkStubInit.c | 5 + generic/ttk/ttkGenStubs.tcl | 963 -------------------------------------------- unix/Makefile.in | 2 +- win/Makefile.in | 2 +- 7 files changed, 18 insertions(+), 968 deletions(-) delete mode 100644 generic/ttk/ttkGenStubs.tcl diff --git a/generic/tk.decls b/generic/tk.decls index 9ceb3af..eaaa063 100644 --- a/generic/tk.decls +++ b/generic/tk.decls @@ -326,7 +326,7 @@ declare 75 { declare 76 { void Tk_FreeTextLayout(Tk_TextLayout textLayout) } -declare 77 { +declare 77 deprecated { void Tk_FreeXId(Display *display, XID xid) } declare 78 { diff --git a/generic/tk.h b/generic/tk.h index 9403f31..658b11e 100644 --- a/generic/tk.h +++ b/generic/tk.h @@ -414,7 +414,9 @@ typedef enum { #define TK_CONFIG_COLOR_ONLY (1 << 1) #define TK_CONFIG_MONO_ONLY (1 << 2) #define TK_CONFIG_DONT_SET_DEFAULT (1 << 3) -#define TK_CONFIG_OPTION_SPECIFIED (1 << 4) +#if !defined(TK_NO_DEPRECATED) || defined(BUILD_tk) +# define TK_CONFIG_OPTION_SPECIFIED (1 << 4) +#endif #define TK_CONFIG_USER_BIT 0x100 #endif /* __NO_OLD_CONFIG */ diff --git a/generic/tkDecls.h b/generic/tkDecls.h index eaaaf6c..3b72706 100644 --- a/generic/tkDecls.h +++ b/generic/tkDecls.h @@ -17,6 +17,12 @@ #define TCL_STORAGE_CLASS DLLEXPORT #endif +#if defined(TK_NO_DEPRECATED) && defined(BUILD_tk) +# define TK_DEPRECATED MODULE_SCOPE +#else +# define TK_DEPRECATED EXTERN +#endif + /* * WARNING: This file is automatically generated by the tools/genStubs.tcl * script. Any modifications to the function declarations below should be made @@ -281,7 +287,7 @@ EXTERN void Tk_FreePixmap(Display *display, Pixmap pixmap); /* 76 */ EXTERN void Tk_FreeTextLayout(Tk_TextLayout textLayout); /* 77 */ -EXTERN void Tk_FreeXId(Display *display, XID xid); +TK_DEPRECATED void Tk_FreeXId(Display *display, XID xid); /* 78 */ EXTERN GC Tk_GCForColor(XColor *colorPtr, Drawable drawable); /* 79 */ diff --git a/generic/tkStubInit.c b/generic/tkStubInit.c index ffe7b75..7f5b3be 100644 --- a/generic/tkStubInit.c +++ b/generic/tkStubInit.c @@ -40,6 +40,10 @@ MODULE_SCOPE const TkStubs tkStubs; #undef Tk_MainEx #undef Tk_FreeXId + +#ifdef TK_NO_DEPRECATED +#define Tk_FreeXId 0 +#else static void doNothing(void) { @@ -47,6 +51,7 @@ doNothing(void) } #define Tk_FreeXId ((void (*)(Display *, XID)) doNothing) +#endif #ifdef _WIN32 diff --git a/generic/ttk/ttkGenStubs.tcl b/generic/ttk/ttkGenStubs.tcl deleted file mode 100644 index 8047e3f..0000000 --- a/generic/ttk/ttkGenStubs.tcl +++ /dev/null @@ -1,963 +0,0 @@ -# ttkGenStubs.tcl -- -# -# This script generates a set of stub files for a given -# interface. -# -# -# Copyright (c) 1998-1999 by Scriptics Corporation. -# Copyright (c) 2007 Daniel A. Steffen -# -# See the file "license.terms" for information on usage and redistribution -# of this file, and for a DISCLAIMER OF ALL WARRANTIES. -# -# SOURCE: tcl/tools/genStubs.tcl, revision 1.44 -# -# CHANGES: -# + Second argument to "declare" is used as a status guard -# instead of a platform guard. -# + Allow trailing semicolon in function declarations -# - -namespace eval genStubs { - # libraryName -- - # - # The name of the entire library. This value is used to compute - # the USE_*_STUBS macro and the name of the init file. - - variable libraryName "UNKNOWN" - - # interfaces -- - # - # An array indexed by interface name that is used to maintain - # the set of valid interfaces. The value is empty. - - array set interfaces {} - - # curName -- - # - # The name of the interface currently being defined. - - variable curName "UNKNOWN" - - # scspec -- - # - # Storage class specifier for external function declarations. - # Normally "EXTERN", may be set to something like XYZAPI - # - variable scspec "EXTERN" - - # epoch, revision -- - # - # The epoch and revision numbers of the interface currently being defined. - # (@@@TODO: should be an array mapping interface names -> numbers) - # - - variable epoch {} - variable revision 0 - - # hooks -- - # - # An array indexed by interface name that contains the set of - # subinterfaces that should be defined for a given interface. - - array set hooks {} - - # stubs -- - # - # This three dimensional array is indexed first by interface name, - # second by field name, and third by a numeric offset or the - # constant "lastNum". The lastNum entry contains the largest - # numeric offset used for a given interface. - # - # Field "decl,$i" contains the C function specification that - # should be used for the given entry in the stub table. The spec - # consists of a list in the form returned by parseDecl. - # Other fields TBD later. - - array set stubs {} - - # outDir -- - # - # The directory where the generated files should be placed. - - variable outDir . -} - -# genStubs::library -- -# -# This function is used in the declarations file to set the name -# of the library that the interfaces are associated with (e.g. "tcl"). -# This value will be used to define the inline conditional macro. -# -# Arguments: -# name The library name. -# -# Results: -# None. - -proc genStubs::library {name} { - variable libraryName $name -} - -# genStubs::interface -- -# -# This function is used in the declarations file to set the name -# of the interface currently being defined. -# -# Arguments: -# name The name of the interface. -# -# Results: -# None. - -proc genStubs::interface {name} { - variable curName $name - variable interfaces - variable stubs - - set interfaces($name) {} - set stubs($name,lastNum) 0 - return -} - -# genStubs::scspec -- -# -# Define the storage class macro used for external function declarations. -# Typically, this will be a macro like XYZAPI or EXTERN that -# expands to either DLLIMPORT or DLLEXPORT, depending on whether -# -DBUILD_XYZ has been set. -# -proc genStubs::scspec {value} { - variable scspec $value -} - -# genStubs::epoch -- -# -# Define the epoch number for this library. The epoch -# should be incrememented when a release is made that -# contains incompatible changes to the public API. -# -proc genStubs::epoch {value} { - variable epoch $value -} - -# genStubs::hooks -- -# -# This function defines the subinterface hooks for the current -# interface. -# -# Arguments: -# names The ordered list of interfaces that are reachable through the -# hook vector. -# -# Results: -# None. - -proc genStubs::hooks {names} { - variable curName - variable hooks - - set hooks($curName) $names - return -} - -# genStubs::declare -- -# -# This function is used in the declarations file to declare a new -# interface entry. -# -# Arguments: -# index The index number of the interface. -# status Status of the interface: one of "current", -# "deprecated", or "obsolete". -# decl The C function declaration, or {} for an undefined -# entry. -# -# Results: -# None. - -proc genStubs::declare {args} { - variable stubs - variable curName - variable revision - - incr revision - if {[llength $args] == 2} { - lassign $args index decl - set status current - } elseif {[llength $args] == 3} { - lassign $args index status decl - } else { - puts stderr "wrong # args: declare $args" - return - } - - # Check for duplicate declarations, then add the declaration and - # bump the lastNum counter if necessary. - - if {[info exists stubs($curName,decl,$index)]} { - puts stderr "Duplicate entry: $index" - } - regsub -all "\[ \t\n\]+" [string trim $decl] " " decl - set decl [parseDecl $decl] - - set stubs($curName,status,$index) $status - set stubs($curName,decl,$index) $decl - - if {$index > $stubs($curName,lastNum)} { - set stubs($curName,lastNum) $index - } - return -} - -# genStubs::export -- -# -# This function is used in the declarations file to declare a symbol -# that is exported from the library but is not in the stubs table. -# -# Arguments: -# decl The C function declaration, or {} for an undefined -# entry. -# -# Results: -# None. - -proc genStubs::export {args} { - if {[llength $args] != 1} { - puts stderr "wrong # args: export $args" - } - return -} - -# genStubs::rewriteFile -- -# -# This function replaces the machine generated portion of the -# specified file with new contents. It looks for the !BEGIN! and -# !END! comments to determine where to place the new text. -# -# Arguments: -# file The name of the file to modify. -# text The new text to place in the file. -# -# Results: -# None. - -proc genStubs::rewriteFile {file text} { - if {![file exists $file]} { - puts stderr "Cannot find file: $file" - return - } - set in [open ${file} r] - set out [open ${file}.new w] - fconfigure $out -translation lf - - while {![eof $in]} { - set line [gets $in] - if {[string match "*!BEGIN!*" $line]} { - break - } - puts $out $line - } - puts $out "/* !BEGIN!: Do not edit below this line. */" - puts $out $text - while {![eof $in]} { - set line [gets $in] - if {[string match "*!END!*" $line]} { - break - } - } - puts $out "/* !END!: Do not edit above this line. */" - puts -nonewline $out [read $in] - close $in - close $out - file rename -force ${file}.new ${file} - return -} - -# genStubs::addPlatformGuard -- -# -# Wrap a string inside a platform #ifdef. -# -# Arguments: -# plat Platform to test. -# -# Results: -# Returns the original text inside an appropriate #ifdef. - -proc genStubs::addPlatformGuard {plat iftxt {eltxt {}}} { - set text "" - switch $plat { - win { - append text "#ifdef _WIN32 /* WIN */\n${iftxt}" - if {$eltxt ne ""} { - append text "#else /* WIN */\n${eltxt}" - } - append text "#endif /* WIN */\n" - } - unix { - append text "#if !defined(_WIN32) && !defined(MAC_OSX_TCL)\ - /* UNIX */\n${iftxt}" - if {$eltxt ne ""} { - append text "#else /* UNIX */\n${eltxt}" - } - append text "#endif /* UNIX */\n" - } - macosx { - append text "#ifdef MAC_OSX_TCL /* MACOSX */\n${iftxt}" - if {$eltxt ne ""} { - append text "#else /* MACOSX */\n${eltxt}" - } - append text "#endif /* MACOSX */\n" - } - aqua { - append text "#ifdef MAC_OSX_TK /* AQUA */\n${iftxt}" - if {$eltxt ne ""} { - append text "#else /* AQUA */\n${eltxt}" - } - append text "#endif /* AQUA */\n" - } - x11 { - append text "#if !(defined(_WIN32) || defined(MAC_OSX_TK))\ - /* X11 */\n${iftxt}" - if {$eltxt ne ""} { - append text "#else /* X11 */\n${eltxt}" - } - append text "#endif /* X11 */\n" - } - default { - append text "${iftxt}${eltxt}" - } - } - return $text -} - -# genStubs::emitSlots -- -# -# Generate the stub table slots for the given interface. If there -# are no generic slots, then one table is generated for each -# platform, otherwise one table is generated for all platforms. -# -# Arguments: -# name The name of the interface being emitted. -# textVar The variable to use for output. -# -# Results: -# None. - -proc genStubs::emitSlots {name textVar} { - upvar $textVar text - - forAllStubs $name makeSlot noGuard text {" void (*reserved$i)(void);\n"} - return -} - -# genStubs::parseDecl -- -# -# Parse a C function declaration into its component parts. -# -# Arguments: -# decl The function declaration. -# -# Results: -# Returns a list of the form {returnType name args}. The args -# element consists of a list of type/name pairs, or a single -# element "void". If the function declaration is malformed -# then an error is displayed and the return value is {}. - -proc genStubs::parseDecl {decl} { - if {![regexp {^(.*)\((.*)\);?$} $decl all prefix args]} { - set prefix $decl - set args {} - } - set prefix [string trim $prefix] - if {![regexp {^(.+[ ][*]*)([^ *]+)$} $prefix all rtype fname]} { - puts stderr "Bad return type: $decl" - return - } - set rtype [string trim $rtype] - if {$args eq ""} { - return [list $rtype $fname {}] - } - foreach arg [split $args ,] { - lappend argList [string trim $arg] - } - if {![string compare [lindex $argList end] "..."]} { - set args TCL_VARARGS - foreach arg [lrange $argList 0 end-1] { - set argInfo [parseArg $arg] - if {[llength $argInfo] == 2 || [llength $argInfo] == 3} { - lappend args $argInfo - } else { - puts stderr "Bad argument: '$arg' in '$decl'" - return - } - } - } else { - set args {} - foreach arg $argList { - set argInfo [parseArg $arg] - if {![string compare $argInfo "void"]} { - lappend args "void" - break - } elseif {[llength $argInfo] == 2 || [llength $argInfo] == 3} { - lappend args $argInfo - } else { - puts stderr "Bad argument: '$arg' in '$decl'" - return - } - } - } - return [list $rtype $fname $args] -} - -# genStubs::parseArg -- -# -# This function parses a function argument into a type and name. -# -# Arguments: -# arg The argument to parse. -# -# Results: -# Returns a list of type and name with an optional third array -# indicator. If the argument is malformed, returns "". - -proc genStubs::parseArg {arg} { - if {![regexp {^(.+[ ][*]*)([^][ *]+)(\[\])?$} $arg all type name array]} { - if {$arg eq "void"} { - return $arg - } else { - return - } - } - set result [list [string trim $type] $name] - if {$array ne ""} { - lappend result $array - } - return $result -} - -# genStubs::makeDecl -- -# -# Generate the prototype for a function. -# -# Arguments: -# name The interface name. -# decl The function declaration. -# index The slot index for this function. -# -# Results: -# Returns the formatted declaration string. - -proc genStubs::makeDecl {name decl index} { - variable scspec - lassign $decl rtype fname args - - append text "/* $index */\n" - set line "$scspec $rtype" - set count [expr {2 - ([string length $line] / 8)}] - append line [string range "\t\t\t" 0 $count] - set pad [expr {24 - [string length $line]}] - if {$pad <= 0} { - append line " " - set pad 0 - } - if {$args eq ""} { - append line $fname - append text $line - append text ";\n" - return $text - } - append line $fname - - set arg1 [lindex $args 0] - switch -exact $arg1 { - void { - append line "(void)" - } - TCL_VARARGS { - set sep "(" - foreach arg [lrange $args 1 end] { - append line $sep - set next {} - append next [lindex $arg 0] - if {[string index $next end] ne "*"} { - append next " " - } - append next [lindex $arg 1] [lindex $arg 2] - if {[string length $line] + [string length $next] \ - + $pad > 76} { - append text [string trimright $line] \n - set line "\t\t\t\t" - set pad 28 - } - append line $next - set sep ", " - } - append line ", ...)" - } - default { - set sep "(" - foreach arg $args { - append line $sep - set next {} - append next [lindex $arg 0] - if {[string index $next end] ne "*"} { - append next " " - } - append next [lindex $arg 1] [lindex $arg 2] - if {[string length $line] + [string length $next] \ - + $pad > 76} { - append text [string trimright $line] \n - set line "\t\t\t\t" - set pad 28 - } - append line $next - set sep ", " - } - append line ")" - } - } - return "$text$line;\n" -} - -# genStubs::makeMacro -- -# -# Generate the inline macro for a function. -# -# Arguments: -# name The interface name. -# decl The function declaration. -# index The slot index for this function. -# -# Results: -# Returns the formatted macro definition. - -proc genStubs::makeMacro {name decl index} { - lassign $decl rtype fname args - - set lfname [string tolower [string index $fname 0]] - append lfname [string range $fname 1 end] - - set text "#define $fname \\\n\t(" - if {$args eq ""} { - append text "*" - } - append text "${name}StubsPtr->$lfname)" - append text " /* $index */\n" - return $text -} - -# genStubs::makeSlot -- -# -# Generate the stub table entry for a function. -# -# Arguments: -# name The interface name. -# decl The function declaration. -# index The slot index for this function. -# -# Results: -# Returns the formatted table entry. - -proc genStubs::makeSlot {name decl index} { - lassign $decl rtype fname args - - set lfname [string tolower [string index $fname 0]] - append lfname [string range $fname 1 end] - - set text " " - if {$args eq ""} { - append text $rtype " *" $lfname "; /* $index */\n" - return $text - } - if {[string range $rtype end-8 end] eq "__stdcall"} { - append text [string trim [string range $rtype 0 end-9]] " (__stdcall *" $lfname ") " - } else { - append text $rtype " (*" $lfname ") " - } - set arg1 [lindex $args 0] - switch -exact $arg1 { - void { - append text "(void)" - } - TCL_VARARGS { - set sep "(" - foreach arg [lrange $args 1 end] { - append text $sep [lindex $arg 0] - if {[string index $text end] ne "*"} { - append text " " - } - append text [lindex $arg 1] [lindex $arg 2] - set sep ", " - } - append text ", ...)" - } - default { - set sep "(" - foreach arg $args { - append text $sep [lindex $arg 0] - if {[string index $text end] ne "*"} { - append text " " - } - append text [lindex $arg 1] [lindex $arg 2] - set sep ", " - } - append text ")" - } - } - - append text "; /* $index */\n" - return $text -} - -# genStubs::makeInit -- -# -# Generate the prototype for a function. -# -# Arguments: -# name The interface name. -# decl The function declaration. -# index The slot index for this function. -# -# Results: -# Returns the formatted declaration string. - -proc genStubs::makeInit {name decl index} { - if {[lindex $decl 2] eq ""} { - append text " &" [lindex $decl 1] ", /* " $index " */\n" - } else { - append text " " [lindex $decl 1] ", /* " $index " */\n" - } - return $text -} - -# genStubs::forAllStubs -- -# -# This function iterates over all of the slots and invokes -# a callback for each slot. The result of the callback is then -# placed inside appropriate guards. -# -# Arguments: -# name The interface name. -# slotProc The proc to invoke to handle the slot. It will -# have the interface name, the declaration, and -# the index appended. -# guardProc The proc to invoke to add guards. It will have -# the slot status and text appended. -# textVar The variable to use for output. -# skipString The string to emit if a slot is skipped. This -# string will be subst'ed in the loop so "$i" can -# be used to substitute the index value. -# -# Results: -# None. - -proc genStubs::forAllStubs {name slotProc guardProc textVar - {skipString {"/* Slot $i is reserved */\n"}}} { - variable stubs - upvar $textVar text - - set lastNum $stubs($name,lastNum) - - for {set i 0} {$i <= $lastNum} {incr i} { - if {[info exists stubs($name,decl,$i)]} { - append text [$guardProc $stubs($name,status,$i) \ - [$slotProc $name $stubs($name,decl,$i) $i]] - } else { - eval {append text} $skipString - } - } -} - -proc genStubs::noGuard {status text} { return $text } - -proc genStubs::addGuard {status text} { - variable libraryName - set upName [string toupper $libraryName] - - switch -- $status { - current { - # No change - } - deprecated { - set text [ifdeffed "${upName}_DEPRECATED" $text] - } - obsolete { - set text "" - } - default { - puts stderr "Unrecognized status code $status" - } - } - return $text -} - -proc genStubs::ifdeffed {macro text} { - join [list "#ifdef $macro" $text "#endif" ""] \n -} - -# genStubs::emitDeclarations -- -# -# This function emits the function declarations for this interface. -# -# Arguments: -# name The interface name. -# textVar The variable to use for output. -# -# Results: -# None. - -proc genStubs::emitDeclarations {name textVar} { - upvar $textVar text - - append text "\n/*\n * Exported function declarations:\n */\n\n" - forAllStubs $name makeDecl noGuard text - return -} - -# genStubs::emitMacros -- -# -# This function emits the inline macros for an interface. -# -# Arguments: -# name The name of the interface being emitted. -# textVar The variable to use for output. -# -# Results: -# None. - -proc genStubs::emitMacros {name textVar} { - variable libraryName - upvar $textVar text - - set upName [string toupper $libraryName] - append text "\n#if defined(USE_${upName}_STUBS)\n" - append text "\n/*\n * Inline function declarations:\n */\n\n" - - forAllStubs $name makeMacro addGuard text - - append text "\n#endif /* defined(USE_${upName}_STUBS) */\n" - return -} - -# genStubs::emitHeader -- -# -# This function emits the body of the Decls.h file for -# the specified interface. -# -# Arguments: -# name The name of the interface being emitted. -# -# Results: -# None. - -proc genStubs::emitHeader {name} { - variable outDir - variable hooks - variable epoch - variable revision - - set capName [string toupper [string index $name 0]] - append capName [string range $name 1 end] - - if {$epoch ne ""} { - set CAPName [string toupper $name] - append text "\n" - append text "#define ${CAPName}_STUBS_EPOCH $epoch\n" - append text "#define ${CAPName}_STUBS_REVISION $revision\n" - } - - append text "\n#ifdef __cplusplus\nextern \"C\" {\n#endif\n" - - emitDeclarations $name text - - if {[info exists hooks($name)]} { - append text "\ntypedef struct {\n" - foreach hook $hooks($name) { - set capHook [string toupper [string index $hook 0]] - append capHook [string range $hook 1 end] - append text " const struct ${capHook}Stubs *${hook}Stubs;\n" - } - append text "} ${capName}StubHooks;\n" - } - append text "\ntypedef struct ${capName}Stubs {\n" - append text " int magic;\n" - if {$epoch ne ""} { - append text " int epoch;\n" - append text " int revision;\n" - } - if {[info exists hooks($name)]} { - append text " const ${capName}StubHooks *hooks;\n\n" - } else { - append text " void *hooks;\n\n" - } - - emitSlots $name text - - append text "} ${capName}Stubs;\n\n" - - append text "extern const ${capName}Stubs *${name}StubsPtr;\n\n" - append text "#ifdef __cplusplus\n}\n#endif\n" - - emitMacros $name text - - rewriteFile [file join $outDir ${name}Decls.h] $text - return -} - -# genStubs::emitInit -- -# -# Generate the table initializers for an interface. -# -# Arguments: -# name The name of the interface to initialize. -# textVar The variable to use for output. -# -# Results: -# Returns the formatted output. - -proc genStubs::emitInit {name textVar} { - variable hooks - variable interfaces - variable epoch - upvar $textVar text - set root 1 - - set capName [string toupper [string index $name 0]] - append capName [string range $name 1 end] - - if {[info exists hooks($name)]} { - append text "\nstatic const ${capName}StubHooks ${name}StubHooks = \{\n" - set sep " " - foreach sub $hooks($name) { - append text $sep "&${sub}Stubs" - set sep ",\n " - } - append text "\n\};\n" - } - foreach intf [array names interfaces] { - if {[info exists hooks($intf)]} { - if {[lsearch -exact $hooks($intf) $name] >= 0} { - set root 0 - break - } - } - } - - append text "\n" - if {!$root} { - append text "static " - } - append text "const ${capName}Stubs ${name}Stubs = \{\n TCL_STUB_MAGIC,\n" - if {$epoch ne ""} { - set CAPName [string toupper $name] - append text " ${CAPName}_STUBS_EPOCH,\n" - append text " ${CAPName}_STUBS_REVISION,\n" - } - if {[info exists hooks($name)]} { - append text " &${name}StubHooks,\n" - } else { - append text " 0,\n" - } - - forAllStubs $name makeInit noGuard text {" 0, /* $i */\n"} - - append text "\};\n" - return -} - -# genStubs::emitInits -- -# -# This function emits the body of the StubInit.c file for -# the specified interface. -# -# Arguments: -# name The name of the interface being emitted. -# -# Results: -# None. - -proc genStubs::emitInits {} { - variable hooks - variable outDir - variable libraryName - variable interfaces - - # Assuming that dependencies only go one level deep, we need to emit - # all of the leaves first to avoid needing forward declarations. - - set leaves {} - set roots {} - foreach name [lsort [array names interfaces]] { - if {[info exists hooks($name)]} { - lappend roots $name - } else { - lappend leaves $name - } - } - foreach name $leaves { - emitInit $name text - } - foreach name $roots { - emitInit $name text - } - - rewriteFile [file join $outDir ${libraryName}StubInit.c] $text -} - -# genStubs::init -- -# -# This is the main entry point. -# -# Arguments: -# None. -# -# Results: -# None. - -proc genStubs::init {} { - global argv argv0 - variable outDir - variable interfaces - - if {[llength $argv] < 2} { - puts stderr "usage: $argv0 outDir declFile ?declFile...?" - exit 1 - } - - set outDir [lindex $argv 0] - - foreach file [lrange $argv 1 end] { - source $file - } - - foreach name [lsort [array names interfaces]] { - puts "Emitting $name" - emitHeader $name - } - - emitInits -} - -# lassign -- -# -# This function emulates the TclX lassign command. -# -# Arguments: -# valueList A list containing the values to be assigned. -# args The list of variables to be assigned. -# -# Results: -# Returns any values that were not assigned to variables. - -if {[string length [namespace which lassign]] == 0} { - proc lassign {valueList args} { - if {[llength $args] == 0} { - error "wrong # args: should be \"lassign list varName ?varName ...?\"" - } - uplevel [list foreach $args $valueList {break}] - return [lrange $valueList [llength $args] end] - } -} - -genStubs::init diff --git a/unix/Makefile.in b/unix/Makefile.in index a4bc2d4..8e6433a 100644 --- a/unix/Makefile.in +++ b/unix/Makefile.in @@ -1465,7 +1465,7 @@ $(TTK_DIR)/ttkStubInit.c: $(TTK_DIR)/ttk.decls genstubs: $(TCL_EXE) $(TOOL_DIR)/genStubs.tcl $(GENERIC_DIR) \ $(GENERIC_DIR)/tk.decls $(GENERIC_DIR)/tkInt.decls - $(TCL_EXE) $(TTK_DIR)/ttkGenStubs.tcl $(TTK_DIR) $(TTK_DIR)/ttk.decls + $(TCL_EXE) $(TOOL_DIR)/genStubs.tcl $(TTK_DIR) $(TTK_DIR)/ttk.decls # # Target to check that all exported functions have an entry in the stubs diff --git a/win/Makefile.in b/win/Makefile.in index 7e48213..0b1acd7 100644 --- a/win/Makefile.in +++ b/win/Makefile.in @@ -730,7 +730,7 @@ genstubs: "$(GENERIC_DIR_NATIVE)" \ "$(GENERIC_DIR_NATIVE)/tk.decls" \ "$(GENERIC_DIR_NATIVE)/tkInt.decls" - $(TCL_EXE) "$(TTK_DIR)/ttkGenStubs.tcl" \ + $(TCL_EXE) "$(TCL_TOOL_DIR)/genStubs.tcl" \ "$(TTK_DIR)" \ "$(TTK_DIR)/ttk.decls" -- cgit v0.12 From b8a68d0c335e5b303b12e9fd8194e27be780a219 Mon Sep 17 00:00:00 2001 From: "jan.nijtmans" Date: Fri, 20 Jan 2017 14:37:27 +0000 Subject: Smarter initialization of doubleTypePtr/intTypePtr without hash-table lookup or creating complete Tcl_Obj's. In Windows tests, allow up to 64 bits for HWND. Check stubs for "8.6-" in stead of "8.6", for better interoperability with "novem". --- generic/tkConsole.c | 2 +- generic/tkIntXlibDecls.h | 4 ++++ generic/tkMain.c | 2 +- generic/tkObj.c | 15 +++++++++++++-- generic/tkTest.c | 2 +- generic/tkWindow.c | 2 +- win/tkWinTest.c | 18 +++++++++--------- 7 files changed, 30 insertions(+), 15 deletions(-) diff --git a/generic/tkConsole.c b/generic/tkConsole.c index fc60d5f..57e8364 100644 --- a/generic/tkConsole.c +++ b/generic/tkConsole.c @@ -223,7 +223,7 @@ Tk_InitConsoleChannels( * Ensure that we are getting a compatible version of Tcl. */ - if (Tcl_InitStubs(interp, "8.6", 0) == NULL) { + if (Tcl_InitStubs(interp, "8.6-", 0) == NULL) { return; } diff --git a/generic/tkIntXlibDecls.h b/generic/tkIntXlibDecls.h index de44068..ce9752f 100644 --- a/generic/tkIntXlibDecls.h +++ b/generic/tkIntXlibDecls.h @@ -23,6 +23,10 @@ # include #endif +#ifndef EXTERN +# define EXTERN extern TCL_STORAGE_CLASS +#endif + /* Some (older) versions of X11/Xutil.h have a wrong signature of those two functions, so move them out of the way temporarly. */ #define XOffsetRegion _XOffsetRegion diff --git a/generic/tkMain.c b/generic/tkMain.c index 1b21223..87a3cf7 100644 --- a/generic/tkMain.c +++ b/generic/tkMain.c @@ -196,7 +196,7 @@ Tk_MainEx( * Ensure that we are getting a compatible version of Tcl. */ - if (Tcl_InitStubs(interp, "8.6", 0) == NULL) { + if (Tcl_InitStubs(interp, "8.6-", 0) == NULL) { if (Tcl_InitStubs(interp, "8.1", 0) == NULL) { abort(); } else { diff --git a/generic/tkObj.c b/generic/tkObj.c index 7c09656..90fedbc 100644 --- a/generic/tkObj.c +++ b/generic/tkObj.c @@ -153,8 +153,19 @@ GetTypeCache(void) Tcl_GetThreadData(&dataKey, sizeof(ThreadSpecificData)); if (tsdPtr->doubleTypePtr == NULL) { - tsdPtr->doubleTypePtr = Tcl_GetObjType("double"); - tsdPtr->intTypePtr = Tcl_GetObjType("int"); + /* Smart initialization of doubleTypePtr/intTypePtr without + * hash-table lookup or creating complete Tcl_Obj's */ + Tcl_Obj obj; + obj.length = 3; + obj.bytes = (char *)"0.0"; + obj.typePtr = NULL; + Tcl_GetDoubleFromObj(NULL, &obj, &obj.internalRep.doubleValue); + tsdPtr->doubleTypePtr = obj.typePtr; + obj.bytes += 2; + obj.length = 1; + obj.typePtr = NULL; + Tcl_GetLongFromObj(NULL, &obj, &obj.internalRep.longValue); + tsdPtr->intTypePtr = obj.typePtr; } return tsdPtr; } diff --git a/generic/tkTest.c b/generic/tkTest.c index faba89d..e23be36 100644 --- a/generic/tkTest.c +++ b/generic/tkTest.c @@ -227,7 +227,7 @@ Tktest_Init( { static int initialized = 0; - if (Tcl_InitStubs(interp, "8.6", 0) == NULL) { + if (Tcl_InitStubs(interp, "8.6-", 0) == NULL) { return TCL_ERROR; } if (Tk_InitStubs(interp, TK_VERSION, 0) == NULL) { diff --git a/generic/tkWindow.c b/generic/tkWindow.c index 20b4f20..f02db35 100644 --- a/generic/tkWindow.c +++ b/generic/tkWindow.c @@ -3040,7 +3040,7 @@ Initialize( * Ensure that we are getting a compatible version of Tcl. */ - if (Tcl_InitStubs(interp, "8.6", 0) == NULL) { + if (Tcl_InitStubs(interp, "8.6-", 0) == NULL) { return TCL_ERROR; } diff --git a/win/tkWinTest.c b/win/tkWinTest.c index d824ee4..095358d 100644 --- a/win/tkWinTest.c +++ b/win/tkWinTest.c @@ -483,7 +483,7 @@ TestfindwindowObjCmd( AppendSystemError(interp, GetLastError()); r = TCL_ERROR; } else { - Tcl_SetObjResult(interp, Tcl_NewLongObj(PTR2INT(hwnd))); + Tcl_SetObjResult(interp, Tcl_NewWideIntObj((size_t)hwnd)); } Tcl_DStringFree(&titleString); @@ -499,7 +499,7 @@ EnumChildrenProc( { Tcl_Obj *listObj = (Tcl_Obj *) lParam; - Tcl_ListObjAppendElement(NULL, listObj, Tcl_NewLongObj(PTR2INT(hwnd))); + Tcl_ListObjAppendElement(NULL, listObj, Tcl_NewWideIntObj((size_t)hwnd)); return TRUE; } @@ -510,7 +510,7 @@ TestgetwindowinfoObjCmd( int objc, Tcl_Obj *const objv[]) { - long hwnd; + Tcl_WideInt hwnd; Tcl_Obj *dictObj = NULL, *classObj = NULL, *textObj = NULL; Tcl_Obj *childrenObj = NULL; TCHAR buf[512]; @@ -521,10 +521,10 @@ TestgetwindowinfoObjCmd( return TCL_ERROR; } - if (Tcl_GetLongFromObj(interp, objv[1], &hwnd) != TCL_OK) + if (Tcl_GetWideIntFromObj(interp, objv[1], &hwnd) != TCL_OK) return TCL_ERROR; - cch = GetClassName(INT2PTR(hwnd), buf, cchBuf); + cch = GetClassName((HWND)(size_t)hwnd, buf, cchBuf); if (cch == 0) { Tcl_SetObjResult(interp, Tcl_NewStringObj("failed to get class name: ", -1)); AppendSystemError(interp, GetLastError()); @@ -539,17 +539,17 @@ TestgetwindowinfoObjCmd( dictObj = Tcl_NewDictObj(); Tcl_DictObjPut(interp, dictObj, Tcl_NewStringObj("class", 5), classObj); Tcl_DictObjPut(interp, dictObj, Tcl_NewStringObj("id", 2), - Tcl_NewLongObj(GetWindowLongA(INT2PTR(hwnd), GWL_ID))); + Tcl_NewWideIntObj(GetWindowLongPtr((HWND)(size_t)hwnd, GWL_ID))); - cch = GetWindowText(INT2PTR(hwnd), (LPTSTR)buf, cchBuf); + cch = GetWindowText((HWND)(size_t)hwnd, (LPTSTR)buf, cchBuf); textObj = Tcl_NewUnicodeObj((LPCWSTR)buf, cch); Tcl_DictObjPut(interp, dictObj, Tcl_NewStringObj("text", 4), textObj); Tcl_DictObjPut(interp, dictObj, Tcl_NewStringObj("parent", 6), - Tcl_NewLongObj(PTR2INT(GetParent((INT2PTR(hwnd)))))); + Tcl_NewWideIntObj((size_t)(GetParent((HWND)(size_t)hwnd)))); childrenObj = Tcl_NewListObj(0, NULL); - EnumChildWindows(INT2PTR(hwnd), EnumChildrenProc, (LPARAM)childrenObj); + EnumChildWindows((HWND)(size_t)hwnd, EnumChildrenProc, (LPARAM)childrenObj); Tcl_DictObjPut(interp, dictObj, Tcl_NewStringObj("children", -1), childrenObj); Tcl_SetObjResult(interp, dictObj); -- cgit v0.12 From e926662190cc08e5f057d0d90cdf9da4a1aab15f Mon Sep 17 00:00:00 2001 From: "jan.nijtmans" Date: Fri, 20 Jan 2017 14:39:30 +0000 Subject: Compile with -Wwrite-strings, as does Tcl. In pkgIndex files, allow "8.6-" to match, for better interoperability with "novem" --- unix/Makefile.in | 2 +- unix/configure | 2 +- unix/tcl.m4 | 2 +- win/Makefile.in | 2 +- win/configure | 2 +- win/makefile.vc | 2 +- win/tcl.m4 | 2 +- 7 files changed, 7 insertions(+), 7 deletions(-) diff --git a/unix/Makefile.in b/unix/Makefile.in index 8e6433a..1b8677e 100644 --- a/unix/Makefile.in +++ b/unix/Makefile.in @@ -723,7 +723,7 @@ install-binaries: $(TK_STUB_LIB_FILE) $(TK_LIB_FILE) ${WISH_EXE} echo "Creating package index $(PKG_INDEX)"; \ rm -f "$(PKG_INDEX)"; \ (\ - echo "if {[catch {package present Tcl 8.6.0}]} return";\ + echo "if {[catch {package present Tcl 8.6-}]} return";\ relative=`echo | awk '{ORS=" "; split("$(TK_PKG_DIR)",a,"/"); for (f in a) {print ".."}}'`;\ if test "x$(DLL_INSTALL_DIR)" != "x$(BIN_INSTALL_DIR)"; then \ echo "package ifneeded Tk $(MAJOR_VERSION).$(MINOR_VERSION)$(PATCH_LEVEL) [list load [file normalize [file join \$$dir $${relative}$(TK_LIB_FILE)]] Tk]";\ diff --git a/unix/configure b/unix/configure index 1ed0275..f76ae3b 100755 --- a/unix/configure +++ b/unix/configure @@ -4595,7 +4595,7 @@ fi if test "$GCC" = yes; then : CFLAGS_OPTIMIZE=-O2 - CFLAGS_WARNING="-Wall -Wsign-compare -Wdeclaration-after-statement" + CFLAGS_WARNING="-Wall -Wwrite-strings -Wsign-compare -Wdeclaration-after-statement" else diff --git a/unix/tcl.m4 b/unix/tcl.m4 index a1d4021..2ab432c 100644 --- a/unix/tcl.m4 +++ b/unix/tcl.m4 @@ -1096,7 +1096,7 @@ AC_DEFUN([SC_CONFIG_CFLAGS], [ CFLAGS_DEBUG=-g AS_IF([test "$GCC" = yes], [ CFLAGS_OPTIMIZE=-O2 - CFLAGS_WARNING="-Wall -Wsign-compare -Wdeclaration-after-statement" + CFLAGS_WARNING="-Wall -Wwrite-strings -Wsign-compare -Wdeclaration-after-statement" ], [ CFLAGS_OPTIMIZE=-O CFLAGS_WARNING="" diff --git a/win/Makefile.in b/win/Makefile.in index 0b1acd7..80d616b 100644 --- a/win/Makefile.in +++ b/win/Makefile.in @@ -487,7 +487,7 @@ install-binaries: binaries @echo "Creating package index $(PKG_INDEX)"; @$(RM) $(PKG_INDEX); @(\ - echo "if {[catch {package present Tcl 8.6.0}]} return";\ + echo "if {[catch {package present Tcl 8.6-}]} 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 libtk$(VERSION).dll]] Tk]";\ diff --git a/win/configure b/win/configure index 0b80f22..0149709 100755 --- a/win/configure +++ b/win/configure @@ -4335,7 +4335,7 @@ $as_echo "using shared flags" >&6; } CFLAGS_DEBUG=-g CFLAGS_OPTIMIZE="-O2 -fomit-frame-pointer" - CFLAGS_WARNING="-Wall -Wsign-compare -Wdeclaration-after-statement" + CFLAGS_WARNING="-Wall -Wwrite-strings -Wsign-compare -Wdeclaration-after-statement" LDFLAGS_DEBUG= LDFLAGS_OPTIMIZE= diff --git a/win/makefile.vc b/win/makefile.vc index 6f61327..c8c42a2 100644 --- a/win/makefile.vc +++ b/win/makefile.vc @@ -961,7 +961,7 @@ install-binaries: !if !$(STATIC_BUILD) @echo creating package index @type << > $(OUT_DIR)\pkgIndex.tcl -if {[catch {package present Tcl 8.6.0}]} { return } +if {[catch {package present Tcl 8.6-}]} { 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 join $$dir .. .. bin libtk$(TK_DOTVERSION).dll] Tk] diff --git a/win/tcl.m4 b/win/tcl.m4 index d1fb11c..4d28744 100644 --- a/win/tcl.m4 +++ b/win/tcl.m4 @@ -727,7 +727,7 @@ AC_DEFUN([SC_CONFIG_CFLAGS], [ CFLAGS_DEBUG=-g CFLAGS_OPTIMIZE="-O2 -fomit-frame-pointer" - CFLAGS_WARNING="-Wall -Wsign-compare -Wdeclaration-after-statement" + CFLAGS_WARNING="-Wall -Wwrite-strings -Wsign-compare -Wdeclaration-after-statement" LDFLAGS_DEBUG= LDFLAGS_OPTIMIZE= -- cgit v0.12 From e0911ec4c26de1730f2f00b8d32a5e1980211dea Mon Sep 17 00:00:00 2001 From: "jan.nijtmans" Date: Mon, 23 Jan 2017 14:46:22 +0000 Subject: If Tk is compiled with -DTK_NO_DEPRECATED=1, remove some deprecated code (pack subcommands) and other stuff which is not used any more. And fix a few typos. Remove rmd.bat and rmd.bat, which are also not used any more. --- .fossil-settings/crlf-glob | 2 -- .fossil-settings/crnl-glob | 2 -- .fossil-settings/encoding-glob | 2 -- changes | 2 +- generic/tk.h | 3 ++- generic/tkIntXlibDecls.h | 8 ++++++-- generic/tkPack.c | 15 ++++++++++++++- generic/tkPanedWindow.c | 22 +++++++++++----------- macosx/Tk.xcode/project.pbxproj | 3 --- macosx/Tk.xcodeproj/project.pbxproj | 4 ---- win/mkd.bat | 12 ------------ win/rmd.bat | 20 -------------------- win/rules.vc | 20 ++++++-------------- 13 files changed, 40 insertions(+), 75 deletions(-) delete mode 100644 win/mkd.bat delete mode 100644 win/rmd.bat diff --git a/.fossil-settings/crlf-glob b/.fossil-settings/crlf-glob index 7175730..ad7795f 100644 --- a/.fossil-settings/crlf-glob +++ b/.fossil-settings/crlf-glob @@ -1,6 +1,4 @@ win/buildall.vc.bat win/makefile.bc win/makefile.vc -win/mkd.bat -win/rmd.bat win/rules.vc diff --git a/.fossil-settings/crnl-glob b/.fossil-settings/crnl-glob index 7175730..ad7795f 100644 --- a/.fossil-settings/crnl-glob +++ b/.fossil-settings/crnl-glob @@ -1,6 +1,4 @@ win/buildall.vc.bat win/makefile.bc win/makefile.vc -win/mkd.bat -win/rmd.bat win/rules.vc diff --git a/.fossil-settings/encoding-glob b/.fossil-settings/encoding-glob index 7175730..ad7795f 100644 --- a/.fossil-settings/encoding-glob +++ b/.fossil-settings/encoding-glob @@ -1,6 +1,4 @@ win/buildall.vc.bat win/makefile.bc win/makefile.vc -win/mkd.bat -win/rmd.bat win/rules.vc diff --git a/changes b/changes index bf3e62e..3f1b43d 100644 --- a/changes +++ b/changes @@ -1315,7 +1315,7 @@ ISO Latin-1 character set. result across the execution of binding scripts. Otherwise if an event triggers in the middle of some other script (e.g. a destroy event during window creation, because there was an error in the creation command), -the intepreter's result gets lost. +the interpreter's result gets lost. 2/19/94 (bug fix) Fixed bug in dealing with results of sent command that could cause them to get lost in some situations. diff --git a/generic/tk.h b/generic/tk.h index 658b11e..a0fbba9 100644 --- a/generic/tk.h +++ b/generic/tk.h @@ -748,9 +748,10 @@ typedef XActivateDeactivateEvent XDeactivateEvent; (((Tk_FakeWin *) (tkwin))->flags & TK_WM_MANAGEABLE) #define Tk_ReqWidth(tkwin) (((Tk_FakeWin *) (tkwin))->reqWidth) #define Tk_ReqHeight(tkwin) (((Tk_FakeWin *) (tkwin))->reqHeight) -/* Tk_InternalBorderWidth is deprecated */ +#ifndef TK_NO_DEPRECATED #define Tk_InternalBorderWidth(tkwin) \ (((Tk_FakeWin *) (tkwin))->internalBorderLeft) +#endif /* !TK_NO_DEPRECATED */ #define Tk_InternalBorderLeft(tkwin) \ (((Tk_FakeWin *) (tkwin))->internalBorderLeft) #define Tk_InternalBorderRight(tkwin) \ diff --git a/generic/tkIntXlibDecls.h b/generic/tkIntXlibDecls.h index ce9752f..67b7c39 100644 --- a/generic/tkIntXlibDecls.h +++ b/generic/tkIntXlibDecls.h @@ -36,8 +36,12 @@ #undef XUnionRegion #ifdef BUILD_tk -#undef TCL_STORAGE_CLASS -#define TCL_STORAGE_CLASS DLLEXPORT +# undef TCL_STORAGE_CLASS +# define TCL_STORAGE_CLASS DLLEXPORT +#else +# ifndef TCL_STORAGE_CLASS +# define TCL_STORAGE_CLASS DLLIMPORT +# endif #endif typedef int (*XAfterFunction) ( /* WARNING, this type not in Xlib spec */ diff --git a/generic/tkPack.c b/generic/tkPack.c index 88a4b2d..8257b43 100644 --- a/generic/tkPack.c +++ b/generic/tkPack.c @@ -122,8 +122,10 @@ static int ConfigureSlaves(Tcl_Interp *interp, Tk_Window tkwin, int objc, Tcl_Obj *const objv[]); static void DestroyPacker(void *memPtr); static Packer * GetPacker(Tk_Window tkwin); +#ifndef TK_NO_DEPRECATED static int PackAfter(Tcl_Interp *interp, Packer *prevPtr, Packer *masterPtr, int objc,Tcl_Obj *const objv[]); +#endif /* !TK_NO_DEPRECATED */ static void PackStructureProc(ClientData clientData, XEvent *eventPtr); static void Unlink(Packer *packPtr); @@ -197,11 +199,14 @@ Tk_PackObjCmd( Tk_Window tkwin = clientData; const char *argv2; static const char *const optionStrings[] = { - /* after, append, before and unpack are deprecated */ +#ifndef TK_NO_DEPRECATED "after", "append", "before", "unpack", +#endif /* !TK_NO_DEPRECATED */ "configure", "forget", "info", "propagate", "slaves", NULL }; enum options { +#ifndef TK_NO_DEPRECATED PACK_AFTER, PACK_APPEND, PACK_BEFORE, PACK_UNPACK, +#endif /* !TK_NO_DEPRECATED */ PACK_CONFIGURE, PACK_FORGET, PACK_INFO, PACK_PROPAGATE, PACK_SLAVES }; int index; @@ -219,6 +224,7 @@ Tk_PackObjCmd( if (Tcl_GetIndexFromObjStruct(interp, objv[1], optionStrings, sizeof(char *), "option", 0, &index) != TCL_OK) { +#ifndef TK_NO_DEPRECATED /* * Call it again without the deprecated ones to get a proper error * message. This works well since there can't be any ambiguity between @@ -228,11 +234,13 @@ Tk_PackObjCmd( Tcl_ResetResult(interp); Tcl_GetIndexFromObjStruct(interp, objv[1], &optionStrings[4], sizeof(char *), "option", 0, &index); +#endif /* TK_NO_DEPRECATED */ return TCL_ERROR; } argv2 = Tcl_GetString(objv[2]); switch ((enum options) index) { +#ifndef TK_NO_DEPRECATED case PACK_AFTER: { Packer *prevPtr; Tk_Window tkwin2; @@ -297,6 +305,7 @@ Tk_PackObjCmd( } return PackAfter(interp, prevPtr, masterPtr, objc-3, objv+3); } +#endif /* !TK_NO_DEPRECATED */ case PACK_CONFIGURE: if (argv2[0] != '.') { Tcl_SetObjResult(interp, Tcl_ObjPrintf( @@ -458,6 +467,7 @@ Tk_PackObjCmd( Tcl_SetObjResult(interp, resultObj); break; } +#ifndef TK_NO_DEPRECATED case PACK_UNPACK: { Tk_Window tkwin2; Packer *packPtr; @@ -481,6 +491,7 @@ Tk_PackObjCmd( } break; } +#endif /* !TK_NO_DEPRECATED */ } return TCL_OK; @@ -1087,6 +1098,7 @@ GetPacker( *------------------------------------------------------------------------ */ +#ifndef TK_NO_DEPRECATED static int PackAfter( Tcl_Interp *interp, /* Interpreter for error reporting. */ @@ -1307,6 +1319,7 @@ PackAfter( } return TCL_OK; } +#endif /* !TK_NO_DEPRECATED */ /* *---------------------------------------------------------------------- diff --git a/generic/tkPanedWindow.c b/generic/tkPanedWindow.c index f350d0a..4bfc695 100644 --- a/generic/tkPanedWindow.c +++ b/generic/tkPanedWindow.c @@ -1484,10 +1484,10 @@ DisplayPanedWindow( */ if (horizontal) { - sashHeight = Tk_Height(tkwin) - (2 * Tk_InternalBorderWidth(tkwin)); + sashHeight = Tk_Height(tkwin) - (2 * Tk_InternalBorderLeft(tkwin)); sashWidth = pwPtr->sashWidth; } else { - sashWidth = Tk_Width(tkwin) - (2 * Tk_InternalBorderWidth(tkwin)); + sashWidth = Tk_Width(tkwin) - (2 * Tk_InternalBorderLeft(tkwin)); sashHeight = pwPtr->sashWidth; } @@ -1754,7 +1754,7 @@ ArrangePanes( */ paneDynSize = paneDynMinSize = 0; - internalBW = Tk_InternalBorderWidth(pwPtr->tkwin); + internalBW = Tk_InternalBorderLeft(pwPtr->tkwin); pwHeight = Tk_Height(pwPtr->tkwin) - (2 * internalBW); pwWidth = Tk_Width(pwPtr->tkwin) - (2 * internalBW); x = y = internalBW; @@ -2184,7 +2184,7 @@ ComputeGeometry( pwPtr->flags |= REQUESTED_RELAYOUT; - x = y = internalBw = Tk_InternalBorderWidth(pwPtr->tkwin); + x = y = internalBw = Tk_InternalBorderLeft(pwPtr->tkwin); reqWidth = reqHeight = 0; /* @@ -2890,7 +2890,7 @@ PanedWindowProxyCommand( return TCL_ERROR; } - internalBW = Tk_InternalBorderWidth(pwPtr->tkwin); + internalBW = Tk_InternalBorderLeft(pwPtr->tkwin); if (pwPtr->orient == ORIENT_HORIZONTAL) { if (x < 0) { x = 0; @@ -2899,10 +2899,10 @@ PanedWindowProxyCommand( if (x > pwWidth) { x = pwWidth; } - y = Tk_InternalBorderWidth(pwPtr->tkwin); + y = Tk_InternalBorderLeft(pwPtr->tkwin); sashWidth = pwPtr->sashWidth; sashHeight = Tk_Height(pwPtr->tkwin) - - (2 * Tk_InternalBorderWidth(pwPtr->tkwin)); + (2 * Tk_InternalBorderLeft(pwPtr->tkwin)); } else { if (y < 0) { y = 0; @@ -2911,10 +2911,10 @@ PanedWindowProxyCommand( if (y > pwHeight) { y = pwHeight; } - x = Tk_InternalBorderWidth(pwPtr->tkwin); + x = Tk_InternalBorderLeft(pwPtr->tkwin); sashHeight = pwPtr->sashWidth; sashWidth = Tk_Width(pwPtr->tkwin) - - (2 * Tk_InternalBorderWidth(pwPtr->tkwin)); + (2 * Tk_InternalBorderLeft(pwPtr->tkwin)); } if (sashWidth < 1) { @@ -3053,7 +3053,7 @@ PanedWindowIdentifyCoords( } else { sashHeight = Tk_ReqHeight(pwPtr->tkwin); } - sashHeight -= 2 * Tk_InternalBorderWidth(pwPtr->tkwin); + sashHeight -= 2 * Tk_InternalBorderLeft(pwPtr->tkwin); if (pwPtr->showHandle && pwPtr->handleSize > pwPtr->sashWidth) { sashWidth = pwPtr->handleSize; lpad = (pwPtr->handleSize - pwPtr->sashWidth) / 2; @@ -3081,7 +3081,7 @@ PanedWindowIdentifyCoords( } else { sashWidth = Tk_ReqWidth(pwPtr->tkwin); } - sashWidth -= 2 * Tk_InternalBorderWidth(pwPtr->tkwin); + sashWidth -= 2 * Tk_InternalBorderLeft(pwPtr->tkwin); lpad = rpad = 0; } diff --git a/macosx/Tk.xcode/project.pbxproj b/macosx/Tk.xcode/project.pbxproj index eee37a2..f919a71 100644 --- a/macosx/Tk.xcode/project.pbxproj +++ b/macosx/Tk.xcode/project.pbxproj @@ -1215,13 +1215,11 @@ F966BC9808F27A3E005CB29B /* makefile.bc */ = {isa = PBXFileReference; explicitFileType = sourcecode.make; fileEncoding = 4; path = makefile.bc; sourceTree = ""; }; F966BC9908F27A3E005CB29B /* Makefile.in */ = {isa = PBXFileReference; explicitFileType = sourcecode.make; fileEncoding = 4; path = Makefile.in; sourceTree = ""; }; F966BC9A08F27A3E005CB29B /* makefile.vc */ = {isa = PBXFileReference; explicitFileType = sourcecode.make; fileEncoding = 4; path = makefile.vc; sourceTree = ""; }; - F966BC9B08F27A3E005CB29B /* mkd.bat */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = text; path = mkd.bat; sourceTree = ""; }; F966BC9C08F27A3E005CB29B /* nmakehlp.c */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.c; path = nmakehlp.c; sourceTree = ""; }; F966BCEE08F27A3E005CB29B /* tk.rc */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = text; path = tk.rc; sourceTree = ""; }; F966BCEF08F27A3E005CB29B /* tk_base.rc */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = text; path = tk_base.rc; sourceTree = ""; }; F966BCF208F27A3E005CB29B /* wish.rc */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = text; path = wish.rc; sourceTree = ""; }; F966BCF308F27A3E005CB29B /* README */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = text; path = README; sourceTree = ""; }; - F966BCF408F27A3E005CB29B /* rmd.bat */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = text; path = rmd.bat; sourceTree = ""; }; F966BCF508F27A3F005CB29B /* rules.vc */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = text; path = rules.vc; sourceTree = ""; }; F966BCF608F27A3F005CB29B /* stubs.c */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.c; path = stubs.c; sourceTree = ""; }; F966BCF708F27A3F005CB29B /* tcl.m4 */ = {isa = PBXFileReference; explicitFileType = text.script.sh; fileEncoding = 4; path = tcl.m4; sourceTree = ""; }; @@ -2794,7 +2792,6 @@ F966BC9808F27A3E005CB29B /* makefile.bc */, F966BC9908F27A3E005CB29B /* Makefile.in */, F966BC9A08F27A3E005CB29B /* makefile.vc */, - F966BC9B08F27A3E005CB29B /* mkd.bat */, F966BC9C08F27A3E005CB29B /* nmakehlp.c */, F966BC9D08F27A3E005CB29B /* rc */, F966BCF308F27A3E005CB29B /* README */, diff --git a/macosx/Tk.xcodeproj/project.pbxproj b/macosx/Tk.xcodeproj/project.pbxproj index 2f7edba..a873432 100644 --- a/macosx/Tk.xcodeproj/project.pbxproj +++ b/macosx/Tk.xcodeproj/project.pbxproj @@ -1215,13 +1215,11 @@ F966BC9808F27A3E005CB29B /* makefile.bc */ = {isa = PBXFileReference; explicitFileType = sourcecode.make; fileEncoding = 4; path = makefile.bc; sourceTree = ""; }; F966BC9908F27A3E005CB29B /* Makefile.in */ = {isa = PBXFileReference; explicitFileType = sourcecode.make; fileEncoding = 4; path = Makefile.in; sourceTree = ""; }; F966BC9A08F27A3E005CB29B /* makefile.vc */ = {isa = PBXFileReference; explicitFileType = sourcecode.make; fileEncoding = 4; path = makefile.vc; sourceTree = ""; }; - F966BC9B08F27A3E005CB29B /* mkd.bat */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = text; path = mkd.bat; sourceTree = ""; }; F966BC9C08F27A3E005CB29B /* nmakehlp.c */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.c; path = nmakehlp.c; sourceTree = ""; }; F966BCEE08F27A3E005CB29B /* tk.rc */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = text; path = tk.rc; sourceTree = ""; }; F966BCEF08F27A3E005CB29B /* tk_base.rc */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = text; path = tk_base.rc; sourceTree = ""; }; F966BCF208F27A3E005CB29B /* wish.rc */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = text; path = wish.rc; sourceTree = ""; }; F966BCF308F27A3E005CB29B /* README */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = text; path = README; sourceTree = ""; }; - F966BCF408F27A3E005CB29B /* rmd.bat */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = text; path = rmd.bat; sourceTree = ""; }; F966BCF508F27A3F005CB29B /* rules.vc */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = text; path = rules.vc; sourceTree = ""; }; F966BCF608F27A3F005CB29B /* stubs.c */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.c; path = stubs.c; sourceTree = ""; }; F966BCF708F27A3F005CB29B /* tcl.m4 */ = {isa = PBXFileReference; explicitFileType = text.script.sh; fileEncoding = 4; path = tcl.m4; sourceTree = ""; }; @@ -2794,11 +2792,9 @@ F966BC9808F27A3E005CB29B /* makefile.bc */, F966BC9908F27A3E005CB29B /* Makefile.in */, F966BC9A08F27A3E005CB29B /* makefile.vc */, - F966BC9B08F27A3E005CB29B /* mkd.bat */, F966BC9C08F27A3E005CB29B /* nmakehlp.c */, F966BC9D08F27A3E005CB29B /* rc */, F966BCF308F27A3E005CB29B /* README */, - F966BCF408F27A3E005CB29B /* rmd.bat */, F966BCF508F27A3F005CB29B /* rules.vc */, F966BCF608F27A3F005CB29B /* stubs.c */, F966BCF708F27A3F005CB29B /* tcl.m4 */, diff --git a/win/mkd.bat b/win/mkd.bat deleted file mode 100644 index 1bd5ccb..0000000 --- a/win/mkd.bat +++ /dev/null @@ -1,12 +0,0 @@ -@echo off - -if exist %1\nul goto end - -md %1 -if errorlevel 1 goto end - -echo Created directory %1 - -:end - - diff --git a/win/rmd.bat b/win/rmd.bat deleted file mode 100644 index 820b76f..0000000 --- a/win/rmd.bat +++ /dev/null @@ -1,20 +0,0 @@ -@echo off - -if not exist %1\nul goto end - -echo Removing directory %1 - -if "%OS%" == "Windows_NT" goto winnt - -deltree /y %1 -if errorlevel 1 goto end -goto success - -:winnt -rmdir /s /q %1 -if errorlevel 1 goto end - -:success -echo Deleted directory %1 - -:end diff --git a/win/rules.vc b/win/rules.vc index 2cd711b..fbbe705 100644 --- a/win/rules.vc +++ b/win/rules.vc @@ -33,7 +33,6 @@ _INSTALLDIR = $(INSTALLDIR:/=\) # "delete all" method. #---------------------------------------------------------- -!if "$(OS)" == "Windows_NT" RMDIR = rmdir /S /Q ERRNULL = 2>NUL !if ![ver | find "4.0" > nul] @@ -43,13 +42,6 @@ COPY = copy >NUL CPY = xcopy /i /y >NUL COPY = copy /y >NUL !endif -!else # "$(OS)" != "Windows_NT" -CPY = xcopy /i >_JUNK.OUT # On Win98 NUL does not work here. -COPY = copy >_JUNK.OUT # On Win98 NUL does not work here. -RMDIR = deltree /Y -NULL = \NUL # Used in testing directory existence -ERRNULL = >NUL # Win9x shell cannot redirect stderr -!endif MKDIR = mkdir #------------------------------------------------------------------------------ @@ -405,14 +397,14 @@ TCL_COMPILE_DEBUG = 0 #---------------------------------------------------------- !if "$(CHECKS)" == "" || [nmakehlp -f "$(CHECKS)" "none"] -TCL_NO_DEPRECATED = 0 +TK_NO_DEPRECATED = 0 WARNINGS = -W3 !else !if [nmakehlp -f $(CHECKS) "nodep"] !message *** Doing nodep check -TCL_NO_DEPRECATED = 1 +TK_NO_DEPRECATED = 1 !else -TCL_NO_DEPRECATED = 0 +TK_NO_DEPRECATED = 0 !endif !if [nmakehlp -f $(CHECKS) "fullwarn"] !message *** Doing full warnings check @@ -451,7 +443,7 @@ This compiler does not support profile guided optimization. # Set our defines now armed with our options. #---------------------------------------------------------- -OPTDEFINES = -DTCL_CFGVAL_ENCODING=$(CFG_ENCODING) -DSTDC_HEADERS +OPTDEFINES = -DTCL_CFGVAL_ENCODING=$(CFG_ENCODING) -DSTDC_HEADERS -DTCL_NO_DEPRECATED !if $(TCL_MEM_DEBUG) OPTDEFINES = $(OPTDEFINES) -DTCL_MEM_DEBUG @@ -468,8 +460,8 @@ OPTDEFINES = $(OPTDEFINES) -DUSE_THREAD_ALLOC=1 !if $(STATIC_BUILD) OPTDEFINES = $(OPTDEFINES) -DSTATIC_BUILD !endif -!if $(TCL_NO_DEPRECATED) -OPTDEFINES = $(OPTDEFINES) -DTCL_NO_DEPRECATED +!if $(TK_NO_DEPRECATED) +OPTDEFINES = $(OPTDEFINES) -DTK_NO_DEPRECATED !endif !if !$(DEBUG) -- cgit v0.12 From 565d1642f3eabd3b4e7a17c4aec1743facb416ba Mon Sep 17 00:00:00 2001 From: "jan.nijtmans" Date: Mon, 23 Jan 2017 14:52:54 +0000 Subject: more typos --- generic/tkTest.c | 2 +- generic/tkWindow.c | 2 +- 2 files changed, 2 insertions(+), 2 deletions(-) diff --git a/generic/tkTest.c b/generic/tkTest.c index e23be36..1f801be 100644 --- a/generic/tkTest.c +++ b/generic/tkTest.c @@ -452,7 +452,7 @@ TestcursorObjCmd( * A standard Tcl result. * * Side effects: - * All the intepreters created by previous calls to "testnewapp" get + * All the interpreters created by previous calls to "testnewapp" get * deleted. * *---------------------------------------------------------------------- diff --git a/generic/tkWindow.c b/generic/tkWindow.c index f02db35..3b3b025 100644 --- a/generic/tkWindow.c +++ b/generic/tkWindow.c @@ -943,7 +943,7 @@ TkCreateMainWindow( } /* - * Set variables for the intepreter. + * Set variables for the interpreter. */ Tcl_SetVar2(interp, "tk_patchLevel", NULL, TK_PATCH_LEVEL, TCL_GLOBAL_ONLY); -- cgit v0.12 From d033d601736ea26760f95cc30695c80d4d19bafe Mon Sep 17 00:00:00 2001 From: fvogel Date: Sat, 28 Jan 2017 17:37:29 +0000 Subject: Fixed [c0dbdd3ff3]: Tk Compatibility Fonts block access to system fonts --- win/tkWinFont.c | 16 ---------------- 1 file changed, 16 deletions(-) diff --git a/win/tkWinFont.c b/win/tkWinFont.c index 9a32227..c01dc3f 100644 --- a/win/tkWinFont.c +++ b/win/tkWinFont.c @@ -2528,22 +2528,6 @@ FamilyExists( int result; Tcl_DString faceString; - /* - * Just immediately rule out the following fonts, because they look so - * ugly on windows. The caller's fallback mechanism will cause the - * corresponding appropriate TrueType fonts to be selected. - */ - - if (strcasecmp(faceName, "Courier") == 0) { - return 0; - } - if (strcasecmp(faceName, "Times") == 0) { - return 0; - } - if (strcasecmp(faceName, "Helvetica") == 0) { - return 0; - } - Tcl_UtfToExternalDString(systemEncoding, faceName, -1, &faceString); /* -- cgit v0.12 From ac3c1f125c104ab506961d6653f0de098a056686 Mon Sep 17 00:00:00 2001 From: fvogel Date: Sat, 28 Jan 2017 17:38:11 +0000 Subject: Make tests pass again after fixing [c0dbdd3ff3]: Tk Compatibility Fonts block access to system fonts --- tests/entry.test | 18 ++++++++++++++---- tests/font.test | 6 +++--- tests/spinbox.test | 23 +++++++++++++++++++---- tests/textDisp.test | 2 +- tests/textWind.test | 4 ++-- tests/winFont.test | 6 +++--- 6 files changed, 42 insertions(+), 17 deletions(-) diff --git a/tests/entry.test b/tests/entry.test index eeebe5d..785dd0b 100644 --- a/tests/entry.test +++ b/tests/entry.test @@ -2305,10 +2305,20 @@ test entry-8.18 {DeleteChars procedure} -setup { .e insert 0 "xyzzy" update .e delete 2 4 - winfo reqwidth .e -} -cleanup { - destroy .e -} -result {31} + # To check that deletion actually happened we measure the new width + # of the widget, based on the measuring width of the remaining text ("xyy") + # in the widget. For that purpose we have to mirror the code in tkEntry.c + # for computation of the reqwidth + # note: XPAD corresponds to the hardcoded #define XPAD 1 + set XPAD 1 + set expected [expr { [font measure [.e cget -font] "xyy"] \ + + 2 * ( [.e cget -borderwidth] + \ + [.e cget -highlightthickness] + $XPAD ) } ] + expr {[winfo reqwidth .e] == $expected} +} -cleanup { + destroy .e + unset XPAD expected +} -result {1} test entry-9.1 {EntryValueChanged procedure} -setup { unset -nocomplain x diff --git a/tests/font.test b/tests/font.test index 7e37698..b8c0144 100644 --- a/tests/font.test +++ b/tests/font.test @@ -141,7 +141,7 @@ test font-4.9 {font command: actual} -constraints {unix noExceed} -body { test font-4.10 {font command: actual} -constraints win -body { # (objc > 3) so objPtr = objv[3 + skip] font actual {-family times} -family -} -result {Times New Roman} +} -result {times} test font-4.11 {font command: bad option} -body { font actual xyz -style } -returnCodes error -result {bad option "-style": must be -family, -size, -weight, -slant, -underline, or -overstrike} @@ -153,7 +153,7 @@ test font-4.13 {font command: actual} -body { } -match glob -result {*} test font-4.14 {font command: actual} -constraints win -body { font actual {-family times} -family -- \ud800\udc00 -} -result {Times New Roman} +} -result {times} test font-4.15 {font command: actual} -body { font actual {-family times} -- \udc00\ud800 } -returnCodes 1 -match glob -result {expected a single character but got "*"} @@ -2345,7 +2345,7 @@ test font-45.1 {TkFontGetAliasList: no match} -body { } -result [font actual {-size 10} -family] test font-45.2 {TkFontGetAliasList: match} -constraints win -body { font actual {times 10} -family -} -result {Times New Roman} +} -result {times} test font-45.3 {TkFontGetAliasList: match} -constraints {unix noExceed} -body { # can fail on Unix systems that have a real "times new roman" font font actual {{times new roman} 10} -family diff --git a/tests/spinbox.test b/tests/spinbox.test index 206a61d..1f2bdac 100644 --- a/tests/spinbox.test +++ b/tests/spinbox.test @@ -2607,10 +2607,25 @@ test spinbox-8.18 {DeleteChars procedure} -setup { .e insert 0 "xyzzy" update .e delete 2 4 - winfo reqwidth .e -} -cleanup { - destroy .e -} -result {42} + # To check that deletion actually happened we measure the new width + # of the widget, based on the measuring width of the remaining text ("xyy") + # in the widget. For that purpose we have to mirror the code in tkEntry.c + # for computation of the reqwidth + # note: XPAD corresponds to the hardcoded #define XPAD 1 + set XPAD 1 + set buttonWidth [expr { [font measure [.e cget -font] "0"] + 2 * (1 + $XPAD) }] + if {$buttonWidth < 11} { + set buttonWidth 11 + } + set expected [expr { [font measure [.e cget -font] "xyy"] \ + + 2 * ( [.e cget -borderwidth] + \ + [.e cget -highlightthickness] + $XPAD ) \ + + $buttonWidth } ] + expr {[winfo reqwidth .e] == $expected} +} -cleanup { + destroy .e + unset XPAD buttonWidth expected +} -result {1} test spinbox-9.1 {SpinboxValueChanged procedure} -setup { unset -nocomplain x diff --git a/tests/textDisp.test b/tests/textDisp.test index 5393533..c413b40 100644 --- a/tests/textDisp.test +++ b/tests/textDisp.test @@ -41,7 +41,7 @@ catch {destroy .f .t} frame .f -width 100 -height 20 pack append . .f left -set fixedFont {Courier -12} +set fixedFont {"Courier New" -12} # 15 on XP, 13 on Solaris 8 set fixedHeight [font metrics $fixedFont -linespace] # 7 on all platforms diff --git a/tests/textWind.test b/tests/textWind.test index b0359f9..f5a5152 100644 --- a/tests/textWind.test +++ b/tests/textWind.test @@ -16,7 +16,7 @@ tcltest::loadTestedCommands option add *Text.borderWidth 2 option add *Text.highlightThickness 2 -option add *Text.font {Courier -12} +option add *Text.font {"Courier New" -12} deleteWindows @@ -27,7 +27,7 @@ update .t debug on # 15 on XP, 13 on Solaris 8 -set fixedHeight [font metrics {Courier -12} -linespace] +set fixedHeight [font metrics {"Courier New" -12} -linespace] set fixedDiff [expr {$fixedHeight - 13}] ;# 2 on XP set color [expr {[winfo depth .t] > 1 ? "green" : "black"}] diff --git a/tests/winFont.test b/tests/winFont.test index 08a53ff..93aeca9 100644 --- a/tests/winFont.test +++ b/tests/winFont.test @@ -71,7 +71,7 @@ test winfont-2.7 {TkpGetFontFromAttributes procedure: Times fonts} -constraints lappend x [font actual {-family "Times"} -family] lappend x [font actual {-family "New York"} -family] lappend x [font actual {-family "Times New Roman"} -family] -} -result {{Times New Roman} {Times New Roman} {Times New Roman}} +} -result {Times Times {Times New Roman}} test winfont-2.8 {TkpGetFontFromAttributes procedure: Courier fonts} -constraints { win } -setup { @@ -80,7 +80,7 @@ test winfont-2.8 {TkpGetFontFromAttributes procedure: Courier fonts} -constraint lappend x [font actual {-family "Courier"} -family] lappend x [font actual {-family "Monaco"} -family] lappend x [font actual {-family "Courier New"} -family] -} -result {{Courier New} {Courier New} {Courier New}} +} -result {Courier Courier {Courier New}} test winfont-2.9 {TkpGetFontFromAttributes procedure: Helvetica fonts} -constraints { win } -setup { @@ -89,7 +89,7 @@ test winfont-2.9 {TkpGetFontFromAttributes procedure: Helvetica fonts} -constrai lappend x [font actual {-family "Helvetica"} -family] lappend x [font actual {-family "Geneva"} -family] lappend x [font actual {-family "Arial"} -family] -} -result {Arial Arial Arial} +} -result {Helvetica Helvetica Arial} test winfont-2.10 {TkpGetFontFromAttributes procedure: fallback} -constraints { win } -body { -- cgit v0.12 From 4a1828d3e7f328cce5d6b770ffbb6ea5a5373d0c Mon Sep 17 00:00:00 2001 From: "jan.nijtmans" Date: Mon, 13 Feb 2017 09:57:07 +0000 Subject: Make tk.h work unchanged with Tcl 9.0 (novem), account for possible missing TCL_STORAGE_CLASS definition. More internal use of size_t in stead of int. --- generic/tk.h | 4 ++++ generic/tkCmds.c | 7 +++---- generic/tkGC.c | 5 ++--- generic/tkImgBmap.c | 5 ++--- generic/tkVisual.c | 13 ++++++------- unix/tkUnixWm.c | 28 ++++++++++++---------------- 6 files changed, 29 insertions(+), 33 deletions(-) diff --git a/generic/tk.h b/generic/tk.h index 1d070d3..1cb10e2 100644 --- a/generic/tk.h +++ b/generic/tk.h @@ -105,6 +105,10 @@ extern "C" { #ifdef BUILD_tk #undef TCL_STORAGE_CLASS #define TCL_STORAGE_CLASS DLLEXPORT +#else +# ifndef TCL_STORAGE_CLASS +# define TCL_STORAGE_CLASS DLLIMPORT +# endif #endif /* diff --git a/generic/tkCmds.c b/generic/tkCmds.c index 6196b17..93c1fb0 100644 --- a/generic/tkCmds.c +++ b/generic/tkCmds.c @@ -2068,14 +2068,13 @@ TkGetDisplayOf( * present. */ { const char *string; - int length; if (objc < 1) { return 0; } - string = Tcl_GetStringFromObj(objv[0], &length); - if ((length >= 2) && - (strncmp(string, "-displayof", (unsigned) length) == 0)) { + string = Tcl_GetString(objv[0]); + if ((objv[0]->length >= 2) && + (strncmp(string, "-displayof", objv[0]->length) == 0)) { if (objc < 2) { Tcl_SetObjResult(interp, Tcl_NewStringObj( "value for \"-displayof\" missing", -1)); diff --git a/generic/tkGC.c b/generic/tkGC.c index c424e30..55e5774 100644 --- a/generic/tkGC.c +++ b/generic/tkGC.c @@ -23,7 +23,7 @@ typedef struct { GC gc; /* Graphics context. */ Display *display; /* Display to which gc belongs. */ - int refCount; /* Number of active uses of gc. */ + size_t refCount; /* Number of active uses of gc. */ Tcl_HashEntry *valueHashPtr;/* Entry in valueTable (needed when deleting * this structure). */ } TkGC; @@ -312,8 +312,7 @@ Tk_FreeGC( Tcl_Panic("Tk_FreeGC received unknown gc argument"); } gcPtr = Tcl_GetHashValue(idHashPtr); - gcPtr->refCount--; - if (gcPtr->refCount == 0) { + if (gcPtr->refCount-- <= 1) { XFreeGC(gcPtr->display, gcPtr->gc); Tcl_DeleteHashEntry(gcPtr->valueHashPtr); Tcl_DeleteHashEntry(idHashPtr); diff --git a/generic/tkImgBmap.c b/generic/tkImgBmap.c index 0906673..1a9a86e 100644 --- a/generic/tkImgBmap.c +++ b/generic/tkImgBmap.c @@ -49,7 +49,7 @@ typedef struct BitmapMaster { */ typedef struct BitmapInstance { - int refCount; /* Number of instances that share this data + size_t refCount; /* Number of instances that share this data * structure. */ BitmapMaster *masterPtr; /* Pointer to master for image. */ Tk_Window tkwin; /* Window in which the instances will be @@ -951,8 +951,7 @@ ImgBmapFree( BitmapInstance *instancePtr = clientData; BitmapInstance *prevPtr; - instancePtr->refCount--; - if (instancePtr->refCount > 0) { + if (instancePtr->refCount-- > 1) { return; } diff --git a/generic/tkVisual.c b/generic/tkVisual.c index 8b0c155..6f6816d 100644 --- a/generic/tkVisual.c +++ b/generic/tkVisual.c @@ -46,7 +46,7 @@ static const VisualDictionary visualNames[] = { struct TkColormap { Colormap colormap; /* X's identifier for the colormap. */ Visual *visual; /* Visual for which colormap was allocated. */ - int refCount; /* How many uses of the colormap are still + size_t refCount; /* How many uses of the colormap are still * outstanding (calls to Tk_GetColormap minus * calls to Tk_FreeColormap). */ int shareable; /* 0 means this colormap was allocated by a @@ -137,7 +137,7 @@ Tk_GetVisual( for (cmapPtr = dispPtr->cmapPtr; cmapPtr != NULL; cmapPtr = cmapPtr->nextPtr) { if (cmapPtr->colormap == *colormapPtr) { - cmapPtr->refCount += 1; + cmapPtr->refCount++; break; } } @@ -324,7 +324,7 @@ Tk_GetVisual( cmapPtr = cmapPtr->nextPtr) { if (cmapPtr->shareable && (cmapPtr->visual == visual)) { *colormapPtr = cmapPtr->colormap; - cmapPtr->refCount += 1; + cmapPtr->refCount++; goto done; } } @@ -427,7 +427,7 @@ Tk_GetColormap( for (cmapPtr = dispPtr->cmapPtr; cmapPtr != NULL; cmapPtr = cmapPtr->nextPtr) { if (cmapPtr->colormap == colormap) { - cmapPtr->refCount += 1; + cmapPtr->refCount++; } } return colormap; @@ -476,8 +476,7 @@ Tk_FreeColormap( for (prevPtr = NULL, cmapPtr = dispPtr->cmapPtr; cmapPtr != NULL; prevPtr = cmapPtr, cmapPtr = cmapPtr->nextPtr) { if (cmapPtr->colormap == colormap) { - cmapPtr->refCount -= 1; - if (cmapPtr->refCount == 0) { + if (cmapPtr->refCount-- <= 1) { XFreeColormap(display, colormap); if (prevPtr == NULL) { dispPtr->cmapPtr = cmapPtr->nextPtr; @@ -534,7 +533,7 @@ Tk_PreserveColormap( for (cmapPtr = dispPtr->cmapPtr; cmapPtr != NULL; cmapPtr = cmapPtr->nextPtr) { if (cmapPtr->colormap == colormap) { - cmapPtr->refCount += 1; + cmapPtr->refCount++; return; } } diff --git a/unix/tkUnixWm.c b/unix/tkUnixWm.c index 19ac86c..68ab6d6 100644 --- a/unix/tkUnixWm.c +++ b/unix/tkUnixWm.c @@ -1033,7 +1033,7 @@ Tk_WmObjCmd( WMOPT_MINSIZE, WMOPT_OVERRIDEREDIRECT, WMOPT_POSITIONFROM, WMOPT_PROTOCOL, WMOPT_RESIZABLE, WMOPT_SIZEFROM, WMOPT_STACKORDER, WMOPT_STATE, WMOPT_TITLE, WMOPT_TRANSIENT, WMOPT_WITHDRAW }; - int index, length; + int index; const char *argv1; TkWindow *winPtr; Tk_Window targetWin; @@ -1045,9 +1045,9 @@ Tk_WmObjCmd( return TCL_ERROR; } - argv1 = Tcl_GetStringFromObj(objv[1], &length); - if ((argv1[0] == 't') && (strncmp(argv1, "tracing", (size_t) length) == 0) - && (length >= 3)) { + argv1 = Tcl_GetString(objv[1]); + if ((argv1[0] == 't') && (strncmp(argv1, "tracing", objv[1]->length) == 0) + && (objv[1]->length >= 3)) { int wmTracing; if ((objc != 2) && (objc != 3)) { @@ -1457,7 +1457,6 @@ WmClientCmd( { register WmInfo *wmPtr = winPtr->wmInfoPtr; const char *argv3; - int length; if ((objc != 3) && (objc != 4)) { Tcl_WrongNumArgs(interp, 2, objv, "window ?name?"); @@ -1470,7 +1469,7 @@ WmClientCmd( } return TCL_OK; } - argv3 = Tcl_GetStringFromObj(objv[3], &length); + argv3 = Tcl_GetString(objv[3]); if (argv3[0] == 0) { if (wmPtr->clientMachine != NULL) { ckfree(wmPtr->clientMachine); @@ -1486,7 +1485,7 @@ WmClientCmd( if (wmPtr->clientMachine != NULL) { ckfree(wmPtr->clientMachine); } - wmPtr->clientMachine = ckalloc(length + 1); + wmPtr->clientMachine = ckalloc(objv[3]->length + 1); strcpy(wmPtr->clientMachine, argv3); if (!(wmPtr->flags & WM_NEVER_MAPPED)) { XTextProperty textProp; @@ -2072,7 +2071,6 @@ WmGroupCmd( Tk_Window tkwin2; WmInfo *wmPtr2; const char *argv3; - int length; if ((objc != 3) && (objc != 4)) { Tcl_WrongNumArgs(interp, 2, objv, "window ?pathName?"); @@ -2084,7 +2082,7 @@ WmGroupCmd( } return TCL_OK; } - argv3 = Tcl_GetStringFromObj(objv[3], &length); + argv3 = Tcl_GetString(objv[3]); if (*argv3 == '\0') { wmPtr->hints.flags &= ~WindowGroupHint; if (wmPtr->leaderName != NULL) { @@ -2112,7 +2110,7 @@ WmGroupCmd( } wmPtr->hints.window_group = Tk_WindowId(wmPtr2->wrapperPtr); wmPtr->hints.flags |= WindowGroupHint; - wmPtr->leaderName = ckalloc(length + 1); + wmPtr->leaderName = ckalloc(objv[3]->length + 1); strcpy(wmPtr->leaderName, argv3); } UpdateHints(winPtr); @@ -2334,7 +2332,6 @@ WmIconnameCmd( { register WmInfo *wmPtr = winPtr->wmInfoPtr; const char *argv3; - int length; if (objc > 4) { Tcl_WrongNumArgs(interp, 2, objv, "window ?newName?"); @@ -2349,8 +2346,8 @@ WmIconnameCmd( if (wmPtr->iconName != NULL) { ckfree(wmPtr->iconName); } - argv3 = Tcl_GetStringFromObj(objv[3], &length); - wmPtr->iconName = ckalloc(length + 1); + argv3 = Tcl_GetString(objv[3]); + wmPtr->iconName = ckalloc(objv[3]->length + 1); strcpy(wmPtr->iconName, argv3); if (!(wmPtr->flags & WM_NEVER_MAPPED)) { UpdateTitle(winPtr); @@ -3471,7 +3468,6 @@ WmTitleCmd( { register WmInfo *wmPtr = winPtr->wmInfoPtr; const char *argv3; - int length; if (objc > 4) { Tcl_WrongNumArgs(interp, 2, objv, "window ?newTitle?"); @@ -3487,8 +3483,8 @@ WmTitleCmd( if (wmPtr->title != NULL) { ckfree(wmPtr->title); } - argv3 = Tcl_GetStringFromObj(objv[3], &length); - wmPtr->title = ckalloc(length + 1); + argv3 = Tcl_GetString(objv[3]); + wmPtr->title = ckalloc(objv[3]->length + 1); strcpy(wmPtr->title, argv3); if (!(wmPtr->flags & WM_NEVER_MAPPED)) { -- cgit v0.12 From 1e9b0fc3c284b29e0adaf439f2438d0246eb7838 Mon Sep 17 00:00:00 2001 From: "jan.nijtmans" Date: Wed, 15 Feb 2017 13:56:17 +0000 Subject: Change some internal refCount's from int to size_t. --- generic/tkImgPhoto.h | 2 +- generic/tkInt.h | 4 ++-- tests/textDisp.test | 2 +- 3 files changed, 4 insertions(+), 4 deletions(-) diff --git a/generic/tkImgPhoto.h b/generic/tkImgPhoto.h index 36bc6cb..45fac88 100644 --- a/generic/tkImgPhoto.h +++ b/generic/tkImgPhoto.h @@ -201,7 +201,7 @@ struct PhotoInstance { * this particular colormap. */ PhotoInstance *nextPtr; /* Pointer to the next instance in the list of * instances associated with this master. */ - int refCount; /* Number of instances using this structure. */ + size_t refCount; /* Number of instances using this structure. */ Tk_Uid palette; /* Palette for these particular instances. */ double gamma; /* Gamma value for these instances. */ Tk_Uid defaultPalette; /* Default palette to use if a palette is not diff --git a/generic/tkInt.h b/generic/tkInt.h index f00d833..3138ffc 100644 --- a/generic/tkInt.h +++ b/generic/tkInt.h @@ -478,7 +478,7 @@ typedef struct TkDisplay { #endif /* TK_USE_INPUT_METHODS */ Tcl_HashTable winTable; /* Maps from X window ids to TkWindow ptrs. */ - int refCount; /* Reference count of how many Tk applications + size_t refCount; /* Reference count of how many Tk applications * are using this display. Used to clean up * the display when we no longer have any Tk * applications using it. */ @@ -582,7 +582,7 @@ typedef struct TkEventHandler { */ typedef struct TkMainInfo { - int refCount; /* Number of windows whose "mainPtr" fields + size_t refCount; /* Number of windows whose "mainPtr" fields * point here. When this becomes zero, can * free up the structure (the reference count * is zero because windows can get deleted in diff --git a/tests/textDisp.test b/tests/textDisp.test index 9a71d96..f2eb47d 100644 --- a/tests/textDisp.test +++ b/tests/textDisp.test @@ -2878,7 +2878,7 @@ test textDisp-20.1 {FindDLine} { list [.t dlineinfo 46.0] [.t dlineinfo 47.0] [.t dlineinfo 49.0] \ [.t dlineinfo 58.0] } [list {} {} [list 3 [expr {$fixedDiff + 16}] 49 [expr {$fixedDiff + 13}] [expr {$fixedDiff + 10}]] {}] -test textDisp-20.2 {FindDLine} { +test textDisp-20.2 {FindDLine} { .t yview 100.0 .t yview -pickplace 53.0 list [.t dlineinfo 50.0] [.t dlineinfo 50.14] [.t dlineinfo 50.21] -- cgit v0.12 From 6214efc0cc2054edbeaf5d08ac8c9a1864797d4a Mon Sep 17 00:00:00 2001 From: "jan.nijtmans" Date: Thu, 16 Feb 2017 11:05:09 +0000 Subject: If compiled with TK_NO_DEPRECATED, remove support for old "set" and "get" syntax on scrollbar. --- generic/tkScrollbar.c | 13 +++++++++---- generic/tkScrollbar.h | 6 ++++++ tests/scrollbar.test | 4 ++-- 3 files changed, 17 insertions(+), 6 deletions(-) diff --git a/generic/tkScrollbar.c b/generic/tkScrollbar.c index 5017d30..9c1ceb8 100644 --- a/generic/tkScrollbar.c +++ b/generic/tkScrollbar.c @@ -179,10 +179,12 @@ Tk_ScrollbarObjCmd( scrollPtr->sliderLast = 0; scrollPtr->activeField = 0; scrollPtr->activeRelief = TK_RELIEF_RAISED; +#ifndef TK_NO_DEPRECATED scrollPtr->totalUnits = 0; scrollPtr->windowUnits = 0; scrollPtr->firstUnit = 0; scrollPtr->lastUnit = 0; +#endif /* TK_NO_DEPRECATED */ scrollPtr->firstFraction = 0.0; scrollPtr->lastFraction = 0.0; scrollPtr->cursor = None; @@ -377,10 +379,13 @@ ScrollbarWidgetObjCmd( Tcl_WrongNumArgs(interp, 1, objv, "get"); goto error; } +#ifndef TK_NO_DEPRECATED if (scrollPtr->flags & NEW_STYLE_COMMANDS) { +#endif /* TK_NO_DEPRECATED */ resObjs[0] = Tcl_NewDoubleObj(scrollPtr->firstFraction); resObjs[1] = Tcl_NewDoubleObj(scrollPtr->lastFraction); Tcl_SetObjResult(interp, Tcl_NewListObj(2, resObjs)); +#ifndef TK_NO_DEPRECATED } else { resObjs[0] = Tcl_NewIntObj(scrollPtr->totalUnits); resObjs[1] = Tcl_NewIntObj(scrollPtr->windowUnits); @@ -388,6 +393,7 @@ ScrollbarWidgetObjCmd( resObjs[3] = Tcl_NewIntObj(scrollPtr->lastUnit); Tcl_SetObjResult(interp, Tcl_NewListObj(4, resObjs)); } +#endif /* TK_NO_DEPRECATED */ break; } case COMMAND_IDENTIFY: { @@ -413,8 +419,6 @@ ScrollbarWidgetObjCmd( break; } case COMMAND_SET: { - int totalUnits, windowUnits, firstUnit, lastUnit; - if (objc == 4) { double first, last; @@ -438,8 +442,10 @@ ScrollbarWidgetObjCmd( } else { scrollPtr->lastFraction = last; } +#ifndef TK_NO_DEPRECATED scrollPtr->flags |= NEW_STYLE_COMMANDS; } else if (objc == 6) { + int totalUnits, windowUnits, firstUnit, lastUnit; if (Tcl_GetIntFromObj(interp, objv[2], &totalUnits) != TCL_OK) { goto error; } @@ -477,10 +483,9 @@ ScrollbarWidgetObjCmd( scrollPtr->lastFraction = ((double) (lastUnit+1))/totalUnits; } scrollPtr->flags &= ~NEW_STYLE_COMMANDS; +#endif /* !TK_NO_DEPRECATED */ } else { Tcl_WrongNumArgs(interp, 1, objv, "set firstFraction lastFraction"); - Tcl_AppendResult(interp, " or \"", Tcl_GetString(objv[0]), - " set totalUnits windowUnits firstUnit lastUnit\"", NULL); goto error; } TkpComputeScrollbarGeometry(scrollPtr); diff --git a/generic/tkScrollbar.h b/generic/tkScrollbar.h index b0cd085..66b12b8 100644 --- a/generic/tkScrollbar.h +++ b/generic/tkScrollbar.h @@ -96,6 +96,7 @@ typedef struct TkScrollbar { * the NEW_STYLE_COMMANDS flag is 0. */ +#ifndef TK_NO_DEPRECATED int totalUnits; /* Total dimension of application, in units. * Valid only if the NEW_STYLE_COMMANDS flag * isn't set. */ @@ -108,6 +109,9 @@ typedef struct TkScrollbar { int lastUnit; /* Index of last unit visible in window. * Valid only if the NEW_STYLE_COMMANDS flag * isn't set. */ +#else + int dummy1,dummy2,dummy3,dummy4; /* sizeof(TkScrollbar) should not depend on TK_NO_DEPRECATED */ +#endif /* TK_NO_DEPRECATED */ double firstFraction; /* Position of first visible thing in window, * specified as a fraction between 0 and * 1.0. */ @@ -153,7 +157,9 @@ typedef struct TkScrollbar { */ #define REDRAW_PENDING 1 +#ifndef TK_NO_DEPRECATED #define NEW_STYLE_COMMANDS 2 +#endif /* TK_NO_DEPRECATED */ #define GOT_FOCUS 4 /* diff --git a/tests/scrollbar.test b/tests/scrollbar.test index 6d811dc..b7cdbc0 100644 --- a/tests/scrollbar.test +++ b/tests/scrollbar.test @@ -396,10 +396,10 @@ test scrollbar-3.70 {ScrollbarWidgetCmd procedure, "set" option} { } {100 50 30 30} test scrollbar-3.71 {ScrollbarWidgetCmd procedure, "set" option} { list [catch {.s set 1 2 3} msg] $msg -} {1 {wrong # args: should be ".s set firstFraction lastFraction" or ".s set totalUnits windowUnits firstUnit lastUnit"}} +} {1 {wrong # args: should be ".s set firstFraction lastFraction"}} test scrollbar-3.72 {ScrollbarWidgetCmd procedure, "set" option} { list [catch {.s set 1 2 3 4 5} msg] $msg -} {1 {wrong # args: should be ".s set firstFraction lastFraction" or ".s set totalUnits windowUnits firstUnit lastUnit"}} +} {1 {wrong # args: should be ".s set firstFraction lastFraction"}} test scrollbar-3.73 {ScrollbarWidgetCmd procedure} { list [catch {.s bogus} msg] $msg } {1 {bad option "bogus": must be activate, cget, configure, delta, fraction, get, identify, or set}} -- cgit v0.12 From 9439bbc72e66a54de76674374faf70c629eda920 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Jos=C3=A9=20Ignacio=20Mar=C3=ADn?= Date: Fri, 3 Mar 2017 18:26:11 +0000 Subject: Patch on behalf of TheLemonMan that addresses bug [6b3644a4858f018cd08615d3d516b07d271fe2a]. --- generic/tkImgPNG.c | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/generic/tkImgPNG.c b/generic/tkImgPNG.c index c6e3029..6e64afa 100644 --- a/generic/tkImgPNG.c +++ b/generic/tkImgPNG.c @@ -2245,10 +2245,10 @@ ApplyAlpha( p += offset; if (16 == pngPtr->bitDepth) { - register int channel; + register unsigned int channel; while (p < endPtr) { - channel = (unsigned char) + channel = (unsigned int) (((p[0] << 8) | p[1]) * pngPtr->alpha); *p++ = (unsigned char) (channel >> 8); -- cgit v0.12 From aa4022a388d07e718331f5a593fc2ed6e0572fa9 Mon Sep 17 00:00:00 2001 From: fvogel Date: Mon, 6 Mar 2017 18:30:38 +0000 Subject: =?UTF-8?q?Updated=20patch=20from=20Ren=C3=A9=20Zaumseil,=20now=20?= =?UTF-8?q?consistent=20with=20the=20proposed=20implementation=20at=20http?= =?UTF-8?q?://wiki.tcl.tk/20059?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- generic/ttk/ttkButton.c | 4 ++++ 1 file changed, 4 insertions(+) diff --git a/generic/ttk/ttkButton.c b/generic/ttk/ttkButton.c index c00754b..ef55ec3 100644 --- a/generic/ttk/ttkButton.c +++ b/generic/ttk/ttkButton.c @@ -23,6 +23,7 @@ typedef struct * Text element resources: */ Tcl_Obj *textObj; + Tcl_Obj *justifyObj; Tcl_Obj *textVariableObj; Tcl_Obj *underlineObj; Tcl_Obj *widthObj; @@ -56,6 +57,9 @@ typedef struct static Tk_OptionSpec BaseOptionSpecs[] = { + {TK_OPTION_JUSTIFY, "-justify", "justify", "Justify", + "left", Tk_Offset(Base,base.justifyObj), -1, + TK_OPTION_NULL_OK,0,GEOMETRY_CHANGED }, {TK_OPTION_STRING, "-text", "text", "Text", "", Tk_Offset(Base,base.textObj), -1, 0,0,GEOMETRY_CHANGED }, -- cgit v0.12 From b536633b39243893edda31138eec6653e484759b Mon Sep 17 00:00:00 2001 From: fvogel Date: Tue, 7 Mar 2017 20:46:17 +0000 Subject: Document -justify for ttk::button --- doc/ttk_button.n | 2 +- doc/ttk_label.n | 7 +------ doc/ttk_widget.n | 5 +++++ 3 files changed, 7 insertions(+), 7 deletions(-) diff --git a/doc/ttk_button.n b/doc/ttk_button.n index 62ebe47..e7c88b2 100644 --- a/doc/ttk_button.n +++ b/doc/ttk_button.n @@ -17,7 +17,7 @@ A \fBttk::button\fR widget displays a textual label and/or image, and evaluates a command when pressed. .SO ttk_widget \-class \-compound \-cursor -\-image \-state \-style +\-image \-justify \-state \-style \-takefocus \-text \-textvariable \-underline \-width .SE diff --git a/doc/ttk_label.n b/doc/ttk_label.n index 6781b47..e891954 100644 --- a/doc/ttk_label.n +++ b/doc/ttk_label.n @@ -19,7 +19,7 @@ The label may be linked to a Tcl variable to automatically change the displayed text. .SO ttk_widget \-class \-compound \-cursor -\-image \-style \-takefocus +\-image \-justify \-style \-takefocus \-text \-textvariable \-underline \-width .SE @@ -38,11 +38,6 @@ Font to use for label text. .OP \-foreground textColor TextColor The widget's foreground color. If unspecified, the theme default is used. -.OP \-justify justify Justify -If there are multiple lines of text, specifies how -the lines are laid out relative to one another. -One of \fBleft\fR, \fBcenter\fR, or \fBright\fR. -See also \fB\-anchor\fR. .OP \-padding padding Padding Specifies the amount of extra space to allocate for the widget. The padding is a list of up to four length specifications diff --git a/doc/ttk_widget.n b/doc/ttk_widget.n index 2ecc29f..1ab3bc8 100644 --- a/doc/ttk_widget.n +++ b/doc/ttk_widget.n @@ -71,6 +71,11 @@ See the description of \fB\-xscrollcommand\fR above for details. .SH "LABEL OPTIONS" The following options are supported by labels, buttons, and other button-like widgets: +.OP \-justify justify Justify +If there are multiple lines of text, specifies how +the lines are laid out relative to one another. +One of \fBleft\fR, \fBcenter\fR, or \fBright\fR. +See also \fB\-anchor\fR (for widgets supporting this option). .OP \-text text Text Specifies a text string to be displayed inside the widget (unless overridden by \fB\-textvariable\fR). -- cgit v0.12 From 1b348a666d6104aa075165cdea1b1ce4bb12323b Mon Sep 17 00:00:00 2001 From: fvogel Date: Tue, 7 Mar 2017 21:43:51 +0000 Subject: Document the new options for ttk::progressbar --- doc/ttk_label.n | 23 +++---------------- doc/ttk_progressbar.n | 35 +++++++++++++++++------------ doc/ttk_widget.n | 61 ++++++++++++++++++++++++++++++++------------------- 3 files changed, 62 insertions(+), 57 deletions(-) diff --git a/doc/ttk_label.n b/doc/ttk_label.n index e891954..a9e7f11 100644 --- a/doc/ttk_label.n +++ b/doc/ttk_label.n @@ -18,26 +18,18 @@ A \fBttk::label\fR widget displays a textual label and/or image. The label may be linked to a Tcl variable to automatically change the displayed text. .SO ttk_widget -\-class \-compound \-cursor +\-anchor \-class \-compound \-cursor +\-foreground \-image \-justify \-style \-takefocus \-text \-textvariable \-underline -\-width +\-width \-wraplength .SE .SH "WIDGET-SPECIFIC OPTIONS" -.OP \-anchor anchor Anchor -Specifies how the information in the widget is positioned -relative to the inner margins. Legal values are -\fBn\fR, \fBne\fR, \fBe\fR, \fBse\fR, -\fBs\fR, \fBsw\fR, \fBw\fR, \fBnw\fR, and \fBcenter\fR. -See also \fB\-justify\fR. .OP \-background frameColor FrameColor The widget's background color. If unspecified, the theme default is used. .OP \-font font Font Font to use for label text. -.OP \-foreground textColor TextColor -The widget's foreground color. -If unspecified, the theme default is used. .OP \-padding padding Padding Specifies the amount of extra space to allocate for the widget. The padding is a list of up to four length specifications @@ -52,15 +44,6 @@ Specifies the 3-D effect desired for the widget border. Valid values are \fBflat\fR, \fBgroove\fR, \fBraised\fR, \fBridge\fR, \fBsolid\fR, and \fBsunken\fR. -.OP \-text text Text -Specifies a text string to be displayed inside the widget -(unless overridden by \fB\-textvariable\fR). -.OP \-wraplength wrapLength WrapLength -Specifies the maximum line length (in pixels). -If this option is less than or equal to zero, -then automatic wrapping is not performed; otherwise -the text is split into lines such that no line is longer -than the specified value. .SH "WIDGET COMMAND" .PP Supports the standard widget commands diff --git a/doc/ttk_progressbar.n b/doc/ttk_progressbar.n index 1945f70..33da815 100644 --- a/doc/ttk_progressbar.n +++ b/doc/ttk_progressbar.n @@ -19,22 +19,36 @@ operation. They can operate in two modes: \fIdeterminate\fR mode shows the amount completed relative to the total amount of work to be done, and \fIindeterminate\fR mode provides an animated display to let the user know that something is happening. +.PP +If the value of \fB-orient\fR is \fBhorizontal\fR a text string can be +displayed inside the progressbar. This string can be configured using +the \fB-anchor\fR, \fB-text\fR, \fB-foreground\fR, \fB-justify\fR and +\fB-wraplength\fR options. If the value of \fB-orient\fR is \fBvertical\fR +then these options are ignored. .SO ttk_widget -\-class \-cursor \-takefocus -\-style +\-anchor \-class \-cursor +\-foreground \-justify \-style +\-takefocus \-text \-wraplength .SE .SH "WIDGET-SPECIFIC OPTIONS" -.OP \-orient orient Orient -One of \fBhorizontal\fR or \fBvertical\fR. -Specifies the orientation of the progress bar. .OP \-length length Length Specifies the length of the long axis of the progress bar (width if horizontal, height if vertical). -.OP \-mode mode Mode -One of \fBdeterminate\fR or \fBindeterminate\fR. .OP \-maximum maximum Maximum A floating point number specifying the maximum \fB\-value\fR. Defaults to 100. +.OP \-mode mode Mode +One of \fBdeterminate\fR or \fBindeterminate\fR. +.OP \-orient orient Orient +One of \fBhorizontal\fR or \fBvertical\fR. +Specifies the orientation of the progress bar. +.OP \-phase phase Phase +Read-only option. +The widget periodically increments the value of this option +whenever the \fB\-value\fR is greater than 0 and, +in \fIdeterminate\fR mode, less than \fB\-maximum\fR. +This option may be used by the current theme +to provide additional animation effects. .OP \-value value Value The current value of the progress bar. In \fIdeterminate\fR mode, this represents the amount of work completed. @@ -47,13 +61,6 @@ The name of a global Tcl variable which is linked to the \fB\-value\fR. If specified, the \fB\-value\fR of the progress bar is automatically set to the value of the variable whenever the latter is modified. -.OP \-phase phase Phase -Read-only option. -The widget periodically increments the value of this option -whenever the \fB\-value\fR is greater than 0 and, -in \fIdeterminate\fR mode, less than \fB\-maximum\fR. -This option may be used by the current theme -to provide additional animation effects. .SH "WIDGET COMMAND" .PP .TP diff --git a/doc/ttk_widget.n b/doc/ttk_widget.n index 1ab3bc8..f8bf98b 100644 --- a/doc/ttk_widget.n +++ b/doc/ttk_widget.n @@ -71,29 +71,12 @@ See the description of \fB\-xscrollcommand\fR above for details. .SH "LABEL OPTIONS" The following options are supported by labels, buttons, and other button-like widgets: -.OP \-justify justify Justify -If there are multiple lines of text, specifies how -the lines are laid out relative to one another. -One of \fBleft\fR, \fBcenter\fR, or \fBright\fR. -See also \fB\-anchor\fR (for widgets supporting this option). -.OP \-text text Text -Specifies a text string to be displayed inside the widget -(unless overridden by \fB\-textvariable\fR). -.OP \-textvariable textVariable Variable -Specifies the name of a global variable whose value will be used -in place of the \fB\-text\fR resource. -.OP \-underline underline Underline -If set, specifies the integer index (0-based) of a character to underline -in the text string. -The underlined character is used for mnemonic activation. -.OP \-image image Image -Specifies an image to display. -This is a list of 1 or more elements. -The first element is the default image name. -The rest of the list is a sequence of \fIstatespec / value\fR pairs -as per \fBstyle map\fR, specifying different images to use when -the widget is in a particular state or combination of states. -All images in the list should have the same size. +.OP \-anchor anchor Anchor +Specifies how the information in the widget is positioned +relative to the inner margins. Legal values are +\fBn\fR, \fBne\fR, \fBe\fR, \fBse\fR, +\fBs\fR, \fBsw\fR, \fBw\fR, \fBnw\fR, and \fBcenter\fR. +See also \fB\-justify\fR (for widgets supporting this option). .OP \-compound compound Compound Specifies how to display the image relative to the text, in the case both \fB\-text\fR and \fB\-image\fR are present. @@ -113,11 +96,43 @@ Display image above, below, left of, or right of the text, respectively. .IP none The default; display the image if present, otherwise the text. .RE +.OP \-foreground textColor TextColor +The widget's foreground color. +If unspecified, the theme default is used. +.OP \-image image Image +Specifies an image to display. +This is a list of 1 or more elements. +The first element is the default image name. +The rest of the list is a sequence of \fIstatespec / value\fR pairs +as per \fBstyle map\fR, specifying different images to use when +the widget is in a particular state or combination of states. +All images in the list should have the same size. +.OP \-justify justify Justify +If there are multiple lines of text, specifies how +the lines are laid out relative to one another. +One of \fBleft\fR, \fBcenter\fR, or \fBright\fR. +See also \fB\-anchor\fR (for widgets supporting this option). +.OP \-text text Text +Specifies a text string to be displayed inside the widget +(unless overridden by \fB\-textvariable\fR for the widgets supporting this option). +.OP \-textvariable textVariable Variable +Specifies the name of a global variable whose value will be used +in place of the \fB\-text\fR resource. +.OP \-underline underline Underline +If set, specifies the integer index (0-based) of a character to underline +in the text string. +The underlined character is used for mnemonic activation. .OP \-width width Width If greater than zero, specifies how much space, in character widths, to allocate for the text label. If less than zero, specifies a minimum width. If zero or unspecified, the natural width of the text label is used. +.OP \-wraplength wrapLength WrapLength +Specifies the maximum line length (in pixels). +If this option is less than or equal to zero, +then automatic wrapping is not performed; otherwise +the text is split into lines such that no line is longer +than the specified value. .SH "COMPATIBILITY OPTIONS" .OP \-state state State May be set to \fBnormal\fR or \fBdisabled\fR -- cgit v0.12 From eddcfed96bcaffb3ba5a2ced5b3c826943e0c51b Mon Sep 17 00:00:00 2001 From: fvogel Date: Tue, 7 Mar 2017 22:00:03 +0000 Subject: Remove duplicate documentation of -width in ttk::button --- doc/ttk_button.n | 7 ------- doc/ttk_widget.n | 2 ++ 2 files changed, 2 insertions(+), 7 deletions(-) diff --git a/doc/ttk_button.n b/doc/ttk_button.n index e7c88b2..f76de6c 100644 --- a/doc/ttk_button.n +++ b/doc/ttk_button.n @@ -39,13 +39,6 @@ The default is \fBnormal\fR. Depending on the theme, the default button may be displayed with an extra highlight ring, or with a different border color. .RE -.OP \-width width Width -If greater than zero, specifies how much space, in character widths, -to allocate for the text label. -If less than zero, specifies a minimum width. -If zero or unspecified, the natural width of the text label is used. -Note that some themes may specify a non-zero \fB\-width\fR -in the style. .\" Not documented -- may go away .\" .OP \-padding padding Padding .\" .OP \-foreground foreground Foreground diff --git a/doc/ttk_widget.n b/doc/ttk_widget.n index f8bf98b..3d3d52e 100644 --- a/doc/ttk_widget.n +++ b/doc/ttk_widget.n @@ -127,6 +127,8 @@ If greater than zero, specifies how much space, in character widths, to allocate for the text label. If less than zero, specifies a minimum width. If zero or unspecified, the natural width of the text label is used. +Note that some themes may specify a non-zero \fB\-width\fR +in the style. .OP \-wraplength wrapLength WrapLength Specifies the maximum line length (in pixels). If this option is less than or equal to zero, -- cgit v0.12 From 2a9ec78640adf4771ef371035ab3d4bb5207acf2 Mon Sep 17 00:00:00 2001 From: fvogel Date: Sat, 11 Mar 2017 10:38:10 +0000 Subject: Add minimal testing of the ttk::progressbar options --- tests/ttk/progressbar.test | 15 +++++++++++++++ 1 file changed, 15 insertions(+) diff --git a/tests/ttk/progressbar.test b/tests/ttk/progressbar.test index b9add86..bd53f2e 100644 --- a/tests/ttk/progressbar.test +++ b/tests/ttk/progressbar.test @@ -82,4 +82,19 @@ test progressbar-end "Cleanup" -body { destroy .pb } +# check existence and default value of each non-core option of the widget +test progressbar-3.1 "progressbar non-core options" -setup { + set res {} + ttk::progressbar .defaultpb +} -body { + foreach option {-anchor -foreground -justify -style -text -wraplength \ + -length -maximum -mode -orient -phase -value -variable} { + lappend res [.defaultpb cget $option] + } + set res +} -cleanup { + unset res + destroy .defaultpb +} -result {w black left {} {} 0 100 100 determinate horizontal 0 0.0 {}} + tcltest::cleanupTests -- cgit v0.12 From 11e3592a11d54f1f9be294b842a526a9c3c6ef67 Mon Sep 17 00:00:00 2001 From: fvogel Date: Mon, 13 Mar 2017 13:33:38 +0000 Subject: =?UTF-8?q?Add=20test=20progressbar-3.2=20(tweaked=20from=20a=20pr?= =?UTF-8?q?oposal=20from=20Ren=C3=A9=20Zaumseil)?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- tests/ttk/progressbar.test | 24 ++++++++++++++++++++++++ 1 file changed, 24 insertions(+) diff --git a/tests/ttk/progressbar.test b/tests/ttk/progressbar.test index bd53f2e..7c888c6 100644 --- a/tests/ttk/progressbar.test +++ b/tests/ttk/progressbar.test @@ -97,4 +97,28 @@ test progressbar-3.1 "progressbar non-core options" -setup { destroy .defaultpb } -result {w black left {} {} 0 100 100 determinate horizontal 0 0.0 {}} +test progressbar-3.2 "TIP #442 options are taken into account" -setup { + set res {} + pack [ttk::progressbar .p -value 0 -maximum 50 -orient horizontal -mode determinate -length 500] + set thefont [font actual {Arial 10}] +} -body { + .p configure -anchor c -foreground blue -justify right \ + -text "TIP #442\noptions are now tested" -wraplength 100 + update + .p step 10 + .p configure -anchor e -font $thefont -foreground green -justify center \ + -text "Changing the value of each option\nfrom TIP #442" -wraplength 250 + update + .p step 20 + .p configure -orient vertical -text "Cannot be seen" + update + foreach option {-anchor -foreground -justify -text -wraplength} { + lappend res [list $option [.p cget $option]] + } + set res +} -cleanup { + unset res thefont + destroy .p +} -result {{-anchor e} {-foreground green} {-justify center} {-text {Cannot be seen}} {-wraplength 250}} + tcltest::cleanupTests -- cgit v0.12 From 32b29153c1c63a7e08d4325c1fe68ae511a5ed36 Mon Sep 17 00:00:00 2001 From: fvogel Date: Mon, 13 Mar 2017 13:43:12 +0000 Subject: Reorder progressbar options alphabetically (to follow the standard convention in the source code) --- generic/ttk/ttkProgress.c | 64 +++++++++++++++++++++++------------------------ 1 file changed, 32 insertions(+), 32 deletions(-) diff --git a/generic/ttk/ttkProgress.c b/generic/ttk/ttkProgress.c index bd0b814..7787390 100644 --- a/generic/ttk/ttkProgress.c +++ b/generic/ttk/ttkProgress.c @@ -23,18 +23,18 @@ static const char *const ProgressbarModeStrings[] = { }; typedef struct { - Tcl_Obj *orientObj; + Tcl_Obj *anchorObj; + Tcl_Obj *fontObj; + Tcl_Obj *foregroundObj; + Tcl_Obj *justifyObj; Tcl_Obj *lengthObj; - Tcl_Obj *modeObj; - Tcl_Obj *variableObj; Tcl_Obj *maximumObj; - Tcl_Obj *valueObj; + Tcl_Obj *modeObj; + Tcl_Obj *orientObj; Tcl_Obj *phaseObj; Tcl_Obj *textObj; - Tcl_Obj *fontObj; - Tcl_Obj *foregroundObj; - Tcl_Obj *anchorObj; - Tcl_Obj *justifyObj; + Tcl_Obj *valueObj; + Tcl_Obj *variableObj; Tcl_Obj *wrapLengthObj; int mode; @@ -52,43 +52,43 @@ typedef struct { static Tk_OptionSpec ProgressbarOptionSpecs[] = { - {TK_OPTION_STRING_TABLE, "-orient", "orient", "Orient", - "horizontal", Tk_Offset(Progressbar,progress.orientObj), -1, - 0, (ClientData)ttkOrientStrings, STYLE_CHANGED }, + {TK_OPTION_ANCHOR, "-anchor", "anchor", "Anchor", + "w", Tk_Offset(Progressbar,progress.anchorObj), -1, + TK_OPTION_NULL_OK, 0, GEOMETRY_CHANGED}, + {TK_OPTION_FONT, "-font", "font", "Font", + DEFAULT_FONT, Tk_Offset(Progressbar,progress.fontObj), -1, + TK_OPTION_NULL_OK,0,GEOMETRY_CHANGED }, + {TK_OPTION_COLOR, "-foreground", "textColor", "TextColor", + "black", Tk_Offset(Progressbar,progress.foregroundObj), -1, + TK_OPTION_NULL_OK,0,0 }, + {TK_OPTION_JUSTIFY, "-justify", "justify", "Justify", + "left", Tk_Offset(Progressbar,progress.justifyObj), -1, + TK_OPTION_NULL_OK,0,GEOMETRY_CHANGED }, {TK_OPTION_PIXELS, "-length", "length", "Length", DEF_PROGRESSBAR_LENGTH, Tk_Offset(Progressbar,progress.lengthObj), -1, 0, 0, GEOMETRY_CHANGED }, + {TK_OPTION_DOUBLE, "-maximum", "maximum", "Maximum", + "100", Tk_Offset(Progressbar,progress.maximumObj), -1, + 0, 0, 0 }, {TK_OPTION_STRING_TABLE, "-mode", "mode", "ProgressMode", "determinate", Tk_Offset(Progressbar,progress.modeObj), Tk_Offset(Progressbar,progress.mode), 0, (ClientData)ProgressbarModeStrings, 0 }, - {TK_OPTION_DOUBLE, "-maximum", "maximum", "Maximum", - "100", Tk_Offset(Progressbar,progress.maximumObj), -1, - 0, 0, 0 }, - {TK_OPTION_STRING, "-variable", "variable", "Variable", - NULL, Tk_Offset(Progressbar,progress.variableObj), -1, - TK_OPTION_NULL_OK, 0, 0 }, - {TK_OPTION_DOUBLE, "-value", "value", "Value", - "0.0", Tk_Offset(Progressbar,progress.valueObj), -1, - 0, 0, 0 }, + {TK_OPTION_STRING_TABLE, "-orient", "orient", "Orient", + "horizontal", Tk_Offset(Progressbar,progress.orientObj), -1, + 0, (ClientData)ttkOrientStrings, STYLE_CHANGED }, {TK_OPTION_INT, "-phase", "phase", "Phase", "0", Tk_Offset(Progressbar,progress.phaseObj), -1, 0, 0, 0 }, {TK_OPTION_STRING, "-text", "text", "Text", "", Tk_Offset(Progressbar,progress.textObj), -1, 0,0,GEOMETRY_CHANGED }, - {TK_OPTION_FONT, "-font", "font", "Font", - DEFAULT_FONT, Tk_Offset(Progressbar,progress.fontObj), -1, - TK_OPTION_NULL_OK,0,GEOMETRY_CHANGED }, - {TK_OPTION_COLOR, "-foreground", "textColor", "TextColor", - "black", Tk_Offset(Progressbar,progress.foregroundObj), -1, - TK_OPTION_NULL_OK,0,0 }, - {TK_OPTION_ANCHOR, "-anchor", "anchor", "Anchor", - "w", Tk_Offset(Progressbar,progress.anchorObj), -1, - TK_OPTION_NULL_OK, 0, GEOMETRY_CHANGED}, - {TK_OPTION_JUSTIFY, "-justify", "justify", "Justify", - "left", Tk_Offset(Progressbar,progress.justifyObj), -1, - TK_OPTION_NULL_OK,0,GEOMETRY_CHANGED }, + {TK_OPTION_DOUBLE, "-value", "value", "Value", + "0.0", Tk_Offset(Progressbar,progress.valueObj), -1, + 0, 0, 0 }, + {TK_OPTION_STRING, "-variable", "variable", "Variable", + NULL, Tk_Offset(Progressbar,progress.variableObj), -1, + TK_OPTION_NULL_OK, 0, 0 }, {TK_OPTION_PIXELS, "-wraplength", "wrapLength", "WrapLength", "0", Tk_Offset(Progressbar, progress.wrapLengthObj), -1, TK_OPTION_NULL_OK,0,GEOMETRY_CHANGED}, -- cgit v0.12 From c1648c48e32da4bf83827f3a11abed72a94640c8 Mon Sep 17 00:00:00 2001 From: fvogel Date: Mon, 13 Mar 2017 13:59:57 +0000 Subject: Document units for -length and -wraplength --- doc/ttk_progressbar.n | 3 ++- doc/ttk_widget.n | 6 +++--- 2 files changed, 5 insertions(+), 4 deletions(-) diff --git a/doc/ttk_progressbar.n b/doc/ttk_progressbar.n index 33da815..6967bd4 100644 --- a/doc/ttk_progressbar.n +++ b/doc/ttk_progressbar.n @@ -33,7 +33,8 @@ then these options are ignored. .SH "WIDGET-SPECIFIC OPTIONS" .OP \-length length Length Specifies the length of the long axis of the progress bar -(width if horizontal, height if vertical). +(width if horizontal, height if vertical). The value may have any of the forms +acceptable to \fBTk_GetPixels\fR. .OP \-maximum maximum Maximum A floating point number specifying the maximum \fB\-value\fR. Defaults to 100. diff --git a/doc/ttk_widget.n b/doc/ttk_widget.n index 3d3d52e..7a770cc 100644 --- a/doc/ttk_widget.n +++ b/doc/ttk_widget.n @@ -130,9 +130,9 @@ If zero or unspecified, the natural width of the text label is used. Note that some themes may specify a non-zero \fB\-width\fR in the style. .OP \-wraplength wrapLength WrapLength -Specifies the maximum line length (in pixels). -If this option is less than or equal to zero, -then automatic wrapping is not performed; otherwise +Specifies the maximum line length. The value may have any of the forms +acceptable to \fBTk_GetPixels\fR. If this option is less than or equal +to zero, then automatic wrapping is not performed; otherwise the text is split into lines such that no line is longer than the specified value. .SH "COMPATIBILITY OPTIONS" -- cgit v0.12 From f3cb1aadffad99fd9e2e5ecf33afefceb2b4efe1 Mon Sep 17 00:00:00 2001 From: fvogel Date: Mon, 13 Mar 2017 14:10:32 +0000 Subject: Document -font for ttk::progressbar --- doc/ttk_label.n | 4 +--- doc/ttk_progressbar.n | 8 ++++---- doc/ttk_widget.n | 2 ++ 3 files changed, 7 insertions(+), 7 deletions(-) diff --git a/doc/ttk_label.n b/doc/ttk_label.n index a9e7f11..c11240f 100644 --- a/doc/ttk_label.n +++ b/doc/ttk_label.n @@ -19,7 +19,7 @@ The label may be linked to a Tcl variable to automatically change the displayed text. .SO ttk_widget \-anchor \-class \-compound \-cursor -\-foreground +\-font \-foreground \-image \-justify \-style \-takefocus \-text \-textvariable \-underline \-width \-wraplength @@ -28,8 +28,6 @@ to automatically change the displayed text. .OP \-background frameColor FrameColor The widget's background color. If unspecified, the theme default is used. -.OP \-font font Font -Font to use for label text. .OP \-padding padding Padding Specifies the amount of extra space to allocate for the widget. The padding is a list of up to four length specifications diff --git a/doc/ttk_progressbar.n b/doc/ttk_progressbar.n index 6967bd4..74d9698 100644 --- a/doc/ttk_progressbar.n +++ b/doc/ttk_progressbar.n @@ -22,12 +22,12 @@ that something is happening. .PP If the value of \fB-orient\fR is \fBhorizontal\fR a text string can be displayed inside the progressbar. This string can be configured using -the \fB-anchor\fR, \fB-text\fR, \fB-foreground\fR, \fB-justify\fR and -\fB-wraplength\fR options. If the value of \fB-orient\fR is \fBvertical\fR -then these options are ignored. +the \fB-anchor\fR, \fB-font\fR, \fB-foreground\fR, \fB-justify\fR, +\fB-text\fR and \fB-wraplength\fR options. If the value of \fB-orient\fR +is \fBvertical\fR then these options are ignored. .SO ttk_widget \-anchor \-class \-cursor -\-foreground \-justify \-style +\-font \-foreground \-justify \-style \-takefocus \-text \-wraplength .SE .SH "WIDGET-SPECIFIC OPTIONS" diff --git a/doc/ttk_widget.n b/doc/ttk_widget.n index 7a770cc..d2916f1 100644 --- a/doc/ttk_widget.n +++ b/doc/ttk_widget.n @@ -96,6 +96,8 @@ Display image above, below, left of, or right of the text, respectively. .IP none The default; display the image if present, otherwise the text. .RE +.OP \-font font Font +Font to use for the text displayed by the widget. .OP \-foreground textColor TextColor The widget's foreground color. If unspecified, the theme default is used. -- cgit v0.12 From 1d6a2ca5b4916f5d7ebb7b024f55d24ccc2303fb Mon Sep 17 00:00:00 2001 From: fvogel Date: Mon, 13 Mar 2017 14:18:42 +0000 Subject: Add minimal test of -justify for ttk::button --- tests/ttk/ttk.test | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/tests/ttk/ttk.test b/tests/ttk/ttk.test index 93dba34..6760b80 100644 --- a/tests/ttk/ttk.test +++ b/tests/ttk/ttk.test @@ -134,8 +134,8 @@ test ttk-selfdestruct-ok-1 "Intentional self-destruction" -body { # # Basic tests. # -test ttk-1.1 "Create button" -body { - pack [ttk::button .t] -expand true -fill both +test ttk-1.1 "Create multiline button showing justified text" -body { + pack [ttk::button .t -text "Hello\nWorld!!" -justify center] -expand true -fill both update } -- cgit v0.12 From 55151fc4c44b0502f0d62d7947cbbf0597d5fcac Mon Sep 17 00:00:00 2001 From: fvogel Date: Tue, 21 Mar 2017 21:22:44 +0000 Subject: Fixed [ddac78bd5e]: Incomplete documentation for ttk::entry --- doc/ttk_entry.n | 6 +++--- 1 file changed, 3 insertions(+), 3 deletions(-) diff --git a/doc/ttk_entry.n b/doc/ttk_entry.n index 984e957..5f72707 100644 --- a/doc/ttk_entry.n +++ b/doc/ttk_entry.n @@ -23,7 +23,9 @@ with the \fB\-textvariable\fR option. Entry widgets support horizontal scrolling with the standard \fB\-xscrollcommand\fR option and \fBxview\fR widget command. .SO ttk_widget -\-class \-cursor \-style +\-class \-cursor +\-font \-foreground +\-style \-takefocus \-xscrollcommand .SE .SH "WIDGET-SPECIFIC OPTIONS" @@ -34,8 +36,6 @@ If the selection is exported, then selecting in the widget deselects the current X selection, selecting outside the widget deselects any widget selection, and the widget will respond to selection retrieval requests when it has a selection. -.\" MAYBE: .OP \-font font Font -.\" MAYBE: .OP \-foreground foreground Foreground .\" MAYBE: .OP \-insertbackground insertBackground Foreground .\" MAYBE: .OP \-insertwidth insertWidth InsertWidth .OP \-invalidcommand invalidCommand InvalidCommand -- cgit v0.12 From ab9f98cc8e92cbe59655b280a6a8fffc1bcff60e Mon Sep 17 00:00:00 2001 From: "jan.nijtmans" Date: Fri, 24 Mar 2017 13:26:52 +0000 Subject: Add test-case for [http://core.tcl.tk/tcl/tktview/1cc44617e2b4ed0a29f75762d45fe46388260f74|1cc44617e2]: Mechanism with 64 bit support in tcl.h does not work outside of core This test-case passes on all platforms I know of. --- generic/tkTest.c | 58 ++++++++++++++++++++++++++++++++++++++++++++++++++++++++ tests/tk.test | 6 ++++++ 2 files changed, 64 insertions(+) diff --git a/generic/tkTest.c b/generic/tkTest.c index 1f801be..61153e5 100644 --- a/generic/tkTest.c +++ b/generic/tkTest.c @@ -192,6 +192,9 @@ static void CustomOptionFree(ClientData clientData, static int TestpropObjCmd(ClientData dummy, Tcl_Interp *interp, int objc, Tcl_Obj * const objv[]); +static int TestprintfObjCmd(ClientData dummy, + Tcl_Interp *interp, int objc, + Tcl_Obj * const objv[]); #if !(defined(_WIN32) || defined(MAC_OSX_TK) || defined(__CYGWIN__)) static int TestwrapperObjCmd(ClientData dummy, Tcl_Interp *interp, int objc, @@ -263,6 +266,7 @@ Tktest_Init( (ClientData) Tk_MainWindow(interp), NULL); Tcl_CreateObjCommand(interp, "testprop", TestpropObjCmd, (ClientData) Tk_MainWindow(interp), NULL); + Tcl_CreateObjCommand(interp, "testprintf", TestprintfObjCmd, NULL, NULL); Tcl_CreateObjCommand(interp, "testtext", TkpTesttextCmd, (ClientData) Tk_MainWindow(interp), NULL); @@ -1896,6 +1900,60 @@ TestpropObjCmd( return TCL_OK; } +/* + *---------------------------------------------------------------------- + * + * TestpropObjCmd -- + * + * This function implements the "testprop" command. It fetches and prints + * the value of a property on a window. + * + * Results: + * A standard Tcl result. + * + * Side effects: + * None. + * + *---------------------------------------------------------------------- + */ + + /* ARGSUSED */ +static int +TestprintfObjCmd( + ClientData clientData, /* Not used */ + Tcl_Interp *interp, /* Current interpreter. */ + int objc, /* Number of arguments. */ + Tcl_Obj *const objv[]) /* Argument strings. */ +{ + char buffer[256]; + Tcl_WideInt wideInt; +#ifdef _WIN32 + __int64 longLongInt; +#else + long long longLongInt; +#endif + + if (objc != 2) { + Tcl_WrongNumArgs(interp, 1, objv, "wideint"); + return TCL_ERROR; + } + if (Tcl_GetWideIntFromObj(interp, objv[1], &wideInt) != TCL_OK) { + return TCL_ERROR; + } + longLongInt = wideInt; + + /* Just add a lot of arguments to sprintf. Reason: on AMD64, the first + * 4 or 6 arguments (we assume 8, just in case) might be put in registers, + * which still woudn't tell if the assumed size is correct: We want this + * test-case to fail if the 64-bit value is printed as truncated to 32-bit. + */ + sprintf(buffer, "%s%s%s%s%s%s%s%s%" TCL_LL_MODIFIER "d %" + TCL_LL_MODIFIER "u", "", "", "", "", "", "", "", "", + (Tcl_WideInt)longLongInt, (Tcl_WideUInt)longLongInt); + Tcl_AppendResult(interp, buffer, NULL); + return TCL_OK; +} + #if !(defined(_WIN32) || defined(MAC_OSX_TK) || defined(__CYGWIN__)) /* *---------------------------------------------------------------------- diff --git a/tests/tk.test b/tests/tk.test index 748a6cf..c5c475e 100644 --- a/tests/tk.test +++ b/tests/tk.test @@ -10,6 +10,8 @@ eval tcltest::configure $argv tcltest::loadTestedCommands namespace import -force tcltest::test +testConstraint testprintf [llength [info command testprintf]] + test tk-1.1 {tk command: general} -body { tk } -returnCodes error -result {wrong # args: should be "tk subcommand ?arg ...?"} @@ -177,6 +179,10 @@ test tk-7.2 {tk inactive reset in a safe interpreter} -body { ::safe::interpDelete foo } -returnCodes 1 -result {resetting the user inactivity timer is not allowed in a safe interpreter} +test tk-8.1 {Test for ticket [1cc44617e2], see if TCL_LL_MODIFIER works as expected on all platforms} -constraints testprintf -body { + testprintf -21474836480 +} -result {-21474836480 18446744052234715136} + # tests of [tk busy] in busy.test # cleanup -- cgit v0.12 From 735fd7e290750c83ddd6d0e1db7e1511c306936b Mon Sep 17 00:00:00 2001 From: simonbachmann Date: Sat, 8 Apr 2017 07:17:12 +0000 Subject: Fixed bug [f0188aca9e] (color names parsing on Windows) --- tests/color.test | 22 ++++++++++++++++++++++ xlib/xcolors.c | 10 ++++++++++ 2 files changed, 32 insertions(+) diff --git a/tests/color.test b/tests/color.test index 0b328cf..4e7adfc 100644 --- a/tests/color.test +++ b/tests/color.test @@ -90,6 +90,16 @@ proc colorsFree {w {red 31} {green 245} {blue 192}} { && ([lindex $vals 2]/256 == $blue) } +# -- WARNING (SB, 6.4.2017) -- +# +# The if block below looks _very_ outdated. It didn't get any +# substatial changes as far back as the fossil history goes. It might +# be from a time, when 256 color was the best you could get! :-o. +# +# The problem is, on machines with a fancy 24 truecolor display, the +# 'colorsFree' constraint doesn't get set, turning off pretty much every test +# in this file. + if {[testConstraint psuedocolor8]} { toplevel .t -visual {pseudocolor 8} -colormap new wm geom .t +0+0 @@ -185,6 +195,18 @@ test color-2.6 {Tk_GetColor procedure} {colorsFree nonPortable} { test color-2.7 {Tk_GetColor procedure} colorsFree { winfo rgb .t #ff0000 } {65535 0 0} +test color-2.8 {Tk_GetColor, invalid char after 3 valid hex digits} -body { + winfo rgb . #abcg +} -returnCodes error -result {invalid color name "#abcg"} +test color-2.9 {Tk_GetColor, invalid char after 6 vaild hex digits} -body { + winfo rgb . #aabbccz +} -returnCodes error -result {invalid color name "#aabbccz"} +test color-2.10 {Tk_GetColor, 3 hex digits, last one invalid} -body { + winfo rgb . #abz +} -returnCodes error -result {invalid color name "#abz"} +test color-2.11 {Tk_GetColor, 6 hex digits, last one invalid} -body { + winfo rgb . #12345g +} -returnCodes error -result {invalid color name "#12345g"} test color-3.1 {Tk_FreeColor procedure, reference counting} colorsFree { eval destroy [winfo child .t] diff --git a/xlib/xcolors.c b/xlib/xcolors.c index b5e45c9..36dc67c 100644 --- a/xlib/xcolors.c +++ b/xlib/xcolors.c @@ -345,6 +345,16 @@ XParseColor( char *p; Tcl_WideInt value = parseHex64bit(++spec, &p); + /* + * If *p does not point to the end of the string, there were invalid + * digits in the spec. Ergo, it is not a vailid color string. + * (Bug f0188aca9e) + */ + + if (*p != '\0') { + return 0; + } + switch ((int)(p-spec)) { case 3: colorPtr->red = US(((value >> 8) & 0xf) * 0x1111); -- cgit v0.12 From 237cce83f9c4e30ab2544cb7329dfc13d5a12a5b Mon Sep 17 00:00:00 2001 From: fvogel Date: Sat, 8 Apr 2017 07:58:52 +0000 Subject: The typo introduced in [c483179b] does not help in running the tests in color.test. Fix that. --- tests/color.test | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/tests/color.test b/tests/color.test index 4e7adfc..4cdaf23 100644 --- a/tests/color.test +++ b/tests/color.test @@ -93,14 +93,14 @@ proc colorsFree {w {red 31} {green 245} {blue 192}} { # -- WARNING (SB, 6.4.2017) -- # # The if block below looks _very_ outdated. It didn't get any -# substatial changes as far back as the fossil history goes. It might +# substantial changes as far back as the fossil history goes. It might # be from a time, when 256 color was the best you could get! :-o. # # The problem is, on machines with a fancy 24 truecolor display, the # 'colorsFree' constraint doesn't get set, turning off pretty much every test # in this file. -if {[testConstraint psuedocolor8]} { +if {[testConstraint pseudocolor8]} { toplevel .t -visual {pseudocolor 8} -colormap new wm geom .t +0+0 mkColors .t.c 40 6 0 0 0 0 6 0 0 0 40 -- cgit v0.12