static void DisplayWinItem( Tk_Canvas canvas, /* Canvas that contains item. */ Tk_Item *itemPtr, /* Item to be displayed. */ Display *display, /* Display on which to draw item. */ Drawable drawable, /* Pixmap or window in which to draw item. */ int regionX, int regionY, int regionWidth, int regionHeight) /* Describes region of canvas that must be * redisplayed (not used). */ { WindowItem *winItemPtr = (WindowItem *) itemPtr; int width, height; short x, y; Tk_Window canvasTkwin = Tk_CanvasTkwin(canvas); Tk_State state = itemPtr->state; if (winItemPtr->tkwin == NULL) { return; } if (state == TK_STATE_NULL) { state = Canvas(canvas)->canvas_state; } /* * A drawable of None is used by the canvas UnmapNotify handler * to indicate that we should no longer display ourselves. */ if (state == TK_STATE_HIDDEN || drawable == None) { if (canvasTkwin == Tk_Parent(winItemPtr->tkwin)) { Tk_UnmapWindow(winItemPtr->tkwin); } else { Tk_UnmaintainGeometry(winItemPtr->tkwin, canvasTkwin); } return; } Tk_CanvasWindowCoords(canvas, (double) winItemPtr->header.x1, (double) winItemPtr->header.y1, &x, &y); width = winItemPtr->header.x2 - winItemPtr->header.x1; height = winItemPtr->header.y2 - winItemPtr->header.y1; /* * If the window is completely out of the visible area of the canvas then * unmap it. This code used not to be present (why unmap the window if it * isn't visible anyway?) but this could cause the window to suddenly * reappear if the canvas window got resized. */ if (((x + width) <= 0) || ((y + height) <= 0) || (x >= Tk_Width(canvasTkwin)) || (y >= Tk_Height(canvasTkwin))) { if (canvasTkwin == Tk_Parent(winItemPtr->tkwin)) { Tk_UnmapWindow(winItemPtr->tkwin); } else { Tk_UnmaintainGeometry(winItemPtr->tkwin, canvasTkwin); } return; } /* * Reposition and map the window (but in different ways depending on * whether the canvas is the window's parent). */ if (canvasTkwin == Tk_Parent(winItemPtr->tkwin)) { if ((x != Tk_X(winItemPtr->tkwin)) || (y != Tk_Y(winItemPtr->tkwin)) || (width != Tk_Width(winItemPtr->tkwin)) || (height != Tk_Height(winItemPtr->tkwin))) { Tk_MoveResizeWindow(winItemPtr->tkwin, x, y, width, height); } Tk_MapWindow(winItemPtr->tkwin); } else { Tk_MaintainGeometry(winItemPtr->tkwin, canvasTkwin, x, y, width, height); } }
void TkTextEmbWinDisplayProc( TkText *textPtr, /* Information about text widget. */ TkTextDispChunk *chunkPtr, /* Chunk that is to be drawn. */ int x, /* X-position in dst at which to draw this * chunk (differs from the x-position in the * chunk because of scrolling). */ int y, /* Top of rectangular bounding box for line: * tells where to draw this chunk in dst * (x-position is in the chunk itself). */ int lineHeight, /* Total height of line. */ int baseline, /* Offset of baseline from y. */ Display *display, /* Display to use for drawing (unused). */ Drawable dst, /* Pixmap or window in which to draw * (unused). */ int screenY) /* Y-coordinate in text window that * corresponds to y. */ { int lineX, windowX, windowY, width, height; Tk_Window tkwin; TkTextSegment *ewPtr = (TkTextSegment*) chunkPtr->clientData; TkTextEmbWindowClient *client = EmbWinGetClient(textPtr, ewPtr); if (client == NULL) { return; } tkwin = client->tkwin; if (tkwin == NULL) { return; } if ((x + chunkPtr->width) <= 0) { /* * The window is off-screen; just unmap it. */ if (textPtr->tkwin != Tk_Parent(tkwin)) { Tk_UnmaintainGeometry(tkwin, textPtr->tkwin); } else { Tk_UnmapWindow(tkwin); } return; } /* * Compute the window's location and size in the text widget, taking into * account the align and stretch values for the window. */ EmbWinBboxProc(textPtr, chunkPtr, 0, screenY, lineHeight, baseline, &lineX, &windowY, &width, &height); windowX = lineX - chunkPtr->x + x; if (textPtr->tkwin == Tk_Parent(tkwin)) { if ((windowX != Tk_X(tkwin)) || (windowY != Tk_Y(tkwin)) || (Tk_ReqWidth(tkwin) != Tk_Width(tkwin)) || (height != Tk_Height(tkwin))) { Tk_MoveResizeWindow(tkwin, windowX, windowY, width, height); } Tk_MapWindow(tkwin); } else { Tk_MaintainGeometry(tkwin, textPtr->tkwin, windowX, windowY, width, height); } /* * Mark the window as displayed so that it won't get unmapped. */ client->displayed = 1; }