Example #1
0
File: math.py Project: nragot/rox
 def __init__(self, parentTex, context):
     TexFile.__init__(self, parentTex, context)
     self.text = ""
     self.cursor = 0
     self.maxCharPerLine = 1
     self.name = "math"
     self.focus = 0
Example #2
0
 def resize(self, left, up, right, down):
     TexFile.resize(self, left, up, right, down)
     self.maxCharPerLine = (self.context.right -
                            self.context.left) // assets.charwidth
     self.line = self.context.down * 0.1
     self.titleFont = ImageFont.truetype('Pillow/Tests/fonts/FreeMono.ttf',
                                         int((self.line * 0.9)))
Example #3
0
File: init.py Project: nragot/rox
 def __init__(self, parentTex, context=None):
     TexFile.__init__(self, parentTex, context)
     self.name = "init"
     self.title = "title"
     self.author = "author"
     self.alone = True
     self.state = None
Example #4
0
 def __init__(self, parentTex, context):
     TexFile.__init__(self, parentTex, context)
     self.text = ""
     self.cursor = 0
     self.maxCharPerLine = 1
     self.name = "text"
     self.titleFont = ImageFont.truetype('Pillow/Tests/fonts/FreeMono.ttf',
                                         assets.fontsize)
     self.focus = 0
     #break "\\" ; nothing "" ; new "\n\n"
     self.breakType = "break"
Example #5
0
    def draw(self, draw):
        TexFile.draw(self, draw)

        draw.line((self.context.left + 20, self.line, self.context.right - 20,
                   self.line),
                  fill=(0, 0, 0))
        draw.text((self.context.left + 10, 0),
                  self.name,
                  fill=(0, 0, 0),
                  font=self.titleFont)
        w, temp = draw.textsize(str(self.nbr), font=self.titleFont)
        draw.text((self.context.right - w, 10),
                  str(self.nbr),
                  fill=(255, 0, 150),
                  font=self.titleFont)

        i = 0
        lastBreaks = 0
        line = 1
        boxColor = None
        textColor = None
        left = 0
        up = 0

        for char in self.text:
            if i - lastBreaks == self.maxCharPerLine:
                lastBreaks = i
                line += 1
            if i == self.cursor:
                boxColor = assets.cursor
                textColor = assets.background
            else:
                boxColor = assets.background
                textColor = assets.text
            left = self.context.left + (i - lastBreaks) * assets.charwidth
            up = assets.fontsize * 1.5 * line + self.line

            draw.rectangle ((left, up, left + assets.charwidth, up + assets.fontsize + 5),\
                            fill = boxColor)
            draw.text((left, up), char, fill=textColor, font=assets.font)
            i += 1
        if self.cursor == len(self.text):
            left = self.context.left + (i - lastBreaks) * assets.charwidth
            up = assets.fontsize * 1.5 * line + self.line
            draw.rectangle( (left, up - 5, left + assets.charwidth, up + assets.fontsize + 5),\
                           fill = assets.cursor)
Example #6
0
 def __init__(self, parentTex, context):
     TexFile.__init__ (self, parentTex, context)
     self.texFiles = []
     self.focus = 0
     self.name = "hey"
Example #7
0
File: end.py Project: nragot/rox
 def __init__(self, parentTex, context):
     TexFile.__init__(self, parentTex, context)
     self.name = "end"
Example #8
0
File: math.py Project: nragot/rox
 def resize(self, left, up, right, down):
     TexFile.resize(self, left, up, right, down)
     self.maxCharPerLine = (self.context.right -
                            self.context.left) // assets.charwidth