Advertisement
Guest User

Untitled

a guest
Mar 27th, 2015
206
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
text 3.79 KB | None | 0 0
  1. class Window(object):
  2. def NoneMethod(cls):
  3. pass
  4.  
  5. NoneMethod = classmethod(NoneMethod)
  6.  
  7. def __init__(self, layer = "UI"):
  8. self.hWnd = None
  9. self.parentWindow = 0
  10. self.RegisterWindow(layer)
  11. self.clickEvent = None
  12. self.Hide()
  13.  
  14. def __del__(self):
  15. wndMgr.Destroy(self.hWnd)
  16.  
  17. def RegisterWindow(self, layer):
  18. self.hWnd = wndMgr.Register(self, layer)
  19.  
  20. def Destroy(self):
  21. pass
  22.  
  23. def GetWindowHandle(self):
  24. return self.hWnd
  25.  
  26. def AddFlag(self, style):
  27. wndMgr.AddFlag(self.hWnd, style)
  28.  
  29. def IsRTL(self):
  30. return wndMgr.IsRTL(self.hWnd)
  31.  
  32. def SetWindowName(self, Name):
  33. wndMgr.SetName(self.hWnd, Name)
  34.  
  35. def SetParent(self, parent):
  36. wndMgr.SetParent(self.hWnd, parent.hWnd)
  37.  
  38. def SetParentProxy(self, parent):
  39. self.parentWindow=proxy(parent)
  40. wndMgr.SetParent(self.hWnd, parent.hWnd)
  41.  
  42.  
  43. def GetParentProxy(self):
  44. return self.parentWindow
  45.  
  46. def SetPickAlways(self):
  47. wndMgr.SetPickAlways(self.hWnd)
  48.  
  49. def SetWindowHorizontalAlignLeft(self):
  50. wndMgr.SetWindowHorizontalAlign(self.hWnd, wndMgr.HORIZONTAL_ALIGN_LEFT)
  51.  
  52. def SetWindowHorizontalAlignCenter(self):
  53. wndMgr.SetWindowHorizontalAlign(self.hWnd, wndMgr.HORIZONTAL_ALIGN_CENTER)
  54.  
  55. def SetWindowHorizontalAlignRight(self):
  56. wndMgr.SetWindowHorizontalAlign(self.hWnd, wndMgr.HORIZONTAL_ALIGN_RIGHT)
  57.  
  58. def SetWindowVerticalAlignTop(self):
  59. wndMgr.SetWindowVerticalAlign(self.hWnd, wndMgr.VERTICAL_ALIGN_TOP)
  60.  
  61. def SetWindowVerticalAlignCenter(self):
  62. wndMgr.SetWindowVerticalAlign(self.hWnd, wndMgr.VERTICAL_ALIGN_CENTER)
  63.  
  64. def SetWindowVerticalAlignBottom(self):
  65. wndMgr.SetWindowVerticalAlign(self.hWnd, wndMgr.VERTICAL_ALIGN_BOTTOM)
  66.  
  67. def SetTop(self):
  68. wndMgr.SetTop(self.hWnd)
  69.  
  70. def Show(self):
  71. wndMgr.Show(self.hWnd)
  72.  
  73. def Hide(self):
  74. wndMgr.Hide(self.hWnd)
  75.  
  76. def Lock(self):
  77. wndMgr.Lock(self.hWnd)
  78.  
  79. def Unlock(self):
  80. wndMgr.Unlock(self.hWnd)
  81.  
  82. def IsShow(self):
  83. return wndMgr.IsShow(self.hWnd)
  84.  
  85. def UpdateRect(self):
  86. wndMgr.UpdateRect(self.hWnd)
  87.  
  88. def SetSize(self, width, height):
  89. wndMgr.SetWindowSize(self.hWnd, width, height)
  90.  
  91. def GetWidth(self):
  92. return wndMgr.GetWindowWidth(self.hWnd)
  93.  
  94. def GetHeight(self):
  95. return wndMgr.GetWindowHeight(self.hWnd)
  96.  
  97. def GetLocalPosition(self):
  98. return wndMgr.GetWindowLocalPosition(self.hWnd)
  99.  
  100. def GetLeft(self):
  101. (x, y) = self.GetLocalPosition()
  102. return x
  103.  
  104. def GetRight(self):
  105. return self.GetLeft() + self.GetWidth()
  106.  
  107. def GetTop(self):
  108. (x, y) = self.GetLocalPosition()
  109. return y
  110.  
  111. def GetBottom(self):
  112. return self.GetTop() + self.GetHeight()
  113.  
  114. def GetGlobalPosition(self):
  115. return wndMgr.GetWindowGlobalPosition(self.hWnd)
  116.  
  117. def GetGlobalLeft(self):
  118. (x, y) = self.GetGlobalPosition()
  119. return x
  120.  
  121. def GetGlobalRight(self):
  122. return self.GetGlobalLeft() + self.GetWidth()
  123.  
  124. def GetGlobalTop(self):
  125. (x, y) = self.GetGlobalPosition()
  126. return y
  127.  
  128. def GetGlobalBottom(self):
  129. return self.GetGlobalTop() + self.GetHeight()
  130.  
  131. def GetMouseLocalPosition(self):
  132. return wndMgr.GetMouseLocalPosition(self.hWnd)
  133.  
  134. def GetRect(self):
  135. return wndMgr.GetWindowRect(self.hWnd)
  136.  
  137. def SetPosition(self, x, y):
  138. wndMgr.SetWindowPosition(self.hWnd, x, y)
  139.  
  140. def SetCenterPosition(self, x = 0, y = 0):
  141. self.SetPosition((wndMgr.GetScreenWidth() - self.GetWidth()) / 2 + x, (wndMgr.GetScreenHeight() - self.GetHeight()) / 2 + y)
  142.  
  143. def IsFocus(self):
  144. return wndMgr.IsFocus(self.hWnd)
  145.  
  146. def SetFocus(self):
  147. wndMgr.SetFocus(self.hWnd)
  148.  
  149. def KillFocus(self):
  150. wndMgr.KillFocus(self.hWnd)
  151.  
  152. def GetChildCount(self):
  153. return wndMgr.GetChildCount(self.hWnd)
  154.  
  155. def IsIn(self):
  156. return wndMgr.IsIn(self.hWnd)
  157.  
  158. def SetClickEvent(self, event):
  159. self.clickEvent = __mem_func__(event)
  160.  
  161. def OnMouseLeftButtonDown(self):
  162. if self.clickEvent:
  163. self.clickEvent()
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement