home *** CD-ROM | disk | FTP | other *** search
- (* ------------------------------------------------------ *)
- (* BANNER.PAS *)
- (* Programm zur Erstellung von Endlos-Transparenten *)
- (* aus den BGI-Zeichensätzen *)
- (* (c) 1990 Uwe Baumann & TOOLBOX *)
- (* ------------------------------------------------------ *)
- PROGRAM Banner;
-
- USES Crt, Graph, Printer;
-
- TYPE
- PrinterRec = RECORD
- ModeName : STRING;
- InitString : ARRAY [0..6] OF CHAR;
- DotCode : CHAR;
- ExitString : ARRAY [0..6] OF CHAR;
- END;
-
- FontRec = RECORD
- FontName : STRING;
- MaxSize : WORD;
- MaxHeight : BYTE
- END;
-
- CONST
- MaxPrinterModes = 2;
- PrinterMode : ARRAY [1..MaxPrinterModes] OF PrinterRec =
- ((ModeName : 'Default ASCII';
- InitString : (#0, #0, #0, #0, #0, #0, #0);
- DotCode : 'X';
- ExitString : (#0, #0, #0, #0, #0, #0, #0) ),
- (ModeName : 'Epson Esc/P';
- InitString : (#5, #27, 't', #1, #10, #13, #0);
- DotCode : #219;
- ExitString : (#0, #0, #0, #0, #0, #0, #0)));
-
- MaxFonts = 4;
- Fonts : ARRAY [0..MaxFonts] OF FontRec =
- ((FontName : 'Default'; MaxSize : 9 ; MaxHeight : 72),
- (FontName : 'Triplex'; MaxSize : 7 ; MaxHeight : 71),
- (FontName : 'Small'; MaxSize : 10 ; MaxHeight : 41),
- (FontName : 'SansSerif'; MaxSize : 7 ; MaxHeight : 71),
- (FontName : 'Gothic'; MaxSize : 7 ; MaxHeight : 71));
-
- VAR
- GraphDriver, GraphMode, ErrorCode,
- ActFont, ActPrinterMode : INTEGER;
- OldExitProc : POINTER;
- BannerText : STRING;
- GraphInitialized : BOOLEAN;
-
- {$F+}
- PROCEDURE GrExit;
- BEGIN
- ExitProc := OldExitProc;
- CloseGraph;
- END;
- {$F-}
-
- PROCEDURE GraphInit;
- BEGIN
- DirectVideo := FALSE;
- OldExitProc := ExitProc;
- ExitProc := @GrExit;
-
- DetectGraph(GraphDriver, GraphMode);
- GraphDriver := Detect;
-
- InitGraph(GraphDriver, GraphMode, '');
-
- ErrorCode := GraphResult;
- IF ErrorCode <> grOk THEN BEGIN
- WriteLn;
- WriteLn('GRAFIK-INITIALISIERUNGSFEHLER:');
- WriteLn('Fehlercode :', GraphErrorMsg(ErrorCode));
- Halt(1);
- END;
-
- SetColor(GetMaxColor);
- SetFillStyle(SolidFill, 0);
- SetTextJustify(LeftText, TopText);
- GraphInitialized := TRUE;
- END;
-
- PROCEDURE PrintOneChar(OutChar : CHAR);
- VAR
- MagWidth, MagHeight, CountWidth,
- CountHeight, a, b : INTEGER;
- ChHeight, ChWidth : WORD;
- BEGIN
- Bar(2, 2, 4 + TextWidth('m'),
- 4 + Fonts[ActFont].MaxHeight);
- Bar(3, 8 + Fonts[ActFont].MaxHeight, 3 + TextWidth('m'),
- 12 + Fonts[ActFont].MaxHeight);
- OutTextXY(3, 3, OutChar);
-
- FOR CountWidth := 3 TO (3 + TextWidth(OutChar)) DO BEGIN
- FOR CountHeight := (3 + Fonts[ActFont].MaxHeight)
- DOWNTO 3 DO
- IF GetPixel(CountWidth,CountHeight)=GetMaxColor THEN
- Write(LST, PrinterMode[ActPrinterMode].DotCode)
- ELSE Write(LST, ' ');
- WriteLn(LST);
- SetFillStyle(SolidFill, GetMaxColor);
- Bar(3, 8 + Fonts[ActFont].MaxHeight, CountWidth,
- 12 + Fonts[ActFont].MaxHeight);
- SetFillStyle(SolidFill, 0);
- END;
- END;
-
- PROCEDURE PrintBanner(Message : STRING);
- VAR
- a : BYTE;
- ch : CHAR;
- BEGIN
- IF GraphInitialized THEN
- SetGraphMode(GraphMode)
- ELSE
- GraphInit;
-
- SetFillStyle(SolidFill, 0);
- SetTextStyle(ActFont, HorizDir, Fonts[ActFont].MaxSize);
- Rectangle(1, 1, 5 + TextWidth('m'),
- 5 + Fonts[ActFont].MaxHeight);
-
- Write(LST, PrinterMode[ActPrinterMode].InitString);
- FOR a := 1 TO Length(Message) DO BEGIN
- PrintOneChar(Message[a]);
- IF KeyPressed THEN BEGIN
- ch := ReadKey;
- IF ch = #27 THEN BEGIN
- RestoreCrtMode;
- Exit;
- END;
- END;
- END;
- Write(LST, PrinterMode[ActPrinterMode].ExitString);
- RestoreCrtMode;
- END;
-
- PROCEDURE InitVars;
- BEGIN
- ActFont := 0;
- ActPrinterMode := 1;
- BannerText := '';
- GraphInitialized := FALSE;
- END;
-
- PROCEDURE Menu;
- VAR
- ch : CHAR;
- BEGIN
- REPEAT
- ClrScr;
- WriteLn('Banner-Druckprogramm 1.0');
- WriteLn('========================');
- WriteLn;
- WriteLn('(c) 1990 Uwe Baumann & TOOLBOX');
- WriteLn;
- WriteLn('Einstellungen:');
- WriteLn(' (1) Zeichensatz : ',
- Fonts[ActFont].FontName);
- WriteLn(' (2) Druckermodus : ',
- PrinterMode[ActPrinterMode].ModeName);
- WriteLn;
- WriteLn('Funktionen:');
- WriteLn(' (3) Text eingeben / ändern');
- WriteLn(' (4) Banner drucken (Abbruch mit [Esc])');
- WriteLn(' (5) Programm beenden');
- WriteLn;
- WriteLn('Banner-Text:');
- WriteLn(BannerText);
- WriteLn;
- Write('Bitte wählen Sie eine Einstellung ',
- 'oder Funktion !');
-
- ch := ReadKey;
- CASE ch OF
- '1' : BEGIN
- Inc(ActFont);
- IF ActFont > 4 THEN ActFont := 0;
- END;
- '2' : BEGIN
- Inc(ActPrinterMode);
- IF ActPrinterMode > MaxPrinterModes THEN
- ActPrinterMode := 1;
- END;
- '3' : BEGIN
- GotoXY(1,16);
- ClrEOL;
- ReadLn(BannerText);
- END;
- '4' : IF BannerText <> '' THEN
- PrintBanner(BannerText);
- END;
- UNTIL ch = '5'
- END;
-
- BEGIN
- InitVars;
- Menu;
- END.
- (* ------------------------------------------------------ *)
- (* Ende von BANNER.PAS *)
-