4 * Author: Teemu Rantanen <tvr@cs.hut.fi>
5 * Copyright (c) 1992 Teemu Rantanen
8 * Created: Thu Mar 5 00:56:46 1992 tvr
9 * Last modified: Wed May 13 06:21:48 1992 tvr
18 #include "../HText/HText.h"
23 #include "XlFormatText.h"
25 #include "XlDefaultFonts.h"
32 * All hypertext styles. Also needed configure data (font configure-name)
35 #define CREATE_STYLE(font, cname, tag, mode, first, left, right) \
36 {NULL, font, 0, cname, tag, 0, mode, first, left, right, 140, 100, 100, 50}
38 XlStyle_t XlStyles[] =
40 CREATE_STYLE(FONT_NORMAL,
46 CREATE_STYLE(FONT_LIST,
52 CREATE_STYLE(FONT_LISTCOMPACT,
58 CREATE_STYLE(FONT_GLOSSARY,
61 STYLE_LEFTIFY | STYLE_CHANGE_REGION_ON_TAB,
64 CREATE_STYLE(FONT_GLOSSARYCOMPACT,
65 C_FONT_GLOSSARYCOMPACT,
67 STYLE_LEFTIFY | STYLE_CHANGE_REGION_ON_TAB,
70 CREATE_STYLE(FONT_EXAMPLE,
73 STYLE_LEFTIFY | STYLE_RAW,
76 CREATE_STYLE(FONT_LISTING,
79 STYLE_LEFTIFY | STYLE_RAW,
82 CREATE_STYLE(FONT_ADDRESS,
88 CREATE_STYLE(FONT_HEADER1,
94 CREATE_STYLE(FONT_HEADER2,
100 CREATE_STYLE(FONT_HEADER3,
106 CREATE_STYLE(FONT_HEADER4,
112 CREATE_STYLE(FONT_HEADER5,
118 CREATE_STYLE(FONT_HEADER6,
124 CREATE_STYLE(FONT_HEADER7,
139 * How much to increase y coordinate after this line ?
143 int xl_linespace(p_start, p_end)
144 HTextObject_t *p_start;
145 HTextObject_t *p_end;
147 if (p_start->xl_data->style->fontinfo) {
149 return ((p_start->xl_data->style->fontinfo->ascent +
150 p_start->xl_data->style->fontinfo->descent) *
151 p_start->xl_data->style->space_line) / 100;
154 return p_start->xl_data->style->space_line / 100;
159 int xl_paragraphspace(p_start, p_end)
160 HTextObject_t *p_start;
161 HTextObject_t *p_end;
163 if (p_start->xl_data->style->fontinfo) {
165 return ((p_start->xl_data->style->fontinfo->ascent +
166 p_start->xl_data->style->fontinfo->descent) *
167 p_start->xl_data->style->space_paragraph) / 100;
170 return p_start->xl_data->style->space_paragraph / 100;
175 int xl_stylespace(p_start, p_end)
176 HTextObject_t *p_start;
177 HTextObject_t *p_end;
179 if (p_start->xl_data->style->fontinfo) {
181 return ((p_start->xl_data->style->fontinfo->ascent +
182 p_start->xl_data->style->fontinfo->descent) *
183 p_start->xl_data->style->space_style) / 100;
192 int xl_stylespace_before(p_start, p_end)
193 HTextObject_t *p_start;
194 HTextObject_t *p_end;
196 if (p_start->xl_data->style->fontinfo) {
198 return ((p_start->xl_data->style->fontinfo->ascent +
199 p_start->xl_data->style->fontinfo->descent) *
200 p_start->xl_data->style->space_style_before) / 100;
209 * How much to increase x-coordinate after this object ?
215 if (xl_object_mode(p) & STYLE_RAW)
218 return p->xl_data->style->char_width;
223 * Return width of a character 'a'. Used to mostly when calculating
226 int xl_character_width(p)
229 return p->xl_data->style->char_width;
234 * Return style of this object
236 int xl_object_style(p)
239 return p->xl_data->style->mode & STYLE_MASK;
244 * Return mode of this object
246 int xl_object_mode(p)
249 return p->xl_data->style->mode;
254 * Calculate position of a coordinate according to left and right margins
257 int xl_calc_position(p, which, left, right)
264 int delta = right - left;
266 XlStyle_t *s = p->xl_data->style;
268 if (which & I_LEFT) {
269 r += (s->left * delta) / 100;
271 if (which & I_MIDDLE_L) {
272 r += (MIDDLE_L_HACK * delta) / 100;
274 if (which & I_MIDDLE_R) {
275 r += (MIDDLE_R_HACK * delta) / 100;
277 if (which & I_RIGHT) {
278 r += (s->right * delta) / 100;
280 if (which & I_FIRST) {
281 r += (s->indent1st * delta) / 100;