/* Filter Editor - may.98 - by Sylvain Huet */ /* Oct. '98 - by Marc Barilley */ /* add localisation (must define "loc" function) - may 2001 - by macfly */ struct FilterMap= [FMch:Chn,FMwin:ObjWin,FMfile:S,FMfilter:S, FMcolcheck:ObjCheck,FMcolwin:ObjWin,FMcolcol:I,FMcolrate:ObjSlider, FMrotcheck:ObjCheck,FMrotang:ObjSlider, FMsatcheck:ObjCheck,FMsatval:ObjSlider,FMsatrate:ObjSlider, FMattcheck:ObjCheck,FMattwin:ObjWin,FMattcol:I,FMattdist:ObjSlider, FMok:ObjButton,FMcancel:ObjButton, FMend:fun[S] I,FMold:S, FMdeffont:ObjFont,FMfont:ObjFont,FMbuf:ObjBitmap ]mkFilterMap;; fun _paintevent(win,b)= _BLTbitmap b.FMwin b.FMbuf 5 25;0;; fun _openBmp(b)= let _checkpack b.FMfile -> f in if f==nil then nil else let (let _LDbitmap b.FMch f -> newbmp in if newbmp!=nil then newbmp else let _LDjpeg b.FMch f -> newjpg in if newjpg!=nil then newjpg else nil ) -> bmp in if bmp==nil then { _DLGMessageBox b.FMch b.FMwin loc "WARNING" loc "NOTBITMAP" 0; nil } else let _GETbitmapSize bmp -> [w h] in { _SCPbitmap b.FMbuf 0 0 128 128 bmp 0 0 w-1 h-1 nil; _DSbitmap bmp; _paintevent nil b };; fun extend(s,i)= if (strlen s)=strlen s then 0 else let nth_char s i ->c in if c=='C then (set b.FMcolcol=htoi substr s i+1 6; _SETsliderLeft b.FMcolrate itof htoi substr s i+7 2; _SETcheck b.FMcolcheck 1; parseFilter b s i+9) else if c=='R then (_SETsliderLeft b.FMrotang itof ((htoi substr s i+1 4)*360/65536); _SETcheck b.FMrotcheck 1; parseFilter b s i+5) else if c=='S then (_SETsliderLeft b.FMsatval itof ((htoi substr s i+1 4)/256); _SETsliderLeft b.FMsatrate itof htoi substr s i+5 2; _SETcheck b.FMsatcheck 1; parseFilter b s i+7) else if c=='A then (set b.FMattcol=htoi substr s i+1 6; _SETsliderLeft b.FMattdist itof htoi substr s i+7 2; _SETcheck b.FMattcheck 1; parseFilter b s i+9) else parseFilter b s i+1;; fun setFilter(b,s)=parseFilter b s 0;; fun updateFilter(b)= let getFilter b -> filter in set b.FMfilter=if (strlen filter)==0 then nil else filter; _openBmp b; M3filter b.FMbuf b.FMfilter; _paintevent nil b;; fun _chkcol(w,b,i)= updateFilter b;; fun _retcol (s, new1, new2, b)=updateFilter b;; fun _paintcol(x,b)= _PAINTrectangle b.FMcolwin 0 0 200 200 DRAW_SOLID 1 b.FMcolcol DRAW_SOLID b.FMcolcol; 0;; fun endcol(c,b)= if c==nil then nil else (set b.FMcolcol=c; _paintcol nil b; updateFilter b);; fun _clickcol(a,b,x,y,c)= _CRcolorMap b.FMch b.FMwin 0 0 loc "COLOR" mkfun2 @endcol b b.FMcolcol;; fun _paintatt(x,b)= _PAINTrectangle b.FMattwin 0 0 200 200 DRAW_SOLID 1 b.FMattcol DRAW_SOLID b.FMattcol; 0;; fun endatt(c,b)= if c==nil then nil else (set b.FMattcol=c; _paintatt nil b; updateFilter b);; fun _clickatt(a,b,x,y,c)= _CRcolorMap b.FMch b.FMwin 0 0 loc "COLOR" mkfun2 @endatt b b.FMattcol;; fun _destroyFM(win,b)= _DSbitmap b.FMbuf; _DSslider b.FMcolrate; _DSslider b.FMrotang; _DSslider b.FMsatval; _DSslider b.FMsatrate; _DSfont b.FMfont; 0;; fun _ok(x,b)= _destroyFM b.FMwin b; _DSwindow b.FMwin; exec b.FMend with [b.FMfilter];; fun _cancel(x,b)= _destroyFM b.FMwin b; _DSwindow b.FMwin;; fun _CRfilterMap(ch,father,x,y,title,texture,filter,end)= /* let _GETdefaultFont -> deffont in let _SETdefaultFont _CRfont ch 12 0 0 "Arial" -> font in*/ let [400 400]->[w h] in let _CRwindow ch father x y w h WN_MENU|WN_MINBOX title -> win in let _CRtext ch win 5 5 w-10 15 ET_BORDER texture -> banner in /* couleur */ let _CRcheck ch win 138 25 250 20 0 loc "COLOR_FILTER" -> colcheck in let _CRtext ch win 150 47 60 15 ET_ALIGN_RIGHT strcat loc "COLOR" " :" -> coltxt1 in let _CRwindow ch win 215 47 15 15 WN_CHILDINSIDE|WN_NOCAPTION|WN_DOWN "" -> colwin in let _CRtext ch win 150 69 60 15 ET_ALIGN_RIGHT strcat loc "RATE" " :" -> coltxt2 in /* rotation */ let _CRcheck ch win 138 120 250 15 0 loc "COLOR_ROTFILT" -> rotcheck in let _CRtext ch win 150 142 60 15 ET_ALIGN_RIGHT strcat loc "ANGULAR" " :" -> rottxt1 in /* saturation filter */ let _CRcheck ch win 138 200 250 15 0 loc "COLOR_SATFILT" -> satcheck in let _CRtext ch win 150 222 60 15 ET_ALIGN_RIGHT strcat loc "VALUE" " :" -> sattxt1 in let _CRtext ch win 150 260 60 15 ET_ALIGN_RIGHT strcat loc "RATE" " :" -> sattxt2 in /* attraction filter */ let _CRcheck ch win 138 300 250 15 0 loc "COLOR_ATTRFILT" -> attcheck in let _CRtext ch win 150 322 60 15 ET_ALIGN_RIGHT strcat loc "COLOR" " :" -> atttxt1 in let _CRwindow ch win 215 322 15 15 WN_CHILDINSIDE|WN_NOCAPTION|WN_DOWN "" -> attwin in let _CRtext ch win 150 344 60 15 ET_ALIGN_RIGHT strcat loc "DISTANCE" " :" -> atttxt2 in let _CRbutton ch win 5 h-25 80 20 0 loc "OK" -> ok in let _CRbutton ch win 100 h-25 80 20 0 loc "CANCEL" -> cancel in let mkFilterMap[ch win texture filter colcheck colwin 0 nil rotcheck nil satcheck nil nil attcheck attwin 0 nil ok cancel end filter nil nil _CRbitmap ch 128 128] -> b in { _CBwinPaint win @_paintevent b; _CBwinDestroy win @_destroyFM b; _CBcheck colcheck @_chkcol b; _CBwinPaint colwin @_paintcol b; _CBwinClick colwin @_clickcol b; set b.FMcolrate= _CRslider ch win nil 215 69 180 25 0xff0000 (itof 0) (itof 255) (itof 0) (itof 0) mkfun4 @_retcol b SLIDER_INTER_FIXED|SLIDER_DRAW_VALUE|SLIDER_BUTTON; _SETsliderPrecisionStep b.FMcolrate itof 1; _SETsliderPrecisionMark b.FMcolrate 0; _CBcheck rotcheck @_chkcol b; set b.FMrotang= _CRslider ch win nil 215 142 180 25 0xff0000 (itof 0) (itof 360) (itof 0) (itof 0) mkfun4 @_retcol b SLIDER_INTER_FIXED|SLIDER_DRAW_VALUE|SLIDER_BUTTON; _SETsliderPrecisionStep b.FMrotang itof 1; _SETsliderPrecisionMark b.FMrotang 0; _CBcheck satcheck @_chkcol b; set b.FMsatval= _CRslider ch win nil 215 222 180 25 0xff0000 (itof 0) (itof 255) (itof 0) (itof 0) mkfun4 @_retcol b SLIDER_INTER_FIXED|SLIDER_DRAW_VALUE|SLIDER_BUTTON; _SETsliderPrecisionStep b.FMsatval itof 1; _SETsliderPrecisionMark b.FMsatval 0; set b.FMsatrate= _CRslider ch win nil 215 260 180 25 0xff0000 (itof 0) (itof 255) (itof 0) (itof 0) mkfun4 @_retcol b SLIDER_INTER_FIXED|SLIDER_DRAW_VALUE|SLIDER_BUTTON; _SETsliderPrecisionStep b.FMsatrate itof 1; _SETsliderPrecisionMark b.FMsatrate 0; _CBcheck attcheck @_chkcol b; _CBwinPaint attwin @_paintatt b; _CBwinClick attwin @_clickatt b; set b.FMattdist= _CRslider ch win nil 215 344 180 25 0xff0000 (itof 0) (itof 255) (itof 0) (itof 0) mkfun4 @_retcol b SLIDER_INTER_FIXED|SLIDER_DRAW_VALUE|SLIDER_BUTTON; _SETsliderPrecisionStep b.FMattdist itof 1; _SETsliderPrecisionMark b.FMattdist 0; _CBbutton ok @_ok b; _CBbutton cancel @_cancel b; setFilter b filter; _paintcol nil b; _paintatt nil b; updateFilter b; /* _SETdefaultFont deffont;*/ b };;