~ubuntu-branches/ubuntu/warty/lynx/warty-security

« back to all changes in this revision

Viewing changes to WWW/Library/Implementation/HTStyle.h

  • Committer: Bazaar Package Importer
  • Author(s): Martin Pitt
  • Date: 2004-09-16 12:14:10 UTC
  • Revision ID: james.westby@ubuntu.com-20040916121410-cz1gu92c4nqfeyrg
Tags: upstream-2.8.5
ImportĀ upstreamĀ versionĀ 2.8.5

Show diffs side-by-side

added added

removed removed

Lines of Context:
 
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 <HTAnchor.h>
 
36
 
 
37
typedef long int HTFont;        /* Dummy definition instead */
 
38
 
 
39
#ifdef NeXT_suppressed
 
40
#include <appkit/appkit.h>
 
41
typedef NXCoord HTCoord;
 
42
#define HTParagraphStyle NXTextStyle
 
43
#define HTCoord NXCoord
 
44
typedef struct _color {
 
45
        float   grey;
 
46
        int     RGBColor;
 
47
} HTColor;
 
48
#else
 
49
 
 
50
typedef int HTCoord;            /* changed from float to int - kw */
 
51
 
 
52
typedef struct _HTParagraphStyle {
 
53
    HTCoord     left_indent;            /* @@@@ junk! etc etc*/
 
54
} HTParagraphStyle;
 
55
 
 
56
typedef int HTColor;            /* Sorry about the US spelling! */
 
57
 
 
58
#endif
 
59
 
 
60
 
 
61
 
 
62
#define STYLE_NAME_LENGTH       80      /* @@@@@@@@@@@ */
 
63
 
 
64
typedef struct {
 
65
    short               kind;           /* only NX_LEFTTAB implemented*/
 
66
    HTCoord             position;       /* x coordinate for stop */
 
67
} HTTabStop;
 
68
 
 
69
 
 
70
/*      The Style Structure
 
71
**      -------------------
 
72
*/
 
73
 
 
74
typedef struct _HTStyle {
 
75
 
 
76
/*      Style management information
 
77
*/
 
78
    struct _HTStyle     *next;          /* Link for putting into stylesheet */
 
79
    char *              name;           /* Style name */
 
80
    int                 id;             /* equivalent of name, for speed */
 
81
    char *              SGMLTag;        /* Tag name to start */
 
82
 
 
83
 
 
84
/*      Character attributes    (a la NXRun)
 
85
*/
 
86
    HTFont              font;           /* Font id */
 
87
    HTCoord             fontSize;       /* The size of font, not independent */
 
88
    HTColor             color;          /* text gray of current run */
 
89
    int                 superscript;    /* superscript (-sub) in points */
 
90
 
 
91
    HTAnchor            *anchor;        /* Anchor id if any, else zero */
 
92
 
 
93
/*      Paragraph Attribtes     (a la NXTextStyle)
 
94
*/
 
95
    HTCoord             indent1st;      /* how far first line in paragraph is
 
96
                                 * indented */
 
97
    HTCoord             leftIndent;     /* how far second line is indented */
 
98
    HTCoord             rightIndent;    /* (Missing from NeXT version */
 
99
    short               alignment;      /* quad justification */
 
100
    HTCoord             lineHt;         /* line height */
 
101
    HTCoord             descentLine;    /* descender bottom from baseline */
 
102
    CONST HTTabStop     *tabs;          /* array of tab stops, 0 terminated */
 
103
 
 
104
    BOOL                wordWrap;       /* Yes means wrap at space not char */
 
105
    BOOL                freeFormat;     /* Yes means \n is just white space */
 
106
    HTCoord             spaceBefore;    /* Omissions from NXTextStyle */
 
107
    HTCoord             spaceAfter;
 
108
    int                 paraFlags;      /* Paragraph flags, bits as follows: */
 
109
 
 
110
#define PARA_KEEP       1       /* Do not break page within this paragraph */
 
111
#define PARA_WITH_NEXT  2       /* Do not break page after this paragraph */
 
112
 
 
113
#define HT_JUSTIFY 0            /* For alignment */
 
114
#define HT_LEFT 1
 
115
#define HT_RIGHT 2
 
116
#define HT_CENTER 3
 
117
 
 
118
} HTStyle;
 
119
 
 
120
#define HT_ALIGN_NONE (-1)
 
121
 
 
122
/*      Style functions:
 
123
*/
 
124
extern HTStyle * HTStyleNew NOPARAMS;
 
