home *** CD-ROM | disk | FTP | other *** search
/ PC PowerPlay 56 / CDPowerplay56Disc2.iso / demos / blade / data1.cab / Program_Executable_Files / Lib / Widgets / ListWidget.pyc (.txt) < prev    next >
Encoding:
Python Compiled Bytecode  |  2000-10-27  |  6.1 KB  |  142 lines

  1. # Source Generated with Decompyle++
  2. # File: in.pyc (Python 1.5)
  3.  
  4. import Raster
  5. import BUIx
  6. import MenuWidget
  7. import ScorerWidgets
  8. import pdb
  9.  
  10. class B_ListWidget(MenuWidget.B_MenuFocusManager, BUIx.B_FrameWidget):
  11.     
  12.     def __init__(self, Parent, Menudesc, StackMenu, VertPos = 0):
  13.         (width, height) = Raster.GetSize()
  14.         
  15.         try:
  16.             (width, height) = Menudesc['Size']
  17.         except:
  18.             pass
  19.  
  20.         MenuWidget.B_MenuFocusManager.__init__(self)
  21.         BUIx.B_FrameWidget.__init__(self, Parent, 'List' + Menudesc['Name'], width, height)
  22.         self.nElements = 0
  23.         self.Position = 0
  24.         self.ListItems = []
  25.         self.VertPos = 0
  26.         self.ListSize = 0
  27.         self.WidgetsVPos = []
  28.         self.WidgetsHeights = []
  29.         self.SetClipDraw(1)
  30.         for i in Menudesc['ListDescr']:
  31.             m_class = MenuWidget.B_MenuItemTextNoFX
  32.             
  33.             try:
  34.                 m_class = i['Kind']
  35.             except:
  36.                 0
  37.                 Menudesc['ListDescr']
  38.  
  39.             wSubMenu = m_class(self, i, StackMenu)
  40.             self.AddMenuElement(wSubMenu)
  41.         
  42.         self.SetFocus_Idx(1)
  43.         self.UpArrow = BUIx.B_TextWidget(self, 'UpArrow', chr(190), ScorerWidgets.font_server, '..\\..\\Data\\Letras menu med.bmp')
  44.         self.AddWidget(self.UpArrow, 77, 0, BUIx.B_FrameWidget.B_FR_AbsoluteLeft, BUIx.B_FrameWidget.B_FR_Left, BUIx.B_FrameWidget.B_FR_AbsoluteTop, BUIx.B_FrameWidget.B_FR_Top)
  45.         self.UpArrow.SetColor(250, 0, 0)
  46.         self.UpArrow.SetAlpha(0.5)
  47.         self.DownArrow = BUIx.B_TextWidget(self, 'DownArrow', chr(191), ScorerWidgets.font_server, '..\\..\\Data\\Letras menu med.bmp')
  48.         self.AddWidget(self.DownArrow, 77, 0, BUIx.B_FrameWidget.B_FR_AbsoluteLeft, BUIx.B_FrameWidget.B_FR_Left, BUIx.B_FrameWidget.B_FR_AbsoluteBottom, BUIx.B_FrameWidget.B_FR_Bottom)
  49.         self.DownArrow.SetColor(250, 0, 0)
  50.         self.DownArrow.SetAlpha(0.5)
  51.  
  52.     
  53.     def __del__(self):
  54.         for i in self.MenuItems:
  55.             i.SetDrawFunc(None)
  56.         
  57.         MenuWidget.B_MenuFocusManager.__del__(self)
  58.         BUIx.B_FrameWidget.__del__(self)
  59.  
  60.     
  61.     def __str__(self):
  62.         print 'B_ListWidget', self.Name()
  63.  
  64.     
  65.     def AdjustScrollArrows(self):
  66.         if self.VertPos < 0:
  67.             self.UpArrow.SetAlpha(1)
  68.         else:
  69.             self.UpArrow.SetAlpha(0.4)
  70.         (w, h) = self.GetSize()
  71.         if self.ListSize + self.VertPos > h:
  72.             self.DownArrow.SetAlpha(1)
  73.         else:
  74.             self.DownArrow.SetAlpha(0.4)
  75.  
  76.     
  77.     def AddMenuElement(self, widget, sep = 0, HPos = 0.5, HIndicator = BUIx.B_FrameWidget.B_FR_HRelative, HAnchor = BUIx.B_FrameWidget.B_FR_HCenter):
  78.         MenuWidget.B_MenuFocusManager.AddMenuElement(self, widget)
  79.         self.AddWidget(widget, 117, self.ListSize, BUIx.B_FrameWidget.B_FR_AbsoluteLeft, BUIx.B_FrameWidget.B_FR_Left, BUIx.B_FrameWidget.B_FR_AbsoluteTop, BUIx.B_FrameWidget.B_FR_Top)
  80.         self.WidgetsVPos.append(self.ListSize)
  81.         widget_height = widget.GetSize()[1]
  82.         self.WidgetsHeights.append(widget_height)
  83.         self.ListSize = self.ListSize + widget_height
  84.         self.SetFocus(widget.Name())
  85.  
  86.     
  87.     def NextFocus(self):
  88.         curr_focus = self.GetFocus()
  89.         index = self.MenuItems.index(curr_focus)
  90.         if index >= len(self.MenuItems) - 1:
  91.             self.AdjustScrollArrows()
  92.             return None
  93.         
  94.         MenuWidget.B_MenuFocusManager.NextFocus(self)
  95.         wFoc = self.GetFocus()
  96.         i = self.MenuItems.index(wFoc)
  97.         if self.WidgetsVPos[i] + self.WidgetsHeights[i] + self.VertPos >= self.GetSize()[1]:
  98.             self.DoScroll(-self.WidgetsHeights[i])
  99.         
  100.         self.AdjustScrollArrows()
  101.  
  102.     
  103.     def PrevFocus(self):
  104.         curr_focus = self.GetFocus()
  105.         index = self.MenuItems.index(curr_focus)
  106.         if index <= 0:
  107.             self.AdjustScrollArrows()
  108.             return None
  109.         
  110.         MenuWidget.B_MenuFocusManager.PrevFocus(self)
  111.         wFoc = self.GetFocus()
  112.         i = self.MenuItems.index(wFoc)
  113.         if self.WidgetsVPos[i] + self.WidgetsHeights[i] + self.VertPos <= 0:
  114.             self.DoScroll(self.WidgetsHeights[i])
  115.         
  116.         self.AdjustScrollArrows()
  117.  
  118.     
  119.     def RemoveWidget(self, widget):
  120.         print 'B_ListWidget::RemoveWidget() not implemented.'
  121.  
  122.     
  123.     def DoScroll(self, amount):
  124.         for i in range(self.nWidgets() - 2):
  125.             self.MoveWidgetRel_Idx(i, 0, amount)
  126.         
  127.         self.VertPos = self.VertPos + amount
  128.  
  129.     
  130.     def GetTopIndex(self):
  131.         pass
  132.  
  133.     
  134.     def SetTopIndex(self, index):
  135.         pass
  136.  
  137.     
  138.     def EnsureVisible(self, index):
  139.         pass
  140.  
  141.  
  142.