' ÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄ
'
'                           Q D E M O _ A . B A S
'
'  This file is a subcomponent of the QBSCR Screen Routines Demonstration
'  program QDEMO. It is not meant to run as a standalone program. Use only
'  in conjunction with the QDEMO.BAS program.  See QBSCR documentation or
'  QDEMO.BAS for more information.
'
' ÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄ

'$INCLUDE: 'qbscr.inc'
'$INCLUDE: 'mouse.bi'

COMMON SHARED kolor%
COMMON SHARED mouseExists%

CONST CANTDOBRIGHTBACKS = -1
CONST NOCOLORON3D = -2
CONST NEEDMOUSE = -3
CONST NEEDMOUSE4GETEVENT = -4
CONST CANTDOEGAVGACOLORS = -5
CONST NEEDCOLOR = -6
CONST GENINFOMISSING = -7
CONST QDEMO1CLRMISSING = -8
CONST QDEMO1MONMISSING = -9
CONST INFO3DMISSING = -10
CONST VIEWLISTMISSING = -11
CONST ORDERFORMMISSING = -12
CONST SELECTMISSING = -13
CONST QDEMO2CLRMISSING = -14
CONST QDEMO2MONMISSING = -15
CONST NEEDVGA = -16
CONST NOFONTS = -17

DECLARE SUB InfoBox (messageNum%)
DECLARE FUNCTION QuitVerification% ()

