home *** CD-ROM | disk | FTP | other *** search
/ OS/2 Shareware BBS: 18 REXX / 18-REXX.zip / vxcliser.zip / VXREXX.2 / MACROS / SETPROPS / SETPROPS.VRX < prev    next >
Text File  |  1994-12-23  |  7KB  |  295 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         DisplayValue
  67. */
  68. /*  Display the value of the selected property for the
  69.     selected object.
  70. */ 
  71. DisplayValue: procedure
  72.     property = VRGet( "LB_Props", "SelectedString" )
  73.     if( property = "" ) then do
  74.         signal DisplayDone
  75.     end
  76.     object = VRGet( "LB_Objects", "Selected" )
  77.     if( object = 0 ) then do
  78.         signal DisplayDone
  79.     end
  80.     object = VRMethod( "LB_Objects", "GetItemData", object )
  81.     value = VRGet( object, property )
  82.     call VRSet "EF_Value", "Value", value
  83.     call VRSet "EF_Value", "SelectedStart", 1
  84.     call VRSet "EF_Value", "SelectedEnd", Length( value ) + 1 
  85.     call VRMethod "EF_Value", "SetFocus"
  86. DisplayDone:
  87. return
  88.  
  89. /*:VRX         Fini
  90. */
  91. Fini:
  92.     window = VRWindow()
  93.     call VRSet window, "Visible", 0
  94.     drop window
  95. return 0
  96.  
  97. /*:VRX         Halt
  98. */
  99. Halt:
  100.     signal _VREHalt
  101. return
  102.  
  103. /*:VRX         Init
  104. */
  105. /*  Assume invoked as a VRXEDIT macro so
  106.         InitArgs.0 = 2
  107.         InitArgs.1 = <object>
  108.         InitArgs.2 = <editWindow>
  109. */
  110. Init: procedure expose InitArgs. CurProp
  111.     window = VRWindow()
  112.     call VRMethod window, "CenterWindow"
  113.  
  114.     /*  Operate on the object under the pop-up, or on 
  115.         all selected items if the pop-up was on a selected  
  116.         item.
  117.     */
  118.     call VRMethod InitArgs.2, "GetSelectedRoots", "objects."
  119.     i = 1
  120.     do while( i <= objects.0 )
  121.         if( objects.i = InitArgs.1 ) then do
  122.             leave
  123.         end
  124.         i = i + 1
  125.     end
  126.     if( i > objects.0 ) then do
  127.         objects.1 = InitArgs.1
  128.         objects.0 = 1
  129.     end
  130.     do i = 1 to objects.0
  131.         call VRMethod "LB_Objects", "AddString",,
  132.                       VRGet( objects.i, "Name" ),, objects.i
  133.     end
  134.  
  135.     /*  Enable PB_SetAll only if all objects are of the same class.
  136.     */
  137.     class = VRGet( objects.1, "ClassName" )
  138.     i = 2
  139.     do while( i <= objects.0 )
  140.         if( VRGet( objects.i, "ClassName" ) <> class ) then do
  141.             leave
  142.         end
  143.         i = i + 1
  144.     end
  145.     if( i > objects.0 ) then do
  146.         call VRSet "PB_SetAll", "Enabled", 1
  147.     end
  148.  
  149.     CurProp = ""
  150.     call VRSet "LB_Objects", "Selected", 1
  151.     call VRSet window, "Visible", 1
  152.     call VRMethod window, "Activate"
  153. return
  154.  
  155. /*:VRX         LB_Objects_Click
  156. */
  157. LB_Objects_Click:
  158.     call ListProps VRMethod( "LB_Objects", "GetItemData", VRGet( "LB_Objects", "Selected" ) )
  159.     call DisplayValue
  160. return
  161.  
  162. /*:VRX         LB_Props_Click
  163. */
  164. LB_Props_Click:
  165.     CurProp = VRGet( "LB_Props", "SelectedString" )
  166.     call DisplayValue
  167. return
  168.  
  169. /*:VRX         ListProps
  170. */
  171. ListProps: procedure expose CurProp
  172.     parse arg object
  173.  
  174.     /*  List properties which are not read only.
  175.     */
  176.     call VRSet "LB_Props", "Painting", 0
  177.     call VRMethod "LB_Props", "Clear"
  178.     call VRMethod object, "ListProperties", "list.", "Saveable" 
  179.     call VRMethod "LB_Props", "AddStringList", "list."
  180.     call VRMethod object, "ListProperties", "list.", "Events" 
  181.     do i = 1 to list.0
  182.         call VRMethod "LB_Props", "DeleteString", list.i
  183.     end
  184.     call VRMethod object, "ListProperties", "list.", "ReadOnly" 
  185.     do i = 1 to list.0
  186.         call VRMethod "LB_Props", "DeleteString", list.i
  187.     end
  188.     call VRSet "LB_Props", "Painting", 1
  189.  
  190.     /*  Set the selected property for the new object to
  191.         the current property.
  192.     */
  193.     pos = VRMethod( "LB_Props", "FindString", CurProp, , "Exact" )
  194.     if( pos > 0 ) then do
  195.         call VRSet "LB_Props", "Selected", pos    
  196.     end    
  197. return
  198.  
  199. /*:VRX         PB_Cancel_Click
  200. */
  201. PB_Cancel_Click:
  202.     call VRDestroy "SW_1"
  203. return
  204.  
  205. /*:VRX         PB_Edit_Click
  206. */
  207. PB_Edit_Click:
  208.     call VRLoadSecondary "SW_1"
  209.     call VRSet "MLE_Edit", "Value", VRGet( "EF_Value", "Value" )
  210. return
  211.  
  212. /*:VRX         PB_OK_Click
  213. */
  214. PB_OK_Click:
  215.     call VRSet "EF_Value", "Value", VRGet( "MLE_Edit", "Value" )        
  216.     call VRDestroy "SW_1"
  217. return
  218.  
  219. /*:VRX         PB_Set_Click
  220. */
  221. PB_Set_Click:
  222.     property = VRGet( "LB_Props", "SelectedString" )
  223.     if( property = "" ) then do
  224.         signal SetDone
  225.     end
  226.     if( translate( property ) = "NAME" )then do
  227.         msg = "The object name cannot be changed using this editor."
  228.         call VRMessage VRWindow(), msg, "Property editor"
  229.         signal SetDone
  230.     end
  231.     index = VRGet( "LB_Objects", "Selected" )
  232.     if( index = 0 ) then do
  233.         signal SetDone
  234.     end
  235.  
  236.     object = VRMethod( "LB_Objects", "GetItemData", index )
  237.     call VRSet object, property, VRGet( "EF_Value", "Value" )
  238.     if( index < VRGet( "LB_Objects", "Count" ) ) then do
  239.         index = index + 1
  240.     end
  241.     else do
  242.         index = 1
  243.     end
  244.     call VRSet "LB_Objects", "Selected", index
  245.  
  246. SetDone:
  247.     drop property index object
  248. return
  249.  
  250. /*:VRX         PB_SetAll_Click
  251. */
  252. PB_SetAll_Click:
  253.     property = VRGet( "LB_Props", "SelectedString" )
  254.     if( property = "" ) then do
  255.         signal SetAllDone
  256.     end
  257.     if( translate( property ) = "NAME" )then do
  258.         msg = "The object name cannot be changed using this editor."
  259.         call VRMessage VRWindow(), msg, "Property editor"
  260.         signal SetDone
  261.     end
  262.  
  263.     value = VRGet( "EF_Value", "Value" )
  264.     call VRMethod "LB_Objects", "GetItemDataList", "objects."
  265.     do i = 1 to objects.0
  266.         call VRSet objects.i, property, value
  267.     end
  268.  
  269. SetAllDone:
  270.     drop property value objects. i
  271. return
  272.  
  273.  
  274. /*:VRX         Quit
  275. */
  276. Quit:
  277.     window = VRWindow()
  278.     call VRSet window, "Shutdown", 1
  279.     drop window
  280. return
  281.  
  282. /*:VRX         SW_1_Close
  283. */
  284. SW_1_Close:
  285.     window = VRInfo( "Object" )
  286.     call VRDestroy window
  287.     drop window
  288. return
  289. /*:VRX         Window1_Close
  290. */
  291. Window1_Close:
  292.     call Quit
  293. return
  294.  
  295.