Mercurial > cpython-lru_cache-weakref
annotate Lib/lib-stdwin/TransParent.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 | f9bbb01388d5 |
| children |
| rev | line source |
|---|---|
| 64 | 1 # A class that sits transparently between a parent and one child. |
| 2 # First create the parent, then this thing, then the child. | |
| 3 # Use this as a base class for objects that are almost transparent. | |
| 4 # Don't use as a base class for parents with multiple children. | |
| 5 | |
| 6 Error = 'TransParent.Error' # Exception | |
| 7 | |
| 539 | 8 class ManageOneChild: |
| 64 | 9 # |
| 10 # Upcalls shared with other single-child parents | |
| 11 # | |
| 12 def addchild(self, child): | |
| 13 if self.child: | |
| 14 raise Error, 'addchild: one child only' | |
| 15 if not child: | |
| 16 raise Error, 'addchild: bad child' | |
| 17 self.child = child | |
| 18 # | |
| 19 def delchild(self, child): | |
| 20 if not self.child: | |
| 21 raise Error, 'delchild: no child' | |
| 22 if child <> self.child: | |
| 23 raise Error, 'delchild: not my child' | |
| 24 self.child = 0 | |
| 25 | |
| 539 | 26 class TransParent(ManageOneChild): |
| 64 | 27 # |
| 28 # Calls from creator | |
| 29 # NB derived classes may add parameters to create() | |
| 30 # | |
| 31 def create(self, parent): | |
| 32 parent.addchild(self) | |
| 33 self.parent = parent | |
| 353 | 34 self.child = None # No child yet |
|
191
5ffd371b7841
Added alternate drawing, realize and getwindow interfaces
Guido van Rossum <guido@python.org>
parents:
64
diff
changeset
|
35 return self |
| 64 | 36 # |
| 37 # Downcalls from parent to child | |
| 38 # | |
| 39 def destroy(self): | |
| 40 del self.parent | |
| 41 if self.child: self.child.destroy() | |
| 42 del self.child | |
| 43 # | |
| 353 | 44 def getminsize(self, args): |
| 64 | 45 if not self.child: |
| 353 | 46 m, size = args |
| 47 return size | |
| 64 | 48 else: |
| 353 | 49 return self.child.getminsize(args) |
| 64 | 50 def getbounds(self, bounds): |
| 51 if not self.child: | |
| 52 raise Error, 'getbounds w/o child' | |
| 53 else: | |
| 54 return self.child.getbounds() | |
| 55 def setbounds(self, bounds): | |
| 56 if not self.child: | |
| 57 raise Error, 'setbounds w/o child' | |
| 58 else: | |
| 59 self.child.setbounds(bounds) | |
|
191
5ffd371b7841
Added alternate drawing, realize and getwindow interfaces
Guido van Rossum <guido@python.org>
parents:
64
diff
changeset
|
60 def realize(self): |
|
5ffd371b7841
Added alternate drawing, realize and getwindow interfaces
Guido van Rossum <guido@python.org>
parents:
64
diff
changeset
|
61 if self.child: |
|
5ffd371b7841
Added alternate drawing, realize and getwindow interfaces
Guido van Rossum <guido@python.org>
parents:
64
diff
changeset
|
62 self.child.realize() |
|
1178
f9bbb01388d5
* More changes due to stricter argument passing rules
Guido van Rossum <guido@python.org>
parents:
539
diff
changeset
|
63 def draw(self, d, area): |
| 64 | 64 if self.child: |
|
1178
f9bbb01388d5
* More changes due to stricter argument passing rules
Guido van Rossum <guido@python.org>
parents:
539
diff
changeset
|
65 self.child.draw(d, area) |
|
f9bbb01388d5
* More changes due to stricter argument passing rules
Guido van Rossum <guido@python.org>
parents:
539
diff
changeset
|
66 def altdraw(self, area): |
|
191
5ffd371b7841
Added alternate drawing, realize and getwindow interfaces
Guido van Rossum <guido@python.org>
parents:
64
diff
changeset
|
67 if self.child: |
|
1178
f9bbb01388d5
* More changes due to stricter argument passing rules
Guido van Rossum <guido@python.org>
parents:
539
diff
changeset
|
68 self.child.altdraw(area) |
| 64 | 69 # |
| 70 # Downcalls only made after certain upcalls | |
| 71 # | |
| 72 def mouse_down(self, detail): | |
| 73 if self.child: self.child.mouse_down(detail) | |
| 74 def mouse_move(self, detail): | |
| 75 if self.child: self.child.mouse_move(detail) | |
| 76 def mouse_up(self, detail): | |
| 77 if self.child: self.child.mouse_up(detail) | |
| 78 # | |
| 353 | 79 def keybd(self, type_detail): |
| 80 self.child.keybd(type_detail) | |
| 81 def activate(self): | |
| 82 self.child.activate() | |
| 83 def deactivate(self): | |
| 84 self.child.deactivate() | |
| 85 # | |
| 64 | 86 def timer(self): |
| 87 if self.child: self.child.timer() | |
| 88 # | |
| 89 # Upcalls from child to parent | |
| 90 # | |
| 91 def need_mouse(self, child): | |
| 92 self.parent.need_mouse(self) | |
| 93 def no_mouse(self, child): | |
| 94 self.parent.no_mouse(self) | |
| 95 # | |
| 96 def need_timer(self, child): | |
| 97 self.parent.need_timer(self) | |
| 98 def no_timer(self, child): | |
| 99 self.parent.no_timer(self) | |
| 100 # | |
|
191
5ffd371b7841
Added alternate drawing, realize and getwindow interfaces
Guido van Rossum <guido@python.org>
parents:
64
diff
changeset
|
101 def need_altdraw(self, child): |
|
5ffd371b7841
Added alternate drawing, realize and getwindow interfaces
Guido van Rossum <guido@python.org>
parents:
64
diff
changeset
|
102 self.parent.need_altdraw(self) |
|
5ffd371b7841
Added alternate drawing, realize and getwindow interfaces
Guido van Rossum <guido@python.org>
parents:
64
diff
changeset
|
103 def no_altdraw(self, child): |
|
5ffd371b7841
Added alternate drawing, realize and getwindow interfaces
Guido van Rossum <guido@python.org>
parents:
64
diff
changeset
|
104 self.parent.no_altdraw(self) |
|
5ffd371b7841
Added alternate drawing, realize and getwindow interfaces
Guido van Rossum <guido@python.org>
parents:
64
diff
changeset
|
105 # |
| 353 | 106 def need_keybd(self, child): |
| 107 self.parent.need_keybd(self) | |
| 108 def no_keybd(self, child): | |
| 109 self.parent.no_keybd(self) | |
| 110 # | |
| 64 | 111 def begindrawing(self): |
| 112 return self.parent.begindrawing() | |
| 113 def beginmeasuring(self): | |
| 114 return self.parent.beginmeasuring() | |
|
191
5ffd371b7841
Added alternate drawing, realize and getwindow interfaces
Guido van Rossum <guido@python.org>
parents:
64
diff
changeset
|
115 def getwindow(self): |
|
5ffd371b7841
Added alternate drawing, realize and getwindow interfaces
Guido van Rossum <guido@python.org>
parents:
64
diff
changeset
|
116 return self.parent.getwindow() |
| 64 | 117 # |
| 118 def change(self, area): | |
| 119 self.parent.change(area) | |
|
1178
f9bbb01388d5
* More changes due to stricter argument passing rules
Guido van Rossum <guido@python.org>
parents:
539
diff
changeset
|
120 def scroll(self, area, vector): |
|
f9bbb01388d5
* More changes due to stricter argument passing rules
Guido van Rossum <guido@python.org>
parents:
539
diff
changeset
|
121 self.parent.scroll(area, vector) |
| 64 | 122 def settimer(self, itimer): |
| 123 self.parent.settimer(itimer) |
