Guest User

Untitled

a guest
Nov 1st, 2017
114
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
text 4.61 KB | None | 0 0
  1. import ui
  2. import dbg
  3. import app
  4. import locale
  5.  
  6. class Component:
  7. def Button(self, parent, buttonName, tooltipText, x, y, func, UpVisual, OverVisual, DownVisual):
  8. button = ui.Button()
  9. if parent != None:
  10. button.SetParent(parent)
  11. button.SetPosition(x, y)
  12. button.SetUpVisual(UpVisual)
  13. button.SetOverVisual(OverVisual)
  14. button.SetDownVisual(DownVisual)
  15. button.SetText(buttonName)
  16. button.SetToolTipText(tooltipText)
  17. button.Show()
  18. button.SetEvent(func)
  19. return button
  20.  
  21. def ToggleButton(self, parent, buttonName, tooltipText, x, y, funcUp, funcDown, UpVisual, OverVisual, DownVisual):
  22. button = ui.ToggleButton()
  23. if parent != None:
  24. button.SetParent(parent)
  25. button.SetPosition(x, y)
  26. button.SetUpVisual(UpVisual)
  27. button.SetOverVisual(OverVisual)
  28. button.SetDownVisual(DownVisual)
  29. button.SetText(buttonName)
  30. button.SetToolTipText(tooltipText)
  31. button.Show()
  32. button.SetToggleUpEvent(funcUp)
  33. button.SetToggleDownEvent(funcDown)
  34. return button
  35.  
  36. def HorizontalBar(self, parent, x, y, width):
  37. bar = ui.HorizontalBar()
  38. if parent != None:
  39. bar.SetParent(parent)
  40. bar.SetPosition(x, y)
  41. bar.Create(width)
  42. bar.Show()
  43. return bar
  44.  
  45. def EditLine(self, parent, editlineText, x, y, width, heigh, max):
  46. SlotBar = ui.SlotBar()
  47. if parent != None:
  48. SlotBar.SetParent(parent)
  49. SlotBar.SetSize(width, heigh)
  50. SlotBar.SetPosition(x, y)
  51. SlotBar.Show()
  52. Value = ui.EditLine()
  53. Value.SetParent(SlotBar)
  54. Value.SetSize(width, heigh)
  55. Value.SetPosition(3, 2)
  56. Value.SetMax(max)
  57. Value.SetLimitWidth(width)
  58. Value.SetMultiLine()
  59. Value.SetText(editlineText)
  60. Value.Show()
  61. self.Value = Value
  62. return SlotBar, Value
  63.  
  64. def EditLineText(self):
  65. return self.Value.GetText()
  66.  
  67. def SlotWithText(self, parent, text, x, y, width, height):
  68. SlotBar = ui.SlotBar()
  69. if parent != None:
  70. SlotBar.SetParent(parent)
  71. SlotBar.SetSize(width, height)
  72. SlotBar.SetPosition(x, y)
  73. SlotBar.Show()
  74. textline = ui.TextLine()
  75. textline.SetParent(SlotBar)
  76. textline.SetPosition(5, 1)
  77. textline.SetText(text)
  78. textline.Show()
  79. return SlotBar, textline
  80.  
  81. def TextLine(self, parent, textlineText, x, y, color):
  82. textline = ui.TextLine()
  83. if parent != None:
  84. textline.SetParent(parent)
  85. textline.SetPosition(x, y)
  86. if color != None:
  87. textline.SetFontColor(color[0], color[1], color[2])
  88. textline.SetText(textlineText)
  89. textline.Show()
  90. return textline
  91.  
  92. def LargeTextLine(self, parent, textlineText, x, y, color):
  93. textline = ui.TextLine()
  94. if parent != None:
  95. textline.SetParent(parent)
  96. textline.SetPosition(x, y)
  97. textline.SetFontName(locale.UI_DEF_FONT_LARGE)
  98. textline.SetPackedFontColor(color)
  99. textline.SetText(textlineText)
  100. textline.Show()
  101. return textline
  102.  
  103. def RGB(self, r, g, b):
  104. return (r*255, g*255, b*255)
  105.  
  106. def SliderBar(self, parent, sliderPos, func, x, y):
  107. Slider = ui.SliderBar()
  108. if parent != None:
  109. Slider.SetParent(parent)
  110. Slider.SetPosition(x, y)
  111. Slider.SetSliderPos(sliderPos / 100)
  112. Slider.Show()
  113. Slider.SetEvent(func)
  114. return Slider
  115.  
  116. def ExpandedImage(self, parent, x, y, img):
  117. image = ui.ExpandedImageBox()
  118. if parent != None:
  119. image.SetParent(parent)
  120. image.SetPosition(x, y)
  121. image.LoadImage(img)
  122. image.Show()
  123. return image
  124.  
  125. def ComboBox(self, parent, text, x, y, width):
  126. combo = ui.ComboBox()
  127. if parent != None:
  128. combo.SetParent(parent)
  129. combo.SetPosition(x, y)
  130. combo.SetSize(width, 15)
  131. combo.SetCurrentItem(text)
  132. combo.Show()
  133. return combo
  134.  
  135. def ThinBoard(self, parent, moveable, x, y, width, heigh, center):
  136. thin = ui.ThinBoard()
  137. if parent != None:
  138. thin.SetParent(parent)
  139. if moveable == TRUE:
  140. thin.AddFlag('movable')
  141. thin.AddFlag('float')
  142. thin.SetSize(width, heigh)
  143. thin.SetPosition(x, y)
  144. if center == TRUE:
  145. thin.SetCenterPosition()
  146. thin.Show()
  147. return thin
  148.  
  149. def Gauge(self, parent, width, color, x, y):
  150. gauge = ui.Gauge()
  151. if parent != None:
  152. gauge.SetParent(parent)
  153. gauge.SetPosition(x, y)
  154. gauge.MakeGauge(width, color)
  155. gauge.Show()
  156. return gauge
  157.  
  158. def ListBoxEx(self, parent, x, y, width, heigh):
  159. bar = ui.Bar()
  160. if parent != None:
  161. bar.SetParent(parent)
  162. bar.SetPosition(x, y)
  163. bar.SetSize(width, heigh)
  164. bar.SetColor(0x77000000)
  165. bar.Show()
  166. ListBox=ui.ListBoxEx()
  167. ListBox.SetParent(bar)
  168. ListBox.SetPosition(0, 0)
  169. ListBox.SetSize(width, heigh)
  170. ListBox.Show()
  171. scroll = ui.ScrollBar()
  172. scroll.SetParent(ListBox)
  173. scroll.SetPosition(width-15, 0)
  174. scroll.SetScrollBarSize(heigh)
  175. scroll.Show()
  176. ListBox.SetScrollBar(scroll)
  177. return bar, ListBox
Add Comment
Please, Sign In to add comment