' ÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄ
'
'                           Q D E M O _ F . 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 NEEDMOUSE = -3
CONST QDEMO2CLRMISSING = -14
CONST QDEMO2MONMISSING = -15

DECLARE SUB InfoBox (messageNum%)
DECLARE SUB RandomWindows ()
DECLARE SUB DrawMouse (x%, y%)

SUB ButtonStatusDemo

	' ÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄ
	'  This demo will illustrate the use of the QBSCR MouseButtonStatus
	'  routine.  A dummy mouse will be displayed and buttons will be depressed
	'  as the real mouse buttons are pressed.  ESC exits.
	' ÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄ

	' ÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄ
	'  If there is noe mouse attached to this machine, then exit straight
	'  away.  Well, perhaps not exactly straight away, since we will be
	'  telling the user first that they can't use this demo since there is
	'  no mouse attached.  But then, after that, VOOOOM! we're outta here.
	' ÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄ
	IF mouseExists% = FALSE THEN
		InfoBox NEEDMOUSE
		EXIT SUB
	END IF

	' ÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄ
	'  Define color-based data.
	' ÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄ
	IF kolor% THEN
		ft1% = 6
		ft2% = 7
		bs% = STYLE3D
	ELSE
		ft1% = 0
		ft2% = 0
		bs% = STYLE2D
	END IF

	' ÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄ
	'  Make a window to house the demo, and then add other goodies and text.
	' ÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄ
	MouseHide
	MakeWindow 5, 8, 23, 73, 0, 7, 0, ft1%, -1, 0, ""    ' The window itself.
	DrawButton SINGLEBORDER, 56, 19, 65, 21, 0, 7, "Done", bs%   ' Done Button.
	DrawMouse 34, 14                       ' Draw the standard mouse body.
	COLOR 0, 7
	FOR i% = 6 TO 12                       ' Now add the mouse cable.
		LOCATE i%, 41, 0: PRINT CHR$(186);
	NEXT i%
	LOCATE 13, 41, 0: PRINT CHR$(240);
	LOCATE 7, 11, 0: PRINT "Using the MouseButtonStatus";
	LOCATE 8, 11, 0: PRINT "routine, you can easily de-";
	LOCATE 9, 11, 0: PRINT "termine the up or down state";
	LOCATE 10, 11, 0: PRINT "of both mouse buttons at any";
	LOCATE 11, 11, 0: PRINT "particular instant.";
	LOCATE 13, 11, 0: PRINT "When you click your";
	LOCATE 14, 11, 0: PRINT "left and right mouse";
	LOCATE 15, 11, 0: PRINT "buttons up and down,";
	LOCATE 16, 11, 0: PRINT "the buttons on the";
	LOCATE 17, 11, 0: PRINT "middle of this window";
	LOCATE 18, 11, 0: PRINT "will also move up and";
	LOCATE 19, 11, 0: PRINT "down to show that we";
	LOCATE 20, 11, 0: PRINT "detecting the status";
	LOCATE 21, 11, 0: PRINT "of the mouse buttons.";

	LOCATE 7, 45, 0: PRINT "There are many other low-";
	LOCATE 8, 45, 0: PRINT "level mouse routines in the";
	LOCATE 9, 45, 0: PRINT "QBSCR package that let you";
	LOCATE 10, 45, 0: PRINT "determine such things as";
	LOCATE 11, 45, 0: PRINT "mouse movement, position,";
	LOCATE 12, 45, 0: PRINT "and configuration.";
	LOCATE 14, 51, 0: PRINT "To end this demo, hit";
	LOCATE 15, 51, 0: PRINT "the ESC or D key, or";
	LOCATE 16, 51, 0: PRINT "left-click the mouse";
	LOCATE 17, 51, 0: PRINT "on the Done button.";

	' ÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄ
	'  Now sit in a loop waiting for events.  Since we are going to demon-
	'  strate the use of the MouseButtonStatus function, we will not be using
	'  the GetEvent function here.  Hence, things will be a little more
	'  complicated.
	' ÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄ

	MouseShow
	done% = FALSE
	lStatus% = BUTTONUP
	rStatus% = BUTTONUP
	oldlStatus% = lStatus%
	oldrStatus% = rStatus%
 
	WHILE done% = FALSE

		' ÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄ
		'  Have any of the mouse buttons changed status?  If they have, then
		'  hide the mouse, update the display, and reshow the mouse.  Note that
		'  The MouseButtonStatus function has a provision for determining the
		'  status of the center button of a three button mouse.  This works
		'  most of the time, but since there is no standard for 3-button mice,
		'  I wouldn't trust it.  That's why we're only using two.
		' ÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄ
		MouseButtonStatus lStatus%, rStatus%, cStatus%
		IF (lStatus% <> oldlStatus%) OR (rStatus% <> oldrStatus%) THEN
			MouseHide
			IF (lStatus% <> oldlStatus%) THEN  ' The LEFT button status changed.
				oldlStatus% = lStatus%           ' Synchronize status indicators.
				IF lStatus% = BUTTONDOWN THEN    ' If button was down, draw pressed.
					IF kolor% THEN
						DepressedBox SINGLEBORDER, 36, 15, 40, 17, 0, 7, bs%
					ELSE
						LOCATE 15, 36, 0: PRINT "ÜÜÜÜÜ";
						LOCATE 16, 36, 0: PRINT "ÛÛÛÛÛ";
						LOCATE 17, 36, 0: PRINT "ßßßßß";
					END IF
					' Was the button pressed in the Done button?
					MousePosition mx%, my%
					mx% = (mx% \ 8) + 1
					my% = (my% \ 8) + 1
					IF (mx% >= 56) AND (mx% <= 65) AND (my% >= 19) AND (my% <= 21) THEN
						PressButton SINGLEBORDER, 56, 19, 65, 21, 0, 7, "Done", bs%
						done% = TRUE
					END IF
				ELSE
					IF kolor% = FALSE THEN
						LOCATE 16, 37, 0: PRINT "   ";
					END IF
					RaisedBox SINGLEBORDER, 36, 15, 40, 17, 0, 7, bs%
				END IF
			END IF
			IF (rStatus% <> oldrStatus%) THEN  ' The RIGHT button status changed.
				oldrStatus% = rStatus%
				IF rStatus% = BUTTONDOWN THEN    ' If button was down, draw pressed.
					IF kolor% THEN
						DepressedBox SINGLEBORDER, 42, 15, 46, 17, 0, 7, bs%
					ELSE
						LOCATE 15, 42, 0: PRINT "ÜÜÜÜÜ";
						LOCATE 16, 42, 0: PRINT "ÛÛÛÛÛ";
						LOCATE 17, 42, 0: PRINT "ßßßßß";
					END IF
				ELSE
					IF kolor% = FALSE THEN
						LOCATE 16, 43, 0: PRINT "   ";
					END IF
					RaisedBox SINGLEBORDER, 42, 15, 46, 17, 0, 7, bs%
				END IF
			END IF
			MouseShow
		END IF
 
		' ÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄ
		'  Test the keyboard to see if the D, d or ESC keys were pressed.  If
		'  so, then we're done.
		' ÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄ
		kc$ = UCASE$(INKEY$)
		IF (kc$ = CHR$(27)) OR (kc$ = "D") THEN
			done% = TRUE
		END IF
		
	WEND
 
