1 from TransParent
import TransParent
3 class BoxParent(TransParent
):
5 def create(self
, parent
, (dh
, dv
)):
6 self
= TransParent
.create(self
, parent
)
11 def getminsize(self
, m
, (width
, height
)):
12 width
= max(0, width
- 2*self
.dh
)
13 height
= max(0, height
- 2*self
.dv
)
14 width
, height
= self
.child
.getminsize(m
, (width
, height
))
15 return width
+ 2*self
.dh
, height
+ 2*self
.dv
17 def setbounds(self
, bounds
):
18 (left
, top
), (right
, bottom
) = bounds
20 left
= min(right
, left
+ self
.dh
)
21 top
= min(bottom
, top
+ self
.dv
)
22 right
= max(left
, right
- self
.dh
)
23 bottom
= max(top
, bottom
- self
.dv
)
24 self
.innerbounds
= (left
, top
), (right
, bottom
)
25 self
.child
.setbounds(self
.innerbounds
)
30 def draw(self
, d
, area
):
31 (left
, top
), (right
, bottom
) = self
.bounds
36 d
.box((left
, top
), (right
, bottom
))
37 TransParent
.draw(self
, d
, area
) # XXX clip to innerbounds?
39 # XXX should scroll clip to innerbounds???
40 # XXX currently the only user restricts itself to child's bounds