From 4658a19f9128ef93ebd4e5052547f4cf2176516e Mon Sep 17 00:00:00 2001 From: "jan.nijtmans" Date: Wed, 15 Jul 2020 13:54:55 +0000 Subject: Add documentation. Let ttk use the new Tk_SendVirtualEvent --- doc/EventHndlr.3 | 17 ++++++++++++++++- doc/GetPixels.3 | 8 +++++++- doc/WindowId.3 | 12 +++++++++++- generic/tk.decls | 4 ++-- generic/tkDecls.h | 4 ++-- generic/ttk/ttkInit.c | 22 ---------------------- generic/ttk/ttkNotebook.c | 4 ++-- generic/ttk/ttkPanedwindow.c | 2 +- generic/ttk/ttkTreeview.c | 4 ++-- generic/ttk/ttkWidget.h | 5 ----- 10 files changed, 43 insertions(+), 39 deletions(-) diff --git a/doc/EventHndlr.3 b/doc/EventHndlr.3 index a2cbf8d..cbc5b79 100644 --- a/doc/EventHndlr.3 +++ b/doc/EventHndlr.3 @@ -9,7 +9,7 @@ .so man.macros .BS .SH NAME -Tk_CreateEventHandler, Tk_DeleteEventHandler \- associate procedure callback with an X event +Tk_CreateEventHandler, Tk_DeleteEventHandler, Tk_GetButtonMask, Tk_SendVirtualEvent \- associate procedure callback with an X event .SH SYNOPSIS .nf \fB#include \fR @@ -17,8 +17,18 @@ Tk_CreateEventHandler, Tk_DeleteEventHandler \- associate procedure callback wit \fBTk_CreateEventHandler\fR(\fItkwin, mask, proc, clientData\fR) .sp \fBTk_DeleteEventHandler\fR(\fItkwin, mask, proc, clientData\fR) +.sp +\fBTk_GetButtonMask\fR(\fIbutton\fR) +.sp +\fBTk_SendVirtualEvent\fR(\fItkwin, eventName, detail\fR) .SH ARGUMENTS .AS "unsigned long" clientData +.AP unsigned button in +Button number. +.AP "const char" *eventName in +The name of the virtual event. +.AP Tcl_Obj *detail in +Detail information for the virtual event. .AP Tk_Window tkwin in Token for window in which events may occur. .AP "unsigned long" mask in @@ -71,5 +81,10 @@ automatically; in this case there is no need to call If multiple handlers are declared for the same type of X event on the same window, then the handlers will be invoked in the order they were created. +.PP +\fBTk_GetButtonMask\fR returns the button mask corresponding to +the button. E.g it will return \fIButton1Mask\fR for button \fIButton1\fR. +.PP +\fBTk_SendVirtualEvent\fR sends a virtual event to Tk's event queue. .SH KEYWORDS bind, callback, event, handler diff --git a/doc/GetPixels.3 b/doc/GetPixels.3 index 6c31af9..568c601 100644 --- a/doc/GetPixels.3 +++ b/doc/GetPixels.3 @@ -9,7 +9,7 @@ .so man.macros .BS .SH NAME -Tk_GetPixelsFromObj, Tk_GetPixels, Tk_GetMMFromObj, Tk_GetScreenMM \- translate between strings and screen units +Tk_GetPixelsFromObj, Tk_GetPixels, Tk_GetMMFromObj, Tk_GetScreenMM, Tk_GetDoublePixelsFromObj \- translate between strings and screen units .SH SYNOPSIS .nf \fB#include \fR @@ -18,6 +18,9 @@ int \fBTk_GetPixelsFromObj(\fIinterp, tkwin, objPtr, intPtr\fB)\fR .sp int +\fBTk_GetDoublePixelsFromObj(\fIinterp, tkwin, objPtr, doublePtr\fB)\fR +.sp +int \fBTk_GetPixels(\fIinterp, tkwin, string, intPtr\fB)\fR .sp int @@ -81,6 +84,9 @@ in \fIinterp\fR's result if \fIinterp\fR is not NULL. value in \fIobjPtr\fR, which speeds up future calls to \fBTk_GetPixelsFromObj\fR with the same \fIobjPtr\fR. .PP +\fBTk_GetDoublePixelsFromObj\fR is identical to \fBTk_GetPixelsFromObj\fR +except it returns a double not rounded to the nearest integer. +.PP \fBTk_GetPixels\fR is identical to \fBTk_GetPixelsFromObj\fR except that the screen distance is specified with a string instead of an object. This prevents \fBTk_GetPixels\fR from caching the diff --git a/doc/WindowId.3 b/doc/WindowId.3 index f937963..477efe1 100644 --- a/doc/WindowId.3 +++ b/doc/WindowId.3 @@ -9,7 +9,7 @@ .so man.macros .BS .SH NAME -Tk_WindowId, Tk_Parent, Tk_Display, Tk_DisplayName, Tk_ScreenNumber, Tk_Screen, Tk_X, Tk_Y, Tk_Width, Tk_Height, Tk_Changes, Tk_Attributes, Tk_IsContainer, Tk_IsEmbedded, Tk_IsMapped, Tk_IsTopLevel, Tk_ReqWidth, Tk_ReqHeight, Tk_MinReqWidth, Tk_MinReqHeight, Tk_InternalBorderLeft, Tk_InternalBorderRight, Tk_InternalBorderTop, Tk_InternalBorderBottom, Tk_Visual, Tk_Depth, Tk_Colormap, Tk_Interp \- retrieve information from Tk's local data structure +Tk_WindowId, Tk_Parent, Tk_Display, Tk_DisplayName, Tk_ScreenNumber, Tk_AlwaysShowSelection, Tk_Screen, Tk_X, Tk_Y, Tk_Width, Tk_Height, Tk_Changes, Tk_Attributes, Tk_IsContainer, Tk_IsEmbedded, Tk_IsMapped, Tk_IsTopLevel, Tk_ReqWidth, Tk_ReqHeight, Tk_MinReqWidth, Tk_MinReqHeight, Tk_InternalBorderLeft, Tk_InternalBorderRight, Tk_InternalBorderTop, Tk_InternalBorderBottom, Tk_Visual, Tk_Depth, Tk_Colormap, Tk_Interp, Tk_NewWindowObj \- retrieve information from Tk's local data structure .SH SYNOPSIS .nf \fB#include \fR @@ -29,6 +29,9 @@ const char * int \fBTk_ScreenNumber\fR(\fItkwin\fR) .sp +int +\fBTk_AlwaysShowSelection\fR(\fItkwin\fR) +.sp Screen * \fBTk_Screen\fR(\fItkwin\fR) .sp @@ -97,6 +100,9 @@ Colormap .sp Tcl_Interp * \fBTk_Interp\fR(\fItkwin\fR) +.sp +Tcl_Obj * +\fBTk_NewWindowObj\fR(\fItkwin\fR) .SH ARGUMENTS .AS Tk_Window tkwin .AP Tk_Window tkwin in @@ -127,6 +133,8 @@ ASCII string identifying \fItkwin\fR's display. \fBTk_ScreenNumber\fR returns the index of \fItkwin\fR's screen among all the screens of \fItkwin\fR's display. \fBTk_Screen\fR returns a pointer to the Xlib structure corresponding to \fItkwin\fR's screen. +\fBTk_AlwaysShowSelection\fR indicates whether text/entry widgets +should always display their selection, regardless of window focus. .PP \fBTk_X\fR, \fBTk_Y\fR, \fBTk_Width\fR, and \fBTk_Height\fR return information about \fItkwin's\fR location within its @@ -182,6 +190,8 @@ and \fBTk_Colormap\fR returns the current colormap for the window. The visual characteristics are normally set from the defaults for the window's screen, but they may be overridden by calling \fBTk_SetWindowVisual\fR. +.PP +\fBTk_NewWindowObj\fR creates a new \fBTcl_Obj\fR from the window. .SH KEYWORDS attributes, colormap, depth, display, height, geometry manager, identifier, mapped, requested size, screen, top-level, diff --git a/generic/tk.decls b/generic/tk.decls index b69df7b..0184f86 100644 --- a/generic/tk.decls +++ b/generic/tk.decls @@ -1069,7 +1069,7 @@ declare 273 { void Tk_CreateOldPhotoImageFormat(const Tk_PhotoImageFormat *formatPtr) } -# TIP #??? +# TIP#580 declare 274 { int Tk_AlwaysShowSelection(Tk_Window tkwin) } @@ -1084,7 +1084,7 @@ declare 277 { Tcl_Obj *Tk_NewWindowObj(Tk_Window tkwin) } declare 278 { - void Tk_SendVirtualEvent(Tk_Window tgtWin, const char *eventName, + void Tk_SendVirtualEvent(Tk_Window tkwin, const char *eventName, Tcl_Obj *detail) } diff --git a/generic/tkDecls.h b/generic/tkDecls.h index f521c09..e55854c 100644 --- a/generic/tkDecls.h +++ b/generic/tkDecls.h @@ -889,7 +889,7 @@ EXTERN int Tk_GetDoublePixelsFromObj(Tcl_Interp *interp, /* 277 */ EXTERN Tcl_Obj * Tk_NewWindowObj(Tk_Window tkwin); /* 278 */ -EXTERN void Tk_SendVirtualEvent(Tk_Window tgtWin, +EXTERN void Tk_SendVirtualEvent(Tk_Window tkwin, const char *eventName, Tcl_Obj *detail); typedef struct { @@ -1181,7 +1181,7 @@ typedef struct TkStubs { unsigned (*tk_GetButtonMask) (unsigned button); /* 275 */ int (*tk_GetDoublePixelsFromObj) (Tcl_Interp *interp, Tk_Window tkwin, Tcl_Obj *objPtr, double *doublePtr); /* 276 */ Tcl_Obj * (*tk_NewWindowObj) (Tk_Window tkwin); /* 277 */ - void (*tk_SendVirtualEvent) (Tk_Window tgtWin, const char *eventName, Tcl_Obj *detail); /* 278 */ + void (*tk_SendVirtualEvent) (Tk_Window tkwin, const char *eventName, Tcl_Obj *detail); /* 278 */ } TkStubs; extern const TkStubs *tkStubsPtr; diff --git a/generic/ttk/ttkInit.c b/generic/ttk/ttkInit.c index f14a2db..4a43253 100644 --- a/generic/ttk/ttkInit.c +++ b/generic/ttk/ttkInit.c @@ -124,28 +124,6 @@ void TtkCheckStateOption(WidgetCore *corePtr, Tcl_Obj *objPtr) # undef SETFLAGS } -/* TtkSendVirtualEvent -- - * Send a virtual event notification to the specified target window. - * Equivalent to "event generate $tgtWindow <<$eventName>>" - * - * Note that we use Tk_QueueWindowEvent, not Tk_HandleEvent, - * so this routine does not reenter the interpreter. - */ -void TtkSendVirtualEvent(Tk_Window tgtWin, const char *eventName) -{ - union {XEvent general; XVirtualEvent virt;} event; - - memset(&event, 0, sizeof(event)); - event.general.xany.type = VirtualEvent; - event.general.xany.serial = NextRequest(Tk_Display(tgtWin)); - event.general.xany.send_event = False; - event.general.xany.window = Tk_WindowId(tgtWin); - event.general.xany.display = Tk_Display(tgtWin); - event.virt.name = Tk_GetUid(eventName); - - Tk_QueueWindowEvent(&event.general, TCL_QUEUE_TAIL); -} - /* TtkEnumerateOptions, TtkGetOptionValue -- * Common factors for data accessor commands. */ diff --git a/generic/ttk/ttkNotebook.c b/generic/ttk/ttkNotebook.c index 7ad46a4..d0151f7 100644 --- a/generic/ttk/ttkNotebook.c +++ b/generic/ttk/ttkNotebook.c @@ -631,7 +631,7 @@ static void SelectTab(Notebook *nb, TkSizeT index) NotebookPlaceSlave(nb, index); TtkRedisplayWidget(&nb->core); - TtkSendVirtualEvent(nb->core.tkwin, "NotebookTabChanged"); + Tk_SendVirtualEvent(nb->core.tkwin, "NotebookTabChanged", NULL); } /* NextTab -- @@ -683,7 +683,7 @@ static void SelectNearestTab(Notebook *nb) Ttk_UnmapSlave(nb->notebook.mgr, currentIndex); } if (currentIndex != nextIndex) { - TtkSendVirtualEvent(nb->core.tkwin, "NotebookTabChanged"); + Tk_SendVirtualEvent(nb->core.tkwin, "NotebookTabChanged", NULL); } nb->notebook.currentIndex = nextIndex; diff --git a/generic/ttk/ttkPanedwindow.c b/generic/ttk/ttkPanedwindow.c index f44c569..5d925de 100644 --- a/generic/ttk/ttkPanedwindow.c +++ b/generic/ttk/ttkPanedwindow.c @@ -486,7 +486,7 @@ static void PanedEventProc(ClientData clientData, XEvent *eventPtr) if ( eventPtr->type == LeaveNotify && eventPtr->xcrossing.detail == NotifyInferior) { - TtkSendVirtualEvent(corePtr->tkwin, "EnteredChild"); + Tk_SendVirtualEvent(corePtr->tkwin, "EnteredChild", NULL); } } diff --git a/generic/ttk/ttkTreeview.c b/generic/ttk/ttkTreeview.c index b484d1c..cab9c34 100644 --- a/generic/ttk/ttkTreeview.c +++ b/generic/ttk/ttkTreeview.c @@ -2730,7 +2730,7 @@ static int TreeviewDeleteCommand( ckfree(items); if (selItemDeleted) { - TtkSendVirtualEvent(tv->core.tkwin, "TreeviewSelect"); + Tk_SendVirtualEvent(tv->core.tkwin, "TreeviewSelect", NULL); } TtkRedisplayWidget(&tv->core); return TCL_OK; @@ -3011,7 +3011,7 @@ static int TreeviewSelectionCommand( } ckfree(items); - TtkSendVirtualEvent(tv->core.tkwin, "TreeviewSelect"); + Tk_SendVirtualEvent(tv->core.tkwin, "TreeviewSelect", NULL); TtkRedisplayWidget(&tv->core); return TCL_OK; diff --git a/generic/ttk/ttkWidget.h b/generic/ttk/ttkWidget.h index 6837d89..2eeab4e 100644 --- a/generic/ttk/ttkWidget.h +++ b/generic/ttk/ttkWidget.h @@ -165,11 +165,6 @@ MODULE_SCOPE void Ttk_UntraceVariable(Ttk_TraceHandle *); MODULE_SCOPE int Ttk_FireTrace(Ttk_TraceHandle *); /* - * Virtual events: - */ -MODULE_SCOPE void TtkSendVirtualEvent(Tk_Window tgtWin, const char *eventName); - -/* * Helper routines for data accessor commands: */ MODULE_SCOPE int TtkEnumerateOptions( -- cgit v0.12