home *** CD-ROM | disk | FTP | other *** search
/ Liren Large Software Subsidy 9 / 09.iso / l / l196 / 3.ddi / CHRTDEM1.BA$ / CHRTDEM1.bin
Encoding:
Text File  |  1990-06-24  |  42.4 KB  |  1,118 lines

  1. '       CHRTDEM1.BAS - second module of the CHRTB demonstration program.
  2. '
  3. '               Copyright (C) 1989-1990, Microsoft Corporation
  4. '
  5. '   Main module - CHRTDEMO.BAS
  6. '   Include files - CHRTDEMO.BI
  7. '
  8. '$INCLUDE: 'chrtdemo.bi'
  9.  
  10. 'local subs
  11. DECLARE SUB ChangeStyle ()
  12.  
  13. DEFINT A-Z
  14. '
  15. ' Sub Name: ChangeAxis
  16. '
  17. ' Description: Allows user to view and change attributes of either
  18. '              chart axis.
  19. '
  20. ' Arguments: title$ - window title
  21. '            axis - X or Y axis variable
  22. '
  23. SUB ChangeAxis (title$, axis AS AxisType)
  24.  
  25.     DIM colorBox AS ListBox
  26.     DIM styleBox AS ListBox
  27.     DIM fontBox AS ListBox
  28.  
  29.     ' set up color list box
  30.     colorBox.scrollButton = 2
  31.     colorBox.areaButton = 3
  32.     colorBox.listLen = numColors
  33.     colorBox.topRow = 3
  34.     colorBox.botRow = 16
  35.     colorBox.leftCol = 4
  36.     colorBox.rightCol = 18
  37.     colorBox.listPos = axis.AxisColor + 1
  38.  
  39.     ' set up border style list box
  40.     styleBox.scrollButton = 5
  41.     styleBox.areaButton = 6
  42.     styleBox.listLen = MAXSTYLES
  43.     styleBox.topRow = 5
  44.     styleBox.botRow = 16
  45.     styleBox.leftCol = 24
  46.     styleBox.rightCol = 40
  47.     styleBox.listPos = axis.GridStyle
  48.  
  49.     ' set up font list box
  50.     fontBox.scrollButton = 8
  51.     fontBox.areaButton = 9
  52.     fontBox.listLen = numFonts
  53.     fontBox.topRow = 5
  54.     fontBox.botRow = 9
  55.     fontBox.leftCol = 46
  56.     fontBox.rightCol = 65
  57.     fontBox.listPos = axis.TicFont
  58.  
  59.     ' open window for display
  60.     winRow = 4
  61.     winCol = 6
  62.     WindowOpen 1, winRow, winCol, 22, 73, 0, 7, 0, 7, 15, FALSE, FALSE, FALSE, TRUE, 2, title$
  63.     WindowBox 1, 2, 17, 20
  64.     WindowLocate 2, 4
  65.     WindowPrint 2, "Axis Color:"
  66.     WindowBox 1, 22, 17, 42
  67.     WindowLocate 4, 24
  68.     WindowPrint 2, "Grid Style:"
  69.     WindowBox 1, 44, 17, 67
  70.     WindowLocate 4, 46
  71.     WindowPrint 2, "Label Font:"
  72.     WindowLocate 10, 46
  73.     WindowPrint 2, "Range Type:"
  74.     WindowBox 11, 46, 16, 65
  75.     WindowLocate 14, 48
  76.     WindowPrint 2, "Log Base:"
  77.     WindowBox 13, 57, 15, 63
  78.     WindowLine 18
  79.  
  80.     ' create list boxes
  81.     CreateListBox colors$(), colorBox, 0
  82.     CreateListBox styles$(), styleBox, 0
  83.     CreateListBox fonts$(), fontBox, 0
  84.  
  85.     ' open control buttons
  86.     ButtonOpen 4, 1, "Display Grid", 2, 24, 0, 0, 2
  87.     ButtonOpen 7, 1, "Display Labels", 2, 46, 0, 0, 2
  88.     ButtonOpen 10, 1, "Lin", 12, 48, 0, 0, 3
  89.     ButtonOpen 11, 1, "Log", 12, 57, 0, 0, 3
  90.     ButtonOpen 12, 2, "OK ", 19, 10, 0, 0, 1
  91.     ButtonOpen 13, 1, "Cancel ", 19, 26, 0, 0, 1
  92.     ButtonOpen 14, 1, "Axis Title ", 19, 46, 0, 0, 1
  93.  
  94.     ' edit field for log base
  95.     EditFieldOpen 1, LTRIM$(STR$(axis.LogBase)), 14, 58, 0, 7, 5, 20
  96.  
  97.     
  98.     currButton = 3                                      ' start with cursor on first button (Autoscale)
  99.     currEditField = 0
  100.  
  101.     optionButton = axis.RangeType + 9                   ' set proper state for buttons
  102.     ButtonToggle optionButton
  103.     IF axis.Labeled THEN ButtonToggle 7
  104.     IF axis.Grid THEN ButtonToggle 4
  105.  
  106.     pushButton = 12                                     ' active command button
  107.  
  108.     ' window control loop
  109.     finished = FALSE
  110.     WHILE NOT finished
  111.         WindowDo currButton, currEditField              ' wait for event
  112.         SELECT CASE Dialog(0)
  113.             CASE 1                                      ' button pressed
  114.                 currButton = Dialog(1)
  115.                 SELECT CASE currButton
  116.                     CASE 4, 7
  117.                         ButtonToggle currButton
  118.                         currEditField = 0
  119.                     CASE 10, 11
  120.                         ButtonToggle optionButton
  121.                         optionButton = currButton
  122.                         ButtonToggle optionButton
  123.                         currEditField = 0
  124.                     CASE 2, 3
  125.                         currEditField = 0
  126.                         ScrollList colors$(), colorBox, currButton, 1, 0, winRow, winCol
  127.                         currButton = 3
  128.                     CASE 5, 6
  129.                         currEditField = 0
  130.                         ScrollList styles$(), styleBox, currButton, 1, 0, winRow, winCol
  131.                         currButton = 6
  132.                     CASE 8, 9
  133.                         currEditField = 0
  134.                         ScrollList fonts$(), fontBox, currButton, 1, 0, winRow, winCol
  135.                         currButton = 9
  136.                     CASE 12, 13
  137.                         pushButton = currButton
  138.                         finished = TRUE
  139.                     CASE 14
  140.                         currEditField = 0
  141.                         ButtonSetState pushButton, 1
  142.                         ButtonSetState currButton, 2
  143.                         pushButton = currButton
  144.                         ChangeTitle 2, title$ + " Title", axis.AxisTitle, 6, 14
  145.                 END SELECT
  146.             CASE 2                                      ' edit field
  147.                 currEditField = 1
  148.                 currButton = 0
  149.             CASE 6                                      ' enter
  150.                 SELECT CASE pushButton
  151.                     CASE 12, 13: finished = TRUE
  152.                     CASE 14: ChangeTitle 2, title$ + " Title", axis.AxisTitle, 6, 14
  153.                 END SELECT
  154.                 currButton = pushButton
  155.             CASE 7                                      ' tab
  156.                 SELECT CASE currButton
  157.                     CASE 0:
  158.                         currEditField = 0
  159.                         currButton = 12
  160.                         ButtonSetState pushButton, 1
  161.                         ButtonSetState currButton, 2
  162.                         pushButton = currButton
  163.                     CASE 2, 3: currButton = 4
  164.                     CASE 4: currButton = 6
  165.                     CASE 5, 6: currButton = 7
  166.                     CASE 7: currButton = 9
  167.                     CASE 8, 9: currButton = optionButton
  168.                     CASE 10, 11:
  169.                         currButton = 0
  170.                         currEditField = 1
  171.                     CASE 12, 13:
  172.                         currButton = currButton + 1
  173.                         ButtonSetState pushButton, 1
  174.                         ButtonSetState currButton, 2
  175.                         pushButton = currButton
  176.                     CASE 14:
  177.                         ButtonSetState currButton, 1
  178.                         pushButton = 12
  179.                         ButtonSetState pushButton, 2
  180.                         currButton = 3
  181.                 END SELECT
  182.             CASE 8                                      ' back tab
  183.                 SELECT CASE currButton
  184.                     CASE 0:
  185.                         currEditField = 0
  186.                         currButton = optionButton
  187.                     CASE 2, 3:
  188.                         currButton = 14
  189.                         ButtonSetState pushButton, 1
  190.                         ButtonSetState currButton, 2
  191.                         pushButton = currButton
  192.                     CASE 4: currButton = 3
  193.                     CASE 5, 6: currButton = 4
  194.                     CASE 7: currButton = 6
  195.                     CASE 8, 9: currButton = 7
  196.                     CASE 10, 11: currButton = 9
  197.                     CASE 12:
  198.                         currButton = 0
  199.                         currEditField = 1
  200.                     CASE 13, 14:
  201.                         currButton = currButton - 1
  202.                         ButtonSetState pushButton, 1
  203.                         ButtonSetState currButton, 2
  204.                         pushButton = currButton
  205.                 END SELECT
  206.             CASE 9                                      ' escape
  207.                 pushButton = 13
  208.                 finished = TRUE
  209.             CASE 10, 12                                 ' up, left arrow
  210.                 SELECT CASE currButton
  211.                     CASE 4, 7: ButtonSetState currButton, 2
  212.                     CASE 2, 3: ScrollList colors$(), colorBox, currButton, 2, 0, winRow, winCol
  213.                     CASE 5, 6: ScrollList styles$(), styleBox, currButton, 2, 0, winRow, winCol
  214.                     CASE 8, 9: ScrollList fonts$(), fontBox, currButton, 2, 0, winRow, winCol
  215.                     CASE 10, 11:
  216.                         ButtonToggle currButton
  217.                         currButton = 21 - currButton
  218.                         optionButton = currButton
  219.                         ButtonToggle optionButton
  220.                 END SELECT
  221.             CASE 11, 13                                 ' down, right arrow
  222.                 SELECT CASE currButton
  223.                     CASE 1, 4, 7: ButtonSetState currButton, 1
  224.                     CASE 2, 3: ScrollList colors$(), colorBox, currButton, 3, 0, winRow, winCol
  225.                     CASE 5, 6: ScrollList styles$(), styleBox, currButton, 3, 0, winRow, winCol
  226.                     CASE 8, 9: ScrollList fonts$(), fontBox, currButton, 3, 0, winRow, winCol
  227.                     CASE 10, 11:
  228.                         ButtonToggle currButton
  229.                         currButton = 21 - currButton
  230.                         optionButton = currButton
  231.                         ButtonToggle optionButton
  232.                 END SELECT
  233.             CASE 14                                     ' space bar
  234.                 SELECT CASE currButton
  235.                     CASE 1, 4, 7: ButtonToggle currButton
  236.                     CASE 12, 13: finished = TRUE
  237.                     CASE 14: ChangeTitle 2, title$ + " Title", axis.AxisTitle, 6, 14
  238.                 END SELECT
  239.         END SELECT
  240.  
  241.         ' error checking on log base before exiting
  242.         IF finished AND pushButton = 12 THEN
  243.             IF VAL(EditFieldInquire(1)) <= 0 THEN
  244.                 PrintError " Log base must be greater than zero."
  245.                 currEditField = 1
  246.                 currButton = 0
  247.                 finished = FALSE
  248.             ELSEIF VAL(EditFieldInquire(1)) = 1 THEN
  249.                 PrintError " Log base cannot equal one. Overflow results."
  250.                 currEditField = 1
  251.                 currButton = 0
  252.                 finished = FALSE
  253.             END IF
  254.         END IF
  255.     WEND
  256.  
  257.     ' if not canceled then assign and return new values
  258.     IF pushButton = 12 THEN
  259.         IF setNum > 0 THEN chartChanged = TRUE
  260.  
  261.         axis.LogBase = VAL(EditFieldInquire(1))
  262.         axis.Grid = (ButtonInquire(4) = 2)
  263.         axis.Labeled = (ButtonInquire(7) = 2)
  264.         axis.RangeType = optionButton - 9
  265.         axis.AxisColor = colorBox.listPos - 1
  266.         axis.ScaleTitle.TitleColor = axis.AxisTitle.TitleColor
  267.         axis.ScaleTitle.Justify = axis.AxisTitle.Justify
  268.         axis.GridStyle = styleBox.listPos
  269.         axis.TicFont = fontBox.listPos
  270.     END IF
  271.  
  272.     WindowClose 1
  273.  
  274. END SUB
  275.  
  276. '
  277. ' Sub Name: ChangeChartType
  278. '
  279. ' Description: Changes chart type based on menu selection and
  280. '              allows the user access to changing the chart style.
  281. '
  282. ' Arguments: ctype - new chart type
  283. '
  284. SUB ChangeChartType (ctype)
  285.  
  286.     'change type if user selected a different type
  287.     IF CEnv.ChartType <> ctype THEN
  288.         IF setNum > 0 THEN chartChanged = TRUE
  289.  
  290.         ' reset chosen type
  291.         MenuItemToggle GALLERYTITLE, CEnv.ChartType
  292.         ' reset other affected menu items
  293.         IF CEnv.ChartType = cPie THEN
  294.             MenuSetState CHARTTITLE, 4, 1
  295.             MenuSetState CHARTTITLE, 5, 1
  296.             MenuSetState TITLETITLE, 3, 1
  297.             MenuSetState TITLETITLE, 4, 1
  298.         END IF
  299.  
  300.         CEnv.ChartType = ctype
  301.  
  302.         'if new type is pie then turn off some items
  303.         IF CEnv.ChartType = cPie THEN
  304.             MenuSetState CHARTTITLE, 4, 0
  305.             MenuSetState CHARTTITLE, 5, 0
  306.             MenuSetState TITLETITLE, 3, 0
  307.             MenuSetState TITLETITLE, 4, 0
  308.         END IF
  309.  
  310.         ' set type in menu bar
  311.         MenuItemToggle GALLERYTITLE, CEnv.ChartType
  312.     END IF
  313.  
  314.     ' allow user to change chart style
  315.     ChangeStyle
  316.  
  317. END SUB
  318.  
  319. '
  320. ' Sub Name: ChangeLegend
  321. '
  322. ' Description: Allows user to view and modify all attributes of the chart
  323. '              legend
  324. '
  325. ' Arguments: none
  326. '
  327. SUB ChangeLegend
  328.  
  329.     DIM fgColorBox AS ListBox
  330.     DIM fontBox AS ListBox
  331.  
  332.     ' set up foreground color box
  333.     fgColorBox.scrollButton = 6
  334.     fgColorBox.areaButton = 7
  335.     fgColorBox.listLen = numColors
  336.     fgColorBox.topRow = 3
  337.     fgColorBox.botRow = 10
  338.     fgColorBox.leftCol = 27
  339.     fgColorBox.rightCol = 41
  340.     fgColorBox.listPos = CEnv.Legend.TextColor + 1
  341.  
  342.     ' set up font box
  343.     fontBox.scrollButton = 8
  344.     fontBox.areaButton = 9
  345.     fontBox.listLen = numFonts
  346.     fontBox.topRow = 3
  347.     fontBox.botRow = 10
  348.     fontBox.leftCol = 43
  349.     fontBox.rightCol = 57
  350.     fontBox.listPos = CEnv.Legend.TextFont
  351.  
  352.     ' set up display window
  353.     winRow = 6
  354.     winCol = 10
  355.     WindowOpen 1, winRow, winCol, 18, 69, 0, 7, 0, 7, 15, FALSE, FALSE, FALSE, TRUE, 2, "Chart Legend"
  356.     WindowBox 1, 2, 11, 23
  357.     WindowLocate 5, 4
  358.     WindowPrint 2, "Location:"
  359.     WindowBox 6, 4, 10, 21
  360.     WindowBox 1, 25, 11, 59
  361.     WindowLocate 2, 27
  362.     WindowPrint 2, "Text Color:"
  363.     WindowLocate 2, 43
  364.     WindowPrint 2, "Text Font:"
  365.     WindowLine 12
  366.  
  367.     ' create list boxes
  368.     CreateListBox colors$(), fgColorBox, 0
  369.     CreateListBox fonts$(), fontBox, 0
  370.  
  371.     ' open command buttons
  372.     ButtonOpen 1, 1, "Display Legend", 2, 4, 0, 0, 2
  373.     ButtonOpen 2, 1, "Autosize", 3, 4, 0, 0, 2
  374.     ButtonOpen 3, 1, "Overlay", 7, 6, 0, 0, 3
  375.     ButtonOpen 4, 1, "Bottom", 8, 6, 0, 0, 3
  376.     ButtonOpen 5, 1, "Right", 9, 6, 0, 0, 3
  377.     ButtonOpen 10, 2, "OK ", 13, 8, 0, 0, 1
  378.     ButtonOpen 11, 1, "Cancel ", 13, 21, 0, 0, 1
  379.     ButtonOpen 12, 1, "Legend Window ", 13, 38, 0, 0, 1
  380.  
  381.     currButton = 1                                      ' start with cursor on first button
  382.  
  383.     ' set button states based on current values
  384.     optionButton = CEnv.Legend.Place + 2
  385.     ButtonToggle optionButton
  386.     IF CEnv.Legend.Legend THEN ButtonToggle 1
  387.     IF CEnv.Legend.AutoSize THEN ButtonToggle 2
  388.     pushButton = 10
  389.  
  390.     ' window control loop
  391.     finished = FALSE
  392.     WHILE NOT finished
  393.         WindowDo currButton, 0                          ' wait for event
  394.         SELECT CASE Dialog(0)
  395.             CASE 1                                      ' button pressed
  396.                 currButton = Dialog(1)
  397.                 SELECT CASE currButton
  398.                     CASE 1, 2: ButtonToggle currButton
  399.                     CASE 3, 4, 5
  400.                         ButtonToggle optionButton
  401.                         optionButton = currButton
  402.                         ButtonToggle optionButton
  403.                     CASE 6, 7:
  404.                         ScrollList colors$(), fgColorBox, currButton, 1, 0, winRow, winCol
  405.                         currButton = 7
  406.                     CASE 8, 9:
  407.                         ScrollList fonts$(), fontBox, currButton, 1, 0, winRow, winCol
  408.                         currButton = 9
  409.                     CASE 10, 11
  410.                         pushButton = currButton
  411.                         finished = TRUE
  412.                     CASE 12
  413.                         ButtonSetState pushButton, 1
  414.                         ButtonSetState currButton, 2
  415.                         pushButton = 12
  416.                         ChangeWindow 2, "Legend Window", CEnv.Legend.LegendWindow
  417.                 END SELECT
  418.             CASE 6                                      ' enter
  419.                 IF pushButton <> 12 THEN
  420.                     finished = TRUE
  421.                 ELSE
  422.                     ChangeWindow 2, "Legend Window", CEnv.Legend.LegendWindow
  423.                 END IF
  424.             CASE 7                                      ' tab
  425.                 SELECT CASE currButton
  426.                     CASE 1: currButton = 2
  427.                     CASE 2: currButton = optionButton
  428.                     CASE 3, 4, 5: currButton = 7
  429.                     CASE 6, 7: currButton = 9
  430.                     CASE 8, 9:
  431.                         currButton = 10
  432.                         ButtonSetState pushButton, 1
  433.                         ButtonSetState currButton, 2
  434.                         pushButton = currButton
  435.                     CASE 10, 11:
  436.                         currButton = currButton + 1
  437.                         ButtonSetState pushButton, 1
  438.                         ButtonSetState currButton, 2
  439.                         pushButton = currButton
  440.                     CASE 12:
  441.                         ButtonSetState currButton, 1
  442.                         pushButton = 10
  443.                         ButtonSetState pushButton, 2
  444.                         currButton = 1
  445.                 END SELECT
  446.             CASE 8                                      ' back tab
  447.                 SELECT CASE currButton
  448.                     CASE 1:
  449.                         currButton = 12
  450.                         ButtonSetState pushButton, 1
  451.                         ButtonSetState currButton, 2
  452.                         pushButton = currButton
  453.                     CASE 2: currButton = 1
  454.                     CASE 3, 4, 5: currButton = 2
  455.                     CASE 6, 7: currButton = optionButton
  456.                     CASE 8, 9: currButton = 7
  457.                     CASE 10: currButton = 9
  458.                     CASE 11, 12:
  459.                         currButton = currButton - 1
  460.                         ButtonSetState pushButton, 1
  461.                         ButtonSetState currButton, 2
  462.                         pushButton = currButton
  463.                 END SELECT
  464.             CASE 9                                      ' escape
  465.                 pushButton = 11
  466.                 finished = TRUE
  467.             CASE 10, 12                                 ' up, left arrow
  468.                 SELECT CASE currButton
  469.                     CASE 1, 2: ButtonSetState currButton, 2
  470.                     CASE 3:
  471.                         ButtonToggle currButton
  472.                         currButton = 5
  473.                         optionButton = currButton
  474.                         ButtonToggle optionButton
  475.                     CASE 4, 5:
  476.                         ButtonToggle currButton
  477.                         currButton = currButton - 1
  478.                         optionButton = currButton
  479.                         ButtonToggle optionButton
  480.                     CASE 6, 7: ScrollList colors$(), fgColorBox, currButton, 2, 0, winRow, winCol
  481.                     CASE 8, 9: ScrollList fonts$(), fontBox, currButton, 2, 0, winRow, winCol
  482.                 END SELECT
  483.             CASE 11, 13                                 ' down, right arrow
  484.                 SELECT CASE currButton
  485.                     CASE 1, 2: ButtonSetState currButton, 1
  486.                     CASE 3, 4:
  487.                         ButtonToggle currButton
  488.                         currButton = currButton + 1
  489.                         optionButton = currButton
  490.                         ButtonToggle optionButton
  491.                     CASE 5:
  492.                         ButtonToggle currButton
  493.                         currButton = 3
  494.                         optionButton = currButton
  495.                         ButtonToggle optionButton
  496.                     CASE 6, 7: ScrollList colors$(), fgColorBox, currButton, 3, 0, winRow, winCol
  497.                     CASE 8, 9: ScrollList fonts$(), fontBox, currButton, 3, 0, winRow, winCol
  498.                 END SELECT
  499.             CASE 14                                     ' space bar
  500.                 SELECT CASE currButton
  501.                     CASE 1, 2: ButtonToggle currButton
  502.                     CASE 10, 11: finished = TRUE
  503.                     CASE 12: ChangeWindow 2, "Legend Window", CEnv.Legend.LegendWindow
  504.                END SELECT
  505.         END SELECT
  506.     WEND
  507.  
  508.     ' if not canceled then return the new values
  509.     IF pushButton = 10 THEN
  510.         IF setNum > 0 THEN chartChanged = TRUE
  511.  
  512.         CEnv.Legend.TextColor = fgColorBox.listPos - 1
  513.         CEnv.Legend.TextFont = fontBox.listPos
  514.         CEnv.Legend.AutoSize = (ButtonInquire(2) = 2)
  515.         CEnv.Legend.Legend = (ButtonInquire(1) = 2)
  516.         CEnv.Legend.Place = optionButton - 2
  517.     END IF
  518.  
  519.     WindowClose 1
  520.  
  521. END SUB
  522.  
  523. '
  524. ' Sub Name: ChangeStyle
  525. '
  526. ' Description: Allows user to view and modify the chart style
  527. '
  528. ' Arguments: none
  529. '
  530. SUB ChangeStyle
  531. DIM fontBox AS ListBox
  532.  
  533.     ' determine button labels based on chart type
  534.     SELECT CASE CEnv.ChartType
  535.         CASE cBar, cColumn
  536.             style1$ = "Adjacent"
  537.             style2$ = "Stacked"
  538.         CASE cLine, cScatter
  539.             style1$ = "Lines"
  540.             style2$ = "No Lines"
  541.         CASE cPie
  542.             style1$ = "Percentages"
  543.             style2$ = "No Percentages"
  544.     END SELECT
  545.  
  546.     topRow = 8
  547.     leftCol = 26
  548.     ' if pie, line or scatter chart then add data font
  549.     IF CEnv.ChartType > 2 THEN
  550.         WindowOpen 1, topRow, leftCol, 19, 47, 0, 7, 0, 7, 15, FALSE, FALSE, FALSE, TRUE, 2, "Chart Style"
  551.         okLine = 12
  552.  
  553.         WindowLocate 5, 3
  554.         WindowPrint -2, "Data Font:"
  555.         ' set up list box containing valid fonts
  556.         fontBox.scrollButton = 3
  557.         fontBox.areaButton = 4
  558.         fontBox.listLen = numFonts
  559.         fontBox.topRow = 6
  560.         fontBox.botRow = 10
  561.         fontBox.leftCol = 3
  562.         fontBox.rightCol = 20
  563.         fontBox.listPos = CEnv.DataFont
  564.         CreateListBox fonts$(), fontBox, 0
  565.     ELSE
  566.         WindowOpen 1, topRow, leftCol, 13, 47, 0, 7, 0, 7, 15, FALSE, FALSE, FALSE, TRUE, 2, "Chart Style"
  567.         okLine = 6
  568.     END IF
  569.  
  570.     ' open buttons
  571.     ButtonOpen 1, 1, style1$, 2, 3, 1, 0, 3
  572.     ButtonOpen 2, 1, style2$, 3, 3, 1, 0, 3
  573.     WindowLine okLine - 1
  574.     ButtonOpen 5, 2, "OK", okLine, 3, 1, 0, 1
  575.     ButtonOpen 6, 1, "Cancel", okLine, 11, 1, 0, 1
  576.  
  577.     pushButton = 5
  578.     optionButton = CEnv.ChartStyle                     ' set current style
  579.     currButton = optionButton
  580.     ButtonSetState optionButton, 2
  581.  
  582.     ' window control loop
  583.     finished = FALSE
  584.     WHILE NOT finished
  585.         WindowDo currButton, 0                          ' wait for event
  586.         SELECT CASE Dialog(0)
  587.             CASE 1                                      'button pressed
  588.                 currButton = Dialog(1)
  589.                 SELECT CASE currButton
  590.                     CASE 1, 2:
  591.                         ButtonSetState optionButton, 1
  592.                         optionButton = currButton
  593.                         ButtonSetState optionButton, 2
  594.                     CASE 3, 4:
  595.                         ScrollList fonts$(), fontBox, currButton, 1, 0, topRow, leftCol
  596.                         currButton = 4
  597.                     CASE 5, 6:
  598.                         finished = TRUE
  599.                 END SELECT
  600.             CASE 6                                      'enter
  601.                 finished = TRUE
  602.             CASE 7                                      'tab
  603.                 SELECT CASE currButton
  604.                     CASE 1, 2:
  605.                         IF CEnv.ChartType > 2 THEN
  606.                             currButton = 4
  607.                         ELSE
  608.                             currButton = 5
  609.                             ButtonSetState pushButton, 1
  610.                             pushButton = currButton
  611.                             ButtonSetState pushButton, 2
  612.                         END IF
  613.                     CASE 3, 4:
  614.                         currButton = 5
  615.                         ButtonSetState pushButton, 1
  616.                         pushButton = currButton
  617.                         ButtonSetState currButton, 2
  618.                     CASE 5:
  619.                         currButton = 6
  620.                         ButtonSetState pushButton, 1
  621.                         pushButton = currButton
  622.                         ButtonSetState currButton, 2
  623.                     CASE 6:
  624.                         currButton = optionButton
  625.                         ButtonSetState pushButton, 1
  626.                         pushButton = 5
  627.                         ButtonSetState pushButton, 2
  628.                 END SELECT
  629.             CASE 8                                      'back tab
  630.                 SELECT CASE currButton
  631.                     CASE 1, 2:
  632.                         currButton = 6
  633.                         ButtonSetState pushButton, 1
  634.                         pushButton = currButton
  635.                         ButtonSetState pushButton, 2
  636.                     CASE 3, 4:
  637.                         currButton = optionButton
  638.                     CASE 5:
  639.                         IF CEnv.ChartType > 2 THEN
  640.                             currButton = 4
  641.                         ELSE
  642.                             currButton = optionButton
  643.                         END IF
  644.                     CASE 6:
  645.                         currButton = 5
  646.                         ButtonSetState pushButton, 1
  647.                         pushButton = currButton
  648.                         ButtonSetState currButton, 2
  649.                 END SELECT
  650.             CASE 9                                      'escape
  651.                 finished = TRUE
  652.                 pushButton = 5
  653.             CASE 10, 12                                 'up, left arrow
  654.                 SELECT CASE currButton
  655.                     CASE 1, 2:
  656.                         ButtonSetState currButton, 1
  657.                         currButton = 3 - currButton
  658.                         optionButton = currButton
  659.                         ButtonSetState currButton, 2
  660.                     CASE 3, 4:
  661.                         ScrollList fonts$(), fontBox, currButton, 2, 0, topRow, leftCol
  662.                 END SELECT
  663.             CASE 11, 13                                 'down, right arrow
  664.                 SELECT CASE currButton
  665.                     CASE 1, 2:
  666.                         ButtonSetState currButton, 1
  667.                         currButton = 3 - currButton
  668.                         optionButton = currButton
  669.                         ButtonSetState currButton, 2
  670.                     CASE 3, 4:
  671.                         ScrollList fonts$(), fontBox, currButton, 3, 0, topRow, leftCol
  672.                 END SELECT
  673.             CASE 14                                     'space bar
  674.                 IF currButton > 4 THEN finished = TRUE
  675.         END SELECT
  676.     WEND
  677.  
  678.     ' if not canceled then set new chart style
  679.     IF pushButton = 5 THEN
  680.         IF setNum > 0 THEN chartChanged = TRUE
  681.         CEnv.ChartStyle = optionButton
  682.         IF CEnv.ChartType > 2 THEN CEnv.DataFont = fontBox.listPos
  683.     END IF
  684.  
  685.     WindowClose 1
  686.  
  687. END SUB
  688.  
  689. '
  690. ' Sub Name: ChangeTitle
  691. '
  692. ' Description: Allows user to view and modify the chart titles
  693. '
  694. ' Arguments: handle - window number
  695. '            wTitle$ - window title
  696. '            title -  chart title
  697. '            topRow - top row of window
  698. '            leftCol - left column of window
  699. '
  700. SUB ChangeTitle (handle, wTitle$, title AS TitleType, topRow, leftCol)
  701. SHARED mode$(), numModes AS INTEGER
  702.  
  703.     DIM colorBox AS ListBox
  704.     DIM fontBox AS ListBox
  705.  
  706.     ' set up foreground color box
  707.     colorBox.scrollButton = 1
  708.     colorBox.areaButton = 2
  709.     colorBox.listLen = numColors
  710.     colorBox.topRow = 6
  711.     colorBox.botRow = 10
  712.     colorBox.leftCol = 2
  713.     colorBox.rightCol = 16
  714.     colorBox.listPos = title.TitleColor + 1
  715.  
  716.     ' set up font box
  717.     fontBox.scrollButton = 3
  718.     fontBox.areaButton = 4
  719.     fontBox.listLen = numFonts
  720.     fontBox.topRow = 6
  721.     fontBox.botRow = 10
  722.     fontBox.leftCol = 18
  723.     fontBox.rightCol = 36
  724.     fontBox.listPos = title.TitleFont
  725.  
  726.     ' set up display window
  727.     WindowOpen handle, topRow, leftCol, topRow + 11, leftCol + 50, 0, 7, 0, 7, 15, FALSE, FALSE, FALSE, TRUE, 2, wTitle$
  728.     WindowLocate 2, 2
  729.     WindowPrint 2, "Title:"
  730.     WindowBox 1, 8, 3, 50
  731.     WindowBox 6, 38, 10, 50
  732.     WindowLine 4
  733.     WindowLine 11
  734.     WindowLocate 5, 1
  735.     WindowPrint -1, " Color:          Font:               Justify:"
  736.  
  737.     ' set color attribute for title editfield background to that of the chart background
  738.     IF mode$(1) = "10" OR (mode$(1) = "2" AND mode$(2) <> "1") OR mode$(1) = "3" THEN
  739.         func = 0
  740.         EditFieldOpen 1, RTRIM$(title.title), 2, 9, 0, 7, 41, 70
  741.     ELSE
  742.         SetAtt 5, CEnv.ChartWindow.Background + 1
  743.         EditFieldOpen 1, RTRIM$(title.title), 2, 9, 12, 5, 41, 70
  744.         func = 2
  745.     END IF
  746.  
  747.     ' create list boxes
  748.     CreateListBox colors$(), colorBox, func
  749.     CreateListBox fonts$(), fontBox, 0
  750.  
  751.     ' open buttons
  752.     ButtonOpen 5, 1, "Left", 7, 39, 0, 0, 3
  753.     ButtonOpen 6, 1, "Center", 8, 39, 0, 0, 3
  754.     ButtonOpen 7, 1, "Right", 9, 39, 0, 0, 3
  755.     ButtonOpen 8, 2, "OK ", 12, 10, 0, 0, 1
  756.     ButtonOpen 9, 1, "Cancel ", 12, 33, 0, 0, 1
  757.  
  758.     currButton = 0                                      ' start in edit field
  759.     currEditField = 1
  760.     optionButton = 4 + title.Justify                    ' set button state
  761.     ButtonToggle optionButton
  762.     pushButton = 8
  763.  
  764.     ' window control loop
  765.     finished = FALSE
  766.     WHILE NOT finished
  767.         WindowDo currButton, currEditField              ' wait for event
  768.         SELECT CASE Dialog(0)
  769.             CASE 1                                      ' button pressed
  770.                 currButton = Dialog(1)
  771.                 SELECT CASE currButton
  772.                     CASE 1, 2
  773.                         currEditField = 0
  774.                         ScrollList colors$(), colorBox, currButton, 1, func, topRow, leftCol
  775.                         currButton = 2
  776.                     CASE 3, 4
  777.                         currEditField = 0
  778.                         ScrollList fonts$(), fontBox, currButton, 1, 0, topRow, leftCol
  779.                         currButton = 4
  780.                     CASE 5, 6, 7
  781.                         ButtonToggle optionButton
  782.                         optionButton = currButton
  783.                         ButtonToggle optionButton
  784.                         currEditField = 0
  785.                     CASE 8, 9
  786.                         pushButton = currButton
  787.                         finished = TRUE
  788.                 END SELECT
  789.             CASE 2                                      ' edit field
  790.                 currButton = 0
  791.                 currEditField = 1
  792.             CASE 6                                      ' enter
  793.                 finished = TRUE
  794.             CASE 7                                      ' tab
  795.                 SELECT CASE currButton
  796.                     CASE 0:
  797.                         currButton = 2
  798.                         currEditField = 0
  799.                     CASE 1, 2: currButton = 4
  800.                     CASE 3, 4: currButton = optionButton
  801.                     CASE 5, 6, 7:
  802.                         currButton = 8
  803.                         ButtonSetState pushButton, 1
  804.                         ButtonSetState currButton, 2
  805.                         pushButton = 8
  806.                     CASE 8:
  807.                         currButton = currButton + 1
  808.                         ButtonSetState pushButton, 1
  809.                         ButtonSetState currButton, 2
  810.                         pushButton = currButton
  811.                     CASE 9:
  812.                         ButtonSetState currButton, 1
  813.                         pushButton = 8
  814.                         ButtonSetState pushButton, 2
  815.                         currButton = 0
  816.                         currEditField = 1
  817.                 END SELECT
  818.             CASE 8                                      ' back tab
  819.                 SELECT CASE currButton
  820.                     CASE 0:
  821.                         currButton = 9
  822.                         ButtonSetState pushButton, 1
  823.                         ButtonSetState currButton, 2
  824.                         pushButton = 9
  825.                         currEditField = 0
  826.                     CASE 1, 2:
  827.                         currButton = 0
  828.                         currEditField = 1
  829.                     CASE 3, 4: currButton = 2
  830.                     CASE 5, 6, 7: currButton = 4
  831.                     CASE 8: currButton = optionButton
  832.                     CASE 9:
  833.                         currButton = currButton - 1
  834.                         ButtonSetState pushButton, 1
  835.                         ButtonSetState currButton, 2
  836.                         pushButton = currButton
  837.                 END SELECT
  838.             CASE 9                                      ' escape
  839.                 pushButton = 9
  840.                 finished = TRUE
  841.             CASE 10, 12                                 ' up, left arrow
  842.                 SELECT CASE currButton
  843.                     CASE 1, 2: ScrollList colors$(), colorBox, currButton, 2, func, topRow, leftCol
  844.                     CASE 3, 4: ScrollList fonts$(), fontBox, currButton, 2, 0, topRow, leftCol
  845.                     CASE 5:
  846.                         ButtonToggle currButton
  847.                         currButton = 7
  848.                         optionButton = 7
  849.                         ButtonToggle optionButton
  850.                     CASE 6, 7:
  851.                         ButtonToggle currButton
  852.                         currButton = currButton - 1
  853.                         optionButton = currButton
  854.                         ButtonToggle optionButton
  855.                 END SELECT
  856.             CASE 11, 13                                 ' down, right arrow
  857.                 SELECT CASE currButton
  858.                     CASE 1, 2: ScrollList colors$(), colorBox, currButton, 3, func, topRow, leftCol
  859.                     CASE 3, 4: ScrollList fonts$(), fontBox, currButton, 3, 0, topRow, leftCol
  860.                     CASE 5, 6:
  861.                         ButtonToggle currButton
  862.                         currButton = currButton + 1
  863.                         optionButton = currButton
  864.                         ButtonToggle optionButton
  865.                     CASE 7:
  866.                         ButtonToggle currButton
  867.                         currButton = 5
  868.                         optionButton = 5
  869.                         ButtonToggle optionButton
  870.                 END SELECT
  871.             CASE 14                                     ' space bar
  872.                 IF currButton > 7 THEN
  873.                     pushButton = currButton
  874.                     finished = TRUE
  875.                 END IF
  876.         END SELECT
  877.     WEND
  878.  
  879.     ' done and not canceled so return new title information
  880.     IF pushButton = 8 THEN
  881.         IF setNum > 0 THEN chartChanged = TRUE
  882.  
  883.         title.title = EditFieldInquire(1)
  884.         title.TitleFont = fontBox.listPos
  885.         title.TitleColor = colorBox.listPos - 1
  886.         title.Justify = optionButton - 4
  887.     END IF
  888.  
  889.     WindowClose handle
  890.  
  891. END SUB
  892.  
  893. '
  894. ' Sub Name: ChangeWindow
  895. '
  896. ' Description: Allows user to view and modify any of the chart windows
  897. '
  898. ' Arguments: handle - window number
  899. '            wTitle$ - window title
  900. '            win - chart window
  901. '
  902. SUB ChangeWindow (handle, title$, win AS RegionType)
  903.  
  904.     DIM bgColorBox AS ListBox
  905.     DIM bdColorBox AS ListBox
  906.     DIM bdStyleBox AS ListBox
  907.  
  908.     ' set up background color box
  909.     bgColorBox.scrollButton = 1
  910.     bgColorBox.areaButton = 2
  911.     bgColorBox.listLen = numColors
  912.     bgColorBox.topRow = 4
  913.     bgColorBox.botRow = 14
  914.     bgColorBox.leftCol = 4
  915.     bgColorBox.rightCol = 18
  916.     bgColorBox.listPos = win.Background + 1
  917.  
  918.     ' set up border color box
  919.     bdColorBox.scrollButton = 3
  920.     bdColorBox.areaButton = 4
  921.     bdColorBox.listLen = numColors
  922.     bdColorBox.topRow = 5
  923.     bdColorBox.botRow = 14
  924.     bdColorBox.leftCol = 24
  925.     bdColorBox.rightCol = 38
  926.     bdColorBox.listPos = win.BorderColor + 1
  927.  
  928.     ' set up border style box
  929.     bdStyleBox.scrollButton = 5
  930.     bdStyleBox.areaButton = 6
  931.     bdStyleBox.listLen = MAXSTYLES
  932.     bdStyleBox.topRow = 5
  933.     bdStyleBox.botRow = 14
  934.     bdStyleBox.leftCol = 40
  935.     bdStyleBox.rightCol = 54
  936.     bdStyleBox.listPos = win.BorderStyle
  937.  
  938.     ' set up display window
  939.     winRow = 5
  940.     winCol = 3
  941.     WindowOpen handle, winRow, winCol, 21, 76, 0, 7, 0, 7, 15, FALSE, FALSE, FALSE, TRUE, 2, title$
  942.     WindowBox 1, 2, 15, 20
  943.     WindowLocate 2, 5
  944.     WindowPrint 2, "Background"
  945.     WindowLocate 3, 5
  946.     WindowPrint 2, "Color:"
  947.     WindowBox 1, 22, 15, 56
  948.     WindowLocate 4, 24
  949.     WindowPrint 2, "Border Color:"
  950.     WindowLocate 4, 40
  951.     WindowPrint 2, "Border Style:"
  952.     WindowBox 1, 58, 15, 73
  953.     WindowLocate 2, 60
  954.     WindowPrint 2, "Coordinates:"
  955.     WindowBox 3, 63, 5, 71
  956.     WindowLocate 4, 60
  957.     WindowPrint 2, "X1:"
  958.     WindowBox 6, 63, 8, 71
  959.     WindowLocate 7, 60
  960.     WindowPrint 2, "Y1:"
  961.     WindowBox 9, 63, 11, 71
  962.     WindowLocate 10, 60
  963.     WindowPrint 2, "X2:"
  964.     WindowBox 12, 63, 14, 71
  965.     WindowLocate 13, 60
  966.     WindowPrint 2, "Y2:"
  967.     WindowLine 16
  968.  
  969.     CreateListBox colors$(), bgColorBox, 0
  970.     CreateListBox colors$(), bdColorBox, 0
  971.     CreateListBox styles$(), bdStyleBox, 0
  972.  
  973.     ButtonOpen 7, 1, "Display Border", 2, 24, 0, 0, 2
  974.     ButtonOpen 8, 2, "OK ", 17, 14, 0, 0, 1
  975.     ButtonOpen 9, 1, "Cancel ", 17, 51, 0, 0, 1
  976.  
  977.     EditFieldOpen 1, LTRIM$(STR$(win.X1)), 4, 64, 0, 7, 7, 10
  978.     EditFieldOpen 2, LTRIM$(STR$(win.Y1)), 7, 64, 0, 7, 7, 10
  979.     EditFieldOpen 3, LTRIM$(STR$(win.X2)), 10, 64, 0, 7, 7, 10
  980.     EditFieldOpen 4, LTRIM$(STR$(win.Y2)), 13, 64, 0, 7, 7, 10
  981.  
  982.     currButton = 2                                      ' start in first list box
  983.     currEditField = 0
  984.     IF win.border = TRUE THEN ButtonSetState 7, 2
  985.     pushButton = 8
  986.  
  987.     ' window control loop
  988.     finished = FALSE
  989.     WHILE NOT finished
  990.         WindowDo currButton, currEditField              ' wait for event
  991.         SELECT CASE Dialog(0)
  992.             CASE 1                                      ' button pressed
  993.                 currButton = Dialog(1)
  994.                 SELECT CASE currButton
  995.                     CASE 1, 2
  996.                         currEditField = 0
  997.                         ScrollList colors$(), bgColorBox, currButton, 1, 0, winRow, winCol
  998.                         currButton = 2
  999.                     CASE 3, 4
  1000.                         currEditField = 0
  1001.                         ScrollList colors$(), bdColorBox, currButton, 1, 0, winRow, winCol
  1002.                         currButton = 4
  1003.                     CASE 5, 6
  1004.                         currEditField = 0
  1005.                         ScrollList styles$(), bdStyleBox, currButton, 1, 0, winRow, winCol
  1006.                         currButton = 6
  1007.                     CASE 7
  1008.                         ButtonToggle currButton
  1009.                         currEditField = 0
  1010.                     CASE 8, 9
  1011.                         pushButton = currButton
  1012.                         finished = TRUE
  1013.                 END SELECT
  1014.             CASE 2                                      ' edit field
  1015.                 currEditField = Dialog(2)
  1016.                 currButton = 0
  1017.             CASE 6                                      ' enter
  1018.                 finished = TRUE
  1019.             CASE 7                                      ' tab
  1020.                 SELECT CASE currButton
  1021.                     CASE 0:
  1022.                         SELECT CASE currEditField
  1023.                             CASE 1, 2, 3: currEditField = currEditField + 1
  1024.                             CASE 4:
  1025.                                 currEditField = 0
  1026.                                 currButton = 8
  1027.                                 ButtonSetState pushButton, 1
  1028.                                 ButtonSetState currButton, 2
  1029.                                 pushButton = currButton
  1030.                         END SELECT
  1031.                     CASE 1, 2: currButton = 7
  1032.                     CASE 3, 4: currButton = 6
  1033.                     CASE 5, 6:
  1034.                         currButton = 0
  1035.                         currEditField = 1
  1036.                     CASE 7: currButton = 4
  1037.                     CASE 8:
  1038.                         currButton = currButton + 1
  1039.                         ButtonSetState pushButton, 1
  1040.                         ButtonSetState currButton, 2
  1041.                         pushButton = currButton
  1042.                     CASE 9:
  1043.                         ButtonSetState currButton, 1
  1044.                         pushButton = 8
  1045.                         ButtonSetState pushButton, 2
  1046.                         currButton = 2
  1047.                         currEditField = 0
  1048.                 END SELECT
  1049.             CASE 8                                      ' back tab
  1050.                 SELECT CASE currButton
  1051.                     CASE 0:
  1052.                         SELECT CASE currEditField
  1053.                             CASE 1:
  1054.                                 currEditField = 0
  1055.                                 currButton = 6
  1056.                             CASE 2, 3, 4: currEditField = currEditField - 1
  1057.                         END SELECT
  1058.                     CASE 1, 2:
  1059.                         currButton = 9
  1060.                         ButtonSetState pushButton, 1
  1061.                         ButtonSetState currButton, 2
  1062.                         pushButton = currButton
  1063.                     CASE 3, 4: currButton = 7
  1064.                     CASE 5, 6: currButton = 4
  1065.                     CASE 7: currButton = 2
  1066.                     CASE 8:
  1067.                         currButton = 0
  1068.                         currEditField = 4
  1069.                     CASE 9:
  1070.                         currButton = currButton - 1
  1071.                         ButtonSetState pushButton, 1
  1072.                         ButtonSetState currButton, 2
  1073.                         pushButton = currButton
  1074.                 END SELECT
  1075.             CASE 9                                      ' escape
  1076.                 pushButton = 9
  1077.                 finished = TRUE
  1078.             CASE 10, 12                                 ' up, left arrow
  1079.                 SELECT CASE currButton
  1080.                     CASE 1, 2: ScrollList colors$(), bgColorBox, currButton, 2, 0, winRow, winCol
  1081.                     CASE 3, 4: ScrollList colors$(), bdColorBox, currButton, 2, 0, winRow, winCol
  1082.                     CASE 5, 6: ScrollList styles$(), bdStyleBox, currButton, 2, 0, winRow, winCol
  1083.                     CASE 7: ButtonSetState currButton, 2
  1084.                 END SELECT
  1085.             CASE 11, 13                                 ' down, right arrow
  1086.                 SELECT CASE currButton
  1087.                     CASE 1, 2: ScrollList colors$(), bgColorBox, currButton, 3, 0, winRow, winCol
  1088.                     CASE 3, 4: ScrollList colors$(), bdColorBox, currButton, 3, 0, winRow, winCol
  1089.                     CASE 5, 6: ScrollList styles$(), bdStyleBox, currButton, 3, 0, winRow, winCol
  1090.                     CASE 7: ButtonSetState currButton, 1
  1091.                 END SELECT
  1092.             CASE 14                                     ' space bar
  1093.                 SELECT CASE currButton
  1094.                     CASE 7: ButtonToggle currButton
  1095.                     CASE 8, 9: finished = TRUE
  1096.                 END SELECT
  1097.         END SELECT
  1098.     WEND
  1099.  
  1100.     ' return new window information
  1101.     IF pushButton = 8 THEN
  1102.         IF setNum > 0 THEN chartChanged = TRUE
  1103.  
  1104.         win.X1 = VAL(EditFieldInquire(1))
  1105.         win.Y1 = VAL(EditFieldInquire(2))
  1106.         win.X2 = VAL(EditFieldInquire(3))
  1107.         win.Y2 = VAL(EditFieldInquire(4))
  1108.         win.Background = bgColorBox.listPos - 1
  1109.         win.border = (ButtonInquire(7) = 2)
  1110.         win.BorderColor = bdColorBox.listPos - 1
  1111.         win.BorderStyle = bdStyleBox.listPos
  1112.     END IF
  1113.  
  1114.     WindowClose handle
  1115.  
  1116. END SUB
  1117.  
  1118.