Many hyperlinks are disabled.
Use anonymous login
to enable hyperlinks.
Changes In Branch tk-cocoa-8-5-backport Excluding Merge-Ins
This is equivalent to a diff from df2abb1c to 77b3f433
2012-09-13
| ||
20:47 | [Bug 3567453]: Clip regions must be cleared with XSetClipMask and not TkSetRegion on X11. check-in: dfcf8982 user: dkf tags: core-8-5-branch | |
2012-09-12
| ||
13:44 | merge core-8-5-branch Closed-Leaf check-in: 77b3f433 user: jan.nijtmans tags: tk-cocoa-8-5-backport | |
03:05 | Review branch for merge of Tk-Cocoa into Tk 8.5 main branch check-in: 7f1b01b5 user: kevin_walzer tags: cocoa-full-merge-review-8.5 | |
2012-09-11
| ||
19:03 | [Bug 3566594]: Fix clipping problem in classic X11; clip regions were leaking in reused GCs. check-in: dda82bdc user: dkf tags: trunk | |
19:00 | [Bug 3566594]: Fix clipping problem in classic X11; clip regions were leaking in reused GCs. check-in: df2abb1c user: dkf tags: core-8-5-branch | |
2012-08-28
| ||
20:40 | Merged inadvertent split back into one. check-in: 4d77650e user: andreask tags: tk-cocoa-8-5-backport | |
14:12 | [Bug 3562426]: Context menu goes out of edge of screen. check-in: 13c14cc5 user: jan.nijtmans tags: core-8-5-branch | |
Changes to ChangeLog.
1 2 3 4 5 6 7 8 9 10 11 12 13 14 | 2012-09-11 Donal K. Fellows <[email protected]> * generic/ttk/ttkEntry.c (EntryDisplay): [Bug 3566594]: Must manually * generic/ttk/ttkLabel.c (TextDraw): reset the clip region of GCs when not using the Xft font renderer (well, especially on classic X11) because the GC sharing code doesn't take into account clip handling. Thanks to Christian Nassau for identifying the problem. 2012-08-28 Jan Nijtmans <[email protected]> * generic/tkMenuDraw.c: [Bug 3562426]: Context menu goes out of edge of screen. 2012-08-24 Donal K. Fellows <[email protected]> | > > > > > > > > > | 1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 | 2012-09-11 Donal K. Fellows <[email protected]> * generic/ttk/ttkEntry.c (EntryDisplay): [Bug 3566594]: Must manually * generic/ttk/ttkLabel.c (TextDraw): reset the clip region of GCs when not using the Xft font renderer (well, especially on classic X11) because the GC sharing code doesn't take into account clip handling. Thanks to Christian Nassau for identifying the problem. 2012-08-28 Andreas Kupries <[email protected]> Cherrypick Merge, Backport of [6223d9e067]. See trunk 2012-05-29 Donal K. Fellows * generic/tkInt.decls (TkMacOSXDrawable): Added OSX-specific mechanism to allow retrieval of the drawing surface. Allows Canvas3d to be adapted to 8.6. 2012-08-28 Jan Nijtmans <[email protected]> * generic/tkMenuDraw.c: [Bug 3562426]: Context menu goes out of edge of screen. 2012-08-24 Donal K. Fellows <[email protected]> |
︙ | ︙ |
Changes to generic/tk.decls.
︙ | ︙ | |||
1123 1124 1125 1126 1127 1128 1129 | void TkGenWMConfigureEvent(Tk_Window tkwin, int x, int y, int width, int height, int flags) } declare 6 aqua { void TkMacOSXInvalClipRgns(Tk_Window tkwin) } declare 7 aqua { | | | | 1123 1124 1125 1126 1127 1128 1129 1130 1131 1132 1133 1134 1135 1136 1137 1138 1139 1140 | void TkGenWMConfigureEvent(Tk_Window tkwin, int x, int y, int width, int height, int flags) } declare 6 aqua { void TkMacOSXInvalClipRgns(Tk_Window tkwin) } declare 7 aqua { void *TkMacOSXGetDrawablePort(Drawable drawable) } declare 8 aqua { void *TkMacOSXGetRootControl(Drawable drawable) } declare 9 aqua { void Tk_MacOSXSetupTkNotifier(void) } declare 10 aqua { int Tk_MacOSXIsAppInFront(void) } |
︙ | ︙ |
Changes to generic/tkInt.decls.
︙ | ︙ | |||
830 831 832 833 834 835 836 | # removed duplicate from tkPlat table(tk.decls) #declare 13 aqua { # void TkMacOSXInvalClipRgns(TkWindow *winPtr) #} declare 14 aqua { | | | | | | 830 831 832 833 834 835 836 837 838 839 840 841 842 843 844 845 846 847 848 849 850 851 852 853 854 855 856 857 858 859 | # removed duplicate from tkPlat table(tk.decls) #declare 13 aqua { # void TkMacOSXInvalClipRgns(TkWindow *winPtr) #} declare 14 aqua { int TkMacOSXDoHLEvent(void *theEvent) } # removed duplicate from tkPlat table(tk.decls) #declare 15 aqua { # GWorldPtr TkMacOSXGetDrawablePort(Drawable drawable) #} declare 16 aqua { Window TkMacOSXGetXWindow(void *macWinPtr) } declare 17 aqua { int TkMacOSXGrowToplevel(void *whichWindow, XPoint start) } declare 18 aqua { void TkMacOSXHandleMenuSelect(short theMenu, unsigned short theItem, int optionKeyPressed) } # removed duplicates from tkPlat table(tk.decls) #declare 19 aqua { # void TkMacOSXInitAppleEvents(Tcl_Interp *interp) #} |
︙ | ︙ | |||
868 869 870 871 872 873 874 | declare 22 aqua { int TkMacOSXIsCharacterMissing(Tk_Font tkfont, unsigned int searchChar) } declare 23 aqua { void TkMacOSXMakeRealWindowExist(TkWindow *winPtr) } declare 24 aqua { | | | | | | | | | | | | 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 896 897 898 899 900 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 | declare 22 aqua { int TkMacOSXIsCharacterMissing(Tk_Font tkfont, unsigned int searchChar) } declare 23 aqua { void TkMacOSXMakeRealWindowExist(TkWindow *winPtr) } declare 24 aqua { void *TkMacOSXMakeStippleMap(Drawable d1, Drawable d2) } declare 25 aqua { void TkMacOSXMenuClick(void) } declare 26 aqua { void TkMacOSXRegisterOffScreenWindow(Window window, void *portPtr) } declare 27 aqua { int TkMacOSXResizable(TkWindow *winPtr) } declare 28 aqua { void TkMacOSXSetHelpMenuItemCount(void) } declare 29 aqua { void TkMacOSXSetScrollbarGrow(TkWindow *winPtr, int flag) } declare 30 aqua { void TkMacOSXSetUpClippingRgn(Drawable drawable) } declare 31 aqua { void TkMacOSXSetUpGraphicsPort(GC gc, void *destPort) } declare 32 aqua { void TkMacOSXUpdateClipRgn(TkWindow *winPtr) } declare 33 aqua { void TkMacOSXUnregisterMacWindow(void *portPtr) } declare 34 aqua { int TkMacOSXUseMenuID(short macID) } declare 35 aqua { TkRegion TkMacOSXVisableClipRgn(TkWindow *winPtr) } declare 36 aqua { void TkMacOSXWinBounds(TkWindow *winPtr, void *geometry) } declare 37 aqua { void TkMacOSXWindowOffset(void *wRef, int *xOffset, int *yOffset) } declare 38 aqua { int TkSetMacColor(unsigned long pixel, void *macColor) } declare 39 aqua { void TkSetWMName(TkWindow *winPtr, Tk_Uid titleUid) } declare 40 aqua { void TkSuspendClipboard(void) } declare 41 aqua { int TkMacOSXZoomToplevel(void *whichWindow, short zoomPart) } declare 42 aqua { Tk_Window Tk_TopCoordsToWindow(Tk_Window tkwin, int rootX, int rootY, int *newX, int *newY) } declare 43 aqua { MacDrawable *TkMacOSXContainerId(TkWindow *winPtr) } declare 44 aqua { MacDrawable *TkMacOSXGetHostToplevel(TkWindow *winPtr) } declare 45 aqua { void TkMacOSXPreprocessMenu(void) } declare 46 aqua { int TkpIsWindowFloating(void *window) } declare 47 aqua { Tk_Window TkMacOSXGetCapture(void) } declare 49 aqua { Window TkGetTransientMaster(TkWindow *winPtr) } |
︙ | ︙ | |||
959 960 961 962 963 964 965 966 967 968 969 970 971 972 | # void TkGenWMConfigureEvent(Tk_Window tkwin, int x, int y, # int width, int height, int flags) #} declare 53 aqua { unsigned long TkpGetMS(void) } ############################################################################## # Define the platform specific internal Xlib interfaces. These functions are # only available on the designated platform. interface tkIntXlib | > > > > > | 959 960 961 962 963 964 965 966 967 968 969 970 971 972 973 974 975 976 977 | # void TkGenWMConfigureEvent(Tk_Window tkwin, int x, int y, # int width, int height, int flags) #} declare 53 aqua { unsigned long TkpGetMS(void) } # For Canvas3d, requested by Sean Woods declare 54 aqua { void *TkMacOSXDrawable(Drawable drawable) } ############################################################################## # Define the platform specific internal Xlib interfaces. These functions are # only available on the designated platform. interface tkIntXlib |
︙ | ︙ |
Changes to generic/tkIntPlatDecls.h.
︙ | ︙ | |||
333 334 335 336 337 338 339 | /* 12 */ EXTERN void TkMacOSXHandleTearoffMenu(void); #endif /* Slot 13 is reserved */ #ifndef TkMacOSXDoHLEvent_TCL_DECLARED #define TkMacOSXDoHLEvent_TCL_DECLARED /* 14 */ | | | | < | | | 333 334 335 336 337 338 339 340 341 342 343 344 345 346 347 348 349 350 351 352 353 354 355 356 357 358 359 360 361 362 363 364 | /* 12 */ EXTERN void TkMacOSXHandleTearoffMenu(void); #endif /* Slot 13 is reserved */ #ifndef TkMacOSXDoHLEvent_TCL_DECLARED #define TkMacOSXDoHLEvent_TCL_DECLARED /* 14 */ EXTERN int TkMacOSXDoHLEvent(VOID *theEvent); #endif /* Slot 15 is reserved */ #ifndef TkMacOSXGetXWindow_TCL_DECLARED #define TkMacOSXGetXWindow_TCL_DECLARED /* 16 */ EXTERN Window TkMacOSXGetXWindow(VOID *macWinPtr); #endif #ifndef TkMacOSXGrowToplevel_TCL_DECLARED #define TkMacOSXGrowToplevel_TCL_DECLARED /* 17 */ EXTERN int TkMacOSXGrowToplevel(VOID *whichWindow, XPoint start); #endif #ifndef TkMacOSXHandleMenuSelect_TCL_DECLARED #define TkMacOSXHandleMenuSelect_TCL_DECLARED /* 18 */ EXTERN void TkMacOSXHandleMenuSelect(short theMenu, unsigned short theItem, int optionKeyPressed); #endif /* Slot 19 is reserved */ /* Slot 20 is reserved */ #ifndef TkMacOSXInvalidateWindow_TCL_DECLARED #define TkMacOSXInvalidateWindow_TCL_DECLARED /* 21 */ EXTERN void TkMacOSXInvalidateWindow(MacDrawable *macWin, |
︙ | ︙ | |||
375 376 377 378 379 380 381 | #define TkMacOSXMakeRealWindowExist_TCL_DECLARED /* 23 */ EXTERN void TkMacOSXMakeRealWindowExist(TkWindow *winPtr); #endif #ifndef TkMacOSXMakeStippleMap_TCL_DECLARED #define TkMacOSXMakeStippleMap_TCL_DECLARED /* 24 */ | | | | 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 | #define TkMacOSXMakeRealWindowExist_TCL_DECLARED /* 23 */ EXTERN void TkMacOSXMakeRealWindowExist(TkWindow *winPtr); #endif #ifndef TkMacOSXMakeStippleMap_TCL_DECLARED #define TkMacOSXMakeStippleMap_TCL_DECLARED /* 24 */ EXTERN VOID * TkMacOSXMakeStippleMap(Drawable d1, Drawable d2); #endif #ifndef TkMacOSXMenuClick_TCL_DECLARED #define TkMacOSXMenuClick_TCL_DECLARED /* 25 */ EXTERN void TkMacOSXMenuClick(void); #endif #ifndef TkMacOSXRegisterOffScreenWindow_TCL_DECLARED #define TkMacOSXRegisterOffScreenWindow_TCL_DECLARED /* 26 */ EXTERN void TkMacOSXRegisterOffScreenWindow(Window window, VOID *portPtr); #endif #ifndef TkMacOSXResizable_TCL_DECLARED #define TkMacOSXResizable_TCL_DECLARED /* 27 */ EXTERN int TkMacOSXResizable(TkWindow *winPtr); #endif #ifndef TkMacOSXSetHelpMenuItemCount_TCL_DECLARED |
︙ | ︙ | |||
411 412 413 414 415 416 417 | #define TkMacOSXSetUpClippingRgn_TCL_DECLARED /* 30 */ EXTERN void TkMacOSXSetUpClippingRgn(Drawable drawable); #endif #ifndef TkMacOSXSetUpGraphicsPort_TCL_DECLARED #define TkMacOSXSetUpGraphicsPort_TCL_DECLARED /* 31 */ | | | | | | | < | | 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 | #define TkMacOSXSetUpClippingRgn_TCL_DECLARED /* 30 */ EXTERN void TkMacOSXSetUpClippingRgn(Drawable drawable); #endif #ifndef TkMacOSXSetUpGraphicsPort_TCL_DECLARED #define TkMacOSXSetUpGraphicsPort_TCL_DECLARED /* 31 */ EXTERN void TkMacOSXSetUpGraphicsPort(GC gc, VOID *destPort); #endif #ifndef TkMacOSXUpdateClipRgn_TCL_DECLARED #define TkMacOSXUpdateClipRgn_TCL_DECLARED /* 32 */ EXTERN void TkMacOSXUpdateClipRgn(TkWindow *winPtr); #endif #ifndef TkMacOSXUnregisterMacWindow_TCL_DECLARED #define TkMacOSXUnregisterMacWindow_TCL_DECLARED /* 33 */ EXTERN void TkMacOSXUnregisterMacWindow(VOID *portPtr); #endif #ifndef TkMacOSXUseMenuID_TCL_DECLARED #define TkMacOSXUseMenuID_TCL_DECLARED /* 34 */ EXTERN int TkMacOSXUseMenuID(short macID); #endif #ifndef TkMacOSXVisableClipRgn_TCL_DECLARED #define TkMacOSXVisableClipRgn_TCL_DECLARED /* 35 */ EXTERN TkRegion TkMacOSXVisableClipRgn(TkWindow *winPtr); #endif #ifndef TkMacOSXWinBounds_TCL_DECLARED #define TkMacOSXWinBounds_TCL_DECLARED /* 36 */ EXTERN void TkMacOSXWinBounds(TkWindow *winPtr, VOID *geometry); #endif #ifndef TkMacOSXWindowOffset_TCL_DECLARED #define TkMacOSXWindowOffset_TCL_DECLARED /* 37 */ EXTERN void TkMacOSXWindowOffset(VOID *wRef, int *xOffset, int *yOffset); #endif #ifndef TkSetMacColor_TCL_DECLARED #define TkSetMacColor_TCL_DECLARED /* 38 */ EXTERN int TkSetMacColor(unsigned long pixel, VOID *macColor); #endif #ifndef TkSetWMName_TCL_DECLARED #define TkSetWMName_TCL_DECLARED /* 39 */ EXTERN void TkSetWMName(TkWindow *winPtr, Tk_Uid titleUid); #endif #ifndef TkSuspendClipboard_TCL_DECLARED #define TkSuspendClipboard_TCL_DECLARED /* 40 */ EXTERN void TkSuspendClipboard(void); #endif #ifndef TkMacOSXZoomToplevel_TCL_DECLARED #define TkMacOSXZoomToplevel_TCL_DECLARED /* 41 */ EXTERN int TkMacOSXZoomToplevel(VOID *whichWindow, short zoomPart); #endif #ifndef Tk_TopCoordsToWindow_TCL_DECLARED #define Tk_TopCoordsToWindow_TCL_DECLARED /* 42 */ EXTERN Tk_Window Tk_TopCoordsToWindow(Tk_Window tkwin, int rootX, int rootY, int *newX, int *newY); |
︙ | ︙ | |||
490 491 492 493 494 495 496 | #define TkMacOSXPreprocessMenu_TCL_DECLARED /* 45 */ EXTERN void TkMacOSXPreprocessMenu(void); #endif #ifndef TkpIsWindowFloating_TCL_DECLARED #define TkpIsWindowFloating_TCL_DECLARED /* 46 */ | | | 488 489 490 491 492 493 494 495 496 497 498 499 500 501 502 | #define TkMacOSXPreprocessMenu_TCL_DECLARED /* 45 */ EXTERN void TkMacOSXPreprocessMenu(void); #endif #ifndef TkpIsWindowFloating_TCL_DECLARED #define TkpIsWindowFloating_TCL_DECLARED /* 46 */ EXTERN int TkpIsWindowFloating(VOID *window); #endif #ifndef TkMacOSXGetCapture_TCL_DECLARED #define TkMacOSXGetCapture_TCL_DECLARED /* 47 */ EXTERN Tk_Window TkMacOSXGetCapture(void); #endif /* Slot 48 is reserved */ |
︙ | ︙ | |||
520 521 522 523 524 525 526 527 528 529 530 531 532 533 | #endif /* Slot 52 is reserved */ #ifndef TkpGetMS_TCL_DECLARED #define TkpGetMS_TCL_DECLARED /* 53 */ EXTERN unsigned long TkpGetMS(void); #endif #endif /* AQUA */ #if !(defined(__WIN32__) || defined(__CYGWIN__) || defined(MAC_OSX_TK)) /* X11 */ #ifndef TkCreateXEventSource_TCL_DECLARED #define TkCreateXEventSource_TCL_DECLARED /* 0 */ EXTERN void TkCreateXEventSource(void); #endif | > > > > > | 518 519 520 521 522 523 524 525 526 527 528 529 530 531 532 533 534 535 536 | #endif /* Slot 52 is reserved */ #ifndef TkpGetMS_TCL_DECLARED #define TkpGetMS_TCL_DECLARED /* 53 */ EXTERN unsigned long TkpGetMS(void); #endif #ifndef TkMacOSXDrawable_TCL_DECLARED #define TkMacOSXDrawable_TCL_DECLARED /* 54 */ EXTERN VOID * TkMacOSXDrawable(Drawable drawable); #endif #endif /* AQUA */ #if !(defined(__WIN32__) || defined(__CYGWIN__) || defined(MAC_OSX_TK)) /* X11 */ #ifndef TkCreateXEventSource_TCL_DECLARED #define TkCreateXEventSource_TCL_DECLARED /* 0 */ EXTERN void TkCreateXEventSource(void); #endif |
︙ | ︙ | |||
664 665 666 667 668 669 670 | void (*tkAboutDlg) (void); /* 7 */ unsigned int (*tkMacOSXButtonKeyState) (void); /* 8 */ void (*tkMacOSXClearMenubarActive) (void); /* 9 */ int (*tkMacOSXDispatchMenuEvent) (int menuID, int index); /* 10 */ void (*tkMacOSXInstallCursor) (int resizeOverride); /* 11 */ void (*tkMacOSXHandleTearoffMenu) (void); /* 12 */ VOID *reserved13; | | | | | | | | | | | | | | | > | 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 703 704 705 706 707 708 709 710 711 712 713 714 715 716 717 718 719 720 721 | void (*tkAboutDlg) (void); /* 7 */ unsigned int (*tkMacOSXButtonKeyState) (void); /* 8 */ void (*tkMacOSXClearMenubarActive) (void); /* 9 */ int (*tkMacOSXDispatchMenuEvent) (int menuID, int index); /* 10 */ void (*tkMacOSXInstallCursor) (int resizeOverride); /* 11 */ void (*tkMacOSXHandleTearoffMenu) (void); /* 12 */ VOID *reserved13; int (*tkMacOSXDoHLEvent) (VOID *theEvent); /* 14 */ VOID *reserved15; Window (*tkMacOSXGetXWindow) (VOID *macWinPtr); /* 16 */ int (*tkMacOSXGrowToplevel) (VOID *whichWindow, XPoint start); /* 17 */ void (*tkMacOSXHandleMenuSelect) (short theMenu, unsigned short theItem, int optionKeyPressed); /* 18 */ VOID *reserved19; VOID *reserved20; void (*tkMacOSXInvalidateWindow) (MacDrawable *macWin, int flag); /* 21 */ int (*tkMacOSXIsCharacterMissing) (Tk_Font tkfont, unsigned int searchChar); /* 22 */ void (*tkMacOSXMakeRealWindowExist) (TkWindow *winPtr); /* 23 */ VOID * (*tkMacOSXMakeStippleMap) (Drawable d1, Drawable d2); /* 24 */ void (*tkMacOSXMenuClick) (void); /* 25 */ void (*tkMacOSXRegisterOffScreenWindow) (Window window, VOID *portPtr); /* 26 */ int (*tkMacOSXResizable) (TkWindow *winPtr); /* 27 */ void (*tkMacOSXSetHelpMenuItemCount) (void); /* 28 */ void (*tkMacOSXSetScrollbarGrow) (TkWindow *winPtr, int flag); /* 29 */ void (*tkMacOSXSetUpClippingRgn) (Drawable drawable); /* 30 */ void (*tkMacOSXSetUpGraphicsPort) (GC gc, VOID *destPort); /* 31 */ void (*tkMacOSXUpdateClipRgn) (TkWindow *winPtr); /* 32 */ void (*tkMacOSXUnregisterMacWindow) (VOID *portPtr); /* 33 */ int (*tkMacOSXUseMenuID) (short macID); /* 34 */ TkRegion (*tkMacOSXVisableClipRgn) (TkWindow *winPtr); /* 35 */ void (*tkMacOSXWinBounds) (TkWindow *winPtr, VOID *geometry); /* 36 */ void (*tkMacOSXWindowOffset) (VOID *wRef, int *xOffset, int *yOffset); /* 37 */ int (*tkSetMacColor) (unsigned long pixel, VOID *macColor); /* 38 */ void (*tkSetWMName) (TkWindow *winPtr, Tk_Uid titleUid); /* 39 */ void (*tkSuspendClipboard) (void); /* 40 */ int (*tkMacOSXZoomToplevel) (VOID *whichWindow, short zoomPart); /* 41 */ Tk_Window (*tk_TopCoordsToWindow) (Tk_Window tkwin, int rootX, int rootY, int *newX, int *newY); /* 42 */ MacDrawable * (*tkMacOSXContainerId) (TkWindow *winPtr); /* 43 */ MacDrawable * (*tkMacOSXGetHostToplevel) (TkWindow *winPtr); /* 44 */ void (*tkMacOSXPreprocessMenu) (void); /* 45 */ int (*tkpIsWindowFloating) (VOID *window); /* 46 */ Tk_Window (*tkMacOSXGetCapture) (void); /* 47 */ VOID *reserved48; Window (*tkGetTransientMaster) (TkWindow *winPtr); /* 49 */ int (*tkGenerateButtonEvent) (int x, int y, Window window, unsigned int state); /* 50 */ void (*tkGenWMDestroyEvent) (Tk_Window tkwin); /* 51 */ VOID *reserved52; unsigned long (*tkpGetMS) (void); /* 53 */ VOID * (*tkMacOSXDrawable) (Drawable drawable); /* 54 */ #endif /* AQUA */ #if !(defined(__WIN32__) || defined(__CYGWIN__) || defined(MAC_OSX_TK)) /* X11 */ void (*tkCreateXEventSource) (void); /* 0 */ void (*tkFreeWindowId) (TkDisplay *dispPtr, Window w); /* 1 */ void (*tkInitXId) (TkDisplay *dispPtr); /* 2 */ int (*tkpCmapStressed) (Tk_Window tkwin, Colormap colormap); /* 3 */ void (*tkpSync) (Display *display); /* 4 */ |
︙ | ︙ | |||
1113 1114 1115 1116 1117 1118 1119 1120 1121 1122 1123 1124 1125 1126 | (tkIntPlatStubsPtr->tkGenWMDestroyEvent) /* 51 */ #endif /* Slot 52 is reserved */ #ifndef TkpGetMS #define TkpGetMS \ (tkIntPlatStubsPtr->tkpGetMS) /* 53 */ #endif #endif /* AQUA */ #if !(defined(__WIN32__) || defined(__CYGWIN__) || defined(MAC_OSX_TK)) /* X11 */ #ifndef TkCreateXEventSource #define TkCreateXEventSource \ (tkIntPlatStubsPtr->tkCreateXEventSource) /* 0 */ #endif #ifndef TkFreeWindowId | > > > > | 1117 1118 1119 1120 1121 1122 1123 1124 1125 1126 1127 1128 1129 1130 1131 1132 1133 1134 | (tkIntPlatStubsPtr->tkGenWMDestroyEvent) /* 51 */ #endif /* Slot 52 is reserved */ #ifndef TkpGetMS #define TkpGetMS \ (tkIntPlatStubsPtr->tkpGetMS) /* 53 */ #endif #ifndef TkMacOSXDrawable #define TkMacOSXDrawable \ (tkIntPlatStubsPtr->tkMacOSXDrawable) /* 54 */ #endif #endif /* AQUA */ #if !(defined(__WIN32__) || defined(__CYGWIN__) || defined(MAC_OSX_TK)) /* X11 */ #ifndef TkCreateXEventSource #define TkCreateXEventSource \ (tkIntPlatStubsPtr->tkCreateXEventSource) /* 0 */ #endif #ifndef TkFreeWindowId |
︙ | ︙ |
Changes to generic/tkPlatDecls.h.
︙ | ︙ | |||
104 105 106 107 108 109 110 | #define TkMacOSXInvalClipRgns_TCL_DECLARED /* 6 */ EXTERN void TkMacOSXInvalClipRgns(Tk_Window tkwin); #endif #ifndef TkMacOSXGetDrawablePort_TCL_DECLARED #define TkMacOSXGetDrawablePort_TCL_DECLARED /* 7 */ | | | | 104 105 106 107 108 109 110 111 112 113 114 115 116 117 118 119 120 121 122 123 | #define TkMacOSXInvalClipRgns_TCL_DECLARED /* 6 */ EXTERN void TkMacOSXInvalClipRgns(Tk_Window tkwin); #endif #ifndef TkMacOSXGetDrawablePort_TCL_DECLARED #define TkMacOSXGetDrawablePort_TCL_DECLARED /* 7 */ EXTERN VOID * TkMacOSXGetDrawablePort(Drawable drawable); #endif #ifndef TkMacOSXGetRootControl_TCL_DECLARED #define TkMacOSXGetRootControl_TCL_DECLARED /* 8 */ EXTERN VOID * TkMacOSXGetRootControl(Drawable drawable); #endif #ifndef Tk_MacOSXSetupTkNotifier_TCL_DECLARED #define Tk_MacOSXSetupTkNotifier_TCL_DECLARED /* 9 */ EXTERN void Tk_MacOSXSetupTkNotifier(void); #endif #ifndef Tk_MacOSXIsAppInFront_TCL_DECLARED |
︙ | ︙ | |||
143 144 145 146 147 148 149 | void (*tk_MacOSXSetEmbedHandler) (Tk_MacOSXEmbedRegisterWinProc *registerWinProcPtr, Tk_MacOSXEmbedGetGrafPortProc *getPortProcPtr, Tk_MacOSXEmbedMakeContainerExistProc *containerExistProcPtr, Tk_MacOSXEmbedGetClipProc *getClipProc, Tk_MacOSXEmbedGetOffsetInParentProc *getOffsetProc); /* 0 */ void (*tk_MacOSXTurnOffMenus) (void); /* 1 */ void (*tk_MacOSXTkOwnsCursor) (int tkOwnsIt); /* 2 */ void (*tkMacOSXInitMenus) (Tcl_Interp *interp); /* 3 */ void (*tkMacOSXInitAppleEvents) (Tcl_Interp *interp); /* 4 */ void (*tkGenWMConfigureEvent) (Tk_Window tkwin, int x, int y, int width, int height, int flags); /* 5 */ void (*tkMacOSXInvalClipRgns) (Tk_Window tkwin); /* 6 */ | | | | 143 144 145 146 147 148 149 150 151 152 153 154 155 156 157 158 | void (*tk_MacOSXSetEmbedHandler) (Tk_MacOSXEmbedRegisterWinProc *registerWinProcPtr, Tk_MacOSXEmbedGetGrafPortProc *getPortProcPtr, Tk_MacOSXEmbedMakeContainerExistProc *containerExistProcPtr, Tk_MacOSXEmbedGetClipProc *getClipProc, Tk_MacOSXEmbedGetOffsetInParentProc *getOffsetProc); /* 0 */ void (*tk_MacOSXTurnOffMenus) (void); /* 1 */ void (*tk_MacOSXTkOwnsCursor) (int tkOwnsIt); /* 2 */ void (*tkMacOSXInitMenus) (Tcl_Interp *interp); /* 3 */ void (*tkMacOSXInitAppleEvents) (Tcl_Interp *interp); /* 4 */ void (*tkGenWMConfigureEvent) (Tk_Window tkwin, int x, int y, int width, int height, int flags); /* 5 */ void (*tkMacOSXInvalClipRgns) (Tk_Window tkwin); /* 6 */ VOID * (*tkMacOSXGetDrawablePort) (Drawable drawable); /* 7 */ VOID * (*tkMacOSXGetRootControl) (Drawable drawable); /* 8 */ void (*tk_MacOSXSetupTkNotifier) (void); /* 9 */ int (*tk_MacOSXIsAppInFront) (void); /* 10 */ #endif /* AQUA */ } TkPlatStubs; #ifdef __cplusplus extern "C" { |
︙ | ︙ |
Changes to generic/tkStubInit.c.
︙ | ︙ | |||
580 581 582 583 584 585 586 587 588 589 590 591 592 593 | TkMacOSXGetCapture, /* 47 */ NULL, /* 48 */ TkGetTransientMaster, /* 49 */ TkGenerateButtonEvent, /* 50 */ TkGenWMDestroyEvent, /* 51 */ NULL, /* 52 */ TkpGetMS, /* 53 */ #endif /* AQUA */ #if !(defined(__WIN32__) || defined(__CYGWIN__) || defined(MAC_OSX_TK)) /* X11 */ TkCreateXEventSource, /* 0 */ TkFreeWindowId, /* 1 */ TkInitXId, /* 2 */ TkpCmapStressed, /* 3 */ TkpSync, /* 4 */ | > | 580 581 582 583 584 585 586 587 588 589 590 591 592 593 594 | TkMacOSXGetCapture, /* 47 */ NULL, /* 48 */ TkGetTransientMaster, /* 49 */ TkGenerateButtonEvent, /* 50 */ TkGenWMDestroyEvent, /* 51 */ NULL, /* 52 */ TkpGetMS, /* 53 */ TkMacOSXDrawable, /* 54 */ #endif /* AQUA */ #if !(defined(__WIN32__) || defined(__CYGWIN__) || defined(MAC_OSX_TK)) /* X11 */ TkCreateXEventSource, /* 0 */ TkFreeWindowId, /* 1 */ TkInitXId, /* 2 */ TkpCmapStressed, /* 3 */ TkpSync, /* 4 */ |
︙ | ︙ |
Changes to macosx/README.
1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 | Tcl/Tk Mac OS X README ---------------------- This is the README file for the Mac OS X/Darwin version of Tcl/Tk. 1. Where to go for support -------------------------- - The tcl-mac mailing list on sourceforge is the best place to ask questions specific to Tcl & Tk on Mac OS X: http://lists.sourceforge.net/lists/listinfo/tcl-mac (this page also has a link to searchable archives of the list, please check them before asking on the list, many questions have already been answered). - For general Tcl/Tk questions, the newsgroup comp.lang.tcl is your best bet: http://groups.google.com/group/comp.lang.tcl/ - The Tcl'ers Wiki also has many pages dealing with Tcl & Tk on Mac OS X, see | > | | > > > > > | | | | < | | | | | | > | | < | | | | < < < < < < < < | | | | | | > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > < < > > | | | > > > > > | > > > > > > > > > > > | > | > > | > | > | > | < > > > > > > > > > > > > > > > | < > > > > | | > | | | | | < | | | > > | > | < > | | > | | > > | | | < | < | | | < < < < < < < < < < < < < < | | > | | | | < < | | < | < | | | | | | | < < < < < < < < | | < | > | | > | | < < < < < < < | | < | | < < | | | | < | | | | > | | < | | | | | | | | | | | | | | 1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 34 35 36 37 38 39 40 41 42 43 44 45 46 47 48 49 50 51 52 53 54 55 56 57 58 59 60 61 62 63 64 65 66 67 68 69 70 71 72 73 74 75 76 77 78 79 80 81 82 83 84 85 86 87 88 89 90 91 92 93 94 95 96 97 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 129 130 131 132 133 134 135 136 137 138 139 140 141 142 143 144 145 146 147 148 149 150 151 152 153 154 155 156 157 158 159 160 161 162 163 164 165 166 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 224 225 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 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 284 285 286 287 288 289 290 291 292 293 294 295 296 297 298 299 300 301 302 303 304 305 306 307 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 338 339 340 341 342 343 344 345 346 347 348 349 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 | Tcl/Tk Mac OS X README ---------------------- This is the README file for the Mac OS X/Darwin version of Tcl/Tk. 1. Where to go for support -------------------------- - The tcl-mac mailing list on sourceforge is the best place to ask questions specific to Tcl & Tk on Mac OS X: http://lists.sourceforge.net/lists/listinfo/tcl-mac (this page also has a link to searchable archives of the list, please check them before asking on the list, many questions have already been answered). - For general Tcl/Tk questions, the newsgroup comp.lang.tcl is your best bet: http://groups.google.com/group/comp.lang.tcl/ - The Tcl'ers Wiki also has many pages dealing with Tcl & Tk on Mac OS X, see http://wiki.tcl.tk/references/3753! http://wiki.tcl.tk/references/8361! - Please report bugs with Tcl or Tk on Mac OS X to the sourceforge bug trackers: Tcl: http://sf.net/tracker/?func=add&group_id=10894&atid=110894 Tk: http://sf.net/tracker/?func=add&group_id=12997&atid=112997 please make sure that your report Tk specific bugs to the tktoolkit project bug tracker rather than the tcl project bug tracker. Mac OS X specific bugs should in general be assigned to user 'das'. 2. Using Tcl/Tk on Mac OS X --------------------------- - There are two versions of Tk available on Mac OS X: TkAqua using the native aqua widgets and look&feel, and TkX11 using the traditional unix X11 wigets. TkX11 requires an X11 server to be installed, such as Apple's X11 (which is available as an optional or default install on recent Mac OS X). TkAqua and TkX11 can be distinguished at runtime via [tk windowingsystem]. - At a minimum, Mac OS X 10.3 is required to run Tcl and TkX11. TkAqua requires Mac OS X 10.5 or later (starting with the Cocoa-based Tk 8.5.7). - Unless weak-linking is used, Tcl/Tk built on Mac OS X 10.x will not run on 10.y with y < x; on the other hand Tcl/Tk built on 10.y will always run on 10.x with y <= x (but without any of the fixes and optimizations that would be available in a binary built on 10.x). Weak-linking is available on OS X 10.2 or later, it additionally allows Tcl/Tk built on 10.x to run on any 10.y with x > y >= z (for a chosen z >= 2). - Wish checks the Resources/Scripts directory in its application bundle for a file called AppMain.tcl, if found it is used as the startup script and the Scripts folder is added to the auto_path. This can be used to emulate the old OS9 TclTk droplets. - If standard input is a special file of zero length (e.g. /dev/null), Wish brings up the Tk console window at startup. This is the case when double clicking Wish in the Finder (or using 'open Wish.app' from the Terminal). - Tcl extensions can be installed in any of: $HOME/Library/Tcl /Library/Tcl /System/Library/Tcl $HOME/Library/Frameworks /Library/Frameworks /System/Library/Frameworks (searched in that order). Given a potential package directory $pkg, Tcl on OSX checks for the file $pkg/Resources/Scripts/pkgIndex.tcl as well as the usual $pkg/pkgIndex.tcl. This allows building extensions as frameworks with all script files contained in the Resources/Scripts directory of the framework. - [load]able binary extensions can linked as either ordinary shared libraries (.dylib) or as MachO bundles (since 8.4.10/8.5a3); bundles have the advantage that they are [load]ed more efficiently from a tcl VFS (no temporary copy to the native filesystem required), and prior to Mac OS X 10.5, only bundles can be [unload]ed. - The 'deploy' target of macosx/GNUmakefile installs the html manpages into the standard documentation location in the Tcl/Tk frameworks: Tcl.framework/Resources/Documentation/Reference/Tcl Tk.framework/Resources/Documentation/Reference/Tk No nroff manpages are installed by default by the GNUmakefile. - The Tcl and Tk frameworks can be installed in any of the system's standard framework directories: $HOME/Library/Frameworks /Library/Frameworks /System/Library/Frameworks - ${prefix}/bin/wish8.x is a script that calls a copy of 'Wish' contained in Tk.framework/Resources - if 'Wish' is started from the Finder or via 'open', $argv may contain a "-psn_XXXX" argument. This is the process serial number, you may need to filter it out for cross platform compatibility of your scripts. - the env array is different when Wish is started from the Finder (i.e. via LaunchServices) than when it (or tclsh) is invoked from the Terminal, in particular PATH may not be what you expect. (Wish started by LaunchServices inherits loginwindow's environment variables, which are essentially those set in $HOME/.MacOSX/environment.plist, and are unrelated to those set in your shell). - TkAqua drawing is antialiased by default, but (outline) linewidth can be used to control whether a line/shape is drawn antialiased. The antialiasing threshold is 0 by default (i.e. antialias everything), it can be changed by setting set tk::mac::CGAntialiasLimit <limit> in your script before drawing, in which case lines (or shapes with outlines) thinner than <limit> pixels will not be antialiased. - Text antialiasing by default uses the standard OS antialising settings. Setting the global variable '::tk::mac::antialiasedtext' allows to control text antialiasing from Tcl: a value of 1 enables AA, 0 disables AA and -1 restores the default behaviour of respecting the OS settings. - Scrollbars: There are two scrollbar variants in Aqua, normal & small. The normal scrollbar has a small dimension of 15, the small variant 11. Access to the small variant was added in Tk 8.4.2. - The default metrics of native buttons, radiobuttons, checkboxes and menubuttons in the Cocoa-based Tk 8.5.7 and later preserve compatibility with the older Carbon-based implementation, you can turn off the compatibility metrics to get more native-looking spacing by setting: set tk::mac::useCompatibilityMetrics 0 - TkAqua provides access to native OS X images via the Tk native bitmap facility (including any image file readable by NSImage). A native bitmap name is interpreted as follows (in order): - predefined builtin 32x32 icon name (stop, caution, document, etc) - name defined by [tk::mac::iconBitmap] - NSImage named image name - NSImage url string - 4-char OSType of IconServices icon the syntax of [tk::mac::iconBitmap] is as follows: tk::mac::iconBitmap name width height -kind value where -kind is one of -file icon of file at given path -fileType icon of given file type -osType icon of given 4-char OSType file type -systemType icon for given IconServices 4-char OSType -namedImage named NSImage for given name -imageFile image at given path This support was added with the Cocoa-based Tk 8.5.7. - TkAqua cursor names are interpred as follows (in order): - standard or platform-specific Tk cursor name (c.f. cursors.n) - @path to any image file readable by NSImage - NSImage named image name Support for the latter two was added with the Cocoa-based Tk 8.5.7. - The standard Tk dialog commands [tk_getOpenFile], [tk_chooseDirectory], [tk_getSaveFile] and [tk_messageBox] all take an additional optional -command parameter on TkAqua. If it is present, the given command prefix is evaluated at the global level when the dialog closes, with the dialog command's result appended (the dialog command itself returning an emtpy result). If the -parent option is also present, the dialog is configured as a modeless (window-modal) sheet attached to the parent window and the dialog command returns immediately. Support for -command was added with the Cocoa-based Tk 8.5.7. - The TkAqua-specific [tk::mac::standardAboutPanel] command brings the standard Cocoa about panel to the front, with all its information filled in from your application bundle files (i.e. standard about panel with no options specified). See Apple Technote TN2179 and the AppKit documentation for -[NSApplication orderFrontStandardAboutPanelWithOptions:] for details on the Info.plist keys and app bundle files used by the about panel. This support was added with the Cocoa-based Tk 8.5.7. - TkAqua has three special menu names that give access to the standard Application, Window and Help menus, see menu.n for details. By default, the platform-specific standard Help menu item "YourApp Help" peforms the default Cocoa action of showing the Help Book configured in the application's Info.plist (or displaying an alert if no Help Book is set). This action can be customized by defining a procedure named [tk::mac::ShowHelp], if present, this procedure is invoked instead by the standard Help menu item. Support for the Window menu and [tk::mac::ShowHelp] was added with the Cocoa-based Tk 8.5.7. - The TkAqua-specific command [tk::unsupported::MacWindowStyle style] is used to get and set Mac OS X-specific toplevel window class and attributes. Note that the window class and many attributes have to be set before the window is first mapped for the change to have any effect. The command has the following syntax: tk::unsupported::MacWindowStyle style window ?class? ?attributes? The 2 argument form returns a list of the current class and attributes for the given window. The 3 argument form sets the class for the given window using the default attributes for that class. The 4 argument form sets the class and the list of attributes for the given window. Window class names: standardDocument, standardFloating, resizable, fullZoom, horizontalZoom, verticalZoom, closeBox, collapseBox, toolbarButton, sideTitlebar, noTitleBar, unifiedTitleAndToolbar, metal, hud, noShadow, doesNotCycle, noActivates, hideOnSuspend, inWindowMenu, ignoreClicks, doesNotHide, canJoinAllSpaces, moveToActiveSpace, nonActivating, black, dark, light, gray, red, green, blue, cyan, yellow, magenta, orange, purple, brown, clear, opacity Note that not all attributes are valid for all window classes. Support for the 3 argument form was added with the Cocoa-based Tk 8.5.7, at the same time support for some legacy Carbon-specific classes and attributes was removed (they are still accepted by the command but no longer have any effect). The color window attributes (black, dark, red, etc.) and the "opacity" allow one to set the background and opacity of a textured ("metal") window. This allows a Tk window to implement a window without the dividing line between the titlebar and the rest of the window, or the "unified toolbar" effect, which is increasingly standard in Mac applications. An example: toplevel .f tk::unsupported::MacWindowStyle style .f document {metal light opaque closeBox collapseBox resizable standardDocument } pack [label .f.f -bg #ababab -text "This is a textured window\nwith opacity and a gray background\nsimilar to other Mac applications"] -fill both -expand yes The color attributes correspond to system-defined NSColor constants (e.g., red is [NSColor redColor]. The "light" and "dark" attributes correspond to lightGrayColor and darkGrayColor, respectively (because of the way the attributes are parsed, using "lightgray" and "darkgray" would cause a conflict with the core "gray" attribute). Below are the corresponding hex and/or Tk-defined colors that can be used from Tk widgets to match the NSColor-based attributes: black #000000 dark #545454 light #ababab white #ffffff gray #7f7f7f red #ff0000 green #00ff00 blue #0000ff cyan #00ffff yellow #ffff00 magenta #ff00ff orange #ff8000 purple #800080 brown #996633 clear systemTransparent - The Cocoa-based TkAqua can be distinguished from the older Carbon-based version via the [winfo server .] command, example output on Mac OS X 10.5.7: Cocoa-based: CG409.3 Apple AppKit GC 949.46 Mac OS X 1057 Carbon-based: QD10R30 Apple 1057 - If you want to use Remote Debugging with Xcode, you need to set the environment variable XCNOSTDIN to 1 in the Executable editor for Wish. That will cause us to force closing stdin & stdout. Otherwise, given how Xcode launches Wish remotely, they will be left open and then Wish & gdb will fight for stdin. 3. Building Tcl/Tk on Mac OS X ------------------------------ - At least Mac OS X 10.3 is required to build Tcl and TkX11, and Mac OS X 10.5 is required to build TkAqua. Apple's Xcode Developer Tools need to be installed (only the most recent version matching your OS release is supported), the Xcode installer is available on Mac OS X install media or may be present in /Applications/Installers on Macs that came with OS X preinstalled. The most recent version can always be downloaded from the ADC website http://connect.apple.com (free ADC membership required). - Tcl/Tk are most easily built as Mac OS X frameworks via GNUmakefile in tcl/macosx and tk/macosx (see below for details), but can also be built with the standard unix configure and make buildsystem in tcl/unix resp. tk/unix as on any other unix platform (indeed, the GNUmakefiles are just wrappers around the unix buildsystem). The Mac OS X specific configure flags are --enable-aqua, --enable-framework and --disable-corefoundation (which disables CF and notably reverts to the standard select based notifier). Note that --enable-aqua is incompatible with --disable-corefoundation (for both Tcl and Tk configure). - It is also possible to build with the Xcode IDE via the projects in tk/macosx, take care to use the project matching your DevTools and OS version: Tk.xcode: for Xcode 3.1 on 10.5 Tk.xcodeproj: for Xcode 3.2 on 10.6 These have the following targets: Tk: calls through to tk/macosx/GNUMakefile, requires a corresponding build of the Tcl target of tcl/macosx/Tcl.xcode. tktest: static build of TkAqua tktest for debugging. tktest-X11: static build of TkX11 tktest for debugging. The following build configurations are available: Debug: debug build for the active architecture, with Fix & Continue enabled. Debug gcc42: use gcc 4.2 compiler. Debug gcc42 nogc: disable Objective-C garbage collection. Debug llvmgcc42: use llvm-gcc 4.2 compiler. DebugNoFixAndContinue: disable Fix & Continue. DebugUnthreaded: disable threading. DebugNoCF: disable corefoundation (X11 only). DebugNoCFUnthreaded: disable corefoundation an threading. DebugMemCompile: enable memory and bytecode debugging. DebugLeaks: define PURIFY. DebugGCov: enable generation of gcov data files. Debug64bit: configure with --enable-64bit (requires building on a 64bit capable processor). Release: release build for the active architecture. ReleaseUniversal: 32/64-bit universal build. ReleaseUniversal gcc42: use gcc 4.2 compiler. ReleaseUniversal llvmgcc42: use llvm-gcc 4.2 compiler. ReleaseUniversal10.5SDK: build against the 10.5 SDK (with 10.5 deployment target). Note that the non-SDK configurations have their deployment target set to 10.5 (Tk.xcode) resp. 10.6 (Tk.xcodeproj). The Xcode projects refer to the toplevel tcl and tk source directories via the the TCL_SRCROOT and TK_SRCROOT user build settings, by default these are set to the project-relative paths '../../tcl' and '../../tk', if your source directories are named differently, e.g. '../../tcl8.6' and '../../tk8.6', you need to manually change the TCL_SRCROOT and TK_SRCROOT settings by editing your ${USER}.pbxuser file (located inside the Tk.xcodeproj bundle directory) with a text editor. - To build universal binaries outside of the Xcode IDE, set CFLAGS as follows: export CFLAGS="-arch i386 -arch x86_64 -arch ppc" This requires Mac OS X 10.4 and Xcode 2.4 (or Xcode 2.2 if -arch x86_64 is omitted, but _not_ Xcode 2.1) and will work on any architecture (on PowerPC Tiger you need to add "-isysroot /Developer/SDKs/MacOSX10.4u.sdk"). Note that configure requires CFLAGS to contain a least one architecture that can be run on the build machine (i.e. ppc on G3/G4, ppc or ppc64 on G5, ppc or i386 on Core and ppc, i386 or x86_64 on Core2/Xeon). Universal builds of Tcl TEA extensions are also possible with CFLAGS set as above, they will be [load]able by universal as well as thin binaries of Tcl. - To enable weak-linking, set the MACOSX_DEPLOYMENT_TARGET environment variable to the minimal OS version the binaries should be able to run on, e.g: export MACOSX_DEPLOYMENT_TARGET=10.4 This requires at least gcc 3.1; with gcc 4 or later, set/add to CFLAGS instead: export CFLAGS="-mmacosx-version-min=10.4" Support for weak-linking was added with 8.4.14/8.5a5. Detailed Instructions for building with macosx/GNUmakefile ---------------------------------------------------------- - Unpack the Tcl and Tk source release archives and place the tcl and tk source trees in a common parent directory. [ If you don't want have the two source trees in one directory, you'll need to ] [ create the following symbolic link for the build to work as setup by default ] [ ln -fs /path_to_tcl/build /path_to_tk/build ] [ (where /path_to_{tcl,tk} is the directory containing the tcl resp. tk tree) ] [ or you can pass an argument of BUILD_DIR=/somewhere to the tcl and tk make. ] - The following instructions assume the Tcl and Tk source trees are named "tcl${ver}" and "tk${ver}" (where ${ver} is a shell variable containing the Tcl/Tk version number, e.g. '8.6'). Setup this shell variable as follows: ver="8.6" If you are building from CVS, omit this step (CVS source tree names usually do not contain a version number). - Setup environment variables as desired, e.g. for a universal build on 10.5: CFLAGS="-arch i386 -arch x86_64 -arch ppc -mmacosx-version-min=10.5" export CFLAGS - Change to the directory containing the Tcl and Tk source trees and build: make -C tcl${ver}/macosx make -C tk${ver}/macosx - Install Tcl and Tk onto the root volume (admin password required): sudo make -C tcl${ver}/macosx install sudo make -C tk${ver}/macosx install if you don't have an admin password, you can install into your home directory instead by passing an INSTALL_ROOT argument to make: make -C tcl${ver}/macosx install INSTALL_ROOT="${HOME}/" make -C tk${ver}/macosx install INSTALL_ROOT="${HOME}/" - The default GNUmakefile targets will build _both_ debug and optimized versions of the Tcl and Tk frameworks with the standard convention of naming the debug library Tcl.framework/Tcl_debug resp. Tk.framework/Tk_debug. This allows switching to the debug libraries at runtime by setting export DYLD_IMAGE_SUFFIX=_debug (c.f. man dyld for more details) If you only want to build and install the debug or optimized build, use the 'develop' or 'deploy' target variants of the GNUmakefile, respectively. For example, to build and install only the optimized versions: make -C tcl${ver}/macosx deploy make -C tk${ver}/macosx deploy sudo make -C tcl${ver}/macosx install-deploy sudo make -C tk${ver}/macosx install-deploy - The GNUmakefile can also build a version of Wish.app that has the Tcl and Tk frameworks embedded in its application package. This allows for standalone deployment of the application with no installation required, e.g. from read-only media. To build & install in this manner, use the 'embedded' variants of the GNUmakefile targets. For example, to build a standalone 'Wish.app' in ./emb/Applications/Utilities: make -C tcl${ver}/macosx embedded make -C tk${ver}/macosx embedded sudo make -C tcl${ver}/macosx install-embedded INSTALL_ROOT=`pwd`/emb/ sudo make -C tk${ver}/macosx install-embedded INSTALL_ROOT=`pwd`/emb/ Notes: * if you've already built standard TclTkAqua, building embedded does not require any new compiling or linking, so you can skip the first two makes. (making relinking unnecessary was added with 8.4.2) * the embedded frameworks include only optimized builds and no documentation. * the standalone Wish has the directory Wish.app/Contents/lib in its auto_path. Thus you can place tcl extensions in this directory (i.e. embed them in the app package) and load them with [package require]. - It is possible to build Tk against an installed Tcl.framework; but you will still need a tcl sourcetree in the location specified in TCL_SRC_DIR in Tcl.framework/tclConfig.sh. Also, linking with Tcl.framework has to work exactly as indicated in TCL_LIB_SPEC in Tcl.framework/tclConfig.sh. If you used non-default install locations for Tcl.framework, specify them as make overrides to the tk/macosx GNUmakefile, e.g. make -C tk${ver}/macosx \ TCL_FRAMEWORK_DIR=$HOME/Library/Frameworks TCLSH_DIR=$HOME/usr/bin sudo make -C tk${ver}/macosx install \ TCL_FRAMEWORK_DIR=$HOME/Library/Frameworks TCLSH_DIR=$HOME/usr/bin The Makefile variables TCL_FRAMEWORK_DIR and TCLSH_DIR were added with Tk 8.4.3. |
Changes to macosx/Tk-Info.plist.in.
1 2 3 | <?xml version="1.0" encoding="UTF-8"?> <!DOCTYPE plist PUBLIC "-//Apple Computer//DTD PLIST 1.0//EN" "http://www.apple.com/DTDs/PropertyList-1.0.dtd"> <!-- | | > | | 1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 | <?xml version="1.0" encoding="UTF-8"?> <!DOCTYPE plist PUBLIC "-//Apple Computer//DTD PLIST 1.0//EN" "http://www.apple.com/DTDs/PropertyList-1.0.dtd"> <!-- Copyright (c) 2005-2009 Daniel A. Steffen <[email protected]> Copyright 2008-2009, Apple Inc. See the file "license.terms" for information on usage and redistribution of this file, and for a DISCLAIMER OF ALL WARRANTIES. --> <plist version="1.0"> <dict> <key>CFBundleDevelopmentRegion</key> <string>English</string> <key>CFBundleExecutable</key> <string>@TK_LIB_FILE@</string> <key>CFBundleGetInfoString</key> <string>Tk @TK_WINDOWINGSYSTEM@ @TK_VERSION@@TK_PATCH_LEVEL@, Copyright © 1989-@TK_YEAR@ Tcl Core Team, Copyright © 2002-@TK_YEAR@ Daniel A. Steffen, Copyright © 2001-2009 Apple Inc., Copyright © 2001-2002 Jim Ingham & Ian Reid</string> <key>CFBundleIdentifier</key> <string>com.tcltk.tklibrary</string> <key>CFBundleInfoDictionaryVersion</key> <string>6.0</string> <key>CFBundleName</key> <string>Tk @TK_WINDOWINGSYSTEM@ @TK_VERSION@</string> |
︙ | ︙ |
Added macosx/Tk.icns.
cannot compute difference between binary files
Added macosx/Tk.tiff.
cannot compute difference between binary files
Deleted macosx/Wish-Common.xcconfig.
|
| < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < |
Deleted macosx/Wish-Debug.xcconfig.
|
| < < < < < < < < < < < < < < < < < < < |
Changes to macosx/Wish-Info.plist.in.
1 2 3 | <?xml version="1.0" encoding="UTF-8"?> <!DOCTYPE plist PUBLIC "-//Apple Computer//DTD PLIST 1.0//EN" "http://www.apple.com/DTDs/PropertyList-1.0.dtd"> <!-- | | > | 1 2 3 4 5 6 7 8 9 10 11 12 | <?xml version="1.0" encoding="UTF-8"?> <!DOCTYPE plist PUBLIC "-//Apple Computer//DTD PLIST 1.0//EN" "http://www.apple.com/DTDs/PropertyList-1.0.dtd"> <!-- Copyright (c) 2005-2009 Daniel A. Steffen <[email protected]> Copyright 2008-2009, Apple Inc. See the file "license.terms" for information on usage and redistribution of this file, and for a DISCLAIMER OF ALL WARRANTIES. --> <plist version="1.0"> <dict> <key>CFBundleDevelopmentRegion</key> |
︙ | ︙ | |||
37 38 39 40 41 42 43 | </array> <key>CFBundleExecutable</key> <string>Wish</string> <key>CFBundleGetInfoString</key> <string>Wish Shell @TK_VERSION@@TK_PATCH_LEVEL@, Copyright © 1989-@TK_YEAR@ Tcl Core Team, Copyright © 2002-@TK_YEAR@ Daniel A. Steffen, | | | 38 39 40 41 42 43 44 45 46 47 48 49 50 51 52 | </array> <key>CFBundleExecutable</key> <string>Wish</string> <key>CFBundleGetInfoString</key> <string>Wish Shell @TK_VERSION@@TK_PATCH_LEVEL@, Copyright © 1989-@TK_YEAR@ Tcl Core Team, Copyright © 2002-@TK_YEAR@ Daniel A. Steffen, Copyright © 2001-2009 Apple Inc., Copyright © 2001-2002 Jim Ingham & Ian Reid</string> <key>CFBundleIconFile</key> <string>Wish.icns</string> <key>CFBundleIdentifier</key> <string>com.tcltk.wish</string> <key>CFBundleInfoDictionaryVersion</key> <string>6.0</string> |
︙ | ︙ | |||
60 61 62 63 64 65 66 | <key>CFBundleShortVersionString</key> <string>@TK_VERSION@@TK_PATCH_LEVEL@</string> <key>CFBundleSignature</key> <string>WiSH</string> <key>CFBundleVersion</key> <string>@TK_VERSION@@TK_PATCH_LEVEL@</string> <key>LSMinimumSystemVersion</key> | | > > | 61 62 63 64 65 66 67 68 69 70 71 72 73 74 75 76 | <key>CFBundleShortVersionString</key> <string>@TK_VERSION@@TK_PATCH_LEVEL@</string> <key>CFBundleSignature</key> <string>WiSH</string> <key>CFBundleVersion</key> <string>@TK_VERSION@@TK_PATCH_LEVEL@</string> <key>LSMinimumSystemVersion</key> <string>10.5.0</string> <key>LSRequiresCarbon</key> <true/> <key>NSAppleScriptEnabled</key> <true/> <key>OSAScriptingDefinition</key> <string>Wish.sdef</string> </dict> </plist> |
Deleted macosx/Wish-Release.xcconfig.
|
| < < < < < < < < < < < < < < < < < < < |
Deleted macosx/Wish.icns.
cannot compute difference between binary files
Deleted macosx/Wish.pbproj/default.pbxuser.
|
| < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < |
Deleted macosx/Wish.pbproj/jingham.pbxuser.
|
| < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < |
Deleted macosx/Wish.pbproj/project.pbxproj.
|
| < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < |
Added macosx/Wish.sdef.
> > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > | 1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 34 35 36 37 | <?xml version="1.0" encoding="UTF-8"?> <!DOCTYPE dictionary SYSTEM "file://localhost/System/Library/DTDs/sdef.dtd"> <!-- Copyright (c) 1997 Sun Microsystems, Inc. Copyright 2009 Kevin Walzer/WordTech Communications LLC. Copyright (c) 2009 Daniel A. Steffen <[email protected]> See the file "license.terms" for information on usage and redistribution of this file, and for a DISCLAIMER OF ALL WARRANTIES. --> <dictionary title="Wish Terminology"> <suite name="Standard Suite" code="reqd" description="Common commands for all applications."> <command name="open" code="aevtodoc" description="Open a document."> <direct-parameter description="The file(s) to be opened."> <type type="file"/> <type type="file" list="yes"/> </direct-parameter> </command> <command name="print" code="aevtpdoc" description="Print a document."> <direct-parameter description="The file(s) to be printed."> <type type="file" list="yes"/> <type type="specifier"/> </direct-parameter> </command> <command name="quit" code="aevtquit" description="Quit the application."/> </suite> <suite name="Wish Suite" code="WIsH" description="Commands for the Wish application."> <command name="do script" code="miscdosc" description="Execute a Tcl script."> <direct-parameter description="Script to execute" type="text"> <type type="text"/> </direct-parameter> <result description="Result"> <type type="text"/> </result> </command> </suite> </dictionary> |
Deleted macosx/Wish.xcode/default.pbxuser.
|
| < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < |
Deleted macosx/Wish.xcode/project.pbxproj.
|
| < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < |
Deleted macosx/Wish.xcodeproj/default.pbxuser.
|
| < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < |
Deleted macosx/Wish.xcodeproj/project.pbxproj.
|
| < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < |
Deleted macosx/tkAboutDlg.r.
|
| < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < |
Changes to macosx/tkMacOSX.h.
1 2 3 4 5 6 | /* * tkMacOSX.h -- * * Declarations of Macintosh specific exported variables and procedures. * * Copyright (c) 1995-1997 Sun Microsystems, Inc. | | | < < | | | | | 1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 34 | /* * tkMacOSX.h -- * * Declarations of Macintosh specific exported variables and procedures. * * Copyright (c) 1995-1997 Sun Microsystems, Inc. * Copyright 2001-2009, Apple Inc. * Copyright (c) 2005-2009 Daniel A. Steffen <[email protected]> * * See the file "license.terms" for information on usage and redistribution * of this file, and for a DISCLAIMER OF ALL WARRANTIES. */ #ifndef _TKMAC #define _TKMAC #ifndef _TK #include "tk.h" #endif /* * Structures and function types for handling Netscape-type in process * embedding where Tk does not control the top-level */ typedef int (Tk_MacOSXEmbedRegisterWinProc) (long winID, Tk_Window window); typedef void* (Tk_MacOSXEmbedGetGrafPortProc) (Tk_Window window); typedef int (Tk_MacOSXEmbedMakeContainerExistProc) (Tk_Window window); typedef void (Tk_MacOSXEmbedGetClipProc) (Tk_Window window, TkRegion rgn); typedef void (Tk_MacOSXEmbedGetOffsetInParentProc) (Tk_Window window, void *ulCorner); #include "tkPlatDecls.h" #endif /* _TKMAC */ |
Deleted macosx/tkMacOSXAETE.r.
|
| < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < |
Changes to macosx/tkMacOSXBitmap.c.
1 2 3 4 5 6 | /* * tkMacOSXBitmap.c -- * * This file handles the implementation of native bitmaps. * * Copyright (c) 1996-1997 Sun Microsystems, Inc. | | | | < < < < < < < < < < < < < < < < < < | < | | | | | | | | | | | | | | | | | > > > > > > > > > > > > > > > > > > | 1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 34 35 36 37 38 39 40 41 42 43 44 45 46 47 48 49 50 51 52 53 54 55 56 57 58 59 60 61 62 63 64 65 66 67 68 69 70 71 72 73 | /* * tkMacOSXBitmap.c -- * * This file handles the implementation of native bitmaps. * * Copyright (c) 1996-1997 Sun Microsystems, Inc. * Copyright 2001-2009, Apple Inc. * Copyright (c) 2006-2009 Daniel A. Steffen <[email protected]> * * See the file "license.terms" for information on usage and redistribution * of this file, and for a DISCLAIMER OF ALL WARRANTIES. */ #include "tkMacOSXPrivate.h" /* * This structure holds information about native bitmaps. */ typedef struct { const char *name; /* Name of icon. */ OSType iconType; /* OSType of icon. */ } BuiltInIcon; /* * This array mapps a string name to the supported builtin icons * on the Macintosh. */ static BuiltInIcon builtInIcons[] = { {"document", kGenericDocumentIcon}, {"stationery", kGenericStationeryIcon}, {"edition", kGenericEditionFileIcon}, {"application", kGenericApplicationIcon}, {"accessory", kGenericDeskAccessoryIcon}, {"folder", kGenericFolderIcon}, {"pfolder", kPrivateFolderIcon}, {"trash", kTrashIcon}, {"floppy", kGenericFloppyIcon}, {"ramdisk", kGenericRAMDiskIcon}, {"cdrom", kGenericCDROMIcon}, {"preferences", kGenericPreferencesIcon}, {"querydoc", kGenericQueryDocumentIcon}, {"stop", kAlertStopIcon}, {"note", kAlertNoteIcon}, {"caution", kAlertCautionIcon}, {NULL} }; #define builtInIconSize 32 static Tcl_HashTable iconBitmapTable = {}; typedef struct { int kind, width, height; char *value; } IconBitmap; static const char *iconBitmapOptionStrings[] = { "-file", "-fileType", "-osType", "-systemType", "-namedImage", "-imageFile", NULL }; enum iconBitmapOptions { ICON_FILE, ICON_FILETYPE, ICON_OSTYPE, ICON_SYSTEMTYPE, ICON_NAMEDIMAGE, ICON_IMAGEFILE, }; /* *---------------------------------------------------------------------- * * TkpDefineNativeBitmaps -- * * Add native bitmaps. |
︙ | ︙ | |||
88 89 90 91 92 93 94 | TkpDefineNativeBitmaps(void) { Tcl_HashTable *tablePtr = TkGetBitmapPredefTable(); BuiltInIcon *builtInPtr; for (builtInPtr = builtInIcons; builtInPtr->name != NULL; builtInPtr++) { Tcl_HashEntry *predefHashPtr; | | < < < < < | | | > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > | < < > < < > | | | | | > > > > > | > > > | | < | | < > > > | < > > > > > | < | < | < | < < | < < < > | > > > > > | | | | > > > > > > | | > > > > > > < < > < < > | > | | | > | < > > | > | > > > > | > > > > > > > > > > | < > > > > > > > > > > | < > > > | > > > > | < < | < > > > > > | > > | > > | > | | < > > > | | | | > > | > > > > > | > > | > > > > > > > | > | > > > > > > > | < > > > | < < < | > | < < < < < < < | > | > > > > > > > | < > | > > > | > > > > > > > > > > > > > > > > > > > > > > > > > > > > > | | < | < | < < > > > > | | > > > > | > > | | > | > > > > > > > > > > > > > > > > > > | > > > > > > > > > | 87 88 89 90 91 92 93 94 95 96 97 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 129 130 131 132 133 134 135 136 137 138 139 140 141 142 143 144 145 146 147 148 149 150 151 152 153 154 155 156 157 158 159 160 161 162 163 164 165 166 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 224 225 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 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 284 285 286 287 288 289 290 291 292 293 294 295 296 297 298 299 300 301 302 303 304 305 306 307 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 338 339 340 341 342 343 344 345 346 347 348 349 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 | TkpDefineNativeBitmaps(void) { Tcl_HashTable *tablePtr = TkGetBitmapPredefTable(); BuiltInIcon *builtInPtr; for (builtInPtr = builtInIcons; builtInPtr->name != NULL; builtInPtr++) { Tcl_HashEntry *predefHashPtr; Tk_Uid name; int isNew; name = Tk_GetUid(builtInPtr->name); predefHashPtr = Tcl_CreateHashEntry(tablePtr, name, &isNew); if (isNew) { TkPredefBitmap *predefPtr = (TkPredefBitmap *) ckalloc(sizeof(TkPredefBitmap)); predefPtr->source = UINT2PTR(builtInPtr->iconType); predefPtr->width = builtInIconSize; predefPtr->height = builtInIconSize; predefPtr->native = 1; Tcl_SetHashValue(predefHashPtr, predefPtr); } } } /* *---------------------------------------------------------------------- * * GetBitmapForIcon -- * * Results: * Bitmap for the given IconRef. * * Side effects: * None. * *---------------------------------------------------------------------- */ static Pixmap GetBitmapForIcon( Display *display, IconRef icon, CGSize size) { TkMacOSXDrawingContext dc; Pixmap pixmap; pixmap = Tk_GetPixmap(display, None, size.width, size.height, 0); if (TkMacOSXSetupDrawingContext(pixmap, NULL, 1, &dc)) { if (dc.context) { const CGAffineTransform t = { .a = 1, .b = 0, .c = 0, .d = -1, .tx = 0, .ty = size.height }; const CGRect r = { .origin = { .x = 0, .y = 0 }, .size = size }; CGContextConcatCTM(dc.context, t); PlotIconRefInContext(dc.context, &r, kAlignAbsoluteCenter, kTransformNone, NULL, kPlotIconRefNormalFlags, icon); } TkMacOSXRestoreDrawingContext(&dc); } return pixmap; } /* *---------------------------------------------------------------------- * * TkpCreateNativeBitmap -- * * Create native bitmap. * * Results: * Native bitmap. * * Side effects: * None. * *---------------------------------------------------------------------- */ Pixmap TkpCreateNativeBitmap( Display *display, const char *source) /* Info about the icon to build. */ { Pixmap pixmap; IconRef icon; OSErr err; err = ChkErr(GetIconRef, kOnSystemDisk, kSystemIconsCreator, PTR2UINT(source), &icon); if (err == noErr) { pixmap = GetBitmapForIcon(display, icon, CGSizeMake(builtInIconSize, builtInIconSize)); ReleaseIconRef(icon); } else { pixmap = Tk_GetPixmap(display, None, builtInIconSize, builtInIconSize, 0); } return pixmap; } /* *---------------------------------------------------------------------- * * OSTypeFromString -- * * Helper to convert string to OSType. * * Results: * A standard Tcl result. * * Side effects: * t is set to OSType if conversion successful. * *---------------------------------------------------------------------- */ static int OSTypeFromString(const char *s, OSType *t) { int result = TCL_ERROR; Tcl_DString ds; Tcl_Encoding encoding = Tcl_GetEncoding(NULL, "macRoman"); Tcl_UtfToExternalDString(encoding, s, -1, &ds); if (Tcl_DStringLength(&ds) <= 4) { char string[4] = {}; memcpy(string, Tcl_DStringValue(&ds), (size_t) Tcl_DStringLength(&ds)); *t = (OSType) string[0] << 24 | (OSType) string[1] << 16 | (OSType) string[2] << 8 | (OSType) string[3]; result = TCL_OK; } Tcl_DStringFree(&ds); Tcl_FreeEncoding(encoding); return result; } /* *---------------------------------------------------------------------- * * TkpGetNativeAppBitmap -- * * Get a named native bitmap. * * Attemps to interpret the given name in order as: * - name defined by ::tk::mac::iconBitmap * - NSImage named image name * - NSImage url string * - 4-char OSType of IconServices icon * * Results: * Native bitmap or None. * * Side effects: * None. * *---------------------------------------------------------------------- */ Pixmap TkpGetNativeAppBitmap( Display *display, /* The display. */ const char *name, /* The name of the bitmap. */ int *width, /* The width & height of the bitmap. */ int *height) { Tcl_HashEntry *hPtr; Pixmap pixmap = None; NSString *string; NSImage *image = nil; NSSize size = { .width = builtInIconSize, .height = builtInIconSize }; if (iconBitmapTable.buckets && (hPtr = Tcl_FindHashEntry(&iconBitmapTable, name))) { OSType type; IconBitmap *iconBitmap = Tcl_GetHashValue(hPtr); name = NULL; size = NSMakeSize(iconBitmap->width, iconBitmap->height); switch (iconBitmap->kind) { case ICON_FILE: string = [[NSString stringWithUTF8String:iconBitmap->value] stringByExpandingTildeInPath]; image = [[NSWorkspace sharedWorkspace] iconForFile:string]; break; case ICON_FILETYPE: string = [NSString stringWithUTF8String:iconBitmap->value]; image = [[NSWorkspace sharedWorkspace] iconForFileType:string]; break; case ICON_OSTYPE: if (OSTypeFromString(iconBitmap->value, &type) == TCL_OK) { string = NSFileTypeForHFSTypeCode(type); image = [[NSWorkspace sharedWorkspace] iconForFileType:string]; } break; case ICON_SYSTEMTYPE: name = iconBitmap->value; break; case ICON_NAMEDIMAGE: string = [NSString stringWithUTF8String:iconBitmap->value]; image = [NSImage imageNamed:string]; break; case ICON_IMAGEFILE: string = [[NSString stringWithUTF8String:iconBitmap->value] stringByExpandingTildeInPath]; image = [[[NSImage alloc] initWithContentsOfFile:string] autorelease]; break; } if (image) { [image setSize:size]; } } else { string = [NSString stringWithUTF8String:name]; image = [NSImage imageNamed:string]; if (!image) { NSURL *url = [NSURL URLWithString:string]; if (url) { image = [[[NSImage alloc] initWithContentsOfURL:url] autorelease]; } } if (image) { size = [image size]; } } if (image) { TkMacOSXDrawingContext dc; int depth = 0; #ifdef MAC_OSX_TK_TODO for (NSImageRep *r in [image representations]) { NSInteger bitsPerSample = [r bitsPerSample]; if (bitsPerSample && bitsPerSample > depth) { depth = bitsPerSample; }; } if (depth == 1) { /* TODO: convert BW NSImage to CGImageMask */ } #endif pixmap = Tk_GetPixmap(display, None, size.width, size.height, depth); *width = size.width; *height = size.height; if (TkMacOSXSetupDrawingContext(pixmap, NULL, 1, &dc)) { if (dc.context) { CGAffineTransform t = { .a = 1, .b = 0, .c = 0, .d = -1, .tx = 0, .ty = size.height}; CGContextConcatCTM(dc.context, t); [NSGraphicsContext saveGraphicsState]; [NSGraphicsContext setCurrentContext:[NSGraphicsContext graphicsContextWithGraphicsPort:dc.context flipped:NO]]; [image drawAtPoint:NSZeroPoint fromRect:NSZeroRect operation:NSCompositeCopy fraction:1.0]; [NSGraphicsContext restoreGraphicsState]; } TkMacOSXRestoreDrawingContext(&dc); } } else if (name) { OSType iconType; if (OSTypeFromString(name, &iconType) == TCL_OK) { IconRef icon; OSErr err = ChkErr(GetIconRef, kOnSystemDisk, kSystemIconsCreator, iconType, &icon); if (err == noErr) { pixmap = GetBitmapForIcon(display, icon, NSSizeToCGSize(size)); *width = size.width; *height = size.height; ReleaseIconRef(icon); } } } return pixmap; } /* *---------------------------------------------------------------------- * * TkMacOSXIconBitmapObjCmd -- * * Implements the ::tk::mac::iconBitmap command. * * Results: * A standard Tcl result. * * Side effects: * none * *---------------------------------------------------------------------- */ int TkMacOSXIconBitmapObjCmd( ClientData clientData, /* Unused. */ Tcl_Interp *interp, /* Current interpreter. */ int objc, /* Number of arguments. */ Tcl_Obj *const objv[]) /* Argument objects. */ { Tcl_HashEntry *hPtr; int i = 1, len, isNew, result = TCL_ERROR; const char *name, *value; IconBitmap ib, *iconBitmap; if (objc != 6) { Tcl_WrongNumArgs(interp, 1, objv, "name width height " "-file|-fileType|-osType|-systemType|-namedImage|-imageFile " "value"); goto end; } name = Tcl_GetStringFromObj(objv[i++], &len); if (!len) { Tcl_AppendResult(interp, "empty bitmap name", NULL); goto end; } if (Tcl_GetIntFromObj(interp, objv[i++], &ib.width) != TCL_OK) { goto end; } if (Tcl_GetIntFromObj(interp, objv[i++], &ib.height) != TCL_OK) { goto end; } if (Tcl_GetIndexFromObj(interp, objv[i++], iconBitmapOptionStrings, "kind", TCL_EXACT, &ib.kind) != TCL_OK) { goto end; } value = Tcl_GetStringFromObj(objv[i++], &len); if (!len) { Tcl_AppendResult(interp, "empty bitmap value", NULL); goto end; } #if 0 if ((kind == ICON_TYPE || kind == ICON_SYSTEM)) { Tcl_DString ds; Tcl_Encoding encoding = Tcl_GetEncoding(NULL, "macRoman"); Tcl_UtfToExternalDString(encoding, value, -1, &ds); len = Tcl_DStringLength(&ds); Tcl_DStringFree(&ds); Tcl_FreeEncoding(encoding); if (len > 4) { Tcl_AppendResult(interp, "invalid bitmap value", NULL); goto end; } } #endif ib.value = ckalloc(len + 1); strcpy(ib.value, value); if (!iconBitmapTable.buckets) { Tcl_InitHashTable(&iconBitmapTable, TCL_STRING_KEYS); } hPtr = Tcl_CreateHashEntry(&iconBitmapTable, name, &isNew); if (!isNew) { iconBitmap = Tcl_GetHashValue(hPtr); ckfree(iconBitmap->value); } else { iconBitmap = (IconBitmap *) ckalloc(sizeof(IconBitmap)); Tcl_SetHashValue(hPtr, iconBitmap); } *iconBitmap = ib; result = TCL_OK; end: return result; } /* * Local Variables: * mode: c * c-basic-offset: 4 * fill-column: 79 * coding: utf-8 * End: */ |
Changes to macosx/tkMacOSXButton.c.
1 2 3 4 5 6 7 | /* * tkMacOSXButton.c -- * * This file implements the Macintosh specific portion of the * button widgets. * * Copyright (c) 1996-1997 by Sun Microsystems, Inc. | | | < | < < < | | | < < | | | | > > | | < < < | < < | > | > < > > > | < < < < < < | < < < < < < < < < < < < | < < < < < | | < < | < < | < | < > > > > < < > > | < > > > > < < < < < < | | < | < | | < < < < < | 1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 34 35 36 37 38 39 40 41 42 43 44 45 46 47 48 49 50 51 52 53 54 55 56 57 58 59 60 61 62 63 64 65 66 67 68 69 70 71 72 73 74 75 76 77 78 79 80 81 82 83 84 85 86 87 88 89 90 | /* * tkMacOSXButton.c -- * * This file implements the Macintosh specific portion of the * button widgets. * * Copyright (c) 1996-1997 by Sun Microsystems, Inc. * Copyright 2001-2009, Apple Inc. * Copyright (c) 2006-2009 Daniel A. Steffen <[email protected]> * * See the file "license.terms" for information on usage and redistribution * of this file, and for a DISCLAIMER OF ALL WARRANTIES. */ #include "tkMacOSXPrivate.h" #include "tkButton.h" #include "tkMacOSXFont.h" #include "tkMacOSXDebug.h" /* #ifdef TK_MAC_DEBUG #define TK_MAC_DEBUG_BUTTON #endif */ typedef struct MacButton { TkButton info; NSButton *button; NSImage *image, *selectImage, *tristateImage; #if TK_MAC_BUTTON_USE_COMPATIBILITY_METRICS int fix; #endif } MacButton; #if TK_MAC_BUTTON_USE_COMPATIBILITY_METRICS int tkMacOSXUseCompatibilityMetrics = 1; /* * Use the following heuristic conversion constants to make NSButton-based * widget metrics match up with the old Carbon control buttons (for the * default Lucida Grande 13 font). */ #define NATIVE_BUTTON_INSET 2 #define NATIVE_BUTTON_EXTRA_H 2 typedef struct { int trimW, trimH, inset, shrinkH, offsetX, offsetY; } BoundsFix; #define fixForTypeStyle(type, style) ( \ type == NSSwitchButton ? 0 : \ type == NSRadioButton ? 1 : \ style == NSRoundedBezelStyle ? 2 : \ style == NSRegularSquareBezelStyle ? 3 : \ style == NSShadowlessSquareBezelStyle ? 4 : \ INT_MIN) static const BoundsFix boundsFixes[] = { [fixForTypeStyle(NSSwitchButton,0)] = { 2, 2, -1, 0, 2, 1 }, [fixForTypeStyle(NSRadioButton,0)] = { 0, 2, -1, 0, 1, 1 }, [fixForTypeStyle(0,NSRoundedBezelStyle)] = { 28, 16, -6, 0, 0, 3 }, [fixForTypeStyle(0,NSRegularSquareBezelStyle)] = { 28, 15, -2, -1 }, [fixForTypeStyle(0,NSShadowlessSquareBezelStyle)] = { 2, 2 }, }; #endif static void DisplayNativeButton(TkButton *butPtr); static void ComputeNativeButtonGeometry(TkButton *butPtr); static void DisplayUnixButton(TkButton *butPtr); static void ComputeUnixButtonGeometry(TkButton *butPtr); /* * The class procedure table for the button widgets. */ Tk_ClassProcs tkpButtonProcs = { sizeof(Tk_ClassProcs), /* size */ TkButtonWorldChanged, /* worldChangedProc */ }; /* *---------------------------------------------------------------------- * * TkpCreateButton -- * * Allocate a new TkButton structure. |
︙ | ︙ | |||
140 141 142 143 144 145 146 | TkButton * TkpCreateButton( Tk_Window tkwin) { MacButton *macButtonPtr = (MacButton *) ckalloc(sizeof(MacButton)); | < < | | | | | | > | > > > | > > > > > > > > > > > | > > > > | | > > > | 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 129 130 131 132 133 134 135 136 137 138 139 140 141 142 143 144 145 146 147 | TkButton * TkpCreateButton( Tk_Window tkwin) { MacButton *macButtonPtr = (MacButton *) ckalloc(sizeof(MacButton)); macButtonPtr->button = nil; macButtonPtr->image = nil; macButtonPtr->selectImage = nil; macButtonPtr->tristateImage = nil; return (TkButton *) macButtonPtr; } /* *---------------------------------------------------------------------- * * TkpDestroyButton -- * * Free data structures associated with the button control. * * Results: * None. * * Side effects: * Restores the default control state. * *---------------------------------------------------------------------- */ void TkpDestroyButton( TkButton *butPtr) { MacButton *macButtonPtr = (MacButton *) butPtr; TkMacOSXMakeCollectableAndRelease(macButtonPtr->button); TkMacOSXMakeCollectableAndRelease(macButtonPtr->selectImage); TkMacOSXMakeCollectableAndRelease(macButtonPtr->selectImage); TkMacOSXMakeCollectableAndRelease(macButtonPtr->tristateImage); } /* *---------------------------------------------------------------------- * * TkpDisplayButton -- * |
︙ | ︙ | |||
178 179 180 181 182 183 184 | *---------------------------------------------------------------------- */ void TkpDisplayButton( ClientData clientData) /* Information about widget. */ { | < < < < < < < < < < < < | < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < | < | < < < < < < < | < < < < < < < | < < < < < < | < < < < < < < < < | < < < < | < < < < < < < < < < < < < < < | < < < < | < < | < < < < < < < | 158 159 160 161 162 163 164 165 166 167 168 169 170 171 172 173 174 175 176 177 178 179 180 181 182 183 184 185 186 187 | *---------------------------------------------------------------------- */ void TkpDisplayButton( ClientData clientData) /* Information about widget. */ { TkButton *butPtr = (TkButton *) clientData; butPtr->flags &= ~REDRAW_PENDING; if (!butPtr->tkwin || !Tk_IsMapped(butPtr->tkwin)) { return; } switch (butPtr->type) { case TYPE_LABEL: DisplayUnixButton(butPtr); break; case TYPE_BUTTON: case TYPE_CHECK_BUTTON: case TYPE_RADIO_BUTTON: DisplayNativeButton(butPtr); break; } } /* *---------------------------------------------------------------------- * * TkpComputeButtonGeometry -- |
︙ | ︙ | |||
508 509 510 511 512 513 514 515 516 | * The button's window may change size. * *---------------------------------------------------------------------- */ void TkpComputeButtonGeometry( TkButton *butPtr) /* Button whose geometry may have changed. */ { | > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > | > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > | > | > < > > > > > > < > | | | | | | | | | | | | | | | | | | | | | | | | | | | | | < | | < | < < < < < < | | | | | | | < < < < | < < < < | | > | | | | | | < < < < < | < | | | < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < | > < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < | < < | < < < < < < < | < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < | < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < | < < | < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < | 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 224 225 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 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 284 285 286 287 288 289 290 291 292 293 294 295 296 297 298 299 300 301 302 303 304 305 306 307 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 338 339 340 341 342 343 344 345 346 347 348 349 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 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 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 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 703 704 705 706 707 708 709 710 711 712 713 714 715 716 717 718 719 720 721 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 773 774 775 776 777 778 779 780 781 782 783 784 785 786 787 788 789 790 791 792 793 794 795 796 797 798 799 800 801 802 803 804 805 806 807 808 809 810 811 812 813 814 815 816 817 818 819 820 821 822 823 824 825 826 827 828 829 830 831 832 833 834 835 836 837 838 839 840 841 842 843 844 845 846 847 848 849 850 851 852 853 854 855 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 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 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 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 1128 1129 1130 1131 1132 1133 1134 1135 1136 1137 1138 1139 1140 1141 1142 1143 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 1178 1179 1180 1181 1182 1183 1184 1185 1186 1187 1188 1189 | * The button's window may change size. * *---------------------------------------------------------------------- */ void TkpComputeButtonGeometry( register TkButton *butPtr) /* Button whose geometry may have changed. */ { MacButton *macButtonPtr = (MacButton *) butPtr; switch (butPtr->type) { case TYPE_LABEL: if (macButtonPtr->button && [macButtonPtr->button superview]) { [macButtonPtr->button removeFromSuperviewWithoutNeedingDisplay]; } ComputeUnixButtonGeometry(butPtr); break; case TYPE_BUTTON: case TYPE_CHECK_BUTTON: case TYPE_RADIO_BUTTON: if (!macButtonPtr->button) { NSButton *button = [[NSButton alloc] initWithFrame:NSZeroRect]; macButtonPtr->button = TkMacOSXMakeUncollectable(button); } ComputeNativeButtonGeometry(butPtr); break; } } /* *---------------------------------------------------------------------- * * TkpButtonSetDefaults -- * * This procedure is invoked before option tables are created for * buttons. It modifies some of the default values to match the current * values defined for this platform. * * Results: * Some of the default values in *specPtr are modified. * * Side effects: * Updates some of. * *---------------------------------------------------------------------- */ void TkpButtonSetDefaults( Tk_OptionSpec *specPtr) /* Points to an array of option specs, * terminated by one with type * TK_OPTION_END. */ { #if TK_MAC_BUTTON_USE_COMPATIBILITY_METRICS if (!tkMacOSXUseCompatibilityMetrics) { while (specPtr->type != TK_CONFIG_END) { switch (specPtr->internalOffset) { case Tk_Offset(TkButton, highlightWidth): specPtr->defValue = DEF_BUTTON_HIGHLIGHT_WIDTH_NOCM; break; case Tk_Offset(TkButton, padX): specPtr->defValue = DEF_BUTTON_PADX_NOCM; break; case Tk_Offset(TkButton, padY): specPtr->defValue = DEF_BUTTON_PADY_NOCM; break; } specPtr++; } } #endif } #pragma mark - #pragma mark Native Buttons: /* *---------------------------------------------------------------------- * * DisplayNativeButton -- * * This procedure is invoked to display a button widget. It is * normally invoked as an idle handler. * * Results: * None. * * Side effects: * Commands are output to X to display the button in its * current mode. The REDRAW_PENDING flag is cleared. * *---------------------------------------------------------------------- */ static void DisplayNativeButton( TkButton *butPtr) { MacButton *macButtonPtr = (MacButton *) butPtr; NSButton *button = macButtonPtr->button; Tk_Window tkwin = butPtr->tkwin; TkWindow *winPtr = (TkWindow *) tkwin; MacDrawable *macWin = (MacDrawable *) winPtr->window; TkMacOSXDrawingContext dc; NSView *view = TkMacOSXDrawableView(macWin); CGFloat viewHeight = [view bounds].size.height; CGAffineTransform t = { .a = 1, .b = 0, .c = 0, .d = -1, .tx = 0, .ty = viewHeight}; NSRect frame; int enabled; NSCellStateValue state; if (!view || !TkMacOSXSetupDrawingContext((Drawable) macWin, NULL, 1, &dc)) { return; } CGContextConcatCTM(dc.context, t); /* * We cannot change the background color of the button itself, only the * color of the background of its container. * This will be the color that peeks around the rounded corners of the * button. We make this the highlightbackground rather than the background, * because if you color the background of a frame containing a * button, you usually also color the highlightbackground as well, * or you will get a thin grey ring around the button. */ Tk_Fill3DRectangle(tkwin, (Pixmap) macWin, butPtr->type == TYPE_BUTTON ? butPtr->highlightBorder : butPtr->normalBorder, 0, 0, Tk_Width(tkwin), Tk_Height(tkwin), 0, TK_RELIEF_FLAT); if ([button superview] != view) { [view addSubview:button]; } if (macButtonPtr->tristateImage) { NSImage *selectImage = macButtonPtr->selectImage ? macButtonPtr->selectImage : macButtonPtr->image; [button setImage:(butPtr->flags & TRISTATED ? selectImage : macButtonPtr->image)]; [button setAlternateImage:(butPtr->flags & TRISTATED ? macButtonPtr->tristateImage : selectImage)]; } if (butPtr->flags & SELECTED) { state = NSOnState; } else if (butPtr->flags & TRISTATED) { state = NSMixedState; } else { state = NSOffState; } [button setState:state]; enabled = !(butPtr->state == STATE_DISABLED); [button setEnabled:enabled]; if (enabled) { //[button highlight:(butPtr->state == STATE_ACTIVE)]; //[cell setHighlighted:(butPtr->state == STATE_ACTIVE)]; } if (butPtr->type == TYPE_BUTTON && butPtr->defaultState == STATE_ACTIVE) { //[[view window] setDefaultButtonCell:cell]; [button setKeyEquivalent:@"\r"]; } else { [button setKeyEquivalent:@""]; } frame = NSMakeRect(macWin->xOff, macWin->yOff, Tk_Width(tkwin), Tk_Height(tkwin)); #if TK_MAC_BUTTON_USE_COMPATIBILITY_METRICS if (tkMacOSXUseCompatibilityMetrics) { BoundsFix boundsFix = boundsFixes[macButtonPtr->fix]; frame = NSOffsetRect(frame, boundsFix.offsetX, boundsFix.offsetY); frame.size.height -= boundsFix.shrinkH + NATIVE_BUTTON_EXTRA_H; frame = NSInsetRect(frame, boundsFix.inset + NATIVE_BUTTON_INSET, boundsFix.inset + NATIVE_BUTTON_INSET); } #endif frame.origin.y = viewHeight - (frame.origin.y + frame.size.height); if (!NSEqualRects(frame, [button frame])) { [button setFrame:frame]; } [button displayRectIgnoringOpacity:[button bounds]]; TkMacOSXRestoreDrawingContext(&dc); #ifdef TK_MAC_DEBUG_BUTTON TKLog(@"button %s frame %@ width %d height %d", ((TkWindow *)butPtr->tkwin)->pathName, NSStringFromRect(frame), Tk_Width(tkwin), Tk_Height(tkwin)); #endif } /* *---------------------------------------------------------------------- * * ComputeNativeButtonGeometry -- * * After changes in a button's text or bitmap, this procedure * recomputes the button's geometry and passes this information * along to the geometry manager for the window. * * Results: * None. * * Side effects: * The button's window may change size. * *---------------------------------------------------------------------- */ static void ComputeNativeButtonGeometry( TkButton *butPtr) /* Button whose geometry may have changed. */ { MacButton *macButtonPtr = (MacButton *) butPtr; NSButton *button = macButtonPtr->button; NSButtonCell *cell = [button cell]; NSButtonType type = -1; NSBezelStyle style = 0; NSInteger highlightsBy = 0, showsStateBy = 0; NSFont *font; NSRect bounds = NSZeroRect, titleRect = NSZeroRect; int haveImage = (butPtr->image || butPtr->bitmap != None), haveText = 0; int haveCompound = (butPtr->compound != COMPOUND_NONE); int width, height, border = 0; butPtr->indicatorSpace = 0; butPtr->inset = 0; if (butPtr->highlightWidth < 0) { butPtr->highlightWidth = 0; } switch (butPtr->type) { case TYPE_BUTTON: type = NSMomentaryPushInButton; if (!haveImage) { style = NSRoundedBezelStyle; butPtr->inset = butPtr->defaultState != STATE_DISABLED ? butPtr->highlightWidth : 0; [button setImage:nil]; [button setImagePosition:NSNoImage]; } else { style = NSShadowlessSquareBezelStyle; highlightsBy = butPtr->selectImage || butPtr->bitmap ? NSContentsCellMask : 0; border = butPtr->borderWidth; } break; case TYPE_RADIO_BUTTON: case TYPE_CHECK_BUTTON: if (!haveImage /*|| butPtr->indicatorOn*/) { // TODO: indicatorOn type = butPtr->type == TYPE_RADIO_BUTTON ? NSRadioButton : NSSwitchButton; butPtr->inset = /*butPtr->indicatorOn ? 0 :*/ butPtr->borderWidth; } else { type = NSPushOnPushOffButton; style = NSShadowlessSquareBezelStyle; highlightsBy = butPtr->selectImage || butPtr->bitmap ? NSContentsCellMask : 0; showsStateBy = butPtr->selectImage || butPtr->tristateImage ? NSContentsCellMask : 0; #if TK_MAC_BUTTON_USE_COMPATIBILITY_METRICS if (tkMacOSXUseCompatibilityMetrics) { border = butPtr->borderWidth > 1 ? butPtr->borderWidth - 1 : 1; } else #endif { border = butPtr->borderWidth; } } break; } [button setButtonType:type]; if (style) { [button setBezelStyle:style]; } if (highlightsBy) { [cell setHighlightsBy:highlightsBy|[cell highlightsBy]]; } if (showsStateBy) { [cell setShowsStateBy:showsStateBy|[cell showsStateBy]]; } #if 0 if (style == NSShadowlessSquareBezelStyle) { NSControlSize controlSize = NSRegularControlSize; if (butPtr->borderWidth <= 2) { controlSize = NSMiniControlSize; } else if (butPtr->borderWidth == 3) { controlSize = NSSmallControlSize; } [cell setControlSize:controlSize]; } #endif [button setAllowsMixedState:YES]; if (!haveImage || haveCompound) { int len; char *text = Tcl_GetStringFromObj(butPtr->textPtr, &len); if (len) { NSString *title = [[NSString alloc] initWithBytes:text length:len encoding:NSUTF8StringEncoding]; [button setTitle:title]; [title release]; haveText = 1; } } haveCompound = (haveCompound && haveImage && haveText); if (haveText) { NSTextAlignment alignment = NSNaturalTextAlignment; switch (butPtr->justify) { case TK_JUSTIFY_LEFT: alignment = NSLeftTextAlignment; break; case TK_JUSTIFY_RIGHT: alignment = NSRightTextAlignment; break; case TK_JUSTIFY_CENTER: alignment = NSCenterTextAlignment; break; } [button setAlignment:alignment]; } else { [button setTitle:@""]; } font = TkMacOSXNSFontForFont(butPtr->tkfont); if (font) { [button setFont:font]; } TkMacOSXMakeCollectableAndRelease(macButtonPtr->image); TkMacOSXMakeCollectableAndRelease(macButtonPtr->selectImage); TkMacOSXMakeCollectableAndRelease(macButtonPtr->tristateImage); if (haveImage) { int width, height; NSImage *image, *selectImage = nil, *tristateImage = nil; NSCellImagePosition pos = NSImageOnly; if (butPtr->image) { Tk_SizeOfImage(butPtr->image, &width, &height); image = TkMacOSXGetNSImageWithTkImage(butPtr->display, butPtr->image, width, height); if (butPtr->selectImage) { selectImage = TkMacOSXGetNSImageWithTkImage(butPtr->display, butPtr->selectImage, width, height); } if (butPtr->tristateImage) { tristateImage = TkMacOSXGetNSImageWithTkImage(butPtr->display, butPtr->tristateImage, width, height); } } else { Tk_SizeOfBitmap(butPtr->display, butPtr->bitmap, &width, &height); image = TkMacOSXGetNSImageWithBitmap(butPtr->display, butPtr->bitmap, butPtr->normalTextGC, width, height); selectImage = TkMacOSXGetNSImageWithBitmap(butPtr->display, butPtr->bitmap, butPtr->activeTextGC, width, height); } [button setImage:image]; if (selectImage) { [button setAlternateImage:selectImage]; } if (tristateImage) { macButtonPtr->image = TkMacOSXMakeUncollectableAndRetain(image); if (selectImage) { macButtonPtr->selectImage = TkMacOSXMakeUncollectableAndRetain(selectImage); } macButtonPtr->tristateImage = TkMacOSXMakeUncollectableAndRetain(tristateImage); } if (haveCompound) { switch ((enum compound) butPtr->compound) { case COMPOUND_TOP: pos = NSImageAbove; break; case COMPOUND_BOTTOM: pos = NSImageBelow; break; case COMPOUND_LEFT: pos = NSImageLeft; break; case COMPOUND_RIGHT: pos = NSImageRight; break; case COMPOUND_CENTER: pos = NSImageOverlaps; break; case COMPOUND_NONE: pos = NSImageOnly; break; } } [button setImagePosition:pos]; } // if font is too tall, we can't use the fixed-height rounded bezel if (!haveImage && haveText && style == NSRoundedBezelStyle) { Tk_FontMetrics fm; Tk_GetFontMetrics(butPtr->tkfont, &fm); if (fm.linespace > 18) { [button setBezelStyle:(style = NSRegularSquareBezelStyle)]; } } bounds.size = [cell cellSize]; if (haveText) { titleRect = [cell titleRectForBounds:bounds]; if (butPtr->wrapLength > 0 && titleRect.size.width > butPtr->wrapLength) { if (style == NSRoundedBezelStyle) { [button setBezelStyle:(style = NSRegularSquareBezelStyle)]; bounds.size = [cell cellSize]; titleRect = [cell titleRectForBounds:bounds]; } bounds.size.width -= titleRect.size.width - butPtr->wrapLength; bounds.size.height = 40000.0; [cell setWraps:YES]; bounds.size = [cell cellSizeForBounds:bounds]; #ifdef TK_MAC_DEBUG_BUTTON titleRect = [cell titleRectForBounds:bounds]; #endif #if TK_MAC_BUTTON_USE_COMPATIBILITY_METRICS if (tkMacOSXUseCompatibilityMetrics) { bounds.size.height += 3; } #endif } } width = lround(bounds.size.width); height = lround(bounds.size.height); #if TK_MAC_BUTTON_USE_COMPATIBILITY_METRICS if (tkMacOSXUseCompatibilityMetrics) { macButtonPtr->fix = fixForTypeStyle(type, style); width -= boundsFixes[macButtonPtr->fix].trimW; height -= boundsFixes[macButtonPtr->fix].trimH; } #endif if (haveImage || haveCompound) { if (butPtr->width > 0) { width = butPtr->width; } if (butPtr->height > 0) { height = butPtr->height; } } else { if (butPtr->width > 0) { int avgWidth = Tk_TextWidth(butPtr->tkfont, "0", 1); width = butPtr->width * avgWidth; } if (butPtr->height > 0) { Tk_FontMetrics fm; Tk_GetFontMetrics(butPtr->tkfont, &fm); height = butPtr->height * fm.linespace; } } if (!haveImage || haveCompound) { width += 2*butPtr->padX; height += 2*butPtr->padY; } if (haveImage) { width += 2*border; height += 2*border; } #if TK_MAC_BUTTON_USE_COMPATIBILITY_METRICS if (tkMacOSXUseCompatibilityMetrics) { width += 2*NATIVE_BUTTON_INSET; height += 2*NATIVE_BUTTON_INSET + NATIVE_BUTTON_EXTRA_H; } #endif Tk_GeometryRequest(butPtr->tkwin, width, height); Tk_SetInternalBorder(butPtr->tkwin, butPtr->inset); #ifdef TK_MAC_DEBUG_BUTTON TKLog(@"button %s bounds %@ titleRect %@ width %d height %d inset %d borderWidth %d", ((TkWindow *)butPtr->tkwin)->pathName, NSStringFromRect(bounds), NSStringFromRect(titleRect), width, height, butPtr->inset, butPtr->borderWidth); #endif } #pragma mark - #pragma mark Unix Buttons: /* *---------------------------------------------------------------------- * * DisplayUnixButton -- * * This procedure is invoked to display a button widget. It is * normally invoked as an idle handler. * * Results: * None. * * Side effects: * Commands are output to X to display the button in its * current mode. The REDRAW_PENDING flag is cleared. * *---------------------------------------------------------------------- */ void DisplayUnixButton( TkButton *butPtr) { GC gc; Tk_3DBorder border; Pixmap pixmap; int x = 0; /* Initialization only needed to stop compiler * warning. */ int y, relief; Tk_Window tkwin = butPtr->tkwin; int width = 0, height = 0, fullWidth, fullHeight; int textXOffset, textYOffset; int haveImage = 0, haveText = 0; int imageWidth, imageHeight; int imageXOffset = 0, imageYOffset = 0; /* image information that will be used to * restrict disabled pixmap as well */ border = butPtr->normalBorder; if ((butPtr->state == STATE_DISABLED) && (butPtr->disabledFg != NULL)) { gc = butPtr->disabledGC; } else if ((butPtr->state == STATE_ACTIVE) && !Tk_StrictMotif(butPtr->tkwin)) { gc = butPtr->activeTextGC; border = butPtr->activeBorder; } else { gc = butPtr->normalTextGC; } if ((butPtr->flags & SELECTED) && (butPtr->state != STATE_ACTIVE) && (butPtr->selectBorder != NULL) && !butPtr->indicatorOn) { border = butPtr->selectBorder; } relief = butPtr->relief; pixmap = (Pixmap) Tk_WindowId(tkwin); Tk_Fill3DRectangle(tkwin, pixmap, border, 0, 0, Tk_Width(tkwin), Tk_Height(tkwin), 0, TK_RELIEF_FLAT); /* * Display image or bitmap or text for button. */ if (butPtr->image != NULL) { Tk_SizeOfImage(butPtr->image, &width, &height); haveImage = 1; } else if (butPtr->bitmap != None) { Tk_SizeOfBitmap(butPtr->display, butPtr->bitmap, &width, &height); haveImage = 1; } imageWidth = width; imageHeight = height; haveText = (butPtr->textWidth != 0 && butPtr->textHeight != 0); if (butPtr->compound != COMPOUND_NONE && haveImage && haveText) { textXOffset = 0; textYOffset = 0; fullWidth = 0; fullHeight = 0; switch ((enum compound) butPtr->compound) { case COMPOUND_TOP: case COMPOUND_BOTTOM: /* * Image is above or below text. */ if (butPtr->compound == COMPOUND_TOP) { textYOffset = height + butPtr->padY; } else { imageYOffset = butPtr->textHeight + butPtr->padY; } fullHeight = height + butPtr->textHeight + butPtr->padY; fullWidth = (width > butPtr->textWidth ? width : butPtr->textWidth); textXOffset = (fullWidth - butPtr->textWidth)/2; imageXOffset = (fullWidth - width)/2; break; case COMPOUND_LEFT: case COMPOUND_RIGHT: /* * Image is left or right of text. */ if (butPtr->compound == COMPOUND_LEFT) { textXOffset = width + butPtr->padX; } else { imageXOffset = butPtr->textWidth + butPtr->padX; } fullWidth = butPtr->textWidth + butPtr->padX + width; fullHeight = (height > butPtr->textHeight ? height : butPtr->textHeight); textYOffset = (fullHeight - butPtr->textHeight)/2; imageYOffset = (fullHeight - height)/2; break; case COMPOUND_CENTER: /* * Image and text are superimposed. */ fullWidth = (width > butPtr->textWidth ? width : butPtr->textWidth); fullHeight = (height > butPtr->textHeight ? height : butPtr->textHeight); textXOffset = (fullWidth - butPtr->textWidth)/2; imageXOffset = (fullWidth - width)/2; textYOffset = (fullHeight - butPtr->textHeight)/2; imageYOffset = (fullHeight - height)/2; break; case COMPOUND_NONE: break; } TkComputeAnchor(butPtr->anchor, tkwin, butPtr->padX, butPtr->padY, fullWidth, fullHeight, &x, &y); imageXOffset += x; imageYOffset += y; if (butPtr->image != NULL) { /* * Do boundary clipping, so that Tk_RedrawImage is passed valid * coordinates. [Bug 979239] */ if (imageXOffset < 0) { imageXOffset = 0; } if (imageYOffset < 0) { imageYOffset = 0; } if (width > Tk_Width(tkwin)) { width = Tk_Width(tkwin); } if (height > Tk_Height(tkwin)) { height = Tk_Height(tkwin); } if ((width + imageXOffset) > Tk_Width(tkwin)) { imageXOffset = Tk_Width(tkwin) - width; } if ((height + imageYOffset) > Tk_Height(tkwin)) { imageYOffset = Tk_Height(tkwin) - height; } if ((butPtr->selectImage != NULL) && (butPtr->flags & SELECTED)) { Tk_RedrawImage(butPtr->selectImage, 0, 0, width, height, pixmap, imageXOffset, imageYOffset); } else if ((butPtr->tristateImage != NULL) && (butPtr->flags & TRISTATED)) { Tk_RedrawImage(butPtr->tristateImage, 0, 0, width, height, pixmap, imageXOffset, imageYOffset); } else { Tk_RedrawImage(butPtr->image, 0, 0, width, height, pixmap, imageXOffset, imageYOffset); } } else { XSetClipOrigin(butPtr->display, gc, imageXOffset, imageYOffset); XCopyPlane(butPtr->display, butPtr->bitmap, pixmap, gc, 0, 0, (unsigned int) width, (unsigned int) height, imageXOffset, imageYOffset, 1); XSetClipOrigin(butPtr->display, gc, 0, 0); } Tk_DrawTextLayout(butPtr->display, pixmap, gc, butPtr->textLayout, x + textXOffset, y + textYOffset, 0, -1); Tk_UnderlineTextLayout(butPtr->display, pixmap, gc, butPtr->textLayout, x + textXOffset, y + textYOffset, butPtr->underline); y += fullHeight/2; } else { if (haveImage) { TkComputeAnchor(butPtr->anchor, tkwin, 0, 0, width, height, &x, &y); imageXOffset += x; imageYOffset += y; if (butPtr->image != NULL) { /* * Do boundary clipping, so that Tk_RedrawImage is passed * valid coordinates. [Bug 979239] */ if (imageXOffset < 0) { imageXOffset = 0; } if (imageYOffset < 0) { imageYOffset = 0; } if (width > Tk_Width(tkwin)) { width = Tk_Width(tkwin); } if (height > Tk_Height(tkwin)) { height = Tk_Height(tkwin); } if ((width + imageXOffset) > Tk_Width(tkwin)) { imageXOffset = Tk_Width(tkwin) - width; } if ((height + imageYOffset) > Tk_Height(tkwin)) { imageYOffset = Tk_Height(tkwin) - height; } if ((butPtr->selectImage != NULL) && (butPtr->flags & SELECTED)) { Tk_RedrawImage(butPtr->selectImage, 0, 0, width, height, pixmap, imageXOffset, imageYOffset); } else if ((butPtr->tristateImage != NULL) && (butPtr->flags & TRISTATED)) { Tk_RedrawImage(butPtr->tristateImage, 0, 0, width, height, pixmap, imageXOffset, imageYOffset); } else { Tk_RedrawImage(butPtr->image, 0, 0, width, height, pixmap, imageXOffset, imageYOffset); } } else { XSetClipOrigin(butPtr->display, gc, x, y); XCopyPlane(butPtr->display, butPtr->bitmap, pixmap, gc, 0, 0, (unsigned int) width, (unsigned int) height, x, y, 1); XSetClipOrigin(butPtr->display, gc, 0, 0); } y += height/2; } else { TkComputeAnchor(butPtr->anchor, tkwin, butPtr->padX, butPtr->padY, butPtr->textWidth, butPtr->textHeight, &x, &y); Tk_DrawTextLayout(butPtr->display, pixmap, gc, butPtr->textLayout, x, y, 0, -1); Tk_UnderlineTextLayout(butPtr->display, pixmap, gc, butPtr->textLayout, x, y, butPtr->underline); y += butPtr->textHeight/2; } } /* * If the button is disabled with a stipple rather than a special * foreground color, generate the stippled effect. If the widget is * selected and we use a different background color when selected, must * temporarily modify the GC so the stippling is the right color. */ if ((butPtr->state == STATE_DISABLED) && ((butPtr->disabledFg == NULL) || (butPtr->image != NULL))) { if ((butPtr->flags & SELECTED) && !butPtr->indicatorOn && (butPtr->selectBorder != NULL)) { XSetForeground(butPtr->display, butPtr->stippleGC, Tk_3DBorderColor(butPtr->selectBorder)->pixel); } /* * Stipple the whole button if no disabledFg was specified, otherwise * restrict stippling only to displayed image */ if (butPtr->disabledFg == NULL) { XFillRectangle(butPtr->display, pixmap, butPtr->stippleGC, 0, 0, (unsigned) Tk_Width(tkwin), (unsigned) Tk_Height(tkwin)); } else { XFillRectangle(butPtr->display, pixmap, butPtr->stippleGC, imageXOffset, imageYOffset, (unsigned) imageWidth, (unsigned) imageHeight); } if ((butPtr->flags & SELECTED) && !butPtr->indicatorOn && (butPtr->selectBorder != NULL)) { XSetForeground(butPtr->display, butPtr->stippleGC, Tk_3DBorderColor(butPtr->normalBorder)->pixel); } } /* * Draw the border and traversal highlight last. This way, if the button's * contents overflow they'll be covered up by the border. This code is * complicated by the possible combinations of focus highlight and default * rings. We draw the focus and highlight rings using the highlight border * and highlight foreground color. */ if (relief != TK_RELIEF_FLAT) { int inset = butPtr->highlightWidth; if (butPtr->defaultState == DEFAULT_ACTIVE) { /* * Draw the default ring with 2 pixels of space between the * default ring and the button and the default ring and the focus * ring. Note that we need to explicitly draw the space in the * highlightBorder color to ensure that we overwrite any overflow * text and/or a different button background color. */ Tk_Draw3DRectangle(tkwin, pixmap, butPtr->highlightBorder, inset, inset, Tk_Width(tkwin) - 2*inset, Tk_Height(tkwin) - 2*inset, 2, TK_RELIEF_FLAT); inset += 2; Tk_Draw3DRectangle(tkwin, pixmap, butPtr->highlightBorder, inset, inset, Tk_Width(tkwin) - 2*inset, Tk_Height(tkwin) - 2*inset, 1, TK_RELIEF_SUNKEN); inset++; Tk_Draw3DRectangle(tkwin, pixmap, butPtr->highlightBorder, inset, inset, Tk_Width(tkwin) - 2*inset, Tk_Height(tkwin) - 2*inset, 2, TK_RELIEF_FLAT); inset += 2; } else if (butPtr->defaultState == DEFAULT_NORMAL) { /* * Leave room for the default ring and write over any text or * background color. */ Tk_Draw3DRectangle(tkwin, pixmap, butPtr->highlightBorder, 0, 0, Tk_Width(tkwin), Tk_Height(tkwin), 5, TK_RELIEF_FLAT); inset += 5; } /* * Draw the button border. */ Tk_Draw3DRectangle(tkwin, pixmap, border, inset, inset, Tk_Width(tkwin) - 2*inset, Tk_Height(tkwin) - 2*inset, butPtr->borderWidth, relief); } if (butPtr->highlightWidth > 0) { GC gc; if (butPtr->flags & GOT_FOCUS) { gc = Tk_GCForColor(butPtr->highlightColorPtr, pixmap); } else { gc = Tk_GCForColor(Tk_3DBorderColor(butPtr->highlightBorder), pixmap); } /* * Make sure the focus ring shrink-wraps the actual button, not the * padding space left for a default ring. */ if (butPtr->defaultState == DEFAULT_NORMAL) { TkDrawInsetFocusHighlight(tkwin, gc, butPtr->highlightWidth, pixmap, 5); } else { Tk_DrawFocusHighlight(tkwin, gc, butPtr->highlightWidth, pixmap); } } } /* *---------------------------------------------------------------------- * * ComputeUnixButtonGeometry -- * * After changes in a button's text or bitmap, this procedure * recomputes the button's geometry and passes this information * along to the geometry manager for the window. * * Results: * None. * * Side effects: * The button's window may change size. * *---------------------------------------------------------------------- */ void ComputeUnixButtonGeometry( register TkButton *butPtr) /* Button whose geometry may have changed. */ { int width, height, avgWidth, txtWidth, txtHeight; int haveImage = 0, haveText = 0; Tk_FontMetrics fm; butPtr->inset = butPtr->highlightWidth + butPtr->borderWidth; /* * Leave room for the default ring if needed. */ if (butPtr->defaultState != DEFAULT_DISABLED) { butPtr->inset += 5; } butPtr->indicatorSpace = 0; width = 0; height = 0; txtWidth = 0; txtHeight = 0; avgWidth = 0; if (butPtr->image != NULL) { Tk_SizeOfImage(butPtr->image, &width, &height); haveImage = 1; } else if (butPtr->bitmap != None) { Tk_SizeOfBitmap(butPtr->display, butPtr->bitmap, &width, &height); haveImage = 1; } if (haveImage == 0 || butPtr->compound != COMPOUND_NONE) { Tk_FreeTextLayout(butPtr->textLayout); butPtr->textLayout = Tk_ComputeTextLayout(butPtr->tkfont, Tcl_GetString(butPtr->textPtr), -1, butPtr->wrapLength, butPtr->justify, 0, &butPtr->textWidth, &butPtr->textHeight); txtWidth = butPtr->textWidth; txtHeight = butPtr->textHeight; avgWidth = Tk_TextWidth(butPtr->tkfont, "0", 1); Tk_GetFontMetrics(butPtr->tkfont, &fm); haveText = (txtWidth != 0 && txtHeight != 0); } /* * If the button is compound (i.e., it shows both an image and text), the * new geometry is a combination of the image and text geometry. We only * honor the compound bit if the button has both text and an image, * because otherwise it is not really a compound button. */ if (butPtr->compound != COMPOUND_NONE && haveImage && haveText) { switch ((enum compound) butPtr->compound) { case COMPOUND_TOP: case COMPOUND_BOTTOM: /* * Image is above or below text. */ height += txtHeight + butPtr->padY; width = (width > txtWidth ? width : txtWidth); break; case COMPOUND_LEFT: case COMPOUND_RIGHT: /* * Image is left or right of text. */ width += txtWidth + butPtr->padX; height = (height > txtHeight ? height : txtHeight); break; case COMPOUND_CENTER: /* * Image and text are superimposed. */ width = (width > txtWidth ? width : txtWidth); height = (height > txtHeight ? height : txtHeight); break; case COMPOUND_NONE: break; } if (butPtr->width > 0) { width = butPtr->width; } if (butPtr->height > 0) { height = butPtr->height; } width += 2*butPtr->padX; height += 2*butPtr->padY; } else { if (haveImage) { if (butPtr->width > 0) { width = butPtr->width; } if (butPtr->height > 0) { height = butPtr->height; } } else { width = txtWidth; height = txtHeight; if (butPtr->width > 0) { width = butPtr->width * avgWidth; } if (butPtr->height > 0) { height = butPtr->height * fm.linespace; } } } if (!haveImage) { width += 2*butPtr->padX; height += 2*butPtr->padY; } Tk_GeometryRequest(butPtr->tkwin, (int) (width + 2*butPtr->inset), (int) (height + 2*butPtr->inset)); Tk_SetInternalBorder(butPtr->tkwin, butPtr->inset); } /* * Local Variables: * mode: c * c-basic-offset: 4 * fill-column: 79 * coding: utf-8 * End: */ |
Changes to macosx/tkMacOSXClipboard.c.
1 2 3 4 5 6 | /* * tkMacOSXClipboard.c -- * * This file manages the clipboard for the Tk toolkit. * * Copyright (c) 1995-1997 Sun Microsystems, Inc. | | | > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > | | | | | | | < < < < | < < < < < < < | < < < | < < < < < < | < | < < < < < < | < < < < < < < < | < < | < | < < < < < < < < < | < < < < < < < | < < < < < < < < < < < < < | < < | < < < < | | | | > | | | | < < | > > > > > > > > > | < < < > | | | > | > > | < > > | > > | > > > > | | < < | | < > > > | < > | | < | 1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 34 35 36 37 38 39 40 41 42 43 44 45 46 47 48 49 50 51 52 53 54 55 56 57 58 59 60 61 62 63 64 65 66 67 68 69 70 71 72 73 74 75 76 77 78 79 80 81 82 83 84 85 86 87 88 89 90 91 92 93 94 95 96 97 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 129 130 131 132 133 134 135 136 137 138 139 140 141 142 143 144 145 146 147 148 149 150 151 152 153 154 155 156 157 158 159 160 161 162 163 164 165 166 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 224 225 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 256 257 258 259 260 261 262 263 264 265 266 267 268 269 | /* * tkMacOSXClipboard.c -- * * This file manages the clipboard for the Tk toolkit. * * Copyright (c) 1995-1997 Sun Microsystems, Inc. * Copyright 2001-2009, Apple Inc. * Copyright (c) 2006-2009 Daniel A. Steffen <[email protected]> * * See the file "license.terms" for information on usage and redistribution * of this file, and for a DISCLAIMER OF ALL WARRANTIES. */ #include "tkMacOSXPrivate.h" #include "tkSelect.h" static NSInteger changeCount = -1; static Tk_Window clipboardOwner = NULL; #pragma mark TKApplication(TKClipboard) @implementation TKApplication(TKClipboard) - (void)tkProvidePasteboard:(TkDisplay *)dispPtr pasteboard:(NSPasteboard *)sender provideDataForType:(NSString *)type { NSMutableString *string = [NSMutableString new]; if (dispPtr && dispPtr->clipboardActive && [type isEqualToString:NSStringPboardType]) { for (TkClipboardTarget *targetPtr = dispPtr->clipTargetPtr; targetPtr; targetPtr = targetPtr->nextPtr) { if (targetPtr->type == XA_STRING || targetPtr->type == dispPtr->utf8Atom) { for (TkClipboardBuffer *cbPtr = targetPtr->firstBufferPtr; cbPtr; cbPtr = cbPtr->nextPtr) { NSString *s = [[NSString alloc] initWithBytesNoCopy: cbPtr->buffer length:cbPtr->length encoding:NSUTF8StringEncoding freeWhenDone:NO]; [string appendString:s]; [s release]; } break; } } } [sender setString:string forType:type]; [string release]; } - (void)tkProvidePasteboard:(TkDisplay *)dispPtr { if (dispPtr && dispPtr->clipboardActive) { [self tkProvidePasteboard:dispPtr pasteboard:[NSPasteboard generalPasteboard] provideDataForType:NSStringPboardType]; } } - (void)pasteboard:(NSPasteboard *)sender provideDataForType:(NSString *)type { [self tkProvidePasteboard:TkGetDisplayList() pasteboard:sender provideDataForType:type]; } - (void)tkCheckPasteboard { if (clipboardOwner && [[NSPasteboard generalPasteboard] changeCount] != changeCount) { TkDisplay *dispPtr = TkGetDisplayList(); if (dispPtr) { XEvent event; event.xany.type = SelectionClear; event.xany.serial = NextRequest(Tk_Display(clipboardOwner)); event.xany.send_event = False; event.xany.window = Tk_WindowId(clipboardOwner); event.xany.display = Tk_Display(clipboardOwner); event.xselectionclear.selection = dispPtr->clipboardAtom; Tk_QueueWindowEvent(&event, TCL_QUEUE_TAIL); } clipboardOwner = NULL; } } @end #pragma mark - /* *---------------------------------------------------------------------- * * TkSelGetSelection -- * * Retrieve the specified selection from another process. For now, only * fetching XA_STRING from CLIPBOARD is supported. Eventually other types * should be allowed. * * Results: * The return value is a standard Tcl return value. If an error occurs * (such as no selection exists) then an error message is left in the * interp's result. * * Side effects: * None. * *---------------------------------------------------------------------- */ int TkSelGetSelection( Tcl_Interp *interp, /* Interpreter to use for reporting errors. */ Tk_Window tkwin, /* Window on whose behalf to retrieve the * selection (determines display from which to * retrieve). */ Atom selection, /* Selection to retrieve. */ Atom target, /* Desired form in which selection is to be * returned. */ Tk_GetSelProc *proc, /* Procedure to call to process the selection, * once it has been retrieved. */ ClientData clientData) /* Arbitrary value to pass to proc. */ { int result = TCL_ERROR; TkDisplay *dispPtr = ((TkWindow *) tkwin)->dispPtr; if (dispPtr && selection == dispPtr->clipboardAtom && (target == XA_STRING || target == dispPtr->utf8Atom)) { NSString *string = nil; NSPasteboard *pb = [NSPasteboard generalPasteboard]; NSString *type = [pb availableTypeFromArray:[NSArray arrayWithObject: NSStringPboardType]]; if (type) { string = [pb stringForType:type]; } result = proc(clientData, interp, string ? (char*)[string UTF8String] : ""); } else { Tcl_AppendResult(interp, Tk_GetAtomName(tkwin, selection), " selection doesn't exist or form \"", Tk_GetAtomName(tkwin, target), "\" not defined", NULL); } return result; } /* *---------------------------------------------------------------------- * * XSetSelectionOwner -- * * This function claims ownership of the specified selection. If the * selection is CLIPBOARD, then we empty the system clipboard. * * Results: * None. * * Side effects: * None. * *---------------------------------------------------------------------- */ int XSetSelectionOwner( Display *display, /* X Display. */ Atom selection, /* What selection to own. */ Window owner, /* Window to be the owner. */ Time time) /* The current time? */ { TkDisplay *dispPtr = TkGetDisplayList(); if (dispPtr && selection == dispPtr->clipboardAtom) { clipboardOwner = owner ? Tk_IdToWindow(display, owner) : NULL; if (!dispPtr->clipboardActive) { NSPasteboard *pb = [NSPasteboard generalPasteboard]; changeCount = [pb declareTypes:[NSArray array] owner:NSApp]; } } } /* *---------------------------------------------------------------------- * * TkMacOSXSelDeadWindow -- * * This function is invoked just before a TkWindow is deleted. It * performs selection-related cleanup. * * Results: * None. * * Side effects: * clipboardOwner is cleared. * *---------------------------------------------------------------------- */ void TkMacOSXSelDeadWindow( TkWindow *winPtr) { if (winPtr && winPtr == (TkWindow *)clipboardOwner) { clipboardOwner = NULL; } return Success; } /* *---------------------------------------------------------------------- * * TkSelUpdateClipboard -- * * This function is called to force the clipboard to be updated after new * data is added. * * Results: * None. * * Side effects: * None. * *---------------------------------------------------------------------- */ void TkSelUpdateClipboard( TkWindow *winPtr, /* Window associated with clipboard. */ TkClipboardTarget *targetPtr) /* Info about the content. */ { NSPasteboard *pb = [NSPasteboard generalPasteboard]; changeCount = [pb addTypes:[NSArray arrayWithObject:NSStringPboardType] owner:NSApp]; } /* *-------------------------------------------------------------- * * TkSelEventProc -- * * This procedure is invoked whenever a selection-related event occurs. * * Results: * None. * * Side effects: * Lots: depends on the type of event. * *-------------------------------------------------------------- */ void TkSelEventProc( Tk_Window tkwin, /* Window for which event was targeted. */ register XEvent *eventPtr) /* X event: either SelectionClear, * SelectionRequest, or SelectionNotify. */ { if (eventPtr->type == SelectionClear) { clipboardOwner = NULL; TkSelClearSelection(tkwin, eventPtr); } } /* *---------------------------------------------------------------------- * * TkSelPropProc -- * * This procedure is invoked when property-change events occur on windows * not known to the toolkit. This is a stub function under Windows. * * Results: * None. * * Side effects: * None. * |
︙ | ︙ | |||
272 273 274 275 276 277 278 | /* *---------------------------------------------------------------------- * * TkSuspendClipboard -- * * Handle clipboard conversion as required by the suppend event. | < < < < < < < | < < < | | < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < | < > | | < < < < < < | < < | | < < < | < < < < < < < < < | 278 279 280 281 282 283 284 285 286 287 288 289 290 291 292 293 294 295 296 297 298 299 300 301 302 303 304 305 306 307 308 | /* *---------------------------------------------------------------------- * * TkSuspendClipboard -- * * Handle clipboard conversion as required by the suppend event. * * Results: * None. * * Side effects: * The local scrap is moved to the global scrap. * *---------------------------------------------------------------------- */ void TkSuspendClipboard(void) { changeCount = [[NSPasteboard generalPasteboard] changeCount]; } /* * Local Variables: * mode: c * c-basic-offset: 4 * fill-column: 79 * coding: utf-8 * End: */ |
Changes to macosx/tkMacOSXColor.c.
1 2 3 4 5 6 7 8 9 | /* * tkMacOSXColor.c -- * * This file maintains a database of color values for the Tk * toolkit, in order to avoid round-trips to the server to * map color names to pixel values. * * Copyright (c) 1990-1994 The Regents of the University of California. * Copyright (c) 1994-1996 Sun Microsystems, Inc. | | | < < < < < | 1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 | /* * tkMacOSXColor.c -- * * This file maintains a database of color values for the Tk * toolkit, in order to avoid round-trips to the server to * map color names to pixel values. * * Copyright (c) 1990-1994 The Regents of the University of California. * Copyright (c) 1994-1996 Sun Microsystems, Inc. * Copyright 2001-2009, Apple Inc. * Copyright (c) 2006-2009 Daniel A. Steffen <[email protected]> * * See the file "license.terms" for information on usage and redistribution * of this file, and for a DISCLAIMER OF ALL WARRANTIES. */ #include "tkMacOSXPrivate.h" #include "tkColor.h" struct SystemColorMapEntry { const char *name; ThemeBrush brush; ThemeTextColor textColor; ThemeBackgroundKind background; }; /* unsigned char pixelCode; */ |
︙ | ︙ | |||
172 173 174 175 176 177 178 | { "WindowHeaderBackground", 0, 0, kThemeBackgroundWindowHeader }, /* 162 */ { "ListViewWindowHeaderBackground", 0, 0, kThemeBackgroundListViewWindowHeader }, /* 163 */ { "SecondaryGroupBoxBackground", 0, 0, kThemeBackgroundSecondaryGroupBox }, /* 164 */ { "MetalBackground", 0, 0, kThemeBackgroundMetal }, /* 165 */ { NULL, 0, 0, 0 } }; #define MAX_PIXELCODE 165 | | | 167 168 169 170 171 172 173 174 175 176 177 178 179 180 181 | { "WindowHeaderBackground", 0, 0, kThemeBackgroundWindowHeader }, /* 162 */ { "ListViewWindowHeaderBackground", 0, 0, kThemeBackgroundListViewWindowHeader }, /* 163 */ { "SecondaryGroupBoxBackground", 0, 0, kThemeBackgroundSecondaryGroupBox }, /* 164 */ { "MetalBackground", 0, 0, kThemeBackgroundMetal }, /* 165 */ { NULL, 0, 0, 0 } }; #define MAX_PIXELCODE 165 /* *---------------------------------------------------------------------- * * GetThemeFromPixelCode -- * * When given a pixel code corresponding to a theme system color, * set one of brush, textColor or background to the corresponding |
︙ | ︙ | |||
198 199 200 201 202 203 204 | static int GetThemeFromPixelCode( unsigned char code, ThemeBrush *brush, ThemeTextColor *textColor, ThemeBackgroundKind *background) { | | | > | 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 | static int GetThemeFromPixelCode( unsigned char code, ThemeBrush *brush, ThemeTextColor *textColor, ThemeBackgroundKind *background) { if (code >= MIN_PIXELCODE && code <= MAX_PIXELCODE) { *brush = systemColorMap[code - MIN_PIXELCODE].brush; *textColor = systemColorMap[code - MIN_PIXELCODE].textColor; *background = systemColorMap[code - MIN_PIXELCODE].background; } else { *brush = 0; *textColor = 0; *background = 0; } if (!*brush && !*textColor && !*background && code != PIXEL_MAGIC && code != TRANSPARENT_PIXEL) { return false; } else { return true; } } /* |
︙ | ︙ | |||
236 237 238 239 240 241 242 | static OSStatus GetThemeColor( unsigned long pixel, ThemeBrush brush, ThemeTextColor textColor, ThemeBackgroundKind background, | | | < < | | > > > > > | | | > | > > > > > > > > > > | > > | > > > > > > < | | > | > | > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > | | < < < < > < > | | > | < < < < | < | < < < | < < | < < < < | < < | < < | < < < < < < < | | < < | < < < | < < | < < < < < < < < < < | 232 233 234 235 236 237 238 239 240 241 242 243 244 245 246 247 248 249 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 284 285 286 287 288 289 290 291 292 293 294 295 296 297 298 299 300 301 302 303 304 305 306 307 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 338 339 340 341 342 343 344 345 346 347 348 349 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 | static OSStatus GetThemeColor( unsigned long pixel, ThemeBrush brush, ThemeTextColor textColor, ThemeBackgroundKind background, CGColorRef *c) { OSStatus err = noErr; if (brush) { err = ChkErr(HIThemeBrushCreateCGColor, brush, c); /*} else if (textColor) { err = ChkErr(GetThemeTextColor, textColor, 32, true, c);*/ } else { CGFloat rgba[4] = {0, 0, 0, 1}; switch ((pixel >> 24) & 0xff) { case PIXEL_MAGIC: { unsigned short red, green, blue; red = (pixel >> 16) & 0xff; green = (pixel >> 8) & 0xff; blue = (pixel ) & 0xff; red |= red << 8; green |= green << 8; blue |= blue << 8; rgba[0] = red / 65535.0; rgba[1] = green / 65535.0; rgba[2] = blue / 65535.0; break; } case TRANSPARENT_PIXEL: rgba[3] = 0.0; break; } // this attempts to find something roughly fitting for any display // *c = CGColorCreateGenericRGB(rgba[0], rgba[1], rgba[2], rgba[3]); // may be off for non-main display but in most cases better than prev static CGColorSpaceRef deviceRGBSpace = NULL; if (!deviceRGBSpace) { deviceRGBSpace = CGDisplayCopyColorSpace(CGMainDisplayID()); } *c = CGColorCreate(deviceRGBSpace, rgba ); } return err; } /* *---------------------------------------------------------------------- * * TkSetMacColor -- * * Creates a CGColorRef from a X style pixel value. * * Results: * Returns false if not a real pixel, true otherwise. * * Side effects: * The variable macColor is set to a new CGColorRef, the caller is * responsible for releasing it! * *---------------------------------------------------------------------- */ int TkSetMacColor( unsigned long pixel, /* Pixel value to convert. */ void *macColor) /* CGColorRef to modify. */ { CGColorRef *color = (CGColorRef*)macColor; OSStatus err = -1; ThemeBrush brush; ThemeTextColor textColor; ThemeBackgroundKind background; if (GetThemeFromPixelCode((pixel >> 24) & 0xff, &brush, &textColor, &background)) { err = ChkErr(GetThemeColor, pixel, brush, textColor, background, color); } return (err == noErr); } /* *---------------------------------------------------------------------- * * TkpInitGCCache, TkpFreeGCCache, CopyCachedColor, SetCachedColor -- * * Maintain a per-GC cache of previously converted CGColorRefs * * Results: * None resp. retained CGColorRef for CopyCachedColor() * * Side effects: * None. * *---------------------------------------------------------------------- */ void TkpInitGCCache( GC gc) { bzero(TkpGetGCCache(gc), sizeof(TkpGCCache)); } void TkpFreeGCCache( GC gc) { TkpGCCache *gcCache = TkpGetGCCache(gc); if (gcCache->cachedForegroundColor) { CFRelease(gcCache->cachedForegroundColor); } if (gcCache->cachedBackgroundColor) { CFRelease(gcCache->cachedBackgroundColor); } } static CGColorRef CopyCachedColor( GC gc, unsigned long pixel) { TkpGCCache *gcCache = TkpGetGCCache(gc); CGColorRef cgColor = NULL; if (gcCache) { if (gcCache->cachedForeground == pixel) { cgColor = gcCache->cachedForegroundColor; } else if (gcCache->cachedBackground == pixel) { cgColor = gcCache->cachedBackgroundColor; } if (cgColor) { CFRetain(cgColor); } } return cgColor; } static void SetCachedColor( GC gc, unsigned long pixel, CGColorRef cgColor) { TkpGCCache *gcCache = TkpGetGCCache(gc); if (gcCache && cgColor) { if (gc->foreground == pixel) { if (gcCache->cachedForegroundColor) { CFRelease(gcCache->cachedForegroundColor); } gcCache->cachedForegroundColor = (CGColorRef) CFRetain(cgColor); gcCache->cachedForeground = pixel; } else if (gc->background == pixel) { if (gcCache->cachedBackgroundColor) { CFRelease(gcCache->cachedBackgroundColor); } gcCache->cachedBackgroundColor = (CGColorRef) CFRetain(cgColor); gcCache->cachedBackground = pixel; } } } /* *---------------------------------------------------------------------- * * TkMacOSXCreateCGColor -- * * Creates a CGColorRef from a X style pixel value. * * Results: * Returns NULL if not a real pixel, CGColorRef otherwise. * * Side effects: * None * *---------------------------------------------------------------------- */ CGColorRef TkMacOSXCreateCGColor( GC gc, unsigned long pixel) /* Pixel value to convert. */ { CGColorRef cgColor = CopyCachedColor(gc, pixel); if (!cgColor && TkSetMacColor(pixel, &cgColor)) { SetCachedColor(gc, pixel, cgColor); } return cgColor; } /* *---------------------------------------------------------------------- * * TkMacOSXGetNSColor -- * * Creates an autoreleased NSColor from a X style pixel value. * * Results: * Returns nil if not a real pixel, NSColor* otherwise. * * Side effects: * None * *---------------------------------------------------------------------- */ NSColor* TkMacOSXGetNSColor( GC gc, unsigned long pixel) /* Pixel value to convert. */ { CGColorRef cgColor = TkMacOSXCreateCGColor(gc, pixel); NSColor *nsColor = nil; if (cgColor) { NSColorSpace *colorSpace = [[NSColorSpace alloc] initWithCGColorSpace:CGColorGetColorSpace(cgColor)]; nsColor = [NSColor colorWithColorSpace:colorSpace components:CGColorGetComponents(cgColor) count:CGColorGetNumberOfComponents(cgColor)]; [colorSpace release]; CFRelease(cgColor); } return nsColor; } /* *---------------------------------------------------------------------- * * TkMacOSXSetColorInContext -- * |
︙ | ︙ | |||
393 394 395 396 397 398 399 400 401 402 403 | * None. * *---------------------------------------------------------------------- */ void TkMacOSXSetColorInContext( unsigned long pixel, CGContextRef context) { OSStatus err = -1; | > | < < < < < < < < < < < < < < < < < < < < < < < < | > > > | | < < < < | > | | | < > | < | | < | < < < < < < < < < | < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < | | < < < < | | < < < < < | < | | < < | > < < < | < < < < < | > > > > > | 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 | * None. * *---------------------------------------------------------------------- */ void TkMacOSXSetColorInContext( GC gc, unsigned long pixel, CGContextRef context) { OSStatus err = -1; CGColorRef cgColor = CopyCachedColor(gc, pixel); ThemeBrush brush; ThemeTextColor textColor; ThemeBackgroundKind background; if (!cgColor && GetThemeFromPixelCode((pixel >> 24) & 0xff, &brush, &textColor, &background)) { if (brush) { err = ChkErr(HIThemeSetFill, brush, NULL, context, kHIThemeOrientationNormal); if (err == noErr) { err = ChkErr(HIThemeSetStroke, brush, NULL, context, kHIThemeOrientationNormal); } } else if (textColor) { err = ChkErr(HIThemeSetTextFill, textColor, NULL, context, kHIThemeOrientationNormal); } else if (background) { CGRect rect = CGContextGetClipBoundingBox(context); HIThemeBackgroundDrawInfo info = { 0, kThemeStateActive, background }; err = ChkErr(HIThemeApplyBackground, &rect, &info, context, kHIThemeOrientationNormal); } if (err == noErr) { return; } err = ChkErr(GetThemeColor, pixel, brush, textColor, background, &cgColor); if (err == noErr) { SetCachedColor(gc, pixel, cgColor); } } else if (!cgColor) { TkMacOSXDbgMsg("Ignored unknown pixel value 0x%lx", pixel); } if (cgColor) { CGContextSetFillColorWithColor(context, cgColor); CGContextSetStrokeColorWithColor(context, cgColor); CGColorRelease(cgColor); } } /* *---------------------------------------------------------------------- * * TkpGetColor -- |
︙ | ︙ | |||
549 550 551 552 553 554 555 | TkColor * TkpGetColor( Tk_Window tkwin, /* Window in which color will be used. */ Tk_Uid name) /* Name of color to allocated (in form * suitable for passing to XParseColor). */ { | | | | > > > > > | | | > > > > > > > > > | 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 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 614 | TkColor * TkpGetColor( Tk_Window tkwin, /* Window in which color will be used. */ Tk_Uid name) /* Name of color to allocated (in form * suitable for passing to XParseColor). */ { Display *display = tkwin != None ? Tk_Display(tkwin) : NULL; Colormap colormap = tkwin!= None ? Tk_Colormap(tkwin) : None; TkColor *tkColPtr; XColor color; /* * Check to see if this is a system color. Otherwise, XParseColor * will do all the work. */ if (strncasecmp(name, "system", 6) == 0) { Tcl_Obj *strPtr = Tcl_NewStringObj(name+6, -1); int idx, result; result = Tcl_GetIndexFromObjStruct(NULL, strPtr, systemColorMap, sizeof(struct SystemColorMapEntry), NULL, TCL_EXACT, &idx); Tcl_DecrRefCount(strPtr); if (result == TCL_OK) { OSStatus err; CGColorRef c; unsigned char pixelCode = idx + MIN_PIXELCODE; ThemeBrush brush = systemColorMap[idx].brush; ThemeTextColor textColor = systemColorMap[idx].textColor; ThemeBackgroundKind background = systemColorMap[idx].background; err = ChkErr(GetThemeColor, 0, brush, textColor, background, &c); if (err == noErr) { const size_t n = CGColorGetNumberOfComponents(c); const CGFloat *rgba = CGColorGetComponents(c); switch (n) { case 4: color.red = rgba[0] * 65535.0; color.green = rgba[1] * 65535.0; color.blue = rgba[2] * 65535.0; break; case 2: color.red = color.green = color.blue = rgba[0] * 65535.0; break; default: Tcl_Panic("CGColor with %d components", n); } color.pixel = ((((((pixelCode << 8) | ((color.red >> 8) & 0xff)) << 8) | ((color.green >> 8) & 0xff)) << 8) | ((color.blue >> 8) & 0xff)); CGColorRelease(c); goto validXColor; } CGColorRelease(c); } } if (TkParseColor(display, colormap, name, &color) == 0) { return (TkColor *) NULL; } |
︙ | ︙ | |||
635 636 637 638 639 640 641 | tkColPtr->color.red = colorPtr->red; tkColPtr->color.green = colorPtr->green; tkColPtr->color.blue = colorPtr->blue; tkColPtr->color.pixel = TkpGetPixel(&tkColPtr->color); return tkColPtr; } | < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < | 652 653 654 655 656 657 658 659 660 661 662 663 664 665 | tkColPtr->color.red = colorPtr->red; tkColPtr->color.green = colorPtr->green; tkColPtr->color.blue = colorPtr->blue; tkColPtr->color.pixel = TkpGetPixel(&tkColPtr->color); return tkColPtr; } /* *---------------------------------------------------------------------- * * Stub functions -- * * These functions are just stubs for functions that either * don't make sense on the Mac or have yet to be implemented. |
︙ | ︙ | |||
732 733 734 735 736 737 738 | /* * The Macintosh version of Tk uses TrueColor. Nothing * needs to be done to release colors as there really is * no colormap in the Tk sense. */ return Success; } | > > > > > > > > > | 718 719 720 721 722 723 724 725 726 727 728 729 730 731 732 733 | /* * The Macintosh version of Tk uses TrueColor. Nothing * needs to be done to release colors as there really is * no colormap in the Tk sense. */ return Success; } /* * Local Variables: * mode: c * c-basic-offset: 4 * fill-column: 79 * coding: utf-8 * End: */ |
Changes to macosx/tkMacOSXConfig.c.
1 2 3 4 5 6 7 | /* * tkMacOSXConfig.c -- * * This module implements the Macintosh system defaults for * the configuration package. * * Copyright (c) 1997 by Sun Microsystems, Inc. | | | 1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 | /* * tkMacOSXConfig.c -- * * This module implements the Macintosh system defaults for * the configuration package. * * Copyright (c) 1997 by Sun Microsystems, Inc. * Copyright 2001, Apple Inc. * * See the file "license.terms" for information on usage and redistribution * of this file, and for a DISCLAIMER OF ALL WARRANTIES. */ #include "tkInt.h" |
︙ | ︙ |
Changes to macosx/tkMacOSXCursor.c.
1 2 3 4 5 6 | /* * tkMacOSXCursor.c -- * * This file contains Macintosh specific cursor related routines. * * Copyright (c) 1995-1997 Sun Microsystems, Inc. | | | | | > > < < | | | | > | > | < | < < < < | | > > > > | > > > > > > > > > > > > > > > > > > > > > > > > > | > > > > > > > > | > > > > | | | | | | > | | | | > > | | > > | > > > | | > | > > > | | > > > > | | | > > > > | > > > > > > > | < > > > | | > > > > > > > > > > > > > > | > > | | > > > > > | | > > > > > | | 1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 34 35 36 37 38 39 40 41 42 43 44 45 46 47 48 49 50 51 52 53 54 55 56 57 58 59 60 61 62 63 64 65 66 67 68 69 70 71 72 73 74 75 76 77 78 79 80 81 82 83 84 85 86 87 88 89 90 91 92 93 94 95 96 97 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 129 130 131 132 133 134 135 136 137 138 139 140 141 142 143 144 145 146 147 148 149 150 151 152 153 154 155 156 157 158 159 160 161 162 163 164 165 166 167 168 169 170 171 172 173 174 175 176 177 178 179 180 181 182 183 184 185 186 187 188 | /* * tkMacOSXCursor.c -- * * This file contains Macintosh specific cursor related routines. * * Copyright (c) 1995-1997 Sun Microsystems, Inc. * Copyright 2001-2009, Apple Inc. * Copyright (c) 2006-2009 Daniel A. Steffen <[email protected]> * * See the file "license.terms" for information on usage and redistribution * of this file, and for a DISCLAIMER OF ALL WARRANTIES. */ #include "tkMacOSXPrivate.h" #include "tkMacOSXCursors.h" #include "tkMacOSXXCursors.h" /* * Mac Cursor Types. */ #define NONE -1 /* Hidden cursor */ #define SELECTOR 1 /* NSCursor class method */ #define IMAGENAMED 2 /* Named NSImage */ #define IMAGEPATH 3 /* Path to NSImage */ #define IMAGEBITMAP 4 /* Pointer to 16x16 cursor bitmap data */ #define pix 16 /* Pixel width & height of cursor bitmap data */ /* * The following data structure contains the system specific data necessary to * control Windows cursors. */ typedef struct { TkCursor info; /* Generic cursor info used by tkCursor.c */ NSCursor *macCursor; /* Macintosh cursor */ int type; /* Type of Mac cursor */ } TkMacOSXCursor; /* * The table below is used to map from the name of a predefined cursor * to a NSCursor. */ struct CursorName { const char *name; const int kind; id id1, id2; NSPoint hotspot; }; #define MacCursorData(n) ((id)tkMacOSXCursors[TK_MAC_CURSOR_##n]) #define MacXCursorData(n) ((id)tkMacOSXXCursors[TK_MAC_XCURSOR_##n]) static const struct CursorName cursorNames[] = { {"none", NONE, nil}, {"arrow", SELECTOR, @"arrowCursor"}, {"top_left_arrow", SELECTOR, @"arrowCursor"}, {"left_ptr", SELECTOR, @"arrowCursor"}, {"copyarrow", SELECTOR, @"dragCopyCursor", @"_copyDragCursor"}, {"aliasarrow", SELECTOR, @"dragLinkCursor", @"_linkDragCursor"}, {"contextualmenuarrow", SELECTOR, @"contextualMenuCursor"}, {"movearrow", SELECTOR, @"_moveCursor"}, {"ibeam", SELECTOR, @"IBeamCursor"}, {"text", SELECTOR, @"IBeamCursor"}, {"xterm", SELECTOR, @"IBeamCursor"}, {"cross", SELECTOR, @"crosshairCursor"}, {"crosshair", SELECTOR, @"crosshairCursor"}, {"cross-hair", SELECTOR, @"crosshairCursor"}, {"tcross", SELECTOR, @"crosshairCursor"}, {"hand", SELECTOR, @"openHandCursor"}, {"openhand", SELECTOR, @"openHandCursor"}, {"closedhand", SELECTOR, @"closedHandCursor"}, {"fist", SELECTOR, @"closedHandCursor"}, {"pointinghand", SELECTOR, @"pointingHandCursor"}, {"resize", SELECTOR, @"arrowCursor"}, {"resizeleft", SELECTOR, @"resizeLeftCursor"}, {"resizeright", SELECTOR, @"resizeRightCursor"}, {"resizeleftright", SELECTOR, @"resizeLeftRightCursor"}, {"resizeup", SELECTOR, @"resizeUpCursor"}, {"resizedown", SELECTOR, @"resizeDownCursor"}, {"resizeupdown", SELECTOR, @"resizeUpDownCursor"}, {"resizebottomleft", SELECTOR, @"_bottomLeftResizeCursor"}, {"resizetopleft", SELECTOR, @"_topLeftResizeCursor"}, {"resizebottomright", SELECTOR, @"_bottomRightResizeCursor"}, {"resizetopright", SELECTOR, @"_topRightResizeCursor"}, {"notallowed", SELECTOR, @"operationNotAllowedCursor"}, {"poof", SELECTOR, @"disappearingItemCursor"}, {"wait", SELECTOR, @"busyButClickableCursor"}, {"spinning", SELECTOR, @"busyButClickableCursor"}, {"countinguphand", SELECTOR, @"busyButClickableCursor"}, {"countingdownhand", SELECTOR, @"busyButClickableCursor"}, {"countingupanddownhand", SELECTOR, @"busyButClickableCursor"}, {"help", IMAGENAMED, @"NSHelpCursor", nil, {8, 8}}, // {"hand", IMAGEBITMAP, MacCursorData(hand)}, {"bucket", IMAGEBITMAP, MacCursorData(bucket)}, {"cancel", IMAGEBITMAP, MacCursorData(cancel)}, // {"resize", IMAGEBITMAP, MacCursorData(resize)}, {"eyedrop", IMAGEBITMAP, MacCursorData(eyedrop)}, {"eyedrop-full", IMAGEBITMAP, MacCursorData(eyedrop_full)}, {"zoom-in", IMAGEBITMAP, MacCursorData(zoom_in)}, {"zoom-out", IMAGEBITMAP, MacCursorData(zoom_out)}, {"X_cursor", IMAGEBITMAP, MacXCursorData(X_cursor)}, // {"arrow", IMAGEBITMAP, MacXCursorData(arrow)}, {"based_arrow_down", IMAGEBITMAP, MacXCursorData(based_arrow_down)}, {"based_arrow_up", IMAGEBITMAP, MacXCursorData(based_arrow_up)}, {"boat", IMAGEBITMAP, MacXCursorData(boat)}, {"bogosity", IMAGEBITMAP, MacXCursorData(bogosity)}, {"bottom_left_corner", IMAGEBITMAP, MacXCursorData(bottom_left_corner)}, {"bottom_right_corner", IMAGEBITMAP, MacXCursorData(bottom_right_corner)}, {"bottom_side", IMAGEBITMAP, MacXCursorData(bottom_side)}, {"bottom_tee", IMAGEBITMAP, MacXCursorData(bottom_tee)}, {"box_spiral", IMAGEBITMAP, MacXCursorData(box_spiral)}, {"center_ptr", IMAGEBITMAP, MacXCursorData(center_ptr)}, {"circle", IMAGEBITMAP, MacXCursorData(circle)}, {"clock", IMAGEBITMAP, MacXCursorData(clock)}, {"coffee_mug", IMAGEBITMAP, MacXCursorData(coffee_mug)}, // {"cross", IMAGEBITMAP, MacXCursorData(cross)}, {"cross_reverse", IMAGEBITMAP, MacXCursorData(cross_reverse)}, // {"crosshair", IMAGEBITMAP, MacXCursorData(crosshair)}, {"diamond_cross", IMAGEBITMAP, MacXCursorData(diamond_cross)}, {"dot", IMAGEBITMAP, MacXCursorData(dot)}, {"dotbox", IMAGEBITMAP, MacXCursorData(dotbox)}, {"double_arrow", IMAGEBITMAP, MacXCursorData(double_arrow)}, {"draft_large", IMAGEBITMAP, MacXCursorData(draft_large)}, {"draft_small", IMAGEBITMAP, MacXCursorData(draft_small)}, {"draped_box", IMAGEBITMAP, MacXCursorData(draped_box)}, {"exchange", IMAGEBITMAP, MacXCursorData(exchange)}, {"fleur", IMAGEBITMAP, MacXCursorData(fleur)}, {"gobbler", IMAGEBITMAP, MacXCursorData(gobbler)}, {"gumby", IMAGEBITMAP, MacXCursorData(gumby)}, {"hand1", IMAGEBITMAP, MacXCursorData(hand1)}, {"hand2", IMAGEBITMAP, MacXCursorData(hand2)}, {"heart", IMAGEBITMAP, MacXCursorData(heart)}, {"icon", IMAGEBITMAP, MacXCursorData(icon)}, {"iron_cross", IMAGEBITMAP, MacXCursorData(iron_cross)}, // {"left_ptr", IMAGEBITMAP, MacXCursorData(left_ptr)}, {"left_side", IMAGEBITMAP, MacXCursorData(left_side)}, {"left_tee", IMAGEBITMAP, MacXCursorData(left_tee)}, {"leftbutton", IMAGEBITMAP, MacXCursorData(leftbutton)}, {"ll_angle", IMAGEBITMAP, MacXCursorData(ll_angle)}, {"lr_angle", IMAGEBITMAP, MacXCursorData(lr_angle)}, {"man", IMAGEBITMAP, MacXCursorData(man)}, {"middlebutton", IMAGEBITMAP, MacXCursorData(middlebutton)}, {"mouse", IMAGEBITMAP, MacXCursorData(mouse)}, {"pencil", IMAGEBITMAP, MacXCursorData(pencil)}, {"pirate", IMAGEBITMAP, MacXCursorData(pirate)}, {"plus", IMAGEBITMAP, MacXCursorData(plus)}, {"question_arrow", IMAGEBITMAP, MacXCursorData(question_arrow)}, {"right_ptr", IMAGEBITMAP, MacXCursorData(right_ptr)}, {"right_side", IMAGEBITMAP, MacXCursorData(right_side)}, {"right_tee", IMAGEBITMAP, MacXCursorData(right_tee)}, {"rightbutton", IMAGEBITMAP, MacXCursorData(rightbutton)}, {"rtl_logo", IMAGEBITMAP, MacXCursorData(rtl_logo)}, {"sailboat", IMAGEBITMAP, MacXCursorData(sailboat)}, {"sb_down_arrow", IMAGEBITMAP, MacXCursorData(sb_down_arrow)}, {"sb_h_double_arrow", IMAGEBITMAP, MacXCursorData(sb_h_double_arrow)}, {"sb_left_arrow", IMAGEBITMAP, MacXCursorData(sb_left_arrow)}, {"sb_right_arrow", IMAGEBITMAP, MacXCursorData(sb_right_arrow)}, {"sb_up_arrow", IMAGEBITMAP, MacXCursorData(sb_up_arrow)}, {"sb_v_double_arrow", IMAGEBITMAP, MacXCursorData(sb_v_double_arrow)}, {"shuttle", IMAGEBITMAP, MacXCursorData(shuttle)}, {"sizing", IMAGEBITMAP, MacXCursorData(sizing)}, {"spider", IMAGEBITMAP, MacXCursorData(spider)}, {"spraycan", IMAGEBITMAP, MacXCursorData(spraycan)}, {"star", IMAGEBITMAP, MacXCursorData(star)}, {"target", IMAGEBITMAP, MacXCursorData(target)}, // {"tcross", IMAGEBITMAP, MacXCursorData(tcross)}, // {"top_left_arrow", IMAGEBITMAP, MacXCursorData(top_left_arrow)}, {"top_left_corner", IMAGEBITMAP, MacXCursorData(top_left_corner)}, {"top_right_corner", IMAGEBITMAP, MacXCursorData(top_right_corner)}, {"top_side", IMAGEBITMAP, MacXCursorData(top_side)}, {"top_tee", IMAGEBITMAP, MacXCursorData(top_tee)}, {"trek", IMAGEBITMAP, MacXCursorData(trek)}, {"ul_angle", IMAGEBITMAP, MacXCursorData(ul_angle)}, {"umbrella", IMAGEBITMAP, MacXCursorData(umbrella)}, {"ur_angle", IMAGEBITMAP, MacXCursorData(ur_angle)}, {"watch", IMAGEBITMAP, MacXCursorData(watch)}, // {"xterm", IMAGEBITMAP, MacXCursorData(xterm)}, {NULL} }; /* * Declarations of static variables used in this file. */ static TkMacOSXCursor * gCurrentCursor = NULL; |
︙ | ︙ | |||
112 113 114 115 116 117 118 | /* *---------------------------------------------------------------------- * * FindCursorByName -- * * Retrieve a system cursor by name, and fill the macCursorPtr | | < | | < | > | < | < | < | | | < > | < < < < < < < < < < < < < < | > > > | > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > | > > > > > > > > > > > > > > > > > > > > > > > | 205 206 207 208 209 210 211 212 213 214 215 216 217 218 219 220 221 222 223 224 225 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 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 284 285 286 287 288 289 290 291 292 293 294 295 296 297 298 299 300 301 302 303 304 305 306 307 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 338 339 340 341 342 343 344 345 346 347 348 349 350 351 352 353 354 | /* *---------------------------------------------------------------------- * * FindCursorByName -- * * Retrieve a system cursor by name, and fill the macCursorPtr * structure. If the cursor cannot be found, the macCursor field * will be nil. * * Results: * Fills the macCursorPtr record. * * Side effects: * None * *---------------------------------------------------------------------- */ void FindCursorByName( TkMacOSXCursor *macCursorPtr, const char *name) { NSString *path = nil; NSImage *image = nil; NSPoint hotSpot = NSZeroPoint; int haveHotSpot = 0, result = TCL_ERROR; NSCursor *macCursor = nil; if (name[0] == '@') { /* * System cursor of type @filename */ macCursorPtr->type = IMAGEPATH; path = [NSString stringWithUTF8String:&name[1]]; } else { Tcl_Obj *strPtr = Tcl_NewStringObj(name, -1); int idx; result = Tcl_GetIndexFromObjStruct(NULL, strPtr, cursorNames, sizeof(struct CursorName), NULL, TCL_EXACT, &idx); Tcl_DecrRefCount(strPtr); if (result == TCL_OK) { macCursorPtr->type = cursorNames[idx].kind; switch (cursorNames[idx].kind) { case SELECTOR: { SEL selector = NSSelectorFromString(cursorNames[idx].id1); if ([NSCursor respondsToSelector:selector]) { macCursor = [[NSCursor performSelector:selector] retain]; } else if (cursorNames[idx].id2) { selector = NSSelectorFromString(cursorNames[idx].id2); if ([NSCursor respondsToSelector:selector]) { macCursor = [[NSCursor performSelector:selector] retain]; } } break; } case IMAGENAMED: image = [[NSImage imageNamed:cursorNames[idx].id1] retain]; hotSpot = cursorNames[idx].hotspot; haveHotSpot = 1; break; case IMAGEPATH: path = [NSApp tkFrameworkImagePath:cursorNames[idx].id1]; break; case IMAGEBITMAP: { unsigned char *bitmap = (unsigned char *)(cursorNames[idx].id1); NSBitmapImageRep *bitmapImageRep = NULL; CGImageRef img = NULL, mask = NULL, maskedImg = NULL; static const CGFloat decodeWB[] = {1, 0}; CGColorSpaceRef colorspace = CGColorSpaceCreateWithName( kCGColorSpaceGenericGray); CGDataProviderRef provider = CGDataProviderCreateWithData(NULL, bitmap, pix*pix/8, NULL); if (provider) { img = CGImageCreate(pix, pix, 1, 1, pix/8, colorspace, kCGBitmapByteOrderDefault, provider, decodeWB, 0, kCGRenderingIntentDefault); CFRelease(provider); } provider = CGDataProviderCreateWithData(NULL, bitmap + pix*pix/8, pix*pix/8, NULL); if (provider) { mask = CGImageMaskCreate(pix, pix, 1, 1, pix/8, provider, decodeWB, 0); CFRelease(provider); } if (img && mask) { maskedImg = CGImageCreateWithMask(img, mask); } if (maskedImg) { bitmapImageRep = [[NSBitmapImageRep alloc] initWithCGImage:maskedImg]; CFRelease(maskedImg); } if (mask) { CFRelease(mask); } if (img) { CFRelease(img); } if (colorspace) { CFRelease(colorspace); } if (bitmapImageRep) { image = [[NSImage alloc] initWithSize:NSMakeSize(pix, pix)]; [image addRepresentation:bitmapImageRep]; [bitmapImageRep release]; } uint16_t *hotSpotData = (uint16_t*)(bitmap + 2*pix*pix/8); hotSpot.y = CFSwapInt16BigToHost(*hotSpotData++); hotSpot.x = CFSwapInt16BigToHost(*hotSpotData); haveHotSpot = 1; break; } } } } if (path) { image = [[NSImage alloc] initWithContentsOfFile:path]; } if (!image && !macCursor && result != TCL_OK) { macCursorPtr->type = IMAGENAMED; image = [[NSImage imageNamed:[NSString stringWithUTF8String:name]] retain]; haveHotSpot = 0; } if (image) { if (!haveHotSpot && [[path pathExtension] isEqualToString:@"cur"]) { NSData *data = [NSData dataWithContentsOfFile:path]; if ([data length] > 14) { uint16_t *hotSpotData = (uint16_t*)((char*) [data bytes] + 10); hotSpot.x = CFSwapInt16LittleToHost(*hotSpotData++); hotSpot.y = CFSwapInt16LittleToHost(*hotSpotData); haveHotSpot = 1; } } if (!haveHotSpot) { NSSize size = [image size]; hotSpot.x = size.width * 0.5; hotSpot.y = size.height * 0.5; } hotSpot.y = -hotSpot.y; macCursor = [[NSCursor alloc] initWithImage:image hotSpot:hotSpot]; [image release]; } macCursorPtr->macCursor = TkMacOSXMakeUncollectable(macCursor); } /* *---------------------------------------------------------------------- * * TkGetCursorByName -- * |
︙ | ︙ | |||
188 189 190 191 192 193 194 | TkCursor * TkGetCursorByName( Tcl_Interp *interp, /* Interpreter to use for error reporting. */ Tk_Window tkwin, /* Window in which cursor will be used. */ Tk_Uid string) /* Description of cursor. See manual entry * for details on legal syntax. */ { | < | | | < < < < | > < < < < < < < < < < < < < < < < < < < < < < < < < < | < > > | < < < < | < | | < < < < < < < < < < < < < < < | | | | < < | > > | | < | > | 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 | TkCursor * TkGetCursorByName( Tcl_Interp *interp, /* Interpreter to use for error reporting. */ Tk_Window tkwin, /* Window in which cursor will be used. */ Tk_Uid string) /* Description of cursor. See manual entry * for details on legal syntax. */ { TkMacOSXCursor *macCursorPtr = NULL; const char **argv = NULL; int argc; /* * All cursor names are valid lists of one element (for * TkX11-compatibility), even unadorned system cursor names. */ if (Tcl_SplitList(interp, string, &argc, &argv) == TCL_OK) { if (argc) { macCursorPtr = (TkMacOSXCursor *) ckalloc(sizeof(TkMacOSXCursor)); macCursorPtr->info.cursor = (Tk_Cursor) macCursorPtr; macCursorPtr->macCursor = nil; macCursorPtr->type = 0; FindCursorByName(macCursorPtr, argv[0]); } ckfree((char *) argv); } if (!macCursorPtr || (!macCursorPtr->macCursor && macCursorPtr->type != NONE)) { Tcl_AppendResult(interp, "bad cursor spec \"", string, "\"", NULL); if (macCursorPtr) { ckfree((char *)macCursorPtr); macCursorPtr = NULL; } } return (TkCursor *) macCursorPtr; } /* *---------------------------------------------------------------------- * |
︙ | ︙ | |||
286 287 288 289 290 291 292 | * *---------------------------------------------------------------------- */ TkCursor * TkCreateCursorFromData( Tk_Window tkwin, /* Window in which cursor will be used. */ | | | | 415 416 417 418 419 420 421 422 423 424 425 426 427 428 429 430 | * *---------------------------------------------------------------------- */ TkCursor * TkCreateCursorFromData( Tk_Window tkwin, /* Window in which cursor will be used. */ const char *source, /* Bitmap data for cursor shape. */ const char *mask, /* Bitmap data for cursor mask. */ int width, int height, /* Dimensions of cursor. */ int xHot, int yHot, /* Location of hot-spot in cursor. */ XColor fgColor, /* Foreground color for cursor. */ XColor bgColor) /* Background color for cursor. */ { return NULL; } |
︙ | ︙ | |||
319 320 321 322 323 324 325 | void TkpFreeCursor( TkCursor *cursorPtr) { TkMacOSXCursor *macCursorPtr = (TkMacOSXCursor *) cursorPtr; | < < < < < | < < < | 448 449 450 451 452 453 454 455 456 457 458 459 460 461 462 | void TkpFreeCursor( TkCursor *cursorPtr) { TkMacOSXCursor *macCursorPtr = (TkMacOSXCursor *) cursorPtr; TkMacOSXMakeCollectableAndRelease(macCursorPtr->macCursor); if (macCursorPtr == gCurrentCursor) { gCurrentCursor = NULL; } } /* *---------------------------------------------------------------------- |
︙ | ︙ | |||
355 356 357 358 359 360 361 | */ void TkMacOSXInstallCursor( int resizeOverride) { TkMacOSXCursor *macCursorPtr = gCurrentCursor; | < < < | < < | | < < < < < < < | | < < < | < < < | < < < | < < | < | < | | 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 | */ void TkMacOSXInstallCursor( int resizeOverride) { TkMacOSXCursor *macCursorPtr = gCurrentCursor; static int cursorHidden = 0; int cursorNone = 0; gResizeOverride = resizeOverride; if (resizeOverride || !macCursorPtr) { [[NSCursor arrowCursor] set]; } else { switch (macCursorPtr->type) { case NONE: if (!cursorHidden) { cursorHidden = 1; [NSCursor hide]; } cursorNone = 1; break; case SELECTOR: case IMAGENAMED: case IMAGEPATH: case IMAGEBITMAP: default: [macCursorPtr->macCursor set]; break; } } if (cursorHidden && !cursorNone) { cursorHidden = 0; [NSCursor unhide]; } } /* *---------------------------------------------------------------------- * * TkpSetCursor -- |
︙ | ︙ | |||
481 482 483 484 485 486 487 | void Tk_MacOSXTkOwnsCursor( int tkOwnsIt) { gTkOwnsCursor = tkOwnsIt; } | > > > > > > > > > | 577 578 579 580 581 582 583 584 585 586 587 588 589 590 591 592 | void Tk_MacOSXTkOwnsCursor( int tkOwnsIt) { gTkOwnsCursor = tkOwnsIt; } /* * Local Variables: * mode: c * c-basic-offset: 4 * fill-column: 79 * coding: utf-8 * End: */ |
Added macosx/tkMacOSXCursors.h.
> > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > | 1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 34 35 36 37 38 39 40 41 42 43 44 45 46 47 48 49 50 51 52 53 54 55 56 57 58 59 60 61 62 63 64 65 66 67 68 69 70 71 72 73 74 75 76 77 78 79 80 81 82 83 84 85 86 87 88 89 | /* * tkMacOSXCursors.h -- * * This file defines a set of Macintosh cursor resources that * are only available on the Macintosh platform. * * Copyright (c) 1995-1996 Sun Microsystems, Inc. * Copyright 2008-2009, Apple Inc. * Copyright (c) 2008-2009 Daniel A. Steffen <[email protected]> * * See the file "license.terms" for information on usage and redistribution * of this file, and for a DISCLAIMER OF ALL WARRANTIES. */ static const unsigned char tkMacOSXCursors[][68] = { #define TK_MAC_CURSOR_hand 0 [TK_MAC_CURSOR_hand] = { 0x01, 0x80, 0x1A, 0x70, 0x26, 0x48, 0x26, 0x4A, 0x12, 0x4D, 0x12, 0x49, 0x68, 0x09, 0x98, 0x01, 0x88, 0x02, 0x40, 0x02, 0x20, 0x02, 0x20, 0x04, 0x10, 0x04, 0x08, 0x08, 0x04, 0x08, 0x04, 0x08, 0x01, 0x80, 0x1B, 0xF0, 0x3F, 0xF8, 0x3F, 0xFA, 0x1F, 0xFF, 0x1F, 0xFF, 0x6F, 0xFF, 0xFF, 0xFF, 0xFF, 0xFE, 0x7F, 0xFE, 0x3F, 0xFE, 0x3F, 0xFC, 0x1F, 0xFC, 0x0F, 0xF8, 0x07, 0xF8, 0x07, 0xF8, 0x00, 0x09, 0x00, 0x08, }, #define TK_MAC_CURSOR_bucket 2 [TK_MAC_CURSOR_bucket] = { 0x00, 0x00, 0x00, 0x00, 0x06, 0x00, 0x09, 0x80, 0x09, 0x40, 0x0B, 0x30, 0x0D, 0x18, 0x09, 0x0C, 0x12, 0x9C, 0x21, 0x2C, 0x10, 0x4C, 0x08, 0x8C, 0x05, 0x0C, 0x02, 0x08, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x06, 0x00, 0x09, 0x80, 0x09, 0xC0, 0x0B, 0xF0, 0x0F, 0xF8, 0x0F, 0xFC, 0x1F, 0xFC, 0x3F, 0xEC, 0x1F, 0xCC, 0x0F, 0x8C, 0x07, 0x0C, 0x02, 0x08, 0x00, 0x00, 0x00, 0x00, 0x00, 0x0D, 0x00, 0x0C, }, #define TK_MAC_CURSOR_cancel 3 [TK_MAC_CURSOR_cancel] = { 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x31, 0x80, 0x4A, 0x40, 0x4A, 0x40, 0x3F, 0x80, 0x0A, 0x00, 0x3F, 0x80, 0x4A, 0x40, 0x4A, 0x46, 0x31, 0x86, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x31, 0x80, 0x7B, 0xC0, 0xFF, 0xE0, 0xFF, 0xE0, 0x7F, 0xC0, 0x3F, 0x80, 0x7F, 0xC0, 0xFF, 0xE6, 0xFF, 0xEF, 0x7B, 0xCF, 0x31, 0x86, 0x00, 0x00, 0x00, 0x00, 0x00, 0x08, 0x00, 0x05, }, #define TK_MAC_CURSOR_resize 4 [TK_MAC_CURSOR_resize] = { 0xFF, 0xFF, 0x80, 0x01, 0xBF, 0x01, 0xA1, 0x81, 0xA1, 0xF9, 0xA1, 0x8D, 0xA1, 0x8D, 0xBF, 0x8D, 0x9F, 0x8D, 0x88, 0x0D, 0x88, 0x0D, 0x88, 0x0D, 0x8F, 0xFD, 0x87, 0xFD, 0x80, 0x01, 0xFF, 0xFF, 0xFF, 0xFF, 0xFF, 0xFF, 0xFF, 0xFF, 0xFF, 0xFF, 0xFF, 0xFF, 0xFF, 0xFF, 0xFF, 0xFF, 0xFF, 0xFF, 0xFF, 0xFF, 0xFF, 0xFF, 0xFF, 0xFF, 0xFF, 0xFF, 0xFF, 0xFF, 0xFF, 0xFF, 0xFF, 0xFF, 0xFF, 0xFF, 0x00, 0x08, 0x00, 0x08, }, #define TK_MAC_CURSOR_eyedrop 5 [TK_MAC_CURSOR_eyedrop] = { 0x00, 0x0E, 0x00, 0x1F, 0x00, 0x1F, 0x00, 0xFF, 0x00, 0x7E, 0x00, 0xB8, 0x01, 0x18, 0x02, 0x28, 0x04, 0x40, 0x08, 0x80, 0x11, 0x00, 0x22, 0x00, 0x44, 0x00, 0x48, 0x00, 0xB0, 0x00, 0x40, 0x00, 0x00, 0x0E, 0x00, 0x1F, 0x00, 0x1F, 0x00, 0xFF, 0x00, 0x7E, 0x00, 0xF8, 0x01, 0xF8, 0x03, 0xE8, 0x07, 0xC0, 0x0F, 0x80, 0x1F, 0x00, 0x3E, 0x00, 0x7C, 0x00, 0x78, 0x00, 0xF0, 0x00, 0x40, 0x00, 0x00, 0x0F, 0x00, 0x00, }, #define TK_MAC_CURSOR_eyedrop_full 6 [TK_MAC_CURSOR_eyedrop_full] = { 0x00, 0x0E, 0x00, 0x1F, 0x00, 0x1F, 0x00, 0xFF, 0x00, 0x7E, 0x00, 0xB8, 0x01, 0x18, 0x03, 0x28, 0x07, 0xC0, 0x0F, 0x80, 0x1F, 0x00, 0x3E, 0x00, 0x7C, 0x00, 0x78, 0x00, 0xF0, 0x00, 0x40, 0x00, 0x00, 0x0E, 0x00, 0x1F, 0x00, 0x1F, 0x00, 0xFF, 0x00, 0x7E, 0x00, 0xF8, 0x01, 0xF8, 0x03, 0xE8, 0x07, 0xC0, 0x0F, 0x80, 0x1F, 0x00, 0x3E, 0x00, 0x7C, 0x00, 0x78, 0x00, 0xF0, 0x00, 0x40, 0x00, 0x00, 0x0F, 0x00, 0x00, }, #define TK_MAC_CURSOR_zoom_in 7 [TK_MAC_CURSOR_zoom_in] = { 0x07, 0x80, 0x18, 0x60, 0x27, 0x90, 0x58, 0x68, 0x53, 0x28, 0xA3, 0x14, 0xAF, 0xD4, 0xAF, 0xD4, 0xA3, 0x14, 0x53, 0x28, 0x58, 0x68, 0x27, 0x98, 0x18, 0x7C, 0x07, 0x8E, 0x00, 0x07, 0x00, 0x03, 0x07, 0x80, 0x1F, 0xE0, 0x3F, 0xF0, 0x78, 0x78, 0x73, 0x38, 0xE3, 0x1C, 0xEF, 0xDC, 0xEF, 0xDC, 0xE3, 0x1C, 0x73, 0x38, 0x78, 0x78, 0x3F, 0xF8, 0x1F, 0xFC, 0x07, 0x8E, 0x00, 0x07, 0x00, 0x03, 0x00, 0x07, 0x00, 0x07, }, #define TK_MAC_CURSOR_zoom_out 8 [TK_MAC_CURSOR_zoom_out] = { 0x07, 0x80, 0x18, 0x60, 0x27, 0x90, 0x58, 0x68, 0x50, 0x28, 0xA0, 0x14, 0xAF, 0xD4, 0xAF, 0xD4, 0xA0, 0x14, 0x50, 0x28, 0x58, 0x68, 0x27, 0x98, 0x18, 0x7C, 0x07, 0x8E, 0x00, 0x07, 0x00, 0x03, 0x07, 0x80, 0x1F, 0xE0, 0x3F, 0xF0, 0x78, 0x78, 0x70, 0x38, 0xE0, 0x1C, 0xEF, 0xDC, 0xEF, 0xDC, 0xE0, 0x1C, 0x70, 0x38, 0x78, 0x78, 0x3F, 0xF8, 0x1F, 0xFC, 0x07, 0x8E, 0x00, 0x07, 0x00, 0x03, 0x00, 0x07, 0x00, 0x07, }, }; |
Deleted macosx/tkMacOSXCursors.r.
|
| < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < |
Changes to macosx/tkMacOSXDebug.c.
1 2 3 | /* * tkMacOSXDebug.c -- * | | | | | | | < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < | | < | | | | | | | | | | | > | 1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 34 35 36 37 38 39 40 41 42 43 44 45 46 47 48 49 50 51 52 53 54 55 56 57 58 59 60 61 | /* * tkMacOSXDebug.c -- * * Implementation of Macintosh specific functions for debugging MacOS * events, regions, etc... * * Copyright 2001-2009, Apple Inc. * Copyright (c) 2006-2009 Daniel A. Steffen <[email protected]> * * See the file "license.terms" for information on usage and redistribution * of this file, and for a DISCLAIMER OF ALL WARRANTIES. */ #include "tkMacOSXPrivate.h" #include "tkMacOSXDebug.h" #ifdef TK_MAC_DEBUG #include <mach-o/dyld.h> #include <mach-o/nlist.h> /* *---------------------------------------------------------------------- * * TkMacOSXGetNamedDebugSymbol -- * * Dynamically acquire address of a named symbol from a loaded dynamic * library, so that we can use API that may not be available on all OS * versions. For debugging purposes, if we cannot find the symbol with * the usual dynamic library APIs, we manually walk the symbol table of * the loaded library. This allows access to unexported symbols such as * private_extern internal debugging functions. If module is NULL or the * empty string, search all loaded libraries (could be very expensive and * should be avoided). * * THIS FUCTION IS ONLY TO BE USED FOR DEBUGGING PURPOSES, IT MAY BREAK * UNEXPECTEDLY IN THE FUTURE! * * Results: * Address of given symbol or NULL if unavailable. * * Side effects: * None. * *---------------------------------------------------------------------- */ MODULE_SCOPE void * TkMacOSXGetNamedDebugSymbol( const char *module, const char *symbol) { void *addr = TkMacOSXGetNamedSymbol(module, symbol); #ifndef __LP64__ if (!addr) { const struct mach_header *mh = NULL; uint32_t i, n = _dyld_image_count(); size_t module_len = 0; if (module && *module) { |
︙ | ︙ | |||
568 569 570 571 572 573 574 | } s++; } } nsect += ns; } } else if (!st && lc->cmd == LC_SYMTAB) { | | > | | > > | | | 106 107 108 109 110 111 112 113 114 115 116 117 118 119 120 121 122 123 124 125 126 127 128 129 130 131 132 133 134 135 136 137 138 139 | } s++; } } nsect += ns; } } else if (!st && lc->cmd == LC_SYMTAB) { st = (struct symtab_command *) lc; break; } lc = (struct load_command *)((char *) lc + lc->cmdsize); } if (st && sg && txtsectx) { intptr_t base, slide = _dyld_get_image_vmaddr_slide(i); char *strings; struct nlist *sym; uint32_t strsize = st->strsize; int32_t strx; /* * Offset file positions by difference to actual position * in memory of last segment before symbol table: */ base = (intptr_t) sg->vmaddr + slide - sg->fileoff; strings = (char *) (base + st->stroff); sym = (struct nlist *) (base + st->symoff); m = st->nsyms; for (j = 0; j < m; j++) { /* Find symbol with given name in __text section */ strx = sym->n_un.n_strx; if ((sym->n_type & N_TYPE) == N_SECT && sym->n_sect == txtsectx && strx > 0 && (uint32_t) strx < strsize && |
︙ | ︙ | |||
609 610 611 612 613 614 615 | break; } } } #endif /* __LP64__ */ return addr; } | > | | > > > > > > > | 150 151 152 153 154 155 156 157 158 159 160 161 162 163 164 165 166 | break; } } } #endif /* __LP64__ */ return addr; } #endif /* TK_MAC_DEBUG */ /* * Local Variables: * mode: c * c-basic-offset: 4 * fill-column: 79 * coding: utf-8 * End: */ |
Changes to macosx/tkMacOSXDebug.h.
1 2 3 4 5 6 | /* * tkMacOSXDebug.h -- * * Declarations of Macintosh specific functions for debugging MacOS events, * regions, etc... * | | | | | < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < | 1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 | /* * tkMacOSXDebug.h -- * * Declarations of Macintosh specific functions for debugging MacOS events, * regions, etc... * * Copyright 2001-2009, Apple Inc. * Copyright (c) 2005-2009 Daniel A. Steffen <[email protected]> * * See the file "license.terms" for information on usage and redistribution * of this file, and for a DISCLAIMER OF ALL WARRANTIES. */ #ifndef _TKMACDEBUG #define _TKMACDEBUG #ifndef _TKMACINT #include "tkMacOSXInt.h" #endif #ifdef TK_MAC_DEBUG MODULE_SCOPE void* TkMacOSXGetNamedDebugSymbol(const char* module, const char* symbol); /* Macro to abstract common use of TkMacOSXGetNamedDebugSymbol to initialize named symbols */ #define TkMacOSXInitNamedDebugSymbol(module, ret, symbol, ...) \ static ret (* symbol)(__VA_ARGS__) = (void*)(-1L); \ if (symbol == (void*)(-1L)) { \ symbol = TkMacOSXGetNamedDebugSymbol(STRINGIFY(module), STRINGIFY(_##symbol));\ |
︙ | ︙ |
Changes to macosx/tkMacOSXDefault.h.
1 2 3 4 5 6 7 8 | /* * tkMacOSXDefault.h -- * * This file defines the defaults for all options for all of * the Tk widgets. * * Copyright (c) 1991-1994 The Regents of the University of California. * Copyright (c) 1994-1997 Sun Microsystems, Inc. | | | > > > > | | | | | | | | | | | | 1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 34 35 36 37 38 39 40 41 42 43 44 45 46 47 48 49 50 51 | /* * tkMacOSXDefault.h -- * * This file defines the defaults for all options for all of * the Tk widgets. * * Copyright (c) 1991-1994 The Regents of the University of California. * Copyright (c) 1994-1997 Sun Microsystems, Inc. * Copyright 2001-2009, Apple Inc. * Copyright (c) 2006-2009 Daniel A. Steffen <[email protected]> * * See the file "license.terms" for information on usage and redistribution * of this file, and for a DISCLAIMER OF ALL WARRANTIES. */ #ifndef _TKMACDEFAULT #define _TKMACDEFAULT #ifndef TK_MAC_BUTTON_USE_COMPATIBILITY_METRICS #define TK_MAC_BUTTON_USE_COMPATIBILITY_METRICS 1 #endif /* * The definitions below provide symbolic names for the default colors. * NORMAL_BG - Normal background color. * ACTIVE_BG - Background color when widget is active. * SELECT_BG - Background color for selected text. * SELECT_FG - Foreground color for selected text. * TROUGH - Background color for troughs in scales and scrollbars. * INDICATOR - Color for indicator when button is selected. * DISABLED - Foreground color when widget is disabled. */ #define BLACK "Black" #define WHITE "White" #define NORMAL_BG "systemWindowBody" #define ACTIVE_BG "systemButtonFacePressed" #define ACTIVE_FG "systemPushButtonPressedText" #define SELECT_BG "systemHighlight" #define SELECT_FG None #define INACTIVE_SELECT_BG "systemHighlightSecondary" #define TROUGH "#c3c3c3" #define INDICATOR "#b03060" #define DISABLED "#a3a3a3" /* * Defaults for labels, buttons, checkbuttons, and radiobuttons: */ #define DEF_BUTTON_ANCHOR "center" #define DEF_BUTTON_ACTIVE_BG_COLOR ACTIVE_BG |
︙ | ︙ | |||
64 65 66 67 68 69 70 71 | #define DEF_CHKRAD_FG DEF_BUTTON_FG #define DEF_BUTTON_FONT "TkDefaultFont" #define DEF_BUTTON_HEIGHT "0" #define DEF_BUTTON_HIGHLIGHT_BG_COLOR DEF_BUTTON_BG_COLOR #define DEF_BUTTON_HIGHLIGHT_BG_MONO DEF_BUTTON_BG_MONO #define DEF_BUTTON_HIGHLIGHT "systemButtonFrame" #define DEF_LABEL_HIGHLIGHT_WIDTH "0" #define DEF_BUTTON_HIGHLIGHT_WIDTH "4" | > > > > > | > > > > > > > > > > | | | 68 69 70 71 72 73 74 75 76 77 78 79 80 81 82 83 84 85 86 87 88 89 90 91 92 93 94 95 96 97 98 99 100 101 102 103 104 105 106 107 108 109 110 111 112 113 114 115 116 117 118 | #define DEF_CHKRAD_FG DEF_BUTTON_FG #define DEF_BUTTON_FONT "TkDefaultFont" #define DEF_BUTTON_HEIGHT "0" #define DEF_BUTTON_HIGHLIGHT_BG_COLOR DEF_BUTTON_BG_COLOR #define DEF_BUTTON_HIGHLIGHT_BG_MONO DEF_BUTTON_BG_MONO #define DEF_BUTTON_HIGHLIGHT "systemButtonFrame" #define DEF_LABEL_HIGHLIGHT_WIDTH "0" #if TK_MAC_BUTTON_USE_COMPATIBILITY_METRICS #define DEF_BUTTON_HIGHLIGHT_WIDTH "4" #define DEF_BUTTON_HIGHLIGHT_WIDTH_NOCM "1" #else #define DEF_BUTTON_HIGHLIGHT_WIDTH "1" #endif #define DEF_BUTTON_IMAGE ((char *) NULL) #define DEF_BUTTON_INDICATOR "1" #define DEF_BUTTON_JUSTIFY "center" #define DEF_BUTTON_OFF_VALUE "0" #define DEF_BUTTON_ON_VALUE "1" #define DEF_BUTTON_TRISTATE_VALUE "" #define DEF_BUTTON_OVER_RELIEF "" #if TK_MAC_BUTTON_USE_COMPATIBILITY_METRICS #define DEF_BUTTON_PADX "12" #define DEF_BUTTON_PADX_NOCM "1" #else #define DEF_BUTTON_PADX "1" #endif #define DEF_LABCHKRAD_PADX "1" #if TK_MAC_BUTTON_USE_COMPATIBILITY_METRICS #define DEF_BUTTON_PADY "3" #define DEF_BUTTON_PADY_NOCM "1" #else #define DEF_BUTTON_PADY "1" #endif #define DEF_LABCHKRAD_PADY "1" #define DEF_BUTTON_RELIEF "flat" #define DEF_LABCHKRAD_RELIEF "flat" #define DEF_BUTTON_REPEAT_DELAY "0" #define DEF_BUTTON_REPEAT_INTERVAL "0" #define DEF_BUTTON_SELECT_COLOR INDICATOR #define DEF_BUTTON_SELECT_MONO BLACK #define DEF_BUTTON_SELECT_IMAGE ((char *) NULL) #define DEF_BUTTON_STATE "normal" #define DEF_LABEL_TAKE_FOCUS "0" #define DEF_BUTTON_TAKE_FOCUS ((char *) NULL) #define DEF_BUTTON_TEXT "" #define DEF_BUTTON_TEXT_VARIABLE "" #define DEF_BUTTON_UNDERLINE "-1" #define DEF_BUTTON_VALUE "" #define DEF_BUTTON_WIDTH "0" #define DEF_BUTTON_WRAP_LENGTH "0" #define DEF_RADIOBUTTON_VARIABLE "selectedButton" |
︙ | ︙ | |||
123 124 125 126 127 128 129 | #define DEF_CANVAS_SCROLL_REGION "" #define DEF_CANVAS_SELECT_COLOR SELECT_BG #define DEF_CANVAS_SELECT_MONO BLACK #define DEF_CANVAS_SELECT_BD_COLOR "1" #define DEF_CANVAS_SELECT_BD_MONO "0" #define DEF_CANVAS_SELECT_FG_COLOR SELECT_FG #define DEF_CANVAS_SELECT_FG_MONO WHITE | | | 142 143 144 145 146 147 148 149 150 151 152 153 154 155 156 | #define DEF_CANVAS_SCROLL_REGION "" #define DEF_CANVAS_SELECT_COLOR SELECT_BG #define DEF_CANVAS_SELECT_MONO BLACK #define DEF_CANVAS_SELECT_BD_COLOR "1" #define DEF_CANVAS_SELECT_BD_MONO "0" #define DEF_CANVAS_SELECT_FG_COLOR SELECT_FG #define DEF_CANVAS_SELECT_FG_MONO WHITE #define DEF_CANVAS_TAKE_FOCUS ((char *) NULL) #define DEF_CANVAS_WIDTH "10c" #define DEF_CANVAS_X_SCROLL_CMD "" #define DEF_CANVAS_X_SCROLL_INCREMENT "0" #define DEF_CANVAS_Y_SCROLL_CMD "" #define DEF_CANVAS_Y_SCROLL_INCREMENT "0" /* |
︙ | ︙ | |||
179 180 181 182 183 184 185 | #define DEF_ENTRY_SCROLL_COMMAND "" #define DEF_ENTRY_SELECT_COLOR SELECT_BG #define DEF_ENTRY_SELECT_MONO BLACK #define DEF_ENTRY_SELECT_BD_COLOR "1" #define DEF_ENTRY_SELECT_BD_MONO "0" #define DEF_ENTRY_SELECT_FG_COLOR SELECT_FG #define DEF_ENTRY_SELECT_FG_MONO WHITE | | | | 198 199 200 201 202 203 204 205 206 207 208 209 210 211 212 213 214 | #define DEF_ENTRY_SCROLL_COMMAND "" #define DEF_ENTRY_SELECT_COLOR SELECT_BG #define DEF_ENTRY_SELECT_MONO BLACK #define DEF_ENTRY_SELECT_BD_COLOR "1" #define DEF_ENTRY_SELECT_BD_MONO "0" #define DEF_ENTRY_SELECT_FG_COLOR SELECT_FG #define DEF_ENTRY_SELECT_FG_MONO WHITE #define DEF_ENTRY_SHOW ((char *) NULL) #define DEF_ENTRY_STATE "normal" #define DEF_ENTRY_TAKE_FOCUS ((char *) NULL) #define DEF_ENTRY_TEXT_VARIABLE "" #define DEF_ENTRY_WIDTH "20" /* * Defaults for frames: */ |
︙ | ︙ | |||
247 248 249 250 251 252 253 | #define DEF_LISTBOX_SELECT_MONO BLACK #define DEF_LISTBOX_SELECT_BD "0" #define DEF_LISTBOX_SELECT_FG_COLOR SELECT_FG #define DEF_LISTBOX_SELECT_FG_MONO WHITE #define DEF_LISTBOX_SELECT_MODE "browse" #define DEF_LISTBOX_SET_GRID "0" #define DEF_LISTBOX_STATE "normal" | | | | | | | | | | | | | | | | | 266 267 268 269 270 271 272 273 274 275 276 277 278 279 280 281 282 283 284 285 286 287 288 289 290 291 292 293 294 295 296 297 298 299 300 301 302 303 304 305 306 307 308 309 | #define DEF_LISTBOX_SELECT_MONO BLACK #define DEF_LISTBOX_SELECT_BD "0" #define DEF_LISTBOX_SELECT_FG_COLOR SELECT_FG #define DEF_LISTBOX_SELECT_FG_MONO WHITE #define DEF_LISTBOX_SELECT_MODE "browse" #define DEF_LISTBOX_SET_GRID "0" #define DEF_LISTBOX_STATE "normal" #define DEF_LISTBOX_TAKE_FOCUS ((char *) NULL) #define DEF_LISTBOX_WIDTH "20" /* * Defaults for individual entries of menus: */ #define DEF_MENU_ENTRY_ACTIVE_BG ((char *) NULL) #define DEF_MENU_ENTRY_ACTIVE_FG ((char *) NULL) #define DEF_MENU_ENTRY_ACCELERATOR ((char *) NULL) #define DEF_MENU_ENTRY_BG ((char *) NULL) #define DEF_MENU_ENTRY_BITMAP None #define DEF_MENU_ENTRY_COLUMN_BREAK "0" #define DEF_MENU_ENTRY_COMMAND ((char *) NULL) #define DEF_MENU_ENTRY_COMPOUND "none" #define DEF_MENU_ENTRY_FG ((char *) NULL) #define DEF_MENU_ENTRY_FONT ((char *) NULL) #define DEF_MENU_ENTRY_HIDE_MARGIN "0" #define DEF_MENU_ENTRY_IMAGE ((char *) NULL) #define DEF_MENU_ENTRY_INDICATOR "1" #define DEF_MENU_ENTRY_LABEL ((char *) NULL) #define DEF_MENU_ENTRY_MENU ((char *) NULL) #define DEF_MENU_ENTRY_OFF_VALUE "0" #define DEF_MENU_ENTRY_ON_VALUE "1" #define DEF_MENU_ENTRY_SELECT_IMAGE ((char *) NULL) #define DEF_MENU_ENTRY_STATE "normal" #define DEF_MENU_ENTRY_VALUE ((char *) NULL) #define DEF_MENU_ENTRY_CHECK_VARIABLE ((char *) NULL) #define DEF_MENU_ENTRY_RADIO_VARIABLE "selectedButton" #define DEF_MENU_ENTRY_SELECT ((char *) NULL) #define DEF_MENU_ENTRY_UNDERLINE "-1" /* * Defaults for menus overall: */ #define DEF_MENU_ACTIVE_BG_COLOR "systemMenuActive" |
︙ | ︙ | |||
307 308 309 310 311 312 313 | #define DEF_MENU_TAKE_FOCUS "0" /* * FIXME: Turn the default back to 1 when we make tearoff menus work again. */ #define DEF_MENU_TEAROFF "0" | | | 326 327 328 329 330 331 332 333 334 335 336 337 338 339 340 | #define DEF_MENU_TAKE_FOCUS "0" /* * FIXME: Turn the default back to 1 when we make tearoff menus work again. */ #define DEF_MENU_TEAROFF "0" #define DEF_MENU_TEAROFF_CMD ((char *) NULL) #define DEF_MENU_TITLE "" #define DEF_MENU_TYPE "normal" /* * Defaults for menubuttons: */ |
︙ | ︙ | |||
335 336 337 338 339 340 341 | #define DEF_MENUBUTTON_FONT "TkDefaultFont" #define DEF_MENUBUTTON_FG BLACK #define DEF_MENUBUTTON_HEIGHT "0" #define DEF_MENUBUTTON_HIGHLIGHT_BG_COLOR DEF_MENUBUTTON_BG_COLOR #define DEF_MENUBUTTON_HIGHLIGHT_BG_MONO DEF_MENUBUTTON_BG_MONO #define DEF_MENUBUTTON_HIGHLIGHT BLACK #define DEF_MENUBUTTON_HIGHLIGHT_WIDTH "0" | | | < | | | 354 355 356 357 358 359 360 361 362 363 364 365 366 367 368 369 370 371 372 373 | #define DEF_MENUBUTTON_FONT "TkDefaultFont" #define DEF_MENUBUTTON_FG BLACK #define DEF_MENUBUTTON_HEIGHT "0" #define DEF_MENUBUTTON_HIGHLIGHT_BG_COLOR DEF_MENUBUTTON_BG_COLOR #define DEF_MENUBUTTON_HIGHLIGHT_BG_MONO DEF_MENUBUTTON_BG_MONO #define DEF_MENUBUTTON_HIGHLIGHT BLACK #define DEF_MENUBUTTON_HIGHLIGHT_WIDTH "0" #define DEF_MENUBUTTON_IMAGE ((char *) NULL) #define DEF_MENUBUTTON_INDICATOR "1" #define DEF_MENUBUTTON_JUSTIFY "left" #define DEF_MENUBUTTON_MENU "" #define DEF_MENUBUTTON_PADX "4" #define DEF_MENUBUTTON_PADY "3" #define DEF_MENUBUTTON_RELIEF "flat" #define DEF_MENUBUTTON_STATE "normal" #define DEF_MENUBUTTON_TAKE_FOCUS "0" #define DEF_MENUBUTTON_TEXT "" #define DEF_MENUBUTTON_TEXT_VARIABLE "" #define DEF_MENUBUTTON_UNDERLINE "-1" #define DEF_MENUBUTTON_WIDTH "0" |
︙ | ︙ | |||
444 445 446 447 448 449 450 | #define DEF_SCALE_RESOLUTION "1" #define DEF_SCALE_TROUGH_COLOR TROUGH #define DEF_SCALE_TROUGH_MONO WHITE #define DEF_SCALE_SHOW_VALUE "1" #define DEF_SCALE_SLIDER_LENGTH "30" #define DEF_SCALE_SLIDER_RELIEF "raised" #define DEF_SCALE_STATE "normal" | | | 462 463 464 465 466 467 468 469 470 471 472 473 474 475 476 | #define DEF_SCALE_RESOLUTION "1" #define DEF_SCALE_TROUGH_COLOR TROUGH #define DEF_SCALE_TROUGH_MONO WHITE #define DEF_SCALE_SHOW_VALUE "1" #define DEF_SCALE_SLIDER_LENGTH "30" #define DEF_SCALE_SLIDER_RELIEF "raised" #define DEF_SCALE_STATE "normal" #define DEF_SCALE_TAKE_FOCUS ((char *) NULL) #define DEF_SCALE_TICK_INTERVAL "0" #define DEF_SCALE_TO "100" #define DEF_SCALE_VARIABLE "" #define DEF_SCALE_WIDTH "15" /* * Defaults for scrollbars: |
︙ | ︙ | |||
471 472 473 474 475 476 477 | #define DEF_SCROLLBAR_HIGHLIGHT BLACK #define DEF_SCROLLBAR_HIGHLIGHT_WIDTH "0" #define DEF_SCROLLBAR_JUMP "0" #define DEF_SCROLLBAR_ORIENT "vertical" #define DEF_SCROLLBAR_RELIEF "flat" #define DEF_SCROLLBAR_REPEAT_DELAY "300" #define DEF_SCROLLBAR_REPEAT_INTERVAL "100" | | | 489 490 491 492 493 494 495 496 497 498 499 500 501 502 503 | #define DEF_SCROLLBAR_HIGHLIGHT BLACK #define DEF_SCROLLBAR_HIGHLIGHT_WIDTH "0" #define DEF_SCROLLBAR_JUMP "0" #define DEF_SCROLLBAR_ORIENT "vertical" #define DEF_SCROLLBAR_RELIEF "flat" #define DEF_SCROLLBAR_REPEAT_DELAY "300" #define DEF_SCROLLBAR_REPEAT_INTERVAL "100" #define DEF_SCROLLBAR_TAKE_FOCUS ((char *) NULL) #define DEF_SCROLLBAR_TROUGH_COLOR TROUGH #define DEF_SCROLLBAR_TROUGH_MONO WHITE #define DEF_SCROLLBAR_WIDTH "15" /* * Defaults for texts: */ |
︙ | ︙ | |||
518 519 520 521 522 523 524 | #define DEF_TEXT_SET_GRID "0" #define DEF_TEXT_SPACING1 "0" #define DEF_TEXT_SPACING2 "0" #define DEF_TEXT_SPACING3 "0" #define DEF_TEXT_STATE "normal" #define DEF_TEXT_TABS "" #define DEF_TEXT_TABSTYLE "tabular" | | | 536 537 538 539 540 541 542 543 544 545 546 547 548 549 550 | #define DEF_TEXT_SET_GRID "0" #define DEF_TEXT_SPACING1 "0" #define DEF_TEXT_SPACING2 "0" #define DEF_TEXT_SPACING3 "0" #define DEF_TEXT_STATE "normal" #define DEF_TEXT_TABS "" #define DEF_TEXT_TABSTYLE "tabular" #define DEF_TEXT_TAKE_FOCUS ((char *) NULL) #define DEF_TEXT_UNDO "0" #define DEF_TEXT_WIDTH "80" #define DEF_TEXT_WRAP "char" #define DEF_TEXT_XSCROLL_COMMAND "" #define DEF_TEXT_YSCROLL_COMMAND "" /* |
︙ | ︙ |
Changes to macosx/tkMacOSXDialog.c.
1 2 3 4 5 6 | /* * tkMacOSXDialog.c -- * * Contains the Mac implementation of the common dialog boxes. * * Copyright (c) 1996-1997 Sun Microsystems, Inc. | | | | | > | < | < > | | > > > > | > | < | < < | < | < | > > | < > | | < > | | < < < > > | > | | | | | < < | < < < > < > | < | > > > > > > > | > > > > > > > > > > > > > > > > > > | > > > > > > > > > > > > > > | > > > > > | > > > > > > > > > | > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > | < | < < < > > | < > | | > > | | | | | < > | | > > > > | < > > > > | < > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > | > > | > > > > > | > > > > > > > > > | > > | > > > > > | > > | > > > > > > > > > > > | > | > > > > > > > > > > > > > > > > > > > | 1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 34 35 36 37 38 39 40 41 42 43 44 45 46 47 48 49 50 51 52 53 54 55 56 57 58 59 60 61 62 63 64 65 66 67 68 69 70 71 72 73 74 75 76 77 78 79 80 81 82 83 84 85 86 87 88 89 90 91 92 93 94 95 96 97 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 129 130 131 132 133 134 135 136 137 138 139 140 141 142 143 144 145 146 147 148 149 150 151 152 153 154 155 156 157 158 159 160 161 162 163 164 165 166 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 224 225 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 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 284 285 286 287 288 289 290 291 292 293 294 295 296 297 298 299 300 301 302 303 304 305 306 307 308 309 | /* * tkMacOSXDialog.c -- * * Contains the Mac implementation of the common dialog boxes. * * Copyright (c) 1996-1997 Sun Microsystems, Inc. * Copyright 2001-2009, Apple Inc. * Copyright (c) 2006-2009 Daniel A. Steffen <[email protected]> * * See the file "license.terms" for information on usage and redistribution * of this file, and for a DISCLAIMER OF ALL WARRANTIES. */ #include "tkMacOSXPrivate.h" #include "tkFileFilter.h" static const char *colorOptionStrings[] = { "-initialcolor", "-parent", "-title", NULL }; enum colorOptions { COLOR_INITIAL, COLOR_PARENT, COLOR_TITLE }; static const char *openOptionStrings[] = { "-defaultextension", "-filetypes", "-initialdir", "-initialfile", "-message", "-multiple", "-parent", "-title", "-typevariable", "-command", NULL }; enum openOptions { OPEN_DEFAULT, OPEN_FILETYPES, OPEN_INITDIR, OPEN_INITFILE, OPEN_MESSAGE, OPEN_MULTIPLE, OPEN_PARENT, OPEN_TITLE, OPEN_TYPEVARIABLE, OPEN_COMMAND, }; static const char *saveOptionStrings[] = { "-defaultextension", "-filetypes", "-initialdir", "-initialfile", "-message", "-parent", "-title", "-typevariable", "-command", "-confirmoverwrite", NULL }; enum saveOptions { SAVE_DEFAULT, SAVE_FILETYPES, SAVE_INITDIR, SAVE_INITFILE, SAVE_MESSAGE, SAVE_PARENT, SAVE_TITLE, SAVE_TYPEVARIABLE, SAVE_COMMAND, SAVE_CONFIRMOW }; static const char *chooseOptionStrings[] = { "-initialdir", "-message", "-mustexist", "-parent", "-title", "-command", NULL }; enum chooseOptions { CHOOSE_INITDIR, CHOOSE_MESSAGE, CHOOSE_MUSTEXIST, CHOOSE_PARENT, CHOOSE_TITLE, CHOOSE_COMMAND, }; typedef struct { Tcl_Interp *interp; Tcl_Obj *cmdObj; int multiple; } FilePanelCallbackInfo; static const char *alertOptionStrings[] = { "-default", "-detail", "-icon", "-message", "-parent", "-title", "-type", "-command", NULL }; enum alertOptions { ALERT_DEFAULT, ALERT_DETAIL, ALERT_ICON, ALERT_MESSAGE, ALERT_PARENT, ALERT_TITLE, ALERT_TYPE, ALERT_COMMAND, }; typedef struct { Tcl_Interp *interp; Tcl_Obj *cmdObj; int typeIndex; } AlertCallbackInfo; static const char *alertTypeStrings[] = { "abortretryignore", "ok", "okcancel", "retrycancel", "yesno", "yesnocancel", NULL }; enum alertTypeOptions { TYPE_ABORTRETRYIGNORE, TYPE_OK, TYPE_OKCANCEL, TYPE_RETRYCANCEL, TYPE_YESNO, TYPE_YESNOCANCEL }; static const char *alertIconStrings[] = { "error", "info", "question", "warning", NULL }; enum alertIconOptions { ICON_ERROR, ICON_INFO, ICON_QUESTION, ICON_WARNING }; static const char *alertButtonStrings[] = { "abort", "retry", "ignore", "ok", "cancel", "yes", "no", NULL }; static const NSString *const alertButtonNames[][3] = { [TYPE_ABORTRETRYIGNORE] = {@"Abort", @"Retry", @"Ignore"}, [TYPE_OK] = {@"OK"}, [TYPE_OKCANCEL] = {@"OK", @"Cancel"}, [TYPE_RETRYCANCEL] = {@"Retry", @"Cancel"}, [TYPE_YESNO] = {@"Yes", @"No"}, [TYPE_YESNOCANCEL] = {@"Yes", @"No", @"Cancel"}, }; static const NSAlertStyle alertStyles[] = { [ICON_ERROR] = NSWarningAlertStyle, [ICON_INFO] = NSInformationalAlertStyle, [ICON_QUESTION] = NSWarningAlertStyle, [ICON_WARNING] = NSCriticalAlertStyle, }; /* * Need to map from 'alertButtonStrings' and its corresponding integer, * index to the native button index, which is 1, 2, 3, from right to left. * This is necessary to do for each separate '-type' of button sets. */ static const short alertButtonIndexAndTypeToNativeButtonIndex[][7] = { /* abort retry ignore ok cancel yes no */ [TYPE_ABORTRETRYIGNORE] = {1, 2, 3, 0, 0, 0, 0}, [TYPE_OK] = {0, 0, 0, 1, 0, 0, 0}, [TYPE_OKCANCEL] = {0, 0, 0, 1, 2, 0, 0}, [TYPE_RETRYCANCEL] = {0, 1, 0, 0, 2, 0, 0}, [TYPE_YESNO] = {0, 0, 0, 0, 0, 1, 2}, [TYPE_YESNOCANCEL] = {0, 0, 0, 0, 3, 1, 2}, }; /* * Need also the inverse mapping, from NSAlertFirstButtonReturn etc to the * descriptive button text string index. */ static const short alertNativeButtonIndexAndTypeToButtonIndex[][3] = { [TYPE_ABORTRETRYIGNORE] = {0, 1, 2}, [TYPE_OK] = {3, 0, 0}, [TYPE_OKCANCEL] = {3, 4, 0}, [TYPE_RETRYCANCEL] = {1, 4, 0}, [TYPE_YESNO] = {5, 6, 0}, [TYPE_YESNOCANCEL] = {5, 6, 4}, }; static int TkBackgroundEvalObjv(Tcl_Interp *interp, int objc, Tcl_Obj *const *objv, int flags); #pragma mark TKApplication(TKDialog) @interface NSColorPanel(TKDialog) - (void)_setUseModalAppearance:(BOOL)flag; @end @implementation TKApplication(TKDialog) - (void)tkFilePanelDidEnd:(NSSavePanel *)panel returnCode:(NSInteger)returnCode contextInfo:(void *)contextInfo { FilePanelCallbackInfo *callbackInfo = contextInfo; if (returnCode == NSFileHandlingPanelOKButton) { Tcl_Obj *resultObj; if (callbackInfo->multiple) { resultObj = Tcl_NewListObj(0, NULL); for (NSString *name in [(NSOpenPanel*)panel filenames]) { Tcl_ListObjAppendElement(callbackInfo->interp, resultObj, Tcl_NewStringObj([name UTF8String], -1)); } } else { resultObj = Tcl_NewStringObj([[panel filename] UTF8String], -1); } if (callbackInfo->cmdObj) { Tcl_Obj **objv, **tmpv; int objc, result = Tcl_ListObjGetElements(callbackInfo->interp, callbackInfo->cmdObj, &objc, &objv); if (result == TCL_OK && objc) { tmpv = (Tcl_Obj **) ckalloc(sizeof(Tcl_Obj *) * (objc + 2)); memcpy(tmpv, objv, sizeof(Tcl_Obj *) * objc); tmpv[objc] = resultObj; TkBackgroundEvalObjv(callbackInfo->interp, objc + 1, tmpv, TCL_EVAL_GLOBAL); ckfree((char *)tmpv); } } else { Tcl_SetObjResult(callbackInfo->interp, resultObj); } } else if (returnCode == NSFileHandlingPanelCancelButton) { Tcl_ResetResult(callbackInfo->interp); } if (panel == [NSApp modalWindow]) { [NSApp stopModalWithCode:returnCode]; } if (callbackInfo->cmdObj) { Tcl_DecrRefCount(callbackInfo->cmdObj); ckfree((char*) callbackInfo); } } - (void)tkAlertDidEnd:(NSAlert *)alert returnCode:(NSInteger)returnCode contextInfo:(void *)contextInfo { AlertCallbackInfo *callbackInfo = contextInfo; if (returnCode != NSAlertErrorReturn) { Tcl_Obj *resultObj = Tcl_NewStringObj(alertButtonStrings[ alertNativeButtonIndexAndTypeToButtonIndex[callbackInfo-> typeIndex][returnCode - NSAlertFirstButtonReturn]], -1); if (callbackInfo->cmdObj) { Tcl_Obj **objv, **tmpv; int objc, result = Tcl_ListObjGetElements(callbackInfo->interp, callbackInfo->cmdObj, &objc, &objv); if (result == TCL_OK && objc) { tmpv = (Tcl_Obj **) ckalloc(sizeof(Tcl_Obj *) * (objc + 2)); memcpy(tmpv, objv, sizeof(Tcl_Obj *) * objc); tmpv[objc] = resultObj; TkBackgroundEvalObjv(callbackInfo->interp, objc + 1, tmpv, TCL_EVAL_GLOBAL); ckfree((char *)tmpv); } } else { Tcl_SetObjResult(callbackInfo->interp, resultObj); } } if ([alert window] == [NSApp modalWindow]) { [NSApp stopModalWithCode:returnCode]; } if (callbackInfo->cmdObj) { Tcl_DecrRefCount(callbackInfo->cmdObj); ckfree((char*) callbackInfo); } } @end #pragma mark - /* * ---------------------------------------------------------------------- * * TkBackgroundEvalObjv -- * * Evaluate a command while ensuring that we do not affect the * interpreters state. This is important when evaluating script * during background tasks. * * Results: * A standard Tcl result code. * * Side Effects: * The interpreters variables and code may be modified by the script * but the result will not be modified. * * ---------------------------------------------------------------------- */ static int TkBackgroundEvalObjv( Tcl_Interp *interp, int objc, Tcl_Obj *const *objv, int flags) { Tcl_DString errorInfo, errorCode; Tcl_SavedResult state; int n, r = TCL_OK; Tcl_DStringInit(&errorInfo); Tcl_DStringInit(&errorCode); Tcl_Preserve(interp); /* * Record the state of the interpreter */ Tcl_SaveResult(interp, &state); Tcl_DStringAppend(&errorInfo, Tcl_GetVar(interp, "errorInfo", TCL_GLOBAL_ONLY), -1); Tcl_DStringAppend(&errorCode, Tcl_GetVar(interp, "errorCode", TCL_GLOBAL_ONLY), -1); /* * Evaluate the command and handle any error. */ for (n = 0; n < objc; ++n) { Tcl_IncrRefCount(objv[n]); } r = Tcl_EvalObjv(interp, objc, objv, flags); for (n = 0; n < objc; ++n) { Tcl_DecrRefCount(objv[n]); } if (r == TCL_ERROR) { Tcl_AddErrorInfo(interp, "\n (background event handler)"); Tcl_BackgroundError(interp); } Tcl_Release(interp); /* * Restore the state of the interpreter */ Tcl_SetVar(interp, "errorInfo", Tcl_DStringValue(&errorInfo), TCL_GLOBAL_ONLY); Tcl_SetVar(interp, "errorCode", Tcl_DStringValue(&errorCode), TCL_GLOBAL_ONLY); Tcl_RestoreResult(interp, &state); /* * Clean up references. */ Tcl_DStringFree(&errorInfo); Tcl_DStringFree(&errorCode); return r; } /* *---------------------------------------------------------------------- * * Tk_ChooseColorObjCmd -- * * This procedure implements the color dialog box for the Mac platform. |
︙ | ︙ | |||
123 124 125 126 127 128 129 | */ int Tk_ChooseColorObjCmd( ClientData clientData, /* Main window associated with interpreter. */ Tcl_Interp *interp, /* Current interpreter. */ int objc, /* Number of arguments. */ | | < | | | < | < < < < < < < | < < < < < | | | < < > > > > > > > > > > | < | < < < | < < < | < > > | < < | > > > > | < < | < > > > < | | 319 320 321 322 323 324 325 326 327 328 329 330 331 332 333 334 335 336 337 338 339 340 341 342 343 344 345 346 347 348 349 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 | */ int Tk_ChooseColorObjCmd( ClientData clientData, /* Main window associated with interpreter. */ Tcl_Interp *interp, /* Current interpreter. */ int objc, /* Number of arguments. */ Tcl_Obj *const objv[]) /* Argument objects. */ { int result = TCL_ERROR; Tk_Window parent, tkwin = clientData; const char *title = NULL; int i; NSColor *color = nil, *initialColor = nil; NSColorPanel *colorPanel; NSInteger returnCode, numberOfComponents = 0; for (i = 1; i < objc; i += 2) { int index; const char *option, *value; if (Tcl_GetIndexFromObj(interp, objv[i], colorOptionStrings, "option", TCL_EXACT, &index) != TCL_OK) { goto end; } if (i + 1 == objc) { option = Tcl_GetString(objv[i]); Tcl_AppendResult(interp, "value for \"", option, "\" missing", NULL); goto end; } value = Tcl_GetString(objv[i + 1]); switch (index) { case COLOR_INITIAL: { XColor *colorPtr; colorPtr = Tk_GetColor(interp, tkwin, value); if (colorPtr == NULL) { goto end; } initialColor = TkMacOSXGetNSColor(NULL, colorPtr->pixel); Tk_FreeColor(colorPtr); break; } case COLOR_PARENT: { parent = Tk_NameToWindow(interp, value, tkwin); if (parent == NULL) { goto end; } break; } case COLOR_TITLE: { title = value; break; } } } colorPanel = [NSColorPanel sharedColorPanel]; [colorPanel orderOut:NSApp]; [colorPanel setContinuous:NO]; [colorPanel setBecomesKeyOnlyIfNeeded:NO]; [colorPanel setShowsAlpha: NO]; [colorPanel _setUseModalAppearance:YES]; if (title) { NSString *s = [[NSString alloc] initWithUTF8String:title]; [colorPanel setTitle:s]; [s release]; } if (initialColor) { [colorPanel setColor:initialColor]; } returnCode = [NSApp runModalForWindow:colorPanel]; if (returnCode == NSOKButton) { color = [[colorPanel color] colorUsingColorSpace: [NSColorSpace genericRGBColorSpace]]; numberOfComponents = [color numberOfComponents]; } if (color && numberOfComponents >= 3 && numberOfComponents <= 4) { CGFloat components[4]; char colorstr[8]; [color getComponents:components]; snprintf(colorstr, 8, "#%02x%02x%02x", (short)(components[0] * 255), (short)(components[1] * 255), (short)(components[2] * 255)); Tcl_SetObjResult(interp, Tcl_NewStringObj(colorstr, 7)); } else { Tcl_ResetResult(interp); } result = TCL_OK; end: return result; } /* *---------------------------------------------------------------------- * * Tk_GetOpenFileObjCmd -- |
︙ | ︙ | |||
244 245 246 247 248 249 250 | */ int Tk_GetOpenFileObjCmd( ClientData clientData, /* Main window associated with interpreter. */ Tcl_Interp *interp, /* Current interpreter. */ int objc, /* Number of arguments. */ | | > > | < | < < < < | < | < > > | < | < < < < < < | | < > > | | < < < < < < < < < < | | < < < | | < | | > | < | > | > | | | < < < | | | > > | | | < < < > > > > > > > > > > > > > > | | < < > > > | | > > > | > > > > | > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > | > > > > | < < < < < < < < < < < < < < < < < | | < < < < < < < < < < < < | > | > > | > | | < < < | | | | | | < | < < < < | < < | < | < < < < < < < | | > > > > > > > > < | | | | < | | < | > | > | | | < < < | | | > > > > > > > > > > > > > > > > > > < < < < | > > > > | | > > > > > > | < < > | < > > > | | | | > > > > > | > | < < < < | < > | < > | < | > > > > | > > > > > > | > > > > > > | 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 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 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 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 703 704 705 706 707 708 709 710 711 712 713 714 715 716 717 718 719 720 721 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 | */ int Tk_GetOpenFileObjCmd( ClientData clientData, /* Main window associated with interpreter. */ Tcl_Interp *interp, /* Current interpreter. */ int objc, /* Number of arguments. */ Tcl_Obj *const objv[]) /* Argument objects. */ { Tk_Window tkwin = clientData; char *str; int i, result = TCL_ERROR, haveParentOption = 0; int index, len, multiple = 0; FileFilterList fl; Tcl_Obj *cmdObj = NULL, *typeVariablePtr = NULL; FilePanelCallbackInfo callbackInfoStruct; FilePanelCallbackInfo *callbackInfo = &callbackInfoStruct; NSString *directory = nil, *filename = nil; NSString *message, *title, *type; NSWindow *parent; NSMutableArray *fileTypes = nil; NSOpenPanel *panel = [NSOpenPanel openPanel]; NSInteger returnCode = NSAlertErrorReturn; TkInitFileFilters(&fl); for (i = 1; i < objc; i += 2) { if (Tcl_GetIndexFromObj(interp, objv[i], openOptionStrings, "option", TCL_EXACT, &index) != TCL_OK) { goto end; } if (i + 1 == objc) { str = Tcl_GetString(objv[i]); Tcl_AppendResult(interp, "value for \"", str, "\" missing", NULL); goto end; } switch (index) { case OPEN_DEFAULT: break; case OPEN_FILETYPES: if (TkGetFileFilters(interp, &fl, objv[i + 1], 0) != TCL_OK) { goto end; } break; case OPEN_INITDIR: str = Tcl_GetStringFromObj(objv[i + 1], &len); if (len) { directory = [[[NSString alloc] initWithUTF8String:str] autorelease]; } break; case OPEN_INITFILE: str = Tcl_GetStringFromObj(objv[i + 1], &len); if (len) { filename = [[[NSString alloc] initWithUTF8String:str] autorelease]; } break; case OPEN_MESSAGE: message = [[NSString alloc] initWithUTF8String: Tcl_GetString(objv[i + 1])]; [panel setMessage:message]; [message release]; break; case OPEN_MULTIPLE: if (Tcl_GetBooleanFromObj(interp, objv[i + 1], &multiple) != TCL_OK) { goto end; } break; case OPEN_PARENT: str = Tcl_GetStringFromObj(objv[i + 1], &len); tkwin = Tk_NameToWindow(interp, str, tkwin); if (!tkwin) { goto end; } haveParentOption = 1; break; case OPEN_TITLE: title = [[NSString alloc] initWithUTF8String: Tcl_GetString(objv[i + 1])]; [panel setTitle:title]; [title release]; break; case OPEN_TYPEVARIABLE: typeVariablePtr = objv[i + 1]; break; case OPEN_COMMAND: cmdObj = objv[i+1]; break; } } if (fl.filters) { fileTypes = [NSMutableArray array]; for (FileFilter *filterPtr = fl.filters; filterPtr; filterPtr = filterPtr->next) { for (FileFilterClause *clausePtr = filterPtr->clauses; clausePtr; clausePtr = clausePtr->next) { for (GlobPattern *globPtr = clausePtr->patterns; globPtr; globPtr = globPtr->next) { str = globPtr->pattern; while (*str && (*str == '*' || *str == '.')) { str++; } if (*str) { type = [[NSString alloc] initWithUTF8String:str]; if (![fileTypes containsObject:type]) { [fileTypes addObject:type]; } [type release]; } } for (MacFileType *mfPtr = clausePtr->macTypes; mfPtr; mfPtr = mfPtr->next) { if (mfPtr->type) { type = NSFileTypeForHFSTypeCode(mfPtr->type); if (![fileTypes containsObject:type]) { [fileTypes addObject:type]; } } } } } } [panel setAllowsMultipleSelection:multiple]; if (cmdObj) { callbackInfo = (FilePanelCallbackInfo *) ckalloc(sizeof(FilePanelCallbackInfo)); if (Tcl_IsShared(cmdObj)) { cmdObj = Tcl_DuplicateObj(cmdObj); } Tcl_IncrRefCount(cmdObj); } callbackInfo->cmdObj = cmdObj; callbackInfo->interp = interp; callbackInfo->multiple = multiple; parent = TkMacOSXDrawableWindow(((TkWindow *) tkwin)->window); if (haveParentOption && parent && ![parent attachedSheet]) { [panel beginSheetForDirectory:directory file:filename types:fileTypes modalForWindow:parent modalDelegate:NSApp didEndSelector: @selector(tkFilePanelDidEnd:returnCode:contextInfo:) contextInfo:callbackInfo]; returnCode = cmdObj ? NSAlertOtherReturn : [NSApp runModalForWindow:panel]; } else { returnCode = [panel runModalForDirectory:directory file:filename types:fileTypes]; [NSApp tkFilePanelDidEnd:panel returnCode:returnCode contextInfo:callbackInfo]; } result = (returnCode != NSAlertErrorReturn) ? TCL_OK : TCL_ERROR; if (typeVariablePtr && result == TCL_OK) { /* * The -typevariable option is not really supported. */ Tcl_SetVar(interp, Tcl_GetString(typeVariablePtr), "", TCL_GLOBAL_ONLY); } end: TkFreeFileFilters(&fl); return result; } /* *---------------------------------------------------------------------- * * Tk_GetSaveFileObjCmd -- * * This procedure implements the "save file" dialog box for the Mac * platform. See the user documentation for details on what it does. * * Results: * A standard Tcl result. * * Side effects: * See user documentation. *---------------------------------------------------------------------- */ int Tk_GetSaveFileObjCmd( ClientData clientData, /* Main window associated with interpreter. */ Tcl_Interp *interp, /* Current interpreter. */ int objc, /* Number of arguments. */ Tcl_Obj *const objv[]) /* Argument objects. */ { Tk_Window tkwin = clientData; char *str; int i, result = TCL_ERROR, haveParentOption = 0; int confirmOverwrite = 1; int index, len; FileFilterList fl; Tcl_Obj *cmdObj = NULL; FilePanelCallbackInfo callbackInfoStruct; FilePanelCallbackInfo *callbackInfo = &callbackInfoStruct; NSString *directory = nil, *filename = nil, *defaultType = nil; NSString *message, *title, *type; NSWindow *parent; NSMutableArray *fileTypes = nil; NSSavePanel *panel = [NSSavePanel savePanel]; NSInteger returnCode = NSAlertErrorReturn; TkInitFileFilters(&fl); for (i = 1; i < objc; i += 2) { if (Tcl_GetIndexFromObj(interp, objv[i], saveOptionStrings, "option", TCL_EXACT, &index) != TCL_OK) { goto end; } if (i + 1 == objc) { str = Tcl_GetString(objv[i]); Tcl_AppendResult(interp, "value for \"", str, "\" missing", NULL); goto end; } switch (index) { case SAVE_DEFAULT: str = Tcl_GetStringFromObj(objv[i + 1], &len); while (*str && (*str == '*' || *str == '.')) { str++; } if (*str) { defaultType = [[[NSString alloc] initWithUTF8String:str] autorelease]; } break; case SAVE_FILETYPES: if (TkGetFileFilters(interp, &fl, objv[i + 1], 0) != TCL_OK) { goto end; } break; case SAVE_INITDIR: str = Tcl_GetStringFromObj(objv[i + 1], &len); if (len) { directory = [[[NSString alloc] initWithUTF8String:str] autorelease]; } break; case SAVE_INITFILE: str = Tcl_GetStringFromObj(objv[i + 1], &len); if (len) { filename = [[[NSString alloc] initWithUTF8String:str] autorelease]; } break; case SAVE_MESSAGE: message = [[NSString alloc] initWithUTF8String: Tcl_GetString(objv[i + 1])]; [panel setMessage:message]; [message release]; break; case SAVE_PARENT: str = Tcl_GetStringFromObj(objv[i + 1], &len); tkwin = Tk_NameToWindow(interp, str, tkwin); if (!tkwin) { goto end; } haveParentOption = 1; break; case SAVE_TITLE: title = [[NSString alloc] initWithUTF8String: Tcl_GetString(objv[i + 1])]; [panel setTitle:title]; [title release]; break; case SAVE_TYPEVARIABLE: break; case SAVE_COMMAND: cmdObj = objv[i+1]; break; case SAVE_CONFIRMOW: if (Tcl_GetBooleanFromObj(interp, objv[i + 1], &confirmOverwrite) != TCL_OK) { goto end; } break; } } if (fl.filters || defaultType) { fileTypes = [NSMutableArray array]; [fileTypes addObject:defaultType ? defaultType : (id)kUTTypeContent]; for (FileFilter *filterPtr = fl.filters; filterPtr; filterPtr = filterPtr->next) { for (FileFilterClause *clausePtr = filterPtr->clauses; clausePtr; clausePtr = clausePtr->next) { for (GlobPattern *globPtr = clausePtr->patterns; globPtr; globPtr = globPtr->next) { str = globPtr->pattern; while (*str && (*str == '*' || *str == '.')) { str++; } if (*str) { type = [[NSString alloc] initWithUTF8String:str]; if (![fileTypes containsObject:type]) { [fileTypes addObject:type]; } [type release]; } } } } [panel setAllowedFileTypes:fileTypes]; [panel setAllowsOtherFileTypes:YES]; } [panel setCanSelectHiddenExtension:YES]; [panel setExtensionHidden:NO]; if (cmdObj) { callbackInfo = (FilePanelCallbackInfo *) ckalloc(sizeof(FilePanelCallbackInfo)); if (Tcl_IsShared(cmdObj)) { cmdObj = Tcl_DuplicateObj(cmdObj); } Tcl_IncrRefCount(cmdObj); } callbackInfo->cmdObj = cmdObj; callbackInfo->interp = interp; callbackInfo->multiple = 0; parent = TkMacOSXDrawableWindow(((TkWindow *) tkwin)->window); if (haveParentOption && parent && ![parent attachedSheet]) { [panel beginSheetForDirectory:directory file:filename modalForWindow:parent modalDelegate:NSApp didEndSelector: @selector(tkFilePanelDidEnd:returnCode:contextInfo:) contextInfo:callbackInfo]; returnCode = cmdObj ? NSAlertOtherReturn : [NSApp runModalForWindow:panel]; } else { returnCode = [panel runModalForDirectory:directory file:filename]; [NSApp tkFilePanelDidEnd:panel returnCode:returnCode contextInfo:callbackInfo]; } result = (returnCode != NSAlertErrorReturn) ? TCL_OK : TCL_ERROR; end: TkFreeFileFilters(&fl); return result; } /* *---------------------------------------------------------------------- * * Tk_ChooseDirectoryObjCmd -- |
︙ | ︙ | |||
559 560 561 562 563 564 565 | */ int Tk_ChooseDirectoryObjCmd( ClientData clientData, /* Main window associated with interpreter. */ Tcl_Interp *interp, /* Current interpreter. */ int objc, /* Number of arguments. */ | | > > | > | < < < | > | | < | | < < | < < | < < < < | | < | | | | > | | | > > > > > < < | | | > < < < < < < < < < | < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < | < | < < < < < < < < < < < < < < < < < < | < < < < < < < < < < < < < < < | < < < < < < < | < < < < < < < < < < < < < < < | < < < < < < < < < < < < < < < < < < < < < < < < < < | | < < < < < < < < < < < < < < < < < < < < < < < | < < < < | < < | < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < | < < < < | < < < < < < < < < < < < < < < < | < < < < < < | < < | < < < < | < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < | | < < < | | < < < | < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < | | < < < < < | < < < < < < < < < < < < < < < < < | | < < < < < < < < < < < < < < < < < < < < < < < < < < < | < < < < < | < < < < < < < < < | < < < < < < < < < | < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < | < < < < < < < | < < < < < < < < < < < < < | < | < < < < < < < < < < < < < < < < | < < < < < < < > < < < | < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < | < < < < | < | > | > > | | < > > > > > > | > > > > > > > > > > > > > > > > > > > | > | | > > > > > > > > > > > > > > > | > | > > > > > | | > < | < > | 780 781 782 783 784 785 786 787 788 789 790 791 792 793 794 795 796 797 798 799 800 801 802 803 804 805 806 807 808 809 810 811 812 813 814 815 816 817 818 819 820 821 822 823 824 825 826 827 828 829 830 831 832 833 834 835 836 837 838 839 840 841 842 843 844 845 846 847 848 849 850 851 852 853 854 855 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 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 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 | */ int Tk_ChooseDirectoryObjCmd( ClientData clientData, /* Main window associated with interpreter. */ Tcl_Interp *interp, /* Current interpreter. */ int objc, /* Number of arguments. */ Tcl_Obj *const objv[]) /* Argument objects. */ { Tk_Window tkwin = clientData; char *str; int i, result = TCL_ERROR, haveParentOption = 0; int index, len, mustexist = 0; Tcl_Obj *cmdObj = NULL; FilePanelCallbackInfo callbackInfoStruct; FilePanelCallbackInfo *callbackInfo = &callbackInfoStruct; NSString *directory = nil, *filename = nil; NSString *message, *title; NSWindow *parent; NSOpenPanel *panel = [NSOpenPanel openPanel]; NSInteger returnCode = NSAlertErrorReturn; for (i = 1; i < objc; i += 2) { if (Tcl_GetIndexFromObj(interp, objv[i], chooseOptionStrings, "option", TCL_EXACT, &index) != TCL_OK) { goto end; } if (i + 1 == objc) { str = Tcl_GetString(objv[i]); Tcl_AppendResult(interp, "value for \"", str, "\" missing", NULL); goto end; } switch (index) { case CHOOSE_INITDIR: str = Tcl_GetStringFromObj(objv[i + 1], &len); if (len) { directory = [[[NSString alloc] initWithUTF8String:str] autorelease]; } break; case CHOOSE_MESSAGE: message = [[NSString alloc] initWithUTF8String: Tcl_GetString(objv[i + 1])]; [panel setMessage:message]; [message release]; break; case CHOOSE_MUSTEXIST: if (Tcl_GetBooleanFromObj(interp, objv[i + 1], &mustexist) != TCL_OK) { goto end; } break; case CHOOSE_PARENT: str = Tcl_GetStringFromObj(objv[i + 1], &len); tkwin = Tk_NameToWindow(interp, str, tkwin); if (!tkwin) { goto end; } haveParentOption = 1; break; case CHOOSE_TITLE: title = [[NSString alloc] initWithUTF8String: Tcl_GetString(objv[i + 1])]; [panel setTitle:title]; [title release]; break; case CHOOSE_COMMAND: cmdObj = objv[i+1]; break; } } [panel setPrompt:@"Choose"]; [panel setCanChooseFiles:NO]; [panel setCanChooseDirectories:YES]; [panel setCanCreateDirectories:!mustexist]; if (cmdObj) { callbackInfo = (FilePanelCallbackInfo *) ckalloc(sizeof(FilePanelCallbackInfo)); if (Tcl_IsShared(cmdObj)) { cmdObj = Tcl_DuplicateObj(cmdObj); } Tcl_IncrRefCount(cmdObj); } callbackInfo->cmdObj = cmdObj; callbackInfo->interp = interp; callbackInfo->multiple = 0; parent = TkMacOSXDrawableWindow(((TkWindow *) tkwin)->window); if (haveParentOption && parent && ![parent attachedSheet]) { [panel beginSheetForDirectory:directory file:filename modalForWindow:parent modalDelegate:NSApp didEndSelector: @selector(tkFilePanelDidEnd:returnCode:contextInfo:) contextInfo:callbackInfo]; returnCode = cmdObj ? NSAlertOtherReturn : [NSApp runModalForWindow:panel]; } else { returnCode = [panel runModalForDirectory:directory file:filename]; [NSApp tkFilePanelDidEnd:panel returnCode:returnCode contextInfo:callbackInfo]; } result = (returnCode != NSAlertErrorReturn) ? TCL_OK : TCL_ERROR; end: return result; } /* *---------------------------------------------------------------------- * * TkAboutDlg -- * * Displays the default Tk About box. * * Results: * None. * * Side effects: * None. * *---------------------------------------------------------------------- */ void TkAboutDlg(void) { NSImage *image; NSString *path = [NSApp tkFrameworkImagePath:@"Tk.tiff"]; if (path) { image = [[[NSImage alloc] initWithContentsOfFile:path] autorelease]; } else { image = [NSApp applicationIconImage]; } NSDateFormatter *dateFormatter = [[NSDateFormatter alloc] init]; [dateFormatter setFormatterBehavior:NSDateFormatterBehavior10_4]; [dateFormatter setDateFormat:@"Y"]; NSString *year = [dateFormatter stringFromDate:[NSDate date]]; [dateFormatter release]; NSMutableParagraphStyle *style = [[[NSParagraphStyle defaultParagraphStyle] mutableCopy] autorelease]; [style setAlignment:NSCenterTextAlignment]; NSDictionary *options = [NSDictionary dictionaryWithObjectsAndKeys: @"Tcl & Tk", @"ApplicationName", @"Tcl " TCL_VERSION " & Tk " TK_VERSION, @"ApplicationVersion", @TK_PATCH_LEVEL, @"Version", image, @"ApplicationIcon", [NSString stringWithFormat:@"Copyright %1$C 1987-%2$@.", 0xA9, year], @"Copyright", [[[NSAttributedString alloc] initWithString: [NSString stringWithFormat: @"%1$C 1987-%2$@ Tcl Core Team." "\n\n" "%1$C 2002-%2$@ Daniel A. Steffen." "\n\n" "%1$C 2001-2009 Apple Inc." "\n\n" "%1$C 2001-2002 Jim Ingham & Ian Reid" "\n\n" "%1$C 1998-2000 Jim Ingham & Ray Johnson" "\n\n" "%1$C 1998-2000 Scriptics Inc." "\n\n" "%1$C 1996-1997 Sun Microsystems Inc.", 0xA9, year] attributes: [NSDictionary dictionaryWithObject:style forKey:NSParagraphStyleAttributeName]] autorelease], @"Credits", nil]; [NSApp orderFrontStandardAboutPanelWithOptions:options]; } /* *---------------------------------------------------------------------- * * TkMacOSXStandardAboutPanelObjCmd -- * * Implements the ::tk::mac::standardAboutPanel command. * * Results: * A standard Tcl result. * * Side effects: * none * *---------------------------------------------------------------------- */ int TkMacOSXStandardAboutPanelObjCmd( ClientData clientData, /* Unused. */ Tcl_Interp *interp, /* Current interpreter. */ int objc, /* Number of arguments. */ Tcl_Obj *const objv[]) /* Argument objects. */ { if (objc > 1) { Tcl_WrongNumArgs(interp, 1, objv, NULL); return TCL_ERROR; } [NSApp orderFrontStandardAboutPanelWithOptions:nil]; return TCL_OK; } /* *---------------------------------------------------------------------- * * Tk_MessageBoxObjCmd -- * |
︙ | ︙ | |||
1401 1402 1403 1404 1405 1406 1407 | */ int Tk_MessageBoxObjCmd( ClientData clientData, /* Main window associated with interpreter. */ Tcl_Interp *interp, /* Current interpreter. */ int objc, /* Number of arguments. */ | | < < < < < < < < < | | < | | < < < < < < < < < < < < < < < < < < < < < < < < < < | < < < < < | < < < < < < < < < | < < | < | < < < < | < < < | < < < < < < < < < < < | | | < < < > | | | < < < | < < < | < < < < < < < < < | < < > | | | < < < | < < | < > > > > | < < < < < < | | | | < < < < < < < < < < < < < < < < < < | < | < < | < | | | < < < | < < | < | < < | < < | < < < > | < > > > | > | < < < < | < < > > | < < > > > < < < < < < | < < < < < < < < < | > > > | < < | > > > > > | < < < < < < | < | < < < > | | < < < < | < < < | | < | | < < | < | < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < | 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 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 1128 1129 1130 1131 1132 1133 1134 1135 1136 1137 1138 1139 1140 1141 1142 1143 1144 1145 1146 1147 1148 1149 1150 1151 1152 | */ int Tk_MessageBoxObjCmd( ClientData clientData, /* Main window associated with interpreter. */ Tcl_Interp *interp, /* Current interpreter. */ int objc, /* Number of arguments. */ Tcl_Obj *const objv[]) /* Argument objects. */ { Tk_Window tkwin = clientData; char *str; int i, result = TCL_ERROR, haveParentOption = 0; int index, typeIndex, iconIndex, indexDefaultOption = 0; int defaultNativeButtonIndex = 1; /* 1, 2, 3: right to left */ Tcl_Obj *cmdObj = NULL; AlertCallbackInfo callbackInfoStruct, *callbackInfo = &callbackInfoStruct; NSString *message, *title; NSWindow *parent; NSArray *buttons; NSAlert *alert = [NSAlert new]; NSInteger returnCode = NSAlertErrorReturn; iconIndex = ICON_INFO; typeIndex = TYPE_OK; for (i = 1; i < objc; i += 2) { if (Tcl_GetIndexFromObj(interp, objv[i], alertOptionStrings, "option", TCL_EXACT, &index) != TCL_OK) { goto end; } if (i + 1 == objc) { str = Tcl_GetString(objv[i]); Tcl_AppendResult(interp, "value for \"", str, "\" missing", NULL); goto end; } switch (index) { case ALERT_DEFAULT: /* * Need to postpone processing of this option until we are sure to * know the '-type' as well. */ indexDefaultOption = i; break; case ALERT_DETAIL: message = [[NSString alloc] initWithUTF8String: Tcl_GetString(objv[i + 1])]; [alert setInformativeText:message]; [message release]; break; case ALERT_ICON: if (Tcl_GetIndexFromObj(interp, objv[i + 1], alertIconStrings, "value", TCL_EXACT, &iconIndex) != TCL_OK) { goto end; } break; case ALERT_MESSAGE: message = [[NSString alloc] initWithUTF8String: Tcl_GetString(objv[i + 1])]; [alert setMessageText:message]; [message release]; break; case ALERT_PARENT: str = Tcl_GetString(objv[i + 1]); tkwin = Tk_NameToWindow(interp, str, tkwin); if (!tkwin) { goto end; } haveParentOption = 1; break; case ALERT_TITLE: title = [[NSString alloc] initWithUTF8String: Tcl_GetString(objv[i + 1])]; [[alert window] setTitle:title]; [title release]; break; case ALERT_TYPE: if (Tcl_GetIndexFromObj(interp, objv[i + 1], alertTypeStrings, "value", TCL_EXACT, &typeIndex) != TCL_OK) { goto end; } break; case ALERT_COMMAND: cmdObj = objv[i+1]; break; } } if (indexDefaultOption) { /* * Any '-default' option needs to know the '-type' option, which is why * we do this here. */ if (Tcl_GetIndexFromObj(interp, objv[indexDefaultOption + 1], alertButtonStrings, "value", TCL_EXACT, &index) != TCL_OK) { goto end; } /* * Need to map from "ok" etc. to 1, 2, 3, right to left. */ defaultNativeButtonIndex = alertButtonIndexAndTypeToNativeButtonIndex[typeIndex][index]; if (!defaultNativeButtonIndex) { Tcl_SetObjResult(interp, Tcl_NewStringObj("Illegal default option", -1)); goto end; } } [alert setIcon:[NSApp applicationIconImage]]; [alert setAlertStyle:alertStyles[iconIndex]]; i = 0; while (i < 3 && alertButtonNames[typeIndex][i]) { [alert addButtonWithTitle:(NSString*)alertButtonNames[typeIndex][i++]]; } buttons = [alert buttons]; for (NSButton *b in buttons) { NSString *ke = [b keyEquivalent]; if (([ke isEqualToString:@"\r"] || [ke isEqualToString:@"\033"]) && ![b keyEquivalentModifierMask]) { [b setKeyEquivalent:@""]; } } [[buttons objectAtIndex:[buttons count]-1] setKeyEquivalent:@"\033"]; [[buttons objectAtIndex:defaultNativeButtonIndex-1] setKeyEquivalent:@"\r"]; if (cmdObj) { callbackInfo = (AlertCallbackInfo *) ckalloc(sizeof(AlertCallbackInfo)); if (Tcl_IsShared(cmdObj)) { cmdObj = Tcl_DuplicateObj(cmdObj); } Tcl_IncrRefCount(cmdObj); } callbackInfo->cmdObj = cmdObj; callbackInfo->interp = interp; callbackInfo->typeIndex = typeIndex; parent = TkMacOSXDrawableWindow(((TkWindow *) tkwin)->window); if (haveParentOption && parent && ![parent attachedSheet]) { [alert beginSheetModalForWindow:parent modalDelegate:NSApp didEndSelector:@selector(tkAlertDidEnd:returnCode:contextInfo:) contextInfo:callbackInfo]; returnCode = cmdObj ? NSAlertOtherReturn : [NSApp runModalForWindow:[alert window]]; } else { returnCode = [alert runModal]; [NSApp tkAlertDidEnd:alert returnCode:returnCode contextInfo:callbackInfo]; } result = (returnCode != NSAlertErrorReturn) ? TCL_OK : TCL_ERROR; end: [alert release]; return result; } /* * Local Variables: * mode: c * c-basic-offset: 4 * fill-column: 79 * coding: utf-8 * End: */ |
Changes to macosx/tkMacOSXDraw.c.
1 2 3 4 5 6 7 8 | /* * tkMacOSXDraw.c -- * * This file contains functions that perform drawing to * Xlib windows. Most of the functions simple emulate * Xlib functions. * * Copyright (c) 1995-1997 Sun Microsystems, Inc. | | | > < < < < < < < < < < < < > > | > > | 1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 34 35 36 37 38 39 40 41 42 43 44 45 46 47 48 49 50 51 52 53 54 55 56 57 | /* * tkMacOSXDraw.c -- * * This file contains functions that perform drawing to * Xlib windows. Most of the functions simple emulate * Xlib functions. * * Copyright (c) 1995-1997 Sun Microsystems, Inc. * Copyright 2001-2009, Apple Inc. * Copyright (c) 2006-2009 Daniel A. Steffen <[email protected]> * * See the file "license.terms" for information on usage and redistribution * of this file, and for a DISCLAIMER OF ALL WARRANTIES. */ #include "tkMacOSXPrivate.h" #include "tkMacOSXDebug.h" #include "xbytes.h" /* #ifdef TK_MAC_DEBUG #define TK_MAC_DEBUG_DRAWING #define TK_MAC_DEBUG_IMAGE_DRAWING #endif */ #define radians(d) ((d) * (M_PI/180.0)) /* * Non-antialiased CG drawing looks better and more like X11 drawing when using * very fine lines, so decrease all linewidths by the following constant. */ #define NON_AA_CG_OFFSET .999 static int cgAntiAliasLimit = 0; #define notAA(w) ((w) < cgAntiAliasLimit) static int useThemedToplevel = 0; static int useThemedFrame = 0; /* * Prototypes for functions used only in this file. */ static void ClipToGC(Drawable d, GC gc, HIShapeRef *clipRgnPtr); static CGImageRef CreateCGImageWithXImage(XImage *ximage); static CGContextRef GetCGContextForDrawable(Drawable d); static void DrawCGImage(Drawable d, GC gc, CGContextRef context, CGImageRef image, unsigned long imageForeground, unsigned long imageBackground, CGRect imageBounds, CGRect srcBounds, CGRect dstBounds); /* *---------------------------------------------------------------------- * * TkMacOSXInitCGDrawing -- * |
︙ | ︙ | |||
83 84 85 86 87 88 89 | if (!initialized) { initialized = TRUE; if (Tcl_CreateNamespace(interp, "::tk::mac", NULL, NULL) == NULL) { Tcl_ResetResult(interp); } | < < < < < | | | > > < < < | < < | 76 77 78 79 80 81 82 83 84 85 86 87 88 89 90 91 92 93 94 95 96 97 98 99 100 101 102 103 104 105 106 107 108 109 110 111 112 113 114 115 116 | if (!initialized) { initialized = TRUE; if (Tcl_CreateNamespace(interp, "::tk::mac", NULL, NULL) == NULL) { Tcl_ResetResult(interp); } if (Tcl_LinkVar(interp, "::tk::mac::CGAntialiasLimit", (char *) &cgAntiAliasLimit, TCL_LINK_INT) != TCL_OK) { Tcl_ResetResult(interp); } cgAntiAliasLimit = limit; /* * Piggy-back the themed drawing var init here. */ if (Tcl_LinkVar(interp, "::tk::mac::useThemedToplevel", (char *) &useThemedToplevel, TCL_LINK_BOOLEAN) != TCL_OK) { Tcl_ResetResult(interp); } if (Tcl_LinkVar(interp, "::tk::mac::useThemedFrame", (char *) &useThemedFrame, TCL_LINK_BOOLEAN) != TCL_OK) { Tcl_ResetResult(interp); } #if TK_MAC_BUTTON_USE_COMPATIBILITY_METRICS if (Tcl_LinkVar(interp, "::tk::mac::useCompatibilityMetrics", (char *) &tkMacOSXUseCompatibilityMetrics, TCL_LINK_BOOLEAN) != TCL_OK) { Tcl_ResetResult(interp); } #endif } return TCL_OK; } /* *---------------------------------------------------------------------- * * XCopyArea -- |
︙ | ︙ | |||
153 154 155 156 157 158 159 | int src_y, /* define the source rectangle */ unsigned int width, /* that will be copied. */ unsigned int height, int dest_x, /* Dest X & Y on dest rect. */ int dest_y) { TkMacOSXDrawingContext dc; | | < < | < < < < < < | | | | > | > > > > > > > | > < > | > > > > | > > > > > > > | > > > > > | < > > | | | > > > > > > > > | > > > > | < | < | < < < < | | | < | 138 139 140 141 142 143 144 145 146 147 148 149 150 151 152 153 154 155 156 157 158 159 160 161 162 163 164 165 166 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 | int src_y, /* define the source rectangle */ unsigned int width, /* that will be copied. */ unsigned int height, int dest_x, /* Dest X & Y on dest rect. */ int dest_y) { TkMacOSXDrawingContext dc; MacDrawable *srcDraw = (MacDrawable *) src; display->request++; if (!width || !height) { /* TkMacOSXDbgMsg("Drawing of emtpy area requested"); */ return; } if (srcDraw->flags & TK_IS_PIXMAP) { if (!TkMacOSXSetupDrawingContext(dst, gc, 1, &dc)) { return; } if (dc.context) { CGImageRef img = TkMacOSXCreateCGImageWithDrawable(src); if (img) { DrawCGImage(dst, gc, dc.context, img, gc->foreground, gc->background, CGRectMake(0, 0, srcDraw->size.width, srcDraw->size.height), CGRectMake(src_x, src_y, width, height), CGRectMake(dest_x, dest_y, width, height)); CFRelease(img); } else { TkMacOSXDbgMsg("Invalid source drawable"); } } else { TkMacOSXDbgMsg("Invalid destination drawable"); } TkMacOSXRestoreDrawingContext(&dc); } else if (TkMacOSXDrawableWindow(src)) { NSView *view = TkMacOSXDrawableView(srcDraw); NSWindow *w = [view window]; NSInteger gs = [w windowNumber] > 0 ? [w gState] : 0; /* // alternative using per-view gState: NSInteger gs = [view gState]; if (!gs) { [view allocateGState]; if ([view lockFocusIfCanDraw]) { [view unlockFocus]; } gs = [view gState]; } */ if (!gs || !TkMacOSXSetupDrawingContext(dst, gc, 1, &dc)) { return; } if (dc.context) { NSGraphicsContext *gc = nil; CGFloat boundsH = [view bounds].size.height; NSRect srcRect = NSMakeRect(srcDraw->xOff + src_x, boundsH - height - (srcDraw->yOff + src_y), width, height); if (((MacDrawable *) dst)->flags & TK_IS_PIXMAP) { gc = [NSGraphicsContext graphicsContextWithGraphicsPort: dc.context flipped:NO]; if (gc) { [NSGraphicsContext saveGraphicsState]; [NSGraphicsContext setCurrentContext:gc]; } } NSCopyBits(gs, srcRect, NSMakePoint(dest_x, dc.portBounds.size.height - dest_y)); if (gc) { [NSGraphicsContext restoreGraphicsState]; } } else { TkMacOSXDbgMsg("Invalid destination drawable"); } TkMacOSXRestoreDrawingContext(&dc); } else { TkMacOSXDbgMsg("Invalid source drawable"); } } /* *---------------------------------------------------------------------- * * XCopyPlane -- |
︙ | ︙ | |||
237 238 239 240 241 242 243 | unsigned int width, /* that will be copied. */ unsigned int height, int dest_x, /* Dest X & Y on dest rect. */ int dest_y, unsigned long plane) /* Which plane to copy. */ { TkMacOSXDrawingContext dc; | | < < | < < < < < < | | | | | < | | < < < < < < < < < | < < < < > | < < < < < < < < | | < < < < < > | > > > | > > | < < < | < < < | < < | > | < | | < < > > | 245 246 247 248 249 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 284 285 286 287 288 289 290 291 292 293 294 295 296 297 298 299 | unsigned int width, /* that will be copied. */ unsigned int height, int dest_x, /* Dest X & Y on dest rect. */ int dest_y, unsigned long plane) /* Which plane to copy. */ { TkMacOSXDrawingContext dc; MacDrawable *srcDraw = (MacDrawable *) src; display->request++; if (!width || !height) { /* TkMacOSXDbgMsg("Drawing of emtpy area requested"); */ return; } if (plane != 1) { Tcl_Panic("Unexpected plane specified for XCopyPlane"); } if (srcDraw->flags & TK_IS_PIXMAP) { if (!TkMacOSXSetupDrawingContext(dst, gc, 1, &dc)) { return; } if (dc.context) { CGImageRef img = TkMacOSXCreateCGImageWithDrawable(src); if (img) { TkpClipMask *clipPtr = (TkpClipMask *) gc->clip_mask; unsigned long imageBackground = gc->background; if (clipPtr && clipPtr->type == TKP_CLIP_PIXMAP && clipPtr->value.pixmap == src) { imageBackground = TRANSPARENT_PIXEL << 24; } DrawCGImage(dst, gc, dc.context, img, gc->foreground, imageBackground, CGRectMake(0, 0, srcDraw->size.width, srcDraw->size.height), CGRectMake(src_x, src_y, width, height), CGRectMake(dest_x, dest_y, width, height)); CFRelease(img); } else { TkMacOSXDbgMsg("Invalid source drawable"); } } else { TkMacOSXDbgMsg("Invalid destination drawable"); } TkMacOSXRestoreDrawingContext(&dc); } else { XCopyArea(display, src, dst, gc, src_x, src_y, width, height, dest_x, dest_y); } } /* *---------------------------------------------------------------------- * * TkPutImage -- |
︙ | ︙ | |||
350 351 352 353 354 355 356 | int src_y, int dest_x, /* Destination X & Y. */ int dest_y, unsigned int width, /* Same width & height for both */ unsigned int height) /* distination and source. */ { TkMacOSXDrawingContext dc; | < | > | > > > > > > | < < < < < < < | | < < < < | > > > > | > > > > > > > | > > > > > > > | > > | | > > > > > > > > > > > > | | | | | < | < | | | | > | > > > > > > > | > > > > > > > > > > > > > > > > > > > | > > > > > > > > > > > > > > > | < < < < | | < | < < | > > > > > | < | | | > > > > > > > > > > > > > > > | | > > > > > | | > > > > | > > > > > > > > > > | < < > > > > | | < | > > | > > > > | < > > > > | | | < < > | < < | < > > > > > > > > > > > > > > > | > > > | > | < > | > | > > > | > | < | > > > > > > > > > > > > > > > | > | > | > > > > > > | > | > > | > > > | > | | < < | > > > > > > | > > > > > > | | < > > | > | > | < > | < | > | > | > > | | | > | < > > > | > > > > > | > > > | | | < < > | | > > | > | | > > > | > | > > > > > > > > > | | > > > > | > > | > > > > | > > | < > > > | < < > > > | < < > > | > > > > > | > | < > > | > > > > > | < > > > > > | | > > | < < > > > > > | > | > | < < > > > > | > > > > < | 322 323 324 325 326 327 328 329 330 331 332 333 334 335 336 337 338 339 340 341 342 343 344 345 346 347 348 349 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 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 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 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 703 704 705 706 707 708 709 710 711 712 713 714 715 716 717 718 719 720 721 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 | int src_y, int dest_x, /* Destination X & Y. */ int dest_y, unsigned int width, /* Same width & height for both */ unsigned int height) /* distination and source. */ { TkMacOSXDrawingContext dc; display->request++; if (!TkMacOSXSetupDrawingContext(d, gc, 1, &dc)) { return BadDrawable; } if (dc.context) { CGImageRef img = CreateCGImageWithXImage(image); if (img) { DrawCGImage(d, gc, dc.context, img, gc->foreground, gc->background, CGRectMake(0, 0, image->width, image->height), CGRectMake(src_x, src_y, width, height), CGRectMake(dest_x, dest_y, width, height)); CFRelease(img); } else { TkMacOSXDbgMsg("Invalid source drawable"); } } else { TkMacOSXDbgMsg("Invalid destination drawable"); } TkMacOSXRestoreDrawingContext(&dc); } /* *---------------------------------------------------------------------- * * CreateCGImageWithXImage -- * * Create CGImage from XImage, copying the image data. * * Results: * CGImage, release after use. * * Side effects: * None. * *---------------------------------------------------------------------- */ static void ReleaseData(void *info, const void *data, size_t size) { ckfree(info); } CGImageRef CreateCGImageWithXImage( XImage *image) { CGImageRef img = NULL; size_t bitsPerComponent, bitsPerPixel; size_t len = image->bytes_per_line * image->height; const CGFloat *decode = NULL; CGBitmapInfo bitmapInfo; CGDataProviderRef provider = NULL; char *data = NULL; CGDataProviderReleaseDataCallback releaseData = ReleaseData; if (image->obdata) { /* * Image from XGetImage */ img = TkMacOSXCreateCGImageWithDrawable((Pixmap) image->obdata); } else if (image->bits_per_pixel == 1) { /* * BW image */ static const CGFloat decodeWB[2] = {1, 0}; bitsPerComponent = 1; bitsPerPixel = 1; decode = decodeWB; if (image->bitmap_bit_order != MSBFirst) { char *srcPtr = image->data + image->xoffset; char *endPtr = srcPtr + len; char *destPtr = (data = ckalloc(len)); while (srcPtr < endPtr) { *destPtr++ = xBitReverseTable[(unsigned char)(*(srcPtr++))]; } } else { data = memcpy(ckalloc(len), image->data + image->xoffset, len); } if (data) { provider = CGDataProviderCreateWithData(data, data, len, releaseData); } if (provider) { img = CGImageMaskCreate(image->width, image->height, bitsPerComponent, bitsPerPixel, image->bytes_per_line, provider, decode, 0); } } else if (image->format == ZPixmap && image->bits_per_pixel == 32) { /* * Color image */ CGColorSpaceRef colorspace = CGColorSpaceCreateWithName(kCGColorSpaceGenericRGB); bitsPerComponent = 8; bitsPerPixel = 32; bitmapInfo = (image->byte_order == MSBFirst ? kCGBitmapByteOrder32Big : kCGBitmapByteOrder32Little) | kCGImageAlphaNoneSkipFirst; data = memcpy(ckalloc(len), image->data + image->xoffset, len); if (data) { provider = CGDataProviderCreateWithData(data, data, len, releaseData); } if (provider) { img = CGImageCreate(image->width, image->height, bitsPerComponent, bitsPerPixel, image->bytes_per_line, colorspace, bitmapInfo, provider, decode, 0, kCGRenderingIntentDefault); } if (colorspace) { CFRelease(colorspace); } } else { TkMacOSXDbgMsg("Unsupported image type"); } if (provider) { CFRelease(provider); } return img; } /* *---------------------------------------------------------------------- * * TkMacOSXCreateCGImageWithDrawable -- * * Create a CGImage from the given Drawable. * * Results: * CGImage, release after use. * * Side effects: * None. * *---------------------------------------------------------------------- */ CGImageRef TkMacOSXCreateCGImageWithDrawable( Drawable drawable) { CGImageRef img = NULL; CGContextRef context = GetCGContextForDrawable(drawable); if (context) { img = CGBitmapContextCreateImage(context); } return img; } /* *---------------------------------------------------------------------- * * CreateNSImageWithPixmap -- * * Create NSImage for Pixmap. * * Results: * NSImage. * * Side effects: * None. * *---------------------------------------------------------------------- */ static NSImage* CreateNSImageWithPixmap( Pixmap pixmap, int width, int height) { CGImageRef cgImage; NSImage *nsImage; NSBitmapImageRep *bitmapImageRep; cgImage = TkMacOSXCreateCGImageWithDrawable(pixmap); nsImage = [[NSImage alloc] initWithSize:NSMakeSize(width, height)]; bitmapImageRep = [[NSBitmapImageRep alloc] initWithCGImage:cgImage]; [nsImage addRepresentation:bitmapImageRep]; [bitmapImageRep release]; CFRelease(cgImage); return nsImage; } /* *---------------------------------------------------------------------- * * TkMacOSXGetNSImageWithTkImage -- * * Get autoreleased NSImage for Tk_Image. * * Results: * NSImage. * * Side effects: * None. * *---------------------------------------------------------------------- */ NSImage* TkMacOSXGetNSImageWithTkImage( Display *display, Tk_Image image, int width, int height) { Pixmap pixmap = Tk_GetPixmap(display, None, width, height, 0); NSImage *nsImage; Tk_RedrawImage(image, 0, 0, width, height, pixmap, 0, 0); nsImage = CreateNSImageWithPixmap(pixmap, width, height); Tk_FreePixmap(display, pixmap); return [nsImage autorelease]; } /* *---------------------------------------------------------------------- * * TkMacOSXGetNSImageWithBitmap -- * * Get autoreleased NSImage for Bitmap. * * Results: * NSImage. * * Side effects: * None. * *---------------------------------------------------------------------- */ NSImage* TkMacOSXGetNSImageWithBitmap( Display *display, Pixmap bitmap, GC gc, int width, int height) { Pixmap pixmap = Tk_GetPixmap(display, None, width, height, 0); NSImage *nsImage; unsigned long origBackground = gc->background; gc->background = TRANSPARENT_PIXEL << 24; XSetClipOrigin(display, gc, 0, 0); XCopyPlane(display, bitmap, pixmap, gc, 0, 0, width, height, 0, 0, 1); gc->background = origBackground; nsImage = CreateNSImageWithPixmap(pixmap, width, height); Tk_FreePixmap(display, pixmap); return [nsImage autorelease]; } /* *---------------------------------------------------------------------- * * GetCGContextForDrawable -- * * Get CGContext for given Drawable, creating one if necessary. * * Results: * CGContext. * * Side effects: * None. * *---------------------------------------------------------------------- */ CGContextRef GetCGContextForDrawable( Drawable d) { MacDrawable *macDraw = (MacDrawable *) d; if (macDraw && (macDraw->flags & TK_IS_PIXMAP) && !macDraw->context) { const size_t bitsPerComponent = 8; size_t bitsPerPixel, bytesPerRow, len; CGColorSpaceRef colorspace = NULL; CGBitmapInfo bitmapInfo = #ifdef __LITTLE_ENDIAN__ kCGBitmapByteOrder32Host; #else kCGBitmapByteOrderDefault; #endif char *data; CGRect bounds = CGRectMake(0, 0, macDraw->size.width, macDraw->size.height); if (macDraw->flags & TK_IS_BW_PIXMAP) { bitsPerPixel = 8; bitmapInfo = kCGImageAlphaOnly; } else { colorspace = CGColorSpaceCreateWithName(kCGColorSpaceGenericRGB); bitsPerPixel = 32; bitmapInfo |= kCGImageAlphaPremultipliedFirst; } bytesPerRow = ((size_t) macDraw->size.width * bitsPerPixel + 127) >> 3 & ~15; len = macDraw->size.height * bytesPerRow; data = ckalloc(len); bzero(data, len); macDraw->context = CGBitmapContextCreate(data, macDraw->size.width, macDraw->size.height, bitsPerComponent, bytesPerRow, colorspace, bitmapInfo); if (macDraw->context) { CGContextClearRect(macDraw->context, bounds); } if (colorspace) { CFRelease(colorspace); } } return (macDraw ? macDraw->context : NULL); } /* *---------------------------------------------------------------------- * * DrawCGImage -- * * Draw CG image into drawable. * * Results: * None. * * Side effects: * None. * *---------------------------------------------------------------------- */ void DrawCGImage( Drawable d, GC gc, CGContextRef context, CGImageRef image, unsigned long imageForeground, unsigned long imageBackground, CGRect imageBounds, CGRect srcBounds, CGRect dstBounds) { MacDrawable *macDraw = (MacDrawable *) d; if (macDraw && context && image) { CGImageRef subImage = NULL; if (!CGRectEqualToRect(imageBounds, srcBounds)) { if (!CGRectContainsRect(imageBounds, srcBounds)) { TkMacOSXDbgMsg("Mismatch of sub CGImage bounds"); } subImage = CGImageCreateWithImageInRect(image, CGRectOffset( srcBounds, -imageBounds.origin.x, -imageBounds.origin.y)); if (subImage) { image = subImage; } } dstBounds = CGRectOffset(dstBounds, macDraw->xOff, macDraw->yOff); if (CGImageIsMask(image)) { /*CGContextSaveGState(context);*/ if (macDraw->flags & TK_IS_BW_PIXMAP) { if (imageBackground != TRANSPARENT_PIXEL << 24) { CGContextClearRect(context, dstBounds); } CGContextSetRGBFillColor(context, 0.0, 0.0, 0.0, 1.0); } else { if (imageBackground != TRANSPARENT_PIXEL << 24) { TkMacOSXSetColorInContext(gc, imageBackground, context); CGContextFillRect(context, dstBounds); } TkMacOSXSetColorInContext(gc, imageForeground, context); } } #ifdef TK_MAC_DEBUG_IMAGE_DRAWING CGContextSaveGState(context); CGContextSetLineWidth(context, 1.0); CGContextSetRGBStrokeColor(context, 0, 0, 0, 0.1); CGContextSetRGBFillColor(context, 0, 1, 0, 0.1); CGContextFillRect(context, dstBounds); CGContextStrokeRect(context, dstBounds); CGPoint p[4] = {dstBounds.origin, CGPointMake(CGRectGetMaxX(dstBounds), CGRectGetMaxY(dstBounds)), CGPointMake(CGRectGetMinX(dstBounds), CGRectGetMaxY(dstBounds)), CGPointMake(CGRectGetMaxX(dstBounds), CGRectGetMinY(dstBounds)) }; CGContextStrokeLineSegments(context, p, 4); CGContextRestoreGState(context); TkMacOSXDbgMsg("Drawing CGImage at (x=%f, y=%f), (w=%f, h=%f)", dstBounds.origin.x, dstBounds.origin.y, dstBounds.size.width, dstBounds.size.height); #else /* TK_MAC_DEBUG_IMAGE_DRAWING */ CGContextSaveGState(context); CGContextTranslateCTM(context, 0, dstBounds.origin.y + CGRectGetMaxY(dstBounds)); CGContextScaleCTM(context, 1, -1); CGContextDrawImage(context, dstBounds, image); CGContextRestoreGState(context); #endif /* TK_MAC_DEBUG_IMAGE_DRAWING */ /*if (CGImageIsMask(image)) { CGContextRestoreGState(context); }*/ if (subImage) { CFRelease(subImage); } } else { TkMacOSXDbgMsg("Drawing of empty CGImage requested"); } return Success; } /* *---------------------------------------------------------------------- * * XDrawLines -- |
︙ | ︙ | |||
563 564 565 566 567 568 569 | int i, lw = gc->line_width; if (npoints < 2) { return BadValue; } display->request++; | | | 777 778 779 780 781 782 783 784 785 786 787 788 789 790 791 | int i, lw = gc->line_width; if (npoints < 2) { return BadValue; } display->request++; if (!TkMacOSXSetupDrawingContext(d, gc, 1, &dc)) { return BadDrawable; } if (dc.context) { double prevx, prevy; double o = (lw % 2) ? .5 : 0; CGContextBeginPath(dc.context); |
︙ | ︙ | |||
586 587 588 589 590 591 592 | } else { prevx += points[i].x; prevy += points[i].y; CGContextAddLineToPoint(dc.context, prevx, prevy); } } CGContextStrokePath(dc.context); | < < < < < < < < < < < < < < < < < | 800 801 802 803 804 805 806 807 808 809 810 811 812 813 | } else { prevx += points[i].x; prevy += points[i].y; CGContextAddLineToPoint(dc.context, prevx, prevy); } } CGContextStrokePath(dc.context); } TkMacOSXRestoreDrawingContext(&dc); return Success; } /* *---------------------------------------------------------------------- |
︙ | ︙ | |||
637 638 639 640 641 642 643 | int nsegments) { MacDrawable *macWin = (MacDrawable *) d; TkMacOSXDrawingContext dc; int i, lw = gc->line_width; display->request++; | | < < < < < < < < < < < < < | 834 835 836 837 838 839 840 841 842 843 844 845 846 847 848 849 850 851 852 853 854 855 856 857 858 859 860 861 862 863 | int nsegments) { MacDrawable *macWin = (MacDrawable *) d; TkMacOSXDrawingContext dc; int i, lw = gc->line_width; display->request++; if (!TkMacOSXSetupDrawingContext(d, gc, 1, &dc)) { return; } if (dc.context) { double o = (lw % 2) ? .5 : 0; for (i = 0; i < nsegments; i++) { CGContextBeginPath(dc.context); CGContextMoveToPoint(dc.context, macWin->xOff + segments[i].x1 + o, macWin->yOff + segments[i].y1 + o); CGContextAddLineToPoint(dc.context, macWin->xOff + segments[i].x2 + o, macWin->yOff + segments[i].y2 + o); CGContextStrokePath(dc.context); } } TkMacOSXRestoreDrawingContext(&dc); } /* *---------------------------------------------------------------------- * |
︙ | ︙ | |||
701 702 703 704 705 706 707 | int mode) /* Drawing mode. */ { MacDrawable *macWin = (MacDrawable *) d; TkMacOSXDrawingContext dc; int i; display->request++; | | | 885 886 887 888 889 890 891 892 893 894 895 896 897 898 899 | int mode) /* Drawing mode. */ { MacDrawable *macWin = (MacDrawable *) d; TkMacOSXDrawingContext dc; int i; display->request++; if (!TkMacOSXSetupDrawingContext(d, gc, 1, &dc)) { return; } if (dc.context) { double prevx, prevy; double o = (gc->line_width % 2) ? .5 : 0; CGContextBeginPath(dc.context); |
︙ | ︙ | |||
724 725 726 727 728 729 730 | } else { prevx += points[i].x; prevy += points[i].y; CGContextAddLineToPoint(dc.context, prevx, prevy); } } CGContextEOFillPath(dc.context); | < < < < < < < < < < < < < < < < < | 908 909 910 911 912 913 914 915 916 917 918 919 920 921 | } else { prevx += points[i].x; prevy += points[i].y; CGContextAddLineToPoint(dc.context, prevx, prevy); } } CGContextEOFillPath(dc.context); } TkMacOSXRestoreDrawingContext(&dc); } /* *---------------------------------------------------------------------- * |
︙ | ︙ | |||
779 780 781 782 783 784 785 | int lw = gc->line_width; if (width == 0 || height == 0) { return; } display->request++; | | < < < < < < < < < | 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 | int lw = gc->line_width; if (width == 0 || height == 0) { return; } display->request++; if (!TkMacOSXSetupDrawingContext(d, gc, 1, &dc)) { return; } if (dc.context) { CGRect rect; double o = (lw % 2) ? .5 : 0; rect = CGRectMake( macWin->xOff + x + o, macWin->yOff + y + o, width, height); CGContextStrokeRect(dc.context, rect); } TkMacOSXRestoreDrawingContext(&dc); } #ifdef TK_MACOSXDRAW_UNUSED /* *---------------------------------------------------------------------- |
︙ | ︙ | |||
845 846 847 848 849 850 851 | { MacDrawable *macWin = (MacDrawable *) drawable; TkMacOSXDrawingContext dc; XRectangle * rectPtr; int i, lw = gc->line_width; display->request++; | | < < < < < < < < < < < | 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 | { MacDrawable *macWin = (MacDrawable *) drawable; TkMacOSXDrawingContext dc; XRectangle * rectPtr; int i, lw = gc->line_width; display->request++; if (!TkMacOSXSetupDrawingContext(d, gc, 1, &dc)) { return; } if (dc.context) { CGRect rect; double o = (lw % 2) ? .5 : 0; for (i = 0, rectPtr = rectArr; i < nRects; i++, rectPtr++) { if (rectPtr->width == 0 || rectPtr->height == 0) { continue; } rect = CGRectMake( macWin->xOff + rectPtr->x + o, macWin->yOff + rectPtr->y + o, rectPtr->width, rectPtr->height); CGContextStrokeRect(dc.context, rect); } } TkMacOSXRestoreDrawingContext(&dc); } #endif /* *---------------------------------------------------------------------- |
︙ | ︙ | |||
908 909 910 911 912 913 914 | { MacDrawable *macWin = (MacDrawable *) d; TkMacOSXDrawingContext dc; XRectangle * rectPtr; int i; display->request++; | | < < < < < < < < < < | 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 | { MacDrawable *macWin = (MacDrawable *) d; TkMacOSXDrawingContext dc; XRectangle * rectPtr; int i; display->request++; if (!TkMacOSXSetupDrawingContext(d, gc, 1, &dc)) { return BadDrawable; } if (dc.context) { CGRect rect; for (i = 0, rectPtr = rectangles; i < n_rectangles; i++, rectPtr++) { if (rectPtr->width == 0 || rectPtr->height == 0) { continue; } rect = CGRectMake( macWin->xOff + rectPtr->x, macWin->yOff + rectPtr->y, rectPtr->width, rectPtr->height); CGContextFillRect(dc.context, rect); } } TkMacOSXRestoreDrawingContext(&dc); return Success; } /* *---------------------------------------------------------------------- |
︙ | ︙ | |||
975 976 977 978 979 980 981 | int lw = gc->line_width; if (width == 0 || height == 0 || angle2 == 0) { return; } display->request++; | | < | | < < < < < | < < < < < < < | 1112 1113 1114 1115 1116 1117 1118 1119 1120 1121 1122 1123 1124 1125 1126 1127 1128 1129 1130 1131 1132 1133 1134 1135 1136 1137 1138 1139 1140 1141 1142 1143 1144 1145 1146 1147 1148 1149 1150 1151 1152 1153 1154 | int lw = gc->line_width; if (width == 0 || height == 0 || angle2 == 0) { return; } display->request++; if (!TkMacOSXSetupDrawingContext(d, gc, 1, &dc)) { return; } if (dc.context) { CGRect rect; double o = (lw % 2) ? .5 : 0; rect = CGRectMake( macWin->xOff + x + o, macWin->yOff + y + o, width, height); if (angle1 == 0 && angle2 == 23040) { CGContextStrokeEllipseInRect(dc.context, rect); } else { CGMutablePathRef p = CGPathCreateMutable(); CGAffineTransform t = CGAffineTransformIdentity; CGPoint c = CGPointMake(CGRectGetMidX(rect), CGRectGetMidY(rect)); double w = CGRectGetWidth(rect); if (width != height) { t = CGAffineTransformMakeScale(1.0, CGRectGetHeight(rect)/w); c = CGPointApplyAffineTransform(c, CGAffineTransformInvert(t)); } CGPathAddArc(p, &t, c.x, c.y, w/2, radians(-angle1/64.0), radians(-(angle1 + angle2)/64.0), angle2 > 0); CGContextAddPath(dc.context, p); CGPathRelease(p); CGContextStrokePath(dc.context); } } TkMacOSXRestoreDrawingContext(&dc); } #ifdef TK_MACOSXDRAW_UNUSED /* *---------------------------------------------------------------------- |
︙ | ︙ | |||
1060 1061 1062 1063 1064 1065 1066 | MacDrawable *macWin = (MacDrawable *) d; TkMacOSXDrawingContext dc; XArc *arcPtr; int i, lw = gc->line_width; display->request++; | | < | | < | < < < < < < < < < < < < < | 1184 1185 1186 1187 1188 1189 1190 1191 1192 1193 1194 1195 1196 1197 1198 1199 1200 1201 1202 1203 1204 1205 1206 1207 1208 1209 1210 1211 1212 1213 1214 1215 1216 1217 1218 1219 1220 1221 1222 1223 1224 1225 1226 1227 1228 1229 1230 1231 1232 1233 1234 1235 1236 | MacDrawable *macWin = (MacDrawable *) d; TkMacOSXDrawingContext dc; XArc *arcPtr; int i, lw = gc->line_width; display->request++; if (!TkMacOSXSetupDrawingContext(d, gc, 1, &dc)) { return; } if (dc.context) { CGRect rect; double o = (lw % 2) ? .5 : 0; for (i=0, arcPtr = arcArr; i < nArcs; i++, arcPtr++) { if (arcPtr->width == 0 || arcPtr->height == 0 || arcPtr->angle2 == 0) { continue; } rect = CGRectMake( macWin->xOff + arcPtr->x + o, macWin->yOff + arcPtr->y + o, arcPtr->width, arcPtr->height); if (arcPtr->angle1 == 0 && arcPtr->angle2 == 23040) { CGContextStrokeEllipseInRect(dc.context, rect); } else { CGMutablePathRef p = CGPathCreateMutable(); CGAffineTransform t = CGAffineTransformIdentity; CGPoint c = CGPointMake(CGRectGetMidX(rect), CGRectGetMidY(rect)); double w = CGRectGetWidth(rect); if (arcPtr->width != arcPtr->height) { t = CGAffineTransformMakeScale(1, CGRectGetHeight(rect)/w); c = CGPointApplyAffineTransform(c, CGAffineTransformInvert(t)); } CGPathAddArc(p, &t, c.x, c.y, w/2, radians(-arcPtr->angle1/64.0), radians(-(arcPtr->angle1 + arcPtr->angle2)/64.0), arcPtr->angle2 > 0); CGContextAddPath(dc.context, p); CGPathRelease(p); CGContextStrokePath(dc.context); } } } TkMacOSXRestoreDrawingContext(&dc); } #endif /* |
︙ | ︙ | |||
1156 1157 1158 1159 1160 1161 1162 | int lw = gc->line_width; if (width == 0 || height == 0 || angle2 == 0) { return; } display->request++; | | < | | < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < | 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 | int lw = gc->line_width; if (width == 0 || height == 0 || angle2 == 0) { return; } display->request++; if (!TkMacOSXSetupDrawingContext(d, gc, 1, &dc)) { return; } if (dc.context) { CGRect rect; double o = (lw % 2) ? .5 : 0, u = 0; if (notAA(lw)) { o += NON_AA_CG_OFFSET/2; u += NON_AA_CG_OFFSET; } rect = CGRectMake( macWin->xOff + x + o, macWin->yOff + y + o, width - u, height - u); if (angle1 == 0 && angle2 == 23040) { CGContextFillEllipseInRect(dc.context, rect); } else { CGMutablePathRef p = CGPathCreateMutable(); CGAffineTransform t = CGAffineTransformIdentity; CGPoint c = CGPointMake(CGRectGetMidX(rect), CGRectGetMidY(rect)); double w = CGRectGetWidth(rect); if (width != height) { t = CGAffineTransformMakeScale(1, CGRectGetHeight(rect)/w); c = CGPointApplyAffineTransform(c, CGAffineTransformInvert(t)); } if (gc->arc_mode == ArcPieSlice) { CGPathMoveToPoint(p, &t, c.x, c.y); } CGPathAddArc(p, &t, c.x, c.y, w/2, radians(-angle1/64.0), radians(-(angle1 + angle2)/64.0), angle2 > 0); CGPathCloseSubpath(p); CGContextAddPath(dc.context, p); CGPathRelease(p); CGContextFillPath(dc.context); } } TkMacOSXRestoreDrawingContext(&dc); } #ifdef TK_MACOSXDRAW_UNUSED /* |
︙ | ︙ | |||
1273 1274 1275 1276 1277 1278 1279 | { MacDrawable *macWin = (MacDrawable *) d; TkMacOSXDrawingContext dc; XArc * arcPtr; int i, lw = gc->line_width; display->request++; | | < | | | 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 | { MacDrawable *macWin = (MacDrawable *) d; TkMacOSXDrawingContext dc; XArc * arcPtr; int i, lw = gc->line_width; display->request++; if (!TkMacOSXSetupDrawingContext(d, gc, 1, &dc)) { return; } if (dc.context) { CGRect rect; double o = (lw % 2) ? .5 : 0, u = 0; if (notAA(lw)) { o += NON_AA_CG_OFFSET/2; u += NON_AA_CG_OFFSET; } for (i = 0, arcPtr = arcArr; i < nArcs; i++, arcPtr++) { if (arcPtr->width == 0 || arcPtr->height == 0 || arcPtr->angle2 == 0) { continue; } rect = CGRectMake( macWin->xOff + arcPtr->x + o, macWin->yOff + arcPtr->y + o, arcPtr->width - u, arcPtr->height - u); if (arcPtr->angle1 == 0 && arcPtr->angle2 == 23040) { CGContextFillEllipseInRect(dc.context, rect); } else { CGMutablePathRef p = CGPathCreateMutable(); CGAffineTransform t = CGAffineTransformIdentity; CGPoint c = CGPointMake(CGRectGetMidX(rect), CGRectGetMidY(rect)); double w = CGRectGetWidth(rect); if (arcPtr->width != arcPtr->height) { |
︙ | ︙ | |||
1319 1320 1321 1322 1323 1324 1325 | radians(-arcPtr->angle1/64.0), radians(-(arcPtr->angle1 + arcPtr->angle2)/64.0), arcPtr->angle2 > 0); CGPathCloseSubpath(p); CGContextAddPath(dc.context, p); CGPathRelease(p); CGContextFillPath(dc.context); | < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < | 1383 1384 1385 1386 1387 1388 1389 1390 1391 1392 1393 1394 1395 1396 | radians(-arcPtr->angle1/64.0), radians(-(arcPtr->angle1 + arcPtr->angle2)/64.0), arcPtr->angle2 > 0); CGPathCloseSubpath(p); CGContextAddPath(dc.context, p); CGPathRelease(p); CGContextFillPath(dc.context); } } } TkMacOSXRestoreDrawingContext(&dc); } #endif |
︙ | ︙ | |||
1417 1418 1419 1420 1421 1422 1423 | Tk_Window tkwin, /* The window to be scrolled. */ GC gc, /* GC for window to be scrolled. */ int x, int y, /* Position rectangle to be scrolled. */ int width, int height, int dx, int dy, /* Distance rectangle should be moved. */ TkRegion damageRgn) /* Region to accumulate damage in. */ { | | | < | | | > > > > > > > > | < < < > | < < < > > | | < < < < < < < < | | | | > | < | < | | < < < < | | < < < < < < | < < | | < < | < < < < < < < < < | | < < < < | < < < < < < < < < < < < < < < | 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 1498 1499 1500 1501 1502 1503 1504 1505 1506 1507 1508 1509 1510 1511 1512 1513 | Tk_Window tkwin, /* The window to be scrolled. */ GC gc, /* GC for window to be scrolled. */ int x, int y, /* Position rectangle to be scrolled. */ int width, int height, int dx, int dy, /* Distance rectangle should be moved. */ TkRegion damageRgn) /* Region to accumulate damage in. */ { MacDrawable *macDraw = (MacDrawable *) Tk_WindowId(tkwin); NSView *view = TkMacOSXDrawableView(macDraw); CGRect visRect, srcRect, dstRect; CGFloat boundsH; HIShapeRef dmgRgn, dstRgn; int result; if (view && !CGRectIsEmpty(visRect = NSRectToCGRect([view visibleRect]))) { boundsH = [view bounds].size.height; srcRect = CGRectMake(macDraw->xOff + x, boundsH - height - (macDraw->yOff + y), width, height); dstRect = CGRectIntersection(CGRectOffset(srcRect, dx, -dy), visRect); srcRect = CGRectIntersection(srcRect, visRect); if (!CGRectIsEmpty(srcRect) && !CGRectIsEmpty(dstRect)) { /* CGRect sRect = CGRectIntersection(CGRectOffset(dstRect, -dx, dy), srcRect); NSCopyBits(0, NSRectFromCGRect(sRect), NSPointFromCGPoint(CGRectOffset(sRect, dx, -dy).origin)); */ [view scrollRect:NSRectFromCGRect(srcRect) by:NSMakeSize(dx, -dy)]; } srcRect.origin.y = boundsH - srcRect.size.height - srcRect.origin.y; dstRect.origin.y = boundsH - dstRect.size.height - dstRect.origin.y; srcRect = CGRectUnion(srcRect, dstRect); dmgRgn = HIShapeCreateMutableWithRect(&srcRect); dstRgn = HIShapeCreateWithRect(&dstRect); ChkErr(HIShapeDifference, dmgRgn, dstRgn, (HIMutableShapeRef) dmgRgn); CFRelease(dstRgn); TkMacOSXInvalidateViewRegion(view, dmgRgn); } else { dmgRgn = HIShapeCreateEmpty(); } TkMacOSXSetWithNativeRegion(damageRgn, dmgRgn); result = HIShapeIsEmpty(dmgRgn) ? 0 : 1; CFRelease(dmgRgn); return result; } /* *---------------------------------------------------------------------- * * TkMacOSXSetUpGraphicsPort -- * * Set up the graphics port from the given GC. * * Results: * None. * * Side effects: * None. * *---------------------------------------------------------------------- */ void TkMacOSXSetUpGraphicsPort( GC gc, /* GC to apply to current port. */ void *destPort) { Tcl_Panic("TkMacOSXSetUpGraphicsPort: Obsolete, no more QD!"); } /* *---------------------------------------------------------------------- * * TkMacOSXSetUpDrawingContext -- * * Set up a drawing context for the given drawable and GC. * |
︙ | ︙ | |||
1555 1556 1557 1558 1559 1560 1561 | TkMacOSXSetupDrawingContext( Drawable d, GC gc, int useCG, /* advisory only ! */ TkMacOSXDrawingContext *dcPtr) { MacDrawable *macDraw = ((MacDrawable*)d); | | | < | < < < < | < | < < < < < | | < < | < > > > | > > > | > | < < < < | | < < < < | > > | < | | < < | > | > | > > > > > > > > | < | > > > > | | > | | | | | | | | | | < | | < < | < | < | < < < | | < < | < < < < < | 1526 1527 1528 1529 1530 1531 1532 1533 1534 1535 1536 1537 1538 1539 1540 1541 1542 1543 1544 1545 1546 1547 1548 1549 1550 1551 1552 1553 1554 1555 1556 1557 1558 1559 1560 1561 1562 1563 1564 1565 1566 1567 1568 1569 1570 1571 1572 1573 1574 1575 1576 1577 1578 1579 1580 1581 1582 1583 1584 1585 1586 1587 1588 1589 1590 1591 1592 1593 1594 1595 1596 1597 1598 1599 1600 1601 1602 1603 1604 1605 1606 1607 1608 1609 1610 1611 1612 1613 1614 1615 1616 1617 1618 1619 1620 1621 1622 1623 1624 1625 1626 1627 1628 1629 1630 1631 1632 1633 1634 1635 1636 1637 1638 1639 1640 1641 1642 1643 1644 1645 1646 1647 1648 1649 1650 1651 1652 1653 1654 1655 1656 1657 1658 1659 1660 1661 1662 1663 1664 1665 1666 1667 1668 1669 1670 1671 | TkMacOSXSetupDrawingContext( Drawable d, GC gc, int useCG, /* advisory only ! */ TkMacOSXDrawingContext *dcPtr) { MacDrawable *macDraw = ((MacDrawable*)d); int dontDraw = 0, isWin = 0; TkMacOSXDrawingContext dc = {}; CGRect clipBounds; dc.clipRgn = TkMacOSXGetClipRgn(d); if (!dontDraw) { ClipToGC(d, gc, &dc.clipRgn); dontDraw = dc.clipRgn ? HIShapeIsEmpty(dc.clipRgn) : 0; } if (dontDraw) { goto end; } if (useCG) { dc.context = GetCGContextForDrawable(d); } if (!dc.context || !(macDraw->flags & TK_IS_PIXMAP)) { isWin = (TkMacOSXDrawableWindow(d) != nil); } if (dc.context) { dc.portBounds = clipBounds = CGContextGetClipBoundingBox(dc.context); } else if (isWin) { NSView *view = TkMacOSXDrawableView(macDraw); if (view) { if (view != [NSView focusView]) { dc.focusLocked = [view lockFocusIfCanDraw]; dontDraw = !dc.focusLocked; } else { dontDraw = ![view canDraw]; } if (dontDraw) { goto end; } [[view window] disableFlushWindow]; dc.view = view; dc.context = [[NSGraphicsContext currentContext] graphicsPort]; dc.portBounds = NSRectToCGRect([view bounds]); if (dc.clipRgn) { clipBounds = CGContextGetClipBoundingBox(dc.context); } } else { Tcl_Panic("TkMacOSXSetupDrawingContext(): " "no NSView to draw into !"); } } else { Tcl_Panic("TkMacOSXSetupDrawingContext(): " "no context to draw into !"); } if (dc.context) { CGAffineTransform t = { .a = 1, .b = 0, .c = 0, .d = -1, .tx = 0, .ty = dc.portBounds.size.height}; dc.portBounds.origin.x += macDraw->xOff; dc.portBounds.origin.y += macDraw->yOff; if (!dc.focusLocked) { CGContextSaveGState(dc.context); } CGContextSetTextDrawingMode(dc.context, kCGTextFill); CGContextConcatCTM(dc.context, t); if (dc.clipRgn) { #ifdef TK_MAC_DEBUG_DRAWING CGContextSaveGState(dc.context); ChkErr(HIShapeReplacePathInCGContext, dc.clipRgn, dc.context); CGContextSetRGBFillColor(dc.context, 1.0, 0.0, 0.0, 0.1); CGContextEOFillPath(dc.context); CGContextRestoreGState(dc.context); #endif /* TK_MAC_DEBUG_DRAWING */ CGRect r; if (!HIShapeIsRectangular(dc.clipRgn) || !CGRectContainsRect( *HIShapeGetBounds(dc.clipRgn, &r), CGRectApplyAffineTransform(clipBounds, t))) { ChkErr(HIShapeReplacePathInCGContext, dc.clipRgn, dc.context); CGContextEOClip(dc.context); } } if (gc) { static const CGLineCap cgCap[] = { [CapNotLast] = kCGLineCapButt, [CapButt] = kCGLineCapButt, [CapRound] = kCGLineCapRound, [CapProjecting] = kCGLineCapSquare, }; static const CGLineJoin cgJoin[] = { [JoinMiter] = kCGLineJoinMiter, [JoinRound] = kCGLineJoinRound, [JoinBevel] = kCGLineJoinBevel, }; bool shouldAntialias; double w = gc->line_width; TkMacOSXSetColorInContext(gc, gc->foreground, dc.context); if (isWin) { CGContextSetPatternPhase(dc.context, CGSizeMake( dc.portBounds.size.width, dc.portBounds.size.height)); } if(gc->function != GXcopy) { TkMacOSXDbgMsg("Logical functions other than GXcopy are " "not supported for CG drawing!"); } /* When should we antialias? */ shouldAntialias = !notAA(gc->line_width); if (!shouldAntialias) { /* Make non-antialiased CG drawing look more like X11 */ w -= (gc->line_width ? NON_AA_CG_OFFSET : 0); } CGContextSetShouldAntialias(dc.context, shouldAntialias); CGContextSetLineWidth(dc.context, w); if (gc->line_style != LineSolid) { int num = 0; char *p = &(gc->dashes); CGFloat dashOffset = gc->dash_offset; CGFloat lengths[10]; while (p[num] != '\0' && num < 10) { lengths[num] = p[num]; num++; } CGContextSetLineDash(dc.context, dashOffset, lengths, num); } if ((unsigned)gc->cap_style < sizeof(cgCap)/sizeof(CGLineCap)) { CGContextSetLineCap(dc.context, cgCap[(unsigned)gc->cap_style]); } if ((unsigned)gc->join_style < sizeof(cgJoin)/sizeof(CGLineJoin)) { CGContextSetLineJoin(dc.context, cgJoin[(unsigned)gc->join_style]); } } } end: if (dontDraw && dc.clipRgn) { CFRelease(dc.clipRgn); dc.clipRgn = NULL; } *dcPtr = dc; return !dontDraw; } /* *---------------------------------------------------------------------- * |
︙ | ︙ | |||
1730 1731 1732 1733 1734 1735 1736 | void TkMacOSXRestoreDrawingContext( TkMacOSXDrawingContext *dcPtr) { if (dcPtr->context) { CGContextSynchronize(dcPtr->context); | | < < | < < < < < < < < < < < | < < | < < < | < < < < | 1684 1685 1686 1687 1688 1689 1690 1691 1692 1693 1694 1695 1696 1697 1698 1699 1700 1701 1702 1703 1704 1705 1706 1707 | void TkMacOSXRestoreDrawingContext( TkMacOSXDrawingContext *dcPtr) { if (dcPtr->context) { CGContextSynchronize(dcPtr->context); [[dcPtr->view window] enableFlushWindow]; if (dcPtr->focusLocked) { [dcPtr->view unlockFocus]; } else { CGContextRestoreGState(dcPtr->context); } } if (dcPtr->clipRgn) { CFRelease(dcPtr->clipRgn); } #ifdef TK_MAC_DEBUG bzero(dcPtr, sizeof(TkMacOSXDrawingContext)); #endif /* TK_MAC_DEBUG */ } /* *---------------------------------------------------------------------- |
︙ | ︙ | |||
1790 1791 1792 1793 1794 1795 1796 | HIShapeRef TkMacOSXGetClipRgn( Drawable drawable) /* Drawable. */ { MacDrawable *macDraw = (MacDrawable *) drawable; HIShapeRef clipRgn = NULL; | < | > > > > > > | > > > > > < < < | < < < < < < | < | | < < < < | < < < < < < < < < < | > | > | > > > > > > | > > > > > > | | > > > > > | > > > > > > | 1722 1723 1724 1725 1726 1727 1728 1729 1730 1731 1732 1733 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 1784 1785 1786 1787 1788 1789 1790 1791 1792 1793 1794 1795 1796 1797 1798 1799 1800 1801 1802 1803 1804 1805 1806 1807 1808 1809 1810 1811 1812 1813 1814 1815 1816 1817 1818 1819 1820 1821 1822 1823 1824 1825 1826 1827 1828 1829 1830 1831 1832 1833 1834 1835 1836 1837 1838 1839 1840 1841 1842 1843 1844 | HIShapeRef TkMacOSXGetClipRgn( Drawable drawable) /* Drawable. */ { MacDrawable *macDraw = (MacDrawable *) drawable; HIShapeRef clipRgn = NULL; if (macDraw->winPtr && macDraw->flags & TK_CLIP_INVALID) { TkMacOSXUpdateClipRgn(macDraw->winPtr); #ifdef TK_MAC_DEBUG_DRAWING TkMacOSXDbgMsg("%s", macDraw->winPtr->pathName); NSView *view = TkMacOSXDrawableView(macDraw); if ([view lockFocusIfCanDraw]) { CGContextRef context = [[NSGraphicsContext currentContext] graphicsPort]; CGContextSaveGState(context); CGContextConcatCTM(context, CGAffineTransformMake(1.0, 0.0, 0.0, -1.0, 0.0, [view bounds].size.height)); ChkErr(HIShapeReplacePathInCGContext, macDraw->visRgn, context); CGContextSetRGBFillColor(context, 0.0, 1.0, 0.0, 0.1); CGContextEOFillPath(context); CGContextRestoreGState(context); [view unlockFocus]; } #endif /* TK_MAC_DEBUG_DRAWING */ } if (macDraw->drawRgn) { clipRgn = HIShapeCreateCopy(macDraw->drawRgn); } else if (macDraw->visRgn) { clipRgn = HIShapeCreateCopy(macDraw->visRgn); } return clipRgn; } /* *---------------------------------------------------------------------- * * TkMacOSXSetUpClippingRgn -- * * Set up the clipping region so that drawing only occurs on the * specified X subwindow. * * Results: * None. * * Side effects: * None. * *---------------------------------------------------------------------- */ void TkMacOSXSetUpClippingRgn( Drawable drawable) /* Drawable to update. */ { } /* *---------------------------------------------------------------------- * * TkpClipDrawableToRect -- * * Clip all drawing into the drawable d to the given rectangle. * If width or height are negative, reset to no clipping. * * Results: * None. * * Side effects: * Subsequent drawing into d is offset and clipped as specified. * *---------------------------------------------------------------------- */ void TkpClipDrawableToRect( Display *display, Drawable d, int x, int y, int width, int height) { MacDrawable *macDraw = (MacDrawable *) d; NSView *view = TkMacOSXDrawableView(macDraw); if (macDraw->drawRgn) { CFRelease(macDraw->drawRgn); macDraw->drawRgn = NULL; } if (width >= 0 && height >= 0) { CGRect drawRect = CGRectMake(x + macDraw->xOff, y + macDraw->yOff, width, height); HIShapeRef drawRgn = HIShapeCreateWithRect(&drawRect); if (macDraw->winPtr && macDraw->flags & TK_CLIP_INVALID) { TkMacOSXUpdateClipRgn(macDraw->winPtr); } if (macDraw->visRgn) { macDraw->drawRgn = HIShapeCreateIntersection(macDraw->visRgn, drawRgn); CFRelease(drawRgn); } else { macDraw->drawRgn = drawRgn; } if (view && view != [NSView focusView] && [view lockFocusIfCanDraw]) { drawRect.origin.y = [view bounds].size.height - (drawRect.origin.y + drawRect.size.height); NSRectClip(NSRectFromCGRect(drawRect)); macDraw->flags |= TK_FOCUSED_VIEW; } } else { if (view && (macDraw->flags & TK_FOCUSED_VIEW)) { [view unlockFocus]; macDraw->flags &= ~TK_FOCUSED_VIEW; } } } /* *---------------------------------------------------------------------- * * ClipToGC -- |
︙ | ︙ | |||
1920 1921 1922 1923 1924 1925 1926 | if (gc && gc->clip_mask && ((TkpClipMask*)gc->clip_mask)->type == TKP_CLIP_REGION) { TkRegion gcClip = ((TkpClipMask*)gc->clip_mask)->value.region; int xOffset = ((MacDrawable *) d)->xOff + gc->clip_x_origin; int yOffset = ((MacDrawable *) d)->yOff + gc->clip_y_origin; HIShapeRef clipRgn = *clipRgnPtr, gcClipRgn; | < | < < | | < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < | 1863 1864 1865 1866 1867 1868 1869 1870 1871 1872 1873 1874 1875 1876 1877 1878 1879 1880 1881 1882 1883 1884 1885 1886 1887 | if (gc && gc->clip_mask && ((TkpClipMask*)gc->clip_mask)->type == TKP_CLIP_REGION) { TkRegion gcClip = ((TkpClipMask*)gc->clip_mask)->value.region; int xOffset = ((MacDrawable *) d)->xOff + gc->clip_x_origin; int yOffset = ((MacDrawable *) d)->yOff + gc->clip_y_origin; HIShapeRef clipRgn = *clipRgnPtr, gcClipRgn; TkMacOSXOffsetRegion(gcClip, xOffset, yOffset); gcClipRgn = TkMacOSXGetNativeRegion(gcClip); if (clipRgn) { *clipRgnPtr = HIShapeCreateIntersection(gcClipRgn, clipRgn); CFRelease(clipRgn); } else { *clipRgnPtr = HIShapeCreateCopy(gcClipRgn); } CFRelease(gcClipRgn); TkMacOSXOffsetRegion(gcClip, -xOffset, -yOffset); } } /* *---------------------------------------------------------------------- * * TkMacOSXMakeStippleMap -- * |
︙ | ︙ | |||
1985 1986 1987 1988 1989 1990 1991 | * * Side effects: * None. * *---------------------------------------------------------------------- */ | | < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < | | 1895 1896 1897 1898 1899 1900 1901 1902 1903 1904 1905 1906 1907 1908 1909 1910 1911 1912 1913 1914 | * * Side effects: * None. * *---------------------------------------------------------------------- */ void * TkMacOSXMakeStippleMap( Drawable drawable, /* Window to apply stipple. */ Drawable stipple) /* The stipple pattern. */ { return NULL; } /* *---------------------------------------------------------------------- * * TkpDrawHighlightBorder -- * |
︙ | ︙ | |||
2111 2112 2113 2114 2115 2116 2117 | } Tk_Fill3DRectangle(tkwin, Tk_WindowId(tkwin), border, highlightWidth, highlightWidth, Tk_Width(tkwin) - 2 * highlightWidth, Tk_Height(tkwin) - 2 * highlightWidth, borderWidth, relief); } | > > > > > > > > > | 1988 1989 1990 1991 1992 1993 1994 1995 1996 1997 1998 1999 2000 2001 2002 2003 | } Tk_Fill3DRectangle(tkwin, Tk_WindowId(tkwin), border, highlightWidth, highlightWidth, Tk_Width(tkwin) - 2 * highlightWidth, Tk_Height(tkwin) - 2 * highlightWidth, borderWidth, relief); } /* * Local Variables: * mode: c * c-basic-offset: 4 * fill-column: 79 * coding: utf-8 * End: */ |
Changes to macosx/tkMacOSXEmbed.c.
1 2 3 4 5 6 7 8 9 10 | /* * tkMacOSXEmbed.c -- * * This file contains platform-specific procedures for theMac to provide * basic operations needed for application embedding (where one * application can use as its main window an internal window from some * other application). Currently only Toplevel embedding within the same * Tk application is allowed on the Macintosh. * * Copyright (c) 1996-1997 Sun Microsystems, Inc. | | | | | | | 1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 | /* * tkMacOSXEmbed.c -- * * This file contains platform-specific procedures for theMac to provide * basic operations needed for application embedding (where one * application can use as its main window an internal window from some * other application). Currently only Toplevel embedding within the same * Tk application is allowed on the Macintosh. * * Copyright (c) 1996-1997 Sun Microsystems, Inc. * Copyright 2001-2009, Apple Inc. * Copyright (c) 2006-2009 Daniel A. Steffen <[email protected]> * * See the file "license.terms" for information on usage and redistribution * of this file, and for a DISCLAIMER OF ALL WARRANTIES. */ #include "tkMacOSXPrivate.h" /* * One of the following structures exists for each container in this * application. It keeps track of the container window and its associated * embedded window. */ |
︙ | ︙ | |||
139 140 141 142 143 144 145 | winPtr->privatePtr = NULL; return None; } macWin->winPtr = winPtr; winPtr->privatePtr = macWin; macWin->visRgn = NULL; macWin->aboveVisRgn = NULL; | | | | | 139 140 141 142 143 144 145 146 147 148 149 150 151 152 153 154 155 156 157 158 159 160 161 162 163 164 165 166 167 | winPtr->privatePtr = NULL; return None; } macWin->winPtr = winPtr; winPtr->privatePtr = macWin; macWin->visRgn = NULL; macWin->aboveVisRgn = NULL; macWin->drawRgn = NULL; macWin->referenceCount = 0; macWin->flags = TK_CLIP_INVALID; macWin->view = nil; macWin->context = NULL; macWin->size = CGSizeZero; if (Tk_IsTopLevel(macWin->winPtr)) { /* * This will be set when we are mapped. */ macWin->xOff = 0; macWin->yOff = 0; macWin->toplevel = macWin; } else if (winPtr->parentPtr) { macWin->xOff = winPtr->parentPtr->privatePtr->xOff + winPtr->parentPtr->changes.border_width + winPtr->changes.x; macWin->yOff = winPtr->parentPtr->privatePtr->yOff + winPtr->parentPtr->changes.border_width + winPtr->changes.y; macWin->toplevel = winPtr->parentPtr->privatePtr->toplevel; |
︙ | ︙ | |||
195 196 197 198 199 200 201 | int TkpUseWindow( Tcl_Interp *interp, /* If not NULL, used for error reporting if * string is bogus. */ Tk_Window tkwin, /* Tk window that does not yet have an * associated X window. */ | | | 195 196 197 198 199 200 201 202 203 204 205 206 207 208 209 | int TkpUseWindow( Tcl_Interp *interp, /* If not NULL, used for error reporting if * string is bogus. */ Tk_Window tkwin, /* Tk window that does not yet have an * associated X window. */ const char *string) /* String identifying an X window to use for * tkwin; must be an integer value. */ { TkWindow *winPtr = (TkWindow *) tkwin; TkWindow *usePtr; MacDrawable *parent, *macWin; Container *containerPtr; |
︙ | ︙ | |||
273 274 275 276 277 278 279 | * The grafPtr will be NULL for a Tk in Tk embedded window. It is none of * our business what it is for a Tk not in Tk embedded window, but we will * initialize it to NULL, and let the registerWinProc set it. In any case, * you must always use TkMacOSXGetDrawablePort to get the portPtr. It will * correctly find the container's port. */ | | | | 273 274 275 276 277 278 279 280 281 282 283 284 285 286 287 288 289 290 291 292 | * The grafPtr will be NULL for a Tk in Tk embedded window. It is none of * our business what it is for a Tk not in Tk embedded window, but we will * initialize it to NULL, and let the registerWinProc set it. In any case, * you must always use TkMacOSXGetDrawablePort to get the portPtr. It will * correctly find the container's port. */ macWin->view = nil; macWin->context = NULL; macWin->size = CGSizeZero; macWin->visRgn = NULL; macWin->aboveVisRgn = NULL; macWin->drawRgn = NULL; macWin->referenceCount = 0; macWin->flags = TK_CLIP_INVALID; macWin->toplevel = macWin; macWin->toplevel->referenceCount++; winPtr->flags |= TK_EMBEDDED; |
︙ | ︙ | |||
306 307 308 309 310 311 312 | if (containerPtr == NULL) { /* * If someone has registered an in process embedding handler, then * see if it can handle this window... */ if (tkMacOSXEmbedHandler == NULL || | | | 306 307 308 309 310 311 312 313 314 315 316 317 318 319 320 | if (containerPtr == NULL) { /* * If someone has registered an in process embedding handler, then * see if it can handle this window... */ if (tkMacOSXEmbedHandler == NULL || tkMacOSXEmbedHandler->registerWinProc((long) parent, (Tk_Window) winPtr) != TCL_OK) { Tcl_AppendResult(interp, "The window ID ", string, " does not correspond to a valid Tk Window.", NULL); return TCL_ERROR; } else { containerPtr = (Container *) ckalloc(sizeof(Container)); |
︙ | ︙ | |||
557 558 559 560 561 562 563 | */ int TkpTestembedCmd( ClientData clientData, /* Main window for application. */ Tcl_Interp *interp, /* Current interpreter. */ int argc, /* Number of arguments. */ | | | 557 558 559 560 561 562 563 564 565 566 567 568 569 570 571 | */ int TkpTestembedCmd( ClientData clientData, /* Main window for application. */ Tcl_Interp *interp, /* Current interpreter. */ int argc, /* Number of arguments. */ const char **argv) /* Argument strings. */ { int all; Container *containerPtr; Tcl_DString dString; char buffer[50]; if ((argc > 1) && (strcmp(argv[1], "all") == 0)) { |
︙ | ︙ | |||
636 637 638 639 640 641 642 643 644 645 646 647 648 649 | void TkpRedirectKeyEvent( TkWindow *winPtr, /* Window to which the event was originally * reported. */ XEvent *eventPtr) /* X event to redirect (should be KeyPress or * KeyRelease). */ { } /* *---------------------------------------------------------------------- * * TkpGetOtherWindow -- * | > | 636 637 638 639 640 641 642 643 644 645 646 647 648 649 650 | void TkpRedirectKeyEvent( TkWindow *winPtr, /* Window to which the event was originally * reported. */ XEvent *eventPtr) /* X event to redirect (should be KeyPress or * KeyRelease). */ { /* TODO: Implement this or decide it definitely needs no implementation */ } /* *---------------------------------------------------------------------- * * TkpGetOtherWindow -- * |
︙ | ︙ | |||
1081 1082 1083 1084 1085 1086 1087 | */ if (containerPtr->parentPtr != NULL && containerPtr->parentPtr->flags & TK_BOTH_HALVES) { XEvent event; event.xany.serial = | | | 1082 1083 1084 1085 1086 1087 1088 1089 1090 1091 1092 1093 1094 1095 1096 | */ if (containerPtr->parentPtr != NULL && containerPtr->parentPtr->flags & TK_BOTH_HALVES) { XEvent event; event.xany.serial = LastKnownRequestProcessed(Tk_Display(containerPtr->parentPtr)); event.xany.send_event = False; event.xany.display = Tk_Display(containerPtr->parentPtr); event.xany.type = DestroyNotify; event.xany.window = containerPtr->parent; event.xdestroywindow.event = containerPtr->parent; Tk_QueueWindowEvent(&event, TCL_QUEUE_HEAD); |
︙ | ︙ | |||
1112 1113 1114 1115 1116 1117 1118 | firstContainerPtr = containerPtr->nextPtr; } else { prevPtr->nextPtr = containerPtr->nextPtr; } ckfree((char *) containerPtr); } } | > > > > > > > > > | 1113 1114 1115 1116 1117 1118 1119 1120 1121 1122 1123 1124 1125 1126 1127 1128 | firstContainerPtr = containerPtr->nextPtr; } else { prevPtr->nextPtr = containerPtr->nextPtr; } ckfree((char *) containerPtr); } } /* * Local Variables: * mode: c * c-basic-offset: 4 * fill-column: 79 * coding: utf-8 * End: */ |
Changes to macosx/tkMacOSXEntry.c.
1 2 3 4 5 6 | /* * tkMacOSXEntry.c -- * * This file implements the native aqua entry widget. * * Copyright 2001, Apple Computer, Inc. | | > | | < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < | > > | | < > | > > < | | | | | | | | | | | | | | | < < < < < < < | < < | | | < | | | > | > > > | < > > > > > > > | | | | | | < | | | | | | | | | | | < < < < < | | < < < < < < | < < < > | | < | | | | > > | < < < < < < > > > > | | | < | | | | | | | | | | < < | < | > | > | | | | | | < | > > > > > > > > | 1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 34 35 36 37 38 39 40 41 42 43 44 45 46 47 48 49 50 51 52 53 54 55 56 57 58 59 60 61 62 63 64 65 66 67 68 69 70 71 72 73 74 75 76 77 78 79 80 81 82 83 84 85 86 87 88 89 90 91 92 93 94 95 96 97 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 129 130 131 132 133 134 135 136 137 138 139 140 141 142 143 144 145 146 147 148 149 150 151 152 153 154 155 156 157 158 159 160 161 162 163 164 165 166 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 224 225 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 256 257 258 259 260 261 262 263 264 265 266 267 | /* * tkMacOSXEntry.c -- * * This file implements the native aqua entry widget. * * Copyright 2001, Apple Computer, Inc. * Copyright (c) 2006-2009 Daniel A. Steffen <[email protected]> * Copyright 2008-2009, Apple Inc. * * See the file "license.terms" for information on usage and redistribution * of this file, and for a DISCLAIMER OF ALL WARRANTIES. */ #include "tkMacOSXPrivate.h" #include "tkEntry.h" static ThemeButtonKind ComputeIncDecParameters(int height, int *width); #define HIOrientation kHIThemeOrientationNormal /* *-------------------------------------------------------------- * * ComputeIncDecParameters -- * * This procedure figures out which of the kThemeIncDec buttons to use. * It also sets width to the width of the IncDec button. * * Results: * The ThemeButtonKind of the button we should use. * * Side effects: * May draw the entry border into pixmap. * *-------------------------------------------------------------- */ static ThemeButtonKind ComputeIncDecParameters( int height, int *width) { ThemeButtonKind kind; if (height < 11 || height > 28) { *width = 0; kind = (ThemeButtonKind) 0; } else { if (height >= 21) { *width = 13; kind = kThemeIncDecButton; } else if (height >= 18) { *width = 12; kind = kThemeIncDecButtonSmall; } else { *width = 11; kind = kThemeIncDecButtonMini; } } return kind; } /* *-------------------------------------------------------------- * * TkpDrawEntryBorderAndFocus -- * * This procedure redraws the border of an entry window. It overrides the * generic border drawing code if the entry widget parameters are such * that the native widget drawing is a good fit. This version just * returns 1, so platforms that don't do special native drawing don't * have to implement it. * * Results: * 1 if it has drawn the border, 0 if not. * * Side effects: * May draw the entry border into pixmap. * *-------------------------------------------------------------- */ int TkpDrawEntryBorderAndFocus( Entry *entryPtr, Drawable d, int isSpinbox) { CGRect bounds; TkMacOSXDrawingContext dc; GC bgGC; Tk_Window tkwin = entryPtr->tkwin; int oldWidth = 0; MacDrawable *macDraw = (MacDrawable *) d; const HIThemeFrameDrawInfo info = { .version = 0, .kind = kHIThemeFrameTextFieldSquare, .state = (entryPtr->state == STATE_DISABLED ? kThemeStateInactive : kThemeStateActive), .isFocused = (entryPtr->flags & GOT_FOCUS ? 1 : 0), }; /* * I use 6 as the borderwidth. 2 of the 5 go into the actual frame the 3 * are because the Mac OS Entry widgets leave more space around the Text * than Tk does on X11. */ if (entryPtr->borderWidth != MAC_OSX_ENTRY_BORDER || entryPtr->highlightWidth != MAC_OSX_FOCUS_WIDTH || entryPtr->relief != MAC_OSX_ENTRY_RELIEF) { return 0; } /* * For the spinbox, we have to make the entry part smaller by the size of * the buttons. We also leave 2 pixels to the left (as per the HIG) and * space for one pixel to the right, 'cause it makes the buttons look * nicer. */ if (isSpinbox) { int incDecWidth; oldWidth = Tk_Width(tkwin); ComputeIncDecParameters(Tk_Height(tkwin) - 2 * MAC_OSX_FOCUS_WIDTH, &incDecWidth); Tk_Width(tkwin) -= incDecWidth + 1; } /* * The focus ring is drawn with an Alpha at the outside part of the ring, * so we have to draw over the edges of the ring before drawing the focus * or the text will peep through. */ bgGC = Tk_GCForColor(entryPtr->highlightBgColorPtr, d); TkDrawInsetFocusHighlight(entryPtr->tkwin, bgGC, MAC_OSX_FOCUS_WIDTH, d, 0); /* * Inset the entry Frame by the maximum width of the focus rect, which is * 3 according to the Carbon docs. */ bounds.origin.x = macDraw->xOff + MAC_OSX_FOCUS_WIDTH; bounds.origin.y = macDraw->yOff + MAC_OSX_FOCUS_WIDTH; bounds.size.width = Tk_Width(tkwin) - 2*MAC_OSX_FOCUS_WIDTH; bounds.size.height = Tk_Height(tkwin) - 2*MAC_OSX_FOCUS_WIDTH; if (!TkMacOSXSetupDrawingContext(d, NULL, 1, &dc)) { return 0; } ChkErr(HIThemeDrawFrame, &bounds, &info, dc.context, HIOrientation); TkMacOSXRestoreDrawingContext(&dc); if (isSpinbox) { Tk_Width(tkwin) = oldWidth; } return 1; } /* *-------------------------------------------------------------- * * TkpDrawSpinboxButtons -- * * This procedure redraws the buttons of an spinbox widget. It overrides * the generic button drawing code if the spinbox widget parameters are * such that the native widget drawing is a good fit. This version just * returns 0, so platforms that don't do special native drawing don't * have to implement it. * * Results: * 1 if it has drawn the border, 0 if not. * * Side effects: * May draw the entry border into pixmap. * *-------------------------------------------------------------- */ int TkpDrawSpinboxButtons( Spinbox *sbPtr, Drawable d) { CGRect bounds; Tk_Window tkwin = sbPtr->entry.tkwin; int height = Tk_Height(tkwin); int buttonHeight = height - 2 * MAC_OSX_FOCUS_WIDTH; int incDecWidth; TkMacOSXDrawingContext dc; XRectangle rects[1]; GC bgGC; MacDrawable *macDraw = (MacDrawable *) d; HIThemeButtonDrawInfo info = { .version = 0, .adornment = kThemeAdornmentNone, }; /* * FIXME: RAISED really makes more sense */ if (sbPtr->buRelief != TK_RELIEF_FLAT) { return 0; } /* * The actual sizes of the IncDec button are 21 for the normal, 18 for the * small and 15 for the mini. But the spinbox still looks okay if the * entry is a little bigger than this, so we give it a little slop. */ info.kind = ComputeIncDecParameters(buttonHeight, &incDecWidth); if (info.kind == (ThemeButtonKind) 0) { return 0; } if (sbPtr->entry.state == STATE_DISABLED) { info.state = kThemeStateInactive; info.value = kThemeButtonOff; } else if (sbPtr->selElement == SEL_BUTTONUP) { info.state = kThemeStatePressedUp; info.value = kThemeButtonOn; } else if (sbPtr->selElement == SEL_BUTTONDOWN) { info.state = kThemeStatePressedDown; info.value = kThemeButtonOn; } else { info.state = kThemeStateActive; info.value = kThemeButtonOff; } bounds.origin.x = macDraw->xOff + Tk_Width(tkwin) - incDecWidth - 1; bounds.origin.y = macDraw->yOff + MAC_OSX_FOCUS_WIDTH; bounds.size.width = incDecWidth; bounds.size.height = Tk_Height(tkwin) - 2*MAC_OSX_FOCUS_WIDTH; /* * We had to make the entry part of the window smaller so that we wouldn't * overdraw the spin buttons with the focus highlight. So now we have to * draw the highlightbackground. */ bgGC = Tk_GCForColor(sbPtr->entry.highlightBgColorPtr, d); rects[0].x = bounds.origin.x; rects[0].y = 0; rects[0].width = Tk_Width(tkwin); rects[0].height = Tk_Height(tkwin); XFillRectangles(Tk_Display(tkwin), d, bgGC, rects, 1); if (!TkMacOSXSetupDrawingContext(d, NULL, 1, &dc)) { return 0; } ChkErr(HIThemeDrawButton, &bounds, &info, dc.context, HIOrientation, NULL); TkMacOSXRestoreDrawingContext(&dc); return 1; } /* * Local Variables: * mode: c * c-basic-offset: 4 * fill-column: 79 * coding: utf-8 * End: */ |
Changes to macosx/tkMacOSXEvent.c.
1 2 3 4 5 6 | /* * tkMacOSXEvent.c -- * * This file contains the basic Mac OS X Event handling routines. * * Copyright (c) 1995-1997 Sun Microsystems, Inc. | | | > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > | | < | < < < < < | < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < | < < < | < < < < < < < < < < < < < < < < | < > > > > | < < < < < | < < < < < < < < < | < < < < < < | < < | < < < | < < < < < < < < < < < < < | < < < < < < < | < < < < < < < < < < < < < < | < | < < | | < < | < | < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < | 1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 34 35 36 37 38 39 40 41 42 43 44 45 46 47 48 49 50 51 52 53 54 55 56 57 58 59 60 61 62 63 64 65 66 67 68 69 70 71 72 73 74 75 76 77 78 79 80 81 82 83 84 85 86 87 88 89 90 91 92 93 94 95 96 97 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 129 130 131 132 133 134 135 136 137 138 139 140 141 142 143 144 145 146 147 148 149 150 151 152 153 154 | /* * tkMacOSXEvent.c -- * * This file contains the basic Mac OS X Event handling routines. * * Copyright (c) 1995-1997 Sun Microsystems, Inc. * Copyright 2001-2009, Apple Inc. * Copyright (c) 2005-2009 Daniel A. Steffen <[email protected]> * * See the file "license.terms" for information on usage and redistribution * of this file, and for a DISCLAIMER OF ALL WARRANTIES. */ #include "tkMacOSXPrivate.h" #include "tkMacOSXEvent.h" #include "tkMacOSXDebug.h" #pragma mark TKApplication(TKEvent) enum { NSWindowWillMoveEventType = 20 }; @implementation TKApplication(TKEvent) /* TODO: replace by +[addLocalMonitorForEventsMatchingMask ? */ - (NSEvent *)tkProcessEvent:(NSEvent *)theEvent { #ifdef TK_MAC_DEBUG_EVENTS TKLog(@"-[%@(%p) %s] %@", [self class], self, _cmd, theEvent); #endif NSEvent *processedEvent = theEvent; NSEventType type = [theEvent type]; NSInteger subtype; NSUInteger flags; switch ((NSInteger)type) { case NSAppKitDefined: subtype = [theEvent subtype]; switch (subtype) { case NSApplicationActivatedEventType: break; case NSApplicationDeactivatedEventType: break; case NSWindowExposedEventType: case NSScreenChangedEventType: break; case NSWindowMovedEventType: break; case NSWindowWillMoveEventType: break; default: break; } break; case NSKeyUp: case NSKeyDown: case NSFlagsChanged: flags = [theEvent modifierFlags]; processedEvent = [self tkProcessKeyEvent:theEvent]; break; case NSLeftMouseDown: case NSLeftMouseUp: case NSRightMouseDown: case NSRightMouseUp: case NSLeftMouseDragged: case NSRightMouseDragged: case NSMouseMoved: case NSMouseEntered: case NSMouseExited: case NSScrollWheel: case NSOtherMouseDown: case NSOtherMouseUp: case NSOtherMouseDragged: case NSTabletPoint: case NSTabletProximity: processedEvent = [self tkProcessMouseEvent:theEvent]; break; #if 0 case NSSystemDefined: subtype = [theEvent subtype]; break; case NSApplicationDefined: { id win; win = [theEvent window]; break; } case NSCursorUpdate: break; #if MAC_OS_X_VERSION_MAX_ALLOWED >= 1060 case NSEventTypeGesture: case NSEventTypeMagnify: case NSEventTypeRotate: case NSEventTypeSwipe: case NSEventTypeBeginGesture: case NSEventTypeEndGesture: break; #endif #endif default: break; } return processedEvent; } @end #pragma mark - /* *---------------------------------------------------------------------- * * TkMacOSXFlushWindows -- * * This routine flushes all the windows of the application. It is * called by XSync(). * * Results: * None. * * Side effects: * Flushes all Carbon windows * *---------------------------------------------------------------------- */ MODULE_SCOPE void TkMacOSXFlushWindows(void) { NSInteger windowCount; NSInteger *windowNumbers; NSCountWindows(&windowCount); if(windowCount) { windowNumbers = (NSInteger *) ckalloc(windowCount * sizeof(NSInteger)); NSWindowList(windowCount, windowNumbers); for (NSInteger index = 0; index < windowCount; index++) { NSWindow *w = [NSApp windowWithWindowNumber:windowNumbers[index]]; if (TkMacOSXGetXWindow(w)) { [w flushWindow]; } } ckfree((char*) windowNumbers); } } /* * Local Variables: * mode: c * c-basic-offset: 4 * fill-column: 79 * coding: utf-8 * End: */ |
Changes to macosx/tkMacOSXEvent.h.
1 2 3 4 5 6 | /* * tkMacOSXEvent.h -- * * Declarations of Macintosh specific functions for implementing the * Mac OS X Notifier. * | | | | | < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < | 1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 | /* * tkMacOSXEvent.h -- * * Declarations of Macintosh specific functions for implementing the * Mac OS X Notifier. * * Copyright 2001-2009, Apple Inc. * Copyright (c) 2005-2009 Daniel A. Steffen <[email protected]> * * See the file "license.terms" for information on usage and redistribution * of this file, and for a DISCLAIMER OF ALL WARRANTIES. */ #ifndef _TKMACEVENT #define _TKMACEVENT #ifndef _TKMACINT #include "tkMacOSXInt.h" #endif MODULE_SCOPE void TkMacOSXFlushWindows(void); #endif |
Changes to macosx/tkMacOSXFont.c.
1 2 3 4 | /* * tkMacOSXFont.c -- * * Contains the Macintosh implementation of the platform-independant | | | < < < < < < | < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < | < < < < < < | < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < | 1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 34 35 36 37 38 39 40 41 42 43 | /* * tkMacOSXFont.c -- * * Contains the Macintosh implementation of the platform-independant * font package interface. * * Copyright 2002-2004 Benjamin Riefenstahl, [email protected] * Copyright (c) 2006-2009 Daniel A. Steffen <[email protected]> * Copyright 2008-2009, Apple Inc. * * See the file "license.terms" for information on usage and redistribution * of this file, and for a DISCLAIMER OF ALL WARRANTIES. */ #include "tkMacOSXPrivate.h" #include "tkMacOSXFont.h" /* #ifdef TK_MAC_DEBUG #define TK_MAC_DEBUG_FONTS #endif */ /* * The following structure represents our Macintosh-specific implementation * of a font object. */ typedef struct { TkFont font; /* Stuff used by generic font package. Must * be first in structure. */ NSFont *nsFont; NSDictionary *nsAttributes; } MacFont; /* * The names for our "native" fonts. */ #define SYSTEMFONT_NAME "system" #define APPLFONT_NAME "application" #define MENUITEMFONT_NAME "menu" |
︙ | ︙ | |||
183 184 185 186 187 188 189 | ThemeFont(MiniSystem), { kThemeSystemFontDetail, "systemDetailSystemFont" }, { kThemeSystemFontDetailEmphasized, "systemDetailEmphasizedSystemFont" }, { -1, NULL } }; #undef ThemeFont | < < < | < < < | < < < | < < < < < < | < < < | < < < < < < < < < < < < < | < < < | < < < < < < < | < < | < < < < < < < < < < < < < < < < < < > > > > > > > > | > > > > > > > | | > > > > > > > > > > | > > > > > > > | > > > > > | > > > > > > > > > < > | | | | > > > > > > > | | > > > > | > > > > | > | < | > > > > | > > > > > > > > > > > > > > > > > > | | < > < | < | | | > > | < < < | > > > > > > > > > > > | > | | | | > | > > > > | | > > > | > > > > < < < > | | | < < < < < > | | > > > > | > > | > > > > | > | > > > > > > > > > > > | < < < | < | 70 71 72 73 74 75 76 77 78 79 80 81 82 83 84 85 86 87 88 89 90 91 92 93 94 95 96 97 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 129 130 131 132 133 134 135 136 137 138 139 140 141 142 143 144 145 146 147 148 149 150 151 152 153 154 155 156 157 158 159 160 161 162 163 164 165 166 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 224 225 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 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 284 285 286 287 288 289 290 291 292 293 294 295 296 297 298 299 300 301 302 303 304 | ThemeFont(MiniSystem), { kThemeSystemFontDetail, "systemDetailSystemFont" }, { kThemeSystemFontDetailEmphasized, "systemDetailEmphasizedSystemFont" }, { -1, NULL } }; #undef ThemeFont static int antialiasedTextEnabled = -1; static NSCharacterSet *whitespaceCharacterSet = nil; static NSCharacterSet *lineendingCharacterSet = nil; static void GetTkFontAttributesForNSFont(NSFont *nsFont, TkFontAttributes *faPtr); static NSFont *FindNSFont(const char *familyName, NSFontTraitMask traits, NSInteger weight, CGFloat size, int fallbackToDefault); static void InitFont(NSFont *nsFont, const TkFontAttributes *reqFaPtr, MacFont * fontPtr); static int CreateNamedSystemFont(Tcl_Interp *interp, Tk_Window tkwin, const char* name, TkFontAttributes *faPtr); static void DrawCharsInContext(Display *display, Drawable drawable, GC gc, Tk_Font tkfont, const char *source, int numBytes, int rangeStart, int rangeLength, int x, int y, double angle); @interface NSFont(TKFont) - (NSFont *)bestMatchingFontForCharacters:(const UTF16Char *)characters length:(NSUInteger)length attributes:(NSDictionary *)attributes actualCoveredLength:(NSUInteger *)coveredLength; @end #pragma mark - #pragma mark Font Helpers: #define GetNSFontTraitsFromTkFontAttributes(faPtr) \ ((faPtr)->weight == TK_FW_BOLD ? NSBoldFontMask : NSUnboldFontMask) | \ ((faPtr)->slant == TK_FS_ITALIC ? NSItalicFontMask : NSUnitalicFontMask) /* *--------------------------------------------------------------------------- * * GetTkFontAttributesForNSFont -- * * Fill in TkFontAttributes for given NSFont. * * Results: * None. * * Side effects: * None. * *--------------------------------------------------------------------------- */ static void GetTkFontAttributesForNSFont( NSFont *nsFont, TkFontAttributes *faPtr) { NSFontTraitMask traits = [[NSFontManager sharedFontManager] traitsOfFont:nsFont]; faPtr->family = Tk_GetUid([[nsFont familyName] UTF8String]); faPtr->size = [nsFont pointSize]; faPtr->weight = (traits & NSBoldFontMask ? TK_FW_BOLD : TK_FW_NORMAL); faPtr->slant = (traits & NSItalicFontMask ? TK_FS_ITALIC : TK_FS_ROMAN); } /* *--------------------------------------------------------------------------- * * FindNSFont -- * * Find NSFont for given attributes. Use default values for missing * attributes, and do a case-insensitive search for font family names * if necessary. If fallbackToDefault flag is set, use the system font * as a last resort. * * Results: * None. * * Side effects: * None. * *--------------------------------------------------------------------------- */ static NSFont * FindNSFont( const char *familyName, NSFontTraitMask traits, NSInteger weight, CGFloat size, int fallbackToDefault) { NSFontManager *fm = [NSFontManager sharedFontManager]; NSFont *nsFont, *dflt = nil; #define defaultFont (dflt ? dflt : (dflt = [NSFont systemFontOfSize:0])) NSString *family; if (familyName) { family = [[[NSString alloc] initWithUTF8String:familyName] autorelease]; } else { family = [defaultFont familyName]; } if (size == 0.0) { size = [defaultFont pointSize]; } nsFont = [fm fontWithFamily:family traits:traits weight:weight size:size]; if (!nsFont) { NSArray *availableFamilies = [fm availableFontFamilies]; NSString *caseFamily = nil; for (NSString *f in availableFamilies) { if ([family caseInsensitiveCompare:f] == NSOrderedSame) { caseFamily = f; break; } } if (caseFamily) { nsFont = [fm fontWithFamily:caseFamily traits:traits weight:weight size:size]; } } if (!nsFont) { nsFont = [NSFont fontWithName:family size:size]; } if (!nsFont && fallbackToDefault) { nsFont = [fm convertFont:defaultFont toFamily:family]; nsFont = [fm convertFont:nsFont toSize:size]; nsFont = [fm convertFont:nsFont toHaveTrait:traits]; } #undef defaultFont return nsFont; } /* *--------------------------------------------------------------------------- * * InitFont -- * * Helper for TkpGetNativeFont() and TkpGetFontFromAttributes(). * * Results: * Fills the MacFont structure. * * Side effects: * Memory allocated. * *--------------------------------------------------------------------------- */ static void InitFont( NSFont *nsFont, const TkFontAttributes *reqFaPtr, /* Can be NULL */ MacFont *fontPtr) { TkFontAttributes *faPtr; TkFontMetrics *fmPtr; NSDictionary *nsAttributes; NSRect bounds; CGFloat kern = 0.0; NSFontRenderingMode renderingMode = NSFontDefaultRenderingMode; int ascent, descent/*, dontAA*/; static const UniChar ch[] = {'.', 'W', ' ', 0xc4, 0xc1, 0xc2, 0xc3, 0xc7}; /* ., W, Space, Auml, Aacute, Acirc, Atilde, Ccedilla */ #define nCh (sizeof(ch) / sizeof(UniChar)) CGGlyph glyphs[nCh]; CGRect boundingRects[nCh]; fontPtr->font.fid = (Font) fontPtr; faPtr = &fontPtr->font.fa; if (reqFaPtr) { *faPtr = *reqFaPtr; } else { TkInitFontAttributes(faPtr); } fontPtr->nsFont = nsFont; // some don't like antialiasing on fixed-width even if bigger than limit // dontAA = [nsFont isFixedPitch] && fontPtr->font.fa.size <= 10; if (antialiasedTextEnabled >= 0/* || dontAA*/) { renderingMode = (antialiasedTextEnabled == 0/* || dontAA*/) ? NSFontIntegerAdvancementsRenderingMode : NSFontAntialiasedRenderingMode; } nsFont = [nsFont screenFontWithRenderingMode:renderingMode]; GetTkFontAttributesForNSFont(nsFont, faPtr); fmPtr = &fontPtr->font.fm; fmPtr->ascent = floor([nsFont ascender] + [nsFont leading] + 0.5); fmPtr->descent = floor(-[nsFont descender] + 0.5); fmPtr->maxWidth = [nsFont maximumAdvancement].width; fmPtr->fixed = [nsFont isFixedPitch]; /* Does not work for all fonts */ /* * The ascent, descent and fixed fields are not correct for all fonts, as * a workaround deduce that info from the metrics of some typical glyphs, * along with screenfont kerning (space advance difference to printer font) */ bounds = [nsFont boundingRectForFont]; if (CTFontGetGlyphsForCharacters((CTFontRef) nsFont, ch, glyphs, nCh)) { fmPtr->fixed = [nsFont advancementForGlyph:glyphs[0]].width == [nsFont advancementForGlyph:glyphs[1]].width; bounds = NSRectFromCGRect(CTFontGetBoundingRectsForGlyphs((CTFontRef) nsFont, kCTFontDefaultOrientation, ch, boundingRects, nCh)); kern = [nsFont advancementForGlyph:glyphs[2]].width - [fontPtr->nsFont advancementForGlyph:glyphs[2]].width; } descent = floor(-bounds.origin.y + 0.5); ascent = floor(bounds.size.height + bounds.origin.y + 0.5); if (ascent > fmPtr->ascent) { fmPtr->ascent = ascent; } if (descent > fmPtr->descent) { fmPtr->descent = descent; } nsAttributes = [NSDictionary dictionaryWithObjectsAndKeys: nsFont, NSFontAttributeName, [NSNumber numberWithInt:faPtr->underline ? NSUnderlineStyleSingle|NSUnderlinePatternSolid : NSUnderlineStyleNone], NSUnderlineStyleAttributeName, [NSNumber numberWithInt:faPtr->overstrike ? NSUnderlineStyleSingle|NSUnderlinePatternSolid : NSUnderlineStyleNone], NSStrikethroughStyleAttributeName, [NSNumber numberWithInt:fmPtr->fixed ? 0 : 1], NSLigatureAttributeName, [NSNumber numberWithDouble:kern], NSKernAttributeName, nil]; fontPtr->nsAttributes = TkMacOSXMakeUncollectableAndRetain(nsAttributes); #undef nCh } /* *------------------------------------------------------------------------- * * CreateNamedSystemFont -- * |
︙ | ︙ | |||
379 380 381 382 383 384 385 | Tk_Window tkwin, const char* name, TkFontAttributes *faPtr) { TkDeleteNamedFont(NULL, tkwin, name); return TkCreateNamedFont(interp, tkwin, name, faPtr); } | | > > > | | < > > > > > > > > > > | < > | > > > > | | < | | > | < | > > | > > > | | | > | > > | > | > | > | > > > > > > | > > > > > > > > > > > > > > > | 321 322 323 324 325 326 327 328 329 330 331 332 333 334 335 336 337 338 339 340 341 342 343 344 345 346 347 348 349 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 | Tk_Window tkwin, const char* name, TkFontAttributes *faPtr) { TkDeleteNamedFont(NULL, tkwin, name); return TkCreateNamedFont(interp, tkwin, name, faPtr); } #pragma mark - #pragma mark Font handling: /* *------------------------------------------------------------------------- * * TkpFontPkgInit -- * * This procedure is called when an application is created. It * initializes all the structures that are used by the * platform-dependant code on a per application basis. * Note that this is called before TkpInit() ! * * Results: * None. * * Side effects: * Initialize named system fonts. * *------------------------------------------------------------------------- */ void TkpFontPkgInit( TkMainInfo *mainPtr) /* The application being created. */ { Tcl_Interp *interp = mainPtr->interp; Tk_Window tkwin = (Tk_Window) mainPtr->winPtr; const struct SystemFontMapEntry *systemFont = systemFontMap; NSFont *nsFont; TkFontAttributes fa; NSMutableCharacterSet *cs; NSAutoreleasePool *pool = [NSAutoreleasePool new]; /* force this for now */ if (!mainPtr->winPtr->mainPtr) { mainPtr->winPtr->mainPtr = mainPtr; } while (systemFont->systemName) { nsFont = (NSFont*) CTFontCreateUIFontForLanguage( HIThemeGetUIFontType(systemFont->id), 0, NULL); if (nsFont) { TkInitFontAttributes(&fa); GetTkFontAttributesForNSFont(nsFont, &fa); CreateNamedSystemFont(interp, tkwin, systemFont->systemName, &fa); if (systemFont->tkName) { CreateNamedSystemFont(interp, tkwin, systemFont->tkName, &fa); } if (systemFont->tkName1) { CreateNamedSystemFont(interp, tkwin, systemFont->tkName1, &fa); } CFRelease(nsFont); } systemFont++; } TkInitFontAttributes(&fa); nsFont = (NSFont*) CTFontCreateUIFontForLanguage( kCTFontUserFixedPitchFontType, 11, NULL); if (nsFont) { GetTkFontAttributesForNSFont(nsFont, &fa); CFRelease(nsFont); } else { fa.family = Tk_GetUid("Monaco"); fa.size = 11; fa.weight = TK_FW_NORMAL; fa.slant = TK_FS_ROMAN; } CreateNamedSystemFont(interp, tkwin, "TkFixedFont", &fa); if (!whitespaceCharacterSet) { whitespaceCharacterSet = [[NSCharacterSet whitespaceAndNewlineCharacterSet] retain]; cs = [whitespaceCharacterSet mutableCopy]; [cs removeCharactersInString:@" "]; lineendingCharacterSet = [cs copy]; [cs release]; } [pool drain]; } /* *--------------------------------------------------------------------------- * * TkpGetNativeFont -- * |
︙ | ︙ | |||
443 444 445 446 447 448 449 450 | */ TkFont * TkpGetNativeFont( Tk_Window tkwin, /* For display where font will be used. */ const char *name) /* Platform-specific font name. */ { ThemeFontID themeFontId; | > < < < < | | < | < < | | | > | 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 | */ TkFont * TkpGetNativeFont( Tk_Window tkwin, /* For display where font will be used. */ const char *name) /* Platform-specific font name. */ { MacFont *fontPtr = NULL; ThemeFontID themeFontId; CTFontRef ctFont; if (strcmp(name, SYSTEMFONT_NAME) == 0) { themeFontId = kThemeSystemFont; } else if (strcmp(name, APPLFONT_NAME) == 0) { themeFontId = kThemeApplicationFont; } else if (strcmp(name, MENUITEMFONT_NAME) == 0) { themeFontId = kThemeMenuItemFont; } else { return NULL; } ctFont = CTFontCreateUIFontForLanguage(HIThemeGetUIFontType( themeFontId), 0, NULL); if (ctFont) { fontPtr = (MacFont *) ckalloc(sizeof(MacFont)); InitFont((NSFont*) ctFont, NULL, fontPtr); } return (TkFont *) fontPtr; } /* *--------------------------------------------------------------------------- * |
︙ | ︙ | |||
512 513 514 515 516 517 518 | * font; the existing contents of the font * will be released. If NULL, a new TkFont * structure is allocated. */ Tk_Window tkwin, /* For display where font will be used. */ const TkFontAttributes *faPtr) /* Set of attributes to match. */ { | < < < < | > > | < < | < | < | | > > | | | < < | < | < > | < > | | 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 | * font; the existing contents of the font * will be released. If NULL, a new TkFont * structure is allocated. */ Tk_Window tkwin, /* For display where font will be used. */ const TkFontAttributes *faPtr) /* Set of attributes to match. */ { MacFont *fontPtr; int points = TkFontGetPoints(tkwin, faPtr->size); NSFontTraitMask traits = GetNSFontTraitsFromTkFontAttributes(faPtr); NSInteger weight = (faPtr->weight == TK_FW_BOLD ? 9 : 5); NSFont *nsFont; nsFont = FindNSFont(faPtr->family, traits, weight, points, 0); if (!nsFont) { char *const *aliases = TkFontGetAliasList(faPtr->family); while (aliases && !nsFont) { nsFont = FindNSFont(*aliases++, traits, weight, points, 0); } } if (!nsFont) { nsFont = FindNSFont(faPtr->family, traits, weight, points, 1); } if (!nsFont) { Tcl_Panic("Could not deternmine NSFont from TkFontAttributes"); } if (tkFontPtr == NULL) { fontPtr = (MacFont *) ckalloc(sizeof(MacFont)); } else { fontPtr = (MacFont *) tkFontPtr; TkpDeleteFont(tkFontPtr); } CFRetain(nsFont); /* Always needed to allow unconditional CFRelease below */ InitFont(nsFont, faPtr, fontPtr); return (TkFont *) fontPtr; } /* *--------------------------------------------------------------------------- * |
︙ | ︙ | |||
574 575 576 577 578 579 580 | *--------------------------------------------------------------------------- */ void TkpDeleteFont( TkFont *tkFontPtr) /* Token of font to be deleted. */ { | | > > > | 551 552 553 554 555 556 557 558 559 560 561 562 563 564 565 566 567 568 | *--------------------------------------------------------------------------- */ void TkpDeleteFont( TkFont *tkFontPtr) /* Token of font to be deleted. */ { MacFont *fontPtr = (MacFont *) tkFontPtr; TkMacOSXMakeCollectableAndRelease(fontPtr->nsAttributes); CFRelease(fontPtr->nsFont); /* Either a CTFontRef or a CFRetained NSFont */ } /* *--------------------------------------------------------------------------- * * TkpGetFontFamilies -- * |
︙ | ︙ | |||
600 601 602 603 604 605 606 | */ void TkpGetFontFamilies( Tcl_Interp *interp, /* Interp to hold result. */ Tk_Window tkwin) /* For display to query. */ { | > > > > > > > | | 580 581 582 583 584 585 586 587 588 589 590 591 592 593 594 595 596 597 598 599 600 601 | */ void TkpGetFontFamilies( Tcl_Interp *interp, /* Interp to hold result. */ Tk_Window tkwin) /* For display to query. */ { Tcl_Obj *resultPtr = Tcl_NewListObj(0, NULL); NSArray *list = [[NSFontManager sharedFontManager] availableFontFamilies]; for (NSString *family in list) { Tcl_ListObjAppendElement(NULL, resultPtr, Tcl_NewStringObj([family UTF8String], -1)); } Tcl_SetObjResult(interp, resultPtr); } /* *------------------------------------------------------------------------- * * TkpGetSubFonts -- * |
︙ | ︙ | |||
626 627 628 629 630 631 632 | */ void TkpGetSubFonts( Tcl_Interp *interp, /* Interp to hold result. */ Tk_Font tkfont) /* Font object to query. */ { | | > | > > > | > > | > > > > > > > | 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 | */ void TkpGetSubFonts( Tcl_Interp *interp, /* Interp to hold result. */ Tk_Font tkfont) /* Font object to query. */ { MacFont *fontPtr = (MacFont *) tkfont; Tcl_Obj *resultPtr = Tcl_NewListObj(0, NULL); if (fontPtr->nsFont) { NSArray *list = [[fontPtr->nsFont fontDescriptor] objectForKey:NSFontCascadeListAttribute]; for (NSFontDescriptor *subFontDesc in list) { NSString *family = [subFontDesc objectForKey:NSFontFamilyAttribute]; if (family) { Tcl_ListObjAppendElement(NULL, resultPtr, Tcl_NewStringObj([family UTF8String], -1)); } } } Tcl_SetObjResult(interp, resultPtr); } /* *---------------------------------------------------------------------- * * TkpGetFontAttrsForChar -- * |
︙ | ︙ | |||
656 657 658 659 660 661 662 | void TkpGetFontAttrsForChar( Tk_Window tkwin, /* Window on the font's display */ Tk_Font tkfont, /* Font to query */ Tcl_UniChar c, /* Character of interest */ TkFontAttributes* faPtr) /* Output: Font attributes */ { | | < < < < < < | < < < < | < < < < < < < < | < < < < < < < < | < < < < < | < < < | < < < < < < | < < < < | | < < < | | < | | < | 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 | void TkpGetFontAttrsForChar( Tk_Window tkwin, /* Window on the font's display */ Tk_Font tkfont, /* Font to query */ Tcl_UniChar c, /* Character of interest */ TkFontAttributes* faPtr) /* Output: Font attributes */ { MacFont *fontPtr = (MacFont *) tkfont; NSFont *nsFont = fontPtr->nsFont; *faPtr = fontPtr->font.fa; if (nsFont && ![[nsFont coveredCharacterSet] characterIsMember:c]) { UTF16Char ch = c; nsFont = [nsFont bestMatchingFontForCharacters:&ch length:1 attributes:nil actualCoveredLength:NULL]; if (nsFont) { GetTkFontAttributesForNSFont(nsFont, faPtr); } } } #pragma mark - #pragma mark Measuring and drawing: /* *--------------------------------------------------------------------------- * * Tk_MeasureChars -- * * Determine the number of characters from the string that will fit in |
︙ | ︙ | |||
833 834 835 836 837 838 839 | * last character should not be considered in * context with the rest of the string (used * for breaking lines). */ int *lengthPtr) /* Filled with x-location just after the * terminating character. */ { const MacFont *fontPtr = (const MacFont *) tkfont; | < < < < | < | < < < | < < | < < | < < < | < | < < | < < < < | > < < < | < | < > | < | < < < | | > | < | | | > | | < < < < < < < < < < | < | < | < < < < < | > | < > | > | | < < > > > | > | | < < < < < < | < | > | < | < < < | < < < < < | < < < < < < | < | > | < < < < | < | < | < < | | < < | < < < < < < < | < > | < < < < < | < | < > | < | > < < < < | < < < < | < > | < | | < < < < | > | < | < < < < | < | | > | | < < < | < < | < < < < | < | | < < < | < < > > > > | > > | | < < < < < < | | < < | < < < | < < < | < < < < < < | | < < | < < | | | | > < | | | 784 785 786 787 788 789 790 791 792 793 794 795 796 797 798 799 800 801 802 803 804 805 806 807 808 809 810 811 812 813 814 815 816 817 818 819 820 821 822 823 824 825 826 827 828 829 830 831 832 833 834 835 836 837 838 839 840 841 842 843 844 845 846 847 848 849 850 851 852 853 854 855 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 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 918 919 | * last character should not be considered in * context with the rest of the string (used * for breaking lines). */ int *lengthPtr) /* Filled with x-location just after the * terminating character. */ { const MacFont *fontPtr = (const MacFont *) tkfont; NSString *string; NSAttributedString *attributedString; CTTypesetterRef typesetter; CFIndex start, len; CFRange range = {0, 0}; CTLineRef line; CGFloat offset = 0; CFIndex index; double width; int length, fit; if (rangeStart < 0 || rangeLength <= 0 || rangeStart + rangeLength > numBytes || (maxLength == 0 && !(flags & TK_AT_LEAST_ONE))) { *lengthPtr = 0; return 0; } #if 0 /* Back-compatibility with ATSUI renderer, appears not to be needed */ if (rangeStart == 0 && maxLength == 1 && (flags & TK_ISOLATE_END) && !(flags & TK_AT_LEAST_ONE)) { length = 0; fit = 0; goto done; } #endif if (maxLength > 32767) { maxLength = 32767; } string = [[NSString alloc] initWithBytesNoCopy:(void*)source length:numBytes encoding:NSUTF8StringEncoding freeWhenDone:NO]; if (!string) { length = 0; fit = rangeLength; goto done; } attributedString = [[NSAttributedString alloc] initWithString:string attributes:fontPtr->nsAttributes]; typesetter = CTTypesetterCreateWithAttributedString( (CFAttributedStringRef)attributedString); start = Tcl_NumUtfChars(source, rangeStart); len = Tcl_NumUtfChars(source + rangeStart, rangeLength); if (start > 0) { range.length = start; line = CTTypesetterCreateLine(typesetter, range); offset = CTLineGetTypographicBounds(line, NULL, NULL, NULL); CFRelease(line); } if (maxLength < 0) { index = len; range.length = len; line = CTTypesetterCreateLine(typesetter, range); width = CTLineGetTypographicBounds(line, NULL, NULL, NULL); CFRelease(line); } else { double maxWidth = maxLength + offset; NSCharacterSet *cs; index = start; if (flags & TK_WHOLE_WORDS) { index = CTTypesetterSuggestLineBreak(typesetter, start, maxWidth); if (index <= start && (flags & TK_AT_LEAST_ONE)) { flags &= ~TK_WHOLE_WORDS; } } if (index <= start && !(flags & TK_WHOLE_WORDS)) { index = CTTypesetterSuggestClusterBreak(typesetter, start, maxWidth); } cs = (index < len || (flags & TK_WHOLE_WORDS)) ? whitespaceCharacterSet : lineendingCharacterSet; while (index > start && [cs characterIsMember:[string characterAtIndex:(index - 1)]]) { index--; } if (index <= start && (flags & TK_AT_LEAST_ONE)) { index = start + 1; } if (index > 0) { range.length = index; line = CTTypesetterCreateLine(typesetter, range); width = CTLineGetTypographicBounds(line, NULL, NULL, NULL); CFRelease(line); } else { width = 0; } if (width < maxWidth && (flags & TK_PARTIAL_OK) && index < len) { range.length = ++index; line = CTTypesetterCreateLine(typesetter, range); width = CTLineGetTypographicBounds(line, NULL, NULL, NULL); CFRelease(line); } /* The call to CTTypesetterSuggestClusterBreak above will always return at least one character regardless of whether it exceeded it or not. Clean that up now. */ while (width > maxWidth && !(flags & TK_PARTIAL_OK) && index > start) { range.length = --index; line = CTTypesetterCreateLine(typesetter, range); width = CTLineGetTypographicBounds(line, NULL, NULL, NULL); CFRelease(line); } } CFRelease(typesetter); [attributedString release]; [string release]; length = ceil(width - offset); fit = (Tcl_UtfAtIndex(source, index) - source) - rangeStart; done: #ifdef TK_MAC_DEBUG_FONTS TkMacOSXDbgMsg("measure: source=\"%s\" range=\"%.*s\" maxLength=%d " "flags='%s%s%s%s' -> width=%d bytesFit=%d\n", source, rangeLength, source+rangeStart, maxLength, flags & TK_PARTIAL_OK ? "partialOk " : "", flags & TK_WHOLE_WORDS ? "wholeWords " : "", flags & TK_AT_LEAST_ONE ? "atLeastOne " : "", flags & TK_ISOLATE_END ? "isolateEnd " : "", length, fit); //if (!(rangeLength==1 && rangeStart == 0)) fprintf(stderr, " measure len=%d (max=%d, w=%.0f) from %d (nb=%d): source=\"%s\": index=%d return %d\n",rangeLength,maxLength,width,rangeStart,numBytes, source+rangeStart, index, fit); #endif *lengthPtr = length; return fit; } /* *--------------------------------------------------------------------------- * * Tk_DrawChars -- * |
︙ | ︙ | |||
1129 1130 1131 1132 1133 1134 1135 | * is passed to this function. If they are not * stripped out, they will be displayed as * regular printing characters. */ int numBytes, /* Number of bytes in string. */ int x, int y) /* Coordinates at which to place origin of the * string when drawing. */ { | | | | 945 946 947 948 949 950 951 952 953 954 955 956 957 958 959 960 | * is passed to this function. If they are not * stripped out, they will be displayed as * regular printing characters. */ int numBytes, /* Number of bytes in string. */ int x, int y) /* Coordinates at which to place origin of the * string when drawing. */ { DrawCharsInContext(display, drawable, gc, tkfont, source, numBytes, 0, numBytes, x, y, 0.0); } /* *--------------------------------------------------------------------------- * * TkpDrawCharsInContext -- * |
︙ | ︙ | |||
1174 1175 1176 1177 1178 1179 1180 | int numBytes, /* Number of bytes in string. */ int rangeStart, /* Index of first byte to draw. */ int rangeLength, /* Length of range to draw in bytes. */ int x, int y) /* Coordinates at which to place origin of the * whole (not just the range) string when * drawing. */ { | < | < | < < < < < < | < < < | > > > > > > > > > > > > > > > > > > > > > | < > | < < > > > > > > > > > > > > | < < < > > > > > | > | < < < | < < > > > > > | < | < < | | > > > | > | | < > > > > | < > > > | | > > > | | > | < < < > > > > > > > > | | > > | > > | < < > | < > > > > > | > | > > | < > > | | < > < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < | < < | < < < | < < < < < < < < < | < < < < < < < < < < < < < < < < < < < < < < < < < | < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < | < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < | < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < | < < < < < < < < | < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < | < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < | 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 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 1128 1129 1130 1131 1132 1133 1134 1135 1136 1137 1138 1139 1140 1141 1142 1143 1144 1145 | int numBytes, /* Number of bytes in string. */ int rangeStart, /* Index of first byte to draw. */ int rangeLength, /* Length of range to draw in bytes. */ int x, int y) /* Coordinates at which to place origin of the * whole (not just the range) string when * drawing. */ { DrawCharsInContext(display, drawable, gc, tkfont, source, numBytes, rangeStart, rangeLength, x, y, 0.0); } static void DrawCharsInContext( Display *display, /* Display on which to draw. */ Drawable drawable, /* Window or pixmap in which to draw. */ GC gc, /* Graphics context for drawing characters. */ Tk_Font tkfont, /* Font in which characters will be drawn; must * be the same as font used in GC. */ const char * source, /* UTF-8 string to be displayed. Need not be * '\0' terminated. All Tk meta-characters * (tabs, control characters, and newlines) * should be stripped out of the string that * is passed to this function. If they are not * stripped out, they will be displayed as * regular printing characters. */ int numBytes, /* Number of bytes in string. */ int rangeStart, /* Index of first byte to draw. */ int rangeLength, /* Length of range to draw in bytes. */ int x, int y, /* Coordinates at which to place origin of the * whole (not just the range) string when * drawing. */ double angle) { const MacFont *fontPtr = (const MacFont *) tkfont; NSString *string; NSMutableDictionary *attributes; NSAttributedString *attributedString; CTTypesetterRef typesetter; CFIndex start, len; CTLineRef line; MacDrawable *macWin = (MacDrawable *) drawable; TkMacOSXDrawingContext drawingContext; CGContextRef context; CGColorRef fg; NSFont *nsFont; CGAffineTransform t; int h; if (rangeStart < 0 || rangeLength <= 0 || rangeStart + rangeLength > numBytes || !TkMacOSXSetupDrawingContext(drawable, gc, 1, &drawingContext)) { return; } string = [[NSString alloc] initWithBytesNoCopy:(void*)source length:numBytes encoding:NSUTF8StringEncoding freeWhenDone:NO]; if (!string) { return; } context = drawingContext.context; fg = TkMacOSXCreateCGColor(gc, gc->foreground); attributes = [fontPtr->nsAttributes mutableCopy]; [attributes setObject:(id)fg forKey:(id)kCTForegroundColorAttributeName]; CFRelease(fg); nsFont = [attributes objectForKey:NSFontAttributeName]; [nsFont setInContext:[NSGraphicsContext graphicsContextWithGraphicsPort: context flipped:NO]]; CGContextSetTextMatrix(context, CGAffineTransformIdentity); attributedString = [[NSAttributedString alloc] initWithString:string attributes:attributes]; typesetter = CTTypesetterCreateWithAttributedString( (CFAttributedStringRef)attributedString); x += macWin->xOff; y += macWin->yOff; h = drawingContext.portBounds.size.height; y = h - y; t = CGAffineTransformMake(1.0, 0.0, 0.0, -1.0, 0.0, h); if (angle != 0.0) { t = CGAffineTransformTranslate(CGAffineTransformRotate( CGAffineTransformTranslate(t, x, y), angle*M_PI/180.0), -x, -y); } CGContextConcatCTM(context, t); CGContextSetTextPosition(context, x, y); start = Tcl_NumUtfChars(source, rangeStart); len = Tcl_NumUtfChars(source, rangeStart + rangeLength); if (start > 0) { CGRect clipRect = CGRectInfinite, startBounds; line = CTTypesetterCreateLine(typesetter, CFRangeMake(0, start)); startBounds = CTLineGetImageBounds(line, context); CFRelease(line); clipRect.origin.x = startBounds.origin.x + startBounds.size.width; CGContextClipToRect(context, clipRect); } line = CTTypesetterCreateLine(typesetter, CFRangeMake(0, len)); CTLineDraw(line, context); CFRelease(line); CFRelease(typesetter); [attributedString release]; [string release]; [attributes release]; TkMacOSXRestoreDrawingContext(&drawingContext); } #pragma mark - #pragma mark Accessors: /* *--------------------------------------------------------------------------- * * TkMacOSXNSFontForFont -- * * Return an NSFont for the given Tk_Font. * * Results: * NSFont*. * * Side effects: * None. * *--------------------------------------------------------------------------- */ MODULE_SCOPE NSFont* TkMacOSXNSFontForFont( Tk_Font tkfont) { return tkfont ? ((MacFont *)tkfont)->nsFont : nil; } /* *--------------------------------------------------------------------------- * * TkMacOSXNSFontAttributesForFont -- * * Return an NSDictionary of font attributes for the given Tk_Font. * * Results: * NSFont*. * * Side effects: * None. * *--------------------------------------------------------------------------- */ MODULE_SCOPE NSDictionary* TkMacOSXNSFontAttributesForFont( Tk_Font tkfont) { return tkfont ? ((MacFont *)tkfont)->nsAttributes : nil; } /* *--------------------------------------------------------------------------- * * TkMacOSXIsCharacterMissing -- * |
︙ | ︙ | |||
2411 2412 2413 2414 2415 2416 2417 | */ int TkMacOSXIsCharacterMissing( Tk_Font tkfont, /* The font we are looking in. */ unsigned int searchChar) /* The character we are looking for. */ { | < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < | 1156 1157 1158 1159 1160 1161 1162 1163 1164 1165 1166 1167 1168 1169 1170 1171 | */ int TkMacOSXIsCharacterMissing( Tk_Font tkfont, /* The font we are looking in. */ unsigned int searchChar) /* The character we are looking for. */ { return 0; } /* *---------------------------------------------------------------------- * * TkMacOSXUseAntialiasedText -- * * Enables or disables application-wide use of antialiased text (where |
︙ | ︙ |
Changes to macosx/tkMacOSXFont.h.
1 2 3 4 5 6 7 8 | /* * tkMacOSXFont.h -- * * Contains the Macintosh implementation of the platform-independant * font package interface. * * Copyright (c) 1990-1994 The Regents of the University of California. * Copyright (c) 1994-1997 Sun Microsystems, Inc. | | | < < < < < < < | 1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 | /* * tkMacOSXFont.h -- * * Contains the Macintosh implementation of the platform-independant * font package interface. * * Copyright (c) 1990-1994 The Regents of the University of California. * Copyright (c) 1994-1997 Sun Microsystems, Inc. * Copyright 2001-2009, Apple Inc. * Copyright (c) 2006-2009 Daniel A. Steffen <[email protected]> * * See the file "license.terms" for information on usage and redistribution * of this file, and for a DISCLAIMER OF ALL WARRANTIES. */ #ifndef TKMACOSXFONT_H #define TKMACOSXFONT_H 1 #include "tkFont.h" #ifndef _TKMACINT #include "tkMacOSXInt.h" #endif #endif /*TKMACOSXFONT_H*/ |
Changes to macosx/tkMacOSXHLEvents.c.
1 2 3 4 5 6 7 | /* * tkMacOSXHLEvents.c -- * * Implements high level event support for the Macintosh. Currently, the * only event that really does anything is the Quit event. * * Copyright (c) 1995-1997 Sun Microsystems, Inc. | | | | | 1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 | /* * tkMacOSXHLEvents.c -- * * Implements high level event support for the Macintosh. Currently, the * only event that really does anything is the Quit event. * * Copyright (c) 1995-1997 Sun Microsystems, Inc. * Copyright 2001-2009, Apple Inc. * Copyright (c) 2006-2009 Daniel A. Steffen <[email protected]> * * See the file "license.terms" for information on usage and redistribution * of this file, and for a DISCLAIMER OF ALL WARRANTIES. */ #include "tkMacOSXPrivate.h" /* * This is a Tcl_Event structure that the Quit AppleEvent handler uses to * schedule the ReallyKillMe function. |
︙ | ︙ | |||
27 28 29 30 31 32 33 | } KillEvent; /* * Static functions used only in this file. */ static OSErr QuitHandler(const AppleEvent *event, | | | | | | | | > > > > > > > > > > > > > > > > | 27 28 29 30 31 32 33 34 35 36 37 38 39 40 41 42 43 44 45 46 47 48 49 50 51 52 53 54 55 56 57 58 59 60 61 62 63 64 65 66 67 68 69 70 71 72 | } KillEvent; /* * Static functions used only in this file. */ static OSErr QuitHandler(const AppleEvent *event, AppleEvent *reply, SRefCon handlerRefcon); static OSErr OappHandler(const AppleEvent *event, AppleEvent *reply, SRefCon handlerRefcon); static OSErr RappHandler(const AppleEvent *event, AppleEvent *reply, SRefCon handlerRefcon); static OSErr OdocHandler(const AppleEvent *event, AppleEvent *reply, SRefCon handlerRefcon); static OSErr PrintHandler(const AppleEvent *event, AppleEvent *reply, SRefCon handlerRefcon); static OSErr ScriptHandler(const AppleEvent *event, AppleEvent *reply, SRefCon handlerRefcon); static OSErr PrefsHandler(const AppleEvent *event, AppleEvent *reply, SRefCon handlerRefcon); static int MissedAnyParameters(const AppleEvent *theEvent); static int ReallyKillMe(Tcl_Event *eventPtr, int flags); static OSStatus FSRefToDString(const FSRef *fsref, Tcl_DString *ds); #pragma mark TKApplication(TKHLEvents) @implementation TKApplication(TKHLEvents) - (void)terminate:(id)sender { QuitHandler(NULL, NULL, (SRefCon) _eventInterp); } - (void)preferences:(id)sender { PrefsHandler(NULL, NULL, (SRefCon) _eventInterp); } @end #pragma mark - /* *---------------------------------------------------------------------- * * TkMacOSXInitAppleEvents -- * * Initilize the Apple Events on the Macintosh. This registers the core |
︙ | ︙ | |||
79 80 81 82 83 84 85 | /* * Install event handlers for the core apple events. */ QuitHandlerUPP = NewAEEventHandlerUPP(QuitHandler); ChkErr(AEInstallEventHandler, kCoreEventClass, kAEQuitApplication, | | | | | | | | | 95 96 97 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 129 130 131 132 133 134 | /* * Install event handlers for the core apple events. */ QuitHandlerUPP = NewAEEventHandlerUPP(QuitHandler); ChkErr(AEInstallEventHandler, kCoreEventClass, kAEQuitApplication, QuitHandlerUPP, (SRefCon) interp, false); OappHandlerUPP = NewAEEventHandlerUPP(OappHandler); ChkErr(AEInstallEventHandler, kCoreEventClass, kAEOpenApplication, OappHandlerUPP, (SRefCon) interp, false); RappHandlerUPP = NewAEEventHandlerUPP(RappHandler); ChkErr(AEInstallEventHandler, kCoreEventClass, kAEReopenApplication, RappHandlerUPP, (SRefCon) interp, false); OdocHandlerUPP = NewAEEventHandlerUPP(OdocHandler); ChkErr(AEInstallEventHandler, kCoreEventClass, kAEOpenDocuments, OdocHandlerUPP, (SRefCon) interp, false); PrintHandlerUPP = NewAEEventHandlerUPP(PrintHandler); ChkErr(AEInstallEventHandler, kCoreEventClass, kAEPrintDocuments, PrintHandlerUPP, (SRefCon) interp, false); PrefsHandlerUPP = NewAEEventHandlerUPP(PrefsHandler); ChkErr(AEInstallEventHandler, kCoreEventClass, kAEShowPreferences, PrefsHandlerUPP, (SRefCon) interp, false); if (interp) { ScriptHandlerUPP = NewAEEventHandlerUPP(ScriptHandler); ChkErr(AEInstallEventHandler, kAEMiscStandards, kAEDoScript, ScriptHandlerUPP, (SRefCon) interp, false); } } } /* *---------------------------------------------------------------------- * |
︙ | ︙ | |||
127 128 129 130 131 132 133 | * Depends on the incoming event. * *---------------------------------------------------------------------- */ int TkMacOSXDoHLEvent( | | | | 143 144 145 146 147 148 149 150 151 152 153 154 155 156 157 158 159 | * Depends on the incoming event. * *---------------------------------------------------------------------- */ int TkMacOSXDoHLEvent( void *theEvent) { return AEProcessAppleEvent((EventRecord *)theEvent); } /* *---------------------------------------------------------------------- * * QuitHandler -- * |
︙ | ︙ | |||
152 153 154 155 156 157 158 | *---------------------------------------------------------------------- */ static OSErr QuitHandler( const AppleEvent *event, AppleEvent *reply, | | | 168 169 170 171 172 173 174 175 176 177 178 179 180 181 182 | *---------------------------------------------------------------------- */ static OSErr QuitHandler( const AppleEvent *event, AppleEvent *reply, SRefCon handlerRefcon) { Tcl_Interp *interp = (Tcl_Interp *) handlerRefcon; KillEvent *eventPtr; if (interp) { /* * Call the exit command from the event loop, since you are not |
︙ | ︙ | |||
195 196 197 198 199 200 201 | *---------------------------------------------------------------------- */ static OSErr OappHandler( const AppleEvent *event, AppleEvent *reply, | | | > | 211 212 213 214 215 216 217 218 219 220 221 222 223 224 225 226 227 228 229 230 231 232 233 | *---------------------------------------------------------------------- */ static OSErr OappHandler( const AppleEvent *event, AppleEvent *reply, SRefCon handlerRefcon) { Tcl_CmdInfo dummy; Tcl_Interp *interp = (Tcl_Interp *) handlerRefcon; if (interp && Tcl_GetCommandInfo(interp, "::tk::mac::OpenApplication", &dummy)){ int code = Tcl_GlobalEval(interp, "::tk::mac::OpenApplication"); if (code != TCL_OK) { Tcl_BackgroundError(interp); } } return noErr; } /* |
︙ | ︙ | |||
229 230 231 232 233 234 235 | *---------------------------------------------------------------------- */ static OSErr RappHandler( const AppleEvent *event, AppleEvent *reply, | | | > | 246 247 248 249 250 251 252 253 254 255 256 257 258 259 260 261 262 263 264 265 266 267 268 269 270 | *---------------------------------------------------------------------- */ static OSErr RappHandler( const AppleEvent *event, AppleEvent *reply, SRefCon handlerRefcon) { Tcl_CmdInfo dummy; Tcl_Interp *interp = (Tcl_Interp *) handlerRefcon; ProcessSerialNumber thePSN = {0, kCurrentProcess}; OSStatus err = ChkErr(SetFrontProcess, &thePSN); if (interp && Tcl_GetCommandInfo(interp, "::tk::mac::ReopenApplication", &dummy)) { int code = Tcl_GlobalEval(interp, "::tk::mac::ReopenApplication"); if (code != TCL_OK){ Tcl_BackgroundError(interp); } } return err; } /* |
︙ | ︙ | |||
266 267 268 269 270 271 272 | *---------------------------------------------------------------------- */ static OSErr PrefsHandler( const AppleEvent *event, AppleEvent *reply, | | | > | 284 285 286 287 288 289 290 291 292 293 294 295 296 297 298 299 300 301 302 303 304 305 306 | *---------------------------------------------------------------------- */ static OSErr PrefsHandler( const AppleEvent *event, AppleEvent *reply, SRefCon handlerRefcon) { Tcl_CmdInfo dummy; Tcl_Interp *interp = (Tcl_Interp *) handlerRefcon; if (interp && Tcl_GetCommandInfo(interp, "::tk::mac::ShowPreferences", &dummy)){ int code = Tcl_GlobalEval(interp, "::tk::mac::ShowPreferences"); if (code != TCL_OK) { Tcl_BackgroundError(interp); } } return noErr; } /* |
︙ | ︙ | |||
300 301 302 303 304 305 306 | *---------------------------------------------------------------------- */ static OSErr OdocHandler( const AppleEvent *event, AppleEvent *reply, | | > | 319 320 321 322 323 324 325 326 327 328 329 330 331 332 333 334 335 336 337 338 339 340 341 342 343 344 | *---------------------------------------------------------------------- */ static OSErr OdocHandler( const AppleEvent *event, AppleEvent *reply, SRefCon handlerRefcon) { Tcl_Interp *interp = (Tcl_Interp *) handlerRefcon; AEDescList fileSpecList; FSRef file; DescType type; Size actual; long count, index; AEKeyword keyword; Tcl_DString command, pathName; Tcl_CmdInfo dummy; int code; /* * Don't bother if we don't have an interp or the open document procedure * doesn't exist. */ if (!interp || |
︙ | ︙ | |||
361 362 363 364 365 366 367 | } } /* * Now handle the event by evaluating a script. */ | | | > | 381 382 383 384 385 386 387 388 389 390 391 392 393 394 395 396 397 | } } /* * Now handle the event by evaluating a script. */ code = Tcl_EvalEx(interp, Tcl_DStringValue(&command), Tcl_DStringLength(&command), TCL_EVAL_GLOBAL); if (code != TCL_OK) { Tcl_BackgroundError(interp); } Tcl_DStringFree(&command); return noErr; } /* |
︙ | ︙ | |||
389 390 391 392 393 394 395 | *---------------------------------------------------------------------- */ static OSErr PrintHandler( const AppleEvent * event, AppleEvent * reply, | | > | 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 | *---------------------------------------------------------------------- */ static OSErr PrintHandler( const AppleEvent * event, AppleEvent * reply, SRefCon handlerRefcon) { Tcl_Interp *interp = (Tcl_Interp *) handlerRefcon; AEDescList fileSpecList; FSRef file; DescType type; Size actual; long count, index; AEKeyword keyword; Tcl_DString command, pathName; Tcl_CmdInfo dummy; int code; /* * Don't bother if we don't have an interp or the print document procedure * doesn't exist. */ if (!interp || |
︙ | ︙ | |||
445 446 447 448 449 450 451 | } } /* * Now handle the event by evaluating a script. */ | | | > | 467 468 469 470 471 472 473 474 475 476 477 478 479 480 481 482 483 | } } /* * Now handle the event by evaluating a script. */ code = Tcl_EvalEx(interp, Tcl_DStringValue(&command), Tcl_DStringLength(&command), TCL_EVAL_GLOBAL); if (code != TCL_OK) { Tcl_BackgroundError(interp); } Tcl_DStringFree(&command); return noErr; } /* |
︙ | ︙ | |||
473 474 475 476 477 478 479 | *---------------------------------------------------------------------- */ static OSErr ScriptHandler( const AppleEvent *event, AppleEvent *reply, | | | 496 497 498 499 500 501 502 503 504 505 506 507 508 509 510 | *---------------------------------------------------------------------- */ static OSErr ScriptHandler( const AppleEvent *event, AppleEvent *reply, SRefCon handlerRefcon) { OSStatus theErr; AEDescList theDesc; Size size; int tclErr = -1; Tcl_Interp *interp = (Tcl_Interp *) handlerRefcon; char errString[128]; |
︙ | ︙ | |||
598 599 600 601 602 603 604 605 | ReallyKillMe( Tcl_Event *eventPtr, int flags) { Tcl_Interp *interp = ((KillEvent *) eventPtr)->interp; Tcl_CmdInfo dummy; int quit = Tcl_GetCommandInfo(interp, "::tk::mac::Quit", &dummy); | > | | 621 622 623 624 625 626 627 628 629 630 631 632 633 634 635 636 637 | ReallyKillMe( Tcl_Event *eventPtr, int flags) { Tcl_Interp *interp = ((KillEvent *) eventPtr)->interp; Tcl_CmdInfo dummy; int quit = Tcl_GetCommandInfo(interp, "::tk::mac::Quit", &dummy); int code = Tcl_GlobalEval(interp, quit ? "::tk::mac::Quit" : "exit"); if (code != TCL_OK) { /* * Should be never reached... */ Tcl_BackgroundError(interp); } return 1; |
︙ | ︙ | |||
674 675 676 677 678 679 680 | return err; } /* * Local Variables: * mode: c * c-basic-offset: 4 | | > | 698 699 700 701 702 703 704 705 706 707 708 | return err; } /* * Local Variables: * mode: c * c-basic-offset: 4 * fill-column: 79 * coding: utf-8 * End: */ |
Changes to macosx/tkMacOSXInit.c.
1 2 3 4 5 6 7 | /* * tkMacOSXInit.c -- * * This file contains Mac OS X -specific interpreter initialization * functions. * * Copyright (c) 1995-1997 Sun Microsystems, Inc. | | | | | < < < < < | < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < > > | > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > | 1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 34 35 36 37 38 39 40 41 42 43 44 45 46 47 48 49 50 51 52 53 54 55 56 57 58 59 60 61 62 63 64 65 66 67 68 69 70 71 72 73 74 75 76 77 78 79 80 81 82 83 84 85 86 87 88 89 90 91 92 93 94 95 96 97 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 129 130 131 132 133 134 135 136 137 138 139 140 141 142 143 144 145 146 147 148 149 150 151 152 153 154 155 156 157 158 159 160 161 162 163 164 165 166 167 168 169 170 171 172 173 174 175 176 177 178 179 180 181 182 183 | /* * tkMacOSXInit.c -- * * This file contains Mac OS X -specific interpreter initialization * functions. * * Copyright (c) 1995-1997 Sun Microsystems, Inc. * Copyright 2001-2009, Apple Inc. * Copyright (c) 2005-2009 Daniel A. Steffen <[email protected]> * * See the file "license.terms" for information on usage and redistribution of * this file, and for a DISCLAIMER OF ALL WARRANTIES. */ #include "tkMacOSXPrivate.h" #include "tclInt.h" /* for Tcl_GetStartupScript() & Tcl_SetStartupScript() */ #include <sys/stat.h> #include <sys/utsname.h> #include <dlfcn.h> #include <objc/objc-auto.h> static char tkLibPath[PATH_MAX + 1] = ""; /* * If the App is in an App package, then we want to add the Scripts directory * to the auto_path. */ static char scriptPath[PATH_MAX + 1] = ""; int tkMacOSXGCEnabled = 0; long tkMacOSXMacOSXVersion = 0; #pragma mark TKApplication(TKInit) #if MAC_OS_X_VERSION_MIN_REQUIRED < 1060 #define NSTextInputContextKeyboardSelectionDidChangeNotification @"NSTextInputContextKeyboardSelectionDidChangeNotification" static void keyboardChanged(CFNotificationCenterRef center, void *observer, CFStringRef name, const void *object, CFDictionaryRef userInfo) { [[NSNotificationCenter defaultCenter] postNotificationName:NSTextInputContextKeyboardSelectionDidChangeNotification object:nil userInfo:nil]; } #endif @interface TKApplication(TKKeyboard) - (void)keyboardChanged:(NSNotification *)notification; @end #if MAC_OS_X_VERSION_MAX_ALLOWED >= 1060 #define TKApplication_NSApplicationDelegate <NSApplicationDelegate> #else #define TKApplication_NSApplicationDelegate #endif @interface TKApplication(TKWindowEvent) TKApplication_NSApplicationDelegate - (void)_setupWindowNotifications; @end @interface TKApplication(TKScrlbr) - (void)_setupScrollBarNotifications; @end @interface TKApplication(TKMenus) - (void)_setupMenus; @end @implementation TKApplication @end @implementation TKApplication(TKInit) #ifdef TK_MAC_DEBUG_NOTIFICATIONS - (void)_postedNotification:(NSNotification *)notification { TKLog(@"-[%@(%p) %s] %@", [self class], self, _cmd, notification); } #endif - (void)_setupApplicationNotifications { NSNotificationCenter *nc = [NSNotificationCenter defaultCenter]; #define observe(n, s) [nc addObserver:self selector:@selector(s) name:(n) object:nil] observe(NSApplicationDidBecomeActiveNotification, applicationActivate:); observe(NSApplicationDidResignActiveNotification, applicationDeactivate:); observe(NSApplicationDidUnhideNotification, applicationShowHide:); observe(NSApplicationDidHideNotification, applicationShowHide:); observe(NSApplicationDidChangeScreenParametersNotification, displayChanged:); observe(NSTextInputContextKeyboardSelectionDidChangeNotification, keyboardChanged:); #undef observe #if MAC_OS_X_VERSION_MIN_REQUIRED < 1060 CFNotificationCenterAddObserver(CFNotificationCenterGetDistributedCenter(), NULL, &keyboardChanged, kTISNotifySelectedKeyboardInputSourceChanged, NULL, CFNotificationSuspensionBehaviorCoalesce); #endif } - (void)_setupEventLoop { _running = 1; if (!_appFlags._hasBeenRun) { _appFlags._hasBeenRun = YES; [self finishLaunching]; } [self setWindowsNeedUpdate:YES]; } - (void)_setup:(Tcl_Interp *)interp { _eventInterp = interp; _defaultMainMenu = nil; [self _setupMenus]; [self setDelegate:self]; #ifdef TK_MAC_DEBUG_NOTIFICATIONS [[NSNotificationCenter defaultCenter] addObserver:self selector:@selector(_postedNotification:) name:nil object:nil]; #endif [self _setupWindowNotifications]; [self _setupScrollBarNotifications]; [self _setupApplicationNotifications]; } - (NSString *)tkFrameworkImagePath:(NSString*)image { NSString *path = nil; if (tkLibPath[0] != '\0') { path = [[NSBundle bundleWithPath:[[NSString stringWithUTF8String: tkLibPath] stringByAppendingString:@"/../.."]] pathForImageResource:image]; } if (!path) { const char *tk_library = Tcl_GetVar2(_eventInterp, "tk_library", NULL, TCL_GLOBAL_ONLY); if (tk_library) { NSFileManager *fm = [NSFileManager defaultManager]; path = [[NSString stringWithUTF8String:tk_library] stringByAppendingFormat:@"/%@", image]; if (![fm isReadableFileAtPath:path]) { path = [[NSString stringWithUTF8String:tk_library] stringByAppendingFormat:@"/../macosx/%@", image]; if (![fm isReadableFileAtPath:path]) { path = nil; } } } } #ifdef TK_MAC_DEBUG if (!path && getenv("TK_SRCROOT")) { path = [[NSString stringWithUTF8String:getenv("TK_SRCROOT")] stringByAppendingFormat:@"/macosx/%@", image]; if (![[NSFileManager defaultManager] isReadableFileAtPath:path]) { path = nil; } } #endif return path; } @end #pragma mark - /* *---------------------------------------------------------------------- * * DoWindowActivate -- * * Idle handler that sets the application icon to the generic Tk icon. * * Results: * None. * * Side effects: * None. * *---------------------------------------------------------------------- */ static void SetApplicationIcon( ClientData clientData) { NSString *path = [NSApp tkFrameworkImagePath:@"Tk.icns"]; if (path) { NSImage *image = [[NSImage alloc] initWithContentsOfFile:path]; if (image) { [NSApp setApplicationIconImage:image]; [image release]; } } } /* *---------------------------------------------------------------------- * * TkpInit -- * * Performs Mac-specific interpreter initialization related to the |
︙ | ︙ | |||
108 109 110 111 112 113 114 | *---------------------------------------------------------------------- */ int TkpInit( Tcl_Interp *interp) { | < < < < < < < > | | > > > > | > | | < < < < < < < < < < < < < < | < | | > > | < < < < < < < < < < < < | < < < < < < < | < | | < < < < < | < < < | < < < < < < < < < < < < < < < < < < > | < < < | < < < < < | < < < < > > | < > | 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 224 225 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 256 257 258 259 260 261 262 263 264 265 266 267 268 | *---------------------------------------------------------------------- */ int TkpInit( Tcl_Interp *interp) { static int initialized = 0; /* * Since it is possible for TkInit to be called multiple times and we * don't want to do the following initialization multiple times we protect * against doing it more than once. */ if (!initialized) { int bundledExecutable = 0; CFBundleRef bundleRef; CFURLRef bundleUrl = NULL; struct utsname name; struct stat st; initialized = 1; /* * Initialize/check OS version variable for runtime checks. */ #if MAC_OS_X_VERSION_MIN_REQUIRED < 1050 # error Mac OS X 10.5 required #endif if (!uname(&name)) { tkMacOSXMacOSXVersion = (strtod(name.release, NULL) + 96) * 10; } if (tkMacOSXMacOSXVersion && tkMacOSXMacOSXVersion/10 < MAC_OS_X_VERSION_MIN_REQUIRED/10) { Tcl_Panic("Mac OS X 10.%d or later required !", (MAC_OS_X_VERSION_MIN_REQUIRED/10)-100); } #ifdef TK_FRAMEWORK /* * When Tk is in a framework, force tcl_findLibrary to look in the * framework scripts directory. * FIXME: Should we come up with a more generic way of doing this? */ if (Tcl_MacOSXOpenVersionedBundleResources(interp, "com.tcltk.tklibrary", TK_FRAMEWORK_VERSION, 0, PATH_MAX, tkLibPath) != TCL_OK) { TkMacOSXDbgMsg("Tcl_MacOSXOpenVersionedBundleResources failed"); } #endif static NSAutoreleasePool *pool = nil; if (!pool) { pool = [NSAutoreleasePool new]; } tkMacOSXGCEnabled = ([NSGarbageCollector defaultCollector] != nil); [[NSUserDefaults standardUserDefaults] registerDefaults: [NSDictionary dictionaryWithObjectsAndKeys: [NSNumber numberWithBool:YES], @"_NSCanWrapButtonTitles", [NSNumber numberWithInt:-1], @"NSStringDrawingTypesetterBehavior", nil]]; [TKApplication sharedApplication]; [NSApp _setup:interp]; /* Check whether we are a bundled executable: */ bundleRef = CFBundleGetMainBundle(); if (bundleRef) { bundleUrl = CFBundleCopyBundleURL(bundleRef); } if (bundleUrl) { |
︙ | ︙ | |||
273 274 275 276 277 278 279 | if (url) { bundledExecutable = CFEqual(bundleUrl, url); CFRelease(url); } CFRelease(bundleUrl); } | > | > > | | | < < | | | < < | < < < < > > | < < | < | | < < | < < < | < | < < < < < < < < < < < < < < | < | | | | | | | | | | | | | | | | | | | | | | | | > > > > > > | 289 290 291 292 293 294 295 296 297 298 299 300 301 302 303 304 305 306 307 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 338 339 340 341 342 343 344 345 346 347 348 349 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 | if (url) { bundledExecutable = CFEqual(bundleUrl, url); CFRelease(url); } CFRelease(bundleUrl); } if (!bundledExecutable) { /* * If we are loaded into an executable that is not a bundled * application, the window server does not let us come to the * foreground. For such an executable, notify the window server * that we are now a full GUI application. */ OSStatus err = procNotFound; ProcessSerialNumber psn = { 0, kCurrentProcess }; err = ChkErr(TransformProcessType, &psn, kProcessTransformToForegroundApplication); /* * Set application icon to generic Tk icon, do it at idle time * instead of now to ensure tk_library is setup. */ Tcl_DoWhenIdle(SetApplicationIcon, NULL); } [NSApp _setupEventLoop]; TkMacOSXInitAppleEvents(interp); TkMacOSXUseAntialiasedText(interp, -1); TkMacOSXInitCGDrawing(interp, TRUE, 0); [pool drain]; pool = [NSAutoreleasePool new]; /* * FIXME: Close stdin & stdout for remote debugging otherwise we will * fight with gdb for stdin & stdout */ if (getenv("XCNOSTDIN") != NULL) { close(0); close(1); } /* * If we don't have a TTY and stdin is a special character file of * length 0, (e.g. /dev/null, which is what Finder sets when double * clicking Wish) then use the Tk based console interpreter. */ if (getenv("TK_CONSOLE") || (!isatty(0) && (fstat(0, &st) || (S_ISCHR(st.st_mode) && st.st_blocks == 0)))) { Tk_InitConsoleChannels(interp); Tcl_RegisterChannel(interp, Tcl_GetStdChannel(TCL_STDIN)); Tcl_RegisterChannel(interp, Tcl_GetStdChannel(TCL_STDOUT)); Tcl_RegisterChannel(interp, Tcl_GetStdChannel(TCL_STDERR)); /* * Only show the console if we don't have a startup script * and tcl_interactive hasn't been set already. */ if (Tcl_GetStartupScript(NULL) == NULL) { const char *intvar = Tcl_GetVar(interp, "tcl_interactive", TCL_GLOBAL_ONLY); if (intvar == NULL) { Tcl_SetVar(interp, "tcl_interactive", "1", TCL_GLOBAL_ONLY); } } if (Tk_CreateConsoleWindow(interp) == TCL_ERROR) { return TCL_ERROR; } } } Tk_MacOSXSetupTkNotifier(); if (tkLibPath[0] != '\0') { Tcl_SetVar(interp, "tk_library", tkLibPath, TCL_GLOBAL_ONLY); } if (scriptPath[0] != '\0') { Tcl_SetVar(interp, "auto_path", scriptPath, TCL_GLOBAL_ONLY|TCL_LIST_ELEMENT|TCL_APPEND_VALUE); } Tcl_CreateObjCommand(interp, "::tk::mac::standardAboutPanel", TkMacOSXStandardAboutPanelObjCmd, NULL, NULL); Tcl_CreateObjCommand(interp, "::tk::mac::iconBitmap", TkMacOSXIconBitmapObjCmd, NULL, NULL); return TCL_OK; } /* *---------------------------------------------------------------------- * |
︙ | ︙ | |||
442 443 444 445 446 447 448 | * Generates messages on stdout. * *---------------------------------------------------------------------- */ void TkpDisplayWarning( | | | | 437 438 439 440 441 442 443 444 445 446 447 448 449 450 451 452 | * Generates messages on stdout. * *---------------------------------------------------------------------- */ void TkpDisplayWarning( const char *msg, /* Message to be displayed. */ const char *title) /* Title of warning. */ { Tcl_Channel errChannel = Tcl_GetStdChannel(TCL_STDERR); if (errChannel) { Tcl_WriteChars(errChannel, title, -1); Tcl_WriteChars(errChannel, ": ", 2); Tcl_WriteChars(errChannel, msg, -1); |
︙ | ︙ | |||
513 514 515 516 517 518 519 | /* *---------------------------------------------------------------------- * * TkMacOSXGetNamedSymbol -- * * Dynamically acquire address of a named symbol from a loaded dynamic * library, so that we can use API that may not be available on all OS | | < < | | < < > | < < < < < < < | < < | 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 | /* *---------------------------------------------------------------------- * * TkMacOSXGetNamedSymbol -- * * Dynamically acquire address of a named symbol from a loaded dynamic * library, so that we can use API that may not be available on all OS * versions. * * Results: * Address of given symbol or NULL if unavailable. * * Side effects: * None. * *---------------------------------------------------------------------- */ MODULE_SCOPE void* TkMacOSXGetNamedSymbol( const char* module, const char* symbol) { void *addr = dlsym(RTLD_NEXT, symbol); if (!addr) { (void) dlerror(); /* Clear dlfcn error state */ } return addr; } /* *---------------------------------------------------------------------- * * TkMacOSXGetStringObjFromCFString -- * |
︙ | ︙ |
Changes to macosx/tkMacOSXInt.h.
1 2 3 4 5 6 | /* * tkMacOSXInt.h -- * * Declarations of Macintosh specific shared variables and procedures. * * Copyright (c) 1995-1997 Sun Microsystems, Inc. | | | < < < < > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > < > < | < < < < < < < < < < < < | | 1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 34 35 36 37 38 39 40 41 42 43 44 45 46 47 48 49 50 51 52 53 54 55 56 57 58 59 60 61 62 63 64 65 66 67 68 69 70 71 72 73 74 75 76 77 78 79 80 81 82 83 84 85 86 87 88 89 90 91 92 | /* * tkMacOSXInt.h -- * * Declarations of Macintosh specific shared variables and procedures. * * Copyright (c) 1995-1997 Sun Microsystems, Inc. * Copyright 2001-2009, Apple Inc. * Copyright (c) 2005-2009 Daniel A. Steffen <[email protected]> * * See the file "license.terms" for information on usage and redistribution * of this file, and for a DISCLAIMER OF ALL WARRANTIES. */ #ifndef _TKMACINT #define _TKMACINT #ifndef _TKINT #include "tkInt.h" #endif /* * Include platform specific public interfaces. */ #ifndef _TKMAC #include "tkMacOSX.h" #endif /* * Define compatibility platform types used in the structures below so that * this header can be included without pulling in the platform headers. */ #ifndef _TKMACPRIV # ifndef CGGEOMETRY_H_ # ifndef CGFLOAT_DEFINED # if __LP64__ # define CGFloat double # else # define CGFloat float # endif # endif # define CGSize struct {CGFloat width; CGFloat height;} # endif # ifndef CGCONTEXT_H_ # define CGContextRef void * # endif # ifndef CGCOLOR_H_ # define CGColorRef void * # endif # ifndef __HISHAPE__ # define HIShapeRef void * # endif # ifndef _APPKITDEFINES_H # define NSView void * # endif #endif struct TkWindowPrivate { TkWindow *winPtr; /* Ptr to tk window or NULL if Pixmap */ NSView *view; CGContextRef context; int xOff; /* X offset from toplevel window */ int yOff; /* Y offset from toplevel window */ CGSize size; HIShapeRef visRgn; /* Visible region of window */ HIShapeRef aboveVisRgn; /* Visible region of window & its children */ HIShapeRef drawRgn; /* Clipped drawing region */ int referenceCount; /* Don't delete toplevel until children are * gone. */ struct TkWindowPrivate *toplevel; /* Pointer to the toplevel datastruct. */ int flags; /* Various state see defines below. */ }; typedef struct TkWindowPrivate MacDrawable; /* * Defines use for the flags field of the MacDrawable data structure. */ #define TK_SCROLLBAR_GROW 0x01 #define TK_CLIP_INVALID 0x02 #define TK_HOST_EXISTS 0x04 #define TK_DRAWN_UNDER_MENU 0x08 #define TK_FOCUSED_VIEW 0x10 #define TK_IS_PIXMAP 0x20 #define TK_IS_BW_PIXMAP 0x40 /* * I am reserving TK_EMBEDDED = 0x100 in the MacDrawable flags * This is defined in tk.h. We need to duplicate the TK_EMBEDDED flag in the * TkWindow structure for the window, but in the MacWin. This way we can |
︙ | ︙ | |||
96 97 98 99 100 101 102 103 104 105 106 107 108 109 110 111 112 113 114 115 116 117 | Tk_MacOSXEmbedMakeContainerExistProc *containerExistProc; Tk_MacOSXEmbedGetClipProc *getClipProc; Tk_MacOSXEmbedGetOffsetInParentProc *getOffsetProc; } TkMacOSXEmbedHandler; MODULE_SCOPE TkMacOSXEmbedHandler *tkMacOSXEmbedHandler; /* * Defines used for TkMacOSXInvalidateWindow */ #define TK_WINDOW_ONLY 0 #define TK_PARENT_WINDOW 1 /* * Accessor for the privatePtr flags field for the TK_HOST_EXISTS field */ #define TkMacOSXHostToplevelExists(tkwin) \ (((TkWindow *) (tkwin))->privatePtr->toplevel->flags & TK_HOST_EXISTS) /* | > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > | > < < < < < < < < < < < < < < < < < < < < < < < < < < | 109 110 111 112 113 114 115 116 117 118 119 120 121 122 123 124 125 126 127 128 129 130 131 132 133 134 135 136 137 138 139 140 141 142 143 144 145 146 147 148 149 150 151 152 153 154 155 156 157 158 159 160 161 162 163 164 165 166 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 | Tk_MacOSXEmbedMakeContainerExistProc *containerExistProc; Tk_MacOSXEmbedGetClipProc *getClipProc; Tk_MacOSXEmbedGetOffsetInParentProc *getOffsetProc; } TkMacOSXEmbedHandler; MODULE_SCOPE TkMacOSXEmbedHandler *tkMacOSXEmbedHandler; /* * GC CGColorRef cache for tkMacOSXColor.c */ typedef struct { unsigned long cachedForeground; CGColorRef cachedForegroundColor; unsigned long cachedBackground; CGColorRef cachedBackgroundColor; } TkpGCCache; MODULE_SCOPE TkpGCCache *TkpGetGCCache(GC gc); MODULE_SCOPE void TkpInitGCCache(GC gc); MODULE_SCOPE void TkpFreeGCCache(GC gc); /* * Undef compatibility platform types defined above. */ #ifndef _TKMACPRIV # ifndef CGGEOMETRY_H_ # ifndef CGFLOAT_DEFINED # undef CGFloat # endif # undef CGSize # endif # ifndef CGCONTEXT_H_ # undef CGContextRef # endif # ifndef CGCOLOR_H_ # undef CGColorRef # endif # ifndef __HISHAPE__ # undef HIShapeRef # endif # ifndef _APPKITDEFINES_H # undef NSView # endif #endif /* * Defines used for TkMacOSXInvalidateWindow */ #define TK_WINDOW_ONLY 0 #define TK_PARENT_WINDOW 1 /* * Accessor for the privatePtr flags field for the TK_HOST_EXISTS field */ #define TkMacOSXHostToplevelExists(tkwin) \ (((TkWindow *) (tkwin))->privatePtr->toplevel->flags & TK_HOST_EXISTS) /* * Defines used for the flags argument to TkGenWMConfigureEvent. */ #define TK_LOCATION_CHANGED 1 #define TK_SIZE_CHANGED 2 #define TK_BOTH_CHANGED 3 #define TK_MACOSX_HANDLE_EVENT_IMMEDIATELY 1024 /* * Defines for tkTextDisp.c */ #define TK_LAYOUT_WITH_BASE_CHUNKS 1 #define TK_DRAW_IN_CONTEXT 1 /* * Prototypes of internal procs not in the stubs table. */ MODULE_SCOPE void TkMacOSXDefaultStartupScript(void); #if 0 MODULE_SCOPE int XSetClipRectangles(Display *d, GC gc, int clip_x_origin, |
︙ | ︙ |
Changes to macosx/tkMacOSXKeyEvent.c.
1 2 3 | /* * tkMacOSXKeyEvent.c -- * | | | | | > < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < > < < < < < < < < < < | < < < < < < < < > > | < < < < < < < < < < < < > > | < < | | | < > < | < < < < < < < < | < < < < < < < < > | | < > | < | | | > | < < | < < < < | < < < < < < < < < < < < < > | < < < < > | | < < < < < < < < < > > | < | > > | > > | > > > > > > > > > | | | < | < < < < < | < < < < < < | < < < < | > < < | > > | < | < < | | | < < | | > > | < < | | < | > > | | < < < < < > | < < < | < | < | < < > | < < < < | < | < < < | < < < < < | < < < < < < < < < < < | | > > > > | | | < > > | | < < < < < < < < < | < < < < < < < > > < < < < < < < < < < < | < | < < | | < | | | | | | | | | | | | | | | < < | < < < < < < < < < | < < < < < < < < < < < < < | < < | < < | < < < < < | | > > > > > > > | < < | < < < < < < < < < < < < | < < < < | < < | < < | < < < < < < < | > > | | | < < | > | < | | < < < < < < < < < | < < < < < < < > > | < | > | < < < < < > | < < < < < | > > > | | | | > < < | < < < | < < < < < < < < < < < | | > < < < < | | < < > < < < < < < < < < < > > > > | | | | < < | < | | < < < < < < < < < < > | < < < < < | < | < < | | < < | | < < < > > | < < < < < < | < < < | < | > | | < < < < < < | < | | < < < < | | < > > | < < < | < < < < < < < < < < < < < < | < < > > | < < > > | < < < < < < > > | | | < | < < < > | < < < < < | < < < > | | < < < < | | > > > | < | > > | | | < | > < < < < < < < < < < < < < < < < < < < < < < < < < < < | < < | < < < < < | < < < | < < < < < | < < < > | > > | < < < < | < | | | < | | < < | > > | | | < < < < < < > > | < < < < < < < < < < < < < < < | < < | | < | < < < > | | < | < < < < < | | < | < < > | | < < < < < < < | > | < < < < < < < < < < < < | | > | < < | | < > | < > | > > | < | < | < | | | < | < | < | | < < < < < < < < < < < < < < < < < < | < < < < < < < | < < < < < | > > | < < | < < | < < > | | < < < < | < | < < | | < < < > | > > | | < < < < < < < | < < < < < < | < < < < < < | < < < | | > | < | | < < > < | < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < > | > > > | < < < < < > < | > | | > > | < < | < < < | < < < | < < < < | | < < < | < < | | < < < < < < < < | | < < | 1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 34 35 36 37 38 39 40 41 42 43 44 45 46 47 48 49 50 51 52 53 54 55 56 57 58 59 60 61 62 63 64 65 66 67 68 69 70 71 72 73 74 75 76 77 78 79 80 81 82 83 84 85 86 87 88 89 90 91 92 93 94 95 96 97 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 129 130 131 132 133 134 135 136 137 138 139 140 141 142 143 144 145 146 147 148 149 150 151 152 153 154 155 156 157 158 159 160 161 162 163 164 165 166 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 224 225 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 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 284 285 286 287 288 289 290 291 292 293 294 295 296 297 298 299 300 301 302 303 304 305 306 307 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 338 339 340 341 342 343 344 345 346 347 348 349 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 | /* * tkMacOSXKeyEvent.c -- * * This file implements functions that decode & handle keyboard events on * MacOS X. * * Copyright 2001-2009, Apple Inc. * Copyright (c) 2006-2009 Daniel A. Steffen <[email protected]> * Copyright (c) 2012 Adrian Robert. * * See the file "license.terms" for information on usage and redistribution of * this file, and for a DISCLAIMER OF ALL WARRANTIES. */ #include "tkMacOSXPrivate.h" #include "tkMacOSXEvent.h" /* #ifdef TK_MAC_DEBUG #define TK_MAC_DEBUG_KEYBOARD #endif */ #define NS_KEYLOG 0 static Tk_Window grabWinPtr = NULL; /* Current grab window, NULL if no grab. */ static Tk_Window keyboardGrabWinPtr = NULL; /* Current keyboard grab window. */ static NSModalSession modalSession = NULL; static BOOL processingCompose = NO; static BOOL finishedCompose = NO; static int caret_x = 0, caret_y = 0, caret_height = 0; static void setupXEvent(XEvent *xEvent, NSWindow *w, unsigned int state); static unsigned isFunctionKey(unsigned int code); #pragma mark TKApplication(TKKeyEvent) @implementation TKApplication(TKKeyEvent) - (NSEvent *) tkProcessKeyEvent: (NSEvent *) theEvent { #ifdef TK_MAC_DEBUG_EVENTS TKLog(@"-[%@(%p) %s] %@", [self class], self, _cmd, theEvent); #endif NSWindow* w; NSEventType type = [theEvent type]; NSUInteger modifiers, len = 0; BOOL repeat = NO; unsigned short keyCode; NSString *characters = nil, *charactersIgnoringModifiers = nil; static NSUInteger savedModifiers = 0; static NSMutableArray *nsEvArray; if (nsEvArray == nil) { nsEvArray = [[NSMutableArray alloc] initWithCapacity: 1]; processingCompose = NO; } switch (type) { case NSKeyUp: if (finishedCompose) { // if we were composing, swallow the last release since we already sent finishedCompose = NO; return theEvent; } case NSKeyDown: repeat = [theEvent isARepeat]; characters = [theEvent characters]; charactersIgnoringModifiers = [theEvent charactersIgnoringModifiers]; len = [charactersIgnoringModifiers length]; case NSFlagsChanged: modifiers = [theEvent modifierFlags]; keyCode = [theEvent keyCode]; w = [self windowWithWindowNumber:[theEvent windowNumber]]; #if defined(TK_MAC_DEBUG_EVENTS) || NS_KEYLOG == 1 NSLog(@"-[%@(%p) %s] r=%d mods=%u '%@' '%@' code=%u c=%d %@ %d", [self class], self, _cmd, repeat, modifiers, characters, charactersIgnoringModifiers, keyCode,([charactersIgnoringModifiers length] == 0) ? 0 : [charactersIgnoringModifiers characterAtIndex: 0], w, type); #endif break; default: return theEvent; } if (!processingCompose) { unsigned int state = 0; if (modifiers & NSAlphaShiftKeyMask) { state |= LockMask; } if (modifiers & NSShiftKeyMask) { state |= ShiftMask; } if (modifiers & NSControlKeyMask) { state |= ControlMask; } if (modifiers & NSCommandKeyMask) { state |= Mod1Mask; /* command key */ } if (modifiers & NSAlternateKeyMask) { state |= Mod2Mask; /* option key */ } if (modifiers & NSNumericPadKeyMask) { state |= Mod3Mask; } if (modifiers & NSFunctionKeyMask) { state |= Mod4Mask; } /* * The focus must be in the FrontWindow on the Macintosh. We then query Tk * to determine the exact Tk window that owns the focus. */ TkWindow *winPtr = TkMacOSXGetTkWindow(w); Tk_Window tkwin = (Tk_Window) winPtr; if (!tkwin) { TkMacOSXDbgMsg("tkwin == NULL"); return theEvent; } tkwin = (Tk_Window) winPtr->dispPtr->focusPtr; if (!tkwin) { TkMacOSXDbgMsg("tkwin == NULL"); return theEvent; } /* * If it's a function key, or we have modifiers other than Shift or Alt, * pass it straight to Tk. Otherwise we'll send for input processing. */ int code = (len == 0) ? 0 : [charactersIgnoringModifiers characterAtIndex: 0]; if (type != NSKeyDown || isFunctionKey(code) || (len > 0 && state & (ControlMask | Mod1Mask | Mod3Mask | Mod4Mask))) { XEvent xEvent; setupXEvent(&xEvent, w, state); if (type == NSFlagsChanged) { if (savedModifiers > modifiers) { xEvent.xany.type = KeyRelease; } else { xEvent.xany.type = KeyPress; } /* * Use special '-1' to signify a special keycode to our platform * specific code in tkMacOSXKeyboard.c. This is rather like what * happens on Windows. */ xEvent.xany.send_event = -1; /* * Set keycode (which was zero) to the changed modifier */ xEvent.xkey.keycode = (modifiers ^ savedModifiers); } else { if (type == NSKeyUp || repeat) { xEvent.xany.type = KeyRelease; } else { xEvent.xany.type = KeyPress; } /* For command key, take input manager's word so things like dvorak / qwerty layout work. */ if ((modifiers & NSCommandKeyMask) == NSCommandKeyMask && (modifiers & NSAlternateKeyMask) != NSAlternateKeyMask && len > 0 && !isFunctionKey(code)) { // head off keycode-based translation in tkMacOSXKeyboard.c xEvent.xkey.nbytes = [characters length]; //len } if ([characters length] > 0) { xEvent.xkey.keycode = (keyCode << 16) | (UInt16) [characters characterAtIndex:0]; if (![characters getCString:xEvent.xkey.trans_chars maxLength:XMaxTransChars encoding:NSUTF8StringEncoding]) { /* prevent SF bug 2907388 (crash on some composite chars) */ //PENDING: we might not need this anymore TkMacOSXDbgMsg("characters too long"); return theEvent; } } if (repeat) { Tk_QueueWindowEvent(&xEvent, TCL_QUEUE_TAIL); xEvent.xany.type = KeyPress; xEvent.xany.serial = LastKnownRequestProcessed(Tk_Display(tkwin)); } } Tk_QueueWindowEvent(&xEvent, TCL_QUEUE_TAIL); savedModifiers = modifiers; return theEvent; } /* if send straight to TK */ } /* if not processing compose */ if (type == NSKeyDown) { if (NS_KEYLOG) fprintf (stderr, "keyDown: %s compose sequence.\n", processingCompose == YES ? "Continue" : "Begin"); processingCompose = YES; [nsEvArray addObject: theEvent]; [[w contentView] interpretKeyEvents: nsEvArray]; [nsEvArray removeObject: theEvent]; } savedModifiers = modifiers; return theEvent; } @end @implementation TKContentView(TKKeyEvent) /* <NSTextInput> implementation (called through interpretKeyEvents:]). */ /* <NSTextInput>: called when done composing; NOTE: also called when we delete over working text, followed immed. by doCommandBySelector: deleteBackward: */ - (void)insertText: (id)aString { int i, len = [(NSString *)aString length]; XEvent xEvent; TkWindow *winPtr = TkMacOSXGetTkWindow([self window]); Tk_Window tkwin = (Tk_Window) winPtr; if (NS_KEYLOG) NSLog (@"insertText '%@'\tlen = %d", aString, len); processingCompose = NO; finishedCompose = YES; /* first, clear any working text */ if (_workingText != nil) [self deleteWorkingText]; /* now insert the string as keystrokes */ setupXEvent(&xEvent, [self window], 0); xEvent.xany.type = KeyPress; for (i =0; i<len; i++) { xEvent.xkey.keycode = (UInt16) [aString characterAtIndex: i]; [[aString substringWithRange: NSMakeRange(i,1)] getCString: xEvent.xkey.trans_chars maxLength: XMaxTransChars encoding: NSUTF8StringEncoding]; xEvent.xkey.nbytes = strlen(xEvent.xkey.trans_chars); xEvent.xany.type = KeyPress; Tk_QueueWindowEvent(&xEvent, TCL_QUEUE_TAIL); xEvent.xany.type = KeyRelease; xEvent.xany.serial = LastKnownRequestProcessed(Tk_Display(tkwin)); Tk_QueueWindowEvent(&xEvent, TCL_QUEUE_TAIL); xEvent.xany.serial = LastKnownRequestProcessed(Tk_Display(tkwin)); } } /* <NSTextInput>: inserts display of composing characters */ - (void)setMarkedText: (id)aString selectedRange: (NSRange)selRange { NSString *str = [aString respondsToSelector: @selector (string)] ? [aString string] : aString; if (NS_KEYLOG) NSLog (@"setMarkedText '%@' len =%d range %d from %d", str, [str length], selRange.length, selRange.location); if (_workingText != nil) [self deleteWorkingText]; if ([str length] == 0) return; processingCompose = YES; _workingText = [str copy]; //PENDING: insert workingText underlined } /* delete display of composing characters [not in <NSTextInput>] */ - (void)deleteWorkingText { if (_workingText == nil) return; if (NS_KEYLOG) NSLog(@"deleteWorkingText len = %d\n", [_workingText length]); [_workingText release]; _workingText = nil; processingCompose = NO; //PENDING: delete working text } - (BOOL)hasMarkedText { return _workingText != nil; } - (NSRange)markedRange { NSRange rng = _workingText != nil ? NSMakeRange (0, [_workingText length]) : NSMakeRange (NSNotFound, 0); if (NS_KEYLOG) NSLog (@"markedRange request"); return rng; } - (void)unmarkText { if (NS_KEYLOG) NSLog (@"unmark (accept) text"); [self deleteWorkingText]; processingCompose = NO; } /* used to position char selection windows, etc. */ - (NSRect)firstRectForCharacterRange: (NSRange)theRange { NSRect rect; NSPoint pt; pt.x = caret_x; pt.y = caret_y; pt = [self convertPoint: pt toView: nil]; pt = [[self window] convertBaseToScreen: pt]; pt.y -= caret_height; rect.origin = pt; rect.size.width = caret_height; rect.size.height = caret_height; return rect; } - (NSInteger)conversationIdentifier { return (NSInteger)self; } - (void)doCommandBySelector: (SEL)aSelector { if (NS_KEYLOG) NSLog (@"doCommandBySelector: %@", NSStringFromSelector (aSelector)); processingCompose = NO; if (aSelector == @selector (deleteBackward:)) { /* happens when user backspaces over an ongoing composition: throw a 'delete' into the event queue */ XEvent xEvent; setupXEvent(&xEvent, [self window], 0); xEvent.xany.type = KeyPress; xEvent.xkey.nbytes = 1; xEvent.xkey.keycode = (0x33 << 16) | 0x7F; xEvent.xkey.trans_chars[0] = 0x7F; xEvent.xkey.trans_chars[1] = 0x0; Tk_QueueWindowEvent(&xEvent, TCL_QUEUE_TAIL); } } - (NSArray *)validAttributesForMarkedText { static NSArray *arr = nil; if (arr == nil) arr = [NSArray new]; /* [[NSArray arrayWithObject: NSUnderlineStyleAttributeName] retain]; */ return arr; } - (NSRange)selectedRange { if (NS_KEYLOG) NSLog (@"selectedRange request"); return NSMakeRange (NSNotFound, 0); } - (NSUInteger)characterIndexForPoint: (NSPoint)thePoint { if (NS_KEYLOG) NSLog (@"characterIndexForPoint request"); return 0; } - (NSAttributedString *)attributedSubstringFromRange: (NSRange)theRange { static NSAttributedString *str = nil; if (str == nil) str = [NSAttributedString new]; if (NS_KEYLOG) NSLog (@"attributedSubstringFromRange request"); return str; } /* End <NSTextInput> impl. */ @end /* * Set up basic fields in xevent for keyboard input. */ static void setupXEvent(XEvent *xEvent, NSWindow *w, unsigned int state) { TkWindow *winPtr = TkMacOSXGetTkWindow(w); Tk_Window tkwin = (Tk_Window) winPtr; memset(xEvent, 0, sizeof(XEvent)); xEvent->xany.serial = LastKnownRequestProcessed(Tk_Display(tkwin)); xEvent->xany.send_event = false; xEvent->xany.display = Tk_Display(tkwin); xEvent->xany.window = Tk_WindowId(tkwin); xEvent->xkey.root = XRootWindow(Tk_Display(tkwin), 0); xEvent->xkey.subwindow = None; xEvent->xkey.time = TkpGetMS(); xEvent->xkey.state = state; xEvent->xkey.same_screen = true; xEvent->xkey.trans_chars[0] = 0; xEvent->xkey.nbytes = 0; } #pragma mark - /* *---------------------------------------------------------------------- * * XGrabKeyboard -- * * Simulates a keyboard grab by setting the focus. |
︙ | ︙ | |||
1034 1035 1036 1037 1038 1039 1040 1041 1042 1043 1044 1045 1046 1047 | Window grab_window, Bool owner_events, int pointer_mode, int keyboard_mode, Time time) { keyboardGrabWinPtr = Tk_IdToWindow(display, grab_window); return GrabSuccess; } /* *---------------------------------------------------------------------- * * XUngrabKeyboard -- | > > > > > > > > > > > | 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 | Window grab_window, Bool owner_events, int pointer_mode, int keyboard_mode, Time time) { keyboardGrabWinPtr = Tk_IdToWindow(display, grab_window); if (keyboardGrabWinPtr && grabWinPtr) { NSWindow *w = TkMacOSXDrawableWindow(grab_window); MacDrawable *macWin = (MacDrawable *) grab_window; if (w && macWin->toplevel->winPtr == (TkWindow*) grabWinPtr) { if (modalSession) { Tcl_Panic("XGrabKeyboard: already grabbed"); } modalSession = [NSApp beginModalSessionForWindow:[w retain]]; } } return GrabSuccess; } /* *---------------------------------------------------------------------- * * XUngrabKeyboard -- |
︙ | ︙ | |||
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 | */ void XUngrabKeyboard( Display* display, Time time) { keyboardGrabWinPtr = NULL; } /* *---------------------------------------------------------------------- * * TkMacOSXGetCapture -- * * Results: * Returns the current grab window * Side effects: * None. * *---------------------------------------------------------------------- */ Tk_Window TkMacOSXGetCapture(void) { return grabWinPtr; } /* *---------------------------------------------------------------------- * * TkpSetCapture -- * | > > > > > > > > > > > > > > > > > > > > > > > > > > > > | | | < < < < < < < < < < < < < < < < < < < | | | | > | < | | > | | > > > > | > > > > | > > | | > > > > > | > > | > > | | > > > | | < > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > | > > > | > > > > | | > > | | > | < > > > > > > > | > > > > > > > > > | 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 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 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 703 704 705 706 707 708 709 710 711 712 713 714 715 716 717 718 719 720 721 722 723 | */ void XUngrabKeyboard( Display* display, Time time) { if (modalSession) { NSWindow *w = keyboardGrabWinPtr ? TkMacOSXDrawableWindow( ((TkWindow *) keyboardGrabWinPtr)->window) : nil; [NSApp endModalSession:modalSession]; [w release]; modalSession = NULL; } keyboardGrabWinPtr = NULL; } /* *---------------------------------------------------------------------- * * TkMacOSXGetCapture -- * * Results: * Returns the current grab window * * Side effects: * None. * *---------------------------------------------------------------------- */ Tk_Window TkMacOSXGetCapture(void) { return grabWinPtr; } /* *---------------------------------------------------------------------- * * TkMacOSXGetModalSession -- * * Results: * Returns the current modal session * * Side effects: * None. * *---------------------------------------------------------------------- */ MODULE_SCOPE NSModalSession TkMacOSXGetModalSession(void) { return modalSession; } /* *---------------------------------------------------------------------- * * TkpSetCapture -- * * This function captures the mouse so that all future events will be * reported to this window, even if the mouse is outside the window. If * the specified window is NULL, then the mouse is released. * * Results: * None. * * Side effects: * Sets the capture flag and captures the mouse. * *---------------------------------------------------------------------- */ void TkpSetCapture( TkWindow *winPtr) /* Capture window, or NULL. */ { while (winPtr && !Tk_IsTopLevel(winPtr)) { winPtr = winPtr->parentPtr; } grabWinPtr = (Tk_Window) winPtr; } /* *---------------------------------------------------------------------- * * Tk_SetCaretPos -- * * This enables correct placement of the XIM caret. This is called by * widgets to indicate their cursor placement, and the caret location is * used by TkpGetString to place the XIM caret. * * Results: * None * * Side effects: * None * *---------------------------------------------------------------------- */ void Tk_SetCaretPos( Tk_Window tkwin, int x, int y, int height) { TkCaret *caretPtr = &(((TkWindow *) tkwin)->dispPtr->caret); /* * Prevent processing anything if the values haven't changed. Windows only * has one display, so we can do this with statics. */ if ((caretPtr->winPtr == ((TkWindow *) tkwin)) && (caretPtr->x == x) && (caretPtr->y == y)) { return; } caretPtr->winPtr = ((TkWindow *) tkwin); caretPtr->x = x; caretPtr->y = y; caretPtr->height = height; /* * As in Windows, adjust to the toplevel to get the coords right. */ while (!Tk_IsTopLevel(tkwin)) { x += Tk_X(tkwin); y += Tk_Y(tkwin); tkwin = Tk_Parent(tkwin); if (tkwin == NULL) { return; } } /* But adjust for fact that NS uses flipped view. */ y = Tk_Height(tkwin) - y; caret_x = x; caret_y = y; caret_height = height; } static unsigned convert_ns_to_X_keysym[] = { NSHomeFunctionKey, 0x50, NSLeftArrowFunctionKey, 0x51, NSUpArrowFunctionKey, 0x52, NSRightArrowFunctionKey, 0x53, NSDownArrowFunctionKey, 0x54, NSPageUpFunctionKey, 0x55, NSPageDownFunctionKey, 0x56, NSEndFunctionKey, 0x57, NSBeginFunctionKey, 0x58, NSSelectFunctionKey, 0x60, NSPrintFunctionKey, 0x61, NSExecuteFunctionKey, 0x62, NSInsertFunctionKey, 0x63, NSUndoFunctionKey, 0x65, NSRedoFunctionKey, 0x66, NSMenuFunctionKey, 0x67, NSFindFunctionKey, 0x68, NSHelpFunctionKey, 0x6A, NSBreakFunctionKey, 0x6B, NSF1FunctionKey, 0xBE, NSF2FunctionKey, 0xBF, NSF3FunctionKey, 0xC0, NSF4FunctionKey, 0xC1, NSF5FunctionKey, 0xC2, NSF6FunctionKey, 0xC3, NSF7FunctionKey, 0xC4, NSF8FunctionKey, 0xC5, NSF9FunctionKey, 0xC6, NSF10FunctionKey, 0xC7, NSF11FunctionKey, 0xC8, NSF12FunctionKey, 0xC9, NSF13FunctionKey, 0xCA, NSF14FunctionKey, 0xCB, NSF15FunctionKey, 0xCC, NSF16FunctionKey, 0xCD, NSF17FunctionKey, 0xCE, NSF18FunctionKey, 0xCF, NSF19FunctionKey, 0xD0, NSF20FunctionKey, 0xD1, NSF21FunctionKey, 0xD2, NSF22FunctionKey, 0xD3, NSF23FunctionKey, 0xD4, NSF24FunctionKey, 0xD5, NSBackspaceCharacter, 0x08, /* 8: Not on some KBs. */ NSDeleteCharacter, 0xFF, /* 127: Big 'delete' key upper right. */ NSDeleteFunctionKey, 0x9F, /* 63272: Del forw key off main array. */ NSTabCharacter, 0x09, 0x19, 0x09, /* left tab->regular since pass shift */ NSCarriageReturnCharacter, 0x0D, NSNewlineCharacter, 0x0D, NSEnterCharacter, 0x8D, 0x1B, 0x1B /* escape */ }; static unsigned isFunctionKey(unsigned code) { const unsigned last_keysym = (sizeof (convert_ns_to_X_keysym) / sizeof (convert_ns_to_X_keysym[0])); unsigned keysym; for (keysym = 0; keysym < last_keysym; keysym += 2) if (code == convert_ns_to_X_keysym[keysym]) return 0xFF00 | convert_ns_to_X_keysym[keysym+1]; return 0; } /* * Local Variables: * mode: objc * c-basic-offset: 4 * fill-column: 79 * coding: utf-8 * End: */ |
Changes to macosx/tkMacOSXKeyboard.c.
1 2 3 4 5 6 | /* * tkMacOSXKeyboard.c -- * * Routines to support keyboard events on the Macintosh. * * Copyright (c) 1995-1997 Sun Microsystems, Inc. | | | | | < < | 1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 | /* * tkMacOSXKeyboard.c -- * * Routines to support keyboard events on the Macintosh. * * Copyright (c) 1995-1997 Sun Microsystems, Inc. * Copyright 2001-2009, Apple Inc. * Copyright (c) 2005-2009 Daniel A. Steffen <[email protected]> * * See the file "license.terms" for information on usage and redistribution * of this file, and for a DISCLAIMER OF ALL WARRANTIES. */ #include "tkMacOSXPrivate.h" #include "tkMacOSXEvent.h" /* * A couple of simple definitions to make code a bit more self-explaining. * * For the assignments of Mod1==meta==command and Mod2==alt==option, see also * tkMacOSXMouseEvent.c. */ |
︙ | ︙ | |||
102 103 104 105 106 107 108 109 110 111 112 113 114 115 116 117 118 119 120 121 122 123 | static Tcl_HashTable keycodeTable; /* keyArray hashed by keycode value. */ static Tcl_HashTable vkeyTable; /* virtualkeyArray hashed by virtual * keycode value. */ static int latin1Table[LATIN1_MAX+1]; /* Reverse mapping table for * controls, ASCII and Latin-1. */ /* * Prototypes for static functions used in this file. */ static void InitKeyMaps (void); static void InitLatin1Table(Display *display); static int XKeysymToMacKeycode(Display *display, KeySym keysym); /* *---------------------------------------------------------------------- * * InitKeyMaps -- * * Creates hash tables used by some of the functions in this file. | > > > > > > > > > > > > > > > > > > | 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 129 130 131 132 133 134 135 136 137 138 139 | static Tcl_HashTable keycodeTable; /* keyArray hashed by keycode value. */ static Tcl_HashTable vkeyTable; /* virtualkeyArray hashed by virtual * keycode value. */ static int latin1Table[LATIN1_MAX+1]; /* Reverse mapping table for * controls, ASCII and Latin-1. */ static int keyboardChanged = 1; /* * Prototypes for static functions used in this file. */ static void InitKeyMaps (void); static void InitLatin1Table(Display *display); static int XKeysymToMacKeycode(Display *display, KeySym keysym); static int KeycodeToUnicode(UniChar * uniChars, int maxChars, UInt16 keyaction, UInt32 keycode, UInt32 modifiers, UInt32 * deadKeyStatePtr); #pragma mark TKApplication(TKKeyboard) @implementation TKApplication(TKKeyboard) - (void) keyboardChanged: (NSNotification *) notification { #ifdef TK_MAC_DEBUG_NOTIFICATIONS TKLog(@"-[%@(%p) %s] %@", [self class], self, _cmd, notification); #endif keyboardChanged = 1; } @end #pragma mark - /* *---------------------------------------------------------------------- * * InitKeyMaps -- * * Creates hash tables used by some of the functions in this file. |
︙ | ︙ | |||
140 141 142 143 144 145 146 | { Tcl_HashEntry *hPtr; KeyInfo *kPtr; int dummy; Tcl_InitHashTable(&keycodeTable, TCL_ONE_WORD_KEYS); for (kPtr = keyArray; kPtr->keycode != 0; kPtr++) { | | | | | | | < < < < < < < < < < | | | | < < < | | | | | | | | | | | | < | | | | | | | | | | | | | | | | | > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > | 156 157 158 159 160 161 162 163 164 165 166 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 224 225 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 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 284 285 286 287 288 289 290 291 292 293 294 295 296 297 298 299 300 301 302 303 304 305 306 307 308 309 310 311 312 313 314 315 316 317 318 319 320 321 322 323 324 325 326 327 | { Tcl_HashEntry *hPtr; KeyInfo *kPtr; int dummy; Tcl_InitHashTable(&keycodeTable, TCL_ONE_WORD_KEYS); for (kPtr = keyArray; kPtr->keycode != 0; kPtr++) { hPtr = Tcl_CreateHashEntry(&keycodeTable, INT2PTR(kPtr->keycode), &dummy); Tcl_SetHashValue(hPtr, kPtr->keysym); } Tcl_InitHashTable(&vkeyTable, TCL_ONE_WORD_KEYS); for (kPtr = virtualkeyArray; kPtr->keycode != 0; kPtr++) { hPtr = Tcl_CreateHashEntry(&vkeyTable, INT2PTR(kPtr->keycode), &dummy); Tcl_SetHashValue(hPtr, kPtr->keysym); } initialized = 1; } /* *---------------------------------------------------------------------- * * InitLatin1Table -- * * Creates a simple table to be used for mapping from keysyms to keycodes. * Always needs to be called before using latin1Table, because the * keyboard layout may have changed, and than the table must be * re-computed. * * Results: * None. * * Side effects: * Sets the global latin1Table. * *---------------------------------------------------------------------- */ static void InitLatin1Table( Display *display) { int keycode; KeySym keysym; int state; int modifiers; memset(latin1Table, 0, sizeof(latin1Table)); /* * In the common X11 implementations, a keymap has four columns * "plain", "Shift", "Mode_switch" and "Mode_switch + Shift". We don't * use "Mode_switch", but we use "Option" instead. (This is similar to * Apple's X11 implementation, where "Mode_switch" is used as an alias * for "Option".) * * So here we go through all 4 columns of the keymap and find all * Latin-1 compatible keycodes. We go through the columns back-to-front * from the more exotic columns to the more simple, so that simple * keycode-modifier combinations are preferred in the resulting table. */ for (state = 3; state >= 0; state--) { modifiers = 0; if (state & 1) { modifiers |= shiftKey; } if (state & 2) { modifiers |= optionKey; } for (keycode = 0; keycode <= MAC_KEYCODE_MAX; keycode++) { keysym = XKeycodeToKeysym(display,keycode<<16,state); if (keysym <= LATIN1_MAX) { latin1Table[keysym] = keycode | modifiers; } } } } /* *---------------------------------------------------------------------- * * KeycodeToUnicode -- * * Given MacOS key event data this function generates the Unicode * characters. It does this using OS resources and APIs. * * The parameter deadKeyStatePtr can be NULL, if no deadkey handling is * needed. * * This function is called from XKeycodeToKeysym() in tkMacOSKeyboard.c. * * Results: * The number of characters generated if any, 0 if we are waiting for * another byte of a dead-key sequence. Fills in the uniChars array with a * Unicode string. * * Side Effects: * None * *---------------------------------------------------------------------- */ static int KeycodeToUnicode( UniChar *uniChars, int maxChars, UInt16 keyaction, UInt32 keycode, UInt32 modifiers, UInt32 *deadKeyStatePtr) { static const void *uchr = NULL; static UInt32 keyboardType = 0; UniCharCount actuallength = 0; if (keyboardChanged) { TISInputSourceRef currentKeyboardLayout = TISCopyCurrentKeyboardLayoutInputSource(); if (currentKeyboardLayout) { CFDataRef keyLayoutData = (CFDataRef) TISGetInputSourceProperty( currentKeyboardLayout, kTISPropertyUnicodeKeyLayoutData); if (keyLayoutData) { uchr = CFDataGetBytePtr(keyLayoutData); keyboardType = LMGetKbdType(); } CFRelease(currentKeyboardLayout); } keyboardChanged = 0; } if (uchr) { OptionBits options = 0; UInt32 dummyState; OSStatus err; keycode &= 0xFF; modifiers = (modifiers >> 8) & 0xFF; if (!deadKeyStatePtr) { options = kUCKeyTranslateNoDeadKeysMask; dummyState = 0; deadKeyStatePtr = &dummyState; } err = ChkErr(UCKeyTranslate, uchr, keycode, keyaction, modifiers, keyboardType, options, deadKeyStatePtr, maxChars, &actuallength, uniChars); if (!actuallength && *deadKeyStatePtr) { /* * More data later */ return 0; } *deadKeyStatePtr = 0; if (err != noErr) { actuallength = 0; } } return actuallength; } /* *---------------------------------------------------------------------- * * XKeycodeToKeysym -- * |
︙ | ︙ | |||
263 264 265 266 267 268 269 | (void) display; /*unused*/ if (!initialized) { InitKeyMaps(); } /* | | | | | | | | | < | | | | 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 | (void) display; /*unused*/ if (!initialized) { InitKeyMaps(); } /* * When determining what keysym to produce we first check to see if the key * is a function key. We then check to see if the character is another * non-printing key. Finally, we return the key syms for all ASCII and * Latin-1 chars. */ newKeycode = keycode >> 16; if ((keycode & 0xFFFF) >= 0xF700) { /* NSEvent.h function key unicodes */ hPtr = Tcl_FindHashEntry(&vkeyTable, INT2PTR(newKeycode)); if (hPtr != NULL) { return (KeySym) Tcl_GetHashValue(hPtr); } } hPtr = Tcl_FindHashEntry(&keycodeTable, INT2PTR(newKeycode)); if (hPtr != NULL) { return (KeySym) Tcl_GetHashValue(hPtr); } /* * Add in the Mac modifier flags for shift and option. */ if (index & 1) { newKeycode |= shiftKey; } if (index & 2) { newKeycode |= optionKey; } newChar = 0; KeycodeToUnicode(&newChar, 1, kUCKeyActionDown, newKeycode & 0x00FF, newKeycode & 0xFF00, NULL); /* * X11 keysyms are identical to Unicode for ASCII and Latin-1. Give up for * other characters for now. */ if ((newChar >= XK_space) && (newChar <= LATIN1_MAX)) { return newChar; } return NoSymbol; |
︙ | ︙ | |||
357 358 359 360 361 362 363 | * Allocates a new modifier map data structure. * *---------------------------------------------------------------------- */ XModifierKeymap * XGetModifierMapping( | | | | | | 443 444 445 446 447 448 449 450 451 452 453 454 455 456 457 458 459 460 461 462 463 464 465 | * Allocates a new modifier map data structure. * *---------------------------------------------------------------------- */ XModifierKeymap * XGetModifierMapping( Display *display) { XModifierKeymap *modmap; (void) display; /*unused*/ /* * MacOSX doesn't use the key codes for the modifiers for anything, and we * don't generate them either. So there is no modifier map. */ modmap = (XModifierKeymap *) ckalloc(sizeof(XModifierKeymap)); modmap->max_keypermod = 0; modmap->modifiermap = NULL; return modmap; } |
︙ | ︙ | |||
407 408 409 410 411 412 413 | /* *---------------------------------------------------------------------- * * XKeysymToString, XStringToKeysym -- * * These X window functions map keysyms to strings & strings to keysyms. | | | | | 493 494 495 496 497 498 499 500 501 502 503 504 505 506 507 508 509 | /* *---------------------------------------------------------------------- * * XKeysymToString, XStringToKeysym -- * * These X window functions map keysyms to strings & strings to keysyms. * However, Tk already does this for the most common keysyms. Therefore, * these functions only need to support keysyms that will be specific to * the Macintosh. Currently, there are none. * * Results: * None. * * Side effects: * None. * |
︙ | ︙ | |||
439 440 441 442 443 444 445 | } /* *---------------------------------------------------------------------- * * XKeysymToMacKeycode -- * | | | | > > | > > | < | | | | | < < | | | | | | | | | | | | | < | | < | | | | 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 587 588 589 590 591 592 593 594 595 596 597 598 599 600 601 602 603 604 | } /* *---------------------------------------------------------------------- * * XKeysymToMacKeycode -- * * An internal function like XKeysymToKeycode but only generating the Mac * specific keycode plus the modifiers Shift and Option. * * Results: * A Mac keycode with the actual keycode in the low byte and Mac-style * modifier bits in the high byte. * * Side effects: * None. * *---------------------------------------------------------------------- */ static int XKeysymToMacKeycode( Display *display, KeySym keysym) { KeyInfo *kPtr; if (keysym <= LATIN1_MAX) { /* * Handle keysyms in the Latin-1 range where keysym and Unicode * character code point are the same. */ if (keyboardChanged) { InitLatin1Table(display); keyboardChanged = 0; } return latin1Table[keysym]; } /* * Handle special keys from our exception tables. Don't mind if this is * slow, neither the test suite nor [event generate] need to be optimized * (we hope). */ for (kPtr = keyArray; kPtr->keycode != 0; kPtr++) { if (kPtr->keysym == keysym) { return kPtr->keycode; } } for (kPtr = virtualkeyArray; kPtr->keycode != 0; kPtr++) { if (kPtr->keysym == keysym) { return kPtr->keycode; } } /* * For other keysyms (not Latin-1 and not special keys), we'd need a * generic keysym-to-unicode table. We don't have that, so we give up here. */ return 0; } /* *---------------------------------------------------------------------- * * XKeysymToKeycode -- * * The function XKeysymToKeycode takes an X11 keysym and converts it into * a Mac keycode. It is in the stubs table for compatibility but not used * anywhere in the core. * * Results: * A 32 bit keycode with the the mac keycode (without modifiers) in the * higher 16 bits of the keycode and the ASCII or Latin-1 code in the * lower 8 bits of the keycode. * * Side effects: |
︙ | ︙ | |||
541 542 543 544 545 546 547 | } else { result = 0x00FF & keysym; } result |= (macKeycode & MAC_KEYCODE_MASK) << 16; return result; } | < < < < < < < < < < < < < < < < < < < < < < < < < < | | | 626 627 628 629 630 631 632 633 634 635 636 637 638 639 640 641 642 643 644 645 646 647 648 649 | } else { result = 0x00FF & keysym; } result |= (macKeycode & MAC_KEYCODE_MASK) << 16; return result; } /* *---------------------------------------------------------------------- * * TkpSetKeycodeAndState -- * * The function TkpSetKeycodeAndState takes a keysym and fills in the * appropriate members of an XEvent. It is similar to XKeysymToKeycode, * but it also sets the modifier mask in the XEvent. It is used by [event * generate] and it is in the stubs table. * * Results: * Fills an XEvent, sets the member xkey.keycode with a keycode * formatted the same as XKeysymToKeycode and the member xkey.state with * the modifiers implied by the keysym. Also fills in xkey.trans_chars, * so that the actual characters can be retrieved later. * |
︙ | ︙ | |||
621 622 623 624 625 626 627 | eventPtr->xkey.state |= ShiftMask; } if (optionKey & macKeycode) { eventPtr->xkey.state |= OPTION_MASK; } if (keysym <= LATIN1_MAX) { | | | | 680 681 682 683 684 685 686 687 688 689 690 691 692 693 694 695 | eventPtr->xkey.state |= ShiftMask; } if (optionKey & macKeycode) { eventPtr->xkey.state |= OPTION_MASK; } if (keysym <= LATIN1_MAX) { int done = Tcl_UniCharToUtf(keysym, eventPtr->xkey.trans_chars); eventPtr->xkey.trans_chars[done] = 0; } else { eventPtr->xkey.trans_chars[0] = 0; } } } |
︙ | ︙ | |||
672 673 674 675 676 677 678 | /* * Handle pure modifier keys specially. We use -1 as a signal for * this. */ if (eventPtr->xany.send_event == -1) { int modifier = eventPtr->xkey.keycode; | > | | | | | | | > > < > > > > > > | | | | | | | < | | | | 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 773 774 775 776 777 778 779 780 781 782 783 784 785 786 787 788 789 790 791 792 793 794 795 796 797 798 799 800 801 802 803 804 805 806 807 808 809 810 811 812 813 814 815 816 817 818 819 820 821 822 823 824 825 826 | /* * Handle pure modifier keys specially. We use -1 as a signal for * this. */ if (eventPtr->xany.send_event == -1) { int modifier = eventPtr->xkey.keycode; if (modifier == NSCommandKeyMask) { return XK_Meta_L; } else if (modifier == NSShiftKeyMask) { return XK_Shift_L; } else if (modifier == NSAlphaShiftKeyMask) { return XK_Caps_Lock; } else if (modifier == NSAlternateKeyMask) { return XK_Alt_L; } else if (modifier == NSControlKeyMask) { return XK_Control_L; } else if (modifier == NSNumericPadKeyMask) { return XK_Num_Lock; } else if (modifier == NSFunctionKeyMask) { return XK_Super_L; /* } else if (modifier == rightShiftKey) { return XK_Shift_R; } else if (modifier == rightOptionKey) { return XK_Alt_R; } else if (modifier == rightControlKey) { return XK_Control_R; */ } else { /* * If we get here, we probably need to implement something new. */ return NoSymbol; } } /* If nbytes has been set, it's not a function key, but a regular key that has been translated in tkMacOSXKeyEvent.c; just use that. */ if (eventPtr->xkey.nbytes) { return eventPtr->xkey.keycode & 0xFFFF; } /* * Figure out which of the four slots in the keymap vector to use for this * key. Refer to Xlib documentation for more info on how this computation * works. (Note: We use "Option" in keymap columns 2 and 3 where other * implementations have "Mode_switch".) */ index = 0; /* * We want Option key combinations to use their base chars as keysyms, so * we ignore the option modifier here. */ #if 0 if (eventPtr->xkey.state & OPTION_MASK) { index |= 2; } #endif if ((eventPtr->xkey.state & ShiftMask) || (/* (dispPtr->lockUsage != LU_IGNORE) && */ (eventPtr->xkey.state & LockMask))) { index |= 1; } /* * First try of the actual translation. */ sym = XKeycodeToKeysym(dispPtr->display, eventPtr->xkey.keycode, index); /* * Special handling: If the key was shifted because of Lock, but lock is * only caps lock, not shift lock, and the shifted keysym isn't upper-case * alphabetic, then switch back to the unshifted keysym. */ if ((index & 1) && !(eventPtr->xkey.state & ShiftMask) /*&& (dispPtr->lockUsage == LU_CAPS)*/ ) { /* * FIXME: Keysyms are only identical to Unicode for ASCII and Latin-1, * so we can't use Tcl_UniCharIsUpper() for keysyms outside that range. * This may be a serious problem here. */ if ((sym == NoSymbol) || (sym > LATIN1_MAX) || !Tcl_UniCharIsUpper(sym)) { index &= ~1; sym = XKeycodeToKeysym(dispPtr->display, eventPtr->xkey.keycode, index); |
︙ | ︙ | |||
774 775 776 777 778 779 780 | } /* *-------------------------------------------------------------- * * TkpInitKeymapInfo -- * | | | | | | | 840 841 842 843 844 845 846 847 848 849 850 851 852 853 854 855 856 857 858 859 860 861 862 863 864 865 866 867 868 869 870 871 872 873 874 875 876 877 | } /* *-------------------------------------------------------------- * * TkpInitKeymapInfo -- * * This procedure is invoked to scan keymap information to recompute stuff * that's important for binding, such as the modifier key (if any) that * corresponds to the "Mode_switch" keysym. * * Results: * None. * * Side effects: * Keymap-related information in dispPtr is updated. * *-------------------------------------------------------------- */ void TkpInitKeymapInfo( TkDisplay *dispPtr) /* Display for which to recompute keymap * information. */ { dispPtr->bindInfoStale = 0; /* * Behaviours that are variable on X11 are defined constant on MacOSX. * lockUsage is only used above in TkpGetKeySym(), nowhere else currently. * There is no offical "Mode_switch" key. */ dispPtr->lockUsage = LU_CAPS; dispPtr->modeModMask = 0; #if 0 /* |
︙ | ︙ | |||
821 822 823 824 825 826 827 | #else dispPtr->altModMask = 0; dispPtr->metaModMask = 0; #endif /* * MacOSX doesn't use the keycodes for the modifiers for anything, and we | | | | | > > > > > > > > > | 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 | #else dispPtr->altModMask = 0; dispPtr->metaModMask = 0; #endif /* * MacOSX doesn't use the keycodes for the modifiers for anything, and we * don't generate them either (the keycodes actually given in the simulated * modifier events are bogus). So there is no modifier map. If we ever want * to simulate real modifier keycodes, the list will be constant in the * Carbon implementation. */ if (dispPtr->modKeyCodes != NULL) { ckfree((char *) dispPtr->modKeyCodes); } dispPtr->numModKeyCodes = 0; dispPtr->modKeyCodes = NULL; } /* * Local Variables: * mode: objc * c-basic-offset: 4 * fill-column: 79 * coding: utf-8 * End: */ |
Changes to macosx/tkMacOSXMenu.c.
1 2 3 4 5 6 | /* * tkMacOSXMenu.c -- * * This module implements the Mac-platform specific features of menus. * * Copyright (c) 1996-1997 by Sun Microsystems, Inc. | | | > | > | > > < < | < < < > > | < > | < > > | | | < < < < < < > < < < < < < < < < < < < | | < < > > > > > | < | > > > > > > | < | > | < | < < < | > > > | | | | > | | < | < | > > > > > > > > > > | < | < < < < < < < < < < < < < < < < < | < < < | < < < < < < < < < < < < < < < < < < < < < < < | < < < < < < < < | < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < | | | > > > > | > > > | > > | | > > > > > > > | < < | < > | | < > | < > | < > | | | | | < > | | < < < | < | | | | < > | > | < < | > | | | | | | < < | < > | > | < < < < < > | < | | > > > > > | > | > > | > | > > > > | > | > > > | > > > > > | < > > > > | > | | < > | > > > | > > | > | | < > | > | < < | < < < > | | < > > | < < | > > | > | < > > > > > > > | < < | < < > > > > | < < > > > > < < < < | | | < < | | > > | | | < < < < < < < < < > | > > > > | | | | | | | | | | | > > > | > | > > > | > > > > | < < | < > | | < < | < | < > | > | | > | < > > | < < < < > > > > | > | < | | < < | < < | > | | > > | < < | < > | | < < < < | > | | < > | | > | > > | | > > > > | | < > | > | > | > > > | > > > > > > > > > > > > | < > | < > > | > > | | < < > | < < > > | < < | < | < < < | < < < < > | | < < > > < > | < | | < > | > > > > > > > > | | < < < < < < < < > > > | > > > | > > > | > > | > | | > > > | | < < < < < < < | < < < < < < < | < | < < | < < < < < < < < < < < < < < < | < < < < < < < < < | < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < | < | < < < < < < < < < < < < < < < < | < < < < < < < < | < < < < | < < < < < < < < < < < < < < < | < < < < < | < < < < < | < < | < < < > | | | < < < < < < < < < < | < < < < < < < < < < < < < < < < < < < < < < < < < | < | < < < < < < | < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < | 1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 34 35 36 37 38 39 40 41 42 43 44 45 46 47 48 49 50 51 52 53 54 55 56 57 58 59 60 61 62 63 64 65 66 67 68 69 70 71 72 73 74 75 76 77 78 79 80 81 82 83 84 85 86 87 88 89 90 91 92 93 94 95 96 97 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 129 130 131 132 133 134 135 136 137 138 139 140 141 142 143 144 145 146 147 148 149 150 151 152 153 154 155 156 157 158 159 160 161 162 163 164 165 166 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 224 225 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 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 284 285 286 287 288 289 290 291 292 293 294 295 296 297 298 299 300 301 302 303 304 305 306 307 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 338 339 340 341 342 343 344 345 346 347 348 349 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 | /* * tkMacOSXMenu.c -- * * This module implements the Mac-platform specific features of menus. * * Copyright (c) 1996-1997 by Sun Microsystems, Inc. * Copyright 2001-2009, Apple Inc. * Copyright (c) 2005-2009 Daniel A. Steffen <[email protected]> * Copyright (c) 2012 Adrian Robert. * * See the file "license.terms" for information on usage and redistribution * of this file, and for a DISCLAIMER OF ALL WARRANTIES. */ #include "tkMacOSXPrivate.h" #include "tkMenubutton.h" #include "tkMenu.h" #include "tkColor.h" #include "tkFont.h" #include "tkMacOSXWm.h" #include "tkMacOSXDebug.h" /* #ifdef TK_MAC_DEBUG #define TK_MAC_DEBUG_MENUS #endif */ #define ENTRY_HELP_MENU ENTRY_PLATFORM_FLAG1 #define ENTRY_APPLE_MENU ENTRY_PLATFORM_FLAG2 #define ENTRY_WINDOWS_MENU ENTRY_PLATFORM_FLAG3 #define sl(s) ((int) (sizeof(s "") - 1)) #define SPECIALMENU(n, f) {.name = "." #n, .len = sl(#n) + 1, \ .flag = ENTRY_##f##_MENU } static const struct { const char *name; const size_t len; const int flag; } specialMenus[] = { SPECIALMENU(help, HELP), SPECIALMENU(apple, APPLE), SPECIALMENU(window, WINDOWS), {NULL} }; #undef SPECIALMENU #define MODIFIER(n, f) {.name = #n, .len = sl(#n), .mask = f } static const struct { const char *name; const size_t len; const NSUInteger mask; } modifiers[] = { MODIFIER(Control, NSControlKeyMask), MODIFIER(Ctrl, NSControlKeyMask), MODIFIER(Option, NSAlternateKeyMask), MODIFIER(Opt, NSAlternateKeyMask), MODIFIER(Alt, NSAlternateKeyMask), MODIFIER(Shift, NSShiftKeyMask), MODIFIER(Command, NSCommandKeyMask), MODIFIER(Cmd, NSCommandKeyMask), MODIFIER(Meta, NSCommandKeyMask), {NULL} }; #undef MODIFIER #define ACCEL(n, c) {.name = #n, .len = sl(#n), .ch = c } static const struct { const char *name; const size_t len; const UniChar ch; } specialAccelerators[] = { ACCEL(PageUp, NSPageUpFunctionKey), ACCEL(PageDown, NSPageDownFunctionKey), ACCEL(Left, NSLeftArrowFunctionKey), ACCEL(Right, NSRightArrowFunctionKey), ACCEL(Up, NSUpArrowFunctionKey), ACCEL(Down, NSDownArrowFunctionKey), ACCEL(Escape, 0x001b), ACCEL(Clear, NSClearDisplayFunctionKey), ACCEL(Enter, NSEnterCharacter), ACCEL(Backspace, NSBackspaceCharacter), ACCEL(Space, ' '), ACCEL(Tab, NSTabCharacter), ACCEL(BackTab, NSBackTabCharacter), ACCEL(Delete, NSDeleteCharacter), ACCEL(Home, NSHomeFunctionKey), ACCEL(End, NSEndFunctionKey), ACCEL(Return, NSCarriageReturnCharacter), ACCEL(Help, NSHelpFunctionKey), ACCEL(Power, 0x233d), ACCEL(Eject, 0xf804), {NULL} }; #undef ACCEL #undef sl static int gNoTkMenus = 0; /* This is used by Tk_MacOSXTurnOffMenus as * the flag that Tk is not to draw any * menus. */ static int inPostMenu = 0; static unsigned long defaultBg = 0, defaultFg = 0; static SInt32 menuMarkColumnWidth = 0, menuIconTrailingEdgeMargin = 0; static SInt32 menuTextLeadingEdgeMargin = 0, menuTextTrailingEdgeMargin = 0; static SInt16 menuItemExtraHeight = 0, menuItemExtraWidth = 0; static SInt16 menuSeparatorHeight = 0; static void CheckForSpecialMenu(TkMenu *menuPtr); static NSString *ParseAccelerator(const char *accel, NSUInteger *maskPtr); static int GenerateMenuSelectEvent(TKMenu *menu, NSMenuItem *menuItem); static void MenuSelectEvent(TkMenu *menuPtr); static void RecursivelyClearActiveMenu(TkMenu *menuPtr); static int ModifierCharWidth(Tk_Font tkfont); #pragma mark TKMenu @interface TKMenu(TKMenuPrivate) - (id) initWithTkMenu: (TkMenu *) tkMenu; - (TkMenu *) tkMenu; - (int) tkIndexOfItem: (NSMenuItem *) menuItem; - (void) insertItem: (NSMenuItem *) newItem atTkIndex: (NSInteger) index; @end #if MAC_OS_X_VERSION_MAX_ALLOWED >= 1060 #define TKMenu_NSMenuDelegate <NSMenuDelegate> #else #define TKMenu_NSMenuDelegate #endif @interface TKMenu(TKMenuDelegate) TKMenu_NSMenuDelegate @end @implementation TKMenu - (void) setSpecial: (NSUInteger) special { NSAssert(!_tkSpecial, @"Cannot change specialness of a special menu"); _tkSpecial = special; } - (BOOL) isSpecial: (NSUInteger) special { return (_tkSpecial == special); } @end @implementation TKMenu(TKMenuPrivate) - (id) initWithTitle: (NSString *) aTitle { self = [super initWithTitle:aTitle]; if (self) { _tkMenu = NULL; _tkOffset = 0; _tkItemCount = 0; _tkSpecial = 0; [self setDelegate:self]; } return self; } - (id) initWithTkMenu: (TkMenu *) tkMenu { NSString *title = [[NSString alloc] initWithUTF8String: Tk_PathName(tkMenu->tkwin)]; self = [self initWithTitle:title]; [title release]; if (self) { _tkMenu = tkMenu; } return self; } - (id) copyWithZone: (NSZone *) zone { TKMenu *copy = [super copyWithZone:zone]; NSAssert(_tkMenu == nil, @"Cannot copy tkMenu"); copy->_tkMenu = _tkMenu; copy->_tkOffset = _tkOffset; copy->_tkItemCount = _tkItemCount; copy->_tkSpecial = _tkSpecial; return copy; } - (TkMenu *) tkMenu { return _tkMenu; } - (int) tkIndexOfItem: (NSMenuItem *) menuItem { return [self indexOfItem:menuItem] - _tkOffset; } - (void) insertItem: (NSMenuItem *) newItem atTkIndex: (NSInteger) index { [super insertItem:newItem atIndex:index + _tkOffset]; _tkItemCount++; } - (void) insertItem: (NSMenuItem *) newItem atIndex: (NSInteger) index { if (_tkMenu && index >= 0) { if ((NSUInteger)index <= _tkOffset) { _tkOffset++; } else { NSAssert((NSUInteger)index >= _tkItemCount + _tkOffset, @"Cannot insert in the middle of Tk menu"); } } [super insertItem:newItem atIndex:index]; } - (void) removeItemAtIndex: (NSInteger) index { if (_tkMenu && index >= 0) { if ((NSUInteger)index < _tkOffset) { _tkOffset--; } else if ((NSUInteger)index < _tkItemCount + _tkOffset) { _tkItemCount--; } } [super removeItemAtIndex:index]; } - (NSMenuItem *) newTkMenuItem: (TkMenuEntry *) mePtr { NSMenuItem *menuItem = [[NSMenuItem alloc] initWithTitle:@"" action:@selector(tkMenuItemInvoke:) keyEquivalent:@""]; [menuItem setTarget:self]; [menuItem setTag:(NSInteger)mePtr]; return menuItem; } @end @implementation TKMenu(TKMenuActions) // target methods - (BOOL) validateMenuItem: (NSMenuItem *) menuItem { return [menuItem isEnabled]; } - (void) tkMenuItemInvoke: (id) sender { /* * With the delegate matching key equivalents, when a menu action is sent * in response to a key equivalent, sender is the whole menu and not the * the specific menu item, use this to ignore key equivalents for our * menus (as Tk handles them directly via bindings). */ if ([sender isKindOfClass:[NSMenuItem class]]) { NSMenuItem *menuItem = (NSMenuItem *)sender; TkMenu *menuPtr = (TkMenu *)_tkMenu; TkMenuEntry *mePtr = (TkMenuEntry *)[menuItem tag]; if (menuPtr && mePtr) { Tcl_Interp *interp = menuPtr->interp; /*Add time for errors to fire if necessary. This is sub-optimal but avoids issues with Tcl/Cocoa event loop integration.*/ Tcl_Sleep(100); Tcl_Preserve(interp); Tcl_Preserve(menuPtr); int result = TkInvokeMenu(interp, menuPtr, mePtr->index); if (result != TCL_OK && result != TCL_CONTINUE && result != TCL_BREAK) { Tcl_AddErrorInfo(interp, "\n (menu invoke)"); Tcl_BackgroundError(interp); } Tcl_Release(menuPtr); Tcl_Release(interp); } } } @end @implementation TKMenu(TKMenuDelegate) #define keyEquivModifiersMatch(km, m) (( \ ((km) & NSCommandKeyMask) != ((m) & NSCommandKeyMask) || \ ((km) & NSAlternateKeyMask) != ((m) & NSAlternateKeyMask) || \ ((km) & NSControlKeyMask) != ((m) & NSControlKeyMask) || \ (((km) & NSShiftKeyMask) != ((m) & NSShiftKeyMask) && \ ((m) & NSFunctionKeyMask))) ? NO : YES) - (BOOL) menuHasKeyEquivalent: (NSMenu *) menu forEvent: (NSEvent *) event target: (id *) target action: (SEL *) action { /*Use lowercaseString to keep "shift" from firing twice if bound to different procedure.*/ NSString *key = [[event charactersIgnoringModifiers] lowercaseString]; NSUInteger modifiers = [event modifierFlags] & NSDeviceIndependentModifierFlagsMask; if (modifiers == (NSCommandKeyMask | NSShiftKeyMask) && [key compare:@"?"] == NSOrderedSame) { return NO; } // For command key, take input manager's word so things // like dvorak / qwerty layout work. if (([event modifierFlags] & NSCommandKeyMask) == NSCommandKeyMask) { key = [event characters]; } NSArray *itemArray = [self itemArray]; for (NSMenuItem *item in itemArray) { if ([item isEnabled] && [[item keyEquivalent] compare:key] == NSOrderedSame) { NSUInteger keyEquivModifiers = [item keyEquivalentModifierMask]; if (keyEquivModifiersMatch(keyEquivModifiers, modifiers)) { *target = [item target]; *action = [item action]; return YES; } } } return NO; } - (void) menuWillOpen: (NSMenu *) menu { if (_tkMenu) { //RecursivelyClearActiveMenu(_tkMenu); GenerateMenuSelectEvent((TKMenu *)[self supermenu], [self itemInSupermenu]); } } - (void) menuDidClose: (NSMenu *) menu { if (_tkMenu) { RecursivelyClearActiveMenu(_tkMenu); } } - (void) menu: (NSMenu *) menu willHighlightItem: (NSMenuItem *) item { if (_tkMenu) { GenerateMenuSelectEvent(self, item); } } - (void) menuNeedsUpdate: (NSMenu *) menu { TkMenu *menuPtr = (TkMenu *) _tkMenu; if (menuPtr) { Tcl_Interp *interp = menuPtr->interp; Tcl_Preserve(interp); Tcl_Preserve(menuPtr); int result = TkPostCommand(_tkMenu); if (result!=TCL_OK && result!=TCL_CONTINUE && result!=TCL_BREAK) { Tcl_AddErrorInfo(interp, "\n (menu preprocess)"); Tcl_BackgroundError(interp); } Tcl_Release(menuPtr); Tcl_Release(interp); } } @end #pragma mark TKApplication(TKMenu) @interface NSApplication(TKMenu) - (void) setAppleMenu: (NSMenu *) menu; @end @implementation TKApplication(TKMenu) - (void) menuBeginTracking: (NSNotification *) notification { #ifdef TK_MAC_DEBUG_NOTIFICATIONS TKLog(@"-[%@(%p) %s] %@", [self class], self, _cmd, notification); #endif //TkMacOSXClearMenubarActive(); //TkMacOSXPreprocessMenu(); } - (void) menuEndTracking: (NSNotification *) notification { #ifdef TK_MAC_DEBUG_NOTIFICATIONS TKLog(@"-[%@(%p) %s] %@", [self class], self, _cmd, notification); #endif if (!inPostMenu) { TkMacOSXClearMenubarActive(); } } - (void) tkSetMainMenu: (TKMenu *) menu { if (gNoTkMenus) { return; } TKMenu *applicationMenu = nil; if (menu) { NSMenuItem *applicationMenuItem = [menu numberOfItems] ? [menu itemAtIndex:0] : nil; if (![menu isSpecial:tkMainMenu]) { TkMenuEntry *mePtr = (TkMenuEntry *)[applicationMenuItem tag]; if (!mePtr || !(mePtr->entryFlags & ENTRY_APPLE_MENU)) { applicationMenuItem = [NSMenuItem itemWithSubmenu: [[_defaultApplicationMenu copy] autorelease]]; [menu insertItem:applicationMenuItem atIndex:0]; } [menu setSpecial:tkMainMenu]; } applicationMenu = (TKMenu *)[applicationMenuItem submenu]; if (![applicationMenu isSpecial:tkApplicationMenu]) { for (NSMenuItem *item in _defaultApplicationMenuItems) { [applicationMenu addItem:[[item copy] autorelease]]; } [applicationMenu setSpecial:tkApplicationMenu]; } NSArray *itemArray = [menu itemArray]; for (NSMenuItem *item in itemArray) { TkMenuEntry *mePtr = (TkMenuEntry *)[item tag]; TKMenu *submenu = (TKMenu *)[item submenu]; if (mePtr && submenu) { if ((mePtr->entryFlags & ENTRY_WINDOWS_MENU) && ![submenu isSpecial:tkWindowsMenu]) { NSInteger index = 0; for (NSMenuItem *i in _defaultWindowsMenuItems) { [submenu insertItem:[[i copy] autorelease] atIndex: index++]; } [self setWindowsMenu:submenu]; [submenu setSpecial:tkWindowsMenu]; } else if ((mePtr->entryFlags & ENTRY_HELP_MENU) && ![submenu isSpecial:tkHelpMenu]) { NSInteger index = 0; for (NSMenuItem *i in _defaultHelpMenuItems) { [submenu insertItem:[[i copy] autorelease] atIndex: index++]; } [submenu setSpecial:tkHelpMenu]; } } } } else { menu = _defaultMainMenu; applicationMenu = _defaultApplicationMenu; } NSMenuItem *servicesMenuItem = [applicationMenu itemWithTitle:@"Services"]; if (servicesMenuItem && [servicesMenuItem submenu] != _servicesMenu) { [[_servicesMenu itemInSupermenu] setSubmenu:nil]; [servicesMenuItem setSubmenu:_servicesMenu]; } [self setAppleMenu:applicationMenu]; [self setMainMenu:menu]; } @end #pragma mark - /* *---------------------------------------------------------------------- * * TkpNewMenu -- * * Gets a new blank menu. Only the platform specific options are filled * in. * * Results: * Returns a standard Tcl error. * * Side effects: * Allocates a NSMenu and puts it into the platformData field of the * menuPtr. * *---------------------------------------------------------------------- */ int TkpNewMenu( TkMenu *menuPtr) /* The common structure we are making the * platform structure for. */ { TKMenu *menu = [[TKMenu alloc] initWithTkMenu:menuPtr]; menuPtr->platformData = (TkMenuPlatformData) TkMacOSXMakeUncollectable(menu); CheckForSpecialMenu(menuPtr); return TCL_OK; } /* *---------------------------------------------------------------------- * * TkpDestroyMenu -- |
︙ | ︙ | |||
741 742 743 744 745 746 747 | *---------------------------------------------------------------------- */ void TkpDestroyMenu( TkMenu *menuPtr) /* The common menu structure */ { | | | < < < | < > > > | > > > | | < < | > > > > > > > > | > > > > | > > | < | | | < < < < > > | > | > > | | | > > | | | | > > > > > > > > > > > > | > > > > > > > | > > > > > > > > > > > > > > > > > > > > > > > > | > > > > > > > | > > > > > > > > > > > > > > | > > > > > > > > > > > > | > > > | | > > > > > > > > > > > | | | > > > | | < < | < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < | | < < | < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < | < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < | < < < | < < < < < | | < < < < < < < < < < < < < < < < < < < < < < < < < < < < < | < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < | 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 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 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 703 704 705 706 707 708 709 710 711 712 713 714 715 716 717 718 719 720 721 722 723 724 725 726 727 728 729 730 | *---------------------------------------------------------------------- */ void TkpDestroyMenu( TkMenu *menuPtr) /* The common menu structure */ { TkMacOSXMakeCollectableAndRelease(menuPtr->platformData); } /* *---------------------------------------------------------------------- * * TkpMenuNewEntry -- * * Adds a pointer to a new menu entry structure with the platform- * specific fields filled in. The Macintosh uses the platformEntryData * field of the TkMenuEntry record. * * Results: * Standard TCL error. * * Side effects: * Storage gets allocated. New menu entry data is put into the * platformEntryData field of the mePtr. * *---------------------------------------------------------------------- */ int TkpMenuNewEntry( TkMenuEntry *mePtr) /* The menu we are adding an entry to */ { TKMenu *menu = (TKMenu *) mePtr->menuPtr->platformData; NSMenuItem *menuItem; if (mePtr->type == SEPARATOR_ENTRY || mePtr->type == TEAROFF_ENTRY) { menuItem = [[NSMenuItem separatorItem] retain]; } else { menuItem = [menu newTkMenuItem:mePtr]; } mePtr->platformEntryData = (TkMenuPlatformEntryData) TkMacOSXMakeUncollectable(menuItem); /* * Caller TkMenuEntry() already did this same insertion into the generic * TkMenu so we just match it for the platform menu. */ [menu insertItem:menuItem atTkIndex:mePtr->index]; return TCL_OK; } /* *---------------------------------------------------------------------- * * TkpConfigureMenuEntry -- * * Processes configurations for menu entries. * * Results: * Returns standard TCL result. If TCL_ERROR is returned, then the * interp's result contains an error message. * * Side effects: * Configuration information get set for mePtr; old resources get freed, * if any need it. * *---------------------------------------------------------------------- */ int TkpConfigureMenuEntry( TkMenuEntry *mePtr) /* Information about menu entry; may or may * not already have values for some fields. */ { NSMenuItem *menuItem = (NSMenuItem *) mePtr->platformEntryData; NSString *title = @""; NSAttributedString *attributedTitle = nil; NSImage *image = nil; NSString *keyEquivalent = @""; NSUInteger modifierMask = NSCommandKeyMask; NSMenu *submenu = nil; NSDictionary *attributes; int imageWidth, imageHeight; GC gc = (mePtr->textGC ? mePtr->textGC : mePtr->menuPtr->textGC); Tcl_Obj *fontPtr = (mePtr->fontPtr ? mePtr->fontPtr : mePtr->menuPtr->fontPtr); if (mePtr->image) { Tk_SizeOfImage(mePtr->image, &imageWidth, &imageHeight); image = TkMacOSXGetNSImageWithTkImage(mePtr->menuPtr->display, mePtr->image, imageWidth, imageHeight); } else if (mePtr->bitmapPtr != None) { Pixmap bitmap = Tk_GetBitmapFromObj(mePtr->menuPtr->tkwin, mePtr->bitmapPtr); Tk_SizeOfBitmap(mePtr->menuPtr->display, bitmap, &imageWidth, &imageHeight); image = TkMacOSXGetNSImageWithBitmap(mePtr->menuPtr->display, bitmap, gc, imageWidth, imageHeight); } [menuItem setImage:image]; if ((!image || mePtr->compound != COMPOUND_NONE) && mePtr->labelPtr && mePtr->labelLength) { title = [[[NSString alloc] initWithBytes:Tcl_GetString(mePtr->labelPtr) length:mePtr->labelLength encoding:NSUTF8StringEncoding] autorelease]; if ([title hasSuffix:@"..."]) { title = [NSString stringWithFormat:@"%@%C", [title substringToIndex:[title length] - 3], 0x2026]; } } [menuItem setTitle:title]; if (strcmp(Tcl_GetString(fontPtr), "menu") || gc->foreground != defaultFg || gc->background != defaultBg) { attributes = TkMacOSXNSFontAttributesForFont(Tk_GetFontFromObj( mePtr->menuPtr->tkwin, fontPtr)); if (gc->foreground != defaultFg || gc->background != defaultBg) { NSColor *color = TkMacOSXGetNSColor(gc, gc->foreground!=defaultFg? gc->foreground:gc->background); attributes = [[attributes mutableCopy] autorelease]; [(NSMutableDictionary *)attributes setObject:color forKey:NSForegroundColorAttributeName]; } if (attributes) { attributedTitle = [[[NSAttributedString alloc] initWithString:title attributes:attributes] autorelease]; } } [menuItem setAttributedTitle:attributedTitle]; [menuItem setEnabled:!(mePtr->state == ENTRY_DISABLED)]; [menuItem setState:((mePtr->type == CHECK_BUTTON_ENTRY || mePtr->type == RADIO_BUTTON_ENTRY) && mePtr->indicatorOn && (mePtr->entryFlags & ENTRY_SELECTED) ? NSOnState : NSOffState)]; if (mePtr->type != CASCADE_ENTRY && mePtr->accelPtr && mePtr->accelLength) { keyEquivalent = ParseAccelerator(Tcl_GetString(mePtr->accelPtr), &modifierMask); } [menuItem setKeyEquivalent:keyEquivalent]; [menuItem setKeyEquivalentModifierMask:modifierMask]; if (mePtr->type == CASCADE_ENTRY && mePtr->namePtr) { TkMenuReferences *menuRefPtr; menuRefPtr = TkFindMenuReferencesObj(mePtr->menuPtr->interp, mePtr->namePtr); if (menuRefPtr && menuRefPtr->menuPtr) { CheckForSpecialMenu(menuRefPtr->menuPtr); submenu = (TKMenu *) menuRefPtr->menuPtr->platformData; if ([submenu supermenu] && [menuItem submenu] != submenu) { /* * This happens during a clone, where the parent menu is * cloned before its children, so just ignore this temprary * setting, it will be changed shortly (c.f. tkMenu.c * CloneMenu()) */ submenu = nil; } else { [submenu setTitle:title]; if ([menuItem isEnabled]) { /* This menuItem might have been previously disabled (XXX: track this), which would have disabled entries; we must re-enable the entries here. */ int i = 0; NSArray *itemArray = [submenu itemArray]; for (NSMenuItem *item in itemArray) { TkMenuEntry *submePtr = menuRefPtr->menuPtr->entries[i]; [item setEnabled: !(submePtr->state == ENTRY_DISABLED)]; i++; } } } } } [menuItem setSubmenu:submenu]; return TCL_OK; } /* *---------------------------------------------------------------------- * * TkpDestroyMenuEntry -- * * Cleans up platform-specific menu entry items. * * Results: * None * * Side effects: * All platform-specific allocations are freed up. * *---------------------------------------------------------------------- */ void TkpDestroyMenuEntry( TkMenuEntry *mePtr) { if (mePtr->platformEntryData && mePtr->menuPtr->platformData) { TKMenu *menu = (TKMenu *) mePtr->menuPtr->platformData; NSMenuItem *menuItem = (NSMenuItem *) mePtr->platformEntryData; NSInteger index = [menu indexOfItem:menuItem]; if (index > -1) { [menu removeItemAtIndex:index]; } } TkMacOSXMakeCollectableAndRelease(mePtr->platformEntryData); } /* *---------------------------------------------------------------------- * * TkpPostMenu -- * |
︙ | ︙ | |||
1522 1523 1524 1525 1526 1527 1528 | Tcl_Interp *interp, /* The interpreter this menu lives in */ TkMenu *menuPtr, /* The menu we are posting */ int x, /* The global x-coordinate of the top, left- * hand corner of where the menu is supposed * to be posted. */ int y) /* The global y-coordinate */ { | > > > > > > > > > > > > > > | > > > > > > > > > > > > > > > > > > > > | > > > > > > > > > > > > > > > > > > > > > > > > > > > > > | > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > | > > > > > > > > | > > > > > > > > > > > > > > > | > > > > > > > > > > > > > > > > > > > | > > > > > > > | > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > | > > > > > > > > > > > > > > > | > | > | > | > > | > > > > > > | < > > > > > > > | > > > > > > > | > > > > > > > > > > > > > > | > > | > > > > > > > | > > > > > > > > > | > > | > > > > > > > | > > | > > > > > > > > | > > > > > > > > > > > | < | | > | | > > > > | > > > > > | | > > > > > > > | > | > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > | > > | > > > > > > | > > | > > > > | > > > > > > > > > > > > > > > > > | > | | | | > | > > > > > > > > | > > > > > > > > | | < < < < > < < > > | > > > | > > | > > > > > > > > > > > | > > > > > > > > > > > > > > > > | > > | > > > > > > > > > > > > > > > > > > > > > > | | > > > > > > > > > > > > > > > | > > > > > | > > > | > > > > > > > | > > > > > > > > > > > > > > > | > > > > | > > | | | | < > | 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 773 774 775 776 777 778 779 780 781 782 783 784 785 786 787 788 789 790 791 792 793 794 795 796 797 798 799 800 801 802 803 804 805 806 807 808 809 810 811 812 813 814 815 816 817 818 819 820 821 822 823 824 825 826 827 828 829 830 831 832 833 834 835 836 837 838 839 840 841 842 843 844 845 846 847 848 849 850 851 852 853 854 855 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 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 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 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 1128 1129 1130 1131 1132 1133 1134 1135 1136 1137 1138 1139 1140 1141 1142 1143 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 1178 1179 1180 1181 1182 1183 1184 1185 1186 1187 1188 1189 1190 1191 1192 1193 1194 1195 1196 1197 1198 1199 1200 1201 1202 1203 1204 1205 1206 1207 1208 1209 1210 1211 1212 1213 1214 1215 1216 1217 1218 1219 1220 1221 1222 1223 1224 1225 1226 1227 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 | Tcl_Interp *interp, /* The interpreter this menu lives in */ TkMenu *menuPtr, /* The menu we are posting */ int x, /* The global x-coordinate of the top, left- * hand corner of where the menu is supposed * to be posted. */ int y) /* The global y-coordinate */ { NSWindow *win = [NSApp keyWindow]; if (!win) { return TCL_ERROR; } inPostMenu = 1; int oldMode = Tcl_SetServiceMode(TCL_SERVICE_NONE); NSView *view = [win contentView]; NSRect frame = NSMakeRect(x + 9, tkMacOSXZeroScreenHeight - y - 9, 1, 1); frame.origin = [view convertPoint: [win convertScreenToBase:frame.origin] fromView:nil]; NSMenu *menu = (NSMenu *) menuPtr->platformData; NSPopUpButtonCell *popUpButtonCell = [[NSPopUpButtonCell alloc] initTextCell:@"" pullsDown:NO]; [popUpButtonCell setAltersStateOfSelectedItem:NO]; [popUpButtonCell setMenu:menu]; [popUpButtonCell selectItem:nil]; [popUpButtonCell performClickWithFrame:frame inView:view]; [popUpButtonCell release]; Tcl_SetServiceMode(oldMode); inPostMenu = 0; return TCL_OK; } /* *---------------------------------------------------------------------- * * TkpSetWindowMenuBar -- * * Associates a given menu with a window. * * Results: * None. * * Side effects: * On Windows and UNIX, associates the platform menu with the platform * window. * *---------------------------------------------------------------------- */ void TkpSetWindowMenuBar( Tk_Window tkwin, /* The window we are setting the menu in */ TkMenu *menuPtr) /* The menu we are setting */ { TkWindow *winPtr = (TkWindow *) tkwin; if (winPtr->wmInfoPtr) { winPtr->wmInfoPtr->menuPtr = menuPtr; } } /* *---------------------------------------------------------------------- * * TkpSetMainMenubar -- * * Puts the menu associated with a window into the menubar. Should only * be called when the window is in front. * * Results: * None. * * Side effects: * The menubar is changed. * *---------------------------------------------------------------------- */ void TkpSetMainMenubar( Tcl_Interp *interp, /* The interpreter of the application */ Tk_Window tkwin, /* The frame we are setting up */ char *menuName) /* The name of the menu to put in front. If * NULL, use the default menu bar. */ { static Tcl_Interp *currentInterp = NULL; TKMenu *menu = nil; if (menuName) { TkWindow *winPtr = (TkWindow *) tkwin; if (winPtr->wmInfoPtr && winPtr->wmInfoPtr->menuPtr && winPtr->wmInfoPtr->menuPtr->masterMenuPtr && winPtr->wmInfoPtr->menuPtr->masterMenuPtr->tkwin && !strcmp(menuName, Tk_PathName( winPtr->wmInfoPtr->menuPtr->masterMenuPtr->tkwin))) { menu = (TKMenu *) winPtr->wmInfoPtr->menuPtr->platformData; } else { TkMenuReferences *menuRefPtr = TkFindMenuReferences(interp, menuName); if (menuRefPtr && menuRefPtr->menuPtr && menuRefPtr->menuPtr->platformData) { menu = (TKMenu *) menuRefPtr->menuPtr->platformData; } } } if (menu || interp != currentInterp) { [NSApp tkSetMainMenu:menu]; } currentInterp = interp; } /* *---------------------------------------------------------------------- * * CheckForSpecialMenu -- * * Given a menu, check to see whether or not it is a cascade in a menubar * with one of the special names .apple, .help or .window If it is, the * entry that points to this menu will be marked. * * Results: * None. * * Side effects: * Will set entryFlags appropriately. * *---------------------------------------------------------------------- */ static void CheckForSpecialMenu( TkMenu *menuPtr) /* The menu we are checking */ { if (!menuPtr->masterMenuPtr->tkwin) { return; } for (TkMenuEntry *cascadeEntryPtr = menuPtr->menuRefPtr->parentEntryPtr; cascadeEntryPtr; cascadeEntryPtr = cascadeEntryPtr->nextCascadePtr) { if (cascadeEntryPtr->menuPtr->menuType == MENUBAR && cascadeEntryPtr->menuPtr->masterMenuPtr->tkwin) { TkMenu *masterMenuPtr = cascadeEntryPtr->menuPtr->masterMenuPtr; int i = 0; Tcl_DString ds; Tcl_DStringInit(&ds); Tcl_DStringAppend(&ds, Tk_PathName(masterMenuPtr->tkwin), -1); while (specialMenus[i].name) { Tcl_DStringAppend(&ds, specialMenus[i].name, specialMenus[i].len); if (strcmp(Tcl_DStringValue(&ds), Tk_PathName(menuPtr->masterMenuPtr->tkwin)) == 0) { cascadeEntryPtr->entryFlags |= specialMenus[i].flag; } else { cascadeEntryPtr->entryFlags &= ~specialMenus[i].flag; } Tcl_DStringSetLength(&ds, Tcl_DStringLength(&ds) - specialMenus[i].len); i++; } Tcl_DStringFree(&ds); } } } /* *---------------------------------------------------------------------- * * ParseAccelerator -- * * Parse accelerator string. * * Results: * Accelerator string & flags. * * Side effects: * None. * *---------------------------------------------------------------------- */ static NSString * ParseAccelerator( const char *accel, NSUInteger *maskPtr) { unichar ch = 0; size_t len; int i; *maskPtr = 0; while (1) { i = 0; while (modifiers[i].name) { int l = modifiers[i].len; if (!strncasecmp(accel, modifiers[i].name, l) && (accel[l] == '-' || accel[l] == '+')) { *maskPtr |= modifiers[i].mask; accel += l+1; break; } i++; } if (!modifiers[i].name || !*accel) { break; } } len = strlen(accel); if (len > 1) { i = 0; if (accel[0] == 'F' && len < 4 && accel[1] > '0' && accel[1] <= '9') { int fkey = accel[1] - '0'; if (len == 3) { if (accel[2] >= '0' && accel[2] <= '9') { fkey = 10 * fkey + (accel[2] - '0'); } else { fkey = 0; } } if (fkey >= 1 && fkey <= 15) { ch = NSF1FunctionKey + fkey - 1; } } else while (specialAccelerators[i].name) { if (accel[0] == specialAccelerators[i].name[0] && len == specialAccelerators[i].len && !strncasecmp(accel, specialAccelerators[i].name, specialAccelerators[i].len)) { ch = specialAccelerators[i].ch; break; } i++; } } if (ch) { return [[[NSString alloc] initWithCharacters:&ch length:1] autorelease]; } else { return [[[[NSString alloc] initWithUTF8String:accel] autorelease] lowercaseString]; } } /* *-------------------------------------------------------------- * * ModifierCharWidth -- * * Helper mesuring width of command char in given font. * * Results: * Width of command char. * * Side effects: * None. * *-------------------------------------------------------------- */ static int ModifierCharWidth( Tk_Font tkfont) { static NSString *cmdChar = nil; if (!cmdChar) { unichar cmd = kCommandUnicode; cmdChar = [[NSString alloc] initWithCharacters:&cmd length:1]; } return [cmdChar sizeWithAttributes: TkMacOSXNSFontAttributesForFont(tkfont)].width; } /* *-------------------------------------------------------------- * * TkpComputeStandardMenuGeometry -- * * This procedure is invoked to recompute the size and layout of a menu * that is not a menubar clone. * * Results: * None. * * Side effects: * Fields of menu entries are changed to reflect their current positions, * and the size of the menu window itself may be changed. * *-------------------------------------------------------------- */ void TkpComputeStandardMenuGeometry( TkMenu *menuPtr) /* Structure describing menu. */ { Tk_Font tkfont, menuFont; Tk_FontMetrics menuMetrics, entryMetrics, *fmPtr; int modifierCharWidth, menuModifierCharWidth; int x, y, modifierWidth, labelWidth, indicatorSpace; int windowWidth, windowHeight, accelWidth; int i, j, lastColumnBreak, maxWidth; int entryWidth, maxIndicatorSpace, borderWidth, activeBorderWidth; TkMenuEntry *mePtr, *columnEntryPtr; int haveAccel = 0; if (menuPtr->tkwin == NULL) { return; } Tk_GetPixelsFromObj(NULL, menuPtr->tkwin, menuPtr->borderWidthPtr, &borderWidth); Tk_GetPixelsFromObj(NULL, menuPtr->tkwin, menuPtr->activeBorderWidthPtr, &activeBorderWidth); x = y = borderWidth; windowHeight = maxWidth = lastColumnBreak = 0; maxIndicatorSpace = 0; /* * On the Mac especially, getting font metrics can be quite slow, so we * want to do it intelligently. We are going to precalculate them and pass * them down to all of the measuring and drawing routines. We will measure * the font metrics of the menu once. If an entry does not have its own * font set, then we give the geometry/drawing routines the menu's font * and metrics. If an entry has its own font, we will measure that font * and give all of the geometry/drawing the entry's font and metrics. */ menuFont = Tk_GetFontFromObj(menuPtr->tkwin, menuPtr->fontPtr); Tk_GetFontMetrics(menuFont, &menuMetrics); menuModifierCharWidth = ModifierCharWidth(menuFont); for (i = 0; i < menuPtr->numEntries; i++) { mePtr = menuPtr->entries[i]; if (mePtr->type == CASCADE_ENTRY || mePtr->accelLength > 0) { haveAccel = 1; break; } } for (i = 0; i < menuPtr->numEntries; i++) { mePtr = menuPtr->entries[i]; if (mePtr->fontPtr == NULL) { tkfont = menuFont; fmPtr = &menuMetrics; modifierCharWidth = menuModifierCharWidth; } else { tkfont = Tk_GetFontFromObj(menuPtr->tkwin, mePtr->fontPtr); Tk_GetFontMetrics(tkfont, &entryMetrics); fmPtr = &entryMetrics; modifierCharWidth = ModifierCharWidth(tkfont); } if ((i > 0) && mePtr->columnBreak) { if (maxIndicatorSpace != 0) { maxIndicatorSpace += 2; } for (j = lastColumnBreak; j < i; j++) { columnEntryPtr = menuPtr->entries[j]; columnEntryPtr->indicatorSpace = maxIndicatorSpace; columnEntryPtr->width = maxIndicatorSpace + maxWidth + 2 * activeBorderWidth; columnEntryPtr->x = x; columnEntryPtr->entryFlags &= ~ENTRY_LAST_COLUMN; } x += maxIndicatorSpace + maxWidth + 2 * borderWidth; maxWidth = maxIndicatorSpace = 0; lastColumnBreak = i; y = borderWidth; } accelWidth = modifierWidth = indicatorSpace = 0; if (mePtr->type == SEPARATOR_ENTRY || mePtr->type == TEAROFF_ENTRY) { mePtr->height = menuSeparatorHeight; } else { /* * For each entry, compute the height required by that particular * entry, plus three widths: the width of the label, the width to * allow for an indicator to be displayed to the left of the label * (if any), and the width of the accelerator to be displayed to * the right of the label (if any). These sizes depend, of course, * on the type of the entry. */ NSMenuItem *menuItem = (NSMenuItem *) mePtr->platformEntryData; int haveImage = 0, width = 0, height = 0; if (mePtr->image) { Tk_SizeOfImage(mePtr->image, &width, &height); haveImage = 1; } else if (mePtr->bitmapPtr) { Pixmap bitmap = Tk_GetBitmapFromObj(menuPtr->tkwin, mePtr->bitmapPtr); Tk_SizeOfBitmap(menuPtr->display, bitmap, &width, &height); haveImage = 1; } if (!haveImage || (mePtr->compound != COMPOUND_NONE)) { NSAttributedString *attrTitle = [menuItem attributedTitle]; NSSize size; if (attrTitle) { size = [attrTitle size]; } else { size = [[menuItem title] sizeWithAttributes: TkMacOSXNSFontAttributesForFont(tkfont)]; } size.width += menuTextLeadingEdgeMargin + menuTextTrailingEdgeMargin; if (size.height < fmPtr->linespace) { size.height = fmPtr->linespace; } if (haveImage && (mePtr->compound != COMPOUND_NONE)) { int margin = width + menuIconTrailingEdgeMargin; if (margin > menuTextLeadingEdgeMargin) { margin = menuTextLeadingEdgeMargin; } width += size.width + menuIconTrailingEdgeMargin - margin; if (size.height > height) { height = size.height; } } else { width = size.width; height = size.height; } } labelWidth = width + menuItemExtraWidth; mePtr->height = height + menuItemExtraHeight; if (mePtr->type == CASCADE_ENTRY) { modifierWidth = modifierCharWidth; } else if (mePtr->accelLength == 0) { if (haveAccel && !mePtr->hideMargin) { modifierWidth = modifierCharWidth; } } else { NSUInteger modifMask = [menuItem keyEquivalentModifierMask]; int i = 0; while (modifiers[i].name) { if (modifMask & modifiers[i].mask) { modifMask &= ~modifiers[i].mask; modifierWidth += modifierCharWidth; } i++; } accelWidth = [[menuItem keyEquivalent] sizeWithAttributes: TkMacOSXNSFontAttributesForFont(tkfont)].width; } if (!mePtr->hideMargin) { indicatorSpace = menuMarkColumnWidth; } if (indicatorSpace > maxIndicatorSpace) { maxIndicatorSpace = indicatorSpace; } entryWidth = labelWidth + modifierWidth + accelWidth; if (entryWidth > maxWidth) { maxWidth = entryWidth; } mePtr->height += 2 * activeBorderWidth; } mePtr->y = y; y += menuPtr->entries[i]->height + borderWidth; if (y > windowHeight) { windowHeight = y; } } for (j = lastColumnBreak; j < menuPtr->numEntries; j++) { columnEntryPtr = menuPtr->entries[j]; columnEntryPtr->indicatorSpace = maxIndicatorSpace; columnEntryPtr->width = maxIndicatorSpace + maxWidth + 2 * activeBorderWidth; columnEntryPtr->x = x; columnEntryPtr->entryFlags |= ENTRY_LAST_COLUMN; } windowWidth = x + maxIndicatorSpace + maxWidth + 2 * activeBorderWidth + borderWidth; windowHeight += borderWidth; if (windowWidth <= 0) { windowWidth = 1; } if (windowHeight <= 0) { windowHeight = 1; } menuPtr->totalWidth = windowWidth; menuPtr->totalHeight = windowHeight; } /* *---------------------------------------------------------------------- * * GenerateMenuSelectEvent -- * * Respond to a menu item being selected. * * Results: * True if event(s) are generated - false otherwise. * * Side effects: * Places a virtual event on the event queue. * *---------------------------------------------------------------------- */ int GenerateMenuSelectEvent( TKMenu *menu, NSMenuItem *menuItem) { TkMenu *menuPtr = [menu tkMenu]; if (menuPtr) { int index = [menu tkIndexOfItem:menuItem]; if (index < 0 || index >= menuPtr->numEntries || (menuPtr->entries[index])->state == ENTRY_DISABLED) { TkActivateMenuEntry(menuPtr, -1); } else { TkActivateMenuEntry(menuPtr, index); MenuSelectEvent(menuPtr); return true; } } return false; } /* *---------------------------------------------------------------------- * * MenuSelectEvent -- * * Generates a "MenuSelect" virtual event. This can be used to do * context-sensitive menu help. * * Results: * None. * * Side effects: * Places a virtual event on the event queue. * *---------------------------------------------------------------------- */ void MenuSelectEvent( TkMenu *menuPtr) /* the menu we have selected. */ { XVirtualEvent event; bzero(&event, sizeof(XVirtualEvent)); event.type = VirtualEvent; event.serial = LastKnownRequestProcessed(menuPtr->display); event.send_event = false; event.display = menuPtr->display; event.event = Tk_WindowId(menuPtr->tkwin); event.root = XRootWindow(menuPtr->display, 0); event.subwindow = None; event.time = TkpGetMS(); XQueryPointer(NULL, None, NULL, NULL, &event.x_root, &event.y_root, NULL, NULL, &event.state); event.same_screen = true; event.name = Tk_GetUid("MenuSelect"); Tk_MakeWindowExist(menuPtr->tkwin); if (Tcl_GetServiceMode() != TCL_SERVICE_NONE) { Tk_HandleEvent((XEvent *) &event); } else { Tk_QueueWindowEvent((XEvent *) &event, TCL_QUEUE_TAIL); } } /* *---------------------------------------------------------------------- * * RecursivelyClearActiveMenu -- * * Recursively clears the active entry in the menu's cascade hierarchy. * * Results: * None. * * Side effects: * Generates <<MenuSelect>> virtual events. * *---------------------------------------------------------------------- */ void RecursivelyClearActiveMenu( TkMenu *menuPtr) /* The menu to reset. */ { int i; TkActivateMenuEntry(menuPtr, -1); for (i = 0; i < menuPtr->numEntries; i++) { TkMenuEntry *mePtr = menuPtr->entries[i]; if (mePtr->type == CASCADE_ENTRY && (mePtr->childMenuRefPtr != NULL) && (mePtr->childMenuRefPtr->menuPtr != NULL)) { RecursivelyClearActiveMenu(mePtr->childMenuRefPtr->menuPtr); } } } /* *---------------------------------------------------------------------- * * TkMacOSXClearMenubarActive -- * * Recursively clears the active entry in the current menubar hierarchy. * * Results: * None. * * Side effects: * Generates <<MenuSelect>> virtual events. * *---------------------------------------------------------------------- */ void TkMacOSXClearMenubarActive(void) { NSMenu *mainMenu = [NSApp mainMenu]; if (mainMenu && [mainMenu isKindOfClass:[TKMenu class]]) { TkMenu *menuPtr = [(TKMenu *) mainMenu tkMenu]; if (menuPtr && menuPtr->numEntries && menuPtr->entries) { RecursivelyClearActiveMenu(menuPtr); } } } /* *---------------------------------------------------------------------- * * Tk_MacOSXTurnOffMenus -- * |
︙ | ︙ | |||
1649 1650 1651 1652 1653 1654 1655 | { gNoTkMenus = 1; } /* *---------------------------------------------------------------------- * | > > > > > > > > > > > > | > > > > | > | > > > > > | > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > | < < < < < < < | < < < | < < < < < < | < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < | | > > | < < < < < < < | < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < | < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < | < < < < < < < < < < < < < < < < | < < < < < < < < < < < < < < < < < < < < < < < < < | < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < | | | | | | | | | | < < < | < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < | | | 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 1498 1499 1500 1501 1502 1503 1504 1505 1506 1507 1508 1509 1510 1511 1512 1513 1514 1515 1516 1517 1518 1519 1520 1521 1522 1523 1524 1525 1526 1527 1528 1529 1530 1531 1532 1533 1534 1535 1536 1537 1538 1539 1540 1541 1542 1543 1544 1545 1546 1547 1548 1549 1550 1551 1552 1553 1554 1555 1556 1557 1558 1559 1560 1561 1562 1563 1564 1565 1566 1567 1568 1569 1570 1571 1572 1573 1574 1575 1576 1577 1578 1579 1580 1581 1582 | { gNoTkMenus = 1; } /* *---------------------------------------------------------------------- * * TkpMenuInit -- * * Initializes Mac-specific menu data. * * Results: * None. * * Side effects: * Allocates a hash table. * *---------------------------------------------------------------------- */ void TkpMenuInit(void) { TkColor *tkColPtr; NSNotificationCenter *nc = [NSNotificationCenter defaultCenter]; #define observe(n, s) \ [nc addObserver:NSApp selector:@selector(s) name:(n) object:nil] observe(NSMenuDidBeginTrackingNotification, menuBeginTracking:); observe(NSMenuDidEndTrackingNotification, menuEndTracking:); #undef observe [NSMenuItem setUsesUserKeyEquivalents:NO]; tkColPtr = TkpGetColor(None, DEF_MENU_BG_COLOR); defaultBg = tkColPtr->color.pixel; ckfree((char *) tkColPtr); tkColPtr = TkpGetColor(None, DEF_MENU_FG); defaultFg = tkColPtr->color.pixel; ckfree((char *) tkColPtr); ChkErr(GetThemeMetric, kThemeMetricMenuMarkColumnWidth, &menuMarkColumnWidth); ChkErr(GetThemeMetric, kThemeMetricMenuTextLeadingEdgeMargin, &menuTextLeadingEdgeMargin); ChkErr(GetThemeMetric, kThemeMetricMenuTextTrailingEdgeMargin, &menuTextTrailingEdgeMargin); ChkErr(GetThemeMetric, kThemeMetricMenuIconTrailingEdgeMargin, &menuIconTrailingEdgeMargin); ChkErr(GetThemeMenuItemExtra, kThemeMenuItemPlain, &menuItemExtraHeight, &menuItemExtraWidth); ChkErr(GetThemeMenuSeparatorHeight, &menuSeparatorHeight); } #pragma mark - #pragma mark NOPs /* *---------------------------------------------------------------------- * * TkpMenuThreadInit -- * * Does platform-specific initialization of thread-specific menu state. * * Results: * None. * * Side effects: * None. * *---------------------------------------------------------------------- */ void TkpMenuThreadInit(void) { /* * Nothing to do. */ } /* *---------------------------------------------------------------------- * * TkpMenuNotifyToplevelCreate -- * * This routine reconfigures the menu and the clones indicated by * menuName because a toplevel has been created and any system menus need * to be created. Only applicable to Windows. * * Results: * None. * * Side effects: * An idle handler is set up to do the reconfiguration. * *---------------------------------------------------------------------- */ void TkpMenuNotifyToplevelCreate( Tcl_Interp *interp, /* The interp the menu lives in. */ char *menuName) /* The name of the menu to reconfigure. */ { /* * Nothing to do. */ } /* *-------------------------------------------------------------- * * TkpInitializeMenuBindings -- * * For every interp, initializes the bindings for Windows menus. Does * nothing on Mac or XWindows. * * Results: * None. * * Side effects: * C-level bindings are setup for the interp which will handle Alt-key * sequences for menus without beeping or interfering with user-defined * Alt-key bindings. * *-------------------------------------------------------------- */ void TkpInitializeMenuBindings( Tcl_Interp *interp, /* The interpreter to set. */ Tk_BindingTable bindingTable) /* The table to add to. */ { /* * Nothing to do. */ } /* *-------------------------------------------------------------- * * TkpComputeMenubarGeometry -- * * This procedure is invoked to recompute the size and layout of a menu * that is a menubar clone. * * Results: * None. * * Side effects: * Fields of menu entries are changed to reflect their current positions, * and the size of the menu window itself may be changed. * *-------------------------------------------------------------- */ void TkpComputeMenubarGeometry( TkMenu *menuPtr) /* Structure describing menu. */ { TkpComputeStandardMenuGeometry(menuPtr); } /* *---------------------------------------------------------------------- * * TkpDrawMenuEntry -- * * Draws the given menu entry at the given coordinates with the given * attributes. * * Results: * None. * * Side effects: * X Server commands are executed to display the menu entry. * |
︙ | ︙ | |||
3045 3046 3047 3048 3049 3050 3051 | const Tk_FontMetrics *menuMetricsPtr, /* Precalculated metrics for menu */ int x, /* X-coordinate of topleft of entry */ int y, /* Y-coordinate of topleft of entry */ int width, /* Width of the entry rectangle */ int height, /* Height of the current rectangle */ int strictMotif, /* Boolean flag */ | | | < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < | < < < < < < < | < < < < < < < < < < < < < < < < | < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < | < < | < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < | < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < | > | > > > | < | > > > > > > > > > > > > > | | > > | < < < | > | > > > | < > > > > > > > > > > > > | > > > > | > > | | > > > > > > > > > > > > > > > > | > > | > > > > | < < > < > | > > > < < | < < < < < < < < < < < < < | < < | < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < | | | | < < < < < < < < < < < < < < | < < < < < < | < < < | < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < | < < < | < | < < < < | | < < < | < | < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < | 1591 1592 1593 1594 1595 1596 1597 1598 1599 1600 1601 1602 1603 1604 1605 1606 1607 1608 1609 1610 1611 1612 1613 1614 1615 1616 1617 1618 1619 1620 1621 1622 1623 1624 1625 1626 1627 1628 1629 1630 1631 1632 1633 1634 1635 1636 1637 1638 1639 1640 1641 1642 1643 1644 1645 1646 1647 1648 1649 1650 1651 1652 1653 1654 1655 1656 1657 1658 1659 1660 1661 1662 1663 1664 1665 1666 1667 1668 1669 1670 1671 1672 1673 1674 1675 1676 1677 1678 1679 1680 1681 1682 1683 1684 1685 1686 1687 1688 1689 1690 1691 1692 1693 1694 1695 1696 1697 1698 1699 1700 1701 1702 1703 1704 1705 1706 1707 1708 1709 1710 1711 1712 1713 1714 1715 1716 1717 1718 1719 1720 1721 1722 1723 1724 1725 1726 1727 1728 1729 1730 1731 1732 1733 1734 1735 1736 1737 1738 1739 1740 1741 1742 1743 1744 1745 1746 1747 1748 1749 1750 1751 1752 1753 1754 1755 1756 1757 | const Tk_FontMetrics *menuMetricsPtr, /* Precalculated metrics for menu */ int x, /* X-coordinate of topleft of entry */ int y, /* Y-coordinate of topleft of entry */ int width, /* Width of the entry rectangle */ int height, /* Height of the current rectangle */ int strictMotif, /* Boolean flag */ int drawArrow) /* Whether or not to draw the cascade arrow * for cascade items. Only applies to * Windows. */ { } #pragma mark Obsolete /* *---------------------------------------------------------------------- * * TkMacOSXPreprocessMenu -- * * Handle preprocessing of menubar if it exists. * * Results: * None. * * Side effects: * All post commands for the current menubar get executed. * *---------------------------------------------------------------------- */ void TkMacOSXPreprocessMenu(void) { } /* *---------------------------------------------------------------------- * * TkMacOSXUseID -- * * Take the ID out of the available list for new menus. Used by the * default menu bar's menus so that they do not get created at the tk * level. See TkMacOSXGetNewMenuID for more information. * * Results: * Returns TCL_OK if the id was not in use. Returns TCL_ERROR if the id * was in use. * * Side effects: * A hash table entry in the command table is created with a NULL value. * *---------------------------------------------------------------------- */ int TkMacOSXUseMenuID( short macID) /* The id to take out of the table */ { return TCL_OK; } /* *---------------------------------------------------------------------- * * TkMacOSXDispatchMenuEvent -- * * Given a menu id and an item, dispatches the command associated with * it. * * Results: * None. * * Side effects: * Commands for the event are scheduled for execution at idle time. * *---------------------------------------------------------------------- */ int TkMacOSXDispatchMenuEvent( int menuID, /* The menu id of the menu we are invoking */ int index) /* The one-based index of the item that was * selected. */ { return TCL_ERROR; } /* *---------------------------------------------------------------------- * * TkMacOSXHandleTearoffMenu() -- * * This routine sees if the MDEF has set a menu and a mouse position for * tearing off and makes a tearoff menu if it has. * * Results: * menuPtr->interp will have the result of the tearoff command. * * Side effects: * A new tearoff menu is created if it is supposed to be. * *---------------------------------------------------------------------- */ void TkMacOSXHandleTearoffMenu(void) { /* * Obsolete: Nothing to do. */ } /* *---------------------------------------------------------------------- * * TkMacOSXSetHelpMenuItemCount -- * * Has to be called after the first call to InsertMenu. Sets up the * global variable for the number of items in the unmodified help menu. * NB. Nobody uses this any more, since you can get the number of system * help items from HMGetHelpMenu trivially. But it is in the stubs * table... * * Results: * None. * * Side effects: * Nothing. * *---------------------------------------------------------------------- */ void TkMacOSXSetHelpMenuItemCount(void) { } /* *---------------------------------------------------------------------- * * TkMacOSXMenuClick -- * * Prepares a menubar for MenuSelect or MenuKey. * * Results: * None. * * Side effects: * Any pending configurations of the menubar are completed. * *---------------------------------------------------------------------- */ void TkMacOSXMenuClick(void) { } /* * Local Variables: * mode: objc * c-basic-offset: 4 * fill-column: 79 * coding: utf-8 * End: */ |
Changes to macosx/tkMacOSXMenubutton.c.
1 2 3 4 5 6 7 | /* * tkMacOSXMenubutton.c -- * * This file implements the Macintosh specific portion of the * menubutton widget. * * Copyright (c) 1996 by Sun Microsystems, Inc. | | | < | < < < | | | < < | < < < | | > > | > > | > | > > > | | > > > | < < | < > > > | < > | | | | > | | < < < < < < < < < < < < < < < < < < < < < < < | | < | 1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 34 35 36 37 38 39 40 41 42 43 44 45 46 47 48 49 50 51 52 53 54 55 56 57 58 59 60 61 62 63 64 65 66 67 68 69 70 71 72 73 74 75 76 77 78 79 80 81 82 83 84 | /* * tkMacOSXMenubutton.c -- * * This file implements the Macintosh specific portion of the * menubutton widget. * * Copyright (c) 1996 by Sun Microsystems, Inc. * Copyright 2001-2009, Apple Inc. * Copyright (c) 2006-2009 Daniel A. Steffen <[email protected]> * * See the file "license.terms" for information on usage and redistribution * of this file, and for a DISCLAIMER OF ALL WARRANTIES. */ #include "tkMacOSXPrivate.h" #include "tkMenubutton.h" #include "tkMacOSXFont.h" #include "tkMacOSXDebug.h" /* #ifdef TK_MAC_DEBUG #define TK_MAC_DEBUG_MENUBUTTON #endif */ typedef struct MacMenuButton { TkMenuButton info; NSPopUpButton *button; #if TK_MAC_BUTTON_USE_COMPATIBILITY_METRICS int fix; #endif } MacMenuButton; #if TK_MAC_BUTTON_USE_COMPATIBILITY_METRICS /* * Use the following heuristic conversion constants to make NSButton-based * widget metrics match up with the old Carbon control buttons (for the * default Lucida Grande 13 font). * TODO: provide a scriptable way to turn this off and use the raw NSButton * metrics (will also need dynamic adjustment of the default padding, * c.f. tkMacOSXDefault.h). */ typedef struct { int trimW, trimH, inset, shrinkW, offsetX, offsetY; } BoundsFix; #define fixForStyle(style) ( \ style == NSRoundedBezelStyle ? 1 : \ style == NSRegularSquareBezelStyle ? 2 : \ style == NSShadowlessSquareBezelStyle ? 3 : \ INT_MIN) static const BoundsFix boundsFixes[] = { [fixForStyle(NSRoundedBezelStyle)] = { 14, 10, -2, -1}, [fixForStyle(NSRegularSquareBezelStyle)] = { 6, 13, -2, 1, 1}, [fixForStyle(NSShadowlessSquareBezelStyle)] = { 15, 0, 2 }, }; #endif /* * Forward declarations for procedures defined later in this file: */ static void MenuButtonEventProc(ClientData clientData, XEvent *eventPtr); /* * The structure below defines menubutton class behavior by means of functions * that can be invoked from generic window code. */ Tk_ClassProcs tkpMenubuttonClass = { sizeof(Tk_ClassProcs), /* size */ TkMenuButtonWorldChanged, /* worldChangedProc */ }; /* *---------------------------------------------------------------------- * * TkpCreateMenuButton -- * * Allocate a new TkMenuButton structure. |
︙ | ︙ | |||
113 114 115 116 117 118 119 | *---------------------------------------------------------------------- */ TkMenuButton * TkpCreateMenuButton( Tk_Window tkwin) { | > | > > | < < < < < < < < | < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < | 92 93 94 95 96 97 98 99 100 101 102 103 104 105 106 107 108 109 110 111 112 113 | *---------------------------------------------------------------------- */ TkMenuButton * TkpCreateMenuButton( Tk_Window tkwin) { MacMenuButton *macButtonPtr = (MacMenuButton *) ckalloc(sizeof(MacMenuButton)); macButtonPtr->button = nil; Tk_CreateEventHandler(tkwin, ActivateMask, MenuButtonEventProc, (ClientData) macButtonPtr); return (TkMenuButton *) macButtonPtr; } /* *---------------------------------------------------------------------- * * TkpDestroyMenuButton -- * |
︙ | ︙ | |||
403 404 405 406 407 408 409 | *---------------------------------------------------------------------- */ void TkpDestroyMenuButton( TkMenuButton *mbPtr) { | | > > | > > > > > > > > > > > > > > > > | > > > > > > > > > > > > > > > > > | > > > > > > > | > > | > > > | > > > > | | > > > > | > > > > > > > > > > | | | > > > > > > > > > | | > > > > > > > > > > > | > > > > > > > > > > > | > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > | | > | | | > > > > > > > > > > > > > > > > > > > > > | > > > > > > > > > > > > > > > > | > | | > > > > > > > > > > > > > > > > > > > > > > > > > > > > | > | | > > | > > > | > > < | | | | < < | | | < < | < < < < < < < < < | | < | < < < < < < < < < < < < < < < < < | < < < < < < | < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < | < < < < < < < < < < < < < < < < < < < < < < < < | < < < | < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < | | < < < | | | | | | < < | | | > > > > > > > > > > | 122 123 124 125 126 127 128 129 130 131 132 133 134 135 136 137 138 139 140 141 142 143 144 145 146 147 148 149 150 151 152 153 154 155 156 157 158 159 160 161 162 163 164 165 166 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 224 225 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 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 284 285 286 287 288 289 290 291 292 293 294 295 296 297 298 299 300 301 302 303 304 305 306 307 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 338 339 340 341 342 343 344 345 346 347 348 349 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 | *---------------------------------------------------------------------- */ void TkpDestroyMenuButton( TkMenuButton *mbPtr) { MacMenuButton *macButtonPtr = (MacMenuButton *) mbPtr; TkMacOSXMakeCollectableAndRelease(macButtonPtr->button); } /* *---------------------------------------------------------------------- * * TkpDisplayMenuButton -- * * This function is invoked to display a menubutton widget. * * Results: * None. * * Side effects: * Commands are output to X to display the menubutton in its current * mode. * *---------------------------------------------------------------------- */ void TkpDisplayMenuButton( ClientData clientData) /* Information about widget. */ { TkMenuButton *mbPtr = (TkMenuButton *) clientData; MacMenuButton *macButtonPtr = (MacMenuButton *) mbPtr; NSPopUpButton *button = macButtonPtr->button; Tk_Window tkwin = mbPtr->tkwin; TkWindow *winPtr = (TkWindow *) tkwin; MacDrawable *macWin = (MacDrawable *) winPtr->window; TkMacOSXDrawingContext dc; NSView *view = TkMacOSXDrawableView(macWin); CGFloat viewHeight = [view bounds].size.height; CGAffineTransform t = { .a = 1, .b = 0, .c = 0, .d = -1, .tx = 0, .ty = viewHeight}; NSRect frame; int enabled; mbPtr->flags &= ~REDRAW_PENDING; if (!tkwin || !Tk_IsMapped(tkwin) || !view || !TkMacOSXSetupDrawingContext((Drawable) macWin, NULL, 1, &dc)) { return; } CGContextConcatCTM(dc.context, t); Tk_Fill3DRectangle(tkwin, (Pixmap) macWin, mbPtr->normalBorder, 0, 0, Tk_Width(tkwin), Tk_Height(tkwin), 0, TK_RELIEF_FLAT); if ([button superview] != view) { [view addSubview:button]; } enabled = !(mbPtr->state == STATE_DISABLED); [button setEnabled:enabled]; if (enabled) { [[button cell] setHighlighted:(mbPtr->state == STATE_ACTIVE)]; } frame = NSMakeRect(macWin->xOff, macWin->yOff, Tk_Width(tkwin), Tk_Height(tkwin)); frame = NSInsetRect(frame, mbPtr->inset, mbPtr->inset); #if TK_MAC_BUTTON_USE_COMPATIBILITY_METRICS if (tkMacOSXUseCompatibilityMetrics) { BoundsFix boundsFix = boundsFixes[macButtonPtr->fix]; frame = NSOffsetRect(frame, boundsFix.offsetX, boundsFix.offsetY); frame.size.width -= boundsFix.shrinkW; frame = NSInsetRect(frame, boundsFix.inset, boundsFix.inset); } #endif frame.origin.y = viewHeight - (frame.origin.y + frame.size.height); if (!NSEqualRects(frame, [button frame])) { [button setFrame:frame]; } [button displayRectIgnoringOpacity:[button bounds]]; TkMacOSXRestoreDrawingContext(&dc); #ifdef TK_MAC_DEBUG_MENUBUTTON TKLog(@"menubutton %s frame %@ width %d height %d", ((TkWindow *)mbPtr->tkwin)->pathName, NSStringFromRect(frame), Tk_Width(tkwin), Tk_Height(tkwin)); #endif } /* *---------------------------------------------------------------------- * * TkpComputeMenuButtonGeometry -- * * After changes in a menu button's text or bitmap, this function * recomputes the menu button's geometry and passes this information * along to the geometry manager for the window. * * Results: * None. * * Side effects: * The menu button's window may change size. * *---------------------------------------------------------------------- */ void TkpComputeMenuButtonGeometry( TkMenuButton *mbPtr) /* Widget record for menu button. */ { MacMenuButton *macButtonPtr = (MacMenuButton *) mbPtr; NSPopUpButton *button = macButtonPtr->button; NSPopUpButtonCell *cell; NSMenuItem *menuItem; NSBezelStyle style = NSRoundedBezelStyle; NSFont *font; NSRect bounds = NSZeroRect, titleRect = NSZeroRect; int haveImage = (mbPtr->image || mbPtr->bitmap != None), haveText = 0; int haveCompound = (mbPtr->compound != COMPOUND_NONE); int width, height; if (!button) { button = [[NSPopUpButton alloc] initWithFrame:NSZeroRect pullsDown:YES]; macButtonPtr->button = TkMacOSXMakeUncollectable(button); cell = [button cell]; [cell setUsesItemFromMenu:NO]; menuItem = [[[NSMenuItem alloc] initWithTitle:@"" action:NULL keyEquivalent:@""] autorelease]; [cell setMenuItem:menuItem]; } else { cell = [button cell]; menuItem = [cell menuItem]; } if (haveImage) { style = NSShadowlessSquareBezelStyle; } else if (!mbPtr->indicatorOn) { style = NSRegularSquareBezelStyle; } [button setBezelStyle:style]; [cell setArrowPosition:(mbPtr->indicatorOn ? NSPopUpArrowAtBottom : NSPopUpNoArrow)]; #if 0 NSControlSize controlSize = NSRegularControlSize; if (mbPtr->borderWidth <= 2) { controlSize = NSMiniControlSize; } else if (mbPtr->borderWidth == 3) { controlSize = NSSmallControlSize; } [cell setControlSize:controlSize]; #endif if (mbPtr->text && *(mbPtr->text) && (!haveImage || haveCompound)) { NSString *title = [[NSString alloc] initWithUTF8String:mbPtr->text]; [button setTitle:title]; [title release]; haveText = 1; } haveCompound = (haveCompound && haveImage && haveText); if (haveText) { NSTextAlignment alignment = NSNaturalTextAlignment; switch (mbPtr->justify) { case TK_JUSTIFY_LEFT: alignment = NSLeftTextAlignment; break; case TK_JUSTIFY_RIGHT: alignment = NSRightTextAlignment; break; case TK_JUSTIFY_CENTER: alignment = NSCenterTextAlignment; break; } [button setAlignment:alignment]; } else { [button setTitle:@""]; } font = TkMacOSXNSFontForFont(mbPtr->tkfont); if (font) { [button setFont:font]; } if (haveImage) { int width, height; NSImage *image; NSCellImagePosition pos = NSImageOnly; if (mbPtr->image) { Tk_SizeOfImage(mbPtr->image, &width, &height); image = TkMacOSXGetNSImageWithTkImage(mbPtr->display, mbPtr->image, width, height); } else { Tk_SizeOfBitmap(mbPtr->display, mbPtr->bitmap, &width, &height); image = TkMacOSXGetNSImageWithBitmap(mbPtr->display, mbPtr->bitmap, mbPtr->normalTextGC, width, height); } if (haveCompound) { switch ((enum compound) mbPtr->compound) { case COMPOUND_TOP: pos = NSImageAbove; break; case COMPOUND_BOTTOM: pos = NSImageBelow; break; case COMPOUND_LEFT: pos = NSImageLeft; break; case COMPOUND_RIGHT: pos = NSImageRight; break; case COMPOUND_CENTER: pos = NSImageOverlaps; break; case COMPOUND_NONE: pos = NSImageOnly; break; } } [button setImagePosition:pos]; [menuItem setImage:image]; bounds.size = cell ? [cell cellSize] : NSZeroSize; if (bounds.size.height < height + 8) { /* workaround AppKit sizing bug */ bounds.size.height = height + 8; } #if TK_MAC_BUTTON_USE_COMPATIBILITY_METRICS if (!mbPtr->indicatorOn && tkMacOSXUseCompatibilityMetrics) { bounds.size.width -= 16; } #endif } else { bounds.size = cell ? [cell cellSize] : NSZeroSize; } if (haveText) { titleRect = cell ? [cell titleRectForBounds:bounds] : NSZeroRect; if (mbPtr->wrapLength > 0 && titleRect.size.width > mbPtr->wrapLength) { if (style == NSRoundedBezelStyle) { [button setBezelStyle:(style = NSRegularSquareBezelStyle)]; bounds.size = cell ? [cell cellSize] : NSZeroSize; titleRect = cell ? [cell titleRectForBounds:bounds] : NSZeroRect; } bounds.size.width -= titleRect.size.width - mbPtr->wrapLength; bounds.size.height = 40000.0; [cell setWraps:YES]; bounds.size = cell ? [cell cellSizeForBounds:bounds] : NSZeroSize; #ifdef TK_MAC_DEBUG_MENUBUTTON titleRect = cell ? [cell titleRectForBounds:bounds] : NSZeroRect; #endif #if TK_MAC_BUTTON_USE_COMPATIBILITY_METRICS if (tkMacOSXUseCompatibilityMetrics) { bounds.size.height += 3; } #endif } } width = lround(bounds.size.width); height = lround(bounds.size.height); #if TK_MAC_BUTTON_USE_COMPATIBILITY_METRICS if (tkMacOSXUseCompatibilityMetrics) { macButtonPtr->fix = fixForStyle(style); width -= boundsFixes[macButtonPtr->fix].trimW; height -= boundsFixes[macButtonPtr->fix].trimH; } #endif if (haveImage || haveCompound) { if (mbPtr->width > 0) { width = mbPtr->width; } if (mbPtr->height > 0) { height = mbPtr->height; } } else { if (mbPtr->width > 0) { int avgWidth = Tk_TextWidth(mbPtr->tkfont, "0", 1); width = mbPtr->width * avgWidth; } if (mbPtr->height > 0) { Tk_FontMetrics fm; Tk_GetFontMetrics(mbPtr->tkfont, &fm); height = mbPtr->height * fm.linespace; } } if (!haveImage || haveCompound) { width += 2*mbPtr->padX; height += 2*mbPtr->padY; } if (mbPtr->highlightWidth < 0) { mbPtr->highlightWidth = 0; } if (haveImage) { mbPtr->inset = mbPtr->highlightWidth; width += 2*mbPtr->borderWidth; height += 2*mbPtr->borderWidth; } else { mbPtr->inset = mbPtr->highlightWidth + mbPtr->borderWidth; } Tk_GeometryRequest(mbPtr->tkwin, width + 2 * mbPtr->inset, height + 2 * mbPtr->inset); Tk_SetInternalBorder(mbPtr->tkwin, mbPtr->inset); #ifdef TK_MAC_DEBUG_MENUBUTTON TKLog(@"menubutton %s bounds %@ titleRect %@ width %d height %d inset %d borderWidth %d", ((TkWindow *)mbPtr->tkwin)->pathName, NSStringFromRect(bounds), NSStringFromRect(titleRect), width, height, mbPtr->inset, mbPtr->borderWidth); #endif } /* *-------------------------------------------------------------- * * MenuButtonEventProc -- * * This procedure is invoked by the Tk dispatcher for various * events on buttons. * * Results: * None. * * Side effects: * When activation state changes, it is redisplayed. * *-------------------------------------------------------------- */ static void MenuButtonEventProc( ClientData clientData, /* Information about window. */ XEvent *eventPtr) /* Information about event. */ { TkMenuButton *mbPtr = (TkMenuButton *) clientData; if (!mbPtr->tkwin || !Tk_IsMapped(mbPtr->tkwin)) { return; } switch (eventPtr->type) { case ActivateNotify: case DeactivateNotify: if (!(mbPtr->flags & REDRAW_PENDING)) { Tcl_DoWhenIdle(TkpDisplayMenuButton, (ClientData) mbPtr); mbPtr->flags |= REDRAW_PENDING; } break; } } /* * Local Variables: * mode: c * c-basic-offset: 4 * fill-column: 79 * coding: utf-8 * End: */ |
Changes to macosx/tkMacOSXMenus.c.
1 2 3 | /* * tkMacOSXMenus.c -- * | | < | | > > > | > | > | > > > | > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > | | | > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > | > > > > > > > > > > | | | | | > > | > > | > > > > > > > > | > | > > | > > > > > > | > > > > > > > > > > > > > > > > > > > > > > > > > > > > | > > > > > > > > > > > | > > > > > > > | | > > > > > > > > > > > > | > | > > > | > > > > > > > > > > > > > > > > | | | | > > | 1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 34 35 36 37 38 39 40 41 42 43 44 45 46 47 48 49 50 51 52 53 54 55 56 57 58 59 60 61 62 63 64 65 66 67 68 69 70 71 72 73 74 75 76 77 78 79 80 81 82 83 84 85 86 87 88 89 90 91 92 93 94 95 96 97 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 129 130 131 132 133 134 135 136 137 138 139 140 141 142 143 144 145 146 147 148 149 150 151 152 153 154 155 156 157 158 159 160 161 162 163 164 165 166 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 224 225 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 256 257 258 259 260 261 262 263 264 265 266 267 268 269 270 271 272 273 274 275 276 277 | /* * tkMacOSXMenus.c -- * * These calls set up the default menus for Tk. * * Copyright (c) 1995-1996 Sun Microsystems, Inc. * Copyright 2001-2009, Apple Inc. * Copyright (c) 2005-2009 Daniel A. Steffen <[email protected]> * * See the file "license.terms" for information on usage and redistribution * of this file, and for a DISCLAIMER OF ALL WARRANTIES. */ #include "tkMacOSXPrivate.h" #include "tkMenu.h" static void GenerateEditEvent(const char *name); static Tcl_Obj * GetWidgetDemoPath(Tcl_Interp *interp); #pragma mark TKApplication(TKMenus) @implementation TKApplication(TKMenus) - (void)_setupMenus { if (_defaultMainMenu) { return; } TkMenuInit(); NSString *applicationName = [[NSBundle mainBundle] objectForInfoDictionaryKey:@"CFBundleName"]; if (!applicationName) { applicationName = [[NSProcessInfo processInfo] processName]; } NSString *aboutName = (applicationName && ![applicationName isEqualToString:@"Wish"] && ![applicationName hasPrefix:@"tclsh"]) ? applicationName : @"Tcl & Tk"; _servicesMenu = [NSMenu menuWithTitle:@"Services"]; _defaultApplicationMenuItems = [[NSArray arrayWithObjects: [NSMenuItem separatorItem], [NSMenuItem itemWithTitle: [NSString stringWithFormat:@"Preferences%C", 0x2026] action:@selector(preferences:) keyEquivalent:@","], [NSMenuItem separatorItem], [NSMenuItem itemWithTitle:@"Services" submenu:_servicesMenu], [NSMenuItem separatorItem], [NSMenuItem itemWithTitle: [NSString stringWithFormat:@"Hide %@", applicationName] action:@selector(hide:) keyEquivalent:@"h"], [NSMenuItem itemWithTitle:@"Hide Others" action:@selector(hideOtherApplications:) keyEquivalent:@"h" keyEquivalentModifierMask: NSCommandKeyMask|NSAlternateKeyMask], [NSMenuItem itemWithTitle:@"Show All" action:@selector(unhideAllApplications:)], [NSMenuItem separatorItem], [NSMenuItem itemWithTitle: [NSString stringWithFormat:@"Quit %@", applicationName] action: @selector(terminate:) keyEquivalent:@"q"], nil] retain]; _defaultApplicationMenu = [TKMenu menuWithTitle:applicationName menuItems:_defaultApplicationMenuItems]; [_defaultApplicationMenu insertItem: [NSMenuItem itemWithTitle: [NSString stringWithFormat:@"About %@", aboutName] action:@selector(orderFrontStandardAboutPanel:)] atIndex:0]; TKMenu *fileMenu = [TKMenu menuWithTitle:@"File" menuItems: [NSArray arrayWithObjects: [NSMenuItem itemWithTitle: [NSString stringWithFormat:@"Source%C", 0x2026] action:@selector(tkSource:)], [NSMenuItem itemWithTitle:@"Run Widget Demo" action:@selector(tkDemo:)], [NSMenuItem itemWithTitle:@"Close" action:@selector(performClose:) target:nil keyEquivalent:@"w"], nil]]; TKMenu *editMenu = [TKMenu menuWithTitle:@"Edit" menuItems: [NSArray arrayWithObjects: [NSMenuItem itemWithTitle:@"Undo" action:@selector(undo:) target:nil keyEquivalent:@"z"], [NSMenuItem itemWithTitle:@"Redo" action:@selector(redo:) target:nil keyEquivalent:@"y"], [NSMenuItem separatorItem], [NSMenuItem itemWithTitle:@"Cut" action:@selector(cut:) target:nil keyEquivalent:@"x"], [NSMenuItem itemWithTitle:@"Copy" action:@selector(copy:) target:nil keyEquivalent:@"c"], [NSMenuItem itemWithTitle:@"Paste" action:@selector(paste:) target:nil keyEquivalent:@"v"], [NSMenuItem itemWithTitle:@"Delete" action:@selector(delete:) target:nil], nil]]; _defaultWindowsMenuItems = [[NSArray arrayWithObjects: [NSMenuItem itemWithTitle:@"Minimize" action:@selector(performMiniaturize:) target:nil keyEquivalent:@"m"], [NSMenuItem itemWithTitle:@"Zoom" action:@selector(performZoom:) target:nil], [NSMenuItem separatorItem], [NSMenuItem itemWithTitle:@"Bring All to Front" action:@selector(arrangeInFront:)], nil] retain]; TKMenu *windowsMenu = [TKMenu menuWithTitle:@"Window" menuItems: _defaultWindowsMenuItems]; _defaultHelpMenuItems = [[NSArray arrayWithObjects: [NSMenuItem itemWithTitle: [NSString stringWithFormat:@"%@ Help", applicationName] action:@selector(showHelp:) keyEquivalent:@"?"], nil] retain]; TKMenu *helpMenu = [TKMenu menuWithTitle:@"Help" menuItems: _defaultHelpMenuItems]; [self setServicesMenu:_servicesMenu]; [self setWindowsMenu:windowsMenu]; _defaultMainMenu = [[TKMenu menuWithTitle:@"" submenus:[NSArray arrayWithObjects:_defaultApplicationMenu, fileMenu, editMenu, windowsMenu, helpMenu, nil]] retain]; [_defaultMainMenu setSpecial:tkMainMenu]; [_defaultApplicationMenu setSpecial:tkApplicationMenu]; [windowsMenu setSpecial:tkWindowsMenu]; [helpMenu setSpecial:tkHelpMenu]; [self tkSetMainMenu:nil]; } - (void)dealloc { [_defaultMainMenu release]; [_defaultHelpMenuItems release]; [_defaultWindowsMenuItems release]; [_defaultApplicationMenuItems release]; [super dealloc]; } - (BOOL)validateUserInterfaceItem:(id <NSValidatedUserInterfaceItem>)anItem { SEL action = [anItem action]; if (sel_isEqual(action, @selector(preferences:))) { Tcl_CmdInfo dummy; return (_eventInterp && Tcl_GetCommandInfo(_eventInterp, "::tk::mac::ShowPreferences", &dummy)); } else if (sel_isEqual(action, @selector(tkDemo:))) { BOOL haveDemo = NO; if (_eventInterp) { Tcl_Obj *path = GetWidgetDemoPath(_eventInterp); if (path) { Tcl_IncrRefCount(path); haveDemo = (Tcl_FSAccess(path, R_OK) == 0); Tcl_DecrRefCount(path); } } return haveDemo; } else { return [super validateUserInterfaceItem:anItem]; } } - (void)orderFrontStandardAboutPanel:(id)sender { Tcl_CmdInfo dummy; if (!_eventInterp || !Tcl_GetCommandInfo(_eventInterp, "tkAboutDialog", &dummy) || (GetCurrentEventKeyModifiers() & optionKey)) { TkAboutDlg(); } else { int code = Tcl_EvalEx(_eventInterp, "tkAboutDialog", -1, TCL_EVAL_GLOBAL); if (code != TCL_OK) { Tcl_BackgroundError(_eventInterp); } Tcl_ResetResult(_eventInterp); } } - (void)showHelp:(id)sender { Tcl_CmdInfo dummy; if (!_eventInterp || !Tcl_GetCommandInfo(_eventInterp, "::tk::mac::ShowHelp", &dummy)) { [super showHelp:sender]; } else { int code = Tcl_EvalEx(_eventInterp, "::tk::mac::ShowHelp", -1, TCL_EVAL_GLOBAL); if (code != TCL_OK) { Tcl_BackgroundError(_eventInterp); } Tcl_ResetResult(_eventInterp); } } - (void)tkSource:(id)sender { if (_eventInterp) { if (Tcl_EvalEx(_eventInterp, "tk_getOpenFile -filetypes {" "{{TCL Scripts} {.tcl} TEXT} {{Text Files} {} TEXT}}", -1, TCL_EVAL_GLOBAL) == TCL_OK) { Tcl_Obj *path = Tcl_GetObjResult(_eventInterp); int len; Tcl_GetStringFromObj(path, &len); if (len) { Tcl_IncrRefCount(path); int code = Tcl_FSEvalFile(_eventInterp, path); if (code != TCL_OK) { Tcl_BackgroundError(_eventInterp); } Tcl_DecrRefCount(path); } } Tcl_ResetResult(_eventInterp); } } - (void)tkDemo:(id)sender { if (_eventInterp) { Tcl_Obj *path = GetWidgetDemoPath(_eventInterp); if (path) { Tcl_IncrRefCount(path); int code = Tcl_FSEvalFile(_eventInterp, path); if (code != TCL_OK) { Tcl_BackgroundError(_eventInterp); } Tcl_DecrRefCount(path); Tcl_ResetResult(_eventInterp); } } } @end #pragma mark TKContentView(TKMenus) @implementation TKContentView(TKMenus) - (BOOL)validateUserInterfaceItem:(id <NSValidatedUserInterfaceItem>)anItem { return YES; } #define EDIT_ACTION(a, e) \ - (void) a:(id)sender { \ if ([sender isKindOfClass:[NSMenuItem class]]) { \ GenerateEditEvent(#e); \ } \ } EDIT_ACTION(cut, Cut) EDIT_ACTION(copy, Copy) EDIT_ACTION(paste, Paste) EDIT_ACTION(delete, Clear) EDIT_ACTION(undo, Undo) EDIT_ACTION(redo, Redo) #undef EDIT_ACTION @end #pragma mark - /* *---------------------------------------------------------------------- * * GetWidgetDemoPath -- * * Get path to the widget demo. * * Results: * pathObj with ref count 0. * * Side effects: * None. * *---------------------------------------------------------------------- */ static Tcl_Obj * GetWidgetDemoPath( Tcl_Interp *interp) { Tcl_Obj *libpath, *result = NULL; libpath = Tcl_GetVar2Ex(interp, "tk_library", NULL, TCL_GLOBAL_ONLY); if (libpath) { Tcl_Obj *demo[2] = { Tcl_NewStringObj("demos", 5), Tcl_NewStringObj("widget", 6) }; Tcl_IncrRefCount(libpath); result = Tcl_FSJoinToPath(libpath, 2, demo); Tcl_DecrRefCount(libpath); } else { Tcl_ResetResult(interp); } return result; } /* *---------------------------------------------------------------------- * |
︙ | ︙ | |||
89 90 91 92 93 94 95 | * None. * *---------------------------------------------------------------------- */ void TkMacOSXHandleMenuSelect( | | | < < < | < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < | 286 287 288 289 290 291 292 293 294 295 296 297 298 299 300 301 302 303 304 | * None. * *---------------------------------------------------------------------- */ void TkMacOSXHandleMenuSelect( short theMenu, unsigned short theItem, int optionKeyPressed) { Tcl_Panic("TkMacOSXHandleMenuSelect: Obsolete, no more Carbon!"); } /* *---------------------------------------------------------------------- * * TkMacOSXInitMenus -- * |
︙ | ︙ | |||
256 257 258 259 260 261 262 | *---------------------------------------------------------------------- */ void TkMacOSXInitMenus( Tcl_Interp *interp) { | < < < < < | < < < | < < < < | < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < | < < < < < < < < < < < < < | | | > | | < > > | < < < | < | < | | < < < | < < < < < < < < < < < > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > | 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 338 339 340 341 342 343 344 345 346 347 348 349 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 | *---------------------------------------------------------------------- */ void TkMacOSXInitMenus( Tcl_Interp *interp) { [NSApp _setupMenus]; } /* *---------------------------------------------------------------------- * * GenerateEditEvent -- * * Takes an edit menu item and posts the corasponding a virtual event to * Tk's event queue. * * Results: * None. * * Side effects: * May place events of queue. * *---------------------------------------------------------------------- */ static void GenerateEditEvent( const char *name) { XVirtualEvent event; int x, y; TkWindow *winPtr = TkMacOSXGetTkWindow([NSApp keyWindow]); Tk_Window tkwin = (Tk_Window) winPtr; if (tkwin == NULL) { return; } tkwin = (Tk_Window) winPtr->dispPtr->focusPtr; if (tkwin == NULL) { return; } bzero(&event, sizeof(XVirtualEvent)); event.type = VirtualEvent; event.serial = LastKnownRequestProcessed(Tk_Display(tkwin)); event.send_event = false; event.display = Tk_Display(tkwin); event.event = Tk_WindowId(tkwin); event.root = XRootWindow(Tk_Display(tkwin), 0); event.subwindow = None; event.time = TkpGetMS(); XQueryPointer(NULL, winPtr->window, NULL, NULL, &event.x_root, &event.y_root, &x, &y, &event.state); Tk_TopCoordsToWindow(tkwin, x, y, &event.x, &event.y); event.same_screen = true; event.name = Tk_GetUid(name); Tk_QueueWindowEvent((XEvent *) &event, TCL_QUEUE_TAIL); } #pragma mark - #pragma mark NSMenu & NSMenuItem Utilities @implementation NSMenu(TKUtils) + (id)menuWithTitle:(NSString *)title { NSMenu *m = [[self alloc] initWithTitle:title]; return [m autorelease]; } + (id)menuWithTitle:(NSString *)title menuItems:(NSArray *)items { NSMenu *m = [[self alloc] initWithTitle:title]; for (NSMenuItem *i in items) { [m addItem:i]; } return [m autorelease]; } + (id)menuWithTitle:(NSString *)title submenus:(NSArray *)submenus { NSMenu *m = [[self alloc] initWithTitle:title]; for (NSMenu *i in submenus) { [m addItem:[NSMenuItem itemWithSubmenu:i]]; } return [m autorelease]; } - (NSMenuItem *)itemWithSubmenu:(NSMenu *)submenu { return [self itemAtIndex:[self indexOfItemWithSubmenu:submenu]]; } - (NSMenuItem *)itemInSupermenu { NSMenu *supermenu = [self supermenu]; return (supermenu ? [supermenu itemWithSubmenu:self] : nil); } @end @implementation NSMenuItem(TKUtils) + (id)itemWithSubmenu:(NSMenu *)submenu { NSMenuItem *i = [[self alloc] initWithTitle:[submenu title] action:NULL keyEquivalent:@""]; [i setSubmenu:submenu]; return [i autorelease]; } + (id)itemWithTitle:(NSString *)title submenu:(NSMenu *)submenu { NSMenuItem *i = [[self alloc] initWithTitle:title action:NULL keyEquivalent:@""]; [i setSubmenu:submenu]; return [i autorelease]; } + (id)itemWithTitle:(NSString *)title action:(SEL)action { NSMenuItem *i = [[self alloc] initWithTitle:title action:action keyEquivalent:@""]; [i setTarget:NSApp]; return [i autorelease]; } + (id)itemWithTitle:(NSString *)title action:(SEL)action target:(id)target { NSMenuItem *i = [[self alloc] initWithTitle:title action:action keyEquivalent:@""]; [i setTarget:target]; return [i autorelease]; } + (id)itemWithTitle:(NSString *)title action:(SEL)action keyEquivalent:(NSString *)keyEquivalent { NSMenuItem *i = [[self alloc] initWithTitle:title action:action keyEquivalent:keyEquivalent]; [i setTarget:NSApp]; return [i autorelease]; } + (id)itemWithTitle:(NSString *)title action:(SEL)action target:(id)target keyEquivalent:(NSString *)keyEquivalent { NSMenuItem *i = [[self alloc] initWithTitle:title action:action keyEquivalent:keyEquivalent]; [i setTarget:target]; return [i autorelease]; } + (id)itemWithTitle:(NSString *)title action:(SEL)action keyEquivalent:(NSString *)keyEquivalent keyEquivalentModifierMask:(NSUInteger)keyEquivalentModifierMask { NSMenuItem *i = [[self alloc] initWithTitle:title action:action keyEquivalent:keyEquivalent]; [i setTarget:NSApp]; [i setKeyEquivalentModifierMask:keyEquivalentModifierMask]; return [i autorelease]; } + (id)itemWithTitle:(NSString *)title action:(SEL)action target:(id)target keyEquivalent:(NSString *)keyEquivalent keyEquivalentModifierMask:(NSUInteger)keyEquivalentModifierMask { NSMenuItem *i = [[self alloc] initWithTitle:title action:action keyEquivalent:keyEquivalent]; [i setTarget:target]; [i setKeyEquivalentModifierMask:keyEquivalentModifierMask]; return [i autorelease]; } @end /* * Local Variables: * mode: c * c-basic-offset: 4 * fill-column: 79 * coding: utf-8 * End: */ |
Changes to macosx/tkMacOSXMouseEvent.c.
1 2 3 | /* * tkMacOSXMouseEvent.c -- * | | | | | < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < | | | | | < < < < < < < < < < < < < < | < < | < | < < | < < | < < < < < < < < < < < < < | < < < < < < < < < < | < < < < < < < < < < | < < < < < < < < < < < < < < < < < < < | < < < < < < < | < < < < < < < < < < < < < < < < < | < > | < < < < < < < < < < | < | < < < < < | | < < < < < < < | < < | < | < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < | < < < < < < < < < < < < < < < < | > | < | < | | < < < < | < | < < < < < | < < < < < < < < < < | < < < | < < < < < < < < < | < < < | < < < < < | < < < | < < | < < < < | < < < < < < < < < | < < < | < < < < < < < < < | | | | < < < < | < < < < < < < < < < < < < < < < < < < < < < < < < < | < | | < < < < < < < < | < < < < < < < < < | < < < < < < | < | < < < < < < < < | < < < < < < < < | < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < | < < < < < | < < < < | < < < < | < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < | < < < | < < < < < < < < | < < < < < < | < < < < < | < < | < < | < | < < | < < < < < < < < < < < < < < < | < < | < < < < | | < < | < < < < < < < < < < < | > > > > > > > | < < < < < | < | < < > | > | > > > > > > > > > > > > > > > > > > > > | < < > > > | > | < < < < < > > | > | < < < | < < < > > > | > > | < < < > | > > > > | > > > | > | > > > | < < | > > > > > > > | < < < > > > | > > > > > > > > > > > > > | > > | | > | 1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 34 35 36 37 38 39 40 41 42 43 44 45 46 47 48 49 50 51 52 53 54 55 56 57 58 59 60 61 62 63 64 65 66 67 68 69 70 71 72 73 74 75 76 77 78 79 80 81 82 83 84 85 86 87 88 89 90 91 92 93 94 95 96 97 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 129 130 131 132 133 134 135 136 137 138 139 140 141 142 143 144 145 146 147 148 149 150 151 152 153 154 155 156 157 158 159 160 161 162 163 164 165 166 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 | /* * tkMacOSXMouseEvent.c -- * * This file implements functions that decode & handle mouse events on * MacOS X. * * Copyright 2001-2009, Apple Inc. * Copyright (c) 2005-2009 Daniel A. Steffen <[email protected]> * * See the file "license.terms" for information on usage and redistribution of * this file, and for a DISCLAIMER OF ALL WARRANTIES. */ #include "tkMacOSXPrivate.h" #include "tkMacOSXWm.h" #include "tkMacOSXEvent.h" #include "tkMacOSXDebug.h" typedef struct { unsigned int state; long delta; Window window; Point global; Point local; } MouseEventData; static int GenerateButtonEvent(MouseEventData *medPtr); static unsigned int ButtonModifiers2State(UInt32 buttonState, UInt32 keyModifiers); #pragma mark TKApplication(TKMouseEvent) enum { NSWindowWillMoveEventType = 20 }; @implementation TKApplication(TKMouseEvent) - (NSEvent *)tkProcessMouseEvent:(NSEvent *)theEvent { #ifdef TK_MAC_DEBUG_EVENTS TKLog(@"-[%@(%p) %s] %@", [self class], self, _cmd, theEvent); #endif id win; NSEventType type = [theEvent type]; #if 0 NSTrackingArea *trackingArea = nil; NSInteger eventNumber, clickCount, buttonNumber; #endif switch (type) { case NSMouseEntered: case NSMouseExited: case NSCursorUpdate: #if 0 trackingArea = [theEvent trackingArea]; #endif /* fall through */ case NSLeftMouseDown: case NSLeftMouseUp: case NSRightMouseDown: case NSRightMouseUp: case NSOtherMouseDown: case NSOtherMouseUp: case NSLeftMouseDragged: case NSRightMouseDragged: case NSOtherMouseDragged: case NSMouseMoved: #if 0 eventNumber = [theEvent eventNumber]; if (!trackingArea) { clickCount = [theEvent clickCount]; buttonNumber = [theEvent buttonNumber]; } #endif case NSTabletPoint: case NSTabletProximity: case NSScrollWheel: win = [self windowWithWindowNumber:[theEvent windowNumber]]; break; default: return theEvent; break; } NSPoint global, local = [theEvent locationInWindow]; if (win) { global = [win convertBaseToScreen:local]; local.y = [win frame].size.height - local.y; global.y = tkMacOSXZeroScreenHeight - global.y; } else { local.y = tkMacOSXZeroScreenHeight - local.y; global = local; } Window window = TkMacOSXGetXWindow(win); Tk_Window tkwin = window ? Tk_IdToWindow(TkGetDisplayList()->display, window) : NULL; if (!tkwin) { tkwin = TkMacOSXGetCapture(); } if (!tkwin) { return theEvent; } /* MacDrawable *macWin = (MacDrawable *) window; NSView *view = TkMacOSXDrawableView(macWin); local = [view convertPoint:local fromView:nil]; local.y = NSHeight([view bounds]) - local.y; */ TkWindow *winPtr = (TkWindow *) tkwin; local.x -= winPtr->wmInfoPtr->xInParent; local.y -= winPtr->wmInfoPtr->yInParent; int win_x, win_y; tkwin = Tk_TopCoordsToWindow(tkwin, local.x, local.y, &win_x, &win_y); unsigned int state = 0; NSInteger button = [theEvent buttonNumber]; EventRef eventRef = (EventRef)[theEvent eventRef]; UInt32 buttons; OSStatus err = GetEventParameter(eventRef, kEventParamMouseChord, typeUInt32, NULL, sizeof(UInt32), NULL, &buttons); if (err == noErr) { state |= (buttons & ((1<<5) - 1)) << 8; } else { if (button < 5) { switch (type) { case NSLeftMouseDown: case NSRightMouseDown: case NSLeftMouseDragged: case NSRightMouseDragged: case NSOtherMouseDown: state |= 1 << (button + 8); break; default: break; } } } NSUInteger modifiers = [theEvent modifierFlags]; if (modifiers & NSAlphaShiftKeyMask) { state |= LockMask; } if (modifiers & NSShiftKeyMask) { state |= ShiftMask; } if (modifiers & NSControlKeyMask) { state |= ControlMask; } if (modifiers & NSCommandKeyMask) { state |= Mod1Mask; /* command key */ } if (modifiers & NSAlternateKeyMask) { state |= Mod2Mask; /* option key */ } if (modifiers & NSNumericPadKeyMask) { state |= Mod3Mask; } if (modifiers & NSFunctionKeyMask) { state |= Mod4Mask; } if (type != NSScrollWheel) { #ifdef TK_MAC_DEBUG_EVENTS TKLog(@"UpdatePointer %p x %f.0 y %f.0 %d", tkwin, global.x, global.y, state); #endif Tk_UpdatePointer(tkwin, global.x, global.y, state); } else { CGFloat delta; int coarseDelta; XEvent xEvent; xEvent.type = MouseWheelEvent; xEvent.xbutton.x = local.x; xEvent.xbutton.y = local.y; xEvent.xbutton.x_root = global.x; xEvent.xbutton.y_root = global.y; xEvent.xany.send_event = false; xEvent.xany.display = Tk_Display(tkwin); xEvent.xany.window = Tk_WindowId(tkwin); delta = [theEvent deltaY]; if (delta != 0.0) { coarseDelta = (delta > -1.0 && delta < 1.0) ? (signbit(delta) ? -1 : 1) : lround(delta); xEvent.xbutton.state = state; xEvent.xkey.keycode = coarseDelta; xEvent.xany.serial = LastKnownRequestProcessed(Tk_Display(tkwin)); Tk_QueueWindowEvent(&xEvent, TCL_QUEUE_TAIL); } delta = [theEvent deltaX]; if (delta != 0.0) { coarseDelta = (delta > -1.0 && delta < 1.0) ? (signbit(delta) ? -1 : 1) : lround(delta); xEvent.xbutton.state = state | ShiftMask; xEvent.xkey.keycode = coarseDelta; xEvent.xany.serial = LastKnownRequestProcessed(Tk_Display(tkwin)); Tk_QueueWindowEvent(&xEvent, TCL_QUEUE_TAIL); } } return theEvent; } @end #pragma mark - /* *---------------------------------------------------------------------- * * TkMacOSXKeyModifiers -- * * Returns the current state of the modifier keys. |
︙ | ︙ | |||
775 776 777 778 779 780 781 | { UInt32 keyModifiers; int isFrontProcess = (GetCurrentEvent() && Tk_MacOSXIsAppInFront()); keyModifiers = isFrontProcess ? GetCurrentEventKeyModifiers() : GetCurrentKeyModifiers(); | | | | < | | < | 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 256 257 258 259 260 261 262 263 264 265 266 267 268 269 270 271 272 | { UInt32 keyModifiers; int isFrontProcess = (GetCurrentEvent() && Tk_MacOSXIsAppInFront()); keyModifiers = isFrontProcess ? GetCurrentEventKeyModifiers() : GetCurrentKeyModifiers(); return (EventModifiers) (keyModifiers & USHRT_MAX); } /* *---------------------------------------------------------------------- * * TkMacOSXButtonKeyState -- * * Returns the current state of the button & modifier keys. * * Results: * A bitwise inclusive OR of a subset of the following: Button1Mask, * ShiftMask, LockMask, ControlMask, Mod*Mask. * * Side effects: * None. * *---------------------------------------------------------------------- */ unsigned int TkMacOSXButtonKeyState(void) { UInt32 buttonState = 0, keyModifiers; int isFrontProcess = (GetCurrentEvent() && Tk_MacOSXIsAppInFront()); buttonState = isFrontProcess ? GetCurrentEventButtonState() : GetCurrentButtonState(); keyModifiers = isFrontProcess ? GetCurrentEventKeyModifiers() : GetCurrentKeyModifiers(); return ButtonModifiers2State(buttonState, keyModifiers); } /* |
︙ | ︙ | |||
829 830 831 832 833 834 835 | * Side effects: * None. * *---------------------------------------------------------------------- */ static unsigned int | | > > > | > > | 283 284 285 286 287 288 289 290 291 292 293 294 295 296 297 298 299 300 301 302 303 304 305 306 | * Side effects: * None. * *---------------------------------------------------------------------- */ static unsigned int ButtonModifiers2State( UInt32 buttonState, UInt32 keyModifiers) { unsigned int state; /* * Tk supports at most 5 buttons. */ state = (buttonState & ((1<<5) - 1)) << 8; if (keyModifiers & alphaLock) { state |= LockMask; } if (keyModifiers & shiftKey) { state |= ShiftMask; |
︙ | ︙ | |||
867 868 869 870 871 872 873 | /* *---------------------------------------------------------------------- * * XQueryPointer -- * * Check the current state of the mouse. This is not a complete | | | | | | | | | | | | | | < < < < | < < < < | < < < < < < < < < < < < < | < < | | < | < | < < < | < | > | | > > > | | < < < < | | | | | | < | | | | | | | | | | > > < < | > > > > > > > > > > > > | | | | | > | | < | > > < < | < | < < | | < < | < | < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < | 326 327 328 329 330 331 332 333 334 335 336 337 338 339 340 341 342 343 344 345 346 347 348 349 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 | /* *---------------------------------------------------------------------- * * XQueryPointer -- * * Check the current state of the mouse. This is not a complete * implementation of this function. It only computes the root coordinates * and the current mask. * * Results: * Sets root_x_return, root_y_return, and mask_return. Returns true on * success. * * Side effects: * None. * *---------------------------------------------------------------------- */ Bool XQueryPointer( Display *display, Window w, Window *root_return, Window *child_return, int *root_x_return, int *root_y_return, int *win_x_return, int *win_y_return, unsigned int *mask_return) { int getGlobal = (root_x_return && root_y_return); int getLocal = (win_x_return && win_y_return && w != None); if (getGlobal || getLocal) { NSPoint global = [NSEvent mouseLocation]; if (getLocal) { MacDrawable *macWin = (MacDrawable *) w; NSWindow *win = TkMacOSXDrawableWindow(w); if (win) { NSPoint local; local = [win convertScreenToBase:global]; local.y = [win frame].size.height - local.y; if (macWin->winPtr && macWin->winPtr->wmInfoPtr) { local.x -= macWin->winPtr->wmInfoPtr->xInParent; local.y -= macWin->winPtr->wmInfoPtr->yInParent; } *win_x_return = local.x; *win_y_return = local.y; } } if (getGlobal) { *root_x_return = global.x; *root_y_return = tkMacOSXZeroScreenHeight - global.y; } } if (mask_return) { *mask_return = TkMacOSXButtonKeyState(); } return True; } /* *---------------------------------------------------------------------- * * TkGenerateButtonEventForXPointer -- * * This procedure generates an X button event for the current pointer * state as reported by XQueryPointer(). * * Results: * True if event(s) are generated - false otherwise. * * Side effects: * Additional events may be place on the Tk event queue. Grab state may * also change. * *---------------------------------------------------------------------- */ MODULE_SCOPE int TkGenerateButtonEventForXPointer( Window window) /* X Window containing button event. */ { MouseEventData med; int global_x, global_y, local_x, local_y; bzero(&med, sizeof(MouseEventData)); XQueryPointer(NULL, window, NULL, NULL, &global_x, &global_y, &local_x, &local_y, &med.state); med.global.h = global_x; med.global.v = global_y; med.local.h = local_x; med.local.v = local_y; med.window = window; return GenerateButtonEvent(&med); } /* *---------------------------------------------------------------------- * * TkGenerateButtonEvent -- * * Given a global x & y position and the button key status this procedure * generates the appropiate X button event. It also handles the state * changes needed to implement implicit grabs. * * Results: * True if event(s) are generated, false otherwise. * * Side effects: * Additional events may be place on the Tk event queue. Grab state may * also change. * *---------------------------------------------------------------------- */ int TkGenerateButtonEvent( int x, /* X location of mouse, */ int y, /* Y location of mouse. */ Window window, /* X Window containing button event. */ unsigned int state) /* Button Key state suitable for X event. */ { MacDrawable *macWin = (MacDrawable *) window; NSWindow *win = TkMacOSXDrawableWindow(window); MouseEventData med; bzero(&med, sizeof(MouseEventData)); med.state = state; med.window = window; med.global.h = x; med.global.v = y; med.local = med.global; if (win) { NSPoint local = NSMakePoint(x, tkMacOSXZeroScreenHeight - y); local = [win convertScreenToBase:local]; local.y = [win frame].size.height - local.y; if (macWin->winPtr && macWin->winPtr->wmInfoPtr) { local.x -= macWin->winPtr->wmInfoPtr->xInParent; local.y -= macWin->winPtr->wmInfoPtr->yInParent; } med.local.h = local.x; med.local.v = tkMacOSXZeroScreenHeight - local.y; } return GenerateButtonEvent(&med); } /* *---------------------------------------------------------------------- * * GenerateButtonEvent -- * * Generate an X button event from a MouseEventData structure. Handles * the state changes needed to implement implicit grabs. * * Results: * True if event(s) are generated - false otherwise. * * Side effects: * Additional events may be place on the Tk event queue. Grab state may * also change. * *---------------------------------------------------------------------- */ static int GenerateButtonEvent( MouseEventData *medPtr) { Tk_Window tkwin; int dummy; TkDisplay *dispPtr; #if UNUSED /* * ButtonDown events will always occur in the front window. ButtonUp * events, however, may occur anywhere on the screen. ButtonUp events * should only be sent to Tk if in the front window or during an implicit * grab. */ if ((medPtr->activeNonFloating == NULL) || ((!(TkpIsWindowFloating(medPtr->whichWin)) && (medPtr->activeNonFloating != medPtr->whichWin)) && TkMacOSXGetCapture() == NULL)) { return false; } #endif dispPtr = TkGetDisplayList(); tkwin = Tk_IdToWindow(dispPtr->display, medPtr->window); if (tkwin != NULL) { tkwin = Tk_TopCoordsToWindow(tkwin, medPtr->local.h, medPtr->local.v, &dummy, &dummy); } Tk_UpdatePointer(tkwin, medPtr->global.h, medPtr->global.v, medPtr->state); return true; } /* * Local Variables: * mode: c * c-basic-offset: 4 * fill-column: 79 * coding: utf-8 * End: */ |
Changes to macosx/tkMacOSXNotify.c.
1 2 3 4 | /* * tkMacOSXNotify.c -- * * This file contains the implementation of a tcl event source | | | | > | < < < < | > > > > | | > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > | > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > | < < | > | > | < < < < < < < | < < | < > | | > > > | 1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 34 35 36 37 38 39 40 41 42 43 44 45 46 47 48 49 50 51 52 53 54 55 56 57 58 59 60 61 62 63 64 65 66 67 68 69 70 71 72 73 74 75 76 77 78 79 80 81 82 83 84 85 86 87 88 89 90 91 92 93 94 95 96 97 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 129 130 131 132 133 134 135 136 137 138 139 140 141 142 143 144 145 146 147 148 149 150 151 152 153 154 155 156 157 158 159 160 161 162 163 164 165 166 | /* * tkMacOSXNotify.c -- * * This file contains the implementation of a tcl event source * for the AppKit event loop. * * Copyright (c) 1995-1997 Sun Microsystems, Inc. * Copyright 2001-2009, Apple Inc. * Copyright (c) 2005-2009 Daniel A. Steffen <[email protected]> * * See the file "license.terms" for information on usage and redistribution * of this file, and for a DISCLAIMER OF ALL WARRANTIES. */ #include "tkMacOSXPrivate.h" #include "tkMacOSXEvent.h" #include <tclInt.h> #include <pthread.h> #import <objc/objc-auto.h> typedef struct ThreadSpecificData { int initialized, sendEventNestingLevel; NSEvent *currentEvent; } ThreadSpecificData; static Tcl_ThreadDataKey dataKey; #define TSD_INIT() ThreadSpecificData *tsdPtr = Tcl_GetThreadData(&dataKey, \ sizeof(ThreadSpecificData)) static void TkMacOSXNotifyExitHandler(ClientData clientData); static void TkMacOSXEventsSetupProc(ClientData clientData, int flags); static void TkMacOSXEventsCheckProc(ClientData clientData, int flags); #pragma mark TKApplication(TKNotify) @interface NSApplication(TKNotify) - (void)_modalSession:(NSModalSession)session sendEvent:(NSEvent *)event; @end @implementation NSWindow(TKNotify) - (id)tkDisplayIfNeeded { if (![self isAutodisplay]) { [self displayIfNeeded]; } return nil; } @end @implementation TKApplication(TKNotify) - (NSEvent *)nextEventMatchingMask:(NSUInteger)mask untilDate:(NSDate *)expiration inMode:(NSString *)mode dequeue:(BOOL)deqFlag { NSAutoreleasePool *pool = [NSAutoreleasePool new]; [NSApp makeWindowsPerform:@selector(tkDisplayIfNeeded) inOrder:NO]; int oldMode = Tcl_SetServiceMode(TCL_SERVICE_ALL); NSEvent *event = [[super nextEventMatchingMask:mask untilDate:expiration inMode:mode dequeue:deqFlag] retain]; Tcl_SetServiceMode(oldMode); if (event) { TSD_INIT(); if (tsdPtr->sendEventNestingLevel) { if (![NSApp tkProcessEvent:event]) { [event release]; event = nil; } } } [pool drain]; return [event autorelease]; } - (void)sendEvent:(NSEvent *)theEvent { TSD_INIT(); int oldMode = Tcl_SetServiceMode(TCL_SERVICE_ALL); tsdPtr->sendEventNestingLevel++; [super sendEvent:theEvent]; tsdPtr->sendEventNestingLevel--; Tcl_SetServiceMode(oldMode); [NSApp tkCheckPasteboard]; } @end #pragma mark - /* *---------------------------------------------------------------------- * * GetRunLoopMode -- * * Results: * RunLoop mode that should be passed to -nextEventMatchingMask: * * Side effects: * None. * *---------------------------------------------------------------------- */ static NSString * GetRunLoopMode(NSModalSession modalSession) { NSString *runLoopMode = nil; if (modalSession) { runLoopMode = NSModalPanelRunLoopMode; } else if (TkMacOSXGetCapture()) { runLoopMode = NSEventTrackingRunLoopMode; } if (!runLoopMode) { runLoopMode = [[NSRunLoop currentRunLoop] currentMode]; } if (!runLoopMode) { runLoopMode = NSDefaultRunLoopMode; } return runLoopMode; } /* *---------------------------------------------------------------------- * * Tk_MacOSXSetupTkNotifier -- * * This procedure is called during Tk initialization to create * the event source for TkAqua events. * * Results: * None. * * Side effects: * A new event source is created. * *---------------------------------------------------------------------- */ void Tk_MacOSXSetupTkNotifier(void) { TSD_INIT(); if (!tsdPtr->initialized) { tsdPtr->initialized = 1; /* * Install TkAqua event source in main event loop thread. */ if (CFRunLoopGetMain() == CFRunLoopGetCurrent()) { if (!pthread_main_np()) { /* * Panic if main runloop is not on the main application thread. */ Tcl_Panic("Tk_MacOSXSetupTkNotifier: %s", "first [load] of TkAqua has to occur in the main thread!"); } Tcl_CreateEventSource(TkMacOSXEventsSetupProc, TkMacOSXEventsCheckProc, GetMainEventQueue()); TkCreateExitHandler(TkMacOSXNotifyExitHandler, NULL); Tcl_SetServiceMode(TCL_SERVICE_ALL); TclMacOSXNotifierAddRunLoopMode(NSEventTrackingRunLoopMode); TclMacOSXNotifierAddRunLoopMode(NSModalPanelRunLoopMode); } } } /* *---------------------------------------------------------------------- * |
︙ | ︙ | |||
97 98 99 100 101 102 103 | * Side effects: * None. * *---------------------------------------------------------------------- */ static void | | | < < | | | | | | | | | | | | > > | > | > > > > | > > | | | | > | | < | | | | > > | > > | > > > > | > > | > > > > > | | > > > > > > > > | | > > > > > > > | | < | | > > | < < > > > > > > > > > | 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 224 225 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 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 284 285 286 287 288 289 290 291 292 293 294 295 296 297 298 299 300 301 302 303 304 305 306 307 308 309 310 311 312 | * Side effects: * None. * *---------------------------------------------------------------------- */ static void TkMacOSXNotifyExitHandler( ClientData clientData) /* Not used. */ { TSD_INIT(); Tcl_DeleteEventSource(TkMacOSXEventsSetupProc, TkMacOSXEventsCheckProc, GetMainEventQueue()); tsdPtr->initialized = 0; } /* *---------------------------------------------------------------------- * * TkMacOSXEventsSetupProc -- * * This procedure implements the setup part of the TkAqua Events event * source. It is invoked by Tcl_DoOneEvent before entering the notifier * to check for events. * * Results: * None. * * Side effects: * If TkAqua events are queued, then the maximum block time will be set * to 0 to ensure that the notifier returns control to Tcl. * *---------------------------------------------------------------------- */ static void TkMacOSXEventsSetupProc( ClientData clientData, int flags) { if (flags & TCL_WINDOW_EVENTS && ![[NSRunLoop currentRunLoop] currentMode]) { static Tcl_Time zeroBlockTime = { 0, 0 }; TSD_INIT(); if (!tsdPtr->currentEvent) { NSEvent *currentEvent = [NSApp nextEventMatchingMask:NSAnyEventMask untilDate:[NSDate distantPast] inMode:GetRunLoopMode(TkMacOSXGetModalSession()) dequeue:YES]; if (currentEvent) { tsdPtr->currentEvent = TkMacOSXMakeUncollectableAndRetain(currentEvent); } } if (tsdPtr->currentEvent) { Tcl_SetMaxBlockTime(&zeroBlockTime); } } } /* *---------------------------------------------------------------------- * * TkMacOSXEventsCheckProc -- * * This procedure processes events sitting in the TkAqua event queue. * * Results: * None. * * Side effects: * Moves applicable queued TkAqua events onto the Tcl event queue. * *---------------------------------------------------------------------- */ static void TkMacOSXEventsCheckProc( ClientData clientData, int flags) { if (flags & TCL_WINDOW_EVENTS && ![[NSRunLoop currentRunLoop] currentMode]) { NSEvent *currentEvent = nil; NSAutoreleasePool *pool = nil; NSModalSession modalSession; TSD_INIT(); if (tsdPtr->currentEvent) { currentEvent = TkMacOSXMakeCollectableAndAutorelease( tsdPtr->currentEvent); } do { modalSession = TkMacOSXGetModalSession(); if (!currentEvent) { currentEvent = [NSApp nextEventMatchingMask:NSAnyEventMask untilDate:[NSDate distantPast] inMode:GetRunLoopMode(modalSession) dequeue:YES]; } if (!currentEvent) { break; } [currentEvent retain]; pool = [NSAutoreleasePool new]; if (tkMacOSXGCEnabled) { objc_clear_stack(0); } if (![NSApp tkProcessEvent:currentEvent]) { [currentEvent release]; currentEvent = nil; } if (currentEvent) { #ifdef TK_MAC_DEBUG_EVENTS TKLog(@" event: %@", currentEvent); #endif if (modalSession) { [NSApp _modalSession:modalSession sendEvent:currentEvent]; } else { [NSApp sendEvent:currentEvent]; } [currentEvent release]; currentEvent = nil; } [pool drain]; pool = nil; } while (1); } } /* * Local Variables: * mode: c * c-basic-offset: 4 * fill-column: 79 * coding: utf-8 * End: */ |
Changes to macosx/tkMacOSXPort.h.
1 2 3 4 5 6 7 8 | /* * tkMacOSXPort.h -- * * This file is included by all of the Tk C files. It contains * information that may be configuration-dependent, such as * #includes for system include files and a few other things. * * Copyright (c) 1994-1996 Sun Microsystems, Inc. | | | | 1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 | /* * tkMacOSXPort.h -- * * This file is included by all of the Tk C files. It contains * information that may be configuration-dependent, such as * #includes for system include files and a few other things. * * Copyright (c) 1994-1996 Sun Microsystems, Inc. * Copyright 2001-2009, Apple Inc. * Copyright (c) 2005-2009 Daniel A. Steffen <[email protected]> * * See the file "license.terms" for information on usage and redistribution * of this file, and for a DISCLAIMER OF ALL WARRANTIES. */ #ifndef _TKMACPORT #define _TKMACPORT |
︙ | ︙ | |||
136 137 138 139 140 141 142 | /* * The following functions are not used on the Mac, so we stub them out. */ #define TkFreeWindowId(dispPtr,w) #define TkInitXId(dispPtr) | < | 136 137 138 139 140 141 142 143 144 145 146 147 148 149 | /* * The following functions are not used on the Mac, so we stub them out. */ #define TkFreeWindowId(dispPtr,w) #define TkInitXId(dispPtr) #define TkpCmapStressed(tkwin,colormap) (0) #define TkpFreeColor(tkColPtr) #define TkSetPixmapColormap(p,c) {} #define TkpSync(display) /* * The following macro returns the pixel value that corresponds to the |
︙ | ︙ |
Changes to macosx/tkMacOSXPrivate.h.
1 2 3 4 5 | /* * tkMacOSXPrivate.h -- * * Macros and declarations that are purely internal & private to TkAqua. * | | > > > > > > > > > > > > > > | < < < < < | < < < < < < < < < < < < < < < < < < < < < < | < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < | 1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 34 35 36 37 38 39 40 41 42 | /* * tkMacOSXPrivate.h -- * * Macros and declarations that are purely internal & private to TkAqua. * * Copyright (c) 2005-2009 Daniel A. Steffen <[email protected]> * Copyright 2008-2009, Apple Inc. * * See the file "license.terms" for information on usage and redistribution * of this file, and for a DISCLAIMER OF ALL WARRANTIES. */ #ifndef _TKMACPRIV #define _TKMACPRIV #if !__OBJC__ #error Objective-C compiler required #endif #define TextStyle MacTextStyle #import <ApplicationServices/ApplicationServices.h> #import <Cocoa/Cocoa.h> #ifndef NO_CARBON_H #import <Carbon/Carbon.h> #endif #undef TextStyle #import <objc/runtime.h> /* for sel_isEqual() */ #ifndef _TKMACINT #include "tkMacOSXInt.h" #endif #ifndef _TKMACDEFAULT #include "tkMacOSXDefault.h" #endif /* Macros for Mac OS X API availability checking */ #define TK_IF_MAC_OS_X_API(vers, symbol, ...) \ tk_if_mac_os_x_10_##vers(symbol != NULL, 1, __VA_ARGS__) #define TK_ELSE_MAC_OS_X(vers, ...) \ tk_else_mac_os_x_10_##vers(__VA_ARGS__) #define TK_IF_MAC_OS_X_API_COND(vers, symbol, cond, ...) \ tk_if_mac_os_x_10_##vers(symbol != NULL, cond, __VA_ARGS__) |
︙ | ︙ | |||
106 107 108 109 110 111 112 | #define tk_else_mac_os_x_chk(...) \ } else { __VA_ARGS__ #define tk_if_mac_os_x_no(chk, cond, ...) \ if (0) { #define tk_else_mac_os_x_no(...) \ } else { __VA_ARGS__ /* Private mapping macros defined according to Mac OS X version requirements */ | < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < | 54 55 56 57 58 59 60 61 62 63 64 65 66 67 | #define tk_else_mac_os_x_chk(...) \ } else { __VA_ARGS__ #define tk_if_mac_os_x_no(chk, cond, ...) \ if (0) { #define tk_else_mac_os_x_no(...) \ } else { __VA_ARGS__ /* Private mapping macros defined according to Mac OS X version requirements */ /* 10.5 Leopard */ #if MAC_OS_X_VERSION_MIN_REQUIRED >= 1050 #define tk_if_mac_os_x_min_10_5 tk_if_mac_os_x_yes #define tk_else_mac_os_x_min_10_5 tk_else_mac_os_x_yes #if MAC_OS_X_VERSION_MAX_ALLOWED >= 1050 #define tk_if_mac_os_x_10_5 tk_if_mac_os_x_yes #define tk_else_mac_os_x_10_5 tk_else_mac_os_x_yes |
︙ | ︙ | |||
181 182 183 184 185 186 187 188 189 190 | #define COMPONENT_SIGNATURE 'Tk ' /* * Macros abstracting checks only active in a debug build. */ #ifdef TK_MAC_DEBUG /* * Macro to do debug message output. */ | > > | > | | | > < | > | | | < < < < < | < < < < < < < > < | | > > > | > > > > > > > > > > > > | < < < | | > > | > > | > | | | | > | | | | | > | | | | | | | | > > | < | < > | | | | < < < < | | | | | | < | | | > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > | > | > | > | > > > > > > > > > | > > > > > > > > > > > > | > > > > > > > > > > > > > > > > | > > > > > > > > | > > > | > | > | > | > > > > > > > | > > > > > > > > > > > > > > > > > | > > > > | 89 90 91 92 93 94 95 96 97 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 129 130 131 132 133 134 135 136 137 138 139 140 141 142 143 144 145 146 147 148 149 150 151 152 153 154 155 156 157 158 159 160 161 162 163 164 165 166 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 224 225 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 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 284 285 286 287 288 289 290 291 292 293 294 295 296 297 298 299 300 301 302 303 304 305 306 307 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 338 339 340 341 342 343 344 345 346 347 348 349 350 351 352 353 354 355 356 357 358 359 360 361 362 363 364 365 366 | #define COMPONENT_SIGNATURE 'Tk ' /* * Macros abstracting checks only active in a debug build. */ #ifdef TK_MAC_DEBUG #define TKLog(f, ...) NSLog(f, ##__VA_ARGS__) /* * Macro to do debug message output. */ #define TkMacOSXDbgMsg(m, ...) \ do { \ TKLog(@"%s:%d: %s(): " m, strrchr(__FILE__, '/')+1, \ __LINE__, __func__, ##__VA_ARGS__); \ } while (0) /* * Macro to do debug API failure message output. */ #define TkMacOSXDbgOSErr(f, err) \ do { \ TkMacOSXDbgMsg("%s failed: %d", #f, (int)(err)); \ } while (0) /* * Macro to do very common check for noErr return from given API and output * debug message in case of failure. */ #define ChkErr(f, ...) ({ \ OSStatus err = f(__VA_ARGS__); \ if (err != noErr) { \ TkMacOSXDbgOSErr(f, err); \ } \ err;}) #else /* TK_MAC_DEBUG */ #define TKLog(f, ...) #define TkMacOSXDbgMsg(m, ...) #define TkMacOSXDbgOSErr(f, err) #define ChkErr(f, ...) ({f(__VA_ARGS__);}) #endif /* TK_MAC_DEBUG */ /* * Macro abstracting use of TkMacOSXGetNamedSymbol to init named symbols. */ #define TkMacOSXInitNamedSymbol(module, ret, symbol, ...) \ static ret (* symbol)(__VA_ARGS__) = (void*)(-1L); \ if (symbol == (void*)(-1L)) { \ symbol = TkMacOSXGetNamedSymbol(STRINGIFY(module), \ STRINGIFY(symbol)); \ } /* * Macros for GC */ #define TkMacOSXMakeUncollectable(x) ({ id o = (id)(x); \ if (o) { if(tkMacOSXGCEnabled) CFRetain(o); } o; }) #define TkMacOSXMakeUncollectableAndRetain(x) ({ id o = (id)(x); \ if (o) { if(tkMacOSXGCEnabled) CFRetain(o); else [o retain]; } o; }) #define TkMacOSXMakeCollectable(x) ({ id o = (id)(x); \ if (o) { x = nil; if (tkMacOSXGCEnabled) CFRelease(o); } o; }) #define TkMacOSXMakeCollectableAndRelease(x) ({ id o = (id)(x); \ if (o) { x = nil; if (tkMacOSXGCEnabled) CFRelease(o); \ else [o release]; } o; }) #define TkMacOSXMakeCollectableAndAutorelease(x) ({ id o = (id)(x); \ if (o) { x = nil; if (tkMacOSXGCEnabled) CFRelease(o); \ else [o autorelease]; } o; }) /* * Structure encapsulating current drawing environment. */ typedef struct TkMacOSXDrawingContext { CGContextRef context; NSView *view; HIShapeRef clipRgn; CGRect portBounds; int focusLocked; } TkMacOSXDrawingContext; /* * Variables internal to TkAqua. */ MODULE_SCOPE CGFloat tkMacOSXZeroScreenHeight; MODULE_SCOPE CGFloat tkMacOSXZeroScreenTop; MODULE_SCOPE int tkMacOSXGCEnabled; MODULE_SCOPE long tkMacOSXMacOSXVersion; #if TK_MAC_BUTTON_USE_COMPATIBILITY_METRICS MODULE_SCOPE int tkMacOSXUseCompatibilityMetrics; #endif /* * Prototypes for TkMacOSXRegion.c. */ #if 0 MODULE_SCOPE void TkMacOSXEmtpyRegion(TkRegion r); MODULE_SCOPE int TkMacOSXIsEmptyRegion(TkRegion r); #endif MODULE_SCOPE HIShapeRef TkMacOSXGetNativeRegion(TkRegion r); MODULE_SCOPE void TkMacOSXSetWithNativeRegion(TkRegion r, HIShapeRef rgn); MODULE_SCOPE void TkMacOSXOffsetRegion(TkRegion r, short dx, short dy); MODULE_SCOPE HIShapeRef TkMacOSXHIShapeCreateEmpty(void); MODULE_SCOPE HIMutableShapeRef TkMacOSXHIShapeCreateMutableWithRect( const CGRect *inRect); MODULE_SCOPE OSStatus TkMacOSXHIShapeSetWithShape( HIMutableShapeRef inDestShape, HIShapeRef inSrcShape); #if 0 MODULE_SCOPE OSStatus TkMacOSXHIShapeSetWithRect(HIMutableShapeRef inShape, const CGRect *inRect); #endif MODULE_SCOPE OSStatus TkMacOSHIShapeDifferenceWithRect( HIMutableShapeRef inShape, const CGRect *inRect); MODULE_SCOPE OSStatus TkMacOSHIShapeUnionWithRect(HIMutableShapeRef inShape, const CGRect *inRect); MODULE_SCOPE OSStatus TkMacOSHIShapeUnion(HIShapeRef inShape1, HIShapeRef inShape2, HIMutableShapeRef outResult); /* * Prototypes of TkAqua internal procs. */ MODULE_SCOPE void * TkMacOSXGetNamedSymbol(const char *module, const char *symbol); MODULE_SCOPE void TkMacOSXDisplayChanged(Display *display); MODULE_SCOPE int TkMacOSXUseAntialiasedText(Tcl_Interp *interp, int enable); MODULE_SCOPE int TkMacOSXInitCGDrawing(Tcl_Interp *interp, int enable, int antiAlias); MODULE_SCOPE int TkMacOSXGenerateFocusEvent(TkWindow *winPtr, int activeFlag); MODULE_SCOPE WindowClass TkMacOSXWindowClass(TkWindow *winPtr); MODULE_SCOPE int TkMacOSXIsWindowZoomed(TkWindow *winPtr); MODULE_SCOPE int TkGenerateButtonEventForXPointer(Window window); MODULE_SCOPE EventModifiers TkMacOSXModifierState(void); MODULE_SCOPE int TkMacOSXSetupDrawingContext(Drawable d, GC gc, int useCG, TkMacOSXDrawingContext *dcPtr); MODULE_SCOPE void TkMacOSXRestoreDrawingContext( TkMacOSXDrawingContext *dcPtr); MODULE_SCOPE void TkMacOSXSetColorInContext(GC gc, unsigned long pixel, CGContextRef context); MODULE_SCOPE int TkMacOSXMakeFullscreen(TkWindow *winPtr, NSWindow *window, int fullscreen, Tcl_Interp *interp); MODULE_SCOPE void TkMacOSXEnterExitFullscreen(TkWindow *winPtr, int active); MODULE_SCOPE NSWindow* TkMacOSXDrawableWindow(Drawable drawable); MODULE_SCOPE NSView* TkMacOSXDrawableView(MacDrawable *macWin); MODULE_SCOPE void TkMacOSXWinCGBounds(TkWindow *winPtr, CGRect *bounds); MODULE_SCOPE HIShapeRef TkMacOSXGetClipRgn(Drawable drawable); MODULE_SCOPE void TkMacOSXInvalidateViewRegion(NSView *view, HIShapeRef rgn); MODULE_SCOPE CGImageRef TkMacOSXCreateCGImageWithDrawable(Drawable drawable); MODULE_SCOPE NSImage* TkMacOSXGetNSImageWithTkImage(Display *display, Tk_Image image, int width, int height); MODULE_SCOPE NSImage* TkMacOSXGetNSImageWithBitmap(Display *display, Pixmap bitmap, GC gc, int width, int height); MODULE_SCOPE CGColorRef TkMacOSXCreateCGColor(GC gc, unsigned long pixel); MODULE_SCOPE NSColor* TkMacOSXGetNSColor(GC gc, unsigned long pixel); MODULE_SCOPE Tcl_Obj * TkMacOSXGetStringObjFromCFString(CFStringRef str); MODULE_SCOPE TkWindow* TkMacOSXGetTkWindow(NSWindow *w); MODULE_SCOPE NSFont* TkMacOSXNSFontForFont(Tk_Font tkfont); MODULE_SCOPE NSDictionary* TkMacOSXNSFontAttributesForFont(Tk_Font tkfont); MODULE_SCOPE NSModalSession TkMacOSXGetModalSession(void); MODULE_SCOPE void TkMacOSXSelDeadWindow(TkWindow *winPtr); MODULE_SCOPE void TkMacOSXApplyWindowAttributes(TkWindow *winPtr, NSWindow *macWindow); MODULE_SCOPE int TkMacOSXStandardAboutPanelObjCmd(ClientData clientData, Tcl_Interp *interp, int objc, Tcl_Obj *const objv[]); MODULE_SCOPE int TkMacOSXIconBitmapObjCmd(ClientData clientData, Tcl_Interp *interp, int objc, Tcl_Obj *const objv[]); #pragma mark Private Objective-C Classes #define VISIBILITY_HIDDEN __attribute__((visibility("hidden"))) enum { tkMainMenu = 1, tkApplicationMenu, tkWindowsMenu, tkHelpMenu}; VISIBILITY_HIDDEN @interface TKMenu : NSMenu { @private void *_tkMenu; NSUInteger _tkOffset, _tkItemCount, _tkSpecial; } - (void)setSpecial:(NSUInteger)special; - (BOOL)isSpecial:(NSUInteger)special; @end VISIBILITY_HIDDEN @interface TKApplication : NSApplication { @private Tcl_Interp *_eventInterp; NSMenu *_servicesMenu; TKMenu *_defaultMainMenu, *_defaultApplicationMenu; NSArray *_defaultApplicationMenuItems, *_defaultWindowsMenuItems; NSArray *_defaultHelpMenuItems; } @end @interface TKApplication(TKInit) - (NSString *)tkFrameworkImagePath:(NSString*)image; @end @interface TKApplication(TKEvent) - (NSEvent *)tkProcessEvent:(NSEvent *)theEvent; @end @interface TKApplication(TKMouseEvent) - (NSEvent *)tkProcessMouseEvent:(NSEvent *)theEvent; @end @interface TKApplication(TKKeyEvent) - (NSEvent *)tkProcessKeyEvent:(NSEvent *)theEvent; @end @interface TKApplication(TKMenu) - (void)tkSetMainMenu:(TKMenu *)menu; @end @interface TKApplication(TKClipboard) - (void)tkProvidePasteboard:(TkDisplay *)dispPtr; - (void)tkCheckPasteboard; @end VISIBILITY_HIDDEN @interface TKContentView : NSView <NSTextInput> { @private id _savedSubviews; BOOL _subviewsSetAside; NSString *_workingText; } @end @interface TKContentView(TKKeyEvent) - (void) deleteWorkingText; @end VISIBILITY_HIDDEN @interface TKWindow : NSWindow @end #pragma mark NSMenu & NSMenuItem Utilities @interface NSMenu(TKUtils) + (id)menuWithTitle:(NSString *)title; + (id)menuWithTitle:(NSString *)title menuItems:(NSArray *)items; + (id)menuWithTitle:(NSString *)title submenus:(NSArray *)submenus; - (NSMenuItem *)itemWithSubmenu:(NSMenu *)submenu; - (NSMenuItem *)itemInSupermenu; @end @interface NSMenuItem(TKUtils) + (id)itemWithSubmenu:(NSMenu *)submenu; + (id)itemWithTitle:(NSString *)title submenu:(NSMenu *)submenu; + (id)itemWithTitle:(NSString *)title action:(SEL)action; + (id)itemWithTitle:(NSString *)title action:(SEL)action target:(id)target; + (id)itemWithTitle:(NSString *)title action:(SEL)action keyEquivalent:(NSString *)keyEquivalent; + (id)itemWithTitle:(NSString *)title action:(SEL)action target:(id)target keyEquivalent:(NSString *)keyEquivalent; + (id)itemWithTitle:(NSString *)title action:(SEL)action keyEquivalent:(NSString *)keyEquivalent keyEquivalentModifierMask:(NSUInteger)keyEquivalentModifierMask; + (id)itemWithTitle:(NSString *)title action:(SEL)action target:(id)target keyEquivalent:(NSString *)keyEquivalent keyEquivalentModifierMask:(NSUInteger)keyEquivalentModifierMask; @end /* From WebKit/WebKit/mac/WebCoreSupport/WebChromeClient.mm: */ @interface NSWindow(TKGrowBoxRect) - (NSRect)_growBoxRect; @end #endif /* _TKMACPRIV */ |
Changes to macosx/tkMacOSXRegion.c.
1 2 3 4 5 6 | /* * tkMacOSXRegion.c -- * * Implements X window calls for manipulating regions * * Copyright (c) 1995-1996 Sun Microsystems, Inc. | | | | | | 1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 | /* * tkMacOSXRegion.c -- * * Implements X window calls for manipulating regions * * Copyright (c) 1995-1996 Sun Microsystems, Inc. * Copyright 2001-2009, Apple Inc. * Copyright (c) 2006-2009 Daniel A. Steffen <[email protected]> * * See the file "license.terms" for information on usage and redistribution * of this file, and for a DISCLAIMER OF ALL WARRANTIES. */ #include "tkMacOSXPrivate.h" /* *---------------------------------------------------------------------- * * TkCreateRegion -- * * Implements the equivelent of the X window function XCreateRegion. See * Xwindow documentation for more details. * * Results: * Returns an allocated region handle. * * Side effects: * None. * |
︙ | ︙ | |||
38 39 40 41 42 43 44 | } /* *---------------------------------------------------------------------- * * TkDestroyRegion -- * | | | | 38 39 40 41 42 43 44 45 46 47 48 49 50 51 52 53 | } /* *---------------------------------------------------------------------- * * TkDestroyRegion -- * * Implements the equivelent of the X window function XDestroyRegion. See * Xwindow documentation for more details. * * Results: * None. * * Side effects: * Memory is freed. * |
︙ | ︙ | |||
64 65 66 67 68 69 70 | } /* *---------------------------------------------------------------------- * * TkIntersectRegion -- * | | | | 64 65 66 67 68 69 70 71 72 73 74 75 76 77 78 79 | } /* *---------------------------------------------------------------------- * * TkIntersectRegion -- * * Implements the equivalent of the X window function XIntersectRegion. * See Xwindow documentation for more details. * * Results: * None. * * Side effects: * None. * |
︙ | ︙ | |||
91 92 93 94 95 96 97 | } /* *---------------------------------------------------------------------- * * TkSubtractRegion -- * | | | | 91 92 93 94 95 96 97 98 99 100 101 102 103 104 105 106 | } /* *---------------------------------------------------------------------- * * TkSubtractRegion -- * * Implements the equivalent of the X window function XSubtractRegion. * See X window documentation for more details. * * Results: * None. * * Side effects: * None. * |
︙ | ︙ | |||
119 120 121 122 123 124 125 | /* *---------------------------------------------------------------------- * * TkUnionRectWithRegion -- * * Implements the equivelent of the X window function | | < | 119 120 121 122 123 124 125 126 127 128 129 130 131 132 133 | /* *---------------------------------------------------------------------- * * TkUnionRectWithRegion -- * * Implements the equivelent of the X window function * XUnionRectWithRegion. See Xwindow documentation for more details. * * Results: * None. * * Side effects: * None. * |
︙ | ︙ | |||
157 158 159 160 161 162 163 | } /* *---------------------------------------------------------------------- * * TkRectInRegion -- * | | | | 156 157 158 159 160 161 162 163 164 165 166 167 168 169 170 171 | } /* *---------------------------------------------------------------------- * * TkRectInRegion -- * * Implements the equivelent of the X window function XRectInRegion. See * Xwindow documentation for more details. * * Results: * Returns RectanglePart or RectangleOut. Note that this is not a * complete implementation since it doesn't test for RectangleIn. * * Side effects: * None. |
︙ | ︙ | |||
181 182 183 184 185 186 187 | int y, unsigned int width, unsigned int height) { int result; const CGRect r = CGRectMake(x, y, width, height); | < | | < < < < < < < < < < < < < < < < < < < < < < < < < < < < < | | | | | | 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 224 225 226 227 228 229 230 231 232 233 234 235 236 | int y, unsigned int width, unsigned int height) { int result; const CGRect r = CGRectMake(x, y, width, height); result = HIShapeIntersectsRect((HIShapeRef) region, &r) ? RectanglePart : RectangleOut; return result; } /* *---------------------------------------------------------------------- * * TkClipBox -- * * Implements the equivelent of the X window function XClipBox. See * Xwindow documentation for more details. * * Results: * None. * * Side effects: * None. * *---------------------------------------------------------------------- */ void TkClipBox( TkRegion r, XRectangle* rect_return) { CGRect rect; HIShapeGetBounds((HIShapeRef) r, &rect); rect_return->x = rect.origin.x; rect_return->y = rect.origin.y; rect_return->width = rect.size.width; rect_return->height = rect.size.height; } /* *---------------------------------------------------------------------- * * TkpBuildRegionFromAlphaData -- * * Set up a rectangle of the given region based on the supplied alpha * data. * * Results: * None * * Side effects: * The region is updated, with extra pixels added to it. * |
︙ | ︙ | |||
284 285 286 287 288 289 290 | unsigned char *lineDataPtr; unsigned int x1, y1, end; XRectangle rect; for (y1 = 0; y1 < height; y1++) { lineDataPtr = dataPtr; for (x1 = 0; x1 < width; x1 = end) { | > | > > > > | > > | 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 | unsigned char *lineDataPtr; unsigned int x1, y1, end; XRectangle rect; for (y1 = 0; y1 < height; y1++) { lineDataPtr = dataPtr; for (x1 = 0; x1 < width; x1 = end) { /* * Search for first non-transparent pixel. */ while ((x1 < width) && !*lineDataPtr) { x1++; lineDataPtr += pixelStride; } end = x1; /* * Search for first transparent pixel. */ while ((end < width) && *lineDataPtr) { end++; lineDataPtr += pixelStride; } if (end > x1) { rect.x = x + x1; rect.y = y + y1; |
︙ | ︙ | |||
491 492 493 494 495 496 497 | */ HIShapeRef TkMacOSXHIShapeCreateEmpty(void) { HIShapeRef result; | < | < < < < < < < < < < < < < | < < < < < < < < | < < < < < < < | 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 | */ HIShapeRef TkMacOSXHIShapeCreateEmpty(void) { HIShapeRef result; result = HIShapeCreateEmpty(); return result; } HIMutableShapeRef TkMacOSXHIShapeCreateMutableWithRect( const CGRect *inRect) { HIMutableShapeRef result; result = HIShapeCreateMutableWithRect(inRect); return result; } OSStatus TkMacOSXHIShapeSetWithShape( HIMutableShapeRef inDestShape, HIShapeRef inSrcShape) { OSStatus result; result = HIShapeSetWithShape(inDestShape, inSrcShape); return result; } #if 0 OSStatus TkMacOSXHIShapeSetWithRect( HIMutableShapeRef inShape, |
︙ | ︙ | |||
582 583 584 585 586 587 588 | OSStatus TkMacOSHIShapeUnionWithRect( HIMutableShapeRef inShape, const CGRect *inRect) { OSStatus result; | < | < < < < < < < < | < < < | < < < < < | | > | | | > > | < > | 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 | OSStatus TkMacOSHIShapeUnionWithRect( HIMutableShapeRef inShape, const CGRect *inRect) { OSStatus result; result = HIShapeUnionWithRect(inShape, inRect); return result; } OSStatus TkMacOSHIShapeUnion( HIShapeRef inShape1, HIShapeRef inShape2, HIMutableShapeRef outResult) { OSStatus result; result = HIShapeUnion(inShape1, inShape2, outResult); return result; } /* * Local Variables: * mode: c * c-basic-offset: 4 * fill-column: 79 * coding: utf-8 * End: */ |
Changes to macosx/tkMacOSXScale.c.
1 2 3 4 5 6 7 8 | /* * tkMacOSXScale.c -- * * This file implements the Macintosh specific portion of the * scale widget. * * Copyright (c) 1996 by Sun Microsystems, Inc. * Copyright (c) 1998-2000 by Scriptics Corporation. | | > > | 1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 | /* * tkMacOSXScale.c -- * * This file implements the Macintosh specific portion of the * scale widget. * * Copyright (c) 1996 by Sun Microsystems, Inc. * Copyright (c) 1998-2000 by Scriptics Corporation. * Copyright (c) 2006-2009 Daniel A. Steffen <[email protected]> * Copyright 2008-2009, Apple Inc. * * See the file "license.terms" for information on usage and redistribution * of this file, and for a DISCLAIMER OF ALL WARRANTIES. */ #include "tkMacOSXPrivate.h" #include "tkScale.h" #ifdef MAC_OSX_TK_TODO /* #ifdef TK_MAC_DEBUG #define TK_MAC_DEBUG_SCALE #endif */ /* |
︙ | ︙ | |||
475 476 477 478 479 480 481 | #endif value = GetControlValue(theControl); TkScaleSetValue(scalePtr, value, 1, 1); Tcl_Preserve((ClientData) scalePtr); TkMacOSXRunTclEventLoop(); Tcl_Release((ClientData) scalePtr); } | > | > > > > > > > > | 477 478 479 480 481 482 483 484 485 486 487 488 489 490 491 492 493 | #endif value = GetControlValue(theControl); TkScaleSetValue(scalePtr, value, 1, 1); Tcl_Preserve((ClientData) scalePtr); TkMacOSXRunTclEventLoop(); Tcl_Release((ClientData) scalePtr); } #endif /* * Local Variables: * mode: c * c-basic-offset: 4 * fill-column: 79 * coding: utf-8 * End: */ |
Changes to macosx/tkMacOSXScrlbr.c.
1 2 3 4 | /* * tkMacOSXScrollbar.c -- * * This file implements the Macintosh specific portion of the scrollbar | | < | | < > | | > > | | | < < < < < < < < < < < < < < < < < < < < < < < < < < | | | | | | | < < < | | < < | < < > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > | | < | | | > > > > > | > > > | | | | > | | | > | | | < < < | < < < | < < < < < | < < | | < | > | > > > > > > > > > > > > > | > | > | | > > | | | | | > | < > | > > > > > > > | > | | < < < | < < | < < < | < > > | | | | | | < < | < < < < | < < < < | < < < | < | < < < < < < | < > | | < | > | | < | | | > | < | | < < | | < < < > > | < | < < < < < < < < < < < | < > | > > > > > > > | < < < > > | | | | > | > > | > > | > > > > > > > > > > > > > > > > | > > > > > > > > > > > > > > > > | | | | | 1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 34 35 36 37 38 39 40 41 42 43 44 45 46 47 48 49 50 51 52 53 54 55 56 57 58 59 60 61 62 63 64 65 66 67 68 69 70 71 72 73 74 75 76 77 78 79 80 81 82 83 84 85 86 87 88 89 90 91 92 93 94 95 96 97 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 129 130 131 132 133 134 135 136 137 138 139 140 141 142 143 144 145 146 147 148 149 150 151 152 153 154 155 156 157 158 159 160 161 162 163 164 165 166 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 224 225 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 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 284 285 286 287 288 289 290 291 292 293 294 295 296 297 298 299 300 301 302 303 304 305 306 307 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 338 339 340 341 342 343 344 345 346 347 348 349 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 | /* * tkMacOSXScrollbar.c -- * * This file implements the Macintosh specific portion of the scrollbar * widget. * * Copyright (c) 1996 by Sun Microsystems, Inc. * Copyright 2001-2009, Apple Inc. * Copyright (c) 2006-2009 Daniel A. Steffen <[email protected]> * * See the file "license.terms" for information on usage and redistribution * of this file, and for a DISCLAIMER OF ALL WARRANTIES. */ #include "tkMacOSXPrivate.h" #include "tkScrollbar.h" /* #ifdef TK_MAC_DEBUG #define TK_MAC_DEBUG_SCROLLBAR #endif */ /* * Declaration of Mac specific scrollbar structure. */ typedef struct MacScrollbar { TkScrollbar info; NSScroller *scroller; int variant; } MacScrollbar; typedef struct ScrollbarMetrics { SInt32 width, minThumbHeight; int minHeight, topArrowHeight, bottomArrowHeight; NSControlSize controlSize; } ScrollbarMetrics; static ScrollbarMetrics metrics[2] = { {15, 54, 26, 14, 14, NSRegularControlSize}, /* kThemeScrollBarMedium */ {11, 40, 20, 10, 10, NSSmallControlSize}, /* kThemeScrollBarSmall */ }; /* * This variable holds the default width for a scrollbar in string form for * use in a Tk_ConfigSpec. */ static char defWidth[TCL_INTEGER_SPACE]; /* * Declarations for functions defined in this file. */ static void UpdateScrollbarMetrics(void); static void ScrollbarEventProc(ClientData clientData, XEvent *eventPtr); /* * The class procedure table for the scrollbar widget. */ Tk_ClassProcs tkpScrollbarProcs = { sizeof(Tk_ClassProcs) /* size */ }; #pragma mark TKApplication(TKScrlbr) #define NSAppleAquaScrollBarVariantChanged @"AppleAquaScrollBarVariantChanged" @implementation TKApplication(TKScrlbr) - (void)tkScroller:(NSScroller *)scroller { NSScrollerPart hitPart = [scroller hitPart]; TkScrollbar *scrollPtr = (TkScrollbar *)[scroller tag]; Tcl_DString cmdString; Tcl_Interp *interp; int result; if (!scrollPtr || !scrollPtr->command || !scrollPtr->commandSize || hitPart == NSScrollerNoPart) { return; } Tcl_DStringInit(&cmdString); Tcl_DStringAppend(&cmdString, scrollPtr->command, scrollPtr->commandSize); switch (hitPart) { case NSScrollerKnob: case NSScrollerKnobSlot: { char valueString[TCL_DOUBLE_SPACE]; Tcl_PrintDouble(NULL, [scroller doubleValue] * (1.0 - [scroller knobProportion]), valueString); Tcl_DStringAppendElement(&cmdString, "moveto"); Tcl_DStringAppendElement(&cmdString, valueString); break; } case NSScrollerDecrementLine: case NSScrollerIncrementLine: Tcl_DStringAppendElement(&cmdString, "scroll"); Tcl_DStringAppendElement(&cmdString, (hitPart == NSScrollerDecrementLine) ? "-1" : "1"); Tcl_DStringAppendElement(&cmdString, "unit"); break; case NSScrollerDecrementPage: case NSScrollerIncrementPage: Tcl_DStringAppendElement(&cmdString, "scroll"); Tcl_DStringAppendElement(&cmdString, (hitPart == NSScrollerDecrementPage) ? "-1" : "1"); Tcl_DStringAppendElement(&cmdString, "page"); break; } interp = scrollPtr->interp; Tcl_Preserve(interp); Tcl_Preserve(scrollPtr); result = Tcl_EvalEx(interp, Tcl_DStringValue(&cmdString), Tcl_DStringLength(&cmdString), TCL_EVAL_GLOBAL); if (result != TCL_OK && result != TCL_CONTINUE && result != TCL_BREAK) { Tcl_AddErrorInfo(interp, "\n (scrollbar command)"); Tcl_BackgroundError(interp); } Tcl_Release(scrollPtr); Tcl_Release(interp); Tcl_DStringFree(&cmdString); #ifdef TK_MAC_DEBUG_SCROLLBAR TKLog(@"scroller %s value %f knobProportion %f", ((TkWindow *)scrollPtr->tkwin)->pathName, [scroller doubleValue], [scroller knobProportion]); #endif } - (void)scrollBarVariantChanged:(NSNotification *)notification { #ifdef TK_MAC_DEBUG_NOTIFICATIONS TKLog(@"-[%@(%p) %s] %@", [self class], self, _cmd, notification); #endif UpdateScrollbarMetrics(); } - (void)_setupScrollBarNotifications { NSNotificationCenter *nc = [NSNotificationCenter defaultCenter]; #define observe(n, s) [nc addObserver:self selector:@selector(s) name:(n) object:nil] observe(NSAppleAquaScrollBarVariantChanged, scrollBarVariantChanged:); #undef observe UpdateScrollbarMetrics(); } @end #pragma mark - /* *---------------------------------------------------------------------- * * UpdateScrollbarMetrics -- * * This function retrieves the current system metrics for a scrollbar. * * Results: * None. * * Side effects: * Updates the geometry cache info for all scrollbars. * *---------------------------------------------------------------------- */ static void UpdateScrollbarMetrics(void) { const short height = 100, width = 50; HIThemeTrackDrawInfo info = { .version = 0, .bounds = {{0, 0}, {width, height}}, .min = 0, .max = 1, .value = 0, .attributes = kThemeTrackShowThumb, .enableState = kThemeTrackActive, .trackInfo.scrollbar = {.viewsize = 1, .pressState = 0}, }; CGRect bounds; Tk_ConfigSpec *specPtr; ChkErr(GetThemeMetric, kThemeMetricScrollBarWidth, &metrics[0].width); ChkErr(GetThemeMetric, kThemeMetricScrollBarMinThumbHeight, &metrics[0].minThumbHeight); info.kind = kThemeScrollBarMedium; ChkErr(HIThemeGetTrackDragRect, &info, &bounds); metrics[0].topArrowHeight = bounds.origin.y; metrics[0].bottomArrowHeight = height - (bounds.origin.y + bounds.size.height); metrics[0].minHeight = metrics[0].minThumbHeight + metrics[0].topArrowHeight + metrics[0].bottomArrowHeight; ChkErr(GetThemeMetric, kThemeMetricSmallScrollBarWidth, &metrics[1].width); ChkErr(GetThemeMetric, kThemeMetricSmallScrollBarMinThumbHeight, &metrics[1].minThumbHeight); info.kind = kThemeScrollBarSmall; ChkErr(HIThemeGetTrackDragRect, &info, &bounds); metrics[1].topArrowHeight = bounds.origin.y; metrics[1].bottomArrowHeight = height - (bounds.origin.y + bounds.size.height); metrics[1].minHeight = metrics[1].minThumbHeight + metrics[1].topArrowHeight + metrics[1].bottomArrowHeight; sprintf(defWidth, "%d", (int)(metrics[0].width)); for (specPtr = tkpScrollbarConfigSpecs; specPtr->type != TK_CONFIG_END; specPtr++) { if (specPtr->offset == Tk_Offset(TkScrollbar, width)) { specPtr->defValue = defWidth; } } } /* *---------------------------------------------------------------------- * * TkpCreateScrollbar -- * * Allocate a new TkScrollbar structure. * * Results: * Returns a newly allocated TkScrollbar structure. * * Side effects: * Registers an event handler for the widget. * *---------------------------------------------------------------------- */ TkScrollbar * TkpCreateScrollbar( Tk_Window tkwin) { MacScrollbar *scrollPtr = (MacScrollbar *) ckalloc(sizeof(MacScrollbar)); scrollPtr->scroller = nil; Tk_CreateEventHandler(tkwin, ActivateMask|ExposureMask| StructureNotifyMask|FocusChangeMask, ScrollbarEventProc, (ClientData) scrollPtr); return (TkScrollbar *) scrollPtr; } /* *---------------------------------------------------------------------- * * TkpDestroyScrollbar -- * * Free data structures associated with the scrollbar control. * * Results: * None. * * Side effects: * None. * *---------------------------------------------------------------------- */ void TkpDestroyScrollbar( TkScrollbar *scrollPtr) { MacScrollbar *macScrollPtr = (MacScrollbar *) scrollPtr; TkMacOSXMakeCollectableAndRelease(macScrollPtr->scroller); } /* *-------------------------------------------------------------- * * TkpDisplayScrollbar -- * * This procedure redraws the contents of a scrollbar window. It is * invoked as a do-when-idle handler, so it only runs when there's * nothing else for the application to do. * * Results: * None. * * Side effects: * Information appears on the screen. * *-------------------------------------------------------------- */ void TkpDisplayScrollbar( ClientData clientData) /* Information about window. */ { TkScrollbar *scrollPtr = (TkScrollbar *) clientData; MacScrollbar *macScrollPtr = (MacScrollbar *) clientData; NSScroller *scroller = macScrollPtr->scroller; Tk_Window tkwin = scrollPtr->tkwin; TkWindow *winPtr = (TkWindow *) tkwin; MacDrawable *macWin = (MacDrawable *) winPtr->window; TkMacOSXDrawingContext dc; NSView *view = TkMacOSXDrawableView(macWin); CGFloat viewHeight = [view bounds].size.height; CGAffineTransform t = { .a = 1, .b = 0, .c = 0, .d = -1, .tx = 0, .ty = viewHeight}; NSRect frame; double knobProportion = scrollPtr->lastFraction - scrollPtr->firstFraction; scrollPtr->flags &= ~REDRAW_PENDING; if (!scrollPtr->tkwin || !Tk_IsMapped(tkwin) || !view || !TkMacOSXSetupDrawingContext((Drawable) macWin, NULL, 1, &dc)) { return; } CGContextConcatCTM(dc.context, t); if (scrollPtr->highlightWidth != 0) { GC fgGC, bgGC; bgGC = Tk_GCForColor(scrollPtr->highlightBgColorPtr, (Pixmap) macWin); if (scrollPtr->flags & GOT_FOCUS) { fgGC = Tk_GCForColor(scrollPtr->highlightColorPtr, (Pixmap) macWin); } else { fgGC = bgGC; } TkpDrawHighlightBorder(tkwin, fgGC, bgGC, scrollPtr->highlightWidth, (Pixmap) macWin); } Tk_Draw3DRectangle(tkwin, (Pixmap) macWin, scrollPtr->bgBorder, scrollPtr->highlightWidth, scrollPtr->highlightWidth, Tk_Width(tkwin) - 2*scrollPtr->highlightWidth, Tk_Height(tkwin) - 2*scrollPtr->highlightWidth, scrollPtr->borderWidth, scrollPtr->relief); Tk_Fill3DRectangle(tkwin, (Pixmap) macWin, scrollPtr->bgBorder, scrollPtr->inset, scrollPtr->inset, Tk_Width(tkwin) - 2*scrollPtr->inset, Tk_Height(tkwin) - 2*scrollPtr->inset, 0, TK_RELIEF_FLAT); if ([scroller superview] != view) { [view addSubview:scroller]; } frame = NSMakeRect(macWin->xOff, macWin->yOff, Tk_Width(tkwin), Tk_Height(tkwin)); frame = NSInsetRect(frame, scrollPtr->inset, scrollPtr->inset); frame.origin.y = viewHeight - (frame.origin.y + frame.size.height); NSWindow *w = [view window]; if ([w showsResizeIndicator]) { NSRect growBox = [view convertRect:[w _growBoxRect] fromView:nil]; if (NSIntersectsRect(growBox, frame)) { if (scrollPtr->vertical) { CGFloat y = frame.origin.y; frame.origin.y = growBox.origin.y + growBox.size.height; frame.size.height -= frame.origin.y - y; } else { frame.size.width = growBox.origin.x - frame.origin.x; } TkMacOSXSetScrollbarGrow(winPtr, true); } } if (!NSEqualRects(frame, [scroller frame])) { [scroller setFrame:frame]; } [scroller setEnabled:(knobProportion < 1.0 && (scrollPtr->vertical ? frame.size.height : frame.size.width) > metrics[macScrollPtr->variant].minHeight)]; [scroller setDoubleValue:scrollPtr->firstFraction / (1.0 - knobProportion)]; [scroller setKnobProportion:knobProportion]; [scroller displayRectIgnoringOpacity:[scroller bounds]]; TkMacOSXRestoreDrawingContext(&dc); #ifdef TK_MAC_DEBUG_SCROLLBAR TKLog(@"scroller %s frame %@ width %d height %d", ((TkWindow *)scrollPtr->tkwin)->pathName, NSStringFromRect(frame), Tk_Width(tkwin), Tk_Height(tkwin)); #endif } /* *---------------------------------------------------------------------- * * TkpComputeScrollbarGeometry -- * * After changes in a scrollbar's size or configuration, this procedure * recomputes various geometry information used in displaying the * scrollbar. * * Results: * None. * * Side effects: * The scrollbar will be displayed differently. * *---------------------------------------------------------------------- */ void TkpComputeScrollbarGeometry( register TkScrollbar *scrollPtr) /* Scrollbar whose geometry may have * changed. */ { MacScrollbar *macScrollPtr = (MacScrollbar *) scrollPtr; NSScroller *scroller = macScrollPtr->scroller; int width, height, variant, fieldLength; if (scrollPtr->highlightWidth < 0) { scrollPtr->highlightWidth = 0; } scrollPtr->inset = scrollPtr->highlightWidth + scrollPtr->borderWidth; width = Tk_Width(scrollPtr->tkwin) - 2 * scrollPtr->inset; height = Tk_Height(scrollPtr->tkwin) - 2 * scrollPtr->inset; variant = ((scrollPtr->vertical ? width : height) < metrics[0].width) ? 1 : 0; macScrollPtr->variant = variant; if (scroller) { NSSize size = [scroller frame].size; if ((size.width > size.height) ^ !scrollPtr->vertical) { /* Orientation changed, need new scroller */ if ([scroller superview]) { [scroller removeFromSuperviewWithoutNeedingDisplay]; } TkMacOSXMakeCollectableAndRelease(scroller); } } if (!scroller) { if ((width > height) ^ !scrollPtr->vertical) { /* -[NSScroller initWithFrame:] determines horizonalness for the * lifetime of the scroller via isHoriz = (width > height) */ if (scrollPtr->vertical) { width = height; } else if (width > 1) { height = width - 1; } else { height = 1; width = 2; } } scroller = [[NSScroller alloc] initWithFrame: NSMakeRect(0, 0, width, height)]; macScrollPtr->scroller = TkMacOSXMakeUncollectable(scroller); [scroller setAction:@selector(tkScroller:)]; [scroller setTarget:NSApp]; [scroller setTag:(NSInteger)scrollPtr]; } [[scroller cell] setControlSize:metrics[variant].controlSize]; scrollPtr->arrowLength = (metrics[variant].topArrowHeight + metrics[variant].bottomArrowHeight) / 2; fieldLength = (scrollPtr->vertical ? Tk_Height(scrollPtr->tkwin) : Tk_Width(scrollPtr->tkwin)) - 2 * (scrollPtr->arrowLength + scrollPtr->inset); if (fieldLength < 0) { fieldLength = 0; } scrollPtr->sliderFirst = fieldLength * scrollPtr->firstFraction; scrollPtr->sliderLast = fieldLength * scrollPtr->lastFraction; /* * Adjust the slider so that some piece of it is always displayed in the * scrollbar and so that it has at least a minimal width (so it can be * grabbed with the mouse). */ if (scrollPtr->sliderFirst > (fieldLength - 2*scrollPtr->borderWidth)) { scrollPtr->sliderFirst = fieldLength - 2*scrollPtr->borderWidth; } if (scrollPtr->sliderFirst < 0) { scrollPtr->sliderFirst = 0; |
︙ | ︙ | |||
397 398 399 400 401 402 403 | } scrollPtr->sliderFirst += scrollPtr->inset + metrics[variant].topArrowHeight; scrollPtr->sliderLast += scrollPtr->inset + metrics[variant].bottomArrowHeight; /* | | | | < > > > > > > | | > > | | < > | | < < < < < < < | < | | | < | < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < | < < < | < < < < < < < < < < < < < | < < < < < < < < < < | < | < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < | < < < < < < < < < < < < < < | < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < | > > | < < < < < | < | | < | < < | | < < < < < | < < < < | > | | < < | < < < < | < < < < < < < | | | | < | > > | < < | < | > < < < < < < < < < < < < < < < | < < < < < < < < < < < | < < < < | < < | < < < < < < < < < < | < < < < < < < < < < < < < < < < < < < < < | < < < < < < < < < < < < < < < < < < < < < < < < < < | < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < | 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 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 614 615 616 617 618 619 620 | } scrollPtr->sliderFirst += scrollPtr->inset + metrics[variant].topArrowHeight; scrollPtr->sliderLast += scrollPtr->inset + metrics[variant].bottomArrowHeight; /* * Register the desired geometry for the window (leave enough space for * the two arrows plus a minimum-size slider, plus border around the whole * window, if any). Then arrange for the window to be redisplayed. */ if (scrollPtr->vertical) { Tk_GeometryRequest(scrollPtr->tkwin, scrollPtr->width + 2 * scrollPtr->inset, 2 * (scrollPtr->arrowLength + scrollPtr->borderWidth + scrollPtr->inset) + metrics[variant].minThumbHeight); } else { Tk_GeometryRequest(scrollPtr->tkwin, 2 * (scrollPtr->arrowLength + scrollPtr->borderWidth + scrollPtr->inset) + metrics[variant].minThumbHeight, scrollPtr->width + 2 * scrollPtr->inset); } Tk_SetInternalBorder(scrollPtr->tkwin, scrollPtr->inset); #ifdef TK_MAC_DEBUG_SCROLLBAR TKLog(@"scroller %s bounds %@ width %d height %d inset %d borderWidth %d", ((TkWindow *)scrollPtr->tkwin)->pathName, NSStringFromRect([scroller bounds]), width, height, scrollPtr->inset, scrollPtr->borderWidth); #endif } /* *---------------------------------------------------------------------- * * TkpConfigureScrollbar -- * * This procedure is called after the generic code has finished * processing configuration options, in order to configure platform * specific options. * * Results: * None. * * Side effects: * None. * *---------------------------------------------------------------------- */ void TkpConfigureScrollbar( register TkScrollbar *scrollPtr) /* Information about widget; may or may not * already have values for some fields. */ { } /* *-------------------------------------------------------------- * * TkpScrollbarPosition -- * * Determine the scrollbar element corresponding to a given position. * * Results: * One of TOP_ARROW, TOP_GAP, etc., indicating which element of the * scrollbar covers the position given by (x, y). If (x,y) is outside the * scrollbar entirely, then OUTSIDE is returned. * * Side effects: * None. * *-------------------------------------------------------------- */ int TkpScrollbarPosition( register TkScrollbar *scrollPtr, /* Scrollbar widget record. */ int x, int y) /* Coordinates within scrollPtr's window. */ { NSScroller *scroller = ((MacScrollbar *) scrollPtr)->scroller; MacDrawable *macWin = (MacDrawable *) ((TkWindow *) scrollPtr->tkwin)->window; NSView *view = TkMacOSXDrawableView(macWin); switch ([scroller testPart:NSMakePoint(macWin->xOff + x, [view bounds].size.height - (macWin->yOff + y))]) { case NSScrollerDecrementLine: return TOP_ARROW; case NSScrollerDecrementPage: return TOP_GAP; case NSScrollerKnob: return SLIDER; case NSScrollerIncrementPage: return BOTTOM_GAP; case NSScrollerIncrementLine: return BOTTOM_ARROW; case NSScrollerKnobSlot: case NSScrollerNoPart: default: return OUTSIDE; } } /* *-------------------------------------------------------------- * * ScrollbarEventProc -- * * This procedure is invoked by the Tk dispatcher for various events on * scrollbars. * * Results: * None. * * Side effects: * When the window gets deleted, internal structures get cleaned up. When * it gets exposed, it is redisplayed. * *-------------------------------------------------------------- */ static void ScrollbarEventProc( ClientData clientData, /* Information about window. */ XEvent *eventPtr) /* Information about event. */ { TkScrollbar *scrollPtr = (TkScrollbar *) clientData; switch (eventPtr->type) { case UnmapNotify: TkMacOSXSetScrollbarGrow((TkWindow *) scrollPtr->tkwin, false); break; case ActivateNotify: case DeactivateNotify: TkScrollbarEventuallyRedraw((ClientData) scrollPtr); break; default: TkScrollbarEventProc(clientData, eventPtr); } } /* * Local Variables: * mode: c * c-basic-offset: 4 * fill-column: 79 * coding: utf-8 * End: */ |
Changes to macosx/tkMacOSXSend.c.
︙ | ︙ | |||
20 21 22 23 24 25 26 | * Implementing this has been on our list of things to do, but what with * the demise of Tcl at Sun, and the lack of resources at Scriptics it * may not get done for awhile. So this sketch is offered for the brave * to attempt if they need the functionality... * * Copyright (c) 1989-1994 The Regents of the University of California. * Copyright (c) 1994-1998 Sun Microsystems, Inc. | | | | | | 20 21 22 23 24 25 26 27 28 29 30 31 32 33 34 35 36 37 38 | * Implementing this has been on our list of things to do, but what with * the demise of Tcl at Sun, and the lack of resources at Scriptics it * may not get done for awhile. So this sketch is offered for the brave * to attempt if they need the functionality... * * Copyright (c) 1989-1994 The Regents of the University of California. * Copyright (c) 1994-1998 Sun Microsystems, Inc. * Copyright 2001-2009, Apple Inc. * Copyright (c) 2005-2009 Daniel A. Steffen <[email protected]> * * See the file "license.terms" for information on usage and redistribution * of this file, and for a DISCLAIMER OF ALL WARRANTIES. */ #include "tkMacOSXInt.h" /* * The following structure is used to keep track of the interpreters * registered by this process. |
︙ | ︙ | |||
74 75 76 77 78 79 80 | * none. See format description above; this is * *not* terminated by the first null * character. Dynamically allocated. */ int allocedByX; /* Non-zero means must free property with * XFree; zero means use ckfree. */ } NameRegistry; | | | 74 75 76 77 78 79 80 81 82 83 84 85 86 87 88 | * none. See format description above; this is * *not* terminated by the first null * character. Dynamically allocated. */ int allocedByX; /* Non-zero means must free property with * XFree; zero means use ckfree. */ } NameRegistry; static int initialized = 0; /* A flag to denote if we have initialized * yet. */ static RegisteredInterp *interpListPtr = NULL; /* List of all interpreters registered by this * process. */ /* |
︙ | ︙ | |||
194 195 196 197 198 199 200 | * "send" command is created in the application's interpreter. The * registration will be removed automatically if the interpreter is * deleted or the "send" command is removed. * *-------------------------------------------------------------- */ | | | | 194 195 196 197 198 199 200 201 202 203 204 205 206 207 208 209 210 211 212 213 | * "send" command is created in the application's interpreter. The * registration will be removed automatically if the interpreter is * deleted or the "send" command is removed. * *-------------------------------------------------------------- */ const char * Tk_SetAppName( Tk_Window tkwin, /* Token for any window in the application to * be named: it is just used to identify the * application and the display. */ const char *name) /* The name that will be used to refer to the * interpreter in later "send" commands. Must * be globally unique. */ { TkWindow *winPtr = (TkWindow *) tkwin; Tcl_Interp *interp = winPtr->mainPtr->interp; int i, suffix, offset, result; RegisteredInterp *riPtr, *prevPtr; |
︙ | ︙ | |||
250 251 252 253 254 255 256 | Tcl_DStringInit(&dString); TkGetInterpNames(interp, tkwin); resultObjPtr = Tcl_GetObjResult(interp); Tcl_IncrRefCount(resultObjPtr); for (i = 0; ; ) { result = Tcl_ListObjIndex(NULL, resultObjPtr, i, &interpNamePtr); | | | 250 251 252 253 254 255 256 257 258 259 260 261 262 263 264 | Tcl_DStringInit(&dString); TkGetInterpNames(interp, tkwin); resultObjPtr = Tcl_GetObjResult(interp); Tcl_IncrRefCount(resultObjPtr); for (i = 0; ; ) { result = Tcl_ListObjIndex(NULL, resultObjPtr, i, &interpNamePtr); if (result != TCL_OK || interpNamePtr == NULL) { break; } interpName = Tcl_GetString(interpNamePtr); if (strcmp(actualName, interpName) == 0) { if (suffix == 1) { Tcl_DStringAppend(&dString, name, -1); Tcl_DStringAppend(&dString, " #", 2); |
︙ | ︙ | |||
319 320 321 322 323 324 325 | */ int Tk_SendObjCmd( ClientData clientData, /* Used only for deletion */ Tcl_Interp *interp, /* The interp we are sending from */ int objc, /* Number of arguments */ | | | | | | < < | 319 320 321 322 323 324 325 326 327 328 329 330 331 332 333 334 335 336 337 338 339 340 341 342 343 344 345 346 347 348 349 350 351 352 353 354 355 356 357 358 359 360 361 362 363 364 365 366 367 368 369 370 371 | */ int Tk_SendObjCmd( ClientData clientData, /* Used only for deletion */ Tcl_Interp *interp, /* The interp we are sending from */ int objc, /* Number of arguments */ Tcl_Obj *const objv[]) /* The arguments */ { const char *sendOptions[] = {"-async", "-displayof", "-", NULL}; char *stringRep, *destName; /*int async = 0;*/ int i, index, firstArg; RegisteredInterp *riPtr; Tcl_Obj *listObjPtr; int result = TCL_OK; for (i = 1; i < (objc - 1); ) { stringRep = Tcl_GetString(objv[i]); if (stringRep[0] == '-') { if (Tcl_GetIndexFromObj(interp, objv[i], sendOptions, "option", 0, &index) != TCL_OK) { return TCL_ERROR; } if (index == 0) { /*async = 1;*/ i++; } else if (index == 1) { i += 2; } else { i++; } } else { break; } } if (objc < (i + 2)) { Tcl_WrongNumArgs(interp, 1, objv, "?-option value ...? interpName arg ?arg ...?"); return TCL_ERROR; } destName = Tcl_GetString(objv[i]); firstArg = i + 1; /* * See if the target interpreter is local. If so, execute the command * directly without going through the DDE server. The only tricky thing is * passing the result from the target interpreter to the invoking * interpreter. Watch out: they could be the same! */ |
︙ | ︙ | |||
502 503 504 505 506 507 508 | SendInit( Tcl_Interp *interp) /* Interpreter to use for error reporting (no * errors are ever returned, but the * interpreter is needed anyway). */ { return TCL_OK; } | > > > > > > > > > | 500 501 502 503 504 505 506 507 508 509 510 511 512 513 514 515 | SendInit( Tcl_Interp *interp) /* Interpreter to use for error reporting (no * errors are ever returned, but the * interpreter is needed anyway). */ { return TCL_OK; } /* * Local Variables: * mode: c * c-basic-offset: 4 * fill-column: 79 * coding: utf-8 * End: */ |
Changes to macosx/tkMacOSXSubwindows.c.
1 2 3 4 5 6 | /* * tkMacOSXSubwindows.c -- * * Implements subwindows for the macintosh version of Tk. * * Copyright (c) 1995-1997 Sun Microsystems, Inc. | | | | | > | > | | | | < > | < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < > > > > > > > > > > > > > > > > > > > > > > > | | | | | | | | > < < < < | < < > | | < < < | < | | | 1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 34 35 36 37 38 39 40 41 42 43 44 45 46 47 48 49 50 51 52 53 54 55 56 57 58 59 60 61 62 63 64 65 66 67 68 69 70 71 72 73 74 75 76 77 78 79 80 81 82 83 84 85 86 87 88 89 90 91 92 93 94 95 96 97 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 129 130 131 132 133 134 135 136 137 138 139 140 141 142 143 144 145 146 147 148 149 150 151 152 153 154 155 156 157 158 159 160 161 162 163 164 165 166 167 168 169 170 171 172 173 174 175 176 177 178 179 180 181 | /* * tkMacOSXSubwindows.c -- * * Implements subwindows for the macintosh version of Tk. * * Copyright (c) 1995-1997 Sun Microsystems, Inc. * Copyright 2001-2009, Apple Inc. * Copyright (c) 2006-2009 Daniel A. Steffen <[email protected]> * * See the file "license.terms" for information on usage and redistribution * of this file, and for a DISCLAIMER OF ALL WARRANTIES. */ #include "tkMacOSXPrivate.h" #include "tkMacOSXDebug.h" #include "tkMacOSXWm.h" /* #ifdef TK_MAC_DEBUG #define TK_MAC_DEBUG_CLIP_REGIONS #endif */ /* * Prototypes for functions used only in this file. */ static void MoveResizeWindow(MacDrawable *macWin); static void GenerateConfigureNotify(TkWindow *winPtr, int includeWin); static void UpdateOffsets(TkWindow *winPtr, int deltaX, int deltaY); static void NotifyVisibility(TkWindow *winPtr, XEvent *eventPtr); /* *---------------------------------------------------------------------- * * XDestroyWindow -- * * Dealocates the given X Window. * * Results: * The window id is returned. * * Side effects: * None. * *---------------------------------------------------------------------- */ void XDestroyWindow( Display *display, /* Display. */ Window window) /* Window. */ { MacDrawable *macWin = (MacDrawable *) window; /* * Remove any dangling pointers that may exist if the window we are * deleting is being tracked by the grab code. */ TkPointerDeadWindow(macWin->winPtr); TkMacOSXSelDeadWindow(macWin->winPtr); macWin->toplevel->referenceCount--; if (!Tk_IsTopLevel(macWin->winPtr)) { TkMacOSXInvalidateWindow(macWin, TK_PARENT_WINDOW); if (macWin->winPtr->parentPtr != NULL) { TkMacOSXInvalClipRgns((Tk_Window) macWin->winPtr->parentPtr); } if (macWin->visRgn) { CFRelease(macWin->visRgn); } if (macWin->aboveVisRgn) { CFRelease(macWin->aboveVisRgn); } if (macWin->drawRgn) { CFRelease(macWin->drawRgn); } if (macWin->toplevel->referenceCount == 0) { ckfree((char *) macWin->toplevel); } ckfree((char *) macWin); return; } if (macWin->visRgn) { CFRelease(macWin->visRgn); } if (macWin->aboveVisRgn) { CFRelease(macWin->aboveVisRgn); } if (macWin->drawRgn) { CFRelease(macWin->drawRgn); } macWin->view = nil; /* * Delay deletion of a toplevel data structure untill all children have * been deleted. */ if (macWin->toplevel->referenceCount == 0) { ckfree((char *) macWin->toplevel); } } /* *---------------------------------------------------------------------- * * XMapWindow -- * * Map the given X Window to the screen. See X window documentation for * more details. * * Results: * None. * * Side effects: * The subwindow or toplevel may appear on the screen. * *---------------------------------------------------------------------- */ void XMapWindow( Display *display, /* Display. */ Window window) /* Window. */ { MacDrawable *macWin = (MacDrawable *) window; XEvent event; /* * Under certain situations it's possible for this function to be called * before the toplevel window it's associated with has actually been * mapped. In that case we need to create the real Macintosh window now as * this function as well as other X functions assume that the portPtr is * valid. */ if (!TkMacOSXHostToplevelExists(macWin->toplevel->winPtr)) { TkMacOSXMakeRealWindowExist(macWin->toplevel->winPtr); } display->request++; macWin->winPtr->flags |= TK_MAPPED; if (Tk_IsTopLevel(macWin->winPtr)) { if (!Tk_IsEmbedded(macWin->winPtr)) { NSWindow *win = TkMacOSXDrawableWindow(window); [win makeKeyAndOrderFront:NSApp]; [win windowRef]; TkMacOSXApplyWindowAttributes(macWin->winPtr, win); } TkMacOSXInvalClipRgns((Tk_Window) macWin->winPtr); /* * We only need to send the MapNotify event for toplevel windows. */ event.xany.serial = LastKnownRequestProcessed(display); event.xany.send_event = False; event.xany.display = display; event.xmap.window = window; event.xmap.type = MapNotify; event.xmap.event = window; event.xmap.override_redirect = macWin->winPtr->atts.override_redirect; Tk_QueueWindowEvent(&event, TCL_QUEUE_TAIL); } else { /* * Generate damage for that area of the window. */ TkMacOSXInvalClipRgns((Tk_Window) macWin->winPtr->parentPtr); TkMacOSXInvalidateWindow(macWin, TK_PARENT_WINDOW); } /* |
︙ | ︙ | |||
283 284 285 286 287 288 289 | /* *---------------------------------------------------------------------- * * NotifyVisibility -- * * Recursively called helper proc for XMapWindow(). | | | 191 192 193 194 195 196 197 198 199 200 201 202 203 204 205 | /* *---------------------------------------------------------------------- * * NotifyVisibility -- * * Recursively called helper proc for XMapWindow(). * * Results: * None. * * Side effects: * VisibilityNotify events are queued. * *---------------------------------------------------------------------- |
︙ | ︙ | |||
316 317 318 319 320 321 322 | } /* *---------------------------------------------------------------------- * * XUnmapWindow -- * | | | | | | < < < < | | < | < | | < > | | 224 225 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 256 257 258 259 260 261 262 263 264 265 266 267 268 269 270 271 272 273 274 275 276 | } /* *---------------------------------------------------------------------- * * XUnmapWindow -- * * Unmap the given X Window to the screen. See X window documentation for * more details. * * Results: * None. * * Side effects: * The subwindow or toplevel may be removed from the screen. * *---------------------------------------------------------------------- */ void XUnmapWindow( Display *display, /* Display. */ Window window) /* Window. */ { MacDrawable *macWin = (MacDrawable *) window; XEvent event; display->request++; macWin->winPtr->flags &= ~TK_MAPPED; if (Tk_IsTopLevel(macWin->winPtr)) { if (!Tk_IsEmbedded(macWin->winPtr) && macWin->winPtr->wmInfoPtr->hints.initial_state!=IconicState) { NSWindow *win = TkMacOSXDrawableWindow(window); if ([win isVisible]) { [[win parentWindow] removeChildWindow:win]; [win orderOut:NSApp]; } } TkMacOSXInvalClipRgns((Tk_Window) macWin->winPtr); /* * We only need to send the UnmapNotify event for toplevel windows. */ event.xany.serial = LastKnownRequestProcessed(display); event.xany.send_event = False; event.xany.display = display; event.xunmap.type = UnmapNotify; event.xunmap.window = window; event.xunmap.event = window; event.xunmap.from_configure = false; |
︙ | ︙ | |||
384 385 386 387 388 389 390 | } /* *---------------------------------------------------------------------- * * XResizeWindow -- * | | | | | | | < | | | | 286 287 288 289 290 291 292 293 294 295 296 297 298 299 300 301 302 303 304 305 306 307 308 309 310 311 312 313 314 315 316 317 318 319 320 321 322 323 324 325 326 327 328 329 330 | } /* *---------------------------------------------------------------------- * * XResizeWindow -- * * Resize a given X window. See X windows documentation for further * details. * * Results: * None. * * Side effects: * None. * *---------------------------------------------------------------------- */ void XResizeWindow( Display *display, /* Display. */ Window window, /* Window. */ unsigned int width, unsigned int height) { MacDrawable *macWin = (MacDrawable *) window; display->request++; if (Tk_IsTopLevel(macWin->winPtr) && !Tk_IsEmbedded(macWin->winPtr)) { NSWindow *w = macWin->winPtr->wmInfoPtr->window; if (w) { NSRect r = [w contentRectForFrameRect:[w frame]]; r.origin.y += r.size.height - height; r.size.width = width; r.size.height = height; [w setFrame:[w frameRectForContentRect:r] display:YES]; } } else { MoveResizeWindow(macWin); } } /* |
︙ | ︙ | |||
441 442 443 444 445 446 447 | * None. * *---------------------------------------------------------------------- */ void XMoveResizeWindow( | | | | < < | | | | | | 342 343 344 345 346 347 348 349 350 351 352 353 354 355 356 357 358 359 360 361 362 363 364 365 366 367 368 369 370 371 372 373 | * None. * *---------------------------------------------------------------------- */ void XMoveResizeWindow( Display *display, /* Display. */ Window window, /* Window. */ int x, int y, unsigned int width, unsigned int height) { MacDrawable *macWin = (MacDrawable *) window; display->request++; if (Tk_IsTopLevel(macWin->winPtr) && !Tk_IsEmbedded(macWin->winPtr)) { NSWindow *w = macWin->winPtr->wmInfoPtr->window; if (w) { NSRect r = NSMakeRect(x + macWin->winPtr->wmInfoPtr->xInParent, tkMacOSXZeroScreenHeight - (y + macWin->winPtr->wmInfoPtr->yInParent + height), width, height); [w setFrame:[w frameRectForContentRect:r] display:YES]; } } else { MoveResizeWindow(macWin); } } /* |
︙ | ︙ | |||
486 487 488 489 490 491 492 | * None. * *---------------------------------------------------------------------- */ void XMoveWindow( | | | < | | | 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 | * None. * *---------------------------------------------------------------------- */ void XMoveWindow( Display *display, /* Display. */ Window window, /* Window. */ int x, int y) { MacDrawable *macWin = (MacDrawable *) window; display->request++; if (Tk_IsTopLevel(macWin->winPtr) && !Tk_IsEmbedded(macWin->winPtr)) { NSWindow *w = macWin->winPtr->wmInfoPtr->window; if (w) { [w setFrameTopLeftPoint:NSMakePoint(x, tkMacOSXZeroScreenHeight - y)]; } } else { MoveResizeWindow(macWin); } } /* |
︙ | ︙ | |||
527 528 529 530 531 532 533 | static void MoveResizeWindow( MacDrawable *macWin) { int deltaX = 0, deltaY = 0, parentBorderwidth = 0; MacDrawable *macParent = NULL; | | > | | | | > | | | | | < | > > | | 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 | static void MoveResizeWindow( MacDrawable *macWin) { int deltaX = 0, deltaY = 0, parentBorderwidth = 0; MacDrawable *macParent = NULL; NSWindow *macWindow = TkMacOSXDrawableWindow((Drawable) macWin); /* * Find the Parent window, for an embedded window it will be its container. */ if (Tk_IsEmbedded(macWin->winPtr)) { TkWindow *contWinPtr = TkpGetOtherWindow(macWin->winPtr); if (contWinPtr) { macParent = contWinPtr->privatePtr; } else { /* * Here we should handle out of process embedding. At this point, * we are assuming that the changes.x,y is not maintained, if you * need the info get it from Tk_GetRootCoords, and that the * toplevel sits at 0,0 when it is drawn. */ } } else { /* * TODO: update all xOff & yOffs */ macParent = macWin->winPtr->parentPtr->privatePtr; parentBorderwidth = macWin->winPtr->parentPtr->changes.border_width; } if (macParent) { deltaX = macParent->xOff + parentBorderwidth + macWin->winPtr->changes.x - macWin->xOff; deltaY = macParent->yOff + parentBorderwidth + macWin->winPtr->changes.y - macWin->yOff; } if (macWindow) { TkMacOSXInvalidateWindow(macWin, TK_PARENT_WINDOW); if (macParent) { TkMacOSXInvalClipRgns((Tk_Window) macParent->winPtr); } } UpdateOffsets(macWin->winPtr, deltaX, deltaY); if (macWindow) { TkMacOSXInvalidateWindow(macWin, TK_PARENT_WINDOW); } GenerateConfigureNotify(macWin->winPtr, 0); } /* *---------------------------------------------------------------------- * * GenerateConfigureNotify -- * * Generates ConfigureNotify events for all the child widgets of the * widget passed in the winPtr parameter. If includeWin is true, also * generates ConfigureNotify event for the widget itself. * * Results: * None. * * Side effects: * ConfigureNotify events will be posted. * *---------------------------------------------------------------------- */ static void GenerateConfigureNotify( TkWindow *winPtr, int includeWin) { TkWindow *childPtr; for (childPtr = winPtr->childList; childPtr != NULL; childPtr = childPtr->nextPtr) { if (!Tk_IsMapped(childPtr) || Tk_IsTopLevel(childPtr)) { continue; } GenerateConfigureNotify(childPtr, 1); } if (includeWin) { TkDoConfigureNotify(winPtr); |
︙ | ︙ | |||
626 627 628 629 630 631 632 | * Changes the stacking order of the specified window. * *---------------------------------------------------------------------- */ void XRaiseWindow( | | | 527 528 529 530 531 532 533 534 535 536 537 538 539 540 541 | * Changes the stacking order of the specified window. * *---------------------------------------------------------------------- */ void XRaiseWindow( Display *display, /* Display. */ Window window) /* Window. */ { MacDrawable *macWin = (MacDrawable *) window; display->request++; if (Tk_IsTopLevel(macWin->winPtr) && !Tk_IsEmbedded(macWin->winPtr)) { TkWmRestackToplevel(macWin->winPtr, Above, NULL); |
︙ | ︙ | |||
660 661 662 663 664 665 666 | * Changes the stacking order of the specified window. * *---------------------------------------------------------------------- */ void XLowerWindow( | | | < | | | | | | | | | > < > | | > > > | | | | | 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 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 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 | * Changes the stacking order of the specified window. * *---------------------------------------------------------------------- */ void XLowerWindow( Display *display, /* Display. */ Window window) /* Window. */ { MacDrawable *macWin = (MacDrawable *) window; display->request++; if (Tk_IsTopLevel(macWin->winPtr) && !Tk_IsEmbedded(macWin->winPtr)) { TkWmRestackToplevel(macWin->winPtr, Below, NULL); } else { /* * TODO: this should generate damage */ } } #endif /* *---------------------------------------------------------------------- * * XConfigureWindow -- * * Change the size, position, stacking, or border of the specified window. * * Results: * None. * * Side effects: * Changes the attributes of the specified window. Note that we ignore the * passed in values and use the values stored in the TkWindow data * structure. * *---------------------------------------------------------------------- */ void XConfigureWindow( Display *display, /* Display. */ Window w, /* Window. */ unsigned int value_mask, XWindowChanges *values) { MacDrawable *macWin = (MacDrawable *) w; TkWindow *winPtr = macWin->winPtr; display->request++; /* * Change the shape and/or position of the window. */ if (value_mask & (CWX|CWY|CWWidth|CWHeight)) { XMoveResizeWindow(display, w, winPtr->changes.x, winPtr->changes.y, winPtr->changes.width, winPtr->changes.height); } /* * Change the stacking order of the window. Tk actually keeps all the * information we need for stacking order. All we need to do is make sure * the clipping regions get updated and generate damage that will ensure * things get drawn correctly. */ if (value_mask & CWStackMode) { NSView *view = TkMacOSXDrawableView(macWin); Rect bounds; NSRect r; if (view) { TkMacOSXInvalClipRgns((Tk_Window) winPtr->parentPtr); TkMacOSXWinBounds(winPtr, &bounds); r = NSMakeRect(bounds.left, [view bounds].size.height - bounds.bottom, bounds.right - bounds.left, bounds.bottom - bounds.top); [view setNeedsDisplayInRect:r]; } } /* TkGenWMMoveRequestEvent(macWin->winPtr, macWin->winPtr->changes.x, macWin->winPtr->changes.y); */ } /* *---------------------------------------------------------------------- * * TkMacOSXUpdateClipRgn -- * * This function updates the cliping regions for a given window and all of * its children. Once updated the TK_CLIP_INVALID flag in the subwindow * data structure is unset. The TK_CLIP_INVALID flag should always be * unset before any drawing is attempted. * * Results: * None. * * Side effects: * The clip regions for the window and its children are updated. * |
︙ | ︙ | |||
770 771 772 773 774 775 776 777 778 779 780 781 782 783 784 785 786 787 788 789 | if (winPtr == NULL) { return; } macWin = winPtr->privatePtr; if (macWin && macWin->flags & TK_CLIP_INVALID) { TkWindow *win2Ptr; if (Tk_IsMapped(winPtr)) { int rgnChanged = 0; CGRect bounds; HIMutableShapeRef rgn; /* * Start with a region defined by the window bounds. */ TkMacOSXWinCGBounds(winPtr, &bounds); rgn = TkMacOSXHIShapeCreateMutableWithRect(&bounds); /* | > > > | < < | < | | | | | | > < | | < < > > < < | < | | > > | < < | | | | | 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 703 704 705 706 707 708 709 710 711 712 713 714 715 716 717 718 719 720 721 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 | if (winPtr == NULL) { return; } macWin = winPtr->privatePtr; if (macWin && macWin->flags & TK_CLIP_INVALID) { TkWindow *win2Ptr; #ifdef TK_MAC_DEBUG_CLIP_REGIONS TkMacOSXDbgMsg("%s", winPtr->pathName); #endif if (Tk_IsMapped(winPtr)) { int rgnChanged = 0; CGRect bounds; HIMutableShapeRef rgn; /* * Start with a region defined by the window bounds. */ TkMacOSXWinCGBounds(winPtr, &bounds); rgn = TkMacOSXHIShapeCreateMutableWithRect(&bounds); /* * Clip away the area of any windows that may obscure this window. * For a non-toplevel window, first, clip to the parents visible * clip region. Second, clip away any siblings that are higher in * the stacking order. For an embedded toplevel, just clip to the * container's visible clip region. Remember, we only allow one * contained window in a frame, and don't support any other widgets * in the frame either. This is not currently enforced, however. */ if (!Tk_IsTopLevel(winPtr)) { TkMacOSXUpdateClipRgn(winPtr->parentPtr); if (winPtr->parentPtr) { ChkErr(HIShapeIntersect, winPtr->parentPtr->privatePtr->aboveVisRgn, rgn, rgn); } win2Ptr = winPtr; while ((win2Ptr = win2Ptr->nextPtr)) { if (Tk_IsTopLevel(win2Ptr) || !Tk_IsMapped(win2Ptr)) { continue; } TkMacOSXWinCGBounds(win2Ptr, &bounds); ChkErr(TkMacOSHIShapeDifferenceWithRect, rgn, &bounds); } } else if (Tk_IsEmbedded(winPtr)) { win2Ptr = TkpGetOtherWindow(winPtr); if (win2Ptr) { TkMacOSXUpdateClipRgn(win2Ptr); ChkErr(HIShapeIntersect, win2Ptr->privatePtr->aboveVisRgn, rgn, rgn); } else if (tkMacOSXEmbedHandler != NULL) { TkRegion r = TkCreateRegion(); HIShapeRef visRgn; tkMacOSXEmbedHandler->getClipProc((Tk_Window) winPtr, r); visRgn = TkMacOSXGetNativeRegion(r); ChkErr(HIShapeIntersect, visRgn, rgn, rgn); CFRelease(visRgn); TkpReleaseRegion(r); } /* * TODO: Here we should handle out of process embedding. */ } else if (winPtr->wmInfoPtr->attributes & kWindowResizableAttribute) { NSWindow *w = TkMacOSXDrawableWindow(winPtr->window); if (w) { bounds = NSRectToCGRect([w _growBoxRect]); bounds.origin.y = [w contentRectForFrameRect: [w frame]].size.height - bounds.size.height - bounds.origin.y; ChkErr(TkMacOSHIShapeDifferenceWithRect, rgn, &bounds); } } macWin->aboveVisRgn = HIShapeCreateCopy(rgn); /* * The final clip region is the aboveVis region (or visible region) * minus all the children of this window. If the window is a * container, we must also subtract the region of the embedded * window. */ win2Ptr = winPtr->childList; while (win2Ptr) { if (Tk_IsTopLevel(win2Ptr) || !Tk_IsMapped(win2Ptr)) { win2Ptr = win2Ptr->nextPtr; continue; |
︙ | ︙ | |||
880 881 882 883 884 885 886 887 888 889 890 891 892 893 | } } /* * TODO: Here we should handle out of process embedding. */ } if (rgnChanged) { HIShapeRef diffRgn = HIShapeCreateDifference( macWin->aboveVisRgn, rgn); if (!HIShapeIsEmpty(diffRgn)) { macWin->visRgn = HIShapeCreateCopy(rgn); } | > | 781 782 783 784 785 786 787 788 789 790 791 792 793 794 795 | } } /* * TODO: Here we should handle out of process embedding. */ } if (rgnChanged) { HIShapeRef diffRgn = HIShapeCreateDifference( macWin->aboveVisRgn, rgn); if (!HIShapeIsEmpty(diffRgn)) { macWin->visRgn = HIShapeCreateCopy(rgn); } |
︙ | ︙ | |||
911 912 913 914 915 916 917 | } macWin->aboveVisRgn = TkMacOSXHIShapeCreateEmpty(); } if (!macWin->visRgn) { macWin->visRgn = HIShapeCreateCopy(macWin->aboveVisRgn); } macWin->flags &= ~TK_CLIP_INVALID; | < < < < | | > | > > > > > | > > | > > > > > > > > > > > > | > > > > | > > < > | > > > > > > > < | > > > > > > > > > > > > | < | < < | | > > | < < < < < < < < < | | | | | | > > > > | > | > > > > > > > > > > > > | < > < < | < < < < < < < < < < < < < | < < | < < < < < < < < < < < | | < < < < > | < | > > > > > > | < > > | < < | | > | < | < | < < < < < | > > > | > > | > > > | | | | | | < < < < < < < < < | < < < < < < < < < < | | | | | | | | > > > > | > | | > | | | | | | > | | | | | | | | | 813 814 815 816 817 818 819 820 821 822 823 824 825 826 827 828 829 830 831 832 833 834 835 836 837 838 839 840 841 842 843 844 845 846 847 848 849 850 851 852 853 854 855 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 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 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 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 1128 1129 1130 1131 1132 1133 1134 1135 1136 1137 1138 1139 1140 1141 1142 1143 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 1178 1179 1180 1181 1182 1183 1184 1185 1186 1187 1188 1189 1190 1191 1192 1193 1194 | } macWin->aboveVisRgn = TkMacOSXHIShapeCreateEmpty(); } if (!macWin->visRgn) { macWin->visRgn = HIShapeCreateCopy(macWin->aboveVisRgn); } macWin->flags &= ~TK_CLIP_INVALID; } } /* *---------------------------------------------------------------------- * * TkMacOSXVisableClipRgn -- * * This function returns the Macintosh cliping region for the given * window. The caller is responsible for disposing of the returned * region via TkDestroyRegion(). * * Results: * The region. * * Side effects: * None. * *---------------------------------------------------------------------- */ TkRegion TkMacOSXVisableClipRgn( TkWindow *winPtr) { if (winPtr->privatePtr->flags & TK_CLIP_INVALID) { TkMacOSXUpdateClipRgn(winPtr); } return (TkRegion)HIShapeCreateMutableCopy(winPtr->privatePtr->visRgn); } /* *---------------------------------------------------------------------- * * TkMacOSXInvalidateViewRegion -- * * This function invalidates the given region of a view. * * Results: * None. * * Side effects: * Damage is created. * *---------------------------------------------------------------------- */ static OSStatus InvalViewRect(int msg, HIShapeRef rgn, const CGRect *rect, void *ref) { static CGAffineTransform t; NSView *view = ref; if (!view) { return paramErr; } switch (msg) { case kHIShapeEnumerateInit: t = CGAffineTransformMake(1.0, 0.0, 0.0, -1.0, 0.0, NSHeight([view bounds])); break; case kHIShapeEnumerateRect: [view setNeedsDisplayInRect:NSRectFromCGRect( CGRectApplyAffineTransform(*rect, t))]; break; } return noErr; } void TkMacOSXInvalidateViewRegion( NSView *view, HIShapeRef rgn) { if (view && !HIShapeIsEmpty(rgn)) { ChkErr(HIShapeEnumerate, rgn, kHIShapeParseFromBottom|kHIShapeParseFromLeft, InvalViewRect, view); } } /* *---------------------------------------------------------------------- * * TkMacOSXInvalidateWindow -- * * This function invalidates a window and (optionally) its children. * * Results: * None. * * Side effects: * Damage is created. * *---------------------------------------------------------------------- */ void TkMacOSXInvalidateWindow( MacDrawable *macWin, /* Window to be invalidated. */ int flag) /* Should be TK_WINDOW_ONLY or * TK_PARENT_WINDOW */ { #ifdef TK_MAC_DEBUG_CLIP_REGIONS TkMacOSXDbgMsg("%s", winPtr->pathName); #endif if (macWin->flags & TK_CLIP_INVALID) { TkMacOSXUpdateClipRgn(macWin->winPtr); } TkMacOSXInvalidateViewRegion(TkMacOSXDrawableView(macWin), (flag == TK_WINDOW_ONLY) ? macWin->visRgn : macWin->aboveVisRgn); } /* *---------------------------------------------------------------------- * * TkMacOSXDrawableWindow -- * * This function returns the NSWindow for a given X drawable. * * Results: * A NSWindow, or nil for off screen pixmaps. * * Side effects: * None. * *---------------------------------------------------------------------- */ NSWindow* TkMacOSXDrawableWindow( Drawable drawable) { MacDrawable *macWin = (MacDrawable *) drawable; NSWindow *result = nil; if (!macWin || macWin->flags & TK_IS_PIXMAP) { result = nil; } else if (macWin->toplevel && macWin->toplevel->winPtr && macWin->toplevel->winPtr->wmInfoPtr && macWin->toplevel->winPtr->wmInfoPtr->window) { result = macWin->toplevel->winPtr->wmInfoPtr->window; } else if (macWin->winPtr && macWin->winPtr->wmInfoPtr && macWin->winPtr->wmInfoPtr->window) { result = macWin->winPtr->wmInfoPtr->window; } else if (macWin->toplevel && (macWin->toplevel->flags & TK_EMBEDDED)) { TkWindow *contWinPtr = TkpGetOtherWindow(macWin->toplevel->winPtr); if (contWinPtr) { result = TkMacOSXDrawableWindow((Drawable) contWinPtr->privatePtr); } } return result; } void * TkMacOSXDrawable( Drawable drawable) { return TkMacOSXDrawableWindow(drawable); } /* *---------------------------------------------------------------------- * * TkMacOSXGetDrawablePort -- * * This function returns the Graphics Port for a given X drawable. * * Results: * NULL. * * Side effects: * None. * *---------------------------------------------------------------------- */ void * TkMacOSXGetDrawablePort( Drawable drawable) { return NULL; } /* *---------------------------------------------------------------------- * * TkMacOSXDrawableView -- * * This function returns the NSView for a given X drawable. * * Results: * A NSView* or nil. * * Side effects: * None. * *---------------------------------------------------------------------- */ NSView* TkMacOSXDrawableView( MacDrawable *macWin) { NSView *result = nil; if (!macWin) { result = nil; } else if (!macWin->toplevel) { result = macWin->view; } else if (!(macWin->toplevel->flags & TK_EMBEDDED)) { result = macWin->toplevel->view; } else { TkWindow *contWinPtr = TkpGetOtherWindow(macWin->toplevel->winPtr); if (contWinPtr) { result = TkMacOSXDrawableView(contWinPtr->privatePtr); } } return result; } /* *---------------------------------------------------------------------- * * TkMacOSXGetRootControl -- * * This function returns the NSView for a given X drawable. * * Results: * A NSView* . * * Side effects: * None. * *---------------------------------------------------------------------- */ void * TkMacOSXGetRootControl( Drawable drawable) { /* * will probably need to fix this up for embedding */ return TkMacOSXDrawableView((MacDrawable *) drawable); } /* *---------------------------------------------------------------------- * * TkMacOSXInvalClipRgns -- * * This function invalidates the clipping regions for a given window and * all of its children. This function should be called whenever changes * are made to subwindows that would affect the size or position of * windows. * * Results: * None. * * Side effects: * The cliping regions for the window and its children are mark invalid. * (Make sure they are valid before drawing.) * *---------------------------------------------------------------------- */ void TkMacOSXInvalClipRgns( Tk_Window tkwin) { TkWindow *winPtr = (TkWindow *) tkwin; TkWindow *childPtr; MacDrawable *macWin = winPtr->privatePtr; /* * If already marked we can stop because all descendants will also already * be marked. */ if (!macWin || macWin->flags & TK_CLIP_INVALID) { return; } macWin->flags |= TK_CLIP_INVALID; if (macWin->visRgn) { CFRelease(macWin->visRgn); macWin->visRgn = NULL; } if (macWin->aboveVisRgn) { CFRelease(macWin->aboveVisRgn); macWin->aboveVisRgn = NULL; } if (macWin->drawRgn) { CFRelease(macWin->drawRgn); macWin->drawRgn = NULL; } /* * Invalidate clip regions for all children & their descendants, unless the * child is a toplevel. */ childPtr = winPtr->childList; while (childPtr) { if (!Tk_IsTopLevel(childPtr)) { TkMacOSXInvalClipRgns((Tk_Window) childPtr); } childPtr = childPtr->nextPtr; } /* * Also, if the window is a container, mark its embedded window. */ if (Tk_IsContainer(winPtr)) { childPtr = TkpGetOtherWindow(winPtr); if (childPtr) { TkMacOSXInvalClipRgns((Tk_Window) childPtr); } /* * TODO: Here we should handle out of process embedding. */ } } /* *---------------------------------------------------------------------- * * TkMacOSXWinBounds -- * * Given a Tk window this function determines the windows bounds in * relation to the Macintosh window's coordinate system. This is also the * same coordinate system as the Tk toplevel window in which this window * is contained. * * Results: * None. * * Side effects: * None. * *---------------------------------------------------------------------- */ void TkMacOSXWinBounds( TkWindow *winPtr, void *bounds) { Rect *b = (Rect *)bounds; b->left = winPtr->privatePtr->xOff; b->top = winPtr->privatePtr->yOff; b->right = b->left + winPtr->changes.width; b->bottom = b->top + winPtr->changes.height; } /* *---------------------------------------------------------------------- * * TkMacOSXWinCGBounds -- * * Given a Tk window this function determines the windows bounds in * relation to the Macintosh window's coordinate system. This is also the * same coordinate system as the Tk toplevel window in which this window * is contained. * * Results: * None. * * Side effects: * None. * |
︙ | ︙ | |||
1295 1296 1297 1298 1299 1300 1301 | } /* *---------------------------------------------------------------------- * * UpdateOffsets -- * | | | | | | | | | > | 1207 1208 1209 1210 1211 1212 1213 1214 1215 1216 1217 1218 1219 1220 1221 1222 1223 1224 1225 1226 1227 1228 1229 1230 1231 1232 1233 1234 1235 1236 1237 1238 1239 1240 1241 1242 1243 1244 1245 1246 1247 1248 1249 | } /* *---------------------------------------------------------------------- * * UpdateOffsets -- * * Updates the X & Y offsets of the given TkWindow from the TopLevel it is * a decendant of. * * Results: * None. * * Side effects: * The xOff & yOff fields for the Mac window datastructure is updated to * the proper offset. * *---------------------------------------------------------------------- */ static void UpdateOffsets( TkWindow *winPtr, int deltaX, int deltaY) { TkWindow *childPtr; if (winPtr->privatePtr == NULL) { /* * We haven't called Tk_MakeWindowExist for this window yet. The offset * information will be postponed and calulated at that time. (This will * usually only happen when a mapped parent is being moved but has * child windows that have yet to be mapped.) */ return; } winPtr->privatePtr->xOff += deltaX; winPtr->privatePtr->yOff += deltaY; childPtr = winPtr->childList; |
︙ | ︙ | |||
1384 1385 1386 1387 1388 1389 1390 | } macPix = (MacDrawable *) ckalloc(sizeof(MacDrawable)); macPix->winPtr = NULL; macPix->xOff = 0; macPix->yOff = 0; macPix->visRgn = NULL; macPix->aboveVisRgn = NULL; | | | < < < < < < < < < < | 1297 1298 1299 1300 1301 1302 1303 1304 1305 1306 1307 1308 1309 1310 1311 1312 1313 1314 1315 1316 1317 | } macPix = (MacDrawable *) ckalloc(sizeof(MacDrawable)); macPix->winPtr = NULL; macPix->xOff = 0; macPix->yOff = 0; macPix->visRgn = NULL; macPix->aboveVisRgn = NULL; macPix->drawRgn = NULL; macPix->referenceCount = 0; macPix->toplevel = NULL; macPix->flags = TK_IS_PIXMAP | (depth == 1 ? TK_IS_BW_PIXMAP : 0); macPix->view = nil; macPix->context = NULL; macPix->size = CGSizeMake(width, height); return (Pixmap) macPix; } /* *---------------------------------------------------------------------- * |
︙ | ︙ | |||
1429 1430 1431 1432 1433 1434 1435 | Tk_FreePixmap( Display *display, /* Display. */ Pixmap pixmap) /* Pixmap to destroy */ { MacDrawable *macPix = (MacDrawable *) pixmap; display->request++; | | > | > > | | < | 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 | Tk_FreePixmap( Display *display, /* Display. */ Pixmap pixmap) /* Pixmap to destroy */ { MacDrawable *macPix = (MacDrawable *) pixmap; display->request++; if (macPix->context) { char *data = CGBitmapContextGetData(macPix->context); if (data) { ckfree(data); } CFRelease(macPix->context); } ckfree((char *) macPix); } /* * Local Variables: * mode: c * c-basic-offset: 4 * fill-column: 79 * coding: utf-8 * End: */ |
Changes to macosx/tkMacOSXTest.c.
1 2 3 4 5 6 7 | /* * tkMacOSXTest.c -- * * Contains commands for platform specific tests for * the Macintosh platform. * * Copyright (c) 1996 Sun Microsystems, Inc. | | | | | 1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 | /* * tkMacOSXTest.c -- * * Contains commands for platform specific tests for * the Macintosh platform. * * Copyright (c) 1996 Sun Microsystems, Inc. * Copyright 2001-2009, Apple Inc. * Copyright (c) 2005-2009 Daniel A. Steffen <[email protected]> * * See the file "license.terms" for information on usage and redistribution * of this file, and for a DISCLAIMER OF ALL WARRANTIES. */ #include "tkMacOSXPrivate.h" /* * Forward declarations of procedures defined later in this file: */ static int DebuggerCmd (ClientData dummy, Tcl_Interp *interp, int argc, const char **argv); |
︙ | ︙ | |||
75 76 77 78 79 80 81 | Tcl_Interp *interp, /* Not used. */ int argc, /* Not used. */ const char **argv) /* Not used. */ { Debugger(); return TCL_OK; } | > > > > > > > > > | 75 76 77 78 79 80 81 82 83 84 85 86 87 88 89 90 | Tcl_Interp *interp, /* Not used. */ int argc, /* Not used. */ const char **argv) /* Not used. */ { Debugger(); return TCL_OK; } /* * Local Variables: * mode: c * c-basic-offset: 4 * fill-column: 79 * coding: utf-8 * End: */ |
Changes to macosx/tkMacOSXWindowEvent.c.
1 2 3 | /* * tkMacOSXWindowEvent.c -- * | | | | | < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < | | > < | > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > | > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > | > > > > > | > | > > > > > | > > > > | > > > > > > | > > > | > | > | | > > | > | > > > > | < > > > > > | > > > | | | > > > > | > > > > | > > > > > > > > > > | > > > > > > > > > > > > > > > > > > > > > > > > | | > | > > > > > > > > > > > > > > > > > > > > > > > < < < < < < < < < < < < < < < < < < < < < < | < < < < < < < < < < < < < < < < < < < < | < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < | < < < < < < < < < < < < | < < < < < < < < < < < | < < < < < < < < < < < < < < < | < < < < < < | < < < | < < < < < | < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < | | < < < < < < < < < < < < < < < | < < < < < < < < < < < < < < < < < | < < < < > | < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < | < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < | < < < < < < | < < | < < | < < < < < < < < | < < < < < < < < < < < < < < < < < < | < < < < < < < < | < < < < | | | | | 1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 34 35 36 37 38 39 40 41 42 43 44 45 46 47 48 49 50 51 52 53 54 55 56 57 58 59 60 61 62 63 64 65 66 67 68 69 70 71 72 73 74 75 76 77 78 79 80 81 82 83 84 85 86 87 88 89 90 91 92 93 94 95 96 97 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 129 130 131 132 133 134 135 136 137 138 139 140 141 142 143 144 145 146 147 148 149 150 151 152 153 154 155 156 157 158 159 160 161 162 163 164 165 166 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 224 225 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 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 284 285 286 287 288 289 290 291 292 293 294 295 296 297 298 299 300 301 302 303 304 305 306 307 308 309 310 311 | /* * tkMacOSXWindowEvent.c -- * * This file defines the routines for both creating and handling Window * Manager class events for Tk. * * Copyright 2001-2009, Apple Inc. * Copyright (c) 2005-2009 Daniel A. Steffen <[email protected]> * * See the file "license.terms" for information on usage and redistribution of * this file, and for a DISCLAIMER OF ALL WARRANTIES. */ #include "tkMacOSXPrivate.h" #include "tkMacOSXWm.h" #include "tkMacOSXEvent.h" #include "tkMacOSXDebug.h" /* #ifdef TK_MAC_DEBUG #define TK_MAC_DEBUG_EVENTS #define TK_MAC_DEBUG_DRAWING #endif */ /* * Declaration of functions used only in this file */ static int GenerateUpdates(HIMutableShapeRef updateRgn, CGRect *updateBounds, TkWindow *winPtr); static int GenerateActivateEvents(TkWindow *winPtr, int activeFlag); static void DoWindowActivate(ClientData clientData); #pragma mark TKApplication(TKWindowEvent) #ifdef TK_MAC_DEBUG_NOTIFICATIONS extern NSString *NSWindowWillOrderOnScreenNotification; extern NSString *NSWindowDidOrderOnScreenNotification; extern NSString *NSWindowDidOrderOffScreenNotification; #if MAC_OS_X_VERSION_MIN_REQUIRED < 1060 #define NSWindowWillStartLiveResizeNotification @"NSWindowWillStartLiveResizeNotification" #define NSWindowDidEndLiveResizeNotification @"NSWindowDidEndLiveResizeNotification" #endif #endif extern NSString *opaqueTag; @implementation TKApplication(TKWindowEvent) - (void) windowActivation: (NSNotification *) notification { #ifdef TK_MAC_DEBUG_NOTIFICATIONS TKLog(@"-[%@(%p) %s] %@", [self class], self, _cmd, notification); #endif BOOL activate = [[notification name] isEqualToString:NSWindowDidBecomeKeyNotification]; NSWindow *w = [notification object]; TkWindow *winPtr = TkMacOSXGetTkWindow(w); if (winPtr && Tk_IsMapped(winPtr)) { GenerateActivateEvents(winPtr, activate); } } - (void) windowBoundsChanged: (NSNotification *) notification { #ifdef TK_MAC_DEBUG_NOTIFICATIONS TKLog(@"-[%@(%p) %s] %@", [self class], self, _cmd, notification); #endif BOOL movedOnly = [[notification name] isEqualToString:NSWindowDidMoveNotification]; if (movedOnly) { /* constraining to screen after move not needed with AppKit */ } NSWindow *w = [notification object]; TkWindow *winPtr = TkMacOSXGetTkWindow(w); if (winPtr) { WmInfo *wmPtr = winPtr->wmInfoPtr; NSRect bounds = [w frame]; int x, y, width = -1, height = -1, flags = 0; x = bounds.origin.x; y = tkMacOSXZeroScreenHeight - (bounds.origin.y + bounds.size.height); if (winPtr->changes.x != x || winPtr->changes.y != y){ flags |= TK_LOCATION_CHANGED; } else { x = y = -1; } if (!movedOnly && (winPtr->changes.width != bounds.size.width || winPtr->changes.height != bounds.size.height)) { width = bounds.size.width - wmPtr->xInParent; height = bounds.size.height - wmPtr->yInParent; flags |= TK_SIZE_CHANGED; } if (Tcl_GetServiceMode() != TCL_SERVICE_NONE) { /* * Propagate geometry changes immediately. */ flags |= TK_MACOSX_HANDLE_EVENT_IMMEDIATELY; } TkGenWMConfigureEvent((Tk_Window) winPtr, x, y, width, height, flags); } } - (void) windowExpanded: (NSNotification *) notification { #ifdef TK_MAC_DEBUG_NOTIFICATIONS TKLog(@"-[%@(%p) %s] %@", [self class], self, _cmd, notification); #endif NSWindow *w = [notification object]; TkWindow *winPtr = TkMacOSXGetTkWindow(w); if (winPtr) { winPtr->wmInfoPtr->hints.initial_state = TkMacOSXIsWindowZoomed(winPtr) ? ZoomState : NormalState; Tk_MapWindow((Tk_Window) winPtr); if (Tcl_GetServiceMode() != TCL_SERVICE_NONE) { /* * Process all Tk events generated by Tk_MapWindow(). */ while (Tcl_ServiceEvent(0)) {} while (Tcl_DoOneEvent(TCL_IDLE_EVENTS|TCL_DONT_WAIT)) {} /* * NSWindowDidDeminiaturizeNotification is received after * NSWindowDidBecomeKeyNotification, so activate manually */ GenerateActivateEvents(winPtr, 1); } else { Tcl_DoWhenIdle(DoWindowActivate, winPtr); } } } - (void) windowCollapsed: (NSNotification *) notification { #ifdef TK_MAC_DEBUG_NOTIFICATIONS TKLog(@"-[%@(%p) %s] %@", [self class], self, _cmd, notification); #endif NSWindow *w = [notification object]; TkWindow *winPtr = TkMacOSXGetTkWindow(w); if (winPtr) { Tk_UnmapWindow((Tk_Window) winPtr); } } - (BOOL) windowShouldClose: (NSWindow *) w { #ifdef TK_MAC_DEBUG_NOTIFICATIONS TKLog(@"-[%@(%p) %s] %@", [self class], self, _cmd, w); #endif TkWindow *winPtr = TkMacOSXGetTkWindow(w); if (winPtr) { TkGenWMDestroyEvent((Tk_Window) winPtr); } /* * If necessary, TkGenWMDestroyEvent() handles [close]ing the window, * so can always return NO from -windowShouldClose: for a Tk window. */ return (winPtr ? NO : YES); } #ifdef TK_MAC_DEBUG_NOTIFICATIONS - (void) windowDragStart: (NSNotification *) notification { TKLog(@"-[%@(%p) %s] %@", [self class], self, _cmd, notification); } - (void) windowLiveResize: (NSNotification *) notification { TKLog(@"-[%@(%p) %s] %@", [self class], self, _cmd, notification); //BOOL start = [[notification name] isEqualToString:NSWindowWillStartLiveResizeNotification]; } - (void) windowMapped: (NSNotification *) notification { TKLog(@"-[%@(%p) %s] %@", [self class], self, _cmd, notification); NSWindow *w = [notification object]; TkWindow *winPtr = TkMacOSXGetTkWindow(w); if (winPtr) { //Tk_MapWindow((Tk_Window) winPtr); } } - (void) windowBecameVisible: (NSNotification *) notification { TKLog(@"-[%@(%p) %s] %@", [self class], self, _cmd, notification); } - (void) windowUnmapped: (NSNotification *) notification { TKLog(@"-[%@(%p) %s] %@", [self class], self, _cmd, notification); NSWindow *w = [notification object]; TkWindow *winPtr = TkMacOSXGetTkWindow(w); if (winPtr) { //Tk_UnmapWindow((Tk_Window) winPtr); } } #endif /* TK_MAC_DEBUG_NOTIFICATIONS */ - (void) _setupWindowNotifications { NSNotificationCenter *nc = [NSNotificationCenter defaultCenter]; #define observe(n, s) \ [nc addObserver:self selector:@selector(s) name:(n) object:nil] observe(NSWindowDidBecomeKeyNotification, windowActivation:); observe(NSWindowDidResignKeyNotification, windowActivation:); observe(NSWindowDidMoveNotification, windowBoundsChanged:); observe(NSWindowDidResizeNotification, windowBoundsChanged:); observe(NSWindowDidDeminiaturizeNotification, windowExpanded:); observe(NSWindowDidMiniaturizeNotification, windowCollapsed:); #ifdef TK_MAC_DEBUG_NOTIFICATIONS observe(NSWindowWillMoveNotification, windowDragStart:); observe(NSWindowWillStartLiveResizeNotification, windowLiveResize:); observe(NSWindowDidEndLiveResizeNotification, windowLiveResize:); observe(NSWindowWillOrderOnScreenNotification, windowMapped:); observe(NSWindowDidOrderOnScreenNotification, windowBecameVisible:); observe(NSWindowDidOrderOffScreenNotification, windowUnmapped:); #endif #undef observe } @end #pragma mark TKApplication(TKApplicationEvent) @implementation TKApplication(TKApplicationEvent) - (void) applicationActivate: (NSNotification *) notification { #ifdef TK_MAC_DEBUG_NOTIFICATIONS TKLog(@"-[%@(%p) %s] %@", [self class], self, _cmd, notification); #endif [NSApp tkCheckPasteboard]; } - (void) applicationDeactivate: (NSNotification *) notification { #ifdef TK_MAC_DEBUG_NOTIFICATIONS TKLog(@"-[%@(%p) %s] %@", [self class], self, _cmd, notification); #endif TkSuspendClipboard(); } - (void) applicationShowHide: (NSNotification *) notification { #ifdef TK_MAC_DEBUG_NOTIFICATIONS TKLog(@"-[%@(%p) %s] %@", [self class], self, _cmd, notification); #endif const char *cmd = ([[notification name] isEqualToString: NSApplicationDidUnhideNotification] ? "::tk::mac::OnShow" : "::tk::mac::OnHide"); Tcl_CmdInfo dummy; if (_eventInterp && Tcl_GetCommandInfo(_eventInterp, cmd, &dummy)) { int code = Tcl_EvalEx(_eventInterp, cmd, -1, TCL_EVAL_GLOBAL); if (code != TCL_OK) { Tcl_BackgroundError(_eventInterp); } Tcl_ResetResult(_eventInterp); } } - (void) displayChanged: (NSNotification *) notification { #ifdef TK_MAC_DEBUG_NOTIFICATIONS TKLog(@"-[%@(%p) %s] %@", [self class], self, _cmd, notification); #endif TkDisplay *dispPtr = TkGetDisplayList(); if (dispPtr) { TkMacOSXDisplayChanged(dispPtr->display); } } @end #pragma mark - /* *---------------------------------------------------------------------- * * GenerateUpdates -- * * Given a Macintosh update region and a Tk window this function geneates * a X Expose event for the window if it is within the update region. The * function will then recursivly have each damaged window generate Expose * events for its child windows. * * Results: * True if event(s) are generated - false otherwise. * * Side effects: * Additional events may be place on the Tk event queue. * |
︙ | ︙ | |||
525 526 527 528 529 530 531 | CGRect bounds, damageBounds; HIShapeRef boundsRgn, damageRgn; TkMacOSXWinCGBounds(winPtr, &bounds); if (!CGRectIntersectsRect(bounds, *updateBounds)) { return 0; } | < | | | < | < | > > > > | 323 324 325 326 327 328 329 330 331 332 333 334 335 336 337 338 339 340 341 342 343 344 345 346 347 348 349 350 351 352 353 354 355 356 357 358 359 360 361 362 363 364 365 366 367 368 369 370 371 | CGRect bounds, damageBounds; HIShapeRef boundsRgn, damageRgn; TkMacOSXWinCGBounds(winPtr, &bounds); if (!CGRectIntersectsRect(bounds, *updateBounds)) { return 0; } if (!HIShapeIntersectsRect(updateRgn, &bounds)) { return 0; } /* * Compute the bounding box of the area that the damage occured in. */ boundsRgn = HIShapeCreateWithRect(&bounds); damageRgn = HIShapeCreateIntersection(updateRgn, boundsRgn); if (HIShapeIsEmpty(damageRgn)) { CFRelease(damageRgn); CFRelease(boundsRgn); return 0; } HIShapeGetBounds(damageRgn, &damageBounds); CFRelease(damageRgn); CFRelease(boundsRgn); event.xany.serial = LastKnownRequestProcessed(Tk_Display(winPtr)); event.xany.send_event = false; event.xany.window = Tk_WindowId(winPtr); event.xany.display = Tk_Display(winPtr); event.type = Expose; event.xexpose.x = damageBounds.origin.x - bounds.origin.x; event.xexpose.y = damageBounds.origin.y - bounds.origin.y; event.xexpose.width = damageBounds.size.width; event.xexpose.height = damageBounds.size.height; event.xexpose.count = 0; Tk_QueueWindowEvent(&event, TCL_QUEUE_TAIL); #ifdef TK_MAC_DEBUG_DRAWING TKLog(@"Expose %p {{%d, %d}, {%d, %d}}", event.xany.window, event.xexpose.x, event.xexpose.y, event.xexpose.width, event.xexpose.height); #endif /* * Generate updates for the children of this window */ for (childPtr = winPtr->childList; childPtr != NULL; childPtr = childPtr->nextPtr) { |
︙ | ︙ | |||
589 590 591 592 593 594 595 | /* * TODO: Here we should handle out of process embedding. */ } return 1; } | | | | | > | | | > > > | > > > > | < > > > > > > | > > > | | < | | | | | | > > > | < > | < < < < < < < < < < < | | | | | | | < | < | < | | 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 | /* * TODO: Here we should handle out of process embedding. */ } return 1; } /* *---------------------------------------------------------------------- * * GenerateActivateEvents -- * * Given a Macintosh window activate event this function generates all the * X Activate events needed by Tk. * * Results: * True if event(s) are generated - false otherwise. * * Side effects: * Additional events may be place on the Tk event queue. * *---------------------------------------------------------------------- */ int GenerateActivateEvents( TkWindow *winPtr, int activeFlag) { TkGenerateActivateEvents(winPtr, activeFlag); TkMacOSXGenerateFocusEvent(winPtr, activeFlag); return true; } /* *---------------------------------------------------------------------- * * DoWindowActivate -- * * Idle handler that calls GenerateActivateEvents(). * * Results: * None. * * Side effects: * Additional events may be place on the Tk event queue. * *---------------------------------------------------------------------- */ void DoWindowActivate( ClientData clientData) { GenerateActivateEvents(clientData, 1); } /* *---------------------------------------------------------------------- * * TkMacOSXGenerateFocusEvent -- * * Given a Macintosh window activate event this function generates all * the X Focus events needed by Tk. * * Results: * True if event(s) are generated - false otherwise. * * Side effects: * Additional events may be place on the Tk event queue. * *---------------------------------------------------------------------- */ MODULE_SCOPE int TkMacOSXGenerateFocusEvent( TkWindow *winPtr, /* Root X window for event. */ int activeFlag) { XEvent event; /* * Don't send focus events to windows of class help or to windows with the * kWindowNoActivatesAttribute. */ if (winPtr->wmInfoPtr && (winPtr->wmInfoPtr->macClass == kHelpWindowClass || winPtr->wmInfoPtr->attributes & kWindowNoActivatesAttribute)) { return false; } /* * Generate FocusIn and FocusOut events. This event is only sent to the * toplevel window. */ if (activeFlag) { event.xany.type = FocusIn; } else { event.xany.type = FocusOut; } event.xany.serial = LastKnownRequestProcessed(Tk_Display(winPtr)); event.xany.send_event = False; event.xfocus.display = Tk_Display(winPtr); event.xfocus.window = winPtr->window; event.xfocus.mode = NotifyNormal; event.xfocus.detail = NotifyDetailNone; Tk_QueueWindowEvent(&event, TCL_QUEUE_TAIL); return true; } /* *---------------------------------------------------------------------- * * TkGenWMConfigureEvent -- * * Generate a ConfigureNotify event for Tk. Depending on the value of flag * the values of width/height, x/y, or both may be changed. * * Results: * None. * * Side effects: * A ConfigureNotify event is sent to Tk. * *---------------------------------------------------------------------- */ void TkGenWMConfigureEvent( Tk_Window tkwin, int x, int y, int width, int height, int flags) { XEvent event; WmInfo *wmPtr; TkWindow *winPtr = (TkWindow *) tkwin; if (tkwin == NULL) { return; } event.type = ConfigureNotify; event.xconfigure.serial = LastKnownRequestProcessed(Tk_Display(tkwin)); event.xconfigure.send_event = False; event.xconfigure.display = Tk_Display(tkwin); event.xconfigure.event = Tk_WindowId(tkwin); event.xconfigure.window = Tk_WindowId(tkwin); event.xconfigure.border_width = winPtr->changes.border_width; event.xconfigure.override_redirect = winPtr->atts.override_redirect; if (winPtr->changes.stack_mode == Above) { |
︙ | ︙ | |||
751 752 753 754 755 756 757 | height = Tk_Height(tkwin); } event.xconfigure.x = x; event.xconfigure.y = y; event.xconfigure.width = width; event.xconfigure.height = height; | > > > | > > < | | | | | | | | | < | | | | | | | | | | | | > | 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 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 614 615 616 617 618 619 620 621 622 623 624 625 626 627 628 629 | height = Tk_Height(tkwin); } event.xconfigure.x = x; event.xconfigure.y = y; event.xconfigure.width = width; event.xconfigure.height = height; if (flags & TK_MACOSX_HANDLE_EVENT_IMMEDIATELY) { Tk_HandleEvent(&event); } else { Tk_QueueWindowEvent(&event, TCL_QUEUE_TAIL); } /* * Update window manager information. */ if (Tk_IsTopLevel(winPtr)) { wmPtr = winPtr->wmInfoPtr; if (flags & TK_LOCATION_CHANGED) { wmPtr->x = x; wmPtr->y = y; wmPtr->flags &= ~(WM_NEGATIVE_X | WM_NEGATIVE_Y); } if ((flags & TK_SIZE_CHANGED) && !(wmPtr->flags & WM_SYNC_PENDING) && ((width != Tk_Width(tkwin)) || (height != Tk_Height(tkwin)))) { if ((wmPtr->width == -1) && (width == winPtr->reqWidth)) { /* * Don't set external width, since the user didn't change it * from what the widgets asked for. */ } else if (wmPtr->gridWin != NULL) { wmPtr->width = wmPtr->reqGridWidth + (width - winPtr->reqWidth)/wmPtr->widthInc; if (wmPtr->width < 0) { wmPtr->width = 0; } } else { wmPtr->width = width; } if ((wmPtr->height == -1) && (height == winPtr->reqHeight)) { /* * Don't set external height, since the user didn't change it * from what the widgets asked for. */ } else if (wmPtr->gridWin != NULL) { wmPtr->height = wmPtr->reqGridHeight + (height - winPtr->reqHeight)/wmPtr->heightInc; if (wmPtr->height < 0) { wmPtr->height = 0; } } else { wmPtr->height = height; } wmPtr->configWidth = width; wmPtr->configHeight = height; } } /* * Now set up the changes structure. Under X we wait for the * ConfigureNotify to set these values. On the Mac we know imediatly that * this is what we want - so we just set them. However, we need to make * sure the windows clipping region is marked invalid so the change is * visible to the subwindow. */ winPtr->changes.x = x; winPtr->changes.y = y; winPtr->changes.width = width; winPtr->changes.height = height; TkMacOSXInvalClipRgns(tkwin); } |
︙ | ︙ | |||
838 839 840 841 842 843 844 | void TkGenWMDestroyEvent( Tk_Window tkwin) { XEvent event; | | | | | < | | < | 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 | void TkGenWMDestroyEvent( Tk_Window tkwin) { XEvent event; event.xany.serial = LastKnownRequestProcessed(Tk_Display(tkwin)); event.xany.send_event = False; event.xany.display = Tk_Display(tkwin); event.xclient.window = Tk_WindowId(tkwin); event.xclient.type = ClientMessage; event.xclient.message_type = Tk_InternAtom(tkwin, "WM_PROTOCOLS"); event.xclient.format = 32; event.xclient.data.l[0] = Tk_InternAtom(tkwin, "WM_DELETE_WINDOW"); Tk_HandleEvent(&event); } /* *---------------------------------------------------------------------- * * TkWmProtocolEventProc -- * * This procedure is called by the Tk_HandleEvent whenever a ClientMessage * event arrives whose type is "WM_PROTOCOLS". This procedure handles the * message from the window manager in an appropriate fashion. * * Results: * None. * * Side effects: * Depends on what sort of handler, if any, was set up for the protocol. * *---------------------------------------------------------------------- */ void TkWmProtocolEventProc( TkWindow *winPtr, /* Window to which the event was sent. */ |
︙ | ︙ | |||
887 888 889 890 891 892 893 | wmPtr = winPtr->wmInfoPtr; if (wmPtr == NULL) { return; } protocol = (Atom) eventPtr->xclient.data.l[0]; for (protPtr = wmPtr->protPtr; protPtr != NULL; | | | | | | | | | | 692 693 694 695 696 697 698 699 700 701 702 703 704 705 706 707 708 709 710 711 712 713 714 715 716 717 718 719 720 721 722 723 724 725 726 727 | wmPtr = winPtr->wmInfoPtr; if (wmPtr == NULL) { return; } protocol = (Atom) eventPtr->xclient.data.l[0]; for (protPtr = wmPtr->protPtr; protPtr != NULL; protPtr = protPtr->nextPtr) { if (protocol == protPtr->protocol) { Tcl_Preserve(protPtr); interp = protPtr->interp; Tcl_Preserve(interp); result = Tcl_GlobalEval(interp, protPtr->command); if (result != TCL_OK) { Tcl_AddErrorInfo(interp, "\n (command for \""); Tcl_AddErrorInfo(interp, Tk_GetAtomName((Tk_Window) winPtr, protocol)); Tcl_AddErrorInfo(interp, "\" window manager protocol)"); Tcl_BackgroundError(interp); } Tcl_Release(interp); Tcl_Release(protPtr); return; } } /* * No handler was present for this protocol. If this is a WM_DELETE_WINDOW * message then just destroy the window. */ if (protocol == Tk_InternAtom((Tk_Window) winPtr, "WM_DELETE_WINDOW")) { Tk_DestroyWindow((Tk_Window) winPtr); } } |
︙ | ︙ | |||
943 944 945 946 947 948 949 | ProcessSerialNumber frontPsn, ourPsn = {0, kCurrentProcess}; Boolean isFrontProcess = true; err = ChkErr(GetFrontProcess, &frontPsn); if (err == noErr) { ChkErr(SameProcess, &frontPsn, &ourPsn, &isFrontProcess); } | | > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > | | < < < < < < < | < < < | > > > > > | > > > > > > > > > > > > > > > | > | > > > > > > > > > | > > > > > > > > > > > | > > > > > > > > > > > | > > > > > > > > > > > > > > | > | > > > > > > > > > | > > > > > > | > > > | > > > | | > > > > > > > | > > > > > > | > | | > > > > > > > | > > > > > > > > | > | > > > > > > > > | 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 773 774 775 776 777 778 779 780 781 782 783 784 785 786 787 788 789 790 791 792 793 794 795 796 797 798 799 800 801 802 803 804 805 806 807 808 809 810 811 812 813 814 815 816 817 818 819 820 821 822 823 824 825 826 827 828 829 830 831 832 833 834 835 836 837 838 839 840 841 842 843 844 845 846 847 848 849 850 851 852 853 854 855 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 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 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 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 | ProcessSerialNumber frontPsn, ourPsn = {0, kCurrentProcess}; Boolean isFrontProcess = true; err = ChkErr(GetFrontProcess, &frontPsn); if (err == noErr) { ChkErr(SameProcess, &frontPsn, &ourPsn, &isFrontProcess); } return (isFrontProcess == true); } #pragma mark TKContentView #import <ApplicationServices/ApplicationServices.h> /* * Custom content view for Tk NSWindows, containing standard NSView subviews. * The goal is to emulate X11-style drawing in response to Expose events: * during the normal AppKit drawing cycle, we supress drawing of all subviews * (using a technique adapted from WebKit's WebHTMLView) and instead send * Expose events about the subviews that would be redrawn. Tk Expose event * handling and drawing handlers then draw the subviews manually via their * -displayRectIgnoringOpacity: */ @interface TKContentView(TKWindowEvent) - (void) drawRect: (NSRect) rect; - (void) generateExposeEvents: (HIMutableShapeRef) shape; - (BOOL) isOpaque; - (BOOL) wantsDefaultClipping; - (BOOL) acceptsFirstResponder; - (void) keyDown: (NSEvent *) theEvent; @end @implementation TKContentView @end static Tk_RestrictAction ExposeRestrictProc( ClientData arg, XEvent *eventPtr) { return (eventPtr->type==Expose && eventPtr->xany.serial==PTR2UINT(arg) ? TK_PROCESS_EVENT : TK_DEFER_EVENT); } @implementation TKContentView(TKWindowEvent) - (void) drawRect: (NSRect) rect { const NSRect *rectsBeingDrawn; NSInteger rectsBeingDrawnCount; [self getRectsBeingDrawn:&rectsBeingDrawn count:&rectsBeingDrawnCount]; #ifdef TK_MAC_DEBUG_DRAWING TKLog(@"-[%@(%p) %s%@]", [self class], self, _cmd, NSStringFromRect(rect)); [[NSColor colorWithDeviceRed:0.0 green:1.0 blue:0.0 alpha:.1] setFill]; NSRectFillListUsingOperation(rectsBeingDrawn, rectsBeingDrawnCount, NSCompositeSourceOver); #endif NSWindow *w = [self window]; if ([self isOpaque] && [w showsResizeIndicator]) { NSRect bounds = [self convertRect:[w _growBoxRect] fromView:nil]; if ([self needsToDrawRect:bounds]) { NSEraseRect(bounds); } } CGFloat height = [self bounds].size.height; HIMutableShapeRef drawShape = HIShapeCreateMutable(); while (rectsBeingDrawnCount--) { CGRect r = NSRectToCGRect(*rectsBeingDrawn++); r.origin.y = height - (r.origin.y + r.size.height); HIShapeUnionWithRect(drawShape, &r); } if (CFRunLoopGetMain() == CFRunLoopGetCurrent()) { [self generateExposeEvents:drawShape]; } else { [self performSelectorOnMainThread:@selector(generateExposeEvents:) withObject:(id)drawShape waitUntilDone:NO modes:[NSArray arrayWithObjects:NSRunLoopCommonModes, NSEventTrackingRunLoopMode, NSModalPanelRunLoopMode, nil]]; } CFRelease(drawShape); } - (void) generateExposeEvents: (HIMutableShapeRef) shape { TkWindow *winPtr = TkMacOSXGetTkWindow([self window]); unsigned long serial; CGRect updateBounds; if (!winPtr) { return; } HIShapeGetBounds(shape, &updateBounds); serial = LastKnownRequestProcessed(Tk_Display(winPtr)); if (GenerateUpdates(shape, &updateBounds, winPtr) && ![[NSRunLoop currentRunLoop] currentMode] && Tcl_GetServiceMode() != TCL_SERVICE_NONE) { /* * Ensure there are no pending idle-time redraws that could prevent the * just posted Expose events from generating new redraws. */ while (Tcl_DoOneEvent(TCL_IDLE_EVENTS|TCL_DONT_WAIT)) {} /* * For smoother drawing, process Expose events and resulting redraws * immediately instead of at idle time. */ ClientData oldArg; Tk_RestrictProc *oldProc = Tk_RestrictEvents(ExposeRestrictProc, UINT2PTR(serial), &oldArg); while (Tcl_ServiceEvent(TCL_WINDOW_EVENTS)) {} Tk_RestrictEvents(oldProc, oldArg, &oldArg); while (Tcl_DoOneEvent(TCL_IDLE_EVENTS|TCL_DONT_WAIT)) {} } } - (void) tkToolbarButton: (id) sender { #ifdef TK_MAC_DEBUG_EVENTS TKLog(@"-[%@(%p) %s] %@", [self class], self, _cmd); #endif XVirtualEvent event; int x, y; TkWindow *winPtr = TkMacOSXGetTkWindow([self window]); Tk_Window tkwin = (Tk_Window) winPtr; bzero(&event, sizeof(XVirtualEvent)); event.type = VirtualEvent; event.serial = LastKnownRequestProcessed(Tk_Display(tkwin)); event.send_event = false; event.display = Tk_Display(tkwin); event.event = Tk_WindowId(tkwin); event.root = XRootWindow(Tk_Display(tkwin), 0); event.subwindow = None; event.time = TkpGetMS(); XQueryPointer(NULL, winPtr->window, NULL, NULL, &event.x_root, &event.y_root, &x, &y, &event.state); Tk_TopCoordsToWindow(tkwin, x, y, &event.x, &event.y); event.same_screen = true; event.name = Tk_GetUid("ToolbarButton"); Tk_QueueWindowEvent((XEvent *) &event, TCL_QUEUE_TAIL); } #ifdef TK_MAC_DEBUG_DRAWING - (void) setFrameSize: (NSSize) newSize { TKLog(@"-[%@(%p) %s%@]", [self class], self, _cmd, NSStringFromSize(newSize)); [super setFrameSize:newSize]; } - (void) setNeedsDisplayInRect: (NSRect) invalidRect { TKLog(@"-[%@(%p) %s%@]", [self class], self, _cmd, NSStringFromRect(invalidRect)); [super setNeedsDisplayInRect:invalidRect]; } #endif - (BOOL) isOpaque { NSWindow *w = [self window]; if (opaqueTag != NULL) { return YES; } else { return (w && (([w styleMask] & NSTexturedBackgroundWindowMask) || ![w isOpaque]) ? NO : YES); } } - (BOOL) wantsDefaultClipping { return NO; } - (BOOL) acceptsFirstResponder { return YES; } - (void) keyDown: (NSEvent *) theEvent { #ifdef TK_MAC_DEBUG_EVENTS TKLog(@"-[%@(%p) %s] %@", [self class], self, _cmd, theEvent); #endif } @end #pragma mark TKContentViewPrivate /* * Technique adapted from WebKit/WebKit/mac/WebView/WebHTMLView.mm to supress * normal AppKit subview drawing and make all drawing go through us. * Overrides NSView internals. */ @interface TKContentView(TKContentViewPrivate) - (id) initWithFrame: (NSRect) frame; - (void) _setAsideSubviews; - (void) _restoreSubviews; @end @interface NSView(TKContentViewPrivate) - (void) _recursiveDisplayRectIfNeededIgnoringOpacity: (NSRect) rect isVisibleRect: (BOOL) isVisibleRect rectIsVisibleRectForView: (NSView *) visibleView topView: (BOOL) topView; - (void) _recursiveDisplayAllDirtyWithLockFocus: (BOOL) needsLockFocus visRect: (NSRect) visRect; - (void) _recursive: (BOOL) recurse displayRectIgnoringOpacity: (NSRect) displayRect inContext: (NSGraphicsContext *) context topView: (BOOL) topView; - (void) _lightWeightRecursiveDisplayInRect: (NSRect) visRect; - (BOOL) _drawRectIfEmpty; - (void) _drawRect: (NSRect) inRect clip: (BOOL) clip; - (void) _setDrawsOwnDescendants: (BOOL) drawsOwnDescendants; @end @implementation TKContentView(TKContentViewPrivate) - (id) initWithFrame: (NSRect) frame { self = [super initWithFrame:frame]; if (self) { _savedSubviews = nil; _subviewsSetAside = NO; [self _setDrawsOwnDescendants:YES]; } return self; } - (void) _setAsideSubviews { #ifdef TK_MAC_DEBUG if (_subviewsSetAside || _savedSubviews) { Tcl_Panic("TKContentView _setAsideSubviews called incorrectly"); } #endif _savedSubviews = _subviews; _subviews = nil; _subviewsSetAside = YES; } - (void) _restoreSubviews { #ifdef TK_MAC_DEBUG if (!_subviewsSetAside || _subviews) { Tcl_Panic("TKContentView _restoreSubviews called incorrectly"); } #endif _subviews = _savedSubviews; _savedSubviews = nil; _subviewsSetAside = NO; } - (void) _recursiveDisplayRectIfNeededIgnoringOpacity: (NSRect) rect isVisibleRect: (BOOL) isVisibleRect rectIsVisibleRectForView: (NSView *) visibleView topView: (BOOL) topView { [self _setAsideSubviews]; [super _recursiveDisplayRectIfNeededIgnoringOpacity:rect isVisibleRect:isVisibleRect rectIsVisibleRectForView:visibleView topView:topView]; [self _restoreSubviews]; } - (void) _recursiveDisplayAllDirtyWithLockFocus: (BOOL) needsLockFocus visRect: (NSRect) visRect { BOOL needToSetAsideSubviews = !_subviewsSetAside; if (needToSetAsideSubviews) { [self _setAsideSubviews]; } [super _recursiveDisplayAllDirtyWithLockFocus:needsLockFocus visRect:visRect]; if (needToSetAsideSubviews) { [self _restoreSubviews]; } } - (void) _recursive: (BOOL) recurse displayRectIgnoringOpacity: (NSRect) displayRect inContext: (NSGraphicsContext *) context topView: (BOOL) topView { [self _setAsideSubviews]; [super _recursive:recurse displayRectIgnoringOpacity:displayRect inContext:context topView:topView]; [self _restoreSubviews]; } - (void) _lightWeightRecursiveDisplayInRect: (NSRect) visRect { BOOL needToSetAsideSubviews = !_subviewsSetAside; if (needToSetAsideSubviews) { [self _setAsideSubviews]; } [super _lightWeightRecursiveDisplayInRect:visRect]; if (needToSetAsideSubviews) { [self _restoreSubviews]; } } - (BOOL) _drawRectIfEmpty { /* * Our -drawRect manages subview drawing directly, so it needs to be called * even if the area to be redrawn is completely obscured by subviews. */ return YES; } - (void) _drawRect: (NSRect) inRect clip: (BOOL) clip { #ifdef TK_MAC_DEBUG_DRAWING TKLog(@"-[%@(%p) %s%@]", [self class], self, _cmd, NSStringFromRect(inRect)); #endif BOOL subviewsWereSetAside = _subviewsSetAside; if (subviewsWereSetAside) { [self _restoreSubviews]; } [super _drawRect:inRect clip:clip]; if (subviewsWereSetAside) { [self _setAsideSubviews]; } } @end /* * Local Variables: * mode: objc * c-basic-offset: 4 * fill-column: 79 * coding: utf-8 * End: */ |
Changes to macosx/tkMacOSXWm.c.
1 2 3 4 5 6 7 8 9 | /* * tkMacOSXWm.c -- * * This module takes care of the interactions between a Tk-based * application and the window manager. Among other things, it implements * the "wm" command and passes geometry information to the window * manager. * * Copyright (c) 1994-1997 Sun Microsystems, Inc. | | | > | | | > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > | < < < < < < < < | 1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 34 35 36 37 38 39 40 41 42 43 44 45 46 47 48 49 50 51 52 53 54 55 56 57 58 59 60 61 62 63 64 65 66 67 68 69 70 71 72 73 74 75 76 77 78 79 80 81 82 83 84 85 86 87 88 89 90 91 92 93 94 95 96 97 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 129 130 131 132 133 134 135 136 137 138 139 140 141 142 143 144 145 146 147 148 149 150 151 152 153 154 155 156 157 158 159 160 161 162 163 164 165 166 167 168 169 170 | /* * tkMacOSXWm.c -- * * This module takes care of the interactions between a Tk-based * application and the window manager. Among other things, it implements * the "wm" command and passes geometry information to the window * manager. * * Copyright (c) 1994-1997 Sun Microsystems, Inc. * Copyright 2001-2009, Apple Inc. * Copyright (c) 2006-2009 Daniel A. Steffen <[email protected]> * Copyright (c) 2010 Kevin Walzer/WordTech Communications LLC. * * See the file "license.terms" for information on usage and redistribution * of this file, and for a DISCLAIMER OF ALL WARRANTIES. */ #include "tkMacOSXPrivate.h" #include "tkScrollbar.h" #include "tkMacOSXWm.h" #include "tkMacOSXEvent.h" #include "tkMacOSXDebug.h" /* #ifdef TK_MAC_DEBUG #define TK_MAC_DEBUG_WINDOWS #endif */ /* * Window attributes and classes */ #define WM_NSMASK_SHIFT 36 #define tkWindowDoesNotHideAttribute \ ((UInt64) 1 << kHIWindowBitDoesNotHide) #define tkCanJoinAllSpacesAttribute \ ((UInt64) NSWindowCollectionBehaviorCanJoinAllSpaces << 34) #define tkMoveToActiveSpaceAttribute \ ((UInt64) NSWindowCollectionBehaviorMoveToActiveSpace << 34) #define tkNonactivatingPanelAttribute \ ((UInt64) NSNonactivatingPanelMask << WM_NSMASK_SHIFT) #define tkHUDWindowAttribute \ ((UInt64) NSHUDWindowMask << WM_NSMASK_SHIFT) #define tkAlwaysValidAttributes (kWindowNoUpdatesAttribute \ | kWindowNoActivatesAttribute | kWindowHideOnSuspendAttribute \ | kWindowHideOnFullScreenAttribute | kWindowNoConstrainAttribute \ | kWindowNoShadowAttribute | kWindowLiveResizeAttribute \ | kWindowOpaqueForEventsAttribute | kWindowIgnoreClicksAttribute \ | kWindowDoesNotCycleAttribute | tkWindowDoesNotHideAttribute \ | tkCanJoinAllSpacesAttribute | tkMoveToActiveSpaceAttribute \ | tkNonactivatingPanelAttribute | tkHUDWindowAttribute) /*Objects for use in setting background color and opacity of window.*/ NSColor *colorName = NULL; NSString *opaqueTag = NULL; static const struct { const UInt64 validAttrs, defaultAttrs, forceOnAttrs, forceOffAttrs; int flags; NSUInteger styleMask; } macClassAttrs[] = { [kAlertWindowClass] = { .defaultAttrs = kWindowDoesNotCycleAttribute, }, [kMovableAlertWindowClass] = { .defaultAttrs = kWindowDoesNotCycleAttribute, }, [kModalWindowClass] = { .defaultAttrs = kWindowDoesNotCycleAttribute, }, [kMovableModalWindowClass] = { .validAttrs = kWindowCloseBoxAttribute | kWindowMetalAttribute | kWindowFullZoomAttribute | kWindowResizableAttribute, .defaultAttrs = kWindowDoesNotCycleAttribute, }, [kFloatingWindowClass] = { .validAttrs = kWindowCloseBoxAttribute | kWindowCollapseBoxAttribute | kWindowMetalAttribute | kWindowToolbarButtonAttribute | kWindowNoTitleBarAttribute | kWindowFullZoomAttribute | kWindowResizableAttribute | kWindowSideTitlebarAttribute, .defaultAttrs = kWindowStandardFloatingAttributes | kWindowHideOnSuspendAttribute | kWindowDoesNotCycleAttribute, .forceOnAttrs = kWindowResizableAttribute, .forceOffAttrs = kWindowCollapseBoxAttribute, .styleMask = NSUtilityWindowMask, }, [kDocumentWindowClass] = { .validAttrs = kWindowCloseBoxAttribute | kWindowCollapseBoxAttribute | kWindowMetalAttribute | kWindowToolbarButtonAttribute | kWindowNoTitleBarAttribute | kWindowUnifiedTitleAndToolbarAttribute | kWindowInWindowMenuAttribute | kWindowFullZoomAttribute | kWindowResizableAttribute, .forceOnAttrs = kWindowResizableAttribute, .defaultAttrs = kWindowStandardDocumentAttributes | kWindowLiveResizeAttribute | kWindowInWindowMenuAttribute, }, [kUtilityWindowClass] = { .validAttrs = kWindowCloseBoxAttribute | kWindowCollapseBoxAttribute | kWindowMetalAttribute | kWindowToolbarButtonAttribute | kWindowNoTitleBarAttribute | kWindowFullZoomAttribute | kWindowResizableAttribute | kWindowSideTitlebarAttribute, .defaultAttrs = kWindowStandardFloatingAttributes | kWindowHideOnFullScreenAttribute | tkWindowDoesNotHideAttribute | tkNonactivatingPanelAttribute | kWindowDoesNotCycleAttribute, .forceOnAttrs = kWindowResizableAttribute, .forceOffAttrs = kWindowCollapseBoxAttribute, .flags = WM_TOPMOST, .styleMask = NSUtilityWindowMask, }, [kHelpWindowClass] = { .defaultAttrs = kWindowHideOnSuspendAttribute, .forceOnAttrs = kWindowNoTitleBarAttribute | kWindowDoesNotCycleAttribute, .flags = WM_TOPMOST, }, [kSheetWindowClass] = { .validAttrs = kWindowResizableAttribute, .forceOnAttrs = kWindowNoTitleBarAttribute | kWindowDoesNotCycleAttribute, .styleMask = NSDocModalWindowMask, }, [kToolbarWindowClass] = { .defaultAttrs = kWindowHideOnSuspendAttribute, .forceOnAttrs = kWindowNoTitleBarAttribute | kWindowDoesNotCycleAttribute, .styleMask = NSUtilityWindowMask, }, [kPlainWindowClass] = { .defaultAttrs = kWindowDoesNotCycleAttribute, .forceOnAttrs = kWindowNoTitleBarAttribute, }, [kOverlayWindowClass] = { .forceOnAttrs = kWindowNoTitleBarAttribute | kWindowDoesNotCycleAttribute, .flags = WM_TOPMOST | WM_TRANSPARENT, }, [kSheetAlertWindowClass] = { .forceOnAttrs = kWindowNoTitleBarAttribute | kWindowDoesNotCycleAttribute, .styleMask = NSDocModalWindowMask, }, [kAltPlainWindowClass] = { .defaultAttrs = kWindowDoesNotCycleAttribute, .forceOnAttrs = kWindowNoTitleBarAttribute, }, [kSimpleWindowClass] = { .defaultAttrs = kWindowDoesNotCycleAttribute, .forceOnAttrs = kWindowNoTitleBarAttribute, }, [kDrawerWindowClass] = { .validAttrs = kWindowMetalAttribute | kWindowResizableAttribute, .forceOnAttrs = kWindowNoTitleBarAttribute | kWindowDoesNotCycleAttribute, }, }; #define ForceAttributes(attributes, class) \ ((attributes) & (~macClassAttrs[(class)].forceOffAttrs | \ (macClassAttrs[(class)].forceOnAttrs & ~kWindowResizableAttribute))) /* * Data for [wm attributes] command: */ typedef enum { WMATT_ALPHA, WMATT_FULLSCREEN, WMATT_MODIFIED, WMATT_NOTIFY, WMATT_TITLEPATH, WMATT_TOPMOST, WMATT_TRANSPARENT, _WMATT_LAST_ATTRIBUTE } WmAttribute; static const char *const WmAttributeNames[] = { "-alpha", "-fullscreen", "-modified", "-notify", "-titlepath", "-topmost", "-transparent", NULL }; /* * The variable below is used to enable or disable tracing in this module. If * tracing is enabled, then information is printed on standard output about * interesting interactions with the window manager. */ static int wmTracing = 0; |
︙ | ︙ | |||
83 84 85 86 87 88 89 | static Tcl_HashTable windowTable; static int windowHashInit = false; /* * Forward declarations for procedures defined in this file: */ | | | | > | > | | | | | | > | > > > > > > > > > > > > > > > > > > > > > | | > > > > | > | | | > > > > | > > > > > > > > > > > > > > > > > > > | | | > | | > > > > > > > | | > | > | | > | | > | | > | | > > > > > > | < | > | | > > > > > > > > > > > | > | > > > > > | > > > > > > > > > > | > | | > > | > > | > | > > > > > > > > > > > > > > > | | < > | > > > > | | | > | < | | | | > > > > > > > > > > > > > > > > > > > > > > > > | < > | | | > > > > > > > > > | < > > > > > | > > > > | > > > > | > > > | > > > > > > > > > > > | | > | > | > | | | | | > > | > | > > > > > > > > > | | 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 224 225 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 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 284 285 286 287 288 289 290 291 292 293 294 295 296 297 298 299 300 301 302 303 304 305 306 307 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 338 339 340 341 342 343 344 345 346 347 348 349 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 | static Tcl_HashTable windowTable; static int windowHashInit = false; /* * Forward declarations for procedures defined in this file: */ static NSRect InitialWindowBounds(TkWindow *winPtr, NSWindow *macWindow); static int ParseGeometry(Tcl_Interp *interp, char *string, TkWindow *winPtr); static void TopLevelEventProc(ClientData clientData, XEvent *eventPtr); static void WmStackorderToplevelWrapperMap(TkWindow *winPtr, Display *display, Tcl_HashTable *table); static void UpdateGeometryInfo(ClientData clientData); static void UpdateSizeHints(TkWindow *winPtr); static void UpdateVRootGeometry(WmInfo *wmPtr); static int WmAspectCmd(Tk_Window tkwin, TkWindow *winPtr, Tcl_Interp *interp, int objc, Tcl_Obj *const objv[]); static int WmAttributesCmd(Tk_Window tkwin, TkWindow *winPtr, Tcl_Interp *interp, int objc, Tcl_Obj *const objv[]); static int WmClientCmd(Tk_Window tkwin, TkWindow *winPtr, Tcl_Interp *interp, int objc, Tcl_Obj *const objv[]); static int WmColormapwindowsCmd(Tk_Window tkwin, TkWindow *winPtr, Tcl_Interp *interp, int objc, Tcl_Obj *const objv[]); static int WmCommandCmd(Tk_Window tkwin, TkWindow *winPtr, Tcl_Interp *interp, int objc, Tcl_Obj *const objv[]); static int WmDeiconifyCmd(Tk_Window tkwin, TkWindow *winPtr, Tcl_Interp *interp, int objc, Tcl_Obj *const objv[]); static int WmFocusmodelCmd(Tk_Window tkwin, TkWindow *winPtr, Tcl_Interp *interp, int objc, Tcl_Obj *const objv[]); static int WmForgetCmd(Tk_Window tkwin, TkWindow *winPtr, Tcl_Interp *interp, int objc, Tcl_Obj *const objv[]); static int WmFrameCmd(Tk_Window tkwin, TkWindow *winPtr, Tcl_Interp *interp, int objc, Tcl_Obj *const objv[]); static int WmGeometryCmd(Tk_Window tkwin, TkWindow *winPtr, Tcl_Interp *interp, int objc, Tcl_Obj *const objv[]); static int WmGridCmd(Tk_Window tkwin, TkWindow *winPtr, Tcl_Interp *interp, int objc, Tcl_Obj *const objv[]); static int WmGroupCmd(Tk_Window tkwin, TkWindow *winPtr, Tcl_Interp *interp, int objc, Tcl_Obj *const objv[]); static int WmIconbitmapCmd(Tk_Window tkwin, TkWindow *winPtr, Tcl_Interp *interp, int objc, Tcl_Obj *const objv[]); static int WmIconifyCmd(Tk_Window tkwin, TkWindow *winPtr, Tcl_Interp *interp, int objc, Tcl_Obj *const objv[]); static int WmIconmaskCmd(Tk_Window tkwin, TkWindow *winPtr, Tcl_Interp *interp, int objc, Tcl_Obj *const objv[]); static int WmIconnameCmd(Tk_Window tkwin, TkWindow *winPtr, Tcl_Interp *interp, int objc, Tcl_Obj *const objv[]); static int WmIconphotoCmd(Tk_Window tkwin, TkWindow *winPtr, Tcl_Interp *interp, int objc, Tcl_Obj *const objv[]); static int WmIconpositionCmd(Tk_Window tkwin, TkWindow *winPtr, Tcl_Interp *interp, int objc, Tcl_Obj *const objv[]); static int WmIconwindowCmd(Tk_Window tkwin, TkWindow *winPtr, Tcl_Interp *interp, int objc, Tcl_Obj *const objv[]); static int WmManageCmd(Tk_Window tkwin, TkWindow *winPtr, Tcl_Interp *interp, int objc, Tcl_Obj *const objv[]); static int WmMaxsizeCmd(Tk_Window tkwin, TkWindow *winPtr, Tcl_Interp *interp, int objc, Tcl_Obj *const objv[]); static int WmMinsizeCmd(Tk_Window tkwin, TkWindow *winPtr, Tcl_Interp *interp, int objc, Tcl_Obj *const objv[]); static int WmOverrideredirectCmd(Tk_Window tkwin, TkWindow *winPtr, Tcl_Interp *interp, int objc, Tcl_Obj *const objv[]); static int WmPositionfromCmd(Tk_Window tkwin, TkWindow *winPtr, Tcl_Interp *interp, int objc, Tcl_Obj *const objv[]); static int WmProtocolCmd(Tk_Window tkwin, TkWindow *winPtr, Tcl_Interp *interp, int objc, Tcl_Obj *const objv[]); static int WmResizableCmd(Tk_Window tkwin, TkWindow *winPtr, Tcl_Interp *interp, int objc, Tcl_Obj *const objv[]); static int WmSizefromCmd(Tk_Window tkwin, TkWindow *winPtr, Tcl_Interp *interp, int objc, Tcl_Obj *const objv[]); static int WmStackorderCmd(Tk_Window tkwin, TkWindow *winPtr, Tcl_Interp *interp, int objc, Tcl_Obj *const objv[]); static int WmStateCmd(Tk_Window tkwin, TkWindow *winPtr, Tcl_Interp *interp, int objc, Tcl_Obj *const objv[]); static int WmTitleCmd(Tk_Window tkwin, TkWindow *winPtr, Tcl_Interp *interp, int objc, Tcl_Obj *const objv[]); static int WmTransientCmd(Tk_Window tkwin, TkWindow *winPtr, Tcl_Interp *interp, int objc, Tcl_Obj *const objv[]); static int WmWithdrawCmd(Tk_Window tkwin, TkWindow *winPtr, Tcl_Interp *interp, int objc, Tcl_Obj *const objv[]); static void WmUpdateGeom(WmInfo *wmPtr, TkWindow *winPtr); static int WmWinStyle(Tcl_Interp *interp, TkWindow *winPtr, int objc, Tcl_Obj *const objv[]); static void ApplyWindowAttributeFlagChanges(TkWindow *winPtr, NSWindow *macWindow, UInt64 oldAttributes, int oldFlags, int create, int initial); static void ApplyMasterOverrideChanges(TkWindow *winPtr, NSWindow *macWindow); static void GetMinSize(TkWindow *winPtr, int *minWidthPtr, int *minHeightPtr); static void GetMaxSize(TkWindow *winPtr, int *maxWidthPtr, int *maxHeightPtr); static void RemapWindows(TkWindow *winPtr, MacDrawable *parentWin); #pragma mark TKWindow(TKWm) #if MAC_OS_X_VERSION_MIN_REQUIRED < 1060 @interface NSWindow(TkWm) - (void) setCanCycle: (BOOL) canCycleFlag; @end #endif @interface NSDrawerWindow : NSWindow { id _i1, _i2; } @end @implementation TKWindow @end @implementation TKWindow(TKWm) - (BOOL) canBecomeKeyWindow { TkWindow *winPtr = TkMacOSXGetTkWindow(self); return (winPtr && winPtr->wmInfoPtr && (winPtr->wmInfoPtr->macClass == kHelpWindowClass || winPtr->wmInfoPtr->attributes & kWindowNoActivatesAttribute)) ? NO : YES; } @end #pragma mark - /* *---------------------------------------------------------------------- * * SetWindowSizeLimits -- * * Sets NSWindow size limits * * Results: * None. * * Side effects: * None. * *---------------------------------------------------------------------- */ static void SetWindowSizeLimits( TkWindow *winPtr) { NSWindow *macWindow = TkMacOSXDrawableWindow(winPtr->window); WmInfo *wmPtr = winPtr->wmInfoPtr; int minWidth, minHeight, maxWidth, maxHeight, base; if (!macWindow) { return; } GetMinSize(winPtr, &minWidth, &minHeight); GetMaxSize(winPtr, &maxWidth, &maxHeight); if (wmPtr->gridWin) { base = winPtr->reqWidth - (wmPtr->reqGridWidth * wmPtr->widthInc); if (base < 0) { base = 0; } minWidth = base + (minWidth * wmPtr->widthInc); maxWidth = base + (maxWidth * wmPtr->widthInc); base = winPtr->reqHeight - (wmPtr->reqGridHeight * wmPtr->heightInc); if (base < 0) { base = 0; } minHeight = base + (minHeight * wmPtr->heightInc); maxHeight = base + (maxHeight * wmPtr->heightInc); } if (wmPtr->flags & WM_WIDTH_NOT_RESIZABLE) { minWidth = maxWidth = wmPtr->configWidth; } if (wmPtr->flags & WM_HEIGHT_NOT_RESIZABLE) { minHeight = maxHeight = wmPtr->configHeight; } if (wmPtr->gridWin) { [macWindow setResizeIncrements:NSMakeSize(wmPtr->widthInc, wmPtr->heightInc)]; } else if (wmPtr->sizeHintsFlags & PAspect && wmPtr->minAspect.x == wmPtr->maxAspect.x && wmPtr->minAspect.y == wmPtr->maxAspect.y) { NSSize aspect = NSMakeSize(wmPtr->minAspect.x, wmPtr->minAspect.y); CGFloat ratio = aspect.width/aspect.height; [macWindow setContentAspectRatio:aspect]; if ((CGFloat)minWidth/(CGFloat)minHeight > ratio) { minHeight = lround(minWidth / ratio); } else { minWidth = lround(minHeight * ratio); } if ((CGFloat)maxWidth/(CGFloat)maxHeight > ratio) { maxWidth = lround(maxHeight * ratio); } else { maxHeight = lround(maxWidth / ratio); } if ((CGFloat)wmPtr->configWidth/(CGFloat)wmPtr->configHeight > ratio) { wmPtr->configWidth = lround(wmPtr->configHeight * ratio); if (wmPtr->configWidth < minWidth) { wmPtr->configWidth = minWidth; wmPtr->configHeight = minHeight; } } else { wmPtr->configHeight = lround(wmPtr->configWidth / ratio); if (wmPtr->configHeight < minHeight) { wmPtr->configWidth = minWidth; wmPtr->configHeight = minHeight; } } } else { [macWindow setResizeIncrements:NSMakeSize(1.0, 1.0)]; } [macWindow setContentMinSize:NSMakeSize(minWidth, minHeight)]; [macWindow setContentMaxSize:NSMakeSize(maxWidth, maxHeight)]; } /* *---------------------------------------------------------------------- * * FrontWindowAtPoint -- * * Find frontmost toplevel window at a given screen location. * * Results: * TkWindow*. * * Side effects: * None. * *---------------------------------------------------------------------- */ static TkWindow* FrontWindowAtPoint( int x, int y) { NSPoint p = NSMakePoint(x, tkMacOSXZeroScreenHeight - y); NSWindow *win = nil; NSInteger windowCount; NSInteger *windowNumbers; NSCountWindows(&windowCount); if (windowCount) { windowNumbers = (NSInteger *) ckalloc(windowCount * sizeof(NSInteger)); NSWindowList(windowCount, windowNumbers); for (NSInteger index = 0; index < windowCount; index++) { NSWindow *w = [NSApp windowWithWindowNumber:windowNumbers[index]]; if (w && NSMouseInRect(p, [w frame], NO)) { win = w; break; } } ckfree((char *) windowNumbers); } return (win ? TkMacOSXGetTkWindow(win) : NULL); } /* *---------------------------------------------------------------------- * * TkWmNewWindow -- * * This procedure is invoked whenever a new top-level window is created. |
︙ | ︙ | |||
239 240 241 242 243 244 245 | wmPtr->configWidth = -1; wmPtr->configHeight = -1; wmPtr->vRoot = None; wmPtr->protPtr = NULL; wmPtr->cmdArgv = NULL; wmPtr->clientMachine = NULL; wmPtr->flags = WM_NEVER_MAPPED; | < | < > > > | 548 549 550 551 552 553 554 555 556 557 558 559 560 561 562 563 564 565 566 567 568 569 570 | wmPtr->configWidth = -1; wmPtr->configHeight = -1; wmPtr->vRoot = None; wmPtr->protPtr = NULL; wmPtr->cmdArgv = NULL; wmPtr->clientMachine = NULL; wmPtr->flags = WM_NEVER_MAPPED; wmPtr->macClass = kDocumentWindowClass; wmPtr->attributes = macClassAttrs[kDocumentWindowClass].defaultAttrs; wmPtr->scrollWinPtr = NULL; wmPtr->menuPtr = NULL; wmPtr->window = nil; winPtr->wmInfoPtr = wmPtr; UpdateVRootGeometry(wmPtr); /* * Tk must monitor structure events for top-level windows, in order to * detect size and position changes caused by window managers. */ Tk_CreateEventHandler((Tk_Window) winPtr, StructureNotifyMask, |
︙ | ︙ | |||
295 296 297 298 299 300 301 | TkWmMapWindow( TkWindow *winPtr) /* Top-level window that's about to be * mapped. */ { WmInfo *wmPtr = winPtr->wmInfoPtr; if (wmPtr->flags & WM_NEVER_MAPPED) { | < < > > > | 605 606 607 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 | TkWmMapWindow( TkWindow *winPtr) /* Top-level window that's about to be * mapped. */ { WmInfo *wmPtr = winPtr->wmInfoPtr; if (wmPtr->flags & WM_NEVER_MAPPED) { /* * Create the underlying Mac window for this Tk window. */ if (!TkMacOSXHostToplevelExists(winPtr)) { TkMacOSXMakeRealWindowExist(winPtr); } wmPtr->flags &= ~WM_NEVER_MAPPED; /* * Generate configure event when we first map the window. */ TkGenWMConfigureEvent((Tk_Window) winPtr, wmPtr->x, wmPtr->y, -1, -1, TK_LOCATION_CHANGED); /* * This is the first time this window has ever been mapped. Store all * the window-manager-related information for the window. */ |
︙ | ︙ | |||
408 409 410 411 412 413 414 | *---------------------------------------------------------------------- */ void TkWmDeadWindow( TkWindow *winPtr) /* Top-level window that's being deleted. */ { | | < | 719 720 721 722 723 724 725 726 727 728 729 730 731 732 733 | *---------------------------------------------------------------------- */ void TkWmDeadWindow( TkWindow *winPtr) /* Top-level window that's being deleted. */ { WmInfo *wmPtr = winPtr->wmInfoPtr, *wmPtr2; if (wmPtr == NULL) { return; } if (wmPtr->hints.flags & IconPixmapHint) { Tk_FreeBitmap(winPtr->display, wmPtr->hints.icon_pixmap); } |
︙ | ︙ | |||
449 450 451 452 453 454 455 | wmPtr->protPtr = protPtr->nextPtr; Tcl_EventuallyFree(protPtr, TCL_DYNAMIC); } if (wmPtr->cmdArgv != NULL) { ckfree((char *) wmPtr->cmdArgv); } if (wmPtr->clientMachine != NULL) { | | > > > > > > > > > > > > > > > > > > > | 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 791 792 793 794 795 796 | wmPtr->protPtr = protPtr->nextPtr; Tcl_EventuallyFree(protPtr, TCL_DYNAMIC); } if (wmPtr->cmdArgv != NULL) { ckfree((char *) wmPtr->cmdArgv); } if (wmPtr->clientMachine != NULL) { ckfree(wmPtr->clientMachine); } if (wmPtr->flags & WM_UPDATE_PENDING) { Tk_CancelIdleCall(UpdateGeometryInfo, winPtr); } /* * Delete the Mac window and remove it from the windowTable. The window * could be nil if the window was never mapped. However, we don't do this * for embedded windows, they don't go in the window list, and they do not * own their portPtr's. */ NSWindow *window = wmPtr->window; if (window && !Tk_IsEmbedded(winPtr) ) { [[window parentWindow] removeChildWindow:window]; [window close]; TkMacOSXUnregisterMacWindow(window); if (winPtr->window) { ((MacDrawable *)winPtr->window)->view = nil; } TkMacOSXMakeCollectableAndRelease(wmPtr->window); } ckfree((char *) wmPtr); winPtr->wmInfoPtr = NULL; } /* *---------------------------------------------------------------------- * |
︙ | ︙ | |||
510 511 512 513 514 515 516 | Tk_WmObjCmd( ClientData clientData, /* Main window associated with interpreter. */ Tcl_Interp *interp, /* Current interpreter. */ int objc, /* Number of arguments. */ Tcl_Obj *const objv[]) /* Argument objects. */ { Tk_Window tkwin = (Tk_Window) clientData; | | | 839 840 841 842 843 844 845 846 847 848 849 850 851 852 853 | Tk_WmObjCmd( ClientData clientData, /* Main window associated with interpreter. */ Tcl_Interp *interp, /* Current interpreter. */ int objc, /* Number of arguments. */ Tcl_Obj *const objv[]) /* Argument objects. */ { Tk_Window tkwin = (Tk_Window) clientData; static const char *const optionStrings[] = { "aspect", "attributes", "client", "colormapwindows", "command", "deiconify", "focusmodel", "forget", "frame", "geometry", "grid", "group", "iconbitmap", "iconify", "iconmask", "iconname", "iconphoto", "iconposition", "iconwindow", "manage", "maxsize", "minsize", "overrideredirect", "positionfrom", "protocol", "resizable", "sizefrom", |
︙ | ︙ | |||
733 734 735 736 737 738 739 | * *---------------------------------------------------------------------- */ static int WmSetAttribute( TkWindow *winPtr, /* Toplevel to work with */ | | | 1062 1063 1064 1065 1066 1067 1068 1069 1070 1071 1072 1073 1074 1075 1076 | * *---------------------------------------------------------------------- */ static int WmSetAttribute( TkWindow *winPtr, /* Toplevel to work with */ NSWindow *macWindow, Tcl_Interp *interp, /* Current interpreter */ WmAttribute attribute, /* Code of attribute to set */ Tcl_Obj *value) /* New value */ { WmInfo *wmPtr = winPtr->wmInfoPtr; int boolean; |
︙ | ︙ | |||
758 759 760 761 762 763 764 | */ if (dval < 0.0) { dval = 0.0; } else if (dval > 1.0) { dval = 1.0; } | | | | > | > > > | < < < < | < | < < | < < < < < < | < < < < < < < < < | < < < < < < < < < < | < < | < > | > < < < < < < < < < | | > | | 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 1128 1129 1130 1131 1132 1133 1134 1135 1136 1137 1138 1139 1140 1141 1142 1143 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 1178 1179 1180 1181 1182 1183 1184 | */ if (dval < 0.0) { dval = 0.0; } else if (dval > 1.0) { dval = 1.0; } [macWindow setAlphaValue:dval]; break; } case WMATT_FULLSCREEN: if (Tcl_GetBooleanFromObj(interp, value, &boolean) != TCL_OK) { return TCL_ERROR; } if (boolean != ((wmPtr->flags & WM_FULLSCREEN) != 0)) { if (TkMacOSXMakeFullscreen(winPtr, macWindow, boolean, interp) != TCL_OK) { return TCL_ERROR; } } break; case WMATT_MODIFIED: if (Tcl_GetBooleanFromObj(interp, value, &boolean) != TCL_OK) { return TCL_ERROR; } if (boolean != [macWindow isDocumentEdited]) { [macWindow setDocumentEdited:boolean]; } break; case WMATT_NOTIFY: if (Tcl_GetBooleanFromObj(interp, value, &boolean) != TCL_OK) { return TCL_ERROR; } if (boolean == !tkMacOSXWmAttrNotifyVal) { static NSInteger request = -1; if (request >= 0) { [NSApp cancelUserAttentionRequest:request]; request = -1; } if (boolean) { request = [NSApp requestUserAttention:NSCriticalRequest]; } tkMacOSXWmAttrNotifyVal = boolean; } break; case WMATT_TITLEPATH: { const char *path = Tcl_FSGetNativePath(value); NSString *filename = @""; if (path && *path) { filename = [NSString stringWithUTF8String:path]; } [macWindow setRepresentedFilename:filename]; break; } case WMATT_TOPMOST: if (Tcl_GetBooleanFromObj(interp, value, &boolean) != TCL_OK) { return TCL_ERROR; } if (boolean != ((wmPtr->flags & WM_TOPMOST) != 0)) { int oldFlags = wmPtr->flags; if (boolean) { wmPtr->flags |= WM_TOPMOST; } else { wmPtr->flags &= ~WM_TOPMOST; } ApplyWindowAttributeFlagChanges(winPtr, macWindow, wmPtr->attributes, oldFlags, 1, 0); } break; case WMATT_TRANSPARENT: if (Tcl_GetBooleanFromObj(interp, value, &boolean) != TCL_OK) { return TCL_ERROR; } if (boolean != ((wmPtr->flags & WM_TRANSPARENT) != 0)) { UInt64 oldAttributes = wmPtr->attributes; int oldFlags = wmPtr->flags; if (boolean) { wmPtr->flags |= WM_TRANSPARENT; wmPtr->attributes |= kWindowNoShadowAttribute; } else { wmPtr->flags &= ~WM_TRANSPARENT; wmPtr->attributes &= ~kWindowNoShadowAttribute; } ApplyWindowAttributeFlagChanges(winPtr, macWindow, oldAttributes, oldFlags, 1, 0); [macWindow setBackgroundColor:boolean ? [NSColor clearColor] : nil]; [macWindow setOpaque:!boolean]; TkMacOSXInvalidateWindow((MacDrawable *) winPtr->window, TK_PARENT_WINDOW); } break; case _WMATT_LAST_ATTRIBUTE: default: return TCL_ERROR; |
︙ | ︙ | |||
904 905 906 907 908 909 910 | * *---------------------------------------------------------------------- */ static Tcl_Obj * WmGetAttribute( TkWindow *winPtr, /* Toplevel to work with */ | | < > | < < < | < | | < < < < < < < < < < < < < < < < < < < < < | > < | 1196 1197 1198 1199 1200 1201 1202 1203 1204 1205 1206 1207 1208 1209 1210 1211 1212 1213 1214 1215 1216 1217 1218 1219 1220 1221 1222 1223 1224 1225 1226 1227 1228 1229 1230 1231 1232 | * *---------------------------------------------------------------------- */ static Tcl_Obj * WmGetAttribute( TkWindow *winPtr, /* Toplevel to work with */ NSWindow *macWindow, WmAttribute attribute) /* Code of attribute to get */ { Tcl_Obj *result = NULL; WmInfo *wmPtr = winPtr->wmInfoPtr; switch (attribute) { case WMATT_ALPHA: result = Tcl_NewDoubleObj([macWindow alphaValue]); break; case WMATT_FULLSCREEN: result = Tcl_NewBooleanObj(wmPtr->flags & WM_FULLSCREEN); break; case WMATT_MODIFIED: result = Tcl_NewBooleanObj([macWindow isDocumentEdited]); break; case WMATT_NOTIFY: result = Tcl_NewBooleanObj(tkMacOSXWmAttrNotifyVal); break; case WMATT_TITLEPATH: result = Tcl_NewStringObj([[macWindow representedFilename] UTF8String], -1); break; case WMATT_TOPMOST: result = Tcl_NewBooleanObj(wmPtr->flags & WM_TOPMOST); break; case WMATT_TRANSPARENT: result = Tcl_NewBooleanObj(wmPtr->flags & WM_TRANSPARENT); break; case _WMATT_LAST_ATTRIBUTE: |
︙ | ︙ | |||
991 992 993 994 995 996 997 | Tk_Window tkwin, /* Main window of the application. */ TkWindow *winPtr, /* Toplevel to work with */ Tcl_Interp *interp, /* Current interpreter. */ int objc, /* Number of arguments. */ Tcl_Obj *const objv[]) /* Argument objects. */ { int attribute = 0; | | | 1258 1259 1260 1261 1262 1263 1264 1265 1266 1267 1268 1269 1270 1271 1272 | Tk_Window tkwin, /* Main window of the application. */ TkWindow *winPtr, /* Toplevel to work with */ Tcl_Interp *interp, /* Current interpreter. */ int objc, /* Number of arguments. */ Tcl_Obj *const objv[]) /* Argument objects. */ { int attribute = 0; NSWindow *macWindow; if (winPtr->window == None) { Tk_MakeWindowExist((Tk_Window) winPtr); } if (!TkMacOSXHostToplevelExists(winPtr)) { TkMacOSXMakeRealWindowExist(winPtr); } |
︙ | ︙ | |||
1079 1080 1081 1082 1083 1084 1085 | Tcl_SetResult(interp, wmPtr->clientMachine, TCL_STATIC); } return TCL_OK; } argv3 = Tcl_GetStringFromObj(objv[3], &length); if (argv3[0] == 0) { if (wmPtr->clientMachine != NULL) { | | | | | 1346 1347 1348 1349 1350 1351 1352 1353 1354 1355 1356 1357 1358 1359 1360 1361 1362 1363 1364 1365 1366 1367 1368 | Tcl_SetResult(interp, wmPtr->clientMachine, TCL_STATIC); } return TCL_OK; } argv3 = Tcl_GetStringFromObj(objv[3], &length); if (argv3[0] == 0) { if (wmPtr->clientMachine != NULL) { ckfree(wmPtr->clientMachine); wmPtr->clientMachine = NULL; } return TCL_OK; } if (wmPtr->clientMachine != NULL) { ckfree(wmPtr->clientMachine); } wmPtr->clientMachine = ckalloc(length + 1); strcpy(wmPtr->clientMachine, argv3); return TCL_OK; } /* *---------------------------------------------------------------------- * |
︙ | ︙ | |||
1142 1143 1144 1145 1146 1147 1148 | } return TCL_OK; } if (Tcl_ListObjGetElements(interp, objv[3], &windowObjc, &windowObjv) != TCL_OK) { return TCL_ERROR; } | | < | 1409 1410 1411 1412 1413 1414 1415 1416 1417 1418 1419 1420 1421 1422 1423 | } return TCL_OK; } if (Tcl_ListObjGetElements(interp, objv[3], &windowObjc, &windowObjv) != TCL_OK) { return TCL_ERROR; } cmapList = (TkWindow **) ckalloc((windowObjc+1) * sizeof(TkWindow*)); for (i = 0; i < windowObjc; i++) { if (TkGetWindowFromObj(interp, tkwin, windowObjv[i], (Tk_Window *) &winPtr2) != TCL_OK) { ckfree((char *) cmapList); return TCL_ERROR; } if (winPtr2 == winPtr) { |
︙ | ︙ | |||
1167 1168 1169 1170 1171 1172 1173 | cmapList[windowObjc] = winPtr; windowObjc++; } else { wmPtr->flags &= ~WM_ADDED_TOPLEVEL_COLORMAP; } wmPtr->flags |= WM_COLORMAPS_EXPLICIT; if (wmPtr->cmapList != NULL) { | | | | | 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 | cmapList[windowObjc] = winPtr; windowObjc++; } else { wmPtr->flags &= ~WM_ADDED_TOPLEVEL_COLORMAP; } wmPtr->flags |= WM_COLORMAPS_EXPLICIT; if (wmPtr->cmapList != NULL) { ckfree((char *) wmPtr->cmapList); } wmPtr->cmapList = cmapList; wmPtr->cmapCount = windowObjc; /* * On the Macintosh all of this is just an excercise in compatability as * we don't support colormaps. If we did they would be installed here. */ return TCL_OK; } /* *---------------------------------------------------------------------- * * WmCommandCmd -- * * This procedure is invoked to process the "wm command" Tcl command. See * the user documentation for details on what it does. * * Results: * A standard Tcl result. * * Side effects: * See the user documentation. * |
︙ | ︙ | |||
1216 1217 1218 1219 1220 1221 1222 | if ((objc != 3) && (objc != 4)) { Tcl_WrongNumArgs(interp, 2, objv, "window ?value?"); return TCL_ERROR; } if (objc == 3) { if (wmPtr->cmdArgv != NULL) { | | > | | 1482 1483 1484 1485 1486 1487 1488 1489 1490 1491 1492 1493 1494 1495 1496 1497 1498 | if ((objc != 3) && (objc != 4)) { Tcl_WrongNumArgs(interp, 2, objv, "window ?value?"); return TCL_ERROR; } if (objc == 3) { if (wmPtr->cmdArgv != NULL) { argv3 = Tcl_Merge(wmPtr->cmdArgc, wmPtr->cmdArgv); Tcl_SetResult(interp, argv3, TCL_VOLATILE); ckfree(argv3); } return TCL_OK; } argv3 = Tcl_GetString(objv[3]); if (argv3[0] == 0) { if (wmPtr->cmdArgv != NULL) { ckfree((char *) wmPtr->cmdArgv); |
︙ | ︙ | |||
1312 1313 1314 1315 1316 1317 1318 | Tk_Window tkwin, /* Main window of the application. */ TkWindow *winPtr, /* Toplevel to work with */ Tcl_Interp *interp, /* Current interpreter. */ int objc, /* Number of arguments. */ Tcl_Obj *const objv[]) /* Argument objects. */ { register WmInfo *wmPtr = winPtr->wmInfoPtr; | | | 1579 1580 1581 1582 1583 1584 1585 1586 1587 1588 1589 1590 1591 1592 1593 | Tk_Window tkwin, /* Main window of the application. */ TkWindow *winPtr, /* Toplevel to work with */ Tcl_Interp *interp, /* Current interpreter. */ int objc, /* Number of arguments. */ Tcl_Obj *const objv[]) /* Argument objects. */ { register WmInfo *wmPtr = winPtr->wmInfoPtr; static const char *const optionStrings[] = { "active", "passive", NULL }; enum options { OPT_ACTIVE, OPT_PASSIVE }; int index; if ((objc != 3) && (objc != 4)) { Tcl_WrongNumArgs(interp, 2, objv, "window ?active|passive?"); |
︙ | ︙ | |||
1363 1364 1365 1366 1367 1368 1369 | static int WmForgetCmd( Tk_Window tkwin, /* Main window of the application. */ TkWindow *winPtr, /* Toplevel or Frame to work with */ Tcl_Interp *interp, /* Current interpreter. */ int objc, /* Number of arguments. */ | | | < < < < < < > | | | < < | < < | < < | < < > | < > | < | 1630 1631 1632 1633 1634 1635 1636 1637 1638 1639 1640 1641 1642 1643 1644 1645 1646 1647 1648 1649 1650 1651 1652 1653 1654 1655 1656 1657 1658 1659 1660 1661 1662 1663 1664 1665 1666 1667 | static int WmForgetCmd( Tk_Window tkwin, /* Main window of the application. */ TkWindow *winPtr, /* Toplevel or Frame to work with */ Tcl_Interp *interp, /* Current interpreter. */ int objc, /* Number of arguments. */ Tcl_Obj *const objv[]) /* Argument objects. */ { register Tk_Window frameWin = (Tk_Window)winPtr; if (Tk_IsTopLevel(frameWin)) { MacDrawable *macWin = (MacDrawable *) winPtr->parentPtr->window; TkFocusJoin(winPtr); Tk_UnmapWindow(frameWin); TkWmDeadWindow(macWin); RemapWindows(winPtr, macWin); winPtr->flags &=~(TK_TOP_HIERARCHY|TK_TOP_LEVEL|TK_HAS_WRAPPER|TK_WIN_MANAGED); /* * Flags (above) must be cleared before calling TkMapTopFrame (below). */ TkMapTopFrame(frameWin); } else { /* Already not managed by wm - ignore it */ } return TCL_OK; } /* *---------------------------------------------------------------------- * * WmFrameCmd -- * |
︙ | ︙ | |||
1439 1440 1441 1442 1443 1444 1445 | Tcl_WrongNumArgs(interp, 2, objv, "window"); return TCL_ERROR; } window = wmPtr->reparent; if (window == None) { window = Tk_WindowId((Tk_Window) winPtr); } | | | 1693 1694 1695 1696 1697 1698 1699 1700 1701 1702 1703 1704 1705 1706 1707 | Tcl_WrongNumArgs(interp, 2, objv, "window"); return TCL_ERROR; } window = wmPtr->reparent; if (window == None) { window = Tk_WindowId((Tk_Window) winPtr); } sprintf(buf, "0x%x", (unsigned) window); Tcl_SetResult(interp, buf, TCL_VOLATILE); return TCL_OK; } /* *---------------------------------------------------------------------- * |
︙ | ︙ | |||
1654 1655 1656 1657 1658 1659 1660 | } Tk_MakeWindowExist(tkwin2); if (wmPtr->leaderName != NULL) { ckfree(wmPtr->leaderName); } wmPtr->hints.window_group = Tk_WindowId(tkwin2); wmPtr->hints.flags |= WindowGroupHint; | | | 1908 1909 1910 1911 1912 1913 1914 1915 1916 1917 1918 1919 1920 1921 1922 | } Tk_MakeWindowExist(tkwin2); if (wmPtr->leaderName != NULL) { ckfree(wmPtr->leaderName); } wmPtr->hints.window_group = Tk_WindowId(tkwin2); wmPtr->hints.flags |= WindowGroupHint; wmPtr->leaderName = ckalloc(length + 1); strcpy(wmPtr->leaderName, argv3); } return TCL_OK; } /* *---------------------------------------------------------------------- |
︙ | ︙ | |||
1733 1734 1735 1736 1737 1738 1739 | } /* *---------------------------------------------------------------------- * * WmIconifyCmd -- * | | | | 1987 1988 1989 1990 1991 1992 1993 1994 1995 1996 1997 1998 1999 2000 2001 2002 | } /* *---------------------------------------------------------------------- * * WmIconifyCmd -- * * This procedure is invoked to process the "wm iconify" Tcl command. See * the user documentation for details on what it does. * * Results: * A standard Tcl result. * * Side effects: * See the user documentation. * |
︙ | ︙ | |||
1873 1874 1875 1876 1877 1878 1879 | int length; if (objc > 4) { Tcl_WrongNumArgs(interp, 2, objv, "window ?newName?"); return TCL_ERROR; } if (objc == 3) { | | | > > | | | | | | | | | < | | 2127 2128 2129 2130 2131 2132 2133 2134 2135 2136 2137 2138 2139 2140 2141 2142 2143 2144 2145 2146 2147 2148 2149 2150 2151 2152 2153 2154 2155 2156 2157 2158 2159 2160 2161 2162 2163 2164 2165 | int length; if (objc > 4) { Tcl_WrongNumArgs(interp, 2, objv, "window ?newName?"); return TCL_ERROR; } if (objc == 3) { if (wmPtr->iconName != NULL) { Tcl_SetObjResult(interp, Tcl_NewStringObj(wmPtr->iconName, -1)); } return TCL_OK; } if (wmPtr->iconName != NULL) { ckfree(wmPtr->iconName); } argv3 = Tcl_GetStringFromObj(objv[3], &length); wmPtr->iconName = ckalloc(length + 1); strcpy(wmPtr->iconName, argv3); if (!(wmPtr->flags & WM_NEVER_MAPPED)) { XSetIconName(winPtr->display, winPtr->window, wmPtr->iconName); } return TCL_OK; } /* *---------------------------------------------------------------------- * * WmIconphotoCmd -- * * This procedure is invoked to process the "wm iconphoto" Tcl command. * See the user documentation for details on what it does. Not yet * implemented for OS X. * * Results: * A standard Tcl result. * * Side effects: * See the user documentation. |
︙ | ︙ | |||
2118 2119 2120 2121 2122 2123 2124 | static int WmManageCmd( Tk_Window tkwin, /* Main window of the application. */ TkWindow *winPtr, /* Toplevel or Frame to work with */ Tcl_Interp *interp, /* Current interpreter. */ int objc, /* Number of arguments. */ | | | < < < | 2373 2374 2375 2376 2377 2378 2379 2380 2381 2382 2383 2384 2385 2386 2387 2388 2389 | static int WmManageCmd( Tk_Window tkwin, /* Main window of the application. */ TkWindow *winPtr, /* Toplevel or Frame to work with */ Tcl_Interp *interp, /* Current interpreter. */ int objc, /* Number of arguments. */ Tcl_Obj *const objv[]) /* Argument objects. */ { register Tk_Window frameWin = (Tk_Window)winPtr; register WmInfo *wmPtr = winPtr->wmInfoPtr; char *oldClass = (char*)Tk_Class(frameWin); if (!Tk_IsTopLevel(frameWin)) { MacDrawable *macWin = (MacDrawable *) winPtr->window; |
︙ | ︙ | |||
2150 2151 2152 2153 2154 2155 2156 | macWin = (MacDrawable *) winPtr->window; } TkWmMapWindow(winPtr); Tk_UnmapWindow(frameWin); } wmPtr = winPtr->wmInfoPtr; winPtr->flags &= ~TK_MAPPED; | < < | | | 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 2428 2429 2430 2431 2432 2433 | macWin = (MacDrawable *) winPtr->window; } TkWmMapWindow(winPtr); Tk_UnmapWindow(frameWin); } wmPtr = winPtr->wmInfoPtr; winPtr->flags &= ~TK_MAPPED; macWin->toplevel = macWin; RemapWindows(winPtr, macWin); winPtr->flags |= (TK_TOP_HIERARCHY|TK_TOP_LEVEL|TK_HAS_WRAPPER|TK_WIN_MANAGED); TkMapTopFrame(frameWin); } else if (Tk_IsTopLevel(frameWin)) { /* Already managed by wm - ignore it */ } return TCL_OK; } /* *---------------------------------------------------------------------- * * WmMaxsizeCmd -- * * This procedure is invoked to process the "wm maxsize" Tcl command. See * the user documentation for details on what it does. * * Results: * A standard Tcl result. * * Side effects: * See the user documentation. * |
︙ | ︙ | |||
2219 2220 2221 2222 2223 2224 2225 | } /* *---------------------------------------------------------------------- * * WmMinsizeCmd -- * | | | | 2469 2470 2471 2472 2473 2474 2475 2476 2477 2478 2479 2480 2481 2482 2483 2484 | } /* *---------------------------------------------------------------------- * * WmMinsizeCmd -- * * This procedure is invoked to process the "wm minsize" Tcl command. See * the user documentation for details on what it does. * * Results: * A standard Tcl result. * * Side effects: * See the user documentation. * |
︙ | ︙ | |||
2298 2299 2300 2301 2302 2303 2304 | XSetWindowAttributes atts; if ((objc != 3) && (objc != 4)) { Tcl_WrongNumArgs(interp, 2, objv, "window ?boolean?"); return TCL_ERROR; } if (objc == 3) { | | | | < | | | 2548 2549 2550 2551 2552 2553 2554 2555 2556 2557 2558 2559 2560 2561 2562 2563 2564 2565 2566 2567 2568 2569 2570 2571 2572 2573 2574 2575 2576 2577 2578 2579 2580 2581 2582 2583 2584 2585 2586 2587 2588 2589 2590 2591 2592 2593 2594 2595 2596 2597 2598 2599 2600 2601 | XSetWindowAttributes atts; if ((objc != 3) && (objc != 4)) { Tcl_WrongNumArgs(interp, 2, objv, "window ?boolean?"); return TCL_ERROR; } if (objc == 3) { Tcl_SetObjResult(interp, Tcl_NewBooleanObj( Tk_Attributes((Tk_Window) winPtr)->override_redirect)); return TCL_OK; } if (Tcl_GetBooleanFromObj(interp, objv[3], &boolean) != TCL_OK) { return TCL_ERROR; } atts.override_redirect = (boolean) ? True : False; Tk_ChangeWindowAttributes((Tk_Window) winPtr, CWOverrideRedirect, &atts); ApplyMasterOverrideChanges(winPtr, NULL); return TCL_OK; } /* *---------------------------------------------------------------------- * * WmPositionfromCmd -- * * This procedure is invoked to process the "wm positionfrom" Tcl * command. See the user documentation for details on what it does. * * Results: * A standard Tcl result. * * Side effects: * See the user documentation. * *---------------------------------------------------------------------- */ static int WmPositionfromCmd( Tk_Window tkwin, /* Main window of the application. */ TkWindow *winPtr, /* Toplevel to work with */ Tcl_Interp *interp, /* Current interpreter. */ int objc, /* Number of arguments. */ Tcl_Obj *const objv[]) /* Argument objects. */ { register WmInfo *wmPtr = winPtr->wmInfoPtr; static const char *const optionStrings[] = { "program", "user", NULL }; enum options { OPT_PROGRAM, OPT_USER }; int index; if ((objc != 3) && (objc != 4)) { Tcl_WrongNumArgs(interp, 2, objv, "window ?user/program?"); |
︙ | ︙ | |||
2495 2496 2497 2498 2499 2500 2501 | TkWindow *winPtr, /* Toplevel to work with */ Tcl_Interp *interp, /* Current interpreter. */ int objc, /* Number of arguments. */ Tcl_Obj *const objv[]) /* Argument objects. */ { register WmInfo *wmPtr = winPtr->wmInfoPtr; int width, height; | | > | 2744 2745 2746 2747 2748 2749 2750 2751 2752 2753 2754 2755 2756 2757 2758 2759 | TkWindow *winPtr, /* Toplevel to work with */ Tcl_Interp *interp, /* Current interpreter. */ int objc, /* Number of arguments. */ Tcl_Obj *const objv[]) /* Argument objects. */ { register WmInfo *wmPtr = winPtr->wmInfoPtr; int width, height; UInt64 oldAttributes = wmPtr->attributes; int oldFlags = wmPtr->flags; if ((objc != 3) && (objc != 5)) { Tcl_WrongNumArgs(interp, 2, objv, "window ?width height?"); return TCL_ERROR; } if (objc == 3) { char buf[TCL_INTEGER_SPACE * 2]; |
︙ | ︙ | |||
2539 2540 2541 2542 2543 2544 2545 | } wmPtr->flags |= WM_UPDATE_SIZE_HINTS; if (wmPtr->scrollWinPtr != NULL) { TkScrollbarEventuallyRedraw((TkScrollbar *) wmPtr->scrollWinPtr->instanceData); } WmUpdateGeom(wmPtr, winPtr); | | < | 2789 2790 2791 2792 2793 2794 2795 2796 2797 2798 2799 2800 2801 2802 2803 | } wmPtr->flags |= WM_UPDATE_SIZE_HINTS; if (wmPtr->scrollWinPtr != NULL) { TkScrollbarEventuallyRedraw((TkScrollbar *) wmPtr->scrollWinPtr->instanceData); } WmUpdateGeom(wmPtr, winPtr); ApplyWindowAttributeFlagChanges(winPtr, NULL, oldAttributes, oldFlags, 1,0); return TCL_OK; } /* *---------------------------------------------------------------------- * * WmSizefromCmd -- |
︙ | ︙ | |||
2570 2571 2572 2573 2574 2575 2576 | Tk_Window tkwin, /* Main window of the application. */ TkWindow *winPtr, /* Toplevel to work with */ Tcl_Interp *interp, /* Current interpreter. */ int objc, /* Number of arguments. */ Tcl_Obj *const objv[]) /* Argument objects. */ { register WmInfo *wmPtr = winPtr->wmInfoPtr; | | | 2819 2820 2821 2822 2823 2824 2825 2826 2827 2828 2829 2830 2831 2832 2833 | Tk_Window tkwin, /* Main window of the application. */ TkWindow *winPtr, /* Toplevel to work with */ Tcl_Interp *interp, /* Current interpreter. */ int objc, /* Number of arguments. */ Tcl_Obj *const objv[]) /* Argument objects. */ { register WmInfo *wmPtr = winPtr->wmInfoPtr; static const char *const optionStrings[] = { "program", "user", NULL }; enum options { OPT_PROGRAM, OPT_USER }; int index; if ((objc != 3) && (objc != 4)) { Tcl_WrongNumArgs(interp, 2, objv, "window ?user|program?"); |
︙ | ︙ | |||
2635 2636 2637 2638 2639 2640 2641 | Tk_Window tkwin, /* Main window of the application. */ TkWindow *winPtr, /* Toplevel to work with */ Tcl_Interp *interp, /* Current interpreter. */ int objc, /* Number of arguments. */ Tcl_Obj *const objv[]) /* Argument objects. */ { TkWindow **windows, **window_ptr; | | | 2884 2885 2886 2887 2888 2889 2890 2891 2892 2893 2894 2895 2896 2897 2898 | Tk_Window tkwin, /* Main window of the application. */ TkWindow *winPtr, /* Toplevel to work with */ Tcl_Interp *interp, /* Current interpreter. */ int objc, /* Number of arguments. */ Tcl_Obj *const objv[]) /* Argument objects. */ { TkWindow **windows, **window_ptr; static const char *const optionStrings[] = { "isabove", "isbelow", NULL }; enum options { OPT_ISABOVE, OPT_ISBELOW }; int index; if ((objc != 3) && (objc != 5)) { Tcl_WrongNumArgs(interp, 2, objv, "window ?isabove|isbelow window?"); |
︙ | ︙ | |||
2690 2691 2692 2693 2694 2695 2696 | /* * Lookup stacking order of all toplevels that are children of "." and * find the position of winPtr and winPtr2 in the stacking order. */ windows = TkWmStackorderToplevel(winPtr->mainPtr->winPtr); | < > | | | | | | | | | | | | | | | | < | | 2939 2940 2941 2942 2943 2944 2945 2946 2947 2948 2949 2950 2951 2952 2953 2954 2955 2956 2957 2958 2959 2960 2961 2962 2963 2964 2965 2966 2967 2968 2969 2970 2971 2972 2973 2974 2975 2976 2977 2978 2979 2980 2981 2982 2983 2984 | /* * Lookup stacking order of all toplevels that are children of "." and * find the position of winPtr and winPtr2 in the stacking order. */ windows = TkWmStackorderToplevel(winPtr->mainPtr->winPtr); if (windows == NULL) { Tcl_AppendResult(interp, "TkWmStackorderToplevel failed", NULL); return TCL_ERROR; } for (window_ptr = windows; *window_ptr ; window_ptr++) { if (*window_ptr == winPtr) { index1 = (window_ptr - windows); } if (*window_ptr == winPtr2) { index2 = (window_ptr - windows); } } if (index1 == -1) { Tcl_Panic("winPtr window not found"); } if (index2 == -1) { Tcl_Panic("winPtr2 window not found"); } ckfree((char *) windows); if (Tcl_GetIndexFromObj(interp, objv[3], optionStrings, "argument", 0, &index) != TCL_OK) { return TCL_ERROR; } if (index == OPT_ISABOVE) { result = index1 > index2; } else { /* OPT_ISBELOW */ result = index1 < index2; } Tcl_SetObjResult(interp, Tcl_NewBooleanObj(result)); return TCL_OK; } return TCL_OK; } /* *---------------------------------------------------------------------- |
︙ | ︙ | |||
2754 2755 2756 2757 2758 2759 2760 | Tk_Window tkwin, /* Main window of the application. */ TkWindow *winPtr, /* Toplevel to work with */ Tcl_Interp *interp, /* Current interpreter. */ int objc, /* Number of arguments. */ Tcl_Obj *const objv[]) /* Argument objects. */ { register WmInfo *wmPtr = winPtr->wmInfoPtr; | | | 3002 3003 3004 3005 3006 3007 3008 3009 3010 3011 3012 3013 3014 3015 3016 | Tk_Window tkwin, /* Main window of the application. */ TkWindow *winPtr, /* Toplevel to work with */ Tcl_Interp *interp, /* Current interpreter. */ int objc, /* Number of arguments. */ Tcl_Obj *const objv[]) /* Argument objects. */ { register WmInfo *wmPtr = winPtr->wmInfoPtr; static const char *const optionStrings[] = { "normal", "iconic", "withdrawn", "zoomed", NULL }; enum options { OPT_NORMAL, OPT_ICONIC, OPT_WITHDRAWN, OPT_ZOOMED }; int index; if ((objc < 3) || (objc > 4)) { Tcl_WrongNumArgs(interp, 2, objv, "window ?state?"); |
︙ | ︙ | |||
2784 2785 2786 2787 2788 2789 2790 2791 | if (Tcl_GetIndexFromObj(interp, objv[3], optionStrings, "argument", 0, &index) != TCL_OK) { return TCL_ERROR; } if (index == OPT_NORMAL) { TkpWmSetState(winPtr, NormalState); /* | > | | < | | | | | | | | | | | | | | | | | | | | | < | 3032 3033 3034 3035 3036 3037 3038 3039 3040 3041 3042 3043 3044 3045 3046 3047 3048 3049 3050 3051 3052 3053 3054 3055 3056 3057 3058 3059 3060 3061 3062 3063 3064 3065 3066 3067 3068 3069 3070 3071 3072 3073 3074 3075 3076 3077 3078 3079 3080 3081 3082 3083 3084 3085 3086 3087 3088 | if (Tcl_GetIndexFromObj(interp, objv[3], optionStrings, "argument", 0, &index) != TCL_OK) { return TCL_ERROR; } if (index == OPT_NORMAL) { TkpWmSetState(winPtr, NormalState); /* * This varies from 'wm deiconify' because it does not force the * window to be raised and receive focus */ } else if (index == OPT_ICONIC) { if (Tk_Attributes((Tk_Window) winPtr)->override_redirect) { Tcl_AppendResult(interp, "can't iconify \"", winPtr->pathName, "\": override-redirect flag is set", NULL); return TCL_ERROR; } if (wmPtr->master != None) { Tcl_AppendResult(interp, "can't iconify \"", winPtr->pathName, "\": it is a transient", NULL); return TCL_ERROR; } TkpWmSetState(winPtr, IconicState); } else if (index == OPT_WITHDRAWN) { TkpWmSetState(winPtr, WithdrawnState); } else { /* OPT_ZOOMED */ TkpWmSetState(winPtr, ZoomState); } } else if (wmPtr->iconFor != NULL) { Tcl_SetResult(interp, "icon", TCL_STATIC); } else { if (wmPtr->hints.initial_state == NormalState || wmPtr->hints.initial_state == ZoomState) { wmPtr->hints.initial_state = (TkMacOSXIsWindowZoomed(winPtr) ? ZoomState : NormalState); } switch (wmPtr->hints.initial_state) { case NormalState: Tcl_SetResult(interp, "normal", TCL_STATIC); break; case IconicState: Tcl_SetResult(interp, "iconic", TCL_STATIC); break; case WithdrawnState: Tcl_SetResult(interp, "withdrawn", TCL_STATIC); break; case ZoomState: Tcl_SetResult(interp, "zoomed", TCL_STATIC); break; } } return TCL_OK; } /* *---------------------------------------------------------------------- |
︙ | ︙ | |||
2907 2908 2909 2910 2911 2912 2913 | Tcl_Interp *interp, /* Current interpreter. */ int objc, /* Number of arguments. */ Tcl_Obj *const objv[]) /* Argument objects. */ { register WmInfo *wmPtr = winPtr->wmInfoPtr; Tk_Window master; WmInfo *wmPtr2; | | | 3154 3155 3156 3157 3158 3159 3160 3161 3162 3163 3164 3165 3166 3167 3168 | Tcl_Interp *interp, /* Current interpreter. */ int objc, /* Number of arguments. */ Tcl_Obj *const objv[]) /* Argument objects. */ { register WmInfo *wmPtr = winPtr->wmInfoPtr; Tk_Window master; WmInfo *wmPtr2; char *masterWindowName; int length; if ((objc != 3) && (objc != 4)) { Tcl_WrongNumArgs(interp, 2, objv, "window ?master?"); return TCL_ERROR; } if (objc == 3) { |
︙ | ︙ | |||
2955 2956 2957 2958 2959 2960 2961 | if ((TkWindow *) master == winPtr) { Tcl_AppendResult(interp, "can't make \"", Tk_PathName(winPtr), "\" its own master", NULL); return TCL_ERROR; } | < > | | | 3202 3203 3204 3205 3206 3207 3208 3209 3210 3211 3212 3213 3214 3215 3216 3217 3218 3219 3220 3221 3222 | if ((TkWindow *) master == winPtr) { Tcl_AppendResult(interp, "can't make \"", Tk_PathName(winPtr), "\" its own master", NULL); return TCL_ERROR; } wmPtr->master = Tk_WindowId(master); masterWindowName = Tcl_GetStringFromObj(objv[3], &length); if (wmPtr->masterWindowName != NULL) { ckfree(wmPtr->masterWindowName); } wmPtr->masterWindowName = ckalloc(length+1); strcpy(wmPtr->masterWindowName, masterWindowName); } ApplyMasterOverrideChanges(winPtr, NULL); return TCL_OK; } /* *---------------------------------------------------------------------- |
︙ | ︙ | |||
3011 3012 3013 3014 3015 3016 3017 3018 | return TCL_OK; } /* * Invoked by those wm subcommands that affect geometry. * Schedules a geometry update. */ static void | > | | | | 3258 3259 3260 3261 3262 3263 3264 3265 3266 3267 3268 3269 3270 3271 3272 3273 3274 3275 3276 | return TCL_OK; } /* * Invoked by those wm subcommands that affect geometry. * Schedules a geometry update. */ static void WmUpdateGeom( WmInfo *wmPtr, TkWindow *winPtr) { if (!(wmPtr->flags & (WM_UPDATE_PENDING|WM_NEVER_MAPPED))) { Tcl_DoWhenIdle(UpdateGeometryInfo, winPtr); wmPtr->flags |= WM_UPDATE_PENDING; } } |
︙ | ︙ | |||
3223 3224 3225 3226 3227 3228 3229 3230 3231 3232 3233 3234 3235 3236 | * best we can. The error handler is needed because * Tk_DestroyWindow will try to destroy the window, but of course * it's already gone. */ Tk_ErrorHandler handler = Tk_CreateErrorHandler(winPtr->display, -1, -1, -1, NULL, NULL); Tk_DestroyWindow((Tk_Window) winPtr); Tk_DeleteErrorHandler(handler); } if (wmTracing) { TkMacOSXDbgMsg("TopLevelEventProc: %s deleted", winPtr->pathName); } } else if (eventPtr->type == ReparentNotify) { | > | 3471 3472 3473 3474 3475 3476 3477 3478 3479 3480 3481 3482 3483 3484 3485 | * best we can. The error handler is needed because * Tk_DestroyWindow will try to destroy the window, but of course * it's already gone. */ Tk_ErrorHandler handler = Tk_CreateErrorHandler(winPtr->display, -1, -1, -1, NULL, NULL); Tk_DestroyWindow((Tk_Window) winPtr); Tk_DeleteErrorHandler(handler); } if (wmTracing) { TkMacOSXDbgMsg("TopLevelEventProc: %s deleted", winPtr->pathName); } } else if (eventPtr->type == ReparentNotify) { |
︙ | ︙ | |||
3297 3298 3299 3300 3301 3302 3303 | static void UpdateGeometryInfo( ClientData clientData) /* Pointer to the window's record. */ { TkWindow *winPtr = clientData; WmInfo *wmPtr = winPtr->wmInfoPtr; int x, y, width, height, min, max; | < | 3546 3547 3548 3549 3550 3551 3552 3553 3554 3555 3556 3557 3558 3559 | static void UpdateGeometryInfo( ClientData clientData) /* Pointer to the window's record. */ { TkWindow *winPtr = clientData; WmInfo *wmPtr = winPtr->wmInfoPtr; int x, y, width, height, min, max; wmPtr->flags &= ~WM_UPDATE_PENDING; if (wmPtr->flags & WM_FULLSCREEN) { return; } |
︙ | ︙ | |||
3462 3463 3464 3465 3466 3467 3468 | wmPtr->x = wmPtr->y = 0; wmPtr->flags &= ~(WM_NEGATIVE_X|WM_NEGATIVE_Y); Tk_GeometryRequest((Tk_Window) contWinPtr, width, height); } return; } | < > | > | | > > | 3710 3711 3712 3713 3714 3715 3716 3717 3718 3719 3720 3721 3722 3723 3724 3725 3726 3727 3728 3729 3730 3731 3732 3733 3734 3735 3736 3737 3738 3739 3740 3741 3742 3743 3744 3745 3746 3747 3748 3749 | wmPtr->x = wmPtr->y = 0; wmPtr->flags &= ~(WM_NEGATIVE_X|WM_NEGATIVE_Y); Tk_GeometryRequest((Tk_Window) contWinPtr, width, height); } return; } if (wmPtr->flags & WM_MOVE_PENDING) { wmPtr->configWidth = width; wmPtr->configHeight = height; if (wmTracing) { TkMacOSXDbgMsg("Moving to %d %d, resizing to %d x %d", x, y, width, height); } SetWindowSizeLimits(winPtr); wmPtr->flags |= WM_SYNC_PENDING; XMoveResizeWindow(winPtr->display, winPtr->window, x, y, wmPtr->configWidth, wmPtr->configHeight); wmPtr->flags &= ~WM_SYNC_PENDING; } else if ((width != wmPtr->configWidth) || (height != wmPtr->configHeight)) { wmPtr->configWidth = width; wmPtr->configHeight = height; if (wmTracing) { TkMacOSXDbgMsg("Resizing to %d x %d\n", width, height); } SetWindowSizeLimits(winPtr); wmPtr->flags |= WM_SYNC_PENDING; XResizeWindow(winPtr->display, winPtr->window, wmPtr->configWidth, wmPtr->configHeight); wmPtr->flags &= ~WM_SYNC_PENDING; } else { SetWindowSizeLimits(winPtr); } } /* *---------------------------------------------------------------------- * * UpdateSizeHints -- |
︙ | ︙ | |||
3695 3696 3697 3698 3699 3700 3701 3702 3703 3704 3705 | */ x = y = 0; while (1) { x += winPtr->changes.x + winPtr->changes.border_width; y += winPtr->changes.y + winPtr->changes.border_width; if (winPtr->flags & TK_TOP_LEVEL) { if (!(Tk_IsEmbedded(winPtr))) { x += winPtr->wmInfoPtr->xInParent; y += winPtr->wmInfoPtr->yInParent; break; | > > < < | < < < < < < | < < < < < | < < | < < | | | | | | | | | | | | | | | | | | > > > > > > > > > > > > > > > | 3946 3947 3948 3949 3950 3951 3952 3953 3954 3955 3956 3957 3958 3959 3960 3961 3962 3963 3964 3965 3966 3967 3968 3969 3970 3971 3972 3973 3974 3975 3976 3977 3978 3979 3980 3981 3982 3983 3984 3985 3986 3987 3988 3989 3990 3991 3992 3993 3994 3995 3996 3997 3998 3999 4000 4001 4002 4003 4004 4005 4006 4007 4008 | */ x = y = 0; while (1) { x += winPtr->changes.x + winPtr->changes.border_width; y += winPtr->changes.y + winPtr->changes.border_width; if (winPtr->flags & TK_TOP_LEVEL) { TkWindow *otherPtr; if (!(Tk_IsEmbedded(winPtr))) { x += winPtr->wmInfoPtr->xInParent; y += winPtr->wmInfoPtr->yInParent; break; } otherPtr = TkpGetOtherWindow(winPtr); if (otherPtr == NULL) { if (tkMacOSXEmbedHandler->getOffsetProc != NULL) { Point theOffset; /* * We do not require that the changes.x & changes.y for a * non-Tk master window be kept up to date. So we first * subtract off the possibly bogus values that have been * added on at the top of this pass through the loop, and * then call out to the getOffsetProc to give us the * correct offset. */ x -= winPtr->changes.x + winPtr->changes.border_width; y -= winPtr->changes.y + winPtr->changes.border_width; tkMacOSXEmbedHandler->getOffsetProc((Tk_Window) winPtr, &theOffset); x += theOffset.h; y += theOffset.v; } break; } /* * The container window is in the same application. Query its * coordinates. */ winPtr = otherPtr; /* * Remember to offset by the container window here, since at the * end of this if branch, we will pop out to the container's * parent... */ x += winPtr->changes.x + winPtr->changes.border_width; y += winPtr->changes.y + winPtr->changes.border_width; } winPtr = winPtr->parentPtr; } *xPtr = x; *yPtr = y; } |
︙ | ︙ | |||
3781 3782 3783 3784 3785 3786 3787 | int rootX, int rootY, /* Coordinates of point in root window. If a * virtual-root window manager is in use, * these coordinates refer to the virtual * root, not the real root. */ Tk_Window tkwin) /* Token for any window in application; used * to identify the display. */ { | < < < < < < | < < < < < < | | 4032 4033 4034 4035 4036 4037 4038 4039 4040 4041 4042 4043 4044 4045 4046 4047 4048 4049 4050 4051 4052 4053 4054 4055 4056 4057 | int rootX, int rootY, /* Coordinates of point in root window. If a * virtual-root window manager is in use, * these coordinates refer to the virtual * root, not the real root. */ Tk_Window tkwin) /* Token for any window in application; used * to identify the display. */ { TkWindow *winPtr, *childPtr; TkWindow *nextPtr; /* Coordinates of highest child found so far * that contains point. */ int x, y; /* Coordinates in winPtr. */ int tmpx, tmpy, bd; /* * Step 1: find the top-level window that contains the desired point. */ winPtr = FrontWindowAtPoint(rootX, rootY); if (!winPtr) { return NULL; } /* * Step 2: work down through the hierarchy underneath this window. At each * level, scan through all the children to find the highest one in the * stacking order that contains the point. Then repeat the whole process |
︙ | ︙ | |||
3836 3837 3838 3839 3840 3841 3842 | if (childPtr != NULL) { if (Tk_IsMapped(childPtr)) { tmpx = x - childPtr->changes.x; tmpy = y - childPtr->changes.y; bd = childPtr->changes.border_width; if ((tmpx >= -bd) && (tmpy >= -bd) | | | | 4075 4076 4077 4078 4079 4080 4081 4082 4083 4084 4085 4086 4087 4088 4089 4090 | if (childPtr != NULL) { if (Tk_IsMapped(childPtr)) { tmpx = x - childPtr->changes.x; tmpy = y - childPtr->changes.y; bd = childPtr->changes.border_width; if ((tmpx >= -bd) && (tmpy >= -bd) && (tmpx < (childPtr->changes.width + bd)) && (tmpy < (childPtr->changes.height + bd))) { nextPtr = childPtr; } } } /* * TODO: Here we should handle out of process embedding. |
︙ | ︙ | |||
4169 4170 4171 4172 4173 4174 4175 | TkWindow *winPtr, /* Window to restack. */ int aboveBelow, /* Gives relative position for restacking; * must be Above or Below. */ TkWindow *otherPtr) /* Window relative to which to restack; if * NULL, then winPtr gets restacked above or * below *all* siblings. */ { | < | | < < | 4408 4409 4410 4411 4412 4413 4414 4415 4416 4417 4418 4419 4420 4421 4422 4423 | TkWindow *winPtr, /* Window to restack. */ int aboveBelow, /* Gives relative position for restacking; * must be Above or Below. */ TkWindow *otherPtr) /* Window relative to which to restack; if * NULL, then winPtr gets restacked above or * below *all* siblings. */ { NSWindow *macWindow; NSInteger otherMacWindowNumber; /* * Get the mac window. Make sure it exists & is mapped. */ if (winPtr->window == None) { Tk_MakeWindowExist((Tk_Window) winPtr); |
︙ | ︙ | |||
4204 4205 4206 4207 4208 4209 4210 | if (otherPtr != NULL) { if (otherPtr->window == None) { Tk_MakeWindowExist((Tk_Window) otherPtr); } if (otherPtr->wmInfoPtr->flags & WM_NEVER_MAPPED) { TkWmMapWindow(otherPtr); } | | > | < < < | < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < | < | 4440 4441 4442 4443 4444 4445 4446 4447 4448 4449 4450 4451 4452 4453 4454 4455 4456 4457 4458 4459 4460 | if (otherPtr != NULL) { if (otherPtr->window == None) { Tk_MakeWindowExist((Tk_Window) otherPtr); } if (otherPtr->wmInfoPtr->flags & WM_NEVER_MAPPED) { TkWmMapWindow(otherPtr); } otherMacWindowNumber = [TkMacOSXDrawableWindow(otherPtr->window) windowNumber]; } else { otherMacWindowNumber = 0; } [macWindow orderWindow:(aboveBelow == Above ? NSWindowAbove : NSWindowBelow) relativeTo:otherMacWindowNumber]; } /* *---------------------------------------------------------------------- * * TkWmAddToColormapWindows -- * |
︙ | ︙ | |||
4325 4326 4327 4328 4329 4330 4331 | } /* * Make a new bigger array and use it to reset the property. Automatically * add the toplevel itself as the last element of the list. */ | | | 4518 4519 4520 4521 4522 4523 4524 4525 4526 4527 4528 4529 4530 4531 4532 | } /* * Make a new bigger array and use it to reset the property. Automatically * add the toplevel itself as the last element of the list. */ newPtr = ckalloc((count+2) * sizeof(TkWindow *)); if (count > 0) { memcpy(newPtr, oldPtr, count * sizeof(TkWindow *)); } if (count == 0) { count++; } newPtr[count-1] = winPtr; |
︙ | ︙ | |||
4455 4456 4457 4458 4459 4460 4461 | * * This function calculates the initial bounds for a new Mac toplevel * window. Unless the geometry is specified by the user this code will * auto place the windows in a cascade diagonially across the main * monitor of the Mac. * * Results: | | | | < < | < < < < < | | < < < < < < | < < < | | > | < < < < | | | 4648 4649 4650 4651 4652 4653 4654 4655 4656 4657 4658 4659 4660 4661 4662 4663 4664 4665 4666 4667 4668 4669 4670 4671 4672 4673 4674 4675 4676 4677 4678 4679 4680 4681 4682 4683 4684 4685 4686 4687 4688 | * * This function calculates the initial bounds for a new Mac toplevel * window. Unless the geometry is specified by the user this code will * auto place the windows in a cascade diagonially across the main * monitor of the Mac. * * Results: * Window bounds. * * Side effects: * None. * *---------------------------------------------------------------------- */ static NSRect InitialWindowBounds( TkWindow *winPtr, /* Window to get initial bounds for. */ NSWindow *macWindow) { WmInfo *wmPtr = winPtr->wmInfoPtr; if (!(wmPtr->sizeHintsFlags & (USPosition | PPosition))) { static NSPoint cascadePoint = { .x = 0, .y = 0 }; NSRect frame; cascadePoint = [macWindow cascadeTopLeftFromPoint:cascadePoint]; frame = [macWindow frame]; wmPtr->x = frame.origin.x; wmPtr->y = tkMacOSXZeroScreenHeight - (frame.origin.y + frame.size.height); } return NSMakeRect(wmPtr->x, wmPtr->y, winPtr->changes.width, winPtr->changes.height); } /* *---------------------------------------------------------------------- * * TkMacOSXResizable -- * |
︙ | ︙ | |||
4564 4565 4566 4567 4568 4569 4570 | * None. * *---------------------------------------------------------------------- */ int TkMacOSXGrowToplevel( | | | < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < | 4738 4739 4740 4741 4742 4743 4744 4745 4746 4747 4748 4749 4750 4751 4752 4753 4754 | * None. * *---------------------------------------------------------------------- */ int TkMacOSXGrowToplevel( void *whichWindow, XPoint start) { return false; } /* *---------------------------------------------------------------------- * * TkSetWMName -- |
︙ | ︙ | |||
4687 4688 4689 4690 4691 4692 4693 | */ void TkSetWMName( TkWindow *winPtr, Tk_Uid titleUid) { | < < < < | | < < | < | 4766 4767 4768 4769 4770 4771 4772 4773 4774 4775 4776 4777 4778 4779 4780 4781 4782 4783 4784 4785 4786 | */ void TkSetWMName( TkWindow *winPtr, Tk_Uid titleUid) { if (Tk_IsEmbedded(winPtr)) { return; } NSString *title = [[NSString alloc] initWithUTF8String:titleUid]; [TkMacOSXDrawableWindow(winPtr->window) setTitle:title]; [title release]; } /* *---------------------------------------------------------------------- * * TkGetTransientMaster -- * |
︙ | ︙ | |||
4735 4736 4737 4738 4739 4740 4741 | } /* *---------------------------------------------------------------------- * * TkMacOSXGetXWindow -- * | | | | | > > > > > > > > > > > > > > > > > > > > > > > > > > > | 4807 4808 4809 4810 4811 4812 4813 4814 4815 4816 4817 4818 4819 4820 4821 4822 4823 4824 4825 4826 4827 4828 4829 4830 4831 4832 4833 4834 4835 4836 4837 4838 4839 4840 4841 4842 4843 4844 4845 4846 4847 4848 4849 4850 4851 4852 4853 4854 4855 4856 4857 4858 4859 4860 4861 4862 4863 4864 4865 4866 4867 4868 4869 4870 4871 4872 4873 | } /* *---------------------------------------------------------------------- * * TkMacOSXGetXWindow -- * * Returns the X window Id associated with the given NSWindow*. * * Results: * The window id is returned. None is returned if not a Tk window. * * Side effects: * None. * *---------------------------------------------------------------------- */ Window TkMacOSXGetXWindow( void *macWinPtr) { Tcl_HashEntry *hPtr; if (!macWinPtr || !windowHashInit) { return None; } hPtr = Tcl_FindHashEntry(&windowTable, macWinPtr); if (hPtr == NULL) { return None; } return (Window) Tcl_GetHashValue(hPtr); } /* *---------------------------------------------------------------------- * * TkMacOSXGetTkWindow -- * * Returns the TkWindow* associated with the given NSWindow*. * * Results: * The TkWindow* returned. NULL is returned if not a Tk window. * * Side effects: * None. * *---------------------------------------------------------------------- */ TkWindow* TkMacOSXGetTkWindow( NSWindow *w) { Window window = TkMacOSXGetXWindow(w); TkDisplay *dispPtr = TkGetDisplayList(); return (window != None ? (TkWindow *)Tk_IdToWindow(dispPtr->display, window) : NULL); } /* *---------------------------------------------------------------------- * * TkMacOSXIsWindowZoomed -- * * Ask Carbon if the given window is in the zoomed out state. Because |
︙ | ︙ | |||
4784 4785 4786 4787 4788 4789 4790 | *---------------------------------------------------------------------- */ MODULE_SCOPE int TkMacOSXIsWindowZoomed( TkWindow *winPtr) { | < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < | < | 4883 4884 4885 4886 4887 4888 4889 4890 4891 4892 4893 4894 4895 4896 4897 | *---------------------------------------------------------------------- */ MODULE_SCOPE int TkMacOSXIsWindowZoomed( TkWindow *winPtr) { return [TkMacOSXDrawableWindow(winPtr->window) isZoomed]; } /* *---------------------------------------------------------------------- * * TkMacOSXZoomToplevel -- * |
︙ | ︙ | |||
4842 4843 4844 4845 4846 4847 4848 | * The window may be resized & events placed on Tk's queue. * *---------------------------------------------------------------------- */ int TkMacOSXZoomToplevel( | | | < | < < < < < < | > | > < < < < < < < < < < < < < < < < < < < < < < < | | < < < > | | < < > | 4907 4908 4909 4910 4911 4912 4913 4914 4915 4916 4917 4918 4919 4920 4921 4922 4923 4924 4925 4926 4927 4928 4929 4930 4931 4932 4933 4934 4935 4936 4937 4938 4939 4940 4941 4942 4943 4944 | * The window may be resized & events placed on Tk's queue. * *---------------------------------------------------------------------- */ int TkMacOSXZoomToplevel( void *whichWindow, /* The Macintosh window to zoom. */ short zoomPart) /* Either inZoomIn or inZoomOut */ { NSWindow *window = whichWindow; TkWindow *winPtr = TkMacOSXGetTkWindow(window); WmInfo *wmPtr; if (!winPtr || !winPtr->wmInfoPtr) { return false; } wmPtr = winPtr->wmInfoPtr; if ((wmPtr->flags & WM_WIDTH_NOT_RESIZABLE) && (wmPtr->flags & WM_HEIGHT_NOT_RESIZABLE)) { return false; } /* * Do nothing if already in desired zoom state. */ if (![window isZoomed] == (zoomPart == inZoomIn)) { return false; } [window zoom:NSApp]; wmPtr->hints.initial_state = (zoomPart == inZoomIn ? NormalState : ZoomState); return true; } /* *---------------------------------------------------------------------- |
︙ | ︙ | |||
4928 4929 4930 4931 4932 4933 4934 | int TkUnsupported1ObjCmd( ClientData clientData, /* Main window associated with interpreter. */ Tcl_Interp *interp, /* Current interpreter. */ int objc, /* Number of arguments. */ Tcl_Obj *const objv[]) /* Argument objects. */ { | | > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > | | | 4962 4963 4964 4965 4966 4967 4968 4969 4970 4971 4972 4973 4974 4975 4976 4977 4978 4979 4980 4981 4982 4983 4984 4985 4986 4987 4988 4989 4990 4991 4992 4993 4994 4995 4996 4997 4998 4999 5000 5001 5002 5003 5004 5005 5006 5007 5008 5009 5010 5011 5012 5013 5014 5015 5016 5017 5018 5019 5020 5021 5022 5023 5024 5025 5026 5027 5028 5029 5030 5031 5032 5033 5034 5035 5036 5037 5038 5039 5040 5041 5042 5043 5044 5045 5046 5047 5048 5049 5050 5051 5052 5053 5054 5055 5056 5057 5058 5059 5060 | int TkUnsupported1ObjCmd( ClientData clientData, /* Main window associated with interpreter. */ Tcl_Interp *interp, /* Current interpreter. */ int objc, /* Number of arguments. */ Tcl_Obj *const objv[]) /* Argument objects. */ { static const char *const subcmds[] = { "style", NULL }; enum SubCmds { TKMWS_STYLE }; Tk_Window tkwin = clientData; TkWindow *winPtr; int index; if (objc < 3) { Tcl_WrongNumArgs(interp, 1, objv, "option window ?arg ...?"); return TCL_ERROR; } /* Iterate through objc/objv to set correct background color and toggle opacity of window. */ int i; for (i= 0; i < objc; i++) { if (Tcl_StringMatch(Tcl_GetString(objv[i]), "*black*") == 1) { colorName = [NSColor blackColor]; // use #000000 in Tk scripts to match } if (Tcl_StringMatch(Tcl_GetString(objv[i]), "*dark*") == 1) { colorName = [NSColor darkGrayColor]; //use #545454 in Tk scripts to match } if (Tcl_StringMatch(Tcl_GetString(objv[i]), "*light*") == 1) { colorName = [NSColor lightGrayColor]; //use #ababab in Tk scripts to match } if (Tcl_StringMatch(Tcl_GetString(objv[i]), "*white*") == 1) { colorName = [NSColor whiteColor]; //use #ffffff in Tk scripts to match } if (Tcl_StringMatch(Tcl_GetString(objv[i]), "gray*") == 1) { colorName = [NSColor grayColor]; //use #7f7f7f in Tk scripts to match } if (Tcl_StringMatch(Tcl_GetString(objv[i]), "*red*") == 1) { colorName = [NSColor redColor]; //use #ff0000 in Tk scripts to match } if (Tcl_StringMatch(Tcl_GetString(objv[i]), "*green*") == 1) { colorName = [NSColor greenColor]; //use #00ff00 in Tk scripts to match } if (Tcl_StringMatch(Tcl_GetString(objv[i]), "*blue*") == 1) { colorName = [NSColor blueColor]; //use #0000ff in Tk scripts to match } if (Tcl_StringMatch(Tcl_GetString(objv[i]), "*cyan*") == 1) { colorName = [NSColor cyanColor]; //use #00ffff in Tk scripts to match } if (Tcl_StringMatch(Tcl_GetString(objv[i]), "*yellow*") == 1) { colorName = [NSColor yellowColor]; //use #ffff00 in Tk scripts to match } if (Tcl_StringMatch(Tcl_GetString(objv[i]), "*magenta*") == 1) { colorName = [NSColor magentaColor]; //use #ff00ff in Tk scripts to match } if (Tcl_StringMatch(Tcl_GetString(objv[i]), "*orange*") == 1) { colorName = [NSColor orangeColor]; //use #ff8000 in Tk scripts to match } if (Tcl_StringMatch(Tcl_GetString(objv[i]), "*purple*") == 1) { colorName = [NSColor purpleColor]; //use #800080 in Tk scripts to match } if (Tcl_StringMatch(Tcl_GetString(objv[i]), "*brown*") == 1){ colorName = [NSColor brownColor]; //use #996633 in Tk scripts to match } if (Tcl_StringMatch(Tcl_GetString(objv[i]), "*clear*") == 1) { colorName = [NSColor clearColor]; //use systemTransparent in Tk scripts to match } if (Tcl_StringMatch(Tcl_GetString(objv[i]), "*opacity*") == 1) { opaqueTag=@"YES"; } } winPtr = (TkWindow *) Tk_NameToWindow(interp, Tcl_GetString(objv[2]), tkwin); if (winPtr == NULL) { return TCL_ERROR; } if (!(winPtr->flags & TK_TOP_LEVEL)) { Tcl_ResetResult(interp); Tcl_AppendResult(interp, "window \"", winPtr->pathName, "\" isn't a top-level window", NULL); return TCL_ERROR; } if (Tcl_GetIndexFromObj(interp, objv[1], subcmds, "option", 0, &index) != TCL_OK) { return TCL_ERROR; } if (((enum SubCmds) index) == TKMWS_STYLE) { if ((objc < 3) || (objc > 5)) { Tcl_WrongNumArgs(interp, 2, objv, "window ?class attributes?"); return TCL_ERROR; } |
︙ | ︙ | |||
4997 4998 4999 5000 5001 5002 5003 | Tcl_Interp *interp, /* Current interpreter. */ TkWindow *winPtr, /* Window to be manipulated. */ int objc, /* Number of arguments. */ Tcl_Obj * const objv[]) /* Argument objects. */ { struct StrIntMap { const char *strValue; | | < < < < < < < < < < < < < < < < < < < | | | | | | | | | | | | | | | | | | | | | | > > > | 5087 5088 5089 5090 5091 5092 5093 5094 5095 5096 5097 5098 5099 5100 5101 5102 5103 5104 5105 5106 5107 5108 5109 5110 5111 5112 5113 5114 5115 5116 5117 5118 5119 5120 5121 5122 5123 5124 5125 5126 5127 5128 5129 5130 5131 | Tcl_Interp *interp, /* Current interpreter. */ TkWindow *winPtr, /* Window to be manipulated. */ int objc, /* Number of arguments. */ Tcl_Obj * const objv[]) /* Argument objects. */ { struct StrIntMap { const char *strValue; UInt64 intValue; }; static const struct StrIntMap classMap[] = { { "alert", kAlertWindowClass }, { "moveableAlert", kMovableAlertWindowClass }, { "modal", kModalWindowClass }, { "moveableModal", kMovableModalWindowClass }, { "floating", kFloatingWindowClass }, { "document", kDocumentWindowClass }, { "utility", kUtilityWindowClass }, { "help", kHelpWindowClass }, { "sheet", kSheetWindowClass }, { "toolbar", kToolbarWindowClass }, { "plain", kPlainWindowClass }, { "overlay", kOverlayWindowClass }, { "sheetAlert", kSheetAlertWindowClass }, { "altPlain", kAltPlainWindowClass }, { "simple", kSimpleWindowClass }, { "drawer", kDrawerWindowClass }, { NULL } }; static const struct StrIntMap compositeAttrMap[] = { { "none", kWindowNoAttributes }, { "standardDocument", kWindowStandardDocumentAttributes }, { "standardFloating", kWindowStandardFloatingAttributes }, { "fullZoom", kWindowFullZoomAttribute }, { NULL } }; /* Map window attributes. Color and opacity are mapped to NULL; these are parsed from the objv in TkUnsupported1ObjCmd.*/ static const struct StrIntMap attrMap[] = { { "closeBox", kWindowCloseBoxAttribute }, { "horizontalZoom", kWindowHorizontalZoomAttribute }, { "verticalZoom", kWindowVerticalZoomAttribute }, { "collapseBox", kWindowCollapseBoxAttribute }, { "resizable", kWindowResizableAttribute }, { "sideTitlebar", kWindowSideTitlebarAttribute }, |
︙ | ︙ | |||
5068 5069 5070 5071 5072 5073 5074 | { "noShadow", kWindowNoShadowAttribute }, { "hideOnSuspend", kWindowHideOnSuspendAttribute }, { "hideOnFullScreen", kWindowHideOnFullScreenAttribute }, { "inWindowMenu", kWindowInWindowMenuAttribute }, { "liveResize", kWindowLiveResizeAttribute }, { "ignoreClicks", kWindowIgnoreClicksAttribute }, { "noConstrain", kWindowNoConstrainAttribute }, | > > > > > > > > > > > > > > > > > > > > | > < < < < < < < < < < | | | | | | | | | | | > | | | | | | | | | | | | | | | | | | | | < | < < < < < < | | > | | < < | | | | | | | | | | | | | | | | | | | > > > > > > > > | | | < > > | 5142 5143 5144 5145 5146 5147 5148 5149 5150 5151 5152 5153 5154 5155 5156 5157 5158 5159 5160 5161 5162 5163 5164 5165 5166 5167 5168 5169 5170 5171 5172 5173 5174 5175 5176 5177 5178 5179 5180 5181 5182 5183 5184 5185 5186 5187 5188 5189 5190 5191 5192 5193 5194 5195 5196 5197 5198 5199 5200 5201 5202 5203 5204 5205 5206 5207 5208 5209 5210 5211 5212 5213 5214 5215 5216 5217 5218 5219 5220 5221 5222 5223 5224 5225 5226 5227 5228 5229 5230 5231 5232 5233 5234 5235 5236 5237 5238 5239 5240 5241 5242 5243 5244 5245 5246 5247 5248 5249 5250 5251 5252 5253 5254 5255 5256 5257 5258 5259 5260 5261 5262 5263 5264 5265 5266 5267 5268 5269 | { "noShadow", kWindowNoShadowAttribute }, { "hideOnSuspend", kWindowHideOnSuspendAttribute }, { "hideOnFullScreen", kWindowHideOnFullScreenAttribute }, { "inWindowMenu", kWindowInWindowMenuAttribute }, { "liveResize", kWindowLiveResizeAttribute }, { "ignoreClicks", kWindowIgnoreClicksAttribute }, { "noConstrain", kWindowNoConstrainAttribute }, { "doesNotHide", tkWindowDoesNotHideAttribute }, { "canJoinAllSpaces", tkCanJoinAllSpacesAttribute }, { "moveToActiveSpace", tkMoveToActiveSpaceAttribute }, { "nonActivating", tkNonactivatingPanelAttribute }, { "hud", tkHUDWindowAttribute }, { "black", NULL }, { "dark", NULL }, { "light", NULL }, { "gray", NULL }, { "red", NULL }, { "green", NULL }, { "blue", NULL }, { "cyan", NULL }, { "yellow", NULL }, { "magenta", NULL }, { "orange", NULL }, { "purple", NULL }, { "brown", NULL }, { "clear", NULL }, { "opacity", NULL }, { NULL } }; int index, i; WmInfo *wmPtr = winPtr->wmInfoPtr; if (objc == 3) { Tcl_Obj *attributeList, *newResult = NULL; UInt64 attributes; for (i = 0; classMap[i].strValue != NULL; i++) { if (wmPtr->macClass == classMap[i].intValue) { newResult = Tcl_NewStringObj(classMap[i].strValue, -1); break; } } if (newResult == NULL) { Tcl_Panic("invalid class"); } attributeList = Tcl_NewListObj(0, NULL); attributes = wmPtr->attributes; for (i = 0; compositeAttrMap[i].strValue != NULL; i++) { UInt64 intValue = compositeAttrMap[i].intValue; if (intValue && (attributes & intValue) == intValue) { Tcl_ListObjAppendElement(interp, attributeList, Tcl_NewStringObj(compositeAttrMap[i].strValue, -1)); attributes &= ~intValue; break; } } for (i = 0; attrMap[i].strValue != NULL; i++) { if (attributes & attrMap[i].intValue) { Tcl_ListObjAppendElement(interp, attributeList, Tcl_NewStringObj(attrMap[i].strValue, -1)); } } Tcl_ListObjAppendElement(interp, newResult, attributeList); Tcl_SetObjResult(interp, newResult); } else { int attrObjc; Tcl_Obj **attrObjv = NULL; WindowClass macClass; UInt64 oldAttributes = wmPtr->attributes; int oldFlags = wmPtr->flags; if (Tcl_GetIndexFromObjStruct(interp, objv[3], classMap, sizeof(struct StrIntMap), "class", 0, &index) != TCL_OK) { goto badClassAttrs; } macClass = classMap[index].intValue; if (objc == 5) { if (Tcl_ListObjGetElements(interp, objv[4], &attrObjc, &attrObjv) != TCL_OK) { goto badClassAttrs; } wmPtr->attributes = kWindowNoAttributes; for (i = 0; i < attrObjc; i++) { if (Tcl_GetIndexFromObjStruct(interp, attrObjv[i], compositeAttrMap, sizeof(struct StrIntMap), "attribute", 0, &index) == TCL_OK) { wmPtr->attributes |= compositeAttrMap[index].intValue; } else if (Tcl_GetIndexFromObjStruct(interp, attrObjv[i], attrMap, sizeof(struct StrIntMap), "attribute", 0, &index) == TCL_OK) { Tcl_ResetResult(interp); wmPtr->attributes |= attrMap[index].intValue; } else { goto badClassAttrs; } } } else { wmPtr->attributes = macClassAttrs[macClass].defaultAttrs; } wmPtr->attributes &= (tkAlwaysValidAttributes | macClassAttrs[macClass].validAttrs); wmPtr->flags |= macClassAttrs[macClass].flags; wmPtr->macClass = macClass; ApplyWindowAttributeFlagChanges(winPtr, NULL, oldAttributes, oldFlags, 0, 1); return TCL_OK; badClassAttrs: wmPtr->attributes = oldAttributes; return TCL_ERROR; } return TCL_OK; } /* *---------------------------------------------------------------------- * * TkpMakeMenuWindow -- |
︙ | ︙ | |||
5232 5233 5234 5235 5236 5237 5238 | */ void TkMacOSXMakeRealWindowExist( TkWindow *winPtr) /* Tk window. */ { WmInfo *wmPtr = winPtr->wmInfoPtr; | < < < < < < | 5319 5320 5321 5322 5323 5324 5325 5326 5327 5328 5329 5330 5331 5332 5333 | */ void TkMacOSXMakeRealWindowExist( TkWindow *winPtr) /* Tk window. */ { WmInfo *wmPtr = winPtr->wmInfoPtr; MacDrawable *macWin; if (TkMacOSXHostToplevelExists(winPtr)) { return; } macWin = (MacDrawable *) winPtr->window; |
︙ | ︙ | |||
5265 5266 5267 5268 5269 5270 5271 | return; } if (tkMacOSXEmbedHandler == NULL) { Tcl_Panic("TkMacOSXMakeRealWindowExist could not find container"); } if (tkMacOSXEmbedHandler->containerExistProc && | | | | | | | < > > | > > > > > > | > | | < > | < < > > | > > | < > | < | > > > > | > > > > > > > > > > > | | | | | > | < < < < < < < < < < < | < < < < < < < < < < < | > > > | < > | < | < < < < | > | | > < | > > > > > | < | < < < < < < < < < | 5346 5347 5348 5349 5350 5351 5352 5353 5354 5355 5356 5357 5358 5359 5360 5361 5362 5363 5364 5365 5366 5367 5368 5369 5370 5371 5372 5373 5374 5375 5376 5377 5378 5379 5380 5381 5382 5383 5384 5385 5386 5387 5388 5389 5390 5391 5392 5393 5394 5395 5396 5397 5398 5399 5400 5401 5402 5403 5404 5405 5406 5407 5408 5409 5410 5411 5412 5413 5414 5415 5416 5417 5418 5419 5420 5421 5422 5423 5424 5425 5426 5427 5428 5429 5430 5431 5432 5433 5434 5435 5436 5437 5438 5439 5440 5441 5442 5443 5444 5445 5446 5447 5448 5449 5450 | return; } if (tkMacOSXEmbedHandler == NULL) { Tcl_Panic("TkMacOSXMakeRealWindowExist could not find container"); } if (tkMacOSXEmbedHandler->containerExistProc && tkMacOSXEmbedHandler->containerExistProc((Tk_Window) winPtr) != TCL_OK) { Tcl_Panic("ContainerExistProc could not make container"); } return; /* * TODO: Here we should handle out of process embedding. */ } WindowClass macClass = wmPtr->macClass; wmPtr->attributes &= (tkAlwaysValidAttributes | macClassAttrs[macClass].validAttrs); wmPtr->flags |= macClassAttrs[macClass].flags | ((wmPtr->attributes & kWindowResizableAttribute) ? 0 : WM_WIDTH_NOT_RESIZABLE|WM_HEIGHT_NOT_RESIZABLE); UInt64 attributes = (wmPtr->attributes & ~macClassAttrs[macClass].forceOffAttrs) | macClassAttrs[macClass].forceOnAttrs; NSUInteger styleMask = macClassAttrs[macClass].styleMask | ((attributes & kWindowNoTitleBarAttribute) ? 0 : NSTitledWindowMask) | ((attributes & kWindowCloseBoxAttribute) ? NSClosableWindowMask : 0) | ((attributes & kWindowCollapseBoxAttribute) ? NSMiniaturizableWindowMask : 0) | ((attributes & kWindowResizableAttribute) ? NSResizableWindowMask : 0) | ((attributes & kWindowMetalAttribute) ? NSTexturedBackgroundWindowMask : 0) | ((attributes & kWindowUnifiedTitleAndToolbarAttribute) ? NSUnifiedTitleAndToolbarWindowMask : 0) | ((attributes & kWindowSideTitlebarAttribute) ? 1 << 9 : 0) | (attributes >> WM_NSMASK_SHIFT); Class winClass = (macClass == kDrawerWindowClass ? [NSDrawerWindow class] : (styleMask & (NSUtilityWindowMask|NSDocModalWindowMask| NSNonactivatingPanelMask|NSHUDWindowMask)) ? [NSPanel class] : [TKWindow class]); NSRect structureRect = [winClass frameRectForContentRect:NSZeroRect styleMask:styleMask]; NSRect contentRect = NSMakeRect(5 - structureRect.origin.x, tkMacOSXZeroScreenHeight - (tkMacOSXZeroScreenTop + 5 + structureRect.origin.y + structureRect.size.height + 200), 200, 200); NSWindow *window = [[winClass alloc] initWithContentRect:contentRect styleMask:styleMask backing:NSBackingStoreBuffered defer:YES]; if (!window) { Tcl_Panic("couldn't allocate new Mac window"); } TkMacOSXMakeUncollectable(window); TKContentView *contentView = [[TKContentView alloc] initWithFrame:NSZeroRect]; [window setContentView:contentView]; [contentView release]; [window setDelegate:NSApp]; [window setAcceptsMouseMovedEvents:YES]; [window setReleasedWhenClosed:NO]; [window setAutodisplay:NO]; if (styleMask & NSUtilityWindowMask) { [(NSPanel*)window setFloatingPanel:YES]; } if ((styleMask & (NSTexturedBackgroundWindowMask|NSHUDWindowMask)) && !(styleMask & NSDocModalWindowMask)) { /* * Workaround for [Bug 2824538]: Texured windows are draggable * from opaque content. */ [window setMovableByWindowBackground:NO]; } /* Set background color and opacity of window if those flags are set. */ if (colorName != NULL) { [window setBackgroundColor: colorName]; } if (opaqueTag != NULL) { [window setOpaque: opaqueTag]; } [window setDocumentEdited:NO]; wmPtr->window = window; macWin->view = contentView; TkMacOSXApplyWindowAttributes(winPtr, window); NSRect geometry = InitialWindowBounds(winPtr, window); geometry.size.width += structureRect.size.width; geometry.size.height += structureRect.size.height; geometry.origin.y = tkMacOSXZeroScreenHeight - (geometry.origin.y + geometry.size.height); [window setFrame:geometry display:NO]; TkMacOSXRegisterOffScreenWindow((Window) macWin, window); macWin->flags |= TK_HOST_EXISTS; } /* *---------------------------------------------------------------------- * * TkMacOSXRegisterOffScreenWindow -- * |
︙ | ︙ | |||
5381 5382 5383 5384 5385 5386 5387 | * *---------------------------------------------------------------------- */ void TkMacOSXRegisterOffScreenWindow( Window window, /* Window structure. */ | | | 5459 5460 5461 5462 5463 5464 5465 5466 5467 5468 5469 5470 5471 5472 5473 | * *---------------------------------------------------------------------- */ void TkMacOSXRegisterOffScreenWindow( Window window, /* Window structure. */ void *portPtr) /* Pointer to a Mac Window. */ { Tcl_HashEntry *valueHashPtr; int isNew; if (!windowHashInit) { Tcl_InitHashTable(&windowTable, TCL_ONE_WORD_KEYS); windowHashInit = true; |
︙ | ︙ | |||
5416 5417 5418 5419 5420 5421 5422 | * An entry is removed from the windowTable hash table. * *---------------------------------------------------------------------- */ void TkMacOSXUnregisterMacWindow( | | | | | 5494 5495 5496 5497 5498 5499 5500 5501 5502 5503 5504 5505 5506 5507 5508 5509 5510 5511 5512 5513 5514 5515 5516 5517 | * An entry is removed from the windowTable hash table. * *---------------------------------------------------------------------- */ void TkMacOSXUnregisterMacWindow( void *macWinPtr) /* Reference to a Mac Window */ { Tcl_HashEntry *entryPtr; if (!windowHashInit) { Tcl_Panic("TkMacOSXUnregisterMacWindow: unmapping before inited"); } entryPtr = Tcl_FindHashEntry(&windowTable, macWinPtr); if (!entryPtr) { TkMacOSXDbgMsg("Failed to find window %p", macWinPtr); } else { Tcl_DeleteHashEntry(entryPtr); } } /* *---------------------------------------------------------------------- |
︙ | ︙ | |||
5550 5551 5552 5553 5554 5555 5556 | void TkpWmSetState( TkWindow *winPtr, /* Toplevel window to operate on. */ int state) /* One of IconicState, ZoomState, NormalState, * or WithdrawnState. */ { WmInfo *wmPtr = winPtr->wmInfoPtr; | | > | | | > | | | < < < < < | | 5628 5629 5630 5631 5632 5633 5634 5635 5636 5637 5638 5639 5640 5641 5642 5643 5644 5645 5646 5647 5648 5649 5650 5651 5652 5653 5654 5655 5656 5657 5658 5659 5660 5661 5662 5663 5664 5665 5666 5667 5668 5669 5670 5671 | void TkpWmSetState( TkWindow *winPtr, /* Toplevel window to operate on. */ int state) /* One of IconicState, ZoomState, NormalState, * or WithdrawnState. */ { WmInfo *wmPtr = winPtr->wmInfoPtr; NSWindow *macWin; wmPtr->hints.initial_state = state; if (wmPtr->flags & WM_NEVER_MAPPED) { return; } macWin = TkMacOSXDrawableWindow(winPtr->window); if (state == WithdrawnState) { Tk_UnmapWindow((Tk_Window) winPtr); } else if (state == IconicState) { /* * The window always gets unmapped. If we can show the icon version of * the window we also collapse it. */ if (macWin && ([macWin styleMask] & NSMiniaturizableWindowMask) && ![macWin isMiniaturized]) { [macWin miniaturize:NSApp]; } Tk_UnmapWindow((Tk_Window) winPtr); } else if (state == NormalState || state == ZoomState) { Tk_MapWindow((Tk_Window) winPtr); if (macWin && ([macWin styleMask] & NSMiniaturizableWindowMask) && [macWin isMiniaturized]) { [macWin deminiaturize:NSApp]; } TkMacOSXZoomToplevel(macWin, state == NormalState ? inZoomIn : inZoomOut); } } /* *---------------------------------------------------------------------- * * TkpIsWindowFloating -- |
︙ | ︙ | |||
5604 5605 5606 5607 5608 5609 5610 | * None. * *---------------------------------------------------------------------- */ int TkpIsWindowFloating( | | < | < < < < < < | 5679 5680 5681 5682 5683 5684 5685 5686 5687 5688 5689 5690 5691 5692 5693 5694 5695 | * None. * *---------------------------------------------------------------------- */ int TkpIsWindowFloating( void *wRef) { return [(NSWindow *)wRef level] == kCGFloatingWindowLevel; } /* *---------------------------------------------------------------------- * * TkMacOSXWindowClass -- * |
︙ | ︙ | |||
5659 5660 5661 5662 5663 5664 5665 | * None. * *---------------------------------------------------------------------- */ void TkMacOSXWindowOffset( | | < < | < < | | | > > > > | 5727 5728 5729 5730 5731 5732 5733 5734 5735 5736 5737 5738 5739 5740 5741 5742 5743 5744 5745 5746 5747 5748 5749 5750 5751 5752 5753 | * None. * *---------------------------------------------------------------------- */ void TkMacOSXWindowOffset( void *wRef, int *xOffset, int *yOffset) { TkWindow *winPtr = TkMacOSXGetTkWindow(wRef); if (winPtr && winPtr->wmInfoPtr) { *xOffset = winPtr->wmInfoPtr->xInParent; *yOffset = winPtr->wmInfoPtr->yInParent; } else { *xOffset = 0; *yOffset = 0; } } /* *---------------------------------------------------------------------- * * TkpGetMS -- * |
︙ | ︙ | |||
5803 5804 5805 5806 5807 5808 5809 | WmStackorderToplevelWrapperMap( TkWindow *winPtr, /* TkWindow to recurse on */ Display *display, /* X display of parent window */ Tcl_HashTable *table) /* Maps mac window to TkWindow */ { TkWindow *childPtr; Tcl_HashEntry *hPtr; | < < < | | 5871 5872 5873 5874 5875 5876 5877 5878 5879 5880 5881 5882 5883 5884 5885 5886 5887 5888 5889 5890 | WmStackorderToplevelWrapperMap( TkWindow *winPtr, /* TkWindow to recurse on */ Display *display, /* X display of parent window */ Tcl_HashTable *table) /* Maps mac window to TkWindow */ { TkWindow *childPtr; Tcl_HashEntry *hPtr; int newEntry; if (Tk_IsMapped(winPtr) && Tk_IsTopLevel(winPtr) && (winPtr->display == display)) { hPtr = Tcl_CreateHashEntry(table, (char*) TkMacOSXDrawableWindow(winPtr->window), &newEntry); Tcl_SetHashValue(hPtr, winPtr); } for (childPtr = winPtr->childList; childPtr != NULL; childPtr = childPtr->nextPtr) { WmStackorderToplevelWrapperMap(childPtr, display, table); } |
︙ | ︙ | |||
5842 5843 5844 5845 5846 5847 5848 | *---------------------------------------------------------------------- */ TkWindow ** TkWmStackorderToplevel( TkWindow *parentPtr) /* Parent toplevel window. */ { | < > > < | | | > > > > | > | | | | | < > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > | | | | < | > | > | < | | < > | | > > > > > > > > | > > > > > > > | | > | > > > > | | | > > > > > > > > > > > > | > > > | > | | > > > | < > > | | | < < > > > > > > > > | > > > > > > | > > > | > | > > > > > > > > > > | | | | < | < | 5907 5908 5909 5910 5911 5912 5913 5914 5915 5916 5917 5918 5919 5920 5921 5922 5923 5924 5925 5926 5927 5928 5929 5930 5931 5932 5933 5934 5935 5936 5937 5938 5939 5940 5941 5942 5943 5944 5945 5946 5947 5948 5949 5950 5951 5952 5953 5954 5955 5956 5957 5958 5959 5960 5961 5962 5963 5964 5965 5966 5967 5968 5969 5970 5971 5972 5973 5974 5975 5976 5977 5978 5979 5980 5981 5982 5983 5984 5985 5986 5987 5988 5989 5990 5991 5992 5993 5994 5995 5996 5997 5998 5999 6000 6001 6002 6003 6004 6005 6006 6007 6008 6009 6010 6011 6012 6013 6014 6015 6016 6017 6018 6019 6020 6021 6022 6023 6024 6025 6026 6027 6028 6029 6030 6031 6032 6033 6034 6035 6036 6037 6038 6039 6040 6041 6042 6043 6044 6045 6046 6047 6048 6049 6050 6051 6052 6053 6054 6055 6056 6057 6058 6059 6060 6061 6062 6063 6064 6065 6066 6067 6068 6069 6070 6071 6072 6073 6074 6075 6076 6077 6078 6079 6080 6081 6082 6083 6084 6085 6086 6087 6088 6089 6090 6091 6092 6093 6094 6095 6096 6097 6098 6099 6100 6101 6102 6103 6104 6105 6106 6107 6108 6109 6110 6111 6112 6113 6114 6115 6116 6117 6118 6119 6120 6121 6122 6123 6124 6125 6126 6127 6128 6129 6130 6131 6132 6133 6134 6135 6136 6137 6138 6139 6140 6141 6142 6143 6144 6145 6146 6147 6148 6149 6150 6151 6152 6153 6154 6155 6156 6157 6158 6159 6160 6161 6162 6163 6164 | *---------------------------------------------------------------------- */ TkWindow ** TkWmStackorderToplevel( TkWindow *parentPtr) /* Parent toplevel window. */ { TkWindow *childWinPtr, **windows, **window_ptr; Tcl_HashTable table; Tcl_HashEntry *hPtr; Tcl_HashSearch search; NSInteger windowCount; NSInteger *windowNumbers; /* * Map mac windows to a TkWindow of the wrapped toplevel. */ Tcl_InitHashTable(&table, TCL_ONE_WORD_KEYS); WmStackorderToplevelWrapperMap(parentPtr, parentPtr->display, &table); windows = ckalloc((table.numEntries+1) * sizeof(TkWindow *)); /* * Special cases: If zero or one toplevels were mapped there is no need to * enumerate Windows. */ switch (table.numEntries) { case 0: windows[0] = NULL; goto done; case 1: hPtr = Tcl_FirstHashEntry(&table, &search); windows[0] = Tcl_GetHashValue(hPtr); windows[1] = NULL; goto done; } NSCountWindows(&windowCount); if (!windowCount) { ckfree((char *) windows); windows = NULL; } else { window_ptr = windows + table.numEntries; *window_ptr-- = NULL; windowNumbers = ckalloc(windowCount * sizeof(NSInteger)); NSWindowList(windowCount, windowNumbers); for (NSInteger index = 0; index < windowCount; index++) { NSWindow *w = [NSApp windowWithWindowNumber:windowNumbers[index]]; if (w) { hPtr = Tcl_FindHashEntry(&table, (char*) w); if (hPtr != NULL) { childWinPtr = Tcl_GetHashValue(hPtr); *window_ptr-- = childWinPtr; } } } if (window_ptr != (windows-1)) { Tcl_Panic("num matched toplevel windows does not equal num " "children"); } ckfree((char *) windowNumbers); } done: Tcl_DeleteHashTable(&table); return windows; } /* *---------------------------------------------------------------------- * * TkMacOSXApplyWindowAttributes -- * * This procedure applies all window attributes to the NSWindow. * * Results: * None. * * Side effects: * None. * *---------------------------------------------------------------------- */ void TkMacOSXApplyWindowAttributes( TkWindow *winPtr, NSWindow *macWindow) { WmInfo *wmPtr = winPtr->wmInfoPtr; ApplyWindowAttributeFlagChanges(winPtr, macWindow, 0, 0, 0, 1); if (wmPtr->master != None || winPtr->atts.override_redirect) { ApplyMasterOverrideChanges(winPtr, macWindow); } } /* *---------------------------------------------------------------------- * * ApplyWindowAttributeFlagChanges -- * * This procedure applies window attribute and flag changes. * * Results: * None. * * Side effects: * None. * *---------------------------------------------------------------------- */ static void ApplyWindowAttributeFlagChanges( TkWindow *winPtr, NSWindow *macWindow, UInt64 oldAttributes, int oldFlags, int create, int initial) { WmInfo *wmPtr = winPtr->wmInfoPtr; UInt64 newAttributes = ForceAttributes(wmPtr->attributes, wmPtr->macClass); UInt64 changedAttributes = newAttributes ^ ForceAttributes(oldAttributes, wmPtr->macClass); if (changedAttributes || wmPtr->flags != oldFlags || initial) { if (!macWindow) { if (winPtr->window == None) { if (create) { Tk_MakeWindowExist((Tk_Window) winPtr); } else { return; } } if (!TkMacOSXHostToplevelExists(winPtr)) { if (create) { TkMacOSXMakeRealWindowExist(winPtr); } else { return; } } macWindow = TkMacOSXDrawableWindow(winPtr->window); } if ((changedAttributes & kWindowCloseBoxAttribute) || initial) { [[macWindow standardWindowButton:NSWindowCloseButton] setEnabled:!!(newAttributes & kWindowCloseBoxAttribute)]; } if ((changedAttributes & kWindowCollapseBoxAttribute) || initial) { [[macWindow standardWindowButton:NSWindowMiniaturizeButton] setEnabled:!!(newAttributes & kWindowCollapseBoxAttribute)]; } if ((changedAttributes & (kWindowResizableAttribute | kWindowFullZoomAttribute)) || initial) { [macWindow setShowsResizeIndicator: !!(newAttributes & kWindowResizableAttribute)]; [[macWindow standardWindowButton:NSWindowZoomButton] setEnabled:(newAttributes & kWindowResizableAttribute) && (newAttributes & kWindowFullZoomAttribute)]; if (newAttributes & kWindowResizableAttribute) { wmPtr->flags &= ~(WM_WIDTH_NOT_RESIZABLE | WM_HEIGHT_NOT_RESIZABLE); } else { wmPtr->flags |= (WM_WIDTH_NOT_RESIZABLE | WM_HEIGHT_NOT_RESIZABLE); } WmUpdateGeom(wmPtr, winPtr); } if ((changedAttributes & kWindowToolbarButtonAttribute) || initial) { [macWindow setShowsToolbarButton: !!(newAttributes & kWindowToolbarButtonAttribute)]; if ((newAttributes & kWindowToolbarButtonAttribute) && ![macWindow toolbar]) { NSToolbar *toolbar = [[NSToolbar alloc] initWithIdentifier:@""]; [toolbar setVisible:NO]; [macWindow setToolbar:toolbar]; [toolbar release]; NSCell *toolbarButtonCell = [[macWindow standardWindowButton: NSWindowToolbarButton] cell]; [toolbarButtonCell setTarget:[macWindow contentView]]; [toolbarButtonCell setAction:@selector(tkToolbarButton:)]; } } if ((changedAttributes & kWindowNoShadowAttribute) || initial) { [macWindow setHasShadow: !(newAttributes & kWindowNoShadowAttribute)]; } if ((changedAttributes & kWindowHideOnSuspendAttribute) || initial) { [macWindow setHidesOnDeactivate: !!(newAttributes & kWindowHideOnSuspendAttribute)]; } if ((changedAttributes & kWindowInWindowMenuAttribute) || initial) { [macWindow setExcludedFromWindowsMenu: !(newAttributes & kWindowInWindowMenuAttribute)]; } if ((changedAttributes & kWindowIgnoreClicksAttribute) || initial) { [macWindow setIgnoresMouseEvents: !!(newAttributes & kWindowIgnoreClicksAttribute)]; } if ((changedAttributes & tkWindowDoesNotHideAttribute) || initial) { [macWindow setCanHide: !(newAttributes & tkWindowDoesNotHideAttribute)]; } if ((changedAttributes & (kWindowDoesNotCycleAttribute | tkCanJoinAllSpacesAttribute | tkMoveToActiveSpaceAttribute)) || initial) { NSWindowCollectionBehavior b = NSWindowCollectionBehaviorDefault; if (newAttributes & tkCanJoinAllSpacesAttribute) { b |= NSWindowCollectionBehaviorCanJoinAllSpaces; } else if (newAttributes & tkMoveToActiveSpaceAttribute) { b |= NSWindowCollectionBehaviorMoveToActiveSpace; } #if MAC_OS_X_VERSION_MAX_ALLOWED >= 1060 if (newAttributes & kWindowDoesNotCycleAttribute) { b |= NSWindowCollectionBehaviorIgnoresCycle; } else { b |= NSWindowCollectionBehaviorParticipatesInCycle; } #endif [macWindow setCollectionBehavior:b]; #if MAC_OS_X_VERSION_MIN_REQUIRED < 1060 if (((changedAttributes & kWindowDoesNotCycleAttribute) || initial) #if MAC_OS_X_VERSION_MAX_ALLOWED >= 1060 && tkMacOSXMacOSXVersion < 1060 #endif ) { [macWindow setCanCycle: !(newAttributes & kWindowDoesNotCycleAttribute)]; } #endif } if ((wmPtr->flags & WM_TOPMOST) != (oldFlags & WM_TOPMOST)) { [macWindow setLevel:(wmPtr->flags & WM_TOPMOST) ? kCGUtilityWindowLevel : ([macWindow isKindOfClass: [NSPanel class]] && [macWindow isFloatingPanel] ? kCGFloatingWindowLevel : kCGNormalWindowLevel)]; } /* * The change of window class/attributes might have changed the window * structure widths: */ NSRect structureRect = [macWindow frameRectForContentRect:NSZeroRect]; wmPtr->xInParent = -structureRect.origin.x; wmPtr->yInParent = structureRect.origin.y + structureRect.size.height; wmPtr->parentWidth = winPtr->changes.width + structureRect.size.width; wmPtr->parentHeight = winPtr->changes.height + structureRect.size.height; } } /* *---------------------------------------------------------------------- * * ApplyMasterOverrideChanges -- |
︙ | ︙ | |||
6010 6011 6012 6013 6014 6015 6016 | * *---------------------------------------------------------------------- */ static void ApplyMasterOverrideChanges( TkWindow *winPtr, | | < | > | | | | | < < < < < < < < < < < | < < < < < < < < < < < < < < < < < < < < < < < < < | | | | | | | | | | | < | | > | | > | < | | | > > | < | > < | 6173 6174 6175 6176 6177 6178 6179 6180 6181 6182 6183 6184 6185 6186 6187 6188 6189 6190 6191 6192 6193 6194 6195 6196 6197 6198 6199 6200 6201 6202 6203 6204 6205 6206 6207 6208 6209 6210 6211 6212 6213 6214 6215 6216 6217 6218 6219 6220 6221 6222 6223 6224 6225 6226 6227 6228 6229 6230 6231 6232 6233 6234 6235 6236 6237 6238 6239 6240 6241 6242 6243 6244 6245 6246 6247 6248 6249 6250 | * *---------------------------------------------------------------------- */ static void ApplyMasterOverrideChanges( TkWindow *winPtr, NSWindow *macWindow) { WmInfo *wmPtr = winPtr->wmInfoPtr; UInt64 oldAttributes = wmPtr->attributes; int oldFlags = wmPtr->flags; /* * FIX: We need an UpdateWrapper equivalent to make this 100% correct */ if (winPtr->atts.override_redirect) { if (wmPtr->macClass == kDocumentWindowClass) { wmPtr->macClass = kSimpleWindowClass; wmPtr->attributes = macClassAttrs[kSimpleWindowClass].defaultAttrs; } wmPtr->attributes |= kWindowNoActivatesAttribute; } else { if (wmPtr->macClass == kSimpleWindowClass && oldAttributes == kWindowNoActivatesAttribute) { wmPtr->macClass = kDocumentWindowClass; wmPtr->attributes = macClassAttrs[kDocumentWindowClass].defaultAttrs; } wmPtr->attributes &= ~kWindowNoActivatesAttribute; } if (!macWindow && winPtr->window != None && TkMacOSXHostToplevelExists(winPtr)) { macWindow = TkMacOSXDrawableWindow(winPtr->window); } if (macWindow) { if (winPtr->atts.override_redirect && wmPtr->master != None) { wmPtr->flags |= WM_TOPMOST; } else { wmPtr->flags &= ~WM_TOPMOST; } NSWindow *parentWindow = [macWindow parentWindow]; if (wmPtr->master != None) { TkDisplay *dispPtr = TkGetDisplayList(); TkWindow *masterWinPtr = (TkWindow *) Tk_IdToWindow(dispPtr->display, wmPtr->master); if (masterWinPtr && masterWinPtr->window != None && TkMacOSXHostToplevelExists(masterWinPtr)) { NSWindow *masterMacWin = TkMacOSXDrawableWindow(masterWinPtr->window); if (masterMacWin && masterMacWin != parentWindow && (winPtr->flags & TK_MAPPED)) { if (parentWindow) { [parentWindow removeChildWindow:macWindow]; } [masterMacWin addChildWindow:macWindow ordered:NSWindowAbove]; if (wmPtr->flags & WM_TOPMOST) { [macWindow setLevel:kCGUtilityWindowLevel]; } } } } else if (parentWindow) { [parentWindow removeChildWindow:macWindow]; } ApplyWindowAttributeFlagChanges(winPtr, macWindow, oldAttributes, oldFlags, 0, 0); } } /* *---------------------------------------------------------------------- * * TkMacOSXMakeFullscreen -- * |
︙ | ︙ | |||
6130 6131 6132 6133 6134 6135 6136 | * *---------------------------------------------------------------------- */ int TkMacOSXMakeFullscreen( TkWindow *winPtr, | | > > > | < < | | | | | | | < | | > > > > > > > > > | | | | > | | | < < < | < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < | 6258 6259 6260 6261 6262 6263 6264 6265 6266 6267 6268 6269 6270 6271 6272 6273 6274 6275 6276 6277 6278 6279 6280 6281 6282 6283 6284 6285 6286 6287 6288 6289 6290 6291 6292 6293 6294 6295 6296 6297 6298 6299 6300 6301 6302 6303 6304 6305 6306 6307 6308 6309 6310 6311 6312 6313 6314 6315 6316 6317 6318 6319 6320 6321 6322 6323 6324 6325 6326 6327 6328 6329 6330 6331 6332 6333 6334 6335 6336 6337 6338 6339 6340 6341 6342 6343 6344 6345 6346 6347 | * *---------------------------------------------------------------------- */ int TkMacOSXMakeFullscreen( TkWindow *winPtr, NSWindow *window, int fullscreen, Tcl_Interp *interp) { WmInfo *wmPtr = winPtr->wmInfoPtr; int result = TCL_OK, wasFullscreen = (wmPtr->flags & WM_FULLSCREEN); static unsigned long prevMask = 0, prevPres = 0; if (fullscreen) { int screenWidth = WidthOfScreen(Tk_Screen(winPtr)); int screenHeight = HeightOfScreen(Tk_Screen(winPtr)); /* * Check max width and height if set by the user. */ if ((wmPtr->maxWidth > 0 && wmPtr->maxWidth < screenWidth) || (wmPtr->maxHeight > 0 && wmPtr->maxHeight < screenHeight)) { if (interp) { Tcl_AppendResult(interp, "can't set fullscreen attribute for \"", winPtr->pathName, "\": max width/height is too small", NULL); } result = TCL_ERROR; wmPtr->flags &= ~WM_FULLSCREEN; } else { NSRect bounds = [window contentRectForFrameRect:[window frame]]; NSRect screenBounds = NSMakeRect(0, 0, screenWidth, screenHeight); if (!NSEqualRects(bounds, screenBounds) && !wasFullscreen) { wmPtr->configX = wmPtr->x; wmPtr->configY = wmPtr->y; wmPtr->configAttributes = wmPtr->attributes; wmPtr->attributes &= ~kWindowResizableAttribute; ApplyWindowAttributeFlagChanges(winPtr, window, wmPtr->configAttributes, wmPtr->flags, 1, 0); wmPtr->flags |= WM_SYNC_PENDING; [window setFrame:[window frameRectForContentRect: screenBounds] display:YES]; wmPtr->flags &= ~WM_SYNC_PENDING; } wmPtr->flags |= WM_FULLSCREEN; } prevMask = [window styleMask]; prevPres = [NSApp presentationOptions]; [window setStyleMask: NSBorderlessWindowMask]; [NSApp setPresentationOptions: NSApplicationPresentationAutoHideDock | NSApplicationPresentationAutoHideMenuBar]; } else { wmPtr->flags &= ~WM_FULLSCREEN; [NSApp setPresentationOptions: prevPres]; [window setStyleMask: prevMask]; } if (wasFullscreen && !(wmPtr->flags & WM_FULLSCREEN)) { UInt64 oldAttributes = wmPtr->attributes; NSRect bounds = NSMakeRect(wmPtr->configX, tkMacOSXZeroScreenHeight - (wmPtr->configY + wmPtr->yInParent + wmPtr->configHeight), wmPtr->xInParent + wmPtr->configWidth, wmPtr->yInParent + wmPtr->configHeight); wmPtr->attributes |= wmPtr->configAttributes & kWindowResizableAttribute; ApplyWindowAttributeFlagChanges(winPtr, window, oldAttributes, wmPtr->flags, 1, 0); wmPtr->flags |= WM_SYNC_PENDING; [window setFrame:[window frameRectForContentRect:bounds] display:YES]; wmPtr->flags &= ~WM_SYNC_PENDING; } return result; } /* *---------------------------------------------------------------------- * * GetMinSize -- * * This function computes the current minWidth and minHeight values for a |
︙ | ︙ | |||
6371 6372 6373 6374 6375 6376 6377 | TkWindow *winPtr, /* Toplevel window to operate on. */ int *maxWidthPtr, /* Where to store the current maximum width of * the window. */ int *maxHeightPtr) /* Where to store the current maximum height * of the window. */ { WmInfo *wmPtr = winPtr->wmInfoPtr; | | | | | 6462 6463 6464 6465 6466 6467 6468 6469 6470 6471 6472 6473 6474 6475 6476 6477 6478 6479 6480 6481 6482 6483 6484 6485 6486 6487 6488 6489 6490 6491 6492 | TkWindow *winPtr, /* Toplevel window to operate on. */ int *maxWidthPtr, /* Where to store the current maximum width of * the window. */ int *maxHeightPtr) /* Where to store the current maximum height * of the window. */ { WmInfo *wmPtr = winPtr->wmInfoPtr; NSRect *maxBounds = (NSRect*)(winPtr->display->screens->ext_data); if (wmPtr->maxWidth > 0) { *maxWidthPtr = wmPtr->maxWidth; } else { int maxWidth = maxBounds->size.width - wmPtr->xInParent; if (wmPtr->gridWin != NULL) { maxWidth = wmPtr->reqGridWidth + (maxWidth - winPtr->reqWidth)/wmPtr->widthInc; } *maxWidthPtr = maxWidth; } if (wmPtr->maxHeight > 0) { *maxHeightPtr = wmPtr->maxHeight; } else { int maxHeight = maxBounds->size.height - wmPtr->yInParent; if (wmPtr->gridWin != NULL) { maxHeight = wmPtr->reqGridHeight + (maxHeight - winPtr->reqHeight)/wmPtr->heightInc; } *maxHeightPtr = maxHeight; } |
︙ | ︙ | |||
6428 6429 6430 6431 6432 6433 6434 | * Remove the OS specific window. It will get rebuilt when the window gets * Mapped. */ if (winPtr->window != None) { MacDrawable *macWin = (MacDrawable *) winPtr->window; | < | > > > > > > > > > > > | 6519 6520 6521 6522 6523 6524 6525 6526 6527 6528 6529 6530 6531 6532 6533 6534 6535 6536 6537 6538 6539 6540 6541 6542 6543 6544 6545 6546 6547 6548 6549 | * Remove the OS specific window. It will get rebuilt when the window gets * Mapped. */ if (winPtr->window != None) { MacDrawable *macWin = (MacDrawable *) winPtr->window; macWin->toplevel = parentWin->toplevel; winPtr->flags &= ~TK_MAPPED; #ifdef TK_REBUILD_TOPLEVEL winPtr->flags |= TK_REBUILD_TOPLEVEL; #endif } /* Repeat for all the children */ for (childPtr = winPtr->childList; childPtr != NULL; childPtr = childPtr->nextPtr) { RemapWindows(childPtr, (MacDrawable *) winPtr->window); } } /* * Local Variables: * mode: objc * c-basic-offset: 4 * fill-column: 79 * coding: utf-8 * End: */ |
Changes to macosx/tkMacOSXWm.h.
1 2 3 4 5 | /* * tkMacOSXWm.h -- * * Declarations of Macintosh specific window manager structures. * | | | | | < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < > | 1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 | /* * tkMacOSXWm.h -- * * Declarations of Macintosh specific window manager structures. * * Copyright 2001-2009, Apple Inc. * Copyright (c) 2006-2009 Daniel A. Steffen <[email protected]> * * See the file "license.terms" for information on usage and redistribution * of this file, and for a DISCLAIMER OF ALL WARRANTIES. */ #ifndef _TKMACWM #define _TKMACWM #include "tkMacOSXInt.h" #include "tkMenu.h" /* * A data structure of the following type holds information for * each window manager protocol (such as WM_DELETE_WINDOW) for * which a handler (i.e. a Tcl command) has been defined for a * particular top-level window. */ |
︙ | ︙ | |||
228 229 230 231 232 233 234 | * property, or NULL. */ int flags; /* Miscellaneous flags, defined below. */ /* * Macintosh information. */ WindowClass macClass; | | > | | 185 186 187 188 189 190 191 192 193 194 195 196 197 198 199 200 201 202 | * property, or NULL. */ int flags; /* Miscellaneous flags, defined below. */ /* * Macintosh information. */ WindowClass macClass; UInt64 attributes, configAttributes; TkWindow *scrollWinPtr; /* Ptr to scrollbar handling grow widget. */ TkMenu *menuPtr; NSWindow *window; } WmInfo; /* * Flag values for WmInfo structures: * * WM_NEVER_MAPPED - non-zero means window has never been |
︙ | ︙ |
Added macosx/tkMacOSXXCursors.h.
> > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > | 1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 34 35 36 37 38 39 40 41 42 43 44 45 46 47 48 49 50 51 52 53 54 55 56 57 58 59 60 61 62 63 64 65 66 67 68 69 70 71 72 73 74 75 76 77 78 79 80 81 82 83 84 85 86 87 88 89 90 91 92 93 94 95 96 97 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 129 130 131 132 133 134 135 136 137 138 139 140 141 142 143 144 145 146 147 148 149 150 151 152 153 154 155 156 157 158 159 160 161 162 163 164 165 166 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 224 225 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 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 284 285 286 287 288 289 290 291 292 293 294 295 296 297 298 299 300 301 302 303 304 305 306 307 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 338 339 340 341 342 343 344 345 346 347 348 349 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 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 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 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 703 704 705 706 707 708 709 710 711 | /* * tkMacOSXXCursors.h -- * * This file defines a set of Macintosh cursors that * emulate the X cursor set. All of these cursors were * constructed and donated by Grant Neufeld. ([email protected]) * * Copyright (c) 1995-1996 Sun Microsystems, Inc. * Copyright 2008-2009, Apple Inc. * Copyright (c) 2008-2009 Daniel A. Steffen <[email protected]> * * See the file "license.terms" for information on usage and redistribution * of this file, and for a DISCLAIMER OF ALL WARRANTIES. */ static const unsigned char tkMacOSXXCursors[][68] = { #define TK_MAC_XCURSOR_X_cursor 0 [TK_MAC_XCURSOR_X_cursor] = { 0xE0, 0x07, 0xF0, 0x0F, 0xF8, 0x1F, 0x7C, 0x3E, 0x3E, 0x7C, 0x1F, 0xF8, 0x0F, 0xF0, 0x07, 0xE0, 0x07, 0xE0, 0x0F, 0xF0, 0x1F, 0xF8, 0x3E, 0x7C, 0x7C, 0x3E, 0xF8, 0x1F, 0xF0, 0x0F, 0xE0, 0x07, 0xE0, 0x07, 0xF0, 0x0F, 0xF8, 0x1F, 0x7C, 0x3E, 0x3E, 0x7C, 0x1F, 0xF8, 0x0F, 0xF0, 0x07, 0xE0, 0x07, 0xE0, 0x0F, 0xF0, 0x1F, 0xF8, 0x3E, 0x7C, 0x7C, 0x3E, 0xF8, 0x1F, 0xF0, 0x0F, 0xE0, 0x07, 0x00, 0x07, 0x00, 0x07, }, #define TK_MAC_XCURSOR_arrow 1 [TK_MAC_XCURSOR_arrow] = { 0x00, 0x00, 0x00, 0x06, 0x00, 0x1E, 0x00, 0x7C, 0x01, 0xFC, 0x07, 0xF8, 0x00, 0xF8, 0x01, 0xF0, 0x03, 0xB0, 0x07, 0x20, 0x0E, 0x20, 0x1C, 0x00, 0x38, 0x00, 0x70, 0x00, 0x20, 0x00, 0x00, 0x00, 0x00, 0x07, 0x00, 0x1F, 0x00, 0x7F, 0x01, 0xFE, 0x07, 0xFE, 0x1F, 0xFC, 0x7F, 0xFC, 0x03, 0xF8, 0x07, 0xF8, 0x0F, 0xF0, 0x1F, 0x70, 0x3E, 0x60, 0x7C, 0x60, 0xF8, 0x40, 0x70, 0x40, 0x20, 0x00, 0x00, 0x01, 0x00, 0x0E, }, #define TK_MAC_XCURSOR_based_arrow_down 2 [TK_MAC_XCURSOR_based_arrow_down] = { 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x1F, 0xE0, 0x00, 0x00, 0x1F, 0xE0, 0x03, 0x00, 0x03, 0x00, 0x03, 0x00, 0x0B, 0x40, 0x07, 0x80, 0x03, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x1F, 0xE0, 0x00, 0x00, 0x1F, 0xE0, 0x07, 0x80, 0x07, 0x80, 0x3F, 0xF0, 0x1F, 0xE0, 0x0F, 0xC0, 0x07, 0x80, 0x03, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x0B, 0x00, 0x06, }, #define TK_MAC_XCURSOR_based_arrow_up 3 [TK_MAC_XCURSOR_based_arrow_up] = { 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x03, 0x00, 0x07, 0x80, 0x0B, 0x40, 0x03, 0x00, 0x03, 0x00, 0x03, 0x00, 0x1F, 0xE0, 0x00, 0x00, 0x1F, 0xE0, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x03, 0x00, 0x07, 0x80, 0x0F, 0xC0, 0x1F, 0xE0, 0x3F, 0xF0, 0x07, 0x80, 0x07, 0x80, 0x1F, 0xE0, 0x00, 0x00, 0x1F, 0xE0, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x04, 0x00, 0x06, }, #define TK_MAC_XCURSOR_boat 4 [TK_MAC_XCURSOR_boat] = { 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x01, 0x00, 0x03, 0xC0, 0x84, 0x60, 0xFF, 0xFF, 0x00, 0x18, 0x00, 0x20, 0x00, 0x40, 0xFF, 0xC0, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x01, 0x00, 0x03, 0xC0, 0x87, 0xE0, 0xFF, 0xFF, 0xFF, 0xF8, 0xFF, 0xE0, 0xFF, 0xC0, 0xFF, 0xC0, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x07, 0x00, 0x0F, }, #define TK_MAC_XCURSOR_bogosity 5 [TK_MAC_XCURSOR_bogosity] = { 0x00, 0x00, 0x71, 0x1C, 0x11, 0x10, 0x11, 0x10, 0x11, 0x10, 0x7F, 0xFC, 0x51, 0x14, 0x51, 0x14, 0x51, 0x14, 0x51, 0x14, 0x7F, 0xFC, 0x11, 0x10, 0x11, 0x10, 0x11, 0x10, 0x71, 0x1C, 0x00, 0x00, 0x00, 0x00, 0x71, 0x1C, 0x11, 0x10, 0x11, 0x10, 0x11, 0x10, 0x7F, 0xFC, 0x7F, 0xFC, 0x7F, 0xFC, 0x7F, 0xFC, 0x7F, 0xFC, 0x7F, 0xFC, 0x11, 0x10, 0x11, 0x10, 0x11, 0x10, 0x71, 0x1C, 0x00, 0x00, 0x00, 0x01, 0x00, 0x07, }, #define TK_MAC_XCURSOR_bottom_left_corner 6 [TK_MAC_XCURSOR_bottom_left_corner] = { 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0xC0, 0x00, 0xC0, 0x20, 0xC8, 0x40, 0xC8, 0x80, 0xC9, 0x00, 0xCA, 0x00, 0xCC, 0x00, 0xCF, 0xC0, 0xC0, 0x00, 0xC0, 0x00, 0xFF, 0xF0, 0xFF, 0xF0, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0xC0, 0x00, 0xC0, 0x20, 0xC8, 0x40, 0xC8, 0x80, 0xC9, 0x00, 0xCA, 0x00, 0xCC, 0x00, 0xCF, 0xC0, 0xC0, 0x00, 0xC0, 0x00, 0xFF, 0xF0, 0xFF, 0xF0, 0x00, 0x0F, 0x00, 0x00, }, #define TK_MAC_XCURSOR_bottom_right_corner 7 [TK_MAC_XCURSOR_bottom_right_corner] = { 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x03, 0x04, 0x03, 0x02, 0x13, 0x01, 0x13, 0x00, 0x93, 0x00, 0x53, 0x00, 0x33, 0x03, 0xF3, 0x00, 0x03, 0x00, 0x03, 0x0F, 0xFF, 0x0F, 0xFF, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x03, 0x04, 0x03, 0x02, 0x13, 0x01, 0x13, 0x00, 0x93, 0x00, 0x53, 0x00, 0x33, 0x03, 0xF3, 0x00, 0x03, 0x00, 0x03, 0x0F, 0xFF, 0x0F, 0xFF, 0x00, 0x0F, 0x00, 0x0F, }, #define TK_MAC_XCURSOR_bottom_side 8 [TK_MAC_XCURSOR_bottom_side] = { 0x00, 0x00, 0x00, 0x00, 0x01, 0x00, 0x01, 0x00, 0x01, 0x00, 0x01, 0x00, 0x01, 0x00, 0x11, 0x10, 0x09, 0x20, 0x05, 0x40, 0x03, 0x80, 0x01, 0x00, 0x00, 0x00, 0x7F, 0xFC, 0x7F, 0xFC, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x01, 0x00, 0x01, 0x00, 0x01, 0x00, 0x01, 0x00, 0x01, 0x00, 0x11, 0x10, 0x09, 0x20, 0x05, 0x40, 0x03, 0x80, 0x01, 0x00, 0x00, 0x00, 0x7F, 0xFC, 0x7F, 0xFC, 0x00, 0x00, 0x00, 0x0B, 0x00, 0x07, }, #define TK_MAC_XCURSOR_bottom_tee 9 [TK_MAC_XCURSOR_bottom_tee] = { 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x01, 0x80, 0x01, 0x80, 0x01, 0x80, 0x01, 0x80, 0x01, 0x80, 0x01, 0x80, 0x01, 0x80, 0x7F, 0xFE, 0x7F, 0xFE, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x01, 0x80, 0x01, 0x80, 0x01, 0x80, 0x01, 0x80, 0x01, 0x80, 0x01, 0x80, 0x01, 0x80, 0x7F, 0xFE, 0x7F, 0xFE, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x0B, 0x00, 0x07, }, #define TK_MAC_XCURSOR_box_spiral 10 [TK_MAC_XCURSOR_box_spiral] = { 0xFF, 0xFE, 0x80, 0x00, 0xBF, 0xFE, 0xA0, 0x02, 0xAF, 0xFA, 0xA8, 0x0A, 0xAB, 0xEA, 0xAA, 0x2A, 0xAA, 0xAA, 0xAB, 0xAA, 0xA8, 0x2A, 0xAF, 0xEA, 0xA0, 0x0A, 0xBF, 0xFA, 0x80, 0x02, 0xFF, 0xFE, 0xFF, 0xFE, 0x80, 0x00, 0xBF, 0xFE, 0xA0, 0x02, 0xAF, 0xFA, 0xA8, 0x0A, 0xAB, 0xEA, 0xAA, 0x2A, 0xAA, 0xAA, 0xAB, 0xAA, 0xA8, 0x2A, 0xAF, 0xEA, 0xA0, 0x0A, 0xBF, 0xFA, 0x80, 0x02, 0xFF, 0xFE, 0x00, 0x08, 0x00, 0x08, }, #define TK_MAC_XCURSOR_center_ptr 11 [TK_MAC_XCURSOR_center_ptr] = { 0x00, 0x00, 0x03, 0x00, 0x03, 0x00, 0x07, 0x80, 0x07, 0x80, 0x0F, 0xC0, 0x0F, 0xC0, 0x1F, 0xE0, 0x1F, 0xE0, 0x33, 0x30, 0x23, 0x10, 0x03, 0x00, 0x03, 0x00, 0x03, 0x00, 0x03, 0x00, 0x00, 0x00, 0x03, 0x00, 0x07, 0x80, 0x07, 0x80, 0x0F, 0xC0, 0x0F, 0xC0, 0x1F, 0xE0, 0x1F, 0xE0, 0x3F, 0xF0, 0x3F, 0xF0, 0x7F, 0xF8, 0x77, 0xB8, 0x67, 0x98, 0x07, 0x80, 0x07, 0x80, 0x07, 0x80, 0x07, 0x80, 0x00, 0x01, 0x00, 0x06, }, #define TK_MAC_XCURSOR_circle 12 [TK_MAC_XCURSOR_circle] = { 0x00, 0x00, 0x03, 0xC0, 0x0F, 0xF0, 0x1F, 0xF8, 0x3C, 0x3C, 0x38, 0x1C, 0x70, 0x0E, 0x70, 0x0E, 0x70, 0x0E, 0x70, 0x0E, 0x38, 0x1C, 0x3C, 0x3C, 0x1F, 0xF8, 0x0F, 0xF0, 0x03, 0xC0, 0x00, 0x00, 0x03, 0xC0, 0x0F, 0xF0, 0x1F, 0xF8, 0x3F, 0xFC, 0x7F, 0xFE, 0x7C, 0x3E, 0xF8, 0x1F, 0xF8, 0x1F, 0xF8, 0x1F, 0xF8, 0x1F, 0x7C, 0x3E, 0x7F, 0xFE, 0x3F, 0xFC, 0x1F, 0xF8, 0x0F, 0xF0, 0x03, 0xC0, 0x00, 0x07, 0x00, 0x07, }, #define TK_MAC_XCURSOR_clock 13 [TK_MAC_XCURSOR_clock] = { 0x1F, 0xF8, 0x33, 0xCC, 0x64, 0x66, 0x49, 0x92, 0x4F, 0x12, 0x44, 0x22, 0x63, 0xC6, 0x3F, 0xFC, 0x29, 0x94, 0x29, 0x94, 0x29, 0x94, 0x2B, 0xD4, 0x69, 0x96, 0x78, 0x1E, 0x7F, 0xFE, 0x7F, 0xFE, 0x1F, 0xF8, 0x3F, 0xFC, 0x7F, 0xFE, 0x7F, 0xFE, 0x7F, 0xFE, 0x7F, 0xFE, 0x7F, 0xFE, 0x3F, 0xFC, 0x3F, 0xFC, 0x3F, 0xFC, 0x3F, 0xFC, 0x3F, 0xFC, 0x7F, 0xFE, 0x7F, 0xFE, 0x7F, 0xFE, 0x7F, 0xFE, 0x00, 0x04, 0x00, 0x08, }, #define TK_MAC_XCURSOR_coffee_mug 14 [TK_MAC_XCURSOR_coffee_mug] = { 0x03, 0xF8, 0x0C, 0x06, 0x10, 0x01, 0x1C, 0x07, 0x33, 0xF9, 0x70, 0x01, 0xD0, 0x01, 0x90, 0x01, 0x96, 0x0D, 0xDA, 0x55, 0x7A, 0x55, 0x36, 0xED, 0x10, 0xA1, 0x10, 0x01, 0x08, 0x02, 0x07, 0xFC, 0x03, 0xF8, 0x0F, 0xFE, 0x1F, 0xFF, 0x1F, 0xFF, 0x3F, 0xFF, 0x7F, 0xFF, 0xFF, 0xFF, 0xFF, 0xFF, 0xFF, 0xFF, 0xFF, 0xFF, 0x7F, 0xFF, 0x3F, 0xFF, 0x1F, 0xFF, 0x1F, 0xFF, 0x0F, 0xFE, 0x07, 0xFC, 0x00, 0x04, 0x00, 0x03, }, #define TK_MAC_XCURSOR_cross 15 [TK_MAC_XCURSOR_cross] = { 0x02, 0x80, 0x02, 0x80, 0x02, 0x80, 0x02, 0x80, 0x02, 0x80, 0x02, 0x80, 0xFE, 0xFE, 0x00, 0x00, 0xFE, 0xFE, 0x02, 0x80, 0x02, 0x80, 0x02, 0x80, 0x02, 0x80, 0x02, 0x80, 0x02, 0x80, 0x00, 0x00, 0x03, 0x80, 0x03, 0x80, 0x03, 0x80, 0x03, 0x80, 0x03, 0x80, 0x03, 0x80, 0xFF, 0xFE, 0xFF, 0xFE, 0xFF, 0xFE, 0x03, 0x80, 0x03, 0x80, 0x03, 0x80, 0x03, 0x80, 0x03, 0x80, 0x03, 0x80, 0x00, 0x00, 0x00, 0x07, 0x00, 0x07, }, #define TK_MAC_XCURSOR_cross_reverse 16 [TK_MAC_XCURSOR_cross_reverse] = { 0x42, 0x84, 0xA2, 0x8A, 0x52, 0x94, 0x2A, 0xA8, 0x16, 0xD0, 0x0A, 0xA0, 0xFD, 0x7E, 0x02, 0x80, 0xFD, 0x7E, 0x0A, 0xA0, 0x16, 0xD0, 0x2A, 0xA8, 0x52, 0x94, 0xA2, 0x8A, 0x42, 0x84, 0x00, 0x00, 0x43, 0x84, 0xE3, 0x8E, 0x73, 0x9C, 0x3B, 0xB8, 0x1F, 0xF0, 0x0F, 0xE0, 0xFF, 0xFE, 0xFF, 0xFE, 0xFF, 0xFE, 0x0F, 0xE0, 0x1F, 0xF0, 0x3B, 0xB8, 0x73, 0x9C, 0xE3, 0x8E, 0x43, 0x84, 0x00, 0x00, 0x00, 0x07, 0x00, 0x07, }, #define TK_MAC_XCURSOR_crosshair 17 [TK_MAC_XCURSOR_crosshair] = { 0x01, 0x00, 0x01, 0x00, 0x01, 0x00, 0x01, 0x00, 0x01, 0x00, 0x01, 0x00, 0x01, 0x00, 0xFE, 0xFE, 0x01, 0x00, 0x01, 0x00, 0x01, 0x00, 0x01, 0x00, 0x01, 0x00, 0x01, 0x00, 0x01, 0x00, 0x00, 0x00, 0x01, 0x00, 0x01, 0x00, 0x01, 0x00, 0x01, 0x00, 0x01, 0x00, 0x01, 0x00, 0x01, 0x00, 0xFE, 0xFE, 0x01, 0x00, 0x01, 0x00, 0x01, 0x00, 0x01, 0x00, 0x01, 0x00, 0x01, 0x00, 0x01, 0x00, 0x00, 0x00, 0x00, 0x07, 0x00, 0x07, }, #define TK_MAC_XCURSOR_diamond_cross 18 [TK_MAC_XCURSOR_diamond_cross] = { 0x02, 0x80, 0x06, 0xC0, 0x0A, 0xA0, 0x12, 0x90, 0x22, 0x88, 0x42, 0x84, 0xFE, 0xFE, 0x00, 0x00, 0xFE, 0xFE, 0x42, 0x84, 0x22, 0x88, 0x12, 0x90, 0x0A, 0xA0, 0x06, 0xC0, 0x02, 0x80, 0x00, 0x00, 0x02, 0x80, 0x06, 0xC0, 0x0E, 0xE0, 0x1E, 0xF0, 0x3E, 0xF8, 0x7E, 0xFC, 0xFE, 0xFE, 0x00, 0x00, 0xFE, 0xFE, 0x7E, 0xFC, 0x3E, 0xF8, 0x1E, 0xF0, 0x0E, 0xE0, 0x06, 0xC0, 0x02, 0x80, 0x00, 0x00, 0x00, 0x07, 0x00, 0x07, }, #define TK_MAC_XCURSOR_dot 19 [TK_MAC_XCURSOR_dot] = { 0x00, 0x00, 0x00, 0x00, 0x07, 0x80, 0x1F, 0xE0, 0x1F, 0xE0, 0x3F, 0xF0, 0x3F, 0xF0, 0x3F, 0xF0, 0x3F, 0xF0, 0x1F, 0xE0, 0x1F, 0xE0, 0x07, 0x80, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x07, 0x80, 0x1F, 0xE0, 0x3F, 0xF0, 0x3F, 0xF0, 0x7F, 0xF8, 0x7F, 0xF8, 0x7F, 0xF8, 0x7F, 0xF8, 0x3F, 0xF0, 0x3F, 0xF0, 0x1F, 0xE0, 0x07, 0x80, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x06, 0x00, 0x06, }, #define TK_MAC_XCURSOR_dotbox 20 [TK_MAC_XCURSOR_dotbox] = { 0x00, 0x00, 0x00, 0x00, 0x3F, 0xFC, 0x20, 0x04, 0x20, 0x04, 0x20, 0x04, 0x20, 0x04, 0x21, 0x84, 0x21, 0x84, 0x20, 0x04, 0x20, 0x04, 0x20, 0x04, 0x20, 0x04, 0x3F, 0xFC, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x3F, 0xFC, 0x3F, 0xFC, 0x30, 0x0C, 0x30, 0x0C, 0x31, 0x8C, 0x33, 0xCC, 0x33, 0xCC, 0x31, 0x8C, 0x30, 0x0C, 0x30, 0x0C, 0x3F, 0xFC, 0x3F, 0xFC, 0x00, 0x00, 0x00, 0x00, 0x00, 0x07, 0x00, 0x07, }, #define TK_MAC_XCURSOR_double_arrow 21 [TK_MAC_XCURSOR_double_arrow] = { 0x00, 0x00, 0x01, 0x80, 0x03, 0xC0, 0x07, 0xE0, 0x0D, 0xB0, 0x19, 0x98, 0x01, 0x80, 0x01, 0x80, 0x01, 0x80, 0x01, 0x80, 0x19, 0x98, 0x0D, 0xB0, 0x07, 0xE0, 0x03, 0xC0, 0x01, 0x80, 0x00, 0x00, 0x01, 0x80, 0x03, 0xC0, 0x07, 0xE0, 0x0F, 0xF0, 0x1F, 0xF8, 0x3F, 0xFC, 0x3B, 0xDC, 0x03, 0xC0, 0x03, 0xC0, 0x3B, 0xDC, 0x3F, 0xFC, 0x1F, 0xF8, 0x0F, 0xF0, 0x07, 0xE0, 0x03, 0xC0, 0x01, 0x80, 0x00, 0x07, 0x00, 0x07, }, #define TK_MAC_XCURSOR_draft_large 22 [TK_MAC_XCURSOR_draft_large] = { 0x00, 0x00, 0x00, 0x02, 0x00, 0x0C, 0x00, 0x3C, 0x00, 0xF8, 0x03, 0xF8, 0x0F, 0xF0, 0x00, 0xF0, 0x01, 0x60, 0x02, 0x60, 0x04, 0x40, 0x08, 0x40, 0x10, 0x00, 0x20, 0x00, 0x40, 0x00, 0x00, 0x00, 0x00, 0x03, 0x00, 0x0F, 0x00, 0x3E, 0x00, 0xFE, 0x03, 0xFC, 0x0F, 0xFC, 0x3F, 0xF8, 0xFF, 0xF8, 0x03, 0xF0, 0x07, 0xF0, 0x0E, 0xE0, 0x1C, 0xE0, 0x38, 0xC0, 0x70, 0xC0, 0xE0, 0x80, 0x40, 0x80, 0x00, 0x01, 0x00, 0x0E, }, #define TK_MAC_XCURSOR_draft_small 23 [TK_MAC_XCURSOR_draft_small] = { 0x00, 0x00, 0x00, 0x02, 0x00, 0x0C, 0x00, 0x3C, 0x00, 0xF8, 0x03, 0xF8, 0x00, 0x70, 0x00, 0xB0, 0x01, 0x20, 0x02, 0x20, 0x04, 0x00, 0x08, 0x00, 0x10, 0x00, 0x20, 0x00, 0x40, 0x00, 0x00, 0x00, 0x00, 0x03, 0x00, 0x0F, 0x00, 0x3E, 0x00, 0xFE, 0x03, 0xFC, 0x0F, 0xFC, 0x3F, 0xF8, 0x01, 0xF8, 0x03, 0xF0, 0x07, 0x70, 0x0E, 0x60, 0x1C, 0x60, 0x38, 0x40, 0x70, 0x40, 0xE0, 0x00, 0x40, 0x00, 0x00, 0x01, 0x00, 0x0E, }, #define TK_MAC_XCURSOR_draped_box 24 [TK_MAC_XCURSOR_draped_box] = { 0x00, 0x00, 0x00, 0x00, 0x3F, 0xFC, 0x22, 0x44, 0x26, 0x64, 0x2C, 0x34, 0x38, 0x1C, 0x21, 0x84, 0x21, 0x84, 0x38, 0x1C, 0x2C, 0x34, 0x26, 0x64, 0x22, 0x44, 0x3F, 0xFC, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x3F, 0xFC, 0x3E, 0x7C, 0x3E, 0x7C, 0x3C, 0x3C, 0x39, 0x9C, 0x23, 0xC4, 0x23, 0xC4, 0x39, 0x9C, 0x3C, 0x3C, 0x3E, 0x7C, 0x3E, 0x7C, 0x3F, 0xFC, 0x00, 0x00, 0x00, 0x00, 0x00, 0x07, 0x00, 0x07, }, #define TK_MAC_XCURSOR_exchange 25 [TK_MAC_XCURSOR_exchange] = { 0x00, 0x00, 0x47, 0xC0, 0x6F, 0xE0, 0x7C, 0x30, 0x48, 0x10, 0x4C, 0x00, 0x7E, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0xFC, 0x00, 0x64, 0x10, 0x24, 0x18, 0x7C, 0x0F, 0xEC, 0x07, 0xC4, 0x00, 0x00, 0xC7, 0xC0, 0xEF, 0xE0, 0xFF, 0xF0, 0xFF, 0xF8, 0xFC, 0x38, 0xFE, 0x10, 0xFF, 0x00, 0xFF, 0x80, 0x03, 0xFE, 0x01, 0xFE, 0x10, 0xFE, 0x38, 0x7E, 0x3F, 0xFE, 0x1F, 0xFE, 0x0F, 0xEE, 0x07, 0xC6, 0x00, 0x07, 0x00, 0x07, }, #define TK_MAC_XCURSOR_fleur 26 [TK_MAC_XCURSOR_fleur] = { 0x00, 0x00, 0x01, 0x80, 0x03, 0xC0, 0x07, 0xE0, 0x01, 0x80, 0x11, 0x88, 0x31, 0x8C, 0x7F, 0xFE, 0x7F, 0xFE, 0x31, 0x8C, 0x11, 0x88, 0x01, 0x80, 0x07, 0xE0, 0x03, 0xC0, 0x01, 0x80, 0x00, 0x00, 0x01, 0x80, 0x03, 0xC0, 0x07, 0xE0, 0x0F, 0xF0, 0x17, 0xE8, 0x3B, 0xDC, 0x7F, 0xFE, 0xFF, 0xFF, 0xFF, 0xFF, 0x7F, 0xFE, 0x3B, 0xDC, 0x17, 0xE8, 0x0F, 0xF0, 0x07, 0xE0, 0x03, 0xC0, 0x01, 0x80, 0x00, 0x07, 0x00, 0x07, }, #define TK_MAC_XCURSOR_gobbler 27 [TK_MAC_XCURSOR_gobbler] = { 0x00, 0x00, 0x00, 0x78, 0x00, 0x70, 0x40, 0x36, 0x4F, 0xB0, 0x7F, 0xF0, 0x7E, 0x30, 0x7C, 0x30, 0x30, 0x38, 0x00, 0xF0, 0x0F, 0xE0, 0x04, 0x00, 0x04, 0x00, 0x04, 0x00, 0x0F, 0x00, 0x00, 0x00, 0x00, 0xFC, 0x00, 0xFC, 0xE0, 0xFF, 0xFF, 0xFF, 0xFF, 0xFF, 0xFF, 0xF8, 0xFF, 0xF8, 0xFF, 0xF8, 0xFF, 0xFC, 0x7F, 0xFC, 0x3F, 0xF8, 0x1F, 0xF0, 0x0E, 0x00, 0x1F, 0x80, 0x1F, 0x80, 0x1F, 0x80, 0x00, 0x03, 0x00, 0x0E, }, #define TK_MAC_XCURSOR_gumby 28 [TK_MAC_XCURSOR_gumby] = { 0x3F, 0x00, 0x10, 0xC0, 0xC8, 0x20, 0xEA, 0xA0, 0xC8, 0x20, 0xCB, 0xA0, 0xF8, 0x38, 0x38, 0x3E, 0x08, 0x26, 0x08, 0x26, 0x09, 0x2E, 0x09, 0x26, 0x09, 0x20, 0x11, 0x10, 0x21, 0x08, 0x3E, 0xF8, 0x3F, 0x00, 0x1F, 0xC0, 0xCF, 0xE0, 0xEF, 0xE0, 0xCF, 0xE0, 0xCF, 0xE0, 0xFF, 0xF8, 0x3F, 0xFE, 0x0F, 0xE6, 0x0F, 0xE6, 0x0F, 0xEE, 0x0F, 0xE6, 0x0F, 0xE0, 0x1F, 0xF0, 0x3F, 0xF8, 0x3E, 0xF8, 0x00, 0x00, 0x00, 0x02, }, #define TK_MAC_XCURSOR_hand1 29 [TK_MAC_XCURSOR_hand1] = { 0x00, 0x0C, 0x00, 0x3C, 0x00, 0xF0, 0x01, 0xE0, 0x03, 0xC0, 0x07, 0xE0, 0x0F, 0xF0, 0x2F, 0xE0, 0x7F, 0xF0, 0x5F, 0xF0, 0x07, 0xE0, 0x07, 0xC0, 0x4A, 0x00, 0x62, 0x00, 0x34, 0x00, 0x18, 0x00, 0x00, 0x0C, 0x00, 0x3C, 0x00, 0xF0, 0x01, 0xE0, 0x03, 0xC0, 0x07, 0xE0, 0x0F, 0xF0, 0x2F, 0xE0, 0x7F, 0xF0, 0x7F, 0xF0, 0x7F, 0xE0, 0x7F, 0xC0, 0x7E, 0x00, 0x7E, 0x00, 0x3C, 0x00, 0x18, 0x00, 0x00, 0x00, 0x00, 0x0D, }, #define TK_MAC_XCURSOR_hand2 30 [TK_MAC_XCURSOR_hand2] = { 0x00, 0x00, 0x3F, 0xC0, 0x40, 0x20, 0x3F, 0x10, 0x08, 0x08, 0x07, 0x08, 0x08, 0x08, 0x07, 0x14, 0x08, 0x22, 0x06, 0x41, 0x01, 0x82, 0x01, 0x24, 0x00, 0x88, 0x00, 0x50, 0x00, 0x20, 0x00, 0x00, 0x00, 0x00, 0x3F, 0xC0, 0x7F, 0xE0, 0x3F, 0xF0, 0x0F, 0xF8, 0x07, 0xF8, 0x0F, 0xF8, 0x07, 0xFC, 0x0F, 0xFE, 0x07, 0xFF, 0x01, 0xFE, 0x01, 0xFC, 0x00, 0xF8, 0x00, 0x70, 0x00, 0x20, 0x00, 0x00, 0x00, 0x02, 0x00, 0x01, }, #define TK_MAC_XCURSOR_heart 31 [TK_MAC_XCURSOR_heart] = { 0x00, 0x00, 0x3E, 0xF8, 0x63, 0x8C, 0xC1, 0x06, 0x80, 0x02, 0x80, 0x02, 0x80, 0x02, 0x80, 0x02, 0xC0, 0x06, 0x60, 0x0C, 0x30, 0x18, 0x18, 0x30, 0x0C, 0x60, 0x06, 0xC0, 0x03, 0x80, 0x00, 0x00, 0x00, 0x00, 0x3E, 0xF8, 0x7F, 0xFC, 0xFF, 0xFE, 0xFF, 0xFE, 0xFF, 0xFE, 0xFF, 0xFE, 0xFF, 0xFE, 0xFF, 0xFE, 0x7F, 0xFC, 0x3F, 0xF8, 0x1F, 0xF0, 0x0F, 0xE0, 0x07, 0xC0, 0x03, 0x80, 0x00, 0x00, 0x00, 0x03, 0x00, 0x07, }, #define TK_MAC_XCURSOR_icon 32 [TK_MAC_XCURSOR_icon] = { 0xFF, 0xFF, 0xD5, 0x55, 0xAA, 0xAB, 0xD5, 0x55, 0xA0, 0x0B, 0xD0, 0x05, 0xA0, 0x0B, 0xD0, 0x05, 0xA0, 0x0B, 0xD0, 0x05, 0xA0, 0x0B, 0xD0, 0x05, 0xAA, 0xAB, 0xD5, 0x55, 0xAA, 0xAB, 0xFF, 0xFF, 0xFF, 0xFF, 0xFF, 0xFF, 0xFF, 0xFF, 0xFF, 0xFF, 0xF0, 0x0F, 0xF0, 0x0F, 0xF0, 0x0F, 0xF0, 0x0F, 0xF0, 0x0F, 0xF0, 0x0F, 0xF0, 0x0F, 0xF0, 0x0F, 0xFF, 0xFF, 0xFF, 0xFF, 0xFF, 0xFF, 0xFF, 0xFF, 0x00, 0x07, 0x00, 0x07, }, #define TK_MAC_XCURSOR_iron_cross 33 [TK_MAC_XCURSOR_iron_cross] = { 0x00, 0x00, 0x3F, 0xFC, 0x1F, 0xF8, 0x4F, 0xF2, 0x67, 0xE6, 0x73, 0xCE, 0x79, 0x9E, 0x7F, 0xFE, 0x7F, 0xFE, 0x79, 0x9E, 0x73, 0xCE, 0x67, 0xE6, 0x4F, 0xF2, 0x1F, 0xF8, 0x3F, 0xFC, 0x00, 0x00, 0x7F, 0xFE, 0x7F, 0xFE, 0xFF, 0xFF, 0xFF, 0xFF, 0xFF, 0xFF, 0xFF, 0xFF, 0xFF, 0xFF, 0xFF, 0xFF, 0xFF, 0xFF, 0xFF, 0xFF, 0xFF, 0xFF, 0xFF, 0xFF, 0xFF, 0xFF, 0xFF, 0xFF, 0x7F, 0xFE, 0x7F, 0xFE, 0x00, 0x07, 0x00, 0x06, }, #define TK_MAC_XCURSOR_left_ptr 34 [TK_MAC_XCURSOR_left_ptr] = { 0x00, 0x00, 0x08, 0x00, 0x0C, 0x00, 0x0E, 0x00, 0x0F, 0x00, 0x0F, 0x80, 0x0F, 0xC0, 0x0F, 0xE0, 0x0F, 0xF0, 0x0F, 0x80, 0x0D, 0x80, 0x08, 0xC0, 0x00, 0xC0, 0x00, 0x60, 0x00, 0x60, 0x00, 0x00, 0x18, 0x00, 0x1C, 0x00, 0x1E, 0x00, 0x1F, 0x00, 0x1F, 0x80, 0x1F, 0xC0, 0x1F, 0xE0, 0x1F, 0xF0, 0x1F, 0xF8, 0x1F, 0xFC, 0x1F, 0xC0, 0x1D, 0xE0, 0x19, 0xE0, 0x10, 0xF0, 0x00, 0xF0, 0x00, 0x70, 0x00, 0x01, 0x00, 0x04, }, #define TK_MAC_XCURSOR_left_side 35 [TK_MAC_XCURSOR_left_side] = { 0x00, 0x00, 0x60, 0x00, 0x60, 0x00, 0x60, 0x80, 0x61, 0x00, 0x62, 0x00, 0x64, 0x00, 0x6F, 0xFC, 0x64, 0x00, 0x62, 0x00, 0x61, 0x00, 0x60, 0x80, 0x60, 0x00, 0x60, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x60, 0x00, 0x60, 0x00, 0x60, 0x80, 0x61, 0x00, 0x62, 0x00, 0x64, 0x00, 0x6F, 0xFC, 0x64, 0x00, 0x62, 0x00, 0x61, 0x00, 0x60, 0x80, 0x60, 0x00, 0x60, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x07, 0x00, 0x04, }, #define TK_MAC_XCURSOR_left_tee 36 [TK_MAC_XCURSOR_left_tee] = { 0x00, 0x00, 0x0C, 0x00, 0x0C, 0x00, 0x0C, 0x00, 0x0C, 0x00, 0x0C, 0x00, 0x0C, 0x00, 0x0F, 0xF8, 0x0F, 0xF8, 0x0C, 0x00, 0x0C, 0x00, 0x0C, 0x00, 0x0C, 0x00, 0x0C, 0x00, 0x0C, 0x00, 0x00, 0x00, 0x00, 0x00, 0x0C, 0x00, 0x0C, 0x00, 0x0C, 0x00, 0x0C, 0x00, 0x0C, 0x00, 0x0C, 0x00, 0x0F, 0xF8, 0x0F, 0xF8, 0x0C, 0x00, 0x0C, 0x00, 0x0C, 0x00, 0x0C, 0x00, 0x0C, 0x00, 0x0C, 0x00, 0x00, 0x00, 0x00, 0x07, 0x00, 0x04, }, #define TK_MAC_XCURSOR_leftbutton 37 [TK_MAC_XCURSOR_leftbutton] = { 0x80, 0x02, 0x7F, 0xFC, 0x7F, 0xFC, 0x44, 0x44, 0x45, 0x54, 0x45, 0x54, 0x45, 0x54, 0x45, 0x54, 0x44, 0x44, 0x7F, 0xFC, 0x7F, 0xFC, 0x7F, 0xFC, 0x7F, 0xFC, 0x7F, 0xFC, 0x7F, 0xFC, 0x80, 0x02, 0xFF, 0xFE, 0xFF, 0xFE, 0xFF, 0xFE, 0xFF, 0xFE, 0xFF, 0xFE, 0xFF, 0xFE, 0xFF, 0xFE, 0xFF, 0xFE, 0xFF, 0xFE, 0xFF, 0xFE, 0xFF, 0xFE, 0xFF, 0xFE, 0xFF, 0xFE, 0xFF, 0xFE, 0xFF, 0xFE, 0xFF, 0xFE, 0x00, 0x04, 0x00, 0x03, }, #define TK_MAC_XCURSOR_ll_angle 38 [TK_MAC_XCURSOR_ll_angle] = { 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x0C, 0x00, 0x0C, 0x00, 0x0C, 0x00, 0x0C, 0x00, 0x0C, 0x00, 0x0C, 0x00, 0x0C, 0x00, 0x0F, 0xF8, 0x0F, 0xF8, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x0C, 0x00, 0x0C, 0x00, 0x0C, 0x00, 0x0C, 0x00, 0x0C, 0x00, 0x0C, 0x00, 0x0C, 0x00, 0x0F, 0xF8, 0x0F, 0xF8, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x0B, 0x00, 0x04, }, #define TK_MAC_XCURSOR_lr_angle 39 [TK_MAC_XCURSOR_lr_angle] = { 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x30, 0x00, 0x30, 0x00, 0x30, 0x00, 0x30, 0x00, 0x30, 0x00, 0x30, 0x00, 0x30, 0x1F, 0xF0, 0x1F, 0xF0, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x30, 0x00, 0x30, 0x00, 0x30, 0x00, 0x30, 0x00, 0x30, 0x00, 0x30, 0x00, 0x30, 0x1F, 0xF0, 0x1F, 0xF0, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x0B, 0x00, 0x0B, }, #define TK_MAC_XCURSOR_man 40 [TK_MAC_XCURSOR_man] = { 0x03, 0x80, 0x1E, 0xF0, 0x02, 0x80, 0x81, 0x00, 0x43, 0x87, 0x24, 0x4B, 0x1D, 0x70, 0x05, 0x40, 0x04, 0x40, 0x02, 0x80, 0x04, 0x40, 0x09, 0x20, 0x12, 0x90, 0x14, 0x50, 0x78, 0x3C, 0xF8, 0x3F, 0x03, 0x80, 0x1F, 0xF0, 0x03, 0x80, 0x81, 0x00, 0x43, 0x87, 0x27, 0xCB, 0x1F, 0xF0, 0x07, 0xC0, 0x07, 0xC0, 0x03, 0x80, 0x07, 0xC0, 0x0F, 0xE0, 0x1E, 0xF0, 0x1C, 0x70, 0x78, 0x3C, 0xF8, 0x3F, 0x00, 0x01, 0x00, 0x07, }, #define TK_MAC_XCURSOR_middlebutton 41 [TK_MAC_XCURSOR_middlebutton] = { 0x80, 0x02, 0x7F, 0xFC, 0x7F, 0xFC, 0x44, 0x44, 0x54, 0x54, 0x54, 0x54, 0x54, 0x54, 0x54, 0x54, 0x44, 0x44, 0x7F, 0xFC, 0x7F, 0xFC, 0x7F, 0xFC, 0x7F, 0xFC, 0x7F, 0xFC, 0x7F, 0xFC, 0x80, 0x02, 0xFF, 0xFE, 0xFF, 0xFE, 0xFF, 0xFE, 0xFF, 0xFE, 0xFF, 0xFE, 0xFF, 0xFE, 0xFF, 0xFE, 0xFF, 0xFE, 0xFF, 0xFE, 0xFF, 0xFE, 0xFF, 0xFE, 0xFF, 0xFE, 0xFF, 0xFE, 0xFF, 0xFE, 0xFF, 0xFE, 0xFF, 0xFE, 0x00, 0x04, 0x00, 0x07, }, #define TK_MAC_XCURSOR_mouse 42 [TK_MAC_XCURSOR_mouse] = { 0x06, 0x00, 0x01, 0x00, 0x01, 0x80, 0x0F, 0xF0, 0x10, 0x08, 0x17, 0xE8, 0x14, 0x28, 0x14, 0x28, 0x17, 0xE8, 0x10, 0x08, 0x10, 0x08, 0x10, 0x08, 0x10, 0x08, 0x10, 0x08, 0x10, 0x08, 0x0F, 0xF0, 0x06, 0x00, 0x01, 0x00, 0x01, 0x80, 0x0F, 0xF0, 0x1F, 0xF8, 0x1F, 0xF8, 0x1F, 0xF8, 0x1F, 0xF8, 0x1F, 0xF8, 0x1F, 0xF8, 0x1F, 0xF8, 0x1F, 0xF8, 0x1F, 0xF8, 0x1F, 0xF8, 0x1F, 0xF8, 0x0F, 0xF0, 0x00, 0x00, 0x00, 0x00, }, #define TK_MAC_XCURSOR_pencil 43 [TK_MAC_XCURSOR_pencil] = { 0x00, 0x00, 0x00, 0xF0, 0x00, 0x88, 0x01, 0x08, 0x01, 0x90, 0x02, 0x70, 0x02, 0x20, 0x04, 0x40, 0x04, 0x40, 0x08, 0x80, 0x08, 0x80, 0x11, 0x00, 0x1E, 0x00, 0x1C, 0x00, 0x18, 0x00, 0x10, 0x00, 0x00, 0x00, 0x00, 0xF0, 0x00, 0xF8, 0x01, 0xF8, 0x01, 0xF0, 0x03, 0xF0, 0x03, 0xE0, 0x07, 0xC0, 0x07, 0xC0, 0x0F, 0x80, 0x0F, 0x80, 0x1F, 0x00, 0x1E, 0x00, 0x1C, 0x00, 0x18, 0x00, 0x10, 0x00, 0x00, 0x0F, 0x00, 0x03, }, #define TK_MAC_XCURSOR_pirate 44 [TK_MAC_XCURSOR_pirate] = { 0x03, 0xC0, 0x07, 0xE0, 0x0F, 0xF0, 0x19, 0x98, 0x19, 0x98, 0x0F, 0xF0, 0x07, 0xE0, 0x03, 0xC0, 0x43, 0xC2, 0x43, 0xC3, 0x21, 0x84, 0x1C, 0x38, 0x03, 0xC0, 0x0F, 0xF1, 0x78, 0x1F, 0x40, 0x02, 0x07, 0xE0, 0x0F, 0xF0, 0x1F, 0xF8, 0x3F, 0xFC, 0x3F, 0xFC, 0x1F, 0xF8, 0x0F, 0xF0, 0x47, 0xE2, 0xE7, 0xE7, 0xE7, 0xE7, 0x7F, 0xFF, 0x3F, 0xFC, 0x1F, 0xF9, 0x7F, 0xFF, 0xFF, 0xFF, 0xF8, 0x1F, 0x00, 0x0A, 0x00, 0x07, }, #define TK_MAC_XCURSOR_plus 45 [TK_MAC_XCURSOR_plus] = { 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x01, 0x80, 0x01, 0x80, 0x01, 0x80, 0x01, 0x80, 0x1F, 0xF8, 0x1F, 0xF8, 0x01, 0x80, 0x01, 0x80, 0x01, 0x80, 0x01, 0x80, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x01, 0x80, 0x01, 0x80, 0x01, 0x80, 0x01, 0x80, 0x1F, 0xF8, 0x1F, 0xF8, 0x01, 0x80, 0x01, 0x80, 0x01, 0x80, 0x01, 0x80, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x07, 0x00, 0x07, }, #define TK_MAC_XCURSOR_question_arrow 46 [TK_MAC_XCURSOR_question_arrow] = { 0x07, 0xC0, 0x0F, 0xE0, 0x1C, 0x70, 0x18, 0x30, 0x1C, 0x30, 0x0C, 0x70, 0x00, 0xE0, 0x03, 0xC0, 0x03, 0x80, 0x02, 0x80, 0x02, 0x80, 0x0E, 0xE0, 0x06, 0xC0, 0x03, 0x80, 0x01, 0x00, 0x00, 0x00, 0x07, 0xC0, 0x0F, 0xE0, 0x1C, 0x70, 0x18, 0x30, 0x1C, 0x30, 0x0C, 0x70, 0x00, 0xE0, 0x03, 0xC0, 0x03, 0x80, 0x02, 0x80, 0x3F, 0xF8, 0x1F, 0xF0, 0x0F, 0xE0, 0x07, 0xC0, 0x03, 0x80, 0x01, 0x00, 0x00, 0x0E, 0x00, 0x07, }, #define TK_MAC_XCURSOR_right_ptr 47 [TK_MAC_XCURSOR_right_ptr] = { 0x00, 0x00, 0x00, 0x10, 0x00, 0x30, 0x00, 0x70, 0x00, 0xF0, 0x01, 0xF0, 0x03, 0xF0, 0x07, 0xF0, 0x0F, 0xF0, 0x01, 0xF0, 0x01, 0xB0, 0x03, 0x10, 0x03, 0x00, 0x06, 0x00, 0x06, 0x00, 0x00, 0x00, 0x00, 0x18, 0x00, 0x38, 0x00, 0x78, 0x00, 0xF8, 0x01, 0xF8, 0x03, 0xF8, 0x07, 0xF8, 0x0F, 0xF8, 0x1F, 0xF8, 0x3F, 0xF8, 0x03, 0xF8, 0x07, 0xB8, 0x07, 0x98, 0x0F, 0x08, 0x0F, 0x00, 0x0E, 0x00, 0x00, 0x01, 0x00, 0x0B, }, #define TK_MAC_XCURSOR_right_side 48 [TK_MAC_XCURSOR_right_side] = { 0x00, 0x00, 0x00, 0x00, 0x00, 0x06, 0x00, 0x06, 0x01, 0x06, 0x00, 0x86, 0x00, 0x46, 0x00, 0x26, 0x3F, 0xF6, 0x00, 0x26, 0x00, 0x46, 0x00, 0x86, 0x01, 0x06, 0x00, 0x06, 0x00, 0x06, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x06, 0x00, 0x06, 0x01, 0x06, 0x00, 0x86, 0x00, 0x46, 0x00, 0x26, 0x3F, 0xF6, 0x00, 0x26, 0x00, 0x46, 0x00, 0x86, 0x01, 0x06, 0x00, 0x06, 0x00, 0x06, 0x00, 0x00, 0x00, 0x08, 0x00, 0x0B, }, #define TK_MAC_XCURSOR_right_tee 49 [TK_MAC_XCURSOR_right_tee] = { 0x00, 0x00, 0x00, 0x30, 0x00, 0x30, 0x00, 0x30, 0x00, 0x30, 0x00, 0x30, 0x00, 0x30, 0x1F, 0xF0, 0x1F, 0xF0, 0x00, 0x30, 0x00, 0x30, 0x00, 0x30, 0x00, 0x30, 0x00, 0x30, 0x00, 0x30, 0x00, 0x00, 0x00, 0x00, 0x00, 0x30, 0x00, 0x30, 0x00, 0x30, 0x00, 0x30, 0x00, 0x30, 0x00, 0x30, 0x1F, 0xF0, 0x1F, 0xF0, 0x00, 0x30, 0x00, 0x30, 0x00, 0x30, 0x00, 0x30, 0x00, 0x30, 0x00, 0x30, 0x00, 0x00, 0x00, 0x07, 0x00, 0x0A, }, #define TK_MAC_XCURSOR_rightbutton 50 [TK_MAC_XCURSOR_rightbutton] = { 0x80, 0x02, 0x7F, 0xFC, 0x7F, 0xFC, 0x44, 0x44, 0x55, 0x44, 0x55, 0x44, 0x55, 0x44, 0x55, 0x44, 0x44, 0x44, 0x7F, 0xFC, 0x7F, 0xFC, 0x7F, 0xFC, 0x7F, 0xFC, 0x7F, 0xFC, 0x7F, 0xFC, 0x80, 0x02, 0xFF, 0xFE, 0xFF, 0xFE, 0xFF, 0xFE, 0xFF, 0xFE, 0xFF, 0xFE, 0xFF, 0xFE, 0xFF, 0xFE, 0xFF, 0xFE, 0xFF, 0xFE, 0xFF, 0xFE, 0xFF, 0xFE, 0xFF, 0xFE, 0xFF, 0xFE, 0xFF, 0xFE, 0xFF, 0xFE, 0xFF, 0xFE, 0x00, 0x04, 0x00, 0x03, }, #define TK_MAC_XCURSOR_rtl_logo 51 [TK_MAC_XCURSOR_rtl_logo] = { 0x00, 0x00, 0x7F, 0xFE, 0x40, 0x22, 0x40, 0x22, 0x40, 0x22, 0x7F, 0xE2, 0x44, 0x22, 0x44, 0x22, 0x44, 0x22, 0x44, 0x22, 0x47, 0xFE, 0x44, 0x02, 0x44, 0x02, 0x44, 0x02, 0x7F, 0xFE, 0x00, 0x00, 0x00, 0x00, 0x7F, 0xFE, 0x7F, 0xFE, 0x60, 0x76, 0x7F, 0xF6, 0x7F, 0xF6, 0x7C, 0x36, 0x6C, 0x36, 0x6C, 0x36, 0x6C, 0x3E, 0x6F, 0xFE, 0x6F, 0xFE, 0x6E, 0x06, 0x7F, 0xFE, 0x7F, 0xFE, 0x00, 0x00, 0x00, 0x07, 0x00, 0x07, }, #define TK_MAC_XCURSOR_sailboat 52 [TK_MAC_XCURSOR_sailboat] = { 0x00, 0x00, 0x00, 0x40, 0x00, 0x40, 0x01, 0x60, 0x01, 0x60, 0x03, 0x60, 0x03, 0x70, 0x07, 0x70, 0x07, 0x70, 0x0F, 0x78, 0x0F, 0x78, 0x1F, 0x78, 0x1F, 0x7C, 0x3E, 0x38, 0x00, 0x00, 0x00, 0x00, 0x00, 0x40, 0x00, 0xE0, 0x01, 0xE0, 0x03, 0xF0, 0x03, 0xF0, 0x07, 0xF0, 0x07, 0xF8, 0x0F, 0xF8, 0x0F, 0xF8, 0x1F, 0xFC, 0x1F, 0xFC, 0x3F, 0xFC, 0x3F, 0xFE, 0x7F, 0x7C, 0x7E, 0x38, 0x00, 0x00, 0x00, 0x0C, 0x00, 0x08, }, #define TK_MAC_XCURSOR_sb_down_arrow 53 [TK_MAC_XCURSOR_sb_down_arrow] = { 0x02, 0x80, 0x02, 0x80, 0x02, 0x80, 0x02, 0x80, 0x02, 0x80, 0x02, 0x80, 0x02, 0x80, 0x02, 0x80, 0x02, 0x80, 0x02, 0x80, 0x02, 0x80, 0x0F, 0xE0, 0x07, 0xC0, 0x03, 0x80, 0x01, 0x00, 0x00, 0x00, 0x03, 0x80, 0x03, 0x80, 0x03, 0x80, 0x03, 0x80, 0x03, 0x80, 0x03, 0x80, 0x03, 0x80, 0x03, 0x80, 0x03, 0x80, 0x03, 0x80, 0x03, 0x80, 0x1F, 0xF0, 0x0F, 0xE0, 0x07, 0xC0, 0x03, 0x80, 0x01, 0x00, 0x00, 0x0E, 0x00, 0x07, }, #define TK_MAC_XCURSOR_sb_h_double_arrow 54 [TK_MAC_XCURSOR_sb_h_double_arrow] = { 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x08, 0x10, 0x18, 0x18, 0x3F, 0xFC, 0x78, 0x1E, 0x3F, 0xFC, 0x18, 0x18, 0x08, 0x10, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x08, 0x10, 0x18, 0x18, 0x38, 0x1C, 0x7F, 0xFE, 0xFF, 0xFF, 0x7F, 0xFE, 0x38, 0x1C, 0x18, 0x18, 0x08, 0x10, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x07, 0x00, 0x07, }, #define TK_MAC_XCURSOR_sb_left_arrow 55 [TK_MAC_XCURSOR_sb_left_arrow] = { 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x08, 0x00, 0x18, 0x00, 0x3F, 0xFF, 0x78, 0x00, 0x3F, 0xFF, 0x18, 0x00, 0x08, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x08, 0x00, 0x18, 0x00, 0x38, 0x00, 0x7F, 0xFF, 0xFF, 0xFF, 0x7F, 0xFF, 0x38, 0x00, 0x18, 0x00, 0x08, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x07, 0x00, 0x01, }, #define TK_MAC_XCURSOR_sb_right_arrow 56 [TK_MAC_XCURSOR_sb_right_arrow] = { 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x10, 0x00, 0x18, 0xFF, 0xFC, 0x00, 0x1E, 0xFF, 0xFC, 0x00, 0x18, 0x00, 0x10, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x10, 0x00, 0x18, 0x00, 0x1C, 0xFF, 0xFE, 0xFF, 0xFF, 0xFF, 0xFE, 0x00, 0x1C, 0x00, 0x18, 0x00, 0x10, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x08, 0x00, 0x0E, }, #define TK_MAC_XCURSOR_sb_up_arrow 57 [TK_MAC_XCURSOR_sb_up_arrow] = { 0x00, 0x00, 0x00, 0x80, 0x01, 0xC0, 0x03, 0xE0, 0x07, 0xF0, 0x01, 0x40, 0x01, 0x40, 0x01, 0x40, 0x01, 0x40, 0x01, 0x40, 0x01, 0x40, 0x01, 0x40, 0x01, 0x40, 0x01, 0x40, 0x01, 0x40, 0x01, 0x40, 0x00, 0x80, 0x01, 0xC0, 0x03, 0xE0, 0x07, 0xF0, 0x0F, 0xF8, 0x01, 0xC0, 0x01, 0xC0, 0x01, 0xC0, 0x01, 0xC0, 0x01, 0xC0, 0x01, 0xC0, 0x01, 0xC0, 0x01, 0xC0, 0x01, 0xC0, 0x01, 0xC0, 0x01, 0xC0, 0x00, 0x01, 0x00, 0x08, }, #define TK_MAC_XCURSOR_sb_v_double_arrow 58 [TK_MAC_XCURSOR_sb_v_double_arrow] = { 0x00, 0x00, 0x01, 0x00, 0x03, 0x80, 0x07, 0xC0, 0x0F, 0xE0, 0x02, 0x80, 0x02, 0x80, 0x02, 0x80, 0x02, 0x80, 0x02, 0x80, 0x02, 0x80, 0x0F, 0xE0, 0x07, 0xC0, 0x03, 0x80, 0x01, 0x00, 0x00, 0x00, 0x01, 0x00, 0x03, 0x80, 0x07, 0xC0, 0x0F, 0xE0, 0x1F, 0xF0, 0x03, 0x80, 0x03, 0x80, 0x03, 0x80, 0x03, 0x80, 0x03, 0x80, 0x03, 0x80, 0x1F, 0xF0, 0x0F, 0xE0, 0x07, 0xC0, 0x03, 0x80, 0x01, 0x00, 0x00, 0x07, 0x00, 0x07, }, #define TK_MAC_XCURSOR_shuttle 59 [TK_MAC_XCURSOR_shuttle] = { 0x00, 0x20, 0x00, 0x70, 0x00, 0xF8, 0x01, 0xDE, 0x05, 0xDE, 0x09, 0xDE, 0x11, 0xDE, 0x11, 0xDE, 0x11, 0xDE, 0x11, 0xDE, 0x31, 0xDE, 0x71, 0xDE, 0xFD, 0xDE, 0x18, 0x88, 0x00, 0x78, 0x00, 0x30, 0x00, 0x20, 0x00, 0x70, 0x00, 0xF8, 0x01, 0xFE, 0x07, 0xFE, 0x0F, 0xFE, 0x1F, 0xFE, 0x1F, 0xFE, 0x1F, 0xFE, 0x1F, 0xFE, 0x3F, 0xFE, 0x7F, 0xFE, 0xFF, 0xFE, 0x18, 0xF8, 0x00, 0x78, 0x00, 0x30, 0x00, 0x00, 0x00, 0x0A, }, #define TK_MAC_XCURSOR_sizing 60 [TK_MAC_XCURSOR_sizing] = { 0x00, 0x00, 0x7F, 0x80, 0x40, 0x00, 0x40, 0x00, 0x40, 0x00, 0x47, 0xE0, 0x44, 0x20, 0x44, 0x22, 0x44, 0x22, 0x04, 0x22, 0x07, 0xE2, 0x00, 0x12, 0x00, 0x0A, 0x00, 0x06, 0x01, 0xFE, 0x00, 0x00, 0xFF, 0xC0, 0xFF, 0xC0, 0xFF, 0xC0, 0xE0, 0x00, 0xEF, 0xF0, 0xEF, 0xF0, 0xEC, 0x37, 0xEC, 0x37, 0xEC, 0x37, 0xEC, 0x37, 0x0F, 0xF7, 0x0F, 0xFF, 0x00, 0x1F, 0x03, 0xFF, 0x03, 0xFF, 0x03, 0xFF, 0x00, 0x0E, 0x00, 0x0E, }, #define TK_MAC_XCURSOR_spider 61 [TK_MAC_XCURSOR_spider] = { 0x20, 0x10, 0x10, 0x20, 0x10, 0x20, 0x08, 0x40, 0x08, 0x40, 0x87, 0x87, 0x67, 0x98, 0x1F, 0xE0, 0x1F, 0xE0, 0x67, 0x98, 0x87, 0x87, 0x08, 0x40, 0x08, 0x40, 0x10, 0x20, 0x10, 0x20, 0x20, 0x10, 0x70, 0x38, 0x38, 0x70, 0x38, 0x70, 0x1C, 0xE0, 0x9F, 0xE7, 0xEF, 0xDF, 0xFF, 0xFF, 0x7F, 0xF8, 0x7F, 0xF8, 0xFF, 0xFF, 0xEF, 0xDF, 0x9F, 0xE7, 0x1C, 0xE0, 0x38, 0x70, 0x38, 0x70, 0x70, 0x38, 0x00, 0x07, 0x00, 0x07, }, #define TK_MAC_XCURSOR_spraycan 62 [TK_MAC_XCURSOR_spraycan] = { 0x00, 0x18, 0x00, 0x40, 0x0D, 0x18, 0x1E, 0x40, 0x1A, 0x18, 0x3F, 0x00, 0x21, 0x00, 0x39, 0x00, 0x29, 0x00, 0x39, 0x00, 0x29, 0x00, 0x39, 0x00, 0x39, 0x00, 0x21, 0x00, 0x21, 0x00, 0x3F, 0x00, 0x00, 0x18, 0x00, 0x40, 0x0D, 0x18, 0x1E, 0x40, 0x1E, 0x18, 0x3F, 0x00, 0x3F, 0x00, 0x3F, 0x00, 0x3F, 0x00, 0x3F, 0x00, 0x3F, 0x00, 0x3F, 0x00, 0x3F, 0x00, 0x3F, 0x00, 0x3F, 0x00, 0x3F, 0x00, 0x00, 0x02, 0x00, 0x07, }, #define TK_MAC_XCURSOR_star 63 [TK_MAC_XCURSOR_star] = { 0x01, 0x00, 0x02, 0x80, 0x02, 0x80, 0x02, 0x80, 0x04, 0x40, 0x04, 0x40, 0x04, 0x40, 0x39, 0x38, 0xC0, 0x06, 0x38, 0x38, 0x09, 0x20, 0x12, 0x90, 0x24, 0x48, 0x28, 0x28, 0x30, 0x18, 0x20, 0x08, 0x01, 0x00, 0x03, 0x80, 0x03, 0x80, 0x03, 0x80, 0x07, 0xC0, 0x07, 0xC0, 0x07, 0xC0, 0x3F, 0xF8, 0xFF, 0xFE, 0x3F, 0xF8, 0x0F, 0xE0, 0x1E, 0xF0, 0x3C, 0x78, 0x38, 0x38, 0x30, 0x18, 0x20, 0x08, 0x00, 0x07, 0x00, 0x07, }, #define TK_MAC_XCURSOR_target 64 [TK_MAC_XCURSOR_target] = { 0x00, 0x00, 0x03, 0x80, 0x0F, 0xE0, 0x1C, 0x70, 0x30, 0x18, 0x60, 0x0C, 0xC1, 0x06, 0xC2, 0x86, 0xC1, 0x06, 0x60, 0x0C, 0x30, 0x18, 0x1C, 0x70, 0x0F, 0xE0, 0x03, 0x80, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x03, 0x80, 0x0F, 0xE0, 0x1F, 0xF0, 0x3C, 0x78, 0x70, 0x1C, 0xE3, 0x8E, 0xE3, 0x8E, 0xE3, 0x8E, 0x70, 0x1C, 0x3C, 0x78, 0x1F, 0xF0, 0x0F, 0xE0, 0x03, 0x80, 0x00, 0x00, 0x00, 0x00, 0x00, 0x07, 0x00, 0x07, }, #define TK_MAC_XCURSOR_tcross 65 [TK_MAC_XCURSOR_tcross] = { 0x01, 0x00, 0x01, 0x00, 0x01, 0x00, 0x01, 0x00, 0x01, 0x00, 0x01, 0x00, 0x01, 0x00, 0xFF, 0xFE, 0x01, 0x00, 0x01, 0x00, 0x01, 0x00, 0x01, 0x00, 0x01, 0x00, 0x01, 0x00, 0x01, 0x00, 0x00, 0x00, 0x01, 0x00, 0x01, 0x00, 0x01, 0x00, 0x01, 0x00, 0x01, 0x00, 0x01, 0x00, 0x01, 0x00, 0xFF, 0xFE, 0x01, 0x00, 0x01, 0x00, 0x01, 0x00, 0x01, 0x00, 0x01, 0x00, 0x01, 0x00, 0x01, 0x00, 0x00, 0x00, 0x00, 0x07, 0x00, 0x07, }, #define TK_MAC_XCURSOR_top_left_arrow 66 [TK_MAC_XCURSOR_top_left_arrow] = { 0x00, 0x00, 0x60, 0x00, 0x78, 0x00, 0x3E, 0x00, 0x3F, 0x80, 0x1F, 0xE0, 0x1E, 0x00, 0x0D, 0x00, 0x0C, 0x80, 0x04, 0x40, 0x04, 0x20, 0x00, 0x10, 0x00, 0x08, 0x00, 0x04, 0x00, 0x00, 0x00, 0x00, 0xE0, 0x00, 0xF8, 0x00, 0xFE, 0x00, 0x7F, 0x80, 0x7F, 0xE0, 0x3F, 0xF8, 0x3F, 0xFE, 0x1F, 0x80, 0x1F, 0xC0, 0x0E, 0xE0, 0x0E, 0x70, 0x06, 0x38, 0x06, 0x1C, 0x02, 0x0E, 0x02, 0x04, 0x00, 0x00, 0x00, 0x01, 0x00, 0x01, }, #define TK_MAC_XCURSOR_top_left_corner 67 [TK_MAC_XCURSOR_top_left_corner] = { 0xFF, 0xF0, 0xFF, 0xF0, 0xC0, 0x00, 0xC0, 0x00, 0xCF, 0xC0, 0xCC, 0x00, 0xCA, 0x00, 0xC9, 0x00, 0xC8, 0x80, 0xC8, 0x40, 0xC0, 0x20, 0xC0, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0xFF, 0xF0, 0xFF, 0xF0, 0xC0, 0x00, 0xC0, 0x00, 0xCF, 0xC0, 0xCC, 0x00, 0xCA, 0x00, 0xC9, 0x00, 0xC8, 0x80, 0xC8, 0x40, 0xC0, 0x20, 0xC0, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, }, #define TK_MAC_XCURSOR_top_right_corner 68 [TK_MAC_XCURSOR_top_right_corner] = { 0x0F, 0xFF, 0x0F, 0xFF, 0x00, 0x03, 0x00, 0x03, 0x03, 0xF3, 0x00, 0x33, 0x00, 0x53, 0x00, 0x93, 0x01, 0x13, 0x02, 0x13, 0x04, 0x03, 0x00, 0x03, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x0F, 0xFF, 0x0F, 0xFF, 0x00, 0x03, 0x00, 0x03, 0x03, 0xF3, 0x00, 0x33, 0x00, 0x53, 0x00, 0x93, 0x01, 0x13, 0x02, 0x13, 0x04, 0x03, 0x00, 0x03, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x0F, }, #define TK_MAC_XCURSOR_top_side 69 [TK_MAC_XCURSOR_top_side] = { 0x00, 0x00, 0x7F, 0xFC, 0x7F, 0xFC, 0x00, 0x00, 0x01, 0x00, 0x03, 0x80, 0x05, 0x40, 0x09, 0x20, 0x11, 0x10, 0x01, 0x00, 0x01, 0x00, 0x01, 0x00, 0x01, 0x00, 0x01, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x7F, 0xFC, 0x7F, 0xFC, 0x00, 0x00, 0x01, 0x00, 0x03, 0x80, 0x05, 0x40, 0x09, 0x20, 0x11, 0x10, 0x01, 0x00, 0x01, 0x00, 0x01, 0x00, 0x01, 0x00, 0x01, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x04, 0x00, 0x07, }, #define TK_MAC_XCURSOR_top_tee 70 [TK_MAC_XCURSOR_top_tee] = { 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x7F, 0xFE, 0x7F, 0xFE, 0x01, 0x80, 0x01, 0x80, 0x01, 0x80, 0x01, 0x80, 0x01, 0x80, 0x01, 0x80, 0x01, 0x80, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x7F, 0xFE, 0x7F, 0xFE, 0x01, 0x80, 0x01, 0x80, 0x01, 0x80, 0x01, 0x80, 0x01, 0x80, 0x01, 0x80, 0x01, 0x80, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x04, 0x00, 0x07, }, #define TK_MAC_XCURSOR_trek 71 [TK_MAC_XCURSOR_trek] = { 0x01, 0x00, 0x00, 0x00, 0x03, 0x80, 0x07, 0xC0, 0x0F, 0xE0, 0x0E, 0xE0, 0x0F, 0xE0, 0x07, 0xC0, 0x03, 0x80, 0x01, 0x00, 0x0B, 0xA0, 0x0D, 0x60, 0x09, 0x20, 0x08, 0x20, 0x08, 0x20, 0x00, 0x00, 0x01, 0x00, 0x03, 0x80, 0x07, 0xC0, 0x0F, 0xE0, 0x1F, 0xF0, 0x1F, 0xF0, 0x1F, 0xF0, 0x0F, 0xE0, 0x07, 0xC0, 0x0B, 0xA0, 0x1F, 0xF0, 0x1F, 0xF0, 0x1F, 0xF0, 0x1D, 0x70, 0x1C, 0x70, 0x08, 0x20, 0x00, 0x00, 0x00, 0x07, }, #define TK_MAC_XCURSOR_ul_angle 72 [TK_MAC_XCURSOR_ul_angle] = { 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x0F, 0xF8, 0x0F, 0xF8, 0x0C, 0x00, 0x0C, 0x00, 0x0C, 0x00, 0x0C, 0x00, 0x0C, 0x00, 0x0C, 0x00, 0x0C, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x0F, 0xF8, 0x0F, 0xF8, 0x0C, 0x00, 0x0C, 0x00, 0x0C, 0x00, 0x0C, 0x00, 0x0C, 0x00, 0x0C, 0x00, 0x0C, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x03, 0x00, 0x04, }, #define TK_MAC_XCURSOR_umbrella 73 [TK_MAC_XCURSOR_umbrella] = { 0x00, 0x00, 0x08, 0x90, 0x02, 0x28, 0x49, 0xA6, 0x27, 0xC8, 0x19, 0x30, 0x61, 0x0C, 0x01, 0x00, 0x01, 0x00, 0x01, 0x00, 0x01, 0x00, 0x01, 0x00, 0x01, 0x40, 0x01, 0x40, 0x00, 0x80, 0x00, 0x00, 0x00, 0x00, 0x0F, 0xF0, 0x1F, 0xF8, 0x7F, 0xFE, 0x7F, 0xFC, 0xFF, 0xFE, 0xFB, 0xBE, 0xE3, 0x8E, 0x03, 0x80, 0x03, 0x80, 0x03, 0x80, 0x03, 0xC0, 0x03, 0xE0, 0x03, 0xE0, 0x01, 0xC0, 0x00, 0x80, 0x00, 0x04, 0x00, 0x07, }, #define TK_MAC_XCURSOR_ur_angle 74 [TK_MAC_XCURSOR_ur_angle] = { 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x1F, 0xF0, 0x1F, 0xF0, 0x00, 0x30, 0x00, 0x30, 0x00, 0x30, 0x00, 0x30, 0x00, 0x30, 0x00, 0x30, 0x00, 0x30, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x1F, 0xF0, 0x1F, 0xF0, 0x00, 0x30, 0x00, 0x30, 0x00, 0x30, 0x00, 0x30, 0x00, 0x30, 0x00, 0x30, 0x00, 0x30, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x04, 0x00, 0x0B, }, #define TK_MAC_XCURSOR_watch 75 [TK_MAC_XCURSOR_watch] = { 0x07, 0xE0, 0x07, 0xE0, 0x07, 0xE0, 0x07, 0xE0, 0x08, 0x10, 0x10, 0x88, 0x10, 0x88, 0x10, 0x8C, 0x13, 0x8C, 0x10, 0x08, 0x10, 0x08, 0x08, 0x10, 0x07, 0xE0, 0x07, 0xE0, 0x07, 0xE0, 0x07, 0xE0, 0x07, 0xE0, 0x07, 0xE0, 0x07, 0xE0, 0x07, 0xE0, 0x0F, 0xF0, 0x1F, 0xF8, 0x1F, 0xF8, 0x1F, 0xFC, 0x1F, 0xFC, 0x1F, 0xF8, 0x1F, 0xF8, 0x0F, 0xF0, 0x07, 0xE0, 0x07, 0xE0, 0x07, 0xE0, 0x07, 0xE0, 0x00, 0x08, 0x00, 0x0D, }, #define TK_MAC_XCURSOR_xterm 76 [TK_MAC_XCURSOR_xterm] = { 0x0C, 0x60, 0x02, 0x80, 0x01, 0x00, 0x01, 0x00, 0x01, 0x00, 0x01, 0x00, 0x01, 0x00, 0x01, 0x00, 0x01, 0x00, 0x01, 0x00, 0x01, 0x00, 0x01, 0x00, 0x01, 0x00, 0x01, 0x00, 0x02, 0x80, 0x0C, 0x60, 0x0C, 0x60, 0x02, 0x80, 0x01, 0x00, 0x01, 0x00, 0x01, 0x00, 0x01, 0x00, 0x01, 0x00, 0x01, 0x00, 0x01, 0x00, 0x01, 0x00, 0x01, 0x00, 0x01, 0x00, 0x01, 0x00, 0x01, 0x00, 0x02, 0x80, 0x0C, 0x60, 0x00, 0x0B, 0x00, 0x07, }, }; |
Deleted macosx/tkMacOSXXCursors.r.
|
| < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < |
Changes to macosx/tkMacOSXXStubs.c.
1 2 3 4 5 6 7 8 9 | /* * tkMacOSXXStubs.c -- * * This file contains most of the X calls called by Tk. Many of these * calls are just stubs and either don't make sense on the Macintosh or * their implamentation just doesn't do anything. Other calls will * eventually be moved into other files. * * Copyright (c) 1995-1997 Sun Microsystems, Inc. | | | | | > > > > | 1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 34 35 36 37 38 39 40 41 42 43 | /* * tkMacOSXXStubs.c -- * * This file contains most of the X calls called by Tk. Many of these * calls are just stubs and either don't make sense on the Macintosh or * their implamentation just doesn't do anything. Other calls will * eventually be moved into other files. * * Copyright (c) 1995-1997 Sun Microsystems, Inc. * Copyright 2001-2009, Apple Inc. * Copyright (c) 2005-2009 Daniel A. Steffen <[email protected]> * * See the file "license.terms" for information on usage and redistribution * of this file, and for a DISCLAIMER OF ALL WARRANTIES. */ #include "tkMacOSXPrivate.h" #include "tkMacOSXEvent.h" #include <IOKit/IOKitLib.h> #include <IOKit/hidsystem/IOHIDShared.h> /* * Because this file is still under major development Debugger statements are * used through out this file. The define TCL_DEBUG will decide whether the * debugger statements actually call the debugger or not. */ #ifndef TCL_DEBUG # define Debugger() #endif #define ROOT_ID 10 CGFloat tkMacOSXZeroScreenHeight = 0; CGFloat tkMacOSXZeroScreenTop = 0; /* * Declarations of static variables used in this file. */ static TkDisplay *gMacDisplay = NULL; /* Macintosh display. */ |
︙ | ︙ | |||
50 51 52 53 54 55 56 | /* * Other declarations */ static int DestroyImage(XImage *image); static unsigned long ImageGetPixel(XImage *image, int x, int y); | | < < < < < | 54 55 56 57 58 59 60 61 62 63 64 65 66 67 68 69 | /* * Other declarations */ static int DestroyImage(XImage *image); static unsigned long ImageGetPixel(XImage *image, int x, int y); static int ImagePutPixel(XImage *image, int x, int y, unsigned long pixel); /* *---------------------------------------------------------------------- * * TkMacOSXDisplayChanged -- * * Called to set up initial screen info or when an event indicated |
︙ | ︙ | |||
79 80 81 82 83 84 85 | *---------------------------------------------------------------------- */ void TkMacOSXDisplayChanged( Display *display) { | < > | < | | | | < | | > | > | | | | < < | < | < > | 78 79 80 81 82 83 84 85 86 87 88 89 90 91 92 93 94 95 96 97 98 99 100 101 102 103 104 105 106 107 108 109 110 111 112 113 114 115 116 117 118 119 120 | *---------------------------------------------------------------------- */ void TkMacOSXDisplayChanged( Display *display) { Screen *screen; NSArray *nsScreens; if (display == NULL || display->screens == NULL) { return; } screen = display->screens; nsScreens = [NSScreen screens]; if (nsScreens && [nsScreens count]) { NSScreen *s = [nsScreens objectAtIndex:0]; NSRect bounds = [s frame], visible = [s visibleFrame]; NSRect maxBounds = NSZeroRect; tkMacOSXZeroScreenHeight = bounds.size.height; tkMacOSXZeroScreenTop = tkMacOSXZeroScreenHeight - (visible.origin.y + visible.size.height); screen->root_depth = NSBitsPerPixelFromDepth([s depth]); screen->width = bounds.size.width; screen->height = bounds.size.height; screen->mwidth = (bounds.size.width * 254 + 360) / 720; screen->mheight = (bounds.size.height * 254 + 360) / 720; for (s in nsScreens) { maxBounds = NSUnionRect(maxBounds, [s visibleFrame]); } *((NSRect *)screen->ext_data) = maxBounds; } } /* *---------------------------------------------------------------------- * * TkpOpenDisplay -- |
︙ | ︙ | |||
133 134 135 136 137 138 139 | * Allocates a new Display structure. * *---------------------------------------------------------------------- */ TkDisplay * TkpOpenDisplay( | | | > > > | 129 130 131 132 133 134 135 136 137 138 139 140 141 142 143 144 145 146 147 148 149 150 151 | * Allocates a new Display structure. * *---------------------------------------------------------------------- */ TkDisplay * TkpOpenDisplay( const char *display_name) { Display *display; Screen *screen; int fd = 0; static NSRect maxBounds = {{0, 0}, {0, 0}}; static char vendor[25] = ""; NSArray *cgVers; NSAutoreleasePool *pool; if (gMacDisplay != NULL) { if (strcmp(gMacDisplay->display->display_name, display_name) == 0) { return gMacDisplay; } else { return NULL; } |
︙ | ︙ | |||
162 163 164 165 166 167 168 | display->qlen = 0; display->fd = fd; display->screens = screen; display->nscreens = 1; display->default_screen = 0; display->display_name = (char *) macScreenName; | > > | > > | > > | > > > > > > | | | 161 162 163 164 165 166 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 | display->qlen = 0; display->fd = fd; display->screens = screen; display->nscreens = 1; display->default_screen = 0; display->display_name = (char *) macScreenName; pool = [NSAutoreleasePool new]; cgVers = [[[NSBundle bundleWithIdentifier:@"com.apple.CoreGraphics"] objectForInfoDictionaryKey:@"CFBundleShortVersionString"] componentsSeparatedByString:@"."]; if ([cgVers count] >= 2) { display->proto_major_version = [[cgVers objectAtIndex:1] integerValue]; } if ([cgVers count] >= 3) { display->proto_minor_version = [[cgVers objectAtIndex:2] integerValue]; } if (!vendor[0]) { snprintf(vendor, sizeof(vendor), "Apple AppKit %s %g", ([NSGarbageCollector defaultCollector] ? "GC" : "RR"), NSAppKitVersionNumber); } display->vendor = vendor; Gestalt(gestaltSystemVersion, (SInt32 *) &display->release); /* * These screen bits never change */ screen->root = ROOT_ID; screen->display = display; screen->black_pixel = 0x00000000 | PIXEL_MAGIC << 24; |
︙ | ︙ | |||
201 202 203 204 205 206 207 208 209 210 211 212 213 214 | /* * This is the quickest way to make sure that all the *Init flags get * properly initialized */ bzero(gMacDisplay, sizeof(TkDisplay)); gMacDisplay->display = display; return gMacDisplay; } /* *---------------------------------------------------------------------- * * TkpCloseDisplay -- | > | 212 213 214 215 216 217 218 219 220 221 222 223 224 225 226 | /* * This is the quickest way to make sure that all the *Init flags get * properly initialized */ bzero(gMacDisplay, sizeof(TkDisplay)); gMacDisplay->display = display; [pool drain]; return gMacDisplay; } /* *---------------------------------------------------------------------- * * TkpCloseDisplay -- |
︙ | ︙ | |||
268 269 270 271 272 273 274 | TkDisplay *dispPtr) /* display associated with clipboard */ { /* * Make sure that the local scrap is transfered to the global scrap if * needed. */ | | | 280 281 282 283 284 285 286 287 288 289 290 291 292 293 294 | TkDisplay *dispPtr) /* display associated with clipboard */ { /* * Make sure that the local scrap is transfered to the global scrap if * needed. */ [NSApp tkProvidePasteboard:dispPtr]; if (dispPtr->clipWindow != NULL) { Tk_DeleteSelHandler(dispPtr->clipWindow, dispPtr->clipboardAtom, dispPtr->applicationAtom); Tk_DeleteSelHandler(dispPtr->clipWindow, dispPtr->clipboardAtom, dispPtr->windowAtom); |
︙ | ︙ | |||
428 429 430 431 432 433 434 | *x_return = Tk_X(winPtr); *y_return = Tk_Y(winPtr); *width_return = Tk_Width(winPtr); *height_return = Tk_Height(winPtr); *border_width_return = winPtr->changes.border_width; *depth_return = Tk_Depth(winPtr); } else { | < < | < | | | | | 440 441 442 443 444 445 446 447 448 449 450 451 452 453 454 455 456 457 458 | *x_return = Tk_X(winPtr); *y_return = Tk_Y(winPtr); *width_return = Tk_Width(winPtr); *height_return = Tk_Height(winPtr); *border_width_return = winPtr->changes.border_width; *depth_return = Tk_Depth(winPtr); } else { CGSize size = ((MacDrawable *) d)->size; *x_return = 0; *y_return = 0; *width_return = size.width; *height_return = size.height; *border_width_return = 0; *depth_return = 32; } return 1; } void |
︙ | ︙ | |||
470 471 472 473 474 475 476 | } int XBell( Display* display, int percent) { | | | 479 480 481 482 483 484 485 486 487 488 489 490 491 492 493 | } int XBell( Display* display, int percent) { NSBeep(); return Success; } #if 0 void XSetWMNormalHints( Display* display, |
︙ | ︙ | |||
649 650 651 652 653 654 655 | *actual_type_return = None; *actual_format_return = *bytes_after_return = 0; *nitems_return = 0; return 0; } void | | > | 658 659 660 661 662 663 664 665 666 667 668 669 670 671 672 673 | *actual_type_return = None; *actual_format_return = *bytes_after_return = 0; *nitems_return = 0; return 0; } void XRefreshKeyboardMapping( XMappingEvent *x) { /* used by tkXEvent.c */ Debugger(); } void XSetIconName( |
︙ | ︙ | |||
714 715 716 717 718 719 720 | int n, int ordering) { TkRegion clipRgn = TkCreateRegion(); while (n--) { XRectangle rect = *rectangles; | | | 724 725 726 727 728 729 730 731 732 733 734 735 736 737 738 | int n, int ordering) { TkRegion clipRgn = TkCreateRegion(); while (n--) { XRectangle rect = *rectangles; rect.x += clip_x_origin; rect.y += clip_y_origin; TkUnionRectWithRegion(&rect, clipRgn, clipRgn); rectangles++; } TkSetRegion(d, gc, clipRgn); TkDestroyRegion(clipRgn); |
︙ | ︙ | |||
751 752 753 754 755 756 757 | void TkGetServerInfo( Tcl_Interp *interp, /* The server information is returned in this * interpreter's result. */ Tk_Window tkwin) /* Token for window; this selects a particular * display and server. */ { | | | > | > | > | 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 | void TkGetServerInfo( Tcl_Interp *interp, /* The server information is returned in this * interpreter's result. */ Tk_Window tkwin) /* Token for window; this selects a particular * display and server. */ { char buffer[5 + TCL_INTEGER_SPACE * 2]; char buffer2[11 + TCL_INTEGER_SPACE]; snprintf(buffer, sizeof(buffer), "CG%d.%d ", ProtocolVersion(Tk_Display(tkwin)), ProtocolRevision(Tk_Display(tkwin))); snprintf(buffer2, sizeof(buffer2), " Mac OS X %x", VendorRelease(Tk_Display(tkwin))); Tcl_AppendResult(interp, buffer, ServerVendor(Tk_Display(tkwin)), buffer2, NULL); } #pragma mark XImage handling /* *---------------------------------------------------------------------- * * XCreateImage -- * * Allocates storage for a new XImage. * |
︙ | ︙ | |||
837 838 839 840 841 842 843 | ximage->red_mask = 0x00FF0000; ximage->green_mask = 0x0000FF00; ximage->blue_mask = 0x000000FF; ximage->obdata = NULL; ximage->f.create_image = NULL; ximage->f.destroy_image = DestroyImage; ximage->f.get_pixel = ImageGetPixel; | | | 850 851 852 853 854 855 856 857 858 859 860 861 862 863 864 | ximage->red_mask = 0x00FF0000; ximage->green_mask = 0x0000FF00; ximage->blue_mask = 0x000000FF; ximage->obdata = NULL; ximage->f.create_image = NULL; ximage->f.destroy_image = DestroyImage; ximage->f.get_pixel = ImageGetPixel; ximage->f.put_pixel = ImagePutPixel; ximage->f.sub_image = NULL; ximage->f.add_pixel = NULL; return ximage; } /* |
︙ | ︙ | |||
872 873 874 875 876 877 878 879 880 | int x, int y, unsigned int width, unsigned int height, unsigned long plane_mask, int format) { XImage * imagePtr = NULL; Pixmap pixmap = (Pixmap) NULL; | > | > | < | | | | | | | | | | | | | | > > | > > > > > > < | > > > | | | | < < | < | 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 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 | int x, int y, unsigned int width, unsigned int height, unsigned long plane_mask, int format) { MacDrawable *macDraw = (MacDrawable *) d; XImage * imagePtr = NULL; Pixmap pixmap = (Pixmap) NULL; Tk_Window win = (Tk_Window) macDraw->winPtr; GC gc; char * data = NULL; int depth = 32; int offset = 0; int bitmap_pad = 0; int bytes_per_line = 0; if (format == ZPixmap) { if (width > 0 && height > 0) { /* * Tk_GetPixmap fails for zero width or height. */ pixmap = Tk_GetPixmap(display, d, width, height, depth); } if (win) { XGCValues values; gc = Tk_GetGC(win, 0, &values); } else { gc = XCreateGC(display, pixmap, 0, NULL); } if (pixmap) { CGContextRef context; XCopyArea(display, d, pixmap, gc, x, y, width, height, 0, 0); context = ((MacDrawable *) pixmap)->context; if (context) { data = CGBitmapContextGetData(context); bytes_per_line = CGBitmapContextGetBytesPerRow(context); } } if (data) { imagePtr = XCreateImage(display, NULL, depth, format, offset, data, width, height, bitmap_pad, bytes_per_line); /* * Track Pixmap underlying the XImage in the unused obdata field * so that we can treat XImages coming from XGetImage specially. */ imagePtr->obdata = (XPointer) pixmap; } else if (pixmap) { Tk_FreePixmap(display, pixmap); } if (!win) { XFreeGC(display, gc); } } else { TkMacOSXDbgMsg("Invalid image format"); } return imagePtr; } /* *---------------------------------------------------------------------- * |
︙ | ︙ | |||
975 976 977 978 979 980 981 | static unsigned long ImageGetPixel( XImage *image, int x, int y) { | < < < | | > > > | | > > > > | < < > > > | > | > > > > > > | | | > > > > | > | | | > | < < < > > > | > | | | < < < < | < < | | | > | < < < > < > > > | < > > | > > | > > > | | < | | | > > > > > > | | < | < < < < < < < < < < > | | | < < < < < < < | 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 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 | static unsigned long ImageGetPixel( XImage *image, int x, int y) { unsigned char r = 0, g = 0, b = 0; if (image && image->data) { unsigned char *srcPtr = ((unsigned char*) image->data) + (y * image->bytes_per_line) + (((image->xoffset + x) * image->bits_per_pixel) / NBBY); switch (image->bits_per_pixel) { case 32: { r = (*((unsigned int*) srcPtr) >> 16) & 0xff; g = (*((unsigned int*) srcPtr) >> 8) & 0xff; b = (*((unsigned int*) srcPtr) ) & 0xff; /*if (image->byte_order == LSBFirst) { r = srcPtr[2]; g = srcPtr[1]; b = srcPtr[0]; } else { r = srcPtr[1]; g = srcPtr[2]; b = srcPtr[3]; }*/ break; } case 16: r = (*((unsigned short*) srcPtr) >> 7) & 0xf8; g = (*((unsigned short*) srcPtr) >> 2) & 0xf8; b = (*((unsigned short*) srcPtr) << 3) & 0xf8; break; case 8: r = (*srcPtr << 2) & 0xc0; g = (*srcPtr << 4) & 0xc0; b = (*srcPtr << 6) & 0xc0; r |= r >> 2 | r >> 4 | r >> 6; g |= g >> 2 | g >> 4 | g >> 6; b |= b >> 2 | b >> 4 | b >> 6; break; case 4: { unsigned char c = (x % 2) ? *srcPtr : (*srcPtr >> 4); r = (c & 0x04) ? 0xff : 0; g = (c & 0x02) ? 0xff : 0; b = (c & 0x01) ? 0xff : 0; break; } case 1: r = g = b = ((*srcPtr) & (0x80 >> (x % 8))) ? 0xff : 0; break; } } return (PIXEL_MAGIC << 24) | (r << 16) | (g << 8) | b; } /* *---------------------------------------------------------------------- * * ImagePutPixel -- * * Set a single pixel in an image. * * Results: * None. * * Side effects: * None. * *---------------------------------------------------------------------- */ static int ImagePutPixel( XImage *image, int x, int y, unsigned long pixel) { if (image && image->data) { unsigned char r = ((pixel & image->red_mask) >> 16) & 0xff; unsigned char g = ((pixel & image->green_mask) >> 8) & 0xff; unsigned char b = ((pixel & image->blue_mask) ) & 0xff; unsigned char *dstPtr = ((unsigned char*) image->data) + (y * image->bytes_per_line) + (((image->xoffset + x) * image->bits_per_pixel) / NBBY); switch (image->bits_per_pixel) { case 32: *((unsigned int*) dstPtr) = (0xff << 24) | (r << 16) | (g << 8) | b; /*if (image->byte_order == LSBFirst) { dstPtr[3] = 0xff; dstPtr[2] = r; dstPtr[1] = g; dstPtr[0] = b; } else { dstPtr[0] = 0xff; dstPtr[1] = r; dstPtr[2] = g; dstPtr[3] = b; }*/ break; case 16: *((unsigned short*) dstPtr) = ((r & 0xf8) << 7) | ((g & 0xf8) << 2) | ((b & 0xf8) >> 3); break; case 8: *dstPtr = ((r & 0xc0) >> 2) | ((g & 0xc0) >> 4) | ((b & 0xc0) >> 6); break; case 4: { unsigned char c = ((r & 0x80) >> 5) | ((g & 0x80) >> 6) | ((b & 0x80) >> 7); *dstPtr = (x % 2) ? ((*dstPtr & 0xf0) | (c & 0x0f)) : ((*dstPtr & 0x0f) | ((c << 4) & 0xf0)); break; } case 1: *dstPtr = ((r|g|b) & 0x80) ? (*dstPtr | (0x80 >> (x % 8))) : (*dstPtr & ~(0x80 >> (x % 8))); break; } } return 0; } /* *---------------------------------------------------------------------- * * XChangeWindowAttributes, XSetWindowBackground, * XSetWindowBackgroundPixmap, XSetWindowBorder, XSetWindowBorderPixmap, * XSetWindowBorderWidth, XSetWindowColormap |
︙ | ︙ | |||
1100 1101 1102 1103 1104 1105 1106 | * None. * *---------------------------------------------------------------------- */ void XChangeWindowAttributes( | | | | | | | | | | | | | > | | > | < | 1129 1130 1131 1132 1133 1134 1135 1136 1137 1138 1139 1140 1141 1142 1143 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 1178 1179 1180 1181 1182 1183 1184 1185 1186 1187 1188 1189 1190 1191 1192 1193 1194 1195 1196 1197 1198 1199 1200 1201 1202 1203 1204 1205 1206 1207 1208 1209 1210 1211 1212 1213 1214 1215 1216 1217 1218 1219 | * None. * *---------------------------------------------------------------------- */ void XChangeWindowAttributes( Display *display, Window w, unsigned long value_mask, XSetWindowAttributes *attributes) { } void XSetWindowBackground( Display *display, Window window, unsigned long value) { } void XSetWindowBackgroundPixmap( Display *display, Window w, Pixmap background_pixmap) { } void XSetWindowBorder( Display *display, Window w, unsigned long border_pixel) { } void XSetWindowBorderPixmap( Display *display, Window w, Pixmap border_pixmap) { } void XSetWindowBorderWidth( Display *display, Window w, unsigned int width) { } void XSetWindowColormap( Display *display, Window w, Colormap colormap) { Debugger(); } Status XStringListToTextProperty( char **list, int count, XTextProperty *text_prop_return) { Debugger(); return (Status) 0; } void XSetWMClientMachine( Display *display, Window w, XTextProperty *text_prop) { Debugger(); } XIC XCreateIC(void) { Debugger(); return (XIC) 0; } /* *---------------------------------------------------------------------- |
︙ | ︙ | |||
1198 1199 1200 1201 1202 1203 1204 | * * Side effects: * None. * *---------------------------------------------------------------------- */ | | | | 1228 1229 1230 1231 1232 1233 1234 1235 1236 1237 1238 1239 1240 1241 1242 1243 1244 1245 | * * Side effects: * None. * *---------------------------------------------------------------------- */ const char * TkGetDefaultScreenName( Tcl_Interp *interp, /* Not used. */ const char *screenName) /* If NULL, use default string. */ { #if 0 if ((screenName == NULL) || (screenName[0] == '\0')) { screenName = macScreenName; } return screenName; #endif |
︙ | ︙ | |||
1302 1303 1304 1305 1306 1307 1308 | *---------------------------------------------------------------------- */ void Tk_ResetUserInactiveTime( Display *dpy) { | > > > > > | > > > | > > > > > > > > > > > > > > > > > > > > > > | 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 | *---------------------------------------------------------------------- */ void Tk_ResetUserInactiveTime( Display *dpy) { IOGPoint loc; kern_return_t kr; NXEvent nullEvent = {NX_NULLEVENT, {0, 0}, 0, -1, 0}; enum { kNULLEventPostThrottle = 10 }; static io_connect_t io_connection = MACH_PORT_NULL; if (io_connection == MACH_PORT_NULL) { io_service_t service = IOServiceGetMatchingService( kIOMasterPortDefault, IOServiceMatching(kIOHIDSystemClass)); if (service == MACH_PORT_NULL) { return; } kr = IOServiceOpen(service, mach_task_self(), kIOHIDParamConnectType, &io_connection); IOObjectRelease(service); if (kr != KERN_SUCCESS) { return; } } kr = IOHIDPostEvent(io_connection, NX_NULLEVENT, loc, &nullEvent.data, FALSE, 0, FALSE); } /* * Local Variables: * mode: c * c-basic-offset: 4 * fill-column: 79 * coding: utf-8 * End: */ |
Changes to macosx/ttkMacOSXTheme.c.
1 2 3 4 5 6 7 | /* * ttkMacOSXTheme.c -- * * Tk theme engine for Mac OSX, using the Appearance Manager API. * * Copyright (c) 2004 Joe English * Copyright (c) 2005 Neil Madden | | > > | 1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 | /* * ttkMacOSXTheme.c -- * * Tk theme engine for Mac OSX, using the Appearance Manager API. * * Copyright (c) 2004 Joe English * Copyright (c) 2005 Neil Madden * Copyright (c) 2006-2009 Daniel A. Steffen <[email protected]> * Copyright 2008-2009, Apple Inc. * Copyright 2009 Kevin Walzer/WordTech Communications LLC. * * See the file "license.terms" for information on usage and redistribution * of this file, and for a DISCLAIMER OF ALL WARRANTIES. * * See also: * * <URL: http://developer.apple.com/documentation/Carbon/Reference/ |
︙ | ︙ | |||
27 28 29 30 31 32 33 | * top-level window, not to the Tk_Window. BoxToRect() * accounts for this. */ #include "tkMacOSXPrivate.h" #include "ttk/ttkTheme.h" | < | | < < < < < < < < < | < < | | | | | | < < < < < < < < < < < < < < < < < < < < < < < < < < < < | 29 30 31 32 33 34 35 36 37 38 39 40 41 42 43 44 45 46 47 48 49 50 51 52 53 54 55 56 57 58 59 60 61 62 63 64 65 66 67 68 69 70 71 72 73 74 75 76 77 78 79 80 81 | * top-level window, not to the Tk_Window. BoxToRect() * accounts for this. */ #include "tkMacOSXPrivate.h" #include "ttk/ttkTheme.h" /* * Use this version in the core: */ #define BEGIN_DRAWING(d) { \ TkMacOSXDrawingContext dc; \ if (!TkMacOSXSetupDrawingContext((d), NULL, 1, &dc)) {return;} #define END_DRAWING \ TkMacOSXRestoreDrawingContext(&dc); } #define HIOrientation kHIThemeOrientationNormal #ifdef __LP64__ #define RangeToFactor(maximum) (((double) (INT_MAX >> 1)) / (maximum)) #else #define RangeToFactor(maximum) (((double) (LONG_MAX >> 1)) / (maximum)) #endif /* __LP64__ */ /*---------------------------------------------------------------------- * +++ Utilities. */ /* * BoxToRect -- * Convert a Ttk_Box in Tk coordinates relative to the given Drawable * to a native Rect relative to the containing port. */ static inline CGRect BoxToRect(Drawable d, Ttk_Box b) { MacDrawable *md = (MacDrawable*)d; CGRect rect; rect.origin.y = b.y + md->yOff; rect.origin.x = b.x + md->xOff; rect.size.height = b.height; rect.size.width = b.width; return rect; } /* * Table mapping Tk states to Appearance manager ThemeStates */ static Ttk_StateTable ThemeStateTable[] = { {kThemeStateUnavailable, TTK_STATE_DISABLED, 0}, {kThemeStatePressed, TTK_STATE_PRESSED, 0}, |
︙ | ︙ | |||
141 142 143 144 145 146 147 | static Ttk_Padding ButtonMargins = {2,2,2,2}; #define NoThemeMetric 0xFFFFFFFF typedef struct { ThemeButtonKind kind; ThemeMetric heightMetric; | | | | | | | | | | | | | | | | > | | > | | | | | | | | | | | | | | < | > | > > > > > | | | | | | | > > > > > > > > > > > > > > > > < > > > > > > | | > > > | > > > > > > > > > > > | > > > | > > > > > > > > | | | > > | > > > > > > | | < | | > > | > > > > > > > | | 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 129 130 131 132 133 134 135 136 137 138 139 140 141 142 143 144 145 146 147 148 149 150 151 152 153 154 155 156 157 158 159 160 161 162 163 164 165 166 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 224 225 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 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 284 285 286 287 288 289 290 291 292 293 294 295 296 297 298 299 300 301 302 303 304 305 306 307 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 338 339 340 341 342 343 344 345 346 347 348 349 350 351 352 353 354 355 356 357 358 359 360 361 362 363 364 365 366 367 368 369 370 | static Ttk_Padding ButtonMargins = {2,2,2,2}; #define NoThemeMetric 0xFFFFFFFF typedef struct { ThemeButtonKind kind; ThemeMetric heightMetric; } ThemeButtonParams; static ThemeButtonParams PushButtonParams = { kThemePushButton, kThemeMetricPushButtonHeight }, CheckBoxParams = { kThemeCheckBox, kThemeMetricCheckBoxHeight }, RadioButtonParams = { kThemeRadioButton, kThemeMetricRadioButtonHeight }, BevelButtonParams = { kThemeBevelButton, NoThemeMetric }, PopupButtonParams = { kThemePopupButton, kThemeMetricPopupButtonHeight }, DisclosureParams = { kThemeDisclosureButton, kThemeMetricDisclosureTriangleHeight }, ListHeaderParams = { kThemeListHeaderButton, kThemeMetricListHeaderHeight }; static Ttk_StateTable ButtonValueTable[] = { { kThemeButtonMixed, TTK_STATE_ALTERNATE, 0 }, { kThemeButtonOn, TTK_STATE_SELECTED, 0 }, { kThemeButtonOff, 0, 0 } /* Others: kThemeDisclosureRight, kThemeDisclosureDown, kThemeDisclosureLeft */ }; static Ttk_StateTable ButtonAdornmentTable[] = { { kThemeAdornmentDefault| kThemeAdornmentFocus, TTK_STATE_ALTERNATE| TTK_STATE_FOCUS, 0 }, { kThemeAdornmentDefault, TTK_STATE_ALTERNATE, 0 }, { kThemeAdornmentFocus, TTK_STATE_FOCUS, 0 }, { kThemeAdornmentNone, 0, 0 } }; /* * computeButtonDrawInfo -- * Fill in an appearance manager HIThemeButtonDrawInfo record. */ static inline HIThemeButtonDrawInfo computeButtonDrawInfo( ThemeButtonParams *params, Ttk_State state) { const HIThemeButtonDrawInfo info = { .version = 0, .state = Ttk_StateTableLookup(ThemeStateTable, state), .kind = params ? params->kind : 0, .value = Ttk_StateTableLookup(ButtonValueTable, state), .adornment = Ttk_StateTableLookup(ButtonAdornmentTable, state), }; return info; } static void ButtonElementSizeNoPadding( void *clientData, void *elementRecord, Tk_Window tkwin, int *widthPtr, int *heightPtr, Ttk_Padding *paddingPtr) { ThemeButtonParams *params = clientData; if (params->heightMetric != NoThemeMetric) { SInt32 height; ChkErr(GetThemeMetric, params->heightMetric, &height); *heightPtr = height; } } static void ButtonElementSize( void *clientData, void *elementRecord, Tk_Window tkwin, int *widthPtr, int *heightPtr, Ttk_Padding *paddingPtr) { ThemeButtonParams *params = clientData; const HIThemeButtonDrawInfo info = computeButtonDrawInfo(params, 0); static const CGRect scratchBounds = {{0, 0}, {100, 100}}; CGRect contentBounds; ButtonElementSizeNoPadding( clientData, elementRecord, tkwin, widthPtr, heightPtr, paddingPtr); /* * To compute internal padding, query the appearance manager * for the content bounds of a dummy rectangle, then use * the difference as the padding. */ ChkErr(HIThemeGetButtonContentBounds, &scratchBounds, &info, &contentBounds); paddingPtr->left = CGRectGetMinX(contentBounds); paddingPtr->top = CGRectGetMinY(contentBounds); paddingPtr->right = CGRectGetMaxX(scratchBounds) - CGRectGetMaxX(contentBounds) + 1; paddingPtr->bottom = CGRectGetMaxY(scratchBounds) - CGRectGetMaxY(contentBounds); /* * Now add a little extra padding to account for drop shadows. * @@@ SHOULD: call GetThemeButtonBackgroundBounds() instead. */ *paddingPtr = Ttk_AddPadding(*paddingPtr, ButtonMargins); *widthPtr += Ttk_PaddingWidth(ButtonMargins); *heightPtr += Ttk_PaddingHeight(ButtonMargins); } static void ButtonElementDraw( void *clientData, void *elementRecord, Tk_Window tkwin, Drawable d, Ttk_Box b, Ttk_State state) { ThemeButtonParams *params = clientData; CGRect bounds = BoxToRect(d, Ttk_PadBox(b, ButtonMargins)); const HIThemeButtonDrawInfo info = computeButtonDrawInfo(params, state); BEGIN_DRAWING(d) ChkErr(HIThemeDrawButton, &bounds, &info, dc.context, HIOrientation, NULL); END_DRAWING } static Ttk_ElementSpec ButtonElementSpec = { TK_STYLE_VERSION_2, sizeof(NullElement), TtkNullElementOptions, ButtonElementSize, ButtonElementDraw }; /*---------------------------------------------------------------------- * +++ Notebook elements. */ /* Tab position logic, c.f. ttkNotebook.c TabState() */ #define TTK_STATE_NOTEBOOK_FIRST TTK_STATE_USER1 #define TTK_STATE_NOTEBOOK_LAST TTK_STATE_USER2 static Ttk_StateTable TabStyleTable[] = { { kThemeTabFrontInactive, TTK_STATE_SELECTED|TTK_STATE_BACKGROUND}, { kThemeTabNonFrontInactive, TTK_STATE_BACKGROUND}, { kThemeTabFrontUnavailable, TTK_STATE_DISABLED|TTK_STATE_SELECTED}, { kThemeTabNonFrontUnavailable, TTK_STATE_DISABLED}, { kThemeTabFront, TTK_STATE_SELECTED}, { kThemeTabNonFrontPressed, TTK_STATE_PRESSED}, { kThemeTabNonFront, 0} }; static Ttk_StateTable TabAdornmentTable[] = { { kHIThemeTabAdornmentNone, TTK_STATE_NOTEBOOK_FIRST|TTK_STATE_NOTEBOOK_LAST}, {kHIThemeTabAdornmentTrailingSeparator, TTK_STATE_NOTEBOOK_FIRST}, {kHIThemeTabAdornmentNone, TTK_STATE_NOTEBOOK_LAST}, {kHIThemeTabAdornmentTrailingSeparator, 0 }, }; static Ttk_StateTable TabPositionTable[] = { { kHIThemeTabPositionOnly, TTK_STATE_NOTEBOOK_FIRST|TTK_STATE_NOTEBOOK_LAST}, { kHIThemeTabPositionFirst, TTK_STATE_NOTEBOOK_FIRST}, { kHIThemeTabPositionLast, TTK_STATE_NOTEBOOK_LAST}, { kHIThemeTabPositionMiddle, 0 }, }; /* * Apple XHIG Tab View Specifications: * * Control sizes: Tab views are available in regular, small, and mini sizes. * The tab height is fixed for each size, but you control the size of the pane * area. The tab heights for each size are listed below: * - Regular size: 20 pixels. * - Small: 17 pixels. * - Mini: 15 pixels. * * Label spacing and fonts: The tab labels should be in a font that’s * proportional to the size of the tab view control. In addition, the label * should be placed so that there are equal margins of space before and after * it. The guidelines below provide the specifications you should use for tab * labels: * - Regular size: System font. Center in tab, leaving 12 pixels on each side. * - Small: Small system font. Center in tab, leaving 10 pixels on each side. * - Mini: Mini system font. Center in tab, leaving 8 pixels on each side. * * Control spacing: Whether you decide to inset a tab view in a window or * extend its edges to the window sides and bottom, you should place the top * edge of the tab view 12 or 14 pixels below the bottom edge of the title bar * (or toolbar, if there is one). If you choose to inset a tab view in a * window, you should leave a margin of 20 pixels between the sides and bottom * of the tab view and the sides and bottom of the window (although 16 pixels * is also an acceptable margin-width). If you need to provide controls below * the tab view, leave enough space below the tab view so the controls are 20 * pixels above the bottom edge of the window and 12 pixels between the tab * view and the controls. * If you choose to extend the tab view sides and bottom so that they meet the * window sides and bottom, you should leave a margin of at least 20 pixels * between the content in the tab view and the tab-view edges. * * <URL: http://developer.apple.com/documentation/userexperience/Conceptual/ * AppleHIGuidelines/XHIGControls/XHIGControls.html#//apple_ref/doc/uid/ * TP30000359-TPXREF116> */ static const int TAB_HEIGHT = 10; static const int TAB_OVERLAP = 10; static void TabElementSize( void *clientData, void *elementRecord, Tk_Window tkwin, int *widthPtr, int *heightPtr, Ttk_Padding *paddingPtr) { *heightPtr = TAB_HEIGHT + TAB_OVERLAP - 1; } static void TabElementDraw( void *clientData, void *elementRecord, Tk_Window tkwin, Drawable d, Ttk_Box b, Ttk_State state) { CGRect bounds = BoxToRect(d, b); HIThemeTabDrawInfo info = { .version = 1, .style = Ttk_StateTableLookup(TabStyleTable, state), .direction = kThemeTabNorth, .size = kHIThemeTabSizeNormal, .adornment = Ttk_StateTableLookup(TabAdornmentTable, state), .kind = kHIThemeTabKindNormal, .position = Ttk_StateTableLookup(TabPositionTable, state), }; bounds.size.height += TAB_OVERLAP; BEGIN_DRAWING(d) ChkErr(HIThemeDrawTab, &bounds, &info, dc.context, HIOrientation, NULL); END_DRAWING } static Ttk_ElementSpec TabElementSpec = { TK_STYLE_VERSION_2, sizeof(NullElement), TtkNullElementOptions, TabElementSize, TabElementDraw }; /* * Notebook panes: */ static void PaneElementSize( void *clientData, void *elementRecord, Tk_Window tkwin, int *widthPtr, int *heightPtr, Ttk_Padding *paddingPtr) { *paddingPtr = Ttk_MakePadding(9, 5, 9, 9); } static void PaneElementDraw( void *clientData, void *elementRecord, Tk_Window tkwin, Drawable d, Ttk_Box b, Ttk_State state) { CGRect bounds = BoxToRect(d, b); HIThemeTabPaneDrawInfo info = { .version = 1, .state = Ttk_StateTableLookup(ThemeStateTable, state), .direction = kThemeTabNorth, .size = kHIThemeTabSizeNormal, .kind = kHIThemeTabKindNormal, .adornment = kHIThemeTabPaneAdornmentNormal, }; bounds.origin.y -= TAB_OVERLAP; bounds.size.height += TAB_OVERLAP; BEGIN_DRAWING(d) ChkErr(HIThemeDrawTabPane, &bounds, &info, dc.context, HIOrientation); END_DRAWING } static Ttk_ElementSpec PaneElementSpec = { TK_STYLE_VERSION_2, sizeof(NullElement), TtkNullElementOptions, |
︙ | ︙ | |||
358 359 360 361 362 363 364 | *paddingPtr = Ttk_UniformPadding(4); } static void GroupElementDraw( void *clientData, void *elementRecord, Tk_Window tkwin, Drawable d, Ttk_Box b, Ttk_State state) { | | > > | > > | | 389 390 391 392 393 394 395 396 397 398 399 400 401 402 403 404 405 406 407 408 409 410 411 | *paddingPtr = Ttk_UniformPadding(4); } static void GroupElementDraw( void *clientData, void *elementRecord, Tk_Window tkwin, Drawable d, Ttk_Box b, Ttk_State state) { CGRect bounds = BoxToRect(d, b); const HIThemeGroupBoxDrawInfo info = { .version = 0, .state = Ttk_StateTableLookup(ThemeStateTable, state), .kind = kHIThemeGroupBoxKindPrimaryOpaque, }; BEGIN_DRAWING(d) ChkErr(HIThemeDrawGroupBox, &bounds, &info, dc.context, HIOrientation); END_DRAWING } static Ttk_ElementSpec GroupElementSpec = { TK_STYLE_VERSION_2, sizeof(NullElement), TtkNullElementOptions, |
︙ | ︙ | |||
404 405 406 407 408 409 410 | static void EntryElementDraw( void *clientData, void *elementRecord, Tk_Window tkwin, Drawable d, Ttk_Box b, Ttk_State state) { EntryElement *e = elementRecord; Tk_3DBorder backgroundPtr = Tk_Get3DBorderFromObj(tkwin,e->backgroundObj); Ttk_Box inner = Ttk_PadBox(b, Ttk_UniformPadding(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 | static void EntryElementDraw( void *clientData, void *elementRecord, Tk_Window tkwin, Drawable d, Ttk_Box b, Ttk_State state) { EntryElement *e = elementRecord; Tk_3DBorder backgroundPtr = Tk_Get3DBorderFromObj(tkwin,e->backgroundObj); Ttk_Box inner = Ttk_PadBox(b, Ttk_UniformPadding(3)); CGRect bounds = BoxToRect(d, inner); const HIThemeFrameDrawInfo info = { .version = 0, .kind = kHIThemeFrameTextFieldSquare, .state = Ttk_StateTableLookup(ThemeStateTable, state), .isFocused = state & TTK_STATE_FOCUS, }; /* * Erase w/background color: */ XFillRectangle(Tk_Display(tkwin), d, Tk_3DBorderGC(tkwin, backgroundPtr, TK_3D_FLAT_GC), inner.x,inner.y, inner.width, inner.height); BEGIN_DRAWING(d) ChkErr(HIThemeDrawFrame, &bounds, &info, dc.context, HIOrientation); /*if (state & TTK_STATE_FOCUS) { ChkErr(DrawThemeFocusRect, &bounds, 1); }*/ END_DRAWING } static Ttk_ElementSpec EntryElementSpec = { TK_STYLE_VERSION_2, sizeof(EntryElement), EntryElementOptions, |
︙ | ︙ | |||
454 455 456 457 458 459 460 | *paddingPtr = Ttk_AddPadding(ComboboxMargins, ComboboxPadding); } static void ComboboxElementDraw( void *clientData, void *elementRecord, Tk_Window tkwin, Drawable d, Ttk_Box b, Ttk_State state) { | < < | > > > > > > > | < | 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 | *paddingPtr = Ttk_AddPadding(ComboboxMargins, ComboboxPadding); } static void ComboboxElementDraw( void *clientData, void *elementRecord, Tk_Window tkwin, Drawable d, Ttk_Box b, Ttk_State state) { CGRect bounds = BoxToRect(d, Ttk_PadBox(b, ComboboxMargins)); const HIThemeButtonDrawInfo info = { .version = 0, .state = Ttk_StateTableLookup(ThemeStateTable, state), .kind = kThemeComboBox, .value = Ttk_StateTableLookup(ButtonValueTable, state), .adornment = Ttk_StateTableLookup(ButtonAdornmentTable, state), }; BEGIN_DRAWING(d) ChkErr(HIThemeDrawButton, &bounds, &info, dc.context, HIOrientation, NULL); END_DRAWING } static Ttk_ElementSpec ComboboxElementSpec = { TK_STYLE_VERSION_2, sizeof(NullElement), TtkNullElementOptions, |
︙ | ︙ | |||
497 498 499 500 501 502 503 | *heightPtr = s + Ttk_PaddingHeight(SpinbuttonMargins); } static void SpinButtonElementDraw( void *clientData, void *elementRecord, Tk_Window tkwin, Drawable d, Ttk_Box b, Ttk_State state) { | | < < > > | < > | | > | < | 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 | *heightPtr = s + Ttk_PaddingHeight(SpinbuttonMargins); } static void SpinButtonElementDraw( void *clientData, void *elementRecord, Tk_Window tkwin, Drawable d, Ttk_Box b, Ttk_State state) { CGRect bounds = BoxToRect(d, Ttk_PadBox(b, SpinbuttonMargins)); /* @@@ can't currently distinguish PressedUp (== Pressed) from PressedDown; * ignore this bit for now [see #2219588] */ const HIThemeButtonDrawInfo info = { .version = 0, .state = Ttk_StateTableLookup(ThemeStateTable, state & ~TTK_STATE_PRESSED), .kind = kThemeIncDecButton, .value = Ttk_StateTableLookup(ButtonValueTable, state), .adornment = kThemeAdornmentNone, }; BEGIN_DRAWING(d) ChkErr(HIThemeDrawButton, &bounds, &info, dc.context, HIOrientation, NULL); END_DRAWING } static Ttk_ElementSpec SpinButtonElementSpec = { TK_STYLE_VERSION_2, sizeof(NullElement), TtkNullElementOptions, |
︙ | ︙ | |||
576 577 578 579 580 581 582 | static void TrackElementDraw( void *clientData, void *elementRecord, Tk_Window tkwin, Drawable d, Ttk_Box b, Ttk_State state) { TrackElementData *data = clientData; TrackElement *elem = elementRecord; | < < > > < > > | | | | | | | | < | > > < < < < | | > | < < | | 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 | static void TrackElementDraw( void *clientData, void *elementRecord, Tk_Window tkwin, Drawable d, Ttk_Box b, Ttk_State state) { TrackElementData *data = clientData; TrackElement *elem = elementRecord; int orientation = TTK_ORIENT_HORIZONTAL; double from = 0, to = 100, value = 0, factor; Ttk_GetOrientFromObj(NULL, elem->orientObj, &orientation); Tcl_GetDoubleFromObj(NULL, elem->fromObj, &from); Tcl_GetDoubleFromObj(NULL, elem->toObj, &to); Tcl_GetDoubleFromObj(NULL, elem->valueObj, &value); factor = RangeToFactor(to - from); HIThemeTrackDrawInfo info = { .version = 0, .kind = data->kind, .bounds = BoxToRect(d, b), .min = from * factor, .max = to * factor, .value = value * factor, .attributes = kThemeTrackShowThumb | (orientation == TTK_ORIENT_HORIZONTAL ? kThemeTrackHorizontal : 0), .enableState = Ttk_StateTableLookup(ThemeTrackEnableTable, state), .trackInfo.progress.phase = 0, }; if (info.kind == kThemeSlider) { info.trackInfo.slider.pressState = state & TTK_STATE_PRESSED ? kThemeThumbPressed : 0; info.trackInfo.slider.thumbDir = kThemeThumbPlain; } BEGIN_DRAWING(d) ChkErr(HIThemeDrawTrack, &info, NULL, dc.context, HIOrientation); END_DRAWING } static Ttk_ElementSpec TrackElementSpec = { TK_STYLE_VERSION_2, sizeof(TrackElement), TrackElementOptions, |
︙ | ︙ | |||
691 692 693 694 695 696 697 | } static void PbarElementDraw( void *clientData, void *elementRecord, Tk_Window tkwin, Drawable d, Ttk_Box b, Ttk_State state) { PbarElement *pbar = elementRecord; | | < < > > | | < < < | | | | > | | < | | > | | 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 | } static void PbarElementDraw( void *clientData, void *elementRecord, Tk_Window tkwin, Drawable d, Ttk_Box b, Ttk_State state) { PbarElement *pbar = elementRecord; int orientation = TTK_ORIENT_HORIZONTAL, phase = 0; double value = 0, maximum = 100, factor; Ttk_GetOrientFromObj(NULL, pbar->orientObj, &orientation); Tcl_GetDoubleFromObj(NULL, pbar->valueObj, &value); Tcl_GetDoubleFromObj(NULL, pbar->maximumObj, &maximum); Tcl_GetIntFromObj(NULL, pbar->phaseObj, &phase); factor = RangeToFactor(maximum); HIThemeTrackDrawInfo info = { .version = 0, .kind = (!strcmp("indeterminate", Tcl_GetString(pbar->modeObj)) && value) ? kThemeIndeterminateBar : kThemeProgressBar, .bounds = BoxToRect(d, b), .min = 0, .max = maximum * factor, .value = value * factor, .attributes = kThemeTrackShowThumb | (orientation == TTK_ORIENT_HORIZONTAL ? kThemeTrackHorizontal : 0), .enableState = Ttk_StateTableLookup(ThemeTrackEnableTable, state), .trackInfo.progress.phase = phase, }; BEGIN_DRAWING(d) ChkErr(HIThemeDrawTrack, &info, NULL, dc.context, HIOrientation); END_DRAWING } static Ttk_ElementSpec PbarElementSpec = { TK_STYLE_VERSION_2, sizeof(PbarElement), PbarElementOptions, |
︙ | ︙ | |||
749 750 751 752 753 754 755 | *widthPtr = *heightPtr = 1; } static void SeparatorElementDraw( void *clientData, void *elementRecord, Tk_Window tkwin, Drawable d, Ttk_Box b, unsigned int state) { | | | | < | < < | > > | | 788 789 790 791 792 793 794 795 796 797 798 799 800 801 802 803 804 805 806 807 808 809 810 | *widthPtr = *heightPtr = 1; } static void SeparatorElementDraw( void *clientData, void *elementRecord, Tk_Window tkwin, Drawable d, Ttk_Box b, unsigned int state) { CGRect bounds = BoxToRect(d, b); const HIThemeSeparatorDrawInfo info = { .version = 0, /* Separator only supports kThemeStateActive, kThemeStateInactive */ .state = Ttk_StateTableLookup(ThemeStateTable, state & TTK_STATE_BACKGROUND), }; BEGIN_DRAWING(d) ChkErr(HIThemeDrawSeparator, &bounds, &info, dc.context, HIOrientation); END_DRAWING } static Ttk_ElementSpec SeparatorElementSpec = { TK_STYLE_VERSION_2, sizeof(NullElement), TtkNullElementOptions, |
︙ | ︙ | |||
780 781 782 783 784 785 786 | static const ThemeGrowDirection sizegripGrowDirection = kThemeGrowRight|kThemeGrowDown; static void SizegripElementSize( void *clientData, void *elementRecord, Tk_Window tkwin, int *widthPtr, int *heightPtr, Ttk_Padding *paddingPtr) { | > | > > > > > | | < | | | | | | | > > > > | < < | 818 819 820 821 822 823 824 825 826 827 828 829 830 831 832 833 834 835 836 837 838 839 840 841 842 843 844 845 846 847 848 849 850 851 852 853 854 855 856 857 858 859 860 861 | static const ThemeGrowDirection sizegripGrowDirection = kThemeGrowRight|kThemeGrowDown; static void SizegripElementSize( void *clientData, void *elementRecord, Tk_Window tkwin, int *widthPtr, int *heightPtr, Ttk_Padding *paddingPtr) { HIThemeGrowBoxDrawInfo info = { .version = 0, .state = kThemeStateActive, .kind = kHIThemeGrowBoxKindNormal, .direction = sizegripGrowDirection, .size = kHIThemeGrowBoxSizeNormal, }; CGRect bounds = CGRectZero; ChkErr(HIThemeGetGrowBoxBounds, &bounds.origin, &info, &bounds); *widthPtr = bounds.size.width; *heightPtr = bounds.size.height; } static void SizegripElementDraw( void *clientData, void *elementRecord, Tk_Window tkwin, Drawable d, Ttk_Box b, unsigned int state) { CGRect bounds = BoxToRect(d, b); HIThemeGrowBoxDrawInfo info = { .version = 0, /* Grow box only supports kThemeStateActive, kThemeStateInactive */ .state = Ttk_StateTableLookup(ThemeStateTable, state & TTK_STATE_BACKGROUND), .kind = kHIThemeGrowBoxKindNormal, .direction = sizegripGrowDirection, .size = kHIThemeGrowBoxSizeNormal, }; BEGIN_DRAWING(d) ChkErr(HIThemeDrawGrowBox, &bounds.origin, &info, dc.context, HIOrientation); END_DRAWING } static Ttk_ElementSpec SizegripElementSpec = { TK_STYLE_VERSION_2, sizeof(NullElement), TtkNullElementOptions, |
︙ | ︙ | |||
830 831 832 833 834 835 836 | * off-screen graphics port this leads to alignment glitches. */ static void FillElementDraw( void *clientData, void *elementRecord, Tk_Window tkwin, Drawable d, Ttk_Box b, Ttk_State state) { | | | | | | 875 876 877 878 879 880 881 882 883 884 885 886 887 888 889 890 891 892 893 894 895 896 897 | * off-screen graphics port this leads to alignment glitches. */ static void FillElementDraw( void *clientData, void *elementRecord, Tk_Window tkwin, Drawable d, Ttk_Box b, Ttk_State state) { CGRect bounds = BoxToRect(d, b); ThemeBrush brush = (state & TTK_STATE_BACKGROUND) ? kThemeBrushModelessDialogBackgroundInactive : kThemeBrushModelessDialogBackgroundActive; BEGIN_DRAWING(d) ChkErr(HIThemeSetFill, brush, NULL, dc.context, HIOrientation); //QDSetPatternOrigin(PatternOrigin(tkwin, d)); CGContextFillRect(dc.context, bounds); END_DRAWING } static void BackgroundElementDraw( void *clientData, void *elementRecord, Tk_Window tkwin, Drawable d, Ttk_Box b, unsigned int state) { |
︙ | ︙ | |||
885 886 887 888 889 890 891 | * */ static void ToolbarBackgroundElementDraw( void *clientData, void *elementRecord, Tk_Window tkwin, Drawable d, Ttk_Box b, Ttk_State state) { ThemeBrush brush = kThemeBrushToolbarBackground; | | | | | > > > > > > | > > > > > | | | | | | | > | | > | | | | 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 | * */ static void ToolbarBackgroundElementDraw( void *clientData, void *elementRecord, Tk_Window tkwin, Drawable d, Ttk_Box b, Ttk_State state) { ThemeBrush brush = kThemeBrushToolbarBackground; CGRect bounds = BoxToRect(d, Ttk_WinBox(tkwin)); BEGIN_DRAWING(d) ChkErr(HIThemeSetFill, brush, NULL, dc.context, HIOrientation); //QDSetPatternOrigin(PatternOrigin(tkwin, d)); CGContextFillRect(dc.context, bounds); END_DRAWING } static Ttk_ElementSpec ToolbarBackgroundElementSpec = { TK_STYLE_VERSION_2, sizeof(NullElement), TtkNullElementOptions, TtkNullElementSize, ToolbarBackgroundElementDraw }; /*---------------------------------------------------------------------- * +++ Treeview header * Redefine the header to use a kThemeListHeaderButton. */ #define TTK_TREEVIEW_STATE_SORTARROW TTK_STATE_USER1 static Ttk_StateTable TreeHeaderValueTable[] = { { kThemeButtonOn, TTK_STATE_ALTERNATE}, { kThemeButtonOn, TTK_STATE_SELECTED}, { kThemeButtonOff, 0} }; static Ttk_StateTable TreeHeaderAdornmentTable[] = { { kThemeAdornmentHeaderButtonSortUp, TTK_STATE_ALTERNATE|TTK_TREEVIEW_STATE_SORTARROW}, { kThemeAdornmentDefault, TTK_STATE_SELECTED|TTK_TREEVIEW_STATE_SORTARROW}, { kThemeAdornmentHeaderButtonNoSortArrow, TTK_STATE_ALTERNATE}, { kThemeAdornmentHeaderButtonNoSortArrow, TTK_STATE_SELECTED}, { kThemeAdornmentFocus, TTK_STATE_FOCUS}, { kThemeAdornmentNone, 0} }; static void TreeHeaderElementDraw( void *clientData, void *elementRecord, Tk_Window tkwin, Drawable d, Ttk_Box b, Ttk_State state) { ThemeButtonParams *params = clientData; CGRect bounds = BoxToRect(d, b); const HIThemeButtonDrawInfo info = { .version = 0, .state = Ttk_StateTableLookup(ThemeStateTable, state), .kind = params->kind, .value = Ttk_StateTableLookup(TreeHeaderValueTable, state), .adornment = Ttk_StateTableLookup(TreeHeaderAdornmentTable, state), }; BEGIN_DRAWING(d) ChkErr(HIThemeDrawButton, &bounds, &info, dc.context, HIOrientation, NULL); END_DRAWING } static Ttk_ElementSpec TreeHeaderElementSpec = { TK_STYLE_VERSION_2, sizeof(NullElement), TtkNullElementOptions, ButtonElementSizeNoPadding, TreeHeaderElementDraw }; /* * Disclosure triangle: */ #define TTK_TREEVIEW_STATE_OPEN TTK_STATE_USER1 #define TTK_TREEVIEW_STATE_LEAF TTK_STATE_USER2 static Ttk_StateTable DisclosureValueTable[] = { { kThemeDisclosureDown, TTK_TREEVIEW_STATE_OPEN, 0 }, { kThemeDisclosureRight, 0, 0 }, }; static void DisclosureElementSize( void *clientData, void *elementRecord, Tk_Window tkwin, |
︙ | ︙ | |||
964 965 966 967 968 969 970 | *heightPtr = s; } static void DisclosureElementDraw( void *clientData, void *elementRecord, Tk_Window tkwin, Drawable d, Ttk_Box b, Ttk_State state) { | > | | | < < < < | > | | > | | < | > | 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 1048 1049 | *heightPtr = s; } static void DisclosureElementDraw( void *clientData, void *elementRecord, Tk_Window tkwin, Drawable d, Ttk_Box b, Ttk_State state) { if (!(state & TTK_TREEVIEW_STATE_LEAF)) { CGRect bounds = BoxToRect(d, b); const HIThemeButtonDrawInfo info = { .version = 0, .state = Ttk_StateTableLookup(ThemeStateTable, state), .kind = kThemeDisclosureTriangle, .value = Ttk_StateTableLookup(DisclosureValueTable, state), .adornment = kThemeAdornmentDrawIndicatorOnly, }; BEGIN_DRAWING(d) ChkErr(HIThemeDrawButton, &bounds, &info, dc.context, HIOrientation, NULL); END_DRAWING } } static Ttk_ElementSpec DisclosureElementSpec = { TK_STYLE_VERSION_2, sizeof(NullElement), TtkNullElementOptions, DisclosureElementSize, |
︙ | ︙ | |||
1074 1075 1076 1077 1078 1079 1080 | */ Ttk_RegisterElementSpec(themePtr, "background", &BackgroundElementSpec, 0); Ttk_RegisterElementSpec(themePtr, "fill", &FillElementSpec, 0); Ttk_RegisterElementSpec(themePtr, "Toolbar.background", &ToolbarBackgroundElementSpec, 0); Ttk_RegisterElementSpec(themePtr, "Button.button", | | | | | | | | | 1131 1132 1133 1134 1135 1136 1137 1138 1139 1140 1141 1142 1143 1144 1145 1146 1147 1148 1149 1150 1151 1152 1153 1154 1155 1156 1157 1158 1159 1160 1161 | */ Ttk_RegisterElementSpec(themePtr, "background", &BackgroundElementSpec, 0); Ttk_RegisterElementSpec(themePtr, "fill", &FillElementSpec, 0); Ttk_RegisterElementSpec(themePtr, "Toolbar.background", &ToolbarBackgroundElementSpec, 0); Ttk_RegisterElementSpec(themePtr, "Button.button", &ButtonElementSpec, &PushButtonParams); Ttk_RegisterElementSpec(themePtr, "Checkbutton.button", &ButtonElementSpec, &CheckBoxParams); Ttk_RegisterElementSpec(themePtr, "Radiobutton.button", &ButtonElementSpec, &RadioButtonParams); Ttk_RegisterElementSpec(themePtr, "Toolbutton.border", &ButtonElementSpec, &BevelButtonParams); Ttk_RegisterElementSpec(themePtr, "Menubutton.button", &ButtonElementSpec, &PopupButtonParams); Ttk_RegisterElementSpec(themePtr, "Spinbox.spinbutton", &SpinButtonElementSpec, 0); Ttk_RegisterElementSpec(themePtr, "Combobox.button", &ComboboxElementSpec, 0); Ttk_RegisterElementSpec(themePtr, "Treeitem.indicator", &DisclosureElementSpec, &DisclosureParams); Ttk_RegisterElementSpec(themePtr, "Treeheading.cell", &TreeHeaderElementSpec, &ListHeaderParams); Ttk_RegisterElementSpec(themePtr, "Notebook.tab", &TabElementSpec, 0); Ttk_RegisterElementSpec(themePtr, "Notebook.client", &PaneElementSpec, 0); Ttk_RegisterElementSpec(themePtr, "Labelframe.border",&GroupElementSpec,0); Ttk_RegisterElementSpec(themePtr, "Entry.field",&EntryElementSpec,0); Ttk_RegisterElementSpec(themePtr, "Spinbox.field",&EntryElementSpec,0); |
︙ | ︙ | |||
1130 1131 1132 1133 1134 1135 1136 | } MODULE_SCOPE int Ttk_MacOSXPlatformInit(Tcl_Interp *interp) { return AquaTheme_Init(interp); } | | > > > > > > > > > | 1187 1188 1189 1190 1191 1192 1193 1194 1195 1196 1197 1198 1199 1200 1201 1202 1203 | } MODULE_SCOPE int Ttk_MacOSXPlatformInit(Tcl_Interp *interp) { return AquaTheme_Init(interp); } /* * Local Variables: * mode: c * c-basic-offset: 4 * fill-column: 79 * coding: utf-8 * End: */ |
Changes to unix/Makefile.in.
︙ | ︙ | |||
280 281 282 283 284 285 286 | # with cc, and the second is for use when running ld directly. CC_SEARCH_FLAGS = @CC_SEARCH_FLAGS@ LD_SEARCH_FLAGS = @LD_SEARCH_FLAGS@ # support for embedded libraries on Darwin / Mac OS X DYLIB_INSTALL_DIR = ${LIB_RUNTIME_DIR} | < < < < < < | 280 281 282 283 284 285 286 287 288 289 290 291 292 293 | # with cc, and the second is for use when running ld directly. CC_SEARCH_FLAGS = @CC_SEARCH_FLAGS@ LD_SEARCH_FLAGS = @LD_SEARCH_FLAGS@ # support for embedded libraries on Darwin / Mac OS X DYLIB_INSTALL_DIR = ${LIB_RUNTIME_DIR} # support for Xft: XFT_CFLAGS = @XFT_CFLAGS@ XFT_LIBS = @XFT_LIBS@ #---------------------------------------------------------------- # The information below is modified by the configure script when # Makefile is generated from Makefile.in. You shouldn't normally |
︙ | ︙ | |||
392 393 394 395 396 397 398 | tkMacOSXColor.o tkMacOSXConfig.o tkMacOSXCursor.o tkMacOSXDebug.o \ tkMacOSXDialog.o tkMacOSXDraw.o tkMacOSXEmbed.o tkMacOSXEntry.o \ tkMacOSXEvent.o tkMacOSXFont.o tkMacOSXHLEvents.o tkMacOSXInit.o \ tkMacOSXKeyboard.o tkMacOSXKeyEvent.o tkMacOSXMenu.o \ tkMacOSXMenubutton.o tkMacOSXMenus.o tkMacOSXMouseEvent.o \ tkMacOSXNotify.o tkMacOSXRegion.o tkMacOSXScrlbr.o tkMacOSXSend.o \ tkMacOSXSubwindows.o tkMacOSXWindowEvent.o \ | | | 386 387 388 389 390 391 392 393 394 395 396 397 398 399 400 | tkMacOSXColor.o tkMacOSXConfig.o tkMacOSXCursor.o tkMacOSXDebug.o \ tkMacOSXDialog.o tkMacOSXDraw.o tkMacOSXEmbed.o tkMacOSXEntry.o \ tkMacOSXEvent.o tkMacOSXFont.o tkMacOSXHLEvents.o tkMacOSXInit.o \ tkMacOSXKeyboard.o tkMacOSXKeyEvent.o tkMacOSXMenu.o \ tkMacOSXMenubutton.o tkMacOSXMenus.o tkMacOSXMouseEvent.o \ tkMacOSXNotify.o tkMacOSXRegion.o tkMacOSXScrlbr.o tkMacOSXSend.o \ tkMacOSXSubwindows.o tkMacOSXWindowEvent.o \ tkMacOSXWm.o tkMacOSXXStubs.o \ tkFileFilter.o tkMacWinMenu.o tkPointer.o tkUnix3d.o tkUnixScale.o \ xcolors.o xdraw.o xgc.o ximage.o xutil.o \ ttkMacOSXTheme.o AQUA_TKTEST_OBJS = tkMacOSXTest.o OBJS = $(GENERIC_OBJS) $(WIDG_OBJS) $(CANV_OBJS) $(IMAGE_OBJS) $(TEXT_OBJS) \ |
︙ | ︙ | |||
518 519 520 521 522 523 524 | $(MAC_OSX_DIR)/tkMacOSXKeyEvent.c $(MAC_OSX_DIR)/tkMacOSXMenu.c \ $(MAC_OSX_DIR)/tkMacOSXMenubutton.c $(MAC_OSX_DIR)/tkMacOSXMenus.c \ $(MAC_OSX_DIR)/tkMacOSXMouseEvent.c $(MAC_OSX_DIR)/tkMacOSXNotify.c \ $(MAC_OSX_DIR)/tkMacOSXRegion.c $(MAC_OSX_DIR)/tkMacOSXScrlbr.c \ $(MAC_OSX_DIR)/tkMacOSXSend.c $(MAC_OSX_DIR)/tkMacOSXSubwindows.c \ $(MAC_OSX_DIR)/tkMacOSXTest.c $(MAC_OSX_DIR)/tkMacOSXWindowEvent.c \ $(MAC_OSX_DIR)/tkMacOSXWm.c $(MAC_OSX_DIR)/tkMacOSXXStubs.c \ | < < < < < < < | 512 513 514 515 516 517 518 519 520 521 522 523 524 525 526 527 528 529 530 531 532 533 | $(MAC_OSX_DIR)/tkMacOSXKeyEvent.c $(MAC_OSX_DIR)/tkMacOSXMenu.c \ $(MAC_OSX_DIR)/tkMacOSXMenubutton.c $(MAC_OSX_DIR)/tkMacOSXMenus.c \ $(MAC_OSX_DIR)/tkMacOSXMouseEvent.c $(MAC_OSX_DIR)/tkMacOSXNotify.c \ $(MAC_OSX_DIR)/tkMacOSXRegion.c $(MAC_OSX_DIR)/tkMacOSXScrlbr.c \ $(MAC_OSX_DIR)/tkMacOSXSend.c $(MAC_OSX_DIR)/tkMacOSXSubwindows.c \ $(MAC_OSX_DIR)/tkMacOSXTest.c $(MAC_OSX_DIR)/tkMacOSXWindowEvent.c \ $(MAC_OSX_DIR)/tkMacOSXWm.c $(MAC_OSX_DIR)/tkMacOSXXStubs.c \ $(GENERIC_DIR)/tkFileFilter.c $(GENERIC_DIR)/tkMacWinMenu.c \ $(GENERIC_DIR)/tkPointer.c $(UNIX_DIR)/tkUnix3d.c \ $(UNIX_DIR)/tkUnixScale.c $(XLIB_DIR)/xcolors.c $(XLIB_DIR)/xdraw.c \ $(XLIB_DIR)/xgc.c $(XLIB_DIR)/ximage.c $(XLIB_DIR)/xutil.c \ $(TTK_DIR)/ttkMacOSXTheme.c SRCS = $(GENERIC_SRCS) $(@TK_WINDOWINGSYSTEM@_SRCS) @PLAT_SRCS@ AQUA_HDRS = $(MAC_OSX_DIR)/tkMacOSX.h $(GENERIC_DIR)/tkIntXlibDecls.h AQUA_XLIB_HDRS = $(XLIB_DIR)/X11/*.h $(XLIB_DIR)/xbytes.h AQUA_PRIVATE_HDRS = $(MAC_OSX_DIR)/tkMacOSXPort.h $(MAC_OSX_DIR)/tkMacOSXInt.h X11_PRIVATE_HDRS = $(UNIX_DIR)/tkUnixPort.h $(UNIX_DIR)/tkUnixInt.h |
︙ | ︙ | |||
581 582 583 584 585 586 587 | rm -f $@ @MAKE_LIB@ ${STUB_LIB_FILE}: ${STUB_LIB_OBJS} rm -f $@ @MAKE_STUB_LIB@ | < < < < < < < < < < < | 568 569 570 571 572 573 574 575 576 577 578 579 580 581 | rm -f $@ @MAKE_LIB@ ${STUB_LIB_FILE}: ${STUB_LIB_OBJS} rm -f $@ @MAKE_STUB_LIB@ # Make target which outputs the list of the .o contained in the Tk lib # usefull to build a single big shared library containing Tcl/Tk and other # extensions. used for the Tcl Plugin. -- dl tkLibObjs: @echo ${OBJS} # This targets actually build the objects needed for the lib in the above # case |
︙ | ︙ | |||
1203 1204 1205 1206 1207 1208 1209 | tkMacOSXBitmap.o: $(MAC_OSX_DIR)/tkMacOSXBitmap.c $(CC) -c $(CC_SWITCHES) $(MAC_OSX_DIR)/tkMacOSXBitmap.c tkMacOSXButton.o: $(MAC_OSX_DIR)/tkMacOSXButton.c $(CC) -c $(CC_SWITCHES) $(MAC_OSX_DIR)/tkMacOSXButton.c | < < < | 1179 1180 1181 1182 1183 1184 1185 1186 1187 1188 1189 1190 1191 1192 | tkMacOSXBitmap.o: $(MAC_OSX_DIR)/tkMacOSXBitmap.c $(CC) -c $(CC_SWITCHES) $(MAC_OSX_DIR)/tkMacOSXBitmap.c tkMacOSXButton.o: $(MAC_OSX_DIR)/tkMacOSXButton.c $(CC) -c $(CC_SWITCHES) $(MAC_OSX_DIR)/tkMacOSXButton.c tkMacOSXClipboard.o: $(MAC_OSX_DIR)/tkMacOSXClipboard.c $(CC) -c $(CC_SWITCHES) $(MAC_OSX_DIR)/tkMacOSXClipboard.c tkMacOSXColor.o: $(MAC_OSX_DIR)/tkMacOSXColor.c $(CC) -c $(CC_SWITCHES) $(MAC_OSX_DIR)/tkMacOSXColor.c tkMacOSXConfig.o: $(MAC_OSX_DIR)/tkMacOSXConfig.c |
︙ | ︙ | |||
1558 1559 1560 1561 1562 1563 1564 | mkdir $(DISTDIR)/win/rc cp -p $(TOP_DIR)/win/wish.exe.manifest.in $(DISTDIR)/win/ cp -p $(TOP_DIR)/win/rc/*.{rc,cur,ico,bmp} $(DISTDIR)/win/rc $(TCL_EXE) $(TOOL_DIR)/eolFix.tcl -crlf $(DISTDIR)/win/rc/*.rc $(TCL_EXE) $(TOOL_DIR)/eolFix.tcl -crlf $(DISTDIR)/win/wish.exe.manifest.in mkdir $(DISTDIR)/macosx cp -p $(MAC_OSX_DIR)/GNUmakefile $(MAC_OSX_DIR)/README \ | | | | | | > | < | > | 1531 1532 1533 1534 1535 1536 1537 1538 1539 1540 1541 1542 1543 1544 1545 1546 1547 1548 1549 1550 1551 1552 1553 1554 1555 1556 | mkdir $(DISTDIR)/win/rc cp -p $(TOP_DIR)/win/wish.exe.manifest.in $(DISTDIR)/win/ cp -p $(TOP_DIR)/win/rc/*.{rc,cur,ico,bmp} $(DISTDIR)/win/rc $(TCL_EXE) $(TOOL_DIR)/eolFix.tcl -crlf $(DISTDIR)/win/rc/*.rc $(TCL_EXE) $(TOOL_DIR)/eolFix.tcl -crlf $(DISTDIR)/win/wish.exe.manifest.in mkdir $(DISTDIR)/macosx cp -p $(MAC_OSX_DIR)/GNUmakefile $(MAC_OSX_DIR)/README \ $(MAC_OSX_DIR)/Tk.* $(MAC_OSX_DIR)/*.[ch] \ $(MAC_OSX_DIR)/*.in $(MAC_OSX_DIR)/*.ac \ $(MAC_OSX_DIR)/*.xcconfig $(MAC_OSX_DIR)/*.sdef \ $(MAC_OSX_DIR)/configure $(DISTDIR)/macosx cp -p $(TOP_DIR)/license.terms $(DISTDIR)/macosx mkdir $(DISTDIR)/macosx/Wish.xcode cp -p $(MAC_OSX_DIR)/Wish.xcode/project.pbxproj \ $(MAC_OSX_DIR)/Wish.xcode/default.pbxuser \ $(DISTDIR)/macosx/Wish.xcode mkdir $(DISTDIR)/macosx/Wish.xcodeproj cp -p $(MAC_OSX_DIR)/Wish.xcodeproj/project.pbxproj \ $(MAC_OSX_DIR)/Wish.xcodeproj/default.pbxuser \ $(DISTDIR)/macosx/Wish.xcodeproj mkdir $(DISTDIR)/compat cp -p $(TOP_DIR)/license.terms $(TCLDIR)/compat/unistd.h \ $(TCLDIR)/compat/stdlib.h $(TCLDIR)/compat/limits.h \ $(DISTDIR)/compat mkdir $(DISTDIR)/xlib cp -p $(XLIB_DIR)/*.[ch] $(DISTDIR)/xlib |
︙ | ︙ |
Changes to unix/configure.
︙ | ︙ | |||
9528 9529 9530 9531 9532 9533 9534 | fi; if test $tk_aqua = yes; then if test $tcl_corefoundation = no; then { echo "$as_me:$LINENO: WARNING: Aqua can only be used when CoreFoundation is available" >&5 echo "$as_me: WARNING: Aqua can only be used when CoreFoundation is available" >&2;} tk_aqua=no fi | | | | | | | | 9528 9529 9530 9531 9532 9533 9534 9535 9536 9537 9538 9539 9540 9541 9542 9543 9544 9545 9546 9547 9548 9549 | fi; if test $tk_aqua = yes; then if test $tcl_corefoundation = no; then { echo "$as_me:$LINENO: WARNING: Aqua can only be used when CoreFoundation is available" >&5 echo "$as_me: WARNING: Aqua can only be used when CoreFoundation is available" >&2;} tk_aqua=no fi if test ! -d /System/Library/Frameworks/Cocoa.framework; then { echo "$as_me:$LINENO: WARNING: Aqua can only be used when Cocoa is available" >&5 echo "$as_me: WARNING: Aqua can only be used when Cocoa is available" >&2;} tk_aqua=no fi if test "`uname -r | awk -F. '{print $1}'`" -lt 9; then { echo "$as_me:$LINENO: WARNING: Aqua requires Mac OS X 10.5 or later" >&5 echo "$as_me: WARNING: Aqua requires Mac OS X 10.5 or later" >&2;} tk_aqua=no fi fi echo "$as_me:$LINENO: result: $tk_aqua" >&5 echo "${ECHO_T}$tk_aqua" >&6 if test "$fat_32_64" = yes; then if test $tk_aqua = no; then |
︙ | ︙ | |||
9609 9610 9611 9612 9613 9614 9615 | done fi echo "$as_me:$LINENO: result: $tcl_cv_lib_x11_64" >&5 echo "${ECHO_T}$tcl_cv_lib_x11_64" >&6 fi # remove 64-bit arch flags from CFLAGS et al. for combined 32 & 64 bit # fat builds if configuration does not support 64-bit. | | | 9609 9610 9611 9612 9613 9614 9615 9616 9617 9618 9619 9620 9621 9622 9623 | done fi echo "$as_me:$LINENO: result: $tcl_cv_lib_x11_64" >&5 echo "${ECHO_T}$tcl_cv_lib_x11_64" >&6 fi # remove 64-bit arch flags from CFLAGS et al. for combined 32 & 64 bit # fat builds if configuration does not support 64-bit. if test "$tcl_cv_lib_x11_64" = no; then { echo "$as_me:$LINENO: Removing 64-bit architectures from compiler & linker flags" >&5 echo "$as_me: Removing 64-bit architectures from compiler & linker flags" >&6;} for v in CFLAGS CPPFLAGS LDFLAGS; do eval $v'="`echo "$'$v' "|sed -e "s/-arch ppc64 / /g" -e "s/-arch x86_64 / /g"`"' done fi fi |
︙ | ︙ | |||
9986 9987 9988 9989 9990 9991 9992 | if test $tk_aqua = yes; then cat >>confdefs.h <<\_ACEOF #define MAC_OSX_TK 1 _ACEOF | | | | 9986 9987 9988 9989 9990 9991 9992 9993 9994 9995 9996 9997 9998 9999 10000 10001 | if test $tk_aqua = yes; then cat >>confdefs.h <<\_ACEOF #define MAC_OSX_TK 1 _ACEOF LIBS="$LIBS -framework Cocoa -framework Carbon -framework IOKit" EXTRA_CC_SWITCHES='-std=gnu99 -x objective-c -fobjc-gc' TK_WINDOWINGSYSTEM=AQUA if test -n "${enable_symbols}" -a "${enable_symbols}" != no; then cat >>confdefs.h <<\_ACEOF #define TK_MAC_DEBUG 1 _ACEOF |
︙ | ︙ | |||
11319 11320 11321 11322 11323 11324 11325 | echo "${ECHO_T}static library" >&6 fi FRAMEWORK_BUILD=0 fi fi TK_SHLIB_LD_EXTRAS="-compatibility_version ${TK_VERSION} -current_version ${TK_VERSION}`echo ${TK_PATCH_LEVEL} | awk '{match($0, "\\\.[0-9]+"); print substr($0,RSTART,RLENGTH)}'`" | | | 11319 11320 11321 11322 11323 11324 11325 11326 11327 11328 11329 11330 11331 11332 11333 | echo "${ECHO_T}static library" >&6 fi FRAMEWORK_BUILD=0 fi fi TK_SHLIB_LD_EXTRAS="-compatibility_version ${TK_VERSION} -current_version ${TK_VERSION}`echo ${TK_PATCH_LEVEL} | awk '{match($0, "\\\.[0-9]+"); print substr($0,RSTART,RLENGTH)}'`" TK_SHLIB_LD_EXTRAS="${TK_SHLIB_LD_EXTRAS}"' -install_name "${DYLIB_INSTALL_DIR}/${TK_LIB_FILE}" -unexported_symbols_list $$(f=$(TK_LIB_FILE).E && nm -gp tkMacOSX*.o 2>/dev/null | awk "/^[0-9a-f]+ . \.objc/ {print \$$3}" > $$f && nm -gjp "$(TCL_BIN_DIR)"/$(TCL_STUB_LIB_FILE) | grep ^_[^_] >> $$f && echo $$f)' echo "$LDFLAGS " | grep -q -- '-prebind ' && TK_SHLIB_LD_EXTRAS="${TK_SHLIB_LD_EXTRAS}"' -seg1addr 0xb000000' TK_SHLIB_LD_EXTRAS="${TK_SHLIB_LD_EXTRAS}"' -sectcreate __TEXT __info_plist Tk-Info.plist' EXTRA_WISH_LIBS='-sectcreate __TEXT __info_plist Wish-Info.plist' EXTRA_APP_CC_SWITCHES="${EXTRA_APP_CC_SWITCHES}"' -mdynamic-no-pic' ac_config_files="$ac_config_files Tk-Info.plist:../macosx/Tk-Info.plist.in Wish-Info.plist:../macosx/Wish-Info.plist.in" for l in ${LOCALES}; do CFBUNDLELOCALIZATIONS="${CFBUNDLELOCALIZATIONS}<string>$l</string>"; done |
︙ | ︙ | |||
11363 11364 11365 11366 11367 11368 11369 | PRIVATE_INCLUDE_DIR="${libdir}/PrivateHeaders" HTML_DIR="${libdir}/Resources/Documentation/Reference/Tk" EXTRA_INSTALL="install-private-headers html-tk" EXTRA_BUILD_HTML='@ln -fs contents.htm "$(HTML_INSTALL_DIR)"/TkTOC.html' EXTRA_INSTALL_BINARIES='@echo "Installing Info.plist to $(LIB_INSTALL_DIR)/Resources/" && $(INSTALL_DATA_DIR) "$(LIB_INSTALL_DIR)/Resources" && $(INSTALL_DATA) Tk-Info.plist "$(LIB_INSTALL_DIR)/Resources/Info.plist"' EXTRA_INSTALL_BINARIES="$EXTRA_INSTALL_BINARIES"' && echo "Installing license.terms to $(LIB_INSTALL_DIR)/Resources/" && $(INSTALL_DATA) "$(TOP_DIR)/license.terms" "$(LIB_INSTALL_DIR)/Resources"' if test $tk_aqua = yes; then | | | | | > > > < < < < < < < < < < < < < < < < | 11363 11364 11365 11366 11367 11368 11369 11370 11371 11372 11373 11374 11375 11376 11377 11378 11379 11380 11381 11382 11383 11384 11385 11386 11387 11388 11389 11390 11391 11392 11393 11394 11395 11396 11397 11398 11399 11400 11401 11402 11403 11404 11405 11406 11407 11408 11409 | PRIVATE_INCLUDE_DIR="${libdir}/PrivateHeaders" HTML_DIR="${libdir}/Resources/Documentation/Reference/Tk" EXTRA_INSTALL="install-private-headers html-tk" EXTRA_BUILD_HTML='@ln -fs contents.htm "$(HTML_INSTALL_DIR)"/TkTOC.html' EXTRA_INSTALL_BINARIES='@echo "Installing Info.plist to $(LIB_INSTALL_DIR)/Resources/" && $(INSTALL_DATA_DIR) "$(LIB_INSTALL_DIR)/Resources" && $(INSTALL_DATA) Tk-Info.plist "$(LIB_INSTALL_DIR)/Resources/Info.plist"' EXTRA_INSTALL_BINARIES="$EXTRA_INSTALL_BINARIES"' && echo "Installing license.terms to $(LIB_INSTALL_DIR)/Resources/" && $(INSTALL_DATA) "$(TOP_DIR)/license.terms" "$(LIB_INSTALL_DIR)/Resources"' if test $tk_aqua = yes; then EXTRA_INSTALL_BINARIES="$EXTRA_INSTALL_BINARIES"' && echo "Installing ${TK_RSRC_FILE} to $(LIB_INSTALL_DIR)/Resources/" && $(INSTALL_DATA_DIR) "$(LIB_INSTALL_DIR)/Resources" && for i in Tk.tiff Tk.icns; do $(INSTALL_DATA) "$(MAC_OSX_DIR)/$$i" "$(LIB_INSTALL_DIR)/Resources"; done' EXTRA_INSTALL_BINARIES="$EXTRA_INSTALL_BINARIES"' && echo "Installing wish$(VERSION) script to $(INSTALL_ROOT)/'"${bindir}"'/" && $(INSTALL_DATA_DIR) "$(INSTALL_ROOT)/'"${bindir}"'" && printf > "$(INSTALL_ROOT)/'"${bindir}"'/wish$(VERSION)" "#!/bin/sh\n\"\$$(dirname \$$0)'"`eval d="${bindir}"; echo "$d" | sed -e 's#/[^/][^/]*#/..#g'`"'$(bindir)/Wish\" \"\$$@\"" && chmod +x "$(INSTALL_ROOT)/'"${bindir}"'/wish$(VERSION)"' bindir="${libdir}/Resources/Wish.app/Contents/MacOS" EXTRA_INSTALL_BINARIES="$EXTRA_INSTALL_BINARIES"' && echo "Installing Info.plist to $(BIN_INSTALL_DIR)/.." && $(INSTALL_DATA) Wish-Info.plist "$(BIN_INSTALL_DIR)/../Info.plist" && mv -f "$(BIN_INSTALL_DIR)/wish$(VERSION)" "$(BIN_INSTALL_DIR)/Wish"' EXTRA_INSTALL_BINARIES="$EXTRA_INSTALL_BINARIES"' && echo "Installing Wish.icns to $(BIN_INSTALL_DIR)/../Resources" && $(INSTALL_DATA_DIR) "$(BIN_INSTALL_DIR)/../Resources" && $(INSTALL_DATA) "$(MAC_OSX_DIR)/Tk.icns" "$(BIN_INSTALL_DIR)/../Resources/Wish.icns"' EXTRA_INSTALL_BINARIES="$EXTRA_INSTALL_BINARIES"' && echo "Installing Wish.sdef to $(BIN_INSTALL_DIR)/../Resources" && $(INSTALL_DATA) "$(MAC_OSX_DIR)/Wish.sdef" "$(BIN_INSTALL_DIR)/../Resources"' fi EXTRA_INSTALL_BINARIES="$EXTRA_INSTALL_BINARIES"' && echo "Finalizing Tk.framework" && rm -f "$(LIB_INSTALL_DIR)/../Current" && ln -s "$(VERSION)" "$(LIB_INSTALL_DIR)/../Current" && for f in "$(LIB_FILE)" tkConfig.sh Resources Headers PrivateHeaders; do rm -f "$(LIB_INSTALL_DIR)/../../$$f" && ln -s "Versions/Current/$$f" "$(LIB_INSTALL_DIR)/../.."; done && f="$(STUB_LIB_FILE)" && rm -f "$(LIB_INSTALL_DIR)/../../$$f" && ln -s "Versions/$(VERSION)/$$f" "$(LIB_INSTALL_DIR)/../.."' # Don't use AC_DEFINE for the following as the framework version define # needs to go into the Makefile even when using autoheader, so that we # can pick up a potential make override of VERSION. Also, don't put this # into CFLAGS as it should not go into tkConfig.sh EXTRA_CC_SWITCHES="$EXTRA_CC_SWITCHES"' -DTK_FRAMEWORK_VERSION=\"$(VERSION)\"' else if test $tk_aqua = yes; then EXTRA_INSTALL_BINARIES='@echo "Installing Images to $(LIB_INSTALL_DIR)" && mkdir -p "$(LIB_INSTALL_DIR)" && for i in Tk.tiff Tk.icns; do $(INSTALL_DATA) "$(MAC_OSX_DIR)/$$i" "$(LIB_INSTALL_DIR)"; done' fi # libdir must be a fully qualified path and not ${exec_prefix}/lib eval libdir="$libdir" if test "${TCL_LIB_VERSIONS_OK}" = "ok"; then TK_LIB_FLAG="-ltk${TK_VERSION}" else TK_LIB_FLAG="-ltk`echo ${TK_VERSION} | tr -d .`" fi TK_BUILD_LIB_SPEC="-L`pwd | sed -e 's/ /\\\\ /g'` ${TK_LIB_FLAG}" if test "${ac_cv_cygwin}" = "yes" -a "$SHARED_BUILD" = "1"; then WISH_BUILD_LIB_SPEC="-L\$(TOP_DIR)/win -ltk${TK_MAJOR_VERSION}${TK_MINOR_VERSION} \${TCL_LIB_SPEC}" else WISH_BUILD_LIB_SPEC="-L`pwd | sed -e 's/ /\\\\ /g'` ${TK_LIB_FLAG} \${WISH_LIBS}" fi TK_LIB_SPEC="-L${libdir} ${TK_LIB_FLAG}" fi #-------------------------------------------------------------------- # The statements below define various symbols relating to Tk # stub support. #-------------------------------------------------------------------- # Replace ${VERSION} with contents of ${TK_VERSION} eval "TK_STUB_LIB_FILE=libtkstub${TK_UNSHARED_LIB_SUFFIX}" |
︙ | ︙ |
Changes to unix/configure.in.
︙ | ︙ | |||
272 273 274 275 276 277 278 | [use Aqua windowingsystem on Mac OS X (default: off)]), [tk_aqua=$enableval], [tk_aqua=no]) if test $tk_aqua = yes; then if test $tcl_corefoundation = no; then AC_MSG_WARN([Aqua can only be used when CoreFoundation is available]) tk_aqua=no fi | | | | | | | 272 273 274 275 276 277 278 279 280 281 282 283 284 285 286 287 288 289 290 291 292 293 294 295 296 297 298 299 300 301 302 303 304 305 306 307 308 309 310 311 312 | [use Aqua windowingsystem on Mac OS X (default: off)]), [tk_aqua=$enableval], [tk_aqua=no]) if test $tk_aqua = yes; then if test $tcl_corefoundation = no; then AC_MSG_WARN([Aqua can only be used when CoreFoundation is available]) tk_aqua=no fi if test ! -d /System/Library/Frameworks/Cocoa.framework; then AC_MSG_WARN([Aqua can only be used when Cocoa is available]) tk_aqua=no fi if test "`uname -r | awk -F. '{print [$]1}'`" -lt 9; then AC_MSG_WARN([Aqua requires Mac OS X 10.5 or later]) tk_aqua=no fi fi AC_MSG_RESULT([$tk_aqua]) if test "$fat_32_64" = yes; then if test $tk_aqua = no; then AC_CACHE_CHECK([for 64-bit X11], tcl_cv_lib_x11_64, [ for v in CFLAGS CPPFLAGS LDFLAGS; do eval 'hold_'$v'="$'$v'";'$v'="`echo "$'$v' "|sed -e "s/-arch ppc / /g" -e "s/-arch i386 / /g"`"' done CPPFLAGS="$CPPFLAGS -I/usr/X11R6/include" LDFLAGS="$LDFLAGS -L/usr/X11R6/lib -lX11" AC_TRY_LINK([#include <X11/Xlib.h>], [XrmInitialize();], tcl_cv_lib_x11_64=yes, tcl_cv_lib_x11_64=no) for v in CFLAGS CPPFLAGS LDFLAGS; do eval $v'="$hold_'$v'"' done]) fi # remove 64-bit arch flags from CFLAGS et al. for combined 32 & 64 bit # fat builds if configuration does not support 64-bit. if test "$tcl_cv_lib_x11_64" = no; then AC_MSG_NOTICE([Removing 64-bit architectures from compiler & linker flags]) for v in CFLAGS CPPFLAGS LDFLAGS; do eval $v'="`echo "$'$v' "|sed -e "s/-arch ppc64 / /g" -e "s/-arch x86_64 / /g"`"' done fi fi if test $tk_aqua = no; then |
︙ | ︙ | |||
359 360 361 362 363 364 365 | fi else tk_aqua=no fi if test $tk_aqua = yes; then AC_DEFINE(MAC_OSX_TK, 1, [Are we building TkAqua?]) | | | | 359 360 361 362 363 364 365 366 367 368 369 370 371 372 373 374 | fi else tk_aqua=no fi if test $tk_aqua = yes; then AC_DEFINE(MAC_OSX_TK, 1, [Are we building TkAqua?]) LIBS="$LIBS -framework Cocoa -framework Carbon -framework IOKit" EXTRA_CC_SWITCHES='-std=gnu99 -x objective-c -fobjc-gc' TK_WINDOWINGSYSTEM=AQUA if test -n "${enable_symbols}" -a "${enable_symbols}" != no; then AC_DEFINE(TK_MAC_DEBUG, 1, [Are TkAqua debug messages enabled?]) fi else #-------------------------------------------------------------------- # Locate the X11 header files and the X11 library archive. Try |
︙ | ︙ | |||
616 617 618 619 620 621 622 | # path name of the Tcl directory rather than "..": this is because # AIX remembers this path and will attempt to use it at run-time to look # up the Tcl library. if test "`uname -s`" = "Darwin" ; then SC_ENABLE_FRAMEWORK TK_SHLIB_LD_EXTRAS="-compatibility_version ${TK_VERSION} -current_version ${TK_VERSION}`echo ${TK_PATCH_LEVEL} | awk ['{match($0, "\\\.[0-9]+"); print substr($0,RSTART,RLENGTH)}']`" | | | 616 617 618 619 620 621 622 623 624 625 626 627 628 629 630 | # path name of the Tcl directory rather than "..": this is because # AIX remembers this path and will attempt to use it at run-time to look # up the Tcl library. if test "`uname -s`" = "Darwin" ; then SC_ENABLE_FRAMEWORK TK_SHLIB_LD_EXTRAS="-compatibility_version ${TK_VERSION} -current_version ${TK_VERSION}`echo ${TK_PATCH_LEVEL} | awk ['{match($0, "\\\.[0-9]+"); print substr($0,RSTART,RLENGTH)}']`" TK_SHLIB_LD_EXTRAS="${TK_SHLIB_LD_EXTRAS}"' -install_name "${DYLIB_INSTALL_DIR}/${TK_LIB_FILE}" -unexported_symbols_list $$(f=$(TK_LIB_FILE).E && nm -gp tkMacOSX*.o 2>/dev/null | awk "/^[[0-9a-f]]+ . \.objc/ {print \$$3}" > $$f && nm -gjp "$(TCL_BIN_DIR)"/$(TCL_STUB_LIB_FILE) | grep ^_[[^_]] >> $$f && echo $$f)' echo "$LDFLAGS " | grep -q -- '-prebind ' && TK_SHLIB_LD_EXTRAS="${TK_SHLIB_LD_EXTRAS}"' -seg1addr 0xb000000' TK_SHLIB_LD_EXTRAS="${TK_SHLIB_LD_EXTRAS}"' -sectcreate __TEXT __info_plist Tk-Info.plist' EXTRA_WISH_LIBS='-sectcreate __TEXT __info_plist Wish-Info.plist' EXTRA_APP_CC_SWITCHES="${EXTRA_APP_CC_SWITCHES}"' -mdynamic-no-pic' AC_CONFIG_FILES([Tk-Info.plist:../macosx/Tk-Info.plist.in Wish-Info.plist:../macosx/Wish-Info.plist.in]) for l in ${LOCALES}; do CFBUNDLELOCALIZATIONS="${CFBUNDLELOCALIZATIONS}<string>$l</string>"; done TK_YEAR="`date +%Y`" |
︙ | ︙ | |||
661 662 663 664 665 666 667 | PRIVATE_INCLUDE_DIR="${libdir}/PrivateHeaders" HTML_DIR="${libdir}/Resources/Documentation/Reference/Tk" EXTRA_INSTALL="install-private-headers html-tk" EXTRA_BUILD_HTML='@ln -fs contents.htm "$(HTML_INSTALL_DIR)"/TkTOC.html' EXTRA_INSTALL_BINARIES='@echo "Installing Info.plist to $(LIB_INSTALL_DIR)/Resources/" && $(INSTALL_DATA_DIR) "$(LIB_INSTALL_DIR)/Resources" && $(INSTALL_DATA) Tk-Info.plist "$(LIB_INSTALL_DIR)/Resources/Info.plist"' EXTRA_INSTALL_BINARIES="$EXTRA_INSTALL_BINARIES"' && echo "Installing license.terms to $(LIB_INSTALL_DIR)/Resources/" && $(INSTALL_DATA) "$(TOP_DIR)/license.terms" "$(LIB_INSTALL_DIR)/Resources"' if test $tk_aqua = yes; then | | | | | > > > < < < < < < < < < < < < < < < < | 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 703 704 705 706 707 | PRIVATE_INCLUDE_DIR="${libdir}/PrivateHeaders" HTML_DIR="${libdir}/Resources/Documentation/Reference/Tk" EXTRA_INSTALL="install-private-headers html-tk" EXTRA_BUILD_HTML='@ln -fs contents.htm "$(HTML_INSTALL_DIR)"/TkTOC.html' EXTRA_INSTALL_BINARIES='@echo "Installing Info.plist to $(LIB_INSTALL_DIR)/Resources/" && $(INSTALL_DATA_DIR) "$(LIB_INSTALL_DIR)/Resources" && $(INSTALL_DATA) Tk-Info.plist "$(LIB_INSTALL_DIR)/Resources/Info.plist"' EXTRA_INSTALL_BINARIES="$EXTRA_INSTALL_BINARIES"' && echo "Installing license.terms to $(LIB_INSTALL_DIR)/Resources/" && $(INSTALL_DATA) "$(TOP_DIR)/license.terms" "$(LIB_INSTALL_DIR)/Resources"' if test $tk_aqua = yes; then EXTRA_INSTALL_BINARIES="$EXTRA_INSTALL_BINARIES"' && echo "Installing ${TK_RSRC_FILE} to $(LIB_INSTALL_DIR)/Resources/" && $(INSTALL_DATA_DIR) "$(LIB_INSTALL_DIR)/Resources" && for i in Tk.tiff Tk.icns; do $(INSTALL_DATA) "$(MAC_OSX_DIR)/$$i" "$(LIB_INSTALL_DIR)/Resources"; done' EXTRA_INSTALL_BINARIES="$EXTRA_INSTALL_BINARIES"' && echo "Installing wish$(VERSION) script to $(INSTALL_ROOT)/'"${bindir}"'/" && $(INSTALL_DATA_DIR) "$(INSTALL_ROOT)/'"${bindir}"'" && printf > "$(INSTALL_ROOT)/'"${bindir}"'/wish$(VERSION)" "#!/bin/sh\n\"\$$(dirname \$$0)'"`eval d="${bindir}"; echo "$d" | sed -e 's#/[^/][^/]*#/..#g'`"'$(bindir)/Wish\" \"\$$@\"" && chmod +x "$(INSTALL_ROOT)/'"${bindir}"'/wish$(VERSION)"' bindir="${libdir}/Resources/Wish.app/Contents/MacOS" EXTRA_INSTALL_BINARIES="$EXTRA_INSTALL_BINARIES"' && echo "Installing Info.plist to $(BIN_INSTALL_DIR)/.." && $(INSTALL_DATA) Wish-Info.plist "$(BIN_INSTALL_DIR)/../Info.plist" && mv -f "$(BIN_INSTALL_DIR)/wish$(VERSION)" "$(BIN_INSTALL_DIR)/Wish"' EXTRA_INSTALL_BINARIES="$EXTRA_INSTALL_BINARIES"' && echo "Installing Wish.icns to $(BIN_INSTALL_DIR)/../Resources" && $(INSTALL_DATA_DIR) "$(BIN_INSTALL_DIR)/../Resources" && $(INSTALL_DATA) "$(MAC_OSX_DIR)/Tk.icns" "$(BIN_INSTALL_DIR)/../Resources/Wish.icns"' EXTRA_INSTALL_BINARIES="$EXTRA_INSTALL_BINARIES"' && echo "Installing Wish.sdef to $(BIN_INSTALL_DIR)/../Resources" && $(INSTALL_DATA) "$(MAC_OSX_DIR)/Wish.sdef" "$(BIN_INSTALL_DIR)/../Resources"' fi EXTRA_INSTALL_BINARIES="$EXTRA_INSTALL_BINARIES"' && echo "Finalizing Tk.framework" && rm -f "$(LIB_INSTALL_DIR)/../Current" && ln -s "$(VERSION)" "$(LIB_INSTALL_DIR)/../Current" && for f in "$(LIB_FILE)" tkConfig.sh Resources Headers PrivateHeaders; do rm -f "$(LIB_INSTALL_DIR)/../../$$f" && ln -s "Versions/Current/$$f" "$(LIB_INSTALL_DIR)/../.."; done && f="$(STUB_LIB_FILE)" && rm -f "$(LIB_INSTALL_DIR)/../../$$f" && ln -s "Versions/$(VERSION)/$$f" "$(LIB_INSTALL_DIR)/../.."' # Don't use AC_DEFINE for the following as the framework version define # needs to go into the Makefile even when using autoheader, so that we # can pick up a potential make override of VERSION. Also, don't put this # into CFLAGS as it should not go into tkConfig.sh EXTRA_CC_SWITCHES="$EXTRA_CC_SWITCHES"' -DTK_FRAMEWORK_VERSION=\"$(VERSION)\"' else if test $tk_aqua = yes; then EXTRA_INSTALL_BINARIES='@echo "Installing Images to $(LIB_INSTALL_DIR)" && mkdir -p "$(LIB_INSTALL_DIR)" && for i in Tk.tiff Tk.icns; do $(INSTALL_DATA) "$(MAC_OSX_DIR)/$$i" "$(LIB_INSTALL_DIR)"; done' fi # libdir must be a fully qualified path and not ${exec_prefix}/lib eval libdir="$libdir" if test "${TCL_LIB_VERSIONS_OK}" = "ok"; then TK_LIB_FLAG="-ltk${TK_VERSION}" else TK_LIB_FLAG="-ltk`echo ${TK_VERSION} | tr -d .`" fi TK_BUILD_LIB_SPEC="-L`pwd | sed -e 's/ /\\\\ /g'` ${TK_LIB_FLAG}" if test "${ac_cv_cygwin}" = "yes" -a "$SHARED_BUILD" = "1"; then WISH_BUILD_LIB_SPEC="-L\$(TOP_DIR)/win -ltk${TK_MAJOR_VERSION}${TK_MINOR_VERSION} \${TCL_LIB_SPEC}" else WISH_BUILD_LIB_SPEC="-L`pwd | sed -e 's/ /\\\\ /g'` ${TK_LIB_FLAG} \${WISH_LIBS}" fi TK_LIB_SPEC="-L${libdir} ${TK_LIB_FLAG}" fi #-------------------------------------------------------------------- # The statements below define various symbols relating to Tk # stub support. #-------------------------------------------------------------------- # Replace ${VERSION} with contents of ${TK_VERSION} eval "TK_STUB_LIB_FILE=libtkstub${TK_UNSHARED_LIB_SUFFIX}" |
︙ | ︙ |
Changes to xlib/xgc.c.
1 2 3 4 5 6 7 | /* * xgc.c -- * * This file contains generic routines for manipulating X graphics * contexts. * * Copyright (c) 1995-1996 Sun Microsystems, Inc. | | > > > > > | < > | 1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 34 35 36 | /* * xgc.c -- * * This file contains generic routines for manipulating X graphics * contexts. * * Copyright (c) 1995-1996 Sun Microsystems, Inc. * Copyright (c) 2002-2009 Daniel A. Steffen <[email protected]> * Copyright 2008-2009, Apple Inc. * * See the file "license.terms" for information on usage and redistribution of * this file, and for a DISCLAIMER OF ALL WARRANTIES. */ #include <tkInt.h> #if !defined(MAC_OSX_TK) # include <X11/Xlib.h> # define gcCacheSize 0 # define TkpInitGCCache(gc) # define TkpFreeGCCache(gc) # define TkpGetGCCache(gc) #else # include <tkMacOSXInt.h> # include <X11/Xlib.h> # include <X11/X.h> # define Cursor XCursor # define Region XRegion # define gcCacheSize sizeof(TkpGCCache) #endif #undef TkSetRegion /* *---------------------------------------------------------------------- * |
︙ | ︙ | |||
114 115 116 117 118 119 120 | * are defined, which is invisible from the outside. The list is assumed * to end with a 0-char, so this must be set explicitely during * initialization. */ #define MAX_DASH_LIST_SIZE 10 | | > | 119 120 121 122 123 124 125 126 127 128 129 130 131 132 133 134 | * are defined, which is invisible from the outside. The list is assumed * to end with a 0-char, so this must be set explicitely during * initialization. */ #define MAX_DASH_LIST_SIZE 10 gp = (XGCValues *) ckalloc(sizeof(XGCValues) + MAX_DASH_LIST_SIZE + gcCacheSize); if (!gp) { return None; } #define InitField(name,maskbit,default) \ (gp->name = (mask & (maskbit)) ? values->name : (default)) |
︙ | ︙ | |||
155 156 157 158 159 160 161 162 163 164 165 166 167 168 169 170 171 | gp->clip_mask = None; if (mask & GCClipMask) { TkpClipMask *clip_mask = AllocClipMask(gp); clip_mask->type = TKP_CLIP_PIXMAP; clip_mask->value.pixmap = values->clip_mask; } return gp; } /* *---------------------------------------------------------------------- * * XChangeGC -- * * Changes the GC components specified by valuemask for the specified GC. | > > > > > > > > > > > > > > > > > > > > > > > | 161 162 163 164 165 166 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 | gp->clip_mask = None; if (mask & GCClipMask) { TkpClipMask *clip_mask = AllocClipMask(gp); clip_mask->type = TKP_CLIP_PIXMAP; clip_mask->value.pixmap = values->clip_mask; } TkpInitGCCache(gp); return gp; } #ifdef MAC_OSX_TK /* *---------------------------------------------------------------------- * * TkpGetGCCache -- * * Results: * Pointer to the TkpGCCache at the end of the GC. * * Side effects: * None. * *---------------------------------------------------------------------- */ TkpGCCache* TkpGetGCCache(GC gc) { return (gc ? (TkpGCCache*)(((char*) gc) + sizeof(XGCValues) + MAX_DASH_LIST_SIZE) : NULL); } #endif /* *---------------------------------------------------------------------- * * XChangeGC -- * * Changes the GC components specified by valuemask for the specified GC. |
︙ | ︙ | |||
238 239 240 241 242 243 244 245 246 247 248 249 250 251 | int XFreeGC( Display *d, GC gc) { if (gc != None) { FreeClipMask(gc); ckfree((char *) gc); } return Success; } /* *---------------------------------------------------------------------- | > | 267 268 269 270 271 272 273 274 275 276 277 278 279 280 281 | int XFreeGC( Display *d, GC gc) { if (gc != None) { FreeClipMask(gc); TkpFreeGCCache(gc); ckfree((char *) gc); } return Success; } /* *---------------------------------------------------------------------- |
︙ | ︙ |