• Open Menu Close Menu
  • Apple
  • Shopping Bag
  • Apple
  • Mac
  • iPad
  • iPhone
  • Watch
  • TV
  • Music
  • Support
  • Search apple.com
  • Shopping Bag

Lists

Open Menu Close Menu
  • Terms and Conditions
  • Lists hosted on this site
  • Email the Postmaster
  • Tips for posting to public mailing lists
Problems while using NSBezierPath
[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

Problems while using NSBezierPath


  • Subject: Problems while using NSBezierPath
  • From: Shrinivasa Kini <email@hidden>
  • Date: Fri, 26 Aug 2005 12:44:33 -0700

Hi all,

I am writing a piece of software which requires making some nodes and
links on a screen.
So I am writing a subclass of NSView and creating objects of
NSBezierPath for showing my Nodes and Links (basically line between 2
points).
In the NSView subclass - which I call GraphView - I override the
drawRect:(NSRect)rect method for drawing my objects. The Nodes come up
fine, but the bezierPaths created to show the links are never
displayed in the view. Here is a snippet of my GraphView code-

- (void)drawRect:(NSRect)rect
{
	if ( mode == NODEMODE )
	{
		NSRect r;
		NSBezierPath *bp;

		r = NSMakeRect(mouseLoc.x-10, mouseLoc.y-10, 20, 20);
		bp = [NSBezierPath bezierPathWithOvalInRect:r];
		[[NSColor blueColor] set];
		[bp fill];
		[bezierPathArr addObject:bp];

	}
	else if ( mode == LINKMODE )
	{
		NSBezierPath *bl = [[NSBezierPath alloc] init];

		[[NSColor blackColor] set];
		[NSBezierPath setDefaultLineWidth:5];
		[NSBezierPath setDefaultLineJoinStyle:NSRoundLineCapStyle];
		NSRect rect1 = [(NSBezierPath*)[bezierPathArr
objectAtIndex:firstSelectedBezierPath] bounds];
		NSRect rect2 = [(NSBezierPath*)[bezierPathArr
objectAtIndex:secondSelectedBezierPath] bounds];

		[bl moveToPoint:NSMakePoint(rect1.origin.x+30,rect1.origin.y+30)];
		[bl lineToPoint:NSMakePoint(rect2.origin.x+30,rect2.origin.y+30)];

	}
}

bezierPathArr is an array which stores all the nodes created.
firstSelectedBezierPath and secondSelectedBezierPath are integers
which store the indices of the 2 selected bezierPath nodes between
which the link is being drawn.
I tried creating the link without setting the default parameters, but
it still doesn't work.

Am I missing something?
Any help will be highly appreciated.

Thanks,
Shrini
 _______________________________________________
Do not post admin requests to the list. They will be ignored.
Cocoa-dev mailing list      (email@hidden)
Help/Unsubscribe/Update your Subscription:

This email sent to email@hidden

  • Follow-Ups:
    • Re: Problems while using NSBezierPath
      • From: James Chen <email@hidden>
  • Prev by Date: Re: what happend of the .hidden file in Tiger?
  • Next by Date: Re: Focus ring annoyance
  • Previous by thread: Re: NSTokenField
  • Next by thread: Re: Problems while using NSBezierPath
  • Index(es):
    • Date
    • Thread