Allow use of uptree .todo files
[ttodo.git] / eedit.cc
blob50751093556d3a38027e6f43365f385f767e570c
1 // Copyright (c) 2006 by Mike Sharov <msharov@users.sourceforge.net>
2 //
3 // eedit.cc
4 //
6 #include "eedit.h"
8 /// Default constructor.
9 CEntryEditDialog::CEntryEditDialog (void)
10 : CDialog (),
11 m_Entry ()
13 AddChild (new CEditBox);
14 AddChild (new CLabel);
15 AddChild (new CLabel);
16 assert (Children().size() == ctrl_Last);
19 void CEntryEditDialog::OnUpdate (void)
21 CDialog::OnUpdate();
22 SetEntry (Document()->CurrentEntry());
25 void CEntryEditDialog::OnResize (rcrect_t wr)
27 CDialog::OnResize (wr);
28 EntryText().OnResize (Rect (1, 1, wr.Width() - 2, 1));
29 CreatedDate().OnResize (Rect (wr.Width() - 26, 3, 25, 1));
30 DoneDate().OnResize (Rect (wr.Width() - 26, 4, 25, 1));
33 void CEntryEditDialog::OnKey (wchar_t key)
35 CDialog::OnKey (key);
36 if (EntryText().Flag (f_OffersFocus)) {
37 if (EntryText().Flag (f_Changed)) {
38 m_Entry.SetText (EntryText().Text());
39 EntryText().Commit();
40 SetFlag (f_Changed);
42 SetFlag (f_OffersFocus);
43 if (Flag (f_Changed))
44 Document()->UpdateCurrentEntry (Entry());
45 else if (Document()->CurrentEntry().Text().empty())
46 Document()->RemoveCurrentEntry();
47 Commit();
51 void CEntryEditDialog::OnGainFocus (void)
53 CDialog::OnGainFocus();
54 SetFocus (ctrl_Text);
57 void CEntryEditDialog::SetEntry (rcentry_t e)
59 m_Entry = e;
60 EntryText().SetText (e.Text());
61 CreatedDate().SetText (e.CreatedDateText());
62 DoneDate().SetText (e.Complete() ? e.DoneDateText() : "Active");
63 SetFocus (ctrl_Text);
64 ClearFlag (f_Changed);