
%% ----------------------------------
%% Gaudy Definitions ----------------
%% ----------------------------------

/QSU { 100000 mul 72 div } def
/DateFont {
    findfont 16 QSU scalefont setfont
} def
/PageNoFont {
    findfont 30 QSU scalefont setfont
} def
/TitleFont {
    findfont 20 QSU scalefont setfont
} def

%% Format : <gray_level> <left> <bottom> <width> <height> Rectangle
/Rectangle
{
    /height exch def
    /width exch def
    /bottom exch def
    /left exch def
    /gray exch def
    gray setgray
    newpath
    left bottom moveto
    0 height rlineto
    width 0 rlineto
    0 height neg rlineto
    closepath
} bind def
%% Format : <gray_level> <left> <bottom> <width> <height> RoundRectangle
/RoundRectangle
{
    /height exch def
    /width exch def
    /bottom exch def
    /left exch def
    /gray exch def
    /fourpops { 4 {pop} repeat } def
    /radius 18 QSU def
    gray setgray
    gsave
        left bottom translate
        newpath
        0 radius moveto
        0 height width height radius arcto fourpops
        width height width 0 radius arcto fourpops
        width 0 0 0 radius arcto fourpops
        0 0 0 height radius arcto fourpops
        fill
    grestore
} bind def
%% Format : <gray> <bounding_width> <bounding_height> <string> CentreString
/CentreString {
    /str exch def
    /ht  exch def
    /wd  exch def
    /gray  exch def
    gsave
        gray 0 0 wd ht Rectangle clip
        str dup
        wd exch
        stringwidth ht 
        sub abs 2 div 2 div
        3 1 roll 
        sub abs 2 div
        exch moveto
        show
    grestore
} bind def

/GaudyHeader {
    /Page  exch def
    /landscape  exch def
    /hdrHt 50 QSU def
    /leftWd 72 QSU def
    /Offset 2 QSU def
    newpath clippath pathbbox   %% Get imageable area in the current units
    /URy exch def
    /URx exch def
    /LLy exch def
    /LLx exch def
    landscape 1 eq
    { LLx URy translate -90 rotate } if
    newpath clippath pathbbox   %% Get imageable area in the current units
    /URy exch def
    /URx exch def
    /LLy exch def
    /LLx exch def
    /TM URy Offset sub def
    /BM LLy Offset add def
    /LM LLx Offset add def
    /RM URx Offset sub def
    gsave
        /Times-Bold DateFont
        LM TM hdrHt sub abs translate
        .8 0 0 leftWd hdrHt RoundRectangle 
        0 setgray
        7 QSU 30 QSU moveto
        Date show
        7 QSU 10 QSU moveto
        Time show
        gsave
            /Times-Bold PageNoFont
            RM LM sub leftWd sub abs 0 translate
            .8 0 0 leftWd hdrHt RoundRectangle 
            0 leftWd hdrHt Page CentreString
        grestore
        gsave
            /Helvetica-Bold TitleFont
            /InnerWd { RM LM sub leftWd 2 mul sub abs } def
            /CBar 30 QSU def
            leftWd 10 QSU translate
            .9 0 0 InnerWd CBar RoundRectangle 
            0 InnerWd CBar Title CentreString
        grestore
    grestore
} bind def

