home *** CD-ROM | disk | FTP | other *** search
/ Frozen Fish 1: Amiga / FrozenFish-Apr94.iso / bbs / alib / d9xx / d925 / donsgenies.lha / DonsGenies / FrenchGenies.lha / Rexx / BorduresObjetsComplexes.pprx < prev    next >
Text File  |  1993-08-07  |  10KB  |  317 lines

  1. /*@BBordureObjetsComplexes @P@I Ecrit et © par Don Cox en juillet 92
  2. @IN'est pas du Domaine Publique. Tous Droits Réservés.
  3. Traduit par Fabien Larini le 17/07/93.
  4.  
  5. Ce Génie encadre les boîtes avec un dessin dans chaque coin et un motif
  6. composé de plusieurs dessins. Il a besoin d'une boîte contenant le dessin
  7. (clip ou bitmap) pour les coins, de une ou plusieur boîtes similaires pour
  8. le motif des côtés. La bordure réalisée, est groupée avec la boîte à 
  9. encadrer, pour déplacer l'ensemble, appuyer sur Shift.
  10. */
  11.  
  12.  
  13. /*BordersRepeats*/
  14. /* This Genie puts a decorative border around a box. You will need a box containing a clip or bitmap for the corners, and one or more similar boxes for the sides. The resulting border consists of a group of individual boxes, which can be moved together if you hold down the shift key.
  15. Written by Don Cox  July '92. Not Public Domain. All rights reserved.  */
  16.  
  17. trace n
  18.  
  19. address command
  20. signal on error
  21. signal on syntax
  22. signal on halt
  23. signal on break_c
  24. signal on break_d
  25. signal on break_e
  26.  
  27. rad = 3.1415926 / 180
  28. call ppm_AutoUpdate(0)
  29. call SafeEndEdit.rexx()
  30. cr="0a"x
  31.  
  32. if ~show('l', "gdarexxsupport.library") then
  33.     if ~addlib("gdarexxsupport.library",0,-30) then
  34.             call exit_msg("Installez la gdarexxsupport.library dans le répertoire libs: avant de lancer ce Génie")
  35.  
  36. CurrentUnits = ppm_GetUnits()
  37.  
  38. select
  39.     when CurrentUnits = 1 then units="inches"
  40.     when CurrentUnits = 2 then units="millimetres"
  41.     otherwise units ="points"
  42.     end
  43.  
  44. mainbox = ppm_ClickOnBox("Clickez sur la Boîte à Encadrer")
  45. if mainbox=0 then exit_msg("Pas de Boîte Selectionnée")
  46. mainpos = ppm_GetBoxPosition(mainbox)
  47. mainXpos = word(mainpos, 1)
  48. mainYpos = word(mainpos, 2)
  49. mainsize = ppm_GetBoxSize(mainbox)
  50. mainangle = ppm_GetBoxAngle(mainbox)
  51.  
  52. breadthRaw =  ppm_GetUserText(6, "Largeur du cadre en "units)
  53. if breadthRaw="" then exit_msg("Abandon Utilisateur")
  54.  
  55. if CurrentUnits = 2 then breadth = breadthRaw/10   /* mm to cm */
  56. if CurrentUnits = 3 then breadth = breadthRaw/12   /* points to picas */
  57. mainheight = (word(mainsize, 2))-(breadth*2)
  58. mainwidth = (word(mainsize, 1))-(breadth*2)
  59. if mainheight<0 | mainwidth<0 then exit_msg("Largeur Impossible : "breadthRaw)
  60.  
  61. cornerbox = ppm_ClickOnBox("Clickez dans la Boîte contenant le Dessin des Coins")
  62. if cornerbox ~=0 then do
  63.     csize = ppm_GetBoxSize(cornerbox)
  64.     cXsize = word(csize, 1)
  65.     cYsize = word(csize, 2)
  66.     cscale = ppm_GetBoxScale(cornerbox)
  67.     cscaleX = word(cscale, 1)
  68.     cscaleY = word(cscale, 2)
  69.     cangle = ppm_GetBoxAngle(cornerbox)
  70.     end
  71.  
  72. counter=0
  73.  
  74. do forever
  75.     box=ppm_ClickOnBox("Clickez dans les Boîtes contenant le(s) Dessin(s) pour le Motif des Cotés")
  76.     if box=0 then break
  77.     counter=counter+1
  78.     boxes.counter=box
  79.     call ppm_SetBoxAngle(box,0)
  80.     if counter = 5 then break
  81. end
  82.                        
  83. if counter = 0 & cornerbox = 0 then exit_msg("Pas de Dessins pour les Coins et les Bords")
  84.  
  85. sideboxes = counter /* This is the number of different units in the design */
  86.  
  87. do while counter<6
  88.     counter = counter+1
  89.     boxes.counter = boxes.1    /* pad up to 5 */
  90.     end
  91.  
  92.  
  93.  
  94. if Sideboxes>1 then do
  95.     pattern = ppm_GetUserText(Sideboxes*3, Sideboxes" boîtes selectionnées. Tapez un motif de répétition en utilisant abBAc etc.")
  96.     if pattern = "" then pattern = "a"
  97.     end
  98. else if Sideboxes = 1 then pattern = "a"
  99.  
  100. /* Place Corner Units */
  101. call ppm_NewGroup()
  102. call ppm_ShowStatus("Placement des Coins")
  103. if cornerbox ~=0 then do
  104.     cbox = ppm_CloneBox(cornerbox, 0, 0)
  105.     call ppm_AddToGroup(cbox)
  106.     call ppm_SetBoxAngle(cbox,0)
  107.     call ppm_SetBoxSize(cbox, breadth, breadth)
  108.     call ppm_SetBoxScale(cbox, cscaleX*breadth/cXsize, cscaleY*breadth/cYsize)
  109.     call ppm_SetBoxPosition(cbox, mainXpos, mainYpos)
  110.     cbox2 = ppm_CloneBox(cbox, 0, 0)
  111.     call ppm_AddToGroup(cbox2)
  112.     call ppm_SetBoxPosition(cbox2, mainXpos, mainYpos+mainheight+breadth)
  113.     call ppm_SetBoxAngle(cbox2, (cangle+90)//360)
  114.     cbox3 = ppm_CloneBox(cbox, 0, 0)
  115.     call ppm_AddToGroup(cbox3)
  116.     call ppm_SetBoxPosition(cbox3, mainXpos+mainwidth+breadth, mainYpos+mainheight+breadth)
  117.     call ppm_SetBoxAngle(cbox3, (cangle+180)//360)
  118.     cbox4 = ppm_CloneBox(cbox, 0, 0)
  119.     call ppm_AddToGroup(cbox4)
  120.     call ppm_SetBoxPosition(cbox4, mainXpos+mainwidth+breadth, mainYpos)
  121.     call ppm_SetBoxAngle(cbox4, (cangle+270)//360)
  122.     call ppm_SetBoxAngle(cbox, cangle//360)
  123.     end
  124.  
  125.  
  126. if Sideboxes = 0 then exit_msg("Terminé")
  127.  
  128.     patternlength = length(pattern)
  129.     totalwidth = 0
  130.  
  131.  
  132.     do i=1 to patternlength
  133.         letter = substr(pattern, i, 1)
  134.         select
  135.             when letter = "a" | letter = "A" then repeats.i = ppm_CloneBox(boxes.1, 0, 0)
  136.             when letter = "b" | letter = "B" then repeats.i = ppm_CloneBox(boxes.2, 0, 0)
  137.             when letter = "c" | letter = "C" then repeats.i = ppm_CloneBox(boxes.3, 0, 0)
  138.             when letter = "d" | letter = "D" then repeats.i = ppm_CloneBox(boxes.4, 0, 0)
  139.             when letter = "e" | letter = "E" then repeats.i = ppm_CloneBox(boxes.5, 0, 0)
  140.             otherwise repeats.i = ppm_CloneBox(boxes.1, 0, 0)
  141.             end
  142.  
  143.             if datatype(letter, "upper") then repeats.i.flip = 1
  144.             else repeats.i.flip = 0
  145.  
  146.  
  147. /* Collect original size and graphic scale of each box */
  148.     repeats.i.scaleX = word(ppm_GetBoxScale(repeats.i), 1)
  149.     repeats.i.scaleY = word(ppm_GetBoxScale(repeats.i), 2)
  150.     repeats.i.width = word(ppm_GetBoxSize(repeats.i), 1)
  151.     repeats.i.height = word(ppm_GetBoxSize(repeats.i), 2)
  152.     repeats.i.scale1 = breadth/repeats.i.height
  153.     repeats.i.width2 = repeats.i.width*repeats.i.scale1
  154.     if repeats.i.flip = 1 then repeats.i.scale1 = -repeats.i.scale1
  155.  
  156.     totalwidth = totalwidth+repeats.i.width2   /* width of the whole pattern */
  157. end
  158.  
  159.  
  160. heightcount = mainheight%totalwidth /* Use integer division to get number of repeats */
  161. widthcount = mainwidth%totalwidth
  162. if widthcount = 0 | heightcount = 0 then exit_msg("Motif trop Grand")
  163.  
  164. Xtotalwidth = mainwidth/widthcount  /* Exact width of whole pattern */
  165. Ytotalwidth = mainheight/heightcount
  166. Xscale = Xtotalwidth/totalwidth
  167. Yscale = Ytotalwidth/totalwidth
  168.  
  169. do i = 1 to patternlength
  170.     repeats.i.widthX = repeats.i.width2*Xscale
  171.     repeats.i.widthY = repeats.i.width2*Yscale 
  172.     end
  173.  
  174.  
  175. /* Place top units  */
  176.  
  177. call ppm_ShowStatus("Placement du Bord Supérieur")
  178. leftpos = mainXpos+breadth
  179. do j=1 to widthcount
  180. do i=1 to patternlength
  181.     newboxes.i = ppm_CloneBox(repeats.i, 0, 0)
  182.     call ppm_AddToGroup(newboxes.i)
  183.     call ppm_SetBoxSize(newboxes.i, repeats.i.widthX, breadth)
  184.     call ppm_SetBoxPosition(newboxes.i, leftpos, mainYpos)
  185.     call ppm_SetBoxScale(newboxes.i, (repeats.i.scaleX *repeats.i.scale1* Xscale), (repeats.i.scaleY * abs(repeats.i.scale1)) )
  186.     call ppm_SetBoxAngle(newboxes.i, 0)
  187.     leftpos = leftpos+repeats.i.widthX
  188.     end
  189. end
  190.  
  191. /* Place right side units */
  192. call ppm_ShowStatus("Placement du Bord Droit")
  193. toppos = mainYpos+breadth
  194. leftpos = mainXpos+word(mainsize, 1)
  195.  
  196. do j=1 to heightcount
  197.     do i=1 to patternlength
  198.         newboxes.i = ppm_CloneBox(repeats.i, 0, 0)
  199.         call ppm_AddToGroup(newboxes.i)
  200.         call ppm_SetBoxAngle(newboxes.i, 270)
  201.         call ppm_SetBoxSize(newboxes.i, repeats.i.widthY, breadth)
  202.         call ppm_SetBoxPosition(newboxes.i, leftpos, toppos)
  203.         call ppm_SetBoxScale(newboxes.i, (repeats.i.scaleX *repeats.i.scale1* Yscale), (repeats.i.scaleY * abs(repeats.i.scale1)) )
  204.         toppos = toppos+repeats.i.widthY
  205.         end 
  206.     end
  207.  
  208.  
  209. /* Place bottom units  */
  210.  
  211. call ppm_ShowStatus("Placement du Bord Inférieur")
  212. leftpos = mainXpos+breadth+mainwidth
  213. toppos = mainYpos+word(mainsize, 2)
  214.  
  215. do j=1 to widthcount
  216. do i=1 to patternlength
  217.     newboxes.i = ppm_CloneBox(repeats.i, 0, 0)
  218.     call ppm_AddToGroup(newboxes.i)
  219.     call ppm_SetBoxAngle(newboxes.i, 180)
  220.     call ppm_SetBoxSize(newboxes.i, repeats.i.widthX, breadth)
  221.     call ppm_SetBoxPosition(newboxes.i, leftpos, toppos)
  222.     call ppm_SetBoxScale(newboxes.i, (repeats.i.scaleX *repeats.i.scale1* Xscale), (repeats.i.scaleY * abs(repeats.i.scale1)) )
  223.     leftpos = leftpos-repeats.i.widthX
  224.     end
  225. end
  226.  
  227. /* Place left side units */
  228. call ppm_ShowStatus("Placement du Bord Gauche")
  229. toppos = mainYpos+breadth+mainheight
  230. leftpos = mainXpos
  231.  
  232. do j=1 to heightcount
  233.     do i=1 to patternlength
  234.         newboxes.i = ppm_CloneBox(repeats.i, 0, 0)
  235.         call ppm_AddToGroup(newboxes.i)
  236.         call ppm_SetBoxAngle(newboxes.i, 90)
  237.         call ppm_SetBoxSize(newboxes.i, repeats.i.widthY, breadth)
  238.         call ppm_SetBoxPosition(newboxes.i, leftpos, toppos)
  239.         call ppm_SetBoxScale(newboxes.i, (repeats.i.scaleX *repeats.i.scale1* Yscale), (repeats.i.scaleY * abs(repeats.i.scale1)) )
  240.         toppos = toppos-repeats.i.widthY
  241.         end 
  242.     end
  243.  
  244. /* Delete the "repeats" set of boxes  */
  245. do i = 1 to patternlength
  246.     gone = ppm_DeleteBox(repeats.i)
  247.     end
  248.  
  249. /* Set an arbitrary margin in main box  */
  250. margin = breadth*1.5
  251. call ppm_SetBoxMargins(mainbox, margin, margin, margin, margin)
  252.  
  253. /* Rotate border to match main box. This routine is just the Group Rotate genie. */
  254.  
  255. if mainangle~=0 then do
  256.     box     = ppm_GroupFirstBox()
  257.     if box  = 0 then exit_msg("Choisissez d'abord un Groupe")
  258.  
  259.  
  260.     rangle  = mainangle * rad
  261.     cosa    = cos(rangle)
  262.     sina    = sin(rangle)
  263.  
  264.     call ppm_ShowStatus("Rotation ...")
  265.  
  266.     grouprect   = ppm_GetGroupRect()
  267.     grpleft     = word(grouprect, 1)
  268.     grptop      = word(grouprect, 2)
  269.  
  270.     do while box ~= 0
  271.  
  272.         boxpos  = ppm_GetBoxPosition(box)
  273.         boxleft = word(boxpos, 1)
  274.         boxtop  = word(boxpos, 2)
  275.  
  276.         newangle = (mainangle + ppm_GetBoxAngle(box))//360
  277.         call ppm_SetBoxAngle(box, newangle )
  278.  
  279.         xoffset = boxleft - grpleft
  280.         yoffset = boxtop - grptop
  281.  
  282.         x   = grpleft + xoffset * cosa + yoffset * sina
  283.         y   = grptop +  yoffset * cosa - xoffset * sina
  284.  
  285.         call ppm_SetBoxPosition(box, x, y)
  286.  
  287.         box = ppm_GroupNextBox(box)
  288.     end
  289. end 
  290.  
  291. call exit_msg()
  292.  
  293. end
  294.  
  295. error:
  296. syntax:
  297.     do      
  298.     exit_msg("Arrêt du Génie dû à l'erreur: "errortext(rc))
  299.     end
  300.  
  301. break_d:
  302. break_e:
  303. break_c:
  304. halt:
  305. call exit_msg("Arrêté par l'Utilisateur")
  306.  
  307. exit_msg:
  308.     do
  309.     parse arg message
  310.     if message ~= "" then
  311.     call ppm_Inform(1, message,)
  312.     call ppm_ClearStatus()
  313.     call ppm_AutoUpdate(1)
  314.     exit
  315.     end
  316.  
  317.