summaryrefslogtreecommitdiffstats
path: root/PCbuild/zlib.dsp
diff options
context:
space:
mode:
Diffstat (limited to 'PCbuild/zlib.dsp')
-rw-r--r--PCbuild/zlib.dsp198
1 files changed, 99 insertions, 99 deletions
diff --git a/PCbuild/zlib.dsp b/PCbuild/zlib.dsp
index ce07442..d180320 100644
--- a/PCbuild/zlib.dsp
+++ b/PCbuild/zlib.dsp
@@ -1,99 +1,99 @@
-# Microsoft Developer Studio Project File - Name="zlib" - Package Owner=<4>
-# Microsoft Developer Studio Generated Build File, Format Version 6.00
-# ** DO NOT EDIT **
-
-# TARGTYPE "Win32 (x86) Dynamic-Link Library" 0x0102
-
-CFG=zlib - Win32 Debug
-!MESSAGE This is not a valid makefile. To build this project using NMAKE,
-!MESSAGE use the Export Makefile command and run
-!MESSAGE
-!MESSAGE NMAKE /f "zlib.mak".
-!MESSAGE
-!MESSAGE You can specify a configuration when running NMAKE
-!MESSAGE by defining the macro CFG on the command line. For example:
-!MESSAGE
-!MESSAGE NMAKE /f "zlib.mak" CFG="zlib - Win32 Debug"
-!MESSAGE
-!MESSAGE Possible choices for configuration are:
-!MESSAGE
-!MESSAGE "zlib - Win32 Release" (based on "Win32 (x86) Dynamic-Link Library")
-!MESSAGE "zlib - Win32 Debug" (based on "Win32 (x86) Dynamic-Link Library")
-!MESSAGE
-
-# Begin Project
-# PROP AllowPerConfigDependencies 0
-# PROP Scc_ProjName "zlib"
-# PROP Scc_LocalPath ".."
-CPP=cl.exe
-MTL=midl.exe
-RSC=rc.exe
-
-!IF "$(CFG)" == "zlib - Win32 Release"
-
-# PROP BASE Use_MFC 0
-# PROP BASE Use_Debug_Libraries 0
-# PROP BASE Output_Dir "Release"
-# PROP BASE Intermediate_Dir "Release"
-# PROP BASE Target_Dir ""
-# PROP Use_MFC 0
-# PROP Use_Debug_Libraries 0
-# PROP Output_Dir "."
-# PROP Intermediate_Dir "x86-temp-release\zlib"
-# PROP Ignore_Export_Lib 0
-# PROP Target_Dir ""
-F90=df.exe
-# ADD BASE CPP /nologo /MT /W3 /GX /O2 /D "WIN32" /D "NDEBUG" /D "_WINDOWS" /YX /FD /c
-# ADD CPP /nologo /MD /W3 /GX /Zi /O2 /I "..\Include" /I "..\PC" /I "..\..\zlib113" /D "NDEBUG" /D "WIN32" /D "_WINDOWS" /D "ZLIB_DLL" /YX /FD /c
-# ADD BASE MTL /nologo /D "NDEBUG" /mktyplib203 /o "NUL" /win32
-# ADD MTL /nologo /D "NDEBUG" /mktyplib203 /o "NUL" /win32
-# ADD BASE RSC /l 0x409 /d "NDEBUG"
-# ADD RSC /l 0x409 /d "NDEBUG"
-BSC32=bscmake.exe
-# ADD BASE BSC32 /nologo
-# ADD BSC32 /nologo
-LINK32=link.exe
-# ADD BASE LINK32 kernel32.lib user32.lib gdi32.lib winspool.lib comdlg32.lib advapi32.lib shell32.lib ole32.lib oleaut32.lib uuid.lib odbc32.lib odbccp32.lib /nologo /subsystem:windows /dll /machine:I386
-# ADD LINK32 user32.lib kernel32.lib gdi32.lib winspool.lib comdlg32.lib advapi32.lib shell32.lib ole32.lib oleaut32.lib uuid.lib odbc32.lib odbccp32.lib ..\..\zlib113dll\static32\zlibstat.lib /nologo /base:"0x1e1B0000" /subsystem:windows /dll /debug /machine:I386 /nodefaultlib:"libc" /out:"./zlib.pyd" /export:initzlib
-# SUBTRACT LINK32 /pdb:none
-
-!ELSEIF "$(CFG)" == "zlib - Win32 Debug"
-
-# PROP BASE Use_MFC 0
-# PROP BASE Use_Debug_Libraries 1
-# PROP BASE Output_Dir "Debug"
-# PROP BASE Intermediate_Dir "Debug"
-# PROP BASE Target_Dir ""
-# PROP Use_MFC 0
-# PROP Use_Debug_Libraries 1
-# PROP Output_Dir "."
-# PROP Intermediate_Dir "x86-temp-debug\zlib"
-# PROP Ignore_Export_Lib 0
-# PROP Target_Dir ""
-F90=df.exe
-# ADD BASE CPP /nologo /MTd /W3 /Gm /GX /Zi /Od /D "WIN32" /D "_DEBUG" /D "_WINDOWS" /YX /FD /c
-# ADD CPP /nologo /MDd /W3 /Gm /GX /Zi /Od /I "..\Include" /I "..\PC" /I "..\..\zlib113" /D "_DEBUG" /D "WIN32" /D "_WINDOWS" /D "ZLIB_DLL" /YX /FD /c
-# ADD BASE MTL /nologo /D "_DEBUG" /mktyplib203 /o "NUL" /win32
-# ADD MTL /nologo /D "_DEBUG" /mktyplib203 /o "NUL" /win32
-# ADD BASE RSC /l 0x409 /d "_DEBUG"
-# ADD RSC /l 0x409 /d "_DEBUG"
-BSC32=bscmake.exe
-# ADD BASE BSC32 /nologo
-# ADD BSC32 /nologo
-LINK32=link.exe
-# ADD BASE LINK32 kernel32.lib user32.lib gdi32.lib winspool.lib comdlg32.lib advapi32.lib shell32.lib ole32.lib oleaut32.lib uuid.lib odbc32.lib odbccp32.lib /nologo /subsystem:windows /dll /debug /machine:I386 /pdbtype:sept
-# ADD LINK32 user32.lib kernel32.lib gdi32.lib winspool.lib comdlg32.lib advapi32.lib shell32.lib ole32.lib oleaut32.lib uuid.lib odbc32.lib odbccp32.lib ..\..\zlib113dll\static32\zlibstat.lib /nologo /base:"0x1e1B0000" /subsystem:windows /dll /debug /machine:I386 /nodefaultlib:"libc" /out:"./zlib_d.pyd" /pdbtype:sept /export:initzlib
-# SUBTRACT LINK32 /pdb:none
-
-!ENDIF
-
-# Begin Target
-
-# Name "zlib - Win32 Release"
-# Name "zlib - Win32 Debug"
-# Begin Source File
-
-SOURCE=..\Modules\zlibmodule.c
-# End Source File
-# End Target
-# End Project
+# Microsoft Developer Studio Project File - Name="zlib" - Package Owner=<4>
+# Microsoft Developer Studio Generated Build File, Format Version 6.00
+# ** DO NOT EDIT **
+
+# TARGTYPE "Win32 (x86) Dynamic-Link Library" 0x0102
+
+CFG=zlib - Win32 Debug
+!MESSAGE This is not a valid makefile. To build this project using NMAKE,
+!MESSAGE use the Export Makefile command and run
+!MESSAGE
+!MESSAGE NMAKE /f "zlib.mak".
+!MESSAGE
+!MESSAGE You can specify a configuration when running NMAKE
+!MESSAGE by defining the macro CFG on the command line. For example:
+!MESSAGE
+!MESSAGE NMAKE /f "zlib.mak" CFG="zlib - Win32 Debug"
+!MESSAGE
+!MESSAGE Possible choices for configuration are:
+!MESSAGE
+!MESSAGE "zlib - Win32 Release" (based on "Win32 (x86) Dynamic-Link Library")
+!MESSAGE "zlib - Win32 Debug" (based on "Win32 (x86) Dynamic-Link Library")
+!MESSAGE
+
+# Begin Project
+# PROP AllowPerConfigDependencies 0
+# PROP Scc_ProjName "zlib"
+# PROP Scc_LocalPath ".."
+CPP=cl.exe
+MTL=midl.exe
+RSC=rc.exe
+
+!IF "$(CFG)" == "zlib - Win32 Release"
+
+# PROP BASE Use_MFC 0
+# PROP BASE Use_Debug_Libraries 0
+# PROP BASE Output_Dir "Release"
+# PROP BASE Intermediate_Dir "Release"
+# PROP BASE Target_Dir ""
+# PROP Use_MFC 0
+# PROP Use_Debug_Libraries 0
+# PROP Output_Dir "."
+# PROP Intermediate_Dir "x86-temp-release\zlib"
+# PROP Ignore_Export_Lib 0
+# PROP Target_Dir ""
+F90=df.exe
+# ADD BASE CPP /nologo /MT /W3 /GX /O2 /D "WIN32" /D "NDEBUG" /D "_WINDOWS" /YX /FD /c
+# ADD CPP /nologo /MD /W3 /GX /Zi /O2 /I "..\Include" /I "..\PC" /I "..\..\zlib113" /D "NDEBUG" /D "WIN32" /D "_WINDOWS" /D "ZLIB_DLL" /YX /FD /c
+# ADD BASE MTL /nologo /D "NDEBUG" /mktyplib203 /o "NUL" /win32
+# ADD MTL /nologo /D "NDEBUG" /mktyplib203 /o "NUL" /win32
+# ADD BASE RSC /l 0x409 /d "NDEBUG"
+# ADD RSC /l 0x409 /d "NDEBUG"
+BSC32=bscmake.exe
+# ADD BASE BSC32 /nologo
+# ADD BSC32 /nologo
+LINK32=link.exe
+# ADD BASE LINK32 kernel32.lib user32.lib gdi32.lib winspool.lib comdlg32.lib advapi32.lib shell32.lib ole32.lib oleaut32.lib uuid.lib odbc32.lib odbccp32.lib /nologo /subsystem:windows /dll /machine:I386
+# ADD LINK32 user32.lib kernel32.lib gdi32.lib winspool.lib comdlg32.lib advapi32.lib shell32.lib ole32.lib oleaut32.lib uuid.lib odbc32.lib odbccp32.lib ..\..\zlib113dll\static32\zlibstat.lib /nologo /base:"0x1e1B0000" /subsystem:windows /dll /debug /machine:I386 /nodefaultlib:"libc" /out:"./zlib.pyd" /export:initzlib
+# SUBTRACT LINK32 /pdb:none
+
+!ELSEIF "$(CFG)" == "zlib - Win32 Debug"
+
+# PROP BASE Use_MFC 0
+# PROP BASE Use_Debug_Libraries 1
+# PROP BASE Output_Dir "Debug"
+# PROP BASE Intermediate_Dir "Debug"
+# PROP BASE Target_Dir ""
+# PROP Use_MFC 0
+# PROP Use_Debug_Libraries 1
+# PROP Output_Dir "."
+# PROP Intermediate_Dir "x86-temp-debug\zlib"
+# PROP Ignore_Export_Lib 0
+# PROP Target_Dir ""
+F90=df.exe
+# ADD BASE CPP /nologo /MTd /W3 /Gm /GX /Zi /Od /D "WIN32" /D "_DEBUG" /D "_WINDOWS" /YX /FD /c
+# ADD CPP /nologo /MDd /W3 /Gm /GX /Zi /Od /I "..\Include" /I "..\PC" /I "..\..\zlib113" /D "_DEBUG" /D "WIN32" /D "_WINDOWS" /D "ZLIB_DLL" /YX /FD /c
+# ADD BASE MTL /nologo /D "_DEBUG" /mktyplib203 /o "NUL" /win32
+# ADD MTL /nologo /D "_DEBUG" /mktyplib203 /o "NUL" /win32
+# ADD BASE RSC /l 0x409 /d "_DEBUG"
+# ADD RSC /l 0x409 /d "_DEBUG"
+BSC32=bscmake.exe
+# ADD BASE BSC32 /nologo
+# ADD BSC32 /nologo
+LINK32=link.exe
+# ADD BASE LINK32 kernel32.lib user32.lib gdi32.lib winspool.lib comdlg32.lib advapi32.lib shell32.lib ole32.lib oleaut32.lib uuid.lib odbc32.lib odbccp32.lib /nologo /subsystem:windows /dll /debug /machine:I386 /pdbtype:sept
+# ADD LINK32 user32.lib kernel32.lib gdi32.lib winspool.lib comdlg32.lib advapi32.lib shell32.lib ole32.lib oleaut32.lib uuid.lib odbc32.lib odbccp32.lib ..\..\zlib113dll\static32\zlibstat.lib /nologo /base:"0x1e1B0000" /subsystem:windows /dll /debug /machine:I386 /nodefaultlib:"libc" /out:"./zlib_d.pyd" /pdbtype:sept /export:initzlib
+# SUBTRACT LINK32 /pdb:none
+
+!ENDIF
+
+# Begin Target
+
+# Name "zlib - Win32 Release"
+# Name "zlib - Win32 Debug"
+# Begin Source File
+
+SOURCE=..\Modules\zlibmodule.c
+# End Source File
+# End Target
+# End Project
n value='tip_442'>tip_442 Tk is a free and open-source, cross-platform widget toolkit that provides a library of basic elements of GUI widgets for building a graphical user interface (GUI) in many programming languages.
summaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
Diffstat
-rw-r--r--doc/FindPhoto.337
-rw-r--r--generic/tk.decls14
-rw-r--r--generic/tkBind.c36
-rw-r--r--generic/tkCanvPs.c2
-rw-r--r--generic/tkDecls.h57
-rw-r--r--generic/tkFont.c44
-rw-r--r--generic/tkFont.h6
-rw-r--r--generic/tkImgPhInstance.c2
-rw-r--r--generic/tkImgPhoto.c169
-rw-r--r--generic/tkInt.h1
-rw-r--r--generic/tkPanedWindow.c24
-rw-r--r--generic/tkSelect.c4
-rw-r--r--generic/tkStubInit.c6
-rw-r--r--generic/tkWindow.c2
-rw-r--r--generic/ttk/ttkNotebook.c9
-rw-r--r--macosx/tkMacOSXDialog.c555
-rw-r--r--macosx/tkMacOSXFont.c2
-rw-r--r--macosx/tkMacOSXScrlbr.c81
-rw-r--r--macosx/tkMacOSXWm.c5
-rw-r--r--macosx/tkMacOSXWm.h4
-rw-r--r--macosx/tkMacOSXXStubs.c6
-rw-r--r--tests/imgBmap.test3
-rw-r--r--tests/imgPhoto.test76
-rw-r--r--tests/menu.test2
-rwxr-xr-xunix/configure155
-rw-r--r--unix/tcl.m4165
-rw-r--r--unix/tkUnixButton.c81
-rw-r--r--unix/tkUnixFont.c16
-rw-r--r--unix/tkUnixRFont.c23
-rw-r--r--win/tcl.m42
-rw-r--r--win/tkWinClipboard.c2
-rw-r--r--win/tkWinDialog.c54
-rw-r--r--win/tkWinFont.c6
-rw-r--r--win/tkWinInit.c7
-rw-r--r--win/tkWinSend.c43
-rw-r--r--win/tkWinSendCom.c25
-rw-r--r--win/tkWinTest.c5
-rw-r--r--win/tkWinX.c30
-rw-r--r--xlib/xcolors.c4
-rw-r--r--xlib/xgc.c2
40 files changed, 1044 insertions, 723 deletions
diff --git a/doc/FindPhoto.3 b/doc/FindPhoto.3
index 61a47de..dc218bf 100644
--- a/doc/FindPhoto.3
+++ b/doc/FindPhoto.3
@@ -130,14 +130,23 @@ The \fIpixelPtr\fR field points to the first pixel, that is, the
top-left pixel in the block.
The \fIwidth\fR and \fIheight\fR fields specify the dimensions of the
block of pixels. The \fIpixelSize\fR field specifies the address
-difference between two horizontally adjacent pixels. Often it is 3
-or 4, but it can have any value. The \fIpitch\fR field specifies the
+difference between two horizontally adjacent pixels. It should be 4 for
+RGB and 2 for grayscale image data. Other values are possible, if the
+offsets in the \fIoffset\fR array are adjusted accordingly (e.g. for
+red, green and blue data stored in different planes). Using such a
+layout is strongly discouraged, though. Due to a bug, it might not work
+correctly if an alpha channel is provided. (see the \fBBUGS\fR section
+below). The \fIpitch\fR field specifies the
address difference between two vertically adjacent pixels. The
\fIoffset\fR array contains the offsets from the address of a pixel
to the addresses of the bytes containing the red, green, blue and alpha
-(transparency) components. These are normally 0, 1, 2 and 3, but can
-have other values, e.g., for images that are stored as separate red,
-green and blue planes.
+(transparency) components. If the offsets for red, green and blue are
+equal, the image is interpreted as grayscale. If they differ, RGB data
+is assumed. Normally the offsets will be 0, 1, 2, 3 for RGB data
+and 0, 0, 0, 1 for grayscale. It is possible to provide image data
+without an alpha channel by setting the offset for alpha to a negative
+value and adjusting the \fIpixelSize\fR field accordingly. This use is
+discouraged, though (see the \fBBUGS\fR section below).
.PP
The \fIcompRule\fR parameter to \fBTk_PhotoPutBlock\fR specifies a
compositing rule that says what to do with transparent pixels. The
@@ -248,6 +257,24 @@ memory was available for an image, Tk would panic. This behaviour is
still supported if you compile your extension with the additional flag
-DUSE_PANIC_ON_PHOTO_ALLOC_FAILURE. Code linked using Stubs against
older versions of Tk will continue to work.
+.SH BUGS
+The \fBTk_PhotoImageBlock\fR structure used to provide image data to
+\fBTk_PhotoPutBlock\fR promises great flexibility in the layout of the
+data (e.g. separate planes for the red, green, blue and alpha
+channels). Unfortunately, the implementation fails to hold this
+promise. The problem is that the \fIpixelSize\fR field is
+(incorrectly) used to determine whether the image has an alpha channel.
+Currently, if the offset for the alpha channel is greater or equal than
+\fIpixelSize\fR, \fBtk_PhotoPutblock\fR assumes no alpha data is
+present and makes the image fully opaque. This means that for layouts
+where the channels are separate (or any other exotic layout where
+\fIpixelSize\fR has to be smaller than the alpha offset), the alpha
+channel will not be read correctly. In order to be on the safe side
+if this issue will be corrected in a future release, it is strongly
+recommended you always provide alpha data - even if the image has no
+transparency - and only use the "standard" layout with a
+\fIpixelSize\fR of 2 for grayscale and 4 for RGB data with
+\fIoffset\fRs of 0, 0, 0, 1 or 0, 1, 2, 3 respectively.
.SH CREDITS
.PP
The code for the photo image type was developed by Paul Mackerras,
diff --git a/generic/tk.decls b/generic/tk.decls
index eaaa063..a8d0c58 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 deprecated {
+declare 77 {deprecated {function does nothing, call can be removed}} {
void Tk_FreeXId(Display *display, XID xid)
}
declare 78 {
@@ -564,12 +564,12 @@ declare 143 {
Tk_Window tkwin, int *argcPtr, CONST84 char **argv,
const Tk_ArgvInfo *argTable, int flags)
}
-declare 144 {
+declare 144 {deprecated {function signature changed}} {
void Tk_PhotoPutBlock_NoComposite(Tk_PhotoHandle handle,
Tk_PhotoImageBlock *blockPtr, int x, int y,
int width, int height)
}
-declare 145 {
+declare 145 {deprecated {function signature changed}} {
void Tk_PhotoPutZoomedBlock_NoComposite(Tk_PhotoHandle handle,
Tk_PhotoImageBlock *blockPtr, int x, int y,
int width, int height, int zoomX, int zoomY,
@@ -581,13 +581,13 @@ declare 146 {
declare 147 {
void Tk_PhotoBlank(Tk_PhotoHandle handle)
}
-declare 148 {
+declare 148 {deprecated {function signature changed}} {
void Tk_PhotoExpand_Panic(Tk_PhotoHandle handle, int width, int height )
}
declare 149 {
void Tk_PhotoGetSize(Tk_PhotoHandle handle, int *widthPtr, int *heightPtr)
}
-declare 150 {
+declare 150 {deprecated {function signature changed}} {
void Tk_PhotoSetSize_Panic(Tk_PhotoHandle handle, int width, int height)
}
declare 151 {
@@ -943,12 +943,12 @@ declare 244 {
declare 245 {
void Tk_SetCaretPos(Tk_Window tkwin, int x, int y, int height)
}
-declare 246 {
+declare 246 {deprecated {function signature changed}} {
void Tk_PhotoPutBlock_Panic(Tk_PhotoHandle handle,
Tk_PhotoImageBlock *blockPtr, int x, int y,
int width, int height, int compRule)
}
-declare 247 {
+declare 247 {deprecated {function signature changed}} {
void Tk_PhotoPutZoomedBlock_Panic(Tk_PhotoHandle handle,
Tk_PhotoImageBlock *blockPtr, int x, int y,
int width, int height, int zoomX, int zoomY,
diff --git a/generic/tkBind.c b/generic/tkBind.c
index aaa5386..e0cc1ca 100644
--- a/generic/tkBind.c
+++ b/generic/tkBind.c
@@ -1267,7 +1267,7 @@ Tk_BindEvent(
*/
if ((eventPtr->type >= TK_LASTEVENT) || !flagArray[eventPtr->type]) {
- return;
+ return;
}
dispPtr = ((TkWindow *) tkwin)->dispPtr;
@@ -3466,12 +3466,7 @@ HandleEventGenerate(
if ((warp != 0) && Tk_IsMapped(tkwin)) {
TkDisplay *dispPtr = TkGetDisplay(event.general.xmotion.display);
- /*
- * TODO: No protection is in place to handle dispPtr destruction
- * before DoWarp is called back.
- */
-
- Tk_Window warpWindow = Tk_IdToWindow(dispPtr->display,
+Tk_Window warpWindow = Tk_IdToWindow(dispPtr->display,
event.general.xmotion.window);
if (!(dispPtr->flags & TK_DISPLAY_IN_WARP)) {
@@ -4321,6 +4316,33 @@ TkpGetBindingXEvent(
}
/*
+ *----------------------------------------------------------------------
+ *
+ * TkpCancelWarp --
+ *
+ * This function cancels an outstanding pointer warp and
+ * is called during tear down of the display.
+ *
+ * Results:
+ * None.
+ *
+ * Side effects:
+ * None.
+ *
+ *----------------------------------------------------------------------
+ */
+
+void
+TkpCancelWarp(
+ TkDisplay *dispPtr)
+{
+ if (dispPtr->flags & TK_DISPLAY_IN_WARP) {
+ Tcl_CancelIdleCall(DoWarp, dispPtr);
+ dispPtr->flags &= ~TK_DISPLAY_IN_WARP;
+ }
+}
+
+/*
* Local Variables:
* mode: c
* c-basic-offset: 4
diff --git a/generic/tkCanvPs.c b/generic/tkCanvPs.c
index c6470dd..2bfdcc5 100644
--- a/generic/tkCanvPs.c
+++ b/generic/tkCanvPs.c
@@ -825,7 +825,7 @@ Tk_PostscriptFont(
fontname = Tcl_DStringValue(&ds);
Tcl_AppendPrintfToObj(GetPostscriptBuffer(interp),
"/%s findfont %d scalefont%s setfont\n",
- fontname, TkFontGetPoints(psInfoPtr->tkwin, points),
+ fontname, (int)(TkFontGetPoints(psInfoPtr->tkwin, points) + 0.5),
strncasecmp(fontname, "Symbol", 7) ? " ISOEncode" : "");
Tcl_CreateHashEntry(&psInfoPtr->fontTable, Tcl_DStringValue(&ds), &i);
Tcl_DStringFree(&ds);
diff --git a/generic/tkDecls.h b/generic/tkDecls.h
index 3b72706..1aa087f 100644
--- a/generic/tkDecls.h
+++ b/generic/tkDecls.h
@@ -18,9 +18,9 @@
#endif
#if defined(TK_NO_DEPRECATED) && defined(BUILD_tk)
-# define TK_DEPRECATED MODULE_SCOPE
+# define TK_DEPRECATED(msg) MODULE_SCOPE
#else
-# define TK_DEPRECATED EXTERN
+# define TK_DEPRECATED(msg) EXTERN TCL_DEPRECATED_API(msg)
#endif
/*
@@ -287,7 +287,9 @@ EXTERN void Tk_FreePixmap(Display *display, Pixmap pixmap);
/* 76 */
EXTERN void Tk_FreeTextLayout(Tk_TextLayout textLayout);
/* 77 */
-TK_DEPRECATED void Tk_FreeXId(Display *display, XID xid);
+TK_DEPRECATED("function does nothing, call can be removed")
+void Tk_FreeXId(
+ Display *display, XID xid);
/* 78 */
EXTERN GC Tk_GCForColor(XColor *colorPtr, Drawable drawable);
/* 79 */
@@ -477,11 +479,14 @@ EXTERN int Tk_ParseArgv(Tcl_Interp *interp, Tk_Window tkwin,
int *argcPtr, CONST84 char **argv,
const Tk_ArgvInfo *argTable, int flags);
/* 144 */
-EXTERN void Tk_PhotoPutBlock_NoComposite(Tk_PhotoHandle handle,
+TK_DEPRECATED("function signature changed")
+void Tk_PhotoPutBlock_NoComposite(
+ Tk_PhotoHandle handle,
Tk_PhotoImageBlock *blockPtr, int x, int y,
int width, int height);
/* 145 */
-EXTERN void Tk_PhotoPutZoomedBlock_NoComposite(
+TK_DEPRECATED("function signature changed")
+void Tk_PhotoPutZoomedBlock_NoComposite(
Tk_PhotoHandle handle,
Tk_PhotoImageBlock *blockPtr, int x, int y,
int width, int height, int zoomX, int zoomY,
@@ -492,14 +497,16 @@ EXTERN int Tk_PhotoGetImage(Tk_PhotoHandle handle,
/* 147 */
EXTERN void Tk_PhotoBlank(Tk_PhotoHandle handle);
/* 148 */
-EXTERN void Tk_PhotoExpand_Panic(Tk_PhotoHandle handle,
- int width, int height);
+TK_DEPRECATED("function signature changed")
+void Tk_PhotoExpand_Panic(
+ Tk_PhotoHandle handle, int width, int height);
/* 149 */
EXTERN void Tk_PhotoGetSize(Tk_PhotoHandle handle, int *widthPtr,
int *heightPtr);
/* 150 */
-EXTERN void Tk_PhotoSetSize_Panic(Tk_PhotoHandle handle,
- int width, int height);
+TK_DEPRECATED("function signature changed")
+void Tk_PhotoSetSize_Panic(
+ Tk_PhotoHandle handle, int width, int height);
/* 151 */
EXTERN int Tk_PointToChar(Tk_TextLayout layout, int x, int y);
/* 152 */
@@ -782,11 +789,15 @@ EXTERN void Tk_SetMinimumRequestSize(Tk_Window tkwin,
EXTERN void Tk_SetCaretPos(Tk_Window tkwin, int x, int y,
int height);
/* 246 */
-EXTERN void Tk_PhotoPutBlock_Panic(Tk_PhotoHandle handle,
+TK_DEPRECATED("function signature changed")
+void Tk_PhotoPutBlock_Panic(
+ Tk_PhotoHandle handle,
Tk_PhotoImageBlock *blockPtr, int x, int y,
int width, int height, int compRule);
/* 247 */
-EXTERN void Tk_PhotoPutZoomedBlock_Panic(Tk_PhotoHandle handle,
+TK_DEPRECATED("function signature changed")
+void Tk_PhotoPutZoomedBlock_Panic(
+ Tk_PhotoHandle handle,
Tk_PhotoImageBlock *blockPtr, int x, int y,
int width, int height, int zoomX, int zoomY,
int subsampleX, int subsampleY, int compRule);
@@ -959,7 +970,7 @@ typedef struct TkStubs {
void (*tk_FreeOptions) (const Tk_ConfigSpec *specs, char *widgRec, Display *display, int needFlags); /* 74 */
void (*tk_FreePixmap) (Display *display, Pixmap pixmap); /* 75 */
void (*tk_FreeTextLayout) (Tk_TextLayout textLayout); /* 76 */
- void (*tk_FreeXId) (Display *display, XID xid); /* 77 */
+ TCL_DEPRECATED_API("function does nothing, call can be removed") void (*tk_FreeXId) (Display *display, XID xid); /* 77 */
GC (*tk_GCForColor) (XColor *colorPtr, Drawable drawable); /* 78 */
void (*tk_GeometryRequest) (Tk_Window tkwin, int reqWidth, int reqHeight); /* 79 */
Tk_3DBorder (*tk_Get3DBorder) (Tcl_Interp *interp, Tk_Window tkwin, Tk_Uid colorName); /* 80 */
@@ -1026,13 +1037,13 @@ typedef struct TkStubs {
Tk_Window (*tk_NameToWindow) (Tcl_Interp *interp, const char *pathName, Tk_Window tkwin); /* 141 */
void (*tk_OwnSelection) (Tk_Window tkwin, Atom selection, Tk_LostSelProc *proc, ClientData clientData); /* 142 */
int (*tk_ParseArgv) (Tcl_Interp *interp, Tk_Window tkwin, int *argcPtr, CONST84 char **argv, const Tk_ArgvInfo *argTable, int flags); /* 143 */
- void (*tk_PhotoPutBlock_NoComposite) (Tk_PhotoHandle handle, Tk_PhotoImageBlock *blockPtr, int x, int y, int width, int height); /* 144 */
- void (*tk_PhotoPutZoomedBlock_NoComposite) (Tk_PhotoHandle handle, Tk_PhotoImageBlock *blockPtr, int x, int y, int width, int height, int zoomX, int zoomY, int subsampleX, int subsampleY); /* 145 */
+ TCL_DEPRECATED_API("function signature changed") void (*tk_PhotoPutBlock_NoComposite) (Tk_PhotoHandle handle, Tk_PhotoImageBlock *blockPtr, int x, int y, int width, int height); /* 144 */
+ TCL_DEPRECATED_API("function signature changed") void (*tk_PhotoPutZoomedBlock_NoComposite) (Tk_PhotoHandle handle, Tk_PhotoImageBlock *blockPtr, int x, int y, int width, int height, int zoomX, int zoomY, int subsampleX, int subsampleY); /* 145 */
int (*tk_PhotoGetImage) (Tk_PhotoHandle handle, Tk_PhotoImageBlock *blockPtr); /* 146 */
void (*tk_PhotoBlank) (Tk_PhotoHandle handle); /* 147 */
- void (*tk_PhotoExpand_Panic) (Tk_PhotoHandle handle, int width, int height); /* 148 */
+ TCL_DEPRECATED_API("function signature changed") void (*tk_PhotoExpand_Panic) (Tk_PhotoHandle handle, int width, int height); /* 148 */
void (*tk_PhotoGetSize) (Tk_PhotoHandle handle, int *widthPtr, int *heightPtr); /* 149 */
- void (*tk_PhotoSetSize_Panic) (Tk_PhotoHandle handle, int width, int height); /* 150 */
+ TCL_DEPRECATED_API("function signature changed") void (*tk_PhotoSetSize_Panic) (Tk_PhotoHandle handle, int width, int height); /* 150 */
int (*tk_PointToChar) (Tk_TextLayout layout, int x, int y); /* 151 */
int (*tk_PostscriptFontName) (Tk_Font tkfont, Tcl_DString *dsPtr); /* 152 */
void (*tk_PreserveColormap) (Display *display, Colormap colormap); /* 153 */
@@ -1128,8 +1139,8 @@ typedef struct TkStubs {
void (*tk_SetInternalBorderEx) (Tk_Window tkwin, int left, int right, int top, int bottom); /* 243 */
void (*tk_SetMinimumRequestSize) (Tk_Window tkwin, int minWidth, int minHeight); /* 244 */
void (*tk_SetCaretPos) (Tk_Window tkwin, int x, int y, int height); /* 245 */
- void (*tk_PhotoPutBlock_Panic) (Tk_PhotoHandle handle, Tk_PhotoImageBlock *blockPtr, int x, int y, int width, int height, int compRule); /* 246 */
- void (*tk_PhotoPutZoomedBlock_Panic) (Tk_PhotoHandle handle, Tk_PhotoImageBlock *blockPtr, int x, int y, int width, int height, int zoomX, int zoomY, int subsampleX, int subsampleY, int compRule); /* 247 */
+ TCL_DEPRECATED_API("function signature changed") void (*tk_PhotoPutBlock_Panic) (Tk_PhotoHandle handle, Tk_PhotoImageBlock *blockPtr, int x, int y, int width, int height, int compRule); /* 246 */
+ TCL_DEPRECATED_API("function signature changed") void (*tk_PhotoPutZoomedBlock_Panic) (Tk_PhotoHandle handle, Tk_PhotoImageBlock *blockPtr, int x, int y, int width, int height, int zoomX, int zoomY, int subsampleX, int subsampleY, int compRule); /* 247 */
int (*tk_CollapseMotionEvents) (Display *display, int collapse); /* 248 */
Tk_StyleEngine (*tk_RegisterStyleEngine) (const char *name, Tk_StyleEngine parent); /* 249 */
Tk_StyleEngine (*tk_GetStyleEngine) (const char *name); /* 250 */
@@ -1736,6 +1747,16 @@ extern const TkStubs *tkStubsPtr;
Tcl_AppInitProc *appInitProc, Tcl_Interp *interp);
#endif
+
+#ifdef TK_NO_DEPRECATED
+#undef Tk_PhotoPutBlock_NoComposite
+#undef Tk_PhotoPutZoomedBlock_NoComposite
+#undef Tk_PhotoExpand_Panic
+#undef Tk_PhotoPutBlock_Panic
+#undef Tk_PhotoPutZoomedBlock_Panic
+#undef Tk_PhotoSetSize_Panic
+#endif /* TK_NO_DEPRECATED */
+
#undef TCL_STORAGE_CLASS
#define TCL_STORAGE_CLASS DLLIMPORT
diff --git a/generic/tkFont.c b/generic/tkFont.c
index a00c627..3c2b4f9 100644
--- a/generic/tkFont.c
+++ b/generic/tkFont.c
@@ -1228,7 +1228,7 @@ Tk_AllocFontFromObj(
descent = fontPtr->fm.descent;
fontPtr->underlinePos = descent / 2;
- fontPtr->underlineHeight = TkFontGetPixels(tkwin, fontPtr->fa.size) / 10;
+ fontPtr->underlineHeight = (int) (TkFontGetPixels(tkwin, fontPtr->fa.size) / 10 + 0.5);
if (fontPtr->underlineHeight == 0) {
fontPtr->underlineHeight = 1;
}
@@ -1795,7 +1795,7 @@ Tk_PostscriptFontName(
}
}
- return fontPtr->fa.size;
+ return (int)(fontPtr->fa.size + 0.5);
}
/*
@@ -3404,7 +3404,7 @@ ConfigAttributesObj(
if (Tcl_GetIntFromObj(interp, valuePtr, &n) != TCL_OK) {
return TCL_ERROR;
}
- faPtr->size = n;
+ faPtr->size = (double)n;
break;
case FONT_WEIGHT:
n = TkFindStateNumObj(interp, optionPtr, weightMap, valuePtr);
@@ -3495,7 +3495,11 @@ GetAttributeInfoObj(
break;
case FONT_SIZE:
- valuePtr = Tcl_NewIntObj(faPtr->size);
+ if (faPtr->size >= 0.0) {
+ valuePtr = Tcl_NewIntObj((int)(faPtr->size + 0.5));
+ } else {
+ valuePtr = Tcl_NewIntObj(-(int)(-faPtr->size + 0.5));
+ }
break;
case FONT_WEIGHT:
@@ -3644,7 +3648,7 @@ ParseFontNameObj(
if (Tcl_GetIntFromObj(interp, objv[1], &n) != TCL_OK) {
return TCL_ERROR;
}
- faPtr->size = n;
+ faPtr->size = (double)n;
}
i = 2;
@@ -3888,7 +3892,7 @@ TkFontParseXLFD(
* historical compatibility.
*/
- faPtr->size = 12;
+ faPtr->size = 12.0;
if (FieldSpecified(field[XLFD_POINT_SIZE])) {
if (field[XLFD_POINT_SIZE][0] == '[') {
@@ -3902,10 +3906,10 @@ TkFontParseXLFD(
* the purpose of, so I ignore them.
*/
- faPtr->size = atoi(field[XLFD_POINT_SIZE] + 1);
+ faPtr->size = atof(field[XLFD_POINT_SIZE] + 1);
} else if (Tcl_GetInt(NULL, field[XLFD_POINT_SIZE],
- &faPtr->size) == TCL_OK) {
- faPtr->size /= 10;
+ &i) == TCL_OK) {
+ faPtr->size = i/10.0;
} else {
return TCL_ERROR;
}
@@ -3927,9 +3931,11 @@ TkFontParseXLFD(
* ignore them.
*/
- faPtr->size = atoi(field[XLFD_PIXEL_SIZE] + 1);
+ faPtr->size = atof(field[XLFD_PIXEL_SIZE] + 1);
} else if (Tcl_GetInt(NULL, field[XLFD_PIXEL_SIZE],
- &faPtr->size) != TCL_OK) {
+ &i) == TCL_OK) {
+ faPtr->size = (double)i;
+ } else {
return TCL_ERROR;
}
}
@@ -4005,21 +4011,21 @@ FieldSpecified(
*---------------------------------------------------------------------------
*/
-int
+double
TkFontGetPixels(
Tk_Window tkwin, /* For point->pixel conversion factor. */
- int size) /* Font size. */
+ double size) /* Font size. */
{
double d;
- if (size < 0) {
+ if (size <= 0.0) {
return -size;
}
d = size * 25.4 / 72.0;
d *= WidthOfScreen(Tk_Screen(tkwin));
d /= WidthMMOfScreen(Tk_Screen(tkwin));
- return (int) (d + 0.5);
+ return d;
}
/*
@@ -4039,21 +4045,21 @@ TkFontGetPixels(
*---------------------------------------------------------------------------
*/
-int
+double
TkFontGetPoints(
Tk_Window tkwin, /* For pixel->point conversion factor. */
- int size) /* Font size. */
+ double size) /* Font size. */
{
double d;
- if (size >= 0) {
+ if (size >= 0.0) {
return size;
}
d = -size * 72.0 / 25.4;
d *= WidthMMOfScreen(Tk_Screen(tkwin));
d /= WidthOfScreen(Tk_Screen(tkwin));
- return (int) (d + 0.5);
+ return d;
}
/*
diff --git a/generic/tkFont.h b/generic/tkFont.h
index b8de885..de479bf 100644
--- a/generic/tkFont.h
+++ b/generic/tkFont.h
@@ -23,7 +23,7 @@
struct TkFontAttributes {
Tk_Uid family; /* Font family, or NULL to represent plaform-
* specific default system font. */
- int size; /* Pointsize of font, 0 for default size, or
+ double size; /* Pointsize of font, 0.0 for default size, or
* negative number meaning pixel size. */
int weight; /* Weight flag; see below for def'n. */
int slant; /* Slant flag; see below for def'n. */
@@ -198,8 +198,8 @@ MODULE_SCOPE int TkFontParseXLFD(const char *string,
TkFontAttributes *faPtr, TkXLFDAttributes *xaPtr);
MODULE_SCOPE const char *const * TkFontGetAliasList(const char *faceName);
MODULE_SCOPE const char *const *const * TkFontGetFallbacks(void);
-MODULE_SCOPE int TkFontGetPixels(Tk_Window tkwin, int size);
-MODULE_SCOPE int TkFontGetPoints(Tk_Window tkwin, int size);
+MODULE_SCOPE double TkFontGetPixels(Tk_Window tkwin, double size);
+MODULE_SCOPE double TkFontGetPoints(Tk_Window tkwin, double size);
MODULE_SCOPE const char *const * TkFontGetGlobalClass(void);
MODULE_SCOPE const char *const * TkFontGetSymbolClass(void);
MODULE_SCOPE int TkCreateNamedFont(Tcl_Interp *interp, Tk_Window tkwin,
diff --git a/generic/tkImgPhInstance.c b/generic/tkImgPhInstance.c
index 98aaeab..fd98c6e 100644
--- a/generic/tkImgPhInstance.c
+++ b/generic/tkImgPhInstance.c
@@ -1261,7 +1261,7 @@ AllocateColors(
}
} else {
/*
- * Monochrome display - allocate the shades of grey we want.
+ * Monochrome display - allocate the shades of gray we want.
*/
for (i = 0; i < numColors; ++i) {
diff --git a/generic/tkImgPhoto.c b/generic/tkImgPhoto.c
index bcf69a0..a1146b7 100644
--- a/generic/tkImgPhoto.c
+++ b/generic/tkImgPhoto.c
@@ -2713,7 +2713,7 @@ Tk_PhotoPutBlock(
* messages, or NULL. */
Tk_PhotoHandle handle, /* Opaque handle for the photo image to be
* updated. */
- register Tk_PhotoImageBlock *blockPtr,
+ Tk_PhotoImageBlock *blockPtr,
/* Pointer to a structure describing the pixel
* data to be copied into the image. */
int x, int y, /* Coordinates of the top-left pixel to be
@@ -2724,6 +2724,8 @@ Tk_PhotoPutBlock(
* transparent pixels. */
{
register PhotoMaster *masterPtr = (PhotoMaster *) handle;
+ Tk_PhotoImageBlock sourceBlock;
+ unsigned char *memToFree;
int xEnd, yEnd, greenOffset, blueOffset, alphaOffset;
int wLeft, hLeft, wCopy, hCopy, pitch;
unsigned char *srcPtr, *srcLinePtr, *destPtr, *destLinePtr;
@@ -2751,11 +2753,43 @@ Tk_PhotoPutBlock(
return TCL_OK;
}
+ /*
+ * Fix for bug e4336bef5d:
+ *
+ * Make a local copy of *blockPtr, as we might have to change some
+ * of its fields and don't want to interfere with the caller's data.
+ *
+ * If source and destination are the same image, create a copy of the
+ * source data in our local sourceBlock.
+ *
+ * To find out, just comparing the pointers is not enough - they might have
+ * different values and still point to the same block of memory. (e.g.
+ * if the -from option was passed to [imageName copy])
+ */
+ sourceBlock = *blockPtr;
+ memToFree = NULL;
+ if (sourceBlock.pixelPtr >= masterPtr->pix32
+ && sourceBlock.pixelPtr <= masterPtr->pix32 + masterPtr->width
+ * masterPtr->height * 4) {
+ sourceBlock.pixelPtr = attemptckalloc(sourceBlock.height
+ * sourceBlock.pitch);
+ if (sourceBlock.pixelPtr == NULL) {
+ if (interp != NULL) {
+ Tcl_SetObjResult(interp, Tcl_NewStringObj(
+ TK_PHOTO_ALLOC_FAILURE_MESSAGE, -1));
+ Tcl_SetErrorCode(interp, "TK", "MALLOC", NULL);
+ }
+ return TCL_ERROR;
+ }
+ memToFree = sourceBlock.pixelPtr;
+ memcpy(sourceBlock.pixelPtr, blockPtr->pixelPtr, sourceBlock.height
+ * sourceBlock.pitch);
+ }
+
+
xEnd = x + width;
yEnd = y + height;
if ((xEnd > masterPtr->width) || (yEnd > masterPtr->height)) {
- int sameSrc = (blockPtr->pixelPtr == masterPtr->pix32);
-
if (ImgPhotoSetSize(masterPtr, MAX(xEnd, masterPtr->width),
MAX(yEnd, masterPtr->height)) == TCL_ERROR) {
if (interp != NULL) {
@@ -2763,11 +2797,7 @@ Tk_PhotoPutBlock(
TK_PHOTO_ALLOC_FAILURE_MESSAGE, -1));
Tcl_SetErrorCode(interp, "TK", "MALLOC", NULL);
}
- return TCL_ERROR;
- }
- if (sameSrc) {
- blockPtr->pixelPtr = masterPtr->pix32;
- blockPtr->pitch = masterPtr->width * 4;
+ goto errorExit;
}
}
@@ -2786,14 +2816,14 @@ Tk_PhotoPutBlock(
* components, mark it as a color image.
*/
- greenOffset = blockPtr->offset[1] - blockPtr->offset[0];
- blueOffset = blockPtr->offset[2] - blockPtr->offset[0];
- alphaOffset = blockPtr->offset[3];
- if ((alphaOffset >= blockPtr->pixelSize) || (alphaOffset < 0)) {
+ greenOffset = sourceBlock.offset[1] - sourceBlock.offset[0];
+ blueOffset = sourceBlock.offset[2] - sourceBlock.offset[0];
+ alphaOffset = sourceBlock.offset[3];
+ if ((alphaOffset >= sourceBlock.pixelSize) || (alphaOffset < 0)) {
alphaOffset = 0;
sourceIsSimplePhoto = 1;
} else {
- alphaOffset -= blockPtr->offset[0];
+ alphaOffset -= sourceBlock.offset[0];
}
if ((greenOffset != 0) || (blueOffset != 0)) {
masterPtr->flags |= COLOR_IMAGE;
@@ -2813,13 +2843,13 @@ Tk_PhotoPutBlock(
* pixelSize == 3 and alphaOffset == 0. Maybe other cases too.
*/
- if ((blockPtr->pixelSize == 4)
+ if ((sourceBlock.pixelSize == 4)
&& (greenOffset == 1) && (blueOffset == 2) && (alphaOffset == 3)
- && (width <= blockPtr->width) && (height <= blockPtr->height)
+ && (width <= sourceBlock.width) && (height <= sourceBlock.height)
&& ((height == 1) || ((x == 0) && (width == masterPtr->width)
- && (blockPtr->pitch == pitch)))
+ && (sourceBlock.pitch == pitch)))
&& (compRule == TK_PHOTO_COMPOSITE_SET)) {
- memmove(destLinePtr, blockPtr->pixelPtr + blockPtr->offset[0],
+ memmove(destLinePtr, sourceBlock.pixelPtr + sourceBlock.offset[0],
((size_t)height * width * 4));
/*
@@ -2835,11 +2865,11 @@ Tk_PhotoPutBlock(
*/
for (hLeft = height; hLeft > 0;) {
- int pixelSize = blockPtr->pixelSize;
+ int pixelSize = sourceBlock.pixelSize;
int compRuleSet = (compRule == TK_PHOTO_COMPOSITE_SET);
- srcLinePtr = blockPtr->pixelPtr + blockPtr->offset[0];
- hCopy = MIN(hLeft, blockPtr->height);
+ srcLinePtr = sourceBlock.pixelPtr + sourceBlock.offset[0];
+ hCopy = MIN(hLeft, sourceBlock.height);
hLeft -= hCopy;
for (; hCopy > 0; --hCopy) {
/*
@@ -2850,10 +2880,10 @@ Tk_PhotoPutBlock(
if ((pixelSize == 4) && (greenOffset == 1)
&& (blueOffset == 2) && (alphaOffset == 3)
- && (width <= blockPtr->width)
+ && (width <= sourceBlock.width)
&& compRuleSet) {
memcpy(destLinePtr, srcLinePtr, ((size_t)width * 4));
- srcLinePtr += blockPtr->pitch;
+ srcLinePtr += sourceBlock.pitch;
destLinePtr += pitch;
continue;
}
@@ -2864,7 +2894,7 @@ Tk_PhotoPutBlock(
destPtr = destLinePtr;
for (wLeft = width; wLeft > 0;) {
- wCopy = MIN(wLeft, blockPtr->width);
+ wCopy = MIN(wLeft, sourceBlock.width);
wLeft -= wCopy;
srcPtr = srcLinePtr;
@@ -2954,7 +2984,7 @@ Tk_PhotoPutBlock(
destPtr += 4;
}
}
- srcLinePtr += blockPtr->pitch;
+ srcLinePtr += sourceBlock.pitch;
destLinePtr += pitch;
}
}
@@ -3070,7 +3100,15 @@ Tk_PhotoPutBlock(
Tk_ImageChanged(masterPtr->tkMaster, x, y, width, height,
masterPtr->width, masterPtr->height);
+
+ if (memToFree) ckfree(memToFree);
+
return TCL_OK;
+
+ errorExit:
+ if (memToFree) ckfree(memToFree);
+
+ return TCL_ERROR;
}
/*
@@ -3097,7 +3135,7 @@ Tk_PhotoPutZoomedBlock(
* messages, or NULL. */
Tk_PhotoHandle handle, /* Opaque handle for the photo image to be
* updated. */
- register Tk_PhotoImageBlock *blockPtr,
+ Tk_PhotoImageBlock *blockPtr,
/* Pointer to a structure describing the pixel
* data to be copied into the image. */
int x, int y, /* Coordinates of the top-left pixel to be
@@ -3112,6 +3150,8 @@ Tk_PhotoPutZoomedBlock(
* transparent pixels. */
{
register PhotoMaster *masterPtr = (PhotoMaster *) handle;
+ register Tk_PhotoImageBlock sourceBlock;
+ unsigned char *memToFree;
int xEnd, yEnd, greenOffset, blueOffset, alphaOffset;
int wLeft, hLeft, wCopy, hCopy, blockWid, blockHt;
unsigned char *srcPtr, *srcLinePtr, *srcOrigPtr, *destPtr, *destLinePtr;
@@ -3148,11 +3188,41 @@ Tk_PhotoPutZoomedBlock(
return TCL_OK;
}
+ /*
+ * Fix for Bug e4336bef5d:
+ * Make a local copy of *blockPtr, as we might have to change some
+ * of its fields and don't want to interfere with the caller's data.
+ *
+ * If source and destination are the same image, create a copy of the
+ * source data in our local sourceBlock.
+ *
+ * To find out, just comparing the pointers is not enough - they might have
+ * different values and still point to the same block of memory. (e.g.
+ * if the -from option was passed to [imageName copy])
+ */
+ sourceBlock = *blockPtr;
+ memToFree = NULL;
+ if (sourceBlock.pixelPtr >= masterPtr->pix32
+ && sourceBlock.pixelPtr <= masterPtr->pix32 + masterPtr->width
+ * masterPtr->height * 4) {
+ sourceBlock.pixelPtr = attemptckalloc(sourceBlock.height
+ * sourceBlock.pitch);
+ if (sourceBlock.pixelPtr == NULL) {
+ if (interp != NULL) {
+ Tcl_SetObjResult(interp, Tcl_NewStringObj(
+ TK_PHOTO_ALLOC_FAILURE_MESSAGE, -1));
+ Tcl_SetErrorCode(interp, "TK", "MALLOC", NULL);
+ }
+ return TCL_ERROR;
+ }
+ memToFree = sourceBlock.pixelPtr;
+ memcpy(sourceBlock.pixelPtr, blockPtr->pixelPtr, sourceBlock.height
+ * sourceBlock.pitch);
+ }
+
xEnd = x + width;
yEnd = y + height;
if ((xEnd > masterPtr->width) || (yEnd > masterPtr->height)) {
- int sameSrc = (blockPtr->pixelPtr == masterPtr->pix32);
-
if (ImgPhotoSetSize(masterPtr, MAX(xEnd, masterPtr->width),
MAX(yEnd, masterPtr->height)) == TCL_ERROR) {
if (interp != NULL) {
@@ -3160,11 +3230,7 @@ Tk_PhotoPutZoomedBlock(
TK_PHOTO_ALLOC_FAILURE_MESSAGE, -1));
Tcl_SetErrorCode(interp, "TK", "MALLOC", NULL);
}
- return TCL_ERROR;
- }
- if (sameSrc) {
- blockPtr->pixelPtr = masterPtr->pix32;
- blockPtr->pitch = masterPtr->width * 4;
+ goto errorExit;
}
}
@@ -3183,14 +3249,14 @@ Tk_PhotoPutZoomedBlock(
* components, mark it as a color image.
*/
- greenOffset = blockPtr->offset[1] - blockPtr->offset[0];
- blueOffset = blockPtr->offset[2] - blockPtr->offset[0];
- alphaOffset = blockPtr->offset[3];
- if ((alphaOffset >= blockPtr->pixelSize) || (alphaOffset < 0)) {
+ greenOffset = sourceBlock.offset[1] - sourceBlock.offset[0];
+ blueOffset = sourceBlock.offset[2] - sourceBlock.offset[0];
+ alphaOffset = sourceBlock.offset[3];
+ if ((alphaOffset >= sourceBlock.pixelSize) || (alphaOffset < 0)) {
alphaOffset = 0;
sourceIsSimplePhoto = 1;
} else {
- alphaOffset -= blockPtr->offset[0];
+ alphaOffset -= sourceBlock.offset[0];
}
if ((greenOffset != 0) || (blueOffset != 0)) {
masterPtr->flags |= COLOR_IMAGE;
@@ -3201,21 +3267,21 @@ Tk_PhotoPutZoomedBlock(
* subsampling and zooming.
*/
- blockXSkip = subsampleX * blockPtr->pixelSize;
- blockYSkip = subsampleY * blockPtr->pitch;
+ blockXSkip = subsampleX * sourceBlock.pixelSize;
+ blockYSkip = subsampleY * sourceBlock.pitch;
if (subsampleX > 0) {
- blockWid = ((blockPtr->width + subsampleX - 1) / subsampleX) * zoomX;
+ blockWid = ((sourceBlock.width + subsampleX - 1) / subsampleX) * zoomX;
} else if (subsampleX == 0) {
blockWid = width;
} else {
- blockWid = ((blockPtr->width - subsampleX - 1) / -subsampleX) * zoomX;
+ blockWid = ((sourceBlock.width - subsampleX - 1) / -subsampleX) * zoomX;
}
if (subsampleY > 0) {
- blockHt = ((blockPtr->height + subsampleY - 1) / subsampleY) * zoomY;
+ blockHt = ((sourceBlock.height + subsampleY - 1) / subsampleY) * zoomY;
} else if (subsampleY == 0) {
blockHt = height;
} else {
- blockHt = ((blockPtr->height - subsampleY - 1) / -subsampleY) * zoomY;
+ blockHt = ((sourceBlock.height - subsampleY - 1) / -subsampleY) * zoomY;
}
/*
@@ -3223,12 +3289,12 @@ Tk_PhotoPutZoomedBlock(
*/
destLinePtr = masterPtr->pix32 + (y * masterPtr->width + x) * 4;
- srcOrigPtr = blockPtr->pixelPtr + blockPtr->offset[0];
+ srcOrigPtr = sourceBlock.pixelPtr + sourceBlock.offset[0];
if (subsampleX < 0) {
- srcOrigPtr += (blockPtr->width - 1) * blockPtr->pixelSize;
+ srcOrigPtr += (sourceBlock.width - 1) * sourceBlock.pixelSize;
}
if (subsampleY < 0) {
- srcOrigPtr += (blockPtr->height - 1) * blockPtr->pitch;
+ srcOrigPtr += (sourceBlock.height - 1) * sourceBlock.pitch;
}
pitch = masterPtr->width * 4;
@@ -3378,7 +3444,15 @@ Tk_PhotoPutZoomedBlock(
Tk_ImageChanged(masterPtr->tkMaster, x, y, width, height, masterPtr->width,
masterPtr->height);
+
+ if (memToFree) ckfree(memToFree);
+
return TCL_OK;
+
+ errorExit:
+ if (memToFree) ckfree(memToFree);
+
+ return TCL_ERROR;
}
/*
@@ -3953,7 +4027,7 @@ ImgPhotoPostscript(
*
*----------------------------------------------------------------------
*/
-
+#ifndef TK_NO_DEPRECATED
void
Tk_PhotoPutBlock_NoComposite(
Tk_PhotoHandle handle,
@@ -4039,6 +4113,7 @@ Tk_PhotoSetSize_Panic(
Tcl_Panic(TK_PHOTO_ALLOC_FAILURE_MESSAGE);
}
}
+#endif /* TK_NO_DEPRECATED */
/*
* Local Variables:
diff --git a/generic/tkInt.h b/generic/tkInt.h
index a52339d..ed22fc3 100644
--- a/generic/tkInt.h
+++ b/generic/tkInt.h
@@ -1224,6 +1224,7 @@ MODULE_SCOPE int TkInitTkCmd(Tcl_Interp *interp,
MODULE_SCOPE int TkInitFontchooser(Tcl_Interp *interp,
ClientData clientData);
MODULE_SCOPE void TkpWarpPointer(TkDisplay *dispPtr);
+MODULE_SCOPE void TkpCancelWarp(TkDisplay *dispPtr);
MODULE_SCOPE int TkListCreateFrame(ClientData clientData,
Tcl_Interp *interp, Tcl_Obj *listObj,
int toplevel, Tcl_Obj *nameObj);
diff --git a/generic/tkPanedWindow.c b/generic/tkPanedWindow.c
index 4bfc695..e1a7d97 100644
--- a/generic/tkPanedWindow.c
+++ b/generic/tkPanedWindow.c
@@ -1789,10 +1789,18 @@ ArrangePanes(
*/
if (horizontal) {
- paneSize = slavePtr->paneWidth;
+ if (slavePtr->width > 0) {
+ paneSize = slavePtr->width;
+ } else {
+ paneSize = slavePtr->paneWidth;
+ }
stretchReserve -= paneSize + (2 * slavePtr->padx);
} else {
- paneSize = slavePtr->paneHeight;
+ if (slavePtr->height > 0) {
+ paneSize = slavePtr->height;
+ } else {
+ paneSize = slavePtr->paneHeight;
+ }
stretchReserve -= paneSize + (2 * slavePtr->pady);
}
if (IsStretchable(slavePtr->stretch,i,first,last)
@@ -1842,10 +1850,18 @@ ArrangePanes(
*/
if (horizontal) {
- paneSize = slavePtr->paneWidth;
+ if (slavePtr->width > 0) {
+ paneSize = slavePtr->width;
+ } else {
+ paneSize = slavePtr->paneWidth;
+ }
pwSize = pwWidth;
} else {
- paneSize = slavePtr->paneHeight;
+ if (slavePtr->height > 0) {
+ paneSize = slavePtr->height;
+ } else {
+ paneSize = slavePtr->paneHeight;
+ }
pwSize = pwHeight;
}
if (IsStretchable(slavePtr->stretch, i, first, last)) {
diff --git a/generic/tkSelect.c b/generic/tkSelect.c
index 74b3964..4c3bbfd 100644
--- a/generic/tkSelect.c
+++ b/generic/tkSelect.c
@@ -190,8 +190,8 @@ Tk_CreateSelHandler(
* should make a copy for this selPtr.
*/
- unsigned cmdInfoLen = Tk_Offset(CommandInfo, command) +
- ((CommandInfo *)clientData)->cmdLength + 1;
+ unsigned cmdInfoLen = Tk_Offset(CommandInfo, command) + 1 +
+ ((CommandInfo *)clientData)->cmdLength;
selPtr->clientData = ckalloc(cmdInfoLen);
memcpy(selPtr->clientData, clientData, cmdInfoLen);
diff --git a/generic/tkStubInit.c b/generic/tkStubInit.c
index f760677..a491622 100644
--- a/generic/tkStubInit.c
+++ b/generic/tkStubInit.c
@@ -43,6 +43,12 @@ MODULE_SCOPE const TkStubs tkStubs;
#ifdef TK_NO_DEPRECATED
#define Tk_FreeXId 0
+#define Tk_PhotoPutBlock_NoComposite 0
+#define Tk_PhotoPutZoomedBlock_NoComposite 0
+#define Tk_PhotoExpand_Panic 0
+#define Tk_PhotoPutBlock_Panic 0
+#define Tk_PhotoPutZoomedBlock_Panic 0
+#define Tk_PhotoSetSize_Panic 0
#else
static void
doNothing(void)
diff --git a/generic/tkWindow.c b/generic/tkWindow.c
index 81d4f0d..ef06a5b 100644
--- a/generic/tkWindow.c
+++ b/generic/tkWindow.c
@@ -239,6 +239,8 @@ TkCloseDisplay(
{
TkClipCleanup(dispPtr);
+ TkpCancelWarp(dispPtr);
+
if (dispPtr->name != NULL) {
ckfree(dispPtr->name);
}
diff --git a/generic/ttk/ttkNotebook.c b/generic/ttk/ttkNotebook.c
index 06aa275..83d7db9 100644
--- a/generic/ttk/ttkNotebook.c
+++ b/generic/ttk/ttkNotebook.c
@@ -4,7 +4,6 @@
#include <string.h>
#include <ctype.h>
-#include <math.h>
#include <stdio.h>
#include <tk.h>
@@ -470,17 +469,15 @@ static void SqueezeTabs(
if (nTabs > 0) {
int difference = available - needed;
- double fraction = (double)difference / needed;
+ double delta = (double)difference / needed;
double slack = 0;
- double ad;
int i;
for (i = 0; i < nTabs; ++i) {
Tab *tab = Ttk_SlaveData(nb->notebook.mgr,i);
-
- ad = slack + tab->width * fraction;
+ double ad = slack + tab->width * delta;
tab->width += (int)ad;
- slack = ad - floor(ad);
+ slack = ad - (int)ad;
}
}
}
diff --git a/macosx/tkMacOSXDialog.c b/macosx/tkMacOSXDialog.c
index 80a7a11..3397f71 100644
--- a/macosx/tkMacOSXDialog.c
+++ b/macosx/tkMacOSXDialog.c
@@ -6,6 +6,7 @@
* Copyright (c) 1996-1997 Sun Microsystems, Inc.
* Copyright 2001-2009, Apple Inc.
* Copyright (c) 2006-2009 Daniel A. Steffen <das@users.sourceforge.net>
+ * Copyright (c) 2017 Christian Gollwitzer.
*
* See the file "license.terms" for information on usage and redistribution of
* this file, and for a DISCLAIMER OF ALL WARRANTIES.
@@ -24,6 +25,22 @@
#define modalOther -1
#define modalError -2
+/*Vars for filtering in "open file" and "save file" dialogs.*/
+typedef struct {
+ bool doFileTypes; // show the accessory view which displays the filter menu
+ bool preselectFilter; // a filter was selected by the typevariable
+ bool userHasSelectedFilter; // The user has changed the filter in the accessory view
+ NSMutableArray *fileTypeNames; // array of names, e.g. "Text document"
+ NSMutableArray *fileTypeExtensions; // array of allowed extensions per name, e.g. "txt", "doc"
+ NSMutableArray *fileTypeLabels; // displayed string, e.g. "Text document (.txt, .doc)"
+ NSMutableArray *allAllowedExtensions; // set of all allowed extensions
+ NSInteger fileTypeIndex; // index of currently selected filter
+} filepanelFilterInfo;
+
+filepanelFilterInfo filterInfo;
+
+NSOpenPanel *openpanel;
+NSSavePanel *savepanel;
static const char *const colorOptionStrings[] = {
"-initialcolor", "-parent", "-title", NULL
@@ -142,22 +159,6 @@ static const short alertNativeButtonIndexAndTypeToButtonIndex[][3] = {
[TYPE_YESNOCANCEL] = {5, 6, 4},
};
-/*
- * Construct a file URL from directory and filename. Either may
- * be nil. If both are nil, returns nil.
- */
-#if MAC_OS_X_VERSION_MIN_REQUIRED > 1050
-static NSURL *getFileURL(NSString *directory, NSString *filename) {
- NSURL *url = nil;
- if (directory) {
- url = [NSURL fileURLWithPath:directory];
- }
- if (filename) {
- url = [NSURL URLWithString:filename relativeToURL:url];
- }
- return url;
-}
-#endif
#pragma mark TKApplication(TKDialog)
@@ -212,6 +213,7 @@ static NSURL *getFileURL(NSString *directory, NSString *filename) {
}
}
+
- (void) tkAlertDidEnd: (NSAlert *) alert returnCode: (NSInteger) returnCode
contextInfo: (void *) contextInfo
{
@@ -247,6 +249,23 @@ static NSURL *getFileURL(NSString *directory, NSString *filename) {
ckfree(callbackInfo);
}
}
+
+- (void)selectFormat:(id)sender {
+ NSPopUpButton *button = (NSPopUpButton *)sender;
+ filterInfo.fileTypeIndex = [button indexOfSelectedItem];
+ NSMutableArray *allowedtypes = filterInfo.fileTypeExtensions[filterInfo.fileTypeIndex];
+ [openpanel setAllowedFileTypes:allowedtypes];
+ filterInfo.userHasSelectedFilter = true;
+
+}
+
+- (void)saveFormat:(id)sender {
+ NSPopUpButton *button = (NSPopUpButton *)sender;
+ filterInfo.fileTypeIndex = [button indexOfSelectedItem];
+ NSMutableArray *allowedtypes = filterInfo.fileTypeExtensions[filterInfo.fileTypeIndex];
+ [savepanel setAllowedFileTypes:allowedtypes];
+}
+
@end
#pragma mark -
@@ -360,6 +379,98 @@ Tk_ChooseColorObjCmd(
end:
return result;
}
+
+/* dissect the -filetype nested lists and store the information
+ * in the filterInfo structure */
+int parseFileFilters(Tcl_Interp *interp, Tcl_Obj *fileTypesPtr, Tcl_Obj *typeVariablePtr) {
+
+ if (!fileTypesPtr) {
+ filterInfo.doFileTypes = false;
+ return TCL_OK;
+ }
+
+ FileFilterList fl;
+ TkInitFileFilters(&fl);
+ if (TkGetFileFilters(interp, &fl, fileTypesPtr, 0) != TCL_OK) {
+ TkFreeFileFilters(&fl);
+ return TCL_ERROR;
+ }
+
+ filterInfo.doFileTypes = (fl.filters != NULL);
+
+ filterInfo.fileTypeIndex = 0;
+ filterInfo.fileTypeExtensions = [NSMutableArray array];
+ filterInfo.fileTypeNames = [NSMutableArray array];
+ filterInfo.fileTypeLabels = [NSMutableArray array];
+ filterInfo.allAllowedExtensions = [NSMutableArray array];
+
+ if (filterInfo.doFileTypes) {
+ for (FileFilter *filterPtr = fl.filters; filterPtr;
+ filterPtr = filterPtr->next) {
+ NSString * name = [[NSString alloc] initWithUTF8String: filterPtr -> name];
+ [filterInfo.fileTypeNames addObject:name];
+ [name release];
+ NSMutableArray * clauseextensions = [NSMutableArray array];
+ NSMutableArray * displayextensions = [NSMutableArray array];
+
+ for (FileFilterClause *clausePtr = filterPtr->clauses; clausePtr;
+ clausePtr = clausePtr->next) {
+ for (GlobPattern *globPtr = clausePtr->patterns; globPtr;
+ globPtr = globPtr->next) {
+ const char *str = globPtr->pattern;
+ while (*str && (*str == '*' || *str == '.')) {
+ str++;
+ }
+ if (*str) {
+ NSString *extension = [[NSString alloc] initWithUTF8String:str];
+ if (![filterInfo.allAllowedExtensions containsObject:extension]) {
+ [filterInfo.allAllowedExtensions addObject:extension];
+ }
+
+ [clauseextensions addObject:extension];
+ [displayextensions addObject:[@"." stringByAppendingString:extension]];
+
+ [extension release];
+ }
+ }
+ }
+ [filterInfo.fileTypeExtensions addObject:clauseextensions];
+
+ NSMutableString * label = [[NSMutableString alloc] initWithString:name];
+ [label appendString:@" ("];
+ [label appendString:[displayextensions componentsJoinedByString:@", "]];
+ [label appendString:@")"];
+ [filterInfo.fileTypeLabels addObject:label];
+ [label release];
+
+ }
+
+ /* Check if the typevariable exists and matches one of the names */
+ filterInfo.preselectFilter = false;
+ filterInfo.userHasSelectedFilter = false;
+ if (typeVariablePtr) {
+ /* extract the variable content as a NSString */
+ Tcl_Obj *selectedFileTypeObj = Tcl_ObjGetVar2(interp, typeVariablePtr, NULL, TCL_GLOBAL_ONLY);
+
+ /* check that the typevariable exists */
+ if (selectedFileTypeObj != NULL) {
+ const char *selectedFileType = Tcl_GetString(selectedFileTypeObj);
+ NSString *selectedFileTypeStr = [[NSString alloc] initWithUTF8String:selectedFileType];
+ NSUInteger index = [filterInfo.fileTypeNames indexOfObject:selectedFileTypeStr];
+
+ if (index != NSNotFound) {
+ filterInfo.fileTypeIndex = index;
+ filterInfo.preselectFilter = true;
+ }
+ }
+ }
+
+ }
+
+ TkFreeFileFilters(&fl);
+ return TCL_OK;
+}
+
/*
*----------------------------------------------------------------------
@@ -388,19 +499,16 @@ Tk_GetOpenFileObjCmd(
char *str;
int i, result = TCL_ERROR, haveParentOption = 0;
int index, len, multiple = 0;
- FileFilterList fl;
- Tcl_Obj *cmdObj = NULL, *typeVariablePtr = NULL;
+ Tcl_Obj *cmdObj = NULL, *typeVariablePtr = NULL, *fileTypesPtr = NULL;
FilePanelCallbackInfo callbackInfoStruct;
FilePanelCallbackInfo *callbackInfo = &callbackInfoStruct;
NSString *directory = nil, *filename = nil;
- NSString *message, *title, *type;
+ NSString *message = nil, *title = nil;
NSWindow *parent;
- NSMutableArray *fileTypes = nil;
- NSOpenPanel *panel = [NSOpenPanel openPanel];
+ openpanel = [NSOpenPanel openPanel];
NSInteger modalReturnCode = modalError;
BOOL parentIsKey = NO;
- TkInitFileFilters(&fl);
for (i = 1; i < objc; i += 2) {
if (Tcl_GetIndexFromObjStruct(interp, objv[i], openOptionStrings,
sizeof(char *), "option", TCL_EXACT, &index) != TCL_OK) {
@@ -416,9 +524,7 @@ Tk_GetOpenFileObjCmd(
case OPEN_DEFAULT:
break;
case OPEN_FILETYPES:
- if (TkGetFileFilters(interp, &fl, objv[i + 1], 0) != TCL_OK) {
- goto end;
- }
+ fileTypesPtr = objv[i + 1];
break;
case OPEN_INITDIR:
str = Tcl_GetStringFromObj(objv[i + 1], &len);
@@ -432,13 +538,12 @@ Tk_GetOpenFileObjCmd(
if (len) {
filename = [[[NSString alloc] initWithUTF8String:str]
autorelease];
+ [openpanel setNameFieldStringValue:filename];
}
break;
case OPEN_MESSAGE:
message = [[NSString alloc] initWithUTF8String:
Tcl_GetString(objv[i + 1])];
- [panel setMessage:message];
- [message release];
break;
case OPEN_MULTIPLE:
if (Tcl_GetBooleanFromObj(interp, objv[i + 1],
@@ -457,8 +562,6 @@ Tk_GetOpenFileObjCmd(
case OPEN_TITLE:
title = [[NSString alloc] initWithUTF8String:
Tcl_GetString(objv[i + 1])];
- [panel setTitle:title];
- [title release];
break;
case OPEN_TYPEVARIABLE:
typeVariablePtr = objv[i + 1];
@@ -468,40 +571,70 @@ Tk_GetOpenFileObjCmd(
break;
}
}
- [panel setAllowsMultipleSelection:multiple];
- if (fl.filters) {
- fileTypes = [NSMutableArray array];
- for (FileFilter *filterPtr = fl.filters; filterPtr;
- filterPtr = filterPtr->next) {
- for (FileFilterClause *clausePtr = filterPtr->clauses; clausePtr;
- clausePtr = clausePtr->next) {
- for (GlobPattern *globPtr = clausePtr->patterns; globPtr;
- globPtr = globPtr->next) {
- str = globPtr->pattern;
- while (*str && (*str == '*' || *str == '.')) {
- str++;
- }
- if (*str) {
- type = [[NSString alloc] initWithUTF8String:str];
- if (![fileTypes containsObject:type]) {
- [fileTypes addObject:type];
- }
- [type release];
- }
- }
- for (MacFileType *mfPtr = clausePtr->macTypes; mfPtr;
- mfPtr = mfPtr->next) {
- if (mfPtr->type) {
- type = NSFileTypeForHFSTypeCode(mfPtr->type);
- if (![fileTypes containsObject:type]) {
- [fileTypes addObject:type];
- }
- }
- }
- }
+
+ /* From OSX 10.11, the title string is silently ignored.
+ * Prepend the title to the message
+ * NOTE should be conditional on OSX version, but
+ * -mmacosx-version-min does not revert this behaviour*/
+ if (title) {
+ [openpanel setTitle:title];
+ if (message) {
+ NSString *fullmessage = [[NSString alloc] initWithFormat:@"%@\n%@",title,message];
+ [message release];
+ [title release];
+ message = fullmessage;
+ } else {
+ message = title;
+ }
+ }
+
+ if (message) {
+ [openpanel setMessage:message];
+ [message release];
+ }
+
+ [openpanel setAllowsMultipleSelection:multiple];
+
+ if (parseFileFilters(interp, fileTypesPtr, typeVariablePtr) != TCL_OK) {
+ goto end;
+ }
+
+ if (filterInfo.doFileTypes) {
+ NSView *accessoryView = [[NSView alloc] initWithFrame:NSMakeRect(0.0, 0.0, 200, 32.0)];
+ NSTextField *label = [[NSTextField alloc] initWithFrame:NSMakeRect(0, 0, 60, 22)];
+ [label setEditable:NO];
+ [label setStringValue:@"Enable:"];
+ [label setBordered:NO];
+ [label setBezeled:NO];
+ [label setDrawsBackground:NO];
+
+ NSPopUpButton *popupButton = [[NSPopUpButton alloc] initWithFrame:NSMakeRect(50.0, 2, 140, 22.0) pullsDown:NO];
+ [popupButton addItemsWithTitles:filterInfo.fileTypeLabels];
+ [popupButton setAction:@selector(selectFormat:)];
+
+ [accessoryView addSubview:label];
+ [accessoryView addSubview:popupButton];
+
+ if (filterInfo.preselectFilter) {
+ /* A specific filter was selected from the typevariable. Select it and
+ * open the accessory view */
+ [popupButton selectItemAtIndex:filterInfo.fileTypeIndex];
+ /* on OSX > 10.11, the optons are not visible by default. Ergo allow all file types
+ [openpanel setAllowedFileTypes:filterInfo.fileTypeExtensions[filterInfo.fileTypeIndex]];
+ */
+ [openpanel setAllowedFileTypes:filterInfo.allAllowedExtensions];
+ } else {
+ [openpanel setAllowedFileTypes:filterInfo.allAllowedExtensions];
}
+
+ [openpanel setAllowsOtherFileTypes:NO];
+
+ [openpanel setAccessoryView:accessoryView];
+ } else {
+ /* No filters are given. Allow picking all files */
+ [openpanel setAllowsOtherFileTypes:YES];
}
- [panel setAllowedFileTypes:fileTypes];
+
if (cmdObj) {
callbackInfo = ckalloc(sizeof(FilePanelCallbackInfo));
if (Tcl_IsShared(cmdObj)) {
@@ -509,6 +642,7 @@ Tk_GetOpenFileObjCmd(
}
Tcl_IncrRefCount(cmdObj);
}
+
callbackInfo->cmdObj = cmdObj;
callbackInfo->interp = interp;
callbackInfo->multiple = multiple;
@@ -516,52 +650,63 @@ Tk_GetOpenFileObjCmd(
if (haveParentOption && parent && ![parent attachedSheet]) {
parentIsKey = [parent isKeyWindow];
#if MAC_OS_X_VERSION_MIN_REQUIRED < 1060
- [panel beginSheetForDirectory:directory
+ [openpanel beginSheetForDirectory:directory
file:filename
- types:fileTypes
+ types:openFileTypes
modalForWindow:parent
modalDelegate:NSApp
didEndSelector:
@selector(tkFilePanelDidEnd:returnCode:contextInfo:)
contextInfo:callbackInfo];
#else
- [panel setAllowedFileTypes:fileTypes];
- [panel setDirectoryURL:getFileURL(directory, filename)];
- [panel beginSheetModalForWindow:parent
+ if (directory) {
+ [openpanel setDirectoryURL:[NSURL fileURLWithPath:directory isDirectory:YES]];
+ }
+ [openpanel setNameFieldStringValue:filename];
+ [openpanel beginSheetModalForWindow:parent
completionHandler:^(NSInteger returnCode)
- { [NSApp tkFilePanelDidEnd:panel
+ { [NSApp tkFilePanelDidEnd:openpanel
returnCode:returnCode
contextInfo:callbackInfo ]; } ];
#endif
- modalReturnCode = cmdObj ? modalOther : [NSApp runModalForWindow:panel];
+ modalReturnCode = cmdObj ? modalOther : [NSApp runModalForWindow:openpanel];
} else {
#if MAC_OS_X_VERSION_MIN_REQUIRED < 1060
- modalReturnCode = [panel runModalForDirectory:directory
+ modalReturnCode = [openpanel runModalForDirectory:directory
file:filename];
#else
- [panel setDirectoryURL:getFileURL(directory, filename)];
- modalReturnCode = [panel runModal];
+ if (directory) {
+ [openpanel setDirectoryURL:[NSURL fileURLWithPath:directory isDirectory:YES]];
+ }
+ [openpanel setNameFieldStringValue:filename];
+ modalReturnCode = [openpanel runModal];
#endif
- [NSApp tkFilePanelDidEnd:panel returnCode:modalReturnCode
+ [NSApp tkFilePanelDidEnd:openpanel returnCode:modalReturnCode
contextInfo:callbackInfo];
}
result = (modalReturnCode != modalError) ? TCL_OK : TCL_ERROR;
if (parentIsKey) {
[parent makeKeyWindow];
}
- if (typeVariablePtr && result == TCL_OK) {
+
+ if ((typeVariablePtr && (modalReturnCode == NSOKButton)) &&
+ filterInfo.doFileTypes && filterInfo.userHasSelectedFilter) {
/*
- * The -typevariable option is not really supported.
+ * The -typevariable must be set to the selected file type, if the dialog was not cancelled
*/
-
- Tcl_SetVar2(interp, Tcl_GetString(typeVariablePtr), NULL,
- "", TCL_GLOBAL_ONLY);
+ #if 0
+ NSLog(@"result: %i modal: %li", result, (long)modalReturnCode);
+ #endif
+ NSString * selectedFilter = filterInfo.fileTypeNames[filterInfo.fileTypeIndex];
+ Tcl_ObjSetVar2(interp, typeVariablePtr, NULL,
+ Tcl_NewStringObj([selectedFilter UTF8String], -1), TCL_GLOBAL_ONLY);
}
+
end:
- TkFreeFileFilters(&fl);
return result;
}
+
/*
*----------------------------------------------------------------------
@@ -591,19 +736,16 @@ Tk_GetSaveFileObjCmd(
int i, result = TCL_ERROR, haveParentOption = 0;
int confirmOverwrite = 1;
int index, len;
- FileFilterList fl;
- Tcl_Obj *cmdObj = NULL;
+ Tcl_Obj *cmdObj = NULL, *typeVariablePtr = NULL, *fileTypesPtr = NULL;
FilePanelCallbackInfo callbackInfoStruct;
FilePanelCallbackInfo *callbackInfo = &callbackInfoStruct;
NSString *directory = nil, *filename = nil, *defaultType = nil;
- NSString *message, *title, *type;
+ NSString *message = nil, *title = nil;
NSWindow *parent;
- NSMutableArray *fileTypes = nil;
- NSSavePanel *panel = [NSSavePanel savePanel];
+ savepanel = [NSSavePanel savePanel];
NSInteger modalReturnCode = modalError;
BOOL parentIsKey = NO;
- TkInitFileFilters(&fl);
for (i = 1; i < objc; i += 2) {
if (Tcl_GetIndexFromObjStruct(interp, objv[i], saveOptionStrings,
sizeof(char *), "option", TCL_EXACT, &index) != TCL_OK) {
@@ -616,96 +758,120 @@ Tk_GetSaveFileObjCmd(
goto end;
}
switch (index) {
- case SAVE_DEFAULT:
- str = Tcl_GetStringFromObj(objv[i + 1], &len);
- while (*str && (*str == '*' || *str == '.')) {
- str++;
- }
- if (*str) {
- defaultType = [[[NSString alloc] initWithUTF8String:str]
- autorelease];
- }
- break;
- case SAVE_FILETYPES:
- if (TkGetFileFilters(interp, &fl, objv[i + 1], 0) != TCL_OK) {
- goto end;
- }
- break;
- case SAVE_INITDIR:
- str = Tcl_GetStringFromObj(objv[i + 1], &len);
- if (len) {
- directory = [[[NSString alloc] initWithUTF8String:str]
- autorelease];
- }
- break;
- case SAVE_INITFILE:
- str = Tcl_GetStringFromObj(objv[i + 1], &len);
- if (len) {
- filename = [[[NSString alloc] initWithUTF8String:str]
- autorelease];
- }
- break;
- case SAVE_MESSAGE:
- message = [[NSString alloc] initWithUTF8String:
- Tcl_GetString(objv[i + 1])];
- [panel setMessage:message];
+ case SAVE_DEFAULT:
+ str = Tcl_GetStringFromObj(objv[i + 1], &len);
+ while (*str && (*str == '*' || *str == '.')) {
+ str++;
+ }
+ if (*str) {
+ defaultType = [[[NSString alloc] initWithUTF8String:str]
+ autorelease];
+ }
+ break;
+ case SAVE_FILETYPES:
+ fileTypesPtr = objv[i + 1];
+ break;
+ case SAVE_INITDIR:
+ str = Tcl_GetStringFromObj(objv[i + 1], &len);
+ if (len) {
+ directory = [[[NSString alloc] initWithUTF8String:str]
+ autorelease];
+ }
+ break;
+ case SAVE_INITFILE:
+ str = Tcl_GetStringFromObj(objv[i + 1], &len);
+ if (len) {
+ filename = [[[NSString alloc] initWithUTF8String:str]
+ autorelease];
+ [savepanel setNameFieldStringValue:filename];
+ }
+ break;
+ case SAVE_MESSAGE:
+ message = [[NSString alloc] initWithUTF8String:
+ Tcl_GetString(objv[i + 1])];
+ break;
+ case SAVE_PARENT:
+ str = Tcl_GetStringFromObj(objv[i + 1], &len);
+ tkwin = Tk_NameToWindow(interp, str, tkwin);
+ if (!tkwin) {
+ goto end;
+ }
+ haveParentOption = 1;
+ break;
+ case SAVE_TITLE:
+ title = [[NSString alloc] initWithUTF8String:
+ Tcl_GetString(objv[i + 1])];
+ break;
+ case SAVE_TYPEVARIABLE:
+ typeVariablePtr = objv[i + 1];
+ break;
+ case SAVE_COMMAND:
+ cmdObj = objv[i+1];
+ break;
+ case SAVE_CONFIRMOW:
+ if (Tcl_GetBooleanFromObj(interp, objv[i + 1],
+ &confirmOverwrite) != TCL_OK) {
+ goto end;
+ }
+ break;
+ }
+ }
+
+ if (title) {
+ [savepanel setTitle:title];
+ if (message) {
+ NSString *fullmessage = [[NSString alloc] initWithFormat:@"%@\n%@",title,message];
[message release];
- break;
- case SAVE_PARENT:
- str = Tcl_GetStringFromObj(objv[i + 1], &len);
- tkwin = Tk_NameToWindow(interp, str, tkwin);
- if (!tkwin) {
- goto end;
- }
- haveParentOption = 1;
- break;
- case SAVE_TITLE:
- title = [[NSString alloc] initWithUTF8String:
- Tcl_GetString(objv[i + 1])];
- [panel setTitle:title];
[title release];
- break;
- case SAVE_TYPEVARIABLE:
- break;
- case SAVE_COMMAND:
- cmdObj = objv[i+1];
- break;
- case SAVE_CONFIRMOW:
- if (Tcl_GetBooleanFromObj(interp, objv[i + 1],
- &confirmOverwrite) != TCL_OK) {
- goto end;
- }
- break;
+ message = fullmessage;
+ } else {
+ message = title;
}
}
- if (fl.filters || defaultType) {
- fileTypes = [NSMutableArray array];
- [fileTypes addObject:defaultType ? defaultType : (id)kUTTypeContent];
- for (FileFilter *filterPtr = fl.filters; filterPtr;
- filterPtr = filterPtr->next) {
- for (FileFilterClause *clausePtr = filterPtr->clauses; clausePtr;
- clausePtr = clausePtr->next) {
- for (GlobPattern *globPtr = clausePtr->patterns; globPtr;
- globPtr = globPtr->next) {
- str = globPtr->pattern;
- while (*str && (*str == '*' || *str == '.')) {
- str++;
- }
- if (*str) {
- type = [[NSString alloc] initWithUTF8String:str];
- if (![fileTypes containsObject:type]) {
- [fileTypes addObject:type];
- }
- [type release];
- }
- }
- }
- }
- [panel setAllowedFileTypes:fileTypes];
- [panel setAllowsOtherFileTypes:YES];
+
+ if (message) {
+ [savepanel setMessage:message];
+ [message release];
+ }
+
+ if (parseFileFilters(interp, fileTypesPtr, typeVariablePtr) != TCL_OK) {
+ goto end;
}
- [panel setCanSelectHiddenExtension:YES];
- [panel setExtensionHidden:NO];
+
+ if (filterInfo.doFileTypes) {
+ NSView *accessoryView = [[NSView alloc] initWithFrame:NSMakeRect(0.0, 0.0, 200, 32.0)];
+ NSTextField *label = [[NSTextField alloc] initWithFrame:NSMakeRect(0, 0, 60, 22)];
+ [label setEditable:NO];
+ [label setStringValue:NSLocalizedString(@"Format:", nil)];
+ [label setBordered:NO];
+ [label setBezeled:NO];
+ [label setDrawsBackground:NO];
+
+ NSPopUpButton *popupButton = [[NSPopUpButton alloc] initWithFrame:NSMakeRect(50.0, 2, 140, 22.0) pullsDown:NO];
+ [popupButton addItemsWithTitles:filterInfo.fileTypeLabels];
+ [popupButton selectItemAtIndex:filterInfo.fileTypeIndex];
+ [popupButton setAction:@selector(saveFormat:)];
+
+ [accessoryView addSubview:label];
+ [accessoryView addSubview:popupButton];
+
+ [savepanel setAccessoryView:accessoryView];
+
+ [savepanel setAllowedFileTypes:filterInfo.fileTypeExtensions[filterInfo.fileTypeIndex]];
+ [savepanel setAllowsOtherFileTypes:NO];
+ } else if (defaultType) {
+ /* If no filetypes are given, defaultextension is an alternative way
+ * to specify the attached extension. Just propose this extension,
+ * but don't display an accessory view */
+ NSMutableArray *AllowedFileTypes = [NSMutableArray array];
+ [AllowedFileTypes addObject:defaultType];
+ [savepanel setAllowedFileTypes:AllowedFileTypes];
+ [savepanel setAllowsOtherFileTypes:YES];
+ }
+
+ [savepanel setCanSelectHiddenExtension:YES];
+ [savepanel setExtensionHidden:NO];
+
if (cmdObj) {
callbackInfo = ckalloc(sizeof(FilePanelCallbackInfo));
if (Tcl_IsShared(cmdObj)) {
@@ -716,11 +882,12 @@ Tk_GetSaveFileObjCmd(
callbackInfo->cmdObj = cmdObj;
callbackInfo->interp = interp;
callbackInfo->multiple = 0;
+
parent = TkMacOSXDrawableWindow(((TkWindow *) tkwin)->window);
if (haveParentOption && parent && ![parent attachedSheet]) {
parentIsKey = [parent isKeyWindow];
#if MAC_OS_X_VERSION_MIN_REQUIRED < 1060
- [panel beginSheetForDirectory:directory
+ [savepanel beginSheetForDirectory:directory
file:filename
modalForWindow:parent
modalDelegate:NSApp
@@ -728,30 +895,52 @@ Tk_GetSaveFileObjCmd(
@selector(tkFilePanelDidEnd:returnCode:contextInfo:)
contextInfo:callbackInfo];
#else
- [panel setDirectoryURL:getFileURL(directory, filename)];
- [panel beginSheetModalForWindow:parent
+ if (directory) {
+ [savepanel setDirectoryURL:[NSURL fileURLWithPath:directory isDirectory:YES]];
+ }
+ [savepanel setNameFieldStringValue:filename];
+ [savepanel beginSheetModalForWindow:parent
completionHandler:^(NSInteger returnCode)
- { [NSApp tkFilePanelDidEnd:panel
+ { [NSApp tkFilePanelDidEnd:savepanel
returnCode:returnCode
contextInfo:callbackInfo ]; } ];
#endif
- modalReturnCode = cmdObj ? modalOther : [NSApp runModalForWindow:panel];
+ modalReturnCode = cmdObj ? modalOther : [NSApp runModalForWindow:savepanel];
} else {
#if MAC_OS_X_VERSION_MIN_REQUIRED < 1060
- modalReturnCode = [panel runModalForDirectory:directory file:filename];
+ modalReturnCode = [savepanel runModalForDirectory:directory file:filename];
#else
- [panel setDirectoryURL:getFileURL(directory, filename)];
- modalReturnCode = [panel runModal];
+ if (directory) {
+ [savepanel setDirectoryURL:[NSURL fileURLWithPath:directory isDirectory:YES]];
+ }
+ [savepanel setNameFieldStringValue:filename];
+ modalReturnCode = [savepanel runModal];
+ #if 0
+ NSLog(@"modal: %li", modalReturnCode);
+ #endif
#endif
- [NSApp tkFilePanelDidEnd:panel returnCode:modalReturnCode
+ [NSApp tkFilePanelDidEnd:savepanel returnCode:modalReturnCode
contextInfo:callbackInfo];
}
result = (modalReturnCode != modalError) ? TCL_OK : TCL_ERROR;
if (parentIsKey) {
[parent makeKeyWindow];
}
+
+ if ((typeVariablePtr && (modalReturnCode == NSOKButton)) && filterInfo.doFileTypes) {
+ /*
+ * The -typevariable must be set to the selected file type, if the dialog was not cancelled
+ */
+ #if 0
+ NSLog(@"result: %i modal: %li", result, (long)modalReturnCode);
+ #endif
+ NSString * selectedFilter = filterInfo.fileTypeNames[filterInfo.fileTypeIndex];
+ Tcl_ObjSetVar2(interp, typeVariablePtr, NULL,
+ Tcl_NewStringObj([selectedFilter UTF8String], -1), TCL_GLOBAL_ONLY);
+ }
+
+
end:
- TkFreeFileFilters(&fl);
return result;
}
@@ -787,7 +976,7 @@ Tk_ChooseDirectoryObjCmd(
Tcl_Obj *cmdObj = NULL;
FilePanelCallbackInfo callbackInfoStruct;
FilePanelCallbackInfo *callbackInfo = &callbackInfoStruct;
- NSString *directory = nil, *filename = nil;
+ NSString *directory = nil;
NSString *message, *title;
NSWindow *parent;
NSOpenPanel *panel = [NSOpenPanel openPanel];
@@ -863,13 +1052,13 @@ Tk_ChooseDirectoryObjCmd(
parentIsKey = [parent isKeyWindow];
#if MAC_OS_X_VERSION_MIN_REQUIRED < 1060
[panel beginSheetForDirectory:directory
- file:filename
+ file:nil
modalForWindow:parent
modalDelegate:NSApp
didEndSelector: @selector(tkFilePanelDidEnd:returnCode:contextInfo:)
contextInfo:callbackInfo];
#else
- [panel setDirectoryURL:getFileURL(directory, filename)];
+ [panel setDirectoryURL:[NSURL fileURLWithPath:directory isDirectory:YES]];
[panel beginSheetModalForWindow:parent
completionHandler:^(NSInteger returnCode)
{ [NSApp tkFilePanelDidEnd:panel
@@ -881,7 +1070,7 @@ Tk_ChooseDirectoryObjCmd(
#if MAC_OS_X_VERSION_MIN_REQUIRED < 1060
modalReturnCode = [panel runModalForDirectory:directory file:nil];
#else
- [panel setDirectoryURL:getFileURL(directory, filename)];
+ [panel setDirectoryURL:[NSURL fileURLWithPath:directory isDirectory:YES]];
modalReturnCode = [panel runModal];
#endif
[NSApp tkFilePanelDidEnd:panel returnCode:modalReturnCode
diff --git a/macosx/tkMacOSXFont.c b/macosx/tkMacOSXFont.c
index b5ae1a3..fd4c19a 100644
--- a/macosx/tkMacOSXFont.c
+++ b/macosx/tkMacOSXFont.c
@@ -515,7 +515,7 @@ TkpGetFontFromAttributes(
/* Set of attributes to match. */
{
MacFont *fontPtr;
- int points = TkFontGetPoints(tkwin, faPtr->size);
+ int points = (int)(TkFontGetPoints(tkwin, faPtr->size) + 0.5);
NSFontTraitMask traits = GetNSFontTraitsFromTkFontAttributes(faPtr);
NSInteger weight = (faPtr->weight == TK_FW_BOLD ? 9 : 5);
NSFont *nsFont;
diff --git a/macosx/tkMacOSXScrlbr.c b/macosx/tkMacOSXScrlbr.c