_HYPlatformGraphicPane::_HYPlatformGraphicPane(int h, int w, int d) { Rect bRect; bRect.left = bRect.top = 0; bRect.right = w; bRect.bottom = h; short errCode; if (d>1) { errCode = NewGWorld (&thePane,d,&bRect,0,GetMainDevice(),noNewDevice); if (errCode == -108) // no memory errCode = NewGWorld (&thePane,d,&bRect,0,GetMainDevice(),noNewDevice|useTempMem); } else { errCode = NewGWorld (&thePane,d,&bRect,0,nil,0); if (errCode == -108) // no memory errCode = NewGWorld (&thePane,d,&bRect,0,nil,useTempMem); } fillColor = NewPixPat(); //backColor = NewPixPat(); if (errCode||(!fillColor)) { _String errMsg ("MacOS Error "); errMsg = errMsg & (long)errCode &" while trying to allocate memory for GraphicPane"; FlagError (errMsg); } savedPort = nil; }
void doUpdateWindow(EventRecord *eventStrucPtr) { IMAGE *img; WindowRef windowRef; Rect srcRect, destRect, fillRect; PixMapHandle srcPixmapHdl, destPixmapHdl; RGBColor grayColour = { 0xC000,0xC000,0xC000 }; SInt32 hScroll, vScroll; windowRef = (WindowRef) eventStrucPtr->message; img = (IMAGE*)GetWRefCon(windowRef); srcPixmapHdl = img->pixmapHdl; destPixmapHdl = GetPortPixMap(GetWindowPort(windowRef)); hScroll = GetControl32BitValue(img->scrollbarHorizRef); vScroll = GetControl32BitValue(img->scrollbarVertRef); if (srcPixmapHdl) { PixMap *pixmap = *srcPixmapHdl; PixPatHandle hdlPixPat = NewPixPat(); MakeRGBPat(hdlPixPat, &grayColour); GetWindowPortBounds(windowRef,&destRect); destRect.right -= kScrollBarWidth; destRect.bottom -= kScrollBarWidth; if (destRect.right > pixmap->bounds.right) { fillRect.top = destRect.top; fillRect.bottom = destRect.bottom; fillRect.left = pixmap->bounds.right; fillRect.right = destRect.right; FillCRect(&fillRect, hdlPixPat); destRect.right = pixmap->bounds.right; } if (destRect.bottom > pixmap->bounds.bottom) { fillRect.top = pixmap->bounds.bottom; fillRect.bottom = destRect.bottom; fillRect.left = destRect.left; fillRect.right = destRect.right; FillCRect(&fillRect, hdlPixPat); destRect.bottom = pixmap->bounds.bottom; } DisposePixPat(hdlPixPat); srcRect = destRect; srcRect.left += hScroll; srcRect.right += hScroll; srcRect.top += vScroll; srcRect.bottom += vScroll; CopyBits((BitMap*)*srcPixmapHdl, (BitMap*)*destPixmapHdl, &srcRect, &destRect, srcCopy, NULL); } DrawGrowIcon(windowRef); }
void TkMacSetUpGraphicsPort( GC gc) /* GC to apply to current port. */ { RGBColor macColor; if (gPenPat == NULL) { gPenPat = NewPixPat(); } if (TkSetMacColor(gc->foreground, &macColor) == true) { /* TODO: cache RGBPats for preformace - measure gains... */ MakeRGBPat(gPenPat, &macColor); } PenNormal(); if(gc->function == GXxor) { PenMode(patXor); } if (gc->line_width > 1) { PenSize(gc->line_width, gc->line_width); } if (gc->line_style != LineSolid) { unsigned char *p = (unsigned char *) &(gc->dashes); /* * Here the dash pattern should be set in the drawing, * environment, but I don't know how to do that for the Mac. * * p[] is an array of unsigned chars containing the dash list. * A '\0' indicates the end of this list. * * Someone knows how to implement this? If you have a more * complete implementation of SetUpGraphicsPort() for * the Mac (or for Windows), please let me know. * * Jan Nijtmans * CMG Arnhem, B.V. * email: [email protected] (private) * [email protected] (work) * url: http://purl.oclc.org/net/nijtmans/ */ } }