public virtual NSPoint ConvertPointFromView(NSPoint aPoint, NSView aView) { NSPoint inBase; if (aView == this) { return aPoint; } if (aView != null) { //NS.Assert(_window == aView.Window, @"NSInvalidArgumentException"); inBase = aView._matrixToWindow.TransformPoint(aPoint); } else { inBase = aPoint; } return this._matrixFromWindow.TransformPoint(inBase); }
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); }
/** * Returns self if aView is the receiver or aView is a subview of the receiver, * the ancestor view shared by aView and the receiver if any, or * aView if it is an ancestor of the receiver, otherwise returns nil. */ public virtual NSView AncestorSharedWithView(NSView aView) { NSView self = this; if (self == aView) return self; if (this.IsDescendantOf(aView)) return aView; if (aView.IsDescendantOf(self)) return self; /* * If neither are descendants of each other and either does not have a * superview then they cannot have a common ancestor */ if (_super_view == null) return null; if (aView.Superview == null) return null; /* Find the common ancestor of superviews */ return _super_view.AncestorSharedWithView((NSView)aView.Superview); }
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; }
public virtual void AddSubview(NSView aView) { this.AddSubview (aView, NSWindowOrderingMode.NSWindowAbove, null); }
public virtual NSSize ConvertSizeToView(NSSize aSize, NSView aView) { NSSize inBase = this._MatrixToWindow().TransformSize(aSize); if (inBase.Height < 0.0) { inBase.Height = -inBase.Height; } if (aView != null) { NSSize inOther; //NS.Assert(_window == aView.Window, @"NSInvalidArgumentException"); inOther = aView._MatrixFromWindow().TransformSize(inBase); if (inOther.Height < 0.0) { inOther.Height = -inOther.Height; } return inOther; } else { return inBase; } }
public virtual NSArray GSGetDragTypes(NSView obj) { NSArray t = null; //FIXME //[typesLock lock]; //t = (NSArray*)NSMapGet(typesMap, (void*)(gsaddr)obj); //[typesLock unlock]; return t; }
protected virtual void _ViewDidMoveToWindow() { this.ViewDidMoveToWindow(); 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]._ViewDidMoveToWindow (); } } } }
protected virtual void _ViewWillMoveToSuperview(NSView newSuper) { this.ViewWillMoveToSuperview(newSuper); _super_view = newSuper; }
public virtual void ViewWillMoveToSuperview(NSView newSuper) { }
public virtual void WillRemoveSubview(NSView subview) { }
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); } } }
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; } }
// Drawing custom content public virtual void DrawSegment(int seg, NSRect frame, NSView view) { }
public virtual NSPoint ConvertPointToView(NSPoint aPoint, NSView aView) { NSPoint inBase; if (aView == this) return aPoint; inBase = this._MatrixToWindow().TransformPoint(aPoint); if (aView != null) { //NS.Assert(_window == [aView window], NSInvalidArgumentException); return aView._matrixFromWindow.TransformPoint(inBase); } else { return inBase; } }
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); } } } }
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 static void GSRemoveDragTypes(NSView obj) { //FIXME //[typesLock lock]; //NSMapRemove(typesMap, (void*)(gsaddr)obj); //[typesLock unlock]; }
public virtual void DidAddSubview(NSView subview) { }
public static NSArray GSSetDragTypes(NSView obj, NSArray types) { uint count = (uint)types.Count; NSString[] strings = new NSString[count]; NSArray t = null; uint i = 0; /* * Make a new array with copies of the type strings so we don't get * them mutated by someone else. */ types.GetObjects(strings); for (i = 0; i < count; i++) { strings[i] = strings[i].Copy(); } /* * Store it. */ //[typesLock lock]; //NSMapInsert(typesMap, (void*)(gsaddr)obj, (void*)(gsaddr)t); //[typesLock unlock]; return t; }
/** * Returns YES if aView is an ancestor of the receiver. */ public virtual bool IsDescendantOf(NSView aView) { id self = this; if (aView == self) return true; if (_super_view == null) return false; if (_super_view == aView) return true; return _super_view.IsDescendantOf(aView); }
public virtual void SetContentView(NSView aView) { if (aView != null) { base.ReplaceSubviewWith((NSView)_content_view, (NSView)aView); _content_view = aView; ((NSView)_content_view).Frame = CalcSizesAllowingNegative(false); } }