_ViewDidMoveToWindow() protected méthode

protected _ViewDidMoveToWindow ( ) : void
Résultat void
Exemple #1
0
        public virtual void ReplaceSubviewWith(NSView oldView, NSView newView)
        {
            if (newView == oldView)
            {
                return;
            }
            /*
               			* NB. we implement the replacement in full rather than calling addSubview:
               			* since classes like NSBox override these methods but expect to be able to
               			* call [super replaceSubview:with:] safely.
               			*/
            if (oldView == null)
            {
                /*
               			* Strictly speaking, the docs say that if 'oldView' is not a subview
               			* of the receiver then we do nothing - but here we add newView anyway.
               			* So a replacement with no oldView is an addition.
               			*/
                //RETAIN(newView);
                newView.RemoveFromSuperview();
                newView._ViewWillMoveToWindow(_window);
                newView._ViewWillMoveToSuperview(this);
                newView.SetNextResponder(this);
                _sub_views.AddObject(newView);
                _rFlags.has_subviews = 1;
                newView.ResetCursorRects();
                newView.SetNeedsDisplay(true);
                newView._ViewDidMoveToWindow();
                newView.ViewDidMoveToSuperview();
                this.DidAddSubview(newView);
                //RELEASE(newView);
            }
            else if (_sub_views.IndexOfObjectIdenticalTo(oldView) != NS.NotFound)
            {
                if (newView == null)
                {
                    /*
                     * If there is no new view to add - we just remove the old one.
                     * So a replacement with no newView is a removal.
                     */
                    oldView.RemoveFromSuperview();
                }
                else
                {
                    uint index;

                    /*
               				* Ok - the standard case - we remove the newView from wherever it
               				* was (which may have been in this view), locate the position of
               				* the oldView (which may have changed due to the removal of the
               				* newView), remove the oldView, and insert the newView in it's
               				* place.
               				*/
                    //RETAIN(newView);
                    newView.RemoveFromSuperview();
                    index = _sub_views.IndexOfObjectIdenticalTo(oldView);
                    oldView.RemoveFromSuperview();
                    newView._ViewWillMoveToWindow(_window);
                    newView._ViewWillMoveToSuperview(this);
                    newView.SetNextResponder(this);
                    _sub_views.InsertObject(newView, index);
                    _rFlags.has_subviews = 1;
                    newView.ResetCursorRects();
                    newView.SetNeedsDisplay(true);
                    newView._ViewDidMoveToWindow();
                    newView.ViewDidMoveToSuperview();
                    this.DidAddSubview(newView);
                    //RELEASE(newView);
                }
            }
        }
Exemple #2
0
        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);
        }
Exemple #3
0
        public virtual void RemoveSubview(NSView aView)
        {
            NSView view;
            /*
             * This must be first because it invokes -resignFirstResponder:,
             * which assumes the view is still in the view hierarchy
             */

            //FIXME (VRI) : normally _window is not null I think ...
            if (_window != null)
            {
                for (view = (NSView)_window.FirstResponder;
                     view != null && view.RespondsToSelector(new SEL(@"GetSuperview"));
                     view = view.Superview)
                {
                    if (view == aView)
                    {

                        //[_window makeFirstResponder: _window];
                        break;
                    }
                }
            }
            this.WillRemoveSubview(aView);
            aView._super_view = null;
            aView._ViewWillMoveToWindow(null);
            aView._ViewWillMoveToSuperview(null);
            aView.SetNextResponder(null);

            _sub_views.RemoveObjectIdenticalTo(aView);
            aView.SetNeedsDisplay(false);
            aView._ViewDidMoveToWindow();
            aView.ViewDidMoveToSuperview();

            if (_sub_views.Count == 0)
            {
                _rFlags.has_subviews = 0;
            }
        }