| 1 |
/* |
| 2 |
* $LynxId: HTStyle.h,v 1.21 2025/01/06 15:13:11 tom Exp $ |
| 3 |
HTStyle: Style management for libwww |
| 4 |
STYLE DEFINITION FOR HYPERTEXT |
| 5 |
|
| 6 |
Styles allow the translation between a logical property of a piece of text |
| 7 |
and its physical representation. |
| 8 |
|
| 9 |
A StyleSheet is a collection of styles, defining the translation necessary |
| 10 |
to represent a document. It is a linked list of styles. |
| 11 |
|
| 12 |
Overriding this module |
| 13 |
|
| 14 |
Why is the style structure declared in the HTStyle.h module, instead of |
| 15 |
having the user browser define the structure, and the HTStyle routines just |
| 16 |
use sizeof() for copying? |
| 17 |
|
| 18 |
It's not obvious whether HTStyle.c should be common code. It's useful to |
| 19 |
have common code for loading style sheets, especially if the movement toward |
| 20 |
standard style sheets gets going. |
| 21 |
|
| 22 |
If it IS common code, then both the hypertext object and HTStyle.c must know |
| 23 |
the structure of a style, so HTStyle.h is a suitable place to put that. |
| 24 |
HTStyle.c has to be compiled with a knowledge of the |
| 25 |
|
| 26 |
It we take it out of the library, then of course HTStyle could be declared |
| 27 |
as an undefined structure. The only references to it are in the |
| 28 |
structure-flattening code HTML.c and HTPlain.c, which only use |
| 29 |
HTStypeNamed(). |
| 30 |
|
| 31 |
You can in any case override this function in your own code, which will |
| 32 |
prevent the HTStyle from being loaded. You will be able to redefine your |
| 33 |
style structure in this case without problems, as no other moule needs to |
| 34 |
know it. |
| 35 |
|
| 36 |
*/ |
| 37 |
#ifndef HTStyle_H |
| 38 |
#define HTStyle_H |
| 39 |
|
| 40 |
#include <HTAnchor.h> |
| 41 |
|
| 42 |
typedef long int HTFont; /* Dummy definition instead */ |
| 43 |
|
| 44 |
#ifdef NeXT_suppressed |
| 45 |
#include <appkit/appkit.h> |
| 46 |
typedef NXCoord HTCoord; |
| 47 |
|
| 48 |
#define HTParagraphStyle NXTextStyle |
| 49 |
#define HTCoord NXCoord |
| 50 |
typedef struct _color { |
| 51 |
float grey; |
| 52 |
int RGBColor; |
| 53 |
} HTColor; |
| 54 |
|
| 55 |
#else |
| 56 |
|
| 57 |
typedef int HTCoord; /* changed from float to int - kw */ |
| 58 |
|
| 59 |
typedef struct _HTParagraphStyle { |
| 60 |
HTCoord left_indent; /* @@@@ junk! etc etc */ |
| 61 |
} HTParagraphStyle; |
| 62 |
|
| 63 |
typedef int HTColor; /* Sorry about the US spelling! */ |
| 64 |
|
| 65 |
#endif |
| 66 |
|
| 67 |
#ifdef __cplusplus |
| 68 |
extern "C" { |
| 69 |
#endif |
| 70 |
#define STYLE_NAME_LENGTH 80 /* @@@@@@@@@@@ */ |
| 71 |
typedef struct { |
| 72 |
short kind; /* only NX_LEFTTAB implemented */ |
| 73 |
HTCoord position; /* x coordinate for stop */ |
| 74 |
} HTTabStop; |
| 75 |
|
| 76 |
/* The Style Structure |
| 77 |
* ------------------- |
| 78 |
*/ |
| 79 |
|
| 80 |
typedef struct _HTStyle { |
| 81 |
|
| 82 |
/* Style management information |
| 83 |
*/ |
| 84 |
struct _HTStyle *next; /* Link for putting into stylesheet */ |
| 85 |
char *w_name; /* Style name */ |
| 86 |
const char *c_name; /* Style name */ |
| 87 |
int id; /* equivalent of name, for speed */ |
| 88 |
char *w_SGMLTag; /* Tag name to start */ |
| 89 |
const char *c_SGMLTag; /* Tag name to start */ |
| 90 |
|
| 91 |
/* Character attributes (a la NXRun) |
| 92 |
*/ |
| 93 |
HTFont font; /* Font id */ |
| 94 |
HTCoord fontSize; /* The size of font, not independent */ |
| 95 |
HTColor color; /* text gray of current run */ |
| 96 |
int superscript; /* superscript (-sub) in points */ |
| 97 |
|
| 98 |
HTAnchor *anchor; /* Anchor id if any, else zero */ |
| 99 |
|
| 100 |
/* Paragraph Attributes (a la NXTextStyle) |
| 101 |
*/ |
| 102 |
HTCoord indent1st; /* how far first line in paragraph is |
| 103 |
* indented */ |
| 104 |
HTCoord leftIndent; /* how far second line is indented */ |
| 105 |
HTCoord rightIndent; /* (Missing from NeXT version */ |
| 106 |
short alignment; /* quad justification */ |
| 107 |
HTCoord lineHt; /* line height */ |
| 108 |
HTCoord descentLine; /* descender bottom from baseline */ |
| 109 |
const HTTabStop *tabs; /* array of tab stops, 0 terminated */ |
| 110 |
|
| 111 |
BOOL wordWrap; /* Yes means wrap at space not char */ |
| 112 |
BOOL freeFormat; /* Yes means \n is just white space */ |
| 113 |
HTCoord spaceBefore; /* Omissions from NXTextStyle */ |
| 114 |
HTCoord spaceAfter; |
| 115 |
int paraFlags; /* Paragraph flags, bits as follows: */ |
| 116 |
|
| 117 |
#define PARA_KEEP 1 /* Do not break page within this paragraph */ |
| 118 |
#define PARA_WITH_NEXT 2 /* Do not break page after this paragraph */ |
| 119 |
|
| 120 |
#define HT_JUSTIFY 0 /* For alignment */ |
| 121 |
#define HT_LEFT 1 |
| 122 |
#define HT_RIGHT 2 |
| 123 |
#define HT_CENTER 3 |
| 124 |
|
| 125 |
} HTStyle; |
| 126 |
|
| 127 |
#define GetHTStyleName(p) ((p)->w_name ? (p)->w_name : (p)->c_name) |
| 128 |
#define GetHTStyleSGML(p) ((p)->w_SGMLTag ? (p)->w_SGMLTag : (p)->c_SGMLTag) |
| 129 |
|
| 130 |
#define HTStyleInit( \ |
| 131 |
next, name, SGML_tag, \ |
| 132 |
font, fontsize, color, superscript, \ |
| 133 |
anchor, indent1st, leftIndent, rightIndent, \ |
| 134 |
alignment, lineHt, descentLine, \ |
| 135 |
tabs, wordWrap, freeFormat, spaceBefore, spaceAfter, paraFlags) \ |
| 136 |
{ \ |
| 137 |
next, NULL, #name, ST_##name, NULL, SGML_tag, \ |
| 138 |
font, fontsize, color, superscript, \ |
| 139 |
anchor, indent1st, leftIndent, rightIndent, \ |
| 140 |
alignment, lineHt, descentLine, \ |
| 141 |
tabs, wordWrap, freeFormat, spaceBefore, spaceAfter, paraFlags } |
| 142 |
|
| 143 |
#define HT_ALIGN_NONE (-1) |
| 144 |
|
| 145 |
/* Style functions: |
| 146 |
*/ |
| 147 |
extern HTStyle *HTStyleNew(void); |
| 148 |
extern HTStyle *HTStyleNewNamed(const char *name); |
| 149 |
extern HTStyle *HTStyleFree(HTStyle *self); |
| 150 |
|
| 151 |
/* Style Sheet |
| 152 |
* ----------- |
| 153 |
*/ |
| 154 |
typedef struct _HTStyleSheet { |
| 155 |
const char *name; |
| 156 |
HTStyle *styles; |
| 157 |
} HTStyleSheet; |
| 158 |
|
| 159 |
/* Stylesheet functions: |
| 160 |
*/ |
| 161 |
extern HTStyleSheet *HTStyleSheetNew(void); |
| 162 |
extern HTStyleSheet *HTStyleSheetFree(HTStyleSheet *self); |
| 163 |
extern HTStyle *HTStyleNamed(HTStyleSheet *self, const char *name); |
| 164 |
extern HTStyle *HTStyleForParagraph(HTStyleSheet *self, HTParagraphStyle * paraStyle); |
| 165 |
extern HTStyle *HTStyleMatching(HTStyleSheet *self, HTStyle *style); |
| 166 |
|
| 167 |
/* extern HTStyle * HTStyleForRun (HTStyleSheet *self, NXRun * run); */ |
| 168 |
extern HTStyleSheet *HTStyleSheetAddStyle(HTStyleSheet *self, HTStyle *style); |
| 169 |
extern HTStyleSheet *HTStyleSheetRemoveStyle(HTStyleSheet *self, HTStyle *style); |
| 170 |
|
| 171 |
#define CLEAR_POINTER ((void *)-1) /* Pointer value means "clear me" */ |
| 172 |
|
| 173 |
/* DefaultStyle.c */ |
| 174 |
extern HTStyleSheet *DefaultStyle(HTStyle ***result_array); |
| 175 |
|
| 176 |
/* enum, use this instead of HTStyle name comparisons */ |
| 177 |
enum HTStyle_Enum { |
| 178 |
ST_Normal = 0, |
| 179 |
ST_DivCenter, |
| 180 |
ST_DivLeft, |
| 181 |
ST_DivRight, |
| 182 |
ST_Banner, |
| 183 |
ST_Blockquote, |
| 184 |
ST_Bq, |
| 185 |
ST_Footnote, |
| 186 |
ST_List, |
| 187 |
ST_List1, |
| 188 |
ST_List2, |
| 189 |
ST_List3, |
| 190 |
ST_List4, |
| 191 |
ST_List5, |
| 192 |
ST_List6, |
| 193 |
ST_Menu, |
| 194 |
ST_Menu1, |
| 195 |
ST_Menu2, |
| 196 |
ST_Menu3, |
| 197 |
ST_Menu4, |
| 198 |
ST_Menu5, |
| 199 |
ST_Menu6, |
| 200 |
ST_Glossary, |
| 201 |
ST_Glossary1, |
| 202 |
ST_Glossary2, |
| 203 |
ST_Glossary3, |
| 204 |
ST_Glossary4, |
| 205 |
ST_Glossary5, |
| 206 |
ST_Glossary6, |
| 207 |
ST_GlossaryCompact, |
| 208 |
ST_GlossaryCompact1, |
| 209 |
ST_GlossaryCompact2, |
| 210 |
ST_GlossaryCompact3, |
| 211 |
ST_GlossaryCompact4, |
| 212 |
ST_GlossaryCompact5, |
| 213 |
ST_GlossaryCompact6, |
| 214 |
ST_Example, |
| 215 |
ST_Preformatted, |
| 216 |
ST_Listing, |
| 217 |
ST_Address, |
| 218 |
ST_Note, |
| 219 |
ST_Heading1, |
| 220 |
ST_Heading2, |
| 221 |
ST_Heading3, |
| 222 |
ST_Heading4, |
| 223 |
ST_Heading5, |
| 224 |
ST_Heading6, |
| 225 |
ST_HeadingCenter, |
| 226 |
ST_HeadingLeft, |
| 227 |
ST_HeadingRight |
| 228 |
}; |
| 229 |
|
| 230 |
#ifdef __cplusplus |
| 231 |
} |
| 232 |
#endif |
| 233 |
#endif /* HTStyle_H */ |