1 |
#Boa:MDIParent:fraggleViewport |
2 |
|
3 |
# $Id: fraggleViewport.py,v 1.13 2004/08/27 03:25:44 joko Exp $ |
4 |
# $Log: fraggleViewport.py,v $ |
5 |
# Revision 1.13 2004/08/27 03:25:44 joko |
6 |
# added FraggleTaskBarMenu |
7 |
# |
8 |
# Revision 1.12 2004/08/27 00:05:22 joko |
9 |
# fix for icon-path and wxTaskBarIcon-events |
10 |
# |
11 |
# Revision 1.11 2004/08/26 23:10:12 xabbu |
12 |
# xmlrpc class added |
13 |
# |
14 |
# Revision 1.10 2004/08/26 18:19:27 joko |
15 |
# now using FraggleTopicFrame |
16 |
# |
17 |
# Revision 1.9 2004/08/26 15:21:13 joko |
18 |
# renamed namespaces |
19 |
# added key shortcuts to menu-items |
20 |
# correct "showAbout" code |
21 |
# |
22 |
|
23 |
import os |
24 |
from wxPython.wx import * |
25 |
from wxPython.stc import * |
26 |
|
27 |
from fraggleConstants import * |
28 |
import fraggleDialogPrefs |
29 |
import fraggleCtlPreferences |
30 |
import FraggleAboutDialog |
31 |
import FraggleTopicFrame |
32 |
import FraggleXMLRPC |
33 |
|
34 |
def create(parent): |
35 |
return fraggleViewport(parent) |
36 |
|
37 |
[wxID_FRAGGLEVIEWPORT] = map(lambda _init_ctrls: wxNewId(), range(1)) |
38 |
|
39 |
[wxID_FRAGGLEVIEWPORTMENU1FPREFS, wxID_FRAGGLEVIEWPORTMENU1ITEMS1, |
40 |
] = map(lambda _init_coll_menu1_Items: wxNewId(), range(2)) |
41 |
|
42 |
[wxID_FRAGGLEVIEWPORTMENU2ABOUT, wxID_FRAGGLEVIEWPORTMENU2CONT, |
43 |
] = map(lambda _init_coll_menu2_Items: wxNewId(), range(2)) |
44 |
|
45 |
[wxID_FRAGGLEVIEWPORTMENU2ABOUT, wxID_FRAGGLEVIEWPORTMENU2CONT, |
46 |
] = map(lambda _init_coll_menu2_Items: wxNewId(), range(2)) |
47 |
|
48 |
[wxID_FRAGGLEVIEWPORTFRAGGLETASKBARMENUITEMSEXIT, |
49 |
wxID_FRAGGLEVIEWPORTFRAGGLETASKBARMENUITEMSRESTORE, |
50 |
wxID_FRAGGLEVIEWPORTFRAGGLETASKBARMENUITEMSSYNC, |
51 |
] = map(lambda _init_coll_FraggleTaskBarMenu_Items: wxNewId(), range(3)) |
52 |
|
53 |
class fraggleViewport(wxMDIParentFrame): |
54 |
def _init_coll_FraggleTaskBarMenu_Items(self, parent): |
55 |
# generated method, don't edit |
56 |
|
57 |
parent.Append(helpString='Restore', |
58 |
id=wxID_FRAGGLEVIEWPORTFRAGGLETASKBARMENUITEMSRESTORE, |
59 |
item='Restore', kind=wxITEM_NORMAL) |
60 |
parent.Append(helpString='Sync enabled', |
61 |
id=wxID_FRAGGLEVIEWPORTFRAGGLETASKBARMENUITEMSSYNC, |
62 |
item='Sync enabled', kind=wxITEM_CHECK) |
63 |
parent.Append(helpString='Exit', |
64 |
id=wxID_FRAGGLEVIEWPORTFRAGGLETASKBARMENUITEMSEXIT, item='Exit', |
65 |
kind=wxITEM_NORMAL) |
66 |
|
67 |
def _init_coll_menu2_Items(self, parent): |
68 |
# generated method, don't edit |
69 |
|
70 |
parent.Append(helpString='Contents', id=wxID_FRAGGLEVIEWPORTMENU2CONT, |
71 |
item='Contents', kind=wxITEM_NORMAL) |
72 |
parent.Append(helpString='About', id=wxID_FRAGGLEVIEWPORTMENU2ABOUT, |
73 |
item='About', kind=wxITEM_NORMAL) |
74 |
|
75 |
def _init_coll_menu1_Items(self, parent): |
76 |
# generated method, don't edit |
77 |
|
78 |
parent.Append(helpString='Configure Netfraggle', |
79 |
id=wxID_FRAGGLEVIEWPORTMENU1FPREFS, item='Preferences', |
80 |
kind=wxITEM_NORMAL) |
81 |
parent.Append(helpString='Exit Netfraggle', |
82 |
id=wxID_FRAGGLEVIEWPORTMENU1ITEMS1, item='Exit', |
83 |
kind=wxITEM_NORMAL) |
84 |
|
85 |
def _init_coll_menuBar1_Menus(self, parent): |
86 |
# generated method, don't edit |
87 |
|
88 |
parent.Append(menu=self.menu1, title='&File') |
89 |
parent.Append(menu=self.menu2, title='&Help') |
90 |
|
91 |
def _init_utils(self): |
92 |
# generated method, don't edit |
93 |
self.menuBar1 = wxMenuBar() |
94 |
self.menuBar1.SetAutoLayout(1) |
95 |
|
96 |
self.menu1 = wxMenu(title='') |
97 |
|
98 |
self.menu2 = wxMenu(title='') |
99 |
|
100 |
self.FraggleTaskBarMenu = wxMenu(title=u'NetFraggle') |
101 |
|
102 |
self._init_coll_menuBar1_Menus(self.menuBar1) |
103 |
self._init_coll_menu1_Items(self.menu1) |
104 |
self._init_coll_menu2_Items(self.menu2) |
105 |
self._init_coll_FraggleTaskBarMenu_Items(self.FraggleTaskBarMenu) |
106 |
|
107 |
def _init_ctrls(self, prnt): |
108 |
# generated method, don't edit |
109 |
wxMDIParentFrame.__init__(self, id=wxID_FRAGGLEVIEWPORT, |
110 |
name='fraggleViewport', parent=prnt, pos=wxPoint(338, 296), |
111 |
size=wxSize(435, 296), |
112 |
style=wxDEFAULT_FRAME_STYLE | wxVSCROLL | wxHSCROLL, |
113 |
title='NetFraggle 0.0.1') |
114 |
self._init_utils() |
115 |
self.SetClientSize(wxSize(427, 269)) |
116 |
self.SetMenuBar(self.menuBar1) |
117 |
|
118 |
def __init_preferences__(self): |
119 |
self.preferencesCtl = fraggleCtlPreferences.create(self) |
120 |
self.dialogPrefs = fraggleDialogPrefs.create(self) |
121 |
self.dialogPrefs.loadConfig() |
122 |
self.dialogPrefs.updateConfig() |
123 |
|
124 |
# new as of 2004-08-26: TopicFrame |
125 |
# new as of 2004-08-27: pass configList to TopicFrame |
126 |
self.topicFrame = FraggleTopicFrame.create(self, self.preferencesCtl.configList) |
127 |
self.topicFrame.Move(wxPoint(5, 5)) |
128 |
|
129 |
#frame.Show() |
130 |
#frame.Destroy() |
131 |
def __init_xmlrpc__(self): |
132 |
#self.xml_rpc = FraggleXMLRPC.create(self, self.preferencesCtl.configList) |
133 |
pass |
134 |
|
135 |
def __init_taskbar_icon__(self): |
136 |
if os.name == 'posix': |
137 |
pass |
138 |
elif os.name == 'nt': |
139 |
self.tbicon = wxTaskBarIcon() |
140 |
#icon = wxIcon('mixxx.ico', wxBITMAP_TYPE_ICO) |
141 |
icon = wxIcon(os.path.join(APPLOCATION, 'mixxx.ico'), wxBITMAP_TYPE_ICO) |
142 |
self.tbicon.SetIcon(icon, '') |
143 |
EVT_TASKBAR_LEFT_DCLICK(self.tbicon, self.OnTaskBarLeftDClick) |
144 |
EVT_TASKBAR_RIGHT_UP(self.tbicon, self.OnTaskBarRightClick) |
145 |
EVT_MENU(self.tbicon, wxID_FRAGGLEVIEWPORTFRAGGLETASKBARMENUITEMSRESTORE, self.OnTaskBarAppRestore) |
146 |
EVT_MENU(self.tbicon, wxID_FRAGGLEVIEWPORTFRAGGLETASKBARMENUITEMSEXIT, self.OnTaskBarAppExit) |
147 |
|
148 |
def __init__(self, parent): |
149 |
self._init_ctrls(parent) |
150 |
self.__init_preferences__() |
151 |
self.__init_taskbar_icon__() |
152 |
self.__init_xmlrpc__() |
153 |
|
154 |
def OnMenu1items0Menu(self, event): |
155 |
try: |
156 |
self.dialogPrefs.ShowModal() |
157 |
finally: |
158 |
self.dialogPrefs.Hide() |
159 |
event.Skip() |
160 |
|
161 |
def OnMenu1items1Menu(self, event): |
162 |
self.Destroy() |
163 |
event.Skip() |
164 |
|
165 |
|
166 |
def OnMenu2items0Menu(self, event): |
167 |
try: |
168 |
self.dialogPrefs.ShowModal() |
169 |
finally: |
170 |
pass |
171 |
event.Skip() |
172 |
|
173 |
def OnMenu2items1Menu(self, event): |
174 |
"""Show about screen""" |
175 |
dlg = FraggleAboutDialog.create(self) |
176 |
dlg.ShowModal() |
177 |
dlg.Destroy() |
178 |
|
179 |
def OnTaskBarLeftDClick(self, event): |
180 |
#event.Skip() |
181 |
#self.SetFocus() |
182 |
if self.IsIconized(): |
183 |
self.Restore() |
184 |
else: |
185 |
self.Iconize() |
186 |
|
187 |
def OnTaskBarRightClick(self, event): |
188 |
#event.Skip() |
189 |
self.tbicon.PopupMenu(self.FraggleTaskBarMenu) |
190 |
|
191 |
def OnTaskBarAppRestore(self, event): |
192 |
self.Restore() |
193 |
#event.Skip() |
194 |
|
195 |
def OnTaskBarAppExit(self, event): |
196 |
#event.Skip() |
197 |
#self.Destroy() |
198 |
self.Close(True) |
199 |
|