home *** CD-ROM | disk | FTP | other *** search
- /*
- @N
-
- This Genie will redistribute the objects in a selection evenly across a specified range.
-
- */
- cr = '0a'x
- msg = PDSetup.rexx(2,0)
- units = getclip(pds_units)
- if msg ~= 1 then exit_msg(msg)
-
- signal on halt
- signal on break_c
- signal on break_e
- signal on break_d
-
- if pdm_NumSelObjs() = 0 then exit_msg("Please select a group of objects first")
-
- hspacing = "Left"cr"Right"cr"_Centers"cr"Objects"cr"None"
- vspacing = "Top"cr"Bottom"cr"_Centers"cr"Objects"cr"None"
-
- hspacing = pdm_SelectFromList("Horizontal Distribution..", 20, 5, 2, hspacing)
- if hspacing = '' then exit_msg()
-
- vspacing = pdm_SelectFromList("Vertical Distribution..", 20, 5, 2, vspacing)
- if vspacing = '' then exit_msg()
-
- vdist = 0
- hdist = 0
-
- grouprect = pdm_GetObjPosn()
- groupleft = word(grouprect, 1)
- grouptop = word(grouprect, 2)
- grouprect = pdm_GetObjSize()
- groupwidth = word(grouprect, 1)
- groupheight = word(grouprect, 2)
- right = groupleft + groupwidth
- bottom = grouptop + groupheight
-
- if units >2 then do
- groupleft = pdm_ConvertUnits(1, units, groupleft)
- right = pdm_ConvertUnits(1, units, right)
- grouptop = pdm_ConvertUnits(1, units, grouptop)
- bottom = pdm_ConvertUnits(1, units, bottom)
- end
-
- if hspacing ~= "None" then do
- htext = "From:"groupleft || cr"To:"right
- hdist = pdm_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 >2 then do
- startx = pdm_ConvertUnits(units, 1, startx)
- endx = pdm_ConvertUnits(units, 1, endx)
- end
-
- end
-
- if vspacing ~= "None" then do
- vtext = "From:"grouptop || cr"To:"bottom
-
- vdist = pdm_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 >2 then do
- starty = pdm_ConvertUnits(units, 1, starty)
- endy = pdm_ConvertUnits(units, 1, endy)
- end
-
- end
-
- counter = 0
- obj = pdm_SelFirstObj()
-
- sumwidths = 0
- sumheights = 0
-
- do while obj ~= 0
- if ((iscompound(obj) = 0) | (isfirst(obj) = 1)) then do
- counter = counter + 1
- objects.counter = obj
-
- objpos = pdm_GetObjVisPosn(obj)
- objsze = pdm_GetObjVisSize(obj)
- objects.counter.0 = word(objpos, 1) /* left */
- objects.counter.1 = word(objpos, 2) /* top */
- objects.counter.2 = word(objsze, 1) /* width */
- objects.counter.3 = word(objsze, 2) /* height */
-
- sumwidths = sumwidths + objects.counter.2
- sumheights = sumheights + objects.counter.3
- end
- obj = pdm_SelNextObj(obj)
-
- end
-
- vpos = starty
- hpos = startx
- vmove = "vpos = vpos + vspace"
- hmove = "hpos = hpos + hspace"
-
- if vspacing = "Top" then do
- vspace = (endy - starty) / max(2,(counter - 1))
- vstring = "vpos"
- end
- else if vspacing = "Bottom" then do
- vspace = (endy - starty) / max(2,(counter - 1))
- vstring = "vpos - objects.i.3"
- end
- else if vspacing = "Centers" then do
- vspace = (endy - starty) / max(2,(counter - 1))
- vstring = "vpos - .5 * objects.i.3"
- end
- else if vspacing = "Objects" then do
- vdist = ((endy - starty) - sumheights) / max(2,(counter - 1))
- vstring = "vpos"
- vmove = "vpos = vpos + objects.i.3 + vdist"
- end
- else do
- vstring = "objects.i.1"
- vmove = "/**/"
- end
-
- if hspacing = "Left" then do
- hspace = (endx - startx) / max(2,(counter - 1))
- hstring = "hpos"
- end
- else if hspacing = "Right" then do
- hspace = (endx - startx) / max(2,(counter - 1))
- hstring = "hpos - objects.i.2"
- end
- else if hspacing = "Centers" then do
- hspace = (endx - startx) / max(2,(counter - 1))
- hstring = "hpos - .5 * objects.i.2"
- end
- else if hspacing = "Objects" then do
- hdist = ((endx - startx) - sumwidths) / max(2,(counter - 1))
- hstring = "hpos"
- hmove = "hpos = hpos + objects.i.2 + hdist"
- end
- else do
- hstring = "objects.i.0"
- hmove = "/**/"
- end
-
- do i = 1 to counter
-
- interpret "x = "hstring
- interpret "y = "vstring
- call pdm_SetObjPosn(objects.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 pdm_Inform( 1, message, )
-
- call pdm_SetUnits(units)
- call pdm_AutoUpdate(1)
- exit
-
- end
-