⭐ 欢迎来到虫虫下载站! | 📦 资源下载 📁 资源专辑 ℹ️ 关于我们
⭐ 虫虫下载站

📄 tkwinwindow.c

📁 linux系统下的音频通信
💻 C
📖 第 1 页 / 共 2 页
字号:
/*  * tkWinWindow.c -- * *	Xlib emulation routines for Windows related to creating, *	displaying and destroying windows. * * Copyright (c) 1995 Sun Microsystems, Inc. * * See the file "license.terms" for information on usage and redistribution * of this file, and for a DISCLAIMER OF ALL WARRANTIES. * * SCCS: @(#) tkWinWindow.c 1.23 97/07/01 18:14:13 */#include "tkWinInt.h"/* * The windowTable maps from HWND to Tk_Window handles. */static Tcl_HashTable windowTable;/* * Have statics in this module been initialized? */static int initialized = 0;/* * Forward declarations for procedures defined in this file: */static void		NotifyVisibility _ANSI_ARGS_((XEvent *eventPtr,			    TkWindow *winPtr));static void 		StackWindow _ANSI_ARGS_((Window w, Window sibling,			    int stack_mode));/* *---------------------------------------------------------------------- * * Tk_AttachHWND -- * *	This function binds an HWND and a reflection procedure to *	the specified Tk_Window.  * * Results: *	Returns an X Window that encapsulates the HWND. * * Side effects: *	May allocate a new X Window.  Also enters the HWND into the *	global window table. * *---------------------------------------------------------------------- */WindowTk_AttachHWND(tkwin, hwnd)    Tk_Window tkwin;    HWND hwnd;{    int new;    Tcl_HashEntry *entryPtr;    TkWinDrawable *twdPtr = (TkWinDrawable *) Tk_WindowId(tkwin);    if (!initialized) {	Tcl_InitHashTable(&windowTable, TCL_ONE_WORD_KEYS);	initialized = 1;    }    /*     * Allocate a new drawable if necessary.  Otherwise, remove the     * previous HWND from from the window table.     */    if (twdPtr == NULL) {	twdPtr = (TkWinDrawable*) ckalloc(sizeof(TkWinDrawable));	twdPtr->type = TWD_WINDOW;	twdPtr->window.winPtr = (TkWindow *) tkwin;    } else if (twdPtr->window.handle != NULL) {	entryPtr = Tcl_FindHashEntry(&windowTable,		(char *)twdPtr->window.handle);	Tcl_DeleteHashEntry(entryPtr);    }    /*     * Insert the new HWND into the window table.     */    twdPtr->window.handle = hwnd;    entryPtr = Tcl_CreateHashEntry(&windowTable, (char *)hwnd, &new);    Tcl_SetHashValue(entryPtr, (ClientData)tkwin);    return (Window)twdPtr;}/* *---------------------------------------------------------------------- * * Tk_HWNDToWindow -- * *	This function retrieves a Tk_Window from the window table *	given an HWND. * * Results: *	Returns the matching Tk_Window. * * Side effects: *	None. * *---------------------------------------------------------------------- */Tk_WindowTk_HWNDToWindow(hwnd)    HWND hwnd;{    Tcl_HashEntry *entryPtr;    if (!initialized) {	Tcl_InitHashTable(&windowTable, TCL_ONE_WORD_KEYS);	initialized = 1;    }    entryPtr = Tcl_FindHashEntry(&windowTable, (char*)hwnd);    if (entryPtr != NULL) {	return (Tk_Window) Tcl_GetHashValue(entryPtr);    }    return NULL;}/* *---------------------------------------------------------------------- * * Tk_GetHWND -- * *	This function extracts the HWND from an X Window. * * Results: *	Returns the HWND associated with the Window. * * Side effects: *	None. * *---------------------------------------------------------------------- */HWNDTk_GetHWND(window)    Window window;{    TkWinDrawable *twdPtr = (TkWinDrawable *) window;    return twdPtr->window.handle;}/* *---------------------------------------------------------------------- * * TkpPrintWindowId -- * *	This routine stores the string representation of the *	platform dependent window handle for an X Window in the *	given buffer. * * Results: *	Returns the result in the specified buffer. * * Side effects: *	None. * *---------------------------------------------------------------------- */voidTkpPrintWindowId(buf, window)    char *buf;			/* Pointer to string large enough to hold				 * the hex representation of a pointer. */    Window window;		/* Window to be printed into buffer. */{    HWND hwnd = (window) ? Tk_GetHWND(window) : 0;    sprintf(buf, "0x%x", (unsigned int) hwnd);}/* *---------------------------------------------------------------------- * * TkpScanWindowId -- * *	Given a string which represents the platform dependent window *	handle, produce the X Window id for the window. * * Results: *	The return value is normally TCL_OK;  in this case *idPtr *	will be set to the X Window id equivalent to string.  If *	string is improperly formed then TCL_ERROR is returned and *	an error message will be left in interp->result.  If the *	number does not correspond to a Tk Window, then *idPtr will *	be set to None. * * Side effects: *	None. * *---------------------------------------------------------------------- */intTkpScanWindowId(interp, string, idPtr)    Tcl_Interp *interp;		/* Interpreter to use for error reporting. */    char *string;		/* String containing a (possibly signed)				 * integer in a form acceptable to strtol. */    int *idPtr;			/* Place to store converted result. */{    int number;    Tk_Window tkwin;    if (Tcl_GetInt(interp, string, &number) != TCL_OK) {	return TCL_ERROR;    }    tkwin = Tk_HWNDToWindow((HWND)number);    if (tkwin) {	*idPtr = Tk_WindowId(tkwin);    } else {	*idPtr = None;    }    return TCL_OK;}/* *---------------------------------------------------------------------- * * TkpMakeWindow -- * *	Creates a Windows window object based on the current attributes *	of the specified TkWindow. * * Results: *	Returns a pointer to a new TkWinDrawable cast to a Window. * * Side effects: *	Creates a new window. * *---------------------------------------------------------------------- */WindowTkpMakeWindow(winPtr, parent)    TkWindow *winPtr;    Window parent;{    HWND parentWin;    int style;    HWND hwnd;        if (parent != None) {	parentWin = Tk_GetHWND(parent);	style = WS_CHILD | WS_CLIPCHILDREN | WS_CLIPSIBLINGS;    } else {	parentWin = NULL;	style = WS_POPUP | WS_CLIPCHILDREN;    }    /*     * Create the window, then ensure that it is at the top of the     * stacking order.     */    hwnd = CreateWindowEx(WS_EX_NOPARENTNOTIFY, TK_WIN_CHILD_CLASS_NAME, NULL,	    style, Tk_X(winPtr), Tk_Y(winPtr), Tk_Width(winPtr),	    Tk_Height(winPtr), parentWin, NULL, Tk_GetHINSTANCE(), NULL);    SetWindowPos(hwnd, HWND_TOP, 0, 0, 0, 0,		    SWP_NOACTIVATE | SWP_NOMOVE | SWP_NOSIZE);    return Tk_AttachHWND((Tk_Window)winPtr, hwnd);}/* *---------------------------------------------------------------------- * * XDestroyWindow -- * *	Destroys the given window. * * Results: *	None. * * Side effects: *	Sends the WM_DESTROY message to the window and then destroys *	it the Win32 resources associated with the window. * *---------------------------------------------------------------------- */voidXDestroyWindow(display, w)    Display* display;    Window w;{    Tcl_HashEntry *entryPtr;    TkWinDrawable *twdPtr = (TkWinDrawable *)w;    TkWindow *winPtr = TkWinGetWinPtr(w);    HWND hwnd = Tk_GetHWND(w);    display->request++;    /*     * Remove references to the window in the pointer module then     * release the drawable.     */    TkPointerDeadWindow(winPtr);    entryPtr = Tcl_FindHashEntry(&windowTable, (char*)hwnd);    if (entryPtr != NULL) {	Tcl_DeleteHashEntry(entryPtr);    }    ckfree((char *)twdPtr);    /*     * Don't bother destroying the window if we are going to destroy     * the parent later.     */    if (hwnd != NULL && !(winPtr->flags & TK_DONT_DESTROY_WINDOW)) {	DestroyWindow(hwnd);    }}/* *---------------------------------------------------------------------- * * XMapWindow -- * *	Cause the given window to become visible. * * Results: *	None * * Side effects: *	Causes the window state to change, and generates a MapNotify *	event. * *---------------------------------------------------------------------- */voidXMapWindow(display, w)    Display* display;    Window w;{    XEvent event;    TkWindow *parentPtr;    TkWindow *winPtr = TkWinGetWinPtr(w);    display->request++;    ShowWindow(TkWinGetHWND(w), SW_SHOWNORMAL);    winPtr->flags |= TK_MAPPED;    /*     * Check to see if this window is visible now.  If all of the parent     * windows up to the first toplevel are mapped, then this window and     * its mapped children have just become visible.     */    if (!(winPtr->flags & TK_TOP_LEVEL)) {	for (parentPtr = winPtr->parentPtr; ;	        parentPtr = parentPtr->parentPtr) {	    if ((parentPtr == NULL) || !(parentPtr->flags & TK_MAPPED)) {		return;	    }	    if (parentPtr->flags & TK_TOP_LEVEL) {		break;	    }	}    } else {	event.type = MapNotify;	event.xmap.serial = display->request;	event.xmap.send_event = False;	event.xmap.display = display;	event.xmap.event = winPtr->window;	event.xmap.window = winPtr->window;	event.xmap.override_redirect = winPtr->atts.override_redirect;	Tk_QueueWindowEvent(&event, TCL_QUEUE_TAIL);    }        /*     * Generate VisibilityNotify events for this window and its mapped     * children.     */    event.type = VisibilityNotify;    event.xvisibility.serial = display->request;    event.xvisibility.send_event = False;    event.xvisibility.display = display;    event.xvisibility.window = winPtr->window;    event.xvisibility.state = VisibilityUnobscured;    NotifyVisibility(&event, winPtr);}/* *---------------------------------------------------------------------- * * NotifyVisibility -- *

⌨️ 快捷键说明

复制代码 Ctrl + C
搜索代码 Ctrl + F
全屏模式 F11
切换主题 Ctrl + Shift + D
显示快捷键 ?
增大字号 Ctrl + =
减小字号 Ctrl + -