struct BitmapType=[ BMPObj2D:Obj2D, BMPfirstx:I, BMPfirsty:I, BMPbitmap:ObjBitmap, BMPTransparency:I, BMPClickReflex:fun [BitmapType I I I] BitmapType, BMPDblClickReflex:fun [BitmapType I I I] BitmapType ] MkBitmapType;; /*******************************************************************************************************************************/ /* Fonctions Intrinseques au Bitmap */ /*******************************************************************************************************************************/ fun PaintBitmap(bmp)= [ bmp.BMPbitmap 0 0 bmp.BMPObj2D.O2Dw bmp.BMPObj2D.O2Dh bmp.BMPTransparency ];; fun PaintPartOfBitmap(area,bmp)= let SizeRectangle area -> [aw ah] in [ bmp.BMPbitmap area.RctHG.iptX area.RctHG.iptY aw ah bmp.BMPTransparency ] ;; fun IsMouseOnBitmap(MouseCol,MouseLgn,bmp)= let bmp.BMPObj2D -> obj in (bmp.BMPTransparency==nil) ||((_GETpixel16 bmp.BMPbitmap (bmp.BMPfirstx+MouseCol-obj.O2Dx) (bmp.BMPfirsty+MouseLgn-obj.O2Dy))!=bmp.BMPTransparency) ;; fun IsUserClickAllowedInBitmap()=1;; fun IsUserUnClickAllowedInBitmap()=1;; fun ClickInBitmap(mousecol,mouselgn,mousebuttons,bmp)= exec bmp.BMPClickReflex with [bmp mousecol mouselgn mousebuttons]; 1;; fun DblClickInBitmap(mousecol,mouselgn,mousebuttons,bmp)= exec bmp.BMPDblClickReflex with [bmp mousecol mouselgn mousebuttons]; 1;; fun DsBitmap(bmp)= { _DSbitmap bmp.BMPbitmap; set bmp.BMPfirstx=nil; set bmp.BMPfirsty=nil; set bmp.BMPbitmap=nil; set bmp.BMPTransparency=nil; set bmp.BMPClickReflex=nil; set bmp.BMPDblClickReflex=nil; 1 };; /******************************************************************************************************************************/ /* Les fonctions externes */ /******************************************************************************************************************************/ fun BMP_New( Channel, Container, ObjPere, Coordinates, BmpFlags, Name, Img, x, y, xsize, ysize, Transparency )= { let O2D_NewObject Container ObjPere Name xsize ysize Coordinates BmpFlags -> Obj in let MkBitmapType [Obj x y Img Transparency nil nil] -> bmp in { /* les methodes */ O2D_CBPaint Obj bmp @PaintBitmap; O2D_CBPaintPart Obj bmp @PaintPartOfBitmap; O2D_CBIsMouseOnDisplayObject Obj bmp @IsMouseOnBitmap; O2D_CBObjectClickIn Obj bmp @ClickInBitmap; O2D_CBObjectDblClickIn Obj bmp @DblClickInBitmap; O2D_CBUserClickAllowed Obj bmp @IsUserClickAllowedInBitmap; O2D_CBUserUnClickAllowed Obj bmp @IsUserUnClickAllowedInBitmap; O2D_CBDsObject Obj bmp @DsBitmap; bmp }; };; fun BMP_Del(bmp)= O2D_DelObject bmp.BMPObj2D;; fun BMP_SetClickReflex(bmp,ReflexeClick,ParamClick)= if bmp==nil then nil else set bmp.BMPClickReflex=mkfun5 ReflexeClick ParamClick;; fun BMP_SetDblClickReflex(bmp,ReflexeDblClick,ParamDblClick)= if bmp==nil then nil else set bmp.BMPDblClickReflex=mkfun5 ReflexeDblClick ParamDblClick;; fun BMP_GetObject(bmp)= bmp.BMPObj2D;; fun BMP_ChangeDisplayFlags(bmp,NewFlag,RedrawFlag,RepaintFlag)= O2D_ChangeObjDisplayFlag bmp.BMPObj2D NewFlag RedrawFlag RepaintFlag; bmp;; fun BMP_ChangeCoordinates(bmp,NewCoordinates,RedrawFlag,RepaintFlag)= O2D_ChangeObjCoordinates bmp.BMPObj2D NewCoordinates RedrawFlag RepaintFlag; bmp;; fun BMP_GetCoordinates(bmp)= O2D_GetObjCoordinates bmp.BMPObj2D;; fun BMP_ChangeBitmap(bmp,bitmap)= { if bitmap==nil then { set bmp.BMPbitmap=nil; set bmp.BMPObj2D.O2Dw=0; set bmp.BMPObj2D.O2Dh=0; } else let _GETbitmapSize bitmap -> [w h] in { set bmp.BMPbitmap=bitmap; set bmp.BMPObj2D.O2Dw=w; set bmp.BMPObj2D.O2Dh=h; }; bmp };; /*+mb+*/ /******************************************************/ /* returns the graphical state of a Bitmap : */ /* [bitmap x y w h transp] */ /* where : */ /* x = abs in bitmap */ /* y = ord in bitmap */ /* w = width in bitmap */ /* h = height in bitmap */ /* transp : transparency color */ fun BMP_GetGraphicalState (bmp)= [bmp.BMPbitmap bmp.BMPfirstx bmp.BMPfirsty bmp.BMPObj2D.O2Dw bmp.BMPObj2D.O2Dh bmp.BMPTransparency];;