text_item.py 897 B

1234567891011121314151617181920212223242526272829
  1. # -*- coding: utf-8 -*-
  2. #local import
  3. from UI.constants import Width,Height,ICON_TYPES
  4. from UI.icon_item import IconItem
  5. from UI.util_funcs import midRect
  6. from UI.skin_manager import MySkinManager
  7. class TextItem(IconItem):
  8. _PosX = 0
  9. _PosY = 0
  10. _Width = 0
  11. _Height = 0
  12. _Str = ""
  13. _Color = MySkinManager.GiveColor('Text')
  14. _FontObj = None
  15. _Bold = False
  16. _MyType = ICON_TYPES["LETTER"]
  17. _Parent = None
  18. def Draw(self):
  19. self._FontObj.set_bold(self._Bold)
  20. my_text = self._FontObj.render(self._Str,True,self._Color)
  21. if my_text.get_width() != self._Width:
  22. self._Width = my_text.get_width()
  23. if my_text.get_height() != self._Height:
  24. self._Height = my_text.get_height()
  25. self._Parent._CanvasHWND.blit(my_text, \
  26. midRect(self._PosX,self._PosY,self._Width,self._Height,Width,Height))