SUB InfoBox (messageNum%)

	' ***
	' *** Save what's underneath this error window.
	' ***
	IF mouseExists% THEN
		MouseHide
	END IF
	DIM scr%(BlockSize%(11, 70, 8, 19))
	BlockSave 11, 70, 8, 19, scr%(), GetVideoSegment!

	' ***
	' *** Make a window and all the rot that goes with it.
	' ***
	IF kolor% THEN
		ft1% = 6
		ft2% = 7
	ELSE
		ft1% = 0
		ft2% = 0
	END IF
	MakeWindow 8, 11, 19, 70, 0, 7, 0, ft1%, -1, 0, ""
	Center "Hey!", 9
	MakeWindow 10, 13, 15, 68, 0, 7, 0, ft2%, -1, 0, ""
	IF kolor% THEN
		DrawButton SINGLEBORDER, 13, 16, 22, 18, 0, 7, "OK", STYLE3D
	ELSE
		DrawButton SINGLEBORDER, 13, 16, 22, 18, 0, 7, "OK", STYLE2D
	END IF

	' ***
	' *** Draw in the appropriate error message.
	' ***
	COLOR 0, 7
	SELECT CASE messageNum%
		CASE CANTDOBRIGHTBACKS
			LOCATE 11, 15, 0: PRINT "Sorry!  You are not using hardware that allows the";
			LOCATE 12, 15, 0: PRINT "use of Bright Backgrounds.  You must have a color";
			LOCATE 13, 15, 0: PRINT "monitor and video card of some sort.  Once again,";
			LOCATE 14, 15, 0: PRINT "those with monochrome get the shaft.";
		CASE NOCOLORON3D
			LOCATE 11, 15, 0: PRINT "Sorry, but you need a color monitor and video card";
			LOCATE 12, 15, 0: PRINT "to use any of the 3D stuff.  Try the Input or the";
			LOCATE 13, 15, 0: PRINT "Display demos, or perhaps something from the Other";
			LOCATE 14, 15, 0: PRINT "category.  Most else will work in monochrome.";
		CASE NEEDMOUSE
			LOCATE 11, 15, 0: PRINT "You must have a working mouse attached to this ma-";
			LOCATE 12, 15, 0: PRINT "chine in order for the mouse demos to function.";
			LOCATE 13, 15, 0: PRINT "One was not detected by this program.";
		CASE NEEDMOUSE4GETEVENT
			LOCATE 11, 15, 0: PRINT "This demo shows how to utilize the GetEvent func-";
			LOCATE 12, 15, 0: PRINT "tion, but it is pretty useless without a mouse. If";
			LOCATE 13, 15, 0: PRINT "you need to handle keyboard events only, then use";
			LOCATE 14, 15, 0: PRINT "the QuickBASIC INKEY$ or INPUT$() functions.";
		CASE NEEDCOLOR
			LOCATE 11, 15, 0: PRINT "The action you tried to perform required a color";
			LOCATE 12, 15, 0: PRINT "video card AND monitor.  These were not detected";
			LOCATE 13, 15, 0: PRINT "on your system.  Perhaps you could try again on a";
			LOCATE 14, 15, 0: PRINT "different machine with color capability.";
		CASE CANTDOEGAVGACOLORS
			LOCATE 11, 15, 0: PRINT "Sorry - this portion of the demo requires an EGA or";
			LOCATE 12, 15, 0: PRINT "VGA video card and display.  If you had either of";
			LOCATE 13, 15, 0: PRINT "those, the nifty colors would now be before your";
			LOCATE 14, 15, 0: PRINT "eyes.  Since you don't, you'll have to do without.";
		CASE GENINFOMISSING
			LOCATE 11, 15, 0: PRINT "The file called GENINFO.TXT is not on disk in the";
			LOCATE 12, 15, 0: PRINT "current directory.  It contains the text to display";
			LOCATE 13, 15, 0: PRINT "for this function.  Please locate it before trying";
			LOCATE 14, 15, 0: PRINT "this again.";
		CASE QDEMO1CLRMISSING
			LOCATE 11, 15, 0: PRINT "The file called QDEMO_1.CLR is not on disk in the";
			LOCATE 12, 15, 0: PRINT "current directory.  It contains the screen to show";
			LOCATE 13, 15, 0: PRINT "for this function.  Please locate it before trying";
			LOCATE 14, 15, 0: PRINT "this again.";
		CASE QDEMO1MONMISSING
			LOCATE 11, 15, 0: PRINT "The file called QDEMO_1.MON is not on disk in the";
			LOCATE 12, 15, 0: PRINT "current directory.  It contains the screen to show";
			LOCATE 13, 15, 0: PRINT "for this function.  Please locate it before trying";
			LOCATE 14, 15, 0: PRINT "this again.";
		CASE INFO3DMISSING
			LOCATE 11, 15, 0: PRINT "The file called INFO3D.TXT is not on disk in the";
			LOCATE 12, 15, 0: PRINT "current directory.  It contains the file to display";
			LOCATE 13, 15, 0: PRINT "for this function.  Please locate it before trying";
			LOCATE 14, 15, 0: PRINT "this again.";
		CASE VIEWLISTMISSING
			LOCATE 11, 15, 0: PRINT "The file called VIEWLIST.TXT is not on disk in the";
			LOCATE 12, 15, 0: PRINT "current directory.  It contains the file to display";
			LOCATE 13, 15, 0: PRINT "for this function.  Please locate it before trying";
			LOCATE 14, 15, 0: PRINT "this again.";
		CASE ORDERFORMMISSING
			LOCATE 11, 15, 0: PRINT "The file called ORDER.FRM is not on disk in the";
			LOCATE 12, 15, 0: PRINT "current directory.  It contains the file to print";
			LOCATE 13, 15, 0: PRINT "for this function.  Please locate it before trying";
			LOCATE 14, 15, 0: PRINT "this again.";
		CASE SELECTMISSING
			LOCATE 11, 15, 0: PRINT "The file called SELECT.TXT is not on disk in the";
			LOCATE 12, 15, 0: PRINT "current directory.  It contains the list of items";
			LOCATE 13, 15, 0: PRINT "for this function.  Please locate it before trying";
			LOCATE 14, 15, 0: PRINT "this again.";
		CASE QDEMO2CLRMISSING
			LOCATE 11, 15, 0: PRINT "The file called QDEMO_2.CLR is not on disk in the";
			LOCATE 12, 15, 0: PRINT "current directory.  It contains the screen image to";
			LOCATE 13, 15, 0: PRINT "be displayed here.  Please locate it before trying";
			LOCATE 14, 15, 0: PRINT "this again.";
		CASE QDEMO2MONMISSING
			LOCATE 11, 15, 0: PRINT "The file called QDEMO_2.MON is not on disk in the";
			LOCATE 12, 15, 0: PRINT "current directory.  It contains the screen image to";
			LOCATE 13, 15, 0: PRINT "be displayed here.  Please locate it before trying";
			LOCATE 14, 15, 0: PRINT "this again.";
		CASE NEEDVGA
			LOCATE 11, 15, 0: PRINT "Sorry, this demo requires a VGA card and display,";
			LOCATE 12, 15, 0: PRINT "and these weren't detected on your system.  You may";
			LOCATE 13, 15, 0: PRINT "attempt this on a different machine, appropriatley";
			LOCATE 14, 15, 0: PRINT "equipped.";
		CASE NOFONTS
			LOCATE 11, 15, 0: PRINT "This routine requires access to font files (*.VGA),";
			LOCATE 12, 15, 0: PRINT "but could not find any.  Make sure that these files";
			LOCATE 13, 15, 0: PRINT "exist before trying this demo again.";
		CASE ELSE
	END SELECT

	' ***
	' *** Sit in a loop waiting on events.  If the user says OK in one way or
	' *** another, then get outta here.
	' ***
	done% = FALSE
	WHILE done% = FALSE

		IF mouseExists% THEN
			MouseShow
		END IF
		result% = getEvent(mouseExists%, kc%, mx%, my%)

		SELECT CASE result%
			CASE EMpressedLeft
				IF (mx% >= 13) AND (mx% <= 22) AND (my% >= 16) AND (my% <= 18) THEN
					IF kolor% THEN
						PressButton SINGLEBORDER, 13, 16, 22, 18, 0, 7, "OK", STYLE3D
					ELSE
						PressButton SINGLEBORDER, 13, 16, 22, 18, 0, 7, "OK", STYLE2D
					END IF
					done% = TRUE
				END IF
			CASE EKpressed
				IF kc% = ASC("O") OR kc% = ASC("o") OR kc% = 27 OR kc% = 13 THEN
					done% = TRUE
				END IF
			CASE ELSE
		END SELECT
	
	WEND

	' ***
	' *** Restore the screen, now that were leaving.
	' ***
	IF mouseExists% THEN
		MouseHide
	END IF
	BlockRestore 11, 70, 8, 19, scr%(), GetVideoSegment!