END SUB

SUB DisplayScreensDemo

	' ÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄ
	'  This routine will demonstrate the QBSCR BuildScreen routine, which
	'  displays premade screens in interesting ways.  Need file QDEMO_2.CLR
	'  or QDEMO_2.MON to work.
	' ÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄ
	DIM scr%(BlockSize%(1, 80, 1, 25))

	' ÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄ
	'  Check for thefile we need straight away, since this doesn't work if we
	'  don't have it.  If we don't have it, display a message and exit.
	' ÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄ
	IF kolor% THEN
		ft1% = 6
		ft2% = 7
		demofile$ = "QDEMO_2.CLR"
		errorCode% = QDEMO2CLRMISSING
	ELSE
		ft1% = 0
		ft2% = 0
		demofile$ = "QDEMO_2.MON"
		errorCode% = QDEMO2MONMISSING
	END IF

	IF (FirstFile%(demofile$, NormalAttr, dta$) = FALSE) THEN
		InfoBox errorCode%
		EXIT SUB
	END IF

	' ÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄ
	'  Display a screen explaining the BuildScreen function.  Then allow the
	'  user to enter a display mode (0-18).
	' ÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄ
	MakeWindow 5, 8, 23, 73, 0, 7, 0, ft1%, -1, 0, ""
	MakeWindow 20, 38, 22, 43, 0, 7, 0, ft2%, -1, 0, ""
	COLOR 0, 7
	Center "úúú The BuildScreen Routine úúú", 7
	LOCATE 9, 11, 0: PRINT "The QBSCR BuildScreen routine allows you to display screens";
	LOCATE 10, 11, 0: PRINT "that have been created the the Screen Builder program, in-";
	LOCATE 11, 11, 0: PRINT "cluded with the QBSCR Screen Routines.";
	LOCATE 13, 11, 0: PRINT "BuildScreen will display your premade screens in any of 19";
	LOCATE 14, 11, 0: PRINT "interesting ways.  Wipes, disolves, blinds, you name it. To";
	LOCATE 15, 11, 0: PRINT "see any of these display modes, enter a number from 0 to 18";
	LOCATE 16, 11, 0: PRINT "in the box below.  A screen will be displayed in the mode";
	LOCATE 17, 11, 0: PRINT "you enter.  To quit, hit the ESC key.";

	' ÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄ
	'  Save the entire screen so that we can quickly restore it after the
	'  premade screen has been displayed.
	' ÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄ
	BlockSave 1, 80, 1, 25, scr%(), GetVideoSegment!
 
	' ÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄ
	'  While the user is not done, display the screen QDEMO_2.CLR/.MON in
	'  whatever mode they desire.  When they hit esc, exit.
	' ÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄ
	done% = FALSE
	WHILE done% = FALSE

		mode$ = "  "
		DO
			EditString mode$, 40, 21, 0, 7
		LOOP UNTIL VAL(mode$) >= 0 AND VAL(mode$) <= 18
		IF LTRIM$(mode$) = "" THEN
			done% = TRUE
		ELSE
			IF kolor% THEN
				BuildScreen "QDEMO_2.CLR", VAL(mode$)
			ELSE
				BuildScreen "QDEMO_2.MON", VAL(mode$)
			END IF
			LOCATE , , 0
			IF mouseExists% THEN
				MouseOrKeyboardPause
			ELSE
				dummy$ = INPUT$(1)
			END IF
			BlockRestore 1, 80, 1, 25, scr%(), GetVideoSegment!
		END IF
 
	WEND

