Many hyperlinks are disabled.
Use anonymous login
to enable hyperlinks.
Overview
Comment: | Move scrollbar sanity checks from platform-code to generic. Fix indenting in win/* files |
---|---|
Downloads: | Tarball | ZIP archive | SQL archive |
Timelines: | family | ancestors | descendants | both | core-8-branch |
Files: | files | file ages | folders |
SHA3-256: |
0970c95e9b7e2523d8062ec69dfc1e7c |
User & Date: | jan.nijtmans 2024-06-17 13:02:57 |
Context
2024-06-17
| ||
13:14 | "less than 0" -> negative, as everywhere else in the documentation check-in: f5dedd94 user: jan.nijtmans tags: core-8-branch | |
13:02 | Move scrollbar sanity checks from platform-code to generic. Fix indenting in win/* files check-in: 0970c95e user: jan.nijtmans tags: core-8-branch | |
10:06 | Change the -elementborderwidth default (for scrollbar) from -1 to {}. Move sanity check from platform-code to generic. See TIP #577. check-in: c3c84c82 user: jan.nijtmans tags: trunk, main | |
2024-06-16
| ||
22:32 | Unintentional change in tk.h check-in: 2ec0342d user: jan.nijtmans tags: core-8-branch | |
Changes
Changes to generic/tkScrollbar.c.
︙ | ︙ | |||
540 541 542 543 544 545 546 547 548 549 550 551 552 553 | * from a 3-D border. */ if (scrollPtr->command != NULL) { scrollPtr->commandSize = (int) strlen(scrollPtr->command); } else { scrollPtr->commandSize = 0; } /* * Configure platform specific options. */ TkpConfigureScrollbar(scrollPtr); | > > > > > > | 540 541 542 543 544 545 546 547 548 549 550 551 552 553 554 555 556 557 558 559 | * from a 3-D border. */ if (scrollPtr->command != NULL) { scrollPtr->commandSize = (int) strlen(scrollPtr->command); } else { scrollPtr->commandSize = 0; } if (scrollPtr->highlightWidth < 0) { scrollPtr->highlightWidth = 0; } if (scrollPtr->elementBorderWidth < 0) { scrollPtr->elementBorderWidth = -1; } /* * Configure platform specific options. */ TkpConfigureScrollbar(scrollPtr); |
︙ | ︙ |
Changes to macosx/tkMacOSXScrlbr.c.
︙ | ︙ | |||
645 646 647 648 649 650 651 | msPtr->info.value = factor * scrollPtr->firstFraction; } if ((scrollPtr->firstFraction <= 0.0 && scrollPtr->lastFraction >= 1.0) || height <= metrics.minHeight) { msPtr->info.enableState = kThemeTrackHideTrack; } else { | | | | 645 646 647 648 649 650 651 652 653 654 655 656 657 658 659 660 | msPtr->info.value = factor * scrollPtr->firstFraction; } if ((scrollPtr->firstFraction <= 0.0 && scrollPtr->lastFraction >= 1.0) || height <= metrics.minHeight) { msPtr->info.enableState = kThemeTrackHideTrack; } else { msPtr->info.enableState = kThemeTrackActive; msPtr->info.attributes = kThemeTrackShowThumb | kThemeTrackThumbRgnIsNotGhost; } } /* *-------------------------------------------------------------- * |
︙ | ︙ |
Changes to unix/tkUnixScrlbr.c.
︙ | ︙ | |||
279 280 281 282 283 284 285 | TkpComputeScrollbarGeometry( TkScrollbar *scrollPtr) /* Scrollbar whose geometry may have * changed. */ { int width, fieldLength; | < < < | 279 280 281 282 283 284 285 286 287 288 289 290 291 292 | TkpComputeScrollbarGeometry( TkScrollbar *scrollPtr) /* Scrollbar whose geometry may have * changed. */ { int width, fieldLength; scrollPtr->inset = scrollPtr->highlightWidth + scrollPtr->borderWidth; width = (scrollPtr->vertical) ? Tk_Width(scrollPtr->tkwin) : Tk_Height(scrollPtr->tkwin); /* * Next line assumes that the arrow area is a square. */ |
︙ | ︙ |
Changes to win/nmakehlp.c.
︙ | ︙ | |||
87 88 89 90 91 92 93 | SetEnvironmentVariable("LINK", ""); if (argc > 1 && *argv[1] == '-') { switch (*(argv[1]+1)) { case 'c': if (argc != 3) { chars = snprintf(msg, sizeof(msg) - 1, | | | 87 88 89 90 91 92 93 94 95 96 97 98 99 100 101 | SetEnvironmentVariable("LINK", ""); if (argc > 1 && *argv[1] == '-') { switch (*(argv[1]+1)) { case 'c': if (argc != 3) { chars = snprintf(msg, sizeof(msg) - 1, "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, &dwWritten, NULL); return 2; } return CheckForCompilerFeature(argv[2]); |
︙ | ︙ | |||
315 316 317 318 319 320 321 | /* * Look for the commandline warning code in both streams. * - in MSVC 6 & 7 we get D4002, in MSVC 8 we get D9002. */ return !(strstr(Out.buffer, "D4002") != NULL | | | | | | | 315 316 317 318 319 320 321 322 323 324 325 326 327 328 329 330 331 332 333 | /* * Look for the commandline warning code in both streams. * - in MSVC 6 & 7 we get D4002, in MSVC 8 we get D9002. */ 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); } static int CheckForLinkerFeature( char **options, int count) { |
︙ | ︙ |
Changes to win/tkWinClipboard.c.
︙ | ︙ | |||
56 57 58 59 60 61 62 | int result, locale, noBackslash = 0; if ((selection != Tk_InternAtom(tkwin, "CLIPBOARD")) || (target != XA_STRING)) { goto error; } if (!OpenClipboard(NULL)) { | | | | | | 56 57 58 59 60 61 62 63 64 65 66 67 68 69 70 71 72 73 | int result, locale, noBackslash = 0; if ((selection != Tk_InternAtom(tkwin, "CLIPBOARD")) || (target != XA_STRING)) { 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; } /* * Attempt to get the data in Unicode form if available as this is less * work that CF_TEXT. */ |
︙ | ︙ |
Changes to win/tkWinDialog.c.
︙ | ︙ | |||
173 174 175 176 177 178 179 | Tcl_Obj *initialTypeObj; /* Initial value of above, or NULL */ Tcl_DString utfDirString; /* Initial dir */ int multi; /* Multiple selection enabled */ int confirmOverwrite; /* Confirm before overwriting */ int mustExist; /* Used only for */ int forceXPStyle; /* XXX - Force XP style even on newer systems */ WCHAR file[TK_MULTI_MAX_PATH]; /* File name | | | | | 173 174 175 176 177 178 179 180 181 182 183 184 185 186 187 188 189 | Tcl_Obj *initialTypeObj; /* Initial value of above, or NULL */ Tcl_DString utfDirString; /* Initial dir */ int multi; /* Multiple selection enabled */ int confirmOverwrite; /* Confirm before overwriting */ 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 ? */ } OFNOpts; /* Define the operation for which option parsing is to be done. */ enum OFNOper { OFN_FILE_SAVE, /* tk_getOpenFile */ OFN_FILE_OPEN, /* tk_getSaveFile */ OFN_DIR_CHOOSE /* tk_chooseDirectory */ |
︙ | ︙ | |||
250 251 252 253 254 255 256 | #endif /* __MSVCRT__ */ typedef struct IShellItemArray IShellItemArray; typedef struct IShellItemArrayVtbl { BEGIN_INTERFACE HRESULT ( STDMETHODCALLTYPE *QueryInterface )( | | | | | | | | | | 250 251 252 253 254 255 256 257 258 259 260 261 262 263 264 265 266 267 268 269 270 271 272 273 274 275 276 277 278 279 280 281 282 283 | #endif /* __MSVCRT__ */ typedef struct IShellItemArray IShellItemArray; typedef struct IShellItemArrayVtbl { BEGIN_INTERFACE HRESULT ( STDMETHODCALLTYPE *QueryInterface )( IShellItemArray *, REFIID riid,void **ppvObject); ULONG ( STDMETHODCALLTYPE *AddRef )(IShellItemArray *); ULONG ( STDMETHODCALLTYPE *Release )(IShellItemArray *); HRESULT ( STDMETHODCALLTYPE *BindToHandler )(IShellItemArray *, IBindCtx *, REFGUID, REFIID, void **); /* flags is actually is enum GETPROPERTYSTOREFLAGS */ HRESULT ( STDMETHODCALLTYPE *GetPropertyStore )( IShellItemArray *, int, REFIID, void **); /* keyType actually REFPROPERTYKEY */ HRESULT ( STDMETHODCALLTYPE *GetPropertyDescriptionList )( IShellItemArray *, void *, REFIID, void **); HRESULT ( STDMETHODCALLTYPE *GetAttributes )(IShellItemArray *, SIATTRIBFLAGS, SFGAOF, SFGAOF *); HRESULT ( STDMETHODCALLTYPE *GetCount )( IShellItemArray *, DWORD *); HRESULT ( STDMETHODCALLTYPE *GetItemAt )( IShellItemArray *, DWORD, IShellItem **); /* ppenumShellItems actually (IEnumShellItems **) */ HRESULT ( STDMETHODCALLTYPE *EnumItems )( IShellItemArray *, void **); END_INTERFACE } IShellItemArrayVtbl; struct IShellItemArray { CONST_VTBL struct IShellItemArrayVtbl *lpVtbl; }; |
︙ | ︙ | |||
350 351 352 353 354 355 356 | typedef struct IFileDialog IFileDialog; typedef struct IFileDialogVtbl { BEGIN_INTERFACE HRESULT ( STDMETHODCALLTYPE *QueryInterface )( | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | 350 351 352 353 354 355 356 357 358 359 360 361 362 363 364 365 366 367 368 369 370 371 372 373 374 375 376 377 378 379 380 381 382 383 384 385 386 387 388 389 390 391 392 393 394 395 396 397 398 399 400 401 402 403 404 405 406 407 408 409 410 411 412 413 414 415 416 417 418 419 420 421 422 423 424 425 426 427 428 429 430 431 432 433 434 435 436 437 438 439 440 441 442 443 444 445 446 447 448 449 450 451 452 453 454 455 456 457 458 459 460 461 462 463 464 465 466 467 468 469 470 471 472 473 474 475 476 477 478 479 480 481 482 483 484 485 486 487 488 489 490 491 492 493 494 495 496 497 498 499 500 501 502 503 504 505 506 507 508 509 510 511 512 513 514 515 516 517 518 519 520 521 522 523 524 525 526 527 528 529 530 531 532 533 534 535 536 537 538 539 540 541 542 543 544 545 546 547 548 549 550 551 552 553 554 555 556 557 | typedef struct IFileDialog IFileDialog; typedef struct IFileDialogVtbl { BEGIN_INTERFACE HRESULT ( STDMETHODCALLTYPE *QueryInterface )( IFileDialog *, REFIID, void **); ULONG ( STDMETHODCALLTYPE *AddRef )( IFileDialog *); ULONG ( STDMETHODCALLTYPE *Release )( IFileDialog *); HRESULT ( STDMETHODCALLTYPE *Show )( IFileDialog *, HWND); HRESULT ( STDMETHODCALLTYPE *SetFileTypes )( IFileDialog *, 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 *); HRESULT ( STDMETHODCALLTYPE *Unadvise )(IFileDialog *, DWORD); HRESULT ( STDMETHODCALLTYPE *SetOptions )( IFileDialog *, FILEOPENDIALOGOPTIONS); HRESULT ( STDMETHODCALLTYPE *GetOptions )( IFileDialog *, FILEOPENDIALOGOPTIONS *); HRESULT ( STDMETHODCALLTYPE *SetDefaultFolder )( IFileDialog *, IShellItem *); HRESULT ( STDMETHODCALLTYPE *SetFolder )( IFileDialog *, IShellItem *); HRESULT ( STDMETHODCALLTYPE *GetFolder )( IFileDialog *, IShellItem **); HRESULT ( STDMETHODCALLTYPE *GetCurrentSelection )( IFileDialog *, IShellItem **); HRESULT ( STDMETHODCALLTYPE *SetFileName )( IFileDialog *, LPCWSTR); HRESULT ( STDMETHODCALLTYPE *GetFileName )( IFileDialog *, LPWSTR *); HRESULT ( STDMETHODCALLTYPE *SetTitle )( IFileDialog *, LPCWSTR); HRESULT ( STDMETHODCALLTYPE *SetOkButtonLabel )( IFileDialog *, LPCWSTR); HRESULT ( STDMETHODCALLTYPE *SetFileNameLabel )( IFileDialog *, LPCWSTR); HRESULT ( STDMETHODCALLTYPE *GetResult )( IFileDialog *, IShellItem **); HRESULT ( STDMETHODCALLTYPE *AddPlace )( IFileDialog *, IShellItem *, FDAP); HRESULT ( STDMETHODCALLTYPE *SetDefaultExtension )( IFileDialog *, LPCWSTR); HRESULT ( STDMETHODCALLTYPE *Close )( IFileDialog *, HRESULT); HRESULT ( STDMETHODCALLTYPE *SetClientGuid )( 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 *); END_INTERFACE } IFileDialogVtbl; struct IFileDialog { CONST_VTBL struct IFileDialogVtbl *lpVtbl; }; typedef struct IFileSaveDialog IFileSaveDialog; typedef struct IFileSaveDialogVtbl { BEGIN_INTERFACE HRESULT ( STDMETHODCALLTYPE *QueryInterface )( IFileSaveDialog *, REFIID, void **); ULONG ( STDMETHODCALLTYPE *AddRef )( IFileSaveDialog *); ULONG ( STDMETHODCALLTYPE *Release )( IFileSaveDialog *); HRESULT ( STDMETHODCALLTYPE *Show )( IFileSaveDialog *, HWND); HRESULT ( STDMETHODCALLTYPE *SetFileTypes )( IFileSaveDialog *, UINT, const TCLCOMDLG_FILTERSPEC *); HRESULT ( STDMETHODCALLTYPE *SetFileTypeIndex )( IFileSaveDialog *, UINT); HRESULT ( STDMETHODCALLTYPE *GetFileTypeIndex )( IFileSaveDialog *, UINT *); /* Actually pfde is IFileSaveDialogEvents* */ HRESULT ( STDMETHODCALLTYPE *Advise )( IFileSaveDialog *, void *, DWORD *); HRESULT ( STDMETHODCALLTYPE *Unadvise )( IFileSaveDialog *, DWORD); HRESULT ( STDMETHODCALLTYPE *SetOptions )( IFileSaveDialog *, FILEOPENDIALOGOPTIONS); HRESULT ( STDMETHODCALLTYPE *GetOptions )( IFileSaveDialog *, FILEOPENDIALOGOPTIONS *); HRESULT ( STDMETHODCALLTYPE *SetDefaultFolder )( IFileSaveDialog *, IShellItem *); HRESULT ( STDMETHODCALLTYPE *SetFolder )( IFileSaveDialog *, IShellItem *); HRESULT ( STDMETHODCALLTYPE *GetFolder )( IFileSaveDialog *, IShellItem **); HRESULT ( STDMETHODCALLTYPE *GetCurrentSelection )( IFileSaveDialog *, IShellItem **); HRESULT ( STDMETHODCALLTYPE *SetFileName )( IFileSaveDialog *, LPCWSTR); HRESULT ( STDMETHODCALLTYPE *GetFileName )( IFileSaveDialog *, LPWSTR *); HRESULT ( STDMETHODCALLTYPE *SetTitle )( IFileSaveDialog *, LPCWSTR); HRESULT ( STDMETHODCALLTYPE *SetOkButtonLabel )( IFileSaveDialog *, LPCWSTR); HRESULT ( STDMETHODCALLTYPE *SetFileNameLabel )( IFileSaveDialog *, LPCWSTR); HRESULT ( STDMETHODCALLTYPE *GetResult )( IFileSaveDialog *, IShellItem **); HRESULT ( STDMETHODCALLTYPE *AddPlace )( IFileSaveDialog *, IShellItem *, FDAP); HRESULT ( STDMETHODCALLTYPE *SetDefaultExtension )( IFileSaveDialog *, LPCWSTR); HRESULT ( STDMETHODCALLTYPE *Close )( IFileSaveDialog *, HRESULT); HRESULT ( STDMETHODCALLTYPE *SetClientGuid )( IFileSaveDialog *, REFGUID); HRESULT ( STDMETHODCALLTYPE *ClearClientData )( IFileSaveDialog *); /* pFilter Actually IShellItemFilter* */ HRESULT ( STDMETHODCALLTYPE *SetFilter )( IFileSaveDialog *, void *); HRESULT ( STDMETHODCALLTYPE *SetSaveAsItem )( IFileSaveDialog *, IShellItem *); HRESULT ( STDMETHODCALLTYPE *SetProperties )( IFileSaveDialog *, IPropertyStore *); HRESULT ( STDMETHODCALLTYPE *SetCollectedProperties )( IFileSaveDialog *, IPropertyDescriptionList *, BOOL); HRESULT ( STDMETHODCALLTYPE *GetProperties )( IFileSaveDialog *, IPropertyStore **); HRESULT ( STDMETHODCALLTYPE *ApplyProperties )( IFileSaveDialog *, IShellItem *, IPropertyStore *, HWND, IFileOperationProgressSink *); END_INTERFACE } IFileSaveDialogVtbl; struct IFileSaveDialog { CONST_VTBL struct IFileSaveDialogVtbl *lpVtbl; }; typedef struct IFileOpenDialog IFileOpenDialog; typedef struct IFileOpenDialogVtbl { BEGIN_INTERFACE HRESULT ( STDMETHODCALLTYPE *QueryInterface )( IFileOpenDialog *, REFIID, void **); ULONG ( STDMETHODCALLTYPE *AddRef )( IFileOpenDialog *); ULONG ( STDMETHODCALLTYPE *Release )( IFileOpenDialog *); HRESULT ( STDMETHODCALLTYPE *Show )( IFileOpenDialog *, HWND); HRESULT ( STDMETHODCALLTYPE *SetFileTypes )( IFileOpenDialog *, UINT, const TCLCOMDLG_FILTERSPEC *); HRESULT ( STDMETHODCALLTYPE *SetFileTypeIndex )( IFileOpenDialog *, UINT); HRESULT ( STDMETHODCALLTYPE *GetFileTypeIndex )( IFileOpenDialog *, UINT *); /* Actually pfde is IFileDialogEvents* */ HRESULT ( STDMETHODCALLTYPE *Advise )( IFileOpenDialog *, void *, DWORD *); HRESULT ( STDMETHODCALLTYPE *Unadvise )( IFileOpenDialog *, DWORD); HRESULT ( STDMETHODCALLTYPE *SetOptions )( IFileOpenDialog *, FILEOPENDIALOGOPTIONS); HRESULT ( STDMETHODCALLTYPE *GetOptions )( IFileOpenDialog *, FILEOPENDIALOGOPTIONS *); HRESULT ( STDMETHODCALLTYPE *SetDefaultFolder )( IFileOpenDialog *, IShellItem *); HRESULT ( STDMETHODCALLTYPE *SetFolder )( IFileOpenDialog *, IShellItem *); HRESULT ( STDMETHODCALLTYPE *GetFolder )( IFileOpenDialog *, IShellItem **); HRESULT ( STDMETHODCALLTYPE *GetCurrentSelection )( IFileOpenDialog *, IShellItem **); HRESULT ( STDMETHODCALLTYPE *SetFileName )( IFileOpenDialog *, LPCWSTR); HRESULT ( STDMETHODCALLTYPE *GetFileName )( IFileOpenDialog *, LPWSTR *); HRESULT ( STDMETHODCALLTYPE *SetTitle )( IFileOpenDialog *, LPCWSTR); HRESULT ( STDMETHODCALLTYPE *SetOkButtonLabel )( IFileOpenDialog *, LPCWSTR); HRESULT ( STDMETHODCALLTYPE *SetFileNameLabel )( IFileOpenDialog *, LPCWSTR); HRESULT ( STDMETHODCALLTYPE *GetResult )( IFileOpenDialog *, IShellItem **); HRESULT ( STDMETHODCALLTYPE *AddPlace )( IFileOpenDialog *, IShellItem *, FDAP); HRESULT ( STDMETHODCALLTYPE *SetDefaultExtension )( IFileOpenDialog *, LPCWSTR); HRESULT ( STDMETHODCALLTYPE *Close )( IFileOpenDialog *, HRESULT); HRESULT ( STDMETHODCALLTYPE *SetClientGuid )( IFileOpenDialog *, REFGUID); HRESULT ( STDMETHODCALLTYPE *ClearClientData )( IFileOpenDialog *); HRESULT ( STDMETHODCALLTYPE *SetFilter )( IFileOpenDialog *, /* pFilter is actually IShellItemFilter */ void *); HRESULT ( STDMETHODCALLTYPE *GetResults )( IFileOpenDialog *, IShellItemArray **); HRESULT ( STDMETHODCALLTYPE *GetSelectedItems )( IFileOpenDialog *, IShellItemArray **); END_INTERFACE } IFileOpenDialogVtbl; struct IFileOpenDialog { CONST_VTBL struct IFileOpenDialogVtbl *lpVtbl; |
︙ | ︙ | |||
565 566 567 568 569 570 571 | static UINT APIENTRY ChooseDirectoryValidateProc(HWND hdlg, UINT uMsg, LPARAM wParam, LPARAM lParam); static UINT CALLBACK ColorDlgHookProc(HWND hDlg, UINT uMsg, WPARAM wParam, LPARAM lParam); static void CleanupOFNOptions(OFNOpts *optsPtr); static int ParseOFNOptions(void *clientData, | | | | | | | | | | 565 566 567 568 569 570 571 572 573 574 575 576 577 578 579 580 581 582 583 584 585 586 587 588 589 590 | static UINT APIENTRY ChooseDirectoryValidateProc(HWND hdlg, UINT uMsg, LPARAM wParam, LPARAM lParam); 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); static int GetFileNameXP(Tcl_Interp *interp, OFNOpts *optsPtr, enum OFNOper oper); static int GetFileNameVista(Tcl_Interp *interp, OFNOpts *optsPtr, enum OFNOper oper); static int GetFileName(void *clientData, 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); static void FreeFilterVista(DWORD count, TCLCOMDLG_FILTERSPEC *dlgFilterPtr); static int MakeFilter(Tcl_Interp *interp, Tcl_Obj *valuePtr, Tcl_DString *dsPtr, Tcl_Obj *initialPtr, int *indexPtr); static UINT APIENTRY OFNHookProc(HWND hdlg, UINT uMsg, WPARAM wParam, LPARAM lParam); static LRESULT CALLBACK MsgBoxCBTProc(int nCode, WPARAM wParam, LPARAM lParam); |
︙ | ︙ | |||
980 981 982 983 984 985 986 | OFNOpts *optsPtr) /* Output, uninitialized on entry */ { int i; Tcl_DString ds; enum options { FILE_DEFAULT, FILE_TYPES, FILE_INITDIR, FILE_INITFILE, FILE_PARENT, FILE_TITLE, FILE_TYPEVARIABLE, FILE_MULTIPLE, FILE_CONFIRMOW, | | | 980 981 982 983 984 985 986 987 988 989 990 991 992 993 994 | OFNOpts *optsPtr) /* Output, uninitialized on entry */ { int i; Tcl_DString ds; enum options { FILE_DEFAULT, FILE_TYPES, FILE_INITDIR, FILE_INITFILE, FILE_PARENT, FILE_TITLE, FILE_TYPEVARIABLE, FILE_MULTIPLE, FILE_CONFIRMOW, FILE_MUSTEXIST, }; struct Options { const char *name; enum options value; }; static const struct Options saveOptions[] = { {"-confirmoverwrite", FILE_CONFIRMOW}, |
︙ | ︙ | |||
1038 1039 1040 1041 1042 1043 1044 | for (i = 1; i < objc; i += 2) { int index; const char *string; Tcl_Obj *valuePtr; if (Tcl_GetIndexFromObjStruct(interp, objv[i], options, sizeof(struct Options), "option", 0, &index) != TCL_OK) { | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | 1038 1039 1040 1041 1042 1043 1044 1045 1046 1047 1048 1049 1050 1051 1052 1053 1054 1055 1056 1057 1058 1059 1060 1061 1062 1063 1064 1065 1066 1067 1068 1069 1070 1071 1072 1073 1074 1075 1076 1077 1078 1079 1080 1081 1082 1083 1084 1085 1086 1087 1088 1089 1090 1091 1092 1093 1094 1095 1096 1097 1098 1099 1100 1101 1102 1103 1104 1105 1106 1107 1108 1109 1110 1111 1112 1113 1114 1115 1116 1117 1118 1119 1120 1121 1122 1123 1124 1125 1126 1127 | for (i = 1; i < objc; i += 2) { int index; const char *string; Tcl_Obj *valuePtr; 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; } if (Tcl_GetBooleanFromObj(interp, objv[i+1], &optsPtr->forceXPStyle) != TCL_OK) goto error_return; 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; } valuePtr = objv[i + 1]; string = Tcl_GetString(valuePtr); switch (options[index].value) { case FILE_DEFAULT: optsPtr->extObj = valuePtr; break; case FILE_TYPES: optsPtr->filterObj = valuePtr; break; case FILE_INITDIR: Tcl_DStringFree(&optsPtr->utfDirString); if (Tcl_TranslateFileName(interp, string, &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_DStringFree(&ds); break; case FILE_PARENT: optsPtr->tkwin = Tk_NameToWindow(interp, string, (Tk_Window)clientData); if (optsPtr->tkwin == NULL) goto error_return; break; case FILE_TITLE: optsPtr->titleObj = valuePtr; break; case FILE_TYPEVARIABLE: optsPtr->typeVariableObj = valuePtr; optsPtr->initialTypeObj = Tcl_ObjGetVar2(interp, valuePtr, NULL, TCL_GLOBAL_ONLY); break; case FILE_MULTIPLE: if (Tcl_GetBooleanFromObj(interp, valuePtr, &optsPtr->multi) != TCL_OK) goto error_return; break; case FILE_CONFIRMOW: if (Tcl_GetBooleanFromObj(interp, valuePtr, &optsPtr->confirmOverwrite) != TCL_OK) goto error_return; break; case FILE_MUSTEXIST: if (Tcl_GetBooleanFromObj(interp, valuePtr, &optsPtr->mustExist) != TCL_OK) goto error_return; break; } } return TCL_OK; error_return: /* interp should already hold error */ /* On error, we need to clean up anything we might have allocated */ |
︙ | ︙ | |||
1147 1148 1149 1150 1151 1152 1153 | *---------------------------------------------------------------------- */ static int VistaFileDialogsAvailable(void) { HRESULT hr; IFileDialog *fdlgPtr = NULL; ThreadSpecificData *tsdPtr = (ThreadSpecificData *) | | | 1147 1148 1149 1150 1151 1152 1153 1154 1155 1156 1157 1158 1159 1160 1161 | *---------------------------------------------------------------------- */ static int VistaFileDialogsAvailable(void) { HRESULT hr; IFileDialog *fdlgPtr = NULL; ThreadSpecificData *tsdPtr = (ThreadSpecificData *) Tcl_GetThreadData(&dataKey, sizeof(ThreadSpecificData)); if (tsdPtr->newFileDialogsState == FDLG_STATE_INIT) { tsdPtr->newFileDialogsState = FDLG_STATE_USE_OLD; hr = CoInitialize(0); /* XXX - need we schedule CoUninitialize at thread shutdown ? */ /* Ensure all COM interfaces we use are available */ |
︙ | ︙ | |||
1194 1195 1196 1197 1198 1199 1200 | * TCL_ERROR - error return * * Side effects: * Dialogs is displayed *---------------------------------------------------------------------- */ static int GetFileNameVista(Tcl_Interp *interp, OFNOpts *optsPtr, | | | 1194 1195 1196 1197 1198 1199 1200 1201 1202 1203 1204 1205 1206 1207 1208 | * TCL_ERROR - error return * * Side effects: * Dialogs is displayed *---------------------------------------------------------------------- */ static int GetFileNameVista(Tcl_Interp *interp, OFNOpts *optsPtr, enum OFNOper oper) { HRESULT hr; HWND hWnd; DWORD flags, nfilters, defaultFilterIndex; TCLCOMDLG_FILTERSPEC *filterPtr = NULL; IFileDialog *fdlgIf = NULL; IShellItem *dirIf = NULL; |
︙ | ︙ | |||
1228 1229 1230 1231 1232 1233 1234 | hWnd = Tk_GetHWND(Tk_WindowId(optsPtr->tkwin)); /* * The only validation we need to do w.r.t caller supplied data * is the filter specification so do that before creating */ if (MakeFilterVista(interp, optsPtr, &nfilters, &filterPtr, | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | 1228 1229 1230 1231 1232 1233 1234 1235 1236 1237 1238 1239 1240 1241 1242 1243 1244 1245 1246 1247 1248 1249 1250 1251 1252 1253 1254 1255 1256 1257 1258 1259 1260 1261 1262 1263 1264 1265 1266 1267 1268 1269 1270 1271 1272 1273 1274 1275 1276 1277 1278 1279 1280 1281 1282 1283 1284 1285 1286 1287 1288 1289 1290 1291 1292 1293 1294 1295 1296 1297 1298 1299 1300 1301 1302 1303 1304 1305 1306 1307 1308 1309 1310 1311 1312 1313 1314 1315 1316 1317 1318 1319 1320 1321 1322 1323 1324 1325 1326 1327 1328 1329 1330 1331 1332 1333 1334 1335 1336 1337 1338 1339 1340 1341 1342 1343 1344 1345 1346 1347 1348 1349 1350 1351 1352 1353 1354 1355 1356 1357 1358 1359 1360 1361 1362 1363 1364 1365 1366 1367 1368 1369 1370 1371 1372 1373 1374 1375 1376 1377 1378 1379 1380 1381 1382 1383 1384 1385 1386 1387 1388 1389 1390 1391 1392 1393 1394 1395 1396 1397 1398 1399 1400 1401 1402 1403 1404 1405 1406 1407 1408 1409 1410 1411 1412 1413 1414 1415 1416 1417 1418 1419 1420 1421 1422 1423 1424 1425 1426 1427 1428 1429 1430 1431 1432 1433 1434 1435 1436 1437 1438 1439 1440 1441 1442 1443 1444 1445 1446 1447 1448 1449 1450 1451 1452 1453 1454 1455 1456 1457 1458 1459 1460 1461 1462 1463 1464 1465 1466 1467 1468 1469 1470 1471 1472 1473 1474 1475 1476 1477 1478 1479 1480 1481 1482 1483 1484 1485 1486 1487 1488 1489 1490 1491 1492 1493 1494 1495 1496 1497 | hWnd = Tk_GetHWND(Tk_WindowId(optsPtr->tkwin)); /* * The only validation we need to do w.r.t caller supplied data * is the filter specification so do that before creating */ if (MakeFilterVista(interp, optsPtr, &nfilters, &filterPtr, &defaultFilterIndex) != TCL_OK) return TCL_ERROR; /* * Beyond this point, do not just return on error as there will be * resources that need to be released/freed. */ if (oper == OFN_FILE_OPEN || oper == OFN_DIR_CHOOSE) hr = CoCreateInstance(&ClsidFileOpenDialog, NULL, CLSCTX_INPROC_SERVER, &IIDIFileOpenDialog, (void **) &fdlgIf); else hr = CoCreateInstance(&ClsidFileSaveDialog, NULL, CLSCTX_INPROC_SERVER, &IIDIFileSaveDialog, (void **) &fdlgIf); if (FAILED(hr)) goto vamoose; /* * Get current settings first because we want to preserve existing * settings like whether to show hidden files etc. based on the * user's existing preference */ hr = fdlgIf->lpVtbl->GetOptions(fdlgIf, &flags); if (FAILED(hr)) 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; } /* Flags are equivalent to those we used in the older API */ /* * Following flags must be set irrespective of original setting * XXX - should FOS_NOVALIDATE be there ? Note FOS_NOVALIDATE has different * 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 */ if (oper == OFN_DIR_CHOOSE) { flags |= FOS_PICKFOLDERS; if (optsPtr->mustExist) flags |= FOS_FILEMUSTEXIST; /* XXX - check working */ } else flags &= ~ FOS_PICKFOLDERS; if (optsPtr->multi) flags |= FOS_ALLOWMULTISELECT; else flags &= ~FOS_ALLOWMULTISELECT; if (optsPtr->confirmOverwrite) flags |= FOS_OVERWRITEPROMPT; else flags &= ~FOS_OVERWRITEPROMPT; hr = fdlgIf->lpVtbl->SetOptions(fdlgIf, flags); if (FAILED(hr)) goto vamoose; if (optsPtr->extObj != NULL) { 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; } if (optsPtr->titleObj != NULL) { 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; } if (optsPtr->file[0]) { 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); } oldMode = Tcl_SetServiceMode(TCL_SERVICE_ALL); hr = fdlgIf->lpVtbl->Show(fdlgIf, hWnd); Tcl_SetServiceMode(oldMode); EatSpuriousMessageBugFix(); /* * Ensure that hWnd is enabled, because it can happen that we have updated * the wrapper of the parent, which causes us to leave this child disabled * (Windows loses sync). */ if (hWnd) EnableWindow(hWnd, 1); /* * Clear interp result since it might have been set during the modal loop. * https://core.tcl-lang.org/tk/tktview/4a0451f5291b3c9168cc560747dae9264e1d2ef6 */ 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); } } } } } else { if (hr == HRESULT_FROM_WIN32(ERROR_CANCELLED)) hr = 0; /* User cancelled, return empty string */ } vamoose: /* (hr != 0) => error */ if (dirIf) dirIf->lpVtbl->Release(dirIf); if (fdlgIf) fdlgIf->lpVtbl->Release(fdlgIf); if (filterPtr) FreeFilterVista(nfilters, filterPtr); if (hr == 0) { 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; } } /* *---------------------------------------------------------------------- * |
︙ | ︙ | |||
1514 1515 1516 1517 1518 1519 1520 | int cdlgerr; int filterIndex = 0, result = TCL_ERROR, winCode, oldMode; HWND hWnd; Tcl_DString utfFilterString, ds; Tcl_DString extString, filterString, dirString, titleString; const char *str; ThreadSpecificData *tsdPtr = (ThreadSpecificData *) | | | | | | 1514 1515 1516 1517 1518 1519 1520 1521 1522 1523 1524 1525 1526 1527 1528 1529 1530 1531 1532 1533 1534 1535 1536 1537 | int cdlgerr; int filterIndex = 0, result = TCL_ERROR, winCode, oldMode; HWND hWnd; Tcl_DString utfFilterString, ds; Tcl_DString extString, filterString, dirString, titleString; const char *str; ThreadSpecificData *tsdPtr = (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 */ if (MakeFilter(interp, optsPtr->filterObj, &utfFilterString, optsPtr->initialTypeObj, &filterIndex) != TCL_OK) { goto end; } Tk_MakeWindowExist(optsPtr->tkwin); hWnd = Tk_GetHWND(Tk_WindowId(optsPtr->tkwin)); memset(&ofn, 0, sizeof(OPENFILENAME)); |
︙ | ︙ | |||
1590 1591 1592 1593 1594 1595 1596 | */ Tcl_DString cwd; Tcl_DStringFree(&optsPtr->utfDirString); if ((Tcl_GetCwd(interp, &optsPtr->utfDirString) == NULL) || (Tcl_TranslateFileName(interp, | | | 1590 1591 1592 1593 1594 1595 1596 1597 1598 1599 1600 1601 1602 1603 1604 | */ Tcl_DString cwd; Tcl_DStringFree(&optsPtr->utfDirString); if ((Tcl_GetCwd(interp, &optsPtr->utfDirString) == NULL) || (Tcl_TranslateFileName(interp, Tcl_DStringValue(&optsPtr->utfDirString), &cwd) == NULL)) { Tcl_ResetResult(interp); } else { Tcl_DStringInit(&dirString); Tcl_UtfToWCharDString(Tcl_DStringValue(&cwd), Tcl_DStringLength(&cwd), &dirString); } Tcl_DStringFree(&cwd); |
︙ | ︙ | |||
1734 1735 1736 1737 1738 1739 1740 | &listObjc, &listObjv) != TCL_OK) { result = TCL_ERROR; } else if (Tcl_ListObjGetElements(interp, listObjv[ofn.nFilterIndex - 1], &count, &typeInfo) != TCL_OK) { result = TCL_ERROR; } else { | | | | | | | | | | | | | | | | | | | | | 1734 1735 1736 1737 1738 1739 1740 1741 1742 1743 1744 1745 1746 1747 1748 1749 1750 1751 1752 1753 1754 1755 1756 1757 1758 1759 1760 1761 1762 1763 1764 1765 1766 1767 1768 1769 1770 1771 1772 1773 1774 1775 1776 1777 1778 1779 1780 1781 1782 1783 | &listObjc, &listObjv) != TCL_OK) { result = TCL_ERROR; } else if (Tcl_ListObjGetElements(interp, listObjv[ofn.nFilterIndex - 1], &count, &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); } } } else if (cdlgerr == FNERR_INVALIDFILENAME) { Tcl_SetObjResult(interp, Tcl_ObjPrintf( "invalid filename \"%s\"", ConvertExternalFilename(ofn.lpstrFile, &ds))); Tcl_SetErrorCode(interp, "TK", "FILEDIALOG", "INVALID_FILENAME", NULL); Tcl_DStringFree(&ds); } else { result = TCL_OK; } if (ofn.lpstrTitle != NULL) { Tcl_DStringFree(&titleString); } if (ofn.lpstrInitialDir != NULL) { /* XXX - huh? lpstrInitialDir is set from Tcl_DStringValue which can never return NULL */ Tcl_DStringFree(&dirString); } Tcl_DStringFree(&filterString); if (ofn.lpstrDefExt != NULL) { Tcl_DStringFree(&extString); } |
︙ | ︙ | |||
1818 1819 1820 1821 1822 1823 1824 | * GetSaveFileName(). */ { OFNOpts ofnOpts; int result; result = ParseOFNOptions(clientData, interp, objc, objv, oper, &ofnOpts); if (result != TCL_OK) | | | | | 1818 1819 1820 1821 1822 1823 1824 1825 1826 1827 1828 1829 1830 1831 1832 1833 1834 1835 1836 1837 | * GetSaveFileName(). */ { OFNOpts ofnOpts; int result; result = ParseOFNOptions(clientData, interp, objc, objv, oper, &ofnOpts); if (result != TCL_OK) return result; if (VistaFileDialogsAvailable() && ! ofnOpts.forceXPStyle) result = GetFileNameVista(interp, &ofnOpts, oper); else result = GetFileNameXP(interp, &ofnOpts, oper); CleanupOFNOptions(&ofnOpts); return result; } /* |
︙ | ︙ | |||
2159 2160 2161 2162 2163 2164 2165 | * * Frees storage previously allocated by MakeFilterVista. * count is the number of elements in dlgFilterPtr[] */ static void FreeFilterVista(DWORD count, TCLCOMDLG_FILTERSPEC *dlgFilterPtr) { if (dlgFilterPtr != NULL) { | | | | | | | | | | 2159 2160 2161 2162 2163 2164 2165 2166 2167 2168 2169 2170 2171 2172 2173 2174 2175 2176 2177 2178 2179 2180 | * * Frees storage previously allocated by MakeFilterVista. * count is the number of elements in dlgFilterPtr[] */ 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((char *)dlgFilterPtr[dw].pszName); if (dlgFilterPtr[dw].pszSpec != NULL) ckfree((char *)dlgFilterPtr[dw].pszSpec); } ckfree(dlgFilterPtr); } } /* *---------------------------------------------------------------------- * * MakeFilterVista -- |
︙ | ︙ | |||
2191 2192 2193 2194 2195 2196 2197 | *---------------------------------------------------------------------- */ static int MakeFilterVista( Tcl_Interp *interp, /* Current interpreter. */ OFNOpts *optsPtr, /* Caller specified options */ DWORD *countPtr, /* Will hold number of filters */ TCLCOMDLG_FILTERSPEC **dlgFilterPtrPtr, /* Will hold pointer to filter array. | | | | | | | | | | | | | | | | 2191 2192 2193 2194 2195 2196 2197 2198 2199 2200 2201 2202 2203 2204 2205 2206 2207 2208 2209 2210 2211 2212 2213 2214 2215 2216 2217 2218 2219 2220 2221 2222 2223 2224 2225 2226 2227 2228 2229 2230 2231 2232 2233 2234 2235 2236 2237 2238 2239 2240 2241 2242 2243 2244 2245 2246 2247 2248 2249 2250 2251 2252 2253 2254 | *---------------------------------------------------------------------- */ static int MakeFilterVista( Tcl_Interp *interp, /* Current interpreter. */ 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 */ DWORD *initialIndexPtr) /* Will hold index of default type */ { TCLCOMDLG_FILTERSPEC *dlgFilterPtr; const char *initial = NULL; FileFilterList flist; FileFilter *filterPtr; DWORD initialIndex = 0; Tcl_DString ds, patterns; int i; if (optsPtr->filterObj == NULL) { *dlgFilterPtrPtr = NULL; *countPtr = 0; return TCL_OK; } if (optsPtr->initialTypeObj) initial = Tcl_GetString(optsPtr->initialTypeObj); TkInitFileFilters(&flist); if (TkGetFileFilters(interp, &flist, optsPtr->filterObj, 1) != TCL_OK) return TCL_ERROR; if (flist.filters == NULL) { *dlgFilterPtrPtr = NULL; *countPtr = 0; return TCL_OK; } Tcl_DStringInit(&ds); Tcl_DStringInit(&patterns); dlgFilterPtr = (TCLCOMDLG_FILTERSPEC *)ckalloc(flist.numFilters * sizeof(*dlgFilterPtr)); for (i = 0, filterPtr = flist.filters; 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 */ /* First stash away the text description of the pattern */ 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); memmove((void *) dlgFilterPtr[i].pszName, Tcl_DStringValue(&ds), nbytes); Tcl_DStringFree(&ds); /* |
︙ | ︙ | |||
2268 2269 2270 2271 2272 2273 2274 | Tcl_DStringAppend(&patterns, sep, TCL_INDEX_NONE); Tcl_DStringAppend(&patterns, globPtr->pattern, TCL_INDEX_NONE); sep = ";"; } } /* Again we need a Unicode form of the string */ | | | | 2268 2269 2270 2271 2272 2273 2274 2275 2276 2277 2278 2279 2280 2281 2282 2283 | Tcl_DStringAppend(&patterns, sep, TCL_INDEX_NONE); Tcl_DStringAppend(&patterns, globPtr->pattern, TCL_INDEX_NONE); sep = ";"; } } /* Again we need a Unicode form of the string */ 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); memmove((void *)dlgFilterPtr[i].pszSpec, Tcl_DStringValue(&ds), nbytes); Tcl_DStringFree(&ds); Tcl_DStringSetLength(&patterns, 0); } |
︙ | ︙ | |||
2383 2384 2385 2386 2387 2388 2389 | Tcl_DString titleString; /* Title */ Tcl_DString tempString; /* temporary */ Tcl_Obj *objPtr; OFNOpts ofnOpts; const char *utfDir; result = ParseOFNOptions(clientData, interp, objc, objv, | | | | | | | | | | | | 2383 2384 2385 2386 2387 2388 2389 2390 2391 2392 2393 2394 2395 2396 2397 2398 2399 2400 2401 2402 2403 2404 2405 2406 2407 2408 2409 2410 2411 2412 2413 2414 2415 2416 2417 2418 2419 2420 2421 2422 2423 2424 2425 2426 2427 | Tcl_DString titleString; /* Title */ Tcl_DString tempString; /* temporary */ Tcl_Obj *objPtr; OFNOpts ofnOpts; const char *utfDir; result = ParseOFNOptions(clientData, interp, objc, objv, OFN_DIR_CHOOSE, &ofnOpts); if (result != TCL_OK) return result; /* Use new dialogs if available */ if (VistaFileDialogsAvailable() && ! ofnOpts.forceXPStyle) { result = GetFileNameVista(interp, &ofnOpts, OFN_DIR_CHOOSE); CleanupOFNOptions(&ofnOpts); return result; } /* Older dialogs */ path[0] = '\0'; memset(&cdCBData, 0, sizeof(ChooseDir)); cdCBData.interp = interp; cdCBData.mustExist = ofnOpts.mustExist; utfDir = Tcl_DStringValue(&ofnOpts.utfDirString); if (utfDir[0] != '\0') { LPCWSTR uniStr; Tcl_DStringInit(&tempString); Tcl_UtfToWCharDString(Tcl_DStringValue(&ofnOpts.utfDirString), TCL_INDEX_NONE, &tempString); uniStr = (WCHAR *) Tcl_DStringValue(&tempString); /* Convert possible relative path to full path to keep dialog happy. */ GetFullPathNameW(uniStr, MAX_PATH, saveDir, NULL); wcsncpy(cdCBData.initDir, saveDir, MAX_PATH); } /* XXX - rest of this (original) code has no error checks at all. */ /* * Get ready to call the browser */ |
︙ | ︙ | |||
2476 2477 2478 2479 2480 2481 2482 | * user a chance to change their mind on an invalid folder if mustexist is * 0. */ oldMode = Tcl_SetServiceMode(TCL_SERVICE_ALL); GetCurrentDirectoryW(MAX_PATH, saveDir); if (SHGetMalloc(&pMalloc) == NOERROR) { | | | | | | 2476 2477 2478 2479 2480 2481 2482 2483 2484 2485 2486 2487 2488 2489 2490 2491 2492 2493 | * user a chance to change their mind on an invalid folder if mustexist is * 0. */ 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. */ pidl = SHBrowseForFolderW(&bInfo); /* * This is a fix for Windows 2000, which seems to modify the folder * name buffer even when the dialog is canceled (in this case the * buffer contains garbage). See [Bug #3002230] */ |
︙ | ︙ | |||
2616 2617 2618 2619 2620 2621 2622 | chooseDirSharedData->retDir, NULL); if (chooseDirSharedData->mustExist) { /* * User HAS to select a valid directory. */ wsprintfW(selDir, L"Directory '%s' does not exist,\n" | | | 2616 2617 2618 2619 2620 2621 2622 2623 2624 2625 2626 2627 2628 2629 2630 | chooseDirSharedData->retDir, NULL); if (chooseDirSharedData->mustExist) { /* * User HAS to select a valid directory. */ wsprintfW(selDir, L"Directory '%s' does not exist,\n" L"please select or enter an existing directory.", chooseDirSharedData->retDir); MessageBoxW(NULL, selDir, NULL, MB_ICONEXCLAMATION|MB_OK); chooseDirSharedData->retDir[0] = '\0'; return 1; } } else { /* |
︙ | ︙ |
Changes to win/tkWinDraw.c.
︙ | ︙ | |||
757 758 759 760 761 762 763 | */ static void MakeAndStrokePath( HDC dc, POINT *winPoints, int npoints, WinDrawFunc func) /* Name of the Windows GDI drawing function: | | | | | | | | | | | 757 758 759 760 761 762 763 764 765 766 767 768 769 770 771 772 773 774 775 776 777 778 779 780 781 782 783 784 785 786 787 788 789 790 | */ static void MakeAndStrokePath( HDC dc, POINT *winPoints, int npoints, WinDrawFunc func) /* Name of the Windows GDI drawing function: this is either Polyline or Polygon. */ { BeginPath(dc); func(dc, winPoints, (int)npoints); /* * In the case of closed polylines, the first and last points * are the same. We want miter or bevel join be rendered also * at this point, this needs telling the Windows GDI that the * 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); } else { EndPath(dc); StrokeAndFillPath(dc); } } /* *---------------------------------------------------------------------- * * RenderObject -- |
︙ | ︙ | |||
875 876 877 878 879 880 881 | * Draw the object in the foreground color and copy it to the * destination wherever the pattern is set. */ SetPolyFillMode(dcMem, (gc->fill_rule == EvenOddRule) ? ALTERNATE : WINDING); oldMemBrush = (HBRUSH)SelectObject(dcMem, CreateSolidBrush(gc->foreground)); | | | | | 875 876 877 878 879 880 881 882 883 884 885 886 887 888 889 890 891 892 893 894 895 896 897 898 899 900 901 902 903 904 905 906 907 908 909 910 911 912 913 914 915 916 917 | * Draw the object in the foreground color and copy it to the * destination wherever the pattern is set. */ SetPolyFillMode(dcMem, (gc->fill_rule == EvenOddRule) ? ALTERNATE : WINDING); oldMemBrush = (HBRUSH)SelectObject(dcMem, CreateSolidBrush(gc->foreground)); MakeAndStrokePath(dcMem, winPoints, npoints, func); BitBlt(dc, rect.left, rect.top, width, height, dcMem, 0, 0, COPYFG); /* * If we are rendering an opaque stipple, then draw the polygon in the * background color and copy it to the destination wherever the * pattern is clear. */ if (gc->fill_style == FillOpaqueStippled) { DeleteObject(SelectObject(dcMem, CreateSolidBrush(gc->background))); MakeAndStrokePath(dcMem, winPoints, npoints, func); BitBlt(dc, rect.left, rect.top, width, height, dcMem, 0, 0, COPYBG); } SelectObject(dcMem, oldPen); DeleteObject(SelectObject(dcMem, oldMemBrush)); DeleteObject(SelectObject(dcMem, oldBitmap)); DeleteDC(dcMem); } else { oldPen = (HPEN)SelectObject(dc, pen); oldBrush = (HBRUSH)SelectObject(dc, CreateSolidBrush(gc->foreground)); SetROP2(dc, tkpWinRopModes[gc->function]); SetPolyFillMode(dc, (gc->fill_rule == EvenOddRule) ? ALTERNATE : WINDING); MakeAndStrokePath(dc, winPoints, npoints, func); SelectObject(dc, oldPen); } DeleteObject(SelectObject(dc, oldBrush)); } /* *---------------------------------------------------------------------- |
︙ | ︙ |
Changes to win/tkWinEmbed.c.
︙ | ︙ | |||
858 859 860 861 862 863 864 | { Container *containerPtr = (Container *)clientData; Tk_Window tkwin = (Tk_Window)containerPtr->parentPtr; if (eventPtr->type == ConfigureNotify) { /* | | | | | | | 858 859 860 861 862 863 864 865 866 867 868 869 870 871 872 873 874 875 876 877 | { Container *containerPtr = (Container *)clientData; Tk_Window tkwin = (Tk_Window)containerPtr->parentPtr; if (eventPtr->type == ConfigureNotify) { /* * Send a ConfigureNotify to the embedded application. */ if (containerPtr->embeddedPtr != NULL) { TkDoConfigureNotify(containerPtr->embeddedPtr); } /* * Resize the embedded window, if there is any. */ if (containerPtr->embeddedHWnd) { SetWindowPos(containerPtr->embeddedHWnd, NULL, 0, 0, |
︙ | ︙ |
Changes to win/tkWinGDI.c.
︙ | ︙ | |||
570 571 572 573 574 575 576 | int n; int nbpoints = 0; POINT* bpoints; inPointList = (double *)attemptckalloc(2 * sizeof(double) * npoly); if (inPointList == 0) { /* TODO: unreachable */ | | | | | | | | | | | 570 571 572 573 574 575 576 577 578 579 580 581 582 583 584 585 586 587 588 589 590 591 592 593 594 595 596 597 598 599 600 601 602 603 604 605 606 607 608 609 610 611 612 613 | int n; int nbpoints = 0; POINT* bpoints; inPointList = (double *)attemptckalloc(2 * sizeof(double) * npoly); if (inPointList == 0) { /* TODO: unreachable */ return nbpoints; /* 0. */ } for (n=0; n<npoly; n++) { 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; } nbpoints = TkMakeBezierCurve(NULL, inPointList, npoly, nStep, NULL, outPointList); ckfree(inPointList); bpoints = (POINT *)attemptckalloc(sizeof(POINT)*nbpoints); if (bpoints == 0) { /* TODO: unreachable */ 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]; } ckfree(outPointList); *bpointptr = *bpoints; return nbpoints; } /* |
︙ | ︙ | |||
1415 1416 1417 1418 1419 1420 1421 | * fails, get the "extended" error code and return. Be sure to deallocate * the font if necessary. */ if (retval == FALSE) { DWORD val = GetLastError(); Tcl_SetObjResult(interp, Tcl_ObjPrintf( | | | 1415 1416 1417 1418 1419 1420 1421 1422 1423 1424 1425 1426 1427 1428 1429 | * fails, get the "extended" error code and return. Be sure to deallocate * the font if necessary. */ if (retval == FALSE) { DWORD val = GetLastError(); Tcl_SetObjResult(interp, Tcl_ObjPrintf( "::tk::print::_gdi character failed with code %ld", val)); if (made_font) { SelectObject(hDC, oldfont); DeleteObject(hfont); } return TCL_ERROR; } |
︙ | ︙ | |||
2975 2976 2977 2978 2979 2980 2981 | HANDLE hDIB; HBITMAP hBitmap; HPALETTE hPalette; /* Check for a valid window handle. */ if (!hWnd) { | | | 2975 2976 2977 2978 2979 2980 2981 2982 2983 2984 2985 2986 2987 2988 2989 | HANDLE hDIB; HBITMAP hBitmap; HPALETTE hPalette; /* Check for a valid window handle. */ if (!hWnd) { return NULL; } switch (type) { case PTWindow: { /* Copy entire window. */ RECT rectWnd; /* Get the window rectangle. */ |
︙ | ︙ | |||
3144 3145 3146 3147 3148 3149 3150 | xScrn = GetDeviceCaps(hScrDC, HORZRES); yScrn = GetDeviceCaps(hScrDC, VERTRES); /* Make sure bitmap rectangle is visible. */ if (nX < 0) { | | | | | | 3144 3145 3146 3147 3148 3149 3150 3151 3152 3153 3154 3155 3156 3157 3158 3159 3160 3161 3162 3163 3164 3165 3166 3167 | xScrn = GetDeviceCaps(hScrDC, HORZRES); yScrn = GetDeviceCaps(hScrDC, VERTRES); /* Make sure bitmap rectangle is visible. */ if (nX < 0) { nX = 0; } if (nY < 0) { nY = 0; } if (nX2 > xScrn) { nX2 = xScrn; } if (nY2 > yScrn) { nY2 = yScrn; } nWidth = nX2 - nX; nHeight = nY2 - nY; /* Create a bitmap compatible with the screen DC. */ hBitmap = CreateCompatibleBitmap(hScrDC, nWidth, nHeight); |
︙ | ︙ | |||
3214 3215 3216 3217 3218 3219 3220 | HANDLE h; HDC hDC; WORD biBits; /* Check if bitmap handle is valid. */ if (!hBitmap) { | | | | | | | | | 3214 3215 3216 3217 3218 3219 3220 3221 3222 3223 3224 3225 3226 3227 3228 3229 3230 3231 3232 3233 3234 3235 3236 3237 3238 3239 3240 3241 3242 3243 3244 3245 3246 3247 3248 3249 3250 3251 3252 3253 3254 3255 3256 | HANDLE h; HDC hDC; WORD biBits; /* Check if bitmap handle is valid. */ if (!hBitmap) { return NULL; } /* Fill in BITMAP structure, return NULL if it didn't work. */ if (!GetObjectW(hBitmap, sizeof(bm), (LPWSTR)&bm)) { return NULL; } /* Ff no palette is specified, use default palette. */ if (hPal == NULL) { hPal = GetStockObject(DEFAULT_PALETTE); } /* Calculate bits per pixel. */ biBits = bm.bmPlanes * bm.bmBitsPixel; /* Make sure bits per pixel is valid. */ if (biBits <= 1) { biBits = 1; } else if (biBits <= 4) { biBits = 4; } else if (biBits <= 8) { biBits = 8; } else { /* If greater than 8-bit, force to 24-bit. */ biBits = 24; } /* Initialize BITMAPINFOHEADER. */ bi.biSize = sizeof(BITMAPINFOHEADER); bi.biWidth = bm.bmWidth; bi.biHeight = bm.bmHeight; |
︙ | ︙ | |||
3309 3310 3311 3312 3313 3314 3315 | /* get the info. returned by GetDIBits and unlock memory block. */ bi = *lpbi; GlobalUnlock(hDIB); /* If the driver did not fill in the biSizeImage field, make one up. */ if (bi.biSizeImage == 0) { | | | | 3309 3310 3311 3312 3313 3314 3315 3316 3317 3318 3319 3320 3321 3322 3323 3324 3325 3326 3327 3328 3329 3330 3331 3332 | /* get the info. returned by GetDIBits and unlock memory block. */ bi = *lpbi; GlobalUnlock(hDIB); /* 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) * bm.bmHeight; } /* Realloc the buffer big enough to hold all the bits. */ dwLen = bi.biSize + DIBNumColors(&bi) * sizeof(RGBQUAD) + bi.biSizeImage; if ((h = GlobalReAlloc(hDIB, dwLen, 0)) != 0) { hDIB = h; } else { /* Clean up and return NULL. */ GlobalFree(hDIB); SelectPalette(hDC, hPal, TRUE); RealizePalette(hDC); ReleaseDC(NULL, hDC); |
︙ | ︙ | |||
3436 3437 3438 3439 3440 3441 3442 | LPLOGPALETTE lpLogPal; /* Pointer to a logical palette. */ int nColors; /* Number of colors. */ /* Find out how many palette entries we want.. */ hDC = GetDC(NULL); if (!hDC) { | | | | 3436 3437 3438 3439 3440 3441 3442 3443 3444 3445 3446 3447 3448 3449 3450 3451 3452 3453 3454 3455 3456 3457 3458 3459 3460 3461 3462 | LPLOGPALETTE lpLogPal; /* Pointer to a logical palette. */ int nColors; /* Number of colors. */ /* Find out how many palette entries we want.. */ hDC = GetDC(NULL); if (!hDC) { return NULL; } nColors = PalEntriesOnDevice(hDC); /* Number of palette entries. */ /* Allocate room for the palette and lock it.. */ hLogPal = GlobalAlloc(GHND, sizeof(LOGPALETTE) + nColors * sizeof(PALETTEENTRY)); if (!hLogPal) { /* If we didn't get a logical palette, return NULL. */ return NULL; } /* get a pointer to the logical palette. */ lpLogPal = (LPLOGPALETTE)GlobalLock(hLogPal); /* Set some important fields. */ |
︙ | ︙ | |||
3639 3640 3641 3642 3643 3644 3645 | } /* * Store print properties and link variables so they can be accessed from * script level. */ if (localPrinterName != NULL) { | | | | | | | | | | | | | | | | | | 3639 3640 3641 3642 3643 3644 3645 3646 3647 3648 3649 3650 3651 3652 3653 3654 3655 3656 3657 3658 3659 3660 3661 3662 3663 3664 3665 3666 3667 3668 3669 | } /* * Store print properties and link variables so they can be accessed from * 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", (char*)varlink2, TCL_LINK_STRING | TCL_LINK_READ_ONLY); Tcl_LinkVar(interp, "::tk::print::copies", (char*)&copies, TCL_LINK_INT | TCL_LINK_READ_ONLY); Tcl_LinkVar(interp, "::tk::print::dpi_x", (char*)&dpi_x, TCL_LINK_INT | TCL_LINK_READ_ONLY); Tcl_LinkVar(interp, "::tk::print::dpi_y", (char*)&dpi_y, TCL_LINK_INT | TCL_LINK_READ_ONLY); Tcl_LinkVar(interp, "::tk::print::paper_width", (char*)&paper_width, TCL_LINK_INT | TCL_LINK_READ_ONLY); Tcl_LinkVar(interp, "::tk::print::paper_height", (char*)&paper_height, TCL_LINK_INT | TCL_LINK_READ_ONLY); } return TCL_OK; } /* * -------------------------------------------------------------------------- |
︙ | ︙ |
Changes to win/tkWinIco.c.
︙ | ︙ | |||
167 168 169 170 171 172 173 | bmInfo.bmiHeader.biWidth = width; bmInfo.bmiHeader.biHeight = -height; bmInfo.bmiHeader.biPlanes = 1; bmInfo.bmiHeader.biBitCount = 32; bmInfo.bmiHeader.biCompression = BI_RGB; iconInfo.hbmColor = CreateDIBSection(NULL, &bmInfo, DIB_RGB_COLORS, | | | | | | | | | | | | 167 168 169 170 171 172 173 174 175 176 177 178 179 180 181 182 183 184 185 186 187 188 189 190 191 192 193 194 195 196 197 198 199 200 201 202 203 204 205 206 207 208 209 210 211 212 213 214 215 216 217 218 219 220 221 222 223 | bmInfo.bmiHeader.biWidth = width; bmInfo.bmiHeader.biHeight = -height; bmInfo.bmiHeader.biPlanes = 1; bmInfo.bmiHeader.biBitCount = 32; bmInfo.bmiHeader.biCompression = BI_RGB; iconInfo.hbmColor = CreateDIBSection(NULL, &bmInfo, DIB_RGB_COLORS, &bgraPixel.voidPtr, NULL, 0); if (!iconInfo.hbmColor) { return NULL; } /* * Convert the photo image data into BGRA format (RGBQUAD). */ 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]; } /* * Create a dummy mask bitmap. The contents of this don't appear to * matter, as CreateIconIndirect will setup the icon mask based on the * alpha channel in our color bitmap. */ bmInfo.bmiHeader.biBitCount = 1; iconInfo.hbmMask = CreateDIBSection(NULL, &bmInfo, DIB_RGB_COLORS, &bgraMask.voidPtr, NULL, 0); if (!iconInfo.hbmMask) { DeleteObject(iconInfo.hbmColor); return NULL; } memset(bgraMask.ptr, 0, width*height/8); /* * Create an icon from the bitmaps. */ hIcon = CreateIconIndirect(&iconInfo); DeleteObject(iconInfo.hbmColor); DeleteObject(iconInfo.hbmMask); if (hIcon == NULL) { return NULL; } return hIcon; } /* * Local Variables: * mode: c |
︙ | ︙ |
Changes to win/tkWinIco.h.
︙ | ︙ | |||
82 83 84 85 86 87 88 | /* * The following are implemented in tkWinIco.c and also used in tkWinWm.c and tkWinSysTray.c. */ DWORD BytesPerLine(LPBITMAPINFOHEADER lpBMIH); LPSTR FindDIBBits(LPSTR lpbi); | | < | 82 83 84 85 86 87 88 89 90 91 92 93 94 95 96 | /* * The following are implemented in tkWinIco.c and also used in tkWinWm.c and tkWinSysTray.c. */ DWORD BytesPerLine(LPBITMAPINFOHEADER lpBMIH); LPSTR FindDIBBits(LPSTR lpbi); HICON CreateIcoFromPhoto(int width, int height, Tk_PhotoImageBlock block); /* * Local Variables: * mode: c * c-basic-offset: 4 * fill-column: 78 |
︙ | ︙ |
Changes to win/tkWinKey.c.
︙ | ︙ | |||
354 355 356 357 358 359 360 | * pressed, return the appropriate keycode. Otherwise, we fall through * and rely on the keymap table to hold the correct keysym value. * Note: this little trick only works for KeyPress, not for KeyRelease, * for reasons stated in bug [2945130] */ case VK_CONTROL: | | | | | | | | 354 355 356 357 358 359 360 361 362 363 364 365 366 367 368 369 370 371 372 373 374 375 376 377 378 379 380 | * pressed, return the appropriate keycode. Otherwise, we fall through * and rely on the keymap table to hold the correct keysym value. * Note: this little trick only works for KeyPress, not for KeyRelease, * for reasons stated in bug [2945130] */ case VK_CONTROL: if (state & EXTENDED_MASK) { return XK_Control_R; } break; case VK_SHIFT: if (GetKeyState(VK_RSHIFT) & 0x80) { return XK_Shift_R; } break; case VK_MENU: if (state & EXTENDED_MASK) { return XK_Alt_R; } break; } return keymap[keycode]; } /* *---------------------------------------------------------------------- |
︙ | ︙ |
Changes to win/tkWinMenu.c.
︙ | ︙ | |||
1597 1598 1599 1600 1601 1602 1603 | } else { int borderWidth; Tk_GetPixelsFromObj(menuPtr->interp, menuPtr->tkwin, menuPtr->borderWidthPtr, &borderWidth); *widthPtr = indicatorDimensions[1] - borderWidth; | | | | | | | | | | 1597 1598 1599 1600 1601 1602 1603 1604 1605 1606 1607 1608 1609 1610 1611 1612 1613 1614 1615 1616 1617 1618 | } else { int borderWidth; Tk_GetPixelsFromObj(menuPtr->interp, menuPtr->tkwin, 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; } } } /* *---------------------------------------------------------------------- * * GetMenuAccelGeometry -- |
︙ | ︙ | |||
1635 1636 1637 1638 1639 1640 1641 | Tk_Font tkfont, /* The precalculated font */ const Tk_FontMetrics *fmPtr,/* The precalculated font metrics */ int *widthPtr, /* The resulting width */ int *heightPtr) /* The resulting height */ { *heightPtr = fmPtr->linespace; if (mePtr->type == CASCADE_ENTRY) { | | | | | | | | 1635 1636 1637 1638 1639 1640 1641 1642 1643 1644 1645 1646 1647 1648 1649 1650 1651 1652 1653 1654 | Tk_Font tkfont, /* The precalculated font */ const Tk_FontMetrics *fmPtr,/* The precalculated font metrics */ int *widthPtr, /* The resulting width */ int *heightPtr) /* The resulting height */ { *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. */ *widthPtr = CASCADE_ARROW_WIDTH; } else if ((menuPtr->menuType != MENUBAR) && (mePtr->accelPtr != NULL)) { const char *accel = Tcl_GetString(mePtr->accelPtr); *widthPtr = Tk_TextWidth(tkfont, accel, mePtr->accelLength); } else { *widthPtr = 0; |
︙ | ︙ | |||
1904 1905 1906 1907 1908 1909 1910 | int height) /* Height of menu entry */ { int baseline; int leftEdge = x + mePtr->indicatorSpace + mePtr->labelWidth; const char *accel; if (menuPtr->menuType == MENUBAR) { | | | 1904 1905 1906 1907 1908 1909 1910 1911 1912 1913 1914 1915 1916 1917 1918 | int height) /* Height of menu entry */ { int baseline; int leftEdge = x + mePtr->indicatorSpace + mePtr->labelWidth; const char *accel; if (menuPtr->menuType == MENUBAR) { return; } if (mePtr->accelPtr != NULL) { accel = Tcl_GetString(mePtr->accelPtr); } else { accel = NULL; } |
︙ | ︙ | |||
1987 1988 1989 1990 1991 1992 1993 | /* * Don't draw the arrow if a submenu is not attached to this * cascade entry. */ if ((mePtr->childMenuRefPtr == NULL) | | | | 1987 1988 1989 1990 1991 1992 1993 1994 1995 1996 1997 1998 1999 2000 2001 2002 | /* * Don't draw the arrow if a submenu is not attached to this * cascade entry. */ if ((mePtr->childMenuRefPtr == NULL) || (mePtr->childMenuRefPtr->menuPtr == NULL)) { return; } oldFgColor = gc->foreground; oldBgColor = gc->background; /* * Set bitmap bg to highlight color if the menu is highlighted. |
︙ | ︙ | |||
2945 2946 2947 2948 2949 2950 2951 | Tk_GetReliefFromObj(NULL, menuPtr->activeReliefPtr, &relief); } Tk_GetPixelsFromObj(NULL, menuPtr->tkwin, menuPtr->activeBorderWidthPtr, &activeBorderWidth); Tk_Fill3DRectangle(menuPtr->tkwin, d, bgBorder, x, y, width, height, activeBorderWidth, relief); } else { | | | | 2945 2946 2947 2948 2949 2950 2951 2952 2953 2954 2955 2956 2957 2958 2959 2960 | Tk_GetReliefFromObj(NULL, menuPtr->activeReliefPtr, &relief); } Tk_GetPixelsFromObj(NULL, menuPtr->tkwin, menuPtr->activeBorderWidthPtr, &activeBorderWidth); 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); } } /* *-------------------------------------------------------------- * * TkpComputeStandardMenuGeometry -- |
︙ | ︙ |
Changes to win/tkWinPointer.c.
︙ | ︙ | |||
373 374 375 376 377 378 379 | /* * A multi-screen system may have different logical pixels/inch, with * Windows applying behind-the-scenes scaling on secondary screens. * Don't try and emulate that, instead fall back to SetCursor if the * requested position is off the primary screen. */ if ( x < 0 || x > xscreen || y < 0 || y > yscreen ) { | | | | | 373 374 375 376 377 378 379 380 381 382 383 384 385 386 387 388 389 390 391 392 393 394 395 396 397 398 399 400 401 402 403 404 | /* * A multi-screen system may have different logical pixels/inch, with * Windows applying behind-the-scenes scaling on secondary screens. * Don't try and emulate that, instead fall back to SetCursor if the * requested position is off the primary screen. */ if ( x < 0 || x > xscreen || y < 0 || y > yscreen ) { SetCursorPos(x, y); return; } input.type = INPUT_MOUSE; input.mi.dx = (x * 65535 + xscreen/2) / xscreen; input.mi.dy = (y * 65535 + yscreen/2) / yscreen; /* * Horrible workaround here. There is a bug on Win 10: when warping to * pixel (x = 0, y = 0) the SendInput() below just does not move the * mouse pointer. However, as soon as dx or dy is non zero it moves as * expected. Given the scaling factor of 65535 (see above), * (dx = 1 , dy = 0) still means pixel (x = 0, y = 0). * See ticket [69b48f427e]. */ if (input.mi.dx == 0 && input.mi.dy == 0) { input.mi.dx = 1; } input.mi.mouseData = 0; input.mi.dwFlags = MOUSEEVENTF_ABSOLUTE | MOUSEEVENTF_MOVE; input.mi.time = 0; input.mi.dwExtraInfo = 0; SendInput(1, &input, sizeof(input)); |
︙ | ︙ |
Changes to win/tkWinScrlbr.c.
︙ | ︙ | |||
390 391 392 393 394 395 396 | int fieldLength, minThumbSize; /* * Windows doesn't use focus rings on scrollbars, but we still perform * basic sanity checks to appease backwards compatibility. */ | < < < < | 390 391 392 393 394 395 396 397 398 399 400 401 402 403 | int fieldLength, minThumbSize; /* * Windows doesn't use focus rings on scrollbars, but we still perform * basic sanity checks to appease backwards compatibility. */ if (scrollPtr->vertical) { scrollPtr->arrowLength = vArrowHeight; fieldLength = Tk_Height(scrollPtr->tkwin); minThumbSize = vThumb; } else { scrollPtr->arrowLength = hArrowWidth; fieldLength = Tk_Width(scrollPtr->tkwin); |
︙ | ︙ |
Changes to win/tkWinSendCom.h.
︙ | ︙ | |||
42 43 44 45 46 47 48 | #define TKWINSENDCOM_DISPID_ASYNC 2 /* * TkWinSendCom public functions */ MODULE_SCOPE HRESULT TkWinSendCom_CreateInstance(Tcl_Interp *interp, | | | | | 42 43 44 45 46 47 48 49 50 51 52 53 54 55 56 57 58 59 60 | #define TKWINSENDCOM_DISPID_ASYNC 2 /* * TkWinSendCom public functions */ MODULE_SCOPE HRESULT TkWinSendCom_CreateInstance(Tcl_Interp *interp, REFIID riid, void **ppv); MODULE_SCOPE int TkWinSend_QueueCommand(Tcl_Interp *interp, Tcl_Obj *cmdPtr); MODULE_SCOPE void TkWinSend_SetExcepInfo(Tcl_Interp *interp, EXCEPINFO *pExcepInfo); #endif /* _tkWinSendCom_h_INCLUDE */ /* * Local Variables: * mode: c * End: |
︙ | ︙ |
Changes to win/tkWinSysTray.c.
︙ | ︙ | |||
32 33 34 35 36 37 38 | */ #define GETHINSTANCE Tk_GetHINSTANCE() typedef struct IcoInfo { HICON hIcon; /* icon handle returned by LoadIcon. */ unsigned id; /* Identifier for command; used to | | | | 32 33 34 35 36 37 38 39 40 41 42 43 44 45 46 47 48 49 50 | */ #define GETHINSTANCE Tk_GetHINSTANCE() typedef struct IcoInfo { HICON hIcon; /* icon handle returned by LoadIcon. */ unsigned id; /* Identifier for command; used to * 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 */ int taskbar_flags; /* taskbar related flags*/ HWND hwndFocus; struct IcoInfo *nextPtr; } IcoInfo; /* Per-interp struture */ typedef struct IcoInterpInfo { |
︙ | ︙ | |||
98 99 100 101 102 103 104 | RECT Rect, LPLPICONIMAGE lpIcon) { int x, y; /* Sanity checks */ if (lpIcon == NULL) | | | | | | | | 98 99 100 101 102 103 104 105 106 107 108 109 110 111 112 113 114 115 116 117 118 119 120 121 122 123 124 125 126 127 128 | RECT Rect, LPLPICONIMAGE lpIcon) { int x, y; /* Sanity checks */ if (lpIcon == NULL) return FALSE; if (lpIcon->lpBits == NULL) return FALSE; /* Account for height*2 thing */ lpIcon->lpbi->bmiHeader.biHeight /= 2; /* Locate it */ x = Rect.left + ((RectWidth(Rect) - lpIcon->lpbi->bmiHeader.biWidth) / 2); y = Rect.top + ((RectHeight(Rect) - lpIcon->lpbi->bmiHeader.biHeight) / 2); /* 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); /* UnAccount for height*2 thing */ lpIcon->lpbi->bmiHeader.biHeight *= 2; return TRUE; } |
︙ | ︙ | |||
149 150 151 152 153 154 155 | LPLPICONIMAGE lpIcon) { LPBITMAPINFO lpbi; int x, y; /* Sanity checks */ if (lpIcon == NULL) | | | | 149 150 151 152 153 154 155 156 157 158 159 160 161 162 163 164 165 | LPLPICONIMAGE lpIcon) { LPBITMAPINFO lpbi; int x, y; /* Sanity checks */ if (lpIcon == NULL) return FALSE; if (lpIcon->lpBits == NULL) return FALSE; /* Need a bitmap header for the mono mask */ lpbi = ckalloc(sizeof(BITMAPINFO) + (2 * sizeof(RGBQUAD))); lpbi->bmiHeader.biSize = sizeof(BITMAPINFOHEADER); lpbi->bmiHeader.biWidth = lpIcon->lpbi->bmiHeader.biWidth; lpbi->bmiHeader.biHeight = lpIcon->lpbi->bmiHeader.biHeight / 2; lpbi->bmiHeader.biPlanes = 1; |
︙ | ︙ | |||
181 182 183 184 185 186 187 | /* Locate it */ x = Rect.left + ((RectWidth(Rect) - lpbi->bmiHeader.biWidth) / 2); y = Rect.top + ((RectHeight(Rect) - lpbi->bmiHeader.biHeight) / 2); /* Blast it to the screen */ SetDIBitsToDevice(hDC, x, y, | | | | | | 181 182 183 184 185 186 187 188 189 190 191 192 193 194 195 196 197 198 | /* Locate it */ x = Rect.left + ((RectWidth(Rect) - lpbi->bmiHeader.biWidth) / 2); y = Rect.top + ((RectHeight(Rect) - lpbi->bmiHeader.biHeight) / 2); /* 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); /* clean up */ ckfree(lpbi); return TRUE; } #endif /* ICO_DRAW */ |
︙ | ︙ | |||
226 227 228 229 230 231 232 | ni.hWnd = icoInterpPtr->hwnd; ni.uID = icoPtr->id; ni.uFlags = NIF_ICON | NIF_TIP | NIF_MESSAGE; ni.uCallbackMessage = ICON_MESSAGE; ni.hIcon = icoPtr->hIcon; if (icoPtr->taskbar_txt != NULL) { | | | | | | | | | | | | | | 226 227 228 229 230 231 232 233 234 235 236 237 238 239 240 241 242 243 244 245 246 247 248 249 250 251 252 253 254 255 | ni.hWnd = icoInterpPtr->hwnd; ni.uID = icoPtr->id; ni.uFlags = NIF_ICON | NIF_TIP | NIF_MESSAGE; ni.uCallbackMessage = ICON_MESSAGE; 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); } else { 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; } } /* Silently ignore error? */ return TCL_OK; } /* *---------------------------------------------------------------------- |
︙ | ︙ | |||
308 309 310 311 312 313 314 | static void FreeIcoPtr( IcoInterpInfo *icoInterpPtr, IcoInfo *icoPtr) { IcoInfo *prevPtr; if (icoInterpPtr->firstIcoPtr == icoPtr) { | | | | | | | | | | | 308 309 310 311 312 313 314 315 316 317 318 319 320 321 322 323 324 325 326 327 328 329 330 331 332 333 334 335 336 337 | static void FreeIcoPtr( IcoInterpInfo *icoInterpPtr, IcoInfo *icoPtr) { IcoInfo *prevPtr; if (icoInterpPtr->firstIcoPtr == icoPtr) { icoInterpPtr->firstIcoPtr = icoPtr->nextPtr; } else { 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); } if (icoPtr->taskbar_txt != NULL) { Tcl_DecrRefCount(icoPtr->taskbar_txt); } if (icoPtr->taskbar_command != NULL) { Tcl_DecrRefCount(icoPtr->taskbar_command); } ckfree(icoPtr); } /* *---------------------------------------------------------------------- * |
︙ | ︙ | |||
356 357 358 359 360 361 362 | { IcoInfo *icoPtr; unsigned id; const char *start; char *end; if (strncmp(string, "ico#", 4) != 0) { | | | | | | | | 356 357 358 359 360 361 362 363 364 365 366 367 368 369 370 371 372 373 374 375 376 377 378 379 380 381 382 383 384 385 | { IcoInfo *icoPtr; unsigned id; const char *start; char *end; if (strncmp(string, "ico#", 4) != 0) { goto notfound; } start = string + 4; id = strtoul(start, &end, 10); if ((end == start) || (*end != 0)) { goto notfound; } for (icoPtr = icoInterpPtr->firstIcoPtr; icoPtr != NULL; icoPtr = icoPtr->nextPtr) { if (icoPtr->id == id) { return icoPtr; } } notfound: Tcl_AppendResult(interp, "icon \"", string, "\" doesn't exist", NULL); return NULL; } /* *---------------------------------------------------------------------- * * GetInt -- |
︙ | ︙ | |||
462 463 464 465 466 467 468 | #define SPACELEFT (*aftersize-(dst-after)-1) #define AFTERLEN ((*aftersize>0)?(*aftersize*2):1024) #define ALLOCLEN ((len>AFTERLEN)?(len*2):AFTERLEN) char buffer[TCL_INTEGER_SPACE + 5]; char* dst; dst = after; while (*before) { | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | 462 463 464 465 466 467 468 469 470 471 472 473 474 475 476 477 478 479 480 481 482 483 484 485 486 487 488 489 490 491 492 493 494 495 496 497 498 499 500 501 502 503 504 505 506 507 508 509 510 511 512 513 514 515 516 517 518 519 520 521 522 523 524 525 526 527 528 529 530 531 532 533 534 535 536 537 538 539 540 541 542 543 544 545 546 547 548 549 550 551 552 553 554 555 556 557 558 559 560 561 562 563 564 565 566 567 568 569 570 571 572 573 574 575 576 577 578 579 580 581 582 583 584 585 586 | #define SPACELEFT (*aftersize-(dst-after)-1) #define AFTERLEN ((*aftersize>0)?(*aftersize*2):1024) #define ALLOCLEN ((len>AFTERLEN)?(len*2):AFTERLEN) char buffer[TCL_INTEGER_SPACE + 5]; 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++; } *dst = 0; return after; } /* *---------------------------------------------------------------------- |
︙ | ︙ | |||
608 609 610 611 612 613 614 | char evalspace[200]; int evalsize = 200; char *expanded; int fixup = 0; switch (lParam) { case WM_MOUSEMOVE: | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | 608 609 610 611 612 613 614 615 616 617 618 619 620 621 622 623 624 625 626 627 628 629 630 631 632 633 634 635 636 637 638 639 640 641 642 643 644 645 646 647 648 649 650 651 652 653 654 655 656 657 658 659 660 661 662 663 664 665 666 667 668 669 670 671 672 673 674 675 676 677 678 679 680 681 682 683 684 685 686 687 688 689 690 691 692 693 694 695 696 697 698 699 700 701 702 | char evalspace[200]; int evalsize = 200; char *expanded; int fixup = 0; switch (lParam) { case WM_MOUSEMOVE: msgstring = "WM_MOUSEMOVE"; icoPtr->hwndFocus = GetFocus(); break; case WM_LBUTTONDOWN: msgstring = "WM_LBUTTONDOWN"; fixup = 1; break; case WM_LBUTTONUP: msgstring = "WM_LBUTTONUP"; fixup = 1; break; case WM_LBUTTONDBLCLK: msgstring = "WM_LBUTTONDBLCLK"; fixup = 1; break; case WM_RBUTTONDOWN: msgstring = "WM_RBUTTONDOWN"; fixup = 1; break; case WM_RBUTTONUP: msgstring = "WM_RBUTTONUP"; fixup = 1; break; case WM_RBUTTONDBLCLK: msgstring = "WM_RBUTTONDBLCLK"; fixup = 1; break; case WM_MBUTTONDOWN: msgstring = "WM_MBUTTONDOWN"; fixup = 1; break; case WM_MBUTTONUP: msgstring = "WM_MBUTTONUP"; fixup = 1; break; case WM_MBUTTONDBLCLK: msgstring = "WM_MBUTTONDBLCLK"; fixup = 1; break; default: msgstring = "WM_NULL"; fixup = 0; } expanded = TaskbarExpandPercents(icoPtr, msgstring, wParam, lParam, 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); } } if (expanded != evalspace) { ckfree(expanded); } } /* *---------------------------------------------------------------------- * * TaskbarHandlerProc -- |
︙ | ︙ | |||
722 723 724 725 726 727 728 | { static UINT msgTaskbarCreated = 0; IcoInterpInfo *icoInterpPtr; IcoInfo *icoPtr; switch (message) { case WM_CREATE: | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | 722 723 724 725 726 727 728 729 730 731 732 733 734 735 736 737 738 739 740 741 742 743 744 745 746 747 748 749 750 751 752 753 754 755 756 757 758 759 760 761 762 763 764 765 766 767 768 769 770 771 772 | { static UINT msgTaskbarCreated = 0; IcoInterpInfo *icoInterpPtr; IcoInfo *icoPtr; switch (message) { case WM_CREATE: 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; 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); } return 0; } /* *---------------------------------------------------------------------- * |
︙ | ︙ | |||
819 820 821 822 823 824 825 | */ static HWND CreateTaskbarHandlerWindow(void) { static int registered = 0; HINSTANCE hInstance = GETHINSTANCE; if (!registered) { | | | | | | 819 820 821 822 823 824 825 826 827 828 829 830 831 832 833 834 835 836 837 838 | */ static HWND CreateTaskbarHandlerWindow(void) { static int registered = 0; HINSTANCE hInstance = GETHINSTANCE; if (!registered) { if (!RegisterHandlerClass(hInstance)) return 0; registered = 1; } return CreateWindow(HANDLER_CLASS, "", WS_OVERLAPPED, 0, 0, CW_USEDEFAULT, CW_USEDEFAULT, NULL, NULL, hInstance, NULL); } /* *---------------------------------------------------------------------- * * WinIcoDestroy -- * |
︙ | ︙ | |||
856 857 858 859 860 861 862 | { IcoInterpInfo *icoInterpPtr = (IcoInterpInfo*) clientData; IcoInterpInfo *prevIcoInterpPtr; IcoInfo *icoPtr; IcoInfo *nextPtr; if (eventPtr->type != DestroyNotify) { | | | | | | | | | | | 856 857 858 859 860 861 862 863 864 865 866 867 868 869 870 871 872 873 874 875 876 877 878 879 880 881 882 883 884 885 886 | { IcoInterpInfo *icoInterpPtr = (IcoInterpInfo*) clientData; IcoInterpInfo *prevIcoInterpPtr; IcoInfo *icoPtr; IcoInfo *nextPtr; if (eventPtr->type != DestroyNotify) { return; } if (firstIcoInterpPtr == icoInterpPtr) { firstIcoInterpPtr = icoInterpPtr->nextPtr; } else { 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); } ckfree(icoInterpPtr); } /* *---------------------------------------------------------------------- * |
︙ | ︙ | |||
901 902 903 904 905 906 907 | WinSystrayCmd( void *clientData, Tcl_Interp *interp, int objc, Tcl_Obj *const objv[]) { static const char *const cmdStrings[] = { | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | 901 902 903 904 905 906 907 908 909 910 911 912 913 914 915 916 917 918 919 920 921 922 923 924 925 926 927 928 929 930 931 932 933 934 935 936 937 938 939 940 941 942 943 944 945 946 947 948 949 950 951 952 953 954 955 956 957 958 959 960 961 962 963 964 965 966 967 968 969 970 971 972 973 974 975 976 977 978 979 980 981 982 983 984 985 986 987 988 989 990 991 992 993 994 995 996 997 998 999 1000 1001 1002 1003 1004 1005 1006 1007 1008 1009 1010 1011 1012 1013 1014 1015 1016 1017 1018 1019 1020 1021 1022 1023 1024 1025 1026 1027 1028 1029 1030 1031 1032 1033 1034 1035 1036 1037 1038 1039 1040 1041 1042 1043 1044 1045 1046 1047 | WinSystrayCmd( void *clientData, Tcl_Interp *interp, int objc, Tcl_Obj *const objv[]) { static const char *const cmdStrings[] = { "add", "delete", "modify", NULL }; enum { CMD_ADD, CMD_DELETE, CMD_MODIFY }; static const char *const optStrings[] = { "-callback", "-image", "-text", NULL }; enum { OPT_CALLBACK, OPT_IMAGE, OPT_TEXT }; int cmd, opt; HICON hIcon; int i; IcoInterpInfo *icoInterpPtr = (IcoInterpInfo*) clientData; IcoInfo *icoPtr = NULL; if (objc < 2) { Tcl_WrongNumArgs(interp, 1, objv, "command ..."); return TCL_ERROR; } if (Tcl_GetIndexFromObj(interp, objv[1], cmdStrings, "command", 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; } return TCL_OK; } /* *---------------------------------------------------------------------- * |
︙ | ︙ | |||
1070 1071 1072 1073 1074 1075 1076 | Tcl_DString infodst; Tcl_DString titledst; NOTIFYICONDATAW ni; char *msgtitle; char *msginfo; if (objc < 2) { | | | | | | | | | | | | | | | | | | | | 1070 1071 1072 1073 1074 1075 1076 1077 1078 1079 1080 1081 1082 1083 1084 1085 1086 1087 1088 1089 1090 1091 1092 1093 1094 1095 1096 1097 1098 1099 1100 1101 1102 1103 1104 1105 1106 1107 1108 1109 1110 1111 1112 1113 1114 1115 1116 1117 1118 1119 1120 1121 1122 1123 1124 1125 1126 | Tcl_DString infodst; Tcl_DString titledst; NOTIFYICONDATAW ni; char *msgtitle; char *msginfo; if (objc < 2) { 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; } if (objc != 5) { 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; } ni.cbSize = sizeof(NOTIFYICONDATAW); ni.hWnd = icoInterpPtr->hwnd; ni.uID = icoPtr->id; ni.uFlags = NIF_INFO; ni.uCallbackMessage = ICON_MESSAGE; ni.hIcon = icoPtr->hIcon; ni.dwInfoFlags = NIIF_INFO; /* Use a sane platform-specific icon here.*/ msgtitle = Tcl_GetString(objv[3]); msginfo = Tcl_GetString(objv[4]); /* 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); } 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); } Shell_NotifyIconW(NIM_MODIFY, &ni); return TCL_OK; } /* |
︙ | ︙ | |||
1144 1145 1146 1147 1148 1149 1150 | Tcl_Interp *interp) { IcoInterpInfo *icoInterpPtr; Tk_Window mainWindow; mainWindow = Tk_MainWindow(interp); if (mainWindow == NULL) { | | | | | | | 1144 1145 1146 1147 1148 1149 1150 1151 1152 1153 1154 1155 1156 1157 1158 1159 1160 1161 1162 1163 1164 1165 1166 1167 1168 1169 1170 1171 1172 1173 1174 1175 1176 1177 | Tcl_Interp *interp) { IcoInterpInfo *icoInterpPtr; Tk_Window mainWindow; mainWindow = Tk_MainWindow(interp); if (mainWindow == NULL) { Tcl_SetObjResult(interp, Tcl_NewStringObj("main window has been destroyed", TCL_INDEX_NONE)); return TCL_ERROR; } icoInterpPtr = (IcoInterpInfo*) ckalloc(sizeof(IcoInterpInfo)); icoInterpPtr->counter = 0; icoInterpPtr->firstIcoPtr = NULL; icoInterpPtr->hwnd = CreateTaskbarHandlerWindow(); icoInterpPtr->nextPtr = firstIcoInterpPtr; firstIcoInterpPtr = icoInterpPtr; Tcl_CreateObjCommand(interp, "::tk::systray::_systray", WinSystrayCmd, icoInterpPtr, NULL); Tcl_CreateObjCommand(interp, "::tk::sysnotify::_sysnotify", WinSysNotifyCmd, icoInterpPtr, NULL); Tk_CreateEventHandler(mainWindow, StructureNotifyMask, WinIcoDestroy, icoInterpPtr); return TCL_OK; } /* * Local variables: * mode: c * indent-tabs-mode: nil * End: */ |
Changes to win/tkWinTest.c.
︙ | ︙ | |||
94 95 96 97 98 99 100 | */ HWND TestFindControl(HWND root, int id) { struct TestFindControlState fcs; fcs.control = GetDlgItem(root, id); if (fcs.control == NULL) { | | | | | | 94 95 96 97 98 99 100 101 102 103 104 105 106 107 108 109 110 111 | */ HWND TestFindControl(HWND root, int id) { struct TestFindControlState fcs; 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); } return fcs.control; } /* *---------------------------------------------------------------------- |
︙ | ︙ | |||
356 357 358 359 360 361 362 | case WM_GETTEXT: { Tcl_DString ds; char buf[256]; #if 0 GetDlgItemTextA(hwnd, id, buf, 256); #else | | | | | | | | | | | 356 357 358 359 360 361 362 363 364 365 366 367 368 369 370 371 372 373 374 375 376 377 378 | case WM_GETTEXT: { Tcl_DString ds; char buf[256]; #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); #endif Tcl_AppendResult(interp, Tcl_ExternalToUtfDString(NULL, buf, TCL_INDEX_NONE, &ds), NULL); Tcl_DStringFree(&ds); break; } case WM_SETTEXT: { Tcl_DString ds; |
︙ | ︙ | |||
439 440 441 442 443 444 445 | int r = TCL_OK; DWORD myPid; Tcl_DStringInit(&classString); Tcl_DStringInit(&titleString); if (objc < 2 || objc > 3) { | | | | | | | | | | | | | | | | | | 439 440 441 442 443 444 445 446 447 448 449 450 451 452 453 454 455 456 457 458 459 460 461 462 463 464 465 466 467 468 469 470 471 472 473 474 475 476 477 478 479 480 481 482 483 484 485 486 487 488 | int r = TCL_OK; DWORD myPid; Tcl_DStringInit(&classString); Tcl_DStringInit(&titleString); if (objc < 2 || objc > 3) { Tcl_WrongNumArgs(interp, 1, objv, "title ?class?"); return TCL_ERROR; } Tcl_DStringInit(&titleString); title = Tcl_UtfToWCharDString(Tcl_GetString(objv[1]), TCL_INDEX_NONE, &titleString); if (objc == 3) { Tcl_DStringInit(&classString); windowClass = Tcl_UtfToWCharDString(Tcl_GetString(objv[2]), TCL_INDEX_NONE, &classString); } if (title[0] == 0) 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 */ } if (hwnd == NULL) { Tcl_SetObjResult(interp, Tcl_NewStringObj("failed to find window: ", TCL_INDEX_NONE)); AppendSystemError(interp, GetLastError()); r = TCL_ERROR; } else { Tcl_SetObjResult(interp, Tcl_NewWideIntObj(PTR2INT(hwnd))); } Tcl_DStringFree(&titleString); Tcl_DStringFree(&classString); return r; } |
︙ | ︙ |
Changes to win/tkWinX.c.
︙ | ︙ | |||
802 803 804 805 806 807 808 | case TK_SETMENU: case TK_STATE: case TK_INFO: result = TkWinEmbeddedEventProc(hwnd, message, wParam, lParam); break; case WM_UNICHAR: | | | | | | 802 803 804 805 806 807 808 809 810 811 812 813 814 815 816 817 818 819 820 821 822 823 824 825 | case TK_SETMENU: case TK_STATE: case TK_INFO: result = TkWinEmbeddedEventProc(hwnd, message, wParam, lParam); break; case WM_UNICHAR: 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; } else { result = 1; } } break; default: if (!TkTranslateWinEvent(hwnd, message, wParam, lParam, &result)) { result = DefWindowProcW(hwnd, message, wParam, lParam); |
︙ | ︙ | |||
868 869 870 871 872 873 874 | if (winPtr) { TkWinClipboardRender(winPtr->dispPtr, wParam); } return 1; } case WM_RENDERALLFORMATS: { | | | | | | | | | | | | | | 868 869 870 871 872 873 874 875 876 877 878 879 880 881 882 883 884 885 886 887 888 889 890 891 892 893 894 895 | if (winPtr) { TkWinClipboardRender(winPtr->dispPtr, wParam); } return 1; } 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; } case WM_COMMAND: case WM_NOTIFY: case WM_VSCROLL: case WM_HSCROLL: { /* |
︙ | ︙ | |||
1217 1218 1219 1220 1221 1222 1223 | * MBCS characters that came from the TranslateMessage call. */ event.x.type = KeyPress; event.x.xany.send_event = -1; event.x.xkey.keycode = wParam; GetTranslatedKey(&event.key, (message == WM_KEYDOWN) ? WM_CHAR : | | | 1217 1218 1219 1220 1221 1222 1223 1224 1225 1226 1227 1228 1229 1230 1231 | * MBCS characters that came from the TranslateMessage call. */ event.x.type = KeyPress; event.x.xany.send_event = -1; event.x.xkey.keycode = wParam; GetTranslatedKey(&event.key, (message == WM_KEYDOWN) ? WM_CHAR : WM_SYSCHAR); break; case WM_SYSKEYUP: case WM_KEYUP: /* * We don't check for translated characters on keyup because Tk * won't know what to do with them. Instead, we wait for the |
︙ | ︙ | |||
1290 1291 1292 1293 1294 1295 1296 | event.key.nbytes = 1; event.key.trans_chars[0] = (char) wParam; if (IsDBCSLeadByte((BYTE) wParam)) { MSG msg; if ((PeekMessageW(&msg, NULL, WM_CHAR, WM_CHAR, | | | 1290 1291 1292 1293 1294 1295 1296 1297 1298 1299 1300 1301 1302 1303 1304 | event.key.nbytes = 1; event.key.trans_chars[0] = (char) wParam; if (IsDBCSLeadByte((BYTE) wParam)) { MSG msg; if ((PeekMessageW(&msg, NULL, WM_CHAR, WM_CHAR, PM_NOREMOVE) != 0) && (msg.message == WM_CHAR)) { GetMessageW(&msg, NULL, WM_CHAR, WM_CHAR); event.key.nbytes = 2; event.key.trans_chars[1] = (char) msg.wParam; } } } |
︙ | ︙ |