diff options
33 files changed, 159 insertions, 652 deletions
diff --git a/.travis.yml b/.travis.yml index f4fbbd4..f8cd9e2 100644 --- a/.travis.yml +++ b/.travis.yml @@ -21,8 +21,8 @@ addons: - tcl-tk - libnotify - glib - casks: - - xquartz +# casks: +# - xquartz jobs: include: # Testing on Linux GCC @@ -207,12 +207,12 @@ jobs: env: - BUILD_DIR=unix - CFGOPT="--with-tcl=/usr/local/opt/tcl-tk/lib --enable-aqua --enable-symbols CFLAGS=-I/usr/local/opt/tcl-tk/include" - - name: "macOS/Xcode 12/Shared/XQuartz" - os: osx - osx_image: xcode12 - env: - - BUILD_DIR=unix - - CFGOPT="--with-tcl=/usr/local/opt/tcl-tk/lib --disable-corefoundation --x-includes=/opt/X11/include --x-libraries=/opt/X11/lib CFLAGS=-I/usr/local/opt/tcl-tk/include" +# - name: "macOS/Xcode 12/Shared/XQuartz" +# os: osx +# osx_image: xcode12 +# env: +# - BUILD_DIR=unix +# - CFGOPT="--with-tcl=/usr/local/opt/tcl-tk/lib --disable-corefoundation --x-includes=/opt/X11/include --x-libraries=/opt/X11/lib CFLAGS=-I/usr/local/opt/tcl-tk/include" # Older MacOS versions - name: "macOS/Xcode 11/Shared" os: osx @@ -278,7 +278,15 @@ install: script: - make all tktest - make install +before_cache: + - |- + case $TRAVIS_OS_NAME in + osx) + brew cleanup + ;; + esac cache: directories: + - $HOME/Library/Caches/Homebrew - $HOME/AppData/Local/Temp/chocolatey - $HOME/AppData/Local/Apps/Tcl86 diff --git a/doc/systray.n b/doc/systray.n index da64636..bf36282 100644 --- a/doc/systray.n +++ b/doc/systray.n @@ -56,9 +56,9 @@ strings to indicate app state. Loading additional interpreters into a running instance of Wish will allow additional icons to be displayed. .SH PLATFORM NOTES .PP -The X11 implementation is supported on a "best efforts" basis because it is dependent on the window manager. The "text" -flag, which is implemented as a tooltip, does not always display if the WM -does not support such features; the systray icon itself may not even -display with some window managers. +The X11 implementation is supported on a "best efforts" basis because it is +dependent on the window manager. The "text" flag, which is implemented as a +tooltip, does not always display if the WM does not support such features; +the systray icon itself may not even display with some window managers. .SH KEYWORDS image, callback diff --git a/doc/tk_mac.n b/doc/tk_mac.n index a4206a9..2ce1374 100644 --- a/doc/tk_mac.n +++ b/doc/tk_mac.n @@ -218,11 +218,17 @@ support. .TP \fB::tk::mac::standardAboutPanel\fR . -Brings the standard Cocoa about panel to the front, with all its information -filled in from your application bundle files (standard about panel with no -options specified). See Apple Technote TN2179 and the AppKit documentation for --[NSApplication orderFrontStandardAboutPanelWithOptions:] for details on the -Info.plist keys and app bundle files used by the about panel. +Brings the standard Cocoa about panel to the front with information filled in +from the application bundle files. The panel displays the application icon and +the values associated to the info.plist keys named CFBundleName, +CFBundleShortVersionString, NSAboutPanelOptionVersion and +NSHumanReadableCopyright. If a file named \fICredits.html\fR or +\fICredits.rtf\fR exists in the bundle's Resources directory then its contents +will be displayed in a scrolling text box at the bottom of the dialog. See the +documentation for -[NSApplication orderFrontStandardAboutPanelWithOptions:] +for more details. A hook is also provided for a custom About dialog. If a Tcl +proc named tkAboutDialog is defined in the main interpreter then that +procedure will be called instead of opening the standardAboutPanel. .SH "SYSTEM CONFIGURATION" .PP There are a number of additional global configuration options that control the diff --git a/generic/tkBind.c b/generic/tkBind.c index 3776c95..3416f52 100644 --- a/generic/tkBind.c +++ b/generic/tkBind.c @@ -455,10 +455,20 @@ static const ModInfo modArray[] = { {"Button9", Button9Mask, 0}, {"Mod1", Mod1Mask, 0}, {"M1", Mod1Mask, 0}, +#ifdef MAC_OSX_TK {"Command", Mod1Mask, 0}, +#elif defined (_WIN32) + {"Command", ControlMask, 0}, +#else + {"Command", META_MASK, 0}, +#endif {"Mod2", Mod2Mask, 0}, {"M2", Mod2Mask, 0}, +#ifdef MAC_OSX_TK {"Option", Mod2Mask, 0}, +#else + {"Option", ALT_MASK, 0}, +#endif {"Mod3", Mod3Mask, 0}, {"M3", Mod3Mask, 0}, {"Mod4", Mod4Mask, 0}, diff --git a/generic/tkGet.c b/generic/tkGet.c index f2aed2c..989584e 100644 --- a/generic/tkGet.c +++ b/generic/tkGet.c @@ -694,6 +694,11 @@ TkGetDoublePixels( char *end; double d; + if (!tkwin) { + Tcl_SetObjResult(interp, Tcl_ObjPrintf("bad screen")); + Tcl_SetErrorCode(interp, "TK", "VALUE", "FRACTIONAL_PIXELS", NULL); + return TCL_ERROR; + } d = strtod((char *) string, &end); if (end == string) { goto error; diff --git a/library/button.tcl b/library/button.tcl index 39431e8..4be16b1 100644 --- a/library/button.tcl +++ b/library/button.tcl @@ -41,10 +41,10 @@ if {[tk windowingsystem] eq "aqua"} { } } if {"win32" eq [tk windowingsystem]} { - bind Checkbutton <equal> { + bind Checkbutton <=> { tk::CheckRadioInvoke %W select } - bind Checkbutton <plus> { + bind Checkbutton <+> { tk::CheckRadioInvoke %W select } bind Checkbutton <minus> { diff --git a/library/comdlg.tcl b/library/comdlg.tcl index 3dd03dc..0a7f65b 100644 --- a/library/comdlg.tcl +++ b/library/comdlg.tcl @@ -29,7 +29,8 @@ # {....} # } # -# flags = currently unused. +# flags = a list of flags. Currently supported flags are: +# DONTSETDEFAULTS = skip default values setting # # argList = The list of "-option value" pairs. # @@ -63,8 +64,10 @@ proc tclParseConfigSpec {w specs flags argList} { # 2: set the default values # - foreach cmdsw [array names cmd] { - set data($cmdsw) $def($cmdsw) + if {"DONTSETDEFAULTS" ni $flags} { + foreach cmdsw [array names cmd] { + set data($cmdsw) $def($cmdsw) + } } # 3: parse the argument list diff --git a/library/console.tcl b/library/console.tcl index 1da85be..f88cfc1 100644 --- a/library/console.tcl +++ b/library/console.tcl @@ -454,23 +454,16 @@ proc ::tk::ConsoleBind {w} { <<Console_Transpose>> <Control-t> <<Console_ClearLine>> <Control-u> <<Console_SaveCommand>> <Control-z> - <<Console_FontSizeIncr>> <Control-plus> + <<Console_FontSizeIncr>> <Control-+> <<Console_FontSizeDecr>> <Control-minus> + <<Console_FontSizeIncr>> <Command-+> + <<Console_FontSizeDecr>> <Command-minus> } { event add $ev $key bind Console $key {} } - if {[tk windowingsystem] eq "aqua"} { - foreach {ev key} { - <<Console_FontSizeIncr>> <Command-plus> - <<Console_FontSizeDecr>> <Command-minus> - } { - event add $ev $key - bind Console $key {} - } - if {$::tk::console::useFontchooser} { - bind Console <Command-t> [list ::tk::console::FontchooserToggle] - } + if {$::tk::console::useFontchooser} { + bind Console <Command-t> [list ::tk::console::FontchooserToggle] } bind Console <<Console_Expand>> { if {[%W compare insert > promptEnd]} { @@ -594,10 +587,8 @@ proc ::tk::ConsoleBind {w} { eval destroy [winfo child .] source -encoding utf-8 [file join $tk_library console.tcl] } - if {[tk windowingsystem] eq "aqua"} { - bind Console <Command-q> { - exit - } + bind Console <Command-q> { + exit } bind Console <<Cut>> { ::tk::console::Cut %W } bind Console <<Copy>> { ::tk::console::Copy %W } diff --git a/library/demos/menu.tcl b/library/demos/menu.tcl index abe70a3..a76bd54 100644 --- a/library/demos/menu.tcl +++ b/library/demos/menu.tcl @@ -63,7 +63,7 @@ if {[tk windowingsystem] eq "aqua"} { } foreach i {A B C D E F} { $m add command -label "Print letter \"$i\"" -underline 14 \ - -accelerator Meta+$i -command "puts $i" -accelerator $modifier+$i + -accelerator $modifier+$i -command "puts $i" bind $w <$modifier-[string tolower $i]> "puts $i" } diff --git a/library/entry.tcl b/library/entry.tcl index bdd9fcc..99f6eb4 100644 --- a/library/entry.tcl +++ b/library/entry.tcl @@ -209,9 +209,7 @@ bind Entry <KP_Enter> {# nothing} bind Entry <Tab> {# nothing} bind Entry <Prior> {# nothing} bind Entry <Next> {# nothing} -if {[tk windowingsystem] eq "aqua"} { - bind Entry <Command-Key> {# nothing} -} +bind Entry <Command-Key> {# nothing} # Tk-on-Cocoa generates characters for these two keys. [Bug 2971663] bind Entry <<NextLine>> {# nothing} bind Entry <<PrevLine>> {# nothing} diff --git a/library/fontchooser.tcl b/library/fontchooser.tcl index a9bd706..9d49c57 100644 --- a/library/fontchooser.tcl +++ b/library/fontchooser.tcl @@ -111,7 +111,7 @@ proc ::tk::fontchooser::Configure {args} { set cache [dict create -parent $S(-parent) -title $S(-title) \ -font $S(-font) -command $S(-command)] - set r [tclParseConfigSpec [namespace which -variable S] $specs "" $args] + set r [tclParseConfigSpec [namespace which -variable S] $specs DONTSETDEFAULTS $args] if {![winfo exists $S(-parent)]} { set code [list TK LOOKUP WINDOW $S(-parent)] set err "bad window path name \"$S(-parent)\"" diff --git a/library/spinbox.tcl b/library/spinbox.tcl index 3d479ef..ad4aacc 100644 --- a/library/spinbox.tcl +++ b/library/spinbox.tcl @@ -218,9 +218,7 @@ bind Spinbox <KP_Enter> {# nothing} bind Spinbox <Tab> {# nothing} bind Spinbox <Prior> {# nothing} bind Spinbox <Next> {# nothing} -if {[tk windowingsystem] eq "aqua"} { - bind Spinbox <Command-Key> {# nothing} -} +bind Spinbox <Command-Key> {# nothing} # On Windows, paste is done using Shift-Insert. Shift-Insert already # generates the <<Paste>> event, so we don't need to do anything here. diff --git a/library/systray.tcl b/library/systray.tcl index 7163423..47f02b2 100644 --- a/library/systray.tcl +++ b/library/systray.tcl @@ -17,7 +17,7 @@ namespace eval ::tk::systray:: { variable ::tk::systray::_iconlist set ::tk::systray::_iconlist {} - + proc _balloon {w help} { bind $w <Any-Enter> "after 1000 [list ::tk::systray::_balloon_show %W [list $help]]" bind $w <Any-Leave> "destroy %W._balloon" diff --git a/library/text.tcl b/library/text.tcl index 5d41dc3..aa6c3f5 100644 --- a/library/text.tcl +++ b/library/text.tcl @@ -306,9 +306,7 @@ bind Text <Meta-Key> {# nothing} bind Text <Control-Key> {# nothing} bind Text <Escape> {# nothing} bind Text <KP_Enter> {# nothing} -if {[tk windowingsystem] eq "aqua"} { - bind Text <Command-Key> {# nothing} -} +bind Text <Command-Key> {# nothing} # Additional emacs-like bindings: diff --git a/library/ttk/button.tcl b/library/ttk/button.tcl index e8c24a1..14460a2 100644 --- a/library/ttk/button.tcl +++ b/library/ttk/button.tcl @@ -42,7 +42,7 @@ ttk::copyBindings TButton TRadiobutton bind TRadiobutton <Up> { ttk::button::RadioTraverse %W -1 } bind TRadiobutton <Down> { ttk::button::RadioTraverse %W +1 } -# bind TCheckbutton <plus> { %W select } +# bind TCheckbutton <+> { %W select } # bind TCheckbutton <minus> { %W deselect } # activate -- diff --git a/library/ttk/notebook.tcl b/library/ttk/notebook.tcl index c5340a5..a871081 100644 --- a/library/ttk/notebook.tcl +++ b/library/ttk/notebook.tcl @@ -112,13 +112,8 @@ proc ttk::notebook::enableTraversal {nb} { catch { bind $top <Control-ISO_Left_Tab> {+ttk::notebook::TLCycleTab %W -1} } - if {[tk windowingsystem] eq "aqua"} { - bind $top <Option-Key> \ - +[list ttk::notebook::MnemonicActivation $top %K] - } else { - bind $top <Alt-Key> \ - +[list ttk::notebook::MnemonicActivation $top %K] - } + bind $top <Option-Key> \ + +[list ttk::notebook::MnemonicActivation $top %K] bind $top <Destroy> {+ttk::notebook::TLCleanup %W} } diff --git a/library/ttk/utils.tcl b/library/ttk/utils.tcl index 181c208..4b925f4 100644 --- a/library/ttk/utils.tcl +++ b/library/ttk/utils.tcl @@ -285,8 +285,8 @@ proc ttk::copyBindings {from to} { # proc ttk::bindMouseWheel {bindtag callback} { - bind $bindtag <MouseWheel> [append callback { %D -120.0}] - bind $bindtag <Option-MouseWheel> [append callback { %D -12.0}] + bind $bindtag <MouseWheel> "$callback %D -120.0" + bind $bindtag <Option-MouseWheel> "$callback %D -12.0" } ## Mousewheel bindings for standard scrollable widgets. diff --git a/macosx/Credits.html.in b/macosx/Credits.html.in new file mode 100644 index 0000000..cc409b1 --- /dev/null +++ b/macosx/Credits.html.in @@ -0,0 +1,24 @@ +<!doctype htmL> +<html> +<head> +</head> +<body style="font-size:120%;font-family:Arial,sans-serif;"> +<p> +Tcl and Tk are distributed under a modified BSD license:<br> +<a href="https:www.tcl.tk/software/tcltk/license.html"> + https:www.tcl.tk/software/tcltk/license.html +</a> +</p> +<ul style="list-style-type:none;"> +<li>© 1987-@TK_YEAR@ Tcl Core Team and Contributers.</li> +<li>© 2011-@TK_YEAR@ Kevin Walzer/WordTech Communications LLC.</li> +<li>© 2014-@TK_YEAR@ Marc Culler.</li> +<li>© 2002-2012 Daniel A. Steffen.</li> +<li>© 2001-2009 Apple Inc.</li> +<li>© 2001-2002 Jim Ingham & Ian Reid.</li> +<li>© 1998-2000 Jim Ingham & Ray Johnson.</li> +<li>© 1998-2000 Scriptics Inc.</li> +<li>© 1996-1997 Sun Microsystems Inc.</li> +</ul> +</body> +</html> diff --git a/macosx/tkMacOSXColor.c b/macosx/tkMacOSXColor.c index 2bcbd4e..4fe3ce4 100644 --- a/macosx/tkMacOSXColor.c +++ b/macosx/tkMacOSXColor.c @@ -282,6 +282,7 @@ GetRGBA( if (!sRGB) { sRGB = [NSColorSpace sRGBColorSpace]; } + switch (entry->type) { case rgbColor: rgba[0] = ((pixel >> 16) & 0xff) / 255.0; @@ -430,22 +431,21 @@ TkMacOSXInDarkMode(Tk_Window tkwin) * Sets the components of a CGColorRef from an XColor pixel value. The * pixel value is used to look up the color in the system color table, and * then SetCGColorComponents is called with the table entry and the pixel - * value. + * value. The parameter macColor should be a pointer to a CGColorRef. * * Results: * Returns false if the color is not found, true otherwise. * * Side effects: - * The variable macColor is set to a new CGColorRef, the caller is - * responsible for releasing it! + * The CGColorRef referenced by the variable macColor may be modified. * *---------------------------------------------------------------------- */ int TkSetMacColor( - unsigned long pixel, /* Pixel value to convert. */ - void *macColor) /* CGColorRef to modify. */ + unsigned long pixel, /* Pixel value to convert. */ + void *macColor) /* CGColorRef to modify. */ { CGColorRef *color = (CGColorRef*)macColor; SystemColorDatum *entry = GetEntryFromPixel(pixel); @@ -460,118 +460,6 @@ TkSetMacColor( /* *---------------------------------------------------------------------- * - * TkpInitGCCache, TkpFreeGCCache, CopyCachedColor, SetCachedColor -- - * - * Maintain a per-GC cache of previously converted CGColorRefs - * - * Results: - * None resp. retained CGColorRef for CopyCachedColor() - * - * Side effects: - * None. - * - *---------------------------------------------------------------------- - */ - -void -TkpInitGCCache( - GC gc) -{ - bzero(TkpGetGCCache(gc), sizeof(TkpGCCache)); -} - -void -TkpFreeGCCache( - GC gc) -{ - TkpGCCache *gcCache = TkpGetGCCache(gc); - - if (gcCache->cachedForegroundColor) { - CFRelease(gcCache->cachedForegroundColor); - } - if (gcCache->cachedBackgroundColor) { - CFRelease(gcCache->cachedBackgroundColor); - } -} - -static CGColorRef -CopyCachedColor( - GC gc, - unsigned long pixel) -{ - TkpGCCache *gcCache = TkpGetGCCache(gc); - CGColorRef cgColor = NULL; - - if (gcCache) { - if (gcCache->cachedForeground == pixel) { - cgColor = gcCache->cachedForegroundColor; - } else if (gcCache->cachedBackground == pixel) { - cgColor = gcCache->cachedBackgroundColor; - } - if (cgColor) { - CFRetain(cgColor); - } - } - return cgColor; -} - -static void -SetCachedColor( - GC gc, - unsigned long pixel, - CGColorRef cgColor) -{ - TkpGCCache *gcCache = TkpGetGCCache(gc); - - if (gcCache && cgColor) { - if (gc->foreground == pixel) { - if (gcCache->cachedForegroundColor) { - CFRelease(gcCache->cachedForegroundColor); - } - gcCache->cachedForegroundColor = (CGColorRef) CFRetain(cgColor); - gcCache->cachedForeground = pixel; - } else if (gc->background == pixel) { - if (gcCache->cachedBackgroundColor) { - CFRelease(gcCache->cachedBackgroundColor); - } - gcCache->cachedBackgroundColor = (CGColorRef) CFRetain(cgColor); - gcCache->cachedBackground = pixel; - } - } -} - -/* - *---------------------------------------------------------------------- - * - * TkMacOSXCreateCGColor -- - * - * Creates a CGColorRef from a X style pixel value. - * - * Results: - * Returns NULL if not a real pixel, CGColorRef otherwise. - * - * Side effects: - * None - * - *---------------------------------------------------------------------- - */ - -CGColorRef -TkMacOSXCreateCGColor( - GC gc, - unsigned long pixel) /* Pixel value to convert. */ -{ - CGColorRef cgColor = CopyCachedColor(gc, pixel); - - if (!cgColor && TkSetMacColor(pixel, &cgColor)) { - SetCachedColor(gc, pixel, cgColor); - } - return cgColor; -} - -/* - *---------------------------------------------------------------------- - * * TkMacOSXGetNSColor -- * * Creates an autoreleased NSColor from a X style pixel value. @@ -588,22 +476,16 @@ TkMacOSXCreateCGColor( NSColor* TkMacOSXGetNSColor( - GC gc, + TCL_UNUSED(GC), unsigned long pixel) /* Pixel value to convert. */ { - CGColorRef cgColor = TkMacOSXCreateCGColor(gc, pixel); + CGColorRef cgColor; NSColor *nsColor = nil; - if (cgColor) { - NSColorSpace *colorSpace = [[NSColorSpace alloc] - initWithCGColorSpace:CGColorGetColorSpace(cgColor)]; - - nsColor = [NSColor colorWithColorSpace:colorSpace - components:CGColorGetComponents(cgColor) - count:CGColorGetNumberOfComponents(cgColor)]; - [colorSpace release]; - CFRelease(cgColor); - } + TkSetMacColor(pixel, &cgColor); + nsColor = [NSColor colorWithColorSpace:sRGB + components:CGColorGetComponents(cgColor) + count:CGColorGetNumberOfComponents(cgColor)]; return nsColor; } @@ -627,7 +509,7 @@ TkMacOSXGetNSColor( void TkMacOSXSetColorInContext( - GC gc, + TCL_UNUSED(GC), unsigned long pixel, CGContextRef context) { @@ -646,9 +528,7 @@ TkMacOSXSetColorInContext( } break; default: - if (SetCGColorComponents(entry, pixel, &cgColor)){ - SetCachedColor(gc, pixel, cgColor); - } + SetCGColorComponents(entry, pixel, &cgColor); break; } } diff --git a/macosx/tkMacOSXDialog.c b/macosx/tkMacOSXDialog.c index 478da71..91383d2 100644 --- a/macosx/tkMacOSXDialog.c +++ b/macosx/tkMacOSXDialog.c @@ -1315,64 +1315,9 @@ Tk_ChooseDirectoryObjCmd( void TkAboutDlg(void) { - NSImage *image; - NSString *path = [NSApp tkFrameworkImagePath: @"Tk.tiff"]; - - if (path) { - image = [[[NSImage alloc] initWithContentsOfFile:path] autorelease]; - } else { - image = [NSApp applicationIconImage]; - } - - NSDateFormatter *dateFormatter = [[NSDateFormatter alloc] init]; - - [dateFormatter setFormatterBehavior:NSDateFormatterBehavior10_4]; - [dateFormatter setDateFormat:@"Y"]; - - NSString *year = [dateFormatter stringFromDate:[NSDate date]]; - - [dateFormatter release]; - - /* - * This replaces the old about dialog with a standard alert that displays - * correctly on 10.14. - */ - - NSString *version = @"Tcl " TCL_PATCH_LEVEL " & Tk " TCL_PATCH_LEVEL; - NSString *url = @"www.tcl-lang.org"; - NSTextView *credits = [[NSTextView alloc] initWithFrame:NSMakeRect(0,0,300,300)]; - NSFont *font = [NSFont systemFontOfSize:[NSFont systemFontSize]]; - NSDictionary *textAttributes = [NSDictionary dictionaryWithObject:font - forKey:NSFontAttributeName]; - - [credits insertText: [[NSAttributedString alloc] - initWithString:[NSString stringWithFormat: @"\n" - "Tcl and Tk are distributed under a modified BSD license: " - "www.tcl.tk/software/tcltk/license.html\n\n" - "%1$C 1987-%2$@ Tcl Core Team and Contributers.\n\n" - "%1$C 2011-%2$@ Kevin Walzer/WordTech Communications LLC.\n\n" - "%1$C 2014-%2$@ Marc Culler.\n\n" - "%1$C 2002-2012 Daniel A. Steffen.\n\n" - "%1$C 2001-2009 Apple Inc.\n\n" - "%1$C 2001-2002 Jim Ingham & Ian Reid\n\n" - "%1$C 1998-2000 Jim Ingham & Ray Johnson\n\n" - "%1$C 1998-2000 Scriptics Inc.\n\n" - "%1$C 1996-1997 Sun Microsystems Inc.", 0xA9, year] - attributes:textAttributes] - replacementRange:NSMakeRange(0,0)]; - [credits setDrawsBackground:NO]; - [credits setEditable:NO]; - - NSAlert *about = [[NSAlert alloc] init]; - - [[about window] setTitle:@"About Tcl & Tk"]; - [about setMessageText: version]; - [about setInformativeText:url]; - about.accessoryView = credits; - [about runModal]; - [about release]; + [NSApp orderFrontStandardAboutPanel:nil]; } - + /* *---------------------------------------------------------------------- * @@ -1400,7 +1345,7 @@ TkMacOSXStandardAboutPanelObjCmd( Tcl_WrongNumArgs(interp, 1, objv, NULL); return TCL_ERROR; } - TkAboutDlg(); + [NSApp orderFrontStandardAboutPanel:nil]; return TCL_OK; } diff --git a/macosx/tkMacOSXFont.c b/macosx/tkMacOSXFont.c index 6c66ed8..c062b16 100644 --- a/macosx/tkMacOSXFont.c +++ b/macosx/tkMacOSXFont.c @@ -1209,10 +1209,9 @@ TkpDrawAngledCharsInContext( } context = drawingContext.context; - fg = TkMacOSXCreateCGColor(gc, gc->foreground); + TkSetMacColor(gc->foreground, &fg); attributes = [fontPtr->nsAttributes mutableCopy]; [attributes setObject:(id)fg forKey:(id)kCTForegroundColorAttributeName]; - CFRelease(fg); nsFont = [attributes objectForKey:NSFontAttributeName]; [nsFont setInContext:GET_NSCONTEXT(context, NO)]; CGContextSetTextMatrix(context, CGAffineTransformIdentity); diff --git a/macosx/tkMacOSXInt.h b/macosx/tkMacOSXInt.h index 6e7e3b2..b0af85b 100644 --- a/macosx/tkMacOSXInt.h +++ b/macosx/tkMacOSXInt.h @@ -101,21 +101,6 @@ typedef struct TkWindowPrivate MacDrawable; */ /* - * GC CGColorRef cache for tkMacOSXColor.c - */ - -typedef struct { - unsigned long cachedForeground; - CGColorRef cachedForegroundColor; - unsigned long cachedBackground; - CGColorRef cachedBackgroundColor; -} TkpGCCache; - -MODULE_SCOPE TkpGCCache *TkpGetGCCache(GC gc); -MODULE_SCOPE void TkpInitGCCache(GC gc); -MODULE_SCOPE void TkpFreeGCCache(GC gc); - -/* * Undef compatibility platform types defined above. */ diff --git a/macosx/tkMacOSXMenus.c b/macosx/tkMacOSXMenus.c index 80ee992..fe53f25 100644 --- a/macosx/tkMacOSXMenus.c +++ b/macosx/tkMacOSXMenus.c @@ -203,7 +203,7 @@ static Tcl_Obj * GetWidgetDemoPath(Tcl_Interp *interp); if (!_eventInterp || !Tcl_FindCommand(_eventInterp, "tkAboutDialog", NULL, 0) || (GetCurrentEventKeyModifiers() & optionKey)) { - TkAboutDlg(); + [super orderFrontStandardAboutPanel:nil]; } else { int code = Tcl_EvalEx(_eventInterp, "tkAboutDialog", -1, TCL_EVAL_GLOBAL); diff --git a/macosx/tkMacOSXPrivate.h b/macosx/tkMacOSXPrivate.h index 6bee883..ef2bd1d 100644 --- a/macosx/tkMacOSXPrivate.h +++ b/macosx/tkMacOSXPrivate.h @@ -272,7 +272,6 @@ MODULE_SCOPE NSImage* TkMacOSXGetNSImageFromTkImage(Display *display, Tk_Image image, int width, int height); MODULE_SCOPE NSImage* TkMacOSXGetNSImageFromBitmap(Display *display, Pixmap bitmap, GC gc, int width, int height); -MODULE_SCOPE CGColorRef TkMacOSXCreateCGColor(GC gc, unsigned long pixel); MODULE_SCOPE NSColor* TkMacOSXGetNSColor(GC gc, unsigned long pixel); MODULE_SCOPE NSFont* TkMacOSXNSFontForFont(Tk_Font tkfont); MODULE_SCOPE NSDictionary* TkMacOSXNSFontAttributesForFont(Tk_Font tkfont); diff --git a/tests/fontchooser.test b/tests/fontchooser.test index f36ddf2..a149ccb 100644 --- a/tests/fontchooser.test +++ b/tests/fontchooser.test @@ -11,7 +11,7 @@ testConstraint failsOnUbuntuNoXft [expr {[testConstraint failsOnUbuntu] || (![ca # the following helper functions are related to the functions used # in winDialog.test where they are used to send messages to the win32 -# dialog (hence the wierdness). +# dialog (hence the weirdness). proc start {cmd} { set ::tk_dialog {} @@ -193,6 +193,12 @@ test fontchooser-4.4 {fontchooser -font} -constraints {scriptImpl failsOnUbuntuN lrange $::testfont 1 end } -result {14 bold} +test fontchooser-5.1 {fontchooser multiple configure} -constraints {scriptImpl} -body { + tk fontchooser configure -title TestTitle -command foo + tk fontchooser configure -command bar + tk fontchooser configure -title +} -result {TestTitle} + # ------------------------------------------------------------------------- cleanupTests diff --git a/unix/configure b/unix/configure index 2b6c983..584d7d6 100755 --- a/unix/configure +++ b/unix/configure @@ -8150,8 +8150,9 @@ $as_echo "static library" >&6; } echo "$LDFLAGS " | grep -q -- '-prebind ' && TK_SHLIB_LD_EXTRAS="${TK_SHLIB_LD_EXTRAS}"' -seg1addr 0xb000000' TK_SHLIB_LD_EXTRAS="${TK_SHLIB_LD_EXTRAS}"' -sectcreate __TEXT __info_plist Tk-Info.plist' EXTRA_WISH_LIBS='-sectcreate __TEXT __info_plist Wish-Info.plist' + EXTRA_WISH_LIBS=${EXTRA_WISH_LIBS}' -sectcreate __TEXT __credits_html Credits.html' EXTRA_APP_CC_SWITCHES="${EXTRA_APP_CC_SWITCHES}"' -mdynamic-no-pic' - ac_config_files="$ac_config_files Tk-Info.plist:../macosx/Tk-Info.plist.in Wish-Info.plist:../macosx/Wish-Info.plist.in" + ac_config_files="$ac_config_files Tk-Info.plist:../macosx/Tk-Info.plist.in Wish-Info.plist:../macosx/Wish-Info.plist.in Credits.html:../macosx/Credits.html.in" for l in ${LOCALES}; do CFBUNDLELOCALIZATIONS="${CFBUNDLELOCALIZATIONS}<string>$l</string>"; done TK_YEAR="`date +%Y`" @@ -8185,6 +8186,7 @@ $as_echo "#define TK_FRAMEWORK 1" >>confdefs.h EXTRA_INSTALL="install-private-headers html-tk" EXTRA_BUILD_HTML='@ln -fs contents.htm "$(HTML_INSTALL_DIR)"/TkTOC.html' EXTRA_INSTALL_BINARIES='@echo "Installing Info.plist to $(LIB_INSTALL_DIR)/Resources/" && $(INSTALL_DATA_DIR) "$(LIB_INSTALL_DIR)/Resources" && $(INSTALL_DATA) Tk-Info.plist "$(LIB_INSTALL_DIR)/Resources/Info.plist"' + EXTRA_INSTALL_BINARIES="$EXTRA_INSTALL_BINARIES"' && echo "Installing Credits.html to $(LIB_INSTALL_DIR)/Resources/" && $(INSTALL_DATA_DIR) "$(LIB_INSTALL_DIR)/Resources" && $(INSTALL_DATA) Credits.html "$(LIB_INSTALL_DIR)/Resources"' EXTRA_INSTALL_BINARIES="$EXTRA_INSTALL_BINARIES"' && echo "Installing license.terms to $(LIB_INSTALL_DIR)/Resources/" && $(INSTALL_DATA) "$(TOP_DIR)/license.terms" "$(LIB_INSTALL_DIR)/Resources"' if test $tk_aqua = yes; then EXTRA_INSTALL_BINARIES="$EXTRA_INSTALL_BINARIES"' && echo "Installing Images to $(LIB_INSTALL_DIR)/Resources/" && $(INSTALL_DATA_DIR) "$(LIB_INSTALL_DIR)/Resources" && for i in Tk.tiff Tk.icns; do $(INSTALL_DATA) "$(MAC_OSX_DIR)/$$i" "$(LIB_INSTALL_DIR)/Resources"; done' @@ -8194,6 +8196,7 @@ $as_echo "#define TK_FRAMEWORK 1" >>confdefs.h EXTRA_INSTALL_BINARIES="$EXTRA_INSTALL_BINARIES"' && echo "Installing Wish.icns to $(BIN_INSTALL_DIR)/../Resources" && $(INSTALL_DATA_DIR) "$(BIN_INSTALL_DIR)/../Resources"' EXTRA_INSTALL_BINARIES="$EXTRA_INSTALL_BINARIES"' && $(INSTALL_DATA) "$(MAC_OSX_DIR)/Tk.icns" "$(BIN_INSTALL_DIR)/../Resources/Wish.icns"' EXTRA_INSTALL_BINARIES="$EXTRA_INSTALL_BINARIES"' && echo "Installing Wish.sdef to $(BIN_INSTALL_DIR)/../Resources" && $(INSTALL_DATA) "$(MAC_OSX_DIR)/Wish.sdef" "$(BIN_INSTALL_DIR)/../Resources"' + EXTRA_INSTALL_BINARIES="$EXTRA_INSTALL_BINARIES"' && echo "Installing Credits.html to $(BIN_INSTALL_DIR)/../Resources" && $(INSTALL_DATA) Credits.html "$(BIN_INSTALL_DIR)/../Resources"' fi EXTRA_INSTALL_BINARIES="$EXTRA_INSTALL_BINARIES"' && echo "Finalizing Tk.framework" && rm -f "$(LIB_INSTALL_DIR)/../Current" && ln -s "$(VERSION)" "$(LIB_INSTALL_DIR)/../Current" && for f in "$(LIB_FILE)" tkConfig.sh Resources Headers PrivateHeaders; do rm -f "$(LIB_INSTALL_DIR)/../../$$f" && ln -s "Versions/Current/$$f" "$(LIB_INSTALL_DIR)/../.."; done && f="$(STUB_LIB_FILE)" && rm -f "$(LIB_INSTALL_DIR)/../../$$f" && ln -s "Versions/$(VERSION)/$$f" "$(LIB_INSTALL_DIR)/../.."' # Don't use AC_DEFINE for the following as the framework version define @@ -9033,6 +9036,7 @@ do case $ac_config_target in "Tk-Info.plist") CONFIG_FILES="$CONFIG_FILES Tk-Info.plist:../macosx/Tk-Info.plist.in" ;; "Wish-Info.plist") CONFIG_FILES="$CONFIG_FILES Wish-Info.plist:../macosx/Wish-Info.plist.in" ;; + "Credits.html") CONFIG_FILES="$CONFIG_FILES Credits.html:../macosx/Credits.html.in" ;; "Tk.framework") CONFIG_COMMANDS="$CONFIG_COMMANDS Tk.framework" ;; "Makefile") CONFIG_FILES="$CONFIG_FILES Makefile:../unix/Makefile.in" ;; "tkConfig.sh") CONFIG_FILES="$CONFIG_FILES tkConfig.sh:../unix/tkConfig.sh.in" ;; diff --git a/unix/configure.ac b/unix/configure.ac index 7563f5a..2012394 100644 --- a/unix/configure.ac +++ b/unix/configure.ac @@ -669,8 +669,9 @@ if test "`uname -s`" = "Darwin" ; then echo "$LDFLAGS " | grep -q -- '-prebind ' && TK_SHLIB_LD_EXTRAS="${TK_SHLIB_LD_EXTRAS}"' -seg1addr 0xb000000' TK_SHLIB_LD_EXTRAS="${TK_SHLIB_LD_EXTRAS}"' -sectcreate __TEXT __info_plist Tk-Info.plist' EXTRA_WISH_LIBS='-sectcreate __TEXT __info_plist Wish-Info.plist' + EXTRA_WISH_LIBS=${EXTRA_WISH_LIBS}' -sectcreate __TEXT __credits_html Credits.html' EXTRA_APP_CC_SWITCHES="${EXTRA_APP_CC_SWITCHES}"' -mdynamic-no-pic' - AC_CONFIG_FILES([Tk-Info.plist:../macosx/Tk-Info.plist.in Wish-Info.plist:../macosx/Wish-Info.plist.in]) + AC_CONFIG_FILES([Tk-Info.plist:../macosx/Tk-Info.plist.in Wish-Info.plist:../macosx/Wish-Info.plist.in Credits.html:../macosx/Credits.html.in]) for l in ${LOCALES}; do CFBUNDLELOCALIZATIONS="${CFBUNDLELOCALIZATIONS}<string>$l</string>"; done TK_YEAR="`date +%Y`" fi @@ -707,6 +708,7 @@ if test "$FRAMEWORK_BUILD" = "1" ; then EXTRA_INSTALL="install-private-headers html-tk" EXTRA_BUILD_HTML='@ln -fs contents.htm "$(HTML_INSTALL_DIR)"/TkTOC.html' EXTRA_INSTALL_BINARIES='@echo "Installing Info.plist to $(LIB_INSTALL_DIR)/Resources/" && $(INSTALL_DATA_DIR) "$(LIB_INSTALL_DIR)/Resources" && $(INSTALL_DATA) Tk-Info.plist "$(LIB_INSTALL_DIR)/Resources/Info.plist"' + EXTRA_INSTALL_BINARIES="$EXTRA_INSTALL_BINARIES"' && echo "Installing Credits.html to $(LIB_INSTALL_DIR)/Resources/" && $(INSTALL_DATA_DIR) "$(LIB_INSTALL_DIR)/Resources" && $(INSTALL_DATA) Credits.html "$(LIB_INSTALL_DIR)/Resources"' EXTRA_INSTALL_BINARIES="$EXTRA_INSTALL_BINARIES"' && echo "Installing license.terms to $(LIB_INSTALL_DIR)/Resources/" && $(INSTALL_DATA) "$(TOP_DIR)/license.terms" "$(LIB_INSTALL_DIR)/Resources"' if test $tk_aqua = yes; then EXTRA_INSTALL_BINARIES="$EXTRA_INSTALL_BINARIES"' && echo "Installing Images to $(LIB_INSTALL_DIR)/Resources/" && $(INSTALL_DATA_DIR) "$(LIB_INSTALL_DIR)/Resources" && for i in Tk.tiff Tk.icns; do $(INSTALL_DATA) "$(MAC_OSX_DIR)/$$i" "$(LIB_INSTALL_DIR)/Resources"; done' @@ -716,6 +718,7 @@ if test "$FRAMEWORK_BUILD" = "1" ; then EXTRA_INSTALL_BINARIES="$EXTRA_INSTALL_BINARIES"' && echo "Installing Wish.icns to $(BIN_INSTALL_DIR)/../Resources" && $(INSTALL_DATA_DIR) "$(BIN_INSTALL_DIR)/../Resources"' EXTRA_INSTALL_BINARIES="$EXTRA_INSTALL_BINARIES"' && $(INSTALL_DATA) "$(MAC_OSX_DIR)/Tk.icns" "$(BIN_INSTALL_DIR)/../Resources/Wish.icns"' EXTRA_INSTALL_BINARIES="$EXTRA_INSTALL_BINARIES"' && echo "Installing Wish.sdef to $(BIN_INSTALL_DIR)/../Resources" && $(INSTALL_DATA) "$(MAC_OSX_DIR)/Wish.sdef" "$(BIN_INSTALL_DIR)/../Resources"' + EXTRA_INSTALL_BINARIES="$EXTRA_INSTALL_BINARIES"' && echo "Installing Credits.html to $(BIN_INSTALL_DIR)/../Resources" && $(INSTALL_DATA) Credits.html "$(BIN_INSTALL_DIR)/../Resources"' fi EXTRA_INSTALL_BINARIES="$EXTRA_INSTALL_BINARIES"' && echo "Finalizing Tk.framework" && rm -f "$(LIB_INSTALL_DIR)/../Current" && ln -s "$(VERSION)" "$(LIB_INSTALL_DIR)/../Current" && for f in "$(LIB_FILE)" tkConfig.sh Resources Headers PrivateHeaders; do rm -f "$(LIB_INSTALL_DIR)/../../$$f" && ln -s "Versions/Current/$$f" "$(LIB_INSTALL_DIR)/../.."; done && f="$(STUB_LIB_FILE)" && rm -f "$(LIB_INSTALL_DIR)/../../$$f" && ln -s "Versions/$(VERSION)/$$f" "$(LIB_INSTALL_DIR)/../.."' # Don't use AC_DEFINE for the following as the framework version define diff --git a/unix/tkUnixSysNotify.c b/unix/tkUnixSysNotify.c index b0c13c8..addb209 100755 --- a/unix/tkUnixSysNotify.c +++ b/unix/tkUnixSysNotify.c @@ -120,7 +120,7 @@ int SysNotify_Init( Tcl_Interp *interp) { - + Tcl_CreateObjCommand(interp, "_sysnotify", SysNotifyCmd, interp, SysNotifyDeleteCmd); return TCL_OK; diff --git a/win/tkWinIco.c b/win/tkWinIco.c index f0ab511..8980066 100644 --- a/win/tkWinIco.c +++ b/win/tkWinIco.c @@ -67,7 +67,7 @@ DIBNumColors( * *---------------------------------------------------------------------- */ - WORD +static WORD PaletteSize( LPSTR lpbi) { @@ -121,74 +121,6 @@ BytesPerLine( } /* - *---------------------------------------------------------------------- - * - * AdjustIconImagePointers -- - * - * Adjusts internal pointers in icon resource struct, as given by - * LPICONIMAGE lpImage - the resource to handle. Used by titlebar icon - * code. - * - * Results: - * BOOL - TRUE for success, FALSE for failure - * - *---------------------------------------------------------------------- - */ - -static BOOL -AdjustIconImagePointers( - LPICONIMAGE lpImage) -{ - /* - * Sanity check. - */ - - if (lpImage == NULL) { - return FALSE; - } - - /* - * BITMAPINFO is at beginning of bits. - */ - - lpImage->lpbi = (LPBITMAPINFO) lpImage->lpBits; - - /* - * Width - simple enough. - */ - - lpImage->Width = lpImage->lpbi->bmiHeader.biWidth; - - /* - * Icons are stored in funky format where height is doubled so account for - * that. - */ - - lpImage->Height = (lpImage->lpbi->bmiHeader.biHeight)/2; - - /* - * How many colors? - */ - - lpImage->Colors = lpImage->lpbi->bmiHeader.biPlanes - * lpImage->lpbi->bmiHeader.biBitCount; - - /* - * XOR bits follow the header and color table. - */ - - lpImage->lpXOR = (LPBYTE) FindDIBBits((LPSTR) lpImage->lpbi); - - /* - * AND bits follow the XOR bits. - */ - - lpImage->lpAND = lpImage->lpXOR + - lpImage->Height*BytesPerLine((LPBITMAPINFOHEADER) lpImage->lpbi); - return TRUE; -} - -/* * Local Variables: * mode: c * c-basic-offset: 4 diff --git a/win/tkWinIco.h b/win/tkWinIco.h index c5d81f6..75f658e 100644 --- a/win/tkWinIco.h +++ b/win/tkWinIco.h @@ -86,7 +86,6 @@ typedef struct { DWORD BytesPerLine(LPBITMAPINFOHEADER lpBMIH); LPSTR FindDIBBits(LPSTR lpbi); -WORD PaletteSize(LPSTR lpbi); WORD DIBNumColors(LPSTR lpbi); /* diff --git a/win/tkWinSysTray.c b/win/tkWinSysTray.c index e1830f4..a00cea1 100644 --- a/win/tkWinSysTray.c +++ b/win/tkWinSysTray.c @@ -76,73 +76,12 @@ static IcoInfo * firstIcoPtr = NULL; #define HANDLER_CLASS "Wtk_TaskbarHandler" static HWND CreateTaskbarHandlerWindow(void); -typedef BOOL(FAR WINAPI * LPFN_SHELLNOTIFYICONW)(DWORD, PNOTIFYICONDATAW); -typedef BOOL(FAR WINAPI * LPFN_SHELLNOTIFYICONA)(DWORD, PNOTIFYICONDATAA); - -static LPFN_SHELLNOTIFYICONA notify_funcA = NULL; -static LPFN_SHELLNOTIFYICONW notify_funcW = NULL; -static HMODULE hmod = NULL; static HWND handlerWindow = NULL; static BlockOfIconImagesPtr iconBits = NULL; /* *---------------------------------------------------------------------- * - * swaplines -- - * - * This function tries to swap the lines of the bitmap in various formats. - * - * Results: - * Swaps lines as needed. - * - * Side effects: - * Accurate rendering of bitmap. - * - *---------------------------------------------------------------------- - * - */ - -static void -swaplines(unsigned char * bits, int width, int height, int bpp) { - #define MAX_LINE 512 - unsigned char line[MAX_LINE]; - unsigned char * pline; - int i, BytesPerLine, middle, end; - if (bpp > 8) { - BytesPerLine = width * (bpp / 8); - /* for size 16 bpp 16 BytesPerLine 32 */ - /* for size 32 bpp 16 BytesPerLine 64 */ - /* for size 16 bpp 24 BytesPerLine 48 */ - /* for size 32 bpp 24 BytesPerLine 96 */ - } else { - BytesPerLine = width / (8 / bpp); - /* for size 16 bpp 8 BytesPerLine 16 */ - /* for size 32 bpp 8 BytesPerLine 32 */ - /* for size 16 bpp 4 BytesPerLine 8 */ - /* for size 32 bpp 4 BytesPerLine 16 */ - /* for size 16 bpp 1 BytesPerLine 2 */ - /* for size 32 bpp 1 BytesPerLine 4 */ - } - if (BytesPerLine < MAX_LINE) - pline = line; - else - pline = (unsigned char * ) ckalloc(BytesPerLine); - middle = (height * BytesPerLine) / 2; - end = (height - 1) * BytesPerLine; - for (i = 0; i < middle; i += BytesPerLine) { - memcpy(pline, bits + i, BytesPerLine); - memcpy(bits + i, bits + (end - i), BytesPerLine); - memcpy(bits + (end - i), pline, BytesPerLine); - } - if (pline != line) { - ckfree((char * ) pline); - } -} - - -/* - *---------------------------------------------------------------------- - * * FreeIconResource -- * * Frees memory from icon. @@ -300,45 +239,6 @@ DrawANDMask(HDC hDC, RECT Rect, LPLPICONIMAGE lpIcon) { /* *---------------------------------------------------------------------- * - * NotifyA -- - * - * Display icon in system tray on older ANSI-encoded systems. - * - * Results: - * Icon is displayed. - * - * Side effects: - * None. - * - *---------------------------------------------------------------------- - */ - - -static BOOL -NotifyA(IcoInfo * icoPtr, int oper, HICON hIcon, char * txt) { - NOTIFYICONDATAA ni; - Tcl_DString dst; - CHAR * str; - - ni.cbSize = sizeof(NOTIFYICONDATAA); - ni.hWnd = CreateTaskbarHandlerWindow(); - ni.uID = icoPtr -> id; - ni.uFlags = NIF_ICON | NIF_TIP | NIF_MESSAGE; - ni.uCallbackMessage = ICON_MESSAGE; - ni.hIcon = (HICON) hIcon; - - /* Tooltip text for system tray icon.*/ - str = (CHAR * ) Tcl_UtfToExternalDString(NULL, txt, -1, & dst); - strncpy(ni.szTip, str, 63); - ni.szTip[63] = 0; - Tcl_DStringFree( & dst); - - return notify_funcA(oper, & ni); -} - -/* - *---------------------------------------------------------------------- - * * NotifyW -- * * Display icon in system tray on more recent systems supporting Unicode. @@ -353,11 +253,10 @@ NotifyA(IcoInfo * icoPtr, int oper, HICON hIcon, char * txt) { */ static BOOL -NotifyW(IcoInfo * icoPtr, int oper, HICON hIcon, char * txt) { +NotifyW(IcoInfo * icoPtr, int oper, HICON hIcon, const char *txt) { NOTIFYICONDATAW ni; Tcl_DString dst; WCHAR * str; - Tcl_Encoding Encoding; ni.cbSize = sizeof(NOTIFYICONDATAW); ni.hWnd = CreateTaskbarHandlerWindow(); @@ -366,13 +265,11 @@ NotifyW(IcoInfo * icoPtr, int oper, HICON hIcon, char * txt) { ni.uCallbackMessage = ICON_MESSAGE; ni.hIcon = (HICON) hIcon; - Encoding = Tcl_GetEncoding(NULL, "unicode"); - str = (WCHAR * ) Tcl_UtfToExternalDString(Encoding, txt, -1, & dst); - wcsncpy(ni.szTip, str, 63); - ni.szTip[63] = 0; - Tcl_DStringFree( & dst); - Tcl_FreeEncoding(Encoding); - return notify_funcW(oper, & ni); + Tcl_DStringInit(&dst); + str = (WCHAR *)Tcl_UtfToWCharDString(txt, -1, &dst); + wcsncpy(ni.szTip, str, (Tcl_DStringLength(&dst) + 2) / 2); + Tcl_DStringFree( &dst); + return Shell_NotifyIconW(oper, &ni); } /* @@ -392,37 +289,10 @@ NotifyW(IcoInfo * icoPtr, int oper, HICON hIcon, char * txt) { */ static int -TaskbarOperation(IcoInfo * icoPtr, int oper, HICON hIcon, char * txt) { +TaskbarOperation(IcoInfo * icoPtr, int oper, HICON hIcon, const char * txt) { int result; - if (notify_funcA == NULL && notify_funcW == NULL && hmod == NULL) { - hmod = GetModuleHandle("SHELL32.DLL"); - if (hmod == NULL) - hmod = LoadLibrary("SHELL32.DLL"); - if (hmod == NULL) { - Tcl_AppendResult(icoPtr -> interp, " Could not Load SHELL32.DLL", (char * ) NULL); - return TCL_ERROR; - } - notify_funcW = (LPFN_SHELLNOTIFYICONW) GetProcAddress(hmod, "Shell_NotifyIconW"); - notify_funcA = (LPFN_SHELLNOTIFYICONA) GetProcAddress(hmod, "Shell_NotifyIconA"); - if (notify_funcW == NULL && notify_funcA == NULL) { - Tcl_AppendResult(icoPtr -> interp, - " Could not get address of Shell_NotifyIconW or Shell_NotifyIconA", - (char * ) NULL); - return TCL_ERROR; - } - } else if (notify_funcA == NULL && notify_funcW == NULL) { - Tcl_AppendResult(icoPtr -> interp, - " You probably don't have a Windows shell", (char * ) NULL); - return TCL_ERROR; - } - - if (notify_funcW != NULL) { - result = NotifyW(icoPtr, oper, hIcon, txt) || - NotifyA(icoPtr, oper, hIcon, txt); - } else { - result = NotifyA(icoPtr, oper, hIcon, txt); - } + result = NotifyW(icoPtr, oper, hIcon, txt); Tcl_SetObjResult(icoPtr -> interp, Tcl_NewIntObj(result)); if (result == 1) { @@ -632,7 +502,7 @@ GetIntDec(long theint, char * buffer, size_t len) { */ static char* -TaskbarExpandPercents(IcoInfo *icoPtr, char *msgstring, +TaskbarExpandPercents(IcoInfo *icoPtr, const char *msgstring, WPARAM wParam, LPARAM lParam, char *before, char *after, int *aftersize) { #define SPACELEFT (*aftersize-(dst-after)-1) @@ -642,7 +512,7 @@ TaskbarExpandPercents(IcoInfo *icoPtr, char *msgstring, char* dst; dst = after; while (*before) { - char *ptr=before; + const char *ptr=before; int len=1; if(*before=='%') { switch(before[1]){ @@ -719,7 +589,7 @@ TaskbarExpandPercents(IcoInfo *icoPtr, char *msgstring, } case 'H': { before++; - len = GetInt((long)icoPtr->hwndFocus, buffer, sizeof(buffer)); + len = GetInt(PTR2INT(icoPtr->hwndFocus), buffer, sizeof(buffer)); ptr = buffer; break; } @@ -774,7 +644,7 @@ TaskbarExpandPercents(IcoInfo *icoPtr, char *msgstring, static void TaskbarEval(IcoInfo * icoPtr, WPARAM wParam, LPARAM lParam) { - char * msgstring = "none"; + const char *msgstring = "none"; char evalspace[200]; int evalsize = 200; char * expanded; @@ -1012,104 +882,6 @@ DestroyHandlerWindow(void) { /* *---------------------------------------------------------------------- * - * StandardIcon -- - * - * Returns standard Windows icons. - * - * Results: - * Icons displayed. - * - * Side effects: - * None. - * - *---------------------------------------------------------------------- - */ - -static char * -StandardIcon(char * arg) { - if (!stricmp(arg, "application")) - return IDI_APPLICATION; - if (!stricmp(arg, "asterisk")) - return IDI_ASTERISK; - if (!stricmp(arg, "error")) - return IDI_ERROR; - if (!stricmp(arg, "exclamation")) - return IDI_EXCLAMATION; - if (!stricmp(arg, "hand")) - return IDI_HAND; - if (!stricmp(arg, "question")) - return IDI_QUESTION; - if (!stricmp(arg, "information")) - return IDI_INFORMATION; - if (!stricmp(arg, "warning")) - return IDI_WARNING; - if (!stricmp(arg, "winlogo")) - return IDI_WINLOGO; - return NULL; -} - - -/* - *---------------------------------------------------------------------- - * - * NameOrHandle -- - * - * Tries to get a valid window handle from a Tk-pathname for a toplevel. - * - * Results: - * Window handle obtained. - * - * Side effects: - * None. - * - *---------------------------------------------------------------------- - */ - -static int -NameOrHandle(Tcl_Interp * interp, char * arg, HWND * hwndPtr) { - #define WINFO_FRAME "wm frame " - Tk_Window tkwin; - size_t limit = 0; - char * cmd; - - if (Tcl_GetInt(interp, arg, (int * ) hwndPtr) == TCL_OK) { - return TCL_OK; - } - Tcl_ResetResult(interp); - tkwin = Tk_NameToWindow(interp, arg, Tk_MainWindow(interp)); - if (tkwin == NULL) { - Tcl_AppendResult(interp, arg, " is no valid windowpath", (char * ) NULL); - return TCL_ERROR; - } - if (!Tk_IsTopLevel(tkwin)) { - Tcl_AppendResult(interp, arg, - " is not a toplevel valid windowpath", (char * ) NULL); - return TCL_ERROR; - } - limit = strlen(arg) + strlen(WINFO_FRAME); - cmd = ckalloc((int) limit + 1); - strcpy(cmd, WINFO_FRAME); - strcat(cmd, arg); - if (Tcl_Eval(interp, cmd) == TCL_ERROR) { - return TCL_ERROR; - } - strncpy(cmd, Tcl_GetStringResult(interp), limit); - cmd[limit] = 0; - if (sscanf(cmd, "0x%x", (int * ) hwndPtr) != 1) { - Tcl_AppendResult(interp, "couldn't scan ", cmd, (char * ) NULL); - return TCL_ERROR; - } - if ( * hwndPtr == NULL) { - Tcl_AppendResult(interp, "couldn't get windowid from ", - cmd, (char * ) NULL); - return TCL_ERROR; - } - return TCL_OK; -} - -/* - *---------------------------------------------------------------------- - * * WinIcoDestroy -- * * Deletes icon and hidden window from display. @@ -1161,7 +933,7 @@ CreateIcoFromTkImage( Tk_PhotoHandle photo; Tk_PhotoImageBlock block; - int width, height, idx, bufferSize, startObj = 3; + int width, height, idx, bufferSize; union {unsigned char *ptr; void *voidPtr;} bgraPixel; union {unsigned char *ptr; void *voidPtr;} bgraMask; HICON hIcon; @@ -1307,7 +1079,9 @@ CreateIcoFromTkImage( */ static int -WinIcoCmd(ClientData clientData, Tcl_Interp * interp, +WinIcoCmd( + TCL_UNUSED(void *), + Tcl_Interp * interp, int argc, const char * argv[]) { size_t length; HICON hIcon; @@ -1475,10 +1249,13 @@ WinIcoCmd(ClientData clientData, Tcl_Interp * interp, */ static int -WinSystrayCmd(ClientData clientData, Tcl_Interp * interp, - int argc, const char * argv[]) { +WinSystrayCmd( + TCL_UNUSED(void *), + Tcl_Interp * interp, + int argc, + const char *argv[]) +{ size_t length; - HICON hIcon = NULL; IcoInfo * icoPtr; Tcl_DString infodst; Tcl_DString titledst; @@ -1532,7 +1309,7 @@ WinSystrayCmd(ClientData clientData, Tcl_Interp * interp, Tcl_DStringFree( & infodst); } - Shell_NotifyIcon(NIM_MODIFY, & ni); + Shell_NotifyIconA(NIM_MODIFY, & ni); return TCL_OK; } return TCL_OK; diff --git a/win/tkWinWm.c b/win/tkWinWm.c index 739f5f4..4c0a863 100644 --- a/win/tkWinWm.c +++ b/win/tkWinWm.c @@ -500,29 +500,6 @@ static void WmUpdateGeom(WmInfo *wmPtr, TkWindow *winPtr); #define WIDTHBYTES(bits) ((((bits) + 31)>>5)<<2) - -/* - *---------------------------------------------------------------------- - * - * PaletteSize -- - * - * Calculates the number of bytes in the color table, as given by LPSTR - * lpbi - pointer to the CF_DIB memory block. Used by titlebar icon code. - * - * Results: - * Number of bytes in the color table - * - *---------------------------------------------------------------------- - */ -static WORD -PaletteSize( - LPSTR lpbi) -{ - return (WORD) (DIBNumColors(lpbi) * sizeof(RGBQUAD)); -} - - - /* *---------------------------------------------------------------------- * @@ -13,16 +13,8 @@ */ #include "tkInt.h" - -#if !defined(MAC_OSX_TK) -# include <X11/Xlib.h> -# define TkpInitGCCache(gc) -# define TkpFreeGCCache(gc) -# define TkpGetGCCache(gc) -#else -# include <tkMacOSXInt.h> -# include <X11/Xlib.h> -# include <X11/X.h> +#include <X11/Xlib.h> +#if defined(MAC_OSX_TK) #endif @@ -30,10 +22,7 @@ typedef struct { XGCValues gc; char dash[MAX_DASH_LIST_SIZE]; -#ifdef MAC_OSX_TK - TkpGCCache cache; -#endif -} XGCValuesWithCache; +} XGCValuesWithDash; /* *---------------------------------------------------------------------- @@ -117,7 +106,7 @@ XCreateGC( * initialization. */ - gp = (GC)ckalloc(sizeof(XGCValuesWithCache)); + gp = (GC)ckalloc(sizeof(XGCValuesWithDash)); if (!gp) { return NULL; } @@ -158,32 +147,9 @@ XCreateGC( clip_mask->type = TKP_CLIP_PIXMAP; clip_mask->value.pixmap = values->clip_mask; } - TkpInitGCCache(gp); - return gp; } -#ifdef MAC_OSX_TK -/* - *---------------------------------------------------------------------- - * - * TkpGetGCCache -- - * - * Results: - * Pointer to the TkpGCCache at the end of the GC. - * - * Side effects: - * None. - * - *---------------------------------------------------------------------- - */ - -TkpGCCache* -TkpGetGCCache(GC gc) { - return (gc ? &((XGCValuesWithCache *)gc)->cache : NULL); -} -#endif - /* *---------------------------------------------------------------------- * @@ -265,7 +231,6 @@ int XFreeGC( if (gc != NULL) { FreeClipMask(gc); - TkpFreeGCCache(gc); ckfree(gc); } return Success; |