From 010d59408bf1dfd9185f07d88ce7e26163d6f494 Mon Sep 17 00:00:00 2001 From: Dave Peticolas Date: Tue, 3 Oct 2000 08:48:49 +0000 Subject: [PATCH] Smarter register combo box height calculations. Misc work. git-svn-id: svn+ssh://svn.gnucash.org/repo/gnucash/trunk@3011 57a11ea4-9604-0410-9ed3-97b8803252fd --- src/SplitLedger.c | 3 ++- src/register/gnome/gnucash-item-edit.c | 17 +++++++++++++---- src/register/gtable.c | 18 ++++++++++++++++++ src/register/gtable.h | 6 ++++++ src/register/table-allgui.c | 5 ++--- 5 files changed, 41 insertions(+), 8 deletions(-) diff --git a/src/SplitLedger.c b/src/SplitLedger.c index a711814721..59a85a1131 100644 --- a/src/SplitLedger.c +++ b/src/SplitLedger.c @@ -2350,7 +2350,8 @@ xaccSRSaveRegEntry (SplitRegister *reg, gboolean do_commit) xaccTransSetDateEnteredSecs(trans, time(NULL)); } - if (split == NULL) { + if (split == NULL) + { /* If we were asked to save data for a row for which there is no * associated split, then assume that this was a row that was * set aside for adding splits to an existing transaction. diff --git a/src/register/gnome/gnucash-item-edit.c b/src/register/gnome/gnucash-item-edit.c index 0ae2cf2044..6c85546fe3 100644 --- a/src/register/gnome/gnucash-item-edit.c +++ b/src/register/gnome/gnucash-item-edit.c @@ -1047,6 +1047,8 @@ item_edit_show_list (ItemEdit *item_edit) gint list_x, list_y; gint list_height; gint view_height; + gint up_height; + gint down_height; g_return_if_fail(item_edit != NULL); g_return_if_fail(IS_ITEM_EDIT(item_edit)); @@ -1060,15 +1062,22 @@ item_edit_show_list (ItemEdit *item_edit) item_edit_get_pixel_coords (item_edit, &x, &y, &w, &h); list_x = x; - list_y = y + h; - list_height = h * 6; - if ((list_y - y_offset) + list_height > view_height) { + up_height = y - y_offset; + down_height = view_height - (up_height + h); + + if (up_height > down_height) { list_y = y; list_anchor = GTK_ANCHOR_SW; + list_height = up_height; } - else + else { + list_y = y + h; list_anchor = GTK_ANCHOR_NW; + list_height = down_height; + } + + list_height = (list_height / h) * h; gnc_item_list_autosize(item_edit->item_list); diff --git a/src/register/gtable.c b/src/register/gtable.c index 8e93313797..60764b3c85 100644 --- a/src/register/gtable.c +++ b/src/register/gtable.c @@ -140,3 +140,21 @@ g_table_resize (GTable *gtable, int rows, int cols) gtable->rows = rows; gtable->cols = cols; } + +int +g_table_rows (GTable *gtable) +{ + if (gtable == NULL) + return 0; + + return gtable->rows; +} + +int +g_table_cols (GTable *gtable) +{ + if (gtable == NULL) + return 0; + + return gtable->cols; +} diff --git a/src/register/gtable.h b/src/register/gtable.h index 0873139c14..0b77dfde7f 100644 --- a/src/register/gtable.h +++ b/src/register/gtable.h @@ -57,4 +57,10 @@ gpointer g_table_index (GTable *gtable, int row, int col); * first. */ void g_table_resize (GTable *gtable, int rows, int cols); +/* Return the number of table rows. */ +int g_table_rows (GTable *gtable); + +/* Return the number of table columns. */ +int g_table_cols (GTable *gtable); + #endif diff --git a/src/register/table-allgui.c b/src/register/table-allgui.c index 0672e627d3..f77bbcade4 100644 --- a/src/register/table-allgui.c +++ b/src/register/table-allgui.c @@ -332,9 +332,8 @@ gnc_table_set_size (Table * table, int virt_rows, int virt_cols) { /* Invalidate the current cursor position, if the array is * shrinking. This must be done since the table is probably - * shrinking because some rows were deleted, and there's a pretty - * good chance (100% with current design) that the cursor is - * located on the deleted rows. */ + * shrinking because some rows were deleted, and the cursor + * could be on the deleted rows. */ if ((virt_rows < table->num_virt_rows) || (virt_cols < table->num_virt_cols)) {