On 24/02/2009, at 11:15 PM, rajesh wrote:

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


Subviews are drawn "on top" because conceptually they are in front.

My advice is general: don't (ab)use NSViews like this. I've seen quite a few people doing this lately, or trying to, and it's actually one of the first things that Apple advise against in the drawing guide. Using an entire NSView to act as a moveable graphic within a larger view is using a sledgehammer to crack a nut. It's very unscalable and will quickly suffer from performance issues.

It's much easier to create lightweight drawing objects that are drawn within one view. Apart from being much faster, you can overlay lines or other things on top as you wish - it gives you much more control.

--Graham


_______________________________________________

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

Reply via email to