home *** CD-ROM | disk | FTP | other *** search
- ' ──────────────────────────────────────────────────────────────────────────
- '
- ' Q D E M O . B A S
- '
- ' This program was written to demonstrate (and hopefully sell) the QBSCR
- ' Screen Routines. It is an excellent resource for learning as well,
- ' since its source code makes use of most of the Screen Routines.
- '
- ' Note that this source code, the executable, and all associated document-
- ' ation are copyright (c) 1992 by Tony Martin.
- '
- ' ──────────────────────────────────────────────────────────────────────────
- '
- ' To correctly compile this code to an executable, you need the following
- ' files available: QDEMO.BAS
- ' QDEMO_A.BAS
- ' QDEMO_B.BAS
- ' QDEMO_C.BAS
- ' QDEMO_D.BAS
- ' QDEMO_E.BAS
- ' QDEMO_F.BAS
- ' QBSCR20.QLB
- ' QBSCR20.LIB
- ' QBSCR.INC
- ' MOUSE.BI
- ' QDEMO.MAK
- '
- ' To load this program into the QuickBASIC environment and have it run
- ' properly, make sure the above files are all available, and issue the
- ' followng DOS command:
- '
- ' QB QDEMO /L QBSCR20
- '
- ' This will load the QDEMO program, all its source files (assuming the
- ' QDEMO.MAK file is available), and will make the QBSCR20.QLB library
- ' available for the program to use.
- '
- ' ──────────────────────────────────────────────────────────────────────────
-
- ' ──────────────────────────────────────────────────────────────────────────
- ' Include any program-specific constants here.
- ' ──────────────────────────────────────────────────────────────────────────
- CONST NUMMENUS% = 7
- CONST MAXITEMS% = 6
- CONST SAVEFILE = "QDEMO.TMP"
-
- ' ──────────────────────────────────────────────────────────────────────────
- ' Include the constants, types, and declare statements for the QBSCR Screen
- ' routines, as well as the mouse routines.
- ' ──────────────────────────────────────────────────────────────────────────
- '$INCLUDE: 'qbscr.inc'
- '$INCLUDE: 'mouse.bi'
-
- ' ──────────────────────────────────────────────────────────────────────────
- ' Place all local declare statements here.
- ' ──────────────────────────────────────────────────────────────────────────
- DECLARE SUB Initialize ()
- DECLARE SUB Interface ()
- DECLARE SUB MainMenu ()
- DECLARE SUB Quit ()
-
- ' From QDEMO_A.BAS
- DECLARE FUNCTION QuitVerification% ()
- DECLARE SUB OpeningScreen ()
-
- ' From QDEMO_B.BAS
- DECLARE SUB BrightBacks ()
- DECLARE SUB GetForeBack ()
- DECLARE SUB GeneralInfo ()
- DECLARE SUB OrderingInfo ()
- DECLARE SUB About ()
- DECLARE SUB EgaVgaColors ()
-
- ' From QDEMO_C.BAS
- DECLARE SUB Info3D ()
- DECLARE SUB Buttons3D ()
- DECLARE SUB Boxes3D ()
- DECLARE SUB MenuDemo ()
-
- ' From QDEMO_D.BAS
- DECLARE SUB EditDemo ()
- DECLARE SUB VerificationDemo ()
- DECLARE SUB ListDemo ()
- DECLARE SUB EventsDemo ()
-
- ' From QDEMO_E.BAS
- DECLARE SUB MouseMovement ()
- DECLARE SUB FontsDemo ()
-
- ' From QDEMO_F.BAS
- DECLARE SUB DisplayScreensDemo ()
- DECLARE SUB WindowsDemo ()
- DECLARE SUB ButtonStatusDemo ()
- DECLARE SUB MouseInfoDemo ()
- DECLARE SUB SensitivityDemo ()
-
-
- ' ──────────────────────────────────────────────────────────────────────────
- ' List data shared between modules. Always keep this to a bare minimum.
- ' ──────────────────────────────────────────────────────────────────────────
- COMMON SHARED kolor%
- COMMON SHARED mouseExists%
- COMMON SHARED mouseState%
-
- DIM SHARED cursorRow%
-
- ' ────────────────────────────────────────────────────────────────────────
- ' Allocate enough stack space so that we can use our VGA font routines
- ' later in the demo.
- ' ────────────────────────────────────────────────────────────────────────
- CLEAR , , 8192
-
- ' ──────────────────────────────────────────────────────────────────────────
- ' Initialize any data that may require it.
- ' ──────────────────────────────────────────────────────────────────────────
- Initialize
-
- ' ──────────────────────────────────────────────────────────────────────────
- ' Display the opening screen for the demo.
- ' ──────────────────────────────────────────────────────────────────────────
- OpeningScreen
-
- ' ──────────────────────────────────────────────────────────────────────────
- ' Draw the basic user interface.
- ' ──────────────────────────────────────────────────────────────────────────
- Interface
-
- ' ──────────────────────────────────────────────────────────────────────────
- ' Call the main menu routine. This handles all user actions and kicks off
- ' all commands to the program.
- ' ──────────────────────────────────────────────────────────────────────────
- MainMenu
-
- ' ──────────────────────────────────────────────────────────────────────────
- ' At this point, the MainMenu function is finished, and we are done here.
- ' Call the Quit routine to clean up and exit.
- ' ──────────────────────────────────────────────────────────────────────────
- Quit
-
- ' ──────────────────────────────────────────────────────────────────────────
- ' Bye bye!
- ' ──────────────────────────────────────────────────────────────────────────
- END
-
- SUB Initialize
-
- ' ────────────────────────────────────────────────────────────────────────
- ' This SUBprogram initializes any settings that may need to be determined
- ' right away, such as color capability and mouse presence.
- ' ────────────────────────────────────────────────────────────────────────
-
- ' ────────────────────────────────────────────────────────────────────────
- ' If we can use color, make sure the whole program knows it.
- ' ────────────────────────────────────────────────────────────────────────
- IF ColorChk THEN
- kolor% = TRUE
- ELSE
- kolor% = FALSE
- END IF
-
- ' ────────────────────────────────────────────────────────────────────────
- ' If a mouse is around, then make sure we know it.
- ' ────────────────────────────────────────────────────────────────────────
- mouseExists% = MouseInit%
-
- ' ────────────────────────────────────────────────────────────────────────
- ' Save the existing screen for redisplay later when we exit.
- ' ────────────────────────────────────────────────────────────────────────
- IF (GetDiskFreeSpace(0) > 4096) THEN
- GetScreen SAVEFILE
- END IF
-
- ' ────────────────────────────────────────────────────────────────────────
- ' Save cursor row.
- ' ────────────────────────────────────────────────────────────────────────
- cursorRow% = CSRLIN
-
- END SUB
-
- SUB MainMenu
-
- ' ────────────────────────────────────────────────────────────────────────
- ' This routine is a high-level sub that runs the menu and kicks off other
- ' routines based on what the user does in the menu. The MultiMenu
- ' routine is used for the multiple pulldown menu.
- ' ────────────────────────────────────────────────────────────────────────
-
- ' ────────────────────────────────────────────────────────────────────────
- ' Save the top half of the screen underneath, so that it can be restored
- ' between calls to MultiMenu.
- ' ────────────────────────────────────────────────────────────────────────
- DIM scr%(BlockSize%(1, 80, 1, 25))
- IF mouseExists% THEN
- MouseHide
- END IF
- BlockSave 1, 80, 1, 25, scr%(), GetVideoSegment!
-
- ' ────────────────────────────────────────────────────────────────────────
- ' Now we're going to define our multiple menu, the information MultiMenu
- ' requires to operate. It can be a bit lengthy, so have patience while
- ' reading this.
- ' ────────────────────────────────────────────────────────────────────────
-
- ' ────────────────────────────────────────────────────────────────────────
- ' DIMension arrays for MultiMenu. Note that the numbers inside the array
- ' parenthesis are named constants, defined in the module-level code.
- ' This is important to do, so that if any of them change (like you want
- ' to add or remove menus or items), all you have to do is change the
- ' value of these constants in one place. Otherwise, you'd have to change
- ' the literal value all over the program.
- ' ────────────────────────────────────────────────────────────────────────
- DIM menuItems$(NUMMENUS%, MAXITEMS%)
- DIM numItems%(NUMMENUS%)
- DIM titles$(NUMMENUS%)
-
- ' ────────────────────────────────────────────────────────────────────────
- ' Fill in the values and text for all the menu items.
- ' ────────────────────────────────────────────────────────────────────────
- IF kolor% THEN
- ft% = 6
- ELSE
- ft% = 0
- END IF
- numItems%(1) = 4
- titles$(1) = " ^Info "
- menuItems$(1, 1) = "^General Info"
- menuItems$(1, 2) = "^Ordering Info"
- menuItems$(1, 3) = "^About QDEMO"
- menuItems$(1, 4) = "^Quit"
-
- numItems%(2) = 3
- titles$(2) = " ^Colors "
- menuItems$(2, 1) = "^Get Fore/Back"
- menuItems$(2, 2) = "^Bright Backgrounds"
- menuItems$(2, 3) = "^EGA/VGA Text Colors"
-
- numItems%(3) = 2
- titles$(3) = " ^3D Stuff "
- menuItems$(3, 1) = "^Info on 3D Stuff"
- menuItems$(3, 2) = "B^uttons"
-
- numItems%(4) = 4
- titles$(4) = " I^nput "
- menuItems$(4, 1) = "^Menus"
- menuItems$(4, 2) = "Editing ^Fields"
- menuItems$(4, 3) = "^Lists"
- menuItems$(4, 4) = "^Events"
-
- numItems%(5) = 2
- titles$(5) = " ^Display "
- menuItems$(5, 1) = "^Displaying Screens"
- menuItems$(5, 2) = "^Windows"
-
- numItems%(6) = 4
- titles$(6) = " ^Mouse "
- menuItems$(6, 1) = "B^utton Status"
- menuItems$(6, 2) = "M^ovement"
- menuItems$(6, 3) = "^Information"
- menuItems$(6, 4) = "^Sensitivity"
-
- numItems%(7) = 1
- titles$(7) = " ^Other "
- menuItems$(7, 1) = "^Fonts"
-
- ' ────────────────────────────────────────────────────────────────────────
- ' Now we sit in a loop. In this loop we call MultiMenu, which creates
- ' the pulldown menu. Based on what the user does in this menu, we will
- ' call other routines to perform the user's chosen action. Keep looping
- ' in this fashion until the user chooses to quit.
- ' ────────────────────────────────────────────────────────────────────────
- done% = FALSE
- WHILE done% = FALSE
-
- MultiMenu menuItems$(), numItems%(), titles$(), 5, 3, 76, "L", "^", "|", ft%, -1, 0, 7, 15, 0, 15, 7, menuSelected%, itemSelected%, mouseExists%
-
- SELECT CASE menuSelected%
- CASE 1 ' Info
- SELECT CASE itemSelected%
- CASE 1 ' General Info
- GeneralInfo
- CASE 2 ' Ordering Info
- OrderingInfo
- CASE 3 ' About
- About
- CASE 4 ' Quit
- done% = QuitVerification%
- CASE ELSE
- END SELECT
- CASE 2 ' Colors
- SELECT CASE itemSelected%
- CASE 1 ' Get Fore/Back
- GetForeBack
- CASE 2 ' Bright Backgrounds
- BrightBacks
- CASE 3 ' EGA/VGA Text Colors
- EgaVgaColors
- CASE ELSE
- END SELECT
- CASE 3 ' 3D Stuff
- SELECT CASE itemSelected%
- CASE 1 ' Info on 3D Stuff
- Info3D
- CASE 2 ' Buttons
- Buttons3D
- CASE ELSE
- END SELECT
- CASE 4 ' Input
- SELECT CASE itemSelected%
- CASE 1 ' Menus
- MenuDemo
- CASE 2 ' Edit Fields
- EditDemo
- CASE 3 ' Lists
- ListDemo
- CASE 4 ' Events
- EventsDemo
- CASE ELSE
- END SELECT
- CASE 5 ' Display stuff
- SELECT CASE itemSelected%
- CASE 1 ' Displaying Screens
- DisplayScreensDemo
- CASE 2 ' Windows
- WindowsDemo
- CASE ELSE
- END SELECT
- CASE 6 ' Mouse
- SELECT CASE itemSelected%
- CASE 1 ' Button Status
- ButtonStatusDemo
- CASE 2 ' Movement
- MouseMovement
- CASE 3 ' Info
- MouseInfoDemo
- CASE 4 ' Sensitivity
- SensitivityDemo
- CASE ELSE
- END SELECT
- CASE 7 ' Other goodies
- SELECT CASE itemSelected%
- CASE 1 ' Fonts
- FontsDemo
- CASE ELSE
- END SELECT
- CASE ELSE
- END SELECT
-
- IF mouseExists% THEN
- MouseHide
- END IF
- BlockRestore 1, 80, 1, 25, scr%(), GetVideoSegment!
-
- WEND
-
- END SUB
-
- SUB Quit
-
- ' ────────────────────────────────────────────────────────────────────────
- ' This routine will take care of cleanup operations, including the last
- ' clearing of the display and the hiding of the mouse, if it exists.
- ' ────────────────────────────────────────────────────────────────────────
-
- ' ────────────────────────────────────────────────────────────────────────
- ' Hide the mouse before we do any drawing.
- ' ────────────────────────────────────────────────────────────────────────
- IF mouseExists% THEN
- MouseHide
- END IF
-
- ' ────────────────────────────────────────────────────────────────────────
- ' If there is a VGA crad present, then the user might have changed the
- ' screen font using the FontsDemo routine. So, if there is a VGA card
- ' present, we will, at this point, force a reset of the VGA character
- ' font to the standard VGA hardware font.
- ' ────────────────────────────────────────────────────────────────────────
- IF VgaPresent% THEN
- LoadVgaTextFont ""
- ELSE
- IF EgaPresent% THEN
- LoadEgaTextFont ""
- END IF
- END IF
-
- ' ────────────────────────────────────────────────────────────────────────
- ' Almost lastly, redisplay the screen as it was when we started.
- ' ────────────────────────────────────────────────────────────────────────
- IF (FirstFile%(SAVEFILE, NormalAttr, dta$)) THEN
- RANDOMIZE TIMER
- BuildScreen SAVEFILE, INT(RND(1) * 19)
- KILL SAVEFILE
- ELSE
- COLOR 7, 0
- CLS
- END IF
-
- ' ────────────────────────────────────────────────────────────────────────
- ' Relocate the cursor where it was saved in the first place.
- ' ────────────────────────────────────────────────────────────────────────
- LOCATE cursorRow%, 1, 1
-
- END SUB
-
-