Core.Object | +--UWindow.UWindowBase | +--UWindow.UWindowWindow | +--UWindow.UWindowClientWindow | +--UWindow.UWindowDialogClientWindow | +--UWindow.UWindowMessageBoxCW
MessageBoxButtons
Buttons
OKButton,
CancelButton
OKText,
CancelText
MessageBoxResult
EnterResult
UWindowMessageBoxArea
MessageArea
void
BeforePaint(Canvas C, float X, float Y)
Created()
float
GetHeight(Canvas C)
KeyDown(int Key, float X, float Y)
Notify(UWindowDialogControl C, byte E)
Paint(Canvas C, float X, float Y)
Resized()
SetupMessageBoxClient(string InMessage, MessageBoxButtons InButtons, MessageBoxResult InEnterResult)
00001 class UWindowMessageBoxCW expands UWindowDialogClientWindow; 00002 00003 var MessageBoxButtons Buttons; 00004 00005 var MessageBoxResult EnterResult; 00006 var UWindowSmallButton YesButton, NoButton, OKButton, CancelButton; 00007 var localized string YesText, NoText, OKText, CancelText; 00008 var UWindowMessageBoxArea MessageArea; 00009 00010 function Created() 00011 { 00012 Super.Created(); 00013 SetAcceptsFocus(); 00014 00015 MessageArea = UWindowMessageBoxArea(CreateWindow(class'UWindowMessageBoxArea', 10, 10, WinWidth-20, WinHeight-44)); 00016 } 00017 00018 function KeyDown(int Key, float X, float Y) 00019 { 00020 local UWindowMessageBox P; 00021 00022 P = UWindowMessageBox(ParentWindow); 00023 00024 if(Key == GetPlayerOwner().EInputKey.IK_Enter && EnterResult != MR_None) 00025 { 00026 P = UWindowMessageBox(ParentWindow); 00027 P.Result = EnterResult; 00028 P.Close(); 00029 } 00030 } 00031 00032 function BeforePaint(Canvas C, float X, float Y) 00033 { 00034 Super.BeforePaint(C, X, Y); 00035 00036 MessageArea.SetSize(WinWidth-20, WinHeight-44); 00037 00038 switch(Buttons) 00039 { 00040 case MB_YesNoCancel: 00041 CancelButton.WinLeft = WinWidth - 52; 00042 CancelButton.WinTop = WinHeight - 20; 00043 NoButton.WinLeft = WinWidth - 104; 00044 NoButton.WinTop = WinHeight - 20; 00045 YesButton.WinLeft = WinWidth - 156; 00046 YesButton.WinTop = WinHeight - 20; 00047 break; 00048 case MB_YesNo: 00049 NoButton.WinLeft = WinWidth - 52; 00050 NoButton.WinTop = WinHeight - 20; 00051 YesButton.WinLeft = WinWidth - 104; 00052 YesButton.WinTop = WinHeight - 20; 00053 break; 00054 case MB_OKCancel: 00055 CancelButton.WinLeft = WinWidth - 52; 00056 CancelButton.WinTop = WinHeight - 20; 00057 OKButton.WinLeft = WinWidth - 104; 00058 OKButton.WinTop = WinHeight - 20; 00059 break; 00060 case MB_OK: 00061 OKButton.WinLeft = WinWidth - 52; 00062 OKButton.WinTop = WinHeight - 20; 00063 break; 00064 } 00065 } 00066 00067 function Resized() 00068 { 00069 Super.Resized(); 00070 MessageArea.SetSize(WinWidth-20, WinHeight-44); 00071 } 00072 00073 function float GetHeight(Canvas C) 00074 { 00075 return 44 + MessageArea.GetHeight(C); 00076 } 00077 00078 function Paint(Canvas C, float X, float Y) 00079 { 00080 local Texture T; 00081 Super.Paint(C, X, Y); 00082 T = GetLookAndFeelTexture(); 00083 DrawUpBevel( C, 0, WinHeight-24, WinWidth, 24, T); 00084 } 00085 00086 function SetupMessageBoxClient(string InMessage, MessageBoxButtons InButtons, MessageBoxResult InEnterResult) 00087 { 00088 MessageArea.Message = InMessage; 00089 Buttons = InButtons; 00090 EnterResult = InEnterResult; 00091 00092 // Create buttons 00093 switch(Buttons) 00094 { 00095 case MB_YesNoCancel: 00096 CancelButton = UWindowSmallButton(CreateControl(class'UWindowSmallButton', WinWidth - 52, WinHeight - 20, 48, 16)); 00097 CancelButton.SetText(CancelText); 00098 if(EnterResult == MR_Cancel) 00099 CancelButton.SetFont(F_Bold); 00100 else 00101 CancelButton.SetFont(F_Normal); 00102 NoButton = UWindowSmallButton(CreateControl(class'UWindowSmallButton', WinWidth - 104, WinHeight - 20, 48, 16)); 00103 NoButton.SetText(NoText); 00104 if(EnterResult == MR_No) 00105 NoButton.SetFont(F_Bold); 00106 else 00107 NoButton.SetFont(F_Normal); 00108 YesButton = UWindowSmallButton(CreateControl(class'UWindowSmallButton', WinWidth - 156, WinHeight - 20, 48, 16)); 00109 YesButton.SetText(YesText); 00110 if(EnterResult == MR_Yes) 00111 YesButton.SetFont(F_Bold); 00112 else 00113 YesButton.SetFont(F_Normal); 00114 break; 00115 case MB_YesNo: 00116 NoButton = UWindowSmallButton(CreateControl(class'UWindowSmallButton', WinWidth - 52, WinHeight - 20, 48, 16)); 00117 NoButton.SetText(NoText); 00118 if(EnterResult == MR_No) 00119 NoButton.SetFont(F_Bold); 00120 else 00121 NoButton.SetFont(F_Normal); 00122 YesButton = UWindowSmallButton(CreateControl(class'UWindowSmallButton', WinWidth - 104, WinHeight - 20, 48, 16)); 00123 YesButton.SetText(YesText); 00124 if(EnterResult == MR_Yes) 00125 YesButton.SetFont(F_Bold); 00126 else 00127 YesButton.SetFont(F_Normal); 00128 break; 00129 case MB_OKCancel: 00130 CancelButton = UWindowSmallButton(CreateControl(class'UWindowSmallButton', WinWidth - 52, WinHeight - 20, 48, 16)); 00131 CancelButton.SetText(CancelText); 00132 if(EnterResult == MR_Cancel) 00133 CancelButton.SetFont(F_Bold); 00134 else 00135 CancelButton.SetFont(F_Normal); 00136 OKButton = UWindowSmallButton(CreateControl(class'UWindowSmallButton', WinWidth - 104, WinHeight - 20, 48, 16)); 00137 OKButton.SetText(OKText); 00138 if(EnterResult == MR_OK) 00139 OKButton.SetFont(F_Bold); 00140 else 00141 OKButton.SetFont(F_Normal); 00142 break; 00143 case MB_OK: 00144 OKButton = UWindowSmallButton(CreateControl(class'UWindowSmallButton', WinWidth - 52, WinHeight - 20, 48, 16)); 00145 OKButton.SetText(OKText); 00146 if(EnterResult == MR_OK) 00147 OKButton.SetFont(F_Bold); 00148 else 00149 OKButton.SetFont(F_Normal); 00150 break; 00151 } 00152 } 00153 00154 function Notify(UWindowDialogControl C, byte E) 00155 { 00156 local UWindowMessageBox P; 00157 00158 P = UWindowMessageBox(ParentWindow); 00159 00160 if(E == DE_Click) 00161 { 00162 switch(C) 00163 { 00164 case YesButton: 00165 P.Result = MR_Yes; 00166 P.Close(); 00167 break; 00168 case NoButton: 00169 P.Result = MR_No; 00170 P.Close(); 00171 break; 00172 case OKButton: 00173 P.Result = MR_OK; 00174 P.Close(); 00175 break; 00176 case CancelButton: 00177 P.Result = MR_Cancel; 00178 P.Close(); 00179 break; 00180 } 00181 } 00182 } 00183 00184 defaultproperties 00185 { 00186 YesText="Yes" 00187 NoText="No" 00188 OKText="OK" 00189 CancelText="Cancel" 00190 }