home *** CD-ROM | disk | FTP | other *** search
/ OS/2 Shareware BBS: 18 REXX / 18-REXX.zip / vxcliser.zip / VRCS.3 / CHTSAMP / PRINTCHT / PRINTCHT.VRX < prev    next >
Text File  |  1994-12-23  |  5KB  |  234 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         EnableButtons
  67. */
  68. EnableButtons:
  69.     /* Enable the buttons only if there are available
  70.        printers.
  71.     */
  72.  
  73.     selected = VRGet( "Printers", "Selected" )
  74.     enabled = ( selected \= 0 )
  75.  
  76.     call VRSet "PB_Print", "Enabled", enabled
  77.     call VRSet "PrintSetup", "Enabled", selected
  78. return
  79.  
  80. /*:VRX         Fini
  81. */
  82. Fini:
  83.     /* Destroy the window
  84.     */
  85.  
  86.     window = VRWindow()
  87.     call VRSet window, "Visible", 0
  88.     drop window
  89. return 0
  90.  
  91. /*:VRX         Halt
  92. */
  93. Halt:
  94.     signal _VREHalt
  95. return
  96.  
  97. /*:VRX         Init
  98. */
  99. Init:
  100.     /* Create the window
  101.     */
  102.  
  103.     window = VRWindow()
  104.     call VRMethod window, "CenterWindow"
  105.     call VRSet window, "Visible", 1
  106.     call VRMethod window, "Activate"
  107.     drop window
  108. return
  109.  
  110. /*:VRX         MI_ProdInfo_Click
  111. */
  112. MI_ProdInfo_Click:
  113.     /* The product information is displayed as a mutli-line
  114.        message dialog.
  115.     */
  116.  
  117.     buttons.0 = 1
  118.     buttons.1 = "Ok"
  119.     
  120.     message.0 = 4
  121.     message.1 = "Chart Print Sample"
  122.     message.2 = ""
  123.     message.3 = "This sample application shows how"
  124.     message.4 = "to print a chart."
  125.  
  126.     call VRMessageStem VRWindow(), "message.", ,
  127.         "Product Information", "I", "buttons.", 1, 1
  128. return
  129.  
  130. /*:VRX         PB_Cancel_Click
  131. */
  132. PB_Cancel_Click:
  133.     /* Destroy the print window
  134.     */    
  135.  
  136.     call VRDestroy "WI_Print"
  137.     call VRSet VRWindow(), "Enabled", 1
  138.     call VRMethod VRWindow(), "Activate"
  139. return
  140.  
  141. /*:VRX         PB_GoPrint_Click
  142. */
  143. PB_GoPrint_Click:
  144.     /* Create the print window
  145.     */
  146.  
  147.     call VRSet "Window1", "Enabled", 0
  148.     if( \VRIsValidObject( "WI_Print" ) )then do
  149.         call VRLoadSecondary "WI_Print"
  150.     end
  151.     call VRMethod "WI_Print", "Activate"
  152.  
  153.     /*  Build the list of printers
  154.     */
  155.     call VRMethod "Application", "ListPrinters", "printer."
  156.     do i = 1 to printer.0
  157.         parse var printer.i queue ";" printer ";" driver
  158.         call VRMethod "Printers", "AddString", queue ,, printer
  159.         JobData.i = VRPrintJobDialog( VRWindow(), printer, "Default" )
  160.     end
  161.     
  162.     /*  Select the first printer
  163.     */
  164.     call VRSet "Printers", "Selected", 1
  165. return
  166.  
  167. /*:VRX         PB_Print_Click
  168. */
  169. PB_Print_Click:
  170.     /*  Get the printer name from the item data stored in the list
  171.     */
  172.     selection = VRGet( "Printers", "Selected" )
  173.     printer = VRMethod( "Printers", "GetItemData", selection )
  174.  
  175.     ok = VRMethod( "WC_Chart", "PrintChart", printer,,
  176.                    JobData.selection, "FitToMargins", ,
  177.                     ".1", ".1", ".1", ".1", 0, 0 )
  178.     call VRDestroy "WI_Print"
  179.     call VRSet VRWindow(), "Enabled", 1
  180.     call VRMethod VRWindow(), "Activate"
  181. return
  182.  
  183. /*:VRX         Printers_Click
  184. */
  185. Printers_Click:
  186.     /* The buttons are enabled only when there is a selected
  187.        printer.
  188.     */
  189.  
  190.     call EnableButtons
  191. return
  192.  
  193. /*:VRX         PrintSetup_Click
  194. */
  195. PrintSetup_Click:
  196.     /* The standard printer dialogs.
  197.     */
  198.  
  199.     w = VRWindow()
  200.     prt_idx = VRGet( "Printers", "Selected" )
  201.     data = VRPrintJobDialog( w, printer, jobData.prt_idx )
  202.     if( data \= "" ) then do
  203.         JobData.prt_idx = data
  204.     end
  205. return
  206.  
  207. /*:VRX         Quit
  208. */
  209. Quit:
  210.     /* Close the application
  211.     */
  212.     
  213.     window = VRWindow()
  214.     call VRSet window, "Shutdown", 1
  215.     drop window
  216. return
  217.  
  218. /*:VRX         WI_Print_Close
  219. */
  220. WI_Print_Close:
  221.     /* Destroy the window
  222.     */
  223.  
  224.     window = VRInfo( "Object" )
  225.     call VRDestroy window
  226.     drop window
  227. return
  228. /*:VRX         Window1_Close
  229. */
  230. Window1_Close:
  231.     call Quit
  232. return
  233.  
  234.