## XIDInterf
Class XIIICheckBoxControl

source: C:\XIII\XIDInterf\Classes\XIIICheckBoxControl.uc

    Core.Object
       |
       +--GUI.GUI
          |
          +--GUI.GUIComponent
             |
             +--GUI.GUILabel
                |
                +--XIDInterf.XIIIGUIBaseButton
                   |
                   +--XIDInterf.XIIICheckBoxControl

Direct Known Subclasses:None

class XIIICheckBoxControl
extends XIDInterf.XIIIGUIBaseButton

Variables
`FirstBoxWidth,` | `SecondBoxWidth`
`WYes,` | `WNo`
`bool` | `bCalculateSize`
`bMouseOnYes,` | `bMouseOnNo`
`bool` | `bWhiteColorOnlyWhenFocused`
`sYes,` | `sNo`

Function Summary
`void` | `BeforePaint(Canvas C, float X, float Y)`
`void` | `InitComponent(GUIController MyController, GUIComponent MyOwner)`
`bool` | `InternalOnKeyEvent(out byte, out byte, float delta)`
`void` | `Paint(Canvas C, float X, float Y)`

Source Code

    00001	class XIIICheckBoxControl extends XIIIGUIBaseButton;
    00002
    00003	var bool bChecked, bMouseOnYes, bMouseOnNo;
    00004	var float TextY, W, H, WYes, WNo;
    00005	var localized string sYes, sNo;
    00006	var bool bCalculateSize;
    00007	var float FirstBoxWidth, SecondBoxWidth;
    00008	var bool bWhiteColorOnlyWhenFocused;
    00009
    00010
    00011	function InitComponent(GUIController MyController, GUIComponent MyOwner)
    00012	{
    00013		Super.Initcomponent(MyController, MyOwner);
    00014	    OnKeyEvent=InternalOnKeyEvent;
    00015	}
    00016
    00017	function BeforePaint(Canvas C, float X, float Y)
    00018	{
    00019		if ( bCalculateSize )
    00020		{
    00021			// no resize, we use default values for boxes
    00022			FirstBoxWidth = WinWidth*640*fRatioX/2;
    00023			SecondBoxWidth = WinWidth*640*fRatioX/5;
    00024		}
    00025		else
    00026		{
    00027			// boxes sizes are defined differently
    00028			SecondBoxWidth = (WinWidth*640*fRatioX - FirstBoxWidth - 32*fRatioX)/2;
    00029		}
    00030
    00031		C.TextSize(/*Caps*/(Text), W, H);
    00032	    C.TextSize(/*Caps*/(sYes), WYes, H);
    00033	    C.TextSize(/*Caps*/(sNo), WNo, H);
    00034
    00035		if ((W > FirstBoxWidth) || bSmallFont)
    00036		{
    00037			C.Font = font'XIIIFonts.XIIIConsoleFont';
    00038			C.TextSize(/*Caps*/(Text), W, H);
    00039			bSmallFont = true;
    00040		}
    00041
    00042	    TextY = (WinHeight*480*fRatioY-H)/2;
    00043
    00044		if ( (Controller.MouseX >= Bounds[0]) && (Controller.MouseX<=Bounds[2]) )
    00045		{
    00046			if ((Controller.MouseX-Bounds[0] >= (FirstBoxWidth + 16*fRatioX)) && (Controller.MouseX-Bounds[0] <= (FirstBoxWidth + SecondBoxWidth + 16*fRatioX)))
    00047			{
    00048				bMouseOnYes = true;
    00049			}
    00050			else if ((Controller.MouseX-Bounds[0] >= (FirstBoxWidth + SecondBoxWidth + 32*fRatioX)) && (Controller.MouseX-Bounds[0] <= WinWidth*640*fRatioX))
    00051			{
    00052				bMouseOnNo = true;
    00053			}
    00054			else
    00055			{
    00056				bMouseOnNo = false;
    00057				bMouseOnYes = false;
    00058			}
    00059		}
    00060	}
    00061
    00062
    00063	function Paint(Canvas C, float X, float Y)
    00064	{
    00065	    local float XPos;
    00066
    00067		C.Style = 5;
    00068
    00069		if ((bVisible && bNeverFocus) || (bVisible && bWhiteColorOnlyWhenFocused))
    00070			BackColor.A = 128;
    00071		else
    00072			BackColor.A = 255;
    00073
    00074		if (bHasFocus)
    00075			BackColor.A = 255;
    00076
    00077		Super.Paint(C, X, Y);
    00078
    00079		C.bUseBorder = true;
    00080		C.DrawColor = BackColor;
    00081		DrawStretchedTexture(C, 0, 0, FirstBoxWidth, WinHeight, myRoot.FondMenu);
    00082		C.DrawColor = DarkColor;
    00083		if (bSmallFont)
    00084			C.Font = font'XIIIFonts.XIIIConsoleFont';
    00085		C.SetPos((FirstBoxWidth - W)/2,TextY);
    00086		C.DrawText(/*Caps*/(Text), false);
    00087
    00088		C.DrawColor = BackColor;
    00089		if (!bChecked)
    00090			C.DrawColor.A = 127;
    00091		else
    00092			if (!bNeverFocus)
    00093				C.DrawColor.A = 255;
    00094		DrawStretchedTexture(C, FirstBoxWidth + 16*fRatioX, 0, SecondBoxWidth, WinHeight, myRoot.FondMenu);
    00095		if (bChecked)
    00096			C.DrawColor.A = 127;
    00097		else
    00098			if (!bNeverFocus)
    00099				C.DrawColor.A = 255;
    00100		DrawStretchedTexture(C, FirstBoxWidth + SecondBoxWidth + 32*fRatioX, 0, SecondBoxWidth, WinHeight, myRoot.FondMenu);
    00101		C.DrawColor = DarkColor;
    00102		C.Font = font'XIIIFonts.PoliceF16';
    00103		if (bSmallFont)
    00104		{
    00105			C.TextSize(/*Caps*/(sNo), W, H);
    00106			TextY = (WinHeight*480*fRatioY-H)/2;
    00107		}
    00108		C.SetPos(FirstBoxWidth + 16*fRatioX + (SecondBoxWidth - WYes)/2,TextY);
    00109		C.DrawText(/*Caps*/(sYes), false);
    00110		C.SetPos(FirstBoxWidth + SecondBoxWidth + 32*fRatioX + (SecondBoxWidth - WNo)/2,TextY);
    00111		C.DrawText(/*Caps*/(sNo), false);
    00112		C.bUseBorder = false;
    00113		C.Style = 1;
    00114	}
    00115
    00116
    00117	function bool InternalOnKeyEvent(out byte Key, out byte State, float delta)
    00118	{
    00119	    if (Key == 0x01)
    00120		{
    00121			if (bMouseOnNo)
    00122				bChecked = false;
    00123			if (bMouseOnYes)
    00124				bChecked = true;
    00125	    }
    00126	    return false;
    00127	}
    00128
    00129
    00130
    00131	defaultproperties
    00132	{
    00133	     sYes="Yes"
    00134	     sNo="No"
    00135	     bCalculateSize=True
    00136	}

End Source Code