Example #1
0
        public TextBox(Base parent)
            : base(parent)
        {
            int row = 0;

            m_Font1 = new Font(Skin.Renderer, "Consolas", 14);             // fixed width font!
            m_Font2 = new Font(Skin.Renderer, "Impact", 50);
            m_Font3 = new Font(Skin.Renderer, "Arial", 14);

            /* Vanilla Textbox */
            {
                Control.TextBox textbox = new Control.TextBox(this);
                textbox.SetText("Type something here");
                textbox.SetPosition(10, 10 + 25 * row);
                textbox.TextChanged   += OnEdit;
                textbox.SubmitPressed += OnSubmit;
                row++;
            }

            /* Multiline Textbox */
            {
                Control.MultilineTextBox textbox = new Control.MultilineTextBox(this);
                textbox.Font       = m_Font1;
                textbox.AcceptTabs = true;
                textbox.SetText("using System;\npublic class Test {\n\tpublic static void Main(){\n\t\tConsole.WriteLine(\"Hello World\");\n\t}\n}");
                textbox.SetPosition(220, 10);
                textbox.SetSize(500, 150);
            }

            {
                Control.TextBoxPassword textbox = new Control.TextBoxPassword(this);
                //textbox.MaskCharacter = '@';
                textbox.SetText("secret");
                textbox.TextChanged += OnEdit;
                textbox.SetPosition(10, 10 + 25 * row);
                row++;
            }

            {
                Control.TextBox textbox = new Control.TextBox(this);
                textbox.SetText("Select All Text On Focus");
                textbox.SetPosition(10, 10 + 25 * row);
                textbox.SelectAllOnFocus = true;
                row++;
            }

            {
                Control.TextBox textbox = new Control.TextBox(this);
                textbox.SetText("Different Coloured Text, for some reason");
                textbox.TextColor = Color.ForestGreen;
                textbox.SetPosition(10, 10 + 25 * row);
                row++;
            }

            {
                Control.TextBox textbox = new Control.TextBoxNumeric(this);
                textbox.SetText("200456698");
                textbox.TextColor = Color.LightCoral;
                textbox.SetPosition(10, 10 + 25 * row);
                row++;
            }

            row++;

            {
                Control.TextBox textbox = new Control.TextBox(this);
                textbox.SetText("OOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOO");
                textbox.TextColor = Color.Black;
                textbox.SetPosition(10, 10 + 28 * row);
                textbox.Font = m_Font3;
                textbox.SizeToContents();
                row++;
            }

            {
                Control.TextBox textbox = new Control.TextBox(this);
                textbox.SetText("..............................................................");
                textbox.TextColor = Color.Black;
                textbox.SetPosition(10, 10 + 28 * row);
                textbox.Font = m_Font3;
                textbox.SizeToContents();
                row++;
            }

            {
                Control.TextBox textbox = new Control.TextBox(this);
                textbox.SetText("public override void SetText(string str, bool doEvents = true)");
                textbox.TextColor = Color.Black;
                textbox.SetPosition(10, 10 + 28 * row);
                textbox.Font = m_Font3;
                textbox.SizeToContents();
                row++;
            }

            {
                Control.TextBox textbox = new Control.TextBox(this);
                textbox.SetText("あおい うみから やってきた");
                textbox.TextColor = Color.Black;
                textbox.SetPosition(10, 10 + 28 * row);
                textbox.Font = m_Font3;
                textbox.SizeToContents();
                row++;
            }

            row++;

            {
                Control.TextBox textbox = new Control.TextBox(this);
                textbox.SetText("OOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOO");
                textbox.TextColor = Color.Black;
                textbox.SetPosition(10, 10 + 28 * row);
                textbox.Font = m_Font1;
                textbox.SizeToContents();
                row++;
            }

            {
                Control.TextBox textbox = new Control.TextBox(this);
                textbox.SetText("..............................................................");
                textbox.TextColor = Color.Black;
                textbox.SetPosition(10, 10 + 28 * row);
                textbox.Font = m_Font1;
                textbox.SizeToContents();
                row++;
            }

            {
                Control.TextBox textbox = new Control.TextBox(this);
                textbox.SetText("public override void SetText(string str, bool doEvents = true)");
                textbox.TextColor = Color.Black;
                textbox.SetPosition(10, 10 + 28 * row);
                textbox.Font = m_Font1;
                textbox.SizeToContents();
                row++;
            }

            {
                Control.TextBox textbox = new Control.TextBox(this);
                textbox.SetText("あおい うみから やってきた");
                textbox.TextColor = Color.Black;
                textbox.SetPosition(10, 10 + 28 * row);
                textbox.Font = m_Font1;
                textbox.SizeToContents();
                row++;
            }

            row++;

            {
                Control.TextBox textbox = new Control.TextBox(this);
                textbox.SetText("Different Font (autosized)");
                textbox.SetPosition(10, 10 + 28 * row);
                textbox.Font = m_Font2;
                textbox.SizeToContents();

                row += 2;
            }
        }
