BsGUITextField.h 2.7 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081
  1. #pragma once
  2. #include "BsEditorPrerequisites.h"
  3. #include "BsGUIElementContainer.h"
  4. namespace BansheeEngine
  5. {
  6. class BS_ED_EXPORT GUITextField : public GUIElementContainer
  7. {
  8. struct PrivatelyConstruct {};
  9. public:
  10. static const String& getLabelStyleType();
  11. static const String& getGUITypeName();
  12. static const String& getInputStyleType();
  13. static GUITextField* create(bool multiline, const GUIContent& labelContent, UINT32 labelWidth, const GUIOptions& layoutOptions,
  14. const String& style = StringUtil::BLANK);
  15. static GUITextField* create(bool multiline, const GUIContent& labelContent, const GUIOptions& layoutOptions,
  16. const String& style = StringUtil::BLANK);
  17. static GUITextField* create(bool multiline, const HString& labelText, UINT32 labelWidth, const GUIOptions& layoutOptions,
  18. const String& style = StringUtil::BLANK);
  19. static GUITextField* create(bool multiline, const HString& labelText, const GUIOptions& layoutOptions,
  20. const String& style = StringUtil::BLANK);
  21. static GUITextField* create(bool multiline, const GUIOptions& layoutOptions, const String& style = StringUtil::BLANK);
  22. static GUITextField* create(bool multiline, const GUIContent& labelContent, UINT32 labelWidth,
  23. const String& style = StringUtil::BLANK);
  24. static GUITextField* create(bool multiline, const GUIContent& labelContent,
  25. const String& style = StringUtil::BLANK);
  26. static GUITextField* create(bool multiline, const HString& labelText, UINT32 labelWidth,
  27. const String& style = StringUtil::BLANK);
  28. static GUITextField* create(bool multiline, const HString& labelText,
  29. const String& style = StringUtil::BLANK);
  30. static GUITextField* create(bool multiline, const String& style = StringUtil::BLANK);
  31. GUITextField(const PrivatelyConstruct& dummy, bool multiline, const GUIContent& labelContent, UINT32 labelWidth,
  32. const String& style, const GUILayoutOptions& layoutOptions, bool withLabel);
  33. void _updateLayoutInternal(INT32 x, INT32 y, UINT32 width, UINT32 height,
  34. Rect2I clipRect, UINT8 widgetDepth, UINT16 areaDepth);
  35. Vector2I _getOptimalSize() const;
  36. WString getValue() const { return mValue; }
  37. void setValue(const WString& value);
  38. bool hasInputFocus() const { return mHasInputFocus; }
  39. /**
  40. * @copydoc GUIElement::setTint
  41. */
  42. virtual void setTint(const Color& color);
  43. Event<void(const WString&)> onValueChanged;
  44. protected:
  45. static const UINT32 DEFAULT_LABEL_WIDTH;
  46. virtual ~GUITextField();
  47. void styleUpdated();
  48. void valueChanged(const WString& newValue);
  49. void focusGained();
  50. void focusLost();
  51. GUIInputBox* mInputBox;
  52. GUILayout* mLayout;
  53. GUILabel* mLabel;
  54. bool mHasInputFocus;
  55. WString mValue;
  56. };
  57. }