/*
DynAPI Distribution
List Class
The DynAPI Distribution is distributed under the terms of the GNU LGPL license.
Requirements:
dynapi.api [dynlayer, dyndocument, nodeitem, events]
dynapi.gui [NodeItem]
*/
function List(){
this.DynLayer=DynLayer;
this.DynLayer();
this.multiMode = false;
this.items = [];
this.listener={
onselect : function(e){
var o=e.getSource().parent;o.select(e.getSource());
},
ondeselect : function(e){
var o=e.getSource().parent;o.deselect(e.getSource());
}
};
this.onCreate(this.PreCreate);
/*default style*/
this.listStyle = {};
this.listStyle.borders = 1;
this.listStyle.spacing = 1;
this.listStyle.padding = 4;
this.listStyle.bos = false;
this.listStyle.ios = false;
this.listStyle.bg = "#eeeeee";
this.listStyle.bgRoll = "#cccccc";
this.listStyle.bgSelect = "lightblue";
this.totalHeight = this.listStyle.borders;
}
var p = dynapi.setPrototype('List','DynLayer');
p.PreCreate=function()
{
if(this._created)
{
this.arrangeItems();
}
}
p.add = function(){
if((arguments.length>1) || (arguments.length<5))
{
var ls = this.listStyle;
switch(arguments.length)
{
case 2:
var content=arguments[0];
var selectedcontent=arguments[0];
var i = new NodeItem(content,arguments[1]);
if (ls.bos) selectedcontent=""+selectedcontent+"";
if (ls.ios) selectedcontent=""+selectedcontent+"";
i.setSelectedContent(selectedcontent);
break;
case 3:
var i = new NodeItem(arguments[0],arguments[2]);
i.setSelectedContent(arguments[1]);
break;
case 4:
var i = new NodeItem(arguments[0],arguments[3]);
i.setSelectedContent(arguments[1]);
i.setRolloverContent(arguments[2]);
break;
}
i.setColors(ls.bg,ls.bgRoll,ls.bgSelect);
i.addEventListener(this.listener);
i.setAutoResize(false,true);
this.items[this.items.length] = i;
this.addChild(i);
if(dynapi.loaded) this.arrangeItems();
}
};
p.arrangeItems = function(){
this.totalHeight = this.listStyle.borders;
for (var i=0;i