1996-09-24 12:35:50 -03:00
|
|
|
# A stab at a python debugger
|
|
|
|
import Res
|
|
|
|
import Qd
|
|
|
|
import Dlg
|
|
|
|
import Win
|
|
|
|
import FrameWork
|
|
|
|
import EasyDialogs
|
|
|
|
import sys
|
1996-09-26 13:26:05 -03:00
|
|
|
import TwitCore
|
1996-09-24 12:35:50 -03:00
|
|
|
from mac_widgets import MT_AnyList, MT_IconTextWidget
|
|
|
|
|
|
|
|
# Our dialogs
|
|
|
|
ID_MODULES=512
|
|
|
|
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
|
|
|
|
|
1996-09-26 13:26:05 -03:00
|
|
|
class ModuleBrowser(FrameWork.DialogWindow, TwitCore.ModuleBrowser):
|
1996-09-24 12:35:50 -03:00
|
|
|
"""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)
|
|
|
|
self.mi_open(module)
|
|
|
|
|
|
|
|
def create_items(self):
|
|
|
|
"""Create the lists we need"""
|
|
|
|
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)
|
|
|
|
|
|
|
|
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 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)
|
|
|
|
|
1996-09-26 13:26:05 -03:00
|
|
|
def force_redraw(self):
|
|
|
|
Qd.SetPort(self.wid)
|
|
|
|
Win.InvalRgn(self.wid.GetWindowPort().visRgn)
|
|
|
|
|
1996-09-24 12:35:50 -03:00
|
|
|
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()
|
|
|
|
|