END SUB

SUB MouseInfoDemo

	' ÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄ
	'  This demo illustrates the information you can extract about the mouse
	'  using the QBSCR routine MouseInfo.
	' ÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄ

	' ÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄ
	'  If the mouse ain't around, get outta here.
	' ÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄ
	IF mouseExists% = FALSE THEN
		InfoBox NEEDMOUSE
		EXIT SUB
	END IF
 
	' ÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄ
	'  Set color-dependent data.
	' ÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄ
	IF kolor% THEN
		ft1% = 6
		ft2% = 7
		bs% = STYLE3D
	ELSE
		ft1% = 0
		ft2% = 0
		bs% = STYLE2D
	END IF

	' ÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄ
	'  Make a window with a button and display some info in it.
	' ÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄ
	MouseHide
	MakeWindow 3, 8, 23, 73, 0, 7, 0, ft1%, -1, 0, ""
	MakeWindow 15, 21, 19, 60, 0, 7, 0, ft2%, -1, 0, ""
	DrawButton SINGLEBORDER, 11, 20, 20, 22, 0, 7, "Done", bs%
	Center "úúú The MouseInfo Routine úúú", 5
	COLOR 0, 7
	Center "This routine allows you to determine a few bits of info", 7
	Center "about the mouse attached to the system.  This includes the", 8
	Center "mouse driver version number, the type of mouse attached,", 9
	Center "and the IRQ number the mouse interrupt is using.", 10
	Center "The info below shows what the MouseInfo routine has", 12
	Center "determined about your mouse.  When you are finished", 13
	Center "reading it, hit ESC or D, or left-click the Done button.", 14

	' ÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄ
	'  Get mouse information and display it.
	' ÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄ
	MouseInfo dv$, mt%, irqNum%
	LOCATE 16, 24, 0: PRINT "Mouse Driver Version: "; dv$;
	LOCATE 17, 24, 0: PRINT "Mouse IRQ Number    :"; irqNum%;
	SELECT CASE mt%
		CASE BUSMOUSE: mtype$ = "BUS"
		CASE SERIALMOUSE: mtype$ = "SERIAL"
		CASE INPORTMOUSE: mtype$ = "IN PORT"
		CASE PS2MOUSE: mtype$ = "PS/2 MOUSE"
		CASE HEWLETTPACKARDMOUSE: mtype$ = "Hewlett Packard Mouse"
		CASE ELSE
	END SELECT
	LOCATE 18, 24, 0: PRINT "Mouse Type          : "; mtype$;

	' ÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄ
	'  Now wait on user actions.
	' ÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄ
	done% = FALSE
	MouseShow
	WHILE done% = FALSE

		result% = getEvent%(mouseExists%, kc%, mx%, my%)

		SELECT CASE result%
		CASE EMpressedLeft      ' Left mouse button pressed.
			IF (mx% >= 11) AND (mx% <= 20) AND (my% >= 20) AND (my% <= 22) THEN
				PressButton SINGLEBORDER, 11, 20, 20, 22, 0, 7, "Done", bs%
				done% = TRUE
			END IF
		CASE EMpressedRight     ' Right mouse button pressed.
			done% = TRUE
		CASE EKpressed          ' Keyboard key pressed.
			IF (kc% = 27) OR (kc% = ASC("D")) OR (kc% = ASC("d")) THEN
				done% = TRUE
			END IF
		CASE ELSE
		END SELECT

	WEND

