Exemplo n.º 1
0
        public bool rulerViewShouldMoveMarker(NSRulerView aRulerView, NSRulerMarker aMarker)
        {
            if (selectedItem == null || selectedItem.IsLocked)
            {
                return(false);
            }

            return(true);
        }
Exemplo n.º 2
0
        public void rulerViewDidRemoveMarker(NSRulerView aRulerView, NSRulerMarker aMarker)
        {
            if (selectedItem == null)
            {
                return;
            }

            SetNeedsDisplayInRect(selectedItem.Frame);
            rects.Remove(selectedItem);
            selectedItem = null;
            updateRulers();
        }
Exemplo n.º 3
0
        public void rulerViewDidRemoveMarker(NSRulerView aRulerView, NSEvent theEvent)
        {
            NSRulerMarker newMarker;

            if (aRulerView.Orientation == NSRulerOrientation.Horizontal)
            {
                newMarker = new NSRulerMarker(aRulerView, 0.0f, leftImage, PointF.Empty);
            }
            else
            {
                newMarker = new NSRulerMarker(aRulerView, 0.0f, topImage, new PointF(8.0f, 8.0f));
            }

            aRulerView.TrackMarker(newMarker, theEvent);
        }
Exemplo n.º 4
0
        private void updateHorizontalRuler()
        {
            NSScrollView  scrollView;
            NSRulerView   horizRuler = null;
            NSRulerMarker leftMarker;
            NSRulerMarker rightMarker;

            scrollView = EnclosingScrollView;
            if (scrollView == null)
            {
                return;
            }

            horizRuler = scrollView.HorizontalRulerView;
            if (horizRuler == null)
            {
                return;
            }

            if (horizRuler.ClientView != this)
            {
                horizRuler.ClientView       = this;
                horizRuler.MeasurementUnits = "MyCustomRulerUnits";
            }

            if (selectedItem == null)
            {
                horizRuler.Markers = null;
                return;
            }

            leftMarker = new NSRulerMarker(horizRuler, MinX(selectedItem.Frame),
                                           leftImage, Point.Empty);
            rightMarker = new NSRulerMarker(horizRuler, MaxX(selectedItem.Frame),
                                            rightImage, new PointF(7.0f, 0.0f));
            horizRuler.Markers = new NSRulerMarker[] { leftMarker, rightMarker };

            leftMarker.Removable  = true;
            rightMarker.Removable = true;

            leftMarker.RepresentedObject  = STR_LEFT_OBJ;
            rightMarker.RepresentedObject = STR_RIGHT_OBJ;
        }
Exemplo n.º 5
0
        public void rulerViewDidAddMarker(NSRulerView aRulerView, NSRulerMarker aMarker)
        {
            float      theOtherCoord;
            RectangleF newRect;
            NSColor    newColor;
            ColorRect  newColorRect;

            var visibleRect = VisibleRect();

            aMarker.Removable = true;

            if (aRulerView.Orientation == NSRulerOrientation.Horizontal)
            {
                theOtherCoord = MaxY(visibleRect) - 165.0f;
                newRect       = new RectangleF(aMarker.MarkerLocation, theOtherCoord, 115.0f, 115.0f);
            }
            else
            {
                if (IsFlipped)
                {
                    theOtherCoord = MinX(visibleRect) + 50.0f;
                    newRect       = new RectangleF(theOtherCoord, aMarker.MarkerLocation, 115.0f, 115.0f);
                }
                else
                {
                    theOtherCoord = MinX(visibleRect) + 50.0f;
                    newRect       = new RectangleF(theOtherCoord, aMarker.MarkerLocation - 115.0f, 115.0f, 115.0f);
                }
            }

            newColor = NSColor.FromDeviceRgba((float)rand.NextDouble(),
                                              (float)rand.NextDouble(),
                                              (float)rand.NextDouble(),
                                              1.0f);
            newColorRect = new ColorRect(newRect, newColor);
            rects.Add(newColorRect);
            selectRect(newColorRect);
        }
Exemplo n.º 6
0
 public void rulerViewDidMoveMarker(NSRulerView aRulerView, NSRulerMarker aMarker)
 {
     updateSelectedRectFromRulers();
 }
Exemplo n.º 7
0
 public float RulerViewWillAddMarkeratLocation(NSRulerView ruler, NSRulerMarker marker, float location)
 {
     return(RulerViewWillAddMarker(ruler, marker, location));
 }
