/**************************************************************************************/ /* librairy used: _jint2D _jobj2dlib.pkg */ /* need: jBitmaph.pkg */ /**************************************************************************************/ /**************************************************************************************/ /* 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 CursorMoveBitmap(mousecol,mouselgn,mousebuttons,bmp)= exec bmp.BMPCursorMoveReflex with [bmp mousecol mouselgn mousebuttons]; 1;; fun UnclickInBitmap (mousecol,mouselgn,mousebuttons,bmp)= exec bmp.BMPUnclickReflex 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.BMPbitmap=nil; 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 )= if (Channel==nil) || (Container==nil) || (Coordinates==nil) || (Img==nil) || (Name==nil) || (x==nil) || (y==nil) || (xsize==nil) || (ysize== nil) then nil else let O2D_NewObject Container ObjPere Name xsize ysize Coordinates BmpFlags -> Obj in if Obj==nil then nil else let MkBitmapType [Obj x y Img Transparency nil nil 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_CBObjectUnClickIn Obj bmp @UnclickInBitmap; O2D_CBCursorMove Obj bmp @CursorMoveBitmap; 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_SetUnclickReflex (bmp, ReflexeClick, ParamClick)= if bmp==nil then nil else set bmp.BMPUnclickReflex=mkfun5 ReflexeClick ParamClick;; fun BMP_SetCursorMoveReflex (bmp, Reflexe, Param)= if bmp==nil then nil else set bmp.BMPCursorMoveReflex=mkfun5 Reflexe Param;; 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 bmp==nil then nil else { _DSbitmap bmp.BMPbitmap; 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;; fun BMP_GetBitmap (bmp)= bmp.BMPbitmap;; fun BMP_GetSize (bmp)= if bmp==nil then nil else [bmp.BMPObj2D.O2Dw bmp.BMPObj2D.O2Dh];; /*+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];;