home *** CD-ROM | disk | FTP | other *** search
/ Media Share 9 / MEDIASHARE_09.ISO / batch / mxmnu233.zip / GRID.INC < prev    next >
Text File  |  1991-05-27  |  8KB  |  334 lines

  1. Comment
  2. ==========================================================
  3.  
  4. This include file exports definitions that create a block menu look and
  5. feel. This is one of several look and feel files that export the same
  6. procedures.
  7.  
  8. Useful Routines Exported:
  9.  
  10. LookSetup
  11.    Call this to initialize the screen. Set MenuTitle and StatusLineText
  12.    before calling this routine.
  13.  
  14. CornerStretchBox (Header,Col,Row)
  15.    Creates a window from the array Choices with the upper left corner at
  16.    Row/Col. LastKey is set to the letter that is chosen.
  17.  
  18. CenterStretchBox (Header,Col,Row)
  19.    Creates a window from the array Choices with the center at Row/Col.
  20.    if a 0 is passed for either the Row or Col then the center of the
  21.    screen is assumed. LastKey is set to the letter that is chosen.
  22.  
  23. Leave
  24.    Puts up an exit box.
  25.  
  26.  
  27. ==========================================================
  28. EndComment
  29.  
  30.  
  31. var
  32.   VertLine = "┬│││││││││││││││││││││││││││││││││││││││││││││"
  33.   VertLine2 = "││││││││││││││││││││"
  34.   VertLine3 = "┌─┴┴┴┴─┐"
  35.   VertLine4 = "└─┬┬┬┬─┘"
  36.   Grid1 = "╠═╬═╬═╬═╬═╬═╬═╬═╬═╬═╬═╬═╬═╬═╬═╬═╬═╬═╬═╬═╬═╬═╬═╬═╬═╬═╬═╬═╬═╬═╬═╬═╬═╬═╬═╬═╬═╬═╬═╣"
  37.   Grid2 = "├─┼─┼─┼─┼─┼─┼─┼─┼─┼─┼─┼─┼─┼─┼─┼─┼─┼─┼─┼─┼─┼─┼─┼─┼─┼─┼─┼─┼─┼─┼─┼─┼─┼─┼─┼─┼─┼─┼─┤"
  38.   Grid3 = "╠╬╬╬╬╬╬╬╬╬╬╬╬╬╬╬╬╬╬╬╬╬╬╬╬╬╬╬╬╬╬╬╬╬╬╬╬╬╬╬╬╬╬╬╬╬╬╬╬╬╬╬╬╬╬╬╬╬╬╬╬╬╬╬╬╬╬╬╬╬╬╬╬╬╬╬╬╬╣"
  39.   Grid4 = "├┼┼┼┼┼┼┼┼┼┼┼┼┼┼┼┼┼┼┼┼┼┼┼┼┼┼┼┼┼┼┼┼┼┼┼┼┼┼┼┼┼┼┼┼┼┼┼┼┼┼┼┼┼┼┼┼┼┼┼┼┼┼┼┼┼┼┼┼┼┼┼┼┼┼┼┼┼┤"
  40.   Choices
  41.   MenuTitle
  42.   StatusLineText
  43.   HeightDifference
  44.   Greek = False
  45.  
  46. var
  47.   BackGroundFG
  48.   BackGroundBG
  49.   TitleBoxBorderFG
  50.   TitleBoxBG
  51.   TitleBoxInsideFG
  52.   ClockColorFG
  53.   StatusLineFG
  54.   StatusLineBG
  55.   MenuInsideFG
  56.   MenuBG
  57.   MenuHeaderFG
  58.   MenuHeaderBG
  59.   MenuBorderFG
  60.   MenuVertLinesFG
  61.   MenuInverseFG
  62.   MenuInverseBG
  63.   MenuCapColorFG
  64.   ConsoleInsideFG
  65.   GreekFG
  66.   GreekBG
  67.  
  68. ;------ This is where you set your favorite colors.
  69.  
  70. Procedure SetColors
  71.    if ColorScreen
  72.       BackGroundFG     = LBlue
  73.       BackGroundBG     = Black
  74.       TitleBoxBG       = Brown
  75.       TitleBoxBorderFG = White
  76.       TitleBoxInsideFG = Yellow
  77.       ClockColorFG     = Yellow
  78.       StatusLineFG     = Yellow
  79.       StatusLineBG     = Mag
  80.       MenuBG           = Black
  81.       MenuInsideFG     = Yellow
  82.       MenuBorderFG     = LRed
  83.       MenuHeaderFG     = White
  84.       MenuHeaderBG     = Green
  85.       MenuVertLinesFG  = LGreen
  86.       MenuInverseFG    = Yellow
  87.       MenuInverseBG    = Mag
  88.       MenuCapColorFG   = White
  89.       ConsoleInsideFG  = White
  90.       GreekFG          = Black
  91.       GreekBG          = Brown
  92.    else
  93.       BackGroundFG     = Grey
  94.       BackGroundBG     = Black
  95.       TitleBoxBG       = Grey
  96.       TitleBoxBorderFG = Black
  97.       TitleBoxInsideFG = Black
  98.       ClockColorFG     = Black
  99.       StatusLineFG     = Black
  100.       StatusLineBG     = Grey
  101.       MenuBG           = Black
  102.       MenuInsideFG     = Grey
  103.       MenuBorderFG     = White
  104.       MenuHeaderFG     = Black
  105.       MenuHeaderBG     = Grey
  106.       MenuVertLinesFG  = White
  107.       MenuInverseFG    = Black
  108.       MenuInverseBG    = Grey
  109.       MenuCapColorFG   = White
  110.       ConsoleInsideFG  = Grey
  111.       GreekFG          = Black
  112.       GreekBG          = Grey
  113.    endif
  114. EndProc
  115.  
  116. ;------ Sets up main window to block look.
  117.  
  118. Procedure LookSetup
  119.    if MenuInsideFG = 0 then SetColors
  120.    NoExit
  121.  
  122.    ;------ Clear the screen with a textured background
  123.  
  124.    TextColor BackGroundFG BackGroundBG
  125.    ClearScreen
  126.    GotoXY 1 3
  127.    loop ScreenHeight - 3
  128.       Writeln Grid3
  129.    endloop
  130.  
  131.    ;------ If Greek is true then draw greek columns
  132.  
  133. ;   if Greek then GreekColumns
  134.  
  135.    ;------ Draw Status Line
  136.  
  137.    NoBoxBorder
  138.    Explode Off
  139.    BoxInsideColor StatusLineFG StatusLineBG
  140.    DrawBox 1 25 ScreenWidth 1
  141.    WriteCenter(StatusLineText)
  142.  
  143.    ;------ Draw the Title Box
  144.  
  145.    SingleLineBox
  146.    Explode Off
  147.    BoxInsideColor TitleBoxInsideFG TitleBoxBG
  148.    BoxBorderColor TitleBoxBorderFG TitleBoxBG
  149.    DrawBox 1 1 ScreenWidth 3
  150.    GotoXY(ScreenWidth - Length(MenuTitle) - 3,1)
  151.    Write MenuTitle
  152.  
  153.    ;------ Display the clock
  154.  
  155.    ClockColor ClockColorFG TitleBoxBG
  156.    ClockPos 3 2
  157.  
  158.    ;------ Setup Console
  159.  
  160.    ConsolePos 42 5
  161.    ConsoleHeaderColor MenuInverseFG MenuInverseBG
  162.    ConsoleInsideColor ConsoleInsideFG MenuBG
  163.  
  164.    BoxHeaderColor MenuHeaderFG MenuHeaderBG
  165.    HeightDifference = 2
  166.    SmallShadow
  167.    Shadow
  168. EndProc
  169.  
  170.  
  171. Procedure CenterStretchBox (Header,Col,Row)
  172.    MakeBox(Header,Col,Row,True)
  173. EndProc
  174.  
  175.  
  176. Procedure CornerStretchBox (Header,Col,Row)
  177.    MakeBox(Header,Col,Row,False)
  178. EndProc
  179.  
  180.  
  181. Procedure MakeBox(Header,Col,Row,Center)
  182. var NumElem Height Width
  183.  
  184.    Width = Length(Header) + 1
  185.    NumElem = NumberOfElements(Choices)
  186.  
  187.      ;Get the widest element in the Choices Array
  188.  
  189.    if Length(Choices[1]) > 0
  190.       loop NumElem
  191.          Trim(Choices[LoopIndex])
  192.          Choices[LoopIndex] = " " + Char(64 + LoopIndex) + ". " + Choices[LoopIndex]
  193.          Width = Max(Width,Length(Choices[LoopIndex]))
  194.       endloop
  195.    else
  196.       Width = 71
  197.    endif
  198.    Height = NumElem + 2
  199.    Width = Width + 5
  200.    if Center
  201.       if Row = 0
  202.  
  203.          ;Center window verticaly
  204.  
  205.          Row = ((ScreenHeight - Height) / 2) + 2
  206.       else
  207.  
  208.          ;Center window with X Coordinate
  209.  
  210.          Row = (Row - (Height / 2) + 1)
  211.       endif
  212.       if Col = 0
  213.  
  214.          ;Center window horizonitly
  215.  
  216.          Col = (ScreenWidth - Width) / 2 + 1
  217.       else
  218.  
  219.          ;Center window with Y Coordinate
  220.  
  221.          Col = (Col - (Width / 2) + 1)
  222.       endif
  223.    endif
  224.  
  225.    ;Make Sure Row and Col are within their range
  226.  
  227.    Row = Max(Row,5)
  228.    Row = Min(Row,ScreenHeight - Height - 2)
  229.    Col = Max(Col,2)
  230.    Col = Min(Col,ScreenWidth - Width - 2)
  231.  
  232.    DrawTheBox(Col,Row,Width,Height,Header)
  233.  
  234.      ;Write the menu choices
  235.  
  236.    loop(NumElem - 1)
  237.       Writeln(Choices[LoopIndex])
  238.    endloop
  239.  
  240.    Write Choices[NumElem]
  241.    UseArrows On
  242.    Dispose(Choices)
  243. EndProc
  244.  
  245. ;------ Draw the Box
  246.  
  247. Procedure DrawTheBox (Col,Row,Width,Height,Header)
  248.  
  249.      ;Draw the main window
  250.  
  251.    DoubleLineBox
  252.    InActiveBox SingleLineBox
  253.    BoxInsideColor(MenuInsideFG,MenuBG)
  254.    BoxBorderColor(MenuBorderFG,MenuBG)
  255.    if Header > '' then Header = ' ' + Header + ' '
  256.    BoxHeader = Header
  257.    DrawBox(Col, Row, Width, Height)
  258.  
  259.    if Header > ''
  260.  
  261.       TextColor MenuInsideFG MenuBG
  262.       CapsColor(MenuCapColorFG,MenuBG)
  263.       InverseColor(MenuInverseFG,MenuInverseBG)
  264.       Window(Col + 2, Row + 1, Width - 4, Height - 2)
  265.    else
  266.       CapsColor Black Black
  267.    endif
  268. EndProc
  269.  
  270. ;------ MenuExit Procedure
  271.  
  272. Procedure LeaveMenu
  273.    AppendArray(Choices,'Yes')
  274.    AppendArray(Choices,'No')
  275.    CenterStretchBox ('Exit Menu',0,0)
  276.    OnScreenOnly Off
  277.  
  278.    OnKey "A"
  279.       |ExitMenu
  280.  
  281.    OnKey "B"
  282.       |LastKey = Esc
  283.  
  284.    OnKey "Y"
  285.       |ExitMenu
  286.  
  287.    OnKey "N"
  288.       |LastKey = Esc
  289.  
  290. EndProc
  291.  
  292. ;------ Read a Text Line Procedure
  293.  
  294. Procedure ReadTextLine(St,Header,Col,Row)
  295. var AnswerLine
  296.    Choices[1] = ""
  297.    CenterStretchBox(Header,Col,Row)
  298.    Write " " St " "
  299.    TextColor(MenuCapColorFG,MenuBG)
  300.    AnswerLine = Readln
  301.    EraseTopWindow
  302.    Dispose Choices
  303.    Return AnswerLine
  304. EndProc
  305.  
  306.  
  307. Procedure GreekColumns
  308.    TextColor GreekFG GreekBG
  309.    GotoXY 4,4
  310.    WriteVertical VertLine2
  311.    GotoXY 5,4
  312.    WriteVertical VertLine2
  313.    GotoXY 6,4
  314.    WriteVertical VertLine2
  315.    GotoXY 7,4
  316.    WriteVertical VertLine2
  317.    GotoXY 74,4
  318.    WriteVertical VertLine2
  319.    GotoXY 75,4
  320.    WriteVertical VertLine2
  321.    GotoXY 76,4
  322.    WriteVertical VertLine2
  323.    GotoXY 77,4
  324.    WriteVertical VertLine2
  325.    GotoXY 2,4
  326.    Write VertLine4
  327.    GotoXY 72,4
  328.    Write VertLine4
  329.    GotoXY 2,24
  330.    Write VertLine3
  331.    GotoXY 72,24
  332.    Write VertLine3
  333. EndProc
  334.