Exemple #1
0
 def create(self, s, single=False):
     if single:
         return self.create_single(s)
     n = Sprite()
     xpos = 0
     ypos = 0
     xmax = 0
     nx = 0
     ny = 0
     height = self.linesize
     padleft, padright, padtop, padbottom = self.padding
     nx -= padleft
     ny += height - padtop
     n.letters = []
     n.font = self
     for c in s:
         if c == '\n':
             xmax = max(xpos, xmax)
             ypos += height + self.linespacing
             nx -= xpos
             ny += height + self.linespacing
             xpos = 0
         img = self.chardict.get(c, None)
         if img is None:
             continue
         s = Sprite(img)
         img = img._cObj
         s.attach_to(n)
         s.position = nx, ny
         n.letters.append(s)
         nx += img.w - padleft - padright + self.spacing
         xpos += img.w - padleft - padright + self.spacing
     #n.rect = (0, 0, xmax, ypos+height)
     return n
Exemple #2
0
 def create(self, s, single=False):
     if single:
         return self.create_single(s)
     n = Sprite()
     xpos = 0
     ypos = 0
     xmax = 0
     nx = 0
     ny = 0
     height = self.linesize
     padleft, padright, padtop, padbottom = self.padding
     nx -= padleft
     ny += height-padtop
     n.letters = []
     n.font = self
     for c in s:
         if c == '\n':
             xmax = max(xpos, xmax)
             ypos += height + self.linespacing
             nx -= xpos
             ny += height + self.linespacing
             xpos = 0
         img = self.chardict.get(c, None)
         if img is None:
             continue
         s = Sprite(img)
         img = img._cObj
         s.attach_to(n)
         s.position = nx, ny
         n.letters.append(s)
         nx += img.w - padleft - padright + self.spacing
         xpos += img.w - padleft - padright + self.spacing
     #n.rect = (0, 0, xmax, ypos+height)
     return n
Exemple #3
0
 def set_cursor(self, cursor):
     """cursor can be either None, image name, Image, Sprite or HWCursor)"""
     if cursor is None:
         mouse.set_visible(False)
         self._sprite = None
         self._cursor = None
     elif isinstance(cursor, HWCursor):
         self._cursor = cursor
         self._sprite = None
         mouse.set_cursor(*cursor._data)
         mouse.set_visible(True)
     elif isinstance(cursor, Sprite):
         mouse.set_visible(False)
         self._sprite = cursor
         self._cursor = self.sprite
     else:
         s = Sprite(cursor)
         mouse.set_visible(False)
         self._sprite = s
         self._cursor = s
Exemple #4
0
 def delete(self):
     self.unregister()
     Sprite.delete(self)
Exemple #5
0
 def delete(self):
     self.unregister()
     Sprite.delete(self)
Exemple #6
0
 def create_single(self, s):
     surf = self.create_surface(s)
     img = ResourceManager._create_image(Bitmap(surf))
     return Sprite(img)