Some more API cleanup. Don't separate table cell parts from columns.

This commit is contained in:
Pietro Gagliardi 2016-06-23 09:56:24 -04:00
parent a57bef13e5
commit f02fbd2ecf
4 changed files with 13 additions and 38 deletions

View File

@ -5,10 +5,8 @@
uiTableColumn *uiTableAppendTextColumn(uiTable *t, const char *name, int modelColumn)
{
uiTableColumn *tc;
uiTableCellPart *part;
part = uiNewTableTextPart(modelColumn);
tc = uiTableAppendColumn(t, name);
uiTableColumnAppend(tc, part, 1);
uiTableColumnAppendTextPart(tc, modelColumn, 1);
return tc;
}

View File

@ -17,7 +17,7 @@ enum {
@interface tablePart : NSObject
@property int type;
@property int mainColumn;
@property int textColumn;
@property int expand;
- (NSView *)mkView:(uiTableModel *)m row:(int)row;
@end
@ -32,12 +32,6 @@ struct uiTableModel {
NSMutableArray *tables;
};
// TODO better memory management for this
// note how expand is part of this
struct uiTableCellPart {
tablePart *part;
};
struct uiTableColumn {
tableColumn *c;
NSMutableArray *parts;
@ -141,7 +135,7 @@ done:
NSView *view;
NSTextField *tf;
data = (*(m->mh->CellValue))(m->mh, m, row, self.mainColumn);
data = (*(m->mh->CellValue))(m->mh, m, row, self.textColumn);
switch (self.type) {
case partText:
str = toNSString((char *) data);
@ -233,28 +227,15 @@ void uiTableModelRowDeleted(uiTableModel *m, int oldIndex)
// set is autoreleased
}
void uiTableColumnAppend(uiTableColumn *c, uiTableCellPart *part, int expand)
void uiTableColumnAppendTextPart(uiTableColumn *c, int modelColumn, int expand)
{
part->part.expand = expand;
[c->parts addObject:part->part];
}
tablePart *part;
uiTableCellPart *uiNewTableTextPart(int modelColumn)
{
uiTableCellPart *p;
p = uiNew(uiTableCellPart);
p->part = [tablePart new];
p->part.type = partText;
p->part.mainColumn = modelColumn;
return p;
}
void uiFreeTableCellPart(uiTableCellPart *p)
{
// TODO disallow if in use
[p->part release];
uiFree(p);
part = [tablePart new];
part.type = partText;
part.textColumn = modelColumn;
part.expand = expand;
[c->parts addObject:part];
}
uiDarwinControlAllDefaultsExceptDestroy(uiTable, sv)

View File

@ -61,8 +61,8 @@ uiBox *makePage16(void)
uiTableAppendTextColumn(t, "Column 1", 0);
tc = uiTableAppendColumn(t, "Column 2");
uiTableColumnAppend(tc, uiNewTableTextPart(1), 0);
uiTableColumnAppend(tc, uiNewTableTextPart(2), 1);
uiTableColumnAppendTextPart(tc, 1, 0);
uiTableColumnAppendTextPart(tc, 2, 1);
return page16;
}

View File

@ -26,12 +26,8 @@ _UI_EXTERN void uiTableModelRowDeleted(uiTableModel *m, int oldIndex);
// TODO reordering/moving
typedef struct uiTableColumn uiTableColumn;
typedef struct uiTableCellPart uiTableCellPart;
_UI_EXTERN void uiTableColumnAppend(uiTableColumn *c, uiTableCellPart *part, int expand);
_UI_EXTERN uiTableCellPart *uiNewTableTextPart(int modelColumn);
_UI_EXTERN void uiFreeTableCellPart(uiTableCellPart *p);
_UI_EXTERN void uiTableColumnAppendTextPart(uiTableColumn *c, int modelColumn, int expand);
typedef struct uiTable uiTable;
#define uiTable(this) ((uiTable *) (this))