UWindow
Class UWindowTabControl

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

class UWindowTabControl
extends UWindow.UWindowListControl


Variables
 UWindowTabControlLeftButton LeftButton
 UWindowTabControlRightButton RightButton
 UWindowTabControlItem SelectedTab
 UWindowTabControlTabArea TabArea
 bool bMultiLine
 bool bSelectNearestTabOnRemove


Function Summary
 UWindowTabControlItem AddTab(string Caption)
 void BeforePaint(Canvas C, float X, float Y)
 void Created()
 void DeleteTab(UWindowTabControlItem Tab)
 UWindowTabControlItem GetTab(string Caption)
 void GotoTab(UWindowTabControlItem NewSelected, optional bool)
 UWindowTabControlItem InsertTab(UWindowTabControlItem BeforeTab, string Caption)
 void Paint(Canvas C, float X, float Y)
 void SetMultiLine(bool InMultiLine)



Source Code


00001	class UWindowTabControl extends UWindowListControl;
00002	
00003	var UWindowTabControlLeftButton		LeftButton;
00004	var UWindowTabControlRightButton	RightButton;
00005	var UWindowTabControlTabArea		TabArea;
00006	var UWindowTabControlItem			SelectedTab;
00007	
00008	var bool							bMultiLine;
00009	var bool							bSelectNearestTabOnRemove;
00010	
00011	function Created()
00012	{
00013		Super.Created();
00014	
00015		SelectedTab = None;
00016	
00017		TabArea = UWindowTabControlTabArea(CreateWindow(class'UWindowTabControlTabArea', 
00018						0, 0, WinWidth - LookAndFeel.Size_ScrollbarWidth 
00019							- LookAndFeel.Size_ScrollbarWidth - 10,
00020						 LookAndFeel.Size_TabAreaHeight+LookAndFeel.Size_TabAreaOverhangHeight));
00021	
00022		TabArea.bAlwaysOnTop = True;
00023	
00024		LeftButton = UWindowTabControlLeftButton(CreateWindow(class'UWindowTabControlLeftButton', WinWidth-20, 0, 10, 12));
00025		RightButton = UWindowTabControlRightButton(CreateWindow(class'UWindowTabControlRightButton', WinWidth-10, 0, 10, 12));
00026	}
00027	
00028	function BeforePaint(Canvas C, float X, float Y)
00029	{
00030		TabArea.WinTop = 0;
00031		TabArea.WinLeft = 0;
00032	
00033		if(bMultiLine)
00034			TabArea.WinWidth = WinWidth;
00035		else
00036			TabArea.WinWidth = WinWidth - LookAndFeel.Size_ScrollbarWidth - LookAndFeel.Size_ScrollbarWidth - 10;
00037	
00038		TabArea.LayoutTabs(C);
00039		WinHeight = (LookAndFeel.Size_TabAreaHeight * TabArea.TabRows) + LookAndFeel.Size_TabAreaOverhangHeight;
00040		TabArea.WinHeight = WinHeight;
00041	
00042		Super.BeforePaint(C, X, Y);
00043	}
00044	
00045	function SetMultiLine(bool InMultiLine)
00046	{
00047		bMultiLine = InMultiLine;
00048	
00049		if(bMultiLine)
00050		{	
00051			LeftButton.HideWindow();
00052			RightButton.HideWindow();
00053		}
00054		else
00055		{
00056			LeftButton.ShowWindow();
00057			RightButton.ShowWindow();
00058		}
00059	}
00060	
00061	function Paint(Canvas C, float X, float Y)
00062	{
00063		local Region R;
00064		local Texture T;
00065	
00066		T = GetLookAndFeelTexture();
00067		R = LookAndFeel.TabBackground;
00068		DrawStretchedTextureSegment( C, 0, 0, WinWidth, LookAndFeel.Size_TabAreaHeight * TabArea.TabRows, R.X, R.Y, R.W, R.H, T );
00069	}
00070	
00071	function UWindowTabControlItem AddTab(string Caption)
00072	{
00073		local UWindowTabControlItem I;
00074	
00075		I = UWindowTabControlItem(Items.Append(ListClass));
00076	
00077		I.Owner = Self;
00078		I.SetCaption(Caption);
00079	
00080		if(SelectedTab == None) 
00081			SelectedTab = I;
00082		
00083		return I;
00084	}
00085	
00086	function UWindowTabControlItem InsertTab(UWindowTabControlItem BeforeTab, string Caption)
00087	{
00088		local UWindowTabControlItem I;
00089	
00090		I = UWindowTabControlItem(BeforeTab.InsertBefore(ListClass));
00091	
00092		I.Owner = Self;
00093		I.SetCaption(Caption);
00094	
00095		if(SelectedTab == None) 
00096			SelectedTab = I;
00097		
00098		return I;
00099	}
00100	
00101	function GotoTab( UWindowTabControlItem NewSelected, optional bool bByUser )
00102	{
00103		if(SelectedTab != NewSelected && bByUser)
00104			LookAndFeel.PlayMenuSound(Self, MS_ChangeTab);
00105		SelectedTab = NewSelected;
00106		TabArea.bShowSelected = True;
00107	}
00108	
00109	function UWindowTabControlItem GetTab( string Caption )
00110	{
00111		local UWindowTabControlItem I;
00112		for(I = UWindowTabControlItem(Items.Next); I != None; I = UWindowTabControlItem(I.Next))
00113		{
00114			if(I.Caption == Caption) return I;
00115		}
00116	
00117		return None;		
00118	}
00119	
00120	function DeleteTab( UWindowTabControlItem Tab )
00121	{
00122		local UWindowTabControlItem NextTab;
00123		local UWindowTabControlItem PrevTab;
00124		
00125		NextTab = UWindowTabControlItem(Tab.Next);
00126		PrevTab = UWindowTabControlItem(Tab.Prev);
00127		Tab.Remove();
00128	
00129		if(SelectedTab == Tab)
00130		{
00131			if(bSelectNearestTabOnRemove)
00132			{
00133				Tab = NextTab;
00134				if(Tab == None)
00135					Tab = PrevTab;
00136				
00137				GotoTab(Tab);
00138			}
00139			else
00140				GotoTab(UWindowTabControlItem(Items.Next));
00141		}
00142	}
00143	
00144	defaultproperties
00145	{
00146	     ListClass=Class'UWindow.UWindowTabControlItem'
00147	}

End Source Code