File: table-view-header.cpp

package info (click to toggle)
higan 106-2
  • links: PTS, VCS
  • area: main
  • in suites: bullseye, buster
  • size: 9,640 kB
  • sloc: cpp: 108,736; ansic: 809; makefile: 22; sh: 7
file content (58 lines) | stat: -rw-r--r-- 1,547 bytes parent folder | download
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
#if defined(Hiro_TableView)

auto mTableViewHeader::allocate() -> pObject* {
  return new pTableViewHeader(*this);
}

//

auto mTableViewHeader::append(sTableViewColumn column) -> type& {
  state.columns.append(column);
  column->setParent(this, columnCount() - 1);
  signal(append, column);
  return *this;
}

auto mTableViewHeader::column(unsigned position) const -> TableViewColumn {
  if(position < columnCount()) return state.columns[position];
  return {};
}

auto mTableViewHeader::columnCount() const -> unsigned {
  return state.columns.size();
}

auto mTableViewHeader::columns() const -> vector<TableViewColumn> {
  vector<TableViewColumn> columns;
  for(auto& column : state.columns) columns.append(column);
  return columns;
}

auto mTableViewHeader::remove() -> type& {
  if(auto tableView = parentTableView()) tableView->remove(*this);
  return *this;
}

auto mTableViewHeader::remove(sTableViewColumn column) -> type& {
  signal(remove, column);
  state.columns.remove(column->offset());
  for(auto n : range(column->offset(), columnCount())) {
    state.columns[n]->adjustOffset(-1);
  }
  column->setParent();
  return *this;
}

auto mTableViewHeader::reset() -> type& {
  for(auto n : rrange(state.columns)) remove(state.columns[n]);
  return *this;
}

auto mTableViewHeader::setParent(mObject* parent, signed offset) -> type& {
  for(auto& column : state.columns) column->destruct();
  mObject::setParent(parent, offset);
  for(auto& column : state.columns) column->setParent(this, column->offset());
  return *this;
}

#endif