/* Day Window - Mar.98 - by Sylvain Huet */ struct Tmp= [month:S,day:S,hour:I, dayhits:tab I,dayaff:tab I,dayaffmax:tab I, daytime:I,dayuser:I,daytimemax:I, totalhits:I,totalaffmax:I,totaltime:I,daytothits:I]mkTmp;; fun sublist(l,n)= if n then (atoi hd l)::sublist tl l n-1 else nil;; fun suml(l)= if l==nil then 0 else (hd l)+suml tl l;; fun AToTmp(ll)= let hd ll->l in let mkTmp[nil nil nil mktab 24 0 mktab 24 0 mktab 24 0 0 0 0 0 0 0 nil]->t in (set t.month=nth_list l 0; set t.day=nth_list l 1; set t.dayhits=listtotab sublist endlist l 2 24; set t.dayaff=listtotab sublist endlist l 26 24; set t.dayaffmax=listtotab sublist endlist l 50 24; set t.daytime=atoi nth_list l 74; set t.dayuser=atoi nth_list l 75; set t.daytimemax=atoi nth_list l 76; set t.totalhits=atoi nth_list l 77; set t.totalaffmax=atoi nth_list l 78; set t.totaltime=atoi nth_list l 79; set t.daytothits=suml tabtolist t.dayhits; t);; struct DW= [chDW:Chn,winDW:ObjWin,hitsDW:ObjBitmap,affDW:ObjBitmap,affmaxDW:ObjBitmap]mkDW;; fun maxVal(l)= if l==nil then 0 else let maxVal tl l -> x in if x win in let _CRbitmap ch 720 125 -> hits in let _CRbitmap ch 720 125 -> aff in let _CRbitmap ch 720 125 -> affmax in let mkDW[ch win hits aff affmax] -> b in (_CBwinPaint win @_paintE b; _FILLbitmap hits 0; _FILLbitmap aff 0; _FILLbitmap affmax 0; _CRtext ch win 5 5 720 20 ET_BORDER|ET_ALIGN_CENTER title; let day-> t in (let 80 -> h in let tabtolist t.dayhits -> tb in (_CRtext ch win 5 h 720 20 ET_BORDER|ET_ALIGN_CENTER (_loc this "TR_HITS" nil); createTexts hits 0 tb 1+maxVal tb 0xff 0); let 155+80 -> h in let coeff 36 tabtolist t.dayaff -> tb in (_CRtext ch win 5 h 720 20 ET_BORDER|ET_ALIGN_CENTER (_loc this "TR_AFF" nil); createTexts aff 0 tb 1+maxVal tb 0xff00 0); let 310+80 -> h in let tabtolist t.dayaffmax -> tb in (_CRtext ch win 5 h 720 20 ET_BORDER|ET_ALIGN_CENTER (_loc this "TR_AFFMAX" nil); createTexts affmax 0 tb 1+maxVal tb 0xffff 0); _CRtext ch win 5 30 200 20 ET_DOWN+ET_AHSCROLL strcat strcat (_loc this "TR_HITS" nil) " : " itoa t.daytothits; _CRtext ch win 5 55 200 20 ET_DOWN+ET_AHSCROLL strcat strcat (_loc this "TR_TIMEMAX" nil) " : " itoa t.daytimemax; _CRtext ch win 255 30 200 20 ET_DOWN+ET_AHSCROLL strcat strcat (_loc this "TR_TIMESPENT" nil) " : " itoa t.daytime; _CRtext ch win 255 55 200 20 ET_DOWN+ET_AHSCROLL strcat strcat (_loc this "TR_AVTIME" nil) " : " itoa t.daytime/(t.dayuser+1); let 465+80->h in (_CRtext ch win 5 h 720 20 ET_BORDER|ET_ALIGN_CENTER (_loc this "TR_FROM" nil); _CRtext ch win 5 h+25 200 20 ET_DOWN+ET_AHSCROLL strcat strcat (_loc this "TR_THITS" nil) " : " itoa t.totalhits; _CRtext ch win 255 h+25 200 20 ET_DOWN+ET_AHSCROLL strcat strcat (_loc this "TR_TTIME" nil) " : " itoa t.totaltime; _CRtext ch win 505 h+25 200 20 ET_DOWN+ET_AHSCROLL strcat strcat (_loc this "TR_TMAX" nil) " : " itoa t.totalaffmax)); _paintE nil b; b );; defcom Cgettoday=gettoday;; defcom Cgetmonth=getmonth S;; typeof win=ObjWin;; typeof hitsb=ObjBitmap;; typeof timeb=ObjBitmap;; typeof days=ObjList;; typeof monthhits=ObjText;; typeof monthtimemax=ObjText;; typeof monthtime=ObjText;; typeof monthavtime=ObjText;; fun _end(b)= _DMSdelete this;; fun _endE()= _DMSevent this "hidden" nil nil;; fun _resize(x,s)= let x->[wn x y w h] in _SIZEwindow win w h x y; 0;; fun _destroyE(x,y)=_end nil;; fun _today(a,b)=_DMSsend this Cgettoday [];; fun __today(s)=iniDay _channel win nil nil (_loc this "TR_TODAY" nil) AToTmp strextr s;; fun months()=(_loc this "MONTH_1" nil)::(_loc this "MONTH_2" nil)::(_loc this "MONTH_3" nil)::(_loc this "MONTH_4" nil):: (_loc this "MONTH_5" nil)::(_loc this "MONTH_6" nil)::(_loc this "MONTH_7" nil)::(_loc this "MONTH_8" nil):: (_loc this "MONTH_9" nil)::(_loc this "MONTH_10" nil)::(_loc this "MONTH_11" nil)::(_loc this "MONTH_12" nil)::nil;; fun addcomb(a,m)=_ADDcombo m 1000 a;; fun _selm(a,b,i,s)= if s==nil then nil else _DMSsend this Cgetmonth [s];; typeof title=S;; typeof tmp=S;; typeof tmps=[Tmp r1];; fun _paintW(a,b)= _BLTbitmap win hitsb 110 55; _BLTbitmap win timeb 110 210;; fun getTmp(l)= if l==nil then nil else (AToTmp (hd l)::nil)::getTmp tl l;; fun addday(t,i)=_ADDlist days 1000 t.day;; fun updatelj()= _RSTlist days; apply_on_list tmps @addday 0;; fun putday(b,i)= if i then (_DRAWtext b Font i*20-10 80 TD_CENTER 0xff0000 itoa i; putday b i-1) else 0;; fun maxHits(l)= if l==nil then 0 else let l->[t n] in let maxHits n -> x in if x[a n] in let atoi substr a.day 0 2 -> j in let 20*(j-1) ->x in (_DRAWtext b Font x+10 95+ if j&1 then 0 else 10 TD_CENTER 0xffffff (itoa a.daytothits); _DRAWrectangle b x+2 95-(a.daytothits)*90/mx 16 (a.daytothits)*90/mx DRAW_SOLID 0 0 DRAW_SOLID c; createHits b n mx c);; fun maxTime(l)= if l==nil then 0 else let l->[t n] in let maxTime n -> x in if x[a n] in let atoi substr a.day 0 2 -> j in let 20*(j-1) ->x in (_DRAWtext b Font x+10 95+if j&1 then 0 else 10 TD_CENTER 0xffffff (itoa a.daytime); _DRAWrectangle b x+2 95-(a.daytime)*90/mx 16 (a.daytime)*90/mx DRAW_SOLID 0 0 DRAW_SOLID c; createTime b n mx c);; fun sumHits(l)= if l==nil then 0 else let l->[a n] in a.daytothits+sumHits n;; fun sumTime(l)= if l==nil then 0 else let l->[a n] in a.daytime+sumTime n;; fun sumUser(l)= if l==nil then 0 else let l->[a n] in a.dayuser+sumUser n;; fun maxTime0(l)= if l==nil then 0 else let l->[t n] in let maxTime0 n -> x in if x t in if t==nil then nil else iniDay _channel win nil nil t.day t;; fun __start(s)=set title=s; set tmp=nil;; fun __send(s)= if s!=nil then (set tmp=strcat tmp s; 0) else if tmp==nil then (_DLGMessageBox _channel win (_loc this "TR_WARNING" nil) (_loc this "TR_WARNING2" nil) 0; 0) else (_storepack tmp title; set tmps=getTmp strextr tmp; updatebmp; updatelj; 0);; fun iniWin(wn,x,y,w,h)= set win=_CRwindow _channel if wn==nil then DMSwin else wn x y w h if wn==nil then WN_MENU+WN_MINBOX+WN_SIZEBOX else WN_CHILDINSIDE|WN_NOCAPTION|WN_NOBORDER _DMSgetName this; _CBwinDestroy win @_destroyE 0; _CRtext _channel win 5 5 725 20 ET_BORDER+ET_ALIGN_CENTER strcat strcat (_loc this "TR_TRAFIC" nil) " : " _DMSgetName this; _CBbutton (_CRbutton _channel win 5 30 100 20 0 (_loc this "TR_TODAY" nil)) @_today 0; let _CRcombo _channel win 5 55 100 256 CB_NOEDIT "" -> m in (apply_on_list months @addcomb m; _CBcombo m @_selm 0); set days=_CRlist _channel win 5 80 100 256 LB_DOWN+LB_VSCROLL; _CBlistDclick days @_chgday 0; _CRtext _channel win 110 30 620 20 ET_BORDER+ET_ALIGN_CENTER (_loc this "TR_HITS" nil); set hitsb=_CRbitmap _channel 620 125; _CRtext _channel win 110 185 620 20 ET_BORDER+ET_ALIGN_CENTER (_loc this "TR_TIMESPENT" nil); set timeb=_CRbitmap _channel 620 125; _FILLbitmap hitsb 0; _FILLbitmap timeb 0; _CBwinPaint win @_paintW 0; set monthhits=_CRtext _channel win 110 340 200 20 ET_DOWN+ET_AHSCROLL ""; set monthtimemax=_CRtext _channel win 110 365 200 20 ET_DOWN+ET_AHSCROLL ""; set monthtime=_CRtext _channel win 360 340 200 20 ET_DOWN+ET_AHSCROLL ""; set monthavtime=_CRtext _channel win 360 365 200 20 ET_DOWN+ET_AHSCROLL ""; 0;; fun IniDMI(param)= _DMSregisterDMI this nil @_endE; let _DMSgetZone this "Trafic" @_end @_resize @_end ->[wn x y w h] in if wn!=nil then iniWin wn x y w h else iniWin nil nil nil 735 400; _DMSevent this "shown" nil nil;;