#Arat;
elif Type == "bar":
parent.Children[Index] = Bar()
parent.Children[Index].SetParent(parent)
self.LoadElementBar(parent.Children[Index], ElementValue, parent)
#Üstüne ekle;
elif Type == "checkbox":
parent.Children[Index] = CheckBox()
parent.Children[Index].SetParent(parent)
self.LoadElementCheckBox(parent.Children[Index], ElementValue, parent)
#Arat;
def LoadDefaultData(self, window, value, parentWindow):
#Üstüne ekle;
def LoadElementCheckBox(self, window, value, parentWindow):
if True == value.has_key("text"):
window.SetTextInfo(value["text"])
self.LoadDefaultData(window, value, parentWindow)
return True
#En sona ekle;
class CheckBox(Window):
def __init__(self):
Window.__init__(self)
self.backgroundImage = None
self.checkImage = None
self.eventFunc = { "ON_CHECK" : None, "ON_UNCKECK" : None, }
self.eventArgs = { "ON_CHECK" : None, "ON_UNCKECK" : None, }
self.CreateElements()
def __del__(self):
Window.__del__(self)
self.backgroundImage = None
self.checkImage = None
self.eventFunc = { "ON_CHECK" : None, "ON_UNCKECK" : None, }
self.eventArgs = { "ON_CHECK" : None, "ON_UNCKECK" : None, }
def CreateElements(self):
self.backgroundImage = ExpandedImageBox()
self.backgroundImage.SetParent(self)
self.backgroundImage.AddFlag("not_pick")
self.backgroundImage.LoadImage("d:/ymir work/ui/game/refine/checkbox.tga")
self.backgroundImage.Show()
self.checkImage = ExpandedImageBox()
self.checkImage.SetParent(self)
self.checkImage.AddFlag("not_pick")
self.checkImage.SetPosition(0, 0)
self.checkImage.LoadImage("d:/ymir work/ui/game/refine/checked.tga")
self.checkImage.Hide()
self.textInfo = TextLine()
self.textInfo.SetParent(self)
self.textInfo.SetPosition(20, -2)
self.textInfo.Show()
self.SetSize(self.backgroundImage.GetWidth() + self.textInfo.GetTextSize()[0], self.backgroundImage.GetHeight() + self.textInfo.GetTextSize()[1])
def SetTextInfo(self, info):
if self.textInfo:
self.textInfo.SetText(info)
self.SetSize(self.backgroundImage.GetWidth() + self.textInfo.GetTextSize()[0], self.backgroundImage.GetHeight() + self.textInfo.GetTextSize()[1])
def SetCheckStatus(self, flag):
if flag:
self.checkImage.Show()
else:
self.checkImage.Hide()
def GetCheckStatus(self):
if self.checkImage:
return self.checkImage.IsShow()
return False
def SetEvent(self, func, *args) :
result = self.eventFunc.has_key(args[0])
if result :
self.eventFunc[args[0]] = func
self.eventArgs[args[0]] = args
else :
print "[ERROR] ui.py SetEvent, Can`t Find has_key : %s" % args[0]
def SetToggleUpEvent(self, event, *args):
self.eventFunc["ON_UNCKECK"] = event
self.eventArgs["ON_UNCKECK"] = args
def SetToggleDownEvent(self, event, *args):
self.eventFunc["ON_CHECK"] = event
self.eventArgs["ON_CHECK"] = args
def OnMouseLeftButtonUp(self):
if self.checkImage:
if self.checkImage.IsShow():
self.checkImage.Hide()
if self.eventFunc["ON_UNCKECK"]:
apply(self.eventFunc["ON_UNCKECK"], self.eventArgs["ON_UNCKECK"])
else:
self.checkImage.Show()
if self.eventFunc["ON_CHECK"]:
apply(self.eventFunc["ON_CHECK"], self.eventArgs["ON_CHECK"])