gnucash unstable: Revert "Merge branch 'gtk3-update8' of https://github.com/Bob-IT/gnucash into unstable"

Geert Janssens gjanssens at code.gnucash.org
Tue Nov 21 16:12:23 EST 2017


Updated	 via  https://github.com/Gnucash/gnucash/commit/2cbfc5bb (commit)
	from  https://github.com/Gnucash/gnucash/commit/cdb764fe (commit)



commit 2cbfc5bbac9bda4ef1206db5a437b45cb79bc373
Author: Geert Janssens <geert at kobaltwit.be>
Date:   Tue Nov 21 22:11:38 2017 +0100

    Revert "Merge branch 'gtk3-update8' of https://github.com/Bob-IT/gnucash into unstable"
    
    This reverts commit cdb764fec525642bbe85dd5a0a49ec967c55f089, reversing
    changes made to 169677a8d753ba26a447d22d2b2ec565bfe4798b.

diff --git a/gnucash/gnucash-310.css b/gnucash/gnucash-310.css
index 76b7232..e4a37a3 100644
--- a/gnucash/gnucash-310.css
+++ b/gnucash/gnucash-310.css
@@ -21,14 +21,13 @@
   color: mix (currentColor, grey, 0.2);
 }
 
-/* Register Cursor settings, top, right, bottom, left */
-.cursor .entry {
-  margin: 2px 5px 2px 5px;  /* this only works by doing it in code, yellow area */
-  padding: 2px 2px 2px 2px; /* all work with different values, around the text blue area */
+/* Register Cursor padding settings, make sure entry matches sheet.h */
+cursor entry {
+  padding: 2px 5px 2px 5px;
 }
 
-.cursor .toggle-button {
-  margin: 1px 1px 1px 1px; /* does not work, not used, here for completeness */
+cursor button {
+  padding: 1px 1px 1px 1px;
 }
 
 /* Register defaults */
@@ -38,7 +37,7 @@
 @define-color register_split_bg_color #EDE7D3;
 @define-color register_cursor_bg_color #FFEF98;
 
-*.register-header {
+.register-header {
   background-color: @register_header_bg_color;
 }
 
diff --git a/gnucash/gnucash-320.css b/gnucash/gnucash-320.css
index 51f197c..d7e0495 100644
--- a/gnucash/gnucash-320.css
+++ b/gnucash/gnucash-320.css
@@ -12,14 +12,13 @@
   color: @negative-numbers;
 }
 
-/* Register Cursor settings, top, right, bottom, left */
+/* Register Cursor padding settings, make sure entry matches sheet.h */
 cursor entry {
-  margin: 2px 5px 2px 5px;
-  padding: 0px 2px 0px 2px;
+  padding: 2px 5px 2px 5px;
 }
 
-cursor toggle-button {
-  margin: 1px 1px 1px 1px;
+cursor button {
+  padding: 1px 1px 1px 1px;
 }
 
 /* Register defaults */
@@ -29,7 +28,7 @@ cursor toggle-button {
 @define-color register_split_bg_color #EDE7D3;
 @define-color register_cursor_bg_color #FFEF98;
 
-*.register-header {
+.register-header {
   background-color: @register_header_bg_color;
 }
 
diff --git a/gnucash/register/ledger-core/gncEntryLedgerModel.c b/gnucash/register/ledger-core/gncEntryLedgerModel.c
index a638d06..8c5207d 100644
--- a/gnucash/register/ledger-core/gncEntryLedgerModel.c
+++ b/gnucash/register/ledger-core/gncEntryLedgerModel.c
@@ -915,57 +915,65 @@ static CellIOFlags get_qty_io_flags (VirtualLocation virt_loc, gpointer user_dat
     return flags;
 }
 
-/* GET COLORS */
+/* GET BG_COLORS */
 
 static guint32
-gnc_entry_ledger_get_cell_color_internal (VirtualLocation virt_loc,
-                                          GncEntryLedger *ledger)
+gnc_entry_ledger_get_color_internal (VirtualLocation virt_loc,
+                                     GncEntryLedger *ledger,
+                                     gboolean foreground)
 {
     VirtualCell *vcell;
     gboolean is_current;
-    guint32 colorbase = 0;
+    guint32 colorbase = 0; /* By default return background colors */
 
-    /* a bit of enum arithmetic */
-
-    // There are negative numbers
+    if (foreground)
+        colorbase = COLOR_UNKNOWN_FG; /* a bit of enum arithmetic */
 
     if (!ledger)
-        return (colorbase + COLOR_UNDEFINED);
+        return (colorbase + COLOR_UNKNOWN_BG);
 
     if (gnc_table_virtual_location_in_header (ledger->table, virt_loc))
-        return (colorbase + COLOR_HEADER);
+        return (colorbase + COLOR_HEADER_BG);
 
     vcell = gnc_table_get_virtual_cell (ledger->table, virt_loc.vcell_loc);
     if (!vcell || !vcell->cellblock)
-        return (colorbase + COLOR_UNDEFINED);
+        return (colorbase + COLOR_UNKNOWN_BG);
 
     if ((virt_loc.phys_col_offset < vcell->cellblock->start_col) ||
             (virt_loc.phys_col_offset > vcell->cellblock->stop_col))
-        return (colorbase + COLOR_UNDEFINED);
+        return (colorbase + COLOR_UNKNOWN_BG);
 
     is_current = virt_cell_loc_equal (ledger->table->current_cursor_loc.vcell_loc,
                                       virt_loc.vcell_loc);
 
     if (is_current)
         return vcell->start_primary_color ?
-                (colorbase + COLOR_PRIMARY_ACTIVE) :
-                (colorbase + COLOR_SECONDARY_ACTIVE);
+                (colorbase + COLOR_PRIMARY_BG_ACTIVE) :
+                (colorbase + COLOR_SECONDARY_BG_ACTIVE);
 
     return vcell->start_primary_color ?
-            (colorbase + COLOR_PRIMARY) : (colorbase + COLOR_SECONDARY);
+            (colorbase + COLOR_PRIMARY_BG) : (colorbase + COLOR_SECONDARY_BG);
 
 }
 
 static guint32
-gnc_entry_ledger_get_cell_color (VirtualLocation virt_loc,
-                                 gboolean *hatching, gpointer user_data)
+gnc_entry_ledger_get_fg_color (VirtualLocation virt_loc,
+                               gpointer user_data)
+{
+    GncEntryLedger *ledger = user_data;
+    return gnc_entry_ledger_get_color_internal (virt_loc, ledger, TRUE);
+}
+
+static guint32
+gnc_entry_ledger_get_bg_color (VirtualLocation virt_loc,
+                               gboolean *hatching, gpointer user_data)
 {
     GncEntryLedger *ledger = user_data;
 
     if (hatching)
         *hatching = FALSE;
 
-    return gnc_entry_ledger_get_cell_color_internal (virt_loc, ledger);
+    return gnc_entry_ledger_get_color_internal (virt_loc, ledger, FALSE);
 }
 
 /* SAVE CELLS */
@@ -1217,8 +1225,11 @@ static void gnc_entry_ledger_model_new_handlers (TableModel *model,
     };
     unsigned int i;
 
-    // Set the cell color handler
-    gnc_table_model_set_default_cell_color_handler (model, gnc_entry_ledger_get_cell_color);
+    gnc_table_model_set_default_fg_color_handler
+    (model, gnc_entry_ledger_get_fg_color);
+
+    gnc_table_model_set_default_bg_color_handler
+    (model, gnc_entry_ledger_get_bg_color);
 
     for (i = 0; i < (sizeof(models) / sizeof(*models)); i++)
     {
diff --git a/gnucash/register/ledger-core/split-register-model.c b/gnucash/register/ledger-core/split-register-model.c
index f8b6614..3a2fac4 100644
--- a/gnucash/register/ledger-core/split-register-model.c
+++ b/gnucash/register/ledger-core/split-register-model.c
@@ -514,85 +514,33 @@ get_trans_total_balance (SplitRegister *reg, Transaction *trans)
     return xaccTransGetAccountBalance(trans, account);
 }
 
-static gboolean
-gnc_split_register_use_negative_color (VirtualLocation virt_loc,
-                                       SplitRegister *reg)
-{
-    const char * cell_name;
-    gnc_numeric value;
-    Split *split;
-
-    if (!use_red_for_negative)
-        return FALSE;
-
-    split = gnc_split_register_get_split (reg, virt_loc.vcell_loc);
-    if (!split)
-        return FALSE;
-
-    cell_name = gnc_table_get_cell_name (reg->table, virt_loc);
-
-    if (gnc_cell_name_equal (cell_name, TSHRS_CELL))
-        value = get_trans_total_amount (reg, xaccSplitGetParent (split));
-    else if (gnc_cell_name_equal (cell_name, SHRS_CELL))
-    {
-        if (virt_cell_loc_equal (reg->table->current_cursor_loc.vcell_loc,
-                                      virt_loc.vcell_loc))
-            value = gnc_price_cell_get_value
-                     ((PriceCell *) gnc_table_layout_get_cell (reg->table->layout,
-                             SHRS_CELL));
-        else
-            value = xaccSplitGetAmount (split);
-    }
-    else if (gnc_cell_name_equal (cell_name, BALN_CELL))
-        value = xaccSplitGetBalance (split);
-    else if (gnc_cell_name_equal (cell_name, RBALN_CELL))
-        value = gnc_split_register_get_rbaln (virt_loc, reg, TRUE);
-    else if (gnc_cell_name_equal (cell_name, TBALN_CELL))
-        value = get_trans_total_balance (reg, xaccSplitGetParent (split));
-
-    if ((gnc_cell_name_equal (cell_name, BALN_CELL)) ||
-            (gnc_cell_name_equal (cell_name, RBALN_CELL)) ||
-            (gnc_cell_name_equal (cell_name, TBALN_CELL)))
-        {
-            Account *account = xaccSplitGetAccount (split);
-            if (gnc_reverse_balance (account))
-                value = gnc_numeric_neg (value);
-        }
-
-    if (gnc_numeric_negative_p (value))
-        return TRUE;
-
-    return FALSE;
-}
-
 static guint32
-gnc_split_register_get_cell_color_internal (VirtualLocation virt_loc,
-                                            SplitRegister *reg)
+gnc_split_register_get_color_internal (VirtualLocation virt_loc,
+                                       SplitRegister *reg,
+                                       gboolean foreground)
 {
     const char *cursor_name;
     VirtualCell *vcell;
     gboolean is_current;
     gboolean double_alternate_virt;
-    guint32 colorbase = 0;
+    guint32 colorbase = 0; /* By default return background colors */
 
-     /* a bit of enum arithmetic */
-
-    if (gnc_split_register_use_negative_color (virt_loc, reg))
-        colorbase = COLOR_NEGATIVE; // Requires Negative fg color
+    if (foreground)
+        colorbase = COLOR_UNKNOWN_FG; /* a bit of enum arithmetic */
 
     if (!reg)
-        return (colorbase + COLOR_UNDEFINED);
+        return (colorbase + COLOR_UNKNOWN_BG);
 
     if (gnc_table_virtual_location_in_header (reg->table, virt_loc))
-        return (colorbase + COLOR_HEADER);
+        return (colorbase + COLOR_HEADER_BG);
 
     vcell = gnc_table_get_virtual_cell (reg->table, virt_loc.vcell_loc);
     if (!vcell || !vcell->cellblock)
-        return (colorbase + COLOR_UNDEFINED);
+        return (colorbase + COLOR_UNKNOWN_BG);
 
     if ((virt_loc.phys_col_offset < vcell->cellblock->start_col) ||
             (virt_loc.phys_col_offset > vcell->cellblock->stop_col))
-        return (colorbase + COLOR_UNDEFINED);
+        return (colorbase + COLOR_UNKNOWN_BG);
 
     is_current = virt_cell_loc_equal (reg->table->current_cursor_loc.vcell_loc,
                                       virt_loc.vcell_loc);
@@ -604,11 +552,11 @@ gnc_split_register_get_cell_color_internal (VirtualLocation virt_loc,
     {
         if (is_current)
             return vcell->start_primary_color ?
-                    (colorbase + COLOR_PRIMARY_ACTIVE) :
-                    (colorbase + COLOR_SECONDARY_ACTIVE);
+                    (colorbase + COLOR_PRIMARY_BG_ACTIVE) :
+                    (colorbase + COLOR_SECONDARY_BG_ACTIVE);
 
         return vcell->start_primary_color ?
-                (colorbase + COLOR_PRIMARY) : (colorbase + COLOR_SECONDARY);
+                (colorbase + COLOR_PRIMARY_BG) : (colorbase + COLOR_SECONDARY_BG);
     }
 
     if (g_strcmp0 (cursor_name, CURSOR_DOUBLE_JOURNAL) == 0 ||
@@ -622,40 +570,101 @@ gnc_split_register_get_cell_color_internal (VirtualLocation virt_loc,
         {
             if (double_alternate_virt)
                 return vcell->start_primary_color ?
-                        (colorbase + COLOR_PRIMARY_ACTIVE) :
-                        (colorbase + COLOR_SECONDARY_ACTIVE);
+                        (colorbase + COLOR_PRIMARY_BG_ACTIVE) :
+                        (colorbase + COLOR_SECONDARY_BG_ACTIVE);
 
             return (virt_loc.phys_row_offset % 2 == 0) ?
-                    (colorbase + COLOR_PRIMARY_ACTIVE) :
-                    (colorbase + COLOR_SECONDARY_ACTIVE);
+                    (colorbase + COLOR_PRIMARY_BG_ACTIVE) :
+                    (colorbase + COLOR_SECONDARY_BG_ACTIVE);
         }
 
         if (double_alternate_virt)
             return vcell->start_primary_color ?
-                    (colorbase + COLOR_PRIMARY) :
-                    (colorbase + COLOR_SECONDARY);
+                    (colorbase + COLOR_PRIMARY_BG) :
+                    (colorbase + COLOR_SECONDARY_BG);
 
         return (virt_loc.phys_row_offset % 2 == 0) ?
-                (colorbase + COLOR_PRIMARY) :
-                (colorbase + COLOR_SECONDARY);
+                (colorbase + COLOR_PRIMARY_BG) :
+                (colorbase + COLOR_SECONDARY_BG);
     }
 
     if (g_strcmp0 (cursor_name, CURSOR_SPLIT) == 0)
     {
         if (is_current)
-            return (colorbase + COLOR_SPLIT_ACTIVE);
+            return (colorbase + COLOR_SPLIT_BG_ACTIVE);
 
-        return (colorbase + COLOR_SPLIT);
+        return (colorbase + COLOR_SPLIT_BG);
     }
 
     PWARN ("Unexpected cursor: %s\n", cursor_name);
 
-    return (colorbase + COLOR_UNDEFINED);
+    return (colorbase + COLOR_UNKNOWN_BG);
 }
 
-// Get Color for non numeric cells, no hatching required
 static guint32
-gnc_split_register_get_cell_color (VirtualLocation virt_loc,
+gnc_split_register_get_fg_color_internal (VirtualLocation virt_loc,
+                                          SplitRegister *reg)
+{
+    guint32 fg_color;
+    const char * cell_name;
+    gnc_numeric value;
+    Split *split;
+
+    fg_color = gnc_split_register_get_color_internal (virt_loc, reg, TRUE);
+
+    if (!use_red_for_negative)
+        return fg_color;
+
+    split = gnc_split_register_get_split (reg, virt_loc.vcell_loc);
+    if (!split)
+        return fg_color;
+
+    cell_name = gnc_table_get_cell_name (reg->table, virt_loc);
+
+    if (gnc_cell_name_equal (cell_name, TSHRS_CELL))
+        value = get_trans_total_amount (reg, xaccSplitGetParent (split));
+    else if (gnc_cell_name_equal (cell_name, SHRS_CELL))
+    {
+        if (virt_cell_loc_equal (reg->table->current_cursor_loc.vcell_loc,
+                                      virt_loc.vcell_loc))
+            value = gnc_price_cell_get_value
+                     ((PriceCell *) gnc_table_layout_get_cell (reg->table->layout,
+                             SHRS_CELL));
+        else
+            value = xaccSplitGetAmount (split);
+    }
+    else if (gnc_cell_name_equal (cell_name, BALN_CELL))
+        value = xaccSplitGetBalance (split);
+    else if (gnc_cell_name_equal (cell_name, RBALN_CELL))
+        value = gnc_split_register_get_rbaln (virt_loc, reg, TRUE);
+    else if (gnc_cell_name_equal (cell_name, TBALN_CELL))
+        value = get_trans_total_balance (reg, xaccSplitGetParent (split));
+
+    if ((gnc_cell_name_equal (cell_name, BALN_CELL)) ||
+            (gnc_cell_name_equal (cell_name, RBALN_CELL)) ||
+            (gnc_cell_name_equal (cell_name, TBALN_CELL)))
+        {
+            Account *account = xaccSplitGetAccount (split);
+            if (gnc_reverse_balance (account))
+                value = gnc_numeric_neg (value);
+        }
+
+    if (gnc_numeric_negative_p (value))
+        return COLOR_NEGATIVE;
+
+    return fg_color;
+}
+
+static guint32
+gnc_split_register_get_fg_color (VirtualLocation virt_loc,
+                                 gpointer user_data)
+{
+    SplitRegister *reg = user_data;
+    return gnc_split_register_get_fg_color_internal (virt_loc, reg);
+}
+
+static guint32
+gnc_split_register_get_bg_color (VirtualLocation virt_loc,
         gboolean *hatching,
         gpointer user_data)
 {
@@ -664,12 +673,11 @@ gnc_split_register_get_cell_color (VirtualLocation virt_loc,
     if (hatching)
         *hatching = FALSE;
 
-    return gnc_split_register_get_cell_color_internal (virt_loc, reg);
+    return gnc_split_register_get_color_internal (virt_loc, reg, FALSE);
 }
 
-// Get Color for numeric cells, update hatching
 static guint32
-gnc_split_register_get_debcred_color (VirtualLocation virt_loc,
+gnc_split_register_get_debcred_bg_color (VirtualLocation virt_loc,
         gboolean *hatching,
         gpointer user_data)
 {
@@ -686,7 +694,8 @@ gnc_split_register_get_debcred_color (VirtualLocation virt_loc,
         else
             *hatching = FALSE;
     }
-    return gnc_split_register_get_cell_color_internal (virt_loc, reg);
+
+    return gnc_split_register_get_bg_color (virt_loc, NULL, user_data);
 }
 
 static void
@@ -2614,26 +2623,42 @@ gnc_split_register_model_new (void)
         model, gnc_split_register_get_security_io_flags, SHRS_CELL);
 
 
-    gnc_table_model_set_default_cell_color_handler(
-        model, gnc_split_register_get_cell_color);
+    gnc_table_model_set_fg_color_handler(
+        model, gnc_split_register_get_fg_color, SHRS_CELL);
+
+    gnc_table_model_set_fg_color_handler(
+        model, gnc_split_register_get_fg_color, TSHRS_CELL);
+
+    gnc_table_model_set_fg_color_handler(
+        model, gnc_split_register_get_fg_color, BALN_CELL);
+
+    gnc_table_model_set_fg_color_handler(
+        model, gnc_split_register_get_fg_color, TBALN_CELL);
+
+    gnc_table_model_set_fg_color_handler(
+        model, gnc_split_register_get_fg_color, RBALN_CELL);
+
+
+    gnc_table_model_set_default_bg_color_handler(
+        model, gnc_split_register_get_bg_color);
 
-    gnc_table_model_set_cell_color_handler(
-        model, gnc_split_register_get_debcred_color, DEBT_CELL);
+    gnc_table_model_set_bg_color_handler(
+        model, gnc_split_register_get_debcred_bg_color, DEBT_CELL);
 
-    gnc_table_model_set_cell_color_handler(
-        model, gnc_split_register_get_debcred_color, CRED_CELL);
+    gnc_table_model_set_bg_color_handler(
+        model, gnc_split_register_get_debcred_bg_color, CRED_CELL);
 
-    gnc_table_model_set_cell_color_handler(
-        model, gnc_split_register_get_debcred_color, TDEBT_CELL);
+    gnc_table_model_set_bg_color_handler(
+        model, gnc_split_register_get_debcred_bg_color, TDEBT_CELL);
 
-    gnc_table_model_set_cell_color_handler(
-        model, gnc_split_register_get_debcred_color, TCRED_CELL);
+    gnc_table_model_set_bg_color_handler(
+        model, gnc_split_register_get_debcred_bg_color, TCRED_CELL);
 
-    gnc_table_model_set_cell_color_handler(
-        model, gnc_split_register_get_debcred_color, FCRED_CELL);
+    gnc_table_model_set_bg_color_handler(
+        model, gnc_split_register_get_debcred_bg_color, FCRED_CELL);
 
-    gnc_table_model_set_cell_color_handler(
-        model, gnc_split_register_get_debcred_color, FDEBT_CELL);
+    gnc_table_model_set_bg_color_handler(
+        model, gnc_split_register_get_debcred_bg_color, FDEBT_CELL);
 
 
     gnc_table_model_set_default_cell_border_handler(
diff --git a/gnucash/register/register-core/table-allgui.c b/gnucash/register/register-core/table-allgui.c
index 038d3b0..7e407db 100644
--- a/gnucash/register/register-core/table-allgui.c
+++ b/gnucash/register/register-core/table-allgui.c
@@ -345,29 +345,68 @@ gnc_table_get_label (Table *table, VirtualLocation virt_loc)
     return label;
 }
 
+static guint32
+gnc_table_get_fg_color_internal (Table *table, VirtualLocation virt_loc)
+{
+    TableGetFGColorHandler fg_color_handler;
+    const char *handler_name;
+
+    if (!table || !table->model)
+        return COLOR_UNKNOWN_FG;
+
+    handler_name = gnc_table_get_cell_name (table, virt_loc);
+
+    fg_color_handler = gnc_table_model_get_fg_color_handler (table->model,
+                       handler_name);
+    if (!fg_color_handler)
+    {
+        TableGetBGColorHandler bg_color_handler =
+            gnc_table_model_get_bg_color_handler (table->model, handler_name);
+
+        guint32 bg_color =
+            bg_color_handler (virt_loc, NULL, table->model->handler_user_data);
+        return bg_color + COLOR_UNKNOWN_FG;
+    }
+
+    return fg_color_handler (virt_loc, table->model->handler_user_data);
+}
+
 guint32
-gnc_table_get_color (Table *table, VirtualLocation virt_loc,
+gnc_table_get_fg_color (Table *table, VirtualLocation virt_loc)
+{
+    return gnc_table_get_fg_color_internal (table, virt_loc);
+}
+
+static guint32
+gnc_table_get_bg_color_internal (Table *table, VirtualLocation virt_loc,
                                  gboolean *hatching)
 {
-    TableGetCellColorHandler color_handler;
+    TableGetBGColorHandler bg_color_handler;
     const char *handler_name;
 
     if (hatching)
         *hatching = FALSE;
 
     if (!table || !table->model)
-        return COLOR_UNDEFINED;
+        return COLOR_UNKNOWN_BG;
 
     handler_name = gnc_table_get_cell_name (table, virt_loc);
 
-    color_handler = gnc_table_model_get_cell_color_handler (table->model,
-                                                            handler_name);
+    bg_color_handler = gnc_table_model_get_bg_color_handler (table->model,
+            handler_name);
+
+    if (!bg_color_handler)
+        return COLOR_UNKNOWN_BG;
 
-    if (!color_handler)
-        return COLOR_UNDEFINED;
+    return bg_color_handler (virt_loc, hatching,
+                             table->model->handler_user_data);
+}
 
-    return color_handler (virt_loc, hatching,
-                          table->model->handler_user_data);
+guint32
+gnc_table_get_bg_color (Table *table, VirtualLocation virt_loc,
+                        gboolean *hatching)
+{
+    return gnc_table_get_bg_color_internal (table, virt_loc, hatching);
 }
 
 void
diff --git a/gnucash/register/register-core/table-allgui.h b/gnucash/register/register-core/table-allgui.h
index 3b4fa26..d827fd5 100644
--- a/gnucash/register/register-core/table-allgui.h
+++ b/gnucash/register/register-core/table-allgui.h
@@ -179,19 +179,35 @@ struct table
 };
 
 /** Color definitions used for table elements */
-typedef enum {
-    COLOR_UNDEFINED = 0,      // 0
-    COLOR_HEADER,             // 1
-    COLOR_PRIMARY,            // 2
-    COLOR_PRIMARY_ACTIVE,     // 3
-    COLOR_SECONDARY,          // 4
-    COLOR_SECONDARY_ACTIVE,   // 5
-    COLOR_SPLIT,              // 6
-    COLOR_SPLIT_ACTIVE,       // 7
-    COLOR_NEGATIVE = 16,      // 16
+typedef enum
+{
+    /* Colors used for background drawing */
+    COLOR_UNKNOWN_BG,          // 0
+    COLOR_HEADER_BG,           // 1
+    COLOR_PRIMARY_BG,          // 2
+    COLOR_PRIMARY_BG_ACTIVE,   // 3
+    COLOR_SECONDARY_BG,        // 4
+    COLOR_SECONDARY_BG_ACTIVE, // 5
+    COLOR_SPLIT_BG,            // 6
+    COLOR_SPLIT_BG_ACTIVE,     // 7
+
+    /* Colors used for foreground drawing (text etc)
+     * ATTENTION: the background and foreground lists should have
+     *            the same types (the same amount of entries) !
+     *            The code relies on this ! */
+    COLOR_UNKNOWN_FG,          // 8
+    COLOR_HEADER_FG,           // 9
+    COLOR_PRIMARY_FG,          // 10
+    COLOR_PRIMARY_FG_ACTIVE,   // 11
+    COLOR_SECONDARY_FG,        // 12
+    COLOR_SECONDARY_FG_ACTIVE, // 13
+    COLOR_SPLIT_FG,            // 14
+    COLOR_SPLIT_FG_ACTIVE,     // 15
+
+    /* Other colors */
+    COLOR_NEGATIVE,            // 16 Color to use for negative numbers
 } RegisterColor;
 
-
 /** Set the default gui handlers used by new tables. */
 void gnc_table_set_default_gui_handlers (TableGUIHandlers *gui_handlers);
 
@@ -242,7 +258,9 @@ const char *   gnc_table_get_label (Table *table, VirtualLocation virt_loc);
 
 CellIOFlags    gnc_table_get_io_flags (Table *table, VirtualLocation virt_loc);
 
-guint32        gnc_table_get_color (Table *table, VirtualLocation virt_loc,
+guint32        gnc_table_get_fg_color (Table *table, VirtualLocation virt_loc);
+
+guint32        gnc_table_get_bg_color (Table *table, VirtualLocation virt_loc,
                                        gboolean *hatching);
 
 void           gnc_table_get_borders (Table *table, VirtualLocation virt_loc,
diff --git a/gnucash/register/register-core/table-model.c b/gnucash/register/register-core/table-model.c
index a5baee2..c76310e 100644
--- a/gnucash/register/register-core/table-model.c
+++ b/gnucash/register/register-core/table-model.c
@@ -134,7 +134,8 @@ gnc_table_model_new (void)
     model->label_handlers = gnc_table_model_handler_hash_new ();
     model->help_handlers = gnc_table_model_handler_hash_new ();
     model->io_flags_handlers = gnc_table_model_handler_hash_new ();
-    model->cell_color_handlers = gnc_table_model_handler_hash_new ();
+    model->fg_color_handlers = gnc_table_model_handler_hash_new ();
+    model->bg_color_handlers = gnc_table_model_handler_hash_new ();
     model->cell_border_handlers = gnc_table_model_handler_hash_new ();
     model->confirm_handlers = gnc_table_model_handler_hash_new ();
     model->save_handlers = gnc_table_model_handler_hash_new ();
@@ -164,8 +165,11 @@ gnc_table_model_destroy (TableModel *model)
     gnc_table_model_handler_hash_destroy (model->io_flags_handlers);
     model->io_flags_handlers = NULL;
 
-    gnc_table_model_handler_hash_destroy (model->cell_color_handlers);
-    model->cell_color_handlers = NULL;
+    gnc_table_model_handler_hash_destroy (model->fg_color_handlers);
+    model->fg_color_handlers = NULL;
+
+    gnc_table_model_handler_hash_destroy (model->bg_color_handlers);
+    model->bg_color_handlers = NULL;
 
     gnc_table_model_handler_hash_destroy (model->cell_border_handlers);
     model->cell_border_handlers = NULL;
@@ -330,39 +334,75 @@ gnc_table_model_get_io_flags_handler (TableModel *model,
 }
 
 void
-gnc_table_model_set_cell_color_handler
+gnc_table_model_set_fg_color_handler
 (TableModel *model,
- TableGetCellColorHandler color_handler,
+ TableGetFGColorHandler fg_color_handler,
  const char * cell_name)
 {
     g_return_if_fail (model != NULL);
     g_return_if_fail (cell_name != NULL);
 
-    gnc_table_model_handler_hash_insert (model->cell_color_handlers,
+    gnc_table_model_handler_hash_insert (model->fg_color_handlers,
                                          cell_name,
-                                         color_handler);
+                                         fg_color_handler);
 }
 
 void
-gnc_table_model_set_default_cell_color_handler
+gnc_table_model_set_default_fg_color_handler
 (TableModel *model,
- TableGetCellColorHandler color_handler)
+ TableGetFGColorHandler fg_color_handler)
 {
     g_return_if_fail (model != NULL);
 
-    gnc_table_model_handler_hash_insert (model->cell_color_handlers,
+    gnc_table_model_handler_hash_insert (model->fg_color_handlers,
                                          DEFAULT_HANDLER,
-                                         color_handler);
+                                         fg_color_handler);
 }
 
-TableGetCellColorHandler
-gnc_table_model_get_cell_color_handler (TableModel *model,
-                                   const char * cell_name)
+TableGetFGColorHandler
+gnc_table_model_get_fg_color_handler (TableModel *model,
+                                      const char * cell_name)
 {
     g_return_val_if_fail (model != NULL, NULL);
 
-    return gnc_table_model_handler_hash_lookup (model->cell_color_handlers,
-                                                cell_name);
+    return gnc_table_model_handler_hash_lookup (model->fg_color_handlers,
+            cell_name);
+}
+
+void
+gnc_table_model_set_bg_color_handler
+(TableModel *model,
+ TableGetBGColorHandler bg_color_handler,
+ const char * cell_name)
+{
+    g_return_if_fail (model != NULL);
+    g_return_if_fail (cell_name != NULL);
+
+    gnc_table_model_handler_hash_insert (model->bg_color_handlers,
+                                         cell_name,
+                                         bg_color_handler);
+}
+
+void
+gnc_table_model_set_default_bg_color_handler
+(TableModel *model,
+ TableGetBGColorHandler bg_color_handler)
+{
+    g_return_if_fail (model != NULL);
+
+    gnc_table_model_handler_hash_insert (model->bg_color_handlers,
+                                         DEFAULT_HANDLER,
+                                         bg_color_handler);
+}
+
+TableGetBGColorHandler
+gnc_table_model_get_bg_color_handler (TableModel *model,
+                                      const char * cell_name)
+{
+    g_return_val_if_fail (model != NULL, NULL);
+
+    return gnc_table_model_handler_hash_lookup (model->bg_color_handlers,
+            cell_name);
 }
 
 void
diff --git a/gnucash/register/register-core/table-model.h b/gnucash/register/register-core/table-model.h
index 2d489a6..268757e 100644
--- a/gnucash/register/register-core/table-model.h
+++ b/gnucash/register/register-core/table-model.h
@@ -76,7 +76,10 @@ typedef char * (*TableGetHelpHandler) (VirtualLocation virt_loc,
 typedef CellIOFlags (*TableGetCellIOFlagsHandler) (VirtualLocation virt_loc,
         gpointer user_data);
 
-typedef guint32 (*TableGetCellColorHandler) (VirtualLocation virt_loc,
+typedef guint32 (*TableGetFGColorHandler) (VirtualLocation virt_loc,
+        gpointer user_data);
+
+typedef guint32 (*TableGetBGColorHandler) (VirtualLocation virt_loc,
         gboolean *hatching,
         gpointer user_data);
 
@@ -104,7 +107,8 @@ typedef struct
     GHashTable *label_handlers;
     GHashTable *help_handlers;
     GHashTable *io_flags_handlers;
-    GHashTable *cell_color_handlers;
+    GHashTable *fg_color_handlers;
+    GHashTable *bg_color_handlers;
     GHashTable *cell_border_handlers;
     GHashTable *confirm_handlers;
 
@@ -185,14 +189,25 @@ TableGetCellIOFlagsHandler gnc_table_model_get_io_flags_handler
 (TableModel *model,
  const char * cell_name);
 
-void gnc_table_model_set_cell_color_handler
+void gnc_table_model_set_fg_color_handler
+(TableModel *model,
+ TableGetFGColorHandler io_flags_handler,
+ const char * cell_name);
+void gnc_table_model_set_default_fg_color_handler
+(TableModel *model,
+ TableGetFGColorHandler io_flags_handler);
+TableGetFGColorHandler gnc_table_model_get_fg_color_handler
+(TableModel *model,
+ const char * cell_name);
+
+void gnc_table_model_set_bg_color_handler
 (TableModel *model,
- TableGetCellColorHandler io_flags_handler,
+ TableGetBGColorHandler io_flags_handler,
  const char * cell_name);
- void gnc_table_model_set_default_cell_color_handler
+void gnc_table_model_set_default_bg_color_handler
 (TableModel *model,
- TableGetCellColorHandler io_flags_handler);
-TableGetCellColorHandler gnc_table_model_get_cell_color_handler
+ TableGetBGColorHandler io_flags_handler);
+TableGetBGColorHandler gnc_table_model_get_bg_color_handler
 (TableModel *model,
  const char * cell_name);
 
diff --git a/gnucash/register/register-gnome/gnucash-header.c b/gnucash/register/register-gnome/gnucash-header.c
index 156ae68..247d08f 100644
--- a/gnucash/register/register-gnome/gnucash-header.c
+++ b/gnucash/register/register-gnome/gnucash-header.c
@@ -69,7 +69,6 @@ static void
 gnc_header_draw_offscreen (GncHeader *header)
 {
     SheetBlockStyle *style = header->style;
-    GncItemEdit *item_edit = GNC_ITEM_EDIT(header->sheet->item_editor);
     Table *table = header->sheet->table;
     VirtualLocation virt_loc;
     VirtualCell *vcell;
@@ -88,8 +87,8 @@ gnc_header_draw_offscreen (GncHeader *header)
 
     gtk_style_context_save (stylectxt);
 
-    // Get the color type and apply the css class
-    color_type = gnc_table_get_color (table, virt_loc, NULL);
+    // Get the background color type and apply the css class
+    color_type = gnc_table_get_bg_color (table, virt_loc, NULL);
     gnucash_get_style_classes (header->sheet, stylectxt, color_type);
 
     if (header->surface)
@@ -126,7 +125,7 @@ gnc_header_draw_offscreen (GncHeader *header)
     for (i = 0; i < style->nrows; i++)
     {
         int col_offset = 0;
-        int height = 0, j;
+        int h = 0, j;
         virt_loc.phys_row_offset = i;
 
         /* TODO: This routine is duplicated in several places.
@@ -140,29 +139,26 @@ gnc_header_draw_offscreen (GncHeader *header)
             double text_x, text_y, text_w, text_h;
             BasicCell *cell;
             const char *text;
-            int width;
+            int w;
             PangoLayout *layout;
-            PangoRectangle logical_rect;
-            GdkRectangle rect;
-            int x_offset;
 
             virt_loc.phys_col_offset = j;
 
             cd = gnucash_style_get_cell_dimensions (style, i, j);
-            height = cd->pixel_height;
+            h = cd->pixel_height;
             if (header->in_resize && (j == header->resize_col))
-                width = header->resize_col_width;
+                w = header->resize_col_width;
             else
-                width = cd->pixel_width;
+                w = cd->pixel_width;
 
             cell = gnc_cellblock_get_cell (cb, i, j);
             if (!cell || !cell->cell_name)
             {
-                col_offset += width;
+                col_offset += w;
                 continue;
             }
 
-            cairo_rectangle (cr, col_offset - 0.5, row_offset + 0.5, width, height);
+            cairo_rectangle (cr, col_offset - 0.5, row_offset + 0.5, w, h);
             cairo_set_line_width (cr, 1.0);
             cairo_stroke (cr);
 
@@ -173,28 +169,38 @@ gnc_header_draw_offscreen (GncHeader *header)
                 text = "";
 
             layout = gtk_widget_create_pango_layout (GTK_WIDGET (header->sheet), text);
+            switch (gnc_table_get_align (table, virt_loc))
+            {
+            default:
+            case CELL_ALIGN_LEFT:
+                pango_layout_set_alignment (layout, PANGO_ALIGN_LEFT);
+                break;
+
+            case CELL_ALIGN_RIGHT:
+                pango_layout_set_alignment (layout, PANGO_ALIGN_RIGHT);
+                break;
+
+            case CELL_ALIGN_CENTER:
+                pango_layout_set_alignment (layout, PANGO_ALIGN_CENTER);
+                break;
+            }
 
-            pango_layout_get_pixel_extents (layout, NULL, &logical_rect);
-
-            gnucash_sheet_set_text_bounds (header->sheet, &rect,
-                                           col_offset, row_offset, width, height);
-
+            text_x = col_offset + CELL_HPADDING;
+            text_y = row_offset + 1;
+            text_w = MAX (0, w - (2 * CELL_HPADDING));
+            text_h = h - 2;
             cairo_save (cr);
-            cairo_rectangle (cr, rect.x, rect.y, rect.width, rect.height);
+            cairo_rectangle (cr, text_x, text_y, text_w, text_h);
             cairo_clip (cr);
 
-            x_offset = gnucash_sheet_get_text_offset (header->sheet, virt_loc,
-                                                      rect.width, logical_rect.width);
-
-            gtk_render_layout (stylectxt, cr, rect.x + x_offset,
-                               rect.y + gnc_item_edit_get_padding_border (item_edit, top), layout);
+            gtk_render_layout (stylectxt, cr, text_x, text_y, layout);
 
             cairo_restore (cr);
             g_object_unref (layout);
 
-            col_offset += width;
+            col_offset += w;
         }
-        row_offset += height;
+        row_offset += h;
     }
     gtk_style_context_restore (stylectxt);
 
diff --git a/gnucash/register/register-gnome/gnucash-item-edit.c b/gnucash/register/register-gnome/gnucash-item-edit.c
index 39641d1..91aa497 100644
--- a/gnucash/register/register-gnome/gnucash-item-edit.c
+++ b/gnucash/register/register-gnome/gnucash-item-edit.c
@@ -58,157 +58,6 @@ enum
 
 static GtkBoxClass *gnc_item_edit_parent_class;
 
-static GtkToggleButtonClass *gnc_item_edit_tb_parent_class;
-
-static void
-gnc_item_edit_tb_init (GncItemEditTb *item_edit_tb)
-{
-    item_edit_tb->sheet = NULL;
-}
-
-static void
-gnc_item_edit_tb_get_property (GObject *object,
-                               guint param_id,
-                               GValue *value,
-                               GParamSpec *pspec)
-{
-    GncItemEditTb *item_edit_tb = GNC_ITEM_EDIT_TB (object);
-
-    switch (param_id)
-    {
-    case PROP_SHEET:
-        g_value_take_object (value, item_edit_tb->sheet);
-        break;
-    default:
-        G_OBJECT_WARN_INVALID_PROPERTY_ID (object, param_id, pspec);
-        break;
-    }
-}
-
-static void
-gnc_item_edit_tb_set_property (GObject *object,
-                               guint param_id,
-                               const GValue *value,
-                               GParamSpec *pspec)
-{
-    GncItemEditTb *item_edit_tb = GNC_ITEM_EDIT_TB (object);
-
-    switch (param_id)
-    {
-    case PROP_SHEET:
-        item_edit_tb->sheet = GNUCASH_SHEET (g_value_get_object (value));
-        break;
-    default:
-        G_OBJECT_WARN_INVALID_PROPERTY_ID (object, param_id, pspec);
-        break;
-    }
-}
-
-static void
-gnc_item_edit_tb_get_preferred_width (GtkWidget *widget,
-                                   gint *minimal_width,
-                                   gint *natural_width)
-{
-    GncItemEditTb *tb = GNC_ITEM_EDIT_TB (widget);
-    GncItemEdit *item_edit = GNC_ITEM_EDIT(tb->sheet->item_editor);
-    gint x, y, w, h, width = 0;
-    gnc_item_edit_get_pixel_coords (GNC_ITEM_EDIT (item_edit), &x, &y, &w, &h);
-    width = ((h - 2)*2)/3;
-    if (width < 20) // minimum size for a button
-        width = 20;
-    *minimal_width = *natural_width = width;
-}
-
-static void
-gnc_item_edit_tb_get_preferred_height (GtkWidget *widget,
-                                    gint *minimal_width,
-                                    gint *natural_width)
-{
-    GncItemEditTb *tb = GNC_ITEM_EDIT_TB (widget);
-    GncItemEdit *item_edit = GNC_ITEM_EDIT(tb->sheet->item_editor);
-    gint x, y, w, h;
-    gnc_item_edit_get_pixel_coords (GNC_ITEM_EDIT (item_edit), &x, &y, &w, &h);
-    *minimal_width = *natural_width = (h - 2);
-}
-
-static void
-gnc_item_edit_tb_class_init (GncItemEditTbClass *gnc_item_edit_tb_class)
-{
-    GObjectClass  *object_class;
-    GtkWidgetClass *widget_class;
-
-#if GTK_CHECK_VERSION(3,20,0)
-//    gtk_widget_class_set_css_name (GTK_WIDGET_CLASS(gnc_item_edit_tb_class), "button");
-    gtk_widget_class_set_css_name (GTK_WIDGET_CLASS(gnc_item_edit_tb_class), "toggle-button");
-#endif
-
-    gnc_item_edit_tb_parent_class = g_type_class_peek_parent (gnc_item_edit_tb_class);
-
-    object_class = G_OBJECT_CLASS (gnc_item_edit_tb_class);
-    widget_class = GTK_WIDGET_CLASS (gnc_item_edit_tb_class);
-
-    object_class->get_property = gnc_item_edit_tb_get_property;
-    object_class->set_property = gnc_item_edit_tb_set_property;
-
-    g_object_class_install_property (object_class,
-                                     PROP_SHEET,
-                                     g_param_spec_object ("sheet",
-                                             "Sheet Value",
-                                             "Sheet Value",
-                                             GNUCASH_TYPE_SHEET,
-                                             G_PARAM_READWRITE));
-
-    /* GtkWidget method overrides */
-    widget_class->get_preferred_width = gnc_item_edit_tb_get_preferred_width;
-    widget_class->get_preferred_height = gnc_item_edit_tb_get_preferred_height;
-}
-
-GType
-gnc_item_edit_tb_get_type (void)
-{
-    static GType gnc_item_edit_tb_type = 0;
-
-    if (!gnc_item_edit_tb_type)
-    {
-        static const GTypeInfo gnc_item_edit_tb_info =
-        {
-            sizeof (GncItemEditTbClass),
-            NULL,
-            NULL,
-            (GClassInitFunc) gnc_item_edit_tb_class_init,
-            NULL,
-            NULL,
-            sizeof (GncItemEditTb),
-            0, /* n_preallocs */
-            (GInstanceInitFunc) gnc_item_edit_tb_init,
-            NULL,
-        };
-        gnc_item_edit_tb_type =
-            g_type_register_static(GTK_TYPE_TOGGLE_BUTTON,
-                                   "GncItemEditTb",
-                                   &gnc_item_edit_tb_info, 0);
-    }
-    return gnc_item_edit_tb_type;
-}
-
-GtkWidget *
-gnc_item_edit_tb_new (GnucashSheet *sheet)
-{
-    GtkStyleContext *context;
-    GncItemEditTb *item_edit_tb =
-            g_object_new (GNC_TYPE_ITEM_EDIT_TB,
-                          "sheet", sheet,
-                           NULL);
-
-    // This sets a style class for when Gtk+ version is less than 3.20
-//    gnc_widget_set_css_name (GTK_WIDGET(item_edit_tb), "button");
-    gnc_widget_set_css_name (GTK_WIDGET(item_edit_tb), "toggle-button");
-
-    context = gtk_widget_get_style_context (GTK_WIDGET(item_edit_tb));
-    gtk_style_context_add_class (context, GTK_STYLE_CLASS_BUTTON);
-
-    return GTK_WIDGET(item_edit_tb);
-}
 
 /*
  * Returns the coordinates for the editor bounding box
@@ -245,6 +94,14 @@ gnc_item_edit_get_pixel_coords (GncItemEdit *item_edit,
     *y += yd;
 }
 
+
+int
+gnc_item_edit_get_toggle_offset (int row_height)
+{
+    /* sync with gnc_item_edit_update */
+    return row_height - (2 * (CELL_VPADDING + 1)) + 3;
+}
+
 static gboolean
 gnc_item_edit_update (GncItemEdit *item_edit)
 {
@@ -487,8 +344,11 @@ draw_background_cb (GtkWidget *widget, cairo_t *cr, gpointer user_data)
 
     gtk_style_context_save (stylectxt);
 
-    // Get the color type and apply the css class
-    color_type = gnc_table_get_color (item_edit->sheet->table, item_edit->virt_loc, NULL);
+    // Get the background and foreground color types and apply the css class
+    color_type = gnc_table_get_bg_color (item_edit->sheet->table, item_edit->virt_loc, NULL);
+    gnucash_get_style_classes (item_edit->sheet, stylectxt, color_type);
+
+    color_type = gnc_table_get_fg_color (item_edit->sheet->table, item_edit->virt_loc);
     gnucash_get_style_classes (item_edit->sheet, stylectxt, color_type);
 
     gtk_render_background (stylectxt, cr, 0, 1, width, height - 2);
@@ -501,7 +361,6 @@ draw_background_cb (GtkWidget *widget, cairo_t *cr, gpointer user_data)
 static gboolean
 draw_text_cursor_cb (GtkWidget *widget, cairo_t *cr, gpointer user_data)
 {
-    GncItemEdit *item_edit = GNC_ITEM_EDIT(user_data);
     GtkEditable *editable = GTK_EDITABLE(widget);
     GtkStyleContext *stylectxt = gtk_widget_get_style_context (GTK_WIDGET(widget));
     gint height = gtk_widget_get_allocated_height (widget);
@@ -542,15 +401,8 @@ draw_text_cursor_cb (GtkWidget *widget, cairo_t *cr, gpointer user_data)
     // Now draw a vertical line
     cairo_set_source_rgb (cr, fg_color->red, fg_color->green, fg_color->blue);
     cairo_set_line_width (cr, 1.0);
-#if GTK_CHECK_VERSION(3,20,0)
-    cairo_move_to (cr, cursor_x + 0.5, gnc_item_edit_get_margin (item_edit, top) +
-                                       gnc_item_edit_get_padding_border (item_edit, top));
-    cairo_rel_line_to (cr, 0, height - gnc_item_edit_get_margin (item_edit, top_bottom) -
-                                       gnc_item_edit_get_padding_border (item_edit, top_bottom));
-#else
-    cairo_move_to (cr, cursor_x + 0.5, gnc_item_edit_get_padding_border (item_edit, top));
-    cairo_rel_line_to (cr, 0, height - gnc_item_edit_get_padding_border (item_edit, top_bottom));
-#endif
+    cairo_move_to (cr, cursor_x + 0.5, 2);
+    cairo_rel_line_to (cr, 0, height - 4);
     cairo_stroke (cr);
 
     return FALSE;
@@ -568,9 +420,6 @@ draw_arrow_cb (GtkWidget *widget, cairo_t *cr, gpointer data)
 
     gtk_render_background (context, cr, 0, 0, width, height);
 
-    gtk_style_context_add_class (context, GTK_STYLE_CLASS_FRAME);
-    gtk_render_frame (context, cr, 1, 1, width - 2, height - 2);
-
     gtk_style_context_add_class (context, GTK_STYLE_CLASS_ARROW);
 
     size = MIN(width / 2, height / 2);
@@ -759,60 +608,13 @@ gnc_item_edit_get_type (void)
     return gnc_item_edit_type;
 }
 
-gint
-gnc_item_edit_get_margin (GncItemEdit *item_edit, Sides side)
-{
-    switch (side)
-    {
-    case left:
-        return item_edit->margin.left;
-    case right:
-        return item_edit->margin.right;
-    case top:
-        return item_edit->margin.top;
-    case bottom:
-        return item_edit->margin.bottom;
-    case left_right:
-        return item_edit->margin.left + item_edit->margin.right;
-    case top_bottom:
-        return item_edit->margin.top + item_edit->margin.bottom;
-    default:
-        return 2;
-    }
-}
-
-gint
-gnc_item_edit_get_padding_border (GncItemEdit *item_edit, Sides side)
-{
-    switch (side)
-    {
-    case left:
-        return item_edit->padding.left + item_edit->border.left;
-    case right:
-        return item_edit->padding.right + item_edit->border.right;
-    case top:
-        return item_edit->padding.top + item_edit->border.top;
-    case bottom:
-        return item_edit->padding.bottom + item_edit->border.bottom;
-    case left_right:
-        return item_edit->padding.left + item_edit->border.left +
-               item_edit->padding.right + item_edit->border.right;
-    case top_bottom:
-        return item_edit->padding.top + item_edit->border.top +
-               item_edit->padding.bottom + item_edit->border.bottom;
-    default:
-        return 2;
-    }
-}
 
 GtkWidget *
 gnc_item_edit_new (GnucashSheet *sheet)
 {
-    GtkStyleContext *stylectxt;
-    GtkBorder padding;
-    GtkBorder margin;
-    GtkBorder border;
-    GtkWidget *vb = gtk_box_new (GTK_ORIENTATION_VERTICAL, 0);
+    char *hpad_str, *vpad_str, *entry_css;
+    GtkStyleContext *stylecontext;
+    GtkCssProvider *provider;
     GncItemEdit *item_edit =
             g_object_new (GNC_TYPE_ITEM_EDIT,
                           "sheet", sheet,
@@ -828,54 +630,32 @@ gnc_item_edit_new (GnucashSheet *sheet)
     item_edit->editor = gtk_entry_new();
     sheet->entry = item_edit->editor;
     gtk_entry_set_width_chars (GTK_ENTRY(item_edit->editor), 1);
-    gtk_box_pack_start (GTK_BOX(item_edit), item_edit->editor, TRUE, TRUE, 0);
-
-    // Get the CSS space settings for the entry
-    stylectxt = gtk_widget_get_style_context (GTK_WIDGET(item_edit->editor));
-    gtk_style_context_get_padding (stylectxt, GTK_STATE_FLAG_NORMAL, &padding);
-    gtk_style_context_get_margin (stylectxt, GTK_STATE_FLAG_NORMAL, &margin);
-    gtk_style_context_get_border (stylectxt, GTK_STATE_FLAG_NORMAL, &border);
-
-    item_edit->padding = padding;
-    item_edit->margin = margin;
-    item_edit->border = border;
+    gtk_box_pack_start (GTK_BOX(item_edit), item_edit->editor,  TRUE, TRUE, 0);
 
     // Make sure the Entry can not have focus and no frame
     gtk_widget_set_can_focus (GTK_WIDGET(item_edit->editor), FALSE);
     gtk_entry_set_has_frame (GTK_ENTRY(item_edit->editor), FALSE);
 
-#if !GTK_CHECK_VERSION(3,20,0)
-#if GTK_CHECK_VERSION(3,12,0)
-    gtk_widget_set_margin_start (GTK_WIDGET(item_edit->editor),
-                                 gnc_item_edit_get_margin (item_edit, left));
-    gtk_widget_set_margin_end (GTK_WIDGET(item_edit->editor),
-                               gnc_item_edit_get_margin (item_edit, right));
-#else
-    gtk_widget_set_margin_left (GTK_WIDGET(item_edit->editor),
-                                gnc_item_edit_get_margin (item_edit, left));
-    gtk_widget_set_margin_right (GTK_WIDGET(item_edit->editor),
-                                 gnc_item_edit_get_margin (item_edit, right));
-#endif
-    gtk_widget_set_margin_top (GTK_WIDGET(item_edit->editor),
-                               gnc_item_edit_get_margin (item_edit, top));
-    gtk_widget_set_margin_bottom (GTK_WIDGET(item_edit->editor),
-                                  gnc_item_edit_get_margin (item_edit, bottom));
-#endif
-
     // Connect to the draw signal so we can draw a cursor
     g_signal_connect_after (item_edit->editor, "draw",
-                            G_CALLBACK (draw_text_cursor_cb), item_edit);
+                            G_CALLBACK (draw_text_cursor_cb), NULL);
 
     // Fill in the background so the underlying sheet cell can not be seen
     g_signal_connect (item_edit, "draw",
                             G_CALLBACK (draw_background_cb), item_edit);
 
+    /* Force padding on the entry to align with the rest of the register this
+       is done in the gnucash.css file which should be in line with sheet.h */
+
     /* Create the popup button
        It will only be displayed when the cell being edited provides
        a popup item (like a calendar or account list) */
-    item_edit->popup_toggle.tbutton = gnc_item_edit_tb_new (sheet);
+    item_edit->popup_toggle.tbutton = gtk_toggle_button_new();
     gtk_toggle_button_set_mode (GTK_TOGGLE_BUTTON (item_edit->popup_toggle.tbutton), FALSE);
 
+    /* Force padding on the button to keep it small and display as much as
+       possible of the arrow which is done in the gnucash.css file */
+
     /* Wrap the popup button in an event box to give it its own gdkwindow.
      * Without one the button would disappear behind the grid object. */
     item_edit->popup_toggle.ebox = gtk_event_box_new();
@@ -883,35 +663,14 @@ gnc_item_edit_new (GnucashSheet *sheet)
     gtk_container_add(GTK_CONTAINER(item_edit->popup_toggle.ebox),
                       item_edit->popup_toggle.tbutton);
 
-    /* The button needs to be packed into a vertical box so that the height and position
-     * can be controlled in ealier than Gtk3.20 versions */
-    gtk_box_pack_start (GTK_BOX(vb), item_edit->popup_toggle.ebox,
-                        FALSE, FALSE, 0);
-
-    gtk_box_pack_start (GTK_BOX(item_edit), vb, FALSE, FALSE, 0);
+    gtk_box_pack_start (GTK_BOX(item_edit),
+                        item_edit->popup_toggle.ebox,
+                        FALSE, TRUE, 0);
     gtk_widget_show_all(GTK_WIDGET(item_edit));
+
     return GTK_WIDGET(item_edit);
 }
 
-static void
-check_popup_height_is_true (GtkWidget    *widget,
-                            GdkRectangle *allocation,
-                            gpointer user_data)
-{
-    GncItemEdit *item_edit = GNC_ITEM_EDIT(user_data);
-    GnucashSheet *sheet = item_edit->sheet;
-
-    // if a larger font is specified in css for the sheet, the popup returned height value
-    // on first pop does not reflect the true height but the minimum height so just to be
-    // sure check this value against the allocated one.
-    if (allocation->height != item_edit->popup_returned_height)
-    {
-        gtk_container_remove (GTK_CONTAINER(item_edit->sheet), item_edit->popup_item);
-
-        g_idle_add_full (G_PRIORITY_HIGH_IDLE,
-                        (GSourceFunc) gnc_item_edit_update, item_edit, NULL);
-    }
-}
 
 void
 gnc_item_edit_show_popup (GncItemEdit *item_edit)
@@ -980,11 +739,6 @@ gnc_item_edit_show_popup (GncItemEdit *item_edit)
     if (!gtk_widget_get_parent (item_edit->popup_item))
         gtk_layout_put (GTK_LAYOUT(sheet), item_edit->popup_item, popup_x, popup_y);
 
-    // Lets check popup height is the true height
-    item_edit->popup_returned_height = popup_h;
-    g_signal_connect_after (item_edit->popup_item, "size-allocate",
-                            G_CALLBACK(check_popup_height_is_true), item_edit);
-
     gtk_widget_set_size_request (item_edit->popup_item, popup_w - 1, popup_h);
 
     toggle = GTK_TOGGLE_BUTTON(item_edit->popup_toggle.tbutton);
diff --git a/gnucash/register/register-gnome/gnucash-item-edit.h b/gnucash/register/register-gnome/gnucash-item-edit.h
index 2be4d24..7b8969a 100644
--- a/gnucash/register/register-gnome/gnucash-item-edit.h
+++ b/gnucash/register/register-gnome/gnucash-item-edit.h
@@ -37,10 +37,6 @@
 #define GNC_ITEM_EDIT_CLASS(k)    (G_TYPE_CHECK_CLASS_CAST ((k), GNC_TYPE_ITEM_EDIT, GncItemEditClass))
 #define GNC_IS_ITEM_EDIT(o)       (G_TYPE_CHECK_INSTANCE_TYPE((o), GNC_TYPE_ITEM_EDIT))
 
-#define GNC_TYPE_ITEM_EDIT_TB        (gnc_item_edit_tb_get_type ())
-#define GNC_ITEM_EDIT_TB(o)          (G_TYPE_CHECK_INSTANCE_CAST((o), GNC_TYPE_ITEM_EDIT_TB, GncItemEditTb))
-#define GNC_ITEM_EDIT_TB_CLASS(k)    (G_TYPE_CHECK_CLASS_CAST ((k), GNC_TYPE_ITEM_EDIT_TB, GncItemEditTbClass))
-#define GNC_IS_ITEM_EDIT_TB(o)       (G_TYPE_CHECK_INSTANCE_TYPE((o), GNC_TYPE_ITEM_EDIT_TB))
 
 typedef int (*PopupGetHeight) (GtkWidget *item,
                                int space_available,
@@ -89,11 +85,6 @@ typedef struct
     PopupPostShow    popup_post_show;
     PopupGetWidth    popup_get_width;
     gpointer         popup_user_data;
-    gint             popup_returned_height;
-
-    GtkBorder        padding;
-    GtkBorder        margin;
-    GtkBorder        border;
 
     /* Where are we */
     VirtualLocation virt_loc;
@@ -106,28 +97,6 @@ typedef struct
     GtkBoxClass parent_class;
 } GncItemEditClass;
 
-typedef struct
-{
-    GtkToggleButton tb;
-    GnucashSheet *sheet;
-} GncItemEditTb;
-
-typedef struct
-{
-    GtkToggleButtonClass parent_class;
-
-    void (* toggled) (GncItemEditTb *item_edit_tb);
-} GncItemEditTbClass;
-
-typedef enum
-{
-    left,
-    right,
-    top,
-    bottom,
-    left_right,
-    top_bottom,
-} Sides;
 
 GType gnc_item_edit_get_type (void);
 
@@ -151,6 +120,8 @@ void gnc_item_edit_set_popup (GncItemEdit    *item_edit,
 void gnc_item_edit_show_popup (GncItemEdit *item_edit);
 void gnc_item_edit_hide_popup (GncItemEdit *item_edit);
 
+int gnc_item_edit_get_toggle_offset (int row_height);
+
 void gnc_item_edit_cut_clipboard (GncItemEdit *item_edit);
 void gnc_item_edit_copy_clipboard (GncItemEdit *item_edit);
 void gnc_item_edit_paste_clipboard (GncItemEdit *item_edit);
@@ -159,11 +130,5 @@ gboolean gnc_item_edit_get_has_selection (GncItemEdit *item_edit);
 void gnc_item_edit_focus_in (GncItemEdit *item_edit);
 void gnc_item_edit_focus_out (GncItemEdit *item_edit);
 
-gint gnc_item_edit_get_margin (GncItemEdit *item_edit, Sides side);
-gint gnc_item_edit_get_padding_border (GncItemEdit *item_edit, Sides side);
-
-GType gnc_item_edit_tb_get_type (void);
-GtkWidget *gnc_item_edit_tb_new (GnucashSheet *sheet);
-
 /** @} */
 #endif /* GNUCASH_ITEM_EDIT_H */
diff --git a/gnucash/register/register-gnome/gnucash-sheet-private.c b/gnucash/register/register-gnome/gnucash-sheet-private.c
index e71db31..955f607 100644
--- a/gnucash/register/register-gnome/gnucash-sheet-private.c
+++ b/gnucash/register/register-gnome/gnucash-sheet-private.c
@@ -381,7 +381,6 @@ draw_cell (GnucashSheet *sheet,
            cairo_t *cr,
            int x, int y, int width, int height)
 {
-    GncItemEdit *item_edit = GNC_ITEM_EDIT(sheet->item_editor);
     Table *table = sheet->table;
     PhysicalCellBorders borders;
     const char *text;
@@ -399,8 +398,11 @@ draw_cell (GnucashSheet *sheet,
 
     gtk_style_context_save (stylectxt);
 
-    // Get the color type and apply the css class
-    color_type = gnc_table_get_color (table, virt_loc, &hatching);
+    // Get the background and foreground color types and apply the css class
+    color_type = gnc_table_get_bg_color (table, virt_loc, &hatching);
+    gnucash_get_style_classes (sheet, stylectxt, color_type);
+
+    color_type = gnc_table_get_fg_color (table, virt_loc);
     gnucash_get_style_classes (sheet, stylectxt, color_type);
 
     // Are we in a read-only row? Then make the background color somewhat more grey.
@@ -415,10 +417,7 @@ draw_cell (GnucashSheet *sheet,
     gtk_render_background (stylectxt, cr, x, y, width, height);
 
     gdk_rgba_parse (&color, "black");
-    if (gtk_style_context_get_state (stylectxt) == GTK_STATE_FLAG_INSENSITIVE)
-        gnc_style_context_get_background_color (stylectxt, GTK_STATE_FLAG_INSENSITIVE, &color);
-    else
-        gnc_style_context_get_background_color (stylectxt, GTK_STATE_FLAG_NORMAL, &color);
+    gnc_style_context_get_background_color (stylectxt, GTK_STATE_FLAG_NORMAL, &color);
     bg_color = &color;
 
     get_cell_borders (sheet, virt_loc, &borders);
@@ -525,19 +524,39 @@ draw_cell (GnucashSheet *sheet,
         goto exit;
     }
 
-    pango_layout_get_pixel_extents (layout, NULL, &logical_rect);
+    pango_layout_get_pixel_extents(layout,
+                                   NULL,
+                                   &logical_rect);
 
-    gnucash_sheet_set_text_bounds (sheet, &rect, x, y, width, height);
+    rect.x      = x + CELL_HPADDING;
+    rect.y      = y + CELL_VPADDING;
+    rect.width  = MAX (0, width - (2 * CELL_HPADDING));
+    rect.height = height - 2;
 
     cairo_save (cr);
     cairo_rectangle (cr, rect.x, rect.y, rect.width, rect.height);
     cairo_clip (cr);
 
-    x_offset = gnucash_sheet_get_text_offset (sheet, virt_loc,
-                                              rect.width, logical_rect.width);
-
-    gtk_render_layout (stylectxt, cr, rect.x + x_offset,
-                       rect.y + gnc_item_edit_get_padding_border (item_edit, top), layout);
+    switch (gnc_table_get_align (table, virt_loc))
+    {
+    default:
+    case CELL_ALIGN_LEFT:
+        x_offset = 0;
+        break;
+
+    case CELL_ALIGN_RIGHT:
+        x_offset = width - 2 * CELL_HPADDING - logical_rect.width - 3;
+        break;
+
+    case CELL_ALIGN_CENTER:
+        if (logical_rect.width > width - 2 * CELL_HPADDING)
+            x_offset = 0;
+        else
+            x_offset = (width - 2 * CELL_HPADDING -
+                        logical_rect.width) / 2;
+        break;
+    }
+    gtk_render_layout (stylectxt, cr, rect.x + x_offset + 1, rect.y, layout);
 
     cairo_restore (cr);
 
@@ -682,7 +701,7 @@ gnucash_sheet_draw_cursor (GnucashCursor *cursor, cairo_t *cr)
     cairo_stroke (cr);
 
     // make the bottom line thicker
-    cairo_move_to (cr, cursor->x - x + 0.5, cursor->y - y + cursor->h - 3.5);
+    cairo_move_to (cr, cursor->x - x + 0.5, cursor->y - y + cursor->h - 1.5);
     cairo_rel_line_to (cr, cursor->w, 0);
     cairo_set_line_width (cr, 1.0);
     cairo_stroke (cr);
diff --git a/gnucash/register/register-gnome/gnucash-sheet.c b/gnucash/register/register-gnome/gnucash-sheet.c
index 311ab1b..d8a6cea 100644
--- a/gnucash/register/register-gnome/gnucash-sheet.c
+++ b/gnucash/register/register-gnome/gnucash-sheet.c
@@ -261,47 +261,6 @@ gnucash_sheet_deactivate_cursor_cell (GnucashSheet *sheet)
     gnucash_sheet_redraw_block (sheet, virt_loc.vcell_loc);
 }
 
-void
-gnucash_sheet_set_text_bounds (GnucashSheet *sheet, GdkRectangle *rect,
-                               gint x, gint y, gint width, gint height)
-{
-    GncItemEdit *item_edit = GNC_ITEM_EDIT(sheet->item_editor);
-
-    rect->x = x + gnc_item_edit_get_margin (item_edit, left);
-    rect->y = y + gnc_item_edit_get_margin (item_edit, top);
-    rect->width = MAX (0, width - gnc_item_edit_get_margin (item_edit, left_right));
-    rect->height = height - gnc_item_edit_get_margin (item_edit, top_bottom);
-}
-
-gint
-gnucash_sheet_get_text_offset (GnucashSheet *sheet, const VirtualLocation virt_loc,
-                                gint rect_width, gint logical_width)
-{
-    GncItemEdit *item_edit = GNC_ITEM_EDIT(sheet->item_editor);
-    Table *table = sheet->table;
-    gint x_offset = 0;
-
-    // Get the alignment of the cell
-    switch (gnc_table_get_align (table, virt_loc))
-    {
-    default:
-    case CELL_ALIGN_LEFT:
-        x_offset = gnc_item_edit_get_padding_border (item_edit, left);
-        break;
-
-    case CELL_ALIGN_RIGHT:
-        x_offset = rect_width - gnc_item_edit_get_padding_border (item_edit, right) - logical_width - 1;
-        break;
-
-    case CELL_ALIGN_CENTER:
-        if (logical_width > rect_width)
-            x_offset = 0;
-        else
-            x_offset = (rect_width - logical_width) / 2;
-        break;
-    }
-    return x_offset;
-}
 
 static gint
 gnucash_sheet_get_text_cursor_position (GnucashSheet *sheet, const VirtualLocation virt_loc)
@@ -312,7 +271,7 @@ gnucash_sheet_get_text_cursor_position (GnucashSheet *sheet, const VirtualLocati
     PangoLayout *layout;
     PangoRectangle logical_rect;
     GdkRectangle rect;
-    gint x, y, width, height;
+    gint x, y, w, h;
     gint index, trailing;
     gboolean result;
     gint x_offset = 0;
@@ -321,7 +280,7 @@ gnucash_sheet_get_text_cursor_position (GnucashSheet *sheet, const VirtualLocati
         return 0;
 
     // Get the item_edit position
-    gnc_item_edit_get_pixel_coords (item_edit, &x, &y, &width, &height);
+    gnc_item_edit_get_pixel_coords (item_edit, &x, &y, &w, &h);
 
     layout = gtk_widget_create_pango_layout (GTK_WIDGET (sheet), text);
 
@@ -330,14 +289,35 @@ gnucash_sheet_get_text_cursor_position (GnucashSheet *sheet, const VirtualLocati
 
     pango_layout_get_pixel_extents (layout, NULL, &logical_rect);
 
-    gnucash_sheet_set_text_bounds (sheet, &rect, x, y, width, height);
+    rect.x      = x + CELL_HPADDING;
+    rect.y      = y + CELL_VPADDING;
+    rect.width  = MAX (0, w - (2 * CELL_HPADDING));
+    rect.height = h - 2;
+
+    // Get the alignment of the cell
+    switch (gnc_table_get_align (table, virt_loc))
+    {
+    default:
+    case CELL_ALIGN_LEFT:
+        x_offset = 0;
+        break;
+
+    case CELL_ALIGN_RIGHT:
+        x_offset = w - 2 * CELL_HPADDING - logical_rect.width - 3;
+        break;
 
-    x_offset = gnucash_sheet_get_text_offset (sheet, virt_loc,
-                                              rect.width, logical_rect.width);
+    case CELL_ALIGN_CENTER:
+        if (logical_rect.width > w - 2 * CELL_HPADDING)
+            x_offset = 0;
+        else
+            x_offset = (w - 2 * CELL_HPADDING -
+                        logical_rect.width) / 2;
+        break;
+    }
 
     result = pango_layout_xy_to_index (layout,
                  PANGO_SCALE * (sheet->button_x - rect.x - x_offset),
-                 PANGO_SCALE * (height/2), &index, &trailing);
+                 PANGO_SCALE * (h/2), &index, &trailing);
 
     g_object_unref (layout);
 
@@ -2210,7 +2190,6 @@ gnucash_sheet_col_max_width (GnucashSheet *sheet, gint virt_col, gint cell_col)
     SheetBlock *block;
     SheetBlockStyle *style;
     PangoLayout *layout = gtk_widget_create_pango_layout (GTK_WIDGET (sheet), "");
-    GncItemEdit *item_edit = GNC_ITEM_EDIT(sheet->item_editor);
 
     g_return_val_if_fail (virt_col >= 0, 0);
     g_return_val_if_fail (virt_col < sheet->num_virt_cols, 0);
@@ -2250,7 +2229,7 @@ gnucash_sheet_col_max_width (GnucashSheet *sheet, gint virt_col, gint cell_col)
                 pango_layout_set_text (layout, text, strlen (text));
                 pango_layout_get_pixel_size (layout, &width, NULL);
 
-                width += gnc_item_edit_get_margin (item_edit, left_right);
+                width += 2 * CELL_HPADDING;
 
                 max = MAX (max, width);
             }
@@ -2428,46 +2407,52 @@ gnucash_sheet_table_load (GnucashSheet *sheet, gboolean do_scroll)
 
 /*************************************************************/
 
-/** Map a cell color type to a css style class. */
+/** Map a cell type to a css style class. */
 void
 gnucash_get_style_classes (GnucashSheet *sheet, GtkStyleContext *stylectxt,
                            RegisterColor field_type)
 {
     gchar *full_class, *style_class = NULL;
 
-    if (field_type >= COLOR_NEGATIVE) // Require a Negative fg color
-    {
-        gtk_style_context_add_class (stylectxt, "negative-numbers");
-        field_type -= COLOR_NEGATIVE;
-    }
-
     switch (field_type)
     {
     default:
-    case COLOR_UNDEFINED:
+    case COLOR_UNKNOWN_BG:
+    case COLOR_UNKNOWN_FG:
         gtk_style_context_add_class (stylectxt, GTK_STYLE_CLASS_BACKGROUND);
         return;
 
-    case COLOR_HEADER:
+    case COLOR_NEGATIVE:
+        gtk_style_context_add_class (stylectxt, "negative-numbers");
+        return;
+
+    case COLOR_HEADER_BG:
+    case COLOR_HEADER_FG:
         style_class = "header";
         break;
 
-    case COLOR_PRIMARY:
+    case COLOR_PRIMARY_BG:
+    case COLOR_PRIMARY_FG:
         style_class = "primary";
         break;
 
-    case COLOR_PRIMARY_ACTIVE:
-    case COLOR_SECONDARY_ACTIVE:
-    case COLOR_SPLIT_ACTIVE:
+    case COLOR_PRIMARY_BG_ACTIVE:
+    case COLOR_PRIMARY_FG_ACTIVE:
+    case COLOR_SECONDARY_BG_ACTIVE:
+    case COLOR_SECONDARY_FG_ACTIVE:
+    case COLOR_SPLIT_BG_ACTIVE:
+    case COLOR_SPLIT_FG_ACTIVE:
         gtk_style_context_set_state (stylectxt, GTK_STATE_FLAG_SELECTED);
         style_class = "cursor";
         break;
 
-    case COLOR_SECONDARY:
+    case COLOR_SECONDARY_BG:
+    case COLOR_SECONDARY_FG:
         style_class = "secondary";
         break;
 
-    case COLOR_SPLIT:
+    case COLOR_SPLIT_BG:
+    case COLOR_SPLIT_FG:
         style_class = "split";
         break;
     }
diff --git a/gnucash/register/register-gnome/gnucash-sheet.h b/gnucash/register/register-gnome/gnucash-sheet.h
index f729e8f..b571d03 100644
--- a/gnucash/register/register-gnome/gnucash-sheet.h
+++ b/gnucash/register/register-gnome/gnucash-sheet.h
@@ -33,6 +33,10 @@
  * @brief Public declarations of GnucashSheet class.
  */
 
+#define CELL_VPADDING 2
+#define CELL_HPADDING 5
+
+
 #define GNUCASH_TYPE_SHEET     (gnucash_sheet_get_type ())
 #define GNUCASH_SHEET(obj)     (G_TYPE_CHECK_INSTANCE_CAST((obj), GNUCASH_TYPE_SHEET, GnucashSheet))
 #define GNUCASH_SHEET_CLASS(k) (G_TYPE_CHECK_CLASS_CAST ((k), GNUCASH_TYPE_SHEET))
@@ -104,11 +108,5 @@ void gnucash_sheet_set_window (GnucashSheet *sheet, GtkWidget *window);
 void gnucash_get_style_classes (GnucashSheet *sheet, GtkStyleContext *stylectxt,
                                 RegisterColor field_type);
 
-void gnucash_sheet_set_text_bounds (GnucashSheet *sheet, GdkRectangle *rect,
-                                    gint x, gint y, gint width, gint height);
-
-gint gnucash_sheet_get_text_offset (GnucashSheet *sheet, const VirtualLocation virt_loc,
-                                    gint rect_width, gint logical_width);
-
 /** @} */
 #endif
diff --git a/gnucash/register/register-gnome/gnucash-style.c b/gnucash/register/register-gnome/gnucash-style.c
index e999620..dcadb7c 100644
--- a/gnucash/register/register-gnome/gnucash-style.c
+++ b/gnucash/register/register-gnome/gnucash-style.c
@@ -169,7 +169,6 @@ set_dimensions_pass_one (GnucashSheet *sheet, CellBlock *cursor,
     int row, col;
     gint max_height = -1;
     PangoLayout *layout;
-    GncItemEdit *item_edit = GNC_ITEM_EDIT(sheet->item_editor);
 
     /* g_return_if_fail (font != NULL); */
 
@@ -197,17 +196,13 @@ set_dimensions_pass_one (GnucashSheet *sheet, CellBlock *cursor,
                 layout = gtk_widget_create_pango_layout (GTK_WIDGET (sheet), text);
                 pango_layout_get_pixel_size (layout, &width, &cd->pixel_height);
                 g_object_unref (layout);
-                width += gnc_item_edit_get_margin (item_edit, left_right) +
-                         gnc_item_edit_get_padding_border (item_edit, left_right);
-
-                cd->pixel_height += gnc_item_edit_get_margin (item_edit, top_bottom) +
-                                    gnc_item_edit_get_padding_border (item_edit, top_bottom);
+                width += 2 * CELL_HPADDING;
+                cd->pixel_height += 2 * CELL_VPADDING;
             }
             else
             {
                 width = 0;
-                cd->pixel_height = gnc_item_edit_get_margin (item_edit, top_bottom) +
-                                   gnc_item_edit_get_padding_border (item_edit, top_bottom);
+                cd->pixel_height = (2 * CELL_VPADDING);
             }
 
             max_height = MAX(max_height, cd->pixel_height);
@@ -215,10 +210,9 @@ set_dimensions_pass_one (GnucashSheet *sheet, CellBlock *cursor,
             if (cd->pixel_width > 0)
                 continue;
 
-            // This is used on new account popup cells to get the default
-            // width of text plus toggle button.
             if (cell && cell->is_popup)
-                width += cd->pixel_height; // toggle button is square, use cell height
+                width += gnc_item_edit_get_toggle_offset
+                         (cd->pixel_height);
 
             cd->pixel_width = MAX (cd->pixel_width, width);
         }
@@ -245,7 +239,6 @@ static void
 set_dimensions_pass_two (GnucashSheet *sheet, int default_width)
 {
     SheetBlockStyle *style;
-    GncItemEdit *item_edit = GNC_ITEM_EDIT(sheet->item_editor);
     BlockDimensions *dimensions;
     CellDimensions *cd;
     GTable *cd_table;
@@ -322,8 +315,7 @@ set_dimensions_pass_two (GnucashSheet *sheet, int default_width)
                 pango_layout_get_pixel_size (layout, &sample_width, NULL);
                 g_object_unref (layout);
                 /*sample_width = gdk_string_width (font, text);*/
-                sample_width += gnc_item_edit_get_margin (item_edit, left_right) +
-                                gnc_item_edit_get_padding_border (item_edit, left_right);
+                sample_width += 2 * CELL_HPADDING;
             }
             else
                 sample_width = 0;



Summary of changes:
 gnucash/gnucash-310.css                            |  13 +-
 gnucash/gnucash-320.css                            |  11 +-
 gnucash/register/ledger-core/gncEntryLedgerModel.c |  49 ++--
 .../register/ledger-core/split-register-model.c    | 217 ++++++++-------
 gnucash/register/register-core/table-allgui.c      |  57 +++-
 gnucash/register/register-core/table-allgui.h      |  42 ++-
 gnucash/register/register-core/table-model.c       |  72 +++--
 gnucash/register/register-core/table-model.h       |  29 +-
 gnucash/register/register-gnome/gnucash-header.c   |  58 ++--
 .../register/register-gnome/gnucash-item-edit.c    | 308 +++------------------
 .../register/register-gnome/gnucash-item-edit.h    |  39 +--
 .../register-gnome/gnucash-sheet-private.c         |  49 +++-
 gnucash/register/register-gnome/gnucash-sheet.c    | 113 ++++----
 gnucash/register/register-gnome/gnucash-sheet.h    |  10 +-
 gnucash/register/register-gnome/gnucash-style.c    |  20 +-
 15 files changed, 476 insertions(+), 611 deletions(-)



More information about the gnucash-changes mailing list