·µ»Ø
{***************************************************************}
{***               FVision Unit Version1.0                   ***}
{***                    À¶ÂìÒϹ¤×÷ÊÒ                         ***}
{***************************************************************}
{***                  Éù¿¨ÒôÁ¿ÉèÖõ¥Ôª                       ***}
{***************************************************************}
{$O+,F+,X+,I-,S-}
Unit SbVol;
Interface
Uses
  FEvent,FView,FControl,FDsp,FTool;

Type
  PVolWin=^TVolWin;
  TVolWin=Object(TWindow)
    Scro:Array[0..10] of PScrollBar;
    TempVol:Array[0..10] of Byte;
    VolText:Array[0..10] of PStaticText;
    Vol:VolType;
    Constructor Init;
    Procedure HandleEvent(Var Event:TEvent);Virtual;
    Procedure SetData;Virtual;
  end;



Implementation
Constructor TVolWin.Init;
Var
  R:TRect;
  i:Integer;
begin
  AssignRect(R,0,0,300,250);
  Inherited Init(R,'ÉèÖûìÒôÆ÷',True);
  GetDspBasePort;
  GetVol(Vol);
  TempVol[0]:=Vol.Master shr 4;
  TempVol[1]:=Vol.Master and $F;
  TempVol[2]:=Vol.Voice shr 4;
  TempVol[3]:=Vol.Voice and $F;
  TempVol[4]:=Vol.Music shr 4;
  TempVol[5]:=Vol.Music and $F;
  TempVol[6]:=Vol.Line shr 4;
  TempVol[7]:=Vol.Line and $F;
  TempVol[8]:=Vol.CD shr 4;
  TempVol[9]:=Vol.CD and $F;
  TempVol[10]:=Vol.Mic and $F;
  AssignRect(R,90,35,170,13);
  Insert(New(PStaticText,Init(stDefault,10,R.a.y+6,'MasterÄÂL',4)));
  Scro[0]:=New(PScrollBar,Init(SbHor,R,TempVol[0]/15));
  Inc(R.a.y,16);
  Insert(New(PStaticText,Init(stDefault,10,R.a.y-1,'       ÀR',4)));
  Scro[1]:=New(PScrollBar,Init(SbHor,R,TempVol[1]/15));
  Inc(R.a.y,16);
  Insert(New(PStaticText,Init(stDefault,10,R.a.y+6,'VoiceÄÄÂL',4)));
  Scro[2]:=New(PScrollBar,Init(SbHor,R,TempVol[2]/15));
  Inc(R.a.y,16);
  Insert(New(PStaticText,Init(stDefault,10,R.a.y-1,'       ÀR',4)));
  Scro[3]:=New(PScrollBar,Init(SbHor,R,TempVol[3]/15));
  Inc(R.a.y,16);
  Insert(New(PStaticText,Init(stDefault,10,R.a.y+6,'MusicÄÄÂL',4)));
  Scro[4]:=New(PScrollBar,Init(SbHor,R,TempVol[4]/15));
  Inc(R.a.y,16);
  Insert(New(PStaticText,Init(stDefault,10,R.a.y-1,'       ÀR',4)));
  Scro[5]:=New(PScrollBar,Init(SbHor,R,TempVol[5]/15));
  Inc(R.a.y,16);
  Insert(New(PStaticText,Init(stDefault,10,R.a.y+6,'LineÄÄÄÂL',4)));
  Scro[6]:=New(PScrollBar,Init(SbHor,R,TempVol[6]/15));
  Inc(R.a.y,16);
  Insert(New(PStaticText,Init(stDefault,10,R.a.y-1,'       ÀR',4)));
  Scro[7]:=New(PScrollBar,Init(SbHor,R,TempVol[7]/15));
  Inc(R.a.y,16);
  Insert(New(PStaticText,Init(stDefault,10,R.a.y+6,'CDÄÄÄÄÄÂL',4)));
  Scro[8]:=New(PScrollBar,Init(SbHor,R,TempVol[8]/15));
  Inc(R.a.y,16);
  Insert(New(PStaticText,Init(stDefault,10,R.a.y-1,'       ÀR',4)));
  Scro[9]:=New(PScrollBar,Init(SbHor,R,TempVol[9]/15));
  Inc(R.a.y,16);
  Insert(New(PStaticText,Init(stDefault,10,R.a.y,'MicÄÄÄÄÄÄ',4)));
  Scro[10]:=New(PScrollBar,Init(SbHor,R,TempVol[10]/15));

  for i:=0 to 10 do Insert(Scro[i]);
  for i:=0 to 10 do Scro[i]^.Option:=Scro[i]^.Option and (not opCantSelect);
  for i:=0 to 10 do
  begin
    VolText[i]:=New(PStaticText,Init(stDefault,270,40+i*15,Intstr(TempVol[i]),0));
    Insert(VolText[i]);
  end;
  Insert(New(PButton,Init(40 ,220,100,240,'~O~K',kbAlto,cmOk)));
  Insert(New(PButton,Init(120 ,220,180,240,'~C~ancel',kbAltc,cmCancel)));
  Insert(New(PButton,Init(200 ,220,260,240,'~H~elp',kbAlth,cmHelp)));
  Next;
  Center;
end;

Procedure TVolWin.HandleEvent;
var
  i:Integer;
  Temp:Byte;
begin
  TWindow.HandleEvent(Event);
  case Event.What of
  evCommand:case Event.Command of
            cmLeft:for i:=0 to 10 do
                   if Event.InfoPtr=Scro[i] then
                   if TempVol[i]>0 then
                   begin
                     Dec(TempVol[i]);
                     Scro[i]^.NewPos(TempVol[i]/15);
                     VolText[i]^.Modify(IntStr(TempVol[i]));
                   end;
            cmRight:for i:=0 to 10 do
                   if Event.InfoPtr=Scro[i] then
                   if TempVol[i]<15 then
                   begin
                     Inc(TempVol[i]);
                     Scro[i]^.NewPos(TempVol[i]/15);
                     VolText[i]^.Modify(IntStr(TempVol[i]));
                   end;
            cmInterHor:for i:=0 to 10 do
                   if Event.Index=Scro[i] then
                   begin
                     Temp:=Round(Event.InfoReal*15);
                     if TempVol[i]<>Temp then
                     begin
                       TempVol[i]:=Temp;
                       Scro[i]^.NewPos(TempVol[i]/15);
                       VolText[i]^.Modify(IntStr(TempVol[i]));
                     end;
                   end;
            else Exit;
            end;
  else Exit;
  end;
end;

Procedure TVolWin.SetData;
begin
  Vol.Master:=(TempVol[0] shl 4) or TempVol[1];
  Vol.Voice:=(TempVol[2] shl 4) or TempVol[3];
  Vol.Music:=(TempVol[4] shl 4) or TempVol[5];
  Vol.Line:=(TempVol[6] shl 4) or TempVol[7];
  Vol.CD:=(TempVol[8] shl 4) or TempVol[9];
  Vol.Mic:=(Vol.Mic and $F0) or TempVol[10];
  SetVol(Vol);
end;

end.