2001-08-06 Dave Peticolas <dave@krondo.com>

* src/register/table-html.[ch]: remove

	* src/register/Makefile.am: add table-model.[ch],
	remove table-html.[ch]

	* src/MultiLedger.c: same as below

	* src/register/table-allgui.[ch]: same as below

	* src/register/table-model.[ch]: separate table model out from
	table code.


git-svn-id: svn+ssh://svn.gnucash.org/repo/gnucash/trunk@5074 57a11ea4-9604-0410-9ed3-97b8803252fd
This commit is contained in:
Dave Peticolas 2001-08-06 23:48:19 +00:00
parent f2ffc649bb
commit 5805a1b5b9
8 changed files with 213 additions and 411 deletions

View File

@ -1,5 +1,17 @@
2001-08-06 Dave Peticolas <dave@krondo.com>
* src/register/table-html.[ch]: remove
* src/register/Makefile.am: add table-model.[ch],
remove table-html.[ch]
* src/MultiLedger.c: same as below
* src/register/table-allgui.[ch]: same as below
* src/register/table-model.[ch]: separate table model out from
table code.
* src/register/pricecell.c: fix bugs
* src/engine/sql/upgrade.h: fix warning

View File

@ -53,6 +53,7 @@ struct _xaccLedgerDisplay
LedgerDisplayType ld_type;
SplitRegister *reg;
TableModel *model;
gboolean loading;
@ -207,7 +208,7 @@ find_by_reg (gpointer find_data, gpointer user_data)
}
static SplitRegisterStyle
gnc_get_default_register_style ()
gnc_get_default_register_style (void)
{
SplitRegisterStyle new_style = REG_STYLE_LEDGER;
char *style_string;
@ -394,7 +395,7 @@ xaccLedgerDisplayAccGroup (Account *account)
\********************************************************************/
xaccLedgerDisplay *
xaccLedgerDisplayGL ()
xaccLedgerDisplayGL (void)
{
Query *query;
time_t start;
@ -612,6 +613,9 @@ close_handler (gpointer user_data)
xaccFreeQuery (ld->query);
ld->query = NULL;
gnc_table_model_destroy (ld->model);
ld->model = NULL;
g_free (ld);
}
@ -694,7 +698,6 @@ xaccLedgerDisplayInternal (Account *lead_account, Query *q,
xaccLedgerDisplay *ld;
gboolean show_all;
const char *class;
TableModel model;
GList *splits;
switch (ld_type)
@ -800,27 +803,30 @@ xaccLedgerDisplayInternal (Account *lead_account, Query *q,
/* xaccMallocSplitRegister will malloc & initialize the register,
* but will not do the gui init */
model.label_handler = xaccSRGetLabelHandler;
model.fg_color_handler = xaccSRGetFGColorHandler;
model.bg_color_handler = xaccSRGetBGColorHandler;
model.cell_border_handler = xaccSRGetCellBorderHandler;
model.handler_user_data = NULL;
ld->model = gnc_table_model_new ();
ld->model->label_handler = xaccSRGetLabelHandler;
ld->model->fg_color_handler = xaccSRGetFGColorHandler;
ld->model->bg_color_handler = xaccSRGetBGColorHandler;
ld->model->cell_border_handler = xaccSRGetCellBorderHandler;
ld->model->handler_user_data = NULL;
/* The following handlers are changed in template mode. */
if ( templateMode ) {
model.entry_handler = xaccSRTemplateGetEntryHandler;
model.io_flag_handler = xaccSRTemplateGetIOFlagsHandler;
model.confirm_handler = xaccSRTemplateConfirmHandler;
ld->model->entry_handler = xaccSRTemplateGetEntryHandler;
ld->model->io_flag_handler = xaccSRTemplateGetIOFlagsHandler;
ld->model->confirm_handler = xaccSRTemplateConfirmHandler;
} else {
model.entry_handler = xaccSRGetEntryHandler;
model.io_flag_handler = xaccSRGetIOFlagsHandler;
model.confirm_handler = xaccSRConfirmHandler;
ld->model->entry_handler = xaccSRGetEntryHandler;
ld->model->io_flag_handler = xaccSRGetIOFlagsHandler;
ld->model->confirm_handler = xaccSRConfirmHandler;
}
model.cell_data_allocator = xaccMLGUIDMalloc;
model.cell_data_deallocator = xaccMLGUIDFree;
model.cell_data_copy = xaccMLGUIDCopy;
ld->model->cell_data_allocator = xaccMLGUIDMalloc;
ld->model->cell_data_deallocator = xaccMLGUIDFree;
ld->model->cell_data_copy = xaccMLGUIDCopy;
ld->reg = gnc_register_new (reg_type, style, FALSE, ld->model, templateMode);
ld->reg = gnc_register_new (reg_type, style, FALSE, &model, templateMode);
xaccSRSetData (ld->reg, ld,
xaccLedgerDisplayParent,
xaccLedgerDisplaySetHelp);

View File

@ -16,6 +16,7 @@ libgncregister_a_SOURCES = \
splitreg.c \
table-allgui.c \
table-gnome.c \
table-model.c \
textcell.c
noinst_HEADERS = \
@ -33,12 +34,11 @@ noinst_HEADERS = \
register-common.h \
splitreg.h \
table-allgui.h \
table-model.h \
textcell.h
EXTRA_DIST = \
.cvsignore \
table-html.c \
table-html.h
.cvsignore
CFLAGS = @CFLAGS@

View File

@ -72,7 +72,7 @@ gnc_table_new (TableModel *model)
table = g_new0 (Table, 1);
table->model = *model;
table->model = model;
gnc_table_init (table);
@ -180,9 +180,9 @@ gnc_table_get_entry_internal (Table *table, VirtualLocation virt_loc,
{
const char *entry;
entry = table->model.entry_handler (virt_loc, FALSE,
conditionally_changed,
table->model.handler_user_data);
entry = table->model->entry_handler (virt_loc, FALSE,
conditionally_changed,
table->model->handler_user_data);
if (!entry)
entry = "";
@ -219,8 +219,8 @@ gnc_table_get_entry (Table *table, VirtualLocation virt_loc)
return cb_cell->cell->value;
}
entry = table->model.entry_handler (virt_loc, TRUE, NULL,
table->model.handler_user_data);
entry = table->model->entry_handler (virt_loc, TRUE, NULL,
table->model->handler_user_data);
if (!entry)
entry = "";
@ -232,11 +232,11 @@ gnc_table_get_entry (Table *table, VirtualLocation virt_loc)
CellIOFlags
gnc_table_get_io_flags (Table *table, VirtualLocation virt_loc)
{
if (!table->model.io_flag_handler)
if (!table->model->io_flag_handler)
return XACC_CELL_ALLOW_NONE;
return table->model.io_flag_handler (virt_loc,
table->model.handler_user_data);
return table->model->io_flag_handler (virt_loc,
table->model->handler_user_data);
}
/* ==================================================== */
@ -244,10 +244,11 @@ gnc_table_get_io_flags (Table *table, VirtualLocation virt_loc)
const char *
gnc_table_get_label (Table *table, VirtualLocation virt_loc)
{
if (!table->model.label_handler)
if (!table->model->label_handler)
return "";
return table->model.label_handler (virt_loc, table->model.handler_user_data);
return table->model->label_handler (virt_loc,
table->model->handler_user_data);
}
/* ==================================================== */
@ -255,11 +256,11 @@ gnc_table_get_label (Table *table, VirtualLocation virt_loc)
guint32
gnc_table_get_fg_color (Table *table, VirtualLocation virt_loc)
{
if (!table->model.fg_color_handler)
if (!table->model->fg_color_handler)
return 0x0; /* black */
return table->model.fg_color_handler (virt_loc,
table->model.handler_user_data);
return table->model->fg_color_handler (virt_loc,
table->model->handler_user_data);
}
/* ==================================================== */
@ -268,11 +269,11 @@ guint32
gnc_table_get_bg_color (Table *table, VirtualLocation virt_loc,
gboolean *hatching)
{
if (!table->model.bg_color_handler)
if (!table->model->bg_color_handler)
return 0xffffff; /* white */
return table->model.bg_color_handler (virt_loc, hatching,
table->model.handler_user_data);
return table->model->bg_color_handler (virt_loc, hatching,
table->model->handler_user_data);
}
/* ==================================================== */
@ -281,11 +282,11 @@ void
gnc_table_get_borders (Table *table, VirtualLocation virt_loc,
PhysicalCellBorders *borders)
{
if (!table->model.cell_border_handler)
if (!table->model->cell_border_handler)
return;
table->model.cell_border_handler (virt_loc, borders,
table->model.handler_user_data);
table->model->cell_border_handler (virt_loc, borders,
table->model->handler_user_data);
}
/* ==================================================== */
@ -384,8 +385,8 @@ gnc_virtual_cell_construct (gpointer _vcell, gpointer user_data)
vcell->cellblock = NULL;
if (table && table->model.cell_data_allocator)
vcell->vcell_data = table->model.cell_data_allocator ();
if (table && table->model->cell_data_allocator)
vcell->vcell_data = table->model->cell_data_allocator ();
else
vcell->vcell_data = NULL;
@ -400,8 +401,8 @@ gnc_virtual_cell_destroy (gpointer _vcell, gpointer user_data)
VirtualCell *vcell = _vcell;
Table *table = user_data;
if (vcell->vcell_data && table && table->model.cell_data_deallocator)
table->model.cell_data_deallocator (vcell->vcell_data);
if (vcell->vcell_data && table && table->model->cell_data_deallocator)
table->model->cell_data_deallocator (vcell->vcell_data);
vcell->vcell_data = NULL;
}
@ -448,8 +449,8 @@ gnc_table_set_vcell (Table *table,
vcell->cellblock = cursor;
/* copy the vcell user data */
if (table->model.cell_data_copy)
table->model.cell_data_copy (vcell->vcell_data, vcell_data);
if (table->model->cell_data_copy)
table->model->cell_data_copy (vcell->vcell_data, vcell_data);
else
vcell->vcell_data = (gpointer) vcell_data;
@ -473,8 +474,8 @@ gnc_table_set_virt_cell_data (Table *table,
if (vcell == NULL)
return;
if (table->model.cell_data_copy)
table->model.cell_data_copy (vcell->vcell_data, vcell_data);
if (table->model->cell_data_copy)
table->model->cell_data_copy (vcell->vcell_data, vcell_data);
else
vcell->vcell_data = (gpointer) vcell_data;
}
@ -954,11 +955,11 @@ gnc_table_confirm_change (Table *table, VirtualLocation virt_loc)
if (!table)
return TRUE;
if (!table->model.confirm_handler)
if (!table->model->confirm_handler)
return TRUE;
return table->model.confirm_handler (virt_loc,
table->model.handler_user_data);
return table->model->confirm_handler (virt_loc,
table->model->handler_user_data);
}
/* ==================================================== */
@ -996,9 +997,9 @@ gnc_table_modify_update(Table *table,
ENTER ("\n");
if (table->model.confirm_handler &&
! (table->model.confirm_handler (virt_loc,
table->model.handler_user_data)))
if (table->model->confirm_handler &&
! (table->model->confirm_handler (virt_loc,
table->model->handler_user_data)))
{
if (cancelled)
*cancelled = TRUE;
@ -1099,9 +1100,9 @@ gnc_table_direct_update (Table *table,
if (safe_strcmp (old_value, cell->value) != 0)
{
if (table->model.confirm_handler &&
! (table->model.confirm_handler (virt_loc,
table->model.handler_user_data)))
if (table->model->confirm_handler &&
! (table->model->confirm_handler (virt_loc,
table->model->handler_user_data)))
{
xaccSetBasicCellValue (cell, old_value);
*newval_ptr = NULL;

View File

@ -83,7 +83,7 @@
*
* HISTORY:
* Copyright (c) 1998,1999,2000 Linas Vepstas
* Copyright (c) 2000 Dave Peticolas
* Copyright (c) 2000-2001 Dave Peticolas
*/
#ifndef TABLE_ALLGUI_H
@ -91,22 +91,12 @@
#include <glib.h>
#include "gnc-common.h"
#include "register-common.h"
#include "basiccell.h"
#include "cellblock.h"
#include "gnc-common.h"
#include "gtable.h"
typedef enum
{
XACC_CELL_ALLOW_NONE = 0,
XACC_CELL_ALLOW_INPUT = 1 << 0,
XACC_CELL_ALLOW_SHADOW = 1 << 1,
XACC_CELL_ALLOW_ALL = XACC_CELL_ALLOW_INPUT | XACC_CELL_ALLOW_SHADOW,
XACC_CELL_ALLOW_EXACT_ONLY = 1 << 2
} CellIOFlags;
#include "register-common.h"
#include "table-model.h"
typedef enum
@ -118,7 +108,6 @@ typedef enum
GNC_TABLE_TRAVERSE_DOWN
} gncTableTraversalDir;
/* The VirtualCell structure holds information about each virtual cell. */
typedef struct _VirtualCell VirtualCell;
struct _VirtualCell
@ -131,25 +120,6 @@ struct _VirtualCell
unsigned int start_primary_color : 1; /* color usage flag */
};
typedef enum
{
CELL_BORDER_LINE_NONE,
CELL_BORDER_LINE_LIGHT,
CELL_BORDER_LINE_NORMAL,
CELL_BORDER_LINE_HEAVY,
CELL_BORDER_LINE_HIGHLIGHT
} PhysicalCellBorderLineStyle;
typedef struct
{
PhysicalCellBorderLineStyle top;
PhysicalCellBorderLineStyle bottom;
PhysicalCellBorderLineStyle left;
PhysicalCellBorderLineStyle right;
} PhysicalCellBorders;
typedef struct _Table Table;
typedef void (*TableMoveFunc) (Table *table,
@ -164,52 +134,6 @@ typedef void (*TableSetHelpFunc) (Table *table,
typedef void (*TableDestroyFunc) (Table *table);
typedef const char * (*TableGetEntryHandler) (VirtualLocation virt_loc,
gboolean translate,
gboolean *conditionally_changed,
gpointer user_data);
typedef const char * (*TableGetLabelHandler) (VirtualLocation virt_loc,
gpointer user_data);
typedef CellIOFlags (*TableGetCellIOFlags) (VirtualLocation virt_loc,
gpointer user_data);
typedef guint32 (*TableGetFGColorHandler) (VirtualLocation virt_loc,
gpointer user_data);
typedef guint32 (*TableGetBGColorHandler) (VirtualLocation virt_loc,
gboolean *hatching,
gpointer user_data);
typedef void (*TableGetCellBorderHandler) (VirtualLocation virt_loc,
PhysicalCellBorders *borders,
gpointer user_data);
typedef gboolean (*TableConfirmHandler) (VirtualLocation virt_loc,
gpointer user_data);
typedef gpointer (*VirtCellDataAllocator) (void);
typedef void (*VirtCellDataDeallocator) (gpointer cell_data);
typedef void (*VirtCellDataCopy) (gpointer to, gconstpointer from);
typedef struct
{
TableGetEntryHandler entry_handler;
TableGetLabelHandler label_handler;
TableGetCellIOFlags io_flag_handler;
TableGetFGColorHandler fg_color_handler;
TableGetBGColorHandler bg_color_handler;
TableGetCellBorderHandler cell_border_handler;
TableConfirmHandler confirm_handler;
gpointer handler_user_data;
VirtCellDataAllocator cell_data_allocator;
VirtCellDataDeallocator cell_data_deallocator;
VirtCellDataCopy cell_data_copy;
} TableModel;
struct _Table
{
short num_virt_rows;
@ -253,7 +177,7 @@ struct _Table
gpointer ui_data;
TableModel model;
TableModel *model;
TableDestroyFunc destroy;
};

View File

@ -1,253 +0,0 @@
/********************************************************************\
* table-html.c -- print table as html *
* *
* 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 the Free Software Foundation; either version 2 of *
* the License, or (at your option) any later version. *
* *
* This program is distributed in the hope that it will be useful, *
* but WITHOUT ANY WARRANTY; without even the implied warranty of *
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the *
* GNU General Public License for more details. *
* *
* You should have received a copy of the GNU General Public License*
* along with this program; if not, contact: *
* *
* Free Software Foundation Voice: +1-617-542-5942 *
* 59 Temple Place - Suite 330 Fax: +1-617-542-2652 *
* Boston, MA 02111-1307, USA gnu@gnu.org *
* *
\********************************************************************/
/*
* FILE:
* table-html.c
*
* FUNCTION:
* Implements the infrastructure for the displayed table.
* This is just a sample hack for printing html to a file,
* or by acting as a web server. Its cheesey, for several
* reasons:
*
* (1) HTML should never be put in the same file as C code.
* Some sort of template file should be used.
*
* (2) The data printed hre is obtained from the displayed
* ledger/register. Thus, it accurately reflects
* what's in the ledger, but is otherwise a cheesy way
* of doing a report. Real report generators should
* get the financial data straight from the engine,
* not from the register.
*
* (3) The so-called "webserver" has less intelligence
* than a mosquito.
*
* But this code is fun, so what the hey.
*
*
* HISTORY:
* Copyright (c) 1998 Linas Vepstas
*/
#include <errno.h>
#include <fcntl.h>
#include <netinet/in.h>
#include <stdio.h>
#include <stdlib.h>
#include <string.h>
#include <sys/socket.h>
#include <sys/stat.h>
#include <sys/time.h>
#include <sys/types.h>
#include <unistd.h>
#include "cellblock.h"
#include "table-allgui.h"
#include "table-html.h"
#include "util.h"
/* This static indicates the debugging module that this .o belongs to. */
static short module = MOD_REGISTER;
/* ==================================================== */
CellBlock *
getcurs (Table *table, int prow)
{
int vrow;
vrow = table->locators[prow][0]->virt_row;
return (table->handlers[vrow][0]);
}
int
xaccTableDumpHTML (Table * table, int fd)
{
FILE * fh;
int i, j;
CellBlock *curs, *head, *trans;
int cnt = 0;
if ((!table) || (0 > fd)) return 0;
/* fd could be a file descriptor for a file, or for a socket. */
fh = fdopen (fd, "a");
if (!fh) {
int norr = errno;
PERR ("can't open fd=%d \n"
"\t(%d) %s \n", fd, norr, strerror (norr));
return 0;
}
/* print the header */
cnt += fprintf (fh,
"<html>\n"
"<head><title>GnuCash Regsiter</title></head>\n"
"<body bgcolor=#FFFFFF>\n"
"<h1>GnuCash Register</h1>\n"
"<table>\n");
/* print the table header rows */
head = getcurs (table, 0);
i = 0;
do {
cnt += fprintf (fh, "<tr>\n");
for (j=0; j<table->num_phys_cols; j++) {
cnt += fprintf (fh, "<th>%s</th>", table->entries[i][j]);
}
cnt += fprintf (fh, "\n</tr>");
i++;
curs = getcurs (table, i);
} while (head == curs);
trans = curs;
/* print the body of the table */
for (; i<table->num_phys_rows; i++) {
curs = getcurs (table, i);
if (trans == curs) {
cnt += fprintf (fh, "<tr bgcolor=#AAAAAA>\n");
} else {
cnt += fprintf (fh, "<tr>\n");
}
for (j=0; j<table->num_phys_cols; j++) {
if (0x0 == table->entries[i][j][0]) {
cnt += fprintf (fh, "<td>&nbsp;</td>");
} else {
cnt += fprintf (fh, "<td>%s</td>", table->entries[i][j]);
}
}
cnt += fprintf (fh, "\n</tr>");
}
cnt += fprintf (fh, "</table></body></html>");
fflush (fh);
return cnt;
}
/* ==================================================== */
int
xaccTablePrintHTML (Table * table, char *filename)
{
int fd;
int cnt;
if ((!table) || (!filename)) return 0;
fd = open (filename, O_CREAT | O_APPEND | O_WRONLY, S_IRUSR | S_IWUSR);
if (0 > fd) {
int norr = errno;
PERR ("can't open file %s\n"
"\t(%d) %s\n", filename, norr, strerror (norr));
return 0;
}
cnt = xaccTableDumpHTML (table, fd);
close (fd);
return (cnt);
}
/* ==================================================== */
/* implement a cheesy web server */
/* maybe not the worlds smallest web server, but close */
#define CHKERR(val, msg) { \
if (0 > val) { \
int norr = errno; \
PERR ( msg "\n" \
"(%d) %s \n", norr, strerror (norr)); \
if (pid) return; \
exit (0); \
} \
}
void
xaccTableWebServeHTML (Table * table, unsigned short port)
{
int listen_fd, accept_fd;
pid_t pid;
int rc;
struct sockaddr_in myaddr;
struct sockaddr clientsock;
int clientaddrsize = sizeof (struct sockaddr);
fd_set readfds;
struct timeval timeout;
char buff[255];
int cnt;
if (!table) return;
/* don't slow down the parent, fork into background */
pid = fork();
if (0 < pid) return; /* parent */
CHKERR (pid, "cant fork");
/* create a socket */
listen_fd = socket(AF_INET, SOCK_STREAM, IPPROTO_TCP);
CHKERR (listen_fd, "cant listen");
memset ((void*) &myaddr, 0, sizeof (struct sockaddr_in));
myaddr.sin_family = AF_INET;
myaddr.sin_addr.s_addr = htonl (INADDR_ANY);
myaddr.sin_port = htons (port); /* WWW server is port 80 but that is usperuser only */
rc = bind (listen_fd, (struct sockaddr *) &myaddr, sizeof (struct sockaddr));
CHKERR (rc, "cant bind");
rc = listen (listen_fd, 10);
CHKERR (rc, "cant listen");
/* if no one connects to us after 8 minutes, just exit */
FD_ZERO (&readfds);
FD_SET (listen_fd, &readfds);
timeout.tv_sec = 500;
timeout.tv_usec = 0;
rc = select (160, &readfds, NULL, NULL, &timeout);
CHKERR (rc, "cant select");
if (0 == rc) exit (0);
accept_fd = accept (listen_fd, &clientsock, &clientaddrsize);
CHKERR (rc, "cant accept");
/* count the number of chars, for content-length */
cnt = xaccTablePrintHTML (table, "/dev/null");
snprintf (buff, 255,
"HTTP/1.0 200 OK\n"
"Connection: close\n"
"Content-Length: %d\n"
"Content-Type: text/html\n\n", cnt);
write (accept_fd, buff, sizeof (buff));
xaccTableDumpHTML (table, accept_fd);
/* linger for some @#$%^ reason, otherwise browser complains */
sleep (30);
shutdown (accept_fd, 1);
close (accept_fd);
close (listen_fd);
exit (0);
}
/* ================== end of file ======================= */

View File

@ -1,5 +1,7 @@
/********************************************************************\
* table-html.h -- print table as html *
* table-model.c -- 2D grid table object model *
* Copyright (c) 2001 Free Software Foundation *
* Author: Dave Peticolas <dave@krondo.com> *
* *
* This program is free software; you can redistribute it and/or *
* modify it under the terms of the GNU General Public License as *
@ -20,24 +22,25 @@
* *
\********************************************************************/
/*
* FILE:
* table-html.h
*
* FUNCTION:
* This header defines the HTML specific functions
* associated with the Table GUI. This is just sample code.
*
* HISTORY:
* Copyright (c) 1998 Linas Vepstas
*/
#include "config.h"
#ifndef XACC_TABLE_HTML_H
#define XACC_TABLE_HTML_H
int xaccTableDumpHTML (Table * table, int fd);
int xaccTablePrintHTML (Table * table, char *filename);
void xaccTableWebServeHTML (Table * table, unsigned short port);
#include "table-model.h"
#endif XACC_TABLE_HTML_H
TableModel *
gnc_table_model_new (void)
{
TableModel *model;
model = g_new0 (TableModel, 1);
return model;
}
void
gnc_table_model_destroy (TableModel *model)
{
if (!model) return;
g_free (model);
}

109
src/register/table-model.h Normal file
View File

@ -0,0 +1,109 @@
/********************************************************************\
* table-model.h -- 2D grid table object model *
* Copyright (c) 2001 Free Software Foundation *
* Author: Dave Peticolas <dave@krondo.com> *
* *
* 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 the Free Software Foundation; either version 2 of *
* the License, or (at your option) any later version. *
* *
* This program is distributed in the hope that it will be useful, *
* but WITHOUT ANY WARRANTY; without even the implied warranty of *
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the *
* GNU General Public License for more details. *
* *
* You should have received a copy of the GNU General Public License*
* along with this program; if not, contact: *
* *
* Free Software Foundation Voice: +1-617-542-5942 *
* 59 Temple Place - Suite 330 Fax: +1-617-542-2652 *
* Boston, MA 02111-1307, USA gnu@gnu.org *
* *
\********************************************************************/
#ifndef TABLE_MODEL_H
#define TABLE_MODEL_H
#include <glib.h>
#include "basiccell.h"
#include "register-common.h"
typedef enum
{
XACC_CELL_ALLOW_NONE = 0,
XACC_CELL_ALLOW_INPUT = 1 << 0,
XACC_CELL_ALLOW_SHADOW = 1 << 1,
XACC_CELL_ALLOW_ALL = XACC_CELL_ALLOW_INPUT | XACC_CELL_ALLOW_SHADOW,
XACC_CELL_ALLOW_EXACT_ONLY = 1 << 2
} CellIOFlags;
typedef enum
{
CELL_BORDER_LINE_NONE,
CELL_BORDER_LINE_LIGHT,
CELL_BORDER_LINE_NORMAL,
CELL_BORDER_LINE_HEAVY,
CELL_BORDER_LINE_HIGHLIGHT
} PhysicalCellBorderLineStyle;
typedef struct
{
PhysicalCellBorderLineStyle top;
PhysicalCellBorderLineStyle bottom;
PhysicalCellBorderLineStyle left;
PhysicalCellBorderLineStyle right;
} PhysicalCellBorders;
typedef const char * (*TableGetEntryHandler) (VirtualLocation virt_loc,
gboolean translate,
gboolean *conditionally_changed,
gpointer user_data);
typedef const char * (*TableGetLabelHandler) (VirtualLocation virt_loc,
gpointer user_data);
typedef CellIOFlags (*TableGetCellIOFlags) (VirtualLocation virt_loc,
gpointer user_data);
typedef guint32 (*TableGetFGColorHandler) (VirtualLocation virt_loc,
gpointer user_data);
typedef guint32 (*TableGetBGColorHandler) (VirtualLocation virt_loc,
gboolean *hatching,
gpointer user_data);
typedef void (*TableGetCellBorderHandler) (VirtualLocation virt_loc,
PhysicalCellBorders *borders,
gpointer user_data);
typedef gboolean (*TableConfirmHandler) (VirtualLocation virt_loc,
gpointer user_data);
typedef gpointer (*VirtCellDataAllocator) (void);
typedef void (*VirtCellDataDeallocator) (gpointer cell_data);
typedef void (*VirtCellDataCopy) (gpointer to, gconstpointer from);
typedef struct
{
TableGetEntryHandler entry_handler;
TableGetLabelHandler label_handler;
TableGetCellIOFlags io_flag_handler;
TableGetFGColorHandler fg_color_handler;
TableGetBGColorHandler bg_color_handler;
TableGetCellBorderHandler cell_border_handler;
TableConfirmHandler confirm_handler;
gpointer handler_user_data;
VirtCellDataAllocator cell_data_allocator;
VirtCellDataDeallocator cell_data_deallocator;
VirtCellDataCopy cell_data_copy;
} TableModel;
TableModel * gnc_table_model_new (void);
void gnc_table_model_destroy (TableModel *model);
#endif