Exemplo n.º 8
0
 public float RulerViewWillMoveMarkertoLocation(NSRulerView ruler, NSRulerMarker marker, float location)
 {
     return RulerViewWillMoveMarker (ruler, marker, location);
 }
Exemplo n.º 9
0
		public bool rulerViewShouldAddMarker (NSRulerView aRulerView, NSRulerMarker aMarker)
		{
			return true;	
		}
Exemplo n.º 10
0
		public void rulerViewDidRemoveMarker (NSRulerView aRulerView, NSRulerMarker aMarker)
		{
			if (selectedItem == null) 
				return;
			
			SetNeedsDisplayInRect (selectedItem.Frame);
			rects.Remove (selectedItem);
			selectedItem = null;
			updateRulers ();
		}
Exemplo n.º 11
0
		public bool rulerViewShouldRemoveMarker (NSRulerView aRulerView, NSRulerMarker aMarker)
		{
			if (selectedItem != null && !selectedItem.IsLocked) 
				return true;
			
			return false;
		}
Exemplo n.º 12
0
		public void rulerViewDidMoveMarker (NSRulerView aRulerView, NSRulerMarker aMarker)
		{
			updateSelectedRectFromRulers ();
		}
Exemplo n.º 13
0
		public float rulerViewWillMoveMarker(NSRulerView aRulerView, NSRulerMarker aMarker, float location)
		{
			NSEvent currentEvent;
			bool shifted;
			RectangleF rect, dirtyRect;
			NSString theEdge = (NSString)aMarker.RepresentedObject;
			
			if (selectedItem == null) 
				return location;
			
			rect = selectedItem.Frame;
			dirtyRect = rect;
			dirtyRect.Size = setRectWidth (dirtyRect,rect.Width + 2.0f);  // fudge to counter hilite prob
			dirtyRect.Size = setRectHeight (dirtyRect, rect.Height + 2.0f);
			
			SetNeedsDisplayInRect (dirtyRect);
			
			currentEvent = NSApplication.SharedApplication.CurrentEvent;
			var eventFlags = currentEvent.ModifierFlags;
			
			shifted = (eventFlags & NSEventModifierMask.ShiftKeyMask) == NSEventModifierMask.ShiftKeyMask;
			
			if (!shifted) {
				switch (theEdge.ToString()){
				case STR_LEFT:
					if (location > MaxX(rect) - MIN_SIZE)
						location = MaxX(rect) - MIN_SIZE;
					
					rect.Size = setRectWidth(rect, MaxX(rect) - location);
					rect.Location = setOriginX(rect,location);
					break;

				case STR_RIGHT:
					if (location < MinX(rect) + MIN_SIZE)
						location = MinX(rect) + MIN_SIZE;
					
					rect.Size = setRectWidth(rect, location - MinX(rect));
					break;	

				case STR_TOP:
					if (this.IsFlipped) {
						if (location > MaxY(rect) - MIN_SIZE)
							location = MaxY(rect) - MIN_SIZE;
					
						rect.Size = setRectHeight(rect, MaxY(rect) - location);
						rect.Location = setOriginY(rect,location);
					} else {
						if (location < MinY(rect) + MIN_SIZE)
							location = MinY(rect) + MIN_SIZE;
					
						rect.Size = setRectHeight(rect, location - MinY(rect));
					}
					break;						

				case STR_BOTTOM:
					if (this.IsFlipped) {
						if (location < MinY(rect) + MIN_SIZE)
							location = MinY(rect) + MIN_SIZE;
					
						rect.Size = setRectHeight(rect, location - MinY(rect));
					} else {
						if (location > MaxY(rect) - MIN_SIZE)
							location = MaxY(rect) - MIN_SIZE;
					
						rect.Size = setRectHeight(rect, MaxY(rect) - location);
						rect.Location = setOriginY(rect,location);
					}
					break;						
				}
			} else {
				NSRulerMarker [] markers = aRulerView.Markers;
				NSRulerMarker otherMarker;
				
				otherMarker = markers [0];
				
				if (otherMarker == aMarker)
					otherMarker = markers [1];
				
				switch (theEdge.ToString ())
				{
				case STR_LEFT:
					rect.Location = setOriginX (rect, location);
					otherMarker.MarkerLocation = MaxX (rect);
					break;
				case STR_RIGHT:
					rect.Location = setOriginX (rect, location - rect.Width);
					otherMarker.MarkerLocation = MinX (rect);
					break;
				case STR_TOP:
					if (this.IsFlipped) 
					{
						rect.Location = setOriginY (rect,location);
						otherMarker.MarkerLocation = MaxY (rect);
					} else {
						rect.Location = setOriginY (rect, location - rect.Height);
						otherMarker.MarkerLocation = MinY (rect);
					}
					break;						
				case STR_BOTTOM:
					if (this.IsFlipped)  {
						rect.Location = setOriginY (rect,location - rect.Height);
						otherMarker.MarkerLocation = MinY (rect);
					} else {
						rect.Location = setOriginY (rect,location);
						otherMarker.MarkerLocation = MaxY (rect);
					}
					break;								
				}
			}
			
			selectedItem.Frame = rect;
			SetNeedsDisplayInRect (rect);
			
			return location;	
		}
