📄 tkwinwindow.c
字号:
* This function recursively notifies the mapped children of the * specified window of a change in visibility. Note that we don't * properly report the visibility state, since Windows does not * provide that info. The eventPtr argument must point to an event * that has been completely initialized except for the window slot. * * Results: * None. * * Side effects: * Generates lots of events. * *---------------------------------------------------------------------- */static voidNotifyVisibility(eventPtr, winPtr) XEvent *eventPtr; /* Initialized VisibilityNotify event. */ TkWindow *winPtr; /* Window to notify. */{ if (winPtr->atts.event_mask & VisibilityChangeMask) { eventPtr->xvisibility.window = winPtr->window; Tk_QueueWindowEvent(eventPtr, TCL_QUEUE_TAIL); } for (winPtr = winPtr->childList; winPtr != NULL; winPtr = winPtr->nextPtr) { if (winPtr->flags & TK_MAPPED) { NotifyVisibility(eventPtr, winPtr); } }}/* *---------------------------------------------------------------------- * * XUnmapWindow -- * * Cause the given window to become invisible. * * Results: * None * * Side effects: * Causes the window state to change, and generates an UnmapNotify * event. * *---------------------------------------------------------------------- */voidXUnmapWindow(display, w) Display* display; Window w;{ XEvent event; TkWindow *winPtr = TkWinGetWinPtr(w); display->request++; /* * Bug fix: Don't short circuit this routine based on TK_MAPPED because * it will be cleared before XUnmapWindow is called. */ ShowWindow(TkWinGetHWND(w), SW_HIDE); winPtr->flags &= ~TK_MAPPED; if (winPtr->flags & TK_TOP_LEVEL) { event.type = UnmapNotify; event.xunmap.serial = display->request; event.xunmap.send_event = False; event.xunmap.display = display; event.xunmap.event = winPtr->window; event.xunmap.window = winPtr->window; event.xunmap.from_configure = False; Tk_HandleEvent(&event); }}/* *---------------------------------------------------------------------- * * XMoveResizeWindow -- * * Move and resize a window relative to its parent. * * Results: * None. * * Side effects: * Repositions and resizes the specified window. * *---------------------------------------------------------------------- */voidXMoveResizeWindow(display, w, x, y, width, height) Display* display; Window w; int x; /* Position relative to parent. */ int y; unsigned int width; unsigned int height;{ display->request++; MoveWindow(TkWinGetHWND(w), x, y, width, height, TRUE);}/* *---------------------------------------------------------------------- * * XMoveWindow -- * * Move a window relative to its parent. * * Results: * None. * * Side effects: * Repositions the specified window. * *---------------------------------------------------------------------- */voidXMoveWindow(display, w, x, y) Display* display; Window w; int x; int y;{ TkWindow *winPtr = TkWinGetWinPtr(w); display->request++; MoveWindow(TkWinGetHWND(w), x, y, winPtr->changes.width, winPtr->changes.height, TRUE);}/* *---------------------------------------------------------------------- * * XResizeWindow -- * * Resize a window. * * Results: * None. * * Side effects: * Resizes the specified window. * *---------------------------------------------------------------------- */voidXResizeWindow(display, w, width, height) Display* display; Window w; unsigned int width; unsigned int height;{ TkWindow *winPtr = TkWinGetWinPtr(w); display->request++; MoveWindow(TkWinGetHWND(w), winPtr->changes.x, winPtr->changes.y, width, height, TRUE);}/* *---------------------------------------------------------------------- * * XRaiseWindow -- * * Change the stacking order of a window. * * Results: * None. * * Side effects: * Changes the stacking order of the specified window. * *---------------------------------------------------------------------- */voidXRaiseWindow(display, w) Display* display; Window w;{ HWND window = TkWinGetHWND(w); display->request++; SetWindowPos(window, HWND_TOPMOST, 0, 0, 0, 0, SWP_NOMOVE | SWP_NOSIZE);}/* *---------------------------------------------------------------------- * * XConfigureWindow -- * * Change the size, position, stacking, or border of the specified * window. * * Results: * None. * * Side effects: * Changes the attributes of the specified window. Note that we * ignore the passed in values and use the values stored in the * TkWindow data structure. * *---------------------------------------------------------------------- */voidXConfigureWindow(display, w, value_mask, values) Display* display; Window w; unsigned int value_mask; XWindowChanges* values;{ TkWindow *winPtr = TkWinGetWinPtr(w); HWND hwnd = TkWinGetHWND(w); display->request++; /* * Change the shape and/or position of the window. */ if (value_mask & (CWX|CWY|CWWidth|CWHeight)) { MoveWindow(hwnd, winPtr->changes.x, winPtr->changes.y, winPtr->changes.width, winPtr->changes.height, TRUE); } /* * Change the stacking order of the window. */ if (value_mask & CWStackMode) { HWND sibling; if ((value_mask & CWSibling) && (values->sibling != None)) { sibling = Tk_GetHWND(values->sibling); } else { sibling = NULL; } TkWinSetWindowPos(hwnd, sibling, values->stack_mode); }}/* *---------------------------------------------------------------------- * * XClearWindow -- * * Clears the entire window to the current background color. * * Results: * None. * * Side effects: * Erases the current contents of the window. * *---------------------------------------------------------------------- */voidXClearWindow(display, w) Display* display; Window w;{ RECT rc; HBRUSH brush; HPALETTE oldPalette, palette; TkWindow *winPtr; HWND hwnd = TkWinGetHWND(w); HDC dc = GetDC(hwnd); palette = TkWinGetPalette(display->screens[0].cmap); oldPalette = SelectPalette(dc, palette, FALSE); display->request++; winPtr = TkWinGetWinPtr(w); brush = CreateSolidBrush(winPtr->atts.background_pixel); GetWindowRect(hwnd, &rc); rc.right = rc.right - rc.left; rc.bottom = rc.bottom - rc.top; rc.left = rc.top = 0; FillRect(dc, &rc, brush); DeleteObject(brush); SelectPalette(dc, oldPalette, TRUE); ReleaseDC(hwnd, dc);}/* *---------------------------------------------------------------------- * * XChangeWindowAttributes -- * * This function is called when the attributes on a window are * updated. Since Tk maintains all of the window state, the only * relevant value is the cursor. * * Results: * None. * * Side effects: * May cause the mouse position to be updated. * *---------------------------------------------------------------------- */voidXChangeWindowAttributes(display, w, valueMask, attributes) Display* display; Window w; unsigned long valueMask; XSetWindowAttributes* attributes;{ if (valueMask & CWCursor) { XDefineCursor(display, w, attributes->cursor); }}/* *---------------------------------------------------------------------- * * TkWinSetWindowPos -- * * Adjust the stacking order of a window relative to a second * window (or NULL). * * Results: * None. * * Side effects: * Moves the specified window in the stacking order. * *---------------------------------------------------------------------- */voidTkWinSetWindowPos(hwnd, siblingHwnd, pos) HWND hwnd; /* Window to restack. */ HWND siblingHwnd; /* Sibling window. */ int pos; /* One of Above or Below. */{ HWND temp; /* * Since Windows does not support Above mode, we place the * specified window below the sibling and then swap them. */ if (siblingHwnd) { if (pos == Above) { SetWindowPos(hwnd, siblingHwnd, 0, 0, 0, 0, SWP_NOACTIVATE | SWP_NOMOVE | SWP_NOSIZE); temp = hwnd; hwnd = siblingHwnd; siblingHwnd = temp; } } else { siblingHwnd = (pos == Above) ? HWND_TOP : HWND_BOTTOM; } SetWindowPos(hwnd, siblingHwnd, 0, 0, 0, 0, SWP_NOACTIVATE | SWP_NOMOVE | SWP_NOSIZE);}/* *---------------------------------------------------------------------- * * TkpWindowWasRecentlyDeleted -- * * Determines whether we know if the window given as argument was * recently deleted. Called by the generic code error handler to * handle BadWindow events. * * Results: * Always 0. We do not keep this information on Windows. * * Side effects: * None. * *---------------------------------------------------------------------- */intTkpWindowWasRecentlyDeleted(win, dispPtr) Window win; TkDisplay *dispPtr;{ return 0;}
⌨️ 快捷键说明
复制代码
Ctrl + C
搜索代码
Ctrl + F
全屏模式
F11
切换主题
Ctrl + Shift + D
显示快捷键
?
增大字号
Ctrl + =
减小字号
Ctrl + -