zero_based_constants

This commit is contained in:
Jean-Marie Place 2023-05-18 08:05:16 +02:00
parent a37ce1d3b8
commit 7427db0ba6

View File

@ -159,6 +159,7 @@ class Composante_boolean(Composante):
class Composante_number_format(Composante):
WIDTH: int = 2
def __init__(self):
assert (1 << self.WIDTH) > SCO_NUMBER_FORMAT.__len__()
super().__init__(width=self.WIDTH)
@ -174,9 +175,11 @@ class Composante_number_format(Composante):
class Composante_Colors(Composante):
WIDTH: int = 5
def __init__(self):
def __init__(self, default: SCO_COLORS = SCO_COLORS.BLACK):
assert (1 << self.WIDTH) > SCO_COLORS.__len__()
super().__init__(width=self.WIDTH)
self.default: SCO_COLORS = default
def set(self, data: SCO_COLORS, signature=0) -> int:
return self.write(data.value, signature)
@ -194,6 +197,7 @@ class Composante_Colors(Composante):
class Composante_borderThickness(Composante):
WIDTH: int = 3
def __init__(self):
assert (1 << self.WIDTH) > SCO_BORDERTHICKNESS.__len__()
super().__init__(width=self.WIDTH)
@ -212,6 +216,7 @@ class Composante_borderThickness(Composante):
class Composante_fontname(Composante):
WIDTH: int = 3
def __init__(self):
assert (1 << self.WIDTH) > SCO_FONTNAME.__len__()
super().__init__(width=self.WIDTH)
@ -230,6 +235,7 @@ class Composante_fontname(Composante):
class Composante_fontsize(Composante):
WIDTH: int = 3
def __init__(self):
assert (1 << self.WIDTH) > SCO_FONTSIZE.__len__()
super().__init__(width=self.WIDTH)
@ -244,9 +250,11 @@ class Composante_fontsize(Composante):
class Composante_halign(Composante):
WIDTH: int = 3
WIDTH: int = 2
def __init__(self):
assert (1 << self.WIDTH) > SCO_HALIGN.__len__()
super().__init__(width=self.WIDTH)
def set(self, data: SCO_HALIGN, signature=0) -> int:
return self.write(data.value, signature)
@ -261,7 +269,8 @@ class Composante_halign(Composante):
class Composante_valign(Composante):
WIDTH: int = 3
WIDTH: int = 2
def __init__(self):
assert (1 << self.WIDTH) > SCO_VALIGN.__len__()
super().__init__(width=self.WIDTH)
@ -531,6 +540,7 @@ class Composante_all(Composante_group):
number_format: Composante_number_format,
):
super().__init__([font, fill, borders, alignment, number_format])
assert self.width < 64
self.font = font
self.fill = fill
self.borders = borders
@ -607,16 +617,15 @@ class FMT(Enum):
ALL = Composante_all(FONT, FILL, BORDERS, ALIGNMENT, NUMBER_FORMAT)
HAIR_BLACK: int = FMT.BORDER_LEFT.composante.make_zero_based_constant(
HAIR_BLACK: int = FMT.BORDER_LEFT.make_zero_based_constant(
enums=[SCO_BORDERTHICKNESS.BORDER_HAIR, SCO_COLORS.BLACK]
)
THIN_BLACK: int = FMT.BORDER_LEFT.composante.make_zero_based_constant(
THIN_BLACK: int = FMT.BORDER_LEFT.make_zero_based_constant(
enums=[SCO_BORDERTHICKNESS.BORDER_THIN, SCO_COLORS.BLACK]
)
MEDIUM_BLACK: int = FMT.BORDER_LEFT.composante.make_zero_based_constant(
MEDIUM_BLACK: int = FMT.BORDER_LEFT.make_zero_based_constant(
enums=[SCO_BORDERTHICKNESS.BORDER_MEDIUM, SCO_COLORS.BLACK]
)
THICK_BLACK: int = FMT.BORDER_LEFT.composante.make_zero_based_constant(
THICK_BLACK: int = FMT.BORDER_LEFT.make_zero_based_constant(
enums=[SCO_BORDERTHICKNESS.BORDER_THICK, SCO_COLORS.BLACK]
)
breakpoint()