blob: a4cd7746af51216fc02c2c362314c17b242b425e [file] [log] [blame]
Jack Jansenfcdf4371996-04-10 14:43:17 +00001# Test TE module.
2# Draw a window in which the user can type.
3#
4# This test expects Win, Evt and FrameWork (and anything used by those)
5# to work.
6#
7# Actually, it is more a test of FrameWork by now....
8
9from FrameWork import *
10import Win
11import Qd
12import TE
13import os
14
15class TEWindow(Window):
16 def open(self, name):
17 r = (40, 40, 400, 300)
18 w = Win.NewWindow(r, name, 1, 0, -1, 1, 0x55555555)
19 r2 = (0, 0, 345, 245)
20 Qd.SetPort(w)
21 self.ted = TE.TENew(r2, r2)
Jack Jansenc9c0dd31996-04-11 15:40:32 +000022 self.ted.TEAutoView(1)
Jack Jansenfcdf4371996-04-10 14:43:17 +000023 w.DrawGrowIcon()
24 self.wid = w
25 self.do_postopen()
26
27 def do_idle(self):
28 self.ted.TEIdle()
29
30 def do_activate(self, onoff, evt):
31 if onoff:
32 self.ted.TEActivate()
33 else:
34 self.ted.TEDeactivate()
35
Jack Jansenc9c0dd31996-04-11 15:40:32 +000036 def do_update(self, wid, event):
37 Qd.EraseRect(wid.GetWindowPort().portRect)
38 self.ted.TEUpdate(wid.GetWindowPort().portRect)
Jack Jansenfcdf4371996-04-10 14:43:17 +000039
40 def do_contentclick(self, local, modifiers, evt):
41 shifted = (modifiers & 0x200)
42 self.ted.TEClick(local, shifted)
43
44 def do_char(self, ch, event):
Jack Jansenc9c0dd31996-04-11 15:40:32 +000045 self.ted.TEKey(ord(ch))
Jack Jansenfcdf4371996-04-10 14:43:17 +000046
47class TestList(Application):
48 def __init__(self):
49 Application.__init__(self)
50 self.num = 0
51 self.listoflists = []
52
53 def makeusermenus(self):
54 self.filemenu = m = Menu(self.menubar, "File")
55 self.newitem = MenuItem(m, "New window...", "O", self.open)
56 self.quititem = MenuItem(m, "Quit", "Q", self.quit)
57
58 def open(self, *args):
59 w = TEWindow(self)
60 w.open('Window %d'%self.num)
61 self.num = self.num + 1
62 self.listoflists.append(w)
63
64 def quit(self, *args):
65 raise self
66
67 def do_about(self, id, item, window, event):
68 EasyDialogs.Message("""Test the TextEdit interface.
69 Simple window in which you can type""")
70
71 def do_idle(self, *args):
72 for l in self.listoflists:
73 l.do_idle()
74
75def main():
76 App = TestList()
77 App.mainloop()
78
79if __name__ == '__main__':
80 main()
81