blob: 59e250d7636c0b2f595c16f0ae9ec9d705857ed1 [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)
22 w.DrawGrowIcon()
23 self.wid = w
24 self.do_postopen()
25
26 def do_idle(self):
27 self.ted.TEIdle()
28
29 def do_activate(self, onoff, evt):
30 if onoff:
31 self.ted.TEActivate()
32 else:
33 self.ted.TEDeactivate()
34
35 def do_rawupdate(self, window, event):
36 window.BeginUpdate()
37 self.do_update(window, event)
38 window.EndUpdate()
39
40 def do_update(self, *args):
41 Qd.EraseRect(self.wid.GetWindowPort().portRect)
42 self.ted.TEUpdate(self.wid.GetWindowPort().portRect)
43
44 def do_contentclick(self, local, modifiers, evt):
45 shifted = (modifiers & 0x200)
46 self.ted.TEClick(local, shifted)
47
48 def do_char(self, ch, event):
49 self.ted.TEKey(ch)
50
51class TestList(Application):
52 def __init__(self):
53 Application.__init__(self)
54 self.num = 0
55 self.listoflists = []
56
57 def makeusermenus(self):
58 self.filemenu = m = Menu(self.menubar, "File")
59 self.newitem = MenuItem(m, "New window...", "O", self.open)
60 self.quititem = MenuItem(m, "Quit", "Q", self.quit)
61
62 def open(self, *args):
63 w = TEWindow(self)
64 w.open('Window %d'%self.num)
65 self.num = self.num + 1
66 self.listoflists.append(w)
67
68 def quit(self, *args):
69 raise self
70
71 def do_about(self, id, item, window, event):
72 EasyDialogs.Message("""Test the TextEdit interface.
73 Simple window in which you can type""")
74
75 def do_idle(self, *args):
76 for l in self.listoflists:
77 l.do_idle()
78
79def main():
80 App = TestList()
81 App.mainloop()
82
83if __name__ == '__main__':
84 main()
85