File: table-view-item.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 (75 lines) | stat: -rw-r--r-- 1,710 bytes parent folder | download | duplicates (5)
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
#if defined(Hiro_TableView)

namespace hiro {

auto pTableViewItem::construct() -> void {
  if(auto parent = _parent()) {
    parent->lock();
    wchar_t text[] = L"";
    LVITEM lvItem{0};
    lvItem.mask = LVIF_TEXT;
    lvItem.iItem = self().offset();
    lvItem.iSubItem = 0;
    lvItem.pszText = text;
    ListView_InsertItem(parent->hwnd, &lvItem);
    _setState();
    parent->unlock();
  }
}

auto pTableViewItem::destruct() -> void {
  if(auto parent = _parent()) {
    parent->lock();
    ListView_DeleteItem(parent->hwnd, self().offset());
    parent->unlock();
  }
}

auto pTableViewItem::append(sTableViewCell cell) -> void {
}

auto pTableViewItem::remove(sTableViewCell cell) -> void {
}

auto pTableViewItem::setAlignment(Alignment alignment) -> void {
}

auto pTableViewItem::setBackgroundColor(Color color) -> void {
}

auto pTableViewItem::setFocused() -> void {
  if(auto parent = _parent()) {
    parent->lock();
    ListView_SetItemState(parent->hwnd, self().offset(), LVIS_FOCUSED, LVIS_FOCUSED);
    parent->unlock();
  }
}

auto pTableViewItem::setForegroundColor(Color color) -> void {
}

auto pTableViewItem::setSelected(bool selected) -> void {
  _setState();
}

auto pTableViewItem::_parent() -> maybe<pTableView&> {
  if(auto parent = self().parentTableView()) {
    if(auto self = parent->self()) return *self;
  }
  return nothing;
}

auto pTableViewItem::_setState() -> void {
  if(auto parent = _parent()) {
    parent->lock();
    ListView_SetItemState(parent->hwnd, self().offset(), state().selected ? LVIS_SELECTED : 0, LVIS_SELECTED);
    for(auto& cell : state().cells) {
      if(auto self = cell->self()) self->_setState();
    }
    parent->unlock();
  }
}

}

#endif