home *** CD-ROM | disk | FTP | other *** search
/ OS/2 Shareware BBS: 18 REXX / 18-REXX.zip / vxcliser.zip / VRCS.3 / CHTSAMP / CLICK / CLICK.VRX < prev    next >
Text File  |  1994-12-23  |  9KB  |  353 lines

  1. /*:VRX         Main
  2. */
  3. /*  Main
  4. */
  5. Main:
  6. /*  Process the arguments.
  7.     Get the parent window.
  8. */
  9.     parse source . calledAs .
  10.     parent = ""
  11.     argCount = arg()
  12.     argOff = 0
  13.     if( calledAs \= "COMMAND" )then do
  14.         if argCount >= 1 then do
  15.             parent = arg(1)
  16.             argCount = argCount - 1
  17.             argOff = 1
  18.         end
  19.     end
  20.     InitArgs.0 = argCount
  21.     if( argCount > 0 )then do i = 1 to argCount
  22.         InitArgs.i = arg( i + argOff )
  23.     end
  24.     drop calledAs argCount argOff
  25.  
  26. /*  Load the windows
  27. */
  28.     call VRInit
  29.     parse source . . spec
  30.     _VREPrimaryWindowPath = ,
  31.         VRParseFileName( spec, "dpn" ) || ".VRW"
  32.     _VREPrimaryWindow = ,
  33.         VRLoad( parent, _VREPrimaryWindowPath )
  34.     drop parent spec
  35.     if( _VREPrimaryWindow == "" )then do
  36.         call VRMessage "", "Cannot load window:" VRError(), ,
  37.             "Error!"
  38.         _VREReturnValue = 32000
  39.         signal _VRELeaveMain
  40.     end
  41.  
  42. /*  Process events
  43. */
  44.     call Init
  45.     signal on halt
  46.     do while( \ VRGet( _VREPrimaryWindow, "Shutdown" ) )
  47.         _VREEvent = VREvent()
  48.         interpret _VREEvent
  49.     end
  50. _VREHalt:
  51.     _VREReturnValue = Fini()
  52.     call VRDestroy _VREPrimaryWindow
  53. _VRELeaveMain:
  54.     call VRFini
  55. exit _VREReturnValue
  56.  
  57. VRLoadSecondary: procedure
  58.     name = arg( 1 )
  59.  
  60.     window = VRLoad( VRWindow(), VRWindowPath(), name )
  61.     call VRMethod window, "CenterWindow"
  62.     call VRSet window, "Visible", 1
  63.     call VRMethod window, "Activate"
  64. return window
  65.  
  66. /*:VRX         Fini
  67. */
  68. Fini:
  69.     /* Destroy the window
  70.     */
  71.  
  72.     window = VRWindow()
  73.     call VRSet window, "Visible", 0
  74.     drop window
  75. return 0
  76.  
  77. /*:VRX         Halt
  78. */
  79. Halt:
  80.     signal _VREHalt
  81. return
  82.  
  83. /*:VRX         Init
  84. */
  85. Init:
  86.     /* Create the window
  87.     */
  88.  
  89.     window = VRWindow()
  90.     call VRSet "LChartType", "Value", "BarLineChart"
  91.     call VRMethod window, "CenterWindow"
  92.     call VRSet window, "Visible", 1
  93.     call VRMethod window, "Activate"
  94.     drop window
  95. return
  96.  
  97. /*:VRX         LChartType_Change
  98. */
  99. LChartType_Change:
  100.     /* Change the chart typed (probably triggered by the DDCB
  101.     */
  102.  
  103.     type = VRGet( "LChartType", "Value" )
  104.     call VRMethod "WC_1", "SetOption", "ChartType", type  
  105.  
  106.     /* Change the 'Last Selected' text to "Chart Type"
  107.     */
  108.   
  109.     call VRSet "DT_LastSel", "Caption", "Chart Type"
  110. return
  111.  
  112. /*:VRX         M1_Project_Copy_Click
  113. */
  114. M1_Project_Copy_Click:
  115.     /* Copy the chart into the clipboard.
  116.     */
  117.  
  118.     call VRMethod "WC_1", "PutClipboard"
  119. return
  120.  
  121. /*:VRX         MI_Help_ProdInfo_Click
  122. */
  123. MI_Help_ProdInfo_Click:
  124.     /* The product information is displayed as a multi-line
  125.        message dialog.
  126.     */
  127.  
  128.     buttons.0 = 1
  129.     buttons.1 = "Ok"
  130.     
  131.     message.0 = 6
  132.     message.1 = "Chart Click Sample"
  133.     message.2 = ""
  134.     message.3 = "This demo application shows the power"
  135.     message.4 = "of the chart's click event which can"
  136.     message.5 = "be used to create fully featured, easy"
  137.     message.6 = "to use applications."
  138.  
  139.     call VRMessageStem VRWindow(), "message.", ,
  140.         "Product Information", "I", "buttons.", 1, 1
  141. return
  142.  
  143. /*:VRX         MI_Project_Load_Click
  144. */
  145. MI_Project_Load_Click:
  146.     /* Load a chart from a file.
  147.     */
  148.     
  149.     filename = VRFileDialog( VRWindow(), "Loading a Chart.", "Open", "*.CHT", , ,  )
  150.     
  151.     if( LENGTH(filename) > 0 ) then do
  152.         if( VRFileExists(filename) ) then do
  153.             /* The load routine
  154.             */
  155.  
  156.             call VRMethod "WC_1", "LoadFromFile", filename
  157.             call VRMethod "WC_1", "Redraw"
  158.         end
  159.         else do             
  160.             id = VRMessage( VRWindow(), "Can't load chart.", "Chart Load Error.", "Error", , ,  )           
  161.         end
  162.     end
  163. return
  164.  
  165. /*:VRX         MI_Project_LoadData_Click
  166. */
  167. MI_Project_LoadData_Click:
  168.     /* Load a chart from a file with the data.
  169.     */
  170.     
  171.     filename = VRFileDialog( VRWindow(), "Loading a Chart.", "Open", "*.CHT", , ,  )
  172.     
  173.     if( LENGTH(filename) > 0 ) then do
  174.         if( VRFileExists(filename) ) then do
  175.             /* The load routine
  176.             */
  177.  
  178.             call VRMethod "WC_1", "LoadFromFile", filename, 1
  179.             call VRMethod "WC_1", "Redraw"
  180.         end
  181.         else do             
  182.             id = VRMessage( VRWindow(), "Can't load chart.", "Chart Load Error.", "Error", , ,  )           
  183.         end
  184.     end
  185.  
  186. return
  187.  
  188. /*:VRX         MI_Project_Paste_Click
  189. */
  190. MI_Project_Paste_Click:
  191.     /* Paste a chart from the clipboard.
  192.     */
  193.  
  194.     call VRMethod "WC_1", "GetClipboard"
  195. return
  196.  
  197. /*:VRX         MI_Project_PasteData_Click
  198. */
  199. MI_Project_PasteData_Click:
  200.     /* Get the data with the chart from the clipboard.
  201.     */
  202.  
  203.     call VRMethod "WC_1", "GetClipboard", 1
  204. return
  205.  
  206. /*:VRX         MI_Project_Save_Click
  207. */
  208. MI_Project_Save_Click:
  209.     /* Save a chart to a file
  210.     */
  211.     
  212.     filename = VRFileDialog( VRWindow(), "Saving a Chart.", "Save", "*.CHT", , ,  )
  213.     
  214.     if( LENGTH(filename) > 0 ) then do
  215.         call VRMethod "WC_1", "SaveToFile", filename
  216.     end
  217. return
  218.  
  219. /*:VRX         Quit
  220. */
  221. Quit:
  222.     /* Close the application
  223.     */
  224.  
  225.     window = VRWindow()
  226.     call VRSet window, "Shutdown", 1
  227.     drop window
  228. return
  229.  
  230. /*:VRX         WC_1_Click
  231. */
  232. WC_1_Click:
  233.     /* Find out which chart item was selected
  234.     */
  235.  
  236.     item = VRInfo( "Item" )
  237.     call VRSet "DT_LastSel", "Caption", item
  238.  
  239.     if( ( item == "ChartTitle" ) | ( item == "ChartSubtitle" ) | ( item == "ChartFootnote" ) ) then do
  240.         /* User selected one of the chart titles
  241.         */
  242.  
  243.         if( item == "ChartTitle" ) then do
  244.             string = "New title:"
  245.         end
  246.         else if( item == "ChartSubtitle" ) then do
  247.             string = "New subtitle:"
  248.         end
  249.         else do
  250.             string = "New footnote:"
  251.         end
  252.  
  253.         /* Bring up a modal window to change the value of the appropriate chart title
  254.         */
  255.         values = Window1( VRWindow(), string, "" )
  256.         if( values \= "" ) then do
  257.             parse var values title
  258.             option = substr( item, 6 )
  259.             /* Set the value of the appropriate chart title
  260.             */
  261.  
  262.             call VRMethod "WC_1", "SetOption", option, title
  263.         end
  264.     end
  265.     else if( substr( item, 1, 10 ) == "ChartGroup" ) then do
  266.         /* User selected a data element
  267.         */
  268.  
  269.         parse var item str'.'group'.'row'.'col
  270.         if( row > 0 & col > 0 ) then do
  271.             /* Bring up a modal window to change the value of the data element
  272.             */
  273.  
  274.             oldvalue = VRMethod( "WC_1", "GetDataValue", row, col )
  275.             values = Window1( VRWindow(), "Change the data value:", oldvalue )
  276.             if( values \= "" ) then do
  277.                 parse var values dataval
  278.                 /* Set the value of the appropriate data element
  279.                 */
  280.  
  281.                 call VRMethod "WC_1", "SetDataValue", row, col, dataval
  282.             end
  283.         end
  284.     end
  285.     else if( substr( item, 1, 11 ) == "ChartXScale" ) then do
  286.         /* User selected a row name
  287.         */
  288.  
  289.         parse var item str'.'row
  290.         if( row > 0 ) then do
  291.             /* Bring up a modal window to change the value of the appropriate row name
  292.             */
  293.  
  294.             oldvalue = VRMethod( "WC_1", "GetRowName", row )
  295.             values = Window1( VRWindow(), "Change the row name:", oldvalue )
  296.             if( values \= "" ) then do
  297.                 parse var values name
  298.                 /* Set the value of the appropriate row name
  299.                 */
  300.  
  301.                 call VRMethod "WC_1", "SetRowName", row, name
  302.             end
  303.         end
  304.     end
  305.     else if( substr( item, 1, 16 ) == "ChartSliceLabels" ) then do
  306.         /* User selected a row name
  307.         */
  308.  
  309.         parse var item str'.'row
  310.         if( row > 0 ) then do
  311.             /* Bring up a modal window to change the value of the appropriate row name
  312.             */
  313.  
  314.             oldvalue = VRMethod( "WC_1", "GetRowName", row )
  315.             values = Window1( VRWindow(), "Change the row name:", oldvalue )
  316.             if( values \= "" ) then do
  317.                 parse var values name
  318.                 /* Set the value of the appropriate row name
  319.                 */
  320.  
  321.                 call VRMethod "WC_1", "SetRowName", row, name
  322.             end
  323.         end
  324.     end
  325.     else if( substr( item, 1, 11 ) == "ChartZScale" ) then do
  326.         /* User selected a column name
  327.         */
  328.  
  329.         parse var item str'.'col
  330.         if( col > 0 ) then do
  331.             /* Bring up a modal window to change the value of the appropriate column name
  332.             */
  333.  
  334.             oldvalue = VRMethod( "WC_1", "GetColName", col )
  335.             values = Window1( VRWindow(), "Change the column name:", oldvalue )
  336.             if( values \= "" )then do
  337.                 parse var values name
  338.  
  339.                 /* Set the value of the appropriate column name
  340.                 */
  341.                 call VRMethod "WC_1", "SetColName", col, name
  342.             end
  343.         end
  344.     end
  345. return
  346.  
  347. /*:VRX         Window1_Close
  348. */
  349. Window1_Close:
  350.     call Quit
  351. return
  352.  
  353.