/**********************************************************************************/ /* BmpList type API 2D written by J.DUMAY */ /**********************************************************************************/ /* BMPLIST_New */ /* BMPLIST_Del */ /* BMPLIST_ChangeDisplayFlags */ /* BMPLIST_ChangeCoordinates */ /* BMPLIST_GetCoordinates */ /* BMPLIST_ChangePath */ /* BMPLIST_GetlistBitmap */ /* BMPLIST_SetClickReflex */ /* BMPLIST_SetDblClickReflex */ /* BMPLIST_ChangePath */ /* BMPLIST_GETbitmapList */ /* BMPLIST_Clear */ /**********************************************************************************/ /* pkg utilisés _mlistlib.pkg */ /**********************************************************************************/ /* struct BmpListType=[ BMPLISTChannel:Chn, BMPLISTObj2D:Obj2D, BMPLISTwindow:ObjWin, BMPLISTlist:ObjListTab, BMPLISTbmplist:ObjBitmapList, BMPLISTindexname:[S r1], BMPLISTsizebmp:I, BMPLISTpath:S, BMPLISTselected:[I S], BMPLISTClickReflex:fun [BmpListType I S] BmpListType, BMPLISTDblClickReflex:fun [BmpListType I S] BmpListType ] MkBmpListType;; */ /*******************************************************************************************************************************/ /* Fonctions Intrinseques au BitmapList */ /*******************************************************************************************************************************/ fun ConvertBitmap(channel,file,size)= { let LoadBitmap channel file -> bmpini in let _GETbitmapSize bmpini -> [w h] in let _CRbitmap channel size size -> bmpres in { _SCPbitmap bmpres 0 0 size size bmpini 0 0 w h nil; _DSbitmap bmpini; bmpres; } };; fun GetName(path,fullpath)= { if (strcmp fullpath "")==0 then "" else let [strlen path strlen fullpath] -> [len lenfull] in substr fullpath len+(if (nth_char path (len-1))=='/ then 0 else 1) lenfull-len };; fun AddToBitmapList(l,list)= { if list==nil then nil else let GetName l.BMPLISTpath hd list -> name in let strlen name -> len in let substr name len-3 3 -> three in let substr name len-4 4 -> four in { if ((strcmpi three "jpg")==0)||((strcmpi four "jpeg")==0)||((strcmpi three "bmp")==0) then { let [ConvertBitmap l.BMPLISTChannel hd list l.BMPLISTsizebmp nil] -> [bmp t] in { set l.BMPLISTindexname=name::l.BMPLISTindexname; set t=[[_ADDbitmapList l.BMPLISTbmplist bmp name] AddToBitmapList l tl list]; _DSbitmap bmp; t }; } else AddToBitmapList l tl list; }; };; fun AddToListTab(listtab,list,i)= { if list==nil then 1 else { let hd list -> [index name] in { _ADDlistTabItem listtab i _GETlistTabCount listtab name; _SETlistTabBitmap listtab i index; }; AddToListTab listtab tl list i+1; } };; proto EvalListFiles= fun [S I] [S r1];; fun EvalListFilesInListDir(list)= if list ==nil then nil else listcat EvalListFiles hd list 1 EvalListFilesInListDir tl list;; fun EvalListFiles(dir,recursive)= let _listoffiles dir -> l in if recursive==1 then listcat l EvalListFilesInListDir _listofsubdir dir else l;; fun EvalFilesInBitmapList(l,recursive)= { _RSTlistTab l.BMPLISTlist; _DSbitmapList l.BMPLISTbmplist; set l.BMPLISTbmplist=_CRbitmapList l.BMPLISTChannel l.BMPLISTsizebmp l.BMPLISTsizebmp; let AddToBitmapList l EvalListFiles l.BMPLISTpath recursive -> in_na in { _SETlistTabBitmaps l.BMPLISTlist l.BMPLISTbmplist; AddToListTab l.BMPLISTlist in_na 0; set l.BMPLISTindexname=mirror l.BMPLISTindexname; }; };; fun IsMouseOnBmpList(MouseCol,MouseLgn,l)=1;; fun IsUserClickAllowedInBmpList()=1;; fun IsUserUnClickAllowedInBmpList()=1;; fun DsBmpList(l)= { _DSbitmapList l.BMPLISTbmplist; _DSlistTab l.BMPLISTlist; _DSwindow l.BMPLISTwindow; set l.BMPLISTChannel=nil; set l.BMPLISTbmplist=nil; set l.BMPLISTlist=nil; set l.BMPLISTwindow=nil; set l.BMPLISTClickReflex=nil; set l.BMPLISTDblClickReflex=nil; 1 };; fun CBClickBmpList(listbox,l,i)= let nth_list l.BMPLISTindexname i -> name in { set l.BMPLISTselected=[i name]; exec l.BMPLISTClickReflex with [l i name]; }; 1;; fun CBDblClickBmpList(listbox,l,i,i2)= let nth_list l.BMPLISTindexname i -> name in { set l.BMPLISTselected=[i name]; exec l.BMPLISTDblClickReflex with [l i name]; }; 1;; /*****************************************************************************************************************************/ /* Les fonctions externes */ /******************************************************************************************************************************/ /* Constructeur de la BmpList Channel : canal de construction Chn Container : container auquel appartient la bitmaplist ContainerType ObjPere : l'objet pere Obj2D Coordinates : coordonnees de l'objet par rapport au pere [I I] xsize : largeur de la bitmaplist I ysize : hauteur de la bitmaplist I BmpListFlags : flags de construction de l'objet (O2D_ENABLE actif O2D_HIDE cache) SizeBitmap : taille des bitmaps dans la liste Name : Nom de l'objet S def: BmpListType fun [Chn ContainerType Obj2D [I I] I I I I S] */ fun BMPLIST_New( Channel, Container, ObjPere, Coordinates, xsize, ysize, BmpListFlags, SizeBitmap, Name )= if (Channel==nil) || (Container==nil) || (Coordinates==nil) || (Name==nil) || (xsize==nil) || (ysize== nil) || (SizeBitmap==nil) || (Name==nil) then nil else let O2D_NewObject Container ObjPere Name xsize ysize Coordinates BmpListFlags -> Obj in if Obj==nil then nil else let Coordinates -> [posx posy] in let _CRwindow Channel Container.CoObjWin posx posy xsize ysize (if BmpListFlags&O2D_ENABLE then WN_NOCAPTION|WN_CHILDINSIDE else WN_NOCAPTION|WN_HIDDEN|WN_CHILDINSIDE ) Name -> window in let MkBmpListType [Channel Obj window (_CRlistTab Channel window 0 0 xsize ysize LV_DOWN|LV_SINGLESEL|8) (_CRbitmapList Channel SizeBitmap SizeBitmap) nil SizeBitmap "" nil nil nil ] -> l in { if (BmpListFlags&~O2D_ENABLE)&&(BmpListFlags&~O2D_HIDE) then _ENlistTab l.BMPLISTlist 0 else nil; /* les methodes */ O2D_CBIsMouseOnDisplayObject Obj l @IsMouseOnBmpList; O2D_CBUserClickAllowed Obj l @IsUserClickAllowedInBmpList; O2D_CBUserUnClickAllowed Obj l @IsUserUnClickAllowedInBmpList; O2D_CBDsObject Obj l @DsBmpList; _CBlistTabSelect l.BMPLISTlist @CBClickBmpList l; _CBlistTabDClick l.BMPLISTlist @CBDblClickBmpList l; l };; /* Destructeur def: BmpListType fun [BmpListType] */ fun BMPLIST_Del(list)= O2D_DelObject list.BMPLISTObj2D;list;; /* Definit le reflexe Click de la bitmaplist */ fun BMPLIST_SetClickReflex(l,ReflexeClick,ParamClick)= if l==nil then nil else { set l.BMPLISTClickReflex=mkfun4 ReflexeClick ParamClick; l };; /* Definit le reflexe Double Click de la bitmaplist */ fun BMPLIST_SetDblClickReflex(l,ReflexeDblClick,ParamDblClick)= if l==nil then nil else { set l.BMPLISTDblClickReflex=mkfun4 ReflexeDblClick ParamDblClick; l };; /* renvoie l'Obj2D associe a l'objet BmpList */ /* def : Obj2D fun [BmpListType] */ fun BMPLIST_GetObject(l)= l.BMPLISTObj2D;; /* change le flag d'affichage de la bitmaplist l : bitmaplist dont il faut changer le flag NewFlag : nouveau flag (O2D_ENABLE O2D_HIDE) RedrawFlag : 1 si l'objet doit etre redessine dans le buffer d'affichage 0 sinon RepaintFlag : 1 si le container doit etre redessine 0 sinon def: BmpListType fun [BmpListType I I I] */ fun BMPLIST_ChangeDisplayFlags(l,NewFlag,RedrawFlag,RepaintFlag)= if NewFlag&O2D_HIDE then _SHOWwindow l.BMPLISTwindow WINDOW_HIDDEN else if NewFlag&O2D_ENABLE then { _SHOWwindow l.BMPLISTwindow WINDOW_UNHIDDEN; _ENlistTab l.BMPLISTlist 1; nil } else if (NewFlag&~O2D_ENABLE)&&(NewFlag&~O2D_HIDE) then { _ENlistTab l.BMPLISTlist 0; nil } else nil; O2D_ChangeObjDisplayFlag l.BMPLISTObj2D NewFlag RedrawFlag RepaintFlag; l;; /* change les coordonnees de la bitmaplist par rapport a son objet pere l : bitmaplist dont il faut changer les coordonnees NewCoordinates : nouvelles coordonnees [I I] RedrawFlag : 1 si l'objet doit etre redessine dans le buffer d'affichage 0 sinon RepaintFlag : 1 si le container doit etre redessine 0 sinon def: BmpListType fun [BmpListType [I I] I I] */ fun BMPLIST_ChangeCoordinates(l,NewCoordinates,RedrawFlag,RepaintFlag)= let NewCoordinates -> [x y] in _MVwindow l.BMPLISTwindow x y; O2D_ChangeObjCoordinates l.BMPLISTObj2D NewCoordinates RedrawFlag RepaintFlag; l;; /* renvoie les coordonnes de la listbox par rapport a son pere [I I] */ /* def : [I I] fun [BmpListType] */ fun BMPLIST_GetCoordinates(l)= O2D_GetObjCoordinates l.BMPLISTObj2D;; /* Cette fonction change le chemin des bitmaps ou jpegs a afficher dans la liste */ /* l : bitmap liste NewPath : repertoire a afficher Recursive : si 1 alors cherche les bmps(ou jpegs recursivement) 0 alors pas de recursion */ /* [BmpListType] fun [Chn BmpListType S I] */ fun BMPLIST_ChangePath(l,NewPath,Recursive)= { set l.BMPLISTpath=NewPath; set l.BMPLISTindexname=nil; EvalFilesInBitmapList l Recursive ; l };; /* Cette fonction renvoie l'indice et le chemin du bmp selectionné dans la liste*/ /* Le nom est relatif au repertoire dans lequel se trouve le bitmap */ /* renvoie nil si aucun fichier n'est selectionné */ /* [I S] fun [BmpListType] */ fun BMPLIST_GETbitmapList(l)=l.BMPLISTselected;; /* Cette fonction vide la listbitmap BmpListType fun [BmpListType] */ fun BMPLIST_Clear(l)= { set l.BMPLISTindexname=nil; set l.BMPLISTpath=nil; _RSTlistTab l.BMPLISTlist; _DSbitmapList l.BMPLISTbmplist; set l.BMPLISTbmplist=nil; set l.BMPLISTselected=nil; l };;