END SUB

SUB RandomWindows

	' ÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄ
	'  This routine is called by the WindowsDemo routine, and simply generates
	'  gobs of random windows.  Hitting the spacebar will pause (and resume)
	'  the display of windows, while the ESC key will terminate the demo.
	' ÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄ

	winNum& = 0
	RANDOMIZE TIMER

	' ÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄ
	'  If the mouse is around, make sure to turn him off before displaying.
	' ÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄ
	IF mouseExists% THEN
		MouseHide
	END IF
 
	' ÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄ
	'  Sit in a loop doing all this stuff.
	' ÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄ
	done% = FALSE
	BlinkOff
	WHILE done% = FALSE

		' ÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄ
		'  Generate coordinates for the window.  Note that the lower right
		'  x and y have to be greater than their upper left counterparts.
		' ÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄ
		x1% = INT(RND(1) * 70) + 1       ' Maximum upper left X is 70.
		y1% = INT(RND(1) * 23) + 1       ' Maximum upper left Y is 23.
		x2% = INT(RND(1) * (75 - x1%)) + x1% + 4
		y2% = INT(RND(1) * (24 - y1%)) + y1% + 1

		' ÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄ
		'  Generate random colors for the window.  Note that we have turned the
		'  blinking attributes OFF using the QBSCR routine BlinkOff. This makes
		'  16 background colors available by adding 16 to the foreground value.
		' ÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄ
		IF kolor% THEN
			fg% = INT(RND(1) * 32)
			bg% = INT(RND(1) * 8)
		ELSE
			temp% = INT(RND(1) * 3)
			SELECT CASE temp%
				CASE 0: fg% = 0
				CASE 1: fg% = 7
				CASE 2: fg% = 15
			END SELECT
			temp% = INT(RND(1) * 2)
			IF temp% = 0 THEN
				bg% = 0
			ELSE
				bg% = 7
			END IF
		END IF

		' ÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄ
		'  Generate a random frame type.
		' ÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄ
		IF kolor% THEN
			ft% = INT(RND(1) * 10)
		ELSE
			ft% = INT(RND(1) * 6)
		END IF

		' ÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄ
		'  Assign a title for the window equal to the window number.
		' ÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄ
		winNum& = winNum& + 1
		title$ = STR$(winNum&) + " "

		' ÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄ
		'  Make the window.
		' ÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄ
		MakeWindow CSNG(y1%), CSNG(x1%), CSNG(y2%), CSNG(x2%), fg%, bg%, 0, ft%, 16, 0, title$

		' ÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄ
		'  See if a key has been hit.  If so, then act based on it.
		' ÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄ
		kc$ = INKEY$
		IF kc$ = " " THEN           ' Spacebar was hit, so pause until key hit.
			dummy$ = ""
			dummy$ = INPUT$(1)
		END IF
		IF kc$ = CHR$(27) THEN   ' If ESC hit, then we're done.
			done% = TRUE
		END IF

	WEND

	' ÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄ
	'  Turn blinking attributes back on, just to be neat and tidy.
	' ÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄ
	BlinkOn

