From 8b39e26dc795f383e621853ad23bbedf208218ed Mon Sep 17 00:00:00 2001 From: Kelvin Sherlock Date: Thu, 4 Jan 2024 13:37:46 -0500 Subject: [PATCH] bug fixes --- prez/control.py | 14 +++++++------- prez/rect.py | 39 +++++++++++++++++++++++++++++++++++++-- 2 files changed, 44 insertions(+), 9 deletions(-) diff --git a/prez/control.py b/prez/control.py index 8ecc35d..0edf4f7 100644 --- a/prez/control.py +++ b/prez/control.py @@ -617,12 +617,12 @@ class rRectangleControl(rControlTemplate): return rv -fSquishText = 0x0010 # 6.0.1 -fTextCanDim = 0x0008 -fBlastText = 0x0004 -fSubstituteText = 0x0002 -fSubTextIsPascal = 0x0001 -fSubTextIsC = 0x0000 +# fSquishText = 0x0010 # 6.0.1 +# fTextCanDim = 0x0008 +# fBlastText = 0x0004 +# fSubstituteText = 0x0002 +# fSubTextIsPascal = 0x0001 +# fSubTextIsC = 0x0000 # leftJustify = 0 # centerJustify = 1 @@ -665,7 +665,7 @@ class rStatTextControl(rControlTemplate): if fBlastText: flags |= 0x0004 if fSubstituteText: flags |= 0x0002 if fSubTextIsPascal: flags |= 0x0001| 0x0002 - if fSubTextIsC != None: flags |= 0x0002 + if fSubTextIsC: flags |= 0x0002 if leftJust: just = 0 elif centerJust: just = 1 diff --git a/prez/rect.py b/prez/rect.py index f59b0be..e360d2e 100644 --- a/prez/rect.py +++ b/prez/rect.py @@ -280,8 +280,8 @@ class rect_class: return rect_class( x = self.x + horizontal, y = self.y + vertical, - width = self.width - horizontal, - height = self.height - vertical + width = self.width - horizontal * 2, + height = self.height - vertical * 2 ) def offset_to(self, x, y): @@ -313,6 +313,27 @@ class rect_class: def bottom_right(self): return point_class(x = self.x + self.width, y = self.y + self.height) + def split_horizontal(self, where): + + if where < 0: where = self.width + where + where = max(0, min(self.width, where)) + + l = rect_class(x = self.x, y = self.y, height = self.height, width = where) + r = rect_class(x = where, y = self.y, height = self.height, width = self.width - where) + + return l, r + + def split_vertical(self, where): + + if where < 0: where = self.height + where + where = max(0, min(self.height, where)) + + l = rect_class(x = self.x, y = self.y, height = where, width = self.width) + r = rect_class(x = self.x, y = where, height = self.height - where, width = self.width) + + return l, r + + def __str__(self): return "{{ {:d}, {:d}, {:d}, {:d} }}".format(self.y, self.x, self.y + self.height, self.x + self.width) @@ -354,6 +375,20 @@ class rect_class: return rect_class(v1 = y1, h1 = x1, v2 = y2, h2 = x2) + def __add__(self, other): + if type(other) == size_class: + return rect_class(x = self.x, y = self.y, height = self.height + other.height, width = self.width + other.width) + + raise ValueError("bad parameter") + + def __sub__(self, other): + if type(other) == size_class: + return rect_class(x = self.x, y = self.y, height = self.height - other.height, width = self.width - other.width) + + raise ValueError("bad parameter") + + + point = point_class rect = rect_class size = size_class