// Copyright (c) 2003,2004,2005 Juraj Kolesár #include "tdb.h" /* width {{{ *******************************************************************/ int t_cellist_width_sum(T_CELLIST *list, int pos) { int i; int width = 0; T_CELL *cell; list = g_list_first(list); for (i=0; i <= pos; i++) { cell = list->data; width += cell->width; if (list->next != NULL) list = g_list_next(list); else return(__LT_ERR); } return(width); } /* }}} */ /* widths sum {{{ *************************************************************/ int t_cols_width_sum(T_COLS *cols) { int i; int width = 0; T_CELL *cell; while (cols != NULL) { cell = cols->data; width += cell->width; cols = g_slist_next(cols); } return(width); } /* }}} */ /* cols get values {{{ ********************************************************/ int t_cols_get_values(T_COLS *cols, int column, int *pos, int *width, char *value) { T_CELL *cell = cols->data; *pos = 1; while ((column > 0) && (cols->next != NULL)) { if (cell->width > 0) *pos += cell->width + 1; cols = g_slist_next(cols); cell = cols->data; column--; } *width = cell->width; strcpy(value,cell->value); return(column); } /* }}} */ /* cols set values {{{ ********************************************************/ int t_cols_set_value(T_COLS *cols, int column, int width, char *value) { register int i; T_CELL *cell; for (i=0; i < column; i++) { if (cols->next != NULL) cols = g_slist_next(cols); else return(__LT_ERR); } cell = cols->data; cell->width = width; strcpy(cell->value, value); return(__LT_OK); } /* }}} */ /* width {{{ *******************************************************************/ int t_cols_next(T_COLS *cols, int *column) { T_COLS *m_cols = cols; T_CELL *cell; register int i; for (i=0; i < *column; i++) { if (m_cols->next != NULL) m_cols = g_slist_next(m_cols); else return(__LT_ERR); } do { if (m_cols->next != NULL) { m_cols = g_slist_next(m_cols); (*column)++; } else { m_cols = cols; *column = 0; } cell = m_cols->data; } while (cell->width == 0); return(__LT_OK); } /* }}} */