/*
@BRedimensionneBoîtes @P @I Ecrit et © par Don Cox
@IN'est pas du Domaine Publique. Tous Droits Réservés.
Traduit par Fabien Larini le 22/07/93.

Ce Génie redimensionne les boîtes suivant un pourcentage, ainsi il modifie
les marges, la bordure, les offsets, et les échelles. La taille de
caractère n'est pas modifiée. Ne fonctionne pas avec les chaînes de boîtes.
*/

/*BoxResize*/
/* This Genie resizes boxes by a percentage factor and sets the margins, frame weight, offset and image scale accordingly. Type is not resized as this genie is for individual boxes, not linked chains. (See the separate TextResize genie).
Written by Don Cox */


signal on error
signal on syntax
address command
call SafeEndEdit.rexx()
call ppm_AutoUpdate(0)
cr="0a"x

counter=0


do forever
    box=ppm_ClickOnBox("Clickez dans les Boîtes à Redimensionner")
    if box=0 then break
    counter=counter+1
    boxes.counter=box
    call ppm_SelectBox(box)
end

if counter=0 then exit_msg("Pas de Boîte Sélectionnée")

percent = ppm_GetUserText(6,"Pourcentage de l'Ancienne Taille")
if percent = "" then exit_msg("Abandon Utilisateur")
if ~(datatype(percent,n)) then exit_msg("Valeur Invalide")
factor = abs(percent/100)
if factor>10 then factor = 10
if factor<0.1 then factor = 0.1

currentunits=ppm_GetUnits()
call ppm_SetUnits(1)


do i=1 to counter
    box=boxes.i

    framedata = ppm_GetBoxFrameData(box)
    parse var framedata linecolor "0a"x fillcolor "0a"x lineweight "0a"x linepattern "0a"x fillpattern
    call ppm_SetBoxFrameData(box, linecolor, fillcolor, lineweight*factor, linepattern, fillpattern)

    margins = ppm_GetBoxMargins(box)
    parse var margins mleft mtop mright mbottom
    call ppm_SetBoxMargins(box,mleft*factor,mtop*factor, mright*factor, mbottom*factor)

    boxtype = upper(word(ppm_GetBoxInfo(box), 1))
    /* if text, ask. Maybe set font size, line spacing, tabs, etc  */
    howbig = ppm_GetBoxSize(box)
    boxwidth = word(howbig,1)
    boxheight = word(howbig,2)
    call ppm_SetBoxSize(box, boxwidth*factor, boxheight*factor)

    boxscale = ppm_GetBoxScale(box)
    Xscale = word(boxscale,1)
    Yscale = word(boxscale,2)
    call ppm_SetBoxScale(box,Xscale*factor, Yscale*factor)

    offsets = ppm_GetBoxOffset(box)
    Xoffset = word(offsets,1)
    Yoffset = word(offsets,2)
    call ppm_SetBoxOffset(box, Xoffset*factor, Yoffset*factor)

    end

call ppm_SetUnits(currentunits)

call exit_msg()

end

error:
syntax:
    do
    exit_msg("Arrêt du Génie dû à l'erreur: "errortext(rc))
    end

exit_msg:
    do
    parse arg message
    if message ~= "" then
    call ppm_Inform(1,message,)
    call ppm_ClearStatus()
    call ppm_AutoUpdate(1)
    exit
    end

