## GUI
Class GUIList

source: C:\XIII\GUI\Classes\GUIList.uc

    Core.Object
       |
       +--GUI.GUI
          |
          +--GUI.GUIComponent
             |
             +--GUI.GUIListBase
                |
                +--GUI.GUIVertList
                   |
                   +--GUI.GUIList

Direct Known Subclasses:GUIMultiList

class GUIList
extends GUI.GUIVertList

    // ====================================================================
    //  (c) 2002, Epic Games, Inc.  All Rights Reserved
    // ====================================================================

Function Summary
`void` | `Add(string NewItem, optional Object, optional string)`
`void` | `Clear()`
`string` | `Get()`
`void` | `GetAtIndex(int i, out string, out object, out string)`
`string` | `GetExtra()`
`string` | `GetExtraAtIndex(int i)`
`string` | `GetItemAtIndex(int i)`
`Object` | `GetObject()`
`Object` | `GetObjectAtIndex(int i)`
`void` | `Insert(int Index, string NewItem, optional Object, optional string)`
`void` | `LoadFrom(GUIList Source, optional bool)`
`void` | `Remove(int i, optional int)`
`void` | `RemoveItem(string Item)`
`void` | `Replace(int index, string NewItem, optional Object, optional string)`
`string` | `SelectedText()`
    // Accessor function for the items.
`void` | `SetExtraAtIndex(int i, string NewExtra)`
`void` | `SetItemAtIndex(int i, string NewItem)`
`void` | `SortList()`
    // How is text Aligned in the control
`string` | `find(string Text, optional bool)`

