home *** CD-ROM | disk | FTP | other *** search
- UNIT sys2; {$project vt}
- { abgespeckte Version vom UNIT sys, für VTview }
-
- INTERFACE;
-
- TYPE Str80 = String[80];
-
- VAR taste: Char;
- escseq: String[10];
- newevent,mouseclicked,dblclicked,menupicked,slidermoved: Boolean;
- clickedx,clickedy: Integer;
- menucode: Long;
- sliderposn: Real; { 0..1 }
- colperm: Long;
- Con: Ptr; { darf nicht vom ExitServer geschlossen werden, komisch }
-
- PROCEDURE event_scan;
- PROCEDURE update_slider(i, anz: Integer);
- FUNCTION fileselect(was_los: str80; speichern: Boolean;
- VAR selected: str80): Boolean;
- PROCEDURE desaster(meldung: Str80);
- PROCEDURE stretch_line(zeile, sp0, sp1: Integer);
- PROCEDURE raster_line(zeile, sp0, sp1: Integer; farbe: Word);
- PROCEDURE sysinit(version: Str);
- PROCEDURE sysclean;
-
- { ---------------------------------------------------------------------- }
-
- IMPLEMENTATION;
-
- {$opt q,s+,i+ } { keine Laufzeitprüfungen außer Stack und Feldindizes }
- {$incl "intuition.lib", "graphics.lib" }
- {$incl "diskfont.lib", "dos.lib", "icon.lib", "asl.lib","exec.lib" }
-
- VAR NeuerScreen: ExtNewScreen; STATIC;
- MyScreen: p_Screen;
- Tags: Array[1..10] OF TagItem; STATIC;
- titel: Str80; STATIC;
- NeuesWindow: NewWindow; STATIC;
- MyWindow: p_Window;
- Schieber: Gadget;
- SchieberInfo: PropInfo;
- MoverData: Image; STATIC;
- Strip, LastMenu: p_Menu;
- LastItem, LastSubItem: p_MenuItem;
- nextselect: Word;
- lastevent: IntuiMessage; { kein Zeiger! }
- topazAttr,teleAttr: TextAttr;
- teleFont: p_TextFont;
-
- PROCEDURE event_scan;
- { überträgt eingehende Tasten und ESC-Sequenzen sowie die Intuition- }
- { Ereignisse Mausklick und Menuewahl in globale Variablen. }
- VAR Msg: ^IntuiMessage;
- gad: ^Gadget;
- propi: ^PropInfo;
- i,charx,chary: Integer;
- PROCEDURE menu_eval(item: Word);
- { wird an zwei Stellen gebraucht ... }
- VAR men,menitem,subitem: Word;
- item_address: ^MenuItem;
- BEGIN
- newevent := True; menupicked := True;
- { Menue, Menuepunkt und Untermenue ermitteln und diese in ziemlich }
- { mutierter Form wieder gemeinsam in einem Langwort ablegen: }
- men := item AND $1F;
- menitem := (item SHR 5) AND $3F;
- subitem := (item SHR 11) AND $1F;
- menucode := (Long(men+1) SHL 16) OR ((menitem+1) SHL 8) OR (subitem+1);
- item_address := ItemAddress(Strip,item);
- nextselect := item_address^.NextSelect;
- END;
- BEGIN
- IF nextselect<>MENUNULL THEN BEGIN
- menu_eval(nextselect); Exit;
- END
- taste := ReadCon(Con);
- IF taste<>#0 THEN BEGIN
- newevent := True; i := 0;
- IF taste=#155 THEN REPEAT
- Inc(i); escseq[i] := ReadCon(Con);
- UNTIL (escseq[i]>='@') OR (i=9);
- escseq[i+1] := #0;
- Exit;
- END;
- Msg := Get_Msg(MyWindow^.UserPort);
- IF Msg<>Nil THEN BEGIN
- CASE Msg^.class OF
- MENUPICK: IF Msg^.Code<>MENUNULL THEN menu_eval(Msg^.Code);
- MOUSEBUTTONS: IF Msg^.code=SELECTDOWN THEN BEGIN
- newevent := True; mouseclicked := True;
- charx := MyWindow^.RPort^.TxWidth;
- chary := MyWindow^.RPort^.TxHeight;
- clickedx := 1 + (Msg^.MouseX - MyWindow^.BorderLeft) DIV charx;
- clickedy := 1 + (Msg^.MouseY - MyWindow^.BorderTop) DIV chary;
- dblclicked := DoubleClick(lastevent.seconds,lastevent.micros,
- Msg^.seconds,Msg^.micros);
- lastevent := Msg^;
- END;
- GADGETUP: BEGIN
- gad := Msg^.IAddress;
- IF gad=^Schieber THEN BEGIN
- slidermoved := True; newevent := True;
- propi := gad^.SpecialInfo;
- sliderposn := Real(propi^.HorizPot)/MAXPOT;
- END;
- END;
- OTHERWISE;
- END;
- Reply_Msg(Msg);
- END;
- END;
-
- PROCEDURE update_slider{(i, anz: Integer)};
- { PropGadget auf Position i von (0..anz-1) stellen }
- VAR max: Integer;
- BEGIN
- IF anz=0 THEN anz := 1;
- max := anz-1; IF max=0 THEN max := 1;
- NewModifyProp(^Schieber,MyWindow,Nil,FREEHORIZ OR AUTOKNOB,
- MAXPOT DIV max*i, 0, MAXBODY DIV anz, MAXBODY, 1);
- END;
-
- FUNCTION fileselect{(was_los: str80; speichern: Boolean;
- VAR selected: str80): Boolean};
- { Mit Filerequester der asl.library, sofern vorhanden, sonst gar nicht. }
- VAR i,p,l: Integer;
- Req: p_FileRequester;
- Msg: p_IntuiMessage;
- pfad,name: str80;
- BEGIN
- fileselect := False;
- AslBase := OpenLibrary(ASLNAME,0);
- IF AslBase=Nil THEN Exit;
- l := Length(selected);
- { selected in pfad und name spalten }
- p := 0; FOR i := 1 TO l DO
- IF selected[i] IN ['/',':'] THEN p := i;
- IF p=0 THEN pfad := '' ELSE pfad := Copy(selected,1,p);
- IF p=l THEN name := '' ELSE name := Copy(selected,p+1,l-p);
- Tags[1] := TagItem(ASL_Hail,Long(^was_los));
- Tags[2] := TagItem(ASL_Dir,Long(^pfad));
- Tags[3] := TagItem(ASL_File,Long(^name));
- Tags[4] := TagItem(ASL_FuncFlags,FILF_SAVE);
- IF speichern THEN Tags[5] := TagItem(TAG_DONE,0)
- ELSE Tags[4] := TagItem(TAG_DONE,0);
- Req := AllocAslRequest(ASL_FileRequest,^Tags);
- IF Req<>NIL THEN BEGIN
- IF RequestFile(Req) THEN
- IF Req^.rf_File<>'' THEN BEGIN
- fileselect := True;
- pfad := Req^.rf_Dir; l := Length(pfad);
- name := Req^.rf_File;
- IF l=0 THEN
- selected := name
- ELSE IF pfad[l] IN [':','/'] THEN
- selected := pfad+name
- ELSE
- selected := pfad+'/'+name;
- END;
- FreeAslRequest(Req);
- END;
- IF AslBase<>Nil THEN CloseLibrary(AslBase);
- AslBase := Nil;
- END;
-
- { PROCEDURE's desaster(), raster_line(), stretch_line() sowie die }
- { Menü-Erzeugung includen: }
- CONST unit_sys=1701; {$path "PAS:prg/vt/"; incl "dbluse.p" }
-
- PROCEDURE create_menu;
- CONST Check = CHECKIT OR MENUTOGGLE;
- CheckOn = Check OR CHECKED;
- VAR egal: Boolean;
- BEGIN
- LastMenu := Nil;
- AddMenu(10, 'VTview');
- { AddItem(0, 0, 'Datei lesen', 'L');
- AddItem(0, 0, 'Seite drucken','P'); }
- AddItem(0, 0, 'Ende', 'Q');
- MenuWidths;
- egal := SetMenuStrip(MyWindow,Strip);
- END;
-
- PROCEDURE sysinit{(version: Str)};
- VAR i,j,breite,hoehe: Integer;
- l: Long;
- BEGIN
- titel := Copy(version,7,Length(version)-6);
- { Zuerst Zeiger für den zugehörigen ExitServer initialisieren: }
- IntuitionBase := Nil; GfxBase := Nil; DiskFontBase := Nil; AslBase := Nil;
- MyScreen := Nil; MyWindow := Nil; teleFont := Nil;
- { Libraries etc. öffnen: }
- IntuitionBase := OpenLibrary('intuition.library',0);
- GfxBase := OpenLibrary(GRAPHICSNAME,0);
- DiskFontBase := OpenLibrary('diskfont.library',0);
- IF IntuitionBase=Nil THEN Error('Can''t open intuition.library!');
- IF GfxBase=Nil THEN Error('Can''t open graphics.library!');
- IF DiskfontBase=Nil THEN desaster('Can''t open diskfont.library !!!');
- { Screen: }
- breite := 320; hoehe := 256;
- topazAttr := TextAttr('topaz.font',8,FS_NORMAL,FPF_ROMFONT);
- i := -1; { Default-DrawInfo-Pens für 2.0 }
- Tags[1] := TagItem(SA_Pens,Long(^i));
- Tags[2] := TagItem(TAG_DONE,0);
- NeuerScreen := ExtNewScreen(0,0,breite,hoehe,3, 0,1, 0,
- NS_EXTENDED OR CUSTOMSCREEN,^topazAttr,titel,Nil,Nil,Nil);
- MyScreen := OpenScreen(^NeuerScreen);
- IF MyScreen=Nil THEN Error('Can''t open screen!');
- FOR i := 0 TO 7 DO
- SetRGB4(^MyScreen^.ViewPort, (colperm SHR (4*(7-i))) AND $F,
- 15*(i AND 1), 15*((i DIV 2) AND 1),15*((i DIV 4) AND 1));
- { Fenster und Menue: }
- NeuesWindow := NewWindow(0,16,breite,hoehe-16, 0,1,
- MENUPICK OR MOUSEBUTTONS OR GADGETUP, ACTIVATE OR BORDERLESS,
- Nil,Nil,Nil,MyScreen,Nil,170,100,breite,hoehe,CUSTOMSCREEN);
- MyWindow := OpenWindow(^NeuesWindow);
- IF MyWindow=Nil THEN Error('Can''t open window!');
- create_menu;
- { Propgadget: }
- Schieber:=Gadget(Nil,0,-12,0,12,GADGHCOMP OR GRELWIDTH OR GRELBOTTOM,
- BOTTOMBORDER OR RELVERIFY,PROPGADGET,^Moverdata,Nil,
- Nil,0,^Schieberinfo,2,Nil);
- SchieberInfo:=Propinfo(FREEHORIZ or AUTOKNOB,$8000,$8000,$8000 div 5,0,
- 0,0,0,0,0,0);
- l := AddGadget(MyWindow,^Schieber,0);
- { Font: }
- teleAttr := TextAttr('videotext.font',9,FS_NORMAL,FPF_DISKFONT);
- IF DiskFontBase<>Nil THEN
- teleFont := OpenDiskFont(^teleAttr);
- IF teleFont<>Nil THEN
- l := SetFont(MyWindow^.RPort,teleFont)
- ELSE
- desaster('Can''t open videotext.font !!!');
- { Console einrichten: }
- Con := OpenConsole(MyWindow);
- SetStdIO(Con);
- RefreshGadgets(^Schieber,MyWindow,Nil);
- END;
-
- PROCEDURE sysclean;
- VAR l: Long;
- BEGIN
- IF MyWindow<>Nil THEN BEGIN
- l := RemoveGadget(MyWindow,^Schieber);
- IF Strip<>Nil THEN ClearMenuStrip(MyWindow); TrashMenu;
- CloseWindow(MyWindow);
- END;
- IF MyScreen<>Nil THEN IF CloseScreen(MyScreen) THEN;
- IF teleFont<>Nil THEN CloseFont(teleFont);
- IF IntuitionBase<>Nil THEN CloseLibrary(IntuitionBase);
- IF GfxBase<>Nil THEN CloseLibrary(GfxBase);
- IF DiskFontBase<>Nil THEN CloseLibrary(DiskFontBase);
- { festhalten, daß alles geschlossen ist: }
- MyWindow := Nil; Strip := Nil;
- MyScreen := Nil;
- teleFont := Nil;
- IntuitionBase := Nil;
- GfxBase := Nil;
- DiskFontBase := Nil;
- END;
-
- BEGIN { Initialisierungsteil }
- colperm := $01234567;
- newevent := False; lastevent.seconds := 0; nextselect := MENUNULL;
- mouseclicked := False; menupicked := False; slidermoved := False;
- END.
-
-