Guest User

Untitled

a guest
Nov 28th, 2023
14
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
Python 126.42 KB | Gaming | 0 0
  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.  
  14. from _weakref import proxy
  15.  
  16. BACKGROUND_COLOR = grp.GenerateColor(0.0, 0.0, 0.0, 1.0)
  17. DARK_COLOR = grp.GenerateColor(0.2, 0.2, 0.2, 1.0)
  18. BRIGHT_COLOR = grp.GenerateColor(0.7, 0.7, 0.7, 1.0)
  19.  
  20. if localeInfo.IsCANADA():
  21.     SELECT_COLOR = grp.GenerateColor(0.9, 0.03, 0.01, 0.4)
  22. else:
  23.     SELECT_COLOR = grp.GenerateColor(0.0, 0.0, 0.5, 0.3)
  24.  
  25. WHITE_COLOR = grp.GenerateColor(1.0, 1.0, 1.0, 0.5)
  26. HALF_WHITE_COLOR = grp.GenerateColor(1.0, 1.0, 1.0, 0.2)
  27.  
  28. createToolTipWindowDict = {}
  29. def RegisterCandidateWindowClass(codePage, candidateWindowClass):
  30.     EditLine.candidateWindowClassDict[codePage]=candidateWindowClass
  31. def RegisterToolTipWindow(type, createToolTipWindow):
  32.     createToolTipWindowDict[type]=createToolTipWindow
  33.  
  34. app.SetDefaultFontName(localeInfo.UI_DEF_FONT)
  35.  
  36. ## Window Manager Event List##
  37. ##############################
  38. ## "OnMouseLeftButtonDown"
  39. ## "OnMouseLeftButtonUp"
  40. ## "OnMouseLeftButtonDoubleClick"
  41. ## "OnMouseRightButtonDown"
  42. ## "OnMouseRightButtonUp"
  43. ## "OnMouseRightButtonDoubleClick"
  44. ## "OnMouseDrag"
  45. ## "OnSetFocus"
  46. ## "OnKillFocus"
  47. ## "OnMouseOverIn"
  48. ## "OnMouseOverOut"
  49. ## "OnRender"
  50. ## "OnUpdate"
  51. ## "OnKeyDown"
  52. ## "OnKeyUp"
  53. ## "OnTop"
  54. ## "OnIMEUpdate" ## IME Only
  55. ## "OnIMETab"   ## IME Only
  56. ## "OnIMEReturn" ## IME Only
  57. ##############################
  58. ## Window Manager Event List##
  59.  
  60.  
  61. class __mem_func__:
  62.     class __noarg_call__:
  63.         def __init__(self, cls, obj, func):
  64.             self.cls=cls
  65.             self.obj=proxy(obj)
  66.             self.func=proxy(func)
  67.  
  68.         def __call__(self, *arg):
  69.             return self.func(self.obj)
  70.  
  71.     class __arg_call__:
  72.         def __init__(self, cls, obj, func):
  73.             self.cls=cls
  74.             self.obj=proxy(obj)
  75.             self.func=proxy(func)
  76.  
  77.         def __call__(self, *arg):
  78.             return self.func(self.obj, *arg)
  79.  
  80.     def __init__(self, mfunc):
  81.         if mfunc.im_func.func_code.co_argcount>1:
  82.             self.call=__mem_func__.__arg_call__(mfunc.im_class, mfunc.im_self, mfunc.im_func)
  83.         else:
  84.             self.call=__mem_func__.__noarg_call__(mfunc.im_class, mfunc.im_self, mfunc.im_func)
  85.  
  86.     def __call__(self, *arg):
  87.         return self.call(*arg)
  88.  
  89.  
  90. class Window(object):
  91.     def NoneMethod(cls):
  92.         pass
  93.  
  94.     NoneMethod = classmethod(NoneMethod)
  95.  
  96.     def __init__(self, layer = "UI"):
  97.         self.hWnd = None
  98.         self.parentWindow = 0
  99.         self.onMouseLeftButtonUpEvent = None
  100.         self.RegisterWindow(layer)
  101.         self.Hide()
  102.        
  103.         if app.ENABLE_SEND_TARGET_INFO:
  104.             self.mouseLeftButtonDownEvent = None
  105.             self.mouseLeftButtonDownArgs = None
  106.             self.mouseLeftButtonUpEvent = None
  107.             self.mouseLeftButtonUpArgs = None
  108.             self.mouseLeftButtonDoubleClickEvent = None
  109.             self.mouseRightButtonDownEvent = None
  110.             self.mouseRightButtonDownArgs = None
  111.             self.moveWindowEvent = None
  112.             self.renderEvent = None
  113.             self.renderArgs = None
  114.  
  115.             self.overInEvent = None
  116.             self.overInArgs = None
  117.  
  118.             self.overOutEvent = None
  119.             self.overOutArgs = None
  120.  
  121.             self.baseX = 0
  122.             self.baseY = 0
  123.  
  124.             self.SetWindowName("NONAME_Window")
  125.  
  126.     def __del__(self):
  127.         wndMgr.Destroy(self.hWnd)
  128.  
  129.     def RegisterWindow(self, layer):
  130.         self.hWnd = wndMgr.Register(self, layer)
  131.  
  132.     def Destroy(self):
  133.         pass
  134.  
  135.     def GetWindowHandle(self):
  136.         return self.hWnd
  137.  
  138.     def AddFlag(self, style):
  139.         wndMgr.AddFlag(self.hWnd, style)
  140.  
  141.     def IsRTL(self):
  142.         return wndMgr.IsRTL(self.hWnd)
  143.  
  144.     def SetWindowName(self, Name):
  145.         wndMgr.SetName(self.hWnd, Name)
  146.  
  147.     def GetWindowName(self):
  148.         return wndMgr.GetName(self.hWnd)
  149.  
  150.     if app.ENABLE_SEND_TARGET_INFO:
  151.         def SetParent(self, parent):
  152.             if parent:
  153.                 wndMgr.SetParent(self.hWnd, parent.hWnd)
  154.             else:
  155.                 wndMgr.SetParent(self.hWnd, 0)
  156.    
  157.         def SetAttachParent(self, parent):
  158.             wndMgr.SetAttachParent(self.hWnd, parent.hWnd)
  159.     else:
  160.         def SetParent(self, parent):
  161.             wndMgr.SetParent(self.hWnd, parent.hWnd)
  162.  
  163.     def SetParentProxy(self, parent):
  164.         self.parentWindow=proxy(parent)
  165.         wndMgr.SetParent(self.hWnd, parent.hWnd)
  166.  
  167.    
  168.     def GetParentProxy(self):
  169.         return self.parentWindow
  170.  
  171.     def SetPickAlways(self):
  172.         wndMgr.SetPickAlways(self.hWnd)
  173.  
  174.     def SetWindowHorizontalAlignLeft(self):
  175.         wndMgr.SetWindowHorizontalAlign(self.hWnd, wndMgr.HORIZONTAL_ALIGN_LEFT)
  176.  
  177.     def SetWindowHorizontalAlignCenter(self):
  178.         wndMgr.SetWindowHorizontalAlign(self.hWnd, wndMgr.HORIZONTAL_ALIGN_CENTER)
  179.  
  180.     def SetWindowHorizontalAlignRight(self):
  181.         wndMgr.SetWindowHorizontalAlign(self.hWnd, wndMgr.HORIZONTAL_ALIGN_RIGHT)
  182.  
  183.     def SetWindowVerticalAlignTop(self):
  184.         wndMgr.SetWindowVerticalAlign(self.hWnd, wndMgr.VERTICAL_ALIGN_TOP)
  185.  
  186.     def SetWindowVerticalAlignCenter(self):
  187.         wndMgr.SetWindowVerticalAlign(self.hWnd, wndMgr.VERTICAL_ALIGN_CENTER)
  188.  
  189.     def SetWindowVerticalAlignBottom(self):
  190.         wndMgr.SetWindowVerticalAlign(self.hWnd, wndMgr.VERTICAL_ALIGN_BOTTOM)
  191.  
  192.     def SetTop(self):
  193.         wndMgr.SetTop(self.hWnd)
  194.  
  195.     def Show(self):
  196.         wndMgr.Show(self.hWnd)
  197.  
  198.     def Hide(self):
  199.         wndMgr.Hide(self.hWnd)
  200.  
  201.     if app.ENABLE_SEND_TARGET_INFO:
  202.         def SetVisible(self, is_show):
  203.             if is_show:
  204.                 self.Show()
  205.             else:
  206.                 self.Hide()
  207.        
  208.     def Lock(self):
  209.         wndMgr.Lock(self.hWnd)
  210.  
  211.     def Unlock(self):
  212.         wndMgr.Unlock(self.hWnd)
  213.  
  214.     def IsShow(self):
  215.         return wndMgr.IsShow(self.hWnd)
  216.  
  217.     def UpdateRect(self):
  218.         wndMgr.UpdateRect(self.hWnd)
  219.  
  220.     def SetSize(self, width, height):
  221.         wndMgr.SetWindowSize(self.hWnd, width, height)
  222.  
  223.     def GetWidth(self):
  224.         return wndMgr.GetWindowWidth(self.hWnd)
  225.  
  226.     def GetHeight(self):
  227.         return wndMgr.GetWindowHeight(self.hWnd)
  228.  
  229.     def GetLocalPosition(self):
  230.         return wndMgr.GetWindowLocalPosition(self.hWnd)
  231.  
  232.     if app.ENABLE_SEND_TARGET_INFO:
  233.         def GetLeft(self):
  234.             x, y = self.GetLocalPosition()
  235.             return x
  236.    
  237.         def GetGlobalLeft(self):
  238.             x, y = self.GetGlobalPosition()
  239.             return x
  240.    
  241.         def GetTop(self):
  242.             x, y = self.GetLocalPosition()
  243.             return y
  244.    
  245.         def GetGlobalTop(self):
  246.             x, y = self.GetGlobalPosition()
  247.             return y
  248.    
  249.         def GetRight(self):
  250.             return self.GetLeft() + self.GetWidth()
  251.    
  252.         def GetBottom(self):
  253.             return self.GetTop() + self.GetHeight()
  254.  
  255.        
  256.     def GetGlobalPosition(self):
  257.         return wndMgr.GetWindowGlobalPosition(self.hWnd)
  258.  
  259.     def GetMouseLocalPosition(self):
  260.         return wndMgr.GetMouseLocalPosition(self.hWnd)
  261.  
  262.     def GetRect(self):
  263.         return wndMgr.GetWindowRect(self.hWnd)
  264.     if app.ENABLE_SEND_TARGET_INFO:
  265.         def SetLeft(self, x):
  266.             wndMgr.SetWindowPosition(self.hWnd, x, self.GetTop())
  267.  
  268.     def SetPosition(self, x, y):
  269.         wndMgr.SetWindowPosition(self.hWnd, x, y)
  270.  
  271.     def SetCenterPosition(self, x = 0, y = 0):
  272.         self.SetPosition((wndMgr.GetScreenWidth() - self.GetWidth()) / 2 + x, (wndMgr.GetScreenHeight() - self.GetHeight()) / 2 + y)
  273.     if app.ENABLE_SEND_TARGET_INFO:
  274.         def SavePosition(self):
  275.             self.baseX = self.GetLeft()
  276.             self.baseY = self.GetTop()
  277.    
  278.         def UpdatePositionByScale(self, scale):
  279.             self.SetPosition(self.baseX * scale, self.baseY * scale)
  280.  
  281.     def IsFocus(self):
  282.         return wndMgr.IsFocus(self.hWnd)
  283.  
  284.     def SetFocus(self):
  285.         wndMgr.SetFocus(self.hWnd)
  286.  
  287.     def KillFocus(self):
  288.         wndMgr.KillFocus(self.hWnd)
  289.  
  290.     def GetChildCount(self):
  291.         return wndMgr.GetChildCount(self.hWnd)
  292.  
  293.     def IsIn(self):
  294.         return wndMgr.IsIn(self.hWnd)
  295.  
  296.     if app.ENABLE_SEND_TARGET_INFO:
  297.         def SetMouseLeftButtonUpEvent(self, event, *args):
  298.             self.mouseLeftButtonUpEvent = event
  299.             self.mouseLeftButtonUpArgs = args
  300.     else:
  301.         def SetOnMouseLeftButtonUpEvent(self, event):
  302.             self.onMouseLeftButtonUpEvent = ev
  303.  
  304.     if app.ENABLE_SEND_TARGET_INFO:
  305.         def SetMouseLeftButtonDoubleClickEvent(self, event):
  306.             self.mouseLeftButtonDoubleClickEvent = event
  307.    
  308.         def OnMouseLeftButtonDoubleClick(self):
  309.             if self.mouseLeftButtonDoubleClickEvent:
  310.                 self.mouseLeftButtonDoubleClickEvent()
  311.    
  312.         def SetMouseRightButtonDownEvent(self, event, *args):
  313.             self.mouseRightButtonDownEvent = event
  314.             self.mouseRightButtonDownArgs = args
  315.    
  316.         def OnMouseRightButtonDown(self):
  317.             if self.mouseRightButtonDownEvent:
  318.                 apply(self.mouseRightButtonDownEvent, self.mouseRightButtonDownArgs)
  319.    
  320.         def SetMoveWindowEvent(self, event):
  321.             self.moveWindowEvent = event
  322.    
  323.         def OnMoveWindow(self, x, y):
  324.             if self.moveWindowEvent:
  325.                 self.moveWindowEvent(x, y)
  326.    
  327.         def SAFE_SetOverInEvent(self, func, *args):
  328.             self.overInEvent = __mem_func__(func)
  329.             self.overInArgs = args
  330.    
  331.         def SetOverInEvent(self, func, *args):
  332.             self.overInEvent = func
  333.             self.overInArgs = args
  334.    
  335.         def SAFE_SetOverOutEvent(self, func, *args):
  336.             self.overOutEvent = __mem_func__(func)
  337.             self.overOutArgs = args
  338.    
  339.         def SetOverOutEvent(self, func, *args):
  340.             self.overOutEvent = func
  341.             self.overOutArgs = args
  342.    
  343.         def OnMouseOverIn(self):
  344.             if self.overInEvent:
  345.                 apply(self.overInEvent, self.overInArgs)
  346.    
  347.         def OnMouseOverOut(self):
  348.             if self.overOutEvent:
  349.                 apply(self.overOutEvent, self.overOutArgs)
  350.    
  351.         def SAFE_SetRenderEvent(self, event, *args):
  352.             self.renderEvent = __mem_func__(event)
  353.             self.renderArgs = args
  354.    
  355.         def ClearRenderEvent(self):
  356.             self.renderEvent = None
  357.             self.renderArgs = None
  358.    
  359.         def OnRender(self):
  360.             if self.renderEvent:
  361.                 apply(self.renderEvent, self.renderArgs)
  362.  
  363.     def OnMouseLeftButtonUp(self):
  364.         if self.onMouseLeftButtonUpEvent:
  365.             self.onMouseLeftButtonUpEvent()
  366.     if app.ENABLE_SEND_TARGET_INFO:
  367.         def IsInPosition(self):
  368.             xMouse, yMouse = wndMgr.GetMousePosition()
  369.             x, y = self.GetGlobalPosition()
  370.             return xMouse >= x and xMouse < x + self.GetWidth() and yMouse >= y and yMouse < y + self.GetHeight()
  371.    
  372.         def SetMouseLeftButtonDownEvent(self, event, *args):
  373.             self.mouseLeftButtonDownEvent = event
  374.             self.mouseLeftButtonDownArgs = args
  375.    
  376.         def OnMouseLeftButtonDown(self):
  377.             if self.mouseLeftButtonDownEvent:
  378.                 apply(self.mouseLeftButtonDownEvent, self.mouseLeftButtonDownArgs)
  379.  
  380. class ListBoxEx(Window):
  381.  
  382.     class Item(Window):
  383.         def __init__(self):
  384.             Window.__init__(self)
  385.  
  386.         def __del__(self):
  387.             Window.__del__(self)
  388.  
  389.         def SetParent(self, parent):
  390.             Window.SetParent(self, parent)
  391.             self.parent=proxy(parent)
  392.  
  393.         def OnMouseLeftButtonDown(self):
  394.             self.parent.SelectItem(self)
  395.  
  396.         def OnRender(self):
  397.             if self.parent.GetSelectedItem()==self:
  398.                 self.OnSelectedRender()
  399.  
  400.         def OnSelectedRender(self):
  401.             x, y = self.GetGlobalPosition()
  402.             grp.SetColor(grp.GenerateColor(0.0, 0.0, 0.7, 0.7))
  403.             grp.RenderBar(x, y, self.GetWidth(), self.GetHeight())
  404.  
  405.     def __init__(self):
  406.         Window.__init__(self)
  407.  
  408.         self.viewItemCount=10
  409.         self.basePos=0
  410.         self.itemHeight=16
  411.         self.itemStep=20
  412.         self.selItem=0
  413.         self.itemList=[]
  414.         self.onSelectItemEvent = lambda *arg: None
  415.  
  416.         if localeInfo.IsARABIC():
  417.             self.itemWidth=130
  418.         else:
  419.             self.itemWidth=100
  420.  
  421.         self.scrollBar=None
  422.         self.__UpdateSize()
  423.  
  424.     def __del__(self):
  425.         Window.__del__(self)
  426.  
  427.     def __UpdateSize(self):
  428.         height=self.itemStep*self.__GetViewItemCount()
  429.  
  430.         self.SetSize(self.itemWidth, height)
  431.  
  432.     def IsEmpty(self):
  433.         if len(self.itemList)==0:
  434.             return 1
  435.         return 0
  436.  
  437.     def SetItemStep(self, itemStep):
  438.         self.itemStep=itemStep
  439.         self.__UpdateSize()
  440.  
  441.     def SetItemSize(self, itemWidth, itemHeight):
  442.         self.itemWidth=itemWidth
  443.         self.itemHeight=itemHeight
  444.         self.__UpdateSize()
  445.  
  446.     def SetViewItemCount(self, viewItemCount):
  447.         self.viewItemCount=viewItemCount
  448.  
  449.     def SetSelectEvent(self, event):
  450.         self.onSelectItemEvent = event
  451.  
  452.     def SetBasePos(self, basePos):
  453.         for oldItem in self.itemList[self.basePos:self.basePos+self.viewItemCount]:
  454.             oldItem.Hide()
  455.  
  456.         self.basePos=basePos
  457.  
  458.         pos=basePos
  459.         for newItem in self.itemList[self.basePos:self.basePos+self.viewItemCount]:
  460.             (x, y)=self.GetItemViewCoord(pos, newItem.GetWidth())
  461.             newItem.SetPosition(x, y)
  462.             newItem.Show()
  463.             pos+=1
  464.  
  465.     def GetItemIndex(self, argItem):
  466.         return self.itemList.index(argItem)
  467.  
  468.     def GetSelectedItem(self):
  469.         return self.selItem
  470.  
  471.     def SelectIndex(self, index):
  472.  
  473.         if index >= len(self.itemList) or index < 0:
  474.             self.selItem = None
  475.             return
  476.  
  477.         try:
  478.             self.selItem=self.itemList[index]
  479.         except:
  480.             pass
  481.  
  482.     def SelectItem(self, selItem):
  483.         self.selItem=selItem
  484.         self.onSelectItemEvent(selItem)
  485.  
  486.     def RemoveAllItems(self):
  487.         self.selItem=None
  488.         self.itemList=[]
  489.  
  490.         if self.scrollBar:
  491.             self.scrollBar.SetPos(0)
  492.  
  493.     def RemoveItem(self, delItem):
  494.         if delItem==self.selItem:
  495.             self.selItem=None
  496.  
  497.         self.itemList.remove(delItem)
  498.  
  499.     def AppendItem(self, newItem):
  500.         newItem.SetParent(self)
  501.         newItem.SetSize(self.itemWidth, self.itemHeight)
  502.  
  503.         pos=len(self.itemList)
  504.         if self.__IsInViewRange(pos):
  505.             (x, y)=self.GetItemViewCoord(pos, newItem.GetWidth())
  506.             newItem.SetPosition(x, y)
  507.             newItem.Show()
  508.         else:
  509.             newItem.Hide()
  510.  
  511.         self.itemList.append(newItem)
  512.  
  513.     def SetScrollBar(self, scrollBar):
  514.         scrollBar.SetScrollEvent(__mem_func__(self.__OnScroll))
  515.         self.scrollBar=scrollBar
  516.  
  517.     def __OnScroll(self):
  518.         self.SetBasePos(int(self.scrollBar.GetPos()*self.__GetScrollLen()))
  519.  
  520.     def __GetScrollLen(self):
  521.         scrollLen=self.__GetItemCount()-self.__GetViewItemCount()
  522.         if scrollLen<0:
  523.             return 0
  524.  
  525.         return scrollLen
  526.  
  527.     def __GetViewItemCount(self):
  528.         return self.viewItemCount
  529.  
  530.     def __GetItemCount(self):
  531.         return len(self.itemList)
  532.  
  533.     def GetItemViewCoord(self, pos, itemWidth):
  534.         if localeInfo.IsARABIC():
  535.             return (self.GetWidth()-itemWidth-10, (pos-self.basePos)*self.itemStep)
  536.         else:
  537.             return (0, (pos-self.basePos)*self.itemStep)
  538.  
  539.     def __IsInViewRange(self, pos):
  540.         if pos<self.basePos:
  541.             return 0
  542.         if pos>=self.basePos+self.viewItemCount:
  543.             return 0
  544.         return 1
  545.  
  546. if app.ENABLE_SEND_TARGET_INFO:
  547.     class ListBoxExNew(Window):
  548.         class Item(Window):
  549.             def __init__(self):
  550.                 Window.__init__(self)
  551.  
  552.                 self.realWidth = 0
  553.                 self.realHeight = 0
  554.  
  555.                 self.removeTop = 0
  556.                 self.removeBottom = 0
  557.  
  558.                 self.SetWindowName("NONAME_ListBoxExNew_Item")
  559.  
  560.             def __del__(self):
  561.                 Window.__del__(self)
  562.  
  563.             def SetParent(self, parent):
  564.                 Window.SetParent(self, parent)
  565.                 self.parent=proxy(parent)
  566.  
  567.             def SetSize(self, width, height):
  568.                 self.realWidth = width
  569.                 self.realHeight = height
  570.                 Window.SetSize(self, width, height)
  571.  
  572.             def SetRemoveTop(self, height):
  573.                 self.removeTop = height
  574.                 self.RefreshHeight()
  575.  
  576.             def SetRemoveBottom(self, height):
  577.                 self.removeBottom = height
  578.                 self.RefreshHeight()
  579.  
  580.             def SetCurrentHeight(self, height):
  581.                 Window.SetSize(self, self.GetWidth(), height)
  582.  
  583.             def GetCurrentHeight(self):
  584.                 return Window.GetHeight(self)
  585.  
  586.             def ResetCurrentHeight(self):
  587.                 self.removeTop = 0
  588.                 self.removeBottom = 0
  589.                 self.RefreshHeight()
  590.  
  591.             def RefreshHeight(self):
  592.                 self.SetCurrentHeight(self.GetHeight() - self.removeTop - self.removeBottom)
  593.  
  594.             def GetHeight(self):
  595.                 return self.realHeight
  596.  
  597.         def __init__(self, stepSize, viewSteps):
  598.             Window.__init__(self)
  599.  
  600.             self.viewItemCount=10
  601.             self.basePos=0
  602.             self.baseIndex=0
  603.             self.maxSteps=0
  604.             self.viewSteps = viewSteps
  605.             self.stepSize = stepSize
  606.             self.itemList=[]
  607.  
  608.             self.scrollBar=None
  609.  
  610.             self.SetWindowName("NONAME_ListBoxEx")
  611.  
  612.         def __del__(self):
  613.             Window.__del__(self)
  614.  
  615.         def IsEmpty(self):
  616.             if len(self.itemList)==0:
  617.                 return 1
  618.             return 0
  619.  
  620.         def __CheckBasePos(self, pos):
  621.             self.viewItemCount = 0
  622.  
  623.             start_pos = pos
  624.  
  625.             height = 0
  626.             while height < self.GetHeight():
  627.                 if pos >= len(self.itemList):
  628.                     return start_pos == 0
  629.                 height += self.itemList[pos].GetHeight()
  630.                 pos += 1
  631.                 self.viewItemCount += 1
  632.             return height == self.GetHeight()
  633.  
  634.         def SetBasePos(self, basePos, forceRefresh = TRUE):
  635.             if forceRefresh == FALSE and self.basePos == basePos:
  636.                 return
  637.  
  638.             for oldItem in self.itemList[self.baseIndex:self.baseIndex+self.viewItemCount]:
  639.                 oldItem.ResetCurrentHeight()
  640.                 oldItem.Hide()
  641.  
  642.             self.basePos=basePos
  643.  
  644.             baseIndex = 0
  645.             while basePos > 0:
  646.                 basePos -= self.itemList[baseIndex].GetHeight() / self.stepSize
  647.                 if basePos < 0:
  648.                     self.itemList[baseIndex].SetRemoveTop(self.stepSize * abs(basePos))
  649.                     break
  650.                 baseIndex += 1
  651.             self.baseIndex = baseIndex
  652.  
  653.             stepCount = 0
  654.             self.viewItemCount = 0
  655.             while baseIndex < len(self.itemList):
  656.                 stepCount += self.itemList[baseIndex].GetCurrentHeight() / self.stepSize
  657.                 self.viewItemCount += 1
  658.                 if stepCount > self.viewSteps:
  659.                     self.itemList[baseIndex].SetRemoveBottom(self.stepSize * (stepCount - self.viewSteps))
  660.                     break
  661.                 elif stepCount == self.viewSteps:
  662.                     break
  663.                 baseIndex += 1
  664.  
  665.             y = 0
  666.             for newItem in self.itemList[self.baseIndex:self.baseIndex+self.viewItemCount]:
  667.                 newItem.SetPosition(0, y)
  668.                 newItem.Show()
  669.                 y += newItem.GetCurrentHeight()
  670.  
  671.         def GetItemIndex(self, argItem):
  672.             return self.itemList.index(argItem)
  673.  
  674.         def GetSelectedItem(self):
  675.             return self.selItem
  676.  
  677.         def GetSelectedItemIndex(self):
  678.             return self.selItemIdx
  679.  
  680.         def RemoveAllItems(self):
  681.             self.itemList=[]
  682.             self.maxSteps=0
  683.  
  684.             if self.scrollBar:
  685.                 self.scrollBar.SetPos(0)
  686.  
  687.         def RemoveItem(self, delItem):
  688.             self.maxSteps -= delItem.GetHeight() / self.stepSize
  689.             self.itemList.remove(delItem)
  690.  
  691.         def AppendItem(self, newItem):
  692.             if newItem.GetHeight() % self.stepSize != 0:
  693.                 import dbg
  694.                 dbg.TraceError("Invalid AppendItem height %d stepSize %d" % (newItem.GetHeight(), self.stepSize))
  695.                 return
  696.  
  697.             self.maxSteps += newItem.GetHeight() / self.stepSize
  698.             newItem.SetParent(self)
  699.             self.itemList.append(newItem)
  700.  
  701.         def SetScrollBar(self, scrollBar):
  702.             scrollBar.SetScrollEvent(__mem_func__(self.__OnScroll))
  703.             self.scrollBar=scrollBar
  704.  
  705.         def __OnScroll(self):
  706.             self.SetBasePos(int(self.scrollBar.GetPos()*self.__GetScrollLen()), FALSE)
  707.  
  708.         def __GetScrollLen(self):
  709.             scrollLen=self.maxSteps-self.viewSteps
  710.             if scrollLen<0:
  711.                 return 0
  712.  
  713.             return scrollLen
  714.  
  715.         def __GetViewItemCount(self):
  716.             return self.viewItemCount
  717.  
  718.         def __GetItemCount(self):
  719.             return len(self.itemList)
  720.  
  721.         def GetViewItemCount(self):
  722.             return self.viewItemCount
  723.  
  724.         def GetItemCount(self):
  725.             return len(self.itemList)
  726.  
  727.        
  728. class CandidateListBox(ListBoxEx):
  729.  
  730.     HORIZONTAL_MODE = 0
  731.     VERTICAL_MODE = 1
  732.  
  733.     class Item(ListBoxEx.Item):
  734.         def __init__(self, text):
  735.             ListBoxEx.Item.__init__(self)
  736.  
  737.             self.textBox=TextLine()
  738.             self.textBox.SetParent(self)
  739.             self.textBox.SetText(text)
  740.             self.textBox.Show()
  741.  
  742.         def __del__(self):
  743.             ListBoxEx.Item.__del__(self)
  744.  
  745.     def __init__(self, mode = HORIZONTAL_MODE):
  746.         ListBoxEx.__init__(self)
  747.         self.itemWidth=32
  748.         self.itemHeight=32
  749.         self.mode = mode
  750.  
  751.     def __del__(self):
  752.         ListBoxEx.__del__(self)
  753.  
  754.     def SetMode(self, mode):
  755.         self.mode = mode
  756.  
  757.     def AppendItem(self, newItem):
  758.         ListBoxEx.AppendItem(self, newItem)
  759.  
  760.     def GetItemViewCoord(self, pos):
  761.         if self.mode == self.HORIZONTAL_MODE:
  762.             return ((pos-self.basePos)*self.itemStep, 0)
  763.         elif self.mode == self.VERTICAL_MODE:
  764.             return (0, (pos-self.basePos)*self.itemStep)
  765.  
  766.  
  767. class TextLine(Window):
  768.     def __init__(self):
  769.         Window.__init__(self)
  770.         self.max = 0
  771.         self.SetFontName(localeInfo.UI_DEF_FONT)
  772.  
  773.     def __del__(self):
  774.         Window.__del__(self)
  775.  
  776.     def RegisterWindow(self, layer):
  777.         self.hWnd = wndMgr.RegisterTextLine(self, layer)
  778.  
  779.     def SetMax(self, max):
  780.         wndMgr.SetMax(self.hWnd, max)
  781.  
  782.     def SetLimitWidth(self, width):
  783.         wndMgr.SetLimitWidth(self.hWnd, width)
  784.  
  785.     def SetMultiLine(self):
  786.         wndMgr.SetMultiLine(self.hWnd, True)
  787.  
  788.     def SetHorizontalAlignArabic(self):
  789.         wndMgr.SetHorizontalAlign(self.hWnd, wndMgr.TEXT_HORIZONTAL_ALIGN_ARABIC)
  790.  
  791.     def SetHorizontalAlignLeft(self):
  792.         wndMgr.SetHorizontalAlign(self.hWnd, wndMgr.TEXT_HORIZONTAL_ALIGN_LEFT)
  793.  
  794.     def SetHorizontalAlignRight(self):
  795.         wndMgr.SetHorizontalAlign(self.hWnd, wndMgr.TEXT_HORIZONTAL_ALIGN_RIGHT)
  796.  
  797.     def SetHorizontalAlignCenter(self):
  798.         wndMgr.SetHorizontalAlign(self.hWnd, wndMgr.TEXT_HORIZONTAL_ALIGN_CENTER)
  799.  
  800.     def SetVerticalAlignTop(self):
  801.         wndMgr.SetVerticalAlign(self.hWnd, wndMgr.TEXT_VERTICAL_ALIGN_TOP)
  802.  
  803.     def SetVerticalAlignBottom(self):
  804.         wndMgr.SetVerticalAlign(self.hWnd, wndMgr.TEXT_VERTICAL_ALIGN_BOTTOM)
  805.  
  806.     def SetVerticalAlignCenter(self):
  807.         wndMgr.SetVerticalAlign(self.hWnd, wndMgr.TEXT_VERTICAL_ALIGN_CENTER)
  808.  
  809.     def SetSecret(self, Value=True):
  810.         wndMgr.SetSecret(self.hWnd, Value)
  811.  
  812.     def SetOutline(self, Value=True):
  813.         wndMgr.SetOutline(self.hWnd, Value)
  814.  
  815.     def SetFeather(self, value=True):
  816.         wndMgr.SetFeather(self.hWnd, value)
  817.  
  818.     def SetFontName(self, fontName):
  819.         wndMgr.SetFontName(self.hWnd, fontName)
  820.  
  821.     def SetDefaultFontName(self):
  822.         wndMgr.SetFontName(self.hWnd, localeInfo.UI_DEF_FONT)
  823.  
  824.     def SetFontColor(self, red, green, blue):
  825.         wndMgr.SetFontColor(self.hWnd, red, green, blue)
  826.  
  827.     def SetPackedFontColor(self, color):
  828.         wndMgr.SetFontColor(self.hWnd, color)
  829.  
  830.     def SetText(self, text):
  831.         wndMgr.SetText(self.hWnd, text)
  832.  
  833.     def GetText(self):
  834.         return wndMgr.GetText(self.hWnd)
  835.  
  836.     def GetTextSize(self):
  837.         return wndMgr.GetTextSize(self.hWnd)
  838.  
  839. class EmptyCandidateWindow(Window):
  840.     def __init__(self):
  841.         Window.__init__(self)
  842.  
  843.     def __del__(self):
  844.         Window.__init__(self)
  845.  
  846.     def Load(self):
  847.         pass
  848.  
  849.     def SetCandidatePosition(self, x, y, textCount):
  850.         pass
  851.  
  852.     def Clear(self):
  853.         pass
  854.  
  855.     def Append(self, text):
  856.         pass
  857.  
  858.     def Refresh(self):
  859.         pass
  860.  
  861.     def Select(self):
  862.         pass
  863.  
  864. class EditLine(TextLine):
  865.     candidateWindowClassDict = {}
  866.  
  867.     def __init__(self):
  868.         TextLine.__init__(self)
  869.  
  870.         self.eventReturn = Window.NoneMethod
  871.         self.eventEscape = Window.NoneMethod
  872.         self.eventTab = None
  873.         self.numberMode = False
  874.         self.useIME = True
  875.  
  876.         self.bCodePage = False
  877.  
  878.         self.candidateWindowClass = None
  879.         self.candidateWindow = None
  880.         self.SetCodePage(app.GetDefaultCodePage())
  881.  
  882.         self.readingWnd = ReadingWnd()
  883.         self.readingWnd.Hide()
  884.  
  885.     def __del__(self):
  886.         TextLine.__del__(self)
  887.  
  888.         self.eventReturn = Window.NoneMethod
  889.         self.eventEscape = Window.NoneMethod
  890.         self.eventTab = None
  891.  
  892.  
  893.     def SetCodePage(self, codePage):
  894.         candidateWindowClass=EditLine.candidateWindowClassDict.get(codePage, EmptyCandidateWindow)
  895.         self.__SetCandidateClass(candidateWindowClass)
  896.  
  897.     def __SetCandidateClass(self, candidateWindowClass):
  898.         if self.candidateWindowClass==candidateWindowClass:
  899.             return
  900.  
  901.         self.candidateWindowClass = candidateWindowClass
  902.         self.candidateWindow = self.candidateWindowClass()
  903.         self.candidateWindow.Load()
  904.         self.candidateWindow.Hide()
  905.  
  906.     def RegisterWindow(self, layer):
  907.         self.hWnd = wndMgr.RegisterTextLine(self, layer)
  908.  
  909.     def SAFE_SetReturnEvent(self, event):
  910.         self.eventReturn = __mem_func__(event)     
  911.  
  912.     def SetReturnEvent(self, event):
  913.         self.eventReturn = event
  914.  
  915.     def SetEscapeEvent(self, event):
  916.         self.eventEscape = event
  917.  
  918.     def SetTabEvent(self, event):
  919.         self.eventTab = event
  920.  
  921.     def SetMax(self, max):
  922.         self.max = max
  923.         wndMgr.SetMax(self.hWnd, self.max)
  924.         ime.SetMax(self.max)
  925.         self.SetUserMax(self.max)
  926.        
  927.     def SetUserMax(self, max):
  928.         self.userMax = max
  929.         ime.SetUserMax(self.userMax)
  930.  
  931.     def SetNumberMode(self):
  932.         self.numberMode = True
  933.  
  934.     #def AddExceptKey(self, key):
  935.     #   ime.AddExceptKey(key)
  936.  
  937.     #def ClearExceptKey(self):
  938.     #   ime.ClearExceptKey()
  939.  
  940.     def SetIMEFlag(self, flag):
  941.         self.useIME = flag
  942.  
  943.     def SetText(self, text):
  944.         wndMgr.SetText(self.hWnd, text)
  945.  
  946.         if self.IsFocus():
  947.             ime.SetText(text)
  948.  
  949.     def Enable(self):
  950.         wndMgr.ShowCursor(self.hWnd)
  951.  
  952.     def Disable(self):
  953.         wndMgr.HideCursor(self.hWnd)
  954.  
  955.     def SetEndPosition(self):
  956.         ime.MoveEnd()
  957.  
  958.     def OnSetFocus(self):
  959.         Text = self.GetText()
  960.         ime.SetText(Text)
  961.         ime.SetMax(self.max)
  962.         ime.SetUserMax(self.userMax)
  963.         ime.SetCursorPosition(-1)
  964.         if self.numberMode:
  965.             ime.SetNumberMode()
  966.         else:
  967.             ime.SetStringMode()
  968.         ime.EnableCaptureInput()
  969.         if self.useIME:
  970.             ime.EnableIME()
  971.         else:
  972.             ime.DisableIME()
  973.         wndMgr.ShowCursor(self.hWnd, True)
  974.  
  975.     def OnKillFocus(self):
  976.         self.SetText(ime.GetText(self.bCodePage))
  977.         self.OnIMECloseCandidateList()
  978.         self.OnIMECloseReadingWnd()
  979.         ime.DisableIME()
  980.         ime.DisableCaptureInput()
  981.         wndMgr.HideCursor(self.hWnd)
  982.  
  983.     def OnIMEChangeCodePage(self):
  984.         self.SetCodePage(ime.GetCodePage())
  985.  
  986.     def OnIMEOpenCandidateList(self):
  987.         self.candidateWindow.Show()
  988.         self.candidateWindow.Clear()
  989.         self.candidateWindow.Refresh()
  990.  
  991.         gx, gy = self.GetGlobalPosition()
  992.         self.candidateWindow.SetCandidatePosition(gx, gy, len(self.GetText()))
  993.  
  994.         return True
  995.  
  996.     def OnIMECloseCandidateList(self):
  997.         self.candidateWindow.Hide()
  998.         return True
  999.  
  1000.     def OnIMEOpenReadingWnd(self):
  1001.         gx, gy = self.GetGlobalPosition()
  1002.         textlen = len(self.GetText())-2    
  1003.         reading = ime.GetReading()
  1004.         readinglen = len(reading)
  1005.         self.readingWnd.SetReadingPosition( gx + textlen*6-24-readinglen*6, gy )
  1006.         self.readingWnd.SetText(reading)
  1007.         if ime.GetReadingError() == 0:
  1008.             self.readingWnd.SetTextColor(0xffffffff)
  1009.         else:
  1010.             self.readingWnd.SetTextColor(0xffff0000)
  1011.         self.readingWnd.SetSize(readinglen * 6 + 4, 19)
  1012.         self.readingWnd.Show()
  1013.         return True
  1014.  
  1015.     def OnIMECloseReadingWnd(self):
  1016.         self.readingWnd.Hide()
  1017.         return True
  1018.  
  1019.     def OnIMEUpdate(self):
  1020.         snd.PlaySound("sound/ui/type.wav")
  1021.         TextLine.SetText(self, ime.GetText(self.bCodePage))
  1022.  
  1023.     def OnIMETab(self):
  1024.         if self.eventTab:
  1025.             self.eventTab()
  1026.             return True
  1027.  
  1028.         return False
  1029.  
  1030.     def OnIMEReturn(self):
  1031.         snd.PlaySound("sound/ui/click.wav")
  1032.         self.eventReturn()
  1033.  
  1034.         return True
  1035.  
  1036.     def OnPressEscapeKey(self):
  1037.         self.eventEscape()
  1038.         return True
  1039.  
  1040.     def OnKeyDown(self, key):
  1041.         if app.DIK_F1 == key:
  1042.             return False
  1043.         if app.DIK_F2 == key:
  1044.             return False
  1045.         if app.DIK_F3 == key:
  1046.             return False
  1047.         if app.DIK_F4 == key:
  1048.             return False
  1049.         if app.DIK_LALT == key:
  1050.             return False
  1051.         if app.DIK_SYSRQ == key:
  1052.             return False
  1053.         if app.DIK_LCONTROL == key:
  1054.             return False
  1055.         if app.DIK_V == key:
  1056.             if app.IsPressed(app.DIK_LCONTROL):
  1057.                 ime.PasteTextFromClipBoard()
  1058.  
  1059.         return True
  1060.  
  1061.     def OnKeyUp(self, key):
  1062.         if app.DIK_F1 == key:
  1063.             return False
  1064.         if app.DIK_F2 == key:
  1065.             return False
  1066.         if app.DIK_F3 == key:
  1067.             return False
  1068.         if app.DIK_F4 == key:
  1069.             return False
  1070.         if app.DIK_LALT == key:
  1071.             return False
  1072.         if app.DIK_SYSRQ == key:
  1073.             return False
  1074.         if app.DIK_LCONTROL == key:
  1075.             return False
  1076.  
  1077.         return True
  1078.  
  1079.     def OnIMEKeyDown(self, key):       
  1080.         # Left
  1081.         if app.VK_LEFT == key:
  1082.             ime.MoveLeft()
  1083.             return True
  1084.         # Right
  1085.         if app.VK_RIGHT == key:
  1086.             ime.MoveRight()
  1087.             return True
  1088.  
  1089.         # Home
  1090.         if app.VK_HOME == key:
  1091.             ime.MoveHome()
  1092.             return True
  1093.         # End
  1094.         if app.VK_END == key:
  1095.             ime.MoveEnd()
  1096.             return True
  1097.  
  1098.         # Delete
  1099.         if app.VK_DELETE == key:
  1100.             ime.Delete()
  1101.             TextLine.SetText(self, ime.GetText(self.bCodePage))
  1102.             return True
  1103.            
  1104.         return True
  1105.  
  1106.     #def OnMouseLeftButtonDown(self):
  1107.     #   self.SetFocus()
  1108.     def OnMouseLeftButtonDown(self):
  1109.         if False == self.IsIn():
  1110.             return False
  1111.  
  1112.         self.SetFocus()
  1113.         PixelPosition = wndMgr.GetCursorPosition(self.hWnd)
  1114.         ime.SetCursorPosition(PixelPosition)
  1115.  
  1116. class MarkBox(Window):
  1117.     def __init__(self, layer = "UI"):
  1118.         Window.__init__(self, layer)
  1119.  
  1120.     def __del__(self):
  1121.         Window.__del__(self)
  1122.  
  1123.     def RegisterWindow(self, layer):
  1124.         self.hWnd = wndMgr.RegisterMarkBox(self, layer)
  1125.  
  1126.     def Load(self):
  1127.         wndMgr.MarkBox_Load(self.hWnd)
  1128.  
  1129.     def SetScale(self, scale):
  1130.         wndMgr.MarkBox_SetScale(self.hWnd, scale)
  1131.  
  1132.     def SetIndex(self, guildID):
  1133.         MarkID = guild.GuildIDToMarkID(guildID)
  1134.         wndMgr.MarkBox_SetImageFilename(self.hWnd, guild.GetMarkImageFilenameByMarkID(MarkID))
  1135.         wndMgr.MarkBox_SetIndex(self.hWnd, guild.GetMarkIndexByMarkID(MarkID))
  1136.  
  1137.     def SetAlpha(self, alpha):
  1138.         wndMgr.MarkBox_SetDiffuseColor(self.hWnd, 1.0, 1.0, 1.0, alpha)
  1139.  
  1140. class ImageBox(Window):
  1141.     def __init__(self, layer = "UI"):
  1142.         Window.__init__(self, layer)
  1143.  
  1144.         self.eventDict={}
  1145.         self.eventFunc = {"mouse_click" : None, "mouse_over_in" : None, "mouse_over_out" : None}
  1146.         self.eventArgs = {"mouse_click" : None, "mouse_over_in" : None, "mouse_over_out" : None}
  1147.  
  1148.  
  1149.     def __del__(self):
  1150.         Window.__del__(self)
  1151.         self.eventFunc = None
  1152.         self.eventArgs = None
  1153.  
  1154.     def RegisterWindow(self, layer):
  1155.         self.hWnd = wndMgr.RegisterImageBox(self, layer)
  1156.  
  1157.     def LoadImage(self, imageName):
  1158.         self.name=imageName
  1159.         wndMgr.LoadImage(self.hWnd, imageName)
  1160.  
  1161.         if len(self.eventDict)!=0:
  1162.             print "LOAD IMAGE", self, self.eventDict
  1163.  
  1164.     def SetAlpha(self, alpha):
  1165.         wndMgr.SetDiffuseColor(self.hWnd, 1.0, 1.0, 1.0, alpha)
  1166.  
  1167.     def GetWidth(self):
  1168.         return wndMgr.GetWidth(self.hWnd)
  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,isa=FALSE):
  1186.         if not isa:
  1187.             self.eventDict[event]=__mem_func__(func)
  1188.         else:
  1189.             self.eventDict[event]=func
  1190.        
  1191.     if app.BL_PRIVATESHOP_SEARCH_SYSTEM:
  1192.         def LeftRightReverse(self):
  1193.             wndMgr.LeftRightReverseImageBox(self.hWnd)
  1194.    
  1195.     def SetEvent(self, func, *args) :
  1196.         result = self.eventFunc.has_key(args[0])
  1197.         if result :
  1198.             self.eventFunc[args[0]] = func
  1199.             self.eventArgs[args[0]] = args
  1200.         else :
  1201.             print "[ERROR] ui.py SetEvent, Can`t Find has_key : %s" % args[0]
  1202.  
  1203.     def OnMouseLeftButtonUp(self) :
  1204.         if self.eventFunc["mouse_click"] :
  1205.             apply(self.eventFunc["mouse_click"], self.eventArgs["mouse_click"])
  1206.  
  1207.     def OnMouseOverIn(self) :
  1208.         if self.eventFunc["mouse_over_in"] :
  1209.             apply(self.eventFunc["mouse_over_in"], self.eventArgs["mouse_over_in"])
  1210.         else:
  1211.             try:
  1212.                 self.eventDict["MOUSE_OVER_IN"]()
  1213.             except KeyError:
  1214.                 pass
  1215.  
  1216.     def OnMouseOverOut(self) :
  1217.         if self.eventFunc["mouse_over_out"] :
  1218.             apply(self.eventFunc["mouse_over_out"], self.eventArgs["mouse_over_out"])
  1219.         else :
  1220.             try:
  1221.                 self.eventDict["MOUSE_OVER_OUT"]()
  1222.             except KeyError:
  1223.                 pass
  1224.    
  1225.     def SetOnMouseLeftButtonUpEvent(self, event, *args):
  1226.         self.eventFunc["MOUSE_LEFT_BUTTON_UP"] = event
  1227.         self.eventArgs["MOUSE_LEFT_BUTTON_UP"] = args
  1228.  
  1229.  
  1230. class ExpandedImageBox(ImageBox):
  1231.     def __init__(self, layer = "UI"):
  1232.         ImageBox.__init__(self, layer)
  1233.  
  1234.     def __del__(self):
  1235.         ImageBox.__del__(self)
  1236.  
  1237.     def RegisterWindow(self, layer):
  1238.         self.hWnd = wndMgr.RegisterExpandedImageBox(self, layer)
  1239.  
  1240.     def SetScale(self, xScale, yScale):
  1241.         wndMgr.SetScale(self.hWnd, xScale, yScale)
  1242.  
  1243.     def SetOrigin(self, x, y):
  1244.         wndMgr.SetOrigin(self.hWnd, x, y)
  1245.  
  1246.     def SetRotation(self, rotation):
  1247.         wndMgr.SetRotation(self.hWnd, rotation)
  1248.  
  1249.     def SetRenderingMode(self, mode):
  1250.         wndMgr.SetRenderingMode(self.hWnd, mode)
  1251.  
  1252.     # [0.0, 1.0] »ηΐΜΐΗ °�ΈΈΕ­ ΖΫΌΎΖ®·Ξ ±ΧΈ®Αφ ΎΚ΄Β΄Ω.
  1253.     def SetRenderingRect(self, left, top, right, bottom):
  1254.         wndMgr.SetRenderingRect(self.hWnd, left, top, right, bottom)
  1255.  
  1256.     def SetPercentage(self, curValue, maxValue):
  1257.         if maxValue:
  1258.             self.SetRenderingRect(0.0, 0.0, -1.0 + float(curValue) / float(maxValue), 0.0)
  1259.         else:
  1260.             self.SetRenderingRect(0.0, 0.0, 0.0, 0.0)
  1261.  
  1262.     def GetWidth(self):
  1263.         return wndMgr.GetWindowWidth(self.hWnd)
  1264.  
  1265.     def GetHeight(self):
  1266.         return wndMgr.GetWindowHeight(self.hWnd)
  1267.  
  1268. class AniImageBox(Window):
  1269.     def __init__(self, layer = "UI"):
  1270.         Window.__init__(self, layer)
  1271.  
  1272.     def __del__(self):
  1273.         Window.__del__(self)
  1274.  
  1275.     def RegisterWindow(self, layer):
  1276.         self.hWnd = wndMgr.RegisterAniImageBox(self, layer)
  1277.  
  1278.     def SetDelay(self, delay):
  1279.         wndMgr.SetDelay(self.hWnd, delay)
  1280.  
  1281.     def AppendImage(self, filename):
  1282.         wndMgr.AppendImage(self.hWnd, filename)
  1283.  
  1284.     def SetPercentage(self, curValue, maxValue):
  1285.         wndMgr.SetRenderingRect(self.hWnd, 0.0, 0.0, -1.0 + float(curValue) / float(maxValue), 0.0)
  1286.  
  1287.     def OnEndFrame(self):
  1288.         pass
  1289.  
  1290. class Button(Window):
  1291.     def __init__(self, layer = "UI"):
  1292.         Window.__init__(self, layer)
  1293.        
  1294.         if app.ENABLE_DETAILS_UI:
  1295.             self.overFunc = None
  1296.             self.overArgs = None
  1297.             self.overOutFunc = None
  1298.             self.overOutArgs = None
  1299.  
  1300.         self.eventFunc = None
  1301.         self.eventArgs = None
  1302.  
  1303.         self.ButtonText = None
  1304.         self.ToolTipText = None
  1305.  
  1306.     def __del__(self):
  1307.         Window.__del__(self)
  1308.        
  1309.         if app.ENABLE_DETAILS_UI:
  1310.             self.overFunc = None
  1311.             self.overArgs = None
  1312.             self.overOutFunc = None
  1313.             self.overOutArgs = None
  1314.  
  1315.         self.eventFunc = None
  1316.         self.eventArgs = None
  1317.  
  1318.     def RegisterWindow(self, layer):
  1319.         self.hWnd = wndMgr.RegisterButton(self, layer)
  1320.  
  1321.     def SetUpVisual(self, filename):
  1322.         wndMgr.SetUpVisual(self.hWnd, filename)
  1323.  
  1324.     def SetOverVisual(self, filename):
  1325.         wndMgr.SetOverVisual(self.hWnd, filename)
  1326.  
  1327.     def SetDownVisual(self, filename):
  1328.         wndMgr.SetDownVisual(self.hWnd, filename)
  1329.  
  1330.     def SetDisableVisual(self, filename):
  1331.         wndMgr.SetDisableVisual(self.hWnd, filename)
  1332.  
  1333.     def GetUpVisualFileName(self):
  1334.         return wndMgr.GetUpVisualFileName(self.hWnd)
  1335.  
  1336.     def GetOverVisualFileName(self):
  1337.         return wndMgr.GetOverVisualFileName(self.hWnd)
  1338.  
  1339.     def GetDownVisualFileName(self):
  1340.         return wndMgr.GetDownVisualFileName(self.hWnd)
  1341.  
  1342.     def Flash(self):
  1343.         wndMgr.Flash(self.hWnd)
  1344.  
  1345.     def Enable(self):
  1346.         wndMgr.Enable(self.hWnd)
  1347.  
  1348.     def Disable(self):
  1349.         wndMgr.Disable(self.hWnd)
  1350.  
  1351.     def Down(self):
  1352.         wndMgr.Down(self.hWnd)
  1353.  
  1354.     def SetUp(self):
  1355.         wndMgr.SetUp(self.hWnd)
  1356.  
  1357.     def SAFE_SetEvent(self, func, *args):
  1358.         self.eventFunc = __mem_func__(func)
  1359.         self.eventArgs = args
  1360.        
  1361.     def SetEvent(self, func, *args):
  1362.         self.eventFunc = func
  1363.         self.eventArgs = args
  1364.  
  1365.     def SetTextColor(self, color):
  1366.         if not self.ButtonText:
  1367.             return
  1368.         self.ButtonText.SetPackedFontColor(color)
  1369.  
  1370.     def SetText(self, text, height = 4):
  1371.  
  1372.         if not self.ButtonText:
  1373.             textLine = TextLine()
  1374.             textLine.SetParent(self)
  1375.             textLine.SetPosition(self.GetWidth()/2, self.GetHeight()/2)
  1376.             textLine.SetVerticalAlignCenter()
  1377.             textLine.SetHorizontalAlignCenter()
  1378.             textLine.Show()
  1379.             self.ButtonText = textLine
  1380.  
  1381.         self.ButtonText.SetText(text)
  1382.  
  1383.     def SetFormToolTipText(self, type, text, x, y):
  1384.         if not self.ToolTipText:       
  1385.             toolTip=createToolTipWindowDict[type]()
  1386.             toolTip.SetParent(self)
  1387.             toolTip.SetSize(0, 0)
  1388.             toolTip.SetHorizontalAlignCenter()
  1389.             toolTip.SetOutline()
  1390.             toolTip.Hide()
  1391.             toolTip.SetPosition(x + self.GetWidth()/2, y)
  1392.             self.ToolTipText=toolTip
  1393.  
  1394.         self.ToolTipText.SetText(text)
  1395.  
  1396.     def SetToolTipWindow(self, toolTip):       
  1397.         self.ToolTipText=toolTip       
  1398.         self.ToolTipText.SetParentProxy(self)
  1399.  
  1400.     def SetToolTipText(self, text, x=0, y = -19):
  1401.         self.SetFormToolTipText("TEXT", text, x, y)
  1402.  
  1403.     def CallEvent(self):
  1404.         snd.PlaySound("sound/ui/click.wav")
  1405.  
  1406.         if self.eventFunc:
  1407.             apply(self.eventFunc, self.eventArgs)
  1408.  
  1409.     def ShowToolTip(self):
  1410.         if self.ToolTipText:
  1411.             self.ToolTipText.Show()
  1412.  
  1413.     def HideToolTip(self):
  1414.         if self.ToolTipText:
  1415.             self.ToolTipText.Hide()
  1416.            
  1417.     def IsDown(self):
  1418.         return wndMgr.IsDown(self.hWnd)
  1419.  
  1420.     def GetText(self):
  1421.         if not self.ButtonText:
  1422.             return ""
  1423.         return self.ButtonText.GetText()
  1424.    
  1425.     if app.BL_PRIVATESHOP_SEARCH_SYSTEM:
  1426.         def SetAlpha(self, alpha):
  1427.             wndMgr.SetButtonDiffuseColor(self.hWnd, 1.0, 1.0, 1.0, alpha)
  1428.  
  1429.         def GetText(self):
  1430.             if self.ButtonText:
  1431.                 return self.ButtonText.GetText()
  1432.             else:
  1433.                 return ""
  1434.                
  1435.         def IsDIsable(self):
  1436.             return wndMgr.IsDisable(self.hWnd)
  1437.  
  1438.     if app.ENABLE_DETAILS_UI:
  1439.         def OnMouseOverIn(self):
  1440.             if self.overFunc:
  1441.                 apply(self.overFunc, self.overArgs )
  1442.         def OnMouseOverOut(self):
  1443.             if self.overOutFunc:
  1444.                 apply(self.overOutFunc, self.overOutArgs )
  1445.         def SetOverEvent(self, func, *args):
  1446.             self.overFunc = func
  1447.             self.overArgs = args
  1448.         def SetOverOutEvent(self, func, *args):
  1449.             self.overOutFunc = func
  1450.             self.overOutArgs = args
  1451.            
  1452. class RadioButton(Button):
  1453.     def __init__(self):
  1454.         Button.__init__(self)
  1455.  
  1456.     def __del__(self):
  1457.         Button.__del__(self)
  1458.  
  1459.     def RegisterWindow(self, layer):
  1460.         self.hWnd = wndMgr.RegisterRadioButton(self, layer)
  1461.  
  1462. class RadioButtonGroup:
  1463.     def __init__(self):
  1464.         self.buttonGroup = []
  1465.         self.selectedBtnIdx = -1
  1466.    
  1467.     def __del__(self):
  1468.         for button, ue, de in self.buttonGroup:
  1469.             button.__del__()
  1470.    
  1471.     def Show(self):
  1472.         for (button, selectEvent, unselectEvent) in self.buttonGroup:
  1473.             button.Show()
  1474.    
  1475.     def Hide(self):
  1476.         for (button, selectEvent, unselectEvent) in self.buttonGroup:
  1477.             button.Hide()
  1478.    
  1479.     def SetText(self, idx, text):
  1480.         if idx >= len(self.buttonGroup):
  1481.             return
  1482.         (button, selectEvent, unselectEvent) = self.buttonGroup[idx]
  1483.         button.SetText(text)
  1484.    
  1485.     def OnClick(self, btnIdx):
  1486.         if btnIdx == self.selectedBtnIdx:
  1487.             return
  1488.         (button, selectEvent, unselectEvent) = self.buttonGroup[self.selectedBtnIdx]
  1489.         if unselectEvent:
  1490.             unselectEvent()
  1491.         button.SetUp()
  1492.        
  1493.         self.selectedBtnIdx = btnIdx
  1494.         (button, selectEvent, unselectEvent) = self.buttonGroup[btnIdx]
  1495.         if selectEvent:
  1496.             selectEvent()
  1497.  
  1498.         button.Down()
  1499.        
  1500.     def AddButton(self, button, selectEvent, unselectEvent):
  1501.         i = len(self.buttonGroup)
  1502.         button.SetEvent(lambda : self.OnClick(i))
  1503.         self.buttonGroup.append([button, selectEvent, unselectEvent])
  1504.         button.SetUp()
  1505.  
  1506.     def Create(rawButtonGroup):
  1507.         radioGroup = RadioButtonGroup()
  1508.         for (button, selectEvent, unselectEvent) in rawButtonGroup:
  1509.             radioGroup.AddButton(button, selectEvent, unselectEvent)
  1510.        
  1511.         radioGroup.OnClick(0)
  1512.        
  1513.         return radioGroup
  1514.        
  1515.     Create=staticmethod(Create)
  1516.  
  1517. class ToggleButton(Button):
  1518.     def __init__(self):
  1519.         Button.__init__(self)
  1520.  
  1521.         self.eventUp = None
  1522.         self.eventDown = None
  1523.  
  1524.     def __del__(self):
  1525.         Button.__del__(self)
  1526.  
  1527.         self.eventUp = None
  1528.         self.eventDown = None
  1529.  
  1530.     def SetToggleUpEvent(self, event):
  1531.         self.eventUp = event
  1532.  
  1533.     def SetToggleDownEvent(self, event):
  1534.         self.eventDown = event
  1535.  
  1536.     def RegisterWindow(self, layer):
  1537.         self.hWnd = wndMgr.RegisterToggleButton(self, layer)
  1538.  
  1539.     def OnToggleUp(self):
  1540.         if self.eventUp:
  1541.             self.eventUp()
  1542.  
  1543.     def OnToggleDown(self):
  1544.         if self.eventDown:
  1545.             self.eventDown()
  1546.  
  1547. class DragButton(Button):
  1548.     def __init__(self):
  1549.         Button.__init__(self)
  1550.         self.AddFlag("movable")
  1551.  
  1552.         self.callbackEnable = True
  1553.         self.eventMove = lambda: None
  1554.  
  1555.     def __del__(self):
  1556.         Button.__del__(self)
  1557.  
  1558.         self.eventMove = lambda: None
  1559.  
  1560.     def RegisterWindow(self, layer):
  1561.         self.hWnd = wndMgr.RegisterDragButton(self, layer)
  1562.  
  1563.     def SetMoveEvent(self, event):
  1564.         self.eventMove = event
  1565.  
  1566.     def SetRestrictMovementArea(self, x, y, width, height):
  1567.         wndMgr.SetRestrictMovementArea(self.hWnd, x, y, width, height)
  1568.  
  1569.     def TurnOnCallBack(self):
  1570.         self.callbackEnable = True
  1571.  
  1572.     def TurnOffCallBack(self):
  1573.         self.callbackEnable = False
  1574.  
  1575.     def OnMove(self):
  1576.         if self.callbackEnable:
  1577.             self.eventMove()
  1578.  
  1579. class NumberLine(Window):
  1580.  
  1581.     def __init__(self, layer = "UI"):
  1582.         Window.__init__(self, layer)
  1583.  
  1584.     def __del__(self):
  1585.         Window.__del__(self)
  1586.  
  1587.     def RegisterWindow(self, layer):
  1588.         self.hWnd = wndMgr.RegisterNumberLine(self, layer)
  1589.  
  1590.     def SetHorizontalAlignCenter(self):
  1591.         wndMgr.SetNumberHorizontalAlignCenter(self.hWnd)
  1592.  
  1593.     def SetHorizontalAlignRight(self):
  1594.         wndMgr.SetNumberHorizontalAlignRight(self.hWnd)
  1595.  
  1596.     def SetPath(self, path):
  1597.         wndMgr.SetPath(self.hWnd, path)
  1598.  
  1599.     def SetNumber(self, number):
  1600.         wndMgr.SetNumber(self.hWnd, number)
  1601.  
  1602. ###################################################################################################
  1603. ## PythonScript Element
  1604. ###################################################################################################
  1605.  
  1606. class Box(Window):
  1607.  
  1608.     def RegisterWindow(self, layer):
  1609.         self.hWnd = wndMgr.RegisterBox(self, layer)
  1610.  
  1611.     def SetColor(self, color):
  1612.         wndMgr.SetColor(self.hWnd, color)
  1613.  
  1614. class Bar(Window):
  1615.  
  1616.     def RegisterWindow(self, layer):
  1617.         self.hWnd = wndMgr.RegisterBar(self, layer)
  1618.  
  1619.     def SetColor(self, color):
  1620.         wndMgr.SetColor(self.hWnd, color)
  1621.  
  1622. class Line(Window):
  1623.  
  1624.     def RegisterWindow(self, layer):
  1625.         self.hWnd = wndMgr.RegisterLine(self, layer)
  1626.  
  1627.     def SetColor(self, color):
  1628.         wndMgr.SetColor(self.hWnd, color)
  1629.  
  1630. class SlotBar(Window):
  1631.  
  1632.     def __init__(self):
  1633.         Window.__init__(self)
  1634.  
  1635.     def RegisterWindow(self, layer):
  1636.         self.hWnd = wndMgr.RegisterBar3D(self, layer)
  1637.  
  1638. ## Same with SlotBar
  1639. class Bar3D(Window):
  1640.  
  1641.     def __init__(self):
  1642.         Window.__init__(self)
  1643.  
  1644.     def RegisterWindow(self, layer):
  1645.         self.hWnd = wndMgr.RegisterBar3D(self, layer)
  1646.  
  1647.     def SetColor(self, left, right, center):
  1648.         wndMgr.SetColor(self.hWnd, left, right, center)
  1649.  
  1650. class SlotWindow(Window):
  1651.  
  1652.     def __init__(self):
  1653.         Window.__init__(self)
  1654.  
  1655.         self.StartIndex = 0
  1656.  
  1657.         self.eventSelectEmptySlot = None
  1658.         self.eventSelectItemSlot = None
  1659.         self.eventUnselectEmptySlot = None
  1660.         self.eventUnselectItemSlot = None
  1661.         self.eventUseSlot = None
  1662.         self.eventOverInItem = None
  1663.         self.eventOverOutItem = None
  1664.         self.eventPressedSlotButton = None
  1665.         self.eventOverInItem2 = None
  1666.         self.eventOverInItem3 = None
  1667.  
  1668.     def __del__(self):
  1669.         Window.__del__(self)
  1670.  
  1671.         self.eventSelectEmptySlot = None
  1672.         self.eventSelectItemSlot = None
  1673.         self.eventUnselectEmptySlot = None
  1674.         self.eventUnselectItemSlot = None
  1675.         self.eventUseSlot = None
  1676.         self.eventOverInItem = None
  1677.         self.eventOverOutItem = None
  1678.         self.eventPressedSlotButton = None
  1679.         self.eventOverInItem2 = None
  1680.         self.eventOverInItem3 = None
  1681.  
  1682.     def RegisterWindow(self, layer):
  1683.         self.hWnd = wndMgr.RegisterSlotWindow(self, layer)
  1684.  
  1685.     def SetSlotStyle(self, style):
  1686.         wndMgr.SetSlotStyle(self.hWnd, style)
  1687.  
  1688.     def HasSlot(self, slotIndex):
  1689.         return wndMgr.HasSlot(self.hWnd, slotIndex)
  1690.  
  1691.     def SetSlotBaseImage(self, imageFileName, r, g, b, a):
  1692.         wndMgr.SetSlotBaseImage(self.hWnd, imageFileName, r, g, b, a)
  1693.  
  1694.     def SetCoverButton(self,\
  1695.                         slotIndex,\
  1696.                         upName="d:/ymir work/ui/public/slot_cover_button_01.sub",\
  1697.                         overName="d:/ymir work/ui/public/slot_cover_button_02.sub",\
  1698.                         downName="d:/ymir work/ui/public/slot_cover_button_03.sub",\
  1699.                         disableName="d:/ymir work/ui/public/slot_cover_button_04.sub",\
  1700.                         LeftButtonEnable = False,\
  1701.                         RightButtonEnable = True):
  1702.         wndMgr.SetCoverButton(self.hWnd, slotIndex, upName, overName, downName, disableName, LeftButtonEnable, RightButtonEnable)
  1703.  
  1704.     def EnableCoverButton(self, slotIndex):
  1705.         wndMgr.EnableCoverButton(self.hWnd, slotIndex)
  1706.  
  1707.     def DisableCoverButton(self, slotIndex):
  1708.         wndMgr.DisableCoverButton(self.hWnd, slotIndex)
  1709.        
  1710.     def SetAlwaysRenderCoverButton(self, slotIndex, bAlwaysRender = TRUE):
  1711.         wndMgr.SetAlwaysRenderCoverButton(self.hWnd, slotIndex, bAlwaysRender)
  1712.  
  1713.     def AppendSlotButton(self, upName, overName, downName):
  1714.         wndMgr.AppendSlotButton(self.hWnd, upName, overName, downName)
  1715.  
  1716.     def ShowSlotButton(self, slotNumber):
  1717.         wndMgr.ShowSlotButton(self.hWnd, slotNumber)
  1718.  
  1719.     def HideAllSlotButton(self):
  1720.         wndMgr.HideAllSlotButton(self.hWnd)
  1721.  
  1722.     def AppendRequirementSignImage(self, filename):
  1723.         wndMgr.AppendRequirementSignImage(self.hWnd, filename)
  1724.  
  1725.     def ShowRequirementSign(self, slotNumber):
  1726.         wndMgr.ShowRequirementSign(self.hWnd, slotNumber)
  1727.  
  1728.     def HideRequirementSign(self, slotNumber):
  1729.         wndMgr.HideRequirementSign(self.hWnd, slotNumber)
  1730.  
  1731.     if app.ENABLE_SASH_SYSTEM:
  1732.         def ActivateSlot(self, slotNumber, r = 1.0, g = 1.0, b = 1.0, a = 1.0):
  1733.             wndMgr.ActivateEffect(self.hWnd, slotNumber, r, g, b, a)
  1734.  
  1735.         def DeactivateSlot(self, slotNumber):
  1736.             wndMgr.DeactivateEffect(self.hWnd, slotNumber)
  1737.  
  1738.         def ActivateSlotOld(self, slotNumber):
  1739.             wndMgr.ActivateSlot(self.hWnd, slotNumber)
  1740.  
  1741.         def DeactivateSlotOld(self, slotNumber):
  1742.             wndMgr.DeactivateSlot(self.hWnd, slotNumber)
  1743.     else:
  1744.         def ActivateSlot(self, slotNumber):
  1745.             wndMgr.ActivateSlot(self.hWnd, slotNumber)
  1746.  
  1747.         def DeactivateSlot(self, slotNumber):
  1748.             wndMgr.DeactivateSlot(self.hWnd, slotNumber)
  1749.  
  1750.     def ShowSlotBaseImage(self, slotNumber):
  1751.         wndMgr.ShowSlotBaseImage(self.hWnd, slotNumber)
  1752.  
  1753.     def HideSlotBaseImage(self, slotNumber):
  1754.         wndMgr.HideSlotBaseImage(self.hWnd, slotNumber)
  1755.  
  1756.     def SAFE_SetButtonEvent(self, button, state, event):
  1757.         if "LEFT"==button:
  1758.             if "EMPTY"==state:
  1759.                 self.eventSelectEmptySlot=__mem_func__(event)
  1760.             elif "EXIST"==state:
  1761.                 self.eventSelectItemSlot=__mem_func__(event)
  1762.             elif "ALWAYS"==state:
  1763.                 self.eventSelectEmptySlot=__mem_func__(event)
  1764.                 self.eventSelectItemSlot=__mem_func__(event)
  1765.         elif "RIGHT"==button:
  1766.             if "EMPTY"==state:
  1767.                 self.eventUnselectEmptySlot=__mem_func__(event)
  1768.             elif "EXIST"==state:
  1769.                 self.eventUnselectItemSlot=__mem_func__(event)
  1770.             elif "ALWAYS"==state:
  1771.                 self.eventUnselectEmptySlot=__mem_func__(event)
  1772.                 self.eventUnselectItemSlot=__mem_func__(event)
  1773.  
  1774.     def SetSelectEmptySlotEvent(self, empty):
  1775.         self.eventSelectEmptySlot = empty
  1776.  
  1777.     def SetSelectItemSlotEvent(self, item):
  1778.         self.eventSelectItemSlot = item
  1779.  
  1780.     def SetUnselectEmptySlotEvent(self, empty):
  1781.         self.eventUnselectEmptySlot = empty
  1782.  
  1783.     def SetUnselectItemSlotEvent(self, item):
  1784.         self.eventUnselectItemSlot = item
  1785.  
  1786.     def SetUseSlotEvent(self, use):
  1787.         self.eventUseSlot = use
  1788.  
  1789.     def SetOverInItemEvent(self, event):
  1790.         self.eventOverInItem = event
  1791.  
  1792.     def SetOverOutItemEvent(self, event):
  1793.         self.eventOverOutItem = event
  1794.  
  1795.     def SetPressedSlotButtonEvent(self, event):
  1796.         self.eventPressedSlotButton = event
  1797.  
  1798.     def GetSlotCount(self):
  1799.         return wndMgr.GetSlotCount(self.hWnd)
  1800.  
  1801.     def SetUseMode(self, flag):
  1802.         "TrueΐΟ¶§ΈΈ ItemToItem ΐΜ °΅΄ΙΗΡΑφ ΊΈΏ©ΑΨ΄Ω"
  1803.         wndMgr.SetUseMode(self.hWnd, flag)
  1804.  
  1805.     def SetUsableItem(self, flag):
  1806.         "TrueΈι Ηφΐη °΅Έ®Ε² ΎΖΐΜΕΫΐΜ ItemToItem ΐϋΏλ °΅΄ΙΗΟ΄Ω"
  1807.         wndMgr.SetUsableItem(self.hWnd, flag)
  1808.  
  1809.     ## Slot
  1810.     def SetSlotCoolTime(self, slotIndex, coolTime, elapsedTime = 0.0):
  1811.         wndMgr.SetSlotCoolTime(self.hWnd, slotIndex, coolTime, elapsedTime)
  1812.  
  1813.     def StoreSlotCoolTime(self, key, slotIndex, coolTime, elapsedTime = 0.0):
  1814.         wndMgr.StoreSlotCoolTime(self.hWnd, key, slotIndex, coolTime, elapsedTime)
  1815.    
  1816.     def RestoreSlotCoolTime(self, key):
  1817.         wndMgr.RestoreSlotCoolTime(self.hWnd, key)
  1818.  
  1819.     def DisableSlot(self, slotIndex):
  1820.         wndMgr.DisableSlot(self.hWnd, slotIndex)
  1821.  
  1822.     def EnableSlot(self, slotIndex):
  1823.         wndMgr.EnableSlot(self.hWnd, slotIndex)
  1824.  
  1825.     def LockSlot(self, slotIndex):
  1826.         wndMgr.LockSlot(self.hWnd, slotIndex)
  1827.  
  1828.     def UnlockSlot(self, slotIndex):
  1829.         wndMgr.UnlockSlot(self.hWnd, slotIndex)
  1830.  
  1831.     def RefreshSlot(self):
  1832.         wndMgr.RefreshSlot(self.hWnd)
  1833.  
  1834.     def ClearSlot(self, slotNumber):
  1835.         wndMgr.ClearSlot(self.hWnd, slotNumber)
  1836.  
  1837.     def ClearAllSlot(self):
  1838.         wndMgr.ClearAllSlot(self.hWnd)
  1839.  
  1840.     def AppendSlot(self, index, x, y, width, height):
  1841.         wndMgr.AppendSlot(self.hWnd, index, x, y, width, height)
  1842.  
  1843.     def SetSlot(self, slotIndex, itemIndex, width, height, icon, diffuseColor = (1.0, 1.0, 1.0, 1.0)):
  1844.         wndMgr.SetSlot(self.hWnd, slotIndex, itemIndex, width, height, icon, diffuseColor)
  1845.  
  1846.     def SetSlotCount(self, slotNumber, count):
  1847.         wndMgr.SetSlotCount(self.hWnd, slotNumber, count)
  1848.  
  1849.     def SetSlotCountNew(self, slotNumber, grade, count):
  1850.         wndMgr.SetSlotCountNew(self.hWnd, slotNumber, grade, count)
  1851.  
  1852.     def SetOverInItemEvent2(self, event):
  1853.         self.eventOverInItem2 = event
  1854.        
  1855.     def SetOverInItemEvent3(self, event):
  1856.         self.eventOverInItem3 = event
  1857.  
  1858.     def SetItemSlot(self, renderingSlotNumber, ItemIndex, ItemCount = 0, diffuseColor = (1.0, 1.0, 1.0, 1.0),id=0):
  1859.         if 0 == ItemIndex or None == ItemIndex:
  1860.             wndMgr.ClearSlot(self.hWnd, renderingSlotNumber)
  1861.             return
  1862.  
  1863.         item.SelectItem(ItemIndex)
  1864.         itemIcon = item.GetIconImage()
  1865.  
  1866.         item.SelectItem(ItemIndex)
  1867.         (width, height) = item.GetItemSize()   
  1868.         wndMgr.SetSlot(self.hWnd, renderingSlotNumber, ItemIndex, width, height, itemIcon, diffuseColor)   
  1869.         wndMgr.SetSlotCount(self.hWnd, renderingSlotNumber, ItemCount)
  1870.         wndMgr.SetSlotID(self.hWnd, renderingSlotNumber, id)
  1871.  
  1872.     def SetSkillSlot(self, renderingSlotNumber, skillIndex, skillLevel):
  1873.  
  1874.         skillIcon = skill.GetIconImage(skillIndex)
  1875.  
  1876.         if 0 == skillIcon:
  1877.             wndMgr.ClearSlot(self.hWnd, renderingSlotNumber)
  1878.             return
  1879.  
  1880.         wndMgr.SetSlot(self.hWnd, renderingSlotNumber, skillIndex, 1, 1, skillIcon)
  1881.         wndMgr.SetSlotCount(self.hWnd, renderingSlotNumber, skillLevel)
  1882.  
  1883.     def SetSkillSlotNew(self, renderingSlotNumber, skillIndex, skillGrade, skillLevel):
  1884.        
  1885.         skillIcon = skill.GetIconImageNew(skillIndex, skillGrade)
  1886.  
  1887.         if 0 == skillIcon:
  1888.             wndMgr.ClearSlot(self.hWnd, renderingSlotNumber)
  1889.             return
  1890.  
  1891.         wndMgr.SetSlot(self.hWnd, renderingSlotNumber, skillIndex, 1, 1, skillIcon)
  1892.  
  1893.     def SetEmotionSlot(self, renderingSlotNumber, emotionIndex):
  1894.         import player
  1895.         icon = player.GetEmotionIconImage(emotionIndex)
  1896.  
  1897.         if 0 == icon:
  1898.             wndMgr.ClearSlot(self.hWnd, renderingSlotNumber)
  1899.             return
  1900.  
  1901.         wndMgr.SetSlot(self.hWnd, renderingSlotNumber, emotionIndex, 1, 1, icon)
  1902.  
  1903.     ## Event
  1904.     def OnSelectEmptySlot(self, slotNumber):
  1905.         if self.eventSelectEmptySlot:
  1906.             self.eventSelectEmptySlot(slotNumber)
  1907.  
  1908.     def OnSelectItemSlot(self, slotNumber):
  1909.         if self.eventSelectItemSlot:
  1910.             self.eventSelectItemSlot(slotNumber)
  1911.  
  1912.     def OnUnselectEmptySlot(self, slotNumber):
  1913.         if self.eventUnselectEmptySlot:
  1914.             self.eventUnselectEmptySlot(slotNumber)
  1915.  
  1916.     def OnUnselectItemSlot(self, slotNumber):
  1917.         if self.eventUnselectItemSlot:
  1918.             self.eventUnselectItemSlot(slotNumber)
  1919.  
  1920.     def OnUseSlot(self, slotNumber):
  1921.         if self.eventUseSlot:
  1922.             self.eventUseSlot(slotNumber)
  1923.  
  1924.  
  1925.     def OnOverInItem(self, slotNumber,vnum=0,itemID=0):
  1926.         if self.eventOverInItem:
  1927.             self.eventOverInItem(slotNumber)
  1928.         if self.eventOverInItem2 and vnum>0:
  1929.             self.eventOverInItem2(vnum)
  1930.         if self.eventOverInItem3 and itemID>0:
  1931.             self.eventOverInItem3(itemID)
  1932.  
  1933.     def OnOverOutItem(self):
  1934.         if self.eventOverOutItem:
  1935.             self.eventOverOutItem()
  1936.  
  1937.     def OnPressedSlotButton(self, slotNumber):
  1938.         if self.eventPressedSlotButton:
  1939.             self.eventPressedSlotButton(slotNumber)
  1940.  
  1941.     def GetStartIndex(self):
  1942.         return 0
  1943.    
  1944.     if app.ENABLE_DSS_ACTIVE_EFFECT_BUTTON:
  1945.         def SetRenderSlot(self, renderingSlotNumber, diffuseColor = (1.0, 1.0, 1.0, 1.0)):
  1946.             wndMgr.SetSlot(self.hWnd, renderingSlotNumber, 1, 1, 1, 0, diffuseColor)
  1947.             wndMgr.SetSlotCount(self.hWnd, renderingSlotNumber, 0)
  1948.  
  1949. class GridSlotWindow(SlotWindow):
  1950.  
  1951.     def __init__(self):
  1952.         SlotWindow.__init__(self)
  1953.  
  1954.         self.startIndex = 0
  1955.  
  1956.     def __del__(self):
  1957.         SlotWindow.__del__(self)
  1958.  
  1959.     def RegisterWindow(self, layer):
  1960.         self.hWnd = wndMgr.RegisterGridSlotWindow(self, layer)
  1961.  
  1962.     def ArrangeSlot(self, StartIndex, xCount, yCount, xSize, ySize, xBlank, yBlank):
  1963.  
  1964.         self.startIndex = StartIndex
  1965.  
  1966.         wndMgr.ArrangeSlot(self.hWnd, StartIndex, xCount, yCount, xSize, ySize, xBlank, yBlank)
  1967.         self.startIndex = StartIndex
  1968.  
  1969.     def GetStartIndex(self):
  1970.         return self.startIndex
  1971.  
  1972. class TitleBar(Window):
  1973.  
  1974.     BLOCK_WIDTH = 32
  1975.     BLOCK_HEIGHT = 23
  1976.  
  1977.     def __init__(self):
  1978.         Window.__init__(self)
  1979.         self.AddFlag("attach")
  1980.  
  1981.     def __del__(self):
  1982.         Window.__del__(self)
  1983.  
  1984.     def MakeTitleBar(self, width, color):
  1985.  
  1986.         ## Ηφΐη Color΄Β »ηΏλΗΟ°ν ΐΦΑφ ΎΚΐ½
  1987.  
  1988.         width = max(64, width)
  1989.  
  1990.         imgLeft = ImageBox()
  1991.         imgCenter = ExpandedImageBox()
  1992.         imgRight = ImageBox()
  1993.         imgLeft.AddFlag("not_pick")
  1994.         imgCenter.AddFlag("not_pick")
  1995.         imgRight.AddFlag("not_pick")
  1996.         imgLeft.SetParent(self)
  1997.         imgCenter.SetParent(self)
  1998.         imgRight.SetParent(self)
  1999.  
  2000.         if localeInfo.IsARABIC():
  2001.             imgLeft.LoadImage("locale/ae/ui/pattern/titlebar_left.tga")
  2002.             imgCenter.LoadImage("locale/ae/ui/pattern/titlebar_center.tga")
  2003.             imgRight.LoadImage("locale/ae/ui/pattern/titlebar_right.tga")
  2004.         else:
  2005.             imgLeft.LoadImage("d:/ymir work/ui/pattern/titlebar_left.tga")
  2006.             imgCenter.LoadImage("d:/ymir work/ui/pattern/titlebar_center.tga")
  2007.             imgRight.LoadImage("d:/ymir work/ui/pattern/titlebar_right.tga")
  2008.  
  2009.         imgLeft.Show()
  2010.         imgCenter.Show()
  2011.         imgRight.Show()
  2012.  
  2013.         btnClose = Button()
  2014.         btnClose.SetParent(self)
  2015.         btnClose.SetUpVisual("d:/ymir work/ui/public/close_button_01.sub")
  2016.         btnClose.SetOverVisual("d:/ymir work/ui/public/close_button_02.sub")
  2017.         btnClose.SetDownVisual("d:/ymir work/ui/public/close_button_03.sub")
  2018.         btnClose.SetToolTipText(localeInfo.UI_CLOSE, 0, -23)
  2019.         btnClose.Show()
  2020.  
  2021.         self.imgLeft = imgLeft
  2022.         self.imgCenter = imgCenter
  2023.         self.imgRight = imgRight
  2024.         self.btnClose = btnClose
  2025.  
  2026.         self.SetWidth(width)
  2027.  
  2028.     def SetWidth(self, width):
  2029.         self.imgCenter.SetRenderingRect(0.0, 0.0, float((width - self.BLOCK_WIDTH*2) - self.BLOCK_WIDTH) / self.BLOCK_WIDTH, 0.0)
  2030.         self.imgCenter.SetPosition(self.BLOCK_WIDTH, 0)
  2031.         self.imgRight.SetPosition(width - self.BLOCK_WIDTH, 0)
  2032.  
  2033.         if localeInfo.IsARABIC():
  2034.             self.btnClose.SetPosition(3, 3)
  2035.         else:
  2036.             self.btnClose.SetPosition(width - self.btnClose.GetWidth() - 3, 3)
  2037.            
  2038.         self.SetSize(width, self.BLOCK_HEIGHT)
  2039.  
  2040.     def SetCloseEvent(self, event):
  2041.         self.btnClose.SetEvent(event)
  2042.    
  2043.     if app.ENABLE_DETAILS_UI:
  2044.         def CloseButtonHide(self) :
  2045.             if localeInfo.IsARABIC():
  2046.                 self.imgLeft.LoadImage("d:/ymir work/ui/pattern/titlebar_right_02.tga")
  2047.                 self.imgLeft.LeftRightReverse()
  2048.                 self.btnClose.Hide()
  2049.             else:
  2050.                 self.imgRight.LoadImage("d:/ymir work/ui/pattern/titlebar_right_02.tga")
  2051.                 self.btnClose.Hide()
  2052.  
  2053. class HorizontalBar(Window):
  2054.  
  2055.     BLOCK_WIDTH = 32
  2056.     BLOCK_HEIGHT = 17
  2057.  
  2058.     def __init__(self):
  2059.         Window.__init__(self)
  2060.         self.AddFlag("attach")
  2061.  
  2062.     def __del__(self):
  2063.         Window.__del__(self)
  2064.  
  2065.     def Create(self, width):
  2066.  
  2067.         width = max(96, width)
  2068.  
  2069.         imgLeft = ImageBox()
  2070.         imgLeft.SetParent(self)
  2071.         imgLeft.AddFlag("not_pick")
  2072.         imgLeft.LoadImage("d:/ymir work/ui/pattern/horizontalbar_left.tga")
  2073.         imgLeft.Show()
  2074.  
  2075.         imgCenter = ExpandedImageBox()
  2076.         imgCenter.SetParent(self)
  2077.         imgCenter.AddFlag("not_pick")
  2078.         imgCenter.LoadImage("d:/ymir work/ui/pattern/horizontalbar_center.tga")
  2079.         imgCenter.Show()
  2080.  
  2081.         imgRight = ImageBox()
  2082.         imgRight.SetParent(self)
  2083.         imgRight.AddFlag("not_pick")
  2084.         imgRight.LoadImage("d:/ymir work/ui/pattern/horizontalbar_right.tga")
  2085.         imgRight.Show()
  2086.  
  2087.         self.imgLeft = imgLeft
  2088.         self.imgCenter = imgCenter
  2089.         self.imgRight = imgRight
  2090.         self.SetWidth(width)
  2091.  
  2092.     def SetWidth(self, width):
  2093.         self.imgCenter.SetRenderingRect(0.0, 0.0, float((width - self.BLOCK_WIDTH*2) - self.BLOCK_WIDTH) / self.BLOCK_WIDTH, 0.0)
  2094.         self.imgCenter.SetPosition(self.BLOCK_WIDTH, 0)
  2095.         self.imgRight.SetPosition(width - self.BLOCK_WIDTH, 0)
  2096.         self.SetSize(width, self.BLOCK_HEIGHT)
  2097.  
  2098. class Gauge(Window):
  2099.  
  2100.     SLOT_WIDTH = 16
  2101.     SLOT_HEIGHT = 7
  2102.  
  2103.     GAUGE_TEMPORARY_PLACE = 12
  2104.     GAUGE_WIDTH = 16
  2105.  
  2106.     def __init__(self):
  2107.         Window.__init__(self)
  2108.         self.width = 0
  2109.     def __del__(self):
  2110.         Window.__del__(self)
  2111.  
  2112.     def MakeGauge(self, width, color):
  2113.  
  2114.         self.width = max(48, width)
  2115.  
  2116.         imgSlotLeft = ImageBox()
  2117.         imgSlotLeft.SetParent(self)
  2118.         imgSlotLeft.LoadImage("d:/ymir work/ui/pattern/gauge_slot_left.tga")
  2119.         imgSlotLeft.Show()
  2120.  
  2121.         imgSlotRight = ImageBox()
  2122.         imgSlotRight.SetParent(self)
  2123.         imgSlotRight.LoadImage("d:/ymir work/ui/pattern/gauge_slot_right.tga")
  2124.         imgSlotRight.Show()
  2125.         imgSlotRight.SetPosition(width - self.SLOT_WIDTH, 0)
  2126.  
  2127.         imgSlotCenter = ExpandedImageBox()
  2128.         imgSlotCenter.SetParent(self)
  2129.         imgSlotCenter.LoadImage("d:/ymir work/ui/pattern/gauge_slot_center.tga")
  2130.         imgSlotCenter.Show()
  2131.         imgSlotCenter.SetRenderingRect(0.0, 0.0, float((width - self.SLOT_WIDTH*2) - self.SLOT_WIDTH) / self.SLOT_WIDTH, 0.0)
  2132.         imgSlotCenter.SetPosition(self.SLOT_WIDTH, 0)
  2133.  
  2134.         imgGauge = ExpandedImageBox()
  2135.         imgGauge.SetParent(self)
  2136.         imgGauge.LoadImage("d:/ymir work/ui/pattern/gauge_" + color + ".tga")
  2137.         imgGauge.Show()
  2138.         imgGauge.SetRenderingRect(0.0, 0.0, 0.0, 0.0)
  2139.         imgGauge.SetPosition(self.GAUGE_TEMPORARY_PLACE, 0)
  2140.  
  2141.         imgSlotLeft.AddFlag("attach")
  2142.         imgSlotCenter.AddFlag("attach")
  2143.         imgSlotRight.AddFlag("attach")
  2144.  
  2145.         self.imgLeft = imgSlotLeft
  2146.         self.imgCenter = imgSlotCenter
  2147.         self.imgRight = imgSlotRight
  2148.         self.imgGauge = imgGauge
  2149.  
  2150.         self.SetSize(width, self.SLOT_HEIGHT)
  2151.  
  2152.     def SetPercentage(self, curValue, maxValue):
  2153.  
  2154.         # PERCENTAGE_MAX_VALUE_ZERO_DIVISION_ERROR
  2155.         if maxValue > 0.0:
  2156.             percentage = min(1.0, float(curValue)/float(maxValue))
  2157.         else:
  2158.             percentage = 0.0
  2159.         # END_OF_PERCENTAGE_MAX_VALUE_ZERO_DIVISION_ERROR
  2160.  
  2161.         gaugeSize = -1.0 + float(self.width - self.GAUGE_TEMPORARY_PLACE*2) * percentage / self.GAUGE_WIDTH
  2162.         self.imgGauge.SetRenderingRect(0.0, 0.0, gaugeSize, 0.0)
  2163.  
  2164. class Board(Window):
  2165.  
  2166.     CORNER_WIDTH = 32
  2167.     CORNER_HEIGHT = 32
  2168.     LINE_WIDTH = 128
  2169.     LINE_HEIGHT = 128
  2170.  
  2171.     LT = 0
  2172.     LB = 1
  2173.     RT = 2
  2174.     RB = 3
  2175.     L = 0
  2176.     R = 1
  2177.     T = 2
  2178.     B = 3
  2179.  
  2180.     def __init__(self):
  2181.         Window.__init__(self)
  2182.  
  2183.         self.MakeBoard("d:/ymir work/ui/pattern/Board_Corner_", "d:/ymir work/ui/pattern/Board_Line_")
  2184.         self.MakeBase()
  2185.  
  2186.     def MakeBoard(self, cornerPath, linePath):
  2187.  
  2188.         CornerFileNames = [ cornerPath+dir+".tga" for dir in ("LeftTop", "LeftBottom", "RightTop", "RightBottom", ) ]
  2189.         LineFileNames = [ linePath+dir+".tga" for dir in ("Left", "Right", "Top", "Bottom", ) ]
  2190.         """
  2191.         CornerFileNames = (
  2192.                             "d:/ymir work/ui/pattern/Board_Corner_LeftTop.tga",
  2193.                             "d:/ymir work/ui/pattern/Board_Corner_LeftBottom.tga",
  2194.                             "d:/ymir work/ui/pattern/Board_Corner_RightTop.tga",
  2195.                             "d:/ymir work/ui/pattern/Board_Corner_RightBottom.tga",
  2196.                             )
  2197.         LineFileNames = (
  2198.                             "d:/ymir work/ui/pattern/Board_Line_Left.tga",
  2199.                             "d:/ymir work/ui/pattern/Board_Line_Right.tga",
  2200.                             "d:/ymir work/ui/pattern/Board_Line_Top.tga",
  2201.                             "d:/ymir work/ui/pattern/Board_Line_Bottom.tga",
  2202.                             )
  2203.         """
  2204.  
  2205.         self.Corners = []
  2206.         for fileName in CornerFileNames:
  2207.             Corner = ExpandedImageBox()
  2208.             Corner.AddFlag("not_pick")
  2209.             Corner.LoadImage(fileName)
  2210.             Corner.SetParent(self)
  2211.             Corner.SetPosition(0, 0)
  2212.             Corner.Show()
  2213.             self.Corners.append(Corner)
  2214.  
  2215.         self.Lines = []
  2216.         for fileName in LineFileNames:
  2217.             Line = ExpandedImageBox()
  2218.             Line.AddFlag("not_pick")
  2219.             Line.LoadImage(fileName)
  2220.             Line.SetParent(self)
  2221.             Line.SetPosition(0, 0)
  2222.             Line.Show()
  2223.             self.Lines.append(Line)
  2224.  
  2225.         self.Lines[self.L].SetPosition(0, self.CORNER_HEIGHT)
  2226.         self.Lines[self.T].SetPosition(self.CORNER_WIDTH, 0)
  2227.  
  2228.     def MakeBase(self):
  2229.         self.Base = ExpandedImageBox()
  2230.         self.Base.AddFlag("not_pick")
  2231.         self.Base.LoadImage("d:/ymir work/ui/pattern/Board_Base.tga")
  2232.         self.Base.SetParent(self)
  2233.         self.Base.SetPosition(self.CORNER_WIDTH, self.CORNER_HEIGHT)
  2234.         self.Base.Show()
  2235.  
  2236.     def __del__(self):
  2237.         Window.__del__(self)
  2238.  
  2239.     def SetSize(self, width, height):
  2240.  
  2241.         width = max(self.CORNER_WIDTH*2, width)
  2242.         height = max(self.CORNER_HEIGHT*2, height)
  2243.         Window.SetSize(self, width, height)
  2244.  
  2245.         self.Corners[self.LB].SetPosition(0, height - self.CORNER_HEIGHT)
  2246.         self.Corners[self.RT].SetPosition(width - self.CORNER_WIDTH, 0)
  2247.         self.Corners[self.RB].SetPosition(width - self.CORNER_WIDTH, height - self.CORNER_HEIGHT)
  2248.         self.Lines[self.R].SetPosition(width - self.CORNER_WIDTH, self.CORNER_HEIGHT)
  2249.         self.Lines[self.B].SetPosition(self.CORNER_HEIGHT, height - self.CORNER_HEIGHT)
  2250.  
  2251.         verticalShowingPercentage = float((height - self.CORNER_HEIGHT*2) - self.LINE_HEIGHT) / self.LINE_HEIGHT
  2252.         horizontalShowingPercentage = float((width - self.CORNER_WIDTH*2) - self.LINE_WIDTH) / self.LINE_WIDTH
  2253.         self.Lines[self.L].SetRenderingRect(0, 0, 0, verticalShowingPercentage)
  2254.         self.Lines[self.R].SetRenderingRect(0, 0, 0, verticalShowingPercentage)
  2255.         self.Lines[self.T].SetRenderingRect(0, 0, horizontalShowingPercentage, 0)
  2256.         self.Lines[self.B].SetRenderingRect(0, 0, horizontalShowingPercentage, 0)
  2257.  
  2258.         if self.Base:
  2259.             self.Base.SetRenderingRect(0, 0, horizontalShowingPercentage, verticalShowingPercentage)
  2260.  
  2261. class BoardWithTitleBar(Board):
  2262.     def __init__(self):
  2263.         Board.__init__(self)
  2264.  
  2265.         titleBar = TitleBar()
  2266.         titleBar.SetParent(self)
  2267.         titleBar.MakeTitleBar(0, "red")
  2268.         titleBar.SetPosition(8, 7)
  2269.         titleBar.Show()
  2270.  
  2271.         titleName = TextLine()
  2272.         titleName.SetParent(titleBar)
  2273.         titleName.SetPosition(0, 4)
  2274.         titleName.SetWindowHorizontalAlignCenter()
  2275.         titleName.SetHorizontalAlignCenter()
  2276.         titleName.Show()
  2277.  
  2278.         self.titleBar = titleBar
  2279.         self.titleName = titleName
  2280.  
  2281.         self.SetCloseEvent(self.Hide)
  2282.  
  2283.     def __del__(self):
  2284.         Board.__del__(self)
  2285.         self.titleBar = None
  2286.         self.titleName = None
  2287.  
  2288.     def SetSize(self, width, height):
  2289.         self.titleBar.SetWidth(width - 15)
  2290.         #self.pickRestrictWindow.SetSize(width, height - 30)
  2291.         Board.SetSize(self, width, height)
  2292.         self.titleName.UpdateRect()
  2293.  
  2294.     def SetTitleColor(self, color):
  2295.         self.titleName.SetPackedFontColor(color)
  2296.  
  2297.     def SetTitleName(self, name):
  2298.         self.titleName.SetText(name)
  2299.  
  2300.     def SetCloseEvent(self, event):
  2301.         self.titleBar.SetCloseEvent(event)
  2302.  
  2303. class ThinBoard(Window):
  2304.  
  2305.     CORNER_WIDTH = 16
  2306.     CORNER_HEIGHT = 16
  2307.     LINE_WIDTH = 16
  2308.     LINE_HEIGHT = 16
  2309.     BOARD_COLOR = grp.GenerateColor(0.0, 0.0, 0.0, 0.51)
  2310.  
  2311.     LT = 0
  2312.     LB = 1
  2313.     RT = 2
  2314.     RB = 3
  2315.     L = 0
  2316.     R = 1
  2317.     T = 2
  2318.     B = 3
  2319.  
  2320.     def __init__(self, layer = "UI"):
  2321.         Window.__init__(self, layer)
  2322.  
  2323.         CornerFileNames = [ "d:/ymir work/ui/pattern/ThinBoard_Corner_"+dir+".tga" for dir in ["LeftTop","LeftBottom","RightTop","RightBottom"] ]
  2324.         LineFileNames = [ "d:/ymir work/ui/pattern/ThinBoard_Line_"+dir+".tga" for dir in ["Left","Right","Top","Bottom"] ]
  2325.  
  2326.         self.Corners = []
  2327.         for fileName in CornerFileNames:
  2328.             Corner = ExpandedImageBox()
  2329.             Corner.AddFlag("attach")
  2330.             Corner.AddFlag("not_pick")
  2331.             Corner.LoadImage(fileName)
  2332.             Corner.SetParent(self)
  2333.             Corner.SetPosition(0, 0)
  2334.             Corner.Show()
  2335.             self.Corners.append(Corner)
  2336.  
  2337.         self.Lines = []
  2338.         for fileName in LineFileNames:
  2339.             Line = ExpandedImageBox()
  2340.             Line.AddFlag("attach")
  2341.             Line.AddFlag("not_pick")
  2342.             Line.LoadImage(fileName)
  2343.             Line.SetParent(self)
  2344.             Line.SetPosition(0, 0)
  2345.             Line.Show()
  2346.             self.Lines.append(Line)
  2347.  
  2348.         Base = Bar()
  2349.         Base.SetParent(self)
  2350.         Base.AddFlag("attach")
  2351.         Base.AddFlag("not_pick")
  2352.         Base.SetPosition(self.CORNER_WIDTH, self.CORNER_HEIGHT)
  2353.         Base.SetColor(self.BOARD_COLOR)
  2354.         Base.Show()
  2355.         self.Base = Base
  2356.  
  2357.         self.Lines[self.L].SetPosition(0, self.CORNER_HEIGHT)
  2358.         self.Lines[self.T].SetPosition(self.CORNER_WIDTH, 0)
  2359.  
  2360.     def __del__(self):
  2361.         Window.__del__(self)
  2362.  
  2363.     if app.ENABLE_SEND_TARGET_INFO:
  2364.         def ShowCorner(self, corner):
  2365.             self.Corners[corner].Show()
  2366.             self.SetSize(self.GetWidth(), self.GetHeight())
  2367.  
  2368.         def HideCorners(self, corner):
  2369.             self.Corners[corner].Hide()
  2370.             self.SetSize(self.GetWidth(), self.GetHeight())
  2371.  
  2372.         def ShowLine(self, line):
  2373.             self.Lines[line].Show()
  2374.             self.SetSize(self.GetWidth(), self.GetHeight())
  2375.  
  2376.         def HideLine(self, line):
  2377.             self.Lines[line].Hide()
  2378.             self.SetSize(self.GetWidth(), self.GetHeight())
  2379.  
  2380.        
  2381.     def SetSize(self, width, height):
  2382.  
  2383.         width = max(self.CORNER_WIDTH*2, width)
  2384.         height = max(self.CORNER_HEIGHT*2, height)
  2385.         Window.SetSize(self, width, height)
  2386.  
  2387.         self.Corners[self.LB].SetPosition(0, height - self.CORNER_HEIGHT)
  2388.         self.Corners[self.RT].SetPosition(width - self.CORNER_WIDTH, 0)
  2389.         self.Corners[self.RB].SetPosition(width - self.CORNER_WIDTH, height - self.CORNER_HEIGHT)
  2390.         self.Lines[self.R].SetPosition(width - self.CORNER_WIDTH, self.CORNER_HEIGHT)
  2391.         self.Lines[self.B].SetPosition(self.CORNER_HEIGHT, height - self.CORNER_HEIGHT)
  2392.  
  2393.         verticalShowingPercentage = float((height - self.CORNER_HEIGHT*2) - self.LINE_HEIGHT) / self.LINE_HEIGHT
  2394.         horizontalShowingPercentage = float((width - self.CORNER_WIDTH*2) - self.LINE_WIDTH) / self.LINE_WIDTH
  2395.         self.Lines[self.L].SetRenderingRect(0, 0, 0, verticalShowingPercentage)
  2396.         self.Lines[self.R].SetRenderingRect(0, 0, 0, verticalShowingPercentage)
  2397.         self.Lines[self.T].SetRenderingRect(0, 0, horizontalShowingPercentage, 0)
  2398.         self.Lines[self.B].SetRenderingRect(0, 0, horizontalShowingPercentage, 0)
  2399.         self.Base.SetSize(width - self.CORNER_WIDTH*2, height - self.CORNER_HEIGHT*2)
  2400.  
  2401.     def ShowInternal(self):
  2402.         self.Base.Show()
  2403.         for wnd in self.Lines:
  2404.             wnd.Show()
  2405.         for wnd in self.Corners:
  2406.             wnd.Show()
  2407.  
  2408.     def HideInternal(self):
  2409.         self.Base.Hide()
  2410.         for wnd in self.Lines:
  2411.             wnd.Hide()
  2412.         for wnd in self.Corners:
  2413.             wnd.Hide()
  2414.  
  2415. class ThinBoardGold(Window):
  2416.     CORNER_WIDTH = 16
  2417.     CORNER_HEIGHT = 16
  2418.     LINE_WIDTH = 16
  2419.     LINE_HEIGHT = 16
  2420.  
  2421.     LT = 0
  2422.     LB = 1
  2423.     RT = 2
  2424.     RB = 3
  2425.     L = 0
  2426.     R = 1
  2427.     T = 2
  2428.     B = 3
  2429.  
  2430.     def __init__(self, layer = "UI"):
  2431.         Window.__init__(self, layer)
  2432.  
  2433.         CornerFileNames = [ "d:/ymir work/ui/pattern/thinboardgold/ThinBoard_Corner_"+dir+"_Gold.tga" for dir in ["LeftTop","LeftBottom","RightTop","RightBottom"] ]
  2434.         LineFileNames = [ "d:/ymir work/ui/pattern/thinboardgold/ThinBoard_Line_"+dir+"_Gold.tga" for dir in ["Left","Right","Top","Bottom"] ]
  2435.  
  2436.         self.MakeBase()
  2437.  
  2438.         self.Corners = []
  2439.         for fileName in CornerFileNames:
  2440.             Corner = ExpandedImageBox()
  2441.             Corner.AddFlag("attach")
  2442.             Corner.AddFlag("not_pick")
  2443.             Corner.LoadImage(fileName)
  2444.             Corner.SetParent(self)
  2445.             Corner.SetPosition(0, 0)
  2446.             Corner.Show()
  2447.             self.Corners.append(Corner)
  2448.  
  2449.         self.Lines = []
  2450.         for fileName in LineFileNames:
  2451.             Line = ExpandedImageBox()
  2452.             Line.AddFlag("attach")
  2453.             Line.AddFlag("not_pick")
  2454.             Line.LoadImage(fileName)
  2455.             Line.SetParent(self)
  2456.             Line.SetPosition(0, 0)
  2457.             Line.Show()
  2458.             self.Lines.append(Line)
  2459.  
  2460.         self.Lines[self.L].SetPosition(0, self.CORNER_HEIGHT)
  2461.         self.Lines[self.T].SetPosition(self.CORNER_WIDTH, 0)
  2462.  
  2463.     def __del__(self):
  2464.         Window.__del__(self)
  2465.  
  2466.     def SetSize(self, width, height):
  2467.  
  2468.         width = max(self.CORNER_WIDTH*2, width)
  2469.         height = max(self.CORNER_HEIGHT*2, height)
  2470.         Window.SetSize(self, width, height)
  2471.  
  2472.         self.Corners[self.LB].SetPosition(0, height - self.CORNER_HEIGHT)
  2473.         self.Corners[self.RT].SetPosition(width - self.CORNER_WIDTH, 0)
  2474.         self.Corners[self.RB].SetPosition(width - self.CORNER_WIDTH, height - self.CORNER_HEIGHT)
  2475.         self.Lines[self.R].SetPosition(width - self.CORNER_WIDTH, self.CORNER_HEIGHT)
  2476.         self.Lines[self.B].SetPosition(self.CORNER_HEIGHT, height - self.CORNER_HEIGHT)
  2477.  
  2478.         verticalShowingPercentage = float((height - self.CORNER_HEIGHT*2) - self.LINE_HEIGHT) / self.LINE_HEIGHT
  2479.         horizontalShowingPercentage = float((width - self.CORNER_WIDTH*2) - self.LINE_WIDTH) / self.LINE_WIDTH
  2480.  
  2481.         self.Lines[self.L].SetRenderingRect(0, 0, 0, verticalShowingPercentage)
  2482.         self.Lines[self.R].SetRenderingRect(0, 0, 0, verticalShowingPercentage)
  2483.         self.Lines[self.T].SetRenderingRect(0, 0, horizontalShowingPercentage, 0)
  2484.         self.Lines[self.B].SetRenderingRect(0, 0, horizontalShowingPercentage, 0)
  2485.  
  2486.         #self.Base.GetWidth()
  2487.         #self.Base.GetHeight()
  2488.         """
  2489.             Defalt Width : 128, Height : 128
  2490.             0.0 > 128, 1.0 > 256
  2491.         """
  2492.         if self.Base:
  2493.             self.Base.SetRenderingRect(0, 0, (float(width)-32)/float(self.Base.GetWidth()) - 1.0, (float(height)-32)/float(self.Base.GetHeight()) - 1.0)
  2494.  
  2495.     def MakeBase(self):
  2496.         self.Base = ExpandedImageBox()
  2497.         self.Base.AddFlag("not_pick")
  2498.         self.Base.LoadImage("d:/ymir work/ui/pattern/Board_Base.tga")
  2499.         self.Base.SetParent(self)
  2500.         self.Base.SetPosition(16, 16)
  2501.         self.Base.SetAlpha(0.8)
  2502.         self.Base.Show()
  2503.  
  2504.     def ShowInternal(self):
  2505.         self.Base.Show()
  2506.         for wnd in self.Lines:
  2507.             wnd.Show()
  2508.         for wnd in self.Corners:
  2509.             wnd.Show()
  2510.  
  2511.     def HideInternal(self):
  2512.         self.Base.Hide()
  2513.         for wnd in self.Lines:
  2514.             wnd.Hide()
  2515.         for wnd in self.Corners:
  2516.             wnd.Hide()
  2517.  
  2518. class ThinBoardCircle(Window):
  2519.     CORNER_WIDTH = 4
  2520.     CORNER_HEIGHT = 4
  2521.     LINE_WIDTH = 4
  2522.     LINE_HEIGHT = 4
  2523.     BOARD_COLOR = grp.GenerateColor(0.0, 0.0, 0.0, 1.0)
  2524.  
  2525.     LT = 0
  2526.     LB = 1
  2527.     RT = 2
  2528.     RB = 3
  2529.     L = 0
  2530.     R = 1
  2531.     T = 2
  2532.     B = 3
  2533.  
  2534.     def __init__(self, layer = "UI"):
  2535.         Window.__init__(self, layer)
  2536.  
  2537.         CornerFileNames = [ "d:/ymir work/ui/pattern/thinboardcircle/ThinBoard_Corner_"+dir+"_Circle.tga" for dir in ["LeftTop","LeftBottom","RightTop","RightBottom"] ]
  2538.         LineFileNames = [ "d:/ymir work/ui/pattern/thinboardcircle/ThinBoard_Line_"+dir+"_Circle.tga" for dir in ["Left","Right","Top","Bottom"] ]
  2539.  
  2540.         self.Corners = []
  2541.         for fileName in CornerFileNames:
  2542.             Corner = ExpandedImageBox()
  2543.             Corner.AddFlag("attach")
  2544.             Corner.AddFlag("not_pick")
  2545.             Corner.LoadImage(fileName)
  2546.             Corner.SetParent(self)
  2547.             Corner.SetPosition(0, 0)
  2548.             Corner.Show()
  2549.             self.Corners.append(Corner)
  2550.  
  2551.         self.Lines = []
  2552.         for fileName in LineFileNames:
  2553.             Line = ExpandedImageBox()
  2554.             Line.AddFlag("attach")
  2555.             Line.AddFlag("not_pick")
  2556.             Line.LoadImage(fileName)
  2557.             Line.SetParent(self)
  2558.             Line.SetPosition(0, 0)
  2559.             Line.Show()
  2560.             self.Lines.append(Line)
  2561.  
  2562.         Base = Bar()
  2563.         Base.SetParent(self)
  2564.         Base.AddFlag("attach")
  2565.         Base.AddFlag("not_pick")
  2566.         Base.SetPosition(self.CORNER_WIDTH, self.CORNER_HEIGHT)
  2567.         Base.SetColor(self.BOARD_COLOR)
  2568.         Base.Show()
  2569.         self.Base = Base
  2570.  
  2571.         self.Lines[self.L].SetPosition(0, self.CORNER_HEIGHT)
  2572.         self.Lines[self.T].SetPosition(self.CORNER_WIDTH, 0)
  2573.  
  2574.     def __del__(self):
  2575.         Window.__del__(self)
  2576.  
  2577.     def SetSize(self, width, height):
  2578.  
  2579.         width = max(self.CORNER_WIDTH*2, width)
  2580.         height = max(self.CORNER_HEIGHT*2, height)
  2581.         Window.SetSize(self, width, height)
  2582.  
  2583.         self.Corners[self.LB].SetPosition(0, height - self.CORNER_HEIGHT)
  2584.         self.Corners[self.RT].SetPosition(width - self.CORNER_WIDTH, 0)
  2585.         self.Corners[self.RB].SetPosition(width - self.CORNER_WIDTH, height - self.CORNER_HEIGHT)
  2586.         self.Lines[self.R].SetPosition(width - self.CORNER_WIDTH, self.CORNER_HEIGHT)
  2587.         self.Lines[self.B].SetPosition(self.CORNER_HEIGHT, height - self.CORNER_HEIGHT)
  2588.  
  2589.         verticalShowingPercentage = float((height - self.CORNER_HEIGHT*2) - self.LINE_HEIGHT) / self.LINE_HEIGHT
  2590.         horizontalShowingPercentage = float((width - self.CORNER_WIDTH*2) - self.LINE_WIDTH) / self.LINE_WIDTH
  2591.         self.Lines[self.L].SetRenderingRect(0, 0, 0, verticalShowingPercentage)
  2592.         self.Lines[self.R].SetRenderingRect(0, 0, 0, verticalShowingPercentage)
  2593.         self.Lines[self.T].SetRenderingRect(0, 0, horizontalShowingPercentage, 0)
  2594.         self.Lines[self.B].SetRenderingRect(0, 0, horizontalShowingPercentage, 0)
  2595.         self.Base.SetSize(width - self.CORNER_WIDTH*2, height - self.CORNER_HEIGHT*2)
  2596.  
  2597.     def ShowInternal(self):
  2598.         self.Base.Show()
  2599.         for wnd in self.Lines:
  2600.             wnd.Show()
  2601.         for wnd in self.Corners:
  2602.             wnd.Show()
  2603.  
  2604.     def HideInternal(self):
  2605.         self.Base.Hide()
  2606.         for wnd in self.Lines:
  2607.             wnd.Hide()
  2608.         for wnd in self.Corners:
  2609.             wnd.Hide()
  2610.            
  2611. class ScrollBar(Window):
  2612.  
  2613.     SCROLLBAR_WIDTH = 17
  2614.     SCROLLBAR_MIDDLE_HEIGHT = 9
  2615.     SCROLLBAR_BUTTON_WIDTH = 17
  2616.     SCROLLBAR_BUTTON_HEIGHT = 17
  2617.     MIDDLE_BAR_POS = 5
  2618.     MIDDLE_BAR_UPPER_PLACE = 3
  2619.     MIDDLE_BAR_DOWNER_PLACE = 4
  2620.     TEMP_SPACE = MIDDLE_BAR_UPPER_PLACE + MIDDLE_BAR_DOWNER_PLACE
  2621.  
  2622.     class MiddleBar(DragButton):
  2623.         def __init__(self):
  2624.             DragButton.__init__(self)
  2625.             self.AddFlag("movable")
  2626.             #self.AddFlag("restrict_x")
  2627.  
  2628.         def MakeImage(self):
  2629.             top = ImageBox()
  2630.             top.SetParent(self)
  2631.             top.LoadImage("d:/ymir work/ui/pattern/ScrollBar_Top.tga")
  2632.             top.SetPosition(0, 0)
  2633.             top.AddFlag("not_pick")
  2634.             top.Show()
  2635.             bottom = ImageBox()
  2636.             bottom.SetParent(self)
  2637.             bottom.LoadImage("d:/ymir work/ui/pattern/ScrollBar_Bottom.tga")
  2638.             bottom.AddFlag("not_pick")
  2639.             bottom.Show()
  2640.  
  2641.             middle = ExpandedImageBox()
  2642.             middle.SetParent(self)
  2643.             middle.LoadImage("d:/ymir work/ui/pattern/ScrollBar_Middle.tga")
  2644.             middle.SetPosition(0, 4)
  2645.             middle.AddFlag("not_pick")
  2646.             middle.Show()
  2647.  
  2648.             self.top = top
  2649.             self.bottom = bottom
  2650.             self.middle = middle
  2651.  
  2652.         def SetSize(self, height):
  2653.             height = max(12, height)
  2654.             DragButton.SetSize(self, 10, height)
  2655.             self.bottom.SetPosition(0, height-4)
  2656.  
  2657.             height -= 4*3
  2658.             self.middle.SetRenderingRect(0, 0, 0, float(height)/4.0)
  2659.  
  2660.     def __init__(self):
  2661.         Window.__init__(self)
  2662.  
  2663.         self.pageSize = 1
  2664.         self.curPos = 0.0
  2665.         self.eventScroll = lambda *arg: None
  2666.         self.lockFlag = False
  2667.         self.scrollStep = 0.20
  2668.  
  2669.  
  2670.         self.CreateScrollBar()
  2671.  
  2672.     def __del__(self):
  2673.         Window.__del__(self)
  2674.  
  2675.     def CreateScrollBar(self):
  2676.         barSlot = Bar3D()
  2677.         barSlot.SetParent(self)
  2678.         barSlot.AddFlag("not_pick")
  2679.         barSlot.Show()
  2680.  
  2681.         middleBar = self.MiddleBar()
  2682.         middleBar.SetParent(self)
  2683.         middleBar.SetMoveEvent(__mem_func__(self.OnMove))
  2684.         middleBar.Show()
  2685.         middleBar.MakeImage()
  2686.         middleBar.SetSize(12)
  2687.  
  2688.         upButton = Button()
  2689.         upButton.SetParent(self)
  2690.         upButton.SetEvent(__mem_func__(self.OnUp))
  2691.         upButton.SetUpVisual("d:/ymir work/ui/public/scrollbar_up_button_01.sub")
  2692.         upButton.SetOverVisual("d:/ymir work/ui/public/scrollbar_up_button_02.sub")
  2693.         upButton.SetDownVisual("d:/ymir work/ui/public/scrollbar_up_button_03.sub")
  2694.         upButton.Show()
  2695.  
  2696.         downButton = Button()
  2697.         downButton.SetParent(self)
  2698.         downButton.SetEvent(__mem_func__(self.OnDown))
  2699.         downButton.SetUpVisual("d:/ymir work/ui/public/scrollbar_down_button_01.sub")
  2700.         downButton.SetOverVisual("d:/ymir work/ui/public/scrollbar_down_button_02.sub")
  2701.         downButton.SetDownVisual("d:/ymir work/ui/public/scrollbar_down_button_03.sub")
  2702.         downButton.Show()
  2703.  
  2704.         self.upButton = upButton
  2705.         self.downButton = downButton
  2706.         self.middleBar = middleBar
  2707.         self.barSlot = barSlot
  2708.  
  2709.         self.SCROLLBAR_WIDTH = self.upButton.GetWidth()
  2710.         self.SCROLLBAR_MIDDLE_HEIGHT = self.middleBar.GetHeight()
  2711.         self.SCROLLBAR_BUTTON_WIDTH = self.upButton.GetWidth()
  2712.         self.SCROLLBAR_BUTTON_HEIGHT = self.upButton.GetHeight()
  2713.  
  2714.     def Destroy(self):
  2715.         self.middleBar = None
  2716.         self.upButton = None
  2717.         self.downButton = None
  2718.         self.eventScroll = lambda *arg: None
  2719.  
  2720.     def SetScrollEvent(self, event):
  2721.         self.eventScroll = event
  2722.  
  2723.     def SetMiddleBarSize(self, pageScale):
  2724.         realHeight = self.GetHeight() - self.SCROLLBAR_BUTTON_HEIGHT*2
  2725.         self.SCROLLBAR_MIDDLE_HEIGHT = int(pageScale * float(realHeight))
  2726.         self.middleBar.SetSize(self.SCROLLBAR_MIDDLE_HEIGHT)
  2727.         self.pageSize = (self.GetHeight() - self.SCROLLBAR_BUTTON_HEIGHT*2) - self.SCROLLBAR_MIDDLE_HEIGHT - (self.TEMP_SPACE)
  2728.  
  2729.     def SetScrollBarSize(self, height):
  2730.         self.pageSize = (height - self.SCROLLBAR_BUTTON_HEIGHT*2) - self.SCROLLBAR_MIDDLE_HEIGHT - (self.TEMP_SPACE)
  2731.         self.SetSize(self.SCROLLBAR_WIDTH, height)
  2732.         self.upButton.SetPosition(0, 0)
  2733.         self.downButton.SetPosition(0, height - self.SCROLLBAR_BUTTON_HEIGHT)
  2734.         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)
  2735.         self.middleBar.SetPosition(self.MIDDLE_BAR_POS, 0)
  2736.  
  2737.         self.UpdateBarSlot()
  2738.  
  2739.     def UpdateBarSlot(self):
  2740.         self.barSlot.SetPosition(0, self.SCROLLBAR_BUTTON_HEIGHT)
  2741.         self.barSlot.SetSize(self.GetWidth() - 2, self.GetHeight() - self.SCROLLBAR_BUTTON_HEIGHT*2 - 2)
  2742.  
  2743.     def GetPos(self):
  2744.         return self.curPos
  2745.  
  2746.     def SetPos(self, pos):
  2747.         pos = max(0.0, pos)
  2748.         pos = min(1.0, pos)
  2749.  
  2750.         newPos = float(self.pageSize) * pos
  2751.         self.middleBar.SetPosition(self.MIDDLE_BAR_POS, int(newPos) + self.SCROLLBAR_BUTTON_HEIGHT + self.MIDDLE_BAR_UPPER_PLACE)
  2752.         self.OnMove()
  2753.  
  2754.     def SetScrollStep(self, step):
  2755.         self.scrollStep = step
  2756.    
  2757.     def GetScrollStep(self):
  2758.         return self.scrollStep
  2759.        
  2760.     def OnUp(self):
  2761.         self.SetPos(self.curPos-self.scrollStep)
  2762.  
  2763.     def OnDown(self):
  2764.         self.SetPos(self.curPos+self.scrollStep)
  2765.  
  2766.     def OnMove(self):
  2767.  
  2768.         if self.lockFlag:
  2769.             return
  2770.  
  2771.         if 0 == self.pageSize:
  2772.             return
  2773.  
  2774.         (xLocal, yLocal) = self.middleBar.GetLocalPosition()
  2775.         self.curPos = float(yLocal - self.SCROLLBAR_BUTTON_HEIGHT - self.MIDDLE_BAR_UPPER_PLACE) / float(self.pageSize)
  2776.  
  2777.         self.eventScroll()
  2778.  
  2779.     def OnMouseLeftButtonDown(self):
  2780.         (xMouseLocalPosition, yMouseLocalPosition) = self.GetMouseLocalPosition()
  2781.         pickedPos = yMouseLocalPosition - self.SCROLLBAR_BUTTON_HEIGHT - self.SCROLLBAR_MIDDLE_HEIGHT/2
  2782.         newPos = float(pickedPos) / float(self.pageSize)
  2783.         self.SetPos(newPos)
  2784.  
  2785.     def LockScroll(self):
  2786.         self.lockFlag = True
  2787.  
  2788.     def UnlockScroll(self):
  2789.         self.lockFlag = False
  2790.  
  2791. class ThinScrollBar(ScrollBar):
  2792.  
  2793.     def CreateScrollBar(self):
  2794.         middleBar = self.MiddleBar()
  2795.         middleBar.SetParent(self)
  2796.         middleBar.SetMoveEvent(__mem_func__(self.OnMove))
  2797.         middleBar.Show()
  2798.         middleBar.SetUpVisual("d:/ymir work/ui/public/scrollbar_thin_middle_button_01.sub")
  2799.         middleBar.SetOverVisual("d:/ymir work/ui/public/scrollbar_thin_middle_button_02.sub")
  2800.         middleBar.SetDownVisual("d:/ymir work/ui/public/scrollbar_thin_middle_button_03.sub")
  2801.  
  2802.         upButton = Button()
  2803.         upButton.SetParent(self)
  2804.         upButton.SetUpVisual("d:/ymir work/ui/public/scrollbar_thin_up_button_01.sub")
  2805.         upButton.SetOverVisual("d:/ymir work/ui/public/scrollbar_thin_up_button_02.sub")
  2806.         upButton.SetDownVisual("d:/ymir work/ui/public/scrollbar_thin_up_button_03.sub")
  2807.         upButton.SetEvent(__mem_func__(self.OnUp))
  2808.         upButton.Show()
  2809.  
  2810.         downButton = Button()
  2811.         downButton.SetParent(self)
  2812.         downButton.SetUpVisual("d:/ymir work/ui/public/scrollbar_thin_down_button_01.sub")
  2813.         downButton.SetOverVisual("d:/ymir work/ui/public/scrollbar_thin_down_button_02.sub")
  2814.         downButton.SetDownVisual("d:/ymir work/ui/public/scrollbar_thin_down_button_03.sub")
  2815.         downButton.SetEvent(__mem_func__(self.OnDown))
  2816.         downButton.Show()
  2817.  
  2818.         self.middleBar = middleBar
  2819.         self.upButton = upButton
  2820.         self.downButton = downButton
  2821.  
  2822.         self.SCROLLBAR_WIDTH = self.upButton.GetWidth()
  2823.         self.SCROLLBAR_MIDDLE_HEIGHT = self.middleBar.GetHeight()
  2824.         self.SCROLLBAR_BUTTON_WIDTH = self.upButton.GetWidth()
  2825.         self.SCROLLBAR_BUTTON_HEIGHT = self.upButton.GetHeight()
  2826.         self.MIDDLE_BAR_POS = 0
  2827.         self.MIDDLE_BAR_UPPER_PLACE = 0
  2828.         self.MIDDLE_BAR_DOWNER_PLACE = 0
  2829.         self.TEMP_SPACE = 0
  2830.  
  2831.     def UpdateBarSlot(self):
  2832.         pass
  2833.  
  2834. class SmallThinScrollBar(ScrollBar):
  2835.  
  2836.     def CreateScrollBar(self):
  2837.         middleBar = self.MiddleBar()
  2838.         middleBar.SetParent(self)
  2839.         middleBar.SetMoveEvent(__mem_func__(self.OnMove))
  2840.         middleBar.Show()
  2841.         middleBar.SetUpVisual("d:/ymir work/ui/public/scrollbar_small_thin_middle_button_01.sub")
  2842.         middleBar.SetOverVisual("d:/ymir work/ui/public/scrollbar_small_thin_middle_button_01.sub")
  2843.         middleBar.SetDownVisual("d:/ymir work/ui/public/scrollbar_small_thin_middle_button_01.sub")
  2844.  
  2845.         upButton = Button()
  2846.         upButton.SetParent(self)
  2847.         upButton.SetUpVisual("d:/ymir work/ui/public/scrollbar_small_thin_up_button_01.sub")
  2848.         upButton.SetOverVisual("d:/ymir work/ui/public/scrollbar_small_thin_up_button_02.sub")
  2849.         upButton.SetDownVisual("d:/ymir work/ui/public/scrollbar_small_thin_up_button_03.sub")
  2850.         upButton.SetEvent(__mem_func__(self.OnUp))
  2851.         upButton.Show()
  2852.  
  2853.         downButton = Button()
  2854.         downButton.SetParent(self)
  2855.         downButton.SetUpVisual("d:/ymir work/ui/public/scrollbar_small_thin_down_button_01.sub")
  2856.         downButton.SetOverVisual("d:/ymir work/ui/public/scrollbar_small_thin_down_button_02.sub")
  2857.         downButton.SetDownVisual("d:/ymir work/ui/public/scrollbar_small_thin_down_button_03.sub")
  2858.         downButton.SetEvent(__mem_func__(self.OnDown))
  2859.         downButton.Show()
  2860.  
  2861.         self.middleBar = middleBar
  2862.         self.upButton = upButton
  2863.         self.downButton = downButton
  2864.  
  2865.         self.SCROLLBAR_WIDTH = self.upButton.GetWidth()
  2866.         self.SCROLLBAR_MIDDLE_HEIGHT = self.middleBar.GetHeight()
  2867.         self.SCROLLBAR_BUTTON_WIDTH = self.upButton.GetWidth()
  2868.         self.SCROLLBAR_BUTTON_HEIGHT = self.upButton.GetHeight()
  2869.         self.MIDDLE_BAR_POS = 0
  2870.         self.MIDDLE_BAR_UPPER_PLACE = 0
  2871.         self.MIDDLE_BAR_DOWNER_PLACE = 0
  2872.         self.TEMP_SPACE = 0
  2873.  
  2874.     def UpdateBarSlot(self):
  2875.         pass
  2876.  
  2877. class SliderBar(Window):
  2878.  
  2879.     def __init__(self):
  2880.         Window.__init__(self)
  2881.  
  2882.         self.curPos = 1.0
  2883.         self.pageSize = 1.0
  2884.         self.eventChange = None
  2885.  
  2886.         self.__CreateBackGroundImage()
  2887.         self.__CreateCursor()
  2888.  
  2889.     def __del__(self):
  2890.         Window.__del__(self)
  2891.  
  2892.     def __CreateBackGroundImage(self):
  2893.         img = ImageBox()
  2894.         img.SetParent(self)
  2895.         img.LoadImage("d:/ymir work/ui/game/windows/sliderbar.sub")
  2896.         img.Show()
  2897.         self.backGroundImage = img
  2898.  
  2899.         ##
  2900.         self.SetSize(self.backGroundImage.GetWidth(), self.backGroundImage.GetHeight())
  2901.  
  2902.     def __CreateCursor(self):
  2903.         cursor = DragButton()
  2904.         cursor.AddFlag("movable")
  2905.         cursor.AddFlag("restrict_y")
  2906.         cursor.SetParent(self)
  2907.         cursor.SetMoveEvent(__mem_func__(self.__OnMove))
  2908.         cursor.SetUpVisual("d:/ymir work/ui/game/windows/sliderbar_cursor.sub")
  2909.         cursor.SetOverVisual("d:/ymir work/ui/game/windows/sliderbar_cursor.sub")
  2910.         cursor.SetDownVisual("d:/ymir work/ui/game/windows/sliderbar_cursor.sub")
  2911.         cursor.Show()
  2912.         self.cursor = cursor
  2913.  
  2914.         ##
  2915.         self.cursor.SetRestrictMovementArea(0, 0, self.backGroundImage.GetWidth(), 0)
  2916.         self.pageSize = self.backGroundImage.GetWidth() - self.cursor.GetWidth()
  2917.  
  2918.     def __OnMove(self):
  2919.         (xLocal, yLocal) = self.cursor.GetLocalPosition()
  2920.         self.curPos = float(xLocal) / float(self.pageSize)
  2921.  
  2922.         if self.eventChange:
  2923.             self.eventChange()
  2924.  
  2925.     def SetSliderPos(self, pos):
  2926.         self.curPos = pos
  2927.         self.cursor.SetPosition(int(self.pageSize * pos), 0)
  2928.  
  2929.     def GetSliderPos(self):
  2930.         return self.curPos
  2931.  
  2932.     def SetEvent(self, event):
  2933.         self.eventChange = event
  2934.  
  2935.     def Enable(self):
  2936.         self.cursor.Show()
  2937.  
  2938.     def Disable(self):
  2939.         self.cursor.Hide()
  2940.  
  2941. class ListBox(Window):
  2942.  
  2943.     TEMPORARY_PLACE = 3
  2944.  
  2945.     def __init__(self, layer = "UI"):
  2946.         Window.__init__(self, layer)
  2947.         self.overLine = -1
  2948.         self.selectedLine = -1
  2949.         self.width = 0
  2950.         self.height = 0
  2951.         self.stepSize = 17
  2952.         self.basePos = 0
  2953.         self.showLineCount = 0
  2954.         self.itemCenterAlign = True
  2955.         self.itemList = []
  2956.         self.keyDict = {}
  2957.         self.textDict = {}
  2958.         self.event = lambda *arg: None
  2959.     def __del__(self):
  2960.         Window.__del__(self)
  2961.  
  2962.     def SetWidth(self, width):
  2963.         self.SetSize(width, self.height)
  2964.  
  2965.     def SetSize(self, width, height):
  2966.         Window.SetSize(self, width, height)
  2967.         self.width = width
  2968.         self.height = height
  2969.  
  2970.     def SetTextCenterAlign(self, flag):
  2971.         self.itemCenterAlign = flag
  2972.  
  2973.     def SetBasePos(self, pos):
  2974.         self.basePos = pos
  2975.         self._LocateItem()
  2976.  
  2977.     def ClearItem(self):
  2978.         self.keyDict = {}
  2979.         self.textDict = {}
  2980.         self.itemList = []
  2981.         self.overLine = -1
  2982.         self.selectedLine = -1
  2983.  
  2984.     def InsertItem(self, number, text):
  2985.         self.keyDict[len(self.itemList)] = number
  2986.         self.textDict[len(self.itemList)] = text
  2987.  
  2988.         textLine = TextLine()
  2989.         textLine.SetParent(self)
  2990.         textLine.SetText(text)
  2991.         textLine.Show()
  2992.  
  2993.         if self.itemCenterAlign:
  2994.             textLine.SetWindowHorizontalAlignCenter()
  2995.             textLine.SetHorizontalAlignCenter()
  2996.  
  2997.         self.itemList.append(textLine)
  2998.  
  2999.         self._LocateItem()
  3000.  
  3001.     def ChangeItem(self, number, text):
  3002.         for key, value in self.keyDict.items():
  3003.             if value == number:
  3004.                 self.textDict[key] = text
  3005.  
  3006.                 if number < len(self.itemList):
  3007.                     self.itemList[key].SetText(text)
  3008.  
  3009.                 return
  3010.  
  3011.     def LocateItem(self):
  3012.         self._LocateItem()
  3013.  
  3014.     def _LocateItem(self):
  3015.  
  3016.         skipCount = self.basePos
  3017.         yPos = 0
  3018.         self.showLineCount = 0
  3019.  
  3020.         for textLine in self.itemList:
  3021.             textLine.Hide()
  3022.  
  3023.             if skipCount > 0:
  3024.                 skipCount -= 1
  3025.                 continue
  3026.  
  3027.             # if localeInfo.IsARABIC():
  3028.                 # w, h = textLine.GetTextSize()
  3029.                 # textLine.SetPosition(w+10, yPos + 3)
  3030.             # else:
  3031.                 # textLine.SetPosition(0, yPos + 3)
  3032.            
  3033.             if app.BL_PRIVATESHOP_SEARCH_SYSTEM:
  3034.                 textLine.SetPosition(0, yPos + 3)
  3035.             else:
  3036.                 if localeInfo.IsARABIC():
  3037.                     w, h = textLine.GetTextSize()
  3038.                     textLine.SetPosition(w+10, yPos + 3)
  3039.                 else:
  3040.                     textLine.SetPosition(0, yPos + 3)
  3041.  
  3042.             yPos += self.stepSize
  3043.  
  3044.             if yPos <= self.GetHeight():
  3045.                 self.showLineCount += 1
  3046.                 textLine.Show()
  3047.  
  3048.     def ArrangeItem(self):
  3049.         self.SetSize(self.width, len(self.itemList) * self.stepSize)
  3050.         self._LocateItem()
  3051.  
  3052.     def GetViewItemCount(self):
  3053.         return int(self.GetHeight() / self.stepSize)
  3054.  
  3055.     def GetItemCount(self):
  3056.         return len(self.itemList)
  3057.  
  3058.     def SetEvent(self, event):
  3059.         self.event = event
  3060.  
  3061.     def SelectItem(self, line):
  3062.  
  3063.         if not self.keyDict.has_key(line):
  3064.             return
  3065.  
  3066.         # if line == self.selectedLine:
  3067.             # return
  3068.         if not app.BL_PRIVATESHOP_SEARCH_SYSTEM:
  3069.             if line == self.selectedLine:
  3070.                 return
  3071.  
  3072.         self.selectedLine = line
  3073.         self.event(self.keyDict.get(line, 0), self.textDict.get(line, "None"))
  3074.  
  3075.     def GetSelectedItem(self):
  3076.         return self.keyDict.get(self.selectedLine, 0)
  3077.  
  3078.     def OnMouseLeftButtonDown(self):
  3079.         if self.overLine < 0:
  3080.             return
  3081.  
  3082.     def OnMouseLeftButtonUp(self):
  3083.         if self.overLine >= 0:
  3084.             self.SelectItem(self.overLine+self.basePos)
  3085.  
  3086.     def OnUpdate(self):
  3087.  
  3088.         self.overLine = -1
  3089.  
  3090.         if self.IsIn():
  3091.             x, y = self.GetGlobalPosition()
  3092.             height = self.GetHeight()
  3093.             xMouse, yMouse = wndMgr.GetMousePosition()
  3094.  
  3095.             if yMouse - y < height - 1:
  3096.                 self.overLine = (yMouse - y) / self.stepSize
  3097.  
  3098.                 if self.overLine < 0:
  3099.                     self.overLine = -1
  3100.                 if self.overLine >= len(self.itemList):
  3101.                     self.overLine = -1
  3102.  
  3103.     def OnRender(self):
  3104.         xRender, yRender = self.GetGlobalPosition()
  3105.         yRender -= self.TEMPORARY_PLACE
  3106.         widthRender = self.width
  3107.         heightRender = self.height + self.TEMPORARY_PLACE*2
  3108.  
  3109.         if localeInfo.IsCIBN10:
  3110.             if -1 != self.overLine and self.keyDict[self.overLine] != -1:
  3111.                 grp.SetColor(HALF_WHITE_COLOR)
  3112.                 grp.RenderBar(xRender + 2, yRender + self.overLine*self.stepSize + 4, self.width - 3, self.stepSize)               
  3113.  
  3114.             if -1 != self.selectedLine and self.keyDict[self.selectedLine] != -1:
  3115.                 if self.selectedLine >= self.basePos:
  3116.                     if self.selectedLine - self.basePos < self.showLineCount:
  3117.                         grp.SetColor(SELECT_COLOR)
  3118.                         grp.RenderBar(xRender + 2, yRender + (self.selectedLine-self.basePos)*self.stepSize + 4, self.width - 3, self.stepSize)
  3119.  
  3120.         else:      
  3121.             if -1 != self.overLine:
  3122.                 grp.SetColor(HALF_WHITE_COLOR)
  3123.                 grp.RenderBar(xRender + 2, yRender + self.overLine*self.stepSize + 4, self.width - 3, self.stepSize)               
  3124.  
  3125.             if -1 != self.selectedLine:
  3126.                 if self.selectedLine >= self.basePos:
  3127.                     if self.selectedLine - self.basePos < self.showLineCount:
  3128.                         grp.SetColor(SELECT_COLOR)
  3129.                         grp.RenderBar(xRender + 2, yRender + (self.selectedLine-self.basePos)*self.stepSize + 4, self.width - 3, self.stepSize)
  3130.  
  3131.  
  3132.  
  3133. class ListBox2(ListBox):
  3134.     def __init__(self, *args, **kwargs):
  3135.         ListBox.__init__(self, *args, **kwargs)
  3136.         self.rowCount = 10
  3137.         self.barWidth = 0
  3138.         self.colCount = 0
  3139.  
  3140.     def SetRowCount(self, rowCount):
  3141.         self.rowCount = rowCount
  3142.  
  3143.     def SetSize(self, width, height):
  3144.         ListBox.SetSize(self, width, height)
  3145.         self._RefreshForm()
  3146.  
  3147.     def ClearItem(self):
  3148.         ListBox.ClearItem(self)
  3149.         self._RefreshForm()
  3150.  
  3151.     def InsertItem(self, *args, **kwargs):
  3152.         ListBox.InsertItem(self, *args, **kwargs)
  3153.         self._RefreshForm()
  3154.  
  3155.     def OnUpdate(self):
  3156.         mpos = wndMgr.GetMousePosition()
  3157.         self.overLine = self._CalcPointIndex(mpos)
  3158.  
  3159.     def OnRender(self):
  3160.         x, y = self.GetGlobalPosition()
  3161.         pos = (x + 2, y)
  3162.  
  3163.         if -1 != self.overLine:
  3164.             grp.SetColor(HALF_WHITE_COLOR)
  3165.             self._RenderBar(pos, self.overLine)
  3166.  
  3167.         if -1 != self.selectedLine:
  3168.             if self.selectedLine >= self.basePos:
  3169.                 if self.selectedLine - self.basePos < self.showLineCount:
  3170.                     grp.SetColor(SELECT_COLOR)
  3171.                     self._RenderBar(pos, self.selectedLine-self.basePos)
  3172.  
  3173.    
  3174.  
  3175.     def _CalcPointIndex(self, mpos):
  3176.         if self.IsIn():
  3177.             px, py = mpos
  3178.             gx, gy = self.GetGlobalPosition()
  3179.             lx, ly = px - gx, py - gy
  3180.  
  3181.             col = lx / self.barWidth
  3182.             row = ly / self.stepSize
  3183.             idx = col * self.rowCount + row
  3184.             if col >= 0 and col < self.colCount:
  3185.                 if row >= 0 and row < self.rowCount:
  3186.                     if idx >= 0 and idx < len(self.itemList):
  3187.                         return idx
  3188.        
  3189.         return -1
  3190.  
  3191.     def _CalcRenderPos(self, pos, idx):
  3192.         x, y = pos
  3193.         row = idx % self.rowCount
  3194.         col = idx / self.rowCount
  3195.         return (x + col * self.barWidth, y + row * self.stepSize)
  3196.  
  3197.     def _RenderBar(self, basePos, idx):
  3198.         x, y = self._CalcRenderPos(basePos, idx)
  3199.         grp.RenderBar(x, y, self.barWidth - 3, self.stepSize)
  3200.  
  3201.     def _LocateItem(self):
  3202.         pos = (0, self.TEMPORARY_PLACE)
  3203.  
  3204.         self.showLineCount = 0
  3205.         for textLine in self.itemList:
  3206.             x, y = self._CalcRenderPos(pos, self.showLineCount)
  3207.             textLine.SetPosition(x, y)
  3208.             textLine.Show()
  3209.  
  3210.             self.showLineCount += 1
  3211.  
  3212.     def _RefreshForm(self):
  3213.         if len(self.itemList) % self.rowCount:
  3214.             self.colCount = len(self.itemList) / self.rowCount + 1
  3215.         else:
  3216.             self.colCount = len(self.itemList) / self.rowCount
  3217.  
  3218.         if self.colCount:
  3219.             self.barWidth = self.width / self.colCount
  3220.         else:
  3221.             self.barWidth = self.width
  3222.  
  3223.  
  3224. class ComboBox(Window):
  3225.  
  3226.     class ListBoxWithBoard(ListBox):
  3227.  
  3228.         def __init__(self, layer):
  3229.             ListBox.__init__(self, layer)
  3230.  
  3231.         def OnRender(self):
  3232.             xRender, yRender = self.GetGlobalPosition()
  3233.             yRender -= self.TEMPORARY_PLACE
  3234.             widthRender = self.width
  3235.             heightRender = self.height + self.TEMPORARY_PLACE*2
  3236.             grp.SetColor(BACKGROUND_COLOR)
  3237.             grp.RenderBar(xRender, yRender, widthRender, heightRender)
  3238.             grp.SetColor(DARK_COLOR)
  3239.             grp.RenderLine(xRender, yRender, widthRender, 0)
  3240.             grp.RenderLine(xRender, yRender, 0, heightRender)
  3241.             grp.SetColor(BRIGHT_COLOR)
  3242.             grp.RenderLine(xRender, yRender+heightRender, widthRender, 0)
  3243.             grp.RenderLine(xRender+widthRender, yRender, 0, heightRender)
  3244.  
  3245.             ListBox.OnRender(self)
  3246.  
  3247.     def __init__(self):
  3248.         Window.__init__(self)
  3249.         self.x = 0
  3250.         self.y = 0
  3251.         self.width = 0
  3252.         self.height = 0
  3253.         self.isSelected = False
  3254.         self.isOver = False
  3255.         self.isListOpened = False
  3256.         self.event = lambda *arg: None
  3257.         self.enable = True
  3258.  
  3259.         self.textLine = MakeTextLine(self)
  3260.         self.textLine.SetText(localeInfo.UI_ITEM)
  3261.  
  3262.         self.listBox = self.ListBoxWithBoard("TOP_MOST")
  3263.         self.listBox.SetPickAlways()
  3264.         self.listBox.SetParent(self)
  3265.         self.listBox.SetEvent(__mem_func__(self.OnSelectItem))
  3266.         self.listBox.Hide()
  3267.  
  3268.     def __del__(self):
  3269.         Window.__del__(self)
  3270.  
  3271.     def Destroy(self):
  3272.         self.textLine = None
  3273.         self.listBox = None
  3274.  
  3275.     def SetPosition(self, x, y):
  3276.         Window.SetPosition(self, x, y)
  3277.         self.x = x
  3278.         self.y = y
  3279.         self.__ArrangeListBox()
  3280.  
  3281.     def SetSize(self, width, height):
  3282.         Window.SetSize(self, width, height)
  3283.         self.width = width
  3284.         self.height = height
  3285.         self.textLine.UpdateRect()
  3286.         self.__ArrangeListBox()
  3287.  
  3288.     def __ArrangeListBox(self):
  3289.         self.listBox.SetPosition(0, self.height + 5)
  3290.         self.listBox.SetWidth(self.width)
  3291.  
  3292.     def Enable(self):
  3293.         self.enable = True
  3294.  
  3295.     def Disable(self):
  3296.         self.enable = False
  3297.         self.textLine.SetText("")
  3298.         self.CloseListBox()
  3299.  
  3300.     def SetEvent(self, event):
  3301.         self.event = event
  3302.  
  3303.     def ClearItem(self):
  3304.         self.CloseListBox()
  3305.         self.listBox.ClearItem()
  3306.  
  3307.     def InsertItem(self, index, name):
  3308.         self.listBox.InsertItem(index, name)
  3309.         self.listBox.ArrangeItem()
  3310.  
  3311.     def SetCurrentItem(self, text):
  3312.         self.textLine.SetText(text)
  3313.  
  3314.     def SelectItem(self, key):
  3315.         self.listBox.SelectItem(key)
  3316.  
  3317.     def OnSelectItem(self, index, name):
  3318.  
  3319.         self.CloseListBox()
  3320.         self.event(index)
  3321.  
  3322.     def CloseListBox(self):
  3323.         self.isListOpened = False
  3324.         self.listBox.Hide()
  3325.  
  3326.     def OnMouseLeftButtonDown(self):
  3327.  
  3328.         if not self.enable:
  3329.             return
  3330.  
  3331.         self.isSelected = True
  3332.  
  3333.     def OnMouseLeftButtonUp(self):
  3334.  
  3335.         if not self.enable:
  3336.             return
  3337.  
  3338.         self.isSelected = False
  3339.  
  3340.         if self.isListOpened:
  3341.             self.CloseListBox()
  3342.         else:
  3343.             if self.listBox.GetItemCount() > 0:
  3344.                 self.isListOpened = True
  3345.                 self.listBox.Show()
  3346.                 self.__ArrangeListBox()
  3347.  
  3348.     def OnUpdate(self):
  3349.  
  3350.         if not self.enable:
  3351.             return
  3352.  
  3353.         if self.IsIn():
  3354.             self.isOver = True
  3355.         else:
  3356.             self.isOver = False
  3357.  
  3358.     def OnRender(self):
  3359.         self.x, self.y = self.GetGlobalPosition()
  3360.         xRender = self.x
  3361.         yRender = self.y
  3362.         widthRender = self.width
  3363.         heightRender = self.height
  3364.         grp.SetColor(BACKGROUND_COLOR)
  3365.         grp.RenderBar(xRender, yRender, widthRender, heightRender)
  3366.         grp.SetColor(DARK_COLOR)
  3367.         grp.RenderLine(xRender, yRender, widthRender, 0)
  3368.         grp.RenderLine(xRender, yRender, 0, heightRender)
  3369.         grp.SetColor(BRIGHT_COLOR)
  3370.         grp.RenderLine(xRender, yRender+heightRender, widthRender, 0)
  3371.         grp.RenderLine(xRender+widthRender, yRender, 0, heightRender)
  3372.  
  3373.         if self.isOver:
  3374.             grp.SetColor(HALF_WHITE_COLOR)
  3375.             grp.RenderBar(xRender + 2, yRender + 3, self.width - 3, heightRender - 5)
  3376.  
  3377.             if self.isSelected:
  3378.                 grp.SetColor(WHITE_COLOR)
  3379.                 grp.RenderBar(xRender + 2, yRender + 3, self.width - 3, heightRender - 5)
  3380.  
  3381. ###################################################################################################
  3382. ## Python Script Loader
  3383. ###################################################################################################
  3384.  
  3385. class ScriptWindow(Window):
  3386.     def __init__(self, layer = "UI"):
  3387.         Window.__init__(self, layer)
  3388.         self.Children = []
  3389.         self.ElementDictionary = {}
  3390.     def __del__(self):
  3391.         Window.__del__(self)
  3392.  
  3393.     def ClearDictionary(self):
  3394.         self.Children = []
  3395.         self.ElementDictionary = {}
  3396.     def InsertChild(self, name, child):
  3397.         self.ElementDictionary[name] = child
  3398.  
  3399.     def IsChild(self, name):
  3400.         return self.ElementDictionary.has_key(name)
  3401.     def GetChild(self, name):
  3402.         return self.ElementDictionary[name]
  3403.  
  3404.     def GetChild2(self, name):
  3405.         return self.ElementDictionary.get(name, None)
  3406.  
  3407. if app.BL_PRIVATESHOP_SEARCH_SYSTEM:
  3408.     class ComboBoxImage(Window):
  3409.         class ListBoxWithBoard(ListBox):
  3410.  
  3411.             def __init__(self, layer):
  3412.                 ListBox.__init__(self, layer)
  3413.  
  3414.             def OnRender(self):
  3415.                 xRender, yRender = self.GetGlobalPosition()
  3416.                 yRender -= self.TEMPORARY_PLACE
  3417.                 widthRender = self.width
  3418.                 heightRender = self.height + self.TEMPORARY_PLACE*2
  3419.                 grp.SetColor(BACKGROUND_COLOR)
  3420.                 grp.RenderBar(xRender, yRender, widthRender, heightRender)
  3421.                 grp.SetColor(DARK_COLOR)
  3422.                 grp.RenderLine(xRender, yRender, widthRender, 0)
  3423.                 grp.RenderLine(xRender, yRender, 0, heightRender)
  3424.                 ListBox.OnRender(self)
  3425.  
  3426.         def __init__(self, parent, name, x ,y):
  3427.             Window.__init__(self)
  3428.             self.isSelected = False
  3429.             self.isOver = False
  3430.             self.isListOpened = False
  3431.             self.event = lambda *arg: None
  3432.             self.enable = True
  3433.             self.imagebox = None
  3434.            
  3435.             ## imagebox
  3436.             image = ImageBox()
  3437.             image.SetParent(parent)
  3438.             image.LoadImage(name)
  3439.             image.SetPosition(x, y)
  3440.             image.Show()
  3441.             self.imagebox = image
  3442.            
  3443.             ## BaseSetting
  3444.             self.x = x + 1
  3445.             self.y = y + 1
  3446.             self.width = self.imagebox.GetWidth() - 3
  3447.             self.height = self.imagebox.GetHeight() - 3
  3448.             self.SetParent(parent)
  3449.  
  3450.             ## TextLine
  3451.             self.textLine = MakeTextLine(self)
  3452.             self.textLine.SetText(localeInfo.UI_ITEM)
  3453.            
  3454.             ## ListBox
  3455.             self.listBox = self.ListBoxWithBoard("TOP_MOST")
  3456.             self.listBox.SetPickAlways()
  3457.             self.listBox.SetParent(self)
  3458.             self.listBox.SetEvent(__mem_func__(self.OnSelectItem))
  3459.             self.listBox.Hide()
  3460.  
  3461.             Window.SetPosition(self, self.x, self.y)
  3462.             Window.SetSize(self, self.width, self.height)
  3463.             self.textLine.UpdateRect()
  3464.             self.__ArrangeListBox()
  3465.            
  3466.         def __del__(self):
  3467.             Window.__del__(self)
  3468.  
  3469.         def Destroy(self):
  3470.             self.textLine = None
  3471.             self.listBox = None
  3472.             self.imagebox = None
  3473.  
  3474.         def SetPosition(self, x, y):
  3475.             Window.SetPosition(self, x, y)
  3476.             self.imagebox.SetPosition(x, y)
  3477.             self.x = x
  3478.             self.y = y
  3479.             self.__ArrangeListBox()
  3480.  
  3481.         def SetSize(self, width, height):
  3482.             Window.SetSize(self, width, height)
  3483.             self.width = width
  3484.             self.height = height
  3485.             self.textLine.UpdateRect()
  3486.             self.__ArrangeListBox()
  3487.  
  3488.         def __ArrangeListBox(self):
  3489.             self.listBox.SetPosition(0, self.height + 5)
  3490.             self.listBox.SetWidth(self.width)
  3491.  
  3492.         def Enable(self):
  3493.             self.enable = True
  3494.  
  3495.         def Disable(self):
  3496.             self.enable = False
  3497.             self.textLine.SetText("")
  3498.             self.CloseListBox()
  3499.  
  3500.         def SetEvent(self, event):
  3501.             self.event = event
  3502.  
  3503.         def ClearItem(self):
  3504.             self.CloseListBox()
  3505.             self.listBox.ClearItem()
  3506.  
  3507.         def InsertItem(self, index, name):
  3508.             self.listBox.InsertItem(index, name)
  3509.             self.listBox.ArrangeItem()
  3510.  
  3511.         def SetCurrentItem(self, text):
  3512.             self.textLine.SetText(text)
  3513.  
  3514.         def SelectItem(self, key):
  3515.             self.listBox.SelectItem(key)
  3516.  
  3517.         def OnSelectItem(self, index, name):
  3518.             self.CloseListBox()
  3519.             self.event(index)
  3520.  
  3521.         def CloseListBox(self):
  3522.             self.isListOpened = False
  3523.             self.listBox.Hide()
  3524.  
  3525.         def OnMouseLeftButtonDown(self):
  3526.        
  3527.             if not self.enable:
  3528.                 return
  3529.  
  3530.             self.isSelected = True
  3531.  
  3532.         def OnMouseLeftButtonUp(self):
  3533.             if not self.enable:
  3534.                 return
  3535.            
  3536.             self.isSelected = False
  3537.            
  3538.             if self.isListOpened:
  3539.                 self.CloseListBox()
  3540.             else:
  3541.                 if self.listBox.GetItemCount() > 0:
  3542.                     self.isListOpened = True
  3543.                     self.listBox.Show()
  3544.                     self.__ArrangeListBox()
  3545.  
  3546.         def OnUpdate(self):
  3547.  
  3548.             if not self.enable:
  3549.                 return
  3550.  
  3551.             if self.IsIn():
  3552.                 self.isOver = True
  3553.             else:
  3554.                 self.isOver = False
  3555.  
  3556.         def OnRender(self):
  3557.             self.x, self.y = self.GetGlobalPosition()
  3558.             xRender = self.x
  3559.             yRender = self.y
  3560.             widthRender = self.width
  3561.             heightRender = self.height
  3562.             if self.isOver:
  3563.                 grp.SetColor(HALF_WHITE_COLOR)
  3564.                 grp.RenderBar(xRender + 2, yRender + 3, self.width - 3, heightRender - 5)
  3565.                 if self.isSelected:
  3566.                     grp.SetColor(WHITE_COLOR)
  3567.                     grp.RenderBar(xRender + 2, yRender + 3, self.width - 3, heightRender - 5)
  3568.  
  3569. class PythonScriptLoader(object):
  3570.  
  3571.     BODY_KEY_LIST = ( "x", "y", "width", "height" )
  3572.  
  3573.     #####
  3574.  
  3575.     DEFAULT_KEY_LIST = ( "type", "x", "y", )
  3576.     WINDOW_KEY_LIST = ( "width", "height", )
  3577.     IMAGE_KEY_LIST = ( "image", )
  3578.     EXPANDED_IMAGE_KEY_LIST = ( "image", )
  3579.     ANI_IMAGE_KEY_LIST = ( "images", )
  3580.     SLOT_KEY_LIST = ( "width", "height", "slot", )
  3581.     CANDIDATE_LIST_KEY_LIST = ( "item_step", "item_xsize", "item_ysize", )
  3582.     GRID_TABLE_KEY_LIST = ( "start_index", "x_count", "y_count", "x_step", "y_step", )
  3583.     EDIT_LINE_KEY_LIST = ( "width", "height", "input_limit", )
  3584.     COMBO_BOX_KEY_LIST = ( "width", "height", "item", )
  3585.     TITLE_BAR_KEY_LIST = ( "width", )
  3586.     HORIZONTAL_BAR_KEY_LIST = ( "width", )
  3587.     BOARD_KEY_LIST = ( "width", "height", )
  3588.     BOARD_WITH_TITLEBAR_KEY_LIST = ( "width", "height", "title", )
  3589.     BOX_KEY_LIST = ( "width", "height", )
  3590.     BAR_KEY_LIST = ( "width", "height", )
  3591.     LINE_KEY_LIST = ( "width", "height", )
  3592.     SLOTBAR_KEY_LIST = ( "width", "height", )
  3593.     GAUGE_KEY_LIST = ( "width", "color", )
  3594.     SCROLLBAR_KEY_LIST = ( "size", )
  3595.     LIST_BOX_KEY_LIST = ( "width", "height", )
  3596.  
  3597.     def __init__(self):
  3598.         self.Clear()
  3599.  
  3600.     def Clear(self):
  3601.         self.ScriptDictionary = { "SCREEN_WIDTH" : wndMgr.GetScreenWidth(), "SCREEN_HEIGHT" : wndMgr.GetScreenHeight() }
  3602.         self.InsertFunction = 0
  3603.  
  3604.     def LoadScriptFile(self, window, FileName):
  3605.         import exception
  3606.         import exceptions
  3607.         import os
  3608.         import errno
  3609.         self.Clear()
  3610.  
  3611.         print "===== Load Script File : %s" % (FileName)
  3612.  
  3613.         try:
  3614.             # chr, player µξΐΊ sandbox ³»Ώ΅Ό­ import°΅ ΗγΏλµΗΑφ ΎΚ±β ¶§Ή®Ώ΅,(ΊΏΐΜ ΎΗΏλΗ� Ώ©Αφ°΅ ΈΕΏμ Ε­.)
  3615.             #  ΉΜΈ® script dictionaryΏ΅ ΗΚΏδΗΡ »σΌφΈ¦ ³ΦΎξ³υ΄Β΄Ω.
  3616.             import chr
  3617.             import player
  3618.             import app
  3619.             self.ScriptDictionary["PLAYER_NAME_MAX_LEN"] = chr.PLAYER_NAME_MAX_LEN
  3620.             self.ScriptDictionary["DRAGON_SOUL_EQUIPMENT_SLOT_START"] = player.DRAGON_SOUL_EQUIPMENT_SLOT_START
  3621.             self.ScriptDictionary["LOCALE_PATH"] = app.GetLocalePath()
  3622.             execfile(FileName, self.ScriptDictionary)
  3623.         except IOError, err:
  3624.             import sys
  3625.             import dbg         
  3626.             dbg.TraceError("Failed to load script file : %s" % (FileName))
  3627.             dbg.TraceError("error  : %s" % (err))
  3628.             exception.Abort("LoadScriptFile1")
  3629.         except RuntimeError,err:
  3630.             import sys
  3631.             import dbg         
  3632.             dbg.TraceError("Failed to load script file : %s" % (FileName))
  3633.             dbg.TraceError("error  : %s" % (err))
  3634.             exception.Abort("LoadScriptFile2")
  3635.         except:
  3636.             import sys
  3637.             import dbg         
  3638.             dbg.TraceError("Failed to load script file : %s" % (FileName))
  3639.             exception.Abort("LoadScriptFile!!!!!!!!!!!!!!")
  3640.        
  3641.         #####
  3642.  
  3643.         Body = self.ScriptDictionary["window"]
  3644.         self.CheckKeyList("window", Body, self.BODY_KEY_LIST)
  3645.  
  3646.         window.ClearDictionary()
  3647.         self.InsertFunction = window.InsertChild
  3648.  
  3649.         window.SetPosition(int(Body["x"]), int(Body["y"]))
  3650.  
  3651.         if localeInfo.IsARABIC():
  3652.             w = wndMgr.GetScreenWidth()
  3653.             h = wndMgr.GetScreenHeight()
  3654.             if Body.has_key("width"):
  3655.                 w = int(Body["width"])
  3656.             if Body.has_key("height"):
  3657.                 h = int(Body["height"])
  3658.  
  3659.             window.SetSize(w, h)
  3660.         else:
  3661.             window.SetSize(int(Body["width"]), int(Body["height"]))
  3662.             if True == Body.has_key("style"):
  3663.                 for StyleList in Body["style"]:
  3664.                     window.AddFlag(StyleList)
  3665.        
  3666.  
  3667.         self.LoadChildren(window, Body)
  3668.  
  3669.     def LoadChildren(self, parent, dicChildren):
  3670.  
  3671.         if localeInfo.IsARABIC():
  3672.             parent.AddFlag( "rtl" )
  3673.  
  3674.         if True == dicChildren.has_key("style"):
  3675.             for style in dicChildren["style"]:
  3676.                 parent.AddFlag(style)
  3677.  
  3678.         if False == dicChildren.has_key("children"):
  3679.             return False
  3680.  
  3681.         Index = 0
  3682.  
  3683.         ChildrenList = dicChildren["children"]
  3684.         parent.Children = range(len(ChildrenList))
  3685.         for ElementValue in ChildrenList:
  3686.             try:
  3687.                 Name = ElementValue["name"]            
  3688.             except KeyError:
  3689.                 Name = ElementValue["name"] = "NONAME"
  3690.                
  3691.             try:
  3692.                 Type = ElementValue["type"]
  3693.             except KeyError:                               
  3694.                 Type = ElementValue["type"] = "window"             
  3695.  
  3696.             if False == self.CheckKeyList(Name, ElementValue, self.DEFAULT_KEY_LIST):
  3697.                 del parent.Children[Index]
  3698.                 continue
  3699.  
  3700.             if Type == "window":
  3701.                 parent.Children[Index] = ScriptWindow()
  3702.                 parent.Children[Index].SetParent(parent)
  3703.                 self.LoadElementWindow(parent.Children[Index], ElementValue, parent)
  3704.  
  3705.             elif Type == "button":
  3706.                 parent.Children[Index] = Button()
  3707.                 parent.Children[Index].SetParent(parent)
  3708.                 self.LoadElementButton(parent.Children[Index], ElementValue, parent)
  3709.  
  3710.             elif Type == "radio_button":
  3711.                 parent.Children[Index] = RadioButton()
  3712.                 parent.Children[Index].SetParent(parent)
  3713.                 self.LoadElementButton(parent.Children[Index], ElementValue, parent)
  3714.  
  3715.             elif Type == "toggle_button":
  3716.                 parent.Children[Index] = ToggleButton()
  3717.                 parent.Children[Index].SetParent(parent)
  3718.                 self.LoadElementButton(parent.Children[Index], ElementValue, parent)
  3719.  
  3720.             elif Type == "mark":
  3721.                 parent.Children[Index] = MarkBox()
  3722.                 parent.Children[Index].SetParent(parent)
  3723.                 self.LoadElementMark(parent.Children[Index], ElementValue, parent)
  3724.  
  3725.             elif Type == "image":
  3726.                 parent.Children[Index] = ImageBox()
  3727.                 parent.Children[Index].SetParent(parent)
  3728.                 self.LoadElementImage(parent.Children[Index], ElementValue, parent)
  3729.  
  3730.             elif Type == "expanded_image":
  3731.                 parent.Children[Index] = ExpandedImageBox()
  3732.                 parent.Children[Index].SetParent(parent)
  3733.                 self.LoadElementExpandedImage(parent.Children[Index], ElementValue, parent)
  3734.  
  3735.             elif Type == "ani_image":
  3736.                 parent.Children[Index] = AniImageBox()
  3737.                 parent.Children[Index].SetParent(parent)
  3738.                 self.LoadElementAniImage(parent.Children[Index], ElementValue, parent)
  3739.  
  3740.             elif Type == "slot":
  3741.                 parent.Children[Index] = SlotWindow()
  3742.                 parent.Children[Index].SetParent(parent)
  3743.                 self.LoadElementSlot(parent.Children[Index], ElementValue, parent)
  3744.  
  3745.             elif Type == "candidate_list":
  3746.                 parent.Children[Index] = CandidateListBox()
  3747.                 parent.Children[Index].SetParent(parent)
  3748.                 self.LoadElementCandidateList(parent.Children[Index], ElementValue, parent)
  3749.  
  3750.             elif Type == "grid_table":
  3751.                 parent.Children[Index] = GridSlotWindow()
  3752.                 parent.Children[Index].SetParent(parent)
  3753.                 self.LoadElementGridTable(parent.Children[Index], ElementValue, parent)
  3754.  
  3755.             elif Type == "text":
  3756.                 parent.Children[Index] = TextLine()
  3757.                 parent.Children[Index].SetParent(parent)
  3758.                 self.LoadElementText(parent.Children[Index], ElementValue, parent)
  3759.  
  3760.             elif Type == "editline":
  3761.                 parent.Children[Index] = EditLine()
  3762.                 parent.Children[Index].SetParent(parent)
  3763.                 self.LoadElementEditLine(parent.Children[Index], ElementValue, parent)
  3764.  
  3765.             elif Type == "titlebar":
  3766.                 parent.Children[Index] = TitleBar()
  3767.                 parent.Children[Index].SetParent(parent)
  3768.                 self.LoadElementTitleBar(parent.Children[Index], ElementValue, parent)
  3769.  
  3770.             elif Type == "horizontalbar":
  3771.                 parent.Children[Index] = HorizontalBar()
  3772.                 parent.Children[Index].SetParent(parent)
  3773.                 self.LoadElementHorizontalBar(parent.Children[Index], ElementValue, parent)
  3774.  
  3775.             elif Type == "board":
  3776.                 parent.Children[Index] = Board()
  3777.                 parent.Children[Index].SetParent(parent)
  3778.                 self.LoadElementBoard(parent.Children[Index], ElementValue, parent)
  3779.  
  3780.             elif Type == "board_with_titlebar":
  3781.                 parent.Children[Index] = BoardWithTitleBar()
  3782.                 parent.Children[Index].SetParent(parent)
  3783.                 self.LoadElementBoardWithTitleBar(parent.Children[Index], ElementValue, parent)
  3784.  
  3785.             elif Type == "thinboard":
  3786.                 parent.Children[Index] = ThinBoard()
  3787.                 parent.Children[Index].SetParent(parent)
  3788.                 self.LoadElementThinBoard(parent.Children[Index], ElementValue, parent)
  3789.  
  3790.             elif Type == "thinboard_gold":
  3791.                 parent.Children[Index] = ThinBoardGold()
  3792.                 parent.Children[Index].SetParent(parent)
  3793.                 self.LoadElementThinBoardGold(parent.Children[Index], ElementValue, parent)
  3794.  
  3795.             elif Type == "thinboard_circle":
  3796.                 parent.Children[Index] = ThinBoardCircle()
  3797.                 parent.Children[Index].SetParent(parent)
  3798.                 self.LoadElementThinBoardCircle(parent.Children[Index], ElementValue, parent)
  3799.                
  3800.             elif Type == "box":
  3801.                 parent.Children[Index] = Box()
  3802.                 parent.Children[Index].SetParent(parent)
  3803.                 self.LoadElementBox(parent.Children[Index], ElementValue, parent)
  3804.  
  3805.             elif Type == "bar":
  3806.                 parent.Children[Index] = Bar()
  3807.                 parent.Children[Index].SetParent(parent)
  3808.                 self.LoadElementBar(parent.Children[Index], ElementValue, parent)
  3809.  
  3810.             elif Type == "line":
  3811.                 parent.Children[Index] = Line()
  3812.                 parent.Children[Index].SetParent(parent)
  3813.                 self.LoadElementLine(parent.Children[Index], ElementValue, parent)
  3814.  
  3815.             elif Type == "slotbar":
  3816.                 parent.Children[Index] = SlotBar()
  3817.                 parent.Children[Index].SetParent(parent)
  3818.                 self.LoadElementSlotBar(parent.Children[Index], ElementValue, parent)
  3819.  
  3820.             elif Type == "gauge":
  3821.                 parent.Children[Index] = Gauge()
  3822.                 parent.Children[Index].SetParent(parent)
  3823.                 self.LoadElementGauge(parent.Children[Index], ElementValue, parent)
  3824.  
  3825.             elif Type == "scrollbar":
  3826.                 parent.Children[Index] = ScrollBar()
  3827.                 parent.Children[Index].SetParent(parent)
  3828.                 self.LoadElementScrollBar(parent.Children[Index], ElementValue, parent)
  3829.  
  3830.             elif Type == "thin_scrollbar":
  3831.                 parent.Children[Index] = ThinScrollBar()
  3832.                 parent.Children[Index].SetParent(parent)
  3833.                 self.LoadElementScrollBar(parent.Children[Index], ElementValue, parent)
  3834.  
  3835.             elif Type == "small_thin_scrollbar":
  3836.                 parent.Children[Index] = SmallThinScrollBar()
  3837.                 parent.Children[Index].SetParent(parent)
  3838.                 self.LoadElementScrollBar(parent.Children[Index], ElementValue, parent)
  3839.  
  3840.             elif Type == "sliderbar":
  3841.                 parent.Children[Index] = SliderBar()
  3842.                 parent.Children[Index].SetParent(parent)
  3843.                 self.LoadElementSliderBar(parent.Children[Index], ElementValue, parent)
  3844.  
  3845.             elif Type == "listbox":
  3846.                 parent.Children[Index] = ListBox()
  3847.                 parent.Children[Index].SetParent(parent)
  3848.                 self.LoadElementListBox(parent.Children[Index], ElementValue, parent)
  3849.  
  3850.             elif Type == "listbox2":
  3851.                 parent.Children[Index] = ListBox2()
  3852.                 parent.Children[Index].SetParent(parent)
  3853.                 self.LoadElementListBox2(parent.Children[Index], ElementValue, parent)
  3854.             elif Type == "listboxex":
  3855.                 parent.Children[Index] = ListBoxEx()
  3856.                 parent.Children[Index].SetParent(parent)
  3857.                 self.LoadElementListBoxEx(parent.Children[Index], ElementValue, parent)
  3858.  
  3859.             else:
  3860.                 Index += 1
  3861.                 continue
  3862.  
  3863.             parent.Children[Index].SetWindowName(Name)
  3864.             if 0 != self.InsertFunction:
  3865.                 self.InsertFunction(Name, parent.Children[Index])
  3866.  
  3867.             self.LoadChildren(parent.Children[Index], ElementValue)
  3868.             Index += 1
  3869.  
  3870.     def CheckKeyList(self, name, value, key_list):
  3871.  
  3872.         for DataKey in key_list:
  3873.             if False == value.has_key(DataKey):
  3874.                 print "Failed to find data key", "[" + name + "/" + DataKey + "]"
  3875.                 return False
  3876.  
  3877.         return True
  3878.  
  3879.     def LoadDefaultData(self, window, value, parentWindow):
  3880.         loc_x = int(value["x"])
  3881.         loc_y = int(value["y"])
  3882.         if value.has_key("vertical_align"):
  3883.             if "center" == value["vertical_align"]:
  3884.                 window.SetWindowVerticalAlignCenter()
  3885.             elif "bottom" == value["vertical_align"]:
  3886.                 window.SetWindowVerticalAlignBottom()
  3887.  
  3888.         if parentWindow.IsRTL():
  3889.             loc_x = int(value["x"]) + window.GetWidth()
  3890.             if value.has_key("horizontal_align"):
  3891.                 if "center" == value["horizontal_align"]:
  3892.                     window.SetWindowHorizontalAlignCenter()
  3893.                     loc_x = - int(value["x"])
  3894.                 elif "right" == value["horizontal_align"]:
  3895.                     window.SetWindowHorizontalAlignLeft()
  3896.                     loc_x = int(value["x"]) - window.GetWidth()
  3897.                     ## loc_x = parentWindow.GetWidth() - int(value["x"]) + window.GetWidth()
  3898.             else:
  3899.                 window.SetWindowHorizontalAlignRight()
  3900.  
  3901.             if value.has_key("all_align"):
  3902.                 window.SetWindowVerticalAlignCenter()
  3903.                 window.SetWindowHorizontalAlignCenter()
  3904.                 loc_x = - int(value["x"])
  3905.         else:
  3906.             if value.has_key("horizontal_align"):
  3907.                 if "center" == value["horizontal_align"]:
  3908.                     window.SetWindowHorizontalAlignCenter()
  3909.                 elif "right" == value["horizontal_align"]:
  3910.                     window.SetWindowHorizontalAlignRight()
  3911.  
  3912.         window.SetPosition(loc_x, loc_y)
  3913.         window.Show()
  3914.  
  3915.     ## Window
  3916.     def LoadElementWindow(self, window, value, parentWindow):
  3917.  
  3918.         if False == self.CheckKeyList(value["name"], value, self.WINDOW_KEY_LIST):
  3919.             return False
  3920.  
  3921.         window.SetSize(int(value["width"]), int(value["height"]))
  3922.         self.LoadDefaultData(window, value, parentWindow)
  3923.  
  3924.         return True
  3925.  
  3926.     ## Button
  3927.     def LoadElementButton(self, window, value, parentWindow):
  3928.  
  3929.         if value.has_key("width") and value.has_key("height"):
  3930.             window.SetSize(int(value["width"]), int(value["height"]))
  3931.  
  3932.         if True == value.has_key("default_image"):
  3933.             window.SetUpVisual(value["default_image"])
  3934.         if True == value.has_key("over_image"):
  3935.             window.SetOverVisual(value["over_image"])
  3936.         if True == value.has_key("down_image"):
  3937.             window.SetDownVisual(value["down_image"])
  3938.         if True == value.has_key("disable_image"):
  3939.             window.SetDisableVisual(value["disable_image"])
  3940.  
  3941.         if True == value.has_key("text"):
  3942.             if True == value.has_key("text_height"):
  3943.                 window.SetText(value["text"], value["text_height"])
  3944.             else:
  3945.                 window.SetText(value["text"])
  3946.  
  3947.             if value.has_key("text_color"):
  3948.                 window.SetTextColor(value["text_color"])
  3949.  
  3950.         if True == value.has_key("tooltip_text"):
  3951.             if True == value.has_key("tooltip_x") and True == value.has_key("tooltip_y"):
  3952.                 window.SetToolTipText(value["tooltip_text"], int(value["tooltip_x"]), int(value["tooltip_y"]))
  3953.             else:
  3954.                 window.SetToolTipText(value["tooltip_text"])
  3955.  
  3956.         self.LoadDefaultData(window, value, parentWindow)
  3957.  
  3958.         return True
  3959.  
  3960.     ## Mark
  3961.     def LoadElementMark(self, window, value, parentWindow):
  3962.  
  3963.         #if False == self.CheckKeyList(value["name"], value, self.MARK_KEY_LIST):
  3964.         #   return False
  3965.  
  3966.         self.LoadDefaultData(window, value, parentWindow)
  3967.  
  3968.         return True
  3969.  
  3970.     ## Image
  3971.     def LoadElementImage(self, window, value, parentWindow):
  3972.  
  3973.         if False == self.CheckKeyList(value["name"], value, self.IMAGE_KEY_LIST):
  3974.             return False
  3975.  
  3976.         window.LoadImage(value["image"])
  3977.         self.LoadDefaultData(window, value, parentWindow)
  3978.  
  3979.         return True
  3980.  
  3981.     ## AniImage
  3982.     def LoadElementAniImage(self, window, value, parentWindow):
  3983.  
  3984.         if False == self.CheckKeyList(value["name"], value, self.ANI_IMAGE_KEY_LIST):
  3985.             return False
  3986.  
  3987.         if True == value.has_key("delay"):
  3988.             window.SetDelay(value["delay"])
  3989.  
  3990.         for image in value["images"]:
  3991.             window.AppendImage(image)
  3992.  
  3993.         if value.has_key("width") and value.has_key("height"):
  3994.             window.SetSize(value["width"], value["height"])
  3995.  
  3996.         self.LoadDefaultData(window, value, parentWindow)
  3997.  
  3998.         return True
  3999.  
  4000.     ## Expanded Image
  4001.     def LoadElementExpandedImage(self, window, value, parentWindow):
  4002.  
  4003.         if False == self.CheckKeyList(value["name"], value, self.EXPANDED_IMAGE_KEY_LIST):
  4004.             return False
  4005.  
  4006.         window.LoadImage(value["image"])
  4007.  
  4008.         if True == value.has_key("x_origin") and True == value.has_key("y_origin"):
  4009.             window.SetOrigin(float(value["x_origin"]), float(value["y_origin"]))
  4010.  
  4011.         if True == value.has_key("x_scale") and True == value.has_key("y_scale"):
  4012.             window.SetScale(float(value["x_scale"]), float(value["y_scale"]))
  4013.  
  4014.         if True == value.has_key("rect"):
  4015.             RenderingRect = value["rect"]
  4016.             window.SetRenderingRect(RenderingRect[0], RenderingRect[1], RenderingRect[2], RenderingRect[3])
  4017.  
  4018.         if True == value.has_key("mode"):
  4019.             mode = value["mode"]
  4020.             if "MODULATE" == mode:
  4021.                 window.SetRenderingMode(wndMgr.RENDERING_MODE_MODULATE)
  4022.  
  4023.         self.LoadDefaultData(window, value, parentWindow)
  4024.  
  4025.         return True
  4026.  
  4027.     ## Slot
  4028.     def LoadElementSlot(self, window, value, parentWindow):
  4029.  
  4030.         if False == self.CheckKeyList(value["name"], value, self.SLOT_KEY_LIST):
  4031.             return False
  4032.  
  4033.         global_x = int(value["x"])
  4034.         global_y = int(value["y"])
  4035.         global_width = int(value["width"])
  4036.         global_height = int(value["height"])
  4037.  
  4038.         window.SetPosition(global_x, global_y)
  4039.         window.SetSize(global_width, global_height)
  4040.         window.Show()
  4041.  
  4042.         r = 1.0
  4043.         g = 1.0
  4044.         b = 1.0
  4045.         a = 1.0
  4046.  
  4047.         if True == value.has_key("image_r") and \
  4048.             True == value.has_key("image_g") and \
  4049.             True == value.has_key("image_b") and \
  4050.             True == value.has_key("image_a"):
  4051.             r = float(value["image_r"])
  4052.             g = float(value["image_g"])
  4053.             b = float(value["image_b"])
  4054.             a = float(value["image_a"])
  4055.  
  4056.         SLOT_ONE_KEY_LIST = ("index", "x", "y", "width", "height")
  4057.  
  4058.         for slot in value["slot"]:
  4059.             if True == self.CheckKeyList(value["name"] + " - one", slot, SLOT_ONE_KEY_LIST):
  4060.                 wndMgr.AppendSlot(window.hWnd,
  4061.                                     int(slot["index"]),
  4062.                                     int(slot["x"]),
  4063.                                     int(slot["y"]),
  4064.                                     int(slot["width"]),
  4065.                                     int(slot["height"]))
  4066.  
  4067.         if True == value.has_key("image"):
  4068.             wndMgr.SetSlotBaseImage(window.hWnd,
  4069.                                     value["image"],
  4070.                                     r, g, b, a)
  4071.  
  4072.         return True
  4073.  
  4074.     def LoadElementCandidateList(self, window, value, parentWindow):
  4075.         if False == self.CheckKeyList(value["name"], value, self.CANDIDATE_LIST_KEY_LIST):
  4076.             return False
  4077.  
  4078.         window.SetPosition(int(value["x"]), int(value["y"]))
  4079.         window.SetItemSize(int(value["item_xsize"]), int(value["item_ysize"]))
  4080.         window.SetItemStep(int(value["item_step"]))    
  4081.         window.Show()
  4082.  
  4083.         return True
  4084.                
  4085.     ## Table
  4086.     def LoadElementGridTable(self, window, value, parentWindow):
  4087.  
  4088.         if False == self.CheckKeyList(value["name"], value, self.GRID_TABLE_KEY_LIST):
  4089.             return False
  4090.  
  4091.         xBlank = 0
  4092.         yBlank = 0
  4093.         if True == value.has_key("x_blank"):
  4094.             xBlank = int(value["x_blank"])
  4095.         if True == value.has_key("y_blank"):
  4096.             yBlank = int(value["y_blank"])
  4097.  
  4098.         if localeInfo.IsARABIC():
  4099.             pass
  4100.         else:
  4101.             window.SetPosition(int(value["x"]), int(value["y"]))
  4102.  
  4103.         window.ArrangeSlot( int(value["start_index"]),
  4104.                             int(value["x_count"]),
  4105.                             int(value["y_count"]),
  4106.                             int(value["x_step"]),
  4107.                             int(value["y_step"]),
  4108.                             xBlank,
  4109.                             yBlank)
  4110.         if True == value.has_key("image"):
  4111.             r = 1.0
  4112.             g = 1.0
  4113.             b = 1.0
  4114.             a = 1.0
  4115.             if True == value.has_key("image_r") and \
  4116.                 True == value.has_key("image_g") and \
  4117.                 True == value.has_key("image_b") and \
  4118.                 True == value.has_key("image_a"):
  4119.                 r = float(value["image_r"])
  4120.                 g = float(value["image_g"])
  4121.                 b = float(value["image_b"])
  4122.                 a = float(value["image_a"])
  4123.             wndMgr.SetSlotBaseImage(window.hWnd, value["image"], r, g, b, a)
  4124.  
  4125.         if True == value.has_key("style"):
  4126.             if "select" == value["style"]:
  4127.                 wndMgr.SetSlotStyle(window.hWnd, wndMgr.SLOT_STYLE_SELECT)
  4128.         if localeInfo.IsARABIC():
  4129.             self.LoadDefaultData(window, value, parentWindow)
  4130.         else:
  4131.             window.Show()
  4132.  
  4133.         return True
  4134.  
  4135.     ## Text
  4136.     def LoadElementText(self, window, value, parentWindow):
  4137.  
  4138.         if value.has_key("fontsize"):
  4139.             fontSize = value["fontsize"]
  4140.  
  4141.             if "LARGE" == fontSize:
  4142.                 window.SetFontName(localeInfo.UI_DEF_FONT_LARGE)
  4143.  
  4144.         elif value.has_key("fontname"):
  4145.             fontName = value["fontname"]
  4146.             window.SetFontName(fontName)
  4147.  
  4148.         if value.has_key("text_horizontal_align"):
  4149.             if "left" == value["text_horizontal_align"]:
  4150.                 window.SetHorizontalAlignLeft()
  4151.             elif "center" == value["text_horizontal_align"]:
  4152.                 window.SetHorizontalAlignCenter()
  4153.             elif "right" == value["text_horizontal_align"]:
  4154.                 window.SetHorizontalAlignRight()
  4155.  
  4156.         if value.has_key("text_vertical_align"):
  4157.             if "top" == value["text_vertical_align"]:
  4158.                 window.SetVerticalAlignTop()
  4159.             elif "center" == value["text_vertical_align"]:
  4160.                 window.SetVerticalAlignCenter()
  4161.             elif "bottom" == value["text_vertical_align"]:
  4162.                 window.SetVerticalAlignBottom()
  4163.  
  4164.         if value.has_key("all_align"):
  4165.             window.SetHorizontalAlignCenter()
  4166.             window.SetVerticalAlignCenter()
  4167.             window.SetWindowHorizontalAlignCenter()
  4168.             window.SetWindowVerticalAlignCenter()
  4169.  
  4170.         if value.has_key("r") and value.has_key("g") and value.has_key("b"):
  4171.             window.SetFontColor(float(value["r"]), float(value["g"]), float(value["b"]))
  4172.         elif value.has_key("color"):
  4173.             window.SetPackedFontColor(value["color"])
  4174.         else:
  4175.             window.SetFontColor(0.8549, 0.8549, 0.8549)
  4176.  
  4177.         if value.has_key("outline"):
  4178.             if value["outline"]:
  4179.                 window.SetOutline()
  4180.         if True == value.has_key("text"):
  4181.             window.SetText(value["text"])
  4182.  
  4183.         self.LoadDefaultData(window, value, parentWindow)
  4184.  
  4185.         return True
  4186.  
  4187.     ## EditLine
  4188.     def LoadElementEditLine(self, window, value, parentWindow):
  4189.  
  4190.         if False == self.CheckKeyList(value["name"], value, self.EDIT_LINE_KEY_LIST):
  4191.             return False
  4192.  
  4193.  
  4194.         if value.has_key("secret_flag"):
  4195.             window.SetSecret(value["secret_flag"])
  4196.         if value.has_key("with_codepage"):
  4197.             if value["with_codepage"]:
  4198.                 window.bCodePage = True
  4199.         if value.has_key("only_number"):
  4200.             if value["only_number"]:
  4201.                 window.SetNumberMode()
  4202.         if value.has_key("enable_codepage"):
  4203.             window.SetIMEFlag(value["enable_codepage"])
  4204.         if value.has_key("enable_ime"):
  4205.             window.SetIMEFlag(value["enable_ime"])
  4206.         if value.has_key("limit_width"):
  4207.             window.SetLimitWidth(value["limit_width"])
  4208.         if value.has_key("multi_line"):
  4209.             if value["multi_line"]:
  4210.                 window.SetMultiLine()
  4211.  
  4212.         window.SetMax(int(value["input_limit"]))
  4213.         window.SetSize(int(value["width"]), int(value["height"]))
  4214.         self.LoadElementText(window, value, parentWindow)
  4215.  
  4216.         return True
  4217.  
  4218.     ## TitleBar
  4219.     def LoadElementTitleBar(self, window, value, parentWindow):
  4220.  
  4221.         if False == self.CheckKeyList(value["name"], value, self.TITLE_BAR_KEY_LIST):
  4222.             return False
  4223.  
  4224.         window.MakeTitleBar(int(value["width"]), value.get("color", "red"))
  4225.         self.LoadDefaultData(window, value, parentWindow)
  4226.  
  4227.         return True
  4228.  
  4229.     ## HorizontalBar
  4230.     def LoadElementHorizontalBar(self, window, value, parentWindow):
  4231.  
  4232.         if False == self.CheckKeyList(value["name"], value, self.HORIZONTAL_BAR_KEY_LIST):
  4233.             return False
  4234.  
  4235.         window.Create(int(value["width"]))
  4236.         self.LoadDefaultData(window, value, parentWindow)
  4237.  
  4238.         return True
  4239.  
  4240.     ## Board
  4241.     def LoadElementBoard(self, window, value, parentWindow):
  4242.  
  4243.         if False == self.CheckKeyList(value["name"], value, self.BOARD_KEY_LIST):
  4244.             return False
  4245.  
  4246.         window.SetSize(int(value["width"]), int(value["height"]))
  4247.         self.LoadDefaultData(window, value, parentWindow)
  4248.  
  4249.         return True
  4250.  
  4251.     ## Board With TitleBar
  4252.     def LoadElementBoardWithTitleBar(self, window, value, parentWindow):
  4253.  
  4254.         if False == self.CheckKeyList(value["name"], value, self.BOARD_WITH_TITLEBAR_KEY_LIST):
  4255.             return False
  4256.  
  4257.         window.SetSize(int(value["width"]), int(value["height"]))
  4258.         window.SetTitleName(value["title"])
  4259.         self.LoadDefaultData(window, value, parentWindow)
  4260.  
  4261.         return True
  4262.  
  4263.     ## ThinBoard
  4264.     def LoadElementThinBoard(self, window, value, parentWindow):
  4265.  
  4266.         if False == self.CheckKeyList(value["name"], value, self.BOARD_KEY_LIST):
  4267.             return False
  4268.  
  4269.         window.SetSize(int(value["width"]), int(value["height"]))
  4270.         self.LoadDefaultData(window, value, parentWindow)
  4271.  
  4272.         return True
  4273.  
  4274.     ## ThinBoard Gold
  4275.     def LoadElementThinBoardGold(self, window, value, parentWindow):
  4276.  
  4277.         if False == self.CheckKeyList(value["name"], value, self.BOARD_KEY_LIST):
  4278.             return False
  4279.  
  4280.         window.SetSize(int(value["width"]), int(value["height"]))
  4281.         self.LoadDefaultData(window, value, parentWindow)
  4282.  
  4283.         return True
  4284.    
  4285.     def LoadElementThinBoardCircle(self, window, value, parentWindow):
  4286.  
  4287.         if False == self.CheckKeyList(value["name"], value, self.BOARD_KEY_LIST):
  4288.             return False
  4289.  
  4290.         window.SetSize(int(value["width"]), int(value["height"]))
  4291.         self.LoadDefaultData(window, value, parentWindow)
  4292.  
  4293.         return True
  4294.    
  4295.     ## Box
  4296.     def LoadElementBox(self, window, value, parentWindow):
  4297.  
  4298.         if False == self.CheckKeyList(value["name"], value, self.BOX_KEY_LIST):
  4299.             return False
  4300.  
  4301.         if True == value.has_key("color"):
  4302.             window.SetColor(value["color"])
  4303.  
  4304.         window.SetSize(int(value["width"]), int(value["height"]))
  4305.         self.LoadDefaultData(window, value, parentWindow)
  4306.  
  4307.         return True
  4308.  
  4309.     ## Bar
  4310.     def LoadElementBar(self, window, value, parentWindow):
  4311.  
  4312.         if False == self.CheckKeyList(value["name"], value, self.BAR_KEY_LIST):
  4313.             return False
  4314.  
  4315.         if True == value.has_key("color"):
  4316.             window.SetColor(value["color"])
  4317.  
  4318.         window.SetSize(int(value["width"]), int(value["height"]))
  4319.         self.LoadDefaultData(window, value, parentWindow)
  4320.  
  4321.         return True
  4322.  
  4323.     ## Line
  4324.     def LoadElementLine(self, window, value, parentWindow):
  4325.  
  4326.         if False == self.CheckKeyList(value["name"], value, self.LINE_KEY_LIST):
  4327.             return False
  4328.  
  4329.         if True == value.has_key("color"):
  4330.             window.SetColor(value["color"])
  4331.  
  4332.         window.SetSize(int(value["width"]), int(value["height"]))
  4333.         self.LoadDefaultData(window, value, parentWindow)
  4334.  
  4335.         return True
  4336.  
  4337.     ## Slot
  4338.     def LoadElementSlotBar(self, window, value, parentWindow):
  4339.  
  4340.         if False == self.CheckKeyList(value["name"], value, self.SLOTBAR_KEY_LIST):
  4341.             return False
  4342.  
  4343.         window.SetSize(int(value["width"]), int(value["height"]))
  4344.         self.LoadDefaultData(window, value, parentWindow)
  4345.  
  4346.         return True
  4347.  
  4348.     ## Gauge
  4349.     def LoadElementGauge(self, window, value, parentWindow):
  4350.  
  4351.         if False == self.CheckKeyList(value["name"], value, self.GAUGE_KEY_LIST):
  4352.             return False
  4353.  
  4354.         window.MakeGauge(value["width"], value["color"])
  4355.         self.LoadDefaultData(window, value, parentWindow)
  4356.  
  4357.         return True
  4358.  
  4359.     ## ScrollBar
  4360.     def LoadElementScrollBar(self, window, value, parentWindow):
  4361.  
  4362.         if False == self.CheckKeyList(value["name"], value, self.SCROLLBAR_KEY_LIST):
  4363.             return False
  4364.  
  4365.         window.SetScrollBarSize(value["size"])
  4366.         self.LoadDefaultData(window, value, parentWindow)
  4367.  
  4368.         return True
  4369.  
  4370.     ## SliderBar
  4371.     def LoadElementSliderBar(self, window, value, parentWindow):
  4372.  
  4373.         self.LoadDefaultData(window, value, parentWindow)
  4374.  
  4375.         return True
  4376.  
  4377.     ## ListBox
  4378.     def LoadElementListBox(self, window, value, parentWindow):
  4379.  
  4380.         if False == self.CheckKeyList(value["name"], value, self.LIST_BOX_KEY_LIST):
  4381.             return False
  4382.  
  4383.         if value.has_key("item_align"):
  4384.             window.SetTextCenterAlign(value["item_align"])
  4385.  
  4386.         window.SetSize(value["width"], value["height"])
  4387.         self.LoadDefaultData(window, value, parentWindow)
  4388.  
  4389.         return True
  4390.  
  4391.     ## ListBox2
  4392.     def LoadElementListBox2(self, window, value, parentWindow):
  4393.  
  4394.         if False == self.CheckKeyList(value["name"], value, self.LIST_BOX_KEY_LIST):
  4395.             return False
  4396.  
  4397.         window.SetRowCount(value.get("row_count", 10))
  4398.         window.SetSize(value["width"], value["height"])
  4399.         self.LoadDefaultData(window, value, parentWindow)
  4400.  
  4401.         if value.has_key("item_align"):
  4402.             window.SetTextCenterAlign(value["item_align"])
  4403.  
  4404.         return True
  4405.     def LoadElementListBoxEx(self, window, value, parentWindow):
  4406.  
  4407.         if False == self.CheckKeyList(value["name"], value, self.LIST_BOX_KEY_LIST):
  4408.             return False
  4409.  
  4410.         window.SetSize(value["width"], value["height"])
  4411.         self.LoadDefaultData(window, value, parentWindow)
  4412.  
  4413.         if value.has_key("itemsize_x") and value.has_key("itemsize_y"):
  4414.             window.SetItemSize(int(value["itemsize_x"]), int(value["itemsize_y"]))
  4415.  
  4416.         if value.has_key("itemstep"):
  4417.             window.SetItemStep(int(value["itemstep"]))
  4418.  
  4419.         if value.has_key("viewcount"):
  4420.             window.SetViewItemCount(int(value["viewcount"]))
  4421.  
  4422.         return True
  4423.  
  4424. class ReadingWnd(Bar):
  4425.  
  4426.     def __init__(self):
  4427.         Bar.__init__(self,"TOP_MOST")
  4428.  
  4429.         self.__BuildText()
  4430.         self.SetSize(80, 19)
  4431.         self.Show()
  4432.  
  4433.     def __del__(self):
  4434.         Bar.__del__(self)
  4435.  
  4436.     def __BuildText(self):
  4437.         self.text = TextLine()
  4438.         self.text.SetParent(self)
  4439.         self.text.SetPosition(4, 3)
  4440.         self.text.Show()
  4441.  
  4442.     def SetText(self, text):
  4443.         self.text.SetText(text)
  4444.  
  4445.     def SetReadingPosition(self, x, y):
  4446.         xPos = x + 2
  4447.         yPos = y  - self.GetHeight() - 2
  4448.         self.SetPosition(xPos, yPos)
  4449.  
  4450.     def SetTextColor(self, color):
  4451.         self.text.SetPackedFontColor(color)
  4452.  
  4453.  
  4454. def MakeSlotBar(parent, x, y, width, height):
  4455.     slotBar = SlotBar()
  4456.     slotBar.SetParent(parent)
  4457.     slotBar.SetSize(width, height)
  4458.     slotBar.SetPosition(x, y)
  4459.     slotBar.Show()
  4460.     return slotBar
  4461.  
  4462. def MakeImageBox(parent, name, x, y):
  4463.     image = ImageBox()
  4464.     image.SetParent(parent)
  4465.     image.LoadImage(name)
  4466.     image.SetPosition(x, y)
  4467.     image.Show()
  4468.     return image
  4469.  
  4470. def MakeTextLine(parent):
  4471.     textLine = TextLine()
  4472.     textLine.SetParent(parent)
  4473.     textLine.SetWindowHorizontalAlignCenter()
  4474.     textLine.SetWindowVerticalAlignCenter()
  4475.     textLine.SetHorizontalAlignCenter()
  4476.     textLine.SetVerticalAlignCenter()
  4477.     textLine.Show()
  4478.     return textLine
  4479.  
  4480. def MakeButton(parent, x, y, tooltipText, path, up, over, down):
  4481.     button = Button()
  4482.     button.SetParent(parent)
  4483.     button.SetPosition(x, y)
  4484.     button.SetUpVisual(path + up)
  4485.     button.SetOverVisual(path + over)
  4486.     button.SetDownVisual(path + down)
  4487.     button.SetToolTipText(tooltipText)
  4488.     button.Show()
  4489.     return button
  4490.  
  4491. def RenderRoundBox(x, y, width, height, color):
  4492.     grp.SetColor(color)
  4493.     grp.RenderLine(x+2, y, width-3, 0)
  4494.     grp.RenderLine(x+2, y+height, width-3, 0)
  4495.     grp.RenderLine(x, y+2, 0, height-4)
  4496.     grp.RenderLine(x+width, y+1, 0, height-3)
  4497.     grp.RenderLine(x, y+2, 2, -2)
  4498.     grp.RenderLine(x, y+height-2, 2, 2)
  4499.     grp.RenderLine(x+width-2, y, 2, 2)
  4500.     grp.RenderLine(x+width-2, y+height, 2, -2)
  4501.  
  4502. def GenerateColor(r, g, b):
  4503.     r = float(r) / 255.0
  4504.     g = float(g) / 255.0
  4505.     b = float(b) / 255.0
  4506.     return grp.GenerateColor(r, g, b, 1.0)
  4507.  
  4508. def EnablePaste(flag):
  4509.     ime.EnablePaste(flag)
  4510.  
  4511. def GetHyperlink():
  4512.     return wndMgr.GetHyperlink()
  4513.  
  4514. def MakeText(parent, textlineText, x, y, color):
  4515.     textline = TextLine()
  4516.     if parent != None:
  4517.         textline.SetParent(parent)
  4518.     textline.SetPosition(x, y)
  4519.     if color != None:
  4520.         textline.SetFontColor(color[0], color[1], color[2])
  4521.     textline.SetText(textlineText)
  4522.     textline.Show()
  4523.     return textline
  4524. def MakeThinBoard(parent,  x, y, width, heigh, moveable=FALSE,center=FALSE):
  4525.     thin = ThinBoard()
  4526.     if parent != None:
  4527.         thin.SetParent(parent)
  4528.     if moveable == TRUE:
  4529.         thin.AddFlag('movable')
  4530.         thin.AddFlag('float')
  4531.     thin.SetSize(width, heigh)
  4532.     thin.SetPosition(x, y)
  4533.     if center == TRUE:
  4534.         thin.SetCenterPosition()
  4535.     thin.Show()
  4536.     return thin
  4537.  
  4538. RegisterToolTipWindow("TEXT", TextLine)
  4539.  
  4540. class CheckBox(Window):
  4541.     def __init__(self):
  4542.         Window.__init__(self)
  4543.        
  4544.         self.backgroundImage = None
  4545.         self.checkImage = None
  4546.  
  4547.         self.eventFunc = { "ON_CHECK" : None, "ON_UNCKECK" : None, }
  4548.         self.eventArgs = { "ON_CHECK" : None, "ON_UNCKECK" : None, }
  4549.    
  4550.         self.CreateElements()
  4551.        
  4552.     def __del__(self):
  4553.         Window.__del__(self)
  4554.        
  4555.         self.backgroundImage = None
  4556.         self.checkImage = None
  4557.        
  4558.         self.eventFunc = { "ON_CHECK" : None, "ON_UNCKECK" : None, }
  4559.         self.eventArgs = { "ON_CHECK" : None, "ON_UNCKECK" : None, }
  4560.        
  4561.     def CreateElements(self):
  4562.         self.backgroundImage = ImageBox()
  4563.         self.backgroundImage.SetParent(self)
  4564.         self.backgroundImage.AddFlag("not_pick")
  4565.         self.backgroundImage.LoadImage("d:/ymir work/ui/game/refine/checkbox.tga")
  4566.         self.backgroundImage.Show()
  4567.        
  4568.         self.checkImage = ImageBox()
  4569.         self.checkImage.SetParent(self)
  4570.         self.checkImage.AddFlag("not_pick")
  4571.         self.checkImage.SetPosition(0, -4)
  4572.         self.checkImage.LoadImage("d:/ymir work/ui/game/refine/checked.tga")
  4573.         self.checkImage.Hide()
  4574.        
  4575.         self.textInfo = TextLine()
  4576.         self.textInfo.SetParent(self)
  4577.         self.textInfo.SetPosition(20, -2)
  4578.         self.textInfo.Show()
  4579.        
  4580.         self.SetSize(self.backgroundImage.GetWidth() + self.textInfo.GetTextSize()[0], self.backgroundImage.GetHeight() + self.textInfo.GetTextSize()[1])
  4581.        
  4582.     def SetTextInfo(self, info):
  4583.         if self.textInfo:
  4584.             self.textInfo.SetText(info)
  4585.            
  4586.         self.SetSize(self.backgroundImage.GetWidth() + self.textInfo.GetTextSize()[0], self.backgroundImage.GetHeight() + self.textInfo.GetTextSize()[1])
  4587.        
  4588.     def SetCheckStatus(self, flag):
  4589.         if flag:
  4590.             self.checkImage.Show()
  4591.         else:
  4592.             self.checkImage.Hide()
  4593.    
  4594.     def GetCheckStatus(self):
  4595.         if self.checkImage:
  4596.             return self.checkImage.IsShow()
  4597.            
  4598.         return False
  4599.        
  4600.     def SetEvent(self, func, *args) :
  4601.         result = self.eventFunc.has_key(args[0])       
  4602.         if result :
  4603.             self.eventFunc[args[0]] = func
  4604.             self.eventArgs[args[0]] = args
  4605.         else :
  4606.             print "[ERROR] ui.py SetEvent, Can`t Find has_key : %s" % args[0]
  4607.        
  4608.     def OnMouseLeftButtonUp(self):
  4609.         if self.checkImage:
  4610.             if self.checkImage.IsShow():
  4611.                 self.checkImage.Hide()
  4612.  
  4613.                 if self.eventFunc["ON_UNCKECK"]:
  4614.                     apply(self.eventFunc["ON_UNCKECK"], self.eventArgs["ON_UNCKECK"])
  4615.             else:
  4616.                 self.checkImage.Show()
  4617.  
  4618.                 if self.eventFunc["ON_CHECK"]:
  4619.                     apply(self.eventFunc["ON_CHECK"], self.eventArgs["ON_CHECK"])
  4620.  
Add Comment
Please, Sign In to add comment