|
4 | 4 | # |
5 | 5 | # This test expects Win, Evt and FrameWork (and anything used by those) |
6 | 6 | # to work. |
| 7 | +# |
| 8 | +# Actually, it is more a test of FrameWork by now.... |
7 | 9 |
|
8 | 10 | from FrameWork import * |
9 | 11 | import Win |
10 | 12 | import Qd |
11 | 13 | import List |
12 | 14 | import os |
13 | 15 |
|
14 | | -class TestList(Application): |
15 | | - def __init__(self): |
16 | | - os.chdir('Moes:') |
17 | | - self.makemenubar() |
18 | | - self.makewindow() |
19 | | - |
20 | | - def makewindow(self): |
| 16 | +class ListWindow(Window): |
| 17 | + def open(self, name, where): |
| 18 | + self.where = where |
21 | 19 | r = (40, 40, 400, 300) |
22 | | - w = Win.NewWindow(r, "List test", 1, 0, -1, 1, 0x55555555) |
| 20 | + w = Win.NewWindow(r, name, 1, 0, -1, 1, 0x55555555) |
23 | 21 | r2 = (0, 0, 345, 245) |
24 | 22 | self.list = List.LNew(r2, (0, 0, 1, 1), (0,0), 0, w, 0, 1, 1, 1) |
25 | 23 | self.filllist() |
26 | 24 | w.DrawGrowIcon() |
27 | | - self.win = w |
| 25 | + self.wid = w |
| 26 | + self.do_postopen() |
28 | 27 |
|
29 | | - def makeusermenus(self): |
30 | | - self.filemenu = m = Menu(self.menubar, "File") |
31 | | - self.quititem = MenuItem(m, "Quit", "Q", self.quit) |
32 | | - |
33 | | - def quit(self, *args): |
34 | | - raise self |
| 28 | + def do_activate(self, onoff, evt): |
| 29 | + self.list.LActivate(onoff) |
35 | 30 |
|
36 | | - def do_about(self, id, item, window, event): |
37 | | - EasyDialogs.Message("""Test the List Manager interface. |
38 | | - Double-click on a folder to change directory""") |
39 | | - |
40 | | - def do_activateEvt(self, *args): |
41 | | - self.list.LActivate(1) # XXXX Wrong... |
| 31 | + def do_rawupdate(self, window, event): |
| 32 | + window.BeginUpdate() |
| 33 | + self.do_update(window, event) |
| 34 | + window.EndUpdate() |
42 | 35 |
|
43 | 36 | def do_update(self, *args): |
44 | | - print 'LUPDATE' |
45 | 37 | self.list.LUpdate() |
46 | | - |
47 | | - def do_inContent(self, partcode, window, event): |
48 | | - (what, message, when, where, modifiers) = event |
49 | | - Qd.SetPort(window) |
50 | | - local = Qd.GlobalToLocal(where) |
51 | | - print 'CLICK', where, '->', local |
| 38 | + |
| 39 | + def do_contentclick(self, local, modifiers, evt): |
52 | 40 | dclick = self.list.LClick(local, modifiers) |
53 | 41 | if dclick: |
54 | 42 | h, v = self.list.LLastClick() |
55 | 43 | file = self.list.LGetCell(1000, (h, v)) |
56 | | - os.chdir(file) |
| 44 | + self.where = os.path.join(self.where, file) |
57 | 45 | self.filllist() |
58 | 46 |
|
59 | 47 | def filllist(self): |
60 | 48 | """Fill the list with the contents of the current directory""" |
61 | 49 | l = self.list |
62 | 50 | l.LSetDrawingMode(0) |
63 | 51 | l.LDelRow(0, 0) |
64 | | - contents = os.listdir(':') |
65 | | - print contents |
| 52 | + contents = os.listdir(self.where) |
66 | 53 | l.LAddRow(len(contents), 0) |
67 | 54 | for i in range(len(contents)): |
68 | 55 | l.LSetCell(contents[i], (0, i)) |
69 | 56 | l.LSetDrawingMode(1) |
70 | 57 | l.LUpdate() |
71 | 58 |
|
72 | 59 |
|
| 60 | +class TestList(Application): |
| 61 | + def __init__(self): |
| 62 | + Application.__init__(self) |
| 63 | + self.num = 0 |
| 64 | + self.listoflists = [] |
| 65 | + |
| 66 | + def makeusermenus(self): |
| 67 | + self.filemenu = m = Menu(self.menubar, "File") |
| 68 | + self.newitem = MenuItem(m, "New window...", "O", self.open) |
| 69 | + self.quititem = MenuItem(m, "Quit", "Q", self.quit) |
| 70 | + |
| 71 | + def open(self, *args): |
| 72 | + import macfs |
| 73 | + fss, ok = macfs.GetDirectory() |
| 74 | + if not ok: |
| 75 | + return |
| 76 | + w = ListWindow(self) |
| 77 | + w.open('Window %d'%self.num, fss.as_pathname()) |
| 78 | + self.num = self.num + 1 |
| 79 | + self.listoflists.append(w) |
| 80 | + |
| 81 | + def quit(self, *args): |
| 82 | + raise self |
| 83 | + |
| 84 | + def do_about(self, id, item, window, event): |
| 85 | + EasyDialogs.Message("""Test the List Manager interface. |
| 86 | + Simple inward-only folder browser""") |
| 87 | + |
73 | 88 | def main(): |
74 | 89 | App = TestList() |
75 | 90 | App.mainloop() |
|
0 commit comments