UWindow
Class UWindowGrid

source: e:\games\UnrealTournament\UWindow\Classes\UWindowGrid.uc
Core.Object
   |
   +--UWindow.UWindowBase
      |
      +--UWindow.UWindowWindow
         |
         +--UWindow.UWindowGrid
Direct Known Subclasses:UBrowserPlayerGrid, UBrowserRulesGrid, UBrowserServerGrid

class UWindowGrid
extends UWindow.UWindowWindow

//============================================================================= // UWindowGrid - a grid with sizable columns and clickable column headings. //=============================================================================
Variables
 UWindowGridClient ClientArea
 UWindowGridColumn FirstColumn
 UWindowHScrollBar HorizSB
 UWindowGridColumn LastColumn
 float RowHeight
 int TopRow
 UWindowVScrollBar VertSB
 bool bNoKeyboard
 bool bShowHorizSB
 bool bSizingColumn


Function Summary
 UWindowGridColumn AddColumn(string ColumnHeading, float DefaultWidth)
 void BeforePaint(Canvas C, float X, float Y)
 void Created()
 void DoubleClickRow(int Row)
 void KeyDown(int Key, float X, float Y)
 void MouseLeaveColumn(UWindowGridColumn Column)
 void Paint(Canvas C, float MouseX, float MouseY)
 void PaintColumn(Canvas C, UWindowGridColumn Column, float MouseX, float MouseY)
 void Resized()
 void RightClickRow(int Row, float X, float Y)
 void RightClickRowDown(int Row, float X, float Y)
 void SelectRow(int Row)
 void SortColumn(UWindowGridColumn Column)



Source Code


