/* Copyright (c): 2002-2005 (Germany): United Internet, 1&1, GMX, Schlund+Partner, Alturo */
function QxList(){QxWidget.call(this);this.setCanSelect(false);this.setOverflow("auto");this.setTabIndex(1);this._manager=new QxSelectionManager(this);this.addEventListener("mouseover",this._onmouseover);this.addEventListener("mousedown",this._g1);this.addEventListener("mouseup",this._g2);this.addEventListener("click",this._g3);this.addEventListener("dblclick",this._ondblclick);this.addEventListener("keydown",this._g4);this.addEventListener("keypress",this._g6);};QxList.extend(QxWidget,"QxList");QxList.addProperty({name:"enableInlineFind",type:Boolean,defaultValue:true});proto.isFocusRoot=function(){return true;};proto._pressedString="";proto._visualizeBlur=function(){};proto._visualizeFocus=function(){};proto.getManager=function(){return this._manager;};proto.getListItemTarget=function(vItem){while(vItem!=null&&vItem.getParent()!=this){vItem=vItem.getParent();};return vItem;};proto.getSelectedItem=function(){return this.getSelectedItems()[0];};proto.getSelectedItems=function(){return this._manager.getSelectedItems();};proto._onmouseover=function(e){var vItem=this.getListItemTarget(e.getTarget());if(vItem){this._manager.handleMouseOver(vItem,e);};};proto._g1=function(e){var vItem=this.getListItemTarget(e.getTarget());if(vItem){this._manager.handleMouseDown(vItem,e);};};proto._g2=function(e){var vItem=this.getListItemTarget(e.getTarget());if(vItem){this._manager.handleMouseUp(vItem,e);};};proto._g3=function(e){var vItem=this.getListItemTarget(e.getTarget());if(vItem){this._manager.handleClick(vItem,e);};};proto._ondblclick=function(e){var vItem=this.getListItemTarget(e.getTarget());if(vItem){this._manager.handleDblClick(vItem,e);};};proto._g4=function(e){var kc=e.getKeyCode();if(kc==QxKeyEvent.keys.enter&&!e.getAltKey()){var items=this.getSelectedItems();var currentItem;for(var i=0;i<items.length;i++){currentItem=items[i];if(currentItem.hasEventListeners("action")){currentItem._dispachEvent(new QxEvent("action"));};};}else {this._manager.handleKeyDown(e);};};this._lastKeyPress=0;proto._g6=function(e){if(!this.getEnableInlineFind()){return;};if(((new Date).valueOf()-this._lastKeyPress)>1000){this._pressedString="";};this._pressedString+=String.fromCharCode(e.getKeyCode());var matchedItem=this.findString(this._pressedString,null);if(matchedItem){var oldVal=this._manager._getChangeValue();var oldFireChange=this._manager.getFireChange();this._manager.setFireChange(false);this._manager._j7();this._manager.setItemSelected(matchedItem,true);this._manager.setAnchorItem(matchedItem);this._manager.setLeadItem(matchedItem);matchedItem.scrollIntoView();this._manager.setFireChange(oldFireChange);if(oldFireChange&&this._manager._j8(oldVal)){this._manager._j1();};};this._lastKeyPress=(new Date).valueOf();e.preventDefault();};proto._findItem=function(vUserValue,vStartIndex,vType){var vAllItems=this.getChildren();if(vStartIndex==null){vStartIndex=vAllItems.indexOf(this.getSelectedItem());if(vStartIndex==-1){vStartIndex=0;};};var methodName="matches"+vType;for(var i=vStartIndex;i<vAllItems.length;i++){if(vAllItems[i][methodName](vUserValue)){return vAllItems[i];};};for(var i=0;i<vStartIndex;i++){if(vAllItems[i][methodName](vUserValue)){return vAllItems[i];};};return null;};proto.findString=function(vText,vStartIndex){return this._findItem(vText,vStartIndex||0,"String");};proto.findStringExact=function(vText,vStartIndex){return this._findItem(vText,vStartIndex||0,"StringExact");};proto.getPreferredHeight=function(){var ch=this.getChildren();var chl=ch.length;var sum=0;for(var i=0;i<chl;i++){sum+=ch[i].getPreferredHeight();};return sum;};