Exemplo n.º 14
0
		private void updateVerticalRuler() 
		{
			
			NSScrollView scrollView;
			NSRulerView vertRuler = null;
			PointF thePoint; 	/* Just a temporary scratch variable */
			float location;
			NSRulerMarker topMarker;
			NSRulerMarker bottomMarker;
			
			scrollView = EnclosingScrollView;
			if (scrollView == null) 
				return;
			
			vertRuler = scrollView.VerticalRulerView;
			if (vertRuler == null) 
				return;
			
			if (vertRuler.ClientView != this){
				vertRuler.ClientView = this;
				vertRuler.MeasurementUnits = "MyCustomRulerUnits";
			}
			
			if (selectedItem == null){
				vertRuler.Markers = null;
				return;
			}
			
			if (IsFlipped)
				location = MaxY (selectedItem.Frame);
			else
				location = MinY (selectedItem.Frame);	
			
			thePoint = new PointF (8.0f, 1.0f);
			bottomMarker = new NSRulerMarker (vertRuler, location, bottomImage, thePoint);
			bottomMarker.Removable = true;
			bottomMarker.RepresentedObject = STR_BOTTOM_OBJ;
			
			if (this.IsFlipped)
				location = MinY (selectedItem.Frame);
			else
				location = MaxY (selectedItem.Frame);	

			thePoint = new PointF (8.0f, 8.0f);
			
			topMarker = new NSRulerMarker (vertRuler, location, topImage, thePoint);
			topMarker.Removable = true;
			topMarker.RepresentedObject = STR_TOP_OBJ;

			vertRuler.Markers = new NSRulerMarker[] { bottomMarker,topMarker };
		}
Exemplo n.º 15
0
		private void updateHorizontalRuler() 
		{
			NSScrollView scrollView;
			NSRulerView horizRuler = null;
			NSRulerMarker leftMarker;
			NSRulerMarker rightMarker;
			
			scrollView = EnclosingScrollView;
			if (scrollView == null) 
				return;
			
			horizRuler = scrollView.HorizontalRulerView;
			if (horizRuler == null) 
				return;
			
			if (horizRuler.ClientView != this){
				horizRuler.ClientView = this;
				horizRuler.MeasurementUnits = "MyCustomRulerUnits";
			}
			
			if (selectedItem == null){
				horizRuler.Markers = null;
				return;
			}
			
			leftMarker = new NSRulerMarker (horizRuler, MinX(selectedItem.Frame), 
			                                leftImage, Point.Empty);
			rightMarker = new NSRulerMarker (horizRuler, MaxX(selectedItem.Frame),
			                                 rightImage, new PointF(7.0f,0.0f));
			horizRuler.Markers = new NSRulerMarker[] { leftMarker, rightMarker };
			
			leftMarker.Removable = true;
			rightMarker.Removable = true;
			
			leftMarker.RepresentedObject = STR_LEFT_OBJ;
			rightMarker.RepresentedObject = STR_RIGHT_OBJ;
		}
Exemplo n.º 16
0
 public bool rulerViewShouldAddMarker(NSRulerView aRulerView, NSRulerMarker aMarker)
 {
     return(true);
 }
Exemplo n.º 17
0
 public float rulerViewWillAddMarker(NSRulerView aRulerView, NSRulerMarker aMarker, float location)
 {
     return(location);
 }
