home *** CD-ROM | disk | FTP | other *** search
- /*
- @BGroupDistribute @P@ICopyright Gold Disk Inc., February, 1992
- This Genie will redistribute the boxes in a group, evenly distributing them across a specified range.
-
- */
- cr = '0a'x
- address command
- call SafeEndEdit.rexx()
- call ppm_AutoUpdate(0)
-
- units = ppm_GetUnits()
- if units = 3 then
- call ppm_SetUnits(1)
-
- signal on halt
- signal on break_c
- signal on break_e
- signal on break_d
-
- group = ppm_GroupFirstBox()
- if group = 0 then exit_msg("Please select a group first")
-
- hspacing = "Left"cr"Right"cr"Centers"cr"Boxes"cr"None"
- vspacing = "Top"cr"Bottom"cr"Centers"cr"Boxes"cr"None"
-
- hspacing = ppm_SelectFromList("Horizontal Distribution..", 20, 5, 0, hspacing)
- if hspacing = '' then exit_msg()
-
- vspacing = ppm_SelectFromList("Vertical Distribution..", 20, 5, 0, vspacing)
- if vspacing = '' then exit_msg()
-
- vdist = 0
- hdist = 0
- grouprect = ppm_GetGroupRect()
- groupleft = word(grouprect, 1)
- grouptop = word(grouprect, 2)
- groupwidth = word(grouprect, 3)
- groupheight = word(grouprect, 4)
- right = groupleft + groupwidth
- bottom = grouptop + groupheight
-
- if hspacing ~= "None" then
- do
- if units = 3 then
- htext = "From:" || ppm_ConvertUnits(1, 3,groupleft) || cr"To:" || ppm_ConvertUnits(1, 3, right)
- else
- htext = "From:"groupleft || cr"To:"right
-
- hdist = ppm_GetForm( "Horizontal Distribution", 8, htext)
- if hdist = '' then exit_msg()
-
- parse var hdist startx '0a'x endx
-
- if ~(datatype(startx, n) & datatype(endx, n)) then
- call exit_msg('Invalid Input')
-
- if units = 3 then
- do
- startx = ppm_ConvertUnits(3, 1, startx)
- endx = ppm_ConvertUnits(3, 1, endx)
- end
-
- if endx < startx then
- do
- temp = endx
- startx = endx
- endx = temp
- end
-
-
- end
-
- if vspacing ~= "None" then
- do
- if units = 3 then
- vtext = "From:" || ppm_ConvertUnits(1, 3,grouptop) || cr"To:" || ppm_ConvertUnits(1, 3, bottom)
- else
- vtext = "From:"grouptop || cr"To:"bottom
-
- vdist = ppm_GetForm( "Vertical Distribution", 8, vtext)
- if vdist = '' then exit_msg()
-
- parse var vdist starty '0a'x endy
-
- if ~(datatype(starty, n) & datatype(endy, n)) then
- call exit_msg('Invalid Input')
-
- if units = 3 then
- do
- starty = ppm_ConvertUnits(3, 1, starty)
- endy = ppm_ConvertUnits(3, 1, endy)
- end
-
- if endy < starty then
- do
- temp = endy
- starty = endy
- endy = temp
- end
-
-
- end
-
- counter = 0
- box = ppm_GroupFirstBox()
-
- sumwidths = 0
- sumheights = 0
-
- do while box ~= 0
-
- counter = counter + 1
- boxes.counter = box
-
- boxpos = ppm_GetBoxRect(box)
- boxes.counter.0 = word(boxpos, 1) /* left */
- boxes.counter.1 = word(boxpos, 2) /* top */
- boxes.counter.2 = word(boxpos, 3) /* width */
- boxes.counter.3 = word(boxpos, 4) /* height */
-
- sumwidths = sumwidths + boxes.counter.2
- sumheights = sumheights + boxes.counter.3
-
- box = ppm_GroupNextBox(box)
-
- end
-
- vpos = starty
- hpos = startx
- vmove = "vpos = vpos + vspace"
- hmove = "hpos = hpos + hspace"
-
- if vspacing = "Top" then
- do
- vspace = (endy - starty) / counter
- vstring = "vpos"
- end
- else if vspacing = "Bottom" then
- do
- vspace = (endy - starty) / counter
- vstring = "vpos - boxes.i.3"
- end
- else if vspacing = "Centers" then
- do
- vspace = (endy - starty) / counter
- vstring = "vpos - .5 * boxes.i.3"
- end
- else if vspacing = "Boxes" then
- do
- vdist = ((endy - starty) - sumheights) / (counter + 1)
- vstring = "vpos"
- vmove = "vpos = vpos + boxes.i.3 + vdist"
- end
- else
- do
- vstring = "boxes.i.1"
- vmove = "/**/"
- end
-
- if hspacing = "Left" then
- do
- hspace = (endx - startx) / counter
- hstring = "hpos"
- end
- else if hspacing = "Right" then
- do
- hspace = (endx - startx) / counter
- hstring = "hpos - boxes.i.2"
- end
- else if hspacing = "Centers" then
- do
- hspace = (endx - startx) / counter
- hstring = "hpos - .5 * boxes.i.2"
- end
- else if hspacing = "Boxes" then
- do
- hdist = ((endx - startx) - sumwidths) / (counter + 1)
- hstring = "hpos"
- hmove = "hpos = hpos + boxes.i.2 + hdist"
- end
- else
- do
- hstring = "boxes.i.0"
- hmove = "/**/"
- end
-
- do i = 1 to counter
-
- interpret "x = "hstring
- interpret "y = "vstring
- call ppm_SetBoxPosition(boxes.i, x, y)
- interpret vmove
- interpret hmove
-
- end
-
- call exit_msg()
- break_d:
- break_e:
- break_c:
- halt:
- call exit_msg("User aborted Genie!")
-
- exit_msg: procedure expose units
- do
- parse arg message
-
- if message ~= '' then
- call ppm_Inform( 1, message, )
-
- if units = 3 then call ppm_SetUnits(3)
- call ppm_AutoUpdate(1)
- exit
-
- end
-