## GUI
Class GUIComponent

source: C:\XIII\GUI\Classes\GUIComponent.uc

    Core.Object
       |
       +--GUI.GUI
          |
          +--GUI.GUIComponent

Direct Known Subclasses:GUIButton, GUIImage, GUILabel, GUIListBase, GUIMultiComponent, GUISlider, GUIVertScrollZone

class GUIComponent
extends GUI.GUI

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

Variables
`color` | `SaveColor` For easier maintenance
`int` | `TimerIndex` For easier maintenance

States
Newstate

Function Summary
`float` | `ActualHeight()`
`float` | `ActualLeft()`
`Float` | `ActualTop()`
`float` | `ActualWidth()`
    // The ActualXXXX functions are not viable until after the first render so don't
    // use them in inits
`void` | `FillOwner()`
    // Force control to use same area as its MenuOwner.
`void` | `InitComponent(GUIController MyController, GUIComponent MyOwner)`
`bool` | `IsInBounds()`
`bool` | `IsInClientBounds()`
`string` | `LoadINI()`
    // Should be subclassed
`string` | `ParseOption(string URL, string Key, string DefaultVal)`
`PlayerController` | `PlayerOwner()`
    // Do the actual work here
`void` | `SaveINI(string Value)`

State Newstate Function Summary

