Some more API cleanup. Don't separate table cell parts from columns.
This commit is contained in:
parent
a57bef13e5
commit
f02fbd2ecf
|
@ -5,10 +5,8 @@
|
||||||
uiTableColumn *uiTableAppendTextColumn(uiTable *t, const char *name, int modelColumn)
|
uiTableColumn *uiTableAppendTextColumn(uiTable *t, const char *name, int modelColumn)
|
||||||
{
|
{
|
||||||
uiTableColumn *tc;
|
uiTableColumn *tc;
|
||||||
uiTableCellPart *part;
|
|
||||||
|
|
||||||
part = uiNewTableTextPart(modelColumn);
|
|
||||||
tc = uiTableAppendColumn(t, name);
|
tc = uiTableAppendColumn(t, name);
|
||||||
uiTableColumnAppend(tc, part, 1);
|
uiTableColumnAppendTextPart(tc, modelColumn, 1);
|
||||||
return tc;
|
return tc;
|
||||||
}
|
}
|
||||||
|
|
|
@ -17,7 +17,7 @@ enum {
|
||||||
|
|
||||||
@interface tablePart : NSObject
|
@interface tablePart : NSObject
|
||||||
@property int type;
|
@property int type;
|
||||||
@property int mainColumn;
|
@property int textColumn;
|
||||||
@property int expand;
|
@property int expand;
|
||||||
- (NSView *)mkView:(uiTableModel *)m row:(int)row;
|
- (NSView *)mkView:(uiTableModel *)m row:(int)row;
|
||||||
@end
|
@end
|
||||||
|
@ -32,12 +32,6 @@ struct uiTableModel {
|
||||||
NSMutableArray *tables;
|
NSMutableArray *tables;
|
||||||
};
|
};
|
||||||
|
|
||||||
// TODO better memory management for this
|
|
||||||
// note how expand is part of this
|
|
||||||
struct uiTableCellPart {
|
|
||||||
tablePart *part;
|
|
||||||
};
|
|
||||||
|
|
||||||
struct uiTableColumn {
|
struct uiTableColumn {
|
||||||
tableColumn *c;
|
tableColumn *c;
|
||||||
NSMutableArray *parts;
|
NSMutableArray *parts;
|
||||||
|
@ -141,7 +135,7 @@ done:
|
||||||
NSView *view;
|
NSView *view;
|
||||||
NSTextField *tf;
|
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) {
|
switch (self.type) {
|
||||||
case partText:
|
case partText:
|
||||||
str = toNSString((char *) data);
|
str = toNSString((char *) data);
|
||||||
|
@ -233,28 +227,15 @@ void uiTableModelRowDeleted(uiTableModel *m, int oldIndex)
|
||||||
// set is autoreleased
|
// set is autoreleased
|
||||||
}
|
}
|
||||||
|
|
||||||
void uiTableColumnAppend(uiTableColumn *c, uiTableCellPart *part, int expand)
|
void uiTableColumnAppendTextPart(uiTableColumn *c, int modelColumn, int expand)
|
||||||
{
|
{
|
||||||
part->part.expand = expand;
|
tablePart *part;
|
||||||
[c->parts addObject:part->part];
|
|
||||||
}
|
|
||||||
|
|
||||||
uiTableCellPart *uiNewTableTextPart(int modelColumn)
|
part = [tablePart new];
|
||||||
{
|
part.type = partText;
|
||||||
uiTableCellPart *p;
|
part.textColumn = modelColumn;
|
||||||
|
part.expand = expand;
|
||||||
p = uiNew(uiTableCellPart);
|
[c->parts addObject:part];
|
||||||
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);
|
|
||||||
}
|
}
|
||||||
|
|
||||||
uiDarwinControlAllDefaultsExceptDestroy(uiTable, sv)
|
uiDarwinControlAllDefaultsExceptDestroy(uiTable, sv)
|
||||||
|
|
|
@ -61,8 +61,8 @@ uiBox *makePage16(void)
|
||||||
uiTableAppendTextColumn(t, "Column 1", 0);
|
uiTableAppendTextColumn(t, "Column 1", 0);
|
||||||
|
|
||||||
tc = uiTableAppendColumn(t, "Column 2");
|
tc = uiTableAppendColumn(t, "Column 2");
|
||||||
uiTableColumnAppend(tc, uiNewTableTextPart(1), 0);
|
uiTableColumnAppendTextPart(tc, 1, 0);
|
||||||
uiTableColumnAppend(tc, uiNewTableTextPart(2), 1);
|
uiTableColumnAppendTextPart(tc, 2, 1);
|
||||||
|
|
||||||
return page16;
|
return page16;
|
||||||
}
|
}
|
||||||
|
|
|
@ -26,12 +26,8 @@ _UI_EXTERN void uiTableModelRowDeleted(uiTableModel *m, int oldIndex);
|
||||||
// TODO reordering/moving
|
// TODO reordering/moving
|
||||||
|
|
||||||
typedef struct uiTableColumn uiTableColumn;
|
typedef struct uiTableColumn uiTableColumn;
|
||||||
typedef struct uiTableCellPart uiTableCellPart;
|
|
||||||
|
|
||||||
_UI_EXTERN void uiTableColumnAppend(uiTableColumn *c, uiTableCellPart *part, int expand);
|
_UI_EXTERN void uiTableColumnAppendTextPart(uiTableColumn *c, int modelColumn, int expand);
|
||||||
|
|
||||||
_UI_EXTERN uiTableCellPart *uiNewTableTextPart(int modelColumn);
|
|
||||||
_UI_EXTERN void uiFreeTableCellPart(uiTableCellPart *p);
|
|
||||||
|
|
||||||
typedef struct uiTable uiTable;
|
typedef struct uiTable uiTable;
|
||||||
#define uiTable(this) ((uiTable *) (this))
|
#define uiTable(this) ((uiTable *) (this))
|
||||||
|
|
Loading…
Reference in New Issue