home *** CD-ROM | disk | FTP | other *** search
- { QwikDemo.pas - Demo program for QWIK screen utilities. ver 4.0, 12-01-87 }
- { Demo has been programmed best for color cards. EGA and VGA should be in
- 25-line mode. }
-
- program QwikDemo;
-
- uses
- Crt, {$U Qwik40.tpu} Qwik;
-
- type
- BrdrRec = record { For Qbox procedure }
- TL,TH,TR,LV,RV,BL,BH,BR: char;
- end;
-
- var
- Row,Rows,Col,Cols,Step,ColMax: byte;
- i,Count,
- OldCursor,Fgrnd,Bgrnd: word;
- BrdrAttr, WndwAttr: integer;
- SavedBlock, PopUpBlock: array [1..4000] of byte;
- BlkRow,BlkCol,V: byte;
- ColL,ColR: array [1..3] of byte;
- Strng,Strng2,NumStr: string[75];
- Data: array [1..9 ] of string[40];
- PC: array [1..13] of string[40];
- Init: array [1.. 8] of string[40];
- Other:array [1..14] of string[40];
- Rnum: Real;
- Ch: char;
-
- const { These are double lines for Qbox }
- Border: BrdrRec = (TL:'╔';TH:'═';TR:'╗';
- LV:'║'; RV:'║';
- BL:'╚';BH:'═';BR:'╝');
- BWcolors: array[0..3] of byte = (
- 0, { Black on Black }
- 7, { LightGray on Black }
- $0F, { White on Black }
- $70); { Black on LightGray }
- Wait: word = 500; { One unit of wait in milliseconds for demo. }
-
- { Qbox is an application of QWIK screen utilities. It can make fast
- pop-up menus. See WINDOWxx.ARC for more applications. }
- procedure Qbox (Row,Col,Rows,Cols: byte; WndwAttr,BrdrAttr: integer;
- Brdr: BrdrRec);
- begin
- if (Rows>=2) and (Cols>=2) then
- begin
- with Brdr do
- begin
- Qwrite (Row ,Col ,BrdrAttr,TL);
- Qfill (Row ,Col+1 ,1 ,Cols-2,BrdrAttr,TH);
- Qwrite (Row ,Col+Cols-1 ,BrdrAttr,TR);
- Qfill (Row+1 ,Col ,Rows-2,1 ,BrdrAttr,LV);
- Qfill (Row+1 ,Col+Cols-1,Rows-2,1 ,BrdrAttr,RV);
- Qwrite (Row+Rows-1,Col ,BrdrAttr,BL);
- Qfill (Row+Rows-1,Col+1 ,1 ,Cols-2,BrdrAttr,BH);
- Qwrite (Row+Rows-1,Col+Cols-1 ,BrdrAttr,BR);
- Qfill (Row+1 ,Col+1 ,Rows-2,Cols-2,WndwAttr,' ')
- end
- end
- end;
-
- procedure PromptKey;
- begin
- Qwrite (25,CRTcols-19,-1,'press any key ...');
- Ch:=ReadKey;
- if Ch=#00 then Ch:=ReadKey;
- end;
-
- procedure CheckCursor;
- var CursorMode: integer absolute $0040:$0060;
- begin
- if ActiveDispDev=MdaMono then
- if CursorMode=$0607 then
- CursorChange($0B0C,OldCursor);
- end;
-
- function Attr (ForeGround,BackGround: byte): byte;
- begin
- Attr := ((BackGround shl 4) + ForeGround) and 127;
- end;
-
- procedure ExplodeScreen;
- var
- TopRow,BottomRow,MaxRows,MaxCols,DeltaCols,LeftCol,RightCol: byte;
- CenterCol: byte;
- MaxCount: word;
- begin
- CenterCol:=CRTcols shr 1;
- randomize;
- MaxCount:=40;
- for Step:=1 to 12 do
- begin
- { Set boundaries }
- TopRow:=13-Step;
- BottomRow:=13+Step;
- MaxRows:=Step;
- if VideoMode<=CO40 then { Keep aspect 1:1 }
- begin
- MaxCols:= MaxRows + MaxRows shr 2; { 1.2 cols/row }
- DeltaCols:=(Step*5 div 3);
- end
- else
- begin
- MaxCols:= MaxRows shl 1 + MaxRows shr 1; { 2.4 cols/row }
- DeltaCols:=(Step*10 div 3);
- end;
- LeftCol :=succ(CenterCol)-DeltaCols;
- RightCol :=CenterCol+DeltaCols;
- if Step=12 then MaxCount:=400;
- for Count:=1 to MaxCount do
- begin
- Rows:= succ(random(MaxRows));
- if VideoMode<=CO40 then { Keep aspect 1:1 }
- Cols:= Rows + Rows shr 2 { 1.2 cols/row }
- else Cols:= Rows shl 1 + Rows shr 1; { 2.4 cols/row }
- Col := LeftCol + random (RightCol-LeftCol-Cols+2);
- Row := TopRow + random (BottomRow-TopRow-Rows+2);
- if VideoMode=Mono then
- TextAttr:=BWcolors[(random(4))]
- else
- begin
- Fgrnd:= random (16);
- Bgrnd:= random (8);
- if Bgrnd=Fgrnd then inc(Fgrnd);
- TextAttr:=Attr(Fgrnd,Bgrnd);
- end;
- Qfill (Row,Col,Rows,Cols,TextAttr,#178);
- end
- end;
- end;
-
- begin
- { --- Set up data --- }
- { If you set a mode, do it first before Qinit! }
- { Please! Test a mode first to see if it is different than what you want; }
- { then change if necessary. Otherwise, the screen jumps. }
-
- if (VideoMode<>Mono) and not Have3270 then
- begin
- Qfill (1,1,25,CRTcols,7,' ');
- QwriteC (11,1,CRTcols,-1,'(1) 40 column mode');
- QwriteC (12,1,CRTcols,-1,'(2) 80 column mode');
- QwriteC (14,1,CRTcols,-1,'Which mode [1,2]? ');
- GotoRC (14,CRTcols div 2 + 9);
- repeat
- Ch:=ReadKey;
- until ch in ['1','2'];
- V:=VideoMode;
- case ch of
- '1': case V of
- BW80: V:=BW40;
- CO80: V:=CO40;
- end;
- '2': case V of
- BW40: V:=BW80;
- CO40: V:=CO80;
- end;
- end;
- if V<>VideoMode then
- begin
- TextMode(V);
- Qinit; { << Do Qinit again after change of mode!! }
- end;
- end;
- Strng:= ' Q Screen Utilities ';
- Strng2:= ' QWIK Screen Utilities ';
- Data[1]:= '1';
- Data[2]:= '22';
- Data[3]:= '333';
- Data[4]:= Strng;
- Data[5]:= 'Odd Length';
- Data[6]:= 'Even Length';
- Data[7]:= '18 characters wide';
- Data[8]:= '19 characters width';
- Data[9]:= 'Margin to Margin width';
- PC[1]:= 'COMPUTERS: ADAPTERS:';
- PC[2]:= '------------------ ----------';
- PC[3]:= 'IBM PC MDA';
- PC[4]:= 'IBM XT CGA';
- PC[5]:= 'IBM AT EGA';
- PC[6]:= 'IBM PCjr MCGA';
- PC[7]:= 'IBM PC Convertible VGA';
- PC[8]:= 'IBM PS/2 Model 25 8514/A';
- PC[9]:= 'IBM PS/2 Model 30 Hercules:';
- PC[10]:= 'IBM PS/2 Model 50 HGC';
- PC[11]:= 'IBM PS/2 Model 60 HGC Plus';
- PC[12]:= 'IBM PS/2 Model 80 InColor';
- PC[13]:= 'IBM 3270 PC';
- Other[1]:='QwriteA - for arrays/partial strings';
- Other[2]:='QfillC - a self-centering Qfill';
- Other[3]:='QattrC - a self-centering Qattr';
- Other[4]:='QviewPage - view any video page';
- Other[5]:='QwritePage - write to any video page';
- Other[6]:='';
- Other[7]:='GotoRC - position absolute cursor';
- Other[8]:='CursorChange - change cursor shape';
- Other[9]:='CursorOff - turns off cursor';
- Other[10]:='CursorOn - turns on cursor';
- Other[11]:='WhereR - absolute cursor row';
- Other[12]:='WhereC - absolute cursor column';
- Other[13]:='A total of 18 utilities';
- Other[14]:='compiling in only 1.6k bytes!';
- Init[1]:='∙ Detects dual monitor/adapters for all';
- Init[2]:=' systems listed on the previous page';
- Init[3]:='∙ Identifies each system by name';
- Init[6]:='∙ Gets System ID and Submodel ID';
- Init[4]:='∙ Sets video buffer segment';
- Init[5]:='∙ Determines need for wait-for-retrace';
- Init[7]:='∙ Gets screen dimensions: Row by Cols';
- Init[8]:='∙ Determines the number of video pages';
-
- { --- Initial screen --- }
- CheckCursor;
- CursorOff;
- Qfill ( 1, 1,25,CRTcols,Attr(white,blue),' '); { Clear Screen }
- QwriteC (11, 1,CRTcols,Attr(yellow,blue), Strng2);
- QwriteC (13, 1,CRTcols, -1,'Your screen is about to explode.');
- QwriteC (14, 1,CRTcols, -1,'Hold on to your seat ...');
- Delay (Wait*5);
-
- { --- Explosion of Boxes --- }
- Qfill (11, 1, 4,CRTcols, -1,' '); { Clear Lines }
- Qattr ( 1, 1,25,CRTcols,Attr(black,lightgray)); { New screen attribute }
- ExplodeScreen;
-
- QfillC (10, 1,CRTcols, 6,34,Red shl 4,' ');
- QfillC (11, 1,CRTcols, 4,30,Brown shl 4,' ');
- TextAttr:= Attr(yellow,red);
- QwriteC (12, 1,CRTcols,TextAttr,Strng2);
- QwriteC (13, 1,CRTcols,TextAttr,' Version 4.0 ');
-
- { --- Save Screen for Page Demo --- }
- if MaxPage>0 then
- begin
- QstoreToMem ( 1, 1,25,CRTcols,SavedBlock);
- QwritePage (1);
- QstoreToScr ( 1, 1,25,CRTcols,SavedBlock);
- QwritePage (0);
- end;
- { --- End of Save Screen --- }
- Delay (Wait*4);
- TextAttr:= Attr(white,blue);
- QwriteC ( 6, 1,CRTcols,TextAttr,' Qwrite will write with new attributes ');
- QwriteC ( 7, 1,CRTcols,TextAttr,' that you specify direct to the screen. ');
- Delay (Wait*6);
- QwriteC (18, 1,CRTcols, -1,'Qwrite will also use existing attributes');
- QwriteC (19, 1,CRTcols, -1,' when you do not even know or care. ');
- { highlight the word 'existing' }
- QattrC (18, 6,CRTcols+5,1,10,Attr(white,lightred));
- Delay (wait*10);
- QwriteC (21, 1,CRTcols,TextAttr,' Say Goodbye to this screen. ');
-
- Delay (wait*3);
- { --- Disintigrate Screen --- }
- for i:=1 to 5000 do
- begin
- Row:=random(25)+1;
- Col:=random(CRTcols)+1;
- Qfill (row,col, 1, 1,Black,' ');
- end;
-
- { --- Compatible computer and adapter list --- }
- Qfill ( 1, 1,25,CRTcols,white,' '); { Clear Screen }
- QwriteC ( 4, 1,CRTcols, -1,'QWIK Screen Utilities detects these IBM');
- QwriteC ( 5, 1,CRTcols, -1,'or compatible computers and adapters:');
- delay (wait*5);
- Col:=(CRTcols-30) shr 1;
- for Row:=7 to 19 do
- Qwrite (Row,Col, -1,PC[Row-6]);
- QwriteC ( 22, 1,CRTcols, -1,'Working text modes 0,1,2,3, or 7!');
- PromptKey;
-
- { --- Qinit detection --- }
- Qfill ( 1, 1,25,CRTcols,Attr(black,lightgray),' '); { Clear Screen }
- QwriteC ( 4, 1,CRTcols, -1,'To configure QWIK, Qinit not only');
- QwriteC ( 5, 1,CRTcols, -1,'detects computers/adapters, it:');
- delay (wait*5);
- Col:=(CRTcols-36) shr 1;
- for Row:=11 to 18 do
- Qwrite (Row,Col, -1,Init[Row-10]);
- PromptKey;
-
- { --- Qwrite with Str on Reals Demo --- }
- Qfill ( 1, 1,25,CRTcols,yellow,' '); { Clear Screen }
- QwriteC ( 2, 1,CRTcols, -1,'Qwrite with Turbo''s Str will write');
- QwriteC ( 3, 1,CRTcols, -1,'reals and integers faster:');
- Delay (wait*7);
- Rnum:=1.23E+05;
- for col:=0 to CRTcols div 20 -1 do
- for row:=5 to 24 do
- begin
- Rnum:=Rnum+1;
- Str(Rnum:12,NumStr);
- Qwrite (row,col*20+4, -1,NumStr);
- end;
- PromptKey;
-
- { --- Centering Demo --- }
- Qfill ( 1, 1,25,CRTcols,Attr(black,lightgray),' '); { Clear Screen }
- QwriteC ( 2, 1,CRTcols, -1,'QwriteC will automatically');
- QwriteC ( 3, 1,CRTcols, -1,'center your data ...');
- QwriteC ( 4, 1,CRTcols, -1,'(Odd breaks are shifted to the left.)');
- Delay (wait*6);
-
- { - Set up columns for varying column modes - }
- ColL[2]:=1; ColR[2]:=CRTcols;
- if CRTcols<80 then
- begin
- ColL[1]:=ColL[2]; ColL[3]:=CRTcols div 2;
- ColR[1]:=ColR[2]; ColR[3]:=CRTcols div 2;
- end
- else
- begin
- ColL[1]:=3; ColR[1]:=26; ColL[3]:=CRTcols-14; ColR[3]:=CRTcols-14;
- end;
-
- QwriteC ( 7,ColL[1],ColR[1], -1,'between margins ...');
- Qbox ( 8,(ColL[1]+ColR[1]) shr 1 -12,15,26,white,LightGray,Border);
- Delay (wait*3);
- for row:=11 to 19 do
- QwriteC (row,ColL[1],ColR[1], -1, Data[row-10]);
- Delay (wait*5);
-
- QwriteC ( 7,ColL[2],ColR[2], -1,'between two columns ...');
- QfillC ( 9,ColL[2],ColR[2],13,24,yellow,' '); { Clear window }
- for row:= 9 to 21 do
- QwriteC (row,ColL[2],ColR[2], -1,'><'); { Show two columns }
- Delay (wait*3);
- for row:=11 to 19 do
- QwriteC (row,ColL[2],ColR[2],LightRed, Data[row-10]);
- Delay (wait*5);
-
- QwriteC ( 7,ColL[3],ColR[3], -1,'or on a center line ...');
- QfillC ( 8,ColL[3],ColR[3],15,27,Attr(black,lightgray),' '); {Clear window}
- for row:=09 to 21 do { Show center line }
- QwriteC (row,ColL[3],ColR[3],Attr(black,lightgray),'|');
- Delay (wait*3);
- for row:=11 to 19 do
- QwriteC (row,ColL[3],ColR[3], -1, Data[row-10]);
- PromptKey;
-
- { --- Qfill Demo --- }
- Qfill ( 1, 1,25,CRTcols,white,' '); { Clear Screen }
- QwriteC ( 2, 1,CRTcols, -1,'Qfill as well as Qattr can fill');
- QwriteC ( 3, 1,CRTcols, -1,'your screen in several ways.');
- Delay (wait*7);
-
- QwriteC ( 7, 1,CRTcols, -1,'by rows ...');
- Delay (wait*3);
- for row:= 9 to 24 do
- Qfill (row, 2, 1,CRTcols-2,9+row,Chr(row+56));
- Delay (wait*5);
-
- Qfill ( 7, 1,19,CRTcols,white,' '); { Clear Lines }
- QwriteC ( 7, 1,CRTcols, -1,'by columns ...');
- Delay (wait*3);
- for col:=2 to CRTcols-2 do
- Qfill ( 9,col,16,1,16+col,chr(col+63));
- Delay (wait*5);
-
- Qfill ( 7, 1,19,CRTcols,white,' '); { Clear Lines }
- QwriteC ( 7, 1,CRTcols, -1,'or by row-by-column blocks ...');
- Delay (wait*3);
- Qfill ( 9,2,16,CRTcols-2,Attr(yellow,blue),'!');
- Delay (wait*5);
-
- { --- Qbox demo --- }
- Qfill ( 1, 1,25,CRTcols,Attr(black,lightgray),' '); { Clear Screen }
- QwriteC ( 2, 1,CRTcols, -1,'Qbox is an application procedure made');
- QwriteC ( 3, 1,CRTcols, -1,'from Qwrite and Qfill. Together they');
- QwriteC ( 4, 1,CRTcols, -1,'can make windows with borders easy.');
- Delay (wait*9);
- QwriteC (14, 1,CRTcols, -1,'How about 100 of them? ... ');
- Delay (wait*4);
- ColMax:=CRTcols-21;
- for i:=1 to 100 do
- begin
- row:=random (10)+6;
- col:=random (ColMax)+2;
- if VideoMode=Mono then
- begin
- BrdrAttr:=BWcolors[random(4)];
- WndwAttr:=BWcolors[random(4)];
- end
- else
- begin
- BrdrAttr:=random (128);
- WndwAttr:=random (128);
- end;
- Qbox (row,col,10,20,BrdrAttr,WndwAttr,Border);
- end;
- Delay (wait*10);
-
- { --- Block Transfer and PopUp Demo --- }
- Qfill ( 1, 1,25,CRTcols,yellow,'?'); { Clear Screen }
- QfillC (10, 1,CRTcols, 6,40,Brown shl 4,' '); { Clear Block }
- QwriteC (11, 1,CRTcols, -1,'Qstore will save and restore');
- QwriteC (12, 1,CRTcols, -1,'Row-by-Column blocks on your display.');
- QwriteC (13, 1,CRTcols, -1,'It is so fast, I have to slow it down');
- QwriteC (14, 1,CRTcols, -1,'so you can see it.');
- Delay (wait*11);
- BlkRow:=8;
- BlkCol:=CRTcols div 2 - 9;
- QstoreToMem(BlkRow,BlkCol,10,20,SavedBlock);
- { --- Make a Pop Up Menu --- }
- Qbox (BlkRow,BlkCol,10,20,Attr(yellow,blue),Attr(brown,blue),Border);
- QwriteC (BlkRow+4,BlkCol,BlkCol+20, -1,'Pop Up');
- QwriteC (BlkRow+5,BlkCol,BlkCol+20, -1,'Menu');
- { --- End of Pop Up Menu --- }
- QstoreToMem(BlkRow,BlkCol,10,20,PopUpBlock);
- Delay (wait*4);
- ColMax:=CRTcols-20;
- for i:=1 to 30 do
- begin
- Delay (Wait div 2);
- QstoreToScr(BlkRow,BlkCol,10,20,SavedBlock);
- BlkRow:=random(15)+1;
- BlkCol:=random(ColMax)+1;
- QstoreToMem(BlkRow,BlkCol,10,20,SavedBlock);
- QstoreToScr(BlkRow,BlkCol,10,20,PopUpBlock);
- end;
-
- { --- Page Demo --- }
- if MaxPage>0 then
- begin
- QviewPage (1);
- QwritePage (1);
- TextAttr:= Attr(yellow,blue);
- QwriteC (20, 1,CRTcols,TextAttr,' Remember this page? ');
- QwriteC (21, 1,CRTcols,TextAttr,' It wasn''t destroyed, but saved using ');
- QwriteC (22, 1,CRTcols,TextAttr,' Qstores and placed on a new page. ');
- Delay (wait*14);
- QwritePage (0);
- QviewPage (0);
- end;
-
- { --- Other Utilities Demo --- }
- Qfill ( 1, 1,25,CRTcols,white,' '); { Clear Screen }
- QwriteC ( 4, 1,CRTcols, -1,'Here are more handy');
- QwriteC ( 5, 1,CRTcols, -1,'QWIK Screen Utilities:');
- delay (wait*5);
- Col:=(CRTcols-38) shr 1;
- for Row:=8 to 19 do
- Qwrite (Row,Col, -1,Other[Row-7]);
- for Row:=21 to 22 do
- QwriteC (Row,1,CRTcols,-1,Other[Row-8]);
- PromptKey;
-
- { --- Attribute Demo --- }
- Qfill ( 1, 1,25,CRTcols,Attr(green,green),' '); { Clear Screen }
- TextAttr:= Attr(white,green);
- QwriteC ( 2, 1,CRTcols,TextAttr,'QWIK Screen Utilities are hiding data');
- QwriteC ( 3, 1,CRTcols,TextAttr,'on your screen ...');
- Cols:=CRTcols div 20;
- if VideoMode=7 then TextAttr:=0 else TextAttr:= Attr(green,green);
- for col:=0 to Cols-1 do
- for row:=5 to 20 do
- Qwrite (row,20*col+1,TextAttr,Strng);
- Delay (wait*8);
-
- Qfill ( 2, 1, 2,CRTcols,-1,' '); { Clear Lines }
- TextAttr:= Attr(white,green);
- QwriteC ( 2, 1,CRTcols,TextAttr,'Qattr can show them -');
- QwriteC ( 3, 1,CRTcols,TextAttr,'by merely changing the attribute!');
- Delay (wait*6);
-
- { --- Try using Turbo's color procedures this time --- }
- TextColor (Black); TextBackground (Green);
- Qattr ( 5, 1,16,CRTcols,TextAttr); { Reveal Data }
- Delay (wait*5);
-
- Qfill ( 2, 1, 2,CRTcols,-1,' '); { Clear Lines }
- TextColor (yellow); TextBackground (Green);
- QwriteC ( 2, 1,CRTcols,TextAttr,'Or even just emphasize what''s seen ...');
- for i:=1 to 500 do
- begin
- Row:= random(16) + 5;
- Col:= random(Cols)*20+1;
- Qattr (Row,Col, 1,20,46);
- Delay (3);
- Qattr (Row,Col, 1,20,32);
- end;
- for i:=1 to Cols do { Emphasize Data }
- Qattr ( 5*i,(i-1)*20+1, 1,20,yellow + (lightgreen shl 4));
- Qattr (21, 1, 5,CRTcols,TextAttr);
- QwriteC (22, 1,CRTcols,TextAttr,' (c) 1986,1987 James H. LeMay ');
- GotoRC (23, 1);
- CursorOn;
- end.