END SUB

SUB Interface

	' ÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄ
	'  This routine draws the interface for the main menu.  This includes the
	'  wide, short window for the menu bar, the frame around the whole mess,
	'  and the copyright window.
	' ÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄ

	' ÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄ
	'  First, draw the screen background and frame.
	' ÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄ
	IF mouseExists% THEN
		MouseHide
	END IF

	COLOR 0, 7
	CLS
	IF kolor% THEN
		ft% = 7: ft2% = 6
	ELSE
		ft% = 0: ft2% = 0
	END IF
	MakeWindow 1, 2, 25, 79, 0, 7, 0, ft%, -1, 0, ""

	' ÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄ
	'  Now add the copyright notice.  Here we'll show you a neat trick for
	'  placing unmodifiable copyright notices in your programs.  So that
	'  your name cannot be modified, use the CHR$() function and the ASCII
	'  codes for your name.  This way, the literal string will not be stored
	'  in the EXE file, but rather numerical codes that will not be sequential
	'  and therefore nearly impossible to change in the EXE.
	' ÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄ
	MakeWindow 14, 8, 23, 73, 0, 7, 0, ft%, -1, 0, ""
	MakeWindow 15, 19, 17, 62, 0, 7, 0, ft2%, -1, 0, ""
	COLOR 0, 7
	Center "ùùù The QBSCR Screen Routines Demo ùùù", 16
	Center "This program, all source code for the QBSCR Screen Routines,", 19
	Center "and all associated documentation are copyright (c) 1992 by", 20
	st$ = ""
	'               'T'         'o'         'n'         'y'        ' '
	st$ = st$ + CHR$(84) + CHR$(111) + CHR$(110) + CHR$(121) + CHR$(32)
	'               'M'        'a'         'r'         't'         'i'         'n'
	st$ = st$ + CHR$(77) + CHR$(97) + CHR$(114) + CHR$(116) + CHR$(105) + CHR$(110)
	Center st$ + ".  Register your shareware if you use it!", 21

	' ÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄ
	'  Finally, add the window for the menu bar.
	' ÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄ
	MakeWindow 2, 4, 4, 77, 0, 7, 0, ft2%, -1, 0, ""

