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

InitWithCoder() public method

public InitWithCoder ( NSCoder aDecoder ) : id
aDecoder NSCoder
return id
        public override id InitWithCoder(NSCoder aDecoder)
        {
            id self = this;

            NSEnumerator e;
            NSView sub;
            NSArray subs;

            if (base.InitWithCoder(aDecoder) == null)
                return null;

            _matrixToWindow = (NSAffineTransform)NSAffineTransform.Alloc().Init();  // Map to window coordinates
            _matrixFromWindow = (NSAffineTransform)NSAffineTransform.Alloc().Init();// Map from window coordinates

            if (aDecoder.AllowsKeyedCoding)
            {
                NSView prevKeyView = null;
                NSView nextKeyView = null;

                if (aDecoder.ContainsValueForKey("NSFrame"))
                {
                    _frame = aDecoder.DecodeRectForKey("NSFrame");
                }
                else
                {
                    _frame = NSRect.Zero;
                    if (aDecoder.ContainsValueForKey("NSFrameSize"))
                    {
                        _frame = aDecoder.DecodeSizeForKey("NSFrameSize");
                    }
                }

                // Set bounds rectangle
                _bounds.Origin = NSPoint.Zero;
                _bounds.Size = _frame.Size;
                if (aDecoder.ContainsValueForKey("NSBounds"))
                {
                    this.SetBounds(aDecoder.DecodeRectForKey(@"NSBounds"));
                }

                _sub_views = (NSMutableArray)NSMutableArray.Alloc().Init();
                _tracking_rects = (NSMutableArray)NSMutableArray.Alloc().Init();
                _cursor_rects = (NSMutableArray)NSMutableArray.Alloc().Init();

                _is_rotated_from_base = false;
                _is_rotated_or_scaled_from_base = false;
                _rFlags.needs_display = Convert.ToUInt32(true);
                _post_bounds_changes = true;
                _post_frame_changes = true;
                _autoresizes_subviews = true;
                _autoresizingMask =(uint) NSViewAutoresizingMasks.NSViewNotSizable;
                _coordinates_valid = false;
                /*
                 * Note: don't zero _nextKeyView and _previousKeyView, as the key view
                 * chain may already have been established by super's initWithCoder:
                 *
                 * _nextKeyView = 0;
                 * _previousKeyView = 0;
                 */

                // previous and next key views...
                 prevKeyView = (NSView)aDecoder.DecodeObjectForKey("NSPreviousKeyView");
                 nextKeyView = (NSView)aDecoder.DecodeObjectForKey("NSNextKeyView");
                if (nextKeyView != null)
                {
                    NextKeyView = nextKeyView;
                }
                if (prevKeyView != null)
                {
                    PreviousKeyView = prevKeyView;
                }
                if (aDecoder.ContainsValueForKey("NSvFlags"))
                {
                    uint vFlags = (uint)aDecoder.DecodeIntForKey("NSvFlags");
                    //2013-06-02 10:40:22.872 Gorm[26233] NSvFlags: 0x112 (274) (274)
                    //2013-06-02 10:40:22.872 Gorm[26233] NSvFlags: 0x80000100 (-2147483392) (-2147483392)
                    //2013-06-02 10:40:22.873 Gorm[26233] NSvFlags: 0x80000100 (-2147483392) (-2147483392)
                    //2013-06-02 10:40:22.873 Gorm[26233] NSvFlags: 0x136 (310) (310)
                    //2013-06-02 10:40:22.873 Gorm[26233] NSvFlags: 0x900 (2304) (2304)
                    //2013-06-02 10:40:22.873 Gorm[26233] NSvFlags: 0x8000010a (-2147483382) (-2147483382)
                    //2013-06-02 10:40:22.873 Gorm[26233] NSvFlags: 0x10a (266) (266)
                    //2013-06-02 10:40:22.873 Gorm[26233] NSvFlags: 0x10c (268) (268)
                    //2013-06-02 10:40:22.873 Gorm[26233] NSvFlags: 0x10a (266) (266)
                    //2013-06-02 10:40:22.874 Gorm[26233] NSvFlags: 0x10c (268) (268)
                    //2013-06-02 10:40:22.874 Gorm[26233] NSvFlags: 0x10a (266) (266)
                    //2013-06-02 10:40:22.874 Gorm[26233] NSvFlags: 0x10c (268) (268)
                    //2013-06-02 10:40:22.874 Gorm[26233] NSvFlags: 0x112 (274) (274)
                    //2013-06-02 10:40:22.874 Gorm[26233] NSvFlags: 0x8000010a (-2147483382) (-2147483382)
                    //2013-06-02 10:40:22.874 Gorm[26233] NSvFlags: 0x100 (256) (256)
                    //2013-06-02 10:40:22.875 Gorm[26233] NSvFlags: 0x10c (268) (268)
                    //2013-06-02 10:40:22.875 Gorm[26233] NSvFlags: 0x10c (268) (268)
                    //2013-06-02 10:40:22.875 Gorm[26233] NSvFlags: 0x10c (268) (268)
                    //2013-06-02 10:40:22.875 Gorm[26233] NSvFlags: 0x102 (258) (258)
                    //2013-06-02 10:40:22.876 Gorm[26233] NSvFlags: 0x104 (260) (260)
                    //2013-06-02 10:40:22.876 Gorm[26233] NSvFlags: 0x102 (258) (258)
                    //2013-06-02 10:40:22.876 Gorm[26233] NSvFlags: 0x10c (268) (268)
                    //2013-06-02 10:40:22.879 Gorm[26233] NSvFlags: 0x10c (268) (268)
                    //2013-06-02 10:40:22.885 Gorm[26233] NSvFlags: 0x10c (268) (268)
                    //2013-06-02 10:40:22.893 Gorm[26233] NSvFlags: 0x10c (268) (268)
                    //2013-06-02 10:40:22.901 Gorm[26233] NSvFlags: 0x10c (268) (268)
                    //2013-06-02 10:40:22.902 Gorm[26233] NSvFlags: 0x10c (268) (268)
                    //2013-06-02 10:40:22.902 Gorm[26233] NSvFlags: 0x12d (301) (301)
                    //2013-06-02 10:40:22.903 Gorm[26233] NSvFlags: 0x112 (274) (274)

                    // We are lucky here, Apple use the same constants
                    // in the lower bits of the flags
                   this.SetAutoresizingMask(vFlags & 0x3F);
                   this.SetAutoresizesSubviews((vFlags & 0x100) == 0x100);
                   this.SetHidden((vFlags & 0x80000000) == 0x80000000);
                }

                 // iterate over subviews and put them into the view...
                subs = (NSArray)aDecoder.DecodeObjectForKey("NSSubviews");
                if (subs != null)
                {
                    e = subs.ObjectEnumerator();
                    while ((sub = (NSView)e.NextObject()) != null)
                    {
                        System.Diagnostics.Debug.Assert(sub.GetClass() != NSCustomView.Class);
                        System.Diagnostics.Debug.Assert(sub.Window == null);
                        System.Diagnostics.Debug.Assert(sub.Superview == null);

                        sub._ViewWillMoveToWindow(_window);
                        sub._ViewWillMoveToSuperview(this);
                        sub.SetNextResponder(this);
                        _sub_views.AddObject(sub);
                        _rFlags.has_subviews = 1;
                        sub.ResetCursorRects();
                        sub.SetNeedsDisplay(true);
                        sub._ViewDidMoveToWindow();
                        sub.ViewDidMoveToSuperview();
                        this.DidAddSubview(sub);

                    }
                }

                //NSvFlags = aDecoder.DecodeIntForKey("NSvFlags");
                //_sub_views = (NSArray)aDecoder.DecodeObjectForKey("NSSubviews");

                //Window = aDecoder.DecodeObjectForKey("NSWindow");
                //ClassName = (NSString)aDecoder.DecodeObjectForKey("NSWindow");

                //Offsets = aDecoder.DecodePointForKey("NSOffsets");

                //Superview = aDecoder.DecodeObjectForKey("NSSuperview");
            }

            return self;
        }
NSView