END SUB

SUB SensitivityDemo

	' ÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄ
	'  This routine demonstrates the usage of the MouseAdjustBox routine,
	'  used for setting the sensitivity of the mouse.
	' ÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄ

	' ÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄ
	'  If the mouse ain't around, get outta here.
	' ÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄ
	IF mouseExists% = FALSE THEN
		InfoBox NEEDMOUSE
		EXIT SUB
	END IF

	' ÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄ
	'  Set color-dependent data.
	' ÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄ
	IF kolor% THEN
		ft1% = 6
		ft2% = 7
		bs% = STYLE3D
	ELSE
		ft1% = 0
		ft2% = 0
		bs% = STYLE2D
	END IF

	' ÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄ
	'  Make a window with buttons and display some info in it.
	' ÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄ
	MouseHide
	MakeWindow 5, 8, 23, 73, 0, 7, 0, ft1%, -1, 0, ""
	DrawButton SINGLEBORDER, 11, 20, 25, 22, 0, 7, "Sensitivity", bs%
	DrawButton SINGLEBORDER, 27, 20, 41, 22, 0, 7, "Done", bs%
	COLOR 0, 7
	Center "úúú The MouseAdjustBox Routine úúú", 7
	Center "The QBSCR Screen routines come with a complete, pre-packaged", 9
	Center "routine for adjusting the sensitivity of the mouse. This is", 10
	Center "quite useful for your own applications, and your users will", 11
	Center "probably appreciate it.", 12
	Center "Left-click the Sensitivity button below (or hit S) to use", 14
	Center "the MouseAdjustBox Sensitivity Adjuster. To exit, hit the", 15
	Center "ESC or D keys, or left-click the Done button.  The use of", 16
	Center "Sensitivity Adjuster is relatively straight-forward, and", 17
	Center "you should have no trouble at all using it.", 18

	' ÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄ
	'  Wait for a user decision about what to do.
	' ÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄ
	MouseShow
	done% = FALSE
	WHILE done% = FALSE

		result% = getEvent%(mouseExists%, kc%, mx%, my%)

		SELECT CASE result%
			CASE EMpressedLeft     ' Left mouse button pressed...somewhere...
				IF (mx% >= 11) AND (mx% <= 25) AND (my% >= 20) AND (my% <= 22) THEN
					PressButton SINGLEBORDER, 11, 20, 25, 22, 0, 7, "Sensitivity", bs%
					MouseAdjustBox 10, 20, 4, 0, 7, 7, 0, ft1%, -1, 0
					done% = TRUE
				END IF
				IF (mx% >= 27) AND (mx% <= 41) AND (my% >= 20) AND (my% <= 22) THEN
					PressButton SINGLEBORDER, 27, 20, 41, 22, 0, 7, "Done", bs%
					done% = TRUE
				END IF
			CASE EMpressedRight    ' Right mouse button pressed.
				done% = TRUE
			CASE EKpressed         ' Keyboard key pressed.
				IF (kc% = 27) OR (kc% = ASC("D")) OR (kc% = ASC("d")) THEN
					done% = TRUE
				END IF
			CASE ELSE
		END SELECT

	WEND