Source Code

    00001	// ====================================================================
    00002	//  (c) 2002, Epic Games, Inc.  All Rights Reserved
    00003	// ====================================================================
    00004
    00005	class GUIComponent extends GUI
    00006			Native;
    00007
    00008
    00009	// Variables
    00010
    00011	var		GUIComponent 		MenuOwner;				// Callback to the Component that owns this one
    00012	var		eMenuState		MenuState;					// Used to determine the current state of this component
    00013
    00014	// RenderStyle and MenuColor are usually pulled from the Parent menu, unless specificlly overridden
    00015
    00016	var(Menu)	string			IniOption;					// Points to the INI option to load for this component
    00017	var(Menu)	string			IniDefault;					// The default value for a missing ini option
    00018	var(Menu)	string			StyleName;					// Name of my Style
    00019	var(Menu)	bool			bBoundToParent;				// Use the Parents Bounds for all positioning
    00020	var(Menu)	bool			bScaleToParent;				// Use the Parent for scaling
    00021	var(Menu)	bool			bHasFocus;					// Does this component currently have input focus
    00022	var(Menu)	bool			bVisible;					// Is this component currently visible
    00023	var(Menu)	bool			bAcceptsInput;				// Does this control accept input
    00024	var(Menu)	bool			bCaptureTabs;				// This control wants tabs
    00025	var(Menu)	bool			bCaptureMouse;				// Set this if the control should capture the mouse when pressed
    00026	var(Menu)	bool			bNeverFocus;				// This control should never fully receive focus
    00027	var(Menu)	bool			bRepeatClick;				// Have the system accept holding down of the mouse
    00028	var(Menu)	bool			bRequireReleaseClick;		// If True, this component wants the click on release even if it's not active
    00029	var(Menu)	GUIComponent	FocusInstead;				// Who should get the focus instead of this control if bNeverFocus
    00030	var(Menu)	localized string			Hint;						// The hint that gets displayed for this component
    00031	var(Menu)	float			WinTop,WinLeft;				// Where does this component exist (in world space) - Grr.. damn Left()
    00032	var(Menu)	float			WinWidth,WinHeight;			// Where does this component exist (in world space) - Grr.. damn Left()
    00033	var(Menu)	int				MouseCursorIndex;			// The mouse cursor to use when over this control
    00034	var(Menu)	bool			bTabStop;					// Does a TAB/Shift-Tab stop here
    00035	var(Menu)	bool			bFocusOnWatch;				// If true, watching focuses
    00036	var(Menu)	int				Tag;						// Not used.
    00037	var(Menu)	GUILabel		FriendlyLabel;				// My state is projected on this objects state.
    00038
    00039	var(Menu)	bool			bMouseOverSound;			// Should component bleep when mouse goes over it
    00040	var(Menu)	enum			EClickSound
    00041	{
    00042		GUI_CS_None,
    00043		GUI_CS_Click,
    00044		GUI_CS_Edit,
    00045		GUI_CS_Up,
    00046		GUI_CS_Down
    00047	} OnClickSound;
    00048
    00049	// Style holds a pointer to the GUI style of this component.
    00050
    00051	var			GUIStyles		 Style;						// My GUI Style
    00052
    00053	// Notes about the Top/Left/Width/Height : This is a somewhat hack but it's really good for functionality.  If
    00054	// the value is <=1, then the control is considered to be scaled.  If they are >1 they are considered to be normal world coords.
    00055	// 0 = 0, 1 = 100%
    00056
    00057	var			float		Bounds[4];								// Internal normalized positions in world space
    00058	var			float		ClientBounds[4];						// The bounds of the actual client area (minus any borders)
    00059
    00060	var			bool		bPendingFocus;							// Big big hack for ComboBoxes..
    00061
    00062	// Timer Support
    00063	var const	int			TimerIndex;			// For easier maintenance
    00064	var			bool		bTimerRepeat;
    00065	var			float		TimerCountdown;
    00066	var			float		TimerInterval;
    00067
    00068	// Used for Saving the last state before drawing natively
    00069
    00070	var		float 	SaveX,SaveY;
    00071	var 	color	SaveColor;
    00072	var		font	SaveFont;
    00073	var		byte	SaveStyle;
    00074
    00075	// Delegates
    00076
    00077	// Drawing delegates return true if you want to short-circuit the default drawing code
    00078
    00079	Delegate bool OnPreDraw(Canvas Canvas);
    00080	Delegate bool OnDraw(Canvas Canvas);
    00081
    00082	Delegate OnActivate();													// Called when the component gains focus
    00083	Delegate OnDeActivate();												// Called when the component loses focus
    00084	Delegate OnWatch();														// Called when the component is being watched
    00085	Delegate OnHitTest(float MouseX, float MouseY);							// Called when Hit test is performed for mouse input
    00086	Delegate OnRender(canvas Canvas);										// Called when the component is rendered
    00087	Delegate OnMessage(coerce string Msg, float MsgLife); 					// When a message comes down the line
    00088
    00089	Delegate OnInvalidate();	// Called when the background is clicked
    00090
    00091	// -- Input event delegates
    00092
    00093	Delegate bool OnClick(GUIComponent Sender);			// The mouse was clicked on this control
    00094	Delegate bool OnDblClick(GUIComponent Sender);		// The mouse was double-clicked on this control
    00095	Delegate bool OnRightClick(GUIComponent Sender);	// Control was right clicked.
    00096
    00097	Delegate OnMousePressed(GUIComponent Sender, bool bRepeat);		// Sent when a mouse is pressed (initially)
    00098	Delegate OnMouseRelease(GUIComponent Sender);		// Sent when the mouse is released.
    00099
    00100	Delegate OnChange(GUIComponent Sender);	// Called when a component changes it's value
    00101
    00102	Delegate bool OnKeyType(out byte Key)  	// Key Strokes
    00103	{
    00104		return false;
    00105	}
    00106
    00107	Delegate bool OnKeyEvent(out byte Key, out byte State, float delta)
    00108	{
    00109		return false;
    00110	}
    00111
    00112	Delegate bool OnCapturedMouseMove(float deltaX, float deltaY)
    00113	{
    00114		return false;
    00115	}
    00116
    00117	Delegate OnLoadINI(GUIComponent Sender, string s);		// Do the actual work here
    00118	Delegate string OnSaveINI(GUIComponent Sender); 		// Do the actual work here
    00119
    00120	function PlayerController PlayerOwner()
    00121	{
    00122		return Controller.ViewportOwner.Actor;
    00123	}
    00124
    00125
    00126	event Timer();		// Should be subclassed
    00127
    00128	function native final SetTimer(float Interval, optional bool bRepeat);
    00129	function native final KillTimer();
    00130
    00131	function string LoadINI()
    00132	{
    00133		local string s;
    00134
    00135		if ( (PlayerOwner()==None) || (INIOption=="") )
    00136			return "";
    00137
    00138		if(!(INIOption~="@INTERNAL"))
    00139			s = PlayerOwner().ConsoleCommand("get"@IniOption);
    00140
    00141		if (s=="")
    00142			s = IniDefault;
    00143
    00144		OnLoadINI(Self,s);
    00145
    00146		return s;
    00147	}
    00148
    00149	function SaveINI(string Value)
    00150	{
    00151		local string s;
    00152
    00153		if (INIOption=="")
    00154			return;
    00155
    00156		if (PlayerOwner()==None)
    00157			return;
    00158
    00159		s = OnSaveINI(Self);
    00160		if ( s!="" )
    00161		{
    00162		}
    00163	}
    00164
    00165	function string ParseOption(string URL, string Key, string DefaultVal)
    00166	{
    00167		local string s;
    00168
    00169		if (PlayerOwner()==None)
    00170			return DefaultVal;
    00171
    00172		s = PlayerOwner().Level.Game.ParseOption( URL, Key);
    00173		if (s=="")
    00174			return DefaultVal;
    00175		else
    00176			return s;
    00177	}
    00178
    00179
    00180
    00181	// Functions
    00182
    00183	event MenuStateChange(eMenuState Newstate)
    00184	{
    00185
    00186		// Check for never focus
    00187
    00188		bPendingFocus=false;
    00189
    00190		if (NewState==MSAT_Focused && bNeverFocus)
    00191			NewState = MSAT_Blurry;
    00192
    00193		MenuState = NewState;
    00194
    00195		switch (MenuState)
    00196		{
    00197			case MSAT_Blurry:
    00198				bHasFocus = false;
    00199				OnDeActivate();
    00200				break;
    00201
    00202			case MSAT_Watched:
    00203
    00204				if (bFocusOnWatch)
    00205				{
    00206					SetFocus(None);
    00207					return;
    00208				}
    00209
    00210				OnWatch();
    00211				break;
    00212
    00213			case MSAT_Focused:
    00214				bHasFocus = true;
    00215				OnActivate();
    00216				break;
    00217
    00218		}
    00219
    00220		if (FriendlyLabel!=None)
    00221			FriendlyLabel.MenuState=MenuState;
    00222
    00223	}
    00224
    00225	function InitComponent(GUIController MyController, GUIComponent MyOwner)
    00226	{
    00227
    00228		Controller = MyController;
    00229		MenuOwner = MyOwner;
    00230
    00231		Style = Controller.GetStyle(StyleName);
    00232	}
    00233
    00234	function bool IsInBounds()	// Script version of PerformHitTest
    00235	{
    00236		return ( (Controller.MouseX >= Bounds[0] && Controller.MouseX<=Bounds[2]) && (Controller.MouseY >= Bounds[1] && Controller.MouseY <=Bounds[3]) );
    00237	}
    00238
    00239	function bool IsInClientBounds()
    00240	{
    00241
return ( (Controller.MouseX >= ClientBounds[0] && Controller.MouseX<=ClientBounds[2]) && (Controller.MouseY >= ClientBounds[1] && Controller.MouseY <=ClientBounds[3]) ); 00242 } 00243 00244 event SetFocus(GUIComponent Who) 00245 { 00246 00247 if (MenuState==MSAT_Focused) 00248 return; 00249 00250 if (bNeverFocus) 00251 { 00252 if (FocusInstead != None) 00253 FocusInstead.SetFocus(Who); 00254 00255 return; 00256 } 00257 00258 bPendingFocus = true; 00259 00260 if (Controller.FocusedControl!=None) 00261 Controller.FocusedControl.LoseFocus(None); 00262 00263 Controller.FocusedControl = self; 00264 00265 MenuStateChange(MSAT_Focused); 00266 if (MenuOwner!=None) 00267 MenuOwner.SetFocus(self); 00268 } 00269 00270 event LoseFocus(GUIComponent Sender) 00271 { 00272 if (Controller!=None) 00273 Controller.FocusedControl = None; 00274 //else 00275 // log("GUIComponent::LoseFocus - Control==None"); 00276 00277 MenuStateChange(MSAT_Blurry); 00278 00279 if (MenuOwner!=None) 00280 MenuOwner.LoseFocus(Self); 00281 } 00282 00283 event bool FocusFirst(GUIComponent Sender, bool bIgnoreMultiTabStops) // Focus your first child, or yourself if no childrean 00284 { 00285 if ( (!bVisible) || (bNeverFocus) || (MenuState==MSAT_Disabled) || (!bTabStop) ) 00286 return false; 00287 00288 SetFocus(None); 00289 return true; 00290 } 00291 00292 event bool FocusLast(GUIComponent Sender, bool bIgnoreMultiTabStops) // Focus your last child, or yourself 00293 { 00294 if ( (!bVisible) || (bNeverFocus) || (MenuState==MSAT_Disabled) || (!bTabStop) ) 00295 return false; 00296 00297 SetFocus(None); 00298 return true; 00299 } 00300 00301 event bool NextControl(GUIComponent Sender) 00302 { 00303 if (MenuOwner!=None) 00304 return MenuOwner.NextControl(Self); 00305 00306 return false; 00307 } 00308 00309 event bool PrevControl(GUIComponent Sender) 00310 { 00311 if (MenuOwner!=None) 00312 return MenuOwner.PrevControl(Self); 00313 00314 return false; 00315 } 00316 00317 event bool NextPage() 00318 { 00319 if (MenuOwner != None) 00320 return MenuOwner.NextPage(); 00321 00322 return false; 00323 } 00324 00325 event bool PrevPage() 00326 { 00327 if (MenuOwner != None) 00328 return MenuOwner.PrevPage(); 00329 00330 return false; 00331 } 00332 00333 // Force control to use same area as its MenuOwner. 00334 function FillOwner() 00335 { 00336 WinLeft = 0.0; 00337 WinTop = 0.0; 00338 WinWidth = 1.0; 00339 WinHeight = 1.0; 00340 bScaleToParent = true; 00341 bBoundToParent = true; 00342 } 00343 00344 // The ActualXXXX functions are not viable until after the first render so don't 00345 // use them in inits 00346 native function float ActualWidth(); 00347 native function float ActualHeight(); 00348 native function float ActualLeft(); 00349 native function Float ActualTop(); 00350 00351 00352 00353 defaultproperties 00354 { 00355 bVisible=True 00356 WinWidth=1.000000 00357 Tag=-1 00358 TimerIndex=-1 00359 }

End Source Code