int C_StretchBoxProc(ClientData cl, Tcl_Interp *interp, int argc, char **argv) { double x2,y2,xtemp2,ytemp2; Pixmap pm; XRectangle theClientArea; Tk_Window tkwin; WindowType theWindow = theWindowArray[atoi(argv[1])]; tkwin = theWindow->tkwin; theClientArea.x = 0; theClientArea.y = 0; theClientArea.width = Tk_Width(tkwin); theClientArea.height = Tk_Height(tkwin); XSetClipRectangles(theDisplay, theWindow->xwingc, 0, 0, &theClientArea, 1, Unsorted); pm = XCreatePixmap(theDisplay, Tk_WindowId(tkwin), Tk_Width(tkwin), Tk_Height(tkwin), Tk_Depth(tkwin)); XCopyArea(theDisplay, theWindow->pixmap_buffer, pm, theWindow->xwingc, 0, 0, Tk_Width(tkwin), Tk_Height(tkwin), 0, 0); x2 = atof(argv[2]); y2 = atof(argv[3]); if (Is_X_Log(theWindow)) { xtemp2 = theWindow->c1 * log10(max(x2, DBL_MIN)) + theWindow->d1; } else { xtemp2 = theWindow->c1 * x2 + theWindow->d1; } if (Is_Y_Log(theWindow)) { ytemp2 = theWindow->c2 * log10(max(y2, DBL_MIN)) + theWindow->d2; } else { ytemp2 = theWindow->c2 * y2 + theWindow->d2; } XSetForeground(theDisplay, theWindow->xwingc, theWhitePixel); XDrawRectangle(theDisplay, pm, theWindow->xwingc, min(xtemp1,xtemp2), min(ytemp1,ytemp2), fabs(xtemp2 - xtemp1), fabs(ytemp2 - ytemp1)); XCopyArea(theDisplay, pm, Tk_WindowId(tkwin), theWindow->xwingc, 0, 0, Tk_Width(tkwin), Tk_Height(tkwin), 0, 0); XFlush(theDisplay); XFreePixmap(theDisplay, pm); return TCL_OK; }
bool ParadynTkGUI::TryFirstWhereAxisWindow( void ) { if (haveSeenFirstWhereAxisWindow) return true; Tk_Window topLevelTkWindow = Tk_MainWindow( interp ); Tk_Window theTkWindow = Tk_NameToWindow(interp, ".whereAxis.nontop.main.all", topLevelTkWindow); assert(theTkWindow); if (Tk_WindowId(theTkWindow) == 0) return false; // sigh...still invalid (that's why this routine is needed) haveSeenFirstWhereAxisWindow = true; theAbstractions = new abstractions("", ".whereAxis.top.mbar.nav.m", ".whereAxis.nontop.main.bottsb", ".whereAxis.nontop.main.leftsb", ".whereAxis.nontop.find.entry", interp, theTkWindow); assert(theAbstractions); return true; }
bool ParadynTkGUI::TryFirstCallGraphWindow( void ) { if (haveSeenFirstCallGraphWindow) return true; Tk_Window topLevelTkWindow = Tk_MainWindow( interp ); Tk_Window theTkWindow = Tk_NameToWindow(interp,".callGraph.nontop.main.all", topLevelTkWindow); assert(theTkWindow); if (Tk_WindowId(theTkWindow) == 0) return false; // sigh...still invalid (that's why this routine is needed) theCallGraphPrograms = new callGraphs(".callGraph.titlearea.left.menu.mbar.program.m", ".callGraph.nontop.main.bottsb", ".callGraph.nontop.main.leftsb", ".callGraph.nontop.labelarea.current", ".callGraph.nontop.currprogramarea.label2", interp, theTkWindow); assert(theCallGraphPrograms); initiateCallGraphRedraw(interp, true); haveSeenFirstCallGraphWindow = true; return true; }
void TreeMarquee_Display( TreeMarquee marquee /* Marquee token. */ ) { TreeCtrl *tree = marquee->tree; if (!marquee->onScreen && marquee->visible) { if (TreeMarquee_IsXOR(marquee)) { marquee->sx = 0 - tree->xOrigin; marquee->sy = 0 - tree->yOrigin; TreeMarquee_DrawXOR(marquee, Tk_WindowId(tree->tkwin), marquee->sx, marquee->sy); } else { marquee->sx = MIN(marquee->x1, marquee->x2) - tree->xOrigin; marquee->sy = MIN(marquee->y1, marquee->y2) - tree->yOrigin; marquee->sw = abs(marquee->x2 - marquee->x1) + 1; marquee->sh = abs(marquee->y2 - marquee->y1) + 1; /* Tree_InvalidateItemArea(tree, marquee->sx, marquee->sy, marquee->sx + marquee->sw, marquee->sy + marquee->sh);*/ Tree_EventuallyRedraw(tree); } marquee->onScreen = TRUE; } }
static void ScrollbarThumbElementDraw( void *clientData, void *elementRecord, Tk_Window tkwin, Drawable d, Ttk_Box b, unsigned state) { if (qApp == NULL) NULL_Q_APP; if (state & TTK_STATE_DISABLED) return; NULL_PROXY_ORIENTED_WIDGET(TileQt_QScrollBar_Widget); Tcl_MutexLock(&tileqtMutex); //QPixmap pixmap(b.width, b.height); QPixmap pixmap = QPixmap::grabWindow(Tk_WindowId(tkwin)); QPainter painter(&pixmap); #ifdef TILEQT_QT_VERSION_4 wc->TileQt_QScrollBar_Widget->resize(b.width, b.height); wc->TileQt_QScrollBar_Widget->setValue(0); if (orient == TTK_ORIENT_HORIZONTAL) { wc->TileQt_QScrollBar_Widget->setOrientation(Qt::Horizontal); } else { wc->TileQt_QScrollBar_Widget->setOrientation(Qt::Vertical); } QStyleOptionSlider option; option.initFrom(wc->TileQt_QScrollBar_Widget); option.state |= (QStyle::StateFlag) TileQt_StateTableLookup(scrollbar_statemap, state); option.subControls = QStyle::SC_ScrollBarGroove; wc->TileQt_Style->drawComplexControl(QStyle::CC_ScrollBar, &option, &painter, wc->TileQt_QScrollBar_Widget); #endif /* TILEQT_QT_VERSION_4 */ // printf("x=%d, y=%d, w=%d, h=%d\n", b.x, b.y, b.width, b.height); TileQt_CopyQtPixmapOnToDrawable(pixmap, d, tkwin, 0, 0, b.width, b.height, b.x, b.y); Tcl_MutexUnlock(&tileqtMutex); }
static PyObject * tkwin_GetGC(TkWinObject * self, PyObject* args, PyObject * kwargs) { Display * display; GC gc; unsigned long mask = 0; XGCValues values; PyObject * dict; if (PySequence_Length(args) > 0) { if (!PyArg_ParseTuple(args, "O", &dict)) return NULL; } else dict = kwargs; display = Tk_Display(self->tkwin); if (dict) { if (!PaxGC_MakeValues(dict, &mask, &values)) return NULL; } gc = Tk_GetGC(self->tkwin, mask, &values); return PaxGC_FromGC(display, Tk_WindowId(self->tkwin), gc, PAXGC_SHARED, NULL); }
/* *--------------------------------------------------------------------------- * * WindowToHandle -- * *--------------------------------------------------------------------------- */ static HWND WindowToHandle(Tk_Window tkwin) { HWND hWnd; Window window; window = Tk_WindowId(tkwin); if (window == None) { Tk_MakeWindowExist(tkwin); } hWnd = Tk_GetHWND(Tk_WindowId(tkwin)); if (Tk_IsTopLevel(tkwin)) { hWnd = GetParent(hWnd); } return hWnd; }
static void GenerateEditEvent( int flag) { XVirtualEvent event; Point where; Tk_Window tkwin; Window window; TkDisplay *dispPtr; if (TkMacHaveAppearance() >= 0x110) { window = TkMacGetXWindow(FrontNonFloatingWindow()); } else { window = TkMacGetXWindow(FrontWindow()); } dispPtr = TkGetDisplayList(); tkwin = Tk_IdToWindow(dispPtr->display, window); tkwin = (Tk_Window) ((TkWindow *) tkwin)->dispPtr->focusPtr; if (tkwin == NULL) { return; } event.type = VirtualEvent; event.serial = Tk_Display(tkwin)->request; event.send_event = false; event.display = Tk_Display(tkwin); event.event = Tk_WindowId(tkwin); event.root = XRootWindow(Tk_Display(tkwin), 0); event.subwindow = None; event.time = TkpGetMS(); GetMouse(&where); tkwin = Tk_TopCoordsToWindow(tkwin, where.h, where.v, &event.x, &event.y); LocalToGlobal(&where); event.x_root = where.h; event.y_root = where.v; event.state = TkMacButtonKeyState(); event.same_screen = true; switch (flag) { case EDIT_CUT: event.name = Tk_GetUid("Cut"); break; case EDIT_COPY: event.name = Tk_GetUid("Copy"); break; case EDIT_PASTE: event.name = Tk_GetUid("Paste"); break; case EDIT_CLEAR: event.name = Tk_GetUid("Clear"); break; } Tk_QueueWindowEvent((XEvent *) &event, TCL_QUEUE_TAIL); }
Window TkWin_AsWindowID(PyObject * self) { if (self && TkWin_Check(self)) return Tk_WindowId(((TkWinObject*)self)->tkwin); PyErr_BadInternalCall(); return None; }
static PyObject * tkwin_CopyArea(TkWinObject * self, PyObject * args) { PyObject *destobj, *gcobj; Drawable dest; GC gc; int src_x, src_y, dest_x, dest_y; unsigned int width, height; if (!PyArg_ParseTuple(args, "OOiiiiii", &destobj, &gcobj, &src_x, &src_y, &width, &height, &dest_x, &dest_y)) return NULL; if (TkWin_Check(destobj)) { if (Tk_IsMapped(self->tkwin)) dest = Tk_WindowId(((TkWinObject*) destobj)->tkwin); else { Py_INCREF(Py_None); return Py_None; } } else if (PaxPixmap_Check(destobj)) { dest = PaxPixmap_AsPixmap(destobj); } else { PyErr_SetString(PyExc_RuntimeError, "bad arguments"); return NULL; } if (gcobj == Py_None) gc = DefaultGCOfScreen(Tk_Screen(self->tkwin)); else { gc = PaxGC_AsGC(gcobj); if (PyErr_Occurred()) return NULL; } XCopyArea(Tk_Display(self->tkwin), Tk_WindowId(self->tkwin), dest, gc, src_x, src_y, width, height, dest_x, dest_y); Py_INCREF(Py_None); return Py_None; }
Pixmap Blt_PictureMask(Tk_Window tkwin, Picture *srcPtr) { Blt_Pixel *srcRowPtr; Pixmap bitmap; int bytesPerLine; int count; int x, y; unsigned char *bits; unsigned char *destRowPtr; bytesPerLine = (srcPtr->width + 7) / 8; bits = Blt_AssertMalloc(sizeof(unsigned char)*srcPtr->height*bytesPerLine); count = 0; srcRowPtr = srcPtr->bits; destRowPtr = bits; for (y = 0; y < srcPtr->height; y++) { int value, bitMask; Blt_Pixel *sp; unsigned char *dp; sp = srcRowPtr, dp = destRowPtr; value = 0, bitMask = 1; for (x = 0; x < srcPtr->width; /*empty*/ ) { unsigned long pixel; pixel = (sp->Alpha != ALPHA_TRANSPARENT); if (pixel) { value |= bitMask; } else { count++; /* Count the number of transparent pixels. */ } bitMask <<= 1; x++; if (!(x & 7)) { *dp++ = (unsigned char)value; value = 0, bitMask = 1; } sp++; } if (x & 7) { *dp++ = (unsigned char)value; } srcRowPtr += srcPtr->pixelsPerRow; destRowPtr += bytesPerLine; } if (count > 0) { Tk_MakeWindowExist(tkwin); bitmap = XCreateBitmapFromData(Tk_Display(tkwin), Tk_WindowId(tkwin), (char *)bits, (unsigned int)srcPtr->width, (unsigned int)srcPtr->height); } else { bitmap = None; /* Image is opaque. */ } Blt_Free(bits); return bitmap; }
void XvWindow::setsize(int w, int h) { CaptureWindow::setsize(w, h); /* Start the video display */ Tk_MakeWindowExist(tk_); XvPutVideo(dpy_, grabID_, Tk_WindowId(tk_), gc_, 0, 0, base_width_, base_height_, 0, 0, width_, height_); }
/* *---------------------------------------------------------------------- * * GetWindowHandle -- * * Returns the XID for the Tk_Window given. Starting in Tk 8.0, * the toplevel widgets are wrapped by another window. * Currently there's no way to get at that window, other than * what is done here: query the X window hierarchy and grab the * parent. * * Results: * Returns the X Window ID of the widget. If it's a toplevel, then * the XID of the wrapper is returned. * *---------------------------------------------------------------------- */ static HWND GetWindowHandle(Tk_Window tkwin) { HWND hWnd; Window window; window = Tk_WindowId(tkwin); if (window == None) { Tk_MakeWindowExist(tkwin); } hWnd = Tk_GetHWND(Tk_WindowId(tkwin)); #if (TK_MAJOR_VERSION > 4) if (Tk_IsTopLevel(tkwin)) { hWnd = GetParent(hWnd); } #endif /* TK_MAJOR_VERSION > 4 */ return hWnd; }
bool shgPhases::altPress(int x, int y) { // returns true if a redraw is called for (in which case a scroll // is done as well as an XWarpPointer) if (!existsCurrent()) return false; if (currInstalledAltMoveHandler) { if (ignoreNextShgAltMove) { ignoreNextShgAltMove = false; return false; } int deltax = x - shgAltAnchorX; int deltay = y - shgAltAnchorY; // add some extra speedup juice as an incentive to use alt-mousemove scrolling deltax *= 4; deltay *= 4; getCurrent().adjustHorizSBOffsetFromDeltaPix(deltax); getCurrent().adjustVertSBOffsetFromDeltaPix(deltay); #if !defined(i386_unknown_nt4_0) XWarpPointer(Tk_Display(theTkWindow), Tk_WindowId(theTkWindow), Tk_WindowId(theTkWindow), 0, 0, 0, 0, shgAltAnchorX, shgAltAnchorY); #else // !defined(i386_unknown_nt4_0) // TODO - implement warping support #endif // !defined(i386_unknown_nt4_0) ignoreNextShgAltMove = true; return true; } else { shgAltAnchorX = x; shgAltAnchorY = y; currInstalledAltMoveHandler = true; return false; } }
Pixmap Blt_PhotoImageMask(Tk_Window tkwin, Tk_PhotoImageBlock src) { Pixmap bitmap; int arraySize, bytes_per_line; int offset, count; int y; unsigned char *bits; unsigned char *dp; #ifdef notdef bytes_per_line = (src.width + 7) / 8; arraySize = src.height * bytes_per_line; bits = Blt_AssertMalloc(sizeof(unsigned char) * arraySize); dp = bits; offset = count = 0; for (y = 0; y < src.height; y++) { int value, bitMask; int x; unsigned char *sp; value = 0, bitMask = 1; sp = src.pixelPtr + offset; for (x = 0; x < src.width; /*empty*/ ) { unsigned long pixel; pixel = (sp[src.offset[3]] != 0x00); if (pixel) { value |= bitMask; } else { count++; /* Count the number of transparent pixels. */ } bitMask <<= 1; x++; if (!(x & 7)) { *dp++ = (unsigned char)value; value = 0, bitMask = 1; } sp += src.pixelSize; } if (x & 7) { *dp++ = (unsigned char)value; } offset += src.pitch; } if (count > 0) { Tk_MakeWindowExist(tkwin); bitmap = XCreateBitmapFromData(Tk_Display(tkwin), Tk_WindowId(tkwin), (char *)bits, (unsigned int)src.width, (unsigned int)src.height); } else { bitmap = None; /* Image is opaque. */ } Blt_Free(bits); #endif return bitmap; }
int TkScrollWindow( Tk_Window tkwin, /* The window to be scrolled. */ GC gc, /* GC for window to be scrolled. */ int x, int y, int width, int height, /* Position rectangle to be scrolled. */ int dx, int dy, /* Distance rectangle should be moved. */ TkRegion damageRgn) /* Region to accumulate damage in. */ { Tk_RestrictProc *oldProc; ClientData oldArg, dummy; ScrollInfo info; XCopyArea(Tk_Display(tkwin), Tk_WindowId(tkwin), Tk_WindowId(tkwin), gc, x, y, (unsigned) width, (unsigned) height, x+dx, y+dy); info.done = 0; info.window = Tk_WindowId(tkwin); info.display = Tk_Display(tkwin); info.region = damageRgn; info.dx = dx; info.dy = dy; /* * Sync the event stream so all of the expose events will be on the Tk * event queue before we start filtering. This avoids busy waiting while * we filter events. */ TkpSync(info.display); oldProc = Tk_RestrictEvents(ScrollRestrictProc, (ClientData) &info, &oldArg); while (!info.done) { Tcl_ServiceEvent(TCL_WINDOW_EVENTS); } Tk_RestrictEvents(oldProc, oldArg, &dummy); if (XEmptyRegion((Region) damageRgn)) { return 0; } else { return 1; } }
int TkpScaleElement( TkScale *scalePtr, /* Widget record for scale. */ int x, int y) /* Coordinates within scalePtr's window. */ { MacScale *macScalePtr = (MacScale *) scalePtr; ControlPartCode part; Point where; Rect bounds; CGrafPtr destPort, savePort; Boolean portChanged; #ifdef TK_MAC_DEBUG_SCALE TkMacOSXDbgMsg("TkpScaleElement"); #endif destPort = TkMacOSXGetDrawablePort(Tk_WindowId(scalePtr->tkwin)); portChanged = QDSwapPort(destPort, &savePort); /* * All of the calculations in this procedure mirror those in * DisplayScrollbar. Be sure to keep the two consistent. */ TkMacOSXWinBounds((TkWindow *) scalePtr->tkwin, &bounds); where.h = x + bounds.left; where.v = y + bounds.top; part = TestControl(macScalePtr->scaleHandle, where); if (portChanged) { QDSwapPort(savePort, NULL); } #ifdef TK_MAC_DEBUG_SCALE fprintf (stderr,"ScalePart %d, pos ( %d %d )\n", part, where.h, where.v ); #endif switch (part) { case inSlider: return SLIDER; case inInc: if (scalePtr->orient == ORIENT_VERTICAL) { return TROUGH1; } else { return TROUGH2; } case inDecr: if (scalePtr->orient == ORIENT_VERTICAL) { return TROUGH2; } else { return TROUGH1; } default: return OTHER; } }
void callGraphDisplay::draw(bool doubleBuffer, bool xsynchronize // are we debugging? ) const { Drawable theDrawable = (doubleBuffer && !xsynchronize) ? consts.offscreenPixmap : Tk_WindowId(consts.theTkWindow); if (doubleBuffer || xsynchronize) // clear the offscreen pixmap before drawing onto it XFillRectangle(consts.display, theDrawable, consts.erasingGC, 0, // x-offset relative to drawable 0, // y-offset relative to drawable Tk_Width(consts.theTkWindow), Tk_Height(consts.theTkWindow) ); const int overallWindowBorderPix = 0; if (rootPtr) rootPtr->draw(consts.theTkWindow, consts, theDrawable, nominal_centerx + horizScrollBarOffset, // relative (not absolute) coord overallWindowBorderPix + vertScrollBarOffset, // relative (not absolute) coord false, // not root only false // not listbox only ); if (doubleBuffer && !xsynchronize) { // copy from offscreen pixmap onto the 'real' window XCopyArea(consts.display, theDrawable, // source pixmap Tk_WindowId(consts.theTkWindow), // dest pixmap consts.listboxCopyAreaGC, 0, 0, // source x,y pix Tk_Width(consts.theTkWindow), Tk_Height(consts.theTkWindow), 0, 0 // dest x,y offset pix ); } }
bool ParadynTkGUI::TryFirstShgWindow( void ) { // called in shgTcl.C // like whereAxis's and barChart's techniques... // Tk_WindowId() returns 0 until the tk window has been mapped for the first // time, which takes a surprisingly long time. Therefore, this hack is needed. if (haveSeenFirstShgWindow) return true; Tk_Window topLevelTkWindow = Tk_MainWindow( interp ); Tk_Window theTkWindow = Tk_NameToWindow(interp, ".shg.nontop.main.all", topLevelTkWindow); assert(theTkWindow); if (Tk_WindowId(theTkWindow) == 0) return false; // this happens in practice...that's why this routine is needed haveSeenFirstShgWindow = true; /* *********************************************************** */ // Why don't we construct "theShgPhases" earlier (perhaps at startup)? // Why do we wait until the shg window has been opened? // Because the constructor requires window names as arguments. theShgPhases = new shgPhases(".shg.titlearea.left.menu.mbar.phase.m", ".shg.nontop.main.bottsb", ".shg.nontop.main.leftsb", ".shg.nontop.labelarea.current", ".shg.nontop.textarea.text", ".shg.nontop.buttonarea.left.search", ".shg.nontop.buttonarea.middle.pause", ".shg.nontop.currphasearea.label2", interp, theTkWindow); assert(theShgPhases); // Now is as good a time as any to define the global phase. const int GlobalPhaseId = 0; // a hardcoded constant (void)theShgPhases->defineNewSearch(GlobalPhaseId, "Global Phase"); // Also add the "current phase", if applicable. // We check "latest_detected_new_phase_id", set by ui_newPhaseDetected (UImain.C) if (latest_detected_new_phase_id >= 0) { theShgPhases->defineNewSearch(latest_detected_new_phase_id, latest_detected_new_phase_name); } initiateShgRedraw(interp, true); return true; }
void TkpSetCapture( TkWindow *winPtr) /* Capture window, or NULL. */ { if (winPtr) { SetCapture(Tk_GetHWND(Tk_WindowId(winPtr))); captured = 1; } else { captured = 0; ReleaseCapture(); } }
void TkpDrawFrame( Tk_Window tkwin, Tk_3DBorder border, int highlightWidth, int borderWidth, int relief) { Tk_Fill3DRectangle(tkwin, Tk_WindowId(tkwin), border, highlightWidth, highlightWidth, Tk_Width(tkwin) - 2 * highlightWidth, Tk_Height(tkwin) - 2 * highlightWidth, borderWidth, relief); }
static PyObject * tkwin_QueryBestCursor(TkWinObject * self, PyObject * args) { unsigned int width, height, ret_width, ret_height; if (!PyArg_ParseTuple(args, "ii", &width, &height)) return NULL; XQueryBestCursor(Tk_Display(self->tkwin), Tk_WindowId(self->tkwin), width, height, &ret_width, &ret_height); return Py_BuildValue("ii", ret_width, ret_height); }
void XGetInputFocus( Display *display, Window *focus_return, int *revert_to_return) { Tk_Window tkwin = Tk_HWNDToWindow(GetFocus()); *focus_return = tkwin ? Tk_WindowId(tkwin) : None; *revert_to_return = RevertToParent; display->request++; }
void TkpCreateBusy( Tk_FakeWin *winPtr, Tk_Window tkRef, Window *parentPtr, Tk_Window tkParent, TkBusy busy) { if (winPtr->flags & TK_REPARENTED) { /* * This works around a bug in the implementation of menubars for * non-MacIntosh window systems (Win32 and X11). Tk doesn't reset the * pointers to the parent window when the menu is reparented (since * winPtr->parentPtr points to the wrong window). We get around this * by determining the parent via the native API calls. */ *parentPtr = GetParent(Tk_Display(tkRef), Tk_WindowId(tkRef)); } else { *parentPtr = Tk_WindowId(tkParent); } }
/* 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) { XEvent event; memset(&event, 0, sizeof(event)); event.xany.type = VirtualEvent; event.xany.serial = NextRequest(Tk_Display(tgtWin)); event.xany.send_event = False; event.xany.window = Tk_WindowId(tgtWin); event.xany.display = Tk_Display(tgtWin); ((XVirtualEvent *) &event)->name = Tk_GetUid(eventName); Tk_QueueWindowEvent(&event, TCL_QUEUE_TAIL); }
Pixmap HtmlImageTilePixmap( HtmlImage2* pImage, int *pW, int *pH ) { if (HtmlImagePixmap(pImage)) { Tk_Window win; XGCValues gc_values; GC gc; int i, j; if( pImage->tilepixmap ){ goto return_tile; } if (!tilesize(pImage, &pImage->iTileWidth, &pImage->iTileHeight)) { goto return_original; } win = pImage->pImageServer->pTree->tkwin; pImage->tilepixmap = Tk_GetPixmap(Tk_Display(win), Tk_WindowId(win), pImage->iTileWidth, pImage->iTileHeight, Tk_Depth(win) ); memset(&gc_values, 0, sizeof(XGCValues)); gc = Tk_GetGC(win, 0, &gc_values); for (i = 0; i < pImage->iTileWidth; i += pImage->width){ for (j = 0; j < pImage->iTileHeight; j += pImage->height){ XCopyArea(Tk_Display(win), pImage->pixmap, pImage->tilepixmap, gc, 0, 0, pImage->width, pImage->height, i, j ); } } Tk_FreeGC(Tk_Display(win), gc); } return_tile: *pW = pImage->iTileWidth; *pH = pImage->iTileHeight; return pImage->tilepixmap; return_original: *pW = pImage->width; *pH = pImage->height; return pImage->pixmap; }
static void GenerateEditEvent( int flag) { XVirtualEvent event; int x, y; Tk_Window tkwin; Window window; TkDisplay *dispPtr; window = TkMacOSXGetXWindow(ActiveNonFloatingWindow()); dispPtr = TkGetDisplayList(); tkwin = Tk_IdToWindow(dispPtr->display, window); tkwin = (Tk_Window) ((TkWindow *) tkwin)->dispPtr->focusPtr; if (tkwin == NULL) { return; } bzero(&event, sizeof(XVirtualEvent)); event.type = VirtualEvent; event.serial = Tk_Display(tkwin)->request; event.send_event = false; event.display = Tk_Display(tkwin); event.event = Tk_WindowId(tkwin); event.root = XRootWindow(Tk_Display(tkwin), 0); event.subwindow = None; event.time = TkpGetMS(); XQueryPointer(NULL, None, NULL, NULL, &event.x_root, &event.y_root, &x, &y, &event.state); Tk_TopCoordsToWindow(tkwin, x, y, &event.x, &event.y); event.same_screen = true; switch (flag) { case EDIT_CUT: event.name = Tk_GetUid("Cut"); break; case EDIT_COPY: event.name = Tk_GetUid("Copy"); break; case EDIT_PASTE: event.name = Tk_GetUid("Paste"); break; case EDIT_CLEAR: event.name = Tk_GetUid("Clear"); break; } Tk_QueueWindowEvent((XEvent *) &event, TCL_QUEUE_TAIL); }
/* *--------------------------------------------------------------------------- * * HtmlImagePixmap -- * * Results: * Pixmap. Or zero. * * Side effects: * May change the image storage to pixmap. * *--------------------------------------------------------------------------- */ Pixmap HtmlImagePixmap(HtmlImage2 *pImage) { if (!pImage->pImageServer->pTree->options.imagepixmapify || !pImage->pImageName || !getImageCompressed(pImage) || pImage->width<=0 || pImage->height<=0 ) { return 0; } if (!pImage->isValid) { HtmlImageImage(pImage); } if (!pImage->pixmap && !HtmlImageAlphaChannel(pImage)) { Tk_Window win = pImage->pImageServer->pTree->tkwin; Tcl_Interp *interp = pImage->pImageServer->pTree->interp; Pixmap pix; int rc; Tcl_Obj *pGetData; #if 0 printf("Pixmapifying - nData = %d\n", nData); #endif pix = Tk_GetPixmap(Tk_Display(win), Tk_WindowId(win), pImage->width, pImage->height, Tk_Depth(win) ); Tk_RedrawImage( pImage->image, 0, 0, pImage->width, pImage->height, pix, 0, 0 ); pImage->pixmap = pix; pGetData = Tcl_NewObj(); Tcl_IncrRefCount(pGetData); Tcl_ListObjAppendElement(0, pGetData, Tcl_NewStringObj("image",-1)); Tcl_ListObjAppendElement(0, pGetData, Tcl_NewStringObj("create",-1)); Tcl_ListObjAppendElement(0, pGetData, Tcl_NewStringObj("photo",-1)); Tcl_ListObjAppendElement(0, pGetData, pImage->pImageName); pImage->nIgnoreChange++; rc = Tcl_EvalObjEx(interp, pGetData, TCL_EVAL_GLOBAL|TCL_EVAL_DIRECT); pImage->nIgnoreChange--; Tcl_DecrRefCount(pGetData); assert(rc==TCL_OK); } return pImage->pixmap; }
void TkGenWMDestroyEvent( Tk_Window tkwin) { XEvent event; event.xany.serial = LastKnownRequestProcessed(Tk_Display(tkwin)); event.xany.send_event = False; event.xany.display = Tk_Display(tkwin); event.xclient.window = Tk_WindowId(tkwin); event.xclient.type = ClientMessage; event.xclient.message_type = Tk_InternAtom(tkwin, "WM_PROTOCOLS"); event.xclient.format = 32; event.xclient.data.l[0] = Tk_InternAtom(tkwin, "WM_DELETE_WINDOW"); Tk_HandleEvent(&event); }
int draw_image (ClientData cd, Tcl_Interp *interp, int argc, char **argv) { Tk_Window tkwin; Display *display; Window window; GC gc; Tk_Window interpWin; interpWin=(Tk_Window) cd; tkwin=Tk_NameToWindow (interp,".c",interpWin); display=Tk_Display (tkwin); window=Tk_WindowId (tkwin); gc=Tk_GetGC (tkwin,0,NULL); if (ximage!=NULL) { XPutImage (display,window,gc,ximage,0,0,0,0,RESX,RESY); } return 0; }