Exemplo n.º 18
0
		public float rulerViewWillAddMarker (NSRulerView aRulerView, NSRulerMarker aMarker, float location)
		{
			return location;	
		}
Exemplo n.º 19
0
		public void rulerViewDidAddMarker (NSRulerView aRulerView, NSRulerMarker aMarker)
		{
			float theOtherCoord;
			RectangleF newRect;
			NSColor newColor;
			ColorRect newColorRect;
			
			var visibleRect = VisibleRect();
			
			aMarker.Removable = true;
			
			if (aRulerView.Orientation == NSRulerOrientation.Horizontal){
				theOtherCoord = MaxY (visibleRect) - 165.0f;
				newRect = new RectangleF (aMarker.MarkerLocation, theOtherCoord, 115.0f, 115.0f);
			} else {
				if (IsFlipped) {
					theOtherCoord = MinX (visibleRect) + 50.0f;
					newRect = new RectangleF(theOtherCoord, aMarker.MarkerLocation, 115.0f, 115.0f);
				} else {
					theOtherCoord = MinX(visibleRect) + 50.0f;
					newRect = new RectangleF (theOtherCoord, aMarker.MarkerLocation - 115.0f, 115.0f, 115.0f);
				}
			}
				
			newColor = NSColor.FromDeviceRgba ((float)rand.NextDouble (),
			                                        (float)rand.NextDouble (),
			                                        (float)rand.NextDouble (),
			                                        1.0f);
			newColorRect = new ColorRect (newRect, newColor);
			rects.Add (newColorRect);
			selectRect (newColorRect);
		}		
Exemplo n.º 20
0
		public void rulerViewDidRemoveMarker (NSRulerView aRulerView, NSEvent theEvent)
		{
			NSRulerMarker newMarker;
			
			if (aRulerView.Orientation == NSRulerOrientation.Horizontal)
				newMarker = new NSRulerMarker (aRulerView, 0.0f, leftImage, PointF.Empty);
			else
				newMarker = new NSRulerMarker (aRulerView, 0.0f, topImage, new PointF (8.0f,8.0f));
			
			aRulerView.TrackMarker (newMarker, theEvent);
		}	
Exemplo n.º 21
0
        private void updateVerticalRuler()
        {
            NSScrollView  scrollView;
            NSRulerView   vertRuler = null;
            PointF        thePoint;             /* Just a temporary scratch variable */
            float         location;
            NSRulerMarker topMarker;
            NSRulerMarker bottomMarker;

            scrollView = EnclosingScrollView;
            if (scrollView == null)
            {
                return;
            }

            vertRuler = scrollView.VerticalRulerView;
            if (vertRuler == null)
            {
                return;
            }

            if (vertRuler.ClientView != this)
            {
                vertRuler.ClientView       = this;
                vertRuler.MeasurementUnits = "MyCustomRulerUnits";
            }

            if (selectedItem == null)
            {
                vertRuler.Markers = null;
                return;
            }

            if (IsFlipped)
            {
                location = MaxY(selectedItem.Frame);
            }
            else
            {
                location = MinY(selectedItem.Frame);
            }

            thePoint                       = new PointF(8.0f, 1.0f);
            bottomMarker                   = new NSRulerMarker(vertRuler, location, bottomImage, thePoint);
            bottomMarker.Removable         = true;
            bottomMarker.RepresentedObject = STR_BOTTOM_OBJ;

            if (this.IsFlipped)
            {
                location = MinY(selectedItem.Frame);
            }
            else
            {
                location = MaxY(selectedItem.Frame);
            }

            thePoint = new PointF(8.0f, 8.0f);

            topMarker                   = new NSRulerMarker(vertRuler, location, topImage, thePoint);
            topMarker.Removable         = true;
            topMarker.RepresentedObject = STR_TOP_OBJ;

            vertRuler.Markers = new NSRulerMarker[] { bottomMarker, topMarker };
        }
Exemplo n.º 22
0
 public float RulerViewWillMoveMarkertoLocation(NSRulerView ruler, NSRulerMarker marker, float location)
 {
     return(RulerViewWillMoveMarker(ruler, marker, location));
 }
