UWindow
Class UWindowWindow

source: e:\games\UnrealTournament\UWindow\Classes\UWindowWindow.uc
Core.Object
   |
   +--UWindow.UWindowBase
      |
      +--UWindow.UWindowWindow
Direct Known Subclasses:UBrowserBannerAd, UBrowserBannerBar, UMenuHelpTextArea, UMenuStatusBar, UMenuToolBar, DemoStoryWindow, DoorArea, MessageWindow, NotifyWindow, StaticArea, UWindowBitmap, UWindowClientWindow, UWindowControlFrame, UWindowDialogControl, UWindowFramedWindow, UWindowGrid, UWindowGridClient, UWindowGridColumn, UWindowHScrollBar, UWindowHSplitter, UWindowMessageBoxArea, UWindowProgressBar, UWindowRootWindow, UWindowTabControlTabArea, UWindowVScrollBar, UWindowVSplitter

class UWindowWindow
extends UWindow.UWindowBase

//============================================================================= // UWindowWindow - the parent class for all Window objects //=============================================================================
Variables
 UWindowWindow ActiveWindow
           The child of ours which is currently active
 float ClickTime
           Does this window accept hotkeys?
 float ClickX
           Does this window accept hotkeys?
 float ClickY
           Does this window accept hotkeys?
 Region ClippingRegion
           Does this window accept hotkeys?
 MouseCursor Cursor
           Does this window accept hotkeys?
 UWindowWindow FirstChildWindow
           First child window - bottom window first
 UWindowWindow LastChildWindow
           Last child window - WinTop window first
 UWindowLookAndFeel LookAndFeel
           Does this window accept hotkeys?
 float MClickTime
           Does this window accept hotkeys?
 float MClickX
           Does this window accept hotkeys?
 float MClickY
           Does this window accept hotkeys?
 UWindowWindow ModalWindow
           Some window we've opened modally.
 UWindowWindow NextSiblingWindow
           sibling window - next window above us
 UWindowWindow OwnerWindow
           Some arbitary owner window
 UWindowWindow ParentWindow
           Parent window
 UWindowWindow PrevSiblingWindow
           previous sibling window - next window below us
 float RClickTime
           Does this window accept hotkeys?
 float RClickX
           Does this window accept hotkeys?
 float RClickY
           Does this window accept hotkeys?
 UWindowRootWindow Root
           The root window
 float WinHeight
 float WinLeft
 float WinTop
 float WinWidth
 bool bAcceptsFocus
           Accepts key messages
 bool bAcceptsHotKeys
           Does this window accept hotkeys?
 bool bAlwaysBehind
           Window doesn't bring to front on click.
 bool bAlwaysOnTop
           Always on top
 bool bIgnoreLDoubleClick
           Does this window accept hotkeys?
 bool bIgnoreMDoubleClick
           Does this window accept hotkeys?
 bool bIgnoreRDoubleClick
           Does this window accept hotkeys?
 bool bLeaveOnscreen
           Window is left onscreen when UWindow isn't active.
 bool bMMouseDown
           Pressed down in this window?
 bool bMouseDown
           Pressed down in this window?
 bool bNoClip
           Clipping disabled for this window?
 bool bRMouseDown
           Pressed down in this window?
 bool bTransient
           Never the active window. Used for combo dropdowns7
 bool bUWindowActive
           Is UWindow active?
 bool bWindowVisible
           Some window we've opened modally.


Function Summary
 void ActivateWindow(int Depth, bool bTransientNoDeactivate)
 void Activated()
 void AfterCreate()
 void AfterPaint(Canvas C, float X, float Y)
 void BeforeCreate()
 void BeforePaint(Canvas C, float X, float Y)
 void BeginPlay()
 void BringToFront()
 void CancelAcceptsFocus()
 UWindowWindow CheckKeyFocusWindow()
 bool CheckMousePassThrough(float X, float Y)
     
// Should mouse events at these co-ordinates be passed through to underlying windows?
 void Click(float X, float Y)
 void ClipText(Canvas C, float X, float Y, string S, optional bool)
 void ClipTextWidth(Canvas C, float X, float Y, string S, float W)
 void Close(optional bool)
 void Created()
 void Deactivated()
 void DoTick(float Delta)
 void DoubleClick(float X, float Y)
 void DrawClippedActor(Canvas C, float X, float Y, Actor A, bool WireFrame, rotator RotOffset, vector LocOffset)
 void DrawClippedTexture(Canvas C, float X, float Y, Texture Tex)
 void DrawHorizTiledPieces(Canvas C, float DestX, float DestY, float DestW, float DestH, TexRegion T1, TexRegion T2, TexRegion T3, TexRegion T4, TexRegion T5, float Scale)
 void DrawMiscBevel(Canvas C, float X, float Y, float W, float H, Texture T, int BevelType)
 void DrawStretchedTexture(Canvas C, float X, float Y, float W, float H, Texture Tex)
 void DrawStretchedTextureSegment(Canvas C, float X, float Y, float W, float H, float tX, float tY, float tW, float tH, Texture Tex)
 void DrawUpBevel(Canvas C, float X, float Y, float W, float H, Texture T)
 void DrawVertTiledPieces(Canvas C, float DestX, float DestY, float DestW, float DestH, TexRegion T1, TexRegion T2, TexRegion T3, TexRegion T4, TexRegion T5, float Scale)
 void EscClose()
 UWindowWindow FindWindowUnder(float X, float Y)
 void FocusOtherWindow(UWindowWindow W)
 void FocusWindow()
 void GetDesiredDimensions(out float, out float)
 LevelInfo GetEntryLevel()
 LevelInfo GetLevel()
 Texture GetLookAndFeelTexture()
 void GetMouseXY(out float, out float)
 PlayerPawn GetPlayerOwner()
 void GlobalToWindow(float GlobalX, float GlobalY, out float, out float)
 void HideChildWindow(UWindowWindow Child)
 void HideWindow()
 bool HotKeyDown(int Key, float X, float Y)
 bool HotKeyUp(int Key, float X, float Y)
 bool IsActive()
 void KeyDown(int Key, float X, float Y)
 void KeyFocusEnter()
 void KeyFocusExit()
 void KeyType(int Key, float X, float Y)
 void KeyUp(int Key, float X, float Y)
 void LMouseDown(float X, float Y)
 void LMouseUp(float X, float Y)
 void MClick(float X, float Y)
 void MDoubleClick(float X, float Y)
 void MMouseDown(float X, float Y)
 void MMouseUp(float X, float Y)
 UWindowMessageBox MessageBox(string Title, string Message, MessageBoxButtons Buttons, MessageBoxResult ESCResult, optional MessageBoxResult, optional int)
 void MessageBoxDone(UWindowMessageBox W, MessageBoxResult Result)
 bool MessageClients(WinMessage Msg, Canvas C, float X, float Y, int Key)
 void MouseEnter()
 bool MouseIsOver()
 void MouseLeave()
 void MouseMove(float X, float Y)
 void NotifyAfterLevelChange()
 void NotifyBeforeLevelChange()
 void NotifyQuitUnreal()
 void Paint(Canvas C, float X, float Y)
 void PaintClients(Canvas C, float X, float Y)
 byte ParseAmpersand(string S, out string, out string, bool bCalcUnderline)
 void ProcessMenuKey(int Key, string KeyName)
 bool PropagateKey(WinMessage Msg, Canvas C, float X, float Y, int Key)
 void RClick(float X, float Y)
 void RDoubleClick(float X, float Y)
 void RMouseDown(float X, float Y)
 void RMouseUp(float X, float Y)
 string RemoveAmpersand(string S)
 void ReplaceText(out string, string Replace, string With)
 void Resized()
 void ResolutionChanged(float W, float H)
 void SaveConfigs()
 void SendToBack()
 void SetAcceptsFocus()
 void SetAcceptsHotKeys(bool bNewAccpetsHotKeys)
 void SetCursor(MouseCursor C)
 void SetMouseWindow()
     
// Sets mouse window for mouse capture.
 void SetParent(UWindowWindow NewParent)
 void SetSize(float W, float H)
 void ShowChildWindow(UWindowWindow Child, optional bool)
 void ShowModal(UWindowWindow W)
 void ShowWindow()
 void StripCRLF(out string)
 void TextSize(Canvas C, string Text, out float, out float)
 void Tick(float Delta)
 void Tile(Canvas C, Texture T)
 void ToolTip(string strTip)
 bool WaitModal()
 void WindowEvent(WinMessage Msg, Canvas C, float X, float Y, int Key)
     
