'Demonstration of TBWINDO
$INCLUDE "TBWINDO.INC"

key off
out &H3d9,1
call qfill(1,1,25,80,32,fnattr(7,1))
for m = 1 to 3
  for i = 1 to 29
    j = rnd(1)*69
    k = rnd(1)*19
    f = rnd(1)*14
    b = rnd(1)*6
    call makewindow(k+1,j+1,5,11,fnattr(f+1,b+1),2,0,0)
    call prtcwindow(2,"WINDOW")
  next
  if (m = 3) then delay 3 else delay 1
  for x = LI to 1 step -1
  call removewindow
  next
next
'Put up opening screen
'4 windows of different colors and a Title Window
call makewindow(4,15,10,30,fnattr(4,3),4,1,1)
call makewindow(3,36,13,40,fnattr(15,2),3,1,1)
call makewindow(9,10,13,40,fnattr(0,5),2,1,1)
call makewindow(12,42,11,36,fnattr(3,4),1,1,1)

call makewindow(3,5,7,40,fnattr(0,7),2,1,1)

call prtcwindow(3,"Presenting...")
delay 4
call makewindow(8,20,7,40,fnattr(0,7),2,1,1)
call prtcwindow(1,"T B W I N D O")
call prtcwindow(2,"3.2")
call prtcwindow(4,"Windowing Routines for the")
call prtcwindow(5,"Borland Turbo BASIC Compiler")

delay 3
call makewindow(17,55,7,24,fnattr(0,6),1,1,1)
call prtwindow(1,2,"By:")
call prtcwindow(3,"Rick Fothergill")
call prtcwindow(4,"141 Oak Hill Road")
call prtcwindow(5,"Pittsfield, MA 01201")


delay 4

call makewindow(5,5,10,32,fnattr(15,1),2,1,0)

call prtcwindow(1,"Including ...")
call prtcwindow(3,"*** Window Tools ***")
call prtcwindow(5,"A collection of routines")
call prtcwindow(6,"for integration into your")
call prtcwindow(7,"own programs.")

delay 4
call makewindow(8,25,10,32,fnattr(15,1),2,1,0)

call prtwindow(1,2," * * * * * * * * * * * * * ")
call prtwindow(3,2,"Stand by for a guided tour")
call prtwindow(5,2,"through the many facets of")
call prtwindow(7,2,"this exciting program.")
delay 2
for x = 1 to 9
call removewindow
next
call makewindow(9,16,8,52,fnattr(0,7),2,0,0)


call prtwindow(1,2,"The basic  purpose of TBWINDO is to provide")
call prtwindow(2,2,"the  fundamental  routines for  implementing")
call prtwindow(3,2,"simple 'windowing' into your Turbo BASIC pro-")
call prtwindow(4,2,"grams.   With  just a few simple statements,")
call prtwindow(5,2,"you can 'pop-up'  a colored  window onto the")
call prtwindow(6,2,"screen; just like this ...")

delay 3
call clearwindow

call prtwindow(2,2,"The window can be a solid panel of any of")
call prtwindow(4,2,"the BASIC background colors; such as ...")

delay 4

call makewindow(2,2,7,35,fnattr(1,2),0,0,0)

delay 3
call removewindow
call clearwindow

call prtwindow(2,2,"or it can be surrounded by a 'frame' in any")
call prtwindow(4,2,"of five styles...")

delay 3

call makewindow(5,5,8,35,fnattr(9,5),1,0,0)
call titlewindow(1,"[ Frame Style 1 ]")
call makewindow(8,8,8,35,fnattr(12,3),2,0,0)
call titlewindow(2,"[ Frame Style 2 ]")
call makewindow(11,11,8,35,fnattr(15,4),3,0,0)
call titlewindow(3,"[ Frame Style 3 ]")
call makewindow(14,14,8,35,fnattr(0,6),4,0,0)
call titlewindow(1,"[ Frame Style 4 ]")
call makewindow(17,17,8,35,fnattr(0,2),5,0,0)
call titlewindow(3,"[ Frame Style 5 ]")

