typeof plugin = S;; typeof class = S;; typeof ed = PluginEditor;; typeof ELfichier= ObjText;; typeof ELX = ObjText;; typeof ELY = ObjText;; typeof ELurl = ObjText;; typeof ELalias = ObjText;; typeof Win = ObjWin;; typeof Bitmap = ObjBitmap;; typeof TRANS2 = ObjCheck;; typeof nrand = I;; /* ??? ajouté par moi */ proto save=fun [ [Inst r1] ] [[S r1] [S r1] [[S r1]r1] [[S r1]r1]];; fun InstName(UI)= UI.nameInst ;; fun getSuppLinks(l) = if l == nil then nil else let l -> [first next] in ("event"::(strcat strcat class ".link." hd first)::nil)::(getSuppLinks next) ;; fun suppactions(l)= if l == nil then nil else let l -> [UI nl] in let (InstName UI) -> name in ("actionC"::(strcatn class::"."::name::".hide"::nil)::nil):: ("actionC"::(strcatn class::"."::name::".show"::nil)::nil):: ("actionC"::(strcatn class::"."::name::".change"::nil)::nil):: (suppactions nl);; fun save(l) = let l -> [UI nl] in let if (InstName UI)==nil then class else InstName UI -> name in [ nil /* registerF */ nil /* register */ ("plugin"::plugin::nil)::nil /* supplemental Dat */ /* dmi */ ("eventC" ::(strcat class ".click")::nil):: (suppactions l) ] ;; fun openBMP(a, b, fP) = let _PtoScol fP->stringF in if (fP != nil && stringF!=nil && ((_FILESize _FILEOpen _channel fP) < 64000)) then ( _SETtext ELfichier stringF; 0 ) else if (fP != nil && stringF==nil) then ( _DLGMessageBox _channel Win "" "The image should be in the scol partitions" 0; 0 ) else if ((_FILESize _FILEOpen _channel fP) >= 64000) then ( _DLGMessageBox _channel Win "" "file is too big (limit is at 64Ko)" 0; 0 ) else nil; 0 ;; fun cbbutton (button, win) = let _DLGOpenFile _channel win "" nil "bitmap (*.bmp,*.jpg,*.png,*.tga)\0*.BMP;*.TGA;*.PNG;*.JPG;*.JPEG\0\0" -> open in _DLGrflopen open @openBMP nil; 0 ;; fun EnableChk (check, ParamU, state) = _SETcheck TRANS2 state ;; fun openedit(win, param) = let strextr param -> l in let _GETwindowSizePosition win -> [w h x y] in ( set ed = startPluginEditor _channel win 0 0 w h WN_CHILDINSIDE|WN_NOBORDER class; _CRtext _channel ed.PluginEditorEditWin 5 7 80 20 ET_ALIGN_LEFT "Image : "; set ELfichier = _CReditLine _channel ed.PluginEditorEditWin 85 5 150 20 ET_ALIGN_LEFT|ET_DOWN|ET_AHSCROLL let getInfo l "fichier" -> string in if (nil == string) then "" else string; _CRtext _channel ed.PluginEditorEditWin 5 32 80 20 ET_ALIGN_LEFT "Position: "; _CRtext _channel ed.PluginEditorEditWin 116 32 150 20 ET_ALIGN_LEFT "% of the width of the screen"; set ELX = _CReditLine _channel ed.PluginEditorEditWin 85 30 30 20 ET_ALIGN_LEFT|ET_DOWN let getInfo l "x" -> string in if (nil == string) then "0" else string; _CRtext _channel ed.PluginEditorEditWin 116 55 150 20 ET_ALIGN_LEFT "% of the height of the screen"; set ELY = _CReditLine _channel ed.PluginEditorEditWin 85 55 30 20 ET_ALIGN_LEFT|ET_DOWN let getInfo l "y" -> string in if (nil == string) then "0" else string; _CRtext _channel ed.PluginEditorEditWin 5 82 80 20 ET_ALIGN_LEFT "URL : "; set ELurl = _CReditLine _channel ed.PluginEditorEditWin 85 80 150 20 ET_ALIGN_LEFT|ET_DOWN|ET_AHSCROLL let getInfo l "url" -> string in if (nil == string) then "" else string; _CRtext _channel ed.PluginEditorEditWin 5 107 80 20 ET_ALIGN_LEFT "Alias : "; set ELalias = _CReditLine _channel ed.PluginEditorEditWin 85 105 150 20 ET_ALIGN_LEFT|ET_DOWN|ET_AHSCROLL let getInfo l "alias" -> string in if (nil == string) then "" else string; set TRANS2 = _CRcheck _channel ed.PluginEditorEditWin 5 132 93 16 CH_LEFT "Transparency :" ; let getInfo l "trans" -> string in if !strcmp string "1" then _SETcheck TRANS2 1 else _SETcheck TRANS2 0; _CBcheck TRANS2 @EnableChk nil; /* callback */ _CBbutton (_CRbutton _channel ed.PluginEditorEditWin 250 5 60 20 0 "Selection") @cbbutton win; set nrand = (atoi getInfo l "nrand"); /* ??? ajouté par moi */ 0 ) ;; 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 ) ;; fun CheckBMP(file) = let _checkpack file -> fP in let Extension file -> ext in if fP == nil then 0 else if !strcmpi ext "png" then let _LDalphaBitmap _channel fP -> alphabmp in let if alphabmp == nil then 0 else 1 -> res in ( _DSalphaBitmap alphabmp; res ) else if !strcmpi ext "jpg" then let _LDjpeg _channel fP -> bmp in let if bmp == nil then 0 else 1 -> res in ( _DSbitmap bmp; res ) else if !strcmpi ext "bmp" then let _LDbitmap _channel fP -> bmp in let if bmp == nil then 0 else 1 -> res in ( _DSbitmap bmp; res ) else if !strcmpi ext "tga" then let _LDtga _channel fP -> bmp in let if bmp == nil then 0 else 1 -> res in ( _DSbitmap bmp; res ) else 0 ;; fun verifyPosition (text) = let atoi (_GETtext text) -> number in itoa if number > 100 then 100 else if number < 0 then 0 else number ;; fun closeedit() = let _GETtext ELfichier -> tmp in let if tmp == nil || (!strcmp tmp "") then "logo.bmp" else tmp -> tmp in let if CheckBMP tmp then tmp else (_DLGMessageBox _channel nil "Warning" "The image is invalid, it has been replaced by logo.bmp" 0;"logo.bmp") -> tmp in let if nrand == 0 then rand else nrand -> nrand in /* ??? ajouter par moi */ ( _storepack (_getpack _checkpack tmp) (strcatn "tmp/logo/"::(substr _getlongname strcat (itoa nrand) (substr tmp 0 (strfind "." tmp 1)) "" "#" 1 8)::"."::(Extension tmp)::nil); /* ??? modifié par moi */ strbuild ("fichier"::tmp::nil):: ("nrand" ::(itoa nrand)::nil):: /* ??? ajouter par moi */ ("x" ::(verifyPosition ELX)::nil):: ("y" ::(verifyPosition ELY)::nil):: ("url" ::(_GETtext ELurl)::nil):: ("alias" ::(_GETtext ELalias)::nil):: ("trans" ::(if _GETcheck TRANS2 then "1" else "0")::nil)::nil ) ;; fun IniPlug(file) = set plugin=file; set class=getInfo strextr _getpack _checkpack file "name"; PlugRegister class @save nil @openedit @closeedit ;;