diff options
-rw-r--r-- | ChangeLog | 25 | ||||
-rw-r--r-- | doc/CrtWindow.3 | 15 | ||||
-rw-r--r-- | generic/tk.decls | 8 | ||||
-rw-r--r-- | generic/tk.h | 5 | ||||
-rw-r--r-- | generic/tkCmds.c | 8 | ||||
-rw-r--r-- | generic/tkDecls.h | 11 | ||||
-rw-r--r-- | generic/tkStubInit.c | 3 | ||||
-rw-r--r-- | generic/tkWindow.c | 115 |
8 files changed, 170 insertions, 20 deletions
@@ -1,3 +1,28 @@ +2000-10-05 Eric Melski <ericm@ajubasolutions.com> + + * generic/tkCmds.c (Tk_WinfoObjCmd): Added check for + TK_ANONYMOUS_WINDOW flag in the [winfo children] subcommand; if + set, the window will not be printed in the list of children. + + * doc/CrtWindow.3: Added entry for Tk_CreateAnonymousWindow. + + * generic/tkWindow.c + (Tk_CreateAnonymousWindow): New API for creating anonymous + windows. These windows are manipulable from C, but not from Tcl, + because they have no pathname associated with them. They are used + initially by widgets that do rubber-band resizing (panedwindow, + multi-column listbox, etc.), and may be useful for other widgets + as well (dropbox, combobox). + (Tk_DestroyWindow): Added check for TK_ANONYMOUS_WINDOW flag when + determining whether to generate a DestroyNotify event. + + * generic/tkStubInit.c: + * generic/tkDecls.h: Regen'd from tk.decls. + + * generic/tk.decls: Added Tk_CreateAnonymousWindow declaration. + + * generic/tk.h: Added TK_ANONYMOUS_WINDOW flag for Tk_Window's. + 2000-10-04 Eric Melski <ericm@ajubasolutions.com> * doc/MaintGeom.3: Noted that Tk_MaintainGeometry handles direct diff --git a/doc/CrtWindow.3 b/doc/CrtWindow.3 index a080e7c..874d76e 100644 --- a/doc/CrtWindow.3 +++ b/doc/CrtWindow.3 @@ -5,7 +5,7 @@ '\" See the file "license.terms" for information on usage and redistribution '\" of this file, and for a DISCLAIMER OF ALL WARRANTIES. '\" -'\" RCS: @(#) $Id: CrtWindow.3,v 1.4 1999/04/21 21:53:21 rjohnson Exp $ +'\" RCS: @(#) $Id: CrtWindow.3,v 1.5 2000/10/05 18:31:24 ericm Exp $ '\" .so man.macros .TH Tk_CreateWindow 3 4.2 Tk "Tk Library Procedures" @@ -20,6 +20,9 @@ Tk_Window \fBTk_CreateWindow\fR(\fIinterp, parent, name, topLevScreen\fR) .sp Tk_Window +\fBTk_CreateAnonymousWindow\fR(\fIinterp, parent, topLevScreen\fR) +.sp +Tk_Window \fBTk_CreateWindowFromPath\fR(\fIinterp, tkwin, pathName, topLevScreen\fR) .sp \fBTk_DestroyWindow\fR(\fItkwin\fR) @@ -51,9 +54,9 @@ Name of new window, specified as path name within application .SH DESCRIPTION .PP -The procedures \fBTk_CreateWindow\fR +The procedures \fBTk_CreateWindow\fR, .VS -and \fBTk_CreateWindowFromPath\fR +\fBTk_CreateAnonymousWindow\fR, and \fBTk_CreateWindowFromPath\fR are used to create new windows for use in Tk-based applications. Each of the procedures returns a token that can be used to manipulate the window in other calls to the Tk @@ -86,6 +89,12 @@ menu's \fIparent\fR would be the button-like window used to invoke it, which would in turn be a child of the menu bar window. A dialog box might have the application's main window as its parent. .PP +\fBTk_CreateAnonymousWindow\fR differs from \fBTk_CreateWindow\fR in +that it creates an unnamed window. This window will be manipulable +only using C interfaces, and will not be visible to Tcl scripts. Both +interior windows and top-level windows may be created with +\fBTk_CreateAnonymousWindow\fR. +.PP \fBTk_CreateWindowFromPath\fR offers an alternate way of specifying new windows. In \fBTk_CreateWindowFromPath\fR the new window is specified with a token for any window in the target diff --git a/generic/tk.decls b/generic/tk.decls index 2843334..e33006f 100644 --- a/generic/tk.decls +++ b/generic/tk.decls @@ -11,7 +11,7 @@ # See the file "license.terms" for information on usage and redistribution # of this file, and for a DISCLAIMER OF ALL WARRANTIES. # -# RCS: @(#) $Id: tk.decls,v 1.11 2000/06/03 08:58:14 hobbs Exp $ +# RCS: @(#) $Id: tk.decls,v 1.12 2000/10/05 18:31:25 ericm Exp $ library tk @@ -1136,6 +1136,12 @@ declare 240 generic { void Tk_DeleteClientMessageHandler (Tk_ClientMessageProc *proc) } +declare 241 generic { + Tk_Window Tk_CreateAnonymousWindow (Tcl_Interp *interp, \ + Tk_Window parent, char *screenName) +} + + # Define the platform specific public Tk interface. These functions are # only available on the designated platform. diff --git a/generic/tk.h b/generic/tk.h index e372b3c..206c864 100644 --- a/generic/tk.h +++ b/generic/tk.h @@ -12,7 +12,7 @@ * See the file "license.terms" for information on usage and redistribution * of this file, and for a DISCLAIMER OF ALL WARRANTIES. * - * RCS: @(#) $Id: tk.h,v 1.51 2000/09/29 17:55:31 ericm Exp $ + * RCS: @(#) $Id: tk.h,v 1.52 2000/10/05 18:31:25 ericm Exp $ */ #ifndef _TK @@ -783,6 +783,8 @@ typedef struct Tk_FakeWin { * concerned it isn't a child of its Tk * parent. Initially this is used only for * special Unix menubar windows. + * TK_ANONYMOUS_WINDOW: 1 means that this window has no name, and is + * thus not accessible from Tk. */ @@ -800,6 +802,7 @@ typedef struct Tk_FakeWin { #define TK_DEFER_MODAL 0x800 #define TK_WRAPPER 0x1000 #define TK_REPARENTED 0x2000 +#define TK_ANONYMOUS_WINDOW 0x4000 /* *-------------------------------------------------------------- diff --git a/generic/tkCmds.c b/generic/tkCmds.c index 4d3f5ae..6be5557 100644 --- a/generic/tkCmds.c +++ b/generic/tkCmds.c @@ -11,7 +11,7 @@ * See the file "license.terms" for information on usage and redistribution * of this file, and for a DISCLAIMER OF ALL WARRANTIES. * - * RCS: @(#) $Id: tkCmds.c,v 1.18 2000/08/04 00:46:32 ericm Exp $ + * RCS: @(#) $Id: tkCmds.c,v 1.19 2000/10/05 18:31:25 ericm Exp $ */ #include "tkPort.h" @@ -1081,8 +1081,10 @@ Tk_WinfoObjCmd(clientData, interp, objc, objv) winPtr = winPtr->childList; for ( ; winPtr != NULL; winPtr = winPtr->nextPtr) { - strPtr = Tcl_NewStringObj(winPtr->pathName, -1); - Tcl_ListObjAppendElement(NULL, resultPtr, strPtr); + if (!(winPtr->flags & TK_ANONYMOUS_WINDOW)) { + strPtr = Tcl_NewStringObj(winPtr->pathName, -1); + Tcl_ListObjAppendElement(NULL, resultPtr, strPtr); + } } break; } diff --git a/generic/tkDecls.h b/generic/tkDecls.h index edd169e..31f5808 100644 --- a/generic/tkDecls.h +++ b/generic/tkDecls.h @@ -8,7 +8,7 @@ * See the file "license.terms" for information on usage and redistribution * of this file, and for a DISCLAIMER OF ALL WARRANTIES. * - * RCS: @(#) $Id: tkDecls.h,v 1.12 2000/06/03 08:58:15 hobbs Exp $ + * RCS: @(#) $Id: tkDecls.h,v 1.13 2000/10/05 18:31:25 ericm Exp $ */ #ifndef _TKDECLS @@ -826,6 +826,10 @@ EXTERN void Tk_CreateClientMessageHandler _ANSI_ARGS_(( /* 240 */ EXTERN void Tk_DeleteClientMessageHandler _ANSI_ARGS_(( Tk_ClientMessageProc * proc)); +/* 241 */ +EXTERN Tk_Window Tk_CreateAnonymousWindow _ANSI_ARGS_(( + Tcl_Interp * interp, Tk_Window parent, + char * screenName)); typedef struct TkStubHooks { struct TkPlatStubs *tkPlatStubs; @@ -1079,6 +1083,7 @@ typedef struct TkStubs { int (*tk_PostscriptPhoto) _ANSI_ARGS_((Tcl_Interp * interp, Tk_PhotoImageBlock * blockPtr, Tk_PostscriptInfo psInfo, int width, int height)); /* 238 */ void (*tk_CreateClientMessageHandler) _ANSI_ARGS_((Tk_ClientMessageProc * proc)); /* 239 */ void (*tk_DeleteClientMessageHandler) _ANSI_ARGS_((Tk_ClientMessageProc * proc)); /* 240 */ + Tk_Window (*tk_CreateAnonymousWindow) _ANSI_ARGS_((Tcl_Interp * interp, Tk_Window parent, char * screenName)); /* 241 */ } TkStubs; #ifdef __cplusplus @@ -2053,6 +2058,10 @@ extern TkStubs *tkStubsPtr; #define Tk_DeleteClientMessageHandler \ (tkStubsPtr->tk_DeleteClientMessageHandler) /* 240 */ #endif +#ifndef Tk_CreateAnonymousWindow +#define Tk_CreateAnonymousWindow \ + (tkStubsPtr->tk_CreateAnonymousWindow) /* 241 */ +#endif #endif /* defined(USE_TK_STUBS) && !defined(USE_TK_STUB_PROCS) */ diff --git a/generic/tkStubInit.c b/generic/tkStubInit.c index 67a2add..2fe2b7f 100644 --- a/generic/tkStubInit.c +++ b/generic/tkStubInit.c @@ -8,7 +8,7 @@ * See the file "license.terms" for information on usage and redistribution * of this file, and for a DISCLAIMER OF ALL WARRANTIES. * - * RCS: @(#) $Id: tkStubInit.c,v 1.23 2000/06/03 08:58:16 hobbs Exp $ + * RCS: @(#) $Id: tkStubInit.c,v 1.24 2000/10/05 18:31:26 ericm Exp $ */ #include "tkInt.h" @@ -951,6 +951,7 @@ TkStubs tkStubs = { Tk_PostscriptPhoto, /* 238 */ Tk_CreateClientMessageHandler, /* 239 */ Tk_DeleteClientMessageHandler, /* 240 */ + Tk_CreateAnonymousWindow, /* 241 */ }; /* !END!: Do not edit above this line. */ diff --git a/generic/tkWindow.c b/generic/tkWindow.c index 09b24c5..9ec1d12 100644 --- a/generic/tkWindow.c +++ b/generic/tkWindow.c @@ -12,7 +12,7 @@ * See the file "license.terms" for information on usage and redistribution * of this file, and for a DISCLAIMER OF ALL WARRANTIES. * - * RCS: @(#) $Id: tkWindow.c,v 1.25 2000/08/08 19:21:20 ericm Exp $ + * RCS: @(#) $Id: tkWindow.c,v 1.26 2000/10/05 18:31:26 ericm Exp $ */ #include "tkPort.h" @@ -199,7 +199,8 @@ static Tk_ArgvInfo argTable[] = { */ static Tk_Window CreateTopLevelWindow _ANSI_ARGS_((Tcl_Interp *interp, - Tk_Window parent, char *name, char *screenName)); + Tk_Window parent, char *name, char *screenName, + unsigned int flags)); static void DeleteWindowsExitProc _ANSI_ARGS_(( ClientData clientData)); static TkDisplay * GetScreen _ANSI_ARGS_((Tcl_Interp *interp, @@ -234,7 +235,7 @@ static void UnlinkWindow _ANSI_ARGS_((TkWindow *winPtr)); */ static Tk_Window -CreateTopLevelWindow(interp, parent, name, screenName) +CreateTopLevelWindow(interp, parent, name, screenName, flags) Tcl_Interp *interp; /* Interpreter to use for error reporting. */ Tk_Window parent; /* Token for logical parent of new window * (used for naming, options, etc.). May @@ -247,6 +248,7 @@ CreateTopLevelWindow(interp, parent, name, screenName) * variable to determine. Empty string means * use parent's screen, or DISPLAY if no * parent. */ + unsigned int flags; /* Additional flags to set on the window. */ { register TkWindow *winPtr; register TkDisplay *dispPtr; @@ -292,6 +294,11 @@ CreateTopLevelWindow(interp, parent, name, screenName) winPtr = TkAllocWindow(dispPtr, screenId, (TkWindow *) parent); /* + * Set the flags specified in the call. + */ + winPtr->flags |= flags; + + /* * Force the window to use a border pixel instead of border pixmap. * This is needed for the case where the window doesn't use the * default visual. In this case, the default border is a pixmap @@ -699,6 +706,19 @@ NameWindow(interp, winPtr, parentPtr, name) parentPtr->lastChildPtr = winPtr; winPtr->mainPtr = parentPtr->mainPtr; winPtr->mainPtr->refCount++; + + /* + * If this is an anonymous window (ie, it has no name), just return OK + * now. + */ + if (winPtr->flags & TK_ANONYMOUS_WINDOW) { + return TCL_OK; + } + + /* + * For non-anonymous windows, set up the window name. + */ + winPtr->nameUid = Tk_GetUid(name); /* @@ -808,7 +828,7 @@ TkCreateMainWindow(interp, screenName, baseName) */ tkwin = CreateTopLevelWindow(interp, (Tk_Window) NULL, baseName, - screenName); + screenName, /* flags */ 0); if (tkwin == NULL) { return NULL; } @@ -959,7 +979,81 @@ Tk_CreateWindow(interp, parent, name, screenName) return (Tk_Window) winPtr; } } else { - return CreateTopLevelWindow(interp, parent, name, screenName); + return CreateTopLevelWindow(interp, parent, name, screenName, + /* flags */ 0); + } +} + +/* + *-------------------------------------------------------------- + * + * Tk_CreateAnonymousWindow -- + * + * Create a new internal or top-level window as a child of an + * existing window; this window will be anonymous (unnamed), so + * it will not be visible at the Tcl level. + * + * Results: + * The return value is a token for the new window. This + * is not the same as X's token for the window. If an error + * occurred in creating the window (e.g. no such display or + * screen), then an error message is left in the interp's result and + * NULL is returned. + * + * Side effects: + * A new window structure is allocated locally. An X + * window is not initially created, but will be created + * the first time the window is mapped. + * + *-------------------------------------------------------------- + */ + +Tk_Window +Tk_CreateAnonymousWindow(interp, parent, screenName) + Tcl_Interp *interp; /* Interpreter to use for error reporting. + * the interp's result is assumed to be + * initialized by the caller. */ + Tk_Window parent; /* Token for parent of new window. */ + char *screenName; /* If NULL, new window will be internal on + * same screen as its parent. If non-NULL, + * gives name of screen on which to create + * new window; window will be a top-level + * window. */ +{ + TkWindow *parentPtr = (TkWindow *) parent; + TkWindow *winPtr; + + if ((parentPtr != NULL) && (parentPtr->flags & TK_ALREADY_DEAD)) { + Tcl_AppendResult(interp, + "can't create window: parent has been destroyed", + (char *) NULL); + return NULL; + } else if ((parentPtr != NULL) && + (parentPtr->flags & TK_CONTAINER)) { + Tcl_AppendResult(interp, + "can't create window: its parent has -container = yes", + (char *) NULL); + return NULL; + } + if (screenName == NULL) { + winPtr = TkAllocWindow(parentPtr->dispPtr, parentPtr->screenNum, + parentPtr); + /* + * Add the anonymous window flag now, so that NameWindow will behave + * correctly. + */ + + winPtr->flags |= TK_ANONYMOUS_WINDOW; + if (NameWindow(interp, winPtr, parentPtr, (char *)NULL) != TCL_OK) { + Tk_DestroyWindow((Tk_Window) winPtr); + return NULL; + } else { + return (Tk_Window) winPtr; + } + return (Tk_Window) winPtr; + } else { + return CreateTopLevelWindow(interp, parent, (char *)NULL, screenName, + TK_ANONYMOUS_WINDOW); } } @@ -1080,7 +1174,7 @@ Tk_CreateWindowFromPath(interp, tkwin, pathName, screenName) } } else { return CreateTopLevelWindow(interp, parent, pathName+numChars+1, - screenName); + screenName, /* flags */ 0); } } @@ -1219,12 +1313,13 @@ Tk_DestroyWindow(tkwin) * expensive, but without it no event handlers will get called for * windows that don't exist yet. * - * Note: if the window's pathName is NULL it means that the window - * was not successfully initialized in the first place, so we should - * not make the window exist or generate the event. + * Note: if the window's pathName is NULL and the window is not an + * anonymous window, it means that the window was not successfully + * initialized in the first place, so we should not make the window exist + * or generate the event. */ - if (winPtr->pathName != NULL) { + if (winPtr->pathName != NULL && !(winPtr->flags & TK_ANONYMOUS_WINDOW)) { if (winPtr->window == None) { Tk_MakeWindowExist(tkwin); } |