UWindow
Class UWindowButton

source: c:\runehov\UWindow\Classes\UWindowButton.uc
Core.Object
   |
   +--UWindow.UWindowBase
      |
      +--UWindow.UWindowWindow
         |
         +--UWindow.UWindowDialogControl
            |
            +--UWindow.UWindowButton
Direct Known Subclasses:RuneMenuHotlinkControl, RuneMenuRaisedButton, UBrowserBrowserButton, 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		{
00113			if (GetPlayerOwner()!=None)
00114			{
00115				if (GetPlayerOwner().ViewTarget != None)
00116					GetPlayerOwner().ViewTarget.PlaySound(OverSound, SLOT_Interface);
00117				else
00118					GetPlayerOwner().PlaySound(OverSound, SLOT_Interface);
00119			}
00120		}
00121	}
00122	
00123	simulated function Click(float X, float Y) 
00124	{
00125		Notify(DE_Click);
00126		if (!bDisabled && (DownSound != None))
00127		{
00128			if (GetPlayerOwner()!=None)
00129			{
00130				if (GetPlayerOwner().ViewTarget != None)
00131					GetPlayerOwner().ViewTarget.PlaySound(DownSound, SLOT_Interact);
00132				else
00133					GetPlayerOwner().PlaySound(DownSound, SLOT_Interact);
00134			}
00135		}
00136	}
00137	
00138	function DoubleClick(float X, float Y) 
00139	{
00140		Notify(DE_DoubleClick);
00141	}
00142	
00143	function RClick(float X, float Y) 
00144	{
00145		Notify(DE_RClick);
00146	}
00147	
00148	function MClick(float X, float Y) 
00149	{
00150		Notify(DE_MClick);
00151	}
00152	
00153	function KeyDown(int Key, float X, float Y)
00154	{
00155		local PlayerPawn P;
00156	
00157		P = Root.GetPlayerOwner();
00158	
00159		switch (Key)
00160		{
00161		case P.EInputKey.IK_Space:
00162			LMouseDown(X, Y);
00163			LMouseUp(X, Y);
00164			break;
00165		default:
00166			Super.KeyDown(Key, X, Y);
00167			break;
00168		}
00169	}
00170	
00171	defaultproperties
00172	{
00173	     bIgnoreLDoubleClick=True
00174	     bIgnoreMDoubleClick=True
00175	     bIgnoreRDoubleClick=True
00176	}

End Source Code