home *** CD-ROM | disk | FTP | other *** search
/ PSION CD 2 / PsionCDVol2.iso / Programs / 720 / PDF090B4-SorceCode / pdf / PSOutputDev.h < prev    next >
Encoding:
C/C++ Source or Header  |  2000-09-30  |  5.1 KB  |  161 lines

  1. //========================================================================
  2. //
  3. // PSOutputDev.h
  4. //
  5. // Copyright 1996 Derek B. Noonburg
  6. //
  7. //========================================================================
  8.  
  9. #ifndef PSOUTPUTDEV_H
  10. #define PSOUTPUTDEV_H
  11.  
  12. #ifdef __GNUC__
  13. #pragma interface
  14. #endif
  15.  
  16. #include <stddef.h>
  17. #include "config.h"
  18. #include "Object.h"
  19. #include "OutputDev.h"
  20.  
  21. class GfxPath;
  22. class GfxFont;
  23.  
  24. //------------------------------------------------------------------------
  25. // Parameters
  26. //------------------------------------------------------------------------
  27.  
  28. // Generate Level 1 PostScript?
  29. extern GBool psOutLevel1;
  30.  
  31. // Paper size.
  32. extern int paperWidth;
  33. extern int paperHeight;
  34.  
  35. //------------------------------------------------------------------------
  36. // PSOutputDev
  37. //------------------------------------------------------------------------
  38.  
  39. enum PSFileType {
  40.   psFile,            // write to file
  41.   psPipe,            // write to pipe
  42.   psStdout            // write to stdout
  43. };
  44.  
  45. class PSOutputDev: public OutputDev {
  46. public:
  47.  
  48.   // Open a PostScript output file, and write the prolog.
  49.   PSOutputDev(char *fileName, Catalog *catalog,
  50.           int firstPage, int lastPage,
  51.           GBool embedType11, GBool doForm1);
  52.  
  53.   // Destructor -- writes the trailer and closes the file.
  54.   virtual ~PSOutputDev();
  55.  
  56.   // Check if file was successfully created.
  57.   virtual GBool isOk() { return ok; }
  58.  
  59.   //---- get info about output device
  60.  
  61.   // Does this device use upside-down coordinates?
  62.   // (Upside-down means (0,0) is the top left corner of the page.)
  63.   virtual GBool upsideDown() { return gFalse; }
  64.  
  65.   // Does this device use drawChar() or drawString()?
  66.   virtual GBool useDrawChar() { return gFalse; }
  67.  
  68.   //----- initialization and control
  69.  
  70.   // Start a page.
  71.   virtual void startPage(int pageNum, GfxState *state);
  72.  
  73.   // End a page.
  74.   virtual void endPage();
  75.  
  76.   //----- save/restore graphics state
  77.   virtual void saveState(GfxState *state);
  78.   virtual void restoreState(GfxState *state);
  79.  
  80.   //----- update graphics state
  81.   virtual void updateCTM(GfxState *state, double m11, double m12,
  82.              double m21, double m22, double m31, double m32);
  83.   virtual void updateLineDash(GfxState *state);
  84.   virtual void updateFlatness(GfxState *state);
  85.   virtual void updateLineJoin(GfxState *state);
  86.   virtual void updateLineCap(GfxState *state);
  87.   virtual void updateMiterLimit(GfxState *state);
  88.   virtual void updateLineWidth(GfxState *state);
  89.   virtual void updateFillColor(GfxState *state);
  90.   virtual void updateStrokeColor(GfxState *state);
  91.  
  92.   //----- update text state
  93.   virtual void updateFont(GfxState *state);
  94.   virtual void updateTextMat(GfxState *state);
  95.   virtual void updateCharSpace(GfxState *state);
  96.   virtual void updateRender(GfxState *state);
  97.   virtual void updateRise(GfxState *state);
  98.   virtual void updateWordSpace(GfxState *state);
  99.   virtual void updateHorizScaling(GfxState *state);
  100.   virtual void updateTextPos(GfxState *state);
  101.   virtual void updateTextShift(GfxState *state, double shift);
  102.  
  103.   //----- path painting
  104.   virtual void stroke(GfxState *state);
  105.   virtual void fill(GfxState *state, GBool strokeToo = gFalse);
  106.   virtual void eoFill(GfxState *state, GBool strokeToo = gFalse);
  107.  
  108.   //----- path clipping
  109.   virtual void clip(GfxState *state);
  110.   virtual void eoClip(GfxState *state);
  111.  
  112.   //----- text drawing
  113.   virtual void drawString(GfxState *state, GString *s);
  114.  
  115.   //----- image drawing
  116.   virtual void drawImageMask(GfxState *state, Stream *str,
  117.                  int width, int height, GBool invert,
  118.                  GBool inlineImg);
  119.   virtual void drawImage(GfxState *state, Stream *str, int width,
  120.              int height, GfxImageColorMap *colorMap,
  121.              GBool inlineImg);
  122.  
  123. private:
  124.  
  125.   void setupFonts(Dict *resDict);
  126.   void setupFont(GfxFont *font);
  127.   void setupEmbeddedType1Font(Ref *id);
  128.   void setupEmbeddedType1Font(char *fileName);
  129.   void setupEmbeddedType1CFont(GfxFont *font, Ref *id);
  130.   void doPath(GfxPath *path);
  131.   void doImageL1(GfxImageColorMap *colorMap,
  132.          GBool invert, GBool inlineImg,
  133.          Stream *str, int width, int height, int len);
  134.   void doImage(GfxImageColorMap *colorMap,
  135.            GBool invert, GBool inlineImg,
  136.            Stream *str, int width, int height, int len);
  137.   void writePS(char *fmt, ...);
  138.   void writePSString(GString *s);
  139.  
  140.   GBool embedType1;        // embed Type 1 fonts?
  141.   GBool doForm;            // generate a form?
  142.  
  143.   FILE *f;            // PostScript file
  144.   PSFileType fileType;        // file / pipe / stdout
  145.   int seqPage;            // current sequential page number
  146.  
  147.   Ref *fontIDs;            // list of object IDs of all used fonts
  148.   int fontIDLen;        // number of entries in fontIDs array
  149.   int fontIDSize;        // size of fontIDs array
  150.   Ref *fontFileIDs;        // list of object IDs of all embedded fonts
  151.   int fontFileIDLen;        // number of entries in fontFileIDs array
  152.   int fontFileIDSize;        // size of fontFileIDs array
  153.   char **fontFileNames;        // list of names of all embedded external fonts
  154.   int fontFileNameLen;        // number of entries in fontFileNames array
  155.   int fontFileNameSize;        // size of fontFileNames array
  156.  
  157.   GBool ok;            // set up ok?
  158. };
  159.  
  160. #endif
  161.