public virtual void AddSubview(NSView aView, NSWindowOrderingMode place, NSView otherView)
{
uint index;
if (aView == null)
{
return;
}
if (this.IsDescendantOf(aView))
{
NSException.Raise(@"NSInvalidArgumentException",
@"addSubview:positioned:relativeTo: creates a loop in the views tree!");
}
if (aView == otherView)
return;
aView.RemoveFromSuperview();
// Do this after the removeFromSuperview, as aView may already
// be a subview and the index could change.
if (otherView == null)
{
index = NS.NotFound;
}
else
{
index = _sub_views.IndexOfObjectIdenticalTo(otherView);
}
if (index == NS.NotFound)
{
if (place == NSWindowOrderingMode.NSWindowBelow)
index = 0;
else
index = (uint)_sub_views.Count;
}
else if (place != NSWindowOrderingMode.NSWindowBelow)
{
index += 1;
}
aView._ViewWillMoveToWindow(_window);
aView._ViewWillMoveToSuperview(this);
aView.SetNextResponder(this);
_sub_views.InsertObject(aView,index);
_rFlags.has_subviews = 1;
aView.ResetCursorRects();
aView.SetNeedsDisplay(true);
aView._ViewDidMoveToWindow();
aView.ViewDidMoveToSuperview();
this.DidAddSubview(aView);
}