30 #include "basiccell.h"
32 #include "table-layout.h"
49 guint32 conditionally_changed;
59 gnc_table_layout_new (
void)
76 for (node = layout->cells; node; node = node->next)
80 gnc_basic_cell_destroy (cell);
82 g_list_free (layout->cells);
85 for (node = layout->cursors; node; node = node->next)
89 gnc_cellblock_destroy (cursor);
91 g_list_free (layout->cursors);
92 layout->cursors = NULL;
103 g_return_if_fail (layout != NULL);
104 g_return_if_fail (cell != NULL);
106 for (node = layout->cells; node; node = node->next)
110 if (gnc_basic_cell_has_name (list_cell, cell->cell_name))
112 if (list_cell == cell)
115 gnc_basic_cell_destroy (list_cell);
121 layout->cells = g_list_append (layout->cells, cell);
127 gnc_table_layout_get_cell (
TableLayout *layout,
const char *cell_name)
131 g_return_val_if_fail (layout != NULL, NULL);
133 for (node = layout->cells; node; node = node->next)
137 if (gnc_basic_cell_has_name (list_cell, cell_name))
145 gnc_table_layout_get_cell_value (
TableLayout *layout,
const char * cell_name)
149 g_return_val_if_fail (layout != NULL, NULL);
151 cell = gnc_table_layout_get_cell (layout, cell_name);
152 if (!cell)
return NULL;
154 return gnc_basic_cell_get_value (cell);
158 gnc_table_layout_get_cell_changed (
TableLayout *layout,
159 const char *cell_name,
160 gboolean include_conditional)
164 g_return_val_if_fail (layout != NULL, FALSE);
166 cell = gnc_table_layout_get_cell (layout, cell_name);
167 if (!cell)
return FALSE;
169 if (!include_conditional)
170 return gnc_basic_cell_get_changed (cell);
172 return (gnc_basic_cell_get_changed (cell) ||
173 gnc_basic_cell_get_conditionally_changed (cell));
182 return layout->cells;
191 g_return_if_fail (layout != NULL);
192 g_return_if_fail (cursor != NULL);
194 if (g_list_find (layout->cursors, cursor))
197 for (node = layout->cursors; node; node = node->next)
201 if (strcmp (list_cursor->cursor_name, cursor->cursor_name) == 0)
203 layout->cursors = g_list_remove (layout->cursors, list_cursor);
204 gnc_cellblock_destroy (list_cursor);
209 layout->cursors = g_list_append (layout->cursors, cursor);
214 const char *cursor_name)
218 g_return_val_if_fail (layout != NULL, NULL);
223 for (node = layout->cursors; node; node = node->next)
227 if (strcmp (cursor_name, cursor->cursor_name) == 0)
237 g_return_val_if_fail (layout != NULL, NULL);
238 return layout->cursors;
242 gnc_table_layout_set_primary_cursor (
TableLayout *layout,
245 g_return_if_fail (layout != NULL);
246 layout->primary_cursor = cursor;
252 const char *cell_name,
258 g_return_if_fail (layout != NULL);
259 g_return_if_fail (layout->primary_cursor != NULL);
260 g_return_if_fail (cursor != NULL);
261 g_return_if_fail (cell_name != NULL);
262 g_return_if_fail (row >= 0);
263 g_return_if_fail (col >= 0);
264 g_return_if_fail (row < cursor->num_rows);
265 g_return_if_fail (col < cursor->num_cols);
267 header = gnc_table_layout_get_cursor (layout, CURSOR_HEADER);
268 cell = gnc_table_layout_get_cell (layout, cell_name);
270 g_return_if_fail (header != NULL);
271 g_return_if_fail (cell != NULL);
273 cursor->start_col = MIN (cursor->start_col, col);
274 cursor->stop_col = MAX (cursor->stop_col, col);
276 header->start_col = MIN (header->start_col, col);
277 header->stop_col = MAX (header->stop_col, col);
279 gnc_cellblock_set_cell (cursor, row, col, cell);
281 if (cursor == layout->primary_cursor)
282 gnc_cellblock_set_cell (header, row, col, cell);
286 gnc_cursor_buffer_new (
void)
301 g_free (cb->cell_name);
302 cb->cell_name = NULL;
317 for (node = buffer->cell_buffers; node; node = node->next)
321 destroy_cell_buffer (cb);
324 g_list_free (buffer->cell_buffers);
325 buffer->cell_buffers = NULL;
333 gnc_cursor_buffer_clear (buffer);
348 cb->cell_name = g_strdup (bcell->cell_name);
349 cb->value = g_strdup (bcell->value);
350 cb->changed = bcell->changed;
351 cb->conditionally_changed = bcell->conditionally_changed;
363 if (!layout || !cursor || !buffer)
366 gnc_cursor_buffer_clear (buffer);
368 for (node = layout->cells; node; node = node->next)
373 if (!gnc_basic_cell_get_changed (list_cell) &&
374 !gnc_basic_cell_get_conditionally_changed (list_cell))
377 cb = save_cell (list_cell);
379 buffer->cell_buffers = g_list_prepend (buffer->cell_buffers, cb);
388 if (!bcell || !cb || !cursor)
391 if (!cb->changed && !cb->conditionally_changed)
395 for (r = 0; r < cursor->num_rows; r++)
396 for (c = 0; c < cursor->num_cols; c++)
400 cell = gnc_cellblock_get_cell (cursor, r, c);
406 gnc_basic_cell_set_value (bcell, cb->value);
407 bcell->changed = cb->changed;
408 bcell->conditionally_changed = cb->conditionally_changed;
415 gnc_table_layout_restore_cursor (
TableLayout *layout,
421 if (!layout || !cursor || !buffer)
424 for (node = buffer->cell_buffers; node; node = node->next)
429 cell = gnc_table_layout_get_cell (layout, cb->cell_name);
431 restore_cell (cell, cb, cursor);
Declarations for the CellBlock object.