Graphviz  2.31.20130618.0446
lib/common/htmltable.h
Go to the documentation of this file.
00001 /* $Id$ $Revision$ */
00002 /* vim:set shiftwidth=4 ts=8: */
00003 
00004 /*************************************************************************
00005  * Copyright (c) 2011 AT&T Intellectual Property 
00006  * All rights reserved. This program and the accompanying materials
00007  * are made available under the terms of the Eclipse Public License v1.0
00008  * which accompanies this distribution, and is available at
00009  * http://www.eclipse.org/legal/epl-v10.html
00010  *
00011  * Contributors: See CVS logs. Details at http://www.graphviz.org/
00012  *************************************************************************/
00013 
00014 #ifdef __cplusplus
00015 extern "C" {
00016 #endif
00017 
00018 #ifndef TABLE_H
00019 #define TABLE_H
00020 
00021 #define FIXED_FLAG 1
00022 #define HALIGN_RIGHT (1 << 1)
00023 #define HALIGN_LEFT (1 << 2)
00024 #define HALIGN_MASK (HALIGN_RIGHT | HALIGN_LEFT)
00025 #define HALIGN_TEXT HALIGN_MASK
00026 #define VALIGN_TOP (1 << 3)
00027 #define VALIGN_BOTTOM (1 << 4)
00028 #define VALIGN_MASK (VALIGN_TOP | VALIGN_BOTTOM)
00029 #define BORDER_SET (1 << 5)
00030 #define PAD_SET (1 << 6)
00031 #define SPACE_SET (1 << 7)
00032 #define BALIGN_RIGHT (1 << 8)
00033 #define BALIGN_LEFT (1 << 9)
00034 #define BALIGN_MASK (BALIGN_RIGHT | BALIGN_LEFT)
00035 
00036 #define UNSET_ALIGN 0
00037 
00038     /* paras of text within a cell
00039      * NOTE: As required, the str field in para is utf-8.
00040      * This translation is done when libexpat scans the input.
00041      */
00042         
00043     /* line of textpara_t's */
00044     typedef struct {
00045         textpara_t *items;
00046         short nitems;
00047         char just;
00048         double size;   /* width of para */
00049         double lfsize; /* offset from previous baseline to current one */
00050     } htextpara_t;
00051         
00052     typedef struct {
00053         htextpara_t *paras;
00054         short nparas;
00055         boxf box;
00056     } htmltxt_t;
00057 
00058     typedef struct {
00059         boxf box;
00060         char *src;
00061         char *scale;
00062     } htmlimg_t;
00063 
00064     typedef struct {
00065         char *href;             /* pointer to an external resource */
00066         char *port;
00067         char *target;
00068         char *title;
00069         char *id;
00070         char *bgcolor;
00071         char *pencolor;
00072         int gradientangle;
00073         signed char space;
00074         unsigned char border;
00075         unsigned char pad;
00076         unsigned char sides;    /* set of sides exposed to field */
00077         unsigned short flags;
00078         unsigned short width;
00079         unsigned short height;
00080         unsigned short style;
00081         boxf box;               /* its geometric placement in points */
00082     } htmldata_t;
00083 
00084 #define HTML_UNSET 0
00085 #define HTML_TBL 1
00086 #define HTML_TEXT 2
00087 #define HTML_IMAGE 3
00088 
00089 #define HTML_VRULE 1
00090 #define HTML_HRULE 2
00091 
00092     typedef struct htmlcell_t htmlcell_t;
00093     typedef struct htmltbl_t htmltbl_t;
00094         
00095     struct htmltbl_t {
00096         htmldata_t data;
00097         union {
00098             struct {
00099                 htmlcell_t *parent;     /* enclosing cell */
00100                 htmlcell_t **cells;     /* cells */
00101             } n;
00102             struct {
00103                 htmltbl_t *prev;        /* stack */
00104                 Dt_t *rows;     /* cells */
00105             } p;
00106         } u;
00107         signed char cb;         /* cell border */
00108         int *heights;           /* heights of the rows */
00109         int *widths;            /* widths of the columns */
00110         int rc;                 /* number of rows */
00111         int cc;                 /* number of columns */
00112         htmlfont_t *font;       /* font info */
00113         unsigned char flags;
00114     };
00115 
00116     struct htmllabel_t {
00117         union {
00118             htmltbl_t *tbl;
00119             htmltxt_t *txt;
00120             htmlimg_t *img;
00121         } u;
00122         char kind;
00123     };
00124 
00125     struct htmlcell_t {
00126         htmldata_t data;
00127         unsigned short cspan;
00128         unsigned short rspan;
00129         unsigned short col;
00130         unsigned short row;
00131         htmllabel_t child;
00132         htmltbl_t *parent;
00133         unsigned char ruled;
00134     };
00135 
00136 /* During parsing, table contents are stored as rows of cells.
00137  * A row is a list of cells
00138  * Rows is a list of rows.
00139  * pitems are used for both lists.
00140  */
00141     typedef struct {
00142         Dtlink_t link;
00143         union {
00144             Dt_t *rp;
00145             htmlcell_t *cp;
00146         } u;
00147         unsigned char ruled;
00148     } pitem;
00149         
00150     extern htmllabel_t *parseHTML(char *, int *, int);
00151 
00152     extern int make_html_label(void *obj, textlabel_t * lp);
00153     extern void emit_html_label(GVJ_t * job, htmllabel_t * lp, textlabel_t *);
00154 
00155     extern void free_html_label(htmllabel_t *, int);
00156     extern void free_html_data(htmldata_t *);
00157     extern void free_html_text(htmltxt_t *);
00158     extern void free_html_font(htmlfont_t*);
00159 
00160     extern boxf *html_port(node_t * n, char *pname, int* sides);
00161     extern int html_path(node_t * n, port* p, int side, boxf * rv, int *k);
00162     extern int html_inside(node_t * n, pointf p, edge_t * e);
00163 
00164 #endif
00165 
00166 #ifdef __cplusplus
00167 }
00168 #endif