6 //----------------------------------------------------------------------
8 /// Constructs a list displaying \p rctdl
9 CTodoList::CTodoList (void)
15 /// Sets the list to display.
16 void CTodoList::SetList (pctodolist_t pl
)
20 SetListSize (pl
->size());
23 /// Sets internal variables when the document is updated.
24 void CTodoList::OnUpdate (void)
27 SetList (&Document()->List());
28 SetSelection (Document()->Selection());
31 /// Draws list item \p ii at \p pos onto \p gc.
32 void CTodoList::OnDrawItem (CGC
& gc
, rcpos_t pos
, uint32_t ii
)
34 CListbox::OnDrawItem (gc
, pos
, ii
);
38 const CTodoEntry
& e ((*m_pTodos
)[ii
]);
39 line
.format ("%c%3u%% %s", "+ "[!e
.SublistId()], e
.Progress(), e
.Text().c_str());
43 /// Causes the current entry to be edited.
44 inline void CTodoList::EditEntry (void)
46 SetFlag (flag_OffersFocus
);
49 /// Processes keystroke \p key.
50 void CTodoList::OnKey (wchar_t key
)
52 CListbox::OnKey (key
);
54 if (Document()->Selection() != Selection())
55 Document()->SetSelection (Selection());
59 else if (key
== 'S') {
60 Document()->SaveData();
62 } else if (key
== 'R')
63 Document()->LoadData();
64 else if (key
== 'n') {
65 Document()->SetSelection (Document()->ListSize() - 1);
66 Document()->AppendEntry();
70 if (Document()->Selection() >= Document()->ListSize())
73 if (key
== kv_Space
) // Toggle complete flag
74 Document()->MarkEntryComplete();
75 else if (key
== kv_Delete
|| key
== 'D')
76 Document()->RemoveCurrentEntry();
77 else if (key
== kv_Enter
|| key
== 'e')
79 else if (key
== kv_Insert
|| key
== 'i') {
80 Document()->AppendEntry();