home *** CD-ROM | disk | FTP | other *** search
- {$A+,B-,D-,E-,F+,I-,L-,N-,O+,R-,S-,V-}
- UNIT GInfo;
-
- INTERFACE
-
- USES GDecl,
- GViews,
- GDlg,
- GDrivers,
- GEvent,
- GUtils,
- crt,
- Graph;
-
-
- type PMemoryInfo=^TMemoryInfo;
- TMemoryInfo=object(TWindow)
- procedure SetPalette; virtual;
- procedure InitBackground; virtual;
- end;
-
- PMausDemo=^TMausDemo;
- TMausdemo=object(TDlgWindow)
- Taste : array[1..2] of TRect;
- MausImage:TRect;
- constructor Init(var Bounds:TRect;ATitle:str80;AType:byte);
- procedure InitBackground; virtual;
- procedure HandleEvent; virtual;
- end;
-
- PJoystickDemo=^TJoystickDemo;
- TJoystickdemo=object(TDlgWindow)
- OsziArea:TRect;
- Winkel :real;
- ss,Ausl :word;
- p :pointer;
- constructor Init(var Bounds:TRect;ATitle:str80;AType:byte);
- destructor Done; virtual;
- procedure InitBackground; virtual;
- procedure HandleEvent; virtual;
- end;
-
- PMemoryInfoBgrd=^TMemoryInfoBgrd;
- TMemoryInfoBgrd=object(TBackground)
- procedure Draw;virtual;
- end;
-
- PMausDemoBgrd=^TMausDemoBgrd;
- TMausDemoBgrd=object(TBackground)
- procedure Draw;virtual;
- end;
-
- PJoystickDemoBgrd=^TJoystickDemoBgrd;
- TJoystickDemoBgrd=object(TBackground)
- procedure Draw;virtual;
- end;
-
-
- tMausDemoData=record
- Schalter:string[19];
- end;
-
- var MausData:tMausDemoData;
-
- IMPLEMENTATION
-
-
- {Implementation TMemoryInfo}
-
- procedure TMemoryInfo.SetPalette;
- begin
- Palette:=Pal[palGreen];
- end;
-
- procedure TMemoryInfo.InitBackground;
- var R:TRect;
- begin
- R:=Frame^.Area;
- Bgrd:=new(PMemoryInfoBgrd, Init(R));
- List^.InsertItem(Bgrd);
- end;
-
- {Implementation TMausDemo}
-
- procedure TMausDemo.InitBackground;
- var RR:TRect;
- begin
- RR:=Frame^.Area;
- Bgrd:=new(PMausDemoBgrd, Init(RR));
- List^.InsertItem(Bgrd);
- end;
-
- constructor TMausDemo.Init(var Bounds:TRect;ATitle:str80;AType:byte);
- var RR:TRect;
- begin
- TDlgWindow.Init(Bounds,ATitle,AType);
- RR:=Frame^.Area;
- with RR do
- begin
- Taste[1].Assign(B.x-140,A.y+45,B.x-91,A.y+105);
- Taste[2].Assign(B.x-85,A.y+45,B.x-40,A.y+105);
- MausImage.Assign(B.x-145,A.y+40,B.x-35,A.y+180);
- end;
- end;
-
- procedure TMausDemo.HandleEvent;
- var ct:byte;
- RR:TRect;
- begin
- TDlgWindow.HandleEvent;
- RR:=Frame^.Area;
- if MausImage.Contains(Mouse.Position) then
- begin
- ct:=pos('R',MausData.Schalter)-2;
- if Mouse.CursorTyp<>ct then Mouse.SetCursorTyp(ct);
- end
- else if Mouse.CursorTyp<>1 then Mouse.SetCursorTyp(1);
- with RR do
- if Taste[1].Contains(Mouse.Position) and Mouse.LButtonKlick then
- begin
- Mouse.HideMouse;
- SetFillStyle(SolidFill,LightRed);
- Bar(B.x-140,A.y+45,B.x-91,A.y+105);
- Mouse.ShowMouse;
- end
- else if Mouse.LButtonRel then
- begin
- Mouse.HideMouse;
- SetFillStyle(SolidFill,LightGray);
- Bar(B.x-140,A.y+45,B.x-91,A.y+105);
- Mouse.ShowMouse;
- end;
- with RR do
- if Taste[2].Contains(Mouse.Position) and Mouse.RButtonKlick then
- begin
- Mouse.HideMouse;
- SetFillStyle(SolidFill,LightRed);
- Bar(B.x-85,A.y+45,B.x-40,A.y+105);
- Mouse.ShowMouse;
- end
- else if Mouse.RButtonRel then
- begin
- Mouse.HideMouse;
- SetFillStyle(SolidFill,LightGray);
- Bar(B.x-85,A.y+45,B.x-40,A.y+105);
- Mouse.ShowMouse;
- end;
- if Event.Command>1000 then
- begin
- case Event.Command of
- 1001 : sound(262);
- 1002 : sound(294);
- 1003 : sound(330);
- 1004 : sound(349);
- 1005 : sound(392);
- 1006 : sound(440);
- 1007 : sound(494);
- 1008 : sound(523);
- 1009 : sound(587);
- 1010 : sound(659);
- 1011 : sound(698);
- 1012 : sound(784);
- 1013 : sound(880);
- 1014 : sound(988);
- end; {case}
- delay(200);
- NoSound;
- Event.Command:=cmNothing;
- end;
- end;
-
- {Implementation TJoystickDemo}
-
- constructor TJoyStickDemo.Init(var Bounds:TRect;ATitle:str80;AType:byte);
- begin
- TDlgWindow.Init(Bounds,ATitle,AType);
- OsziArea:=Frame^.Area;
- with OsziArea do ss:=ImageSize(A.x+50,A.y+150,B.x-120,B.y-50);
- GetMem(p,ss);
- Winkel:=0; Ausl:=0;
- Mouse.HideMouse;
- end;
-
- destructor TJoyStickDemo.Done;
- begin
- Mouse.ShowMouse;
- FreeMem(p,ss);
- TDlgWindow.Done;
- end;
-
- procedure TJoystickDemo.InitBackground;
- var RR:TRect;
- begin
- RR:=Frame^.Area;
- Bgrd:=new(PJoystickDemoBgrd, Init(RR));
- List^.InsertItem(Bgrd);
- end;
-
- procedure TJoystickDemo.HandleEvent;
- var ww:real;
- aa:word;
- begin
- TDlgWindow.HandleEvent;
- with OsziArea do
- begin
- Joy.JoyStickHandle;
- ww:=(Joy.Degree+90)*Pi/180;
- aa:=Joy.Turn;
- SetColor(White);
- line(B.x-120,A.y+150,B.x-120,B.y-50);
- SetWriteMode(XORPut);
- SetColor(LightMagenta);
- line(B.x-120,A.y+204,B.x-120,A.y+204+trunc(Joy.Y) div 3);
- SetColor(Cyan);
- line(B.x-120,A.y+205,B.x-120,A.y+205+trunc(Joy.X) div 3);
- SetWriteMode(CopyPut);
- GetImage(A.x+51,A.y+150,B.x-120,B.y-50,p^);
- PutImage(A.x+50,A.y+150,p^,NormalPut);
- SetLineStyle(SolidLn,0,ThickWidth);
- SetColor(LightCyan);
- line(A.x+320,A.y+70,A.x+320+trunc(40*sin(Winkel)),
- A.y+70+trunc(40*cos((Winkel))));
- SetColor(Black);
- line(A.x+320,A.y+70,A.x+320+trunc(40*sin(ww)),
- A.y+70+trunc(40*cos((ww))));
- SetLineStyle(SolidLn,0,NormWidth);
- Winkel:=ww;
- if aa<>Ausl then
- begin
- SetFillStyle(SolidFill,Blue);
- Bar(A.x+125,A.y+120,A.x+155,A.y+10);
- SetFillStyle(SolidFill,Yellow); SetColor(LightGray);
- Bar3D(A.x+125,A.y+120,A.x+145,A.y+120-(aa div 2),5,TopOn);
- end;
- Ausl:=aa;
- SetFillStyle(SolidFill,Yellow);
- if Joy.PushOne then
- begin
- FillEllipse(A.x+170,A.y+115,5,5);
- Beep(440);
- SetFillStyle(SolidFill,Red);
- FillEllipse(A.x+170,A.y+115,5,5);
- end;
- if Joy.PushTwo then
- begin
- FillEllipse(A.x+170,A.y+85,5,5);
- Beep(440);
- SetFillStyle(SolidFill,Red);
- FillEllipse(A.x+170,A.y+85,5,5);
- end;
- end;
- end;
-
- {Implementation TMemoryInfoBgrd}
-
- procedure TMemoryInfoBgrd.Draw;
- var z:string;
- EMS:PEMS;
- HD:PHardDisk;
- begin
- with Border do
- begin
- SetFillStyle(SolidFill,GetPalColor(7));
- Bar(A.x,A.y,B.x,B.y);
- str(MemAvail:8,z);
- SetColor(Red);
- OutTextXY(A.x+10,A.y+25,'Hauptspeicher');
- OutTextXY(A.x+10,A.y+100,'Expanded Memory');
- OutTextXY(A.x+10,A.y+160,'Festplatte C');
- SetColor(Blue);
- OutTextXY(A.x+10,A.y+45,'Freier RAM (Heap) : '+z+' Byte');
- str(MaxAvail:8,z);
- OutTextXY(A.x+10,A.y+65,'Größter zusammenhängender');
- OutTextXY(A.x+10,A.y+75,'freier Speicherblock : '+z+' Byte');
- EMS:=new(PEMS, Init(Border));
- str(EMS^.FreeMemory:8,z);
- OutTextXY(A.x+10,A.y+120,'verfügbarer Speicher : '+z+' Byte');
- str(EMS^.FreeMemory div 16384:8,z);
- OutTextXY(A.x+10,A.y+140,'verfügbare Seiten : '+z+' Seiten');
- dispose(EMS, Done);
- HD:=new(PHardDisk, Init(Border));
- str(HD^.FreeMemory:8,z);
- OutTextXY(A.x+10,A.y+180,'verfügbare Plattenkapazität : '+z+' Byte');
- dispose(HD, Done);
- end;
- end;
-
- {Implementation TMausDemoBgrd}
-
- procedure TMausDemoBgrd.Draw;
- begin
- with Border do
- begin
- SetFillStyle(SolidFill,Yellow);
- Bar(A.x,A.y,B.x,B.y);
- SetFillStyle(HatchFill,LightGray);
- Bar(B.x-145,A.y+40,B.x-35,A.y+180);
- SetFillStyle(SolidFill,LightGray);
- Bar(B.x-140,A.y+45,B.x-91,A.y+105);
- Bar(B.x-85,A.y+45,B.x-40,A.y+105);
- end;
- end;
-
- {Implementation TJoyStickDemoBgrd}
-
- procedure TJoyStickDemoBgrd.Draw;
- var i:integer;
- begin
- with Border do
- begin
- SetFillStyle(SolidFill,Blue);
- Bar(A.x,A.y,B.x,B.y);
- SetFillStyle(SolidFill,White);
- Bar(A.x+50,A.y+150,B.x-120,B.y-50);
- SetFillStyle(SolidFill,Red);
- Bar(A.x+20,B.y-35,A.x+50,B.y-15);
- FillEllipse(A.x+170,A.y+115,5,5);
- FillEllipse(A.x+170,A.y+85,5,5);
- SetFillStyle(SolidFill,Green);
- Bar(A.x+150,B.y-35,A.x+180,B.y-15);
- SetColor(Red);
- line(A.x+50,A.y+205,B.x-120,A.y+205);
- SetColor(White);
- OutTextXY(A.x+20,A.y+125,'Auslenkung');
- for i:=0 to 10 do
- line(A.x+40,A.y+155+i*10,A.x+45,A.y+155+i*10);
- RectAngle(A.x+20,B.y-35,A.x+50,B.y-15);
- OutTextXY(A.x+60,B.y-30,'x-Richtung');
- RectAngle(A.x+150,B.y-35,A.x+180,B.y-15);
- OutTextXY(A.x+190,B.y-30,'y-Richtung');
- SetFillStyle(SolidFill,LightCyan);
- FillEllipse(A.x+320,A.y+70,45,45);
- for i:=1 to 8 do
- line(A.x+320+trunc(50*sin(i*pi/4)),A.y+70+trunc(50*cos(i*pi/4)),
- A.x+320+trunc(60*sin(i*pi/4)),A.y+70+trunc(60*cos(i*pi/4)));
- OutTextXY(A.x+170,A.y+20,'Horizontale');
- OutTextXY(A.x+170,A.y+30,'Auslenkung');
- end;
- end;
-
-
- END.