home *** CD-ROM | disk | FTP | other *** search
/ OS/2 Shareware BBS: 18 REXX / 18-REXX.zip / vrproj21.zip / WINDOW1.VRX < prev    next >
Text File  |  1995-12-28  |  36KB  |  1,197 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; else do
  20.         call VROptions 'ImplicitNames'
  21.     end
  22.     InitArgs.0 = argCount
  23.     if( argCount > 0 )then do i = 1 to argCount
  24.         InitArgs.i = arg( i + argOff )
  25.     end
  26.     drop calledAs argCount argOff
  27.  
  28. /*  Load the windows
  29. */
  30.     call VRInit
  31.     parse source . . spec
  32.     _VREPrimaryWindowPath = ,
  33.         VRParseFileName( spec, "dpn" ) || ".VRW"
  34.     _VREPrimaryWindow = ,
  35.         VRLoad( parent, _VREPrimaryWindowPath )
  36.     drop parent spec
  37.     if( _VREPrimaryWindow == "" )then do
  38.         call VRMessage "", "Cannot load window:" VRError(), ,
  39.             "Error!"
  40.         _VREReturnValue = 32000
  41.         signal _VRELeaveMain
  42.     end
  43.  
  44. /*  Process events
  45. */
  46.     call Init
  47.     signal on halt
  48.     do while( \ VRGet( _VREPrimaryWindow, "Shutdown" ) )
  49.         _VREEvent = VREvent()
  50.         interpret _VREEvent
  51.     end
  52. _VREHalt:
  53.     _VREReturnValue = Fini()
  54.     call VRDestroy _VREPrimaryWindow
  55. _VRELeaveMain:
  56.     call VRFini
  57. exit _VREReturnValue
  58.  
  59. VRLoadSecondary:
  60.     __vrlsWait = abbrev( 'WAIT', translate(arg(2)), 1 )
  61.     if __vrlsWait then do
  62.         call VRFlush
  63.     end
  64.     __vrlsHWnd = VRLoad( VRWindow(), VRWindowPath(), arg(1) )
  65.     if __vrlsHWnd = '' then signal __vrlsDone
  66.     if __vrlsWait \= 1 then signal __vrlsDone
  67.     call VRSet __vrlsHWnd, 'WindowMode', 'Modal' 
  68.     __vrlsTmp = __vrlsWindows.0
  69.     if( DataType(__vrlsTmp) \= 'NUM' ) then do
  70.         __vrlsTmp = 1
  71.     end
  72.     else do
  73.         __vrlsTmp = __vrlsTmp + 1
  74.     end
  75.     __vrlsWindows.__vrlsTmp = VRWindow( __vrlsHWnd )
  76.     __vrlsWindows.0 = __vrlsTmp
  77.     do while( VRIsValidObject( VRWindow() ) = 1 )
  78.         __vrlsEvent = VREvent()
  79.         interpret __vrlsEvent
  80.     end
  81.     __vrlsTmp = __vrlsWindows.0
  82.     __vrlsWindows.0 = __vrlsTmp - 1
  83.     call VRWindow __vrlsWindows.__vrlsTmp 
  84.     __vrlsHWnd = ''
  85. __vrlsDone:
  86. return __vrlsHWnd
  87.  
  88. /*:VRX         CB_1_Click
  89. */
  90. CB_1_Click: 
  91.     
  92.     /***** Enable or disable spin buttoms *******************************/
  93.     
  94.     if VRGet( CB_1, 'Set') then do
  95.         call VRSet SPIN_1, 'Enabled', 1
  96.         call VRSet SPIN_4, 'Enabled', 1
  97.     end
  98.     else do
  99.         call VRSet SPIN_1, 'Enabled', 0
  100.         call VRSet SPIN_4, 'Enabled', 0
  101.     end
  102.  
  103. return
  104.  
  105. /*:VRX         Fini
  106. */
  107. Fini:
  108.     window = VRWindow()
  109.     call VRSet window, "Visible", 0
  110.     drop window
  111.  
  112. return 0
  113.  
  114. /*:VRX         front_page_Close
  115. */
  116. front_page_Close: 
  117.     call front_page_Fini
  118. return
  119.  
  120. /*:VRX         front_page_Create
  121. */
  122. front_page_Create: 
  123.     call front_page_Init
  124. return
  125.  
  126. /*:VRX         front_page_Fini
  127. */
  128. front_page_Fini: 
  129.     window = VRInfo( "Window" )
  130.     call VRDestroy window
  131.     drop window
  132. return
  133. /*:VRX         front_page_Init
  134. */
  135. front_page_Init: 
  136.     window = VRInfo( "Object" )
  137.     if( \VRIsChildOf( window, "Notebook" ) ) then do
  138.         call VRMethod window, "CenterWindow"
  139.         call VRSet window, "Visible", 1
  140.         call VRMethod window, "Activate"
  141.     end
  142.     drop window
  143. return
  144.  
  145. /*:VRX         front_page_Resize
  146. */
  147. front_page_Resize: 
  148.     call resize_dlg front_page, GB_11
  149.     if loading then do
  150.         call VRSet "NB_1", "Selected", 2
  151.         call VRSet "NB_1", "Selected", 3
  152.         call VRSet "NB_1", "Selected", 4
  153.         call VRSet "NB_1", "Selected", 5
  154.         call VRSet "NB_1", "Selected", 6
  155.         call VRSet "NB_1", "Selected", 1
  156.         loading = 0
  157.         call VRSet "NB_1", "Painting", 1;
  158.     end
  159. return
  160.  
  161. /*:VRX         ftr_dlg_Close
  162. */
  163. ftr_dlg_Close: 
  164.     call ftr_dlg_Fini
  165. return
  166.  
  167. /*:VRX         ftr_dlg_Create
  168. */
  169. ftr_dlg_Create: 
  170.     call ftr_dlg_Init
  171. return
  172.  
  173. /*:VRX         ftr_dlg_Fini
  174. */
  175. ftr_dlg_Fini: 
  176.     window = VRInfo( "Window" )
  177.     call VRDestroy window
  178.     drop window
  179. return
  180. /*:VRX         ftr_dlg_Init
  181. */
  182. ftr_dlg_Init: 
  183.     window = VRInfo( "Object" )
  184.     if( \VRIsChildOf( window, "Notebook" ) ) then do
  185.         call VRMethod window, "CenterWindow"
  186.         call VRSet window, "Visible", 1
  187.         call VRMethod window, "Activate"
  188.     end
  189.     drop window
  190. return
  191.  
  192. /*:VRX         ftr_dlg_Resize
  193. */
  194. ftr_dlg_Resize: 
  195.     call resize_dlg ftr_dlg, GB_5
  196. return
  197.  
  198. /*:VRX         Halt
  199. */
  200. Halt:
  201.     signal _VREHalt
  202. return
  203.  
  204. /*:VRX         hdr_ftr_dlg_Close
  205. */
  206. hdr_ftr_dlg_Close: 
  207.     call hdr_ftr_dlg_Fini
  208. return
  209.  
  210. /*:VRX         hdr_ftr_dlg_Create
  211. */
  212. hdr_ftr_dlg_Create: 
  213.     call hdr_ftr_dlg_Init
  214. return
  215.  
  216. /*:VRX         hdr_ftr_dlg_Fini
  217. */
  218. hdr_ftr_dlg_Fini: 
  219.     window = VRInfo( "Window" )
  220.     call VRDestroy window
  221.     drop window
  222. return
  223. /*:VRX         hdr_ftr_dlg_Init
  224. */
  225. hdr_ftr_dlg_Init: 
  226.     window = VRInfo( "Object" )
  227.     if( \VRIsChildOf( window, "Notebook" ) ) then do
  228.         call VRMethod window, "CenterWindow"
  229.         call VRSet window, "Visible", 1
  230.         call VRMethod window, "Activate"
  231.     end
  232.     drop window
  233. return
  234.  
  235. /*:VRX         hdr_ftr_dlg_Resize
  236. */
  237. hdr_ftr_dlg_Resize: 
  238.     call resize_dlg hdr_ftr_dlg, GB_4
  239. return
  240.  
  241. /*:VRX         idm_about_Click
  242. */
  243. idm_about_Click: 
  244.     wTitle = 'VRPrint Demo v' || version
  245.     call aboutwin VRWindow(), wTitle
  246. return
  247.  
  248. /*:VRX         idm_exit_Click
  249. */
  250. idm_exit_Click: 
  251.     call Quit
  252. return
  253.  
  254. /*:VRX         idm_prt_setup_Click
  255. */
  256. idm_prt_setup_Click: 
  257.     
  258.     /***** Call the printers dialog *************************************/
  259.     
  260.     buttons.0 = 3
  261.     buttons.1 = '~Accept'
  262.     buttons.2 = '~Job Properties...'
  263.     buttons.3 = 'Cancel'
  264.  
  265.     pName = VRMethod( "PRT_1", "PrinterDialog", 'Choose printer', 'buttons.');
  266.     if pName = '' then
  267.         pName = VRGet( "PRT_1", "CurrentPrinter");
  268.     wTitle = 'VRPrinter Demo v' || version '-' pName
  269.     call VRSet Window1, 'Caption', wTitle
  270.  
  271. return
  272.  
  273. /*:VRX         Init
  274. */
  275. Init:
  276.  
  277.     window = VRWindow()
  278.     call VRMethod window, "CenterWindow"
  279.  
  280.     loading = 1;
  281. /*
  282.     call VRRedirectStdIO 'Off'
  283. */
  284.     call VRSet window, "Visible", 1
  285.     call VRMethod window, "Activate"
  286.  
  287.     /***** Set the title of the window **********************************/
  288.     
  289.     pName = VRGet( "PRT_1", "CurrentPrinter");
  290.     version = VRGet( "PRT_1", "Version");
  291.     wTitle = 'VRPrinter Demo v' || version '-' pName
  292.     call VRSet window, 'Caption', wTitle
  293.     
  294.     /***** Get the path to the OS/2 logo ********************************/
  295.     
  296.     set_path = VALUE( 'PATH', , 'OS2ENVIRONMENT');
  297.     bootdrive = substr( set_path, pos( '\OS2\SYSTEM', set_path ) -2, 2);
  298.     bmp_name = bootdrive || '\os2\bitmap\os2logo.bmp'
  299.     bmp_name2 = bootdrive || '\os2\bitmap\addlogo.bmp'
  300.  
  301.     call VRSet "NB_1", "Painting", 0;
  302.  
  303.     drop window ver set_path bootdrive
  304.  
  305. return
  306.  
  307. /*:VRX         Page_dlg_Close
  308. */
  309. Page_dlg_Close: 
  310.     call Page_dlg_Fini
  311. return
  312.  
  313. /*:VRX         Page_dlg_Create
  314. */
  315. Page_dlg_Create: 
  316.     call Page_dlg_Init
  317. return
  318.  
  319. /*:VRX         Page_dlg_Fini
  320. */
  321. Page_dlg_Fini: 
  322.     window = VRInfo( "Window" )
  323.     call VRDestroy window
  324.     drop window
  325. return
  326. /*:VRX         Page_dlg_Init
  327. */
  328. Page_dlg_Init: 
  329.     window = VRInfo( "Object" )
  330.     if( \VRIsChildOf( window, "Notebook" ) ) then do
  331.         call VRMethod window, "CenterWindow"
  332.         call VRSet window, "Visible", 1
  333.         call VRMethod window, "Activate"
  334.     end
  335.     drop window
  336. return
  337.  
  338. /*:VRX         Page_dlg_Resize
  339. */
  340. Page_dlg_Resize: 
  341.     call resize_dlg Page_dlg, GB_7
  342. return
  343.  
  344. /*:VRX         PB_1_Click
  345. */
  346. PB_1_Click: 
  347.     
  348.     /***** Get Page settings ********************************************/
  349.     
  350.     border = VRGet( CB_1, 'Set');
  351.     if border then do
  352.         thick = VRGet( SPIN_1, 'Value');
  353.         style = VRGet( SPIN_4, 'Value');
  354.     end
  355.     else do
  356.         thick = 0;
  357.         style = 0;
  358.     end
  359.     bcolor = VRGet( "DDCB_bcolor", "Value");
  360.     fcolor = VRGet( "DDCB_fcolor", "Value");
  361.     tcolor = VRGet( "DDCB_color", "Value");
  362.  
  363.     call VRSet "PRT_1", "PrintColor", tcolor
  364.  
  365.     /***** Get header settings ******************************************/
  366.     
  367.     header = VRGet( CB_2, 'Set');
  368.     allpages = VRGet( CB_4, 'Set');
  369.     if header then do
  370.         hthick = VRGet( SPIN_2, 'Value');
  371.         hstyle = VRGet( SPIN_3, 'Value');
  372.     end
  373.     else do
  374.         hthick = 0;
  375.         hstyle = 0;
  376.     end
  377.     hlcolor = VRGet( "DDCB_hlcolor", "Value");
  378.     hfcolor = VRGet( "DDCB_hfcolor", "Value");
  379.     htcolor = VRGet( "DDCB_htcolor", "Value");
  380.  
  381.     htext1 = VRGet( "EF_3", "value");
  382.     htext2 = VRGet( "EF_4", "value");
  383.     htext3 = VRGet( "EF_5", "value");
  384.     htext4 = VRGet( "EF_6", "value");
  385.     hlines = 4;
  386.     if htext4 = '' then do
  387.         hlines = 3;
  388.         if htext3 = '' then do
  389.             hlines = 2
  390.             if htext2 = '' then do
  391.                 hlines = 1
  392.                 if htext1 = '' then do
  393.                     hlines = 0
  394.                     header = 0
  395.                 end
  396.             end
  397.         end
  398.     end
  399.  
  400.     /***** Get footer settings ******************************************/
  401.     
  402.     footer = VRGet( CB_3, 'Set');
  403.     if footer then do
  404.         fthick = VRGet( SPIN_6, 'Value');
  405.         fstyle = VRGet( SPIN_5, 'Value');
  406.     end
  407.     else do
  408.         fthick = 0;
  409.         fstyle = 0;
  410.     end
  411.     flcolor = VRGet( "DDCB_flcolor", "Value");
  412.     ffcolor = VRGet( "DDCB_ffcolor", "Value");
  413.     ftcolor = VRGet( "DDCB_ftcolor", "Value");
  414.  
  415.     ftext = VRGet( "EF_8", "value");
  416.     if ftext = '' then
  417.         ftext = '$▌$rpage $#'
  418.  
  419.     /***** Get table settings ******************************************/
  420.     
  421.     tthick = VRGet( SPIN_15, 'Value');
  422.     tstyle = VRGet( SPIN_14, 'Value');
  423.     tlcolor = VRGet( "DDCB_tlcolor", "Value");
  424.     tfcolor = VRGet( "DDCB_tfcolor", "Value");
  425.     ttcolor = VRGet( "DDCB_ttcolor", "Value");
  426.  
  427.     ththick = VRGet( SPIN_13, 'Value');
  428.     thstyle = VRGet( SPIN_12, 'Value');
  429.     thlcolor = VRGet( "DDCB_thlcolor", "Value");
  430.     thfcolor = VRGet( "DDCB_thfcolor", "Value");
  431.     thtcolor = VRGet( "DDCB_thtcolor", "Value");
  432.  
  433.     /***** Get margins for page *****************************************/
  434.     
  435.     lm = VRGet( SPIN_10, 'Value');
  436.     rm = VRGet( SPIN_9, 'Value');
  437.     tm = VRGet( SPIN_8, 'Value');
  438.     bm = VRGet( SPIN_7, 'Value');
  439.     ils = VRGet( SPIN_11, 'Value');
  440.  
  441.     /***** Find what we want to print ***********************************/
  442.     
  443.     if VRGet( RB_1, 'Set') then do
  444.         pstyle = 1
  445.         text_style = 'L'
  446.     end
  447.     if VRGet( RB_2, 'Set') then do
  448.         pstyle = 2
  449.         text_style = 'R'
  450.     end
  451.     if VRGet( RB_3, 'Set') then do
  452.         pstyle = 3
  453.         text_style = 'C'
  454.     end
  455.     if VRGet( RB_4, 'Set') then do
  456.         pstyle = 4
  457.         text_style = 'J'
  458.     end
  459.     if VRGet( RB_5, 'Set') then
  460.         pstyle = 5
  461.     if VRGet( RB_6, 'Set') then
  462.         pstyle = 6
  463.     if VRGet( RB_7, 'Set') then
  464.         pstyle = 7
  465.     if VRGet( RB_8, 'Set') then
  466.         pstyle = 8
  467.     if VRGet( RB_9, 'Set') then do
  468.         pstyle = 9
  469.         text_file_name = VRGet( "EF_2", "Value");
  470.         if text_file_name = '' then do
  471.             call beep 1000, 1000
  472.             return
  473.         end
  474.     end
  475.     if VRGet( RB_10, 'Set') then
  476.         pstyle = 10
  477.     
  478.     /***** get the font face name ***************************************/
  479.     
  480.     facename = VRGet( EF_1, 'Value');
  481.     if facename = '' then do
  482.         call beep 1000, 1000
  483.         return
  484.     end
  485.  
  486.     p = pos( '.', facename) + 1;
  487.     facename = substr( facename, p);
  488.  
  489.     call VRSet Window1, 'pointer', 'wait'
  490.     
  491.     /***** Set the margins **********************************************/
  492.     
  493.     rcy = VRMethod( "PRT_1", "SetMargins", lm, rm, tm, bm, thick, style, bcolor, fcolor);
  494.     
  495.     /***** Set the header mode ******************************************/
  496.     
  497.     rcy = VRMethod( "PRT_1", "SetHeaderMode", header, facename, 10, hstyle, hthick, allpages, hlcolor, hfcolor, htcolor);
  498.     
  499.     /***** Set the header ***********************************************/
  500.     
  501.     rcy = VRMethod( "PRT_1", "SetHeader", hlines, htext1, htext2, htext3, htext4);
  502.     
  503.     if hlines > 0 then
  504.         rcy = VRMethod( "PRT_1", "SetHeaderLineFont", 1,,14);
  505.  
  506.     /***** Set the footer if any ****************************************/
  507.     
  508.     if footer then do
  509.         rcy = VRMethod( "PRT_1", "SetFooter", facename, 8, fstyle, fthick, ftext, flcolor, ffcolor, ftcolor);
  510.     end
  511.     
  512.     /***** Open the print job *******************************************/
  513.     
  514.     rcy = VRMethod( "PRT_1", "OpenPrintJob", 'Test Printing');
  515.  
  516.     /***** Check that everything was ok *********************************/
  517.     
  518.     if \rcy then do
  519.         call VRSet Window1, 'pointer', '<default>'
  520.         return
  521.     end
  522.  
  523.     call PrintItAll
  524.  
  525.     call VRSet Window1, 'pointer', '<default>'
  526.  
  527. return
  528.  
  529. /*:VRX         PB_2_Click
  530. */
  531. PB_2_Click: 
  532.     call Quit
  533. return
  534.  
  535. /*:VRX         PB_3_Click
  536. */
  537. PB_3_Click: 
  538.     
  539.     /***** Get the font for printing ************************************/
  540.  
  541.     face = VRGet( EF_1, 'Value')
  542.     p = pos( '.', face)
  543.     if p > 0 then
  544.         face = word( substr( face, p + 1), 1);
  545.     else
  546.         face = ''
  547.     font = VRMethod( "PRT_1", "FontDialog", 'Choose Font for Printing', face);
  548.     if font <> '' then
  549.         call VRSet EF_1, 'Value', font
  550.  
  551.     drop font face
  552. return
  553.  
  554. /*:VRX         PB_4_Click
  555. */
  556. PB_4_Click: 
  557.     
  558.     /***** Get/Set the job properties for selected printer **************/
  559.     
  560.     rcy = VRMethod( "PRT_1", "JobProperties");
  561. return
  562.  
  563. /*:VRX         PB_5_Click
  564. */
  565. PB_5_Click: 
  566.     call idm_prt_setup_Click
  567. return
  568.  
  569. /*:VRX         PB_7_Click
  570. */
  571. PB_7_Click: 
  572.     
  573.     FileName = VRFileDialog( VRWindow(), "Pick text file to print", "Open", "*.*", , ,  )
  574.     
  575.     if FileName <> '' then
  576.         call VRSet EF_2, 'Value', FileName
  577.  
  578.     drop FileName
  579. return
  580.  
  581. /*:VRX         Print_dlg_Close
  582. */
  583. Print_dlg_Close: 
  584.     call Print_dlg_Fini
  585. return
  586.  
  587. /*:VRX         Print_dlg_Create
  588. */
  589. Print_dlg_Create: 
  590.     call Print_dlg_Init
  591. return
  592.  
  593. /*:VRX         Print_dlg_Fini
  594. */
  595. Print_dlg_Fini: 
  596.     window = VRInfo( "Window" )
  597.     call VRDestroy window
  598.     drop window
  599. return
  600. /*:VRX         Print_dlg_Init
  601. */
  602. Print_dlg_Init: 
  603.     window = VRInfo( "Object" )
  604.     if( \VRIsChildOf( window, "Notebook" ) ) then do
  605.         call VRMethod window, "CenterWindow"
  606.         call VRSet window, "Visible", 1
  607.         call VRMethod window, "Activate"
  608.     end
  609.     drop window
  610. return
  611.  
  612. /*:VRX         Print_dlg_Resize
  613. */
  614. Print_dlg_Resize: 
  615.     call resize_dlg Print_dlg, GB_6
  616. return
  617.  
  618. /*:VRX         PrintItAll
  619. */
  620. PrintItAll: 
  621.     /***** Set the line spacing for printing ****************************/
  622.     
  623.     rcy = VRSet( "PRT_1", "LineSpace", ils);
  624.  
  625.     rcy = VRMethod( "PRT_1", "ResetHeader", 2,,);
  626.  
  627.     /***** Set the texts for printing ***********************************/
  628.     
  629.     txt1 = 'Hello everyone, this is some text in'
  630.     txt2 = 'point which wraps over several lines.'
  631.     txt3 = 'This is so that you can see how the VRPrinter methods work.'
  632.     txt4 = 'We hope that you will find them useful.'
  633.     
  634.     select
  635.         
  636.         /***** If left justified text demo ******************************/
  637.         
  638.         when pstyle = 1 then do
  639.             fnt = 8
  640.             rcy = VRMethod( "PRT_1", "PrintLine", facename, fnt, txt1 facename fnt txt2 txt3 txt4);
  641.             rcy = VRMethod( "PRT_1", "PrintLine", , fnt, '');
  642.             do fnt = 10 to 24 by 2
  643.                 rcy = VRMethod( "PRT_1", "PrintLine", , fnt, txt1 facename fnt txt2 txt3 txt4);
  644.                 rcy = VRMethod( "PRT_1", "PrintLine", , fnt, '');
  645.             end
  646.         end
  647.         
  648.         /***** If right justified text demo *****************************/
  649.         
  650.         when pstyle = 2 then do
  651.             fnt = 8
  652.             rcy = VRMethod( "PRT_1", "PrintRight", facename, fnt, txt1 facename fnt txt2 txt3 txt4);
  653.             rcy = VRMethod( "PRT_1", "PrintLine", , fnt, '');
  654.             do fnt = 10 to 24 by 2
  655.                 rcy = VRMethod( "PRT_1", "PrintRight", , fnt, txt1 facename fnt txt2 txt3 txt4);
  656.                 rcy = VRMethod( "PRT_1", "PrintLine", , fnt, '');
  657.             end
  658.         end
  659.         
  660.         /***** If centred text demo *************************************/
  661.         
  662.         when pstyle = 3 then do
  663.             fnt = 8
  664.             rcy = VRMethod( "PRT_1", "PrintCentered", facename, fnt, txt1 facename fnt txt2 txt3 txt4);
  665.             rcy = VRMethod( "PRT_1", "PrintLine", , fnt, '');
  666.             do fnt = 10 to 24 by 2
  667.                 rcy = VRMethod( "PRT_1", "PrintCentered", , fnt, txt1 facename fnt txt2 txt3 txt4);
  668.                 rcy = VRMethod( "PRT_1", "PrintLine", , fnt, '');
  669.             end
  670.         end
  671.         
  672.         /***** If justified text demo ***********************************/
  673.         
  674.         when pstyle = 4 then do
  675.             fnt = 8
  676.             rcy = VRMethod( "PRT_1", "PrintJustified", facename, fnt, txt1 facename fnt txt2 txt3 txt4);
  677.             rcy = VRMethod( "PRT_1", "PrintLine", , fnt, '');
  678.             do fnt = 10 to 24 by 2
  679.                 rcy = VRMethod( "PRT_1", "PrintJustified", , fnt, txt1 facename fnt txt2 txt3 txt4);
  680.                 rcy = VRMethod( "PRT_1", "PrintLine", , fnt, '');
  681.             end
  682.         end
  683.         
  684.         /***** If print bitmap demo *************************************/
  685.         
  686.         when pstyle = 5 then do
  687.             rcy = VRMethod( "PRT_1", "PrintLine", facename, 14, 'Hello everyone, this is boxed printout of the OS/2 logo');
  688.             rcy = VRMethod( "PRT_1", "PrintBitMap", bmp_name, 40, 20, 100, 80, 200);
  689.             rcy = VRMethod( "PRT_1", "PrintBitMap", bmp_name2, 50, 90, 90, 120, 100);
  690.             rcy = VRMethod( "PRT_1", "NewPage");
  691.             rcy = VRMethod( "PRT_1", "PrintBitMap", bmp_name,,,,, 56);
  692.         end
  693.         
  694.         /***** If print table demo **************************************/
  695.         
  696.         when pstyle = 6 then do
  697.             do cnt = 1 to 6
  698.                 rcy = VRMethod( "PRT_1", "PrintLine", facename, 12, 'Example of printing a table with different styles in each cell');
  699.                 rcy = VRMethod( "PRT_1", "PrintLine",,,'');
  700.                 rcy = VRMethod( "PRT_1", "PrintLine",,,'Table created with StartTable');
  701.                 call WriteTable
  702.                 rcy = VRMethod( "PRT_1", "PrintLine",facename, 12,'');
  703.                 rcy = VRMethod( "PRT_1", "PrintLine", facename, 12, 'Table created with DefineTable');
  704.                 rcy = VRMethod( "PRT_1", "PrintLine",facename, 12,'');
  705.                 call WriteTable3
  706.             end
  707.             rcy = VRMethod( "PRT_1", "PrintLine",facename, 12,'');
  708.             rcy = VRMethod( "PRT_1", "PrintLine", facename, 12, 'Table created with DefineTable');
  709.             rcy = VRMethod( "PRT_1", "PrintLine",facename, 12,'');
  710.             call WriteTable2
  711.         end
  712.         
  713.         /***** If styles demo *******************************************/
  714.         
  715.         when pstyle = 7 then do
  716.             call PrintStyles
  717.         end
  718.         
  719.         /***** If tabbing and goto demo *********************************/
  720.         
  721.         when pstyle = 8 then do
  722.             call PrintTabbedText
  723.         end
  724.  
  725.         when pstyle = 9 then do
  726.             rcy = VRMethod( "PRT_1", "PrintFile", "Courier", 8, text_style, text_file_name);
  727.         end
  728.  
  729.         when pstyle = 10 then do
  730.             rcy = VRMethod( "PRT_1", "PrintObjectImage", "Window1", 20, 20, , , 0);
  731.             rcy = VRMethod( "PRT_1", "NewPage");
  732.  
  733.             ok = VRMethod( "Screen", "ListWindows", "window.")
  734.             if ok = 1 then do
  735.                 found = 0
  736.                 do while( found = 0)
  737.                     idx = random( 1, window.0)
  738.                     w = word( window.idx, 1 )
  739.                     if VRGet( w, "Visible" ) = 1 then do
  740.                         rcy = VRMethod( w, "Activate");
  741.                         rcy = VRMethod( "PRT_1", "PrintLine",facename, 12,'Print' VRGet( w, "Caption" ));
  742.                         rcy = VRMethod( "PRT_1", "PrintWinImage", w, 20, 20, , , 0);
  743.                         found = 1;
  744.                         rcy = VRMethod( "window1", "Activate");
  745.                     end
  746.                 end
  747.             end
  748.             
  749.         end
  750.  
  751.     end
  752.     
  753.     /***** Close the print job ******************************************/
  754.     
  755.     rcy = VRMethod( "PRT_1", "ClosePrintJob");
  756.  
  757. return
  758.  
  759. /*:VRX         PrintStyles
  760. */
  761. PrintStyles: 
  762.     
  763.     wide = VRGet( "PRT_1", "PageWidth");
  764.     high = VRGet( "PRT_1", "PageHeight");
  765.  
  766.     /***** Calculate positions for printing *****************************/
  767.     
  768.     vpos1 = trunc( high / 3) * 2;
  769.     vpos2 = trunc( high / 3);
  770.     vinc = trunc( vpos2/ 3);
  771.  
  772.     by1 = vpos1 
  773.     ty1 = vpos1 + vinc
  774.     by2 = vpos2
  775.     ty2 = vpos2 + vinc
  776.  
  777.     hpos = trunc( wide / 8);
  778.     hinc = trunc( hpos / 3) * 2;
  779.  
  780.     bx = 5;
  781.     tx = bx + hinc;
  782.     
  783.     /***** Say what we are printing *************************************/
  784. /*    
  785.     rcy = VRMethod( "PRT_1", "PrintLine", facename, 10, 'Defined styles for filling');
  786. */  
  787.     /***** print a row of boxes with different styles *******************/
  788.     
  789.     do style = 0 to 7
  790.         rcy = VRMethod( "PRT_1", "PrintBox", bx, by1, tx, ty1, 28, style, "Red", "Blue");
  791.         rcy = VRMethod( "PRT_1", "Goto", bx, by1 - 10);
  792.         rcy = VRMethod( "PRT_1", "PrintLeft", facename, 10, 'Style' style);
  793.         bx = bx + hpos;
  794.         tx = tx + hpos;
  795.     end
  796.  
  797.     bx = 5;
  798.     tx = bx + hinc;
  799.     
  800.     /***** print a row of boxes with different styles *******************/
  801.     
  802.     do style = 8 to 15
  803.         rcy = VRMethod( "PRT_1", "PrintBox", bx, by2, tx, ty2, 28, style, "Pink", "Green");
  804.         rcy = VRMethod( "PRT_1", "Goto", bx, by2 - 10);
  805.         rcy = VRMethod( "PRT_1", "Printleft", facename, 10, 'Style' style);
  806.         bx = bx + hpos;
  807.         tx = tx + hpos;
  808.     end
  809.  
  810. return
  811.  
  812. /*:VRX         PrintTabbedText
  813. */
  814. PrintTabbedText: 
  815.     
  816.     /***** Get the page size ********************************************/
  817.     
  818.     wide = VRGet( "PRT_1", "PageWidth");
  819.     high = VRGet( "PRT_1", "PageHeight");
  820.     
  821.     /***** Calculate the number of tabs *********************************/
  822.     
  823.     numtabs = trunc( wide / 10) - 1;
  824.     
  825.     /***** Print '|' at each tab position *******************************/
  826.     
  827.     rcy = VRMethod( "PRT_1", "PrintLine", facename, 10, 'Tab positions are shown on the next line');
  828.     rcy = VRMethod( "PRT_1", "PrintLine", , , '');
  829.     rcy = VRMethod( "PRT_1", "PrintLeft", , , '|');
  830.  
  831.     do i = 1 to numtabs
  832.         rcy = VRMethod( "PRT_1", "Tab");
  833.         rcy = VRMethod( "PRT_1", "PrintLeft", , , '|');
  834.     end
  835.  
  836.     /***** show some moves **********************************************/
  837.  
  838.     rcy = VRMethod( "PRT_1", "PrintLine", , , '');
  839.     rcy = VRMethod( "PRT_1", "PrintLine", , , '');
  840.  
  841.     rcy = VRMethod( "PRT_1", "PrintLeft", , ,'Here we are');
  842.     rcy = VRMethod( "PRT_1", "MoveX", 10, 0);
  843.     rcy = VRMethod( "PRT_1", "PrintLeft", , ,'1 cm right');
  844.  
  845.     rcy = VRMethod( "PRT_1", "MoveY", -10, 0);
  846.     rcy = VRMethod( "PRT_1", "PrintLeft", , ,'1 cm down');
  847.     rcy = VRMethod( "PRT_1", "MoveY", 5, 1);
  848.     rcy = VRMethod( "PRT_1", "PrintLeft", , ,'5 pts up');
  849.     rcy = VRMethod( "PRT_1", "MoveY", -5, 1);
  850.     rcy = VRMethod( "PRT_1", "PrintLeft", , ,'5 pts down');
  851.  
  852.     /***** Go to the bottom of the page *********************************/
  853.     
  854.     rcy = VRMethod( "PRT_1", "PrintLine", , , '');
  855.  
  856.     rcy = VRMethod( "PRT_1", "MoveX", 100, 0);
  857.     rcy = VRMethod( "PRT_1", "PrintLeft", , ,'10 cm right');
  858.  
  859.     rcy = VRMethod( "PRT_1", "MoveX", -50, 0);
  860.     rcy = VRMethod( "PRT_1", "PrintLeft", , ,'5 cm left');
  861.  
  862.     rcy = VRMethod( "PRT_1", "PrintLine", , , '');
  863.     rcy = VRMethod( "PRT_1", "PrintLine", , , '');
  864.  
  865.     rcy = VRMethod( "PRT_1", "PrintLine", , 20, 'The End');
  866.  
  867. return
  868.  
  869.     rcy = VRMethod( "PRT_1", "Goto", 0, 10);
  870.     rcy = VRMethod( "PRT_1", "PrintLeft", , , 'On the next page we show 20 random moves in an area within 200mm of the top margin and right margin');
  871.     rcy = VRMethod( "PRT_1", "NewPage");
  872.  
  873.     vinc = high - 20;
  874.     hinc = wide - 20;
  875.     
  876.     /***** Do 20 random jumps around the page ***************************/
  877.     
  878.     do i = 1 to 20
  879.         x = random( 5, hinc)
  880.         y = random( 5, vinc)
  881.         rcy = VRMethod( "PRT_1", "Goto", x, y);
  882.         rcy = VRMethod( "PRT_1", "PrintLeft",,,'Jump' i x','y);
  883.     end
  884.  
  885. return
  886.  
  887. /*:VRX         Quit
  888. */
  889. Quit:
  890.     window = VRWindow()
  891.     call VRSet window, "Shutdown", 1
  892.     drop window
  893. return
  894.  
  895. /*:VRX         resize_dlg
  896. */
  897. resize_dlg:  procedure
  898.  
  899.     dlg = arg(1)
  900.     gbox = arg(2)
  901.  
  902.     h1 = VRGet( dlg, 'InteriorHeight');
  903.     h2 = VRGet( gbox, 'Height');
  904.     w1 = VRGet( dlg, 'Width');
  905.     w2 = VRGet( gbox, 'Width');
  906.     if w1 < w2 then
  907.         l = 0
  908.     else
  909.         l = trunc(( w1 - w2) / 2)
  910.  
  911.     if h1 < h2 then
  912.         t = 0
  913.     else
  914.         t = trunc(( h1 - h2) / 2)
  915.  
  916.     call VRSet gbox, 'Left', l
  917.     call VRSet gbox, 'Top', t
  918.  
  919. return
  920.  
  921. /*:VRX         table_dlg_Close
  922. */
  923. table_dlg_Close: 
  924.     call table_dlg_Fini
  925. return
  926.  
  927. /*:VRX         table_dlg_Create
  928. */
  929. table_dlg_Create: 
  930.     call table_dlg_Init
  931. return
  932.  
  933. /*:VRX         table_dlg_Fini
  934. */
  935. table_dlg_Fini: 
  936.     window = VRInfo( "Window" )
  937.     call VRDestroy window
  938.     drop window
  939. return
  940. /*:VRX         table_dlg_Init
  941. */
  942. table_dlg_Init: 
  943.     window = VRInfo( "Object" )
  944.     if( \VRIsChildOf( window, "Notebook" ) ) then do
  945.         call VRMethod window, "CenterWindow"
  946.         call VRSet window, "Visible", 1
  947.         call VRMethod window, "Activate"
  948.     end
  949.     drop window
  950. return
  951.  
  952. /*:VRX         table_dlg_Resize
  953. */
  954. table_dlg_Resize: 
  955.     call resize_dlg table_dlg, GB_13
  956. return
  957.  
  958. /*:VRX         Window1_Close
  959. */
  960. Window1_Close:
  961.     call Quit
  962. return
  963.  
  964. /*:VRX         WriteTable
  965. */
  966. WriteTable: 
  967.     
  968.     /***** Initialise a table *******************************************/
  969.     
  970.     rcy = VRMethod( "PRT_1", "StartTable", tstyle, tthick, 3, 10, 45, 50, 40);
  971.  
  972.     if rcy then do
  973.         
  974.         /***** Start printing a row *************************************/
  975.         
  976.         rcy = VRMethod( "PRT_1", "StartRow");
  977.  
  978.         /***** write to col 1 *******************************************/
  979.         
  980.  
  981.         rcy = VRMethod( "PRT_1", "StartCol", 1);
  982.         rcy = VRMethod( "PRT_1", "PrintRight", 'Helvetica', 10, 'This is some text in the first column. It is not very long,');
  983.         
  984.         /***** write to col 2 *******************************************/
  985.         
  986.         rcy = VRMethod( "PRT_1", "StartCol", 2);
  987.         rcy = VRMethod( "PRT_1", "PrintJustified", 'Helvetica Bold', 10, 'This is some text in the second column. It is not very long,');
  988.         rcy = VRMethod( "PRT_1", "PrintJustified",,,'This text has several lines and with a bit of luck should force a new page.');
  989.         rcy = VRMethod( "PRT_1", "PrintJustified",,,'If it does then we have a test of a cell rolling over from one page to the next and we will not have to write any more.');
  990.         
  991.         /***** write to col 3 *******************************************/
  992.         
  993.         rcy = VRMethod( "PRT_1", "StartCol", 3);
  994.         rcy = VRMethod( "PRT_1", "PrintCentered", 'Helvetica Bold', 14, 'This is some text in the third column. It is not very long,');
  995.         
  996.         /***** print out the row ****************************************/
  997.         
  998.         rcy = VRMethod( "PRT_1", "EndRow");
  999.         
  1000.         /***** start the next row ***************************************/
  1001.         
  1002.         rcy = VRMethod( "PRT_1", "StartRow");
  1003.         
  1004.         /***** write to col 1 *******************************************/
  1005.         
  1006.         rcy = VRMethod( "PRT_1", "StartCol", 1);
  1007.         rcy = VRMethod( "PRT_1", "PrintRight", 'Times New Roman', 10, 'This is some text in the first column. It is not very long,');
  1008.         
  1009.         /***** write to col 2 *******************************************/
  1010.         
  1011.         rcy = VRMethod( "PRT_1", "StartCol", 2);
  1012.         rcy = VRMethod( "PRT_1", "PrintLeft", 'Helvetica Bold', 10, 'This is some text in the second column. It is not very long and should be left justified.');
  1013.         rcy = VRMethod( "PRT_1", "PrintCentered",,,'This text has several lines and with a bit of luck should be centred.');
  1014.         rcy = VRMethod( "PRT_1", "PrintJustified",,,'This text here was designed to be justified and should roll over several lines, of course the last line will be left aligned.');
  1015.         rcy = VRMethod( "PRT_1", "PrintRight",,,'This last bit of text should finally show all the styles in one cell as it is right aligned.');
  1016.         
  1017.         /***** write to col 3 *******************************************/
  1018.         
  1019.         rcy = VRMethod( "PRT_1", "StartCol", 3);
  1020.         rcy = VRMethod( "PRT_1", "PrintJustified", 'Times New Roman', 8, 'This is some text in the third column. It is not very long,');
  1021.         
  1022.         /***** print out the row ****************************************/
  1023.         
  1024.         rcy = VRMethod( "PRT_1", "EndRow");
  1025.         
  1026.         /***** Terminate the table **************************************/
  1027.         
  1028.         rcy = VRMethod( "PRT_1", "EndTable");
  1029.  
  1030.     end
  1031.     else
  1032.         rcy = VRMethod( "PRT_1", "PrintLeft", 'Helvetica Bold', 14, 'ERROR - Failed to create the table...');
  1033.  
  1034. return
  1035.  
  1036. /*:VRX         WriteTable2
  1037. */
  1038. WriteTable2: 
  1039.  
  1040.  
  1041. /***** Define the table ********************************/
  1042.  
  1043. table.0 = 9
  1044. table.1 = tstyle
  1045. table.2 = tthick
  1046. table.3 = 1
  1047. table.4 = thstyle
  1048. table.5 = ththick
  1049. table.6 = 1
  1050. table.7 = 12
  1051. table.8 = 'Helvetica Bold'
  1052. table.9 = 10
  1053.  
  1054. /***** Make 3 columns ***********************************/
  1055.  
  1056. Cols.0.0 = 3
  1057.  
  1058. Cols.1.1 = 45
  1059. Cols.1.2 = 'Index'
  1060.  
  1061. Cols.2.1 = 50
  1062. Cols.2.2 = '$cText'
  1063.  
  1064. Cols.3.1 = 40
  1065. Cols.3.2 = '$rRandom N°'
  1066.  
  1067. rcy = VRMethod( "PRT_1", "DefineTable", "table.", "Cols.");
  1068.  
  1069. /**** Start printing in the table **********************************/
  1070.  
  1071. if rcy then do
  1072.     do i = 1 to 20
  1073.         rcy = VRMethod( "PRT_1", "StartRow");
  1074.         rcy = VRMethod( "PRT_1", "StartCol", 1)
  1075.         rcy = VRMethod( "PRT_1", "PrintLeft", 'Helvetica Bold', 10, i);
  1076.         rcy = VRMethod( "PRT_1", "StartCol", 2)
  1077.         rcy = VRMethod( "PRT_1", "PrintCentered", 'Helvetica Italic', 10, 'Some italic text');
  1078.         rcy = VRMethod( "PRT_1", "StartCol", 3)
  1079.         rcy = VRMethod( "PRT_1", "PrintRight", 'Helvetica', 10, random( 20000));
  1080.         rcy = VRMethod( "PRT_1", "EndRow");
  1081.     end
  1082.     rcy = VRMethod( "PRT_1", "EndTable");
  1083. end    
  1084. else
  1085.     rcy = VRMethod( "PRT_1", "PrintLine", 'Helvetica Bold', 14, 'ERROR - Failed to create the table...');
  1086.  
  1087. return
  1088.  
  1089. /*:VRX         WriteTable3
  1090. */
  1091. WriteTable3: 
  1092.  
  1093.     /***** Define the table ********************************/
  1094.  
  1095.     table.0 = 15
  1096.     table.1 = tstyle
  1097.     table.2 = tthick
  1098.     table.3 = 1
  1099.     table.4 = thstyle
  1100.     table.5 = ththick
  1101.     table.6 = 1
  1102.     table.7 = 12
  1103.     table.8 = 'Helvetica Bold'
  1104.     table.9 = 10
  1105.     table.10 = ttcolor
  1106.     table.11 = tlcolor
  1107.     table.12 = tfcolor
  1108.     table.13 = thtcolor
  1109.     table.14 = thlcolor
  1110.     table.15 = thfcolor
  1111.  
  1112.     /***** Make 3 columns ***********************************/
  1113.  
  1114.     Cols.0.0 = 3
  1115.  
  1116.     Cols.1.1 = 45
  1117.     Cols.1.2 = 'Column 1'
  1118.  
  1119.     Cols.2.1 = 50
  1120.     Cols.2.2 = '$cColumn 2'
  1121.  
  1122.     Cols.3.1 = 40
  1123.     Cols.3.2 = '$rColumn 3'
  1124.  
  1125.     rcy = VRMethod( "PRT_1", "DefineTable", "table.", "Cols.");
  1126.  
  1127.     if rcy then do
  1128.  
  1129.         /***** Change column headers for following pages ****************/
  1130.         
  1131.         call VRMethod "PRT_1", "ResetColHeader", 1, "New header 1"
  1132.         call VRMethod "PRT_1", "ResetColHeader", 2, "$rNew header 2"
  1133.         call VRMethod "PRT_1", "ResetColHeader", 3, "$cNew header 3"
  1134.  
  1135.         /***** Start printing a row *************************************/
  1136.         
  1137.         rcy = VRMethod( "PRT_1", "StartRow");
  1138.  
  1139.         /***** write to col 1 *******************************************/
  1140.         
  1141.  
  1142.         rcy = VRMethod( "PRT_1", "StartCol", 1);
  1143.         rcy = VRMethod( "PRT_1", "PrintRight", 'Helvetica', 10, 'This is some text in the first column. It is not very long,');
  1144.         
  1145.         /***** write to col 2 *******************************************/
  1146.         
  1147.         rcy = VRMethod( "PRT_1", "StartCol", 2);
  1148.         rcy = VRMethod( "PRT_1", "PrintJustified", 'Helvetica Bold', 10, 'This is some text in the second column. It is not very long,');
  1149.         rcy = VRMethod( "PRT_1", "PrintJustified",,,'This text has several lines and with a bit of luck should force a new page.');
  1150.         rcy = VRMethod( "PRT_1", "PrintJustified",,,'If it does then we have a test of a cell rolling over from one page to the next and we will not have to write any more.');
  1151.         
  1152.         /***** write to col 3 *******************************************/
  1153.         
  1154.         rcy = VRMethod( "PRT_1", "StartCol", 3);
  1155.         rcy = VRMethod( "PRT_1", "PrintCentered", 'Helvetica Bold', 14, 'This is some text in the third column. It is not very long,');
  1156.         
  1157.         /***** print out the row ****************************************/
  1158.         
  1159.         rcy = VRMethod( "PRT_1", "EndRow");
  1160.         
  1161.         /***** start the next row ***************************************/
  1162.         
  1163.         rcy = VRMethod( "PRT_1", "StartRow");
  1164.         
  1165.         /***** write to col 1 *******************************************/
  1166.         
  1167.         rcy = VRMethod( "PRT_1", "StartCol", 1);
  1168.         rcy = VRMethod( "PRT_1", "PrintRight", 'Times New Roman', 10, 'This is some text in the first column. It is not very long,');
  1169.         
  1170.         /***** write to col 2 *******************************************/
  1171.         
  1172.         rcy = VRMethod( "PRT_1", "StartCol", 2);
  1173.         rcy = VRMethod( "PRT_1", "PrintLeft", 'Helvetica Bold', 10, 'This is some text in the second column. It is not very long and should be left justified.');
  1174.         rcy = VRMethod( "PRT_1", "PrintCentered",,,'This text has several lines and with a bit of luck should be centred.');
  1175.         rcy = VRMethod( "PRT_1", "PrintJustified",,,'This text here was designed to be justified and should roll over several lines, of course the last line will be left aligned.');
  1176.         rcy = VRMethod( "PRT_1", "PrintRight",,,'This last bit of text should finally show all the styles in one cell as it is right aligned.');
  1177.         
  1178.         /***** write to col 3 *******************************************/
  1179.         
  1180.         rcy = VRMethod( "PRT_1", "StartCol", 3);
  1181.         rcy = VRMethod( "PRT_1", "PrintJustified", 'Times New Roman', 8, 'This is some text in the third column. It is not very long,');
  1182.         
  1183.         /***** print out the row ****************************************/
  1184.         
  1185.         rcy = VRMethod( "PRT_1", "EndRow");
  1186.         
  1187.         /***** Terminate the table **************************************/
  1188.         
  1189.         rcy = VRMethod( "PRT_1", "EndTable");
  1190.  
  1191.     end
  1192.     else
  1193.         rcy = VRMethod( "PRT_1", "PrintLeft", 'Helvetica Bold', 14, 'ERROR - Failed to create the table...');
  1194.  
  1195. return
  1196.  
  1197.