Example #2
0
        public TextBox(ControlBase parent)
            : base(parent)
        {
            m_Font1          = Skin.DefaultFont.Copy();
            m_Font1.FaceName = "Courier New";             // fixed width font!

            m_Font2          = Skin.DefaultFont.Copy();
            m_Font2.FaceName = "Times New Roman";
            m_Font2.Size    *= 3;

            m_Font3       = Skin.DefaultFont.Copy();
            m_Font3.Size += 5;

            VerticalLayout vlayout = new VerticalLayout(this);
            {
                DockLayout dockLayout = new DockLayout(vlayout);
                {
                    VerticalLayout vlayout2 = new VerticalLayout(dockLayout);
                    vlayout2.Dock  = Dock.Left;
                    vlayout2.Width = 200;
                    {
                        /* Vanilla Textbox */
                        {
                            Control.TextBox textbox = new Control.TextBox(vlayout2);
                            textbox.Margin = Margin.Five;
                            textbox.SetText("Type something here");
                            textbox.TextChanged   += OnEdit;
                            textbox.SubmitPressed += OnSubmit;
                        }

                        {
                            Control.TextBoxPassword textbox = new Control.TextBoxPassword(vlayout2);
                            textbox.Margin = Margin.Five;
                            //textbox.MaskCharacter = '@';
                            textbox.SetText("secret");
                            textbox.TextChanged += OnEdit;
                        }

                        {
                            Control.TextBox textbox = new Control.TextBox(vlayout2);
                            textbox.Margin = Margin.Five;
                            textbox.SetText("Select All Text On Focus");
                            textbox.SelectAllOnFocus = true;
                        }

                        {
                            Control.TextBox textbox = new Control.TextBox(vlayout2);
                            textbox.Margin = Margin.Five;
                            textbox.SetText("Different Coloured Text, for some reason");
                            textbox.TextColor = Color.Green;
                        }

                        {
                            Control.TextBox textbox = new Control.TextBoxNumeric(vlayout2);
                            textbox.Margin = Margin.Five;
                            textbox.SetText("200456698");
                            textbox.TextColor = Color.Red;
                        }
                    }

                    /* Multiline Textbox */
                    {
                        Control.MultilineTextBox textbox = new Control.MultilineTextBox(dockLayout);
                        textbox.Dock       = Dock.Fill;
                        textbox.Margin     = Margin.Five;
                        textbox.Font       = m_Font1;
                        textbox.AcceptTabs = true;
                        textbox.SetText("In olden times when wishing still helped one, there lived a king whose daughters were all beautiful,\nbut the youngest was so beautiful that the sun itself, which has seen so much, \nwas astonished whenever it shone in her face. \nClose by the king's castle lay a great dark forest, \nand under an old lime-tree in the forest was a well, and when the day was very warm, \nthe king's child went out into the forest and sat down by the side of the cool fountain, \nand when she was bored she took a golden ball, and threw it up on high and caught it, \nand this ball was her favorite plaything.");
                    }
                    {
                        Control.Button pad = new Control.Button(dockLayout);
                        pad.Dock     = Dock.Right;
                        pad.Margin   = Margin.Five;
                        pad.Text     = "Pad";
                        pad.Clicked += (s, a) => new TextPad(this);
                    }
                }

                {
                    Control.TextBox textbox = new Control.TextBox(vlayout);
                    textbox.Margin = Margin.Five;
                    textbox.SetText("In olden times when wishing still helped one, there lived a king whose daughters were all beautiful, but the youngest was so beautiful that the sun itself, which has seen so much, was astonished whenever it shone in her face. Close by the king's castle lay a great dark forest, and under an old lime-tree in the forest was a well, and when the day was very warm, the king's child went out into the forest and sat down by the side of the cool fountain, and when she was bored she took a golden ball, and threw it up on high and caught it, and this ball was her favorite plaything.");
                    textbox.TextColor = Color.Black;
                    textbox.Font      = m_Font3;
                }

                {
                    Control.TextBox textbox = new Control.TextBox(vlayout);
                    textbox.Margin = Margin.Five;
                    textbox.Width  = 150;
                    textbox.HorizontalAlignment = HorizontalAlignment.Right;
                    textbox.SetText("あおい うみから やってきた");
                    textbox.TextColor = Color.Black;
                    textbox.Font      = m_Font3;
                }

                {
                    Control.TextBox textbox = new Control.TextBox(vlayout);
                    textbox.Margin = Margin.Five;
                    textbox.HorizontalAlignment = HorizontalAlignment.Left;
                    textbox.FitToText           = "Fit the text";
                    textbox.SetText("FitToText");
                    textbox.TextColor = Color.Black;
                    textbox.Font      = m_Font3;
                }

                {
                    Control.TextBox textbox = new Control.TextBox(vlayout);
                    textbox.Margin = Margin.Five;
                    textbox.HorizontalAlignment = HorizontalAlignment.Left;
                    textbox.Width = 200;
                    textbox.SetText("Width = 200");
                    textbox.TextColor = Color.Black;
                    textbox.Font      = m_Font3;
                }

                {
                    Control.TextBox textbox = new Control.TextBox(vlayout);
                    textbox.Margin = Margin.Five;
                    textbox.SetText("Different Font");
                    textbox.Font = m_Font2;
                }
            }
        }
