UWindow
Class UWindowComboControl

source: e:\games\UnrealTournament\UWindow\Classes\UWindowComboControl.uc
Core.Object
   |
   +--UWindow.UWindowBase
      |
      +--UWindow.UWindowWindow
         |
         +--UWindow.UWindowDialogControl
            |
            +--UWindow.UWindowComboControl
Direct Known Subclasses:None

class UWindowComboControl
extends UWindow.UWindowDialogControl


Variables
 UWindowComboButton Button
 EditAreaDrawX, EditAreaDrawY
 UWindowEditBox EditBox
 UWindowComboLeftButton LeftButton
 UWindowComboList List
 class ListClass
 UWindowComboRightButton RightButton
 bool bButtons
 bool bCanEdit
 bool bListVisible


Function Summary
 void AddItem(string S, optional string, optional int)
 void BeforePaint(Canvas C, float X, float Y)
 void Clear()
 void ClearValue()
 void Close(optional bool)
 void CloseUp()
 void Created()
 void DropDown()
 int FindItemIndex(string V, optional bool)
 int FindItemIndex2(string V2, optional bool)
 void FocusOtherWindow(UWindowWindow W)
 int GetSelectedIndex()
 string GetValue()
 string GetValue2()
 void InsertItem(string S, optional string, optional int)
 void Notify(byte E)
 void Paint(Canvas C, float X, float Y)
 void RemoveItem(int Index)
 void SetButtons(bool bInButtons)
 void SetEditTextColor(Color NewColor)
 void SetEditable(bool bNewCanEdit)
 void SetFont(int NewFont)
 void SetMaxLength(int MaxLength)
 void SetNumericFloat(bool bNumericFloat)
 void SetNumericOnly(bool bNumericOnly)
 void SetSelectedIndex(int Index)
 void SetValue(string NewValue, optional string)
 void Sort()



Source Code