Exemplo n.º 23
0
        public float rulerViewWillMoveMarker(NSRulerView aRulerView, NSRulerMarker aMarker, float location)
        {
            NSEvent    currentEvent;
            bool       shifted;
            RectangleF rect, dirtyRect;
            NSString   theEdge = (NSString)aMarker.RepresentedObject;

            if (selectedItem == null)
            {
                return(location);
            }

            rect           = selectedItem.Frame;
            dirtyRect      = rect;
            dirtyRect.Size = setRectWidth(dirtyRect, rect.Width + 2.0f);              // fudge to counter hilite prob
            dirtyRect.Size = setRectHeight(dirtyRect, rect.Height + 2.0f);

            SetNeedsDisplayInRect(dirtyRect);

            currentEvent = NSApplication.SharedApplication.CurrentEvent;
            var eventFlags = currentEvent.ModifierFlags;

            shifted = (eventFlags & NSEventModifierMask.ShiftKeyMask) == NSEventModifierMask.ShiftKeyMask;

            if (!shifted)
            {
                switch (theEdge.ToString())
                {
                case STR_LEFT:
                    if (location > MaxX(rect) - MIN_SIZE)
                    {
                        location = MaxX(rect) - MIN_SIZE;
                    }

                    rect.Size     = setRectWidth(rect, MaxX(rect) - location);
                    rect.Location = setOriginX(rect, location);
                    break;

                case STR_RIGHT:
                    if (location < MinX(rect) + MIN_SIZE)
                    {
                        location = MinX(rect) + MIN_SIZE;
                    }

                    rect.Size = setRectWidth(rect, location - MinX(rect));
                    break;

                case STR_TOP:
                    if (this.IsFlipped)
                    {
                        if (location > MaxY(rect) - MIN_SIZE)
                        {
                            location = MaxY(rect) - MIN_SIZE;
                        }

                        rect.Size     = setRectHeight(rect, MaxY(rect) - location);
                        rect.Location = setOriginY(rect, location);
                    }
                    else
                    {
                        if (location < MinY(rect) + MIN_SIZE)
                        {
                            location = MinY(rect) + MIN_SIZE;
                        }

                        rect.Size = setRectHeight(rect, location - MinY(rect));
                    }
                    break;

                case STR_BOTTOM:
                    if (this.IsFlipped)
                    {
                        if (location < MinY(rect) + MIN_SIZE)
                        {
                            location = MinY(rect) + MIN_SIZE;
                        }

                        rect.Size = setRectHeight(rect, location - MinY(rect));
                    }
                    else
                    {
                        if (location > MaxY(rect) - MIN_SIZE)
                        {
                            location = MaxY(rect) - MIN_SIZE;
                        }

                        rect.Size     = setRectHeight(rect, MaxY(rect) - location);
                        rect.Location = setOriginY(rect, location);
                    }
                    break;
                }
            }
            else
            {
                NSRulerMarker [] markers = aRulerView.Markers;
                NSRulerMarker    otherMarker;

                otherMarker = markers [0];

                if (otherMarker == aMarker)
                {
                    otherMarker = markers [1];
                }

                switch (theEdge.ToString())
                {
                case STR_LEFT:
                    rect.Location = setOriginX(rect, location);
                    otherMarker.MarkerLocation = MaxX(rect);
                    break;

                case STR_RIGHT:
                    rect.Location = setOriginX(rect, location - rect.Width);
                    otherMarker.MarkerLocation = MinX(rect);
                    break;

                case STR_TOP:
                    if (this.IsFlipped)
                    {
                        rect.Location = setOriginY(rect, location);
                        otherMarker.MarkerLocation = MaxY(rect);
                    }
                    else
                    {
                        rect.Location = setOriginY(rect, location - rect.Height);
                        otherMarker.MarkerLocation = MinY(rect);
                    }
                    break;

                case STR_BOTTOM:
                    if (this.IsFlipped)
                    {
                        rect.Location = setOriginY(rect, location - rect.Height);
                        otherMarker.MarkerLocation = MinY(rect);
                    }
                    else
                    {
                        rect.Location = setOriginY(rect, location);
                        otherMarker.MarkerLocation = MaxY(rect);
                    }
                    break;
                }
            }

            selectedItem.Frame = rect;
            SetNeedsDisplayInRect(rect);

            return(location);
        }
Exemplo n.º 24
0
 public float RulerViewWillAddMarkeratLocation(NSRulerView ruler, NSRulerMarker marker, float location)
 {
     return RulerViewWillAddMarker (ruler, marker, location);
 }