GUITextBox.cs 2.0 KB

12345678910111213141516171819202122232425262728293031323334353637383940414243444546474849505152535455565758596061
  1. using System;
  2. using System.Runtime.CompilerServices;
  3. namespace BansheeEngine
  4. {
  5. public sealed class GUITextBox : GUIElement
  6. {
  7. public delegate void OnChangedDelegate(string newValue);
  8. public event OnChangedDelegate OnChanged;
  9. public GUITextBox(bool multiline, string style, params GUIOption[] options)
  10. {
  11. Internal_CreateInstance(this, multiline, style, options);
  12. }
  13. public GUITextBox(bool multiline, params GUIOption[] options)
  14. {
  15. Internal_CreateInstance(this, multiline, "", options);
  16. }
  17. public GUITextBox(string style, params GUIOption[] options)
  18. {
  19. Internal_CreateInstance(this, false, style, options);
  20. }
  21. public GUITextBox(params GUIOption[] options)
  22. {
  23. Internal_CreateInstance(this, false, "", options);
  24. }
  25. public string Text
  26. {
  27. get { string value; Internal_GetText(mCachedPtr, out value); return value; }
  28. set { Internal_SetText(mCachedPtr, value); }
  29. }
  30. public void SetTint(Color color)
  31. {
  32. Internal_SetTint(mCachedPtr, color);
  33. }
  34. private void DoOnChanged(string newValue)
  35. {
  36. if (OnChanged != null)
  37. OnChanged(newValue);
  38. }
  39. [MethodImpl(MethodImplOptions.InternalCall)]
  40. private static extern void Internal_CreateInstance(GUITextBox instance, bool multiline, string style, GUIOption[] options);
  41. [MethodImpl(MethodImplOptions.InternalCall)]
  42. private static extern void Internal_SetText(IntPtr nativeInstance, string text);
  43. [MethodImpl(MethodImplOptions.InternalCall)]
  44. private static extern void Internal_GetText(IntPtr nativeInstance, out string text);
  45. [MethodImpl(MethodImplOptions.InternalCall)]
  46. private static extern void Internal_SetTint(IntPtr nativeInstance, Color color);
  47. }
  48. }