Guido van Rossum | e6afe6a | 1991-08-16 13:02:04 +0000 | [diff] [blame] | 1 | from TransParent import TransParent |
| 2 | |
Guido van Rossum | ce08448 | 1991-12-26 13:06:29 +0000 | [diff] [blame] | 3 | class BoxParent(TransParent): |
Guido van Rossum | e6afe6a | 1991-08-16 13:02:04 +0000 | [diff] [blame] | 4 | # |
Guido van Rossum | 89a7869 | 1992-12-14 12:57:56 +0000 | [diff] [blame] | 5 | def create(self, parent, (dh, dv)): |
Guido van Rossum | e6afe6a | 1991-08-16 13:02:04 +0000 | [diff] [blame] | 6 | self = TransParent.create(self, parent) |
| 7 | self.dh = dh |
| 8 | self.dv = dv |
| 9 | return self |
| 10 | # |
Guido van Rossum | 89a7869 | 1992-12-14 12:57:56 +0000 | [diff] [blame] | 11 | def getminsize(self, m, (width, height)): |
Guido van Rossum | e6afe6a | 1991-08-16 13:02:04 +0000 | [diff] [blame] | 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 |
| 16 | # |
| 17 | def setbounds(self, bounds): |
| 18 | (left, top), (right, bottom) = bounds |
| 19 | self.bounds = 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) |
| 26 | # |
| 27 | def getbounds(self): |
| 28 | return self.bounds |
| 29 | # |
Guido van Rossum | fea2af1 | 1993-01-04 09:16:51 +0000 | [diff] [blame^] | 30 | def draw(self, d, area): |
Guido van Rossum | e6afe6a | 1991-08-16 13:02:04 +0000 | [diff] [blame] | 31 | (left, top), (right, bottom) = self.bounds |
| 32 | left = left + 1 |
| 33 | top = top + 1 |
| 34 | right = right - 1 |
| 35 | bottom = bottom - 1 |
| 36 | d.box((left, top), (right, bottom)) |
Guido van Rossum | fea2af1 | 1993-01-04 09:16:51 +0000 | [diff] [blame^] | 37 | TransParent.draw(self, d, area) # XXX clip to innerbounds? |
Guido van Rossum | e6afe6a | 1991-08-16 13:02:04 +0000 | [diff] [blame] | 38 | # |
| 39 | # XXX should scroll clip to innerbounds??? |
| 40 | # XXX currently the only user restricts itself to child's bounds |