Source Code

    00001	// ====================================================================
    00002	//  (c) 2002, Epic Games, Inc.  All Rights Reserved
    00003	// ====================================================================
    00004
    00005	class GUIList extends GUIVertList
    00006			Native;
    00007
    00008	//#exec OBJ LOAD FILE=GUIContent.utx
    00009
    00010
    00011	var		eTextAlign			TextAlign;			// How is text Aligned in the control
    00012
    00013	var	    array<GUIListElem>	Elements;
    00014
    00015	native final function SortList();
    00016
    00017	// Used by SortList.
    00018	delegate int CompareItem(GUIListElem ElemA, GUIListElem ElemB);
    00019
    00020	// Accessor function for the items.
    00021
    00022	function string SelectedText()
    00023	{
    00024		if ( (Index >=0) && (Index <Elements.Length) )
    00025			return Elements[Index].Item;
    00026		else
    00027			return "";
    00028	}
    00029
    00030	function Add(string NewItem, optional Object obj, optional string Str)
    00031	{
    00032		Elements.Length = Elements.Length+1;
    00033
    00034		Elements[Elements.Length-1].Item=NewItem;
    00035		Elements[Elements.Length-1].ExtraData=obj;
    00036		Elements[Elements.Length-1].ExtraStrData=Str;
    00037
    00038		ItemCount=Elements.Length;
    00039
    00040		if (Elements.Length == 1)
    00041			SetIndex(0);
    00042		else
    00043			OnChange(self);
    00044
    00045		MyScrollBar.AlignThumb();
    00046	}
    00047
    00048	function Replace(int index, string NewItem, optional Object obj, optional string Str)
    00049	{
    00050		if ( (Index<0) || (Index>=Elements.Length) )
    00051			Add(NewItem,Obj,Str);
    00052		else
    00053		{
    00054			Elements[Index].Item = NewItem;
    00055			Elements[Index].ExtraData = obj;
    00056			Elements[Index].ExtraStrData = Str;
    00057		}
    00058	}
    00059
    00060	function Insert(int Index, string NewItem, optional Object obj, optional string Str)
    00061	{
    00062		if ( (Index<0) || (Index>=Elements.Length) )
    00063			Add(NewItem,Obj,Str);
    00064		else
    00065		{
    00066			Elements.Insert(index,1);
    00067			Elements[Index].Item=NewItem;
    00068			Elements[Index].ExtraData=obj;
    00069			Elements[Index].ExtraStrData=Str;
    00070
    00071			ItemCount=Elements.Length;
    00072
    00073			OnChange(self);
    00074			MyScrollBar.AlignThumb();
    00075		}
    00076	}
    00077
    00078	event Swap(int IndexA, int IndexB)
    00079	{
    00080		local GUI.GUIListElem elem;
    00081
    00082		if ( (IndexA<0) || (IndexA>=Elements.Length) || (IndexB<0) || (IndexB>=Elements.Length) )
    00083			return;
    00084
    00085		elem = Elements[IndexA];
    00086		Elements[IndexA] = Elements[IndexB];
    00087		Elements[IndexB] = elem;
    00088	}
    00089
    00090	function string GetItemAtIndex(int i)
    00091	{
    00092		if ((i<0) || (i>Elements.Length))
    00093			return "";
    00094
    00095		return Elements[i].Item;
    00096	}
    00097
    00098	function SetItemAtIndex(int i, string NewItem)
    00099	{
    00100		if ((i<0) || (i>Elements.Length))
    00101			return;
    00102
    00103		Elements[i].Item = NewItem;
    00104	}
    00105
    00106	function object GetObjectAtIndex(int i)
    00107	{
    00108		if ((i<0) || (i>Elements.Length))
    00109			return None;
    00110
    00111		return Elements[i].ExtraData;
    00112	}
    00113
    00114	function string GetExtraAtIndex(int i)
    00115	{
    00116		if ((i<0) || (i>Elements.Length))
    00117			return "";
    00118
    00119		return Elements[i].ExtraStrData;
    00120	}
    00121
    00122	function SetExtraAtIndex(int i, string NewExtra)
    00123	{
    00124		if ((i<0) || (i>Elements.Length))
    00125			return;
    00126
    00127		Elements[i].ExtraStrData = NewExtra;
    00128	}
    00129
    00130	function GetAtIndex(int i, out string ItemStr, out object ExtraObj, out string ExtraStr)
    00131	{
    00132		if ((i<0) || (i>Elements.Length))
    00133			return;
    00134
    00135		ItemStr = Elements[i].Item;
    00136		ExtraObj = Elements[i].ExtraData;
    00137		ExtraStr = Elements[i].ExtraStrData;
    00138	}
    00139
    00140	function LoadFrom(GUIList Source, optional bool bClearFirst)
    00141	{
    00142		local string t1,t2;
    00143		local object t;
    00144		local int i;
    00145
    00146		if (bClearfirst)
    00147			Clear();
    00148
    00149		for (i=0;i<Source.Elements.Length;i++)
    00150		{
    00151			Source.GetAtIndex(i,t1,t,t2);
    00152			Add(t1,t,t2);
    00153		}
    00154	}
    00155
    00156	function Remove(int i, optional int Count)
    00157	{
    00158		if (Count==0)
    00159			Count=1;
    00160
    00161		Elements.Remove(i, Count);
    00162
    00163		ItemCount = Elements.Length;
    00164
    00165		SetIndex(-1);
    00166		MyScrollBar.AlignThumb();
    00167	}
    00168
    00169	function RemoveItem(string Item)
    00170	{
    00171		local int i;
    00172
    00173		// Work through array. If we find it, remove it (will reduce Elements.Length).
    00174		// If we don't, move on to next one.
    00175		i=0;
    00176		while(i<Elements.Length)
    00177		{
    00178			if(Item ~= Elements[i].Item)
    00179				Elements.Remove(i, 1);
    00180			else
    00181				i++;
    00182		}
    00183
    00184		ItemCount = Elements.Length;
    00185
    00186		SetIndex(-1);
    00187		MyScrollBar.AlignThumb();
    00188	}
    00189
    00190	function Clear()
    00191	{
    00192		Elements.Remove(0,Elements.Length);
    00193
    00194		Super.Clear();
    00195		OnChange(self);
    00196	}
    00197
    00198	function string Get()
    00199	{
    00200		if ( (Index<0) || (Index>=ItemCount) )
    00201			return "";
    00202		else
    00203			return Elements[Index].Item;
    00204	}
    00205
    00206	function object GetObject()
    00207	{
    00208		if ( (Index<0) || (Index>=ItemCount) )
    00209			return none;
    00210		else
    00211			return Elements[Index].ExtraData;
    00212	}
    00213
    00214	function string GetExtra()
    00215	{
    00216		if ( (Index<0) || (Index>=ItemCount) )
    00217			return "";
    00218		else
    00219			return Elements[Index].ExtraStrData;
    00220	}
    00221
    00222	function string find(string Text, optional bool bExact)
    00223	{
    00224		local int i;
    00225		for (i=0;i<ItemCount;i++)
    00226		{
    00227			if (bExact)
    00228			{
    00229				if (Text == Elements[i].Item)
    00230				{
    00231					SetIndex(i);
    00232					return  Elements[i].Item;
    00233				}
    00234			}
    00235			else
    00236			{
    00237				if (Text ~=  Elements[i].Item)
    00238				{
    00239					SetIndex(i);
    00240					return  Elements[i].Item;
    00241				}
    00242			}
    00243		}
    00244		return "";
    00245	}
    00246
    00247
00248 00249 defaultproperties 00250 { 00251 TextAlign=TXTA_Center 00252 }

End Source Code