home *** CD-ROM | disk | FTP | other *** search
- (* ------------------------------------------------------ *)
- (* SPOOLTST.PAS *)
- (* Drucker-Spooler für Turbo-Vision *)
- (* (c) 1993 Jochen Schäfer & DMV-Verlag *)
- (* ------------------------------------------------------ *)
- PROGRAM SpoolTest;
- {$O-,R-,S-,X-,G-,D-}
-
- USES Objects, App, Drivers, Views, Menus, StdDlg, Dos,
- Spooler;
-
- CONST
- cmSpooler = 100;
- cmAktiv = 101;
- cmPassiv = 102;
- cmDelete = 103;
- cmList = 104;
-
- TYPE
- pMainApp = ^tMainApp;
- tMainApp = OBJECT (tApplication)
- CONSTRUCTOR Init;
- DESTRUCTOR Done; VIRTUAL;
- PROCEDURE HandleEvent(VAR Event : tEvent); VIRTUAL;
- PROCEDURE InitMenuBar; VIRTUAL;
- PROCEDURE InitStatusLine; VIRTUAL;
- PROCEDURE Idle; VIRTUAL;
- END;
-
- VAR
- MainProc : tMainApp;
- Drucker : PSpooler;
- Path_Spooler : ^PathStr;
-
- PROCEDURE FileOpen(VAR WildCard : PathStr);
- VAR
- D : pFileDialog;
- x : INTEGER;
- BEGIN
- D := New(pFileDialog, Init(WildCard, 'Datei laden',
- '~N~ame', fdOpenButton+fdHelpButton, 100));
- D^.helpCtx := hcNoContext;
- IF Application^.ValidView(D) <> NIL THEN BEGIN
- x := Desktop^.ExecView(D);
- IF x <> cmCancel THEN
- D^.GetFileName(WildCard)
- ELSE
- WildCard := '';
- Dispose(D, Done);
- END;
- END;
-
- CONSTRUCTOR tMainApp.Init;
- BEGIN
- tApplication.Init;
- Drucker := New(pSpooler, Init(5, 'LPT1'));
- END;
-
- DESTRUCTOR tMainApp.Done;
- BEGIN
- Dispose(Drucker, Done);
- tApplication.Done;
- END;
-
- PROCEDURE tMainApp.Idle;
- BEGIN
- tApplication.Idle;
- IF Drucker^.Count > 0 THEN Drucker^.Update;
- (* Wenn Dateien in Liste sind,
- nächstes Zeichen drucken *)
- END;
-
- PROCEDURE tMainApp.InitMenuBar;
- VAR
- R : tRect;
- BEGIN
- GetExtent(R);
- R.B.Y := R.A.Y + 1;
- MenuBar := New(pMenuBar, Init(R, NewMenu(
- NewSubMenu('~D~rucken', hcNoContext, NewMenu(
- NewItem('~S~pooler', 'F1', kbF1,
- cmSpooler, hcNoContext,
- NewItem('Spooler ~a~ktivieren', 'F2', kbF2,
- cmAktiv, hcNoContext,
- NewItem('Spooler ~d~eaktivieren', 'F3', kbF3,
- cmPassiv, hcNoContext,
- NewItem('~F~ile löschen', 'F4', kbF4,
- cmDelete, hcNoContext,
- NewItem('~L~iste drucken', 'F5', kbF5,
- cmList, hcNoContext,
- NIL)))))),
- NIL))));
- END;
-
- PROCEDURE tMainApp.InitStatusLine;
- VAR
- R : tRect;
- BEGIN
- GetExtent(R);
- R.A.Y := R.B.Y - 1;
- StatusLine := New(pStatusLine, Init(R,
- NewStatusDef(0, $FFFF,
- NewStatusKey('F10 Menu', kbF10, cmMenu,
- NewStatusKey('~ALT-X~ Exit', kbAltX, cmQuit,
- NIL)),
- NIL)));
- END;
-
- PROCEDURE tMainApp.HandleEvent(VAR Event : tEvent);
- VAR
- Liste : pItemList;
- i : INTEGER;
- Datei : Text;
- BEGIN
- tApplication.HandleEvent(Event);
- IF Event.What = evCommand THEN BEGIN
- CASE Event.Command OF
- cmSpooler : BEGIN
- New(Path_Spooler);
- Path_Spooler^ := '*.*';
- FileOpen(Path_Spooler^);
- IF Path_Spooler^ <> '' THEN
- Drucker^.Insert(pString(Path_Spooler));
- end;
- cmAktiv : Drucker^.Go;
- cmPassiv : Drucker^.Stop;
- cmDelete : BEGIN
- New(Path_Spooler);
- Path_Spooler^ := '*.*';
- FileOpen(Path_Spooler^);
- IF Path_Spooler^ <> '' THEN
- Drucker^.Delete(pString(Path_Spooler));
- END;
- cmList : BEGIN
- New(Path_Spooler);
- Path_Spooler^ := 'LISTE.DAT';
- Assign(Datei, Path_Spooler^);
- Rewrite(Datei);
- Drucker^.GetItems(Liste);
- FOR i := 0 TO Drucker^.Count-1 DO
- WriteLn(Datei, String(Liste^[i]^));
- Close(Datei);
- Drucker^.Insert(pString(Path_Spooler));
- END;
- END;
- ClearEvent(Event);
- END;
- END;
-
- BEGIN
- MainProc.Init;
- MainProc.Run;
- MainProc.Done;
- END.
- (* ------------------------------------------------------ *)
- (* Ende von SPOOLTST.PAS *)
-
-