Annotation of libwww/Library/src/HTStyle.html, revision 2.15
2.6 timbl 1: <HTML>
2: <HEAD>
2.12 frystyk 3: <TITLE>HTStyle: Style management for libwww</TITLE>
4: </HEAD>
2.6 timbl 5: <BODY>
2.11 frystyk 6:
2.12 frystyk 7: <H1>Style Definition for Hypertext</H1>
8:
9: <PRE>
10: /*
11: ** (c) COPYRIGHT CERN 1994.
12: ** Please first read the full copyright statement in the file COPYRIGH.
13: */
14: </PRE>
15:
16: Styles allow the translation between a logical property of a piece of
17: text and its physical representation. A StyleSheet is a collection of
18: styles, defining the translation necessary to represent a document. It
19: is a linked list of styles.
2.11 frystyk 20:
21: <H2>Overriding this module</H2>
22:
23: Why is the style structure declared in the HTStyle.h module, instead
24: of having the user browser define the structure, and the HTStyle
25: routines just use sizeof() for copying?<P>
26:
27: It's not obvious whether HTStyle.c should be common code. It's useful
28: to have common code for loading style sheets, especially if the
29: movement toward standard style sheets gets going.<P>
30:
31: If it <B>is</B> common code, then both the hypertext object and
32: HTStyle.c must know the structure of a style, so HTStyle.h is a
33: suitable place to put that.<P>
34:
35: If we take it out of the library, then of course HTStyle could be
36: declared as an undefined structure. The only references to it are in
37: the structure-flattening code HTML.c and HTPlain.c, which only use
38: HTStypeNamed().<P>
39:
40: You can in any case override this function in your own code, which
41: will prevent the HTStyle from being loaded. You will be able to
42: redefine your style structure in this case without problems, as no
2.12 frystyk 43: other moule needs to know it. <P>
44:
45: This module is implemented by <A HREF="HTStyle.c">HTStyle.c</A>, and
46: it is a part of the <A
47: HREF="http://info.cern.ch/hypertext/WWW/Library/User/Guide/Guide.html">
48: Library of Common Code</A>.
2.11 frystyk 49:
2.10 timbl 50: <PRE>
51: #ifndef HTStyle_H
2.1 timbl 52: #define HTStyle_H
53:
2.8 luotonen 54: #include "HTFormat.h"
2.1 timbl 55: #include "HTAnchor.h"
2.10 timbl 56: #include "HTML.h"
2.1 timbl 57:
58: typedef long int HTFont; /* Dummy definition instead */
59:
2.10 timbl 60:
61:
2.1 timbl 62: #ifdef SHORT_NAMES
63: #define HTStyleNew HTStNew
64: #define HTStyleFree HTStFree
65: #define HTStyleRead HTStRead
66: #define HTStyleWrite HTStWrite
67: #define HTStyleSheetNew HTStShNe
68: #define HTStyleSheetFree HTStShFr
69: #define HTStyleNamed HTStName
70: #define HTStyleForParagraph HTStFoPa
71: #define HTStyleMatching HTStMatc
72: #define HTStyleForRun HTStFoRu
73: #define HTStyleSheetAddStyle HTStShAd
74: #define HTStyleSheetRemoveStyle HTStShRm
75: #define HTStyleSheetRead HTStShRe
76: #define HTStyleSheetWrite HTStShWr
77: #endif
78:
2.9 timbl 79: #ifdef DEFINE_STRUCT_HTSTYLE
2.1 timbl 80: #ifdef NeXT_suppressed
2.14 frystyk 81: #include <appkit/appkit.h>
2.1 timbl 82: typedef NXCoord HTCoord;
83: #define HTParagraphStyle NXTextStyle
84: #define HTCoord NXCoord
85: typedef struct _color {
2.15 ! frystyk 86: double grey;
2.1 timbl 87: int RGBColor;
88: } HTColor;
89: #else
90:
2.15 ! frystyk 91: typedef double HTCoord;
2.1 timbl 92:
93: typedef struct _HTParagraphStyle {
94: HTCoord left_indent; /* @@@@ junk! etc etc*/
95: } HTParagraphStyle;
96:
97: typedef int HTColor; /* Sorry about the US spelling! */
98:
99: #endif
100:
101: typedef struct {
102: short kind; /* only NX_LEFTTAB implemented*/
103: HTCoord position; /* x coordinate for stop */
104: } HTTabStop;
105:
2.9 timbl 106: #else
107: typedef struct _HTParagraphStyle HTParagraphStyle;
108: #endif
109:
110:
111:
112: #define STYLE_NAME_LENGTH 80 /* @@@@@@@@@@@ */
113:
2.1 timbl 114:
115: /* The Style Structure
116: ** -------------------
117: */
118:
2.9 timbl 119: typedef struct _HTStyle
2.10 timbl 120: #ifdef DEFINE_STRUCT_HTSTYLE /* Don't */
2.9 timbl 121: {
2.1 timbl 122:
123: /* Style management information
124: */
125: struct _HTStyle *next; /* Link for putting into stylesheet */
126: char * name; /* Style name */
127: char * SGMLTag; /* Tag name to start */
128:
129:
130: /* Character attributes (a la NXRun)
131: */
132: HTFont font; /* Font id */
133: HTCoord fontSize; /* The size of font, not independent */
134: HTColor color; /* text gray of current run */
135: int superscript; /* superscript (-sub) in points */
136:
137: HTAnchor *anchor; /* Anchor id if any, else zero */
138:
139: /* Paragraph Attribtes (a la NXTextStyle)
140: */
141: HTCoord indent1st; /* how far first line in paragraph is
142: * indented */
143: HTCoord leftIndent; /* how far second line is indented */
144: HTCoord rightIndent; /* (Missing from NeXT version */
145: short alignment; /* quad justification */
146: HTCoord lineHt; /* line height */
147: HTCoord descentLine; /* descender bottom from baseline */
148: HTTabStop *tabs; /* array of tab stops, 0 terminated */
149:
150: BOOL wordWrap; /* Yes means wrap at space not char */
151: BOOL freeFormat; /* Yes means \n is just white space */
152: HTCoord spaceBefore; /* Omissions from NXTextStyle */
153: HTCoord spaceAfter;
154: int paraFlags; /* Paragraph flags, bits as follows: */
155:
156: #define PARA_KEEP 1 /* Do not break page within this paragraph */
157: #define PARA_WITH_NEXT 2 /* Do not break page after this paragraph */
158:
159: #define HT_JUSTIFY 0 /* For alignment */
160: #define HT_LEFT 1
161: #define HT_RIGHT 2
162: #define HT_CENTER 3
163:
2.9 timbl 164: }
165: #endif
166: HTStyle;
2.1 timbl 167:
2.10 timbl 168: </pre>
169: <h2>Style Creation</h2>
170: <h3>HtStyleModify</h3>
171: This routine is passed the style for a particular SGML nesting state,
172: and the element number of a new element whithin that state.
173: The routine returns a suitable style for text within the new element.
174: It is passed a popinter tothe nesting state so that it can link
175: the style back to the nesting state for later manipulation
176: of the SGML nesting tree.
177: <pre>
178:
179: extern HTStyle * HTStyleModify PARAMS((
180: HTStyle * style,
181: HTNesting* nesting,
182: int element_number));
183:
184:
2.1 timbl 185:
186: /* Style functions:
187: */
188: extern HTStyle * HTStyleNew NOPARAMS;
189: extern HTStyle* HTStyleNewNamed PARAMS ((CONST char * name));
190: extern HTStyle * HTStyleFree PARAMS((HTStyle * self));
191: #ifdef SUPRESS
192: extern HTStyle * HTStyleRead PARAMS((HTStyle * self, HTStream * stream));
193: extern HTStyle * HTStyleWrite PARAMS((HTStyle * self, HTStream * stream));
194: #endif
195: /* Style Sheet
196: ** -----------
197: */
198: typedef struct _HTStyleSheet {
199: char * name;
200: HTStyle * styles;
201: } HTStyleSheet;
202:
203:
204: /* Stylesheet functions:
205: */
206: extern HTStyleSheet * HTStyleSheetNew NOPARAMS;
207: extern HTStyleSheet * HTStyleSheetFree PARAMS((HTStyleSheet * self));
208: extern HTStyle * HTStyleNamed PARAMS((HTStyleSheet * self, CONST char * name));
209: extern HTStyle * HTStyleMatching PARAMS((HTStyleSheet *self, HTStyle * style));
210: /* extern HTStyle * HTStyleForRun PARAMS((HTStyleSheet *self, NXRun * run)); */
211: extern HTStyleSheet * HTStyleSheetAddStyle PARAMS((HTStyleSheet * self,
212: HTStyle * style));
213: extern HTStyleSheet * HTStyleSheetRemoveStyle PARAMS((HTStyleSheet * self,
214: HTStyle * style));
215: #ifdef SUPPRESS
216: extern HTStyleSheet * HTStyleSheetRead PARAMS((HTStyleSheet * self,
217: HTStream * stream));
218: extern HTStyleSheet * HTStyleSheetWrite PARAMS((HTStyleSheet * self,
219: HTStream * stream));
220: #endif
221: #define CLEAR_POINTER ((void *)-1) /* Pointer value means "clear me" */
222: #endif /* HTStyle_H */
2.6 timbl 223:
2.7 timbl 224:
225: </BODY>
2.6 timbl 226: </HTML>
Webmaster