/****************************************************************************************************************/ /* RollOver Button written by J.DUMAY */ /****************************************************************************************************************/ /* ROB_NewRollOverButton */ /* ROB_DelRollOver */ /* ROB_SetClickReflex */ /* ROB_SetCursorMoveInReflex */ /* ROB_SetCursorMoveOutReflex */ /* ROB_GetObject */ /* ROB_ChangeDisplayFlags */ /* ROB_ChangeCoordinates */ /* ROB_GetCoordinates */ /****************************************************************************************************************/ /* librairy used: _jint2D _jobj2dlib.pkg */ /****************************************************************************************************************/ /* le type de creation de bouton */ var NO_CREATION=0;; var AUTO_CREATION=1;; /* presence de texte */ var TEXT_BUTTON=1;; var NO_TEXT_BUTTON=0;; /* les differents etats du bouton */ var STATE_OFF_UNDISPLAYED=0;; /* undisplay */ var STATE_OFF=1;; /* highlight */ var STATE_OFF_PUSHED=2;; /* pushed */ var STATE_OFF_PUSHED_OUT=3;; /* pushed out*/ /* RollOverButtonType: ROBObj2D:l'objet 2D associe ROBbitmap:bitmap contenant les differents etats du bouton ROBlistcoordinatesinbitmap:liste des coordonnees des differents etats du bouton ROBmask:le bouton possede un masque (1) ou pas (0) ROBstate:etat du bouton ROBtransparency:couleur de transparence ROBClickReflex:reflexe utilisateur lors du clic sur le bouton ROBCursorMoveInReflex:reflexe utilisateur lorsque la souris entre sur le bouton ROBCursorMoveOutReflex:reflexe utilisateur lorsque la souris sort sur le bouton */ struct RollOverButtonType=[ ROBObj2D:Obj2D, ROBbitmap:ObjBitmap, ROBlistcoordinatesinbitmap:[[I I] r1], ROBmask:I, ROBstate:I, ROBtransparency:I, ROBClickReflex:fun [RollOverButtonType I I I] RollOverButtonType, ROBCursorMoveInReflex:fun [RollOverButtonType I I I] RollOverButtonType, ROBCursorMoveOutReflex:fun [RollOverButtonType I I I] RollOverButtonType ] MkRollOverButtonType;; /****************************************************************************************************************************/ /* Fonctions Internes du RollOverButton */ /****************************************************************************************************************************/ /* Cree la bitmap globale des differents etats du rollover a partir d'une bitmap.renvoie la bitmap global et les coordonnees de chacun des etats du bouton: Channel:canal de creation de la bitmap Bmpref:ObjBitmap d'origine ListCoordinatesInRef:liste de coordonnees dans la bitmapde reference IsThereAMask:presence d'un masque dans la bitmap de reference (1) ou pas (0) TransparencyXcoord:coordonnees de la couleur de transparence.Si pas de transparence vaut [-1 -1] HighLightUdpCoeff:coefficient pour highlighter l'etat udp de type S HighLightOffCoeff:coefficient pour highlighter l'etat off de type S */ fun CreateRollOverBitmapsFromBmp(Channel,BmpRef,ListCoordinatesInRef,IsThereAMask,TransparencyXcoord,TransparencyYcoord,HighLightUdpCoeff,HighLightOffCoeff)= { let sizelist ListCoordinatesInRef -> taillelist in if (taillelist==1)&&(IsThereAMask) then { FatalError "Cowin AutoCreation""Creation failed because there is the mask is not defined"; nil } else let _GETbitmapSize BmpRef -> [XSizeRef YSizeRef] in let (if taillelist==1 then [XSizeRef YSizeRef] else [XSizeRef YSizeRef/2]) -> [xsize ysize] in let hd ListCoordinatesInRef -> [xBtn yBtn] in let hd tl ListCoordinatesInRef -> [xMask yMask] in let TransparentColor BmpRef TransparencyXcoord TransparencyYcoord -> Transparency in let _CRbitmap _channel xsize (if taillelist==1 then ysize*3 else ysize*4) -> BmpRes in let [ (_CPbitmap16 (_CRbitmap Channel xsize ysize) 0 0 BmpRef xBtn yBtn xsize ysize nil) (_CPbitmap16 (_CRbitmap Channel xsize ysize) 0 0 BmpRef xBtn yBtn xsize ysize nil) nil (if taillelist==1 then (_FILLbitmap (_CRbitmap Channel xsize ysize) 0xFFFFFF) else (_CPbitmap16 (_CRbitmap Channel xsize ysize) 0 0 BmpRef xMask yMask xsize ysize nil) ) (_FILLbitmap (_CRbitmap Channel xsize ysize) Transparency) ] -> [UdpBmp OffBmp PushedBmp MaskBmp Transp] in { /* udp bitmap */ set UdpBmp=_MULbitmap UdpBmp 0 0 xsize ysize HighLightUdpCoeff HighLightUdpCoeff HighLightUdpCoeff nil; set Transp=_SPLUSbitmap Transp 0 0 xsize ysize MaskBmp 0 0; set UdpBmp=_CPbitmap16 UdpBmp 0 0 Transp 0 0 xsize ysize 0xFFFFFF; set Transp=_FILLbitmap Transp Transparency; /* off bitmap */ set OffBmp=_MULbitmap OffBmp 0 0 xsize ysize HighLightOffCoeff HighLightOffCoeff HighLightOffCoeff nil; set Transp=_SPLUSbitmap Transp 0 0 xsize ysize MaskBmp 0 0; set OffBmp=_CPbitmap16 OffBmp 0 0 Transp 0 0 xsize ysize 0xFFFFFF; /* pushed bitmap */ set PushedBmp=(_CPbitmap16 (_FILLbitmap (_CRbitmap _channel xsize ysize) Transparency) 1 1 OffBmp 0 0 xsize ysize nil); /* bitmap res */ set BmpRes=_CPbitmap16 BmpRes 0 0 UdpBmp 0 0 xsize ysize nil; set BmpRes=_CPbitmap16 BmpRes 0 ysize OffBmp 0 0 xsize ysize nil; set BmpRes=_CPbitmap16 BmpRes 0 2*ysize PushedBmp 0 0 xsize ysize nil; if taillelist==2 then set BmpRes=_CPbitmap16 BmpRes 0 3*ysize MaskBmp 0 0 xsize ysize nil else nil; /* destruction des bitmaps temporaires */ _DSbitmap UdpBmp; _DSbitmap OffBmp; _DSbitmap PushedBmp; _DSbitmap Transp; _DSbitmap MaskBmp; [ BmpRes ([0 0]::[0 ysize]::[0 2*ysize]::(if taillelist==2 then [0 3*ysize]::nil else nil) ) ]; }; };; /* renvoie les coordonnees de l'etat du bouton dans la bitmap globale */ fun RollOverBitmapCoordinatesToUse(rollover)= { nth_list rollover.ROBlistcoordinatesinbitmap ( if (rollover.ROBstate==STATE_OFF_UNDISPLAYED) then 0 else if (rollover.ROBstate==STATE_OFF) then 1 else if (rollover.ROBstate==STATE_OFF_PUSHED) then 2 else if (rollover.ROBstate==STATE_OFF_PUSHED_OUT) then 1 else 0 ) };; /* Methode Paint*/ fun PaintRollOver(rollover)= let rollover.ROBObj2D -> obj in let RollOverBitmapCoordinatesToUse rollover -> [XInGlobal YInGlobal] in [ rollover.ROBbitmap XInGlobal YInGlobal obj.O2Dw obj.O2Dh rollover.ROBtransparency ];; /* Methode Paint Part */ fun PaintPartOfRollOver(area,rollover)= let RollOverBitmapCoordinatesToUse rollover -> [XInGlobal YInGlobal] in let IntersectionRectangle MkRectangle2D [ MkInt2DPoint[XInGlobal YInGlobal] MkInt2DPoint[XInGlobal+rollover.ROBObj2D.O2Dw YInGlobal+rollover.ROBObj2D.O2Dh] ] MoveRectangleBy area MkInt2DPoint[XInGlobal YInGlobal] -> rect in let SizeRectangle rect -> [rw rh] in [ rollover.ROBbitmap rect.RctHG.iptX rect.RctHG.iptY rw rh rollover.ROBtransparency ] ;; /* Methode IsMouseOnObject */ fun IsMouseOnRollOver(MouseCol,MouseLgn,rollover)= let rollover.ROBObj2D -> obj in if rollover.ROBmask then let nth_list rollover.ROBlistcoordinatesinbitmap 3 -> [XInGlobal YInGlobal] in (_GETpixel16 rollover.ROBbitmap (XInGlobal+MouseCol-obj.O2Dx) (YInGlobal+MouseLgn-obj.O2Dy)) !=0 else let RollOverBitmapCoordinatesToUse rollover -> [XInGlobal YInGlobal] in (rollover.ROBtransparency==nil) ||((_GETpixel16 rollover.ROBbitmap (XInGlobal+MouseCol-obj.O2Dx) (YInGlobal+MouseLgn-obj.O2Dy)) !=rollover.ROBtransparency) ;; /* Methode Move Out Object*/ fun MoveOutRollOver(mousecol,mouselgn,mousebuttons,rollover)= set rollover.ROBstate=STATE_OFF_UNDISPLAYED; let rollover.ROBObj2D -> obj in { O2D_RedrawObj obj; exec rollover.ROBCursorMoveOutReflex with [rollover mousecol mouselgn mousebuttons]; }; 1 ;; /* Methode Move In Object*/ fun MoveInRollOver(mousecol,mouselgn,mousebuttons,rollover)= if rollover.ROBstate==STATE_OFF then set rollover.ROBstate=STATE_OFF_UNDISPLAYED else set rollover.ROBstate=STATE_OFF; let rollover.ROBObj2D -> obj in { O2D_RedrawObj obj; exec rollover.ROBCursorMoveInReflex with [rollover mousecol mouselgn mousebuttons]; }; 1 ;; /* Methode Move Out object with button pushed */ fun MoveOutRollOverWithBtnClicked(mousecol,mouselgn,mousebuttons,rollover)= let rollover.ROBObj2D -> obj in if rollover.ROBstate==STATE_OFF then { nil } else if rollover.ROBstate==STATE_OFF_PUSHED then { set rollover.ROBstate=STATE_OFF_PUSHED_OUT; O2D_RedrawObj obj } else nil; 1 ;; /* Methode Move In object with button pushed */ fun MoveInRollOverWithBtnClicked(mousecol,mouselgn,mousebuttons,rollover)= if rollover.ROBstate==STATE_OFF_PUSHED_OUT then { /* Make the button Pushed */ set rollover.ROBstate=STATE_OFF_PUSHED; O2D_RedrawObj rollover.ROBObj2D } else nil;/* The button should not be redrawn */ 1 ;; /* Methode Click Out */ fun ClickOutRollOver(mousecol,mouselgn,mousebuttons,rollover)= { let rollover.ROBObj2D -> obj in { set obj.O2DParentContainer.CoUserMoveIsAllowed=0; if rollover.ROBstate==STATE_OFF then { set obj.O2DParentContainer.CoHandledObject=nil; nil } else if rollover.ROBstate==STATE_OFF_PUSHED then { set rollover.ROBstate=STATE_OFF_PUSHED_OUT; O2D_RedrawArea obj.O2DParentContainer (O2D_RectangleIncludingObject obj) 1 } else nil; }; 1 };; /* Methode Click In */ fun ClickInRollOver(mousecol,mouselgn,mousebuttons,rollover)= { if mousebuttons==1 then { set rollover.ROBstate=STATE_OFF_PUSHED; let rollover.ROBObj2D -> obj in O2D_RedrawArea obj.O2DParentContainer (O2D_RectangleIncludingObject obj) 1; } else { exec rollover.ROBClickReflex with [rollover mousecol mouselgn mousebuttons]; nil }; 1 };; /* Methode UnClick In */ fun UnClickInRollOver(mousecol,mouselgn,mousebuttons,rollover)= { if mousebuttons==1 then { set rollover.ROBstate=STATE_OFF; let rollover.ROBObj2D -> obj in O2D_RedrawArea obj.O2DParentContainer (O2D_RectangleIncludingObject obj) 1; exec rollover.ROBClickReflex with [rollover mousecol mouselgn mousebuttons]; } else nil; 1 };; /* Methode UnClick Out */ fun UnClickOutRollOver(mousecol,mouselgn,mousebuttons,rollover)= { set rollover.ROBstate=STATE_OFF_UNDISPLAYED; let rollover.ROBObj2D -> obj in O2D_RedrawArea obj.O2DParentContainer (O2D_RectangleIncludingObject obj) 1; 1 };; fun IsUserClickAllowedInRollOver()= { 0 };; fun IsUserUnClickAllowedInRollOver()= { 0 };; /* Methode destruction object */ fun DsRollOverButton(rollover)= { _DSbitmap rollover.ROBbitmap; set rollover.ROBlistcoordinatesinbitmap=nil; set rollover.ROBmask=nil; set rollover.ROBstate=nil; set rollover.ROBtransparency=nil; set rollover.ROBClickReflex=nil; set rollover.ROBCursorMoveInReflex=nil; set rollover.ROBCursorMoveOutReflex=nil; 1 };; /**************************************************************************************************************************/ /* Fonctions externes du RollOverButton */ /**************************************************************************************************************************/ /* Constructeur du RollOver Channel:canal de construction Container:container auquel appartient le rollover ObjPere:l'objet pere Coordinates:coordonnees de l'objet par rapport au pere RollOverFlags:flag de construction (O2D_ENABLE,O2D_DISABLE,O2D_HIDE) Name:Nom de l'objet Res:ressource pour construire l'objet (bitmap ou fichier) ListCoordinatesInBitmap:liste des coordonees dans la bitmap de reference IsThereAMask:presence d'un mask dans la bitmap de reference (1) ou pas TypeCreation:type de creation :AUTO_CREATION:creation automatique de la bitmap global du rollover a partir de la bitmap de reference NO_CREATIOn:pas de creation de la bitmape globale TransparencyCoords:coordonnees de transparence CoeffHighLight:coefficient pour le highlight de l'etat highlight de type S */ fun ROB_New(Channel, Container, ObjPere, Coordinates, RollOverFlags, Name, bmp, ListCoordinatesInBitmap, IsThereAMask, TypeCreation, TransparencyCoords, CoeffHighLight )= { if Container!=nil then { let (if TransparencyCoords==nil then [(-1) (-1)] else TransparencyCoords) -> [TransparencyXCoord TransparencyYCoord] in let (if TypeCreation==AUTO_CREATION then CreateRollOverBitmapsFromBmp Channel bmp ListCoordinatesInBitmap IsThereAMask TransparencyXCoord TransparencyYCoord (atof "1") (atof CoeffHighLight) else [bmp ListCoordinatesInBitmap] ) -> [bmpglobale listecoords] in let _GETbitmapSize bmpglobale -> [xsize ysize] in let O2D_NewObject Container ObjPere Name xsize ysize/(sizelist listecoords) Coordinates RollOverFlags -> Obj in let MkRollOverButtonType [ Obj bmpglobale listecoords IsThereAMask STATE_OFF_UNDISPLAYED TransparentColor bmpglobale TransparencyXCoord TransparencyYCoord nil nil nil ] -> rollover in { /* les methodes */ O2D_CBDsObject Obj rollover @DsRollOverButton; O2D_CBPaint Obj rollover @PaintRollOver; O2D_CBPaintPart Obj rollover @PaintPartOfRollOver; O2D_CBIsMouseOnDisplayObject Obj rollover @IsMouseOnRollOver; O2D_CBUserClickAllowed Obj rollover @IsUserClickAllowedInRollOver; O2D_CBUserUnClickAllowed Obj rollover @IsUserUnClickAllowedInRollOver; O2D_CBCursorMoveOut Obj rollover @MoveOutRollOver; O2D_CBCursorMoveIn Obj rollover @MoveInRollOver; O2D_CBCursorMoveInWithButtonPush Obj rollover @MoveInRollOverWithBtnClicked; O2D_CBCursorMoveOutWithButtonPush Obj rollover @MoveOutRollOverWithBtnClicked; O2D_CBObjectClickIn Obj rollover @ClickInRollOver; O2D_CBObjectClickOut Obj rollover @ClickOutRollOver; O2D_CBObjectUnClickIn Obj rollover @UnClickInRollOver; O2D_CBObjectUnClickOut Obj rollover @UnClickOutRollOver; rollover }; } else { /* le container est vide */ FatalError "RollOver Creation impossible" "Container is nil"; nil }; };; fun ROB_Del(rollover)= O2D_DelObject rollover.ROBObj2D; rollover ;; fun ROB_SetClickReflex(rollover,ReflexeClick,ParamClick)= if rollover==nil then nil else set rollover.ROBClickReflex=mkfun5 ReflexeClick ParamClick;; fun ROB_SetCursorMoveInReflex(rollover,ReflexeCursorMoveIn,ParamCursorMoveIn)= if rollover==nil then nil else set rollover.ROBCursorMoveInReflex=mkfun5 ReflexeCursorMoveIn ParamCursorMoveIn;; fun ROB_SetCursorMoveOutReflex(rollover,ReflexeCursorMoveOut,ParamCursorMoveOut)= if rollover==nil then nil else set rollover.ROBCursorMoveOutReflex=mkfun5 ReflexeCursorMoveOut ParamCursorMoveOut;; fun ROB_GetObject(rollover)= rollover.ROBObj2D;; fun ROB_ChangeDisplayFlags(rollover,NewFlag,RedrawFlag,RepaintFlag)= O2D_ChangeObjDisplayFlag rollover.ROBObj2D NewFlag RedrawFlag RepaintFlag; rollover;; fun ROB_ChangeCoordinates(rollover,NewCoordinates,RedrawFlag,RepaintFlag)= O2D_ChangeObjCoordinates rollover.ROBObj2D NewCoordinates RedrawFlag RepaintFlag; rollover;; fun ROB_GetCoordinates(rollover)= O2D_GetObjCoordinates rollover.ROBObj2D;; /*+mb+*/ /******************************************************/ /* returns the graphical state of a RollOver Button: */ /* [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 */ /* This may be usefull to know how the button is */ /* represented without having it really exist */ fun ROB_GetGraphicalState (rollover)= let rollover.ROBObj2D -> obj in let RollOverBitmapCoordinatesToUse rollover -> [XInGlobal YInGlobal] in [rollover.ROBbitmap XInGlobal YInGlobal obj.O2Dw obj.O2Dh rollover.ROBtransparency];;