125
extern HTStyle * HTStyleNewNamed PARAMS ((CONST char * name));
 
126
extern HTStyle * HTStyleFree PARAMS((HTStyle * self));
 
127
#ifdef SUPRESS
 
128
extern HTStyle * HTStyleRead PARAMS((HTStyle * self, HTStream * stream));
 
129
extern HTStyle * HTStyleWrite PARAMS((HTStyle * self, HTStream * stream));
 
130
#endif
 
131
/*              Style Sheet
 
132
**              -----------
 
133
*/
 
134
typedef struct _HTStyleSheet {
 
135
        char *          name;
 
136
        HTStyle *       styles;
 
137
} HTStyleSheet;
 
138
 
 
139
 
 
140
/*      Stylesheet functions:
 
141
*/
 
142
extern HTStyleSheet * HTStyleSheetNew NOPARAMS;
 
143
extern HTStyleSheet * HTStyleSheetFree PARAMS((HTStyleSheet * self));
 
144
extern HTStyle * HTStyleNamed PARAMS((HTStyleSheet * self, CONST char * name));
 
145
extern HTStyle * HTStyleForParagraph PARAMS((HTStyleSheet * self,
 
146
        HTParagraphStyle * paraStyle));
 
147
extern HTStyle * HTStyleMatching PARAMS((HTStyleSheet *self, HTStyle * style));
 
148
/* extern HTStyle * HTStyleForRun PARAMS((HTStyleSheet *self, NXRun * run)); */
 
149
extern HTStyleSheet * HTStyleSheetAddStyle PARAMS((HTStyleSheet * self,
 
150
        HTStyle * style));
 
151
extern HTStyleSheet * HTStyleSheetRemoveStyle PARAMS((HTStyleSheet * self,
 
152
        HTStyle * style));
 
153
#ifdef SUPPRESS
 
154
extern HTStyleSheet * HTStyleSheetRead PARAMS((HTStyleSheet * self,
 
155
                                                HTStream * stream));
 
156
extern HTStyleSheet * HTStyleSheetWrite PARAMS((HTStyleSheet * self,
 
157
                                                HTStream * stream));
 
158
#endif
 
159
#define CLEAR_POINTER ((void *)-1)      /* Pointer value means "clear me" */
 
160
 
 
161
/* DefaultStyle.c */
 
162
extern HTStyleSheet * DefaultStyle PARAMS((HTStyle*** result_array));
 
163
 
 
164
/* enum, use this instead of HTStyle name comparisons */
 
165
enum HTStyle_Enum {
 
166
        ST_Normal = 0,
 
167
        ST_DivCenter,
 
168
        ST_DivLeft,
 
169
        ST_DivRight,
 
170
        ST_Banner,
 
171
        ST_Blockquote,
 
172
        ST_Bq,
 
173
        ST_Footnote,
 
174
        ST_List,
 
175
        ST_List1,
 
176
        ST_List2,
 
177
        ST_List3,
 
178
        ST_List4,
 
179
        ST_List5,
 
180
        ST_List6,
 
181
        ST_Menu,
 
182
        ST_Menu1,
 
183
        ST_Menu2,
 
184
        ST_Menu3,
 
185
        ST_Menu4,
 
186
        ST_Menu5,
 
187
        ST_Menu6,
 
188
        ST_Glossary,
 
189
        ST_Glossary1,
 
190
        ST_Glossary2,
 
191
        ST_Glossary3,
 
192
        ST_Glossary4,
 
193
        ST_Glossary5,
 
194
        ST_Glossary6,
 
195
        ST_GlossaryCompact,
 
196
        ST_GlossaryCompact1,
 
197
        ST_GlossaryCompact2,
 
198
        ST_GlossaryCompact3,
 
199
        ST_GlossaryCompact4,
 
200
        ST_GlossaryCompact5,
 
201
        ST_GlossaryCompact6,
 
202
        ST_Example,
 
203
        ST_Preformatted,
 
204
        ST_Listing,
 
205
        ST_Address,
 
206
        ST_Note,
 
207
        ST_Heading1,
 
208
        ST_Heading2,
 
209
        ST_Heading3,
 
210
        ST_Heading4,
 
211
        ST_Heading5,
 
212
        ST_Heading6,
 
213
        ST_HeadingCenter,
 
214
        ST_HeadingLeft,
 
215
        ST_HeadingRight
 
216
};
 
217
 
 
218
#endif /* HTStyle_H */