Advertisement
deadx2

Untitled

Aug 29th, 2017
197
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
text 140.74 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.  
  2685. class SlotBarMG(Window):
  2686. def __init__(self):
  2687. Window.__init__(self)
  2688.  
  2689. self.MakeBoard()
  2690.  
  2691. def MakeBoard(self):
  2692. self.Left = ExpandedImageBox()
  2693. self.Left.SetParent(self)
  2694. self.Left.AddFlag("not_pick")
  2695. self.Left.SetPosition(0, 0)
  2696. self.Left.LoadImage("illumina/slotbar/illumina_bar_left.tga")
  2697. self.Left.Show()
  2698.  
  2699. self.Center = ExpandedImageBox()
  2700. self.Center.SetParent(self)
  2701. self.Center.AddFlag("not_pick")
  2702. self.Center.SetPosition(1, 0)
  2703. self.Center.LoadImage("illumina/slotbar/illumina_bar_center.tga")
  2704. self.Center.Show()
  2705.  
  2706. self.Right = ExpandedImageBox()
  2707. self.Right.SetParent(self)
  2708. self.Right.AddFlag("not_pick")
  2709. self.Right.SetPosition(0, 0)
  2710. self.Right.LoadImage("illumina/slotbar/illumina_bar_right.tga")
  2711. self.Right.Show()
  2712.  
  2713. def __del__(self):
  2714. Window.__del__(self)
  2715.  
  2716. def SetWidth(self, width):
  2717.  
  2718. width = max(6, width)
  2719. Window.SetSize(self, width, 23)
  2720.  
  2721. horizontalShowingPercentage = float((width - 6) - 1) / 1
  2722. self.Center.SetRenderingRect(0, 0, horizontalShowingPercentage, 0)
  2723. self.Right.SetPosition(width-6, 0)
  2724.  
  2725.  
  2726.  
  2727.  
  2728. class Board(Window):
  2729.  
  2730. CORNER_WIDTH = 55
  2731. CORNER_HEIGHT = 55
  2732. LINE_WIDTH = 128
  2733. LINE_HEIGHT = 128
  2734.  
  2735. LT = 0
  2736. LB = 1
  2737. RT = 2
  2738. RB = 3
  2739. L = 0
  2740. R = 1
  2741. T = 2
  2742. B = 3
  2743.  
  2744. def __init__(self):
  2745. Window.__init__(self)
  2746.  
  2747. self.MakeBoard("d:/ymir work/ui/pattern/Board_Corner_", "d:/ymir work/ui/pattern/Board_Line_")
  2748. self.MakeBase()
  2749.  
  2750. def MakeBoard(self, cornerPath, linePath):
  2751.  
  2752. CornerFileNames = [ cornerPath+dir+".tga" for dir in ("LeftTop", "LeftBottom", "RightTop", "RightBottom", ) ]
  2753. LineFileNames = [ linePath+dir+".tga" for dir in ("Left", "Right", "Top", "Bottom", ) ]
  2754. """
  2755. CornerFileNames = (
  2756. "d:/ymir work/ui/pattern/Board_Corner_LeftTop.tga",
  2757. "d:/ymir work/ui/pattern/Board_Corner_LeftBottom.tga",
  2758. "d:/ymir work/ui/pattern/Board_Corner_RightTop.tga",
  2759. "d:/ymir work/ui/pattern/Board_Corner_RightBottom.tga",
  2760. )
  2761. LineFileNames = (
  2762. "d:/ymir work/ui/pattern/Board_Line_Left.tga",
  2763. "d:/ymir work/ui/pattern/Board_Line_Right.tga",
  2764. "d:/ymir work/ui/pattern/Board_Line_Top.tga",
  2765. "d:/ymir work/ui/pattern/Board_Line_Bottom.tga",
  2766. )
  2767. """
  2768.  
  2769. self.Corners = []
  2770. for fileName in CornerFileNames:
  2771. Corner = ExpandedImageBox()
  2772. Corner.AddFlag("not_pick")
  2773. Corner.LoadImage(fileName)
  2774. Corner.SetParent(self)
  2775. Corner.SetPosition(0, 0)
  2776. Corner.Show()
  2777. self.Corners.append(Corner)
  2778.  
  2779. self.Lines = []
  2780. for fileName in LineFileNames:
  2781. Line = ExpandedImageBox()
  2782. Line.AddFlag("not_pick")
  2783. Line.LoadImage(fileName)
  2784. Line.SetParent(self)
  2785. Line.SetPosition(0, 0)
  2786. Line.Show()
  2787. self.Lines.append(Line)
  2788.  
  2789. self.Lines[self.L].SetPosition(0, self.CORNER_HEIGHT)
  2790. self.Lines[self.T].SetPosition(self.CORNER_WIDTH, 0)
  2791.  
  2792. def MakeBase(self):
  2793. self.Base = ExpandedImageBox()
  2794. self.Base.AddFlag("not_pick")
  2795. self.Base.LoadImage("d:/ymir work/ui/pattern/Board_Base.tga")
  2796. self.Base.SetParent(self)
  2797. self.Base.SetPosition(self.CORNER_WIDTH, self.CORNER_HEIGHT)
  2798. self.Base.Show()
  2799.  
  2800. self.Decoration = ExpandedImageBox()
  2801. self.Decoration.AddFlag("not_pick")
  2802. self.Decoration.LoadImage("d:/ymir work/ui/pattern/decoration_leftbottom.tga")
  2803. self.Decoration.SetParent(self)
  2804. self.Decoration.SetPosition(self.CORNER_WIDTH, self.CORNER_HEIGHT)
  2805. self.Decoration.Show()
  2806.  
  2807. def __del__(self):
  2808. Window.__del__(self)
  2809.  
  2810. def SetSize(self, width, height):
  2811.  
  2812. width = max(self.CORNER_WIDTH*2, width)
  2813. height = max(self.CORNER_HEIGHT*2, height)
  2814. Window.SetSize(self, width, height)
  2815.  
  2816. self.Corners[self.LB].SetPosition(0, height - self.CORNER_HEIGHT)
  2817. self.Corners[self.RT].SetPosition(width - self.CORNER_WIDTH, 0)
  2818. self.Corners[self.RB].SetPosition(width - self.CORNER_WIDTH, height - self.CORNER_HEIGHT)
  2819. self.Lines[self.R].SetPosition(width - self.CORNER_WIDTH, self.CORNER_HEIGHT)
  2820. self.Lines[self.B].SetPosition(self.CORNER_HEIGHT, height - self.CORNER_HEIGHT)
  2821.  
  2822. self.Decoration.SetPosition(-5,height-57)
  2823.  
  2824. verticalShowingPercentage = float((height - self.CORNER_HEIGHT*2) - self.LINE_HEIGHT) / self.LINE_HEIGHT
  2825. horizontalShowingPercentage = float((width - self.CORNER_WIDTH*2) - self.LINE_WIDTH) / self.LINE_WIDTH
  2826. self.Lines[self.L].SetRenderingRect(0, 0, 0, verticalShowingPercentage)
  2827. self.Lines[self.R].SetRenderingRect(0, 0, 0, verticalShowingPercentage)
  2828. self.Lines[self.T].SetRenderingRect(0, 0, horizontalShowingPercentage, 0)
  2829. self.Lines[self.B].SetRenderingRect(0, 0, horizontalShowingPercentage, 0)
  2830.  
  2831. if self.Base:
  2832. self.Base.SetRenderingRect(0, 0, horizontalShowingPercentage, verticalShowingPercentage)
  2833.  
  2834. class BoardWithTitleBar(Board):
  2835. def __init__(self):
  2836. Board.__init__(self)
  2837.  
  2838. titleBar = TitleBar()
  2839. titleBar.SetParent(self)
  2840. titleBar.MakeTitleBar(0, "red")
  2841. titleBar.SetPosition(8, 7)
  2842. titleBar.Show()
  2843.  
  2844. titleName = TextLine()
  2845. titleName.SetParent(titleBar)
  2846. titleName.SetPosition(0, 7)
  2847. titleName.SetWindowHorizontalAlignCenter()
  2848. titleName.SetHorizontalAlignCenter()
  2849. titleName.Show()
  2850.  
  2851. self.titleBar = titleBar
  2852. self.titleName = titleName
  2853.  
  2854. self.SetCloseEvent(self.Hide)
  2855.  
  2856. def __del__(self):
  2857. Board.__del__(self)
  2858. self.titleBar = None
  2859. self.titleName = None
  2860.  
  2861. def SetSize(self, width, height):
  2862. self.titleBar.SetWidth(width - 15)
  2863. #self.pickRestrictWindow.SetSize(width, height - 30)
  2864. Board.SetSize(self, width, height)
  2865. self.titleName.UpdateRect()
  2866.  
  2867. def SetTitleColor(self, color):
  2868. self.titleName.SetPackedFontColor(color)
  2869.  
  2870. def SetTitleName(self, name):
  2871. self.titleName.SetText(name)
  2872.  
  2873. def SetCloseEvent(self, event):
  2874. self.titleBar.SetCloseEvent(event)
  2875.  
  2876. class ThinBoard(Window):
  2877.  
  2878. CORNER_WIDTH = 21
  2879. CORNER_HEIGHT = 21
  2880. LINE_WIDTH = 21
  2881. LINE_HEIGHT = 21
  2882. BOARD_COLOR = grp.GenerateColor(0.0, 0.0, 0.0, 0.6)
  2883.  
  2884. LT = 0
  2885. LB = 1
  2886. RT = 2
  2887. RB = 3
  2888. L = 0
  2889. R = 1
  2890. T = 2
  2891. B = 3
  2892.  
  2893. def __init__(self, layer = "UI"):
  2894. Window.__init__(self, layer)
  2895.  
  2896. CornerFileNames = [ "d:/ymir work/ui/pattern/ThinBoard_Corner_"+dir+".tga" for dir in ["LeftTop","LeftBottom","RightTop","RightBottom"] ]
  2897. LineFileNames = [ "d:/ymir work/ui/pattern/ThinBoard_Line_"+dir+".tga" for dir in ["Left","Right","Top","Bottom"] ]
  2898.  
  2899. self.Corners = []
  2900. for fileName in CornerFileNames:
  2901. Corner = ExpandedImageBox()
  2902. Corner.AddFlag("attach")
  2903. Corner.AddFlag("not_pick")
  2904. Corner.LoadImage(fileName)
  2905. Corner.SetParent(self)
  2906. Corner.SetPosition(0, 0)
  2907. Corner.Show()
  2908. self.Corners.append(Corner)
  2909.  
  2910. self.Lines = []
  2911. for fileName in LineFileNames:
  2912. Line = ExpandedImageBox()
  2913. Line.AddFlag("attach")
  2914. Line.AddFlag("not_pick")
  2915. Line.LoadImage(fileName)
  2916. Line.SetParent(self)
  2917. Line.SetPosition(0, 0)
  2918. Line.Show()
  2919. self.Lines.append(Line)
  2920.  
  2921. Base = Bar()
  2922. Base.SetParent(self)
  2923. Base.AddFlag("attach")
  2924. Base.AddFlag("not_pick")
  2925. Base.SetPosition(self.CORNER_WIDTH, self.CORNER_HEIGHT)
  2926. Base.SetColor(self.BOARD_COLOR)
  2927. Base.Show()
  2928. self.Base = Base
  2929.  
  2930. self.Lines[self.L].SetPosition(0, self.CORNER_HEIGHT)
  2931. self.Lines[self.T].SetPosition(self.CORNER_WIDTH, 0)
  2932.  
  2933. def __del__(self):
  2934. Window.__del__(self)
  2935.  
  2936. if app.ENABLE_SEND_TARGET_INFO:
  2937. def ShowCorner(self, corner):
  2938. self.Corners[corner].Show()
  2939. self.SetSize(self.GetWidth(), self.GetHeight())
  2940.  
  2941. def HideCorners(self, corner):
  2942. self.Corners[corner].Hide()
  2943. self.SetSize(self.GetWidth(), self.GetHeight())
  2944.  
  2945. def ShowLine(self, line):
  2946. self.Lines[line].Show()
  2947. self.SetSize(self.GetWidth(), self.GetHeight())
  2948.  
  2949. def HideLine(self, line):
  2950. self.Lines[line].Hide()
  2951. self.SetSize(self.GetWidth(), self.GetHeight())
  2952.  
  2953. def SetSize(self, width, height):
  2954.  
  2955. width = max(self.CORNER_WIDTH*2, width)
  2956. height = max(self.CORNER_HEIGHT*2, height)
  2957. Window.SetSize(self, width, height)
  2958.  
  2959. self.Corners[self.LB].SetPosition(0, height - self.CORNER_HEIGHT)
  2960. self.Corners[self.RT].SetPosition(width - self.CORNER_WIDTH, 0)
  2961. self.Corners[self.RB].SetPosition(width - self.CORNER_WIDTH, height - self.CORNER_HEIGHT)
  2962. self.Lines[self.R].SetPosition(width - self.CORNER_WIDTH, self.CORNER_HEIGHT)
  2963. self.Lines[self.B].SetPosition(self.CORNER_HEIGHT, height - self.CORNER_HEIGHT)
  2964.  
  2965. verticalShowingPercentage = float((height - self.CORNER_HEIGHT*2) - self.LINE_HEIGHT) / self.LINE_HEIGHT
  2966. horizontalShowingPercentage = float((width - self.CORNER_WIDTH*2) - self.LINE_WIDTH) / self.LINE_WIDTH
  2967. self.Lines[self.L].SetRenderingRect(0, 0, 0, verticalShowingPercentage)
  2968. self.Lines[self.R].SetRenderingRect(0, 0, 0, verticalShowingPercentage)
  2969. self.Lines[self.T].SetRenderingRect(0, 0, horizontalShowingPercentage, 0)
  2970. self.Lines[self.B].SetRenderingRect(0, 0, horizontalShowingPercentage, 0)
  2971. self.Base.SetSize(width - self.CORNER_WIDTH*2, height - self.CORNER_HEIGHT*2)
  2972.  
  2973. def ShowInternal(self):
  2974. self.Base.Show()
  2975. for wnd in self.Lines:
  2976. wnd.Show()
  2977. for wnd in self.Corners:
  2978. wnd.Show()
  2979.  
  2980. def HideInternal(self):
  2981. self.Base.Hide()
  2982. for wnd in self.Lines:
  2983. wnd.Hide()
  2984. for wnd in self.Corners:
  2985. wnd.Hide()
  2986.  
  2987. ############## NOWE OKNO ###############
  2988.  
  2989.  
  2990.  
  2991. class ThinBoardNew(Window):
  2992.  
  2993. CORNER_WIDTH = 16
  2994. CORNER_HEIGHT = 16
  2995. LINE_WIDTH = 1
  2996. LINE_HEIGHT = 1
  2997.  
  2998. LT = 0
  2999. LB = 1
  3000. RT = 2
  3001. RB = 3
  3002. L = 0
  3003. R = 1
  3004. T = 2
  3005. B = 3
  3006.  
  3007. def __init__(self):
  3008. Window.__init__(self)
  3009.  
  3010. self.MakeBoard("d:/ymir work/ui/pattern/newbar/bar_corner_", "d:/ymir work/ui/pattern/newbar/bar_")
  3011. self.MakeBase()
  3012.  
  3013. def MakeBoard(self, cornerPath, linePath):
  3014.  
  3015. CornerFileNames = [ cornerPath+dir+".tga" for dir in ("LeftTop", "LeftBottom", "RightTop", "RightBottom", ) ]
  3016. LineFileNames = [ linePath+dir+".tga" for dir in ("Left", "Right", "Top", "Bottom", ) ]
  3017. """
  3018. CornerFileNames = (
  3019. "d:/ymir work/ui/pattern/Board_Corner_LeftTop.tga",
  3020. "d:/ymir work/ui/pattern/Board_Corner_LeftBottom.tga",
  3021. "d:/ymir work/ui/pattern/Board_Corner_RightTop.tga",
  3022. "d:/ymir work/ui/pattern/Board_Corner_RightBottom.tga",
  3023. )
  3024. LineFileNames = (
  3025. "d:/ymir work/ui/pattern/Board_Line_Left.tga",
  3026. "d:/ymir work/ui/pattern/Board_Line_Right.tga",
  3027. "d:/ymir work/ui/pattern/Board_Line_Top.tga",
  3028. "d:/ymir work/ui/pattern/Board_Line_Bottom.tga",
  3029. )
  3030. """
  3031.  
  3032. self.Corners = []
  3033. for fileName in CornerFileNames:
  3034. Corner = ExpandedImageBox()
  3035. Corner.AddFlag("not_pick")
  3036. Corner.LoadImage(fileName)
  3037. Corner.SetParent(self)
  3038. Corner.SetPosition(0, 0)
  3039. Corner.Show()
  3040. self.Corners.append(Corner)
  3041.  
  3042. self.Lines = []
  3043. for fileName in LineFileNames:
  3044. Line = ExpandedImageBox()
  3045. Line.AddFlag("not_pick")
  3046. Line.LoadImage(fileName)
  3047. Line.SetParent(self)
  3048. Line.SetPosition(0, 0)
  3049. Line.Show()
  3050. self.Lines.append(Line)
  3051.  
  3052. self.Lines[self.L].SetPosition(0, self.CORNER_HEIGHT)
  3053. self.Lines[self.T].SetPosition(self.CORNER_WIDTH, 0)
  3054.  
  3055. def MakeBase(self):
  3056. self.Base = ExpandedImageBox()
  3057. self.Base.AddFlag("not_pick")
  3058. self.Base.LoadImage("d:/ymir work/ui/pattern/newbar/bar_fill.tga")
  3059. self.Base.SetParent(self)
  3060. self.Base.SetPosition(self.CORNER_WIDTH, self.CORNER_HEIGHT)
  3061. self.Base.Show()
  3062.  
  3063. def __del__(self):
  3064. Window.__del__(self)
  3065.  
  3066. def SetSize(self, width, height):
  3067.  
  3068. width = max(self.CORNER_WIDTH*2, width)
  3069. height = max(self.CORNER_HEIGHT*2, height)
  3070. Window.SetSize(self, width, height)
  3071.  
  3072. self.Corners[self.LB].SetPosition(0, height - self.CORNER_HEIGHT)
  3073. self.Corners[self.RT].SetPosition(width - self.CORNER_WIDTH, 0)
  3074. self.Corners[self.RB].SetPosition(width - self.CORNER_WIDTH, height - self.CORNER_HEIGHT)
  3075. self.Lines[self.R].SetPosition(width - self.CORNER_WIDTH, self.CORNER_HEIGHT)
  3076. self.Lines[self.B].SetPosition(self.CORNER_HEIGHT, height - self.CORNER_HEIGHT)
  3077.  
  3078. verticalShowingPercentage = float((height - self.CORNER_HEIGHT*2) - self.LINE_HEIGHT) / self.LINE_HEIGHT
  3079. horizontalShowingPercentage = float((width - self.CORNER_WIDTH*2) - self.LINE_WIDTH) / self.LINE_WIDTH
  3080. self.Lines[self.L].SetRenderingRect(0, 0, 0, verticalShowingPercentage)
  3081. self.Lines[self.R].SetRenderingRect(0, 0, 0, verticalShowingPercentage)
  3082. self.Lines[self.T].SetRenderingRect(0, 0, horizontalShowingPercentage, 0)
  3083. self.Lines[self.B].SetRenderingRect(0, 0, horizontalShowingPercentage, 0)
  3084.  
  3085. if self.Base:
  3086. self.Base.SetRenderingRect(0, 0, horizontalShowingPercentage, verticalShowingPercentage)
  3087.  
  3088.  
  3089. class ScrollBar(Window):
  3090.  
  3091. SCROLLBAR_WIDTH = 17
  3092. SCROLLBAR_MIDDLE_HEIGHT = 1
  3093. SCROLLBAR_BUTTON_WIDTH = 17
  3094. SCROLLBAR_BUTTON_HEIGHT = 17
  3095. MIDDLE_BAR_POS = 5
  3096. MIDDLE_BAR_UPPER_PLACE = 3
  3097. MIDDLE_BAR_DOWNER_PLACE = 4
  3098. TEMP_SPACE = MIDDLE_BAR_UPPER_PLACE + MIDDLE_BAR_DOWNER_PLACE
  3099. SCROLLBAR_IS_MOVE = False
  3100.  
  3101. class MiddleBar(DragButton):
  3102.  
  3103. SCROLLBAR_IS_MOVE_TWO = False
  3104.  
  3105. def __init__(self):
  3106. DragButton.__init__(self)
  3107. self.AddFlag("movable")
  3108. #self.AddFlag("restrict_x")
  3109.  
  3110. def MakeImage(self):
  3111. top = ImageBox()
  3112. top.SetParent(self)
  3113. top.LoadImage("illumina/controls/common/scrollbar/btn_board_middle_top_01_normal.tga")
  3114. top.SetPosition(1, 0)
  3115. top.AddFlag("not_pick")
  3116. top.Show()
  3117.  
  3118. # under_image = ExpandedImageBox()
  3119. # under_image.SetParent(self)
  3120. # under_image.LoadImage("illumina/inne/scrollbar_pod_grip.tga")
  3121. # under_image.SetPosition(0, 0)
  3122. # under_image.AddFlag("not_pick")
  3123. # under_image.Show()
  3124.  
  3125. bottom = ImageBox()
  3126. bottom.SetParent(self)
  3127. bottom.LoadImage("illumina/controls/common/scrollbar/btn_board_middle_bottom_01_normal.tga")
  3128. bottom.SetPosition(10, 0)
  3129. bottom.AddFlag("not_pick")
  3130. bottom.Show()
  3131.  
  3132. middle = ExpandedScrollBar()
  3133. middle.SetParent(self)
  3134. middle.SetUpVisual("illumina/controls/common/scrollbar/btn_board_middle_center_01_normal.tga")
  3135. #middle.SetOverVisual("illumina/controls/common/scrollbar/btn_board_middle_center_02_hover.tga")
  3136. #middle.SetDownVisual("illumina/controls/common/scrollbar/btn_board_middle_center_03_active.tga")
  3137. middle.SetPosition(1, 3)
  3138. middle.AddFlag("not_pick")
  3139. middle.Show()
  3140.  
  3141. #middleHover = ImageBox()
  3142. #middleHover.SetParent(self)
  3143. #middleHover.SetOverVisual("illumina/controls/common/scrollbar/btn_board_middle_center_02_hover.tga")
  3144. #middleHover.SetPosition(0, 30)
  3145. #middleHover.AddFlag("not_pick")
  3146. #middleHover.Show()
  3147.  
  3148. #middleActiv = ImageBox()
  3149. #middleActiv.SetParent(self)
  3150. #middleActiv.SetDownVisual("illumina/controls/common/scrollbar/btn_board_middle_center_03_active.tga")
  3151. #middleActiv.SetPosition(0, 20)
  3152. #middleActiv.AddFlag("not_pick")
  3153. #middleActiv.Show()
  3154.  
  3155. grip = ImageBox()
  3156. grip.SetParent(self)
  3157. grip.LoadImage("illumina/controls/common/scrollbar/btn_board_middle_grip_01_normal.tga")
  3158. #grip.LoadImage("illumina/controls/common/scrollbar/btn_board_middle_grip_02_hover.tga")
  3159. #grip.LoadImage("illumina/controls/common/scrollbar/btn_board_middle_grip_03_active.tga")
  3160. # btnClose.SetUpVisual("d:/ymir work/ui/pattern/board_close_normal.tga")
  3161. # btnClose.SetOverVisual("d:/ymir work/ui/pattern/board_close_hover.tga")
  3162. # btnClose.SetDownVisual("d:/ymir work/ui/pattern/board_close_active.tga")
  3163. grip.SetPosition(1, 0)
  3164. grip.AddFlag("not_pick")
  3165. grip.Show()
  3166.  
  3167. # under_image = under_image
  3168. self.top = top
  3169. self.bottom = bottom
  3170. self.middle = middle
  3171. #self.middleHover = middleHover
  3172. #self.middleActiv = middleActiv
  3173. self.grip = grip
  3174. self.on_hover = True
  3175. # self.under_image = under_image
  3176.  
  3177. def SetSize(self, height):
  3178. height = max(12, height)
  3179. DragButton.SetSize(self, 10, height)
  3180. self.bottom.SetPosition(0, height-4)
  3181. # self.under_image.SetRenderingRect(0, height, 0, 0)
  3182.  
  3183. height -= 4*2
  3184. #if self.SCROLLBAR_IS_MOVE_TWO:
  3185. # self.middleActiv.Show()
  3186. # self.middleActiv.SetRenderingRect(0, 0, 0, float(height)/1.0)
  3187. #elif self.on_hover:
  3188. self.middle.SetRenderingRect(0, 0, 0, float(height)/1.0)
  3189. #else:
  3190. # self.middleHover.SetRenderingRect(0, 0, 0, float(height)/1.0)
  3191. self.grip.SetPosition(0, float(height)/2.0)
  3192.  
  3193.  
  3194. def __init__(self):
  3195. Window.__init__(self)
  3196.  
  3197. self.pageSize = 1
  3198. self.curPos = 0.0
  3199. self.eventScroll = lambda *arg: None
  3200. self.eventScrollUp = lambda *arg: None
  3201. self.eventScrollDown = lambda *arg: None
  3202. self.lockFlag = FALSE
  3203.  
  3204. self.CreateScrollBar()
  3205.  
  3206. def __del__(self):
  3207. Window.__del__(self)
  3208.  
  3209. def CreateScrollBar(self):
  3210. barSlot = Bar3D()
  3211. barSlot.SetParent(self)
  3212. barSlot.AddFlag("not_pick")
  3213. barSlot.Show()
  3214.  
  3215. down_grip = ExpandedImageBox()
  3216. down_grip.SetParent(barSlot)
  3217. down_grip.LoadImage("illumina/inne/scrollbar_pod_grip.tga")
  3218. down_grip.SetPosition(5, 30)
  3219. down_grip.AddFlag("not_pick")
  3220. down_grip.Show()
  3221.  
  3222. middleBar = self.MiddleBar()
  3223. middleBar.SetParent(self)
  3224. middleBar.SetMoveEvent(__mem_func__(self.OnMove))
  3225. middleBar.Show()
  3226. middleBar.MakeImage()
  3227. middleBar.SetSize(12)
  3228.  
  3229. upButton = Button()
  3230. upButton.SetParent(self)
  3231. upButton.SetEvent(__mem_func__(self.OnUp))
  3232. upButton.SetUpVisual("illumina/buttons/btn_up_n.tga")
  3233. upButton.SetOverVisual("illumina/buttons/btn_up_h.tga")
  3234. upButton.SetDownVisual("illumina/buttons/btn_up_a.tga")
  3235. upButton.Show()
  3236.  
  3237. downButton = Button()
  3238. downButton.SetParent(self)
  3239. downButton.SetEvent(__mem_func__(self.OnDown))
  3240. downButton.SetUpVisual("illumina/buttons/btn_down_n.tga")
  3241. downButton.SetOverVisual("illumina/buttons/btn_down_h.tga")
  3242. downButton.SetDownVisual("illumina/buttons/btn_down_a.tga")
  3243. downButton.Show()
  3244.  
  3245. self.upButton = upButton
  3246. self.downButton = downButton
  3247. self.middleBar = middleBar
  3248. self.barSlot = barSlot
  3249. self.down_grip = down_grip
  3250.  
  3251. self.SCROLLBAR_WIDTH = self.upButton.GetWidth()
  3252. self.SCROLLBAR_MIDDLE_HEIGHT = self.middleBar.GetHeight()
  3253. self.SCROLLBAR_BUTTON_WIDTH = self.upButton.GetWidth()
  3254. self.SCROLLBAR_BUTTON_HEIGHT = self.upButton.GetHeight()
  3255.  
  3256. def Destroy(self):
  3257. self.middleBar = None
  3258. self.upButton = None
  3259. self.downButton = None
  3260. self.down_grip = None
  3261. self.eventScroll = lambda *arg: None
  3262. self.eventScrollUp = lambda *arg: None
  3263. self.eventScrollDown = lambda *arg: None
  3264.  
  3265. def SetScrollEvent(self, event):
  3266. self.eventScroll = event
  3267. self.eventScrollUp = event
  3268. self.eventScrollDown = event
  3269.  
  3270. def SetUpEvent(self, event):
  3271. self.eventScrollUp = event
  3272.  
  3273. def SetDownEvent(self, event):
  3274. self.eventScrollDown = event
  3275.  
  3276. def SetMiddleBarSize(self, pageScale):
  3277. realHeight = self.GetHeight() - self.SCROLLBAR_BUTTON_HEIGHT*2
  3278. self.SCROLLBAR_MIDDLE_HEIGHT = int(pageScale * float(realHeight))
  3279. self.middleBar.SetSize(self.SCROLLBAR_MIDDLE_HEIGHT)
  3280. self.pageSize = (self.GetHeight() - self.SCROLLBAR_BUTTON_HEIGHT*2) - self.SCROLLBAR_MIDDLE_HEIGHT - (self.TEMP_SPACE)
  3281.  
  3282. def SetScrollBarSize(self, height):
  3283. self.pageSize = (height - self.SCROLLBAR_BUTTON_HEIGHT*2) - self.SCROLLBAR_MIDDLE_HEIGHT - (self.TEMP_SPACE)
  3284. self.SetSize(self.SCROLLBAR_WIDTH, height)
  3285. self.upButton.SetPosition(0, 0)
  3286. #self.down_grip.SetRenderingRect(0, height, 0, 0)
  3287. self.downButton.SetPosition(0, height - self.SCROLLBAR_BUTTON_HEIGHT)
  3288. 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)
  3289. self.middleBar.SetPosition(self.MIDDLE_BAR_POS, 0)
  3290. self.down_grip.SetPosition(0, self.SCROLLBAR_BUTTON_HEIGHT-3)
  3291. # self.down_grip.SetSize(self.barSlot.GetWidth() - 2, self.barSlot.GetHeight() - self.SCROLLBAR_BUTTON_HEIGHT*2 - 2)
  3292. self.down_grip.SetRenderingRect(0.0, 0.0, 0.0, self.GetHeight()-27 )
  3293.  
  3294. self.UpdateBarSlot()
  3295.  
  3296. def UpdateBarSlot(self):
  3297. self.barSlot.SetPosition(0, self.SCROLLBAR_BUTTON_HEIGHT)
  3298. self.barSlot.SetSize(self.GetWidth() - 2, self.GetHeight() - self.SCROLLBAR_BUTTON_HEIGHT*2 - 2)
  3299. self.down_grip.SetPosition(0, self.SCROLLBAR_BUTTON_HEIGHT)
  3300. # self.down_grip.SetSize(self.barSlot.GetWidth() - 2, self.barSlot.GetHeight() - self.SCROLLBAR_BUTTON_HEIGHT*2 - 2)
  3301. self.down_grip.SetRenderingRect(0.0, 0.0, 0.0, self.GetHeight())
  3302.  
  3303. def GetPos(self):
  3304. return self.curPos
  3305.  
  3306. def SetPos(self, pos, event=TRUE):
  3307. pos = max(0.0, pos)
  3308. pos = min(1.0, pos)
  3309.  
  3310. newPos = float(self.pageSize) * pos
  3311. self.middleBar.SetPosition(self.MIDDLE_BAR_POS, int(newPos) + self.SCROLLBAR_BUTTON_HEIGHT + self.MIDDLE_BAR_UPPER_PLACE)
  3312.  
  3313. self.OnMove(event)
  3314.  
  3315. def SetScrollStep(self, step):
  3316. self.scrollStep = step
  3317.  
  3318. def OnUp(self):
  3319. self.SetPos(self.curPos-self.scrollStep, FALSE)
  3320. self.eventScrollUp()
  3321.  
  3322. def OnDown(self):
  3323. self.SetPos(self.curPos+self.scrollStep, FALSE)
  3324. self.eventScrollDown()
  3325.  
  3326.  
  3327. def OnMove(self, event=TRUE):
  3328.  
  3329. if self.lockFlag:
  3330. return
  3331.  
  3332. if 0 == self.pageSize:
  3333. return
  3334.  
  3335. (xLocal, yLocal) = self.middleBar.GetLocalPosition()
  3336. self.curPos = float(yLocal - self.SCROLLBAR_BUTTON_HEIGHT - self.MIDDLE_BAR_UPPER_PLACE) / float(self.pageSize)
  3337. if event == TRUE:
  3338. self.eventScroll()
  3339. self.middleBar.SCROLLBAR_IS_MOVE_TWO = True
  3340.  
  3341.  
  3342. def OnMouseLeftButtonDown(self):
  3343. (xMouseLocalPosition, yMouseLocalPosition) = self.GetMouseLocalPosition()
  3344. pickedPos = yMouseLocalPosition - self.SCROLLBAR_BUTTON_HEIGHT - self.SCROLLBAR_MIDDLE_HEIGHT/2
  3345. newPos = float(pickedPos) / float(self.pageSize)
  3346. self.SetPos(newPos)
  3347.  
  3348.  
  3349.  
  3350. def LockScroll(self):
  3351. self.lockFlag = TRUE
  3352.  
  3353. def UnlockScroll(self):
  3354. self.lockFlag = FALSE
  3355.  
  3356. def UpdateBarSlot(self):
  3357. pass
  3358. '''
  3359. class ScrollBar(Window):
  3360.  
  3361. SCROLLBAR_WIDTH = 17
  3362. SCROLLBAR_MIDDLE_HEIGHT = 9
  3363. SCROLLBAR_BUTTON_WIDTH = 17
  3364. SCROLLBAR_BUTTON_HEIGHT = 17
  3365. MIDDLE_BAR_POS = 5
  3366. MIDDLE_BAR_UPPER_PLACE = 3
  3367. MIDDLE_BAR_DOWNER_PLACE = 4
  3368. TEMP_SPACE = MIDDLE_BAR_UPPER_PLACE + MIDDLE_BAR_DOWNER_PLACE
  3369.  
  3370. class MiddleBar(DragButton):
  3371. def __init__(self):
  3372. DragButton.__init__(self)
  3373. self.AddFlag("movable")
  3374. #self.AddFlag("restrict_x")
  3375.  
  3376. def MakeImage(self):
  3377. top = ImageBox()
  3378. top.SetParent(self)
  3379. top.LoadImage("d:/ymir work/ui/pattern/ScrollBar_Top.tga")
  3380. top.SetPosition(0, 0)
  3381. top.AddFlag("not_pick")
  3382. top.Show()
  3383. bottom = ImageBox()
  3384. bottom.SetParent(self)
  3385. bottom.LoadImage("d:/ymir work/ui/pattern/ScrollBar_Bottom.tga")
  3386. bottom.AddFlag("not_pick")
  3387. bottom.Show()
  3388.  
  3389. middle = ExpandedImageBox()
  3390. middle.SetParent(self)
  3391. middle.LoadImage("d:/ymir work/ui/pattern/ScrollBar_Middle.tga")
  3392. middle.SetPosition(0, 4)
  3393. middle.AddFlag("not_pick")
  3394. middle.Show()
  3395.  
  3396. self.top = top
  3397. self.bottom = bottom
  3398. self.middle = middle
  3399.  
  3400. def SetSize(self, height):
  3401. height = max(12, height)
  3402. DragButton.SetSize(self, 10, height)
  3403. self.bottom.SetPosition(0, height-4)
  3404.  
  3405. height -= 4*3
  3406. self.middle.SetRenderingRect(0, 0, 0, float(height)/4.0)
  3407.  
  3408. def __init__(self):
  3409. Window.__init__(self)
  3410.  
  3411. self.pageSize = 1
  3412. self.curPos = 0.0
  3413. self.eventScroll = lambda *arg: None
  3414. self.eventScrollUp = lambda *arg: None
  3415. self.eventScrollDown = lambda *arg: None
  3416. self.lockFlag = FALSE
  3417.  
  3418. self.CreateScrollBar()
  3419.  
  3420. def __del__(self):
  3421. Window.__del__(self)
  3422.  
  3423. def CreateScrollBar(self):
  3424. barSlot = Bar3D()
  3425. barSlot.SetParent(self)
  3426. barSlot.AddFlag("not_pick")
  3427. barSlot.Show()
  3428.  
  3429. middleBar = self.MiddleBar()
  3430. middleBar.SetParent(self)
  3431. middleBar.SetMoveEvent(__mem_func__(self.OnMove))
  3432. middleBar.Show()
  3433. middleBar.MakeImage()
  3434. middleBar.SetSize(12)
  3435.  
  3436. upButton = Button()
  3437. upButton.SetParent(self)
  3438. upButton.SetEvent(__mem_func__(self.OnUp))
  3439. upButton.SetUpVisual("d:/ymir work/ui/public/scrollbar_up_button_01.sub")
  3440. upButton.SetOverVisual("d:/ymir work/ui/public/scrollbar_up_button_02.sub")
  3441. upButton.SetDownVisual("d:/ymir work/ui/public/scrollbar_up_button_03.sub")
  3442. upButton.Show()
  3443.  
  3444. downButton = Button()
  3445. downButton.SetParent(self)
  3446. downButton.SetEvent(__mem_func__(self.OnDown))
  3447. downButton.SetUpVisual("d:/ymir work/ui/public/scrollbar_down_button_01.sub")
  3448. downButton.SetOverVisual("d:/ymir work/ui/public/scrollbar_down_button_02.sub")
  3449. downButton.SetDownVisual("d:/ymir work/ui/public/scrollbar_down_button_03.sub")
  3450. downButton.Show()
  3451.  
  3452. self.upButton = upButton
  3453. self.downButton = downButton
  3454. self.middleBar = middleBar
  3455. self.barSlot = barSlot
  3456.  
  3457. self.SCROLLBAR_WIDTH = self.upButton.GetWidth()
  3458. self.SCROLLBAR_MIDDLE_HEIGHT = self.middleBar.GetHeight()
  3459. self.SCROLLBAR_BUTTON_WIDTH = self.upButton.GetWidth()
  3460. self.SCROLLBAR_BUTTON_HEIGHT = self.upButton.GetHeight()
  3461.  
  3462. def Destroy(self):
  3463. self.middleBar = None
  3464. self.upButton = None
  3465. self.downButton = None
  3466. self.eventScroll = lambda *arg: None
  3467. self.eventScrollUp = lambda *arg: None
  3468. self.eventScrollDown = lambda *arg: None
  3469.  
  3470. def SetScrollEvent(self, event):
  3471. self.eventScroll = event
  3472. self.eventScrollUp = event
  3473. self.eventScrollDown = event
  3474.  
  3475. def SetUpEvent(self, event):
  3476. self.eventScrollUp = event
  3477.  
  3478. def SetDownEvent(self, event):
  3479. self.eventScrollDown = event
  3480.  
  3481. def SetMiddleBarSize(self, pageScale):
  3482. realHeight = self.GetHeight() - self.SCROLLBAR_BUTTON_HEIGHT*2
  3483. self.SCROLLBAR_MIDDLE_HEIGHT = int(pageScale * float(realHeight))
  3484. self.middleBar.SetSize(self.SCROLLBAR_MIDDLE_HEIGHT)
  3485. self.pageSize = (self.GetHeight() - self.SCROLLBAR_BUTTON_HEIGHT*2) - self.SCROLLBAR_MIDDLE_HEIGHT - (self.TEMP_SPACE)
  3486.  
  3487. def SetScrollBarSize(self, height):
  3488. self.pageSize = (height - self.SCROLLBAR_BUTTON_HEIGHT*2) - self.SCROLLBAR_MIDDLE_HEIGHT - (self.TEMP_SPACE)
  3489. self.SetSize(self.SCROLLBAR_WIDTH, height)
  3490. self.upButton.SetPosition(0, 0)
  3491. self.downButton.SetPosition(0, height - self.SCROLLBAR_BUTTON_HEIGHT)
  3492. 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)
  3493. self.middleBar.SetPosition(self.MIDDLE_BAR_POS, 0)
  3494.  
  3495. self.UpdateBarSlot()
  3496.  
  3497. def UpdateBarSlot(self):
  3498. self.barSlot.SetPosition(0, self.SCROLLBAR_BUTTON_HEIGHT)
  3499. self.barSlot.SetSize(self.GetWidth() - 2, self.GetHeight() - self.SCROLLBAR_BUTTON_HEIGHT*2 - 2)
  3500.  
  3501. def GetPos(self):
  3502. return self.curPos
  3503.  
  3504. def SetPos(self, pos, event=TRUE):
  3505. pos = max(0.0, pos)
  3506. pos = min(1.0, pos)
  3507.  
  3508. newPos = float(self.pageSize) * pos
  3509. self.middleBar.SetPosition(self.MIDDLE_BAR_POS, int(newPos) + self.SCROLLBAR_BUTTON_HEIGHT + self.MIDDLE_BAR_UPPER_PLACE)
  3510. self.OnMove(event)
  3511.  
  3512. def SetScrollStep(self, step):
  3513. self.scrollStep = step
  3514.  
  3515. def OnUp(self):
  3516. self.SetPos(self.curPos-self.scrollStep, FALSE)
  3517. self.eventScrollUp()
  3518.  
  3519. def OnDown(self):
  3520. self.SetPos(self.curPos+self.scrollStep, FALSE)
  3521. self.eventScrollDown()
  3522.  
  3523. def OnMove(self, event=TRUE):
  3524.  
  3525. if self.lockFlag:
  3526. return
  3527.  
  3528. if 0 == self.pageSize:
  3529. return
  3530.  
  3531. (xLocal, yLocal) = self.middleBar.GetLocalPosition()
  3532. self.curPos = float(yLocal - self.SCROLLBAR_BUTTON_HEIGHT - self.MIDDLE_BAR_UPPER_PLACE) / float(self.pageSize)
  3533. if event == TRUE:
  3534. self.eventScroll()
  3535.  
  3536. def OnMouseLeftButtonDown(self):
  3537. (xMouseLocalPosition, yMouseLocalPosition) = self.GetMouseLocalPosition()
  3538. pickedPos = yMouseLocalPosition - self.SCROLLBAR_BUTTON_HEIGHT - self.SCROLLBAR_MIDDLE_HEIGHT/2
  3539. newPos = float(pickedPos) / float(self.pageSize)
  3540. self.SetPos(newPos)
  3541.  
  3542. def LockScroll(self):
  3543. self.lockFlag = TRUE
  3544.  
  3545. def UnlockScroll(self):
  3546. self.lockFlag = FALSE
  3547. '''
  3548. class ThinScrollBar(ScrollBar):
  3549.  
  3550. def CreateScrollBar(self):
  3551. middleBar = self.MiddleBar()
  3552. middleBar.SetParent(self)
  3553. middleBar.SetMoveEvent(__mem_func__(self.OnMove))
  3554. middleBar.Show()
  3555. middleBar.SetUpVisual("illumina/controls/common/scrollbar/btn_thinboard_middle_01_normal.tga")
  3556. middleBar.SetOverVisual("illumina/controls/common/scrollbar/btn_thinboard_middle_02_hover.tga")
  3557. middleBar.SetDownVisual("illumina/controls/common/scrollbar/btn_thinboard_middle_03_active.tga")
  3558.  
  3559. upButton = Button()
  3560. upButton.SetParent(self)
  3561. upButton.SetUpVisual("illumina/controls/common/scrollbar/btn_up_01_normal.tga")
  3562. upButton.SetOverVisual("illumina/controls/common/scrollbar/btn_up_02_hover.tga")
  3563. upButton.SetDownVisual("illumina/controls/common/scrollbar/btn_up_03_active.tga")
  3564. upButton.SetEvent(__mem_func__(self.OnUp))
  3565. upButton.Show()
  3566.  
  3567. downButton = Button()
  3568. downButton.SetParent(self)
  3569. downButton.SetUpVisual("illumina/controls/common/scrollbar/btn_down_01_normal.tga")
  3570. downButton.SetOverVisual("illumina/controls/common/scrollbar/btn_down_02_hover.tga")
  3571. downButton.SetDownVisual("illumina/controls/common/scrollbar/btn_down_03_active.tga")
  3572. downButton.SetEvent(__mem_func__(self.OnDown))
  3573. downButton.Show()
  3574.  
  3575. self.middleBar = middleBar
  3576. self.upButton = upButton
  3577. self.downButton = downButton
  3578.  
  3579. self.SCROLLBAR_WIDTH = self.upButton.GetWidth()
  3580. self.SCROLLBAR_MIDDLE_HEIGHT = self.middleBar.GetHeight()
  3581. self.SCROLLBAR_BUTTON_WIDTH = self.upButton.GetWidth()
  3582. self.SCROLLBAR_BUTTON_HEIGHT = self.upButton.GetHeight()
  3583. self.MIDDLE_BAR_POS = 0
  3584. self.MIDDLE_BAR_UPPER_PLACE = 0
  3585. self.MIDDLE_BAR_DOWNER_PLACE = 0
  3586. self.TEMP_SPACE = 0
  3587.  
  3588. def SetScrollBarSize(self, height):
  3589. self.pageSize = (height - self.SCROLLBAR_BUTTON_HEIGHT*2) - self.SCROLLBAR_MIDDLE_HEIGHT - (self.TEMP_SPACE)
  3590. self.SetSize(self.SCROLLBAR_WIDTH, height)
  3591. self.upButton.SetPosition(0, 0)
  3592. #self.down_grip.SetRenderingRect(0, height, 0, 0)
  3593. self.downButton.SetPosition(0, height - self.SCROLLBAR_BUTTON_HEIGHT)
  3594. 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)
  3595. self.middleBar.SetPosition(self.MIDDLE_BAR_POS, 0)
  3596. # self.down_grip.SetPosition(0, self.SCROLLBAR_BUTTON_HEIGHT)
  3597. # self.down_grip.SetSize(self.barSlot.GetWidth() - 2, self.barSlot.GetHeight() - self.SCROLLBAR_BUTTON_HEIGHT*2 - 2)
  3598. # self.down_grip.SetRenderingRect(0.0, 0.0, 0.0, self.GetHeight())
  3599.  
  3600. self.UpdateBarSlot()
  3601.  
  3602. def UpdateBarSlot(self):
  3603. pass
  3604.  
  3605. class SmallThinScrollBar(ScrollBar):
  3606.  
  3607. def CreateScrollBar(self):
  3608. middleBar = self.MiddleBar()
  3609. middleBar.SetParent(self)
  3610. middleBar.SetMoveEvent(__mem_func__(self.OnMove))
  3611. middleBar.Show()
  3612. middleBar.SetUpVisual("d:/ymir work/ui/public/scrollbar_small_thin_middle_button_01.sub")
  3613. middleBar.SetOverVisual("d:/ymir work/ui/public/scrollbar_small_thin_middle_button_01.sub")
  3614. middleBar.SetDownVisual("d:/ymir work/ui/public/scrollbar_small_thin_middle_button_01.sub")
  3615.  
  3616. upButton = Button()
  3617. upButton.SetParent(self)
  3618. upButton.SetUpVisual("d:/ymir work/ui/public/scrollbar_small_thin_up_button_01.sub")
  3619. upButton.SetOverVisual("d:/ymir work/ui/public/scrollbar_small_thin_up_button_02.sub")
  3620. upButton.SetDownVisual("d:/ymir work/ui/public/scrollbar_small_thin_up_button_03.sub")
  3621. upButton.SetEvent(__mem_func__(self.OnUp))
  3622. upButton.Show()
  3623.  
  3624. downButton = Button()
  3625. downButton.SetParent(self)
  3626. downButton.SetUpVisual("d:/ymir work/ui/public/scrollbar_small_thin_down_button_01.sub")
  3627. downButton.SetOverVisual("d:/ymir work/ui/public/scrollbar_small_thin_down_button_02.sub")
  3628. downButton.SetDownVisual("d:/ymir work/ui/public/scrollbar_small_thin_down_button_03.sub")
  3629. downButton.SetEvent(__mem_func__(self.OnDown))
  3630. downButton.Show()
  3631.  
  3632. self.middleBar = middleBar
  3633. self.upButton = upButton
  3634. self.downButton = downButton
  3635.  
  3636. self.SCROLLBAR_WIDTH = self.upButton.GetWidth()
  3637. self.SCROLLBAR_MIDDLE_HEIGHT = self.middleBar.GetHeight()
  3638. self.SCROLLBAR_BUTTON_WIDTH = self.upButton.GetWidth()
  3639. self.SCROLLBAR_BUTTON_HEIGHT = self.upButton.GetHeight()
  3640. self.MIDDLE_BAR_POS = 0
  3641. self.MIDDLE_BAR_UPPER_PLACE = 0
  3642. self.MIDDLE_BAR_DOWNER_PLACE = 0
  3643. self.TEMP_SPACE = 0
  3644.  
  3645. def SetScrollBarSize(self, height):
  3646. self.pageSize = (height - self.SCROLLBAR_BUTTON_HEIGHT*2) - self.SCROLLBAR_MIDDLE_HEIGHT - (self.TEMP_SPACE)
  3647. self.SetSize(self.SCROLLBAR_WIDTH, height)
  3648. self.upButton.SetPosition(0, 0)
  3649. #self.down_grip.SetRenderingRect(0, height, 0, 0)
  3650. self.downButton.SetPosition(0, height - self.SCROLLBAR_BUTTON_HEIGHT)
  3651. 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)
  3652. self.middleBar.SetPosition(self.MIDDLE_BAR_POS, 0)
  3653. # self.down_grip.SetPosition(0, self.SCROLLBAR_BUTTON_HEIGHT)
  3654. # self.down_grip.SetSize(self.barSlot.GetWidth() - 2, self.barSlot.GetHeight() - self.SCROLLBAR_BUTTON_HEIGHT*2 - 2)
  3655. # self.down_grip.SetRenderingRect(0.0, 0.0, 0.0, self.GetHeight())
  3656.  
  3657. self.UpdateBarSlot()
  3658.  
  3659. def UpdateBarSlot(self):
  3660. pass
  3661.  
  3662. class SliderBar(Window):
  3663.  
  3664. def __init__(self):
  3665. Window.__init__(self)
  3666.  
  3667. self.curPos = 1.0
  3668. self.pageSize = 1.0
  3669. self.eventChange = None
  3670.  
  3671. self.__CreateBackGroundImage()
  3672. self.__CreateCursor()
  3673.  
  3674. def __del__(self):
  3675. Window.__del__(self)
  3676.  
  3677. def __CreateBackGroundImage(self):
  3678. img = ImageBox()
  3679. img.SetParent(self)
  3680. img.LoadImage("illumina/inne/sliderbar.tga")
  3681. img.Show()
  3682. self.backGroundImage = img
  3683.  
  3684. ##
  3685. self.SetSize(self.backGroundImage.GetWidth(), self.backGroundImage.GetHeight())
  3686.  
  3687. def __CreateCursor(self):
  3688. cursor = DragButton()
  3689. cursor.AddFlag("movable")
  3690. cursor.AddFlag("restrict_y")
  3691. cursor.SetParent(self)
  3692. cursor.SetMoveEvent(__mem_func__(self.__OnMove))
  3693. cursor.SetUpVisual("illumina/inne/sliderbar_btn1.tga")
  3694. cursor.SetOverVisual("illumina/inne/sliderbar_btn2.tga")
  3695. cursor.SetDownVisual("illumina/inne/sliderbar_btn3.tga")
  3696. cursor.Show()
  3697. self.cursor = cursor
  3698.  
  3699. ##
  3700. self.cursor.SetRestrictMovementArea(0, 0, self.backGroundImage.GetWidth(), 0)
  3701. self.pageSize = self.backGroundImage.GetWidth() - self.cursor.GetWidth()
  3702.  
  3703. def __OnMove(self):
  3704. (xLocal, yLocal) = self.cursor.GetLocalPosition()
  3705. self.curPos = float(xLocal) / float(self.pageSize)
  3706.  
  3707. if self.eventChange:
  3708. self.eventChange()
  3709.  
  3710. def SetSliderPos(self, pos):
  3711. self.curPos = pos
  3712. self.cursor.SetPosition(int(self.pageSize * pos), 0)
  3713.  
  3714. def GetSliderPos(self):
  3715. return self.curPos
  3716.  
  3717. def SetEvent(self, event):
  3718. self.eventChange = event
  3719.  
  3720. def Enable(self):
  3721. self.cursor.Show()
  3722.  
  3723. def Disable(self):
  3724. self.cursor.Hide()
  3725.  
  3726. class ListBox(Window):
  3727.  
  3728. TEMPORARY_PLACE = 3
  3729.  
  3730. def __init__(self, layer = "UI"):
  3731. Window.__init__(self, layer)
  3732. self.overLine = -1
  3733. self.selectedLine = -1
  3734. self.width = 0
  3735. self.height = 0
  3736. self.stepSize = 17
  3737. self.basePos = 0
  3738. self.showLineCount = 0
  3739. self.itemCenterAlign = True
  3740. self.itemList = []
  3741. self.keyDict = {}
  3742. self.textDict = {}
  3743. self.event = lambda *arg: None
  3744. def __del__(self):
  3745. Window.__del__(self)
  3746.  
  3747. def SetWidth(self, width):
  3748. self.SetSize(width, self.height)
  3749.  
  3750. def SetSize(self, width, height):
  3751. Window.SetSize(self, width, height)
  3752. self.width = width
  3753. self.height = height
  3754.  
  3755. def SetTextCenterAlign(self, flag):
  3756. self.itemCenterAlign = flag
  3757.  
  3758. def SetBasePos(self, pos):
  3759. self.basePos = pos
  3760. self._LocateItem()
  3761.  
  3762. def ClearItem(self):
  3763. self.keyDict = {}
  3764. self.textDict = {}
  3765. self.itemList = []
  3766. self.overLine = -1
  3767. self.selectedLine = -1
  3768.  
  3769. def InsertItem(self, number, text):
  3770. self.keyDict[len(self.itemList)] = number
  3771. self.textDict[len(self.itemList)] = text
  3772.  
  3773. textLine = TextLine()
  3774. textLine.SetParent(self)
  3775. textLine.SetText(text)
  3776. textLine.Show()
  3777.  
  3778. if self.itemCenterAlign:
  3779. textLine.SetWindowHorizontalAlignCenter()
  3780. textLine.SetHorizontalAlignCenter()
  3781.  
  3782. self.itemList.append(textLine)
  3783.  
  3784. self._LocateItem()
  3785.  
  3786. def ChangeItem(self, number, text):
  3787. for key, value in self.keyDict.items():
  3788. if value == number:
  3789. self.textDict[key] = text
  3790.  
  3791. if number < len(self.itemList):
  3792. self.itemList[key].SetText(text)
  3793.  
  3794. return
  3795.  
  3796. def LocateItem(self):
  3797. self._LocateItem()
  3798.  
  3799. def _LocateItem(self):
  3800.  
  3801. skipCount = self.basePos
  3802. yPos = 0
  3803. self.showLineCount = 0
  3804.  
  3805. for textLine in self.itemList:
  3806. textLine.Hide()
  3807.  
  3808. if skipCount > 0:
  3809. skipCount -= 1
  3810. continue
  3811.  
  3812. if localemg.IsARABIC():
  3813. w, h = textLine.GetTextSize()
  3814. textLine.SetPosition(w+10, yPos + 3)
  3815. else:
  3816. textLine.SetPosition(0, yPos + 3)
  3817.  
  3818. yPos += self.stepSize
  3819.  
  3820. if yPos <= self.GetHeight():
  3821. self.showLineCount += 1
  3822. textLine.Show()
  3823.  
  3824. def ArrangeItem(self):
  3825. self.SetSize(self.width, len(self.itemList) * self.stepSize)
  3826. self._LocateItem()
  3827.  
  3828. def GetViewItemCount(self):
  3829. return int(self.GetHeight() / self.stepSize)
  3830.  
  3831. def GetItemCount(self):
  3832. return len(self.itemList)
  3833.  
  3834. def SetEvent(self, event):
  3835. self.event = event
  3836.  
  3837. def SelectItem(self, line):
  3838.  
  3839. if not self.keyDict.has_key(line):
  3840. return
  3841.  
  3842. if line == self.selectedLine:
  3843. return
  3844.  
  3845. self.selectedLine = line
  3846. self.event(self.keyDict.get(line, 0), self.textDict.get(line, "None"))
  3847.  
  3848. def GetSelectedItem(self):
  3849. return self.keyDict.get(self.selectedLine, 0)
  3850.  
  3851. def OnMouseLeftButtonDown(self):
  3852. if self.overLine < 0:
  3853. return
  3854.  
  3855. def OnMouseLeftButtonUp(self):
  3856. if self.overLine >= 0:
  3857. self.SelectItem(self.overLine+self.basePos)
  3858.  
  3859. def OnUpdate(self):
  3860.  
  3861. self.overLine = -1
  3862.  
  3863. if self.IsIn():
  3864. x, y = self.GetGlobalPosition()
  3865. height = self.GetHeight()
  3866. xMouse, yMouse = wndMgr.GetMousePosition()
  3867.  
  3868. if yMouse - y < height - 1:
  3869. self.overLine = (yMouse - y) / self.stepSize
  3870.  
  3871. if self.overLine < 0:
  3872. self.overLine = -1
  3873. if self.overLine >= len(self.itemList):
  3874. self.overLine = -1
  3875.  
  3876. def OnRender(self):
  3877. xRender, yRender = self.GetGlobalPosition()
  3878. yRender -= self.TEMPORARY_PLACE
  3879. widthRender = self.width
  3880. heightRender = self.height + self.TEMPORARY_PLACE*2
  3881.  
  3882. if localemg.IsCIBN10:
  3883. if -1 != self.overLine and self.keyDict[self.overLine] != -1:
  3884. grp.SetColor(HALF_WHITE_COLOR)
  3885. grp.RenderBar(xRender + 2, yRender + self.overLine*self.stepSize + 4, self.width - 3, self.stepSize)
  3886.  
  3887. if -1 != self.selectedLine and self.keyDict[self.selectedLine] != -1:
  3888. if self.selectedLine >= self.basePos:
  3889. if self.selectedLine - self.basePos < self.showLineCount:
  3890. grp.SetColor(SELECT_COLOR)
  3891. grp.RenderBar(xRender + 2, yRender + (self.selectedLine-self.basePos)*self.stepSize + 4, self.width - 3, self.stepSize)
  3892.  
  3893. else:
  3894. if -1 != self.overLine:
  3895. grp.SetColor(HALF_WHITE_COLOR)
  3896. grp.RenderBar(xRender + 2, yRender + self.overLine*self.stepSize + 4, self.width - 3, self.stepSize)
  3897.  
  3898. if -1 != self.selectedLine:
  3899. if self.selectedLine >= self.basePos:
  3900. if self.selectedLine - self.basePos < self.showLineCount:
  3901. grp.SetColor(SELECT_COLOR)
  3902. grp.RenderBar(xRender + 2, yRender + (self.selectedLine-self.basePos)*self.stepSize + 4, self.width - 3, self.stepSize)
  3903.  
  3904.  
  3905. class ListBoxScroll(ListBox):
  3906. def __init__(self):
  3907. ListBox.__init__(self)
  3908.  
  3909. self.scrollBar = ScrollBar()
  3910. self.scrollBar.SetParent(self)
  3911. self.scrollBar.SetScrollEvent(self.__OnScroll)
  3912. self.scrollBar.Hide()
  3913.  
  3914. def SetSize(self, width, height):
  3915. ListBox.SetSize(self, width - ScrollBar.SCROLLBAR_WIDTH, height)
  3916. Window.SetSize(self, width, height)
  3917.  
  3918. self.scrollBar.SetPosition(width - ScrollBar.SCROLLBAR_WIDTH, 0)
  3919. self.scrollBar.SetScrollBarSize(height)
  3920.  
  3921. def ClearItem(self):
  3922. ListBox.ClearItem(self)
  3923. self.scrollBar.SetPos(0)
  3924.  
  3925. def _LocateItem(self):
  3926. ListBox._LocateItem(self)
  3927.  
  3928. if self.showLineCount < len(self.itemList):
  3929. self.scrollBar.SetMiddleBarSize(float(self.GetViewItemCount())/self.GetItemCount())
  3930. self.scrollBar.Show()
  3931. else:
  3932. self.scrollBar.Hide()
  3933.  
  3934. def __OnScroll(self):
  3935. scrollLen = self.GetItemCount()-self.GetViewItemCount()
  3936. if scrollLen < 0:
  3937. scrollLen = 0
  3938. self.SetBasePos(int(self.scrollBar.GetPos()*scrollLen))
  3939.  
  3940.  
  3941. class ListBox2(ListBox):
  3942. def __init__(self, *args, **kwargs):
  3943. ListBox.__init__(self, *args, **kwargs)
  3944. self.rowCount = 10
  3945. self.barWidth = 0
  3946. self.colCount = 0
  3947.  
  3948. def SetRowCount(self, rowCount):
  3949. self.rowCount = rowCount
  3950.  
  3951. def SetSize(self, width, height):
  3952. ListBox.SetSize(self, width, height)
  3953. self._RefreshForm()
  3954.  
  3955. def ClearItem(self):
  3956. ListBox.ClearItem(self)
  3957. self._RefreshForm()
  3958.  
  3959. def InsertItem(self, *args, **kwargs):
  3960. ListBox.InsertItem(self, *args, **kwargs)
  3961. self._RefreshForm()
  3962.  
  3963. def OnUpdate(self):
  3964. mpos = wndMgr.GetMousePosition()
  3965. self.overLine = self._CalcPointIndex(mpos)
  3966.  
  3967. def OnRender(self):
  3968. x, y = self.GetGlobalPosition()
  3969. pos = (x + 2, y)
  3970.  
  3971. if -1 != self.overLine:
  3972. grp.SetColor(HALF_WHITE_COLOR)
  3973. self._RenderBar(pos, self.overLine)
  3974.  
  3975. if -1 != self.selectedLine:
  3976. if self.selectedLine >= self.basePos:
  3977. if self.selectedLine - self.basePos < self.showLineCount:
  3978. grp.SetColor(SELECT_COLOR)
  3979. self._RenderBar(pos, self.selectedLine-self.basePos)
  3980.  
  3981.  
  3982.  
  3983. def _CalcPointIndex(self, mpos):
  3984. if self.IsIn():
  3985. px, py = mpos
  3986. gx, gy = self.GetGlobalPosition()
  3987. lx, ly = px - gx, py - gy
  3988.  
  3989. col = lx / self.barWidth
  3990. row = ly / self.stepSize
  3991. idx = col * self.rowCount + row
  3992. if col >= 0 and col < self.colCount:
  3993. if row >= 0 and row < self.rowCount:
  3994. if idx >= 0 and idx < len(self.itemList):
  3995. return idx
  3996.  
  3997. return -1
  3998.  
  3999. def _CalcRenderPos(self, pos, idx):
  4000. x, y = pos
  4001. row = idx % self.rowCount
  4002. col = idx / self.rowCount
  4003. return (x + col * self.barWidth, y + row * self.stepSize)
  4004.  
  4005. def _RenderBar(self, basePos, idx):
  4006. x, y = self._CalcRenderPos(basePos, idx)
  4007. grp.RenderBar(x, y, self.barWidth - 3, self.stepSize)
  4008.  
  4009. def _LocateItem(self):
  4010. pos = (0, self.TEMPORARY_PLACE)
  4011.  
  4012. self.showLineCount = 0
  4013. for textLine in self.itemList:
  4014. x, y = self._CalcRenderPos(pos, self.showLineCount)
  4015. textLine.SetPosition(x, y)
  4016. textLine.Show()
  4017.  
  4018. self.showLineCount += 1
  4019.  
  4020. def _RefreshForm(self):
  4021. if len(self.itemList) % self.rowCount:
  4022. self.colCount = len(self.itemList) / self.rowCount + 1
  4023. else:
  4024. self.colCount = len(self.itemList) / self.rowCount
  4025.  
  4026. if self.colCount:
  4027. self.barWidth = self.width / self.colCount
  4028. else:
  4029. self.barWidth = self.width
  4030.  
  4031.  
  4032. class ComboBox(Window):
  4033.  
  4034. class ListBoxWithBoard(ListBox):
  4035.  
  4036. def __init__(self, layer):
  4037. ListBox.__init__(self, layer)
  4038.  
  4039. def OnRender(self):
  4040. xRender, yRender = self.GetGlobalPosition()
  4041. yRender -= self.TEMPORARY_PLACE
  4042. widthRender = self.width
  4043. heightRender = self.height + self.TEMPORARY_PLACE*2
  4044. grp.SetColor(BACKGROUND_COLOR)
  4045. grp.RenderBar(xRender, yRender, widthRender, heightRender)
  4046. grp.SetColor(DARK_COLOR)
  4047. grp.RenderLine(xRender, yRender, widthRender, 0)
  4048. grp.RenderLine(xRender, yRender, 0, heightRender)
  4049. grp.SetColor(BRIGHT_COLOR)
  4050. grp.RenderLine(xRender, yRender+heightRender, widthRender, 0)
  4051. grp.RenderLine(xRender+widthRender, yRender, 0, heightRender)
  4052.  
  4053. ListBox.OnRender(self)
  4054.  
  4055. def __init__(self):
  4056. Window.__init__(self)
  4057. self.x = 0
  4058. self.y = 0
  4059. self.width = 0
  4060. self.height = 0
  4061. self.isSelected = False
  4062. self.isOver = False
  4063. self.isListOpened = False
  4064. self.event = lambda *arg: None
  4065. self.enable = True
  4066.  
  4067. self.textLine = MakeTextLine(self)
  4068. self.textLine.SetText(localemg.UI_ITEM)
  4069.  
  4070. self.listBox = self.ListBoxWithBoard("TOP_MOST")
  4071. self.listBox.SetPickAlways()
  4072. self.listBox.SetParent(self)
  4073. self.listBox.SetEvent(__mem_func__(self.OnSelectItem))
  4074. self.listBox.Hide()
  4075.  
  4076. def __del__(self):
  4077. Window.__del__(self)
  4078.  
  4079. def Destroy(self):
  4080. self.textLine = None
  4081. self.listBox = None
  4082.  
  4083. def SetPosition(self, x, y):
  4084. Window.SetPosition(self, x, y)
  4085. self.x = x
  4086. self.y = y
  4087. self.__ArrangeListBox()
  4088.  
  4089. def SetSize(self, width, height):
  4090. Window.SetSize(self, width, height)
  4091. self.width = width
  4092. self.height = height
  4093. self.textLine.UpdateRect()
  4094. self.__ArrangeListBox()
  4095.  
  4096. def __ArrangeListBox(self):
  4097. self.listBox.SetPosition(0, self.height + 5)
  4098. self.listBox.SetWidth(self.width)
  4099.  
  4100. def Enable(self):
  4101. self.enable = True
  4102.  
  4103. def Disable(self):
  4104. self.enable = False
  4105. self.textLine.SetText("")
  4106. self.CloseListBox()
  4107.  
  4108. def SetEvent(self, event):
  4109. self.event = event
  4110.  
  4111. def ClearItem(self):
  4112. self.CloseListBox()
  4113. self.listBox.ClearItem()
  4114.  
  4115. def InsertItem(self, index, name):
  4116. self.listBox.InsertItem(index, name)
  4117. self.listBox.ArrangeItem()
  4118.  
  4119. def SetCurrentItem(self, text):
  4120. self.textLine.SetText(text)
  4121.  
  4122. def SelectItem(self, key):
  4123. self.listBox.SelectItem(key)
  4124.  
  4125. def OnSelectItem(self, index, name):
  4126.  
  4127. self.CloseListBox()
  4128. self.event(index)
  4129.  
  4130. def CloseListBox(self):
  4131. self.isListOpened = False
  4132. self.listBox.Hide()
  4133.  
  4134. def OnMouseLeftButtonDown(self):
  4135.  
  4136. if not self.enable:
  4137. return
  4138.  
  4139. self.isSelected = True
  4140.  
  4141. def OnMouseLeftButtonUp(self):
  4142.  
  4143. if not self.enable:
  4144. return
  4145.  
  4146. self.isSelected = False
  4147.  
  4148. if self.isListOpened:
  4149. self.CloseListBox()
  4150. else:
  4151. if self.listBox.GetItemCount() > 0:
  4152. self.isListOpened = True
  4153. self.listBox.Show()
  4154. self.__ArrangeListBox()
  4155.  
  4156. def OnUpdate(self):
  4157.  
  4158. if not self.enable:
  4159. return
  4160.  
  4161. if self.IsIn():
  4162. self.isOver = True
  4163. else:
  4164. self.isOver = False
  4165.  
  4166. def OnRender(self):
  4167. self.x, self.y = self.GetGlobalPosition()
  4168. xRender = self.x
  4169. yRender = self.y
  4170. widthRender = self.width
  4171. heightRender = self.height
  4172. grp.SetColor(BACKGROUND_COLOR)
  4173. grp.RenderBar(xRender, yRender, widthRender, heightRender)
  4174. grp.SetColor(DARK_COLOR)
  4175. grp.RenderLine(xRender, yRender, widthRender, 0)
  4176. grp.RenderLine(xRender, yRender, 0, heightRender)
  4177. grp.SetColor(BRIGHT_COLOR)
  4178. grp.RenderLine(xRender, yRender+heightRender, widthRender, 0)
  4179. grp.RenderLine(xRender+widthRender, yRender, 0, heightRender)
  4180.  
  4181. if self.isOver:
  4182. grp.SetColor(HALF_WHITE_COLOR)
  4183. grp.RenderBar(xRender + 2, yRender + 3, self.width - 3, heightRender - 5)
  4184.  
  4185. if self.isSelected:
  4186. grp.SetColor(WHITE_COLOR)
  4187. grp.RenderBar(xRender + 2, yRender + 3, self.width - 3, heightRender - 5)
  4188.  
  4189. ###################################################################################################
  4190. ## Python Script Loader
  4191. ###################################################################################################
  4192.  
  4193. class ScriptWindow(Window):
  4194. def __init__(self, layer = "UI"):
  4195. Window.__init__(self, layer)
  4196. self.Children = []
  4197. self.ElementDictionary = {}
  4198. def __del__(self):
  4199. Window.__del__(self)
  4200.  
  4201. def ClearDictionary(self):
  4202. self.Children = []
  4203. self.ElementDictionary = {}
  4204. def InsertChild(self, name, child):
  4205. self.ElementDictionary[name] = child
  4206.  
  4207. def IsChild(self, name):
  4208. return self.ElementDictionary.has_key(name)
  4209. def GetChild(self, name):
  4210. return self.ElementDictionary[name]
  4211.  
  4212. def GetChild2(self, name):
  4213. return self.ElementDictionary.get(name, None)
  4214.  
  4215.  
  4216. class PythonScriptLoader(object):
  4217.  
  4218. BODY_KEY_LIST = ( "x", "y", "width", "height" )
  4219.  
  4220. VERTICAL_SEPARATOR_KEY_LIST = ("height", )
  4221. HORIZONTAL_SEPARATOR_KEY_LIST = ("width", )
  4222.  
  4223. #####
  4224.  
  4225. DEFAULT_KEY_LIST = ( "type", "x", "y", )
  4226. WINDOW_KEY_LIST = ( "width", "height", )
  4227. IMAGE_KEY_LIST = ( "image", )
  4228. EXPANDED_IMAGE_KEY_LIST = ( "image", )
  4229. ANI_IMAGE_KEY_LIST = ( "images", )
  4230. SLOT_KEY_LIST = ( "width", "height", "slot", )
  4231. CANDIDATE_LIST_KEY_LIST = ( "item_step", "item_xsize", "item_ysize", )
  4232. GRID_TABLE_KEY_LIST = ( "start_index", "x_count", "y_count", "x_step", "y_step", )
  4233. EDIT_LINE_KEY_LIST = ( "width", "height", "input_limit", )
  4234. COMBO_BOX_KEY_LIST = ( "width", "height", "item", )
  4235. TITLE_BAR_KEY_LIST = ( "width", )
  4236. HORIZONTAL_BAR_KEY_LIST = ( "width", )
  4237. BOARD_KEY_LIST = ( "width", "height", )
  4238. BOARD_WITH_TITLEBAR_KEY_LIST = ( "width", "height", "title", )
  4239. BOX_KEY_LIST = ( "width", "height", )
  4240. BAR_KEY_LIST = ( "width", "height", )
  4241. LINE_KEY_LIST = ( "width", "height", )
  4242. SLOTBAR_KEY_LIST = ( "width", "height", )
  4243. GAUGE_KEY_LIST = ( "width", "color", )
  4244. SCROLLBAR_KEY_LIST = ( "size", )
  4245. LIST_BOX_KEY_LIST = ( "width", "height", )
  4246.  
  4247. def __init__(self):
  4248. self.Clear()
  4249.  
  4250. def Clear(self):
  4251. self.ScriptDictionary = { "SCREEN_WIDTH" : wndMgr.GetScreenWidth(), "SCREEN_HEIGHT" : wndMgr.GetScreenHeight() }
  4252. self.InsertFunction = 0
  4253.  
  4254. def LoadScriptFile(self, window, FileName):
  4255. import exception
  4256. import exceptions
  4257. import os
  4258. import errno
  4259. self.Clear()
  4260.  
  4261. print "===== Load Script File : %s" % (FileName)
  4262.  
  4263. try:
  4264. # chr, player 등은 sandbox 내에서 import가 허용되지 않기 때문에,(봇이 악용할 여지가 매우 큼.)
  4265. # 미리 script dictionary에 필요한 상수를 넣어놓는다.
  4266. import chr
  4267. import player
  4268. import app
  4269. self.ScriptDictionary["PLAYER_NAME_MAX_LEN"] = chr.PLAYER_NAME_MAX_LEN
  4270. self.ScriptDictionary["DRAGON_SOUL_EQUIPMENT_SLOT_START"] = player.DRAGON_SOUL_EQUIPMENT_SLOT_START
  4271. self.ScriptDictionary["LOCALE_PATH"] = app.GetLocalePath()
  4272. execfile(FileName, self.ScriptDictionary)
  4273. except IOError, err:
  4274. import sys
  4275. import dbg
  4276. dbg.TraceError("Failed to load script file : %s" % (FileName))
  4277. dbg.TraceError("error : %s" % (err))
  4278. exception.Abort("LoadScriptFile1")
  4279. except RuntimeError,err:
  4280. import sys
  4281. import dbg
  4282. dbg.TraceError("Failed to load script file : %s" % (FileName))
  4283. dbg.TraceError("error : %s" % (err))
  4284. exception.Abort("LoadScriptFile2")
  4285. except:
  4286. import sys
  4287. import dbg
  4288. dbg.TraceError("Failed to load script file : %s" % (FileName))
  4289. exception.Abort("LoadScriptFile!!!!!!!!!!!!!!")
  4290.  
  4291. #####
  4292.  
  4293. Body = self.ScriptDictionary["window"]
  4294. self.CheckKeyList("window", Body, self.BODY_KEY_LIST)
  4295.  
  4296. window.ClearDictionary()
  4297. self.InsertFunction = window.InsertChild
  4298.  
  4299. window.SetPosition(int(Body["x"]), int(Body["y"]))
  4300.  
  4301. if localemg.IsARABIC():
  4302. w = wndMgr.GetScreenWidth()
  4303. h = wndMgr.GetScreenHeight()
  4304. if Body.has_key("width"):
  4305. w = int(Body["width"])
  4306. if Body.has_key("height"):
  4307. h = int(Body["height"])
  4308.  
  4309. window.SetSize(w, h)
  4310. else:
  4311. window.SetSize(int(Body["width"]), int(Body["height"]))
  4312. if True == Body.has_key("style"):
  4313. for StyleList in Body["style"]:
  4314. window.AddFlag(StyleList)
  4315.  
  4316.  
  4317. self.LoadChildren(window, Body)
  4318.  
  4319. def LoadChildren(self, parent, dicChildren):
  4320.  
  4321. if localemg.IsARABIC():
  4322. parent.AddFlag( "rtl" )
  4323.  
  4324. if True == dicChildren.has_key("style"):
  4325. for style in dicChildren["style"]:
  4326. parent.AddFlag(style)
  4327.  
  4328. if False == dicChildren.has_key("children"):
  4329. return False
  4330.  
  4331. Index = 0
  4332.  
  4333. ChildrenList = dicChildren["children"]
  4334. parent.Children = range(len(ChildrenList))
  4335. for ElementValue in ChildrenList:
  4336. try:
  4337. Name = ElementValue["name"]
  4338. except KeyError:
  4339. Name = ElementValue["name"] = "NONAME"
  4340.  
  4341. try:
  4342. Type = ElementValue["type"]
  4343. except KeyError:
  4344. Type = ElementValue["type"] = "window"
  4345.  
  4346. if False == self.CheckKeyList(Name, ElementValue, self.DEFAULT_KEY_LIST):
  4347. del parent.Children[Index]
  4348. continue
  4349.  
  4350. if Type == "window":
  4351. parent.Children[Index] = ScriptWindow()
  4352. parent.Children[Index].SetParent(parent)
  4353. self.LoadElementWindow(parent.Children[Index], ElementValue, parent)
  4354.  
  4355. elif Type == "verticalseparator":
  4356. parent.Children[Index] = VerticalSeparator()
  4357. parent.Children[Index].SetParent(parent)
  4358. self.LoadElementVerticalSeparator(parent.Children[Index], ElementValue, parent)
  4359.  
  4360. elif Type == "horizontalseparator":
  4361. parent.Children[Index] = HorizontalSeparator()
  4362. parent.Children[Index].SetParent(parent)
  4363. self.LoadElementHorizontalSeparator(parent.Children[Index], ElementValue, parent)
  4364.  
  4365. elif Type == "button":
  4366. parent.Children[Index] = Button()
  4367. parent.Children[Index].SetParent(parent)
  4368. self.LoadElementButton(parent.Children[Index], ElementValue, parent)
  4369.  
  4370. elif Type == "radio_button":
  4371. parent.Children[Index] = RadioButton()
  4372. parent.Children[Index].SetParent(parent)
  4373. self.LoadElementButton(parent.Children[Index], ElementValue, parent)
  4374.  
  4375. elif Type == "toggle_button":
  4376. parent.Children[Index] = ToggleButton()
  4377. parent.Children[Index].SetParent(parent)
  4378. self.LoadElementButton(parent.Children[Index], ElementValue, parent)
  4379.  
  4380. elif Type == "mark":
  4381. parent.Children[Index] = MarkBox()
  4382. parent.Children[Index].SetParent(parent)
  4383. self.LoadElementMark(parent.Children[Index], ElementValue, parent)
  4384.  
  4385. elif Type == "image":
  4386. parent.Children[Index] = ImageBox()
  4387. parent.Children[Index].SetParent(parent)
  4388. self.LoadElementImage(parent.Children[Index], ElementValue, parent)
  4389.  
  4390. elif Type == "expanded_image":
  4391. parent.Children[Index] = ExpandedImageBox()
  4392. parent.Children[Index].SetParent(parent)
  4393. self.LoadElementExpandedImage(parent.Children[Index], ElementValue, parent)
  4394.  
  4395. elif Type == "ani_image":
  4396. parent.Children[Index] = AniImageBox()
  4397. parent.Children[Index].SetParent(parent)
  4398. self.LoadElementAniImage(parent.Children[Index], ElementValue, parent)
  4399.  
  4400. elif Type == "slot":
  4401. parent.Children[Index] = SlotWindow()
  4402. parent.Children[Index].SetParent(parent)
  4403. self.LoadElementSlot(parent.Children[Index], ElementValue, parent)
  4404.  
  4405. elif Type == "candidate_list":
  4406. parent.Children[Index] = CandidateListBox()
  4407. parent.Children[Index].SetParent(parent)
  4408. self.LoadElementCandidateList(parent.Children[Index], ElementValue, parent)
  4409.  
  4410. elif Type == "grid_table":
  4411. parent.Children[Index] = GridSlotWindow()
  4412. parent.Children[Index].SetParent(parent)
  4413. self.LoadElementGridTable(parent.Children[Index], ElementValue, parent)
  4414.  
  4415. elif Type == "text":
  4416. parent.Children[Index] = TextLine()
  4417. parent.Children[Index].SetParent(parent)
  4418. self.LoadElementText(parent.Children[Index], ElementValue, parent)
  4419.  
  4420. elif Type == "editline":
  4421. parent.Children[Index] = EditLine()
  4422. parent.Children[Index].SetParent(parent)
  4423. self.LoadElementEditLine(parent.Children[Index], ElementValue, parent)
  4424.  
  4425. elif Type == "titlebar":
  4426. parent.Children[Index] = TitleBar()
  4427. parent.Children[Index].SetParent(parent)
  4428. self.LoadElementTitleBar(parent.Children[Index], ElementValue, parent)
  4429.  
  4430. elif Type == "horizontalbar":
  4431. parent.Children[Index] = HorizontalBar()
  4432. parent.Children[Index].SetParent(parent)
  4433. self.LoadElementHorizontalBar(parent.Children[Index], ElementValue, parent)
  4434.  
  4435. elif Type == "board":
  4436. parent.Children[Index] = Board()
  4437. parent.Children[Index].SetParent(parent)
  4438. self.LoadElementBoard(parent.Children[Index], ElementValue, parent)
  4439.  
  4440. elif Type == "board_with_titlebar":
  4441. parent.Children[Index] = BoardWithTitleBar()
  4442. parent.Children[Index].SetParent(parent)
  4443. self.LoadElementBoardWithTitleBar(parent.Children[Index], ElementValue, parent)
  4444.  
  4445. elif Type == "thinboard":
  4446. parent.Children[Index] = ThinBoard()
  4447. parent.Children[Index].SetParent(parent)
  4448. self.LoadElementThinBoard(parent.Children[Index], ElementValue, parent)
  4449.  
  4450. elif Type == "thinboardnew":
  4451. parent.Children[Index] = ThinBoardNew()
  4452. parent.Children[Index].SetParent(parent)
  4453. self.LoadElementThinBoardNew(parent.Children[Index], ElementValue, parent)
  4454.  
  4455. elif Type == "box":
  4456. parent.Children[Index] = Box()
  4457. parent.Children[Index].SetParent(parent)
  4458. self.LoadElementBox(parent.Children[Index], ElementValue, parent)
  4459.  
  4460. elif Type == "bar":
  4461. parent.Children[Index] = Bar()
  4462. parent.Children[Index].SetParent(parent)
  4463. self.LoadElementBar(parent.Children[Index], ElementValue, parent)
  4464.  
  4465. elif Type == "line":
  4466. parent.Children[Index] = Line()
  4467. parent.Children[Index].SetParent(parent)
  4468. self.LoadElementLine(parent.Children[Index], ElementValue, parent)
  4469.  
  4470. elif Type == "slotbar":
  4471. parent.Children[Index] = SlotBar()
  4472. parent.Children[Index].SetParent(parent)
  4473. self.LoadElementSlotBar(parent.Children[Index], ElementValue, parent)
  4474.  
  4475. elif Type == "gauge":
  4476. parent.Children[Index] = Gauge()
  4477. parent.Children[Index].SetParent(parent)
  4478. self.LoadElementGauge(parent.Children[Index], ElementValue, parent)
  4479.  
  4480. elif Type == "scrollbar":
  4481. parent.Children[Index] = ScrollBar()
  4482. parent.Children[Index].SetParent(parent)
  4483. self.LoadElementScrollBar(parent.Children[Index], ElementValue, parent)
  4484.  
  4485. elif Type == "thin_scrollbar":
  4486. parent.Children[Index] = ThinScrollBar()
  4487. parent.Children[Index].SetParent(parent)
  4488. self.LoadElementScrollBar(parent.Children[Index], ElementValue, parent)
  4489.  
  4490. elif Type == "small_thin_scrollbar":
  4491. parent.Children[Index] = SmallThinScrollBar()
  4492. parent.Children[Index].SetParent(parent)
  4493. self.LoadElementScrollBar(parent.Children[Index], ElementValue, parent)
  4494.  
  4495. elif Type == "sliderbar":
  4496. parent.Children[Index] = SliderBar()
  4497. parent.Children[Index].SetParent(parent)
  4498. self.LoadElementSliderBar(parent.Children[Index], ElementValue, parent)
  4499.  
  4500. elif Type == "listbox":
  4501. parent.Children[Index] = ListBox()
  4502. parent.Children[Index].SetParent(parent)
  4503. self.LoadElementListBox(parent.Children[Index], ElementValue, parent)
  4504.  
  4505. elif Type == "listbox_scroll":
  4506. parent.Children[Index] = ListBoxScroll()
  4507. parent.Children[Index].SetParent(parent)
  4508. self.LoadElementListBox(parent.Children[Index], ElementValue, parent)
  4509.  
  4510. elif Type == "resizable_text_value":
  4511. parent.Children[Index] = ResizableTextValue()
  4512. parent.Children[Index].SetParent(parent)
  4513. self.LoadElementResizableTextValue(parent.Children[Index], ElementValue, parent)
  4514.  
  4515. elif Type == "listbox2":
  4516. parent.Children[Index] = ListBox2()
  4517. parent.Children[Index].SetParent(parent)
  4518. self.LoadElementListBox2(parent.Children[Index], ElementValue, parent)
  4519. elif Type == "listboxex":
  4520. parent.Children[Index] = ListBoxEx()
  4521. parent.Children[Index].SetParent(parent)
  4522. self.LoadElementListBoxEx(parent.Children[Index], ElementValue, parent)
  4523.  
  4524. else:
  4525. Index += 1
  4526. continue
  4527.  
  4528. parent.Children[Index].SetWindowName(Name)
  4529. if 0 != self.InsertFunction:
  4530. self.InsertFunction(Name, parent.Children[Index])
  4531.  
  4532. self.LoadChildren(parent.Children[Index], ElementValue)
  4533. Index += 1
  4534.  
  4535. def CheckKeyList(self, name, value, key_list):
  4536.  
  4537. for DataKey in key_list:
  4538. if False == value.has_key(DataKey):
  4539. print "Failed to find data key", "[" + name + "/" + DataKey + "]"
  4540. return False
  4541.  
  4542. return True
  4543.  
  4544. def LoadDefaultData(self, window, value, parentWindow):
  4545. loc_x = int(value["x"])
  4546. loc_y = int(value["y"])
  4547. if value.has_key("vertical_align"):
  4548. if "center" == value["vertical_align"]:
  4549. window.SetWindowVerticalAlignCenter()
  4550. elif "bottom" == value["vertical_align"]:
  4551. window.SetWindowVerticalAlignBottom()
  4552.  
  4553. if parentWindow.IsRTL():
  4554. loc_x = int(value["x"]) + window.GetWidth()
  4555. if value.has_key("horizontal_align"):
  4556. if "center" == value["horizontal_align"]:
  4557. window.SetWindowHorizontalAlignCenter()
  4558. loc_x = - int(value["x"])
  4559. elif "right" == value["horizontal_align"]:
  4560. window.SetWindowHorizontalAlignLeft()
  4561. loc_x = int(value["x"]) - window.GetWidth()
  4562. ## loc_x = parentWindow.GetWidth() - int(value["x"]) + window.GetWidth()
  4563. else:
  4564. window.SetWindowHorizontalAlignRight()
  4565.  
  4566. if value.has_key("all_align"):
  4567. window.SetWindowVerticalAlignCenter()
  4568. window.SetWindowHorizontalAlignCenter()
  4569. loc_x = - int(value["x"])
  4570. else:
  4571. if value.has_key("horizontal_align"):
  4572. if "center" == value["horizontal_align"]:
  4573. window.SetWindowHorizontalAlignCenter()
  4574. elif "right" == value["horizontal_align"]:
  4575. window.SetWindowHorizontalAlignRight()
  4576.  
  4577. window.SetPosition(loc_x, loc_y)
  4578. window.Show()
  4579.  
  4580. ## Window
  4581. def LoadElementWindow(self, window, value, parentWindow):
  4582.  
  4583. if False == self.CheckKeyList(value["name"], value, self.WINDOW_KEY_LIST):
  4584. return False
  4585.  
  4586. window.SetSize(int(value["width"]), int(value["height"]))
  4587. self.LoadDefaultData(window, value, parentWindow)
  4588.  
  4589. return True
  4590.  
  4591. ## Button
  4592. def LoadElementButton(self, window, value, parentWindow):
  4593.  
  4594. if value.has_key("width") and value.has_key("height"):
  4595. window.SetSize(int(value["width"]), int(value["height"]))
  4596.  
  4597. if True == value.has_key("default_image"):
  4598. window.SetUpVisual(value["default_image"])
  4599. if True == value.has_key("over_image"):
  4600. window.SetOverVisual(value["over_image"])
  4601. if True == value.has_key("down_image"):
  4602. window.SetDownVisual(value["down_image"])
  4603. if True == value.has_key("disable_image"):
  4604. window.SetDisableVisual(value["disable_image"])
  4605.  
  4606. if True == value.has_key("text"):
  4607. if True == value.has_key("text_height"):
  4608. window.SetText(value["text"], value["text_height"])
  4609. else:
  4610. window.SetText(value["text"])
  4611.  
  4612. if value.has_key("text_color"):
  4613. window.SetTextColor(value["text_color"])
  4614.  
  4615. if True == value.has_key("tooltip_text"):
  4616. if True == value.has_key("tooltip_x") and True == value.has_key("tooltip_y"):
  4617. window.SetToolTipText(value["tooltip_text"], int(value["tooltip_x"]), int(value["tooltip_y"]))
  4618. else:
  4619. window.SetToolTipText(value["tooltip_text"])
  4620.  
  4621. self.LoadDefaultData(window, value, parentWindow)
  4622.  
  4623. return True
  4624.  
  4625. def LoadElementResizableTextValue(self, window, value, parentWindow):
  4626.  
  4627. if value.has_key("width") and value.has_key("height"):
  4628. window.SetSize(int(value["width"]), int(value["height"]))
  4629.  
  4630. if TRUE == value.has_key("text"):
  4631. window.SetText(value["text"])
  4632.  
  4633. if value.has_key("line_color"):
  4634. window.SetLineColor(value["line_color"])
  4635.  
  4636. if value.has_key("color"):
  4637. window.SetBackgroundColor(value["color"])
  4638.  
  4639. if value.has_key("line_top"):
  4640. window.SetLine('top')
  4641. if value.has_key("line_bottom"):
  4642. window.SetLine('bottom')
  4643. if value.has_key("line_left"):
  4644. window.SetLine('left')
  4645. if value.has_key("line_right"):
  4646. window.SetLine('right')
  4647.  
  4648. if value.has_key('all_lines'):
  4649. window.SetLine('top')
  4650. window.SetLine('bottom')
  4651. window.SetLine('left')
  4652. window.SetLine('right')
  4653.  
  4654. if value.has_key('without_background'):
  4655. window.SetNoBackground()
  4656.  
  4657. if value.has_key("text"):
  4658. window.SetText(value["text"])
  4659.  
  4660. self.LoadDefaultData(window, value, parentWindow)
  4661.  
  4662. return TRUE
  4663.  
  4664. def LoadElementVerticalSeparator(self, window, value, parentWindow):
  4665. if FALSE == self.CheckKeyList(value["name"], value, self.VERTICAL_SEPARATOR_KEY_LIST):
  4666. return FALSE
  4667.  
  4668. window.SetHeight(int(value["height"]))
  4669. self.LoadDefaultData(window, value, parentWindow)
  4670.  
  4671. return TRUE
  4672.  
  4673. def LoadElementHorizontalSeparator(self, window, value, parentWindow):
  4674. if FALSE == self.CheckKeyList(value["name"], value, self.HORIZONTAL_SEPARATOR_KEY_LIST):
  4675. return FALSE
  4676.  
  4677. window.SetWidth(int(value["width"]))
  4678. self.LoadDefaultData(window, value, parentWindow)
  4679.  
  4680. return TRUE
  4681.  
  4682. ## Mark
  4683. def LoadElementMark(self, window, value, parentWindow):
  4684.  
  4685. #if False == self.CheckKeyList(value["name"], value, self.MARK_KEY_LIST):
  4686. # return False
  4687.  
  4688. self.LoadDefaultData(window, value, parentWindow)
  4689.  
  4690. return True
  4691.  
  4692. ## Image
  4693. def LoadElementImage(self, window, value, parentWindow):
  4694.  
  4695. if False == self.CheckKeyList(value["name"], value, self.IMAGE_KEY_LIST):
  4696. return False
  4697.  
  4698. window.LoadImage(value["image"])
  4699. self.LoadDefaultData(window, value, parentWindow)
  4700.  
  4701. return True
  4702.  
  4703. ## AniImage
  4704. def LoadElementAniImage(self, window, value, parentWindow):
  4705.  
  4706. if False == self.CheckKeyList(value["name"], value, self.ANI_IMAGE_KEY_LIST):
  4707. return False
  4708.  
  4709. if TRUE == value.has_key("delay"):
  4710. window.SetDelay(value["delay"])
  4711.  
  4712. if TRUE == value.has_key("x_scale") and TRUE == value.has_key("y_scale"):
  4713. for image in value["images"]:
  4714. window.AppendImageScale(image, float(value["x_scale"]), float(value["y_scale"]))
  4715. else:
  4716. for image in value["images"]:
  4717. window.AppendImage(image)
  4718.  
  4719. if value.has_key("width") and value.has_key("height"):
  4720. window.SetSize(value["width"], value["height"])
  4721.  
  4722. self.LoadDefaultData(window, value, parentWindow)
  4723.  
  4724. return True
  4725.  
  4726. ## Expanded Image
  4727. def LoadElementExpandedImage(self, window, value, parentWindow):
  4728.  
  4729. if False == self.CheckKeyList(value["name"], value, self.EXPANDED_IMAGE_KEY_LIST):
  4730. return False
  4731.  
  4732. window.LoadImage(value["image"])
  4733.  
  4734. if True == value.has_key("x_origin") and True == value.has_key("y_origin"):
  4735. window.SetOrigin(float(value["x_origin"]), float(value["y_origin"]))
  4736.  
  4737. if True == value.has_key("x_scale") and True == value.has_key("y_scale"):
  4738. window.SetScale(float(value["x_scale"]), float(value["y_scale"]))
  4739.  
  4740. if True == value.has_key("rect"):
  4741. RenderingRect = value["rect"]
  4742. window.SetRenderingRect(RenderingRect[0], RenderingRect[1], RenderingRect[2], RenderingRect[3])
  4743.  
  4744. if True == value.has_key("mode"):
  4745. mode = value["mode"]
  4746. if "MODULATE" == mode:
  4747. window.SetRenderingMode(wndMgr.RENDERING_MODE_MODULATE)
  4748.  
  4749. self.LoadDefaultData(window, value, parentWindow)
  4750.  
  4751. return True
  4752.  
  4753. ## Slot
  4754. def LoadElementSlot(self, window, value, parentWindow):
  4755.  
  4756. if False == self.CheckKeyList(value["name"], value, self.SLOT_KEY_LIST):
  4757. return False
  4758.  
  4759. global_x = int(value["x"])
  4760. global_y = int(value["y"])
  4761. global_width = int(value["width"])
  4762. global_height = int(value["height"])
  4763.  
  4764. window.SetPosition(global_x, global_y)
  4765. window.SetSize(global_width, global_height)
  4766. window.Show()
  4767.  
  4768. r = 1.0
  4769. g = 1.0
  4770. b = 1.0
  4771. a = 1.0
  4772.  
  4773. if True == value.has_key("image_r") and \
  4774. True == value.has_key("image_g") and \
  4775. True == value.has_key("image_b") and \
  4776. True == value.has_key("image_a"):
  4777. r = float(value["image_r"])
  4778. g = float(value["image_g"])
  4779. b = float(value["image_b"])
  4780. a = float(value["image_a"])
  4781.  
  4782. SLOT_ONE_KEY_LIST = ("index", "x", "y", "width", "height")
  4783.  
  4784. for slot in value["slot"]:
  4785. if True == self.CheckKeyList(value["name"] + " - one", slot, SLOT_ONE_KEY_LIST):
  4786. wndMgr.AppendSlot(window.hWnd,
  4787. int(slot["index"]),
  4788. int(slot["x"]),
  4789. int(slot["y"]),
  4790. int(slot["width"]),
  4791. int(slot["height"]))
  4792.  
  4793. if TRUE == value.has_key("image"):
  4794. if TRUE == value.has_key("x_scale") and TRUE == value.has_key("y_scale"):
  4795. wndMgr.SetSlotBaseImageScale(window.hWnd,
  4796. value["image"],
  4797. r, g, b, a, float(value["x_scale"]), float(value["y_scale"]))
  4798. else:
  4799. wndMgr.SetSlotBaseImage(window.hWnd,
  4800. value["image"],
  4801. r, g, b, a)
  4802.  
  4803. return True
  4804.  
  4805. def LoadElementCandidateList(self, window, value, parentWindow):
  4806. if False == self.CheckKeyList(value["name"], value, self.CANDIDATE_LIST_KEY_LIST):
  4807. return False
  4808.  
  4809. window.SetPosition(int(value["x"]), int(value["y"]))
  4810. window.SetItemSize(int(value["item_xsize"]), int(value["item_ysize"]))
  4811. window.SetItemStep(int(value["item_step"]))
  4812. window.Show()
  4813.  
  4814. return True
  4815.  
  4816. ## Table
  4817. def LoadElementGridTable(self, window, value, parentWindow):
  4818.  
  4819. if False == self.CheckKeyList(value["name"], value, self.GRID_TABLE_KEY_LIST):
  4820. return False
  4821.  
  4822. xBlank = 0
  4823. yBlank = 0
  4824. if True == value.has_key("x_blank"):
  4825. xBlank = int(value["x_blank"])
  4826. if True == value.has_key("y_blank"):
  4827. yBlank = int(value["y_blank"])
  4828.  
  4829. if localemg.IsARABIC():
  4830. pass
  4831. else:
  4832. window.SetPosition(int(value["x"]), int(value["y"]))
  4833.  
  4834. window.ArrangeSlot( int(value["start_index"]),
  4835. int(value["x_count"]),
  4836. int(value["y_count"]),
  4837. int(value["x_step"]),
  4838. int(value["y_step"]),
  4839. xBlank,
  4840. yBlank)
  4841. if True == value.has_key("image"):
  4842. r = 1.0
  4843. g = 1.0
  4844. b = 1.0
  4845. a = 1.0
  4846. if True == value.has_key("image_r") and \
  4847. True == value.has_key("image_g") and \
  4848. True == value.has_key("image_b") and \
  4849. True == value.has_key("image_a"):
  4850. r = float(value["image_r"])
  4851. g = float(value["image_g"])
  4852. b = float(value["image_b"])
  4853. a = float(value["image_a"])
  4854. wndMgr.SetSlotBaseImage(window.hWnd, value["image"], r, g, b, a)
  4855.  
  4856. if True == value.has_key("style"):
  4857. if "select" == value["style"]:
  4858. wndMgr.SetSlotStyle(window.hWnd, wndMgr.SLOT_STYLE_SELECT)
  4859. if localemg.IsARABIC():
  4860. self.LoadDefaultData(window, value, parentWindow)
  4861. else:
  4862. window.Show()
  4863.  
  4864. return True
  4865.  
  4866. ## Text
  4867. def LoadElementText(self, window, value, parentWindow):
  4868.  
  4869. if value.has_key("fontsize"):
  4870. fontSize = value["fontsize"]
  4871.  
  4872. if "LARGE" == fontSize:
  4873. window.SetFontName(localemg.UI_DEF_FONT_LARGE)
  4874.  
  4875. elif value.has_key("fontname"):
  4876. fontName = value["fontname"]
  4877. window.SetFontName(fontName)
  4878.  
  4879. if value.has_key("text_horizontal_align"):
  4880. if "left" == value["text_horizontal_align"]:
  4881. window.SetHorizontalAlignLeft()
  4882. elif "center" == value["text_horizontal_align"]:
  4883. window.SetHorizontalAlignCenter()
  4884. elif "right" == value["text_horizontal_align"]:
  4885. window.SetHorizontalAlignRight()
  4886.  
  4887. if value.has_key("text_vertical_align"):
  4888. if "top" == value["text_vertical_align"]:
  4889. window.SetVerticalAlignTop()
  4890. elif "center" == value["text_vertical_align"]:
  4891. window.SetVerticalAlignCenter()
  4892. elif "bottom" == value["text_vertical_align"]:
  4893. window.SetVerticalAlignBottom()
  4894.  
  4895. if value.has_key("all_align"):
  4896. window.SetHorizontalAlignCenter()
  4897. window.SetVerticalAlignCenter()
  4898. window.SetWindowHorizontalAlignCenter()
  4899. window.SetWindowVerticalAlignCenter()
  4900.  
  4901. if value.has_key("r") and value.has_key("g") and value.has_key("b"):
  4902. window.SetFontColor(float(value["r"]), float(value["g"]), float(value["b"]))
  4903. elif value.has_key("color"):
  4904. window.SetPackedFontColor(value["color"])
  4905. else:
  4906. window.SetFontColor(0.8549, 0.8549, 0.8549)
  4907.  
  4908. if value.has_key("outline"):
  4909. if value["outline"]:
  4910. window.SetOutline()
  4911. if True == value.has_key("text"):
  4912. window.SetText(value["text"])
  4913.  
  4914. self.LoadDefaultData(window, value, parentWindow)
  4915.  
  4916. return True
  4917.  
  4918. ## EditLine
  4919. def LoadElementEditLine(self, window, value, parentWindow):
  4920.  
  4921. if False == self.CheckKeyList(value["name"], value, self.EDIT_LINE_KEY_LIST):
  4922. return False
  4923.  
  4924.  
  4925. if value.has_key("secret_flag"):
  4926. window.SetSecret(value["secret_flag"])
  4927. if value.has_key("with_codepage"):
  4928. if value["with_codepage"]:
  4929. window.bCodePage = True
  4930. if value.has_key("only_number"):
  4931. if value["only_number"]:
  4932. window.SetNumberMode()
  4933. if value.has_key("enable_codepage"):
  4934. window.SetIMEFlag(value["enable_codepage"])
  4935. if value.has_key("enable_ime"):
  4936. window.SetIMEFlag(value["enable_ime"])
  4937. if value.has_key("limit_width"):
  4938. window.SetLimitWidth(value["limit_width"])
  4939. if value.has_key("multi_line"):
  4940. if value["multi_line"]:
  4941. window.SetMultiLine()
  4942.  
  4943. window.SetMax(int(value["input_limit"]))
  4944. window.SetSize(int(value["width"]), int(value["height"]))
  4945. self.LoadElementText(window, value, parentWindow)
  4946.  
  4947. return True
  4948.  
  4949. ## TitleBar
  4950. def LoadElementTitleBar(self, window, value, parentWindow):
  4951.  
  4952. if False == self.CheckKeyList(value["name"], value, self.TITLE_BAR_KEY_LIST):
  4953. return False
  4954.  
  4955. window.MakeTitleBar(int(value["width"]), value.get("color", "red"))
  4956. self.LoadDefaultData(window, value, parentWindow)
  4957.  
  4958. return True
  4959.  
  4960. ## HorizontalBar
  4961. def LoadElementHorizontalBar(self, window, value, parentWindow):
  4962.  
  4963. if False == self.CheckKeyList(value["name"], value, self.HORIZONTAL_BAR_KEY_LIST):
  4964. return False
  4965.  
  4966. window.Create(int(value["width"]))
  4967. self.LoadDefaultData(window, value, parentWindow)
  4968.  
  4969. return True
  4970.  
  4971. ## Board
  4972. def LoadElementBoard(self, window, value, parentWindow):
  4973.  
  4974. if False == self.CheckKeyList(value["name"], value, self.BOARD_KEY_LIST):
  4975. return False
  4976.  
  4977. window.SetSize(int(value["width"]), int(value["height"]))
  4978. self.LoadDefaultData(window, value, parentWindow)
  4979.  
  4980. return True
  4981.  
  4982. ## Board With TitleBar
  4983. def LoadElementBoardWithTitleBar(self, window, value, parentWindow):
  4984.  
  4985. if False == self.CheckKeyList(value["name"], value, self.BOARD_WITH_TITLEBAR_KEY_LIST):
  4986. return False
  4987.  
  4988. window.SetSize(int(value["width"]), int(value["height"]))
  4989. window.SetTitleName(value["title"])
  4990. self.LoadDefaultData(window, value, parentWindow)
  4991.  
  4992. return True
  4993.  
  4994. ## ThinBoard
  4995. def LoadElementThinBoard(self, window, value, parentWindow):
  4996.  
  4997. if False == self.CheckKeyList(value["name"], value, self.BOARD_KEY_LIST):
  4998. return False
  4999.  
  5000. window.SetSize(int(value["width"]), int(value["height"]))
  5001. self.LoadDefaultData(window, value, parentWindow)
  5002.  
  5003. return True
  5004.  
  5005. ## Box
  5006. def LoadElementBox(self, window, value, parentWindow):
  5007.  
  5008. if False == self.CheckKeyList(value["name"], value, self.BOX_KEY_LIST):
  5009. return False
  5010.  
  5011. if True == value.has_key("color"):
  5012. window.SetColor(value["color"])
  5013.  
  5014. window.SetSize(int(value["width"]), int(value["height"]))
  5015. self.LoadDefaultData(window, value, parentWindow)
  5016.  
  5017. return True
  5018.  
  5019. ## ThinBoardNew
  5020. def LoadElementThinBoardNew(self, window, value, parentWindow):
  5021.  
  5022. if FALSE == self.CheckKeyList(value["name"], value, self.BOARD_KEY_LIST):
  5023. return FALSE
  5024.  
  5025. window.SetSize(int(value["width"]), int(value["height"]))
  5026. self.LoadDefaultData(window, value, parentWindow)
  5027.  
  5028. return TRUE
  5029.  
  5030. ## Bar
  5031. def LoadElementBar(self, window, value, parentWindow):
  5032.  
  5033. if False == self.CheckKeyList(value["name"], value, self.BAR_KEY_LIST):
  5034. return False
  5035.  
  5036. if True == value.has_key("color"):
  5037. window.SetColor(value["color"])
  5038.  
  5039. window.SetSize(int(value["width"]), int(value["height"]))
  5040. self.LoadDefaultData(window, value, parentWindow)
  5041.  
  5042. return True
  5043.  
  5044. ## Line
  5045. def LoadElementLine(self, window, value, parentWindow):
  5046.  
  5047. if False == self.CheckKeyList(value["name"], value, self.LINE_KEY_LIST):
  5048. return False
  5049.  
  5050. if True == value.has_key("color"):
  5051. window.SetColor(value["color"])
  5052.  
  5053. window.SetSize(int(value["width"]), int(value["height"]))
  5054. self.LoadDefaultData(window, value, parentWindow)
  5055.  
  5056. return True
  5057.  
  5058. ## Slot
  5059. def LoadElementSlotBar(self, window, value, parentWindow):
  5060.  
  5061. if False == self.CheckKeyList(value["name"], value, self.SLOTBAR_KEY_LIST):
  5062. return False
  5063.  
  5064. window.SetSize(int(value["width"]), int(value["height"]))
  5065. self.LoadDefaultData(window, value, parentWindow)
  5066.  
  5067. return True
  5068.  
  5069. ## Gauge
  5070. def LoadElementGauge(self, window, value, parentWindow):
  5071.  
  5072. if False == self.CheckKeyList(value["name"], value, self.GAUGE_KEY_LIST):
  5073. return False
  5074.  
  5075. window.MakeGauge(value["width"], value["color"])
  5076. self.LoadDefaultData(window, value, parentWindow)
  5077.  
  5078. return True
  5079.  
  5080. ## ScrollBar
  5081. def LoadElementScrollBar(self, window, value, parentWindow):
  5082.  
  5083. if False == self.CheckKeyList(value["name"], value, self.SCROLLBAR_KEY_LIST):
  5084. return False
  5085.  
  5086. window.SetScrollBarSize(value["size"])
  5087. self.LoadDefaultData(window, value, parentWindow)
  5088.  
  5089. return True
  5090.  
  5091. ## SliderBar
  5092. def LoadElementSliderBar(self, window, value, parentWindow):
  5093.  
  5094. self.LoadDefaultData(window, value, parentWindow)
  5095.  
  5096. return True
  5097.  
  5098. ## ListBox
  5099. def LoadElementListBox(self, window, value, parentWindow):
  5100.  
  5101. if False == self.CheckKeyList(value["name"], value, self.LIST_BOX_KEY_LIST):
  5102. return False
  5103.  
  5104. if value.has_key("item_align"):
  5105. window.SetTextCenterAlign(value["item_align"])
  5106.  
  5107. window.SetSize(value["width"], value["height"])
  5108. self.LoadDefaultData(window, value, parentWindow)
  5109.  
  5110. return True
  5111.  
  5112. ## ListBox2
  5113. def LoadElementListBox2(self, window, value, parentWindow):
  5114.  
  5115. if False == self.CheckKeyList(value["name"], value, self.LIST_BOX_KEY_LIST):
  5116. return False
  5117.  
  5118. window.SetRowCount(value.get("row_count", 10))
  5119. window.SetSize(value["width"], value["height"])
  5120. self.LoadDefaultData(window, value, parentWindow)
  5121.  
  5122. if value.has_key("item_align"):
  5123. window.SetTextCenterAlign(value["item_align"])
  5124.  
  5125. return True
  5126. def LoadElementListBoxEx(self, window, value, parentWindow):
  5127.  
  5128. if False == self.CheckKeyList(value["name"], value, self.LIST_BOX_KEY_LIST):
  5129. return False
  5130.  
  5131. window.SetSize(value["width"], value["height"])
  5132. self.LoadDefaultData(window, value, parentWindow)
  5133.  
  5134. if value.has_key("itemsize_x") and value.has_key("itemsize_y"):
  5135. window.SetItemSize(int(value["itemsize_x"]), int(value["itemsize_y"]))
  5136.  
  5137. if value.has_key("itemstep"):
  5138. window.SetItemStep(int(value["itemstep"]))
  5139.  
  5140. if value.has_key("viewcount"):
  5141. window.SetViewItemCount(int(value["viewcount"]))
  5142.  
  5143. return True
  5144.  
  5145. class ReadingWnd(Bar):
  5146.  
  5147. def __init__(self):
  5148. Bar.__init__(self,"TOP_MOST")
  5149.  
  5150. self.__BuildText()
  5151. self.SetSize(80, 19)
  5152. self.Show()
  5153.  
  5154. def __del__(self):
  5155. Bar.__del__(self)
  5156.  
  5157. def __BuildText(self):
  5158. self.text = TextLine()
  5159. self.text.SetParent(self)
  5160. self.text.SetPosition(4, 3)
  5161. self.text.Show()
  5162.  
  5163. def SetText(self, text):
  5164. self.text.SetText(text)
  5165.  
  5166. def SetReadingPosition(self, x, y):
  5167. xPos = x + 2
  5168. yPos = y - self.GetHeight() - 2
  5169. self.SetPosition(xPos, yPos)
  5170.  
  5171. def SetTextColor(self, color):
  5172. self.text.SetPackedFontColor(color)
  5173.  
  5174.  
  5175. def MakeSlotBar(parent, x, y, width, height):
  5176. slotBar = SlotBar()
  5177. slotBar.SetParent(parent)
  5178. slotBar.SetSize(width, height)
  5179. slotBar.SetPosition(x, y)
  5180. slotBar.Show()
  5181. return slotBar
  5182.  
  5183. def MakeImageBox(parent, name, x, y):
  5184. image = ImageBox()
  5185. image.SetParent(parent)
  5186. image.LoadImage(name)
  5187. image.SetPosition(x, y)
  5188. image.Show()
  5189. return image
  5190.  
  5191. def MakeTextLine(parent):
  5192. textLine = TextLine()
  5193. textLine.SetParent(parent)
  5194. textLine.SetWindowHorizontalAlignCenter()
  5195. textLine.SetWindowVerticalAlignCenter()
  5196. textLine.SetHorizontalAlignCenter()
  5197. textLine.SetVerticalAlignCenter()
  5198. textLine.Show()
  5199. return textLine
  5200.  
  5201. def MakeButton(parent, x, y, tooltipText, path, up, over, down):
  5202. button = Button()
  5203. button.SetParent(parent)
  5204. button.SetPosition(x, y)
  5205. button.SetUpVisual(path + up)
  5206. button.SetOverVisual(path + over)
  5207. button.SetDownVisual(path + down)
  5208. button.SetToolTipText(tooltipText)
  5209. button.Show()
  5210. return button
  5211.  
  5212. def RenderRoundBox(x, y, width, height, color):
  5213. grp.SetColor(color)
  5214. grp.RenderLine(x+2, y, width-3, 0)
  5215. grp.RenderLine(x+2, y+height, width-3, 0)
  5216. grp.RenderLine(x, y+2, 0, height-4)
  5217. grp.RenderLine(x+width, y+1, 0, height-3)
  5218. grp.RenderLine(x, y+2, 2, -2)
  5219. grp.RenderLine(x, y+height-2, 2, 2)
  5220. grp.RenderLine(x+width-2, y, 2, 2)
  5221. grp.RenderLine(x+width-2, y+height, 2, -2)
  5222.  
  5223. def GenerateColor(r, g, b):
  5224. r = float(r) / 255.0
  5225. g = float(g) / 255.0
  5226. b = float(b) / 255.0
  5227. return grp.GenerateColor(r, g, b, 1.0)
  5228.  
  5229. def EnablePaste(flag):
  5230. ime.EnablePaste(flag)
  5231.  
  5232. def GetHyperlink():
  5233. return wndMgr.GetHyperlink()
  5234.  
  5235. def MakeText(parent, textlineText, x, y, color):
  5236. textline = TextLine()
  5237. if parent != None:
  5238. textline.SetParent(parent)
  5239. textline.SetPosition(x, y)
  5240. if color != None:
  5241. textline.SetFontColor(color[0], color[1], color[2])
  5242. textline.SetText(textlineText)
  5243. textline.Show()
  5244. return textline
  5245. def MakeThinBoard(parent, x, y, width, heigh, moveable=FALSE,center=FALSE):
  5246. thin = ThinBoard()
  5247. if parent != None:
  5248. thin.SetParent(parent)
  5249. if moveable == TRUE:
  5250. thin.AddFlag('movable')
  5251. thin.AddFlag('float')
  5252. thin.SetSize(width, heigh)
  5253. thin.SetPosition(x, y)
  5254. if center == TRUE:
  5255. thin.SetCenterPosition()
  5256. thin.Show()
  5257. return thin
  5258.  
  5259. RegisterToolTipWindow("TEXT", TextLine)
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement