}
Docker {
AllowDrop = "false";
- Margin="0";
+ Margin="5";
Focusable="true";
}
DockStack {
- Margin="1";
+ Margin="5";
AllowDrop = "true";
Focusable="true";
//DragEnter="{Background=DarkBlue}";
}
#endregion
+ public static Orientation GetOrientation(this Alignment a){
+ return (a==Alignment.Left) ||(a==Alignment.Right) ? Orientation.Horizontal : Orientation.Vertical;
+ }
public static void Raise(this EventHandler handler, object sender, EventArgs e)
{
if(handler != null)
{
public class DockStack : GenericStack
{
- internal static Instantiator instStack, instSplit, instSpacer;
+ internal static Instantiator instStack, instSplit;//, instSpacer;
int dockingDiv = 5;
-
GraphicObject subStack = null;
+
+ Docker rootDock { get { return LogicalParent as Docker; }}
+
public GraphicObject SubStack {
get { return subStack;}
set{ subStack=value; }
}
+ #region CTor
public DockStack () {}
public DockStack (Interface iface) : base (iface) {}
+ #endregion
+
+ protected override void onInitialized (object sender, EventArgs e)
+ {
+ base.onInitialized (sender, e);
+ instStack = IFace.CreateITorFromIMLFragment (@"<DockStack/>");
+ instSplit = IFace.CreateITorFromIMLFragment (@"<Splitter/>");
+ //instSpacer = IFace.CreateITorFromIMLFragment (@"<GraphicObject Background='Transparent' IsEnabled='false'/>");
+ }
+
+ public override void AddChild (GraphicObject g)
+ {
+ base.AddChild (g);
+ g.LogicalParent = this.LogicalParent;
+ }
+ public override void InsertChild (int idx, GraphicObject g)
+ {
+ base.InsertChild (idx, g);
+ g.LogicalParent = this.LogicalParent;
+ }
public override bool PointIsIn (ref Point m)
{
}
return Slot.ContainsOrIsEqual(m);
}
-// protected override void onDragEnter (object sender, DragDropEventArgs e)
-// {
-// base.onDragEnter (sender, e);
-// showDock = true;
-// }
-// protected override void onDragLeave (object sender, DragDropEventArgs e)
-// {
-// base.onDragLeave (sender, e);
-// showDock = false;
-// }
public override void onMouseMove (object sender, MouseMoveEventArgs e)
{
if (IsDropTarget) {
}
base.onMouseMove (sender, e);
}
- static Orientation GetOrientation (Alignment a){
- return (a==Alignment.Left) ||(a==Alignment.Right) ? Orientation.Horizontal : Orientation.Vertical;
+
+ protected override void onDragEnter (object sender, DragDropEventArgs e)
+ {
+ base.onDragEnter (sender, e);
+ RegisterForGraphicUpdate ();
}
+ protected override void onDragLeave (object sender, DragDropEventArgs e)
+ {
+ base.onDragLeave (sender, e);
+ RegisterForGraphicUpdate ();
+ }
+
protected override void onDraw (Cairo.Context gr)
{
gr.Save ();
Rectangle r;
- if (GetOrientation (dw.DockingPosition) == Orientation || SubStack == null)
+ if (dw.DockingPosition.GetOrientation() == Orientation || SubStack == null)
r = ClientRectangle;
else
r = SubStack.ClientRectangle + SubStack.Slot.Position + ClientRectangle.TopLeft;
}
gr.Restore ();
}
+
public void Undock (DockWindow dw){
+ int dwIdx = Children.IndexOf(dw);
+
RemoveChild(dw);
if (dw.DockingPosition == Alignment.Left || dw.DockingPosition == Alignment.Top)
- RemoveChild (0);
+ RemoveChild (dwIdx);
else
- RemoveChild (Children.Count - 1);
+ RemoveChild (dwIdx - 1);
if (Children.Count > 1)
return;
dsp.RemoveChild (this);
dsp.InsertChild (i, g);
dsp.SubStack = g;
-// if (SubStack is DockStack) {
-//
-// } else {
-// int i = p.Children.IndexOf (this);
-// p.RemoveChild (this);
-// if (p is DockStack) {
-// DockStack dsp = p as DockStack;
-// dsp.SubStack = instSpacer.CreateInstance ();
-// dsp.AddChild (dsp.SubStack);
-// }
-// }
-
}
public void Dock(DockWindow dw){
- checkInstantiators();
-
Splitter splitter = instSplit.CreateInstance<Splitter> ();
Rectangle r = ClientRectangle;
if (SubStack == null) {
activeStack = this;
- SubStack = instSpacer.CreateInstance ();
- }else if (GetOrientation (dw.DockingPosition) != Orientation) {
+ SubStack = rootDock.CenterDockedObj;
+ }else if (dw.DockingPosition.GetOrientation() != Orientation) {
int i = Children.IndexOf (SubStack);
RemoveChild (SubStack);
activeStack = instStack.CreateInstance<DockStack> ();
- activeStack.SubStack = instSpacer.CreateInstance ();
+ activeStack.SubStack = rootDock.CenterDockedObj;
SubStack = activeStack;
InsertChild(i, activeStack);
}
activeStack.AddChild (activeStack.SubStack);
} else {
activeStack.InsertChild (0, dw);
- activeStack.InsertChild (0, splitter);
+ activeStack.InsertChild (1, splitter);
}
break;
case Alignment.Bottom:
break;
}
}
-
- void checkInstantiators () {
- if (instStack != null)
- return;
- instStack = IFace.CreateITorFromIMLFragment (@"<DockStack/>");
- instSplit = IFace.CreateITorFromIMLFragment (@"<Splitter/>");
- instSpacer = IFace.CreateITorFromIMLFragment (@"<GraphicObject Background='Transparent' IsEnabled='false'/>");
- }
-
}
}
}
#endregion
- //GenericStack rootStack = null;
- public DockStack SubStack = null;
int dockingThreshold;
- List<DockWindow> windows = new List<DockWindow>();
-
- public override void AddChild (GraphicObject g)
- {
- base.AddChild (g);
- g.LogicalParent = this;
- }
+ public DockStack SubStack = null;
+ public GraphicObject CenterDockedObj = null;
[XmlAttributeAttribute][DefaultValue(10)]
public virtual int DockingThreshold {
}
}
- //bool showDockingTarget = false;
- //Alignment dockingDirection = Alignment.Center;
- //int dockingDiv = 8;
- //bool showDock = false;
+ protected override void onInitialized (object sender, EventArgs e)
+ {
+ base.onInitialized (sender, e);
+ CenterDockedObj = new GraphicObject (IFace) { IsEnabled = false };
+ }
+
+ public override void AddChild (GraphicObject g)
+ {
+ base.AddChild (g);
+ g.LogicalParent = this;
+ }
public override void onMouseMove (object sender, MouseMoveEventArgs e)
{
}
base.onMouseMove (sender, e);
}
- /*
- protected override void onDragEnter (object sender, DragDropEventArgs e)
- {
- base.onDragEnter (sender, e);
- showDock = true;
- Console.WriteLine ("showdock=" + showDock);
- }
- protected override void onDragLeave (object sender, DragDropEventArgs e)
- {
- base.onDragLeave (sender, e);
- showDock = false;
- Console.WriteLine ("showdock=" + showDock);
- }
-
- protected override void onDraw (Cairo.Context gr)
- {
- gr.Save ();
-
- Rectangle rBack = new Rectangle (Slot.Size);
-
- Background.SetAsSource (gr, rBack);
- CairoHelpers.CairoRectangle (gr, rBack, CornerRadius);
- gr.Fill ();
-
- if (ClipToClientRect) {
- //clip to client zone
- CairoHelpers.CairoRectangle (gr, ClientRectangle, CornerRadius);
- gr.Clip ();
- }
-
- childrenRWLock.EnterReadLock ();
-
- foreach (GraphicObject g in Children) {
-// if (IFace.DragAndDropOperation?.DragSource == g)
-// continue;
- g.Paint (ref gr);
- }
-
- childrenRWLock.ExitReadLock ();
-
- if (showDockingTarget) {
- Rectangle r;
- if (stack == null)
- r = ClientRectangle;
- else
- r = stack.ClientRectangle;
-
- switch (dockingDirection) {
- case Alignment.Top:
- gr.Rectangle (r.Left, r.Top, r.Width, r.Height / dockingDiv);
- break;
- case Alignment.Bottom:
- gr.Rectangle (r.Left, r.Bottom - r.Height / dockingDiv, r.Width, r.Height / dockingDiv);
- break;
- case Alignment.Left:
- gr.Rectangle (r.Left, r.Top, r.Width / dockingDiv, r.Height);
- break;
- case Alignment.Right:
- gr.Rectangle (r.Right - r.Width / dockingDiv, r.Top, r.Width / dockingDiv, r.Height);
- break;
- }
- gr.LineWidth = 1;
- gr.SetSourceRGBA (0.4, 0.4, 0.9, 0.4);
- gr.FillPreserve ();
- gr.SetSourceRGBA (0.9, 0.9, 1.0, 0.8);
- gr.Stroke ();
- }
-
- gr.Restore ();
- }
-*/
-
- /*
- public void Dock(DockWindow dw){
- checkInstantiators();
-
- if (dockingDirection == Alignment.Center)
- return;
-
- lock (IFace.UpdateMutex) {
-
- Splitter splitter = instSplit.CreateInstance<Splitter> ();
- Rectangle r = ClientRectangle;
-
- if (stack == null) {
- stack = instStack.CreateInstance<GenericStack> ();
- this.AddChild (stack);
- this.putWidgetOnBottom (stack);
- }
-
- int vTreshold = r.Height / dockingDiv;
- int hTreshold = r.Width / dockingDiv;
-
- switch (dockingDirection) {
- case Alignment.Top:
- dw.Height = vTreshold;
- stack.Orientation = Orientation.Vertical;
- if (stack.Children.Count == 0) {
- stack.AddChild (dw);
- stack.AddChild (splitter);
- stack.AddChild (instSpacer.CreateInstance ());
- } else {
- stack.AddChild (splitter);
- stack.AddChild (dw);
- }
- break;
- case Alignment.Bottom:
- dw.Height = vTreshold;
- stack.Orientation = Orientation.Vertical;
- if (stack.Children.Count == 0) {
- stack.AddChild (instSpacer.CreateInstance ());
- stack.AddChild (splitter);
- stack.AddChild (dw);
- } else {
- stack.InsertChild (0, dw);
- stack.InsertChild (0, splitter);
- }
- break;
- case Alignment.Left:
- dw.Width = hTreshold;
- stack.Orientation = Orientation.Horizontal;
- if (stack.Children.Count == 0) {
- stack.AddChild (dw);
- stack.AddChild (splitter);
- stack.AddChild (instSpacer.CreateInstance ());
- } else {
- stack.AddChild (splitter);
- stack.AddChild (dw);
- }
- break;
- case Alignment.Right:
- dw.Width = hTreshold;
- stack.Orientation = Orientation.Horizontal;
- if (stack.Children.Count == 0) {
- stack.AddChild (instSpacer.CreateInstance ());
- stack.AddChild (splitter);
- stack.AddChild (dw);
- } else {
- stack.InsertChild (0, dw);
- stack.InsertChild (0, splitter);
- }
- break;
- }
- }
- }*/
}
}
{
base.RemoveChild (child);
if (child == stretchedGO) {
+ stretchedGO.LastSlots = default(Rectangle);
stretchedGO = null;
RegisterForLayouting (LayoutingType.Sizing);
return;
Initialize ();
}
#endregion
- internal bool initialized = false;
+ //internal bool initialized = false;
/// <summary>
/// Initialize this Graphic object instance by setting style and default values and loading template if required
/// </summary>
public virtual void Initialize(){
loadDefaultValues ();
- initialized = true;
+ //initialized = true;
}
#region private fields
LayoutingType registeredLayoutings = LayoutingType.All;
internal Size contentSize;
#endregion
- public void ResetSlots () {
- LastSlots = LastPaintedSlot = Slot = default(Rectangle);
- }
#region ILayoutable
[XmlIgnore]public LayoutingType RegisteredLayoutings { get { return registeredLayoutings; } set { registeredLayoutings = value; } }
//TODO: it would save the recurent cost of a cast in event bubbling if parent type was GraphicObject
public event EventHandler Enabled;
/// <summary>Occurs when the enabled state this object is set to false</summary>
public event EventHandler Disabled;
+
+ #region DragAndDrop Events
public event EventHandler StartDrag;
public event EventHandler DragEnter;
public event EventHandler DragLeave;
public event EventHandler EndDrag;
public event EventHandler Drop;
+ #endregion
+
+ /// <summary>
+ /// Occurs when default value and styling are loaded, and for templated control,
+ /// template is also loaded. Bindings should be functionnal as well.
+ /// </summary>
+ public event EventHandler Initialized;
+
/// <summary>Occurs when one part of the rendering slot changed</summary>
public event EventHandler<LayoutingEventArgs> LayoutChanged;
/// <summary>Occurs when DataSource changed</summary>
} catch (Exception ex) {
throw new Exception ("Error applying style <" + styleKey + ">:", ex);
}
+ onInitialized (this, null);
+ }
+ protected virtual void onInitialized (object sender, EventArgs e){
+ Initialized.Raise(sender, e);
}
bool getDefaultEvent(EventInfo ei, List<Style> styling,
out string expression){
Children.Remove(child);
child.Parent = null;
- //child.ResetSlots ();
childrenRWLock.ExitWriteLock ();