*** empty log message ***

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

View File

@ -13,6 +13,8 @@ class DirectScrolledList(DirectFrame):
('items', [], None),
('command', None, None),
('extraArgs', [], None),
('itemMakeFunction', None, None),
('itemMakeExtraArgs', [], None),
('numItemsVisible', 1, self.setNumItemsVisible),
('scrollSpeed', 8, self.setScrollSpeed),
)
@ -36,6 +38,7 @@ class DirectScrolledList(DirectFrame):
DirectFrame, (self,),
)
for item in self["items"]:
if item.__class__.__name__ != 'str':
item.reparentTo(self.itemFrame)
self.initialiseoptions(DirectScrolledList)
@ -48,6 +51,7 @@ class DirectScrolledList(DirectFrame):
def recordMaxHeight(self):
self.maxHeight = 0.0
for item in self["items"]:
if item.__class__.__name__ != 'str':
self.maxHeight = max(self.maxHeight, item.getHeight())
def setScrollSpeed(self):
@ -96,15 +100,29 @@ class DirectScrolledList(DirectFrame):
# Hide them all
for item in self["items"]:
if item.__class__.__name__ != 'str':
item.hide()
# Then show the ones in range, and stack their positions
upperRange = min(len(self["items"]), self["numItemsVisible"])
for i in range(self.index, self.index + upperRange):
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.setPos(0,0, - (i - self.index) * self.maxHeight)
if self['command']:
# Pass any extra args to command
apply(self['command'], self['extraArgs'])