UWindow
Class UWindowButton

source: e:\games\UnrealTournament\UWindow\Classes\UWindowButton.uc
Core.Object
   |
   +--UWindow.UWindowBase
      |
      +--UWindow.UWindowWindow
         |
         +--UWindow.UWindowDialogControl
            |
            +--UWindow.UWindowButton
Direct Known Subclasses:UBrowserBrowserButton, UMenuRaisedButton, MatchButton, NotifyButton, UWindowCheckbox, UWindowComboButton, UWindowComboLeftButton, UWindowComboRightButton, UWindowFrameCloseBox, UWindowSBDownButton, UWindowSBLeftButton, UWindowSBRightButton, UWindowSBUpButton, UWindowSmallButton, UWindowSmallCancelButton, UWindowTabControlLeftButton, UWindowTabControlRightButton

class UWindowButton
extends UWindow.UWindowDialogControl

//============================================================================= // UWindowButton - A button //=============================================================================
Variables
 OverSound, DownSound
 ImageX, ImageY
 DisabledRegion, OverRegion
 DisabledTexture, OverTexture
 float RegionScale
 string ToolTipString
 bool bDisabled
 bool bStretched
 bool bUseRegion


Function Summary
 void BeforePaint(Canvas C, float X, float Y)
 
simulated
Click(float X, float Y)
 void Created()
 void DoubleClick(float X, float Y)
 void KeyDown(int Key, float X, float Y)
 void MClick(float X, float Y)
 
simulated
MouseEnter()
 void MouseLeave()
 void Paint(Canvas C, float X, float Y)
 void RClick(float X, float Y)



Source Code


00001	//=============================================================================
00002	// UWindowButton - A button
00003	//=============================================================================
00004	class UWindowButton extends UWindowDialogControl;
00005	
00006	var bool		bDisabled;
00007	var bool		bStretched;
00008	var texture		UpTexture, DownTexture, DisabledTexture, OverTexture;
00009	var Region		UpRegion,  DownRegion,  DisabledRegion,  OverRegion;
00010	var bool		bUseRegion;
00011	var float		RegionScale;
00012	var string		ToolTipString;
00013	var float		ImageX, ImageY;
00014	var sound		OverSound, DownSound;
00015	
00016	function Created()
00017	{
00018		Super.Created();
00019	
00020		ImageX = 0;
00021		ImageY = 0;
00022		TextX = 0;
00023		TextY = 0;
00024		RegionScale = 1;
00025	}
00026	
00027	function BeforePaint(Canvas C, float X, float Y)
00028	{
00029		C.Font = Root.Fonts[Font];
00030	}
00031	
00032	function Paint(Canvas C, float X, float Y)
00033	{
00034		C.Font = Root.Fonts[Font];
00035	
00036		if(bDisabled) {
00037			if(DisabledTexture != None)
00038			{
00039				if(bUseRegion)
00040					DrawStretchedTextureSegment( C, ImageX, ImageY, DisabledRegion.W*RegionScale, DisabledRegion.H*RegionScale, 
00041												DisabledRegion.X, DisabledRegion.Y, 
00042												DisabledRegion.W, DisabledRegion.H, DisabledTexture );
00043				else if(bStretched)
00044					DrawStretchedTexture( C, ImageX, ImageY, WinWidth, WinHeight, DisabledTexture );
00045				else
00046					DrawClippedTexture( C, ImageX, ImageY, DisabledTexture);
00047			}
00048		} else {
00049			if(bMouseDown)
00050			{
00051				if(DownTexture != None)
00052				{
00053					if(bUseRegion)
00054						DrawStretchedTextureSegment( C, ImageX, ImageY, DownRegion.W*RegionScale, DownRegion.H*RegionScale, 
00055													DownRegion.X, DownRegion.Y, 
00056													DownRegion.W, DownRegion.H, DownTexture );
00057					else if(bStretched)
00058						DrawStretchedTexture( C, ImageX, ImageY, WinWidth, WinHeight, DownTexture );
00059					else
00060						DrawClippedTexture( C, ImageX, ImageY, DownTexture);
00061				}
00062			} else {
00063				if(MouseIsOver()) {
00064					if(OverTexture != None)
00065					{
00066						if(bUseRegion)
00067							DrawStretchedTextureSegment( C, ImageX, ImageY, OverRegion.W*RegionScale, OverRegion.H*RegionScale, 
00068														OverRegion.X, OverRegion.Y, 
00069														OverRegion.W, OverRegion.H, OverTexture );
00070						else if(bStretched)
00071							DrawStretchedTexture( C, ImageX, ImageY, WinWidth, WinHeight, OverTexture );
00072						else
00073							DrawClippedTexture( C, ImageX, ImageY, OverTexture);
00074					}
00075				} else {
00076					if(UpTexture != None)
00077					{
00078						if(bUseRegion)
00079							DrawStretchedTextureSegment( C, ImageX, ImageY, UpRegion.W*RegionScale, UpRegion.H*RegionScale, 
00080														UpRegion.X, UpRegion.Y, 
00081														UpRegion.W, UpRegion.H, UpTexture );
00082						else if(bStretched)
00083							DrawStretchedTexture( C, ImageX, ImageY, WinWidth, WinHeight, UpTexture );
00084						else
00085							DrawClippedTexture( C, ImageX, ImageY, UpTexture);
00086					}
00087				}
00088			}
00089		}
00090	
00091		if(Text != "")
00092		{
00093			C.DrawColor = TextColor;
00094			ClipText(C, TextX, TextY, Text, True);
00095			C.DrawColor.R = 255;
00096			C.DrawColor.G = 255;
00097			C.DrawColor.B = 255;
00098		}
00099	}
00100	
00101	function MouseLeave()
00102	{
00103		Super.MouseLeave();
00104		if(ToolTipString != "") ToolTip("");
00105	}
00106	
00107	simulated function MouseEnter()
00108	{
00109		Super.MouseEnter();
00110		if(ToolTipString != "") ToolTip(ToolTipString);
00111		if (!bDisabled && (OverSound != None))
00112			GetPlayerOwner().PlaySound(OverSound, SLOT_Interface);
00113	}
00114	
00115	simulated function Click(float X, float Y) 
00116	{
00117		Notify(DE_Click);
00118		if (!bDisabled && (DownSound != None))
00119			GetPlayerOwner().PlaySound(DownSound, SLOT_Interact);
00120	}
00121	
00122	function DoubleClick(float X, float Y) 
00123	{
00124		Notify(DE_DoubleClick);
00125	}
00126	
00127	function RClick(float X, float Y) 
00128	{
00129		Notify(DE_RClick);
00130	}
00131	
00132	function MClick(float X, float Y) 
00133	{
00134		Notify(DE_MClick);
00135	}
00136	
00137	function KeyDown(int Key, float X, float Y)
00138	{
00139		local PlayerPawn P;
00140	
00141		P = Root.GetPlayerOwner();
00142	
00143		switch (Key)
00144		{
00145		case P.EInputKey.IK_Space:
00146			LMouseDown(X, Y);
00147			LMouseUp(X, Y);
00148			break;
00149		default:
00150			Super.KeyDown(Key, X, Y);
00151			break;
00152		}
00153	}
00154	
00155	defaultproperties
00156	{
00157	     bIgnoreLDoubleClick=True
00158	     bIgnoreMDoubleClick=True
00159	     bIgnoreRDoubleClick=True
00160	}

End Source Code