Change source files gnucash-sheet/header.* for space and tabs

This commit is contained in:
Robert Fewell 2020-11-11 10:38:02 +00:00
parent 8ad9d0a22d
commit fdbbc1305e
5 changed files with 240 additions and 274 deletions

View File

@ -625,7 +625,8 @@ gnc_header_init (GncHeader *header)
header->width = 400; header->width = 400;
header->style = NULL; header->style = NULL;
gtk_widget_add_events(GTK_WIDGET(header), (GDK_EXPOSURE_MASK gtk_widget_add_events (GTK_WIDGET(header),
(GDK_EXPOSURE_MASK
| GDK_BUTTON_PRESS_MASK | GDK_BUTTON_PRESS_MASK
| GDK_BUTTON_RELEASE_MASK | GDK_BUTTON_RELEASE_MASK
| GDK_POINTER_MOTION_MASK | GDK_POINTER_MOTION_MASK

View File

@ -326,8 +326,8 @@ draw_cell_line (cairo_t *cr, GdkRGBA *bg_color,
} }
static void static void
draw_hatching (cairo_t *cr, draw_hatching (cairo_t *cr, double x, double y,
double x, double y, G_GNUC_UNUSED double width, double height) G_GNUC_UNUSED double width, double height)
{ {
GdkRGBA *fg_color; GdkRGBA *fg_color;
double h_x = x + 2.5; double h_x = x + 2.5;
@ -375,10 +375,8 @@ draw_divider_line (cairo_t *cr, VirtualLocation virt_loc,
} }
static void static void
draw_cell (GnucashSheet *sheet, draw_cell (GnucashSheet *sheet, SheetBlock *block,
SheetBlock *block, VirtualLocation virt_loc, cairo_t *cr,
VirtualLocation virt_loc,
cairo_t *cr,
int x, int y, int width, int height) int x, int y, int width, int height)
{ {
GncItemEdit *item_edit = GNC_ITEM_EDIT(sheet->item_editor); GncItemEdit *item_edit = GNC_ITEM_EDIT(sheet->item_editor);
@ -554,10 +552,8 @@ exit:
} }
static void static void
draw_block (GnucashSheet *sheet, draw_block (GnucashSheet *sheet, SheetBlock *block,
SheetBlock *block, VirtualLocation virt_loc, cairo_t *cr,
VirtualLocation virt_loc,
cairo_t *cr,
int x, int y, int width, int height) int x, int y, int width, int height)
{ {
CellDimensions *cd; CellDimensions *cd;
@ -627,8 +623,7 @@ gnucash_sheet_draw_internal (GnucashSheet* sheet, cairo_t* cr,
return FALSE; return FALSE;
/* compute our initial values where we start drawing */ /* compute our initial values where we start drawing */
sheet_block = find_block_by_pixel (sheet, x, y, sheet_block = find_block_by_pixel (sheet, x, y, &virt_loc.vcell_loc);
&virt_loc.vcell_loc);
if (!sheet_block || !sheet_block->style) if (!sheet_block || !sheet_block->style)
return FALSE; return FALSE;
@ -637,8 +632,7 @@ gnucash_sheet_draw_internal (GnucashSheet* sheet, cairo_t* cr,
{ {
while (TRUE) while (TRUE)
{ {
sheet_block = gnucash_sheet_get_block sheet_block = gnucash_sheet_get_block (sheet, virt_loc.vcell_loc);
(sheet, virt_loc.vcell_loc);
if (!sheet_block || !sheet_block->style) if (!sheet_block || !sheet_block->style)
return TRUE; return TRUE;
@ -655,7 +649,6 @@ gnucash_sheet_draw_internal (GnucashSheet* sheet, cairo_t* cr,
draw_block (sheet, sheet_block, virt_loc, cr, draw_block (sheet, sheet_block, virt_loc, cr,
x, y, width, height); x, y, width, height);
} }
return TRUE; return TRUE;
} }

View File

@ -446,8 +446,7 @@ gnucash_sheet_activate_cursor_cell (GnucashSheet *sheet,
} }
gnucash_sheet_set_position (sheet, index + trailing); gnucash_sheet_set_position (sheet, index + trailing);
} }
sheet->direct_update_cell = sheet->direct_update_cell = gnucash_sheet_check_direct_update_cell (sheet, virt_loc);
gnucash_sheet_check_direct_update_cell (sheet, virt_loc);
} }
// when a gui refresh is called, we end up here so only grab the focus // when a gui refresh is called, we end up here so only grab the focus
// if the sheet is showing on the current plugin_page // if the sheet is showing on the current plugin_page
@ -526,7 +525,6 @@ gnucash_sheet_y_pixel_to_block (GnucashSheet *sheet, int y)
if (block->origin_y + block->style->dimensions->height > y) if (block->origin_y + block->style->dimensions->height > y)
break; break;
} }
return vcell_loc.virt_row; return vcell_loc.virt_row;
} }
@ -540,7 +538,6 @@ gnucash_sheet_compute_visible_range (GnucashSheet *sheet)
gint height; gint height;
gint cy; gint cy;
gint top_block; gint top_block;
// gint old_visible_blocks, old_visible_rows;
g_return_if_fail (sheet != NULL); g_return_if_fail (sheet != NULL);
g_return_if_fail (GNUCASH_IS_SHEET(sheet)); g_return_if_fail (GNUCASH_IS_SHEET(sheet));
@ -553,8 +550,6 @@ gnucash_sheet_compute_visible_range (GnucashSheet *sheet)
top_block = gnucash_sheet_y_pixel_to_block (sheet, cy); top_block = gnucash_sheet_y_pixel_to_block (sheet, cy);
// old_visible_blocks = sheet->num_visible_blocks;
// old_visible_rows = sheet->num_visible_phys_rows;
sheet->num_visible_blocks = 0; sheet->num_visible_blocks = 0;
sheet->num_visible_phys_rows = 0; sheet->num_visible_phys_rows = 0;
@ -787,8 +782,7 @@ gnucash_sheet_redraw_block (GnucashSheet *sheet, VirtualCellLocation vcell_loc)
gtk_widget_get_allocation (GTK_WIDGET(sheet), &alloc); gtk_widget_get_allocation (GTK_WIDGET(sheet), &alloc);
h = block->style->dimensions->height; h = block->style->dimensions->height;
w = MIN(block->style->dimensions->width, w = MIN(block->style->dimensions->width, alloc.width);
alloc.width);
gtk_widget_queue_draw_area (GTK_WIDGET(sheet), x, y, w + 1, h + 1); gtk_widget_queue_draw_area (GTK_WIDGET(sheet), x, y, w + 1, h + 1);
} }
@ -895,9 +889,7 @@ gnucash_sheet_modify_current_cell (GnucashSheet *sheet, const gchar *new_text)
Table *table = sheet->table; Table *table = sheet->table;
VirtualLocation virt_loc; VirtualLocation virt_loc;
int new_text_len; int new_text_len;
const char *retval; const char *retval;
int cursor_position, start_sel, end_sel; int cursor_position, start_sel, end_sel;
gnucash_cursor_get_virt (GNUCASH_CURSOR(sheet->cursor), &virt_loc); gnucash_cursor_get_virt (GNUCASH_CURSOR(sheet->cursor), &virt_loc);
@ -948,9 +940,7 @@ gnucash_sheet_direct_event(GnucashSheet *sheet, GdkEvent *event)
Table *table = sheet->table; Table *table = sheet->table;
VirtualLocation virt_loc; VirtualLocation virt_loc;
gboolean result; gboolean result;
char *new_text = NULL; char *new_text = NULL;
int cursor_position, start_sel, end_sel; int cursor_position, start_sel, end_sel;
int new_position, new_start, new_end; int new_position, new_start, new_end;
@ -1211,7 +1201,6 @@ gnucash_sheet_draw_cb (GtkWidget *widget, cairo_t *cr, G_GNUC_UNUSED gpointer da
GnucashSheet *sheet = GNUCASH_SHEET(widget); GnucashSheet *sheet = GNUCASH_SHEET(widget);
GtkStyleContext *context = gtk_widget_get_style_context (widget); GtkStyleContext *context = gtk_widget_get_style_context (widget);
GtkAllocation alloc; GtkAllocation alloc;
gboolean result; //FIXME
gtk_widget_get_allocation (widget, &alloc); gtk_widget_get_allocation (widget, &alloc);
@ -1220,7 +1209,6 @@ gnucash_sheet_draw_cb (GtkWidget *widget, cairo_t *cr, G_GNUC_UNUSED gpointer da
gtk_render_background (context, cr, 0, 0, alloc.width, alloc.height); gtk_render_background (context, cr, 0, 0, alloc.width, alloc.height);
gtk_style_context_restore (context); gtk_style_context_restore (context);
//FIXME what should be done with result being TRUE or FALSE
gnucash_sheet_draw_internal (sheet, cr, &alloc); gnucash_sheet_draw_internal (sheet, cr, &alloc);
gnucash_sheet_draw_cursor (sheet->cursor, cr); gnucash_sheet_draw_cursor (sheet->cursor, cr);
@ -1269,8 +1257,7 @@ gnucash_sheet_size_allocate (GtkWidget *widget, GtkAllocation *allocation)
virt_loc = sheet->table->current_cursor_loc; virt_loc = sheet->table->current_cursor_loc;
if (gnucash_sheet_cell_valid (sheet, virt_loc)) if (gnucash_sheet_cell_valid (sheet, virt_loc))
gnucash_sheet_show_row (sheet, gnucash_sheet_show_row (sheet, virt_loc.vcell_loc.virt_row);
virt_loc.vcell_loc.virt_row);
} }
gnc_header_request_redraw (GNC_HEADER(sheet->header_item)); gnc_header_request_redraw (GNC_HEADER(sheet->header_item));
LEAVE(" "); LEAVE(" ");
@ -1452,11 +1439,8 @@ gnucash_sheet_button_press_event (GtkWidget *widget, GdkEventButton *event)
{ {
GnucashSheet *sheet; GnucashSheet *sheet;
VirtualCell *vcell; VirtualCell *vcell;
gboolean changed_cells; //FIXME
VirtualLocation cur_virt_loc; VirtualLocation cur_virt_loc;
VirtualLocation new_virt_loc; VirtualLocation new_virt_loc;
Table *table; Table *table;
gboolean abort_move; gboolean abort_move;
gboolean button_1; gboolean button_1;
@ -1504,8 +1488,8 @@ gnucash_sheet_button_press_event (GtkWidget *widget, GdkEventButton *event)
sheet->button_x = -1; sheet->button_x = -1;
sheet->button_y = -1; sheet->button_y = -1;
if (!gnucash_sheet_find_loc_by_pixel(sheet, if (!gnucash_sheet_find_loc_by_pixel (sheet, event->x, event->y,
event->x, event->y, &new_virt_loc)) &new_virt_loc))
return TRUE; return TRUE;
sheet->button_x = event->x; sheet->button_x = event->x;
@ -1543,7 +1527,6 @@ gnucash_sheet_button_press_event (GtkWidget *widget, GdkEventButton *event)
if (abort_move) if (abort_move)
return TRUE; return TRUE;
//FIXME does something need to be done if changed_cells is true or false ?
gnucash_sheet_cursor_move (sheet, new_virt_loc); gnucash_sheet_cursor_move (sheet, new_virt_loc);
// if clicked in ocument link cell, run call back // if clicked in ocument link cell, run call back
@ -1623,7 +1606,6 @@ gnucash_sheet_clipboard_event (GnucashSheet *sheet, GdkEventKey *event)
} }
break; break;
} }
return handled; return handled;
} }
@ -1642,7 +1624,8 @@ gnucash_sheet_need_horizontal_scroll (GnucashSheet *sheet,
hscroll_val = (gint) gtk_adjustment_get_value (sheet->hadj); hscroll_val = (gint) gtk_adjustment_get_value (sheet->hadj);
// offset is the start of the cell for column // offset is the start of the cell for column
offset = gnc_header_get_cell_offset (GNC_HEADER(sheet->header_item), new_virt_loc->phys_col_offset, &cell_width); offset = gnc_header_get_cell_offset (GNC_HEADER(sheet->header_item),
new_virt_loc->phys_col_offset, &cell_width);
if (((offset + cell_width) > sheet->window_width) || (offset < hscroll_val)) if (((offset + cell_width) > sheet->window_width) || (offset < hscroll_val))
gtk_adjustment_set_value (sheet->hadj, offset); gtk_adjustment_set_value (sheet->hadj, offset);
@ -1670,14 +1653,12 @@ process_motion_keys (GnucashSheet *sheet, GdkEventKey *event, gboolean *pass_on,
if (event->state & GDK_SHIFT_MASK) if (event->state & GDK_SHIFT_MASK)
{ {
*direction = GNC_TABLE_TRAVERSE_LEFT; *direction = GNC_TABLE_TRAVERSE_LEFT;
gnc_table_move_tab (sheet->table, new_virt_loc, gnc_table_move_tab (sheet->table, new_virt_loc, FALSE);
FALSE);
} }
else else
{ {
*direction = GNC_TABLE_TRAVERSE_RIGHT; *direction = GNC_TABLE_TRAVERSE_RIGHT;
gnc_table_move_tab (sheet->table, new_virt_loc, gnc_table_move_tab (sheet->table, new_virt_loc, TRUE);
TRUE);
} }
break; break;
case GDK_KEY_KP_Page_Up: case GDK_KEY_KP_Page_Up:
@ -1719,16 +1700,13 @@ process_motion_keys (GnucashSheet *sheet, GdkEventKey *event, gboolean *pass_on,
if (event->keyval == GDK_KEY_Menu || if (event->keyval == GDK_KEY_Menu ||
(event->state & GDK_MODIFIER_INTENT_PRIMARY_ACCELERATOR)) (event->state & GDK_MODIFIER_INTENT_PRIMARY_ACCELERATOR))
{ {
GncItemEdit *item_edit; GncItemEdit *item_edit = GNC_ITEM_EDIT(sheet->item_editor);
item_edit = GNC_ITEM_EDIT (sheet->item_editor); if (gnc_table_confirm_change (sheet->table, cur_virt_loc))
if (gnc_table_confirm_change (sheet->table,
cur_virt_loc))
gnc_item_edit_show_popup (item_edit); gnc_item_edit_show_popup (item_edit);
/* Clear the saved selection for the new cell. */ /* Clear the saved selection for the new cell. */
sheet->pos = sheet->bound; sheet->pos = sheet->bound;
return TRUE; return TRUE;
} }
@ -1994,7 +1972,6 @@ gnucash_sheet_block_set_from_table (GnucashSheet *sheet,
gnucash_sheet_style_ref (sheet, block->style); gnucash_sheet_style_ref (sheet, block->style);
return TRUE; return TRUE;
} }
return FALSE; return FALSE;
} }
@ -2083,15 +2060,12 @@ void
gnucash_sheet_set_scroll_region (GnucashSheet *sheet) gnucash_sheet_set_scroll_region (GnucashSheet *sheet)
{ {
guint new_h, new_w; guint new_h, new_w;
// GtkWidget *widget;
GtkAllocation alloc; GtkAllocation alloc;
guint old_h, old_w; guint old_h, old_w;
if (!sheet) if (!sheet)
return; return;
// widget = GTK_WIDGET(sheet);
if (!sheet->header_item || !GNC_HEADER(sheet->header_item)->style) if (!sheet->header_item || !GNC_HEADER(sheet->header_item)->style)
return; return;
@ -2186,7 +2160,6 @@ gnucash_sheet_recompute_block_offsets (GnucashSheet *sheet)
if (i > 0 && block && block->visible) if (i > 0 && block && block->visible)
height += block->style->dimensions->height; height += block->style->dimensions->height;
} }
sheet->height = height; sheet->height = height;
} }
@ -2376,7 +2349,8 @@ gnucash_sheet_init (GnucashSheet *sheet)
gnucash_sheet_block_construct, gnucash_sheet_block_construct,
gnucash_sheet_block_destroy, sheet); gnucash_sheet_block_destroy, sheet);
gtk_widget_add_events(GTK_WIDGET(sheet), (GDK_EXPOSURE_MASK gtk_widget_add_events (GTK_WIDGET(sheet),
(GDK_EXPOSURE_MASK
| GDK_BUTTON_PRESS_MASK | GDK_BUTTON_PRESS_MASK
| GDK_BUTTON_RELEASE_MASK | GDK_BUTTON_RELEASE_MASK
| GDK_POINTER_MOTION_MASK | GDK_POINTER_MOTION_MASK
@ -2422,7 +2396,8 @@ gnucash_sheet_get_type (void)
static gboolean static gboolean
gnucash_sheet_tooltip (GtkWidget *widget, gint x, gint y, gnucash_sheet_tooltip (GtkWidget *widget, gint x, gint y,
gboolean keyboard_mode, GtkTooltip *tooltip, gboolean keyboard_mode,
GtkTooltip *tooltip,
gpointer user_data) gpointer user_data)
{ {
GnucashSheet *sheet = GNUCASH_SHEET(widget); GnucashSheet *sheet = GNUCASH_SHEET(widget);

View File

@ -116,9 +116,6 @@ GncItemEdit *gnucash_sheet_get_item_edit (GnucashSheet *sheet);
void gnucash_sheet_set_popup (GnucashSheet *sheet, GtkWidget *popup, gpointer data); void gnucash_sheet_set_popup (GnucashSheet *sheet, GtkWidget *popup, gpointer data);
void gnucash_sheet_goto_virt_loc (GnucashSheet *sheet, VirtualLocation virt_loc); void gnucash_sheet_goto_virt_loc (GnucashSheet *sheet, VirtualLocation virt_loc);
void gnucash_sheet_refresh_from_prefs (GnucashSheet *sheet); void gnucash_sheet_refresh_from_prefs (GnucashSheet *sheet);
//Table *gnucash_sheet_get_table (GnucashSheet *sheet);
//gint gnucash_sheet_get_num_virt_rows (GnucashSheet *sheet);
//gint gnucash_sheet_get_num_virt_cols (GnucashSheet *sheet);
gboolean gnucash_sheet_find_loc_by_pixel (GnucashSheet *sheet, gint x, gint y, gboolean gnucash_sheet_find_loc_by_pixel (GnucashSheet *sheet, gint x, gint y,
VirtualLocation *vcell_loc); VirtualLocation *vcell_loc);