home *** CD-ROM | disk | FTP | other *** search
/ Blender Volume 3 #4 / Blender_3_4.iso / BLENDER / FILES / Shared.Cst / 00059.ls < prev    next >
Encoding:
Text File  |  1997-01-01  |  11.3 KB  |  450 lines

  1. global gOpSys -- the local operating system
  2.  
  3.  
  4. --PRINTING PROCEDURES
  5. --from GREY MATTER DESIGN
  6. on PrintBitmap theCast
  7.   
  8.   -- a Lingo script for printing a castmember bitmap
  9.   -- using the PrintOMatic Xtra
  10.   -- the parameter "theCast" represents the castmember you want to print
  11.   
  12.   -- This script prints the castmember at up to 100% size,
  13.   -- centered on the page. It will change the page
  14.   -- orientation to landscape mode if it will result in a bigger printout.
  15.   
  16.   -- PARAMETERS:
  17.   -- theCast is the number or name of a bitmapped castmember
  18.   
  19.   if the Type of member theCast <> #bitmap then
  20.     --    alert "PrintBitmap can only print bitmapped castmembers."
  21.     exit
  22.   end if
  23.   
  24.   --  if the machineType = 256 then
  25.   --    put "pmatic.dll" into XObjFile
  26.   --  else
  27.   --    put "BLENDER1:FILES:pmatic.xobj" into XObjFile
  28.   --  end if
  29.   
  30.   set doc = new(xtra "PrintOMatic")
  31.   if not objectP(doc) then exit
  32.   
  33.   --  openxlib XObjFile
  34.   
  35.   --  put PrintOMatic(mNew) into printer
  36.   
  37.   --  if not objectP(printer) then
  38.   --    -- something went wrong, the Xtra was not instantiated
  39.   --    Alert "There is no currently selected printer. Printing features are disabled."
  40.   --  else
  41.   
  42.   -- register your Xtra here!
  43.   --    printer(mRegister,"PMAT130-925-01031")
  44.   register(xtra "PrintOMatic", "PMAT130-925-01031")
  45.   
  46.   -- get the page size
  47.   --  put printer(mGetPageWidth) into pw
  48.   --  put printer(mGetPageHeight) into ph
  49.   set w = getPageWidth(doc)
  50.   set h = getPageHeight(doc)
  51.   
  52.   -- figure out scaling
  53.   put the width of member theCast into w
  54.   put the height of member  theCast into h
  55.   put min(float(pw)/float(w),float(ph)/float(h)) into scaling
  56.   
  57.   -- see if we can print bigger by switching to landscape mode
  58.   if scaling < 1.0 and w > h then 
  59.     --    printer(mSetLandscapeMode,TRUE)
  60.     setLandscapeMode(doc, TRUE)
  61.     set pw = getPageWidth(doc)
  62.     set ph = getPageHeight(doc)
  63.     --    put printer(mGetPageWidth) into pw
  64.     --    put printer(mGetPageHeight) into ph
  65.     put min(float(pw)/float(w),float(ph)/float(h)) into scaling
  66.   end if
  67.   
  68.   -- fix scaling not to exceed 100 percent
  69.   put min(scaling,1.0) into scaling
  70.   
  71.   -- figure out the printed size and page location
  72.   put integer(w*scaling) into w
  73.   put integer(h*scaling) into h
  74.   put (pw-w)/2 into left
  75.   put (ph-h)/2 into top
  76.   
  77.   -- now make a page and put the image on it
  78.   --  printer(mNewPage)
  79.   newPage(doc)
  80.   
  81.   --  printer(mPicture,the picture of cast theCast, rect(left,top,left+w,top+h))
  82.   drawPicture doc,  member theCast, rect(left,top,left+w,top+h)
  83.   
  84.   -- and print
  85.   
  86.   --  if printer (mDoJobSetup) = true then
  87.   if  doJobSetup(doc) = TRUE then
  88.     updateStage
  89.     --    printer (mPrint)
  90.     print(doc)
  91.   end if
  92.   
  93.   --  printer(mDispose)
  94.   set doc = 0
  95.   --end if
  96.   
  97.   
  98.   -- close the PrintOMatic Xtra
  99.   --closexlib XObjFile
  100.   
  101. end PrintBitmap 
  102.  
  103.  
  104. on PrintBitmap_W_Text theCast, theText
  105.   
  106.   -- a Lingo script for printing a castmember bitmap
  107.   -- using the PrintOMatic Xtra
  108.   -- the parameter "theCast" represents the castmember you want to print
  109.   
  110.   -- PARAMETERS:
  111.   -- theCast is the number or name of a bitmapped castmember
  112.   
  113.   -- Modified 8/21 -- top justify the bitmap and 
  114.   -- print a textbox under it
  115.   
  116.   if the castType of cast theCast <> #bitmap then
  117.     --    alert "PrintBitmap can only print bitmapped castmembers."
  118.     exit
  119.   end if
  120.   
  121.   set doc = new(xtra "PrintOMatic")
  122.   if not objectP(doc) then exit
  123.   
  124.   if the machineType = 256 then
  125.     --    put "pmatic.dll" into XObjFile
  126.     --    put "arial" into printingFont
  127.     setTextFont doc, "arial"
  128.   else
  129.     --    put "BLENDER1:FILES:pmatic.xobj" into XObjFile
  130.     --    put "helvetica" into printingFont
  131.     setTextFont doc,  "helvetica" 
  132.   end if
  133.   
  134.   --  openxlib XObjFile
  135.   
  136.   --  put PrintOMatic(mNew) into printer
  137.   
  138.   --  if not objectP(printer) then
  139.   --    -- something went wrong, the Xtra was not instantiated
  140.   --    Alert "There is no currently selected printer. Printing features are disabled."
  141.   --  else
  142.   
  143.   -- register your Xtra here!
  144.   --  printer(mRegister,"PMAT130-925-01031")
  145.   
  146.   register(xtra "PrintOMatic", "PMAT130-925-01031")
  147.   
  148.   
  149.   -- get the page size
  150.   --  put printer(mGetPageWidth) into pw
  151.   --  put printer(mGetPageHeight) into ph
  152.   set w = getPageWidth(doc)
  153.   set h = getPageHeight(doc)
  154.   
  155.   -- figure out scaling
  156.   put the width of cast theCast into w
  157.   put the height of cast theCast into h
  158.   
  159.   -- new 8/21
  160.   set left = 0
  161.   set top = 0
  162.   -- now make a page and put the image on it
  163.   --  printer(mNewPage)
  164.   newPage(doc)
  165.   --  printer(mPicture,the picture of cast theCast,left,top,left+w,top+h)
  166.   drawPicture doc, the picture of cast theCast,left,top,left+w,top+h
  167.   
  168.   set bitmapBottom = top + h + 16
  169.   
  170.   --  put printer (mGetPageWidth) into w
  171.   --  put printer (mGetPageHeight) into h
  172.   set w = getPageWidth(doc)
  173.   set h = getPageHeight(doc)
  174.   
  175.   
  176.   --  printer (mSetTextFont,printingFont)
  177.   --  printer (mSetTextSize,7)
  178.   setTextFont doc, "printingFont"
  179.   setTextSize doc, 7
  180.   
  181.   --  printer (mSetTextStyle,"normal")
  182.   setTextStyle doc, "normal"
  183.   
  184.   -- start the first text box at the bottom of the bitmap
  185.   --  printer (mTextBox,0,bitmapBottom,w,h,true)
  186.   newFrame doc, Rect(0,bitmapBottom,w,h), TRUE
  187.   
  188.   -- place the text onto the first page
  189.   -- with the "autoAppend" parameter set to false
  190.   --  printer (mSetText, theText, false)
  191.   append doc,  theText, FALSE
  192.   
  193.   -- guess the number of pages based on font
  194.   -- size 7: one line = 7.28 pixels
  195.   set numLines = the number of lines in theText
  196.   set totEstPixels = numLines * 7.28
  197.   -- allow for first page
  198.   set totEstPixels = totEstPixels - (h-bitMapBottom)
  199.   set totFractionalPages = totEstPixels/h
  200.   set totAddlPages = integer(totFractionalPages)
  201.   -- make sure we have not added and extra page
  202.   -- due to the integer rounding up from a >.5 decimal
  203.   if (totFractionalPages > integer(totFractionalPages))then 
  204.     -- the decimal place was < .5  
  205.     set totAddlPages = totAddlPages + 1
  206.   end if
  207.   
  208.   repeat with n = 1 to totAddlPages
  209.     --    printer(mNewPage)
  210.     newPage(doc)
  211.     --    printer (mTextBox,0,72,w,h,true)
  212.     newFrame doc, Rect(0,72,w,h), TRUE
  213.     --    printer (mSetText, theText, false)
  214.     append doc,  theText, FALSE
  215.   end repeat
  216.   
  217.   -- and print
  218.   
  219.   if  doJobSetup(doc) = TRUE then
  220.     updateStage
  221.     --    printer (mPrint)
  222.     print(doc)
  223.   end if
  224.   
  225.   --  if printer (mDoJobSetup) = true then
  226.   --    updateStage
  227.   --    if the optionDown then
  228.   --      printer (mPrintPreview)
  229.   --    else
  230.   --      printer (mPrint)
  231.   --    end if
  232.   --    
  233.   --end if
  234.   
  235.   
  236.   set doc = 0
  237.   
  238.   --  printer(mDispose)
  239.   
  240.   --end if
  241.   
  242.   
  243.   -- close the PrintOMatic Xtra
  244.   --closexlib XObjFile
  245.   
  246. end PrintBitmap_W_Text 
  247.  
  248.  
  249. on min a,b
  250.   -- a little script that returns the lesser of two values
  251.   if a<b then 
  252.     return a
  253.   else
  254.     return b
  255.   end if
  256. end
  257.  
  258.  
  259. on PrintTexta textStringBig, textStringLittle
  260.   
  261.   -- a Lingo script for printing an arbitrary quantity of text
  262.   -- using the PrintOMatic Xtra
  263.   
  264.   -- 2/15/96 Modify handler to print two blocks of text
  265.   -- using different font sizes
  266.   
  267.   -- PARAMETERS:
  268.   -- textString is a string value, the text you want to print
  269.   
  270.   --  if the machineType = 256 then
  271.   --    put "arial" into printingFont
  272.   --    put "pmatic.dll" into XObjFile
  273.   --  else
  274.   --    put "helvetica" into printingFont
  275.   --    put "BLENDER1:FILES:pmatic.xobj" into XObjFile
  276.   --  end if
  277.   set doc = new(xtra "PrintOMatic")
  278.   if not objectP(doc) then exit
  279.   
  280.   if the machineType = 256 then
  281.     setTextFont doc, "arial"
  282.   else
  283.     setTextFont doc,  "helvetica" 
  284.   end if
  285.     
  286.   --  openxlib XObjFile
  287.   --  put PrintOMatic(mnew) into printer
  288.   
  289.   --  if not objectP(printer) then
  290.   --    -- something went wrong, the Xtra was not instantiated
  291.   --    Alert "There is no currently selected printer. Printing features are disabled."
  292.   --  else
  293.   
  294.   -- register your Xtra here!
  295.   --  printer(mRegister,"PMAT130-925-01031")
  296.   register(xtra "PrintOMatic", "PMAT130-925-01031")
  297.   
  298.   -- set the page margins
  299.   --  printer (mSetMargins,72,72,72,72)
  300.   setMargins doc, rect(72,72,72,72)
  301.   
  302.   --  put printer (mGetPageWidth) into w
  303.   --  put printer (mGetPageHeight) into h
  304.   set w = getPageWidth(doc)
  305.   set h = getPageHeight(doc)
  306.   
  307.   --  printer (mSetTextFont,printingFont)
  308.   --  setTextFont doc, printingFont
  309.   
  310.   --  printer (mSetTextSize,10)
  311.   setTextSize doc, 10
  312.   
  313.   --  printer (mSetTextStyle,"normal")
  314.   setTextStyle doc, "normal"
  315.   
  316.   -- set up our first page and text box
  317.   --  printer (mNewPage)
  318.   newPage(doc)
  319.   --  printer (mTextBox,0,0,w,h,false)
  320.   newFrame doc, Rect(0,0,w,h), FALSE
  321.   
  322.   -- and place the appropriate text (the first block) onto it
  323.   -- with the "autoAppend" parameter set to true
  324.   -- printer (mSetText, textStringBig, true)
  325.   append doc, textStringBig, TRUE
  326.   
  327.   -- add the second block of text
  328.   -- note use of "mAppendText"
  329.   --  printer (mSetTextSize,7)
  330.   setTextSize doc, 7
  331.   printer (mAppendText, textStringLittle, true)
  332.   append doc, textStringLittle, TRUE
  333.   
  334.   if  doJobSetup(doc) = TRUE then
  335.     updateStage
  336.     if the optionDown then 
  337.       printPreview(doc)
  338.     else
  339.       print(doc)
  340.     end if
  341.   end if
  342.   
  343.   --  if printer (mDoJobSetup) = true then
  344.   --    updateStage
  345.   --    if the optionDown then
  346.   --      printer (mPrintPreview)
  347.   --    else
  348.   --      printer (mPrint)
  349.   --    end if
  350.   
  351.   --end if
  352.   
  353.   --printer(mDispose)
  354.   
  355.   set doc = 0
  356.   
  357.   --end if
  358.   
  359.   
  360.   -- close the PrintOMatic Xtra
  361.   --  closexlib XObjFile
  362.   
  363.   
  364. end printTexta 
  365.  
  366.  
  367. on PrintText textString
  368.   
  369.   -- a Lingo script for printing an arbitrary quantity of text
  370.   -- using the PrintOMatic Xtra
  371.   
  372.   -- PARAMETERS:
  373.   -- textString is a string value, the text you want to print
  374.   set doc = new(xtra "PrintOMatic")
  375.   if not objectP(doc) then exit
  376.   
  377.   if the machineType = 256 then
  378.     setTextFont doc, "arial"
  379.   else
  380.     setTextFont doc,  "helvetica" 
  381.   end if
  382.   
  383.   
  384.   --  if the machineType = 256 then
  385.   --    put "arial" into printingFont
  386.   --    put "pmatic.dll" into XObjFile
  387.   --  else
  388.   --    put "helvetica" into printingFont
  389.   --    put "BLENDER1:FILES:pmatic.xobj" into XObjFile
  390.   --  end if
  391.   --  
  392.   --  openxlib XObjFile
  393.   --  put PrintOMatic(mnew) into printer
  394.   
  395.   --  if not objectP(printer) then
  396.   --    -- something went wrong, the Xtra was not instantiated
  397.   --    Alert "There is no currently selected printer. Printing features are disabled."
  398.   --  else
  399.   
  400.   -- register your Xtra here!
  401.   --  printer(mRegister,"PMAT130-925-01031")
  402.   register(xtra "PrintOMatic", "PMAT130-925-01031")
  403.   
  404.   -- set the page margins
  405.   --  printer (mSetMargins,72,72,72,72)
  406.   setMargins doc, rect(72,72,72,72)
  407.   
  408.   --  put printer (mGetPageWidth) into w
  409.   --  put printer (mGetPageHeight) into h
  410.   set w = getPageWidth(doc)
  411.   set h = getPageHeight(doc)
  412.   
  413.   --  printer (mSetTextFont,printingFont)
  414.   --  setTextFont doc, printingFont
  415.   
  416.   --  printer (mSetTextSize,10)
  417.   --  printer (mSetTextStyle,"normal")
  418.   setTextSize doc, 10
  419.   setTextStyle doc, "normal"
  420.   
  421.   -- set up our first page and text box
  422.   --  printer (mNewPage)
  423.   newPage(doc)
  424.   --  printer (mTextBox,0,0,w,100,false)
  425.   newFrame doc, Rect(0,0,w,h), FALSE
  426.   
  427.   -- and place the appropriate text onto it
  428.   -- with the "autoAppend" parameter set to true
  429.   --  printer (mSetText, textString, true)
  430.   append doc, textString, TRUE
  431.   
  432.   if  doJobSetup(doc) = TRUE then
  433.     updateStage
  434.     if the optionDown then 
  435.       printPreview(doc)
  436.     else
  437.       print(doc)
  438.     end if
  439.   end if
  440.   
  441.   --  printer(mDispose)
  442.   set doc = 0
  443.   
  444.   --end if
  445.   
  446.   
  447.   -- close the PrintOMatic Xtra
  448.   --closexlib XObjFile
  449.   
  450. end printText