home *** CD-ROM | disk | FTP | other *** search
/ Monster Media 1993 #2 / Image.iso / database / pk4pak.zip / KEYBAR.SC < prev    next >
Text File  |  1993-02-03  |  7KB  |  194 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. ; KeyBar version 1.1
  11.  
  12. Proc KeyBar.Constructor()
  13.    If Not IsAssigned(ButtonMan.IsActive) Then
  14.       ButtonMan.Constructor()
  15.    Endif
  16.    Dynarray KeyBar.ButtonBag[]
  17.    KeyBar.ButtonBag["HELP"]   = Asc("F1")
  18.    KeyBar.ButtonBag["ESC"]    = Asc("Esc")
  19.    KeyBar.ButtonBag["CLOSE"]  = Asc("WinClose")
  20.    KeyBar.ButtonBag["NEXT"]   = Asc("WinNext")
  21.    KeyBar.ButtonBag["EDIT"]   = Asc("CoEditKey")
  22.    KeyBar.ButtonBag["FIELD"]  = Asc("Fieldview")
  23.    KeyBar.ButtonBag["INS"]    = Asc("Ins")
  24.    KeyBar.ButtonBag["DEL"]    = Asc("Del")
  25.    KeyBar.ButtonBag["UNDO"]   = Asc("Undo")
  26.    KeyBar.ButtonBag["DO IT"]  = Asc("Do_It!")
  27.    KeyBar.ButtonBag[" ???"]   = Asc("Zoom")
  28.    KeyBar.ButtonBag[" ?.."]   = Asc("ZoomNext")
  29.    KeyBar.ButtonBag[" ▐"]    = Asc("Home")
  30.    KeyBar.ButtonBag[" "]    = Asc("PgUp")
  31.    KeyBar.ButtonBag["  "]    = Asc("CtrlPgUp")
  32.    KeyBar.ButtonBag["  "]    = Asc("CtrlPgDn")
  33.    KeyBar.ButtonBag[" "]    = Asc("PgDn")
  34.    KeyBar.ButtonBag[" ▌"]    = Asc("End")
  35.    KeyBar.ButtonBag[" ─┘"]   = Asc("Enter")
  36.    KeyBar.Row = BlankNum()
  37.    KeyBar.Col = BlankNum()
  38.    KeyBar.IsHidden = False
  39.    KeyBar.IsActive = True
  40. EndProc ; KeyBar.Constructor
  41.  
  42. Proc KeyBar.Destructor()
  43.    Release Vars
  44.       KeyBar.ButtonBag,
  45.       KeyBar.IsActive,
  46.       KeyBar.Row,
  47.       KeyBar.Col,
  48.       KeyBar.IsHidden
  49. EndProc ; KeyBar.Destructor
  50.  
  51. Proc KeyBar.PushButton()
  52.    Private
  53.       SelectedButton,
  54.       ReturnCode,
  55.       ObjectTag,
  56.       WorkspaceTag
  57.    ; ************* Moveto alternate window?
  58.    SelectedButton = ButtonMan.Property[EventMan.ObjectTag + "ButtonTag"]
  59.    ForEach Element in EventMan.EventBag
  60.       Release Vars EventMan.EventBag[Element]
  61.    EndForEach
  62.    EventMan.EventBag["Type"] = "KEY"
  63.    EventMan.EventBag["Buttons"] = "NONE" ; required to get out of
  64.                                          ; completeMouseSequence
  65.    EventMan.EventBag["Keycode"] = KeyBar.ButtonBag[SelectedButton]
  66.    EventMan.TargetWindow =
  67.       EventMan.GetTargetWindow("EVENT",EventMan.EventBag)
  68.    ; EventMan.ObjectTag = WorkspaceTag *************
  69.    ; If EventMan.ObjectTag = "" Then
  70.       ExecProc EventMan.SetObjectTagProc
  71.    ; Endif
  72.    If IsAssigned(EventMan.ObjectTypeBag[EventMan.ObjectTag]) And
  73.       EventMan.ObjectType = "TABLE" Then
  74.       Switch
  75.          Case EventMan.EventBag["Keycode"] = Asc("CtrlPgUp"):
  76.             EventMan.EventBag["Keycode"] = Asc("Up")
  77.          Case EventMan.EventBag["Keycode"] = Asc("CtrlPgDn"):
  78.             EventMan.EventBag["Keycode"] = Asc("Down")
  79.       EndSwitch
  80.    Endif
  81.    EventMan.DispatchEventBag()
  82.    ReturnCode = EventMan.ReturnCode
  83.    Return ReturnCode
  84. EndProc ; KeyBar.PushButton
  85.  
  86. Proc KeyBar.MakeButtonBar()
  87.    Private
  88.       PropertyBag,
  89.       ButtonBag,
  90.       WindowBag,
  91.       ColorBag,
  92.       SysinfoBag,
  93.       Bkg
  94.  
  95.    Dynarray PropertyBag[]
  96.    Dynarray ButtonBag[]
  97.    Dynarray WindowBag[]
  98.    Dynarray ColorBag[]
  99.  
  100.    If True Then ; SysMode() = "Main" Then
  101.       ButtonBag[" ▐"]     = Chr(1)  + "KeyBar.PushButton"
  102.       ButtonBag[" "]     = Chr(2)  + "KeyBar.PushButton"
  103.       ButtonBag["  "]     = Chr(3)  + "KeyBar.PushButton"
  104.       ButtonBag["  "]     = Chr(4)  + "KeyBar.PushButton"
  105.       ButtonBag[" "]     = Chr(5)  + "KeyBar.PushButton"
  106.       ButtonBag[" ▌"]     = Chr(6)  + "KeyBar.PushButton"
  107.       ButtonBag[" ─┘"]    = Chr(7)  + "KeyBar.PushButton"
  108.       ButtonBag["Help"]   = Chr(8)  + "KeyBar.PushButton"
  109.       ButtonBag["Esc"]    = Chr(9)  + "KeyBar.PushButton"
  110.       ButtonBag["Close"]   = Chr(10) + "KeyBar.PushButton"
  111.       ButtonBag["Next"]    = Chr(11) + "KeyBar.PushButton"
  112.       ButtonBag["Field"]   = Chr(12) + "KeyBar.PushButton"
  113.       ButtonBag[" ???"]    = Chr(13) + "KeyBar.PushButton"
  114.       ButtonBag[" ?.."]    = Chr(14) + "KeyBar.PushButton"
  115.    Else
  116.       ButtonBag[" ▐"]     = Chr(1)  + "KeyBar.PushButton"
  117.       ButtonBag[" "]     = Chr(2)  + "KeyBar.PushButton"
  118.       ButtonBag["  "]     = Chr(3)  + "KeyBar.PushButton"
  119.       ButtonBag["  "]     = Chr(4)  + "KeyBar.PushButton"
  120.       ButtonBag[" "]     = Chr(5)  + "KeyBar.PushButton"
  121.       ButtonBag[" ▌"]     = Chr(6)  + "KeyBar.PushButton"
  122.       ButtonBag[" ─┘"]    = Chr(7)  + "KeyBar.PushButton"
  123.       ButtonBag["DO IT"]   = Chr(8)  + "KeyBar.PushButton"
  124.       ButtonBag["Esc"]     = Chr(9)  + "KeyBar.PushButton"
  125.       ButtonBag["HELP"]    = Chr(10) + "KeyBar.PushButton"
  126.       ButtonBag["INS"]     = Chr(11) + "KeyBar.PushButton"
  127.       ButtonBag["DEL"]     = Chr(12) + "KeyBar.PushButton"
  128.       ButtonBag["UNDO"]    = Chr(13) + "KeyBar.PushButton"
  129.       ButtonBag["Field"]   = Chr(14) + "KeyBar.PushButton"
  130.    Endif
  131.  
  132.    PropertyBag["ObjectTag"] = "KeyBar"
  133.    PropertyBag["Action"] = "Toggle"
  134.    PropertyBag["WrapCount"] = 7
  135.    Bkg = 48 ; cyan
  136.    PropertyBag["CanvasColor"] = Bkg + 0
  137.    PropertyBag["HighlightColor"] = Bkg + 11
  138.    PropertyBag["ShadowColor"] = Bkg + 8
  139.    PropertyBag["ButtonColor"] = Bkg + 0
  140.    PropertyBag["SelectedColor"] = Bkg + 4
  141.    PropertyBag["UserScript"] = "!Keybar"
  142.  
  143.    WindowBag["Title"] = "Key Bar"
  144.    WindowBag["HasFrame"] = False
  145.  
  146.    If Not IsAssigned(ButtonMan.Property["KeyBarObjectTag"]) Then
  147.       Sysinfo To SysinfoBag
  148.       WindowBag["OriginRow"] = SysinfoBag["ScreenHeight"] - 7
  149.       WindowBag["OriginCol"] = 0
  150.    Endif
  151.    ButtonMan.MakeButtonBar(PropertyBag,ButtonBag,WindowBag,ColorBag)
  152.  
  153. EndProc ; KeyBar.MakeButtonBar
  154.  
  155. Proc KeyBar.DestroyButtonBar()
  156.    Private
  157.       CurrentWindow,
  158.       IsButtonBarWindow,
  159.       ResponseCode,
  160.       WindowBag,
  161.       WindowHandle
  162.  
  163.    ResponseCode = 0
  164.    If IsAssigned(ButtonMan.Property["KeyBarObjectTag"]) Then
  165.       WindowHandle = EventMan.ObjectTagWindow["KeyBar"]
  166.       IsButtonBarWindow = (WindowHandle = GetWindow())
  167.       CurrentWindow = GetWindow()
  168.       Window Select WindowHandle
  169.       Window GetAttributes WindowHandle To WindowBag
  170.       ButtonMan.DestroyButtonBar("KeyBar")
  171.       If IsWindow(CurrentWindow) Then
  172.          Window Select CurrentWindow
  173.       Endif
  174.    Endif
  175.    Return ResponseCode
  176. EndProc ; KeyBar.DestroyButtonBar
  177.  
  178. Proc KeyBar.Hide()
  179.    Private
  180.       WindowBag
  181.    If IsAssigned(KeyBar.IsActive) Then
  182.       Window GetAttributes EventMan.ObjectTagWindow["Keybar"] To WindowBag
  183.       KeyBar.Row = WindowBag["OriginRow"]
  184.       KeyBar.Col = WindowBag["OriginCol"]
  185.       Window Move EventMan.ObjectTagWindow["KeyBar"] To 500,500
  186.       KeyBar.IsHidden = True
  187.    Endif
  188. EndProc ; KeyBar.Hide
  189.  
  190. Proc KeyBar.UnHide()
  191.    If IsAssigned(KeyBar.IsActive) Then
  192.       Window Move EventMan.ObjectTagWindow["KeyBar"] To KeyBar.Row, KeyBar.Col
  193.    Endif
  194. EndProc ; KeyBar.Unhide