GUI
Class GUIVertScrollBar

source: C:\XIII\GUI\Classes\GUIVertScrollBar.uc
Core.Object
   |
   +--GUI.GUI
      |
      +--GUI.GUIComponent
         |
         +--GUI.GUIMultiComponent
            |
            +--GUI.GUIScrollBarBase
               |
               +--GUI.GUIVertScrollBar
Direct Known Subclasses:None

class GUIVertScrollBar
extends GUI.GUIScrollBarBase

// ==================================================================== // (c) 2002, Epic Games, Inc. All Rights Reserved // ====================================================================

Function Summary
 void AlignThumb()
 bool DownTickClick(GUIComponent Sender)
 bool GripClick(GUIComponent Sender)
     
// Record location you grabbed the grip
 bool GripMouseMove(float deltaX, float deltaY)
 void InitComponent(GUIController MyController, GUIComponent MyOwner)
     
// distance from top of button that the user started their drag. Set natively.	
 void MoveGripBy(int items)
 bool UpTickClick(GUIComponent Sender)
 void UpdateGripPosition(float NewPos)
 void WheelDown()
 void WheelUp()
 void ZoneClick(float Delta)



Source Code


00001	// ====================================================================
00002	//  (c) 2002, Epic Games, Inc.  All Rights Reserved
00003	// ====================================================================
00004	
00005	class GUIVertScrollBar extends GUIScrollBarBase
00006			Native;
00007			
00008			
00009	var		float			GripTop;		// Where in the ScrollZone is the grip	- Set Natively
00010	var		float			GripHeight;		// How big is the grip - Set Natively
00011	
00012	var		float			GrabOffset; // distance from top of button that the user started their drag. Set natively.	
00013	
00014	
00015	function InitComponent(GUIController MyController, GUIComponent MyOwner)
00016	{
00017		Super.InitComponent(MyController, MyOwner);
00018		
00019		GUIVertScrollZone(Controls[0]).OnScrollZoneClick = ZoneClick;
00020		Controls[1].OnClick = UpTickClick;
00021		Controls[2].OnClick = DownTickClick;
00022		Controls[3].OnCapturedMouseMove = GripMouseMove;
00023		Controls[3].OnClick = GripClick;
00024	}
00025	
00026	function UpdateGripPosition(float NewPos)
00027	{
00028		MyList.MakeVisible(NewPos);
00029		GripTop = NewPos;
00030	}
00031	
00032	// Record location you grabbed the grip
00033	function bool GripClick(GUIComponent Sender)
00034	{
00035		GrabOffset = Controller.MouseY - Controls[3].ActualTop();
00036	
00037		return true;
00038	}
00039	
00040	function bool GripMouseMove(float deltaX, float deltaY)
00041	{
00042		local float NewPerc,NewTop;
00043		
00044		// Calculate the new Grip Top using the mouse cursor location.	
00045		NewPerc = (  float(Controller.MouseY) - (GrabOffset + Controls[0].ActualTop()) )  /(Controls[0].ActualHeight()-GripHeight);
00046		NewTop = FClamp(NewPerc,0.0,1.0);
00047	
00048		UpdateGripPosition(Newtop);
00049		
00050		return true;	
00051	}
00052	
00053	function ZoneClick(float Delta)
00054	{
00055		if ( Controller.MouseY < Controls[3].Bounds[1] )
00056			MoveGripBy(-MyList.ItemsPerPage);
00057		else if ( Controller.MouseY > Controls[3].Bounds[3] )
00058			MoveGripBy(MyList.ItemsPerPage);
00059			
00060		return;
00061	}
00062	
00063	function MoveGripBy(int items)
00064	{
00065		local int TopItem;
00066	
00067		TopItem = MyList.Top + items;
00068		if (MyList.ItemCount > 0)
00069		{
00070			MyList.SetTopItem(TopItem);
00071			AlignThumb();
00072		}
00073	}
00074	
00075	function bool UpTickClick(GUIComponent Sender)
00076	{
00077		WheelUp();
00078		return true;
00079	}
00080	
00081	function bool DownTickClick(GUIComponent Sender)
00082	{
00083		WheelDown();
00084		return true;
00085	}
00086	
00087	function WheelUp()
00088	{
00089		if (!Controller.CtrlPressed)
00090			MoveGripBy(-1);
00091		else
00092			MoveGripBy(-MyList.ItemsPerPage);
00093	}
00094	
00095	function WheelDown()
00096	{
00097		if (!Controller.CtrlPressed)
00098			MoveGripBy(1);
00099		else
00100			MoveGripBy(MyList.ItemsPerPage);
00101	}
00102	
00103	function AlignThumb()
00104	{
00105		local float NewTop;
00106		
00107		if (MyList.ItemCount==0)
00108			NewTop = 0;
00109		else
00110		{
00111			NewTop = Float(MyList.Top) / Float(MyList.ItemCount-MyList.ItemsPerPage);
00112			NewTop = FClamp(NewTop,0.0,1.0);
00113		}
00114			
00115		GripTop = NewTop;
00116	}
00117		
00118	
00119	// NOTE:  Add graphics for no-man's land about and below the scrollzone, and the Scroll nub.		
00120	
00121	
00122	
00123	defaultproperties
00124	{
00125	     Controls(0)=GUIVertScrollZone'GUI.GUIVertScrollBar.ScrollZone'
00126	     Controls(1)=GUIVertScrollButton'GUI.GUIVertScrollBar.UpBut'
00127	     Controls(2)=GUIVertScrollButton'GUI.GUIVertScrollBar.DownBut'
00128	     Controls(3)=GUIVertGripButton'GUI.GUIVertScrollBar.Grip'
00129	     bAcceptsInput=True
00130	     WinWidth=0.037500
00131	}

End Source Code