Example #1
0
 def pre_update(self, context):
     cr = context.cairo
     text = self.subject.name
     if text:
         width, height = text_extents(cr, text)
         self.min_width, self.min_height = width + 10, height + 20
     super(UseCaseItem, self).pre_update(context)
Example #2
0
    def pre_update(self, context):
        """
        Pre update, determine width and height of the compartment.
        """
        self.width = self.height = 0
        cr = context.cairo
        for item in self:
            item.pre_update(context)
        
        if self:
            # self (=list) contains items
            sizes = [ (0, 0) ] # to not throw exceptions by max and sum
            if self.title:
                w, h = text_extents(cr, self.title)
                self.title_height = h
                sizes.append((w, h))
            sizes.extend(f.get_size(True) for f in self)
            self.width = max(size[0] for size in sizes)
            self.height = sum(size[1] for size in sizes)
            vspacing = self.owner.style.compartment_vspacing
            self.height += vspacing * (len(sizes) - 1)

        padding = self.owner.style.compartment_padding
        self.width += padding[1] + padding[3]
        self.height += padding[0] + padding[2]
Example #3
0
    def pre_update(self, context):
        """
        Pre update, determine width and height of the compartment.
        """
        self.width = self.height = 0
        cr = context.cairo
        for item in self:
            item.pre_update(context)

        if self:
            # self (=list) contains items
            sizes = [(0, 0)]  # to not throw exceptions by max and sum
            if self.title:
                w, h = text_extents(cr, self.title)
                self.title_height = h
                sizes.append((w, h))
            sizes.extend(f.get_size(True) for f in self)
            self.width = max(size[0] for size in sizes)
            self.height = sum(size[1] for size in sizes)
            vspacing = self.owner.style.compartment_vspacing
            self.height += vspacing * (len(sizes) - 1)

        padding = self.owner.style.compartment_padding
        self.width += padding[1] + padding[3]
        self.height += padding[0] + padding[2]
Example #4
0
 def pre_update(self, context):
     cr = context.cairo
     text = self.subject.name
     if text:
         width, height = text_extents(cr, text)
         self.min_width, self.min_height = width + 10, height + 20
     super(UseCaseItem, self).pre_update(context)
Example #5
0
 def pre_update(self, context):
     if not self.subject:
         return
     cr = context.cairo
     e = self.EAR
     o = self.OFFSET
     w, h = text_extents(cr, self.subject.body, self.style.font, width=self.width - e)
     self.min_width = w + e + o * 2
     self.min_height = h + o * 2
     ElementItem.pre_update(self, context)
Example #6
0
 def update_size(self, text, context):
     if text:
         cr = context.cairo
         self.width, self.height = text_extents(cr, text)
     else:
         self.width, self.height = 0, 0
Example #7
0
 def update_size(self, text, context):
     if text:
         cr = context.cairo
         self.width, self.height = text_extents(cr, text)
     else:
         self.width, self.height = 0, 0