UWindow
Class UWindowFramedWindow

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

End Source Code