delay 4
for x = 1 to 5
call removewindow
next
call clearwindow

call prtwindow(1,2,"The frame itself can be in any one of the")
call prtwindow(2,2,"BASIC foreground colors. It can even blink")
call prtwindow(3,2,"if you want...")

delay 3
for i=0 to 15
  label$="[ Color:"+str$(i)+" ]"
  j=rnd(1)*50
  k=rnd(1)*12
  call makewindow(k+1,j+1,7,25,fnattr(i,5),4,2,0)
  call titlewindow(2,label$)
  delay .5
next
call makewindow(7,20,7,25,fnattr(31,5),4,2,0)
call titlewindow(2,"[ Color: 31 ]")

delay 4
for x = 1 to 17
call removewindow
next

call clearwindow
call prtcwindow(5,"The window itself can be presented in many")
call prtcwindow(6,"different ways. It can be flat...")

delay 3

call makewindow(1,2,11,30,fnattr(15,4),1,0,0)

delay 3
call removewindow
call clearwindow
call prtcwindow(5,"or it can have a black shadow underneath; giving")
call prtcwindow(6,"a three-dimensional effect...")
delay 3
call makewindow(5,5,10,30,fnattr(14,5),2,1,0)
call qprintc(7,5,35,"Left Shadow",fnattr(15,5))
delay 2
call makewindow(5,40,10,30,fnattr(0,2),2,2,0)
call qprintc(7,40,70,"Right Shadow",fnattr(15,2))
delay 2
call removewindow
call removewindow
call clearwindow
call prtcwindow(2,"Titles may be placed in any")
call prtcwindow(3,"of six different locations,")
call prtcwindow(4,"or any combination.")
delay 2
call makewindow(2,5,10,70,fnattr(15,5),2,1,0)
for x = 1 to 6
  title$ = "[ Location"+str$(x)+" ]"
  call titlewindow(x,title$)
  delay 1
next
delay 3
call removewindow
call clearwindow
call prtcwindow(3,"Windows can be zoomed")
call prtcwindow(4,"onto the screen.")
delay 2
call makewindow(2,2,15,60,fnattr(0,2),2,0,1)
delay 2
call makewindow(13,10,10,60,fnattr(1,3),3,0,1)
delay 2
call makewindow(7,33,10,45,fnattr(14,5),1,0,1)
delay 2
call makewindow(7,10,12,63,fnattr(15,4),2,1,1)
call prtcwindow(5,"W O W !!!")
delay 3
for x = 1 to 4
call removewindow
next
call clearwindow
call prtwindow(1,2,"Once you have your window on the screen, simply")
call prtwindow(2,2,"use calls to PrtWindow or PrtCWindow to put text")
call prtwindow(3,2,"in them.  A call to ClearWindow will erase the")
call prtwindow(4,2,"contents of the window ...   ")
delay 3


call clearwindow
call prtwindow(1,2,"Just as easily as you can create the window!")
call prtwindow(2,2,"In fact, all of the commands of TBWINDO are")
call prtwindow(3,2,"very  easy to use.  Here is a call to create")
call prtwindow(4,2,"this window ...")
call prtwindow(5,2,"   CALL MAKEWINDOW(8,14,8,52,fnattr(0,7),2,0,1)")
delay 5

call clearwindow

call prtwindow(1,2,"Each window is stored as a result of a call to")
call prtwindow(2,2,"MakeWindow.  To restore the screen to it's")
call prtwindow(3,2,"original contents, simply call RemoveWindow.")
call prtwindow(4,2,"Here is a good example . . .")
delay 5
call makewindow(3,5,15,45,fnattr(0,2),4,1,1)
call prtcwindow(6,"This is the first level ...")
delay 2
call makewindow(6,29,17,50,fnattr(15,4),4,1,1)
call prtcwindow(6,"This is the second level ...")
delay 2
call makewindow(9,22,15,35,fnattr(0,3),4,1,1)
call prtcwindow(7,"This is the third level ...")
delay 2
call prtcwindow(7,"Now to go back ...           ")
delay 1
call removewindow
delay 1
call removewindow
delay 1
call removewindow
delay 2
call clearwindow
call prtwindow(2,2,"Next is a demonstration of the MakeMenu")
call prtwindow(3,2,"procedure which will create a point and")
call prtwindow(4,2,"shoot type menu.")
delay 3
call removewindow

