Smartmobili.Cocoa.NSView._ViewWillMoveToWindow C# (CSharp) Method

_ViewWillMoveToWindow() protected method

protected _ViewWillMoveToWindow ( NSWindow newWindow ) : void
newWindow NSWindow
return void
        protected virtual void _ViewWillMoveToWindow(NSWindow newWindow)
        {
            bool old_allocate_gstate;

            this.ViewWillMoveToWindow(newWindow);
            if (_coordinates_valid)
            {
                //FIXME
                //(*invalidateImp)(self, invalidateSel);
            }
            if (_rFlags.has_currects != 0)
            {
                this.DiscardCursorRects();
            }

            if (newWindow == _window)
            {
                return;
            }

            // This call also reset _allocate_gstate, so we have
            // to store this value and set it again.
            // This way we keep the logic in one place.
            old_allocate_gstate = _allocate_gstate;
            this.ReleaseGState();
            _allocate_gstate = old_allocate_gstate;

            if (_rFlags.has_draginfo != 0)
            {
                NSArray t = GSGetDragTypes(this);

                if (_window != null)
                {
                    //FIXME
                    //[GSDisplayServer removeDragTypes: t fromWindow: _window];
                    //if ([_window autorecalculatesKeyViewLoop])
                    //{
                    //	[_window recalculateKeyViewLoop];
                    //}
                }
                if (newWindow != null)
                {
                    //FIXME
            //					[GSDisplayServer addDragTypes: t toWindow: newWindow];
            //					if ([newWindow autorecalculatesKeyViewLoop])
            //					{
            //						[newWindow recalculateKeyViewLoop];
            //					}
                }
            }

            _window = newWindow;

            if (_rFlags.has_subviews != 0)
            {
                uint count = (uint)_sub_views.Count;

                if (count > 0)
                {
                    uint i;
                    NSView[] array = new NSView[count];

                    _sub_views.GetObjects((id[])array);
                    for (i = 0; i < count; ++i)
                    {
                        array[i]._ViewWillMoveToWindow(newWindow);
                    }
                }
            }
        }

Usage Example

Example #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);
                }
            }
        }
All Usage Examples Of Smartmobili.Cocoa.NSView::_ViewWillMoveToWindow
NSView