<s> from . gl_utils import * <EOL> from . widget import Widget , BGUI_DEFAULT , BGUI_NO_NORMALIZE <EOL> class Label ( Widget ) : <EOL> """<STR_LIT>""" <EOL> theme_section = '<STR_LIT>' <EOL> theme_options = { <EOL> '<STR_LIT>' : '<STR_LIT>' , <EOL> '<STR_LIT>' : ( <NUM_LIT:1> , <NUM_LIT:1> , <NUM_LIT:1> , <NUM_LIT:1> ) , <EOL> '<STR_LIT>' : ( <NUM_LIT:0> , <NUM_LIT:0> , <NUM_LIT:0> , <NUM_LIT:1> ) , <EOL> '<STR_LIT>' : <NUM_LIT:0> , <EOL> '<STR_LIT>' : False , <EOL> '<STR_LIT>' : <NUM_LIT:30> , <EOL> } <EOL> def __init__ ( self , parent , name = None , text = "<STR_LIT>" , font = None , pt_size = None , color = None , <EOL> outline_color = None , outline_size = None , outline_smoothing = None , pos = [ <NUM_LIT:0> , <NUM_LIT:0> ] , sub_theme = '<STR_LIT>' , options = BGUI_DEFAULT ) : <EOL> """<STR_LIT>""" <EOL> Widget . __init__ ( self , parent , name , None , [ <NUM_LIT:0> , <NUM_LIT:0> ] , pos , sub_theme , options ) <EOL> if font : <EOL> self . fontid = self . system . textlib . load ( font ) <EOL> else : <EOL> font = self . theme [ '<STR_LIT>' ] <EOL> self . fontid = self . system . textlib . load ( font ) if font else <NUM_LIT:0> <EOL> if pt_size : <EOL> self . pt_size = pt_size <EOL> else : <EOL> self . pt_size = self . theme [ '<STR_LIT>' ] <EOL> if color : <EOL> self . color = color <EOL> else : <EOL> self . color = self . theme [ '<STR_LIT>' ] <EOL> if outline_color : <EOL> self . outline_color = outline_color <EOL> else : <EOL> self . outline_color = self . theme [ '<STR_LIT>' ] <EOL> if outline_size is not None : <EOL> self . outline_size = outline_size <EOL> else : <EOL> self . outline_size = self . theme [ '<STR_LIT>' ] <EOL> self . outline_size = int ( self . outline_size ) <EOL> if outline_smoothing is not None : <EOL> self . outline_smoothing = outline_smoothing <EOL> else : <EOL> self . outline_smoothing = self . theme [ '<STR_LIT>' ] <EOL> self . text = text <EOL> @ property <EOL> def text ( self ) : <EOL> """<STR_LIT>""" <EOL> return self . _text <EOL> @ text . setter <EOL> def text ( self , value ) : <EOL> self . system . textlib . size ( self . fontid , self . pt_size , <NUM_LIT> ) <EOL> size = [ self . system . textlib . dimensions ( self . fontid , value ) [ <NUM_LIT:0> ] , self . system . textlib . dimensions ( self . fontid , '<STR_LIT>' ) [ <NUM_LIT:0> ] ] <EOL> if not ( self . options & BGUI_NO_NORMALIZE ) : <EOL> size [ <NUM_LIT:0> ] /= self . parent . size [ <NUM_LIT:0> ] <EOL> size [ <NUM_LIT:1> ] /= self . parent . size [ <NUM_LIT:1> ] <EOL> self . _update_position ( size , self . _base_pos ) <EOL> self . _text = value <EOL> @ property <EOL> def pt_size ( self ) : <EOL> """<STR_LIT>""" <EOL> return self . _pt_size <EOL> @ pt_size . setter <EOL> def pt_size ( self , value ) : <EOL> if self . system . normalize_text : <EOL> self . _pt_size = int ( value * ( self . system . size [ <NUM_LIT:1> ] / <NUM_LIT:1000> ) ) <EOL> else : <EOL> self . _pt_size = value <EOL> def _draw_text ( self , x , y ) : <EOL> for i , txt in enumerate ( [ i for i in self . _text . split ( '<STR_LIT:\n>' ) ] ) : <EOL> self . system . textlib . position ( self . fontid , x , y - ( self . size [ <NUM_LIT:1> ] * i ) , <NUM_LIT:0> ) <EOL> self . system . textlib . draw ( self . fontid , txt . replace ( '<STR_LIT:\t>' , '<STR_LIT:U+0020>' ) ) <EOL> def _draw ( self ) : <EOL> """<STR_LIT>""" <EOL> self . system . textlib . size ( self . fontid , self . pt_size , <NUM_LIT> ) <EOL> if self . outline_size : <EOL> glColor4f ( * self . outline_color ) <EOL> if self . outline_smoothing : <EOL> steps = range ( - self . outline_size , self . outline_size + <NUM_LIT:1> ) <EOL> else : <EOL> steps = ( - self . outline_size , <NUM_LIT:0> , self . outline_size ) <EOL> for x in steps : <EOL> for y in steps : <EOL> self . _draw_text ( self . position [ <NUM_LIT:0> ] + x , self . position [ <NUM_LIT:1> ] + y ) <EOL> glColor4f ( * self . color ) <EOL> self . _draw_text ( * self . position ) <EOL> Widget . _draw ( self ) </s>
