changeset 37288:f7aaa73f592e

Footer implementation. Doc fix. (doLineNumber): Code fix for line number color. (BeginPage, BeginSheet, HeaderFramePath, HeaderFrame, HeaderText): Code fix for footer implementation. (TextStart, SetFooterLines, FooterFrameStart, doFramePath) (FooterFramePath, doFrame, FooterFrame, FooterStart) (HeaderOrFooterTextLines, HeaderOrFooterText, FooterText): New funs.
author Gerd Moellmann <gerd@gnu.org>
date Tue, 10 Apr 2001 11:34:26 +0000
parents 5601685e2d51
children a1af2574e64b
files etc/ps-prin1.ps
diffstat 1 files changed, 113 insertions(+), 48 deletions(-) [+]
line wrap: on
line diff
--- a/etc/ps-prin1.ps	Tue Apr 10 11:33:06 2001 +0000
+++ b/etc/ps-prin1.ps	Tue Apr 10 11:34:26 2001 +0000
@@ -348,7 +348,7 @@
    LineNumber Lines ge or	% or last line
    {currentfont
     gsave
-    0.0 0.0 0.0 setrgbcolor
+    LineNumberColor SetColor
     /L0 findfont setfont
     LineNumber Lines ge
     {(end      )}
@@ -507,11 +507,14 @@
     printGlobalBackground
     printLocalBackground
   }if
-  PrintHeader{
-    PrintOnlyOneHeader{ColumnIndex 1 eq}{true}ifelse{
-      PrintHeaderFrame{HeaderFrame}if
-      HeaderText
-    }if
+  PrintOnlyOneHeader{ColumnIndex 1 eq}{true}ifelse
+  dup PrintHeader and{
+    PrintHeaderFrame{HeaderFrame}if
+    HeaderText
+  }if
+  PrintFooter and{
+    PrintFooterFrame{FooterFrame}if
+    FooterText
   }if
   0 PrintStartY moveto			% move to where printing will start
   /LineNumber where
@@ -551,6 +554,15 @@
   }ifelse
 }def
 
+/TextStart{
+  LeftMargin BottomMargin
+  PrintFooter{
+    FooterPad add
+    FooterLines FooterLineHeight mul add
+    FooterPad add
+    FooterOffset add}if
+}def
+
 % stack: number-of-pages-per-sheet |- --
 /BeginSheet{
   /sheetState save def
@@ -605,14 +617,14 @@
     translate
   }if
   % ---- translate to lower left corner of TEXT
