home *** CD-ROM | disk | FTP | other *** search
/ OS/2 Shareware BBS: 18 REXX / 18-REXX.zip / vxcliser.zip / VXREXX.3 / SAMPLES / RGB / RGB.VRX < prev    next >
Text File  |  1994-12-23  |  6KB  |  243 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         Fini
  67. */
  68. Fini:
  69.     /* Destroy the window
  70.     */
  71.  
  72.     window = VRWindow()
  73.     call VRSet window, "Visible", 0
  74.     drop window
  75. return 0
  76.  
  77. /*:VRX         Halt
  78. */
  79. Halt:
  80.     signal _VREHalt
  81. return
  82.  
  83. /*:VRX         Init
  84. */
  85. Init: 
  86.     /* Create the window
  87.     */
  88.  
  89.     window = VRWindow()
  90.     call VRMethod window, "CenterWindow"
  91.     call VRSet window, "Visible", 1
  92.     call VRMethod window, "Activate"
  93.     drop window
  94.  
  95.     /* Change the focus to the value set
  96.     */
  97.     
  98.     IgnoreChange = 0
  99.     call VRSet "VALUE_RGB", "Selected", 1
  100.     call SetSliders
  101. return
  102.  
  103. /*:VRX         Quit
  104. */
  105. Quit:
  106.     window = VRWindow()
  107.     call VRSet window, "Shutdown", 1
  108.     drop window
  109. return
  110.  
  111. /*:VRX         SetColor
  112. */
  113. SetColor: procedure expose IgnoreChange
  114.     parse arg color, value
  115.  
  116.     /*  Get the color of the selected item
  117.     */
  118.     selected = VRGet( "VALUE_RGB", "Selected" )
  119.     call VRMethod "VALUE_RGB", "GetAttributes", "Values", "attrs."
  120.     parse var attrs.selected "("red","green","blue")"
  121.  
  122.     /*  Set the color of the slider ribbon strip
  123.     */
  124.     value = Trunc( 255 * ( value / 100 ) )
  125.     if( color = "Red" ) then do
  126.         red = value
  127.         call VRSet "SL_Red", "RibbonColor", "(" || red || ",0,0)"
  128.     end
  129.     else if( color = "Green" ) then do
  130.         green = value
  131.         call VRSet "SL_Green", "RibbonColor", "(0," || green || ",0)"
  132.     end
  133.     else do
  134.         blue = value
  135.         call VRSet "SL_Blue", "RibbonColor", "(0,0," || blue || ")"
  136.     end
  137.  
  138.     if( IgnoreChange \= 0 ) then do
  139.         IgnoreChange = IgnoreChange - 1
  140.         signal endSetColor
  141.     end
  142.  
  143.     /*  Set the color of the value set item
  144.     */
  145.     attrs.selected = "(" || red || "," || green || "," || blue || ")"
  146.     call VRMethod "VALUE_RGB", "SetAttributes", "Values", "attrs."
  147.     call VRSet "DT_Settings", "Caption", attrs.selected
  148.  
  149. endSetColor:
  150. return
  151.  
  152. /*:VRX         SetSliders
  153. */
  154. SetSliders: procedure
  155.     /* Change the sliders to show the RGB content of the selected
  156.         color.
  157.     */
  158.  
  159.     /* Get the selected color information   
  160.     */
  161.     selected = VRGet( "VALUE_RGB", "Selected" )
  162.     call VRMethod "VALUE_RGB", "GetAttributes", "Values", "attrs."
  163.     call VRSet "DT_Settings", "Caption", attrs.selected
  164.     parse var attrs.selected "("red","green","blue")"
  165.  
  166.     /* Change the sliders.
  167.     */
  168.     call VRSet "SL_Red", "Percentile", Trunc( red * 100 / 255 )
  169.     call VRSet "SL_Green", "Percentile", Trunc( green * 100 / 255 )
  170.     call VRSet "SL_Blue", "Percentile", Trunc( blue * 100 / 255 )
  171. return
  172.  
  173. /*:VRX         SL_Blue_Change
  174. */
  175. SL_Blue_Change:
  176.     /* Change the blue content of the selected color
  177.     */
  178.     
  179.     call SetColor "Blue", VRGet( "SL_Blue", "Percentile" )
  180. return
  181.  
  182. /*:VRX         SL_Blue_Track
  183. */
  184. SL_Blue_Track:
  185.     /* Change the color of the blue slider
  186.     */
  187.  
  188.     call SetColor "Blue", VRGet( "SL_Blue", "Percentile" )
  189. return
  190.  
  191. /*:VRX         SL_Green_Change
  192. */
  193. SL_Green_Change:
  194.     /* Change the green content of the selected color
  195.     */
  196.  
  197.     call SetColor "Green", VRGet( "SL_Green", "Percentile" )
  198. return
  199.  
  200. /*:VRX         SL_Green_Track
  201. */
  202. SL_Green_Track:
  203.     /* Change the color of the green slider.
  204.     */
  205.  
  206.     call SetColor "Green", VRGet( "SL_Green", "Percentile" )
  207. return
  208.  
  209. /*:VRX         SL_Red_Change
  210. */
  211. SL_Red_Change:    
  212.     /* Change the red content of the selected color 
  213.     */
  214.  
  215.     call SetColor "Red", VRGet( "SL_Red", "Percentile" )
  216. return
  217.  
  218. /*:VRX         SL_Red_Track
  219. */
  220. SL_Red_Track:
  221.     /* Change the color of the red slider.
  222.     */
  223.     
  224.     call SetColor "Red", VRGet( "SL_Red", "Percentile" )
  225. return
  226.  
  227. /*:VRX         VALUE_RGB_Click
  228. */
  229. VALUE_RGB_Click:
  230.     /* The currently selected color has just changed.
  231.     */
  232.  
  233.     IgnoreChange = 3        /* Ignore the next three changes to the sliders. */
  234.     call SetSliders
  235. return
  236.  
  237. /*:VRX         Window1_Close
  238. */
  239. Window1_Close:
  240.     call Quit
  241. return
  242.  
  243.