UWindow
Class UWindowFramedWindow

source: e:\games\UnrealTournament\UWindow\Classes\UWindowFramedWindow.uc
Core.Object
   |
   +--UWindow.UWindowBase
      |
      +--UWindow.UWindowWindow
         |
         +--UWindow.UWindowFramedWindow
Direct Known Subclasses:UBrowserEditFavoriteWindow, UBrowserInfoWindow, UBrowserMainWindow, UBrowserOpenWindow, UMenuFramedWindow, UMenuHelpWindow, UMenuMapListWindow, UMenuMutatorWindow, UTPasswordWindow, UWindowConsoleWindow, UWindowMessageBox

class UWindowFramedWindow
extends UWindow.UWindowWindow

//============================================================================= // UWindowFramedWindow - a Windows95 style framed window //=============================================================================
Variables
 UWindowWindow ClientArea
 class ClientClass
 UWindowFrameCloseBox CloseBox
           co-ordinates where the move was requested
 MinWinWidth, MinWinHeight
           co-ordinates where the move was requested
 MoveX, MoveY
           co-ordinates where the move was requested
 string StatusBarText
 string WindowTitle
 bool bBLSizing
           co-ordinates where the move was requested
 bool bBRSizing
           co-ordinates where the move was requested
 bool bBSizing
           co-ordinates where the move was requested
 bool bLSizing
           co-ordinates where the move was requested
 bool bMoving
           co-ordinates where the move was requested
 bool bRSizing
           co-ordinates where the move was requested
 bool bSizable
           co-ordinates where the move was requested
 bool bStatusBar
           co-ordinates where the move was requested
 bool bTLSizing
           co-ordinates where the move was requested
 bool bTRSizing
           co-ordinates where the move was requested
 bool bTSizing
           co-ordinates where the move was requested


Function Summary
 void BeforePaint(Canvas C, float X, float Y)
 void Created()
 Texture GetLookAndFeelTexture()
 bool IsActive()
 void LMouseDown(float X, float Y)
 void MouseMove(float X, float Y)
 void Paint(Canvas C, float X, float Y)
 void Resized()
 void ToolTip(string strTip)
 void WindowEvent(WinMessage Msg, Canvas C, float X, float Y, int Key)
 void WindowHidden()



Source Code


