Debian Codegraph @

hiro/gtk/widget/table-view-item.cpp

raw
1 #if defined(Hiro_TableView)
2
3 namespace hiro {
4
5 auto pTableViewItem::construct() -> void {
6 if(auto parent = _parent()) {
7 auto lock = parent->acquire();
8 gtk_list_store_append(parent->gtkListStore, &gtkIter);
9 _setState();
10 }
11 }
12
13 auto pTableViewItem::destruct() -> void {
14 if(auto parent = _parent()) {
15 auto lock = parent->acquire();
16 gtk_list_store_remove(parent->gtkListStore, &gtkIter);
17 parent->_updateSelected();
18 }
19 }
20
21 auto pTableViewItem::append(sTableViewCell cell) -> void {
22 }
23
24 auto pTableViewItem::remove(sTableViewCell cell) -> void {
25 }
26
27 auto pTableViewItem::setAlignment(Alignment alignment) -> void {
28 }
29
30 auto pTableViewItem::setBackgroundColor(Color color) -> void {
31 }
32
33 auto pTableViewItem::setFocused() -> void {
34 if(auto parent = _parent()) {
35 //calling setSelected() and then setFocused() right after sometimes fails to set focus
36 Application::processEvents();
37
38 auto lock = parent->acquire();
39 GtkTreePath* path = gtk_tree_path_new_from_string(string{self().offset()});
40 gtk_tree_view_set_cursor(parent->gtkTreeView, path, nullptr, false);
41 gtk_tree_view_scroll_to_cell(parent->gtkTreeView, path, nullptr, true, 0.5, 0.0);
42 gtk_tree_path_free(path);
43 }
44 }
45
46 auto pTableViewItem::setForegroundColor(Color color) -> void {
47 }
48
49 auto pTableViewItem::setSelected(bool selected) -> void {
50 _setState();
51 }
52
53 auto pTableViewItem::_parent() -> maybe<pTableView&> {
54 if(auto parent = self().parentTableView()) {
55 if(auto self = parent->self()) return *self;
56 }
57 return nothing;
58 }
59
60 auto pTableViewItem::_setState() -> void {
61 if(auto parent = _parent()) {
62 auto lock = parent->acquire();
63 if(state().selected) {
64 gtk_tree_selection_select_iter(parent->gtkTreeSelection, &gtkIter);
65 } else {
66 gtk_tree_selection_unselect_iter(parent->gtkTreeSelection, &gtkIter);
67 }
68 parent->_updateSelected();
69 for(auto& cell : state().cells) {
70 if(auto self = cell->self()) self->_setState();
71 }
72 }
73 }
74
75 }
76
77 #endif