home *** CD-ROM | disk | FTP | other *** search
/ OS/2 Shareware BBS: 18 REXX / 18-REXX.zip / vrprt21.zip / VRPrMarg.VRM < prev    next >
Text File  |  1995-10-15  |  5KB  |  218 lines

  1. /* Custom mainline for macro */
  2.  
  3.     signal on SYNTAX name _VRESyntax
  4.     signal _VREMain
  5.  
  6. _VRESyntax:
  7.     parse source . . _VRESourceSpec
  8.     call VRMessage "", "Syntax error in" _VRESourceSpec "line" SIGL":" ErrorText(rc), "Error!"
  9.     call VRFini
  10.     exit 32000
  11.  
  12. _VREMain:
  13. /*:VRX         Main
  14. */
  15. /*  Main
  16. */
  17. Main:
  18. /*  Process the arguments.
  19.     Get the parent window.
  20. */
  21.     parse source . calledAs .
  22.     parent = ""
  23.     argCount = arg()
  24.     argOff = 0
  25.     if( calledAs \= "COMMAND" )then do
  26.         if argCount >= 1 then do
  27.             parent = arg(1)
  28.             argCount = argCount - 1
  29.             argOff = 1
  30.         end
  31.     end; else do
  32.         call VROptions 'ImplicitNames'
  33.     end
  34.     InitArgs.0 = argCount
  35.     if( argCount > 0 )then do i = 1 to argCount
  36.         InitArgs.i = arg( i + argOff )
  37.     end
  38.     drop calledAs argCount argOff
  39.  
  40. /*  Load the windows
  41. */
  42.     call VRInit
  43.     parse source . . spec
  44.     _VREPrimaryWindowPath = ,
  45.         VRParseFileName( spec, "dpn" ) || ".VRW"
  46.     _VREPrimaryWindow = ,
  47.         VRLoad( parent, _VREPrimaryWindowPath )
  48.     drop parent spec
  49.     if( _VREPrimaryWindow == "" )then do
  50.         call VRMessage "", "Cannot load window:" VRError(), ,
  51.             "Error!"
  52.         _VREReturnValue = 32000
  53.         signal _VRELeaveMain
  54.     end
  55.  
  56. /*  Process events
  57. */
  58.     call Init
  59.     signal on halt
  60.     do while( \ VRGet( _VREPrimaryWindow, "Shutdown" ) )
  61.         _VREEvent = VREvent()
  62.         interpret _VREEvent
  63.     end
  64. _VREHalt:
  65.     _VREReturnValue = Fini()
  66.     call VRDestroy _VREPrimaryWindow
  67. _VRELeaveMain:
  68.     call VRFini
  69. exit _VREReturnValue
  70.  
  71. VRLoadSecondary:
  72.     __vrlsWait = abbrev( 'WAIT', translate(arg(2)), 1 )
  73.     if __vrlsWait then do
  74.         call VRFlush
  75.     end
  76.     __vrlsHWnd = VRLoad( VRWindow(), VRWindowPath(), arg(1) )
  77.     if __vrlsHWnd = '' then signal __vrlsDone
  78.     if __vrlsWait \= 1 then signal __vrlsDone
  79.     call VRSet __vrlsHWnd, 'WindowMode', 'Modal' 
  80.     __vrlsTmp = __vrlsWindows.0
  81.     if( DataType(__vrlsTmp) \= 'NUM' ) then do
  82.         __vrlsTmp = 1
  83.     end
  84.     else do
  85.         __vrlsTmp = __vrlsTmp + 1
  86.     end
  87.     __vrlsWindows.__vrlsTmp = VRWindow( __vrlsHWnd )
  88.     __vrlsWindows.0 = __vrlsTmp
  89.     do while( VRIsValidObject( VRWindow() ) = 1 )
  90.         __vrlsEvent = VREvent()
  91.         interpret __vrlsEvent
  92.     end
  93.     __vrlsTmp = __vrlsWindows.0
  94.     __vrlsWindows.0 = __vrlsTmp - 1
  95.     call VRWindow __vrlsWindows.__vrlsTmp 
  96.     __vrlsHWnd = ''
  97. __vrlsDone:
  98. return __vrlsHWnd
  99.  
  100. /*:VRX         dlg_Close
  101. */
  102. dlg_Close:
  103.     call Quit
  104. return
  105.  
  106. /*:VRX         Fini
  107. */
  108. Fini:
  109.     window = VRWindow()
  110.     call VRSet window, "Visible", 0
  111.     drop window
  112. return ret
  113.  
  114. /*:VRX         Halt
  115. */
  116. Halt:
  117.     signal _VREHalt
  118. return
  119.  
  120. /*:VRX         Init
  121. */
  122. Init:
  123.  
  124.     ret = '';
  125.  
  126.     if InitArgs.0 < 2 then
  127.         call Quit;
  128.  
  129.     object = InitArgs.1;
  130.     method = InitArgs.2;
  131.  
  132.     window = VRWindow()
  133.     ok = VRSet( window, "Caption", method )
  134.     call VRMethod window, "CenterWindow"
  135.     call VRSet window, "Visible", 1
  136.     call VRMethod window, "Activate"
  137.     drop window
  138.  
  139.     if method = "PrintBitMap" then do
  140.         call VRSet "EF_File", "Enabled", 1
  141.         call VRSet "PB_File", "Enabled", 1
  142.         call VRSet "CB_1", "Enabled", 1
  143.         call VRSet "SPIN_Fill", "Enabled", 0
  144.     end
  145.     else do
  146.         call VRSet "EF_File", "Enabled", 0
  147.         call VRSet "PB_File", "Enabled", 0
  148.         call VRSet "CB_1", "Enabled", 0
  149.         call VRSet "SPIN_Fill", "Enabled", 1
  150.     end
  151.     if method = "PrintBox" then
  152.         call VRSet "SPIN_line", "Value", 14
  153.  
  154. return
  155.  
  156. /*:VRX         PB_accept_Click
  157. */
  158. PB_accept_Click: 
  159.     left = VRGet( "SPIN_left", "Value");
  160.     right = VRGet( "SPIN_right", "Value");
  161.     top = VRGet( "SPIN_top", "Value");
  162.     bottom = VRGet( "SPIN_bottom", "Value");
  163.     fill = VRGet( "SPIN_fill", "Value");
  164.     line = VRGet( "SPIN_line", "Value");
  165.     filename = VRGet( "EF_File", "Value");
  166.     set = VRGet( "CB_1", "Set");
  167.     if set then
  168.         filename = '"' || filename || '"'
  169.  
  170.     lc = VRGet( "DDCB_lc", "Value");
  171.     if VRMethod( "DDCB_lc", "FindString", lc) > 0 then
  172.         lc = '"' || lc || '"'
  173.     fc = VRGet( "DDCB_fc", "Value");
  174.     if VRMethod( "DDCB_fc", "FindString", fc) > 0 then
  175.         fc = '"' || fc || '"'
  176.  
  177.     select
  178.         when method = "SetMargins" then
  179.             tag_str = left',' right',' top',' bottom',' line',' fill',' lc',' fc ");"
  180.     
  181.         when method = "PrintBox" then
  182.             tag_str = left',' bottom',' right',' top',' line',' fill',' lc',' fc ");"
  183.  
  184.         when method = "PrintBitMap" then
  185.             tag_str = filename',' left',' bottom',' right',' top',' line',' lc ");"
  186.  
  187.         otherwise
  188.             tag_str = ''
  189.     end
  190.     ret = 'ok = VRMethod( "' || object ||'", "' || method || '",' tag_str
  191.     call Quit
  192. return
  193.  
  194. /*:VRX         PB_Cancel_Click
  195. */
  196. PB_Cancel_Click: 
  197.     ret = '';
  198.     call Quit;
  199. return
  200.  
  201. /*:VRX         PB_File_Click
  202. */
  203. PB_File_Click: 
  204.     FileName = VRFileDialog( VRWindow(), "Choose Bitmap", "Open", "*.bmp", , ,  )
  205.     if FileName <> '' then
  206.         call VRSet "EF_File", "Value", FileName
  207.     drop FileName
  208. return
  209.  
  210. /*:VRX         Quit
  211. */
  212. Quit:
  213.     window = VRWindow()
  214.     call VRSet window, "Shutdown", 1
  215.     drop window
  216. return
  217.  
  218.