home *** CD-ROM | disk | FTP | other *** search
/ OS/2 Shareware BBS: 18 REXX / 18-REXX.zip / vxcliser.zip / VXREXX.2 / MACROS / SETPROPS.VRM < prev    next >
Text File  |  1994-12-23  |  8KB  |  317 lines

  1. /* Custom mainline for macro */
  2.  
  3.     call RXFuncAdd "VRLoadFuncs", "VROBJ", "VRLoadFuncs"
  4.     call VRLoadFuncs
  5.  
  6.     _VREVersion = SubWord( VRVersion( "VRObj" ), 1, 1 )
  7.     if( _VREVersion < 2.10 )then do
  8.         call VRMessage "", "This program requires VX-REXX version 2.1 to run.", "Error!"
  9.         return 32000
  10.     end
  11.  
  12.  
  13.     signal on SYNTAX name _VRESyntax
  14.     signal _VREMain
  15.  
  16. _VRESyntax:
  17.     parse source . . _VRESourceSpec
  18.     call VRMessage "", "Syntax error in" _VRESourceSpec "line" SIGL":" ErrorText(rc), "Error!"
  19.     call VRFini
  20.     exit 32000
  21.  
  22. _VREMain:
  23. /*:VRX         Main
  24. */
  25. /*  Main
  26. */
  27. Main:
  28. /*  Process the arguments.
  29.     Get the parent window.
  30. */
  31.     parse source . calledAs .
  32.     parent = ""
  33.     argCount = arg()
  34.     argOff = 0
  35.     if( calledAs \= "COMMAND" )then do
  36.         if argCount >= 1 then do
  37.             parent = arg(1)
  38.             argCount = argCount - 1
  39.             argOff = 1
  40.         end
  41.     end
  42.     InitArgs.0 = argCount
  43.     if( argCount > 0 )then do i = 1 to argCount
  44.         InitArgs.i = arg( i + argOff )
  45.     end
  46.     drop calledAs argCount argOff
  47.  
  48. /*  Load the windows
  49. */
  50.     call VRInit
  51.     parse source . . spec
  52.     _VREPrimaryWindowPath = ,
  53.         VRParseFileName( spec, "dpn" ) || ".VRW"
  54.     _VREPrimaryWindow = ,
  55.         VRLoad( parent, _VREPrimaryWindowPath )
  56.     drop parent spec
  57.     if( _VREPrimaryWindow == "" )then do
  58.         call VRMessage "", "Cannot load window:" VRError(), ,
  59.             "Error!"
  60.         _VREReturnValue = 32000
  61.         signal _VRELeaveMain
  62.     end
  63.  
  64. /*  Process events
  65. */
  66.     call Init
  67.     signal on halt
  68.     do while( \ VRGet( _VREPrimaryWindow, "Shutdown" ) )
  69.         _VREEvent = VREvent()
  70.         interpret _VREEvent
  71.     end
  72. _VREHalt:
  73.     _VREReturnValue = Fini()
  74.     call VRDestroy _VREPrimaryWindow
  75. _VRELeaveMain:
  76.     call VRFini
  77. exit _VREReturnValue
  78.  
  79. VRLoadSecondary: procedure
  80.     name = arg( 1 )
  81.  
  82.     window = VRLoad( VRWindow(), VRWindowPath(), name )
  83.     call VRMethod window, "CenterWindow"
  84.     call VRSet window, "Visible", 1
  85.     call VRMethod window, "Activate"
  86. return window
  87.  
  88. /*:VRX         DisplayValue
  89. */
  90. /*  Display the value of the selected property for the
  91.     selected object.
  92. */ 
  93. DisplayValue: procedure
  94.     property = VRGet( "LB_Props", "SelectedString" )
  95.     if( property = "" ) then do
  96.         signal DisplayDone
  97.     end
  98.     object = VRGet( "LB_Objects", "Selected" )
  99.     if( object = 0 ) then do
  100.         signal DisplayDone
  101.     end
  102.     object = VRMethod( "LB_Objects", "GetItemData", object )
  103.     value = VRGet( object, property )
  104.     call VRSet "EF_Value", "Value", value
  105.     call VRSet "EF_Value", "SelectedStart", 1
  106.     call VRSet "EF_Value", "SelectedEnd", Length( value ) + 1 
  107.     call VRMethod "EF_Value", "SetFocus"
  108. DisplayDone:
  109. return
  110.  
  111. /*:VRX         Fini
  112. */
  113. Fini:
  114.     window = VRWindow()
  115.     call VRSet window, "Visible", 0
  116.     drop window
  117. return 0
  118.  
  119. /*:VRX         Halt
  120. */
  121. Halt:
  122.     signal _VREHalt
  123. return
  124.  
  125. /*:VRX         Init
  126. */
  127. /*  Assume invoked as a VRXEDIT macro so
  128.         InitArgs.0 = 2
  129.         InitArgs.1 = <object>
  130.         InitArgs.2 = <editWindow>
  131. */
  132. Init: procedure expose InitArgs. CurProp
  133.     window = VRWindow()
  134.     call VRMethod window, "CenterWindow"
  135.  
  136.     /*  Operate on the object under the pop-up, or on 
  137.         all selected items if the pop-up was on a selected  
  138.         item.
  139.     */
  140.     call VRMethod InitArgs.2, "GetSelectedRoots", "objects."
  141.     i = 1
  142.     do while( i <= objects.0 )
  143.         if( objects.i = InitArgs.1 ) then do
  144.             leave
  145.         end
  146.         i = i + 1
  147.     end
  148.     if( i > objects.0 ) then do
  149.         objects.1 = InitArgs.1
  150.         objects.0 = 1
  151.     end
  152.     do i = 1 to objects.0
  153.         call VRMethod "LB_Objects", "AddString",,
  154.                       VRGet( objects.i, "Name" ),, objects.i
  155.     end
  156.  
  157.     /*  Enable PB_SetAll only if all objects are of the same class.
  158.     */
  159.     class = VRGet( objects.1, "ClassName" )
  160.     i = 2
  161.     do while( i <= objects.0 )
  162.         if( VRGet( objects.i, "ClassName" ) <> class ) then do
  163.             leave
  164.         end
  165.         i = i + 1
  166.     end
  167.     if( i > objects.0 ) then do
  168.         call VRSet "PB_SetAll", "Enabled", 1
  169.     end
  170.  
  171.     CurProp = ""
  172.     call VRSet "LB_Objects", "Selected", 1
  173.     call VRSet window, "Visible", 1
  174.     call VRMethod window, "Activate"
  175. return
  176.  
  177. /*:VRX         LB_Objects_Click
  178. */
  179. LB_Objects_Click:
  180.     call ListProps VRMethod( "LB_Objects", "GetItemData", VRGet( "LB_Objects", "Selected" ) )
  181.     call DisplayValue
  182. return
  183.  
  184. /*:VRX         LB_Props_Click
  185. */
  186. LB_Props_Click:
  187.     CurProp = VRGet( "LB_Props", "SelectedString" )
  188.     call DisplayValue
  189. return
  190.  
  191. /*:VRX         ListProps
  192. */
  193. ListProps: procedure expose CurProp
  194.     parse arg object
  195.  
  196.     /*  List properties which are not read only.
  197.     */
  198.     call VRSet "LB_Props", "Painting", 0
  199.     call VRMethod "LB_Props", "Clear"
  200.     call VRMethod object, "ListProperties", "list.", "Saveable" 
  201.     call VRMethod "LB_Props", "AddStringList", "list."
  202.     call VRMethod object, "ListProperties", "list.", "Events" 
  203.     do i = 1 to list.0
  204.         call VRMethod "LB_Props", "DeleteString", list.i
  205.     end
  206.     call VRMethod object, "ListProperties", "list.", "ReadOnly" 
  207.     do i = 1 to list.0
  208.         call VRMethod "LB_Props", "DeleteString", list.i
  209.     end
  210.     call VRSet "LB_Props", "Painting", 1
  211.  
  212.     /*  Set the selected property for the new object to
  213.         the current property.
  214.     */
  215.     pos = VRMethod( "LB_Props", "FindString", CurProp, , "Exact" )
  216.     if( pos > 0 ) then do
  217.         call VRSet "LB_Props", "Selected", pos    
  218.     end    
  219. return
  220.  
  221. /*:VRX         PB_Cancel_Click
  222. */
  223. PB_Cancel_Click:
  224.     call VRDestroy "SW_1"
  225. return
  226.  
  227. /*:VRX         PB_Edit_Click
  228. */
  229. PB_Edit_Click:
  230.     call VRLoadSecondary "SW_1"
  231.     call VRSet "MLE_Edit", "Value", VRGet( "EF_Value", "Value" )
  232. return
  233.  
  234. /*:VRX         PB_OK_Click
  235. */
  236. PB_OK_Click:
  237.     call VRSet "EF_Value", "Value", VRGet( "MLE_Edit", "Value" )        
  238.     call VRDestroy "SW_1"
  239. return
  240.  
  241. /*:VRX         PB_Set_Click
  242. */
  243. PB_Set_Click:
  244.     property = VRGet( "LB_Props", "SelectedString" )
  245.     if( property = "" ) then do
  246.         signal SetDone
  247.     end
  248.     if( translate( property ) = "NAME" )then do
  249.         msg = "The object name cannot be changed using this editor."
  250.         call VRMessage VRWindow(), msg, "Property editor"
  251.         signal SetDone
  252.     end
  253.     index = VRGet( "LB_Objects", "Selected" )
  254.     if( index = 0 ) then do
  255.         signal SetDone
  256.     end
  257.  
  258.     object = VRMethod( "LB_Objects", "GetItemData", index )
  259.     call VRSet object, property, VRGet( "EF_Value", "Value" )
  260.     if( index < VRGet( "LB_Objects", "Count" ) ) then do
  261.         index = index + 1
  262.     end
  263.     else do
  264.         index = 1
  265.     end
  266.     call VRSet "LB_Objects", "Selected", index
  267.  
  268. SetDone:
  269.     drop property index object
  270. return
  271.  
  272. /*:VRX         PB_SetAll_Click
  273. */
  274. PB_SetAll_Click:
  275.     property = VRGet( "LB_Props", "SelectedString" )
  276.     if( property = "" ) then do
  277.         signal SetAllDone
  278.     end
  279.     if( translate( property ) = "NAME" )then do
  280.         msg = "The object name cannot be changed using this editor."
  281.         call VRMessage VRWindow(), msg, "Property editor"
  282.         signal SetDone
  283.     end
  284.  
  285.     value = VRGet( "EF_Value", "Value" )
  286.     call VRMethod "LB_Objects", "GetItemDataList", "objects."
  287.     do i = 1 to objects.0
  288.         call VRSet objects.i, property, value
  289.     end
  290.  
  291. SetAllDone:
  292.     drop property value objects. i
  293. return
  294.  
  295.  
  296. /*:VRX         Quit
  297. */
  298. Quit:
  299.     window = VRWindow()
  300.     call VRSet window, "Shutdown", 1
  301.     drop window
  302. return
  303.  
  304. /*:VRX         SW_1_Close
  305. */
  306. SW_1_Close:
  307.     window = VRInfo( "Object" )
  308.     call VRDestroy window
  309.     drop window
  310. return
  311. /*:VRX         Window1_Close
  312. */
  313. Window1_Close:
  314.     call Quit
  315. return
  316.  
  317.