Layout help

Hi,

Basically what i'm trying to achieve is a GoObject that inherits GoTextNode and has GoText objects added to it. Each of these GoText objects are to be placed in their own corner of the parent object and should move as the object is resized.
Using the DecoratedTextNode example i was able to achieve part of what i'm trying to do. However, whenever the GoObject that extends the GoTextNode is resized (for exmaple, it resizes to fit the label), the GoText objects added to it are not relocating to the new corner positions.
I've tried several other methods besides the DecoratedTextNode example (just trial and error with what's available) and i can't seem to get it to work.
Any help would be great. Happy to supply current code (VB.NET).
Cheers....

Here is a pic of what i’m trying to achieve. Looks like your standard GoTextNode except it has the letters in the corners. The letters arne’t selecteable and editable, but need to individually be set to visible/invisible depending on different circumstances.

Cheers....

You need to override LayoutChildren to position those GoText objects where you want them:

[Serializable]
public class DecoratedTextNode2 : GoTextNode {
public DecoratedTextNode2() {
this.Label.Alignment = Middle;
this.Text = "Extension of a GoTextNode";
this.AutoResizes = false;
this.Resizable = true; //???
this.Reshapable = true; //???
GoText t = new GoText();
t.Selectable = false;
t.Text = "S";
Add(t);
AddChildName("TopLeft", t);
t = new GoText();
t.Selectable = false;
t.Text = "A";
Add(t);
AddChildName("TopRight", t);
t = new GoText();
t.Selectable = false;
t.Text = "I";
Add(t);
AddChildName("BottomRight", t);
t = new GoText();
t.Selectable = false;
t.Text = "L";
Add(t);
AddChildName("BottomLeft", t);
}
public override void LayoutChildren(GoObject childchanged) {
base.LayoutChildren(childchanged);
GoObject back = this.Background;
if (back == null) return;
GoObject t = FindChild("TopLeft");
if (t != null) {
PointF p = back.GetSpotLocation(TopLeft);
t.SetSpotLocation(TopLeft, new PointF(p.X+2, p.Y+2));
}
t = FindChild("TopRight");
if (t != null) {
PointF p = back.GetSpotLocation(TopRight);
t.SetSpotLocation(TopRight, new PointF(p.X-2, p.Y+2));
}
t = FindChild("BottomRight");
if (t != null) {
PointF p = back.GetSpotLocation(BottomRight);
t.SetSpotLocation(BottomRight, new PointF(p.X-2, p.Y-2));
}
t = FindChild("BottomLeft");
if (t != null) {
PointF p = back.GetSpotLocation(BottomLeft);
t.SetSpotLocation(BottomLeft, new PointF(p.X+2, p.Y-2));
}
}
}
Of course you might want to change those label names to be specific to your application, instead of "TopLeft", "TopRight", etc.
You could also add properties that return the corresponding value of a call to FindChild, to make the code using these nodes even simpler/cleaner.

Thanks mate, worked perfectly!

Cheers....