home
***
CD-ROM
|
disk
|
FTP
|
other
***
search
/
DOS/V Power Report 1997 May
/
VPR9705A.ISO
/
FFILLY
/
CalClock
/
CalClock.tfy
< prev
next >
Wrap
Text File
|
1997-01-30
|
5KB
|
186 lines
//calclock.tfy
//デスクトップ常駐型カレンダー&時計
#info INAM "CalClock"
#info ISBJ "デスクトップ常駐型カレンダー&時計"
#info IART "POCOPEN,GGB02243@niftyserve.or.jp"
#info ICMT "ドラッグで好きな位置に移動できます。終了は右クリック。"
#info ICOP "POCOPEN,GGB02243@niftyserve.or.jp"
#info IENG "POCOPEN,GGB02243@niftyserve.or.jp"
#info IGNR "utility"
#info IKEY "カレンダー; 時計"
#info GENR "graphic; animation; joy; utility"
#info MDFY "Ask me"
#info TRNS "Ask me"
#info JINT "Ask me"
#define SPEED 2
#include draw3d.h
#include rgb2bgr.h
#include setcolor.h
int changeStringColor();
str getWhatTime();
str getYoubi();
main(){
int dotPic,basePic,stringPic,backPic,win;
int stringCast,leftCast,rightCast;
int w,h,xmr,ymu,xml,ymd,x,y;
int fontSize,stringWidth,moveStep;
int mx0,mx1,mx2,my0,my1,my2,posx,posy,flag;
int edge1,edge2;
int wCol,wColR,wColG,wColB;
str strings;
str wColStr;
mx0=GetIniInt("Position","x",0,"calclock.ini");
my0=GetIniInt("Position","y",0,"calclock.ini");
stringWidth=280;
fontSize=36;
w=320;
h=40;
if(h<fontSize) h=fontSize;
if(w<stringWidth) w=stringWidth;
xmr=10;
ymu=10;
xml=10;
ymd=10;
x=w+xml;
y=ymu+(h-fontSize)/2;
moveStep=10;
flag=0;
dotPic=LoadPic("1pixel.bmp");
stringPic=CreatePic(dotPic,w,h);
DelPic(dotPic);
backPic=CreatePic(stringPic,w+xmr+xml,h+ymu+ymd);
basePic=CreatePic(backPic);
SetPaintColor(BLACK);
SetLineSize(1);
DrawRect(stringPic,0,0,w,h);
SetPaintColor(BLUE);
wColStr=GetIniStr("Colors","ActiveBorder","192 192 192","win.ini");
wColR=StrtoInt(SubStr(wColStr,0,StrFind(wColStr," ")));
wColStr=SubStr(wColStr,StrFind(wColStr," ")+1,20);
wColG=StrtoInt(SubStr(wColStr,0,StrFind(wColStr," ")));
wColB=StrtoInt(SubStr(wColStr,StrFind(wColStr," ")+1,20));
wCol=wColB*256*256+wColG*256+wColR;
edge1=3;
edge2=2;
Draw3D(backPic,0,0,w+xmr+xml-1,h+ymu+ymd-1,wCol,edge1,35,0);
Draw3D(backPic,xml-edge2,ymu-edge2,w+xmr+xml-(xmr-edge2)-1,h+ymu+ymd-(ymd-edge2)-1,wCol,edge2,35,1);
SetPaintColor(BLACK);
DrawRect(backPic,xml,ymu,w+xml,h+ymu);
SetFont(fontSize,"Times New Roman",0,0,0,0,400);
BackMode(0);
BgCol(BLACK);
strings=getWhatTime();
changeStringColor(strings,stringPic);
PutCast(backPic,basePic);
stringCast=PutCast(stringPic,basePic,x,y,BLACK,0,1);
leftCast=PutCast(backPic,basePic,0,ymu,0x80000000,0,2,0,xml,h,0,ymu);
rightCast=PutCast(backPic,basePic,w+xml,ymu,0x80000000,0,2,0,xmr,h,w+xml,ymu);
CapTitle("");
win=OpenWin(basePic,mx0,my0);
mes(TIME){
step(SPEED){
MoveCast(stringCast,stringPic,x,y);
if(x<xml-stringWidth){
x=w+xml;
strings=getWhatTime();
changeStringColor(strings,stringPic);
}
else{
x=x-moveStep;
TextWrite(getWhatTime(),stringPic);
}
}
}
mes(LBDOWN){
mx1=GetLowWord(GetCurPos());
my1=GetHiWord(GetCurPos());
flag=1;
}
mes(TIME){
step(SPEED){
if(flag==1){
mx2=GetLowWord(GetCurPos());
my2=GetHiWord(GetCurPos());
posx=mx2-mx1+mx0;
posy=my2-my1+my0;
MoveWin(win,basePic,posx,posy);
}
}
}
mes(LBUP){
mx0=posx;
my0=posy;
WriteIniInt("Position","x",mx0,"calclock.ini");
WriteIniInt("Position","y",my0,"calclock.ini");
flag=0;
}
mes(RBDOWN){
WriteIniInt("Position","x",mx0,"calclock.ini");
WriteIniInt("Position","y",my0,"calclock.ini");
CloseWin(win);
del_us;
del_me;
}
}
int changeStringColor(str string,int pic){
int colr,colg,colb;
repeat:;
colb=Random(256);
colg=Random(256);
colr=Random(256);
if(colb+colg+colr<160) goto repeat;
TextColor(colr,colg,colb);
TextWrite(string,pic);
}
str getWhatTime(){
int date,year,month,day;
int time,hour,minute,second;
str string,youbi;
date=WhatDay();
year=date/10000;
month=(date-year*10000)/100;
day=date-year*10000-month*100;
time=WhatTime();
hour=time/10000;
minute=(time-hour*10000)/100;
second=time-hour*10000-minute*100;
youbi=getYoubi(year,month,day);
return(StrPrint("%ld.%2ld.%2ld %s / %2ld:%02ld:%02ld ",year,month,day,youbi,hour,minute,second));
}
str getYoubi(int Y,int M,int D){
int sumDay;
int i,n[];
str Youbi[];
Youbi[0]="Sun"; Youbi[1]="Mon"; Youbi[2]="Tue"; Youbi[3]="Wed";
Youbi[4]="Thu"; Youbi[5]="Fri"; Youbi[6]="Sat";
n[1]=31; n[2]=28; n[3]=31; n[4]=30; n[5]=31; n[6]=30;
n[7]=31; n[8]=31; n[9]=30; n[10]=31; n[11]=30; n[12]=31;
if(Y<96) Y=Y+2000;
else Y=Y+1900;
sumDay=0; //sumDay:960101からの積算日数
for(i=0;i<Y-1996;i=i+1){
sumDay=sumDay+365;
if(i%4==0) sumDay=sumDay+1; //閏年のときは+1
}
for(i=1;i<M;i=i+1) sumDay=sumDay+n[i];
if((Y%4==0)&&(M>2)) sumDay=sumDay+1; //閏年の3月以降では+1
sumDay=sumDay+D;
return(Youbi[sumDay%7]);
}