oops, forgot to add this from peticolas '10 patches' patch

git-svn-id: svn+ssh://svn.gnucash.org/repo/gnucash/trunk@1955 57a11ea4-9604-0410-9ed3-97b8803252fd
zzzoldreleases/1.4
Linas Vepstas 27 years ago
parent d782ecc47b
commit 423da4d4a8

@ -0,0 +1,189 @@
/*
* FILE:
* table-gnome.c
*
* FUNCTION:
* Implements the infrastructure for the displayed table.
* This is the Gtk implementation;
*
* HISTORY:
* Copyright (c) 1998 Linas Vepstas
* Copyright (c) 1998 Rob Browning <rlb@cs.utexas.edu>
* Copyright (c) 1999 Heath Martin <martinh@pegasus.cc.ucf.edu>
*/
/********************************************************************\
* 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, write to the Free Software *
* Foundation, Inc., 675 Mass Ave, Cambridge, MA 02139, USA. *
\********************************************************************/
/*
TODO: fix up alignments in a UI independent manner.
deal with the fact (if necessary) that the gtk UI can't directly
"cancel" a traverse.
*/
#include <stdio.h>
#include <stdlib.h>
#include <string.h>
#include <gnome.h>
#include "cellblock.h"
#include "table-allgui.h"
#include "table-gnome.h"
#include "util.h"
#include "splitreg.h"
#include "gnome/gnucash-sheet.h"
#include "gnome/gnucash-color.h"
#include "gnome/gnucash-style.h"
static gint
register_destroy_event (GtkWidget *widget, Table *table)
{
if (table)
table->table_widget = NULL;
return FALSE;
}
void
xaccCreateTable (GtkWidget *widget, void *data)
{
SplitRegister *sr;
GnucashSheet *sheet;
GnucashRegister *greg;
Table *table;
g_return_if_fail (widget != NULL);
g_return_if_fail (GNUCASH_IS_REGISTER (widget));
g_return_if_fail (data != NULL);
sr = (SplitRegister *)data;
greg = GNUCASH_REGISTER(widget);
sheet = GNUCASH_SHEET(greg->sheet);
sheet->split_register = data;
table = sheet->table;
table->table_widget = GTK_WIDGET(sheet);
gtk_widget_ref (table->table_widget);
/* config the cell-block styles */
sheet->cursor_style[GNUCASH_CURSOR_HEADER] = gnucash_sheet_style_compile (sheet,
sr->header,
GNUCASH_CURSOR_HEADER);
sheet->cursor_style[GNUCASH_CURSOR_SINGLE] = gnucash_sheet_style_compile (sheet,
sr->single_cursor,
GNUCASH_CURSOR_SINGLE);
sheet->cursor_style[GNUCASH_CURSOR_DOUBLE] = gnucash_sheet_style_compile (sheet,
sr->double_cursor,
GNUCASH_CURSOR_DOUBLE);
sheet->cursor_style[GNUCASH_CURSOR_TRANS] = gnucash_sheet_style_compile (sheet,
sr->trans_cursor,
GNUCASH_CURSOR_TRANS);
sheet->cursor_style[GNUCASH_CURSOR_SPLIT] = gnucash_sheet_style_compile (sheet,
sr->split_cursor,
GNUCASH_CURSOR_SPLIT);
xaccRefreshHeader (table);
gnome_canvas_item_set (sheet->header_item,
"type", GNUCASH_CURSOR_HEADER,
NULL);
gnucash_sheet_table_load (sheet);
gnucash_sheet_cursor_set_from_table (sheet);
gnucash_sheet_redraw_all (sheet);
return;
}
void
xaccRefreshTableGUI (Table * table)
{
GnucashSheet *sheet;
if (!table)
return;
if (!table->table_widget)
return;
g_return_if_fail (GNUCASH_IS_SHEET (table->table_widget));
sheet = GNUCASH_SHEET(table->table_widget);
gnucash_sheet_table_load (sheet);
gnucash_sheet_redraw_all (sheet);
}
void
doRefreshCursorGUI (Table * table, CellBlock *curs, int from_row, int from_col)
{
GnucashSheet *sheet;
int phys_row, phys_col;
int to_row, to_col;
gint virt_row, virt_col;
int i,j;
if (!table)
return;
if (!table->table_widget)
return;
g_return_if_fail (GNUCASH_IS_SHEET (table->table_widget));
/* if the current cursor is undefined, there is nothing to do. */
if (!curs) return;
if ((0 > from_row) || (0 > from_col)) return;
sheet = GNUCASH_SHEET(table->table_widget);
/* compute the physical bounds of the current cursor */
virt_row = table->locators[from_row][from_col]->virt_row;
virt_col = table->locators[from_row][from_col]->virt_col;
gnucash_sheet_cursor_set_from_table (sheet);
gnucash_sheet_block_set_from_table (sheet, virt_row, virt_col);
gnucash_sheet_redraw_block (sheet, virt_row, virt_col);
}
/* FIXME: this won't really do what is expected, since
* our sheet doesn't necessarily have constant width columns.
*
*/
int
gnc_table_column_width(Table *table, const int col)
{
GnucashSheet *sheet = GNUCASH_SHEET(table->table_widget);
return 0;
}
/* ================== end of file ======================= */
/*
Local Variables:
c-basic-offset: 8
End:
*/

