1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 34 35 36 37 38 39 40 41 42 43 44 45 46 47 48 49 50 51 52 53 54 55 56 57 58 59 60 61 62 63 64 65 66 67 68 69 70 71 72 73 74 75 76 77 78 79 80 81 82 83 84 85 86 87 88 89 90 91 92 93 94 95 96 97 98 99 100 101 102 103
|
#if defined(Hiro_TableView)
auto mTableViewItem::allocate() -> pObject* {
return new pTableViewItem(*this);
}
//
auto mTableViewItem::alignment() const -> Alignment {
return state.alignment;
}
auto mTableViewItem::append(sTableViewCell cell) -> type& {
state.cells.append(cell);
cell->setParent(this, cellCount() - 1);
signal(append, cell);
return *this;
}
auto mTableViewItem::backgroundColor() const -> Color {
return state.backgroundColor;
}
auto mTableViewItem::cell(unsigned position) const -> TableViewCell {
if(position < cellCount()) return state.cells[position];
return {};
}
auto mTableViewItem::cellCount() const -> unsigned {
return state.cells.size();
}
auto mTableViewItem::cells() const -> vector<TableViewCell> {
vector<TableViewCell> cells;
for(auto& cell : state.cells) cells.append(cell);
return cells;
}
auto mTableViewItem::foregroundColor() const -> Color {
return state.foregroundColor;
}
auto mTableViewItem::remove() -> type& {
if(auto tableView = parentTableView()) tableView->remove(*this);
return *this;
}
auto mTableViewItem::remove(sTableViewCell cell) -> type& {
signal(remove, cell);
state.cells.remove(cell->offset());
for(auto n : range(cell->offset(), cellCount())) {
state.cells[n]->adjustOffset(-1);
}
cell->setParent();
return *this;
}
auto mTableViewItem::reset() -> type& {
for(auto n : rrange(state.cells)) remove(state.cells[n]);
return *this;
}
auto mTableViewItem::selected() const -> bool {
return state.selected;
}
auto mTableViewItem::setAlignment(Alignment alignment) -> type& {
state.alignment = alignment;
signal(setAlignment, alignment);
return *this;
}
auto mTableViewItem::setBackgroundColor(Color color) -> type& {
state.backgroundColor = color;
signal(setBackgroundColor, color);
return *this;
}
auto mTableViewItem::setFocused() -> type& {
signal(setFocused);
return *this;
}
auto mTableViewItem::setForegroundColor(Color color) -> type& {
state.foregroundColor = color;
signal(setForegroundColor, color);
return *this;
}
auto mTableViewItem::setParent(mObject* parent, signed offset) -> type& {
for(auto& cell : state.cells) cell->destruct();
mObject::setParent(parent, offset);
for(auto& cell : state.cells) cell->setParent(this, cell->offset());
return *this;
}
auto mTableViewItem::setSelected(bool selected) -> type& {
state.selected = selected;
signal(setSelected, selected);
return *this;
}
#endif
|