home *** CD-ROM | disk | FTP | other *** search
/ High Voltage Shareware / high1.zip / high1 / DIR24 / REMIN301.ZIP / PATCH301.ZIP / REM2PS.H < prev    next >
Text File  |  1992-12-28  |  6KB  |  169 lines

  1. /***************************************************************/
  2. /*                                                             */
  3. /*  REM2PS.H                                                   */
  4. /*                                                             */
  5. /*  Define the PostScript prologue                             */
  6. /*                                                             */
  7. /*  This file is part of REMIND.                               */
  8. /*  Copyright (C) 1992 by David F. Skoll.                      */
  9. /*                                                             */
  10. /***************************************************************/
  11.  
  12. char *PSProlog[] =
  13. {
  14.    "% L - Draw a line",
  15.    "/L {",
  16.    "   newpath moveto lineto stroke",
  17.    "} bind def",
  18.    "% string1 string2 strcat string",
  19.    "% Function: Concatenates two strings together.",
  20.    "/strcat {",
  21.    "         2 copy length exch length add",
  22.    "         string dup",
  23.    "         4 2 roll",
  24.    "         2 index 0 3 index",
  25.    "         putinterval",
  26.    "         exch length exch putinterval",
  27.    "} bind def",
  28.    "% string doheading",
  29.    "/doheading",
  30.    "{",
  31.    "   /monthyr exch def",
  32.    "   ",
  33.    "   HeadFont findfont",
  34.    "   HeadSize scalefont setfont   ",
  35.    "   monthyr stringwidth",
  36.    "   pop",
  37.    "   2 div MaxX MinX add 2 div exch sub /x exch def",
  38.    "   MaxY HeadSize 1.5 mul sub /y exch def",
  39.    "   newpath x y moveto monthyr show",
  40.    "   y HeadSize 0.5 mul sub /y exch def",
  41.    "   MinX y MaxX y L",
  42.    "   /topy y def",
  43.    "% Do the days of the week",
  44.    "   MaxX MinX sub 7 div /xincr exch def",
  45.    "   /x MinX def",
  46.    "  [(Sunday) (Monday) (Tuesday) (Wednesday) (Thursday) (Friday) (Saturday)]",
  47.    "  {",
  48.    "     HeadSize x y HeadSize 2 mul sub x xincr add y CenterText",
  49.    "     x xincr add /x exch def",
  50.    "  } forall",
  51.    "  y HeadSize 2 mul sub /y exch def",
  52.    "  MinX y MaxX y L",
  53.    "  /ytop y def /ymin y def",
  54.    "}",
  55.    "def",
  56.    "/CenterText",
  57.    "{",
  58.    "   /maxy exch def",
  59.    "   /maxx exch def",
  60.    "   /miny exch def",
  61.    "   /minx exch def",
  62.    "   /sz exch def",
  63.    "   /str exch def",
  64.    "   str stringwidth pop",
  65.    "   2 div maxx minx add 2 div exch sub",
  66.    "   sz 2 div maxy miny add 2 div exch sub",
  67.    "   moveto str show",
  68.    "} def",
  69.    "% Variables:",
  70.    "% curline - a string holding the current line",
  71.    "% y - current y pos",
  72.    "% yincr - increment to next line",
  73.    "% xleft - left margin",
  74.    "% width - max width.",
  75.    "% EnterOneWord - given a word, enter it into the box.",
  76.    "% string EnterOneWord",
  77.    "/EnterOneWord {",
  78.    "   { EnterOneWordAux",
  79.    "     {exit} if }",
  80.    "   loop",
  81.    "} bind def",
  82.    "% EnterOneWordAux - if the word fits, enter it into box and return true.",
  83.    "% If it doesn't fit, put as much as will fit and return the string and false.",
  84.    "/EnterOneWordAux {",
  85.    "   /word exch def",
  86.    "   /tmpline curline word strcat def",
  87.    "   tmpline stringwidth pop width gt",
  88.    "   {MoveToNewLine}",
  89.    "   {/curline tmpline ( ) strcat def /word () def}",
  90.    "   ifelse",
  91.    "   word () eq",
  92.    "   {true}",
  93.    "   {word false}",
  94.    "   ifelse",
  95.    "} bind def",
  96.    "% MoveToNewLine - move to a new line, resetting word as appropriate",
  97.    "/MoveToNewLine {",
  98.    "   curline () ne",
  99.    "   {newpath xleft y moveto curline show /curline () def /y y yincr add def}   ",
  100.    "   {ChopWord}",
  101.    "   ifelse",
  102.    "} bind def",
  103.    "% ChopWord - word won't fit.  Chop it and find biggest piece that will fit",
  104.    "/ChopWord {",
  105.    "   /curline () def",
  106.    "   /len word length def",
  107.    "   /Fcount len 1 sub def",
  108.    "   ",
  109.    "   {",
  110.    "     word 0 Fcount getinterval stringwidth pop width le",
  111.    "     {exit} if",
  112.    "     /Fcount Fcount 1 sub def",
  113.    "   } loop",
  114.    "% Got the count.  Display it and reset word",
  115.    "   newpath xleft y moveto word 0 Fcount getinterval show",
  116.    "   /y y yincr add def",
  117.    "   /word word Fcount len Fcount sub getinterval def",
  118.    "} bind def",
  119.    "/FinishFormatting {",
  120.    "   word () ne",
  121.    "   {newpath xleft y moveto word show /word () def",
  122.    "    /curline () def /y y yincr add def}",
  123.    "   {curline () ne",
  124.    "     {newpath xleft y moveto curline show /word () def",
  125.    "      /curline () def /y y yincr add def} if}",
  126.    "   ifelse",
  127.    "} bind def",
  128.    "% FillBoxWithText - fill a box with text",
  129.    "% text-array xleft width yincr y FillBoxWithText new-y",
  130.    "% Returns the new Y-coordinate.",
  131.    "/FillBoxWithText {",
  132.    "   /y exch def",
  133.    "   /yincr exch def",
  134.    "   /width exch def",
  135.    "   /xleft exch def",
  136.    "   /curline () def",
  137.    "   {EnterOneWord} forall",
  138.    "   FinishFormatting",
  139.    "   y",
  140.    "} bind def",
  141.    "% Variables for calendar boxes:",
  142.    "% ytop - current top position",
  143.    "% ymin - minimum y reached for current row",
  144.    "% border ytop xleft width textarray daynum DoCalBox ybot",
  145.    "% Do the entries for one calendar box.  Returns lowest Y-coordinate reached",
  146.    "/DoCalBox {",
  147.    "   /daynum exch def",
  148.    "   /textarr exch def",
  149.    "   /wid exch def",
  150.    "   /xl exch def",
  151.    "   /yt exch def",
  152.    "   /border exch def",
  153.    "% Do the day number",
  154.    "   DayFont findfont DaySize scalefont setfont",
  155.    "   xl wid add border sub daynum stringwidth pop sub",
  156.    "   yt border sub DaySize sub moveto daynum show",
  157.    "% Do the text entries.  Precharge the stack with current y pos.",
  158.    "   /ycur yt border sub DaySize sub DaySize sub 2 add def",
  159.    "   EntryFont findfont EntrySize scalefont setfont",
  160.    "   ycur",
  161.    "   textarr",
  162.    "   { exch 2 sub /ycur exch def xl border add wid border sub border sub EntrySize 2 add neg",
  163.    "     ycur FillBoxWithText }",
  164.    "    forall",
  165.    "} bind def",
  166.    "2 setlinecap",
  167.    NULL
  168. };
  169.