home *** CD-ROM | disk | FTP | other *** search
/ PC Online 1998 November / PCO_1198.ISO / filesbbs / os2 / tspg202s.arj / TSPG202S.ZIP / Scripts / ROTATE.CWX < prev    next >
Encoding:
Text File  |  1997-05-04  |  6.0 KB  |  193 lines

  1. /***************************************************************************
  2.   P>G Pro Script                                                           
  3.                                                                           
  4.  Prompt the user for rotation parameters, then do it!                     
  5.  
  6.  Copyright 1997 by TrueSpectra Inc.                                  
  7.                                                                      
  8.  This code is provided purely for demonstration purposes and is not  
  9.  supported or under warranty.  Feel free to modify and examine this  
  10.  example script for your own purposes.                               
  11.  
  12. */                                                                          
  13.  
  14.   /* what is selected? */
  15. original_object = CwGetSelectedObject()
  16.  
  17. /* nothing selected?  Continue */
  18.   if \CwIsHandleValid(original_object) then
  19.     do
  20.       say "You MUST select an object before running this script!"
  21.       Signal DONE
  22.     end
  23.  
  24.   /* get it's current angle from the original_position. stem */
  25. call CwGetPosition original_object, original_position
  26.  
  27. startangle = original_position.Rotation
  28.  
  29. /* Prompt user for Total Degrees Rotation & size of each step               */
  30. call prompt
  31.  
  32. /* now wait form them to press the green button */
  33. call wait
  34.  
  35.  
  36. finalangle = startangle + totaldegrees
  37. count = 0
  38. newangle = 0
  39. Do until newangle >= finalangle
  40.   count = count + 1
  41.  
  42.   /* duplicate the object */
  43.   newobject = CwDuplicateObject(original_object)
  44.  
  45.   /* calculate the new angle */
  46.   newangle = startangle + (step * count)
  47.  
  48.   /* rotate the new object */
  49.   call CwSetPosition newobject,,
  50.          original_position.x,,
  51.          original_position.y,,
  52.          original_position.width,,
  53.          original_position.height,,
  54.          newangle,,
  55.          original_position.XShear
  56.  
  57. end
  58.  
  59. DONE:
  60.  
  61. Exit
  62.  
  63. /* Routine to display the prompt information                                */
  64. Prompt:
  65.  
  66. /* Stop drawing until we've setup the display */
  67. Window=CwGetCurrentView()
  68. call CwStopRender window
  69.  
  70. /* find out the area we have to draw in */
  71. ah=CwGetAppHandle('output settings')
  72. maxwidth=CwGetProperty(ah, 'output size:width')
  73. maxheight=CwGetProperty(ah, 'output size:height')
  74.  
  75. /* Drop a white box over everything so we can see our prompts */
  76. boxeffect = CwCreateEffect('Rectangle', 'Solid Color')
  77. call CwSetPosition boxeffect, maxwidth/2, maxheight/2, maxwidth, maxheight, 0,0
  78. call CWSetName boxeffect, "_TS_BOX"
  79.  
  80. whitebox = CwGetTool(boxeffect)
  81. call CWSetProperty whitebox, "Color", "(255,255,255)"
  82.  
  83. /* show the prompts */
  84. text1effect = CwCreateEffect('Headline Text', 'Solid Color')
  85. call CwSetPosition text1effect, maxwidth/4, maxheight-maxheight/12, maxwidth/2, maxheight/6, 0, 0
  86. call CWSetName text1effect, "_TS_TEXT1"
  87.  
  88. textobj = CwGetRegion(text1effect)
  89. call CWSetProperty textobj, "Caption", "TOTAL ROTATION"
  90. textobj = CwGetTool(text1effect)
  91. call CWSetProperty textobj, "Color", "(0,0,0)"
  92.  
  93. /* show the prompts */
  94. text2effect = CwCreateEffect('Headline Text', 'Solid Color')
  95. call CwSetPosition text2effect, maxwidth-maxwidth/6, maxheight-maxheight/12, maxwidth/3, maxheight/6, 0, 0
  96. call CWSetName text2effect, "_TS_TEXT2"
  97.  
  98. textobj = CwGetRegion(text2effect)
  99. call CWSetProperty textobj, "Caption", "EACH STEP IS:"
  100. textobj = CwGetTool(text2effect)
  101. call CWSetProperty textobj, "Color", "(0,0,0)"
  102.  
  103. /* show the prompts */
  104. degreeseffect = CwCreateEffect('Headline Text', 'Solid Color')
  105. call CwSetPosition degreeseffect, maxwidth/6, maxheight/1.3, maxwidth/3, maxheight/4, 0, 0
  106. call CWSetName degreeseffect, "_TS_ITEM1"
  107.  
  108. o = CwGetRegion(degreeseffect)
  109. call CWSetProperty o, "Caption", "90"
  110. o = CwGetTool(degreeseffect)
  111. call CWSetProperty o, "Color", "(255,0,0)"
  112.  
  113. /* show the prompts */
  114. stepeffect = CwCreateEffect('Headline Text', 'Solid Color')
  115. call CwSetPosition stepeffect, maxwidth-maxwidth/6, maxheight/1.3, maxwidth/3, maxheight/4, 0, 0
  116. call CWSetName stepeffect, "_TS_ITEM2"
  117.  
  118. o = CwGetRegion(stepeffect)
  119. call CWSetProperty o, "Caption", "5"
  120. o = CwGetTool(stepeffect)
  121. call CWSetProperty o, "Color", "(255,0,0)"
  122.  
  123. /* show the prompts */
  124. blockeffect = CwCreateEffect('Block Text', 'Solid Color')
  125. call CwSetPosition blockeffect, maxwidth/2, maxheight/2, maxwidth/1.5, maxheight/3, 0, 0
  126. call CWSetName blockeffect, "_TS_TEXT3"
  127.  
  128. o = CwGetRegion(blockeffect)
  129. call CWSetProperty o, "Caption", "Change the RED numbers above then select Green Button"
  130. o = CwGetTool(blockeffect)
  131. call CWSetProperty o, "Color", "(0,0,0)"
  132.  
  133. /* show the prompts */
  134. btneffect = CwCreateEffect('Ellipse', 'Solid Color')
  135. call CwSetPosition btneffect, maxwidth/2, maxheight/6, maxwidth/4, maxheight/3, 0, 0
  136. call CWSetName btneffect, "_TS_BUTTON"
  137.  
  138. o = CwGetTool(btneffect)
  139. call CWSetProperty o, "Color", "(0,255,0)"
  140.  
  141. /* Now render the screen for the user */
  142. call CwStartRender window
  143.  
  144.  
  145.  
  146. return
  147.  
  148. /* Routine to wait until the green button is pressed                        */
  149. WAIT:
  150.  
  151. /* Begin loop to wait for "green button" selection */
  152. if RxFuncQuery('SysLoadFuncs') then
  153.   do
  154.       call RxFuncAdd 'SysLoadFuncs', 'REXXUTIL', 'SysLoadFuncs'
  155.       call SysLoadFuncs
  156.   end
  157.  
  158. do forever
  159. /* sleep */
  160.   rc = SysSleep 5
  161.  
  162. /* see what (if anything) is selected */
  163.   obj = CWGetSelectedObject()
  164.  
  165. /* nothing selected?  Continue */
  166.   if \CwIsHandleValid(obj) then ITERATE
  167.  
  168. /* Something selected.  What is it? */
  169.   name = CWGetName(obj)
  170.  
  171. /* if it is the button then go on */
  172.   If name = "_TS_BUTTON" then
  173.    do
  174.      o = CwGetRegion(degreeseffect)
  175.      TotalDegrees = CWGetProperty(o,"Caption")
  176.      o = CwGetRegion(stepeffect)
  177.      Step = CWGetProperty(o,"Caption")
  178.      say "Rotating: "totaldegrees "Step by: "step
  179.      LEAVE
  180.    end
  181. end
  182.  
  183. /* delete all the "prompting" stuff before continuing */
  184. rc = CwDeleteObject(blockeffect)
  185. rc = CwDeleteObject(boxeffect)
  186. rc = CwDeleteObject(btneffect)
  187. rc = CwDeleteObject(stepeffect)
  188. rc = CwDeleteObject(degreeseffect)
  189. rc = CwDeleteObject(text1effect)
  190. rc = CwDeleteObject(text2effect)
  191.  
  192. return
  193.