Hi All,
Sorry for the bad subject line,
Need help with drawing (I have done some basic drawings in Cocoa)
Problem:
I have a View which in-turn has subviews(elements) e.g.,
chocolates ,balloons,roses , etc.,
These elements have complex drawings and are subclasses of NSView.
I place these elements on to the view with some gaps/space in between
(exposed part of main view), so far good , but I am really stuck at a
point where I have to draw a line/lines which connect all the like
elements or something like that.
When I attempt to draw a line joining the elements , line is drawn
then subViews are placed over it , but I want the other way around.
There should be something fundamental flaw or I am missing the big
picture.
I know that drawRect: is called first and the subViews are placed.
How should make my code to work as Intended
Any help is appreciated
and I did go through the basic drawing concepts and Googled for
something of my requirement
Thanks
~Rajesh
Code goes something like this:
- (void)drawRect:(NSRect)rect {
//for now just draw a sample line diagonally.
[[NSColor blackColor] set];
NSBezierPath *sample = [NSBezierPath bezierPath];
[sample moveToPoint:NSMakePoint(0,0)];
[sample lineToPoint:NSMakePoint(500, 500)];
[sample stroke];
}
- (void)layout {
//NSAutoreleasePool *pool = [[NSAutoreleasePool alloc] init];
// NSLog(@"layout poloMainView");
NSMutableArray *subviews = [NSMutableArray arrayWithArray:[self
subviews]];
for( i = 0 ; i < (count - 1) ; i++)
{
Element *subview = [subviews objectAtIndex:i ];
// do the placing of the view accordingly
}
}
- (IBAction)addElement:(id)sender
{
Element *box = [[[Element alloc] initWithFrame:NSMakeRect(0.0, 0.0,
PAGEWIDTH, PAGEHEIGHT)] autorelease];
[self addSubview:box];
[self layout];
}
_______________________________________________
Cocoa-dev mailing list (Cocoa-dev@lists.apple.com)
Please do not post admin requests or moderator comments to the list.
Contact the moderators at cocoa-dev-admins(at)lists.apple.com
Help/Unsubscribe/Update your Subscription:
http://lists.apple.com/mailman/options/cocoa-dev/archive%40mail-archive.com
This email sent to arch...@mail-archive.com