1 /* $Id$ $Revision$ */
2 /* vim:set shiftwidth=4 ts=8: */
3 
4 /*************************************************************************
5  * Copyright (c) 2011 AT&T Intellectual Property
6  * All rights reserved. This program and the accompanying materials
7  * are made available under the terms of the Eclipse Public License v1.0
8  * which accompanies this distribution, and is available at
9  * http://www.eclipse.org/legal/epl-v10.html
10  *
11  * Contributors: See CVS logs. Details at http://www.graphviz.org/
12  *************************************************************************/
13 
14 #ifdef __cplusplus
15 extern "C" {
16 #endif
17 
18 #ifndef TABLE_H
19 #define TABLE_H
20 
21 #define FIXED_FLAG 1
22 #define HALIGN_RIGHT (1 << 1)
23 #define HALIGN_LEFT (1 << 2)
24 #define HALIGN_MASK (HALIGN_RIGHT | HALIGN_LEFT)
25 #define HALIGN_TEXT HALIGN_MASK
26 #define VALIGN_TOP (1 << 3)
27 #define VALIGN_BOTTOM (1 << 4)
28 #define VALIGN_MASK (VALIGN_TOP | VALIGN_BOTTOM)
29 #define BORDER_SET (1 << 5)
30 #define PAD_SET (1 << 6)
31 #define SPACE_SET (1 << 7)
32 #define BALIGN_RIGHT (1 << 8)
33 #define BALIGN_LEFT (1 << 9)
34 #define BALIGN_MASK (BALIGN_RIGHT | BALIGN_LEFT)
35 #define BORDER_LEFT (1 << 10)
36 #define BORDER_TOP (1 << 11)
37 #define BORDER_RIGHT (1 << 12)
38 #define BORDER_BOTTOM (1 << 13)
39 #define BORDER_MASK (BORDER_LEFT|BORDER_TOP|BORDER_RIGHT|BORDER_BOTTOM)
40 
41 #define UNSET_ALIGN 0
42 
43     /* spans of text within a cell
44      * NOTE: As required, the str field in span is utf-8.
45      * This translation is done when libexpat scans the input.
46      */
47 
48     /* line of textspan_t's */
49     typedef struct {
50 	textspan_t *items;
51 	short nitems;
52 	char just;
53 	double size;   /* width of span */
54 	double lfsize; /* offset from previous baseline to current one */
55     } htextspan_t;
56 
57     typedef struct {
58 	htextspan_t *spans;
59 	short nspans;
60 	char simple;
61 	boxf box;
62     } htmltxt_t;
63 
64     typedef struct {
65 	boxf box;
66 	char *src;
67 	char *scale;
68     } htmlimg_t;
69 
70     typedef struct {
71 	char *href;		/* pointer to an external resource */
72 	char *port;
73 	char *target;
74 	char *title;
75 	char *id;
76 	char *bgcolor;
77 	char *pencolor;
78 	int gradientangle;
79 	signed char space;
80 	unsigned char border;
81 	unsigned char pad;
82 	unsigned char sides;    /* set of sides exposed to field */
83 	unsigned short flags;
84 	unsigned short width;
85 	unsigned short height;
86 	unsigned short style;
87 	boxf box;		/* its geometric placement in points */
88     } htmldata_t;
89 
90 #define HTML_UNSET 0
91 #define HTML_TBL 1
92 #define HTML_TEXT 2
93 #define HTML_IMAGE 3
94 
95 #define HTML_VRULE 1
96 #define HTML_HRULE 2
97 
98     typedef struct htmlcell_t htmlcell_t;
99     typedef struct htmltbl_t htmltbl_t;
100 
101     struct htmltbl_t {
102 	htmldata_t data;
103 	union {
104 	    struct {
105 		htmlcell_t *parent;	/* enclosing cell */
106 		htmlcell_t **cells;	/* cells */
107 	    } n;
108 	    struct {
109 		htmltbl_t *prev;	/* stack */
110 		Dt_t *rows;	/* cells */
111 	    } p;
112 	} u;
113 	signed char cb;		/* cell border */
114 	int *heights;		/* heights of the rows */
115 	int *widths;		/* widths of the columns */
116 	int rc;			/* number of rows */
117 	int cc;			/* number of columns */
118 	textfont_t *font;	/* font info */
119 	unsigned char flags;
120     };
121 
122     struct htmllabel_t {
123 	union {
124 	    htmltbl_t *tbl;
125 	    htmltxt_t *txt;
126 	    htmlimg_t *img;
127 	} u;
128 	char kind;
129     };
130 
131     struct htmlcell_t {
132 	htmldata_t data;
133 	unsigned short cspan;
134 	unsigned short rspan;
135 	unsigned short col;
136 	unsigned short row;
137 	htmllabel_t child;
138 	htmltbl_t *parent;
139 	unsigned char ruled;
140     };
141 
142 /* During parsing, table contents are stored as rows of cells.
143  * A row is a list of cells
144  * Rows is a list of rows.
145  * pitems are used for both lists.
146  */
147     typedef struct {
148 	Dtlink_t link;
149 	union {
150 	    Dt_t *rp;
151 	    htmlcell_t *cp;
152 	} u;
153 	unsigned char ruled;
154     } pitem;
155 
156     typedef struct {
157         pointf pos;
158         textfont_t finfo;
159         void *obj;
160         graph_t *g;
161         char *imgscale;
162         char *objid;
163         boolean objid_set;
164     } htmlenv_t;
165 
166     extern htmllabel_t *parseHTML(char *, int *, htmlenv_t *);
167 
168     extern int make_html_label(void *obj, textlabel_t * lp);
169     extern void emit_html_label(GVJ_t * job, htmllabel_t * lp, textlabel_t *);
170 
171     extern void free_html_label(htmllabel_t *, int);
172     extern void free_html_data(htmldata_t *);
173     extern void free_html_text(htmltxt_t *);
174 
175     extern boxf *html_port(node_t * n, char *pname, int* sides);
176     extern int html_path(node_t * n, port* p, int side, boxf * rv, int *k);
177     extern int html_inside(node_t * n, pointf p, edge_t * e);
178 
179 #endif
180 
181 #ifdef __cplusplus
182 }
183 #endif
184