END SUB

SUB WindowsDemo

	' ÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄ
	'  This routine demonstrates the use of the MakeWindow function and all
	'  of its various parameters.  It will show a window of explanatory info
	'  to the user and two buttons.  If they click the "Windows" button, the
	'  routine will generate random windows until ESC or the right mouse
	'  button is hit.  The spacebar or the left mouse button will pause the
	'  lightning window display until the same key/button is hit again.
	' ÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄ

	' ÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄ
	'  Determine all color-related data.
	' ÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄ
	IF kolor% THEN
		ft1% = 6
		ft2% = 7
		bs% = STYLE3D
	ELSE
		ft1% = 0
		ft2% = 0
		bs% = STYLE2D
	END IF

	' ÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄ
	' Display a window with information, and the two control buttons.
	' ÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄ
	IF mouseExists% THEN
		MouseHide
	END IF
	MakeWindow 5, 8, 23, 73, 0, 7, 0, ft1%, -1, 0, ""
	DrawButton SINGLEBORDER, 10, 20, 20, 22, 0, 7, "Windows", bs%
	DrawButton SINGLEBORDER, 22, 20, 32, 22, 0, 7, "Done", bs%
	COLOR 0, 7
	Center "úúú The MakeWindow Routine úúú", 7
	LOCATE 9, 11, 0: PRINT "The QBSCR MakeWindow routine allows you to display windows";
	LOCATE 10, 11, 0: PRINT "in text mode, including the 3D style windows you see here.";
	LOCATE 12, 11, 0: PRINT "This demo, if activated, will display continuous, random";
	LOCATE 13, 11, 0: PRINT "windows. In this way, you can see most of MakeWindow's cap-";
	LOCATE 14, 11, 0: PRINT "abilities as well as some nifty combinations of parameters.";
	LOCATE 16, 11, 0: PRINT "The spacebar or the left mouse button pauses the display,";
	LOCATE 17, 11, 0: PRINT "and the ESC key or right mouse button ends it all.  Hit the";
	LOCATE 18, 11, 0: PRINT "Windows button (or W) to start, or ESC (or D) to quit.";

	' ÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄ
	'  Wait for the user to decide what's going on. If they pick the Windows
	'  button, then call the RandomWindows function.  If they pick Done, then
	'  get outta here.
	' ÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄ
	done% = FALSE
	IF mouseExists% THEN
		MouseShow
	END IF
	WHILE done% = FALSE

		result% = getEvent(mouseExists%, kc%, mx%, my%)

		SELECT CASE result%
			CASE EMpressedLeft
				IF (mx% >= 10) AND (mx% <= 20) AND (my% >= 20) AND (my% <= 22) THEN
					PressButton SINGLEBORDER, 10, 20, 20, 22, 0, 7, "Windows", bs%
					RandomWindows
					done% = TRUE
				END IF
				IF (mx% >= 22) AND (mx% <= 32) AND (my% >= 20) AND (my% <= 22) THEN
					PressButton SINGLEBORDER, 22, 20, 32, 22, 0, 7, "Done", bs%
					done% = TRUE
				END IF
			CASE EMpressedRight
				done% = TRUE
			CASE EKpressed
				IF (kc% = ASC("W")) OR (kc% = ASC("w")) THEN
					RandomWindows
					done% = TRUE
				END IF
				IF (kc% = ASC("D")) OR (kc% = ASC("d")) OR (kc% = 27) THEN
					done% = TRUE
				END IF
			CASE ELSE
		END SELECT
 
	WEND

END SUB

