/* Listbox Client - DMS - Aug. '98 - by Marc BARILLEY */ /* Rev. June '01 - by Julien ZORKO */ defcom cStarted = started;; typeof list=ObjList;; typeof items=[S r1];; typeof startupItems = [S r1];; var SendItems = 1;; fun _strcmp (a, b)=!strcmp a b;; fun sstrcmp (a, b)=strcmp struppercase b struppercase a;; fun click (l, b, i, s)= let nth_list items i -> it in ( if isf_in_list startupItems @_strcmp it then if SendItems then _DMSevent this strcat "click " it it nil else _DMSevent this strcat "click " it nil nil else nil; _DMSevent this "click" it nil ) ;; fun dclick (l, b, i, s)= let nth_list items i -> it in ( if isf_in_list startupItems @_strcmp it then if SendItems then _DMSevent this strcat "dclick " it it nil else _DMSevent this strcat "dclick " it nil nil else nil; _DMSevent this "dclick" it nil ) ;; fun _end (s)= _DMSdelete this;; fun _resizeI(x,s)= let x->[win x y w h] in _SIZElist list w h x y; 0;; fun showlist()= let _DMSgetZone this "Listbox" @_end @_resizeI @_end ->[win x y w h] in if win==nil then nil else set list= _CBlistDclick _CBlistClick _CRlist _channel win x y w h LB_DOWN|LB_VSCROLL @click 0 @dclick 0;; fun fill (lb, l)= if l==nil then lb else { _ADDlist lb _GETlistCount lb hd l; fill lb tl l };; fun __add (s)= if s==nil then nil else { set items=listcat items s::nil; _ADDlist list _GETlistCount list s };; fun __del (s)= let search_in_list items @_strcmp s -> p in if p==nil then nil else let pos_in_list items p 0 -> i in { set items = remove_nth_from_list items i; _DELlist list i };; fun __reset ()= set items=nil; _RSTlist list;; fun __sort ()= set items = rquicksort @sstrcmp items; fill _RSTlist list items;; fun __startup (errorcode, item)= if errorcode == 0 then set startupItems = nil else if errorcode == 1 then if item==nil then nil else set startupItems = listcat startupItems item::nil else nil;; fun IniDMI (sendItems) = set SendItems = atoi sendItems; showlist ;;