deadx2

Untitled

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