public virtual void BoundingRectFor(NSRect rect, ref  NSRect newRect)
        {
            NSAffineTransformStruct matrix = this.GetTransformStruct();
            /* Shortcuts of the usual rect values */
            double x = rect.Origin.X;
            double y = rect.Origin.Y;
            double width = rect.Size.Width;
            double height = rect.Size.Height;
            double[] xc = new double[3];
            double[] yc = new double[3];
            double min_x;
            double max_x;
            double min_y;
            double max_y;
            int i;

            max_x = _matrix.m11 * x + _matrix.m21 * y + _matrix.tX;
            max_y = _matrix.m12 * x + _matrix.m22 * y + _matrix.tY;
            xc[0] = max_x + _matrix.m11 * width;
            yc[0] = max_y + _matrix.m12 * width;
            xc[1] = max_x + _matrix.m21 * height;
            yc[1] = max_y + _matrix.m22 * height;
            xc[2] = max_x + _matrix.m11 * width + _matrix.m21 * height;
            yc[2] = max_y + _matrix.m12 * width + _matrix.m22 * height;

            min_x = max_x;
            min_y = max_y;

            for (i = 0; i < 3; i++)
            {
                if (xc[i] < min_x)
                    min_x = xc[i];
                if (xc[i] > max_x)
                    max_x = xc[i];

                if (yc[i] < min_y)
                    min_y = yc[i];
                if (yc[i] > max_y)
                    max_y = yc[i];
            }

            newRect = NSRect.Make(min_x, min_y, max_x - min_x, max_y - min_y);
            //newRect.Origin.X = min_x;
            //newRect.Origin.Y = min_y;
            //newRect.Size.Width = max_x -min_x;
            //newRect.Size.Height = max_y -min_y;
        }
Beispiel #2
0
        public override id InitWithFrame(NSRect aFrame)
        {
            id self = this;

            //self = [super initWithFrame: aFrame];
            //if (!self)
            //  return nil;

            //[self setFont: [NSFont menuFontOfSize: 0.0]];

            _highlightedItemIndex = -1;
            _horizontalEdgePad = 4.0f;

            /* Set the necessary offset for the menuView. That is, how many pixels
             * do we need for our left side border line.
             */
            _leftBorderOffset = 1;

            // Create an array to store our menu item cells.
            _itemCells = (NSMutableArray)NSMutableArray.Alloc().Init();

            return self;
        }
Beispiel #3
0
        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;
        }
Beispiel #4
0
 public virtual void DisplayRectIgnoringOpacity(NSRect aRect, NSGraphicsContext context)
 {
 }
Beispiel #5
0
 public virtual void DisplayRect(NSRect aRect)
 {
 }
Beispiel #6
0
 public virtual void DisplayIfNeededInRect(NSRect aRect)
 {
 }
Beispiel #7
0
 public virtual NSRect ConvertRectToBase(NSRect aRect)
 {
     return this.ConvertRectToView(aRect, null);
 }
Beispiel #8
0
        /* Helper for -convertRect:fromView: and -convertRect:toView:. */
        private static NSRect convert_rect_using_matrices(NSRect aRect, NSAffineTransform matrix1,
            NSAffineTransform matrix2)
        {
            NSRect r = new NSRect();
            NSPoint[] p = new NSPoint[4];
            NSPoint min, max;
            int i;

            for (i = 0; i < 4; i++)
                p[i] = aRect.Origin;
            p[1].X += aRect.Size.Width;
            p[2].Y += aRect.Size.Height;
            p[3].X += aRect.Size.Width;
            p[3].Y += aRect.Size.Height;

            for (i = 0; i < 4; i++)
                p[i] = matrix1.TransformPoint(p[i]);

            min = max = p[0] = matrix2.TransformPoint(p[0]);
            for (i = 1; i < 4; i++)
            {
                p[i] = matrix2.TransformPoint(p[i]);
                min.X = Math.Min(min.X, p[i].X);
                min.Y = Math.Min(min.Y, p[i].Y);
                max.X = Math.Max(max.X, p[i].X);
                max.Y = Math.Max(max.Y, p[i].Y);
            }

            r.Origin = min;
            r.Size = NS.MakeSize(max.X - min.X, max.Y - min.Y);
            //r.Size.Width = max.X - min.X;
            //r.Size.Height = max.Y - min.Y;

            return r;
        }
Beispiel #9
0
        private static NSRect IntegralRect(NSRect rect, NSView view)
        {
            NSRect dummy = new NSRect();

            //NSRect output;
            //int rounded;

            //output = [view convertRect: rect  toView: nil];

            //rounded = (int)(output.origin.x);
            //if ((CGFloat)rounded != output.origin.x)
            //  {
            //    output.origin.x = rounded + 1;
            //  }

            //rounded = (int)(output.origin.y);
            //if ((CGFloat)rounded != output.origin.y)
            //  {
            //    output.origin.y = rounded + 1;
            //  }

            //rounded = (int)(NSMaxX (output));
            //if ((CGFloat)rounded != NSMaxX (output))
            //  {
            //    output.size.width = rounded - output.origin.x;
            //  }

            //rounded = (int)(NSMaxY (output));
            //if ((CGFloat)rounded != NSMaxY (output))
            //  {
            //    output.size.height = rounded - output.origin.y;
            //  }

            //return [view convertRect: output  fromView: nil];
            //return output;

            return dummy;
        }
Beispiel #10
0
 public override void SetFrame(NSRect frameRect)
 {
     base.Frame = frameRect;
     if (_content_view != null)
         ((NSView)_content_view).Frame = CalcSizesAllowingNegative(false);
 }
Beispiel #11
0
        public virtual void SetFrameFromContentFrame(NSRect contentFrame)
        {
            NSRect r = this.CalcSizesAllowingNegative(true);
            NSRect f = _frame;

            if (_super_view != null)
                r = _super_view.ConvertRectFromView(r, this);

            // Add the difference to the frame
            double w = f.Size.Width + (contentFrame.Size.Width - r.Size.Width);
            double h = f.Size.Height + (contentFrame.Size.Height - r.Size.Height);
            f.Size = new NSSize(w, h);

            double x = f.Origin.X + (contentFrame.Origin.X - r.Origin.X);
            double y = f.Origin.Y + (contentFrame.Origin.Y - r.Origin.Y);
            f.Origin = new NSPoint(x,y);

            this.Frame = f;
            ((NSView)_content_view).Frame = CalcSizesAllowingNegative(false);
        }
Beispiel #12
0
        public virtual NSSize MinimumSize()
        {
            NSRect rect = new NSRect();
            //NSSize borderSize = [[GSTheme theme] sizeForBorderType: _border_type];

            if (_content_view.RespondsToSelector(new SEL("MinimumSize")))
            {
                rect.Size = (NSSize)Objc.MsgSend(_content_view, @"MinimumSize");
            }
            else
            {
                NSArray subviewArray = ((NSView)_content_view).SubViews;
                if (subviewArray.Count != 0)
                {
                    id subview;
                    NSEnumerator enumerator;
                    enumerator = subviewArray.ObjectEnumerator();
                    rect = ((NSView)enumerator.NextObject()).Frame;

                    // Loop through subviews and calculate rect
                    // to encompass all
                    while ((subview = enumerator.NextObject()) != null)
                      {
                        rect = NSRect.Union(rect, ((NSView)subview).Frame);
                      }
                  }
                else // _content_view has no subviews
                  {
                    rect = NSRect.Zero;
                }
            }

            // FIXME
            //rect.size = [self convertSize: rect.size fromView:_content_view];
            //rect.size.width += (2 * _offsets.width) + (2 * borderSize.width);
            //rect.size.height += (2 * _offsets.height) + (2 * borderSize.height);

            return rect.Size;
        }
Beispiel #13
0
        public override id InitWithFrame(NSRect frameRect)
        {
            id self = this;

            NSView cv;

            if (base.InitWithFrame(frameRect) == null)
                return null;

            _cell = (id)Objc.MsgSend(NSCell.Alloc(), "InitTextCell", @"Title");
            ((NSCell)_cell).Alignment = NSTextAlignment.NSCenterTextAlignment;
            ((NSCell)_cell).Bordered = false;
            ((NSCell)_cell).Editable = false;
            this.TitleFont = NSFont.SystemFontOfSize(NSFont.SmallSystemFontSize);

            _offsets.Width = 5;
            _offsets.Height = 5;
            _border_rect = _bounds;
            _border_type = NSBorderType.NSGrooveBorder;
            _title_position = NSTitlePosition.NSAtTop;
            _title_rect = NSRect.Zero;

            // FIXME
            //this.AutoresizesSubviews = false;

            cv = (NSView)NSView.Alloc().Init();
            this.ContentView = cv;

            return self;
        }
Beispiel #14
0
 public override void DrawRect(NSRect aRect)
 {
     //FIXME
     //[self drawCell: _cell];
 }
Beispiel #15
0
 public virtual void SetNeedsDisplayInRect(NSRect invalidRect)
 {
 }
Beispiel #16
0
        public virtual id InitWithContentRect(NSRect contentRect, int aStyle, NSBackingStoreType bufferingType, bool flag)
        {
            id self = this;

            return self;
        }
Beispiel #17
0
 public virtual void _SetFrameAndClearAutoresizingError(NSRect frameRect)
 {
     _frame = frameRect;
     _autoresizingFrameError = NSRect.Zero;
 }
Beispiel #18
0
 //
 // Drawing
 //
 public virtual void DrawSwatchInRect(NSRect rect)
 {
 }
Beispiel #19
0
 public virtual NSRect CenterScanRect(NSRect aRect)
 {
     //FIXME
     return new NSRect ();
 }
        public NSRect DecodeRectForKey(string keyName)
        {
            NSRect nsRect = new NSRect();

            XElement xElm = _classDict.Find( i => (string)i.Attribute("key") == keyName);
            if (xElm != null)
            {
                nsRect = (NSRect)(NSString)this.Create(xElm);
            }

            return nsRect;
        }
Beispiel #21
0
        public virtual NSRect ConvertRectToView(NSRect aRect, NSView aView)
        {
            NSAffineTransform matrix1, matrix2;

            if (aView == this || _window == null || (aView != null && aView.Window == null))
            {
                return aRect;
            }

            matrix1 = this._MatrixToWindow();

            if (aView != null)
            {
                //NS.Assert(_window == aView.Window, @"NSInvalidArgumentException");
                matrix2 = aView._MatrixFromWindow();
            }
            else
            {
                matrix2 = NSAffineTransform.Transform;
            }

            return convert_rect_using_matrices(aRect, matrix1, matrix2);
        }
        public override id InitWithCoder(NSCoder aDecoder)
        {
            base.InitWithCoder(aDecoder);

            if (aDecoder.AllowsKeyedCoding)
            {
                if (aDecoder.ContainsValueForKey("NSViewClass"))
                {
                    _viewClass = (id)aDecoder.DecodeObjectForKey("NSViewClass");
                }
                if (aDecoder.ContainsValueForKey("NSWindowClass"))
                {
                    _windowClass = (NSString)aDecoder.DecodeObjectForKey("NSWindowClass");
                }
                if (aDecoder.ContainsValueForKey("NSWindowStyleMask"))
                {
                    _windowStyle = (uint)aDecoder.DecodeIntForKey("NSWindowStyleMask");
                }
                if (aDecoder.ContainsValueForKey("NSWindowBacking"))
                {
                    _backingStoreType = (NSBackingStoreType)aDecoder.DecodeIntForKey("NSWindowBacking");
                }
                if (aDecoder.ContainsValueForKey("NSWindowView"))
                {
                    _view = (id)aDecoder.DecodeObjectForKey("NSWindowView");
                }
                if (aDecoder.ContainsValueForKey("NSWTFlags"))
                {
                    uint flags = (uint)aDecoder.DecodeIntForKey("NSWTFlags");
                    _flags = PrimitiveConversion.FromLong<GSWindowTemplateFlags>(flags);
                }
                if (aDecoder.ContainsValueForKey("NSMinSize"))
                {
                    _minSize = aDecoder.DecodeSizeForKey("NSMinSize");
                }
                if (aDecoder.ContainsValueForKey("NSMaxSize"))
                {
                    _maxSize = aDecoder.DecodeSizeForKey("NSMaxSize");
                }
                else
                {
                    _maxSize = new NSSize((float)10e+4, (float)10e+4);
                }

                if (aDecoder.ContainsValueForKey("NSWindowRect"))
                {
                    _windowRect = aDecoder.DecodeRectForKey("NSWindowRect");
                }
                if (aDecoder.ContainsValueForKey("NSFrameAutosaveName"))
                {
                    _autosaveName = (NSString)aDecoder.DecodeObjectForKey("NSFrameAutosaveName");
                }
                if (aDecoder.ContainsValueForKey("NSWindowTitle"))
                {
                    _title = (NSString)aDecoder.DecodeObjectForKey("NSWindowTitle");
                    _windowStyle |= (uint)NSWindowStyleMasks.NSTitledWindowMask;
                }

                //_baseWindowClass = [NSWindow class];
            }
            else
            {
                //[NSException raise: NSInvalidArgumentException 
                //             format: @"Can't decode %@ with %@.",NSStringFromClass([self class]),
                //             NSStringFromClass([coder class])];
            }

            //if (aDecoder.AllowsKeyedCoding)
            //{
            //    StyleMask = (NSWindowStyleMasks)aDecoder.DecodeIntForKey("NSWindowStyleMask");
            //    Backing = aDecoder.DecodeIntForKey("NSWindowBacking");
            //    WindowRect = aDecoder.DecodeRectForKey("NSWindowRect");
            //    NSWTFlags = (uint)aDecoder.DecodeIntForKey("NSWTFlags");
            //    if (aDecoder.ContainsValueForKey("NSWindowTitle"))
            //    {
            //        Title = (NSString)aDecoder.DecodeObjectForKey("NSWindowTitle");
            //        StyleMask |= NSWindowStyleMasks.NSTitledWindowMask;
            //    }

            //    WindowClass = (NSString)aDecoder.DecodeObjectForKey("NSWindowClass");
            //    Toolbar = (NSToolbar)aDecoder.DecodeObjectForKey("NSViewClass");
            //    WindowView = (NSView)aDecoder.DecodeObjectForKey("NSWindowView");
            //    ScreenRect = (NSRect)aDecoder.DecodeRectForKey("NSScreenRect");
            //    IsRestorable = aDecoder.DecodeBoolForKey("NSWindowIsRestorable");

            //    MinSize = aDecoder.DecodeSizeForKey("NSMinSize");

            //    if (aDecoder.ContainsValueForKey("NSMaxSize"))
            //    {
            //        MaxSize = aDecoder.DecodeSizeForKey("NSMaxSize");
            //    }
            //    else
            //    {
            //        MaxSize = new NSSize((float)10e+4, (float)10e+4);
            //    }
            //}

            return this;
        }
