home
***
CD-ROM
|
disk
|
FTP
|
other
***
search
/
Frozen Fish 2: PC
/
frozenfish_august_1995.bin
/
bbs
/
d09xx
/
d0925.lha
/
DonsGenies
/
DonsGenies.lha
/
Don'sGenies
/
BoxesToGrid.pprx
< prev
next >
Wrap
Text File
|
1993-05-25
|
3KB
|
109 lines
/* This Genie snaps the corners of the boxes to the nearest grid point.
Written by Don Cox Aug 92 Not Public Domain. All rights reserved. */
trace n
signal on error
signal on syntax
address command
call SafeEndEdit.rexx()
call ppm_AutoUpdate(0)
cr="0a"x
cpage = ppm_CurrentPage()
counter=0
choice = ppm_Inform(2,"Which boxes?","All on page","Click to select")
select
when choice = 1 then do
do forever
box=ppm_ClickOnBox(" Click on boxes to be repositioned")
if box=0 then break
counter=counter+1
boxes.counter=box
call ppm_SelectBox(box)
end
end
when choice = 0 then do
boxes.1 = ppm_PageFirstBox()
box = boxes.1
totalboxes = ppm_NumBoxes(cpage)
counter = totalboxes
do i=2 to totalboxes
box = ppm_PageNextBox(box)
boxes.i = box
end
end
otherwise exit_msg()
end
if counter=0 then exit_msg("No boxes selected")
currentunits=ppm_GetUnits()
call ppm_SetUnits(2)
gridsize = ppm_GetGridSize()
spacingY = word(gridsize,2)
spacingX = word(gridsize,1)
call ppm_ShowStatus(" Tidying boxes...")
do i=1 to counter
box=boxes.i
Ypos = word(ppm_GetBoxPosition(box),2)
Xpos = word(ppm_GetBoxPosition(box),1)
oddbit = Ypos//spacingY
if oddbit<= spacingY/2 then Ypos = Ypos-oddbit
else Ypos = Ypos+spacingY-oddbit
oddbit = Xpos//spacingX
if oddbit<= spacingX/2 then Xpos = Xpos-oddbit
else Xpos = Xpos+spacingX-oddbit
call ppm_SetBoxPosition(box,Xpos,Ypos)
width = word(ppm_GetBoxSize(box),1)
height = word(ppm_GetBoxSize(box),2)
oddbit = height//spacingY
if oddbit<= spacingY/2 then newheight = height-oddbit
else newheight = height+spacingY-oddbit
oddbit = width//spacingX
if oddbit<= spacingX/2 then newwidth = width-oddbit
else newwidth = width+spacingX-oddbit
call ppm_SetBoxSize(box,newwidth,newheight)
info = ppm_GetBoxInfo(box)
boxtype = word(info,1)
if upper(boxtype) = "CLIP" | upper(boxtype) = "STRUCTURED" then do
scales = ppm_GetBoxScale(box)
Xscale = word(scales,1)
Yscale = word(scales,2)
call ppm_SetBoxScale(box, Xscale*(newwidth/width), Yscale*(newheight/height))
end
end
call ppm_SetUnits(currentunits)
call exit_msg()
end
error:
syntax:
do
exit_msg("Genie failed due to error: "errortext(rc))
end
exit_msg:
do
parse arg message
if message ~= "" then
call ppm_Inform(1,message,"Resume")
call ppm_ClearStatus()
call ppm_AutoUpdate(1)
exit
end