Simplify register sizing.

git-svn-id: svn+ssh://svn.gnucash.org/repo/gnucash/trunk@2904 57a11ea4-9604-0410-9ed3-97b8803252fd
This commit is contained in:
Dave Peticolas 2000-09-20 08:15:27 +00:00
parent 088a63e352
commit 9a6a43197c
13 changed files with 409 additions and 1158 deletions

View File

@ -198,7 +198,7 @@ static char account_separator = ':';
static SRReverseBalanceCallback reverse_balance = NULL;
/* The copied split or transaction, if any */
static CursorType copied_type = CURSOR_NONE;
static CursorClass copied_class = CURSOR_NONE;
static SCM copied_item = SCM_UNDEFINED;
static GUID copied_leader_guid;
@ -814,7 +814,7 @@ LedgerAutoCompletion(SplitRegister *reg, gncTableTraversalDir dir,
Split *blank_split = xaccSplitLookup(&info->blank_split_guid);
Transaction *pending_trans = xaccTransLookup(&info->pending_trans_guid);
PhysicalLocation new_phys_loc;
CursorType cursor_type;
CursorClass cursor_class;
CellType cell_type;
Transaction *trans;
guint32 changed;
@ -830,11 +830,11 @@ LedgerAutoCompletion(SplitRegister *reg, gncTableTraversalDir dir,
if (trans == NULL)
return;
cursor_type = xaccSplitRegisterGetCurrentCursorType(reg);
cursor_class = xaccSplitRegisterGetCurrentCursorClass(reg);
cell_type = xaccSplitRegisterGetCurrentCellType(reg);
changed = xaccSplitRegisterGetChangeFlag(reg);
switch (cursor_type)
switch (cursor_class)
{
case CURSOR_TRANS: {
Transaction *auto_trans;
@ -1278,7 +1278,7 @@ xaccSRGetTrans (SplitRegister *reg, PhysicalLocation phys_loc)
static Split *
xaccSRGetTransSplit (SplitRegister *reg, PhysicalLocation phys_loc)
{
CursorType cursor_type;
CursorClass cursor_class;
VirtualCellLocation vcell_loc;
PhysicalCell *pcell;
@ -1293,9 +1293,9 @@ xaccSRGetTransSplit (SplitRegister *reg, PhysicalLocation phys_loc)
while (TRUE)
{
cursor_type = xaccSplitRegisterGetCursorType (reg, vcell_loc);
cursor_class = xaccSplitRegisterGetCursorClass (reg, vcell_loc);
if (cursor_type == CURSOR_TRANS)
if (cursor_class == CURSOR_TRANS)
return gnc_table_get_user_data_virtual (reg->table, vcell_loc);
vcell_loc.virt_row --;
@ -1314,7 +1314,7 @@ xaccSRGetCurrentTransSplit (SplitRegister *reg)
{
Split *split;
PhysicalCell *pcell;
CursorType cursor_type;
CursorClass cursor_class;
PhysicalLocation phys_loc;
VirtualCellLocation vcell_loc;
@ -1322,8 +1322,8 @@ xaccSRGetCurrentTransSplit (SplitRegister *reg)
return NULL;
split = xaccSRGetCurrentSplit (reg);
cursor_type = xaccSplitRegisterGetCurrentCursorType (reg);
if (cursor_type == CURSOR_TRANS)
cursor_class = xaccSplitRegisterGetCurrentCursorClass (reg);
if (cursor_class == CURSOR_TRANS)
return split;
/* Split is not associated with a transaction cursor. Assume it is a
@ -1346,9 +1346,9 @@ xaccSRGetCurrentTransSplit (SplitRegister *reg)
return NULL;
}
cursor_type = xaccSplitRegisterGetCursorType (reg, vcell_loc);
cursor_class = xaccSplitRegisterGetCursorClass (reg, vcell_loc);
if (cursor_type == CURSOR_TRANS)
if (cursor_class == CURSOR_TRANS)
return gnc_table_get_user_data_virtual (reg->table, vcell_loc);
}
}
@ -1459,7 +1459,7 @@ xaccSRGetSplitAmountVirtLoc (SplitRegister *reg, Split *split,
VirtualLocation *virt_loc)
{
VirtualLocation v_loc;
CursorType cursor_type;
CursorClass cursor_class;
PhysicalLocation p_loc;
PhysicalCell *pcell;
CellType cell_type;
@ -1468,13 +1468,13 @@ xaccSRGetSplitAmountVirtLoc (SplitRegister *reg, Split *split,
if (!xaccSRGetSplitVirtLoc (reg, split, &v_loc.vcell_loc))
return FALSE;
cursor_type = xaccSplitRegisterGetCursorType (reg, v_loc.vcell_loc);
cursor_class = xaccSplitRegisterGetCursorClass (reg, v_loc.vcell_loc);
value = xaccSplitGetValue (split);
if (DEQ (value, 0.0))
value = 0.0;
switch (cursor_type)
switch (cursor_class)
{
case CURSOR_TRANS:
cell_type = (value >= 0.0) ? DEBT_CELL : CRED_CELL;
@ -1513,7 +1513,7 @@ xaccSRGetTransSplitVirtLoc (SplitRegister *reg, Transaction *trans,
gboolean found_trans = FALSE;
gboolean found_trans_split = FALSE;
gboolean found_something = FALSE;
CursorType cursor_type;
CursorClass cursor_class;
int v_row, v_col;
Transaction *t;
Split *s;
@ -1526,12 +1526,12 @@ xaccSRGetTransSplitVirtLoc (SplitRegister *reg, Transaction *trans,
s = gnc_table_get_user_data_virtual (table, vc_loc);
t = xaccSplitGetParent(s);
cursor_type = xaccSplitRegisterGetCursorType(reg, vc_loc);
cursor_class = xaccSplitRegisterGetCursorClass(reg, vc_loc);
if (t == trans)
found_trans = TRUE;
if ((cursor_type == CURSOR_TRANS) && (s == trans_split))
if ((cursor_class == CURSOR_TRANS) && (s == trans_split))
found_trans_split = TRUE;
if (found_trans && (s == split))
@ -1561,7 +1561,7 @@ xaccSRDuplicateCurrent (SplitRegister *reg)
{
SRInfo *info = xaccSRGetInfo(reg);
Split *blank_split = xaccSplitLookup(&info->blank_split_guid);
CursorType cursor_type;
CursorClass cursor_class;
Transaction *trans;
Split *return_split;
Split *trans_split;
@ -1576,14 +1576,14 @@ xaccSRDuplicateCurrent (SplitRegister *reg)
if (trans == NULL)
return NULL;
cursor_type = xaccSplitRegisterGetCurrentCursorType(reg);
cursor_class = xaccSplitRegisterGetCurrentCursorClass (reg);
/* Can't do anything with this. */
if (cursor_type == CURSOR_NONE)
if (cursor_class == CURSOR_NONE)
return NULL;
/* This shouldn't happen, but be paranoid. */
if ((split == NULL) && (cursor_type == CURSOR_TRANS))
if ((split == NULL) && (cursor_class == CURSOR_TRANS))
return NULL;
changed = xaccSplitRegisterGetChangeFlag(reg);
@ -1618,7 +1618,7 @@ xaccSRDuplicateCurrent (SplitRegister *reg)
/* Ok, we are now ready to make the copy. */
if (cursor_type == CURSOR_SPLIT)
if (cursor_class == CURSOR_SPLIT)
{
Split *new_split;
@ -1686,7 +1686,7 @@ xaccSRCopyCurrent (SplitRegister *reg)
{
SRInfo *info = xaccSRGetInfo(reg);
Split *blank_split = xaccSplitLookup(&info->blank_split_guid);
CursorType cursor_type;
CursorClass cursor_class;
Transaction *trans;
guint32 changed;
Split *split;
@ -1699,14 +1699,14 @@ xaccSRCopyCurrent (SplitRegister *reg)
if (trans == NULL)
return;
cursor_type = xaccSplitRegisterGetCurrentCursorType(reg);
cursor_class = xaccSplitRegisterGetCurrentCursorClass (reg);
/* Can't do anything with this. */
if (cursor_type == CURSOR_NONE)
if (cursor_class == CURSOR_NONE)
return;
/* This shouldn't happen, but be paranoid. */
if ((split == NULL) && (cursor_type == CURSOR_TRANS))
if ((split == NULL) && (cursor_class == CURSOR_TRANS))
return;
changed = xaccSplitRegisterGetChangeFlag(reg);
@ -1717,7 +1717,7 @@ xaccSRCopyCurrent (SplitRegister *reg)
/* Ok, we are now ready to make the copy. */
if (cursor_type == CURSOR_SPLIT)
if (cursor_class == CURSOR_SPLIT)
{
/* We are on a split in an expanded transaction. Just copy the split. */
new_item = gnc_copy_split(split);
@ -1765,7 +1765,7 @@ xaccSRCopyCurrent (SplitRegister *reg)
copied_item = new_item;
scm_protect_object(copied_item);
copied_type = cursor_type;
copied_class = cursor_class;
}
/* ======================================================== */
@ -1775,7 +1775,7 @@ xaccSRCutCurrent (SplitRegister *reg)
{
SRInfo *info = xaccSRGetInfo(reg);
Split *blank_split = xaccSplitLookup(&info->blank_split_guid);
CursorType cursor_type;
CursorClass cursor_class;
Transaction *trans;
guint32 changed;
Split *split;
@ -1787,14 +1787,14 @@ xaccSRCutCurrent (SplitRegister *reg)
if (trans == NULL)
return;
cursor_type = xaccSplitRegisterGetCurrentCursorType(reg);
cursor_class = xaccSplitRegisterGetCurrentCursorClass (reg);
/* Can't do anything with this. */
if (cursor_type == CURSOR_NONE)
if (cursor_class == CURSOR_NONE)
return;
/* This shouldn't happen, but be paranoid. */
if ((split == NULL) && (cursor_type == CURSOR_TRANS))
if ((split == NULL) && (cursor_class == CURSOR_TRANS))
return;
changed = xaccSplitRegisterGetChangeFlag(reg);
@ -1805,7 +1805,7 @@ xaccSRCutCurrent (SplitRegister *reg)
xaccSRCopyCurrent(reg);
if (cursor_type == CURSOR_SPLIT)
if (cursor_class == CURSOR_SPLIT)
xaccSRDeleteCurrentSplit(reg);
else
xaccSRDeleteCurrentTrans(reg);
@ -1819,12 +1819,12 @@ xaccSRPasteCurrent (SplitRegister *reg)
SRInfo *info = xaccSRGetInfo(reg);
Split *blank_split = xaccSplitLookup(&info->blank_split_guid);
GList *accounts = NULL;
CursorType cursor_type;
CursorClass cursor_class;
Transaction *trans;
Split *trans_split;
Split *split;
if (copied_type == CURSOR_NONE)
if (copied_class == CURSOR_NONE)
return;
split = xaccSRGetCurrentSplit(reg);
@ -1836,18 +1836,18 @@ xaccSRPasteCurrent (SplitRegister *reg)
if (trans == NULL)
return;
cursor_type = xaccSplitRegisterGetCurrentCursorType(reg);
cursor_class = xaccSplitRegisterGetCurrentCursorClass (reg);
/* Can't do anything with this. */
if (cursor_type == CURSOR_NONE)
if (cursor_class == CURSOR_NONE)
return;
/* This shouldn't happen, but be paranoid. */
if ((split == NULL) && (cursor_type == CURSOR_TRANS))
if ((split == NULL) && (cursor_class == CURSOR_TRANS))
return;
if (cursor_type == CURSOR_SPLIT) {
if (copied_type == CURSOR_TRANS)
if (cursor_class == CURSOR_SPLIT) {
if (copied_class == CURSOR_TRANS)
return;
accounts = gnc_trans_prepend_account_list(trans, NULL);
@ -1869,7 +1869,7 @@ xaccSRPasteCurrent (SplitRegister *reg)
int split_index;
int num_splits;
if (copied_type == CURSOR_SPLIT)
if (copied_class == CURSOR_SPLIT)
return;
accounts = gnc_trans_prepend_account_list(trans, NULL);

View File

@ -2295,7 +2295,7 @@ deleteCB(GtkWidget *widget, gpointer data)
{
RegWindow *regData = data;
SplitRegisterStyle style;
CursorType cursor_type;
CursorClass cursor_class;
Transaction *trans;
char *buf = NULL;
Split *split;
@ -2311,7 +2311,8 @@ deleteCB(GtkWidget *widget, gpointer data)
trans = xaccSplitGetParent(split);
style = regData->ledger->ledger->style;
cursor_type = xaccSplitRegisterGetCurrentCursorType(regData->ledger->ledger);
cursor_class =
xaccSplitRegisterGetCurrentCursorClass(regData->ledger->ledger);
/* Deleting the blank split just cancels */
{
@ -2324,11 +2325,11 @@ deleteCB(GtkWidget *widget, gpointer data)
}
}
if (cursor_type == CURSOR_NONE)
if (cursor_class == CURSOR_NONE)
return;
/* On a split cursor, just delete the one split. */
if (cursor_type == CURSOR_SPLIT)
if (cursor_class == CURSOR_SPLIT)
{
/* ask for user confirmation before performing permanent damage */
buf = g_strdup_printf(TRANS_DEL_MSG, xaccSplitGetMemo(split),
@ -2346,7 +2347,7 @@ deleteCB(GtkWidget *widget, gpointer data)
return;
}
assert(cursor_type == CURSOR_TRANS);
assert(cursor_class == CURSOR_TRANS);
/* On a transaction cursor with 2 or fewer splits in single or double
* mode, we just delete the whole transaction, kerblooie */

View File

@ -712,7 +712,7 @@
/* register sample strings */
#define DATE_CELL_SAMPLE _("sample:12/12/2000"+7)
#define NUM_CELL_SAMPLE _("sample:999"+7)
#define NUM_CELL_SAMPLE _("sample:99999"+7)
#define ACTN_CELL_SAMPLE TRANSFER_STR
#define XFRM_CELL_SAMPLE _("sample:Expenses:Automobile:Gasoline"+7)
#define MXFRM_CELL_SAMPLE XFRM_CELL_SAMPLE
@ -720,7 +720,7 @@
#define DESC_CELL_SAMPLE _("sample:Description of a transaction"+7)
#define MEMO_CELL_SAMPLE _("sample:Memo field sample text string"+7)
#define RECN_CELL_SAMPLE RECONCILE_ABBREV
#define DEBT_CELL_SAMPLE _("sample:99,999.00"+7)
#define DEBT_CELL_SAMPLE _("sample:999,999.000"+7)
#define CRED_CELL_SAMPLE DEBT_CELL_SAMPLE
#define NDEBT_CELL_SAMPLE DEBT_CELL_SAMPLE
#define NCRED_CELL_SAMPLE DEBT_CELL_SAMPLE

View File

@ -61,7 +61,8 @@ gnc_cellblock_cell_new (void)
cb_cell->cell_type = -1;
cb_cell->alignment = CELL_ALIGN_LEFT;
cb_cell->resizable = TRUE;
cb_cell->expandable = FALSE;
cb_cell->span = FALSE;
return cb_cell;
}

View File

@ -78,9 +78,10 @@ typedef struct
short cell_type; /* cell type from splitreg.h */
/* GUI layout information */
char *sample_text; /* sample text for sizing purposes */
char *sample_text; /* sample text for sizing purposes */
CellAlignment alignment;
gboolean resizable;
gboolean expandable; /* can fill with extra space */
gboolean span; /* can span multiple columns */
} CellBlockCell;
typedef struct

View File

@ -73,7 +73,7 @@ gnucash_header_draw (GnomeCanvasItem *item, GdkDrawable *drawable,
GdkFont *font;
CellStyle *cs;
header_style = header->sheet->cursor_style[GNUCASH_CURSOR_HEADER];
header_style = header->sheet->cursor_styles[GNUCASH_CURSOR_HEADER];
cs = gnucash_style_get_cell_style (header_style, 0, 0);
@ -237,13 +237,13 @@ gnucash_header_reconfigure (GnucashHeader *header)
g_return_if_fail (header != NULL);
g_return_if_fail (GNUCASH_IS_HEADER (header));
canvas = GNOME_CANVAS_ITEM(header)->canvas;
widget = GTK_WIDGET (header->sheet);
sheet = GNUCASH_SHEET(header->sheet);
old_style = header->style;
header->style = header->sheet->cursor_style[header->type];
header->style = header->sheet->cursor_styles[header->type];
if (header->style == NULL)
return;
@ -255,7 +255,7 @@ gnucash_header_reconfigure (GnucashHeader *header)
sheet->width = header->style->dimensions->width;
w = MAX (widget->allocation.width, header->style->dimensions->width);
w = header->style->dimensions->width;
h = header->style->dimensions->height;
if (header->height != h || header->width != w ||
@ -265,13 +265,13 @@ gnucash_header_reconfigure (GnucashHeader *header)
gnome_canvas_set_scroll_region(GNOME_CANVAS(canvas),
0, 0, w, h);
gtk_widget_set_usize (GTK_WIDGET(canvas), -1, h);
gnucash_header_request_redraw (header);
}
}
static double
gnucash_header_point (GnomeCanvasItem *item,
double x, double y, int cx, int cy,
@ -346,17 +346,17 @@ gnucash_header_auto_resize_column (GnucashHeader *header, gint col)
int width = gnucash_sheet_col_max_width (sheet, 0, col);
gnucash_sheet_style_set_col_width (sheet, header->style,
col, width, FALSE);
gtk_window_set_default_size(GTK_WINDOW(sheet->window), 0, 0);
gnucash_sheet_set_col_width (sheet, col, width);
gnucash_cursor_configure (GNUCASH_CURSOR(sheet->cursor));
item_edit_configure (ITEM_EDIT(sheet->item_editor));
gnucash_sheet_update_adjustments (sheet);
gnucash_header_request_redraw (header);
gnucash_header_reconfigure (header);
gnucash_sheet_set_scroll_region (sheet);
gnucash_sheet_update_adjustments (sheet);
gnucash_sheet_redraw_all (sheet);
}
@ -453,18 +453,18 @@ gnucash_header_event (GnomeCanvasItem *item, GdkEvent *event)
event->button.time);
header->needs_ungrab = FALSE;
gnucash_sheet_style_set_col_width (sheet,
header->style,
header->resize_col, header->resize_col_width, FALSE);
gnucash_sheet_set_col_width (sheet,
header->resize_col, header->resize_col_width);
gtk_window_set_default_size(GTK_WINDOW(sheet->window), 0, 0);
gnucash_cursor_configure (GNUCASH_CURSOR(sheet->cursor));
item_edit_configure (ITEM_EDIT(sheet->item_editor));
gnucash_header_reconfigure (header);
gnucash_sheet_set_scroll_region (sheet);
gnucash_sheet_update_adjustments (sheet);
gnucash_header_request_redraw (header);
gnucash_sheet_redraw_all (sheet);
}
header->in_resize = FALSE;
@ -494,7 +494,8 @@ gnucash_header_event (GnomeCanvasItem *item, GdkEvent *event)
header->in_resize = FALSE;
header->resize_col = -1;
if (header->needs_ungrab) {
gnome_canvas_item_ungrab (item, event->button.time);
gnome_canvas_item_ungrab (item,
event->button.time);
header->needs_ungrab = FALSE;
}
@ -616,7 +617,7 @@ static void
gnucash_header_realized (GtkWidget *widget, gpointer data)
{
gdk_window_set_back_pixmap (GTK_LAYOUT (widget)->bin_window,
NULL, FALSE);
NULL, FALSE);
}
@ -645,6 +646,7 @@ gnucash_header_new (GnucashSheet *sheet)
sheet->header_item = item;
gtk_widget_show (canvas);
return canvas;
}

View File

@ -73,6 +73,18 @@ static GtkTableClass *register_parent_class;
static guint register_signals[LAST_SIGNAL];
void
gnucash_sheet_set_cursor (GnucashSheet *sheet, CellBlock *cursor,
GNCCursorType cursor_type)
{
g_return_if_fail (sheet != NULL);
g_return_if_fail (GNUCASH_IS_SHEET (sheet));
g_return_if_fail (cursor_type >= 0);
g_return_if_fail (cursor_type < GNUCASH_NUM_CURSORS);
sheet->cursors[cursor_type] = cursor;
}
void
gnucash_register_set_initial_rows(guint num_rows)
{
@ -704,8 +716,8 @@ gnucash_sheet_destroy (GtkObject *object)
g_table_destroy (sheet->blocks);
sheet->blocks = NULL;
for (i = GNUCASH_CURSOR_HEADER; i < GNUCASH_CURSOR_LAST; i++)
gnucash_sheet_style_destroy(sheet, sheet->cursor_style[i]);
for (i = GNUCASH_CURSOR_HEADER; i < GNUCASH_NUM_CURSORS; i++)
gnucash_sheet_style_destroy(sheet, sheet->cursor_styles[i]);
g_hash_table_destroy (sheet->layout_info_hash_table);
g_hash_table_destroy (sheet->dimensions_hash_table);
@ -765,20 +777,19 @@ compute_optimal_width (GnucashSheet *sheet)
{
SheetBlockStyle *style;
if ((sheet == NULL) || (sheet->cursor_style == NULL))
if ((sheet == NULL) ||
(sheet->cursor_styles[GNUCASH_CURSOR_HEADER] == NULL))
return DEFAULT_REGISTER_WIDTH;
#if 0
if (sheet->default_width >= 0)
return sheet->default_width;
#endif
style = sheet->cursor_style[GNUCASH_CURSOR_HEADER];
if (sheet->window_width >= 0)
return sheet->window_width;
style = sheet->cursor_styles[GNUCASH_CURSOR_HEADER];
if ((style == NULL) || (style->dimensions == NULL))
return DEFAULT_REGISTER_WIDTH;
sheet->default_width = style->dimensions->width;
return sheet->default_width;
return style->dimensions->width;
}
@ -790,22 +801,22 @@ compute_optimal_height (GnucashSheet *sheet)
CellDimensions *cd;
gint row_height;
if (sheet->default_height >= 0)
return sheet->default_height;
if (sheet->window_height >= 0)
return sheet->window_height;
if ((sheet == NULL) || (sheet->cursor_style == NULL))
if ((sheet == NULL) ||
(sheet->cursor_styles[GNUCASH_CURSOR_HEADER] == NULL))
return DEFAULT_REGISTER_HEIGHT;
style = sheet->cursor_style[GNUCASH_CURSOR_HEADER];
style = sheet->cursor_styles[GNUCASH_CURSOR_HEADER];
cd = gnucash_style_get_cell_dimensions (style, 0, 0);
if (cd == NULL)
return DEFAULT_REGISTER_HEIGHT;
row_height = cd->pixel_height;
sheet->default_height = row_height * gnucash_register_initial_rows;
return sheet->default_height;
return row_height * gnucash_register_initial_rows;
}
@ -818,7 +829,6 @@ gnucash_sheet_size_request (GtkWidget *widget, GtkRequisition *requisition)
requisition->height = compute_optimal_height (sheet);
}
const char *
gnucash_sheet_modify_current_cell(GnucashSheet *sheet, const gchar *new_text)
{
@ -1089,27 +1099,26 @@ static void
gnucash_sheet_size_allocate (GtkWidget *widget, GtkAllocation *allocation)
{
GnucashSheet *sheet = GNUCASH_SHEET(widget);
gint i;
if (GTK_WIDGET_CLASS(sheet_parent_class)->size_allocate)
(*GTK_WIDGET_CLASS (sheet_parent_class)->size_allocate)
(widget, allocation);
if (allocation->height != sheet->window_height ||
allocation->width != sheet->window_width) {
sheet->window_height = allocation->height;
sheet->window_width = allocation->width;
for (i = GNUCASH_CURSOR_HEADER; i < GNUCASH_CURSOR_LAST; i++)
gnucash_sheet_style_set_dimensions(sheet,
sheet->cursor_style[i], allocation->width);
gnucash_cursor_configure (GNUCASH_CURSOR (sheet->cursor));
gnucash_header_reconfigure (GNUCASH_HEADER(sheet->header_item));
gnucash_sheet_set_scroll_region (sheet);
item_edit_configure (ITEM_EDIT(sheet->item_editor));
gnucash_sheet_update_adjustments (sheet);
}
if (allocation->height == sheet->window_height &&
allocation->width == sheet->window_width)
return;
sheet->window_height = allocation->height;
sheet->window_width = allocation->width;
gnucash_sheet_styles_set_dimensions(sheet, allocation->width);
gnucash_cursor_configure (GNUCASH_CURSOR (sheet->cursor));
gnucash_header_reconfigure (GNUCASH_HEADER(sheet->header_item));
gnucash_sheet_set_scroll_region (sheet);
item_edit_configure (ITEM_EDIT(sheet->item_editor));
gnucash_sheet_update_adjustments (sheet);
}
@ -2363,8 +2372,8 @@ gnucash_sheet_init (GnucashSheet *sheet)
sheet->editing = FALSE;
sheet->button = 0;
sheet->grabbed = FALSE;
sheet->default_width = -1;
sheet->default_height = -1;
sheet->window_width = -1;
sheet->window_height = -1;
sheet->width = 0;
sheet->height = 0;
sheet->smooth_scroll = TRUE;

View File

@ -42,14 +42,15 @@
#define GNUCASH_IS_SHEET(o) (GTK_CHECK_TYPE((o), GNUCASH_TYPE_SHEET))
enum {
typedef enum
{
GNUCASH_CURSOR_HEADER = 0,
GNUCASH_CURSOR_SINGLE,
GNUCASH_CURSOR_DOUBLE,
GNUCASH_CURSOR_TRANS,
GNUCASH_CURSOR_SPLIT,
GNUCASH_CURSOR_LAST,
};
GNUCASH_NUM_CURSORS
} GNCCursorType;
typedef enum {
@ -98,7 +99,8 @@ typedef struct {
GnomeCanvasItem *cursor;
GnomeCanvasItem *grid;
SheetBlockStyle *cursor_style[GNUCASH_CURSOR_LAST];
CellBlock *cursors[GNUCASH_NUM_CURSORS];
SheetBlockStyle *cursor_styles[GNUCASH_NUM_CURSORS];
/* some style information associated to a sheet */
GHashTable *layout_info_hash_table;
@ -207,6 +209,9 @@ void gnucash_sheet_block_pixel_origin (GnucashSheet *sheet,
void gnucash_sheet_make_cell_visible (GnucashSheet *sheet,
VirtualLocation virt_loc);
void gnucash_sheet_set_cursor (GnucashSheet *sheet, CellBlock *cursor,
GNCCursorType cursor_type);
void gnucash_sheet_update_adjustments (GnucashSheet *sheet);
void gnucash_register_goto_virt_cell (GnucashRegister *reg,

File diff suppressed because it is too large Load Diff

View File

@ -66,16 +66,16 @@ typedef struct
int border;
} CellStyle;
typedef struct _CellLayoutInfo CellLayoutInfo;
struct _SheetBlockStyle
{
CellBlock * cursor;
gint nrows;
gint ncols;
gint reg_type;
gint cursor_type;
CellLayoutInfo *layout_info;
BlockDimensions *dimensions;
GTable *cell_styles;
@ -104,25 +104,17 @@ CellDimensions * gnucash_style_get_cell_dimensions (SheetBlockStyle *style,
CellStyle * gnucash_style_get_cell_style (SheetBlockStyle *style,
int row, int col);
void gnucash_sheet_style_set_col_width (GnucashSheet *sheet,
SheetBlockStyle *style,
int col, int width, int same_size);
void gnucash_sheet_set_col_width (GnucashSheet *sheet, int col, int width);
gint gnucash_style_row_width(SheetBlockStyle *style, int row);
void gnucash_sheet_style_set_dimensions (GnucashSheet *sheet,
SheetBlockStyle *style, int width);
void gnucash_sheet_styles_set_dimensions (GnucashSheet *sheet, int width);
void gnucash_sheet_style_destroy (GnucashSheet *sheet, SheetBlockStyle *style);
SheetBlockStyle * gnucash_sheet_style_compile (GnucashSheet *sheet,
CellBlock *cellblock,
gint cursor_type);
void gnucash_sheet_compile_styles (GnucashSheet *sheet);
void gnucash_sheet_style_recompile (SheetBlockStyle *style,
CellBlock *cellblock,
SplitRegister *sr,
gint cursor_type);
void gnucash_sheet_styles_recompile (GnucashSheet *sheet);
SheetBlockStyle *gnucash_sheet_get_style (GnucashSheet *sheet,
VirtualCellLocation vcell_loc);

View File

@ -294,29 +294,32 @@ configAction (SplitRegister *reg)
/* ============================================== */
#define SET(NAME,col,row,handler) \
{ \
BasicCell *hcell; \
hcell = reg->header_label_cells[NAME##_CELL]; \
\
if ((0<=row) && (0<=col)) { \
CellBlockCell *cb_cell; \
\
cb_cell = gnc_cellblock_get_cell (curs, row, col); \
\
cb_cell->cell = (handler); \
cb_cell->cell_type = NAME##_CELL; \
cb_cell->sample_text = g_strdup (NAME##_CELL_SAMPLE); \
cb_cell->alignment = NAME##_CELL_ALIGN; \
cb_cell->resizable = (cb_cell->cell != \
(BasicCell *) reg->recnCell); \
\
cb_cell = gnc_cellblock_get_cell (header, row, col); \
if (cb_cell) { \
cb_cell->alignment = NAME##_CELL_ALIGN; \
cb_cell->cell = hcell; \
} \
} \
#define SET(NAME,col,row,handler) \
{ \
BasicCell *hcell; \
hcell = reg->header_label_cells[NAME##_CELL]; \
\
if ((0<=row) && (0<=col)) { \
CellBlockCell *cb_cell; \
\
cb_cell = gnc_cellblock_get_cell (curs, row, col); \
\
cb_cell->cell = (handler); \
cb_cell->cell_type = NAME##_CELL; \
cb_cell->sample_text = g_strdup (NAME##_CELL_SAMPLE); \
cb_cell->alignment = NAME##_CELL_ALIGN; \
cb_cell->expandable = ((handler) == (BasicCell *) reg->descCell); \
cb_cell->span = ((handler) == (BasicCell *) reg->memoCell); \
\
cb_cell = gnc_cellblock_get_cell (header, row, col); \
if (cb_cell) { \
cb_cell->cell = hcell; \
cb_cell->sample_text = g_strdup (NAME##_CELL_SAMPLE); \
cb_cell->alignment = NAME##_CELL_ALIGN; \
cb_cell->expandable = ((handler) == (BasicCell *) reg->descCell); \
cb_cell->span = ((handler) == (BasicCell *) reg->memoCell); \
} \
} \
}
/* SET_CELL macro initializes cells in the register */
@ -1333,8 +1336,8 @@ xaccSplitRegisterClearChangeFlag (SplitRegister *reg)
/* ============================================== */
static CursorType
sr_cellblock_cursor_type(SplitRegister *reg, CellBlock *cursor)
static CursorClass
sr_cellblock_cursor_class(SplitRegister *reg, CellBlock *cursor)
{
if (cursor == NULL)
return CURSOR_NONE;
@ -1352,8 +1355,8 @@ sr_cellblock_cursor_type(SplitRegister *reg, CellBlock *cursor)
/* ============================================== */
CursorType
xaccSplitRegisterGetCurrentCursorType (SplitRegister *reg)
CursorClass
xaccSplitRegisterGetCurrentCursorClass (SplitRegister *reg)
{
Table *table;
@ -1364,14 +1367,14 @@ xaccSplitRegisterGetCurrentCursorType (SplitRegister *reg)
if (table == NULL)
return CURSOR_NONE;
return sr_cellblock_cursor_type(reg, table->current_cursor);
return sr_cellblock_cursor_class(reg, table->current_cursor);
}
/* ============================================== */
CursorType
xaccSplitRegisterGetCursorType (SplitRegister *reg,
VirtualCellLocation vcell_loc)
CursorClass
xaccSplitRegisterGetCursorClass (SplitRegister *reg,
VirtualCellLocation vcell_loc)
{
VirtualCell *vcell;
Table *table;
@ -1387,7 +1390,7 @@ xaccSplitRegisterGetCursorType (SplitRegister *reg,
if (vcell == NULL)
return CURSOR_NONE;
return sr_cellblock_cursor_type(reg, vcell->cellblock);
return sr_cellblock_cursor_class(reg, vcell->cellblock);
}
/* ============================================== */

View File

@ -152,7 +152,7 @@ typedef enum
CURSOR_SPLIT,
CURSOR_TRANS,
CURSOR_NONE
} CursorType;
} CursorClass;
/* The value of NUM_CELLS should be larger than the number of
* cells defined in the structure below!
@ -270,10 +270,10 @@ guint32 xaccSplitRegisterGetChangeFlag (SplitRegister *reg);
void xaccSplitRegisterClearChangeFlag (SplitRegister *reg);
/* Returns the type of the current cursor */
CursorType xaccSplitRegisterGetCurrentCursorType (SplitRegister *reg);
CursorClass xaccSplitRegisterGetCurrentCursorClass (SplitRegister *reg);
/* Returns the type of the cursor at the given virtual row and column. */
CursorType xaccSplitRegisterGetCursorType (SplitRegister *reg,
CursorClass xaccSplitRegisterGetCursorClass (SplitRegister *reg,
VirtualCellLocation vcell_loc);
/* Returns the type of the current cell */

View File

@ -92,30 +92,17 @@ gnc_table_init_gui (gncUIWidget widget, void *data)
/* config the cell-block styles */
sheet->cursor_style[GNUCASH_CURSOR_HEADER] =
gnucash_sheet_style_compile (sheet,
sr->header,
GNUCASH_CURSOR_HEADER);
gnucash_sheet_set_cursor (sheet, sr->header, GNUCASH_CURSOR_HEADER);
gnucash_sheet_set_cursor (sheet, sr->single_cursor,
GNUCASH_CURSOR_SINGLE);
gnucash_sheet_set_cursor (sheet, sr->double_cursor,
GNUCASH_CURSOR_DOUBLE);
gnucash_sheet_set_cursor (sheet, sr->trans_cursor,
GNUCASH_CURSOR_TRANS);
gnucash_sheet_set_cursor (sheet, sr->split_cursor,
GNUCASH_CURSOR_SPLIT);
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);
gnucash_sheet_compile_styles (sheet);
gnc_table_refresh_header (table);
@ -124,13 +111,10 @@ gnc_table_init_gui (gncUIWidget widget, void *data)
gnucash_sheet_redraw_all (sheet);
}
void
gnc_table_refresh_gui (Table * table)
{
GnucashSheet *sheet;
SheetBlockStyle *style;
SplitRegister *sr;
if (!table)
return;
@ -140,30 +124,9 @@ gnc_table_refresh_gui (Table * table)
g_return_if_fail (GNUCASH_IS_SHEET (table->ui_data));
sheet = GNUCASH_SHEET(table->ui_data);
sr = sheet->split_register;
style = sheet->cursor_style[GNUCASH_CURSOR_HEADER];
gnucash_sheet_style_recompile (style, sr->header, sr,
GNUCASH_CURSOR_HEADER);
style = sheet->cursor_style[GNUCASH_CURSOR_SINGLE];
gnucash_sheet_style_recompile (style, sr->single_cursor,
sr, GNUCASH_CURSOR_SINGLE);
style = sheet->cursor_style[GNUCASH_CURSOR_DOUBLE];
gnucash_sheet_style_recompile (style, sr->double_cursor,
sr, GNUCASH_CURSOR_DOUBLE);
style = sheet->cursor_style[GNUCASH_CURSOR_TRANS];
gnucash_sheet_style_recompile (style, sr->trans_cursor,
sr, GNUCASH_CURSOR_TRANS);
style = sheet->cursor_style[GNUCASH_CURSOR_SPLIT];
gnucash_sheet_style_recompile (style, sr->split_cursor,
sr, GNUCASH_CURSOR_SPLIT);
gnucash_sheet_styles_recompile (sheet);
gnucash_sheet_table_load (sheet);
gnucash_sheet_redraw_all (sheet);
}