Esempio n. 1
0
        private void setRulerOffsets()
        {
            NSScrollView scrollView = EnclosingScrollView;
            NSRulerView  horizRuler = null;
            NSRulerView  vertRuler;
            NSView       docView;
            NSView       clientView;
            PointF       zero = PointF.Empty;

            docView    = (NSView)scrollView.DocumentView;
            clientView = this;

            if (scrollView == null)
            {
                return;
            }

            horizRuler = scrollView.HorizontalRulerView;
            vertRuler  = scrollView.VerticalRulerView;

            zero = docView.ConvertPointFromView(clientView.Bounds.Location, clientView);

            horizRuler.OriginOffset = zero.X - docView.Bounds.Location.X;
            vertRuler.OriginOffset  = zero.Y - docView.Bounds.Location.Y;
        }
Esempio n. 2
0
        public bool rulerViewShouldMoveMarker(NSRulerView aRulerView, NSRulerMarker aMarker)
        {
            if (selectedItem == null || selectedItem.IsLocked)
            {
                return(false);
            }

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

            SetNeedsDisplayInRect(selectedItem.Frame);
            rects.Remove(selectedItem);
            selectedItem = null;
            updateRulers();
        }
Esempio n. 4
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);
        }
Esempio n. 5
0
        // Shared initialization code
        void Initialize()
        {
            if (beenHere)
            {
                return;
            }

            beenHere = true;

            // Moved from the initWithFrame constructor because it was giving a
            // not initialized correctly message.
            RectangleF aRect;
            ColorRect  firstRect;

            SetBoundsOrigin(new PointF(-108.0f, -108.0f));

            rects        = new List <ColorRect> ();
            selectedItem = null;

            aRect     = new RectangleF(30.0f, 45.0f, 57.0f, 118.0f);
            firstRect = new ColorRect(aRect, NSColor.Blue);
            rects.Add(firstRect);

            //-------------------------------------------------------------------

            NSBundle mainBundle;
            string   path;

            mainBundle = NSBundle.MainBundle;
            path       = mainBundle.PathForResource("EdgeMarkerLeft", "tiff");
            leftImage  = new NSImage(path);

            path       = mainBundle.PathForResource("EdgeMarkerRight", "tiff");
            rightImage = new NSImage(path);

            path     = mainBundle.PathForResource("EdgeMarkerTop", "tiff");
            topImage = new NSImage(path);

            path        = mainBundle.PathForResource("EdgeMarkerBottom", "tiff");
            bottomImage = new NSImage(path);

            upArray   = new NSNumber[] { NSNumber.FromDouble(2.0) };
            downArray = new NSNumber[] { NSNumber.FromDouble(0.5),
                                         NSNumber.FromDouble(0.2) };

            // Setup our custom ruler units
            NSRulerView.RegisterUnit("MyCustomRulerUnits", "mcru", 100.0f, upArray, downArray);
        }
Esempio n. 6
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;
        }
Esempio n. 7
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);
        }
Esempio n. 8
0
 public float RulerViewWillMoveMarkertoLocation(NSRulerView ruler, NSRulerMarker marker, float location)
 {
     return(RulerViewWillMoveMarker(ruler, marker, location));
 }
Esempio n. 9
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;	
		}
Esempio n. 10
0
 public void rulerViewWillSetClientView(NSRulerView aRulerView, NSView newClient)
 {
     return;
 }
Esempio n. 11
0
		public void rulerViewDidMoveMarker (NSRulerView aRulerView, NSRulerMarker aMarker)
		{
			updateSelectedRectFromRulers ();
		}
Esempio n. 12
0
 public bool rulerViewShouldAddMarker(NSRulerView aRulerView, NSRulerMarker aMarker)
 {
     return(true);
 }
Esempio n. 13
0
 public float rulerViewWillAddMarker(NSRulerView aRulerView, NSRulerMarker aMarker, float location)
 {
     return(location);
 }
Esempio n. 14
0
 public float RulerViewWillMoveMarkertoLocation(NSRulerView ruler, NSRulerMarker marker, float location)
 {
     return RulerViewWillMoveMarker (ruler, marker, location);
 }
Esempio n. 15
0
		public bool rulerViewShouldRemoveMarker (NSRulerView aRulerView, NSRulerMarker aMarker)
		{
			if (selectedItem != null && !selectedItem.IsLocked) 
				return true;
			
			return false;
		}
Esempio n. 16
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 };
        }
Esempio n. 17
0
		public void rulerViewDidRemoveMarker (NSRulerView aRulerView, NSRulerMarker aMarker)
		{
			if (selectedItem == null) 
				return;
			
			SetNeedsDisplayInRect (selectedItem.Frame);
			rects.Remove (selectedItem);
			selectedItem = null;
			updateRulers ();
		}
Esempio n. 18
0
		public void rulerViewWillSetClientView (NSRulerView aRulerView, NSView newClient)
		{
			return;
		}		
Esempio n. 19
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);
		}	
Esempio n. 20
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);
		}		
Esempio n. 21
0
		public float rulerViewWillAddMarker (NSRulerView aRulerView, NSRulerMarker aMarker, float location)
		{
			return location;	
		}
Esempio n. 22
0
		public bool rulerViewShouldAddMarker (NSRulerView aRulerView, NSRulerMarker aMarker)
		{
			return true;	
		}
Esempio n. 23
0
 public float RulerViewWillAddMarkeratLocation(NSRulerView ruler, NSRulerMarker marker, float location)
 {
     return(RulerViewWillAddMarker(ruler, marker, location));
 }
Esempio n. 24
0
 public void rulerViewDidMoveMarker(NSRulerView aRulerView, NSRulerMarker aMarker)
 {
     updateSelectedRectFromRulers();
 }
Esempio n. 25
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);
        }
Esempio n. 26
0
 public float RulerViewWillAddMarkeratLocation(NSRulerView ruler, NSRulerMarker marker, float location)
 {
     return RulerViewWillAddMarker (ruler, marker, location);
 }