summaryrefslogtreecommitdiff
path: root/src/widget/table.c
diff options
context:
space:
mode:
Diffstat (limited to 'src/widget/table.c')
-rw-r--r--src/widget/table.c22
1 files changed, 8 insertions, 14 deletions
diff --git a/src/widget/table.c b/src/widget/table.c
index 7a0ea03..dfb2e69 100644
--- a/src/widget/table.c
+++ b/src/widget/table.c
@@ -33,7 +33,7 @@ uiTable* uiMakeTable(int rows, int cols, const char** header) {
33 33
34 if (header) { 34 if (header) {
35 for (int col = 0; col < cols; ++col) { 35 for (int col = 0; col < cols; ++col) {
36 table->header[col].child = (uiWidget*)uiMakeLabel(header[col]); 36 table->header[col].text = string_new(header[col]);
37 } 37 }
38 } 38 }
39 39
@@ -47,7 +47,7 @@ void uiTableClear(uiTable* table) {
47 if (table->cells) { 47 if (table->cells) {
48 for (int row = 0; row < table->rows; ++row) { 48 for (int row = 0; row < table->rows; ++row) {
49 for (int col = 0; col < table->cols; ++col) { 49 for (int col = 0; col < table->cols; ++col) {
50 DestroyWidget(&table->cells[row][col].child); 50 string_del(&table->cells[row][col].text);
51 } 51 }
52 free(table->cells[row]); 52 free(table->cells[row]);
53 } 53 }
@@ -81,23 +81,17 @@ void uiTableAddRow(uiTable* table, const char** row) {
81 uiCell* lastRow = *pLastRow; 81 uiCell* lastRow = *pLastRow;
82 82
83 for (int col = 0; col < table->cols; ++col) { 83 for (int col = 0; col < table->cols; ++col) {
84 lastRow[col].child = (uiWidget*)uiMakeLabel(row[col]); 84 lastRow[col].text = string_new(row[col]);
85 } 85 }
86} 86}
87 87
88void uiTableSet(uiTable* table, int row, int col, uiPtr child) { 88void uiTableSet(uiTable* table, int row, int col, const char* text) {
89 assert(table); 89 assert(table);
90 assert(child.widget); 90 assert(text);
91 91 GetCellMut(table, row, col)->text = string_new(text);
92 GetCellMut(table, row, col)->child = child.widget;
93}
94
95const uiWidget* uiTableGet(const uiTable* table, int row, int col) {
96 assert(table);
97 return GetCell(table, row, col)->child;
98} 92}
99 93
100uiWidget* uiTableGetMut(uiTable* table, int row, int col) { 94const char* uiTableGet(const uiTable* table, int row, int col) {
101 assert(table); 95 assert(table);
102 return GetCellMut(table, row, col)->child; 96 return string_data(GetCell(table, row, col)->text);
103} 97}