/* Bitmap Editor - DMS - June 98 - by Sylvain HUET */ /* Rev. Jul. '98 - by Marc BARILLEY */ /* Rev. 1.2 - Sep. '98 - by Marc BARILLEY */ typeof checkll = ObjBitmapList;; typeof banner = ObjText;; typeof ll=ObjListTab;; typeof addbut = ObjButton;; typeof delbut = ObjButton;; typeof viewwin = ObjWin;; typeof backmap = ObjBitmap;; typeof links=[[S S I] r1];; typeof oldpath=S;; typeof currentSel = I;; typeof fullIndex = BitmapIndex;; typeof emptyIndex = BitmapIndex;; typeof editor = Editor;; fun updatel2 (l, i)= if l==nil then ll else let hd l -> [x y r] in { _ADDlistTabItem ll i i x; _SETlistTabBitmap ll i if r then fullIndex else emptyIndex; _SETlistTabItem ll i 1 y; updatel2 tl l i+1; };; fun updatel ()= _RSTlistTab ll; updatel2 links 0;; fun addr(a,z,r)= let z->[s [name w b]] in ( _DSwindow w;_DSbitmap b; set links=listcat links [s name r]::nil; updatel );; fun addr0(s,z)= let z->[name w b] in if s==nil then ( _DSwindow w;_DSbitmap b; nil ) else _DLGrflmessage /* loc( _DLGMessageBox _channel w "Question" "Is it a double button bitmap ? (click no if you do not know)" 2 ) */ _DLGMessageBox _channel w (_locEditor "540-BITMAP-question" nil) (_locEditor "541-BITMAP-isitadoubl" nil) 2 @addr [s z]; 0;; fun _paintWn(w,b)=_BLTbitmap w b 0 0;; fun _destroyWn(w,b)=_DSbitmap b;; fun rflPaintViewwin (w, x)= _BLTbitmap w backmap 0 0;; fun _OpenBmp(d,b,s)= let _PtoScol s -> name in if name==nil then nil else ( let getPathFile name "" -> [dir _] in set oldpath=dir; let _LDbitmap _channel s -> bmp0 in let if bmp0==nil then _LDjpeg _channel s else bmp0 -> newbmp in if newbmp==nil then /* loc( (_DLGMessageBox _channel (getEditWin editor) "Warning" ) */ (_DLGMessageBox _channel (getEditWin editor) (_locEditor "750-BITMAP-warning" nil) /* loc( "This file is not a correct bitmap file" 0;nil) ) */ (_locEditor "760-BITMAP-thisfileis" nil) 0;nil) else let _GETbitmapSize newbmp -> [w h] in let _CRwindow _channel (getEditWin editor) 10 10 w h WN_MENU+WN_MINBOX name -> wn in (_CBwinPaint wn @_paintWn newbmp; _CBwinDestroy wn @_destroyWn newbmp; _paintWn wn newbmp; if b then nil else iniEnterBox _channel wn 100 150 /* loc( "New Bitmap" mkfun2 @addr0 [name wn newbmp] "Enter alias"; ) */ (_locEditor "840-BITMAP-newbitmap" nil) mkfun2 @addr0 [name wn newbmp] (_locEditor "841-BITMAP-enteralias" nil); 0));; fun _add(a,b)= _DLGrflopen _DLGOpenFile _channel (getEditWin editor) oldpath nil "bitmap (*.bmp,*.jpg)\0*.BMP;*.JPG\0\0" @_OpenBmp 0;; fun _rem(x,b)= if currentSel==nil then nil else let nth_list links currentSel -> a in (set links=remove_from_list links a; updatel);; fun rflSelectLL (lb, blurp, id)= let nth_list links id -> [a p _] in { /* loc( status editor strcat "Loading file " p; ) */ status editor strcat (_locEditor "1040-BITMAP-loadingfil" nil) p; let let _LDbitmap _channel _checkpack p -> bmp in if bmp == nil then _LDjpeg _channel _checkpack p else bmp -> bmp in if bmp==nil then { /* loc( status editor "Not a valid image file"; ) */ status editor (_locEditor "1160-BITMAP-notavalidi" nil); nil } else let _GETbitmapSize backmap -> [backw backh] in let _GETbitmapSize bmp -> [bmpw bmph] in let if (bmpw>backw) && (bmph>backh) then if (min backw-bmpw backh-bmph) == (backw-bmpw) then [0 (backh-backw*bmph/bmpw)/2 backw backw*bmph/bmpw] else [(backw-backh*bmpw/bmph)/2 0 backh*bmpw/bmph backh] else if bmpw>backw then [0 (backh-backw*bmph/bmpw)/2 backw backw*bmph/bmpw] else if bmph>backh then [(backw-backh*bmpw/bmph)/2 0 backh*bmpw/bmph backh] else [(backw-bmpw)/2 (backh-bmph)/2 bmpw bmph] -> [x y w h] in { _FILLbitmap backmap 0xffffff; _SCPbitmap backmap x y x+w y+h bmp 0 0 bmpw-1 bmph-1 nil; _DSbitmap bmp; _PAINTwindow viewwin; /* loc( status editor strcatn "File "::p::" loaded"::nil; ) */ status editor strcatn (_locEditor "1440-BITMAP-file" nil)::p::(_locEditor "1441-BITMAP-loaded" nil)::nil; } }; set currentSel = id;; fun rflDClickLL (lb, blurp, id, i)= let nth_list links id -> [a p _] in _OpenBmp nil 1 _checkpack p;; /* SCS editor */ fun fdlink(a,b)= if strcmp hd a "bmp" then 0 else let a->[_ [x[y[z _]]]] in (set links=listcat links [x y atoi z]::nil; 0);; fun load (l) = set links=nil; apply_on_list l @fdlink 0; updatel; 0;; fun listbmp(l)= if l==nil then nil else let l->[[_ b _] n] in b::listbmp n;; fun suppevent(l)= if l==nil then nil else let l->[[a b c] n] in ("action"::a::nil):: ("bmp"::a::b::(itoa c)::nil):: ("eventC"::(strcat a ".left")::nil):: ("eventC"::(strcat a ".right")::nil):: suppevent n;; fun save (filename, n)= ("registerF"::listbmp links):: ("action"::"destroy"::"destroy"::nil):: ("action"::"start"::"start"::nil):: ("eventC"::"in"::nil):: ("eventC"::"clickLeft"::nil):: ("eventC"::"clickRight"::nil):: ("zoneC"::"bitmap"::nil):: suppevent links;; fun rflSizeEditWin (wn, blurp, w, h)= _SIZEtext banner w-10 20 5 5; _SIZElistTab ll w/2-5 h-60 5 30; _SIZEbutton addbut 45 20 5 h-25; _SIZEbutton delbut 45 20 70 h-25; _DSbitmap backmap; set backmap = _FILLbitmap _CRbitmap _channel w/2-5 h-60 0xffffff; _SIZEwindow viewwin w/2-5 h-60 w/2 30; if currentSel==nil then nil else rflSelectLL nil 0 currentSel;; fun IniEditor(s)= let [315 220] -> [w h] in let startEditor _channel nil nil nil w h WN_MENU EDITOR_NORMAL s "dms/tools/bitmap/bitmap.dmc" nil nil @load @save nil -> ed in let getEditWin ed -> editWin in ( set editor = ed; _CBwinSize editWin @rflSizeEditWin 0; set checkll = _CRbitmapList _channel 10 10; let _LDbitmap _channel _checkpack "Dms/Tools/Bitmap/blank.bmp" -> emptycheck in let _LDbitmap _channel _checkpack "Dms/Tools/Bitmap/double.bmp" -> fullcheck in { set emptyIndex = _ADDbitmapList checkll emptycheck; set fullIndex = _ADDbitmapList checkll fullcheck; _DSbitmap emptycheck; _DSbitmap fullcheck; }; /* loc( set banner = _CRtext _channel editWin 5 5 w-10 20 ET_ALIGN_CENTER "Bitmaps :"; ) */ set banner = _CRtext _channel editWin 5 5 w-10 20 ET_ALIGN_CENTER (_locEditor "2270-BITMAP-bitmaps:" nil); set ll = _CRlistTab _channel editWin 5 30 w/2-5 h-60 LV_DOWN|LV_SINGLESEL; /* loc( _ADDlistTabColumn ll 0 w/4 0 "Alias"; ) */ _ADDlistTabColumn ll 0 w/4 0 (_locEditor "2290-BITMAP-alias" nil); /* loc( _ADDlistTabColumn ll 1 w/4 0 "File"; ) */ _ADDlistTabColumn ll 1 w/4 0 (_locEditor "2300-BITMAP-file" nil); _SETlistTabBitmaps ll checkll; _CBlistTabSelect ll @rflSelectLL 0; _CBlistTabDClick ll @rflDClickLL 0; set viewwin = _CRwindow _channel editWin w/2 30 w/2-5 h-60 WN_CHILD|WN_DOWN ""; _CBwinPaint viewwin @rflPaintViewwin 0; set backmap = _FILLbitmap _CRbitmap _channel w/2-5 h-60 0xffffff; /* loc( set addbut = _CBbutton _CRbutton _channel editWin 5 h-25 45 20 0 "Add" @_add 0; ) */ set addbut = _CBbutton _CRbutton _channel editWin 5 h-25 45 20 0 (_locEditor "2370-BITMAP-add" nil) @_add 0; /* loc( set delbut = _CBbutton _CRbutton _channel editWin 70 h-25 45 20 0 "Remove" @_rem 0; ) */ set delbut = _CBbutton _CRbutton _channel editWin 70 h-25 45 20 0 (_locEditor "2380-BITMAP-remove" nil) @_rem 0; if s==nil then nil else openDMI ed ); 0;;