home *** CD-ROM | disk | FTP | other *** search
/ Monster Media 1993 #2 / Image.iso / database / pk4pak.zip / HYPERTXT.SC < prev    next >
Text File  |  1993-03-24  |  29KB  |  777 lines

  1. ;==============================================================================
  2. ; (c) Copyright Elect Software International Inc., 1992, Toronto. Anyone can
  3. ; use this code for anything as long as it is not resold as a software
  4. ; development resource, as long as the copyright notice isn't removed, as
  5. ; long as changes are clearly marked as to authorship, and as long as users
  6. ; indemnify Elect from any liability.
  7. ; Comments welcome. Henrik Bechmann, CIS:72701,3717; Tel:416-534-8176.
  8. ;==============================================================================
  9.  
  10. ; The HelpPanel.<PanelName> procs set the following dynarrays:
  11. ;   Hypertext.HotSpotString[]
  12. ;   Hypertext.HotSpotStartLine[]
  13. ;   Hypertext.HotSpotStartCol[]
  14. ;   Hypertext.HotSpotEndLine[]
  15. ;   Hypertext.HotSpotEndCol[]
  16. ;   Hypertext.HotSpotReference[]
  17. ;
  18. ; ... as well as the properties:
  19. ;   Hypertext.Width
  20. ;   Hypertext.Height
  21. ;
  22. ;==============================================================================
  23. ;                             Hypertext INTERFACE
  24. ;==============================================================================
  25.  
  26. ; Methods:
  27. ; Hypertext.Constructor()
  28. ; Hypertext.ShowPanel(PanelName)
  29. ; Hypertext.Destructor()
  30. ; Hypertext.StartWithPanel(PanelName)
  31. ;
  32. ; Properties:
  33. ; (public...)
  34. ; Hypertext.ColorBag[]
  35. ; Hypertext.WindowBag[]
  36. ; Hypertext.HypertextKey
  37. ; Hypertext.Prompt
  38. ; Hypertext.HighLightColor
  39. ; Hypertext.HotSpotColor
  40. ; (protected...)
  41. ; Hypertext.WindowHandle
  42. ; Hypertext.Width
  43. ; Hypertext.Height
  44.  
  45. ;==============================================================================
  46. ;                         Hypertext IMPLEMENTATION
  47. ;==============================================================================
  48.  
  49. Proc Hypertext.Constructor()
  50.    Dynarray Hypertext.ColorBag[]
  51.    Hypertext.ColorBag[0] = 8 + 32
  52.    Hypertext.ColorBag[1] = 8 + 32
  53.    Hypertext.ColorBag[2] = 8 + 32
  54.    Hypertext.ColorBag[3] = 8 + 32
  55.    Hypertext.ColorBag[4] = 8 + 32
  56.    Dynarray Hypertext.WindowBag[]
  57.    Hypertext.HypertextKey = Asc("Enter")
  58.    Hypertext.Prompt =
  59.       "[Tab/ShiftTab] for next/prev hotspot; [Enter] to select hypertext"
  60.    Hypertext.HighLightColor = 112 + 4
  61.    Hypertext.HotSpotColor = 64 + 15
  62.    Hypertext.TextColor = 112 + 0
  63. EndProc ; Hypertext.Constructor
  64.  
  65. Proc Hypertext.Destructor()
  66.    Release Vars
  67.       Hypertext_HelpText,
  68.       Hypertext_nHotSpots,
  69.       Hypertext_CurrentHotSpot,
  70.       Hypertext_StackDepth,
  71.       Hypertext_StackCurrent,
  72.       Hypertext_StackHeight,
  73.       Hypertext_StackWidth,
  74.       Hypertext_StackRow,
  75.       Hypertext_StackCol,
  76.       Hypertext_StackName,
  77.       Hypertext_ErrorCode,
  78.       Hypertext_PanelName,
  79.       Hypertext.ColorBag,
  80.       Hypertext.WindowBag,
  81.       Hypertext.HypertextKey,
  82.       Hypertext.Prompt,
  83.       Hypertext.HotSpotColor,
  84.       Hypertext.HighLightColor,
  85.       Hypertext.WindowHandle,
  86.       Hypertext.HotSpotStartCol,
  87.       Hypertext.HotSpotEndCol,
  88.       Hypertext.HotSpotStartLine,
  89.       Hypertext.HotSpotEndLint,
  90.       Hypertext.HotSpotString,
  91.       Hypertext.HotSpotReference,
  92.       Hypertext.Hieght,
  93.       Hypertext.Width,
  94.       Hypertext.HotSpot
  95. EndProc ; Hypertext.Destructor
  96.  
  97. ;--------------------------- SHOW HELP Panel -------------------------------
  98.  
  99. Proc Hypertext.ShowPanel(PanelName)
  100.    Private
  101.       WindowBag,
  102.       StartWindowHandle,
  103.       CRow,
  104.       CCol,
  105.       ErrorProc,
  106.       Found
  107.    StartWindowHandle = GetWindow()
  108.    ShowPullDown
  109.       "NextHotSpot":"Moveto next HotSpot":"NextHotSpot",
  110.       "PrevHotSpot":"Moveto previous HotSpot":"PrevHotSpot",
  111.       "SelectHotSpot":"Select current HotSpot":"SelectHotSpot",
  112.       "P~r~evPanel":"Move back to parent panel, or quit":"ParentPanel",
  113.       "Quit":"Leave help panel":"QuitPanel"
  114.    EndMenu
  115.    Prompt Hypertext.Prompt
  116.    PanelName = Upper(PanelName)
  117.    Hypertext!SetStack()
  118.    Dynarray WindowBag[]
  119.    WindowBag["CanvasHeight"] = 200
  120.    WindowBag["CanvasWidth"] = 132
  121.    Window Create Floating @500,500 Attributes WindowBag
  122.       To Hypertext.WindowHandle
  123.    Cursor Normal
  124.    Window SetColors Hypertext.WindowHandle From Hypertext.ColorBag
  125.    PaintCanvas Attribute Hypertext.TextColor All
  126.    Hypertext_PanelName = PanelName
  127.    Canvas off
  128.    Hypertext_ErrorCode = 0
  129.    ErrorProc = "Hypertext.ErrorProc"
  130.    ExecProc "HyperPanel." + PanelName
  131.    ErrorProc = ""
  132.    If Hypertext_ErrorCode <> 34 Then
  133.       CRow = 0
  134.       CCol = 0
  135.       @CRow,CCol
  136.       Hypertext_nHotSpots = Dynarraysize(HyperText.HotSpotString)
  137.       Found = False
  138.       If IsAssigned(Hypertext.HotSpot) Then
  139.          Hypertext.HotSpot = Upper(Hypertext.HotSpot)
  140.          ForEach Element In Hypertext.HotSpotReference
  141.             Found = (Upper(Hypertext.HotSpotString[Element]) = Hypertext.HotSpot)
  142.             If Found Then
  143.                Hypertext_CurrentHotSpot = NumVal(Element)
  144.                QuitLoop
  145.             Endif
  146.          EndForEach
  147.       Endif
  148.       If Not Found Then
  149.          Hypertext_CurrentHotSpot = Min(Hypertext_nHotSpots,1)
  150.       Endif
  151.       Hypertext!HighlightHotSpots()
  152.       Hypertext!SetHotSpot(Hypertext_CurrentHotSpot)
  153.       Canvas on
  154.       if Hypertext_currentHotSpot > 0 then
  155.          CRow = HyperText.HotSpotStartLine[Hypertext_CurrentHotSpot] - 1
  156.          CCol = Hypertext.HotSpotStartCol[Hypertext_CurrentHotSpot] - 1
  157.       endif
  158.       @CRow,CCol
  159.       Hypertext!BrowseText()
  160.    Else
  161.       Message PanelName, " panel not found."
  162.       Hypertext_ErrorCode = 0
  163.    Endif
  164.    Window Select Hypertext.WindowHandle
  165.    Window Close
  166.    If IsWindow(StartWindowHandle) Then
  167.       Window Select StartWindowHandle
  168.    Endif
  169.    Return True
  170. EndProc ; Hypertext.ShowPanel
  171.  
  172. Proc Hypertext.ErrorProc()
  173.    Hypertext_ErrorCode = ErrorCode()
  174.    Return 1
  175. EndProc ; Hypertext.ErrorProc
  176.  
  177. Proc Hypertext!HighlightHotSpots()
  178.    Private
  179.       HotSpotNum,
  180.       Length,
  181.       FirstHalfLength,
  182.       LastHalfLength
  183.    SetCanvas Hypertext.WindowHandle
  184.    For HotSpotNum From 1 to Hypertext_nHotSpots
  185.       Hypertext!SetHotSpotColor(HotSpotNum,Hypertext.HighLightColor)
  186.    EndFor
  187. EndProc ; Hypertext!HighlightHotSpots
  188.  
  189. Proc Hypertext!SetHotSpotColor(HotSpotNum,HighLightColor)
  190.    Private
  191.       FirstHalfLength
  192.    If Hypertext.HotSpotStartLine[HotSpotNum] =
  193.       Hypertext.HotSpotEndLine[HotSpotNum] Then
  194.       PaintCanvas Attribute HighlightColor
  195.          Hypertext.HotSpotStartLine[HotSpotNum] -1,
  196.          Hypertext.HotSpotStartCol[HotSpotNum] -1,
  197.          Hypertext.HotSpotEndLine[HotSpotNum] -1,
  198.          Hypertext.HotSpotEndCol[HotSpotNum] -1
  199.    Else
  200.       FirstHalfLength = Len(Hypertext.HotSpotString[HotSpotNum]) + 2 -
  201.                             (Hypertext.HotSpotEndCol[HotSpotNum] + 1)
  202.       PaintCanvas Attribute HighlightColor
  203.          Hypertext.HotSpotStartLine[HotSpotNum] -1,
  204.          Hypertext.HotSpotStartCol[HotSpotNum] -1,
  205.          Hypertext.HotSpotStartLine[HotSpotNum] -1,
  206.          Hypertext.HotSpotStartCol[HotSpotNum] + FirstHalfLength  -2
  207.       PaintCanvas Attribute HighlightColor
  208.          Hypertext.HotSpotEndLine[HotSpotNum] -1, 0,
  209.          Hypertext.HotSpotEndLine[HotSpotNum] -1,
  210.          Hypertext.HotSpotEndCol[HotSpotNum] -1
  211.    Endif
  212. EndProc ; Hypertext!SetHotSpotColor
  213.  
  214. Proc Hypertext!SetHotSpot(HotSpotNum)
  215.    If HotSpotNum = 0 Then
  216.       Return
  217.    Endif
  218.    If HotSpotNum <> Hypertext_CurrentHotSpot Then
  219.       Hypertext!SetHotSpotColor(
  220.          Hypertext_CurrentHotSpot,Hypertext.HighLightColor)
  221.       Hypertext_CurrentHotSpot = HotSpotNum
  222.    Endif
  223.    Hypertext!SetHotSpotColor(
  224.       Hypertext_CurrentHotSpot,Hypertext.HotSpotColor)
  225. EndProc ; Hypertext!SetHotSpot
  226.  
  227. Proc Hypertext!SetStack()
  228.    Hypertext_StackDepth = 0
  229.    Dynarray Hypertext_StackCurrent[]
  230.    Dynarray Hypertext_StackName[]
  231.    Dynarray Hypertext_StackHeight[]
  232.    Dynarray Hypertext_StackWidth[]
  233.    Dynarray Hypertext_StackRow[]
  234.    Dynarray Hypertext_StackCol[]
  235. EndProc ; Hypertext!SetStack
  236.  
  237. Proc Hypertext!BrowseText()
  238.    Private
  239.       Browsing,
  240.       EventBag,
  241.       Keycode,
  242.       MessageTag,
  243.       MenuTag,
  244.       WindowBag,
  245.       MRow,
  246.       MCol
  247.    Browsing = True
  248.    While Browsing
  249.       GetEvent All To EventBag
  250.       Switch
  251.          Case EventBag["Type"] = "KEY":
  252.             Keycode = EventBag["Keycode"]
  253.             Switch
  254.                Case KeyCode = Asc("F2"):
  255.                   Browsing = False
  256.                Case KeyCode = Asc("Esc"):
  257.                   If Not Hypertext!PrevPanel() Then
  258.                      Browsing = False
  259.                   Endif
  260.                Case KeyCode = Asc("Tab"):
  261.                   Hypertext!GotoNextHotSpot()
  262.                Case KeyCode = Asc("ReverseTab"):
  263.                   Hypertext!GotoPrevHotSpot()
  264.                Case KeyCode = Hypertext.HypertextKey:
  265.                   Hypertext!SelectHotSpot()
  266.                Case KeyCode = Asc("WinMax"):
  267.                   WinMax
  268.                Case KeyCode = Asc("WinResize"):
  269.                   WinResize
  270.                Case Keycode = Asc("Home"):
  271.                   CCol = 0
  272.                   @CRow,CCol
  273.                   Hypertext!ResetHotSpot()
  274.                Case Keycode = Asc("End"):
  275.                   CCol = Hypertext.Width
  276.                   @CRow,CCol
  277.                   Hypertext!ResetHotSpot()
  278.                Case Keycode = Asc("PgUp"):
  279.                   Window GetAttributes Hypertext.WindowHandle To WindowBag
  280.                   CRow = Max(CRow - (WindowBag["Height"] - 3),0)
  281.                   @CRow,CCol
  282.                   Hypertext!ResetHotSpot()
  283.                Case Keycode = Asc("PgDn"):
  284.                   Window GetAttributes Hypertext.WindowHandle To WindowBag
  285.                   CRow = Min(CRow + (WindowBag["Height"] - 3),Hypertext.Height - 1)
  286.                   @CRow,CCol
  287.                   Hypertext!ResetHotSpot()
  288.                Case Keycode = Asc("Left"):
  289.                   CCol = CCol - 1
  290.                   If CCol < 0 Then
  291.                      If CRow > 0 Then
  292.                         CCol = Hypertext.Width
  293.                         CRow = CRow - 1
  294.                      Else
  295.                         CCol = 0
  296.                      Endif
  297.                   Endif
  298.                   @CRow,CCol
  299.                   Hypertext!ResetHotSpot()
  300.                Case Keycode = Asc("Right"):
  301.                   CCol = CCol + 1
  302.                   If CCol > Hypertext.Width Then
  303.                      If CRow < Hypertext.Height - 1 Then
  304.                         CCol = 0
  305.                         CRow = CRow + 1
  306.                      Else
  307.                         CCol = Hypertext.Width
  308.                      Endif
  309.                   Endif
  310.                   @CRow,CCol
  311.                   Hypertext!ResetHotSpot()
  312.                Case Keycode = Asc("Up"):
  313.                   If CRow > 0 Then
  314.                      CRow = Crow - 1
  315.                   Endif
  316.                   @CRow,CCol
  317.                   Hypertext!ResetHotSpot()
  318.                Case Keycode = Asc("Down"):
  319.                   If CRow < Hypertext.Height - 1 Then
  320.                      CRow = Crow + 1
  321.                   Endif
  322.                   @CRow,CCol
  323.                   Hypertext!ResetHotSpot()
  324.                Case Keycode = Asc("CtrlPgUp"):
  325.                   Crow = 0
  326.                   @CRow,CCol
  327.                   Hypertext!ResetHotSpot()
  328.                Case Keycode = Asc("CtrlPgDn"):
  329.                   CRow = Hypertext.Height - 1
  330.                   @CRow,CCol
  331.                   Hypertext!ResetHotSpot()
  332.                Case Keycode = Asc("CtrlLeft"):
  333.                   If CCol > 20 Then
  334.                      CCol = CCol - 20
  335.                   Else
  336.                      CCol = 0
  337.                   Endif
  338.                   @CRow,CCol
  339.                   Hypertext!ResetHotSpot()
  340.                Case Keycode = Asc("CtrlRight"):
  341.                   If CCol < Hypertext.Width - 21 Then
  342.                      CCol = CCol + 20
  343.                   Else
  344.                      CCol = Hypertext.Width
  345.                   Endif
  346.                   @CRow,CCol
  347.                   Hypertext!ResetHotSpot()
  348.                OtherWise:
  349.                   ; do nothing... suppress the keystroke.
  350.             EndSwitch
  351.          Case EventBag["Type"] = "MESSAGE":
  352.             MessageTag = EventBag["Message"]
  353.             Switch
  354.                Case MessageTag = "CLOSE":
  355.                   Browsing = False
  356.                Case MessageTag = "MENUSELECT":
  357.                   MenuTag = EventBag["MenuTag"]
  358.                   Switch
  359.                      Case MenuTag = "NextHotSpot":
  360.                         Hypertext!GotoNextHotSpot()
  361.                      Case MenuTag = "PrevHotSpot":
  362.                         Hypertext!GotoPrevHotSpot()
  363.                      Case MenuTag = "SelectHotSpot":
  364.                         Hypertext!SelectHotSpot()
  365.                      Case MenuTag = "ParentPanel":
  366.                         If Not Hypertext!PrevPanel() Then
  367.                            Browsing = False
  368.                         Endif
  369.                      Case MenuTag = "QuitPanel":
  370.                         Browsing = False
  371.                   EndSwitch
  372.                OtherWise:
  373.                   ExecEvent EventBag
  374.             EndSwitch
  375.          Case EventBag["Type"] = "MOUSE":
  376.             EventTag = EventBag["Buttons"] +
  377.                  IIf(EventBag["Doubleclick"],"DOUBLE","") +
  378.                  EventBag["Action"]
  379.             Switch
  380.                Case WindowAt(EventBag["Row"],EventBag["Col"]) <>
  381.                   GetWindow(): ; do nothing
  382.                Case EventTag = "LEFTDOUBLEDOWN":
  383.                   MRow = EventBag["Row"]
  384.                   MCol = EventBag["Col"]
  385.                   LocalizeEvent EventBag
  386.                   Window GetAttributes Hypertext.WindowHandle To WindowBag
  387.                   If EventBag["Row"] = 0 or EventBag["Col"] = 0 or
  388.                      EventBag["Row"] = WindowBag["Height"] - 1 or
  389.                      EventBag["Col"] = WindowBag["Width"] - 1 Then
  390.                      EventBag["Row"] = MRow
  391.                      EventBag["Col"] = MCol
  392.                      ExecEvent EventBag
  393.                   Else
  394.                      If WindowBag["ScrollRow"] + EventBag["Row"] - 1 = CRow And
  395.                         WindowBag["ScrollCol"] + EventBag["Col"] - 1 = CCol And
  396.                         Hypertext!GetHotSpotNumber() <> 0 Then
  397.                         Hypertext!SelectHotSpot()
  398.                      Endif
  399.                   Endif
  400.                Case EventTag = "RIGHTDOWN":
  401.                   If Not Hypertext!PrevPanel() Then
  402.                      Browsing = False
  403.                   Endif
  404.                Case EventTag = "LEFTDOWN":
  405.                   MRow = EventBag["Row"]
  406.                   MCol = EventBag["Col"]
  407.                   LocalizeEvent EventBag
  408.                   Window GetAttributes Hypertext.WindowHandle To WindowBag
  409.                   If EventBag["Row"] = 0 or EventBag["Col"] = 0 or
  410.                      EventBag["Row"] = WindowBag["Height"] - 1 or
  411.                      EventBag["Col"] = WindowBag["Width"] - 1 Then
  412.                      EventBag["Row"] = MRow
  413.                      EventBag["Col"] = MCol
  414.                      ExecEvent EventBag
  415.                   Else
  416.                      CRow = WindowBag["ScrollRow"] + EventBag["Row"] - 1
  417.                      CCol = WindowBag["ScrollCol"] + EventBag["Col"] - 1
  418.                      @CRow,CCol
  419.                      Hypertext!ResetHotSpot()
  420.                   Endif
  421.                Case EventBag["DoubleClick"]:
  422.                   ; suppress this
  423.             OtherWise:
  424.                ExecEvent EventBag
  425.             EndSwitch
  426.          Case EventBag["Type"] = "IDLE":
  427.             If IsAssigned(EventMan.IsActive) Then
  428.                EventMan.DoIdleEvent()
  429.                SetCanvas Hypertext.WindowHandle
  430.             Endif
  431.          OtherWise:
  432.             ExecEvent EventBag
  433.       EndSwitch
  434.    EndWhile ; Browsing
  435. EndProc ; Hypertext!BrowseText
  436.  
  437. Proc Hypertext!SelectHotSpot()
  438.    Private
  439.       EditorBag,
  440.       ReferenceText,
  441.       PanelName,
  442.       WindowBag
  443.    If Hypertext_nHotSpots = 0 Then
  444.       Message "No hotspot to select"
  445.       Return
  446.    Endif
  447.    If Not Hypertext!IsVisible() Then
  448.       Message "No hotspots visible"
  449.       Return
  450.    Endif
  451.    If IsBlank(Hypertext.HotSpotReference[Hypertext_CurrentHotSpot]) Then
  452.       Message "No more information on this subject."
  453.       Return
  454.    Endif
  455.    Message "Working..."
  456.    Hypertext_StackDepth = Hypertext_StackDepth + 1
  457.    Hypertext_StackCurrent[Hypertext_StackDepth] = Hypertext_CurrentHotSpot
  458.    Hypertext_StackName[Hypertext_StackDepth] = Hypertext_PanelName
  459.    Window GetAttributes Hypertext.WindowHandle to WindowBag
  460.    Hypertext_StackHeight[Hypertext_StackDepth] = WindowBag["Height"]
  461.    Hypertext_StackWidth[Hypertext_StackDepth] = WindowBag["Width"]
  462.    Hypertext_StackRow[Hypertext_StackDepth] = WindowBag["OriginRow"]
  463.    Hypertext_StackCol[Hypertext_StackDepth] = WindowBag["OriginCol"]
  464.    Hypertext_PanelName = Hypertext.HotSpotReference[Hypertext_CurrentHotSpot]
  465.    SetCanvas Hypertext.WindowHandle
  466.    Canvas off
  467.    Clear
  468.    PaintCanvas Attribute Hypertext.TextColor All
  469.    @0,0
  470.    ExecProc "HyperPanel." + Hypertext_PanelName
  471.    CRow = 0
  472.    CCol = 0
  473.    @CRow,CCol
  474.    Hypertext_nHotSpots = Dynarraysize(HyperText.HotSpotString)
  475.    Hypertext_CurrentHotSpot = Min(Hypertext_nHotSpots,1)
  476.    Hypertext!HighlightHotSpots()
  477.    Hypertext!SetHotSpot(Hypertext_CurrentHotSpot)
  478.    Canvas on
  479.    Message ""
  480. EndProc ; Hypertext!SelectHotSpot
  481.  
  482. Proc Hypertext!IsVisible()
  483.    Private
  484.       WindowBag,
  485.       RowOffset,
  486.       ColOffset,
  487.       WinHeight,
  488.       WinWidth,
  489.       LeftMarker,
  490.       RightMarker,
  491.       TopLine,
  492.       BottomLine,
  493.       FirstHalfLength
  494.    If Hypertext_CurrentHotSpot = 0 Then
  495.       Return False
  496.    Endif
  497.    Window GetAttributes Hypertext.WindowHandle To WindowBag
  498.    RowOffset = WindowBag["ScrollRow"]
  499.    ColOffset = WindowBag["ScrollCol"]
  500.    WinHeight = WindowBag["Height"]
  501.    WinWidth = WindowBag["Width"]
  502.    LeftMarker = Hypertext.HotSpotStartCol[Hypertext_CurrentHotSpot] - 1
  503.    RightMarker = Hypertext.HotSpotEndCol[Hypertext_CurrentHotSpot] - 1
  504.    TopLine = Hypertext.HotSpotStartLine[Hypertext_CurrentHotSpot] - 1
  505.    BottomLine = Hypertext.HotSpotEndLine[Hypertext_CurrentHotSpot] - 1
  506.    If TopLine = BottomLine Then
  507.       If (TopLine >= RowOffset And
  508.          BottomLine < RowOffset + WinHeight - 2) And
  509.          ((LeftMarker >= ColOffset And
  510.          LeftMarker < ColOffset + WinWidth - 2) Or
  511.          (RightMarker >= ColOffset And
  512.           RightMarker < ColOffset + WinWidth - 2)) Then
  513.          Return True
  514.       Else
  515.          Return False
  516.       Endif
  517.    Else
  518.       FirstHalfLength = Len(Hypertext.HotSpotString[Hypertext_CurrentHotSpot]) + 2 -
  519.                             (Hypertext.HotSpotEndCol[Hypertext_CurrentHotSpot] + 1)
  520.       If ((TopLine >= RowOffset And
  521.          TopLine < RowOffset + WinHeight - 2) And
  522.          ((LeftMarker >= ColOffset And
  523.          LeftMarker < ColOffset + WinWidth - 2) Or
  524.          (LeftMarker + FirstHalfLength - 1 >= ColOffset And
  525.           LeftMarker + FirstHalfLength - 1 < ColOffset + WinWidth - 2)))
  526.          ;---
  527.           Or
  528.          ;---
  529.          ((BottomLine >= RowOffset And
  530.          BottomLine < WinHeight - 2) And
  531.          ((0 >= ColOffset And
  532.          0 < WinWidth - 2) Or
  533.          (RightMarker >= ColOffset And
  534.           RightMarker < WinWidth - 2)))
  535.          ;---
  536.          Then
  537.          ;---
  538.          Return True
  539.       Else
  540.          Return False
  541.       Endif
  542.    Endif
  543. EndProc ; Hypertext!IsVisible
  544.  
  545. Proc Hypertext!PrevPanel()
  546.    Private
  547.       WindowBag
  548.    If Hypertext_StackDepth = 0 Then
  549.       Return False
  550.    Else
  551.       Message "Working..."
  552.       Hypertext_PanelName = Hypertext_StackName[Hypertext_StackDepth]
  553.       Hypertext_CurrentHotSpot = Hypertext_StackCurrent[Hypertext_StackDepth]
  554.       Release Vars
  555.          Hypertext_StackName[Hypertext_StackDepth],
  556.          Hypertext_StackCurrent[Hypertext_StackDepth]
  557.       SetCanvas Hypertext.WindowHandle
  558.       Canvas off
  559.       Clear
  560.       PaintCanvas Attribute Hypertext.TextColor All
  561.       @0,0
  562.       Hypertext_StackDepth = Hypertext_StackDepth - 1
  563.                 ; to accomodate depth marker in title
  564.       ExecProc "HyperPanel." + Hypertext_PanelName
  565.       Hypertext_StackDepth = Hypertext_StackDepth + 1
  566.       Dynarray WindowBag[]
  567.       WindowBag["Height"] = Hypertext_StackHeight[Hypertext_StackDepth]
  568.       WindowBag["Width"] = Hypertext_StackWidth[Hypertext_StackDepth]
  569.       WindowBag["OriginRow"] = Hypertext_StackRow[Hypertext_StackDepth]
  570.       WindowBag["OriginCol"] = Hypertext_StackCol[Hypertext_StackDepth]
  571.       Window SetAttributes Hypertext.WindowHandle From WindowBag
  572.       Hypertext_StackDepth = Hypertext_StackDepth - 1
  573.       @0,0
  574.       Hypertext_nHotSpots = Dynarraysize(HyperText.HotSpotString)
  575.       Hypertext!HighlightHotSpots()
  576.       Hypertext!SetHotSpot(Hypertext_CurrentHotSpot)
  577.       CRow = HyperText.HotSpotStartLine[Hypertext_CurrentHotSpot] - 1
  578.       CCol = HyperText.HotSpotStartCol[Hypertext_CurrentHotSpot] - 1
  579.       @CRow,CCol
  580.       Canvas on
  581.       Message ""
  582.       Return True
  583.    Endif
  584. EndProc ; Hypertext!PrevPanel
  585.  
  586. Proc Hypertext!GotoNextHotSpot()
  587.    Private
  588.       NextHotSpot
  589.    If Hypertext_nHotSpots = 0 Then
  590.       Return
  591.    Endif
  592.    NextHotSpot = Hypertext!GetNextHotSpot()
  593.    Hypertext!SetHotSpot(NextHotSpot)
  594.    CRow = HyperText.HotSpotStartLine[Hypertext_CurrentHotSpot] - 1
  595.    CCol = Hypertext.HotSpotStartCol[Hypertext_CurrentHotSpot] - 1
  596.    @CRow,CCol
  597. EndProc ; Hypertext!GotoNextHotSpot
  598.  
  599. Proc Hypertext!GetNextHotSpot()
  600.    Private
  601.       HotSpotNum
  602.    HotSpotNum = 1
  603.    ;-------------------------------------------------------------------------
  604.    ; Find the next row for a hotspot
  605.    ;-------------------------------------------------------------------------
  606.    While HotSpotNum <= Hypertext_nHotSpots And
  607.       CRow > Hypertext.HotSpotStartLine[HotSpotNum] - 1
  608.       HotSpotNum = HotSpotNum + 1
  609.    EndWhile
  610.    ;-------------------------------------------------------------------------
  611.    ; If the next row is the current row then try to find the next hotspot on
  612.    ; the line
  613.    ;-------------------------------------------------------------------------
  614.    If HotSpotNum <= Hypertext_nHotSpots And
  615.       CRow = Hypertext.HotSpotStartLine[HotSpotNum] - 1 Then
  616.       While HotSpotNum <= Hypertext_nHotSpots And
  617.          CRow = Hypertext.HotSpotStartLine[HotSpotNum] - 1 And
  618.          CCol >= Hypertext.HotSpotStartCol[HotSpotNum] - 1
  619.          HotSpotNum = HotSpotNum + 1
  620.       EndWhile
  621.       If HotSpotNum <= Hypertext_nHotSpots And
  622.          CRow = Hypertext.HotSpotStartLine[HotSpotNum] - 1 And
  623.          CCol < Hypertext.HotSpotStartCol[HotSpotNum] - 1 Then
  624.          Return HotSpotNum
  625.       Endif
  626.    Endif
  627.    ;-------------------------------------------------------------------------
  628.    ; Resolve the situation by getting the next available hotspot...
  629.    ;-------------------------------------------------------------------------
  630.    If HotSpotNum > Hypertext_nHotSpots Then
  631.       HotSpotNum = 1
  632.    Endif
  633.    Return HotSpotNum
  634. EndProc ; Hypertext!GetNextHotSpot
  635.  
  636. Proc Hypertext!GotoPrevHotSpot()
  637.    Private
  638.       NextHotSpot
  639.    If Hypertext_nHotSpots = 0 Then
  640.       Return
  641.    Endif
  642.    NextHotSpot = Hypertext!GetPrevHotSpot()
  643.    Hypertext!SetHotSpot(NextHotSpot)
  644.    CRow = HyperText.HotSpotStartLine[Hypertext_CurrentHotSpot] - 1
  645.    CCol = Hypertext.HotSpotStartCol[Hypertext_CurrentHotSpot] - 1
  646.    @CRow,CCol
  647. EndProc ; Hypertext!GotoPrevHotSpot
  648.  
  649. Proc Hypertext!GetPrevHotSpot()
  650.    Private
  651.       HotSpotNum
  652.    HotSpotNum = Hypertext_nHotSpots
  653.    ;-------------------------------------------------------------------------
  654.    ; Find the previous row for a hotspot
  655.    ;-------------------------------------------------------------------------
  656.    While HotSpotNum >= 1 And
  657.       CRow < Hypertext.HotSpotStartLine[HotSpotNum] - 1
  658.       HotSpotNum = HotSpotNum - 1
  659.    EndWhile
  660.    ;-------------------------------------------------------------------------
  661.    ; If the next row is the current row then try to find the previous hotspot
  662.    ; on the line
  663.    ;-------------------------------------------------------------------------
  664.    If HotSpotNum >= 1 And
  665.       CRow = Hypertext.HotSpotStartLine[HotSpotNum] - 1 Then
  666.       While HotSpotNum >= 1 And
  667.          CRow = Hypertext.HotSpotStartLine[HotSpotNum] - 1 And
  668.          CCol <= Hypertext.HotSpotStartCol[HotSpotNum] - 1
  669.          HotSpotNum = HotSpotNum - 1
  670.       EndWhile
  671.       If HotSpotNum >= 1 And
  672.          CRow = Hypertext.HotSpotStartLine[HotSpotNum] - 1 And
  673.          CCol > Hypertext.HotSpotStartCol[HotSpotNum] - 1 Then
  674.          Return HotSpotNum
  675.       Endif
  676.    Endif
  677.    ;-------------------------------------------------------------------------
  678.    ; Resolve the situation by getting the previous available hotspot...
  679.    ;-------------------------------------------------------------------------
  680.    If HotSpotNum < 1 Then
  681.       HotSpotNum = Hypertext_nHotSpots
  682.    Endif
  683.    Return HotSpotNum
  684. EndProc ; Hypertext!GetPrevHotSpot
  685.  
  686. Proc Hypertext!GetHotSpotNumber()
  687.    Private
  688.       HotSpotNum
  689.    HotSpotNum = 1
  690.    While HotSpotNum <= Hypertext_nHotSpots And
  691.       (Hypertext.HotSpotStartLine[HotSpotNum] - 1 < CRow And
  692.       Hypertext.HotSpotEndLine[HotSpotNum] - 1 < CRow)
  693.       HotSpotNum = HotSpotNum + 1
  694.    EndWhile
  695.    If HotSpotNum <= Hypertext_nHotSpots And
  696.       (Hypertext.HotSpotStartLine[HotSpotNum] -1 = CRow or
  697.       Hypertext.HotSpotEndLine[HotSpotNum] - 1 = CRow) Then
  698.       While HotSpotNum <= Hypertext_nHotSpots And
  699.          (Hypertext.HotSpotStartLine[HotSpotNum] -1 = CRow or
  700.          Hypertext.HotSpotEndLine[HotSpotNum] - 1 = CRow)
  701.          If (Hypertext.HotSpotStartCol[HotSpotNum] - 1 <= CCol And
  702.              Hypertext.HotSpotEndCol[HotSpotNum] - 1 >= CCol) or
  703.             (Hypertext.HotSpotEndCol[HotSpotNum] - 1 >= CCol and
  704.              Hypertext.HotSpotEndLine[HotSpotNum] -1 = CRow And
  705.              Hypertext.HotSpotStartLine[HotSpotNum] -1 < CRow) Or
  706.             (Hypertext.HotSpotStartCol[HotSpotNum] - 1 <= CCol and
  707.              Hypertext.HotSpotEndLine[HotSpotNum] -1 > CRow And
  708.              Hypertext.HotSpotStartLine[HotSpotNum] -1 = CRow) Then
  709.              Return HotSpotNum
  710.          Endif
  711.          HotSpotNum = HotSpotNum + 1
  712.       EndWhile
  713.    Endif
  714.    Return 0
  715. EndProc ; Hypertext!GetHotSpotNumber
  716.  
  717. Proc Hypertext!ResetHotSpot()
  718.    Private
  719.       HotSpotNum
  720.    If Hypertext_nHotSpots > 0 Then
  721.       HotSpotNum = Hypertext!GetHotSpotNumber()
  722.       If  (HotSpotNum <> 0) And (HotSpotNum <> Hypertext_CurrentHotSpot) Then
  723.          Hypertext!SetHotSpot(HotSpotNum)
  724.       Endif
  725.    Endif
  726. EndProc ; Hypertext!ResetHotSpot
  727.  
  728. Proc Hypertext.StartWithPanel(PanelName)
  729.    Hypertext.Constructor()
  730.    Hypertext.ShowPanel(PanelName)
  731.    Hypertext.Destructor()
  732. EndProc ; Hypertext.StartWithPanel
  733.  
  734. If IsAssigned(Librarian.HasControl) And
  735.    IsAssigned(Librarian.WriteToHelpLib) Then
  736.    WriteLib Librarian.LibSpec
  737.       Hypertext.Constructor,
  738.       Hypertext.Destructor,
  739.       Hypertext.ShowPanel,
  740.       Hypertext.ErrorProc,
  741.       Hypertext!HighlightHotSpots,
  742.       Hypertext!SetHotSpotColor,
  743.       Hypertext!SetHotSpot,
  744.       Hypertext!SetStack,
  745.       Hypertext!BrowseText,
  746.       Hypertext!SelectHotSpot,
  747.       Hypertext!IsVisible,
  748.       Hypertext!PrevPanel,
  749.       Hypertext!GotoNextHotSpot,
  750.       Hypertext!GetNextHotSpot,
  751.       Hypertext!GotoPrevHotSpot,
  752.       Hypertext!GetPrevHotSpot,
  753.       Hypertext!GetHotSpotNumber,
  754.       Hypertext!ResetHotSpot,
  755.       Hypertext.StartWithPanel
  756.  
  757.    Release Procs
  758.       Hypertext.Constructor,
  759.       Hypertext.Destructor,
  760.       Hypertext.ShowPanel,
  761.       Hypertext.ErrorProc,
  762.       Hypertext!HighlightHotSpots,
  763.       Hypertext!SetHotSpotColor,
  764.       Hypertext!SetHotSpot,
  765.       Hypertext!SetStack,
  766.       Hypertext!BrowseText,
  767.       Hypertext!SelectHotSpot,
  768.       Hypertext!IsVisible,
  769.       Hypertext!PrevPanel,
  770.       Hypertext!GotoNextHotSpot,
  771.       Hypertext!GetNextHotSpot,
  772.       Hypertext!GotoPrevHotSpot,
  773.       Hypertext!GetPrevHotSpot,
  774.       Hypertext!GetHotSpotNumber,
  775.       Hypertext!ResetHotSpot,
  776.       Hypertext.StartWithPanel
  777. Endif