home *** CD-ROM | disk | FTP | other *** search
- (***************************************
- * WG-VISION 1.0 DEMONSTRATION *
- ****************************************
- * *
- * Unit für das Demonstrationsprogramm *
- * *
- *--------------------------------------*
- * Achtung: Nur VGA ! *
- ****************************************
- * (c) 1993 Dipl.Phys. Mathias Scholz *
- ***************************************)
-
- {$I COMPILER.INC}
- {$F+,O+}
-
- UNIT DemoGr;
-
- INTERFACE
-
- USES WDecl,
- WViews,
- WDlg,
- WDriver,
- WEvent,
- WUtils,
- crt,
- dos,
- graph;
-
-
- type PDiagramm=^TDiagramm;
- TDiagramm=object(TWindow)
- constructor Init(x,y:integer);
- procedure SetPalette; virtual;
- procedure InitBackground; virtual;
- end;
-
- PFarn=^TFarn;
- TFarn=object(TWindow)
- xs,ys,k:integer;
- x,y,xn,yn,z,s:real;
- constructor Init(a,b:integer);
- procedure InitBackground; virtual;
- procedure HandleEvent; virtual;
- end;
-
- PMausDemo=^TMausDemo;
- TMausdemo=object(TDlgWindow)
- Taste : array[1..2] of TRect;
- MausImage:TRect;
- constructor Init(x,y:integer);
- procedure InitBackground; virtual;
- procedure HandleEvent; virtual;
- end;
-
- PDiaBgrd=^TDiaBgrd;
- TDiaBgrd=object(TBackground)
- procedure Draw;virtual;
- end;
-
- PFarnBgrd=^TFarnBgrd;
- TFarnBgrd=object(TBackground)
- procedure Draw;virtual;
- end;
-
- PMausDemoBgrd=^TMausDemoBgrd;
- TMausDemoBgrd=object(TBackground)
- procedure Draw;virtual;
- end;
-
-
- IMPLEMENTATION
-
- type tMausDemoData=record
- Schalter:string[19];
- end;
-
- var MausData:tMausDemoData;
-
- {Implementation TDiagramm}
-
- constructor TDiagramm.Init(x,y:integer);
- var R:TRect;
- begin
- R.Assign(x,y,x+210,y+200);
- TWindow.Init(R,'Demo Geschäftsgrafik',winDouble+winPanel+winMenu+winKey);
- end;
-
- procedure TDiagramm.SetPalette;
- begin
- Palette:=Pal[palRed];
- end;
-
- procedure TDiagramm.InitBackground;
- var R:TRect;
- begin
- R:=Frame^.Area;
- Bgrd:=new(PDiaBgrd, Init(R));
- List^.InsertItem(Bgrd);
- end;
-
- {Implementation TFarn}
-
- const ax:array[1..3,1..4] of real = ((0,0.2,-0.15,0.85),
- (0,-0.26,0.28,0.04),
- (0,0,0,0));
-
- ay:array[1..3,1..4] of real = ((0,0.23,0.26,-0.04),
- (0.16,0.22,0.24,0.85),
- (0,1.6,0.44,1.6));
-
- p:array[1..4] of real = (0.01,0.07,0.07,0.85);
-
-
- constructor TFarn.Init(a,b:integer);
- var R:TRect;
- begin
- R.Assign(a,b,a+210,b+200);
- TWindow.Init(R,'Demo fraktales Farnblatt',winDouble+winPanel+winMenu+winKey);
- end;
-
- procedure TFarn.HandleEvent;
- var R:TRect;
- begin
- TWindow.HandleEvent;
- R:=Frame^.Area;
- with R do
- begin
- z:=Random;
- k:=1;
- s:=p[1];
- while s<z do
- begin
- inc(k);
- s:=s+p[k];
- end;
- xn:=ax[1,k]*x+ax[2,k]*y+ax[3,k];
- yn:=ay[1,k]*x+ay[2,k]*y+ay[3,k];
- x:=xn; y:=yn;
- xs:=round(A.x+(Size.x div 2)*(x+8)*0.12);
- ys:=round(A.y+((Size.y-24) div 2)*(15-y)*0.1);
- PutPixel(xs,ys,LightGreen);
- end;
- end;
-
- procedure TFarn.InitBackground;
- var R:TRect;
- begin
- x:=0; y:=0; Randomize;
- R:=Frame^.Area;
- Bgrd:=new(PFarnBgrd, 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(x,y:integer);
- var RR:TRect;
- i:integer;
- begin
- RR.Assign(x,y,x+400,y+320);
- TDlgWindow.Init(RR,'Maus-Demo',winSingle);
- SetPushButton(268,197,80,22,'OK',cmCloseWindow);
- ChangePalColor(8,LightGray);
- SetGroupFrame(20,40,195,230,'Mauszeiger',ThickWidth);
- ChangePalColor(2,LightCyan);
- ChangePalColor(1,Red);
- SetRadioButton(40,70,' ~1~ Standard',1);
- ChangePalColor(2,LightCyan);
- ChangePalColor(3,Magenta);
- SetRadioButton(40,90,' ~2~ Fadenkreuz',1);
- ChangePalColor(2,LightCyan);
- ChangePalColor(3,Magenta);
- SetRadioButton(40,110,' ~3~ Sanduhr',1);
- ChangePalColor(2,LightCyan);
- ChangePalColor(3,Magenta);
- SetRadioButton(40,130,' ~4~ Vierfach-Pfeil',1);
- ChangePalColor(2,LightCyan);
- ChangePalColor(3,Magenta);
- SetRadioButton(40,150,' ~5~ Doppelpfeil',1);
- ChangePalColor(2,LightCyan);
- ChangePalColor(3,Magenta);
- SetRadioButton(40,170,' ~6~ DPfeil/schräg',1);
- ChangePalColor(2,LightCyan);
- ChangePalColor(3,Magenta);
- SetRadioButton(40,190,' ~7~ DPfeil/gerade',1);
- ChangePalColor(2,LightCyan);
- ChangePalColor(3,Magenta);
- SetRadioButton(40,210,' ~8~ DPfeil/schräg',1);
- ChangePalColor(2,LightCyan);
- ChangePalColor(3,Magenta);
- SetRadioButton(40,230,' ~9~ Kursorstrich',1);
- ChangePalColor(2,LightCyan);
- ChangePalColor(3,Magenta);
- SetRadioButton(40,250,'1~0~ Hand',1);
- ChangePalColor(2,LightCyan);
- ChangePalColor(3,Magenta);
- for i:=1 to 7 do
- begin
- SetPushButton(212+i*22,235,16,(8-i)*8,'',1000+i);
- ChangePalColor(7,LightGray);
- ChangePalColor(8,LightGray);
- SetPushButton(212+i*22,238+(8-i)*8,16,i*8,'',1007+i);
- ChangePalColor(7,LightGray);
- ChangePalColor(8,LightGray);
- end;
- with MausData do Schalter:='TGRrrrrrrrrrTTTTTTT';
- SetData(MausData);
- 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 TDiaBgrd}
-
- procedure TDiaBgrd.Draw;
- var dx,dy,xm,ym,r:integer;
- begin
- with Border do
- begin
- SetFillStyle(XHatchFill,DarkGray);
- Bar(A.x,A.y,B.x,B.y);
- SetColor(Blue);
- dx:=abs(B.x-A.x);
- dy:=abs(B.y-A.y);
- xm:=A.x+dx div 2;
- ym:=A.y+dy div 2;
- if dy>dx then r:=trunc(dx*3/8) else r:=trunc(dy*3/8);
- SetFillStyle(SolidFill,LightRed);
- PieSlice(xm,ym,0,45,r);
- SetFillStyle(SolidFill,LightGreen);
- PieSlice(xm,ym,45,140,r);
- SetFillStyle(SolidFill,LightMagenta);
- PieSlice(xm,ym,140,268,r);
- SetFillStyle(SolidFill,LightBlue);
- PieSlice(xm,ym,268,310,r);
- SetFillStyle(SolidFill,Yellow);
- PieSlice(xm,ym,310,360,r);
- end;
- end;
-
- {Implementation TFarnBgrd}
-
- procedure TFarnBgrd.Draw;
- begin
- with Border do
- begin
- SetFillStyle(XHatchFill,DarkGray);
- Bar(A.x,A.y,B.x,B.y);
- end;
- end;
-
- {Implementation TMausDemoBgrd}
-
- procedure TMausDemoBgrd.Draw;
- begin
- with Border do
- begin
- FBar(A.x,A.y,B.x,B.y,LightGray);
- SetFillStyle(HatchFill,LightGreen);
- Bar(B.x-145,A.y+40,B.x-35,A.y+180);
- RectAngle(B.x-145,A.y+40,B.x-35,A.y+180);
- D3Frame(B.x-150,a.y+35,B.x-30,A.y+185,Black,White);
- FBar(B.x-140,A.y+45,B.x-91,A.y+105,LightGray);
- FBar(B.x-85,A.y+45,B.x-40,A.y+105,LightGray);
- end;
- end;
-
-
- END.