Some compile fixes, not enough
[erwise] / Cl / WWWLibrary / HTStyle.h
1 /*      Style Definition for Hypertext                          HTStyle.h
2 **      ==============================
3 **
4 **      Styles allow the translation between a logical property of a piece of
5 **      text and its physical representation.
6 **
7 **      A StyleSheet is a collection of styles, defining the
8 **      translation necessary to represent a document.
9 **      It is a linked list of styles.
10 */
11 #ifndef HTStyle_H
12 #define HTStyle_H
13
14 #include "HTUtils.h"
15 #include "HTAnchor.h"
16 #include "HTFont.h"
17
18 #ifdef SHORT_NAMES
19 #define HTStyleNew                      HTStNew
20 #define HTStyleFree                     HTStFree
21 #define HTStyleRead                     HTStRead
22 #define HTStyleWrite                    HTStWrite
23 #define HTStyleSheetNew                 HTStShNe
24 #define HTStyleSheetFree                HTStShFr
25 #define HTStyleNamed                    HTStName
26 #define HTStyleForParagraph             HTStFoPa
27 #define HTStyleMatching                 HTStMatc
28 #define HTStyleForRun                   HTStFoRu
29 #define HTStyleSheetAddStyle            HTStShAd
30 #define HTStyleSheetRemoveStyle         HTStShRm
31 #define HTStyleSheetRead                HTStShRe
32 #define HTStyleSheetWrite               HTStShWr
33 #endif
34
35 #ifdef NeXT_suppressed
36 #include <appkit/appkit.h>
37 typedef NXCoord HTCoord;
38 #define HTParagraphStyle NXTextStyle
39 #define HTCoord NXCoord
40 typedef struct _color {
41         float   grey;
42         int     RGBColor;
43 } HTColor;
44 #else
45
46 typedef float HTCoord;
47
48 typedef struct _HTParagraphStyle {
49     HTCoord     left_indent;            /* @@@@ junk! etc etc*/
50 } HTParagraphStyle;
51
52 typedef int HTColor;            /* Sorry about the US spelling! */
53
54 #endif
55
56
57
58 #define STYLE_NAME_LENGTH       80      /* @@@@@@@@@@@ */
59          
60 typedef struct {
61     short               kind;           /* only NX_LEFTTAB implemented*/
62     HTCoord             position;       /* x coordinate for stop */
63 } HTTabStop;
64
65
66 /*      The Style Structure
67 **      -------------------
68 */
69
70 typedef struct _HTStyle {
71
72 /*      Style management information
73 */
74     struct _HTStyle     *next;          /* Link for putting into stylesheet */
75     char *              name;           /* Style name */
76     char *              SGMLTag;        /* Tag name to start */
77
78
79 /*      Character attributes    (a la NXRun)
80 */
81     HTFont              font;           /* Font id */
82     HTCoord             fontSize;       /* The size of font, not independent */
83     HTColor             color;  /* text gray of current run */
84     int                 superscript;    /* superscript (-sub) in points */
85
86     HTAnchor            *anchor;        /* Anchor id if any, else zero */
87
88 /*      Paragraph Attribtes     (a la NXTextStyle)
89 */
90     HTCoord             indent1st;      /* how far first line in paragraph is
91                                  * indented */
92     HTCoord             leftIndent;     /* how far second line is indented */
93     HTCoord             rightIndent;    /* (Missing from NeXT version */
94     short               alignment;      /* quad justification */
95     HTCoord             lineHt;         /* line height */
96     HTCoord             descentLine;    /* descender bottom from baseline */
97     HTTabStop           *tabs;          /* array of tab stops, 0 terminated */
98
99     BOOL                wordWrap;       /* Yes means wrap at space not char */
100     BOOL                freeFormat;     /* Yes means \n is just white space */
101     HTCoord             spaceBefore;    /* Omissions from NXTextStyle */
102     HTCoord             spaceAfter;
103     int                 paraFlags;      /* Paragraph flags, bits as follows: */
104
105 #define PARA_KEEP       1       /* Do not break page within this paragraph */
106 #define PARA_WITH_NEXT  2       /* Do not break page after this paragraph */
107
108 #define HT_JUSTIFY 0            /* For alignment */
109 #define HT_LEFT 1
110 #define HT_RIGHT 2
111 #define HT_CENTER 3
112   
113 } HTStyle;
114
115
116 /*      Style functions:
117 */
118 extern HTStyle * HTStyleNew NOPARAMS;
119 extern HTStyle* HTStyleNewNamed PARAMS ((CONST char * name));
120 extern HTStyle * HTStyleFree PARAMS((HTStyle * self));
121 #ifdef SUPRESS
122 extern HTStyle * HTStyleRead PARAMS((HTStyle * self, HTStream * stream));
123 extern HTStyle * HTStyleWrite PARAMS((HTStyle * self, HTStream * stream));
124 #endif
125 /*              Style Sheet
126 **              -----------
127 */
128 typedef struct _HTStyleSheet {
129         char *          name;
130         HTStyle *       styles;
131 } HTStyleSheet;
132
133
134 /*      Stylesheet functions:
135 */
136 extern HTStyleSheet * HTStyleSheetNew NOPARAMS;
137 extern HTStyleSheet * HTStyleSheetFree PARAMS((HTStyleSheet * self));
138 extern HTStyle * HTStyleNamed PARAMS((HTStyleSheet * self, CONST char * name));
139 extern HTStyle * HTStyleForParagraph PARAMS((HTStyleSheet * self,
140         HTParagraphStyle * paraStyle));
141 extern HTStyle * HTStyleMatching PARAMS((HTStyleSheet *self, HTStyle * style));
142 /* extern HTStyle * HTStyleForRun PARAMS((HTStyleSheet *self, NXRun * run)); */
143 extern HTStyleSheet * HTStyleSheetAddStyle PARAMS((HTStyleSheet * self,
144         HTStyle * style));
145 extern HTStyleSheet * HTStyleSheetRemoveStyle PARAMS((HTStyleSheet * self,
146         HTStyle * style));
147 #ifdef SUPPRESS
148 extern HTStyleSheet * HTStyleSheetRead PARAMS((HTStyleSheet * self,
149                                                 HTStream * stream));
150 extern HTStyleSheet * HTStyleSheetWrite PARAMS((HTStyleSheet * self,
151                                                 HTStream * stream));
152 #endif
153 #define CLEAR_POINTER ((void *)-1)      /* Pointer value means "clear me" */
154 #endif /* HTStyle_H */