diff --git a/ChangeLog b/ChangeLog index 81bfd8094b..834d1caf18 100644 --- a/ChangeLog +++ b/ChangeLog @@ -1,3 +1,13 @@ +2001-04-27 Dave Peticolas + + * src/SplitLedger.c (xaccSRExpandCurrentTrans): if expanding + a transaction, try to show all of it + + * src/register/table-gnome.c (gnc_table_show_range): new func + + * src/register/gnome/gnucash-sheet.c (gnucash_sheet_show_range): + new func + 2001-04-27 Christian Stimming * src/scm/report/balance-sheet.scm: Added option to choose the diff --git a/src/SplitLedger.c b/src/SplitLedger.c index f3ecd6bc39..6027c32968 100644 --- a/src/SplitLedger.c +++ b/src/SplitLedger.c @@ -780,6 +780,37 @@ xaccSRExpandCurrentTrans (SplitRegister *reg, gboolean expand) } gnc_table_refresh_gui (reg->table, TRUE); + + if (expand) + { + VirtualCellLocation start_loc; + VirtualCellLocation end_loc; + int v_row; + + start_loc = reg->table->current_cursor_loc.vcell_loc; + end_loc = reg->table->current_cursor_loc.vcell_loc; + + for (v_row = end_loc.virt_row + 1; + v_row < reg->table->num_virt_rows; v_row++) + { + VirtualCellLocation vc_loc = { v_row, 0 }; + CursorClass cursor_class; + + cursor_class = xaccSplitRegisterGetCursorClass (reg, vc_loc); + if (cursor_class == CURSOR_CLASS_TRANS) + break; + + if (cursor_class != CURSOR_CLASS_SPLIT) + { + v_row--; + break; + } + } + + end_loc.virt_row = MIN (v_row, reg->table->num_virt_rows - 1); + + gnc_table_show_range (reg->table, start_loc, end_loc); + } } gboolean diff --git a/src/register/gnome/gnucash-sheet.c b/src/register/gnome/gnucash-sheet.c index b1e4488c57..811f879af6 100644 --- a/src/register/gnome/gnucash-sheet.c +++ b/src/register/gnome/gnucash-sheet.c @@ -414,7 +414,7 @@ gnucash_sheet_show_row (GnucashSheet *sheet, gint virt_row) return; if (y > cy) - y -= height - block_height; + y -= height - MIN (block_height, height); if ((sheet->height - y) < height) y = sheet->height - height; @@ -447,6 +447,63 @@ gnucash_sheet_make_cell_visible (GnucashSheet *sheet, VirtualLocation virt_loc) } +void +gnucash_sheet_show_range (GnucashSheet *sheet, + VirtualCellLocation start_loc, + VirtualCellLocation end_loc) +{ + SheetBlock *start_block; + SheetBlock *end_block; + gint block_height; + gint height; + gint cx, cy; + gint x, y; + + g_return_if_fail (sheet != NULL); + g_return_if_fail (GNUCASH_IS_SHEET(sheet)); + + start_loc.virt_row = MAX (start_loc.virt_row, 1); + start_loc.virt_row = MIN (start_loc.virt_row, + sheet->num_virt_rows - 1); + + end_loc.virt_row = MAX (end_loc.virt_row, 1); + end_loc.virt_row = MIN (end_loc.virt_row, + sheet->num_virt_rows - 1); + + gnome_canvas_get_scroll_offsets (GNOME_CANVAS(sheet), &cx, &cy); + x = cx; + + height = GTK_WIDGET(sheet)->allocation.height; + + start_block = gnucash_sheet_get_block (sheet, start_loc); + end_block = gnucash_sheet_get_block (sheet, end_loc); + + y = start_block->origin_y; + block_height = (end_block->origin_y + + end_block->style->dimensions->height) - y; + + if ((cy <= y) && (cy + height >= y + block_height)) + return; + + if (y > cy) + y -= height - MIN (block_height, height); + + if ((sheet->height - y) < height) + y = sheet->height - height; + + if (y < 0) + y = 0; + + if (y != cy) + gtk_adjustment_set_value (sheet->vadj, y); + if (x != cx) + gtk_adjustment_set_value (sheet->hadj, x); + + gnucash_sheet_compute_visible_range (sheet); + gnucash_sheet_update_adjustments (sheet); +} + + void gnucash_sheet_update_adjustments (GnucashSheet *sheet) { diff --git a/src/register/gnome/gnucash-sheet.h b/src/register/gnome/gnucash-sheet.h index 65f7286eae..4fda956e24 100644 --- a/src/register/gnome/gnucash-sheet.h +++ b/src/register/gnome/gnucash-sheet.h @@ -174,6 +174,10 @@ void gnucash_sheet_compute_visible_range (GnucashSheet *sheet); void gnucash_sheet_make_cell_visible (GnucashSheet *sheet, VirtualLocation virt_loc); +void gnucash_sheet_show_range (GnucashSheet *sheet, + VirtualCellLocation start_loc, + VirtualCellLocation end_loc); + void gnucash_sheet_set_cursor (GnucashSheet *sheet, CellBlock *cursor); void gnucash_sheet_update_adjustments (GnucashSheet *sheet); diff --git a/src/register/table-allgui.h b/src/register/table-allgui.h index bdb95f8584..f7e7b6077e 100644 --- a/src/register/table-allgui.h +++ b/src/register/table-allgui.h @@ -389,6 +389,10 @@ void gnc_table_refresh_current_cursor_gui (Table * table, /* Refresh the whole GUI from the table. */ void gnc_table_refresh_gui (Table *table, gboolean do_scroll); +/* Try to show the whole range in the register. */ +void gnc_table_show_range (Table *table, + VirtualCellLocation start_loc, + VirtualCellLocation end_loc); /* ==================================================== */ diff --git a/src/register/table-gnome.c b/src/register/table-gnome.c index 389de7fc75..d7603e816e 100644 --- a/src/register/table-gnome.c +++ b/src/register/table-gnome.c @@ -220,7 +220,6 @@ gnc_table_refresh_cursor_gui (Table * table, g_return_if_fail (GNUCASH_IS_SHEET (table->ui_data)); - /* if the current cursor is undefined, there is nothing to do. */ if (gnc_table_virtual_cell_out_of_bounds (table, vcell_loc)) return; @@ -239,6 +238,29 @@ gnc_table_refresh_cursor_gui (Table * table, gnucash_sheet_redraw_block (sheet, vcell_loc); } +void +gnc_table_show_range (Table *table, + VirtualCellLocation start_loc, + VirtualCellLocation end_loc) +{ + GnucashSheet *sheet; + + if (!table) + return; + + g_return_if_fail (GNUCASH_IS_SHEET (table->ui_data)); + + if (gnc_table_virtual_cell_out_of_bounds (table, start_loc)) + return; + + if (gnc_table_virtual_cell_out_of_bounds (table, end_loc)) + return; + + sheet = GNUCASH_SHEET (table->ui_data); + + gnucash_sheet_show_range (sheet, start_loc, end_loc); +} + /* ================== end of file ======================= */