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.
12 //----------------------------------------------------------------------
14 BEGIN_MENU(4, c_TodoMenu
)
15 SUBMENU(2, "&File", cmd_File
),
16 MENUITEM ("&Save", cmd_File_Save
),
17 MENUITEM ("&Quit", cmd_File_Quit
),
18 SUBMENU(7, "&List", cmd_List
),
19 MENUITEM ("&Enter", cmd_List_Enter
),
20 MENUITEM ("&Leave", cmd_List_Leave
),
22 MENUITEM ("&Copy", cmd_List_Copy
),
23 MENUITEM ("&Paste", cmd_List_Paste
),
25 MENUCHECK ("&Old items",cmd_List_OldItems
),
26 SUBMENU(6, "&Item", cmd_Item
),
27 MENUITEM ("&New", cmd_Item_New
),
28 MENUITEM ("&Edit", cmd_Item_Edit
),
29 MENUITEM ("&Delete", cmd_Item_Delete
),
31 MENUITEM ("&Complete", cmd_Item_Complete
),
32 SUBMENU(5,"&Priority", cmd_Item_Priority
),
33 MENUCHECK ("H&ighest", cmd_Item_Priority_Highest
),
34 MENUCHECK ("&High", cmd_Item_Priority_High
),
35 MENUCHECK ("&Medium", cmd_Item_Priority_Medium
),
36 MENUCHECK ("&Low", cmd_Item_Priority_Low
),
37 MENUCHECK ("Low&est", cmd_Item_Priority_Lowest
),
38 SUBMENU(2, "&Help", cmd_Help
),
39 MENUITEM ("&Contents", cmd_Help_Contents
),
40 MENUITEM ("&About", cmd_Help_About
)
43 //----------------------------------------------------------------------
45 /// Default constructor.
46 CTodoFrame::CTodoFrame (void)
49 AddChild (CMenuBar::Instance());
50 AddChild (new CTodoList
);
51 AddChild (new CItemEditDialog
);
52 assert (pane_Last
== Children().size());
53 CMenuBar::Instance()->Set (VectorBlock (c_TodoMenu
));
56 /// Registers each child pane with the document.
57 void CTodoFrame::OnInitialUpdate (void)
59 CWindow::OnInitialUpdate();
60 Document()->RegisterView (&TodoList());
61 Document()->RegisterView (&ItemEditor());
64 /// Allows each child pane to close the frame by closing itself.
65 void CTodoFrame::OnChildClose (uoff_t i
)
67 CWindow::OnChildClose (i
);
68 Close (CW(i
).Status());
71 /// Resizes and places child windows.
72 void CTodoFrame::OnResize (rcrect_t wr
)
74 CWindow::OnResize (wr
);
76 CW(pane_MenuBar
).SizeHints (menuRect
);
77 MenuBar().OnResize (menuRect
);
78 TodoList().OnResize (Rect (0, menuRect
.Height(), wr
.Width(), wr
.Height() - 8 - menuRect
.Height()));
79 ItemEditor().OnResize (Rect (0, wr
.Height() - 8, wr
.Width(), 8));
82 void CTodoFrame::OnKey (wchar_t key
)
85 SetFocus (pane_MenuBar
);
89 void CTodoFrame::OnCommand (cmd_t c
)
91 Document()->OnCommand (c
);
92 CWindow::OnCommand (c
);
95 void CTodoFrame::OnUpdateCommandUI (rcmd_t rc
) const
97 rc
.SetFlag (SCmd::cf_Grayed
, !Document());
100 Document()->OnUpdateCommandUI (rc
);
101 CWindow::OnUpdateCommandUI (rc
);