Example #3
0
        public TextBox(Base parent)
            : base(parent)
        {
            int row = 0;

            m_Font1 = new Font(Skin.Renderer, "Consolas", 14); // fixed width font!
            m_Font2 = new Font(Skin.Renderer, "Impact", 50);
            m_Font3 = new Font(Skin.Renderer, "Arial", 14);

            /* Vanilla Textbox */
            {
                Control.TextBox textbox = new Control.TextBox(this);
                textbox.SetText("Type something here");
                textbox.SetPosition(10, 10 + 25 * row);
                textbox.TextChanged += OnEdit;
                textbox.SubmitPressed += OnSubmit;
                row++;
            }

            /* Multiline Textbox */
            {
                Control.MultilineTextBox textbox = new Control.MultilineTextBox(this);
                textbox.Font = m_Font1;
                textbox.AcceptTabs = true;
                textbox.SetText(
                    "using System;\npublic class Test {\n\tpublic static void Main(){\n\t\tConsole.WriteLine(\"Hello World\");\n\t}\n}");
                textbox.SetPosition(220, 10);
                textbox.SetSize(500, 150);
            }

            {
                Control.TextBoxPassword textbox = new Control.TextBoxPassword(this);
                //textbox.MaskCharacter = '@';
                textbox.SetText("secret");
                textbox.TextChanged += OnEdit;
                textbox.SetPosition(10, 10 + 25 * row);
                row++;
            }

            {
                Control.TextBox textbox = new Control.TextBox(this);
                textbox.SetText("Select All Text On Focus");
                textbox.SetPosition(10, 10 + 25 * row);
                textbox.SelectAllOnFocus = true;
                row++;
            }

            {
                Control.TextBox textbox = new Control.TextBox(this);
                textbox.SetText("Different Coloured Text, for some reason");
                textbox.TextColor = Color.ForestGreen;
                textbox.SetPosition(10, 10 + 25 * row);
                row++;
            }

            {
                Control.TextBox textbox = new Control.TextBoxNumeric(this);
                textbox.SetText("200456698");
                textbox.TextColor = Color.LightCoral;
                textbox.SetPosition(10, 10 + 25 * row);
                row++;
            }

            row++;

            {
                Control.TextBox textbox = new Control.TextBox(this);
                textbox.SetText("OOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOO");
                textbox.TextColor = Color.Black;
                textbox.SetPosition(10, 10 + 28 * row);
                textbox.Font = m_Font3;
                textbox.SizeToContents();
                row++;
            }

            {
                Control.TextBox textbox = new Control.TextBox(this);
                textbox.SetText("..............................................................");
                textbox.TextColor = Color.Black;
                textbox.SetPosition(10, 10 + 28 * row);
                textbox.Font = m_Font3;
                textbox.SizeToContents();
                row++;
            }

            {
                Control.TextBox textbox = new Control.TextBox(this);
                textbox.SetText("public override void SetText(string str, bool doEvents = true)");
                textbox.TextColor = Color.Black;
                textbox.SetPosition(10, 10 + 28 * row);
                textbox.Font = m_Font3;
                textbox.SizeToContents();
                row++;
            }

            {
                Control.TextBox textbox = new Control.TextBox(this);
                textbox.SetText("あおい うみから やってきた");
                textbox.TextColor = Color.Black;
                textbox.SetPosition(10, 10 + 28 * row);
                textbox.Font = m_Font3;
                textbox.SizeToContents();
                row++;
            }

            row++;

            {
                Control.TextBox textbox = new Control.TextBox(this);
                textbox.SetText("OOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOO");
                textbox.TextColor = Color.Black;
                textbox.SetPosition(10, 10 + 28 * row);
                textbox.Font = m_Font1;
                textbox.SizeToContents();
                row++;
            }

            {
                Control.TextBox textbox = new Control.TextBox(this);
                textbox.SetText("..............................................................");
                textbox.TextColor = Color.Black;
                textbox.SetPosition(10, 10 + 28 * row);
                textbox.Font = m_Font1;
                textbox.SizeToContents();
                row++;
            }

            {
                Control.TextBox textbox = new Control.TextBox(this);
                textbox.SetText("public override void SetText(string str, bool doEvents = true)");
                textbox.TextColor = Color.Black;
                textbox.SetPosition(10, 10 + 28 * row);
                textbox.Font = m_Font1;
                textbox.SizeToContents();
                row++;
            }

            {
                Control.TextBox textbox = new Control.TextBox(this);
                textbox.SetText("あおい うみから やってきた");
                textbox.TextColor = Color.Black;
                textbox.SetPosition(10, 10 + 28 * row);
                textbox.Font = m_Font1;
                textbox.SizeToContents();
                row++;
            }

            row++;

            {
                Control.TextBox textbox = new Control.TextBox(this);
                textbox.SetText("Different Font (autosized)");
                textbox.SetPosition(10, 10 + 28 * row);
                textbox.Font = m_Font2;
                textbox.SizeToContents();

                row += 2;
            }
        }