Go to the documentation of this file.00001 '''
00002 Anoria (c) Gsk 2010
00003 '''
00004
00005
00006 import BigWorld, GUI, Keys
00007 import Helpers.PyGUI as PyGUI
00008
00009
00010 """
00011 This class implements a text field with a prepended text label
00012 to be used for example in characters stats displays and similar
00013 """
00014 class LabeledTextField( PyGUI.PyGUIBase ):
00015
00016 factoryString = "AnGUI.LabeledTextField"
00017
00018 def __init__(self, component):
00019 PyGUI.PyGUIBase.__init__( self, component )
00020 component.script = self
00021
00022 def adjustFont( self, screenWidth ):
00023 if screenWidth < 700:
00024 self.component.font = self.smallFont
00025 else:
00026 self.component.font = self.bigFont
00027
00028
00029 def onLoad( self, section ):
00030 self.smallFont = section.readString( "smallFont", "default_small.font" )
00031 self.bigFont = section.readString( "bigFont", "default_medium.font" )
00032
00033
00034 @staticmethod
00035 def create(t_label="Foo:", t_text="bar"):
00036 ''' create a basic labeled text object (GUI.Simple)
00037 - label and text are left aligned to display as label:text
00038 - the LabeledTextField itself is anchored TOP/LEFT
00039 '''
00040
00041
00042 label = GUI.Text(t_label)
00043 label.horizontalAnchor = "LEFT"
00044 label.verticalAnchor = "TOP"
00045 label.horizontalPositionMode = "CLIP"
00046 label.verticalPositionMode = "CLIP"
00047 label.position = (-1.0, 1.0, 1.0)
00048
00049
00050 text = GUI.Text(t_text)
00051 text.horizontalAnchor = "LEFT"
00052 text.verticalAnchor = "TOP"
00053 text.horizontalPositionMode = "CLIP"
00054 text.verticalPositionMode = "CLIP"
00055 text.position = (-1.0+label.width, 1.0, 1.0)
00056
00057
00058 c = GUI.Simple("")
00059 c.horizontalAnchor = "LEFT"
00060 c.verticalAnchor = "TOP"
00061 c.horizontalPositionMode = "CLIP"
00062 c.verticalPositionMode = "CLIP"
00063 c.addChild(label, "label")
00064 c.addChild(text, "text")
00065
00066
00067 c.width = label.width + text.width
00068 c.height = label.height + text.height
00069
00070 return LabeledTextField(c).component