Broke menu, navbar, statusbar, panel.notebook, and panel.welcome out of gui
[hooke.git] / hooke / ui / gui / menu.py
1 # Copyright
2
3 """Menu bar for Hooke.
4 """
5
6 import wx
7
8
9 class FileMenu (wx.Menu):
10     def __init__(self, *args, **kwargs):
11         super(FileMenu, self).__init__(*args, **kwargs)
12         self._c = {'exit': self.Append(wx.ID_EXIT)}
13
14
15 class ViewMenu (wx.Menu):
16     def __init__(self, *args, **kwargs):
17         super(ViewMenu, self).__init__(*args, **kwargs)
18         self._c = {
19             'folders': self.AppendCheckItem(id=wx.ID_ANY, text='Folders\tF5'),
20             'playlist': self.AppendCheckItem(
21                 id=wx.ID_ANY, text='Playlists\tF6'),
22             'commands': self.AppendCheckItem(
23                 id=wx.ID_ANY, text='Commands\tF7'),
24             'assistant': self.AppendCheckItem(
25                 id=wx.ID_ANY, text='Assistant\tF9'),
26             'properties': self.AppendCheckItem(
27                 id=wx.ID_ANY, text='Properties\tF8'),
28             'results': self.AppendCheckItem(id=wx.ID_ANY, text='Results\tF10'),
29             'output': self.AppendCheckItem(id=wx.ID_ANY, text='Output\tF11'),
30             'note': self.AppendCheckItem(id=wx.ID_ANY, text='Note\tF12'),
31             }
32         for item in self._c.values():
33             item.Check()
34
35
36 class PerspectiveMenu (wx.Menu):
37     def __init__(self, *args, **kwargs):
38         super(PerspectiveMenu, self).__init__(*args, **kwargs)
39         self._c = {}
40
41     def update(self, perspectives, selected, callback):
42         """Rebuild the perspectives menu.
43         """
44         for item in self.GetMenuItems():
45             self.UnBind(item)
46             self.DeleteItem(item)
47         self._c = {
48             'save': self.Append(id=wx.ID_ANY, text='Save Perspective'),
49             'delete': self.Append(id=wx.ID_ANY, text='Delete Perspective'),
50             }
51         self.AppendSeparator()
52         for label in perspectives:
53             self._c[label] = self.AppendRadioItem(id=wx.ID_ANY, text=label)
54             self.Bind(wx.EVT_MENU, callback, self._c[label])
55             if label == selected:
56                 self._c[label].Check(True)
57             
58
59 class HelpMenu (wx.Menu):
60     def __init__(self, *args, **kwargs):
61         super(HelpMenu, self).__init__(*args, **kwargs)
62         self._c = {'about':self.Append(id=wx.ID_ABOUT)}
63
64
65 class MenuBar (wx.MenuBar):
66     def __init__(self, *args, **kwargs):
67         super(MenuBar, self).__init__(*args, **kwargs)
68         self._c = {
69             'file': FileMenu(),
70             'view': ViewMenu(),
71             'perspective': PerspectiveMenu(),
72             'help': HelpMenu(),
73             }
74         self.Append(self._c['file'], 'File')
75         self.Append(self._c['view'], 'View')
76         self.Append(self._c['perspective'], 'Perspective')
77         self.Append(self._c['help'], 'Help')