END SUB

SUB OpeningScreen

	' ÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄ
	'  This displays an opening screen and waits on the user to hit a key or
	'  click the Begin button.
	' ÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄ

	' ÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄ
	'  Display the screen if the file exists.  If not, then exit and go right
	'  into the program.
	' ÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄ
	IF kolor% THEN
		bs% = STYLE3D
	ELSE
		bs% = STYLE2D
	END IF

	IF mouseExists% THEN
		MouseHide
	END IF

	RANDOMIZE TIMER
	IF kolor% THEN
		IF FirstFile%("QDEMO.CLR", NormalAttr, dta$) THEN
			BuildScreen "QDEMO.CLR", INT(RND(1) * 19)
		ELSE
			EXIT SUB
		END IF
	ELSE
		IF FirstFile%("QDEMO.MON", NormalAttr, dta$) THEN
			BuildScreen "QDEMO.MON", INT(RND(1) * 19)
		ELSE
			EXIT SUB
		END IF
	END IF
	LOCATE 1, 1, 0

	' ÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄ
	'  Sit in a loop waiting for the user to do something.  If they do the
	'  right thing, then move on.
	' ÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄ
	done% = FALSE
	IF mouseExists% THEN
		MouseShow
	END IF
	WHILE done% = FALSE

		result% = getEvent%(mouseExists%, kc%, mx%, my%)

		SELECT CASE result%
			CASE EMpressedLeft
				IF (mx% >= 9) AND (mx% <= 21) AND (my% >= 20) AND (my% <= 22) THEN
					PressButton SINGLEBORDER, 9, 20, 21, 22, 0, 7, "Begin", bs%
					done% = TRUE
				END IF
			CASE EKpressed
				IF (kc% = ASC("B")) OR (kc% = ASC("b")) OR (kc% = 13) THEN
					done% = TRUE
				END IF
			CASE ELSE
		END SELECT

	WEND

	' ÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄ
	'  Clear the screen in an interesting fashion.
	' ÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄ
	COLOR 0, 7
	IF mouseExists% THEN
		MouseHide
	END IF
	ClrScr 17, " "

END SUB

FUNCTION QuitVerification%

	' ÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄ
	'  This routine displays an OK/Cancel box and requests Quit verification
	'  from the user.  If the user selects OK or ENTER or O (for OK), then
	'  this function returns TRUE (non-zero).  If the user selects Cancel,
	'  then this function returns FALSE (zero).  Most of the mechanics of
	'  this function are handled by the QBSCR routine OkCanceMessageBox%.
	' ÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄ

	' ÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄ
	'  Prepare for the OkMessageBox.
	' ÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄ
	IF mouseExists% THEN
		MouseHide
	END IF

	IF kolor% THEN
		ft% = 6
		bs% = STYLE3D
	ELSE
		ft% = 0
		bs% = STYLE2D
	END IF

	DIM txt$(3)
	txt$(1) = ""
	txt$(2) = "Are you sure you want to quit?"
	txt$(3) = ""
	QuitVerification% = OkCancelMessageBox%(21, 10, 60, 18, txt$(), 3, 2, 0, 7, ft%, -1, 0, "", mouseExists%, SINGLEBORDER, bs%)

END FUNCTION

