home
***
CD-ROM
|
disk
|
FTP
|
other
***
search
/
The World of Computer Software
/
World_Of_Computer_Software-02-385-Vol-1of3.iso
/
d
/
dir_nm20.zip
/
Dir_NM_2.0
/
NM-Output.c
< prev
next >
Wrap
C/C++ Source or Header
|
1992-07-16
|
29KB
|
944 lines
/* === NM-Output.c ===
*
* void See_Tempo_Set(Id)
* void Use_Keys(ch)
* void Output(Melody_Id)
* void Print_Melody(Melody_Id)
* void Switch_Set(button,W,H)
* void Adjust_Set(button,W,H)
* void Combine_Tempo(Id)
* void Up_Date_Value(W,H)
* void Fix_Value(button,W,H)
* void Adjust_Value(Melody_Id)
*
*/
#include "NM.h"
XEvent report;
KeySym ks;
int i,p,q,button,MS_x,MS_y,old_MS_x,old_MS_y,dx,dy,first,last;
void See_Tempo_Set(Id)
int Id;
{
XEvent report;
KeySym ks;
int button,i,k,Num,Tmp_Id,Timbre_Id,Mx,My,Info;
more *WITH;
if ((timfile=fopen("Dir_Song/IM.tim","r"))==NULL)
for (i=0;i<100;i++)
{
tim[i]=(more *)malloc(sizeof(more));WITH=tim[i];*WITH->tool='\0';
for (j=0;j<20;j++) WITH->freq[j]=0;
}
if (Motion!=Tempo_Set_On)
{
Num=0;
for (i=1;i<7;i++)
{
if (i<4)
{
if (St[Id][2][1].nt[i]!=200)
{
for (k=0;k<4;k++) tmp_buf[Num][k].note=tmp_buf[Num][k].act=0;
for (k=4;k<30;k++)
tmp_buf[Num][k].note=tmp_buf[Num][k].act=200;
tmp_buf[Num][1].note=St[Id][1][1].nt[0]; /* Timer */
tmp_buf[Num][1].act=St[Id][2][1].nt[0]; /* Measure */
tmp_buf[Num][2].note=0;tmp_buf[Num][2].act=0;
for (k=3;k<30;k++)
{
Info=St[Id][k-1][1].nt[i];if (Info==200) break;
if (Info<0) tmp_buf[Num][k].note=0;
else tmp_buf[Num][k].note=71;
tmp_buf[Num][k].act=abs(Info);
}
tmp_buf[Num][0].note=k-2;tmp_buf[Num][0].act=0;
Timbre_Id=St[Id][1][1].nt[i]-1;
Sample_names[Num]=(char *)malloc(50);*Sample_names[Num]='\0';
if (tim[Timbre_Id]->tool!='\0')
strcpy(Sample_names[Num],tim[Timbre_Id]->tool);
Num++;
}
}
else
{
if (St[Id][2][2].nt[i-3]!=200)
{
for (k=0;k<4;k++) tmp_buf[Num][k].note=tmp_buf[Num][k].act=0;
for (k=4;k<30;k++)
tmp_buf[Num][k].note=tmp_buf[Num][k].act=200;
tmp_buf[Num][1].note=St[Id][1][1].nt[0]; /* Timer */
tmp_buf[Num][1].act=St[Id][2][1].nt[0]; /* Measure */
tmp_buf[Num][2].note=0;tmp_buf[Num][2].act=0;
for (k=3;k<30;k++)
{
Info=St[Id][k-1][2].nt[i-3];if (Info==200) break;
if (Info<0) tmp_buf[Num][k].note=0;
else tmp_buf[Num][k].note=71;
tmp_buf[Num][k].act=abs(Info);
}
tmp_buf[Num][0].note=k-2;tmp_buf[Num][0].act=0;
Timbre_Id=St[Id][1][2].nt[i-3]-1;
Sample_names[Num]=(char *)malloc(50);*Sample_names[Num]='\0';
if (tim[Timbre_Id]->tool!='\0')
strcpy(Sample_names[Num],tim[Timbre_Id]->tool);
Num++;
}
}
}
if (Num>0)
{
Tour_On=1;Back_Id=Id;Now_Bank=now;now=0;XClearWindow(display,win);
Staff(now,five,0);for (k=0;k<Num;k++) Showpage(k,0,1,0,2,-1);
}
}
else
{
Set_Id=Id;now=0;five=1;XClearWindow(display,win);Staff(now,five,0);
_LA:Num=0;
for (i=0;i<6;i++)
{
Tmp_Id=cont[Set_Id].tempo[i]-1;Timbre_Id=cont[Set_Id].instru[i];
if (Tmp_Id>-1 && Tmp_Id<content[0])
{
for (k=0;k<30;k++) tmp_buf[Num][k]=tmp[Tmp_Id][k];
Sample_names[Num]=(char *)malloc(50);*Sample_names[Num]='\0';
if (-1<Timbre_Id && Timbre_Id<100 &&
strlen(tim[Timbre_Id]->tool)>0)
strcpy(Sample_names[Num],tim[Timbre_Id]->tool);
Num++;
}
}
Rub(0,33,1137,700,"NavyBlue");
if (Num>0) for (k=0;k<Num;k++) Showpage(k,0,1,0,2,-1);
if (Action==Print_On) system("xwd | xpr -device lw -rv | lpr -h -Pps10");
do {
XNextEvent(display,&report);ch='\0';
switch(report.type)
{
case ButtonPress:button=report.xbutton.button;
Mx=report.xmotion.x;My=report.xmotion.y;
switch (button)
{
case Button1:if (Set_Id>0) Set_Id--;
else
Set_Id=content[Max_kind-1];
goto _LA;
break;
case Button2:if (Set_Id<content[Max_kind-1])
Set_Id++;
else Set_Id=0;
goto _LA;
break;
case Button3:if (548<Mx && Mx<585 && 2<My
&& My<28)
ch='&';
else
{
if (Set_Id<content[Max_kind
-1])
Set_Id++;
else Set_Id=0;
goto _LA;
}
break;
}
break;
case KeyPress:ks=XLookupKeysym(report,0);
switch(ks)
{
case 65498:if (Set_Id>0) Set_Id--;
else Set_Id=content[Max_kind-1];
goto _LA;
break; /* PgUp */
case 65504:if (Set_Id<content[Max_kind-1])
Set_Id++;
else Set_Id=0;
goto _LA;
break; /* PgDn */
case XK_Return:ch='!';break;
case XK_Escape:ch='&';break;
}
break;
}
} while (!(ch == '!' || ch == '&'));
}
}
void Use_Keys(ch)
char ch;
{
char STR1[256],*filename;
old_MS_x=200;old_MS_y=200;MS_x=old_MS_x;MS_y=old_MS_y;dx=dy=0;;
switch (ch)
{
case '$':if (now>0)
{
if (M_Id>p)
{
switch (page)
{
case 0:M_Id--;Print_pt=0;
if (St[M_Id][8][0].nt[0]>St[M_Id][8][1].nt[0])
page=St[M_Id][8][0].nt[0];
else page=St[M_Id][8][1].nt[0];
if (St[M_Id][8][0].nt[2]>page)
page=St[M_Id][8][2].nt[0];
Rub(67,3,477,25,"MediumBlue");
SetColor("gold");Use_Font("12x24");
OutTextXY(67,26,names[now*1000+M_Id-1000]);
Showpage(M_Id,page,1,0,2,-1);
break;
case 1:
case 2:
case 3:
case 4:
case 5:
case 6:
case 7:
case 8:
case 9:page--;Showpage(M_Id,page,1,0,2,-1);
break;
}
}
else if (page!=0)
{ page--;Showpage(M_Id,page,1,0,2,-1); }
}
break;
case '^':if (now>0)
{
if (M_Id<q)
{
if (page<St[M_Id][8][0].nt[0]||page<St[M_Id][8][1].nt[0]
|| page<St[M_Id][8][2].nt[0])
page++;
else { M_Id++;page=0;Print_pt=0; }
Showpage(M_Id,page,1,0,2,-1);
}
else if (page<St[M_Id][8][0].nt[0] ||
page<St[M_Id][8][1].nt[0] ||
page<St[M_Id][8][2].nt[0])
{ page++;Showpage(M_Id,page,1,0,2,-1); }
}
break;
case '*': /* F1 */
case '/':_LA:page=0; /* F2 */
if (now>0)
{
Rub(67,3,477,25,"MediumBlue");
SetColor("gold");Use_Font("12x24");
if (ch=='*') { if (M_Id>0) M_Id--;else M_Id=content[now]-1; }
else { if (M_Id<content[now]-1) M_Id++;else M_Id=0; }
OutTextXY(67,26,names[now*1000+M_Id]);ch='\0';
do {
XNextEvent(display,&report);
switch(report.type)
{
case ButtonPress:button=report.xbutton.button;
MS_x=report.xbutton.x;
MS_y=report.xbutton.y;
switch(button)
{
case Button1:ch='*';break;
case Button2:ch='!';Print_pt=0;
break;
case Button3:if (548<MS_x &&
MS_x<585 &&
2<MS_y &&
MS_y<28)
ch='&';
else ch='/';
break;
}
break;
case KeyPress:ks=XLookupKeysym(report,0);
switch(ks)
{
case XK_F1:ch='*';break;
case XK_F2:ch='/';break;
case XK_Return:ch='!';break;
case XK_Escape:ch='&';break;
}
break;
}
if (ch=='*' || ch=='/') goto _LA;
} while (ch != '!' && ch != '&');
if (ch=='&') return;else Showpage(M_Id,0,1,0,2,-1);
if (unite) highlight(x*36+5,z+100,26,37);
}
else
{
Rub(200,3,50,25,"MediumBlue");SetColor("gold");
if (ch=='*') { if (M_Id>0) M_Id--;else M_Id=content[now]-1; }
else { if (M_Id<content[now]-1) M_Id++;else M_Id=0; }
Use_Font("12x24");Out_I_XY(200,26,M_Id+1);
Showpage(M_Id,0,1,0,2,-1);
}
break;
case '+':if (unite) { Pickup(x,way,-1);first=Count(M_Id,way*30+x,&n,1); }
break; /* F3 */
case '=':if (unite) { Pickup(x,way,1);last=Count(M_Id,way*30+x,&n,1); }
break; /* F4 */
case '[':if (unite && first<=last && i+last-first<=M_Len-1) /* F5 */
{
if (St[head][0][0].nt[0]==0)
for (j=0;j<St_Start;j++)
{
St[head][j][0]=St[M_Id][j][0];
St[head][j][1]=St[M_Id][j][1];
St[head][j][2]=St[M_Id][j][2];
}
for (j=first;j<last+1;j++)
{
St[head][i+j-first][0]=St[M_Id][j][0];
St[head][i+j-first][1]=St[M_Id][j][1];
St[head][i+j-first][2]=St[M_Id][j][2];
}
i+=last-first+1;
St[head][0][0].nt[0]=St[head][0][1].nt[0]=i;
St[head][0][2].nt[0]=i;Save(M_Id+1,tail);
}
else { /*sound(180);delay(600);nosound();*/ }
break;
case '#':if (now>0)
{
dis(&lock);Rub(921,835,30,17,"MediumBlue");
SetColor("gold");Use_Font("7x14");
if (lock) OutTextXY(921,852,"On ");
else OutTextXY(921,852,"Off");
}
break;
case '<':if (unite)
{
highlight(x*36+5,z+100,26,37);
if (x>1) x--;
else
{
switch (way)
{
case 3:
case 6:way--;page=way/3;Showpage(M_Id,page,1,0,2,-1);
x=30;
break;
case 1:
case 2:
case 4:
case 5:
case 7:
case 8:way--;x=30;break;
}
z=(way-page*3)*Dist;
}
highlight(x*36+5,z+100,26,37);
}
break;
case '>':if (unite)
{
highlight(x*36+5,z+100,26,37);
if (x<30) x++;
else
{
switch (way)
{
case 2:
case 5:way++;page=way/3;Showpage(M_Id,page,1,0,2,-1);
x=1;
break;
default:way++;x=1;break;
}
z=(way-page*3)*Dist;
}
highlight(x*36+5,z+100,26,37);
}
break;
case '?':if (unite && way>0)
{
switch (way)
{
case 3:
case 6:way--;page=way/3;Showpage(M_Id,page,1,0,2,-1);
break;
case 1:
case 2:
case 4:
case 5:
case 7:
case 8:way--;break;
}
highlight(x*36+5,z+100,26,37);z=(way-page*3)*Dist;
highlight(x*36+5,z+100,26,37);
}
break;
case '@':if (unite & St[M_Id][0][0].nt[0]-p>=30)
{
switch (way)
{
case 2:
case 5:way++;page=way/3;Showpage(M_Id,page,1,0,2,-1);
break;
default:way++;break;
}
highlight(x*36+5,z+100,26,37);z=(way-page*3)*Dist;
highlight(x*36+5,z+100,26,37);
}
break;
case 'L':Signal=1;q=M_Id+1;Sing();q=content[now];break;
case 'G':Rub(176,840,770,16,"MediumBlue");SetColor("cyan");
Use_Font("7x14");OutTextXY(176,852,"Back file name: ");
SetColor("white");filename=(char *)malloc(100);*filename='\0';
sprintf(filename+strlen(filename),"%s","Dir_Text/");j=0;
do {
ch='\0';ch=getkey();
if (('0'<=ch && ch<='9') || ('a'<=ch && ch<='z') || ('A'<=ch
&& ch<='Z') || ch=='.' || ch=='-' || ch=='_' || ch=='*')
{
sprintf(filename+strlen(filename),"%c",ch);
sprintf(STR1,"%c",ch);OutTextXY(j*8+300,852,STR1);j++;
}
} while (ch != '!' && j != 33);
if (j>1)
{
Load_On=1;M_Id=Load_From_Back_Up(filename,M_Id,1);
Showpage(M_Id,0,1,0,2,-1);Load_On=0;
}
Rub(176,840,770,16,"MediumBlue");
SetColor("gold");Use_Font("7x14");
OutTextXY(179,852,"F1-Ahead F2-Behind F3-First F4-Last F5-Copy B-Backup G-Get_Backup D-Midi_Load S-Midi_Save Lock-Off");
break;
case 'B':if (now>0) Save_To_Back_Up(names[now*1000+M_Id],M_Id);
else Save_To_Back_Up("tempo-",M_Id);
break;
case 'D':Rub(176,840,770,16,"MediumBlue");SetColor("cyan");
Use_Font("7x14");OutTextXY(176,852,"Midi file name: ");
SetColor("white");filename=(char *)malloc(100);*filename='\0';
sprintf(filename+strlen(filename),"%s","Dir_Midi/");j=0;
do {
ch='\0';ch=getkey();
if (('0'<=ch && ch<='9') || ('a'<=ch && ch<='z') || ('A'<=ch
&& ch<='Z') || ch=='.' || ch=='-' || ch=='_' || ch=='*')
{
sprintf(filename+strlen(filename),"%c",ch);
sprintf(STR1,"%c",ch);OutTextXY(j*8+300,852,STR1);j++;
}
} while (ch != '!' && j != 33);
if (j>1)
{
M_Id=Load_From_Midi(filename,M_Id);
Showpage(M_Id,0,1,0,2,-1);
Rub(176,840,770,16,"MediumBlue");
}
SetColor("gold");Use_Font("7x14");
OutTextXY(179,852,"F1-Ahead F2-Behind F3-First F4-Last F5-Copy B-Backup G-Get_Backup D-Midi_Load S-Midi_Save Lock-Off");
break;
case 'S':if (now>0) Save_To_Midi(names[now*1000+M_Id],M_Id);
else Save_To_Midi("tempo-",M_Id);
break;
}
}
void Output(Melody_Id)
int Melody_Id;
{
int j,k,At_high,Tmp_Lim,Val;
char STR1[256];
old_MS_x=200;old_MS_y=200;MS_x=old_MS_x;MS_y=old_MS_y;ch='\0';
if (next==0) unite=0;first=St_Start+1;last=St_Start;
if (content[next]==0 || unite)
{
Rub(0,480,1139,400,"MediumBlue");Rub(0,480,1139,2,"yellow");
SetColor("green");Use_Font("12x24");
}
if (content[next]==0)
{
OutTextXY(470,600,"No such melody !");do { } while ((ch=GetKey())!='!');
return;
}
p=0;q=content[next]-1;
if (unite)
{
if (content[next]==1000)
{
Rub(0,480,1139,400,"MediumBlue");Rub(0,480,1139,2,"yellow");
SetColor("green");Use_Font("12x24");
OutTextXY(300,600,"No more then 1000 melodys");
do { } while ((ch=GetKey())!='!');return;
}
head=content[next];tail=head+1;
}
if (now!=next) { now=next;Load(); }
/*
OutTextXY(420,600,"Five-line ?");ch=GetKey();if (ch!= 'N') five=1;else five=0;
*/
Rub(0,480,1137,378,"MediumBlue");XSetLineAttributes(display,gc,2,0,0,0);
SetColor("yellow");Line(0,480,1137,480);SetColor("green");
nx=-1;ny=-1;five=1;
if (unite)
{
OutTextXY(310,560,"Melody name: ");i=now*1000+head;
S_bf=(char *)malloc(10);*S_bf='\0';sprintf(S_bf,"%5ld",i+1);
Out_I_XY(460,560,i+1);strcpy(names[i],S_bf);ch='.';j=0;
do {
sprintf(names[i]+strlen(names[i]),"%c",ch);
sprintf(STR1,"%c",ch);OutTextXY(j*12+530,560,STR1);j++;ch=getkey();
} while (ch != '!' && j != 34);
if (j==1) sprintf(names[i]+strlen(names[i]),"%s","New");
sprintf(names[i]+strlen(names[i]),"%c",'\n');i=St_Start;
for (j=0;j<M_Len;j++)
for (At_high=0;At_high<3;At_high++)
{
St[head][j][At_high].nt[0]=200;
St[head][j][At_high].nt[1]=St[head][j][At_high].nt[2]=0;
St[head][j][At_high].nt[3]=0;
St[head][j][At_high].act=0;St[head][j][At_high].vol=Volumn;
}
St[head][0][0].nt[0]=0;
}
XClearWindow(display,win);Staff(now,five,0);On_High=2;
next=0;M_Id=Melody_Id;way=0;page=0;lock=0;Use_Font("7x14");SetColor("gold");
OutTextXY(179,852,"F1-Ahead F2-Behind F3-First F4-Last F5-Copy B-Backup G-Get_Backup D-Midi_Load S-Midi_Save Lock-Off");
if (now>0) Showpage(M_Id,0,1,0,2,-1);
else
{
for (j=0;j<q+1;j++)
{
for (k=0;k<30;k++) tmp_buf[j][k]=tmp[j][k];
Sample_names[j]=(char *)malloc(50);*Sample_names[j]='\0';
strcpy(Sample_names[j],names[j]);
}
if (q-M_Id>9) Tmp_Lim=10;else Tmp_Lim=q+1-M_Id;
for (j=M_Id;j<M_Id+Tmp_Lim;j++) Showpage(j,0,1,0,2,-1);M_Id+=Tmp_Lim-1;
}
if (unite) { z=0;if (five) x=1;else x=4;highlight(x*36+5,z+100,26,37); }
do {
XNextEvent(display,&report);
switch(report.type)
{
case ButtonPress:button=report.xbutton.button;ch='\0';
MS_x=report.xbutton.x;MS_y=report.xbutton.y;
Val=DoButtonEvent(report,button,MS_x,MS_y,M_Id,1,1);
if (Val!=1) Use_Keys(ch);
break;
case KeyPress:ks=XLookupKeysym(report,0);
switch(ks)
{
case XK_F1:ch='*';break;
case XK_F2:ch='/';break;
case XK_F3:ch='+';break;
case XK_F4:ch='=';break;
case XK_F5:ch='[';break;
case XK_F6:ch=']';break;
case XK_Return:ch='!';break;
case XK_Escape:ch='&';break;
case XK_Left:ch='<';break;
case XK_Right:ch='>';break;
case XK_Up:ch='?';break;
case XK_Down:ch='@';break;
case 65496:ch='#';break; /* Home */
case 65502:ch='%';break; /* End */
case 65498:ch='$';break; /* PgUp */
case 65504:ch='^';break; /* PgDn */
case XK_Num_Lock:ch='|';break;
case XK_Insert:ch='{';break;
case XK_Delete:ch='}';break;
default:XLookupString(report,tmpstr,128,&ks,0);
if (isalpha(tmpstr[0]))
ch=toupper(tmpstr[0]);
else ch=tmpstr[0];
break;
}
Use_Keys(ch);
break;
}
} while (ch != '&');
if (unite)
{ if (first<=last) { Del=-1;content[now]+=1;Save(M_Id+1,tail);} unite=0; }
}
void Print_Melody(Melody_Id)
int Melody_Id;
{
int i,j,k,q,Tmp_Lim,page,Num;
if (Melody_Id==-1)
{
Rub(0,480,1139,400,"MediumBlue");Rub(0,480,1139,2,"yellow");
SetColor("green");Use_Font("12x24");OutTextXY(370,630,"Print all ?");
ch=GetKey();if (ch != 'N') ch='Y';S_bf=(char *)malloc(10);*S_bf='\0';
sprintf(S_bf,"%c",ch);OutTextXY(590,630,S_bf);
if (ch!='N') { M_Id=0;Num=content[next]; } else return;
if (M_Id>=content[next])
{
OutTextXY(500,700,"No such melody !");
do { } while ((ch=GetKey())!='!');
return;
}
}
else { M_Id=Melody_Id;Num=1; }
if (now != next) now=next;
if (now!=Max_kind-1 && content[now]>0) Load();
five=1;
if (now==0)
{
q=content[next]-1;Num=0;XClearWindow(display,win);Staff(now,1,0);
for (j=0;j<q;j++)
{
for (k=0;k<30;k++) tmp_buf[j][k]=tmp[j][k];
Sample_names[j]=(char *)malloc(50);*Sample_names[j]='\0';
strcpy(Sample_names[j],names[j]);
}
do {
if (content[next]-Num>10) Tmp_Lim=10;else Tmp_Lim=content[next]-Num;
for (M_Id=Num;M_Id<Num+Tmp_Lim;M_Id++) Showpage(M_Id,0,1,0,2,-1);
Num+=Tmp_Lim;system("xwd | xpr -device lw -rv | lpr -h -Pps10");
} while (Num<content[next]);
}
else
{
XClearWindow(display,win);Staff(now,1,0);i=M_Id;
for (M_Id=i;M_Id<i+Num;M_Id++)
{
if (St[M_Id][8][0].nt[0]>St[M_Id][8][1].nt[0]) k=St[M_Id][8][0].nt[0];
else k=St[M_Id][8][1].nt[0];
if (k<St[M_Id][8][2].nt[0]) k=St[M_Id][8][2].nt[0];
for (page=0;page<k+1;page++)
{
Showpage(M_Id,page,1,1,2,-1);
system("xwd | xpr -device lw -rv | lpr -h -Pps10");
}
}
}
}
void Switch_Set(button,W,H)
int button,W,H;
{
int i,dx,dy;
Rub(Set_X+40,Set_Y+1,2*W-40,H-2,"MediumBlue");
for (i=0;i<6;i++)
{
dx=Set_X+2*W+i*W+2;dy=Set_Y+H+2;Rub(dx,dy,W-3,H-4,"MediumBlue");
Rub(dx,dy+H,W-3,H-4,"MediumBlue");
}
if (button==Button1)
{ if (Set_Id==0) Set_Id=content[Max_kind-1];else Set_Id--; }
else if (button==Button3)
{ if (Set_Id==content[Max_kind-1]) Set_Id=0;else Set_Id++; }
SetColor("SpringGreen");
OutTextXY(Set_X+32,Set_Y+26,Sub_Str(cont[Set_Id].Set_name,0,12));
for (i=0;i<6;i++)
{
if (cont[Set_Id].tempo[i]>0)
Out_I_XY(Set_X+22+2*W+i*W,Set_Y+H+26,cont[Set_Id].tempo[i]);
if (cont[Set_Id].instru[i]>0)
Out_I_XY(Set_X+22+2*W+i*W,Set_Y+2*H+26,cont[Set_Id].instru[i]);
}
}
void Adjust_Set(button,W,H)
int button,W,H;
{
int dx,dy;
dx=Set_X+2*W+Set_Column*W+2;dy=Set_Y+H+Set_Row*H+2;
Rub(dx,dy,W-3,H-4,"MediumBlue");SetColor("white");
if (Set_Row==0)
{
switch (button)
{
case Button1:if (cont[Set_Id].tempo[Set_Column]==0)
cont[Set_Id].tempo[Set_Column]=1000;
else cont[Set_Id].tempo[Set_Column]--;
break;
case Button2:if (cont[Set_Id].tempo[Set_Column]+10>999)
cont[Set_Id].tempo[Set_Column]=0;
else cont[Set_Id].tempo[Set_Column]+=10;
break;
case Button3:if (cont[Set_Id].tempo[Set_Column]>999)
cont[Set_Id].tempo[Set_Column]=0;
else cont[Set_Id].tempo[Set_Column]++;
break;
}
Out_I_XY(Set_X+22+2*W+Set_Column*W,Set_Y+H+26,
cont[Set_Id].tempo[Set_Column]);
}
else if (Set_Row==1)
{
switch (button)
{
case Button1:if (cont[Set_Id].instru[Set_Column]==0)
cont[Set_Id].instru[Set_Column]=1000;
else cont[Set_Id].instru[Set_Column]--;
break;
case Button2:if (cont[Set_Id].instru[Set_Column]+10>999)
cont[Set_Id].instru[Set_Column]=0;
else cont[Set_Id].instru[Set_Column]+=10;
break;
case Button3:if (cont[Set_Id].instru[Set_Column]>999)
cont[Set_Id].instru[Set_Column]=0;
else cont[Set_Id].instru[Set_Column]++;
break;
}
Out_I_XY(Set_X+22+2*W+Set_Column*W,Set_Y+26+2*H,
cont[Set_Id].instru[Set_Column]);
}
highlight(dx+1,dy+1,W-5,H-6);
}
void Combine_Tempo(Id)
int Id;
{
int i,W,H,button,Ms_x,Ms_y;
Rub(0,480,1132,384,"MediumBlue");XSetLineAttributes(display,gc,2,0,0,0);
SetColor("yellow");Line(0,480,1132,480);Use_Font("7x14");SetColor("white");
Set_X=325;Set_Y=620;Set_W=480;Set_H=120;W=60;H=40;Set_Id=Id;ch='\0';
DrawRectangle(Set_X,Set_Y,Set_W,Set_H);XSetLineAttributes(display,gc,1,0,0,0);
for (i=0;i<6;i++) Line(Set_X+2*W+W*i,Set_Y,Set_X+2*W+W*i,Set_Y+Set_H);
for (i=1;i<3;i++) Line(Set_X,Set_Y+H*i,Set_X+Set_W,Set_Y+H*i);
SetColor("magenta");OutTextXY(Set_X+10,Set_Y+26,"Num");SetColor("yellow");
OutTextXY(Set_X+10,Set_Y+26+H,"Tempo #");Set_Column=-10;Set_Row=-10;
OutTextXY(Set_X+10,Set_Y+26+2*H,"Instrument #");SetColor("cyan");
for (i=0;i<6;i++) Out_I_XY(Set_X+26+2*W+i*W,Set_Y+26,i+1);
Switch_Set(Button2,W,H);
do {
XNextEvent(display,&report);
switch(report.type)
{
case MotionNotify:Ms_x=report.xmotion.x;Ms_y=report.xmotion.y;
Hi_light_Set(Ms_x,Ms_y);
break;
case ButtonPress:button=report.xbutton.button;
if (button==Button2 && In_Set(Ms_x,Ms_y,W,H)==0)
{
for (i=0;i<6;i++)
if (cont[content[Max_kind-1]].instru[i]>0 ||
cont[content[Max_kind-1]].tempo[i]>0)
{
if (content[Max_kind-1]<999)
{
content[Max_kind-1]++;Save_Set();
Get_List();
}
break;
}
}
else
{
Ms_x=report.xbutton.x;Ms_y=report.xbutton.y;
if (In_Set(Ms_x,Ms_y,W,H)==0)
Switch_Set(button,W,H);
else if (In_Set(Ms_x,Ms_y,W,H)==1)
Adjust_Set(button,W,H);
}
break;
case KeyPress:ks=XLookupKeysym(report,0);
switch(ks)
{
case XK_Return:ch='!';break;
case XK_Escape:ch='&';break;
case XK_Delete:Delete_Set(Set_Id);
if (content[Max_kind-1]<Set_Id)
Set_Id=content[Max_kind-1];
Switch_Set(-1,W,H);Get_List();
break;
}
break;
}
} while (!(ch=='!' || ch=='&'));
Save_Set();
}
void Up_Date_Value(W,H)
int W,H;
{
int i,j,X,Y;
for (i=0;i<4;i++)
for (j=0;j<5;j++)
{
X=Value_X+Value_H_X+j*W+2;Y=Value_Y+Value_H_Y+i*H+2;
Rub(X,Y,Value_H_W,Value_H_H,"MediumBlue");SetColor("cyan");
Out_I_XY(X+22,Y+15,St[M_Id][10+i*5+j][On_High].nt[0]);
}
}
void Fix_Value(button,W,H)
int button,W,H;
{
int X,Y,Id;
X=Value_X+Value_H_X+Value_Column*W+2;Y=Value_Y+Value_H_Y+Value_Row*H+2;
Rub(X,Y,Value_H_W,Value_H_H,"MediumBlue");SetColor("white");
Id=10+Value_Row*5+Value_Column;
switch (button)
{
case Button1:if (St[M_Id][Id][On_High].nt[0]<-9)
St[M_Id][Id][On_High].nt[0]=10;
else St[M_Id][Id][On_High].nt[0]-=1;
Out_I_XY(Value_X+96+Value_Column*W,Value_Y+47+Value_Row*H,
St[M_Id][Id][On_High].nt[0]);
break;
case Button2:Rub(Value_X,Value_Y-32,33,16,"MediumBlue");
switch (On_High)
{
case 0:On_High=2;break;
case 1:On_High=0;break;
case 2:On_High=1;break;
}
Up_Date_Value(W,H);SetColor("white");
if (On_High==2) OutTextXY(Value_X,Value_Y-20,"Vois");
else if (On_High==1) OutTextXY(Value_X,Value_Y-20,"High");
else if (On_High==0)
OutTextXY(Value_X,Value_Y-20,"Low");
break;
case Button3:if (St[M_Id][Id][On_High].nt[0]>9)
St[M_Id][Id][On_High].nt[0]=-10;
else St[M_Id][Id][On_High].nt[0]+=1;
Out_I_XY(Value_X+96+Value_Column*W,Value_Y+47+Value_Row*H,
St[M_Id][Id][On_High].nt[0]);
break;
}
highlight(X,Y,Value_H_W,Value_H_H);
}
void Adjust_Value(Melody_Id)
int Melody_Id;
{
int i,j,W,H,button,Ms_x,Ms_y;
Rub(0,480,1132,384,"MediumBlue");XSetLineAttributes(display,gc,2,0,0,0);
SetColor("yellow");Line(0,480,1132,480);Value_X=225;Value_Y=590;Value_W=680;
Value_H=240;W=136;H=60;SetColor("white");M_Id=Melody_Id;Use_Font("12x24");
DrawRectangle(Value_X,Value_Y,Value_W,Value_H);Value_Column=-10;Value_Row=-10;
XSetLineAttributes(display,gc,1,0,0,0);ch='\0';On_High=1;
for (i=1;i<5;i++) Line(Value_X+W*i,Value_Y,Value_X+W*i,Value_Y+Value_H);
for (i=1;i<4;i++) Line(Value_X,Value_Y+H*i,Value_X+Value_W,Value_Y+H*i);
SetColor("green");OutTextXY(Value_X+2*W,Value_Y-20,names[now*1000+M_Id]);
Use_Font("7x14");SetColor("white");OutTextXY(Value_X,Value_Y-20,"High");
SetColor("yellow");
for (i=0;i<4;i++)
switch (i)
{
case 0:for (j=0;j<5;j++)
switch (j)
{
case 0:OutTextXY(Value_X+20+j*W,Value_Y+26+i*H,"Quality");
break;
case 1:OutTextXY(Value_X+20+j*W,Value_Y+26+i*H,"Creative");
break;
case 2:OutTextXY(Value_X+20+j*W,Value_Y+26+i*H,"Famous");
break;
case 3:OutTextXY(Value_X+20+j*W,Value_Y+26+i*H,"Pleasing");
break;
case 4:OutTextXY(Value_X+20+j*W,Value_Y+26+i*H,
"Genaration");
break;
}
break;
case 1:for (j=0;j<5;j++)
switch (j)
{
case 0:OutTextXY(Value_X+20+j*W,Value_Y+26+i*H,"Year");
break;
case 1:OutTextXY(Value_X+20+j*W,Value_Y+26+i*H,"Complex");
break;
case 2:OutTextXY(Value_X+20+j*W,Value_Y+26+i*H,"Fast");
break;
case 3:OutTextXY(Value_X+20+j*W,Value_Y+26+i*H,"Best_A");
break;
case 4:OutTextXY(Value_X+20+j*W,Value_Y+26+i*H,"Best_Z");
break;
}
break;
case 2:for (j=0;j<5;j++)
switch (j)
{
case 0:OutTextXY(Value_X+20+j*W,Value_Y+26+i*H,"Lasting");
break;
case 1:OutTextXY(Value_X+20+j*W,Value_Y+26+i*H,"Light");
break;
case 2:OutTextXY(Value_X+20+j*W,Value_Y+26+i*H,"Bright");
break;
case 3:OutTextXY(Value_X+20+j*W,Value_Y+26+i*H,"Better_A");
break;
case 4:OutTextXY(Value_X+20+j*W,Value_Y+26+i*H,"Better_Z");
break;
}
break;
case 3:for (j=0;j<5;j++)
switch (j)
{
case 0:OutTextXY(Value_X+20+j*W,Value_Y+26+i*H,"Happy");
break;
case 1:OutTextXY(Value_X+20+j*W,Value_Y+26+i*H,"Smooth");
break;
case 2:OutTextXY(Value_X+20+j*W,Value_Y+26+i*H,"Humor");
break;
case 3:OutTextXY(Value_X+20+j*W,Value_Y+26+i*H,"Good_A");
break;
case 4:OutTextXY(Value_X+20+j*W,Value_Y+26+i*H,"Good_Z");
break;
}
break;
}
Up_Date_Value(W,H);
do {
XNextEvent(display,&report);
switch(report.type)
{
case MotionNotify:Ms_x=report.xmotion.x;Ms_y=report.xmotion.y;
Hi_light_Value(Ms_x,Ms_y);
break;
case ButtonPress:button=report.xbutton.button;
if (In_Value(Ms_x,Ms_y)==1 || button==Button2)
Fix_Value(button,W,H);
break;
case KeyPress:ks=XLookupKeysym(report,0);
switch(ks)
{
case XK_Return:ch='!';break;
case XK_Escape:ch='&';break;
}
break;
}
} while (!(ch=='!' || ch=='&'));
Del=-1;tail=content[now];Save(1,tail);Host=0;Column_Id=-10;Row_Id=-10;List();
}