using System;
using System.Drawing;
namespace Gwen.Control
{
///
/// Group box (container).
///
/// Don't use autosize with docking.
public class GroupBox : Label
{
///
/// Initializes a new instance of the class.
///
/// Parent control.
public GroupBox(Base parent)
: base(parent)
{
// Set to true, because it's likely that our
// children will want mouse input, and they
// can't get it without us..
MouseInputEnabled = true;
KeyboardInputEnabled = true;
TextPadding = new Padding(10, 0, 10, 0);
Alignment = Pos.Top | Pos.Left;
Invalidate();
m_InnerPanel = new Base(this);
m_InnerPanel.Dock = Pos.Fill;
m_InnerPanel.Margin = new Margin(5, TextHeight+5, 5, 5);
//Margin = new Margin(5, 5, 5, 5);
}
///
/// Lays out the control's interior according to alignment, padding, dock etc.
///
/// Skin to use.
protected override void Layout(Skin.Base skin)
{
base.Layout(skin);
if (AutoSizeToContents)
{
DoSizeToContents();
}
}
///
/// Renders the control using specified skin.
///
/// Skin to use.
protected override void Render(Skin.Base skin)
{
skin.DrawGroupBox(this, TextX, TextHeight, TextWidth);
}
///
/// Sizes to contents.
///
public override void SizeToContents()
{
// we inherit from Label and shouldn't use its method.
DoSizeToContents();
}
protected virtual void DoSizeToContents()
{
m_InnerPanel.SizeToChildren();
SizeToChildren();
if (Width < TextWidth + TextPadding.Right + TextPadding.Left)
Width = TextWidth + TextPadding.Right + TextPadding.Left;
}
}
}