diff options
author | jan.nijtmans <nijtmans@users.sourceforge.net> | 2024-06-30 17:07:58 (GMT) |
---|---|---|
committer | jan.nijtmans <nijtmans@users.sourceforge.net> | 2024-06-30 17:07:58 (GMT) |
commit | b1b5c61a7458041a11b7a5920b22689566345256 (patch) | |
tree | 24244422ce05e0adb9528fa7d76f3c95ff398341 /win | |
parent | 81291da33b1e6f1cab8020cb72dd43a974a0a20e (diff) | |
parent | 247c0ea91f30dcb6e0897e0598ddbaff82525184 (diff) | |
download | tk-b1b5c61a7458041a11b7a5920b22689566345256.zip tk-b1b5c61a7458041a11b7a5920b22689566345256.tar.gz tk-b1b5c61a7458041a11b7a5920b22689566345256.tar.bz2 |
Merge 9.0. Streamline some indenting
Diffstat (limited to 'win')
-rw-r--r-- | win/nmakehlp.c | 49 | ||||
-rw-r--r-- | win/tkWinClipboard.c | 8 | ||||
-rw-r--r-- | win/tkWinDefault.h | 2 | ||||
-rw-r--r-- | win/tkWinDialog.c | 720 | ||||
-rw-r--r-- | win/tkWinDraw.c | 24 | ||||
-rw-r--r-- | win/tkWinEmbed.c | 10 | ||||
-rw-r--r-- | win/tkWinGDI.c | 86 | ||||
-rw-r--r-- | win/tkWinIco.c | 20 | ||||
-rw-r--r-- | win/tkWinIco.h | 3 | ||||
-rw-r--r-- | win/tkWinKey.c | 12 | ||||
-rw-r--r-- | win/tkWinMenu.c | 38 | ||||
-rw-r--r-- | win/tkWinPointer.c | 6 | ||||
-rw-r--r-- | win/tkWinScrlbr.c | 4 | ||||
-rw-r--r-- | win/tkWinSendCom.h | 6 | ||||
-rw-r--r-- | win/tkWinSysTray.c | 806 | ||||
-rw-r--r-- | win/tkWinTest.c | 58 | ||||
-rw-r--r-- | win/tkWinWm.c | 5 | ||||
-rw-r--r-- | win/tkWinX.c | 40 | ||||
-rw-r--r-- | win/ttkWinXPTheme.c | 2 |
19 files changed, 947 insertions, 952 deletions
diff --git a/win/nmakehlp.c b/win/nmakehlp.c index 4d95662..4fc9f7a 100644 --- a/win/nmakehlp.c +++ b/win/nmakehlp.c @@ -19,7 +19,6 @@ #pragma comment (lib, "kernel32.lib") #endif #include <stdio.h> -#include <math.h> /* * This library is required for x64 builds with _some_ versions of MSVC @@ -91,7 +90,7 @@ main( case 'c': if (argc != 3) { chars = snprintf(msg, sizeof(msg) - 1, - "usage: %s -c <compiler option>\n" + "usage: %s -c <compiler option>\n" "Tests for whether cl.exe supports an option\n" "exitcodes: 0 == no, 1 == yes, 2 == error\n", argv[0]); WriteFile(GetStdHandle(STD_ERROR_HANDLE), msg, chars, @@ -319,11 +318,11 @@ CheckForCompilerFeature( */ return !(strstr(Out.buffer, "D4002") != NULL - || strstr(Err.buffer, "D4002") != NULL - || strstr(Out.buffer, "D9002") != NULL - || strstr(Err.buffer, "D9002") != NULL - || strstr(Out.buffer, "D2021") != NULL - || strstr(Err.buffer, "D2021") != NULL); + || strstr(Err.buffer, "D4002") != NULL + || strstr(Out.buffer, "D9002") != NULL + || strstr(Err.buffer, "D9002") != NULL + || strstr(Out.buffer, "D2021") != NULL + || strstr(Err.buffer, "D2021") != NULL); } static int @@ -601,9 +600,9 @@ list_free(list_item_t **listPtrPtr) * * Usage is something like: * nmakehlp -S << $** > $@ - * @PACKAGE_NAME@ $(PACKAGE_NAME) - * @PACKAGE_VERSION@ $(PACKAGE_VERSION) - * << + * @PACKAGE_NAME@ $(PACKAGE_NAME) + * @PACKAGE_VERSION@ $(PACKAGE_VERSION) + * << */ static int @@ -727,11 +726,13 @@ static int LocateDependencyHelper(const char *dir, const char *keypath) int keylen, ret; WIN32_FIND_DATA finfo; - if (dir == NULL || keypath == NULL) + if (dir == NULL || keypath == NULL) { return 2; /* Have no real error reporting mechanism into nmake */ + } dirlen = strlen(dir); - if ((dirlen + 3) > sizeof(path)) + if ((dirlen + 3) > sizeof(path)) { return 2; + } strncpy(path, dir, dirlen); strncpy(path+dirlen, "\\*", 3); /* Including terminating \0 */ keylen = strlen(keypath); @@ -746,8 +747,9 @@ static int LocateDependencyHelper(const char *dir, const char *keypath) #else hSearch = FindFirstFile(path, &finfo); #endif - if (hSearch == INVALID_HANDLE_VALUE) + if (hSearch == INVALID_HANDLE_VALUE) { return 1; /* Not found */ + } /* Loop through all subdirs checking if the keypath is under there */ ret = 1; /* Assume not found */ @@ -757,11 +759,13 @@ static int LocateDependencyHelper(const char *dir, const char *keypath) * We need to check it is a directory despite the * FindExSearchLimitToDirectories in the above call. See SDK docs */ - if ((finfo.dwFileAttributes & FILE_ATTRIBUTE_DIRECTORY) == 0) + if ((finfo.dwFileAttributes & FILE_ATTRIBUTE_DIRECTORY) == 0) { continue; + } sublen = strlen(finfo.cFileName); - if ((dirlen+1+sublen+1+keylen+1) > sizeof(path)) + if ((dirlen+1+sublen+1+keylen+1) > sizeof(path)) { continue; /* Path does not fit, assume not matched */ + } strncpy(path+dirlen+1, finfo.cFileName, sublen); path[dirlen+1+sublen] = '\\'; strncpy(path+dirlen+1+sublen+1, keypath, keylen+1); @@ -781,13 +785,13 @@ static int LocateDependencyHelper(const char *dir, const char *keypath) * LocateDependency -- * * Locates a dependency for a package. - * keypath - a relative path within the package directory - * that is used to confirm it is the correct directory. + * keypath - a relative path within the package directory + * that is used to confirm it is the correct directory. * The search path for the package directory is currently only - * the parent and grandparent of the current working directory. - * If found, the command prints - * name_DIRPATH=<full path of located directory> - * and returns 0. If not found, does not print anything and returns 1. + * the parent and grandparent of the current working directory. + * If found, the command prints + * name_DIRPATH=<full path of located directory> + * and returns 0. If not found, does not print anything and returns 1. */ static int LocateDependency(const char *keypath) { @@ -797,8 +801,9 @@ static int LocateDependency(const char *keypath) for (i = 0; i < (sizeof(paths)/sizeof(paths[0])); ++i) { ret = LocateDependencyHelper(paths[i], keypath); - if (ret == 0) + if (ret == 0) { return ret; + } } return ret; } diff --git a/win/tkWinClipboard.c b/win/tkWinClipboard.c index 7de4338..f51bf8a 100644 --- a/win/tkWinClipboard.c +++ b/win/tkWinClipboard.c @@ -60,10 +60,10 @@ TkSelGetSelection( goto error; } if (!OpenClipboard(NULL)) { - Tcl_SetObjResult(interp, Tcl_ObjPrintf( - "clipboard cannot be opened, another application grabbed it")); - Tcl_SetErrorCode(interp, "TK", "CLIPBOARD", "BUSY", NULL); - return TCL_ERROR; + Tcl_SetObjResult(interp, Tcl_ObjPrintf( + "clipboard cannot be opened, another application grabbed it")); + Tcl_SetErrorCode(interp, "TK", "CLIPBOARD", "BUSY", NULL); + return TCL_ERROR; } /* diff --git a/win/tkWinDefault.h b/win/tkWinDefault.h index 5318f84..5af7877 100644 --- a/win/tkWinDefault.h +++ b/win/tkWinDefault.h @@ -450,7 +450,7 @@ #define DEF_SCROLLBAR_BORDER_WIDTH "0" #define DEF_SCROLLBAR_COMMAND "" #define DEF_SCROLLBAR_CURSOR "" -#define DEF_SCROLLBAR_EL_BORDER_WIDTH "-1" +#define DEF_SCROLLBAR_EL_BORDER_WIDTH NULL #define DEF_SCROLLBAR_HIGHLIGHT_BG NORMAL_BG #define DEF_SCROLLBAR_HIGHLIGHT HIGHLIGHT #define DEF_SCROLLBAR_HIGHLIGHT_WIDTH "0" diff --git a/win/tkWinDialog.c b/win/tkWinDialog.c index 77f8e98..0b0494b 100644 --- a/win/tkWinDialog.c +++ b/win/tkWinDialog.c @@ -177,9 +177,9 @@ typedef struct OFNOpts { int mustExist; /* Used only for */ int forceXPStyle; /* XXX - Force XP style even on newer systems */ WCHAR file[TK_MULTI_MAX_PATH]; /* File name - XXX - fixed size because it was so - historically. Why not malloc'ed ? - */ + XXX - fixed size because it was so + historically. Why not malloc'ed ? + */ } OFNOpts; /* Define the operation for which option parsing is to be done. */ @@ -254,26 +254,26 @@ typedef struct IShellItemArrayVtbl BEGIN_INTERFACE HRESULT ( STDMETHODCALLTYPE *QueryInterface )( - IShellItemArray *, REFIID riid,void **ppvObject); + IShellItemArray *, REFIID riid,void **ppvObject); ULONG ( STDMETHODCALLTYPE *AddRef )(IShellItemArray *); ULONG ( STDMETHODCALLTYPE *Release )(IShellItemArray *); HRESULT ( STDMETHODCALLTYPE *BindToHandler )(IShellItemArray *, - IBindCtx *, REFGUID, REFIID, void **); + IBindCtx *, REFGUID, REFIID, void **); /* flags is actually is enum GETPROPERTYSTOREFLAGS */ HRESULT ( STDMETHODCALLTYPE *GetPropertyStore )( - IShellItemArray *, int, REFIID, void **); + IShellItemArray *, int, REFIID, void **); /* keyType actually REFPROPERTYKEY */ HRESULT ( STDMETHODCALLTYPE *GetPropertyDescriptionList )( - IShellItemArray *, void *, REFIID, void **); + IShellItemArray *, void *, REFIID, void **); HRESULT ( STDMETHODCALLTYPE *GetAttributes )(IShellItemArray *, - SIATTRIBFLAGS, SFGAOF, SFGAOF *); + SIATTRIBFLAGS, SFGAOF, SFGAOF *); HRESULT ( STDMETHODCALLTYPE *GetCount )( - IShellItemArray *, DWORD *); + IShellItemArray *, DWORD *); HRESULT ( STDMETHODCALLTYPE *GetItemAt )( - IShellItemArray *, DWORD, IShellItem **); + IShellItemArray *, DWORD, IShellItem **); /* ppenumShellItems actually (IEnumShellItems **) */ HRESULT ( STDMETHODCALLTYPE *EnumItems )( - IShellItemArray *, void **); + IShellItemArray *, void **); END_INTERFACE } IShellItemArrayVtbl; @@ -354,56 +354,56 @@ typedef struct IFileDialogVtbl BEGIN_INTERFACE HRESULT ( STDMETHODCALLTYPE *QueryInterface )( - IFileDialog *, REFIID, void **); + IFileDialog *, REFIID, void **); ULONG ( STDMETHODCALLTYPE *AddRef )( IFileDialog *); ULONG ( STDMETHODCALLTYPE *Release )( IFileDialog *); HRESULT ( STDMETHODCALLTYPE *Show )( IFileDialog *, HWND); HRESULT ( STDMETHODCALLTYPE *SetFileTypes )( IFileDialog *, - UINT, const TCLCOMDLG_FILTERSPEC *); + UINT, const TCLCOMDLG_FILTERSPEC *); HRESULT ( STDMETHODCALLTYPE *SetFileTypeIndex )(IFileDialog *, UINT); HRESULT ( STDMETHODCALLTYPE *GetFileTypeIndex )(IFileDialog *, UINT *); /* XXX - Actually pfde is IFileDialogEvents* but we do not use this call and do not want to define IFileDialogEvents as that pulls in a whole bunch of other stuff. */ HRESULT ( STDMETHODCALLTYPE *Advise )( - IFileDialog *, void *, DWORD *); + IFileDialog *, void *, DWORD *); HRESULT ( STDMETHODCALLTYPE *Unadvise )(IFileDialog *, DWORD); HRESULT ( STDMETHODCALLTYPE *SetOptions )( - IFileDialog *, FILEOPENDIALOGOPTIONS); + IFileDialog *, FILEOPENDIALOGOPTIONS); HRESULT ( STDMETHODCALLTYPE *GetOptions )( - IFileDialog *, FILEOPENDIALOGOPTIONS *); + IFileDialog *, FILEOPENDIALOGOPTIONS *); HRESULT ( STDMETHODCALLTYPE *SetDefaultFolder )( - IFileDialog *, IShellItem *); + IFileDialog *, IShellItem *); HRESULT ( STDMETHODCALLTYPE *SetFolder )( - IFileDialog *, IShellItem *); + IFileDialog *, IShellItem *); HRESULT ( STDMETHODCALLTYPE *GetFolder )( - IFileDialog *, IShellItem **); + IFileDialog *, IShellItem **); HRESULT ( STDMETHODCALLTYPE *GetCurrentSelection )( - IFileDialog *, IShellItem **); + IFileDialog *, IShellItem **); HRESULT ( STDMETHODCALLTYPE *SetFileName )( - IFileDialog *, LPCWSTR); + IFileDialog *, LPCWSTR); HRESULT ( STDMETHODCALLTYPE *GetFileName )( - IFileDialog *, LPWSTR *); + IFileDialog *, LPWSTR *); HRESULT ( STDMETHODCALLTYPE *SetTitle )( - IFileDialog *, LPCWSTR); + IFileDialog *, LPCWSTR); HRESULT ( STDMETHODCALLTYPE *SetOkButtonLabel )( - IFileDialog *, LPCWSTR); + IFileDialog *, LPCWSTR); HRESULT ( STDMETHODCALLTYPE *SetFileNameLabel )( - IFileDialog *, LPCWSTR); + IFileDialog *, LPCWSTR); HRESULT ( STDMETHODCALLTYPE *GetResult )( - IFileDialog *, IShellItem **); + IFileDialog *, IShellItem **); HRESULT ( STDMETHODCALLTYPE *AddPlace )( - IFileDialog *, IShellItem *, FDAP); + IFileDialog *, IShellItem *, FDAP); HRESULT ( STDMETHODCALLTYPE *SetDefaultExtension )( - IFileDialog *, LPCWSTR); + IFileDialog *, LPCWSTR); HRESULT ( STDMETHODCALLTYPE *Close )( IFileDialog *, HRESULT); HRESULT ( STDMETHODCALLTYPE *SetClientGuid )( - IFileDialog *, REFGUID); + IFileDialog *, REFGUID); HRESULT ( STDMETHODCALLTYPE *ClearClientData )( IFileDialog *); /* pFilter actually IShellItemFilter. But deprecated in Win7 AND we do not use it anyways. So define as void* */ HRESULT ( STDMETHODCALLTYPE *SetFilter )( - IFileDialog *, void *); + IFileDialog *, void *); END_INTERFACE } IFileDialogVtbl; @@ -418,67 +418,67 @@ typedef struct IFileSaveDialogVtbl { BEGIN_INTERFACE HRESULT ( STDMETHODCALLTYPE *QueryInterface )( - IFileSaveDialog *, REFIID, void **); + IFileSaveDialog *, REFIID, void **); ULONG ( STDMETHODCALLTYPE *AddRef )( IFileSaveDialog *); ULONG ( STDMETHODCALLTYPE *Release )( IFileSaveDialog *); HRESULT ( STDMETHODCALLTYPE *Show )( - IFileSaveDialog *, HWND); + IFileSaveDialog *, HWND); HRESULT ( STDMETHODCALLTYPE *SetFileTypes )( IFileSaveDialog *, - UINT, const TCLCOMDLG_FILTERSPEC *); + UINT, const TCLCOMDLG_FILTERSPEC *); HRESULT ( STDMETHODCALLTYPE *SetFileTypeIndex )( - IFileSaveDialog *, UINT); + IFileSaveDialog *, UINT); HRESULT ( STDMETHODCALLTYPE *GetFileTypeIndex )( - IFileSaveDialog *, UINT *); + IFileSaveDialog *, UINT *); /* Actually pfde is IFileSaveDialogEvents* */ HRESULT ( STDMETHODCALLTYPE *Advise )( - IFileSaveDialog *, void *, DWORD *); + IFileSaveDialog *, void *, DWORD *); HRESULT ( STDMETHODCALLTYPE *Unadvise )( IFileSaveDialog *, DWORD); HRESULT ( STDMETHODCALLTYPE *SetOptions )( - IFileSaveDialog *, FILEOPENDIALOGOPTIONS); + IFileSaveDialog *, FILEOPENDIALOGOPTIONS); HRESULT ( STDMETHODCALLTYPE *GetOptions )( - IFileSaveDialog *, FILEOPENDIALOGOPTIONS *); + IFileSaveDialog *, FILEOPENDIALOGOPTIONS *); HRESULT ( STDMETHODCALLTYPE *SetDefaultFolder )( - IFileSaveDialog *, IShellItem *); + IFileSaveDialog *, IShellItem *); HRESULT ( STDMETHODCALLTYPE *SetFolder )( - IFileSaveDialog *, IShellItem *); + IFileSaveDialog *, IShellItem *); HRESULT ( STDMETHODCALLTYPE *GetFolder )( - IFileSaveDialog *, IShellItem **); + IFileSaveDialog *, IShellItem **); HRESULT ( STDMETHODCALLTYPE *GetCurrentSelection )( - IFileSaveDialog *, IShellItem **); + IFileSaveDialog *, IShellItem **); HRESULT ( STDMETHODCALLTYPE *SetFileName )( - IFileSaveDialog *, LPCWSTR); + IFileSaveDialog *, LPCWSTR); HRESULT ( STDMETHODCALLTYPE *GetFileName )( - IFileSaveDialog *, LPWSTR *); + IFileSaveDialog *, LPWSTR *); HRESULT ( STDMETHODCALLTYPE *SetTitle )( - IFileSaveDialog *, LPCWSTR); + IFileSaveDialog *, LPCWSTR); HRESULT ( STDMETHODCALLTYPE *SetOkButtonLabel )( - IFileSaveDialog *, LPCWSTR); + IFileSaveDialog *, LPCWSTR); HRESULT ( STDMETHODCALLTYPE *SetFileNameLabel )( - IFileSaveDialog *, LPCWSTR); + IFileSaveDialog *, LPCWSTR); HRESULT ( STDMETHODCALLTYPE *GetResult )( - IFileSaveDialog *, IShellItem **); + IFileSaveDialog *, IShellItem **); HRESULT ( STDMETHODCALLTYPE *AddPlace )( - IFileSaveDialog *, IShellItem *, FDAP); + IFileSaveDialog *, IShellItem *, FDAP); HRESULT ( STDMETHODCALLTYPE *SetDefaultExtension )( - IFileSaveDialog *, LPCWSTR); + IFileSaveDialog *, LPCWSTR); HRESULT ( STDMETHODCALLTYPE *Close )( IFileSaveDialog *, HRESULT); HRESULT ( STDMETHODCALLTYPE *SetClientGuid )( - IFileSaveDialog *, REFGUID); + IFileSaveDialog *, REFGUID); HRESULT ( STDMETHODCALLTYPE *ClearClientData )( IFileSaveDialog *); /* pFilter Actually IShellItemFilter* */ HRESULT ( STDMETHODCALLTYPE *SetFilter )( - IFileSaveDialog *, void *); + IFileSaveDialog *, void *); HRESULT ( STDMETHODCALLTYPE *SetSaveAsItem )( - IFileSaveDialog *, IShellItem *); + IFileSaveDialog *, IShellItem *); HRESULT ( STDMETHODCALLTYPE *SetProperties )( - IFileSaveDialog *, IPropertyStore *); + IFileSaveDialog *, IPropertyStore *); HRESULT ( STDMETHODCALLTYPE *SetCollectedProperties )( - IFileSaveDialog *, IPropertyDescriptionList *, BOOL); + IFileSaveDialog *, IPropertyDescriptionList *, BOOL); HRESULT ( STDMETHODCALLTYPE *GetProperties )( - IFileSaveDialog *, IPropertyStore **); + IFileSaveDialog *, IPropertyStore **); HRESULT ( STDMETHODCALLTYPE *ApplyProperties )( - IFileSaveDialog *, IShellItem *, IPropertyStore *, - HWND, IFileOperationProgressSink *); + IFileSaveDialog *, IShellItem *, IPropertyStore *, + HWND, IFileOperationProgressSink *); END_INTERFACE @@ -493,61 +493,61 @@ typedef struct IFileOpenDialogVtbl { BEGIN_INTERFACE HRESULT ( STDMETHODCALLTYPE *QueryInterface )( - IFileOpenDialog *, REFIID, void **); + IFileOpenDialog *, REFIID, void **); ULONG ( STDMETHODCALLTYPE *AddRef )( IFileOpenDialog *); ULONG ( STDMETHODCALLTYPE *Release )( IFileOpenDialog *); HRESULT ( STDMETHODCALLTYPE *Show )( IFileOpenDialog *, HWND); HRESULT ( STDMETHODCALLTYPE *SetFileTypes )( IFileOpenDialog *, - UINT, const TCLCOMDLG_FILTERSPEC *); + UINT, const TCLCOMDLG_FILTERSPEC *); HRESULT ( STDMETHODCALLTYPE *SetFileTypeIndex )( - IFileOpenDialog *, UINT); + IFileOpenDialog *, UINT); HRESULT ( STDMETHODCALLTYPE *GetFileTypeIndex )( - IFileOpenDialog *, UINT *); + IFileOpenDialog *, UINT *); /* Actually pfde is IFileDialogEvents* */ HRESULT ( STDMETHODCALLTYPE *Advise )( - IFileOpenDialog *, void *, DWORD *); + IFileOpenDialog *, void *, DWORD *); HRESULT ( STDMETHODCALLTYPE *Unadvise )( IFileOpenDialog *, DWORD); HRESULT ( STDMETHODCALLTYPE *SetOptions )( - IFileOpenDialog *, FILEOPENDIALOGOPTIONS); + IFileOpenDialog *, FILEOPENDIALOGOPTIONS); HRESULT ( STDMETHODCALLTYPE *GetOptions )( - IFileOpenDialog *, FILEOPENDIALOGOPTIONS *); + IFileOpenDialog *, FILEOPENDIALOGOPTIONS *); HRESULT ( STDMETHODCALLTYPE *SetDefaultFolder )( - IFileOpenDialog *, IShellItem *); + IFileOpenDialog *, IShellItem *); HRESULT ( STDMETHODCALLTYPE *SetFolder )( - IFileOpenDialog *, IShellItem *); + IFileOpenDialog *, IShellItem *); HRESULT ( STDMETHODCALLTYPE *GetFolder )( - IFileOpenDialog *, IShellItem **); + IFileOpenDialog *, IShellItem **); HRESULT ( STDMETHODCALLTYPE *GetCurrentSelection )( - IFileOpenDialog *, IShellItem **); + IFileOpenDialog *, IShellItem **); HRESULT ( STDMETHODCALLTYPE *SetFileName )( - IFileOpenDialog *, LPCWSTR); + IFileOpenDialog *, LPCWSTR); HRESULT ( STDMETHODCALLTYPE *GetFileName )( - IFileOpenDialog *, LPWSTR *); + IFileOpenDialog *, LPWSTR *); HRESULT ( STDMETHODCALLTYPE *SetTitle )( - IFileOpenDialog *, LPCWSTR); + IFileOpenDialog *, LPCWSTR); HRESULT ( STDMETHODCALLTYPE *SetOkButtonLabel )( - IFileOpenDialog *, LPCWSTR); + IFileOpenDialog *, LPCWSTR); HRESULT ( STDMETHODCALLTYPE *SetFileNameLabel )( - IFileOpenDialog *, LPCWSTR); + IFileOpenDialog *, LPCWSTR); HRESULT ( STDMETHODCALLTYPE *GetResult )( - IFileOpenDialog *, IShellItem **); + IFileOpenDialog *, IShellItem **); HRESULT ( STDMETHODCALLTYPE *AddPlace )( - IFileOpenDialog *, IShellItem *, FDAP); + IFileOpenDialog *, IShellItem *, FDAP); HRESULT ( STDMETHODCALLTYPE *SetDefaultExtension )( - IFileOpenDialog *, LPCWSTR); + IFileOpenDialog *, LPCWSTR); HRESULT ( STDMETHODCALLTYPE *Close )( IFileOpenDialog *, HRESULT); HRESULT ( STDMETHODCALLTYPE *SetClientGuid )( - IFileOpenDialog *, REFGUID); + IFileOpenDialog *, REFGUID); HRESULT ( STDMETHODCALLTYPE *ClearClientData )( - IFileOpenDialog *); + IFileOpenDialog *); HRESULT ( STDMETHODCALLTYPE *SetFilter )( - IFileOpenDialog *, - /* pFilter is actually IShellItemFilter */ - void *); + IFileOpenDialog *, + /* pFilter is actually IShellItemFilter */ + void *); HRESULT ( STDMETHODCALLTYPE *GetResults )( - IFileOpenDialog *, IShellItemArray **); + IFileOpenDialog *, IShellItemArray **); HRESULT ( STDMETHODCALLTYPE *GetSelectedItems )( - IFileOpenDialog *, IShellItemArray **); + IFileOpenDialog *, IShellItemArray **); END_INTERFACE } IFileOpenDialogVtbl; @@ -569,18 +569,18 @@ static UINT CALLBACK ColorDlgHookProc(HWND hDlg, UINT uMsg, WPARAM wParam, LPARAM lParam); static void CleanupOFNOptions(OFNOpts *optsPtr); static int ParseOFNOptions(void *clientData, - Tcl_Interp *interp, int objc, - Tcl_Obj *const objv[], enum OFNOper oper, OFNOpts *optsPtr); + Tcl_Interp *interp, int objc, + Tcl_Obj *const objv[], enum OFNOper oper, OFNOpts *optsPtr); static int GetFileNameXP(Tcl_Interp *interp, OFNOpts *optsPtr, - enum OFNOper oper); + enum OFNOper oper); static int GetFileNameVista(Tcl_Interp *interp, OFNOpts *optsPtr, - enum OFNOper oper); + enum OFNOper oper); static int GetFileName(void *clientData, - Tcl_Interp *interp, int objc, - Tcl_Obj *const objv[], enum OFNOper oper); + Tcl_Interp *interp, int objc, + Tcl_Obj *const objv[], enum OFNOper oper); static int MakeFilterVista(Tcl_Interp *interp, OFNOpts *optsPtr, - DWORD *countPtr, TCLCOMDLG_FILTERSPEC **dlgFilterPtrPtr, - DWORD *defaultFilterIndexPtr); + DWORD *countPtr, TCLCOMDLG_FILTERSPEC **dlgFilterPtrPtr, + DWORD *defaultFilterIndexPtr); static void FreeFilterVista(DWORD count, TCLCOMDLG_FILTERSPEC *dlgFilterPtr); static int MakeFilter(Tcl_Interp *interp, Tcl_Obj *valuePtr, Tcl_DString *dsPtr, Tcl_Obj *initialPtr, @@ -984,7 +984,7 @@ ParseOFNOptions( enum options { FILE_DEFAULT, FILE_TYPES, FILE_INITDIR, FILE_INITFILE, FILE_PARENT, FILE_TITLE, FILE_TYPEVARIABLE, FILE_MULTIPLE, FILE_CONFIRMOW, - FILE_MUSTEXIST, + FILE_MUSTEXIST, }; struct Options { const char *name; @@ -1042,31 +1042,31 @@ ParseOFNOptions( if (Tcl_GetIndexFromObjStruct(interp, objv[i], options, sizeof(struct Options), "option", 0, &index) != TCL_OK) { - /* - * XXX -xpstyle is explicitly checked for as it is undocumented - * and we do not want it to show in option error messages. - */ - if (strcmp(Tcl_GetString(objv[i]), "-xpstyle")) - goto error_return; - if (i + 1 == objc) { - Tcl_SetObjResult(interp, Tcl_NewStringObj("value for \"-xpstyle\" missing", TCL_INDEX_NONE)); - Tcl_SetErrorCode(interp, "TK", "FILEDIALOG", "VALUE", NULL); - goto error_return; - } + /* + * XXX -xpstyle is explicitly checked for as it is undocumented + * and we do not want it to show in option error messages. + */ + if (strcmp(Tcl_GetString(objv[i]), "-xpstyle")) + goto error_return; + if (i + 1 == objc) { + Tcl_SetObjResult(interp, Tcl_NewStringObj("value for \"-xpstyle\" missing", TCL_INDEX_NONE)); + Tcl_SetErrorCode(interp, "TK", "FILEDIALOG", "VALUE", NULL); + goto error_return; + } if (Tcl_GetBooleanFromObj(interp, objv[i+1], - &optsPtr->forceXPStyle) != TCL_OK) - goto error_return; + &optsPtr->forceXPStyle) != TCL_OK) + goto error_return; - continue; + continue; } else if (i + 1 == objc) { - Tcl_SetObjResult(interp, Tcl_ObjPrintf( - "value for \"%s\" missing", options[index].name)); - Tcl_SetErrorCode(interp, "TK", "FILEDIALOG", "VALUE", NULL); - goto error_return; + Tcl_SetObjResult(interp, Tcl_ObjPrintf( + "value for \"%s\" missing", options[index].name)); + Tcl_SetErrorCode(interp, "TK", "FILEDIALOG", "VALUE", NULL); + goto error_return; } - valuePtr = objv[i + 1]; + valuePtr = objv[i + 1]; string = Tcl_GetString(valuePtr); switch (options[index].value) { case FILE_DEFAULT: @@ -1078,16 +1078,16 @@ ParseOFNOptions( case FILE_INITDIR: Tcl_DStringFree(&optsPtr->utfDirString); if (Tcl_TranslateFileName(interp, string, - &optsPtr->utfDirString) == NULL) + &optsPtr->utfDirString) == NULL) goto error_return; break; case FILE_INITFILE: if (Tcl_TranslateFileName(interp, string, &ds) == NULL) goto error_return; Tcl_UtfToExternal(NULL, TkWinGetUnicodeEncoding(), - Tcl_DStringValue(&ds), Tcl_DStringLength(&ds), - TCL_ENCODING_PROFILE_TCL8, NULL, (char *)&optsPtr->file[0], - sizeof(optsPtr->file), NULL, NULL, NULL); + Tcl_DStringValue(&ds), Tcl_DStringLength(&ds), + TCL_ENCODING_PROFILE_TCL8, NULL, (char *)&optsPtr->file[0], + sizeof(optsPtr->file), NULL, NULL, NULL); Tcl_DStringFree(&ds); break; case FILE_PARENT: @@ -1101,23 +1101,23 @@ ParseOFNOptions( case FILE_TYPEVARIABLE: optsPtr->typeVariableObj = valuePtr; optsPtr->initialTypeObj = Tcl_ObjGetVar2(interp, valuePtr, - NULL, TCL_GLOBAL_ONLY); + NULL, TCL_GLOBAL_ONLY); break; case FILE_MULTIPLE: if (Tcl_GetBooleanFromObj(interp, valuePtr, - &optsPtr->multi) != TCL_OK) - goto error_return; + &optsPtr->multi) != TCL_OK) + goto error_return; break; case FILE_CONFIRMOW: if (Tcl_GetBooleanFromObj(interp, valuePtr, - &optsPtr->confirmOverwrite) != TCL_OK) - goto error_return; + &optsPtr->confirmOverwrite) != TCL_OK) + goto error_return; break; - case FILE_MUSTEXIST: + case FILE_MUSTEXIST: if (Tcl_GetBooleanFromObj(interp, valuePtr, - &optsPtr->mustExist) != TCL_OK) - goto error_return; - break; + &optsPtr->mustExist) != TCL_OK) + goto error_return; + break; } } @@ -1151,7 +1151,7 @@ static int VistaFileDialogsAvailable(void) HRESULT hr; IFileDialog *fdlgPtr = NULL; ThreadSpecificData *tsdPtr = (ThreadSpecificData *) - Tcl_GetThreadData(&dataKey, sizeof(ThreadSpecificData)); + Tcl_GetThreadData(&dataKey, sizeof(ThreadSpecificData)); if (tsdPtr->newFileDialogsState == FDLG_STATE_INIT) { tsdPtr->newFileDialogsState = FDLG_STATE_USE_OLD; @@ -1198,7 +1198,7 @@ static int VistaFileDialogsAvailable(void) *---------------------------------------------------------------------- */ static int GetFileNameVista(Tcl_Interp *interp, OFNOpts *optsPtr, - enum OFNOper oper) + enum OFNOper oper) { HRESULT hr; HWND hWnd; @@ -1232,8 +1232,8 @@ static int GetFileNameVista(Tcl_Interp *interp, OFNOpts *optsPtr, * is the filter specification so do that before creating */ if (MakeFilterVista(interp, optsPtr, &nfilters, &filterPtr, - &defaultFilterIndex) != TCL_OK) - return TCL_ERROR; + &defaultFilterIndex) != TCL_OK) + return TCL_ERROR; /* * Beyond this point, do not just return on error as there will be @@ -1241,14 +1241,14 @@ static int GetFileNameVista(Tcl_Interp *interp, OFNOpts *optsPtr, */ if (oper == OFN_FILE_OPEN || oper == OFN_DIR_CHOOSE) - hr = CoCreateInstance(&ClsidFileOpenDialog, NULL, - CLSCTX_INPROC_SERVER, &IIDIFileOpenDialog, (void **) &fdlgIf); + hr = CoCreateInstance(&ClsidFileOpenDialog, NULL, + CLSCTX_INPROC_SERVER, &IIDIFileOpenDialog, (void **) &fdlgIf); else - hr = CoCreateInstance(&ClsidFileSaveDialog, NULL, - CLSCTX_INPROC_SERVER, &IIDIFileSaveDialog, (void **) &fdlgIf); + hr = CoCreateInstance(&ClsidFileSaveDialog, NULL, + CLSCTX_INPROC_SERVER, &IIDIFileSaveDialog, (void **) &fdlgIf); if (FAILED(hr)) - goto vamoose; + goto vamoose; /* * Get current settings first because we want to preserve existing @@ -1257,20 +1257,20 @@ static int GetFileNameVista(Tcl_Interp *interp, OFNOpts *optsPtr, */ hr = fdlgIf->lpVtbl->GetOptions(fdlgIf, &flags); if (FAILED(hr)) - goto vamoose; + goto vamoose; if (filterPtr) { - /* - * Causes -filetypes {{All *}} -defaultextension ext to return - * foo.ext.ext when foo is typed into the entry box - * flags |= FOS_STRICTFILETYPES; - */ - hr = fdlgIf->lpVtbl->SetFileTypes(fdlgIf, nfilters, filterPtr); - if (FAILED(hr)) - goto vamoose; - hr = fdlgIf->lpVtbl->SetFileTypeIndex(fdlgIf, defaultFilterIndex); - if (FAILED(hr)) - goto vamoose; + /* + * Causes -filetypes {{All *}} -defaultextension ext to return + * foo.ext.ext when foo is typed into the entry box + * flags |= FOS_STRICTFILETYPES; + */ + hr = fdlgIf->lpVtbl->SetFileTypes(fdlgIf, nfilters, filterPtr); + if (FAILED(hr)) + goto vamoose; + hr = fdlgIf->lpVtbl->SetFileTypeIndex(fdlgIf, defaultFilterIndex); + if (FAILED(hr)) + goto vamoose; } /* Flags are equivalent to those we used in the older API */ @@ -1281,88 +1281,88 @@ static int GetFileNameVista(Tcl_Interp *interp, OFNOpts *optsPtr, * semantics than OFN_NOVALIDATE in the old API. */ flags |= - FOS_FORCEFILESYSTEM | /* Only want files, not other shell items */ - FOS_NOVALIDATE | /* Don't check for access denied etc. */ - FOS_PATHMUSTEXIST; /* The *directory* path must exist */ + FOS_FORCEFILESYSTEM | /* Only want files, not other shell items */ + FOS_NOVALIDATE | /* Don't check for access denied etc. */ + FOS_PATHMUSTEXIST; /* The *directory* path must exist */ if (oper == OFN_DIR_CHOOSE) { - flags |= FOS_PICKFOLDERS; - if (optsPtr->mustExist) - flags |= FOS_FILEMUSTEXIST; /* XXX - check working */ + flags |= FOS_PICKFOLDERS; + if (optsPtr->mustExist) + flags |= FOS_FILEMUSTEXIST; /* XXX - check working */ } else - flags &= ~ FOS_PICKFOLDERS; + flags &= ~ FOS_PICKFOLDERS; if (optsPtr->multi) - flags |= FOS_ALLOWMULTISELECT; + flags |= FOS_ALLOWMULTISELECT; else - flags &= ~FOS_ALLOWMULTISELECT; + flags &= ~FOS_ALLOWMULTISELECT; if (optsPtr->confirmOverwrite) - flags |= FOS_OVERWRITEPROMPT; + flags |= FOS_OVERWRITEPROMPT; else - flags &= ~FOS_OVERWRITEPROMPT; + flags &= ~FOS_OVERWRITEPROMPT; hr = fdlgIf->lpVtbl->SetOptions(fdlgIf, flags); if (FAILED(hr)) - goto vamoose; + goto vamoose; if (optsPtr->extObj != NULL) { - Tcl_DString ds; - const char *src; + Tcl_DString ds; + const char *src; - src = Tcl_GetString(optsPtr->extObj); - Tcl_DStringInit(&ds); - wstr = Tcl_UtfToWCharDString(src, optsPtr->extObj->length, &ds); - if (wstr[0] == '.') - ++wstr; - hr = fdlgIf->lpVtbl->SetDefaultExtension(fdlgIf, wstr); - Tcl_DStringFree(&ds); - if (FAILED(hr)) - goto vamoose; + src = Tcl_GetString(optsPtr->extObj); + Tcl_DStringInit(&ds); + wstr = Tcl_UtfToWCharDString(src, optsPtr->extObj->length, &ds); + if (wstr[0] == '.') + ++wstr; + hr = fdlgIf->lpVtbl->SetDefaultExtension(fdlgIf, wstr); + Tcl_DStringFree(&ds); + if (FAILED(hr)) + goto vamoose; } if (optsPtr->titleObj != NULL) { - Tcl_DString ds; - const char *src; + Tcl_DString ds; + const char *src; - src = Tcl_GetString(optsPtr->titleObj); - Tcl_DStringInit(&ds); - wstr = Tcl_UtfToWCharDString(src, optsPtr->titleObj->length, &ds); - hr = fdlgIf->lpVtbl->SetTitle(fdlgIf, wstr); - Tcl_DStringFree(&ds); - if (FAILED(hr)) - goto vamoose; + src = Tcl_GetString(optsPtr->titleObj); + Tcl_DStringInit(&ds); + wstr = Tcl_UtfToWCharDString(src, optsPtr->titleObj->length, &ds); + hr = fdlgIf->lpVtbl->SetTitle(fdlgIf, wstr); + Tcl_DStringFree(&ds); + if (FAILED(hr)) + goto vamoose; } if (optsPtr->file[0]) { - hr = fdlgIf->lpVtbl->SetFileName(fdlgIf, optsPtr->file); - if (FAILED(hr)) - goto vamoose; + hr = fdlgIf->lpVtbl->SetFileName(fdlgIf, optsPtr->file); + if (FAILED(hr)) + goto vamoose; } if (Tcl_DStringValue(&optsPtr->utfDirString)[0] != '\0') { - Tcl_Obj *normPath, *iniDirPath; - iniDirPath = Tcl_NewStringObj(Tcl_DStringValue(&optsPtr->utfDirString), TCL_INDEX_NONE); - Tcl_IncrRefCount(iniDirPath); - normPath = Tcl_FSGetNormalizedPath(interp, iniDirPath); - /* XXX - Note on failures do not raise error, simply ignore ini dir */ - if (normPath) { - LPCWSTR nativePath; - Tcl_IncrRefCount(normPath); - nativePath = (LPCWSTR)Tcl_FSGetNativePath(normPath); /* Points INTO normPath*/ - if (nativePath) { - hr = SHCreateItemFromParsingName( - nativePath, NULL, - &IIDIShellItem, (void **) &dirIf); - if (SUCCEEDED(hr)) { - /* Note we use SetFolder, not SetDefaultFolder - see MSDN */ - fdlgIf->lpVtbl->SetFolder(fdlgIf, dirIf); /* Ignore errors */ - } - } - Tcl_DecrRefCount(normPath); /* ALSO INVALIDATES nativePath !! */ - } - Tcl_DecrRefCount(iniDirPath); + Tcl_Obj *normPath, *iniDirPath; + iniDirPath = Tcl_NewStringObj(Tcl_DStringValue(&optsPtr->utfDirString), TCL_INDEX_NONE); + Tcl_IncrRefCount(iniDirPath); + normPath = Tcl_FSGetNormalizedPath(interp, iniDirPath); + /* XXX - Note on failures do not raise error, simply ignore ini dir */ + if (normPath) { + LPCWSTR nativePath; + Tcl_IncrRefCount(normPath); + nativePath = (LPCWSTR)Tcl_FSGetNativePath(normPath); /* Points INTO normPath*/ + if (nativePath) { + hr = SHCreateItemFromParsingName( + nativePath, NULL, + &IIDIShellItem, (void **) &dirIf); + if (SUCCEEDED(hr)) { + /* Note we use SetFolder, not SetDefaultFolder - see MSDN */ + fdlgIf->lpVtbl->SetFolder(fdlgIf, dirIf); /* Ignore errors */ + } + } + Tcl_DecrRefCount(normPath); /* ALSO INVALIDATES nativePath !! */ + } + Tcl_DecrRefCount(iniDirPath); } oldMode = Tcl_SetServiceMode(TCL_SERVICE_ALL); @@ -1377,7 +1377,7 @@ static int GetFileNameVista(Tcl_Interp *interp, OFNOpts *optsPtr, */ if (hWnd) - EnableWindow(hWnd, 1); + EnableWindow(hWnd, 1); /* * Clear interp result since it might have been set during the modal loop. @@ -1386,108 +1386,108 @@ static int GetFileNameVista(Tcl_Interp *interp, OFNOpts *optsPtr, Tcl_ResetResult(interp); if (SUCCEEDED(hr)) { - if ((oper == OFN_FILE_OPEN) && optsPtr->multi) { - IShellItemArray *multiIf; - DWORD dw, count; - IFileOpenDialog *fodIf = (IFileOpenDialog *) fdlgIf; - hr = fodIf->lpVtbl->GetResults(fodIf, &multiIf); - if (SUCCEEDED(hr)) { - Tcl_Obj *multiObj; - hr = multiIf->lpVtbl->GetCount(multiIf, &count); - multiObj = Tcl_NewListObj(count, NULL); - if (SUCCEEDED(hr)) { - IShellItem *itemIf; - for (dw = 0; dw < count; ++dw) { - hr = multiIf->lpVtbl->GetItemAt(multiIf, dw, &itemIf); - if (FAILED(hr)) - break; - hr = itemIf->lpVtbl->GetDisplayName(itemIf, - SIGDN_FILESYSPATH, &wstr); - if (SUCCEEDED(hr)) { - Tcl_DString fnds; - - ConvertExternalFilename(wstr, &fnds); - CoTaskMemFree(wstr); - Tcl_ListObjAppendElement( - interp, multiObj, - Tcl_NewStringObj(Tcl_DStringValue(&fnds), - Tcl_DStringLength(&fnds))); - Tcl_DStringFree(&fnds); - } - itemIf->lpVtbl->Release(itemIf); - if (FAILED(hr)) - break; - } - } - multiIf->lpVtbl->Release(multiIf); - if (SUCCEEDED(hr)) - resultObj = multiObj; - else - Tcl_DecrRefCount(multiObj); - } - } else { - IShellItem *resultIf; - hr = fdlgIf->lpVtbl->GetResult(fdlgIf, &resultIf); - if (SUCCEEDED(hr)) { - hr = resultIf->lpVtbl->GetDisplayName(resultIf, SIGDN_FILESYSPATH, - &wstr); - if (SUCCEEDED(hr)) { - Tcl_DString fnds; - - ConvertExternalFilename(wstr, &fnds); - resultObj = Tcl_NewStringObj(Tcl_DStringValue(&fnds), - Tcl_DStringLength(&fnds)); - CoTaskMemFree(wstr); - Tcl_DStringFree(&fnds); - } - resultIf->lpVtbl->Release(resultIf); - } - } - if (SUCCEEDED(hr)) { - if (filterPtr && optsPtr->typeVariableObj) { - UINT ftix; - - hr = fdlgIf->lpVtbl->GetFileTypeIndex(fdlgIf, &ftix); - if (SUCCEEDED(hr)) { - /* Note ftix is a 1-based index */ - if (ftix > 0 && ftix <= nfilters) { - Tcl_DString ftds; - Tcl_Obj *ftobj; - - Tcl_DStringInit(&ftds); - Tcl_WCharToUtfDString(filterPtr[ftix-1].pszName, wcslen(filterPtr[ftix-1].pszName), &ftds); - ftobj = Tcl_NewStringObj(Tcl_DStringValue(&ftds), - Tcl_DStringLength(&ftds)); - Tcl_ObjSetVar2(interp, optsPtr->typeVariableObj, NULL, - ftobj, TCL_GLOBAL_ONLY|TCL_LEAVE_ERR_MSG); - Tcl_DStringFree(&ftds); - } - } - } - } + if ((oper == OFN_FILE_OPEN) && optsPtr->multi) { + IShellItemArray *multiIf; + DWORD dw, count; + IFileOpenDialog *fodIf = (IFileOpenDialog *) fdlgIf; + hr = fodIf->lpVtbl->GetResults(fodIf, &multiIf); + if (SUCCEEDED(hr)) { + Tcl_Obj *multiObj; + hr = multiIf->lpVtbl->GetCount(multiIf, &count); + multiObj = Tcl_NewListObj(count, NULL); + if (SUCCEEDED(hr)) { + IShellItem *itemIf; + for (dw = 0; dw < count; ++dw) { + hr = multiIf->lpVtbl->GetItemAt(multiIf, dw, &itemIf); + if (FAILED(hr)) + break; + hr = itemIf->lpVtbl->GetDisplayName(itemIf, + SIGDN_FILESYSPATH, &wstr); + if (SUCCEEDED(hr)) { + Tcl_DString fnds; + + ConvertExternalFilename(wstr, &fnds); + CoTaskMemFree(wstr); + Tcl_ListObjAppendElement( + interp, multiObj, + Tcl_NewStringObj(Tcl_DStringValue(&fnds), + Tcl_DStringLength(&fnds))); + Tcl_DStringFree(&fnds); + } + itemIf->lpVtbl->Release(itemIf); + if (FAILED(hr)) + break; + } + } + multiIf->lpVtbl->Release(multiIf); + if (SUCCEEDED(hr)) + resultObj = multiObj; + else + Tcl_DecrRefCount(multiObj); + } + } else { + IShellItem *resultIf; + hr = fdlgIf->lpVtbl->GetResult(fdlgIf, &resultIf); + if (SUCCEEDED(hr)) { + hr = resultIf->lpVtbl->GetDisplayName(resultIf, SIGDN_FILESYSPATH, + &wstr); + if (SUCCEEDED(hr)) { + Tcl_DString fnds; + + ConvertExternalFilename(wstr, &fnds); + resultObj = Tcl_NewStringObj(Tcl_DStringValue(&fnds), + Tcl_DStringLength(&fnds)); + CoTaskMemFree(wstr); + Tcl_DStringFree(&fnds); + } + resultIf->lpVtbl->Release(resultIf); + } + } + if (SUCCEEDED(hr)) { + if (filterPtr && optsPtr->typeVariableObj) { + UINT ftix; + + hr = fdlgIf->lpVtbl->GetFileTypeIndex(fdlgIf, &ftix); + if (SUCCEEDED(hr)) { + /* Note ftix is a 1-based index */ + if (ftix > 0 && ftix <= nfilters) { + Tcl_DString ftds; + Tcl_Obj *ftobj; + + Tcl_DStringInit(&ftds); + Tcl_WCharToUtfDString(filterPtr[ftix-1].pszName, wcslen(filterPtr[ftix-1].pszName), &ftds); + ftobj = Tcl_NewStringObj(Tcl_DStringValue(&ftds), + Tcl_DStringLength(&ftds)); + Tcl_ObjSetVar2(interp, optsPtr->typeVariableObj, NULL, + ftobj, TCL_GLOBAL_ONLY|TCL_LEAVE_ERR_MSG); + Tcl_DStringFree(&ftds); + } + } + } + } } else { - if (hr == HRESULT_FROM_WIN32(ERROR_CANCELLED)) - hr = 0; /* User cancelled, return empty string */ + if (hr == HRESULT_FROM_WIN32(ERROR_CANCELLED)) + hr = 0; /* User cancelled, return empty string */ } vamoose: /* (hr != 0) => error */ if (dirIf) - dirIf->lpVtbl->Release(dirIf); + dirIf->lpVtbl->Release(dirIf); if (fdlgIf) - fdlgIf->lpVtbl->Release(fdlgIf); + fdlgIf->lpVtbl->Release(fdlgIf); if (filterPtr) - FreeFilterVista(nfilters, filterPtr); + FreeFilterVista(nfilters, filterPtr); if (hr == 0) { - if (resultObj) /* May be NULL if user cancelled */ - Tcl_SetObjResult(interp, resultObj); - return TCL_OK; + if (resultObj) /* May be NULL if user cancelled */ + Tcl_SetObjResult(interp, resultObj); + return TCL_OK; } else { - if (resultObj) - Tcl_DecrRefCount(resultObj); - Tcl_SetObjResult(interp, TkWin32ErrorObj(hr)); - return TCL_ERROR; + if (resultObj) + Tcl_DecrRefCount(resultObj); + Tcl_SetObjResult(interp, TkWin32ErrorObj(hr)); + return TCL_ERROR; } } @@ -1518,16 +1518,16 @@ static int GetFileNameXP(Tcl_Interp *interp, OFNOpts *optsPtr, enum OFNOper oper Tcl_DString extString, filterString, dirString, titleString; const char *str; ThreadSpecificData *tsdPtr = (ThreadSpecificData *) - Tcl_GetThreadData(&dataKey, sizeof(ThreadSpecificData)); + Tcl_GetThreadData(&dataKey, sizeof(ThreadSpecificData)); memset(&ofnData, 0, sizeof(OFNData)); Tcl_DStringInit(&utfFilterString); Tcl_DStringInit(&dirString); /* XXX - original code was missing this - leaving dirString uninitialized for - the unlikely code path where cwd failed */ + leaving dirString uninitialized for + the unlikely code path where cwd failed */ if (MakeFilter(interp, optsPtr->filterObj, &utfFilterString, - optsPtr->initialTypeObj, &filterIndex) != TCL_OK) { + optsPtr->initialTypeObj, &filterIndex) != TCL_OK) { goto end; } @@ -1594,7 +1594,7 @@ static int GetFileNameXP(Tcl_Interp *interp, OFNOpts *optsPtr, enum OFNOper oper Tcl_DStringFree(&optsPtr->utfDirString); if ((Tcl_GetCwd(interp, &optsPtr->utfDirString) == NULL) || (Tcl_TranslateFileName(interp, - Tcl_DStringValue(&optsPtr->utfDirString), &cwd) == NULL)) { + Tcl_DStringValue(&optsPtr->utfDirString), &cwd) == NULL)) { Tcl_ResetResult(interp); } else { Tcl_DStringInit(&dirString); @@ -1738,23 +1738,23 @@ static int GetFileNameXP(Tcl_Interp *interp, OFNOpts *optsPtr, enum OFNOper oper &typeInfo) != TCL_OK) { result = TCL_ERROR; } else { - /* - * BUGFIX for d43a10ce2fed950e00890049f3c273f2cdd12583 - * The original code was broken because it passed typeinfo[0] - * directly into Tcl_ObjSetVar2. In the case of typeInfo[0] - * pointing into a list which is also referenced by - * typeVariableObj, TOSV2 shimmers the object into - * variable intrep which loses the list representation. - * This invalidates typeInfo[0] which is freed but - * nevertheless stored as the value of the variable. - */ - Tcl_Obj *selFilterObj = typeInfo[0]; - Tcl_IncrRefCount(selFilterObj); - if (Tcl_ObjSetVar2(interp, optsPtr->typeVariableObj, NULL, - selFilterObj, TCL_GLOBAL_ONLY|TCL_LEAVE_ERR_MSG) == NULL) { - result = TCL_ERROR; - } - Tcl_DecrRefCount(selFilterObj); + /* + * BUGFIX for d43a10ce2fed950e00890049f3c273f2cdd12583 + * The original code was broken because it passed typeinfo[0] + * directly into Tcl_ObjSetVar2. In the case of typeInfo[0] + * pointing into a list which is also referenced by + * typeVariableObj, TOSV2 shimmers the object into + * variable intrep which loses the list representation. + * This invalidates typeInfo[0] which is freed but + * nevertheless stored as the value of the variable. + */ + Tcl_Obj *selFilterObj = typeInfo[0]; + Tcl_IncrRefCount(selFilterObj); + if (Tcl_ObjSetVar2(interp, optsPtr->typeVariableObj, NULL, + selFilterObj, TCL_GLOBAL_ONLY|TCL_LEAVE_ERR_MSG) == NULL) { + result = TCL_ERROR; + } + Tcl_DecrRefCount(selFilterObj); } } } else if (cdlgerr == FNERR_INVALIDFILENAME) { @@ -1772,8 +1772,8 @@ static int GetFileNameXP(Tcl_Interp *interp, OFNOpts *optsPtr, enum OFNOper oper Tcl_DStringFree(&titleString); } if (ofn.lpstrInitialDir != NULL) { - /* XXX - huh? lpstrInitialDir is set from Tcl_DStringValue which - can never return NULL */ + /* XXX - huh? lpstrInitialDir is set from Tcl_DStringValue which + can never return NULL */ Tcl_DStringFree(&dirString); } Tcl_DStringFree(&filterString); @@ -1822,12 +1822,12 @@ GetFileName( result = ParseOFNOptions(clientData, interp, objc, objv, oper, &ofnOpts); if (result != TCL_OK) - return result; + return result; if (VistaFileDialogsAvailable() && ! ofnOpts.forceXPStyle) - result = GetFileNameVista(interp, &ofnOpts, oper); + result = GetFileNameVista(interp, &ofnOpts, oper); else - result = GetFileNameXP(interp, &ofnOpts, oper); + result = GetFileNameXP(interp, &ofnOpts, oper); CleanupOFNOptions(&ofnOpts); return result; @@ -2163,14 +2163,14 @@ MakeFilter( static void FreeFilterVista(DWORD count, TCLCOMDLG_FILTERSPEC *dlgFilterPtr) { if (dlgFilterPtr != NULL) { - DWORD dw; - for (dw = 0; dw < count; ++dw) { - if (dlgFilterPtr[dw].pszName != NULL) - ckfree((void *)dlgFilterPtr[dw].pszName); - if (dlgFilterPtr[dw].pszSpec != NULL) - ckfree((void *)dlgFilterPtr[dw].pszSpec); - } - ckfree(dlgFilterPtr); + DWORD dw; + for (dw = 0; dw < count; ++dw) { + if (dlgFilterPtr[dw].pszName != NULL) + ckfree((void *)dlgFilterPtr[dw].pszName); + if (dlgFilterPtr[dw].pszSpec != NULL) + ckfree((void *)dlgFilterPtr[dw].pszSpec); + } + ckfree(dlgFilterPtr); } } @@ -2195,9 +2195,9 @@ static int MakeFilterVista( OFNOpts *optsPtr, /* Caller specified options */ DWORD *countPtr, /* Will hold number of filters */ TCLCOMDLG_FILTERSPEC **dlgFilterPtrPtr, /* Will hold pointer to filter array. - Set to NULL if no filters specified. - Must be freed by calling - FreeFilterVista */ + Set to NULL if no filters specified. + Must be freed by calling + FreeFilterVista */ DWORD *initialIndexPtr) /* Will hold index of default type */ { TCLCOMDLG_FILTERSPEC *dlgFilterPtr; @@ -2209,9 +2209,9 @@ static int MakeFilterVista( int i; if (optsPtr->filterObj == NULL) { - *dlgFilterPtrPtr = NULL; - *countPtr = 0; - return TCL_OK; + *dlgFilterPtrPtr = NULL; + *countPtr = 0; + return TCL_OK; } if (optsPtr->initialTypeObj) @@ -2222,9 +2222,9 @@ static int MakeFilterVista( return TCL_ERROR; if (flist.filters == NULL) { - *dlgFilterPtrPtr = NULL; - *countPtr = 0; - return TCL_OK; + *dlgFilterPtrPtr = NULL; + *countPtr = 0; + return TCL_OK; } Tcl_DStringInit(&ds); @@ -2232,19 +2232,19 @@ static int MakeFilterVista( dlgFilterPtr = (TCLCOMDLG_FILTERSPEC *)ckalloc(flist.numFilters * sizeof(*dlgFilterPtr)); for (i = 0, filterPtr = flist.filters; - filterPtr; - filterPtr = filterPtr->next, ++i) { + filterPtr; + filterPtr = filterPtr->next, ++i) { const char *sep; FileFilterClause *clausePtr; size_t nbytes; /* Check if this entry should be shown as the default */ if (initial && strcmp(initial, filterPtr->name) == 0) - initialIndex = i+1; /* Windows filter indices are 1-based */ + initialIndex = i+1; /* Windows filter indices are 1-based */ /* First stash away the text description of the pattern */ - Tcl_DStringInit(&ds); - Tcl_UtfToWCharDString(filterPtr->name, TCL_INDEX_NONE, &ds); + Tcl_DStringInit(&ds); + Tcl_UtfToWCharDString(filterPtr->name, TCL_INDEX_NONE, &ds); nbytes = Tcl_DStringLength(&ds); /* # bytes, not Unicode chars */ nbytes += sizeof(WCHAR); /* Terminating \0 */ dlgFilterPtr[i].pszName = (LPCWSTR)ckalloc(nbytes); @@ -2272,8 +2272,8 @@ static int MakeFilterVista( } /* Again we need a Unicode form of the string */ - Tcl_DStringInit(&ds); - Tcl_UtfToWCharDString(Tcl_DStringValue(&patterns), TCL_INDEX_NONE, &ds); + Tcl_DStringInit(&ds); + Tcl_UtfToWCharDString(Tcl_DStringValue(&patterns), TCL_INDEX_NONE, &ds); nbytes = Tcl_DStringLength(&ds); /* # bytes, not Unicode chars */ nbytes += sizeof(WCHAR); /* Terminating \0 */ dlgFilterPtr[i].pszSpec = (LPCWSTR)ckalloc(nbytes); @@ -2387,15 +2387,15 @@ Tk_ChooseDirectoryObjCmd( const char *utfDir; result = ParseOFNOptions(clientData, interp, objc, objv, - OFN_DIR_CHOOSE, &ofnOpts); + OFN_DIR_CHOOSE, &ofnOpts); if (result != TCL_OK) - return result; + return result; /* Use new dialogs if available */ if (VistaFileDialogsAvailable() && ! ofnOpts.forceXPStyle) { - result = GetFileNameVista(interp, &ofnOpts, OFN_DIR_CHOOSE); - CleanupOFNOptions(&ofnOpts); - return result; + result = GetFileNameVista(interp, &ofnOpts, OFN_DIR_CHOOSE); + CleanupOFNOptions(&ofnOpts); + return result; } /* Older dialogs */ @@ -2411,13 +2411,13 @@ Tk_ChooseDirectoryObjCmd( Tcl_DStringInit(&tempString); Tcl_UtfToWCharDString(Tcl_DStringValue(&ofnOpts.utfDirString), TCL_INDEX_NONE, - &tempString); - uniStr = (WCHAR *) Tcl_DStringValue(&tempString); + &tempString); + uniStr = (WCHAR *) Tcl_DStringValue(&tempString); - /* Convert possible relative path to full path to keep dialog happy. */ + /* Convert possible relative path to full path to keep dialog happy. */ - GetFullPathNameW(uniStr, MAX_PATH, saveDir, NULL); - wcsncpy(cdCBData.initDir, saveDir, MAX_PATH); + GetFullPathNameW(uniStr, MAX_PATH, saveDir, NULL); + wcsncpy(cdCBData.initDir, saveDir, MAX_PATH); } /* XXX - rest of this (original) code has no error checks at all. */ @@ -2480,10 +2480,10 @@ Tk_ChooseDirectoryObjCmd( oldMode = Tcl_SetServiceMode(TCL_SERVICE_ALL); GetCurrentDirectoryW(MAX_PATH, saveDir); if (SHGetMalloc(&pMalloc) == NOERROR) { - /* - * XXX - MSDN says CoInitialize must have been called before - * SHBrowseForFolder can be used but don't see that called anywhere. - */ + /* + * XXX - MSDN says CoInitialize must have been called before + * SHBrowseForFolder can be used but don't see that called anywhere. + */ pidl = SHBrowseForFolderW(&bInfo); /* @@ -2620,7 +2620,7 @@ ChooseDirectoryValidateProc( */ wsprintfW(selDir, L"Directory '%s' does not exist,\n" - L"please select or enter an existing directory.", + L"please select or enter an existing directory.", chooseDirSharedData->retDir); MessageBoxW(NULL, selDir, NULL, MB_ICONEXCLAMATION|MB_OK); chooseDirSharedData->retDir[0] = '\0'; diff --git a/win/tkWinDraw.c b/win/tkWinDraw.c index 7943aa3..1022be4 100644 --- a/win/tkWinDraw.c +++ b/win/tkWinDraw.c @@ -761,7 +761,7 @@ MakeAndStrokePath( POINT *winPoints, int npoints, WinDrawFunc func) /* Name of the Windows GDI drawing function: - this is either Polyline or Polygon. */ + this is either Polyline or Polygon. */ { BeginPath(dc); func(dc, winPoints, (int)npoints); @@ -772,15 +772,15 @@ MakeAndStrokePath( * path is closed. */ if (func == Polyline) { - if ((winPoints[0].x == winPoints[npoints-1].x) && - (winPoints[0].y == winPoints[npoints-1].y)) { - CloseFigure(dc); - } - EndPath(dc); - StrokePath(dc); + if ((winPoints[0].x == winPoints[npoints-1].x) && + (winPoints[0].y == winPoints[npoints-1].y)) { + CloseFigure(dc); + } + EndPath(dc); + StrokePath(dc); } else { - EndPath(dc); - StrokeAndFillPath(dc); + EndPath(dc); + StrokeAndFillPath(dc); } } @@ -879,7 +879,7 @@ RenderObject( SetPolyFillMode(dcMem, (gc->fill_rule == EvenOddRule) ? ALTERNATE : WINDING); oldMemBrush = (HBRUSH)SelectObject(dcMem, CreateSolidBrush(gc->foreground)); - MakeAndStrokePath(dcMem, winPoints, npoints, func); + MakeAndStrokePath(dcMem, winPoints, npoints, func); BitBlt(dc, rect.left, rect.top, width, height, dcMem, 0, 0, COPYFG); /* @@ -891,7 +891,7 @@ RenderObject( if (gc->fill_style == FillOpaqueStippled) { DeleteObject(SelectObject(dcMem, CreateSolidBrush(gc->background))); - MakeAndStrokePath(dcMem, winPoints, npoints, func); + MakeAndStrokePath(dcMem, winPoints, npoints, func); BitBlt(dc, rect.left, rect.top, width, height, dcMem, 0, 0, COPYBG); } @@ -907,7 +907,7 @@ RenderObject( SetPolyFillMode(dc, (gc->fill_rule == EvenOddRule) ? ALTERNATE : WINDING); - MakeAndStrokePath(dc, winPoints, npoints, func); + MakeAndStrokePath(dc, winPoints, npoints, func); SelectObject(dc, oldPen); } DeleteObject(SelectObject(dc, oldBrush)); diff --git a/win/tkWinEmbed.c b/win/tkWinEmbed.c index 0a2b543..34cd8ca 100644 --- a/win/tkWinEmbed.c +++ b/win/tkWinEmbed.c @@ -862,12 +862,12 @@ ContainerEventProc( if (eventPtr->type == ConfigureNotify) { /* - * Send a ConfigureNotify to the embedded application. - */ + * Send a ConfigureNotify to the embedded application. + */ - if (containerPtr->embeddedPtr != NULL) { - TkDoConfigureNotify(containerPtr->embeddedPtr); - } + if (containerPtr->embeddedPtr != NULL) { + TkDoConfigureNotify(containerPtr->embeddedPtr); + } /* * Resize the embedded window, if there is any. diff --git a/win/tkWinGDI.c b/win/tkWinGDI.c index 7ed36ff..2cded45 100644 --- a/win/tkWinGDI.c +++ b/win/tkWinGDI.c @@ -574,20 +574,20 @@ static int Bezierize( inPointList = (double *)attemptckalloc(2 * sizeof(double) * npoly); if (inPointList == 0) { /* TODO: unreachable */ - return nbpoints; /* 0. */ + return nbpoints; /* 0. */ } for (n=0; n<npoly; n++) { - inPointList[2*n] = polypoints[n].x; - inPointList[2*n + 1] = polypoints[n].y; + inPointList[2*n] = polypoints[n].x; + inPointList[2*n + 1] = polypoints[n].y; } nbpoints = 1 + npoly * nStep; /* this is the upper limit. */ outPointList = (double *)attemptckalloc(2 * sizeof(double) * nbpoints); if (outPointList == 0) { /* TODO: unreachable */ - ckfree(inPointList); - return 0; + ckfree(inPointList); + return 0; } nbpoints = TkMakeBezierCurve(NULL, inPointList, npoly, nStep, @@ -597,13 +597,13 @@ static int Bezierize( bpoints = (POINT *)attemptckalloc(sizeof(POINT)*nbpoints); if (bpoints == 0) { /* TODO: unreachable */ - ckfree(outPointList); - return 0; + ckfree(outPointList); + return 0; } for (n=0; n<nbpoints; n++) { - bpoints[n].x = (long)outPointList[2*n]; - bpoints[n].y = (long)outPointList[2*n + 1]; + bpoints[n].x = (long)outPointList[2*n]; + bpoints[n].y = (long)outPointList[2*n + 1]; } ckfree(outPointList); *bpointptr = *bpoints; @@ -1420,7 +1420,7 @@ static int GdiCharWidths( DWORD val = GetLastError(); Tcl_SetObjResult(interp, Tcl_ObjPrintf( - "::tk::print::_gdi character failed with code %ld", val)); + "::tk::print::_gdi character failed with code %ld", val)); if (made_font) { SelectObject(hDC, oldfont); DeleteObject(hfont); @@ -2981,7 +2981,7 @@ static HANDLE CopyToDIB( /* Check for a valid window handle. */ if (!hWnd) { - return NULL; + return NULL; } switch (type) { @@ -3150,16 +3150,16 @@ static HBITMAP CopyScreenToBitmap( /* Make sure bitmap rectangle is visible. */ if (nX < 0) { - nX = 0; + nX = 0; } if (nY < 0) { - nY = 0; + nY = 0; } if (nX2 > xScrn) { - nX2 = xScrn; + nX2 = xScrn; } if (nY2 > yScrn) { - nY2 = yScrn; + nY2 = yScrn; } nWidth = nX2 - nX; @@ -3220,19 +3220,19 @@ static HANDLE BitmapToDIB( /* Check if bitmap handle is valid. */ if (!hBitmap) { - return NULL; + return NULL; } /* Fill in BITMAP structure, return NULL if it didn't work. */ if (!GetObjectW(hBitmap, sizeof(bm), (LPWSTR)&bm)) { - return NULL; + return NULL; } /* Ff no palette is specified, use default palette. */ if (hPal == NULL) { - hPal = (HPALETTE)GetStockObject(DEFAULT_PALETTE); + hPal = (HPALETTE)GetStockObject(DEFAULT_PALETTE); } /* Calculate bits per pixel. */ @@ -3242,13 +3242,13 @@ static HANDLE BitmapToDIB( /* Make sure bits per pixel is valid. */ if (biBits <= 1) { - biBits = 1; + biBits = 1; } else if (biBits <= 4) { - biBits = 4; + biBits = 4; } else if (biBits <= 8) { - biBits = 8; + biBits = 8; } else { /* If greater than 8-bit, force to 24-bit. */ - biBits = 24; + biBits = 24; } /* Initialize BITMAPINFOHEADER. */ @@ -3315,7 +3315,7 @@ static HANDLE BitmapToDIB( /* If the driver did not fill in the biSizeImage field, make one up. */ if (bi.biSizeImage == 0) { - bi.biSizeImage = (((((DWORD)bm.bmWidth * biBits) + 31) / 32) * 4) + bi.biSizeImage = (((((DWORD)bm.bmWidth * biBits) + 31) / 32) * 4) * bm.bmHeight; } @@ -3324,7 +3324,7 @@ static HANDLE BitmapToDIB( dwLen = bi.biSize + DIBNumColors(&bi) * sizeof(RGBQUAD) + bi.biSizeImage; if ((h = GlobalReAlloc(hDIB, dwLen, 0)) != 0) { - hDIB = h; + hDIB = h; } else { /* Clean up and return NULL. */ @@ -3442,7 +3442,7 @@ static HPALETTE GetSystemPalette(void) hDC = GetDC(NULL); if (!hDC) { - return NULL; + return NULL; } nColors = PalEntriesOnDevice(hDC); /* Number of palette entries. */ @@ -3454,7 +3454,7 @@ static HPALETTE GetSystemPalette(void) if (!hLogPal) { /* If we didn't get a logical palette, return NULL. */ - return NULL; + return NULL; } /* get a pointer to the logical palette. */ @@ -3645,23 +3645,23 @@ static int PrintSelectPrinter( * script level. */ if (localPrinterName != NULL) { - char* varlink1 = (char*)ckalloc(100 * sizeof(char)); - char** varlink2 = (char**)ckalloc(sizeof(char*)); - *varlink2 = varlink1; - WideCharToMultiByte(CP_UTF8, 0, localPrinterName, -1, varlink1, 0, NULL, NULL); - - Tcl_LinkVar(interp, "::tk::print::printer_name", varlink2, - TCL_LINK_STRING | TCL_LINK_READ_ONLY); - Tcl_LinkVar(interp, "::tk::print::copies", &copies, - TCL_LINK_INT | TCL_LINK_READ_ONLY); - Tcl_LinkVar(interp, "::tk::print::dpi_x", &dpi_x, - TCL_LINK_INT | TCL_LINK_READ_ONLY); - Tcl_LinkVar(interp, "::tk::print::dpi_y", &dpi_y, - TCL_LINK_INT | TCL_LINK_READ_ONLY); - Tcl_LinkVar(interp, "::tk::print::paper_width", &paper_width, - TCL_LINK_INT | TCL_LINK_READ_ONLY); - Tcl_LinkVar(interp, "::tk::print::paper_height", &paper_height, - TCL_LINK_INT | TCL_LINK_READ_ONLY); + char* varlink1 = (char*)ckalloc(100 * sizeof(char)); + char** varlink2 = (char**)ckalloc(sizeof(char*)); + *varlink2 = varlink1; + WideCharToMultiByte(CP_UTF8, 0, localPrinterName, -1, varlink1, 0, NULL, NULL); + + Tcl_LinkVar(interp, "::tk::print::printer_name", varlink2, + TCL_LINK_STRING | TCL_LINK_READ_ONLY); + Tcl_LinkVar(interp, "::tk::print::copies", &copies, + TCL_LINK_INT | TCL_LINK_READ_ONLY); + Tcl_LinkVar(interp, "::tk::print::dpi_x", &dpi_x, + TCL_LINK_INT | TCL_LINK_READ_ONLY); + Tcl_LinkVar(interp, "::tk::print::dpi_y", &dpi_y, + TCL_LINK_INT | TCL_LINK_READ_ONLY); + Tcl_LinkVar(interp, "::tk::print::paper_width", &paper_width, + TCL_LINK_INT | TCL_LINK_READ_ONLY); + Tcl_LinkVar(interp, "::tk::print::paper_height", &paper_height, + TCL_LINK_INT | TCL_LINK_READ_ONLY); } return TCL_OK; diff --git a/win/tkWinIco.c b/win/tkWinIco.c index 134e7f0..899d437 100644 --- a/win/tkWinIco.c +++ b/win/tkWinIco.c @@ -171,9 +171,9 @@ CreateIcoFromPhoto( bmInfo.bmiHeader.biCompression = BI_RGB; iconInfo.hbmColor = CreateDIBSection(NULL, &bmInfo, DIB_RGB_COLORS, - &bgraPixel.voidPtr, NULL, 0); + &bgraPixel.voidPtr, NULL, 0); if (!iconInfo.hbmColor) { - return NULL; + return NULL; } /* @@ -182,10 +182,10 @@ CreateIcoFromPhoto( bufferSize = height * width * 4; for (idx = 0 ; idx < bufferSize ; idx += 4) { - bgraPixel.ptr[idx] = block.pixelPtr[idx+2]; - bgraPixel.ptr[idx+1] = block.pixelPtr[idx+1]; - bgraPixel.ptr[idx+2] = block.pixelPtr[idx+0]; - bgraPixel.ptr[idx+3] = block.pixelPtr[idx+3]; + bgraPixel.ptr[idx] = block.pixelPtr[idx+2]; + bgraPixel.ptr[idx+1] = block.pixelPtr[idx+1]; + bgraPixel.ptr[idx+2] = block.pixelPtr[idx+0]; + bgraPixel.ptr[idx+3] = block.pixelPtr[idx+3]; } /* @@ -197,10 +197,10 @@ CreateIcoFromPhoto( bmInfo.bmiHeader.biBitCount = 1; iconInfo.hbmMask = CreateDIBSection(NULL, &bmInfo, DIB_RGB_COLORS, - &bgraMask.voidPtr, NULL, 0); + &bgraMask.voidPtr, NULL, 0); if (!iconInfo.hbmMask) { - DeleteObject(iconInfo.hbmColor); - return NULL; + DeleteObject(iconInfo.hbmColor); + return NULL; } memset(bgraMask.ptr, 0, width*height/8); @@ -213,7 +213,7 @@ CreateIcoFromPhoto( DeleteObject(iconInfo.hbmColor); DeleteObject(iconInfo.hbmMask); if (hIcon == NULL) { - return NULL; + return NULL; } return hIcon; diff --git a/win/tkWinIco.h b/win/tkWinIco.h index 16cbb77..d690f49 100644 --- a/win/tkWinIco.h +++ b/win/tkWinIco.h @@ -86,8 +86,7 @@ typedef struct { DWORD BytesPerLine(LPBITMAPINFOHEADER lpBMIH); LPSTR FindDIBBits(LPSTR lpbi); -HICON CreateIcoFromPhoto(int width, int height, - Tk_PhotoImageBlock block); +HICON CreateIcoFromPhoto(int width, int height, Tk_PhotoImageBlock block); /* diff --git a/win/tkWinKey.c b/win/tkWinKey.c index f2230c9..61cb06e 100644 --- a/win/tkWinKey.c +++ b/win/tkWinKey.c @@ -358,9 +358,9 @@ KeycodeToKeysym( */ case VK_CONTROL: - if (state & EXTENDED_MASK) { - return XK_Control_R; - } + if (state & EXTENDED_MASK) { + return XK_Control_R; + } break; case VK_SHIFT: if (GetKeyState(VK_RSHIFT) & 0x80) { @@ -368,9 +368,9 @@ KeycodeToKeysym( } break; case VK_MENU: - if (state & EXTENDED_MASK) { - return XK_Alt_R; - } + if (state & EXTENDED_MASK) { + return XK_Alt_R; + } break; } return keymap[keycode]; diff --git a/win/tkWinMenu.c b/win/tkWinMenu.c index 5dadf56..909237c 100644 --- a/win/tkWinMenu.c +++ b/win/tkWinMenu.c @@ -1601,14 +1601,14 @@ GetMenuIndicatorGeometry( menuPtr->borderWidthPtr, &borderWidth); *widthPtr = indicatorDimensions[1] - borderWidth; - /* - * Quite dubious about the above (why would borderWidth play a role?) - * and about how indicatorDimensions[1] is obtained in SetDefaults(). - * At least don't let the result be negative! - */ - if (*widthPtr < 0) { - *widthPtr = 0; - } + /* + * Quite dubious about the above (why would borderWidth play a role?) + * and about how indicatorDimensions[1] is obtained in SetDefaults(). + * At least don't let the result be negative! + */ + if (*widthPtr < 0) { + *widthPtr = 0; + } } } @@ -1639,12 +1639,12 @@ GetMenuAccelGeometry( { *heightPtr = fmPtr->linespace; if (mePtr->type == CASCADE_ENTRY) { - /* - * Cascade entries have no accelerator but do show an arrow. Set - * this field width to the width of the OBM_MNARROW system bitmap - * used to display the arrow. I couldn't find how to query the - * system for this value, therefore I resort to hardcoding. - */ + /* + * Cascade entries have no accelerator but do show an arrow. Set + * this field width to the width of the OBM_MNARROW system bitmap + * used to display the arrow. I couldn't find how to query the + * system for this value, therefore I resort to hardcoding. + */ *widthPtr = CASCADE_ARROW_WIDTH; } else if ((menuPtr->menuType != MENUBAR) && (mePtr->accelPtr != NULL)) { const char *accel = Tcl_GetString(mePtr->accelPtr); @@ -1908,7 +1908,7 @@ DrawMenuEntryAccelerator( const char *accel; if (menuPtr->menuType == MENUBAR) { - return; + return; } if (mePtr->accelPtr != NULL) { @@ -1991,8 +1991,8 @@ DrawMenuEntryArrow( */ if ((mePtr->childMenuRefPtr == NULL) - || (mePtr->childMenuRefPtr->menuPtr == NULL)) { - return; + || (mePtr->childMenuRefPtr->menuPtr == NULL)) { + return; } oldFgColor = gc->foreground; @@ -2949,8 +2949,8 @@ DrawMenuEntryBackground( Tk_Fill3DRectangle(menuPtr->tkwin, d, bgBorder, x, y, width, height, activeBorderWidth, relief); } else { - Tk_Fill3DRectangle(menuPtr->tkwin, d, bgBorder, x, y, width, height, 0, - TK_RELIEF_FLAT); + Tk_Fill3DRectangle(menuPtr->tkwin, d, bgBorder, x, y, width, height, 0, + TK_RELIEF_FLAT); } } diff --git a/win/tkWinPointer.c b/win/tkWinPointer.c index b895a96..5ccd862 100644 --- a/win/tkWinPointer.c +++ b/win/tkWinPointer.c @@ -377,8 +377,8 @@ void TkSetCursorPos( * requested position is off the primary screen. */ if ( x < 0 || x > xscreen || y < 0 || y > yscreen ) { - SetCursorPos(x, y); - return; + SetCursorPos(x, y); + return; } input.type = INPUT_MOUSE; @@ -394,7 +394,7 @@ void TkSetCursorPos( * See ticket [69b48f427e]. */ if (input.mi.dx == 0 && input.mi.dy == 0) { - input.mi.dx = 1; + input.mi.dx = 1; } input.mi.mouseData = 0; diff --git a/win/tkWinScrlbr.c b/win/tkWinScrlbr.c index 457b82f..a54deeb 100644 --- a/win/tkWinScrlbr.c +++ b/win/tkWinScrlbr.c @@ -394,10 +394,6 @@ TkpComputeScrollbarGeometry( * basic sanity checks to appease backwards compatibility. */ - if (scrollPtr->highlightWidth < 0) { - scrollPtr->highlightWidth = 0; - } - if (scrollPtr->vertical) { scrollPtr->arrowLength = vArrowHeight; fieldLength = Tk_Height(scrollPtr->tkwin); diff --git a/win/tkWinSendCom.h b/win/tkWinSendCom.h index d20b48c..73f326b 100644 --- a/win/tkWinSendCom.h +++ b/win/tkWinSendCom.h @@ -46,11 +46,11 @@ typedef struct { */ MODULE_SCOPE HRESULT TkWinSendCom_CreateInstance(Tcl_Interp *interp, - REFIID riid, void **ppv); + REFIID riid, void **ppv); MODULE_SCOPE int TkWinSend_QueueCommand(Tcl_Interp *interp, - Tcl_Obj *cmdPtr); + Tcl_Obj *cmdPtr); MODULE_SCOPE void TkWinSend_SetExcepInfo(Tcl_Interp *interp, - EXCEPINFO *pExcepInfo); + EXCEPINFO *pExcepInfo); #endif /* _tkWinSendCom_h_INCLUDE */ diff --git a/win/tkWinSysTray.c b/win/tkWinSysTray.c index 6c8893e..a710ee6 100644 --- a/win/tkWinSysTray.c +++ b/win/tkWinSysTray.c @@ -36,11 +36,11 @@ typedef struct IcoInfo { HICON hIcon; /* icon handle returned by LoadIcon. */ unsigned id; /* Identifier for command; used to - * cancel it. */ + * cancel it. */ Tcl_Obj *taskbar_txt; /* text to display in the taskbar */ Tcl_Interp *interp; /* interp which created the icon */ Tcl_Obj *taskbar_command; /* command to eval if events in the taskbar - * arrive */ + * arrive */ int taskbar_flags; /* taskbar related flags*/ HWND hwndFocus; struct IcoInfo *nextPtr; @@ -102,9 +102,9 @@ DrawXORMask( /* Sanity checks */ if (lpIcon == NULL) - return FALSE; + return FALSE; if (lpIcon->lpBits == NULL) - return FALSE; + return FALSE; /* Account for height*2 thing */ lpIcon->lpbi->bmiHeader.biHeight /= 2; @@ -115,10 +115,10 @@ DrawXORMask( /* Blast it to the screen */ SetDIBitsToDevice(hDC, x, y, - lpIcon->lpbi->bmiHeader.biWidth, - lpIcon->lpbi->bmiHeader.biHeight, - 0, 0, 0, lpIcon->lpbi->bmiHeader.biHeight, - lpIcon->lpXOR, lpIcon->lpbi, DIB_RGB_COLORS); + lpIcon->lpbi->bmiHeader.biWidth, + lpIcon->lpbi->bmiHeader.biHeight, + 0, 0, 0, lpIcon->lpbi->bmiHeader.biHeight, + lpIcon->lpXOR, lpIcon->lpbi, DIB_RGB_COLORS); /* UnAccount for height*2 thing */ lpIcon->lpbi->bmiHeader.biHeight *= 2; @@ -153,9 +153,9 @@ DrawANDMask( /* Sanity checks */ if (lpIcon == NULL) - return FALSE; + return FALSE; if (lpIcon->lpBits == NULL) - return FALSE; + return FALSE; /* Need a bitmap header for the mono mask */ lpbi = ckalloc(sizeof(BITMAPINFO) + (2 * sizeof(RGBQUAD))); @@ -185,10 +185,10 @@ DrawANDMask( /* Blast it to the screen */ SetDIBitsToDevice(hDC, x, y, - lpbi->bmiHeader.biWidth, - lpbi->bmiHeader.biHeight, - 0, 0, 0, lpbi->bmiHeader.biHeight, - lpIcon->lpAND, lpbi, DIB_RGB_COLORS); + lpbi->bmiHeader.biWidth, + lpbi->bmiHeader.biHeight, + 0, 0, 0, lpbi->bmiHeader.biHeight, + lpIcon->lpAND, lpbi, DIB_RGB_COLORS); /* clean up */ ckfree(lpbi); @@ -230,22 +230,22 @@ TaskbarOperation( ni.hIcon = icoPtr->hIcon; if (icoPtr->taskbar_txt != NULL) { - Tcl_DString dst; - Tcl_DStringInit(&dst); - str = (WCHAR *)Tcl_UtfToWCharDString(Tcl_GetString(icoPtr->taskbar_txt), TCL_INDEX_NONE, &dst); - wcsncpy(ni.szTip, str, (Tcl_DStringLength(&dst) + 2) / 2); - Tcl_DStringFree(&dst); + Tcl_DString dst; + Tcl_DStringInit(&dst); + str = (WCHAR *)Tcl_UtfToWCharDString(Tcl_GetString(icoPtr->taskbar_txt), TCL_INDEX_NONE, &dst); + wcsncpy(ni.szTip, str, (Tcl_DStringLength(&dst) + 2) / 2); + Tcl_DStringFree(&dst); } else { - ni.szTip[0] = 0; + ni.szTip[0] = 0; } if (Shell_NotifyIconW(oper, &ni) == 1) { - if (oper == NIM_ADD || oper == NIM_MODIFY) { - icoPtr->taskbar_flags |= TASKBAR_ICON; - } - if (oper == NIM_DELETE) { - icoPtr->taskbar_flags &= ~TASKBAR_ICON; - } + if (oper == NIM_ADD || oper == NIM_MODIFY) { + icoPtr->taskbar_flags |= TASKBAR_ICON; + } + if (oper == NIM_DELETE) { + icoPtr->taskbar_flags &= ~TASKBAR_ICON; + } } /* Silently ignore error? */ return TCL_OK; @@ -312,22 +312,22 @@ FreeIcoPtr( { IcoInfo *prevPtr; if (icoInterpPtr->firstIcoPtr == icoPtr) { - icoInterpPtr->firstIcoPtr = icoPtr->nextPtr; + icoInterpPtr->firstIcoPtr = icoPtr->nextPtr; } else { - for (prevPtr = icoInterpPtr->firstIcoPtr; prevPtr->nextPtr != icoPtr; - prevPtr = prevPtr->nextPtr) { - /* Empty loop body. */ - } - prevPtr->nextPtr = icoPtr->nextPtr; + for (prevPtr = icoInterpPtr->firstIcoPtr; prevPtr->nextPtr != icoPtr; + prevPtr = prevPtr->nextPtr) { + /* Empty loop body. */ + } + prevPtr->nextPtr = icoPtr->nextPtr; } if (icoPtr->taskbar_flags & TASKBAR_ICON) { - TaskbarOperation(icoInterpPtr, icoPtr, NIM_DELETE); + TaskbarOperation(icoInterpPtr, icoPtr, NIM_DELETE); } if (icoPtr->taskbar_txt != NULL) { - Tcl_DecrRefCount(icoPtr->taskbar_txt); + Tcl_DecrRefCount(icoPtr->taskbar_txt); } if (icoPtr->taskbar_command != NULL) { - Tcl_DecrRefCount(icoPtr->taskbar_command); + Tcl_DecrRefCount(icoPtr->taskbar_command); } ckfree(icoPtr); } @@ -360,22 +360,22 @@ GetIcoPtr( char *end; if (strncmp(string, "ico#", 4) != 0) { - goto notfound; + goto notfound; } start = string + 4; id = strtoul(start, &end, 10); if ((end == start) || (*end != 0)) { - goto notfound; + goto notfound; } for (icoPtr = icoInterpPtr->firstIcoPtr; icoPtr != NULL; icoPtr = icoPtr->nextPtr) { - if (icoPtr->id == id) { - return icoPtr; - } + if (icoPtr->id == id) { + return icoPtr; + } } notfound: Tcl_AppendResult(interp, "icon \"", string, - "\" doesn't exist", NULL); + "\" doesn't exist", NULL); return NULL; } @@ -466,117 +466,117 @@ TaskbarExpandPercents( char* dst; dst = after; while (*before) { - const char *ptr = before; - int len = 1; - if(*before == '%') { - switch(before[1]){ - case 'M': - case 'm': { - before++; - len = strlen(msgstring); - ptr = msgstring; - break; - } - /* case 'W': { - before++; - len = (int)strlen(winstring); - ptr = winstring; - break; - } - */ - case 'i': { - before++; - snprintf(buffer, sizeof(buffer) - 1, "ico#%d", icoPtr->id); - len = strlen(buffer); - ptr = buffer; - break; - } - case 'w': { - before++; - len = GetInt((long)wParam,buffer, sizeof(buffer)); - ptr = buffer; - break; - } - case 'l': { - before++; - len = GetInt((long)lParam,buffer, sizeof(buffer)); - ptr = buffer; - break; - } - case 't': { - before++; - len = GetInt((long)GetTickCount(), buffer, sizeof(buffer)); - ptr = buffer; - break; - } - case 'x': { - POINT pt; - GetCursorPos(&pt); - before++; - len = GetIntDec((long)pt.x, buffer, sizeof(buffer)); - ptr = buffer; - break; - } - case 'y': { - POINT pt; - GetCursorPos(&pt); - before++; - len = GetIntDec((long)pt.y,buffer, sizeof(buffer)); - ptr = buffer; - break; - } - case 'X': { - DWORD dw; - dw = GetMessagePos(); - before++; - len = GetIntDec((long)LOWORD(dw),buffer, sizeof(buffer)); - ptr = buffer; - break; - } - case 'Y': { - DWORD dw; - dw = GetMessagePos(); - before++; - len = GetIntDec((long)HIWORD(dw),buffer, sizeof(buffer)); - ptr = buffer; - break; - } - case 'H': { - before++; - len = GetInt(PTR2INT(icoPtr->hwndFocus), buffer, sizeof(buffer)); - ptr = buffer; - break; - } - case '%': { - before++; - len = 1; - ptr = "%"; - break; - } - } - } - if (SPACELEFT < len) { - char *newspace; - ptrdiff_t dist = dst - after; - int alloclen = ALLOCLEN; - newspace = (char *)ckalloc(alloclen); - if (dist>0) - memcpy(newspace, after, dist); - if (after && *aftersize) { - ckfree(after); - } - *aftersize =alloclen; - after = newspace; - dst = after + dist; - } - if (len > 0) { - memcpy(dst, ptr, len); - } - dst += len; - if ((dst-after)>(*aftersize-1)) { - printf("oops\n"); - } - before++; + const char *ptr = before; + int len = 1; + if(*before == '%') { + switch(before[1]){ + case 'M': + case 'm': { + before++; + len = strlen(msgstring); + ptr = msgstring; + break; + } + /* case 'W': { + before++; + len = (int)strlen(winstring); + ptr = winstring; + break; + } + */ + case 'i': { + before++; + snprintf(buffer, sizeof(buffer) - 1, "ico#%d", icoPtr->id); + len = strlen(buffer); + ptr = buffer; + break; + } + case 'w': { + before++; + len = GetInt((long)wParam,buffer, sizeof(buffer)); + ptr = buffer; + break; + } + case 'l': { + before++; + len = GetInt((long)lParam,buffer, sizeof(buffer)); + ptr = buffer; + break; + } + case 't': { + before++; + len = GetInt((long)GetTickCount(), buffer, sizeof(buffer)); + ptr = buffer; + break; + } + case 'x': { + POINT pt; + GetCursorPos(&pt); + before++; + len = GetIntDec((long)pt.x, buffer, sizeof(buffer)); + ptr = buffer; + break; + } + case 'y': { + POINT pt; + GetCursorPos(&pt); + before++; + len = GetIntDec((long)pt.y,buffer, sizeof(buffer)); + ptr = buffer; + break; + } + case 'X': { + DWORD dw; + dw = GetMessagePos(); + before++; + len = GetIntDec((long)LOWORD(dw),buffer, sizeof(buffer)); + ptr = buffer; + break; + } + case 'Y': { + DWORD dw; + dw = GetMessagePos(); + before++; + len = GetIntDec((long)HIWORD(dw),buffer, sizeof(buffer)); + ptr = buffer; + break; + } + case 'H': { + before++; + len = GetInt(PTR2INT(icoPtr->hwndFocus), buffer, sizeof(buffer)); + ptr = buffer; + break; + } + case '%': { + before++; + len = 1; + ptr = "%"; + break; + } + } + } + if (SPACELEFT < len) { + char *newspace; + ptrdiff_t dist = dst - after; + int alloclen = ALLOCLEN; + newspace = (char *)ckalloc(alloclen); + if (dist>0) + memcpy(newspace, after, dist); + if (after && *aftersize) { + ckfree(after); + } + *aftersize =alloclen; + after = newspace; + dst = after + dist; + } + if (len > 0) { + memcpy(dst, ptr, len); + } + dst += len; + if ((dst-after)>(*aftersize-1)) { + printf("oops\n"); + } + before++; } *dst = 0; return after; @@ -612,87 +612,87 @@ TaskbarEval( switch (lParam) { case WM_MOUSEMOVE: - msgstring = "WM_MOUSEMOVE"; - icoPtr->hwndFocus = GetFocus(); - break; + msgstring = "WM_MOUSEMOVE"; + icoPtr->hwndFocus = GetFocus(); + break; case WM_LBUTTONDOWN: - msgstring = "WM_LBUTTONDOWN"; - fixup = 1; - break; + msgstring = "WM_LBUTTONDOWN"; + fixup = 1; + break; case WM_LBUTTONUP: - msgstring = "WM_LBUTTONUP"; - fixup = 1; - break; + msgstring = "WM_LBUTTONUP"; + fixup = 1; + break; case WM_LBUTTONDBLCLK: - msgstring = "WM_LBUTTONDBLCLK"; - fixup = 1; - break; + msgstring = "WM_LBUTTONDBLCLK"; + fixup = 1; + break; case WM_RBUTTONDOWN: - msgstring = "WM_RBUTTONDOWN"; - fixup = 1; - break; + msgstring = "WM_RBUTTONDOWN"; + fixup = 1; + break; case WM_RBUTTONUP: - msgstring = "WM_RBUTTONUP"; - fixup = 1; - break; + msgstring = "WM_RBUTTONUP"; + fixup = 1; + break; case WM_RBUTTONDBLCLK: - msgstring = "WM_RBUTTONDBLCLK"; - fixup = 1; - break; + msgstring = "WM_RBUTTONDBLCLK"; + fixup = 1; + break; case WM_MBUTTONDOWN: - msgstring = "WM_MBUTTONDOWN"; - fixup = 1; - break; + msgstring = "WM_MBUTTONDOWN"; + fixup = 1; + break; case WM_MBUTTONUP: - msgstring = "WM_MBUTTONUP"; - fixup = 1; - break; + msgstring = "WM_MBUTTONUP"; + fixup = 1; + break; case WM_MBUTTONDBLCLK: - msgstring = "WM_MBUTTONDBLCLK"; - fixup = 1; - break; + msgstring = "WM_MBUTTONDBLCLK"; + fixup = 1; + break; default: - msgstring = "WM_NULL"; - fixup = 0; + msgstring = "WM_NULL"; + fixup = 0; } expanded = TaskbarExpandPercents(icoPtr, msgstring, wParam, lParam, - Tcl_GetString(icoPtr->taskbar_command), evalspace, &evalsize); + Tcl_GetString(icoPtr->taskbar_command), evalspace, &evalsize); if (icoPtr->interp != NULL) { - int result; - HWND hwnd = NULL; - - /* See http://support.microsoft.com/kb/q135788/ - * Seems to have moved to https://www.betaarchive.com/wiki/index.php/Microsoft_KB_Archive/135788 */ - if (fixup) { - if (icoPtr->hwndFocus != NULL && IsWindow(icoPtr->hwndFocus)) { - hwnd = icoPtr->hwndFocus; - } else { - Tk_Window tkwin = Tk_MainWindow(icoPtr->interp); - if (tkwin != NULL) { - hwnd = Tk_GetHWND(Tk_WindowId(tkwin)); - } - } - if (hwnd != NULL) { - SetForegroundWindow(hwnd); - } - } - - result = Tcl_GlobalEval(icoPtr->interp, expanded); - - if (hwnd != NULL) { - /* See http://support.microsoft.com/kb/q135788/ - * Seems to have moved to https://www.betaarchive.com/wiki/index.php/Microsoft_KB_Archive/135788 */ - PostMessageW(hwnd, WM_NULL, 0, 0); - } - if (result != TCL_OK) { - char buffer[100]; - snprintf(buffer, 100, "\n (command bound to taskbar-icon ico#%d)", icoPtr->id); - Tcl_AddErrorInfo(icoPtr->interp, buffer); - Tcl_BackgroundError(icoPtr->interp); - } + int result; + HWND hwnd = NULL; + + /* See http://support.microsoft.com/kb/q135788/ + * Seems to have moved to https://www.betaarchive.com/wiki/index.php/Microsoft_KB_Archive/135788 */ + if (fixup) { + if (icoPtr->hwndFocus != NULL && IsWindow(icoPtr->hwndFocus)) { + hwnd = icoPtr->hwndFocus; + } else { + Tk_Window tkwin = Tk_MainWindow(icoPtr->interp); + if (tkwin != NULL) { + hwnd = Tk_GetHWND(Tk_WindowId(tkwin)); + } + } + if (hwnd != NULL) { + SetForegroundWindow(hwnd); + } + } + + result = Tcl_GlobalEval(icoPtr->interp, expanded); + + if (hwnd != NULL) { + /* See http://support.microsoft.com/kb/q135788/ + * Seems to have moved to https://www.betaarchive.com/wiki/index.php/Microsoft_KB_Archive/135788 */ + PostMessageW(hwnd, WM_NULL, 0, 0); + } + if (result != TCL_OK) { + char buffer[100]; + snprintf(buffer, 100, "\n (command bound to taskbar-icon ico#%d)", icoPtr->id); + Tcl_AddErrorInfo(icoPtr->interp, buffer); + Tcl_BackgroundError(icoPtr->interp); + } } if (expanded != evalspace) { - ckfree(expanded); + ckfree(expanded); } } @@ -726,43 +726,43 @@ TaskbarHandlerProc( switch (message) { case WM_CREATE: - msgTaskbarCreated = RegisterWindowMessage(TEXT("TaskbarCreated")); - break; + msgTaskbarCreated = RegisterWindowMessage(TEXT("TaskbarCreated")); + break; case ICON_MESSAGE: - for (icoInterpPtr = firstIcoInterpPtr; icoInterpPtr != NULL; icoInterpPtr = icoInterpPtr->nextPtr) { - if (icoInterpPtr->hwnd == hwnd) { - for (icoPtr = icoInterpPtr->firstIcoPtr; icoPtr != NULL; icoPtr = icoPtr->nextPtr) { - if (icoPtr->id == wParam) { - if (icoPtr->taskbar_command != NULL) { - TaskbarEval(icoPtr, wParam, lParam); - } - break; - } - } - break; - } - } - break; + for (icoInterpPtr = firstIcoInterpPtr; icoInterpPtr != NULL; icoInterpPtr = icoInterpPtr->nextPtr) { + if (icoInterpPtr->hwnd == hwnd) { + for (icoPtr = icoInterpPtr->firstIcoPtr; icoPtr != NULL; icoPtr = icoPtr->nextPtr) { + if (icoPtr->id == wParam) { + if (icoPtr->taskbar_command != NULL) { + TaskbarEval(icoPtr, wParam, lParam); + } + break; + } + } + break; + } + } + break; default: - /* - * Check to see if explorer has been restarted and we need to - * re-add our icons. - */ - if (message == msgTaskbarCreated) { - for (icoInterpPtr = firstIcoInterpPtr; icoInterpPtr != NULL; icoInterpPtr = icoInterpPtr->nextPtr) { - if (icoInterpPtr->hwnd == hwnd) { - for (icoPtr = icoInterpPtr->firstIcoPtr; icoPtr != NULL; icoPtr = icoPtr->nextPtr) { - if (icoPtr->taskbar_flags & TASKBAR_ICON) { - TaskbarOperation(icoInterpPtr, icoPtr, NIM_ADD); - } - } - break; - } - } - } - return DefWindowProc(hwnd, message, wParam, lParam); + /* + * Check to see if explorer has been restarted and we need to + * re-add our icons. + */ + if (message == msgTaskbarCreated) { + for (icoInterpPtr = firstIcoInterpPtr; icoInterpPtr != NULL; icoInterpPtr = icoInterpPtr->nextPtr) { + if (icoInterpPtr->hwnd == hwnd) { + for (icoPtr = icoInterpPtr->firstIcoPtr; icoPtr != NULL; icoPtr = icoPtr->nextPtr) { + if (icoPtr->taskbar_flags & TASKBAR_ICON) { + TaskbarOperation(icoInterpPtr, icoPtr, NIM_ADD); + } + } + break; + } + } + } + return DefWindowProc(hwnd, message, wParam, lParam); } return 0; } @@ -823,12 +823,12 @@ CreateTaskbarHandlerWindow(void) { static int registered = 0; HINSTANCE hInstance = GETHINSTANCE; if (!registered) { - if (!RegisterHandlerClass(hInstance)) - return 0; - registered = 1; + if (!RegisterHandlerClass(hInstance)) + return 0; + registered = 1; } return CreateWindow(HANDLER_CLASS, "", WS_OVERLAPPED, 0, 0, - CW_USEDEFAULT, CW_USEDEFAULT, NULL, NULL, hInstance, NULL); + CW_USEDEFAULT, CW_USEDEFAULT, NULL, NULL, hInstance, NULL); } /* @@ -860,23 +860,23 @@ WinIcoDestroy( IcoInfo *nextPtr; if (eventPtr->type != DestroyNotify) { - return; + return; } if (firstIcoInterpPtr == icoInterpPtr) { - firstIcoInterpPtr = icoInterpPtr->nextPtr; + firstIcoInterpPtr = icoInterpPtr->nextPtr; } else { - for (prevIcoInterpPtr = firstIcoInterpPtr; prevIcoInterpPtr->nextPtr != icoInterpPtr; - prevIcoInterpPtr = prevIcoInterpPtr->nextPtr) { - /* Empty loop body. */ - } - prevIcoInterpPtr->nextPtr = icoInterpPtr->nextPtr; + for (prevIcoInterpPtr = firstIcoInterpPtr; prevIcoInterpPtr->nextPtr != icoInterpPtr; + prevIcoInterpPtr = prevIcoInterpPtr->nextPtr) { + /* Empty loop body. */ + } + prevIcoInterpPtr->nextPtr = icoInterpPtr->nextPtr; } DestroyWindow(icoInterpPtr->hwnd); for (icoPtr = icoInterpPtr->firstIcoPtr; icoPtr != NULL; icoPtr = nextPtr) { - nextPtr = icoPtr->nextPtr; - FreeIcoPtr(icoInterpPtr, icoPtr); + nextPtr = icoPtr->nextPtr; + FreeIcoPtr(icoInterpPtr, icoPtr); } ckfree(icoInterpPtr); } @@ -905,11 +905,11 @@ WinSystrayCmd( Tcl_Obj *const objv[]) { static const char *const cmdStrings[] = { - "add", "delete", "modify", NULL + "add", "delete", "modify", NULL }; enum { CMD_ADD, CMD_DELETE, CMD_MODIFY }; static const char *const optStrings[] = { - "-callback", "-image", "-text", NULL + "-callback", "-image", "-text", NULL }; enum { OPT_CALLBACK, OPT_IMAGE, OPT_TEXT }; int cmd, opt; @@ -920,124 +920,124 @@ WinSystrayCmd( IcoInfo *icoPtr = NULL; if (objc < 2) { - Tcl_WrongNumArgs(interp, 1, objv, "command ..."); - return TCL_ERROR; + Tcl_WrongNumArgs(interp, 1, objv, "command ..."); + return TCL_ERROR; } if (Tcl_GetIndexFromObj(interp, objv[1], cmdStrings, "command", - 0, &cmd) == TCL_ERROR) { - return TCL_ERROR; + 0, &cmd) == TCL_ERROR) { + return TCL_ERROR; } switch (cmd) { - case CMD_ADD: - case CMD_MODIFY: { - Tcl_Obj *imageObj = NULL, *textObj = NULL, *callbackObj = NULL; - int optStart; - int oper; - if (cmd == CMD_ADD) { - optStart = 2; - oper = NIM_ADD; - } else { - optStart = 3; - oper = NIM_MODIFY; - if (objc != 5) { - Tcl_WrongNumArgs(interp, 2, objv, "id option value"); - return TCL_ERROR; - } - icoPtr = GetIcoPtr(interp, icoInterpPtr, Tcl_GetString(objv[2])); - if (icoPtr == NULL) { - return TCL_ERROR; - } - } - for (i = optStart; i < objc; i += 2) { - if (Tcl_GetIndexFromObj(interp, objv[i], optStrings, "option", - 0, &opt) == TCL_ERROR) { - return TCL_ERROR; - } - if (i+1 >= objc) { - Tcl_AppendResult(interp, - "missing value for option \"", Tcl_GetString(objv[i]), - "\"", NULL); - return TCL_ERROR; - } - switch (opt) { - case OPT_IMAGE: - imageObj = objv[i+1]; - break; - case OPT_TEXT: - textObj = objv[i+1]; - break; - case OPT_CALLBACK: - callbackObj = objv[i+1]; - break; - } - } - if (cmd == CMD_ADD && imageObj == NULL) { - Tcl_SetObjResult(interp, Tcl_NewStringObj("missing required option \"-image\"", TCL_INDEX_NONE)); - return TCL_ERROR; - } - if (imageObj != NULL) { - Tk_PhotoHandle photo; - int width, height; - Tk_PhotoImageBlock block; - - photo = Tk_FindPhoto(interp, Tcl_GetString(imageObj)); - if (photo == NULL) { - Tcl_SetObjResult(interp, Tcl_ObjPrintf( - "image \"%s\" doesn't exist", Tcl_GetString(imageObj))); - return TCL_ERROR; - } - Tk_PhotoGetSize(photo, &width, &height); - Tk_PhotoGetImage(photo, &block); - hIcon = CreateIcoFromPhoto(width, height, block); - if (hIcon == NULL) { - Tcl_SetObjResult(interp, Tcl_ObjPrintf( - "failed to create an iconphoto with image \"%s\"", Tcl_GetString(imageObj))); - return TCL_ERROR; - } - } - if (cmd == CMD_ADD) { - icoPtr = NewIcon(interp, icoInterpPtr, hIcon); - } else { - if (imageObj != NULL) { - DestroyIcon(icoPtr->hIcon); - icoPtr->hIcon = hIcon; - } - } - if (callbackObj != NULL) { - if (icoPtr->taskbar_command != NULL) { - Tcl_DecrRefCount(icoPtr->taskbar_command); - } - icoPtr->taskbar_command = callbackObj; - Tcl_IncrRefCount(icoPtr->taskbar_command); - } - if (textObj != NULL) { - if (icoPtr->taskbar_txt != NULL) { - Tcl_DecrRefCount(icoPtr->taskbar_txt); - } - icoPtr->taskbar_txt = textObj; - Tcl_IncrRefCount(icoPtr->taskbar_txt); - } - TaskbarOperation(icoInterpPtr, icoPtr, oper); - if (cmd == CMD_ADD) { - char buffer[5 + TCL_INTEGER_SPACE]; - int n; - n = snprintf(buffer, sizeof(buffer) - 1, "ico#%d", icoPtr->id); - buffer[n] = 0; - Tcl_SetObjResult(interp, Tcl_NewStringObj(buffer, n)); - } - return TCL_OK; - } - case CMD_DELETE: - if (objc != 3) { - Tcl_WrongNumArgs(interp, 2, objv, "id"); - return TCL_ERROR; - } - icoPtr = GetIcoPtr(interp, icoInterpPtr, Tcl_GetString(objv[2])); - if (icoPtr == NULL) { - return TCL_ERROR; - } - FreeIcoPtr(icoInterpPtr, icoPtr); - return TCL_OK; + case CMD_ADD: + case CMD_MODIFY: { + Tcl_Obj *imageObj = NULL, *textObj = NULL, *callbackObj = NULL; + int optStart; + int oper; + if (cmd == CMD_ADD) { + optStart = 2; + oper = NIM_ADD; + } else { + optStart = 3; + oper = NIM_MODIFY; + if (objc != 5) { + Tcl_WrongNumArgs(interp, 2, objv, "id option value"); + return TCL_ERROR; + } + icoPtr = GetIcoPtr(interp, icoInterpPtr, Tcl_GetString(objv[2])); + if (icoPtr == NULL) { + return TCL_ERROR; + } + } + for (i = optStart; i < objc; i += 2) { + if (Tcl_GetIndexFromObj(interp, objv[i], optStrings, "option", + 0, &opt) == TCL_ERROR) { + return TCL_ERROR; + } + if (i+1 >= objc) { + Tcl_AppendResult(interp, + "missing value for option \"", Tcl_GetString(objv[i]), + "\"", NULL); + return TCL_ERROR; + } + switch (opt) { + case OPT_IMAGE: + imageObj = objv[i+1]; + break; + case OPT_TEXT: + textObj = objv[i+1]; + break; + case OPT_CALLBACK: + callbackObj = objv[i+1]; + break; + } + } + if (cmd == CMD_ADD && imageObj == NULL) { + Tcl_SetObjResult(interp, Tcl_NewStringObj("missing required option \"-image\"", TCL_INDEX_NONE)); + return TCL_ERROR; + } + if (imageObj != NULL) { + Tk_PhotoHandle photo; + int width, height; + Tk_PhotoImageBlock block; + + photo = Tk_FindPhoto(interp, Tcl_GetString(imageObj)); + if (photo == NULL) { + Tcl_SetObjResult(interp, Tcl_ObjPrintf( + "image \"%s\" doesn't exist", Tcl_GetString(imageObj))); + return TCL_ERROR; + } + Tk_PhotoGetSize(photo, &width, &height); + Tk_PhotoGetImage(photo, &block); + hIcon = CreateIcoFromPhoto(width, height, block); + if (hIcon == NULL) { + Tcl_SetObjResult(interp, Tcl_ObjPrintf( + "failed to create an iconphoto with image \"%s\"", Tcl_GetString(imageObj))); + return TCL_ERROR; + } + } + if (cmd == CMD_ADD) { + icoPtr = NewIcon(interp, icoInterpPtr, hIcon); + } else { + if (imageObj != NULL) { + DestroyIcon(icoPtr->hIcon); + icoPtr->hIcon = hIcon; + } + } + if (callbackObj != NULL) { + if (icoPtr->taskbar_command != NULL) { + Tcl_DecrRefCount(icoPtr->taskbar_command); + } + icoPtr->taskbar_command = callbackObj; + Tcl_IncrRefCount(icoPtr->taskbar_command); + } + if (textObj != NULL) { + if (icoPtr->taskbar_txt != NULL) { + Tcl_DecrRefCount(icoPtr->taskbar_txt); + } + icoPtr->taskbar_txt = textObj; + Tcl_IncrRefCount(icoPtr->taskbar_txt); + } + TaskbarOperation(icoInterpPtr, icoPtr, oper); + if (cmd == CMD_ADD) { + char buffer[5 + TCL_INTEGER_SPACE]; + int n; + n = snprintf(buffer, sizeof(buffer) - 1, "ico#%d", icoPtr->id); + buffer[n] = 0; + Tcl_SetObjResult(interp, Tcl_NewStringObj(buffer, n)); + } + return TCL_OK; + } + case CMD_DELETE: + if (objc != 3) { + Tcl_WrongNumArgs(interp, 2, objv, "id"); + return TCL_ERROR; + } + icoPtr = GetIcoPtr(interp, icoInterpPtr, Tcl_GetString(objv[2])); + if (icoPtr == NULL) { + return TCL_ERROR; + } + FreeIcoPtr(icoInterpPtr, icoPtr); + return TCL_OK; } return TCL_OK; } @@ -1074,22 +1074,22 @@ WinSysNotifyCmd( char *msginfo; if (objc < 2) { - Tcl_WrongNumArgs(interp, 1, objv, "command ..."); - return TCL_ERROR; + Tcl_WrongNumArgs(interp, 1, objv, "command ..."); + return TCL_ERROR; } if (strcmp(Tcl_GetString(objv[1]), "notify") != 0) { - Tcl_AppendResult(interp, "unknown subcommand \"", Tcl_GetString(objv[1]), - "\": must be notify", NULL); - return TCL_ERROR; + Tcl_AppendResult(interp, "unknown subcommand \"", Tcl_GetString(objv[1]), + "\": must be notify", NULL); + return TCL_ERROR; } if (objc != 5) { - Tcl_WrongNumArgs(interp, 2, objv, "id title detail"); - return TCL_ERROR; + Tcl_WrongNumArgs(interp, 2, objv, "id title detail"); + return TCL_ERROR; } icoPtr = GetIcoPtr(interp, icoInterpPtr, Tcl_GetString(objv[2])); if (icoPtr == NULL) { - return TCL_ERROR; + return TCL_ERROR; } ni.cbSize = sizeof(NOTIFYICONDATAW); @@ -1105,18 +1105,18 @@ WinSysNotifyCmd( /* Balloon notification for system tray icon. */ if (msgtitle != NULL) { - WCHAR *title; - Tcl_DStringInit(&titledst); - title = Tcl_UtfToWCharDString(msgtitle, TCL_INDEX_NONE, &titledst); - wcsncpy(ni.szInfoTitle, title, (Tcl_DStringLength(&titledst) + 2) / 2); - Tcl_DStringFree(&titledst); + WCHAR *title; + Tcl_DStringInit(&titledst); + title = Tcl_UtfToWCharDString(msgtitle, TCL_INDEX_NONE, &titledst); + wcsncpy(ni.szInfoTitle, title, (Tcl_DStringLength(&titledst) + 2) / 2); + Tcl_DStringFree(&titledst); } if (msginfo != NULL) { - WCHAR *info; - Tcl_DStringInit(&infodst); - info = Tcl_UtfToWCharDString(msginfo, TCL_INDEX_NONE, &infodst); - wcsncpy(ni.szInfo, info, (Tcl_DStringLength(&infodst) + 2) / 2); - Tcl_DStringFree(&infodst); + WCHAR *info; + Tcl_DStringInit(&infodst); + info = Tcl_UtfToWCharDString(msginfo, TCL_INDEX_NONE, &infodst); + wcsncpy(ni.szInfo, info, (Tcl_DStringLength(&infodst) + 2) / 2); + Tcl_DStringFree(&infodst); } Shell_NotifyIconW(NIM_MODIFY, &ni); @@ -1148,8 +1148,8 @@ WinIcoInit( mainWindow = Tk_MainWindow(interp); if (mainWindow == NULL) { - Tcl_SetObjResult(interp, Tcl_NewStringObj("main window has been destroyed", TCL_INDEX_NONE)); - return TCL_ERROR; + Tcl_SetObjResult(interp, Tcl_NewStringObj("main window has been destroyed", TCL_INDEX_NONE)); + return TCL_ERROR; } icoInterpPtr = (IcoInterpInfo*) ckalloc(sizeof(IcoInterpInfo)); @@ -1159,12 +1159,12 @@ WinIcoInit( icoInterpPtr->nextPtr = firstIcoInterpPtr; firstIcoInterpPtr = icoInterpPtr; Tcl_CreateObjCommand(interp, "::tk::systray::_systray", WinSystrayCmd, - icoInterpPtr, NULL); + icoInterpPtr, NULL); Tcl_CreateObjCommand(interp, "::tk::sysnotify::_sysnotify", WinSysNotifyCmd, - icoInterpPtr, NULL); + icoInterpPtr, NULL); Tk_CreateEventHandler(mainWindow, StructureNotifyMask, - WinIcoDestroy, icoInterpPtr); + WinIcoDestroy, icoInterpPtr); return TCL_OK; } diff --git a/win/tkWinTest.c b/win/tkWinTest.c index 544f89c..4e993af 100644 --- a/win/tkWinTest.c +++ b/win/tkWinTest.c @@ -98,10 +98,10 @@ HWND TestFindControl(HWND root, int id) fcs.control = GetDlgItem(root, id); if (fcs.control == NULL) { - /* Control is not a direct child. Look in descendents */ - fcs.id = id; - fcs.control = NULL; - EnumChildWindows(root, TestFindControlCallback, (LPARAM) &fcs); + /* Control is not a direct child. Look in descendents */ + fcs.id = id; + fcs.control = NULL; + EnumChildWindows(root, TestFindControlCallback, (LPARAM) &fcs); } return fcs.control; } @@ -360,15 +360,15 @@ TestwineventObjCmd( #if 0 GetDlgItemTextA(hwnd, id, buf, 256); #else - control = TestFindControl(hwnd, id); - if (control == NULL) { - Tcl_SetObjResult(interp, - Tcl_ObjPrintf("Could not find control with id %d", id)); - return TCL_ERROR; - } - buf[0] = 0; - SendMessageA(control, WM_GETTEXT, (WPARAM)sizeof(buf), - (LPARAM) buf); + control = TestFindControl(hwnd, id); + if (control == NULL) { + Tcl_SetObjResult(interp, + Tcl_ObjPrintf("Could not find control with id %d", id)); + return TCL_ERROR; + } + buf[0] = 0; + SendMessageA(control, WM_GETTEXT, (WPARAM)sizeof(buf), + (LPARAM) buf); #endif Tcl_AppendResult(interp, Tcl_ExternalToUtfDString(NULL, buf, TCL_INDEX_NONE, &ds), NULL); Tcl_DStringFree(&ds); @@ -443,8 +443,8 @@ TestfindwindowObjCmd( Tcl_DStringInit(&titleString); if (objc < 2 || objc > 3) { - Tcl_WrongNumArgs(interp, 1, objv, "title ?class?"); - return TCL_ERROR; + Tcl_WrongNumArgs(interp, 1, objv, "title ?class?"); + return TCL_ERROR; } Tcl_DStringInit(&titleString); @@ -454,23 +454,23 @@ TestfindwindowObjCmd( windowClass = Tcl_UtfToWCharDString(Tcl_GetString(objv[2]), TCL_INDEX_NONE, &classString); } if (title[0] == 0) - title = NULL; + title = NULL; /* We want find a window the belongs to us and not some other process */ hwnd = NULL; myPid = GetCurrentProcessId(); while (1) { - DWORD pid, tid; - hwnd = FindWindowExW(NULL, hwnd, windowClass, title); - if (hwnd == NULL) - break; - tid = GetWindowThreadProcessId(hwnd, &pid); - if (tid == 0) { - /* Window has gone */ - hwnd = NULL; - break; - } - if (pid == myPid) - break; /* Found it */ + DWORD pid, tid; + hwnd = FindWindowExW(NULL, hwnd, windowClass, title); + if (hwnd == NULL) + break; + tid = GetWindowThreadProcessId(hwnd, &pid); + if (tid == 0) { + /* Window has gone */ + hwnd = NULL; + break; + } + if (pid == myPid) + break; /* Found it */ } if (hwnd == NULL) { @@ -478,7 +478,7 @@ TestfindwindowObjCmd( AppendSystemError(interp, GetLastError()); r = TCL_ERROR; } else { - Tcl_SetObjResult(interp, Tcl_NewWideIntObj(PTR2INT(hwnd))); + Tcl_SetObjResult(interp, Tcl_NewWideIntObj(PTR2INT(hwnd))); } Tcl_DStringFree(&titleString); diff --git a/win/tkWinWm.c b/win/tkWinWm.c index 4ad0056..ba52b32 100644 --- a/win/tkWinWm.c +++ b/win/tkWinWm.c @@ -1436,11 +1436,6 @@ ReadIconOrCursorFromFile( Tcl_Close(NULL, channel); return NULL; } - if (Tcl_SetChannelOption(interp, channel, "-encoding", "binary") - != TCL_OK) { - Tcl_Close(NULL, channel); - return NULL; - } /* * Allocate memory for the resource structure diff --git a/win/tkWinX.c b/win/tkWinX.c index 80407df..656e142 100644 --- a/win/tkWinX.c +++ b/win/tkWinX.c @@ -806,16 +806,16 @@ TkWinChildProc( break; case WM_UNICHAR: - if (wParam == UNICODE_NOCHAR) { + if (wParam == UNICODE_NOCHAR) { /* If wParam is UNICODE_NOCHAR and the application processes * this message, then return TRUE. */ result = 1; } else { /* If the event was translated, we must return 0 */ - if (TkTranslateWinEvent(hwnd, message, wParam, lParam, &result)) { - result = 0; + if (TkTranslateWinEvent(hwnd, message, wParam, lParam, &result)) { + result = 0; } else { - result = 1; + result = 1; } } break; @@ -872,20 +872,20 @@ TkTranslateWinEvent( } case WM_RENDERALLFORMATS: { - TkWindow *winPtr = (TkWindow *) Tk_HWNDToWindow(hwnd); - - if (winPtr && OpenClipboard(hwnd)) { - /* - * Make sure that nobody had taken ownership of the clipboard - * before we opened it. - */ - - if (GetClipboardOwner() == hwnd) { - TkWinClipboardRender(winPtr->dispPtr, CF_TEXT); - } - CloseClipboard(); - } - return 1; + TkWindow *winPtr = (TkWindow *) Tk_HWNDToWindow(hwnd); + + if (winPtr && OpenClipboard(hwnd)) { + /* + * Make sure that nobody had taken ownership of the clipboard + * before we opened it. + */ + + if (GetClipboardOwner() == hwnd) { + TkWinClipboardRender(winPtr->dispPtr, CF_TEXT); + } + CloseClipboard(); + } + return 1; } case WM_COMMAND: @@ -1221,7 +1221,7 @@ GenerateXEvent( event.x.xany.send_event = -1; event.x.xkey.keycode = wParam; GetTranslatedKey(&event.key, (message == WM_KEYDOWN) ? WM_CHAR : - WM_SYSCHAR); + WM_SYSCHAR); break; case WM_SYSKEYUP: @@ -1294,7 +1294,7 @@ GenerateXEvent( MSG msg; if ((PeekMessageW(&msg, NULL, WM_CHAR, WM_CHAR, - PM_NOREMOVE) != 0) + PM_NOREMOVE) != 0) && (msg.message == WM_CHAR)) { GetMessageW(&msg, NULL, WM_CHAR, WM_CHAR); event.key.nbytes = 2; diff --git a/win/ttkWinXPTheme.c b/win/ttkWinXPTheme.c index 463d60d..5b97fad 100644 --- a/win/ttkWinXPTheme.c +++ b/win/ttkWinXPTheme.c @@ -805,7 +805,7 @@ static void TabElementDraw( return; if (nbTabsStickBit == TTK_STICK_S) { - if (state & TTK_STATE_USER1) { + if (state & TTK_STATE_FIRST) { partId = TABP_TABITEMLEFTEDGE; } |