diff options
author | jan.nijtmans <nijtmans@users.sourceforge.net> | 2020-03-24 07:56:41 (GMT) |
---|---|---|
committer | jan.nijtmans <nijtmans@users.sourceforge.net> | 2020-03-24 07:56:41 (GMT) |
commit | bc56730d2abae5198c3667a55729e01684f3cb29 (patch) | |
tree | a67f18bf70f2081877ab48b4aecd142c54848262 /win/tkWinDialog.c | |
parent | abbe37191732849b4d22072a8572f29205025457 (diff) | |
download | tk-bc56730d2abae5198c3667a55729e01684f3cb29.zip tk-bc56730d2abae5198c3667a55729e01684f3cb29.tar.gz tk-bc56730d2abae5198c3667a55729e01684f3cb29.tar.bz2 |
Replace all instances of Tcl_WinTCharToUtf()/Tcl_WinUtfToTChar() with Tcl_UniCharToUtfDString()/Tcl_UtfToUniCharDString(), if possible (only for -DTCL_UTF_MAX=3, which is the default and only supported option)
Backported, as far as possible, from 8.7. This helps moving away from Tcl_WinTCharToUtf()/Tcl_WinUtfToTChar(), even though it only becomes deprecated in 8.7.
Diffstat (limited to 'win/tkWinDialog.c')
-rw-r--r-- | win/tkWinDialog.c | 190 |
1 files changed, 106 insertions, 84 deletions
diff --git a/win/tkWinDialog.c b/win/tkWinDialog.c index ab2f179..3702efa 100644 --- a/win/tkWinDialog.c +++ b/win/tkWinDialog.c @@ -423,7 +423,7 @@ typedef struct IFileSaveDialogVtbl { ULONG ( STDMETHODCALLTYPE *Release )( IFileSaveDialog *); HRESULT ( STDMETHODCALLTYPE *Show )( IFileSaveDialog *, HWND); - HRESULT ( STDMETHODCALLTYPE *SetFileTypes )( IFileSaveDialog * this, + HRESULT ( STDMETHODCALLTYPE *SetFileTypes )( IFileSaveDialog *, UINT, const TCLCOMDLG_FILTERSPEC *); HRESULT ( STDMETHODCALLTYPE *SetFileTypeIndex )( IFileSaveDialog *, UINT); @@ -589,8 +589,7 @@ static UINT APIENTRY OFNHookProc(HWND hdlg, UINT uMsg, WPARAM wParam, LPARAM lParam); static LRESULT CALLBACK MsgBoxCBTProc(int nCode, WPARAM wParam, LPARAM lParam); static void SetTkDialog(ClientData clientData); -static const char *ConvertExternalFilename(WCHAR *filename, - Tcl_DString *dsPtr); +static const char *ConvertExternalFilename(LPCWSTR, Tcl_DString *); static void LoadShellProcs(void); @@ -630,7 +629,7 @@ struct ShellProcPointers { * ShellProcs is populated. *------------------------------------------------------------------------- */ -static void LoadShellProcs() +static void LoadShellProcs(void) { static HMODULE shell32_handle = NULL; @@ -720,7 +719,7 @@ void TkWinDialogDebug( int debug) { - ThreadSpecificData *tsdPtr = + ThreadSpecificData *tsdPtr = (ThreadSpecificData *) Tcl_GetThreadData(&dataKey, sizeof(ThreadSpecificData)); tsdPtr->debugFlag = debug; @@ -752,7 +751,7 @@ Tk_ChooseColorObjCmd( int objc, /* Number of arguments. */ Tcl_Obj *const objv[]) /* Argument objects. */ { - Tk_Window tkwin = clientData, parent; + Tk_Window tkwin = (Tk_Window)clientData, parent; HWND hWnd; int i, oldMode, winCode, result; CHOOSECOLORW chooseColor; @@ -906,10 +905,11 @@ ColorDlgHookProc( WPARAM wParam, /* First message parameter. */ LPARAM lParam) /* Second message parameter. */ { - ThreadSpecificData *tsdPtr = + ThreadSpecificData *tsdPtr = (ThreadSpecificData *) Tcl_GetThreadData(&dataKey, sizeof(ThreadSpecificData)); const char *title; CHOOSECOLOR *ccPtr; + (void)wParam; if (WM_INITDIALOG == uMsg) { @@ -923,7 +923,8 @@ ColorDlgHookProc( if ((title != NULL) && (title[0] != '\0')) { Tcl_DString ds; - SetWindowTextW(hDlg, (LPCWSTR)Tcl_WinUtfToTChar(title,-1,&ds)); + Tcl_DStringInit(&ds); + SetWindowTextW(hDlg, Tcl_UtfToWCharDString(title, -1, &ds)); Tcl_DStringFree(&ds); } if (tsdPtr->debugFlag) { @@ -1086,7 +1087,7 @@ ParseOFNOptions( ZeroMemory(optsPtr, sizeof(*optsPtr)); // optsPtr->forceXPStyle = 1; - optsPtr->tkwin = clientData; + optsPtr->tkwin = (Tk_Window)clientData; optsPtr->confirmOverwrite = 1; /* By default we ask for confirmation */ Tcl_DStringInit(&optsPtr->utfDirString); optsPtr->file[0] = 0; @@ -1147,7 +1148,7 @@ ParseOFNOptions( Tcl_DStringFree(&ds); break; case FILE_PARENT: - optsPtr->tkwin = Tk_NameToWindow(interp, string, clientData); + optsPtr->tkwin = Tk_NameToWindow(interp, string, (Tk_Window)clientData); if (optsPtr->tkwin == NULL) goto error_return; break; @@ -1202,11 +1203,11 @@ error_return: /* interp should already hold error */ * If new dialogs are available, COM is also initialized. *---------------------------------------------------------------------- */ -static int VistaFileDialogsAvailable() +static int VistaFileDialogsAvailable(void) { HRESULT hr; IFileDialog *fdlgPtr = NULL; - ThreadSpecificData *tsdPtr = + ThreadSpecificData *tsdPtr = (ThreadSpecificData *) Tcl_GetThreadData(&dataKey, sizeof(ThreadSpecificData)); if (tsdPtr->newFileDialogsState == FDLG_STATE_INIT) { @@ -1268,7 +1269,7 @@ static int GetFileNameVista(Tcl_Interp *interp, OFNOpts *optsPtr, IShellItem *dirIf = NULL; LPWSTR wstr; Tcl_Obj *resultObj = NULL; - ThreadSpecificData *tsdPtr = + ThreadSpecificData *tsdPtr = (ThreadSpecificData *) Tcl_GetThreadData(&dataKey, sizeof(ThreadSpecificData)); int oldMode; @@ -1372,8 +1373,9 @@ static int GetFileNameVista(Tcl_Interp *interp, OFNOpts *optsPtr, const char *src; src = Tcl_GetString(optsPtr->extObj); - wstr = (LPWSTR) Tcl_WinUtfToTChar(src, optsPtr->extObj->length, &ds); - if (wstr[0] == L'.') + Tcl_DStringInit(&ds); + wstr = Tcl_UtfToWCharDString(src, optsPtr->extObj->length, &ds); + if (wstr[0] == '.') ++wstr; hr = fdlgIf->lpVtbl->SetDefaultExtension(fdlgIf, wstr); Tcl_DStringFree(&ds); @@ -1386,7 +1388,8 @@ static int GetFileNameVista(Tcl_Interp *interp, OFNOpts *optsPtr, const char *src; src = Tcl_GetString(optsPtr->titleObj); - wstr = (LPWSTR) Tcl_WinUtfToTChar(src, optsPtr->titleObj->length, &ds); + Tcl_DStringInit(&ds); + wstr = Tcl_UtfToWCharDString(src, optsPtr->titleObj->length, &ds); hr = fdlgIf->lpVtbl->SetTitle(fdlgIf, wstr); Tcl_DStringFree(&ds); if (FAILED(hr)) @@ -1408,7 +1411,7 @@ static int GetFileNameVista(Tcl_Interp *interp, OFNOpts *optsPtr, if (normPath) { LPCWSTR nativePath; Tcl_IncrRefCount(normPath); - nativePath = Tcl_FSGetNativePath(normPath); /* Points INTO normPath*/ + nativePath = (LPCWSTR)Tcl_FSGetNativePath(normPath); /* Points INTO normPath*/ if (nativePath) { hr = ShellProcs.SHCreateItemFromParsingName( nativePath, NULL, @@ -1512,7 +1515,8 @@ static int GetFileNameVista(Tcl_Interp *interp, OFNOpts *optsPtr, Tcl_DString ftds; Tcl_Obj *ftobj; - Tcl_WinTCharToUtf((LPCTSTR)filterPtr[ftix-1].pszName, -1, &ftds); + 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, @@ -1574,7 +1578,7 @@ static int GetFileNameXP(Tcl_Interp *interp, OFNOpts *optsPtr, enum OFNOper oper Tcl_DString utfFilterString, ds; Tcl_DString extString, filterString, dirString, titleString; const char *str; - ThreadSpecificData *tsdPtr = + ThreadSpecificData *tsdPtr = (ThreadSpecificData *) Tcl_GetThreadData(&dataKey, sizeof(ThreadSpecificData)); ZeroMemory(&ofnData, sizeof(OFNData)); @@ -1619,24 +1623,26 @@ static int GetFileNameXP(Tcl_Interp *interp, OFNOpts *optsPtr, enum OFNOper oper */ ofnData.dynFileBufferSize = 512; - ofnData.dynFileBuffer = ckalloc(512 * sizeof(WCHAR)); + ofnData.dynFileBuffer = (WCHAR *)ckalloc(512 * sizeof(WCHAR)); } if (optsPtr->extObj != NULL) { - str = Tcl_GetString(optsPtr->extObj); - if (str[0] == '.') - ++str; - Tcl_WinUtfToTChar(str, -1, &extString); - ofn.lpstrDefExt = (WCHAR *) Tcl_DStringValue(&extString); + str = Tcl_GetString(optsPtr->extObj); + if (str[0] == '.') { + ++str; + } + Tcl_DStringInit(&extString); + ofn.lpstrDefExt = Tcl_UtfToWCharDString(str, -1, &extString); } - Tcl_WinUtfToTChar(Tcl_DStringValue(&utfFilterString), + Tcl_DStringInit(&filterString); + ofn.lpstrFilter = Tcl_UtfToWCharDString(Tcl_DStringValue(&utfFilterString), Tcl_DStringLength(&utfFilterString), &filterString); - ofn.lpstrFilter = (WCHAR *) Tcl_DStringValue(&filterString); ofn.nFilterIndex = filterIndex; if (Tcl_DStringValue(&optsPtr->utfDirString)[0] != '\0') { - Tcl_WinUtfToTChar(Tcl_DStringValue(&optsPtr->utfDirString), + Tcl_DStringInit(&dirString); + Tcl_UtfToWCharDString(Tcl_DStringValue(&optsPtr->utfDirString), Tcl_DStringLength(&optsPtr->utfDirString), &dirString); } else { /* @@ -1652,7 +1658,8 @@ static int GetFileNameXP(Tcl_Interp *interp, OFNOpts *optsPtr, enum OFNOper oper Tcl_DStringValue(&optsPtr->utfDirString), &cwd) == NULL)) { Tcl_ResetResult(interp); } else { - Tcl_WinUtfToTChar(Tcl_DStringValue(&cwd), + Tcl_DStringInit(&dirString); + Tcl_UtfToWCharDString(Tcl_DStringValue(&cwd), Tcl_DStringLength(&cwd), &dirString); } Tcl_DStringFree(&cwd); @@ -1660,8 +1667,8 @@ static int GetFileNameXP(Tcl_Interp *interp, OFNOpts *optsPtr, enum OFNOper oper ofn.lpstrInitialDir = (WCHAR *) Tcl_DStringValue(&dirString); if (optsPtr->titleObj != NULL) { - Tcl_WinUtfToTChar(Tcl_GetString(optsPtr->titleObj), -1, &titleString); - ofn.lpstrTitle = (WCHAR *) Tcl_DStringValue(&titleString); + Tcl_DStringInit(&titleString); + ofn.lpstrTitle = Tcl_UtfToWCharDString(Tcl_GetString(optsPtr->titleObj), -1, &titleString); } /* @@ -1914,10 +1921,11 @@ OFNHookProc( WPARAM wParam, /* Message parameter */ LPARAM lParam) /* Message parameter */ { - ThreadSpecificData *tsdPtr = + ThreadSpecificData *tsdPtr = (ThreadSpecificData *) Tcl_GetThreadData(&dataKey, sizeof(ThreadSpecificData)); OPENFILENAME *ofnPtr; OFNData *ofnData; + (void)wParam; if (uMsg == WM_INITDIALOG) { TkWinSetUserData(hdlg, lParam); @@ -1962,7 +1970,7 @@ OFNHookProc( if ((selsize > 1) && (dirsize > 0)) { if (ofnData->dynFileBufferSize < buffersize) { - buffer = ckrealloc(buffer, buffersize * sizeof(WCHAR)); + buffer = (WCHAR *)ckrealloc(buffer, buffersize * sizeof(WCHAR)); ofnData->dynFileBufferSize = buffersize; ofnData->dynFileBuffer = buffer; } @@ -2008,7 +2016,7 @@ OFNHookProc( if (TCL_PATH_ABSOLUTE == Tcl_GetPathType(Tcl_DStringValue(&tmpfile))) { /* re-get the full path to the start of the buffer */ - buffer = (WCHAR *) ofnData->dynFileBuffer; + buffer = ofnData->dynFileBuffer; SendMessageW(hdlg, CDM_GETSPEC, selsize, (LPARAM) buffer); } else { *(buffer-1) = '\\'; @@ -2094,7 +2102,7 @@ MakeFilter( */ const char *defaultFilter = "All Files (*.*)"; - p = filterStr = ckalloc(30); + p = filterStr = (char *)ckalloc(30); strcpy(p, defaultFilter); p+= strlen(defaultFilter); @@ -2108,13 +2116,12 @@ MakeFilter( *p = '\0'; } else { - size_t len; + int len; if (valuePtr == NULL) { len = 0; } else { - (void) Tcl_GetString(valuePtr); - len = valuePtr->length; + (void) Tcl_GetStringFromObj(valuePtr, &len); } /* @@ -2131,7 +2138,7 @@ MakeFilter( * twice the size of the string to format the filter */ - filterStr = ckalloc(len * 3); + filterStr = (char *)ckalloc(len * 3); for (filterPtr = flist.filters, p = filterStr; filterPtr; filterPtr = filterPtr->next) { @@ -2284,7 +2291,7 @@ static int MakeFilterVista( Tcl_DStringInit(&ds); Tcl_DStringInit(&patterns); - dlgFilterPtr = ckalloc(flist.numFilters * sizeof(*dlgFilterPtr)); + dlgFilterPtr = (TCLCOMDLG_FILTERSPEC *)ckalloc(flist.numFilters * sizeof(*dlgFilterPtr)); for (i = 0, filterPtr = flist.filters; filterPtr; @@ -2298,10 +2305,11 @@ static int MakeFilterVista( initialIndex = i+1; /* Windows filter indices are 1-based */ /* First stash away the text description of the pattern */ - Tcl_WinUtfToTChar(filterPtr->name, -1, &ds); + Tcl_DStringInit(&ds); + Tcl_UtfToWCharDString(filterPtr->name, -1, &ds); nbytes = Tcl_DStringLength(&ds); /* # bytes, not Unicode chars */ nbytes += sizeof(WCHAR); /* Terminating \0 */ - dlgFilterPtr[i].pszName = ckalloc(nbytes); + dlgFilterPtr[i].pszName = (LPCWSTR)ckalloc(nbytes); memmove((void *) dlgFilterPtr[i].pszName, Tcl_DStringValue(&ds), nbytes); Tcl_DStringFree(&ds); @@ -2326,10 +2334,11 @@ static int MakeFilterVista( } /* Again we need a Unicode form of the string */ - Tcl_WinUtfToTChar(Tcl_DStringValue(&patterns), -1, &ds); + Tcl_DStringInit(&ds); + Tcl_UtfToWCharDString(Tcl_DStringValue(&patterns), -1, &ds); nbytes = Tcl_DStringLength(&ds); /* # bytes, not Unicode chars */ nbytes += sizeof(WCHAR); /* Terminating \0 */ - dlgFilterPtr[i].pszSpec = ckalloc(nbytes); + dlgFilterPtr[i].pszSpec = (LPCWSTR)ckalloc(nbytes); memmove((void *)dlgFilterPtr[i].pszSpec, Tcl_DStringValue(&ds), nbytes); Tcl_DStringFree(&ds); Tcl_DStringSetLength(&patterns, 0); @@ -2425,7 +2434,7 @@ Tk_ChooseDirectoryObjCmd( int objc, /* Number of arguments. */ Tcl_Obj *const objv[]) /* Argument objects. */ { - WCHAR path[MAX_PATH]; + WCHAR path[MAX_PATH]; int oldMode, result; LPCITEMIDLIST pidl; /* Returned by browser */ BROWSEINFOW bInfo; /* Used by browser */ @@ -2462,14 +2471,15 @@ Tk_ChooseDirectoryObjCmd( if (utfDir[0] != '\0') { LPCWSTR uniStr; - Tcl_WinUtfToTChar(Tcl_DStringValue(&ofnOpts.utfDirString), -1, + Tcl_DStringInit(&tempString); + Tcl_UtfToWCharDString(Tcl_DStringValue(&ofnOpts.utfDirString), -1, &tempString); - uniStr = (WCHAR *) Tcl_DStringValue(&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. */ @@ -2494,8 +2504,8 @@ Tk_ChooseDirectoryObjCmd( bInfo.lParam = (LPARAM) &cdCBData; if (ofnOpts.titleObj != NULL) { - bInfo.lpszTitle = (LPCWSTR)Tcl_WinUtfToTChar( - Tcl_GetString(ofnOpts.titleObj), -1, &titleString); + Tcl_DStringInit(&titleString); + bInfo.lpszTitle = Tcl_UtfToWCharDString(Tcl_GetString(ofnOpts.titleObj), -1, &titleString); } else { bInfo.lpszTitle = L"Please choose a directory, then select OK."; } @@ -2619,7 +2629,7 @@ ChooseDirectoryValidateProc( Tcl_DString tempString; Tcl_DString initDirString; WCHAR string[MAX_PATH]; - ThreadSpecificData *tsdPtr = + ThreadSpecificData *tsdPtr = (ThreadSpecificData *) Tcl_GetThreadData(&dataKey, sizeof(ThreadSpecificData)); if (tsdPtr->debugFlag) { @@ -2638,7 +2648,8 @@ ChooseDirectoryValidateProc( * like ~ are converted correctly. */ - Tcl_WinTCharToUtf((LPCTSTR) lParam, -1, &initDirString); + Tcl_DStringInit(&initDirString); + Tcl_WCharToUtfDString((WCHAR *) lParam, wcslen((WCHAR *) lParam), &initDirString); if (Tcl_TranslateFileName(chooseDirSharedData->interp, Tcl_DStringValue(&initDirString), &tempString) == NULL) { /* @@ -2649,12 +2660,11 @@ ChooseDirectoryValidateProc( chooseDirSharedData->retDir[0] = '\0'; return 1; } - Tcl_DStringFree(&initDirString); - Tcl_WinUtfToTChar(Tcl_DStringValue(&tempString), -1, &initDirString); - Tcl_DStringFree(&tempString); - wcsncpy(string, (WCHAR *) Tcl_DStringValue(&initDirString), + Tcl_DStringSetLength(&initDirString, 0); + wcsncpy(string, Tcl_UtfToWCharDString(Tcl_DStringValue(&tempString), -1, &initDirString), MAX_PATH); Tcl_DStringFree(&initDirString); + Tcl_DStringFree(&tempString); if (SetCurrentDirectoryW(string) == 0) { @@ -2735,8 +2745,8 @@ ChooseDirectoryValidateProc( ULONG ulCount, ulAttr; if (SUCCEEDED(psfFolder->lpVtbl->ParseDisplayName( - psfFolder, hwnd, NULL, (WCHAR *) - initDir, &ulCount,&pidlMain,&ulAttr)) + psfFolder, hwnd, NULL, initDir, + &ulCount,&pidlMain,&ulAttr)) && (pidlMain != NULL)) { SendMessageW(hwnd, BFFM_SETSELECTIONW, FALSE, (LPARAM) pidlMain); @@ -2782,7 +2792,7 @@ Tk_MessageBoxObjCmd( int objc, /* Number of arguments. */ Tcl_Obj *const objv[]) /* Argument objects. */ { - Tk_Window tkwin = clientData, parent; + Tk_Window tkwin = (Tk_Window)clientData, parent; HWND hWnd; Tcl_Obj *messageObj, *titleObj, *detailObj, *tmpObj; int defaultBtn, icon, type; @@ -2796,7 +2806,7 @@ Tk_MessageBoxObjCmd( MSG_DEFAULT, MSG_DETAIL, MSG_ICON, MSG_MESSAGE, MSG_PARENT, MSG_TITLE, MSG_TYPE }; - ThreadSpecificData *tsdPtr = + ThreadSpecificData *tsdPtr = (ThreadSpecificData *) Tcl_GetThreadData(&dataKey, sizeof(ThreadSpecificData)); Tcl_DString titleBuf, tmpBuf; LPCWSTR titlePtr, tmpPtr; @@ -2930,10 +2940,12 @@ Tk_MessageBoxObjCmd( tsdPtr->hMsgBoxHook = SetWindowsHookExW(WH_CBT, MsgBoxCBTProc, NULL, GetCurrentThreadId()); src = Tcl_GetString(tmpObj); - tmpPtr = (LPCWSTR)Tcl_WinUtfToTChar(src, tmpObj->length, &tmpBuf); + Tcl_DStringInit(&tmpBuf); + tmpPtr = Tcl_UtfToWCharDString(src, tmpObj->length, &tmpBuf); if (titleObj != NULL) { src = Tcl_GetString(titleObj); - titlePtr = (LPCWSTR)Tcl_WinUtfToTChar(src, titleObj->length, &titleBuf); + Tcl_DStringInit(&titleBuf); + titlePtr = Tcl_UtfToWCharDString(src, titleObj->length, &titleBuf); } else { titlePtr = L""; Tcl_DStringInit(&titleBuf); @@ -2964,7 +2976,7 @@ MsgBoxCBTProc( WPARAM wParam, LPARAM lParam) { - ThreadSpecificData *tsdPtr = + ThreadSpecificData *tsdPtr = (ThreadSpecificData *) Tcl_GetThreadData(&dataKey, sizeof(ThreadSpecificData)); if (nCode == HCBT_CREATEWND) { @@ -3011,7 +3023,7 @@ static void SetTkDialog( ClientData clientData) { - ThreadSpecificData *tsdPtr = + ThreadSpecificData *tsdPtr = (ThreadSpecificData *) Tcl_GetThreadData(&dataKey, sizeof(ThreadSpecificData)); char buf[32]; @@ -3025,12 +3037,13 @@ SetTkDialog( static const char * ConvertExternalFilename( - WCHAR *filename, + LPCWSTR filename, Tcl_DString *dsPtr) { char *p; - Tcl_WinTCharToUtf((LPCTSTR)filename, -1, dsPtr); + Tcl_DStringInit(dsPtr); + Tcl_WCharToUtfDString(filename, wcslen(filename), dsPtr); for (p = Tcl_DStringValue(dsPtr); *p != '\0'; p++) { /* * Change the pathname to the Tcl "normalized" pathname, where back @@ -3067,7 +3080,8 @@ GetFontObj( int pt = 0; resObj = Tcl_NewListObj(0, NULL); - Tcl_WinTCharToUtf((LPCTSTR)plf->lfFaceName, -1, &ds); + Tcl_DStringInit(&ds); + Tcl_WCharToUtfDString(plf->lfFaceName, wcslen(plf->lfFaceName), &ds); Tcl_ListObjAppendElement(NULL, resObj, Tcl_NewStringObj(Tcl_DStringValue(&ds), -1)); Tcl_DStringFree(&ds); @@ -3102,7 +3116,7 @@ ApplyLogfont( Tcl_Obj **objv, **tmpv; Tcl_ListObjGetElements(NULL, cmdObj, &objc, &objv); - tmpv = ckalloc(sizeof(Tcl_Obj *) * (objc + 2)); + tmpv = (Tcl_Obj **)ckalloc(sizeof(Tcl_Obj *) * (objc + 2)); memcpy(tmpv, objv, sizeof(Tcl_Obj *) * objc); tmpv[objc] = GetFontObj(hdc, logfontPtr); TkBackgroundEvalObjv(interp, objc+1, tmpv, TCL_EVAL_GLOBAL); @@ -3140,7 +3154,7 @@ HookProc( CHOOSEFONT *pcf = (CHOOSEFONT *) lParam; HWND hwndCtrl; static HookData *phd = NULL; - ThreadSpecificData *tsdPtr = + ThreadSpecificData *tsdPtr = (ThreadSpecificData *) Tcl_GetThreadData(&dataKey, sizeof(ThreadSpecificData)); if (WM_INITDIALOG == msg && lParam != 0) { @@ -3153,7 +3167,8 @@ HookProc( if (phd->titleObj != NULL) { Tcl_DString title; - Tcl_WinUtfToTChar(Tcl_GetString(phd->titleObj), -1, &title); + Tcl_DStringInit(&title); + Tcl_UtfToWCharDString(Tcl_GetString(phd->titleObj), -1, &title); if (Tcl_DStringLength(&title) > 0) { SetWindowTextW(hwndDlg, (LPCWSTR) Tcl_DStringValue(&title)); } @@ -3282,14 +3297,14 @@ FontchooserConfigureCmd( int objc, Tcl_Obj *const objv[]) { - Tk_Window tkwin = clientData; + Tk_Window tkwin = (Tk_Window)clientData; HookData *hdPtr = NULL; int i, r = TCL_OK; static const char *const optionStrings[] = { "-parent", "-title", "-font", "-command", "-visible", NULL }; - hdPtr = Tcl_GetAssocData(interp, "::tk::fontchooser", NULL); + hdPtr = (HookData *)Tcl_GetAssocData(interp, "::tk::fontchooser", NULL); /* * With no arguments we return all the options in a dict. @@ -3426,14 +3441,16 @@ FontchooserShowCmd( Tcl_Obj *const objv[]) { Tcl_DString ds; - Tk_Window tkwin = clientData, parent; + Tk_Window tkwin = (Tk_Window)clientData, parent; CHOOSEFONTW cf; LOGFONTW lf; HDC hdc; HookData *hdPtr; int r = TCL_OK, oldMode = 0; + (void)objc; + (void)objv; - hdPtr = Tcl_GetAssocData(interp, "::tk::fontchooser", NULL); + hdPtr = (HookData *)Tcl_GetAssocData(interp, "::tk::fontchooser", NULL); parent = tkwin; if (hdPtr->parentObj) { @@ -3470,8 +3487,8 @@ FontchooserShowCmd( } fontPtr = (TkFont *) f; cf.Flags |= CF_INITTOLOGFONTSTRUCT; - Tcl_WinUtfToTChar(fontPtr->fa.family, -1, &ds); - wcsncpy(lf.lfFaceName, (WCHAR *)Tcl_DStringValue(&ds), + Tcl_DStringInit(&ds); + wcsncpy(lf.lfFaceName, Tcl_UtfToWCharDString(fontPtr->fa.family, -1, &ds), LF_FACESIZE-1); Tcl_DStringFree(&ds); lf.lfFaceName[LF_FACESIZE-1] = 0; @@ -3534,12 +3551,15 @@ FontchooserShowCmd( static int FontchooserHideCmd( - ClientData clientData, /* Main window */ + ClientData dummy, /* Main window */ Tcl_Interp *interp, int objc, Tcl_Obj *const objv[]) { - HookData *hdPtr = Tcl_GetAssocData(interp, "::tk::fontchooser", NULL); + HookData *hdPtr = (HookData *)Tcl_GetAssocData(interp, "::tk::fontchooser", NULL); + (void)dummy; + (void)objc; + (void)objv; if (hdPtr->hwnd && IsWindow(hdPtr->hwnd)) { EndDialog(hdPtr->hwnd, 0); @@ -3559,9 +3579,10 @@ FontchooserHideCmd( */ static void -DeleteHookData(ClientData clientData, Tcl_Interp *interp) +DeleteHookData(ClientData clientData, Tcl_Interp *dummy) { - HookData *hdPtr = clientData; + HookData *hdPtr = (HookData *)clientData; + (void)dummy; if (hdPtr->parentObj) { Tcl_DecrRefCount(hdPtr->parentObj); @@ -3598,9 +3619,10 @@ const TkEnsemble tkFontchooserEnsemble[] = { }; int -TkInitFontchooser(Tcl_Interp *interp, ClientData clientData) +TkInitFontchooser(Tcl_Interp *interp, ClientData dummy) { - HookData *hdPtr = ckalloc(sizeof(HookData)); + HookData *hdPtr = (HookData *)ckalloc(sizeof(HookData)); + (void)dummy; memset(hdPtr, 0, sizeof(HookData)); Tcl_SetAssocData(interp, "::tk::fontchooser", DeleteHookData, hdPtr); |