/* Nav2 Window - aug98 - by Sylvain Huet */ /* rev December 2000 - by Sebastien DENEUX */ struct Nav= [chNav:Chn,winNav:ObjWin,movNav:fun[[I I I] [I I I] I] I, bufNav:ObjBitmap,bmpNav:ObjBitmap, kNav:[I I],vectorNav:[I I I],angularNav:[I I I], refNav:[I I],flagNav:I,curNav:I, backcursNav:ObjCursor,frontcursNav:ObjCursor,bsizeNav:I ]mkNav;; var NAV_CHILD=1;; var NAV_RESIZE=2;; var NAV_HOR=4;; var NUM_BOX=3;; fun _PaintE(x,b)= _BLTbitmap b.winNav b.bufNav 0 0;; fun _UnclickE(a,b,x,y,button)= set b.vectorNav=set b.angularNav=[0 0 0]; exec b.movNav with [b.vectorNav b.angularNav 0]; set b.curNav=nil;; fun getnumbox(b,x,y)= let _GETbitmapSize b.bufNav ->[w h] in let if b.flagNav&NAV_HOR then [x*NUM_BOX*4/w y*4/h] else [y*NUM_BOX*4/h x*4/w]->[L l] in if ((l+1)&2)&&((L+1)&2) then L>>2 else nil;; fun _ClickE(a,b,x,y,button)= _SETfocus b.winNav ; set b.curNav=getnumbox b x y; if b.curNav==3 then exec b.movNav with [[0 0 0] [0 0 0] 1] else nil; set b.refNav=[x y];; fun movecurs(b,x,y)= let b.kNav ->[kv ka] in let b.refNav ->[xr yr] in (set x=x-xr; set y=yr-y; set b.vectorNav= if b.curNav==0 then [x*kv y*kv 0] else if b.curNav==1 then [0 0 y*kv] else [0 0 0]; set b.angularNav= if b.curNav==1 then [(-x*ka) 0 0] else if b.curNav==2 then [0 y*ka 0] else [0 0 0] );; fun _CursorE(a,b,x,y,c)= if nil==getnumbox b x y then _SETwinCursor b.winNav b.backcursNav else _SETwinCursor b.winNav b.frontcursNav; if b.curNav==nil then nil else (movecurs b x y; exec b.movNav with [b.vectorNav b.angularNav 0] );; fun _keydownE (t,b,code,val)= let b.kNav ->[kv0 ka0] in let [kv0*64 ka0*64] ->[kv ka] in (set b.vectorNav= if _keybdstate&2 then if val==0xff51 then [(-kv) 0 0] else if val==0xff53 then [kv 0 0] else if val==0xff52 then [0 kv 0] else if val==0xff54 then [0 (-kv) 0] else [0 0 0] else if _keybdstate&1 then [0 0 0] else if val==0xff52 then [0 0 kv] else if val==0xff54 then [0 0 (-kv)] else [0 0 0]; set b.angularNav= if _keybdstate&2 then [0 0 0] else if _keybdstate&1 then if val==0xff52 then [0 ka 0] else if val==0xff54 then [0 (-ka) 0] else [0 0 0] else if val==0xff51 then [ka 0 0] else if val==0xff53 then [-ka 0 0] else [0 0 0]); exec b.movNav with [b.vectorNav b.angularNav 0] ;; fun _keyupE (a,b,code)= set b.vectorNav=set b.angularNav=[0 0 0]; exec b.movNav with [b.vectorNav b.angularNav 0] ;; fun _DestroyE(x,b)= _DSbitmap b.bufNav; _DSbitmap b.bmpNav; _DMSdelete this ;; fun calcwin(b)= let _GETbitmapSize b.bmpNav -> [w h] in let _GETbitmapSize b.bufNav ->[ww hh] in _SCPbitmap b.bufNav 0 0 ww-1 hh-1 b.bmpNav 0 0 w-1 h-1 nil ;; fun _ResizeE(a,b,w,h)= _DSbitmap b.bufNav; set b.bufNav=_CRbitmap b.chNav max 1 w max 1 h; calcwin b; _paintE nil b;; fun iniNav(ch,father,x,y,w,h,title,mov,flag,frontcurs,backcurs,horiz,bmpname)= let _CRwindow ch father x y w h (if flag&NAV_CHILD then WN_CHILDINSIDE|WN_NOCAPTION|WN_NOBORDER else WN_MENU+WN_MINBOX)+ (if flag&NAV_RESIZE then WN_SIZEBOX else 0) title -> win in let _CRbitmap ch w h ->buf in let _LDbitmap ch _checkpack bmpname -> bmp0 in let if bmp0==nil then _LDjpeg ch _checkpack bmpname else bmp0 -> bmp in let mkNav [ch win mov buf bmp [1 20] nil nil nil flag+4*horiz nil frontcurs backcurs 64] -> b in (calcwin b; _CBwinDestroy win @_DestroyE b; _CBwinPaint win @_PaintE b; _CBwinSize win @_ResizeE b; _CBwinClick win @_ClickE b; _CBwinUnclick win @_UnclickE b; _CBcursorMove win @_CursorE b; _CBwinKeydown win @_keydownE b; _CBwinKeyup win @_keyupE b; _PaintE nil b; b );; fun setTitleNav(b,s)= _SETwindowName b.winNav s;; fun setInterfNav(b,kv,ka)= set b.kNav=[kv ka];; fun setCBNav(b,mov)= set b.movNav=mov;; fun destroyNav(b)= _DSwindow b.winNav; _DSbitmap b.bufNav; _DSbitmap b.bmpNav;;