void WgGfxDevice::ClipBlitVertBar( const WgRect& _clip, const WgSurfacePtr& _pSurf, const WgRect& _src, const WgBorder& _borders, bool _bTile, int _dx, int _dy, int _len ) { /* This can be optimized by handling clipping directly instead of calling clipBlit(). */ // Blit top edge WgRect r( _src.x, _src.y, _src.w, _borders.top ); ClipBlit( _clip, _pSurf, r, _dx, _dy ); _len -= _borders.Height(); // Remove top and bottom edges from len. _dy += _borders.top; // Blit tiling part r.y += _borders.top; r.h = _src.h - _borders.Height(); if( _bTile ) { while( _len > r.h ) { ClipBlit( _clip, _pSurf, r, _dx, _dy ); _len -= r.h; _dy += r.h; } if( _len != 0 ) { r.h = _len; ClipBlit( _clip, _pSurf, r, _dx, _dy ); _dy += _len; } } else { ClipStretchBlit( _clip, _pSurf, r, WgRect( _dx, _dy, r.w, _len ) ); _dy += _len; } // Blit bottom edge r.y = _src.y + _src.h - _borders.bottom; r.h = _borders.bottom; ClipBlit( _clip, _pSurf, r, _dx, _dy ); }
void WgGfxDevice::ClipBlitHorrBar( const WgRect& _clip, const WgSurfacePtr& _pSurf, const WgRect& _src, const WgBorder& _borders, bool _bTile, int _dx, int _dy, int _len ) { /* This can be optimized by handling clipping directly instead of calling clipBlit(). */ // Blit left edge WgRect r( _src.x, _src.y, _borders.left, _src.h ); ClipBlit( _clip, _pSurf, r, _dx, _dy ); _len -= _borders.Width(); // Remove left and right edges from len. _dx += _borders.left; // Blit tiling part r.x += _borders.left; r.w = _src.w - _borders.Width(); if( _bTile ) { while( _len > r.w ) { ClipBlit( _clip, _pSurf, r, _dx, _dy ); _len -= r.w; _dx += r.w; } if( _len != 0 ) { r.w = _len; ClipBlit( _clip, _pSurf, r, _dx, _dy ); _dx += _len; } } else { ClipStretchBlit( _clip, _pSurf, r, WgRect( _dx, _dy, _len, r.h ) ); _dx += _len; } // Blit right edge r.x = _src.x + _src.w - _borders.right; r.w = _borders.right; ClipBlit( _clip, _pSurf, r, _dx, _dy ); }
void move_text (int offset, int max) { int xSource, xDest; xSource = RastPort->cp_x; xDest = RastPort->cp_x + offset; ClipBlit (RastPort, xSource, RastPort->cp_y, RastPort, xDest, RastPort->cp_y, max - MAX (xSource, xDest), RastPort->TxHeight, 0xC0); }
void os_printchar (char c) { if (Window == 0) { if (c == '\r') c = '\n'; fputc (c, stdout); return; } if (c == '\r') { os_flush (); ClipBlit (RastPort, Window->BorderLeft, Window->BorderTop + RastPort->TxHeight, RastPort, Window->BorderLeft, Window->BorderTop, Window->Width - Window->BorderLeft - Window->BorderRight, DisplayHeight * RastPort->TxHeight, 0xC0); rect (Window->BorderLeft, Window->BorderTop + DisplayHeight * RastPort->TxHeight, Window->Width - Window->BorderRight - 1, Window->BorderTop + (DisplayHeight + 1) * RastPort->TxHeight - 1, 0); reset_cursor (); if (scriptfile == NULL) { if (++MoreCount >= DisplayHeight) { MoreCount = 0; text ("[More]", 6); cursor (0); get_key (0, -1, 1); cursor (0); rect (Window->BorderLeft, Window->BorderTop + DisplayHeight * RastPort->TxHeight, Window->Width - Window->BorderRight - 1, Window->BorderTop + (DisplayHeight + 1) * RastPort->TxHeight - 1, 0); reset_cursor (); } } return; } if (isprint(c) == 0) return; if (TextBufferPtr >= TEXTBUFFER_SIZE) os_flush (); *(TextBuffer + (TextBufferPtr++)) = c; }
int main(int argc, char **argv) { ULONG DisplayID,Depth; struct Screen *CyberScreen; struct Window *WriteWindow; LONG done; struct IntuiMessage *IntMsg; IMAGE image; LONG src_x,src_y, old_src_x,old_src_y; ULONG argarray[2]; struct RDArgs *rdargs; char *file; rdargs = ReadArgs((STRPTR)arg_template, (LONG*)argarray, NULL); if(!rdargs) return 20; file = (char*)argarray[0]; IntuitionBase = (struct IntuitionBase *)OpenLibrary("intuition.library",39L); if(!IntuitionBase) return 20; CyberGfxBase = OpenLibrary(CYBERGFXNAME,CYBERGFXVERSION); if(!CyberGfxBase) { ErrorF ("Can't open \"%s\" version %ld or newer.", CYBERGFXNAME,CYBERGFXVERSION); CloseLibrary (&IntuitionBase->LibNode); return 10; } if(!Load(file, &image)) { ErrorF ("Can't load image."); FreeArgs(rdargs); CloseLibrary (CyberGfxBase); CloseLibrary (&IntuitionBase->LibNode); return 10; } /* Let CyberGraphX search a display mode for us! */ if(argarray[1]) Depth = 16; else Depth = 24; FreeArgs(rdargs); while (Depth) { DisplayID = BestCModeIDTags(CYBRBIDTG_NominalWidth, image.width, CYBRBIDTG_NominalHeight, image.height, CYBRBIDTG_Depth, Depth, TAG_DONE); if(DisplayID != INVALID_ID) { /* Because older version of the "cybergraphics.library" don't handle */ /* CYBRBIDTG_Depth properly we query the real depth of the mode. */ Depth = GetCyberIDAttr(CYBRIDATTR_DEPTH,DisplayID); break; } /* retry with less bits per pixel */ Depth = NextDepth(Depth); } if (Depth < SCREEN_MIN_DEPTH) { ErrorF ("Can't find suitable display mode for %ldx%ldx.", image.width, image.height); CloseLibrary (CyberGfxBase); CloseLibrary (&IntuitionBase->LibNode); Cleanup(&image); return 5; } /* open screen, but let Intuition choose the actual dimensions */ CyberScreen = OpenScreenTags( NULL, SA_Title,"RayStorm Image Viewer (C) 1998 Andreas Heumann", SA_DisplayID,DisplayID, SA_Depth,Depth, TAG_DONE); if(!CyberScreen) { ErrorF ("Can't open screen."); CloseLibrary (CyberGfxBase); CloseLibrary (&IntuitionBase->LibNode); Cleanup(&image); return 5; } /* create Write window */ WriteWindow = OpenWindowTags( NULL, WA_Title,"Viewer", WA_Flags, WFLG_ACTIVATE|WFLG_SIMPLE_REFRESH|WFLG_RMBTRAP, WA_IDCMP, IDCMP_REFRESHWINDOW|IDCMP_VANILLAKEY|IDCMP_RAWKEY|IDCMP_MOUSEBUTTONS, WA_Borderless, TRUE, WA_Left, 0, WA_Top, 0, WA_Width, image.width, WA_Height, image.height, WA_CustomScreen,CyberScreen, TAG_DONE); if(!WriteWindow) { ErrorF ("Can't open write window."); CloseScreen (CyberScreen); CloseLibrary (CyberGfxBase); CloseLibrary (&IntuitionBase->LibNode); Cleanup(&image); return 5; } src_x = 0; src_y = 0; WritePixelArray( image.colormap, src_x, src_y, image.width*sizeof(SMALL_COLOR), WriteWindow->RPort, 0, 0, image.width, image.height, RECTFMT_RGBA); /* event loop */ done = FALSE; while (!done) { (void)Wait(SIGMASK(WriteWindow)); while (IntMsg=GETIMSG(WriteWindow)) { switch (IntMsg->Class) { case IDCMP_REFRESHWINDOW: BeginRefresh(WriteWindow); WritePixelArray( image.colormap, src_x, src_y, image.width*sizeof(SMALL_COLOR), WriteWindow->RPort, 0, 0, image.width, image.height, RECTFMT_RGBA); EndRefresh(WriteWindow,TRUE); break; case IDCMP_VANILLAKEY: switch(IntMsg->Qualifier & 0x7fff) { case 0: switch (IntMsg->Code) { case 27: done = TRUE; break; } break; } break; case IDCMP_RAWKEY: old_src_x = src_x; old_src_y = src_y; switch(IntMsg->Code) { case CURSORRIGHT: if(src_x + WriteWindow->Width + WriteWindow->LeftEdge < image.width) { src_x += 8; if(src_x + WriteWindow->Width + WriteWindow->LeftEdge > image.width) src_x = image.width - WriteWindow->Width - WriteWindow->LeftEdge; } break; case CURSORLEFT: if(src_x > 0) { src_x -= 8; if(src_x < 0) src_x = 0; } break; case CURSORDOWN: if(src_y + WriteWindow->Height + WriteWindow->TopEdge < image.height) { src_y += 8; if(src_y + WriteWindow->Height + WriteWindow->TopEdge > image.height) src_y = image.height - WriteWindow->Height - WriteWindow->TopEdge; } break; case CURSORUP: if(src_y > 0) { src_y -= 8; if(src_y < 0) src_y = 0; } break; } if((old_src_x != src_x) || (old_src_y != src_y)) { if(old_src_x < src_x) { ClipBlit( WriteWindow->RPort, src_x - old_src_x, 0, WriteWindow->RPort, 0, 0, WriteWindow->Width + WriteWindow->LeftEdge - (src_x - old_src_x), WriteWindow->Height + WriteWindow->TopEdge, 0xc0); WritePixelArray( image.colormap, old_src_x + WriteWindow->Width + WriteWindow->LeftEdge, src_y, image.width*sizeof(SMALL_COLOR), WriteWindow->RPort, WriteWindow->Width + WriteWindow->LeftEdge - (src_x - old_src_x), 0, src_x - old_src_x, WriteWindow->Height + WriteWindow->TopEdge, RECTFMT_RGBA); } else if(old_src_x > src_x) { ClipBlit( WriteWindow->RPort, 0, 0, WriteWindow->RPort, old_src_x - src_x, 0, WriteWindow->Width + WriteWindow->LeftEdge - (old_src_x - src_x), WriteWindow->Height + WriteWindow->TopEdge, 0xc0); WritePixelArray( image.colormap, src_x, src_y, image.width*sizeof(SMALL_COLOR), WriteWindow->RPort, 0, 0, old_src_x - src_x, WriteWindow->Height + WriteWindow->TopEdge, RECTFMT_RGBA); } else if(old_src_y < src_y) { ClipBlit( WriteWindow->RPort, 0, src_y - old_src_y, WriteWindow->RPort, 0, 0, WriteWindow->Width + WriteWindow->LeftEdge, WriteWindow->Height + WriteWindow->TopEdge - (src_y - old_src_y), 0xc0); WritePixelArray( image.colormap, src_x, old_src_y + WriteWindow->Height + WriteWindow->TopEdge, image.width*sizeof(SMALL_COLOR), WriteWindow->RPort, 0, WriteWindow->Height + WriteWindow->TopEdge - (src_y - old_src_y), WriteWindow->Width + WriteWindow->LeftEdge, src_y - old_src_y, RECTFMT_RGBA); } else if(old_src_y > src_y) { ClipBlit( WriteWindow->RPort, 0, 0, WriteWindow->RPort, 0, old_src_y - src_y, WriteWindow->Width + WriteWindow->LeftEdge, WriteWindow->Height + WriteWindow->TopEdge - (old_src_y - src_y), 0xc0); WritePixelArray( image.colormap, src_x, src_y, image.width*sizeof(SMALL_COLOR), WriteWindow->RPort, 0, 0, WriteWindow->Width + WriteWindow->LeftEdge, old_src_y - src_y, RECTFMT_RGBA); } } break; case IDCMP_MOUSEBUTTONS: done = TRUE; break; } ReplyMsg (&IntMsg->ExecMessage); } } /* cleanup */ CloseWindow(WriteWindow); CloseScreen(CyberScreen); CloseLibrary(CyberGfxBase); CloseLibrary(&IntuitionBase->LibNode); Cleanup(&image); return 0; }
struct DragObj * PRIVATE CreateDragObj(struct DragGadget *dg,int x,int y) { struct Screen *scr; struct RastPort *rp; struct DragObj *gdo; ULONG line; int wordwidth; int width,height,depth; int i = 0,xpos,ypos; scr = dg->dg_Window->WScreen; rp = &scr->RastPort; if (dg->dg_Flags & DGF_IMAGES && ((struct ImageNode *)dg->dg_Object.od_Object)->in_Image) dg->dg_Image = ((struct ImageNode *)dg->dg_Object.od_Object)->in_Image; if (!dg->dg_Width || !dg->dg_Height) { if ((dg->dg_Type == LISTVIEW_KIND) && !dg->dg_Image) { dg->dg_Width = dg->dg_Gadget->Width-20; dg->dg_Height = dg->dg_ItemHeight; } else if (!dg->dg_RenderHook && dg->dg_Image) { dg->dg_Width = dg->dg_Image->Width; dg->dg_Height = dg->dg_Image->Height; } else /* be sure width & height are not zero */ { dg->dg_Width = dg->dg_Gadget->Width; dg->dg_Height = dg->dg_Gadget->Height; } } width = dg->dg_Width; height = dg->dg_Height; memset(&dm,0,sizeof(struct DropMessage)); if (dg->dg_Type == LISTVIEW_KIND) { xpos = dg->dg_Gadget->LeftEdge+2; ypos = dg->dg_Gadget->TopEdge+2; dg->dg_Object.od_Object = NULL; if (y < ypos || y > ypos+dg->dg_Gadget->Height-5) return(NULL); line = (y-ypos)/dg->dg_ItemHeight; ypos += line*dg->dg_ItemHeight; GT_GetGadgetAttrs(dg->dg_Gadget,dg->dg_Window,NULL,GTLV_Labels,&dg->dg_List,TAG_END); if (dg->dg_List && !IsListEmpty(dg->dg_List)) { GT_GetGadgetAttrs(dg->dg_Gadget,dg->dg_Window,NULL,GTLV_Top,&i,TAG_END); i += line; if (i < CountNodes(dg->dg_List)) { struct Node *ln; dm.dm_SourceEntry = i; for(ln = dg->dg_List->lh_Head;i;i--,ln = ln->ln_Succ); if (dg->dg_Flags & DGF_TREEVIEW && TREENODE(ln)->tn_Flags & TNF_STATIC) { mx = ~0L; // avoid a following drag return(NULL); } dg->dg_Object.od_Object = ln; if (dg->dg_ObjectFunc) dg->dg_ObjectFunc(dg->dg_Window,dg->dg_Gadget,&dg->dg_Object,dm.dm_SourceEntry); } } } else { if (dg->dg_ObjectFunc) dg->dg_ObjectFunc(dg->dg_Window,dg->dg_Gadget,&dg->dg_Object,0L); dm.dm_SourceEntry = dg->dg_SourceEntry; xpos = x-width/2; ypos = y-height/2; } if (!dg->dg_Object.od_Object) { mx = ~0L; // avoid a following drag return(NULL); } wordwidth = (width + 15) >> 4; depth = GetBitMapAttr(rp->BitMap,BMA_DEPTH); if (dg->dg_Object.od_Object && (gdo = AllocMem(sizeof(struct DragObj), MEMF_CLEAR | MEMF_PUBLIC))) { #ifdef LOCKLAYERS LockLayers(&scr->LayerInfo); UnlockLayer(dg->dg_Window->RPort->Layer); #endif gdo->do_Screen = scr; gdo->do_ScrRPort = rp; gdo->do_BitMap = AllocBitMap(width,height,depth,BMF_CLEAR | BMF_MINPLANES,!(GetBitMapAttr( rp->BitMap, BMA_FLAGS ) & BMF_INTERLEAVED) ? rp->BitMap : NULL); gdo->do_SaveBack = AllocBitMap(width,height,depth,BMF_CLEAR | BMF_MINPLANES,rp->BitMap); gdo->do_RefreshMap = AllocBitMap(width*2,height*2,depth,BMF_CLEAR | BMF_MINPLANES,rp->BitMap); if (GetBitMapAttr(gdo->do_BitMap,BMA_FLAGS) & BMF_STANDARD) i = MEMF_CHIP | MEMF_PUBLIC; else i = 0; gdo->do_FullShadow = AllocMem(2*wordwidth*height,i | MEMF_CLEAR); gdo->do_HalfShadow = AllocMem(2*wordwidth*height,i); if (gdo->do_BitMap && gdo->do_SaveBack && gdo->do_RefreshMap && gdo->do_FullShadow && gdo->do_HalfShadow) { InitRastPort(&gdo->do_RPort); gdo->do_RPort.BitMap = gdo->do_BitMap; InitRastPort(&gdo->do_RefreshRPort); gdo->do_RefreshRPort.BitMap = gdo->do_RefreshMap; gdo->do_DragGadget = dg; CopyMem(&dg->dg_Object,&dm.dm_Object,sizeof(struct ObjectDescription)); dm.dm_Window = dg->dg_Window; dm.dm_Gadget = dg->dg_Gadget; /*** create the drag&drop image ***/ if (dg->dg_RenderHook) { struct LVDrawMsg lvdm; SetFont(&gdo->do_RPort,scr->RastPort.Font); lvdm.lvdm_MethodID = LV_DRAW; lvdm.lvdm_RastPort = &gdo->do_RPort; lvdm.lvdm_DrawInfo = GetScreenDrawInfo(scr); lvdm.lvdm_Bounds.MinX = 0; lvdm.lvdm_Bounds.MinY = 0; lvdm.lvdm_Bounds.MaxX = width-1; lvdm.lvdm_Bounds.MaxY = height-1; lvdm.lvdm_State = LVR_SELECTED; CallHookPkt(dg->dg_RenderHook,dm.dm_Object.od_Object,&lvdm); FreeScreenDrawInfo(scr,lvdm.lvdm_DrawInfo); } else if (dg->dg_Image) DrawImage(&gdo->do_RPort,dg->dg_Image,0,0); else ClipBlit(dg->dg_Window->RPort,xpos,ypos,&gdo->do_RPort,0,0,width,height,0xc0); /*** initialize drag object structure ***/ gdo->do_X = -9999; gdo->do_Y = ypos+dg->dg_Window->TopEdge; gdo->do_PX = -9999; gdo->do_Width = width; gdo->do_Height = height; gdo->do_DeltaX = xpos-x+dg->dg_Window->LeftEdge; gdo->do_DeltaY = ypos-y+dg->dg_Window->TopEdge; gdo->do_Mask = gdo->do_FullShadow; /*** create masks (transparent and full imagery) ***/ if (CyberGfxBase && (GetBitMapAttr(gdo->do_BitMap,BMA_FLAGS) & BMF_STANDARD) == 0L) { struct BitMap tbm; ULONG col; InitBitMap(&tbm,1,width,height); tbm.Planes[0] = (UBYTE *)gdo->do_FullShadow; /* if (!GetCyberMapAttr(gdo->do_BitMap, CYBRMATTR_PIXELFMT)) */ if (GetBitMapAttr(gdo->do_BitMap, BMA_DEPTH) > 8L) { ULONG triplet[3]; GetRGB32(scr->ViewPort.ColorMap,0L,1L,triplet); col = (triplet[0] & 0xff0000) | (triplet[1] & 0xff00) | (triplet[2] & 0xff); } else col = 0; // ExtractColor(rp,&tbm,col,xpos,ypos,width,height); ExtractColor(&gdo->do_RPort,&tbm,col,0,0,width,height); BltBitMap(&tbm,0,0,&tbm,0,0,width,height,0x50,0xff,NULL); // invertieren der Maske } else { UWORD *p = gdo->do_FullShadow; for(ypos = 0;ypos < height;ypos++) { for(xpos = 0;xpos < wordwidth;xpos++,p++) { for(i = 0;i < depth;i++) *p |= *((UWORD *)gdo->do_BitMap->Planes[i]+ypos*(gdo->do_BitMap->BytesPerRow >> 1)+xpos); } } } { UWORD *p = gdo->do_HalfShadow; CopyMem(gdo->do_FullShadow,p,2*wordwidth*height); for(line = 0x5555,ypos = 0;ypos < height;ypos++) { line = ~line; for(xpos = 0;xpos < wordwidth;xpos++,p++) *p &= (UWORD)line; } } if (!boopsigad) FakeInputEvent(); UpdateDragObj(gdo,gdo->do_X,gdo->do_Y); /* show drag object */ return(gdo); }
// Draw an object void backdrop_draw_object( BackdropInfo *info, BackdropObject *object, UWORD flags, struct RastPort *rp, short left, short top) { UBYTE fpen=1,bpen=0,drawmode=JAM2,opus_drawmode=JAM2; UWORD *imagedata=0; struct Image *image=0; struct Rectangle rect; short len; BOOL comp=0,draw=1,state=0; short has_border; // No icon? if (!object->icon) return; // See if icon has no border has_border=backdrop_icon_border(object); // Not just clearing image? if (!(flags&BRENDERF_CLEAR)) { // Get image to render if ((image=(struct Image *)object->icon->do_Gadget.GadgetRender)) imagedata=image->ImageData; // Is icon selected? if (object->state) { // Is there a select image? if (object->icon->do_Gadget.SelectRender && (object->icon->do_Gadget.Flags&GFLG_GADGHIMAGE)) { if ((image=(struct Image *)object->icon->do_Gadget.SelectRender)) imagedata=image->ImageData; state=1; } else comp=1; } } #ifdef USE_DRAWICONSTATE if (GetIconRectangle( rp, object->icon, NULL, &rect, ICONDRAWA_Borderless, TRUE, TAG_DONE)) { object->pos.Width = rect.MaxX - rect.MinX + 1; object->pos.Height = rect.MaxY - rect.MinY + 1; } #elif defined(__MORPHOS__) if (ISOWN(object->icon)) { struct OwnDiskObject *o = (APTR)object->icon; object->pos.Width = o->pngimage_width; object->pos.Height = o->pngimage_height; } #endif // Get object position if (flags&BRENDERF_REAL) { short border_x=0,border_y_top=0,border_y_bottom=0; // Border? if (has_border) { // Use default border border_x=ICON_BORDER_X; border_y_top=ICON_BORDER_Y_TOP; border_y_bottom=ICON_BORDER_Y_BOTTOM; } // Calculate full size object->full_size.MinX=left-border_x; object->full_size.MinY=top-border_y_top; object->full_size.MaxX=left+object->pos.Width+border_x-1; object->full_size.MaxY=top+object->pos.Height+border_y_bottom-1; // Get image rectangle rect.MinX=object->full_size.MinX+(info->size.MinX-info->offset_x); rect.MinY=object->full_size.MinY+(info->size.MinY-info->offset_y); rect.MaxX=object->full_size.MaxX+(info->size.MinX-info->offset_x); rect.MaxY=object->full_size.MaxY+(info->size.MinY-info->offset_y); // Store position object->show_rect=rect; object->image_rect=rect; // Is object offscreen? if (rect.MaxX<info->size.MinX || rect.MaxY<info->size.MinY || rect.MinX>info->size.MaxX || rect.MinY>info->size.MaxY) draw=0; // Offset by coordinates left+=info->size.MinX-info->offset_x; top+=info->size.MinY-info->offset_y; } else { rect.MinX=left; rect.MinY=top; rect.MaxX=left+object->pos.Width-1; rect.MaxY=top+object->pos.Height-1; } // Clear area? if (flags&BRENDERF_CLEAR) { // Ok to draw? if (draw) { // Clear whole icon? if (!(flags&BRENDERF_LABEL)) { EraseRect(rp,rect.MinX,rect.MinY,rect.MaxX,rect.MaxY); } } // Can't draw else flags&=~BRENDERF_CLEAR; } // Object state changed? else if (object->flags&BDOF_STATE_CHANGE) { #ifndef USE_DRAWICONSTATE // Need to clear if transparent #if !defined(__MORPHOS__) if (!has_border) #endif EraseRect(rp,rect.MinX,rect.MinY,rect.MaxX,rect.MaxY); #endif object->flags&=~BDOF_STATE_CHANGE; } // Draw as normal if (!(flags&BRENDERF_CLEAR)) { // Not drawing if no image if (!imagedata) draw=0; // Ok to draw? if (draw) { struct BitMap bitmap; BOOL use_mask=0; // Full icon? if (flags&BRENDERF_REAL) { // Want border? if (has_border) { // Draw border around icon DrawBox(rp,&rect,GUI->draw_info,object->state); // Get background colour #ifdef USE_64BIT SetAPen( rp, (object->flags&BDOF_BACKGROUND)? object->pen: GUI->draw_info->dri_Pens[BACKGROUNDPEN]); #else SetAPen( rp, (object->flags&BDOF_BACKGROUND)? object->size: GUI->draw_info->dri_Pens[BACKGROUNDPEN]); #endif // Clear boundary around image #ifdef USE_DRAWICONSTATE RectFill(rp,rect.MinX+1,rect.MinY+1,rect.MaxX-1,rect.MaxY-1); #else RectFill(rp,rect.MinX+1,rect.MinY+1,rect.MaxX-1,rect.MinY+2); RectFill(rp,rect.MinX+1,rect.MinY+1,rect.MinX+3,rect.MaxY-1); RectFill(rp,rect.MinX+4,rect.MaxY-3,rect.MaxX-1,rect.MaxY-1); RectFill(rp,rect.MaxX-3,rect.MinY+3,rect.MaxX-1,rect.MaxY-4); #endif } #ifdef USE_DRAWICONSTATE else { EraseRect(rp,rect.MinX,rect.MinY,rect.MaxX,rect.MaxY); } #endif } #ifdef USE_DRAWICONSTATE DrawIconState( rp, object->icon, NULL, left, top, object->state ? IDS_SELECTED : IDS_NORMAL, ICONDRAWA_Frameless, TRUE, ICONDRAWA_Borderless, TRUE, ICONDRAWA_EraseBackground, FALSE, TAG_DONE); #else #if defined(__MORPHOS__) if (ISOWN(object->icon)) { IPTR tags[] = { BLTBMA_USESOURCEALPHA, TRUE, TAG_DONE }; struct OwnDiskObject *o = (APTR)object->icon; BltBitMapRastPortAlpha(o->pngimage, 0, 0, rp, left, top, o->pngimage_width, o->pngimage_height, (struct TagItem *)&tags); if (object->state) { ProcessPixelArray(rp, left, top, o->pngimage_width, o->pngimage_height, POP_TINT, 0x5082ff, NULL); } } else { #endif // Get image as a bitmap backdrop_image_bitmap(info,image,imagedata,&bitmap); // Using a mask (no border)? if (!has_border && object->image_mask[state]) { // Draw using a mask BltMaskBitMapRastPort( &bitmap,0,0, rp,left,top, image->Width,image->Height, 0xe0, (PLANEPTR)object->image_mask[state]); use_mask=1; } // Draw normally else { // Draw image BltBitMapRastPort( &bitmap,0,0, rp,left,top, image->Width,image->Height, 0xc0); } // Complement? if (comp) { DragInfo *drag_info; UBYTE mask; // Only complement to image depth mask=rp->Mask; SetWrMsk(rp,image->PlanePick); // Need backfill? if ((object->icon->do_Gadget.Flags&GFLG_GADGBACKFILL) && (drag_info=GetDragInfo(info->window,0,-object->pos.Width,-object->pos.Height,0))) { // Draw icon into drag buffer BltBitMapRastPort( &bitmap,0,0, &drag_info->drag_rp,0,0, image->Width,image->Height, 0xc0); // Build mask GetDragMask(drag_info); // Complement area with mask BltMaskBitMapRastPort( &drag_info->drag_bm, 0,0, rp, left,top, image->Width, image->Height, 0x20, (PLANEPTR)drag_info->bob.ImageShadow); // Free temporary drag info FreeDragInfo(drag_info); } // Just complement image else { ClipBlit( rp, left,top, rp, left,top, image->Width, image->Height, 0x50); } // Restore mask SetWrMsk(rp,mask); } #if defined(__MORPHOS__) } #endif #endif // Left out (on desktop), or a link? if (!(environment->env->desktop_flags&DESKTOPF_NO_ARROW) && ((object->type==BDO_LEFT_OUT && !(object->flags&BDOF_DESKTOP_FOLDER) && info->flags&BDIF_MAIN_DESKTOP) || object->flags&BDOF_LINK_ICON)) { struct Image *image; // Get correct image for this resolution image=(GUI->screen_info&SCRI_LORES)?&arrow_image[1]:&arrow_image[0]; // Is object big enough for the 'shortcut arrow'? if (object->pos.Width>(image->Width<<1) && object->pos.Height>image->Height+4) { // Draw arrow in bottom-left corner DrawImage(rp,image,rect.MinX,rect.MaxY-image->Height+1); } } // Ghosted icon? if (object->flags&BDOF_GHOSTED) { // Draw ghosting over the icon backdrop_draw_icon_ghost(rp,&rect,(use_mask)?(PLANEPTR)object->image_mask[state]:0); } } // Get pens from configuration fpen=(info->flags&BDIF_MAIN_DESKTOP)?environment->env->icon_fpen:environment->env->iconw_fpen; bpen=(info->flags&BDIF_MAIN_DESKTOP)?environment->env->icon_bpen:environment->env->iconw_bpen; drawmode=(info->flags&BDIF_MAIN_DESKTOP)?environment->env->icon_style:environment->env->iconw_style; opus_drawmode=drawmode; // Shadow/Outline? if (drawmode==MODE_SHADOW || drawmode==MODE_OUTLINE) { UBYTE temp; // Set back to JAM1 drawmode=JAM1; // Swap the pens temp=fpen; fpen=bpen; bpen=temp; } // Fix pens for user colours if (fpen>=4 && fpen<252) fpen=GUI->pens[fpen-4]; if (bpen>=4 && bpen<252) bpen=GUI->pens[bpen-4]; // Use fast call under 39 if(((struct Library *)GfxBase)->lib_Version>=39) { SetABPenDrMd(rp,fpen,bpen,drawmode); } else { SetAPen(rp,fpen); SetBPen(rp,bpen); SetDrMd(rp,drawmode); } } // Full icon? if (flags&BRENDERF_REAL && !(object->flags&BDOF_NO_LABEL)) { char *name,namebuf[40]; // Bad disk? if (object->type==BDO_BAD_DISK) { // Get bad disk name backdrop_bad_disk_name(object,namebuf); name=namebuf; } // Custom label? else if (object->flags&BDOF_CUSTOM_LABEL) name=object->device_name; // Get name pointer else name=object->name; // Get text length if ((len=strlen(name))) { struct TextExtent extent; short max_width=0,loop,textx,texty; // Splitting long labels? if (environment->env->desktop_flags&DESKTOPF_SPLIT_LABELS) { // Calculate maximum text width (minimum 6 chars) max_width=RECTWIDTH(&rect)+(RECTWIDTH(&rect)>>1); if (max_width<rp->Font->tf_XSize*6) max_width=rp->Font->tf_XSize*6; } // Position for text textx=rect.MinX+(RECTWIDTH(&rect)>>1); texty=rect.MaxY+ICON_LABEL_SPACE+rp->TxBaseline+((opus_drawmode==MODE_OUTLINE)?1:0); Move(rp,textx,texty); // Get text pixel size TextMultiLine(rp,name,len,max_width,TMLF_CENTER|TMLF_EXTENT,&extent); // Fix extent for shadow/outline if (opus_drawmode==MODE_SHADOW) { extent.te_Extent.MaxX++; extent.te_Width++; extent.te_Height++; } else if (opus_drawmode==MODE_OUTLINE) { extent.te_Extent.MinX--; extent.te_Extent.MaxX++; extent.te_Width+=2; extent.te_Height+=2; } // Stretch out rectangle sides if necessary if (extent.te_Extent.MinX<rect.MinX) object->full_size.MinX-=rect.MinX-extent.te_Extent.MinX; if (extent.te_Extent.MaxX>rect.MaxX) object->full_size.MaxX+=extent.te_Extent.MaxX-rect.MaxX; if (object->show_rect.MinX>extent.te_Extent.MinX) object->show_rect.MinX=extent.te_Extent.MinX; if (object->show_rect.MaxX<extent.te_Extent.MinX+extent.te_Width-1) object->show_rect.MaxX=extent.te_Extent.MinX+extent.te_Width-1; // Save bottom of text object->show_rect.MaxY+=ICON_LABEL_SPACE+extent.te_Height; // +((opus_drawmode==MODE_OUTLINE)?1:0); object->full_size.MaxY+=ICON_LABEL_SPACE+extent.te_Height; // +((opus_drawmode==MODE_OUTLINE)?1:0); // Clear? if (flags&BRENDERF_CLEAR) { EraseRect(rp, extent.te_Extent.MinX,rect.MaxY+ICON_LABEL_SPACE+((opus_drawmode==MODE_OUTLINE)?1:0), extent.te_Extent.MinX+extent.te_Width-1,rect.MaxY+ICON_LABEL_SPACE+extent.te_Height-1); } // Draw text else { // Is object selected? if (object->flags&BDOF_SELECTED) { if (drawmode==JAM2) SetDrMd(rp,INVERSVID|JAM2); else if (fpen!=GUI->draw_info->dri_Pens[HIGHLIGHTTEXTPEN]) SetAPen(rp,GUI->draw_info->dri_Pens[HIGHLIGHTTEXTPEN]); else SetAPen(rp,GUI->draw_info->dri_Pens[BACKGROUNDPEN]); } // Shadow if (opus_drawmode==MODE_SHADOW) { // Draw shadow text first Move(rp,textx+1,texty+1); TextMultiLine(rp,name,len,max_width,TMLF_CENTER,0); // Draw text SetAPen(rp,bpen); Move(rp,textx,texty); TextMultiLine(rp,name,len,max_width,TMLF_CENTER,0); } // Normal text else if (opus_drawmode!=MODE_OUTLINE) { // Render text TextMultiLine(rp,name,len,max_width,TMLF_CENTER,0); } // Outline else { Move(rp,textx+1,texty+1); for (loop=0;loop<5;loop++) { // Render text TextMultiLine(rp,name,len,max_width,TMLF_CENTER,0); // Doing shadow? if (loop<4) { short s_x=0,s_y=0; // Switch to other pen? if (loop==3) SetAPen(rp,bpen); // Get the new offsets else if (loop==0) { s_x=-1; s_y=1; } else if (loop==1) { s_x=-1; s_y=-1; } else if (loop==2) { s_x=1; s_y=-1; } // Position for text Move(rp,textx+s_x,texty+s_y); } } } // Reset draw mode if necessary if (object->flags&BDOF_SELECTED) SetDrMd(rp,drawmode); } }
void WgGfxDevice::ClipBlit( const WgRect& clip, const WgSurfacePtr& pSrc, int dx, int dy ) { ClipBlit( clip, pSrc, WgRect(0,0,pSrc->Width(),pSrc->Height()), dx, dy ); }
///ImageBackFill_CopyTiledBitMap() static void ImageBackFill_CopyTiledBitMap ( struct RastPort *SrcRast, WORD SrcOffsetX, WORD SrcOffsetY, WORD SrcSizeX, WORD SrcSizeY, struct RastPort *DstRast, struct Rectangle *DstAreaBounds, struct Rectangle *DstFillBounds, ULONG blit_MODE ) { WORD FirstSizeX; // the width of the rectangle to blit as the first column WORD FirstSizeY; // the height of the rectangle to blit as the first row WORD SecondMinX; // the left edge of the second column WORD SecondMinY; // the top edge of the second column WORD SecondSizeX; // the width of the second column WORD SecondSizeY; // the height of the second column WORD PosX, PosY; // used as starting position in the "exponential" blit WORD SizeX, SizeY; // used as bitmap size in the "exponential" blit WORD SrcX, SrcY; // used as bitmap size in the "exponential" blit struct BitMap *Src = SrcRast->BitMap; struct BitMap *Dst = DstRast->BitMap; #if defined(DEBUG) int xcount; int ycount; #endif D(bug("[IconWindow.ImageBackFill] ImageBackFill_CopyTiledBitMap(mode %d)\n", blit_MODE)); D(bug("[IconWindow.ImageBackFill] ImageBackFill_CopyTiledBitMap: SrcRast @ %x, DstRast @ %x\n", SrcRast, DstRast)); D(bug("[IconWindow.ImageBackFill] ImageBackFill_CopyTiledBitMap: AreaBounds @ %x, FillBounds @ %x\n", DstAreaBounds, DstFillBounds)); D(bug("[IconWindow.ImageBackFill] ImageBackFill_CopyTiledBitMap: AreaBounds.MinX %d\n", DstAreaBounds->MinX)); D(bug("[IconWindow.ImageBackFill] ImageBackFill_CopyTiledBitMap: AreaBounds.MinY %d\n", DstAreaBounds->MinY)); D(bug("[IconWindow.ImageBackFill] ImageBackFill_CopyTiledBitMap: AreaBounds.MaxX %d\n", DstAreaBounds->MaxX)); D(bug("[IconWindow.ImageBackFill] ImageBackFill_CopyTiledBitMap: AreaBounds.MaxY %d\n", DstAreaBounds->MaxY)); D(bug("[IconWindow.ImageBackFill] ImageBackFill_CopyTiledBitMap: AreaBounds Width %d Height %d\n", (DstAreaBounds->MaxX - DstAreaBounds->MinX) + 1, (DstAreaBounds->MaxY - DstAreaBounds->MinY) + 1)); D(bug("[IconWindow.ImageBackFill] ImageBackFill_CopyTiledBitMap: FillBounds.MinX %d\n", DstFillBounds->MinX)); D(bug("[IconWindow.ImageBackFill] ImageBackFill_CopyTiledBitMap: FillBounds.MinY %d\n", DstFillBounds->MinY)); D(bug("[IconWindow.ImageBackFill] ImageBackFill_CopyTiledBitMap: FillBounds.MaxX %d\n", DstFillBounds->MaxX)); D(bug("[IconWindow.ImageBackFill] ImageBackFill_CopyTiledBitMap: FillBounds.MaxY %d\n", DstFillBounds->MaxY)); D(bug("[IconWindow.ImageBackFill] ImageBackFill_CopyTiledBitMap: FillBounds Width %d Height %d\n", (DstAreaBounds->MaxX - DstAreaBounds->MinX) + 1, (DstAreaBounds->MaxY - DstAreaBounds->MinY) + 1)); FirstSizeX = MIN(SrcSizeX - SrcOffsetX, RECTSIZEX(DstFillBounds)); // the width of the first tile, this is either the rest of the tile right to SrcOffsetX or the width of the dest rect, if the rect is narrow SecondMinX = DstFillBounds->MinX + FirstSizeX; // the start for the second tile (if used) SecondSizeX = MIN(SrcOffsetX, DstFillBounds->MaxX-SecondMinX + 1); // the width of the second tile (we want the whole tile to be SrcSizeX pixels wide, if we use SrcSizeX-SrcOffsetX pixels for the left part we'll use SrcOffsetX for the right part) FirstSizeY = MIN(SrcSizeY - SrcOffsetY, RECTSIZEY(DstFillBounds)); // the same values are calculated for y direction SecondMinY = DstFillBounds->MinY + FirstSizeY; SecondSizeY = MIN(SrcOffsetY, DstFillBounds->MaxY - SecondMinY + 1); if (blit_MODE == blit_MODE_Blit) // blit the first piece of the tile { D(bug("[IconWindow.ImageBackFill] ImageBackFill_CopyTiledBitMap: 1st Tile Part @ %d,%d [%d x %d]\n", DstFillBounds->MinX, DstFillBounds->MinY, FirstSizeX, FirstSizeY)); BltBitMap(Src, SrcOffsetX, SrcOffsetY, Dst, DstFillBounds->MinX, DstFillBounds->MinY, FirstSizeX, FirstSizeY, 0xC0, -1, NULL); if (SecondSizeX > 0) // if SrcOffset was 0 or the dest rect was too narrow, we won't need a second column { D(bug("[IconWindow.ImageBackFill] ImageBackFill_CopyTiledBitMap: 2nd Tile Part @ %d,%d [%d x %d]\n", SecondMinX, DstFillBounds->MinY, SecondSizeX, FirstSizeY)); BltBitMap(Src, 0, SrcOffsetY, Dst, SecondMinX, DstFillBounds->MinY, SecondSizeX, FirstSizeY, 0xC0, -1, NULL); } if (SecondSizeY > 0) // is a second row necessary? { D(bug("[IconWindow.ImageBackFill] ImageBackFill_CopyTiledBitMap: 3rd Tile Part @ %d,%d [%d x %d]\n", DstFillBounds->MinX, SecondMinY, FirstSizeX, SecondSizeY)); BltBitMap(Src, SrcOffsetX, 0, Dst, DstFillBounds->MinX, SecondMinY, FirstSizeX, SecondSizeY, 0xC0, -1, NULL); if (SecondSizeX > 0) { D(bug("[IconWindow.ImageBackFill] ImageBackFill_CopyTiledBitMap: 4th Tile Part @ %d,%d [%d x %d]\n", SecondMinX, SecondMinY, SecondSizeX, SecondSizeY)); BltBitMap(Src, 0, 0, Dst, SecondMinX, SecondMinY, SecondSizeX, SecondSizeY, 0xC0, -1, NULL); } } #if defined(DEBUG) xcount = 2; #endif //Generates the first row of the tiles .... for (PosX = DstFillBounds->MinX + SrcSizeX, SizeX = MIN(SrcSizeX, (DstFillBounds->MaxX - PosX) + 1);PosX <= DstFillBounds->MaxX;) { #if defined(DEBUG) D(bug("[IconWindow.ImageBackFill] ImageBackFill_CopyTiledBitMap: Row 1 Tile %d @ %d,%d [%d x %d]\n", xcount, PosX, DstFillBounds->MinY, SizeX, MIN(SrcSizeY, RECTSIZEY(DstFillBounds)))); xcount++; #endif BltBitMap(Dst, DstFillBounds->MinX, DstFillBounds->MinY, Dst, PosX, DstFillBounds->MinY, SizeX, MIN(SrcSizeY, RECTSIZEY(DstFillBounds)), 0xC0, -1, NULL); PosX += SizeX; SizeX = MIN(SrcSizeX, (DstFillBounds->MaxX - PosX) + 1); } #if defined(DEBUG) ycount = 2; #endif // .. now Blit the first row down several times to fill the whole dest rect for (PosY = DstFillBounds->MinY + SrcSizeY, SizeY = MIN(SrcSizeY, (DstFillBounds->MaxY - PosY) + 1);PosY <= DstFillBounds->MaxY;) { #if defined(DEBUG) D(bug("[IconWindow.ImageBackFill] ImageBackFill_CopyTiledBitMap: Row %d @ %d,%d [%d x %d]\n", ycount, DstFillBounds->MinX, PosY, MIN(SrcSizeX, RECTSIZEX(DstFillBounds)), SizeY)); ycount++; #endif BltBitMap(Dst, DstFillBounds->MinX, DstFillBounds->MinY, Dst, DstFillBounds->MinX, PosY, MIN(SrcSizeX, RECTSIZEX(DstFillBounds)), SizeY, 0xC0, -1, NULL); PosY += SizeY; SizeY = MIN(SrcSizeY, (DstFillBounds->MaxY - PosY) + 1); } } else if (blit_MODE == blit_MODE_Clip) { for (SrcY = MOD(SrcOffsetY + MOD((DstFillBounds->MinY - DstAreaBounds->MinY), SrcSizeY - 1), SrcSizeY - 1), PosY = DstFillBounds->MinY, SizeY = MIN((SrcSizeY - SrcY), (DstFillBounds->MaxY - DstFillBounds->MinY ) + 1); PosY <= DstFillBounds->MaxY;) { for (SrcX = MOD(SrcOffsetX + MOD((DstFillBounds->MinX - DstAreaBounds->MinX), SrcSizeY - 1), SrcSizeX - 1), PosX = DstFillBounds->MinX, SizeX = MIN((SrcSizeX - SrcX), (DstFillBounds->MaxX - DstFillBounds->MinX ) + 1); PosX <= DstFillBounds->MaxX;) { D(bug("[IconWindow.ImageBackFill] ImageBackFill_CopyTiledBitMap: ClipBlit @ %d,%d [%d x %d]\n", PosX, PosY, SizeX, SizeY)); ClipBlit(SrcRast, SrcX, SrcY, DstRast, PosX, PosY, SizeX, SizeY, 0xC0); if (SrcX != 0) SrcX = 0; PosX += SizeX; SizeX = MIN(SrcSizeX, (DstFillBounds->MaxX - PosX) + 1); } if (SrcY != 0) SrcY = 0; PosY += SizeY; SizeY = MIN(SrcSizeY, (DstFillBounds->MaxY - PosY) + 1); } } }