home *** CD-ROM | disk | FTP | other *** search
/ PC World 2000 August / PCWorld_2000-08_cd.bin / Software / TemaCD / xbasic / xbpro.exe / xb / ademo.x < prev    next >
Text File  |  1999-11-13  |  75KB  |  2,008 lines

  1. '
  2. '
  3. ' ####################
  4. ' #####  PROLOG  #####
  5. ' ####################
  6. '
  7. PROGRAM    "ademo"
  8. VERSION    "0.0016"
  9. '
  10. IMPORT    "xst"        ' Standard
  11. IMPORT    "xma"        ' Mathematics
  12. IMPORT    "xgr"        ' GraphicsDesigner
  13. IMPORT    "xui"        ' GuiDesigner
  14. '
  15. DECLARE  FUNCTION  Entry         ()
  16. INTERNAL FUNCTION  InitGui       ()
  17. INTERNAL FUNCTION  InitProgram   ()
  18. INTERNAL FUNCTION  CreateWindows ()
  19. INTERNAL FUNCTION  InitWindows   ()
  20. INTERNAL FUNCTION  Circle        (grid, message, v0, v1, v2, v3, r0, ANY)
  21. INTERNAL FUNCTION  CircleCode    (grid, message, v0, v1, v2, v3, r0, ANY)
  22. INTERNAL FUNCTION  Math          (grid, message, v0, v1, v2, v3, r0, ANY)
  23. INTERNAL FUNCTION  MathCode      (grid, message, v0, v1, v2, v3, kid, ANY)
  24. INTERNAL FUNCTION  Control       (grid, message, v0, v1, v2, v3, r0, ANY)
  25. INTERNAL FUNCTION  ControlCode   (grid, message, v0, v1, v2, v3, kid, ANY)
  26. '
  27. '
  28. ' ######################
  29. ' #####  Entry ()  #####
  30. ' ######################
  31. '
  32. FUNCTION  Entry ()
  33.     SHARED  terminateProgram
  34.     SHARED    paused
  35.     SHARED  Circle
  36.     SHARED  Math
  37. '
  38.     PRINT "begin execution of ademo.x"
  39. '
  40.     InitGui ()                                        ' initialize messages
  41.     InitProgram ()                                ' initialize this program
  42.     CreateWindows ()                            ' create main window and others
  43.     InitWindows ()                                ' initialize windows
  44. '
  45. ' This message loop is modified to draw the circle pattern continuously
  46. ' when no paused, but still process messages whenever they occur.
  47. '
  48.     DO                                                        ' the message loop
  49.         count = 1                                        ' wait for 1+ messages, then process 1
  50.         IFZ paused THEN                            ' if circle drawing not paused
  51.             CircleCode (0, #Redraw, 0, 0, 0, 0, 0, 0)        ' draw a few circles
  52.             count = 0                                    ' avoid hang up in XgrProcessMessages()
  53.         END IF
  54.         XgrProcessMessages (count)    ' process zero or one message
  55.     LOOP UNTIL terminateProgram        ' and repeats until program is terminated
  56. END FUNCTION
  57. '
  58. '
  59. ' ########################
  60. ' #####  InitGui ()  #####
  61. ' ########################
  62. '
  63. ' InitGui() initializes cursor, icon, message, and display variables.
  64. ' Programs can reference these variables, but must never change them.
  65. '
  66. FUNCTION  InitGui ()
  67. '
  68. ' ***************************************
  69. ' *****  Register Standard Cursors  *****
  70. ' ***************************************
  71. '
  72.     XgrRegisterCursor (@"default",      @#cursorDefault)
  73.     XgrRegisterCursor (@"arrow",        @#cursorArrow)
  74.     XgrRegisterCursor (@"n",            @#cursorN)
  75.     XgrRegisterCursor (@"s",            @#cursorS)
  76.     XgrRegisterCursor (@"e",            @#cursorE)
  77.     XgrRegisterCursor (@"w",            @#cursorW)
  78.     XgrRegisterCursor (@"ns",           @#cursorArrowsNS)
  79.     XgrRegisterCursor (@"ns",           @#cursorArrowsSN)
  80.     XgrRegisterCursor (@"ew",           @#cursorArrowsEW)
  81.     XgrRegisterCursor (@"ew",           @#cursorArrowsWE)
  82.     XgrRegisterCursor (@"nwse",         @#cursorArrowsNWSE)
  83.     XgrRegisterCursor (@"nesw",         @#cursorArrowsNESW)
  84.     XgrRegisterCursor (@"all",          @#cursorArrowsAll)
  85.     XgrRegisterCursor (@"plus",         @#cursorPlus)
  86.     XgrRegisterCursor (@"wait",         @#cursorWait)
  87.     XgrRegisterCursor (@"insert",       @#cursorInsert)
  88.     XgrRegisterCursor (@"crosshair",    @#cursorCrosshair)
  89.     XgrRegisterCursor (@"hourglass",    @#cursorHourglass)
  90. '
  91.     #defaultCursor = #cursorDefault
  92. '
  93. '
  94. ' ********************************************
  95. ' *****  Register Standard Window Icons  *****
  96. ' ********************************************
  97. '
  98.     XgrRegisterIcon (@"hand",                    @#iconHand)
  99.     XgrRegisterIcon (@"asterisk",            @#iconAsterisk)
  100.     XgrRegisterIcon (@"question",            @#iconQuestion)
  101.     XgrRegisterIcon (@"exclamation",    @#iconExclamation)
  102.     XgrRegisterIcon (@"application",    @#iconApplication)
  103. '
  104.     XgrRegisterIcon (@"hand",                    @#iconStop)                        ' alias
  105.     XgrRegisterIcon (@"asterisk",            @#iconInformation)        ' alias
  106.     XgrRegisterIcon (@"application",  @#iconBlank)                    ' alias
  107. '
  108.     XgrRegisterIcon (@"window",                @#iconWindow)                    ' custom
  109. '
  110. '
  111. ' ******************************
  112. ' *****  Register Messages *****  Create message numbers for message names
  113. ' ******************************
  114. '
  115.     XgrRegisterMessage (@"Blowback",                                        @#Blowback)
  116.     XgrRegisterMessage (@"Callback",                                        @#Callback)
  117.     XgrRegisterMessage (@"Cancel",                                            @#Cancel)
  118.     XgrRegisterMessage (@"Change",                                            @#Change)
  119.     XgrRegisterMessage (@"CloseWindow",                                    @#CloseWindow)
  120.     XgrRegisterMessage (@"ContextChange",                                @#ContextChange)
  121.     XgrRegisterMessage (@"Create",                                            @#Create)
  122.     XgrRegisterMessage (@"CreateValueArray",                        @#CreateValueArray)
  123.     XgrRegisterMessage (@"CreateWindow",                                @#CreateWindow)
  124.     XgrRegisterMessage (@"CursorH",                                            @#CursorH)
  125.     XgrRegisterMessage (@"CursorV",                                            @#CursorV)
  126.     XgrRegisterMessage (@"Deselected",                                    @#Deselected)
  127.     XgrRegisterMessage (@"Destroy",                                            @#Destroy)
  128.     XgrRegisterMessage (@"Destroyed",                                        @#Destroyed)
  129.     XgrRegisterMessage (@"DestroyWindow",                                @#DestroyWindow)
  130.     XgrRegisterMessage (@"Disable",                                            @#Disable)
  131.     XgrRegisterMessage (@"Disabled",                                        @#Disabled)
  132.     XgrRegisterMessage (@"Displayed",                                        @#Displayed)
  133.     XgrRegisterMessage (@"DisplayWindow",                                @#DisplayWindow)
  134.     XgrRegisterMessage (@"Enable",                                            @#Enable)
  135.     XgrRegisterMessage (@"Enabled",                                            @#Enabled)
  136.     XgrRegisterMessage (@"Enter",                                                @#Enter)
  137.     XgrRegisterMessage (@"ExitMessageLoop",                            @#ExitMessageLoop)
  138.     XgrRegisterMessage (@"Find",                                                @#Find)
  139.     XgrRegisterMessage (@"FindForward",                                    @#FindForward)
  140.     XgrRegisterMessage (@"FindReverse",                                    @#FindReverse)
  141.     XgrRegisterMessage (@"Forward",                                            @#Forward)
  142.     XgrRegisterMessage (@"GetAlign",                                        @#GetAlign)
  143.     XgrRegisterMessage (@"GetBorder",                                        @#GetBorder)
  144.     XgrRegisterMessage (@"GetBorderOffset",                            @#GetBorderOffset)
  145.     XgrRegisterMessage (@"GetCallback",                                    @#GetCallback)
  146.     XgrRegisterMessage (@"GetCallbackArgs",                            @#GetCallbackArgs)
  147.     XgrRegisterMessage (@"GetCan",                                            @#GetCan)
  148.     XgrRegisterMessage (@"GetCharacterMapArray",                @#GetCharacterMapArray)
  149.     XgrRegisterMessage (@"GetClipGrid",                                    @#GetClipGrid)
  150.     XgrRegisterMessage (@"GetColor",                                        @#GetColor)
  151.     XgrRegisterMessage (@"GetColorExtra",                                @#GetColorExtra)
  152.     XgrRegisterMessage (@"GetCursor",                                        @#GetCursor)
  153.     XgrRegisterMessage (@"GetCursorXY",                                    @#GetCursorXY)
  154.     XgrRegisterMessage (@"GetDisplay",                                    @#GetDisplay)
  155.     XgrRegisterMessage (@"GetEnclosedGrids",                        @#GetEnclosedGrids)
  156.     XgrRegisterMessage (@"GetEnclosingGrid",                        @#GetEnclosingGrid)
  157.     XgrRegisterMessage (@"GetFocusColor",                                @#GetFocusColor)
  158.     XgrRegisterMessage (@"GetFocusColorExtra",                    @#GetFocusColorExtra)
  159.     XgrRegisterMessage (@"GetFont",                                            @#GetFont)
  160.     XgrRegisterMessage (@"GetFontNumber",                                @#GetFontNumber)
  161.     XgrRegisterMessage (@"GetGridFunction",                            @#GetGridFunction)
  162.     XgrRegisterMessage (@"GetGridFunctionName",                    @#GetGridFunctionName)
  163.     XgrRegisterMessage (@"GetGridName",                                    @#GetGridName)
  164.     XgrRegisterMessage (@"GetGridNumber",                                @#GetGridNumber)
  165.     XgrRegisterMessage (@"GetGridType",                                    @#GetGridType)
  166.     XgrRegisterMessage (@"GetGridTypeName",                            @#GetGridTypeName)
  167.     XgrRegisterMessage (@"GetGroup",                                        @#GetGroup)
  168.     XgrRegisterMessage (@"GetHelp",                                            @#GetHelp)
  169.     XgrRegisterMessage (@"GetHelpFile",                                    @#GetHelpFile)
  170.     XgrRegisterMessage (@"GetHelpString",                                @#GetHelpString)
  171.     XgrRegisterMessage (@"GetHelpStrings",                            @#GetHelpStrings)
  172.     XgrRegisterMessage (@"GetHintString",                                @#GetHintString)
  173.     XgrRegisterMessage (@"GetImage",                                        @#GetImage)
  174.     XgrRegisterMessage (@"GetImageCoords",                            @#GetImageCoords)
  175.     XgrRegisterMessage (@"GetIndent",                                        @#GetIndent)
  176.     XgrRegisterMessage (@"GetInfo",                                            @#GetInfo)
  177.     XgrRegisterMessage (@"GetJustify",                                    @#GetJustify)
  178.     XgrRegisterMessage (@"GetKeyboardFocus",                        @#GetKeyboardFocus)
  179.     XgrRegisterMessage (@"GetKeyboardFocusGrid",                @#GetKeyboardFocusGrid)
  180.     XgrRegisterMessage (@"GetKidNumber",                                @#GetKidNumber)
  181.     XgrRegisterMessage (@"GetKids",                                            @#GetKids)
  182.     XgrRegisterMessage (@"GetKidArray",                                    @#GetKidArray)
  183.     XgrRegisterMessage (@"GetKind",                                            @#GetKind)
  184.     XgrRegisterMessage (@"GetMaxMinSize",                                @#GetMaxMinSize)
  185.     XgrRegisterMessage (@"GetMessageFunc",                            @#GetMessageFunc)
  186.     XgrRegisterMessage (@"GetMessageFuncArray",                    @#GetMessageFuncArray)
  187.     XgrRegisterMessage (@"GetMessageSub",                                @#GetMessageSub)
  188.     XgrRegisterMessage (@"GetMessageSubArray",                    @#GetMessageSubArray)
  189.     XgrRegisterMessage (@"GetModalInfo",                                @#GetModalInfo)
  190.     XgrRegisterMessage (@"GetModalWindow",                            @#GetModalWindow)
  191.     XgrRegisterMessage (@"GetParent",                                        @#GetParent)
  192.     XgrRegisterMessage (@"GetPosition",                                    @#GetPosition)
  193.     XgrRegisterMessage (@"GetProtoInfo",                                @#GetProtoInfo)
  194.     XgrRegisterMessage (@"GetRedrawFlags",                            @#GetRedrawFlags)
  195.     XgrRegisterMessage (@"GetSize",                                            @#GetSize)
  196.     XgrRegisterMessage (@"GetSmallestSize",                            @#GetSmallestSize)
  197.     XgrRegisterMessage (@"GetState",                                        @#GetState)
  198.     XgrRegisterMessage (@"GetStyle",                                        @#GetStyle)
  199.     XgrRegisterMessage (@"GetTabArray",                                    @#GetTabArray)
  200.     XgrRegisterMessage (@"GetTabWidth",                                    @#GetTabWidth)
  201.     XgrRegisterMessage (@"GetTextArray",                                @#GetTextArray)
  202.     XgrRegisterMessage (@"GetTextArrayBounds",                    @#GetTextArrayBounds)
  203.     XgrRegisterMessage (@"GetTextArrayLine",                        @#GetTextArrayLine)
  204.     XgrRegisterMessage (@"GetTextArrayLines",                        @#GetTextArrayLines)
  205.     XgrRegisterMessage (@"GetTextCursor",                                @#GetTextCursor)
  206.     XgrRegisterMessage (@"GetTextFilename",                            @#GetTextFilename)
  207.     XgrRegisterMessage (@"GetTextPosition",                            @#GetTextPosition)
  208.     XgrRegisterMessage (@"GetTextSelection",                        @#GetTextSelection)
  209.     XgrRegisterMessage (@"GetTextString",                                @#GetTextString)
  210.     XgrRegisterMessage (@"GetTextStrings",                            @#GetTextStrings)
  211.     XgrRegisterMessage (@"GetTexture",                                    @#GetTexture)
  212.     XgrRegisterMessage (@"GetTimer",                                        @#GetTimer)
  213.     XgrRegisterMessage (@"GetValue",                                        @#GetValue)
  214.     XgrRegisterMessage (@"GetValues",                                        @#GetValues)
  215.     XgrRegisterMessage (@"GetValueArray",                                @#GetValueArray)
  216.     XgrRegisterMessage (@"GetWindow",                                        @#GetWindow)
  217.     XgrRegisterMessage (@"GetWindowFunction",                        @#GetWindowFunction)
  218.     XgrRegisterMessage (@"GetWindowGrid",                                @#GetWindowGrid)
  219.     XgrRegisterMessage (@"GetWindowIcon",                                @#GetWindowIcon)
  220.     XgrRegisterMessage (@"GetWindowSize",                                @#GetWindowSize)
  221.     XgrRegisterMessage (@"GetWindowTitle",                            @#GetWindowTitle)
  222.     XgrRegisterMessage (@"GotKeyboardFocus",                        @#GotKeyboardFocus)
  223.     XgrRegisterMessage (@"GrabArray",                                        @#GrabArray)
  224.     XgrRegisterMessage (@"GrabTextArray",                                @#GrabTextArray)
  225.     XgrRegisterMessage (@"GrabTextString",                            @#GrabTextString)
  226.     XgrRegisterMessage (@"GrabValueArray",                            @#GrabValueArray)
  227.     XgrRegisterMessage (@"Help",                                                @#Help)
  228.     XgrRegisterMessage (@"Hidden",                                            @#Hidden)
  229.     XgrRegisterMessage (@"HideTextCursor",                            @#HideTextCursor)
  230.     XgrRegisterMessage (@"HideWindow",                                    @#HideWindow)
  231.     XgrRegisterMessage (@"Initialize",                                    @#Initialize)
  232.     XgrRegisterMessage (@"Initialized",                                    @#Initialized)
  233.     XgrRegisterMessage (@"Inline",                                            @#Inline)
  234.     XgrRegisterMessage (@"InquireText",                                    @#InquireText)
  235.     XgrRegisterMessage (@"KeyboardFocusBackward",                @#KeyboardFocusBackward)
  236.     XgrRegisterMessage (@"KeyboardFocusForward",                @#KeyboardFocusForward)
  237.     XgrRegisterMessage (@"KeyDown",                                            @#KeyDown)
  238.     XgrRegisterMessage (@"KeyUp",                                                @#KeyUp)
  239.     XgrRegisterMessage (@"LostKeyboardFocus",                        @#LostKeyboardFocus)
  240.     XgrRegisterMessage (@"LostTextSelection",                        @#LostTextSelection)
  241.     XgrRegisterMessage (@"Maximized",                                        @#Maximized)
  242.     XgrRegisterMessage (@"MaximizeWindow",                            @#MaximizeWindow)
  243.     XgrRegisterMessage (@"Maximum",                                            @#Maximum)
  244.     XgrRegisterMessage (@"Minimized",                                        @#Minimized)
  245.     XgrRegisterMessage (@"MinimizeWindow",                            @#MinimizeWindow)
  246.     XgrRegisterMessage (@"Minimum",                                            @#Minimum)
  247.     XgrRegisterMessage (@"MonitorContext",                            @#MonitorContext)
  248.     XgrRegisterMessage (@"MonitorHelp",                                    @#MonitorHelp)
  249.     XgrRegisterMessage (@"MonitorKeyboard",                            @#MonitorKeyboard)
  250.     XgrRegisterMessage (@"MonitorMouse",                                @#MonitorMouse)
  251.     XgrRegisterMessage (@"MouseDown",                                        @#MouseDown)
  252.     XgrRegisterMessage (@"MouseDrag",                                        @#MouseDrag)
  253.     XgrRegisterMessage (@"MouseEnter",                                    @#MouseEnter)
  254.     XgrRegisterMessage (@"MouseExit",                                        @#MouseExit)
  255.     XgrRegisterMessage (@"MouseMove",                                        @#MouseMove)
  256.     XgrRegisterMessage (@"MouseUp",                                            @#MouseUp)
  257.     XgrRegisterMessage (@"MuchLess",                                        @#MuchLess)
  258.     XgrRegisterMessage (@"MuchMore",                                        @#MuchMore)
  259.     XgrRegisterMessage (@"OneLess",                                            @#OneLess)
  260.     XgrRegisterMessage (@"OneMore",                                            @#OneMore)
  261.     XgrRegisterMessage (@"PokeArray",                                        @#PokeArray)
  262.     XgrRegisterMessage (@"PokeTextArray",                                @#PokeTextArray)
  263.     XgrRegisterMessage (@"PokeTextString",                            @#PokeTextString)
  264.     XgrRegisterMessage (@"PokeValueArray",                            @#PokeValueArray)
  265.     XgrRegisterMessage (@"Print",                                                @#Print)
  266.     XgrRegisterMessage (@"Redraw",                                            @#Redraw)
  267.     XgrRegisterMessage (@"RedrawGrid",                                    @#RedrawGrid)
  268.     XgrRegisterMessage (@"RedrawLines",                                    @#RedrawLines)
  269.     XgrRegisterMessage (@"RedrawText",                                    @#RedrawText)
  270.     XgrRegisterMessage (@"RedrawWindow",                                @#RedrawWindow)
  271.     XgrRegisterMessage (@"Replace",                                            @#Replace)
  272.     XgrRegisterMessage (@"ReplaceForward",                            @#ReplaceForward)
  273.     XgrRegisterMessage (@"ReplaceReverse",                            @#ReplaceReverse)
  274.     XgrRegisterMessage (@"Reset",                                                @#Reset)
  275.     XgrRegisterMessage (@"Resize",                                            @#Resize)
  276.     XgrRegisterMessage (@"Resized",                                            @#Resized)
  277.     XgrRegisterMessage (@"ResizeNot",                                        @#ResizeNot)
  278.     XgrRegisterMessage (@"ResizeWindow",                                @#ResizeWindow)
  279.     XgrRegisterMessage (@"ResizeWindowToGrid",                    @#ResizeWindowToGrid)
  280.     XgrRegisterMessage (@"Resized",                                            @#Resized)
  281.     XgrRegisterMessage (@"Reverse",                                            @#Reverse)
  282.     XgrRegisterMessage (@"ScrollH",                                            @#ScrollH)
  283.     XgrRegisterMessage (@"ScrollV",                                            @#ScrollV)
  284.     XgrRegisterMessage (@"Select",                                            @#Select)
  285.     XgrRegisterMessage (@"Selected",                                        @#Selected)
  286.     XgrRegisterMessage (@"Selection",                                        @#Selection)
  287.     XgrRegisterMessage (@"SelectWindow",                                @#SelectWindow)
  288.     XgrRegisterMessage (@"SetAlign",                                        @#SetAlign)
  289.     XgrRegisterMessage (@"SetBorder",                                        @#SetBorder)
  290.     XgrRegisterMessage (@"SetBorderOffset",                            @#SetBorderOffset)
  291.     XgrRegisterMessage (@"SetCallback",                                    @#SetCallback)
  292.     XgrRegisterMessage (@"SetCan",                                            @#SetCan)
  293.     XgrRegisterMessage (@"SetCharacterMapArray",                @#SetCharacterMapArray)
  294.     XgrRegisterMessage (@"SetClipGrid",                                    @#SetClipGrid)
  295.     XgrRegisterMessage (@"SetColor",                                        @#SetColor)
  296.     XgrRegisterMessage (@"SetColorAll",                                    @#SetColorAll)
  297.     XgrRegisterMessage (@"SetColorExtra",                                @#SetColorExtra)
  298.     XgrRegisterMessage (@"SetColorExtraAll",                        @#SetColorExtraAll)
  299.     XgrRegisterMessage (@"SetCursor",                                        @#SetCursor)
  300.     XgrRegisterMessage (@"SetCursorXY",                                    @#SetCursorXY)
  301.     XgrRegisterMessage (@"SetDisplay",                                    @#SetDisplay)
  302.     XgrRegisterMessage (@"SetFocusColor",                                @#SetFocusColor)
  303.     XgrRegisterMessage (@"SetFocusColorExtra",                    @#SetFocusColorExtra)
  304.     XgrRegisterMessage (@"SetFont",                                            @#SetFont)
  305.     XgrRegisterMessage (@"SetFontNumber",                                @#SetFontNumber)
  306.     XgrRegisterMessage (@"SetGridFunction",                            @#SetGridFunction)
  307.     XgrRegisterMessage (@"SetGridFunctionName",                    @#SetGridFunctionName)
  308.     XgrRegisterMessage (@"SetGridName",                                    @#SetGridName)
  309.     XgrRegisterMessage (@"SetGridType",                                    @#SetGridType)
  310.     XgrRegisterMessage (@"SetGridTypeName",                            @#SetGridTypeName)
  311.     XgrRegisterMessage (@"SetGroup",                                        @#SetGroup)
  312.     XgrRegisterMessage (@"SetHelp",                                            @#SetHelp)
  313.     XgrRegisterMessage (@"SetHelpFile",                                    @#SetHelpFile)
  314.     XgrRegisterMessage (@"SetHelpString",                                @#SetHelpString)
  315.     XgrRegisterMessage (@"SetHelpStrings",                            @#SetHelpStrings)
  316.     XgrRegisterMessage (@"SetHintString",                                @#SetHintString)
  317.     XgrRegisterMessage (@"SetImage",                                        @#SetImage)
  318.     XgrRegisterMessage (@"SetImageCoords",                            @#SetImageCoords)
  319.     XgrRegisterMessage (@"SetIndent",                                        @#SetIndent)
  320.     XgrRegisterMessage (@"SetInfo",                                            @#SetInfo)
  321.     XgrRegisterMessage (@"SetJustify",                                    @#SetJustify)
  322.     XgrRegisterMessage (@"SetKeyboardFocus",                        @#SetKeyboardFocus)
  323.     XgrRegisterMessage (@"SetKeyboardFocusGrid",                @#SetKeyboardFocusGrid)
  324.     XgrRegisterMessage (@"SetMaxMinSize",                                @#SetMaxMinSize)
  325.     XgrRegisterMessage (@"SetMessageFunc",                            @#SetMessageFunc)
  326.     XgrRegisterMessage (@"SetMessageFuncArray",                    @#SetMessageFuncArray)
  327.     XgrRegisterMessage (@"SetMessageSub",                                @#SetMessageSub)
  328.     XgrRegisterMessage (@"SetMessageSubArray",                    @#SetMessageSubArray)
  329.     XgrRegisterMessage (@"SetModalWindow",                            @#SetModalWindow)
  330.     XgrRegisterMessage (@"SetParent",                                        @#SetParent)
  331.     XgrRegisterMessage (@"SetPosition",                                    @#SetPosition)
  332.     XgrRegisterMessage (@"SetRedrawFlags",                            @#SetRedrawFlags)
  333.     XgrRegisterMessage (@"SetSize",                                            @#SetSize)
  334.     XgrRegisterMessage (@"SetState",                                        @#SetState)
  335.     XgrRegisterMessage (@"SetStyle",                                        @#SetStyle)
  336.     XgrRegisterMessage (@"SetTabArray",                                    @#SetTabArray)
  337.     XgrRegisterMessage (@"SetTabWidth",                                    @#SetTabWidth)
  338.     XgrRegisterMessage (@"SetTextArray",                                @#SetTextArray)
  339.     XgrRegisterMessage (@"SetTextArrayLine",                        @#SetTextArrayLine)
  340.     XgrRegisterMessage (@"SetTextArrayLines",                        @#SetTextArrayLines)
  341.     XgrRegisterMessage (@"SetTextCursor",                                @#SetTextCursor)
  342.     XgrRegisterMessage (@"SetTextFilename",                            @#SetTextFilename)
  343.     XgrRegisterMessage (@"SetTextSelection",                        @#SetTextSelection)
  344.     XgrRegisterMessage (@"SetTextString",                                @#SetTextString)
  345.     XgrRegisterMessage (@"SetTextStrings",                            @#SetTextStrings)
  346.     XgrRegisterMessage (@"SetTexture",                                    @#SetTexture)
  347.     XgrRegisterMessage (@"SetTimer",                                        @#SetTimer)
  348.     XgrRegisterMessage (@"SetValue",                                        @#SetValue)
  349.     XgrRegisterMessage (@"SetValues",                                        @#SetValues)
  350.     XgrRegisterMessage (@"SetValueArray",                                @#SetValueArray)
  351.     XgrRegisterMessage (@"SetWindowFunction",                        @#SetWindowFunction)
  352.     XgrRegisterMessage (@"SetWindowIcon",                                @#SetWindowIcon)
  353.     XgrRegisterMessage (@"SetWindowTitle",                            @#SetWindowTitle)
  354.     XgrRegisterMessage (@"ShowTextCursor",                            @#ShowTextCursor)
  355.     XgrRegisterMessage (@"ShowWindow",                                    @#ShowWindow)
  356.     XgrRegisterMessage (@"SomeLess",                                        @#SomeLess)
  357.     XgrRegisterMessage (@"SomeMore",                                        @#SomeMore)
  358.     XgrRegisterMessage (@"StartTimer",                                    @#StartTimer)
  359.     XgrRegisterMessage (@"SystemMessage",                                @#SystemMessage)
  360.     XgrRegisterMessage (@"TextDelete",                                    @#TextDelete)
  361.     XgrRegisterMessage (@"TextEvent",                                        @#TextEvent)
  362.     XgrRegisterMessage (@"TextInsert",                                    @#TextInsert)
  363.     XgrRegisterMessage (@"TextModified",                                @#TextModified)
  364.     XgrRegisterMessage (@"TextReplace",                                    @#TextReplace)
  365.     XgrRegisterMessage (@"TimeOut",                                            @#TimeOut)
  366.     XgrRegisterMessage (@"Update",                                            @#Update)
  367.     XgrRegisterMessage (@"WindowClose",                                    @#WindowClose)
  368.     XgrRegisterMessage (@"WindowCreate",                                @#WindowCreate)
  369.     XgrRegisterMessage (@"WindowDeselected",                        @#WindowDeselected)
  370.     XgrRegisterMessage (@"WindowDestroy",                                @#WindowDestroy)
  371.     XgrRegisterMessage (@"WindowDestroyed",                            @#WindowDestroyed)
  372.     XgrRegisterMessage (@"WindowDisplay",                                @#WindowDisplay)
  373.     XgrRegisterMessage (@"WindowDisplayed",                            @#WindowDisplayed)
  374.     XgrRegisterMessage (@"WindowGetDisplay",                        @#WindowGetDisplay)
  375.     XgrRegisterMessage (@"WindowGetFunction",                        @#WindowGetFunction)
  376.     XgrRegisterMessage (@"WindowGetIcon",                                @#WindowGetIcon)
  377.     XgrRegisterMessage (@"WindowGetKeyboardFocusGrid",    @#WindowGetKeyboardFocusGrid)
  378.     XgrRegisterMessage (@"WindowGetSelectedWindow",            @#WindowGetSelectedWindow)
  379.     XgrRegisterMessage (@"WindowGetSize",                                @#WindowGetSize)
  380.     XgrRegisterMessage (@"WindowGetTitle",                            @#WindowGetTitle)
  381.     XgrRegisterMessage (@"WindowHelp",                                    @#WindowHelp)
  382.     XgrRegisterMessage (@"WindowHide",                                    @#WindowHide)
  383.     XgrRegisterMessage (@"WindowHidden",                                @#WindowHidden)
  384.     XgrRegisterMessage (@"WindowKeyDown",                                @#WindowKeyDown)
  385.     XgrRegisterMessage (@"WindowKeyUp",                                    @#WindowKeyUp)
  386.     XgrRegisterMessage (@"WindowMaximize",                            @#WindowMaximize)
  387.     XgrRegisterMessage (@"WindowMaximized",                            @#WindowMaximized)
  388.     XgrRegisterMessage (@"WindowMinimize",                            @#WindowMinimize)
  389.     XgrRegisterMessage (@"WindowMinimized",                            @#WindowMinimized)
  390.     XgrRegisterMessage (@"WindowMonitorContext",                @#WindowMonitorContext)
  391.     XgrRegisterMessage (@"WindowMonitorHelp",                        @#WindowMonitorHelp)
  392.     XgrRegisterMessage (@"WindowMonitorKeyboard",                @#WindowMonitorKeyboard)
  393.     XgrRegisterMessage (@"WindowMonitorMouse",                    @#WindowMonitorMouse)
  394.     XgrRegisterMessage (@"WindowMouseDown",                            @#WindowMouseDown)
  395.     XgrRegisterMessage (@"WindowMouseDrag",                            @#WindowMouseDrag)
  396.     XgrRegisterMessage (@"WindowMouseEnter",                        @#WindowMouseEnter)
  397.     XgrRegisterMessage (@"WindowMouseExit",                            @#WindowMouseExit)
  398.     XgrRegisterMessage (@"WindowMouseMove",                            @#WindowMouseMove)
  399.     XgrRegisterMessage (@"WindowMouseUp",                                @#WindowMouseUp)
  400.     XgrRegisterMessage (@"WindowRedraw",                                @#WindowRedraw)
  401.     XgrRegisterMessage (@"WindowRegister",                            @#WindowRegister)
  402.     XgrRegisterMessage (@"WindowResize",                                @#WindowResize)
  403.     XgrRegisterMessage (@"WindowResized",                                @#WindowResized)
  404.     XgrRegisterMessage (@"WindowResizeToGrid",                    @#WindowResizeToGrid)
  405.     XgrRegisterMessage (@"WindowSelect",                                @#WindowSelect)
  406.     XgrRegisterMessage (@"WindowSelected",                            @#WindowSelected)
  407.     XgrRegisterMessage (@"WindowSetFunction",                        @#WindowSetFunction)
  408.     XgrRegisterMessage (@"WindowSetIcon",                                @#WindowSetIcon)
  409.     XgrRegisterMessage (@"WindowSetKeyboardFocusGrid",    @#WindowSetKeyboardFocusGrid)
  410.     XgrRegisterMessage (@"WindowSetTitle",                            @#WindowSetTitle)
  411.     XgrRegisterMessage (@"WindowShow",                                    @#WindowShow)
  412.     XgrRegisterMessage (@"WindowSystemMessage",                    @#WindowSystemMessage)
  413.     XgrRegisterMessage (@"LastMessage",                                    @#LastMessage)
  414. '
  415.     XgrGetDisplaySize ("", @#displayWidth, @#displayHeight, @#windowBorderWidth, @#windowTitleHeight)
  416. END FUNCTION
  417. '
  418. '
  419. ' ############################
  420. ' #####  InitProgram ()  #####
  421. ' ############################
  422. '
  423. FUNCTION  InitProgram ()
  424. '        Initialize everything your program needs to initialize
  425. END FUNCTION
  426. '
  427. '
  428. ' ##############################
  429. ' #####  CreateWindows ()  #####
  430. ' ##############################
  431. '
  432. FUNCTION  CreateWindows ()
  433.     SHARED  Control
  434.     SHARED  Circle
  435.     SHARED    Math
  436. '
  437.     wt = $$WindowTypeResizeFrame OR $$WindowTypeSystemMenu OR $$WindowTypeTitleBar OR $$WindowTypeMinimizeBox OR $$WindowTypeMaximizeBox
  438.   Control        (@Control, #CreateWindow, 0, 0, 0, 0, wt, 0)
  439.   XuiSendMessage ( Control, #SetCallback, Control, &ControlCode(), -1, -1, -1, 0)
  440.   XuiSendMessage ( Control, #DisplayWindow, 0, 0, 0, 0, 0, 0)
  441.     PRINT "display control window"
  442. '
  443.     wt = $$WindowTypeResizeFrame OR $$WindowTypeSystemMenu OR $$WindowTypeTitleBar OR $$WindowTypeMinimizeBox OR $$WindowTypeMaximizeBox OR $$WindowTypeCloseHide
  444.     Circle         (@Circle, #CreateWindow, 0, 0, 0, 0, wt, 0)
  445.     XuiSendMessage ( Circle, #SetCallback, Circle, &CircleCode(), -1, -1, -1, -1)
  446.     XuiSendMessage ( Circle, #DisplayWindow, 0, 0, 0, 0, 0, 0)
  447.     PRINT "display circle window"
  448. '
  449.     wt = $$WindowTypeResizeFrame OR $$WindowTypeSystemMenu OR $$WindowTypeTitleBar OR $$WindowTypeMinimizeBox OR $$WindowTypeMaximizeBox OR $$WindowTypeCloseMinimize
  450.     Math           (@Math, #CreateWindow, 0, 0, 0, 0, wt, 0)
  451.     XuiSendMessage ( Math, #SetCallback, Math, &MathCode(), -1, -1, -1, -1)
  452.     XuiSendMessage ( Math, #DisplayWindow, 0, 0, 0, 0, 0, 0)
  453.     PRINT "display math window"
  454. END FUNCTION
  455. '
  456. '
  457. ' ############################
  458. ' #####  InitWindows ()  #####
  459. ' ############################
  460. '
  461. FUNCTION  InitWindows ()
  462.     SHARED  Math
  463. '
  464.     XstGetConsoleGrid (@console)
  465.     XstGetApplicationEnvironment (@standalone, @reserved)
  466.     IF standalone THEN XuiSendMessage (console, #HideWindow, 0, 0, 0, 0, 0, 0)
  467. '
  468.     XuiSendMessage (Math, #MouseDown, 0, 0, 0, 0, 23, 0)
  469. END FUNCTION
  470. '
  471. '
  472. ' #######################
  473. ' #####  Circle ()  #####
  474. ' #######################
  475. '
  476. FUNCTION  Circle (grid, message, v0, v1, v2, v3, r0, (r1, r1$, r1[], r1$[]))
  477.   STATIC    designX,  designY,  designWidth,  designHeight
  478.   STATIC    SUBADDR  sub[]
  479.     STATIC    upperMessage
  480.   STATIC    Circle
  481. '
  482.   $Circle       =   0  ' kid   0 grid type = Circle
  483.   $DrawingArea  =   1  ' kid   1 grid type = XuiArea
  484.   $ClearButton  =   2  ' kid   2 grid type = XuiPushButton
  485.   $PauseButton  =   3  ' kid   3 grid type = XuiPushButton
  486.   $QuitButton   =   4  ' kid   4 grid type = XuiPushButton
  487.   $UpperKid     =   4  ' kid maximum
  488. '
  489.   IFZ sub[] THEN GOSUB Initialize
  490. ' XuiReportMessage (grid, message, v0, v1, v2, v3, r0, r1)
  491.   IF XuiProcessMessage (grid, message, @v0, @v1, @v2, @v3, @r0, @r1, Circle) THEN RETURN
  492.   IF (message <= upperMessage) THEN GOSUB @sub[message]
  493.   RETURN
  494. '
  495. '
  496. ' *****  Callback  *****  message = Callback : r1 = original message
  497. '
  498. SUB Callback
  499.   message = r1
  500.   IF (message <= upperMessage) THEN GOSUB @sub[message]
  501. END SUB
  502. '
  503. '
  504. ' *****  Create  *****  v0123 = xywh : r0 = window : r1 = parent
  505. '
  506. SUB Create
  507.   IF (v0 <= 0) THEN v0 = 0
  508.   IF (v1 <= 0) THEN v1 = 0
  509.   IF (v2 <= 0) THEN v2 = designWidth
  510.   IF (v3 <= 0) THEN v3 = designHeight
  511.   XuiCreateGrid (@grid, Circle, @v0, @v1, @v2, @v3, r0, r1, &Circle())
  512.   XuiSendMessage ( grid, #SetGridName, 0, 0, 0, 0, 0, @"Circle")
  513.   XuiArea        (@g, #Create, 4, 4, 444, 444, r0, grid)
  514.   XuiSendMessage ( g, #SetCallback, grid, &Circle(), -1, -1, $DrawingArea, grid)
  515.   XuiSendMessage ( g, #SetGridName, 0, 0, 0, 0, 0, @"DrawingArea")
  516.   XuiSendMessage ( g, #SetColor, $$Black, $$White, $$Black, $$White, 0, 0)
  517.   XuiSendMessage ( g, #SetColorExtra, 37, 120, $$Black, $$White, 0, 0)
  518.   XuiPushButton  (@g, #Create, 4, 448, 148, 20, r0, grid)
  519.   XuiSendMessage ( g, #SetCallback, grid, &Circle(), -1, -1, $ClearButton, grid)
  520.   XuiSendMessage ( g, #SetGridName, 0, 0, 0, 0, 0, @"ClearButton")
  521.   XuiSendMessage ( g, #SetColor, $$BrightGreen, $$Black, $$Black, $$White, 0, 0)
  522.   XuiSendMessage ( g, #SetTextString, 0, 0, 0, 0, 0, @" Clear ")
  523.   XuiPushButton  (@g, #Create, 152, 448, 148, 20, r0, grid)
  524.   XuiSendMessage ( g, #SetCallback, grid, &Circle(), -1, -1, $PauseButton, grid)
  525.   XuiSendMessage ( g, #SetGridName, 0, 0, 0, 0, 0, @"PauseButton")
  526.   XuiSendMessage ( g, #SetColor, 110, $$Black, $$Black, $$White, 0, 0)
  527.   XuiSendMessage ( g, #SetTextString, 0, 0, 0, 0, 0, @" Pause ")
  528.   XuiPushButton  (@g, #Create, 300, 448, 148, 20, r0, grid)
  529.   XuiSendMessage ( g, #SetCallback, grid, &Circle(), -1, -1, $QuitButton, grid)
  530.   XuiSendMessage ( g, #SetGridName, 0, 0, 0, 0, 0, @"QuitButton")
  531.   XuiSendMessage ( g, #SetColor, 102, $$Black, $$Black, $$White, 0, 0)
  532.   XuiSendMessage ( g, #SetTextString, 0, 0, 0, 0, 0, @" Quit ")
  533.   GOSUB Resize
  534. END SUB
  535. '
  536. '
  537. ' *****  CreateWindow  *****  v0123 = xywh : r0 = windowType : r1$ = display$
  538. '
  539. SUB CreateWindow
  540.   IF (v0 =  0) THEN v0 = designX
  541.   IF (v1 =  0) THEN v1 = designY
  542.   IF (v2 <= 0) THEN v2 = designWidth
  543.   IF (v3 <= 0) THEN v3 = designHeight
  544.   XuiWindow (@window, #WindowCreate, v0, v1, v2, v3, r0, @r1$)
  545.   v0 = 0 : v1 = 0 : r0 = window : ATTACH r1$ TO display$
  546.   GOSUB Create
  547.     r1 = 0 : ATTACH display$ TO r1$
  548.   XuiWindow (window, #WindowRegister, grid, -1, v2, v3, @r0, @"Circle")
  549. END SUB
  550. '
  551. '
  552. ' *****  DesignSize  *****
  553. '
  554. SUB DesignSize
  555.   v0 = designX : v1 = designY : v2 = designWidth : v3 = designHeight
  556. END SUB
  557. '
  558. '
  559. ' *****  GetSmallestSize  *****
  560. '
  561. SUB GetSmallestSize
  562.     v2 = 100
  563.     v3 = 120
  564.     XuiGetBorder (grid, #GetBorder, 0, 0, 0, 0, 0, @bw)
  565.     FOR i = 2 TO 4
  566.         XuiSendMessage (grid, #GetSmallestSize, 0, 0, @ww, @hh, i, 0)
  567.         w = MAX (w, ww) : h = MAX (h, hh)
  568.     NEXT i
  569.     w = w + 4 AND -4
  570.     h = h + 4 AND -4
  571.     innerWidth = w + w + w
  572.     innerHeight = innerWidth + h
  573.     totalWidth = bw + bw + innerWidth
  574.     totalHeight = bw + bw + innerHeight
  575.     v2 = totalWidth
  576.     v3 = totalHeight
  577. END SUB
  578. '
  579. '
  580. ' *****  Resize  *****
  581. '
  582. SUB Resize
  583.     v2Entry = v2
  584.     v3Entry = v3
  585.     GOSUB GetSmallestSize
  586.     v2 = MAX (v2, v2Entry)
  587.     v3 = MAX (v3, v3Entry)
  588. '    IF (v2 > (v3 - h)) THEN v2 = v3 - h
  589. '    IF (v3 > (v2 + h)) THEN v3 = v2 + h
  590. '
  591.     XuiPositionGrid (grid, @v0, @v1, @v2, @v3)
  592.     innerWidth = v2 - bw - bw
  593.     innerHeight = v3 - bw - bw
  594.     gw            = innerWidth
  595.     gh            = innerHeight - h
  596.     bw0            = innerWidth / 3
  597.     bw1            = bw0
  598.     bw2            = innerWidth - bw1 - bw0
  599.     bx0            = bw
  600.     bx1            = bx0 + bw0
  601.     bx2            = bx1 + bw1
  602.     by            = v3-h-bw
  603. '
  604.     XuiSendMessage (grid, #Resize,  bw, bw,  gw, gh, 1, 0)
  605.     XuiSendMessage (grid, #Resize, bx0, by, bw0,  h, 2, 0)
  606.     XuiSendMessage (grid, #Resize, bx1, by, bw1,  h, 3, 0)
  607.     XuiSendMessage (grid, #Resize, bx2, by, bw2,  h, 4, 0)
  608.     XuiSendMessage (grid, #ResizeWindowToGrid, 0, 0, 0, 0, 0, 0)
  609.     XuiGetSize (grid, #GetSize, 0, 0, @width, @height, 0, 0)
  610.     XuiCallback (grid, #Resized, 0, 0, width, height, 0, 0)
  611. END SUB
  612. '
  613. '
  614. ' *****  Initialize  *****
  615. '
  616. SUB Initialize
  617.   XuiGetDefaultMessageFuncArray (@func[])
  618.   XgrMessageNameToNumber (@"LastMessage", @upperMessage)
  619. '
  620.   func[#Callback]           = &XuiCallback()
  621.   func[#Resize]             = &XuiResizeNot()
  622.   func[#Selection]          = &XuiCallback()
  623.     func[#GetSmallestSize]    = 0
  624.     func[#Resize]             = 0
  625. '
  626.   DIM sub[upperMessage]
  627.   sub[#Create]              = SUBADDRESS (Create)
  628.   sub[#CreateWindow]        = SUBADDRESS (CreateWindow)
  629.   sub[#GetSmallestSize]     = SUBADDRESS (GetSmallestSize)
  630.   sub[#Resize]              = SUBADDRESS (Resize)
  631. '
  632.     IF func[0] THEN PRINT "Circle(): Initialize: Error::: (Undefined Message)"
  633.     IF sub[0] THEN PRINT "Circle(): Initialize: Error::: (Undefined Message)"
  634.   XuiRegisterGridType (@Circle, "Circle", &Circle(), @func[], @sub[])
  635. '
  636.   designX = 4
  637.   designY = 293
  638.   designWidth = 452
  639.   designHeight = 472
  640. '
  641.     gridType = Circle
  642.     XuiSetGridTypeValue (gridType, @"x",           designX)
  643.     XuiSetGridTypeValue (gridType, @"y",           designY)
  644.     XuiSetGridTypeValue (gridType, @"width",       designWidth)
  645.     XuiSetGridTypeValue (gridType, @"height",      designHeight)
  646.     XuiSetGridTypeValue (gridType, @"border",      $$BorderFrame)
  647.     XuiSetGridTypeValue (gridType, @"can",         $$Focus OR $$Respond OR $$Callback)
  648.   IFZ message THEN RETURN
  649. END SUB
  650. END FUNCTION
  651. '
  652. '
  653. ' ###########################
  654. ' #####  CircleCode ()  #####
  655. ' ###########################
  656. '
  657. FUNCTION  CircleCode (grid, message, v0, v1, v2, v3, r0, r1)
  658.     SHARED    Circle,  CircleGrid
  659.     SHARED    paused,  circleWidth,  circleHeight
  660.     STATIC    entry,  color,  dx,  dy,  half,  rad,  jjj
  661.     STATIC    s1#,  s2#,  a1#,  a2#
  662. '
  663.   $Circle       =   0  ' kid   0 grid type = Circle
  664.   $DrawingArea  =   1  ' kid   1 grid type = XuiArea
  665.   $ClearButton  =   2  ' kid   2 grid type = XuiPushButton
  666.   $PauseButton  =   3  ' kid   3 grid type = XuiPushButton
  667.   $QuitButton   =   4  ' kid   4 grid type = XuiPushButton
  668.   $UpperKid     =   4  ' kid maximum
  669. '
  670. '    XuiReportMessage (grid, message, v0, v1, v2, v3, r0, r1)
  671.     IFZ entry THEN entry = $$TRUE : GOSUB Resized
  672.     IF (message = #Callback) THEN message = r1
  673. '
  674.     SELECT CASE message
  675.         CASE #Redraw            :    GOSUB Redraw
  676.         CASE #Resized            :    GOSUB Resized
  677.         CASE #Selection        :    GOSUB Selection
  678.         CASE #CloseWindow    :    GOSUB CloseWindow
  679.     END SELECT
  680.     RETURN
  681. '
  682. '
  683. ' *****  CloseWindow  *****
  684. '
  685. SUB CloseWindow
  686.     PRINT "CircleCode() : windowType handles CloseWindow from system menu"
  687. END SUB
  688. '
  689. '
  690. ' *****  Selection  *****
  691. '
  692. SUB Selection
  693.     SELECT CASE r0
  694.         CASE $ClearButton    : XgrClearGrid (CircleGrid, -1)
  695.         CASE $PauseButton    : paused = NOT paused
  696.         CASE $QuitButton    : QUIT (0)
  697.     END SELECT
  698. END SUB
  699. '
  700. '
  701. ' *********************
  702. ' *****  Resized  *****  Callbacks from Circle() resize routine
  703. ' *********************
  704. '
  705. SUB Resized
  706.     entry = $$TRUE
  707.     XuiSendMessage (Circle, #GetKidArray, 0, 0, 0, 0, 0, @kid[])
  708.     XuiSendMessage (Circle, #GetSize, 0, 0, @circleWidth, @circleHeight, 1, 0)
  709.     CircleGrid = kid[1]
  710.     s1#        = $$PI / 256#
  711.     s2#        = 4.9# * s1#
  712.     a1#        = 0#
  713.     a2#        = $$PI / 4#
  714.     dx        = circleWidth >> 1
  715.     dy        = circleHeight >> 1
  716.     rad        = MIN (circleWidth, circleHeight) >> 1
  717.     rad        = rad - 6
  718.     color = 0
  719.     XgrClearGrid (CircleGrid, -1)
  720. END SUB
  721. '
  722. '
  723. ' ********************
  724. ' *****  Redraw  *****  Messages from Entry ()
  725. ' ********************
  726. '
  727. SUB Redraw
  728.     INC jjj
  729.     IF (jjj > 100) THEN jjj = 0
  730.     IF (jjj < 50) THEN XgrClearGrid (CircleGrid, -1)        ' comment out or in for variety
  731.     FOR i = 0 TO 99
  732.         GOSUB Circle
  733.     NEXT i
  734.     INC color
  735. END SUB
  736. '
  737. '
  738. ' ********************
  739. ' *****  Circle  *****  Drawing subroutine
  740. ' ********************
  741. '
  742. SUB Circle
  743.     IF (a1# >= $$TWOPI) THEN
  744.         a1# = a1# - $$TWOPI
  745.         color = (color + 3)
  746.         IF (color > 124) THEN color = color - 124
  747.     END IF
  748.     IF (a2# >= $$TWOPI) THEN
  749.         a2# = a2# - $$TWOPI
  750.         INC i
  751.     END IF
  752.     IFZ color THEN INC color
  753.     p1x    = SIN (a1#) * rad + dx
  754.     p1y    = COS (a1#) * rad + dy
  755.     p2x    = SIN (a2#) * rad + dx
  756.     p2y    = COS (a2#) * rad + dy
  757.     XgrDrawLine (CircleGrid, color, p1x, p1y, p2x, p2y)
  758.     a1#    = a1# + s1#
  759.     a2#    = a2# + s2#
  760.     s2# = 1.0002# * s2#
  761.     IF (s2# > $$TWOPI) THEN s2# = s2# - $$TWOPI
  762. END SUB
  763. END FUNCTION
  764. '
  765. '
  766. ' #####################
  767. ' #####  Math ()  #####
  768. ' #####################
  769. '
  770. FUNCTION  Math (grid, message, v0, v1, v2, v3, r0, (r1, r1$, r1[], r1$[]))
  771.     STATIC    designX,  designY,  designWidth,  designHeight
  772.   STATIC    SUBADDR  sub[]
  773.   STATIC    upperMessage
  774.   STATIC    Math
  775. '
  776.   $Math     =  0  ' kid  0 grid type = Math
  777.   $SIN      =  1  ' kid  1 grid type = XuiRadioButton
  778.   $ASIN     =  2  ' kid  2 grid type = XuiRadioButton
  779.   $Graphic  =  3  ' kid  3 grid type = XuiLabel
  780.   $Graph    =  4  ' kid  4 grid type = XuiLabel
  781.   $COS      =  5  ' kid  5 grid type = XuiRadioButton
  782.   $ACOS     =  6  ' kid  6 grid type = XuiRadioButton
  783.   $TAN      =  7  ' kid  7 grid type = XuiRadioButton
  784.   $ATAN     =  8  ' kid  8 grid type = XuiRadioButton
  785.   $COT      =  9  ' kid  9 grid type = XuiRadioButton
  786.   $ACOT     = 10  ' kid 10 grid type = XuiRadioButton
  787.   $SEC      = 11  ' kid 11 grid type = XuiRadioButton
  788.   $ASEC     = 12  ' kid 12 grid type = XuiRadioButton
  789.   $CSC      = 13  ' kid 13 grid type = XuiRadioButton
  790.   $ACSC     = 14  ' kid 14 grid type = XuiRadioButton
  791.   $SINH     = 15  ' kid 15 grid type = XuiRadioButton
  792.   $ASINH    = 16  ' kid 16 grid type = XuiRadioButton
  793.   $COSH     = 17  ' kid 17 grid type = XuiRadioButton
  794.   $ACOSH    = 18  ' kid 18 grid type = XuiRadioButton
  795.   $TANH     = 19  ' kid 19 grid type = XuiRadioButton
  796.   $ATANH    = 20  ' kid 20 grid type = XuiRadioButton
  797.   $COTH     = 21  ' kid 21 grid type = XuiRadioButton
  798.   $ACOTH    = 22  ' kid 22 grid type = XuiRadioButton
  799.   $SECH     = 23  ' kid 23 grid type = XuiRadioButton
  800.   $ASECH    = 24  ' kid 24 grid type = XuiRadioButton
  801.   $CSCH     = 25  ' kid 25 grid type = XuiRadioButton
  802.   $ACSCH    = 26  ' kid 26 grid type = XuiRadioButton
  803.   $SQRT     = 27  ' kid 27 grid type = XuiRadioButton
  804.   $POWER    = 28  ' kid 28 grid type = XuiRadioButton
  805.   $Range    = 29  ' kid 29 grid type = XuiLabel
  806.   $LOG      = 30  ' kid 30 grid type = XuiRadioButton
  807.   $EXP      = 31  ' kid 31 grid type = XuiRadioButton
  808.   $Maximum  = 32  ' kid 32 grid type = XuiLabel
  809.   $LOG10    = 33  ' kid 33 grid type = XuiRadioButton
  810.   $EXP10    = 34  ' kid 34 grid type = XuiRadioButton
  811.   $Minimum  = 35  ' kid 35 grid type = XuiLabel
  812.   $CLEAR    = 36  ' kid 36 grid type = XuiRadioButton
  813.   $QUIT     = 37  ' kid 37 grid type = XuiRadioButton
  814.   $Comment  = 38  ' kid 38 grid type = XuiLabel
  815. '
  816.   IFZ sub[] THEN GOSUB Initialize
  817. '    XuiReportMessage (grid, message, v0, v1, v2, v3, r0, r1)
  818.   IF XuiProcessMessage (grid, message, @v0, @v1, @v2, @v3, @r0, @r1, Math) THEN RETURN
  819.   IF (message <= upperMessage) THEN GOSUB @sub[message]
  820.   RETURN
  821. '
  822. '
  823. ' *****  Callback  *****  message = Callback : r1 = original message
  824. '
  825. SUB Callback
  826.   message = r1
  827.   IF (message <= upperMessage) THEN GOSUB @sub[message]
  828. END SUB
  829. '
  830. '
  831. ' *****  Create  *****  v0123 = xywh : r0 = window : r1 = parent
  832. '
  833. SUB Create
  834.   IF (v0 <= 0) THEN v0 = 0
  835.   IF (v1 <= 0) THEN v1 = 0
  836.   IF (v2 <= 0) THEN v2 = designWidth
  837.   IF (v3 <= 0) THEN v3 = designHeight
  838.   XuiCreateGrid  (@grid, Math, @v0, @v1, @v2, @v3, r0, r1, &Math())
  839.     XuiSendMessage ( grid, #SetGridName, 0, 0, 0, 0, 0, @"Math")
  840.   XuiRadioButton (@g, #Create, 4, 4, 64, 20, r0, grid)
  841.   XuiSendMessage ( g, #SetCallback, grid, &Math(), -1, -1, $SIN, grid)
  842.   XuiSendMessage ( g, #SetGridName, 0, 0, 0, 0, 0, @"SIN")
  843.   XuiSendMessage ( g, #SetColor, 18, 0, 0, 124, 0, 0)
  844.   XuiSendMessage ( g, #SetTextString, 0, 0, 0, 0, 0, @"SIN")
  845.   XuiRadioButton (@g, #Create, 68, 4, 64, 20, r0, grid)
  846.   XuiSendMessage ( g, #SetCallback, grid, &Math(), -1, -1, $ASIN, grid)
  847.   XuiSendMessage ( g, #SetGridName, 0, 0, 0, 0, 0, @"ASIN")
  848.   XuiSendMessage ( g, #SetColor, 16, 0, 0, 124, 0, 0)
  849.   XuiSendMessage ( g, #SetTextString, 0, 0, 0, 0, 0, @"ASIN")
  850.   XuiLabel       (@g, #Create, 132, 4, 248, 248, r0, grid)
  851.   XuiSendMessage ( g, #SetGridName, 0, 0, 0, 0, 0, @"Graphic")
  852.   XuiSendMessage ( g, #SetColor, 7, 0, 0, 124, 0, 0)
  853.   XuiLabel       (@g, #Create, 140, 12, 232, 232, r0, grid)
  854.   XuiSendMessage ( g, #SetGridName, 0, 0, 0, 0, 0, @"Graph")
  855.   XuiSendMessage ( g, #SetColor, 0, 0, 0, 124, 0, 0)
  856.   XuiSendMessage ( g, #SetBorder, $$BorderHiLine1, $$BorderHiLine1, $$BorderRaise1, -1, 0, 0)
  857.     XuiSendMessage ( g, #SetMessageFunc, #RedrawGrid, &MathCode(), 0, 0, 0, 0)
  858.   XuiRadioButton (@g, #Create, 4, 24, 64, 20, r0, grid)
  859.   XuiSendMessage ( g, #SetCallback, grid, &Math(), -1, -1, $COS, grid)
  860.   XuiSendMessage ( g, #SetGridName, 0, 0, 0, 0, 0, @"COS")
  861.   XuiSendMessage ( g, #SetColor, 18, 0, 0, 124, 0, 0)
  862.   XuiSendMessage ( g, #SetTextString, 0, 0, 0, 0, 0, @"COS")
  863.   XuiRadioButton (@g, #Create, 68, 24, 64, 20, r0, grid)
  864.   XuiSendMessage ( g, #SetCallback, grid, &Math(), -1, -1, $ACOS, grid)
  865.   XuiSendMessage ( g, #SetGridName, 0, 0, 0, 0, 0, @"ACOS")
  866.   XuiSendMessage ( g, #SetColor, 16, 0, 0, 124, 0, 0)
  867.   XuiSendMessage ( g, #SetTextString, 0, 0, 0, 0, 0, @"ACOS")
  868.   XuiRadioButton (@g, #Create, 4, 44, 64, 20, r0, grid)
  869.   XuiSendMessage ( g, #SetCallback, grid, &Math(), -1, -1, $TAN, grid)
  870.   XuiSendMessage ( g, #SetGridName, 0, 0, 0, 0, 0, @"TAN")
  871.   XuiSendMessage ( g, #SetColor, 18, 0, 0, 124, 0, 0)
  872.   XuiSendMessage ( g, #SetTextString, 0, 0, 0, 0, 0, @"TAN")
  873.   XuiRadioButton (@g, #Create, 68, 44, 64, 20, r0, grid)
  874.   XuiSendMessage ( g, #SetCallback, grid, &Math(), -1, -1, $ATAN, grid)
  875.   XuiSendMessage ( g, #SetGridName, 0, 0, 0, 0, 0, @"ATAN")
  876.   XuiSendMessage ( g, #SetColor, 16, 0, 0, 124, 0, 0)
  877.   XuiSendMessage ( g, #SetTextString, 0, 0, 0, 0, 0, @"ATAN")
  878.   XuiRadioButton (@g, #Create, 4, 64, 64, 20, r0, grid)
  879.   XuiSendMessage ( g, #SetCallback, grid, &Math(), -1, -1, $COT, grid)
  880.   XuiSendMessage ( g, #SetGridName, 0, 0, 0, 0, 0, @"COT")
  881.   XuiSendMessage ( g, #SetColor, 18, 0, 0, 124, 0, 0)
  882.   XuiSendMessage ( g, #SetTextString, 0, 0, 0, 0, 0, @"COT")
  883.   XuiRadioButton (@g, #Create, 68, 64, 64, 20, r0, grid)
  884.   XuiSendMessage ( g, #SetCallback, grid, &Math(), -1, -1, $ACOT, grid)
  885.   XuiSendMessage ( g, #SetGridName, 0, 0, 0, 0, 0, @"ACOT")
  886.   XuiSendMessage ( g, #SetColor, 16, 0, 0, 124, 0, 0)
  887.   XuiSendMessage ( g, #SetTextString, 0, 0, 0, 0, 0, @"ACOT")
  888.   XuiRadioButton (@g, #Create, 4, 84, 64, 20, r0, grid)
  889.   XuiSendMessage ( g, #SetCallback, grid, &Math(), -1, -1, $SEC, grid)
  890.   XuiSendMessage ( g, #SetGridName, 0, 0, 0, 0, 0, @"SEC")
  891.   XuiSendMessage ( g, #SetColor, 18, 0, 0, 124, 0, 0)
  892.   XuiSendMessage ( g, #SetTextString, 0, 0, 0, 0, 0, @"SEC")
  893.   XuiRadioButton (@g, #Create, 68, 84, 64, 20, r0, grid)
  894.   XuiSendMessage ( g, #SetCallback, grid, &Math(), -1, -1, $ASEC, grid)
  895.   XuiSendMessage ( g, #SetGridName, 0, 0, 0, 0, 0, @"ASEC")
  896.   XuiSendMessage ( g, #SetColor, 16, 0, 0, 124, 0, 0)
  897.   XuiSendMessage ( g, #SetTextString, 0, 0, 0, 0, 0, @"ASEC")
  898.   XuiRadioButton (@g, #Create, 4, 104, 64, 20, r0, grid)
  899.   XuiSendMessage ( g, #SetCallback, grid, &Math(), -1, -1, $CSC, grid)
  900.   XuiSendMessage ( g, #SetGridName, 0, 0, 0, 0, 0, @"CSC")
  901.   XuiSendMessage ( g, #SetColor, 18, 0, 0, 124, 0, 0)
  902.   XuiSendMessage ( g, #SetTextString, 0, 0, 0, 0, 0, @"CSC")
  903.   XuiRadioButton (@g, #Create, 68, 104, 64, 20, r0, grid)
  904.   XuiSendMessage ( g, #SetCallback, grid, &Math(), -1, -1, $ACSC, grid)
  905.   XuiSendMessage ( g, #SetGridName, 0, 0, 0, 0, 0, @"ACSC")
  906.   XuiSendMessage ( g, #SetColor, 16, 0, 0, 124, 0, 0)
  907.   XuiSendMessage ( g, #SetTextString, 0, 0, 0, 0, 0, @"ACSC")
  908.   XuiRadioButton (@g, #Create, 4, 132, 64, 20, r0, grid)
  909.   XuiSendMessage ( g, #SetCallback, grid, &Math(), -1, -1, $SINH, grid)
  910.   XuiSendMessage ( g, #SetGridName, 0, 0, 0, 0, 0, @"SINH")
  911.   XuiSendMessage ( g, #SetColor, 18, 0, 0, 124, 0, 0)
  912.   XuiSendMessage ( g, #SetTextString, 0, 0, 0, 0, 0, @"SINH")
  913.   XuiRadioButton (@g, #Create, 68, 132, 64, 20, r0, grid)
  914.   XuiSendMessage ( g, #SetCallback, grid, &Math(), -1, -1, $ASINH, grid)
  915.   XuiSendMessage ( g, #SetGridName, 0, 0, 0, 0, 0, @"ASINH")
  916.   XuiSendMessage ( g, #SetColor, 16, 0, 0, 124, 0, 0)
  917.   XuiSendMessage ( g, #SetTextString, 0, 0, 0, 0, 0, @"ASINH")
  918.   XuiRadioButton (@g, #Create, 4, 152, 64, 20, r0, grid)
  919.   XuiSendMessage ( g, #SetCallback, grid, &Math(), -1, -1, $COSH, grid)
  920.   XuiSendMessage ( g, #SetGridName, 0, 0, 0, 0, 0, @"COSH")
  921.   XuiSendMessage ( g, #SetColor, 18, 0, 0, 124, 0, 0)
  922.   XuiSendMessage ( g, #SetTextString, 0, 0, 0, 0, 0, @"COSH")
  923.   XuiRadioButton (@g, #Create, 68, 152, 64, 20, r0, grid)
  924.   XuiSendMessage ( g, #SetCallback, grid, &Math(), -1, -1, $ACOSH, grid)
  925.   XuiSendMessage ( g, #SetGridName, 0, 0, 0, 0, 0, @"ACOSH")
  926.   XuiSendMessage ( g, #SetColor, 16, 0, 0, 124, 0, 0)
  927.   XuiSendMessage ( g, #SetTextString, 0, 0, 0, 0, 0, @"ACOSH")
  928.   XuiRadioButton (@g, #Create, 4, 172, 64, 20, r0, grid)
  929.   XuiSendMessage ( g, #SetCallback, grid, &Math(), -1, -1, $TANH, grid)
  930.   XuiSendMessage ( g, #SetGridName, 0, 0, 0, 0, 0, @"TANH")
  931.   XuiSendMessage ( g, #SetColor, 18, 0, 0, 124, 0, 0)
  932.   XuiSendMessage ( g, #SetTextString, 0, 0, 0, 0, 0, @"TANH")
  933.   XuiRadioButton (@g, #Create, 68, 172, 64, 20, r0, grid)
  934.   XuiSendMessage ( g, #SetCallback, grid, &Math(), -1, -1, $ATANH, grid)
  935.   XuiSendMessage ( g, #SetGridName, 0, 0, 0, 0, 0, @"ATANH")
  936.   XuiSendMessage ( g, #SetColor, 16, 0, 0, 124, 0, 0)
  937.   XuiSendMessage ( g, #SetTextString, 0, 0, 0, 0, 0, @"ATANH")
  938.   XuiRadioButton (@g, #Create, 4, 192, 64, 20, r0, grid)
  939.   XuiSendMessage ( g, #SetCallback, grid, &Math(), -1, -1, $COTH, grid)
  940.   XuiSendMessage ( g, #SetGridName, 0, 0, 0, 0, 0, @"COTH")
  941.   XuiSendMessage ( g, #SetColor, 18, 0, 0, 124, 0, 0)
  942.   XuiSendMessage ( g, #SetTextString, 0, 0, 0, 0, 0, @"COTH")
  943.   XuiRadioButton (@g, #Create, 68, 192, 64, 20, r0, grid)
  944.   XuiSendMessage ( g, #SetCallback, grid, &Math(), -1, -1, $ACOTH, grid)
  945.   XuiSendMessage ( g, #SetGridName, 0, 0, 0, 0, 0, @"ACOTH")
  946.   XuiSendMessage ( g, #SetColor, 16, 0, 0, 124, 0, 0)
  947.   XuiSendMessage ( g, #SetTextString, 0, 0, 0, 0, 0, @"ACOTH")
  948.   XuiRadioButton (@g, #Create, 4, 212, 64, 20, r0, grid)
  949.   XuiSendMessage ( g, #SetCallback, grid, &Math(), -1, -1, $SECH, grid)
  950.   XuiSendMessage ( g, #SetGridName, 0, 0, 0, 0, 0, @"SECH")
  951.   XuiSendMessage ( g, #SetColor, 18, 0, 0, 124, 0, 0)
  952.   XuiSendMessage ( g, #SetTextString, 0, 0, 0, 0, 0, @"SECH")
  953.   XuiRadioButton (@g, #Create, 68, 212, 64, 20, r0, grid)
  954.   XuiSendMessage ( g, #SetCallback, grid, &Math(), -1, -1, $ASECH, grid)
  955.   XuiSendMessage ( g, #SetGridName, 0, 0, 0, 0, 0, @"ASECH")
  956.   XuiSendMessage ( g, #SetColor, 16, 0, 0, 124, 0, 0)
  957.   XuiSendMessage ( g, #SetTextString, 0, 0, 0, 0, 0, @"ASECH")
  958.   XuiRadioButton (@g, #Create, 4, 232, 64, 20, r0, grid)
  959.   XuiSendMessage ( g, #SetCallback, grid, &Math(), -1, -1, $CSCH, grid)
  960.   XuiSendMessage ( g, #SetGridName, 0, 0, 0, 0, 0, @"CSCH")
  961.   XuiSendMessage ( g, #SetColor, 18, 0, 0, 124, 0, 0)
  962.   XuiSendMessage ( g, #SetTextString, 0, 0, 0, 0, 0, @"CSCH")
  963.   XuiRadioButton (@g, #Create, 68, 232, 64, 20, r0, grid)
  964.   XuiSendMessage ( g, #SetCallback, grid, &Math(), -1, -1, $ACSCH, grid)
  965.   XuiSendMessage ( g, #SetGridName, 0, 0, 0, 0, 0, @"ACSCH")
  966.   XuiSendMessage ( g, #SetColor, 16, 0, 0, 124, 0, 0)
  967.   XuiSendMessage ( g, #SetTextString, 0, 0, 0, 0, 0, @"ACSCH")
  968.   XuiRadioButton (@g, #Create, 4, 260, 64, 20, r0, grid)
  969.   XuiSendMessage ( g, #SetCallback, grid, &Math(), -1, -1, $SQRT, grid)
  970.   XuiSendMessage ( g, #SetGridName, 0, 0, 0, 0, 0, @"SQRT")
  971.   XuiSendMessage ( g, #SetColor, 18, 0, 0, 124, 0, 0)
  972.   XuiSendMessage ( g, #SetTextString, 0, 0, 0, 0, 0, @"SQRT")
  973.   XuiRadioButton (@g, #Create, 68, 260, 64, 20, r0, grid)
  974.   XuiSendMessage ( g, #SetCallback, grid, &Math(), -1, -1, $POWER, grid)
  975.   XuiSendMessage ( g, #SetGridName, 0, 0, 0, 0, 0, @"POWER")
  976.   XuiSendMessage ( g, #SetColor, 16, 0, 0, 124, 0, 0)
  977.   XuiSendMessage ( g, #SetTextString, 0, 0, 0, 0, 0, @"POWER")
  978.   XuiLabel       (@g, #Create, 132, 260, 248, 20, r0, grid)
  979.   XuiSendMessage ( g, #SetGridName, 0, 0, 0, 0, 0, @"Range")
  980.   XuiSendMessage ( g, #SetColor, 61, 0, 0, 124, 0, 0)
  981.   XuiSendMessage ( g, #SetAlign, $$AlignMiddleLeft, -1, 4, 0, 0, 0)
  982.   XuiSendMessage ( g, #SetTextString, 0, 0, 0, 0, 0, @"Range:")
  983.   XuiRadioButton (@g, #Create, 4, 280, 64, 20, r0, grid)
  984.   XuiSendMessage ( g, #SetCallback, grid, &Math(), -1, -1, $LOG, grid)
  985.   XuiSendMessage ( g, #SetGridName, 0, 0, 0, 0, 0, @"LOG")
  986.   XuiSendMessage ( g, #SetColor, 18, 0, 0, 124, 0, 0)
  987.   XuiSendMessage ( g, #SetTextString, 0, 0, 0, 0, 0, @"LOG")
  988.   XuiRadioButton (@g, #Create, 68, 280, 64, 20, r0, grid)
  989.   XuiSendMessage ( g, #SetCallback, grid, &Math(), -1, -1, $EXP, grid)
  990.   XuiSendMessage ( g, #SetGridName, 0, 0, 0, 0, 0, @"EXP")
  991.   XuiSendMessage ( g, #SetColor, 16, 0, 0, 124, 0, 0)
  992.   XuiSendMessage ( g, #SetTextString, 0, 0, 0, 0, 0, @"EXP")
  993.   XuiLabel       (@g, #Create, 132, 280, 248, 20, r0, grid)
  994.   XuiSendMessage ( g, #SetGridName, 0, 0, 0, 0, 0, @"Maximum")
  995.   XuiSendMessage ( g, #SetColor, 56, 0, 0, 124, 0, 0)
  996.   XuiSendMessage ( g, #SetAlign, $$AlignMiddleLeft, -1, 4, 0, 0, 0)
  997.   XuiSendMessage ( g, #SetTextString, 0, 0, 0, 0, 0, @"Maximum:")
  998.   XuiRadioButton (@g, #Create, 4, 300, 64, 20, r0, grid)
  999.   XuiSendMessage ( g, #SetCallback, grid, &Math(), -1, -1, $LOG10, grid)
  1000.   XuiSendMessage ( g, #SetGridName, 0, 0, 0, 0, 0, @"LOG10")
  1001.   XuiSendMessage ( g, #SetColor, 18, 0, 0, 124, 0, 0)
  1002.   XuiSendMessage ( g, #SetTextString, 0, 0, 0, 0, 0, @"LOG10")
  1003.   XuiRadioButton (@g, #Create, 68, 300, 64, 20, r0, grid)
  1004.   XuiSendMessage ( g, #SetCallback, grid, &Math(), -1, -1, $EXP10, grid)
  1005.   XuiSendMessage ( g, #SetGridName, 0, 0, 0, 0, 0, @"EXP10")
  1006.   XuiSendMessage ( g, #SetColor, 16, 0, 0, 124, 0, 0)
  1007.   XuiSendMessage ( g, #SetTextString, 0, 0, 0, 0, 0, @"EXP10")
  1008.   XuiLabel       (@g, #Create, 132, 300, 248, 20, r0, grid)
  1009.   XuiSendMessage ( g, #SetGridName, 0, 0, 0, 0, 0, @"Minimum")
  1010.   XuiSendMessage ( g, #SetColor, 56, 0, 0, 124, 0, 0)
  1011.   XuiSendMessage ( g, #SetAlign, $$AlignMiddleLeft, -1, 4, 0, 0, 0)
  1012.   XuiSendMessage ( g, #SetTextString, 0, 0, 0, 0, 0, @"Minimum:")
  1013.   XuiRadioButton (@g, #Create, 4, 320, 64, 20, r0, grid)
  1014.   XuiSendMessage ( g, #SetCallback, grid, &Math(), -1, -1, $CLEAR, grid)
  1015.   XuiSendMessage ( g, #SetGridName, 0, 0, 0, 0, 0, @"CLEAR")
  1016.   XuiSendMessage ( g, #SetColor, 15, 0, 0, 124, 0, 0)
  1017.   XuiSendMessage ( g, #SetTextString, 0, 0, 0, 0, 0, @"CLEAR")
  1018.   XuiRadioButton (@g, #Create, 68, 320, 64, 20, r0, grid)
  1019.   XuiSendMessage ( g, #SetCallback, grid, &Math(), -1, -1, $QUIT, grid)
  1020.   XuiSendMessage ( g, #SetGridName, 0, 0, 0, 0, 0, @"QUIT")
  1021.   XuiSendMessage ( g, #SetColor, 78, 0, 0, 124, 0, 0)
  1022.   XuiSendMessage ( g, #SetTextString, 0, 0, 0, 0, 0, @"QUIT")
  1023.     XuiSendMessage ( g, #SetTexture, $$TextureShadow, $$TextureShadow, 0, 0, 0, 0)
  1024.   XuiLabel       (@g, #Create, 132, 320, 248, 20, r0, grid)
  1025.   XuiSendMessage ( g, #SetGridName, 0, 0, 0, 0, 0, @"Comment")
  1026.   XuiSendMessage ( g, #SetColor, 57, 0, 0, 124, 0, 0)
  1027.   XuiSendMessage ( g, #SetAlign, $$AlignMiddleLeft, -1, 4, 0, 0, 0)
  1028.   XuiSendMessage ( g, #SetTextString, 0, 0, 0, 0, 0, @"Comment:")
  1029.   GOSUB Resize
  1030. END SUB
  1031. '
  1032. '
  1033. ' *****  CreateWindow  *****  v0123 = xywh : r0 = windowType : r1$ = display$
  1034. '
  1035. SUB CreateWindow
  1036.   IF (v0 =  0) THEN v0 = designX
  1037.   IF (v1 =  0) THEN v1 = designY
  1038.   IF (v2 <= 0) THEN v2 = designWidth
  1039.   IF (v3 <= 0) THEN v3 = designHeight
  1040.   XuiWindow (@window, #WindowCreate, v0, v1, v2, v3, r0, @r1$)
  1041.   v0 = 0 : v1 = 0 : r0 = window : ATTACH r1$ TO display$
  1042.   GOSUB Create
  1043.     r1 = 0 : ATTACH display$ TO r1$
  1044.   XuiWindow (window, #WindowRegister, grid, -1, v2, v3, @r0, @"Math")
  1045. END SUB
  1046. '
  1047. '
  1048. ' *****  GetSmallestSize  *****
  1049. '
  1050. SUB GetSmallestSize
  1051. END SUB
  1052. '
  1053. '
  1054. ' *****  Resize  *****
  1055. '
  1056. SUB Resize
  1057. END SUB
  1058. '
  1059. '
  1060. ' *****  Selection  *****
  1061. '
  1062. SUB Selection
  1063. END SUB
  1064. '
  1065. '
  1066. ' *****  Initialize  *****
  1067. '
  1068. SUB Initialize
  1069.   XuiGetDefaultMessageFuncArray (@func[])
  1070.   XgrMessageNameToNumber (@"LastMessage", @upperMessage)
  1071. '
  1072.   func[#Callback]           = &XuiCallback()
  1073.   func[#Resize]             = &XuiResizeNot()
  1074. '
  1075.   DIM sub[upperMessage]
  1076.   sub[#Create]              = SUBADDRESS (Create)
  1077.   sub[#CreateWindow]        = SUBADDRESS (CreateWindow)
  1078. '
  1079.   IF sub[0] THEN PRINT "First(): Initialize: Error::: Undefined Message"
  1080.   IF func[0] THEN PRINT "First(): Initialize: Error::: Undefined Message"
  1081.   XuiRegisterGridType (@Math, "Math", &Math(), @func[], @sub[])
  1082. '
  1083.   designX = 800
  1084.   designY = 23
  1085.   designWidth = 384
  1086.   designHeight = 344
  1087. '
  1088.   gridType = Math
  1089.   XuiSetGridTypeValue (gridType, @"x",                designX)
  1090.   XuiSetGridTypeValue (gridType, @"y",                designY)
  1091.   XuiSetGridTypeValue (gridType, @"width",            designWidth)
  1092.   XuiSetGridTypeValue (gridType, @"height",           designHeight)
  1093.   XuiSetGridTypeValue (gridType, @"maxWidth",         designWidth)
  1094.   XuiSetGridTypeValue (gridType, @"maxHeight",        designHeight)
  1095.   XuiSetGridTypeValue (gridType, @"minWidth",         designWidth)
  1096.   XuiSetGridTypeValue (gridType, @"minHeight",        designHeight)
  1097.   XuiSetGridTypeValue (gridType, @"border",           $$BorderFrame)
  1098.   XuiSetGridTypeValue (gridType, @"can",              $$Respond OR $$Callback)
  1099.   IFZ message THEN RETURN
  1100. END SUB
  1101. END FUNCTION
  1102. '
  1103. '
  1104. ' #########################
  1105. ' #####  MathCode ()  #####
  1106. ' #########################
  1107. '
  1108. FUNCTION  MathCode (grid, message, v0, v1, v2, v3, r0, r1)
  1109.     STATIC    graph
  1110.     STATIC    func
  1111. '
  1112.   $Math     =  0  ' kid  0 grid type = Math
  1113.   $SIN      =  1  ' kid  1 grid type = XuiRadioButton
  1114.   $ASIN     =  2  ' kid  2 grid type = XuiRadioButton
  1115.   $Graphic  =  3  ' kid  3 grid type = XuiLabel
  1116.   $Graph    =  4  ' kid  4 grid type = XuiLabel
  1117.   $COS      =  5  ' kid  5 grid type = XuiRadioButton
  1118.   $ACOS     =  6  ' kid  6 grid type = XuiRadioButton
  1119.   $TAN      =  7  ' kid  7 grid type = XuiRadioButton
  1120.   $ATAN     =  8  ' kid  8 grid type = XuiRadioButton
  1121.   $COT      =  9  ' kid  9 grid type = XuiRadioButton
  1122.   $ACOT     = 10  ' kid 10 grid type = XuiRadioButton
  1123.   $SEC      = 11  ' kid 11 grid type = XuiRadioButton
  1124.   $ASEC     = 12  ' kid 12 grid type = XuiRadioButton
  1125.   $CSC      = 13  ' kid 13 grid type = XuiRadioButton
  1126.   $ACSC     = 14  ' kid 14 grid type = XuiRadioButton
  1127.   $SINH     = 15  ' kid 15 grid type = XuiRadioButton
  1128.   $ASINH    = 16  ' kid 16 grid type = XuiRadioButton
  1129.   $COSH     = 17  ' kid 17 grid type = XuiRadioButton
  1130.   $ACOSH    = 18  ' kid 18 grid type = XuiRadioButton
  1131.   $TANH     = 19  ' kid 19 grid type = XuiRadioButton
  1132.   $ATANH    = 20  ' kid 20 grid type = XuiRadioButton
  1133.   $COTH     = 21  ' kid 21 grid type = XuiRadioButton
  1134.   $ACOTH    = 22  ' kid 22 grid type = XuiRadioButton
  1135.   $SECH     = 23  ' kid 23 grid type = XuiRadioButton
  1136.   $ASECH    = 24  ' kid 24 grid type = XuiRadioButton
  1137.   $CSCH     = 25  ' kid 25 grid type = XuiRadioButton
  1138.   $ACSCH    = 26  ' kid 26 grid type = XuiRadioButton
  1139.   $SQRT     = 27  ' kid 27 grid type = XuiRadioButton
  1140.   $POWER    = 28  ' kid 28 grid type = XuiRadioButton
  1141.   $Range    = 29  ' kid 29 grid type = XuiLabel
  1142.   $LOG      = 30  ' kid 30 grid type = XuiRadioButton
  1143.   $EXP      = 31  ' kid 31 grid type = XuiRadioButton
  1144.   $Maximum  = 32  ' kid 32 grid type = XuiLabel
  1145.   $LOG10    = 33  ' kid 33 grid type = XuiRadioButton
  1146.   $EXP10    = 34  ' kid 34 grid type = XuiRadioButton
  1147.   $Minimum  = 35  ' kid 35 grid type = XuiLabel
  1148.   $CLEAR    = 36  ' kid 36 grid type = XuiRadioButton
  1149.   $QUIT     = 37  ' kid 37 grid type = XuiRadioButton
  1150.   $Comment  = 38  ' kid 38 grid type = XuiLabel
  1151. '
  1152.     IFZ graph THEN GOSUB Initialize
  1153. '    XuiReportMessage (grid, message, v0, v1, v2, v3, r0, r1)
  1154.     IF (message = #Callback) THEN message = r1
  1155. '
  1156.     SELECT CASE message
  1157. '   CASE #Help                :    GOSUB Help        ' callback when help requested
  1158.         CASE #CloseWindow    :    GOSUB CloseWindow    ' window closed by system menu
  1159.         CASE #RedrawGrid    : GOSUB RedrawGrid    ' graph cleared - redraw trig
  1160.     CASE #Selection        :    GOSUB Selection   ' common callback message
  1161. '   CASE #TextEvent        :    GOSUB TextEvent   ' from TextArea and TextLine
  1162.     END SELECT
  1163.     RETURN
  1164. '
  1165. '
  1166. ' *****  CloseWindow  *****
  1167. '
  1168. SUB CloseWindow
  1169.     PRINT "MathCode() : windowType handles CloseWindow from system menu"
  1170. END SUB
  1171. '
  1172. '
  1173. ' *****  RedrawGrid  *****
  1174. '
  1175. SUB RedrawGrid
  1176.     XuiRedrawGrid (grid, #RedrawGrid, 0, 0, 0, 0, 0, 0)
  1177.     r0 = func                                        ' same curve as before
  1178.     v0 = $$TRUE                                    ' simulate select button
  1179.     GOSUB Selection                            '    redraw the curve
  1180. END SUB
  1181. '
  1182. '
  1183. ' *****  Selection  *****
  1184. '
  1185. SUB Selection
  1186.     IFZ v0 THEN EXIT SUB
  1187.     func = r0
  1188.     SELECT CASE r0
  1189.         CASE $SIN            :    GOSUB PlotSIN
  1190.         CASE $COS            :    GOSUB PlotCOS
  1191.         CASE $TAN            :    GOSUB PlotTAN
  1192.         CASE $COT            :    GOSUB PlotCOT
  1193.         CASE $SEC            :    GOSUB PlotSEC
  1194.         CASE $CSC            :    GOSUB PlotCSC
  1195. '
  1196.         CASE $ASIN        :    GOSUB PlotASIN
  1197.         CASE $ACOS        :    GOSUB PlotACOS
  1198.         CASE $ATAN        :    GOSUB PlotATAN
  1199.         CASE $ACOT        :    GOSUB PlotACOT
  1200.         CASE $ASEC        :    GOSUB PlotASEC
  1201.         CASE $ACSC        :    GOSUB PlotACSC
  1202. '
  1203.         CASE $SINH        :    GOSUB PlotSINH
  1204.         CASE $COSH        :    GOSUB PlotCOSH
  1205.         CASE $TANH        :    GOSUB PlotTANH
  1206.         CASE $COTH        :    GOSUB PlotCOTH
  1207.         CASE $SECH        :    GOSUB PlotSECH
  1208.         CASE $CSCH        :    GOSUB PlotCSCH
  1209. '
  1210.         CASE $ASINH        :    GOSUB PlotASINH
  1211.         CASE $ACOSH        :    GOSUB PlotACOSH
  1212.         CASE $ATANH        :    GOSUB PlotATANH
  1213.         CASE $ACOTH        :    GOSUB PlotACOTH
  1214.         CASE $ASECH        :    GOSUB PlotASECH
  1215.         CASE $ACSCH        :    GOSUB PlotACSCH
  1216. '
  1217.         CASE $SQRT        :    GOSUB PlotSQRT
  1218.         CASE $POWER        :    GOSUB PlotPOWER
  1219.         CASE $LOG            :    GOSUB PlotLOG
  1220.         CASE $EXP            :    GOSUB PlotEXP
  1221.         CASE $LOG10        :    GOSUB PlotLOG10
  1222.         CASE $EXP10        :    GOSUB PlotEXP10
  1223. '
  1224.         CASE $CLEAR        :    XgrClearGrid (graph, -1) : GOSUB DrawAxes
  1225.         CASE $QUIT        :    QUIT(0)
  1226.         CASE ELSE            :    func = 0
  1227.     END SELECT
  1228. END SUB
  1229. '
  1230. '
  1231. ' *****  DrawAxes  *****
  1232. '
  1233. SUB DrawAxes
  1234.     XgrClearGrid (graph, -1)
  1235.     XgrSetGridBoxScaled (graph, -1#, -1#, +1#, +1#)
  1236.     XgrDrawLineScaled (graph, $$Green, -1#, 0#, +1#, 0#)
  1237.     XgrDrawLineScaled (graph, $$Green, 0#, +1#, 0#, -1#)
  1238.     XgrDrawBoxScaled (graph, $$BrightGreen, -1#, -1#, +1#, +1#)
  1239.     XuiSendMessage (grid, #SetTextString, 0, 0, 0, 0, $Range,   "Range::: " + range$)
  1240.     XuiSendMessage (grid, #SetTextString, 0, 0, 0, 0, $Minimum, "Minumum: " + minimum$)
  1241.     XuiSendMessage (grid, #SetTextString, 0, 0, 0, 0, $Maximum, "Maximum: " + maximum$)
  1242.     XuiSendMessage (grid, #SetTextString, 0, 0, 0, 0, $Comment, "Comment: " + comment$)
  1243.     XuiSendMessage (grid, #Redraw, 0, 0, 0, 0, $Range, 0)
  1244.     XuiSendMessage (grid, #Redraw, 0, 0, 0, 0, $Minimum, 0)
  1245.     XuiSendMessage (grid, #Redraw, 0, 0, 0, 0, $Maximum, 0)
  1246.     XuiSendMessage (grid, #Redraw, 0, 0, 0, 0, $Comment, 0)
  1247.     range$ = ""
  1248.     minimum$ = ""
  1249.     maximum$ = ""
  1250.     comment$ = ""
  1251. END SUB
  1252. '
  1253. '
  1254. ' *****  PlotSIN  *****
  1255. '
  1256. SUB PlotSIN
  1257.     range$ = "-2PI to +2PI"
  1258.     minimum$ = "-1"
  1259.     maximum$ = "+1"
  1260.     comment$ = "SIN()"
  1261.     GOSUB DrawAxes
  1262.     XgrSetGridBoxScaled (graph, -$$TWOPI, 1#, $$TWOPI, -1#)
  1263.     x# = -$$TWOPI
  1264.     y# = SIN (x#)
  1265.     XgrMoveToScaled (graph, x#, y#)
  1266.     FOR x# = -$$TWOPI TO $$TWOPI STEP ($$PI/64#)
  1267.         y# = SIN(x#)
  1268.         XgrDrawLineToScaled (graph, $$Yellow, x#, y#)
  1269.     NEXT x#
  1270. END SUB
  1271. '
  1272. SUB PlotCOS
  1273.     range$ = "-2PI to +2PI"
  1274.     minimum$ = "-1"
  1275.     maximum$ = "+1"
  1276.     comment$ = "COS()"
  1277.     GOSUB DrawAxes
  1278.     XgrSetGridBoxScaled (graph, -$$TWOPI, 1#, $$TWOPI, -1#)
  1279.     x# = -$$TWOPI
  1280.     y# = COS (x#)
  1281.     XgrMoveToScaled (graph, x#, y#)
  1282.     FOR x# = -$$TWOPI TO $$TWOPI STEP ($$PI/64#)
  1283.         y# = COS (x#)
  1284.         XgrDrawLineToScaled (graph, $$Yellow, x#, y#)
  1285.     NEXT x#
  1286. END SUB
  1287. '
  1288. SUB PlotTAN
  1289.     range$ = "-2PI to +2PI"
  1290.     minimum$ = "-4"
  1291.     maximum$ = "+4"
  1292.     comment$ = "TAN()"
  1293.     GOSUB DrawAxes
  1294.     XgrSetGridBoxScaled (graph, -$$TWOPI, 4#, $$TWOPI, -4#)
  1295.     x# = -$$TWOPI
  1296.     y# = TAN (x#)
  1297.     XgrMoveToScaled (graph, x#, y#)
  1298.     FOR x# = -$$TWOPI TO $$TWOPI STEP ($$PI/64#)
  1299.         y# = TAN (x#)
  1300.         XgrDrawLineToScaled (graph, $$Yellow, x#, y#)
  1301.     NEXT x#
  1302. END SUB
  1303. '
  1304. SUB PlotCOT
  1305.     range$ = "-2PI to +2PI"
  1306.     minimum$ = "-4"
  1307.     maximum$ = "+4"
  1308.     comment$ = "COT()"
  1309.     GOSUB DrawAxes
  1310.     XgrSetGridBoxScaled (graph, -$$TWOPI, 4#, $$TWOPI, -4#)
  1311.     x# = -$$TWOPI
  1312.     y# = COT (x#)
  1313.     XgrMoveToScaled (graph, x#, y#)
  1314.     FOR x# = -$$TWOPI TO $$TWOPI STEP ($$PI/64#)
  1315.         y# = COT (x#)
  1316.         XgrDrawLineToScaled (graph, $$Yellow, x#, y#)
  1317.     NEXT x#
  1318. END SUB
  1319. '
  1320. SUB PlotSEC
  1321.     range$ = "-2PI to +2PI"
  1322.     minimum$ = "-4"
  1323.     maximum$ = "+4"
  1324.     comment$ = "SEC()"
  1325.     GOSUB DrawAxes
  1326.     XgrSetGridBoxScaled (graph, -$$TWOPI, 4#, $$TWOPI, -4#)
  1327.     x# = -$$TWOPI
  1328.     y# = SEC (x#)
  1329.     XgrMoveToScaled (graph, x#, y#)
  1330.     FOR x# = -$$TWOPI TO $$TWOPI STEP ($$PI/64#)
  1331.         y# = SEC (x#)
  1332.         XgrDrawLineToScaled (graph, $$Yellow, x#, y#)
  1333.     NEXT x#
  1334. END SUB
  1335. '
  1336. SUB PlotCSC
  1337.     range$ = "-2PI to +2PI"
  1338.     minimum$ = "-4"
  1339.     maximum$ = "+4"
  1340.     comment$ = "CSC()"
  1341.     GOSUB DrawAxes
  1342.     XgrSetGridBoxScaled (graph, -$$TWOPI, 4#, $$TWOPI, -4#)
  1343.     x# = -$$TWOPI
  1344.     y# = CSC (x#)
  1345.     XgrMoveToScaled (graph, x#, y#)
  1346.     FOR x# = -$$TWOPI TO $$TWOPI STEP ($$PI/64#)
  1347.         y# = CSC (x#)
  1348.         XgrDrawLineToScaled (graph, $$Yellow, x#, y#)
  1349.     NEXT x#
  1350. END SUB
  1351. '
  1352. '
  1353. ' *****  PlotASIN  *****
  1354. '
  1355. SUB PlotASIN
  1356.     range$ = "-1 to +1"
  1357.     minimum$ = "-PI/2"
  1358.     maximum$ = "+PI/2"
  1359.     comment$ = "ASIN()"
  1360.     GOSUB DrawAxes
  1361.     XgrSetGridBoxScaled (graph, -1#, +$$PIDIV2, +1#, -$$PIDIV2)
  1362.     x# = -1#
  1363.     y# = ASIN (x#)
  1364.     XgrMoveToScaled (graph, x#, y#)
  1365.     FOR x# = -1# TO +1# STEP (1#/64#)
  1366.         y# = ASIN(x#)
  1367.         XgrDrawLineToScaled (graph, $$Yellow, x#, y#)
  1368.     NEXT x#
  1369. END SUB
  1370. '
  1371. SUB PlotACOS
  1372.     range$ = "-1 to +1"
  1373.     minimum$ = "-PI"
  1374.     maximum$ = "+PI"
  1375.     comment$ = "ACOS()"
  1376.     GOSUB DrawAxes
  1377.     XgrSetGridBoxScaled (graph, -1#, +$$PI, +1#, -$$PI)
  1378.     x# = -1#
  1379.     y# = ACOS (x#)
  1380.     XgrMoveToScaled (graph, x#, y#)
  1381.     FOR x# = -1# TO +1# STEP (1#/64#)
  1382.         y# = ACOS (x#)
  1383.         XgrDrawLineToScaled (graph, $$Yellow, x#, y#)
  1384.     NEXT x#
  1385. END SUB
  1386. '
  1387. SUB PlotATAN
  1388.     range$ = "-8 to +8"
  1389.     minimum$ = "-PI/2"
  1390.     maximum$ = "+PI/2"
  1391.     comment$ = "ATAN()"
  1392.     GOSUB DrawAxes
  1393.     XgrSetGridBoxScaled (graph, -8#, +$$PIDIV2, +8#, -$$PIDIV2)
  1394.     x# = -8#
  1395.     y# = ATAN (x#)
  1396.     XgrMoveToScaled (graph, x#, y#)
  1397.     FOR x# = -8# TO +8# STEP (1#/16#)
  1398.         y# = ATAN (x#)
  1399.         XgrDrawLineToScaled (graph, $$Yellow, x#, y#)
  1400.     NEXT x#
  1401. END SUB
  1402. '
  1403. SUB PlotACOT
  1404.     range$ = "-4 to +4"
  1405.     minimum$ = "-PI"
  1406.     maximum$ = "+PI"
  1407.     comment$ = "ACOT()"
  1408.     GOSUB DrawAxes
  1409.     XgrSetGridBoxScaled (graph, -4#, +$$PI, 4#, -$$PI)
  1410.     x# = -4#
  1411.     y# = ACOT (x#)
  1412.     XgrMoveToScaled (graph, x#, y#)
  1413.     FOR x# = -4# TO 4# STEP (1#/16#)
  1414.         y# = ACOT (x#)
  1415.         XgrDrawLineToScaled (graph, $$Yellow, x#, y#)
  1416.     NEXT x#
  1417. END SUB
  1418. '
  1419. SUB PlotASEC
  1420.     range$ = "-16 to -1 : +1 to +16"
  1421.     minimum$ = "-PI"
  1422.     maximum$ = "+PI"
  1423.     comment$ = "ASEC()"
  1424.     GOSUB DrawAxes
  1425.     XgrSetGridBoxScaled (graph, -16#, +$$PI, +16#, -$$PI)
  1426.     x# = -16#
  1427.     y# = ASEC (x#)
  1428.     XgrMoveToScaled (graph, x#, y#)
  1429.     FOR x# = -16# TO -1# STEP (.5#)
  1430.         y# = ASEC (x#)
  1431.         XgrDrawLineToScaled (graph, $$Yellow, x#, y#)
  1432.     NEXT x#
  1433.     x# = +1#
  1434.     y# = ASEC (x#)
  1435.     XgrMoveToScaled (graph, x#, y#)
  1436.     FOR x# = +1# TO +16# STEP (.5#)
  1437.         y# = ASEC (x#)
  1438.         XgrDrawLineToScaled (graph, $$Yellow, x#, y#)
  1439.     NEXT x#
  1440. END SUB
  1441. '
  1442. SUB PlotACSC
  1443.     range$ = "-16 to -1 : +1 to +16"
  1444.     minimum$ = "-PI"
  1445.     maximum$ = "+PI"
  1446.     comment$ = "ACSC()"
  1447.     GOSUB DrawAxes
  1448.     XgrSetGridBoxScaled (graph, -16#, +$$PI, +16#, -$$PI)
  1449.     x# = -16#
  1450.     y# = ACSC (x#)
  1451.     XgrMoveToScaled (graph, x#, y#)
  1452.     FOR x# = -16# TO -1# STEP (.5#)
  1453.         y# = ACSC (x#)
  1454.         XgrDrawLineToScaled (graph, $$Yellow, x#, y#)
  1455.     NEXT x#
  1456.     x# = +1#
  1457.     y# = ACSC (x#)
  1458.     XgrMoveToScaled (graph, x#, y#)
  1459.     FOR x# = +1# TO +16# STEP (.5#)
  1460.         y# = ACSC (x#)
  1461.         XgrDrawLineToScaled (graph, $$Yellow, x#, y#)
  1462.     NEXT x#
  1463. END SUB
  1464. '
  1465. '
  1466. ' *****  PlotSINH  *****
  1467. '
  1468. SUB PlotSINH
  1469.     range$ = "-2 to +2"
  1470.     minimum$ = "-2"
  1471.     maximum$ = "+2"
  1472.     comment$ = "SINH()"
  1473.     GOSUB DrawAxes
  1474.     XgrSetGridBoxScaled (graph, -2#, +2#, +2#, -2#)
  1475.     x# = -2#
  1476.     y# = SINH (x#)
  1477.     XgrMoveToScaled (graph, x#, y#)
  1478.     FOR x# = -2# TO +2# STEP (.0625#)
  1479.         y# = SINH (x#)
  1480.         XgrDrawLineToScaled (graph, $$Yellow, x#, y#)
  1481.     NEXT x#
  1482. END SUB
  1483. '
  1484. SUB PlotCOSH
  1485.     range$ = "-4 to +4"
  1486.     minimum$ = "-16"
  1487.     maximum$ = "+16"
  1488.     comment$ = "COSH()"
  1489.     GOSUB DrawAxes
  1490.     XgrSetGridBoxScaled (graph, -4#, +16#, +4#, -16#)
  1491.     x# = -4#
  1492.     y# = COSH (x#)
  1493.     XgrMoveToScaled (graph, x#, y#)
  1494.     FOR x# = -4# TO +4# STEP (.0625#)
  1495.         y# = COSH (x#)
  1496.         XgrDrawLineToScaled (graph, $$Yellow, x#, y#)
  1497.     NEXT x#
  1498. END SUB
  1499. '
  1500. SUB PlotTANH
  1501.     range$ = "-PI to +PI"
  1502.     minimum$ = "-1"
  1503.     maximum$ = "+1"
  1504.     comment$ = "TANH()"
  1505.     GOSUB DrawAxes
  1506.     XgrSetGridBoxScaled (graph, -$$PI, +1#, +$$PI, -1#)
  1507.     x# = -$$PI
  1508.     y# = TANH (x#)
  1509.     XgrMoveToScaled (graph, x#, y#)
  1510.     FOR x# = -$$PI TO +$$PI STEP ($$PI/64#)
  1511.         y# = TANH (x#)
  1512.         XgrDrawLineToScaled (graph, $$Yellow, x#, y#)
  1513.     NEXT x#
  1514. END SUB
  1515. '
  1516. SUB PlotCOTH
  1517.     range$ = "-2 to +2"
  1518.     minimum$ = "-16"
  1519.     maximum$ = "+16"
  1520.     comment$ = "COTH()"
  1521.     GOSUB DrawAxes
  1522.     XgrSetGridBoxScaled (graph, -2#, +16#, +2#, -16#)
  1523.     x# = -2#
  1524.     y# = COTH (x#)
  1525.     XgrMoveToScaled (graph, x#, y#)
  1526.     FOR x# = -2# TO -.01# STEP (.0625#)
  1527.         y# = COTH (x#)
  1528.         XgrDrawLineToScaled (graph, $$Yellow, x#, y#)
  1529.     NEXT x#
  1530.     x# = .01#
  1531.     y# = COTH (x#)
  1532.     XgrMoveToScaled (graph, x#, y#)
  1533.     FOR x# = .01# TO +2# STEP (.0625#)
  1534.         y# = COTH (x#)
  1535.         XgrDrawLineToScaled (graph, $$Yellow, x#, y#)
  1536.     NEXT x#
  1537. END SUB
  1538. '
  1539. SUB PlotSECH
  1540.     range$ = "-2PI to +2PI"
  1541.     minimum$ = "-1"
  1542.     maximum$ = "+1"
  1543.     comment$ = "SECH()"
  1544.     GOSUB DrawAxes
  1545.     XgrSetGridBoxScaled (graph, -$$TWOPI, 1#, $$TWOPI, -1#)
  1546.     x# = -$$TWOPI
  1547.     y# = SECH (x#)
  1548.     XgrMoveToScaled (graph, x#, y#)
  1549.     FOR x# = -$$TWOPI TO $$TWOPI STEP ($$PI/64#)
  1550.         y# = SECH (x#)
  1551.         XgrDrawLineToScaled (graph, $$Yellow, x#, y#)
  1552.     NEXT x#
  1553. END SUB
  1554. '
  1555. SUB PlotCSCH
  1556.     range$ = "-2 to +2"
  1557.     minimum$ = "-16"
  1558.     maximum$ = "+16"
  1559.     comment$ = "CSCH()"
  1560.     GOSUB DrawAxes
  1561.     XgrSetGridBoxScaled (graph, -2#, +16#, +2#, -16#)
  1562.     x# = -2#
  1563.     y# = CSCH (x#)
  1564.     XgrMoveToScaled (graph, x#, y#)
  1565.     FOR x# = -2# TO -.01# STEP (.0625#)
  1566.         y# = CSCH (x#)
  1567.         XgrDrawLineToScaled (graph, $$Yellow, x#, y#)
  1568.     NEXT x#
  1569.     x# = +.01#
  1570.     y# = CSCH (x#)
  1571.     XgrMoveToScaled (graph, x#, y#)
  1572.     FOR x# = .01# TO +2# STEP (.0625#)
  1573.         y# = CSCH (x#)
  1574.         XgrDrawLineToScaled (graph, $$Yellow, x#, y#)
  1575.     NEXT x#
  1576. END SUB
  1577. '
  1578. '
  1579. ' *****  PlotASINH  *****
  1580. '
  1581. SUB PlotASINH
  1582.     range$ = "-16 to +16"
  1583.     minimum$ = "-4"
  1584.     maximum$ = "+4"
  1585.     comment$ = "ASINH()"
  1586.     GOSUB DrawAxes
  1587.     XgrSetGridBoxScaled (graph, -16#, +4#, +16#, -4#)
  1588.     x# = -16#
  1589.     y# = ASINH (x#)
  1590.     XgrMoveToScaled (graph, x#, y#)
  1591.     FOR x# = -16# TO +16# STEP (.25#)
  1592.         y# = ASINH (x#)
  1593.         XgrDrawLineToScaled (graph, $$Yellow, x#, y#)
  1594.     NEXT x#
  1595. END SUB
  1596. '
  1597. SUB PlotACOSH
  1598.     range$ = "-16 to +16"
  1599.     minimum$ = "-4"
  1600.     maximum$ = "+4"
  1601.     comment$ = "ACOSH()"
  1602.     GOSUB DrawAxes
  1603.     XgrSetGridBoxScaled (graph, -16#, +4#, +16#, -4#)
  1604.     x# = +1#
  1605.     y# = ACOSH (x#)
  1606.     XgrMoveToScaled (graph, x#, y#)
  1607.     FOR x# = +1# TO +16# STEP (.25#)
  1608.         y# = ACOSH (x#)
  1609.         XgrDrawLineToScaled (graph, $$Yellow, x#, y#)
  1610.     NEXT x#
  1611. END SUB
  1612. '
  1613. SUB PlotATANH
  1614.     range$ = "-1 to +1"
  1615.     minimum$ = "-2"
  1616.     maximum$ = "+2"
  1617.     comment$ = "ATANH()"
  1618.     GOSUB DrawAxes
  1619.     XgrSetGridBoxScaled (graph, -1#, +2#, +1#, -2#)
  1620.     x# = -.99#
  1621.     y# = ATANH (x#)
  1622.     XgrMoveToScaled (graph, x#, y#)
  1623.     FOR x# = -.99# TO +.99# STEP (1#/64#)
  1624.         y# = ATANH (x#)
  1625.         XgrDrawLineToScaled (graph, $$Yellow, x#, y#)
  1626.     NEXT x#
  1627. END SUB
  1628. '
  1629. SUB PlotACOTH
  1630.     range$ = "-4 to +4"
  1631.     minimum$ = "-4"
  1632.     maximum$ = "+4"
  1633.     comment$ = "ACOTH()"
  1634.     GOSUB DrawAxes
  1635.     XgrSetGridBoxScaled (graph, -4#, +4#, +4#, -4#)
  1636.     x# = -4#
  1637.     y# = ACOTH (x#)
  1638.     XgrMoveToScaled (graph, x#, y#)
  1639.     FOR x# = -4# TO -1.01# STEP (.0625#)
  1640.         y# = ACOTH (x#)
  1641.         XgrDrawLineToScaled (graph, $$Yellow, x#, y#)
  1642.     NEXT x#
  1643.     x# = +1.01#
  1644.     y# = ACOTH (x#)
  1645.     XgrMoveToScaled (graph, x#, y#)
  1646.     FOR x# = +1.01# TO +4# STEP (.0625#)
  1647.         y# = ACOTH (x#)
  1648.         XgrDrawLineToScaled (graph, $$Yellow, x#, y#)
  1649.     NEXT x#
  1650. END SUB
  1651. '
  1652. SUB PlotASECH
  1653.     range$ = "-1 to +1"
  1654.     minimum$ = "-4"
  1655.     maximum$ = "+4"
  1656.     comment$ = "ASECH()"
  1657.     GOSUB DrawAxes
  1658.     XgrSetGridBoxScaled (graph, -1#, +4#, +1#, -4#)
  1659.     x# = .01#
  1660.     y# = ASECH (x#)
  1661.     XgrMoveToScaled (graph, x#, y#)
  1662.     FOR x# = .01# TO 1# STEP (.0625#)
  1663.         y# = ASECH (x#)
  1664.         XgrDrawLineToScaled (graph, $$Yellow, x#, y#)
  1665.     NEXT x#
  1666. END SUB
  1667. '
  1668. SUB PlotACSCH
  1669.     range$ = "-4 to +4"
  1670.     minimum$ = "-4"
  1671.     maximum$ = "+4"
  1672.     comment$ = "ACSCH()"
  1673.     GOSUB DrawAxes
  1674.     XgrSetGridBoxScaled (graph, -4#, +4#, +4#, -4#)
  1675.     x# = -4#
  1676.     y# = ACSCH (x#)
  1677.     XgrMoveToScaled (graph, x#, y#)
  1678.     FOR x# = -4# TO -.01# STEP (.0625#)
  1679.         y# = ACSCH (x#)
  1680.         XgrDrawLineToScaled (graph, $$Yellow, x#, y#)
  1681.     NEXT x#
  1682.     x# = .01#
  1683.     y# = ACSCH (x#)
  1684.     XgrMoveToScaled (graph, x#, y#)
  1685.     FOR x# = .01# TO +4# STEP (.0625#)
  1686.         y# = ACSCH (x#)
  1687.         XgrDrawLineToScaled (graph, $$Yellow, x#, y#)
  1688.     NEXT x#
  1689. END SUB
  1690. '
  1691. '
  1692. ' *****  PlotSQRT  *****
  1693. '
  1694. SUB PlotSQRT
  1695.     range$ = "-1 to +1"
  1696.     minimum$ = "-1"
  1697.     maximum$ = "+1"
  1698.     comment$ = "SQRT()"
  1699.     GOSUB DrawAxes
  1700.     XgrSetGridBoxScaled (graph, -1#, +1#, +1#, -1#)
  1701.     x# = 0#
  1702.     y# = SQRT (x#)
  1703.     XgrMoveToScaled (graph, x#, y#)
  1704.     FOR x# = 0# TO +1# STEP (1#/64#)
  1705.         y# = SQRT (x#)
  1706.         XgrDrawLineToScaled (graph, $$Yellow, x#, y#)
  1707.     NEXT x#
  1708. END SUB
  1709. '
  1710. SUB PlotPOWER
  1711.     range$ = "-2 to +2"
  1712.     minimum$ = "-4"
  1713.     maximum$ = "+4"
  1714.     comment$ = "x ** x  (x to the x)"
  1715.     GOSUB DrawAxes
  1716.     XgrSetGridBoxScaled (graph, -2#, +4#, +2#, -4#)
  1717.     x# = .01#
  1718.     y# = POWER (x#, x#)
  1719.     XgrMoveToScaled (graph, x#, y#)
  1720.     FOR x# = .01# TO +2# STEP (1#/64#)
  1721.         y# = POWER (x#, x#)
  1722.         XgrDrawLineToScaled (graph, $$Yellow, x#, y#)
  1723.     NEXT x#
  1724. END SUB
  1725. '
  1726. SUB PlotLOG
  1727.     range$ = "-4 to +4"
  1728.     minimum$ = "-4"
  1729.     maximum$ = "+4"
  1730.     comment$ = "LOG()"
  1731.     GOSUB DrawAxes
  1732.     XgrSetGridBoxScaled (graph, -4#, +4#, +4#, -4#)
  1733.     x# = .01#
  1734.     y# = LOG (x#)
  1735.     XgrMoveToScaled (graph, x#, y#)
  1736.     FOR x# = .01# TO +4# STEP (1#/64#)
  1737.         y# = LOG (x#)
  1738.         XgrDrawLineToScaled (graph, $$Yellow, x#, y#)
  1739.     NEXT x#
  1740. END SUB
  1741. '
  1742. SUB PlotEXP
  1743.     range$ = "-2 to +2"
  1744.     minimum$ = "-8"
  1745.     maximum$ = "+8"
  1746.     comment$ = "EXP()"
  1747.     GOSUB DrawAxes
  1748.     XgrSetGridBoxScaled (graph, -2#, +8#, +2#, -8#)
  1749.     x# = -2#
  1750.     y# = EXP (x#)
  1751.     XgrMoveToScaled (graph, x#, y#)
  1752.     FOR x# = -2# TO +2# STEP (1#/64#)
  1753.         y# = EXP (x#)
  1754.         XgrDrawLineToScaled (graph, $$Yellow, x#, y#)
  1755.     NEXT x#
  1756. END SUB
  1757. '
  1758. SUB PlotLOG10
  1759.     range$ = "-4 to +4"
  1760.     minimum$ = "-4"
  1761.     maximum$ = "+4"
  1762.     comment$ = "LOG10()"
  1763.     GOSUB DrawAxes
  1764.     XgrSetGridBoxScaled (graph, -4#, +4#, +4#, -4#)
  1765.     x# = .01#
  1766.     y# = LOG10 (x#)
  1767.     XgrMoveToScaled (graph, x#, y#)
  1768.     FOR x# = .01# TO +4# STEP (1#/64#)
  1769.         y# = LOG10 (x#)
  1770.         XgrDrawLineToScaled (graph, $$Yellow, x#, y#)
  1771.     NEXT x#
  1772. END SUB
  1773. '
  1774. SUB PlotEXP10
  1775.     range$ = "-1 to +1"
  1776.     minimum$ = "-4"
  1777.     maximum$ = "+4"
  1778.     comment$ = "EXP10()"
  1779.     GOSUB DrawAxes
  1780.     XgrSetGridBoxScaled (graph, -1#, +4#, +1#, -4#)
  1781.     x# = -1#
  1782.     y# = EXP10 (x#)
  1783.     XgrMoveToScaled (graph, x#, y#)
  1784.     FOR x# = -1# TO +1# STEP (1#/64#)
  1785.         y# = EXP10 (x#)
  1786.         XgrDrawLineToScaled (graph, $$Yellow, x#, y#)
  1787.     NEXT x#
  1788. END SUB
  1789. '
  1790. '
  1791. ' *****  Initialize  *****
  1792. '
  1793. SUB Initialize
  1794.     XuiSendMessage (grid, #GetGridNumber, @graph, 0, 0, 0, $Graph, 0)
  1795.     XgrSetGridClip (graph, graph)
  1796. END SUB
  1797. END FUNCTION
  1798. '
  1799. '
  1800. ' ########################
  1801. ' #####  Control ()  #####
  1802. ' ########################
  1803. '
  1804. FUNCTION  Control (grid, message, v0, v1, v2, v3, r0, (r1, r1$, r1[], r1$[]))
  1805.   STATIC  designX,  designY,  designWidth,  designHeight
  1806.   STATIC  SUBADDR  sub[]
  1807.   STATIC  upperMessage
  1808.   STATIC  Control
  1809.     SHARED    Circle
  1810.     SHARED    Math
  1811. '
  1812.   $Control     =  0  ' kid  0 grid type = Control
  1813.   $ShowCircle  =  1  ' kid  1 grid type = XuiPushButton
  1814.   $ShowMath    =  2  ' kid  2 grid type = XuiPushButton
  1815.   $UpperKid    =  2  ' kid maximum
  1816. '
  1817. '
  1818.   IFZ sub[] THEN GOSUB Initialize
  1819. ' XuiReportMessage (grid, message, v0, v1, v2, v3, r0, r1)
  1820.   IF XuiProcessMessage (grid, message, @v0, @v1, @v2, @v3, @r0, @r1, Control) THEN RETURN
  1821.   IF (message <= upperMessage) THEN GOSUB @sub[message]
  1822.   RETURN
  1823. '
  1824. '
  1825. ' *****  Callback  *****  message = Callback : r1 = original message
  1826. '
  1827. SUB Callback
  1828.   message = r1
  1829.   IF (message <= upperMessage) THEN GOSUB @sub[message]
  1830. END SUB
  1831. '
  1832. '
  1833. ' *****  Create  *****  v0123 = xywh : r0 = window : r1 = parent
  1834. '
  1835. SUB Create
  1836.   IF (v0 <= 0) THEN v0 = 0
  1837.   IF (v1 <= 0) THEN v1 = 0
  1838.   IF (v2 <= 0) THEN v2 = designWidth
  1839.   IF (v3 <= 0) THEN v3 = designHeight
  1840.   XuiCreateGrid (@grid, Control, @v0, @v1, @v2, @v3, r0, r1, &Control())
  1841.   XuiSendMessage (grid, #SetGridName, 0, 0, 0, 0, 0, @"Control")
  1842.   XuiPushButton (@g, #Create, 4, 4, 316, 112, r0, grid)
  1843.   XuiSendMessage (g, #SetCallback, grid, &Control(), -1, -1, $ShowCircle, grid)
  1844.   XuiSendMessage (g, #SetGridName, 0, 0, 0, 0, 0, @"ShowCircle")
  1845.   XuiSendMessage (g, #SetColor, 7, $$Black, $$Black, $$White, 0, 0)
  1846.   XuiSendMessage (g, #SetColorExtra, $$Cyan, 120, $$Black, 120, 0, 0)
  1847.   XuiSendMessage (g, #SetTexture, $$TextureShadow, 0, 0, 0, 0, 0)
  1848.   XuiSendMessage (g, #SetFont, 640, 400, 400, 0, 0, @"Roman")
  1849.   XuiSendMessage (g, #SetTextString, 0, 0, 0, 0, 0, @"Show Circle")
  1850.   XuiPushButton (@g, #Create, 4, 116, 316, 112, r0, grid)
  1851.   XuiSendMessage (g, #SetCallback, grid, &Control(), -1, -1, $ShowMath, grid)
  1852.   XuiSendMessage (g, #SetGridName, 0, 0, 0, 0, 0, @"ShowMath")
  1853.   XuiSendMessage (g, #SetColor, $$DarkCyan, $$Black, $$Black, $$White, 0, 0)
  1854.   XuiSendMessage (g, #SetColorExtra, $$Cyan, 120, $$Black, $$LightGreen, 0, 0)
  1855.   XuiSendMessage (g, #SetTexture, $$TextureShadow, 0, 0, 0, 0, 0)
  1856.   XuiSendMessage (g, #SetFont, 640, 400, 400, 0, 0, @"Serif")
  1857.   XuiSendMessage (g, #SetTextString, 0, 0, 0, 0, 0, @"Show Math")
  1858.   GOSUB Resize
  1859. END SUB
  1860. '
  1861. '
  1862. ' *****  CreateWindow  *****  v0123 = xywh : r0 = windowType : r1$ = display$
  1863. '
  1864. SUB CreateWindow
  1865.   IF (v0  = 0) THEN v0 = designX
  1866.   IF (v1  = 0) THEN v1 = designY
  1867.   IF (v2 <= 0) THEN v2 = designWidth
  1868.   IF (v3 <= 0) THEN v3 = designHeight
  1869.   XuiWindow (@window, #WindowCreate, v0, v1, v2, v3, r0, @r1$)
  1870.   v0 = 0 : v1 = 0 : r0 = window : ATTACH r1$ TO display$
  1871.   GOSUB Create
  1872.     r1 = 0 : ATTACH display$ TO r1$
  1873.   XuiWindow (window, #WindowRegister, grid, -1, v2, v3, @r0, @"Control")
  1874. END SUB
  1875. '
  1876. '
  1877. ' *****  GetSmallestSize  *****  See "Anatomy of Grid Functions"
  1878. '
  1879. SUB GetSmallestSize
  1880. END SUB
  1881. '
  1882. '
  1883. ' *****  Resize  *****  See "Anatomy of Grid Functions"
  1884. '
  1885. SUB Resize
  1886. END SUB
  1887. '
  1888. '
  1889. ' *****  Selection  *****  See "Anatomy of Grid Functions"
  1890. '
  1891. SUB Selection
  1892.   SELECT CASE r0
  1893.     CASE $Control     :
  1894.     CASE $ShowCircle  :    XuiSendMessage (Circle, #ShowWindow, 0, 0, 0, 0, 0, 0)
  1895.     CASE $ShowMath    : XuiSendMessage (Math, #ShowWindow, 0, 0, 0, 0, 0, 0)
  1896.   END SELECT
  1897. END SUB
  1898. '
  1899. '
  1900. ' *****  Initialize  *****  ' see "Anatomy of Grid Functions"
  1901. '
  1902. SUB Initialize
  1903.   XuiGetDefaultMessageFuncArray (@func[])
  1904.   XgrMessageNameToNumber (@"LastMessage", @upperMessage)
  1905. '
  1906.   func[#Callback]           = &XuiCallback ()               ' disable to handle Callback messages internally
  1907. ' func[#GetSmallestSize]    = 0                             ' enable to add internal GetSmallestSize routine
  1908. ' func[#Resize]             = 0                             ' enable to add internal Resize routine
  1909. '
  1910.   DIM sub[upperMessage]
  1911. ' sub[#Callback]            = SUBADDRESS (Callback)         ' enable to handle Callback messages internally
  1912.   sub[#Create]              = SUBADDRESS (Create)           ' must be internal routine
  1913.   sub[#CreateWindow]        = SUBADDRESS (CreateWindow)     ' must be internal routine
  1914. ' sub[#GetSmallestSize]     = SUBADDRESS (GetSmallestSize)  ' enable to add internal GetSmallestSize routine
  1915. ' sub[#Resize]              = SUBADDRESS (Resize)           ' enable to add internal Resize routine
  1916.   sub[#Selection]           = SUBADDRESS (Selection)        ' routes Selection callbacks to subroutine
  1917. '
  1918.   IF sub[0] THEN PRINT "Control(): Initialize: Error::: (Undefined Message)"
  1919.   IF func[0] THEN PRINT "Control(): Initialize: Error::: (Undefined Message)"
  1920.   XuiRegisterGridType (@Control, "Control", &Control(), @func[], @sub[])
  1921. '
  1922. ' Don't remove the following 4 lines, or WindowFromFunction/WindowToFunction will not work
  1923. '
  1924.   designX = 2000
  1925.   designY = 2000
  1926.   designWidth = 324
  1927.   designHeight = 232
  1928. '
  1929.   gridType = Control
  1930.   XuiSetGridTypeValue (gridType, @"x",                designX)
  1931.   XuiSetGridTypeValue (gridType, @"y",                designY)
  1932.   XuiSetGridTypeValue (gridType, @"width",            designWidth)
  1933.   XuiSetGridTypeValue (gridType, @"height",           designHeight)
  1934.   XuiSetGridTypeValue (gridType, @"maxWidth",         designWidth)
  1935.   XuiSetGridTypeValue (gridType, @"maxHeight",        designHeight)
  1936.   XuiSetGridTypeValue (gridType, @"minWidth",         designWidth)
  1937.   XuiSetGridTypeValue (gridType, @"minHeight",        designHeight)
  1938.   XuiSetGridTypeValue (gridType, @"border",           $$BorderFrame)
  1939.   XuiSetGridTypeValue (gridType, @"can",              $$Focus OR $$Respond OR $$Callback)
  1940.   XuiSetGridTypeValue (gridType, @"focusKid",         $ShowCircle)
  1941.   IFZ message THEN RETURN
  1942. END SUB
  1943. END FUNCTION
  1944. '
  1945. '
  1946. ' ############################
  1947. ' #####  ControlCode ()  #####
  1948. ' ############################
  1949. '
  1950. FUNCTION  ControlCode (grid, message, v0, v1, v2, v3, kid, r1)
  1951.     SHARED    Circle
  1952.     SHARED    Math
  1953.     STATIC    circle
  1954.     STATIC    math
  1955. '
  1956.   $Control     =  0  ' kid  0 grid type = Control
  1957.   $ShowCircle  =  1  ' kid  1 grid type = XuiPushButton
  1958.   $ShowMath    =  2  ' kid  2 grid type = XuiPushButton
  1959.   $UpperKid    =  2  ' kid maximum
  1960. '
  1961. '    XuiReportMessage (grid, message, v0, v1, v2, v3, kid, r1)
  1962.   IF (message = #Callback) THEN message = r1
  1963. '
  1964.   SELECT CASE message
  1965.         CASE #CloseWindow    :    GOSUB CloseWindow    ' close from system menu
  1966.     CASE #Selection        : GOSUB Selection   ' common callback message
  1967. '   CASE #TextEvent        : GOSUB TextEvent   ' KeyDown in TextArea or TextLine
  1968.   END SELECT
  1969.   RETURN
  1970. '
  1971. '
  1972. ' *****  CloseWindow  *****
  1973. '
  1974. SUB CloseWindow
  1975.     PRINT "ControlCode() : ignore CloseWindow from system menu"
  1976. END SUB
  1977. '
  1978. '
  1979. ' *****  Selection  *****
  1980. '
  1981. SUB Selection
  1982.   SELECT CASE kid
  1983.     CASE $Control     :
  1984.     CASE $ShowCircle  : grid = Circle
  1985.                                                 XgrGetGridWindow (grid, @window)
  1986.                                                 XgrGetWindowState (window, @state)
  1987.                                                 SELECT CASE state
  1988.                                                     CASE $$WindowHidden            : XuiSendMessage (grid, #ShowWindow, 0, 0, 0, 0, 0, 0)
  1989.                                                     CASE $$WindowDisplayed    : XuiSendMessage (grid, #HideWindow, 0, 0, 0, 0, 0, 0)
  1990.                                                     CASE $$WindowMaximized    : XuiSendMessage (grid, #HideWindow, 0, 0, 0, 0, 0, 0)
  1991.                                                     CASE $$WindowMinimized    : XuiSendMessage (grid, #ShowWindow, 0, 0, 0, 0, 0, 0)
  1992.                                                     CASE ELSE                                : XuiSendMessage (grid, #ShowWindow, 0, 0, 0, 0, 0, 0)
  1993.                                                 END SELECT
  1994.     CASE $ShowMath    : grid = Math
  1995.                                                 XgrGetGridWindow (grid, @window)
  1996.                                                 XgrGetWindowState (window, @state)
  1997.                                                 SELECT CASE state
  1998.                                                     CASE $$WindowHidden            : XuiSendMessage (grid, #ShowWindow, 0, 0, 0, 0, 0, 0)
  1999.                                                     CASE $$WindowDisplayed    : XuiSendMessage (grid, #HideWindow, 0, 0, 0, 0, 0, 0)
  2000.                                                     CASE $$WindowMaximized    : XuiSendMessage (grid, #HideWindow, 0, 0, 0, 0, 0, 0)
  2001.                                                     CASE $$WindowMinimized    : XuiSendMessage (grid, #ShowWindow, 0, 0, 0, 0, 0, 0)
  2002.                                                     CASE ELSE                                : XuiSendMessage (grid, #ShowWindow, 0, 0, 0, 0, 0, 0)
  2003.                                                 END SELECT
  2004.   END SELECT
  2005. END SUB
  2006. END FUNCTION
  2007. END PROGRAM
  2008.