home *** CD-ROM | disk | FTP | other *** search
- { WTUTOR34.PAS - demonstration program for WINDOW34.INC ver 3.4, 08-31-87 }
-
- program WindowTutor;
-
- {$i Qwik30.inc}
-
- Const MaxWndw = 30; { Define storage area for Max number of window stats }
- {$I Window34.inc}
-
- var i,j,k,m: integer;
- Battr,Step,OldCursor: integer;
- ExtKey: boolean;
- Key: char;
-
- const
- RetKey = #13;
- EscKey = #27;
- StrA : array [1..16] of str80 = (
- '',
- 'The windowing procedures in the file WINDOW34.INC',
- 'are a set of ShareWare routines that allow Turbo',
- 'PASCAL to create incredibly fast multi-level',
- 'windows. WINDOW34.INC makes use of the quick',
- 'screen writing procedures of QWIK30.INC.',
- '',
- 'The windows may be of any size (from 2x2 to screen',
- 'limits) and color, and may have one of several',
- 'different border styles and colors including no',
- 'border. They also work in any column mode',
- '40/80/etc. Once inside a window, the normal Turbo',
- 'PASCAL procedures "TextColor" and "TextBackground"',
- 'may be used to change character attributes. These',
- 'routines automatically configure to your video',
- 'card and mode.');
-
- StrB : array [1..11] of str80 = (
- 'The window procedures package',
- 'consists of five procedures:',
- '',
- ' InitWindow',
- ' MakeWindow',
- ' ScrollWindow',
- ' RemoveWindow',
- ' TitleWindow',
- '',
- 'The procedures are described',
- 'in the following windows:');
-
- StrC : array [1..8] of str80 = (
- 'InitWindow',
- '',
- 'FORMAT: InitWindow (WindowAttribute: byte);',
- '',
- 'InitWindow initializes several variables required by the',
- 'windowing package, as well as selecting the foreground and',
- 'background colors of the initial screen display. InitWindow',
- 'must be called before using any of the other procedures.');
-
- StrD : array [1..17] of str80 = (
- 'MakeWindow',
- '',
- 'FORMAT: MakeWindow (Row,Col,Rows,Cols,Wattr,Battr: byte;',
- ' BrdrSel: borders);',
- '',
- 'MakeWindow puts a new blank window on the display. The window starts',
- 'at the upper left corner (row,col) and extends for a number of rows',
- 'and columns (rows,cols). If a border exists, the actual dimensions',
- 'of the Turbo window will be 2 less than indicated in the MakeWindow',
- 'statement. The border can be one of the following:',
- '',
- ' NoBrdr - just window EvenSolidBrdr - evenly solid',
- ' BlankBrdr - blank spaces ThinSolidBrdr - thin solid line',
- ' SingleBrdr - single line LhatchBrdr - light hatch',
- ' DoubleBrdr - double line MhatchBrdr - medium hatch',
- ' MixedBrdr - single/double HhatchBrdr - heavy hatch',
- ' SolidBrdr - solid UserBrdr - user defined border');
-
- StrE : array [1..6] of str80 = (
- 'RemoveWindow',
- 'FORMAT: RemoveWindow;',
- '',
- 'RemoveWindow removes the last window',
- 'remaining on the screen from the',
- 'MakeWindow procedure.');
-
- StrF : array [1..2] of str80 = (
- 'See if your BIOS gives you flicker',
- 'when your screen rolls down next ...');
-
- StrG : array [1..19] of str80 = (
- '',
- ' ScrollWindow',
- '',
- '',
- 'FORMAT: ScrollWindow (RowBegin,RowEnd: byte; Dir: DirType);',
- '',
- 'Turbo''s standard procedures InsLine and DelLine may have worked just',
- 'fine this window. However, if your screen just had some bad flicker',
- 'as it was scrolling down, your BIOS is not flicker-free. To keep the',
- 'display flicker-free, to work on other video pages, VGA, or EGA, then',
- 'you will need this procedure. The upward scroll used ScrollWindow,',
- 'so no flicker was seen then. It also scrolls partial windows.',
- '',
- 'The direction of scroll can be either of the following:',
- '',
- ' ''Up'' - to scroll up',
- ' ''Down'' - to scroll down',
- '',
- '');
-
- StrH : array [1..6] of str80 = (
- 'TitleWindow',
- 'FORMAT: TitleWindow (Justify, Title);',
- '',
- 'TitleWindow places a title in the top border',
- 'of the current window. Justify permits Left,',
- 'Center or Right justification of the title.');
-
- StrI : array [1..18] of str80 = (
- 'There are now two special effects that can',
- 'enhance the window display:',
- ' ZoomEffect - emulates the Macintosh.',
- ' ShadowEffect - places a left or right',
- ' shadow underneath the menu.',
- 'These global variables can be placed anywhere',
- 'in your program. ZoomEffect is boolean while',
- 'ShadowEffect is of DirType.',
- ' press RETURN ...',
- 'CGA:',
- 'The CGA is self-regulating and controls the',
- 'zoom rate.',
- 'MDA, EGA, MCGA, and VGA:',
- 'These video cards are quite fast and need a',
- 'delay for the effect. A default value of 11',
- 'milliseconds is used in a typed constant',
- 'named ''ZoomDelay'' and shouldn''t need any',
- 'adjustment.');
-
- StrJ : array [1..5] of str80 = (
- ' The maximum number of windows that',
- ' may be on the screen at any one time',
- ' is specified by the constant',
- ' "MaxWndw". Assign it in your program',
- ' before including $I WINDOW34.INC.');
-
- StrK : array [1..10] of str80 = (
- ' In addition to windows, there are 17 powerful',
- ' QWIK screen write procedures you can use:',
- ' QwriteLV QfillC QstoreToMem',
- ' QwriteV Qfill QstoreToScr',
- ' Qwrite Qattr QviewPage',
- ' QwriteC QattrC QwritePage',
- ' QwriteCV CursorOff CursorChange',
- ' CursorOn GotoRC',
- ' In QWIK30.ARC, compile and run QDEMO.PAS to see',
- ' all of the features.');
-
- StrL : array [1..20] of str80 = (
- ' The procedures are used as follows:',
- '',
- ' program YourProgram;',
- ' {$I Qwik30.inc}',
- ' const MaxWndw = ??? { Max # of windows }',
- ' {$I Window34.inc}',
- ' ...Your variables and procedures...',
- ' begin',
- ' .',
- ' InitWindow (WindowAttribute);',
- ' .',
- ' MakeWindow (Row,Col,Rows,Cols,Wattr,Battr,',
- ' BrdrSel);',
- ' TitleWindow (Justify,''the window title'');',
- ' .',
- ' RemoveWindow;',
- ' .',
- ' end.',
- '',
- ' { Use one RemoveWindow for each MakeWindow. }');
-
- StrM : array [1..15] of str80 = (
- 'WINDOW34.INC works these ...',
- '',
- 'COMPUTERS: ADAPTERS:',
- '------------------ ---------',
- 'IBM PC MDA',
- 'IBM XT CGA',
- 'IBM AT EGA',
- 'IBM PCjr MCGA',
- 'IBM PC Convertible VGA',
- 'IBM PS/2 Model 25 8514/A',
- 'IBM PS/2 Model 30',
- 'IBM PS/2 Model 50',
- 'IBM PS/2 Model 60',
- 'IBM PS/2 Model 80',
- 'IBM 3270');
-
- StrN : array [1..7] of str80 = (
- 'If you have any questions or comments,',
- 'please write to or call:',
- '',
- ' Jim H. LeMay (CIS 76011,217)',
- ' 6341 Klamath Rd.',
- ' Ft. Worth, TX 76116',
- ' 1-(817)-735-4833 (after 1730 CST)');
-
- Title: str160 = ' Turbo PASCAL Windows (Continued) ';
-
- procedure Show30windows;
- begin
- { -- Throw out 30 windows 4 times -- }
- for m:=1 to 4 do
- begin
- for i:=1 to 30 do
- begin
- j := random (70);
- k := random (21);
- Tattr:=Attr(yellow,green);
- MakeWindow (k+1,j+1,5,11,Attr(black,green),Tattr,DoubleBrdr);
- Qwrite (k+3,j+3, -1,'WINDOWS');
- end;
- if m=4 then delay (1500) else delay (300);
- for i:=LI downto 1 do RemoveWindow;
- end
- end;
-
- procedure ShowInitialScreen;
- begin
- { -- Create initial screen -- }
- QwriteC ( 1, 1,80, -1,'Turbo PASCAL Windows Tutorial');
- QwriteC ( 2, 1,80, -1,'Version 3.4');
- TextColor (black);
- QwriteC ( 4, 1,80,Tattr,'For each of the following displays:');
- Qwrite ( 5,26 ,Tattr,'1. Press RETURN to continue.');
- Qwrite ( 6,26 ,Tattr,'2. Press ESC to back up.');
- QwriteC (12, 1,80,Tattr,'This is the original screen without windows.');
- Step:=0;
- end;
-
- procedure ShowGeneral;
- begin
- { -- General description -- }
- ShadowEffect:=Right;
- MakeWindow (3,15,19,52,Attr(black,green),Attr(black,green),MixedBrdr);
- TitleWindow (Center,' Turbo PASCAL Windows ');
- with WndwStat[LI] do
- for j :=1 to 16 do QwriteV (WSrow+j,WScol+1,-1,StrA[j]);
- ShadowEffect:=NoDir;
- end;
-
- procedure ShowList;
- begin
- { -- List of Procedures -- }
- MakeWindow (5,2,15,33,Attr(black,cyan),Attr(white,blue),MhatchBrdr);
- TitleWindow (Center,' Five Procedures ');
- with WndwStat[LI] do
- begin
- for j:=1 to 2 do QwriteV (WSrow+1+j,WScol+2, -1,StrB[j]);
- for j:=3 to 9 do QwriteV (WSrow+1+j,WScol+2,Attr(white,cyan),StrB[j]);
- for j:=10 to 11 do QwriteV (WSrow+1+j,WScol+2, -1,StrB[j])
- end;
- end;
-
- procedure ShowInitWindow;
- begin
- { -- InitWindow description -- }
- MakeWindow (11,17,12,63,Attr(yellow,red),Attr(yellow,red),SingleBrdr);
- TitleWindow (Left,Title);
- with WndwStat[LI] do
- begin
- QwriteV (WSrow+2 ,WScol+2,Attr(white,blue),StrC[1]);
- for j:=2 to 4 do QwriteV (WSrow+1+j,WScol+2,Attr(cyan,red) ,StrC[j]);
- for j:=5 to 8 do QwriteV (WSrow+1+j,WScol+2,Attr(white,red) ,StrC[j]);
- end;
- end;
-
- procedure ShowMakeWindow;
- begin
- { -- MakeWindow description -- }
- MakeWindow (4,7,21,71,Attr(lightmagenta,blue),Attr(lightmagenta,blue),
- SolidBrdr);
- TitleWindow (Left,Title);
- with WndwStat[LI] do
- begin
- QwriteV (WSrow+2 ,WScol+5,Attr(yellow,red) ,StrD[1]);
- for j:=2 to 4 do QwriteV (WSrow+1+j,WScol+1,Attr(lightred,blue),StrD[j]);
- for j:=5 to 17 do QwriteV (WSrow+1+j,WScol+1,Attr(yellow,blue) ,StrD[j]);
- end;
- end;
-
- procedure ShowBorders;
- begin
- { -- Show different borders -- }
- for i:=0 to 5 do
- begin
- if i=1 then Battr:=Attr(yellow,yellow) else Battr := Attr(yellow,green);
- MakeWindow (2+2*i,13+3*i,5,10,Attr(yellow,green),Battr,Borders(i));
- end;
- with Brdr[UserBrdr] do
- begin
- TL := ^O;
- TH := ^O;
- TR := ^O;
- LV := '▐';
- RV := '▌';
- BL := ^O;
- BH := ^O;
- BR := ^O
- end;
- for i:=6 to 11 do
- MakeWindow (24-2*i,24+3*i,5,10,Attr(yellow,green),Battr,Borders(i));
- end;
-
- procedure ShowRemoveWindow;
- begin
- { -- RemoveWindow description -- }
- MakeWindow (11,20,11,40,Attr(black,brown),Attr(black,brown),DoubleBrdr);
- TitleWindow (Left,Title);
- with WndwStat[LI] do
- begin
- QwriteV (WSrow+2 ,WScol+5,Attr(white,magenta),StrE[1]);
- QwriteV (WSrow+4 ,WScol+2,Attr(yellow,brown) ,StrE[2]);
- for j:=3 to 6 do QwriteV (WSrow+2+j,WScol+2,Attr(white,brown) ,StrE[j]);
- end;
- end;
-
- procedure ShowFlicker;
- begin
- { -- Flicker Note -- }
- MakeWindow (11,22, 4,40,Attr(black,brown),Attr(black,brown),MixedBrdr);
- with WndwStat[LI] do
- begin
- for j:=1 to 2 do QwriteV (WSrow+j,WScol+2,-1,StrF[j]);
- end;
- end;
-
- procedure ShowScrollWindow;
- begin
- { -- ScrollWindow description -- }
- with WndwStat[LI] do
- begin
- GotoRC (WSrow+1,WSCol+1);
- for j :=1 to 19 do InsLine;
- for j :=1 to 19 do
- begin
- ScrollWindow (1,19,up);
- QwriteV (WSrow+19,WScol+1,-1,StrG[j])
- end
- end;
- end;
-
- procedure ShowTitleWindow;
- begin
- { -- TitleWindow description -- }
- MakeWindow (12,16,11,49,Attr(red,lightgray),Attr(red,lightgray),
- EvenSolidBrdr);
- TitleWindow (Left,Title);
- with WndwStat[LI] do
- begin
- QwriteV (WSrow+2 ,WScol+5,Attr(lightgreen,blue),StrH[1]);
- QwriteV (WSrow+4 ,WScol+2,Attr(black,lightgray),StrH[2]);
- for j:=3 to 6 do QwriteV (WSrow+2+j,WScol+2,Attr(green,lightgray),StrH[j]);
- end;
- end;
-
- procedure ShowSpecialEffects;
- begin
- { -- Special effects description -- }
- if Vmode<>7 then ShadowEffect:=Right;
- MakeWindow ( 6,25,14,49,Attr(black,green),Attr(white,green),DoubleBrdr);
- TitleWindow (Center,' Special Effects ');
- with WndwStat[LI] do
- begin
- for j:=1 to 2 do QwriteV (WSrow+1+j,WScol+2, -1,StrI[j]);
- for j:=3 to 5 do QwriteV (WSrow+2+j,WScol+2,Attr(white,green),StrI[j]);
- for j:=6 to 9 do QwriteV (WSrow+3+j,WScol+2, -1,StrI[j]);
- readln;
- Qfill (WSrow+2 ,WScol+2,11,45,Attr(black,green),' ');
- QwriteV (WSrow+2 ,WScol+2,Attr(white,green),StrI[10]);
- for j:=11 to 12 do QwriteV (WSrow+j-8,WScol+2, -1,StrI[j]);
- QwriteV (WSrow+6 ,WScol+2,Attr(white,green),StrI[13]);
- for j:=14 to 18 do QwriteV (WSrow+j-7,WScol+2, -1,StrI[j]);
- end;
- ShadowEffect:=NoDir;
- end;
-
- procedure ShowMaxWndw;
- begin
- { -- MaxWndw constant -- }
- MakeWindow (17, 9, 7,38,Attr(black,brown),Attr(black,brown),NoBrdr);
- TitleWindow (Center,'- WINDOW LIMITS -');
- with WndwStat[LI] do
- for j:=1 to 5 do QwriteV (WSrow+j,WScol,-1,StrJ[j]);
- end;
-
- procedure ShowQWIK30;
- begin
- { -- QWIK30.INC procedures -- }
- MakeWindow (8,20,15,51,Attr(yellow,red),Attr(yellow,red),EvenSolidBrdr);
- TitleWindow (Center,' QWIK Write Procedures ');
- with WndwStat[LI] do
- begin
- for j:=1 to 2 do QwriteV (WSrow+1+j,WScol+1, -1,StrK[j]);
- for j:=3 to 8 do QwriteV (WSrow+2+j,WScol+1,Attr(white,red),StrK[j]);
- for j:=9 to 10 do QwriteV (WSrow+3+j,WScol+1, -1,StrK[j])
- end;
- end;
-
- procedure ShowProgramming;
- begin
- { -- Programming for WINDOW34.INC -- }
- MakeWindow (2,25,23,50,Attr(yellow,magenta),Attr(yellow,magenta),
- MhatchBrdr);
- with WndwStat[LI] do
- for j:=1 to 20 do QwriteV (WSrow+1+j,WScol+1,-1,StrL[j]);
- end;
-
- procedure ShowEquipmentList;
- begin
- { -- Compatible computers and adapters for WINDOW34.INC -- }
- MakeWindow (4,35,17,34,Attr(black,brown),Attr(black,brown),MixedBrdr);
- TitleWindow (Center,' Software Compatibility ');
- with WndwStat[LI] do
- for j:=1 to 15 do QwriteV (WSrow+j,WScol+2,Attr(white,brown),StrM[j]);
- end;
-
- procedure ShowAuthor;
- begin
- { -- Author for WINDOW34.INC -- }
- if Vmode<>7 then ShadowEffect:=Right;
- MakeWindow (8,20,11,42,Attr(black,brown),Attr(black,brown),HhatchBrdr);
- with WndwStat[LI] do
- for j:=1 to 7 do QwriteV (WSrow+1+j,WScol+2,Attr(white,brown),StrN[j]);
- ShadowEffect:=NoDir;
- end;
-
- procedure ReadKB (VAR ExtKey: boolean; VAR Key: char);
- begin
- Read (Kbd,Key); { Read keyboard input. }
- if KeyPressed and (Key=EscKey) then { If first Char was ESC ... }
- begin
- Read (Kbd,Key); { ... read second char. }
- ExtKey := true
- end
- else ExtKey:=false;
- end;
-
- procedure GetKey;
- begin
- repeat
- ReadKB (ExtKey,Key);
- until (Key=RetKey) or (Key=EscKey);
- end;
-
- procedure FindNextStep;
- begin
- case Key of
- EscKey: begin
- if Step>0 then
- begin
- RemoveWindow;
- case Step of
- 5: for j:=1 to 11 do RemoveWindow;
- 7: begin
- ShowBorders;
- ShowRemoveWindow;
- end;
- 8: Step:=4;
- end; { case }
- Step:=Step-1
- end
- end;
- RetKey: begin
- Step:=Step+1;
- if Step in [9..14] then ZoomEffect:=true else ZoomEffect:=false;
- case Step of
- 7: for i:=0 to 12 do RemoveWindow;
- 8: RemoveWindow;
- end
- end;
- end { case }
- end;
-
- procedure ShowWindows;
- begin
- repeat
- GetKey;
- FindNextStep;
- if Key=RetKey then
- case Step of
- 1: ShowGeneral;
- 2: ShowList;
- 3: ShowInitWindow;
- 4: ShowMakeWindow;
- 5: ShowBorders;
- 6: ShowRemoveWindow;
- 7: ShowFlicker;
- 8: ShowScrollWindow;
- 9: ShowTitleWindow;
- 10: ShowSpecialEffects;
- 11: ShowMaxWndw;
- 12: ShowQWIK30;
- 13: ShowProgramming;
- 14: ShowEquipmentList;
- 15: ShowAuthor;
- end;
- until Step=16;
- end;
-
- procedure CheckCursor;
- var CursorMode: integer absolute $0040:$0060;
- begin
- if ActiveDD=MdaMono then
- if CursorMode=$0607 then
- CursorChange($0C0D,OldCursor);
- end;
-
- begin
- InitWindow (Attr(blue,lightgray));
- CheckCursor;
- CursorOff;
- Show30windows;
- ShowInitialScreen;
- ShowWindows;
- { -- Use the following statment to return to the original screen.-- }
- for i:=1 to LI do RemoveWindow;
- Qfill (1,1,25,80,Tattr,' ');
- QwriteC (12,1,80,Tattr,'(c) 1986,1987 James H. LeMay');
- QwriteC (13,1,80,Tattr,'This concludes the windows tutorial...');
- delay (2000);
- NormVideo;
- GotoRC (1,1);
- ClrScr;
- CursorOn;
- end.