home *** CD-ROM | disk | FTP | other *** search
- /* $VER: RotateAboutPoint.rexx 1.1 (23.09.96)
- Copyright 1996 SoftLogik Publishing Corporation
- May not be distributed without SoftLogik Publishing Corporation's express written permission */
-
- OPTIONS RESULTS
- TRACE OFF
-
- ADDRESS 'PAGESTREAM'
-
- /* Get the current rotation values and strip off the degree and measurement symbols */
- getobject type objtype rotation rstem about astem
-
- /* Are there any objects selected? If not, alert the user */
- if rc>0 then do
- allocarexxrequester '"RotateAboutPoint Alert"' 376 59
- hDialog=result
- addarexxgadget hDialog EXIT 290 42 70 label "Exit"
- Exithandle=result
- addarexxgadget hDialog TEXT 8 10 360 border none string "'There are no objects selected. Select one or'"
- addarexxgadget hDialog TEXT 8 20 360 border none string "'more objects and then play the script again.'"
- doarexxrequester hDialog
- freearexxrequester hDialog
- EXIT
- end
-
- /* if objects are locked, we don't want the actual lock alert box opening */
- /* 2 or more times, so let's simulate it and temporarily reset the lock */
- /* status if required. */
- getobjectlock
- lockstatus=result
- ignorehandle=1
- lockaction=0
- if lockstatus='ON' | lockstatus='UNKNOWN' then do
- allocarexxrequester '"Locked"' 254 55
- hDialog=result
- addarexxgadget hDialog EXIT 172 38 70 label "_Cancel"
- cancelhandle=result
- addarexxgadget hDialog EXIT 12 38 70 label "_Ignore"
- ignorehandle=result
- addarexxgadget hDialog EXIT 92 38 70 label "_Unlock"
- unlockhandle=result
- addarexxgadget hDialog TEXT 8 10 232 border none string "'A selected object is locked.'"
- doarexxrequester hDialog
- lockaction=result
- freearexxrequester hDialog
-
- /* If Cancel, then exit */
- if lockaction=cancelhandle then do
- exit
- end
- /* If Unlock, then unlock. If Ignore, temporarily unlock */
- /* Note, this doesn't properly handle the situation of some objects being locked and others not. They'll all be locked at the end of this script. */
- if lockaction=unlockhandle | lockaction=ignorehandle then unlock
- end
-
- /* PGS3 returns slant and twist. Reduce to rotate and remainder. */
- aslant=abs(rstem.slant)
- atwist=abs(rstem.twist)
- if rstem.slant=rstem.twist then do
- rstem.rotate=rstem.slant||'°'
- rstem.slant='0°'
- rstem.twist='0°'
- end
- else do
- if aslant<atwist then do
- rstem.rotate=rstem.slant||'°'
- mult=rstem.slant*-1
- end
- else do
- rstem.rotate=rstem.twist||'°'
- mult=rstem.twist*-1
- end
- rstem.slant=rstem.slant+mult||'°'
- rstem.twist=rstem.twist+mult||'°'
- end
-
- /* Allocate the Rotate About Point dialog box */
- allocarexxrequester '"Rotate About Point"' 290 93
- hDialog=result
-
- /* Allocate a list for the about cycle control */
- allocarexxlist
- hAboutList=result
- addarexxlist hAboutList 'Center'
- addarexxlist hAboutList 'Point'
-
- /* Add controls to dialog box */
- addarexxgadget hDialog EXIT 12 76 70 label "OK"
- hOK=result
- addarexxgadget hDialog EXIT 210 76 70 label "Cancel"
- hCancel=result
- addarexxgadget hDialog TEXT 8 8 128 border none string "'Rotation Amount'"
- addarexxgadget hDialog STRING 64 22 70 label "_Rotate" string rstem.rotate
- hRotate=result
- addarexxgadget hDialog STRING 64 36 70 label "_Slant" string rstem.slant
- hSlant=result
- addarexxgadget hDialog STRING 64 50 70 label "_Twist" string rstem.twist
- hTwist=result
- addarexxgadget hDialog TEXT 146 8 120 border none string "'Rotation Point'"
- addarexxgadget hDialog CYCLE 194 22 86 label '"Ab_out"' list hAboutList current 0
- hAbout=result
- if astem.mode='POINT' then do
- setarexxgadget hDialog hAbout current 1
- addarexxgadget hDialog STRING 194 36 70 label "_Horz" string astem.x
- hXPoint=result
- addarexxgadget hDialog STRING 194 50 70 label "V_ert" string astem.y
- hYPoint=result
- end
- else do
- setarexxgadget hDialog hAbout current 0
- addarexxgadget hDialog STRING 158 36 106 label "_Horz"
- hXPoint=result
- addarexxgadget hDialog STRING 158 50 106 label "_Vert"
- hYPoint=result
- end
- /* Show dialog box */
- doarexxrequester hDialog
- action=result
-
- /* If Cancel, then exit */
- if action=hCancel then signal cancel
-
- /* If Rotate, then rotate it and exit */
- /* Get gadget status */
- getarexxgadget hDialog hRotate string
- dRotate=result
- if lastpos('°',dRotate)~=0 then dRotate=left(dRotate,lastpos('°',dRotate)-1)
- getarexxgadget hDialog hSlant string
- dSlant=result
- if lastpos('°',dSlant)~=0 then dSlant=left(dSlant,lastpos('°',dSlant)-1)
- getarexxgadget hDialog hTwist string
- dTwist=result
- if lastpos('°',dTwist)~=0 then dTwist=left(dTwist,lastpos('°',dTwist)-1)
- getarexxgadget hDialog hXPoint string
- dHorz=result
- getarexxgadget hDialog hYPoint string
- dVert=result
-
- /* Check for blank text boxes */
- if dRotate="" then dRotate=0
- if dSlant="" then dSlant=0
- if dTwist="" then dTwist=0
- if dHorz="" then dHorz=astem.x
- if dVert="" then dVert=astem.y
-
- /* Determine if the rotation point was changed from center, then set rotation point */
- /* strip the msys if they type one. msys abbrevs are not supported by this version */
-
- if (right(dHorz,1)<0 | right(dHorz,1)>9) then dHorz=left(dHorz,length(dHorz)-1)
- if (right(dHorz,1)<0 | right(dHorz,1)>9) then dHorz=left(dHorz,length(dHorz)-1)
- if (right(dHorz,1)<0 | right(dHorz,1)>9) then dHorz=left(dHorz,length(dHorz)-1)
- if (left(dHorz,1)<0 | left(dHorz,1)>9) then dVert=left(dVert,length(dVert)-1)
- if (left(dHorz,1)<0 | left(dHorz,1)>9) then dVert=left(dVert,length(dVert)-1)
- if (left(dHorz,1)<0 | left(dHorz,1)>9) then dVert=left(dVert,length(dVert)-1)
-
- refresh wait
-
- /* Rotate About Center or Point? */
- getarexxgadget hDialog hAbout current
- if result=0 then do
- editobject aboutcenter
- end
- else do
- editobject about dHorz dVert
- end
-
- dSlant=dSlant+dRotate
- dTwist=dTwist+dRotate
-
- /* Rotate the selected objects */
- editobject skew dSlant dTwist
- if lockaction=ignorehandle then lock
- refresh continue
-
- /* Clean up and Exit */
- CANCEL:
- freearexxrequester hDialog
- freearexxlist hAboutList
- exit
- return 0
-