1 // This file is part of a terminal todo application.
3 // Copyright (C) 2006 by Mike Sharov <msharov@users.sourceforge.net>
4 // This file is free software, distributed under the MIT License.
11 /// Default constructor.
12 CItemEditDialog::CItemEditDialog (void)
16 AddChild (new CEditBox
);
17 AddChild (new CLabel
);
18 AddChild (new CLabel
);
19 assert (Children().size() == ctrl_Last
);
22 void CItemEditDialog::OnUpdate (void)
25 SetItem (Document()->CurrentItem());
28 void CItemEditDialog::OnResize (rcrect_t wr
)
30 CDialog::OnResize (wr
);
31 ItemText().OnResize (Rect (1, 1, wr
.Width() - 2, 1));
32 CreatedDate().OnResize (Rect (wr
.Width() - 26, 3, 25, 1));
33 DoneDate().OnResize (Rect (wr
.Width() - 26, 4, 25, 1));
36 void CItemEditDialog::OnKey (wchar_t key
)
39 if (ItemText().Flag (f_OffersFocus
)) {
40 if (ItemText().Flag (f_Changed
)) {
41 m_Item
.SetText (ItemText().Text());
44 SetFlag (f_OffersFocus
);
46 Document()->UpdateCurrentItem (Item());
47 else if (Document()->CurrentItem().Text().empty())
48 Document()->RemoveCurrentItem();
52 void CItemEditDialog::SetItem (rcentry_t e
)
55 ItemText().SetText (e
.Text());
56 CreatedDate().SetText (e
.CreatedDateText());
57 DoneDate().SetText (e
.Complete() ? e
.DoneDateText() : "Active");
59 ClearFlag (f_Changed
);