diff options
Diffstat (limited to 'generic/tkWindow.c')
-rw-r--r-- | generic/tkWindow.c | 166 |
1 files changed, 91 insertions, 75 deletions
diff --git a/generic/tkWindow.c b/generic/tkWindow.c index 40cf462..4d5e895 100644 --- a/generic/tkWindow.c +++ b/generic/tkWindow.c @@ -14,7 +14,7 @@ #include "tkInt.h" -#if !( defined(__WIN32__) || defined(MAC_OSX_TK)) +#if !(defined(__WIN32__) || defined(MAC_OSX_TK)) #include "tkUnixInt.h" #endif @@ -95,13 +95,14 @@ static const XSetWindowAttributes defAtts= { #define ISSAFE 1 #define PASSMAINWINDOW 2 +#define NOOBJPROC 4 +#define WINMACONLY 8 +#define USEINITPROC 16 typedef int (TkInitProc)(Tcl_Interp *interp, ClientData clientData); typedef struct { - const char *name; /* Name of command. */ - Tcl_CmdProc *cmdProc; /* Command's string-based function. */ - Tcl_ObjCmdProc *objProc; /* Command's object-based function. */ - TkInitProc *initProc; /* Command's initialization function */ + const char *name; /* Name of command. */ + Tcl_ObjCmdProc *objProc; /* Command's object- (or string-) based function, or initProc. */ int flags; } TkCmd; @@ -110,72 +111,72 @@ static const TkCmd commands[] = { * Commands that are part of the intrinsics: */ - {"bell", NULL, Tk_BellObjCmd, NULL, PASSMAINWINDOW}, - {"bind", NULL, Tk_BindObjCmd, NULL, PASSMAINWINDOW|ISSAFE}, - {"bindtags", NULL, Tk_BindtagsObjCmd, NULL, PASSMAINWINDOW|ISSAFE}, - {"clipboard", NULL, Tk_ClipboardObjCmd, NULL, PASSMAINWINDOW}, - {"destroy", NULL, Tk_DestroyObjCmd, NULL, PASSMAINWINDOW|ISSAFE}, - {"event", NULL, Tk_EventObjCmd, NULL, PASSMAINWINDOW|ISSAFE}, - {"focus", NULL, Tk_FocusObjCmd, NULL, PASSMAINWINDOW|ISSAFE}, - {"font", NULL, Tk_FontObjCmd, NULL, PASSMAINWINDOW|ISSAFE}, - {"grab", NULL, Tk_GrabObjCmd, NULL, PASSMAINWINDOW}, - {"grid", NULL, Tk_GridObjCmd, NULL, PASSMAINWINDOW|ISSAFE}, - {"image", NULL, Tk_ImageObjCmd, NULL, PASSMAINWINDOW|ISSAFE}, - {"lower", NULL, Tk_LowerObjCmd, NULL, PASSMAINWINDOW|ISSAFE}, - {"option", NULL, Tk_OptionObjCmd, NULL, PASSMAINWINDOW|ISSAFE}, - {"pack", NULL, Tk_PackObjCmd, NULL, PASSMAINWINDOW|ISSAFE}, - {"place", NULL, Tk_PlaceObjCmd, NULL, PASSMAINWINDOW|ISSAFE}, - {"raise", NULL, Tk_RaiseObjCmd, NULL, PASSMAINWINDOW|ISSAFE}, - {"selection", NULL, Tk_SelectionObjCmd, NULL, PASSMAINWINDOW}, - {"tk", NULL, NULL, TkInitTkCmd, PASSMAINWINDOW|ISSAFE}, - {"tkwait", NULL, Tk_TkwaitObjCmd, NULL, PASSMAINWINDOW|ISSAFE}, - {"update", NULL, Tk_UpdateObjCmd, NULL, PASSMAINWINDOW|ISSAFE}, - {"winfo", NULL, Tk_WinfoObjCmd, NULL, PASSMAINWINDOW|ISSAFE}, - {"wm", NULL, Tk_WmObjCmd, NULL, PASSMAINWINDOW}, + {"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, PASSMAINWINDOW|ISSAFE}, + {"raise", Tk_RaiseObjCmd, PASSMAINWINDOW|ISSAFE}, + {"selection", Tk_SelectionObjCmd, PASSMAINWINDOW}, + {"tk", (Tcl_ObjCmdProc *) TkInitTkCmd, USEINITPROC|PASSMAINWINDOW|ISSAFE}, + {"tkwait", Tk_TkwaitObjCmd, PASSMAINWINDOW|ISSAFE}, + {"update", Tk_UpdateObjCmd, PASSMAINWINDOW|ISSAFE}, + {"winfo", Tk_WinfoObjCmd, PASSMAINWINDOW|ISSAFE}, + {"wm", Tk_WmObjCmd, PASSMAINWINDOW}, /* * Default widget class commands. */ - {"button", NULL, Tk_ButtonObjCmd, NULL, ISSAFE}, - {"canvas", NULL, Tk_CanvasObjCmd, NULL, PASSMAINWINDOW|ISSAFE}, - {"checkbutton", NULL, Tk_CheckbuttonObjCmd, NULL, ISSAFE}, - {"entry", NULL, Tk_EntryObjCmd, NULL, ISSAFE}, - {"frame", NULL, Tk_FrameObjCmd, NULL, ISSAFE}, - {"label", NULL, Tk_LabelObjCmd, NULL, ISSAFE}, - {"labelframe", NULL, Tk_LabelframeObjCmd, NULL, ISSAFE}, - {"listbox", NULL, Tk_ListboxObjCmd, NULL, ISSAFE}, - {"menubutton", NULL, Tk_MenubuttonObjCmd, NULL, ISSAFE}, - {"message", NULL, Tk_MessageObjCmd, NULL, ISSAFE}, - {"panedwindow", NULL, Tk_PanedWindowObjCmd, NULL, ISSAFE}, - {"radiobutton", NULL, Tk_RadiobuttonObjCmd, NULL, ISSAFE}, - {"scale", NULL, Tk_ScaleObjCmd, NULL, ISSAFE}, - {"scrollbar", Tk_ScrollbarCmd,NULL, NULL, PASSMAINWINDOW|ISSAFE}, - {"spinbox", NULL, Tk_SpinboxObjCmd, NULL, ISSAFE}, - {"text", NULL, Tk_TextObjCmd, NULL, PASSMAINWINDOW|ISSAFE}, - {"toplevel", NULL, Tk_ToplevelObjCmd, NULL, 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", Tk_TextObjCmd, PASSMAINWINDOW|ISSAFE}, + {"toplevel", Tk_ToplevelObjCmd, 0}, /* * Classic widget class commands. */ - {"::tk::button", NULL, Tk_ButtonObjCmd, NULL, ISSAFE}, - {"::tk::canvas", NULL, Tk_CanvasObjCmd, NULL, PASSMAINWINDOW|ISSAFE}, - {"::tk::checkbutton",NULL, Tk_CheckbuttonObjCmd, NULL, ISSAFE}, - {"::tk::entry", NULL, Tk_EntryObjCmd, NULL, ISSAFE}, - {"::tk::frame", NULL, Tk_FrameObjCmd, NULL, ISSAFE}, - {"::tk::label", NULL, Tk_LabelObjCmd, NULL, ISSAFE}, - {"::tk::labelframe",NULL, Tk_LabelframeObjCmd, NULL, ISSAFE}, - {"::tk::listbox", NULL, Tk_ListboxObjCmd, NULL, ISSAFE}, - {"::tk::menubutton",NULL, Tk_MenubuttonObjCmd, NULL, ISSAFE}, - {"::tk::message", NULL, Tk_MessageObjCmd, NULL, ISSAFE}, - {"::tk::panedwindow",NULL, Tk_PanedWindowObjCmd, NULL, ISSAFE}, - {"::tk::radiobutton",NULL, Tk_RadiobuttonObjCmd, NULL, ISSAFE}, - {"::tk::scale", NULL, Tk_ScaleObjCmd, NULL, ISSAFE}, - {"::tk::scrollbar", Tk_ScrollbarCmd,NULL, NULL, PASSMAINWINDOW|ISSAFE}, - {"::tk::spinbox", NULL, Tk_SpinboxObjCmd, NULL, ISSAFE}, - {"::tk::text", NULL, Tk_TextObjCmd, NULL, PASSMAINWINDOW|ISSAFE}, - {"::tk::toplevel", NULL, Tk_ToplevelObjCmd, NULL, 0}, + {"::tk::button", Tk_ButtonObjCmd, ISSAFE}, + {"::tk::canvas", Tk_CanvasObjCmd, PASSMAINWINDOW|ISSAFE}, + {"::tk::checkbutton",Tk_CheckbuttonObjCmd, ISSAFE}, + {"::tk::entry", Tk_EntryObjCmd, ISSAFE}, + {"::tk::frame", Tk_FrameObjCmd, ISSAFE}, + {"::tk::label", Tk_LabelObjCmd, ISSAFE}, + {"::tk::labelframe",Tk_LabelframeObjCmd, ISSAFE}, + {"::tk::listbox", Tk_ListboxObjCmd, ISSAFE}, + {"::tk::menubutton",Tk_MenubuttonObjCmd, ISSAFE}, + {"::tk::message", Tk_MessageObjCmd, ISSAFE}, + {"::tk::panedwindow",Tk_PanedWindowObjCmd, ISSAFE}, + {"::tk::radiobutton",Tk_RadiobuttonObjCmd, ISSAFE}, + {"::tk::scale", Tk_ScaleObjCmd, ISSAFE}, + {"::tk::scrollbar", (Tcl_ObjCmdProc *) Tk_ScrollbarCmd, NOOBJPROC|PASSMAINWINDOW|ISSAFE}, + {"::tk::spinbox", Tk_SpinboxObjCmd, ISSAFE}, + {"::tk::text", Tk_TextObjCmd, PASSMAINWINDOW|ISSAFE}, + {"::tk::toplevel", Tk_ToplevelObjCmd, 0}, /* * Standard dialog support. Note that the Unix/X11 platform implements @@ -183,11 +184,11 @@ static const TkCmd commands[] = { */ #if defined(__WIN32__) || defined(MAC_OSX_TK) - {"tk_chooseColor", NULL, Tk_ChooseColorObjCmd, NULL, PASSMAINWINDOW}, - {"tk_chooseDirectory", NULL, Tk_ChooseDirectoryObjCmd,NULL,PASSMAINWINDOW}, - {"tk_getOpenFile", NULL, Tk_GetOpenFileObjCmd, NULL, PASSMAINWINDOW}, - {"tk_getSaveFile", NULL, Tk_GetSaveFileObjCmd, NULL, PASSMAINWINDOW}, - {"tk_messageBox", NULL, Tk_MessageBoxObjCmd, NULL, PASSMAINWINDOW}, + {"tk_chooseColor", Tk_ChooseColorObjCmd, PASSMAINWINDOW}, + {"tk_chooseDirectory", Tk_ChooseDirectoryObjCmd,WINMACONLY|PASSMAINWINDOW}, + {"tk_getOpenFile", Tk_GetOpenFileObjCmd, WINMACONLY|PASSMAINWINDOW}, + {"tk_getSaveFile", Tk_GetSaveFileObjCmd, WINMACONLY|PASSMAINWINDOW}, + {"tk_messageBox", Tk_MessageBoxObjCmd, PASSMAINWINDOW}, #endif /* @@ -196,9 +197,9 @@ static const TkCmd commands[] = { #if defined(MAC_OSX_TK) {"::tk::unsupported::MacWindowStyle", - NULL, TkUnsupported1ObjCmd, NULL, PASSMAINWINDOW|ISSAFE}, + TkUnsupported1ObjCmd, PASSMAINWINDOW|ISSAFE}, #endif - {NULL, NULL, NULL, NULL, 0} + {NULL, NULL, 0} }; /* @@ -858,6 +859,9 @@ TkCreateMainWindow( { Tk_Window tkwin; int dummy, isSafe; +#ifdef __WIN32__ + int isWin32 = 0; +#endif Tcl_HashEntry *hPtr; register TkMainInfo *mainPtr; register TkWindow *winPtr; @@ -865,6 +869,14 @@ TkCreateMainWindow( ClientData clientData; ThreadSpecificData *tsdPtr = 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 @@ -946,20 +958,24 @@ TkCreateMainWindow( isSafe = Tcl_IsSafe(interp); for (cmdPtr = commands; cmdPtr->name != NULL; cmdPtr++) { - if ((cmdPtr->cmdProc == NULL) && (cmdPtr->objProc == NULL) - && (cmdPtr->initProc == 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 = tkwin; } else { clientData = NULL; } - if (cmdPtr->initProc != NULL) { - cmdPtr->initProc(interp, clientData); - } else if (cmdPtr->cmdProc != NULL) { - Tcl_CreateCommand(interp, cmdPtr->name, cmdPtr->cmdProc, - clientData, NULL); + if (cmdPtr->flags & USEINITPROC) { + ((TkInitProc *)cmdPtr->objProc)(interp, clientData); + } else 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); |