blob: 36d41f99e15383a7e15433bacad50df79631dd39 (
plain)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
|
using System;
using System.Diagnostics;
using System.Collections.Generic;
using System.Linq;
using System.Text;
using System.Xml.Serialization;
using System.ComponentModel;
namespace go
{
public class GenericStack : Group
{
#region CTOR
public GenericStack()
: base()
{
}
#endregion
#region Private fields
int _spacing;
Orientation _orientation;
#endregion
#region Public Properties
[XmlAttributeAttribute()][DefaultValue(2)]
public int Spacing
{
get { return _spacing; }
set { _spacing = value; }
}
[XmlAttributeAttribute()][DefaultValue(Orientation.Horizontal)]
public virtual Orientation Orientation
{
get { return _orientation; }
set { _orientation = value; }
}
#endregion
#region GraphicObject Overrides
[XmlAttributeAttribute()][DefaultValue(-1)]
public override int Width {
get { return base.Width; }
set { base.Width = value; }
}
[XmlAttributeAttribute()][DefaultValue(-1)]
public override int Height {
get { return base.Height; }
set { base.Height = value; }
}
protected override Size measureRawSize ()
{
Size tmp = new Size ();
if (Orientation == Orientation.Horizontal) {
foreach (GraphicObject c in Children) {
tmp.Width += c.Slot.Width + Spacing;
tmp.Height = Math.Max (tmp.Height, c.Slot.Bottom);
}
} else {
foreach (GraphicObject c in Children) {
tmp.Width = Math.Max (tmp.Width, c.Slot.Right);
tmp.Height += c.Slot.Height + Spacing;
}
}
tmp.Width += 2*Margin;
tmp.Height += 2*Margin;
return tmp;
}
public virtual void ComputeChildrenPositions()
{
int d = 0;
if (Orientation == Orientation.Horizontal) {
foreach (GraphicObject c in Children) {
c.Slot.X = d;
d += c.Slot.Width + Spacing;
}
} else {
foreach (GraphicObject c in Children) {
c.Slot.Y = d;
d += c.Slot.Height + Spacing;
}
}
}
public override void RegisterForLayouting ()
{
base.RegisterForLayouting ();
int idx = Interface.LayoutingQueue.IndexOf (Interface.LayoutingQueue.Where (lq => lq.GraphicObject.Parent == this).LastOrDefault ());
if (idx < 0)
return;
Interface.LayoutingQueue.Insert (
idx+1,
new LayoutingQueueItem (LayoutingType.PositionChildren, this));
}
public override void UpdateLayout (LayoutingType layoutType)
{
if (layoutType == LayoutingType.PositionChildren)
ComputeChildrenPositions ();
base.UpdateLayout(layoutType);
}
#endregion
}
}
|