output: Implement styling for footnotes.
[pspp] / src / output / tab.h
index ae3f4aeaf8458294de8f6382cefdced83d2278f5..40f871b12df5101cc718a07d16e2de02cbaf627f 100644 (file)
@@ -1,5 +1,5 @@
 /* PSPP - a program for statistical analysis.
-   Copyright (C) 1997, 1998, 1999, 2000, 2009, 2011 Free Software Foundation, Inc.
+   Copyright (C) 1997, 1998, 1999, 2000, 2009, 2011, 2014 Free Software Foundation, Inc.
 
    This program is free software: you can redistribute it and/or modify
    it under the terms of the GNU General Public License as published by
@@ -25,9 +25,9 @@
    Some of the features of this type of table are obsolete but have not yet
    been removed, because some code still uses them.  These features are:
 
-       - The title.  The title (or caption, actually) is a property of the
-         table_item (see output/table-item.h) in which a table is embedded,
-         not a property of the table itself.
+       - The title and caption.  These are properties of the table_item (see
+         output/table-item.h) in which a table is embedded, not properties of
+         the table itself.
 
        - Row and columns offsets (via tab_offset(), tab_next_row()).  This
          feature simply isn't used enough to justify keeping it.
@@ -51,16 +51,23 @@ enum result_class
     n_RC
   };
 
+#define TAB_STYLE_MASK (7u << (TAB_FIRST_AVAILABLE + 3))
+#define TAB_STYLE_SHIFT (TAB_FIRST_AVAILABLE + 3)
+
+/* Rule masks. */
+#define TAB_RULE_TYPE_MASK   7
+#define TAB_RULE_TYPE_SHIFT  0
+#define TAB_RULE_STYLE_MASK  (31 << TAB_RULE_STYLE_SHIFT)
+#define TAB_RULE_STYLE_SHIFT 3
+
 /* A table. */
 struct tab_table
   {
     struct table table;
     struct pool *container;
 
-    /* Table title, or a null pointer if no title has been set.
-
-       The table title is properly part of struct table_item, not struc*/
-    char *title;
+    /* Table title and caption, or null. */
+    char *title, *caption;
     int cf;                    /* Column factor for indexing purposes. */
 
     /* Table contents.
@@ -70,11 +77,13 @@ struct tab_table
        however, it is a joined cell and the corresponding element of cc[]
        points to a struct tab_joined_cell. */
     void **cc;                  /* Cell contents; void *[nr][nc]. */
-    unsigned char *ct;         /* Cell types; unsigned char[nr][nc]. */
+    unsigned short *ct;                /* Cell types; unsigned short[nr][nc]. */
+    struct cell_style *styles[8];
 
     /* Rules. */
     unsigned char *rh;         /* Horiz rules; unsigned char[nr+1][nc]. */
     unsigned char *rv;         /* Vert rules; unsigned char[nr][nc+1]. */
+    struct cell_color *rule_colors[32];
 
     /* X and Y offsets. */
     int col_ofs, row_ofs;
@@ -107,6 +116,8 @@ void tab_realloc (struct tab_table *, int nc, int nr);
 void tab_headers (struct tab_table *, int l, int r, int t, int b);
 void tab_title (struct tab_table *, const char *, ...)
      PRINTF_FORMAT (2, 3);
+void tab_caption (struct tab_table *, const char *, ...)
+     PRINTF_FORMAT (2, 3);
 void tab_submit (struct tab_table *);
 
 /* Rules. */
@@ -125,11 +136,11 @@ void tab_set_format (struct tab_table *, enum result_class, const struct fmt_spe
 struct fmt_spec;
 struct dictionary;
 union value;
-void tab_value (struct tab_table *, int c, int r, unsigned char opt,
+void tab_value (struct tab_table *, int c, int r, unsigned short opt,
                const union value *, const struct variable *,
                const struct fmt_spec *);
 
-void tab_double (struct tab_table *, int c, int r, unsigned char opt,
+void tab_double (struct tab_table *, int c, int r, unsigned short opt,
                 double v, const struct fmt_spec *, enum result_class );
 
 void tab_text (struct tab_table *, int c, int r, unsigned opt, const char *);
@@ -143,6 +154,15 @@ void tab_joint_text_format (struct tab_table *, int x1, int y1, int x2, int y2,
                             unsigned opt, const char *, ...)
      PRINTF_FORMAT (7, 8);
 
+struct footnote *tab_create_footnote (struct tab_table *, size_t idx,
+                                      const char *content, const char *marker,
+                                      struct cell_style *);
+void tab_add_footnote (struct tab_table *, int x, int y,
+                       const struct footnote *);
+
+void tab_add_style (struct tab_table *, int x, int y,
+                    const struct cell_style *);
+
 bool tab_cell_is_empty (const struct tab_table *, int c, int r);
 
 /* Editing. */