00001	//=============================================================================
00002	// UWindowFramedWindow - a Windows95 style framed window
00003	//=============================================================================
00004	class UWindowFramedWindow extends UWindowWindow;
00005	
00006	
00007	var class<UWindowWindow>	ClientClass;
00008	var UWindowWindow			ClientArea;
00009	var localized string		WindowTitle;
00010	var string					StatusBarText;
00011	var float					MoveX, MoveY;	// co-ordinates where the move was requested
00012	var float					MinWinWidth, MinWinHeight;
00013	
00014	var bool					bTLSizing;
00015	var bool					bTSizing;
00016	var bool					bTRSizing;
00017	var bool					bLSizing;
00018	var bool					bRSizing;
00019	var bool					bBLSizing;
00020	var bool					bBSizing;
00021	var bool					bBRSizing;
00022	
00023	var bool					bMoving;
00024	var bool					bSizable;
00025	var bool					bStatusBar;
00026	var UWindowFrameCloseBox	CloseBox;
00027	
00028	
00029	function Created()
00030	{
00031		Super.Created();
00032	
00033		MinWinWidth = 50;
00034		MinWinHeight = 50;
00035		ClientArea = CreateWindow(ClientClass, 4, 16, WinWidth - 8, WinHeight - 20, OwnerWindow);
00036		CloseBox = UWindowFrameCloseBox(CreateWindow(Class'UWindowFrameCloseBox', WinWidth-20, WinHeight-20, 11, 10));
00037	}
00038	
00039	function Texture GetLookAndFeelTexture()
00040	{
00041		return LookAndFeel.GetTexture(Self);
00042	}
00043	
00044	function bool IsActive()
00045	{
00046		return ParentWindow.ActiveWindow == Self;
00047	}
00048	
00049	function BeforePaint(Canvas C, float X, float Y)
00050	{	
00051		Super.BeforePaint(C, X, Y);
00052		Resized();
00053		LookAndFeel.FW_SetupFrameButtons(Self, C);
00054	}
00055	
00056	function Paint(Canvas C, float X, float Y)
00057	{
00058		LookAndFeel.FW_DrawWindowFrame(Self, C);
00059	}
00060	
00061	function LMouseDown(float X, float Y)
00062	{
00063		local FrameHitTest H;
00064		H = LookAndFeel.FW_HitTest(Self, X, Y);
00065	
00066		Super.LMouseDown(X, Y);
00067	
00068	
00069		if(H == HT_TitleBar)
00070		{
00071			MoveX = X;
00072			MoveY = Y;
00073			bMoving = True;
00074			Root.CaptureMouse();
00075	
00076			return;
00077		}
00078	
00079		if(bSizable) 
00080		{
00081			switch(H)
00082			{
00083			case HT_NW:
00084				bTLSizing = True;
00085				Root.CaptureMouse();
00086				return;
00087			case HT_NE:
00088				bTRSizing = True;
00089				Root.CaptureMouse();
00090				return;
00091			case HT_SW:
00092				bBLSizing = True;
00093				Root.CaptureMouse();
00094				return;		
00095			case HT_SE:
00096				bBRSizing = True;
00097				Root.CaptureMouse();
00098				return;
00099			case HT_N:
00100				bTSizing = True;
00101				Root.CaptureMouse();
00102				return;
00103			case HT_S:
00104				bBSizing = True;
00105				Root.CaptureMouse();
00106				return;
00107			case HT_W:
00108				bLSizing = True;
00109				Root.CaptureMouse();
00110				return;
00111			case HT_E:
00112				bRSizing = True;
00113				Root.CaptureMouse();
00114				return;
00115			}
00116		}
00117	}
00118	
00119	function Resized()
00120	{
00121		local Region R;
00122	
00123		if(ClientArea == None)
00124		{
00125			Log("Client Area is None for "$Self);
00126			return;
00127		}
00128	
00129		R = LookAndFeel.FW_GetClientArea(Self);
00130	
00131		ClientArea.WinLeft = R.X;
00132		ClientArea.WinTop = R.Y;
00133	
00134		if((R.W != ClientArea.WinWidth) || (R.H != ClientArea.WinHeight)) 
00135		{
00136			ClientArea.SetSize(R.W, R.H);
00137		}
00138	
00139	}
00140	
00141	function MouseMove(float X, float Y)
00142	{
00143		local float OldW, OldH;
00144		local FrameHitTest H;
00145		H = LookAndFeel.FW_HitTest(Self, X, Y);
00146	
00147	
00148		if(bMoving && bMouseDown)
00149		{
00150			WinLeft = Int(WinLeft + X - MoveX);
00151			WinTop = Int(WinTop + Y - MoveY);
00152		}
00153		else
00154			bMoving = False;
00155	
00156	
00157		Cursor = Root.NormalCursor;
00158	
00159		if(bSizable && !bMoving)
00160		{
00161			switch(H)
00162			{
00163			case HT_NW:
00164			case HT_SE:
00165				Cursor = Root.DiagCursor1;
00166				break;
00167			case HT_NE:
00168			case HT_SW:
00169				Cursor = Root.DiagCursor2;
00170				break;
00171			case HT_W:
00172			case HT_E:
00173				Cursor = Root.WECursor;
00174				break;
00175			case HT_N:
00176			case HT_S:
00177				Cursor = Root.NSCursor;
00178				break;
00179			}
00180		}	
00181	
00182		// Top Left
00183		if(bTLSizing && bMouseDown)
00184		{
00185			Cursor = Root.DiagCursor1;	
00186			OldW = WinWidth;
00187			OldH = WinHeight;
00188			SetSize(Max(MinWinWidth, WinWidth - X), Max(MinWinHeight, WinHeight - Y));
00189			WinLeft = Int(WinLeft + OldW - WinWidth);
00190			WinTop = Int(WinTop + OldH - WinHeight);
00191		}
00192		else 
00193			bTLSizing = False;
00194	
00195	
00196		// Top
00197		if(bTSizing && bMouseDown)
00198		{
00199			Cursor = Root.NSCursor;
00200			OldH = WinHeight;
00201			SetSize(WinWidth, Max(MinWinHeight, WinHeight - Y));
00202			WinTop = Int(WinTop + OldH - WinHeight);
00203		}
00204		else 
00205			bTSizing = False;
00206	
00207		// Top Right
00208		if(bTRSizing && bMouseDown)
00209		{
00210			Cursor = Root.DiagCursor2;
00211			OldH = WinHeight;
00212			SetSize(Max(MinWinWidth, X), Max(MinWinHeight, WinHeight - Y));
00213			WinTop = Int(WinTop + OldH - WinHeight);
00214		}
00215		else 
00216			bTRSizing = False;
00217	
00218	
00219		// Left
00220		if(bLSizing && bMouseDown)
00221		{
00222			Cursor = Root.WECursor;
00223			OldW = WinWidth;
00224			SetSize(Max(MinWinWidth, WinWidth - X), WinHeight);
00225			WinLeft = Int(WinLeft + OldW - WinWidth);
00226		}
00227		else 
00228			bLSizing = False;
00229	
00230		// Right
00231		if(bRSizing && bMouseDown)
00232		{
00233			Cursor = Root.WECursor;
00234			SetSize(Max(MinWinWidth, X), WinHeight);
00235		}
00236		else 
00237			bRSizing = False;
00238	
00239		// Bottom Left
00240		if(bBLSizing && bMouseDown)
00241		{
00242			Cursor = Root.DiagCursor2;
00243			OldW = WinWidth;
00244			SetSize(Max(MinWinWidth, WinWidth - X), Max(MinWinHeight, Y));
00245			WinLeft = Int(WinLeft + OldW - WinWidth);
00246		}
00247		else 
00248			bBLSizing = False;
00249	
00250		// Bottom
00251		if(bBSizing && bMouseDown)
00252		{
00253			Cursor = Root.NSCursor;
00254			SetSize(WinWidth, Max(MinWinHeight, Y));
00255		}
00256		else 
00257			bBSizing = False;
00258	
00259		// Bottom Right
00260		if(bBRSizing && bMouseDown)
00261		{
00262			Cursor = Root.DiagCursor1;
00263			SetSize(Max(MinWinWidth, X), Max(MinWinHeight, Y));
00264		}
00265		else
00266			bBRSizing = False;
00267	
00268	}
00269	
00270	function ToolTip(string strTip)
00271	{
00272		StatusBarText = strTip;
00273	}
00274	
00275	function WindowEvent(WinMessage Msg, Canvas C, float X, float Y, int Key) 
00276	{
00277		if(Msg == WM_Paint || !WaitModal())
00278			Super.WindowEvent(Msg, C, X, Y, Key);
00279	}
00280	
00281	function WindowHidden()
00282	{
00283		Super.WindowHidden();
00284		LookAndFeel.PlayMenuSound(Self, MS_WindowClose);
00285	}
00286	
00287	defaultproperties
00288	{
00289	     ClientClass=Class'UWindow.UWindowClientWindow'
00290	}

End Source Code