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.
6 Error
= 'TransParent.Error' # Exception
10 # Upcalls shared with other single-child parents
12 def addchild(self
, child
):
14 raise Error
, 'addchild: one child only'
16 raise Error
, 'addchild: bad child'
19 def delchild(self
, child
):
21 raise Error
, 'delchild: no child'
22 if child
<> self
.child
:
23 raise Error
, 'delchild: not my child'
26 class TransParent(ManageOneChild
):
29 # NB derived classes may add parameters to create()
31 def create(self
, parent
):
34 self
.child
= None # No child yet
37 # Downcalls from parent to child
41 if self
.child
: self
.child
.destroy()
44 def getminsize(self
, args
):
49 return self
.child
.getminsize(args
)
50 def getbounds(self
, bounds
):
52 raise Error
, 'getbounds w/o child'
54 return self
.child
.getbounds()
55 def setbounds(self
, bounds
):
57 raise Error
, 'setbounds w/o child'
59 self
.child
.setbounds(bounds
)
63 def draw(self
, d
, area
):
65 self
.child
.draw(d
, area
)
66 def altdraw(self
, area
):
68 self
.child
.altdraw(area
)
70 # Downcalls only made after certain upcalls
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
)
79 def keybd(self
, type_detail
):
80 self
.child
.keybd(type_detail
)
84 self
.child
.deactivate()
87 if self
.child
: self
.child
.timer()
89 # Upcalls from child to parent
91 def need_mouse(self
, child
):
92 self
.parent
.need_mouse(self
)
93 def no_mouse(self
, child
):
94 self
.parent
.no_mouse(self
)
96 def need_timer(self
, child
):
97 self
.parent
.need_timer(self
)
98 def no_timer(self
, child
):
99 self
.parent
.no_timer(self
)
101 def need_altdraw(self
, child
):
102 self
.parent
.need_altdraw(self
)
103 def no_altdraw(self
, child
):
104 self
.parent
.no_altdraw(self
)
106 def need_keybd(self
, child
):
107 self
.parent
.need_keybd(self
)
108 def no_keybd(self
, child
):
109 self
.parent
.no_keybd(self
)
111 def begindrawing(self
):
112 return self
.parent
.begindrawing()
113 def beginmeasuring(self
):
114 return self
.parent
.beginmeasuring()
116 return self
.parent
.getwindow()
118 def change(self
, area
):
119 self
.parent
.change(area
)
120 def scroll(self
, area
, vector
):
121 self
.parent
.scroll(area
, vector
)
122 def settimer(self
, itimer
):
123 self
.parent
.settimer(itimer
)