home *** CD-ROM | disk | FTP | other *** search
/ OS/2 Shareware BBS: Graphics / Graphics.zip / pgpro40.zip / GreetingCard.cwx < prev    next >
Text File  |  1999-08-04  |  9KB  |  277 lines

  1. /*
  2.     GreetingCard.cwx
  3.     PGPro Scripts v3.0 - by Don Eitner, 1999
  4.  
  5.     Lays out an 8x10 inch greeting card which the user then modifies, prints,
  6.     and folds.
  7.  
  8.     This code is neither supported nor under warranty.  Feel free to
  9.     examine and modify this script for your own purposes.  See the
  10.     included readme.txt for additional information.
  11. */
  12.  
  13. call RxFuncAdd 'SysLoadFuncs', 'RexxUtil', 'SysLoadFuncs'
  14. call SysLoadFuncs
  15.  
  16. /* Make sure the user wants to do this */
  17. if RxMessageBox("This script will replace any current project.  Do you wish to continue?", ,
  18.     "New Project?","yesno","warning") \= 6 then
  19. exit
  20.  
  21. Handle = CwNewProject()
  22.  
  23. /* Set initial variables */
  24. Output  = CwGetAppHandle("Output Settings")
  25. Measure = CwGetProperty(Output, "Unit")
  26. Embo = "No"
  27.  
  28. /* Set project to 8x10 inches and 150dpi */
  29. call CwSetProperty Output, Unit, "Inches"
  30. call CwSetProperty Output, 'Output Size:Width', "8"
  31. call CwSetProperty Output, 'Output Size:Height', "10"
  32. call CwSetProperty Output, 'DPI', '150'
  33. call CwSetViewZoom 4.5, 4, 10, 12
  34.  
  35. /* Set additional variables */
  36. oWidth  = CwGetProperty(Output, "Output Size:Width")
  37. oHeight = CwGetProperty(Output, "Output Size:Height")
  38.  
  39. /* Prompt user for card front text */
  40. call Prompt "Out"
  41. call Wait
  42.  
  43. /* Prompt user for card inside text */
  44. call Prompt "In"
  45. call Wait
  46.  
  47. /* Create the front and inside of the card */
  48. Face1 = CwCreateEffect("Headline Text", "Solid Color")
  49. call CwSetPosition Face1, 6, 2.5, 3.5, 4.5, 0, 0
  50. Textobj = CwGetRegion(Face1)
  51. call CwSetProperty Textobj, "Caption", FT
  52. call CwSetProperty Textobj, "Font", FTF
  53. call CwSetProperty Textobj, "Justification", FTJ
  54. call CwSetProperty Textobj, "Line Spacing", FTL
  55. Textobj = CwGetTool(Face1)
  56. call CwSetProperty Textobj, "Color", FTC
  57.  
  58. if FTE = "Yes" then
  59.     do
  60.     Face1Emb = CwCreateEffect("Rectangle", "Emboss")
  61.     call CwSetPosition Face1Emb, 6, 2.5, 4, 5, 0, 0
  62.     Textobj = CwGetTool(Face1Emb)
  63.     call CwSetProperty Textobj, "Color", "(225,225,225)"
  64.     end
  65.  
  66. Face2 = CwCreateEffect("Headline Text", "Solid Color")
  67. call CwSetPosition Face2, 2, 7.5, 3.5, 4.5, 180, 0
  68. Textobj = CwGetRegion(Face2)
  69. call CwSetProperty Textobj, "Caption", IT
  70. call CwSetProperty Textobj, "Font", ITF
  71. call CwSetProperty Textobj, "Justification", ITJ
  72. call CwSetProperty Textobj, "Line Spacing", ITL
  73. Textobj = CwGetTool(Face2)
  74. call CwSetProperty Textobj, "Color", ITC
  75.  
  76. if ITE = "Yes" then
  77.     do
  78.     Face1Emb = CwCreateEffect("Rectangle", "Emboss")
  79.     call CwSetPosition Face1Emb, 2, 7.5, 4, 5, 180, 0
  80.     Textobj = CwGetTool(Face1Emb)
  81.     call CwSetProperty Textobj, "Color", "(225,225,225)"
  82.     end
  83.  
  84. Face3 = CwCreateEffect("Headline Text", "Solid Color")
  85. call CwSetPosition Face3, 2, 2, 3, 1, 0, 0
  86. Textobj = CwGetRegion(Face3)
  87. call CwSetProperty Textobj, "Caption", "Greetings by Freiheit"
  88. call CwSetProperty Textobj, "Font", "Times New Roman"
  89. Textobj = CwGetTool(Face3)
  90. call CwSetProperty Textobj, "Color", "(0,0,192)"
  91. call CwSetProperty Face3, "Translucency", "75"
  92.  
  93. /* Create the lines on which to fold the card */
  94. Fold1 = CwCreateEffect("Rectangle", "Solid Color")
  95. Lineobj = CwGetTool(Fold1)
  96. call CwSetProperty Lineobj, "Color", "(0,0,0)"
  97. call CwSetPosition Fold1, 4, 5, 8, 0.03, 0, 0
  98.  
  99. Fold1Text = CwCreateEffect("Headline Text", "Solid Color")
  100. Textobj = CwGetRegion(Fold1Text)
  101. call CwSetProperty Textobj, "Caption", "<= Fold 1st."
  102. Textobj = CwGetTool(Fold1Text)
  103. call CwSetProperty Textobj, "Color", "(192,0,192)"
  104. call CwSetPosition Fold1Text, 9, 5, 1.5, 0.5, 0, 0
  105.  
  106. Fold2 = CwCreateEffect("Rectangle", "Solid Color")
  107. Lineobj = CwGetTool(Fold2)
  108. call CwSetProperty Lineobj, "Color", "(0,0,0)"
  109. call CwSetPosition Fold2, 4, 5, 0.03, 10, 0, 0
  110.  
  111. Fold2Text = CwCreateEffect("Headline Text", "Solid Color")
  112. Textobj = CwGetRegion(Fold2Text)
  113. call CwSetProperty Textobj, "Caption", "<= Fold 2md."
  114. Textobj = CwGetTool(Fold2Text)
  115. call CwSetProperty Textobj, "Color", "(192,0,192)"
  116. call CwSetPosition Fold2Text, 4, -1, 1.5, 0.5, -90, 0
  117.  
  118. exit
  119.  
  120.  
  121. /* Prompt user for card front text */
  122. Prompt:
  123. parse arg InOut
  124.  
  125.     /* Stop drawing until we've setup the display */
  126.     call CwClearSelectionRectangle
  127.     Window=CwGetCurrentView()
  128.     call CwStopRender window
  129.  
  130.     /* Drop a white box over everything so we can see our prompts */
  131.     Boxeffect = CwCreateEffect('Rectangle', 'Solid Color')
  132.     call CwSetPosition Boxeffect, oWidth/2, oHeight/2, oWidth, oHeight, 0, 0
  133.     call CwSetName Boxeffect, "DIALOG"
  134.     Whitebox = CwGetTool(Boxeffect)
  135.     call CwSetProperty Whitebox, "Color", "(255,255,255)"
  136.  
  137.     /* Show the prompts */
  138.     Text1effect = CwCreateEffect('Headline Text', 'Solid Color')
  139.     call CwSetPosition Text1effect, oWidth/2, oHeight-oHeight/12, oWidth, oHeight/6, 0, 0
  140.     call CwSetName Text1effect, "INSTRUCTIONS"
  141.     Textobj = CwGetTool(Text1effect)
  142.     call CwSetProperty Textobj, "Color", "(0,0,0)"
  143.  
  144.     Text2effect = CwCreateEffect('Headline Text', 'Solid Color')
  145.     call CwSetPosition Text2effect, oWidth/2, (3*oHeight/5), 3.5, 4.5, 0, 0
  146.     call CwSetName Text2effect, "USERTEXT"
  147.     Textobj = CwGetTool(Text2effect)
  148.     call CwSetProperty Textobj, "Color", "(0,0,255)"
  149.  
  150.     if InOut = "Out" then
  151.         do
  152.             Textobj = CwGetRegion(Text1effect)
  153.             call CwSetProperty Textobj, "Caption", "Edit blue text below for card front."
  154.  
  155.             Textobj = CwGetRegion(Text2effect)
  156.             call CwSetProperty Textobj, "Caption", "Card front"||'0d0a'x||"text here."
  157.         end
  158.     else
  159.         do
  160.             Textobj = CwGetRegion(Text1effect)
  161.             call CwSetProperty Textobj, "Caption", "Edit blue text below for card inside."
  162.  
  163.             Textobj = CwGetRegion(Text2effect)
  164.             call CwSetProperty Textobj, "Caption", "Card inside"||'0d0a'x||"text here."
  165.         end
  166.  
  167.     Embosseffect = CwCreateEffect('Headline Text', 'Solid Color')
  168.     call CwSetPosition Embosseffect, oWidth/2, oHeight/4, oWidth, oHeight/6, 0, 0
  169.     call CwSetName Embosseffect, "EMBOSS"
  170.     Textobj = CwGetRegion(Embosseffect)
  171.     call CwSetProperty Textobj, "Caption", "Click here to emboss this text."
  172.     Textobj = CwGetTool(Embosseffect)
  173.     call CwSetProperty Textobj, "Color", "(192,0,0)"
  174.  
  175.     Text3effect = CwCreateEffect('Headline Text', 'Solid Color')
  176.     call CwSetPosition Text3effect, oWidth/2, oHeight/12, oWidth/4, oHeight/6, 0, 0
  177.     call CwSetName Text3effect, "NEXT"
  178.     Textobj = CwGetRegion(Text3effect)
  179.     call CwSetProperty Textobj, "Caption", "OK"
  180.     Textobj = CwGetTool(Text3effect)
  181.     call CwSetProperty Textobj, "Color", "(0,255,0)"
  182.  
  183.     /* Now render the screen for the user */
  184.     call CwStartRender window
  185.  
  186. return
  187.  
  188.  
  189. Wait:
  190.  
  191.     /* Begin loop to wait for button selection */
  192.     if RxFuncQuery('SysLoadFuncs') then
  193.         do
  194.             call RxFuncAdd 'SysLoadFuncs', 'REXXUTIL', 'SysLoadFuncs'
  195.             call SysLoadFuncs
  196.         end
  197.  
  198.     do forever
  199.         /* sleep */
  200.         rc = SysSleep 5
  201.  
  202.         /* see what (if anything) is selected */
  203.         Obj = CwGetSelectedObject()
  204.  
  205.         /* nothing selected?  Continue */
  206.         if \CwIsHandleValid(Obj) then iterate
  207.  
  208.         /* Something selected.  What is it? */
  209.         Name = CwGetName(Obj)
  210.  
  211.         /* if it is a button then go on */
  212.         if Name = "NEXT" then
  213.             select
  214.                 when InOut = "Out" then
  215.                     do
  216.                         o = CwGetRegion(text2effect)
  217.                         FT = CwGetProperty(o,"Caption")
  218.                         FTF = CwGetProperty(o, "Font")
  219.                         FTJ = CwGetProperty(o, "Justification")
  220.                         FTL = CwGetProperty(o, "Line Spacing")
  221.                         if Embo = "Yes" then
  222.                             do
  223.                                 FTE ="Yes"
  224.                                 Embo = "No"
  225.                             end
  226.                         o = CwGetTool(text2effect)
  227.                         FTC = CwGetProperty(o, "Color")
  228.                         leave
  229.                     end
  230.                 when InOut = "In" then
  231.                     do
  232.                         o = CwGetRegion(text2effect)
  233.                         IT = CwGetProperty(o,"Caption")
  234.                         ITF = CwGetProperty(o, "Font")
  235.                         ITJ = CwGetProperty(o, "Justification")
  236.                         ITL = CwGetProperty(o, "Line Spacing")
  237.                         if Embo = "Yes" then
  238.                             do
  239.                                 ITE ="Yes"
  240.                                 Embo = "No"
  241.                             end
  242.                         o = CwGetTool(text2effect)
  243.                         ITC = CwGetProperty(o, "Color")
  244.                         leave
  245.                     end
  246.             end
  247.  
  248.         if Name = "EMBOSS" then
  249.             select
  250.                 when Embo = "No" then
  251.                     do
  252.                         Embo = "Yes"
  253.                         call CwDeselectObject(obj)
  254.                         Textobj = CwGetRegion(Embosseffect)
  255.                         call CwSetProperty Textobj, "Caption", "Click here to turn off embossing."
  256.                         signal Wait
  257.                     end
  258.                 when Embo = "Yes" then
  259.                     do
  260.                         Embo = "No"
  261.                         call CwDeselectObject(obj)
  262.                         Textobj = CwGetRegion(Embosseffect)
  263.                         call CwSetProperty Textobj, "Caption", "Click here to emboss this text."
  264.                         signal Wait
  265.                     end
  266.             end
  267.     end
  268.  
  269.     /* delete all the prompting stuff before continuing */
  270.     rc = CwDeleteObject(Text1effect)
  271.     rc = CwDeleteObject(Text2effect)
  272.     rc = CwDeleteObject(Text3effect)
  273.     rc = CwDeleteObject(Embosseffect)
  274.     rc = CwDeleteObject(Boxeffect)
  275.  
  276. return
  277.