blob: 661ad2bce96504275011b89cfd900fa9ae65f2fa [file] [log] [blame]
Jack Jansene3532151996-04-12 16:24:44 +00001# Test FrameWork scrollbars
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 MyWindow(ScrolledWindow):
16 def open(self, name):
17 r = (40, 40, 400, 300)
18 w = Win.NewWindow(r, name, 1, 0, -1, 1, 0x55555555)
19 self.ourrect = 0, 0, 360-SCROLLBARWIDTH-1, 260-SCROLLBARWIDTH-1
20 Qd.SetPort(w)
21 w.DrawGrowIcon()
22 self.wid = w
23 self.do_postopen()
24 self.vx = self.vy = 0
25 self.scrollbars()
26
27 def getscrollbarvalues(self):
28 return self.vx, self.vy
29
30 def scrollbar_callback(self, which, what, value):
31 if what == '-':
32 delta = -1
33 elif what == '--':
34 delta = -100
35 elif what == '+':
36 delta = 1
37 elif what == '++':
38 delta = 100
39
40 if which == 'x':
41 if value:
42 self.vx = value
43 else:
44 self.vx = self.vx + delta
45 else:
46 if value:
47 self.vy = value
48 else:
49 self.vy = self.vy + delta
Jack Jansen73023402001-01-23 14:58:20 +000050 self.wid.InvalWindowRect(self.ourrect)
Jack Jansene3532151996-04-12 16:24:44 +000051
52 def do_update(self, wid, event):
53 Qd.EraseRect(self.ourrect)
54 Qd.MoveTo(40, 40)
55 Qd.DrawString("x=%d, y=%d"%(self.vx, self.vy))
56
57class TestSW(Application):
58 def __init__(self):
59 Application.__init__(self)
60 self.num = 0
61 self.listoflists = []
62
63 def makeusermenus(self):
64 self.filemenu = m = Menu(self.menubar, "File")
65 self.newitem = MenuItem(m, "New window...", "O", self.open)
66 self.quititem = MenuItem(m, "Quit", "Q", self.quit)
67
68 def open(self, *args):
69 w = MyWindow(self)
70 w.open('Window %d'%self.num)
71 self.num = self.num + 1
72 self.listoflists.append(w)
73
74 def quit(self, *args):
75 raise self
76
77 def do_about(self, id, item, window, event):
78 EasyDialogs.Message("""Test scrolling FrameWork windows""")
79
80def main():
81 App = TestSW()
82 App.mainloop()
83
84if __name__ == '__main__':
85 main()
86