const char * gnc_table_get_entry (Table *table, VirtualLocation virt_loc) { TableGetEntryHandler entry_handler; const char *entry; BasicCell *cell; cell = gnc_table_get_cell (table, virt_loc); if (!cell || !cell->cell_name) return ""; if (virt_cell_loc_equal (table->current_cursor_loc.vcell_loc, virt_loc.vcell_loc)) { CellIOFlags io_flags; io_flags = gnc_table_get_io_flags (table, virt_loc); if (io_flags & XACC_CELL_ALLOW_INPUT) return cell->value; } entry_handler = gnc_table_model_get_entry_handler (table->model, cell->cell_name); if (!entry_handler) return ""; entry = entry_handler (virt_loc, TRUE, NULL, table->model->handler_user_data); if (!entry) entry = ""; return entry; }
/* gnc_table_verify_cursor_position checks the location of the cursor * with respect to a virtual location, and repositions the cursor * if necessary. Returns true if the cell cursor was repositioned. */ gboolean gnc_table_verify_cursor_position (Table *table, VirtualLocation virt_loc) { gboolean do_move = FALSE; gboolean moved_cursor = FALSE; if (!table) return FALSE; /* Someone may be trying to intentionally invalidate the cursor, in * which case the physical addresses could be out of bounds. For * example, in order to unmap it in preparation for a reconfig. * So, if the specified location is out of bounds, then the cursor * MUST be moved. */ if (gnc_table_virtual_cell_out_of_bounds (table, virt_loc.vcell_loc)) do_move = TRUE; if (!virt_cell_loc_equal (virt_loc.vcell_loc, table->current_cursor_loc.vcell_loc)) do_move = TRUE; if (do_move) { gnc_table_move_cursor_gui (table, virt_loc); moved_cursor = TRUE; } else if (!virt_loc_equal (virt_loc, table->current_cursor_loc)) { table->current_cursor_loc = virt_loc; moved_cursor = TRUE; } return moved_cursor; }
static const char * get_taxval_entry (VirtualLocation virt_loc, gboolean translate, gboolean *conditionally_changed, gpointer user_data) { GncEntryLedger *ledger = user_data; gnc_numeric value; /* Check if this is the current cursor */ if (virt_cell_loc_equal (ledger->table->current_cursor_loc.vcell_loc, virt_loc.vcell_loc)) { /* Sign attention: this function works with values as seen * on-screen in the ledger, so they are always in the proper sign. */ gnc_entry_ledger_compute_value (ledger, NULL, &value); } else { GncEntry *entry = gnc_entry_ledger_get_entry (ledger, virt_loc.vcell_loc); if (entry == gnc_entry_ledger_get_blank_entry (ledger)) return NULL; /* Ledger should display values with the same sign as on the document * so get the document value instead of the internal value here. */ value = gncEntryGetDocTaxValue (entry, TRUE, ledger->is_cust_doc, ledger->is_credit_note); } return xaccPrintAmount (value, gnc_default_print_info (FALSE)); }
static const char * get_taxval_entry (VirtualLocation virt_loc, gboolean translate, gboolean *conditionally_changed, gpointer user_data) { GncEntryLedger *ledger = user_data; gnc_numeric value; /* Check if this is the current cursor */ if (virt_cell_loc_equal (ledger->table->current_cursor_loc.vcell_loc, virt_loc.vcell_loc)) { gnc_entry_ledger_compute_value (ledger, NULL, &value); } else { GncEntry *entry = gnc_entry_ledger_get_entry (ledger, virt_loc.vcell_loc); if (entry == gnc_entry_ledger_get_blank_entry (ledger)) return NULL; value = gncEntryReturnTaxValue (entry, ledger->is_cust_doc); } /* Credit notes have negative values, but the ledger should * display it as on the document, meaning positive. * So reverse the value for credit notes. */ if (ledger->is_credit_note) value = gnc_numeric_neg (value); return xaccPrintAmount (value, gnc_default_print_info (FALSE)); }
static const char * get_value_entry (VirtualLocation virt_loc, gboolean translate, gboolean *conditionally_changed, gpointer user_data) { GncEntryLedger *ledger = user_data; gnc_numeric value; /* Credit notes need some attention here: the ledger displays values * as on the document, meaning positive for credit notes. Credit note * values are negative internally though. So depending on which values * are used to calculate the subtotal, the resulting subtotal has to be * sign-reversed before displaying. */ /* Check if this is the current cursor */ if (virt_cell_loc_equal (ledger->table->current_cursor_loc.vcell_loc, virt_loc.vcell_loc)) { gnc_entry_ledger_compute_value (ledger, &value, NULL); /* Credit note info: this function works with values as seen * on-screen in the ledger, so they are always in the proper sign. * As per the above no sign reversal is needed for * credit note type ledgers. */ } else { GncEntry *entry = gnc_entry_ledger_get_entry (ledger, virt_loc.vcell_loc); if (entry == gnc_entry_ledger_get_blank_entry (ledger)) return NULL; value = gncEntryReturnValue (entry, ledger->is_cust_doc); /* Credit note info: this function works with internal values, * so they are negative for credit note type ledgers and have to * be sign-reversed as per the above. */ if (ledger->is_credit_note) value = gnc_numeric_neg (value); } return xaccPrintAmount (value, gnc_default_print_info (FALSE)); }
static guint32 gnc_entry_ledger_get_bg_color (VirtualLocation virt_loc, gboolean *hatching, gpointer user_data) { GncEntryLedger *ledger = user_data; VirtualCell *vcell; guint32 bg_color; gboolean is_current; if (hatching) *hatching = FALSE; bg_color = 0xffffff; /* white */ if (!ledger) return bg_color; if (gnc_table_virtual_location_in_header (ledger->table, virt_loc)) return reg_colors.header_bg_color; vcell = gnc_table_get_virtual_cell (ledger->table, virt_loc.vcell_loc); if (!vcell || !vcell->cellblock) return bg_color; if ((virt_loc.phys_col_offset < vcell->cellblock->start_col) || (virt_loc.phys_col_offset > vcell->cellblock->stop_col)) return bg_color; 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 ? reg_colors.primary_active_bg_color : reg_colors.secondary_active_bg_color; return vcell->start_primary_color ? reg_colors.primary_bg_color : reg_colors.secondary_bg_color; }
static gboolean gnc_entry_ledger_get_taxable_value (VirtualLocation virt_loc, gboolean translate, gboolean *conditionally_changed, gpointer user_data) { GncEntryLedger *ledger = user_data; gboolean is_current; is_current = virt_cell_loc_equal(ledger->table->current_cursor_loc.vcell_loc, virt_loc.vcell_loc); if (is_current) return gnc_entry_ledger_get_checkmark (ledger, ENTRY_TAXABLE_CELL); else { const char *valstr = get_taxable_entry (virt_loc, translate, conditionally_changed, user_data); if (valstr && *valstr == 'X') return TRUE; } return FALSE; }