Beispiel #23
0
 public virtual void DisplayIfNeededInRectIgnoringOpacity(NSRect aRect)
 {
 }
 // Drawing custom content
 public virtual void DrawSegment(int seg, NSRect frame, NSView view)
 {
 }
Beispiel #25
0
 public virtual void DisplayRectIgnoringOpacity(NSRect aRect)
 {
 }
Beispiel #26
0
        public virtual void SetBounds(NSRect aRect)
        {
            //NSDebugLLog(@"NSView", @"setBounds %@", NSStringFromRect(aRect));
            if (aRect.Size.Width < 0)
            {
                //NSWarnMLog(@"given negative width", 0);
                //aRect.Size.Width = 0;
                aRect.Size = NS.MakeSize(0, aRect.Size.Height);
            }
            if (aRect.Size.Height < 0)
            {
                //NSWarnMLog(@"given negative height", 0);
                //aRect.Size.Height = 0;
                aRect.Size = NS.MakeSize(aRect.Size.Width, 0);
            }

            if (_is_rotated_from_base || (NS.EqualRects(_bounds, aRect) == false))
            {
                NSAffineTransform matrix;
                NSPoint oldOrigin;
                NSSize scale;

                if (_boundsMatrix == null)
                {
                    _boundsMatrix = (NSAffineTransform)NSAffineTransform.Alloc().Init();
                }

                // Adjust scale
                scale = _computeScale(_frame.Size, aRect.Size);
                if (scale.Width != 1 || scale.Height != 1)
                {
                    _is_rotated_or_scaled_from_base = true;
                }
                _boundsMatrix.ScaleTo(scale.Width, scale.Height);
                {
                    matrix = (NSAffineTransform)_boundsMatrix.Copy();
                    matrix.Invert();
                    oldOrigin = matrix.TransformPoint(NS.MakePoint(0, 0));
                    //RELEASE(matrix);
                }
                _boundsMatrix.TranslateXByYBy(oldOrigin.X - aRect.Origin.X, oldOrigin.Y - aRect.Origin.Y);
                if (!_is_rotated_from_base)
                {
                    // Adjust bounds
                    _bounds = aRect;
                }
                else
                {
                    // Adjust bounds
                    NSRect frame = _frame;

                    frame.Origin = NS.MakePoint(0, 0);
                    matrix = (NSAffineTransform)_boundsMatrix.Copy();
                    matrix.Invert();
                    matrix.BoundingRectFor(frame, ref _bounds);
                    //RELEASE(matrix);
                }

                if (_coordinates_valid)
                {
                    //FIXME
                    //(*invalidateImp)(self, invalidateSel);
                }
                this.ResetCursorRects();
                if (_post_bounds_changes)
                {
                    //[nc postNotificationName: NSViewBoundsDidChangeNotification object: self];
                }
            }
        }
Beispiel #27
0
 public virtual void DrawRect(NSRect rect)
 {
 }
