/* rev 11 - 2001 - by Sebastien DENEUX */ /* add event with no url by iri 01/2004 (function cbClic) */ /* rev 03/2004 by iri : event if logo is shown */ typeof Bitmap = ObjBitmap;; typeof BitmapH = I;; typeof BitmapL = I;; typeof class = S;; struct Tdata = [ D_posX : I, /* X position of the logo */ D_posY : I, /* Y position of the logo */ D_view_posX : I, D_view_posY : I, D_url : S, /* url to redirect when click */ D_bitmap : ObjBitmap, /* bitmap on he screen */ D_bitmapW : I, /* widht of the bitmap */ D_bitmapH : I, /* Height of the bitmap */ D_show : I, /* flag to show the bitmap */ D_in : I, /* The mouse is in the bitmap */ D_alias : S, /* text on the picture */ D_trans : I ] mkData;; /******************************************************************* blit the logon on the screen o -> Obj z -> p -> Tdata ********************************************************************/ fun cbBlitLogo(o, b, p) = let p -> [z transColor] in let b->[surf [l h]] in if z.D_show && (_GETsurfaceState == SURFACE_WINDOWED) then let if z.D_trans then transColor else nil -> transparence in _Bitmap2Surface surf z.D_view_posX z.D_view_posY z.D_bitmap 0 0 z.D_bitmapW z.D_bitmapH transparence else nil; 0 ;; /********************************************************************* find extension file fi -> S : name of the file <- S : extension **********************************************************************/ fun extension(fi) = let 0->j in let 0->find in ( while ((set find=strfind "." fi j)!=nil) do ( set j=find+1 ); substr fi j (strlen fi)-j ) ;; /********************************************************************* open the bitmap stringF -> S : name of the bitmap p -> Tdata *********************************************************************/ fun openBMP(stringF, p) = let _checkpack stringF->fP in if (fP != nil) then ( if (!strcmpi (extension stringF) "png") then ( let _LDalphaBitmap _channel fP->alphabmp in let _GETalphaBitmapSize alphabmp->[l h] in let _GETalphaBitmaps alphabmp -> [bmp b8] in ( _DSbitmap8 b8; set p.D_bitmap = bmp; set p.D_bitmapW = l; set p.D_bitmapH = h ); ) else let if (!strcmpi (extension stringF) "jpg") then _LDjpeg _channel fP else if (!strcmpi (extension stringF) "bmp") then _LDbitmap _channel fP else if (!strcmpi (extension stringF) "tga") then _LDtga _channel fP else nil -> bmp in if bmp == nil then nil else let _GETbitmapSize bmp -> [l h] in ( set p.D_bitmap = bmp; set p.D_bitmapW = l; set p.D_bitmapH = h ); ) else ( set p.D_bitmap = nil; set p.D_bitmapW = nil; set p.D_bitmapH = nil ); 0 ;; /******************************************************************* hide the picture ********************************************************************/ fun hide(o, from, action, param, reply, p) = set p.D_show = 0 ;; /******************************************************************* show the picture ********************************************************************/ fun show(o, from, action, param, reply, p) = set p.D_show = 1 ;; /******************************************************************* change the picture (skin) ********************************************************************/ fun setShortName(s)= let strfind "/" s 0 -> r in if r == nil then s else setShortName substr s r+1 strlen s;; fun searchGoodFile(l, p)= if l == nil then nil else let l -> [elt suite] in let p -> [z oldfile] in let setShortName elt -> file in let setShortName oldfile -> old in if !strcmp file old then openBMP elt z else searchGoodFile suite p;; fun change(o, from, action, param, reply, p) = let lineextr param -> files in searchGoodFile files p; 0;; /******************************************************************* callback on click **@** MODIFIED BY IRI : add if logo is shown then event click without url **@** ********************************************************************/ fun cbClic(o,b,z) = let b -> [_ [xclick yclick bt]] in if z.D_url!=nil && bt==1 && (xclick > z.D_view_posX) && (xclick < z.D_view_posX+z.D_bitmapW) && (yclick > z.D_view_posY) && (yclick < z.D_view_posY+z.D_bitmapH) && (z.D_show) then _DMSevent this strcat class ".click" z.D_url nil else if z.D_url==nil && bt==1 && (xclick > z.D_view_posX) && (xclick < z.D_view_posX+z.D_bitmapW) && (yclick > z.D_view_posY) && (yclick < z.D_view_posY+z.D_bitmapH) && (z.D_show) then _DMSevent this strcat class ".click" nil nil else nil; 0 ;; fun cbMove(o,b,z) = let b -> [_ [xmove ymove _]] in if (xmove > z.D_view_posX) && (xmove < z.D_view_posX+z.D_bitmapW) && (ymove > z.D_view_posY) && (ymove < z.D_view_posY+z.D_bitmapH) then /*move ds la zone*/ if z.D_show && !z.D_in then ( set z.D_in = 1; if z.D_alias != nil then ( _DMSevent this "contextHelp" strbuild ("ref"::z.D_alias::nil)::("userParam"::"1"::nil)::nil nil; 0 ) else nil; OB_TakeMouse o; OB_TakeCursor o; OB_SetCursor o HandCursor; ) else nil else /*move en dehors de la zone*/ if z.D_in then ( set z.D_in = 0; _DMSevent this "contextHelp" nil nil; OB_ReleaseMouse o; OB_ReleaseCursor o; OB_SetCursor o StdCursor ) else nil; 0 ;; fun cbDestroy(o, p) = OB_ReleaseMouse o; OB_ReleaseCursor o; ObCbPostRender o nil; _DSbitmap p.D_bitmap; 0 ;; fun cbLOGO_resize (ob, param, z) = let param -> [w h] in ( set z.D_view_posX = ((z.D_posX*w)/100) - (z.D_bitmapW/2); set z.D_view_posY = ((z.D_posY*h)/100) - (z.D_bitmapW/2); if ((z.D_view_posX + z.D_bitmapW) > w) then set z.D_view_posX = w - z.D_bitmapW else nil; if (z.D_view_posX < 0) then set z.D_view_posX = 0 else nil; if ((z.D_view_posY + z.D_bitmapH) > h) then set z.D_view_posY = h - z.D_bitmapH else nil; if (z.D_view_posY < 0) then set z.D_view_posY = 0 else nil ); 0 ;; fun cbEndDownImage(doc,b) = let b -> [o z fileName file] in let openBMP fileName z -> _ in /*ouverture img*/ let _GETpixel16 z.D_bitmap 0 0 -> colRGB in let ((colRGB&16252928)>>16)+(colRGB&63488)+((colRGB&248)<<16) -> transColor in let getView3dSize w3d -> [w h] in ( ObCbPostRender o mkfun3 @cbBlitLogo [z transColor]; ObRegisterAction o (strcatn class::"."::(ObName o)::".hide"::nil) mkfun6 @hide z; ObRegisterAction o (strcatn class::"."::(ObName o)::".show"::nil) mkfun6 @show z; ObRegisterAction o (strcatn class::"."::(ObName o)::".change"::nil) mkfun6 @change [z file]; OB_CBclickDown o mkfun3 @cbClic z; OB_CBmouseMove o mkfun3 @cbMove z; cbLOGO_resize o [w h] z; 0 ) ;; fun cbRegistered (ui, action, p, o) = let lineextr p -> [fileNameOnClient[file _]] in let getView3dSize w3d -> [w h] in let atoi hd UgetParam ObUi o "x" -> x in let atoi hd UgetParam ObUi o "y" -> y in let hd UgetParam ObUi o "url" -> url in let 1 -> show in let hd UgetParam ObUi o "alias" -> alias in let strcat ObName o hd UgetParam ObUi o "fichier" -> docName in let atoi hd UgetParam ObUi o "trans" -> trans in let mkData[x y ((x*w)/100) ((y*h)/100) url nil nil nil show 0 alias trans] -> z in ( _RSCdownload this docName fileNameOnClient mknode @cbEndDownImage [o z fileNameOnClient file] 3; ObCbDestroy o mkfun2 @cbDestroy z; OB_CBresizeView o mkfun3 @cbLOGO_resize z; 0 ) ;; fun newOb(o) = UsendMessage ObUi o "register" nil; UcbMessage ObUi o ["registered" mkfun4 @cbRegistered o]::nil; 0 ;; fun IniPlug(file) = set class=getInfo strextr _getpack _checkpack file "name"; PLUGsetinfo thisplug PLUGIN_ONLINE_EDITING; PLUGdefineEditor thisplug @dynamicedit; PlugRegister class @newOb nil; 0 ;;