-  LeftMargin BottomMargin translate
+  TextStart translate
 
   % ---- N-up printing
   N-Up 1 gt N-Up-Border and pages-per-sheet 0 gt and{
     % ---- page border
     gsave
     0 setgray
-    LeftMargin neg BottomMargin neg moveto
+    TextStart exch neg exch neg moveto
     N-Up-Repeat
     {N-Up-End
      {gsave
@@ -647,6 +659,15 @@
   /HeaderHeight exch def
 }def
 
+/SetFooterLines{			% nb-lines --
+  /FooterLines exch def
+  % ---- bottom up
+  FooterPad
+  FooterLines FooterLineHeight mul add
+  FooterPad add
+  /FooterHeight exch def
+}def
+
 % |---------|
 % |  tm     |
 % |---------|
@@ -655,36 +676,52 @@
 % |  ho     |
 % |---------|
 % |  text   |
+% |---------|
+% |  fo     |
+% |---------|
+% |  footer |
 % |-+-------| <-- (0 0)
 % |  bm     |
 % |---------|
 
 % -- |- x y
 /HeaderFrameStart{0  PrintHeight HeaderOffset add}def
+/FooterFrameStart{0  FooterHeight FooterOffset add neg}def
 
-/HeaderFramePath{
-  PrintHeaderWidth	0			rlineto
-  0			HeaderHeight		rlineto
-  PrintHeaderWidth neg	0			rlineto
-  0			HeaderHeight neg	rlineto
+/doFramePath{
+  /h exch def
+  PrintHeaderWidth	0	rlineto
+  0			h	rlineto
+  PrintHeaderWidth neg	0	rlineto
+  0			h neg	rlineto
 }def
 
-/HeaderFrame{
+/HeaderFramePath{HeaderHeight doFramePath}def
+/FooterFramePath{FooterHeight doFramePath}def
+
+% /path-fun /start-fun vector-property doFrame
+/doFrame{
+  /vecFrame exch def
+  /startFrame exch load def
+  /pathFrame exch load def
   gsave
-    0.4 setlinewidth
-    % ---- fill a black rectangle (the shadow of the next one)
-    HeaderFrameStart moveto
+    vecFrame 2 get setlinewidth				% frame border width
+    % ---- do the shadow of the next rectangle
+    startFrame moveto
     1 -1 rmoveto
-    HeaderFramePath
-    0 setgray fill
+    pathFrame
+    vecFrame 4 get SetColor fill			% frame shadow color
     % ---- do the next rectangle ...
-    HeaderFrameStart moveto
-    HeaderFramePath
-    gsave 0.9 setgray fill grestore	% filled with grey
-    gsave 0 setgray stroke grestore	% drawn  with black
+    startFrame moveto
+    pathFrame
+    gsave vecFrame 1 get SetColor fill grestore		% frame background
+    gsave vecFrame 3 get SetColor stroke grestore	% frame border color
   grestore
 }def
 
+/HeaderFrame{/HeaderFramePath /HeaderFrameStart HeaderFrameProperties doFrame}def
+/FooterFrame{/FooterFramePath /FooterFrameStart FooterFrameProperties doFrame}def
+
 /HeaderStart{
   HeaderFrameStart
   exch HeaderPad add exch	% horizontal pad
@@ -694,6 +731,15 @@
   HeaderLineHeight HeaderLines 1 sub mul add
 }def
 
+/FooterStart{
+  FooterFrameStart
+  exch FooterPad add exch	% horizontal pad
+  % ---- bottom up
+  FooterPad add			% vertical   pad
+  FooterDescent sub
+  FooterLineHeight FooterLines 1 sub mul add
+}def
+
 /strcat{
   dup length 3 -1 roll dup length dup 4 -1 roll add string dup
   0 5 -1 roll putinterval
@@ -705,39 +751,58 @@
   ShowNofN{(/)strcat PageCount 32 string cvs strcat}if
 }def
 
-/HeaderText{
-  HeaderStart moveto
+% lines is-right HeaderOrFooterTextLines
+/HeaderOrFooterTextLines{
+  /is_right exch def
+  HFStart moveto
+  { % ---- process the lines
+   aload pop
+   exch F
+   gsave
+    dup xcheck{exec}if
+    is_right{
+     dup stringwidth pop
+     PrintHeaderWidth exch sub HFPad HFPad add sub 0 rmoveto
+    }if
+    HFColor SetColor
+    show
+   grestore
+   0 HFLineHeight neg rmoveto
+  }forall
+}def
 
-  HeaderLinesRight HeaderLinesLeft	% -- rightLines leftLines
+% right-lines left-lines /start lineheight pad fore-color HeaderOrFooterText
+/HeaderOrFooterText{
+  /HFColor exch def
+  /HFPad exch def
+  /HFLineHeight exch def
+  /HFStart exch load def
+
+  % -- rightLines leftLines -- at stack
 
   % ---- hack: `PN 1 and'  ==  `PN 2 modulo'
-
   % ---- if even page number and duplex, then exchange left and right
   PageNumber 1 and 0 eq SwitchHeader and{exch}if
 
-  { % ---- process the left lines
-    aload pop
-    exch F
-    gsave
-      dup xcheck{exec}if
-      show
-    grestore
-    0 HeaderLineHeight neg rmoveto
-  }forall
+  % ---- process the left lines
+  false HeaderOrFooterTextLines
 
-  HeaderStart moveto
+  % ---- process the right lines
+  true HeaderOrFooterTextLines
+}def
 
-  { % ---- process the right lines
-    aload pop
-    exch F
-    gsave
-      dup xcheck{exec}if
-      dup stringwidth pop
-      PrintHeaderWidth exch sub HeaderPad 2 mul sub 0 rmoveto
-      show
-    grestore
-    0 HeaderLineHeight neg rmoveto
-  }forall
+/HeaderText{
+  HeaderLinesRight HeaderLinesLeft
+  /HeaderStart HeaderLineHeight HeaderPad
+  HeaderFrameProperties 0 get
+  HeaderOrFooterText
+}def
+
+/FooterText{
+  FooterLinesRight FooterLinesLeft
+  /FooterStart FooterLineHeight FooterPad
+  FooterFrameProperties 0 get
+  HeaderOrFooterText
 }def
 
 /ReportFontInfo{