00001	//=============================================================================
00002	// UWindowGrid - a grid with sizable columns and clickable column headings.
00003	//=============================================================================
00004	class UWindowGrid extends UWindowWindow;
00005	
00006	var UWindowGridColumn FirstColumn;
00007	var UWindowGridColumn LastColumn;
00008	var UWindowGridClient ClientArea;
00009	
00010	var int					TopRow;
00011	var float				RowHeight;
00012	var UWindowVScrollbar	VertSB;
00013	var UWindowHScrollbar	HorizSB;
00014	var bool				bShowHorizSB;
00015	var bool				bSizingColumn;
00016	var bool				bNoKeyboard;
00017	
00018	function Created()
00019	{
00020		ClientArea = UWindowGridClient(CreateWindow(class'UWindowGridClient', 0, 0, WinWidth - 12, WinHeight));
00021		VertSB = UWindowVScrollbar(CreateWindow(class'UWindowVScrollbar', WinWidth-12, 0, 12, WinHeight));
00022		VertSB.bAlwaysOnTop = True;
00023	
00024		HorizSB = UWindowHScrollbar(CreateWindow(class'UWindowHScrollbar', 0, WinHeight-12, WinWidth, 12));
00025		HorizSB.bAlwaysOnTop = True;
00026		HorizSB.HideWindow();
00027		bShowHorizSB = False;
00028	
00029		if(!bNoKeyboard)
00030			SetAcceptsFocus();
00031	
00032		Super.Created();
00033	}
00034	
00035	
00036	function BeforePaint(Canvas C, float X, float Y)
00037	{
00038		Super.BeforePaint(C, X, Y);
00039		Resized();
00040	}
00041	
00042	function Resized()
00043	{
00044		local float Offset;
00045		local UWindowGridColumn colColumn;
00046		local float TotalWidth;
00047	
00048	
00049		TotalWidth = 0;
00050		colColumn = FirstColumn;
00051		while(colColumn != None)
00052		{
00053			TotalWidth = TotalWidth + colColumn.WinWidth;
00054			colColumn = colColumn.NextColumn;
00055		}
00056	
00057		if(!bSizingColumn)
00058			HorizSB.SetRange(0, TotalWidth, WinWidth - LookAndFeel.Size_ScrollbarWidth, 10);
00059	
00060		if(!HorizSB.bDisabled)
00061		{
00062			// Need a horizontal scrollbar
00063			HorizSB.ShowWindow();
00064			bShowHorizSB = True;
00065		}
00066		else
00067		{
00068			HorizSB.HideWindow();
00069			bShowHorizSB = False;
00070			HorizSB.Pos = 0;
00071		}
00072	
00073	
00074		ClientArea.WinTop = 0;
00075		ClientArea.WinLeft = 0;
00076		ClientArea.WinWidth = WinWidth - LookAndFeel.Size_ScrollbarWidth;
00077		if(bShowHorizSB)
00078			ClientArea.WinHeight = WinHeight - LookAndFeel.Size_ScrollbarWidth;
00079		else
00080			ClientArea.WinHeight = WinHeight;
00081	
00082	
00083		if(bShowHorizSB)
00084		{
00085			HorizSB.WinTop = WinHeight-LookAndFeel.Size_ScrollbarWidth;
00086			HorizSB.WinLeft = 0;
00087			HorizSB.WinWidth = WinWidth - LookAndFeel.Size_ScrollbarWidth;
00088			HorizSB.WinHeight = LookAndFeel.Size_ScrollbarWidth;
00089		}
00090	
00091		VertSB.WinTop = 0;
00092		VertSB.WinLeft = WinWidth-LookAndFeel.Size_ScrollbarWidth;
00093		VertSB.WinWidth = LookAndFeel.Size_ScrollbarWidth;
00094		if(bShowHorizSB)
00095			VertSB.WinHeight = WinHeight - LookAndFeel.Size_ScrollbarWidth;
00096		else
00097			VertSB.WinHeight = WinHeight;
00098	
00099		
00100		if(bShowHorizSB)
00101			Offset = 1 - HorizSB.Pos;
00102		else
00103			Offset = 1;
00104	
00105		colColumn = FirstColumn;
00106		while(colColumn != None)
00107		{
00108			colColumn.WinLeft = Offset ;
00109			colColumn.WinTop = 0;
00110			colColumn.WinHeight = WinHeight;
00111			Offset = Offset + colColumn.WinWidth;
00112			colColumn = colColumn.NextColumn;
00113		}
00114	}
00115	
00116	
00117	function UWindowGridColumn AddColumn(string ColumnHeading, float DefaultWidth)
00118	{
00119		local UWindowGridColumn NewColumn;
00120		local UWindowGridColumn OldLastColumn;
00121	
00122		OldLastColumn = LastColumn;
00123	
00124		if(LastColumn == None)
00125		{
00126			NewColumn = UWindowGridColumn(ClientArea.CreateWindow(class'UWindowGridColumn', 0, 0, DefaultWidth, WinHeight));
00127			FirstColumn = NewColumn;
00128			NewColumn.ColumnNum = 0;
00129		}
00130		else
00131		{
00132			NewColumn = UWindowGridColumn(ClientArea.CreateWindow(class'UWindowGridColumn', LastColumn.WinLeft + LastColumn.WinWidth, 0, DefaultWidth, WinHeight));
00133			LastColumn.NextColumn = NewColumn;
00134			NewColumn.ColumnNum = LastColumn.ColumnNum + 1;
00135		}
00136	
00137		LastColumn = NewColumn;
00138		NewColumn.NextColumn = None;
00139		NewColumn.PrevColumn = OldLastColumn;
00140	
00141		NewColumn.ColumnHeading = ColumnHeading;	
00142		return NewColumn;
00143	}
00144	
00145	function Paint(Canvas C, float MouseX, float MouseY)
00146	{
00147		local float X;
00148		local Texture T;
00149		local Region R;
00150	
00151		X = LastColumn.WinWidth + LastColumn.WinLeft;
00152	
00153		T = GetLookAndFeelTexture();
00154		DrawUpBevel( C, X, 0, WinWidth-X, LookAndFeel.ColumnHeadingHeight, T);
00155	
00156		if(bShowHorizSB)
00157		{
00158			// R = LookAndFeel.SBBackground;
00159			DrawStretchedTextureSegment( C, WinWidth-LookAndFeel.Size_ScrollbarWidth,
00160											WinHeight-LookAndFeel.Size_ScrollbarWidth,
00161											LookAndFeel.Size_ScrollbarWidth,
00162											LookAndFeel.Size_ScrollbarWidth,
00163											R.X, R.Y, R.W, R.H, T);
00164		}
00165	}
00166	
00167	
00168	function PaintColumn(Canvas C, UWindowGridColumn Column, float MouseX, float MouseY)
00169	{
00170		// defined in subclass
00171	}
00172	
00173	function SortColumn(UWindowGridColumn Column)
00174	{
00175		// defined in subclass
00176	}
00177	
00178	function SelectRow(int Row)
00179	{
00180		// defined in subclass
00181	}
00182	
00183	function RightClickRow(int Row, float X, float Y)
00184	{
00185		// defined in subclass
00186	}
00187	
00188	function RightClickRowDown(int Row, float X, float Y)
00189	{
00190		// defined in subclass
00191	}
00192	
00193	function DoubleClickRow(int Row)
00194	{
00195		// defined in subclass
00196	}
00197	
00198	function MouseLeaveColumn(UWindowGridColumn Column)
00199	{
00200		// defined in subclass
00201	}
00202	
00203	function KeyDown(int Key, float X, float Y)
00204	{
00205		switch(Key) {
00206		case 0x26: // IK_Up
00207		case 0xEC: // IK_MouseWheelUp
00208			VertSB.Scroll(-1);
00209			break;
00210		case 0x28: // IK_Down
00211		case 0xED: // IK_MouseWheelDown
00212			VertSB.Scroll(1);
00213			break;
00214		case 0x21: // IK_PageUp
00215			VertSB.Scroll(-(VertSB.MaxVisible-1));
00216			break;
00217		case 0x22: // IK_PageDown
00218			VertSB.Scroll(VertSB.MaxVisible-1);
00219			break;
00220		}
00221	}
00222	
00223	defaultproperties
00224	{
00225	     RowHeight=10.000000
00226	}

End Source Code