1 /* 2 * $LynxId: HTStyle.h,v 1.17 2011/06/06 09:12:01 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 Attribtes (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 #ifdef SUPRESS 152 extern HTStyle *HTStyleRead(HTStyle *self, HTStream *stream); 153 extern HTStyle *HTStyleWrite(HTStyle *self, HTStream *stream); 154 #endif 155 /* Style Sheet 156 * ----------- 157 */ 158 typedef struct _HTStyleSheet { 159 const char *name; 160 HTStyle *styles; 161 } HTStyleSheet; 162 163 /* Stylesheet functions: 164 */ 165 extern HTStyleSheet *HTStyleSheetNew(void); 166 extern HTStyleSheet *HTStyleSheetFree(HTStyleSheet *self); 167 extern HTStyle *HTStyleNamed(HTStyleSheet *self, const char *name); 168 extern HTStyle *HTStyleForParagraph(HTStyleSheet *self, HTParagraphStyle * paraStyle); 169 extern HTStyle *HTStyleMatching(HTStyleSheet *self, HTStyle *style); 170 171 /* extern HTStyle * HTStyleForRun (HTStyleSheet *self, NXRun * run); */ 172 extern HTStyleSheet *HTStyleSheetAddStyle(HTStyleSheet *self, HTStyle *style); 173 extern HTStyleSheet *HTStyleSheetRemoveStyle(HTStyleSheet *self, HTStyle *style); 174 175 #ifdef SUPPRESS 176 extern HTStyleSheet *HTStyleSheetRead(HTStyleSheet *self, HTStream *stream); 177 extern HTStyleSheet *HTStyleSheetWrite(HTStyleSheet *self, HTStream *stream); 178 #endif 179 #define CLEAR_POINTER ((void *)-1) /* Pointer value means "clear me" */ 180 181 /* DefaultStyle.c */ 182 extern HTStyleSheet *DefaultStyle(HTStyle ***result_array); 183 184 /* enum, use this instead of HTStyle name comparisons */ 185 enum HTStyle_Enum { 186 ST_Normal = 0, 187 ST_DivCenter, 188 ST_DivLeft, 189 ST_DivRight, 190 ST_Banner, 191 ST_Blockquote, 192 ST_Bq, 193 ST_Footnote, 194 ST_List, 195 ST_List1, 196 ST_List2, 197 ST_List3, 198 ST_List4, 199 ST_List5, 200 ST_List6, 201 ST_Menu, 202 ST_Menu1, 203 ST_Menu2, 204 ST_Menu3, 205 ST_Menu4, 206 ST_Menu5, 207 ST_Menu6, 208 ST_Glossary, 209 ST_Glossary1, 210 ST_Glossary2, 211 ST_Glossary3, 212 ST_Glossary4, 213 ST_Glossary5, 214 ST_Glossary6, 215 ST_GlossaryCompact, 216 ST_GlossaryCompact1, 217 ST_GlossaryCompact2, 218 ST_GlossaryCompact3, 219 ST_GlossaryCompact4, 220 ST_GlossaryCompact5, 221 ST_GlossaryCompact6, 222 ST_Example, 223 ST_Preformatted, 224 ST_Listing, 225 ST_Address, 226 ST_Note, 227 ST_Heading1, 228 ST_Heading2, 229 ST_Heading3, 230 ST_Heading4, 231 ST_Heading5, 232 ST_Heading6, 233 ST_HeadingCenter, 234 ST_HeadingLeft, 235 ST_HeadingRight 236 }; 237 238 #ifdef __cplusplus 239 } 240 #endif 241 #endif /* HTStyle_H */ 242