1 // Copyright (c) 2006 by Mike Sharov <msharov@users.sourceforge.net>
8 /// Default constructor.
9 CEntryEditDialog::CEntryEditDialog (void)
13 AddChild (new CEditBox
);
14 AddChild (new CLabel
);
15 AddChild (new CLabel
);
16 assert (Children().size() == ctrl_Last
);
19 void CEntryEditDialog::OnUpdate (void)
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
)
36 if (EntryText().Flag (f_OffersFocus
)) {
37 if (EntryText().Flag (f_Changed
)) {
38 m_Entry
.SetText (EntryText().Text());
42 SetFlag (f_OffersFocus
);
44 Document()->UpdateCurrentEntry (Entry());
45 else if (Document()->CurrentEntry().Text().empty())
46 Document()->RemoveCurrentEntry();
51 void CEntryEditDialog::OnGainFocus (void)
53 CDialog::OnGainFocus();
57 void CEntryEditDialog::SetEntry (rcentry_t e
)
60 EntryText().SetText (e
.Text());
61 CreatedDate().SetText (e
.CreatedDateText());
62 DoneDate().SetText (e
.Complete() ? e
.DoneDateText() : "Active");
64 ClearFlag (f_Changed
);