diff options
Diffstat (limited to 'generic/tkWindow.c')
-rw-r--r-- | generic/tkWindow.c | 123 |
1 files changed, 70 insertions, 53 deletions
diff --git a/generic/tkWindow.c b/generic/tkWindow.c index d3de72d..98b89db 100644 --- a/generic/tkWindow.c +++ b/generic/tkWindow.c @@ -101,11 +101,12 @@ static CONST XSetWindowAttributes defAtts= { #define ISSAFE 1 #define PASSMAINWINDOW 2 +#define NOOBJPROC 4 +#define WINMACONLY 8 typedef struct { CONST char *name; /* Name of command. */ - Tcl_CmdProc *cmdProc; /* Command's string-based procedure. */ - Tcl_ObjCmdProc *objProc; /* Command's object-based procedure. */ + Tcl_ObjCmdProc *objProc; /* Command's object- (or string-) based procedure. */ int flags; } TkCmd; @@ -114,59 +115,59 @@ static CONST TkCmd commands[] = { * Commands that are part of the intrinsics: */ - {"bell", NULL, Tk_BellObjCmd, PASSMAINWINDOW}, - {"bind", NULL, Tk_BindObjCmd, PASSMAINWINDOW|ISSAFE}, - {"bindtags", NULL, Tk_BindtagsObjCmd, PASSMAINWINDOW|ISSAFE}, - {"clipboard", NULL, Tk_ClipboardObjCmd, PASSMAINWINDOW}, - {"destroy", NULL, Tk_DestroyObjCmd, PASSMAINWINDOW|ISSAFE}, - {"event", NULL, Tk_EventObjCmd, PASSMAINWINDOW|ISSAFE}, - {"focus", NULL, Tk_FocusObjCmd, PASSMAINWINDOW|ISSAFE}, - {"font", NULL, Tk_FontObjCmd, PASSMAINWINDOW|ISSAFE}, - {"grab", NULL, Tk_GrabObjCmd, PASSMAINWINDOW}, - {"grid", NULL, Tk_GridObjCmd, PASSMAINWINDOW|ISSAFE}, - {"image", NULL, Tk_ImageObjCmd, PASSMAINWINDOW|ISSAFE}, - {"lower", NULL, Tk_LowerObjCmd, PASSMAINWINDOW|ISSAFE}, - {"option", NULL, Tk_OptionObjCmd, PASSMAINWINDOW|ISSAFE}, - {"pack", NULL, Tk_PackObjCmd, PASSMAINWINDOW|ISSAFE}, - {"place", NULL, Tk_PlaceObjCmd, ISSAFE}, - {"raise", NULL, Tk_RaiseObjCmd, PASSMAINWINDOW|ISSAFE}, - {"selection", NULL, Tk_SelectionObjCmd, PASSMAINWINDOW}, - {"tk", NULL, Tk_TkObjCmd, PASSMAINWINDOW|ISSAFE}, - {"tkwait", NULL, Tk_TkwaitObjCmd, PASSMAINWINDOW|ISSAFE}, + {"bell", Tk_BellObjCmd, PASSMAINWINDOW}, + {"bind", Tk_BindObjCmd, PASSMAINWINDOW|ISSAFE}, + {"bindtags", Tk_BindtagsObjCmd, PASSMAINWINDOW|ISSAFE}, + {"clipboard", Tk_ClipboardObjCmd, PASSMAINWINDOW}, + {"destroy", Tk_DestroyObjCmd, PASSMAINWINDOW|ISSAFE}, + {"event", Tk_EventObjCmd, PASSMAINWINDOW|ISSAFE}, + {"focus", Tk_FocusObjCmd, PASSMAINWINDOW|ISSAFE}, + {"font", Tk_FontObjCmd, PASSMAINWINDOW|ISSAFE}, + {"grab", Tk_GrabObjCmd, PASSMAINWINDOW}, + {"grid", Tk_GridObjCmd, PASSMAINWINDOW|ISSAFE}, + {"image", Tk_ImageObjCmd, PASSMAINWINDOW|ISSAFE}, + {"lower", Tk_LowerObjCmd, PASSMAINWINDOW|ISSAFE}, + {"option", Tk_OptionObjCmd, PASSMAINWINDOW|ISSAFE}, + {"pack", Tk_PackObjCmd, PASSMAINWINDOW|ISSAFE}, + {"place", Tk_PlaceObjCmd, ISSAFE}, + {"raise", Tk_RaiseObjCmd, PASSMAINWINDOW|ISSAFE}, + {"selection", Tk_SelectionObjCmd, PASSMAINWINDOW}, + {"tk", Tk_TkObjCmd, PASSMAINWINDOW|ISSAFE}, + {"tkwait", Tk_TkwaitObjCmd, PASSMAINWINDOW|ISSAFE}, #if defined(__WIN32__) || defined(MAC_TCL) || defined(MAC_OSX_TK) - {"tk_chooseColor", NULL, Tk_ChooseColorObjCmd, PASSMAINWINDOW}, - {"tk_chooseDirectory", NULL, Tk_ChooseDirectoryObjCmd, PASSMAINWINDOW}, - {"tk_getOpenFile", NULL, Tk_GetOpenFileObjCmd, PASSMAINWINDOW}, - {"tk_getSaveFile", NULL, Tk_GetSaveFileObjCmd, PASSMAINWINDOW}, + {"tk_chooseColor", Tk_ChooseColorObjCmd, PASSMAINWINDOW}, + {"tk_chooseDirectory", Tk_ChooseDirectoryObjCmd, WINMACONLY|PASSMAINWINDOW}, + {"tk_getOpenFile", Tk_GetOpenFileObjCmd, WINMACONLY|PASSMAINWINDOW}, + {"tk_getSaveFile", Tk_GetSaveFileObjCmd, WINMACONLY|PASSMAINWINDOW}, #endif #if defined(__WIN32__) || defined(MAC_OSX_TK) - {"tk_messageBox", NULL, Tk_MessageBoxObjCmd, PASSMAINWINDOW}, + {"tk_messageBox", Tk_MessageBoxObjCmd, PASSMAINWINDOW}, #endif - {"update", NULL, Tk_UpdateObjCmd, PASSMAINWINDOW|ISSAFE}, - {"winfo", NULL, Tk_WinfoObjCmd, PASSMAINWINDOW|ISSAFE}, - {"wm", NULL, Tk_WmObjCmd, PASSMAINWINDOW}, + {"update", Tk_UpdateObjCmd, PASSMAINWINDOW|ISSAFE}, + {"winfo", Tk_WinfoObjCmd, PASSMAINWINDOW|ISSAFE}, + {"wm", Tk_WmObjCmd, PASSMAINWINDOW}, /* * Widget class commands. */ - {"button", NULL, Tk_ButtonObjCmd, ISSAFE}, - {"canvas", NULL, Tk_CanvasObjCmd, PASSMAINWINDOW|ISSAFE}, - {"checkbutton", NULL, Tk_CheckbuttonObjCmd, ISSAFE}, - {"entry", NULL, Tk_EntryObjCmd, ISSAFE}, - {"frame", NULL, Tk_FrameObjCmd, ISSAFE}, - {"label", NULL, Tk_LabelObjCmd, ISSAFE}, - {"labelframe", NULL, Tk_LabelframeObjCmd, ISSAFE}, - {"listbox", NULL, Tk_ListboxObjCmd, ISSAFE}, - {"menubutton", NULL, Tk_MenubuttonObjCmd, ISSAFE}, - {"message", NULL, Tk_MessageObjCmd, ISSAFE}, - {"panedwindow", NULL, Tk_PanedWindowObjCmd, ISSAFE}, - {"radiobutton", NULL, Tk_RadiobuttonObjCmd, ISSAFE}, - {"scale", NULL, Tk_ScaleObjCmd, ISSAFE}, - {"scrollbar", Tk_ScrollbarCmd, NULL, PASSMAINWINDOW|ISSAFE}, - {"spinbox", NULL, Tk_SpinboxObjCmd, ISSAFE}, - {"text", Tk_TextCmd, NULL, PASSMAINWINDOW|ISSAFE}, - {"toplevel", NULL, Tk_ToplevelObjCmd, 0}, + {"button", Tk_ButtonObjCmd, ISSAFE}, + {"canvas", Tk_CanvasObjCmd, PASSMAINWINDOW|ISSAFE}, + {"checkbutton", Tk_CheckbuttonObjCmd, ISSAFE}, + {"entry", Tk_EntryObjCmd, ISSAFE}, + {"frame", Tk_FrameObjCmd, ISSAFE}, + {"label", Tk_LabelObjCmd, ISSAFE}, + {"labelframe", Tk_LabelframeObjCmd, ISSAFE}, + {"listbox", Tk_ListboxObjCmd, ISSAFE}, + {"menubutton", Tk_MenubuttonObjCmd, ISSAFE}, + {"message", Tk_MessageObjCmd, ISSAFE}, + {"panedwindow", Tk_PanedWindowObjCmd, ISSAFE}, + {"radiobutton", Tk_RadiobuttonObjCmd, ISSAFE}, + {"scale", Tk_ScaleObjCmd, ISSAFE}, + {"scrollbar", (Tcl_ObjCmdProc *) Tk_ScrollbarCmd, NOOBJPROC|PASSMAINWINDOW|ISSAFE}, + {"spinbox", Tk_SpinboxObjCmd, ISSAFE}, + {"text", (Tcl_ObjCmdProc *) Tk_TextCmd, NOOBJPROC|PASSMAINWINDOW|ISSAFE}, + {"toplevel", Tk_ToplevelObjCmd, 0}, /* * Misc. @@ -174,9 +175,9 @@ static CONST TkCmd commands[] = { #if defined(MAC_TCL) || defined(MAC_OSX_TK) {"::tk::unsupported::MacWindowStyle", - NULL, TkUnsupported1ObjCmd, PASSMAINWINDOW|ISSAFE}, + TkUnsupported1ObjCmd, PASSMAINWINDOW|ISSAFE}, #endif - {(char *) NULL, (int (*) _ANSI_ARGS_((ClientData, Tcl_Interp *, int, CONST char **))) NULL, NULL, 0} + {NULL, NULL, 0} }; /* @@ -851,6 +852,9 @@ TkCreateMainWindow(interp, screenName, baseName) Tk_Window tkwin; int dummy; int isSafe; +#ifdef __WIN32__ + int isWin32 = 0; +#endif Tcl_HashEntry *hPtr; register TkMainInfo *mainPtr; register TkWindow *winPtr; @@ -858,7 +862,15 @@ TkCreateMainWindow(interp, screenName, baseName) ClientData clientData; ThreadSpecificData *tsdPtr = (ThreadSpecificData *) Tcl_GetThreadData(&dataKey, sizeof(ThreadSpecificData)); - +#ifdef __WIN32__ + Tcl_Obj *stringObjPtr = Tcl_GetVar2Ex(interp, "::tcl_platform", "platform", 0); + + if (stringObjPtr + && !strcmp(Tcl_GetString(stringObjPtr), "windows")) { + isWin32 = 1; + } +#endif + /* * Panic if someone updated the TkWindow structure without * also updating the Tk_FakeWin structure (or vice versa). @@ -938,17 +950,22 @@ TkCreateMainWindow(interp, screenName, baseName) isSafe = Tcl_IsSafe(interp); for (cmdPtr = commands; cmdPtr->name != NULL; cmdPtr++) { - if ((cmdPtr->cmdProc == NULL) && (cmdPtr->objProc == NULL)) { + if (cmdPtr->objProc == NULL) { Tcl_Panic("TkCreateMainWindow: builtin command with NULL string and object procs"); } +#ifdef __WIN32__ + if (!isWin32 && (cmdPtr->flags & WINMACONLY)) { + continue; + } +#endif if (cmdPtr->flags & PASSMAINWINDOW) { clientData = (ClientData) tkwin; } else { clientData = (ClientData) NULL; } - if (cmdPtr->cmdProc != NULL) { - Tcl_CreateCommand(interp, cmdPtr->name, cmdPtr->cmdProc, - clientData, (void (*) _ANSI_ARGS_((ClientData))) NULL); + if (cmdPtr->flags & NOOBJPROC) { + Tcl_CreateCommand(interp, cmdPtr->name, + (Tcl_CmdProc *) cmdPtr->objProc, clientData, NULL); } else { Tcl_CreateObjCommand(interp, cmdPtr->name, cmdPtr->objProc, clientData, NULL); |