Mercurial > cpython-lru_cache-weakref
annotate Mac/Tools/twit/mac_widgets.py @ 5817:48b94de85bf3 legacy-trunk
Extensive changes by AMK.
| author | Guido van Rossum <guido@python.org> |
|---|---|
| date | Thu, 17 Jul 1997 16:29:42 +0000 |
| parents | 0f7515ebe3bf |
| children |
| rev | line source |
|---|---|
|
4331
c2eb38b674f3
The Window Independent Tracer (which will probably move elsewhere once
Jack Jansen <jack.jansen@cwi.nl>
parents:
diff
changeset
|
1 from FrameWork import * |
|
c2eb38b674f3
The Window Independent Tracer (which will probably move elsewhere once
Jack Jansen <jack.jansen@cwi.nl>
parents:
diff
changeset
|
2 import Win |
|
c2eb38b674f3
The Window Independent Tracer (which will probably move elsewhere once
Jack Jansen <jack.jansen@cwi.nl>
parents:
diff
changeset
|
3 import Qd |
|
c2eb38b674f3
The Window Independent Tracer (which will probably move elsewhere once
Jack Jansen <jack.jansen@cwi.nl>
parents:
diff
changeset
|
4 import Controls |
|
c2eb38b674f3
The Window Independent Tracer (which will probably move elsewhere once
Jack Jansen <jack.jansen@cwi.nl>
parents:
diff
changeset
|
5 import Ctl |
|
c2eb38b674f3
The Window Independent Tracer (which will probably move elsewhere once
Jack Jansen <jack.jansen@cwi.nl>
parents:
diff
changeset
|
6 import TE |
|
c2eb38b674f3
The Window Independent Tracer (which will probably move elsewhere once
Jack Jansen <jack.jansen@cwi.nl>
parents:
diff
changeset
|
7 import List |
|
c2eb38b674f3
The Window Independent Tracer (which will probably move elsewhere once
Jack Jansen <jack.jansen@cwi.nl>
parents:
diff
changeset
|
8 import os |
|
c2eb38b674f3
The Window Independent Tracer (which will probably move elsewhere once
Jack Jansen <jack.jansen@cwi.nl>
parents:
diff
changeset
|
9 import string |
|
c2eb38b674f3
The Window Independent Tracer (which will probably move elsewhere once
Jack Jansen <jack.jansen@cwi.nl>
parents:
diff
changeset
|
10 import macfs |
|
c2eb38b674f3
The Window Independent Tracer (which will probably move elsewhere once
Jack Jansen <jack.jansen@cwi.nl>
parents:
diff
changeset
|
11 |
|
c2eb38b674f3
The Window Independent Tracer (which will probably move elsewhere once
Jack Jansen <jack.jansen@cwi.nl>
parents:
diff
changeset
|
12 SCROLLBAR=16 |
|
c2eb38b674f3
The Window Independent Tracer (which will probably move elsewhere once
Jack Jansen <jack.jansen@cwi.nl>
parents:
diff
changeset
|
13 MARGIN=2 |
|
c2eb38b674f3
The Window Independent Tracer (which will probably move elsewhere once
Jack Jansen <jack.jansen@cwi.nl>
parents:
diff
changeset
|
14 ICONSIZE=16 |
|
c2eb38b674f3
The Window Independent Tracer (which will probably move elsewhere once
Jack Jansen <jack.jansen@cwi.nl>
parents:
diff
changeset
|
15 TEXTWIDTH=4096 # More-or-less random value |
|
c2eb38b674f3
The Window Independent Tracer (which will probably move elsewhere once
Jack Jansen <jack.jansen@cwi.nl>
parents:
diff
changeset
|
16 |
|
4336
4dbfd4dfe281
- Simplified inheritance structure (still not good enough)
Jack Jansen <jack.jansen@cwi.nl>
parents:
4333
diff
changeset
|
17 TEXTFONT=4 |
|
4dbfd4dfe281
- Simplified inheritance structure (still not good enough)
Jack Jansen <jack.jansen@cwi.nl>
parents:
4333
diff
changeset
|
18 TEXTSIZE=9 |
|
4dbfd4dfe281
- Simplified inheritance structure (still not good enough)
Jack Jansen <jack.jansen@cwi.nl>
parents:
4333
diff
changeset
|
19 |
|
4817
0f7515ebe3bf
Moved resources around to forestall conflicts with debuggee
Jack Jansen <jack.jansen@cwi.nl>
parents:
4387
diff
changeset
|
20 # Resource numbers |
|
0f7515ebe3bf
Moved resources around to forestall conflicts with debuggee
Jack Jansen <jack.jansen@cwi.nl>
parents:
4387
diff
changeset
|
21 PIC_CURRENT=500 |
|
0f7515ebe3bf
Moved resources around to forestall conflicts with debuggee
Jack Jansen <jack.jansen@cwi.nl>
parents:
4387
diff
changeset
|
22 PIC_BREAK=501 |
|
0f7515ebe3bf
Moved resources around to forestall conflicts with debuggee
Jack Jansen <jack.jansen@cwi.nl>
parents:
4387
diff
changeset
|
23 |
|
4331
c2eb38b674f3
The Window Independent Tracer (which will probably move elsewhere once
Jack Jansen <jack.jansen@cwi.nl>
parents:
diff
changeset
|
24 picture_cache={} |
|
c2eb38b674f3
The Window Independent Tracer (which will probably move elsewhere once
Jack Jansen <jack.jansen@cwi.nl>
parents:
diff
changeset
|
25 |
|
c2eb38b674f3
The Window Independent Tracer (which will probably move elsewhere once
Jack Jansen <jack.jansen@cwi.nl>
parents:
diff
changeset
|
26 class MT_TextWidget: |
|
c2eb38b674f3
The Window Independent Tracer (which will probably move elsewhere once
Jack Jansen <jack.jansen@cwi.nl>
parents:
diff
changeset
|
27 def __init__(self, wid, r): |
|
c2eb38b674f3
The Window Independent Tracer (which will probably move elsewhere once
Jack Jansen <jack.jansen@cwi.nl>
parents:
diff
changeset
|
28 self.wid = wid |
|
c2eb38b674f3
The Window Independent Tracer (which will probably move elsewhere once
Jack Jansen <jack.jansen@cwi.nl>
parents:
diff
changeset
|
29 self.rect = r |
|
c2eb38b674f3
The Window Independent Tracer (which will probably move elsewhere once
Jack Jansen <jack.jansen@cwi.nl>
parents:
diff
changeset
|
30 left, top, right, bottom = r |
|
c2eb38b674f3
The Window Independent Tracer (which will probably move elsewhere once
Jack Jansen <jack.jansen@cwi.nl>
parents:
diff
changeset
|
31 self.terect = left+MARGIN+ICONSIZE, top+MARGIN, \ |
|
c2eb38b674f3
The Window Independent Tracer (which will probably move elsewhere once
Jack Jansen <jack.jansen@cwi.nl>
parents:
diff
changeset
|
32 right-(MARGIN+SCROLLBAR), bottom-(MARGIN+SCROLLBAR) |
|
c2eb38b674f3
The Window Independent Tracer (which will probably move elsewhere once
Jack Jansen <jack.jansen@cwi.nl>
parents:
diff
changeset
|
33 dr = self.terect[0], self.terect[1], TEXTWIDTH, self.terect[3] |
|
c2eb38b674f3
The Window Independent Tracer (which will probably move elsewhere once
Jack Jansen <jack.jansen@cwi.nl>
parents:
diff
changeset
|
34 Qd.SetPort(wid) |
|
4336
4dbfd4dfe281
- Simplified inheritance structure (still not good enough)
Jack Jansen <jack.jansen@cwi.nl>
parents:
4333
diff
changeset
|
35 Qd.TextFont(TEXTFONT) |
|
4dbfd4dfe281
- Simplified inheritance structure (still not good enough)
Jack Jansen <jack.jansen@cwi.nl>
parents:
4333
diff
changeset
|
36 Qd.TextSize(TEXTSIZE) |
|
4331
c2eb38b674f3
The Window Independent Tracer (which will probably move elsewhere once
Jack Jansen <jack.jansen@cwi.nl>
parents:
diff
changeset
|
37 self.ted = TE.TENew(dr, self.terect) |
|
c2eb38b674f3
The Window Independent Tracer (which will probably move elsewhere once
Jack Jansen <jack.jansen@cwi.nl>
parents:
diff
changeset
|
38 self.ted.TEAutoView(1) |
|
c2eb38b674f3
The Window Independent Tracer (which will probably move elsewhere once
Jack Jansen <jack.jansen@cwi.nl>
parents:
diff
changeset
|
39 self.activate(1) |
|
c2eb38b674f3
The Window Independent Tracer (which will probably move elsewhere once
Jack Jansen <jack.jansen@cwi.nl>
parents:
diff
changeset
|
40 |
|
c2eb38b674f3
The Window Independent Tracer (which will probably move elsewhere once
Jack Jansen <jack.jansen@cwi.nl>
parents:
diff
changeset
|
41 rect = right-SCROLLBAR, top, right, bottom-SCROLLBAR+1 |
|
c2eb38b674f3
The Window Independent Tracer (which will probably move elsewhere once
Jack Jansen <jack.jansen@cwi.nl>
parents:
diff
changeset
|
42 self.bary = Ctl.NewControl(self.wid, rect, "", 1, 0, 0, 0, 16, 0) |
|
c2eb38b674f3
The Window Independent Tracer (which will probably move elsewhere once
Jack Jansen <jack.jansen@cwi.nl>
parents:
diff
changeset
|
43 rect = left, bottom-SCROLLBAR, right-SCROLLBAR+1, bottom |
|
c2eb38b674f3
The Window Independent Tracer (which will probably move elsewhere once
Jack Jansen <jack.jansen@cwi.nl>
parents:
diff
changeset
|
44 self.barx = Ctl.NewControl(self.wid, rect, "", 1, 0, 0, 0, 16, 0) |
|
c2eb38b674f3
The Window Independent Tracer (which will probably move elsewhere once
Jack Jansen <jack.jansen@cwi.nl>
parents:
diff
changeset
|
45 |
|
c2eb38b674f3
The Window Independent Tracer (which will probably move elsewhere once
Jack Jansen <jack.jansen@cwi.nl>
parents:
diff
changeset
|
46 self.have_data = 0 |
|
c2eb38b674f3
The Window Independent Tracer (which will probably move elsewhere once
Jack Jansen <jack.jansen@cwi.nl>
parents:
diff
changeset
|
47 self.line_index = [] |
|
c2eb38b674f3
The Window Independent Tracer (which will probably move elsewhere once
Jack Jansen <jack.jansen@cwi.nl>
parents:
diff
changeset
|
48 |
|
c2eb38b674f3
The Window Independent Tracer (which will probably move elsewhere once
Jack Jansen <jack.jansen@cwi.nl>
parents:
diff
changeset
|
49 def close(self): |
|
c2eb38b674f3
The Window Independent Tracer (which will probably move elsewhere once
Jack Jansen <jack.jansen@cwi.nl>
parents:
diff
changeset
|
50 del self.barx |
|
c2eb38b674f3
The Window Independent Tracer (which will probably move elsewhere once
Jack Jansen <jack.jansen@cwi.nl>
parents:
diff
changeset
|
51 del self.bary |
|
c2eb38b674f3
The Window Independent Tracer (which will probably move elsewhere once
Jack Jansen <jack.jansen@cwi.nl>
parents:
diff
changeset
|
52 del self.ted |
|
c2eb38b674f3
The Window Independent Tracer (which will probably move elsewhere once
Jack Jansen <jack.jansen@cwi.nl>
parents:
diff
changeset
|
53 |
|
c2eb38b674f3
The Window Independent Tracer (which will probably move elsewhere once
Jack Jansen <jack.jansen@cwi.nl>
parents:
diff
changeset
|
54 def scrollbars(self): |
|
c2eb38b674f3
The Window Independent Tracer (which will probably move elsewhere once
Jack Jansen <jack.jansen@cwi.nl>
parents:
diff
changeset
|
55 pass |
|
c2eb38b674f3
The Window Independent Tracer (which will probably move elsewhere once
Jack Jansen <jack.jansen@cwi.nl>
parents:
diff
changeset
|
56 |
|
c2eb38b674f3
The Window Independent Tracer (which will probably move elsewhere once
Jack Jansen <jack.jansen@cwi.nl>
parents:
diff
changeset
|
57 def setcontent(self, file): |
|
c2eb38b674f3
The Window Independent Tracer (which will probably move elsewhere once
Jack Jansen <jack.jansen@cwi.nl>
parents:
diff
changeset
|
58 self.line_index = [] |
|
c2eb38b674f3
The Window Independent Tracer (which will probably move elsewhere once
Jack Jansen <jack.jansen@cwi.nl>
parents:
diff
changeset
|
59 if file == None: |
|
c2eb38b674f3
The Window Independent Tracer (which will probably move elsewhere once
Jack Jansen <jack.jansen@cwi.nl>
parents:
diff
changeset
|
60 data = '' |
|
c2eb38b674f3
The Window Independent Tracer (which will probably move elsewhere once
Jack Jansen <jack.jansen@cwi.nl>
parents:
diff
changeset
|
61 self.have_data = 0 |
|
c2eb38b674f3
The Window Independent Tracer (which will probably move elsewhere once
Jack Jansen <jack.jansen@cwi.nl>
parents:
diff
changeset
|
62 else: |
|
c2eb38b674f3
The Window Independent Tracer (which will probably move elsewhere once
Jack Jansen <jack.jansen@cwi.nl>
parents:
diff
changeset
|
63 try: |
|
c2eb38b674f3
The Window Independent Tracer (which will probably move elsewhere once
Jack Jansen <jack.jansen@cwi.nl>
parents:
diff
changeset
|
64 fp = open(file, 'rb') # NOTE the binary |
|
c2eb38b674f3
The Window Independent Tracer (which will probably move elsewhere once
Jack Jansen <jack.jansen@cwi.nl>
parents:
diff
changeset
|
65 data = fp.read() |
|
c2eb38b674f3
The Window Independent Tracer (which will probably move elsewhere once
Jack Jansen <jack.jansen@cwi.nl>
parents:
diff
changeset
|
66 self.have_data = 1 |
|
c2eb38b674f3
The Window Independent Tracer (which will probably move elsewhere once
Jack Jansen <jack.jansen@cwi.nl>
parents:
diff
changeset
|
67 except IOError, arg: |
|
c2eb38b674f3
The Window Independent Tracer (which will probably move elsewhere once
Jack Jansen <jack.jansen@cwi.nl>
parents:
diff
changeset
|
68 data = 'Cannot open file:\r'+`arg` |
|
c2eb38b674f3
The Window Independent Tracer (which will probably move elsewhere once
Jack Jansen <jack.jansen@cwi.nl>
parents:
diff
changeset
|
69 self.have_data = 0 |
|
c2eb38b674f3
The Window Independent Tracer (which will probably move elsewhere once
Jack Jansen <jack.jansen@cwi.nl>
parents:
diff
changeset
|
70 if len(data) > 32767: |
|
c2eb38b674f3
The Window Independent Tracer (which will probably move elsewhere once
Jack Jansen <jack.jansen@cwi.nl>
parents:
diff
changeset
|
71 self.have_data = 0 |
|
c2eb38b674f3
The Window Independent Tracer (which will probably move elsewhere once
Jack Jansen <jack.jansen@cwi.nl>
parents:
diff
changeset
|
72 data = 'File too big' |
|
c2eb38b674f3
The Window Independent Tracer (which will probably move elsewhere once
Jack Jansen <jack.jansen@cwi.nl>
parents:
diff
changeset
|
73 self.ted.TESetText(data) |
|
c2eb38b674f3
The Window Independent Tracer (which will probably move elsewhere once
Jack Jansen <jack.jansen@cwi.nl>
parents:
diff
changeset
|
74 if self.have_data: |
|
c2eb38b674f3
The Window Independent Tracer (which will probably move elsewhere once
Jack Jansen <jack.jansen@cwi.nl>
parents:
diff
changeset
|
75 cur = 0 |
|
c2eb38b674f3
The Window Independent Tracer (which will probably move elsewhere once
Jack Jansen <jack.jansen@cwi.nl>
parents:
diff
changeset
|
76 while 1: |
|
c2eb38b674f3
The Window Independent Tracer (which will probably move elsewhere once
Jack Jansen <jack.jansen@cwi.nl>
parents:
diff
changeset
|
77 self.line_index.append(cur) |
|
c2eb38b674f3
The Window Independent Tracer (which will probably move elsewhere once
Jack Jansen <jack.jansen@cwi.nl>
parents:
diff
changeset
|
78 try: |
|
c2eb38b674f3
The Window Independent Tracer (which will probably move elsewhere once
Jack Jansen <jack.jansen@cwi.nl>
parents:
diff
changeset
|
79 cur = string.index(data, '\r', cur+1) |
|
c2eb38b674f3
The Window Independent Tracer (which will probably move elsewhere once
Jack Jansen <jack.jansen@cwi.nl>
parents:
diff
changeset
|
80 except ValueError: |
|
c2eb38b674f3
The Window Independent Tracer (which will probably move elsewhere once
Jack Jansen <jack.jansen@cwi.nl>
parents:
diff
changeset
|
81 break |
|
c2eb38b674f3
The Window Independent Tracer (which will probably move elsewhere once
Jack Jansen <jack.jansen@cwi.nl>
parents:
diff
changeset
|
82 self.line_index.append(len(data)) |
|
c2eb38b674f3
The Window Independent Tracer (which will probably move elsewhere once
Jack Jansen <jack.jansen@cwi.nl>
parents:
diff
changeset
|
83 Win.InvalRect(self.rect) |
|
c2eb38b674f3
The Window Independent Tracer (which will probably move elsewhere once
Jack Jansen <jack.jansen@cwi.nl>
parents:
diff
changeset
|
84 self.ted.TESetSelect(0,0) |
|
c2eb38b674f3
The Window Independent Tracer (which will probably move elsewhere once
Jack Jansen <jack.jansen@cwi.nl>
parents:
diff
changeset
|
85 self.ted.TECalText() |
|
c2eb38b674f3
The Window Independent Tracer (which will probably move elsewhere once
Jack Jansen <jack.jansen@cwi.nl>
parents:
diff
changeset
|
86 self.ted.TESelView() |
|
c2eb38b674f3
The Window Independent Tracer (which will probably move elsewhere once
Jack Jansen <jack.jansen@cwi.nl>
parents:
diff
changeset
|
87 self.setscrollbars() |
|
c2eb38b674f3
The Window Independent Tracer (which will probably move elsewhere once
Jack Jansen <jack.jansen@cwi.nl>
parents:
diff
changeset
|
88 |
|
c2eb38b674f3
The Window Independent Tracer (which will probably move elsewhere once
Jack Jansen <jack.jansen@cwi.nl>
parents:
diff
changeset
|
89 def setscrollbars(self): |
|
c2eb38b674f3
The Window Independent Tracer (which will probably move elsewhere once
Jack Jansen <jack.jansen@cwi.nl>
parents:
diff
changeset
|
90 docleft, doctop, docright, docbot = self.ted.destRect |
|
c2eb38b674f3
The Window Independent Tracer (which will probably move elsewhere once
Jack Jansen <jack.jansen@cwi.nl>
parents:
diff
changeset
|
91 winleft, wintop, winright, winbot = self.ted.viewRect |
|
c2eb38b674f3
The Window Independent Tracer (which will probably move elsewhere once
Jack Jansen <jack.jansen@cwi.nl>
parents:
diff
changeset
|
92 docbot = self.ted.nLines*self.ted.lineHeight + doctop |
|
c2eb38b674f3
The Window Independent Tracer (which will probably move elsewhere once
Jack Jansen <jack.jansen@cwi.nl>
parents:
diff
changeset
|
93 self.setbar(self.barx, docleft, docright, winleft, winright) |
|
c2eb38b674f3
The Window Independent Tracer (which will probably move elsewhere once
Jack Jansen <jack.jansen@cwi.nl>
parents:
diff
changeset
|
94 self.setbar(self.bary, doctop, docbot, wintop, winbot) |
|
c2eb38b674f3
The Window Independent Tracer (which will probably move elsewhere once
Jack Jansen <jack.jansen@cwi.nl>
parents:
diff
changeset
|
95 |
|
c2eb38b674f3
The Window Independent Tracer (which will probably move elsewhere once
Jack Jansen <jack.jansen@cwi.nl>
parents:
diff
changeset
|
96 def setbar(self, bar, minmin, maxmax, curmin, curmax): |
|
c2eb38b674f3
The Window Independent Tracer (which will probably move elsewhere once
Jack Jansen <jack.jansen@cwi.nl>
parents:
diff
changeset
|
97 if maxmax-minmin > 32767 or (curmin <= minmin and curmax >= maxmax): |
|
c2eb38b674f3
The Window Independent Tracer (which will probably move elsewhere once
Jack Jansen <jack.jansen@cwi.nl>
parents:
diff
changeset
|
98 bar.SetControlMinimum(0) |
|
c2eb38b674f3
The Window Independent Tracer (which will probably move elsewhere once
Jack Jansen <jack.jansen@cwi.nl>
parents:
diff
changeset
|
99 bar.SetControlMaximum(0) |
|
c2eb38b674f3
The Window Independent Tracer (which will probably move elsewhere once
Jack Jansen <jack.jansen@cwi.nl>
parents:
diff
changeset
|
100 bar.SetControlValue(0) |
|
c2eb38b674f3
The Window Independent Tracer (which will probably move elsewhere once
Jack Jansen <jack.jansen@cwi.nl>
parents:
diff
changeset
|
101 return |
|
c2eb38b674f3
The Window Independent Tracer (which will probably move elsewhere once
Jack Jansen <jack.jansen@cwi.nl>
parents:
diff
changeset
|
102 bar.SetControlMinimum(minmin) |
|
c2eb38b674f3
The Window Independent Tracer (which will probably move elsewhere once
Jack Jansen <jack.jansen@cwi.nl>
parents:
diff
changeset
|
103 bar.SetControlMaximum(maxmax-(curmax-curmin)) |
|
c2eb38b674f3
The Window Independent Tracer (which will probably move elsewhere once
Jack Jansen <jack.jansen@cwi.nl>
parents:
diff
changeset
|
104 bar.SetControlValue(curmin) |
|
c2eb38b674f3
The Window Independent Tracer (which will probably move elsewhere once
Jack Jansen <jack.jansen@cwi.nl>
parents:
diff
changeset
|
105 |
|
c2eb38b674f3
The Window Independent Tracer (which will probably move elsewhere once
Jack Jansen <jack.jansen@cwi.nl>
parents:
diff
changeset
|
106 def update(self, rgn): |
|
c2eb38b674f3
The Window Independent Tracer (which will probably move elsewhere once
Jack Jansen <jack.jansen@cwi.nl>
parents:
diff
changeset
|
107 Qd.EraseRect(self.terect) |
|
c2eb38b674f3
The Window Independent Tracer (which will probably move elsewhere once
Jack Jansen <jack.jansen@cwi.nl>
parents:
diff
changeset
|
108 Qd.FrameRect(self.rect) |
|
c2eb38b674f3
The Window Independent Tracer (which will probably move elsewhere once
Jack Jansen <jack.jansen@cwi.nl>
parents:
diff
changeset
|
109 self.ted.TEUpdate(self.terect) |
|
c2eb38b674f3
The Window Independent Tracer (which will probably move elsewhere once
Jack Jansen <jack.jansen@cwi.nl>
parents:
diff
changeset
|
110 |
|
c2eb38b674f3
The Window Independent Tracer (which will probably move elsewhere once
Jack Jansen <jack.jansen@cwi.nl>
parents:
diff
changeset
|
111 def activate(self, onoff): |
|
c2eb38b674f3
The Window Independent Tracer (which will probably move elsewhere once
Jack Jansen <jack.jansen@cwi.nl>
parents:
diff
changeset
|
112 if onoff: |
|
c2eb38b674f3
The Window Independent Tracer (which will probably move elsewhere once
Jack Jansen <jack.jansen@cwi.nl>
parents:
diff
changeset
|
113 self.ted.TEActivate() |
|
c2eb38b674f3
The Window Independent Tracer (which will probably move elsewhere once
Jack Jansen <jack.jansen@cwi.nl>
parents:
diff
changeset
|
114 else: |
|
c2eb38b674f3
The Window Independent Tracer (which will probably move elsewhere once
Jack Jansen <jack.jansen@cwi.nl>
parents:
diff
changeset
|
115 self.ted.TEDeactivate() |
|
c2eb38b674f3
The Window Independent Tracer (which will probably move elsewhere once
Jack Jansen <jack.jansen@cwi.nl>
parents:
diff
changeset
|
116 |
|
c2eb38b674f3
The Window Independent Tracer (which will probably move elsewhere once
Jack Jansen <jack.jansen@cwi.nl>
parents:
diff
changeset
|
117 def select(self, line): |
|
c2eb38b674f3
The Window Independent Tracer (which will probably move elsewhere once
Jack Jansen <jack.jansen@cwi.nl>
parents:
diff
changeset
|
118 if line == None or line <= 0 or not self.have_data: |
|
c2eb38b674f3
The Window Independent Tracer (which will probably move elsewhere once
Jack Jansen <jack.jansen@cwi.nl>
parents:
diff
changeset
|
119 self.ted.TESetSelect(0,0) |
|
c2eb38b674f3
The Window Independent Tracer (which will probably move elsewhere once
Jack Jansen <jack.jansen@cwi.nl>
parents:
diff
changeset
|
120 else: |
|
c2eb38b674f3
The Window Independent Tracer (which will probably move elsewhere once
Jack Jansen <jack.jansen@cwi.nl>
parents:
diff
changeset
|
121 line = line - 1 |
|
c2eb38b674f3
The Window Independent Tracer (which will probably move elsewhere once
Jack Jansen <jack.jansen@cwi.nl>
parents:
diff
changeset
|
122 if line > len(self.line_index)-1: line = len(self.line_index)-1 |
|
c2eb38b674f3
The Window Independent Tracer (which will probably move elsewhere once
Jack Jansen <jack.jansen@cwi.nl>
parents:
diff
changeset
|
123 if line == 1: |
|
c2eb38b674f3
The Window Independent Tracer (which will probably move elsewhere once
Jack Jansen <jack.jansen@cwi.nl>
parents:
diff
changeset
|
124 self.ted.TESetSelect(0, self.line_index[1]) |
|
c2eb38b674f3
The Window Independent Tracer (which will probably move elsewhere once
Jack Jansen <jack.jansen@cwi.nl>
parents:
diff
changeset
|
125 else: |
|
c2eb38b674f3
The Window Independent Tracer (which will probably move elsewhere once
Jack Jansen <jack.jansen@cwi.nl>
parents:
diff
changeset
|
126 self.ted.TESetSelect(self.line_index[line]+1, self.line_index[line+1]) |
|
c2eb38b674f3
The Window Independent Tracer (which will probably move elsewhere once
Jack Jansen <jack.jansen@cwi.nl>
parents:
diff
changeset
|
127 self.setscrollbars() |
|
c2eb38b674f3
The Window Independent Tracer (which will probably move elsewhere once
Jack Jansen <jack.jansen@cwi.nl>
parents:
diff
changeset
|
128 |
|
c2eb38b674f3
The Window Independent Tracer (which will probably move elsewhere once
Jack Jansen <jack.jansen@cwi.nl>
parents:
diff
changeset
|
129 def click(self, where, modifiers): |
|
c2eb38b674f3
The Window Independent Tracer (which will probably move elsewhere once
Jack Jansen <jack.jansen@cwi.nl>
parents:
diff
changeset
|
130 # First check scrollbars |
|
c2eb38b674f3
The Window Independent Tracer (which will probably move elsewhere once
Jack Jansen <jack.jansen@cwi.nl>
parents:
diff
changeset
|
131 ctltype, control = Ctl.FindControl(where, self.wid) |
|
c2eb38b674f3
The Window Independent Tracer (which will probably move elsewhere once
Jack Jansen <jack.jansen@cwi.nl>
parents:
diff
changeset
|
132 if ctltype and control: |
|
c2eb38b674f3
The Window Independent Tracer (which will probably move elsewhere once
Jack Jansen <jack.jansen@cwi.nl>
parents:
diff
changeset
|
133 partcode = control.TrackControl(where) |
|
c2eb38b674f3
The Window Independent Tracer (which will probably move elsewhere once
Jack Jansen <jack.jansen@cwi.nl>
parents:
diff
changeset
|
134 if partcode: |
|
c2eb38b674f3
The Window Independent Tracer (which will probably move elsewhere once
Jack Jansen <jack.jansen@cwi.nl>
parents:
diff
changeset
|
135 self.controlhit(control, partcode) |
|
c2eb38b674f3
The Window Independent Tracer (which will probably move elsewhere once
Jack Jansen <jack.jansen@cwi.nl>
parents:
diff
changeset
|
136 return None, 0 |
|
c2eb38b674f3
The Window Independent Tracer (which will probably move elsewhere once
Jack Jansen <jack.jansen@cwi.nl>
parents:
diff
changeset
|
137 off = self.ted.TEGetOffset(where) |
|
c2eb38b674f3
The Window Independent Tracer (which will probably move elsewhere once
Jack Jansen <jack.jansen@cwi.nl>
parents:
diff
changeset
|
138 inborder = where[0] < self.terect[0] |
|
4336
4dbfd4dfe281
- Simplified inheritance structure (still not good enough)
Jack Jansen <jack.jansen@cwi.nl>
parents:
4333
diff
changeset
|
139 l, t, r, b = self.terect |
|
4dbfd4dfe281
- Simplified inheritance structure (still not good enough)
Jack Jansen <jack.jansen@cwi.nl>
parents:
4333
diff
changeset
|
140 if l <= where[0] <= r and t <= where[1] <= b or inborder: |
|
4dbfd4dfe281
- Simplified inheritance structure (still not good enough)
Jack Jansen <jack.jansen@cwi.nl>
parents:
4333
diff
changeset
|
141 return self.offsettoline(off), inborder |
|
4dbfd4dfe281
- Simplified inheritance structure (still not good enough)
Jack Jansen <jack.jansen@cwi.nl>
parents:
4333
diff
changeset
|
142 return None, 0 # In the grow box or something. |
|
4331
c2eb38b674f3
The Window Independent Tracer (which will probably move elsewhere once
Jack Jansen <jack.jansen@cwi.nl>
parents:
diff
changeset
|
143 |
|
c2eb38b674f3
The Window Independent Tracer (which will probably move elsewhere once
Jack Jansen <jack.jansen@cwi.nl>
parents:
diff
changeset
|
144 def offsettoline(self, offset): |
|
c2eb38b674f3
The Window Independent Tracer (which will probably move elsewhere once
Jack Jansen <jack.jansen@cwi.nl>
parents:
diff
changeset
|
145 for i in range(len(self.line_index)): |
|
c2eb38b674f3
The Window Independent Tracer (which will probably move elsewhere once
Jack Jansen <jack.jansen@cwi.nl>
parents:
diff
changeset
|
146 if offset < self.line_index[i]: |
|
c2eb38b674f3
The Window Independent Tracer (which will probably move elsewhere once
Jack Jansen <jack.jansen@cwi.nl>
parents:
diff
changeset
|
147 return i # Not i-1: 1-based line numbers in files |
|
c2eb38b674f3
The Window Independent Tracer (which will probably move elsewhere once
Jack Jansen <jack.jansen@cwi.nl>
parents:
diff
changeset
|
148 return None |
|
c2eb38b674f3
The Window Independent Tracer (which will probably move elsewhere once
Jack Jansen <jack.jansen@cwi.nl>
parents:
diff
changeset
|
149 |
|
c2eb38b674f3
The Window Independent Tracer (which will probably move elsewhere once
Jack Jansen <jack.jansen@cwi.nl>
parents:
diff
changeset
|
150 def controlhit(self, control, partcode): |
|
c2eb38b674f3
The Window Independent Tracer (which will probably move elsewhere once
Jack Jansen <jack.jansen@cwi.nl>
parents:
diff
changeset
|
151 if partcode <> Controls.inThumb: |
|
c2eb38b674f3
The Window Independent Tracer (which will probably move elsewhere once
Jack Jansen <jack.jansen@cwi.nl>
parents:
diff
changeset
|
152 if control == self.barx: |
|
c2eb38b674f3
The Window Independent Tracer (which will probably move elsewhere once
Jack Jansen <jack.jansen@cwi.nl>
parents:
diff
changeset
|
153 if partcode == Controls.inUpButton: |
|
c2eb38b674f3
The Window Independent Tracer (which will probably move elsewhere once
Jack Jansen <jack.jansen@cwi.nl>
parents:
diff
changeset
|
154 delta = -10 |
|
c2eb38b674f3
The Window Independent Tracer (which will probably move elsewhere once
Jack Jansen <jack.jansen@cwi.nl>
parents:
diff
changeset
|
155 if partcode == Controls.inDownButton: |
|
c2eb38b674f3
The Window Independent Tracer (which will probably move elsewhere once
Jack Jansen <jack.jansen@cwi.nl>
parents:
diff
changeset
|
156 delta = 10 |
|
c2eb38b674f3
The Window Independent Tracer (which will probably move elsewhere once
Jack Jansen <jack.jansen@cwi.nl>
parents:
diff
changeset
|
157 if partcode == Controls.inPageUp: |
|
c2eb38b674f3
The Window Independent Tracer (which will probably move elsewhere once
Jack Jansen <jack.jansen@cwi.nl>
parents:
diff
changeset
|
158 delta = 10-(self.terect[2]-self.terect[0]) |
|
c2eb38b674f3
The Window Independent Tracer (which will probably move elsewhere once
Jack Jansen <jack.jansen@cwi.nl>
parents:
diff
changeset
|
159 if partcode == Controls.inPageDown: |
|
c2eb38b674f3
The Window Independent Tracer (which will probably move elsewhere once
Jack Jansen <jack.jansen@cwi.nl>
parents:
diff
changeset
|
160 delta = (self.terect[2]-self.terect[0])-10 |
|
c2eb38b674f3
The Window Independent Tracer (which will probably move elsewhere once
Jack Jansen <jack.jansen@cwi.nl>
parents:
diff
changeset
|
161 old = control.GetControlValue() |
|
c2eb38b674f3
The Window Independent Tracer (which will probably move elsewhere once
Jack Jansen <jack.jansen@cwi.nl>
parents:
diff
changeset
|
162 control.SetControlValue(old+delta) |
|
c2eb38b674f3
The Window Independent Tracer (which will probably move elsewhere once
Jack Jansen <jack.jansen@cwi.nl>
parents:
diff
changeset
|
163 if control == self.bary: |
|
c2eb38b674f3
The Window Independent Tracer (which will probably move elsewhere once
Jack Jansen <jack.jansen@cwi.nl>
parents:
diff
changeset
|
164 if partcode == Controls.inUpButton: |
|
c2eb38b674f3
The Window Independent Tracer (which will probably move elsewhere once
Jack Jansen <jack.jansen@cwi.nl>
parents:
diff
changeset
|
165 delta = -self.ted.lineHeight |
|
c2eb38b674f3
The Window Independent Tracer (which will probably move elsewhere once
Jack Jansen <jack.jansen@cwi.nl>
parents:
diff
changeset
|
166 if partcode == Controls.inDownButton: |
|
c2eb38b674f3
The Window Independent Tracer (which will probably move elsewhere once
Jack Jansen <jack.jansen@cwi.nl>
parents:
diff
changeset
|
167 delta = self.ted.lineHeight |
|
c2eb38b674f3
The Window Independent Tracer (which will probably move elsewhere once
Jack Jansen <jack.jansen@cwi.nl>
parents:
diff
changeset
|
168 if partcode == Controls.inPageUp: |
|
c2eb38b674f3
The Window Independent Tracer (which will probably move elsewhere once
Jack Jansen <jack.jansen@cwi.nl>
parents:
diff
changeset
|
169 delta = self.ted.lineHeight-(self.terect[3]-self.terect[1]) |
|
c2eb38b674f3
The Window Independent Tracer (which will probably move elsewhere once
Jack Jansen <jack.jansen@cwi.nl>
parents:
diff
changeset
|
170 if partcode == Controls.inPageDown: |
|
c2eb38b674f3
The Window Independent Tracer (which will probably move elsewhere once
Jack Jansen <jack.jansen@cwi.nl>
parents:
diff
changeset
|
171 delta = (self.terect[3]-self.terect[1])-self.ted.lineHeight |
|
c2eb38b674f3
The Window Independent Tracer (which will probably move elsewhere once
Jack Jansen <jack.jansen@cwi.nl>
parents:
diff
changeset
|
172 old = control.GetControlValue() |
|
c2eb38b674f3
The Window Independent Tracer (which will probably move elsewhere once
Jack Jansen <jack.jansen@cwi.nl>
parents:
diff
changeset
|
173 control.SetControlValue(old+delta) |
|
c2eb38b674f3
The Window Independent Tracer (which will probably move elsewhere once
Jack Jansen <jack.jansen@cwi.nl>
parents:
diff
changeset
|
174 newx = self.barx.GetControlValue() |
|
c2eb38b674f3
The Window Independent Tracer (which will probably move elsewhere once
Jack Jansen <jack.jansen@cwi.nl>
parents:
diff
changeset
|
175 newy = self.bary.GetControlValue() |
|
c2eb38b674f3
The Window Independent Tracer (which will probably move elsewhere once
Jack Jansen <jack.jansen@cwi.nl>
parents:
diff
changeset
|
176 oldx = self.ted.viewRect[0] |
|
c2eb38b674f3
The Window Independent Tracer (which will probably move elsewhere once
Jack Jansen <jack.jansen@cwi.nl>
parents:
diff
changeset
|
177 oldy = self.ted.viewRect[1] |
|
c2eb38b674f3
The Window Independent Tracer (which will probably move elsewhere once
Jack Jansen <jack.jansen@cwi.nl>
parents:
diff
changeset
|
178 self.ted.TEPinScroll(oldx-newx, oldy-newy) |
|
c2eb38b674f3
The Window Independent Tracer (which will probably move elsewhere once
Jack Jansen <jack.jansen@cwi.nl>
parents:
diff
changeset
|
179 self.setscrollbars() # XXXX Bibbert, maar hoe anders? |
|
c2eb38b674f3
The Window Independent Tracer (which will probably move elsewhere once
Jack Jansen <jack.jansen@cwi.nl>
parents:
diff
changeset
|
180 |
|
c2eb38b674f3
The Window Independent Tracer (which will probably move elsewhere once
Jack Jansen <jack.jansen@cwi.nl>
parents:
diff
changeset
|
181 class MT_IconTextWidget(MT_TextWidget): |
|
c2eb38b674f3
The Window Independent Tracer (which will probably move elsewhere once
Jack Jansen <jack.jansen@cwi.nl>
parents:
diff
changeset
|
182 def __init__(self, wid, r): |
|
c2eb38b674f3
The Window Independent Tracer (which will probably move elsewhere once
Jack Jansen <jack.jansen@cwi.nl>
parents:
diff
changeset
|
183 MT_TextWidget.__init__(self, wid, r) |
|
c2eb38b674f3
The Window Independent Tracer (which will probably move elsewhere once
Jack Jansen <jack.jansen@cwi.nl>
parents:
diff
changeset
|
184 self.breakpointlist = [] |
|
c2eb38b674f3
The Window Independent Tracer (which will probably move elsewhere once
Jack Jansen <jack.jansen@cwi.nl>
parents:
diff
changeset
|
185 self.curline = None |
|
c2eb38b674f3
The Window Independent Tracer (which will probably move elsewhere once
Jack Jansen <jack.jansen@cwi.nl>
parents:
diff
changeset
|
186 self.iconrect = (self.rect[0]+1, self.rect[1]+1, |
|
4387
2e272bf5a43e
Prepared for Tk windowing implementation
Jack Jansen <jack.jansen@cwi.nl>
parents:
4336
diff
changeset
|
187 self.terect[0]-1, self.rect[3]-SCROLLBAR) |
|
4331
c2eb38b674f3
The Window Independent Tracer (which will probably move elsewhere once
Jack Jansen <jack.jansen@cwi.nl>
parents:
diff
changeset
|
188 self.curlinerange = (self.terect[1]+self.ted.lineHeight, |
|
c2eb38b674f3
The Window Independent Tracer (which will probably move elsewhere once
Jack Jansen <jack.jansen@cwi.nl>
parents:
diff
changeset
|
189 self.terect[3]-2*self.ted.lineHeight) |
|
4817
0f7515ebe3bf
Moved resources around to forestall conflicts with debuggee
Jack Jansen <jack.jansen@cwi.nl>
parents:
4387
diff
changeset
|
190 self.piccurrent = PIC_CURRENT |
|
4331
c2eb38b674f3
The Window Independent Tracer (which will probably move elsewhere once
Jack Jansen <jack.jansen@cwi.nl>
parents:
diff
changeset
|
191 |
|
c2eb38b674f3
The Window Independent Tracer (which will probably move elsewhere once
Jack Jansen <jack.jansen@cwi.nl>
parents:
diff
changeset
|
192 def setbreaks(self, list): |
|
c2eb38b674f3
The Window Independent Tracer (which will probably move elsewhere once
Jack Jansen <jack.jansen@cwi.nl>
parents:
diff
changeset
|
193 self.breakpointlist = list[:] |
|
c2eb38b674f3
The Window Independent Tracer (which will probably move elsewhere once
Jack Jansen <jack.jansen@cwi.nl>
parents:
diff
changeset
|
194 Qd.SetPort(self.wid) |
|
c2eb38b674f3
The Window Independent Tracer (which will probably move elsewhere once
Jack Jansen <jack.jansen@cwi.nl>
parents:
diff
changeset
|
195 Win.InvalRect(self.iconrect) |
|
c2eb38b674f3
The Window Independent Tracer (which will probably move elsewhere once
Jack Jansen <jack.jansen@cwi.nl>
parents:
diff
changeset
|
196 |
|
4817
0f7515ebe3bf
Moved resources around to forestall conflicts with debuggee
Jack Jansen <jack.jansen@cwi.nl>
parents:
4387
diff
changeset
|
197 def setcurline(self, line, pic=PIC_CURRENT): |
|
4331
c2eb38b674f3
The Window Independent Tracer (which will probably move elsewhere once
Jack Jansen <jack.jansen@cwi.nl>
parents:
diff
changeset
|
198 self.curline = line |
| 4333 | 199 self.piccurrent = pic |
|
4331
c2eb38b674f3
The Window Independent Tracer (which will probably move elsewhere once
Jack Jansen <jack.jansen@cwi.nl>
parents:
diff
changeset
|
200 Qd.SetPort(self.wid) |
|
c2eb38b674f3
The Window Independent Tracer (which will probably move elsewhere once
Jack Jansen <jack.jansen@cwi.nl>
parents:
diff
changeset
|
201 self.showline(line) |
|
c2eb38b674f3
The Window Independent Tracer (which will probably move elsewhere once
Jack Jansen <jack.jansen@cwi.nl>
parents:
diff
changeset
|
202 |
|
c2eb38b674f3
The Window Independent Tracer (which will probably move elsewhere once
Jack Jansen <jack.jansen@cwi.nl>
parents:
diff
changeset
|
203 def showline(self, line): |
|
c2eb38b674f3
The Window Independent Tracer (which will probably move elsewhere once
Jack Jansen <jack.jansen@cwi.nl>
parents:
diff
changeset
|
204 if line <= 0: line = 1 |
|
c2eb38b674f3
The Window Independent Tracer (which will probably move elsewhere once
Jack Jansen <jack.jansen@cwi.nl>
parents:
diff
changeset
|
205 if line >= len(self.line_index): line = len(self.line_index)-1 |
|
c2eb38b674f3
The Window Independent Tracer (which will probably move elsewhere once
Jack Jansen <jack.jansen@cwi.nl>
parents:
diff
changeset
|
206 if line < 0: return |
|
c2eb38b674f3
The Window Independent Tracer (which will probably move elsewhere once
Jack Jansen <jack.jansen@cwi.nl>
parents:
diff
changeset
|
207 off = self.line_index[line] |
|
c2eb38b674f3
The Window Independent Tracer (which will probably move elsewhere once
Jack Jansen <jack.jansen@cwi.nl>
parents:
diff
changeset
|
208 x, y = self.ted.TEGetPoint(off) |
|
c2eb38b674f3
The Window Independent Tracer (which will probably move elsewhere once
Jack Jansen <jack.jansen@cwi.nl>
parents:
diff
changeset
|
209 if self.curlinerange[0] <= y <= self.curlinerange[1]: |
|
c2eb38b674f3
The Window Independent Tracer (which will probably move elsewhere once
Jack Jansen <jack.jansen@cwi.nl>
parents:
diff
changeset
|
210 return # It is in view |
|
c2eb38b674f3
The Window Independent Tracer (which will probably move elsewhere once
Jack Jansen <jack.jansen@cwi.nl>
parents:
diff
changeset
|
211 middle = (self.curlinerange[0]+self.curlinerange[1])/2 |
|
c2eb38b674f3
The Window Independent Tracer (which will probably move elsewhere once
Jack Jansen <jack.jansen@cwi.nl>
parents:
diff
changeset
|
212 self.ted.TEPinScroll(0, middle-y) # Of andersom? |
|
c2eb38b674f3
The Window Independent Tracer (which will probably move elsewhere once
Jack Jansen <jack.jansen@cwi.nl>
parents:
diff
changeset
|
213 self.setscrollbars() |
|
c2eb38b674f3
The Window Independent Tracer (which will probably move elsewhere once
Jack Jansen <jack.jansen@cwi.nl>
parents:
diff
changeset
|
214 |
|
c2eb38b674f3
The Window Independent Tracer (which will probably move elsewhere once
Jack Jansen <jack.jansen@cwi.nl>
parents:
diff
changeset
|
215 def setscrollbars(self): |
|
c2eb38b674f3
The Window Independent Tracer (which will probably move elsewhere once
Jack Jansen <jack.jansen@cwi.nl>
parents:
diff
changeset
|
216 MT_TextWidget.setscrollbars(self) |
|
c2eb38b674f3
The Window Independent Tracer (which will probably move elsewhere once
Jack Jansen <jack.jansen@cwi.nl>
parents:
diff
changeset
|
217 Win.InvalRect(self.iconrect) |
|
c2eb38b674f3
The Window Independent Tracer (which will probably move elsewhere once
Jack Jansen <jack.jansen@cwi.nl>
parents:
diff
changeset
|
218 |
|
c2eb38b674f3
The Window Independent Tracer (which will probably move elsewhere once
Jack Jansen <jack.jansen@cwi.nl>
parents:
diff
changeset
|
219 def update(self, rgn): |
|
c2eb38b674f3
The Window Independent Tracer (which will probably move elsewhere once
Jack Jansen <jack.jansen@cwi.nl>
parents:
diff
changeset
|
220 MT_TextWidget.update(self, rgn) |
|
c2eb38b674f3
The Window Independent Tracer (which will probably move elsewhere once
Jack Jansen <jack.jansen@cwi.nl>
parents:
diff
changeset
|
221 self.drawallicons() |
|
c2eb38b674f3
The Window Independent Tracer (which will probably move elsewhere once
Jack Jansen <jack.jansen@cwi.nl>
parents:
diff
changeset
|
222 |
|
c2eb38b674f3
The Window Independent Tracer (which will probably move elsewhere once
Jack Jansen <jack.jansen@cwi.nl>
parents:
diff
changeset
|
223 def drawallicons(self): |
|
c2eb38b674f3
The Window Independent Tracer (which will probably move elsewhere once
Jack Jansen <jack.jansen@cwi.nl>
parents:
diff
changeset
|
224 Qd.EraseRect(self.iconrect) |
|
c2eb38b674f3
The Window Independent Tracer (which will probably move elsewhere once
Jack Jansen <jack.jansen@cwi.nl>
parents:
diff
changeset
|
225 Qd.MoveTo(self.iconrect[2], self.iconrect[1]) |
|
c2eb38b674f3
The Window Independent Tracer (which will probably move elsewhere once
Jack Jansen <jack.jansen@cwi.nl>
parents:
diff
changeset
|
226 Qd.LineTo(self.iconrect[2], self.iconrect[3]) |
|
c2eb38b674f3
The Window Independent Tracer (which will probably move elsewhere once
Jack Jansen <jack.jansen@cwi.nl>
parents:
diff
changeset
|
227 topoffset = self.ted.TEGetOffset((self.terect[0], self.terect[1])) |
|
c2eb38b674f3
The Window Independent Tracer (which will probably move elsewhere once
Jack Jansen <jack.jansen@cwi.nl>
parents:
diff
changeset
|
228 botoffset = self.ted.TEGetOffset((self.terect[0], self.terect[3])) |
|
c2eb38b674f3
The Window Independent Tracer (which will probably move elsewhere once
Jack Jansen <jack.jansen@cwi.nl>
parents:
diff
changeset
|
229 topline = self.offsettoline(topoffset) |
|
c2eb38b674f3
The Window Independent Tracer (which will probably move elsewhere once
Jack Jansen <jack.jansen@cwi.nl>
parents:
diff
changeset
|
230 botline = self.offsettoline(botoffset) |
|
c2eb38b674f3
The Window Independent Tracer (which will probably move elsewhere once
Jack Jansen <jack.jansen@cwi.nl>
parents:
diff
changeset
|
231 if topline == None: topline = 1 # ??? |
|
c2eb38b674f3
The Window Independent Tracer (which will probably move elsewhere once
Jack Jansen <jack.jansen@cwi.nl>
parents:
diff
changeset
|
232 if botline == None: botline = len(self.line_index) |
|
c2eb38b674f3
The Window Independent Tracer (which will probably move elsewhere once
Jack Jansen <jack.jansen@cwi.nl>
parents:
diff
changeset
|
233 for i in self.breakpointlist: |
|
c2eb38b674f3
The Window Independent Tracer (which will probably move elsewhere once
Jack Jansen <jack.jansen@cwi.nl>
parents:
diff
changeset
|
234 if topline <= i <= botline: |
|
c2eb38b674f3
The Window Independent Tracer (which will probably move elsewhere once
Jack Jansen <jack.jansen@cwi.nl>
parents:
diff
changeset
|
235 self.draw1icon(i, PIC_BREAK) |
|
c2eb38b674f3
The Window Independent Tracer (which will probably move elsewhere once
Jack Jansen <jack.jansen@cwi.nl>
parents:
diff
changeset
|
236 if self.curline <> None and topline <= self.curline <= botline: |
| 4333 | 237 self.draw1icon(self.curline, self.piccurrent) |
|
4331
c2eb38b674f3
The Window Independent Tracer (which will probably move elsewhere once
Jack Jansen <jack.jansen@cwi.nl>
parents:
diff
changeset
|
238 |
|
c2eb38b674f3
The Window Independent Tracer (which will probably move elsewhere once
Jack Jansen <jack.jansen@cwi.nl>
parents:
diff
changeset
|
239 def draw1icon(self, line, which): |
|
c2eb38b674f3
The Window Independent Tracer (which will probably move elsewhere once
Jack Jansen <jack.jansen@cwi.nl>
parents:
diff
changeset
|
240 offset = self.line_index[line] |
|
c2eb38b674f3
The Window Independent Tracer (which will probably move elsewhere once
Jack Jansen <jack.jansen@cwi.nl>
parents:
diff
changeset
|
241 botx, boty = self.ted.TEGetPoint(offset) |
|
c2eb38b674f3
The Window Independent Tracer (which will probably move elsewhere once
Jack Jansen <jack.jansen@cwi.nl>
parents:
diff
changeset
|
242 rect = self.rect[0]+2, boty-self.ted.lineHeight, \ |
|
c2eb38b674f3
The Window Independent Tracer (which will probably move elsewhere once
Jack Jansen <jack.jansen@cwi.nl>
parents:
diff
changeset
|
243 self.rect[0]+ICONSIZE-2, boty |
|
c2eb38b674f3
The Window Independent Tracer (which will probably move elsewhere once
Jack Jansen <jack.jansen@cwi.nl>
parents:
diff
changeset
|
244 if not picture_cache.has_key(which): |
|
c2eb38b674f3
The Window Independent Tracer (which will probably move elsewhere once
Jack Jansen <jack.jansen@cwi.nl>
parents:
diff
changeset
|
245 picture_cache[which] = Qd.GetPicture(which) |
|
c2eb38b674f3
The Window Independent Tracer (which will probably move elsewhere once
Jack Jansen <jack.jansen@cwi.nl>
parents:
diff
changeset
|
246 self.drawicon(rect, picture_cache[which]) |
|
c2eb38b674f3
The Window Independent Tracer (which will probably move elsewhere once
Jack Jansen <jack.jansen@cwi.nl>
parents:
diff
changeset
|
247 |
|
c2eb38b674f3
The Window Independent Tracer (which will probably move elsewhere once
Jack Jansen <jack.jansen@cwi.nl>
parents:
diff
changeset
|
248 def drawicon(self, rect, which): |
|
c2eb38b674f3
The Window Independent Tracer (which will probably move elsewhere once
Jack Jansen <jack.jansen@cwi.nl>
parents:
diff
changeset
|
249 Qd.DrawPicture(which, rect) |
|
c2eb38b674f3
The Window Independent Tracer (which will probably move elsewhere once
Jack Jansen <jack.jansen@cwi.nl>
parents:
diff
changeset
|
250 |
|
c2eb38b674f3
The Window Independent Tracer (which will probably move elsewhere once
Jack Jansen <jack.jansen@cwi.nl>
parents:
diff
changeset
|
251 class MT_IndexList: |
|
c2eb38b674f3
The Window Independent Tracer (which will probably move elsewhere once
Jack Jansen <jack.jansen@cwi.nl>
parents:
diff
changeset
|
252 def __init__(self, wid, rect, width): |
|
c2eb38b674f3
The Window Independent Tracer (which will probably move elsewhere once
Jack Jansen <jack.jansen@cwi.nl>
parents:
diff
changeset
|
253 # wid is the window (dialog) where our list is going to be in |
|
c2eb38b674f3
The Window Independent Tracer (which will probably move elsewhere once
Jack Jansen <jack.jansen@cwi.nl>
parents:
diff
changeset
|
254 # rect is it's item rectangle (as in dialog item) |
|
c2eb38b674f3
The Window Independent Tracer (which will probably move elsewhere once
Jack Jansen <jack.jansen@cwi.nl>
parents:
diff
changeset
|
255 self.rect = rect |
|
c2eb38b674f3
The Window Independent Tracer (which will probably move elsewhere once
Jack Jansen <jack.jansen@cwi.nl>
parents:
diff
changeset
|
256 rect2 = rect[0]+1, rect[1]+1, rect[2]-16, rect[3]-1 |
|
c2eb38b674f3
The Window Independent Tracer (which will probably move elsewhere once
Jack Jansen <jack.jansen@cwi.nl>
parents:
diff
changeset
|
257 self.list = List.LNew(rect2, (0, 0, width, 0), (0,0), 0, wid, |
|
c2eb38b674f3
The Window Independent Tracer (which will probably move elsewhere once
Jack Jansen <jack.jansen@cwi.nl>
parents:
diff
changeset
|
258 0, 1, 0, 1) |
|
c2eb38b674f3
The Window Independent Tracer (which will probably move elsewhere once
Jack Jansen <jack.jansen@cwi.nl>
parents:
diff
changeset
|
259 self.wid = wid |
|
c2eb38b674f3
The Window Independent Tracer (which will probably move elsewhere once
Jack Jansen <jack.jansen@cwi.nl>
parents:
diff
changeset
|
260 self.width = width |
|
c2eb38b674f3
The Window Independent Tracer (which will probably move elsewhere once
Jack Jansen <jack.jansen@cwi.nl>
parents:
diff
changeset
|
261 |
|
c2eb38b674f3
The Window Independent Tracer (which will probably move elsewhere once
Jack Jansen <jack.jansen@cwi.nl>
parents:
diff
changeset
|
262 def setcontent(self, *content): |
|
c2eb38b674f3
The Window Independent Tracer (which will probably move elsewhere once
Jack Jansen <jack.jansen@cwi.nl>
parents:
diff
changeset
|
263 self.list.LDelRow(0, 1) |
|
c2eb38b674f3
The Window Independent Tracer (which will probably move elsewhere once
Jack Jansen <jack.jansen@cwi.nl>
parents:
diff
changeset
|
264 self.list.LSetDrawingMode(0) |
|
c2eb38b674f3
The Window Independent Tracer (which will probably move elsewhere once
Jack Jansen <jack.jansen@cwi.nl>
parents:
diff
changeset
|
265 self.list.LAddRow(len(content[0]), 0) |
|
c2eb38b674f3
The Window Independent Tracer (which will probably move elsewhere once
Jack Jansen <jack.jansen@cwi.nl>
parents:
diff
changeset
|
266 for x in range(len(content)): |
|
c2eb38b674f3
The Window Independent Tracer (which will probably move elsewhere once
Jack Jansen <jack.jansen@cwi.nl>
parents:
diff
changeset
|
267 column = content[x] |
|
c2eb38b674f3
The Window Independent Tracer (which will probably move elsewhere once
Jack Jansen <jack.jansen@cwi.nl>
parents:
diff
changeset
|
268 for y in range(len(column)): |
|
c2eb38b674f3
The Window Independent Tracer (which will probably move elsewhere once
Jack Jansen <jack.jansen@cwi.nl>
parents:
diff
changeset
|
269 self.list.LSetCell(column[y], (x, y)) |
|
c2eb38b674f3
The Window Independent Tracer (which will probably move elsewhere once
Jack Jansen <jack.jansen@cwi.nl>
parents:
diff
changeset
|
270 self.list.LSetDrawingMode(1) |
|
c2eb38b674f3
The Window Independent Tracer (which will probably move elsewhere once
Jack Jansen <jack.jansen@cwi.nl>
parents:
diff
changeset
|
271 Win.InvalRect(self.rect) |
|
c2eb38b674f3
The Window Independent Tracer (which will probably move elsewhere once
Jack Jansen <jack.jansen@cwi.nl>
parents:
diff
changeset
|
272 |
|
c2eb38b674f3
The Window Independent Tracer (which will probably move elsewhere once
Jack Jansen <jack.jansen@cwi.nl>
parents:
diff
changeset
|
273 def deselectall(self): |
|
c2eb38b674f3
The Window Independent Tracer (which will probably move elsewhere once
Jack Jansen <jack.jansen@cwi.nl>
parents:
diff
changeset
|
274 while 1: |
|
c2eb38b674f3
The Window Independent Tracer (which will probably move elsewhere once
Jack Jansen <jack.jansen@cwi.nl>
parents:
diff
changeset
|
275 ok, pt = self.list.LGetSelect(1, (0,0)) |
|
c2eb38b674f3
The Window Independent Tracer (which will probably move elsewhere once
Jack Jansen <jack.jansen@cwi.nl>
parents:
diff
changeset
|
276 if not ok: return |
|
c2eb38b674f3
The Window Independent Tracer (which will probably move elsewhere once
Jack Jansen <jack.jansen@cwi.nl>
parents:
diff
changeset
|
277 self.list.LSetSelect(0, pt) |
|
c2eb38b674f3
The Window Independent Tracer (which will probably move elsewhere once
Jack Jansen <jack.jansen@cwi.nl>
parents:
diff
changeset
|
278 |
|
c2eb38b674f3
The Window Independent Tracer (which will probably move elsewhere once
Jack Jansen <jack.jansen@cwi.nl>
parents:
diff
changeset
|
279 def select(self, num): |
|
c2eb38b674f3
The Window Independent Tracer (which will probably move elsewhere once
Jack Jansen <jack.jansen@cwi.nl>
parents:
diff
changeset
|
280 self.deselectall() |
|
c2eb38b674f3
The Window Independent Tracer (which will probably move elsewhere once
Jack Jansen <jack.jansen@cwi.nl>
parents:
diff
changeset
|
281 if num < 0: |
|
c2eb38b674f3
The Window Independent Tracer (which will probably move elsewhere once
Jack Jansen <jack.jansen@cwi.nl>
parents:
diff
changeset
|
282 return |
|
c2eb38b674f3
The Window Independent Tracer (which will probably move elsewhere once
Jack Jansen <jack.jansen@cwi.nl>
parents:
diff
changeset
|
283 for i in range(self.width): |
|
c2eb38b674f3
The Window Independent Tracer (which will probably move elsewhere once
Jack Jansen <jack.jansen@cwi.nl>
parents:
diff
changeset
|
284 self.list.LSetSelect(1, (i, num)) |
|
c2eb38b674f3
The Window Independent Tracer (which will probably move elsewhere once
Jack Jansen <jack.jansen@cwi.nl>
parents:
diff
changeset
|
285 |
|
c2eb38b674f3
The Window Independent Tracer (which will probably move elsewhere once
Jack Jansen <jack.jansen@cwi.nl>
parents:
diff
changeset
|
286 def click(self, where, modifiers): |
|
c2eb38b674f3
The Window Independent Tracer (which will probably move elsewhere once
Jack Jansen <jack.jansen@cwi.nl>
parents:
diff
changeset
|
287 is_double = self.list.LClick(where, modifiers) |
|
c2eb38b674f3
The Window Independent Tracer (which will probably move elsewhere once
Jack Jansen <jack.jansen@cwi.nl>
parents:
diff
changeset
|
288 ok, (x, y) = self.list.LGetSelect(1, (0, 0)) |
|
c2eb38b674f3
The Window Independent Tracer (which will probably move elsewhere once
Jack Jansen <jack.jansen@cwi.nl>
parents:
diff
changeset
|
289 if ok: |
|
c2eb38b674f3
The Window Independent Tracer (which will probably move elsewhere once
Jack Jansen <jack.jansen@cwi.nl>
parents:
diff
changeset
|
290 return y, is_double |
|
c2eb38b674f3
The Window Independent Tracer (which will probably move elsewhere once
Jack Jansen <jack.jansen@cwi.nl>
parents:
diff
changeset
|
291 else: |
|
c2eb38b674f3
The Window Independent Tracer (which will probably move elsewhere once
Jack Jansen <jack.jansen@cwi.nl>
parents:
diff
changeset
|
292 return None, is_double |
|
c2eb38b674f3
The Window Independent Tracer (which will probably move elsewhere once
Jack Jansen <jack.jansen@cwi.nl>
parents:
diff
changeset
|
293 |
|
c2eb38b674f3
The Window Independent Tracer (which will probably move elsewhere once
Jack Jansen <jack.jansen@cwi.nl>
parents:
diff
changeset
|
294 # draw a frame around the list, List Manager doesn't do that |
|
c2eb38b674f3
The Window Independent Tracer (which will probably move elsewhere once
Jack Jansen <jack.jansen@cwi.nl>
parents:
diff
changeset
|
295 def drawframe(self): |
|
c2eb38b674f3
The Window Independent Tracer (which will probably move elsewhere once
Jack Jansen <jack.jansen@cwi.nl>
parents:
diff
changeset
|
296 Qd.SetPort(self.wid) |
|
c2eb38b674f3
The Window Independent Tracer (which will probably move elsewhere once
Jack Jansen <jack.jansen@cwi.nl>
parents:
diff
changeset
|
297 Qd.FrameRect(self.rect) |
|
c2eb38b674f3
The Window Independent Tracer (which will probably move elsewhere once
Jack Jansen <jack.jansen@cwi.nl>
parents:
diff
changeset
|
298 |
|
c2eb38b674f3
The Window Independent Tracer (which will probably move elsewhere once
Jack Jansen <jack.jansen@cwi.nl>
parents:
diff
changeset
|
299 def update(self, rgn): |
|
c2eb38b674f3
The Window Independent Tracer (which will probably move elsewhere once
Jack Jansen <jack.jansen@cwi.nl>
parents:
diff
changeset
|
300 self.drawframe() |
|
c2eb38b674f3
The Window Independent Tracer (which will probably move elsewhere once
Jack Jansen <jack.jansen@cwi.nl>
parents:
diff
changeset
|
301 self.list.LUpdate(rgn) |
|
c2eb38b674f3
The Window Independent Tracer (which will probably move elsewhere once
Jack Jansen <jack.jansen@cwi.nl>
parents:
diff
changeset
|
302 |
|
c2eb38b674f3
The Window Independent Tracer (which will probably move elsewhere once
Jack Jansen <jack.jansen@cwi.nl>
parents:
diff
changeset
|
303 def activate(self, onoff): |
|
c2eb38b674f3
The Window Independent Tracer (which will probably move elsewhere once
Jack Jansen <jack.jansen@cwi.nl>
parents:
diff
changeset
|
304 self.list.LActivate(onoff) |
|
c2eb38b674f3
The Window Independent Tracer (which will probably move elsewhere once
Jack Jansen <jack.jansen@cwi.nl>
parents:
diff
changeset
|
305 |
|
c2eb38b674f3
The Window Independent Tracer (which will probably move elsewhere once
Jack Jansen <jack.jansen@cwi.nl>
parents:
diff
changeset
|
306 class MT_AnyList(MT_IndexList): |
|
c2eb38b674f3
The Window Independent Tracer (which will probably move elsewhere once
Jack Jansen <jack.jansen@cwi.nl>
parents:
diff
changeset
|
307 |
|
c2eb38b674f3
The Window Independent Tracer (which will probably move elsewhere once
Jack Jansen <jack.jansen@cwi.nl>
parents:
diff
changeset
|
308 def click(self, where, modifiers): |
|
c2eb38b674f3
The Window Independent Tracer (which will probably move elsewhere once
Jack Jansen <jack.jansen@cwi.nl>
parents:
diff
changeset
|
309 is_double = self.list.LClick(where, modifiers) |
|
c2eb38b674f3
The Window Independent Tracer (which will probably move elsewhere once
Jack Jansen <jack.jansen@cwi.nl>
parents:
diff
changeset
|
310 ok, (x, y) = self.list.LGetSelect(1, (0, 0)) |
|
c2eb38b674f3
The Window Independent Tracer (which will probably move elsewhere once
Jack Jansen <jack.jansen@cwi.nl>
parents:
diff
changeset
|
311 if ok: |
|
c2eb38b674f3
The Window Independent Tracer (which will probably move elsewhere once
Jack Jansen <jack.jansen@cwi.nl>
parents:
diff
changeset
|
312 self.select(y) |
|
c2eb38b674f3
The Window Independent Tracer (which will probably move elsewhere once
Jack Jansen <jack.jansen@cwi.nl>
parents:
diff
changeset
|
313 field0 = self.list.LGetCell(1000,(0,y)) |
|
c2eb38b674f3
The Window Independent Tracer (which will probably move elsewhere once
Jack Jansen <jack.jansen@cwi.nl>
parents:
diff
changeset
|
314 else: |
|
c2eb38b674f3
The Window Independent Tracer (which will probably move elsewhere once
Jack Jansen <jack.jansen@cwi.nl>
parents:
diff
changeset
|
315 field0 = None |
|
c2eb38b674f3
The Window Independent Tracer (which will probably move elsewhere once
Jack Jansen <jack.jansen@cwi.nl>
parents:
diff
changeset
|
316 return field0, is_double |
|
c2eb38b674f3
The Window Independent Tracer (which will probably move elsewhere once
Jack Jansen <jack.jansen@cwi.nl>
parents:
diff
changeset
|
317 |
