/// <summary> /// Initializes a new instance of the <see cref="MenuItem"/> class. /// </summary> /// <param name="parent">Parent control.</param> public MenuItem(Control parent) : base(parent) { m_OnStrip = false; IsTabable = false; IsCheckable = false; IsChecked = false; m_Accelerator = new Label(this); }
/// <summary> /// Initializes a new instance of the <see cref="PropertyRow"/> class. /// </summary> /// <param name="parent">Parent control.</param> /// <param name="prop">Property control associated with this row.</param> public PropertyRow(Control parent, Property.Control prop) : base(parent) { PropertyRowLabel label = new PropertyRowLabel(this); label.Dock = Pos.Left; label.Alignment = Pos.Left | Pos.Top; label.Margin = new Margin(2, 2, 0, 0); m_Label = label; m_Property = prop; m_Property.Parent = this; m_Property.Dock = Pos.Fill; m_Property.ValueChanged += OnValueChanged; }
private readonly Label m_Label; // should be rich label with maxwidth = parent #endregion Fields #region Constructors /// <summary> /// Initializes a new instance of the <see cref="MessageBox"/> class. /// </summary> /// <param name="parent">Parent control.</param> /// <param name="text">Message to display.</param> /// <param name="caption">Window caption.</param> public MessageBox(Control parent, String text, String caption = "") : base(parent, caption, true) { DeleteOnClose = true; m_Label = new Label(m_InnerPanel); m_Label.Text = text; m_Label.Margin = Margin.Five; m_Label.Dock = Pos.Top; m_Label.Alignment = Pos.Center; m_Label.AutoSizeToContents = true; m_Button = new Button(m_InnerPanel); m_Button.Text = "OK"; // todo: parametrize buttons m_Button.Clicked += CloseButtonPressed; m_Button.Clicked += DismissedHandler; m_Button.Margin = Margin.Five; m_Button.SetSize(50, 20); Align.Center(this); }
/// <summary> /// Initializes a new instance of the <see cref="WindowControl"/> class. /// </summary> /// <param name="parent">Parent control.</param> /// <param name="caption">Window caption.</param> /// <param name="modal">Determines whether the window should be modal.</param> public WindowControl(Control parent, String caption = "", bool modal = false) : base(parent) { m_TitleBar = new Dragger(this); m_TitleBar.Height = 24; m_TitleBar.Padding = Padding.Zero; m_TitleBar.Margin = new Margin(0, 0, 0, 4); m_TitleBar.Target = this; m_TitleBar.Dock = Pos.Top; m_Caption = new Label(m_TitleBar); m_Caption.Alignment = Pos.Left | Pos.CenterV; m_Caption.Text = caption; m_Caption.Dock = Pos.Fill; m_Caption.Padding = new Padding(8, 0, 0, 0); m_Caption.TextColor = Skin.Colors.Window.TitleInactive; m_CloseButton = new CloseButton(m_TitleBar, this); //m_CloseButton.Text = String.Empty; m_CloseButton.SetSize(24, 24); m_CloseButton.Dock = Pos.Right; m_CloseButton.Clicked += CloseButtonPressed; m_CloseButton.IsTabable = false; m_CloseButton.Name = "closeButton"; //Create a blank content control, dock it to the top - Should this be a ScrollControl? m_InnerPanel = new Control(this); m_InnerPanel.Dock = Pos.Fill; GetResizer(8).Hide(); BringToFront(); IsTabable = false; Focus(); MinimumSize = new Vector2i(100, 40); ClampMovement = true; KeyboardInputEnabled = false; if (modal) MakeModal(); }
/// <summary> /// Initializes a new instance of the <see cref="HSVColorPicker"/> class. /// </summary> /// <param name="parent">Parent control.</param> public HSVColorPicker(Control parent) : base(parent) { MouseInputEnabled = true; SetSize(256, 128); //ShouldCacheToTexture = true; m_LerpBox = new ColorLerpBox(this); m_LerpBox.ColorChanged += ColorBoxChanged; m_LerpBox.Dock = Pos.Left; m_ColorSlider = new ColorSlider(this); m_ColorSlider.SetPosition(m_LerpBox.Width + 15, 5); m_ColorSlider.ColorChanged += ColorSliderChanged; m_ColorSlider.Dock = Pos.Left; m_After = new ColorDisplay(this); m_After.SetSize(48, 24); m_After.SetPosition(m_ColorSlider.X + m_ColorSlider.Width + 15, 5); m_Before = new ColorDisplay(this); m_Before.SetSize(48, 24); m_Before.SetPosition(m_After.X, 28); int x = m_Before.X; int y = m_Before.Y + 30; { Label label = new Label(this); label.SetText("R:"); label.SizeToContents(); label.SetPosition(x, y); TextBoxNumeric numeric = new TextBoxNumeric(this); numeric.Name = "RedBox"; numeric.SetPosition(x + 15, y - 1); numeric.SetSize(26, 16); numeric.SelectAllOnFocus = true; numeric.TextChanged += NumericTyped; } y += 20; { Label label = new Label(this); label.SetText("G:"); label.SizeToContents(); label.SetPosition(x, y); TextBoxNumeric numeric = new TextBoxNumeric(this); numeric.Name = "GreenBox"; numeric.SetPosition(x + 15, y - 1); numeric.SetSize(26, 16); numeric.SelectAllOnFocus = true; numeric.TextChanged += NumericTyped; } y += 20; { Label label = new Label(this); label.SetText("B:"); label.SizeToContents(); label.SetPosition(x, y); TextBoxNumeric numeric = new TextBoxNumeric(this); numeric.Name = "BlueBox"; numeric.SetPosition(x + 15, y - 1); numeric.SetSize(26, 16); numeric.SelectAllOnFocus = true; numeric.TextChanged += NumericTyped; } SetColor(DefaultColor); }
public void SetAccelerator(String acc) { if (m_Accelerator != null) { //m_Accelerator.DelayedDelete(); // to prevent double disposing m_Accelerator = null; } if (acc == string.Empty) return; m_Accelerator = new Label(this); m_Accelerator.Dock = Pos.Right; m_Accelerator.Alignment = Pos.Right | Pos.CenterV; m_Accelerator.Text = acc; m_Accelerator.Margin = new Margin(0, 0, 16, 0); // todo }
public void TestLabel() { var control = new Label(canvas); control.Text = "Label"; GUI.Test(control, "label1"); }
protected void CreateLabel(String text, TextBlock block, ref int x, ref int y, ref int lineHeight, bool noSplit) { // Use default font or is one set? Font font = Skin.DefaultFont; if (block.Font != null) font = block.Font; // This string is too long for us, split it up. var p = Skin.Renderer.MeasureText(font, text); if (lineHeight == -1) { lineHeight = (int)(p.Y + 0.5); } if (!noSplit) { if (x + p.X > Width) { SplitLabel(text, font, block, ref x, ref y, ref lineHeight); return; } } // Wrap if (x + p.X >= Width) { CreateNewline(ref x, ref y, lineHeight); } Label label = new Label(this); label.SetText(x == 0 ? text.TrimStart(' ') : text); label.TextColor = block.Color; label.Font = font; label.SizeToContents(); label.SetPosition(x, y); //lineheight = (lineheight + pLabel.Height()) / 2; x += label.Width; if (x >= Width) { CreateNewline(ref x, ref y, lineHeight); } }
/// <summary> /// Creates a tooltip for the control. /// </summary> /// <param name="text">Tooltip text.</param> public virtual void SetToolTipText(String text) { Label tooltip = new Label(this); tooltip.AutoSizeToContents = true; tooltip.Text = text; tooltip.TextColorOverride = Skin.Colors.TooltipText; tooltip.Padding = new Padding(5, 3, 5, 3); tooltip.SizeToContents(); ToolTip = tooltip; }