@ -0,0 +1,113 @@
/********************************************************************\
* 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, write to the Free Software *
* Foundation, Inc., 675 Mass Ave, Cambridge, MA 02139, USA. *
\********************************************************************/
/*
* FILE:
* table-gnome.h
*
* FUNCTION:
* This file defines the GNOME-specific GUI portions of the Table object.
*
* HISTORY:
* Copyright (c) 1998 Linas Vepstas
* Copyright (c) 1998 Rob Browning <rlb@cs.utexas.edu>
*/
#ifndef __XACC_TABLE_GNOME_H__
#define __XACC_TABLE_GNOME_H__
#include <gnome.h>
/* We use C not C++ in this project, but we none-the-less need
* the general mechanism of inheritance. The three #defines
* below implement that.
*
* the TABLE_PRIVATE_DATA declaration should be thought of as a
* "derived class" of which Table is the base class. This
* define is included as a part of the definition of the Table
* structure in table-allgui.h
*
* The TABLE_PRIVATE_DATA_INIT and DESTROY are the constructors
* and destructors, respectively, for this derived class.
* These are included in the xaccTableInit() and the xaccTableDestroy()
* routines in the file table-allgui.c, where they are called,
* respectively, last, and first, just as "real" constructors &
* destructors would be
TODO:
- Still need prev_entry_text?
*/
/* TABLE_PRIVATE_DATA:in_between_cells is used to detect real user
cell changes. Otherwise we get a bunch of spurious changed,
insert_text, and delete_text events whenever the user clicks on a
new cell as the engine updates all the cell contents (in the
current cursor?)
This may not be strictly necessary, as the redundant "changes"
might not hurt anything, but for now I'm going to do this until I
figure out what's going on. At the very least, this will be more
efficient. I don't know yet if it's at all dangerous, but so far I
don't suspect it to be. */
#define TABLE_PRIVATE_DATA \
/* Gtk-only private table members */ \
GtkWidget *table_widget; /* the Sheet */ \
gint insert_signal_tag; \
gint delete_signal_tag; \
gint entry_needs_reconnect; \
/* see comments above */ \
gboolean in_between_cells; \
\
GtkWidget *next_tab_group; /* where to traverse in the end */ \
#define TABLE_PRIVATE_DATA_INIT(table) { \
table->table_widget = NULL; \
\
table->in_between_cells = TRUE; \
\
table->next_tab_group = 0; \
table->insert_signal_tag = -1; \
table->delete_signal_tag = -1; \
}
#define TABLE_PRIVATE_DATA_DESTROY(table) { \
\
/* Let GTK know we're finished with this */ \
if(table->table_widget) gtk_widget_unref(table->table_widget); \
table->table_widget = NULL; \
\
}
/* nothing to resize */
#define TABLE_PRIVATE_DATA_RESIZE(a,b,c,d,e)
typedef struct _Table Table;
void xaccCreateTable (GtkWidget *, void *);
void doRefreshCursorGUI (Table *, CellBlock *, int, int);
void xaccRefreshTableGUI (Table *);
#endif __XACC_TABLE_GNOME_H__
/* ================== end of file ======================= */
Loading…
Cancel
Save