1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
|
# A stab at a python debugger
import Res
import Qd
import Dlg
import Win
import FrameWork
import EasyDialogs
import sys
import TwitCore
from mac_widgets import MT_AnyList, MT_IconTextWidget
# Our dialogs
ID_MODULES=500
I_MODULES_TITLE=1
I_MODULES=2
I_VARS_TITLE=3
I_VARS=4
I_SOURCE_TITLE=5
I_SOURCE=6
I_RULER=7
I_EDIT=8
class ModuleBrowser(FrameWork.DialogWindow, TwitCore.ModuleBrowser):
"""The module-browser dialog - mac-dependent part"""
def open(self, module):
FrameWork.DialogWindow.open(self, ID_MODULES)
self.SetPort()
Qd.TextFont(3)
Qd.TextSize(9)
tp, h, rect = self.wid.GetDialogItem(I_MODULES)
self.modules = MT_AnyList(self.wid, rect, 1)
tp, h, rect = self.wid.GetDialogItem(I_VARS)
self.vars = MT_AnyList(self.wid, rect, 2)
tp, h, rect = self.wid.GetDialogItem(I_SOURCE)
self.source = MT_IconTextWidget(self.wid, rect)
self.mi_open(module)
def setsource(self, msg):
tp, h, rect = self.wid.GetDialogItem(I_SOURCE_TITLE)
if self.cur_source:
Dlg.SetDialogItemText(h, self.cur_source)
else:
Dlg.SetDialogItemText(h, msg)
self.source.setcontent(self.cur_source)
def source_setbreaks(self, list):
self.source.setbreaks(list)
def source_setline(self, lineno, icon):
self.source.setcurline(lineno, icon)
def source_select(self, lineno):
self.source.select(lineno)
def setmodulenames(self):
self.modules.setcontent(self.cont_modules)
def module_select(self, number):
self.modules.select(number)
def setvars(self):
self.vars.setcontent(self.cont_varnames, self.cont_varvalues)
def do_itemhit(self, item, event):
(what, message, when, where, modifiers) = event
Qd.SetPort(self.wid)
where = Qd.GlobalToLocal(where)
if item == I_MODULES:
new_module, double = self.modules.click(where, 0)
self.click_module(new_module)
elif item == I_VARS:
new_var, double = self.vars.click(where, 0)
if double:
self.click_var(new_var)
elif item == I_SOURCE:
lineno, inborder = self.source.click(where, 0)
if lineno <> None and lineno >= 0:
self.click_source(lineno, inborder)
elif item == I_EDIT:
self.click_edit()
def do_rawupdate(self, window, event):
Qd.SetPort(self.wid)
rgn = self.wid.GetWindowPort().visRgn
tp, h, rect = self.wid.GetDialogItem(I_RULER)
Qd.MoveTo(rect[0], rect[1])
Qd.LineTo(rect[2], rect[1])
self.modules.update(rgn)
self.vars.update(rgn)
self.source.update(rgn)
def force_redraw(self):
Qd.SetPort(self.wid)
Win.InvalRgn(self.wid.GetWindowPort().visRgn)
def do_activate(self, activate, event):
self.modules.activate(activate)
self.vars.activate(activate)
self.source.activate(activate)
def close(self):
self.parent.module_dialog = None
self.source.close()
del self.modules
del self.vars
del self.source
self.do_postclose()
if __name__ == '__main__':
main()
|