home *** CD-ROM | disk | FTP | other *** search
/ Monster Media 1993 #2 / Image.iso / database / pk4pak.zip / BUTTNDEM.SC next >
Text File  |  1993-02-18  |  9KB  |  264 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. ; Demo for ButtonMan, Version 1.5 January, 1993
  11.  
  12. Librarian.HasControl = True
  13. Play Sdir() + "buttnman"
  14. Play Sdir() + "eventman"
  15. Play Sdir() + "packman"
  16. Play Sdir() + "keybar"
  17. Play Sdir() + "colorpal"
  18. Release vars
  19.    Librarian.HasControl
  20.  
  21. EventMan.Constructor()
  22. EventMan.SetObjectTagProc = "EventMan.SetIndexedObjectTag"
  23. ButtonMan.Constructor()
  24.  
  25. Proc Demo.MakeABeep()
  26.    Beep
  27.    Return 1
  28. EndProc
  29.  
  30. Proc Demo.CloseButtonBar()
  31.    ButtonMan.DestroyButtonBar(ButtonMan.ButtonBarTag)
  32.    Return 1
  33. EndProc
  34.  
  35. Proc Demo.Quit()
  36.    Return 2
  37. EndProc
  38.  
  39. Proc Demo.MakeRadioButtonBar()
  40.    Private
  41.       PropertyBag,
  42.       ButtonBag,
  43.       WindowBag,
  44.       ColorBag
  45.    Dynarray PropertyBag[]
  46.    Dynarray ButtonBag[]
  47.    Dynarray WindowBag[]
  48.    Dynarray ColorBag[]
  49.  
  50.    PropertyBag["ObjectTag"] = "ButtonBar1"
  51.    PropertyBag["Action"] = "Radio"
  52.    PropertyBag["ButtonStyle"] = "Border"
  53.    PropertyBag["ButtonColor"] = 96 + 14
  54.    PropertyBag["SelectedColor"] = 96 + 15
  55.    PropertyBag["UserScript"] = "!Button1"
  56.  
  57.    ButtonBag["First"]   = Chr(1)  + "Demo.MakeABeep"
  58.    ButtonBag["Second"]  = Chr(2)  + "Demo.MakeABeep"
  59.    ButtonBag["Third"]   = Chr(3)  + "Demo.MakeABeep"
  60.    ButtonBag["Fourth"]  = Chr(4)  + "Demo.MakeABeep"
  61.    ButtonBag["Fifth"]   = Chr(5)  + "Demo.MakeABeep"
  62.    ButtonBag["Sixth"]   = Chr(6)  + "Demo.MakeABeep"
  63.    ButtonBag["Seventh"] = Chr(7)  + "Demo.MakeABeep"
  64.    ButtonBag["Eighth"]  = Chr(8)  + "Demo.MakeABeep"
  65.    ButtonBag["Close"]   = Chr(9)  + "Demo.CloseButtonBar"
  66.    ButtonBag["Quit"]    = Chr(10) + "Demo.Quit"
  67.  
  68.    WindowBag["Title"] = "Radio Button Bar"
  69.    WindowBag["OriginRow"] = 2
  70.    WindowBag["OriginCol"] = 0
  71.    WindowBag["CanResize"] = True
  72.    WindowBag["HasFrame"] = True
  73.    WindowBag["Floating"] = False
  74.  
  75.    ButtonMan.MakeButtonBar(PropertyBag,ButtonBag,WindowBag,ColorBag)
  76. EndProc ; Demo.MakeRadioButtonBar
  77.  
  78. Proc Demo.MakeToggleButtonBar()
  79.    Private
  80.       PropertyBag,
  81.       ButtonBag,
  82.       WindowBag,
  83.       ColorBag
  84.    Dynarray PropertyBag[]
  85.    Dynarray ButtonBag[]
  86.    Dynarray WindowBag[]
  87.    Dynarray ColorBag[]
  88.  
  89.    PropertyBag["ObjectTag"] = "ButtonBar2"
  90.    PropertyBag["Action"] = "Toggle"
  91.    PropertyBag["ButtonStyle"] = "Flat"
  92.    PropertyBag["ButtonColor"] = 64 + 15 ; 32 + 14
  93.    PropertyBag["SelectedColor"] = 32 + 15
  94.    PropertyBag["CanvasColor"] = 64 + 0
  95.    PropertyBag["ShadowColor"] = 64 + 0
  96.    PropertyBag["WrapCount"] = 4
  97.    PropertyBag["UserScript"] = "!Button2"
  98.  
  99.    ButtonBag["One"]     = Chr(1)  + "Demo.MakeABeep"
  100.    ButtonBag["Two"]     = Chr(2)  + "Demo.MakeABeep"
  101.    ButtonBag["Three"]   = Chr(3)  + "Demo.MakeABeep"
  102.    ButtonBag["Four"]    = Chr(4)  + "Demo.MakeABeep"
  103.    ButtonBag["Five"]    = Chr(5)  + "Demo.MakeABeep"
  104.    ButtonBag["Six"]     = Chr(6)  + "Demo.MakeABeep"
  105.    ButtonBag["Seven"]   = Chr(7)  + "Demo.MakeABeep"
  106.    ButtonBag["Eight"]   = Chr(8)  + "Demo.MakeABeep"
  107.    ButtonBag["Close"]   = Chr(9)  + "Demo.CloseButtonBar"
  108.    ButtonBag["DoProcess"] = Chr(10) + "Demo.DoProcess,DoProcess"
  109.    ButtonBag["Quit"]    = Chr(11) + "Demo.Quit"
  110.  
  111.    WindowBag["Title"] = "Toggle Button Bar"
  112.    WindowBag["OriginRow"] = 12
  113.    WindowBag["OriginCol"] = 0
  114.    WindowBag["CanResize"] = True
  115.    WindowBag["HasFrame"] = True
  116.  
  117.    ButtonMan.MakeButtonBar(PropertyBag,ButtonBag,WindowBag,ColorBag)
  118. EndProc ; Demo.MakeToggleButtonBar()
  119.  
  120. Proc Demo.DoProcess()
  121.    Private
  122.       CurrentWindow
  123.    Demo.MakeProcessButtonBar()
  124.    CurrentWindow = GetWindow()
  125.    Window Select EventMan.ObjectTagWindow["ProcessBar"]
  126.    Message "Please wait while your request is being processed..."
  127.    Sleep 1000
  128.    ButtonMan.SelectButton("ProcessBar","Two")
  129.    ButtonMan.EnableButton("ProcessBar","One",False)
  130.    Sleep 1000
  131.    ButtonMan.SelectButton("ProcessBar","Three")
  132.    ButtonMan.EnableButton("ProcessBar","Two",False)
  133.    Sleep 1000
  134.    ButtonMan.SelectButton("ProcessBar","Four")
  135.    ButtonMan.EnableButton("ProcessBar","Three",False)
  136.    Sleep 1000
  137.    ButtonMan.SelectButton("ProcessBar","Five")
  138.    ButtonMan.EnableButton("ProcessBar","Four",False)
  139.    Sleep 1000
  140.    ButtonMan.SelectButton("ProcessBar","Six")
  141.    ButtonMan.EnableButton("ProcessBar","Five",False)
  142.    Sleep 1000
  143.    ButtonMan.SelectButton("ProcessBar","Seven")
  144.    ButtonMan.EnableButton("ProcessBar","Six",False)
  145.    Sleep 1000
  146.    ButtonMan.SelectButton("ProcessBar","Eight")
  147.    ButtonMan.EnableButton("ProcessBar","Seven",False)
  148.    Sleep 1000
  149.    ButtonMan.SelectButton("ProcessBar","Nine")
  150.    ButtonMan.EnableButton("ProcessBar","Eight",False)
  151.    Sleep 1000
  152.    ButtonMan.SelectButton("ProcessBar","Ten")
  153.    ButtonMan.EnableButton("ProcessBar","Nine",False)
  154.    Sleep 1000
  155.    ButtonMan.DestroyButtonBar("ProcessBar")
  156.    Message "Done."
  157.    Return 1
  158. EndProc ; DoProcess
  159.  
  160. Proc Demo.MakeProcessButtonBar()
  161.    Private
  162.       PropertyBag,
  163.       ButtonBag,
  164.       WindowBag,
  165.       ColorBag
  166.    Dynarray PropertyBag[]
  167.    Dynarray ButtonBag[]
  168.    Dynarray WindowBag[]
  169.    Dynarray ColorBag[]
  170.  
  171.    PropertyBag["ObjectTag"] = "ProcessBar"
  172.    PropertyBag["Action"] = "Radio"
  173.    PropertyBag["ButtonStyle"] = "Border"
  174.    PropertyBag["Orientation"] = "Vertical"
  175.    PropertyBag["WrapCount"] = 5
  176.  
  177.    ButtonBag["One"]     = Chr(1)  + ",This is the first step."
  178.    ButtonBag["Two"]     = Chr(2)  + ",We now move to the second."
  179.    ButtonBag["Three"]   = Chr(3)  + ",The third step after 2."
  180.    ButtonBag["Four"]    = Chr(4)  + ",Now for the fourth."
  181.    ButtonBag["Five"]    = Chr(5)  + ",The end of the first set."
  182.    ButtonBag["Six"]     = Chr(6)  + ",Now we start the second set."
  183.    ButtonBag["Seven"]   = Chr(7)  + ",The other buttons are dimmed."
  184.    ButtonBag["Eight"]   = Chr(8)  + ",Almost done."
  185.    ButtonBag["Nine"]    = Chr(9)  + ",Only one more to go!"
  186.    ButtonBag["Ten"]     = Chr(10) + ",Now we are finished."
  187.  
  188.    WindowBag["Title"] = "Progress report"
  189.    WindowBag["OriginRow"] = 5
  190.    WindowBag["OriginCol"] = 3
  191.    WindowBag["CanResize"] = False
  192.    WindowBag["HasFrame"] = True
  193.  
  194.    ButtonMan.MakeButtonBar(PropertyBag,ButtonBag,WindowBag,ColorBag)
  195. EndProc ; Demo.MakeProcessButtonBar
  196.  
  197. Proc Demo.MakeCheckbox()
  198.    Private
  199.       PropertyBag,
  200.       ButtonBag,
  201.       WindowBag,
  202.       ColorBag
  203.    Dynarray PropertyBag[]
  204.    Dynarray ButtonBag[]
  205.    Dynarray WindowBag[]
  206.    Dynarray ColorBag[]
  207.  
  208.    PropertyBag["ObjectTag"] = "ButtonBar3"
  209.    PropertyBag["Action"] = "Checkbox"
  210.    PropertyBag["Orientation"] = "Vertical"
  211.    PropertyBag["ButtonStyle"] = "Shadow"
  212.    PropertyBag["ButtonColor"] = 64 + 15
  213.    PropertyBag["SelectedColor"] = 32 + 15
  214.    PropertyBag["SelectedHotKeyColor"] = 32 + 12
  215.    PropertyBag["CanvasColor"] = 80 + 14
  216.    PropertyBag["ShadowColor"] = 80 + 0
  217.    PropertyBag["HighLightColor"] = 80 + 13
  218.    PropertyBag["HotKeyColor"] = 80 + 12
  219.    PropertyBag["DisableColor"] = 64 + 7
  220.    PropertyBag["UserScript"] = "!Button3"
  221.  
  222.    ButtonBag["One"]   = Chr(1)  + "Demo.MakeABeep,The ~F~irst"
  223.    ButtonBag["Two"]   = Chr(2)  + "Demo.MakeABeep,The ~S~econd"
  224.    ButtonBag["Three"] = Chr(3)  + "Demo.MakeABeep,The ~T~hird"
  225.    ButtonBag["Four"]  = Chr(4)  + "Demo.MakeABeep,The F~o~urth"
  226.    ButtonBag["Five"]  = Chr(5)  + "Demo.MakeABeep,The F~i~fth"
  227.    ButtonBag["Six"]   = Chr(6)  + "Demo.MakeABeep,The Si~x~th"
  228.    ButtonBag["Seven"] = Chr(7)  + "Demo.MakeABeep,The S~e~venth"
  229.    ButtonBag["Eight"] = Chr(8)  + "Demo.MakeABeep,The Ei~g~hth"
  230.    ButtonBag["Nine"]  = Chr(9)  + "Demo.CloseButtonBar,~C~lose"
  231.    ButtonBag["Ten"]   = Chr(10) + "Demo.Quit,~Q~uit"
  232.  
  233.    WindowBag["Title"] = "Checkbox"
  234.    WindowBag["OriginRow"] = 5
  235.    WindowBag["OriginCol"] = 59
  236.    WindowBag["HasFrame"] = True
  237.  
  238.    ButtonMan.MakeButtonBar(PropertyBag,ButtonBag,WindowBag,ColorBag)
  239. EndProc ; Demo.MakeCheckBox
  240.  
  241. SetCanvas Default
  242. Echo Normal
  243. Cursor off
  244.  
  245. KeyBar.Constructor()
  246. Demo.MakeRadioButtonBar()
  247. Demo.MakeToggleButtonBar()
  248. Demo.MakeCheckBox()
  249. ButtonMan.EnableButton("ButtonBar3","Two",False)
  250. ButtonMan.EnableButton("ButtonBar3","Five",False)
  251. KeyBar.MakeButtonBar()
  252.  
  253. Message "Right click on any ButtonBar for an inspector"
  254.  
  255. EventMan.DoGetEvent()
  256.  
  257. ButtonMan.DestroyButtonBar("ButtonBar1")
  258. ButtonMan.DestroyButtonBar("ButtonBar2")
  259. ButtonMan.DestroyButtonBar("ButtonBar3")
  260. KeyBar.DestroyButtonBar()
  261.  
  262. KeyBar.Destructor()
  263. ButtonMan.Destructor()
  264. EventMan.Destructor()