home *** CD-ROM | disk | FTP | other *** search
/ Collection of Internet / Collection of Internet.iso / msdos / lynx / source / www / library / implemen / htstyle.h < prev    next >
Encoding:
C/C++ Source or Header  |  1994-10-25  |  6.7 KB  |  182 lines

  1. /*                                                       HTStyle: Style management for libwww
  2.                               STYLE DEFINITION FOR HYPERTEXT
  3.                                              
  4.    Styles allow the translation between a logical property of a piece of text and its
  5.    physical representation.
  6.    
  7.    A StyleSheet is a collection of styles, defining the translation necessary to represent
  8.    a document. It is a linked list of styles.
  9.    
  10. Overriding this module
  11.  
  12.    Why is the style structure declared in the HTStyle.h module, instead of having the user
  13.    browser define the structure, and the HTStyle routines just use sizeof() for copying?
  14.    
  15.    It's not obvious whether HTStyle.c should be common code.  It's useful to have common
  16.    code for loading style sheets, especially if the movement toward standard style sheets
  17.    gets going.
  18.    
  19.    If it IS common code, then both the hypertext object and HTStyle.c must know the
  20.    structure of a style, so HTStyle.h is a suitable place to put that.  HTStyle.c has to
  21.    be compiled with a knowledge of the
  22.    
  23.    It we take it out of the library, then of course HTStyle could be declared as an
  24.    undefined structure. The only references to it are in the structure-flattening code
  25.    HTML.c and HTPlain.c, which only use HTStypeNamed().
  26.    
  27.    You can in any case override this function in your own code, which will prevent the
  28.    HTStyle from being loaded.  You will be able to redefine your style structure in this
  29.    case without problems, as no other moule needs to know it.
  30.    
  31.  */
  32. #ifndef HTStyle_H
  33. #define HTStyle_H
  34.  
  35. #include "HTUtils.h"
  36. #include "HTAnchor.h"
  37.  
  38. typedef long int HTFont;        /* Dummy definition instead */
  39.  
  40. #ifdef SHORT_NAMES
  41. #define HTStyleNew                      HTStNew
  42. #define HTStyleFree                     HTStFree
  43. #define HTStyleRead                     HTStRead
  44. #define HTStyleWrite                    HTStWrite
  45. #define HTStyleSheetNew                 HTStShNe
  46. #define HTStyleSheetFree                HTStShFr
  47. #define HTStyleNamed                    HTStName
  48. #define HTStyleForParagraph             HTStFoPa
  49. #define HTStyleMatching                 HTStMatc
  50. #define HTStyleForRun                   HTStFoRu
  51. #define HTStyleSheetAddStyle            HTStShAd
  52. #define HTStyleSheetRemoveStyle         HTStShRm
  53. #define HTStyleSheetRead                HTStShRe
  54. #define HTStyleSheetWrite               HTStShWr
  55. #endif
  56.  
  57. #ifdef NeXT_suppressed
  58. #include <appkit/appkit.h>
  59. typedef NXCoord HTCoord;
  60. #define HTParagraphStyle NXTextStyle
  61. #define HTCoord NXCoord
  62. typedef struct _color {
  63.         float   grey;
  64.         int     RGBColor;
  65. } HTColor;
  66. #else
  67.  
  68. typedef float HTCoord;
  69.  
  70. typedef struct _HTParagraphStyle {
  71.     HTCoord     left_indent;            /* @@@@ junk! etc etc*/
  72. } HTParagraphStyle;
  73.  
  74. typedef int HTColor;            /* Sorry about the US spelling! */
  75.  
  76. #endif
  77.  
  78.  
  79.  
  80. #define STYLE_NAME_LENGTH       80      /* @@@@@@@@@@@ */
  81.         
  82. typedef struct {
  83.     short               kind;           /* only NX_LEFTTAB implemented*/
  84.     HTCoord             position;       /* x coordinate for stop */
  85. } HTTabStop;
  86.  
  87.  
  88. /*      The Style Structure
  89. **      -------------------
  90. */
  91.  
  92. typedef struct _HTStyle {
  93.  
  94. /*      Style management information
  95. */
  96.     struct _HTStyle     *next;          /* Link for putting into stylesheet */
  97.     char *              name;           /* Style name */
  98.     char *              SGMLTag;        /* Tag name to start */
  99.  
  100.  
  101. /*      Character attributes    (a la NXRun)
  102. */
  103.     HTFont              font;           /* Font id */
  104.     HTCoord             fontSize;       /* The size of font, not independent */
  105.     HTColor             color;  /* text gray of current run */
  106.     int                 superscript;    /* superscript (-sub) in points */
  107.  
  108.     HTAnchor            *anchor;        /* Anchor id if any, else zero */
  109.  
  110. /*      Paragraph Attribtes     (a la NXTextStyle)
  111. */
  112.     HTCoord             indent1st;      /* how far first line in paragraph is
  113.                                  * indented */
  114.     HTCoord             leftIndent;     /* how far second line is indented */
  115.     HTCoord             rightIndent;    /* (Missing from NeXT version */
  116.     short               alignment;      /* quad justification */
  117.     HTCoord             lineHt;         /* line height */
  118.     HTCoord             descentLine;    /* descender bottom from baseline */
  119.     HTTabStop           *tabs;          /* array of tab stops, 0 terminated */
  120.  
  121.     BOOL                wordWrap;       /* Yes means wrap at space not char */
  122.     BOOL                freeFormat;     /* Yes means \n is just white space */
  123.     HTCoord             spaceBefore;    /* Omissions from NXTextStyle */
  124.     HTCoord             spaceAfter;
  125.     int                 paraFlags;      /* Paragraph flags, bits as follows: */
  126.  
  127. #define PARA_KEEP       1       /* Do not break page within this paragraph */
  128. #define PARA_WITH_NEXT  2       /* Do not break page after this paragraph */
  129.  
  130. #define HT_JUSTIFY 0            /* For alignment */
  131. #define HT_LEFT 1
  132. #define HT_RIGHT 2
  133. #define HT_CENTER 3
  134.  
  135. } HTStyle;
  136.  
  137.  
  138. /*      Style functions:
  139. */
  140. extern HTStyle * HTStyleNew NOPARAMS;
  141. extern HTStyle* HTStyleNewNamed PARAMS ((CONST char * name));
  142. extern HTStyle * HTStyleFree PARAMS((HTStyle * self));
  143. #ifdef SUPRESS
  144. extern HTStyle * HTStyleRead PARAMS((HTStyle * self, HTStream * stream));
  145. extern HTStyle * HTStyleWrite PARAMS((HTStyle * self, HTStream * stream));
  146. #endif
  147. /*              Style Sheet
  148. **              -----------
  149. */
  150. typedef struct _HTStyleSheet {
  151.         char *          name;
  152.         HTStyle *       styles;
  153. } HTStyleSheet;
  154.  
  155.  
  156. /*      Stylesheet functions:
  157. */
  158. extern HTStyleSheet * HTStyleSheetNew NOPARAMS;
  159. extern HTStyleSheet * HTStyleSheetFree PARAMS((HTStyleSheet * self));
  160. extern HTStyle * HTStyleNamed PARAMS((HTStyleSheet * self, CONST char * name));
  161. extern HTStyle * HTStyleForParagraph PARAMS((HTStyleSheet * self,
  162.         HTParagraphStyle * paraStyle));
  163. extern HTStyle * HTStyleMatching PARAMS((HTStyleSheet *self, HTStyle * style));
  164. /* extern HTStyle * HTStyleForRun PARAMS((HTStyleSheet *self, NXRun * run)); */
  165. extern HTStyleSheet * HTStyleSheetAddStyle PARAMS((HTStyleSheet * self,
  166.         HTStyle * style));
  167. extern HTStyleSheet * HTStyleSheetRemoveStyle PARAMS((HTStyleSheet * self,
  168.         HTStyle * style));
  169. #ifdef SUPPRESS
  170. extern HTStyleSheet * HTStyleSheetRead PARAMS((HTStyleSheet * self,
  171.                                                 HTStream * stream));
  172. extern HTStyleSheet * HTStyleSheetWrite PARAMS((HTStyleSheet * self,
  173.                                                 HTStream * stream));
  174. #endif
  175. #define CLEAR_POINTER ((void *)-1)      /* Pointer value means "clear me" */
  176. #endif /* HTStyle_H */
  177.  
  178.  
  179. /*
  180.  
  181.     */
  182.