home *** CD-ROM | disk | FTP | other *** search
/ Tools / WinSN5.0Ver.iso / NETSCAP.50 / WIN1998.ZIP / ns / include / xlate.h < prev    next >
Encoding:
C/C++ Source or Header  |  1998-04-08  |  6.2 KB  |  180 lines

  1. /* -*- Mode: C; tab-width: 4; indent-tabs-mode: nil; c-basic-offset: 2 -*-
  2.  *
  3.  * The contents of this file are subject to the Netscape Public License
  4.  * Version 1.0 (the "NPL"); you may not use this file except in
  5.  * compliance with the NPL.  You may obtain a copy of the NPL at
  6.  * http://www.mozilla.org/NPL/
  7.  *
  8.  * Software distributed under the NPL is distributed on an "AS IS" basis,
  9.  * WITHOUT WARRANTY OF ANY KIND, either express or implied. See the NPL
  10.  * for the specific language governing rights and limitations under the
  11.  * NPL.
  12.  *
  13.  * The Initial Developer of this code under the NPL is Netscape
  14.  * Communications Corporation.  Portions created by Netscape are
  15.  * Copyright (C) 1998 Netscape Communications Corporation.  All Rights
  16.  * Reserved.
  17.  */
  18.  
  19.  
  20. /*
  21. ** External points of interest for the translation library
  22. */
  23.  
  24. #ifndef XLATE_H
  25. #define XLATE_H
  26.  
  27. typedef void (*XL_CompletionRoutine)(PrintSetup*);
  28. typedef void* XL_TextTranslation;
  29. typedef void* XL_PostscriptTranslation;
  30.  
  31. XP_BEGIN_PROTOS
  32. extern void XL_InitializePrintSetup(PrintSetup *p);
  33. extern void XL_InitializeTextSetup(PrintSetup *p);
  34. extern void XL_TranslatePostscript(MWContext*, URL_Struct *u,
  35.                                    SHIST_SavedData *sd, PrintSetup*p);
  36. extern XL_TextTranslation
  37.   XL_TranslateText(MWContext *, URL_Struct *u, PrintSetup*p);
  38. extern void XL_GetTextImage(LO_ImageStruct *image);
  39. extern void
  40.  XL_DisplayTextImage(MWContext *cx, int iLocation, LO_ImageStruct *img);
  41. extern XP_Bool XP_CheckElementSpan(MWContext*, int top, int height);
  42. extern void XP_InitializePrintInfo(MWContext *);
  43. extern void XP_CleanupPrintInfo(MWContext *);
  44. extern void XP_DrawForPrint(MWContext *, int );
  45. extern void XP_LayoutForPrint(MWContext *cx, int32 doc_height);
  46. XP_END_PROTOS
  47.  
  48. typedef struct LineRecord_struct LineRecord;
  49.  
  50. /*
  51. ** PAGE coordinates are 720/inch, layout happens in this space
  52. ** POINT coordinates are 72/inch, the printer wants these
  53. */
  54. #define INCH_TO_PAGE(f) ((int) (.5 + (f)*720))
  55. #define PAGE_TO_POINT_I(f) ((int) ((f) / 10.0))
  56. #define PAGE_TO_POINT_F(f) ((f) / 10.0)
  57. #define POINT_TO_PAGE(p) ((p)*10)
  58.  
  59. /*
  60. ** Used to pass info into text and/or postscript translation
  61. */
  62. struct PrintSetup_ {
  63.   int top;                        /* Margins  (PostScript Only) */
  64.   int bottom;
  65.   int left;
  66.   int right;
  67.  
  68.   int width;                       /* Paper size, # of cols for text xlate */
  69.   int height;
  70.  
  71.   char* header;
  72.   char* footer;
  73.  
  74.   int *sizes;
  75.   XP_Bool reverse;                 /* Output order */
  76.   XP_Bool color;                   /* Image output */
  77.   XP_Bool deep_color;           /* 24 bit color output */
  78.   XP_Bool landscape;               /* Rotated output */
  79.   XP_Bool underline;               /* underline links */
  80.   XP_Bool scale_images;            /* Scale unsized images which are too big */
  81.   XP_Bool scale_pre;           /* do the pre-scaling thing */
  82.   float dpi;                       /* dpi for externally sized items */
  83.   float rules;               /* Scale factor for rulers */
  84.   int n_up;                        /* cool page combining */
  85.   int bigger;                      /* Used to init sizes if sizesin NULL */
  86.  
  87.   char* prefix;                    /* For text xlate, prepended to each line */
  88.   char* eol;               /* For text translation, line terminator */
  89.   char* bullet;                    /* What char to use for bullets */
  90.  
  91.   struct URL_Struct_ *url;         /* url of doc being translated */
  92.   XP_File out;                     /* Where to send the output */
  93.   char *filename;                  /* output file name, if any */
  94.   XL_CompletionRoutine completion; /* Called when translation finished */
  95.   void* carg;                      /* Data saved for completion routine */
  96.   int status;                      /* Status of URL on completion */
  97.  
  98.                    /* "other" font is typically East Asian */
  99.   char *otherFontName;           /* name of "other" PostScript font */
  100.   int16 otherFontCharSetID;       /* charset ID of "other" font */
  101.   int otherFontWidth;           /* width of "other" font (square) */
  102.   int otherFontAscent;           /* Ascent of "other" font (square) */
  103.  
  104.   MWContext *cx;                   /* original context, if available */
  105. };
  106.  
  107. #define XL_LOADING_PHASE 1
  108. #define XL_LAYOUT_PHASE 2
  109. #define XL_DRAW_PHASE 3
  110.  
  111. typedef struct page_breaks {
  112.     int32 y_top;
  113.     int32 y_break;
  114. } PageBreaks;
  115.  
  116. /*
  117. ** Used to store state needed while translation is in progress
  118. */
  119. struct PrintInfo_ {
  120.     /*
  121.     ** BEGIN SPECIAL
  122.     **    If using the table print code, the following fields must
  123.     **    be properly set up.
  124.     */
  125.   int32    page_height;    /* Size of printable area on page */
  126.   int32    page_width;    /* Size of printable area on page */
  127.   int32    page_break;    /* Current page bottom */
  128.   int32 page_topy;    /* Current page top */
  129.   int phase;
  130.     /*
  131.     ** CONTINUE SPECIAL
  132.     **    The table print code maintains these
  133.     */
  134.  
  135.     PageBreaks *pages;        /* Contains extents of each page */
  136.  
  137.   int pt_size;        /* Size of above table */
  138.   int n_pages;        /* # of valid entries in above table */
  139.     /*
  140.     ** END SPECIAL
  141.     */
  142.  
  143.     /*
  144.     ** AAAOOOGAH
  145.     **
  146.     ** These are used to cache values from the originating context's
  147.     ** function table
  148.     */
  149.   void (*scnatt)(MWContext*);   /* SetCallNetlibAllTheTime */
  150.   void (*ccnatt)(MWContext*);   /* CLearCallNetlibAllTheTime */
  151.  
  152.   char*    doc_title;    /* best guess at title */
  153.   int32 doc_width;    /* Total document width */
  154.   int32 doc_height;    /* Total document height */
  155.  
  156. #ifdef LATER
  157.   float    scale;        /* for shrinking pre areas */
  158.   int32    pre_start;    /* First y of current pre section */
  159.   int32    pre_end;    /* Last y of current pre section */
  160.   XP_List    *interesting;    /* List of pre's about which I care */
  161.   XP_Bool    in_pre;        /* True when inside a <pre> section */
  162. #endif
  163.  
  164. /*
  165. ** These fields are used only by the text translator
  166. */
  167.   char *line;        /* Pointer to data for the current line */
  168.   XP_Bool in_table;    /* True when caching lines in a table */
  169.   XP_Bool first_line_p;        /* true when the first line has not yet been
  170.                                output - this is a kludge for the mail
  171.                                citation code. */
  172.   int table_top,    /* Size of the table being cached */
  173.       table_bottom;
  174.   LineRecord *saved_lines;    /* cached lines for tables */
  175.   int last_y;        /* Used to track blank lines */
  176. };
  177.  
  178. #endif /* XLATE_H */
  179.  
  180.