home *** CD-ROM | disk | FTP | other *** search
- PROGRAM DXFView;
-
- {$N+,E+ } { 8087, Emulation }
-
- { Dieses Beispielprogramm erlaubt die Betrachtung von bis zu vier DXF-
- Grafiken in Fenstern und illustriert die Anwendung des deLite-Toolkits }
-
-
- USES Kernel, api, AcadDXF, firework, DOS, errors;
-
- CONST ProjektName = 'DXFVIEW'; { so heissen alle Dateien }
- DXFSuffix = '.DXF';
- IDFenster1 = 201; { Die IDs der Botschaften }
- IDFenster2 = 202;
- IDFenster3 = 203;
- IDFenster4 = 204;
- IDAlleFenster= 205;
- IDZoom = 206;
-
- TYPE Darstellung = (Einzel, Alle); { Bildschirmdarstellung }
-
- VAR LaunchResult : integer;
- MyEvent : EventTyp; { eine Botschaft }
- StillRunning : boolean;
- MyID : integer;
- MyMenu : hMenu; { Handle auf das Menü }
- Modus : Darstellung;
-
- AktivWindow : integer; { Rahmenfarbe akt. Fenster }
-
- ID1,ID2 : integer; { Die IDs der Fenster }
- ID3,ID4 : integer;
- AktivID : integer; { ID des aktiven Fensters }
-
- DXFFile1 : String; { Die DXF-Files der Fenster }
- DXFFile2 : String;
- DXFFile3 : String;
- DXFFile4 : String;
-
- MyRec : SearchRec; { temporär zum Suchen }
- DXFDirectory : String;
-
- GetInitFileResult : Boolean; { Ergebnis Platzhalter für die Funktionen
- des Init Files }
-
-
- procedure StartWindow; { wir stellen uns kurz vor }
- Var ScrX,ScrY : Integer;
- WindowX : Integer;
- WindowY : Integer;
- begin
- HideMouse;
- ScrX := Succ(GetMaxX) div 2;
- ScrY := Succ(GetMaxY) div 4;
- WindowX := (50 * FontX) div 2;
- WindowY := ( 6 * FontY);
- OpenWindow(ScrX-WindowX,ScrY,ScrX+WindowX,ScrY+WindowY );
- WriteWin('BrainLab DXFView Version 1.0 2/91',7,1,DialogText);
- WriteWin('Andreas Schumm & Frank Seidinger',9,3,DialogStat);
- ShowMouse;
- WaitConfirm;
- HideMouse;
- CloseWindow;
- ShowMouse;
- end;
-
-
- procedure Information; { wir stellen uns noch einmal vor }
- Var ScrX,ScrY : Integer;
- WindowX : Integer;
- WindowY : Integer;
- begin
- HideMouse;
- ScrX := Succ(GetMaxX) div 2;
- ScrY := Succ(GetMaxY) div 4;
- WindowX := (74 * FontX) div 2;
- WindowY := (13 * FontY);
- OpenWindow(ScrX-WindowX,ScrY,ScrX+WindowX,ScrY+WindowY );
- WriteWin('BrainLab DXFView Version 1.0 1/91',35,1,DialogText);
- WriteWin('Andreas Schumm & Frank Seidinger',37,3,DialogStat);
- WriteWin('erstellt mit deLite für Turbo-Pascal',35,8,DialogText);
- OpenWindow(ScrX-WindowX+5,ScrY+FontY div 2,
- ScrX-WindowX+33*FontX,ScrY+12*FontY+FontY div 2);
- Bar(0,0,PortMaxX,PortMaxY,0);
- Fireworks(6,200,PortMaxX,PortMaxY,15);
- CloseWindow;
- CloseWindow;
- ShowMouse;
- end;
-
- Function RemoveExt(Item: String):NameString; { Dateierweiterung entfernen }
- begin
- Delete(Item,Pos('.',Item),4);
- RemoveExt := Item;
- end;
-
-
-
- {$F+ }
-
- { Die Callback-Prozeduren für den Dateiauswahldialog }
-
- Procedure GetFirstDXF(Var Item: NameString; Var eol: boolean);
- begin
- MyRec.Name := '';
- FindFirst(DXFDirectory+'\'+'*'+DXFSuffix,ReadOnly,MyRec);
- If DosError = 0 then eol := false
- else eol := true;
- Item := RemoveExt(MyRec.Name);
- end;
-
-
- Procedure GetNextDXF(Var Item: NameString; Var eol: boolean);
- begin
- FindNext(MyRec);
- If DosError = 0 then eol := false
- else eol := true;
- Item := RemoveExt(MyRec.Name);
- end;
-
-
- {$F- }
-
-
- procedure DoQuit; { Programm ggf. beenden }
- Var YNRsc: YesNoDialog;
- begin
- YNRsc.text := 'Programm wirklich beenden ?';
- YNRsc.xorg := 50;
- YNRsc.yorg := 50;
- YNRsc.topic := 'Programm beenden';
- IF DoYesNoDialog(YNRsc) then StillRunning := false;
- end;
-
- procedure DXFDir; { Arbeitsverzeichnis ändern }
- Var MyRsc : SmallDialog;
- Fname : DlgStr;
- OldDir: String;
- ready : boolean;
- result: DlgSet;
- begin
- ready := false;
- MyRsc.text1 := 'DXF-Verzeichnis wechseln:';
- MyRsc.text2 := '';
- MyRsc.xorg := 50;
- MyRsc.yorg := 120;
- MyRsc.len := 60;
- MyRsc.topic := 'DXF-Verzeichnis';
- MyRsc.deflt := DXFDirectory;
- GetDir(0,OldDir);
- InitSmallDlg(MyRsc);
- repeat
- result := DoSmallDlg(MyRsc, fname);
- if result = success then
- begin
- (*$i- *)
- ChDir(Fname);
- (*$i+ *)
- if ioresult = 0 then
- Begin
- ready := true;
- DXFDirectory := Fname;
- UpString(DXFDirectory);
- End
- else
- ErrWindow(MyRsc.xorg+10,MyRsc.yorg+32,'Falsche Pfadangabe');
- ChDir(OldDIr);
- end;
- until ready or (result = escaped);
- CloseSmallDlg;
- end;
-
-
- { ******************************* }
- { Die Fenster-Empfangsprozeduren }
- { ******************************* }
-
- {$F+ }
-
- Procedure Fenster1(MyMessage: EventTyp);
- begin
- If ((MyMessage.Class = LeMouse) and (MyMessage.Attrib = LeftButtonPressed))
- or (MyMessage.Class = Menu) then
- begin
- CheckMenuItem(MyMenu,AktivID,MF_UNCHECKED);
- Case AktivID of { aktives Fenster umrahmen }
- IDFenster1: FrameSubApplication(ID1,7);
- IDFenster2: FrameSubApplication(ID2,7);
- IDFenster3: FrameSubApplication(ID3,7);
- IDFenster4: FrameSubApplication(ID4,7);
- end;
- AktivID := IDFenster1;
- FrameSubApplication(ID1,AktivWindow);
- CheckMenuItem(MyMenu,AktivID,MF_CHECKED);
- end;
- Case MyMessage.Class of
- DoRedraw : begin
- ClearWindow;
- if DXFFile1 <> '' then
- if InterpretDXF(DXFFile1) <> ok then
- ErrWindow(30,30,'DXF kann nicht interpretiert werden.');
- end;
- end;
- end;
-
-
- Procedure Fenster2(MyMessage: EventTyp);
- begin
- If ((MyMessage.Class = LeMouse) and (MyMessage.Attrib = LeftButtonPressed))
- or (MyMessage.Class = Menu) then
- begin
- CheckMenuItem(MyMenu,AktivID,MF_UNCHECKED);
- Case AktivID of { aktives Fenster umrahmen }
- IDFenster1: FrameSubApplication(ID1,7);
- IDFenster2: FrameSubApplication(ID2,7);
- IDFenster3: FrameSubApplication(ID3,7);
- IDFenster4: FrameSubApplication(ID4,7);
- end;
- AktivID := IDFenster2;
- FrameSubApplication(ID2,AktivWindow);
- CheckMenuItem(MyMenu,AktivID,MF_CHECKED);
- end;
- Case MyMessage.Class of
- DoRedraw : begin
- ClearWindow;
- if DXFFile2 <> '' then
- if InterpretDXF(DXFFile2) <> ok then
- ErrWindow(30,30,'DXF kann nicht interpretiert werden.');
- end;
- end;
- end;
-
-
- Procedure Fenster3(MyMessage: EventTyp);
- begin
- If ((MyMessage.Class = LeMouse) and (MyMessage.Attrib = LeftButtonPressed))
- or (MyMessage.Class = Menu) then
- begin
- CheckMenuItem(MyMenu,AktivID,MF_UNCHECKED);
- Case AktivID of { aktives Fenster umrahmen }
- IDFenster1: FrameSubApplication(ID1,7);
- IDFenster2: FrameSubApplication(ID2,7);
- IDFenster3: FrameSubApplication(ID3,7);
- IDFenster4: FrameSubApplication(ID4,7);
- end;
- AktivID := IDFenster3;
- FrameSubApplication(ID3,AktivWindow);
- CheckMenuItem(MyMenu,AktivID,MF_CHECKED);
- end;
- Case MyMessage.Class of
- DoRedraw : begin
- ClearWindow;
- if DXFFile3 <> '' then
- if InterpretDXF(DXFFile3) <> ok then
- ErrWindow(30,30,'DXF kann nicht interpretiert werden.');
- end;
- end;
- end;
-
-
- Procedure Fenster4(MyMessage: EventTyp);
- begin
- If ((MyMessage.Class = LeMouse) and (MyMessage.Attrib = LeftButtonPressed))
- or (MyMessage.Class = Menu) then
- begin
- CheckMenuItem(MyMenu,AktivID,MF_UNCHECKED);
- Case AktivID of { aktives Fenster umrahmen }
- IDFenster1: FrameSubApplication(ID1,7);
- IDFenster2: FrameSubApplication(ID2,7);
- IDFenster3: FrameSubApplication(ID3,7);
- IDFenster4: FrameSubApplication(ID4,7);
- end;
- AktivID := IDFenster4;
- FrameSubApplication(ID4,AktivWindow);
- CheckMenuItem(MyMenu,AktivID,MF_CHECKED);
- end;
- Case MyMessage.Class of
- DoRedraw : begin
- ClearWindow;
- if DXFFile4 <> '' then
- if InterpretDXF(DXFFile4) <> ok then
- ErrWindow(30,30,'DXF kann nicht interpretiert werden.');
- end;
- end;
- end;
-
-
- Procedure Vollbild; { Zeigt ein Fenster ganz gross ! }
- Var MSG : EventTyp;
- begin
- CloseSubApplication(ID1); { Die vier Fenster schliessen }
- CloseSubApplication(ID2);
- CloseSubApplication(ID3);
- CloseSubApplication(ID4);
- ActivateApplication(MyID); { und die Hauptapplikation reaktivieren }
- SetTheViewPort(MyID);
- ClearViewPort; { Bildschirm löschen }
- Msg.Class := DoRedraw;
- Case AktivID of { dann ein Redraw }
- IDFenster1 : Fenster1(Msg);
- IDFenster2 : Fenster2(Msg);
- IDFenster3 : Fenster3(Msg);
- IDFenster4 : Fenster4(Msg);
- end;
- Modus := Einzel;
- end;
-
-
- Procedure VierFenster; { zeigt vier kleine Fenster ! }
- Var ThePort: ViewPortType;
- XSize : integer;
- YSize : integer;
- XOrg : integer;
- YOrg : integer;
- XEnd : integer;
- YEnd : integer;
- Msg : EventTyp;
- begin
- ClearViewPort; { Fenster löschen }
- GetViewSettings(ThePort);
- With ThePort Do
- begin
- XSize := (x2-x1) div 2 - 2; { Ausdehnung in x-Richtung berechnen }
- YSize := (y2-y1) div 2 - 4; { dito in y-Richtung }
- XOrg := x1;
- YOrg := y1 + 3;
- XEND := x2;
- YEnd := y2;
- end;
-
- ID1 := OpenSubApplication(Fenster1,0,'Fenster 1',
- XOrg,YOrg,Xorg+XSize,YOrg+YSize);
-
- ID2 := OpenSubApplication(Fenster2,0,'Fenster 2',
- XEND-XSize,YOrg,XEND,YOrg+YSize);
-
- ID3 := OpenSubApplication(Fenster3,0,'Fenster 3',
- XOrg,YEnd-YSize,Xorg+XSize,YEnd);
-
- ID4 := OpenSubApplication(Fenster4,0,'Fenster 4',
- XEnd-XSize,YEnd-YSize,XEnd,YEnd);
-
- SuspendApplication(MyID); { Hauptfenster deaktivieren }
-
- Case AktivID of { aktives Fenster umrahmen }
- IDFenster1: FrameSubApplication(ID1,AktivWindow);
- IDFenster2: FrameSubApplication(ID2,AktivWindow);
- IDFenster3: FrameSubApplication(ID3,AktivWindow);
- IDFenster4: FrameSubApplication(ID4,AktivWindow);
- end;
-
- MSG.Class := DoRedraw;
-
- PostMessage(MSG, ID1); { alle Fenster neu zeichnen }
- PostMessage(MSG, ID2);
- PostMessage(MSG, ID3);
- PostMessage(MSG, ID4);
-
- Modus := Alle;
- end;
-
-
- procedure NewWindow;
- Var MyMsg : EventTyp;
- begin
- MyMsg.Class := DoRedraw;
- Case AktivID of
- IDFenster1 : begin
- DXFFile1 := '';
- SetTheViewPort(ID1);
- Fenster1(MyMsg);
- end;
- IDFenster2 : begin
- DXFFile2 := '';
- SetTheViewPort(ID2);
- Fenster2(MyMsg);
- end;
- IDFenster3 : begin
- DXFFile3 := '';
- SetTheViewPort(ID3);
- Fenster3(MyMsg);
- end;
- IDFenster4 : begin
- DXFFile4 := '';
- SetTheViewPort(ID4);
- Fenster4(MyMsg);
- end;
- end; { Case }
- end;
-
-
- procedure LoadDXF;
- Var MyRsc : ListDialog;
- LaList : TheList;
- LFname : NameString;
- result : DlgSet;
- TheString:string;
- MyMsg : EventTyp;
- begin
- MyRsc.text := 'Datei auswählen:';
- MyRsc.ItemWidth := 12;
- MyRsc.ListLength := 4;
- MyRsc.xorg := 80;
- MyRsc.yorg := 60;
- MyRsc.topic := 'DXF laden';
- MyRsc.GetFirst := GetFirstDXF;
- MyRsc.GetNext := GetNextDXF;
- result := empty;
- new(LaList);
- InitListDialog(MyRsc,LaList);
- result := DoListDialog(MyRsc,LFname,LaList);
- CloseListDialog;
- dispose(LaList);
- if result = success then
- begin
- MyMsg.Class := DoRedraw;
- Case AktivID of
- IDFenster1 : begin
- DXFFile1 := DXFDirectory + '\' + LFname;
- SetTheViewPort(ID1);
- Fenster1(MyMsg);
- end;
- IDFenster2 : begin
- DXFFile2 := DXFDirectory + '\' + LFname;
- SetTheViewPort(ID2);
- Fenster2(MyMsg);
- end;
- IDFenster3 : begin
- DXFFile3 := DXFDirectory + '\' + LFname;
- SetTheViewPort(ID3);
- Fenster3(MyMsg);
- end;
- IDFenster4 : begin
- DXFFile4 := DXFDirectory + '\' + LFname;
- SetTheViewPort(ID4);
- Fenster4(MyMsg);
- end;
- end; { Case }
- end;
- end;
-
-
- Procedure HandleMsg(MyMessage: EventTyp);
- { Die Hauptempfangsprozedur behandelt die Menü-Botschaften }
- Begin
- With MyMessage Do
- Case Class Of
- Menu : begin
- Case x of
- 0 : DoQuit;
-
- 101 : LoadDXF;
- 102 : NewWindow;
- 103 : DXFDir;
-
- 205 : begin
- ReplaceMenuItem(MyMenu,
- 205,
- '&Alle Fenster',
- 206,'A');
- Vollbild;
- end;
-
- 206 : begin
- ReplaceMenuItem(MyMenu,
- 206,
- '&Zoom',
- 205,'Z');
- VierFenster;
- end;
-
- IDFenster1: begin
- Fenster1(MyMessage);
- MyMessage.Class := DoRedraw;
- If Modus = Einzel then
- Fenster1(MyMessage);
- end;
-
- IDFenster2: begin
- Fenster2(MyMessage);
- MyMessage.Class := DoRedraw;
- If Modus = Einzel then
- Fenster2(MyMessage);
- end;
-
- IDFenster3: begin
- Fenster3(MyMessage);
- MyMessage.Class := DoRedraw;
- If Modus = Einzel then
- Fenster3(MyMessage);
- end;
-
- IDFenster4: begin
- Fenster4(MyMessage);
- MyMessage.Class := DoRedraw;
- If Modus = Einzel then
- Fenster4(MyMessage);
- end;
-
- 399 : Information;
-
- end;
- end;
- end;
- End;
-
-
- {$F- }
-
-
- Begin
- StillRunning := true;
- Modus := Alle; { 4 Fenster sichtbar }
- AktivID := IDFenster1; { Fenster 1 ist aktiv }
-
- DXFFile1 := ''; { Keine DXF-Dateien zugewiesen }
- DXFFile2 := '';
- DXFFile3 := '';
- DXFFile4 := '';
-
- LaunchResult := OpenMainApplication(HandleMsg, { deLite starten }
- 0,
- ProjektName);
- MyID := GetMainID;
- If LaunchResult = 0 then { erfolgreich gestartet }
- begin
- GetInitFileResult := GetInitFileName('PATHS','DXFDir',DXFDirectory);
- InitDXF; { DXF-Interpreter initialisieren }
- AktivWindow := 15; { Farbe des aktiven Fensters }
- MyMenu := GetMenu;
- DisableMoveDetect; { keine Bewegungen melden }
- StartWindow; { Begrüssung anzeigen }
- VierFenster;
- while StillRunning Do
- begin
- GetEvent(MyEvent); { Botschaften holen und weiterleiten }
- DispatchMessage(MyEvent);
- end;
- CloseMainApplication; { deLite schliessen }
- Writeln('Programm beendet.');
- end
- Else
- begin
- Writeln('Programm kann nicht gestartet werden. Fehler: ',LaunchResult);
- Writeln(ErrorName(LaunchResult));
- end;
- End.