Facebook
From Amsterdam, 2 Months ago, written in Plain Text.
Embed
Download Paste or View Raw
Hits: 220
  1. import app
  2. import ime
  3. import grp
  4. import snd
  5. import wndMgr
  6. import item
  7. import skill
  8. import localeInfo
  9. import dbg
  10. # MARK_BUG_FIX
  11. import guild
  12. # END_OF_MARK_BUG_FIX
  13. import constInfo
  14. import sys
  15. from constInfo import ENABLE_RECURSIVE_UI_DESTROY
  16. from _weakref import proxy
  17.  
  18. if ENABLE_RECURSIVE_UI_DESTROY:
  19.  WOC_WHITELIST = {'hWnd', 'parentWindow', 'Children', 'ElementDictionary', 'windowName', 'WocIsDestroyed', 'WocIsCleaned'}
  20.  WOC_ENABLE_RECURSIVE_CLEANER = False #unnecessary
  21.  WOC_ENABLE_PRINT_DEBUG = False
  22.  WOC_ENABLE_PRINT_DEL_DEBUG = False
  23.  WOC_ENABLE_FORCE_HIDE = True
  24.  WOC_ENABLE_PRINT_REGISTERS = False
  25.  WOC_ENABLE_PRINT_STACK = False
  26.  
  27.  def IsIterable(obj):
  28.   return isinstance(obj, (list,tuple,set,dict))
  29.  
  30.  def WindowDestroy(func):
  31.   def _decorator(self, *args, **kwargs):
  32.    if WOC_ENABLE_PRINT_DEL_DEBUG: dbg.TraceError("WindowDestroy decorator called for {}".format(self.__class__.__name__))
  33.    if WOC_ENABLE_FORCE_HIDE: self.Hide()
  34.    WindowObjectCleaner(self)
  35.    func(self, *args, **kwargs)
  36.   return _decorator
  37.  
  38.  def WindowObjectCleaner(obj):
  39.   ######################################
  40.   def WindowDestroyer(obj):
  41.    if WOC_ENABLE_RECURSIVE_CLEANER:
  42.     WindowObjectCleaner(obj)
  43.  
  44.    fDestroy = getattr(obj, 'Destroy', None)
  45.    if fDestroy and not getattr(obj, "WocIsDestroyed", False):
  46.     setattr(obj, "WocIsDestroyed", True)
  47.     if WOC_ENABLE_FORCE_HIDE: obj.Hide()
  48.     fDestroy()
  49.   ######################################
  50.   def ObjectItering(obj):
  51.    if isinstance(obj, (list,tuple,set)):
  52.     for elem in obj:
  53.      ObjectItering(elem)
  54.  
  55.    elif isinstance(obj, dict):
  56.     for k in obj:
  57.      ObjectItering(obj[k])
  58.  
  59.    elif isinstance(obj, (Window,NoWindow)):
  60.     WindowDestroyer(obj)
  61.   ######################################
  62.   if WOC_ENABLE_RECURSIVE_CLEANER:
  63.    if getattr(obj, "WocIsCleaned", False):
  64.     if WOC_ENABLE_PRINT_DEBUG: dbg.TraceError("WocIsCleaned already True")
  65.     return
  66.    setattr(obj, "WocIsCleaned", True)
  67.  
  68.   if WOC_ENABLE_PRINT_DEBUG: dbg.TraceError("WindowObjectCleaner vars: {}".format(repr(vars(obj).keys())))
  69.   for elemName in vars(obj).keys():
  70.    elemObj = getattr(obj, elemName)
  71.    elemType = type(elemObj)
  72.  
  73.    if elemName in WOC_WHITELIST:
  74.     continue
  75.  
  76.    if WOC_ENABLE_PRINT_DEBUG: dbg.TraceError("WindowObjectCleaner elemName {}".format(elemName))
  77.    if isinstance(elemObj, (Window,NoWindow)):
  78.     if WOC_ENABLE_PRINT_DEBUG: dbg.TraceError("WindowDestroyer elemName {}".format(elemName))
  79.     WindowDestroyer(elemObj)
  80.  
  81.    elif IsIterable(elemObj):
  82.     if WOC_ENABLE_PRINT_DEBUG: dbg.TraceError("{} is iterable: {}".format(elemName, repr(elemObj)))
  83.     ObjectItering(elemObj)
  84.     elemObj = elemType()
  85.     continue
  86.  
  87.    setattr(obj, elemName, None)
  88.  
  89. else:
  90.  WOC_ENABLE_PRINT_DEL_DEBUG = False
  91.  WOC_ENABLE_PRINT_REGISTERS = False
  92.  def WindowDestroy(func):
  93.   def _decorator(self, *args, **kwargs):
  94.    func(self, *args, **kwargs)
  95.   return _decorator
  96.  
  97.  
  98. BACKGROUND_COLOR = grp.GenerateColor(0.0, 0.0, 0.0, 1.0)
  99. DARK_COLOR = grp.GenerateColor(0.2, 0.2, 0.2, 1.0)
  100. BRIGHT_COLOR = grp.GenerateColor(0.7, 0.7, 0.7, 1.0)
  101.  
  102. SELECT_COLOR = grp.GenerateColor(0.0, 0.0, 0.5, 0.3)
  103.  
  104. WHITE_COLOR = grp.GenerateColor(1.0, 1.0, 1.0, 0.5)
  105. HALF_WHITE_COLOR = grp.GenerateColor(1.0, 1.0, 1.0, 0.2)
  106.  
  107. if app.ENABLE_KEYCHANGE_SYSTEM:
  108.  RED_COLOR = grp.GenerateColor(1.0, 0.0, 0.0, 0.5)
  109.  HALF_HALF_RED_COLOR = grp.GenerateColor(1.0, 0.0, 0.0, 0.4)
  110.  HALF_RED_COLOR = grp.GenerateColor(1.0, 0.0, 0.0, 0.3)
  111.  
  112. createToolTipWindowDict = {}
  113. def RegisterCandidateWindowClass(codePage, candidateWindowClass):
  114.  EditLine.candidateWindowClassDict[codePage]=candidateWindowClass
  115. def RegisterToolTipWindow(type, createToolTipWindow):
  116.  createToolTipWindowDict[type]=createToolTipWindow
  117.  
  118. app.SetDefaultFontName(localeInfo.UI_DEF_FONT)
  119.  
  120. ## Window Manager Event List##
  121. ##############################
  122. ## "OnMouseLeftButtonDown"
  123. ## "OnMouseLeftButtonUp"
  124. ## "OnMouseLeftButtonDoubleClick"
  125. ## "OnMouseRightButtonDown"
  126. ## "OnMouseRightButtonUp"
  127. ## "OnMouseRightButtonDoubleClick"
  128. ## "OnMouseDrag"
  129. ## "OnSetFocus"
  130. ## "OnKillFocus"
  131. ## "OnMouseOverIn"
  132. ## "OnMouseOverOut"
  133. ## "OnRender"
  134. ## "OnUpdate"
  135. ## "OnKeyDown"
  136. ## "OnKeyUp"
  137. ## "OnTop"
  138. ## "OnIMEUpdate" ## IME Only
  139. ## "OnIMETab" ## IME Only
  140. ## "OnIMEReturn" ## IME Only
  141. ##############################
  142. ## Window Manager Event List##
  143.  
  144.  
  145. class __mem_func__:
  146.  class __noarg_call__:
  147.   def __init__(self, cls, obj, func):
  148.    self.cls=cls
  149.    self.obj=proxy(obj)
  150.    self.func=proxy(func)
  151.  
  152.   def __call__(self, *arg):
  153.    return self.func(self.obj)
  154.  
  155.  class __arg_call__:
  156.   def __init__(self, cls, obj, func):
  157.    self.cls=cls
  158.    self.obj=proxy(obj)
  159.    self.func=proxy(func)
  160.  
  161.   def __call__(self, *arg):
  162.    return self.func(self.obj, *arg)
  163.  
  164.  def __init__(self, mfunc):
  165.   if mfunc.im_func.func_code.co_argcount>1:
  166.    self.call=__mem_func__.__arg_call__(mfunc.im_class, mfunc.im_self, mfunc.im_func)
  167.   else:
  168.    self.call=__mem_func__.__noarg_call__(mfunc.im_class, mfunc.im_self, mfunc.im_func)
  169.  
  170.  def __call__(self, *arg):
  171.   return self.call(*arg)
  172.  
  173. if WOC_ENABLE_PRINT_REGISTERS:
  174.  WocWindowRegister = {}
  175.  WocWindowNames = {}
  176.  if WOC_ENABLE_PRINT_STACK:
  177.   WocWindowStack = {}
  178.  
  179.  def WocGetStackList():
  180.   stacks = []
  181.   try:
  182.    for i in range(10):
  183.     stack = sys._getframe(i)
  184.     trace = stack.f_code.co_filename
  185.     line = stack.f_lineno
  186.     module = stack.f_code.co_name
  187.     stacks.append((trace, line, module))
  188.   except ValueError:
  189.    pass
  190.  
  191.   return stacks
  192.  
  193.  def WocDumpRegisters():
  194.   # if called at the end of prototype.py RunApp, you'll get no leaks, but you'll miss all the ingame-leaks
  195.   # if called inside networkmodule.py MainStream.Destroy, mouseModule.mouseController is still allocating NumberLine 1x
  196.   with old_open("windowRegisters.txt", "w") as f1:
  197.    for k,v in WocWindowRegister.items():
  198.     f1.write("window {} count {} name {}\n".format(k,v,WocWindowNames.get(k, "NONAME")))
  199.     if WOC_ENABLE_PRINT_STACK:
  200.      if v > 0:
  201.       for stack in WocWindowStack[k]:
  202.        f1.write("\tfile {} line {} name {}\n".format(*stack))
  203.  
  204. class NoWindow:
  205.  @WindowDestroy
  206.  def Destroy(self):
  207.   pass
  208.  def Hide(self):
  209.   pass
  210.  
  211. class Window(object):
  212.  def NoneMethod(cls):
  213.   pass
  214.  
  215.  NoneMethod = classmethod(NoneMethod)
  216.  
  217.  def __init__(self, layer = "UI"):
  218.   self.hWnd = None
  219.   self.parentWindow = 0
  220.   self.onMouseLeftButtonUpEvent = None
  221.   if app.ENABLE_MOUSEWHEEL_EVENT:
  222.    self.onMouseWheelEvent=None
  223.   self.RegisterWindow(layer)
  224.   self.Hide()
  225.  
  226.   if app.BL_MAILBOX:
  227.    self.onMouseLeftButtonUpEventArgs = None
  228.    self.overFunc = None
  229.    self.overArgs = None
  230.    self.overOutFunc = None
  231.    self.overOutArgs = None
  232.  
  233.   if WOC_ENABLE_PRINT_REGISTERS:
  234.    global WocWindowRegister
  235.    WocKey = "{}[{}]".format(self.__class__.__name__, id(self))
  236.    try:
  237.     WocWindowRegister[WocKey] += 1
  238.    except:
  239.     WocWindowRegister[WocKey] = 1
  240.     if WOC_ENABLE_PRINT_STACK:
  241.      global WocWindowStack
  242.      WocWindowStack[WocKey] = WocGetStackList()
  243.  
  244.  def __del__(self):
  245.   wndMgr.Destroy(self.hWnd)
  246.  
  247.   if app.BL_MAILBOX:
  248.    self.onMouseLeftButtonUpEventArgs = None
  249.    self.overFunc = None
  250.    self.overArgs = None
  251.    self.overOutFunc = None
  252.    self.overOutArgs = None
  253.  
  254.   if WOC_ENABLE_PRINT_DEL_DEBUG: import dbg; dbg.TraceError("{} __del__ called".format(self.__class__.__name__))
  255.   if WOC_ENABLE_PRINT_REGISTERS:
  256.    global WocWindowRegister,WocWindowStack
  257.    WocKey = "{}[{}]".format(self.__class__.__name__, id(self))
  258.    try:
  259.     WocWindowRegister[WocKey] -= 1
  260.    except:
  261.     WocWindowRegister[WocKey] = -1
  262.  
  263.  def RegisterWindow(self, layer):
  264.   self.hWnd = wndMgr.Register(self, layer)
  265.  
  266.  @WindowDestroy
  267.  def Destroy(self):
  268.   pass
  269.  
  270.  def GetWindowHandle(self):
  271.   return self.hWnd
  272.  
  273.  def AddFlag(self, style):
  274.   wndMgr.AddFlag(self.hWnd, style)
  275.  
  276.  def IsRTL(self):
  277.   return wndMgr.IsRTL(self.hWnd)
  278.  
  279.  def SetWindowName(self, Name):
  280.   wndMgr.SetName(self.hWnd, Name)
  281.   if WOC_ENABLE_PRINT_REGISTERS:
  282.    global WocWindowNames
  283.    WocKey = "{}[{}]".format(self.__class__.__name__, id(self))
  284.    WocWindowNames[WocKey] = self.GetWindowName()
  285.  
  286.  def GetWindowName(self):
  287.   return wndMgr.GetName(self.hWnd)
  288.  
  289.  def SetParent(self, parent):
  290.   wndMgr.SetParent(self.hWnd, parent.hWnd)
  291.  
  292.  def SetParentProxy(self, parent):
  293.   self.parentWindow=proxy(parent)
  294.   wndMgr.SetParent(self.hWnd, parent.hWnd)
  295.  
  296.  def GetParentProxy(self):
  297.   return self.parentWindow
  298.  
  299.  def SetPickAlways(self):
  300.   wndMgr.SetPickAlways(self.hWnd)
  301.  
  302.  def SetWindowHorizontalAlignLeft(self):
  303.   wndMgr.SetWindowHorizontalAlign(self.hWnd, wndMgr.HORIZONTAL_ALIGN_LEFT)
  304.  
  305.  def SetWindowHorizontalAlignCenter(self):
  306.   wndMgr.SetWindowHorizontalAlign(self.hWnd, wndMgr.HORIZONTAL_ALIGN_CENTER)
  307.  
  308.  def SetWindowHorizontalAlignRight(self):
  309.   wndMgr.SetWindowHorizontalAlign(self.hWnd, wndMgr.HORIZONTAL_ALIGN_RIGHT)
  310.  
  311.  def SetWindowVerticalAlignTop(self):
  312.   wndMgr.SetWindowVerticalAlign(self.hWnd, wndMgr.VERTICAL_ALIGN_TOP)
  313.  
  314.  def SetWindowVerticalAlignCenter(self):
  315.   wndMgr.SetWindowVerticalAlign(self.hWnd, wndMgr.VERTICAL_ALIGN_CENTER)
  316.  
  317.  def SetWindowVerticalAlignBottom(self):
  318.   wndMgr.SetWindowVerticalAlign(self.hWnd, wndMgr.VERTICAL_ALIGN_BOTTOM)
  319.  
  320.  def SetTop(self):
  321.   wndMgr.SetTop(self.hWnd)
  322.  
  323.  def Show(self):
  324.   wndMgr.Show(self.hWnd)
  325.  
  326.  def Hide(self):
  327.   wndMgr.Hide(self.hWnd)
  328.  
  329.  if app.__BL_CLIP_MASK__:
  330.   def SetClippingMaskRect(self, left, top, right, bottom):
  331.    wndMgr.SetClippingMaskRect(self.hWnd, left, top, right, bottom)
  332.    
  333.   def SetClippingMaskWindow(self, clipping_mask_window):
  334.    wndMgr.SetClippingMaskWindow(self.hWnd, clipping_mask_window.hWnd)
  335.  
  336.  def Lock(self):
  337.   wndMgr.Lock(self.hWnd)
  338.  
  339.  def Unlock(self):
  340.   wndMgr.Unlock(self.hWnd)
  341.  
  342.  def IsShow(self):
  343.   return wndMgr.IsShow(self.hWnd)
  344.  
  345.  def UpdateRect(self):
  346.   wndMgr.UpdateRect(self.hWnd)
  347.  
  348.  def SetSize(self, width, height):
  349.   wndMgr.SetWindowSize(self.hWnd, width, height)
  350.  
  351.  def GetWidth(self):
  352.   return wndMgr.GetWindowWidth(self.hWnd)
  353.  
  354.  def GetHeight(self):
  355.   return wndMgr.GetWindowHeight(self.hWnd)
  356.  
  357.  def GetLocalPosition(self):
  358.   return wndMgr.GetWindowLocalPosition(self.hWnd)
  359.  
  360.  def GetGlobalPosition(self):
  361.   return wndMgr.GetWindowGlobalPosition(self.hWnd)
  362.  
  363.  def GetMouseLocalPosition(self):
  364.   return wndMgr.GetMouseLocalPosition(self.hWnd)
  365.  
  366.  def GetRect(self):
  367.   return wndMgr.GetWindowRect(self.hWnd)
  368.  
  369.  def SetPosition(self, x, y):
  370.   wndMgr.SetWindowPosition(self.hWnd, x, y)
  371.  
  372.  def SetCenterPosition(self, x = 0, y = 0):
  373.   self.SetPosition((wndMgr.GetScreenWidth() - self.GetWidth()) / 2 + x, (wndMgr.GetScreenHeight() - self.GetHeight()) / 2 + y)
  374.  
  375.  def IsFocus(self):
  376.   return wndMgr.IsFocus(self.hWnd)
  377.  
  378.  def SetFocus(self):
  379.   wndMgr.SetFocus(self.hWnd)
  380.  
  381.  def KillFocus(self):
  382.   wndMgr.KillFocus(self.hWnd)
  383.  
  384.  def GetChildCount(self):
  385.   return wndMgr.GetChildCount(self.hWnd)
  386.  
  387.  def IsIn(self):
  388.   return wndMgr.IsIn(self.hWnd)
  389.  
  390.  if app.BL_MAILBOX:
  391.   def OnMouseOverIn(self):
  392.    if self.overFunc:
  393.     apply(self.overFunc, self.overArgs )
  394.   def OnMouseOverOut(self):
  395.    if self.overOutFunc:
  396.     apply(self.overOutFunc, self.overOutArgs )
  397.   def SetOverEvent(self, func, *args):
  398.    self.overFunc = func
  399.    self.overArgs = args
  400.   def SetOverOutEvent(self, func, *args):
  401.    self.overOutFunc = func
  402.    self.overOutArgs = args
  403.  
  404.   def SetOnMouseLeftButtonUpEvent(self, event, *args):
  405.    self.onMouseLeftButtonUpEvent  = event
  406.    self.onMouseLeftButtonUpEventArgs = args
  407.    
  408.   def OnMouseLeftButtonUp(self):
  409.    if self.onMouseLeftButtonUpEvent:
  410.     apply( self.onMouseLeftButtonUpEvent, self.onMouseLeftButtonUpEventArgs )
  411.  else:
  412.   def SetOnMouseLeftButtonUpEvent(self, event):
  413.    self.onMouseLeftButtonUpEvent = event
  414.    
  415.   def OnMouseLeftButtonUp(self):
  416.    if self.onMouseLeftButtonUpEvent:
  417.     self.onMouseLeftButtonUpEvent()
  418.  
  419.  if app.ENABLE_MOUSEWHEEL_EVENT:
  420.   def SetMouseWheelEvent(self, event):
  421.    self.onMouseWheelEvent = event
  422.  
  423.   def OnMouseWheel(self, delta):
  424.    # print("OnMouseWheel delta %d" % delta)
  425.    if self.onMouseWheelEvent:
  426.     return self.onMouseWheelEvent(delta)
  427.    return False
  428.  
  429. class ListBoxEx(Window):
  430.  
  431.  class Item(Window):
  432.   def __init__(self):
  433.    Window.__init__(self)
  434.  
  435.   def __del__(self):
  436.    Window.__del__(self)
  437.  
  438.   def SetParent(self, parent):
  439.    Window.SetParent(self, parent)
  440.    self.parent=proxy(parent)
  441.  
  442.   def OnMouseLeftButtonDown(self):
  443.    self.parent.SelectItem(self)
  444.  
  445.   def OnRender(self):
  446.    if self.parent.GetSelectedItem()==self:
  447.     self.OnSelectedRender()
  448.  
  449.   def OnSelectedRender(self):
  450.    x, y = self.GetGlobalPosition()
  451.    grp.SetColor(grp.GenerateColor(0.0, 0.0, 0.7, 0.7))
  452.    grp.RenderBar(x, y, self.GetWidth(), self.GetHeight())
  453.  
  454.  def __init__(self):
  455.   Window.__init__(self)
  456.  
  457.   self.viewItemCount=10
  458.   self.basePos=0
  459.   self.itemHeight=16
  460.   self.itemStep=20
  461.   self.selItem=0
  462.   self.itemList=[]
  463.   self.onSelectItemEvent = lambda *arg: None
  464.  
  465.   if localeInfo.IsARABIC():
  466.    self.itemWidth=130
  467.   else:
  468.    self.itemWidth=100
  469.  
  470.   self.scrollBar=None
  471.   self.__UpdateSize()
  472.  
  473.  def __del__(self):
  474.   Window.__del__(self)
  475.  
  476.  def __UpdateSize(self):
  477.   height=self.itemStep*self.__GetViewItemCount()
  478.  
  479.   self.SetSize(self.itemWidth, height)
  480.  
  481.  def IsEmpty(self):
  482.   if len(self.itemList)==0:
  483.    return 1
  484.   return 0
  485.  
  486.  def SetItemStep(self, itemStep):
  487.   self.itemStep=itemStep
  488.   self.__UpdateSize()
  489.  
  490.  def SetItemSize(self, itemWidth, itemHeight):
  491.   self.itemWidth=itemWidth
  492.   self.itemHeight=itemHeight
  493.   self.__UpdateSize()
  494.  
  495.  def SetViewItemCount(self, viewItemCount):
  496.   self.viewItemCount=viewItemCount
  497.  
  498.  def SetSelectEvent(self, event):
  499.   self.onSelectItemEvent = event
  500.  
  501.  def SetBasePos(self, basePos):
  502.   for oldItem in self.itemList[self.basePos:self.basePos+self.viewItemCount]:
  503.    oldItem.Hide()
  504.  
  505.   self.basePos=basePos
  506.  
  507.   pos=basePos
  508.   for newItem in self.itemList[self.basePos:self.basePos+self.viewItemCount]:
  509.    (x, y)=self.GetItemViewCoord(pos, newItem.GetWidth())
  510.    newItem.SetPosition(x, y)
  511.    newItem.Show()
  512.    pos+=1
  513.  
  514.  def GetItemIndex(self, argItem):
  515.   return self.itemList.index(argItem)
  516.  
  517.  def GetSelectedItem(self):
  518.   return self.selItem
  519.  
  520.  def SelectIndex(self, index):
  521.  
  522.   if index >= len(self.itemList) or index < 0:
  523.    self.selItem = None
  524.    return
  525.  
  526.   try:
  527.    self.selItem=self.itemList[index]
  528.   except:
  529.    pass
  530.  
  531.  def SelectItem(self, selItem):
  532.   self.selItem=selItem
  533.   self.onSelectItemEvent(selItem)
  534.  
  535.  def RemoveAllItems(self):
  536.   self.selItem=None
  537.   self.itemList=[]
  538.  
  539.   if self.scrollBar:
  540.    self.scrollBar.SetPos(0)
  541.  
  542.  def RemoveItem(self, delItem):
  543.   if delItem==self.selItem:
  544.    self.selItem=None
  545.  
  546.   self.itemList.remove(delItem)
  547.  
  548.  def AppendItem(self, newItem):
  549.   newItem.SetParent(self)
  550.   newItem.SetSize(self.itemWidth, self.itemHeight)
  551.  
  552.   pos=len(self.itemList)
  553.   if self.__IsInViewRange(pos):
  554.    (x, y)=self.GetItemViewCoord(pos, newItem.GetWidth())
  555.    newItem.SetPosition(x, y)
  556.    newItem.Show()
  557.   else:
  558.    newItem.Hide()
  559.  
  560.   self.itemList.append(newItem)
  561.  
  562.  def SetScrollBar(self, scrollBar):
  563.   scrollBar.SetScrollEvent(__mem_func__(self.__OnScroll))
  564.   self.scrollBar=scrollBar
  565.  
  566.  def __OnScroll(self):
  567.   self.SetBasePos(int(self.scrollBar.GetPos()*self.__GetScrollLen()))
  568.  
  569.  def __GetScrollLen(self):
  570.   scrollLen=self.__GetItemCount()-self.__GetViewItemCount()
  571.   if scrollLen<0:
  572.    return 0
  573.  
  574.   return scrollLen
  575.  
  576.  def __GetViewItemCount(self):
  577.   return self.viewItemCount
  578.  
  579.  def __GetItemCount(self):
  580.   return len(self.itemList)
  581.  
  582.  def GetItemViewCoord(self, pos, itemWidth):
  583.   if localeInfo.IsARABIC():
  584.    return (self.GetWidth()-itemWidth-10, (pos-self.basePos)*self.itemStep)
  585.   else:
  586.    return (0, (pos-self.basePos)*self.itemStep)
  587.  
  588.  def __IsInViewRange(self, pos):
  589.   if pos<self.basePos:
  590.    return 0
  591.   if pos>=self.basePos+self.viewItemCount:
  592.    return 0
  593.   return 1
  594.  
  595. class CandidateListBox(ListBoxEx):
  596.  
  597.  HORIZONTAL_MODE = 0
  598.  VERTICAL_MODE = 1
  599.  
  600.  class Item(ListBoxEx.Item):
  601.   def __init__(self, text):
  602.    ListBoxEx.Item.__init__(self)
  603.  
  604.    self.textBox=TextLine()
  605.    self.textBox.SetParent(self)
  606.    self.textBox.SetText(text)
  607.    self.textBox.Show()
  608.  
  609.   def __del__(self):
  610.    ListBoxEx.Item.__del__(self)
  611.  
  612.  def __init__(self, mode = HORIZONTAL_MODE):
  613.   ListBoxEx.__init__(self)
  614.   self.itemWidth=32
  615.   self.itemHeight=32
  616.   self.mode = mode
  617.  
  618.  def __del__(self):
  619.   ListBoxEx.__del__(self)
  620.  
  621.  def SetMode(self, mode):
  622.   self.mode = mode
  623.  
  624.  def AppendItem(self, newItem):
  625.   ListBoxEx.AppendItem(self, newItem)
  626.  
  627.  def GetItemViewCoord(self, pos):
  628.   if self.mode == self.HORIZONTAL_MODE:
  629.    return ((pos-self.basePos)*self.itemStep, 0)
  630.   elif self.mode == self.VERTICAL_MODE:
  631.    return (0, (pos-self.basePos)*self.itemStep)
  632.  
  633.  
  634. class TextLine(Window):
  635.  def __init__(self):
  636.   Window.__init__(self)
  637.   self.max = 0
  638.   self.SetFontName(localeInfo.UI_DEF_FONT)
  639.  
  640.  def __del__(self):
  641.   Window.__del__(self)
  642.  
  643.  def RegisterWindow(self, layer):
  644.   self.hWnd = wndMgr.RegisterTextLine(self, layer)
  645.  
  646.  def SetMax(self, max):
  647.   wndMgr.SetMax(self.hWnd, max)
  648.  
  649.  def SetLimitWidth(self, width):
  650.   wndMgr.SetLimitWidth(self.hWnd, width)
  651.  
  652.  def SetMultiLine(self):
  653.   wndMgr.SetMultiLine(self.hWnd, True)
  654.  
  655.  def SetHorizontalAlignArabic(self):
  656.   wndMgr.SetHorizontalAlign(self.hWnd, wndMgr.TEXT_HORIZONTAL_ALIGN_ARABIC)
  657.  
  658.  def SetHorizontalAlignLeft(self):
  659.   wndMgr.SetHorizontalAlign(self.hWnd, wndMgr.TEXT_HORIZONTAL_ALIGN_LEFT)
  660.  
  661.  def SetHorizontalAlignRight(self):
  662.   wndMgr.SetHorizontalAlign(self.hWnd, wndMgr.TEXT_HORIZONTAL_ALIGN_RIGHT)
  663.  
  664.  def SetHorizontalAlignCenter(self):
  665.   wndMgr.SetHorizontalAlign(self.hWnd, wndMgr.TEXT_HORIZONTAL_ALIGN_CENTER)
  666.  
  667.  def SetVerticalAlignTop(self):
  668.   wndMgr.SetVerticalAlign(self.hWnd, wndMgr.TEXT_VERTICAL_ALIGN_TOP)
  669.  
  670.  def SetVerticalAlignBottom(self):
  671.   wndMgr.SetVerticalAlign(self.hWnd, wndMgr.TEXT_VERTICAL_ALIGN_BOTTOM)
  672.  
  673.  def SetVerticalAlignCenter(self):
  674.   wndMgr.SetVerticalAlign(self.hWnd, wndMgr.TEXT_VERTICAL_ALIGN_CENTER)
  675.  
  676.  def SetSecret(self, Value=True):
  677.   wndMgr.SetSecret(self.hWnd, Value)
  678.  
  679.  def SetOutline(self, Value=True):
  680.   wndMgr.SetOutline(self.hWnd, Value)
  681.  
  682.  def SetFeather(self, value=True):
  683.   wndMgr.SetFeather(self.hWnd, value)
  684.  
  685.  def SetFontName(self, fontName):
  686.   wndMgr.SetFontName(self.hWnd, fontName)
  687.  
  688.  if app.WJ_MULTI_TEXTLINE:
  689.   def SetEnterToken(self, bool):
  690.    wndMgr.SetEnterToken(self.hWnd, bool)
  691.  
  692.  def SetDefaultFontName(self):
  693.   wndMgr.SetFontName(self.hWnd, localeInfo.UI_DEF_FONT)
  694.  
  695.  def SetFontColor(self, red, green, blue):
  696.   wndMgr.SetFontColor(self.hWnd, red, green, blue)
  697.  
  698.  def SetPackedFontColor(self, color):
  699.   wndMgr.SetFontColor(self.hWnd, color)
  700.  
  701.  def SetText(self, text):
  702.   wndMgr.SetText(self.hWnd, text)
  703.  
  704.  def GetText(self):
  705.   return wndMgr.GetText(self.hWnd)
  706.  
  707.  def GetTextSize(self):
  708.   return wndMgr.GetTextSize(self.hWnd)
  709.  
  710.  def SetLineHeight(self, Height):
  711.   wndMgr.SetLineHeight(self.hWnd, Height)
  712.  
  713.  def GetLineHeight(self):
  714.   return wndMgr.GetLineHeight(self.hWnd)
  715.  
  716.  def GetTextLineCount(self):
  717.   return wndMgr.GetTextLineCount(self.hWnd)
  718.  
  719. class EmptyCandidateWindow(Window):
  720.  def __init__(self):
  721.   Window.__init__(self)
  722.  
  723.  def __del__(self):
  724.   Window.__del__(self)
  725.  
  726.  def Load(self):
  727.   pass
  728.  
  729.  def SetCandidatePosition(self, x, y, textCount):
  730.   pass
  731.  
  732.  def Clear(self):
  733.   pass
  734.  
  735.  def Append(self, text):
  736.   pass
  737.  
  738.  def Refresh(self):
  739.   pass
  740.  
  741.  def Select(self):
  742.   pass
  743.  
  744. class EditLine(TextLine):
  745.  candidateWindowClassDict = {}
  746.  
  747.  def __init__(self):
  748.   TextLine.__init__(self)
  749.  
  750.   self.eventReturn = Window.NoneMethod
  751.   self.eventUpdate = Window.NoneMethod
  752.   self.eventEscape = Window.NoneMethod
  753.   self.eventTab    = Window.NoneMethod
  754.   self.eventUpdateArgs = None
  755.   self.eventReturnArgs = None
  756.   self.eventEscapeArgs = None
  757.   self.eventTabArgs = None
  758.   self.backgroundText = TextLine()
  759.   self.backgroundText.SetParent(self)
  760.   self.backgroundText.SetPosition(0, 0)
  761.   self.backgroundText.SetPackedFontColor(WHITE_COLOR)
  762.   self.backgroundText.Hide()
  763.  
  764.   self.eventReturn = Window.NoneMethod
  765.   self.eventEscape = Window.NoneMethod
  766.   self.eventTab = None
  767.   self.numberMode = False
  768.   self.useIME = True
  769.  
  770.   self.bCodePage = False
  771.  
  772.   self.candidateWindowClass = None
  773.   self.candidateWindow = None
  774.   self.SetCodePage(app.GetDefaultCodePage())
  775.  
  776.   self.readingWnd = ReadingWnd()
  777.   self.readingWnd.Hide()
  778.  
  779.  def __del__(self):
  780.   TextLine.__del__(self)
  781.  
  782.   self.eventReturn = Window.NoneMethod
  783.   self.eventUpdate = Window.NoneMethod
  784.   self.eventEscape = Window.NoneMethod
  785.   self.eventTab    = Window.NoneMethod
  786.   self.eventUpdateArgs = None
  787.   self.eventReturnArgs = None
  788.   self.eventEscapeArgs = None
  789.   self.eventTabArgs = None
  790.   self.backgroundText = None
  791.  
  792.   self.eventReturn = Window.NoneMethod
  793.   self.eventEscape = Window.NoneMethod
  794.   self.eventTab = None
  795.  
  796.  
  797.  def SetCodePage(self, codePage):
  798.   candidateWindowClass=EditLine.candidateWindowClassDict.get(codePage, EmptyCandidateWindow)
  799.   self.__SetCandidateClass(candidateWindowClass)
  800.  
  801.  def __SetCandidateClass(self, candidateWindowClass):
  802.   if self.candidateWindowClass==candidateWindowClass:
  803.    return
  804.  
  805.   self.candidateWindowClass = candidateWindowClass
  806.   self.candidateWindow = self.candidateWindowClass()
  807.   self.candidateWindow.Load()
  808.   self.candidateWindow.Hide()
  809.  
  810.  def RegisterWindow(self, layer):
  811.   self.hWnd = wndMgr.RegisterTextLine(self, layer)
  812.  
  813.  def SAFE_SetReturnEvent(self, event):
  814.   self.eventReturn = __mem_func__(event)  
  815.   self.eventReturnArgs = args
  816.  
  817.  def SetReturnEvent(self, event, *args):
  818.   self.eventReturn = event
  819.   self.eventReturnArgs = args
  820.  
  821.  def SAFE_SetUpdateEvent(self, event, *args):
  822.   self.eventUpdate = __mem_func__(event)  
  823.   self.eventUpdateArgs = args
  824.  
  825.  def SetUpdateEvent(self, event, *args):
  826.   self.eventUpdate = event
  827.   self.eventUpdateArgs = args
  828.  
  829.  def SetEscapeEvent(self, event, *args):
  830.   self.eventEscape = event
  831.   self.eventEscapeArgs = args
  832.  
  833.  def SetTabEvent(self, event, *args):
  834.   self.eventTab = event
  835.   self.eventTabArgs = args
  836.  
  837.  def SetBackgroundText(self, text):
  838.   self.backgroundText.SetPosition(0, 0)
  839.   self.backgroundText.SetText(text)
  840.  
  841.   if not self.backgroundText.IsShow():
  842.    self.backgroundText.Show()
  843.  
  844.  def SetTipText(self, tipText):
  845.   input = self.GetText()
  846.   (widht, height) = self.GetTextSize()
  847.  
  848.   tip = tipText[len(input):]
  849.   self.backgroundText.SetPosition(widht, 0)
  850.   self.backgroundText.SetText(tip)
  851.  
  852.   if not self.backgroundText.IsShow():
  853.    self.backgroundText.Show()
  854.  
  855.  def GetBackgroundText(self):
  856.   return self.backgroundText.GetText()
  857.  
  858.  def SetEscapeEvent(self, event):
  859.   self.eventEscape = event
  860.  
  861.  def SetTabEvent(self, event):
  862.   self.eventTab = event
  863.  
  864.  def SetMax(self, max):
  865.   self.max = max
  866.   wndMgr.SetMax(self.hWnd, self.max)
  867.   ime.SetMax(self.max)
  868.   self.SetUserMax(self.max)
  869.  
  870.  def SetUserMax(self, max):
  871.   self.userMax = max
  872.   ime.SetUserMax(self.userMax)
  873.  
  874.  def SetNumberMode(self):
  875.   self.numberMode = True
  876.  
  877.  #def AddExceptKey(self, key):
  878.  # ime.AddExceptKey(key)
  879.  
  880.  #def ClearExceptKey(self):
  881.  # ime.ClearExceptKey()
  882.  
  883.  def SetIMEFlag(self, flag):
  884.   self.useIME = flag
  885.  
  886.  def SetText(self, text):
  887.   wndMgr.SetText(self.hWnd, text)
  888.  
  889.   if self.IsFocus():
  890.    ime.SetText(text)
  891.  
  892.  def Enable(self):
  893.   wndMgr.ShowCursor(self.hWnd)
  894.  
  895.  def Disable(self):
  896.   wndMgr.HideCursor(self.hWnd)
  897.  
  898.  def SetEndPosition(self):
  899.   ime.MoveEnd()
  900.  
  901.  def OnSetFocus(self):
  902.   Text = self.GetText()
  903.   ime.SetText(Text)
  904.   ime.SetMax(self.max)
  905.   ime.SetUserMax(self.userMax)
  906.   ime.SetCursorPosition(-1)
  907.   if self.numberMode:
  908.    ime.SetNumberMode()
  909.   else:
  910.    ime.SetStringMode()
  911.   ime.EnableCaptureInput()
  912.   if self.useIME:
  913.    ime.EnableIME()
  914.   else:
  915.    ime.DisableIME()
  916.   wndMgr.ShowCursor(self.hWnd, True)
  917.  
  918.  def OnKillFocus(self):
  919.   self.SetText(ime.GetText(self.bCodePage))
  920.   self.OnIMECloseCandidateList()
  921.   self.OnIMECloseReadingWnd()
  922.   ime.DisableIME()
  923.   ime.DisableCaptureInput()
  924.   wndMgr.HideCursor(self.hWnd)
  925.  
  926.  def OnIMEChangeCodePage(self):
  927.   self.SetCodePage(ime.GetCodePage())
  928.  
  929.  def OnIMEOpenCandidateList(self):
  930.   self.candidateWindow.Show()
  931.   self.candidateWindow.Clear()
  932.   self.candidateWindow.Refresh()
  933.  
  934.   gx, gy = self.GetGlobalPosition()
  935.   self.candidateWindow.SetCandidatePosition(gx, gy, len(self.GetText()))
  936.  
  937.   return True
  938.  
  939.  def OnIMECloseCandidateList(self):
  940.   self.candidateWindow.Hide()
  941.   return True
  942.  
  943.  def OnIMEOpenReadingWnd(self):
  944.   gx, gy = self.GetGlobalPosition()
  945.   textlen = len(self.GetText())-2
  946.   reading = ime.GetReading()
  947.   readinglen = len(reading)
  948.   self.readingWnd.SetReadingPosition( gx + textlen*6-24-readinglen*6, gy )
  949.   self.readingWnd.SetText(reading)
  950.   if ime.GetReadingError() == 0:
  951.    self.readingWnd.SetTextColor(0xffffffff)
  952.   else:
  953.    self.readingWnd.SetTextColor(0xffff0000)
  954.   self.readingWnd.SetSize(readinglen * 6 + 4, 19)
  955.   self.readingWnd.Show()
  956.   return True
  957.  
  958.  def OnIMECloseReadingWnd(self):
  959.   self.readingWnd.Hide()
  960.   return True
  961.  
  962.  def IsNumber(self, text) :
  963.   try :
  964.    int(text)
  965.    return True
  966.   except ValueError :
  967.    return False
  968.  
  969.  def IsIncludeCodePage(self, text) :
  970.   textLen = len(text)
  971.   idx = 0
  972.  
  973.   while(idx < textLen) :
  974.    n = text.find("@", idx)
  975.  
  976.    if n == -1 :
  977.     break
  978.    elif n+4 < textLen and self.IsNumber(text[n+1:n+4]) == True:
  979.     return True
  980.    else:
  981.     idx = n + 1
  982.  
  983.   return False
  984.  
  985.  def OnIMEUpdate(self):
  986.   snd.PlaySound("sound/ui/type.wav")
  987.   TextLine.SetText(self, ime.GetText(self.bCodePage))
  988.  
  989.   if self.eventUpdate != None:
  990.    if self.eventUpdateArgs:
  991.     apply(self.eventUpdate, self.eventUpdateArgs)
  992.    else:
  993.     self.eventUpdate()
  994.  
  995.    if self.eventUpdate != Window.NoneMethod:
  996.     return True
  997.  
  998.   return False
  999.  
  1000.  def OnIMETab(self):
  1001.   if self.eventTabArgs:
  1002.    apply(self.eventTab, self.eventTabArgs)
  1003.   else:
  1004.    self.eventTab()
  1005.    
  1006.   if self.eventTab != Window.NoneMethod:
  1007.    return True
  1008.  
  1009.   return False
  1010.  
  1011.  def OnIMEReturn(self):
  1012.   snd.PlaySound("sound/ui/click.wav")
  1013.   if self.eventReturnArgs:
  1014.    apply(self.eventReturn, self.eventReturnArgs)
  1015.   else:
  1016.    self.eventReturn()
  1017.  
  1018.   if self.eventReturn != Window.NoneMethod:
  1019.    return True
  1020.  
  1021.   return False
  1022.  
  1023.  def OnPressEscapeKey(self):
  1024.   if self.eventEscapeArgs:
  1025.    apply(self.eventEscape, self.eventEscapeArgs)
  1026.   else:
  1027.    self.eventEscape()
  1028.  
  1029.   if self.eventEscape != Window.NoneMethod:
  1030.    return True
  1031.  
  1032.   return False
  1033.  
  1034.  def OnKeyDown(self, key):
  1035.   if app.DIK_F1 == key:
  1036.    return False
  1037.   if app.DIK_F2 == key:
  1038.    return False
  1039.   if app.DIK_F3 == key:
  1040.    return False
  1041.   if app.DIK_F4 == key:
  1042.    return False
  1043.   if app.DIK_LALT == key:
  1044.    return False
  1045.   if app.DIK_SYSRQ == key:
  1046.    return False
  1047.    if app.DIK_LC key:
  1048.    return False
  1049.   if app.DIK_V == key:
  1050.    if app.IsPressed(app.DIK_LCONTROL):
  1051.     ime.PasteTextFromClipBoard()
  1052.  
  1053.   return True
  1054.  
  1055.  def OnKeyUp(self, key):
  1056.   if app.DIK_F1 == key:
  1057.    return False
  1058.   if app.DIK_F2 == key:
  1059.    return False
  1060.   if app.DIK_F3 == key:
  1061.    return False
  1062.   if app.DIK_F4 == key:
  1063.    return False
  1064.   if app.DIK_LALT == key:
  1065.    return False
  1066.   if app.DIK_SYSRQ == key:
  1067.    return False
  1068.    if app.DIK_LC key:
  1069.    return False
  1070.  
  1071.   return True
  1072.  
  1073.  def OnIMEKeyDown(self, key):
  1074.   # Left
  1075.   if app.VK_LEFT == key:
  1076.    ime.MoveLeft()
  1077.    return True
  1078.   # Right
  1079.   if app.VK_RIGHT == key:
  1080.    ime.MoveRight()
  1081.    return True
  1082.  
  1083.   # Home
  1084.   if app.VK_HOME == key:
  1085.    ime.MoveHome()
  1086.    return True
  1087.   # End
  1088.   if app.VK_END == key:
  1089.    ime.MoveEnd()
  1090.    return True
  1091.  
  1092.   # Delete
  1093.   if app.VK_DELETE == key:
  1094.    ime.Delete()
  1095.    TextLine.SetText(self, ime.GetText(self.bCodePage))
  1096.    return True
  1097.  
  1098.   return True
  1099.  
  1100.  #def OnMouseLeftButtonDown(self):
  1101.  # self.SetFocus()
  1102.  def OnMouseLeftButtonDown(self):
  1103.   if False == self.IsIn():
  1104.    return False
  1105.  
  1106.   self.SetFocus()
  1107.    PixelPositi
  1108.   ime.SetCursorPosition(PixelPosition)
  1109.  
  1110. class MarkBox(Window):
  1111.  def __init__(self, layer = "UI"):
  1112.   Window.__init__(self, layer)
  1113.  
  1114.  def __del__(self):
  1115.   Window.__del__(self)
  1116.  
  1117.  def RegisterWindow(self, layer):
  1118.   self.hWnd = wndMgr.RegisterMarkBox(self, layer)
  1119.  
  1120.  def Load(self):
  1121.   wndMgr.MarkBox_Load(self.hWnd)
  1122.  
  1123.  def SetScale(self, scale):
  1124.   wndMgr.MarkBox_SetScale(self.hWnd, scale)
  1125.  
  1126.  def SetIndex(self, guildID):
  1127.   MarkID = guild.GuildIDToMarkID(guildID)
  1128.   wndMgr.MarkBox_SetImageFilename(self.hWnd, guild.GetMarkImageFilenameByMarkID(MarkID))
  1129.   wndMgr.MarkBox_SetIndex(self.hWnd, guild.GetMarkIndexByMarkID(MarkID))
  1130.  
  1131.  def SetAlpha(self, alpha):
  1132.   wndMgr.MarkBox_SetDiffuseColor(self.hWnd, 1.0, 1.0, 1.0, alpha)
  1133.  
  1134. class ImageBox(Window):
  1135.  def __init__(self, layer = "UI"):
  1136.   Window.__init__(self, layer)
  1137.  
  1138.   self.eventDict={}
  1139.   self.eventFunc = {"mouse_click" : None, "mouse_over_in" : None, "mouse_over_out" : None}
  1140.   self.eventArgs = {"mouse_click" : None, "mouse_over_in" : None, "mouse_over_out" : None}
  1141.  
  1142.  def __del__(self):
  1143.   Window.__del__(self)
  1144.   self.eventFunc = None
  1145.   self.eventArgs = None
  1146.  
  1147.  def LeftRightReverse(self):
  1148.   wndMgr.LeftRightReverseImageBox(self.hWnd)
  1149.  
  1150.  def RegisterWindow(self, layer):
  1151.   self.hWnd = wndMgr.RegisterImageBox(self, layer)
  1152.  
  1153.  def LoadImage(self, imageName):
  1154.   self.name=imageName
  1155.   wndMgr.LoadImage(self.hWnd, imageName)
  1156.  
  1157.   if len(self.eventDict)!=0:
  1158.    print "LOAD IMAGE", self, self.eventDict
  1159.  
  1160.  def SetAlpha(self, alpha):
  1161.   wndMgr.SetDiffuseColor(self.hWnd, 1.0, 1.0, 1.0, alpha)
  1162.  
  1163.  def GetWidth(self):
  1164.   return wndMgr.GetWidth(self.hWnd)
  1165.  
  1166.  ## Button Functions
  1167.  def SetScale(self, xScale, yScale):
  1168.   wndMgr.SetScale(self.hWnd, xScale, yScale)
  1169.  
  1170.  def GetHeight(self):
  1171.   return wndMgr.GetHeight(self.hWnd)
  1172.  
  1173.  def OnMouseOverIn(self):
  1174.   try:
  1175.    self.eventDict["MOUSE_OVER_IN"]()
  1176.   except KeyError:
  1177.    pass
  1178.  
  1179.  def OnMouseOverOut(self):
  1180.   try:
  1181.    self.eventDict["MOUSE_OVER_OUT"]()
  1182.   except KeyError:
  1183.    pass
  1184.  
  1185.  def SAFE_SetStringEvent(self, event, func):
  1186.   self.eventDict[event]=__mem_func__(func)
  1187.  
  1188.  def SetEvent(self, func, *args) :
  1189.   result = self.eventFunc.has_key(args[0])  
  1190.   if result :
  1191.    self.eventFunc[args[0]] = func
  1192.    self.eventArgs[args[0]] = args
  1193.   else :
  1194.    print "[ERROR] ui.py SetEvent, Can`t Find has_key : %s" % args[0]
  1195.  
  1196.  def OnMouseLeftButtonUp(self) :
  1197.   if self.eventFunc["mouse_click"] :
  1198.    apply(self.eventFunc["mouse_click"], self.eventArgs["mouse_click"])
  1199.  
  1200.  def OnMouseOverIn(self) :
  1201.   if self.eventFunc["mouse_over_in"] :
  1202.    apply(self.eventFunc["mouse_over_in"], self.eventArgs["mouse_over_in"])
  1203.   else:
  1204.    try:
  1205.     self.eventDict["MOUSE_OVER_IN"]()
  1206.    except KeyError:
  1207.     pass
  1208.  
  1209.  def OnMouseOverOut(self) :
  1210.   if self.eventFunc["mouse_over_out"] :
  1211.    apply(self.eventFunc["mouse_over_out"], self.eventArgs["mouse_over_out"])
  1212.   else :
  1213.    try:
  1214.     self.eventDict["MOUSE_OVER_OUT"]()
  1215.    except KeyError:
  1216.     pass
  1217.  
  1218.  if app.__BL_FISH_RENEWAL__:
  1219.   def OnMouseLeftButtonDown(self):
  1220.    try:
  1221.     self.eventDict["mouse_down"]()
  1222.    except KeyError:
  1223.     pass
  1224.  
  1225. class ExpandedImageBox(ImageBox):
  1226.  def __init__(self, layer = "UI"):
  1227.   ImageBox.__init__(self, layer)
  1228.  
  1229.  def __del__(self):
  1230.   ImageBox.__del__(self)
  1231.  
  1232.  def RegisterWindow(self, layer):
  1233.   self.hWnd = wndMgr.RegisterExpandedImageBox(self, layer)
  1234.  
  1235.  #def SetScale(self, xScale, yScale):
  1236.  # wndMgr.SetScale(self.hWnd, xScale, yScale)
  1237.  
  1238.  def SetOrigin(self, x, y):
  1239.   wndMgr.SetOrigin(self.hWnd, x, y)
  1240.  
  1241.  def SetRotation(self, rotation):
  1242.   wndMgr.SetRotation(self.hWnd, rotation)
  1243.  
  1244.  def SetRenderingMode(self, mode):
  1245.   wndMgr.SetRenderingMode(self.hWnd, mode)
  1246.  
  1247.  def SetRenderingRect(self, left, top, right, bottom):
  1248.   wndMgr.SetRenderingRect(self.hWnd, left, top, right, bottom)
  1249.  
  1250.  def SetPercentage(self, curValue, maxValue):
  1251.   if maxValue:
  1252.    self.SetRenderingRect(0.0, 0.0, -1.0 + float(curValue) / float(maxValue), 0.0)
  1253.   else:
  1254.    self.SetRenderingRect(0.0, 0.0, 0.0, 0.0)
  1255.  
  1256.  def GetWidth(self):
  1257.   return wndMgr.GetWindowWidth(self.hWnd)
  1258.  
  1259.  def GetHeight(self):
  1260.   return wndMgr.GetWindowHeight(self.hWnd)
  1261.  
  1262. class AniImageBox(Window):
  1263.  def __init__(self, layer = "UI"):
  1264.   Window.__init__(self, layer)
  1265.  
  1266.   if app.__BL_ON_END_KEY_FRAME__:
  1267.    self.end_frame_event = None
  1268.    self.key_frame_event = None
  1269.  
  1270.  def __del__(self):
  1271.   Window.__del__(self)
  1272.  
  1273.   if app.__BL_ON_END_KEY_FRAME__:
  1274.    self.end_frame_event = None
  1275.    self.key_frame_event = None
  1276.  
  1277.  def RegisterWindow(self, layer):
  1278.   self.hWnd = wndMgr.RegisterAniImageBox(self, layer)
  1279.  
  1280.  def SetDelay(self, delay):
  1281.   wndMgr.SetDelay(self.hWnd, delay)
  1282.  
  1283.  if app.BL_MAILBOX:
  1284.   def ResetFrame(self):
  1285.    wndMgr.ResetFrame(self.hWnd)
  1286.  
  1287.  def AppendImage(self, filename):
  1288.   wndMgr.AppendImage(self.hWnd, filename)
  1289.  
  1290.  def SetPercentage(self, curValue, maxValue):
  1291.   wndMgr.SetRenderingRect(self.hWnd, 0.0, 0.0, -1.0 + float(curValue) / float(maxValue), 0.0)
  1292.  
  1293.  if app.__BL_ON_END_KEY_FRAME__:
  1294.   def OnEndFrame(self):
  1295.    if self.end_frame_event:
  1296.     self.end_frame_event()
  1297.  
  1298.   def SetEndFrameEvent(self, event):
  1299.    self.end_frame_event = event
  1300.  
  1301.   def OnKeyFrame(self, cur_frame):
  1302.    if self.key_frame_event:
  1303.     self.key_frame_event(cur_frame)
  1304.    
  1305.   def SetKeyFrameEvent(self, event):
  1306.    self.key_frame_event = event
  1307.  else:
  1308.   def OnEndFrame(self):
  1309.    pass
  1310.  
  1311. class Button(Window):
  1312.  def __init__(self, layer = "UI"):
  1313.   Window.__init__(self, layer)
  1314.  
  1315.   self.overFunc = None
  1316.   self.overArgs = None
  1317.   self.overOutFunc = None
  1318.   self.overOutArgs = None
  1319.  
  1320.   self.showtooltipevent = None
  1321.   self.showtooltiparg = None
  1322.   self.hidetooltipevent = None
  1323.   self.hidetooltiparg = None
  1324.  
  1325.   self.eventFunc = None
  1326.   self.eventArgs = None
  1327.  
  1328.    self.Butt
  1329.   self.ToolTipText = None
  1330.  
  1331.   if app.__BL_CHARACTER_CREATE_SELECT__:
  1332.    self.TextChild = []
  1333.  
  1334.  def __del__(self):
  1335.   Window.__del__(self)
  1336.  
  1337.   self.overFunc = None
  1338.   self.overArgs = None
  1339.   self.overOutFunc = None
  1340.   self.overOutArgs = None
  1341.  
  1342.   self.eventFunc = None
  1343.   self.eventArgs = None
  1344.  
  1345.   self.showtooltipevent = None
  1346.   self.showtooltiparg = None
  1347.   self.hidetooltipevent = None
  1348.   self.hidetooltiparg = None
  1349.  
  1350.  def LeftRightReverse(self) :
  1351.   wndMgr.LeftRightReverse(self.hWnd)
  1352.  
  1353.  def RegisterWindow(self, layer):
  1354.   self.hWnd = wndMgr.RegisterButton(self, layer)
  1355.  
  1356.  def SetUpVisual(self, filename):
  1357.   wndMgr.SetUpVisual(self.hWnd, filename)
  1358.  
  1359.  def SetOverVisual(self, filename):
  1360.   wndMgr.SetOverVisual(self.hWnd, filename)
  1361.  
  1362.  def SetDownVisual(self, filename):
  1363.   wndMgr.SetDownVisual(self.hWnd, filename)
  1364.  
  1365.  def SetDisableVisual(self, filename):
  1366.   wndMgr.SetDisableVisual(self.hWnd, filename)
  1367.  
  1368.  def GetUpVisualFileName(self):
  1369.   return wndMgr.GetUpVisualFileName(self.hWnd)
  1370.  
  1371.  def GetOverVisualFileName(self):
  1372.   return wndMgr.GetOverVisualFileName(self.hWnd)
  1373.  
  1374.  def GetDownVisualFileName(self):
  1375.   return wndMgr.GetDownVisualFileName(self.hWnd)
  1376.  
  1377.  def Flash(self):
  1378.   wndMgr.Flash(self.hWnd)
  1379.  
  1380.  def Enable(self):
  1381.   wndMgr.Enable(self.hWnd)
  1382.  
  1383.  def Disable(self):
  1384.   wndMgr.Disable(self.hWnd)
  1385.  
  1386.  def Down(self):
  1387.   wndMgr.Down(self.hWnd)
  1388.  
  1389.  def SetUp(self):
  1390.   wndMgr.SetUp(self.hWnd)
  1391.  
  1392.  def SAFE_SetEvent(self, func, *args):
  1393.   self.eventFunc = __mem_func__(func)
  1394.   self.eventArgs = args
  1395.  
  1396.  def SetEvent(self, func, *args):
  1397.   self.eventFunc = func
  1398.   self.eventArgs = args
  1399.  
  1400.  def SetTextColor(self, color):
  1401.   if not self.ButtonText:
  1402.    return
  1403.   self.ButtonText.SetPackedFontColor(color)
  1404.  
  1405.  def SetText(self, text, height = 4):
  1406.  
  1407.   if not self.ButtonText:
  1408.    textLine = TextLine()
  1409.    textLine.SetParent(self)
  1410.    textLine.SetPosition(self.GetWidth()/2, self.GetHeight()/2)
  1411.    textLine.SetVerticalAlignCenter()
  1412.    textLine.SetHorizontalAlignCenter()
  1413.    textLine.Show()
  1414.     self.Butt
  1415.  
  1416.   self.ButtonText.SetText(text)
  1417.  
  1418.  if constInfo.EXTRA_UI_FEATURE:
  1419.   def GetText(self):
  1420.    if not self.ButtonText:
  1421.     return ""
  1422.    return self.ButtonText.GetText()
  1423.  
  1424.  def SetFormToolTipText(self, type, text, x, y):
  1425.   if not self.ToolTipText:
  1426.    toolTip=createToolTipWindowDict[type]()
  1427.    toolTip.SetParent(self)
  1428.    toolTip.SetSize(0, 0)
  1429.    toolTip.SetHorizontalAlignCenter()
  1430.    toolTip.SetOutline()
  1431.    toolTip.Hide()
  1432.    toolTip.SetPosition(x + self.GetWidth()/2, y)
  1433.    self.ToolTipText=toolTip
  1434.  
  1435.   self.ToolTipText.SetText(text)
  1436.  
  1437.  def SetToolTipWindow(self, toolTip):
  1438.   self.ToolTipText=toolTip
  1439.   self.ToolTipText.SetParentProxy(self)
  1440.  
  1441.  def SetToolTipText(self, text, x=0, y = -19):
  1442.   self.SetFormToolTipText("TEXT", text, x, y)
  1443.  
  1444.  def CallEvent(self):
  1445.   snd.PlaySound("sound/ui/click.wav")
  1446.  
  1447.   if self.eventFunc:
  1448.    apply(self.eventFunc, self.eventArgs)
  1449.  
  1450.  def ShowToolTip(self):
  1451.   if self.ToolTipText:
  1452.    self.ToolTipText.Show()
  1453.  
  1454.   if self.showtooltipevent:
  1455.    apply(self.showtooltipevent, self.showtooltiparg)
  1456.  
  1457.  def HideToolTip(self):
  1458.   if self.ToolTipText:
  1459.    self.ToolTipText.Hide()
  1460.  
  1461.   if self.hidetooltipevent:
  1462.    apply(self.hidetooltipevent, self.hidetooltiparg)
  1463.  
  1464.  def SetShowToolTipEvent(self, func, *args):
  1465.   self.showtooltipevent = func
  1466.   self.showtooltiparg = args
  1467.  
  1468.  def SetHideToolTipEvent(self, func, *args):
  1469.   self.hidetooltipevent = func
  1470.   self.hidetooltiparg = args
  1471.  
  1472.  if app.ENABLE_PREMIUM_PRIVATE_SHOP:
  1473.   def SetAlpha(self, alpha):
  1474.    wndMgr.SetButtonDiffuseColor(self.hWnd, 1.0, 1.0, 1.0, alpha)
  1475.  
  1476.   def GetText(self):
  1477.    if self.ButtonText:
  1478.     return self.ButtonText.GetText()
  1479.    else:
  1480.     return ""
  1481.    
  1482.   def IsDisable(self):
  1483.    return wndMgr.IsDisable(self.hWnd)
  1484.  
  1485.   def SetScale(self, scale_x, scale_y):
  1486.    wndMgr.SetButtonScale(self.hWnd, scale_x, scale_y)
  1487.    
  1488.   def SetDiffuseColor(self, r, g, b, a):
  1489.    wndMgr.SetButtonDiffuseColor(self.hWnd, r, g, b, a)
  1490.  
  1491.  def IsDown(self):
  1492.   return wndMgr.IsDown(self.hWnd)
  1493.  
  1494.  if app.__BL_MULTI_LANGUAGE__:
  1495.   def OnMouseOverIn(self):
  1496.    if self.overFunc:
  1497.     apply(self.overFunc, self.overArgs )
  1498.   def OnMouseOverOut(self):
  1499.    if self.overOutFunc:
  1500.     apply(self.overOutFunc, self.overOutArgs )
  1501.   def SetOverEvent(self, func, *args):
  1502.    self.overFunc = func
  1503.    self.overArgs = args
  1504.   def SetOverOutEvent(self, func, *args):
  1505.    self.overOutFunc = func
  1506.    self.overOutArgs = args
  1507.  
  1508.  if app.__BL_CHARACTER_CREATE_SELECT__:
  1509.   def Over(self):
  1510.    wndMgr.Over(self.hWnd)
  1511.  
  1512.   def AppendTextLineAllClear(self) :
  1513.    self.TextChild = []
  1514.  
  1515.   def SetAppendTextChangeText(self, idx, text):
  1516.    if not len(self.TextChild) :
  1517.     return
  1518.  
  1519.    self.TextChild[idx].SetText(text)
  1520.  
  1521.   def SetAppendTextColor(self, idx, color) :
  1522.    if not len(self.TextChild) :
  1523.     return
  1524.  
  1525.    self.TextChild[idx].SetPackedFontColor(color)
  1526.  
  1527.   def AppendTextLine(self, text
  1528.     , f
  1529.     , f 0.7607, 0.7607, 1.0)
  1530.    , text_sort = "center"
  1531.    , pos_x = None
  1532.    , pos_y = None) :
  1533.    textLine = TextLine()
  1534.    textLine.SetParent(self)
  1535.    textLine.SetFontName(font_size)
  1536.    textLine.SetPackedFontColor(font_color)
  1537.    textLine.SetText(text)
  1538.    textLine.Show()
  1539.  
  1540.    if not pos_x and not pos_y :
  1541.     textLine.SetPosition(self.GetWidth()/2, self.GetHeight()/2)
  1542.    else :
  1543.     textLine.SetPosition(pos_x, pos_y)
  1544.  
  1545.    textLine.SetVerticalAlignCenter()
  1546.    if "center" == text_sort :
  1547.     textLine.SetHorizontalAlignCenter()
  1548.    elif "right" == text_sort :
  1549.     textLine.SetHorizontalAlignRight()
  1550.    elif "left" ==  text_sort :
  1551.     textLine.SetHorizontalAlignLeft()
  1552.    
  1553.    self.TextChild.append(textLine)
  1554.  
  1555.  ## Button Functions
  1556.  def EnableFlash(self):
  1557.   wndMgr.EnableFlash(self.hWnd)
  1558.  
  1559.  def DisableFlash(self):
  1560.   wndMgr.DisableFlash(self.hWnd)
  1561.  
  1562.  def GetButtonImageWidth(self):
  1563.   return wndMgr.GetButtonImageWidth(self.hWnd)
  1564.  
  1565.  def GetButtonImageHeight(self):
  1566.   return wndMgr.GetButtonImageHeight(self.hWnd)
  1567.  
  1568.  def SetAlwaysToolTip(self, bFlag):
  1569.   wndMgr.SetAlwaysToolTip(self.hWnd, bFlag)
  1570.  
  1571.  def SetAlwaysExecuteOverFunc(self, bFlag):
  1572.   wndMgr.SetAlwaysExecuteOverFunc(self.hWnd, bFlag)
  1573.  
  1574.  def SetButtonScale(self, xScale, yScale):
  1575.   wndMgr.SetButtonScale(self.hWnd, xScale, yScale)
  1576.  
  1577.  def SetAlpha(self, alpha):
  1578.   wndMgr.SetButtonDiffuseColor(self.hWnd, 1.0, 1.0, 1.0, alpha)
  1579.  
  1580.  def IsDIsable(self):
  1581.   return wndMgr.IsDIsable(self.hWnd)
  1582.  
  1583.  if app.__BL__DETAILS_UI__:
  1584.   def OnMouseOverIn(self):
  1585.    if self.overFunc:
  1586.     apply(self.overFunc, self.overArgs )
  1587.   def OnMouseOverOut(self):
  1588.    if self.overOutFunc:
  1589.     apply(self.overOutFunc, self.overOutArgs )
  1590.   def SetOverEvent(self, func, *args):
  1591.    self.overFunc = func
  1592.    self.overArgs = args
  1593.   def SetOverOutEvent(self, func, *args):
  1594.    self.overOutFunc = func
  1595.    self.overOutArgs = args
  1596.  
  1597. class RadioButton(Button):
  1598.  def __init__(self):
  1599.   Button.__init__(self)
  1600.  
  1601.  def __del__(self):
  1602.   Button.__del__(self)
  1603.  
  1604.  def RegisterWindow(self, layer):
  1605.   self.hWnd = wndMgr.RegisterRadioButton(self, layer)
  1606.  
  1607. class RadioButtonGroup(NoWindow):
  1608.  def __init__(self):
  1609.    self.butt
  1610.   self.selectedBtnIdx = -1
  1611.  
  1612.  def __del__(self):
  1613.   for button, ue, de in self.buttonGroup:
  1614.    button.__del__()
  1615.  
  1616.  def Show(self):
  1617.   for (button, selectEvent, unselectEvent) in self.buttonGroup:
  1618.    button.Show()
  1619.  
  1620.  def Hide(self):
  1621.   for (button, selectEvent, unselectEvent) in self.buttonGroup:
  1622.    button.Hide()
  1623.  
  1624.  def SetText(self, idx, text):
  1625.   if idx >= len(self.buttonGroup):
  1626.    return
  1627.   (button, selectEvent, unselectEvent) = self.buttonGroup[idx]
  1628.   button.SetText(text)
  1629.  
  1630.  def OnClick(self, btnIdx):
  1631.   if btnIdx == self.selectedBtnIdx:
  1632.    return
  1633.   (button, selectEvent, unselectEvent) = self.buttonGroup[self.selectedBtnIdx]
  1634.   if unselectEvent:
  1635.    unselectEvent()
  1636.   button.SetUp()
  1637.  
  1638.   self.selectedBtnIdx = btnIdx
  1639.   (button, selectEvent, unselectEvent) = self.buttonGroup[btnIdx]
  1640.   if selectEvent:
  1641.    selectEvent()
  1642.  
  1643.   button.Down()
  1644.  
  1645.  def AddButton(self, button, selectEvent, unselectEvent):
  1646.   i = len(self.buttonGroup)
  1647.   button.SetEvent(lambda : self.OnClick(i))
  1648.   self.buttonGroup.append([button, selectEvent, unselectEvent])
  1649.   button.SetUp()
  1650.  
  1651.  def Create(rawButtonGroup):
  1652.   radioGroup = RadioButtonGroup()
  1653.   for (button, selectEvent, unselectEvent) in rawButtonGroup:
  1654.    radioGroup.AddButton(button, selectEvent, unselectEvent)
  1655.  
  1656.   radioGroup.OnClick(0)
  1657.  
  1658.   return radioGroup
  1659.  
  1660.  Create=staticmethod(Create)
  1661.  
  1662. class ToggleButton(Button):
  1663.  def __init__(self):
  1664.   Button.__init__(self)
  1665.  
  1666.   self.eventUp = None
  1667.   self.eventDown = None
  1668.  
  1669.   self.eventUpArgs = None
  1670.   self.eventDownArgs = None
  1671.  
  1672.  def __del__(self):
  1673.   Button.__del__(self)
  1674.  
  1675.   self.eventUp = None
  1676.   self.eventDown = None
  1677.  
  1678.  def SetToggleUpEvent(self, event, *args):
  1679.   self.eventUp = event
  1680.   self.eventUpArgs = args
  1681.  
  1682.  def SetToggleDownEvent(self, event, *args):
  1683.   self.eventDown = event
  1684.   self.eventDownArgs = args
  1685.  
  1686.  def RegisterWindow(self, layer):
  1687.   self.hWnd = wndMgr.RegisterToggleButton(self, layer)
  1688.  
  1689.  def OnToggleUp(self):
  1690.   if self.eventUp:
  1691.    if self.eventUpArgs:
  1692.     apply(self.eventUp, self.eventUpArgs)
  1693.    else:
  1694.     self.eventUp()
  1695.  
  1696.  def OnToggleDown(self):
  1697.   if self.eventDown:
  1698.    if self.eventDownArgs:
  1699.     apply(self.eventDown, self.eventDownArgs)
  1700.    else:
  1701.     self.eventDown()
  1702.  
  1703. class DragButton(Button):
  1704.  def __init__(self):
  1705.   Button.__init__(self)
  1706.   self.AddFlag("movable")
  1707.  
  1708.   self.callbackEnable = True
  1709.   self.eventMove = lambda: None
  1710.  
  1711.  def __del__(self):
  1712.   Button.__del__(self)
  1713.  
  1714.   self.eventMove = lambda: None
  1715.  
  1716.  def RegisterWindow(self, layer):
  1717.   self.hWnd = wndMgr.RegisterDragButton(self, layer)
  1718.  
  1719.  def SetMoveEvent(self, event):
  1720.   self.eventMove = event
  1721.  
  1722.  def SetRestrictMovementArea(self, x, y, width, height):
  1723.   wndMgr.SetRestrictMovementArea(self.hWnd, x, y, width, height)
  1724.  
  1725.  def TurnOnCallBack(self):
  1726.   self.callbackEnable = True
  1727.  
  1728.  def TurnOffCallBack(self):
  1729.   self.callbackEnable = False
  1730.  
  1731.  def OnMove(self):
  1732.   if self.callbackEnable:
  1733.    self.eventMove()
  1734.  
  1735. class NumberLine(Window):
  1736.  
  1737.  def __init__(self, layer = "UI"):
  1738.   Window.__init__(self, layer)
  1739.  
  1740.  def __del__(self):
  1741.   Window.__del__(self)
  1742.  
  1743.  def RegisterWindow(self, layer):
  1744.   self.hWnd = wndMgr.RegisterNumberLine(self, layer)
  1745.  
  1746.  def SetHorizontalAlignCenter(self):
  1747.   wndMgr.SetNumberHorizontalAlignCenter(self.hWnd)
  1748.  
  1749.  def SetHorizontalAlignRight(self):
  1750.   wndMgr.SetNumberHorizontalAlignRight(self.hWnd)
  1751.  
  1752.  def SetPath(self, path):
  1753.   wndMgr.SetPath(self.hWnd, path)
  1754.  
  1755.  def SetNumber(self, number):
  1756.   wndMgr.SetNumber(self.hWnd, number)
  1757.  
  1758. ###################################################################################################
  1759. ## PythonScript Element
  1760. ###################################################################################################
  1761.  
  1762. class Box(Window):
  1763.  
  1764.  def RegisterWindow(self, layer):
  1765.   self.hWnd = wndMgr.RegisterBox(self, layer)
  1766.  
  1767.  def SetColor(self, color):
  1768.   wndMgr.SetColor(self.hWnd, color)
  1769.  
  1770. class Bar(Window):
  1771.  def __init__(self, layer = "UI"):
  1772.   Window.__init__(self, layer)
  1773.  
  1774.  def __del__(self):
  1775.   Window.__del__(self)
  1776.  
  1777.  def RegisterWindow(self, layer):
  1778.   self.hWnd = wndMgr.RegisterBar(self, layer)
  1779.  
  1780.  def SetColor(self, color):
  1781.   wndMgr.SetColor(self.hWnd, color)
  1782.  
  1783. class Line(Window):
  1784.  
  1785.  def RegisterWindow(self, layer):
  1786.   self.hWnd = wndMgr.RegisterLine(self, layer)
  1787.  
  1788.  def SetColor(self, color):
  1789.   wndMgr.SetColor(self.hWnd, color)
  1790.  
  1791. class SlotBar(Window):
  1792.  
  1793.  def __init__(self):
  1794.   Window.__init__(self)
  1795.  
  1796.  def RegisterWindow(self, layer):
  1797.   self.hWnd = wndMgr.RegisterBar3D(self, layer)
  1798.  
  1799. ## Same with SlotBar
  1800. class Bar3D(Window):
  1801.  
  1802.  def __init__(self):
  1803.   Window.__init__(self)
  1804.  
  1805.  def RegisterWindow(self, layer):
  1806.   self.hWnd = wndMgr.RegisterBar3D(self, layer)
  1807.  
  1808.  def SetColor(self, left, right, center):
  1809.   wndMgr.SetColor(self.hWnd, left, right, center)
  1810.  
  1811. class SlotWindow(Window):
  1812.  
  1813.  def __init__(self):
  1814.   Window.__init__(self)
  1815.  
  1816.   self.StartIndex = 0
  1817.  
  1818.   self.eventSelectEmptySlot = None
  1819.   self.eventSelectItemSlot = None
  1820.   self.eventUnselectEmptySlot = None
  1821.   self.eventUnselectItemSlot = None
  1822.   self.eventUseSlot = None
  1823.   self.eventOverInItem = None
  1824.   self.eventOverOutItem = None
  1825.   self.eventPressedSlotButton = None
  1826.  
  1827.  def __del__(self):
  1828.   Window.__del__(self)
  1829.  
  1830.   self.eventSelectEmptySlot = None
  1831.   self.eventSelectItemSlot = None
  1832.   self.eventUnselectEmptySlot = None
  1833.   self.eventUnselectItemSlot = None
  1834.   self.eventUseSlot = None
  1835.   self.eventOverInItem = None
  1836.   self.eventOverOutItem = None
  1837.   self.eventPressedSlotButton = None
  1838.  
  1839.  def SetSlotType(self, flag):
  1840.   wndMgr.SetSlotType(self.hWnd, flag)
  1841.  
  1842.  if app.ENABLE_DSS_ACTIVE_EFFECT_BUTTON:
  1843.   def SetRenderSlot(self, renderingSlotNumber, diffuseColor = (1.0, 1.0, 1.0, 1.0)):
  1844.    wndMgr.SetSlot(self.hWnd, renderingSlotNumber, 1, 1, 1, 0, diffuseColor)
  1845.    wndMgr.SetSlotCount(self.hWnd, renderingSlotNumber, 0)
  1846.  
  1847.  def RegisterWindow(self, layer):
  1848.   self.hWnd = wndMgr.RegisterSlotWindow(self, layer)
  1849.  
  1850.  def SetSlotStyle(self, style):
  1851.   wndMgr.SetSlotStyle(self.hWnd, style)
  1852.  
  1853.  def HasSlot(self, slotIndex):
  1854.   return wndMgr.HasSlot(self.hWnd, slotIndex)
  1855.  
  1856.  def SetSlotBaseImage(self, imageFileName, r, g, b, a):
  1857.   wndMgr.SetSlotBaseImage(self.hWnd, imageFileName, r, g, b, a)
  1858.  
  1859.  def SetCoverButton(self,\
  1860.       slotIndex,\
  1861.       upName="d:/ymir work/ui/public/slot_cover_button_01.sub",\
  1862.       overName="d:/ymir work/ui/public/slot_cover_button_02.sub",\
  1863.       downName="d:/ymir work/ui/public/slot_cover_button_03.sub",\
  1864.       disableName="d:/ymir work/ui/public/slot_cover_button_04.sub",\
  1865.       LeftButtonEnable = False,\
  1866.       RightButtonEnable = True):
  1867.   wndMgr.SetCoverButton(self.hWnd, slotIndex, upName, overName, downName, disableName, LeftButtonEnable, RightButtonEnable)
  1868.  
  1869.  def EnableCoverButton(self, slotIndex):
  1870.   wndMgr.EnableCoverButton(self.hWnd, slotIndex)
  1871.  
  1872.  def DisableCoverButton(self, slotIndex):
  1873.   wndMgr.DisableCoverButton(self.hWnd, slotIndex)
  1874.  
  1875.  def SetAlwaysRenderCoverButton(self, slotIndex, bAlwaysRender = True):
  1876.   wndMgr.SetAlwaysRenderCoverButton(self.hWnd, slotIndex, bAlwaysRender)
  1877.  
  1878.  def AppendSlotButton(self, upName, overName, downName):
  1879.   wndMgr.AppendSlotButton(self.hWnd, upName, overName, downName)
  1880.  
  1881.  def ShowSlotButton(self, slotNumber):
  1882.   wndMgr.ShowSlotButton(self.hWnd, slotNumber)
  1883.  
  1884.  def HideAllSlotButton(self):
  1885.   wndMgr.HideAllSlotButton(self.hWnd)
  1886.  
  1887.  def AppendRequirementSignImage(self, filename):
  1888.   wndMgr.AppendRequirementSignImage(self.hWnd, filename)
  1889.  
  1890.  def ShowRequirementSign(self, slotNumber):
  1891.   wndMgr.ShowRequirementSign(self.hWnd, slotNumber)
  1892.  
  1893.  def HideRequirementSign(self, slotNumber):
  1894.   wndMgr.HideRequirementSign(self.hWnd, slotNumber)
  1895.  
  1896.  def ActivateSlot(self, slotNumber, r = 1.0, g = 1.0, b = 1.0, a = 1.0):
  1897.   wndMgr.ActivateSlot(self.hWnd, slotNumber, r, g, b, a)
  1898.  
  1899.  def DeactivateSlot(self, slotNumber):
  1900.   wndMgr.DeactivateSlot(self.hWnd, slotNumber)
  1901.  
  1902.  def ShowSlotBaseImage(self, slotNumber):
  1903.   wndMgr.ShowSlotBaseImage(self.hWnd, slotNumber)
  1904.  
  1905.  def HideSlotBaseImage(self, slotNumber):
  1906.   wndMgr.HideSlotBaseImage(self.hWnd, slotNumber)
  1907.  
  1908.  def SAFE_SetButtonEvent(self, button, state, event):
  1909.   if "LEFT"==button:
  1910.    if "EMPTY"==state:
  1911.     self.eventSelectEmptySlot=__mem_func__(event)
  1912.    elif "EXIST"==state:
  1913.     self.eventSelectItemSlot=__mem_func__(event)
  1914.    elif "ALWAYS"==state:
  1915.     self.eventSelectEmptySlot=__mem_func__(event)
  1916.     self.eventSelectItemSlot=__mem_func__(event)
  1917.   elif "RIGHT"==button:
  1918.    if "EMPTY"==state:
  1919.     self.eventUnselectEmptySlot=__mem_func__(event)
  1920.    elif "EXIST"==state:
  1921.     self.eventUnselectItemSlot=__mem_func__(event)
  1922.    elif "ALWAYS"==state:
  1923.     self.eventUnselectEmptySlot=__mem_func__(event)
  1924.     self.eventUnselectItemSlot=__mem_func__(event)
  1925.  
  1926.  def SetSelectEmptySlotEvent(self, empty):
  1927.   self.eventSelectEmptySlot = empty
  1928.  
  1929.  def SetSelectItemSlotEvent(self, item):
  1930.   self.eventSelectItemSlot = item
  1931.  
  1932.  def SetUnselectEmptySlotEvent(self, empty):
  1933.   self.eventUnselectEmptySlot = empty
  1934.  
  1935.  def SetUnselectItemSlotEvent(self, item):
  1936.   self.eventUnselectItemSlot = item
  1937.  
  1938.  def SetUseSlotEvent(self, use):
  1939.   self.eventUseSlot = use
  1940.  
  1941.  def SetOverInItemEvent(self, event):
  1942.   self.eventOverInItem = event
  1943.  
  1944.  def SetOverOutItemEvent(self, event):
  1945.   self.eventOverOutItem = event
  1946.  
  1947.  def SetPressedSlotButtonEvent(self, event):
  1948.   self.eventPressedSlotButton = event
  1949.  
  1950.  def GetSlotCount(self):
  1951.   return wndMgr.GetSlotCount(self.hWnd)
  1952.  
  1953.  def SetUseMode(self, flag):
  1954.   wndMgr.SetUseMode(self.hWnd, flag)
  1955.  
  1956.  def SetUsableItem(self, flag):
  1957.   wndMgr.SetUsableItem(self.hWnd, flag)
  1958.  
  1959.  ## Slot
  1960.  if app.ENABLE_SLOT_WINDOW_EX:
  1961.   def IsActivatedSlot(self, slotNumber):
  1962.    return wndMgr.IsActivatedSlot(self.hWnd, slotNumber)
  1963.  
  1964.   def GetSlotCoolTime(self, slotIndex):
  1965.    return wndMgr.GetSlotCoolTime(self.hWnd, slotIndex)
  1966.  
  1967.  if app.WJ_ENABLE_TRADABLE_ICON:
  1968.   def SetCanMouseEventSlot(self, slotIndex):
  1969.    wndMgr.SetCanMouseEventSlot(self.hWnd, slotIndex)
  1970.  
  1971.   def SetCantMouseEventSlot(self, slotIndex):
  1972.    wndMgr.SetCantMouseEventSlot(self.hWnd, slotIndex)
  1973.  
  1974.   def SetUsableSlotOnTopWnd(self, slotIndex):
  1975.    wndMgr.SetUsableSlotOnTopWnd(self.hWnd, slotIndex)
  1976.  
  1977.   def SetUnusableSlotOnTopWnd(self, slotIndex):
  1978.    wndMgr.SetUnusableSlotOnTopWnd(self.hWnd, slotIndex)
  1979.  
  1980.  def SetSlotCoolTime(self, slotIndex, coolTime, elapsedTime = 0.0):
  1981.   wndMgr.SetSlotCoolTime(self.hWnd, slotIndex, coolTime, elapsedTime)
  1982.  
  1983.  def DisableSlot(self, slotIndex):
  1984.   wndMgr.DisableSlot(self.hWnd, slotIndex)
  1985.  
  1986.  def EnableSlot(self, slotIndex):
  1987.   wndMgr.EnableSlot(self.hWnd, slotIndex)
  1988.  
  1989.  def LockSlot(self, slotIndex):
  1990.   wndMgr.LockSlot(self.hWnd, slotIndex)
  1991.  
  1992.  def UnlockSlot(self, slotIndex):
  1993.   wndMgr.UnlockSlot(self.hWnd, slotIndex)
  1994.  
  1995.  def RefreshSlot(self):
  1996.   wndMgr.RefreshSlot(self.hWnd)
  1997.  
  1998.  def ClearSlot(self, slotNumber):
  1999.   wndMgr.ClearSlot(self.hWnd, slotNumber)
  2000.  
  2001.  def ClearAllSlot(self):
  2002.   wndMgr.ClearAllSlot(self.hWnd)
  2003.  
  2004.  def AppendSlot(self, index, x, y, width, height):
  2005.   wndMgr.AppendSlot(self.hWnd, index, x, y, width, height)
  2006.  
  2007.  def SetSlot(self, slotIndex, itemIndex, width, height, icon, diffuseColor = (1.0, 1.0, 1.0, 1.0)):
  2008.   wndMgr.SetSlot(self.hWnd, slotIndex, itemIndex, width, height, icon, diffuseColor)
  2009.  
  2010.  def SetSlotCount(self, slotNumber, count):
  2011.   wndMgr.SetSlotCount(self.hWnd, slotNumber, count)
  2012.  
  2013.  def SetSlotCountNew(self, slotNumber, grade, count):
  2014.   wndMgr.SetSlotCountNew(self.hWnd, slotNumber, grade, count)
  2015.  
  2016.  def SetItemSlot(self, renderingSlotNumber, ItemIndex, ItemCount = 0, diffuseColor = (1.0, 1.0, 1.0, 1.0)):
  2017.   if 0 == ItemIndex or None == ItemIndex:
  2018.    wndMgr.ClearSlot(self.hWnd, renderingSlotNumber)
  2019.    return
  2020.  
  2021.   item.SelectItem(ItemIndex)
  2022.   itemIcon = item.GetIconImage()
  2023.  
  2024.   item.SelectItem(ItemIndex)
  2025.   (width, height) = item.GetItemSize()
  2026.  
  2027.   wndMgr.SetSlot(self.hWnd, renderingSlotNumber, ItemIndex, width, height, itemIcon, diffuseColor)
  2028.   wndMgr.SetSlotCount(self.hWnd, renderingSlotNumber, ItemCount)
  2029.  
  2030.  def SetSkillSlot(self, renderingSlotNumber, skillIndex, skillLevel):
  2031.  
  2032.   skillIcon = skill.GetIconImage(skillIndex)
  2033.  
  2034.   if 0 == skillIcon:
  2035.    wndMgr.ClearSlot(self.hWnd, renderingSlotNumber)
  2036.    return
  2037.  
  2038.   wndMgr.SetSlot(self.hWnd, renderingSlotNumber, skillIndex, 1, 1, skillIcon)
  2039.   wndMgr.SetSlotCount(self.hWnd, renderingSlotNumber, skillLevel)
  2040.  
  2041.  def SetSkillSlotNew(self, renderingSlotNumber, skillIndex, skillGrade, skillLevel):
  2042.  
  2043.   skillIcon = skill.GetIconImageNew(skillIndex, skillGrade)
  2044.  
  2045.   if 0 == skillIcon:
  2046.    wndMgr.ClearSlot(self.hWnd, renderingSlotNumber)
  2047.    return
  2048.  
  2049.   wndMgr.SetSlot(self.hWnd, renderingSlotNumber, skillIndex, 1, 1, skillIcon)
  2050.  
  2051.  def SetEmotionSlot(self, renderingSlotNumber, emotionIndex):
  2052.   import player
  2053.   icon = player.GetEmotionIconImage(emotionIndex)
  2054.  
  2055.   if 0 == icon:
  2056.    wndMgr.ClearSlot(self.hWnd, renderingSlotNumber)
  2057.    return
  2058.  
  2059.   wndMgr.SetSlot(self.hWnd, renderingSlotNumber, emotionIndex, 1, 1, icon)
  2060.  
  2061.  ## Event
  2062.  def OnSelectEmptySlot(self, slotNumber):
  2063.   if self.eventSelectEmptySlot:
  2064.    self.eventSelectEmptySlot(slotNumber)
  2065.  
  2066.  def OnSelectItemSlot(self, slotNumber):
  2067.   if self.eventSelectItemSlot:
  2068.    self.eventSelectItemSlot(slotNumber)
  2069.  
  2070.  def OnUnselectEmptySlot(self, slotNumber):
  2071.   if self.eventUnselectEmptySlot:
  2072.    self.eventUnselectEmptySlot(slotNumber)
  2073.  
  2074.  def OnUnselectItemSlot(self, slotNumber):
  2075.   if self.eventUnselectItemSlot:
  2076.    self.eventUnselectItemSlot(slotNumber)
  2077.  
  2078.  def OnUseSlot(self, slotNumber):
  2079.   if self.eventUseSlot:
  2080.    self.eventUseSlot(slotNumber)
  2081.  
  2082.  def OnOverInItem(self, slotNumber):
  2083.   if self.eventOverInItem:
  2084.    self.eventOverInItem(slotNumber)
  2085.  
  2086.  def OnOverOutItem(self):
  2087.   if self.eventOverOutItem:
  2088.    self.eventOverOutItem()
  2089.  
  2090.  def OnPressedSlotButton(self, slotNumber):
  2091.   if self.eventPressedSlotButton:
  2092.    self.eventPressedSlotButton(slotNumber)
  2093.  
  2094.  def GetStartIndex(self):
  2095.   return 0
  2096.  
  2097. class GridSlotWindow(SlotWindow):
  2098.  
  2099.  def __init__(self):
  2100.   SlotWindow.__init__(self)
  2101.  
  2102.   self.startIndex = 0
  2103.  
  2104.  def __del__(self):
  2105.   SlotWindow.__del__(self)
  2106.  
  2107.  def RegisterWindow(self, layer):
  2108.   self.hWnd = wndMgr.RegisterGridSlotWindow(self, layer)
  2109.  
  2110.  def ArrangeSlot(self, StartIndex, xCount, yCount, xSize, ySize, xBlank, yBlank):
  2111.  
  2112.   self.startIndex = StartIndex
  2113.  
  2114.   wndMgr.ArrangeSlot(self.hWnd, StartIndex, xCount, yCount, xSize, ySize, xBlank, yBlank)
  2115.   self.startIndex = StartIndex
  2116.  
  2117.  def GetStartIndex(self):
  2118.   return self.startIndex
  2119.  
  2120. class TitleBar(Window):
  2121.  
  2122.  BLOCK_WIDTH = 32
  2123.  BLOCK_HEIGHT = 23
  2124.  
  2125.  def __init__(self):
  2126.   Window.__init__(self)
  2127.   self.AddFlag("attach")
  2128.  
  2129.  def __del__(self):
  2130.   Window.__del__(self)
  2131.  
  2132.  def MakeTitleBar(self, width, color):
  2133.  
  2134.  
  2135.   width = max(64, width)
  2136.  
  2137.   imgLeft = ImageBox()
  2138.   imgCenter = ExpandedImageBox()
  2139.   imgRight = ImageBox()
  2140.   imgLeft.AddFlag("not_pick")
  2141.   imgCenter.AddFlag("not_pick")
  2142.   imgRight.AddFlag("not_pick")
  2143.   imgLeft.SetParent(self)
  2144.   imgCenter.SetParent(self)
  2145.   imgRight.SetParent(self)
  2146.  
  2147.   if localeInfo.IsARABIC():
  2148.    imgLeft.LoadImage("locale/ae/ui/pattern/titlebar_left.tga")
  2149.    imgCenter.LoadImage("locale/ae/ui/pattern/titlebar_center.tga")
  2150.    imgRight.LoadImage("locale/ae/ui/pattern/titlebar_right.tga")
  2151.   else:
  2152.    imgLeft.LoadImage("d:/ymir work/ui/pattern/titlebar_left.tga")
  2153.    imgCenter.LoadImage("d:/ymir work/ui/pattern/titlebar_center.tga")
  2154.    imgRight.LoadImage("d:/ymir work/ui/pattern/titlebar_right.tga")
  2155.  
  2156.   imgLeft.Show()
  2157.   imgCenter.Show()
  2158.   imgRight.Show()
  2159.  
  2160.   btnClose = Button()
  2161.   btnClose.SetParent(self)
  2162.   btnClose.SetUpVisual("d:/ymir work/ui/public/close_button_01.sub")
  2163.   btnClose.SetOverVisual("d:/ymir work/ui/public/close_button_02.sub")
  2164.   btnClose.SetDownVisual("d:/ymir work/ui/public/close_button_03.sub")
  2165.   btnClose.SetToolTipText(localeInfo.UI_CLOSE, 0, -23)
  2166.   btnClose.Show()
  2167.  
  2168.   self.imgLeft = imgLeft
  2169.   self.imgCenter = imgCenter
  2170.   self.imgRight = imgRight
  2171.   self.btnClose = btnClose
  2172.  
  2173.   self.SetWidth(width)
  2174.  
  2175.  def SetWidth(self, width):
  2176.   self.imgCenter.SetRenderingRect(0.0, 0.0, float((width - self.BLOCK_WIDTH*2) - self.BLOCK_WIDTH) / self.BLOCK_WIDTH, 0.0)
  2177.   self.imgCenter.SetPosition(self.BLOCK_WIDTH, 0)
  2178.   self.imgRight.SetPosition(width - self.BLOCK_WIDTH, 0)
  2179.  
  2180.   if localeInfo.IsARABIC():
  2181.    self.btnClose.SetPosition(3, 3)
  2182.   else:
  2183.    self.btnClose.SetPosition(width - self.btnClose.GetWidth() - 3, 3)
  2184.  
  2185.   self.SetSize(width, self.BLOCK_HEIGHT)
  2186.  
  2187.  def SetCloseEvent(self, event):
  2188.   self.btnClose.SetEvent(event)
  2189.  
  2190.  def CloseButtonHide(self) :
  2191.   if localeInfo.IsARABIC():
  2192.    self.imgLeft.LoadImage("d:/ymir work/ui/pattern/titlebar_right_02.tga")
  2193.    self.imgLeft.LeftRightReverse()
  2194.    self.btnClose.Hide()
  2195.   else:
  2196.    self.imgRight.LoadImage("d:/ymir work/ui/pattern/titlebar_right_02.tga")
  2197.    self.btnClose.Hide()
  2198.  
  2199. class HorizontalBar(Window):
  2200.  
  2201.  BLOCK_WIDTH = 32
  2202.  BLOCK_HEIGHT = 17
  2203.  
  2204.  def __init__(self):
  2205.   Window.__init__(self)
  2206.   self.AddFlag("attach")
  2207.  
  2208.  def __del__(self):
  2209.   Window.__del__(self)
  2210.  
  2211.  def Create(self, width):
  2212.  
  2213.   width = max(96, width)
  2214.  
  2215.   imgLeft = ImageBox()
  2216.   imgLeft.SetParent(self)
  2217.   imgLeft.AddFlag("not_pick")
  2218.   imgLeft.LoadImage("d:/ymir work/ui/pattern/horizontalbar_left.tga")
  2219.   imgLeft.Show()
  2220.  
  2221.   imgCenter = ExpandedImageBox()
  2222.   imgCenter.SetParent(self)
  2223.   imgCenter.AddFlag("not_pick")
  2224.   imgCenter.LoadImage("d:/ymir work/ui/pattern/horizontalbar_center.tga")
  2225.   imgCenter.Show()
  2226.  
  2227.   imgRight = ImageBox()
  2228.   imgRight.SetParent(self)
  2229.   imgRight.AddFlag("not_pick")
  2230.   imgRight.LoadImage("d:/ymir work/ui/pattern/horizontalbar_right.tga")
  2231.   imgRight.Show()
  2232.  
  2233.   self.imgLeft = imgLeft
  2234.   self.imgCenter = imgCenter
  2235.   self.imgRight = imgRight
  2236.   self.SetWidth(width)
  2237.  
  2238.  def SetWidth(self, width):
  2239.   self.imgCenter.SetRenderingRect(0.0, 0.0, float((width - self.BLOCK_WIDTH*2) - self.BLOCK_WIDTH) / self.BLOCK_WIDTH, 0.0)
  2240.   self.imgCenter.SetPosition(self.BLOCK_WIDTH, 0)
  2241.   self.imgRight.SetPosition(width - self.BLOCK_WIDTH, 0)
  2242.   self.SetSize(width, self.BLOCK_HEIGHT)
  2243.  
  2244. class Gauge(Window):
  2245.  
  2246.  SLOT_WIDTH = 16
  2247.  SLOT_HEIGHT = 7
  2248.  
  2249.  GAUGE_TEMPORARY_PLACE = 12
  2250.  GAUGE_WIDTH = 16
  2251.  
  2252.  def __init__(self):
  2253.   Window.__init__(self)
  2254.   self.width = 0
  2255.  def __del__(self):
  2256.   Window.__del__(self)
  2257.  
  2258.  def MakeGauge(self, width, color):
  2259.  
  2260.   self.width = max(48, width)
  2261.  
  2262.   imgSlotLeft = ImageBox()
  2263.   imgSlotLeft.SetParent(self)
  2264.   imgSlotLeft.LoadImage("d:/ymir work/ui/pattern/gauge_slot_left.tga")
  2265.   imgSlotLeft.Show()
  2266.  
  2267.   imgSlotRight = ImageBox()
  2268.   imgSlotRight.SetParent(self)
  2269.   imgSlotRight.LoadImage("d:/ymir work/ui/pattern/gauge_slot_right.tga")
  2270.   imgSlotRight.Show()
  2271.   imgSlotRight.SetPosition(width - self.SLOT_WIDTH, 0)
  2272.  
  2273.   imgSlotCenter = ExpandedImageBox()
  2274.   imgSlotCenter.SetParent(self)
  2275.   imgSlotCenter.LoadImage("d:/ymir work/ui/pattern/gauge_slot_center.tga")
  2276.   imgSlotCenter.Show()
  2277.   imgSlotCenter.SetRenderingRect(0.0, 0.0, float((width - self.SLOT_WIDTH*2) - self.SLOT_WIDTH) / self.SLOT_WIDTH, 0.0)
  2278.   imgSlotCenter.SetPosition(self.SLOT_WIDTH, 0)
  2279.  
  2280.   imgGauge = ExpandedImageBox()
  2281.   imgGauge.SetParent(self)
  2282.   imgGauge.LoadImage("d:/ymir work/ui/pattern/gauge_" + color + ".tga")
  2283.   imgGauge.Show()
  2284.   imgGauge.SetRenderingRect(0.0, 0.0, 0.0, 0.0)
  2285.   imgGauge.SetPosition(self.GAUGE_TEMPORARY_PLACE, 0)
  2286.  
  2287.   imgSlotLeft.AddFlag("attach")
  2288.   imgSlotCenter.AddFlag("attach")
  2289.   imgSlotRight.AddFlag("attach")
  2290.  
  2291.   self.imgLeft = imgSlotLeft
  2292.   self.imgCenter = imgSlotCenter
  2293.   self.imgRight = imgSlotRight
  2294.   self.imgGauge = imgGauge
  2295.  
  2296.   self.SetSize(width, self.SLOT_HEIGHT)
  2297.  
  2298.  def SetPercentage(self, curValue, maxValue):
  2299.  
  2300.   # PERCENTAGE_MAX_VALUE_ZERO_DIVISION_ERROR
  2301.   if maxValue > 0.0:
  2302.    percentage = min(1.0, float(curValue)/float(maxValue))
  2303.   else:
  2304.    percentage = 0.0
  2305.   # END_OF_PERCENTAGE_MAX_VALUE_ZERO_DIVISION_ERROR
  2306.  
  2307.   gaugeSize = -1.0 + float(self.width - self.GAUGE_TEMPORARY_PLACE*2) * percentage / self.GAUGE_WIDTH
  2308.   self.imgGauge.SetRenderingRect(0.0, 0.0, gaugeSize, 0.0)
  2309.  
  2310. class Board(Window):
  2311.  
  2312.  CORNER_WIDTH = 32
  2313.  CORNER_HEIGHT = 32
  2314.  LINE_WIDTH = 128
  2315.  LINE_HEIGHT = 128
  2316.  
  2317.  LT = 0
  2318.  LB = 1
  2319.  RT = 2
  2320.  RB = 3
  2321.  L = 0
  2322.  R = 1
  2323.  T = 2
  2324.  B = 3
  2325.  
  2326.  def __init__(self):
  2327.   Window.__init__(self)
  2328.  
  2329.   self.MakeBoard("d:/ymir work/ui/pattern/Board_Corner_", "d:/ymir work/ui/pattern/Board_Line_")
  2330.   self.MakeBase()
  2331.  
  2332.  def MakeBoard(self, cornerPath, linePath):
  2333.  
  2334.   CornerFileNames = [ cornerPath+dir+".tga" for dir in ("LeftTop", "LeftBottom", "RightTop", "RightBottom", ) ]
  2335.   LineFileNames = [ linePath+dir+".tga" for dir in ("Left", "Right", "Top", "Bottom", ) ]
  2336.   """
  2337.   CornerFileNames = (
  2338.        "d:/ymir work/ui/pattern/Board_Corner_LeftTop.tga",
  2339.        "d:/ymir work/ui/pattern/Board_Corner_LeftBottom.tga",
  2340.        "d:/ymir work/ui/pattern/Board_Corner_RightTop.tga",
  2341.        "d:/ymir work/ui/pattern/Board_Corner_RightBottom.tga",
  2342.        )
  2343.   LineFileNames = (
  2344.        "d:/ymir work/ui/pattern/Board_Line_Left.tga",
  2345.        "d:/ymir work/ui/pattern/Board_Line_Right.tga",
  2346.        "d:/ymir work/ui/pattern/Board_Line_Top.tga",
  2347.        "d:/ymir work/ui/pattern/Board_Line_Bottom.tga",
  2348.        )
  2349.   """
  2350.  
  2351.   self.Corners = []
  2352.   for fileName in CornerFileNames:
  2353.    Corner = ExpandedImageBox()
  2354.    Corner.AddFlag("not_pick")
  2355.    Corner.LoadImage(fileName)
  2356.    Corner.SetParent(self)
  2357.    Corner.SetPosition(0, 0)
  2358.    Corner.Show()
  2359.    self.Corners.append(Corner)
  2360.  
  2361.   self.Lines = []
  2362.   for fileName in LineFileNames:
  2363.    Line = ExpandedImageBox()
  2364.    Line.AddFlag("not_pick")
  2365.    Line.LoadImage(fileName)
  2366.    Line.SetParent(self)
  2367.    Line.SetPosition(0, 0)
  2368.    Line.Show()
  2369.    self.Lines.append(Line)
  2370.  
  2371.   self.Lines[self.L].SetPosition(0, self.CORNER_HEIGHT)
  2372.   self.Lines[self.T].SetPosition(self.CORNER_WIDTH, 0)
  2373.  
  2374.  def MakeBase(self):
  2375.   self.Base = ExpandedImageBox()
  2376.   self.Base.AddFlag("not_pick")
  2377.   self.Base.LoadImage("d:/ymir work/ui/pattern/Board_Base.tga")
  2378.   self.Base.SetParent(self)
  2379.   self.Base.SetPosition(self.CORNER_WIDTH, self.CORNER_HEIGHT)
  2380.   self.Base.Show()
  2381.  
  2382.  def __del__(self):
  2383.   Window.__del__(self)
  2384.  
  2385.  def SetSize(self, width, height):
  2386.  
  2387.   width = max(self.CORNER_WIDTH*2, width)
  2388.   height = max(self.CORNER_HEIGHT*2, height)
  2389.   Window.SetSize(self, width, height)
  2390.  
  2391.   self.Corners[self.LB].SetPosition(0, height - self.CORNER_HEIGHT)
  2392.   self.Corners[self.RT].SetPosition(width - self.CORNER_WIDTH, 0)
  2393.   self.Corners[self.RB].SetPosition(width - self.CORNER_WIDTH, height - self.CORNER_HEIGHT)
  2394.   self.Lines[self.R].SetPosition(width - self.CORNER_WIDTH, self.CORNER_HEIGHT)
  2395.   self.Lines[self.B].SetPosition(self.CORNER_HEIGHT, height - self.CORNER_HEIGHT)
  2396.  
  2397.   verticalShowingPercentage = float((height - self.CORNER_HEIGHT*2) - self.LINE_HEIGHT) / self.LINE_HEIGHT
  2398.   horizontalShowingPercentage = float((width - self.CORNER_WIDTH*2) - self.LINE_WIDTH) / self.LINE_WIDTH
  2399.   self.Lines[self.L].SetRenderingRect(0, 0, 0, verticalShowingPercentage)
  2400.   self.Lines[self.R].SetRenderingRect(0, 0, 0, verticalShowingPercentage)
  2401.   self.Lines[self.T].SetRenderingRect(0, 0, horizontalShowingPercentage, 0)
  2402.   self.Lines[self.B].SetRenderingRect(0, 0, horizontalShowingPercentage, 0)
  2403.  
  2404.   if self.Base:
  2405.    self.Base.SetRenderingRect(0, 0, horizontalShowingPercentage, verticalShowingPercentage)
  2406.  
  2407. class BoardWithTitleBar(Board):
  2408.  def __init__(self):
  2409.   Board.__init__(self)
  2410.  
  2411.   titleBar = TitleBar()
  2412.   titleBar.SetParent(self)
  2413.   titleBar.MakeTitleBar(0, "red")
  2414.   titleBar.SetPosition(8, 7)
  2415.   titleBar.Show()
  2416.  
  2417.   titleName = TextLine()
  2418.   titleName.SetParent(titleBar)
  2419.   titleName.SetPosition(0, 4)
  2420.   titleName.SetWindowHorizontalAlignCenter()
  2421.   titleName.SetHorizontalAlignCenter()
  2422.   titleName.Show()
  2423.  
  2424.   self.titleBar = titleBar
  2425.   self.titleName = titleName
  2426.  
  2427.   self.SetCloseEvent(self.Hide)
  2428.  
  2429.  def __del__(self):
  2430.   Board.__del__(self)
  2431.   self.titleBar = None
  2432.   self.titleName = None
  2433.  
  2434.  def SetSize(self, width, height):
  2435.   self.titleBar.SetWidth(width - 15)
  2436.   #self.pickRestrictWindow.SetSize(width, height - 30)
  2437.   Board.SetSize(self, width, height)
  2438.   self.titleName.UpdateRect()
  2439.  
  2440.  def SetTitleColor(self, color):
  2441.   self.titleName.SetPackedFontColor(color)
  2442.  
  2443.  def SetTitleName(self, name):
  2444.   self.titleName.SetText(name)
  2445.  
  2446.  def SetCloseEvent(self, event):
  2447.   self.titleBar.SetCloseEvent(event)
  2448.  
  2449. class ThinBoard(Window):
  2450.  
  2451.  CORNER_WIDTH = 16
  2452.  CORNER_HEIGHT = 16
  2453.  LINE_WIDTH = 16
  2454.  LINE_HEIGHT = 16
  2455.  BOARD_COLOR = grp.GenerateColor(0.0, 0.0, 0.0, 0.51)
  2456.  
  2457.  LT = 0
  2458.  LB = 1
  2459.  RT = 2
  2460.  RB = 3
  2461.  L = 0
  2462.  R = 1
  2463.  T = 2
  2464.  B = 3
  2465.  
  2466.  def __init__(self, layer = "UI"):
  2467.   Window.__init__(self, layer)
  2468.  
  2469.   CornerFileNames = [ "d:/ymir work/ui/pattern/ThinBoard_Corner_"+dir+".tga" for dir in ["LeftTop","LeftBottom","RightTop","RightBottom"] ]
  2470.   LineFileNames = [ "d:/ymir work/ui/pattern/ThinBoard_Line_"+dir+".tga" for dir in ["Left","Right","Top","Bottom"] ]
  2471.  
  2472.   self.Corners = []
  2473.   for fileName in CornerFileNames:
  2474.    Corner = ExpandedImageBox()
  2475.    Corner.AddFlag("attach")
  2476.    Corner.AddFlag("not_pick")
  2477.    Corner.LoadImage(fileName)
  2478.    Corner.SetParent(self)
  2479.    Corner.SetPosition(0, 0)
  2480.    Corner.Show()
  2481.    self.Corners.append(Corner)
  2482.  
  2483.   self.Lines = []
  2484.   for fileName in LineFileNames:
  2485.    Line = ExpandedImageBox()
  2486.    Line.AddFlag("attach")
  2487.    Line.AddFlag("not_pick")
  2488.    Line.LoadImage(fileName)
  2489.    Line.SetParent(self)
  2490.    Line.SetPosition(0, 0)
  2491.    Line.Show()
  2492.    self.Lines.append(Line)
  2493.  
  2494.   Base = Bar()
  2495.   Base.SetParent(self)
  2496.   Base.AddFlag("attach")
  2497.   Base.AddFlag("not_pick")
  2498.   Base.SetPosition(self.CORNER_WIDTH, self.CORNER_HEIGHT)
  2499.   Base.SetColor(self.BOARD_COLOR)
  2500.   Base.Show()
  2501.   self.Base = Base
  2502.  
  2503.   self.Lines[self.L].SetPosition(0, self.CORNER_HEIGHT)
  2504.   self.Lines[self.T].SetPosition(self.CORNER_WIDTH, 0)
  2505.  
  2506.  def __del__(self):
  2507.   Window.__del__(self)
  2508.  
  2509.  def SetSize(self, width, height):
  2510.  
  2511.   width = max(self.CORNER_WIDTH*2, width)
  2512.   height = max(self.CORNER_HEIGHT*2, height)
  2513.   Window.SetSize(self, width, height)
  2514.  
  2515.   self.Corners[self.LB].SetPosition(0, height - self.CORNER_HEIGHT)
  2516.   self.Corners[self.RT].SetPosition(width - self.CORNER_WIDTH, 0)
  2517.   self.Corners[self.RB].SetPosition(width - self.CORNER_WIDTH, height - self.CORNER_HEIGHT)
  2518.   self.Lines[self.R].SetPosition(width - self.CORNER_WIDTH, self.CORNER_HEIGHT)
  2519.   self.Lines[self.B].SetPosition(self.CORNER_HEIGHT, height - self.CORNER_HEIGHT)
  2520.  
  2521.   verticalShowingPercentage = float((height - self.CORNER_HEIGHT*2) - self.LINE_HEIGHT) / self.LINE_HEIGHT
  2522.   horizontalShowingPercentage = float((width - self.CORNER_WIDTH*2) - self.LINE_WIDTH) / self.LINE_WIDTH
  2523.   self.Lines[self.L].SetRenderingRect(0, 0, 0, verticalShowingPercentage)
  2524.   self.Lines[self.R].SetRenderingRect(0, 0, 0, verticalShowingPercentage)
  2525.   self.Lines[self.T].SetRenderingRect(0, 0, horizontalShowingPercentage, 0)
  2526.   self.Lines[self.B].SetRenderingRect(0, 0, horizontalShowingPercentage, 0)
  2527.   self.Base.SetSize(width - self.CORNER_WIDTH*2, height - self.CORNER_HEIGHT*2)
  2528.  
  2529.  def ShowInternal(self):
  2530.   self.Base.Show()
  2531.   for wnd in self.Lines:
  2532.    wnd.Show()
  2533.   for wnd in self.Corners:
  2534.    wnd.Show()
  2535.  
  2536.  def HideInternal(self):
  2537.   self.Base.Hide()
  2538.   for wnd in self.Lines:
  2539.    wnd.Hide()
  2540.   for wnd in self.Corners:
  2541.    wnd.Hide()
  2542.  
  2543. class ThinBoardGold(Window):
  2544.  CORNER_WIDTH = 16
  2545.  CORNER_HEIGHT = 16
  2546.  LINE_WIDTH = 16
  2547.  LINE_HEIGHT = 16
  2548.  
  2549.  LT = 0
  2550.  LB = 1
  2551.  RT = 2
  2552.  RB = 3
  2553.  L = 0
  2554.  R = 1
  2555.  T = 2
  2556.  B = 3
  2557.  
  2558.  def __init__(self, layer = "UI"):
  2559.   Window.__init__(self, layer)
  2560.  
  2561.   CornerFileNames = [ "d:/ymir work/ui/pattern/thinboardgold/ThinBoard_Corner_"+dir+"_Gold.tga" for dir in ["LeftTop","LeftBottom","RightTop","RightBottom"] ]
  2562.   LineFileNames = [ "d:/ymir work/ui/pattern/thinboardgold/ThinBoard_Line_"+dir+"_Gold.tga" for dir in ["Left","Right","Top","Bottom"] ]
  2563.  
  2564.   self.MakeBase()
  2565.  
  2566.   self.Corners = []
  2567.   for fileName in CornerFileNames:
  2568.    Corner = ExpandedImageBox()
  2569.    Corner.AddFlag("attach")
  2570.    Corner.AddFlag("not_pick")
  2571.    Corner.LoadImage(fileName)
  2572.    Corner.SetParent(self)
  2573.    Corner.SetPosition(0, 0)
  2574.    Corner.Show()
  2575.    self.Corners.append(Corner)
  2576.  
  2577.   self.Lines = []
  2578.   for fileName in LineFileNames:
  2579.    Line = ExpandedImageBox()
  2580.    Line.AddFlag("attach")
  2581.    Line.AddFlag("not_pick")
  2582.    Line.LoadImage(fileName)
  2583.    Line.SetParent(self)
  2584.    Line.SetPosition(0, 0)
  2585.    Line.Show()
  2586.    self.Lines.append(Line)
  2587.  
  2588.   self.Lines[self.L].SetPosition(0, self.CORNER_HEIGHT)
  2589.   self.Lines[self.T].SetPosition(self.CORNER_WIDTH, 0)
  2590.  
  2591.  def __del__(self):
  2592.   Window.__del__(self)
  2593.  
  2594.  def SetSize(self, width, height):
  2595.  
  2596.   width = max(self.CORNER_WIDTH*2, width)
  2597.   height = max(self.CORNER_HEIGHT*2, height)
  2598.   Window.SetSize(self, width, height)
  2599.  
  2600.   self.Corners[self.LB].SetPosition(0, height - self.CORNER_HEIGHT)
  2601.   self.Corners[self.RT].SetPosition(width - self.CORNER_WIDTH, 0)
  2602.   self.Corners[self.RB].SetPosition(width - self.CORNER_WIDTH, height - self.CORNER_HEIGHT)
  2603.   self.Lines[self.R].SetPosition(width - self.CORNER_WIDTH, self.CORNER_HEIGHT)
  2604.   self.Lines[self.B].SetPosition(self.CORNER_HEIGHT, height - self.CORNER_HEIGHT)
  2605.  
  2606.   verticalShowingPercentage = float((height - self.CORNER_HEIGHT*2) - self.LINE_HEIGHT) / self.LINE_HEIGHT
  2607.   horizontalShowingPercentage = float((width - self.CORNER_WIDTH*2) - self.LINE_WIDTH) / self.LINE_WIDTH
  2608.  
  2609.   self.Lines[self.L].SetRenderingRect(0, 0, 0, verticalShowingPercentage)
  2610.   self.Lines[self.R].SetRenderingRect(0, 0, 0, verticalShowingPercentage)
  2611.   self.Lines[self.T].SetRenderingRect(0, 0, horizontalShowingPercentage, 0)
  2612.   self.Lines[self.B].SetRenderingRect(0, 0, horizontalShowingPercentage, 0)
  2613.  
  2614.   #self.Base.GetWidth()
  2615.   #self.Base.GetHeight()
  2616.   """
  2617.    Defalt Width : 128, Height : 128
  2618.    0.0 > 128, 1.0 > 256
  2619.   """
  2620.   if self.Base:
  2621.    self.Base.SetRenderingRect(0, 0, (float(width)-32)/float(self.Base.GetWidth()) - 1.0, (float(height)-32)/float(self.Base.GetHeight()) - 1.0)
  2622.  
  2623.  def MakeBase(self):
  2624.   self.Base = ExpandedImageBox()
  2625.   self.Base.AddFlag("not_pick")
  2626.   self.Base.LoadImage("d:/ymir work/ui/pattern/Board_Base.tga")
  2627.   self.Base.SetParent(self)
  2628.   self.Base.SetPosition(16, 16)
  2629.   self.Base.SetAlpha(0.8)
  2630.   self.Base.Show()
  2631.  
  2632.  def ShowInternal(self):
  2633.   self.Base.Show()
  2634.   for wnd in self.Lines:
  2635.    wnd.Show()
  2636.   for wnd in self.Corners:
  2637.    wnd.Show()
  2638.  
  2639.  def HideInternal(self):
  2640.   self.Base.Hide()
  2641.   for wnd in self.Lines:
  2642.    wnd.Hide()
  2643.   for wnd in self.Corners:
  2644.    wnd.Hide()
  2645.  
  2646. class ThinBoardCircle(Window):
  2647.  CORNER_WIDTH = 4
  2648.  CORNER_HEIGHT = 4
  2649.  LINE_WIDTH = 4
  2650.  LINE_HEIGHT = 4
  2651.  BOARD_COLOR = grp.GenerateColor(0.0, 0.0, 0.0, 1.0)
  2652.  
  2653.  LT = 0
  2654.  LB = 1
  2655.  RT = 2
  2656.  RB = 3
  2657.  L = 0
  2658.  R = 1
  2659.  T = 2
  2660.  B = 3
  2661.  
  2662.  def __init__(self, layer = "UI"):
  2663.   Window.__init__(self, layer)
  2664.  
  2665.   CornerFileNames = [ "d:/ymir work/ui/pattern/thinboardcircle/ThinBoard_Corner_"+dir+"_Circle.tga" for dir in ["LeftTop","LeftBottom","RightTop","RightBottom"] ]
  2666.   LineFileNames = [ "d:/ymir work/ui/pattern/thinboardcircle/ThinBoard_Line_"+dir+"_Circle.tga" for dir in ["Left","Right","Top","Bottom"] ]
  2667.  
  2668.   self.Corners = []
  2669.   for fileName in CornerFileNames:
  2670.    Corner = ExpandedImageBox()
  2671.    Corner.AddFlag("attach")
  2672.    Corner.AddFlag("not_pick")
  2673.    Corner.LoadImage(fileName)
  2674.    Corner.SetParent(self)
  2675.    Corner.SetPosition(0, 0)
  2676.    Corner.Show()
  2677.    self.Corners.append(Corner)
  2678.  
  2679.   self.Lines = []
  2680.   for fileName in LineFileNames:
  2681.    Line = ExpandedImageBox()
  2682.    Line.AddFlag("attach")
  2683.    Line.AddFlag("not_pick")
  2684.    Line.LoadImage(fileName)
  2685.    Line.SetParent(self)
  2686.    Line.SetPosition(0, 0)
  2687.    Line.Show()
  2688.    self.Lines.append(Line)
  2689.  
  2690.   Base = Bar()
  2691.   Base.SetParent(self)
  2692.   Base.AddFlag("attach")
  2693.   Base.AddFlag("not_pick")
  2694.   Base.SetPosition(self.CORNER_WIDTH, self.CORNER_HEIGHT)
  2695.   Base.SetColor(self.BOARD_COLOR)
  2696.   Base.Show()
  2697.   self.Base = Base
  2698.  
  2699.   self.Lines[self.L].SetPosition(0, self.CORNER_HEIGHT)
  2700.   self.Lines[self.T].SetPosition(self.CORNER_WIDTH, 0)
  2701.  
  2702.  def __del__(self):
  2703.   Window.__del__(self)
  2704.  
  2705.  def SetSize(self, width, height):
  2706.  
  2707.   width = max(self.CORNER_WIDTH*2, width)
  2708.   height = max(self.CORNER_HEIGHT*2, height)
  2709.   Window.SetSize(self, width, height)
  2710.  
  2711.   self.Corners[self.LB].SetPosition(0, height - self.CORNER_HEIGHT)
  2712.   self.Corners[self.RT].SetPosition(width - self.CORNER_WIDTH, 0)
  2713.   self.Corners[self.RB].SetPosition(width - self.CORNER_WIDTH, height - self.CORNER_HEIGHT)
  2714.   self.Lines[self.R].SetPosition(width - self.CORNER_WIDTH, self.CORNER_HEIGHT)
  2715.   self.Lines[self.B].SetPosition(self.CORNER_HEIGHT, height - self.CORNER_HEIGHT)
  2716.  
  2717.   verticalShowingPercentage = float((height - self.CORNER_HEIGHT*2) - self.LINE_HEIGHT) / self.LINE_HEIGHT
  2718.   horizontalShowingPercentage = float((width - self.CORNER_WIDTH*2) - self.LINE_WIDTH) / self.LINE_WIDTH
  2719.   self.Lines[self.L].SetRenderingRect(0, 0, 0, verticalShowingPercentage)
  2720.   self.Lines[self.R].SetRenderingRect(0, 0, 0, verticalShowingPercentage)
  2721.   self.Lines[self.T].SetRenderingRect(0, 0, horizontalShowingPercentage, 0)
  2722.   self.Lines[self.B].SetRenderingRect(0, 0, horizontalShowingPercentage, 0)
  2723.   self.Base.SetSize(width - self.CORNER_WIDTH*2, height - self.CORNER_HEIGHT*2)
  2724.  
  2725.  def ShowInternal(self):
  2726.   self.Base.Show()
  2727.   for wnd in self.Lines:
  2728.    wnd.Show()
  2729.   for wnd in self.Corners:
  2730.    wnd.Show()
  2731.  
  2732.  def HideInternal(self):
  2733.   self.Base.Hide()
  2734.   for wnd in self.Lines:
  2735.    wnd.Hide()
  2736.   for wnd in self.Corners:
  2737.    wnd.Hide()
  2738.  
  2739. class ScrollBar(Window):
  2740.  
  2741.  SCROLLBAR_WIDTH = 17
  2742.  SCROLLBAR_MIDDLE_HEIGHT = 9
  2743.  SCROLLBAR_BUTTON_WIDTH = 17
  2744.  SCROLLBAR_BUTTON_HEIGHT = 17
  2745.  MIDDLE_BAR_POS = 5
  2746.  MIDDLE_BAR_UPPER_PLACE = 3
  2747.  MIDDLE_BAR_DOWNER_PLACE = 4
  2748.  TEMP_SPACE = MIDDLE_BAR_UPPER_PLACE + MIDDLE_BAR_DOWNER_PLACE
  2749.  
  2750.  if app.__BL_SMOOTH_SCROLL__:
  2751.   SMOOTH_RATIO = 10.0 # UPPER = SLOWER
  2752.  
  2753.  class MiddleBar(DragButton):
  2754.   def __init__(self):
  2755.    DragButton.__init__(self)
  2756.    self.AddFlag("movable")
  2757.    #self.AddFlag("restrict_x")
  2758.  
  2759.   def MakeImage(self):
  2760.    top = ImageBox()
  2761.    top.SetParent(self)
  2762.    top.LoadImage("d:/ymir work/ui/pattern/ScrollBar_Top.tga")
  2763.    top.SetPosition(0, 0)
  2764.    top.AddFlag("not_pick")
  2765.    top.Show()
  2766.    bottom = ImageBox()
  2767.    bottom.SetParent(self)
  2768.    bottom.LoadImage("d:/ymir work/ui/pattern/ScrollBar_Bottom.tga")
  2769.    bottom.AddFlag("not_pick")
  2770.    bottom.Show()
  2771.  
  2772.    middle = ExpandedImageBox()
  2773.    middle.SetParent(self)
  2774.    middle.LoadImage("d:/ymir work/ui/pattern/ScrollBar_Middle.tga")
  2775.    middle.SetPosition(0, 4)
  2776.    middle.AddFlag("not_pick")
  2777.    middle.Show()
  2778.  
  2779.    self.top = top
  2780.    self.bottom = bottom
  2781.    self.middle = middle
  2782.  
  2783.   def SetSize(self, height):
  2784.    height = max(12, height)
  2785.    DragButton.SetSize(self, 10, height)
  2786.    self.bottom.SetPosition(0, height-4)
  2787.  
  2788.    height -= 4*3
  2789.    self.middle.SetRenderingRect(0, 0, 0, float(height)/4.0)
  2790.  
  2791.  def __init__(self):
  2792.   Window.__init__(self)
  2793.  
  2794.   self.pageSize = 1
  2795.   self.curPos = 0.0
  2796.   self.eventScroll = lambda *arg: None
  2797.   self.lockFlag = False
  2798.   self.scrollStep = 0.20
  2799.  
  2800.   if app.__BL_SMOOTH_SCROLL__:
  2801.    self.smooth_mode = False
  2802.    self.actual_pos = 0.0
  2803.    self.target_pos = 0.0
  2804.  
  2805.   self.CreateScrollBar()
  2806.  
  2807.  def __del__(self):
  2808.   Window.__del__(self)
  2809.  
  2810.  def CreateScrollBar(self):
  2811.   barSlot = Bar3D()
  2812.   barSlot.SetParent(self)
  2813.   barSlot.AddFlag("not_pick")
  2814.   barSlot.Show()
  2815.  
  2816.   middleBar = self.MiddleBar()
  2817.   middleBar.SetParent(self)
  2818.   middleBar.SetMoveEvent(__mem_func__(self.OnMove))
  2819.   middleBar.Show()
  2820.   middleBar.MakeImage()
  2821.   middleBar.SetSize(12)
  2822.  
  2823.   upButton = Button()
  2824.   upButton.SetParent(self)
  2825.   upButton.SetEvent(__mem_func__(self.OnUp))
  2826.   upButton.SetUpVisual("d:/ymir work/ui/public/scrollbar_up_button_01.sub")
  2827.   upButton.SetOverVisual("d:/ymir work/ui/public/scrollbar_up_button_02.sub")
  2828.   upButton.SetDownVisual("d:/ymir work/ui/public/scrollbar_up_button_03.sub")
  2829.   upButton.Show()
  2830.  
  2831.   downButton = Button()
  2832.   downButton.SetParent(self)
  2833.   downButton.SetEvent(__mem_func__(self.OnDown))
  2834.   downButton.SetUpVisual("d:/ymir work/ui/public/scrollbar_down_button_01.sub")
  2835.   downButton.SetOverVisual("d:/ymir work/ui/public/scrollbar_down_button_02.sub")
  2836.   downButton.SetDownVisual("d:/ymir work/ui/public/scrollbar_down_button_03.sub")
  2837.   downButton.Show()
  2838.  
  2839.   self.upButton = upButton
  2840.   self.downButton = downButton
  2841.   self.middleBar = middleBar
  2842.   self.barSlot = barSlot
  2843.  
  2844.   self.SCROLLBAR_WIDTH = self.upButton.GetWidth()
  2845.   self.SCROLLBAR_MIDDLE_HEIGHT = self.middleBar.GetHeight()
  2846.   self.SCROLLBAR_BUTTON_WIDTH = self.upButton.GetWidth()
  2847.   self.SCROLLBAR_BUTTON_HEIGHT = self.upButton.GetHeight()
  2848.  
  2849.   # if app.ENABLE_MOUSEWHEEL_EVENT:
  2850.   #  self.upButton.SetMouseWheelEvent(self.OnMouseWheel_ScrollBar)
  2851.   #  self.downButton.SetMouseWheelEvent(self.OnMouseWheel_ScrollBar)
  2852.   #  self.middleBar.SetMouseWheelEvent(self.OnMouseWheel_ScrollBar)
  2853.   #  self.barSlot.SetMouseWheelEvent(self.OnMouseWheel_ScrollBar)
  2854.   #  self.SetMouseWheelEvent(self.OnMouseWheel_ScrollBar)
  2855.  
  2856.  
  2857.  if app.ENABLE_MOUSEWHEEL_EVENT:
  2858.   def OnMouseWheel(self, delta):
  2859.    if delta > 0:
  2860.     self.SetPos(self.curPos - (self.scrollStep/4))
  2861.     return True
  2862.    elif delta < 0:
  2863.     self.SetPos(self.curPos + (self.scrollStep/4))
  2864.     return True
  2865.    return False
  2866.  
  2867.  @WindowDestroy
  2868.  def Destroy(self):
  2869.   self.middleBar = None
  2870.    self.upButt
  2871.    self.downButt
  2872.   self.eventScroll = lambda *arg: None
  2873.  
  2874.  def SetScrollEvent(self, event):
  2875.   self.eventScroll = event
  2876.  
  2877.  def SetMiddleBarSize(self, pageScale):
  2878.   realHeight = self.GetHeight() - self.SCROLLBAR_BUTTON_HEIGHT*2
  2879.   self.SCROLLBAR_MIDDLE_HEIGHT = int(pageScale * float(realHeight))
  2880.   self.middleBar.SetSize(self.SCROLLBAR_MIDDLE_HEIGHT)
  2881.   self.pageSize = (self.GetHeight() - self.SCROLLBAR_BUTTON_HEIGHT*2) - self.SCROLLBAR_MIDDLE_HEIGHT - (self.TEMP_SPACE)
  2882.  
  2883.  def SetScrollBarSize(self, height):
  2884.   self.pageSize = (height - self.SCROLLBAR_BUTTON_HEIGHT*2) - self.SCROLLBAR_MIDDLE_HEIGHT - (self.TEMP_SPACE)
  2885.   self.SetSize(self.SCROLLBAR_WIDTH, height)
  2886.   self.upButton.SetPosition(0, 0)
  2887.   self.downButton.SetPosition(0, height - self.SCROLLBAR_BUTTON_HEIGHT)
  2888.   self.middleBar.SetRestrictMovementArea(self.MIDDLE_BAR_POS, self.SCROLLBAR_BUTTON_HEIGHT + self.MIDDLE_BAR_UPPER_PLACE, self.MIDDLE_BAR_POS+2, height - self.SCROLLBAR_BUTTON_HEIGHT*2 - self.TEMP_SPACE)
  2889.   self.middleBar.SetPosition(self.MIDDLE_BAR_POS, 0)
  2890.  
  2891.   self.UpdateBarSlot()
  2892.  
  2893.  def UpdateBarSlot(self):
  2894.   self.barSlot.SetPosition(0, self.SCROLLBAR_BUTTON_HEIGHT)
  2895.   self.barSlot.SetSize(self.GetWidth() - 2, self.GetHeight() - self.SCROLLBAR_BUTTON_HEIGHT*2 - 2)
  2896.  
  2897.  def GetPos(self):
  2898.   return self.curPos
  2899.  
  2900.  def SetPos(self, pos):
  2901.   pos = max(0.0, pos)
  2902.   pos = min(1.0, pos)
  2903.  
  2904.   newPos = float(self.pageSize) * pos
  2905.   if app.BL_MAILBOX:
  2906.    self.middleBar.SetPosition(self.MIDDLE_BAR_POS, round(float(newPos) + self.SCROLLBAR_BUTTON_HEIGHT + self.MIDDLE_BAR_UPPER_PLACE) )
  2907.   else:  
  2908.    self.middleBar.SetPosition(self.MIDDLE_BAR_POS, int(newPos) + self.SCROLLBAR_BUTTON_HEIGHT + self.MIDDLE_BAR_UPPER_PLACE)
  2909.   self.OnMove()
  2910.  
  2911.  def SetScrollStep(self, step):
  2912.   self.scrollStep = step
  2913.  
  2914.  def GetScrollStep(self):
  2915.   return self.scrollStep
  2916.  
  2917.  def OnUp(self):
  2918.   if app.__BL_SMOOTH_SCROLL__ and self.smooth_mode:
  2919.    self.actual_pos = min(1.0, max(0.0, self.curPos))
  2920.    self.target_pos = min(1.0, max(0.0, self.curPos-self.scrollStep))
  2921.   else:
  2922.    self.SetPos(self.curPos-self.scrollStep)
  2923.  
  2924.  def OnDown(self):
  2925.   if app.__BL_SMOOTH_SCROLL__ and self.smooth_mode:
  2926.    self.actual_pos = min(1.0, max(0.0, self.curPos))
  2927.    self.target_pos = min(1.0, max(0.0, self.curPos+self.scrollStep))
  2928.   else:
  2929.    self.SetPos(self.curPos+self.scrollStep)
  2930.  
  2931.  def OnMove(self):
  2932.  
  2933.   if self.lockFlag:
  2934.    return
  2935.  
  2936.   if 0 == self.pageSize:
  2937.    return
  2938.  
  2939.   (xLocal, yLocal) = self.middleBar.GetLocalPosition()
  2940.   self.curPos = float(yLocal - self.SCROLLBAR_BUTTON_HEIGHT - self.MIDDLE_BAR_UPPER_PLACE) / float(self.pageSize)
  2941.  
  2942.   self.eventScroll()
  2943.  
  2944.  def OnMouseLeftButtonDown(self):
  2945.   (xMouseLocalPosition, yMouseLocalPosition) = self.GetMouseLocalPosition()
  2946.   pickedPos = yMouseLocalPosition - self.SCROLLBAR_BUTTON_HEIGHT - self.SCROLLBAR_MIDDLE_HEIGHT/2
  2947.   newPos = float(pickedPos) / float(self.pageSize)
  2948.   if app.__BL_SMOOTH_SCROLL__ and self.smooth_mode:
  2949.    self.actual_pos = min(1.0, max(0.0, self.curPos))
  2950.    self.target_pos = min(1.0, max(0.0, newPos))
  2951.   else:
  2952.    self.SetPos(newPos)
  2953.  
  2954.  def LockScroll(self):
  2955.   self.lockFlag = True
  2956.  
  2957.  def UnlockScroll(self):
  2958.   self.lockFlag = False
  2959.  
  2960.  if app.BL_MAILBOX:
  2961.   def SetUpButtonSizeRefresh(self):
  2962.    self.SCROLLBAR_WIDTH   = self.upButton.GetWidth()
  2963.     self.SCROLLBAR_BUTT
  2964.     self.SCROLLBAR_BUTT
  2965.  
  2966.   def SetUpButtonUpVisual(self, img_path):
  2967.    if self.upButton:
  2968.     self.upButton.SetUpVisual( img_path )
  2969.   def SetUpButtonOverVisual(self, img_path):
  2970.    if self.upButton:
  2971.     self.upButton.SetOverVisual( img_path )
  2972.   def SetUpButtonDownVisual(self, img_path):
  2973.    if self.upButton:
  2974.     self.upButton.SetDownVisual( img_path )
  2975.   def SetDownButtonUpVisual(self, img_path):
  2976.    if self.downButton:
  2977.     self.downButton.SetUpVisual( img_path )
  2978.   def SetDownButtonOverVisual(self, img_path):
  2979.    if self.downButton:
  2980.     self.downButton.SetOverVisual( img_path )
  2981.   def SetDownButtonDownVisual(self, img_path):
  2982.    if self.downButton:
  2983.     self.downButton.SetDownVisual( img_path )
  2984.  
  2985.  if app.__BL_SMOOTH_SCROLL__:
  2986.   def EnableSmoothMode(self):
  2987.    self.smooth_mode = True
  2988.  
  2989.   def OnUpdate(self):
  2990.    if not self.smooth_mode:
  2991.     return
  2992.    
  2993.    if self.lockFlag:
  2994.     return
  2995.    
  2996.    if 0 == self.pageSize:
  2997.     return
  2998.    
  2999.    if self.actual_pos == self.target_pos:
  3000.     return
  3001.  
  3002.    distance = abs(self.actual_pos - self.target_pos)
  3003.    smooth_step = max(distance / ScrollBar.SMOOTH_RATIO, 0.005)
  3004.  
  3005.    if self.actual_pos < self.target_pos:
  3006.     self.actual_pos = min(self.actual_pos + smooth_step, self.target_pos)
  3007.    elif self.actual_pos > self.target_pos:
  3008.     self.actual_pos = max(self.actual_pos - smooth_step, self.target_pos)
  3009.    
  3010.    self.SetPos(self.actual_pos)
  3011.  
  3012. class ThinScrollBar(ScrollBar):
  3013.  
  3014.  def CreateScrollBar(self):
  3015.   middleBar = self.MiddleBar()
  3016.   middleBar.SetParent(self)
  3017.   middleBar.SetMoveEvent(__mem_func__(self.OnMove))
  3018.   middleBar.Show()
  3019.   middleBar.SetUpVisual("d:/ymir work/ui/public/scrollbar_thin_middle_button_01.sub")
  3020.   middleBar.SetOverVisual("d:/ymir work/ui/public/scrollbar_thin_middle_button_02.sub")
  3021.   middleBar.SetDownVisual("d:/ymir work/ui/public/scrollbar_thin_middle_button_03.sub")
  3022.  
  3023.   upButton = Button()
  3024.   upButton.SetParent(self)
  3025.   upButton.SetUpVisual("d:/ymir work/ui/public/scrollbar_thin_up_button_01.sub")
  3026.   upButton.SetOverVisual("d:/ymir work/ui/public/scrollbar_thin_up_button_02.sub")
  3027.   upButton.SetDownVisual("d:/ymir work/ui/public/scrollbar_thin_up_button_03.sub")
  3028.   upButton.SetEvent(__mem_func__(self.OnUp))
  3029.   upButton.Show()
  3030.  
  3031.   downButton = Button()
  3032.   downButton.SetParent(self)
  3033.   downButton.SetUpVisual("d:/ymir work/ui/public/scrollbar_thin_down_button_01.sub")
  3034.   downButton.SetOverVisual("d:/ymir work/ui/public/scrollbar_thin_down_button_02.sub")
  3035.   downButton.SetDownVisual("d:/ymir work/ui/public/scrollbar_thin_down_button_03.sub")
  3036.   downButton.SetEvent(__mem_func__(self.OnDown))
  3037.   downButton.Show()
  3038.  
  3039.   self.middleBar = middleBar
  3040.   self.upButton = upButton
  3041.   self.downButton = downButton
  3042.  
  3043.   self.SCROLLBAR_WIDTH = self.upButton.GetWidth()
  3044.   self.SCROLLBAR_MIDDLE_HEIGHT = self.middleBar.GetHeight()
  3045.   self.SCROLLBAR_BUTTON_WIDTH = self.upButton.GetWidth()
  3046.   self.SCROLLBAR_BUTTON_HEIGHT = self.upButton.GetHeight()
  3047.   self.MIDDLE_BAR_POS = 0
  3048.   self.MIDDLE_BAR_UPPER_PLACE = 0
  3049.   self.MIDDLE_BAR_DOWNER_PLACE = 0
  3050.   self.TEMP_SPACE = 0
  3051.  
  3052.  def UpdateBarSlot(self):
  3053.   pass
  3054.  
  3055. class SmallThinScrollBar(ScrollBar):
  3056.  
  3057.  def CreateScrollBar(self):
  3058.   middleBar = self.MiddleBar()
  3059.   middleBar.SetParent(self)
  3060.   middleBar.SetMoveEvent(__mem_func__(self.OnMove))
  3061.   middleBar.Show()
  3062.   middleBar.SetUpVisual("d:/ymir work/ui/public/scrollbar_small_thin_middle_button_01.sub")
  3063.   middleBar.SetOverVisual("d:/ymir work/ui/public/scrollbar_small_thin_middle_button_01.sub")
  3064.   middleBar.SetDownVisual("d:/ymir work/ui/public/scrollbar_small_thin_middle_button_01.sub")
  3065.  
  3066.   upButton = Button()
  3067.   upButton.SetParent(self)
  3068.   upButton.SetUpVisual("d:/ymir work/ui/public/scrollbar_small_thin_up_button_01.sub")
  3069.   upButton.SetOverVisual("d:/ymir work/ui/public/scrollbar_small_thin_up_button_02.sub")
  3070.   upButton.SetDownVisual("d:/ymir work/ui/public/scrollbar_small_thin_up_button_03.sub")
  3071.   upButton.SetEvent(__mem_func__(self.OnUp))
  3072.   upButton.Show()
  3073.  
  3074.   downButton = Button()
  3075.   downButton.SetParent(self)
  3076.   downButton.SetUpVisual("d:/ymir work/ui/public/scrollbar_small_thin_down_button_01.sub")
  3077.   downButton.SetOverVisual("d:/ymir work/ui/public/scrollbar_small_thin_down_button_02.sub")
  3078.   downButton.SetDownVisual("d:/ymir work/ui/public/scrollbar_small_thin_down_button_03.sub")
  3079.   downButton.SetEvent(__mem_func__(self.OnDown))
  3080.   downButton.Show()
  3081.  
  3082.   self.middleBar = middleBar
  3083.   self.upButton = upButton
  3084.   self.downButton = downButton
  3085.  
  3086.   self.SCROLLBAR_WIDTH = self.upButton.GetWidth()
  3087.   self.SCROLLBAR_MIDDLE_HEIGHT = self.middleBar.GetHeight()
  3088.   self.SCROLLBAR_BUTTON_WIDTH = self.upButton.GetWidth()
  3089.   self.SCROLLBAR_BUTTON_HEIGHT = self.upButton.GetHeight()
  3090.   self.MIDDLE_BAR_POS = 0
  3091.   self.MIDDLE_BAR_UPPER_PLACE = 0
  3092.   self.MIDDLE_BAR_DOWNER_PLACE = 0
  3093.   self.TEMP_SPACE = 0
  3094.  
  3095.   # if app.ENABLE_MOUSEWHEEL_EVENT:
  3096.   #  self.middleBar.SetMouseWheelEvent(self.OnMouseWheel_ScrollBar)
  3097.   #  self.upButton.SetMouseWheelEvent(self.OnMouseWheel_ScrollBar)
  3098.   #  self.downButton.SetMouseWheelEvent(self.OnMouseWheel_ScrollBar)
  3099.   #  self.SetMouseWheelEvent(self.OnMouseWheel_ScrollBar)
  3100.  
  3101.  def UpdateBarSlot(self):
  3102.   pass
  3103.  
  3104. class SliderBar(Window):
  3105.  
  3106.  def __init__(self):
  3107.   Window.__init__(self)
  3108.  
  3109.   self.curPos = 1.0
  3110.   self.pageSize = 1.0
  3111.   self.eventChange = None
  3112.  
  3113.   self.__CreateBackGroundImage()
  3114.   self.__CreateCursor()
  3115.  
  3116.  def __del__(self):
  3117.   Window.__del__(self)
  3118.  
  3119.  def __CreateBackGroundImage(self):
  3120.   img = ImageBox()
  3121.   img.SetParent(self)
  3122.   img.LoadImage("d:/ymir work/ui/game/windows/sliderbar.sub")
  3123.   img.Show()
  3124.   self.backGroundImage = img
  3125.  
  3126.   ##
  3127.   self.SetSize(self.backGroundImage.GetWidth(), self.backGroundImage.GetHeight())
  3128.  
  3129.  def __CreateCursor(self):
  3130.   cursor = DragButton()
  3131.   cursor.AddFlag("movable")
  3132.   cursor.AddFlag("restrict_y")
  3133.   cursor.SetParent(self)
  3134.   cursor.SetMoveEvent(__mem_func__(self.__OnMove))
  3135.   cursor.SetUpVisual("d:/ymir work/ui/game/windows/sliderbar_cursor.sub")
  3136.   cursor.SetOverVisual("d:/ymir work/ui/game/windows/sliderbar_cursor.sub")
  3137.   cursor.SetDownVisual("d:/ymir work/ui/game/windows/sliderbar_cursor.sub")
  3138.   cursor.Show()
  3139.   self.cursor = cursor
  3140.  
  3141.   ##
  3142.   self.cursor.SetRestrictMovementArea(0, 0, self.backGroundImage.GetWidth(), 0)
  3143.   self.pageSize = self.backGroundImage.GetWidth() - self.cursor.GetWidth()
  3144.  
  3145.  def __OnMove(self):
  3146.   (xLocal, yLocal) = self.cursor.GetLocalPosition()
  3147.   self.curPos = float(xLocal) / float(self.pageSize)
  3148.  
  3149.   if self.eventChange:
  3150.    self.eventChange()
  3151.  
  3152.  def SetSliderPos(self, pos):
  3153.   self.curPos = pos
  3154.   self.cursor.SetPosition(int(self.pageSize * pos), 0)
  3155.  
  3156.  def GetSliderPos(self):
  3157.   return self.curPos
  3158.  
  3159.  def SetEvent(self, event):
  3160.   self.eventChange = event
  3161.  
  3162.  def Enable(self):
  3163.   self.cursor.Show()
  3164.  
  3165.  def Disable(self):
  3166.   self.cursor.Hide()
  3167.  
  3168. class ListBox(Window):
  3169.  
  3170.  TEMPORARY_PLACE = 3
  3171.  
  3172.  def __init__(self, layer = "UI"):
  3173.   Window.__init__(self, layer)
  3174.   self.overLine = -1
  3175.   self.selectedLine = -1
  3176.   self.width = 0
  3177.   self.height = 0
  3178.   self.stepSize = 17
  3179.   self.basePos = 0
  3180.   self.showLineCount = 0
  3181.   self.itemCenterAlign = True
  3182.   self.itemList = []
  3183.   self.keyDict = {}
  3184.   self.textDict = {}
  3185.   self.event = lambda *arg: None
  3186.  def __del__(self):
  3187.   Window.__del__(self)
  3188.  
  3189.  def SetWidth(self, width):
  3190.   self.SetSize(width, self.height)
  3191.  
  3192.  def SetSize(self, width, height):
  3193.   Window.SetSize(self, width, height)
  3194.   self.width = width
  3195.   self.height = height
  3196.  
  3197.  def SetTextCenterAlign(self, flag):
  3198.   self.itemCenterAlign = flag
  3199.  
  3200.  def SetBasePos(self, pos):
  3201.   self.basePos = pos
  3202.   self._LocateItem()
  3203.  
  3204.  def ClearItem(self):
  3205.   self.keyDict = {}
  3206.   self.textDict = {}
  3207.   self.itemList = []
  3208.   self.overLine = -1
  3209.   self.selectedLine = -1
  3210.  
  3211.  def InsertItem(self, number, text):
  3212.   self.keyDict[len(self.itemList)] = number
  3213.   self.textDict[len(self.itemList)] = text
  3214.  
  3215.   textLine = TextLine()
  3216.   textLine.SetParent(self)
  3217.   textLine.SetText(text)
  3218.   textLine.Show()
  3219.  
  3220.   if self.itemCenterAlign:
  3221.    textLine.SetWindowHorizontalAlignCenter()
  3222.    textLine.SetHorizontalAlignCenter()
  3223.  
  3224.   self.itemList.append(textLine)
  3225.  
  3226.   self._LocateItem()
  3227.  
  3228.  def ChangeItem(self, number, text):
  3229.   for key, value in self.keyDict.items():
  3230.    if value == number:
  3231.     self.textDict[key] = text
  3232.  
  3233.     if number < len(self.itemList):
  3234.      self.itemList[key].SetText(text)
  3235.  
  3236.     return
  3237.  
  3238.  def LocateItem(self):
  3239.   self._LocateItem()
  3240.  
  3241.  def _LocateItem(self):
  3242.  
  3243.   skipCount = self.basePos
  3244.   yPos = 0
  3245.   self.showLineCount = 0
  3246.  
  3247.   for textLine in self.itemList:
  3248.    textLine.Hide()
  3249.  
  3250.    if skipCount > 0:
  3251.     skipCount -= 1
  3252.     continue
  3253.  
  3254.    if localeInfo.IsARABIC():
  3255.     w, h = textLine.GetTextSize()
  3256.     textLine.SetPosition(w+10, yPos + 3)
  3257.    else:
  3258.     textLine.SetPosition(0, yPos + 3)
  3259.  
  3260.    yPos += self.stepSize
  3261.  
  3262.    if yPos <= self.GetHeight():
  3263.     self.showLineCount += 1
  3264.     textLine.Show()
  3265.  
  3266.  def ArrangeItem(self):
  3267.   self.SetSize(self.width, len(self.itemList) * self.stepSize)
  3268.   self._LocateItem()
  3269.  
  3270.  def GetViewItemCount(self):
  3271.   return int(self.GetHeight() / self.stepSize)
  3272.  
  3273.  def GetItemCount(self):
  3274.   return len(self.itemList)
  3275.  
  3276.  def SetEvent(self, event):
  3277.   self.event = event
  3278.  
  3279.  def SelectItem(self, line):
  3280.  
  3281.   if not self.keyDict.has_key(line):
  3282.    return
  3283.  
  3284.   if line == self.selectedLine:
  3285.    return
  3286.  
  3287.   self.selectedLine = line
  3288.   self.event(self.keyDict.get(line, 0), self.textDict.get(line, "None"))
  3289.  
  3290.  def GetSelectedItem(self):
  3291.   return self.keyDict.get(self.selectedLine, 0)
  3292.  
  3293.  def OnMouseLeftButtonDown(self):
  3294.   if self.overLine < 0:
  3295.    return
  3296.  
  3297.  def OnMouseLeftButtonUp(self):
  3298.   if self.overLine >= 0:
  3299.    self.SelectItem(self.overLine+self.basePos)
  3300.  
  3301.  def OnUpdate(self):
  3302.  
  3303.   self.overLine = -1
  3304.  
  3305.   if self.IsIn():
  3306.    x, y = self.GetGlobalPosition()
  3307.    height = self.GetHeight()
  3308.    xMouse, yMouse = wndMgr.GetMousePosition()
  3309.  
  3310.    if yMouse - y < height - 1:
  3311.     self.overLine = (yMouse - y) / self.stepSize
  3312.  
  3313.     if self.overLine < 0:
  3314.      self.overLine = -1
  3315.     if self.overLine >= len(self.itemList):
  3316.      self.overLine = -1
  3317.  
  3318.  def OnRender(self):
  3319.   xRender, yRender = self.GetGlobalPosition()
  3320.   yRender -= self.TEMPORARY_PLACE
  3321.   widthRender = self.width
  3322.   heightRender = self.height + self.TEMPORARY_PLACE*2
  3323.  
  3324.   if localeInfo.IsCIBN10:
  3325.    if -1 != self.overLine and self.keyDict[self.overLine] != -1:
  3326.     grp.SetColor(HALF_WHITE_COLOR)
  3327.     grp.RenderBar(xRender + 2, yRender + self.overLine*self.stepSize + 4, self.width - 3, self.stepSize)
  3328.  
  3329.    if -1 != self.selectedLine and self.keyDict[self.selectedLine] != -1:
  3330.     if self.selectedLine >= self.basePos:
  3331.      if self.selectedLine - self.basePos < self.showLineCount:
  3332.       grp.SetColor(SELECT_COLOR)
  3333.       grp.RenderBar(xRender + 2, yRender + (self.selectedLine-self.basePos)*self.stepSize + 4, self.width - 3, self.stepSize)
  3334.  
  3335.   else:
  3336.    if -1 != self.overLine:
  3337.     grp.SetColor(HALF_WHITE_COLOR)
  3338.     grp.RenderBar(xRender + 2, yRender + self.overLine*self.stepSize + 4, self.width - 3, self.stepSize)
  3339.  
  3340.    if -1 != self.selectedLine:
  3341.     if self.selectedLine >= self.basePos:
  3342.      if self.selectedLine - self.basePos < self.showLineCount:
  3343.       grp.SetColor(SELECT_COLOR)
  3344.       grp.RenderBar(xRender + 2, yRender + (self.selectedLine-self.basePos)*self.stepSize + 4, self.width - 3, self.stepSize)
  3345.  
  3346.  
  3347.  
  3348. class ListBox2(ListBox):
  3349.  def __init__(self, *args, **kwargs):
  3350.   ListBox.__init__(self, *args, **kwargs)
  3351.   self.rowCount = 10
  3352.   self.barWidth = 0
  3353.   self.colCount = 0
  3354.  
  3355.  def SetRowCount(self, rowCount):
  3356.   self.rowCount = rowCount
  3357.  
  3358.  def SetSize(self, width, height):
  3359.   ListBox.SetSize(self, width, height)
  3360.   self._RefreshForm()
  3361.  
  3362.  def ClearItem(self):
  3363.   ListBox.ClearItem(self)
  3364.   self._RefreshForm()
  3365.  
  3366.  def InsertItem(self, *args, **kwargs):
  3367.   ListBox.InsertItem(self, *args, **kwargs)
  3368.   self._RefreshForm()
  3369.  
  3370.  def OnUpdate(self):
  3371.   mpos = wndMgr.GetMousePosition()
  3372.   self.overLine = self._CalcPointIndex(mpos)
  3373.  
  3374.  def OnRender(self):
  3375.   x, y = self.GetGlobalPosition()
  3376.   pos = (x + 2, y)
  3377.  
  3378.   if -1 != self.overLine:
  3379.    grp.SetColor(HALF_WHITE_COLOR)
  3380.    self._RenderBar(pos, self.overLine)
  3381.  
  3382.   if -1 != self.selectedLine:
  3383.    if self.selectedLine >= self.basePos:
  3384.     if self.selectedLine - self.basePos < self.showLineCount:
  3385.      grp.SetColor(SELECT_COLOR)
  3386.      self._RenderBar(pos, self.selectedLine-self.basePos)
  3387.  
  3388.  
  3389.  
  3390.  def _CalcPointIndex(self, mpos):
  3391.   if self.IsIn():
  3392.    px, py = mpos
  3393.    gx, gy = self.GetGlobalPosition()
  3394.    lx, ly = px - gx, py - gy
  3395.  
  3396.    col = lx / self.barWidth
  3397.    row = ly / self.stepSize
  3398.    idx = col * self.rowCount + row
  3399.    if col >= 0 and col < self.colCount:
  3400.     if row >= 0 and row < self.rowCount:
  3401.      if idx >= 0 and idx < len(self.itemList):
  3402.       return idx
  3403.  
  3404.   return -1
  3405.  
  3406.  def _CalcRenderPos(self, pos, idx):
  3407.   x, y = pos
  3408.   row = idx % self.rowCount
  3409.   col = idx / self.rowCount
  3410.   return (x + col * self.barWidth, y + row * self.stepSize)
  3411.  
  3412.  def _RenderBar(self, basePos, idx):
  3413.   x, y = self._CalcRenderPos(basePos, idx)
  3414.   grp.RenderBar(x, y, self.barWidth - 3, self.stepSize)
  3415.  
  3416.  def _LocateItem(self):
  3417.   pos = (0, self.TEMPORARY_PLACE)
  3418.  
  3419.   self.showLineCount = 0
  3420.   for textLine in self.itemList:
  3421.    x, y = self._CalcRenderPos(pos, self.showLineCount)
  3422.    textLine.SetPosition(x, y)
  3423.    textLine.Show()
  3424.  
  3425.    self.showLineCount += 1
  3426.  
  3427.  def _RefreshForm(self):
  3428.   if len(self.itemList) % self.rowCount:
  3429.    self.colCount = len(self.itemList) / self.rowCount + 1
  3430.   else:
  3431.    self.colCount = len(self.itemList) / self.rowCount
  3432.  
  3433.   if self.colCount:
  3434.    self.barWidth = self.width / self.colCount
  3435.   else:
  3436.    self.barWidth = self.width
  3437.  
  3438.  
  3439. class ComboBox(Window):
  3440.  
  3441.  class ListBoxWithBoard(ListBox):
  3442.  
  3443.   def __init__(self, layer):
  3444.    ListBox.__init__(self, layer)
  3445.  
  3446.   def OnRender(self):
  3447.    xRender, yRender = self.GetGlobalPosition()
  3448.    yRender -= self.TEMPORARY_PLACE
  3449.    widthRender = self.width
  3450.    heightRender = self.height + self.TEMPORARY_PLACE*2
  3451.    grp.SetColor(BACKGROUND_COLOR)
  3452.    grp.RenderBar(xRender, yRender, widthRender, heightRender)
  3453.    grp.SetColor(DARK_COLOR)
  3454.    grp.RenderLine(xRender, yRender, widthRender, 0)
  3455.    grp.RenderLine(xRender, yRender, 0, heightRender)
  3456.    grp.SetColor(BRIGHT_COLOR)
  3457.    grp.RenderLine(xRender, yRender+heightRender, widthRender, 0)
  3458.    grp.RenderLine(xRender+widthRender, yRender, 0, heightRender)
  3459.  
  3460.    ListBox.OnRender(self)
  3461.  
  3462.  def __init__(self):
  3463.   Window.__init__(self)
  3464.   self.x = 0
  3465.   self.y = 0
  3466.   self.width = 0
  3467.   self.height = 0
  3468.   self.isSelected = False
  3469.   self.isOver = False
  3470.   self.isListOpened = False
  3471.   self.event = lambda *arg: None
  3472.   self.enable = True
  3473.  
  3474.   self.textLine = MakeTextLine(self)
  3475.   self.textLine.SetText(localeInfo.UI_ITEM)
  3476.  
  3477.   self.listBox = self.ListBoxWithBoard("TOP_MOST")
  3478.   self.listBox.SetPickAlways()
  3479.   self.listBox.SetParent(self)
  3480.   self.listBox.SetEvent(__mem_func__(self.OnSelectItem))
  3481.   self.listBox.Hide()
  3482.  
  3483.  def __del__(self):
  3484.   Window.__del__(self)
  3485.  
  3486.  @WindowDestroy
  3487.  def Destroy(self):
  3488.   self.textLine = None
  3489.   self.listBox = None
  3490.  
  3491.  def SetPosition(self, x, y):
  3492.   Window.SetPosition(self, x, y)
  3493.   self.x = x
  3494.   self.y = y
  3495.   self.__ArrangeListBox()
  3496.  
  3497.  def SetSize(self, width, height):
  3498.   Window.SetSize(self, width, height)
  3499.   self.width = width
  3500.   self.height = height
  3501.   self.textLine.UpdateRect()
  3502.   self.__ArrangeListBox()
  3503.  
  3504.  def __ArrangeListBox(self):
  3505.   self.listBox.SetPosition(0, self.height + 5)
  3506.   self.listBox.SetWidth(self.width)
  3507.  
  3508.  def Enable(self):
  3509.   self.enable = True
  3510.  
  3511.  def Disable(self):
  3512.   self.enable = False
  3513.   self.textLine.SetText("")
  3514.   self.CloseListBox()
  3515.  
  3516.  def SetEvent(self, event):
  3517.   self.event = event
  3518.  
  3519.  def ClearItem(self):
  3520.   self.CloseListBox()
  3521.   self.listBox.ClearItem()
  3522.  
  3523.  def InsertItem(self, index, name):
  3524.   self.listBox.InsertItem(index, name)
  3525.   self.listBox.ArrangeItem()
  3526.  
  3527.  def SetCurrentItem(self, text):
  3528.   self.textLine.SetText(text)
  3529.  
  3530.  def SelectItem(self, key):
  3531.   self.listBox.SelectItem(key)
  3532.  
  3533.  def OnSelectItem(self, index, name):
  3534.  
  3535.   self.CloseListBox()
  3536.   self.event(index)
  3537.  
  3538.  def CloseListBox(self):
  3539.   self.isListOpened = False
  3540.   self.listBox.Hide()
  3541.  
  3542.  def OnMouseLeftButtonDown(self):
  3543.  
  3544.   if not self.enable:
  3545.    return
  3546.  
  3547.   self.isSelected = True
  3548.  
  3549.  def OnMouseLeftButtonUp(self):
  3550.  
  3551.   if not self.enable:
  3552.    return
  3553.  
  3554.   self.isSelected = False
  3555.  
  3556.   if self.isListOpened:
  3557.    self.CloseListBox()
  3558.   else:
  3559.    if self.listBox.GetItemCount() > 0:
  3560.     self.isListOpened = True
  3561.     self.listBox.Show()
  3562.     self.__ArrangeListBox()
  3563.  
  3564.  def OnUpdate(self):
  3565.  
  3566.   if not self.enable:
  3567.    return
  3568.  
  3569.   if self.IsIn():
  3570.    self.isOver = True
  3571.   else:
  3572.    self.isOver = False
  3573.  
  3574.  def OnRender(self):
  3575.   self.x, self.y = self.GetGlobalPosition()
  3576.   xRender = self.x
  3577.   yRender = self.y
  3578.   widthRender = self.width
  3579.   heightRender = self.height
  3580.   grp.SetColor(BACKGROUND_COLOR)
  3581.   grp.RenderBar(xRender, yRender, widthRender, heightRender)
  3582.   grp.SetColor(DARK_COLOR)
  3583.   grp.RenderLine(xRender, yRender, widthRender, 0)
  3584.   grp.RenderLine(xRender, yRender, 0, heightRender)
  3585.   grp.SetColor(BRIGHT_COLOR)
  3586.   grp.RenderLine(xRender, yRender+heightRender, widthRender, 0)
  3587.   grp.RenderLine(xRender+widthRender, yRender, 0, heightRender)
  3588.  
  3589.   if self.isOver:
  3590.    grp.SetColor(HALF_WHITE_COLOR)
  3591.    grp.RenderBar(xRender + 2, yRender + 3, self.width - 3, heightRender - 5)
  3592.  
  3593.    if self.isSelected:
  3594.     grp.SetColor(WHITE_COLOR)
  3595.     grp.RenderBar(xRender + 2, yRender + 3, self.width - 3, heightRender - 5)
  3596.  
  3597. ###################################################################################################
  3598. ## Python Script Loader
  3599. ###################################################################################################
  3600.  
  3601. class ScriptWindow(Window):
  3602.  def __init__(self, layer = "UI"):
  3603.   Window.__init__(self, layer)
  3604.   self.Children = []
  3605.   self.ElementDictionary = {}
  3606.  
  3607.  def __del__(self):
  3608.   Window.__del__(self)
  3609.  
  3610.  def ClearDictionary(self):
  3611.   if ENABLE_RECURSIVE_UI_DESTROY:
  3612.    if hasattr(self, "Children"):
  3613.     for child in self.Children:
  3614.      if hasattr(child, "Destroy"):
  3615.       child.Destroy()
  3616.     self.Children = []
  3617.   self.Children = []
  3618.   self.ElementDictionary = {}
  3619.  
  3620.  def InsertChild(self, name, child):
  3621.   self.ElementDictionary[name] = child
  3622.  
  3623.  def IsChild(self, name):
  3624.   return self.ElementDictionary.has_key(name)
  3625.  
  3626.  def GetChild(self, name):
  3627.   return self.ElementDictionary[name]
  3628.  
  3629.  def GetChild2(self, name):
  3630.   return self.ElementDictionary.get(name, None)
  3631.  
  3632.  
  3633. class PythonScriptLoader(object):
  3634.  
  3635.  BODY_KEY_LIST = ( "x", "y", "width", "height" )
  3636.  
  3637.  #####
  3638.  
  3639.  DEFAULT_KEY_LIST = ( "type", "x", "y", )
  3640.  WINDOW_KEY_LIST = ( "width", "height", )
  3641.  IMAGE_KEY_LIST = ( "image", )
  3642.  EXPANDED_IMAGE_KEY_LIST = ( "image", )
  3643.  ANI_IMAGE_KEY_LIST = ( "images", )
  3644.  SLOT_KEY_LIST = ( "width", "height", "slot", )
  3645.  CANDIDATE_LIST_KEY_LIST = ( "item_step", "item_xsize", "item_ysize", )
  3646.  GRID_TABLE_KEY_LIST = ( "start_index", "x_count", "y_count", "x_step", "y_step", )
  3647.  EDIT_LINE_KEY_LIST = ( "width", "height", "input_limit", )
  3648.  COMBO_BOX_KEY_LIST = ( "width", "height", "item", )
  3649.  TITLE_BAR_KEY_LIST = ( "width", )
  3650.  HORIZONTAL_BAR_KEY_LIST = ( "width", )
  3651.  BOARD_KEY_LIST = ( "width", "height", )
  3652.  BOARD_WITH_TITLEBAR_KEY_LIST = ( "width", "height", "title", )
  3653.  BOX_KEY_LIST = ( "width", "height", )
  3654.  BAR_KEY_LIST = ( "width", "height", )
  3655.  LINE_KEY_LIST = ( "width", "height", )
  3656.  SLOTBAR_KEY_LIST = ( "width", "height", )
  3657.  GAUGE_KEY_LIST = ( "width", "color", )
  3658.  SCROLLBAR_KEY_LIST = ( "size", )
  3659.  LIST_BOX_KEY_LIST = ( "width", "height", )
  3660.  RENDER_TARGET_KEY_LIST = ( "index", )
  3661.  
  3662.  if app.__BL_OUTLINE_WINDOW__:
  3663.   OUTLINE_WINDOW_KEY_LIST = ( "width", "height", )
  3664.  
  3665.  if app.BL_MAILBOX:
  3666.   RENDER_BOX_KEY_LIST = ( "color", )
  3667.  
  3668.  def __init__(self):
  3669.   self.Clear()
  3670.  
  3671.  def Clear(self):
  3672.   self.ScriptDictionary = { "SCREEN_WIDTH" : wndMgr.GetScreenWidth(), "SCREEN_HEIGHT" : wndMgr.GetScreenHeight() }
  3673.   self.InsertFunction = 0
  3674.  
  3675.  def LoadScriptFile&#40;self, window, FileName&#41;:
  3676.   import exception
  3677.   import exceptions
  3678.   import os
  3679.   import errno
  3680.   self.Clear()
  3681.  
  3682.   print("===== Load Script File : %s" % (FileName))
  3683.  
  3684.   import sys
  3685.   from utils import Sandbox
  3686.   sandbox = Sandbox(True, ["uiScriptLocale", "localeInfo", "sys", "item", "app", "player","utils","privateShop"])
  3687.  
  3688.   import chr
  3689.   import player
  3690.   import app
  3691.   self.ScriptDictionary["PLAYER_NAME_MAX_LEN"] = chr.PLAYER_NAME_MAX_LEN
  3692.   self.ScriptDictionary["DRAGON_SOUL_EQUIPMENT_SLOT_START"] = player.DRAGON_SOUL_EQUIPMENT_SLOT_START
  3693.   self.ScriptDictionary["LOCALE_PATH"] = app.GetLocalePath()
  3694.  
  3695.   if __USE_EXTRA_CYTHON__:
  3696.    # sub functions
  3697.    from os.path import splitext as op_splitext, basename as op_basename, dirname as op_dirname
  3698.    def GetModName(filename):
  3699.     return op_splitext(op_basename(filename))[0]
  3700.    def IsInUiPath(filename):
  3701.     def ICmp(s1, s2):
  3702.      return s1.lower() == s2.lower()
  3703.     return ICmp(op_dirname(filename), "uiscript")
  3704.    # module name to import
  3705.    modname = GetModName(FileName)
  3706.    # lazy loading of uiscriptlib
  3707.    import uiscriptlib
  3708.    # copy scriptdictionary stuff to builtin scope (otherwise, import will fail)
  3709.    tpl2Main = (
  3710.     "SCREEN_WIDTH","SCREEN_HEIGHT",
  3711.     "PLAYER_NAME_MAX_LEN", "DRAGON_SOUL_EQUIPMENT_SLOT_START","LOCALE_PATH"
  3712.    )
  3713.    import __builtin__ as bt
  3714.    for idx in tpl2Main:
  3715.     tmpVal = self.ScriptDictionary[idx]
  3716.     exec "bt.%s = tmpVal"%idx in globals(), locals()
  3717.    # debug stuff
  3718.    import dbg
  3719.    dbg.TraceError("Loading %s (%s %s)"%(FileName, GetModName(FileName), IsInUiPath(FileName)))
  3720.   try:
  3721.    if __USE_EXTRA_CYTHON__ and IsInUiPath(FileName) and uiscriptlib.isExist(modname):
  3722.     m1 = uiscriptlib.moduleImport(modname)
  3723.     self.ScriptDictionary["window"] = m1.window.copy()
  3724.     del m1
  3725.    else:
  3726.     sandbox.execfile&#40;FileName, self.ScriptDictionary&#41;
  3727.   except IOError as err:
  3728.    import sys
  3729.    import dbg
  3730.    dbg.TraceError("Failed to load script file : %s" % (FileName))
  3731.    dbg.TraceError("error: %s" % (err))
  3732.    exception.Abort("LoadScriptFile1")
  3733.   except RuntimeError as err:
  3734.    import sys
  3735.    import dbg
  3736.    dbg.TraceError("Failed to load script file : %s" % (FileName))
  3737.    dbg.TraceError("error: %s" % (err))
  3738.    exception.Abort("LoadScriptFile2")
  3739.   except:
  3740.    import sys
  3741.    import dbg
  3742.    dbg.TraceError("Failed to load script file : %s" % (FileName))
  3743.    exception.Abort("LoadScriptFile!!!!!!!!!!!!!!")
  3744.  
  3745.   #####
  3746.  
  3747.   Body = self.ScriptDictionary["window"]
  3748.   self.CheckKeyList("window", Body, self.BODY_KEY_LIST)
  3749.  
  3750.   window.ClearDictionary()
  3751.   self.InsertFunction = window.InsertChild
  3752.  
  3753.   window.SetPosition(int(Body["x"]), int(Body["y"]))
  3754.  
  3755.   if localeInfo.IsARABIC():
  3756.    w = wndMgr.GetScreenWidth()
  3757.    h = wndMgr.GetScreenHeight()
  3758.    if Body.has_key("width"):
  3759.     w = int(Body["width"])
  3760.    if Body.has_key("height"):
  3761.     h = int(Body["height"])
  3762.  
  3763.    window.SetSize(w, h)
  3764.   else:
  3765.    window.SetSize(int(Body["width"]), int(Body["height"]))
  3766.    if True == Body.has_key("style"):
  3767.     for StyleList in Body["style"]:
  3768.      window.AddFlag(StyleList)
  3769.  
  3770.  
  3771.   self.LoadChildren(window, Body)
  3772.  
  3773.  def LoadChildren(self, parent, dicChildren):
  3774.  
  3775.   if localeInfo.IsARABIC():
  3776.    parent.AddFlag( "rtl" )
  3777.  
  3778.   if True == dicChildren.has_key("style"):
  3779.    for style in dicChildren["style"]:
  3780.     parent.AddFlag(style)
  3781.  
  3782.   if False == dicChildren.has_key("children"):
  3783.    return False
  3784.  
  3785.   Index = 0
  3786.  
  3787.   ChildrenList = dicChildren["children"]
  3788.   parent.Children = range(len(ChildrenList))
  3789.   for ElementValue in ChildrenList:
  3790.    try:
  3791.     Name = ElementValue["name"]
  3792.    except KeyError:
  3793.     Name = ElementValue["name"] = "NONAME"
  3794.  
  3795.    try:
  3796.     Type = ElementValue["type"]
  3797.    except KeyError:
  3798.     Type = ElementValue["type"] = "window"
  3799.  
  3800.    if False == self.CheckKeyList(Name, ElementValue, self.DEFAULT_KEY_LIST):
  3801.     del parent.Children[Index]
  3802.     continue
  3803.  
  3804.    if Type == "window":
  3805.     parent.Children[Index] = ScriptWindow()
  3806.     parent.Children[Index].SetParent(parent)
  3807.     self.LoadElementWindow(parent.Children[Index], ElementValue, parent)
  3808.  
  3809.    elif Type == "button":
  3810.     parent.Children[Index] = Button()
  3811.     parent.Children[Index].SetParent(parent)
  3812.     self.LoadElementButton(parent.Children[Index], ElementValue, parent)
  3813.  
  3814.    elif Type == "radio_button":
  3815.     parent.Children[Index] = RadioButton()
  3816.     parent.Children[Index].SetParent(parent)
  3817.     self.LoadElementButton(parent.Children[Index], ElementValue, parent)
  3818.  
  3819.    elif Type == "toggle_button":
  3820.     parent.Children[Index] = ToggleButton()
  3821.     parent.Children[Index].SetParent(parent)
  3822.     self.LoadElementButton(parent.Children[Index], ElementValue, parent)
  3823.  
  3824.    elif Type == "mark":
  3825.     parent.Children[Index] = MarkBox()
  3826.     parent.Children[Index].SetParent(parent)
  3827.     self.LoadElementMark(parent.Children[Index], ElementValue, parent)
  3828.  
  3829.    elif Type == "image":
  3830.     parent.Children[Index] = ImageBox()
  3831.     parent.Children[Index].SetParent(parent)
  3832.     self.LoadElementImage(parent.Children[Index], ElementValue, parent)
  3833.  
  3834.    elif Type == "expanded_image":
  3835.     parent.Children[Index] = ExpandedImageBox()
  3836.     parent.Children[Index].SetParent(parent)
  3837.     self.LoadElementExpandedImage(parent.Children[Index], ElementValue, parent)
  3838.  
  3839.    elif Type == "ani_image":
  3840.     parent.Children[Index] = AniImageBox()
  3841.     parent.Children[Index].SetParent(parent)
  3842.     self.LoadElementAniImage(parent.Children[Index], ElementValue, parent)
  3843.  
  3844.    elif Type == "slot":
  3845.     parent.Children[Index] = SlotWindow()
  3846.     parent.Children[Index].SetParent(parent)
  3847.     self.LoadElementSlot(parent.Children[Index], ElementValue, parent)
  3848.  
  3849.    elif Type == "candidate_list":
  3850.     parent.Children[Index] = CandidateListBox()
  3851.     parent.Children[Index].SetParent(parent)
  3852.     self.LoadElementCandidateList(parent.Children[Index], ElementValue, parent)
  3853.  
  3854.    elif Type == "grid_table":
  3855.     parent.Children[Index] = GridSlotWindow()
  3856.     parent.Children[Index].SetParent(parent)
  3857.     self.LoadElementGridTable(parent.Children[Index], ElementValue, parent)
  3858.  
  3859.    elif Type == "text":
  3860.     parent.Children[Index] = TextLine()
  3861.     parent.Children[Index].SetParent(parent)
  3862.     self.LoadElementText(parent.Children[Index], ElementValue, parent)
  3863.  
  3864.    elif Type == "editline":
  3865.     parent.Children[Index] = EditLine()
  3866.     parent.Children[Index].SetParent(parent)
  3867.     self.LoadElementEditLine(parent.Children[Index], ElementValue, parent)
  3868.  
  3869.    elif Type == "titlebar":
  3870.     parent.Children[Index] = TitleBar()
  3871.     parent.Children[Index].SetParent(parent)
  3872.     self.LoadElementTitleBar(parent.Children[Index], ElementValue, parent)
  3873.  
  3874.    elif Type == "horizontalbar":
  3875.     parent.Children[Index] = HorizontalBar()
  3876.     parent.Children[Index].SetParent(parent)
  3877.     self.LoadElementHorizontalBar(parent.Children[Index], ElementValue, parent)
  3878.  
  3879.    elif Type == "board":
  3880.     parent.Children[Index] = Board()
  3881.     parent.Children[Index].SetParent(parent)
  3882.     self.LoadElementBoard(parent.Children[Index], ElementValue, parent)
  3883.  
  3884.    elif Type == "board_with_titlebar":
  3885.     parent.Children[Index] = BoardWithTitleBar()
  3886.     parent.Children[Index].SetParent(parent)
  3887.     self.LoadElementBoardWithTitleBar(parent.Children[Index], ElementValue, parent)
  3888.  
  3889.    elif Type == "middleboard" and app.__BL_MIDDLE_BOARD_WINDOW__:
  3890.     parent.Children[Index] = MiddleBoard()
  3891.     parent.Children[Index].SetParent(parent)
  3892.     self.LoadElementBoard(parent.Children[Index], ElementValue, parent)
  3893.  
  3894.    elif Type == "thinboard":
  3895.     parent.Children[Index] = ThinBoard()
  3896.     parent.Children[Index].SetParent(parent)
  3897.     self.LoadElementThinBoard(parent.Children[Index], ElementValue, parent)
  3898.  
  3899.    elif Type == "thinboard_gold":
  3900.     parent.Children[Index] = ThinBoardGold()
  3901.     parent.Children[Index].SetParent(parent)
  3902.     self.LoadElementThinBoard(parent.Children[Index], ElementValue, parent)
  3903.  
  3904.    elif Type == "thinboard_circle":
  3905.     parent.Children[Index] = ThinBoardCircle()
  3906.     parent.Children[Index].SetParent(parent)
  3907.     self.LoadElementThinBoard(parent.Children[Index], ElementValue, parent)
  3908.  
  3909.    elif Type == "box":
  3910.     parent.Children[Index] = Box()
  3911.     parent.Children[Index].SetParent(parent)
  3912.     self.LoadElementBox(parent.Children[Index], ElementValue, parent)
  3913.  
  3914.    elif Type == "bar":
  3915.     parent.Children[Index] = Bar()
  3916.     parent.Children[Index].SetParent(parent)
  3917.     self.LoadElementBar(parent.Children[Index], ElementValue, parent)
  3918.  
  3919.    elif Type == "line":
  3920.     parent.Children[Index] = Line()
  3921.     parent.Children[Index].SetParent(parent)
  3922.     self.LoadElementLine(parent.Children[Index], ElementValue, parent)
  3923.  
  3924.    elif Type == "slotbar":
  3925.     parent.Children[Index] = SlotBar()
  3926.     parent.Children[Index].SetParent(parent)
  3927.     self.LoadElementSlotBar(parent.Children[Index], ElementValue, parent)
  3928.  
  3929.    elif Type == "gauge":
  3930.     parent.Children[Index] = Gauge()
  3931.     parent.Children[Index].SetParent(parent)
  3932.     self.LoadElementGauge(parent.Children[Index], ElementValue, parent)
  3933.  
  3934.    elif Type == "scrollbar":
  3935.     parent.Children[Index] = ScrollBar()
  3936.     parent.Children[Index].SetParent(parent)
  3937.     self.LoadElementScrollBar(parent.Children[Index], ElementValue, parent)
  3938.  
  3939.    elif Type == "thin_scrollbar":
  3940.     parent.Children[Index] = ThinScrollBar()
  3941.     parent.Children[Index].SetParent(parent)
  3942.     self.LoadElementScrollBar(parent.Children[Index], ElementValue, parent)
  3943.  
  3944.    elif Type == "small_thin_scrollbar":
  3945.     parent.Children[Index] = SmallThinScrollBar()
  3946.     parent.Children[Index].SetParent(parent)
  3947.     self.LoadElementScrollBar(parent.Children[Index], ElementValue, parent)
  3948.  
  3949.    elif Type == "sliderbar":
  3950.     parent.Children[Index] = SliderBar()
  3951.     parent.Children[Index].SetParent(parent)
  3952.     self.LoadElementSliderBar(parent.Children[Index], ElementValue, parent)
  3953.  
  3954.    elif Type == "listbox":
  3955.     parent.Children[Index] = ListBox()
  3956.     parent.Children[Index].SetParent(parent)
  3957.     self.LoadElementListBox(parent.Children[Index], ElementValue, parent)
  3958.  
  3959.    elif Type == "listbox2":
  3960.     parent.Children[Index] = ListBox2()
  3961.     parent.Children[Index].SetParent(parent)
  3962.     self.LoadElementListBox2(parent.Children[Index], ElementValue, parent)
  3963.  
  3964.    elif Type == "listboxex":
  3965.     parent.Children[Index] = ListBoxEx()
  3966.     parent.Children[Index].SetParent(parent)
  3967.     self.LoadElementListBoxEx(parent.Children[Index], ElementValue, parent)
  3968.    
  3969.    elif Type == "render_target":
  3970.     parent.Children[Index] = RenderTarget()
  3971.     parent.Children[Index].SetParent(parent)
  3972.     self.LoadElementRenderTarget(parent.Children[Index], ElementValue, parent)
  3973.  
  3974.    elif app.ENABLE_PREMIUM_PRIVATE_SHOP and Type == "thinboard_deco":
  3975.     parent.Children[Index] = ShopDecoThinboard()
  3976.     parent.Children[Index].SetParent(parent)
  3977.     self.LoadElementShopDecoThinBoard(parent.Children[Index], ElementValue, parent)
  3978.  
  3979.    elif app.BL_MAILBOX and Type == "renderbox":
  3980.     parent.Children[Index] = RenderBox()
  3981.     parent.Children[Index].SetParent(parent)
  3982.     self.LoadElementRenderBox(parent.Children[Index], ElementValue, parent)
  3983.  
  3984.    elif Type == "outline_window" and app.__BL_OUTLINE_WINDOW__:
  3985.     parent.Children[Index] = OutlineWindow()
  3986.     parent.Children[Index].SetParent(parent)
  3987.     self.LoadOutlineWindow(parent.Children[Index], ElementValue, parent)
  3988.  
  3989.    elif Type == "editline_centered":
  3990.     parent.Children[Index] = EditLineCentered()
  3991.     parent.Children[Index].SetParent(parent)
  3992.     self.LoadElementEditLine(parent.Children[Index], ElementValue, parent)
  3993.    else:
  3994.     Index += 1
  3995.     continue
  3996.  
  3997.    parent.Children[Index].SetWindowName(Name)
  3998.    if 0 != self.InsertFunction:
  3999.     self.InsertFunction(Name, parent.Children[Index])
  4000.  
  4001.    self.LoadChildren(parent.Children[Index], ElementValue)
  4002.    Index += 1
  4003.  
  4004.  def CheckKeyList(self, name, value, key_list):
  4005.   for DataKey in key_list:
  4006.    if False == value.has_key(DataKey):
  4007.     print("Failed to find data key", "[" + name + "/" + DataKey + "]")
  4008.     return False
  4009.  
  4010.   return True
  4011.  
  4012.  def LoadDefaultData(self, window, value, parentWindow):
  4013.   loc_x = int(value["x"])
  4014.   loc_y = int(value["y"])
  4015.   if value.has_key("vertical_align"):
  4016.    if "center" == value["vertical_align"]:
  4017.     window.SetWindowVerticalAlignCenter()
  4018.    elif "bottom" == value["vertical_align"]:
  4019.     window.SetWindowVerticalAlignBottom()
  4020.  
  4021.   if parentWindow.IsRTL():
  4022.    loc_x = int(value["x"]) + window.GetWidth()
  4023.    if value.has_key("horizontal_align"):
  4024.     if "center" == value["horizontal_align"]:
  4025.      window.SetWindowHorizontalAlignCenter()
  4026.      loc_x = - int(value["x"])
  4027.     elif "right" == value["horizontal_align"]:
  4028.      window.SetWindowHorizontalAlignLeft()
  4029.      loc_x = int(value["x"]) - window.GetWidth()
  4030.      ## loc_x = parentWindow.GetWidth() - int(value["x"]) + window.GetWidth()
  4031.    else:
  4032.     window.SetWindowHorizontalAlignRight()
  4033.  
  4034.    if value.has_key("all_align"):
  4035.     window.SetWindowVerticalAlignCenter()
  4036.     window.SetWindowHorizontalAlignCenter()
  4037.     loc_x = - int(value["x"])
  4038.   else:
  4039.    if value.has_key("horizontal_align"):
  4040.     if "center" == value["horizontal_align"]:
  4041.      window.SetWindowHorizontalAlignCenter()
  4042.     elif "right" == value["horizontal_align"]:
  4043.      window.SetWindowHorizontalAlignRight()
  4044.  
  4045.   window.SetPosition(loc_x, loc_y)
  4046.   window.Show()
  4047.  
  4048.  ## Window
  4049.  def LoadElementWindow(self, window, value, parentWindow):
  4050.  
  4051.   if False == self.CheckKeyList(value["name"], value, self.WINDOW_KEY_LIST):
  4052.    return False
  4053.  
  4054.   window.SetSize(int(value["width"]), int(value["height"]))
  4055.   self.LoadDefaultData(window, value, parentWindow)
  4056.  
  4057.   return True
  4058.  
  4059.  ## Button
  4060.  def LoadElementButton(self, window, value, parentWindow):
  4061.  
  4062.   if value.has_key("width") and value.has_key("height"):
  4063.    window.SetSize(int(value["width"]), int(value["height"]))
  4064.  
  4065.   if True == value.has_key("default_image"):
  4066.    window.SetUpVisual(value["default_image"])
  4067.   if True == value.has_key("over_image"):
  4068.    window.SetOverVisual(value["over_image"])
  4069.   if True == value.has_key("down_image"):
  4070.    window.SetDownVisual(value["down_image"])
  4071.   if True == value.has_key("disable_image"):
  4072.    window.SetDisableVisual(value["disable_image"])
  4073.  
  4074.   if True == value.has_key("text"):
  4075.    if True == value.has_key("text_height"):
  4076.     window.SetText(value["text"], value["text_height"])
  4077.    else:
  4078.     window.SetText(value["text"])
  4079.  
  4080.    if value.has_key("text_color"):
  4081.     window.SetTextColor(value["text_color"])
  4082.  
  4083.   if True == value.has_key("tooltip_text"):
  4084.    if True == value.has_key("tooltip_x") and True == value.has_key("tooltip_y"):
  4085.     window.SetToolTipText(value["tooltip_text"], int(value["tooltip_x"]), int(value["tooltip_y"]))
  4086.    else:
  4087.     window.SetToolTipText(value["tooltip_text"])
  4088.  
  4089.   self.LoadDefaultData(window, value, parentWindow)
  4090.  
  4091.   return True
  4092.  
  4093.  ## Mark
  4094.  def LoadElementMark(self, window, value, parentWindow):
  4095.  
  4096.   #if False == self.CheckKeyList(value["name"], value, self.MARK_KEY_LIST):
  4097.   # return False
  4098.  
  4099.   self.LoadDefaultData(window, value, parentWindow)
  4100.  
  4101.   return True
  4102.  
  4103.  ## Image
  4104.  def LoadElementImage(self, window, value, parentWindow):
  4105.  
  4106.   if False == self.CheckKeyList(value["name"], value, self.IMAGE_KEY_LIST):
  4107.    return False
  4108.  
  4109.   window.LoadImage(value["image"])
  4110.   self.LoadDefaultData(window, value, parentWindow)
  4111.  
  4112.   return True
  4113.  
  4114.  ## AniImage
  4115.  def LoadElementAniImage(self, window, value, parentWindow):
  4116.  
  4117.   if False == self.CheckKeyList(value["name"], value, self.ANI_IMAGE_KEY_LIST):
  4118.    return False
  4119.  
  4120.   if True == value.has_key("delay"):
  4121.    window.SetDelay(value["delay"])
  4122.  
  4123.   for image in value["images"]:
  4124.    window.AppendImage(image)
  4125.  
  4126.   if value.has_key("width") and value.has_key("height"):
  4127.    window.SetSize(value["width"], value["height"])
  4128.  
  4129.   self.LoadDefaultData(window, value, parentWindow)
  4130.  
  4131.   return True
  4132.  
  4133.  ## Expanded Image
  4134.  def LoadElementExpandedImage(self, window, value, parentWindow):
  4135.  
  4136.   if False == self.CheckKeyList(value["name"], value, self.EXPANDED_IMAGE_KEY_LIST):
  4137.    return False
  4138.  
  4139.   window.LoadImage(value["image"])
  4140.  
  4141.   if True == value.has_key("x_origin") and True == value.has_key("y_origin"):
  4142.    window.SetOrigin(float(value["x_origin"]), float(value["y_origin"]))
  4143.  
  4144.   if True == value.has_key("x_scale") and True == value.has_key("y_scale"):
  4145.    window.SetScale(float(value["x_scale"]), float(value["y_scale"]))
  4146.  
  4147.   if True == value.has_key("rect"):
  4148.    RenderingRect = value["rect"]
  4149.    window.SetRenderingRect(RenderingRect[0], RenderingRect[1], RenderingRect[2], RenderingRect[3])
  4150.  
  4151.   if True == value.has_key("mode"):
  4152.    mode = value["mode"]
  4153.    if "MODULATE" == mode:
  4154.     window.SetRenderingMode(wndMgr.RENDERING_MODE_MODULATE)
  4155.  
  4156.   self.LoadDefaultData(window, value, parentWindow)
  4157.  
  4158.   return True
  4159.  
  4160.  ## Slot
  4161.  def LoadElementSlot(self, window, value, parentWindow):
  4162.  
  4163.   if False == self.CheckKeyList(value["name"], value, self.SLOT_KEY_LIST):
  4164.    return False
  4165.  
  4166.   global_x = int(value["x"])
  4167.   global_y = int(value["y"])
  4168.   global_width = int(value["width"])
  4169.   global_height = int(value["height"])
  4170.  
  4171.   window.SetPosition(global_x, global_y)
  4172.   window.SetSize(global_width, global_height)
  4173.   window.Show()
  4174.  
  4175.   r = 1.0
  4176.   g = 1.0
  4177.   b = 1.0
  4178.   a = 1.0
  4179.  
  4180.   if True == value.has_key("image_r") and \
  4181.    True == value.has_key("image_g") and \
  4182.    True == value.has_key("image_b") and \
  4183.    True == value.has_key("image_a"):
  4184.    r = float(value["image_r"])
  4185.    g = float(value["image_g"])
  4186.    b = float(value["image_b"])
  4187.    a = float(value["image_a"])
  4188.  
  4189.   SLOT_ONE_KEY_LIST = ("index", "x", "y", "width", "height")
  4190.  
  4191.   for slot in value["slot"]:
  4192.    if True == self.CheckKeyList(value["name"] + " - one", slot, SLOT_ONE_KEY_LIST):
  4193.     wndMgr.AppendSlot(window.hWnd,
  4194.          int(slot["index"]),
  4195.          int(slot["x"]),
  4196.          int(slot["y"]),
  4197.          int(slot["width"]),
  4198.          int(slot["height"]))
  4199.  
  4200.   if True == value.has_key("image"):
  4201.    wndMgr.SetSlotBaseImage(window.hWnd,
  4202.          value["image"],
  4203.          r, g, b, a)
  4204.  
  4205.   return True
  4206.  
  4207.  def LoadElementCandidateList(self, window, value, parentWindow):
  4208.   if False == self.CheckKeyList(value["name"], value, self.CANDIDATE_LIST_KEY_LIST):
  4209.    return False
  4210.  
  4211.   window.SetPosition(int(value["x"]), int(value["y"]))
  4212.   window.SetItemSize(int(value["item_xsize"]), int(value["item_ysize"]))
  4213.   window.SetItemStep(int(value["item_step"]))
  4214.   window.Show()
  4215.  
  4216.   return True
  4217.  
  4218.  ## Table
  4219.  def LoadElementGridTable(self, window, value, parentWindow):
  4220.  
  4221.   if False == self.CheckKeyList(value["name"], value, self.GRID_TABLE_KEY_LIST):
  4222.    return False
  4223.  
  4224.   xBlank = 0
  4225.   yBlank = 0
  4226.   if True == value.has_key("x_blank"):
  4227.    xBlank = int(value["x_blank"])
  4228.   if True == value.has_key("y_blank"):
  4229.    yBlank = int(value["y_blank"])
  4230.  
  4231.   if localeInfo.IsARABIC():
  4232.    pass
  4233.   else:
  4234.    window.SetPosition(int(value["x"]), int(value["y"]))
  4235.  
  4236.   window.ArrangeSlot( int(value["start_index"]),
  4237.        int(value["x_count"]),
  4238.        int(value["y_count"]),
  4239.        int(value["x_step"]),
  4240.        int(value["y_step"]),
  4241.        xBlank,
  4242.        yBlank)
  4243.   if True == value.has_key("image"):
  4244.    r = 1.0
  4245.    g = 1.0
  4246.    b = 1.0
  4247.    a = 1.0
  4248.    if True == value.has_key("image_r") and \
  4249.     True == value.has_key("image_g") and \
  4250.     True == value.has_key("image_b") and \
  4251.     True == value.has_key("image_a"):
  4252.     r = float(value["image_r"])
  4253.     g = float(value["image_g"])
  4254.     b = float(value["image_b"])
  4255.     a = float(value["image_a"])
  4256.    wndMgr.SetSlotBaseImage(window.hWnd, value["image"], r, g, b, a)
  4257.  
  4258.   if True == value.has_key("style"):
  4259.    if "select" == value["style"]:
  4260.     wndMgr.SetSlotStyle(window.hWnd, wndMgr.SLOT_STYLE_SELECT)
  4261.   if localeInfo.IsARABIC():
  4262.    self.LoadDefaultData(window, value, parentWindow)
  4263.   else:
  4264.    window.Show()
  4265.  
  4266.   return True
  4267.  
  4268.  ## Text
  4269.  def LoadElementText(self, window, value, parentWindow):
  4270.  
  4271.   if value.has_key("fontsize"):
  4272.    fontSize = value["fontsize"]
  4273.  
  4274.    if "LARGE" == fontSize:
  4275.     window.SetFontName(localeInfo.UI_DEF_FONT_LARGE)
  4276.  
  4277.   elif value.has_key("fontname"):
  4278.    fontName = value["fontname"]
  4279.    window.SetFontName(fontName)
  4280.  
  4281.   if value.has_key("text_horizontal_align"):
  4282.    if "left" == value["text_horizontal_align"]:
  4283.     window.SetHorizontalAlignLeft()
  4284.    elif "center" == value["text_horizontal_align"]:
  4285.     window.SetHorizontalAlignCenter()
  4286.    elif "right" == value["text_horizontal_align"]:
  4287.     window.SetHorizontalAlignRight()
  4288.  
  4289.   if value.has_key("text_vertical_align"):
  4290.    if "top" == value["text_vertical_align"]:
  4291.     window.SetVerticalAlignTop()
  4292.    elif "center" == value["text_vertical_align"]:
  4293.     window.SetVerticalAlignCenter()
  4294.    elif "bottom" == value["text_vertical_align"]:
  4295.     window.SetVerticalAlignBottom()
  4296.  
  4297.   if value.has_key("all_align"):
  4298.    window.SetHorizontalAlignCenter()
  4299.    window.SetVerticalAlignCenter()
  4300.    window.SetWindowHorizontalAlignCenter()
  4301.    window.SetWindowVerticalAlignCenter()
  4302.  
  4303.   if value.has_key("r") and value.has_key("g") and value.has_key("b"):
  4304.    window.SetFontColor(float(value["r"]), float(value["g"]), float(value["b"]))
  4305.   elif value.has_key("color"):
  4306.    window.SetPackedFontColor(value["color"])
  4307.   else:
  4308.    window.SetFontColor(0.8549, 0.8549, 0.8549)
  4309.  
  4310.   if value.has_key("outline"):
  4311.    if value["outline"]:
  4312.     window.SetOutline()
  4313.   if True == value.has_key("text"):
  4314.    window.SetText(value["text"])
  4315.  
  4316.   self.LoadDefaultData(window, value, parentWindow)
  4317.  
  4318.   return True
  4319.  
  4320.  ## EditLine
  4321.  def LoadElementEditLine(self, window, value, parentWindow):
  4322.  
  4323.   if False == self.CheckKeyList(value["name"], value, self.EDIT_LINE_KEY_LIST):
  4324.    return False
  4325.  
  4326.  
  4327.   if value.has_key("secret_flag"):
  4328.    window.SetSecret(value["secret_flag"])
  4329.   if value.has_key("with_codepage"):
  4330.    if value["with_codepage"]:
  4331.     window.bCodePage = True
  4332.   if value.has_key("only_number"):
  4333.    if value["only_number"]:
  4334.     window.SetNumberMode()
  4335.   if value.has_key("enable_codepage"):
  4336.    window.SetIMEFlag(value["enable_codepage"])
  4337.   if value.has_key("enable_ime"):
  4338.    window.SetIMEFlag(value["enable_ime"])
  4339.   if value.has_key("limit_width"):
  4340.    window.SetLimitWidth(value["limit_width"])
  4341.   if value.has_key("multi_line"):
  4342.    if value["multi_line"]:
  4343.     window.SetMultiLine()
  4344.  
  4345.   window.SetMax(int(value["input_limit"]))
  4346.   window.SetSize(int(value["width"]), int(value["height"]))
  4347.   self.LoadElementText(window, value, parentWindow)
  4348.  
  4349.   return True
  4350.  
  4351.  def LoadElementRenderTarget(self, window, value, parentWindow):
  4352.  
  4353.   if False == self.CheckKeyList(value["name"], value, self.RENDER_TARGET_KEY_LIST):
  4354.    return False
  4355.  
  4356.   window.SetSize(value["width"], value["height"])
  4357.    
  4358.   if True == value.has_key("style"):
  4359.    for style in value["style"]:
  4360.     window.AddFlag(style)
  4361.      
  4362.    self.LoadDefaultData(window, value, parentWindow)
  4363.    
  4364.   if value.has_key("index"):
  4365.    window.SetRenderTarget(int(value["index"]))
  4366.  
  4367.   return True
  4368.  
  4369.  ## TitleBar
  4370.  def LoadElementTitleBar(self, window, value, parentWindow):
  4371.  
  4372.   if False == self.CheckKeyList(value["name"], value, self.TITLE_BAR_KEY_LIST):
  4373.    return False
  4374.  
  4375.   window.MakeTitleBar(int(value["width"]), value.get("color", "red"))
  4376.   self.LoadDefaultData(window, value, parentWindow)
  4377.  
  4378.   return True
  4379.  
  4380.  ## HorizontalBar
  4381.  def LoadElementHorizontalBar(self, window, value, parentWindow):
  4382.  
  4383.   if False == self.CheckKeyList(value["name"], value, self.HORIZONTAL_BAR_KEY_LIST):
  4384.    return False
  4385.  
  4386.   window.Create(int(value["width"]))
  4387.   self.LoadDefaultData(window, value, parentWindow)
  4388.  
  4389.   return True
  4390.  
  4391.  ## Board
  4392.  def LoadElementBoard(self, window, value, parentWindow):
  4393.  
  4394.   if False == self.CheckKeyList(value["name"], value, self.BOARD_KEY_LIST):
  4395.    return False
  4396.  
  4397.   window.SetSize(int(value["width"]), int(value["height"]))
  4398.   self.LoadDefaultData(window, value, parentWindow)
  4399.  
  4400.   return True
  4401.  
  4402.  ## Board With TitleBar
  4403.  def LoadElementBoardWithTitleBar(self, window, value, parentWindow):
  4404.  
  4405.   if False == self.CheckKeyList(value["name"], value, self.BOARD_WITH_TITLEBAR_KEY_LIST):
  4406.    return False
  4407.  
  4408.   window.SetSize(int(value["width"]), int(value["height"]))
  4409.   window.SetTitleName(value["title"])
  4410.   self.LoadDefaultData(window, value, parentWindow)
  4411.  
  4412.   return True
  4413.  
  4414.  ## ThinBoard
  4415.  def LoadElementThinBoard(self, window, value, parentWindow):
  4416.  
  4417.   if False == self.CheckKeyList(value["name"], value, self.BOARD_KEY_LIST):
  4418.    return False
  4419.  
  4420.   window.SetSize(int(value["width"]), int(value["height"]))
  4421.   self.LoadDefaultData(window, value, parentWindow)
  4422.  
  4423.   return True
  4424.  
  4425.  ## Box
  4426.  def LoadElementBox(self, window, value, parentWindow):
  4427.  
  4428.   if False == self.CheckKeyList(value["name"], value, self.BOX_KEY_LIST):
  4429.    return False
  4430.  
  4431.   if True == value.has_key("color"):
  4432.    window.SetColor(value["color"])
  4433.  
  4434.   window.SetSize(int(value["width"]), int(value["height"]))
  4435.   self.LoadDefaultData(window, value, parentWindow)
  4436.  
  4437.   return True
  4438.  
  4439.  ## Bar
  4440.  def LoadElementBar(self, window, value, parentWindow):
  4441.  
  4442.   if False == self.CheckKeyList(value["name"], value, self.BAR_KEY_LIST):
  4443.    return False
  4444.  
  4445.   if True == value.has_key("color"):
  4446.    window.SetColor(value["color"])
  4447.  
  4448.   window.SetSize(int(value["width"]), int(value["height"]))
  4449.   self.LoadDefaultData(window, value, parentWindow)
  4450.  
  4451.   return True
  4452.  
  4453.  ## Line
  4454.  def LoadElementLine(self, window, value, parentWindow):
  4455.  
  4456.   if False == self.CheckKeyList(value["name"], value, self.LINE_KEY_LIST):
  4457.    return False
  4458.  
  4459.   if True == value.has_key("color"):
  4460.    window.SetColor(value["color"])
  4461.  
  4462.   window.SetSize(int(value["width"]), int(value["height"]))
  4463.   self.LoadDefaultData(window, value, parentWindow)
  4464.  
  4465.   return True
  4466.  
  4467.  ## Slot
  4468.  def LoadElementSlotBar(self, window, value, parentWindow):
  4469.  
  4470.   if False == self.CheckKeyList(value["name"], value, self.SLOTBAR_KEY_LIST):
  4471.    return False
  4472.  
  4473.   window.SetSize(int(value["width"]), int(value["height"]))
  4474.   self.LoadDefaultData(window, value, parentWindow)
  4475.  
  4476.   return True
  4477.  
  4478.  ## Gauge
  4479.  def LoadElementGauge(self, window, value, parentWindow):
  4480.  
  4481.   if False == self.CheckKeyList(value["name"], value, self.GAUGE_KEY_LIST):
  4482.    return False
  4483.  
  4484.   window.MakeGauge(value["width"], value["color"])
  4485.   self.LoadDefaultData(window, value, parentWindow)
  4486.  
  4487.   return True
  4488.  
  4489.  ## ScrollBar
  4490.  def LoadElementScrollBar(self, window, value, parentWindow):
  4491.  
  4492.   if False == self.CheckKeyList(value["name"], value, self.SCROLLBAR_KEY_LIST):
  4493.    return False
  4494.  
  4495.   window.SetScrollBarSize(value["size"])
  4496.  
  4497.   if app.__BL_SMOOTH_SCROLL__:
  4498.    if value.has_key("smooth"):
  4499.     if value["smooth"]:
  4500.      window.EnableSmoothMode()
  4501.  
  4502.   self.LoadDefaultData(window, value, parentWindow)
  4503.  
  4504.   return True
  4505.  
  4506.  ## SliderBar
  4507.  def LoadElementSliderBar(self, window, value, parentWindow):
  4508.  
  4509.   self.LoadDefaultData(window, value, parentWindow)
  4510.  
  4511.   return True
  4512.  
  4513.  ## ListBox
  4514.  def LoadElementListBox(self, window, value, parentWindow):
  4515.  
  4516.   if False == self.CheckKeyList(value["name"], value, self.LIST_BOX_KEY_LIST):
  4517.    return False
  4518.  
  4519.   if value.has_key("item_align"):
  4520.    window.SetTextCenterAlign(value["item_align"])
  4521.  
  4522.   window.SetSize(value["width"], value["height"])
  4523.   self.LoadDefaultData(window, value, parentWindow)
  4524.  
  4525.   return True
  4526.  
  4527.  ## ListBox2
  4528.  def LoadElementListBox2(self, window, value, parentWindow):
  4529.  
  4530.   if False == self.CheckKeyList(value["name"], value, self.LIST_BOX_KEY_LIST):
  4531.    return False
  4532.  
  4533.   window.SetRowCount(value.get("row_count", 10))
  4534.   window.SetSize(value["width"], value["height"])
  4535.   self.LoadDefaultData(window, value, parentWindow)
  4536.  
  4537.   if value.has_key("item_align"):
  4538.    window.SetTextCenterAlign(value["item_align"])
  4539.  
  4540.   return True
  4541.  def LoadElementListBoxEx(self, window, value, parentWindow):
  4542.  
  4543.   if False == self.CheckKeyList(value["name"], value, self.LIST_BOX_KEY_LIST):
  4544.    return False
  4545.  
  4546.   window.SetSize(value["width"], value["height"])
  4547.   self.LoadDefaultData(window, value, parentWindow)
  4548.  
  4549.   if value.has_key("itemsize_x") and value.has_key("itemsize_y"):
  4550.    window.SetItemSize(int(value["itemsize_x"]), int(value["itemsize_y"]))
  4551.  
  4552.   if value.has_key("itemstep"):
  4553.    window.SetItemStep(int(value["itemstep"]))
  4554.  
  4555.   if value.has_key("viewcount"):
  4556.    window.SetViewItemCount(int(value["viewcount"]))
  4557.  
  4558.   return True
  4559.  
  4560.  if app.ENABLE_PREMIUM_PRIVATE_SHOP:
  4561.   ## ThinBoardDeco
  4562.   def LoadElementShopDecoThinBoard(self, window, value, parentWindow):
  4563.  
  4564.    if False == self.CheckKeyList(value["name"], value, self.BOARD_KEY_LIST):
  4565.     return False
  4566.  
  4567.    window.SetBoardSize(int(value["width"]), int(value["height"]))
  4568.    self.LoadDefaultData(window, value, parentWindow)
  4569.  
  4570.    return True
  4571.  
  4572.  if app.BL_MAILBOX:
  4573.   def LoadElementRenderBox(self, window, value, parentWindow):
  4574.    if False == self.CheckKeyList(value["name"], value, self.RENDER_BOX_KEY_LIST):
  4575.     return False
  4576.    
  4577.    window.SetSize(value["width"], value["height"])
  4578.    self.LoadDefaultData(window, value, parentWindow)
  4579.    
  4580.    if value.has_key("color"):
  4581.     window.SetColor(int(value["color"]))
  4582.    
  4583.    return True
  4584.  
  4585.  ## OutlineWindow
  4586.  if app.__BL_OUTLINE_WINDOW__:
  4587.   def LoadOutlineWindow(self, window, value, parentWindow):
  4588.    if False == self.CheckKeyList(value["name"], value, self.OUTLINE_WINDOW_KEY_LIST):
  4589.     return False
  4590.  
  4591.    window.MakeOutlineWindow(int(value["width"]), int(value["height"]))
  4592.    self.LoadDefaultData(window, value, parentWindow)
  4593.  
  4594.    return True
  4595.    
  4596.  def LoadElementRenderTarget(self, window, value, parentWindow):
  4597.  
  4598.   if False == self.CheckKeyList(value["name"], value, self.RENDER_TARGET_KEY_LIST) or \
  4599.    False == self.CheckKeyList(value["index"], value, self.RENDER_TARGET_KEY_LIST):
  4600.    return False
  4601.  
  4602.   window.SetSize(value["width"], value["height"])
  4603.   window.SetRenderTarget(value["index"])
  4604.   self.LoadDefaultData(window, value, parentWindow)
  4605.  
  4606.   return True  
  4607.  
  4608. class ReadingWnd(Bar):
  4609.  
  4610.  def __init__(self):
  4611.   Bar.__init__(self,"TOP_MOST")
  4612.  
  4613.   self.__BuildText()
  4614.   self.SetSize(80, 19)
  4615.   self.Show()
  4616.  
  4617.  def __del__(self):
  4618.   Bar.__del__(self)
  4619.  
  4620.  def __BuildText(self):
  4621.   self.text = TextLine()
  4622.   self.text.SetParent(self)
  4623.   self.text.SetPosition(4, 3)
  4624.   self.text.Show()
  4625.  
  4626.  def SetText(self, text):
  4627.   self.text.SetText(text)
  4628.  
  4629.  def SetReadingPosition(self, x, y):
  4630.   xPos = x + 2
  4631.   yPos = y - self.GetHeight() - 2
  4632.   self.SetPosition(xPos, yPos)
  4633.  
  4634.  def SetTextColor(self, color):
  4635.   self.text.SetPackedFontColor(color)
  4636.  
  4637. if app.ENABLE_PREMIUM_PRIVATE_SHOP:
  4638.  class DynamicListBox(Window):
  4639.  
  4640.   def GetSelectedItemText(self):
  4641.    return self.textDict.get(self.selectedLine, "")
  4642.  
  4643.   TEMPORARY_PLACE = 3
  4644.  
  4645.   def __init__(self, layer = "UI"):
  4646.    Window.__init__(self, layer)
  4647.    self.overLine = -1
  4648.    self.selectedLine = -1
  4649.    self.width = 0
  4650.    self.height = 0
  4651.    self.stepSize = 17
  4652.    self.basePos = 0
  4653.    self.showLineCount = 0
  4654.    self.visibleLineCount = 10
  4655.    self.currentPosition = 0
  4656.    self.itemCenterAlign = TRUE
  4657.    self.itemList = []
  4658.    self.keyDict = {}
  4659.    self.textDict = {}
  4660.    self.event = lambda *arg: None
  4661.    
  4662.   def __del__(self):
  4663.    Window.__del__(self)
  4664.  
  4665.   def SetWidth(self, width):
  4666.    self.SetSize(width, self.height)
  4667.  
  4668.   def SetSize(self, width, height):
  4669.    Window.SetSize(self, width, height)
  4670.    self.width = width
  4671.    self.height = height
  4672.  
  4673.   def SetTextCenterAlign(self, flag):
  4674.    self.itemCenterAlign = flag
  4675.  
  4676.   def SetBasePos(self, pos):
  4677.    self.basePos = pos
  4678.    self._LocateItem()
  4679.  
  4680.   def ClearItem(self):
  4681.    self.keyDict = {}
  4682.    self.textDict = {}
  4683.    self.itemList = []
  4684.    self.overLine = -1
  4685.    self.selectedLine = -1
  4686.  
  4687.   def InsertItem(self, number, text):
  4688.    self.keyDict[len(self.itemList)] = number
  4689.    self.textDict[len(self.itemList)] = text
  4690.  
  4691.    textLine = TextLine()
  4692.    textLine.SetParent(self)
  4693.    textLine.SetText(text)
  4694.    textLine.Hide()
  4695.  
  4696.    if self.itemCenterAlign:
  4697.     textLine.SetWindowHorizontalAlignCenter()
  4698.     textLine.SetHorizontalAlignCenter()
  4699.  
  4700.    self.itemList.append(textLine)
  4701.  
  4702.    self._LocateItem()
  4703.  
  4704.   def ChangeItem(self, number, text):
  4705.    for key, value in self.keyDict.items():
  4706.     if value == number:
  4707.      self.textDict[key] = text
  4708.  
  4709.      if number < len(self.itemList):
  4710.       self.itemList[key].SetText(text)
  4711.  
  4712.      return
  4713.  
  4714.   def LocateItem(self):
  4715.    self._LocateItem()
  4716.    
  4717.   def SetVisibleLineCount(self, count):
  4718.    self.visibleLineCount = count
  4719.    
  4720.   def GetVisibleLineCount(self):
  4721.    return self.visibleLineCount
  4722.    
  4723.   def GetVisibleHeight(self):
  4724.    return self.visibleLineCount * self.stepSize
  4725.  
  4726.   def _LocateItem(self):
  4727.    yPos = 0
  4728.    self.showLineCount = 0
  4729.  
  4730.    i = 0
  4731.    for textLine in self.itemList:
  4732.     if i >= self.currentPosition and i < (self.currentPosition + self.GetVisibleLineCount()):
  4733.      if localeInfo.IsARABIC():
  4734.       w, h = textLine.GetTextSize()
  4735.       textLine.SetPosition(w+10, yPos + 3)
  4736.      else:
  4737.       textLine.SetPosition(0, yPos + 3)
  4738.      
  4739.      textLine.Show()
  4740.      yPos += self.stepSize
  4741.     else:
  4742.      textLine.Hide()
  4743.  
  4744.     self.showLineCount += 1
  4745.     i += 1
  4746.  
  4747.   def ArrangeItem(self):
  4748.    self.SetSize(self.width, len(self.itemList) * self.stepSize)
  4749.    self._LocateItem()
  4750.  
  4751.   def GetViewItemCount(self):
  4752.    return int(self.GetHeight() / self.stepSize)
  4753.  
  4754.   def GetItemCount(self):
  4755.    return len(self.itemList)
  4756.  
  4757.   def SetEvent(self, event):
  4758.    self.event = event
  4759.  
  4760.   def SelectItem(self, line):
  4761.  
  4762.    if not self.keyDict.has_key(line):
  4763.     return
  4764.  
  4765.    if line == self.selectedLine:
  4766.     return
  4767.  
  4768.    self.selectedLine = line + self.currentPosition
  4769.    self.event(self.keyDict.get(self.selectedLine, 0), self.textDict.get(self.selectedLine, "None"))
  4770.  
  4771.   def GetSelectedItem(self):
  4772.    return self.keyDict.get(self.selectedLine, 0)
  4773.  
  4774.   def GetSelectedItemText(self):
  4775.    return self.itemList[self.selectedLine].GetText()
  4776.  
  4777.   def OnMouseLeftButtonDown(self):
  4778.    if self.overLine < 0:
  4779.     return
  4780.  
  4781.   def OnMouseLeftButtonUp(self):
  4782.    if self.overLine >= 0:
  4783.     self.SelectItem(self.overLine+self.basePos)
  4784.    
  4785.   def OnDown(self):
  4786.    if self.GetItemCount() > self.GetVisibleLineCount():
  4787.     self.currentPosition = min(self.GetItemCount() - self.GetVisibleLineCount(), self.currentPosition + 1)
  4788.  
  4789.     self._LocateItem()
  4790.    
  4791.   def OnUp(self):
  4792.    if self.GetItemCount() > self.GetVisibleLineCount():
  4793.     self.currentPosition = max(0, self.currentPosition - 1)
  4794.  
  4795.     self._LocateItem()
  4796.    
  4797.   def OnUpdate(self):
  4798.    self.overLine = -1
  4799.  
  4800.    if self.IsIn():
  4801.     x, y = self.GetGlobalPosition()
  4802.     height = self.GetHeight()
  4803.     xMouse, yMouse = wndMgr.GetMousePosition()
  4804.  
  4805.     if yMouse - y < height - 1:
  4806.      self.overLine = (yMouse - y) / self.stepSize
  4807.  
  4808.      if self.overLine < 0:
  4809.       self.overLine = -1
  4810.      if self.overLine >= len(self.itemList):
  4811.       self.overLine = -1
  4812.  
  4813.   def OnRender(self):
  4814.    xRender, yRender = self.GetGlobalPosition()
  4815.    yRender -= self.TEMPORARY_PLACE
  4816.    widthRender = self.width
  4817.    heightRender = self.height + self.TEMPORARY_PLACE*2
  4818.  
  4819.    if -1 != self.overLine:
  4820.     grp.SetColor(HALF_WHITE_COLOR)
  4821.     grp.RenderBar(xRender + 2, yRender + self.overLine*self.stepSize + 4, self.width - 3, self.stepSize)    
  4822.  
  4823.    if -1 != self.selectedLine:
  4824.     if self.selectedLine >= self.currentPosition and self.selectedLine < (self.currentPosition + self.GetVisibleLineCount()):
  4825.      if self.selectedLine - self.basePos < self.showLineCount:
  4826.       grp.SetColor(grp.GenerateColor(255.0 / 255.0, 150.0 / 255.0, 95.0 / 255.0, 0.2))
  4827.       grp.RenderBar(xRender + 2, yRender + (self.selectedLine-self.basePos-self.currentPosition) * self.stepSize + 4, self.width - 3, self.stepSize)
  4828.  
  4829.    max_count = min(self.GetVisibleLineCount(), self.GetItemCount())
  4830.    for i in range(1, max_count):
  4831.     grp.SetColor(WHITE_COLOR)
  4832.     grp.RenderBar(xRender, yRender + i*self.stepSize + 4, self.width, 1)  
  4833.  
  4834.  class DynamicComboBoxImage(Window):
  4835.   class ListBoxWithBoard(DynamicListBox):
  4836.  
  4837.    BG_COLOR = grp.GenerateColor(33.0 / 255.0, 33.0 / 255.0, 33.0 / 255.0, 1.0)
  4838.  
  4839.    def __init__(self, layer):
  4840.     DynamicListBox.__init__(self, layer)
  4841.  
  4842.    def OnRender(self):
  4843.     xRender, yRender = self.GetGlobalPosition()
  4844.     yRender -= self.TEMPORARY_PLACE
  4845.     widthRender = self.width
  4846.     heightRender = self.height + self.TEMPORARY_PLACE*2
  4847.     grp.SetColor(BACKGROUND_COLOR)
  4848.     grp.RenderBar(xRender, yRender, widthRender, heightRender)
  4849.     grp.SetColor(WHITE_COLOR)
  4850.     grp.RenderBox(xRender, yRender, widthRender, heightRender)
  4851.     # grp.SetColor(DARK_COLOR)
  4852.     # grp.RenderLine(xRender, yRender, widthRender, 0)
  4853.     # grp.RenderLine(xRender, yRender, 0, heightRender)
  4854.     DynamicListBox.OnRender(self)
  4855.  
  4856.   def __init__(self, parent, name, x, y):
  4857.    self.isSelected = False
  4858.    self.isOver = False
  4859.    self.isListOpened = False
  4860.    self.event = lambda *arg: None
  4861.    self.enable = True
  4862.    self.imagebox = None
  4863.    self.listBox = None
  4864.    self.titleText = None
  4865.  
  4866.    Window.__init__(self)
  4867.    
  4868.    ## ImageBox
  4869.    image = ExpandedImageBox()
  4870.    image.SetParent(parent)
  4871.    image.LoadImage(name)
  4872.    image.SetPosition(x, y)
  4873.    image.Hide()
  4874.    self.imagebox = image
  4875.    
  4876.    ## BaseSetting
  4877.    self.x = x + 1
  4878.    self.y = y + 1
  4879.    self.width = self.imagebox.GetWidth() - 3
  4880.    self.height = self.imagebox.GetHeight() - 3
  4881.    self.SetParent(parent)
  4882.  
  4883.    ## TextLine
  4884.    self.textLine = MakeTextLine(self)
  4885.    self.textLine.SetText(localeInfo.UI_ITEM)
  4886.    
  4887.    ## ListBox
  4888.    self.listBox = self.ListBoxWithBoard("TOP_MOST")
  4889.    self.listBox.SetPickAlways()
  4890.    self.listBox.SetParent(self)
  4891.    self.listBox.SetVisibleLineCount(12)
  4892.    self.listBox.SetEvent(__mem_func__(self.OnSelectItem))
  4893.    self.listBox.Hide()
  4894.    
  4895.    Window.SetPosition(self, self.x, self.y)
  4896.    Window.SetSize(self, self.width, self.height)
  4897.    self.textLine.UpdateRect()
  4898.    self.listBox.SetPosition(0, self.height + 5)
  4899.    self.__ArrangeListBox()
  4900.    
  4901.   def __del__(self):
  4902.    Window.__del__(self)
  4903.  
  4904.   def Hide(self):
  4905.    Window.Hide(self)
  4906.    
  4907.    if self.listBox:
  4908.     self.CloseListBox()
  4909.  
  4910.    if self.imagebox:
  4911.     self.imagebox.Hide()
  4912.  
  4913.   def Show(self):
  4914.    Window.Show(self)
  4915.  
  4916.    if self.imagebox:
  4917.     self.imagebox.Show()
  4918.  
  4919.   def Destroy(self):
  4920.    self.textLine = None
  4921.    self.listBox = None
  4922.    self.imagebox = None
  4923.  
  4924.   def Clear(self):
  4925.    self.SelectItem(0)
  4926.  
  4927.   def SetPosition(self, x, y):
  4928.    Window.SetPosition(self, x, y)
  4929.    self.imagebox.SetPosition(x, y)
  4930.    self.x = x
  4931.    self.y = y
  4932.    self.__ArrangeListBox()
  4933.  
  4934.   def SetSize(self, width, height):
  4935.    Window.SetSize(self, width, height)
  4936.    self.width = width
  4937.    self.height = height
  4938.    self.textLine.UpdateRect()
  4939.    self.__ArrangeListBox()
  4940.    
  4941.   def SetImageScale(self, scale_x, scale_y):
  4942.    self.imagebox.SetScale(scale_x, scale_y)
  4943.    self.width = self.imagebox.GetWidth() - 3
  4944.    self.height = self.imagebox.GetHeight() - 3
  4945.    Window.SetSize(self, self.width, self.height)
  4946.    self.textLine.UpdateRect()
  4947.    self.__ArrangeListBox()
  4948.    
  4949.   def __ArrangeListBox(self):
  4950.    self.listBox.SetPosition(0, self.height + 5)
  4951.  
  4952.    if self.listBox.GetItemCount() <= self.listBox.GetVisibleLineCount():
  4953.     self.listBox.SetSize(self.width, self.listBox.GetHeight())
  4954.    else:
  4955.     self.listBox.SetSize(self.width, self.listBox.GetVisibleHeight())
  4956.  
  4957.   def Enable(self):
  4958.    self.enable = True
  4959.  
  4960.   def Disable(self):
  4961.    self.enable = False
  4962.    self.CloseListBox()
  4963.  
  4964.   def SetEvent(self, event):
  4965.    self.event = event
  4966.  
  4967.   def SetDefaultTitle(self, title):
  4968.    self.titleText = title
  4969.  
  4970.    self.SetCurrentItem(self.titleText)
  4971.  
  4972.   def UseDefaultTitle(self):
  4973.    self.SetCurrentItem(self.titleText)
  4974.    
  4975.   def SetTitle(self, title):
  4976.    self.SetCurrentItem(title)
  4977.  
  4978.   def GetTitle(self):
  4979.    return self.titleText
  4980.  
  4981.   def ClearItem(self):
  4982.    self.CloseListBox()
  4983.    self.listBox.ClearItem()
  4984.  
  4985.   def InsertItem(self, index, name):
  4986.    self.listBox.InsertItem(index, name)
  4987.    self.listBox.ArrangeItem()
  4988.  
  4989.   def SetCurrentItem(self, text):
  4990.    self.textLine.SetText(text)
  4991.  
  4992.   def GetSelectedItemText(self):
  4993.    return self.listBox.GetSelectedItemText()
  4994.  
  4995.   def SelectItem(self, key):
  4996.    self.listBox.SelectItem(key)
  4997.  
  4998.   def OnSelectItem(self, index, name):
  4999.    self.CloseListBox()
  5000.    self.event(index)
  5001.  
  5002.   def CloseListBox(self):
  5003.    self.isListOpened = False
  5004.    self.listBox.Hide()
  5005.  
  5006.   def OnMouseLeftButtonDown(self):
  5007.    if not self.enable:
  5008.     return
  5009.  
  5010.    self.isSelected = True
  5011.  
  5012.   def OnMouseLeftButtonUp(self):
  5013.    if not self.enable:
  5014.     return
  5015.    
  5016.    self.isSelected = False
  5017.    
  5018.    if self.isListOpened:
  5019.     self.CloseListBox()
  5020.    else:
  5021.     if self.listBox.GetItemCount() > 0:
  5022.      self.isListOpened = True
  5023.      self.listBox.Show()
  5024.      self.listBox.SetTop()
  5025.      self.__ArrangeListBox()
  5026.      
  5027.   def OnMouseWheel(self, nLen):
  5028.    if nLen > 0:
  5029.     self.listBox.OnUp()
  5030.     return True
  5031.    
  5032.    elif nLen < 0:
  5033.     self.listBox.OnDown()
  5034.     return True
  5035.    
  5036.    return False
  5037.  
  5038.   def OnUpdate(self):
  5039.    if not self.enable:
  5040.     return
  5041.  
  5042.    if self.IsIn():
  5043.     self.isOver = True
  5044.    else:
  5045.     self.isOver = False
  5046.  
  5047.   def OnRender(self):
  5048.    self.x, self.y = self.GetGlobalPosition()
  5049.    xRender = self.x
  5050.    yRender = self.y
  5051.    widthRender = self.width
  5052.    heightRender = self.height
  5053.    
  5054.    if self.isOver:
  5055.     grp.SetColor(HALF_WHITE_COLOR)
  5056.     grp.RenderBar(xRender + 2, yRender + 3, self.width - 3, heightRender - 5)
  5057.    
  5058.     if self.isSelected:
  5059.      grp.SetColor(WHITE_COLOR)
  5060.      grp.RenderBar(xRender + 2, yRender + 3, self.width - 3, heightRender - 5)
  5061.      
  5062.  class ShopDecoThinboard(Window):
  5063.   DEFAULT_VALUE = 16
  5064.   CORNER_WIDTH = 48
  5065.   CORNER_HEIGHT = 32
  5066.   LINE_WIDTH = 16
  5067.   LINE_HEIGHT = 32
  5068.  
  5069.   DEFAULT_CORNER_WIDTH = 16
  5070.   DEFAULT_CORNER_HEIGHT = 16
  5071.   DEFAULT_LINE_WIDTH = 16
  5072.   DEFAULT_LINE_HEIGHT = 16
  5073.   DEFAULT_BOARD_COLOR = grp.GenerateColor(0.0, 0.0, 0.0, 0.51)
  5074.  
  5075.   LT = 0
  5076.   LB = 1
  5077.   RT = 2
  5078.   RB = 3
  5079.   L = 0
  5080.   R = 1
  5081.   T = 2
  5082.   B = 3
  5083.  
  5084.   def __init__(self, type = 0, layer = "UI"):
  5085.    Window.__init__(self, layer)
  5086.    
  5087.    self.type = type
  5088.    
  5089.    base = Bar()
  5090.    base.SetParent(self)
  5091.    base.AddFlag("attach")
  5092.    base.AddFlag("not_pick")
  5093.    base.SetPosition(self.DEFAULT_CORNER_WIDTH, self.DEFAULT_CORNER_HEIGHT)
  5094.    base.SetColor(self.DEFAULT_BOARD_COLOR)
  5095.    base.Hide()
  5096.    self.base = base
  5097.  
  5098.    self.width = 190
  5099.    self.height = 32
  5100.    
  5101.    self.SetStyle(type)
  5102.    self.Refresh()
  5103.    
  5104.   def __del__(self):
  5105.    Window.__del__(self)
  5106.    
  5107.   def GetStyle(self, type):
  5108.    import privateShop
  5109.  
  5110.    (name, path, text_color) = privateShop.GetTitleDeco(type)
  5111.    
  5112.    CornerFileNames = [ path + "_"+dir+".tga" for dir in ["left_top","left_bottom","right_top","right_bottom"] ]
  5113.    LineFileNames = [ path + "_"+dir+".tga" for dir in ["left","right","top","bottom"] ]
  5114.    
  5115.    return CornerFileNames, LineFileNames
  5116.    
  5117.   def SetStyle(self, type):
  5118.    self.type = type
  5119.    
  5120.    CornerFileNames, LineFileNames = self.GetStyle(type)
  5121.    
  5122.    if CornerFileNames == None or LineFileNames == None :
  5123.     return
  5124.  
  5125.    self.Corners = []
  5126.    for fileName in CornerFileNames:
  5127.     Corner = ExpandedImageBox()
  5128.     Corner.AddFlag("attach")
  5129.     Corner.AddFlag("not_pick")
  5130.     Corner.LoadImage(fileName)
  5131.     Corner.SetParent(self)
  5132.     Corner.SetPosition(0, 0)
  5133.     Corner.Show()
  5134.     self.Corners.append(Corner)
  5135.  
  5136.    self.Lines = []
  5137.    for fileName in LineFileNames:
  5138.     Line = ExpandedImageBox()
  5139.     Line.AddFlag("attach")
  5140.     Line.AddFlag("not_pick")
  5141.     Line.LoadImage(fileName)
  5142.     Line.SetParent(self)
  5143.     Line.SetPosition(0, 0)
  5144.     Line.Show()
  5145.     self.Lines.append(Line)
  5146.    
  5147.    if self.type == 0:
  5148.     self.base.Show()
  5149.    else:
  5150.     self.base.Hide()
  5151.    
  5152.    self.Refresh()
  5153.  
  5154.   def SetBoardSize(self, width, height):
  5155.    if self.type == 0:
  5156.     self.width = max(self.DEFAULT_CORNER_WIDTH*2, width)
  5157.     self.height = max(self.DEFAULT_CORNER_HEIGHT*2, height)
  5158.    
  5159.    else:
  5160.     self.width = max(self.DEFAULT_VALUE*2, width)
  5161.     self.height = max(self.DEFAULT_VALUE*2, height)
  5162.    
  5163.    Window.SetSize(self, self.width, self.height)
  5164.    self.Refresh()
  5165.  
  5166.   def Refresh(self):
  5167.    if self.type == 0:
  5168.  
  5169.     self.Corners[self.LB].SetPosition(0, self.height - self.DEFAULT_CORNER_HEIGHT)
  5170.     self.Corners[self.RT].SetPosition(self.width - self.DEFAULT_CORNER_WIDTH, 0)
  5171.     self.Corners[self.RB].SetPosition(self.width - self.DEFAULT_CORNER_WIDTH, self.height - self.DEFAULT_CORNER_HEIGHT)
  5172.    
  5173.     self.Lines[self.L].SetPosition(0, self.DEFAULT_CORNER_HEIGHT)
  5174.     self.Lines[self.T].SetPosition(self.DEFAULT_CORNER_WIDTH, 0)
  5175.     self.Lines[self.R].SetPosition(self.width - self.DEFAULT_CORNER_WIDTH, self.DEFAULT_CORNER_HEIGHT)
  5176.     self.Lines[self.B].SetPosition(self.DEFAULT_CORNER_HEIGHT, self.height - self.DEFAULT_CORNER_HEIGHT)
  5177.  
  5178.     verticalShowingPercentage = float((self.height - self.DEFAULT_CORNER_HEIGHT*2) - self.DEFAULT_LINE_HEIGHT) / self.DEFAULT_LINE_HEIGHT
  5179.      horiz - self.DEFAULT_CORNER_WIDTH*2) - self.DEFAULT_LINE_WIDTH) / self.DEFAULT_LINE_WIDTH
  5180.    
  5181.     self.Lines[self.L].SetRenderingRect(0, 0, 0, verticalShowingPercentage)
  5182.     self.Lines[self.R].SetRenderingRect(0, 0, 0, verticalShowingPercentage)
  5183.     self.Lines[self.T].SetRenderingRect(0, 0, horizontalShowingPercentage, 0)
  5184.     self.Lines[self.B].SetRenderingRect(0, 0, horizontalShowingPercentage, 0)
  5185.     self.base.SetSize(self.width - self.DEFAULT_CORNER_WIDTH*2, self.height - self.DEFAULT_CORNER_HEIGHT*2)
  5186.     self.base.Show()
  5187.  
  5188.    else:
  5189.     self.Corners[self.LT].SetPosition(-self.CORNER_WIDTH + self.DEFAULT_VALUE, -self.CORNER_HEIGHT + self.DEFAULT_VALUE)
  5190.     self.Corners[self.LB].SetPosition(-self.CORNER_WIDTH + self.DEFAULT_VALUE, self.height - self.CORNER_HEIGHT + self.DEFAULT_VALUE)
  5191.    
  5192.     self.Corners[self.RT].SetPosition(self.width - self.DEFAULT_VALUE, -self.CORNER_HEIGHT + self.DEFAULT_VALUE)
  5193.     self.Corners[self.RB].SetPosition(self.width - self.DEFAULT_VALUE, self.height - self.CORNER_HEIGHT + self.DEFAULT_VALUE)
  5194.    
  5195.     self.Lines[self.L].SetPosition(0, self.DEFAULT_VALUE)
  5196.     self.Lines[self.R].SetPosition(self.width - self.DEFAULT_VALUE, self.DEFAULT_VALUE)
  5197.     self.Lines[self.B].SetPosition(self.DEFAULT_VALUE, self.height - self.LINE_HEIGHT + self.DEFAULT_VALUE)
  5198.     self.Lines[self.T].SetPosition(self.DEFAULT_VALUE, -self.LINE_HEIGHT + self.DEFAULT_VALUE)
  5199.    
  5200.     verticalShowingPercentage = float((self.height - self.DEFAULT_VALUE*2) - self.DEFAULT_VALUE) / self.DEFAULT_VALUE
  5201.      horiz - self.DEFAULT_VALUE*2) - self.DEFAULT_VALUE) / self.DEFAULT_VALUE
  5202.    
  5203.     self.Lines[self.L].SetRenderingRect(0, 0, 0, verticalShowingPercentage)
  5204.     self.Lines[self.R].SetRenderingRect(0, 0, 0, verticalShowingPercentage)
  5205.     self.Lines[self.T].SetRenderingRect(0, 0, horizontalShowingPercentage, 0)
  5206.     self.Lines[self.B].SetRenderingRect(0, 0, horizontalShowingPercentage, 0)
  5207.     self.base.Hide()
  5208.  
  5209.   def ShowInternal(self):
  5210.    for wnd in self.Lines:
  5211.     wnd.Show()
  5212.    for wnd in self.Corners:
  5213.     wnd.Show()
  5214.  
  5215.   def HideInternal(self):
  5216.    for wnd in self.Lines:
  5217.     wnd.Hide()
  5218.    for wnd in self.Corners:
  5219.     wnd.Hide()
  5220.  
  5221. if app.__BL_MIDDLE_BOARD_WINDOW__:
  5222.  class MiddleBoard(Window):
  5223.  
  5224.   CORNER_WIDTH = 16
  5225.   CORNER_HEIGHT = 16
  5226.   LINE_WIDTH = 16
  5227.   LINE_HEIGHT = 16
  5228.   BOARD_COLOR = grp.GenerateColor(0.0, 0.0, 0.0, 0.7)
  5229.  
  5230.   LT = 0
  5231.   LB = 1
  5232.   RT = 2
  5233.   RB = 3
  5234.   L = 0
  5235.   R = 1
  5236.   T = 2
  5237.   B = 3
  5238.  
  5239.   def __init__(self, layer = "UI"):
  5240.    Window.__init__(self, layer)
  5241.  
  5242.    CornerFileNames = [ "d:/ymir work/ui/pattern/ThinBoardB_Corner_"+dir+".tga" for dir in ["LeftTop","LeftBottom","RightTop","RightBottom"] ]
  5243.    LineFileNames = [ "d:/ymir work/ui/pattern/ThinBoardB_Line_"+dir+".tga" for dir in ["Left","Right","Top","Bottom"] ]
  5244.  
  5245.    self.Corners = []
  5246.    for fileName in CornerFileNames:
  5247.     Corner = ExpandedImageBox()
  5248.     Corner.AddFlag("attach")
  5249.     Corner.AddFlag("not_pick")
  5250.     Corner.LoadImage(fileName)
  5251.     Corner.SetParent(self)
  5252.     Corner.SetPosition(0, 0)
  5253.     Corner.Show()
  5254.     self.Corners.append(Corner)
  5255.  
  5256.    self.Lines = []
  5257.    for fileName in LineFileNames:
  5258.     Line = ExpandedImageBox()
  5259.     Line.AddFlag("attach")
  5260.     Line.AddFlag("not_pick")
  5261.     Line.LoadImage(fileName)
  5262.     Line.SetParent(self)
  5263.     Line.SetPosition(0, 0)
  5264.     Line.Show()
  5265.     self.Lines.append(Line)
  5266.  
  5267.    Base = Bar()
  5268.    Base.SetParent(self)
  5269.    Base.AddFlag("attach")
  5270.    Base.AddFlag("not_pick")
  5271.    Base.SetPosition(self.CORNER_WIDTH, self.CORNER_HEIGHT)
  5272.    Base.SetColor(self.BOARD_COLOR)
  5273.    Base.Show()
  5274.    self.Base = Base
  5275.  
  5276.    self.Lines[self.L].SetPosition(0, self.CORNER_HEIGHT)
  5277.    self.Lines[self.T].SetPosition(self.CORNER_WIDTH, 0)
  5278.  
  5279.   def __del__(self):
  5280.    Window.__del__(self)
  5281.  
  5282.   def SetSize(self, width, height):
  5283.  
  5284.    width = max(self.CORNER_WIDTH*2, width)
  5285.    height = max(self.CORNER_HEIGHT*2, height)
  5286.    Window.SetSize(self, width, height)
  5287.  
  5288.    self.Corners[self.LB].SetPosition(0, height - self.CORNER_HEIGHT)
  5289.    self.Corners[self.RT].SetPosition(width - self.CORNER_WIDTH, 0)
  5290.    self.Corners[self.RB].SetPosition(width - self.CORNER_WIDTH, height - self.CORNER_HEIGHT)
  5291.    self.Lines[self.R].SetPosition(width - self.CORNER_WIDTH, self.CORNER_HEIGHT)
  5292.    self.Lines[self.B].SetPosition(self.CORNER_HEIGHT, height - self.CORNER_HEIGHT)
  5293.  
  5294.    verticalShowingPercentage = float((height - self.CORNER_HEIGHT*2) - self.LINE_HEIGHT) / self.LINE_HEIGHT
  5295.     horiz - self.CORNER_WIDTH*2) - self.LINE_WIDTH) / self.LINE_WIDTH
  5296.    self.Lines[self.L].SetRenderingRect(0, 0, 0, verticalShowingPercentage)
  5297.    self.Lines[self.R].SetRenderingRect(0, 0, 0, verticalShowingPercentage)
  5298.    self.Lines[self.T].SetRenderingRect(0, 0, horizontalShowingPercentage, 0)
  5299.    self.Lines[self.B].SetRenderingRect(0, 0, horizontalShowingPercentage, 0)
  5300.    self.Base.SetSize(width - self.CORNER_WIDTH*2, height - self.CORNER_HEIGHT*2)
  5301.  
  5302.   def ShowInternal(self):
  5303.    self.Base.Show()
  5304.    for wnd in self.Lines:
  5305.     wnd.Show()
  5306.    for wnd in self.Corners:
  5307.     wnd.Show()
  5308.  
  5309.   def HideInternal(self):
  5310.    self.Base.Hide()
  5311.    for wnd in self.Lines:
  5312.     wnd.Hide()
  5313.    for wnd in self.Corners:
  5314.     wnd.Hide()
  5315.  
  5316. if app.__BL_OUTLINE_WINDOW__:
  5317.  class OutlineWindow(Window):
  5318.   PATTERN_PATH = "d:/ymir work/ui/pattern/"
  5319.  
  5320.   def __init__(self):
  5321.    Window.__init__(self)
  5322.    self.__Initialize()
  5323.  
  5324.   def __del__(self):
  5325.    Window.__del__(self)
  5326.    self.__Initialize()
  5327.  
  5328.   def __Initialize(self):
  5329.    self.pattern_x_count = 0
  5330.    self.pattern_y_count = 0
  5331.    self.left_top_img = None
  5332.    self.right_top_img = None
  5333.    self.left_bottom_img = None
  5334.    self.right_bottom_img = None
  5335.    self.top_center_img = None
  5336.    self.left_center_img = None
  5337.    self.right_center_img = None
  5338.    self.bottom_center_img = None
  5339.    self.center_img = None
  5340.  
  5341.   def MakeOutlineWindow(self, window_width, window_height):  
  5342.    self.AddFlag("ltr")
  5343.    self.AddFlag("attach")
  5344.    self.SetWindowName("outline_window")
  5345.    self.SetSize(window_width, window_height)
  5346.    
  5347.    self.pattern_x_count = (window_width - 32) / 16
  5348.    self.pattern_y_count = (window_height - 32) / 16
  5349.    
  5350.    self.left_top_img = ImageBox()
  5351.    self.left_top_img.SetParent(self)
  5352.    self.left_top_img.LoadImage(OutlineWindow.PATTERN_PATH + "border_A_left_top.tga")
  5353.    self.left_top_img.SetPosition(0, 0)
  5354.    self.left_top_img.Show()
  5355.  
  5356.    self.right_top_img = ImageBox()
  5357.    self.right_top_img.SetParent(self)
  5358.    self.right_top_img.LoadImage(OutlineWindow.PATTERN_PATH + "border_A_right_top.tga")
  5359.    self.right_top_img.SetPosition(window_width - 16, 0)
  5360.    self.right_top_img.Show()
  5361.  
  5362.    self.left_bottom_img = ImageBox()
  5363.    self.left_bottom_img.SetParent(self)
  5364.    self.left_bottom_img.LoadImage(OutlineWindow.PATTERN_PATH + "border_A_left_bottom.tga")
  5365.    self.left_bottom_img.SetPosition(0, window_height - 16)
  5366.    self.left_bottom_img.Show()
  5367.  
  5368.    self.right_bottom_img = ImageBox()
  5369.    self.right_bottom_img.SetParent(self)
  5370.    self.right_bottom_img.LoadImage(OutlineWindow.PATTERN_PATH + "border_A_right_bottom.tga")
  5371.    self.right_bottom_img.SetPosition(window_width - 16, window_height - 16)
  5372.    self.right_bottom_img.Show()
  5373.  
  5374.    self.top_center_img = ExpandedImageBox()
  5375.    self.top_center_img.SetParent(self)
  5376.    self.top_center_img.LoadImage(OutlineWindow.PATTERN_PATH + "border_A_top.tga")
  5377.    self.top_center_img.SetPosition(16, 0)
  5378.    self.top_center_img.SetRenderingRect(0.0, 0.0, self.pattern_x_count, 0.0)
  5379.    self.top_center_img.Show()
  5380.  
  5381.    self.left_center_img = ExpandedImageBox()
  5382.    self.left_center_img.SetParent(self)
  5383.    self.left_center_img.LoadImage(OutlineWindow.PATTERN_PATH + "border_A_left.tga")
  5384.    self.left_center_img.SetPosition(0, 16)
  5385.    self.left_center_img.SetRenderingRect(0.0, 0.0, 0.0, self.pattern_y_count)
  5386.    self.left_center_img.Show()
  5387.  
  5388.    self.right_center_img = ExpandedImageBox()
  5389.    self.right_center_img.SetParent(self)
  5390.    self.right_center_img.LoadImage(OutlineWindow.PATTERN_PATH + "border_A_right.tga")
  5391.    self.right_center_img.SetPosition(window_width - 16, 16)
  5392.    self.right_center_img.SetRenderingRect(0.0, 0.0, 0.0, self.pattern_y_count)
  5393.    self.right_center_img.Show()
  5394.  
  5395.    self.bottom_center_img = ExpandedImageBox()
  5396.    self.bottom_center_img.SetParent(self)
  5397.    self.bottom_center_img.LoadImage(OutlineWindow.PATTERN_PATH + "border_A_bottom.tga")
  5398.    self.bottom_center_img.SetPosition(16, window_height - 16)
  5399.    self.bottom_center_img.SetRenderingRect(0.0, 0.0, self.pattern_x_count, 0.0)
  5400.    self.bottom_center_img.Show()
  5401.  
  5402.    self.center_img = ExpandedImageBox()
  5403.    self.center_img.SetParent(self)
  5404.    self.center_img.LoadImage(OutlineWindow.PATTERN_PATH + "border_A_center.tga")
  5405.    self.center_img.SetPosition(16, 16)
  5406.    self.center_img.SetRenderingRect(0.0, 0.0, self.pattern_x_count, self.pattern_y_count)
  5407.    self.center_img.Show()
  5408.  
  5409.    # self.Show()
  5410.  
  5411. if app.BL_MAILBOX:
  5412.  class RenderBox(Window):
  5413.   def __init__(self, layer = "UI"):
  5414.    Window.__init__(self, layer)
  5415.    self.color = 0xFF000000
  5416.   def __del__(self):
  5417.    Window.__del__(self)
  5418.    self.color = 0xFF000000
  5419.    
  5420.   def RegisterWindow(self, layer):
  5421.    self.hWnd = wndMgr.Register(self, layer)
  5422.    
  5423.   def SetColor(self, color):
  5424.    self.color = color
  5425.    
  5426.   def OnRender(self):
  5427.    (x, y, width, height) = self.GetRect()
  5428.    grp.SetColor( self.color )
  5429.    grp.RenderBar( x, y, width, height )
  5430.  
  5431. class EditLineCentered(EditLine):
  5432.  def __init__(self):
  5433.   EditLine.__init__(self)
  5434.   self.basePos = (0, 0)
  5435.  
  5436.  def __del__(self):
  5437.   EditLine.__del__(self)
  5438.   del self.basePos
  5439.  
  5440.  def SetFocus(self):
  5441.   EditLine.SetFocus(self)
  5442.   self.AdjustTextPosition()
  5443.  
  5444.  def SetPosition(self, x, y):
  5445.   EditLine.SetPosition(self, x, y)
  5446.   self.basePos = (x, y)
  5447.   self.AdjustTextPosition()
  5448.  
  5449.  def OnIMEUpdate(self):
  5450.   EditLine.OnIMEUpdate(self)
  5451.   self.AdjustTextPosition()
  5452.  
  5453.  def SetText(self, text):
  5454.   EditLine.SetText(self, text)
  5455.   self.AdjustTextPosition()
  5456.  
  5457.  def OnMouseLeftButtonDown(self):
  5458.   if self.IsIn():
  5459.    EditLine.SetFocus(self)
  5460.    ime.SetCursorPosition(wndMgr.GetCursorPosition(self.hWnd))
  5461.  
  5462.  def AdjustTextPosition(self):
  5463.   (textX, textY) = EditLine.GetTextSize(self)
  5464.   (locX, locY) = self.basePos
  5465.   TextLine.SetPosition(self, locX + (self.GetWidth() / 2) - textX / 2, locY)
  5466.  
  5467. def MakeSlotBar(parent, x, y, width, height):
  5468.  slotBar = SlotBar()
  5469.  slotBar.SetParent(parent)
  5470.  slotBar.SetSize(width, height)
  5471.  slotBar.SetPosition(x, y)
  5472.  slotBar.Show()
  5473.  return slotBar
  5474.  
  5475. def MakeImageBox(parent, name, x, y):
  5476.  image = ImageBox()
  5477.  image.SetParent(parent)
  5478.  image.LoadImage(name)
  5479.  image.SetPosition(x, y)
  5480.  image.Show()
  5481.  return image
  5482.  
  5483. def MakeTextLine(parent):
  5484.  textLine = TextLine()
  5485.  textLine.SetParent(parent)
  5486.  textLine.SetWindowHorizontalAlignCenter()
  5487.  textLine.SetWindowVerticalAlignCenter()
  5488.  textLine.SetHorizontalAlignCenter()
  5489.  textLine.SetVerticalAlignCenter()
  5490.  textLine.Show()
  5491.  return textLine
  5492.  
  5493. def MakeButton(parent, x, y, tooltipText, path, up, over, down):
  5494.   butt
  5495.  button.SetParent(parent)
  5496.  button.SetPosition(x, y)
  5497.  button.SetUpVisual(path + up)
  5498.  button.SetOverVisual(path + over)
  5499.  button.SetDownVisual(path + down)
  5500.  button.SetToolTipText(tooltipText)
  5501.  button.Show()
  5502.  return button
  5503.  
  5504. def MakeText(parent, textlineText, x, y, color):
  5505.  textline = TextLine()
  5506.  if parent:
  5507.   textline.SetParent(parent)
  5508.  textline.SetPosition(x, y)
  5509.  if color:
  5510.   textline.SetFontColor(color[0], color[1], color[2])
  5511.  textline.SetText(textlineText)
  5512.  textline.Show()
  5513.  return textline
  5514.  
  5515. def MakeThinBoardCircle(parent, x, y, width, heigh, text, bnsId = 0):
  5516.  thin = RadioButton()
  5517.  thin.SetParent(parent)
  5518.  thin.SetSize(width, heigh)
  5519.  thin.SetPosition(x, y)
  5520.  thin.SetText(text)
  5521.  thin.SetBonusId(bnsId)
  5522.  thin.Show()
  5523.  return thin
  5524.  
  5525. def MakeRadioButton(parent, x, y, path, up, over, down):
  5526.   butt
  5527.  button.SetParent(parent)
  5528.  button.SetPosition(x, y)
  5529.  button.SetUpVisual(path + up)
  5530.  button.SetOverVisual(path + over)
  5531.  button.SetDownVisual(path + down)
  5532.  button.Show()
  5533.  return button
  5534.  
  5535. def RenderRoundBox(x, y, width, height, color):
  5536.  grp.SetColor(color)
  5537.  grp.RenderLine(x+2, y, width-3, 0)
  5538.  grp.RenderLine(x+2, y+height, width-3, 0)
  5539.  grp.RenderLine(x, y+2, 0, height-4)
  5540.  grp.RenderLine(x+width, y+1, 0, height-3)
  5541.  grp.RenderLine(x, y+2, 2, -2)
  5542.  grp.RenderLine(x, y+height-2, 2, 2)
  5543.  grp.RenderLine(x+width-2, y, 2, 2)
  5544.  grp.RenderLine(x+width-2, y+height, 2, -2)
  5545.  
  5546. def GenerateColor(r, g, b):
  5547.  r = float(r) / 255.0
  5548.  g = float(g) / 255.0
  5549.  b = float(b) / 255.0
  5550.  return grp.GenerateColor(r, g, b, 1.0)
  5551.  
  5552. def EnablePaste(flag):
  5553.  ime.EnablePaste(flag)
  5554.  
  5555. def GetHyperlink():
  5556.  return wndMgr.GetHyperlink()
  5557.  
  5558. RegisterToolTipWindow("TEXT", TextLine)
  5559.  
  5560. class RenderTarget(Window):
  5561.  
  5562.  def __init__(self, layer = "UI"):
  5563.   Window.__init__(self, layer)
  5564.    
  5565.   self.number = -1
  5566.  
  5567.  def __del__(self):
  5568.   Window.__del__(self)
  5569.  
  5570.  def RegisterWindow(self, layer):
  5571.   self.hWnd = wndMgr.RegisterRenderTarget(self, layer)
  5572.    
  5573.  def SetRenderTarget(self, number):
  5574.   self.number = number
  5575.   wndMgr.SetRenderTarget(self.hWnd, self.number)
  5576.  
  5577. class MoveTextLine(TextLine):
  5578.  def __init__(self):
  5579.   TextLine.__init__(self)
  5580.   self.end_move_event_func = None
  5581.   self.end_move_event_args = None
  5582.  
  5583.  def __del__(self):
  5584.   TextLine.__del__(self)
  5585.   self.end_move_event_func = None
  5586.   self.end_move_event_args = None
  5587.  
  5588.  def RegisterWindow(self, layer):
  5589.   self.hWnd = wndMgr.RegisterMoveTextLine(self, layer)
  5590.  
  5591.  def SetMovePosition(self, dst_x, dst_y):
  5592.   wndMgr.SetMovePosition(self.hWnd, dst_x, dst_y)
  5593.  
  5594.  def SetMoveSpeed(self, speed):
  5595.   wndMgr.SetMoveSpeed(self.hWnd, speed)
  5596.  
  5597.  def MoveStart(self):
  5598.   wndMgr.MoveStart(self.hWnd)
  5599.  def MoveStop(self):
  5600.   wndMgr.MoveStop(self.hWnd)
  5601.  def GetMove(self):
  5602.   return wndMgr.GetMove(self.hWnd)
  5603.  
  5604.  def OnEndMove(self):
  5605.   if self.end_move_event_func:
  5606.    apply(self.end_move_event_func, self.end_move_event_args)
  5607.  
  5608.  def SetEndMoveEvent(self, event, *args):
  5609.   self.end_move_event_func = event
  5610.   self.end_move_event_args = args
  5611.  
  5612. class MoveImageBox(ImageBox):
  5613.  def __init__(self, layer = "UI"):
  5614.   ImageBox.__init__(self, layer)
  5615.   self.end_move_event = None
  5616.  
  5617.  def __del__(self):
  5618.   ImageBox.__del__(self)
  5619.   self.end_move_event = None
  5620.  
  5621.  def RegisterWindow(self, layer):
  5622.   self.hWnd = wndMgr.RegisterMoveImageBox(self, layer)
  5623.  
  5624.  def MoveStart(self):
  5625.   wndMgr.MoveStart(self.hWnd)
  5626.  def MoveStop(self):
  5627.   wndMgr.MoveStop(self.hWnd)
  5628.  def GetMove(self):
  5629.   return wndMgr.GetMove(self.hWnd)
  5630.  
  5631.  def SetMovePosition(self, dst_x, dst_y):
  5632.   wndMgr.SetMovePosition(self.hWnd, dst_x, dst_y)
  5633.  
  5634.  def SetMoveSpeed(self, speed):
  5635.   wndMgr.SetMoveSpeed(self.hWnd, speed)
  5636.  
  5637.  def OnEndMove(self):
  5638.   if self.end_move_event:
  5639.    self.end_move_event()
  5640.  
  5641.  def SetEndMoveEvent(self, event):
  5642.   self.end_move_event = event
  5643.  
  5644. class MoveScaleImageBox(MoveImageBox):
  5645.  def __init__(self, layer = "UI"):
  5646.   MoveImageBox.__init__(self, layer)
  5647.  
  5648.  def __del__(self):
  5649.   MoveImageBox.__del__(self)
  5650.  
  5651.  def RegisterWindow(self, layer):
  5652.   self.hWnd = wndMgr.RegisterMoveScaleImageBox(self, layer)
  5653.  
  5654.  def SetMaxScale(self, scale):
  5655.   wndMgr.SetMaxScale(self.hWnd, scale)
  5656.  
  5657.  def SetMaxScaleRate(self, pivot):
  5658.   wndMgr.SetMaxScaleRate(self.hWnd, pivot)
  5659.  
  5660.  def SetScalePivotCenter(self, flag):
  5661.   wndMgr.SetScalePivotCenter(self.hWnd, flag)
  5662.  
  5663.