7
public class Boxes: VBox
11
HBox box1 = new HBox ();
13
VBox box2 = new VBox ();
14
box2.PackStart (new SimpleBox (30), BoxMode.None);
15
box2.PackStart (new SimpleBox (30), BoxMode.None);
16
box2.PackStart (new SimpleBox (30), BoxMode.FillAndExpand);
18
box1.PackStart (box2, BoxMode.FillAndExpand);
19
box1.PackStart (new SimpleBox (30), BoxMode.None);
20
box1.PackStart (new SimpleBox (30), BoxMode.Expand);
21
PackStart (box1, BoxMode.None);
23
HBox box3 = new HBox ();
24
box3.PackEnd (new SimpleBox (30));
25
box3.PackStart (new SimpleBox (20) {Color = new Color (1, 0.5, 0.5)});
26
box3.PackEnd (new SimpleBox (40));
27
box3.PackStart (new SimpleBox (10) {Color = new Color (1, 0.5, 0.5)});
28
box3.PackEnd (new SimpleBox (30));
29
box3.PackStart (new SimpleBox (10) {Color = new Color (1, 0.5, 0.5)}, BoxMode.FillAndExpand);
32
HBox box4 = new HBox ();
33
Button b = new Button ("Click me");
34
b.Clicked += delegate {
35
b.Label = "Button has grown";
37
box4.PackStart (new SimpleBox (30), BoxMode.FillAndExpand);
39
box4.PackStart (new SimpleBox (30), BoxMode.FillAndExpand);
42
HBox box5 = new HBox ();
43
Button b2 = new Button ("Hide / Show");
44
box5.PackStart (new SimpleBox (30), BoxMode.FillAndExpand);
45
var hsb = new SimpleBox (20);
46
box5.PackStart (hsb, BoxMode.None);
48
box5.PackStart (new SimpleBox (30), BoxMode.FillAndExpand);
49
b2.Clicked += delegate {
50
hsb.Visible = !hsb.Visible;
54
HBox box6 = new HBox ();
55
for (int n=0; n<15; n++) {
56
var w = new Label ("TestLabel" + n);
64
class SimpleBox: Canvas
70
public Color Color { get; set; }
72
public SimpleBox (double coreSize)
74
Color = new Color (0.5, 0.5, 1);
75
this.coreSize = new Size (coreSize, coreSize);
76
MinWidth = MinHeight = coreSize + margin * 2;
79
public SimpleBox (double coreWidth, double coreHeight)
81
Color = new Color (0.5, 0.5, 1);
82
this.coreSize = new Size (coreWidth, coreHeight);
83
MinWidth = coreSize.Width + margin * 2;
84
MinHeight = coreSize.Height + margin * 2;
87
protected override void OnMouseEntered (EventArgs args)
89
base.OnMouseEntered (args);
94
protected override void OnMouseExited (EventArgs args)
96
base.OnMouseExited (args);
101
protected override void OnDraw (Context ctx, Rectangle dirtyRect)
103
ctx.SetColor (new Color (0.5, 0.5, 0.5));
104
ctx.Rectangle (Bounds);
106
ctx.SetColor (new Color (0.8, 0.8, 0.8));
107
ctx.Rectangle (Bounds.Inflate (-margin, -margin));
109
ctx.SetColor (highlight ? Color.BlendWith (Xwt.Drawing.Colors.White, 0.5) : Color);
110
ctx.Rectangle (Bounds.Width / 2 - coreSize.Width / 2, Bounds.Height / 2 - coreSize.Height / 2, coreSize.Width, coreSize.Height);