// Ideally Key would be a EInputKey but I can't see that class here.
 void WindowHidden()
 bool WindowIsVisible()
 void WindowShown()
 void WindowToGlobal(float WinX, float WinY, out float, out float)
 int WrapClipText(Canvas C, float X, float Y, string S, optional bool, optional int, optional int, optional bool)



Source Code


00001	//=============================================================================
00002	// UWindowWindow - the parent class for all Window objects
00003	//=============================================================================
00004	class UWindowWindow extends UWindowBase;
00005	
00006	#exec TEXTURE IMPORT NAME=BlackTexture FILE=TEXTURES\Black.PCX
00007	#exec TEXTURE IMPORT NAME=WhiteTexture FILE=TEXTURES\White.PCX
00008	
00009	// Dimensions, offset relative to parent.
00010	var float				WinLeft;
00011	var float				WinTop;
00012	var float				WinWidth;
00013	var float				WinHeight;
00014	
00015	// Relationships to other windows
00016	var UWindowWindow		ParentWindow;			// Parent window
00017	var UWindowWindow		FirstChildWindow;		// First child window - bottom window first
00018	var UWindowWindow		LastChildWindow;		// Last child window - WinTop window first
00019	var UWindowWindow		NextSiblingWindow;		// sibling window - next window above us
00020	var UWindowWindow		PrevSiblingWindow;		// previous sibling window - next window below us
00021	var UWindowWindow		ActiveWindow;			// The child of ours which is currently active
00022	var UWindowRootWindow	Root;					// The root window
00023	var UWindowWindow		OwnerWindow;			// Some arbitary owner window
00024	var UWindowWindow		ModalWindow;			// Some window we've opened modally.
00025	
00026	var bool				bWindowVisible;
00027	var bool				bNoClip;				// Clipping disabled for this window?
00028	var bool				bMouseDown;				// Pressed down in this window?
00029	var bool				bRMouseDown;			// Pressed down in this window?
00030	var bool				bMMouseDown;			// Pressed down in this window?
00031	var bool				bAlwaysBehind;			// Window doesn't bring to front on click.
00032	var bool				bAcceptsFocus;			// Accepts key messages
00033	var bool				bAlwaysOnTop;			// Always on top
00034	var bool				bLeaveOnscreen;			// Window is left onscreen when UWindow isn't active.
00035	var bool				bUWindowActive;			// Is UWindow active?
00036	var bool				bTransient;				// Never the active window. Used for combo dropdowns7
00037	var bool				bAcceptsHotKeys;		// Does this window accept hotkeys?
00038	var bool				bIgnoreLDoubleClick;
00039	var bool				bIgnoreMDoubleClick;
00040	var bool				bIgnoreRDoubleClick;
00041	
00042	var float				ClickTime;
00043	var float				MClickTime;
00044	var float				RClickTime;
00045	var float				ClickX;
00046	var float				ClickY;
00047	var float				MClickX;
00048	var float				MClickY;
00049	var float				RClickX;
00050	var float				RClickY;
00051	
00052	var UWindowLookAndFeel	LookAndFeel;
00053	
00054	var Region	ClippingRegion;
00055	
00056	struct MouseCursor
00057	{
00058		var Texture tex;
00059		var int HotX;
00060		var int HotY;
00061		var byte WindowsCursor;
00062	};
00063	
00064	var MouseCursor Cursor;
00065	
00066	enum WinMessage
00067	{
00068		WM_LMouseDown,
00069		WM_LMouseUp,
00070		WM_MMouseDown,
00071		WM_MMouseUp,
00072		WM_RMouseDown,
00073		WM_RMouseUp,
00074		WM_KeyUp,
00075		WM_KeyDown,
00076		WM_KeyType,
00077		WM_Paint	// Window needs painting
00078	};
00079	
00080	// Dialog messages
00081	const DE_Created = 0;
00082	const DE_Change	 = 1;
00083	const DE_Click	 = 2;
00084	const DE_Enter	 = 3;
00085	const DE_Exit	 = 4;
00086	const DE_MClick	 = 5;
00087	const DE_RClick	 = 6;
00088	const DE_EnterPressed = 7;
00089	const DE_MouseMove = 8;
00090	const DE_MouseLeave = 9;
00091	const DE_LMouseDown = 10;
00092	const DE_DoubleClick = 11;
00093	const DE_MouseEnter = 12;
00094	const DE_HelpChanged = 13;
00095	const DE_WheelUpPressed = 14;
00096	const DE_WheelDownPressed = 15;
00097	
00098	// Ideally Key would be a EInputKey but I can't see that class here.
00099	function WindowEvent(WinMessage Msg, Canvas C, float X, float Y, int Key) 
00100	{
00101		switch(Msg)
00102		{
00103		case WM_Paint:
00104			Paint(C, X, Y);
00105			PaintClients(C, X, Y);
00106			break;
00107		case WM_LMouseDown:
00108			if(!Root.CheckCaptureMouseDown())
00109			{
00110				if(!MessageClients(Msg, C, X, Y, Key)) 
00111					LMouseDown(X, Y);
00112			}
00113			break;	
00114		case WM_LMouseUp:
00115			if(!Root.CheckCaptureMouseUp())
00116			{
00117				if(!MessageClients(Msg, C, X, Y, Key))
00118					LMouseUp(X, Y);
00119			}
00120			break;	
00121		case WM_RMouseDown:
00122			if(!MessageClients(Msg, C, X, Y, Key)) RMouseDown(X, Y);
00123			break;	
00124		case WM_RMouseUp:
00125			if(!MessageClients(Msg, C, X, Y, Key)) RMouseUp(X, Y);
00126			break;	
00127		case WM_MMouseDown:
00128			if(!MessageClients(Msg, C, X, Y, Key)) MMouseDown(X, Y);
00129			break;	
00130		case WM_MMouseUp:
00131			if(!MessageClients(Msg, C, X, Y, Key)) MMouseUp(X, Y);
00132			break;	
00133		case WM_KeyDown:
00134			if(!PropagateKey(Msg, C, X, Y, Key))
00135				KeyDown(Key, X, Y);
00136			break;	
00137		case WM_KeyUp:
00138			if(!PropagateKey(Msg, C, X, Y, Key))
00139				KeyUp(Key, X, Y);
00140			break;	
00141		case WM_KeyType:
00142			if(!PropagateKey(Msg, C, X, Y, Key))
00143				KeyType(Key, X, Y);
00144			break;	
00145		default:
00146			break;
00147		}
00148	}
00149	
00150	function SaveConfigs()
00151	{
00152	
00153		// Implemented in a child class
00154	}
00155	
00156	final function PlayerPawn GetPlayerOwner()
00157	{
00158		return Root.Console.ViewPort.Actor;
00159	}
00160	
00161	final function LevelInfo GetLevel()
00162	{
00163		return Root.Console.ViewPort.Actor.Level;
00164	}
00165	
00166	final function LevelInfo GetEntryLevel()
00167	{
00168		return Root.Console.ViewPort.Actor.GetEntryLevel();
00169	}
00170	
00171	function Resized()
00172	{
00173		// Implemented in a child class
00174	}
00175	
00176	function BeforePaint(Canvas C, float X, float Y)
00177	{
00178		// Implemented in a child class
00179	}
00180	
00181	function AfterPaint(Canvas C, float X, float Y)
00182	{
00183		// Implemented in a child class
00184	}
00185	
00186	function Paint(Canvas C, float X, float Y)
00187	{
00188		// Implemented in a child class
00189	}
00190	
00191	function Click(float X, float Y)
00192	{
00193		// Implemented in a child class
00194	}
00195	
00196	
00197	function MClick(float X, float Y)
00198	{
00199		// Implemented in a child class
00200	}
00201	
00202	function RClick(float X, float Y)
00203	{
00204		// Implemented in a child class
00205	}
00206	
00207	function DoubleClick(float X, float Y)
00208	{
00209		// Implemented in a child class
00210	}
00211	
00212	function MDoubleClick(float X, float Y)
00213	{
00214		// Implemented in a child class
00215	}
00216	
00217	function RDoubleClick(float X, float Y)
00218	{
00219		// Implemented in a child class
00220	}
00221	
00222	function BeginPlay()
00223	{
00224		// Implemented in a child class
00225	}
00226	
00227	function BeforeCreate()
00228	{
00229		// Implemented in a child class
00230	}
00231	
00232	function Created()
00233	{
00234		// Implemented in a child class
00235	}
00236	
00237	function AfterCreate()
00238	{
00239		// Implemented in a child class
00240	}
00241	
00242	function MouseEnter()
00243	{
00244		// Implemented in a child class
00245	}
00246	
00247	function Activated()
00248	{
00249		// Implemented in a child class
00250	}
00251	
00252	function Deactivated()
00253	{
00254		// Implemented in a child class
00255	}
00256	
00257	function MouseLeave()
00258	{
00259		bMouseDown = False;
00260		bMMouseDown = False;
00261		bRMouseDown = False;
00262	}
00263	
00264	function MouseMove(float X, float Y)
00265	{
00266	}
00267	
00268	function KeyUp(int Key, float X, float Y)
00269	{
00270		// Implemented in child class
00271	}
00272	
00273	function KeyDown(int Key, float X, float Y)
00274	{
00275		// Implemented in child class
00276	}
00277	
00278	function bool HotKeyDown(int Key, float X, float Y)
00279	{
00280		// Implemented in child class
00281		//Log("UWindowWindow: Checking HotKeyDown for "$Self);
00282		return False;
00283	}
00284	
00285	function bool HotKeyUp(int Key, float X, float Y)
00286	{
00287		// Implemented in child class
00288		//Log("UWindowWindow: Checking HotKeyUp for "$Self);
00289		return False;
00290	}
00291	
00292	function KeyType(int Key, float X, float Y)
00293	{
00294		// Implemented in child class
00295	}
00296	
00297	function ProcessMenuKey(int Key, string KeyName)
00298	{
00299		// Implemented in child class
00300	}
00301	
00302	function KeyFocusEnter()
00303	{
00304		// Implemented in child class
00305	}
00306	
00307	function KeyFocusExit()
00308	{
00309		// Implemented in child class
00310	}
00311	
00312	
00313	function RMouseDown(float X, float Y) 
00314	{
00315		ActivateWindow(0, False);
00316		bRMouseDown = True;
00317	}
00318	
00319	function RMouseUp(float X, float Y) 
00320	{
00321		if(bRMouseDown)
00322		{
00323			if(!bIgnoreRDoubleClick && Abs(X-RClickX) <= 1 && Abs(Y-RClickY) <= 1 && GetLevel().TimeSeconds < RClickTime + 0.600)
00324			{
00325				RDoubleClick(X, Y);
00326				RClickTime = 0;
00327			}
00328			else
00329			{
00330				RClickTime = GetLevel().TimeSeconds;
00331				RClickX = X;
00332				RClickY = Y;
00333				RClick(X, Y);
00334			}
00335		}
00336		bRMouseDown = False;
00337	
00338	}
00339	
00340	function MMouseDown(float X, float Y) 
00341	{
00342		ActivateWindow(0, False);
00343		/* DEBUG
00344		HideWindow();
00345		*/
00346		bMMouseDown = True;
00347	}
00348	
00349	function MMouseUp(float X, float Y) 
00350	{
00351		if(bMMouseDown)
00352		{
00353			if(!bIgnoreMDoubleClick && Abs(X-MClickX) <= 1 && (Y-MClickY)<=1 && GetLevel().TimeSeconds < MClickTime + 0.600)
00354			{
00355				MDoubleClick(X, Y);
00356				MClickTime = 0;
00357			}
00358			else
00359			{
00360				MClickTime = GetLevel().TimeSeconds;
00361				MClickX = X;
00362				MClickY = Y;
00363				MClick(X, Y);
00364			}
00365		}
00366		bMMouseDown = False;
00367	}
00368	
00369	
00370	function LMouseDown(float X, float Y)
00371	{
00372		ActivateWindow(0, False);
00373		bMouseDown = True;
00374	}
00375	
00376	function LMouseUp(float X, float Y)
00377	{
00378		if(bMouseDown)
00379		{
00380			if(!bIgnoreLDoubleClick && Abs(X-ClickX) <= 1 && (Y-ClickY) <= 1 && GetLevel().TimeSeconds < ClickTime + 0.600)
00381			{
00382				DoubleClick(X, Y);
00383				ClickTime = 0;
00384			}
00385			else
00386			{
00387				ClickTime = GetLevel().TimeSeconds;
00388				ClickX = X;
00389				ClickY = Y;
00390				Click(X, Y);
00391			}
00392		}
00393		bMouseDown = False;
00394	}
00395	
00396	function FocusWindow()
00397	{
00398		if(Root.FocusedWindow != None && Root.FocusedWindow != Self)
00399			Root.FocusedWindow.FocusOtherWindow(Self);
00400	
00401		Root.FocusedWindow = Self;
00402	}
00403	
00404	function FocusOtherWindow(UWindowWindow W)
00405	{
00406	}
00407	
00408	function EscClose()
00409	{
00410		Close();
00411	}
00412	
00413	function Close(optional bool bByParent)
00414	{
00415		local UWindowWindow Prev, Child;
00416	
00417		for(Child = LastChildWindow;Child != None;Child = Prev)
00418		{
00419			Prev = Child.PrevSiblingWindow;
00420			Child.Close(True);
00421		}
00422		SaveConfigs();
00423		if(!bByParent)
00424			HideWindow();
00425	}
00426	
00427	final function SetSize(float W, float H)
00428	{
00429		if(WinWidth != W || WinHeight != H)
00430		{
00431			WinWidth = W;
00432			WinHeight = H;
00433			Resized();
00434		}
00435	}
00436	
00437	function Tick(float Delta)
00438	{
00439	}
00440	
00441	final function DoTick(float Delta)
00442	{
00443		local UWindowWindow Child;
00444	
00445		Tick(Delta);
00446	
00447		Child = FirstChildWindow;
00448	
00449		while(Child != None)
00450		{
00451			Child.bUWindowActive = bUWindowActive;
00452	
00453			if(bLeaveOnScreen)
00454				Child.bLeaveOnscreen = True;
00455	
00456			if(bUWindowActive || Child.bLeaveOnscreen)
00457			{
00458				Child.DoTick(Delta);
00459			}
00460	
00461			Child = Child.NextSiblingWindow;
00462		}
00463	}
00464	
00465	final function PaintClients(Canvas C, float X, float Y)
00466	{
00467		local float   OrgX, OrgY;   
00468		local float   ClipX, ClipY; 
00469		local UWindowWindow Child;
00470	
00471		OrgX = C.OrgX;
00472		OrgY = C.OrgY;
00473		ClipX = C.ClipX;
00474		ClipY = C.ClipY;
00475	
00476		Child = FirstChildWindow;
00477	
00478		while(Child != None)
00479		{
00480			Child.bUWindowActive = bUWindowActive;
00481	
00482			C.SetPos(0,0);
00483			C.Style = GetPlayerOwner().ERenderStyle.STY_Normal;
00484			C.DrawColor.R = 255;
00485			C.DrawColor.G = 255;
00486			C.DrawColor.B = 255;
00487			C.SpaceX = 0;
00488			C.SpaceY = 0;
00489	
00490			Child.BeforePaint(C, X - Child.WinLeft, Y - Child.WinTop);
00491	
00492			if(bLeaveOnScreen)
00493				Child.bLeaveOnscreen = True;
00494	
00495			if(bUWindowActive || Child.bLeaveOnscreen)
00496			{
00497	
00498				C.OrgX = C.OrgX + Child.WinLeft*Root.GUIScale;
00499				C.OrgY = C.OrgY + Child.WinTop*Root.GUIScale;
00500	
00501				if(!Child.bNoClip)
00502				{
00503					C.ClipX = FMin(WinWidth - Child.WinLeft, Child.WinWidth)*Root.GUIScale;
00504					C.ClipY = FMin(WinHeight - Child.WinTop, Child.WinHeight)*Root.GUIScale;
00505	
00506	
00507					// Translate to child's co-ordinate system
00508					Child.ClippingRegion.X = ClippingRegion.X - Child.WinLeft;
00509					Child.ClippingRegion.Y = ClippingRegion.Y - Child.WinTop;
00510					Child.ClippingRegion.W = ClippingRegion.W;
00511					Child.ClippingRegion.H = ClippingRegion.H;
00512	
00513					if(Child.ClippingRegion.X < 0)
00514					{
00515						Child.ClippingRegion.W += Child.ClippingRegion.X;
00516						Child.ClippingRegion.X = 0;
00517					}
00518	
00519					if(Child.ClippingRegion.Y < 0)
00520					{
00521						Child.ClippingRegion.H += Child.ClippingRegion.Y;
00522						Child.ClippingRegion.Y = 0;
00523					}
00524	
00525					if(Child.ClippingRegion.W > Child.WinWidth - Child.ClippingRegion.X)
00526					{
00527						Child.ClippingRegion.W = Child.WinWidth - Child.ClippingRegion.X;
00528					}
00529	
00530					if(Child.ClippingRegion.H > Child.WinHeight - Child.ClippingRegion.Y)
00531					{
00532						Child.ClippingRegion.H = Child.WinHeight - Child.ClippingRegion.Y;
00533					}
00534				}
00535	
00536				if(Child.ClippingRegion.W > 0 && Child.ClippingRegion.H > 0) 
00537				{		
00538					Child.WindowEvent(WM_Paint, C, X - Child.WinLeft, Y - Child.WinTop, 0);
00539					Child.AfterPaint(C, X - Child.WinLeft, Y - Child.WinTop);
00540				}
00541		
00542				C.OrgX = OrgX;
00543				C.OrgY = OrgY;
00544			}
00545	
00546			Child = Child.NextSiblingWindow;
00547		}
00548	
00549		C.ClipX = ClipX;
00550		C.ClipY = ClipY;
00551	}
00552	
00553	final function UWindowWindow FindWindowUnder(float X, float Y)
00554	{
00555		local UWindowWindow Child;
00556	
00557		// go from Topmost downwards
00558		Child = LastChildWindow;
00559	
00560		while(Child != None)
00561		{
00562			Child.bUWindowActive = bUWindowActive;
00563	
00564			if(bLeaveOnScreen)
00565				Child.bLeaveOnscreen = True;
00566	
00567			if(bUWindowActive || Child.bLeaveOnscreen)
00568			{
00569				if((X >= Child.WinLeft) && (X <= Child.WinLeft+Child.WinWidth) &&
00570				   (Y >= Child.WinTop) && (Y <= Child.WinTop+Child.WinHeight) &&
00571				   (!Child.CheckMousePassThrough(X-Child.WinLeft, Y-Child.WinTop)))
00572				{
00573					return Child.FindWindowUnder(X - Child.WinLeft, Y - Child.WinTop);
00574				}
00575			}
00576		
00577			Child = Child.PrevSiblingWindow;
00578		}
00579	
00580		// Doesn't correspond to any children - it's us.
00581		return Self;
00582	}
00583	
00584	final function bool PropagateKey(WinMessage Msg, Canvas C, float X, float Y, int Key)
00585	{
00586		local UWindowWindow Child;
00587	
00588		// Check from WinTopmost for windows which accept focus
00589		Child = LastChildWindow;
00590	
00591		// HACK for always on top windows...need a better solution
00592		if(ActiveWindow != None && Child != ActiveWindow && !Child.bTransient)
00593			Child = ActiveWindow;
00594	
00595		while(Child != None)
00596		{
00597			Child.bUWindowActive = bUWindowActive;
00598	
00599			if(bLeaveOnScreen)
00600				Child.bLeaveOnscreen = True;
00601	
00602			if((bUWindowActive || Child.bLeaveOnscreen) && Child.bAcceptsFocus)
00603			{
00604				//Log("Sending keystrokes to:  "$Child);
00605				Child.WindowEvent(Msg, C, X - Child.WinLeft, Y - Child.WinTop, Key);
00606				return True;		
00607			}
00608			//else
00609				//Log("Ignoring child:  "$Child);
00610			Child = Child.PrevSiblingWindow;
00611		}
00612	
00613		return False;
00614	}
00615	
00616	final function UWindowWindow CheckKeyFocusWindow()
00617	{
00618		local UWindowWindow Child;
00619	
00620		// Check from WinTopmost for windows which accept key focus
00621		Child = LastChildWindow;
00622	
00623		if(ActiveWindow != None && Child != ActiveWindow && !Child.bTransient)
00624			Child = ActiveWindow;
00625	
00626		while(Child != None)
00627		{
00628			Child.bUWindowActive = bUWindowActive;
00629	
00630			if(bLeaveOnScreen)
00631				Child.bLeaveOnscreen = True;
00632	
00633			if(bUWindowActive || Child.bLeaveOnscreen)
00634			{
00635				if(Child.bAcceptsFocus)
00636				{
00637					return Child.CheckKeyFocusWindow();
00638				}
00639			}
00640			Child = Child.PrevSiblingWindow;
00641		}
00642	
00643		return Self;
00644	}
00645	
00646	final function bool MessageClients(WinMessage Msg, Canvas C, float X, float Y, int Key)
00647	{
00648		local UWindowWindow Child;
00649	
00650		// go from topmost downwards
00651		Child = LastChildWindow;
00652	
00653		while(Child != None)
00654		{
00655			Child.bUWindowActive = bUWindowActive;
00656	
00657			if(bLeaveOnScreen)
00658				Child.bLeaveOnscreen = True;
00659	
00660			if(bUWindowActive || Child.bLeaveOnscreen)
00661			{
00662				if((X >= Child.WinLeft) && (X <= Child.WinLeft+Child.WinWidth) &&
00663				   (Y >= Child.WinTop) && (Y <= Child.WinTop+Child.WinHeight)  &&
00664				   (!Child.CheckMousePassThrough(X-Child.WinLeft, Y-Child.WinTop))) 
00665				{
00666					Child.WindowEvent(Msg, C, X - Child.WinLeft, Y - Child.WinTop, Key);
00667					return True;
00668				}
00669			}
00670		
00671			Child = Child.PrevSiblingWindow;
00672		}
00673	
00674		return False;
00675	}
00676	
00677	final function ActivateWindow(int Depth, bool bTransientNoDeactivate)
00678	{
00679		if(Self == Root)
00680		{
00681			if(Depth == 0)
00682				FocusWindow();
00683			return;
00684		}
00685	
00686		if(WaitModal()) return;
00687	
00688		if(!bAlwaysBehind)
00689		{
00690			ParentWindow.HideChildWindow(Self);
00691			ParentWindow.ShowChildWindow(Self);
00692		}
00693		
00694		//Log("Activating Window "$Self);
00695		
00696		if(!(bTransient || bTransientNoDeactivate))
00697		{
00698			if(ParentWindow.ActiveWindow != None && ParentWindow.ActiveWindow != Self)
00699			{
00700				ParentWindow.ActiveWindow.Deactivated();
00701			}
00702	
00703			ParentWindow.ActiveWindow = Self;
00704			ParentWindow.ActivateWindow(Depth + 1, False);
00705	
00706			Activated();
00707		}
00708		else
00709		{
00710			ParentWindow.ActivateWindow(Depth + 1, True);
00711		}
00712	
00713		if(Depth == 0)
00714			FocusWindow();
00715	}
00716	
00717	final function BringToFront()
00718	{
00719		if(Self == Root)
00720			return;
00721	
00722		if(!bAlwaysBehind && !WaitModal())
00723		{
00724			ParentWindow.HideChildWindow(Self);
00725			ParentWindow.ShowChildWindow(Self);
00726		}
00727		ParentWindow.BringToFront();
00728	}
00729	
00730	final function SendToBack()
00731	{
00732		ParentWindow.HideChildWindow(Self);
00733		ParentWindow.ShowChildWindow(Self, True);
00734	}
00735	
00736	final function HideChildWindow(UWindowWindow Child)
00737	{
00738		local UWindowWindow Window;
00739	
00740		if(!Child.bWindowVisible) return;
00741		Child.bWindowVisible = False;
00742	
00743		if(Child.bAcceptsHotKeys)
00744			Root.RemoveHotkeyWindow(Child);
00745	
00746		// Check WinTopmost
00747		if(LastChildWindow == Child) 
00748		{
00749			LastChildWindow = Child.PrevSiblingWindow;
00750			if(LastChildWindow != None)
00751			{
00752				LastChildWindow.NextSiblingWindow = None;
00753			}
00754			else
00755			{
00756				FirstChildWindow = None;
00757			}
00758		} 
00759		else if(FirstChildWindow == Child) // Check bottommost
00760		{ 
00761			FirstChildWindow = Child.NextSiblingWindow;
00762			if(FirstChildWindow != None)
00763			{
00764				FirstChildWindow.PrevSiblingWindow = None;
00765			}
00766			else
00767			{
00768				LastChildWindow = None;
00769			}
00770		} 
00771		else 
00772		{
00773			// you mean I have to go looking for it???
00774			Window = FirstChildWindow;
00775			while(Window != None)
00776			{
00777				if(Window.NextSiblingWindow == Child)
00778				{
00779					Window.NextSiblingWindow = Child.NextSiblingWindow;
00780					Window.NextSiblingWindow.PrevSiblingWindow = Window;
00781					break;
00782				}
00783				Window = Window.NextSiblingWindow;
00784			}
00785		}
00786	
00787		// Set the active window
00788		ActiveWindow = None;
00789		Window = LastChildWindow;
00790		while(Window != None)
00791		{
00792			if(!Window.bAlwaysOnTop)
00793			{
00794				ActiveWindow = Window;
00795				break;
00796			}
00797			Window = Window.PrevSiblingWindow;
00798		}
00799		if(ActiveWindow == None) ActiveWindow = LastChildWindow;
00800	}
00801	
00802	final function SetAcceptsFocus()
00803	{
00804		if(bAcceptsFocus) return;
00805		bAcceptsFocus = True;
00806	
00807		if(Self != Root)
00808			ParentWindow.SetAcceptsFocus();
00809	}
00810	
00811	final function CancelAcceptsFocus()
00812	{
00813		local UWindowWindow Child;
00814	
00815		for(Child = LastChildWindow; Child != None; Child = Child.PrevSiblingWindow)
00816			Child.CancelAcceptsFocus();
00817	
00818		bAcceptsFocus = False;
00819	}
00820	
00821	final function GetMouseXY(out float X, out float Y)
00822	{
00823		local UWindowWindow P;
00824	
00825		X = Int(Root.MouseX);
00826		Y = Int(Root.MouseY);
00827		
00828		P = Self;
00829		while(P != Root)
00830		{		
00831			X = X - P.WinLeft;
00832			Y = Y - P.WinTop;
00833			P = P.ParentWindow;
00834		}
00835	}
00836	
00837	final function GlobalToWindow(float GlobalX, float GlobalY, out float WinX, out float WinY)
00838	{
00839		local UWindowWindow P;
00840	
00841		WinX = GlobalX;
00842		WinY = GlobalY;
00843	
00844		P = Self;
00845		while(P != Root)
00846		{		
00847			WinX -= P.WinLeft;
00848			WinY -= P.WinTop;
00849			P = P.ParentWindow;
00850		}
00851	}
00852	
00853	final function WindowToGlobal(float WinX, float WinY, out float GlobalX, out float GlobalY)
00854	{
00855		local UWindowWindow P;
00856	
00857		GlobalX = WinX;
00858		GlobalY = WinY;
00859	
00860		P = Self;
00861		while(P != Root)
00862		{		
00863			GlobalX += P.WinLeft;
00864			GlobalY += P.WinTop;
00865			P = P.ParentWindow;
00866		}
00867	}
00868	
00869	final function ShowChildWindow(UWindowWindow Child, optional bool bAtBack)
00870	{
00871		local UWindowWindow W;
00872		
00873		if(!Child.bTransient) ActiveWindow = Child;
00874	
00875		if(Child.bWindowVisible) return;
00876		Child.bWindowVisible = True;
00877	
00878		if(Child.bAcceptsHotKeys)
00879			Root.AddHotkeyWindow(Child);
00880	
00881		if(bAtBack)
00882		{
00883			if(FirstChildWindow == None)
00884			{
00885				Child.NextSiblingWindow = None;
00886				Child.PrevSiblingWindow = None;
00887				LastChildWindow = Child;
00888				FirstChildWindow = Child;
00889			}
00890			else
00891			{
00892				FirstChildWindow.PrevSiblingWindow = Child;
00893				Child.NextSiblingWindow = FirstChildWindow;
00894				Child.PrevSiblingWindow = None;
00895				FirstChildWindow = Child;
00896			}
00897		}
00898		else
00899		{
00900			W = LastChildWindow;
00901			while(True) 
00902			{
00903				if((Child.bAlwaysOnTop) || (W == None) || (!W.bAlwaysOnTop))
00904				{
00905					if(W == None)
00906					{	
00907						if(LastChildWindow == None)
00908						{
00909							// We're the only window
00910							Child.NextSiblingWindow = None;
00911							Child.PrevSiblingWindow = None;
00912							LastChildWindow = Child;
00913							FirstChildWindow = Child;
00914						}
00915						else
00916						{
00917							// We feel off the end of the list, we're the bottom (first) child window.
00918							Child.NextSiblingWindow = FirstChildWindow;
00919							Child.PrevSiblingWindow = None;
00920							FirstChildWindow.PrevSiblingWindow = Child;
00921							FirstChildWindow = Child;
00922						}
00923					}
00924					else
00925					{
00926						// We're either the new topmost (last) or we need to be inserted in the list.
00927	
00928						Child.NextSiblingWindow = W.NextSiblingWindow;
00929						Child.PrevSiblingWindow = W;
00930						if(W.NextSiblingWindow != None)
00931						{
00932							W.NextSiblingWindow.PrevSiblingWindow = Child;
00933						}
00934						else
00935						{
00936							LastChildWindow = Child;
00937						}
00938						W.NextSiblingWindow = Child;
00939					}
00940					
00941					// We're done.
00942					break;
00943				}
00944				
00945				W = W.PrevSiblingWindow;
00946			}
00947		}
00948	}
00949	
00950	function ShowWindow()
00951	{
00952		ParentWindow.ShowChildWindow(Self);
00953		WindowShown();
00954	}
00955	
00956	function HideWindow()
00957	{
00958		WindowHidden();
00959		ParentWindow.HideChildWindow(Self);
00960	}
00961	
00962	final function UWindowWindow CreateWindow(class<UWindowWindow> WndClass, float X, float Y, float W, float H, optional UWindowWindow OwnerW, optional bool bUnique, optional name ObjectName)
00963	{
00964		local UWindowWindow Child;
00965	
00966		if(bUnique)
00967		{
00968			Child = Root.FindChildWindow(WndClass, True);
00969	
00970			if(Child != None)
00971			{
00972				Child.ShowWindow();
00973				Child.BringToFront();
00974				return Child;
00975			}
00976		}
00977	
00978		if(ObjectName != '')
00979			Child = New(None, ObjectName) WndClass;
00980		else
00981			Child = New(None) WndClass;
00982	
00983		Child.BeginPlay();
00984		Child.WinTop = Y;
00985		Child.WinLeft = X;
00986		Child.WinWidth = W;
00987		Child.WinHeight = H;
00988		Child.Root = Root;
00989		Child.ParentWindow = Self;
00990		Child.OwnerWindow = OwnerW;
00991		if(Child.OwnerWindow == None)
00992			Child.OwnerWindow = Self;
00993		Child.Cursor = Cursor;
00994		Child.bAlwaysBehind = False;
00995		Child.LookAndFeel = LookAndFeel;
00996		Child.BeforeCreate();
00997		Child.Created();
00998	
00999		// Now add it at the WinTop of the Z-Order and then adjust child list.
01000		ShowChildWindow(Child);
01001	
01002		Child.AfterCreate();
01003	
01004		return Child;
01005	}
01006	
01007	final function Tile(Canvas C, Texture T)
01008	{
01009		local int X, Y;
01010	
01011		X = 0;
01012		Y = 0;
01013	
01014		While(X < WinWidth)
01015		{
01016			While(Y < WinHeight)
01017			{
01018				DrawClippedTexture( C, X, Y, T );
01019				Y += T.VSize;
01020			}
01021			X += T.USize;
01022			Y = 0;
01023		}
01024	}
01025	
01026	final function DrawHorizTiledPieces( Canvas C, float DestX, float DestY, float DestW, float DestH, TexRegion T1, TexRegion T2, TexRegion T3, TexRegion T4, TexRegion T5, float Scale )
01027	{
01028		local TexRegion Pieces[5], R;
01029		local int PieceCount;
01030		local int j;
01031		local float X, L;
01032	
01033		Pieces[0] = T1; if(T1.T != None) PieceCount = 1;
01034		Pieces[1] = T2; if(T2.T != None) PieceCount = 2;
01035		Pieces[2] = T3; if(T3.T != None) PieceCount = 3;
01036		Pieces[3] = T4; if(T4.T != None) PieceCount = 4;
01037		Pieces[4] = T5; if(T5.T != None) PieceCount = 5;
01038	
01039		j = 0;
01040		X = DestX;
01041		while( X < DestX + DestW )
01042		{
01043			L = DestW - (X - DestX);
01044			R = Pieces[j];
01045			DrawStretchedTextureSegment( C, X, DestY, FMin(R.W*Scale, L), R.H*Scale, R.X, R.Y, FMin(R.W, L/Scale), R.H, R.T );
01046			X += FMin(R.W*Scale, L);
01047			j = (j+1)%PieceCount;
01048		}
01049	}
01050	
01051	final function DrawVertTiledPieces( Canvas C, float DestX, float DestY, float DestW, float DestH, TexRegion T1, TexRegion T2, TexRegion T3, TexRegion T4, TexRegion T5, float Scale )
01052	{
01053		local TexRegion Pieces[5], R;
01054		local int PieceCount;
01055		local int j;
01056		local float Y, L;
01057	
01058		Pieces[0] = T1; if(T1.T != None) PieceCount = 1;
01059		Pieces[1] = T2; if(T2.T != None) PieceCount = 2;
01060		Pieces[2] = T3; if(T3.T != None) PieceCount = 3;
01061		Pieces[3] = T4; if(T4.T != None) PieceCount = 4;
01062		Pieces[4] = T5; if(T5.T != None) PieceCount = 5;
01063	
01064		j = 0;
01065		Y = DestY;
01066		while( Y < DestY + DestH )
01067		{
01068			L = DestH - (Y - DestY);
01069			R = Pieces[j];
01070			DrawStretchedTextureSegment( C, DestX, Y, R.W*Scale, FMin(R.H*Scale, L), R.X, R.Y, R.W, FMin(R.H, L/Scale), R.T );
01071			Y += FMin(R.H*Scale, L);
01072			j = (j+1)%PieceCount;
01073		}
01074	}
01075	
01076	
01077	final function DrawClippedTexture( Canvas C, float X, float Y, texture Tex )
01078	{
01079		DrawStretchedTextureSegment( C, X, Y, Tex.USize, Tex.VSize, 0, 0, Tex.USize, Tex.VSize, Tex);
01080	}
01081	
01082	final function DrawStretchedTexture( Canvas C, float X, float Y, float W, float H, texture Tex )
01083	{
01084		DrawStretchedTextureSegment( C, X, Y, W, H, 0, 0, Tex.USize, Tex.VSize, Tex);
01085	}
01086	
01087	final function DrawStretchedTextureSegment( Canvas C, float X, float Y, float W, float H, 
01088										  float tX, float tY, float tW, float tH, texture Tex ) 
01089	{
01090		local float OrgX, OrgY, ClipX, ClipY;
01091	
01092		OrgX = C.OrgX;
01093		OrgY = C.OrgY;
01094		ClipX = C.ClipX;
01095		ClipY = C.ClipY;
01096	
01097		C.SetOrigin(OrgX + ClippingRegion.X*Root.GUIScale, OrgY + ClippingRegion.Y*Root.GUIScale);
01098		C.SetClip(ClippingRegion.W*Root.GUIScale, ClippingRegion.H*Root.GUIScale);
01099	
01100		C.SetPos((X - ClippingRegion.X)*Root.GUIScale, (Y - ClippingRegion.Y)*Root.GUIScale);
01101		C.DrawTileClipped( Tex, W*Root.GUIScale, H*Root.GUIScale, tX, tY, tW, tH);
01102		
01103		C.SetClip(ClipX, ClipY);
01104		C.SetOrigin(OrgX, OrgY);
01105	}
01106	
01107	final function ClipText(Canvas C, float X, float Y, coerce string S, optional bool bCheckHotkey)
01108	{
01109		local float OrgX, OrgY, ClipX, ClipY;
01110	
01111		OrgX = C.OrgX;
01112		OrgY = C.OrgY;
01113		ClipX = C.ClipX;
01114		ClipY = C.ClipY;
01115	
01116		C.SetOrigin(OrgX + ClippingRegion.X*Root.GUIScale, OrgY + ClippingRegion.Y*Root.GUIScale);
01117		C.SetClip(ClippingRegion.W*Root.GUIScale, ClippingRegion.H*Root.GUIScale);
01118	
01119		C.SetPos((X - ClippingRegion.X)*Root.GUIScale, (Y - ClippingRegion.Y)*Root.GUIScale);
01120		C.DrawTextClipped(S, bCheckHotKey);
01121	
01122		C.SetClip(ClipX, ClipY);
01123		C.SetOrigin(OrgX, OrgY);
01124	}
01125	
01126	final function int WrapClipText(Canvas C, float X, float Y, coerce string S, optional bool bCheckHotkey, optional int Length, optional int PaddingLength, optional bool bNoDraw)
01127	{
01128		local float W, H;
01129		local int SpacePos, CRPos, WordPos, TotalPos;
01130		local string Out, Temp, Padding;
01131		local bool bCR, bSentry;
01132		local int i;
01133		local int NumLines;
01134		local float pW, pH;
01135	
01136		// replace \\n's with Chr(13)'s
01137		i = InStr(S, "\\n");
01138		while(i != -1)
01139		{
01140			S = Left(S, i) $ Chr(13) $ Mid(S, i + 2);
01141			i = InStr(S, "\\n");
01142		}
01143	
01144		i = 0;
01145		bSentry = True;
01146		Out = "";
01147		NumLines = 1;
01148		while( bSentry && Y < WinHeight )
01149		{
01150			// Get the line to be drawn.
01151			if(Out == "")
01152			{
01153				i++;
01154				if (Length > 0)
01155					Out = Left(S, Length);
01156				else
01157					Out = S;
01158			}
01159	
01160			// Find the word boundary.
01161			SpacePos = InStr(Out, " ");
01162			CRPos = InStr(Out, Chr(13));
01163			
01164			bCR = False;
01165			if(CRPos != -1 && (CRPos < SpacePos || SpacePos == -1))
01166			{
01167				WordPos = CRPos;
01168				bCR = True;
01169			}
01170			else
01171			{
01172				WordPos = SpacePos;
01173			}
01174			
01175			// Get the current word.
01176			C.SetPos(0, 0);
01177			if(WordPos == -1)
01178				Temp = Out;
01179			else
01180				Temp = Left(Out, WordPos)$" ";
01181			TotalPos += WordPos;
01182	
01183			TextSize(C, Temp, W, H);
01184	
01185			// Calculate draw offset.
01186			if ( (Mid(Out, Len(Temp)) == "") && (PaddingLength > 0) )
01187			{
01188				Padding = Mid(S, Length, PaddingLength);
01189				TextSize(C, Padding, pW, pH);
01190				if(W + X + pW > WinWidth && X > 0)
01191				{
01192					X = 0;
01193					Y += H;
01194					NumLines++;
01195				}
01196			}
01197			else
01198			{
01199				if(W + X > WinWidth && X > 0)
01200				{
01201					X = 0;
01202					Y += H;
01203					NumLines++;
01204				}
01205			}
01206	
01207			// Draw the line.
01208			if(!bNoDraw)
01209				ClipText(C, X, Y, Temp, bCheckHotKey);
01210	
01211			// Increment the draw offset.
01212			X += W;
01213			if(bCR)
01214			{
01215				X =0;
01216				Y += H;
01217				NumLines++;
01218			}
01219			Out = Mid(Out, Len(Temp));
01220			if ((Out == "") && (i > 0))
01221				bSentry = False;
01222		}
01223		return NumLines;
01224	}
01225	
01226	final function ClipTextWidth(Canvas C, float X, float Y, coerce string S, float W)
01227	{
01228		ClipText(C, X, Y, S);
01229	}
01230	
01231	final function DrawClippedActor( Canvas C, float X, float Y, Actor A, bool WireFrame, rotator RotOffset, vector LocOffset )
01232	{
01233		local vector MeshLoc;
01234		local float FOV;
01235	
01236		FOV = GetPlayerOwner().FOVAngle * Pi / 180;
01237		
01238		MeshLoc.X = 4 / tan(FOV/2);
01239		MeshLoc.Y = 0;
01240		MeshLoc.Z = 0;
01241	
01242		A.SetRotation(RotOffset);
01243		A.SetLocation(MeshLoc + LocOffset);
01244	
01245		C.DrawClippedActor(A, WireFrame, ClippingRegion.W * Root.GUIScale, ClippingRegion.H * Root.GUIScale, C.OrgX + ClippingRegion.X * Root.GUIScale, C.OrgY + ClippingRegion.Y * Root.GUIScale, True);
01246	}
01247	
01248	final function DrawUpBevel( Canvas C, float X, float Y, float W, float H, Texture T)
01249	{
01250		local Region R;
01251	
01252		R = LookAndFeel.BevelUpTL;
01253		DrawStretchedTextureSegment( C, X, Y, R.W, R.H, R.X, R.Y, R.W, R.H, T );
01254	
01255		R = LookAndFeel.BevelUpT;
01256		DrawStretchedTextureSegment( C, X+LookAndFeel.BevelUpTL.W, Y, 
01257										W - LookAndFeel.BevelUpTL.W
01258										- LookAndFeel.BevelUpTR.W,
01259										R.H, R.X, R.Y, R.W, R.H, T );
01260	
01261		R = LookAndFeel.BevelUpTR;
01262		DrawStretchedTextureSegment( C, X + W - R.W, Y, R.W, R.H, R.X, R.Y, R.W, R.H, T );
01263		
01264		R = LookAndFeel.BevelUpL;
01265		DrawStretchedTextureSegment( C, X, Y + LookAndFeel.BevelUpTL.H,
01266										R.W,  
01267										H - LookAndFeel.BevelUpTL.H
01268										- LookAndFeel.BevelUpBL.H,
01269										R.X, R.Y, R.W, R.H, T );
01270	
01271		R = LookAndFeel.BevelUpR;
01272		DrawStretchedTextureSegment( C, X + W - R.W, Y + LookAndFeel.BevelUpTL.H,
01273										R.W,  
01274										H - LookAndFeel.BevelUpTL.H
01275										- LookAndFeel.BevelUpBL.H,
01276										R.X, R.Y, R.W, R.H, T );
01277	
01278		
01279		R = LookAndFeel.BevelUpBL;
01280		DrawStretchedTextureSegment( C, X, Y + H - R.H, R.W, R.H, R.X, R.Y, R.W, R.H, T );
01281	
01282		R = LookAndFeel.BevelUpB;
01283		DrawStretchedTextureSegment( C, X + LookAndFeel.BevelUpBL.W, Y + H - R.H, 
01284										W - LookAndFeel.BevelUpBL.W
01285										- LookAndFeel.BevelUpBR.W,
01286										R.H, R.X, R.Y, R.W, R.H, T );
01287	
01288		R = LookAndFeel.BevelUpBR;
01289		DrawStretchedTextureSegment( C, X + W - R.W, Y + H - R.H, R.W, R.H, R.X, R.Y, 
01290										R.W, R.H, T );
01291	
01292		R = LookAndFeel.BevelUpArea;
01293		DrawStretchedTextureSegment( C, X + LookAndFeel.BevelUpTL.W,
01294		                                Y + LookAndFeel.BevelUpTL.H,
01295										W - LookAndFeel.BevelUpBL.W
01296										- LookAndFeel.BevelUpBR.W,
01297										H - LookAndFeel.BevelUpTL.H
01298										- LookAndFeel.BevelUpBL.H,
01299										R.X, R.Y, R.W, R.H, T );
01300		
01301	}
01302	
01303	final function DrawMiscBevel( Canvas C, float X, float Y, float W, float H, Texture T, int BevelType)
01304	{
01305		local Region R;
01306	
01307		R = LookAndFeel.MiscBevelTL[BevelType];
01308		DrawStretchedTextureSegment( C, X, Y, R.W, R.H, R.X, R.Y, R.W, R.H, T );
01309	
01310		R = LookAndFeel.MiscBevelT[BevelType];
01311		DrawStretchedTextureSegment( C, X+LookAndFeel.MiscBevelTL[BevelType].W, Y, 
01312										W - LookAndFeel.MiscBevelTL[BevelType].W
01313										- LookAndFeel.MiscBevelTR[BevelType].W,
01314										R.H, R.X, R.Y, R.W, R.H, T );
01315	
01316		R = LookAndFeel.MiscBevelTR[BevelType];
01317		DrawStretchedTextureSegment( C, X + W - R.W, Y, R.W, R.H, R.X, R.Y, R.W, R.H, T );
01318		
01319		R = LookAndFeel.MiscBevelL[BevelType];
01320		DrawStretchedTextureSegment( C, X, Y + LookAndFeel.MiscBevelTL[BevelType].H,
01321										R.W,  
01322										H - LookAndFeel.MiscBevelTL[BevelType].H
01323										- LookAndFeel.MiscBevelBL[BevelType].H,
01324										R.X, R.Y, R.W, R.H, T );
01325	
01326		R = LookAndFeel.MiscBevelR[BevelType];
01327		DrawStretchedTextureSegment( C, X + W - R.W, Y + LookAndFeel.MiscBevelTL[BevelType].H,
01328										R.W,  
01329										H - LookAndFeel.MiscBevelTL[BevelType].H
01330										- LookAndFeel.MiscBevelBL[BevelType].H,
01331										R.X, R.Y, R.W, R.H, T );
01332	
01333		
01334		R = LookAndFeel.MiscBevelBL[BevelType];
01335		DrawStretchedTextureSegment( C, X, Y + H - R.H, R.W, R.H, R.X, R.Y, R.W, R.H, T );
01336	
01337		R = LookAndFeel.MiscBevelB[BevelType];
01338		DrawStretchedTextureSegment( C, X + LookAndFeel.MiscBevelBL[BevelType].W, Y + H - R.H, 
01339										W - LookAndFeel.MiscBevelBL[BevelType].W
01340										- LookAndFeel.MiscBevelBR[BevelType].W,
01341										R.H, R.X, R.Y, R.W, R.H, T );
01342	
01343		R = LookAndFeel.MiscBevelBR[BevelType];
01344		DrawStretchedTextureSegment( C, X + W - R.W, Y + H - R.H, R.W, R.H, R.X, R.Y, 
01345										R.W, R.H, T );
01346	
01347		R = LookAndFeel.MiscBevelArea[BevelType];
01348		DrawStretchedTextureSegment( C, X + LookAndFeel.MiscBevelTL[BevelType].W,
01349		                                Y + LookAndFeel.MiscBevelTL[BevelType].H,
01350										W - LookAndFeel.MiscBevelBL[BevelType].W
01351										- LookAndFeel.MiscBevelBR[BevelType].W,
01352										H - LookAndFeel.MiscBevelTL[BevelType].H
01353										- LookAndFeel.MiscBevelBL[BevelType].H,
01354										R.X, R.Y, R.W, R.H, T );
01355	}
01356	
01357	final function string RemoveAmpersand(string S)
01358	{
01359		local string Result;
01360		local string Underline;
01361	
01362		ParseAmpersand(S, Result, Underline, False);
01363	
01364		return Result;
01365	}
01366	
01367	final function byte ParseAmpersand(string S, out string Result, out string Underline, bool bCalcUnderline)
01368	{
01369		local string Temp;
01370		local int Pos, NewPos;
01371		local int i;
01372		local byte HotKey;
01373		
01374		HotKey = 0;
01375		Pos = 0;
01376		Result = "";
01377		Underline = "";
01378	
01379		while(True)
01380		{
01381			Temp = Mid(S, Pos);
01382	
01383			NewPos = InStr(Temp, "&");
01384			
01385			if(NewPos == -1) break;
01386			Pos += NewPos;
01387	
01388			if(Mid(Temp, NewPos + 1, 1) == "&")
01389			{
01390				// It's a double &, lets add one to the output.
01391				Result = Result $ Left(Temp, NewPos) $ "&";
01392				
01393				if(bCalcUnderline) 
01394					Underline = Underline $ " ";
01395	
01396				Pos++;
01397			}
01398			else
01399			{
01400				if(HotKey == 0)
01401					HotKey = Asc(Caps(Mid(Temp, NewPos + 1, 1)));
01402	
01403				Result = Result $ Left(Temp, NewPos);
01404				
01405				if(bCalcUnderline)
01406				{
01407					for(i=0;i<NewPos - 1;i++) 
01408						Underline = Underline $ " ";
01409					Underline = Underline $ "_";
01410				}
01411			}
01412	
01413			Pos++;
01414		}
01415		Result = Result $ Temp;
01416	
01417		return HotKey;
01418	}
01419	
01420	final function bool MouseIsOver()
01421	{
01422		return (Root.MouseWindow == Self);
01423	}
01424	
01425	function ToolTip(string strTip) 
01426	{
01427		if(ParentWindow != Root) ParentWindow.ToolTip(strTip);
01428	}
01429	
01430	// Sets mouse window for mouse capture.
01431	final function SetMouseWindow()
01432	{
01433		Root.MouseWindow = Self;
01434	}
01435	
01436	function Texture GetLookAndFeelTexture()
01437	{
01438		return ParentWindow.GetLookAndFeelTexture();
01439	}
01440	
01441	function bool IsActive()
01442	{
01443		return ParentWindow.IsActive();
01444	}
01445	
01446	function SetAcceptsHotKeys(bool bNewAccpetsHotKeys)
01447	{
01448		if(bNewAccpetsHotKeys && !bAcceptsHotKeys && bWindowVisible)
01449			Root.AddHotkeyWindow(Self);
01450		
01451		if(!bNewAccpetsHotKeys && bAcceptsHotKeys && bWindowVisible)
01452			Root.RemoveHotkeyWindow(Self);
01453	
01454		bAcceptsHotKeys = bNewAccpetsHotKeys;
01455	}
01456	
01457	final function UWindowWindow GetParent(class<UWindowWindow> ParentClass, optional bool bExactClass)
01458	{
01459		local UWindowWindow P;
01460	
01461		P = ParentWindow;
01462		while(P != Root)
01463		{
01464			if(bExactClass)
01465			{
01466				if(P.Class == ParentClass)
01467					return P;
01468			}
01469			else
01470			{
01471				if(ClassIsChildOf(P.Class, ParentClass))
01472					return P;
01473			}
01474			P = P.ParentWindow;
01475		}
01476	
01477		return None;
01478	}
01479	
01480	final function UWindowWindow FindChildWindow(class<UWindowWindow> ChildClass, optional bool bExactClass)
01481	{
01482		local UWindowWindow Child, Found;
01483	
01484		for(Child = LastChildWindow;Child != None;Child = Child.PrevSiblingWindow)
01485		{
01486			if(bExactClass)
01487			{
01488				if(Child.Class == ChildClass) return Child;
01489			}
01490			else
01491			{
01492				if(ClassIsChildOf(Child.Class, ChildClass)) return Child;
01493			}
01494	
01495			Found = Child.FindChildWindow(ChildClass);
01496			if(Found != None) return Found;
01497		}
01498	
01499		return None;
01500	}
01501	
01502	function GetDesiredDimensions(out float W, out float H)
01503	{
01504		local float MaxW, MaxH, TW, TH;
01505		local UWindowWindow Child, Found;
01506		
01507		MaxW = 0;
01508		MaxH = 0;
01509	
01510		for(Child = LastChildWindow;Child != None;Child = Child.PrevSiblingWindow)
01511		{
01512			Child.GetDesiredDimensions(TW, TH);
01513			//Log("Calling: "$GetPlayerOwner().GetItemName(string(Child)));
01514			
01515	
01516			if(TW > MaxW) MaxW = TW;
01517			if(TH > MaxH) MaxH = TH;
01518		}
01519		W = MaxW;
01520		H = MaxH;
01521		//Log(GetPlayerOwner().GetItemName(string(Self))$": DesiredHeight: "$H);
01522	}
01523	
01524	final function TextSize(Canvas C, string Text, out float W, out float H)
01525	{
01526		C.SetPos(0, 0);
01527		C.TextSize(Text, W, H);
01528		W = W / Root.GUIScale;
01529		H = H / Root.GUIScale;
01530	}
01531	
01532	function ResolutionChanged(float W, float H)
01533	{
01534		local UWindowWindow Child;
01535	
01536		for(Child = LastChildWindow;Child != None;Child = Child.PrevSiblingWindow)
01537		{
01538			Child.ResolutionChanged(W, H);
01539		}
01540	}
01541	
01542	function ShowModal(UWindowWindow W)
01543	{
01544		ModalWindow = W;
01545		W.ShowWindow();
01546		W.BringToFront();		
01547	}
01548	
01549	function bool WaitModal()
01550	{
01551		if(ModalWindow != None && ModalWindow.bWindowVisible)
01552			return True;
01553	
01554		ModalWindow = None;
01555	
01556		return False;
01557	}
01558	
01559	function WindowHidden()
01560	{
01561		local UWindowWindow Child;
01562	
01563		for(Child = LastChildWindow;Child != None;Child = Child.PrevSiblingWindow)
01564			Child.WindowHidden();
01565	}
01566	
01567	function WindowShown()
01568	{
01569		local UWindowWindow Child;
01570	
01571		for(Child = LastChildWindow;Child != None;Child = Child.PrevSiblingWindow)
01572			Child.WindowShown();
01573	}
01574	
01575	// Should mouse events at these co-ordinates be passed through to underlying windows?
01576	function bool CheckMousePassThrough(float X, float Y)
01577	{
01578		return False;
01579	}
01580	
01581	final function bool WindowIsVisible()
01582	{
01583		if(Self == Root)
01584			return True;
01585	
01586		if(!bWindowVisible)
01587			return False;
01588		return ParentWindow.WindowIsVisible();
01589	}
01590	
01591	function SetParent(UWindowWindow NewParent)
01592	{
01593		HideWindow();
01594		ParentWindow = NewParent;
01595		ShowWindow();
01596	}
01597	
01598	function UWindowMessageBox MessageBox(string Title, string Message, MessageBoxButtons Buttons, MessageBoxResult ESCResult, optional MessageBoxResult EnterResult, optional int TimeOut)
01599	{
01600		local UWindowMessageBox W;
01601		local UWindowFramedWindow F;
01602		
01603		W = UWindowMessageBox(Root.CreateWindow(class'UWindowMessageBox', 100, 100, 100, 100, Self));
01604		W.SetupMessageBox(Title, Message, Buttons, ESCResult, EnterResult, TimeOut);
01605		F = UWindowFramedWindow(GetParent(class'UWindowFramedWindow'));
01606	
01607		if(F!= None)
01608			F.ShowModal(W);
01609		else
01610			Root.ShowModal(W);
01611	
01612		return W;
01613	}
01614	
01615	function MessageBoxDone(UWindowMessageBox W, MessageBoxResult Result)
01616	{
01617	}
01618	
01619	function NotifyQuitUnreal()
01620	{
01621		local UWindowWindow Child;
01622	
01623		for(Child = LastChildWindow;Child != None;Child = Child.PrevSiblingWindow)
01624			Child.NotifyQuitUnreal();
01625	}
01626	
01627	function NotifyBeforeLevelChange()
01628	{
01629		local UWindowWindow Child;
01630	
01631		for(Child = LastChildWindow;Child != None;Child = Child.PrevSiblingWindow)
01632			Child.NotifyBeforeLevelChange();
01633	}
01634	
01635	function SetCursor(MouseCursor C)
01636	{
01637		local UWindowWindow Child;
01638	
01639		Cursor = C;
01640	
01641		for(Child = LastChildWindow;Child != None;Child = Child.PrevSiblingWindow)
01642			Child.SetCursor(C);
01643	}
01644	
01645	function NotifyAfterLevelChange()
01646	{
01647		local UWindowWindow Child;
01648	
01649		for(Child = LastChildWindow;Child != None;Child = Child.PrevSiblingWindow)
01650			Child.NotifyAfterLevelChange();
01651	}
01652	
01653	final function ReplaceText(out string Text, string Replace, string With)
01654	{
01655		local int i;
01656		local string Input;
01657			
01658		Input = Text;
01659		Text = "";
01660		i = InStr(Input, Replace);
01661		while(i != -1)
01662		{	
01663			Text = Text $ Left(Input, i) $ With;
01664			Input = Mid(Input, i + Len(Replace));	
01665			i = InStr(Input, Replace);
01666		}
01667		Text = Text $ Input;
01668	}
01669	
01670	function StripCRLF(out string Text)
01671	{
01672		ReplaceText(Text, Chr(13)$Chr(10), "");
01673		ReplaceText(Text, Chr(13), "");
01674		ReplaceText(Text, Chr(10), "");
01675	}
01676	
01677	defaultproperties
01678	{
01679	}

End Source Code