Beispiel #28
0
        public virtual void SetFrame(NSRect frameRect)
        {
            bool	changedOrigin = false;
            bool	changedSize = false;
            NSSize old_size = _frame.Size;

            if (frameRect.Size.Width < 0)
            {
                //NSWarnMLog(@"given negative width", 0);
                //frameRect.Size.Width = 0;
                frameRect.Size = NS.MakeSize(0, frameRect.Size.Height);
            }
            if (frameRect.Size.Height < 0)
            {
                //NSWarnMLog(@"given negative height", 0);
                //frameRect.Size.Height = 0;
                frameRect.Size = NS.MakeSize(frameRect.Size.Width, 0);
            }

            if (NS.EqualPoints(_frame.Origin, frameRect.Origin) == false)
            {
                changedOrigin = true;
            }
            if (NS.EqualSizes(_frame.Size, frameRect.Size) == false)
            {
                changedSize = true;
            }

            if (changedSize == true || changedOrigin == true)
            {
                this._SetFrameAndClearAutoresizingError(frameRect);

                if (changedSize == true)
                {
                    if (_is_rotated_or_scaled_from_base == true)
                    {
                        NSAffineTransform matrix;
                        NSRect frame = _frame;

                        frame.Origin = NS.MakePoint(0, 0);
                        matrix = (NSAffineTransform)_boundsMatrix.Copy();
                        matrix.Invert();
                        matrix.BoundingRectFor(frame, ref _bounds);
                        //RELEASE(matrix);
                    }
                    else
                    {
                        _bounds.Size = frameRect.Size;
                    }
                }

                if (_coordinates_valid)
                {
                    //FIXME
                    //(*invalidateImp)(self, invalidateSel);
                }
                this.ResetCursorRects();
                this.ResizeSubviewsWithOldSize(old_size);
                if (_post_frame_changes)
                {
                    //[nc postNotificationName: NSViewFrameDidChangeNotification object: self];
                }
            }
        }
Beispiel #29
0
        public virtual id InitWithFrame(NSRect frameRect)
        {
            id self = this;

            if (base.Init() == null)
                return null;

            if (frameRect.Size.Width < 0)
            {
                frameRect.Size = new NSSize(0, frameRect.Size.Height);
            }
            if (frameRect.Size.Height < 0)
            {
                frameRect.Size = new NSSize(frameRect.Size.Width, 0);
            }

            _frame = frameRect;			// Set frame rectangle
            _bounds.Origin = NSPoint.Zero;		// Set bounds rectangle
            _bounds.Size = _frame.Size;

            // _frameMatrix = [NSAffineTransform new];    // Map fromsuperview to frame
            // _boundsMatrix = [NSAffineTransform new];   // Map from superview to bounds
            _matrixToWindow = (NSAffineTransform)NSAffineTransform.Alloc().Init();   // Map to window coordinates
            _matrixFromWindow = (NSAffineTransform)NSAffineTransform.Alloc().Init(); // Map from window coordinates

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

            // Some values are already set by initialisation
            //_super_view = nil;
            //_window = nil;
            //_is_rotated_from_base = NO;
            //_is_rotated_or_scaled_from_base = NO;
            _rFlags.needs_display = 1;
            _post_bounds_changes = true;
            _post_frame_changes = true;
            _autoresizes_subviews = true;
            _autoresizingMask = (uint)NSViewAutoresizingMasks.NSViewNotSizable;
            //_coordinates_valid = NO;
            //_nextKeyView = 0;
            //_previousKeyView = 0;

            return self;
        }
        //Returns the smallest rectangle that completely encloses both aRect and bRect.
        //If one of the rectangles has 0 (or negative) width or height, a copy of the other rectangle is returned;
        //but if both have 0 (or negative) width or height, the returned rectangle has its origin at (0.0, 0.0) and has 0 width and height.
        public static NSRect Union(NSRect aRect, NSRect bRect)
        {
            NSRect rect = new NSRect();

            if (aRect.IsEmpty && bRect.IsEmpty)
                return NSRect.Make(0.0, 0.0, 0.0, 0.0);
            else if (aRect.IsEmpty)
                return bRect;
            else if (bRect.IsEmpty)
                return aRect;

            rect = NSRect.Make(Math.Min(aRect.MinX, bRect.MinX), Math.Min(aRect.MinY, bRect.MinY), 0.0, 0.0);

            rect = NSRect.Make(rect.MinX,
                               rect.MinY,
                               Math.Max(aRect.MaxX, bRect.MaxX) - rect.MinX,
                               Math.Max(aRect.MaxY, bRect.MaxY) - rect.MinY);
            return rect;
        }