]> git.ipfire.org Git - thirdparty/Python/cpython.git/commitdiff
Initial revision
authorGuido van Rossum <guido@python.org>
Fri, 16 Aug 1991 13:02:04 +0000 (13:02 +0000)
committerGuido van Rossum <guido@python.org>
Fri, 16 Aug 1991 13:02:04 +0000 (13:02 +0000)
Lib/lib-stdwin/BoxParent.py [new file with mode: 0644]
Lib/stdwin/BoxParent.py [new file with mode: 0755]

diff --git a/Lib/lib-stdwin/BoxParent.py b/Lib/lib-stdwin/BoxParent.py
new file mode 100644 (file)
index 0000000..7a0723a
--- /dev/null
@@ -0,0 +1,41 @@
+from TransParent import TransParent
+
+class BoxParent() = TransParent():
+       #
+       def create(self, (parent, (dh, dv))):
+               self = TransParent.create(self, parent)
+               self.dh = dh
+               self.dv = dv
+               return self
+       #
+       def getminsize(self, (m, (width, height))):
+               width = max(0, width - 2*self.dh)
+               height = max(0, height - 2*self.dv)
+               width, height = self.child.getminsize(m, (width, height))
+               return width + 2*self.dh, height + 2*self.dv
+       #
+       def setbounds(self, bounds):
+               (left, top), (right, bottom) = bounds
+               self.bounds = bounds
+               left = min(right, left + self.dh)
+               top = min(bottom, top + self.dv)
+               right = max(left, right - self.dh)
+               bottom = max(top, bottom - self.dv)
+               self.innerbounds = (left, top), (right, bottom)
+               self.child.setbounds(self.innerbounds)
+       #
+       def getbounds(self):
+               return self.bounds
+       #
+       def draw(self, args):
+               d, area = args
+               (left, top), (right, bottom) = self.bounds
+               left = left + 1
+               top = top + 1
+               right = right - 1
+               bottom = bottom - 1
+               d.box((left, top), (right, bottom))
+               TransParent.draw(self, args) # XXX clip to innerbounds?
+       #
+       # XXX should scroll clip to innerbounds???
+       # XXX currently the only user restricts itself to child's bounds
diff --git a/Lib/stdwin/BoxParent.py b/Lib/stdwin/BoxParent.py
new file mode 100755 (executable)
index 0000000..7a0723a
--- /dev/null
@@ -0,0 +1,41 @@
+from TransParent import TransParent
+
+class BoxParent() = TransParent():
+       #
+       def create(self, (parent, (dh, dv))):
+               self = TransParent.create(self, parent)
+               self.dh = dh
+               self.dv = dv
+               return self
+       #
+       def getminsize(self, (m, (width, height))):
+               width = max(0, width - 2*self.dh)
+               height = max(0, height - 2*self.dv)
+               width, height = self.child.getminsize(m, (width, height))
+               return width + 2*self.dh, height + 2*self.dv
+       #
+       def setbounds(self, bounds):
+               (left, top), (right, bottom) = bounds
+               self.bounds = bounds
+               left = min(right, left + self.dh)
+               top = min(bottom, top + self.dv)
+               right = max(left, right - self.dh)
+               bottom = max(top, bottom - self.dv)
+               self.innerbounds = (left, top), (right, bottom)
+               self.child.setbounds(self.innerbounds)
+       #
+       def getbounds(self):
+               return self.bounds
+       #
+       def draw(self, args):
+               d, area = args
+               (left, top), (right, bottom) = self.bounds
+               left = left + 1
+               top = top + 1
+               right = right - 1
+               bottom = bottom - 1
+               d.box((left, top), (right, bottom))
+               TransParent.draw(self, args) # XXX clip to innerbounds?
+       #
+       # XXX should scroll clip to innerbounds???
+       # XXX currently the only user restricts itself to child's bounds