home *** CD-ROM | disk | FTP | other *** search
- (***************************************
- * WG-VISION 1.0 BEISPIELPROGRAMM *
- ****************************************
- * *
- * Quelltextlister mit Veränderung des *
- * Zeichensatzes zur Laufzeit *
- * *
- *--------------------------------------*
- * Achtung: Nur VGA ! *
- ****************************************
- * (c) 1993 Dipl.Phys. Mathias Scholz *
- ***************************************)
-
- {$I COMPILER.INC}
-
- program List;
-
- uses WApp,
- WEvent,
- WDecl,
- WViews,
- WDriver,
- WDlg,
- WFileDlg,
- WUtils,
- WText,
- Graph;
-
-
- const cmOpen = 101;
- cmSetFont = 102;
-
- msgDraw = 100;
-
- type TApplication=object(TApp)
- procedure InitMenuBar; virtual;
- procedure SetDialogData; virtual;
- procedure HandleEvent; virtual;
- procedure LoadFile;
- procedure ListWindow;
- procedure SetFont;
- end;
-
- PNewScroller=^TNewScroller;
-
- PScrollWindow=^TScrollWindow;
- TScrollWindow=object(TWindow)
- Scroller:PNewScroller;
- procedure InitWindowScroller; virtual;
- procedure HandleEvent; virtual;
- destructor Done; virtual;
- end;
-
- TNewScroller=object(TScroller)
- procedure CreateData;
- procedure ScrollDraw; virtual;
- end;
-
- PSetFontWindow=^TSetFontWindow;
- TSetFontWindow=object(TDlgWindow)
- DFont:GraficFont;
- constructor Init(X,Y:integer);
- procedure DrawClientArea; virtual;
- procedure HandleEvent; virtual;
- end;
-
- {Dialog-Record}
-
- tFontDataRec=record
- Schalter:string[8];
- end;
-
-
- var MyApp:TApplication;
- FontDataRec:tFontDataRec;
-
-
- {Implementation TApplication}
-
- procedure TApplication.InitMenuBar;
- begin
- MainMenu('~F~enster',0);
- SubMenu('~D~atei Laden',cmOpen,0,0,false,false);
- SubMenu('~Z~eichensatz wechseln',cmSetFont,0,0,true,false);
- NewLine;
- SubMenu('E~x~it Alt-X',cmCloseApplication,0,altX,false,false);
- end;
-
- procedure TApplication.SetDialogData;
- begin
- FontDataRec.Schalter:='TGrrrrRr';
- end;
-
- procedure TApplication.HandleEvent;
- begin
- Heap^.ShowHeapStatus(523,8,White);
- TProgram.HandleEvent;
- case Event.Command of
- cmOpen : LoadFile;
- cmSetFont : SetFont;
- end; {case}
- if Event.Message=msgLoadFile then
- begin
- ListWindow;
- ClearMessage;
- end;
- if WinAnz=0 then MMenu[1]^.sbMenu[2]^.Aktiviere
- else MMenu[1]^.sbMenu[2]^.DeAktiviere;
- end;
-
- procedure TApplication.LoadFile;
- var Window:PInputDialog;
- begin
- Window:=New(PInputDialog, Init('Dateiauswahl','*.PAS'));
- InsertDesktop(Window);
- end;
-
- procedure TApplication.ListWindow;
- var R:TRect;
- Window:PScrollWindow;
- begin
- R.Assign(20,60,616,446);
- Window:=New(PScrollWindow, Init(R,'ScrollWindow / Quelltext-Lister',winDouble+winPanel+winMenu+winKey));
- InsertDesktop(Window);
- end;
-
- procedure TApplication.SetFont;
- var Window:PSetFontWindow;
- begin
- Window:=New(PSetFontWindow, Init(60,80));
- InsertDesktop(Window);
- end;
-
- {Implementation TScrollWindow}
-
- procedure TScrollWindow.InitWindowScroller;
- var R:TRect;
- SBH1,SBV1:PScrollBar;
- begin
- R:=Frame^.Area;
- SBH1:=New(PScrollBar, Init(R,HorizDir));
- SBV1:=New(PScrollBar, Init(R,VertDir));
- Scroller:=New(PNewScroller, Init(R,SBH1,SBV1));
- Scroller^.CreateData;
- List^.InsertItem(Scroller);
- end;
-
- procedure TScrollWindow.HandleEvent;
- begin
- TWindow.HandleEvent;
- if Event.Message=msgDraw then
- begin
- Scroller^.ScrollDraw;
- ClearMessage;
- end;
- end;
-
- destructor TScrollWindow.Done;
- begin
- TWindow.Done;
- Dispose(Scroller, Done);
- end;
-
- {Implementation TNewScroller}
-
- procedure TNewScroller.CreateData;
- var dat:text;
- LfdPtr:PLine;
- begin
- SetFont(Wndw19);
- Assign(dat,Event.InfoString);
- Reset(dat);
- while not Eof(dat) do
- begin
- LfdPtr:=New(PLine, Init);
- ReadLn(dat,LfdPtr^.Eintrag);
- Liste^.InsertItem(LfdPtr);
- end;
- SetLimit(25,Liste^.AnzElem-1,8,16);
- end;
-
- procedure TNewScroller.ScrollDraw;
- var I:integer;
- LfdPtr:PGroup;
-
- function Clip(P,N:byte;z:string):string;
- begin
- Clip:=Copy(z,P,N);
- end;
-
- {------}
-
- begin
- SetFontColor(White,Blue);
- Mouse.HideMouse;
- with Border do
- begin
- SetFillStyle(SolidFill,GetPalColor(1));
- SetColor(GetPalColor(2));
- for I:=Delta.Y to WDelta.Y do
- begin
- LfdPtr:=Liste^.GetItems(I);
- Bar(A.X,A.Y+(I-Delta.Y)*Py+10,B.X,A.Y+(I-Delta.Y)*Py+10+Py);
- WriteText(A.X+20,A.Y+(I-Delta.Y)*Py+10,Clip(Delta.X,
- Spalten*8 div 8-5,PLine(LfdPtr)^.Eintrag));
- end;
- if VertiScrollBar<>nil then
- for I:=(WDelta.Y-Delta.Y)+1 to Zeilen do
- Bar(A.X,A.Y+I*Py+10,B.X,A.Y+I*Py+10+Py);
- end;
- Mouse.ShowMouse;
- end;
-
- {Implementation TSetFontWindow}
-
- constructor TSetFontWindow.Init(X,Y:integer);
- var RR:TRect;
- I:integer;
- begin
- RR.Assign(X,Y,X+455,Y+265);
- TDlgWindow.Init(RR,'Zeichensätze',winDouble+winPanel+winMenu);
- SetPushButton(55,210,80,22,'OK',cmCloseWindow);
- SetGroupFrame(25,55,150,125,'Zeichensätze',NormWidth);
- SetRadioButton(45,80, '~T~hin8 8x12',1);
- SetRadioButton(45,95, 'T~h~in14 8x14',1);
- SetRadioButton(45,110,'Th~i~n16 8x16',1);
- SetRadioButton(45,125,'~B~rdwy19 8x19',1);
- SetRadioButton(45,140,'~W~ndw19 8x19',1);
- SetRadioButton(45,155,'~S~ans19 8x19',1);
- SetData(FontDataRec);
- for I:=3 to 8 do
- if FontDataRec.Schalter[I]='R' then
- case I of
- 3 : DFont:=Thin8;
- 4 : DFont:=Thin14;
- 5 : DFont:=Thin16;
- 6 : DFont:=Brdwy19;
- 7 : DFont:=Wndw19;
- 8 : DFont:=Sans19;
- end; {case}
- SetFont(DFont);
- SetFontColor(White,Green);
- end;
-
- procedure TSetFontWindow.DrawClientArea;
- var z:array[1..6] of string;
- I:integer;
- begin
- z[1]:='ABCDEFGHIJKLMNOPQRSTUVWXYZ';
- z[2]:='abcdefghijklmnopqrstuvwxyz';
- z[3]:='ÄÖÜäöü?=)(/&%$"!^°²ⁿ{[]}\';
- z[4]:='12345678901234567890123456';
- z[5]:='{}[]\~ÇüéâäàåçêëèïîìÄÅÉæôö';
- z[6]:='òûùÿÖÜ¢£¥₧ƒáíóúñѪº¿⌐¬½¼─«';
- with Origin do
- begin
- SetColor(Black);
- Mouse.HideMouse;
- FBar(X+205,Y+60,X+425,Y+188,White);
- SetLineStyle(SolidLn,0,ThickWidth);
- Rectangle(X+200,Y+55,X+427,Y+190);
- SetLineStyle(SolidLn,0,NormWidth);
- for I:=1 to 6 do WriteText(X+215,Y+45+I*20,z[I]);
- Mouse.ShowMouse;
- end;
- end;
-
- procedure TSetFontWindow.HandleEvent;
- var I:byte;
- begin
- with FontDataRec do
- for I:=3 to 8 do
- if Schalter[I]='R' then
- begin
- case I of
- 3 : DFont:=Thin8;
- 4 : DFont:=Thin14;
- 5 : DFont:=Thin16;
- 6 : DFont:=Brdwy19;
- 7 : DFont:=Wndw19;
- 8 : DFont:=Sans19;
- end; {case}
- end;
- if DFont<>Font then
- begin
- SetFont(DFont);
- DrawClientArea;
- Event.Message:=msgDraw;
- end;
- TDlgWindow.HandleEvent;
- end;
-
- {Hauptprogramm}
-
- begin
- MyApp.Init('Quelltext-Lister mit Fontwechsel');
- MyApp.Run;
- MyApp.Done;
- end.
-
-