Lua - implement forms.settext()

This commit is contained in:
andres.delikat 2012-07-10 22:27:05 +00:00
parent 4542ae12d1
commit 04273ec3ee
1 changed files with 34 additions and 6 deletions

View File

@ -416,6 +416,7 @@ namespace BizHawk.MultiClient
"textbox",
"setlocation",
"setsize",
"settext",
};
/****************************************************/
@ -1755,6 +1756,14 @@ namespace BizHawk.MultiClient
}
}
private void SetText(Control control, object caption)
{
if (caption != null)
{
control.Text = caption.ToString();
}
}
public int forms_button(object form_handle, object caption, LuaFunction lua_event, object X = null, object Y = null)
{
LuaWinform form = GetForm(form_handle);
@ -1764,7 +1773,7 @@ namespace BizHawk.MultiClient
}
LuaButton button = new LuaButton();
button.Text = caption.ToString();
SetText(button, caption);
form.Controls.Add(button);
form.Control_Events.Add(new LuaWinform.Lua_Event(button.Handle, lua_event));
SetLocation(button, X, Y);
@ -1780,7 +1789,7 @@ namespace BizHawk.MultiClient
}
Label label = new Label();
label.Text = caption.ToString();
SetText(label, caption);
form.Controls.Add(label);
SetLocation(label, X, Y);
return (int)label.Handle;
@ -1795,10 +1804,7 @@ namespace BizHawk.MultiClient
}
TextBox textbox = new TextBox();
if (caption != null)
{
textbox.Text = caption.ToString();
}
SetText(textbox, caption);
SetLocation(textbox, X, Y);
SetSize(textbox, X, Y);
form.Controls.Add(textbox);
@ -1848,5 +1854,27 @@ namespace BizHawk.MultiClient
}
}
}
public void forms_settext(object handle, object caption)
{
IntPtr ptr = new IntPtr(LuaInt(handle));
foreach (LuaWinform form in LuaForms)
{
if (form.Handle == ptr)
{
SetText(form, caption);
}
else
{
foreach (Control control in form.Controls)
{
if (control.Handle == ptr)
{
SetText(control, caption);
}
}
}
}
}
}
}