using Chernobyl.Collections.Generic.Event; using Chernobyl.Dependency; using Chernobyl.Graphics; using Chernobyl.Graphics.Drawing; using Chernobyl.Graphics.Texture; using Chernobyl.Graphics.Writing; using Chernobyl.Interface.Writing; using Chernobyl.Mathematics.Movement; namespace Chernobyl.Interface { /// /// A 2D box that contains characters that can be edited. /// public class EditBox : Sprite { /// /// Initializes a new instance of the class that /// uses a default background. /// /// The services instance that takes and receives /// services. public EditBox(IEventCollection services) : this(services, null) { } /// /// Initializes a new instance of the class. /// /// The services instance that takes and receives /// services. /// The texture to apply to the background of /// the edit box or null if a default background should be used. public EditBox(IEventCollection services, ITexture background) : base(services, background ?? new Texture2D(services, ColorRgba.White)) { ScaleX(100.0f); ScaleY(25.0f); Text = new Text(services); Transform.MakeParentChild(NoScaleTransform, Text); TextCursor textCursor = new TextCursor(services, Text); TextConstraint textConstraint = new TextConstraint(services, this, Text); TextEditor textEditor = new TextEditor(services, Text); // give the edit box some default borders Borders = new Borders(services); services.Inject(this); } /// /// The instance used to display text on this EditBox. /// public IText Text { get; private set; } /// /// The borders on this . By default, this button /// is given borders along all it's edges. Note: you do not need to /// parent this Button with the new Border or un-parent the old border; /// this property will do that for you. /// public Borders Borders { get { return _borders; } set { if (_borders != null) Transform.SeperateParentChild(this, _borders); _borders = value; Transform.MakeParentChild(this, _borders); } } /// /// The that the text should be rendered in. /// [Inject] public Scene Scene { set { Text.DrawableParent = value.Draw3D; } } /// /// The backing field to . /// Borders _borders; } }