GUI
Class GUISlider

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

class GUISlider
extends GUI.GUIComponent

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

Function Summary
 void Adjust(float amount)
 void InitComponent(GUIController MyController, GUIComponent MyOwner)
 bool InternalCapturedMouseMove(float deltaX, float deltaY)
 bool InternalOnClick(GUIComponent Sender)
 bool InternalOnKeyEvent(out byte, out byte, float delta)
 void InternalOnMousePressed(GUIComponent Sender, bool RepeatClick)
 string LoadINI()
 void SaveINI(string V)
 void SetValue(float NewValue)



Source Code


00001	// ====================================================================
00002	//  (c) 2002, Epic Games, Inc.  All Rights Reserved
00003	// ====================================================================
00004	
00005	class GUISlider extends GUIComponent
00006			Native;
00007	
00008			
00009	var(Menu)	float 		MinValue, MaxValue;
00010	var(Menu)	string		CaptionStyleName;
00011	var			float		Value;
00012	var			GUIStyles	CaptionStyle;
00013	var			bool		bIntSlider;
00014	
00015	delegate string OnDrawCaption()
00016	{
00017		if (bIntSlider)
00018			return "("$int(Value)$")";
00019		else
00020			return "("$Value$")";
00021	}
00022	
00023	function SetValue(float NewValue)
00024	{
00025		if (NewValue<MinValue) NewValue=MinValue;
00026		if (NewValue>MaxValue) NewValue=MaxValue;
00027		
00028		if (bIntSlider)
00029			Value = int(NewValue);
00030		else
00031			Value = NewValue;
00032	}
00033	
00034	function InitComponent(GUIController MyController, GUIComponent MyOwner)
00035	{
00036		Super.Initcomponent(MyController, MyOwner);
00037		OnCapturedMouseMove=InternalCapturedMouseMove;
00038		OnKeyEvent=InternalOnKeyEvent;
00039		OnClick=InternalOnClick;
00040		OnMousePressed=InternalOnMousePressed;
00041		
00042		CaptionStyle = Controller.GetStyle(CaptionStyleName);	
00043	}
00044	
00045	
00046	function bool InternalCapturedMouseMove(float deltaX, float deltaY)
00047	{
00048		local float Perc, OldValue;
00049		
00050		OldValue = Value;
00051		
00052		if ( (Controller.MouseX >= Bounds[0]) && (Controller.MouseX<=Bounds[2]) )
00053		{
00054			Perc = ( float(Controller.MouseX) - ActualLeft()) / ActualWidth();
00055			Perc = FClamp(Perc,0.0,1.0); 
00056			Value = ( (MaxValue - MinValue) * Perc) + MinValue;
00057		}
00058		else if (Controller.MouseX < Bounds[0])
00059			Value = MinValue;
00060		else if (Controller.MouseX > Bounds[2])
00061			Value = MaxValue;
00062	
00063		Value = FClamp(Value,MinValue,MaxValue);
00064		
00065		return true;
00066	}
00067	
00068	function bool InternalOnKeyEvent(out byte Key, out byte State, float delta)
00069	{
00070		if ( (Key==0x25 || Key==0x64) && (State==1) )	// Left
00071		{
00072			Adjust(-0.01);	
00073			return true;
00074		}
00075		
00076		if ( (Key==0x27 || Key==0x66) && (State==1) ) // Right
00077		{
00078			Adjust(0.01);
00079			return true;
00080		}
00081		
00082		
00083		return false;
00084	}
00085	
00086	function Adjust(float amount)
00087	{
00088		local float Perc;
00089		Perc = (Value-MinValue) / (MaxValue-MinValue);
00090		Perc += amount;  
00091		Perc = FClamp(Perc,0.0,1.0); 
00092		Value = ( (MaxValue - MinValue) * Perc) + MinValue;
00093		FClamp(Value,MinValue, MaxValue);
00094		OnChange(self);
00095	}
00096	
00097	function string LoadINI()
00098	{	local string s;
00099		
00100		s = Super.LoadINI();
00101		if (s!="")
00102			Value = float(s);
00103				
00104		return s;
00105	}
00106	
00107	function SaveINI(string V)
00108	{
00109		Super.SaveINI(""$V);
00110	}
00111	
00112	function bool InternalOnClick(GUIComponent Sender)
00113	{
00114		OnChange(self);
00115		return true;
00116	}
00117	
00118	function InternalOnMousePressed(GUIComponent Sender,bool RepeatClick)
00119	{
00120		InternalCapturedMouseMove(0,0);
00121	}
00122	
00123	
00124	
00125	defaultproperties
00126	{
00127	     bAcceptsInput=True
00128	     bCaptureMouse=True
00129	     bRequireReleaseClick=True
00130	     WinHeight=0.030000
00131	     bTabStop=True
00132	     OnClickSound=GUI_CS_Click
00133	}

End Source Code