out &H03d9,7
call qfill(1,1,25,80,32,fnattr(0,7))
call mainmenu
out &H03d9,0

sub mainmenu
shared item$(),itemcount,startpos
shared curntpos,done
done = 0
curntpos = 0
call makewindow(5,20,7,40,fnattr%(15,1),2,2,0)
call titlewindow(2,"[ MAIN MENU ]")
while not done
  oldcurntpos = curntpos
  item$(1) = "Pop Screen 1"
  item$(2) = "Pop Screen 2"
  item$(3) = "Pop Screen 3"
  item$(4) = "Second Menu Demo"
  item$(5) = "Exit"
  itemcount = 5
  startpos = 1
  call makemenu
  select case curntpos
    case 1 'screen 1
      call popscreen1
    case 2 ' screen 2
      call popscreen2
    case 3 ' screen 3
      call popscreen3
    case 4 ' second menu
      call secondmenu
    case else
      call removewindow
      curntpos = oldcurntpos
      out &H03d9,1
      call qfill(1,1,25,80,32,fnattr(15,1))
      color 0,7
      call makewindow(9,16,8,52,fnattr(0,7),2,0,0)
      locate 10,18:print "Please see the source code and documentation"
      locate 11,18:print "for how to create and use menu windows in"
      locate 12,18:print "your programs...."
      delay 5
      done = -1
    end select
wend 'done
call removewindow
end sub

sub popscreen1
call makewindow(8,10,7,60,fnattr(0,6),2,1,1)
call titlewindow(2,"[ SELECTION 1 ]")
call qprintc(10,10,70,"This is selection no. 1",fnattr(0,6))
call qprintc(11,10,70,"Press enter to return to main menu...",fnattr(15,6))
while not instat
wend
a$=inkey$
call removewindow
end sub

sub popscreen2
call makewindow(8,10,7,60,fnattr(0,3),2,1,1)
call titlewindow(2,"[ SELECTION 2 ]")
call qprintc(10,10,70,"This is selection no. 2",fnattr(0,3))
call qprintc(11,10,70,"Press enter to return to main menu...",fnattr(0,3))
while not instat
wend
a$=inkey$
call removewindow
end sub

sub popscreen3
call makewindow(8,10,7,60,fnattr(14,5),2,1,1)
call titlewindow(2,"[ SELECTION 3 ]")
call qprintc(10,10,70,"This is selection no. 3",fnattr(14,5))
call qprintc(11,10,70,"Press enter to return to main menu...",fnattr(14,5))
while not instat
wend
a$=inkey$
call removewindow
end sub

sub secondmenu
shared item$(),itemcount,startpos
shared curntpos,done
call makewindow(7,25,6,40,fnattr%(14,2),2,2,0)
call titlewindow(2,"[ SECOND MENU DEMO ]")
done = 0
oldcurntpos = curntpos
curntpos = 0
while not done
  item$(1) = "Pop Screen 1"
  item$(2) = "Pop Screen 2"
  item$(3) = "Pop Screen 3"
  item$(4) = "Exit"
  itemcount = 4
  startpos = 3
  call makemenu
  select case curntpos
    case 1 'screen 1
      call popscreen1
    case 2 ' screen 2
      call popscreen2
    case 3 ' screen 3
      call popscreen3
    case else
      call removewindow
      curntpos = oldcurntpos
      done = -1
  end select
wend 'done
done = 0
end sub
