*** empty log message ***

This commit is contained in:
slpatto 2002-06-18 19:23:09 +00:00
parent 89af39b692
commit a723359846

View File

@ -10,11 +10,13 @@ class DirectScrolledList(DirectFrame):
# Inherits from DirectFrame # Inherits from DirectFrame
optiondefs = ( optiondefs = (
# Define type of DirectGuiWidget # Define type of DirectGuiWidget
('items', [], None), ('items', [], None),
('command', None, None), ('command', None, None),
('extraArgs', [], None), ('extraArgs', [], None),
('numItemsVisible', 1, self.setNumItemsVisible), ('itemMakeFunction', None, None),
('scrollSpeed', 8, self.setScrollSpeed), ('itemMakeExtraArgs', [], None),
('numItemsVisible', 1, self.setNumItemsVisible),
('scrollSpeed', 8, self.setScrollSpeed),
) )
# Merge keyword options with default options # Merge keyword options with default options
self.defineoptions(kw, optiondefs) self.defineoptions(kw, optiondefs)
@ -36,7 +38,8 @@ class DirectScrolledList(DirectFrame):
DirectFrame, (self,), DirectFrame, (self,),
) )
for item in self["items"]: for item in self["items"]:
item.reparentTo(self.itemFrame) if item.__class__.__name__ != 'str':
item.reparentTo(self.itemFrame)
self.initialiseoptions(DirectScrolledList) self.initialiseoptions(DirectScrolledList)
self.recordMaxHeight() self.recordMaxHeight()
@ -48,7 +51,8 @@ class DirectScrolledList(DirectFrame):
def recordMaxHeight(self): def recordMaxHeight(self):
self.maxHeight = 0.0 self.maxHeight = 0.0
for item in self["items"]: for item in self["items"]:
self.maxHeight = max(self.maxHeight, item.getHeight()) if item.__class__.__name__ != 'str':
self.maxHeight = max(self.maxHeight, item.getHeight())
def setScrollSpeed(self): def setScrollSpeed(self):
# Items per second to move # Items per second to move
@ -96,14 +100,28 @@ class DirectScrolledList(DirectFrame):
# Hide them all # Hide them all
for item in self["items"]: for item in self["items"]:
item.hide() if item.__class__.__name__ != 'str':
item.hide()
# Then show the ones in range, and stack their positions # Then show the ones in range, and stack their positions
upperRange = min(len(self["items"]), self["numItemsVisible"]) upperRange = min(len(self["items"]), self["numItemsVisible"])
for i in range(self.index, self.index + upperRange): for i in range(self.index, self.index + upperRange):
item = self["items"][i] item = self["items"][i]
# If the item is a 'str', then it has not been created (scrolled list is 'as needed')
# Therefore, use the the function given to make it or just make it a frame
if item.__class__.__name__ == 'str':
if self['itemMakeFunction']:
# If there is a function to create the item
item = apply(self['itemMakeFunction'], (item, i, self['itemMakeExtraArgs']))
else:
item = DirectFrame(text = item)
# Then add the newly formed item back into the normal item list
self["items"][i] = item
item.reparentTo(self.itemFrame)
self.recordMaxHeight()
item.show() item.show()
item.setPos(0,0, - (i - self.index) * self.maxHeight) item.setPos(0,0, - (i - self.index) * self.maxHeight)
if self['command']: if self['command']:
# Pass any extra args to command # Pass any extra args to command