40 static void gnc_cellblock_init (
CellBlock *cellblock,
int rows,
int cols);
44 gnc_cellblock_new (
int rows,
int cols,
const char *cursor_name)
48 g_return_val_if_fail (rows > 0, NULL);
49 g_return_val_if_fail (cols > 0, NULL);
50 g_return_val_if_fail (cursor_name != NULL, NULL);
54 gnc_cellblock_init (cellblock, rows, cols);
56 cellblock->cursor_name = g_strdup (cursor_name);
62 gnc_cellblock_init (
CellBlock *cellblock,
int rows,
int cols)
65 cellblock->num_rows = rows;
66 cellblock->num_cols = cols;
68 cellblock->start_col = cols;
69 cellblock->stop_col = -1;
72 cellblock->cells = g_ptr_array_new ();
74 g_ptr_array_set_size (cellblock->cells, rows * cols);
78 gnc_cellblock_destroy (
CellBlock *cellblock)
80 if (!cellblock)
return;
82 g_ptr_array_free (cellblock->cells, FALSE);
83 cellblock->cells = NULL;
85 g_free (cellblock->cursor_name);
86 cellblock->cursor_name = NULL;
92 gnc_cellblock_set_cell (
CellBlock *cellblock,
96 if (cellblock == NULL)
99 if (row < 0 || row >= cellblock->num_rows)
102 if (col < 0 || col >= cellblock->num_cols)
105 cellblock->cells->pdata[(row * cellblock->num_cols) + col] = cell;
109 gnc_cellblock_get_cell (
CellBlock *cellblock,
int row,
int col)
111 if (cellblock == NULL)
114 if (row < 0 || row >= cellblock->num_rows)
117 if (col < 0 || col >= cellblock->num_cols)
120 return cellblock->cells->pdata[(row * cellblock->num_cols) + col];
125 const char *cell_name,
128 int r, c, num_rows, num_cols;
130 if (cellblock == NULL)
133 if (cell_name == NULL)
136 num_rows = cellblock->num_rows;
137 num_cols = cellblock->num_cols;
138 for (r = 0; r < num_rows; r++)
139 for (c = 0; c < num_cols; c++)
141 BasicCell *cell = cellblock->cells->pdata[(r * num_cols) + c];
143 if (gnc_cell_name_equal(cell->cell_name, cell_name))
157 gnc_cellblock_changed (
CellBlock *cursor, gboolean include_conditional)
165 for (r = 0; r < cursor->num_rows; r++)
166 for (c = 0; c < cursor->num_cols; c++)
170 cell = gnc_cellblock_get_cell (cursor, r, c);
174 if (gnc_basic_cell_get_changed (cell))
180 if (include_conditional &&
181 gnc_basic_cell_get_conditionally_changed (cell))
189 gnc_cellblock_clear_changes (
CellBlock *cursor)
196 for (r = 0; r < cursor->num_rows; r++)
197 for (c = 0; c < cursor->num_cols; c++)
201 cell = gnc_cellblock_get_cell (cursor, r, c);
205 gnc_basic_cell_set_changed (cell, FALSE);
206 gnc_basic_cell_set_conditionally_changed (cell, FALSE);
BasicCell * gnc_cellblock_get_cell_by_name(CellBlock *cellblock, const char *cell_name, int *row, int *col)
Declarations for the CellBlock object.