home *** CD-ROM | disk | FTP | other *** search
/ Amiga ISO Collection / AmigaUtilCD1.iso / GFX / Painting / OpalPaint2,3-020+Version.LHA / Rexx / ScalePage.oprx < prev   
Encoding:
Text File  |  1994-04-22  |  6.1 KB  |  210 lines

  1. /* Scales the current page proportionally.
  2.    AREXX script by Greg Niles, Centaur Development.
  3.     Version 1.0 - initial version
  4.     Version 1.1 - added scale to larger size capability
  5.     Version 1.2 - added percentage width and height scaling
  6.     Version 2.0 - revamped interface for OpalPaint v2.3
  7.             - much smarter about changing screen resolution
  8.             - online help (in an AREXX script??? weird...)
  9.  */
  10.  
  11. address 'OpalPaint_Rexx'
  12.  
  13. options Results
  14.  
  15. SaveSetUp
  16.  
  17. /* get current page size & initialize variables */
  18. PageSize
  19. parse var result Width Height
  20. Width = compress(Width)
  21. Height = compress(Height)
  22. MaxScale = 32767
  23. NewWidth = Width
  24. NewHeight = Height
  25. SliderAmt = 100
  26. ScaleMethod = BothGad
  27.  
  28. call OptionsRequester
  29.  
  30. RestoreSetUp
  31. EXIT
  32.  
  33.  
  34. OptionsRequester:
  35.     /* Scaling requester */
  36.     ReqBuild '450 250 "Scale Image v2.0"' 
  37.  
  38.     AddGadget 'Toggle WidthGad 35 55 Medium "Width"'
  39.     AddGadget 'Toggle HeightGad Below WidthGad 0 10 Medium "Height"'
  40.     AddGadget 'Toggle BothGad Below HeightGad 0 10 Medium "Both"'
  41.     AddGadget 'VProp ScaleSlider Right WidthGad 30 0 Medium 0 200 1 Percent'
  42.     AddGadget 'Integer WidthString Right ScaleSlider 60 10 Medium 1 'MaxScale''
  43.     AddGadget 'Integer HeightString Below WidthString 0 20 Medium 1 'MaxScale''
  44.     AddGadget 'Toggle LockToWidth Below HeightString 0 20 80 25 "Width"'
  45.     AddGadget 'Toggle LockToHeight Right LockToWidth 10 0 80 25 "Height"'
  46.     AddGadget 'Button Recalculate Below LockToHeight CenterX 44 Large "Recalculate size"'
  47.     AddGadget 'Button HelpGad 416 5 20 20 "?"'
  48.  
  49.     AddText 'Above WidthString 0 -3 "Enter new width:"'
  50.     AddText 'Above HeightString 0 -3 "Enter new height:"'
  51.     AddText 'Above LockToWidth 5 -3 "Lock aspect ratio to:"'
  52.     AddHeading 'Above Recalculate CenterX -20 "Old image size: 'Width' x 'Height'"'
  53.     AddHeading 'Above Recalculate CenterX -7 "New image size: 'NewWidth' x 'NewHeight'"'
  54.  
  55.     MutualEx WidthGad HeightGad BothGad LockToWidth LockToHeight
  56.     InitGadget ''ScaleMethod' Selected'
  57.     InitGadget 'ScaleSlider 'SliderAmt''
  58.     InitGadget 'WidthString 'NewWidth''
  59.     InitGadget 'HeightString 'NewHeight''
  60.     AddHeading 'Above WidthGad 10 -10 "Percentage Scaling"'
  61.     AddHeading 'Above WidthString 30 -20 "Numeric Scaling"'
  62.     AddBox 'Above WidthGad -20 -25 200 150'
  63.     AddBox 'Above ScaleSlider 70 -25 200 150'
  64.  
  65.     Request
  66.  
  67.     GadgetStatus Cancel
  68.     if Result=1 Then do
  69.         Exit
  70.         END
  71.  
  72.     GadgetStatus WidthGad
  73.     if Result=1 then do
  74.         GadgetStatus ScaleSlider
  75.         ScaleFactor = (Result/100)   /* Set scale percentage */
  76.         NewWidth = Trunc(Width*ScaleFactor)
  77.         NewHeight = Height
  78.         SliderAmt = (ScaleFactor*100)
  79.         ScaleMethod = WidthGad
  80.         END
  81.  
  82.     GadgetStatus HeightGad
  83.     if Result=1 then do
  84.         GadgetStatus ScaleSlider
  85.         ScaleFactor = (Result/100)   /* Set scale percentage */
  86.         NewWidth = Width
  87.         NewHeight = Trunc(Height*ScaleFactor)
  88.         SliderAmt = (ScaleFactor*100)
  89.         ScaleMethod = HeightGad
  90.         END
  91.  
  92.     GadgetStatus BothGad
  93.     if Result=1 then do
  94.         GadgetStatus ScaleSlider
  95.         ScaleFactor = (Result/100)   /* Set scale percentage */
  96.         NewWidth = Trunc(Width*ScaleFactor)
  97.         NewHeight = Trunc(Height*ScaleFactor)
  98.         SliderAmt = (ScaleFactor*100)
  99.         ScaleMethod = BothGad
  100.         END
  101.  
  102.     GadgetStatus LockToWidth
  103.     if Result=1 then do
  104.         GadgetStatus WidthString
  105.         ScaleFactor = (Result/Width)
  106.         NewWidth = Result
  107.         NewHeight = Trunc(Height*ScaleFactor)
  108.         SliderAmt = (ScaleFactor*100)
  109.         ScaleMethod = LockToWidth
  110.         END
  111.  
  112.     GadgetStatus LockToHeight
  113.     if Result=1 then do
  114.         GadgetStatus HeightString
  115.         ScaleFactor = (Result/Height)
  116.         NewHeight = Result
  117.         NewWidth = Trunc(Width*ScaleFactor)
  118.         SliderAmt = (ScaleFactor*100)
  119.         ScaleMethod = LockToHeight
  120.         END
  121.  
  122.     GadgetStatus Recalculate
  123.     if Result=1 then do
  124.         call OptionsRequester
  125.         Return
  126.         END
  127.  
  128.     GadgetStatus HelpGad
  129.     if Result=1 then do
  130.         call Help
  131.         call OptionsRequester
  132.         Return
  133.         END
  134.  
  135.     GadgetStatus Okay
  136.  
  137.     HorizRes=''
  138.     VertRes=''
  139.     Scan=''
  140.     if Result=1 then do
  141.         if NewWidth>640 then do
  142.             HorizRes=HIRES
  143.             Scan=OVERSCAN
  144.             end
  145.         else if NewWidth>370 then
  146.             HorizRes=HIRES
  147.         else if NewWidth>320 then
  148.             Scan=OVERSCAN
  149.  
  150.         VideoMode
  151.         if Result=PAL then do
  152.             if NewHeight>512 then do
  153.                 VertRes=INTERLACE
  154.                 Scan=OVERSCAN
  155.                 end
  156.             else if NewHeight>286 then
  157.                 VertRes=INTERLACE
  158.             else if NewHeight>256 then
  159.                 Scan=OVERSCAN
  160.             end
  161.         else do
  162.             if NewHeight>400 then do
  163.                 VertRes=INTERLACE
  164.                 Scan=OVERSCAN
  165.                 end
  166.             else if NewHeight>236 then
  167.                 VertRes=INTERLACE
  168.             else if NewHeight>200 then
  169.                 Scan=OVERSCAN
  170.             end
  171.  
  172.         PageSize NewWidth NewHeight HorizRes VertRes Scan
  173.         END
  174. Return
  175.  
  176.  
  177. Help:
  178.     ReqBuild '640 310 "Help for Scale Image v2.0"'
  179.     AddBox '15 30 610 235'
  180.     AddGadget 'Button ExitHelp CenterX 275 Medium "Exit Help"'
  181.  
  182.     AddHeading 'CenterX 40 "Percentage Scaling"'
  183.     AddText '25 55 "The  slider  allows  you  to  set  the  percentage for scaling the image."'
  184.     AddText '25 65 "Normally, the BOTH button is selected, which scales both width and height"'
  185.     AddText '25 75 "proportionally,  but  selecting  either  the WIDTH or HEIGHT buttons will"'
  186.     AddText '25 85 "scale  ONLY the width or height of the image by the specified percentage."'
  187.     AddText '25 95 "For all three methods, the width and height strings are ignored."'
  188.  
  189.     AddHeading 'CenterX 110 "Numeric Scaling"'
  190.     AddText '25 125 "The  width  and  height strings allow you to type in a size directly.  To"'
  191.     AddText '25 135 "activate these gadgets, however, you must click on either of the two LOCK"'
  192.     AddText '25 145 "ASPECT  RATIO  TO:  buttons.  Selecting WIDTH will scale the image to the"'
  193.     AddText '25 155 "specified  pixel  width,  while  the  height  will  be scaled by the same"'
  194.     AddText '25 165 "proportion  automatically.  The opposite applies when HEIGHT is selected."'
  195.     AddText '25 175 "In either case, the percentage slider setting is ignored."'
  196.  
  197.     AddHeading 'CenterX 190 "Viewing / performing your changes"'
  198.     AddText '25 205 "The  current  image  size is shown at the bottom of the requester.  Click"'
  199.     AddText '25 215 "the RECALCULATE SIZE button to update the new page size values to reflect"'
  200.     AddText '25 225 "the  changes  you have made.  This also updates the slider to reflect any"'
  201.     AddText '25 235 "width  or  height reference scaling.  Click OK to accept all settings and"'
  202.     AddText '25 245 "scale the image to the new size, or CANCEL to abort."'
  203.  
  204.     Request NoOk NoCancel
  205. Return
  206.  
  207. EXIT
  208.  
  209.  
  210.