mirror of
https://github.com/Gnucash/gnucash.git
synced 2025-02-25 18:55:30 -06:00
Add functionality to extract column widths from gnome sheet.
Remove TODO -- obsolete. git-svn-id: svn+ssh://svn.gnucash.org/repo/gnucash/trunk@2924 57a11ea4-9604-0410-9ed3-97b8803252fd
This commit is contained in:
parent
7bc9362270
commit
21d8db13e7
@ -1,32 +0,0 @@
|
||||
UPDATED June 03 2000
|
||||
|
||||
|
||||
*********************
|
||||
Overall Issues and Features.
|
||||
|
||||
1. The styles still need a lot of work. I'm not sure whether
|
||||
we should handle the styles entirely within the gnome register
|
||||
code, or try to make splitreg.c reasonably GUI independent.
|
||||
For example, things like fonts, cell colors, cell configurations,
|
||||
etc. should be dynamically changeable by the user. Also,
|
||||
the style dimension computation should take into account
|
||||
the font size.
|
||||
|
||||
2. Also, regarding the styles, I made some rather arbitrary
|
||||
choices in setting up how the cells are layed out and drawn.
|
||||
(For example, the Reconcile cells aren't dealt with very well
|
||||
for multline cellblocks.) And, it isn't clear that setting
|
||||
up layouts by percentages is the right way to go.
|
||||
|
||||
3. The "artwork" isn't great. I'd like a better looking
|
||||
cell cursor.
|
||||
|
||||
4. There's a bit of overdraw, but it isn't clear if optimizing
|
||||
the drawing is worth the effort.
|
||||
|
||||
*********************
|
||||
|
||||
Bugs
|
||||
|
||||
1. There are a few drawing bugs in the register; this is mostly related
|
||||
to the style computation.
|
@ -648,9 +648,8 @@ gnucash_sheet_style_new (GnucashSheet *sheet, CellBlock *cursor,
|
||||
|
||||
sr = sheet->split_register;
|
||||
|
||||
style = g_new0(SheetBlockStyle, 1);
|
||||
style = g_new0(SheetBlockStyle, 1);
|
||||
|
||||
style->reg_type = sr->type;
|
||||
style->cursor = cursor;
|
||||
style->cursor_type = cursor_type;
|
||||
|
||||
@ -761,7 +760,6 @@ gnucash_sheet_get_style_from_table (GnucashSheet *sheet,
|
||||
VirtualCellLocation vcell_loc)
|
||||
{
|
||||
Table *table;
|
||||
SplitRegister *sr;
|
||||
VirtualCell *vcell;
|
||||
CellBlock *cursor;
|
||||
int i;
|
||||
@ -770,7 +768,6 @@ gnucash_sheet_get_style_from_table (GnucashSheet *sheet,
|
||||
g_return_val_if_fail (GNUCASH_IS_SHEET(sheet), NULL);
|
||||
|
||||
table = sheet->table;
|
||||
sr = sheet->split_register;
|
||||
|
||||
vcell = gnc_table_get_virtual_cell (table, vcell_loc);
|
||||
|
||||
@ -864,6 +861,74 @@ gnucash_style_set_register_hint_font_name(const char *name)
|
||||
gdk_font_ref(gnucash_register_hint_font);
|
||||
}
|
||||
|
||||
void
|
||||
gnucash_sheet_get_header_widths (GnucashSheet *sheet, int *header_widths)
|
||||
{
|
||||
SheetBlockStyle *style;
|
||||
CellBlock *header;
|
||||
int row, col;
|
||||
|
||||
g_return_if_fail(sheet != NULL);
|
||||
g_return_if_fail(GNUCASH_IS_SHEET(sheet));
|
||||
|
||||
style = sheet->cursor_styles[GNUCASH_CURSOR_HEADER];
|
||||
header = sheet->cursors[GNUCASH_CURSOR_HEADER];
|
||||
|
||||
g_return_if_fail(style != NULL);
|
||||
g_return_if_fail(header != NULL);
|
||||
|
||||
for (row = 0; row < style->nrows; row++)
|
||||
for (col = 0; col < style->ncols; col++)
|
||||
{
|
||||
CellDimensions *cd;
|
||||
CellBlockCell *cb_cell;
|
||||
|
||||
cd = gnucash_style_get_cell_dimensions (style,
|
||||
row, col);
|
||||
|
||||
cb_cell = gnc_cellblock_get_cell (header, row, col);
|
||||
|
||||
if (cb_cell->cell_type < 0)
|
||||
continue;
|
||||
|
||||
header_widths[cb_cell->cell_type] = cd->pixel_width;
|
||||
}
|
||||
}
|
||||
|
||||
void
|
||||
gnucash_sheet_set_header_widths (GnucashSheet *sheet, int *header_widths)
|
||||
{
|
||||
SheetBlockStyle *style;
|
||||
CellBlock *header;
|
||||
int row, col;
|
||||
|
||||
g_return_if_fail(sheet != NULL);
|
||||
g_return_if_fail(GNUCASH_IS_SHEET(sheet));
|
||||
|
||||
style = sheet->cursor_styles[GNUCASH_CURSOR_HEADER];
|
||||
header = sheet->cursors[GNUCASH_CURSOR_HEADER];
|
||||
|
||||
g_return_if_fail(style != NULL);
|
||||
g_return_if_fail(header != NULL);
|
||||
|
||||
for (row = 0; row < style->nrows; row++)
|
||||
for (col = 0; col < style->ncols; col++)
|
||||
{
|
||||
CellDimensions *cd;
|
||||
CellBlockCell *cb_cell;
|
||||
|
||||
cd = gnucash_style_get_cell_dimensions (style,
|
||||
row, col);
|
||||
|
||||
cb_cell = gnc_cellblock_get_cell (header, row, col);
|
||||
|
||||
if (cb_cell->cell_type < 0)
|
||||
continue;
|
||||
|
||||
cd->pixel_width = header_widths[cb_cell->cell_type];
|
||||
}
|
||||
}
|
||||
|
||||
const char *
|
||||
gnucash_style_get_default_register_font_name(void)
|
||||
{
|
||||
|
@ -138,6 +138,9 @@ void gnucash_style_set_register_borders (int reg_borders_new);
|
||||
void gnucash_style_set_borders (SheetBlockStyle *style, int border);
|
||||
void gnucash_sheet_set_borders (GnucashSheet *sheet, int border);
|
||||
|
||||
void gnucash_sheet_get_header_widths (GnucashSheet *sheet, int *header_widths);
|
||||
void gnucash_sheet_set_header_widths (GnucashSheet *sheet, int *header_widths);
|
||||
|
||||
|
||||
extern GdkFont *gnucash_register_font;
|
||||
extern GdkFont *gnucash_register_hint_font;
|
||||
|
@ -312,8 +312,9 @@ configAction (SplitRegister *reg)
|
||||
cb_cell->span = ((handler) == (BasicCell *) reg->memoCell); \
|
||||
\
|
||||
cb_cell = gnc_cellblock_get_cell (header, row, col); \
|
||||
if (cb_cell) { \
|
||||
if (cb_cell && (curs == reg->single_cursor)) { \
|
||||
cb_cell->cell = hcell; \
|
||||
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); \
|
||||
@ -1723,4 +1724,52 @@ xaccSplitRegisterRestoreCursorChanged(SplitRegister *sr,
|
||||
restoreCellChanged(&sr->ndebitCell->cell, &srb->ndebitCell);
|
||||
}
|
||||
|
||||
/* keep in sync with CellType enum */
|
||||
static const char *cell_names[] =
|
||||
{
|
||||
"date",
|
||||
"num",
|
||||
"description",
|
||||
"reconcile",
|
||||
"shares",
|
||||
"balance",
|
||||
"action",
|
||||
"account",
|
||||
"split-account",
|
||||
"memo",
|
||||
"credit",
|
||||
"debit",
|
||||
"price",
|
||||
"value",
|
||||
"neg-credit",
|
||||
"neg-debit",
|
||||
"transfer"
|
||||
};
|
||||
|
||||
const char *
|
||||
xaccSplitRegisterGetCellTypeName (CellType type)
|
||||
{
|
||||
if (type < 0)
|
||||
return NULL;
|
||||
if (type >= CELL_TYPE_COUNT)
|
||||
return NULL;
|
||||
|
||||
return cell_names[type];
|
||||
}
|
||||
|
||||
CellType
|
||||
xaccSplitRegisterGetCellTypeFromName (const char *name)
|
||||
{
|
||||
CellType type;
|
||||
|
||||
if (name == NULL)
|
||||
return NO_CELL;
|
||||
|
||||
for (type = 0; type < CELL_TYPE_COUNT; type++)
|
||||
if (safe_strcmp (name, cell_names[type]) == 0)
|
||||
return type;
|
||||
|
||||
return NO_CELL;
|
||||
}
|
||||
|
||||
/* ============ END OF FILE ===================== */
|
||||
|
@ -82,30 +82,33 @@ typedef enum
|
||||
} SplitRegisterType;
|
||||
|
||||
/* These values are used to identify the cells in the register. */
|
||||
/* Keep these in sync with the cell_names array in splitreg.c. */
|
||||
typedef enum
|
||||
{
|
||||
NO_CELL = -1,
|
||||
DATE_CELL = 0,
|
||||
NUM_CELL = 1,
|
||||
DESC_CELL = 2,
|
||||
RECN_CELL = 3,
|
||||
SHRS_CELL = 4,
|
||||
BALN_CELL = 5,
|
||||
ACTN_CELL = 6,
|
||||
XFRM_CELL = 7,
|
||||
XTO_CELL = 8,
|
||||
MEMO_CELL = 9,
|
||||
CRED_CELL = 10,
|
||||
DEBT_CELL = 11,
|
||||
PRIC_CELL = 12,
|
||||
VALU_CELL = 13,
|
||||
NUM_CELL,
|
||||
DESC_CELL,
|
||||
RECN_CELL,
|
||||
SHRS_CELL,
|
||||
BALN_CELL,
|
||||
ACTN_CELL,
|
||||
XFRM_CELL,
|
||||
XTO_CELL,
|
||||
MEMO_CELL,
|
||||
CRED_CELL,
|
||||
DEBT_CELL,
|
||||
PRIC_CELL,
|
||||
VALU_CELL,
|
||||
|
||||
/* NCRED & NDEBT handle minus the usual quantities */
|
||||
NCRED_CELL = 14,
|
||||
NDEBT_CELL = 15,
|
||||
NCRED_CELL,
|
||||
NDEBT_CELL,
|
||||
|
||||
/* MXFRM is the "mirrored" transfer-from account */
|
||||
MXFRM_CELL = 16
|
||||
MXFRM_CELL,
|
||||
|
||||
CELL_TYPE_COUNT
|
||||
} CellType;
|
||||
|
||||
/*
|
||||
@ -303,6 +306,9 @@ void xaccSplitRegisterSaveCursor(SplitRegister *sr, SplitRegisterBuffer *srb);
|
||||
void xaccSplitRegisterRestoreCursorChanged(SplitRegister *sr,
|
||||
SplitRegisterBuffer *srb);
|
||||
|
||||
const char * xaccSplitRegisterGetCellTypeName (CellType type);
|
||||
CellType xaccSplitRegisterGetCellTypeFromName (const char *name);
|
||||
|
||||
|
||||
#endif /* __XACC_SPLITREG_H__ */
|
||||
|
||||
|
@ -54,14 +54,24 @@
|
||||
static void
|
||||
table_destroy_cb(Table *table)
|
||||
{
|
||||
int header_widths[CELL_TYPE_COUNT];
|
||||
GnucashSheet *sheet;
|
||||
int i;
|
||||
|
||||
if (table == NULL)
|
||||
return;
|
||||
|
||||
if (table->ui_data == NULL)
|
||||
return;
|
||||
|
||||
if (table->ui_data)
|
||||
gtk_widget_unref(GTK_WIDGET(table->ui_data));
|
||||
sheet = GNUCASH_SHEET(table->ui_data);
|
||||
|
||||
for (i = 0; i < CELL_TYPE_COUNT; i++)
|
||||
header_widths[i] = -1;
|
||||
|
||||
gnucash_sheet_get_header_widths (sheet, header_widths);
|
||||
|
||||
gtk_widget_unref(GTK_WIDGET(sheet));
|
||||
|
||||
table->ui_data = NULL;
|
||||
}
|
||||
@ -82,7 +92,7 @@ gnc_table_init_gui (gncUIWidget widget, void *data)
|
||||
|
||||
greg = GNUCASH_REGISTER(widget);
|
||||
sheet = GNUCASH_SHEET(greg->sheet);
|
||||
sheet->split_register = data;
|
||||
sheet->split_register = sr;
|
||||
table = sheet->table;
|
||||
|
||||
table->destroy = table_destroy_cb;
|
||||
|
Loading…
Reference in New Issue
Block a user