00001	class UWindowComboControl extends UWindowDialogControl;
00002	
00003	var	float				EditBoxWidth;
00004	var float				EditAreaDrawX, EditAreaDrawY;
00005	
00006	var UWindowEditBox		EditBox;
00007	var UWindowComboButton	Button;
00008	var UWindowComboLeftButton LeftButton;
00009	var UWindowComboRightButton RightButton;
00010	
00011	var class<UWindowComboList>	ListClass;
00012	var UWindowComboList	List;
00013	
00014	var bool				bListVisible;
00015	var bool				bCanEdit;
00016	var bool				bButtons;
00017	
00018	function Created()
00019	{
00020		Super.Created();
00021		
00022		EditBox = UWindowEditBox(CreateWindow(class'UWindowEditBox', 0, 0, WinWidth-12, WinHeight)); 
00023		EditBox.NotifyOwner = Self;
00024		EditBoxWidth = WinWidth / 2;
00025		EditBox.bTransient = True;
00026	
00027		Button = UWindowComboButton(CreateWindow(class'UWindowComboButton', WinWidth-12, 0, 12, 10)); 
00028		Button.Owner = Self;
00029		
00030		List = UWindowComboList(Root.CreateWindow(ListClass, 0, 0, 100, 100)); 
00031		List.LookAndFeel = LookAndFeel;
00032		List.Owner = Self;
00033		List.Setup();
00034		
00035		List.HideWindow();
00036		bListVisible = False;
00037	
00038		SetEditTextColor(LookAndFeel.EditBoxTextColor);
00039	}
00040	
00041	function SetButtons(bool bInButtons)
00042	{
00043		bButtons = bInButtons;
00044		if(bInButtons)
00045		{
00046			LeftButton = UWindowComboLeftButton(CreateWindow(class'UWindowComboLeftButton', WinWidth-12, 0, 12, 10));
00047			RightButton = UWindowComboRightButton(CreateWindow(class'UWindowComboRightButton', WinWidth-12, 0, 12, 10));
00048		}
00049		else
00050		{
00051			LeftButton = None;
00052			RightButton = None;
00053		}
00054	}
00055	
00056	function Notify(byte E)
00057	{
00058		Super.Notify(E);
00059	
00060		if(E == DE_LMouseDown)
00061		{
00062			if(!bListVisible)
00063			{
00064				if(!bCanEdit)
00065				{
00066					DropDown();
00067					Root.CaptureMouse(List);
00068				}
00069			}
00070			else
00071				CloseUp();
00072		}
00073	}
00074	
00075	function int FindItemIndex(string V, optional bool bIgnoreCase)
00076	{
00077		return List.FindItemIndex(V, bIgnoreCase);
00078	}
00079	
00080	function RemoveItem(int Index)
00081	{
00082		List.RemoveItem(Index);
00083	}
00084	
00085	function int FindItemIndex2(string V2, optional bool bIgnoreCase)
00086	{
00087		return List.FindItemIndex2(V2, bIgnoreCase);
00088	}
00089	
00090	function Close(optional bool bByParent)
00091	{
00092		if(bByParent && bListVisible)
00093			CloseUp();
00094	
00095		Super.Close(bByParent);
00096	}
00097	
00098	function SetNumericOnly(bool bNumericOnly)
00099	{
00100		EditBox.bNumericOnly = bNumericOnly;
00101	}
00102	
00103	function SetNumericFloat(bool bNumericFloat)
00104	{
00105		EditBox.bNumericFloat = bNumericFloat;
00106	}
00107	
00108	function SetFont(int NewFont)
00109	{
00110		Super.SetFont(NewFont);
00111		EditBox.SetFont(NewFont);
00112	}
00113	
00114	function SetEditTextColor(Color NewColor)
00115	{
00116		EditBox.SetTextColor(NewColor);
00117	}
00118	
00119	function SetEditable(bool bNewCanEdit)
00120	{
00121		bCanEdit = bNewCanEdit;
00122		EditBox.SetEditable(bCanEdit);
00123	}
00124	
00125	function int GetSelectedIndex()
00126	{
00127		return List.FindItemIndex(GetValue());
00128	}
00129	
00130	function SetSelectedIndex(int Index)
00131	{
00132		SetValue(List.GetItemValue(Index), List.GetItemValue2(Index));
00133	}
00134	
00135	function string GetValue()
00136	{
00137		return EditBox.GetValue();
00138	}
00139	
00140	function string GetValue2()
00141	{
00142		return EditBox.GetValue2();
00143	}
00144	
00145	function SetValue(string NewValue, optional string NewValue2)
00146	{
00147		EditBox.SetValue(NewValue, NewValue2);
00148	}
00149	
00150	function SetMaxLength(int MaxLength)
00151	{
00152		EditBox.MaxLength = MaxLength;
00153	}
00154	
00155	function Paint(Canvas C, float X, float Y)
00156	{
00157		LookAndFeel.Combo_Draw(Self, C);
00158		Super.Paint(C, X, Y);
00159	}
00160	
00161	function AddItem(string S, optional string S2, optional int SortWeight)
00162	{
00163		List.AddItem(S, S2, SortWeight);
00164	}
00165	
00166	function InsertItem(string S, optional string S2, optional int SortWeight)
00167	{
00168		List.InsertItem(S, S2, SortWeight);
00169	}
00170	
00171	function BeforePaint(Canvas C, float X, float Y)
00172	{
00173		Super.BeforePaint(C, X, Y);
00174		LookAndFeel.Combo_SetupSizes(Self, C);
00175		List.bLeaveOnscreen = bListVisible && bLeaveOnscreen;
00176	}
00177	
00178	function CloseUp()
00179	{
00180		bListVisible = False;
00181		EditBox.SetEditable(bCanEdit);
00182		EditBox.SelectAll();
00183		List.HideWindow();
00184	}
00185	
00186	function DropDown()
00187	{
00188		bListVisible = True;
00189		EditBox.SetEditable(False);
00190		List.ShowWindow();
00191	}
00192	
00193	function Sort()
00194	{
00195		List.Sort();
00196	}
00197	
00198	function ClearValue()
00199	{
00200		EditBox.Clear();
00201	}
00202	
00203	function Clear()
00204	{
00205		List.Clear();
00206		EditBox.Clear();
00207	}
00208	
00209	function FocusOtherWindow(UWindowWindow W)
00210	{
00211		Super.FocusOtherWindow(W);
00212	
00213		if(bListVisible && W.ParentWindow != Self && W != List && W.ParentWindow != List)
00214			CloseUp();
00215	}
00216	
00217	defaultproperties
00218	{
00219	     ListClass=Class'UWindow.UWindowComboList'
00220	     bNoKeyboard=True
00221	}

End Source Code